From 3a32ef79cf6bde5074fc15dc222e65da17e34509 Mon Sep 17 00:00:00 2001 From: "Stanislav (Stas) Katkov" Date: Fri, 27 Dec 2024 23:03:01 +0100 Subject: [PATCH] Don't include ruby documentation --- .gitignore | 5 +- Rakefile | 7 +- example/ruby/A.md | 7 - example/ruby/ACRONYM.md | 6 - example/ruby/Action.md | 22 - example/ruby/ActionFilter.md | 26 - example/ruby/ActionMap.md | 47 - example/ruby/Addrinfo.md | 516 -- example/ruby/Alias0.md | 10 - example/ruby/Alias1.md | 12 - example/ruby/Alias2.md | 7 - example/ruby/Alias3.md | 14 - example/ruby/AliasObject.md | 26 - example/ruby/AllPairs.md | 16 - example/ruby/AnError.md | 9 - example/ruby/Apache.md | 12 - example/ruby/Apache/Request.md | 47 - example/ruby/ApplicationController.md | 10 - example/ruby/ArbitraryException.md | 7 - example/ruby/ArgumentError.md | 32 - example/ruby/Array.md | 4567 -------------- example/ruby/ArrayCode.md | 18 - example/ruby/ArraySpec.md | 6 - example/ruby/ArraySpec/SideEffect.md | 20 - example/ruby/ArraySpec/Splat.md | 12 - example/ruby/ArraySpecs.md | 23 - example/ruby/ArraySpecs/ArrayConvertible.md | 20 - example/ruby/ArraySpecs/ArrayMethodMissing.md | 14 - example/ruby/ArraySpecs/AssocKey.md | 10 - .../ruby/ArraySpecs/ComparableWithInteger.md | 99 - example/ruby/ArraySpecs/D.md | 10 - example/ruby/ArraySpecs/MockForCompared.md | 18 - example/ruby/ArraySpecs/MyArray.md | 15 - example/ruby/ArraySpecs/MyRange.md | 7 - example/ruby/ArraySpecs/PrivateToAry.md | 7 - example/ruby/ArraySpecs/Sexp.md | 12 - example/ruby/ArraySpecs/SortSame.md | 12 - example/ruby/ArraySpecs/SubArray.md | 12 - example/ruby/ArraySpecs/ToAryArray.md | 12 - example/ruby/ArraySpecs/UFOSceptic.md | 10 - example/ruby/ArraySpecs/Uncomparable.md | 10 - example/ruby/ArraySub.md | 12 - example/ruby/ArraySubPush.md | 10 - example/ruby/Artifice.md | 18 - example/ruby/Artifice/Net.md | 6 - example/ruby/Artifice/Net/HTTP.md | 32 - example/ruby/Artifice/Net/RackRequest.md | 20 - example/ruby/Assertion.md | 67 - example/ruby/AutoIndent.md | 9 - example/ruby/AvailableOLE.md | 17 - example/ruby/B.md | 6 - example/ruby/Bar.md | 14 - example/ruby/BaseFormatter.md | 69 - example/ruby/BasicObject.md | 251 - example/ruby/BasicObjectSpecs.md | 6 - example/ruby/BasicObjectSpecs/BOSubclass.md | 1951 ------ example/ruby/BasicObjectSpecs/IVars.md | 12 - example/ruby/BasicObjectSpecs/InstEval.md | 6 - .../ruby/BasicObjectSpecs/InstEval/CVar.md | 6 - .../BasicObjectSpecs/InstEval/CVar/Get.md | 6 - .../InstEval/CVar/Get/BlockDefinitionScope.md | 10 - .../InstEval/CVar/Get/CallerScope.md | 12 - .../CVar/Get/CallerWithoutCVarScope.md | 10 - .../InstEval/CVar/Get/ReceiverScope.md | 7 - .../BasicObjectSpecs/InstEval/CVar/Set.md | 6 - .../InstEval/CVar/Set/BlockDefinitionScope.md | 12 - .../InstEval/CVar/Set/CallerScope.md | 14 - .../InstEval/CVar/Set/ReceiverScope.md | 7 - .../BasicObjectSpecs/InstEval/Constants.md | 6 - .../Constants/ConstantInCallerClass.md | 6 - .../ConstantInCallerClass/CallerScope.md | 6 - .../CallerScope/Caller.md | 10 - .../CallerScope/CallerParent.md | 7 - .../ConstantInCallerClass/ReceiverScope.md | 6 - .../ReceiverScope/Receiver.md | 7 - .../ReceiverScope/ReceiverParent.md | 7 - .../Constants/ConstantInCallerOuterScopes.md | 6 - .../CallerScope.md | 6 - .../CallerScope/Caller.md | 11 - .../CallerScope/CallerParent.md | 7 - .../ReceiverScope.md | 6 - .../ReceiverScope/Receiver.md | 7 - .../ReceiverScope/ReceiverParent.md | 7 - .../Constants/ConstantInReceiverClass.md | 6 - .../ConstantInReceiverClass/CallerScope.md | 6 - .../CallerScope/Caller.md | 10 - .../CallerScope/CallerParent.md | 7 - .../ConstantInReceiverClass/ReceiverScope.md | 6 - .../ReceiverScope/Receiver.md | 7 - .../ReceiverScope/ReceiverParent.md | 7 - .../ConstantInReceiverParentClass.md | 6 - .../CallerScope.md | 6 - .../CallerScope/Caller.md | 11 - .../CallerScope/CallerParent.md | 8 - .../ReceiverScope.md | 6 - .../ReceiverScope/Receiver.md | 7 - .../ReceiverScope/ReceiverParent.md | 7 - .../ConstantInReceiverSingletonClass.md | 6 - .../CallerScope.md | 6 - .../CallerScope/Caller.md | 10 - .../CallerScope/CallerParent.md | 7 - .../ReceiverScope.md | 6 - .../ReceiverScope/Receiver.md | 12 - .../ReceiverScope/ReceiverParent.md | 7 - .../ruby/BasicObjectSpecs/InstEvalConst.md | 7 - .../ruby/BasicObjectSpecs/InstEvalOuter.md | 6 - .../BasicObjectSpecs/InstEvalOuter/Inner.md | 6 - example/ruby/BasicObjectSpecs/InstExec.md | 10 - .../ruby/BasicObjectSpecs/InstExecIncluded.md | 8 - .../ruby/BasicObjectSpecs/SingletonMethod.md | 10 - example/ruby/BasicSocket.md | 514 -- example/ruby/BeAnInOfSpecs.md | 6 - example/ruby/BeAnInOfSpecs/A.md | 7 - example/ruby/BeAnInOfSpecs/B.md | 7 - example/ruby/BeAnInOfSpecs/C.md | 7 - example/ruby/BeAnInstanceOfMatcher.md | 20 - example/ruby/BeAncestorOfMatcher.md | 20 - example/ruby/BeCloseMatcher.md | 20 - example/ruby/BeCloseToMatrixMatcher.md | 20 - example/ruby/BeComputedByMatcher.md | 20 - example/ruby/BeEmptyMatcher.md | 16 - example/ruby/BeFalseMatcher.md | 16 - example/ruby/BeKindOfMatcher.md | 20 - example/ruby/BeNaNMatcher.md | 16 - example/ruby/BeNilMatcher.md | 16 - example/ruby/BeTrueMatcher.md | 16 - example/ruby/BeTrueOrFalseMatcher.md | 16 - example/ruby/Benchmark.md | 224 - example/ruby/Benchmark/Job.md | 30 - example/ruby/Benchmark/Report.md | 32 - example/ruby/Benchmark/Tms.md | 109 - example/ruby/BenchmarkDriver/Output/Driver.md | 15 - example/ruby/BenchmarkDriver/Runner/Cstime.md | 7 - example/ruby/BenchmarkDriver/Runner/Cutime.md | 7 - example/ruby/BenchmarkDriver/Runner/Peak.md | 23 - example/ruby/BenchmarkDriver/Runner/Ractor.md | 8 - example/ruby/BenchmarkDriver/Runner/Size.md | 8 - example/ruby/BenchmarkDriver/Runner/Stime.md | 7 - example/ruby/BenchmarkDriver/Runner/Total.md | 23 - example/ruby/BenchmarkDriver/Runner/Utime.md | 7 - example/ruby/Biff.md | 16 - example/ruby/BigDecimal.md | 44 - example/ruby/BigDecimalSpecs.md | 10 - example/ruby/BigEndianGuard.md | 12 - example/ruby/Binding.md | 122 - example/ruby/BindingGenerator.md | 35 - example/ruby/BindingSpecs.md | 6 - example/ruby/BindingSpecs/AddFooToString.md | 6 - example/ruby/BindingSpecs/Demo.md | 32 - example/ruby/BindingSpecs/LocationMethod.md | 6 - example/ruby/BindingSpecs/Refined.md | 9 - example/ruby/BlockDeviceGuard.md | 12 - example/ruby/BlockSpecs.md | 6 - .../ruby/BlockSpecs/OverwriteBlockVariable.md | 14 - example/ruby/BlockSpecs/Yield.md | 27 - example/ruby/BlockSpecs/Yielder.md | 26 - example/ruby/BlockingMatcher.md | 16 - example/ruby/Board.md | 38 - example/ruby/Book.md | 10 - example/ruby/Book/Page.md | 12 - example/ruby/Book/Spine.md | 7 - example/ruby/Book/TableOfContents.md | 7 - example/ruby/Branch.md | 29 - example/ruby/BreakSpecs.md | 6 - example/ruby/BreakSpecs/Block.md | 40 - example/ruby/BreakSpecs/Driver.md | 14 - example/ruby/BreakSpecs/Lambda.md | 36 - example/ruby/BrokenUnblockScheduler.md | 13 - example/ruby/Bug.md | 35 - example/ruby/Bug/Array.md | 10 - example/ruby/Bug/Array/DataError.md | 7 - example/ruby/Bug/Bar.md | 10 - example/ruby/Bug/Bignum.md | 10 - example/ruby/Bug/Bug7802.md | 7 - example/ruby/Bug/Class.md | 9 - example/ruby/Bug/Class/Loop.md | 6 - example/ruby/Bug/Class/VersionMax.md | 6 - example/ruby/Bug/Class/VersionZero.md | 6 - example/ruby/Bug/Debug.md | 6 - example/ruby/Bug/EnumeratorKw.md | 9 - example/ruby/Bug/Exception.md | 32 - example/ruby/Bug/File.md | 9 - example/ruby/Bug/File/NewlineConv.md | 9 - example/ruby/Bug/File/Stat.md | 26 - example/ruby/Bug/Float.md | 14 - example/ruby/Bug/Float/Breakable.md | 9 - example/ruby/Bug/Float/Yield.md | 9 - example/ruby/Bug/Hash.md | 7 - example/ruby/Bug/Integer.md | 7 - example/ruby/Bug/Iter.md | 6 - example/ruby/Bug/Marshal.md | 6 - example/ruby/Bug/Marshal/TestInternalIVar.md | 10 - example/ruby/Bug/Marshal/TestUsrMarshal.md | 16 - example/ruby/Bug/Method.md | 6 - example/ruby/Bug/NotImplement.md | 34 - example/ruby/Bug/NotImplement/MyInteger.md | 9 - example/ruby/Bug/Proc.md | 6 - example/ruby/Bug/Rational.md | 36 - example/ruby/Bug/RbCallSuperKw.md | 9 - example/ruby/Bug/Regexp.md | 25 - example/ruby/Bug/ScanArgs.md | 39 - example/ruby/Bug/StNumHash.md | 7 - example/ruby/Bug/StNumHash/Test_NumHash.md | 18 - example/ruby/Bug/StTable.md | 7 - example/ruby/Bug/StTable/Test_Update.md | 20 - example/ruby/Bug/String.md | 9 - example/ruby/Bug/Struct.md | 7 - example/ruby/Bug/Struct/Test_Data.md | 12 - example/ruby/Bug/Struct/Test_Duplicate.md | 12 - example/ruby/Bug/Struct/Test_Len.md | 10 - example/ruby/Bug/Struct/Test_Member.md | 10 - example/ruby/Bug/Symbol.md | 25 - example/ruby/Bug/Test_ExceptionAT.md | 10 - example/ruby/Bug/Test_ExceptionDE.md | 10 - example/ruby/Bug/Test_ExceptionE.md | 10 - example/ruby/Bug/Test_ExceptionER.md | 10 - example/ruby/Bug/Thread.md | 9 - example/ruby/Bug/ThreadInstrumentation.md | 10 - example/ruby/Bug/Time.md | 16 - example/ruby/Bug/Time/Test_New.md | 16 - example/ruby/Bug/TypedData.md | 23 - example/ruby/Bug/VM.md | 9 - example/ruby/Bug/Win32.md | 16 - example/ruby/Bug/Win32/TestDln.md | 12 - example/ruby/Bug/Win32/TestFdSetSize.md | 12 - example/ruby/BugGuard.md | 16 - example/ruby/BundledGem.md | 16 - example/ruby/Bundler.md | 180 - .../APIResponseInvalidDependenciesError.md | 7 - .../ruby/Bundler/APIResponseMismatchError.md | 7 - example/ruby/Bundler/BuildMetadata.md | 18 - example/ruby/Bundler/BundlerError.md | 10 - example/ruby/Bundler/CIDetector.md | 11 - example/ruby/Bundler/CLI.md | 600 -- example/ruby/Bundler/CLI/Add.md | 24 - example/ruby/Bundler/CLI/Binstubs.md | 21 - example/ruby/Bundler/CLI/Cache.md | 18 - example/ruby/Bundler/CLI/Check.md | 18 - example/ruby/Bundler/CLI/Clean.md | 18 - example/ruby/Bundler/CLI/Common.md | 25 - example/ruby/Bundler/CLI/Config.md | 18 - example/ruby/Bundler/CLI/Config/Base.md | 48 - example/ruby/Bundler/CLI/Console.md | 25 - example/ruby/Bundler/CLI/Doctor.md | 36 - example/ruby/Bundler/CLI/Exec.md | 24 - example/ruby/Bundler/CLI/Fund.md | 18 - example/ruby/Bundler/CLI/Gem.md | 33 - example/ruby/Bundler/CLI/Info.md | 21 - example/ruby/Bundler/CLI/Init.md | 18 - example/ruby/Bundler/CLI/Inject.md | 33 - example/ruby/Bundler/CLI/Install.md | 18 - example/ruby/Bundler/CLI/Issue.md | 12 - example/ruby/Bundler/CLI/List.md | 16 - example/ruby/Bundler/CLI/Lock.md | 18 - example/ruby/Bundler/CLI/Open.md | 26 - example/ruby/Bundler/CLI/Outdated.md | 36 - example/ruby/Bundler/CLI/Platform.md | 18 - example/ruby/Bundler/CLI/Plugin.md | 14 - example/ruby/Bundler/CLI/Pristine.md | 14 - example/ruby/Bundler/CLI/Remove.md | 16 - example/ruby/Bundler/CLI/Show.md | 24 - example/ruby/Bundler/CLI/Update.md | 21 - example/ruby/Bundler/CLI/Viz.md | 21 - example/ruby/Bundler/Checksum.md | 56 - example/ruby/Bundler/Checksum/Source.md | 32 - example/ruby/Bundler/Checksum/Store.md | 33 - example/ruby/Bundler/ChecksumMismatchError.md | 16 - example/ruby/Bundler/CompactIndexClient.md | 57 - .../ruby/Bundler/CompactIndexClient/Cache.md | 24 - .../Bundler/CompactIndexClient/CacheFile.md | 70 - .../CacheFile/ClosedError.md | 7 - .../CacheFile/DigestMismatchError.md | 12 - .../CompactIndexClient/CacheFile/Error.md | 7 - .../ruby/Bundler/CompactIndexClient/Error.md | 7 - .../Bundler/CompactIndexClient/GemParser.md | 10 - .../ruby/Bundler/CompactIndexClient/Parser.md | 25 - .../Bundler/CompactIndexClient/Updater.md | 14 - .../Updater/MismatchedChecksumError.md | 12 - example/ruby/Bundler/ConnectionPool.md | 78 - example/ruby/Bundler/ConnectionPool/Error.md | 7 - .../Bundler/ConnectionPool/ForkTracker.md | 9 - .../ConnectionPool/PoolShuttingDownError.md | 7 - .../ruby/Bundler/ConnectionPool/TimedStack.md | 60 - .../Bundler/ConnectionPool/TimeoutError.md | 7 - .../ruby/Bundler/ConnectionPool/Wrapper.md | 28 - .../Bundler/CorruptBundlerInstallError.md | 14 - example/ruby/Bundler/CurrentRuby.md | 36 - example/ruby/Bundler/CyclicDependencyError.md | 7 - example/ruby/Bundler/Definition.md | 197 - example/ruby/Bundler/Dependency.md | 71 - example/ruby/Bundler/Deployment.md | 9 - example/ruby/Bundler/Deprecate.md | 11 - example/ruby/Bundler/DeprecatedError.md | 7 - example/ruby/Bundler/Digest.md | 8 - example/ruby/Bundler/DirectoryRemovalError.md | 12 - example/ruby/Bundler/Dsl.md | 81 - example/ruby/Bundler/Dsl/DSLError.md | 58 - example/ruby/Bundler/EndpointSpecification.md | 83 - example/ruby/Bundler/Env.md | 11 - example/ruby/Bundler/EnvironmentPreserver.md | 29 - example/ruby/Bundler/FeatureFlag.md | 12 - example/ruby/Bundler/FetchMetadata.md | 18 - example/ruby/Bundler/Fetcher.md | 49 - .../Fetcher/AuthenticationForbiddenError.md | 14 - .../Fetcher/AuthenticationRequiredError.md | 13 - .../Bundler/Fetcher/BadAuthenticationError.md | 13 - example/ruby/Bundler/Fetcher/Base.md | 37 - .../Fetcher/CertificateFailureError.md | 13 - example/ruby/Bundler/Fetcher/CompactIndex.md | 22 - .../Fetcher/CompactIndex/ClientFetcher.md | 10 - example/ruby/Bundler/Fetcher/Dependency.md | 26 - example/ruby/Bundler/Fetcher/Downloader.md | 25 - example/ruby/Bundler/Fetcher/FallbackError.md | 8 - .../ruby/Bundler/Fetcher/GemRemoteFetcher.md | 10 - example/ruby/Bundler/Fetcher/Index.md | 10 - .../ruby/Bundler/Fetcher/NetworkDownError.md | 8 - example/ruby/Bundler/Fetcher/SSLError.md | 13 - .../Bundler/Fetcher/TooManyRequestsError.md | 8 - example/ruby/Bundler/FileUtils.md | 1779 ------ example/ruby/Bundler/FileUtils/DryRun.md | 78 - example/ruby/Bundler/FileUtils/Entry_.md | 103 - example/ruby/Bundler/FileUtils/LowMethods.md | 7 - example/ruby/Bundler/FileUtils/NoWrite.md | 78 - .../ruby/Bundler/FileUtils/StreamUtils_.md | 7 - example/ruby/Bundler/FileUtils/Verbose.md | 78 - example/ruby/Bundler/ForcePlatform.md | 13 - example/ruby/Bundler/FriendlyErrors.md | 19 - example/ruby/Bundler/GemHelper.md | 44 - example/ruby/Bundler/GemHelpers.md | 21 - .../ruby/Bundler/GemHelpers/PlatformMatch.md | 12 - example/ruby/Bundler/GemInstaller.md | 33 - example/ruby/Bundler/GemNotFound.md | 7 - example/ruby/Bundler/GemRequireError.md | 16 - example/ruby/Bundler/GemVersionPromoter.md | 76 - example/ruby/Bundler/GemfileError.md | 7 - example/ruby/Bundler/GemfileEvalError.md | 7 - example/ruby/Bundler/GemfileLockNotFound.md | 7 - example/ruby/Bundler/GemfileNotFound.md | 7 - example/ruby/Bundler/GemspecError.md | 7 - .../ruby/Bundler/GenericSystemCallError.md | 16 - example/ruby/Bundler/GitError.md | 7 - example/ruby/Bundler/Graph.md | 33 - example/ruby/Bundler/Graph/GraphVizClient.md | 16 - example/ruby/Bundler/HTTPError.md | 10 - .../Bundler/IncorrectLockfileDependencies.md | 16 - example/ruby/Bundler/Index.md | 2129 ------- example/ruby/Bundler/Injector.md | 31 - .../ruby/Bundler/InsecureInstallPathError.md | 14 - example/ruby/Bundler/InstallError.md | 7 - example/ruby/Bundler/InstallHookError.md | 7 - example/ruby/Bundler/Installer.md | 66 - example/ruby/Bundler/InvalidArgumentError.md | 7 - example/ruby/Bundler/InvalidOption.md | 7 - example/ruby/Bundler/LazySpecification.md | 139 - example/ruby/Bundler/LockfileError.md | 7 - example/ruby/Bundler/LockfileGenerator.md | 25 - example/ruby/Bundler/LockfileParser.md | 45 - .../ruby/Bundler/LockfileParser/Position.md | 23 - example/ruby/Bundler/MarshalError.md | 7 - example/ruby/Bundler/MatchMetadata.md | 19 - example/ruby/Bundler/MatchPlatform.md | 15 - example/ruby/Bundler/MatchRemoteMetadata.md | 21 - example/ruby/Bundler/Materialization.md | 32 - example/ruby/Bundler/MirrorSockets.md | 22 - example/ruby/Bundler/NoSpaceOnDeviceError.md | 10 - .../Bundler/OperationNotSupportedError.md | 10 - example/ruby/Bundler/ParallelInstaller.md | 20 - .../ParallelInstaller/SpecInstallation.md | 70 - example/ruby/Bundler/PathError.md | 7 - example/ruby/Bundler/PermissionError.md | 20 - example/ruby/Bundler/Persistent.md | 6 - example/ruby/Bundler/Persistent/Net.md | 6 - example/ruby/Bundler/Persistent/Net/HTTP.md | 6 - example/ruby/Bundler/Plugin.md | 130 - example/ruby/Bundler/Plugin/API.md | 41 - example/ruby/Bundler/Plugin/API/Source.md | 236 - example/ruby/Bundler/Plugin/DSL.md | 32 - .../Bundler/Plugin/DSL/PluginGemfileError.md | 7 - example/ruby/Bundler/Plugin/Events.md | 13 - example/ruby/Bundler/Plugin/Index.md | 72 - .../Bundler/Plugin/Index/CommandConflict.md | 12 - .../Bundler/Plugin/Index/SourceConflict.md | 12 - example/ruby/Bundler/Plugin/Installer.md | 18 - example/ruby/Bundler/Plugin/Installer/Git.md | 16 - example/ruby/Bundler/Plugin/Installer/Path.md | 12 - .../ruby/Bundler/Plugin/Installer/Rubygems.md | 7 - .../ruby/Bundler/Plugin/MalformattedPlugin.md | 7 - .../ruby/Bundler/Plugin/PluginInstallError.md | 7 - example/ruby/Bundler/Plugin/SourceList.md | 16 - .../Bundler/Plugin/UndefinedCommandError.md | 7 - .../ruby/Bundler/Plugin/UnknownSourceError.md | 7 - example/ruby/Bundler/PluginError.md | 7 - example/ruby/Bundler/ProcessLock.md | 9 - example/ruby/Bundler/ProductionError.md | 7 - example/ruby/Bundler/PubGrub.md | 9 - example/ruby/Bundler/PubGrub/Assignment.md | 31 - .../Bundler/PubGrub/BasicPackageSource.md | 99 - example/ruby/Bundler/PubGrub/FailureWriter.md | 14 - .../ruby/Bundler/PubGrub/Incompatibility.md | 43 - .../PubGrub/Incompatibility/ConflictCause.md | 18 - .../Incompatibility/InvalidDependency.md | 18 - .../PubGrub/Incompatibility/NoVersions.md | 13 - example/ruby/Bundler/PubGrub/Package.md | 28 - .../ruby/Bundler/PubGrub/PartialSolution.md | 41 - example/ruby/Bundler/PubGrub/RubyGems.md | 22 - example/ruby/Bundler/PubGrub/SolveFailure.md | 20 - .../Bundler/PubGrub/StaticPackageSource.md | 22 - .../PubGrub/StaticPackageSource/DSL.md | 18 - example/ruby/Bundler/PubGrub/Term.md | 62 - .../ruby/Bundler/PubGrub/VersionConstraint.md | 80 - example/ruby/Bundler/PubGrub/VersionRange.md | 100 - .../Bundler/PubGrub/VersionRange/Empty.md | 48 - example/ruby/Bundler/PubGrub/VersionSolver.md | 31 - example/ruby/Bundler/PubGrub/VersionUnion.md | 63 - example/ruby/Bundler/RemoteSpecification.md | 179 - example/ruby/Bundler/Resolver.md | 53 - example/ruby/Bundler/Resolver/Base.md | 36 - example/ruby/Bundler/Resolver/Candidate.md | 132 - .../ruby/Bundler/Resolver/Incompatibility.md | 16 - example/ruby/Bundler/Resolver/Package.md | 81 - example/ruby/Bundler/Resolver/Root.md | 22 - example/ruby/Bundler/Resolver/SpecGroup.md | 36 - example/ruby/Bundler/Retry.md | 28 - example/ruby/Bundler/RubyDsl.md | 26 - example/ruby/Bundler/RubyGemsGemInstaller.md | 26 - example/ruby/Bundler/RubyVersion.md | 60 - example/ruby/Bundler/RubyVersionMismatch.md | 7 - example/ruby/Bundler/RubygemsIntegration.md | 132 - example/ruby/Bundler/Runtime.md | 109 - example/ruby/Bundler/SafeMarshal.md | 8 - example/ruby/Bundler/SecureRandom.md | 266 - example/ruby/Bundler/SecurityError.md | 7 - example/ruby/Bundler/SelfManager.md | 16 - example/ruby/Bundler/Settings.md | 53 - example/ruby/Bundler/Settings/Mirror.md | 32 - example/ruby/Bundler/Settings/MirrorConfig.md | 30 - example/ruby/Bundler/Settings/Mirrors.md | 26 - example/ruby/Bundler/Settings/Path.md | 33 - .../ruby/Bundler/Settings/TCPSocketProbe.md | 13 - example/ruby/Bundler/Settings/Validator.md | 9 - .../ruby/Bundler/Settings/Validator/Rule.md | 26 - example/ruby/Bundler/SharedHelpers.md | 152 - example/ruby/Bundler/SimilarityDetector.md | 20 - .../SimilarityDetector/SimilarityScore.md | 18 - example/ruby/Bundler/SocketAddress.md | 28 - example/ruby/Bundler/SolveFailure.md | 8 - example/ruby/Bundler/Source.md | 56 - example/ruby/Bundler/Source/Gemspec.md | 18 - example/ruby/Bundler/Source/Git.md | 98 - .../Source/Git/AmbiguousGitReference.md | 12 - .../Bundler/Source/Git/GitCommandError.md | 16 - .../Bundler/Source/Git/GitNotAllowedError.md | 12 - .../Source/Git/GitNotInstalledError.md | 12 - example/ruby/Bundler/Source/Git/GitProxy.md | 49 - .../Source/Git/MissingGitRevisionError.md | 12 - example/ruby/Bundler/Source/Metadata.md | 22 - example/ruby/Bundler/Source/Path.md | 53 - example/ruby/Bundler/Source/Path/Installer.md | 18 - example/ruby/Bundler/Source/Rubygems.md | 86 - .../ruby/Bundler/Source/Rubygems/Remote.md | 29 - .../ruby/Bundler/Source/RubygemsAggregate.md | 25 - example/ruby/Bundler/SourceList.md | 94 - example/ruby/Bundler/SourceMap.md | 30 - example/ruby/Bundler/SpecSet.md | 2255 ------- example/ruby/Bundler/Standalone.md | 14 - example/ruby/Bundler/StubSpecification.md | 75 - example/ruby/Bundler/TSort.md | 361 -- example/ruby/Bundler/TSort/Cyclic.md | 7 - .../ruby/Bundler/TemporaryResourceError.md | 10 - example/ruby/Bundler/Thor.md | 296 - example/ruby/Bundler/Thor/Actions.md | 539 -- .../Bundler/Thor/Actions/CapturableERB.md | 12 - .../ruby/Bundler/Thor/Actions/ClassMethods.md | 25 - .../ruby/Bundler/Thor/Actions/CreateFile.md | 34 - .../ruby/Bundler/Thor/Actions/CreateLink.md | 31 - .../ruby/Bundler/Thor/Actions/Directory.md | 21 - .../Bundler/Thor/Actions/EmptyDirectory.md | 62 - .../Bundler/Thor/Actions/InjectIntoFile.md | 27 - .../Bundler/Thor/AmbiguousCommandError.md | 7 - example/ruby/Bundler/Thor/Argument.md | 51 - example/ruby/Bundler/Thor/Arguments.md | 23 - .../Thor/AtLeastOneRequiredArgumentError.md | 7 - example/ruby/Bundler/Thor/Base.md | 62 - .../ruby/Bundler/Thor/Base/ClassMethods.md | 386 -- example/ruby/Bundler/Thor/Command.md | 74 - example/ruby/Bundler/Thor/CoreExt.md | 7 - .../Thor/CoreExt/HashWithIndifferentAccess.md | 51 - example/ruby/Bundler/Thor/DynamicCommand.md | 15 - example/ruby/Bundler/Thor/Error.md | 14 - .../Bundler/Thor/ExclusiveArgumentError.md | 7 - example/ruby/Bundler/Thor/Group.md | 128 - example/ruby/Bundler/Thor/HiddenCommand.md | 13 - example/ruby/Bundler/Thor/Invocation.md | 96 - .../Bundler/Thor/Invocation/ClassMethods.md | 12 - example/ruby/Bundler/Thor/InvocationError.md | 8 - example/ruby/Bundler/Thor/LineEditor.md | 9 - example/ruby/Bundler/Thor/LineEditor/Basic.md | 25 - .../ruby/Bundler/Thor/LineEditor/Readline.md | 14 - .../LineEditor/Readline/PathCompletion.md | 14 - .../Bundler/Thor/MalformattedArgumentError.md | 7 - example/ruby/Bundler/Thor/NestedContext.md | 18 - example/ruby/Bundler/Thor/Option.md | 69 - example/ruby/Bundler/Thor/Options.md | 39 - example/ruby/Bundler/Thor/RakeCompat.md | 27 - .../Thor/RequiredArgumentMissingError.md | 7 - example/ruby/Bundler/Thor/Runner.md | 40 - example/ruby/Bundler/Thor/Sandbox.md | 7 - example/ruby/Bundler/Thor/Shell.md | 31 - example/ruby/Bundler/Thor/Shell/Basic.md | 151 - example/ruby/Bundler/Thor/Shell/Color.md | 42 - .../ruby/Bundler/Thor/Shell/ColumnPrinter.md | 21 - example/ruby/Bundler/Thor/Shell/HTML.md | 26 - .../ruby/Bundler/Thor/Shell/TablePrinter.md | 14 - example/ruby/Bundler/Thor/Shell/Terminal.md | 13 - .../ruby/Bundler/Thor/Shell/WrappedPrinter.md | 10 - .../Bundler/Thor/UndefinedCommandError.md | 33 - .../UndefinedCommandError/SpellChecker.md | 20 - .../ruby/Bundler/Thor/UnknownArgumentError.md | 32 - .../Thor/UnknownArgumentError/SpellChecker.md | 20 - example/ruby/Bundler/Thor/Util.md | 134 - example/ruby/Bundler/ThreadCreationError.md | 7 - example/ruby/Bundler/UI.md | 6 - example/ruby/Bundler/UI/RGProxy.md | 14 - example/ruby/Bundler/UI/Shell.md | 81 - example/ruby/Bundler/UI/Silent.md | 80 - example/ruby/Bundler/URI.md | 366 -- example/ruby/Bundler/URI/BadURIError.md | 8 - example/ruby/Bundler/URI/Error.md | 8 - example/ruby/Bundler/URI/FTP.md | 91 - example/ruby/Bundler/URI/File.md | 70 - example/ruby/Bundler/URI/Generic.md | 444 -- example/ruby/Bundler/URI/HTTP.md | 75 - example/ruby/Bundler/URI/HTTPS.md | 10 - .../ruby/Bundler/URI/InvalidComponentError.md | 8 - example/ruby/Bundler/URI/InvalidURIError.md | 8 - example/ruby/Bundler/URI/LDAP.md | 86 - example/ruby/Bundler/URI/LDAPS.md | 10 - example/ruby/Bundler/URI/MailTo.md | 71 - example/ruby/Bundler/URI/RFC2396_Parser.md | 154 - example/ruby/Bundler/URI/RFC2396_REGEXP.md | 7 - .../Bundler/URI/RFC2396_REGEXP/PATTERN.md | 7 - example/ruby/Bundler/URI/RFC3986_Parser.md | 40 - example/ruby/Bundler/URI/Util.md | 9 - example/ruby/Bundler/URI/WS.md | 49 - example/ruby/Bundler/URI/WSS.md | 10 - example/ruby/Bundler/URICredentialsFilter.md | 9 - example/ruby/Bundler/URINormalizer.md | 14 - example/ruby/Bundler/VirtualProtocolError.md | 10 - example/ruby/Bundler/Worker.md | 34 - .../ruby/Bundler/Worker/WrappedException.md | 16 - example/ruby/Bundler/YAMLSerializer.md | 12 - example/ruby/Bundler/YamlSyntaxError.md | 16 - example/ruby/BundlerVCRHTTP.md | 12 - example/ruby/BundlerVCRHTTP/RequestHandler.md | 47 - example/ruby/C.md | 2254 ------- example/ruby/CApiClassSpecs.md | 7 - example/ruby/CApiClassSpecs/A.md | 7 - example/ruby/CApiClassSpecs/A/B.md | 7 - example/ruby/CApiClassSpecs/A/D.md | 6 - example/ruby/CApiClassSpecs/A/M.md | 6 - example/ruby/CApiClassSpecs/Alloc.md | 19 - example/ruby/CApiClassSpecs/Attr.md | 12 - example/ruby/CApiClassSpecs/CVars.md | 14 - example/ruby/CApiClassSpecs/Inherited.md | 11 - example/ruby/CApiClassSpecs/KeywordAlloc.md | 22 - example/ruby/CApiClassSpecs/M.md | 11 - example/ruby/CApiClassSpecs/NewClass.md | 11 - example/ruby/CApiClassSpecs/Sub.md | 10 - example/ruby/CApiClassSpecs/SubM.md | 14 - example/ruby/CApiClassSpecs/SubSelf.md | 7 - example/ruby/CApiClassSpecs/SubSub.md | 10 - example/ruby/CApiClassSpecs/Super.md | 10 - example/ruby/CApiClassSpecs/SuperSelf.md | 10 - example/ruby/CApiEncodingSpecs.md | 7 - example/ruby/CApiEncodingSpecs/S.md | 7 - example/ruby/CApiKernelSpecs.md | 7 - .../CApiKernelSpecs/ClassWithPrivateMethod.md | 7 - .../ClassWithProtectedMethod.md | 7 - .../CApiKernelSpecs/ClassWithPublicMethod.md | 10 - example/ruby/CApiKernelSpecs/Exc.md | 7 - example/ruby/CApiModuleSpecs.md | 7 - example/ruby/CApiModuleSpecs/A.md | 7 - example/ruby/CApiModuleSpecs/B.md | 7 - example/ruby/CApiModuleSpecs/C.md | 7 - example/ruby/CApiModuleSpecs/M.md | 6 - .../ruby/CApiModuleSpecs/RubyUnderAutoload.md | 6 - example/ruby/CApiModuleSpecs/Super.md | 7 - example/ruby/CApiObjectSpecs.md | 8 - example/ruby/CApiObjectSpecs/Alloc.md | 19 - example/ruby/CApiObjectSpecs/CVars.md | 6 - example/ruby/CApiObjectSpecs/IVars.md | 14 - example/ruby/CApiObjectSpecs/MVars.md | 6 - example/ruby/CApiObjectSpecs/SubArray.md | 10 - example/ruby/CApiProcSpecs.md | 20 - example/ruby/CApiStringSpecs.md | 7 - .../ruby/CApiStringSpecs/InvalidTostrTest.md | 10 - example/ruby/CApiStringSpecs/ToSOrInspect.md | 12 - .../ruby/CApiStringSpecs/ValidTostrTest.md | 10 - example/ruby/CGI.md | 494 -- example/ruby/CGI/Cookie.md | 129 - example/ruby/CGI/Escape.md | 37 - example/ruby/CGI/HTML3.md | 488 -- example/ruby/CGI/HTML4.md | 487 -- example/ruby/CGI/HTML4Fr.md | 487 -- example/ruby/CGI/HTML4Tr.md | 487 -- example/ruby/CGI/HTML5.md | 487 -- example/ruby/CGI/Html3.md | 35 - example/ruby/CGI/Html4.md | 35 - example/ruby/CGI/Html4Fr.md | 35 - example/ruby/CGI/Html4Tr.md | 35 - example/ruby/CGI/Html5.md | 35 - example/ruby/CGI/HtmlExtension.md | 469 -- example/ruby/CGI/InvalidEncoding.md | 8 - example/ruby/CGI/QueryExtension.md | 66 - example/ruby/CGI/Session.md | 258 - example/ruby/CGI/Session/FileStore.md | 59 - example/ruby/CGI/Session/MemoryStore.md | 38 - example/ruby/CGI/Session/NoSession.md | 8 - example/ruby/CGI/Session/NullStore.md | 37 - example/ruby/CGI/Session/PStore.md | 54 - example/ruby/CGI/TagMaker.md | 33 - example/ruby/CGI/Util.md | 90 - example/ruby/CGICookieTest.md | 40 - example/ruby/CGICoreTest.md | 36 - example/ruby/CGIHeaderTest.md | 30 - example/ruby/CGIModrubyTest.md | 24 - example/ruby/CGIMultipartTest.md | 48 - example/ruby/CGISessionTest.md | 24 - example/ruby/CGISpecs.md | 9 - example/ruby/CGITagHelperTest.md | 28 - example/ruby/CGIUtilPureRubyTest.md | 24 - example/ruby/CGIUtilTest.md | 171 - example/ruby/CGIUtilTest/UnescapeHTMLTests.md | 13 - example/ruby/CHashDir.md | 2084 ------- example/ruby/CONST1.md | 6 - example/ruby/CONST2_.md | 6 - example/ruby/CSAutoloadA.md | 6 - example/ruby/CSAutoloadB.md | 6 - example/ruby/CSAutoloadC.md | 6 - example/ruby/CSAutoloadD.md | 6 - example/ruby/CSAutoloadD/InnerModule.md | 6 - example/ruby/CS_CONST_AUTOLOAD.md | 7 - example/ruby/Cal.md | 44 - example/ruby/CaseFolding.md | 48 - example/ruby/CaseFolding/Util.md | 10 - ...CaseInsensitiveRegularExpressionVisitor.md | 21 - example/ruby/CaseMapping.md | 29 - example/ruby/CaseMappingDummy.md | 14 - example/ruby/CertStore.md | 40 - example/ruby/ChangeWordTest.md | 18 - example/ruby/ChatClient.md | 23 - example/ruby/ChatEntry.md | 25 - example/ruby/ChatServer.md | 16 - example/ruby/Checksum.md | 35 - example/ruby/Child.md | 7 - example/ruby/Class.md | 142 - example/ruby/ClassNameCheckTest.md | 28 - example/ruby/ClassSpecs.md | 11 - example/ruby/ClassSpecs/A.md | 7 - example/ruby/ClassSpecs/B.md | 7 - example/ruby/ClassSpecs/C.md | 10 - example/ruby/ClassSpecs/Container.md | 7 - example/ruby/ClassSpecs/Container/A.md | 7 - example/ruby/ClassSpecs/Container/B.md | 7 - example/ruby/ClassSpecs/D.md | 10 - example/ruby/ClassSpecs/E.md | 13 - example/ruby/ClassSpecs/F.md | 12 - example/ruby/ClassSpecs/G.md | 10 - example/ruby/ClassSpecs/H.md | 12 - example/ruby/ClassSpecs/I.md | 7 - example/ruby/ClassSpecs/I/J.md | 7 - example/ruby/ClassSpecs/K.md | 12 - example/ruby/ClassSpecs/L.md | 7 - example/ruby/ClassSpecs/M.md | 7 - example/ruby/ClassVariablesSpec.md | 6 - example/ruby/ClassVariablesSpec/ClassA.md | 12 - example/ruby/ClassVariablesSpec/ClassB.md | 7 - example/ruby/ClassVariablesSpec/ClassC.md | 16 - example/ruby/ClassVariablesSpec/ModuleM.md | 12 - example/ruby/ClassVariablesSpec/ModuleN.md | 12 - example/ruby/ClassVariablesSpec/ModuleO.md | 11 - example/ruby/Clock.md | 14 - example/ruby/ClosedQueueError.md | 9 - example/ruby/CodeLoadingSpecs.md | 10 - example/ruby/CodeLoadingSpecs/Method.md | 15 - example/ruby/CodingUS_ASCII.md | 9 - example/ruby/CodingUTF_8.md | 9 - example/ruby/Colorize.md | 24 - example/ruby/CommandSyntaxError.md | 7 - example/ruby/CommentStripper.md | 14 - example/ruby/CompactIndexAPI.md | 7 - example/ruby/CompactIndexApiMissing.md | 7 - .../ruby/CompactIndexBasicAuthentication.md | 7 - example/ruby/CompactIndexChecksumMismatch.md | 7 - .../ruby/CompactIndexConcurrentDownload.md | 7 - example/ruby/CompactIndexCredsDiffHost.md | 7 - example/ruby/CompactIndexEtagMatch.md | 7 - example/ruby/CompactIndexExtra.md | 7 - example/ruby/CompactIndexExtraAPIMissing.md | 7 - example/ruby/CompactIndexExtraApi.md | 7 - example/ruby/CompactIndexExtraMissing.md | 7 - example/ruby/CompactIndexForbidden.md | 7 - example/ruby/CompactIndexHostRedirect.md | 7 - example/ruby/CompactIndexNoGem.md | 7 - example/ruby/CompactIndexPartialUpdate.md | 14 - .../CompactIndexPartialUpdateBadDigest.md | 12 - ...ndexPartialUpdateNoDigestNotIncremental.md | 13 - example/ruby/CompactIndexPrecompiledBefore.md | 7 - example/ruby/CompactIndexRangeIgnored.md | 13 - .../ruby/CompactIndexRangeNotSatisfiable.md | 7 - example/ruby/CompactIndexRateLimited.md | 7 - .../CompactIndexRateLimited/RequestCounter.md | 12 - example/ruby/CompactIndexRedirect.md | 7 - .../CompactIndexStrictBasicAuthentication.md | 7 - example/ruby/CompactIndexWrongDependencies.md | 7 - example/ruby/CompactIndexWrongGemChecksum.md | 7 - example/ruby/Comparable.md | 142 - example/ruby/ComparableSpecs.md | 6 - .../ComparableSpecs/CompareCallingSuper.md | 103 - example/ruby/ComparableSpecs/Weird.md | 93 - .../ComparableSpecs/WithOnlyCompareDefined.md | 18 - .../ComparableSpecs/WithoutCompareDefined.md | 93 - example/ruby/CompileWarning.md | 11 - example/ruby/ComplainMatcher.md | 20 - example/ruby/Complex.md | 665 -- example/ruby/Complex/compatible.md | 7 - example/ruby/ComplexRational_Test.md | 12 - example/ruby/ComplexSub.md | 7 - example/ruby/Complex_Test.md | 124 - example/ruby/Complex_Test/ObjectX.md | 20 - example/ruby/Complex_Test2.md | 12 - example/ruby/ConflictsGuard.md | 16 - example/ruby/Const.md | 6 - example/ruby/Const2.md | 6 - example/ruby/ConstantLeakError.md | 7 - example/ruby/ConstantSpecs.md | 12 - example/ruby/ConstantSpecs/ClassA.md | 21 - example/ruby/ConstantSpecs/ClassB.md | 16 - example/ruby/ConstantSpecs/ClassC.md | 7 - example/ruby/ConstantSpecs/ClassC/ClassE.md | 7 - example/ruby/ConstantSpecs/ClassD.md | 7 - example/ruby/ConstantSpecs/ConstSource.md | 6 - example/ruby/ConstantSpecs/ContainerA.md | 14 - .../ruby/ConstantSpecs/ContainerA/ChildA.md | 31 - example/ruby/ConstantSpecs/ContainerB.md | 11 - .../ruby/ConstantSpecs/ContainerB/ChildB.md | 32 - .../ruby/ConstantSpecs/ContainerPrepend.md | 9 - example/ruby/ConstantSpecs/ModuleA.md | 7 - example/ruby/ConstantSpecs/ModuleB.md | 7 - example/ruby/ConstantSpecs/ModuleC.md | 7 - example/ruby/ConstantSpecs/ModuleD.md | 9 - example/ruby/ConstantSpecs/ModuleE.md | 7 - example/ruby/ConstantSpecs/ModuleF.md | 7 - example/ruby/ConstantSpecs/ModuleG.md | 7 - example/ruby/ConstantSpecs/ModuleH.md | 7 - .../ConstantSpecs/ModuleIncludePrepended.md | 9 - example/ruby/ConstantSpecs/ModuleM.md | 7 - example/ruby/ConstantSpecs/ParentA.md | 19 - example/ruby/ConstantSpecs/ParentB.md | 16 - example/ruby/ConstantSpecsThree.md | 6 - .../ConstantSpecsThree/ConstantSpecsTwo.md | 6 - example/ruby/ConstantSpecsTwo.md | 6 - example/ruby/ConstantUnicodeSpecs.md | 6 - example/ruby/ConstantVisibility.md | 8 - .../ruby/ConstantVisibility/ClassContainer.md | 7 - .../ClassIncludingPrivConstModule.md | 14 - .../ConstantVisibility/ModuleContainer.md | 6 - .../ModuleIncludingPrivConstModule.md | 12 - .../ruby/ConstantVisibility/PrivConstClass.md | 10 - .../PrivConstClass/Nested.md | 9 - .../ConstantVisibility/PrivConstClassChild.md | 12 - .../ConstantVisibility/PrivConstModule.md | 9 - .../PrivConstModule/Nested.md | 9 - example/ruby/ConstantsLeakCheckerAction.md | 22 - example/ruby/ConstantsLockFile.md | 11 - example/ruby/ContextState.md | 102 - example/ruby/Continuation.md | 97 - example/ruby/CoreClassSpecs.md | 6 - example/ruby/CoreClassSpecs/A.md | 11 - example/ruby/CoreClassSpecs/F.md | 11 - example/ruby/CoreClassSpecs/H.md | 11 - example/ruby/CoreClassSpecs/Inherited.md | 6 - example/ruby/CoreClassSpecs/Inherited/A.md | 11 - example/ruby/CoreClassSpecs/Inherited/B.md | 8 - example/ruby/CoreClassSpecs/Inherited/C.md | 7 - example/ruby/CoreClassSpecs/Inherited/D.md | 11 - example/ruby/CoreClassSpecs/M.md | 9 - example/ruby/CoreClassSpecs/Record.md | 7 - example/ruby/CoreDumpError.md | 7 - example/ruby/CoreExtensions.md | 6 - example/ruby/CoreExtensions/TCPSocketExt.md | 8 - .../TCPSocketExt/Initializer.md | 9 - example/ruby/Coverage.md | 85 - example/ruby/CoverageSpecs.md | 6 - example/ruby/CrlStore.md | 14 - example/ruby/DQEntry.md | 14 - example/ruby/DRb.md | 6 - example/ruby/DRb/HTTP0.md | 10 - example/ruby/DRb/HTTP0/Callback.md | 20 - example/ruby/DRb/HTTP0/ClientSide.md | 24 - example/ruby/DRb/HTTP0/Server.md | 24 - example/ruby/DRb/HTTP0/ServerSide.md | 26 - example/ruby/DRb/HTTP0/StrStream.md | 20 - example/ruby/DRbEx.md | 22 - example/ruby/DRbEx2.md | 16 - example/ruby/DRbEx3.md | 16 - example/ruby/DRbEx4.md | 16 - example/ruby/DRbNamedIdConv.md | 16 - example/ruby/DRbNamedObject.md | 10 - example/ruby/DSL.md | 42 - example/ruby/DSL/Var.md | 31 - example/ruby/DSL/Var/Table.md | 22 - example/ruby/DTrace.md | 6 - example/ruby/DTrace/TestArrayCreate.md | 12 - example/ruby/DTrace/TestCMethod.md | 14 - example/ruby/DTrace/TestCase.md | 16 - example/ruby/DTrace/TestFunctionEntry.md | 14 - example/ruby/DTrace/TestGC.md | 7 - example/ruby/DTrace/TestHashCreate.md | 16 - example/ruby/DTrace/TestLoad.md | 16 - example/ruby/DTrace/TestMethodCacheClear.md | 10 - example/ruby/DTrace/TestObjectCreateStart.md | 12 - example/ruby/DTrace/TestRaise.md | 10 - example/ruby/DTrace/TestRequire.md | 12 - .../ruby/DTrace/TestSingletonFunctionEntry.md | 14 - example/ruby/DTrace/TestStringProbes.md | 10 - example/ruby/DataSpecs.md | 6 - example/ruby/Data_.md | 167 - example/ruby/Date.md | 1327 ---- example/ruby/Date/Error.md | 7 - example/ruby/Date/Infinity.md | 41 - example/ruby/DateSub.md | 7 - example/ruby/DateTime.md | 443 -- example/ruby/DateTimeSub.md | 7 - example/ruby/DebugPOpen.md | 6 - example/ruby/DebugSystem.md | 9 - example/ruby/DefineMethodSpecClass.md | 7 - example/ruby/DefinedSpecs.md | 12 - example/ruby/DefinedSpecs/Basic.md | 52 - example/ruby/DefinedSpecs/Child.md | 16 - .../DefinedSpecs/ClassUndefiningMethod.md | 7 - example/ruby/DefinedSpecs/ClassWithMethod.md | 10 - .../ruby/DefinedSpecs/ClassWithoutMethod.md | 12 - .../ruby/DefinedSpecs/IntermediateModule1.md | 9 - .../ruby/DefinedSpecs/IntermediateModule2.md | 9 - example/ruby/DefinedSpecs/Mixin.md | 9 - .../DefinedSpecs/ModuleWithConstMissing.md | 8 - example/ruby/DefinedSpecs/Parent.md | 10 - example/ruby/DefinedSpecs/Super.md | 24 - .../SuperWithIntermediateModules.md | 12 - example/ruby/DefinedSpecs/Superclass.md | 26 - example/ruby/DelegateSpecs.md | 6 - example/ruby/DelegateSpecs/DelegateClass.md | 12 - example/ruby/DelegateSpecs/Delegator.md | 21 - example/ruby/DelegateSpecs/Extra.md | 9 - example/ruby/DelegateSpecs/Simple.md | 16 - example/ruby/DelegationSpecs.md | 6 - example/ruby/DelegationSpecs/Target.md | 14 - example/ruby/Delegator.md | 103 - example/ruby/DescribeFormatter.md | 12 - example/ruby/DetailedMessageSpec.md | 6 - example/ruby/Dhasen.md | 16 - example/ruby/DidYouMean.md | 87 - example/ruby/DidYouMean/ClassNameChecker.md | 22 - example/ruby/DidYouMean/Correctable.md | 18 - example/ruby/DidYouMean/Formatter.md | 35 - example/ruby/DidYouMean/Jaro.md | 8 - example/ruby/DidYouMean/JaroWinkler.md | 8 - example/ruby/DidYouMean/KeyErrorChecker.md | 14 - example/ruby/DidYouMean/Levenshtein.md | 17 - example/ruby/DidYouMean/MethodNameChecker.md | 25 - example/ruby/DidYouMean/NullChecker.md | 14 - .../ruby/DidYouMean/PatternKeyNameChecker.md | 14 - example/ruby/DidYouMean/RequirePathChecker.md | 20 - example/ruby/DidYouMean/SpellChecker.md | 14 - example/ruby/DidYouMean/TestHelper.md | 18 - example/ruby/DidYouMean/TreeSpellChecker.md | 38 - .../ruby/DidYouMean/VariableNameChecker.md | 30 - example/ruby/DifferentOFS.md | 10 - example/ruby/DifferentOFS/WithDifferentOFS.md | 11 - example/ruby/Digest.md | 161 - example/ruby/Digest/Base.md | 75 - example/ruby/Digest/Class.md | 179 - example/ruby/Digest/DigestError.md | 7 - example/ruby/Digest/Foo.md | 7 - example/ruby/Digest/Instance.md | 147 - example/ruby/Digest/MD5.md | 28 - example/ruby/Digest/RMD160.md | 28 - example/ruby/Digest/SHA1.md | 31 - example/ruby/Digest/SHA2.md | 101 - example/ruby/Digest/SHA256.md | 12 - example/ruby/Digest/SHA384.md | 12 - example/ruby/Digest/SHA512.md | 12 - example/ruby/Dir.md | 2935 --------- example/ruby/Dir/Tmpname.md | 11 - example/ruby/DirSpecs.md | 20 - example/ruby/DivmodSpecs.md | 9 - example/ruby/DottedFormatter.md | 17 - example/ruby/Downloader.md | 47 - example/ruby/Downloader/GNU.md | 9 - example/ruby/Downloader/RubyGems.md | 9 - example/ruby/Downloader/Unicode.md | 10 - example/ruby/ENV.md | 176 - example/ruby/ENVSpecs.md | 8 - example/ruby/EOFError.md | 20 - example/ruby/ERB.md | 399 -- example/ruby/ERB/Compiler.md | 125 - example/ruby/ERB/Compiler/Buffer.md | 23 - example/ruby/ERB/Compiler/PercentLine.md | 18 - example/ruby/ERB/Compiler/Scanner.md | 29 - example/ruby/ERB/Compiler/TrimScanner.md | 29 - example/ruby/ERB/DefMethod.md | 39 - example/ruby/ERB/Escape.md | 10 - example/ruby/ERB/Util.md | 36 - example/ruby/ERBSpecs.md | 8 - example/ruby/Emoji.md | 6 - example/ruby/Emoji/TestDoCoMo.md | 32 - example/ruby/Emoji/TestKDDI.md | 34 - example/ruby/Emoji/TestRenameSJIS.md | 10 - example/ruby/Emoji/TestSoftBank.md | 32 - .../Emoji/TestUTF8_BLACK_SUN_WITH_RAYS.md | 14 - example/ruby/EmojiTable.md | 16 - example/ruby/Encoding.md | 245 - example/ruby/Encoding/CompatibilityError.md | 9 - example/ruby/Encoding/Converter.md | 503 -- .../ruby/Encoding/ConverterNotFoundError.md | 9 - .../ruby/Encoding/InvalidByteSequenceError.md | 86 - .../ruby/Encoding/UndefinedConversionError.md | 56 - example/ruby/EncodingError.md | 8 - example/ruby/EncodingSpecs.md | 6 - .../EncodingSpecs/InvalidByteSequenceError.md | 9 - .../InvalidByteSequenceErrorIndirect.md | 9 - .../EncodingSpecs/UndefinedConversionError.md | 9 - .../UndefinedConversionErrorIndirect.md | 9 - example/ruby/EndianGuard.md | 9 - example/ruby/Endpoint.md | 12 - example/ruby/Endpoint500.md | 7 - example/ruby/EndpointApiForbidden.md | 7 - example/ruby/EndpointBasicAuthentication.md | 7 - example/ruby/EndpointCredsDiffHost.md | 7 - example/ruby/EndpointExtra.md | 7 - example/ruby/EndpointExtraApi.md | 7 - example/ruby/EndpointExtraMissing.md | 7 - example/ruby/EndpointFallback.md | 7 - example/ruby/EndpointHostRedirect.md | 7 - example/ruby/EndpointMarshalFail.md | 7 - .../EndpointMarshalFailBasicAuthentication.md | 7 - example/ruby/EndpointMirrorSource.md | 7 - example/ruby/EndpointRedirect.md | 7 - .../ruby/EndpointStrictBasicAuthentication.md | 7 - example/ruby/EndpointTimeout.md | 7 - example/ruby/English.md | 51 - example/ruby/EnsureAndCallcc.md | 10 - example/ruby/EnsureSpec.md | 6 - example/ruby/EnsureSpec/Container.md | 38 - example/ruby/EnsureSpec/Error.md | 7 - example/ruby/EnsureSpec/Test.md | 20 - example/ruby/EnumSpecs.md | 6 - example/ruby/EnumSpecs/Numerous.md | 2074 ------ example/ruby/Enumerable.md | 2256 ------- example/ruby/EnumerableSpecs.md | 6 - .../ruby/EnumerableSpecs/ArrayConvertible.md | 20 - .../EnumerableSpecs/ComparableWithInteger.md | 99 - .../EnumerableSpecs/ComparesByVowelCount.md | 23 - example/ruby/EnumerableSpecs/EachCounter.md | 24 - example/ruby/EnumerableSpecs/EachDefiner.md | 2079 ------ example/ruby/EnumerableSpecs/Empty.md | 2070 ------ example/ruby/EnumerableSpecs/EmptyWithSize.md | 2072 ------ .../ruby/EnumerableSpecs/EnumConvertible.md | 25 - example/ruby/EnumerableSpecs/Equals.md | 14 - example/ruby/EnumerableSpecs/Freezy.md | 2067 ------ .../ruby/EnumerableSpecs/InvalidComparable.md | 10 - .../EnumerableSpecs/MapReturnsEnumerable.md | 2059 ------ .../MapReturnsEnumerable/EnumerableMapping.md | 2074 ------ example/ruby/EnumerableSpecs/NoEach.md | 2068 ------ example/ruby/EnumerableSpecs/Numerous.md | 2074 ------ .../ruby/EnumerableSpecs/NumerousWithSize.md | 10 - example/ruby/EnumerableSpecs/Pattern.md | 18 - .../ruby/EnumerableSpecs/ReverseComparable.md | 104 - example/ruby/EnumerableSpecs/SortByDummy.md | 14 - example/ruby/EnumerableSpecs/ThrowingEach.md | 2070 ------ example/ruby/EnumerableSpecs/Uncomparable.md | 10 - example/ruby/EnumerableSpecs/Undupable.md | 25 - example/ruby/EnumerableSpecs/YieldsMixed.md | 2072 ------ example/ruby/EnumerableSpecs/YieldsMixed2.md | 2077 ------ example/ruby/EnumerableSpecs/YieldsMulti.md | 2072 ------ .../EnumerableSpecs/YieldsMultiWithFalse.md | 2072 ------ .../YieldsMultiWithSingleTrue.md | 2072 ------ example/ruby/Enumerator.md | 2521 -------- example/ruby/Enumerator/ArithmeticSequence.md | 87 - example/ruby/Enumerator/Chain.md | 55 - example/ruby/Enumerator/Generator.md | 2077 ------ example/ruby/Enumerator/Lazy.md | 366 -- example/ruby/Enumerator/Producer.md | 11 - example/ruby/Enumerator/Product.md | 79 - example/ruby/Enumerator/Yielder.md | 29 - example/ruby/EnumeratorLazySpecs.md | 6 - .../ruby/EnumeratorLazySpecs/EventsMixed.md | 14 - .../ruby/EnumeratorLazySpecs/SpecificError.md | 7 - .../ruby/EnumeratorLazySpecs/YieldsMixed.md | 17 - example/ruby/EnumeratorSpecs.md | 6 - example/ruby/EnumeratorSpecs/Feed.md | 10 - example/ruby/EnvUtil.md | 45 - example/ruby/EqlMatcher.md | 20 - example/ruby/EqualElementMatcher.md | 24 - example/ruby/EqualMatcher.md | 20 - example/ruby/Errno.md | 44 - example/ruby/ErrorHighlight.md | 39 - example/ruby/ErrorHighlight/CoreExt.md | 11 - .../ruby/ErrorHighlight/DefaultFormatter.md | 12 - example/ruby/ErrorHighlightTest.md | 226 - .../ruby/ErrorHighlightTest/DummyFormatter.md | 9 - .../ruby/ErrorHighlightTest/OP_CDECL_TEST.md | 6 - example/ruby/Etc.md | 242 - example/ruby/Etc/Group.md | 28 - example/ruby/Etc/Passwd.md | 30 - example/ruby/EvTest.md | 6 - example/ruby/EvalSpecs.md | 12 - example/ruby/EvalSpecs/A.md | 10 - example/ruby/EvalSpecs/CoercedObject.md | 12 - example/ruby/EvalTest.md | 10 - example/ruby/ExampleState.md | 32 - example/ruby/Exception.md | 472 -- example/ruby/ExceptionSpecs.md | 6 - example/ruby/ExceptionSpecs/Backtrace.md | 10 - .../ExceptionSpecs/ConstructorException.md | 12 - example/ruby/ExceptionSpecs/EmptyToS.md | 10 - .../ruby/ExceptionSpecs/ExceptionModule.md | 9 - example/ruby/ExceptionSpecs/Exceptional.md | 7 - .../ExceptionSpecs/InitializeException.md | 18 - example/ruby/ExceptionSpecs/OverrideToS.md | 10 - example/ruby/ExceptionSpecs/UnExceptional.md | 12 - example/ruby/ExceptionState.md | 33 - example/ruby/ExpectedException.md | 7 - example/ruby/Exports.md | 20 - example/ruby/Exports/Cygwin.md | 16 - example/ruby/Exports/Mingw.md | 12 - example/ruby/Exports/Mswin.md | 14 - example/ruby/Exports/Msys.md | 7 - example/ruby/ExtArray.md | 12 - example/ruby/ExtLibs.md | 34 - example/ruby/ExtLibs/Colorize.md | 12 - example/ruby/ExtLibs/Vars.md | 12 - example/ruby/Fail.md | 15 - example/ruby/FalseClass.md | 48 - example/ruby/Fcntl.md | 35 - example/ruby/FeatureGuard.md | 16 - example/ruby/Fiber.md | 487 -- example/ruby/Fiber/Pool.md | 11 - example/ruby/Fiber/Scheduler.md | 89 - example/ruby/FiberError.md | 14 - example/ruby/FiberSpecs.md | 6 - example/ruby/FiberSpecs/CustomError.md | 7 - example/ruby/FiberSpecs/NewFiberToRaise.md | 9 - example/ruby/Fiddle.md | 112 - example/ruby/Fiddle/BasicTypes.md | 13 - example/ruby/Fiddle/CParser.md | 87 - example/ruby/Fiddle/CStruct.md | 2063 ------ example/ruby/Fiddle/CStructBuilder.md | 49 - example/ruby/Fiddle/CStructEntity.md | 78 - example/ruby/Fiddle/CUnion.md | 13 - example/ruby/Fiddle/CUnionEntity.md | 24 - example/ruby/Fiddle/ClearedReferenceError.md | 8 - example/ruby/Fiddle/Closure.md | 73 - example/ruby/Fiddle/Closure/BlockCaller.md | 38 - example/ruby/Fiddle/CompositeHandler.md | 28 - example/ruby/Fiddle/DLError.md | 8 - example/ruby/Fiddle/Error.md | 8 - example/ruby/Fiddle/FFIBackend.md | 10 - example/ruby/Fiddle/Function.md | 93 - example/ruby/Fiddle/Handle.md | 133 - example/ruby/Fiddle/Importer.md | 304 - example/ruby/Fiddle/LIBC.md | 139 - example/ruby/Fiddle/MemoryView.md | 38 - example/ruby/Fiddle/PackInfo.md | 9 - example/ruby/Fiddle/Packer.md | 23 - example/ruby/Fiddle/Pinned.md | 33 - example/ruby/Fiddle/Pointer.md | 261 - example/ruby/Fiddle/Pointer/LibC.md | 8 - example/ruby/Fiddle/StructArray.md | 27 - example/ruby/Fiddle/TestCParser.md | 156 - example/ruby/Fiddle/TestCStructBuilder.md | 219 - example/ruby/Fiddle/TestCStructEntity.md | 42 - example/ruby/Fiddle/TestCUnionEntity.md | 14 - example/ruby/Fiddle/TestCase.md | 20 - example/ruby/Fiddle/TestClosure.md | 28 - example/ruby/Fiddle/TestFunc.md | 28 - example/ruby/Fiddle/TestFunction.md | 56 - example/ruby/Fiddle/TestHandle.md | 54 - example/ruby/Fiddle/TestImport.md | 60 - example/ruby/Fiddle/TestMemoryView.md | 30 - example/ruby/Fiddle/TestPack.md | 10 - example/ruby/Fiddle/TestPinned.md | 14 - example/ruby/Fiddle/TestPointer.md | 81 - .../ruby/Fiddle/TestPointer/MimicInteger.md | 13 - example/ruby/Fiddle/Types.md | 6 - example/ruby/Fiddle/ValueUtil.md | 16 - example/ruby/Fiddle/Win32Types.md | 34 - example/ruby/File.md | 833 --- example/ruby/File/Constants.md | 312 - example/ruby/File/Stat.md | 472 -- example/ruby/FileFormatter.md | 16 - example/ruby/FileSpecs.md | 22 - example/ruby/FileSpecs/SubString.md | 7 - example/ruby/FileStat.md | 9 - example/ruby/FileTest.md | 6 - example/ruby/FileUtils.md | 1771 ------ example/ruby/FileUtils/DryRun.md | 78 - example/ruby/FileUtils/Entry_.md | 103 - example/ruby/FileUtils/LowMethods.md | 7 - example/ruby/FileUtils/NoWrite.md | 78 - example/ruby/FileUtils/StreamUtils_.md | 7 - example/ruby/FileUtils/Verbose.md | 78 - example/ruby/Find.md | 40 - example/ruby/FindDirSpecs.md | 13 - example/ruby/FindMethodComments.md | 23 - example/ruby/Float.md | 814 --- example/ruby/FloatDomainError.md | 11 - example/ruby/FloatSpecs.md | 6 - example/ruby/FloatSpecs/CanCoerce.md | 16 - example/ruby/FloatSpecs/CoerceError.md | 7 - example/ruby/Foo.md | 29 - example/ruby/Foo/Unknown.md | 7 - example/ruby/FooError.md | 7 - example/ruby/ForSpecs.md | 6 - example/ruby/ForSpecs/ForInClassMethod.md | 9 - example/ruby/FormatterOverrides.md | 11 - example/ruby/Forwardable.md | 65 - example/ruby/Front.md | 14 - example/ruby/FrozenError.md | 29 - example/ruby/GC.md | 449 -- example/ruby/GC/Profiler.md | 98 - example/ruby/GCCompactChecker.md | 9 - example/ruby/GCDisabledChecker.md | 11 - example/ruby/Gem.md | 457 -- example/ruby/Gem/AvailableSet.md | 2103 ------- example/ruby/Gem/AvailableSet/Tuple.md | 18 - example/ruby/Gem/BUNDLED_GEMS.md | 15 - example/ruby/Gem/BasicSpecification.md | 179 - example/ruby/Gem/BetterPermissionError.md | 9 - example/ruby/Gem/BundlerVersionFinder.md | 9 - example/ruby/Gem/CIDetector.md | 11 - example/ruby/Gem/Command.md | 266 - example/ruby/Gem/CommandLineError.md | 7 - example/ruby/Gem/CommandManager.md | 129 - example/ruby/Gem/Commands.md | 7 - example/ruby/Gem/Commands/BuildCommand.md | 39 - example/ruby/Gem/Commands/CertCommand.md | 58 - example/ruby/Gem/Commands/CheckCommand.md | 44 - example/ruby/Gem/Commands/CleanupCommand.md | 36 - example/ruby/Gem/Commands/ContentsCommand.md | 63 - example/ruby/Gem/Commands/CrashCommand.md | 7 - .../ruby/Gem/Commands/DependencyCommand.md | 103 - .../ruby/Gem/Commands/EnvironmentCommand.md | 28 - example/ruby/Gem/Commands/ExecCommand.md | 40 - example/ruby/Gem/Commands/FetchCommand.md | 79 - .../ruby/Gem/Commands/GenerateIndexCommand.md | 10 - example/ruby/Gem/Commands/HelpCommand.md | 24 - example/ruby/Gem/Commands/InfoCommand.md | 98 - example/ruby/Gem/Commands/InsCommand.md | 12 - example/ruby/Gem/Commands/InstallCommand.md | 123 - example/ruby/Gem/Commands/InterruptCommand.md | 16 - example/ruby/Gem/Commands/ListCommand.md | 100 - example/ruby/Gem/Commands/LockCommand.md | 30 - example/ruby/Gem/Commands/MirrorCommand.md | 17 - example/ruby/Gem/Commands/OpenCommand.md | 48 - example/ruby/Gem/Commands/OutdatedCommand.md | 67 - example/ruby/Gem/Commands/OwnerCommand.md | 137 - example/ruby/Gem/Commands/PristineCommand.md | 40 - example/ruby/Gem/Commands/PushCommand.md | 131 - example/ruby/Gem/Commands/QueryCommand.md | 104 - example/ruby/Gem/Commands/RdocCommand.md | 40 - example/ruby/Gem/Commands/RebuildCommand.md | 27 - example/ruby/Gem/Commands/SearchCommand.md | 99 - example/ruby/Gem/Commands/ServerCommand.md | 17 - example/ruby/Gem/Commands/SetupCommand.md | 54 - .../Gem/Commands/SetupCommand/MakeDirs.md | 9 - example/ruby/Gem/Commands/SigninCommand.md | 90 - example/ruby/Gem/Commands/SignoutCommand.md | 20 - example/ruby/Gem/Commands/SourcesCommand.md | 86 - .../ruby/Gem/Commands/SpecificationCommand.md | 78 - example/ruby/Gem/Commands/StaleCommand.md | 20 - example/ruby/Gem/Commands/UninstallCommand.md | 54 - example/ruby/Gem/Commands/UnpackCommand.md | 61 - example/ruby/Gem/Commands/UpdateCommand.md | 131 - example/ruby/Gem/Commands/WhichCommand.md | 28 - example/ruby/Gem/Commands/YankCommand.md | 143 - example/ruby/Gem/ConfigFile.md | 257 - example/ruby/Gem/ConflictError.md | 21 - example/ruby/Gem/ConsoleUI.md | 16 - example/ruby/Gem/DefaultUserInteraction.md | 49 - example/ruby/Gem/Dependency.md | 129 - .../ruby/Gem/Dependency/FilterIgnoredSpecs.md | 9 - example/ruby/Gem/DependencyError.md | 7 - example/ruby/Gem/DependencyInstaller.md | 174 - example/ruby/Gem/DependencyList.md | 2268 ------- .../ruby/Gem/DependencyRemovalException.md | 7 - example/ruby/Gem/DependencyResolutionError.md | 21 - example/ruby/Gem/Deprecate.md | 28 - example/ruby/Gem/Doctor.md | 104 - example/ruby/Gem/DocumentError.md | 7 - example/ruby/Gem/EndOfYAMLException.md | 8 - example/ruby/Gem/ErrorReason.md | 7 - example/ruby/Gem/Exception.md | 9 - example/ruby/Gem/Ext.md | 7 - example/ruby/Gem/Ext/BuildError.md | 7 - example/ruby/Gem/Ext/Builder.md | 107 - example/ruby/Gem/Ext/CargoBuilder.md | 31 - .../Ext/CargoBuilder/DylibNotFoundError.md | 13 - .../Gem/Ext/CargoBuilder/LinkFlagConverter.md | 10 - example/ruby/Gem/Ext/CmakeBuilder.md | 9 - example/ruby/Gem/Ext/ConfigureBuilder.md | 11 - example/ruby/Gem/Ext/ExtConfBuilder.md | 12 - example/ruby/Gem/Ext/RakeBuilder.md | 11 - example/ruby/Gem/FakeFetcher.md | 77 - example/ruby/Gem/FakeFetcher/FakeSocket.md | 10 - example/ruby/Gem/FilePermissionError.md | 18 - example/ruby/Gem/FixFullNameEncoding.md | 9 - example/ruby/Gem/FormatException.md | 12 - example/ruby/Gem/GemNotFoundException.md | 7 - example/ruby/Gem/GemNotInHomeException.md | 12 - example/ruby/Gem/GemRunner.md | 26 - example/ruby/Gem/GemcutterUtilities.md | 108 - .../GemcutterUtilities/WebauthnListener.md | 20 - .../WebauthnListener/BadRequestResponse.md | 7 - .../MethodNotAllowedResponse.md | 7 - .../WebauthnListener/NoContentResponse.md | 7 - .../WebauthnListener/NotFoundResponse.md | 7 - .../WebauthnListener/OkResponse.md | 7 - .../WebauthnListener/Response.md | 20 - .../WebauthnListener/SocketResponder.md | 14 - .../Gem/GemcutterUtilities/WebauthnPoller.md | 93 - example/ruby/Gem/GemspecHelpers.md | 10 - example/ruby/Gem/HTTPResponseFactory.md | 20 - .../ruby/Gem/ImpossibleDependenciesError.md | 26 - example/ruby/Gem/InstallError.md | 7 - example/ruby/Gem/InstallUpdateOptions.md | 21 - example/ruby/Gem/Installer.md | 386 -- example/ruby/Gem/Installer/FakePackage.md | 29 - example/ruby/Gem/InstallerTestCase.md | 84 - example/ruby/Gem/InstallerUninstallerUtils.md | 12 - .../ruby/Gem/InvalidSpecificationException.md | 8 - example/ruby/Gem/Licenses.md | 36 - example/ruby/Gem/List.md | 2085 ------- example/ruby/Gem/LoadError.md | 17 - example/ruby/Gem/LocalRemoteOptions.md | 44 - example/ruby/Gem/MissingSpecError.md | 18 - example/ruby/Gem/MissingSpecVersionError.md | 19 - example/ruby/Gem/MockBrowser.md | 20 - example/ruby/Gem/MockGemUi.md | 32 - example/ruby/Gem/MockGemUi/InputEOFError.md | 13 - .../ruby/Gem/MockGemUi/SystemExitException.md | 7 - example/ruby/Gem/MockGemUi/TTY.md | 21 - example/ruby/Gem/MockGemUi/TermError.md | 16 - example/ruby/Gem/MockTCPServer.md | 35 - example/ruby/Gem/Molinillo.md | 7 - .../Gem/Molinillo/CircularDependencyError.md | 27 - .../Molinillo/Delegates/ResolutionState.md | 33 - .../Delegates/SpecificationProvider.md | 103 - example/ruby/Gem/Molinillo/DependencyGraph.md | 2327 ------- .../Gem/Molinillo/DependencyGraph/Action.md | 38 - .../Gem/Molinillo/DependencyGraph/Edge.md | 30 - .../ruby/Gem/Molinillo/DependencyGraph/Log.md | 2096 ------- .../Gem/Molinillo/DependencyGraph/Vertex.md | 103 - example/ruby/Gem/Molinillo/DependencyState.md | 16 - .../Gem/Molinillo/NoSuchDependencyError.md | 32 - .../ruby/Gem/Molinillo/PossibilityState.md | 9 - example/ruby/Gem/Molinillo/ResolutionState.md | 70 - example/ruby/Gem/Molinillo/Resolver.md | 41 - .../ruby/Gem/Molinillo/Resolver/Resolution.md | 184 - .../Molinillo/Resolver/Resolution/Conflict.md | 76 - .../Resolver/Resolution/PossibilitySet.md | 31 - .../Resolver/Resolution/UnwindDetails.md | 174 - example/ruby/Gem/Molinillo/ResolverError.md | 8 - .../Gem/Molinillo/SpecificationProvider.md | 107 - example/ruby/Gem/Molinillo/UI.md | 49 - example/ruby/Gem/Molinillo/VersionConflict.md | 144 - example/ruby/Gem/MultifactorAuthFetcher.md | 38 - example/ruby/Gem/NameTuple.md | 151 - example/ruby/Gem/Net.md | 7 - example/ruby/Gem/Net/BufferedIO.md | 53 - example/ruby/Gem/Net/HTTP.md | 1667 ----- example/ruby/Gem/Net/HTTP/Copy.md | 23 - example/ruby/Gem/Net/HTTP/Delete.md | 36 - example/ruby/Gem/Net/HTTP/Get.md | 36 - example/ruby/Gem/Net/HTTP/Head.md | 35 - example/ruby/Gem/Net/HTTP/Lock.md | 23 - example/ruby/Gem/Net/HTTP/Mkcol.md | 23 - example/ruby/Gem/Net/HTTP/Move.md | 23 - example/ruby/Gem/Net/HTTP/Options.md | 35 - example/ruby/Gem/Net/HTTP/Patch.md | 38 - example/ruby/Gem/Net/HTTP/Persistent.md | 454 -- .../Gem/Net/HTTP/Persistent/Connection.md | 33 - example/ruby/Gem/Net/HTTP/Persistent/Error.md | 9 - example/ruby/Gem/Net/HTTP/Persistent/Pool.md | 26 - .../Net/HTTP/Persistent/TimedStackMulti.md | 25 - example/ruby/Gem/Net/HTTP/Post.md | 39 - example/ruby/Gem/Net/HTTP/Propfind.md | 24 - example/ruby/Gem/Net/HTTP/Proppatch.md | 24 - example/ruby/Gem/Net/HTTP/ProxyDelta.md | 7 - example/ruby/Gem/Net/HTTP/Put.md | 39 - example/ruby/Gem/Net/HTTP/Trace.md | 35 - example/ruby/Gem/Net/HTTP/Unlock.md | 23 - example/ruby/Gem/Net/HTTPAccepted.md | 19 - example/ruby/Gem/Net/HTTPAlreadyReported.md | 20 - example/ruby/Gem/Net/HTTPBadGateway.md | 20 - example/ruby/Gem/Net/HTTPBadRequest.md | 20 - example/ruby/Gem/Net/HTTPBadResponse.md | 8 - example/ruby/Gem/Net/HTTPClientError.md | 16 - example/ruby/Gem/Net/HTTPClientException.md | 13 - example/ruby/Gem/Net/HTTPConflict.md | 19 - example/ruby/Gem/Net/HTTPContinue.md | 19 - example/ruby/Gem/Net/HTTPCreated.md | 19 - example/ruby/Gem/Net/HTTPEarlyHints.md | 20 - example/ruby/Gem/Net/HTTPError.md | 13 - example/ruby/Gem/Net/HTTPExceptions.md | 16 - example/ruby/Gem/Net/HTTPExpectationFailed.md | 20 - example/ruby/Gem/Net/HTTPFailedDependency.md | 19 - example/ruby/Gem/Net/HTTPFatalError.md | 13 - example/ruby/Gem/Net/HTTPForbidden.md | 20 - example/ruby/Gem/Net/HTTPFound.md | 19 - example/ruby/Gem/Net/HTTPGatewayTimeout.md | 21 - example/ruby/Gem/Net/HTTPGenericRequest.md | 615 -- .../Gem/Net/HTTPGenericRequest/Chunker.md | 17 - example/ruby/Gem/Net/HTTPGone.md | 19 - example/ruby/Gem/Net/HTTPHeader.md | 706 --- example/ruby/Gem/Net/HTTPHeaderSyntaxError.md | 7 - example/ruby/Gem/Net/HTTPIMUsed.md | 19 - example/ruby/Gem/Net/HTTPInformation.md | 17 - .../ruby/Gem/Net/HTTPInsufficientStorage.md | 20 - .../ruby/Gem/Net/HTTPInternalServerError.md | 21 - example/ruby/Gem/Net/HTTPLengthRequired.md | 21 - example/ruby/Gem/Net/HTTPLocked.md | 17 - example/ruby/Gem/Net/HTTPLoopDetected.md | 18 - example/ruby/Gem/Net/HTTPMethodNotAllowed.md | 20 - .../ruby/Gem/Net/HTTPMisdirectedRequest.md | 19 - example/ruby/Gem/Net/HTTPMovedPermanently.md | 21 - example/ruby/Gem/Net/HTTPMultiStatus.md | 19 - example/ruby/Gem/Net/HTTPMultipleChoices.md | 21 - .../Net/HTTPNetworkAuthenticationRequired.md | 19 - example/ruby/Gem/Net/HTTPNoContent.md | 20 - .../Net/HTTPNonAuthoritativeInformation.md | 23 - example/ruby/Gem/Net/HTTPNotAcceptable.md | 21 - example/ruby/Gem/Net/HTTPNotExtended.md | 18 - example/ruby/Gem/Net/HTTPNotFound.md | 19 - example/ruby/Gem/Net/HTTPNotImplemented.md | 21 - example/ruby/Gem/Net/HTTPNotModified.md | 20 - example/ruby/Gem/Net/HTTPOK.md | 19 - example/ruby/Gem/Net/HTTPPartialContent.md | 21 - example/ruby/Gem/Net/HTTPPayloadTooLarge.md | 20 - example/ruby/Gem/Net/HTTPPaymentRequired.md | 20 - example/ruby/Gem/Net/HTTPPermanentRedirect.md | 20 - .../ruby/Gem/Net/HTTPPreconditionFailed.md | 21 - .../ruby/Gem/Net/HTTPPreconditionRequired.md | 18 - example/ruby/Gem/Net/HTTPProcessing.md | 18 - .../Net/HTTPProxyAuthenticationRequired.md | 21 - .../ruby/Gem/Net/HTTPRangeNotSatisfiable.md | 21 - example/ruby/Gem/Net/HTTPRedirection.md | 17 - example/ruby/Gem/Net/HTTPRequest.md | 97 - .../Net/HTTPRequestHeaderFieldsTooLarge.md | 20 - example/ruby/Gem/Net/HTTPRequestTimeout.md | 20 - example/ruby/Gem/Net/HTTPResetContent.md | 21 - example/ruby/Gem/Net/HTTPResponse.md | 774 --- example/ruby/Gem/Net/HTTPResponse/Inflater.md | 42 - example/ruby/Gem/Net/HTTPRetriableError.md | 13 - example/ruby/Gem/Net/HTTPSeeOther.md | 20 - example/ruby/Gem/Net/HTTPServerError.md | 16 - .../ruby/Gem/Net/HTTPServiceUnavailable.md | 21 - example/ruby/Gem/Net/HTTPSuccess.md | 17 - example/ruby/Gem/Net/HTTPSwitchProtocol.md | 21 - example/ruby/Gem/Net/HTTPTemporaryRedirect.md | 21 - example/ruby/Gem/Net/HTTPTooManyRequests.md | 18 - example/ruby/Gem/Net/HTTPURITooLong.md | 19 - example/ruby/Gem/Net/HTTPUnauthorized.md | 19 - .../Gem/Net/HTTPUnavailableForLegalReasons.md | 20 - example/ruby/Gem/Net/HTTPUnknownResponse.md | 7 - .../ruby/Gem/Net/HTTPUnprocessableEntity.md | 20 - .../ruby/Gem/Net/HTTPUnsupportedMediaType.md | 21 - example/ruby/Gem/Net/HTTPUpgradeRequired.md | 20 - example/ruby/Gem/Net/HTTPUseProxy.md | 19 - .../ruby/Gem/Net/HTTPVariantAlsoNegotiates.md | 19 - .../ruby/Gem/Net/HTTPVersionNotSupported.md | 20 - example/ruby/Gem/Net/InternetMessageIO.md | 26 - example/ruby/Gem/Net/NetPrivate.md | 7 - example/ruby/Gem/Net/OpenTimeout.md | 9 - example/ruby/Gem/Net/ProtoAuthError.md | 7 - example/ruby/Gem/Net/ProtoCommandError.md | 7 - example/ruby/Gem/Net/ProtoFatalError.md | 7 - example/ruby/Gem/Net/ProtoRetriableError.md | 7 - example/ruby/Gem/Net/ProtoServerError.md | 7 - example/ruby/Gem/Net/ProtoSyntaxError.md | 7 - example/ruby/Gem/Net/ProtoUnknownError.md | 7 - example/ruby/Gem/Net/Protocol.md | 8 - example/ruby/Gem/Net/ProtocolError.md | 7 - example/ruby/Gem/Net/ReadAdapter.md | 17 - example/ruby/Gem/Net/ReadTimeout.md | 20 - example/ruby/Gem/Net/WriteAdapter.md | 23 - example/ruby/Gem/Net/WriteTimeout.md | 20 - example/ruby/Gem/NoAliasYAMLTree.md | 17 - .../ruby/Gem/OperationNotSupportedError.md | 7 - example/ruby/Gem/OptionParser.md | 750 --- example/ruby/Gem/OptionParser/AC.md | 24 - example/ruby/Gem/OptionParser/Acceptables.md | 8 - .../Gem/OptionParser/AmbiguousArgument.md | 8 - .../ruby/Gem/OptionParser/AmbiguousOption.md | 8 - example/ruby/Gem/OptionParser/Arguable.md | 51 - .../ruby/Gem/OptionParser/CompletingHash.md | 20 - example/ruby/Gem/OptionParser/Completion.md | 19 - .../ruby/Gem/OptionParser/InvalidArgument.md | 8 - .../ruby/Gem/OptionParser/InvalidOption.md | 8 - example/ruby/Gem/OptionParser/List.md | 103 - .../ruby/Gem/OptionParser/MissingArgument.md | 8 - .../ruby/Gem/OptionParser/NeedlessArgument.md | 8 - example/ruby/Gem/OptionParser/OptionMap.md | 17 - example/ruby/Gem/OptionParser/ParseError.md | 38 - example/ruby/Gem/OptionParser/Switch.md | 90 - .../Gem/OptionParser/Switch/NoArgument.md | 22 - .../OptionParser/Switch/OptionalArgument.md | 15 - .../Gem/OptionParser/Switch/PlacedArgument.md | 15 - .../OptionParser/Switch/RequiredArgument.md | 15 - example/ruby/Gem/Package.md | 254 - example/ruby/Gem/Package/DigestIO.md | 46 - example/ruby/Gem/Package/Error.md | 7 - example/ruby/Gem/Package/FileSource.md | 31 - example/ruby/Gem/Package/FormatError.md | 16 - example/ruby/Gem/Package/IOSource.md | 33 - example/ruby/Gem/Package/NonSeekableIO.md | 7 - example/ruby/Gem/Package/Old.md | 44 - example/ruby/Gem/Package/PathError.md | 12 - example/ruby/Gem/Package/Source.md | 8 - example/ruby/Gem/Package/SymlinkError.md | 12 - example/ruby/Gem/Package/TarHeader.md | 56 - example/ruby/Gem/Package/TarInvalidError.md | 8 - example/ruby/Gem/Package/TarReader.md | 2055 ------ example/ruby/Gem/Package/TarReader/Entry.md | 86 - example/ruby/Gem/Package/TarTestCase.md | 49 - example/ruby/Gem/Package/TarWriter.md | 70 - .../Gem/Package/TarWriter/BoundedStream.md | 25 - .../Gem/Package/TarWriter/FileOverflow.md | 7 - .../Gem/Package/TarWriter/RestrictedStream.md | 17 - example/ruby/Gem/Package/TooLongFileName.md | 7 - example/ruby/Gem/PackageTask.md | 63 - example/ruby/Gem/PathSupport.md | 26 - example/ruby/Gem/Platform.md | 87 - example/ruby/Gem/PlatformMismatch.md | 37 - example/ruby/Gem/QueryUtils.md | 85 - example/ruby/Gem/RemoteError.md | 11 - example/ruby/Gem/RemoteFetcher.md | 139 - example/ruby/Gem/RemoteFetcher/FetchError.md | 24 - .../Gem/RemoteFetcher/UnknownHostError.md | 9 - .../ruby/Gem/RemoteInstallationCancelled.md | 7 - example/ruby/Gem/RemoteInstallationSkipped.md | 7 - example/ruby/Gem/RemoteSourceException.md | 8 - example/ruby/Gem/Request.md | 156 - example/ruby/Gem/Request/ConnectionPools.md | 21 - example/ruby/Gem/Request/HTTPPool.md | 28 - example/ruby/Gem/Request/HTTPSPool.md | 8 - example/ruby/Gem/RequestSet.md | 255 - .../ruby/Gem/RequestSet/GemDependencyAPI.md | 294 - example/ruby/Gem/RequestSet/Lockfile.md | 50 - .../Gem/RequestSet/Lockfile/ParseError.md | 25 - .../ruby/Gem/RequestSet/Lockfile/Parser.md | 37 - .../ruby/Gem/RequestSet/Lockfile/Tokenizer.md | 34 - .../RequestSet/Lockfile/Tokenizer/Token.md | 28 - example/ruby/Gem/Requirement.md | 111 - .../Gem/Requirement/BadRequirementError.md | 8 - example/ruby/Gem/Resolv.md | 76 - example/ruby/Gem/Resolv/DNS.md | 166 - example/ruby/Gem/Resolv/DNS/Config.md | 36 - .../ruby/Gem/Resolv/DNS/Config/NXDomain.md | 8 - .../Gem/Resolv/DNS/Config/OtherResolvError.md | 8 - example/ruby/Gem/Resolv/DNS/DecodeError.md | 8 - example/ruby/Gem/Resolv/DNS/EncodeError.md | 8 - example/ruby/Gem/Resolv/DNS/Label.md | 9 - example/ruby/Gem/Resolv/DNS/Label/Str.md | 32 - example/ruby/Gem/Resolv/DNS/Message.md | 74 - .../Gem/Resolv/DNS/Message/MessageDecoder.md | 47 - .../Gem/Resolv/DNS/Message/MessageEncoder.md | 35 - example/ruby/Gem/Resolv/DNS/Name.md | 75 - example/ruby/Gem/Resolv/DNS/OpCode.md | 7 - example/ruby/Gem/Resolv/DNS/Query.md | 19 - example/ruby/Gem/Resolv/DNS/RCode.md | 7 - example/ruby/Gem/Resolv/DNS/Requester.md | 19 - .../Gem/Resolv/DNS/Requester/ConnectedUDP.md | 21 - .../DNS/Requester/ConnectedUDP/Sender.md | 15 - .../Gem/Resolv/DNS/Requester/MDNSOneShot.md | 13 - .../Gem/Resolv/DNS/Requester/RequestError.md | 8 - .../ruby/Gem/Resolv/DNS/Requester/Sender.md | 13 - example/ruby/Gem/Resolv/DNS/Requester/TCP.md | 19 - .../Gem/Resolv/DNS/Requester/TCP/Sender.md | 15 - .../Resolv/DNS/Requester/UnconnectedUDP.md | 21 - .../DNS/Requester/UnconnectedUDP/Sender.md | 19 - example/ruby/Gem/Resolv/DNS/Resource.md | 36 - example/ruby/Gem/Resolv/DNS/Resource/ANY.md | 8 - example/ruby/Gem/Resolv/DNS/Resource/CAA.md | 39 - example/ruby/Gem/Resolv/DNS/Resource/CNAME.md | 8 - .../Gem/Resolv/DNS/Resource/DomainName.md | 24 - .../ruby/Gem/Resolv/DNS/Resource/Generic.md | 26 - example/ruby/Gem/Resolv/DNS/Resource/HINFO.md | 27 - example/ruby/Gem/Resolv/DNS/Resource/IN.md | 7 - example/ruby/Gem/Resolv/DNS/Resource/IN/A.md | 24 - .../ruby/Gem/Resolv/DNS/Resource/IN/AAAA.md | 24 - .../ruby/Gem/Resolv/DNS/Resource/IN/HTTPS.md | 8 - .../ruby/Gem/Resolv/DNS/Resource/IN/SRV.md | 55 - .../ruby/Gem/Resolv/DNS/Resource/IN/SVCB.md | 8 - .../Resolv/DNS/Resource/IN/ServiceBinding.md | 43 - .../ruby/Gem/Resolv/DNS/Resource/IN/WKS.md | 33 - example/ruby/Gem/Resolv/DNS/Resource/LOC.md | 47 - example/ruby/Gem/Resolv/DNS/Resource/MINFO.md | 26 - example/ruby/Gem/Resolv/DNS/Resource/MX.md | 27 - example/ruby/Gem/Resolv/DNS/Resource/NS.md | 8 - example/ruby/Gem/Resolv/DNS/Resource/PTR.md | 8 - example/ruby/Gem/Resolv/DNS/Resource/SOA.md | 46 - example/ruby/Gem/Resolv/DNS/Resource/TXT.md | 26 - example/ruby/Gem/Resolv/DNS/SvcParam.md | 13 - example/ruby/Gem/Resolv/DNS/SvcParam/ALPN.md | 24 - .../ruby/Gem/Resolv/DNS/SvcParam/DoHPath.md | 24 - .../ruby/Gem/Resolv/DNS/SvcParam/Generic.md | 25 - .../ruby/Gem/Resolv/DNS/SvcParam/IPv4Hint.md | 24 - .../ruby/Gem/Resolv/DNS/SvcParam/IPv6Hint.md | 24 - .../ruby/Gem/Resolv/DNS/SvcParam/Mandatory.md | 24 - .../Gem/Resolv/DNS/SvcParam/NoDefaultALPN.md | 15 - example/ruby/Gem/Resolv/DNS/SvcParam/Port.md | 24 - example/ruby/Gem/Resolv/DNS/SvcParams.md | 2078 ------ example/ruby/Gem/Resolv/Hosts.md | 39 - example/ruby/Gem/Resolv/IPv4.md | 40 - example/ruby/Gem/Resolv/IPv6.md | 49 - example/ruby/Gem/Resolv/LOC.md | 6 - example/ruby/Gem/Resolv/LOC/Alt.md | 44 - example/ruby/Gem/Resolv/LOC/Coord.md | 47 - example/ruby/Gem/Resolv/LOC/Size.md | 44 - example/ruby/Gem/Resolv/MDNS.md | 42 - example/ruby/Gem/Resolv/ResolvError.md | 8 - example/ruby/Gem/Resolv/ResolvTimeout.md | 8 - example/ruby/Gem/Resolver.md | 149 - example/ruby/Gem/Resolver/APISet.md | 43 - example/ruby/Gem/Resolver/APISet/GemParser.md | 10 - example/ruby/Gem/Resolver/APISpecification.md | 45 - .../ruby/Gem/Resolver/ActivationRequest.md | 70 - example/ruby/Gem/Resolver/BestSet.md | 29 - example/ruby/Gem/Resolver/ComposedSet.md | 40 - example/ruby/Gem/Resolver/Conflict.md | 52 - example/ruby/Gem/Resolver/CurrentSet.md | 12 - .../ruby/Gem/Resolver/DependencyRequest.md | 75 - example/ruby/Gem/Resolver/GitSet.md | 56 - example/ruby/Gem/Resolver/GitSpecification.md | 25 - example/ruby/Gem/Resolver/IndexSet.md | 21 - .../ruby/Gem/Resolver/IndexSpecification.md | 51 - .../Gem/Resolver/InstalledSpecification.md | 29 - example/ruby/Gem/Resolver/InstallerSet.md | 78 - .../ruby/Gem/Resolver/LocalSpecification.md | 22 - example/ruby/Gem/Resolver/LockSet.md | 36 - .../ruby/Gem/Resolver/LockSpecification.md | 32 - example/ruby/Gem/Resolver/RequirementList.md | 2101 ------- example/ruby/Gem/Resolver/Set.md | 45 - example/ruby/Gem/Resolver/SourceSet.md | 25 - .../ruby/Gem/Resolver/SpecSpecification.md | 42 - example/ruby/Gem/Resolver/Specification.md | 78 - example/ruby/Gem/Resolver/Stats.md | 24 - example/ruby/Gem/Resolver/VendorSet.md | 47 - .../ruby/Gem/Resolver/VendorSpecification.md | 20 - example/ruby/Gem/RubyVersionMismatch.md | 9 - .../ruby/Gem/RuntimeRequirementNotMetError.md | 14 - example/ruby/Gem/S3URISigner.md | 24 - .../Gem/S3URISigner/ConfigurationError.md | 15 - .../Gem/S3URISigner/InstanceProfileError.md | 15 - example/ruby/Gem/S3URISigner/S3Config.md | 7 - example/ruby/Gem/SafeMarshal.md | 12 - example/ruby/Gem/SafeMarshal/Elements.md | 6 - .../ruby/Gem/SafeMarshal/Elements/Array.md | 16 - .../ruby/Gem/SafeMarshal/Elements/Bignum.md | 20 - .../ruby/Gem/SafeMarshal/Elements/Element.md | 7 - .../ruby/Gem/SafeMarshal/Elements/False.md | 12 - .../ruby/Gem/SafeMarshal/Elements/Float.md | 16 - example/ruby/Gem/SafeMarshal/Elements/Hash.md | 16 - .../Elements/HashWithDefaultValue.md | 16 - .../ruby/Gem/SafeMarshal/Elements/Integer.md | 16 - example/ruby/Gem/SafeMarshal/Elements/Nil.md | 7 - .../ruby/Gem/SafeMarshal/Elements/Object.md | 16 - .../Gem/SafeMarshal/Elements/ObjectLink.md | 16 - .../ruby/Gem/SafeMarshal/Elements/String.md | 16 - .../ruby/Gem/SafeMarshal/Elements/Symbol.md | 16 - .../Gem/SafeMarshal/Elements/SymbolLink.md | 16 - example/ruby/Gem/SafeMarshal/Elements/True.md | 12 - .../Gem/SafeMarshal/Elements/UserClass.md | 19 - .../Gem/SafeMarshal/Elements/UserDefined.md | 19 - .../Gem/SafeMarshal/Elements/UserMarshal.md | 19 - .../Gem/SafeMarshal/Elements/WithIvars.md | 19 - example/ruby/Gem/SafeMarshal/Reader.md | 16 - .../SafeMarshal/Reader/DataTooShortError.md | 7 - .../ruby/Gem/SafeMarshal/Reader/EOFError.md | 7 - example/ruby/Gem/SafeMarshal/Reader/Error.md | 7 - .../SafeMarshal/Reader/NegativeLengthError.md | 7 - .../SafeMarshal/Reader/NotImplementedError.md | 7 - .../Reader/UnconsumedBytesError.md | 7 - .../Reader/UnsupportedVersionError.md | 7 - example/ruby/Gem/SafeMarshal/Visitors.md | 6 - .../Gem/SafeMarshal/Visitors/StreamPrinter.md | 14 - .../ruby/Gem/SafeMarshal/Visitors/ToRuby.md | 17 - .../Gem/SafeMarshal/Visitors/ToRuby/Error.md | 7 - .../Visitors/ToRuby/FormatError.md | 7 - .../Visitors/ToRuby/MethodCallError.md | 7 - .../Visitors/ToRuby/TimeTooLargeError.md | 12 - .../Visitors/ToRuby/UnpermittedClassError.md | 12 - .../Visitors/ToRuby/UnpermittedIvarError.md | 12 - .../Visitors/ToRuby/UnpermittedSymbolError.md | 12 - .../Visitors/ToRuby/UnsupportedError.md | 12 - .../ruby/Gem/SafeMarshal/Visitors/Visitor.md | 10 - example/ruby/Gem/SafeYAML.md | 18 - example/ruby/Gem/SecureRandom.md | 266 - example/ruby/Gem/Security.md | 52 - example/ruby/Gem/Security/Exception.md | 8 - example/ruby/Gem/Security/Policy.md | 151 - example/ruby/Gem/Security/Signer.md | 129 - example/ruby/Gem/Security/TrustDir.md | 43 - example/ruby/Gem/SecurityOption.md | 10 - example/ruby/Gem/SilentUI.md | 22 - example/ruby/Gem/SilentUI/NullIO.md | 21 - example/ruby/Gem/Source.md | 162 - example/ruby/Gem/Source/Git.md | 86 - example/ruby/Gem/Source/Installed.md | 23 - example/ruby/Gem/Source/Local.md | 38 - example/ruby/Gem/Source/Lock.md | 36 - example/ruby/Gem/Source/SpecificFile.md | 48 - example/ruby/Gem/Source/Vendor.md | 16 - example/ruby/Gem/SourceFetchProblem.md | 24 - example/ruby/Gem/SourceList.md | 2090 ------- example/ruby/Gem/SpecFetcher.md | 130 - .../ruby/Gem/SpecificGemNotFoundException.md | 25 - example/ruby/Gem/Specification.md | 2931 --------- .../Gem/Specification/AllowSettingSource.md | 9 - .../Gem/Specification/RequirePathFlattener.md | 9 - example/ruby/Gem/SpecificationPolicy.md | 122 - example/ruby/Gem/SpecificationRecord.md | 2127 ------- example/ruby/Gem/StreamUI.md | 88 - .../Gem/StreamUI/SilentDownloadReporter.md | 25 - .../Gem/StreamUI/SilentProgressReporter.md | 26 - .../Gem/StreamUI/SimpleProgressReporter.md | 58 - .../Gem/StreamUI/ThreadedDownloadReporter.md | 29 - .../Gem/StreamUI/VerboseProgressReporter.md | 58 - example/ruby/Gem/StubSpecification.md | 85 - .../ruby/Gem/StubSpecification/StubLine.md | 32 - example/ruby/Gem/SystemExitException.md | 15 - example/ruby/Gem/TSort.md | 359 -- example/ruby/Gem/TSort/Cyclic.md | 7 - example/ruby/Gem/TargetRbConfig.md | 32 - example/ruby/Gem/TempIO.md | 20 - example/ruby/Gem/TestCase.md | 370 -- example/ruby/Gem/TestCase/SpecFetcherSetup.md | 72 - example/ruby/Gem/TestCase/StaticSet.md | 35 - example/ruby/Gem/Text.md | 29 - example/ruby/Gem/Timeout.md | 65 - example/ruby/Gem/Timeout/Error.md | 11 - example/ruby/Gem/Timeout/ExitException.md | 12 - example/ruby/Gem/URI.md | 366 -- example/ruby/Gem/URI/BadURIError.md | 8 - example/ruby/Gem/URI/Error.md | 8 - example/ruby/Gem/URI/FTP.md | 91 - example/ruby/Gem/URI/File.md | 70 - example/ruby/Gem/URI/Generic.md | 441 -- example/ruby/Gem/URI/HTTP.md | 75 - example/ruby/Gem/URI/HTTPS.md | 10 - example/ruby/Gem/URI/InvalidComponentError.md | 8 - example/ruby/Gem/URI/InvalidURIError.md | 8 - example/ruby/Gem/URI/LDAP.md | 85 - example/ruby/Gem/URI/LDAPS.md | 10 - example/ruby/Gem/URI/MailTo.md | 70 - example/ruby/Gem/URI/RFC2396_Parser.md | 154 - example/ruby/Gem/URI/RFC2396_REGEXP.md | 7 - .../ruby/Gem/URI/RFC2396_REGEXP/PATTERN.md | 7 - example/ruby/Gem/URI/RFC3986_Parser.md | 40 - example/ruby/Gem/URI/Util.md | 9 - example/ruby/Gem/URI/WS.md | 49 - example/ruby/Gem/URI/WSS.md | 9 - example/ruby/Gem/UninstallError.md | 12 - example/ruby/Gem/Uninstaller.md | 151 - example/ruby/Gem/UnknownCommandError.md | 18 - .../ruby/Gem/UnknownCommandSpellChecker.md | 18 - .../ruby/Gem/UnsatisfiableDependencyError.md | 30 - example/ruby/Gem/UpdateSuggestion.md | 16 - example/ruby/Gem/Uri.md | 34 - example/ruby/Gem/UriFormatter.md | 31 - example/ruby/Gem/UserInteraction.md | 88 - example/ruby/Gem/Util.md | 32 - example/ruby/Gem/Validator.md | 89 - example/ruby/Gem/Validator/ErrorData.md | 23 - example/ruby/Gem/VerificationError.md | 8 - example/ruby/Gem/Version.md | 340 - example/ruby/Gem/VersionOption.md | 20 - example/ruby/Gem/WebauthnVerificationError.md | 14 - example/ruby/Gem/YAMLSerializer.md | 12 - example/ruby/GemTest.md | 14 - example/ruby/Git.md | 24 - example/ruby/Gods.md | 14 - example/ruby/HCMSpecs.md | 7 - example/ruby/HIMMSpecs.md | 10 - example/ruby/HIMMSpecs/Subclass.md | 10 - example/ruby/HMACConstants.md | 6 - example/ruby/HMMSpecs.md | 10 - example/ruby/HMMSpecs/Subclass.md | 10 - example/ruby/HPIMMSpecs.md | 10 - example/ruby/HPIMMSpecs/Subclass.md | 10 - example/ruby/HPMMSpecs.md | 7 - example/ruby/HSMMSpecs.md | 9 - example/ruby/HTTPHeaderTest.md | 96 - example/ruby/HTTPHeaderTest/C.md | 530 -- example/ruby/HTTPHeaderTest/D.md | 522 -- example/ruby/HTTPRequestTest.md | 20 - example/ruby/HTTPResponseTest.md | 76 - example/ruby/HTTPResponsesTest.md | 10 - example/ruby/HTTPSProxyTest.md | 14 - example/ruby/Hash.md | 3122 --------- example/ruby/HashSpecs.md | 9 - example/ruby/HashSpecs/ByIdentityKey.md | 10 - example/ruby/HashSpecs/ByValueKey.md | 22 - example/ruby/HashSpecs/DefaultHash.md | 10 - example/ruby/HashSpecs/KeyWithPrivateHash.md | 7 - example/ruby/HashSpecs/MyHash.md | 7 - example/ruby/HashSpecs/MyInitializerHash.md | 12 - example/ruby/HashSpecs/NewHash.md | 12 - .../HashSpecs/SubHashSettingInInitialize.md | 12 - example/ruby/HashSpecs/ToHashHash.md | 10 - example/ruby/HashStringsBinary.md | 8 - example/ruby/HashStringsUSASCII.md | 8 - example/ruby/HashStringsUTF8.md | 8 - example/ruby/HaveClassVariableMatcher.md | 7 - example/ruby/HaveConstantMatcher.md | 7 - example/ruby/HaveInstanceMethodMatcher.md | 16 - example/ruby/HaveInstanceVariableMatcher.md | 7 - example/ruby/HaveMethodMatcher.md | 16 - .../ruby/HavePrivateInstanceMethodMatcher.md | 16 - example/ruby/HavePrivateMethodMatcher.md | 16 - .../HaveProtectedInstanceMethodMatcher.md | 16 - .../ruby/HavePublicInstanceMethodMatcher.md | 16 - example/ruby/HaveSingletonMethodMatcher.md | 16 - example/ruby/HeaderParser.md | 16 - example/ruby/HelloWorld.md | 12 - example/ruby/Hi_Exception.md | 12 - example/ruby/Hoge.md | 16 - example/ruby/HtmlFormatter.md | 24 - example/ruby/HumanTypoTest.md | 14 - example/ruby/IEHandler.md | 24 - example/ruby/IE_CONST.md | 10 - example/ruby/IO.md | 5557 ----------------- example/ruby/IO/Buffer.md | 841 --- example/ruby/IO/Buffer/AccessError.md | 7 - example/ruby/IO/Buffer/AllocationError.md | 7 - example/ruby/IO/Buffer/InvalidatedError.md | 7 - example/ruby/IO/Buffer/LockedError.md | 7 - example/ruby/IO/Buffer/MaskError.md | 7 - example/ruby/IO/ConsoleMode.md | 16 - example/ruby/IO/EAGAINWaitReadable.md | 9 - example/ruby/IO/EAGAINWaitWritable.md | 9 - example/ruby/IO/EINPROGRESSWaitReadable.md | 9 - example/ruby/IO/EINPROGRESSWaitWritable.md | 9 - example/ruby/IO/EWOULDBLOCKWaitReadable.md | 9 - example/ruby/IO/EWOULDBLOCKWaitWritable.md | 9 - example/ruby/IO/TimeoutError.md | 7 - example/ruby/IO/WaitReadable.md | 6 - example/ruby/IO/WaitWritable.md | 6 - example/ruby/IO/generic_readable.md | 61 - example/ruby/IO/generic_writable.md | 20 - example/ruby/IOBufferScheduler.md | 20 - example/ruby/IOError.md | 20 - example/ruby/IOSpec.md | 8 - example/ruby/IOSpecs.md | 31 - example/ruby/IOSpecs/CopyStream.md | 9 - example/ruby/IOSpecs/CopyStreamRead.md | 16 - example/ruby/IOSpecs/CopyStreamReadPartial.md | 16 - example/ruby/IOSpecs/SubIO.md | 7 - example/ruby/IOSpecs/SubIOWithRedefinedNew.md | 14 - example/ruby/IOStub.md | 34 - example/ruby/IPAddr.md | 286 - example/ruby/IPAddr/AddressFamilyError.md | 10 - example/ruby/IPAddr/Error.md | 9 - example/ruby/IPAddr/InvalidAddressError.md | 8 - example/ruby/IPAddr/InvalidPrefixError.md | 8 - example/ruby/IPSocket.md | 83 - example/ruby/IRB.md | 66 - example/ruby/IRB/Abort.md | 8 - example/ruby/IRB/BaseCompletor.md | 25 - example/ruby/IRB/CallTracer.md | 12 - example/ruby/IRB/CantChangeBinding.md | 12 - example/ruby/IRB/CantReturnToNormalMode.md | 12 - example/ruby/IRB/Canvas.md | 16 - example/ruby/IRB/Color.md | 21 - example/ruby/IRB/ColorPrinter.md | 14 - example/ruby/IRB/Command.md | 28 - example/ruby/IRB/Command/Backtrace.md | 10 - example/ruby/IRB/Command/Base.md | 23 - example/ruby/IRB/Command/Break.md | 10 - example/ruby/IRB/Command/CD.md | 10 - example/ruby/IRB/Command/Catch.md | 10 - example/ruby/IRB/Command/ChangeWorkspace.md | 10 - .../ruby/IRB/Command/CommandArgumentError.md | 8 - example/ruby/IRB/Command/Context.md | 10 - example/ruby/IRB/Command/Continue.md | 10 - .../IRB/Command/CurrentWorkingWorkspace.md | 10 - example/ruby/IRB/Command/Debug.md | 12 - example/ruby/IRB/Command/DebugCommand.md | 10 - example/ruby/IRB/Command/Delete.md | 10 - example/ruby/IRB/Command/DisableIrb.md | 10 - example/ruby/IRB/Command/Edit.md | 17 - example/ruby/IRB/Command/Exit.md | 10 - example/ruby/IRB/Command/Finish.md | 10 - example/ruby/IRB/Command/ForceExit.md | 10 - example/ruby/IRB/Command/Foreground.md | 14 - example/ruby/IRB/Command/Help.md | 10 - example/ruby/IRB/Command/History.md | 10 - example/ruby/IRB/Command/Info.md | 10 - example/ruby/IRB/Command/IrbCommand.md | 12 - example/ruby/IRB/Command/IrbInfo.md | 10 - example/ruby/IRB/Command/Jobs.md | 10 - example/ruby/IRB/Command/Kill.md | 12 - example/ruby/IRB/Command/Load.md | 12 - example/ruby/IRB/Command/LoaderCommand.md | 40 - example/ruby/IRB/Command/Ls.md | 16 - .../ruby/IRB/Command/Ls/EvaluationError.md | 7 - example/ruby/IRB/Command/Measure.md | 23 - example/ruby/IRB/Command/MultiIRBCommand.md | 15 - example/ruby/IRB/Command/Next.md | 10 - example/ruby/IRB/Command/PopWorkspace.md | 10 - example/ruby/IRB/Command/PushWorkspace.md | 10 - example/ruby/IRB/Command/Require.md | 12 - example/ruby/IRB/Command/RubyArgsExtractor.md | 13 - example/ruby/IRB/Command/ShowDoc.md | 17 - example/ruby/IRB/Command/ShowSource.md | 17 - example/ruby/IRB/Command/Source.md | 12 - example/ruby/IRB/Command/Step.md | 10 - example/ruby/IRB/Command/Whereami.md | 10 - example/ruby/IRB/Command/Workspaces.md | 10 - example/ruby/IRB/Context.md | 347 - example/ruby/IRB/Debug.md | 9 - .../ruby/IRB/Debug/SkipPathHelperForIRB.md | 11 - example/ruby/IRB/Debug/UI.md | 34 - example/ruby/IRB/EvalHistory.md | 56 - example/ruby/IRB/ExtendCommandBundle.md | 20 - example/ruby/IRB/FileInputMethod.md | 37 - example/ruby/IRB/Frame.md | 35 - example/ruby/IRB/Frame/FrameOverflow.md | 12 - example/ruby/IRB/Frame/FrameUnderflow.md | 12 - example/ruby/IRB/HelperMethod.md | 13 - example/ruby/IRB/HelperMethod/Base.md | 25 - example/ruby/IRB/HelperMethod/Conf.md | 10 - example/ruby/IRB/HelpersContainer.md | 8 - example/ruby/IRB/History.md | 17 - example/ruby/IRB/HistorySavingAbility.md | 18 - example/ruby/IRB/IllegalParameter.md | 12 - example/ruby/IRB/InputCompletor.md | 8 - example/ruby/IRB/InputMethod.md | 38 - example/ruby/IRB/Inspector.md | 47 - example/ruby/IRB/Irb.md | 85 - example/ruby/IRB/IrbAlreadyDead.md | 12 - example/ruby/IRB/IrbLoader.md | 31 - .../ruby/IRB/IrbSwitchedToCurrentThread.md | 12 - example/ruby/IRB/JobManager.md | 77 - example/ruby/IRB/LoadAbort.md | 8 - example/ruby/IRB/Locale.md | 59 - example/ruby/IRB/NestingParser.md | 28 - example/ruby/IRB/NoSuchJob.md | 12 - example/ruby/IRB/Notifier.md | 16 - example/ruby/IRB/Notifier/AbstractNotifier.md | 55 - .../ruby/IRB/Notifier/CompositeNotifier.md | 38 - .../ruby/IRB/Notifier/ErrUndefinedNotifier.md | 12 - .../ruby/IRB/Notifier/ErrUnrecognizedLevel.md | 12 - example/ruby/IRB/Notifier/LeveledNotifier.md | 119 - example/ruby/IRB/Notifier/NoMsgNotifier.md | 24 - example/ruby/IRB/OutputMethod.md | 51 - example/ruby/IRB/Pager.md | 12 - example/ruby/IRB/ReadlineInputMethod.md | 49 - example/ruby/IRB/RegexpCompletor.md | 21 - example/ruby/IRB/ReidlineInputMethod.md | 12 - example/ruby/IRB/RelineInputMethod.md | 61 - example/ruby/IRB/RenderingTest.md | 54 - example/ruby/IRB/RubyLex.md | 49 - .../ruby/IRB/RubyLex/TerminateLineInput.md | 12 - example/ruby/IRB/RubyModel.md | 16 - example/ruby/IRB/SourceFinder.md | 14 - .../ruby/IRB/SourceFinder/EvaluationError.md | 7 - example/ruby/IRB/Statement.md | 30 - example/ruby/IRB/Statement/Command.md | 31 - example/ruby/IRB/Statement/EmptyInput.md | 23 - example/ruby/IRB/Statement/Expression.md | 24 - example/ruby/IRB/StdioInputMethod.md | 51 - example/ruby/IRB/StdioOutputMethod.md | 12 - example/ruby/IRB/TypeCompletor.md | 19 - example/ruby/IRB/UndefinedPromptMode.md | 12 - example/ruby/IRB/UnrecognizedSwitch.md | 13 - example/ruby/IRB/Vec.md | 30 - example/ruby/IRB/WorkSpace.md | 46 - example/ruby/ITER_TEST1.md | 10 - example/ruby/ITER_TEST2.md | 10 - example/ruby/ITER_TEST3.md | 10 - example/ruby/ITER_TEST4.md | 10 - example/ruby/ITER_TEST5.md | 14 - example/ruby/ITER_TEST6.md | 10 - example/ruby/IVarModMock.md | 9 - example/ruby/IXMLDOMAttribute.md | 145 - example/ruby/IXMLDOMCDATASection.md | 175 - example/ruby/IXMLDOMCharacterData.md | 170 - example/ruby/IXMLDOMComment.md | 170 - example/ruby/IXMLDOMDocument.md | 251 - example/ruby/IXMLDOMDocumentFragment.md | 136 - example/ruby/IXMLDOMDocumentType.md | 145 - example/ruby/IXMLDOMElement.md | 171 - example/ruby/IXMLDOMEntity.md | 145 - example/ruby/IXMLDOMEntityReference.md | 136 - example/ruby/IXMLDOMImplementation.md | 18 - example/ruby/IXMLDOMNamedNodeMap.md | 48 - example/ruby/IXMLDOMNode.md | 137 - example/ruby/IXMLDOMNodeList.md | 26 - example/ruby/IXMLDOMNotation.md | 142 - example/ruby/IXMLDOMParseError.md | 35 - example/ruby/IXMLDOMProcessingInstruction.md | 145 - example/ruby/IXMLDOMText.md | 175 - example/ruby/IXMLHttpRequest.md | 65 - example/ruby/IXTLRuntime.md | 180 - example/ruby/ImmutableString.md | 10 - example/ruby/IncludeAnyOfMatcher.md | 20 - example/ruby/IncludeMatcher.md | 20 - example/ruby/IncludesMath.md | 9 - example/ruby/IndexError.md | 13 - example/ruby/Indexer.md | 10 - example/ruby/Indexer/Repository.md | 30 - example/ruby/Indexer/Visitor.md | 22 - example/ruby/InfinityMatcher.md | 20 - example/ruby/Inspector.md | 18 - example/ruby/IntWrapper.md | 18 - example/ruby/Integer.md | 3055 --------- example/ruby/IntegerSpecs.md | 6 - example/ruby/IntegerSpecs/CoerceError.md | 7 - example/ruby/Interrupt.md | 29 - example/ruby/Isect.md | 25 - example/ruby/IterTest.md | 32 - example/ruby/JISX0208.md | 7 - example/ruby/JISX0208/Char.md | 32 - example/ruby/JITSupport.md | 25 - example/ruby/JSON.md | 1090 ---- example/ruby/JSON/CircularDatastructure.md | 8 - example/ruby/JSON/Ext.md | 8 - example/ruby/JSON/Ext/Generator.md | 12 - .../JSON/Ext/Generator/GeneratorMethods.md | 7 - .../Ext/Generator/GeneratorMethods/Array.md | 15 - .../Ext/Generator/GeneratorMethods/Bignum.md | 13 - .../Generator/GeneratorMethods/FalseClass.md | 13 - .../Ext/Generator/GeneratorMethods/Fixnum.md | 13 - .../Ext/Generator/GeneratorMethods/Float.md | 13 - .../Ext/Generator/GeneratorMethods/Hash.md | 15 - .../Ext/Generator/GeneratorMethods/Integer.md | 13 - .../Generator/GeneratorMethods/NilClass.md | 13 - .../Ext/Generator/GeneratorMethods/Object.md | 15 - .../Ext/Generator/GeneratorMethods/String.md | 33 - .../GeneratorMethods/String/Extend.md | 14 - .../Generator/GeneratorMethods/TrueClass.md | 13 - example/ruby/JSON/Ext/Generator/State.md | 242 - example/ruby/JSON/Ext/Parser.md | 60 - example/ruby/JSON/GeneratorError.md | 19 - example/ruby/JSON/GenericObject.md | 34 - example/ruby/JSON/JSONError.md | 10 - example/ruby/JSON/MissingUnicodeSupport.md | 9 - example/ruby/JSON/NestingError.md | 8 - example/ruby/JSON/ParserError.md | 8 - example/ruby/JSONAdditionTest.md | 36 - example/ruby/JSONAdditionTest/A.md | 22 - example/ruby/JSONAdditionTest/A2.md | 10 - example/ruby/JSONAdditionTest/B.md | 14 - example/ruby/JSONAdditionTest/C.md | 14 - example/ruby/JSONAdditionTest/MyJsonStruct.md | 18 - example/ruby/JSONCommonInterfaceTest.md | 60 - .../JSONCommonInterfaceTest/MethodMissing.md | 13 - example/ruby/JSONEncodingTest.md | 20 - example/ruby/JSONExtParserTest.md | 20 - example/ruby/JSONFixturesTest.md | 16 - example/ruby/JSONGeneratorTest.md | 94 - .../ruby/JSONGeneratorTest/ArrayWithToJSON.md | 12 - .../ruby/JSONGeneratorTest/ArrayWithToS.md | 12 - .../ruby/JSONGeneratorTest/CustomToJSON.md | 9 - example/ruby/JSONGeneratorTest/CustomToS.md | 9 - example/ruby/JSONGeneratorTest/FakeString.md | 12 - .../ruby/JSONGeneratorTest/HashWithToJSON.md | 12 - example/ruby/JSONGeneratorTest/HashWithToS.md | 12 - .../ruby/JSONGeneratorTest/MyCustomString.md | 12 - .../JSONGeneratorTest/StringWithToJSON.md | 12 - .../ruby/JSONGeneratorTest/StringWithToS.md | 12 - example/ruby/JSONGenericObjectTest.md | 22 - example/ruby/JSONInRactorTest.md | 10 - example/ruby/JSONParserTest.md | 88 - example/ruby/JSONParserTest/SubArray.md | 14 - example/ruby/JSONParserTest/SubArray2.md | 12 - .../ruby/JSONParserTest/SubArrayWrapper.md | 24 - example/ruby/JSONParserTest/SubHash.md | 14 - example/ruby/JSONParserTest/SubHash2.md | 12 - example/ruby/JSONParserTest/SubOpenStruct.md | 16 - example/ruby/JSONSpecs.md | 6 - example/ruby/JSONSpecs/MyClass.md | 16 - example/ruby/JSONStringMatchingTest.md | 12 - .../ruby/JSONStringMatchingTest/TestTime.md | 14 - example/ruby/JUnitFormatter.md | 18 - example/ruby/JaroWinklerTest.md | 17 - example/ruby/KSAutoloadB.md | 8 - example/ruby/KSAutoloadD.md | 8 - example/ruby/Kernel.md | 2146 ------- example/ruby/KernelSpecs.md | 20 - example/ruby/KernelSpecs/A.md | 13 - example/ruby/KernelSpecs/AncestorClass.md | 9 - example/ruby/KernelSpecs/AncestorModule.md | 6 - example/ruby/KernelSpecs/AutoloadMethod.md | 9 - .../AutoloadFromIncludedModule.md | 8 - example/ruby/KernelSpecs/AutoloadMethod2.md | 9 - .../AutoloadFromIncludedModule2.md | 8 - .../KernelSpecs/AutoloadMethodIncluder.md | 12 - .../KernelSpecs/AutoloadMethodIncluder2.md | 12 - example/ruby/KernelSpecs/B.md | 7 - example/ruby/KernelSpecs/Binding.md | 16 - example/ruby/KernelSpecs/BlockGiven.md | 9 - example/ruby/KernelSpecs/CalleeTest.md | 18 - .../ruby/KernelSpecs/CallerLocationsTest.md | 9 - example/ruby/KernelSpecs/CallerTest.md | 9 - example/ruby/KernelSpecs/Child.md | 7 - example/ruby/KernelSpecs/ClassMM.md | 12 - example/ruby/KernelSpecs/ClassNoMM.md | 14 - example/ruby/KernelSpecs/Clone.md | 10 - example/ruby/KernelSpecs/CloneFreeze.md | 10 - example/ruby/KernelSpecs/CustomRangeFloat.md | 22 - .../ruby/KernelSpecs/CustomRangeInteger.md | 22 - example/ruby/KernelSpecs/Dup.md | 10 - example/ruby/KernelSpecs/Duplicate.md | 24 - example/ruby/KernelSpecs/DuplicateM.md | 9 - example/ruby/KernelSpecs/EvalTest.md | 10 - example/ruby/KernelSpecs/Grandchild.md | 7 - example/ruby/KernelSpecs/InstanceClass.md | 9 - example/ruby/KernelSpecs/InstanceVariable.md | 12 - example/ruby/KernelSpecs/KernelBlockGiven.md | 9 - example/ruby/KernelSpecs/KindaClass.md | 14 - example/ruby/KernelSpecs/Lambda.md | 15 - example/ruby/KernelSpecs/LambdaSpecs.md | 6 - .../ruby/KernelSpecs/LambdaSpecs/Ampersand.md | 9 - .../LambdaSpecs/ForwardBlockWithZSuper.md | 12 - .../KernelSpecs/LambdaSpecs/SuperAmpersand.md | 12 - .../ruby/KernelSpecs/LambdaSpecs/ZSuper.md | 9 - example/ruby/KernelSpecs/M.md | 12 - example/ruby/KernelSpecs/Method.md | 7 - example/ruby/KernelSpecs/MethodTest.md | 18 - example/ruby/KernelSpecs/Methods.md | 18 - .../KernelSpecs/Methods/MetaclassMethods.md | 9 - example/ruby/KernelSpecs/ModuleMM.md | 11 - example/ruby/KernelSpecs/ModuleNoMM.md | 10 - example/ruby/KernelSpecs/MyExtensionModule.md | 6 - example/ruby/KernelSpecs/MyModule.md | 6 - example/ruby/KernelSpecs/MyPrependedModule.md | 6 - example/ruby/KernelSpecs/Parent.md | 18 - example/ruby/KernelSpecs/ParentMixin.md | 9 - example/ruby/KernelSpecs/PrivateSup.md | 7 - example/ruby/KernelSpecs/PrivateToA.md | 7 - example/ruby/KernelSpecs/PrivateToAry.md | 7 - example/ruby/KernelSpecs/PublicSub.md | 10 - example/ruby/KernelSpecs/RespondViaMissing.md | 14 - example/ruby/KernelSpecs/SelfBlockGiven.md | 9 - example/ruby/KernelSpecs/SomeOtherModule.md | 7 - example/ruby/KernelSpecs/VisibilityChange.md | 7 - example/ruby/KernelSpecs/WarnInNestedCall.md | 24 - example/ruby/KeyError.md | 28 - example/ruby/KeyNameCheckTest.md | 22 - example/ruby/LangSendSpecs.md | 52 - example/ruby/LangSendSpecs/Attr19Set.md | 14 - example/ruby/LangSendSpecs/AttrSet.md | 14 - example/ruby/LangSendSpecs/MethodMissing.md | 21 - example/ruby/LangSendSpecs/PrivateGetter.md | 12 - example/ruby/LangSendSpecs/PrivateSetter.md | 16 - example/ruby/LangSendSpecs/ToAry.md | 14 - example/ruby/LangSendSpecs/ToProc.md | 14 - example/ruby/LanguageSpecs.md | 15 - example/ruby/Launchable.md | 11 - example/ruby/Launchable/JsonStreamWriter.md | 20 - example/ruby/LaunchableFormatter.md | 20 - example/ruby/LeakChecker.md | 28 - example/ruby/LeakCheckerAction.md | 14 - example/ruby/LeakError.md | 17 - example/ruby/Lo_Exception.md | 12 - example/ruby/LoadError.md | 13 - example/ruby/LoadSpecWrap.md | 7 - example/ruby/LocalBarrier.md | 16 - example/ruby/LocalJumpError.md | 42 - example/ruby/Logger.md | 603 -- example/ruby/Logger/Error.md | 8 - example/ruby/Logger/Formatter.md | 19 - example/ruby/Logger/LogDevice.md | 55 - example/ruby/Logger/Period.md | 9 - example/ruby/Logger/Severity.md | 9 - example/ruby/Logger/ShiftingError.md | 8 - example/ruby/LoggerSpecs.md | 8 - example/ruby/Lrama.md | 10 - example/ruby/Lrama/Bitmap.md | 9 - example/ruby/Lrama/Command.md | 10 - example/ruby/Lrama/Context.md | 93 - example/ruby/Lrama/Counterexamples.md | 25 - .../ruby/Lrama/Counterexamples/Derivation.md | 28 - example/ruby/Lrama/Counterexamples/Example.md | 36 - example/ruby/Lrama/Counterexamples/Path.md | 22 - .../Lrama/Counterexamples/ProductionPath.md | 18 - .../ruby/Lrama/Counterexamples/StartPath.md | 22 - .../ruby/Lrama/Counterexamples/StateItem.md | 18 - .../Lrama/Counterexamples/TransitionPath.md | 18 - example/ruby/Lrama/Counterexamples/Triple.md | 29 - example/ruby/Lrama/Diagnostics.md | 14 - example/ruby/Lrama/Digraph.md | 15 - example/ruby/Lrama/Grammar.md | 188 - example/ruby/Lrama/Grammar/Auxiliary.md | 29 - example/ruby/Lrama/Grammar/Binding.md | 21 - example/ruby/Lrama/Grammar/Code.md | 69 - .../ruby/Lrama/Grammar/Code/DestructorCode.md | 12 - .../Lrama/Grammar/Code/InitialActionCode.md | 7 - .../Lrama/Grammar/Code/NoReferenceCode.md | 7 - .../ruby/Lrama/Grammar/Code/PrinterCode.md | 12 - example/ruby/Lrama/Grammar/Code/RuleAction.md | 12 - example/ruby/Lrama/Grammar/Counter.md | 14 - example/ruby/Lrama/Grammar/Destructor.md | 26 - example/ruby/Lrama/Grammar/ErrorToken.md | 26 - .../ruby/Lrama/Grammar/ParameterizingRule.md | 7 - .../Grammar/ParameterizingRule/Resolver.md | 29 - .../Lrama/Grammar/ParameterizingRule/Rhs.md | 24 - .../Lrama/Grammar/ParameterizingRule/Rule.md | 33 - example/ruby/Lrama/Grammar/PercentCode.md | 19 - example/ruby/Lrama/Grammar/Precedence.md | 106 - example/ruby/Lrama/Grammar/Printer.md | 26 - example/ruby/Lrama/Grammar/Reference.md | 48 - example/ruby/Lrama/Grammar/Rule.md | 95 - example/ruby/Lrama/Grammar/RuleBuilder.md | 45 - example/ruby/Lrama/Grammar/Symbol.md | 106 - example/ruby/Lrama/Grammar/Symbols.md | 7 - .../ruby/Lrama/Grammar/Symbols/Resolver.md | 55 - example/ruby/Lrama/Grammar/Type.md | 21 - example/ruby/Lrama/Grammar/Union.md | 21 - example/ruby/Lrama/GrammarValidator.md | 16 - example/ruby/Lrama/Lexer.md | 40 - example/ruby/Lrama/Lexer/GrammarFile.md | 25 - example/ruby/Lrama/Lexer/GrammarFile/Text.md | 10 - example/ruby/Lrama/Lexer/Location.md | 38 - example/ruby/Lrama/Lexer/Token.md | 43 - example/ruby/Lrama/Lexer/Token/Char.md | 7 - example/ruby/Lrama/Lexer/Token/Ident.md | 7 - .../ruby/Lrama/Lexer/Token/InstantiateRule.md | 23 - example/ruby/Lrama/Lexer/Token/Tag.md | 11 - example/ruby/Lrama/Lexer/Token/UserCode.md | 14 - example/ruby/Lrama/Logger.md | 16 - example/ruby/Lrama/OptionParser.md | 15 - example/ruby/Lrama/Options.md | 50 - example/ruby/Lrama/Output.md | 165 - example/ruby/Lrama/Parser.md | 10 - example/ruby/Lrama/Report.md | 7 - example/ruby/Lrama/Report/Duration.md | 14 - example/ruby/Lrama/Report/Profile.md | 9 - example/ruby/Lrama/State.md | 72 - example/ruby/Lrama/State/Reduce.md | 31 - .../ruby/Lrama/State/ReduceReduceConflict.md | 26 - example/ruby/Lrama/State/ResolvedConflict.md | 35 - example/ruby/Lrama/State/Shift.md | 22 - .../ruby/Lrama/State/ShiftReduceConflict.md | 26 - example/ruby/Lrama/States.md | 96 - example/ruby/Lrama/States/Item.md | 108 - example/ruby/Lrama/StatesReporter.md | 18 - example/ruby/Lrama/TraceReporter.md | 14 - example/ruby/M001.md | 6 - example/ruby/M002.md | 8 - example/ruby/M003.md | 8 - example/ruby/MD5Constants.md | 6 - example/ruby/MOSConfig.md | 12 - example/ruby/MPart.md | 15 - example/ruby/MSpec.md | 157 - example/ruby/MSpecCI.md | 12 - example/ruby/MSpecEnv.md | 9 - example/ruby/MSpecExampleError.md | 8 - example/ruby/MSpecMain.md | 20 - example/ruby/MSpecMatchers.md | 7 - example/ruby/MSpecOption.md | 36 - example/ruby/MSpecOptions.md | 126 - example/ruby/MSpecOptions/OptionError.md | 8 - example/ruby/MSpecOptions/ParseError.md | 8 - example/ruby/MSpecRun.md | 16 - example/ruby/MSpecScript.md | 110 - example/ruby/MSpecTag.md | 18 - example/ruby/MainSpecs.md | 8 - example/ruby/MainSpecs/Module.md | 6 - example/ruby/MainSpecs/WrapIncludeModule.md | 6 - example/ruby/MakeMakefile.md | 1296 ---- example/ruby/MakeMakefile/Logging.md | 24 - example/ruby/MapItem.md | 25 - example/ruby/Marshal.md | 68 - example/ruby/Marshal/InternalIVar.md | 16 - example/ruby/Marshal/InternalIVar/compat.md | 10 - example/ruby/Marshal/UsrMarshal.md | 16 - example/ruby/MarshalSpec.md | 10 - .../MarshalSpec/ArrayWithOverriddenName.md | 9 - .../BasicObjectSubWithRespondToFalse.md | 12 - .../MarshalSpec/ClassWithOverriddenName.md | 9 - example/ruby/MarshalSpec/DataSpec.md | 6 - .../DataSpec/MeasureWithOverriddenName.md | 9 - .../MarshalSpec/HashWithOverriddenName.md | 9 - example/ruby/MarshalSpec/M1.md | 7 - example/ruby/MarshalSpec/ModuleToExtendBy.md | 6 - .../MarshalSpec/ModuleWithOverriddenName.md | 9 - ...tibyte_E38181_E38182_E38183_E38184Class.md | 7 - ...ltibyte_E38181_E38182_E38183_E38184Time.md | 7 - ...ibyte_E38191_E38192_E38193_E38194Module.md | 6 - .../ObjectWithFreezeRaisingException.md | 10 - .../ruby/MarshalSpec/ObjectWithoutFreeze.md | 7 - .../MarshalSpec/RegexpWithOverriddenName.md | 9 - .../MarshalSpec/StringWithOverriddenName.md | 9 - example/ruby/MarshalSpec/StructToDump.md | 18 - .../MarshalSpec/StructWithOverriddenName.md | 15 - .../MarshalSpec/StructWithUserInitialize.md | 18 - .../MarshalSpec/TimeWithOverriddenName.md | 9 - .../UserDefinedWithOverriddenName.md | 9 - example/ruby/MarshalTestLib.md | 117 - example/ruby/MarshalTestLib/CyclicRange.md | 10 - example/ruby/MarshalTestLib/Mod1.md | 6 - example/ruby/MarshalTestLib/Mod2.md | 6 - example/ruby/MarshalTestLib/MyArray.md | 12 - example/ruby/MarshalTestLib/MyException.md | 16 - example/ruby/MarshalTestLib/MyHash.md | 12 - example/ruby/MarshalTestLib/MyObject.md | 16 - example/ruby/MarshalTestLib/MyRange.md | 12 - example/ruby/MarshalTestLib/MyRegexp.md | 12 - example/ruby/MarshalTestLib/MyString.md | 12 - example/ruby/MarshalTestLib/MyStruct.md | 18 - example/ruby/MarshalTestLib/MyStruct2.md | 18 - example/ruby/MarshalTestLib/MySubStruct.md | 12 - example/ruby/MarshalTestLib/MyTime.md | 12 - example/ruby/MatchData.md | 375 -- example/ruby/MatchDataSpecs.md | 6 - example/ruby/MatchDataSpecs/MyString.md | 7 - example/ruby/MatchFilter.md | 18 - example/ruby/MatchYAMLMatcher.md | 20 - example/ruby/Math.md | 480 -- example/ruby/Math/DomainError.md | 18 - example/ruby/MathSpecs.md | 6 - example/ruby/MathSpecs/Float.md | 14 - example/ruby/MathSpecs/Integer.md | 10 - example/ruby/MathSpecs/StringSubClass.md | 7 - example/ruby/MathSpecs/UserClass.md | 7 - example/ruby/MatrixSub.md | 9 - example/ruby/Mdoc2Man.md | 60 - example/ruby/Memory.md | 6 - example/ruby/Memory/Status.md | 18 - example/ruby/MemoryViewTestUtils.md | 17 - .../MemoryViewTestUtils/ExportableString.md | 10 - .../MultiDimensionalView.md | 12 - example/ruby/Merger_3DObject.new.md | 7 - example/ruby/MetaClassSpecs.md | 8 - example/ruby/MetaClassSpecs/A.md | 9 - example/ruby/MetaClassSpecs/B.md | 9 - example/ruby/MetaClassSpecs/C.md | 9 - example/ruby/MetaClassSpecs/D.md | 7 - example/ruby/MetaMetaMetaTestCase.md | 16 - example/ruby/Method.md | 344 - example/ruby/MethodFormatter.md | 32 - example/ruby/MethodMatcher.md | 18 - example/ruby/MethodNameCheckTest.md | 46 - example/ruby/MethodNameCheckTest/User.md | 29 - .../ruby/MethodNameCheckTest/UserModule.md | 9 - example/ruby/MethodSpecs.md | 6 - example/ruby/MethodSpecs/A.md | 12 - example/ruby/MethodSpecs/B.md | 10 - example/ruby/MethodSpecs/BetweenBAndC.md | 9 - example/ruby/MethodSpecs/C.md | 12 - example/ruby/MethodSpecs/Composition.md | 20 - example/ruby/MethodSpecs/D.md | 10 - example/ruby/MethodSpecs/Eql.md | 16 - example/ruby/MethodSpecs/Eql2.md | 10 - example/ruby/MethodSpecs/InheritedMethods.md | 6 - .../ruby/MethodSpecs/InheritedMethods/A.md | 6 - .../ruby/MethodSpecs/InheritedMethods/B.md | 6 - .../ruby/MethodSpecs/InheritedMethods/C.md | 9 - example/ruby/MethodSpecs/Methods.md | 90 - example/ruby/MethodSpecs/MyMod.md | 9 - example/ruby/MethodSpecs/MySub.md | 7 - example/ruby/MethodSpecs/MySuper.md | 12 - example/ruby/MethodSpecs/OverrideAgain.md | 9 - example/ruby/MethodSpecs/SourceLocation.md | 14 - example/ruby/MethodSpecs/ToProc.md | 12 - example/ruby/MethodSpecs/ToProcBeta.md | 12 - example/ruby/Meths.md | 9 - example/ruby/MethsMore.md | 9 - .../ruby/Microsoft_FreeThreadedXMLDOM_1_0.md | 274 - example/ruby/Microsoft_XMLDOM_1_0.md | 274 - example/ruby/Microsoft_XMLDSO_1_0.md | 45 - example/ruby/Microsoft_XMLHTTP_1.md | 81 - example/ruby/MkSpec.md | 32 - example/ruby/Mock.md | 26 - example/ruby/MockAndRaiseError.md | 7 - example/ruby/MockIntObject.md | 20 - example/ruby/MockObject.md | 12 - example/ruby/MockProxy.md | 69 - example/ruby/Module.md | 1058 ---- example/ruby/ModuleSpecs.md | 9 - example/ruby/ModuleSpecs/A.md | 11 - example/ruby/ModuleSpecs/AddConstant.md | 6 - example/ruby/ModuleSpecs/Alias.md | 9 - example/ruby/ModuleSpecs/Aliasing.md | 14 - example/ruby/ModuleSpecs/AliasingSubclass.md | 7 - example/ruby/ModuleSpecs/AliasingSuper.md | 6 - .../ruby/ModuleSpecs/AliasingSuper/Child.md | 11 - .../ruby/ModuleSpecs/AliasingSuper/Parent.md | 9 - .../AliasingSuper/RedefineAfterAlias.md | 14 - .../ruby/ModuleSpecs/AliasingSuper/Target.md | 9 - example/ruby/ModuleSpecs/Allonym.md | 12 - example/ruby/ModuleSpecs/Ancestor.md | 12 - example/ruby/ModuleSpecs/Anonymous.md | 6 - example/ruby/ModuleSpecs/Anonymous/Child.md | 6 - example/ruby/ModuleSpecs/Autoload.md | 8 - .../Autoload/AutoloadDuringRequire.md | 7 - .../Autoload/AutoloadSelfDuringRequire.md | 7 - example/ruby/ModuleSpecs/Autoload/Child.md | 7 - .../ModuleSpecs/Autoload/DuringAutoload.md | 7 - .../Autoload/DuringAutoloadAfterDefine.md | 7 - example/ruby/ModuleSpecs/Autoload/DynClass.md | 7 - .../ruby/ModuleSpecs/Autoload/DynClass/C.md | 10 - .../ruby/ModuleSpecs/Autoload/DynModule.md | 6 - .../ruby/ModuleSpecs/Autoload/DynModule/D.md | 10 - example/ruby/ModuleSpecs/Autoload/E.md | 10 - example/ruby/ModuleSpecs/Autoload/EX1.md | 10 - example/ruby/ModuleSpecs/Autoload/F.md | 8 - example/ruby/ModuleSpecs/Autoload/Foo.md | 6 - example/ruby/ModuleSpecs/Autoload/Foo/Bar.md | 7 - example/ruby/ModuleSpecs/Autoload/Foo/Baz.md | 7 - .../ruby/ModuleSpecs/Autoload/FromThread.md | 6 - .../ruby/ModuleSpecs/Autoload/FromThread/A.md | 6 - .../ModuleSpecs/Autoload/FromThread/A/B.md | 9 - .../ModuleSpecs/Autoload/FromThread/A/B/C.md | 9 - .../ruby/ModuleSpecs/Autoload/FromThread/D.md | 7 - example/ruby/ModuleSpecs/Autoload/G.md | 10 - .../ruby/ModuleSpecs/Autoload/GoodParent.md | 6 - .../ModuleSpecs/Autoload/GoodParent/Nested.md | 7 - example/ruby/ModuleSpecs/Autoload/H.md | 9 - example/ruby/ModuleSpecs/Autoload/KHash.md | 7 - example/ruby/ModuleSpecs/Autoload/LoadPath.md | 8 - example/ruby/ModuleSpecs/Autoload/Parent.md | 7 - example/ruby/ModuleSpecs/Autoload/R.md | 7 - .../ModuleSpecs/Autoload/RequiredDirectly.md | 7 - example/ruby/ModuleSpecs/Autoload/S.md | 6 - example/ruby/ModuleSpecs/Autoload/U.md | 6 - example/ruby/ModuleSpecs/Autoload/U/V.md | 9 - example/ruby/ModuleSpecs/Autoload/XX.md | 6 - .../Autoload/XX/CS_CONST_AUTOLOAD.md | 7 - example/ruby/ModuleSpecs/Autoload/YY.md | 7 - example/ruby/ModuleSpecs/Autoload/Z.md | 7 - example/ruby/ModuleSpecs/B.md | 15 - example/ruby/ModuleSpecs/Basic.md | 9 - example/ruby/ModuleSpecs/C.md | 14 - example/ruby/ModuleSpecs/CVars.md | 13 - .../ModuleSpecs/CaseCompareOnSingleton.md | 8 - example/ruby/ModuleSpecs/Child.md | 22 - example/ruby/ModuleSpecs/Child2.md | 11 - .../ChildPrivateMethodMadePublic.md | 7 - example/ruby/ModuleSpecs/ClassEvalTest.md | 9 - example/ruby/ModuleSpecs/ClassVars.md | 6 - example/ruby/ModuleSpecs/ClassVars/A.md | 7 - example/ruby/ModuleSpecs/ClassVars/B.md | 9 - example/ruby/ModuleSpecs/ClassVars/M.md | 6 - example/ruby/ModuleSpecs/ClassWithFoo.md | 10 - example/ruby/ModuleSpecs/ClassWithSuperFoo.md | 10 - example/ruby/ModuleSpecs/ConstAddedSpecs.md | 6 - example/ruby/ModuleSpecs/CountsChild.md | 10 - example/ruby/ModuleSpecs/CountsMixin.md | 12 - example/ruby/ModuleSpecs/CountsParent.md | 14 - example/ruby/ModuleSpecs/CyclicAppendA.md | 6 - example/ruby/ModuleSpecs/CyclicAppendB.md | 8 - example/ruby/ModuleSpecs/CyclicBarrier.md | 20 - example/ruby/ModuleSpecs/CyclicPrepend.md | 6 - example/ruby/ModuleSpecs/Detached.md | 9 - example/ruby/ModuleSpecs/ExtendObject.md | 9 - .../ruby/ModuleSpecs/ExtendObjectPrivate.md | 8 - example/ruby/ModuleSpecs/First.md | 10 - example/ruby/ModuleSpecs/Grandchild.md | 7 - example/ruby/ModuleSpecs/IncludedInObject.md | 6 - .../IncludedInObject/IncludedModuleSpecs.md | 6 - example/ruby/ModuleSpecs/IncludedModule.md | 9 - example/ruby/ModuleSpecs/InstanceMeth.md | 14 - example/ruby/ModuleSpecs/InstanceMethChild.md | 7 - example/ruby/ModuleSpecs/InstanceMethMod.md | 9 - example/ruby/ModuleSpecs/Internal.md | 6 - example/ruby/ModuleSpecs/Lookup.md | 9 - example/ruby/ModuleSpecs/LookupChild.md | 7 - example/ruby/ModuleSpecs/LookupMod.md | 8 - example/ruby/ModuleSpecs/LookupModInMod.md | 6 - example/ruby/ModuleSpecs/M1.md | 7 - example/ruby/ModuleSpecs/M2.md | 6 - example/ruby/ModuleSpecs/M3.md | 6 - example/ruby/ModuleSpecs/MA.md | 6 - example/ruby/ModuleSpecs/MB.md | 8 - example/ruby/ModuleSpecs/MC.md | 6 - example/ruby/ModuleSpecs/MVars.md | 6 - example/ruby/ModuleSpecs/ModuleWithPrepend.md | 8 - example/ruby/ModuleSpecs/Modules.md | 6 - example/ruby/ModuleSpecs/Modules/Klass.md | 7 - example/ruby/ModuleSpecs/MultipleIncludes.md | 9 - example/ruby/ModuleSpecs/NameEncoding.md | 10 - .../ruby/ModuleSpecs/NameEncoding/C_C39F.md | 7 - example/ruby/ModuleSpecs/NameSpecs.md | 6 - example/ruby/ModuleSpecs/NamedClass.md | 7 - example/ruby/ModuleSpecs/Nesting.md | 11 - .../ruby/ModuleSpecs/Nesting/NestedClass.md | 12 - example/ruby/ModuleSpecs/Parent.md | 24 - .../ModuleSpecs/ParentPrivateMethodRedef.md | 10 - example/ruby/ModuleSpecs/PrependedModule.md | 9 - example/ruby/ModuleSpecs/PrivConstModule.md | 6 - .../ruby/ModuleSpecs/RecordIncludedModules.md | 11 - .../ruby/ModuleSpecs/RemoveClassVariable.md | 7 - example/ruby/ModuleSpecs/ReopeningModule.md | 10 - example/ruby/ModuleSpecs/Second.md | 10 - example/ruby/ModuleSpecs/ShadowingOuter.md | 6 - example/ruby/ModuleSpecs/ShadowingOuter/M.md | 6 - example/ruby/ModuleSpecs/ShadowingOuter/N.md | 6 - .../ruby/ModuleSpecs/SingletonOnModuleCase.md | 6 - .../ModuleSpecs/SingletonOnModuleCase/Bar.md | 12 - .../ModuleSpecs/SingletonOnModuleCase/Foo.md | 10 - example/ruby/ModuleSpecs/SubCVars.md | 7 - example/ruby/ModuleSpecs/SubModule.md | 16 - example/ruby/ModuleSpecs/Subclass.md | 7 - example/ruby/ModuleSpecs/SubclassSpec.md | 7 - example/ruby/ModuleSpecs/Super.md | 13 - example/ruby/ModuleSpecs/Super/SuperChild.md | 7 - example/ruby/ModuleSpecs/ThreadSafeCounter.md | 16 - example/ruby/ModuleSpecs/UnboundMethodTest.md | 9 - .../ModuleSpecs/UndefinedInstanceMethods.md | 7 - .../UndefinedInstanceMethods/Child.md | 12 - .../UndefinedInstanceMethods/Grandchild.md | 7 - .../UndefinedInstanceMethods/Parent.md | 14 - .../UndefinedInstanceMethods/Super.md | 9 - .../ruby/ModuleSpecs/WithPrependedModule.md | 9 - example/ruby/ModuleSpecs/Z.md | 6 - example/ruby/Monitor.md | 58 - example/ruby/MonitorMixin.md | 113 - .../ruby/MonitorMixin/ConditionVariable.md | 31 - example/ruby/Msxml.md | 78 - example/ruby/MultiFormatter.md | 17 - example/ruby/MultiPart.md | 47 - example/ruby/MyApp.md | 14 - example/ruby/MyDict.md | 10 - example/ruby/MyElem.md | 21 - example/ruby/MyList.md | 19 - example/ruby/MyModule.md | 6 - example/ruby/MyTimeout.md | 7 - example/ruby/NameError.md | 57 - example/ruby/NameError/message.md | 24 - example/ruby/NameErrorExtensionTest.md | 22 - .../TestSpellChecker.md | 14 - example/ruby/NameErrorSpecs.md | 7 - example/ruby/NameErrorSpecs/ReceiverClass.md | 10 - example/ruby/NameMap.md | 26 - example/ruby/NameMapSpecs.md | 11 - example/ruby/NameMapSpecs/A.md | 14 - example/ruby/NameMapSpecs/A/B.md | 10 - example/ruby/NameMapSpecs/Error.md | 7 - example/ruby/NameMapSpecs/Fixnum.md | 10 - example/ruby/NamespaceTest.md | 6 - example/ruby/Net.md | 7 - example/ruby/Net/BufferedIO.md | 53 - example/ruby/Net/HTTP.md | 1638 ----- example/ruby/Net/HTTP/Copy.md | 23 - example/ruby/Net/HTTP/Delete.md | 36 - example/ruby/Net/HTTP/Get.md | 36 - example/ruby/Net/HTTP/Head.md | 35 - example/ruby/Net/HTTP/Lock.md | 23 - example/ruby/Net/HTTP/Mkcol.md | 23 - example/ruby/Net/HTTP/Move.md | 23 - example/ruby/Net/HTTP/Options.md | 35 - example/ruby/Net/HTTP/Patch.md | 38 - example/ruby/Net/HTTP/Post.md | 39 - example/ruby/Net/HTTP/Propfind.md | 23 - example/ruby/Net/HTTP/Proppatch.md | 23 - example/ruby/Net/HTTP/ProxyDelta.md | 7 - example/ruby/Net/HTTP/Put.md | 39 - example/ruby/Net/HTTP/Trace.md | 35 - example/ruby/Net/HTTP/Unlock.md | 23 - example/ruby/Net/HTTPAccepted.md | 19 - example/ruby/Net/HTTPAlreadyReported.md | 20 - example/ruby/Net/HTTPBadGateway.md | 20 - example/ruby/Net/HTTPBadRequest.md | 20 - example/ruby/Net/HTTPBadResponse.md | 8 - example/ruby/Net/HTTPClientError.md | 16 - example/ruby/Net/HTTPClientException.md | 13 - example/ruby/Net/HTTPConflict.md | 19 - example/ruby/Net/HTTPContinue.md | 19 - example/ruby/Net/HTTPCreated.md | 19 - example/ruby/Net/HTTPEarlyHints.md | 20 - example/ruby/Net/HTTPError.md | 13 - example/ruby/Net/HTTPExceptions.md | 16 - example/ruby/Net/HTTPExpectationFailed.md | 20 - example/ruby/Net/HTTPFailedDependency.md | 19 - example/ruby/Net/HTTPFatalError.md | 13 - example/ruby/Net/HTTPForbidden.md | 20 - example/ruby/Net/HTTPFound.md | 19 - example/ruby/Net/HTTPGatewayTimeout.md | 21 - example/ruby/Net/HTTPGenericRequest.md | 612 -- .../ruby/Net/HTTPGenericRequest/Chunker.md | 17 - example/ruby/Net/HTTPGone.md | 19 - example/ruby/Net/HTTPHeader.md | 703 --- example/ruby/Net/HTTPHeaderSyntaxError.md | 7 - example/ruby/Net/HTTPIMUsed.md | 19 - example/ruby/Net/HTTPInformation.md | 17 - example/ruby/Net/HTTPInsufficientStorage.md | 20 - example/ruby/Net/HTTPInternalServerError.md | 21 - example/ruby/Net/HTTPLengthRequired.md | 21 - example/ruby/Net/HTTPLocked.md | 17 - example/ruby/Net/HTTPLoopDetected.md | 18 - example/ruby/Net/HTTPMethodNotAllowed.md | 20 - example/ruby/Net/HTTPMisdirectedRequest.md | 19 - example/ruby/Net/HTTPMovedPermanently.md | 21 - example/ruby/Net/HTTPMultiStatus.md | 19 - example/ruby/Net/HTTPMultipleChoices.md | 21 - .../Net/HTTPNetworkAuthenticationRequired.md | 19 - example/ruby/Net/HTTPNoContent.md | 20 - .../Net/HTTPNonAuthoritativeInformation.md | 23 - example/ruby/Net/HTTPNotAcceptable.md | 21 - example/ruby/Net/HTTPNotExtended.md | 18 - example/ruby/Net/HTTPNotFound.md | 19 - example/ruby/Net/HTTPNotImplemented.md | 21 - example/ruby/Net/HTTPNotModified.md | 20 - example/ruby/Net/HTTPOK.md | 19 - example/ruby/Net/HTTPPartialContent.md | 21 - example/ruby/Net/HTTPPayloadTooLarge.md | 20 - example/ruby/Net/HTTPPaymentRequired.md | 20 - example/ruby/Net/HTTPPermanentRedirect.md | 20 - example/ruby/Net/HTTPPreconditionFailed.md | 21 - example/ruby/Net/HTTPPreconditionRequired.md | 18 - example/ruby/Net/HTTPProcessing.md | 18 - .../Net/HTTPProxyAuthenticationRequired.md | 21 - example/ruby/Net/HTTPRangeNotSatisfiable.md | 21 - example/ruby/Net/HTTPRedirection.md | 17 - example/ruby/Net/HTTPRequest.md | 95 - .../Net/HTTPRequestHeaderFieldsTooLarge.md | 20 - example/ruby/Net/HTTPRequestTimeout.md | 20 - example/ruby/Net/HTTPResetContent.md | 21 - example/ruby/Net/HTTPResponse.md | 771 --- example/ruby/Net/HTTPResponse/Inflater.md | 42 - example/ruby/Net/HTTPRetriableError.md | 13 - example/ruby/Net/HTTPSeeOther.md | 20 - example/ruby/Net/HTTPServerError.md | 16 - example/ruby/Net/HTTPServiceUnavailable.md | 21 - example/ruby/Net/HTTPSuccess.md | 17 - example/ruby/Net/HTTPSwitchProtocol.md | 21 - example/ruby/Net/HTTPTemporaryRedirect.md | 21 - example/ruby/Net/HTTPTooManyRequests.md | 18 - example/ruby/Net/HTTPURITooLong.md | 19 - example/ruby/Net/HTTPUnauthorized.md | 19 - .../Net/HTTPUnavailableForLegalReasons.md | 20 - example/ruby/Net/HTTPUnknownResponse.md | 7 - example/ruby/Net/HTTPUnprocessableEntity.md | 20 - example/ruby/Net/HTTPUnsupportedMediaType.md | 21 - example/ruby/Net/HTTPUpgradeRequired.md | 20 - example/ruby/Net/HTTPUseProxy.md | 19 - example/ruby/Net/HTTPVariantAlsoNegotiates.md | 19 - example/ruby/Net/HTTPVersionNotSupported.md | 20 - example/ruby/Net/InternetMessageIO.md | 26 - example/ruby/Net/NetPrivate.md | 7 - example/ruby/Net/OpenTimeout.md | 9 - example/ruby/Net/ProtoAuthError.md | 7 - example/ruby/Net/ProtoCommandError.md | 7 - example/ruby/Net/ProtoFatalError.md | 7 - example/ruby/Net/ProtoRetriableError.md | 7 - example/ruby/Net/ProtoServerError.md | 7 - example/ruby/Net/ProtoSyntaxError.md | 7 - example/ruby/Net/ProtoUnknownError.md | 7 - example/ruby/Net/Protocol.md | 8 - example/ruby/Net/ProtocolError.md | 7 - example/ruby/Net/ReadAdapter.md | 17 - example/ruby/Net/ReadTimeout.md | 20 - example/ruby/Net/TestBufferedIO.md | 12 - example/ruby/Net/WriteAdapter.md | 23 - example/ruby/Net/WriteTimeout.md | 20 - example/ruby/NetFTPSpecs.md | 6 - example/ruby/NetFTPSpecs/DummyFTP.md | 104 - example/ruby/NetHTTPExceptionsSpecs.md | 6 - example/ruby/NetHTTPExceptionsSpecs/Simple.md | 13 - example/ruby/NetHTTPHeaderSpecs.md | 6 - example/ruby/NetHTTPHeaderSpecs/Example.md | 530 -- example/ruby/NetHTTPRequestSpecs.md | 6 - .../ruby/NetHTTPRequestSpecs/TestRequest.md | 7 - example/ruby/NetHTTPSpecs.md | 10 - example/ruby/NetHTTPSpecs/NullWriter.md | 16 - example/ruby/NetHTTPSpecs/SmallHTTPServer.md | 28 - example/ruby/NextSpecs.md | 21 - example/ruby/NextSpecs/Block.md | 12 - example/ruby/NilClass.md | 142 - example/ruby/NoMatchingPatternError.md | 7 - example/ruby/NoMatchingPatternKeyError.md | 24 - example/ruby/NoMemoryError.md | 8 - example/ruby/NoMethodError.md | 38 - example/ruby/NoMethodErrorSpecs.md | 6 - .../NoMethodErrorSpecs/InstanceException.md | 7 - .../ruby/NoMethodErrorSpecs/NoMethodErrorA.md | 7 - .../ruby/NoMethodErrorSpecs/NoMethodErrorB.md | 7 - .../ruby/NoMethodErrorSpecs/NoMethodErrorC.md | 7 - .../ruby/NoMethodErrorSpecs/NoMethodErrorD.md | 7 - example/ruby/Node.md | 53 - example/ruby/NotImplementedError.md | 14 - example/ruby/Notify.md | 18 - example/ruby/NthToggle.md | 14 - example/ruby/Num2int.md | 20 - example/ruby/Numeric.md | 801 --- example/ruby/NumericMockObject.md | 16 - example/ruby/NumericSpecs.md | 6 - example/ruby/NumericSpecs/Comparison.md | 12 - example/ruby/NumericSpecs/Subclass.md | 11 - example/ruby/OLEtagDOMNodeType.md | 13 - example/ruby/OLEtagXMLEMEM_TYPE.md | 13 - example/ruby/Object.md | 2785 --------- example/ruby/Object/CApiModuleSpecsModuleA.md | 6 - example/ruby/Object/ConstantSpecs.md | 6 - .../ruby/Object/ConstantSpecs/ContainerA.md | 7 - .../Object/ConstantSpecs/ContainerA/ChildA.md | 9 - .../ruby/Object/ConstantSpecs/ContainerB.md | 7 - .../Object/ConstantSpecs/ContainerB/ChildB.md | 9 - example/ruby/ObjectSpace.md | 542 -- .../ruby/ObjectSpace/InternalObjectWrapper.md | 17 - example/ruby/ObjectSpace/WeakKeyMap.md | 147 - example/ruby/ObjectSpace/WeakMap.md | 2180 ------- example/ruby/ObjectSpaceFixtures.md | 15 - .../ObjectSpaceFixtures/ObjectToBeFound.md | 16 - .../ObjectWithInstanceVariable.md | 12 - example/ruby/ObjectSpecDup.md | 16 - example/ruby/ObjectSpecDupInitCopy.md | 19 - example/ruby/ObjectWithInstanceVariables.md | 14 - example/ruby/ObservableSpecs.md | 9 - example/ruby/ObserverCallbackSpecs.md | 18 - example/ruby/Olympians.md | 9 - example/ruby/Open3.md | 1036 --- example/ruby/OpenSSL.md | 40 - example/ruby/OpenSSL/ASN1.md | 165 - example/ruby/OpenSSL/ASN1/ASN1Data.md | 140 - example/ruby/OpenSSL/ASN1/ASN1Error.md | 9 - example/ruby/OpenSSL/ASN1/BitString.md | 16 - example/ruby/OpenSSL/ASN1/Boolean.md | 7 - example/ruby/OpenSSL/ASN1/Constructive.md | 2130 ------- example/ruby/OpenSSL/ASN1/EndOfContent.md | 12 - example/ruby/OpenSSL/ASN1/Enumerated.md | 7 - example/ruby/OpenSSL/ASN1/Integer.md | 7 - example/ruby/OpenSSL/ASN1/ObjectId.md | 43 - example/ruby/OpenSSL/ASN1/Primitive.md | 97 - example/ruby/OpenSSL/ASN1/TaggedASN1Data.md | 36 - example/ruby/OpenSSL/BN.md | 363 -- example/ruby/OpenSSL/BNError.md | 8 - example/ruby/OpenSSL/Buffering.md | 2261 ------- example/ruby/OpenSSL/Buffering/Buffer.md | 15 - example/ruby/OpenSSL/Certs.md | 13 - example/ruby/OpenSSL/Cipher.md | 433 -- example/ruby/OpenSSL/Cipher/Cipher.md | 10 - example/ruby/OpenSSL/Cipher/CipherError.md | 7 - example/ruby/OpenSSL/Config.md | 2149 ------- example/ruby/OpenSSL/ConfigError.md | 9 - example/ruby/OpenSSL/Digest.md | 86 - example/ruby/OpenSSL/Digest/Digest.md | 11 - example/ruby/OpenSSL/Digest/DigestError.md | 9 - example/ruby/OpenSSL/Engine.md | 146 - example/ruby/OpenSSL/Engine/EngineError.md | 8 - example/ruby/OpenSSL/HMAC.md | 160 - example/ruby/OpenSSL/HMACError.md | 7 - example/ruby/OpenSSL/KDF.md | 155 - example/ruby/OpenSSL/KDF/KDFError.md | 7 - example/ruby/OpenSSL/Marshal.md | 13 - example/ruby/OpenSSL/Marshal/ClassMethods.md | 9 - example/ruby/OpenSSL/Netscape.md | 10 - example/ruby/OpenSSL/Netscape/SPKI.md | 113 - example/ruby/OpenSSL/Netscape/SPKIError.md | 9 - example/ruby/OpenSSL/OCSP.md | 6 - example/ruby/OpenSSL/OCSP/BasicResponse.md | 104 - example/ruby/OpenSSL/OCSP/CertificateId.md | 66 - example/ruby/OpenSSL/OCSP/OCSPError.md | 7 - example/ruby/OpenSSL/OCSP/Request.md | 99 - example/ruby/OpenSSL/OCSP/Response.md | 43 - example/ruby/OpenSSL/OCSP/SingleResponse.md | 73 - example/ruby/OpenSSL/OSSL.md | 16 - example/ruby/OpenSSL/OpenSSLError.md | 7 - example/ruby/OpenSSL/PKCS12.md | 58 - example/ruby/OpenSSL/PKCS12/PKCS12Error.md | 7 - example/ruby/OpenSSL/PKCS5.md | 11 - example/ruby/OpenSSL/PKCS7.md | 85 - example/ruby/OpenSSL/PKCS7/PKCS7Error.md | 7 - example/ruby/OpenSSL/PKCS7/RecipientInfo.md | 16 - example/ruby/OpenSSL/PKCS7/SignerInfo.md | 16 - example/ruby/OpenSSL/PKey.md | 50 - example/ruby/OpenSSL/PKey/DH.md | 247 - example/ruby/OpenSSL/PKey/DHError.md | 10 - example/ruby/OpenSSL/PKey/DSA.md | 230 - example/ruby/OpenSSL/PKey/DSAError.md | 10 - example/ruby/OpenSSL/PKey/EC.md | 210 - example/ruby/OpenSSL/PKey/EC/Group.md | 148 - example/ruby/OpenSSL/PKey/EC/Group/Error.md | 7 - example/ruby/OpenSSL/PKey/EC/Point.md | 99 - example/ruby/OpenSSL/PKey/EC/Point/Error.md | 7 - example/ruby/OpenSSL/PKey/ECError.md | 7 - example/ruby/OpenSSL/PKey/PKey.md | 12 - example/ruby/OpenSSL/PKey/PKeyError.md | 8 - example/ruby/OpenSSL/PKey/RSA.md | 297 - example/ruby/OpenSSL/PKey/RSAError.md | 10 - example/ruby/OpenSSL/PKeyTestCase.md | 10 - example/ruby/OpenSSL/Provider.md | 40 - .../ruby/OpenSSL/Provider/ProviderError.md | 8 - example/ruby/OpenSSL/Random.md | 67 - example/ruby/OpenSSL/Random/RandomError.md | 7 - example/ruby/OpenSSL/SSL.md | 16 - example/ruby/OpenSSL/SSL/SSLContext.md | 344 - example/ruby/OpenSSL/SSL/SSLError.md | 8 - .../ruby/OpenSSL/SSL/SSLErrorWaitReadable.md | 9 - .../ruby/OpenSSL/SSL/SSLErrorWaitWritable.md | 9 - example/ruby/OpenSSL/SSL/SSLServer.md | 76 - example/ruby/OpenSSL/SSL/SSLSocket.md | 2543 -------- example/ruby/OpenSSL/SSL/Session.md | 66 - .../ruby/OpenSSL/SSL/Session/SessionError.md | 7 - example/ruby/OpenSSL/SSL/SocketForwarder.md | 46 - example/ruby/OpenSSL/SSLPair.md | 17 - example/ruby/OpenSSL/SSLPairLowlevelSocket.md | 17 - example/ruby/OpenSSL/SSLPairM.md | 11 - example/ruby/OpenSSL/SSLTestCase.md | 18 - example/ruby/OpenSSL/TestASN1.md | 64 - example/ruby/OpenSSL/TestBN.md | 68 - example/ruby/OpenSSL/TestBuffering.md | 24 - example/ruby/OpenSSL/TestBuffering/IO.md | 2265 ------- example/ruby/OpenSSL/TestCase.md | 194 - example/ruby/OpenSSL/TestCipher.md | 64 - example/ruby/OpenSSL/TestCipher/Helper.md | 11 - example/ruby/OpenSSL/TestConfig.md | 48 - example/ruby/OpenSSL/TestDigest.md | 38 - example/ruby/OpenSSL/TestEC.md | 46 - example/ruby/OpenSSL/TestEOF.md | 21 - example/ruby/OpenSSL/TestEOF/Seek.md | 13 - example/ruby/OpenSSL/TestEOF1.md | 34 - .../ruby/OpenSSL/TestEOF1LowlevelSocket.md | 34 - example/ruby/OpenSSL/TestEOF1M.md | 9 - example/ruby/OpenSSL/TestEOF2.md | 34 - .../ruby/OpenSSL/TestEOF2LowlevelSocket.md | 34 - example/ruby/OpenSSL/TestEOF2M.md | 9 - example/ruby/OpenSSL/TestEngine.md | 22 - example/ruby/OpenSSL/TestFIPS.md | 16 - example/ruby/OpenSSL/TestHMAC.md | 22 - example/ruby/OpenSSL/TestKDF.md | 45 - example/ruby/OpenSSL/TestNSSPI.md | 14 - example/ruby/OpenSSL/TestOCSP.md | 50 - example/ruby/OpenSSL/TestPKCS12.md | 34 - example/ruby/OpenSSL/TestPKCS7.md | 42 - example/ruby/OpenSSL/TestPKey.md | 30 - example/ruby/OpenSSL/TestPKeyDH.md | 32 - example/ruby/OpenSSL/TestPKeyDSA.md | 34 - example/ruby/OpenSSL/TestPKeyRSA.md | 60 - example/ruby/OpenSSL/TestPair.md | 70 - .../ruby/OpenSSL/TestPairLowlevelSocket.md | 70 - example/ruby/OpenSSL/TestPairM.md | 59 - example/ruby/OpenSSL/TestProvider.md | 16 - example/ruby/OpenSSL/TestRandom.md | 12 - example/ruby/OpenSSL/TestSSL.md | 183 - example/ruby/OpenSSL/TestSSLSession.md | 30 - example/ruby/OpenSSL/TestTimestamp.md | 100 - example/ruby/OpenSSL/TestUtils.md | 17 - example/ruby/OpenSSL/TestUtils/Fixtures.md | 10 - example/ruby/OpenSSL/TestX509Attribute.md | 22 - example/ruby/OpenSSL/TestX509CRL.md | 28 - example/ruby/OpenSSL/TestX509Certificate.md | 70 - example/ruby/OpenSSL/TestX509Extension.md | 26 - example/ruby/OpenSSL/TestX509Name.md | 44 - example/ruby/OpenSSL/TestX509Request.md | 40 - example/ruby/OpenSSL/TestX509Store.md | 28 - example/ruby/OpenSSL/Timestamp.md | 46 - example/ruby/OpenSSL/Timestamp/Factory.md | 125 - example/ruby/OpenSSL/Timestamp/Request.md | 122 - example/ruby/OpenSSL/Timestamp/Response.md | 111 - .../ruby/OpenSSL/Timestamp/TimestampError.md | 8 - example/ruby/OpenSSL/Timestamp/TokenInfo.md | 110 - example/ruby/OpenSSL/X509.md | 6 - example/ruby/OpenSSL/X509/Attribute.md | 40 - example/ruby/OpenSSL/X509/AttributeError.md | 7 - example/ruby/OpenSSL/X509/CRL.md | 69 - example/ruby/OpenSSL/X509/CRLError.md | 7 - example/ruby/OpenSSL/X509/Certificate.md | 269 - example/ruby/OpenSSL/X509/CertificateError.md | 7 - example/ruby/OpenSSL/X509/Extension.md | 55 - .../X509/Extension/AuthorityInfoAccess.md | 24 - .../X509/Extension/AuthorityKeyIdentifier.md | 17 - .../X509/Extension/CRLDistributionPoints.md | 17 - .../ruby/OpenSSL/X509/Extension/Helpers.md | 9 - .../X509/Extension/SubjectKeyIdentifier.md | 17 - example/ruby/OpenSSL/X509/ExtensionError.md | 7 - example/ruby/OpenSSL/X509/ExtensionFactory.md | 36 - example/ruby/OpenSSL/X509/Name.md | 248 - example/ruby/OpenSSL/X509/Name/RFC2253DN.md | 11 - example/ruby/OpenSSL/X509/NameError.md | 7 - example/ruby/OpenSSL/X509/Request.md | 50 - example/ruby/OpenSSL/X509/RequestError.md | 7 - example/ruby/OpenSSL/X509/Revoked.md | 32 - example/ruby/OpenSSL/X509/RevokedError.md | 7 - example/ruby/OpenSSL/X509/Store.md | 161 - example/ruby/OpenSSL/X509/StoreContext.md | 108 - example/ruby/OpenSSL/X509/StoreError.md | 7 - example/ruby/OpenStruct.md | 263 - example/ruby/OpenStructSpecs.md | 6 - example/ruby/OpenStructSpecs/OpenStructSub.md | 7 - example/ruby/OpenURI.md | 79 - example/ruby/OpenURI/Buffer.md | 21 - example/ruby/OpenURI/HTTPError.md | 16 - example/ruby/OpenURI/HTTPRedirect.md | 17 - example/ruby/OpenURI/Meta.md | 62 - example/ruby/OpenURI/OpenRead.md | 236 - example/ruby/OpenURI/TooManyRedirects.md | 7 - example/ruby/OperatorImplementor.md | 12 - example/ruby/OptionParser.md | 748 --- example/ruby/OptionParser/AC.md | 24 - example/ruby/OptionParser/Acceptables.md | 8 - .../ruby/OptionParser/AmbiguousArgument.md | 8 - example/ruby/OptionParser/AmbiguousOption.md | 8 - example/ruby/OptionParser/Arguable.md | 49 - example/ruby/OptionParser/CompletingHash.md | 20 - example/ruby/OptionParser/Completion.md | 19 - example/ruby/OptionParser/InvalidArgument.md | 8 - example/ruby/OptionParser/InvalidOption.md | 8 - example/ruby/OptionParser/List.md | 103 - example/ruby/OptionParser/MissingArgument.md | 8 - example/ruby/OptionParser/NeedlessArgument.md | 8 - example/ruby/OptionParser/OptionMap.md | 17 - example/ruby/OptionParser/ParseError.md | 38 - example/ruby/OptionParser/Switch.md | 90 - .../ruby/OptionParser/Switch/NoArgument.md | 22 - .../OptionParser/Switch/OptionalArgument.md | 15 - .../OptionParser/Switch/PlacedArgument.md | 15 - .../OptionParser/Switch/RequiredArgument.md | 15 - example/ruby/OtherCustomException.md | 7 - example/ruby/Output.md | 23 - example/ruby/OutputMatcher.md | 20 - example/ruby/OutputToFDMatcher.md | 26 - example/ruby/PP.md | 160 - example/ruby/PP/ObjectMixin.md | 37 - example/ruby/PP/PPMethods.md | 79 - example/ruby/PP/SingleLine.md | 82 - example/ruby/PPTestModule.md | 6 - example/ruby/PPTestModule/HasBoth.md | 16 - example/ruby/PPTestModule/HasInspect.md | 14 - example/ruby/PPTestModule/HasPrettyPrint.md | 14 - .../ruby/PPTestModule/PPAbstractSyntaxTree.md | 10 - example/ruby/PPTestModule/PPCycleTest.md | 28 - example/ruby/PPTestModule/PPCycleTest/S.md | 18 - example/ruby/PPTestModule/PPDelegateTest.md | 12 - example/ruby/PPTestModule/PPDelegateTest/A.md | 7 - example/ruby/PPTestModule/PPFileStatTest.md | 10 - example/ruby/PPTestModule/PPInheritedTest.md | 10 - .../PPInheritedTest/PPSymbolHash.md | 10 - example/ruby/PPTestModule/PPInspectTest.md | 24 - example/ruby/PPTestModule/PPSingleLineTest.md | 14 - example/ruby/PPTestModule/PPTest.md | 20 - .../PPTestModule/PPTest/OverriddenStruct.md | 18 - .../ruby/PPTestModule/PrettyPrintInspect.md | 7 - .../PrettyPrintInspectWithoutPrettyPrint.md | 7 - example/ruby/PStore.md | 454 -- example/ruby/PStore/Error.md | 8 - example/ruby/PStoreTest.md | 42 - example/ruby/PTY.md | 125 - example/ruby/PTY/ChildExited.md | 13 - example/ruby/ParallelRunner.md | 22 - example/ruby/ParamList.md | 28 - example/ruby/Parent.md | 7 - example/ruby/ParserSupport.md | 20 - example/ruby/Path.md | 15 - example/ruby/Path/HardlinkExcutable.md | 9 - example/ruby/Path/Mswin.md | 12 - example/ruby/Pathname.md | 805 --- example/ruby/PatternKeyNameCheckTest.md | 14 - example/ruby/PiDigitSpigot.md | 25 - example/ruby/Piece.md | 40 - example/ruby/Plane.md | 14 - example/ruby/Planet.md | 36 - example/ruby/PlatformGuard.md | 44 - example/ruby/Point.md | 17 - example/ruby/PrecedenceSpecs.md | 6 - .../ruby/PrecedenceSpecs/NonUnaryOpTest.md | 16 - example/ruby/PrettyPrint.md | 193 - example/ruby/PrettyPrint/Breakable.md | 41 - example/ruby/PrettyPrint/Group.md | 46 - example/ruby/PrettyPrint/GroupQueue.md | 34 - example/ruby/PrettyPrint/SingleLine.md | 66 - example/ruby/PrettyPrint/Text.md | 38 - example/ruby/PrettyPrintTest.md | 6 - example/ruby/PrettyPrintTest/Fill.md | 25 - example/ruby/PrettyPrintTest/NonString.md | 15 - .../PrettyPrintTest/StrictPrettyExample.md | 29 - example/ruby/PrettyPrintTest/TailGroup.md | 11 - example/ruby/PrettyPrintTest/WadlerExample.md | 43 - .../PrettyPrintTest/WadlerExample/Tree.md | 17 - example/ruby/Prism.md | 177 - example/ruby/Prism/ASCIISource.md | 40 - example/ruby/Prism/AttributeWriteTest.md | 18 - .../ruby/Prism/AttributeWriteTest/Target.md | 10 - example/ruby/Prism/BOMTest.md | 24 - example/ruby/Prism/BeginNode.md | 11 - example/ruby/Prism/BreadthFirstSearchTest.md | 10 - example/ruby/Prism/CallNode.md | 19 - example/ruby/Prism/CallOperatorWriteNode.md | 16 - example/ruby/Prism/CaseMatchNode.md | 12 - example/ruby/Prism/CaseNode.md | 12 - .../ruby/Prism/ClassVariableAndWriteNode.md | 11 - .../Prism/ClassVariableOperatorWriteNode.md | 19 - .../ruby/Prism/ClassVariableOrWriteNode.md | 11 - example/ruby/Prism/CodeUnitsCache.md | 29 - example/ruby/Prism/CommandLineTest.md | 26 - example/ruby/Prism/Comment.md | 25 - example/ruby/Prism/CommentsTest.md | 22 - example/ruby/Prism/CompilerTest.md | 10 - .../ruby/Prism/CompilerTest/SExpressions.md | 16 - example/ruby/Prism/ConstantAndWriteNode.md | 11 - .../ruby/Prism/ConstantOperatorWriteNode.md | 19 - example/ruby/Prism/ConstantOrWriteNode.md | 11 - example/ruby/Prism/ConstantPathNode.md | 20 - .../DynamicPartsInConstantPathError.md | 11 - .../MissingNodesInConstantPathError.md | 12 - example/ruby/Prism/ConstantPathNodeTest.md | 22 - .../Prism/ConstantPathOperatorWriteNode.md | 16 - example/ruby/Prism/ConstantPathTargetNode.md | 20 - example/ruby/Prism/ConstantReadNode.md | 15 - example/ruby/Prism/ConstantTargetNode.md | 15 - example/ruby/Prism/ConstantWriteNode.md | 15 - example/ruby/Prism/DesugarCompiler.md | 103 - example/ruby/Prism/DesugarCompilerTest.md | 14 - example/ruby/Prism/DispatcherTest.md | 10 - .../ruby/Prism/DispatcherTest/TestListener.md | 22 - example/ruby/Prism/DumpTest.md | 12 - example/ruby/Prism/EmbDocComment.md | 18 - example/ruby/Prism/EncodingsTest.md | 7 - .../Prism/EncodingsTest/ConstantContext.md | 9 - .../Prism/EncodingsTest/IdentifierContext.md | 10 - example/ruby/Prism/EqualityTest.md | 10 - example/ruby/Prism/ErrorsTest.md | 22 - example/ruby/Prism/FixturesTest.md | 7 - example/ruby/Prism/FuzzerTest.md | 11 - .../ruby/Prism/GlobalVariableAndWriteNode.md | 11 - .../Prism/GlobalVariableOperatorWriteNode.md | 19 - .../ruby/Prism/GlobalVariableOrWriteNode.md | 11 - example/ruby/Prism/HeredocDedentTest.md | 40 - example/ruby/Prism/HeredocTest.md | 12 - example/ruby/Prism/IfNode.md | 15 - example/ruby/Prism/ImaginaryNode.md | 11 - example/ruby/Prism/ImplicitArrayTest.md | 24 - example/ruby/Prism/IndexOperatorWriteNode.md | 16 - example/ruby/Prism/IndexWriteTest.md | 16 - example/ruby/Prism/InlineComment.md | 19 - .../Prism/InstanceVariableAndWriteNode.md | 11 - .../InstanceVariableOperatorWriteNode.md | 19 - .../ruby/Prism/InstanceVariableOrWriteNode.md | 11 - example/ruby/Prism/IntegerBaseFlagsTest.md | 21 - example/ruby/Prism/IntegerParseTest.md | 10 - .../Prism/InterpolatedMatchLastLineNode.md | 11 - .../InterpolatedRegularExpressionNode.md | 11 - example/ruby/Prism/InterpolatedStringNode.md | 11 - example/ruby/Prism/InterpolatedSymbolNode.md | 11 - example/ruby/Prism/InterpolatedXStringNode.md | 11 - .../ruby/Prism/LexCompat/EndContentToken.md | 13 - .../Prism/LexCompat/Heredoc/DashHeredoc.md | 26 - .../LexCompat/Heredoc/DedentingHeredoc.md | 42 - .../Prism/LexCompat/Heredoc/PlainHeredoc.md | 24 - example/ruby/Prism/LexCompat/IdentToken.md | 15 - .../ruby/Prism/LexCompat/IgnoreStateToken.md | 13 - .../Prism/LexCompat/IgnoredNewlineToken.md | 13 - example/ruby/Prism/LexCompat/ParamToken.md | 18 - example/ruby/Prism/LexCompat/Result.md | 21 - example/ruby/Prism/LexCompat/Token.md | 23 - example/ruby/Prism/LexResult.md | 21 - example/ruby/Prism/LexTest.md | 18 - .../ruby/Prism/LibRubyParser/PrismBuffer.md | 28 - .../ruby/Prism/LibRubyParser/PrismString.md | 32 - example/ruby/Prism/LibrarySymbolsTest.md | 43 - .../ruby/Prism/LocalVariableAndWriteNode.md | 11 - .../Prism/LocalVariableOperatorWriteNode.md | 19 - .../ruby/Prism/LocalVariableOrWriteNode.md | 11 - example/ruby/Prism/LocalsTest.md | 12 - example/ruby/Prism/LocalsTest/ISeq.md | 26 - example/ruby/Prism/Location.md | 145 - example/ruby/Prism/LocationTest.md | 26 - example/ruby/Prism/MagicComment.md | 33 - example/ruby/Prism/MagicCommentTest.md | 34 - .../MagicCommentTest/MagicCommentRipper.md | 18 - example/ruby/Prism/MatchLastLineNode.md | 7 - example/ruby/Prism/NewlineOffsetsTest.md | 7 - example/ruby/Prism/NewlineTest.md | 7 - example/ruby/Prism/Node.md | 19 - example/ruby/Prism/NodeIdTest.md | 7 - example/ruby/Prism/NumericValueTest.md | 10 - example/ruby/Prism/OnigmoTest.md | 24 - example/ruby/Prism/OverlapTest.md | 7 - example/ruby/Prism/Pack.md | 12 - example/ruby/Prism/Pack/Directive.md | 45 - example/ruby/Prism/Pack/Format.md | 24 - example/ruby/Prism/ParametersNode.md | 11 - example/ruby/Prism/ParametersSignatureTest.md | 40 - example/ruby/Prism/ParenthesesNode.md | 11 - example/ruby/Prism/ParseCommentsTest.md | 14 - example/ruby/Prism/ParseError.md | 34 - example/ruby/Prism/ParseLexResult.md | 22 - example/ruby/Prism/ParseResult.md | 35 - .../ParseResult/Comments/LocationTarget.md | 30 - .../Prism/ParseResult/Comments/NodeTarget.md | 29 - example/ruby/Prism/ParseStreamTest.md | 26 - example/ruby/Prism/ParseSuccessTest.md | 16 - example/ruby/Prism/ParseTest.md | 30 - example/ruby/Prism/ParseWarning.md | 34 - example/ruby/Prism/ParserTest.md | 7 - example/ruby/Prism/Pattern.md | 62 - .../ruby/Prism/Pattern/CompilationError.md | 16 - example/ruby/Prism/PatternTest.md | 52 - .../ruby/Prism/PercentDelimiterRegexpTest.md | 34 - .../ruby/Prism/PercentDelimiterStringTest.md | 34 - example/ruby/Prism/PercentDelimiterTests.md | 27 - example/ruby/Prism/RationalNode.md | 15 - example/ruby/Prism/ReflectionTest.md | 10 - example/ruby/Prism/RegexpTest.md | 117 - .../Prism/RegularExpressionEncodingTest.md | 7 - example/ruby/Prism/RegularExpressionNode.md | 7 - .../Prism/RegularExpressionOptionsTest.md | 10 - example/ruby/Prism/Relocation.md | 20 - .../Prism/Relocation/CharacterColumnsField.md | 12 - .../Prism/Relocation/CharacterOffsetsField.md | 12 - .../Prism/Relocation/CodeUnitColumnsField.md | 26 - .../Prism/Relocation/CodeUnitOffsetsField.md | 26 - example/ruby/Prism/Relocation/ColumnsField.md | 12 - .../ruby/Prism/Relocation/CommentsField.md | 8 - .../Prism/Relocation/CommentsField/Comment.md | 18 - example/ruby/Prism/Relocation/Entry.md | 77 - .../Relocation/Entry/MissingValueError.md | 9 - .../ruby/Prism/Relocation/FilepathField.md | 21 - .../Prism/Relocation/LeadingCommentsField.md | 12 - example/ruby/Prism/Relocation/LinesField.md | 12 - example/ruby/Prism/Relocation/OffsetsField.md | 12 - example/ruby/Prism/Relocation/Repository.md | 77 - .../Repository/ConfigurationError.md | 9 - example/ruby/Prism/Relocation/Source.md | 26 - .../ruby/Prism/Relocation/SourceFilepath.md | 12 - example/ruby/Prism/Relocation/SourceString.md | 12 - .../Prism/Relocation/TrailingCommentsField.md | 12 - example/ruby/Prism/RelocationTest.md | 36 - example/ruby/Prism/RescueModifierNode.md | 11 - example/ruby/Prism/RescueNode.md | 12 - example/ruby/Prism/Result.md | 56 - example/ruby/Prism/RipperTest.md | 7 - example/ruby/Prism/RubyParserTest.md | 7 - example/ruby/Prism/SnippetsTest.md | 7 - example/ruby/Prism/Source.md | 86 - example/ruby/Prism/SourceLocationTest.md | 308 - example/ruby/Prism/StaticInspectTest.md | 34 - example/ruby/Prism/StaticLiteralsTest.md | 10 - .../Prism/StaticLiteralsTest/NullWarning.md | 10 - example/ruby/Prism/StringEncodingTest.md | 32 - example/ruby/Prism/StringNode.md | 12 - example/ruby/Prism/StringQuery.md | 51 - example/ruby/Prism/StringQueryTest.md | 22 - example/ruby/Prism/SymbolEncodingTest.md | 7 - example/ruby/Prism/Template.md | 10 - example/ruby/Prism/Template/ConfigComment.md | 21 - example/ruby/Prism/Template/ConstantField.md | 16 - .../ruby/Prism/Template/ConstantListField.md | 16 - example/ruby/Prism/Template/DoubleField.md | 16 - example/ruby/Prism/Template/Error.md | 16 - example/ruby/Prism/Template/Field.md | 36 - example/ruby/Prism/Template/Flags.md | 28 - example/ruby/Prism/Template/Flags/Flag.md | 23 - example/ruby/Prism/Template/IntegerField.md | 16 - example/ruby/Prism/Template/JavaDoc.md | 9 - example/ruby/Prism/Template/LocationField.md | 19 - example/ruby/Prism/Template/NodeField.md | 16 - example/ruby/Prism/Template/NodeKindField.md | 26 - example/ruby/Prism/Template/NodeListField.md | 18 - example/ruby/Prism/Template/NodeType.md | 49 - .../Prism/Template/OptionalConstantField.md | 16 - .../Prism/Template/OptionalLocationField.md | 19 - .../ruby/Prism/Template/OptionalNodeField.md | 16 - example/ruby/Prism/Template/StringField.md | 15 - example/ruby/Prism/Template/Token.md | 23 - example/ruby/Prism/Template/UInt32Field.md | 15 - example/ruby/Prism/Template/UInt8Field.md | 15 - example/ruby/Prism/Template/Warning.md | 16 - example/ruby/Prism/TestCase.md | 13 - example/ruby/Prism/TestCase/Fixture.md | 31 - example/ruby/Prism/TestCompilePrism.md | 384 -- .../ruby/Prism/TestCompilePrism/Subclass.md | 8 - example/ruby/Prism/Token.md | 36 - example/ruby/Prism/Translation.md | 8 - example/ruby/Prism/Translation/Parser.md | 35 - .../ruby/Prism/Translation/Parser/Compiler.md | 579 -- .../Parser/Compiler/CompilationError.md | 8 - .../Translation/Parser/PrismDiagnostic.md | 20 - example/ruby/Prism/Translation/Parser33.md | 12 - example/ruby/Prism/Translation/Parser34.md | 12 - example/ruby/Prism/Translation/Parser35.md | 12 - example/ruby/Prism/Translation/Ripper.md | 675 -- .../Prism/Translation/Ripper/SexpBuilder.md | 13 - .../Prism/Translation/Ripper/SexpBuilderPP.md | 10 - example/ruby/Prism/Translation/RubyParser.md | 25 - example/ruby/Prism/TunnelTest.md | 10 - example/ruby/Prism/UnescapeTest.md | 76 - example/ruby/Prism/UnescapeTest/Context.md | 6 - .../ruby/Prism/UnescapeTest/Context/Base.md | 21 - .../Prism/UnescapeTest/Context/Heredoc.md | 12 - .../ruby/Prism/UnescapeTest/Context/List.md | 12 - .../ruby/Prism/UnescapeTest/Context/RegExp.md | 12 - .../ruby/Prism/UnescapeTest/Context/String.md | 12 - .../ruby/Prism/UnescapeTest/Context/Symbol.md | 12 - example/ruby/Prism/UnlessNode.md | 15 - example/ruby/Prism/UntilNode.md | 11 - example/ruby/Prism/VersionTest.md | 10 - example/ruby/Prism/WarningsTest.md | 62 - example/ruby/Prism/WhileNode.md | 11 - example/ruby/Prism/XStringNode.md | 12 - example/ruby/Private.md | 6 - example/ruby/Private/A.md | 10 - example/ruby/Private/B.md | 12 - example/ruby/Private/B/C.md | 10 - example/ruby/Private/D.md | 6 - example/ruby/Private/E.md | 9 - example/ruby/Private/G.md | 10 - example/ruby/Private/H.md | 7 - example/ruby/Proc.md | 847 --- example/ruby/ProcArefFrozenSpecs.md | 9 - example/ruby/ProcArefSpecs.md | 9 - example/ruby/ProcSpecs.md | 11 - example/ruby/ProcSpecs/Arity.md | 10 - example/ruby/ProcSpecs/MyProc.md | 7 - example/ruby/ProcSpecs/MyProc2.md | 19 - example/ruby/ProcSpecs/ProcSubclass.md | 7 - example/ruby/ProcSpecs/SourceLocation.md | 18 - example/ruby/ProcSpecs/ToAryAsNil.md | 10 - example/ruby/Process.md | 1682 ----- example/ruby/Process/GID.md | 77 - example/ruby/Process/Status.md | 145 - example/ruby/Process/Sys.md | 110 - example/ruby/Process/Tms.md | 10 - example/ruby/Process/UID.md | 75 - example/ruby/Process/Waiter.md | 10 - example/ruby/ProcessSpecs.md | 9 - example/ruby/ProcessSpecs/Daemon.md | 42 - example/ruby/ProcessSpecs/Daemonizer.md | 25 - example/ruby/ProcessSpecs/Signalizer.md | 25 - example/ruby/ProfileAction.md | 24 - example/ruby/ProfileFilter.md | 24 - example/ruby/ProfileFormatter.md | 14 - example/ruby/Progress.md | 28 - example/ruby/Progress/Rotator.md | 15 - example/ruby/Project.md | 9 - example/ruby/Psych.md | 562 -- example/ruby/Psych/AliasesNotEnabled.md | 13 - example/ruby/Psych/AnchorNotDefined.md | 13 - example/ruby/Psych/BadAlias.md | 7 - example/ruby/Psych/ClassLoader.md | 17 - example/ruby/Psych/ClassLoader/Restricted.md | 14 - example/ruby/Psych/Coder.md | 67 - example/ruby/Psych/Config.md | 22 - example/ruby/Psych/DisallowedClass.md | 12 - example/ruby/Psych/Emitter.md | 118 - example/ruby/Psych/Exception.md | 7 - example/ruby/Psych/Foo.md | 16 - example/ruby/Psych/Handler.md | 194 - example/ruby/Psych/Handler/DumperOptions.md | 23 - example/ruby/Psych/Handlers.md | 6 - example/ruby/Psych/Handlers/DocumentStream.md | 17 - example/ruby/Psych/Handlers/Recorder.md | 33 - example/ruby/Psych/Handlers/TestRecorder.md | 10 - example/ruby/Psych/JSON.md | 6 - example/ruby/Psych/JSON/RubyEvents.md | 14 - example/ruby/Psych/JSON/Stream.md | 25 - example/ruby/Psych/JSON/Stream/Emitter.md | 21 - example/ruby/Psych/JSON/TestStream.md | 34 - example/ruby/Psych/JSON/TestStream/Bar.md | 10 - example/ruby/Psych/JSON/TestStream/Foo.md | 7 - example/ruby/Psych/JSON/TreeBuilder.md | 22 - example/ruby/Psych/JSON/YAMLEvents.md | 18 - example/ruby/Psych/Nodes.md | 67 - example/ruby/Psych/Nodes/Alias.md | 25 - example/ruby/Psych/Nodes/Document.md | 58 - example/ruby/Psych/Nodes/Mapping.md | 48 - example/ruby/Psych/Nodes/Node.md | 2131 ------- example/ruby/Psych/Nodes/Scalar.md | 47 - example/ruby/Psych/Nodes/Sequence.md | 72 - example/ruby/Psych/Nodes/Stream.md | 27 - example/ruby/Psych/Nodes/TestEnumerable.md | 20 - example/ruby/Psych/Omap.md | 7 - example/ruby/Psych/Parser.md | 62 - example/ruby/Psych/Parser/Mark.md | 23 - example/ruby/Psych/ScalarScanner.md | 27 - example/ruby/Psych/Set.md | 7 - example/ruby/Psych/Stream.md | 38 - example/ruby/Psych/Stream/Emitter.md | 15 - example/ruby/Psych/Streaming.md | 10 - example/ruby/Psych/Streaming/ClassMethods.md | 11 - example/ruby/Psych/SyntaxError.md | 31 - example/ruby/Psych/Tagged.md | 16 - example/ruby/Psych/TestAliasAndAnchor.md | 20 - example/ruby/Psych/TestArray.md | 28 - example/ruby/Psych/TestArray/X.md | 7 - example/ruby/Psych/TestArray/Y.md | 11 - example/ruby/Psych/TestBoolean.md | 17 - example/ruby/Psych/TestCase.md | 25 - example/ruby/Psych/TestClass.md | 20 - example/ruby/Psych/TestClass/Foo.md | 6 - example/ruby/Psych/TestCoder.md | 68 - example/ruby/Psych/TestCoder/CustomEncode.md | 14 - example/ruby/Psych/TestCoder/InitApi.md | 35 - example/ruby/Psych/TestCoder/Referential.md | 20 - example/ruby/Psych/TestCoder/Represent.md | 10 - .../ruby/Psych/TestCoder/RepresentWithInit.md | 16 - .../ruby/Psych/TestCoder/RepresentWithMap.md | 16 - .../Psych/TestCoder/RepresentWithObject.md | 10 - .../ruby/Psych/TestCoder/RepresentWithSeq.md | 16 - example/ruby/Psych/TestCoder/ScalarCoder.md | 10 - example/ruby/Psych/TestCoder/TaggingCoder.md | 10 - example/ruby/Psych/TestDateTime.md | 38 - example/ruby/Psych/TestDeprecated.md | 22 - .../ruby/Psych/TestDeprecated/QuickEmitter.md | 7 - .../TestDeprecated/QuickEmitterEncodeWith.md | 23 - .../TestDeprecated/YamlInitAndInitWith.md | 23 - example/ruby/Psych/TestDocument.md | 22 - example/ruby/Psych/TestEmitter.md | 28 - example/ruby/Psych/TestEncoding.md | 56 - .../Psych/TestEncoding/EncodingCatcher.md | 16 - example/ruby/Psych/TestException.md | 38 - example/ruby/Psych/TestException/Wups.md | 19 - example/ruby/Psych/TestHash.md | 42 - .../ruby/Psych/TestHash/HashWithCustomInit.md | 16 - .../TestHash/HashWithCustomInitNoIvar.md | 12 - example/ruby/Psych/TestHash/HashWithIvar.md | 14 - example/ruby/Psych/TestHash/X.md | 7 - example/ruby/Psych/TestJSONTree.md | 28 - example/ruby/Psych/TestJSONTree/Bar.md | 10 - example/ruby/Psych/TestMarshalable.md | 14 - .../TestMarshalable/PsychCustomMarshalable.md | 30 - example/ruby/Psych/TestMergeKeys.md | 38 - example/ruby/Psych/TestMergeKeys/Product.md | 11 - example/ruby/Psych/TestNil.md | 12 - example/ruby/Psych/TestNull.md | 11 - example/ruby/Psych/TestNumeric.md | 29 - example/ruby/Psych/TestObject.md | 16 - example/ruby/Psych/TestObjectReferences.md | 30 - example/ruby/Psych/TestOmap.md | 27 - example/ruby/Psych/TestParser.md | 90 - example/ruby/Psych/TestParser/EventCatcher.md | 22 - example/ruby/Psych/TestSafeLoad.md | 32 - example/ruby/Psych/TestSafeLoad/Foo.md | 7 - example/ruby/Psych/TestSafeLoad/X.md | 13 - example/ruby/Psych/TestScalar.md | 13 - example/ruby/Psych/TestScalarScanner.md | 72 - .../TestScalarScanner/MatchCallCounter.md | 16 - example/ruby/Psych/TestSerializeSubclasses.md | 12 - .../TestSerializeSubclasses/SomeObject.md | 14 - .../TestSerializeSubclasses/StructSubclass.md | 20 - example/ruby/Psych/TestSet.md | 25 - example/ruby/Psych/TestStream.md | 26 - example/ruby/Psych/TestString.md | 79 - example/ruby/Psych/TestString/X.md | 7 - example/ruby/Psych/TestString/Y.md | 11 - example/ruby/Psych/TestString/Z.md | 12 - example/ruby/Psych/TestStruct.md | 14 - .../ruby/Psych/TestStruct/StructSubclass.md | 18 - example/ruby/Psych/TestSymbol.md | 18 - example/ruby/Psych/TestTreeBuilder.md | 22 - example/ruby/Psych/TestYamlSpecialCases.md | 34 - example/ruby/Psych/TreeBuilder.md | 49 - example/ruby/Psych/Visitors.md | 6 - example/ruby/Psych/Visitors/DepthFirst.md | 12 - example/ruby/Psych/Visitors/Emitter.md | 24 - example/ruby/Psych/Visitors/JSONTree.md | 20 - example/ruby/Psych/Visitors/NoAliasRuby.md | 12 - .../ruby/Psych/Visitors/RestrictedYAMLTree.md | 16 - example/ruby/Psych/Visitors/TestDepthFirst.md | 16 - .../Visitors/TestDepthFirst/Collector.md | 20 - example/ruby/Psych/Visitors/TestEmitter.md | 28 - example/ruby/Psych/Visitors/TestToRuby.md | 78 - example/ruby/Psych/Visitors/TestToRuby/A.md | 13 - example/ruby/Psych/Visitors/TestYAMLTree.md | 67 - example/ruby/Psych/Visitors/TestYAMLTree/A.md | 13 - .../TestYAMLTree/TestDelegatorClass.md | 16 - .../TestYAMLTree/TestSimpleDelegatorClass.md | 7 - example/ruby/Psych/Visitors/ToRuby.md | 33 - example/ruby/Psych/Visitors/Visitor.md | 10 - example/ruby/Psych/Visitors/YAMLTree.md | 92 - .../ruby/Psych/Visitors/YAMLTree/Registrar.md | 23 - example/ruby/Psych/YAMLDBMTest.md | 64 - example/ruby/Psych/YAMLStoreTest.md | 28 - example/ruby/PsychStructWithIvar.md | 21 - example/ruby/Psych_Tests.md | 8 - example/ruby/Psych_Tests/StructTest.md | 13 - example/ruby/Psych_Unit_Tests.md | 176 - example/ruby/Psych_Unit_Tests/NumericTest.md | 15 - example/ruby/QuarantineGuard.md | 12 - example/ruby/QuxParameterVisitor.md | 17 - example/ruby/RDoc.md | 29 - example/ruby/RDoc/Alias.md | 58 - example/ruby/RDoc/AnonClass.md | 12 - example/ruby/RDoc/AnyMethod.md | 114 - example/ruby/RDoc/Attr.md | 62 - example/ruby/RDoc/ClassModule.md | 224 - example/ruby/RDoc/CodeObject.md | 230 - example/ruby/RDoc/Comment.md | 128 - example/ruby/RDoc/Constant.md | 67 - example/ruby/RDoc/Context.md | 465 -- example/ruby/RDoc/Context/Section.md | 131 - example/ruby/RDoc/CrossReference.md | 29 - example/ruby/RDoc/ERBIO.md | 28 - example/ruby/RDoc/ERBPartial.md | 14 - example/ruby/RDoc/Encoding.md | 24 - example/ruby/RDoc/Error.md | 8 - example/ruby/RDoc/Extend.md | 10 - example/ruby/RDoc/Generator.md | 44 - example/ruby/RDoc/Generator/Darkfish.md | 196 - example/ruby/RDoc/Generator/JsonIndex.md | 157 - example/ruby/RDoc/Generator/Markup.md | 28 - example/ruby/RDoc/Generator/POT.md | 69 - .../RDoc/Generator/POT/MessageExtractor.md | 18 - example/ruby/RDoc/Generator/POT/PO.md | 20 - example/ruby/RDoc/Generator/POT/POEntry.md | 39 - example/ruby/RDoc/Generator/RI.md | 17 - example/ruby/RDoc/GhostMethod.md | 8 - example/ruby/RDoc/I18n.md | 7 - example/ruby/RDoc/I18n/Locale.md | 49 - example/ruby/RDoc/I18n/Text.md | 41 - example/ruby/RDoc/Include.md | 10 - example/ruby/RDoc/Markdown.md | 1206 ---- example/ruby/RDoc/Markdown/KpegPosInfo.md | 33 - example/ruby/RDoc/Markdown/Literals.md | 115 - .../RDoc/Markdown/Literals/KpegPosInfo.md | 33 - .../ruby/RDoc/Markdown/Literals/MemoEntry.md | 30 - .../ruby/RDoc/Markdown/Literals/ParseError.md | 7 - .../ruby/RDoc/Markdown/Literals/RuleInfo.md | 19 - example/ruby/RDoc/Markdown/MemoEntry.md | 30 - example/ruby/RDoc/Markdown/ParseError.md | 7 - example/ruby/RDoc/Markdown/RuleInfo.md | 19 - example/ruby/RDoc/Markup.md | 147 - example/ruby/RDoc/Markup/AttrChanger.md | 27 - example/ruby/RDoc/Markup/AttrSpan.md | 20 - example/ruby/RDoc/Markup/AttributeManager.md | 109 - example/ruby/RDoc/Markup/Attributes.md | 28 - example/ruby/RDoc/Markup/BlankLine.md | 18 - example/ruby/RDoc/Markup/BlockQuote.md | 12 - example/ruby/RDoc/Markup/Document.md | 2130 ------- example/ruby/RDoc/Markup/Formatter.md | 87 - .../ruby/RDoc/Markup/Formatter/InlineTag.md | 25 - example/ruby/RDoc/Markup/FormatterTestCase.md | 73 - example/ruby/RDoc/Markup/HardBreak.md | 21 - example/ruby/RDoc/Markup/Include.md | 30 - example/ruby/RDoc/Markup/IndentedParagraph.md | 29 - example/ruby/RDoc/Markup/List.md | 70 - example/ruby/RDoc/Markup/ListItem.md | 51 - example/ruby/RDoc/Markup/Paragraph.md | 16 - example/ruby/RDoc/Markup/Parser.md | 127 - example/ruby/RDoc/Markup/Parser/Error.md | 8 - .../RDoc/Markup/Parser/MyStringScanner.md | 31 - example/ruby/RDoc/Markup/Parser/ParseError.md | 8 - example/ruby/RDoc/Markup/PreProcess.md | 92 - example/ruby/RDoc/Markup/PreProcessTest.md | 98 - example/ruby/RDoc/Markup/Raw.md | 39 - example/ruby/RDoc/Markup/RegexpHandling.md | 30 - example/ruby/RDoc/Markup/Rule.md | 21 - example/ruby/RDoc/Markup/Table.md | 31 - .../ruby/RDoc/Markup/TextFormatterTestCase.md | 35 - example/ruby/RDoc/Markup/ToAnsi.md | 26 - example/ruby/RDoc/Markup/ToBs.md | 36 - example/ruby/RDoc/Markup/ToHtml.md | 177 - example/ruby/RDoc/Markup/ToHtmlCrossref.md | 63 - example/ruby/RDoc/Markup/ToHtmlSnippet.md | 89 - example/ruby/RDoc/Markup/ToJoinedParagraph.md | 28 - example/ruby/RDoc/Markup/ToLabel.md | 30 - example/ruby/RDoc/Markup/ToMarkdown.md | 50 - example/ruby/RDoc/Markup/ToRdoc.md | 100 - example/ruby/RDoc/Markup/ToTableOfContents.md | 42 - example/ruby/RDoc/Markup/ToTest.md | 34 - example/ruby/RDoc/Markup/ToTtOnly.md | 49 - example/ruby/RDoc/Markup/Verbatim.md | 38 - example/ruby/RDoc/MarkupReference.md | 1212 ---- .../ruby/RDoc/MarkupReference/DummyClass.md | 8 - .../ruby/RDoc/MarkupReference/DummyModule.md | 7 - example/ruby/RDoc/MetaMethod.md | 8 - example/ruby/RDoc/MethodAttr.md | 251 - example/ruby/RDoc/Mixin.md | 55 - example/ruby/RDoc/NormalClass.md | 31 - example/ruby/RDoc/NormalModule.md | 31 - example/ruby/RDoc/Options.md | 292 - example/ruby/RDoc/Parser.md | 102 - example/ruby/RDoc/Parser/C.md | 351 -- example/ruby/RDoc/Parser/ChangeLog.md | 59 - example/ruby/RDoc/Parser/ChangeLog/Git.md | 19 - .../RDoc/Parser/ChangeLog/Git/LogEntry.md | 56 - example/ruby/RDoc/Parser/Markdown.md | 15 - example/ruby/RDoc/Parser/PrismRuby.md | 148 - .../ruby/RDoc/Parser/PrismRuby/RDocVisitor.md | 29 - .../RDocVisitor/MethodSignatureVisitor.md | 33 - example/ruby/RDoc/Parser/RD.md | 15 - example/ruby/RDoc/Parser/RipperStateLex.md | 23 - .../Parser/RipperStateLex/InnerStateLex.md | 14 - .../ruby/RDoc/Parser/RipperStateLex/Token.md | 34 - example/ruby/RDoc/Parser/Ruby.md | 501 -- example/ruby/RDoc/Parser/RubyTools.md | 45 - example/ruby/RDoc/Parser/Simple.md | 33 - example/ruby/RDoc/Parser/Text.md | 11 - example/ruby/RDoc/RD.md | 12 - example/ruby/RDoc/RD/BlockParser.md | 183 - example/ruby/RDoc/RD/Inline.md | 36 - example/ruby/RDoc/RD/InlineParser.md | 148 - example/ruby/RDoc/RDoc.md | 133 - example/ruby/RDoc/RI.md | 9 - example/ruby/RDoc/RI/Driver.md | 238 - example/ruby/RDoc/RI/Driver/Error.md | 8 - example/ruby/RDoc/RI/Driver/NotFoundError.md | 20 - example/ruby/RDoc/RI/Error.md | 8 - example/ruby/RDoc/RI/Formatter.md | 7 - example/ruby/RDoc/RI/Paths.md | 68 - example/ruby/RDoc/RI/Task.md | 53 - example/ruby/RDoc/Require.md | 27 - example/ruby/RDoc/RubyGemsHook.md | 193 - example/ruby/RDoc/RubygemsHook.md | 31 - example/ruby/RDoc/Servlet.md | 107 - example/ruby/RDoc/SingleClass.md | 21 - example/ruby/RDoc/Stats.md | 134 - example/ruby/RDoc/Stats/Normal.md | 18 - example/ruby/RDoc/Stats/Quiet.md | 41 - example/ruby/RDoc/Stats/Verbose.md | 34 - example/ruby/RDoc/Store.md | 282 - example/ruby/RDoc/Store/Error.md | 8 - example/ruby/RDoc/Store/MissingFileError.md | 28 - example/ruby/RDoc/Task.md | 149 - example/ruby/RDoc/TestCase.md | 83 - example/ruby/RDoc/Text.md | 51 - example/ruby/RDoc/TokenStream.md | 35 - example/ruby/RDoc/TomDoc.md | 108 - example/ruby/RDoc/TopLevel.md | 125 - example/ruby/RDocGeneratorDarkfishTest.md | 61 - example/ruby/RDocMarkupToAnsiTest.md | 131 - example/ruby/RDocMarkupToBsTest.md | 128 - example/ruby/RDocMarkupToHtmlCrossrefTest.md | 82 - example/ruby/RDocMarkupToHtmlTest.md | 224 - example/ruby/RDocMarkupToMarkdownTest.md | 142 - example/ruby/RDocMarkupToRDocTest.md | 133 - example/ruby/RDocParserPrismTestCases.md | 179 - example/ruby/RDocParserTest.md | 65 - example/ruby/RDocRIDriverTest.md | 197 - example/ruby/RSpecExt.md | 9 - example/ruby/Racc.md | 171 - example/ruby/Racc/ParseError.md | 7 - example/ruby/Racc/Parser.md | 83 - example/ruby/Ractor.md | 836 --- example/ruby/Ractor/ClosedError.md | 39 - example/ruby/Ractor/Error.md | 7 - example/ruby/Ractor/IsolationError.md | 7 - example/ruby/Ractor/MovedError.md | 16 - example/ruby/Ractor/MovedObject.md | 41 - example/ruby/Ractor/RemoteError.md | 24 - example/ruby/Ractor/Selector.md | 27 - example/ruby/Ractor/UnsafeError.md | 7 - example/ruby/RactorCompatibilityTest.md | 20 - example/ruby/RactorLocalSingleton.md | 28 - .../RactorLocalSingletonClassMethods.md | 17 - example/ruby/RaiseErrorMatcher.md | 50 - example/ruby/Rake.md | 7 - example/ruby/Rake/ExtensionTask.md | 12 - example/ruby/Random.md | 185 - example/ruby/Random/Formatter.md | 280 - .../ruby/Random/Formatter/FormatterTest.md | 41 - .../ruby/Random/Formatter/NotDefaultTest.md | 9 - .../ruby/Random/Formatter/TestClassMethods.md | 48 - .../Random/Formatter/TestInstanceMethods.md | 48 - example/ruby/RandomSpecs.md | 6 - example/ruby/RandomSpecs/CustomRangeFloat.md | 22 - .../ruby/RandomSpecs/CustomRangeInteger.md | 22 - example/ruby/Range.md | 2744 -------- example/ruby/RangeError.md | 14 - example/ruby/RangeSpecs.md | 6 - example/ruby/RangeSpecs/ComparisonError.md | 7 - example/ruby/RangeSpecs/Custom.md | 104 - example/ruby/RangeSpecs/MyRange.md | 7 - example/ruby/RangeSpecs/TenfoldSucc.md | 105 - example/ruby/RangeSpecs/WithoutSucc.md | 103 - example/ruby/RangeSpecs/Xs.md | 13 - example/ruby/RangeSpecs/Ys.md | 13 - example/ruby/Rational.md | 401 -- example/ruby/Rational/compatible.md | 7 - example/ruby/RationalSpecs.md | 6 - example/ruby/RationalSpecs/CoerceError.md | 7 - example/ruby/RationalSpecs/SubNumeric.md | 14 - example/ruby/RationalSub.md | 7 - example/ruby/Rational_Test.md | 118 - example/ruby/Rational_Test/ObjectX.md | 12 - example/ruby/Rational_Test2.md | 10 - example/ruby/Ray.md | 19 - example/ruby/RbConfig.md | 10 - example/ruby/RbInstall.md | 8 - example/ruby/RbInstall/DirPackage.md | 27 - example/ruby/RbInstall/Specs.md | 6 - example/ruby/RbInstall/Specs/FileCollector.md | 26 - .../ruby/RbInstall/Specs/FileCollector/Ext.md | 10 - .../ruby/RbInstall/Specs/FileCollector/Lib.md | 10 - example/ruby/RbInstall/UnpackedInstaller.md | 36 - example/ruby/RealSuperUserGuard.md | 12 - example/ruby/RedBlackTree.md | 2082 ------ example/ruby/RedBlackTree/NilNode.md | 19 - example/ruby/RedBlackTree/Node.md | 38 - example/ruby/Refinement.md | 24 - example/ruby/RefinementSpec.md | 6 - .../RefinementSpec/ModuleWithAncestors.md | 6 - example/ruby/ReflectSpecs.md | 51 - example/ruby/ReflectSpecs/A.md | 18 - example/ruby/ReflectSpecs/B.md | 18 - example/ruby/ReflectSpecs/C.md | 24 - example/ruby/ReflectSpecs/D.md | 21 - example/ruby/ReflectSpecs/E.md | 17 - example/ruby/ReflectSpecs/F.md | 19 - example/ruby/ReflectSpecs/K.md | 7 - example/ruby/ReflectSpecs/L.md | 14 - example/ruby/ReflectSpecs/M.md | 16 - example/ruby/ReflectSpecs/N.md | 20 - example/ruby/ReflectSpecs/O.md | 8 - example/ruby/ReflectSpecs/P.md | 13 - example/ruby/Regexp.md | 546 -- example/ruby/Regexp/TimeoutError.md | 7 - example/ruby/RegexpError.md | 14 - example/ruby/RegexpFilter.md | 18 - example/ruby/Reline.md | 86 - example/ruby/Reline/ANSI.md | 93 - example/ruby/Reline/ANSITest.md | 34 - example/ruby/Reline/Config.md | 69 - example/ruby/Reline/Config/InvalidInputrc.md | 14 - example/ruby/Reline/Config/Test.md | 118 - .../Reline/ConfigEncodingConversionError.md | 7 - example/ruby/Reline/Core.md | 153 - example/ruby/Reline/Core/DialogProc.md | 18 - example/ruby/Reline/CursorPos.md | 18 - example/ruby/Reline/DialogRenderInfo.md | 43 - example/ruby/Reline/Dumb.md | 70 - example/ruby/Reline/Face.md | 17 - example/ruby/Reline/Face/Test.md | 12 - example/ruby/Reline/Face/Test/ConfigTest.md | 34 - .../Face/Test/WithInsufficientSetupTest.md | 14 - .../ruby/Reline/Face/Test/WithSetupTest.md | 22 - .../ruby/Reline/Face/Test/WithoutSetupTest.md | 22 - example/ruby/Reline/History.md | 26 - example/ruby/Reline/History/Test.md | 54 - example/ruby/Reline/IO.md | 23 - example/ruby/Reline/Key.md | 31 - example/ruby/Reline/KeyActor.md | 6 - example/ruby/Reline/KeyActor/Base.md | 24 - example/ruby/Reline/KeyActor/Composite.md | 18 - example/ruby/Reline/KeyActor/EmacsTest.md | 245 - example/ruby/Reline/KeyStroke.md | 20 - example/ruby/Reline/KeyStroke/Test.md | 20 - example/ruby/Reline/KillRing.md | 2082 ------ example/ruby/Reline/KillRing/RingBuffer.md | 25 - example/ruby/Reline/KillRing/RingPoint.md | 30 - example/ruby/Reline/KillRing/State.md | 6 - example/ruby/Reline/KillRing/Test.md | 30 - example/ruby/Reline/LineEditor.md | 154 - .../Reline/LineEditor/CompletionBlockTest.md | 22 - .../LineEditor/CompletionJourneyState.md | 38 - .../ruby/Reline/LineEditor/CompletionState.md | 6 - .../Reline/LineEditor/CursorPositionTest.md | 12 - example/ruby/Reline/LineEditor/Dialog.md | 41 - .../ruby/Reline/LineEditor/DialogProcScope.md | 44 - .../DialogProcScope/CompletionJourneyData.md | 28 - example/ruby/Reline/LineEditor/MenuInfo.md | 18 - .../LineEditor/RenderLineDifferentialTest.md | 28 - .../RenderLineDifferentialTest/TestIO.md | 14 - .../ruby/Reline/LineEditor/RenderedScreen.md | 23 - .../Reline/LineEditor/StringProcessingTest.md | 18 - example/ruby/Reline/MacroTest.md | 20 - example/ruby/Reline/Test.md | 78 - .../ruby/Reline/Test/DummyCallbackObject.md | 10 - example/ruby/Reline/TestCase.md | 26 - example/ruby/Reline/TestKey.md | 10 - example/ruby/Reline/Unicode.md | 40 - example/ruby/Reline/Unicode/EastAsianWidth.md | 7 - example/ruby/Reline/Unicode/Test.md | 66 - example/ruby/Reline/ViInsertTest.md | 174 - example/ruby/Reline/Windows.md | 97 - example/ruby/Reline/Windows/KeyEventRecord.md | 40 - .../Reline/Windows/KeyEventRecord/Test.md | 24 - example/ruby/Reline/Windows/Win32API.md | 14 - example/ruby/Reline/WithinPipeTest.md | 22 - example/ruby/RelocationVisitor.md | 26 - example/ruby/Removal.md | 42 - example/ruby/RequirePathCheckTest.md | 16 - example/ruby/RequirementChecker.md | 16 - example/ruby/RescueSpecs.md | 14 - example/ruby/RescueSpecs/Captor.md | 13 - .../ruby/RescueSpecs/ClassVariableCaptor.md | 12 - example/ruby/RescueSpecs/ConstantCaptor.md | 12 - .../ruby/RescueSpecs/GlobalVariableCaptor.md | 12 - .../RescueSpecs/InstanceVariableCaptor.md | 10 - .../ruby/RescueSpecs/LocalVariableCaptor.md | 10 - .../RescueSpecs/SafeNavigationSetterCaptor.md | 10 - example/ruby/RescueSpecs/SetterCaptor.md | 10 - .../ruby/RescueSpecs/SquareBracketsCaptor.md | 14 - example/ruby/Resolv.md | 76 - example/ruby/Resolv/DNS.md | 166 - example/ruby/Resolv/DNS/Config.md | 36 - example/ruby/Resolv/DNS/Config/NXDomain.md | 8 - .../Resolv/DNS/Config/OtherResolvError.md | 8 - example/ruby/Resolv/DNS/DecodeError.md | 8 - example/ruby/Resolv/DNS/EncodeError.md | 8 - example/ruby/Resolv/DNS/Label.md | 9 - example/ruby/Resolv/DNS/Label/Str.md | 32 - example/ruby/Resolv/DNS/Message.md | 74 - .../ruby/Resolv/DNS/Message/MessageDecoder.md | 47 - .../ruby/Resolv/DNS/Message/MessageEncoder.md | 35 - example/ruby/Resolv/DNS/Name.md | 75 - example/ruby/Resolv/DNS/OpCode.md | 7 - example/ruby/Resolv/DNS/Query.md | 19 - example/ruby/Resolv/DNS/RCode.md | 7 - example/ruby/Resolv/DNS/Requester.md | 19 - .../ruby/Resolv/DNS/Requester/ConnectedUDP.md | 21 - .../DNS/Requester/ConnectedUDP/Sender.md | 15 - .../ruby/Resolv/DNS/Requester/MDNSOneShot.md | 13 - .../ruby/Resolv/DNS/Requester/RequestError.md | 8 - example/ruby/Resolv/DNS/Requester/Sender.md | 13 - example/ruby/Resolv/DNS/Requester/TCP.md | 19 - .../ruby/Resolv/DNS/Requester/TCP/Sender.md | 15 - .../Resolv/DNS/Requester/UnconnectedUDP.md | 21 - .../DNS/Requester/UnconnectedUDP/Sender.md | 19 - example/ruby/Resolv/DNS/Resource.md | 36 - example/ruby/Resolv/DNS/Resource/ANY.md | 8 - example/ruby/Resolv/DNS/Resource/CAA.md | 39 - example/ruby/Resolv/DNS/Resource/CNAME.md | 8 - .../ruby/Resolv/DNS/Resource/DomainName.md | 24 - example/ruby/Resolv/DNS/Resource/Generic.md | 26 - example/ruby/Resolv/DNS/Resource/HINFO.md | 27 - example/ruby/Resolv/DNS/Resource/IN.md | 7 - example/ruby/Resolv/DNS/Resource/IN/A.md | 24 - example/ruby/Resolv/DNS/Resource/IN/AAAA.md | 24 - example/ruby/Resolv/DNS/Resource/IN/HTTPS.md | 8 - example/ruby/Resolv/DNS/Resource/IN/SRV.md | 55 - example/ruby/Resolv/DNS/Resource/IN/SVCB.md | 8 - .../Resolv/DNS/Resource/IN/ServiceBinding.md | 43 - example/ruby/Resolv/DNS/Resource/IN/WKS.md | 33 - example/ruby/Resolv/DNS/Resource/LOC.md | 47 - example/ruby/Resolv/DNS/Resource/MINFO.md | 26 - example/ruby/Resolv/DNS/Resource/MX.md | 27 - example/ruby/Resolv/DNS/Resource/NS.md | 8 - example/ruby/Resolv/DNS/Resource/PTR.md | 8 - example/ruby/Resolv/DNS/Resource/SOA.md | 46 - example/ruby/Resolv/DNS/Resource/TXT.md | 26 - example/ruby/Resolv/DNS/SvcParam.md | 13 - example/ruby/Resolv/DNS/SvcParam/ALPN.md | 24 - example/ruby/Resolv/DNS/SvcParam/DoHPath.md | 24 - example/ruby/Resolv/DNS/SvcParam/Generic.md | 25 - example/ruby/Resolv/DNS/SvcParam/IPv4Hint.md | 24 - example/ruby/Resolv/DNS/SvcParam/IPv6Hint.md | 24 - example/ruby/Resolv/DNS/SvcParam/Mandatory.md | 24 - .../ruby/Resolv/DNS/SvcParam/NoDefaultALPN.md | 15 - example/ruby/Resolv/DNS/SvcParam/Port.md | 24 - example/ruby/Resolv/DNS/SvcParams.md | 2078 ------ example/ruby/Resolv/Hosts.md | 39 - example/ruby/Resolv/IPv4.md | 40 - example/ruby/Resolv/IPv6.md | 49 - example/ruby/Resolv/LOC.md | 6 - example/ruby/Resolv/LOC/Alt.md | 44 - example/ruby/Resolv/LOC/Coord.md | 47 - example/ruby/Resolv/LOC/Size.md | 44 - example/ruby/Resolv/MDNS.md | 41 - example/ruby/Resolv/ResolvError.md | 8 - example/ruby/Resolv/ResolvTimeout.md | 8 - example/ruby/ResolveSymbolResolver.md | 10 - example/ruby/ResolveSymbolTarget.md | 8 - example/ruby/RespondToMatcher.md | 20 - example/ruby/ReturnSpecs.md | 6 - example/ruby/ReturnSpecs/Blocks.md | 12 - example/ruby/ReturnSpecs/DefineMethod.md | 10 - example/ruby/ReturnSpecs/MethodWithBlock.md | 14 - example/ruby/ReturnSpecs/NestedBlocks.md | 10 - example/ruby/ReturnSpecs/NestedCalls.md | 12 - example/ruby/ReturnSpecs/SavedInnerBlock.md | 16 - .../ruby/ReturnSpecs/ThroughDefineMethod.md | 12 - example/ruby/Ring.md | 18 - example/ruby/RingEcho.md | 16 - example/ruby/Ripper.md | 165 - example/ruby/Ripper/Filter.md | 37 - example/ruby/Ripper/Lexer.md | 22 - example/ruby/Ripper/Lexer/Elem.md | 36 - example/ruby/Ripper/Lexer/State.md | 42 - example/ruby/Ripper/SexpBuilder.md | 12 - example/ruby/Ripper/SexpBuilderPP.md | 8 - example/ruby/Ripper/TokenPattern.md | 17 - .../ruby/Ripper/TokenPattern/CompileError.md | 8 - example/ruby/Ripper/TokenPattern/Error.md | 8 - example/ruby/Ripper/TokenPattern/MatchData.md | 15 - .../ruby/Ripper/TokenPattern/MatchError.md | 8 - example/ruby/Rotation.md | 71 - example/ruby/Ruby.md | 6 - example/ruby/Ruby2HTML.md | 20 - example/ruby/RubyExeSpecs.md | 7 - example/ruby/RubyImplementation.md | 32 - example/ruby/RubyVM.md | 78 - example/ruby/RubyVM/AbstractSyntaxTree.md | 102 - .../RubyVM/AbstractSyntaxTree/Location.md | 42 - .../ruby/RubyVM/AbstractSyntaxTree/Node.md | 138 - .../AbstractSyntaxTree/Node/CodePosition.md | 106 - example/ruby/RubyVM/Attribute.md | 35 - example/ruby/RubyVM/BareInstructions.md | 90 - example/ruby/RubyVM/CEscape.md | 23 - example/ruby/RubyVM/CExpr.md | 30 - example/ruby/RubyVM/Dumper.md | 22 - example/ruby/RubyVM/Insns2VM.md | 8 - example/ruby/RubyVM/InstructionSequence.md | 655 -- .../InstructionSequence/BasicStorage.md | 18 - .../RubyVM/InstructionSequence/DBMStorage.md | 14 - .../RubyVM/InstructionSequence/FS2Storage.md | 10 - .../RubyVM/InstructionSequence/FSStorage.md | 14 - .../RubyVM/InstructionSequence/NullStorage.md | 14 - .../ruby/RubyVM/InstructionsUnifications.md | 18 - example/ruby/RubyVM/OperandsUnifications.md | 32 - example/ruby/RubyVM/RJIT.md | 19 - example/ruby/RubyVM/RJIT/Assembler.md | 151 - example/ruby/RubyVM/RJIT/Assembler/Label.md | 8 - example/ruby/RubyVM/RJIT/Assembler/ModRM.md | 8 - example/ruby/RubyVM/RJIT/Assembler/Rel32.md | 8 - example/ruby/RubyVM/RJIT/Block.md | 48 - example/ruby/RubyVM/RJIT/BranchStub.md | 44 - example/ruby/RubyVM/RJIT/BranchTarget.md | 23 - example/ruby/RubyVM/RJIT/BytePtr.md | 8 - example/ruby/RubyVM/RJIT/CPointer.md | 11 - example/ruby/RubyVM/RJIT/CPointer/Array.md | 31 - example/ruby/RubyVM/RJIT/CPointer/BitField.md | 27 - example/ruby/RubyVM/RJIT/CPointer/Bool.md | 14 - .../ruby/RubyVM/RJIT/CPointer/Immediate.md | 41 - example/ruby/RubyVM/RJIT/CPointer/Pointer.md | 41 - example/ruby/RubyVM/RJIT/CPointer/Struct.md | 36 - example/ruby/RubyVM/RJIT/CPointer/Union.md | 39 - example/ruby/RubyVM/RJIT/CType.md | 6 - example/ruby/RubyVM/RJIT/CType/Array.md | 9 - example/ruby/RubyVM/RJIT/CType/BitField.md | 12 - example/ruby/RubyVM/RJIT/CType/Bool.md | 8 - example/ruby/RubyVM/RJIT/CType/Immediate.md | 14 - example/ruby/RubyVM/RJIT/CType/Pointer.md | 12 - example/ruby/RubyVM/RJIT/CType/Struct.md | 12 - example/ruby/RubyVM/RJIT/CType/Stub.md | 14 - example/ruby/RubyVM/RJIT/CType/Union.md | 12 - example/ruby/RubyVM/RJIT/C_3DModule.new.md | 11 - example/ruby/RubyVM/RJIT/CodeBlock.md | 34 - example/ruby/RubyVM/RJIT/Compiler.md | 49 - example/ruby/RubyVM/RJIT/Context.md | 109 - example/ruby/RubyVM/RJIT/DwordPtr.md | 8 - example/ruby/RubyVM/RJIT/EntryStub.md | 18 - example/ruby/RubyVM/RJIT/ExitCompiler.md | 53 - example/ruby/RubyVM/RJIT/Hooks.md | 17 - example/ruby/RubyVM/RJIT/Invariants.md | 45 - example/ruby/RubyVM/RJIT/JITState.md | 64 - example/ruby/RubyVM/RJIT/OperandMatcher.md | 33 - example/ruby/RubyVM/RJIT/TestAssembler.md | 70 - example/ruby/RubyVM/RJIT/TypeDiff.md | 6 - example/ruby/RubyVM/Scanner.md | 31 - example/ruby/RubyVM/Shape.md | 8 - example/ruby/RubyVM/TraceInstructions.md | 38 - example/ruby/RubyVM/YJIT.md | 97 - example/ruby/RubygemsVersionManager.md | 47 - example/ruby/RuntimeError.md | 15 - example/ruby/S.md | 12 - example/ruby/SHA1Constants.md | 6 - example/ruby/SHA256Constants.md | 6 - example/ruby/SHA384Constants.md | 6 - example/ruby/SHA512Constants.md | 6 - example/ruby/SOCKSSocket.md | 27 - example/ruby/SameName.md | 7 - .../ruby/SampleClassForTestProfileFrames.md | 16 - .../Sample2.md | 10 - .../Sample3.md | 8 - .../SampleClassForTestProfileThreadFrames.md | 16 - example/ruby/Scene.md | 16 - example/ruby/Scheduler.md | 86 - example/ruby/ScratchPad.md | 12 - example/ruby/ScriptError.md | 11 - example/ruby/SecondClass.md | 10 - example/ruby/SecureRandom.md | 266 - example/ruby/SecurityError.md | 8 - example/ruby/Segfault.md | 7 - example/ruby/SendSpecs.md | 6 - example/ruby/Sentence.md | 2285 ------- example/ruby/Sentence/Gen.md | 32 - example/ruby/Seq.md | 16 - example/ruby/Set.md | 2517 -------- example/ruby/SetSpecs.md | 6 - example/ruby/SetSpecs/SetLike.md | 2088 ------- example/ruby/Shellwords.md | 164 - example/ruby/ShouldSpecsMonitor.md | 16 - example/ruby/Signal.md | 51 - example/ruby/SignalException.md | 33 - example/ruby/SignedZeroMatcher.md | 20 - example/ruby/SimpleDelegator.md | 91 - example/ruby/SimpleHTTPProxyServer.md | 16 - example/ruby/SimpleHTTPProxyServer/Request.md | 27 - example/ruby/SimpleHTTPSServer.md | 18 - example/ruby/SimpleHTTPServer.md | 18 - example/ruby/SimpleHTTPServer/Request.md | 26 - example/ruby/SimpleHTTPServer/Response.md | 36 - example/ruby/SimpleRat.md | 70 - example/ruby/SimpleTupleSpace.md | 18 - example/ruby/SingleForwardable.md | 59 - example/ruby/Singleton.md | 117 - .../ruby/Singleton/SingletonClassMethods.md | 17 - .../Singleton/SingletonClassProperties.md | 17 - .../Singleton/SingletonInstanceMethods.md | 20 - example/ruby/SingletonMethodsSpecs.md | 6 - .../ruby/SingletonMethodsSpecs/Prepended.md | 9 - .../SingletonMethodsSpecs/SelfExtending.md | 8 - example/ruby/SingletonSpecs.md | 6 - example/ruby/SingletonSpecs/MyClass.md | 27 - example/ruby/SingletonSpecs/MyClassChild.md | 7 - example/ruby/SingletonSpecs/NewSpec.md | 23 - .../ruby/SingletonSpecs/NotInstantiated.md | 7 - example/ruby/SkippedSpecError.md | 7 - example/ruby/SleepingBlockingScheduler.md | 12 - example/ruby/SleepingUnblockScheduler.md | 14 - example/ruby/Socket.md | 1326 ---- example/ruby/Socket/AncillaryData.md | 258 - example/ruby/Socket/Ifaddr.md | 58 - example/ruby/Socket/Option.md | 192 - example/ruby/Socket/ResolutionError.md | 24 - example/ruby/Socket/UDPSource.md | 31 - example/ruby/SocketError.md | 7 - example/ruby/SocketSpecs.md | 21 - .../ruby/SocketSpecs/ServerLoopPortFinder.md | 17 - example/ruby/SocketSpecs/SpecTCPServer.md | 26 - example/ruby/SomeClass.md | 12 - example/ruby/SortedSet.md | 7 - example/ruby/Spec.md | 6 - example/ruby/Spec/BuildMetadata.md | 418 -- example/ruby/Spec/Builders.md | 59 - example/ruby/Spec/Builders/BundlerBuilder.md | 20 - example/ruby/Spec/Builders/DepBuilder.md | 71 - example/ruby/Spec/Builders/GemBuilder.md | 12 - example/ruby/Spec/Builders/GitBareBuilder.md | 10 - example/ruby/Spec/Builders/GitBuilder.md | 10 - example/ruby/Spec/Builders/GitReader.md | 21 - example/ruby/Spec/Builders/GitUpdater.md | 10 - example/ruby/Spec/Builders/IndexBuilder.md | 71 - example/ruby/Spec/Builders/LibBuilder.md | 30 - example/ruby/Spec/Builders/PluginBuilder.md | 10 - example/ruby/Spec/Checksums.md | 24 - .../ruby/Spec/Checksums/ChecksumsBuilder.md | 26 - example/ruby/Spec/CommandExecution.md | 53 - example/ruby/Spec/Env.md | 11 - example/ruby/Spec/Helpers.md | 278 - example/ruby/Spec/Indexes.md | 50 - example/ruby/Spec/Matchers.md | 17 - example/ruby/Spec/Matchers/Precondition.md | 77 - example/ruby/Spec/Options.md | 11 - example/ruby/Spec/Path.md | 200 - example/ruby/Spec/Permissions.md | 9 - example/ruby/Spec/Platforms.md | 55 - example/ruby/Spec/Rubygems.md | 37 - example/ruby/Spec/SilentLogger.md | 7 - example/ruby/Spec/Subprocess.md | 28 - .../ruby/Spec/Subprocess/TimeoutExceeded.md | 7 - example/ruby/Spec/TheBundle.md | 152 - example/ruby/SpecEvaluate.md | 25 - example/ruby/SpecExpectation.md | 15 - example/ruby/SpecExpectationNotFoundError.md | 10 - example/ruby/SpecExpectationNotMetError.md | 7 - example/ruby/SpecGuard.md | 55 - example/ruby/SpecNegativeOperatorMatcher.md | 22 - example/ruby/SpecPositiveOperatorMatcher.md | 22 - example/ruby/SpecTag.md | 32 - example/ruby/SpecVersion.md | 114 - example/ruby/SpecdocFormatter.md | 27 - example/ruby/SpecificExampleException.md | 7 - example/ruby/Specs.md | 6 - example/ruby/Specs/Kernel.md | 6 - example/ruby/Specs/Kernel/HasEqual.md | 12 - example/ruby/Specs/Kernel/HasNone.md | 7 - example/ruby/Specs/Kernel/HasOpEqual.md | 10 - example/ruby/Specs/Kernel/HasOppoOpEqual.md | 14 - example/ruby/SpellCheckerTest.md | 16 - example/ruby/Sphere.md | 21 - example/ruby/SpinnerFormatter.md | 43 - example/ruby/SquigglyHeredocSpecs.md | 17 - example/ruby/StandardError.md | 23 - example/ruby/StatsPerFileFormatter.md | 21 - example/ruby/StopIteration.md | 47 - example/ruby/String.md | 2024 ------ example/ruby/StringIO.md | 2533 -------- example/ruby/StringIOSpecs.md | 8 - example/ruby/StringRefinement.md | 6 - example/ruby/StringScanner.md | 682 -- example/ruby/StringScanner/Error.md | 7 - example/ruby/StringScannerTests.md | 147 - example/ruby/StringSpecs.md | 8 - example/ruby/StringSpecs/ISO88599Encoding.md | 17 - example/ruby/StringSpecs/InitializeString.md | 18 - example/ruby/StringSpecs/MyArray.md | 7 - example/ruby/StringSpecs/MyRange.md | 7 - example/ruby/StringSpecs/MyString.md | 7 - .../ruby/StringSpecs/SpecialVarProcessor.md | 10 - example/ruby/StringSpecs/StringModule.md | 9 - .../StringWithRaisingConstructor.md | 14 - example/ruby/StringSpecs/SubString.md | 16 - example/ruby/StringSubclass.md | 7 - example/ruby/StringifySymbols.md | 8 - example/ruby/StringifyTarget.md | 8 - example/ruby/Struct.md | 2541 -------- example/ruby/StructClasses.md | 6 - example/ruby/StructClasses/Apple.md | 7 - example/ruby/StructClasses/Car.md | 23 - example/ruby/StructClasses/Honda.md | 12 - example/ruby/StructClasses/Ruby.md | 18 - .../StructClasses/StructWithOverriddenName.md | 15 - example/ruby/StructClasses/SubclassX.md | 16 - .../ruby/SubStringWithInstanceVariables.md | 11 - example/ruby/SummaryFormatter.md | 7 - example/ruby/SuperSpecs.md | 6 - example/ruby/SuperSpecs/Alias1.md | 10 - example/ruby/SuperSpecs/Alias2.md | 14 - example/ruby/SuperSpecs/Alias3.md | 7 - example/ruby/SuperSpecs/AliasWithSuper.md | 6 - example/ruby/SuperSpecs/AliasWithSuper/AS1.md | 9 - example/ruby/SuperSpecs/AliasWithSuper/BS1.md | 9 - .../ruby/SuperSpecs/AliasWithSuper/Base.md | 11 - .../ruby/SuperSpecs/AliasWithSuper/Trigger.md | 9 - .../AnonymousModuleIncludedTwice.md | 7 - .../AnonymousModuleIncludedTwiceBase.md | 12 - example/ruby/SuperSpecs/FromBasicObject.md | 9 - example/ruby/SuperSpecs/IncludesFromBasic.md | 14 - .../ruby/SuperSpecs/IncludesIntermediate.md | 14 - example/ruby/SuperSpecs/IntermediateBasic.md | 11 - example/ruby/SuperSpecs/Keywords.md | 6 - example/ruby/SuperSpecs/Keywords/Arguments.md | 10 - .../OptionalAndPlaceholderArguments.md | 10 - .../SuperSpecs/Keywords/OptionalArguments.md | 10 - .../Keywords/PlaceholderArguments.md | 10 - ...uiredAndOptionalAndPlaceholderArguments.md | 11 - .../Keywords/RequiredAndOptionalArguments.md | 11 - .../RequiredAndPlaceholderArguments.md | 10 - .../SuperSpecs/Keywords/RequiredArguments.md | 11 - example/ruby/SuperSpecs/MM_A.md | 7 - example/ruby/SuperSpecs/MM_B.md | 14 - example/ruby/SuperSpecs/MS1.md | 6 - example/ruby/SuperSpecs/MS1/A.md | 14 - example/ruby/SuperSpecs/MS1/B.md | 14 - example/ruby/SuperSpecs/MS1/ModA.md | 11 - example/ruby/SuperSpecs/MS1/ModB.md | 9 - example/ruby/SuperSpecs/MS2.md | 6 - example/ruby/SuperSpecs/MS2/A.md | 10 - example/ruby/SuperSpecs/MS2/B.md | 12 - example/ruby/SuperSpecs/MS2/C.md | 10 - example/ruby/SuperSpecs/MS2/ModB.md | 9 - example/ruby/SuperSpecs/MS3.md | 6 - example/ruby/SuperSpecs/MS3/A.md | 15 - example/ruby/SuperSpecs/MS3/B.md | 10 - example/ruby/SuperSpecs/MS3/ModA.md | 11 - example/ruby/SuperSpecs/MS4.md | 6 - example/ruby/SuperSpecs/MS4/A.md | 12 - example/ruby/SuperSpecs/MS4/Layer1.md | 9 - example/ruby/SuperSpecs/MS4/Layer2.md | 11 - example/ruby/SuperSpecs/MultiSuperTargets.md | 6 - .../ruby/SuperSpecs/MultiSuperTargets/A.md | 12 - .../ruby/SuperSpecs/MultiSuperTargets/B.md | 12 - .../SuperSpecs/MultiSuperTargets/BaseA.md | 10 - .../SuperSpecs/MultiSuperTargets/BaseB.md | 10 - .../ruby/SuperSpecs/MultiSuperTargets/M.md | 9 - example/ruby/SuperSpecs/RegularAndKeywords.md | 6 - .../RegularAndKeywords/Arguments.md | 10 - .../OptionalAndPlaceholderArguments.md | 10 - .../RegularAndKeywords/OptionalArguments.md | 10 - .../PlaceholderArguments.md | 10 - ...uiredAndOptionalAndPlaceholderArguments.md | 11 - .../RequiredAndOptionalArguments.md | 11 - .../RequiredAndPlaceholderArguments.md | 10 - .../RegularAndKeywords/RequiredArguments.md | 11 - example/ruby/SuperSpecs/RestArgsWithSuper.md | 6 - .../ruby/SuperSpecs/RestArgsWithSuper/A.md | 10 - .../ruby/SuperSpecs/RestArgsWithSuper/B.md | 10 - example/ruby/SuperSpecs/S1.md | 6 - example/ruby/SuperSpecs/S1/A.md | 12 - example/ruby/SuperSpecs/S1/B.md | 12 - example/ruby/SuperSpecs/S2.md | 6 - example/ruby/SuperSpecs/S2/A.md | 10 - example/ruby/SuperSpecs/S2/B.md | 10 - example/ruby/SuperSpecs/S2/C.md | 10 - example/ruby/SuperSpecs/S3.md | 6 - example/ruby/SuperSpecs/S3/A.md | 13 - example/ruby/SuperSpecs/S3/B.md | 10 - example/ruby/SuperSpecs/S4.md | 6 - example/ruby/SuperSpecs/S4/A.md | 10 - example/ruby/SuperSpecs/S4/B.md | 10 - example/ruby/SuperSpecs/S5.md | 10 - example/ruby/SuperSpecs/S6.md | 12 - example/ruby/SuperSpecs/S7.md | 7 - example/ruby/SuperSpecs/SingletonAliasCase.md | 6 - .../SuperSpecs/SingletonAliasCase/Base.md | 12 - .../ruby/SuperSpecs/SingletonAliasCase/Foo.md | 10 - example/ruby/SuperSpecs/SingletonCase.md | 6 - example/ruby/SuperSpecs/SingletonCase/Base.md | 10 - example/ruby/SuperSpecs/SingletonCase/Foo.md | 10 - example/ruby/SuperSpecs/SplatAndKeywords.md | 6 - .../SplatAndKeywords/AllArguments.md | 10 - .../SuperSpecs/SplatAndKeywords/Arguments.md | 10 - example/ruby/SuperSpecs/ZSuperInBlock.md | 6 - example/ruby/SuperSpecs/ZSuperInBlock/A.md | 10 - example/ruby/SuperSpecs/ZSuperInBlock/B.md | 10 - example/ruby/SuperSpecs/ZSuperWithBlock.md | 6 - example/ruby/SuperSpecs/ZSuperWithBlock/A.md | 14 - example/ruby/SuperSpecs/ZSuperWithBlock/B.md | 14 - example/ruby/SuperSpecs/ZSuperWithOptional.md | 6 - .../ruby/SuperSpecs/ZSuperWithOptional/A.md | 10 - .../ruby/SuperSpecs/ZSuperWithOptional/B.md | 10 - .../ruby/SuperSpecs/ZSuperWithOptional/C.md | 10 - example/ruby/SuperSpecs/ZSuperWithRest.md | 6 - example/ruby/SuperSpecs/ZSuperWithRest/A.md | 12 - example/ruby/SuperSpecs/ZSuperWithRest/B.md | 12 - .../SuperSpecs/ZSuperWithRestAndOthers.md | 6 - .../SuperSpecs/ZSuperWithRestAndOthers/A.md | 12 - .../SuperSpecs/ZSuperWithRestAndOthers/B.md | 12 - .../ruby/SuperSpecs/ZSuperWithRestAndPost.md | 6 - .../SuperSpecs/ZSuperWithRestAndPost/A.md | 12 - .../SuperSpecs/ZSuperWithRestAndPost/B.md | 12 - .../SuperSpecs/ZSuperWithRestOthersAndPost.md | 6 - .../ZSuperWithRestOthersAndPost/A.md | 12 - .../ZSuperWithRestOthersAndPost/B.md | 12 - .../SuperSpecs/ZSuperWithRestReassigned.md | 6 - .../SuperSpecs/ZSuperWithRestReassigned/A.md | 10 - .../SuperSpecs/ZSuperWithRestReassigned/B.md | 10 - .../ZSuperWithRestReassignedWithScalar.md | 6 - .../ZSuperWithRestReassignedWithScalar/A.md | 10 - .../ZSuperWithRestReassignedWithScalar/B.md | 10 - .../ruby/SuperSpecs/ZSuperWithUnderscores.md | 6 - .../SuperSpecs/ZSuperWithUnderscores/A.md | 24 - .../SuperSpecs/ZSuperWithUnderscores/B.md | 24 - example/ruby/SuperUserGuard.md | 12 - example/ruby/SupportedGuard.md | 12 - example/ruby/Symbol.md | 446 -- example/ruby/SymbolSpecs.md | 6 - example/ruby/SymbolSpecs/MyRange.md | 7 - example/ruby/SyncDefaultGems.md | 106 - example/ruby/SyntaxError.md | 20 - example/ruby/SyntaxSuggest.md | 107 - example/ruby/SyntaxSuggest/AroundBlockScan.md | 111 - example/ruby/SyntaxSuggest/BlockExpand.md | 121 - example/ruby/SyntaxSuggest/Capture.md | 6 - .../Capture/BeforeAfterKeywordEnds.md | 46 - .../Capture/FallingIndentLines.md | 43 - .../ruby/SyntaxSuggest/CaptureCodeContext.md | 138 - example/ruby/SyntaxSuggest/CleanDocument.md | 213 - example/ruby/SyntaxSuggest/Cli.md | 31 - example/ruby/SyntaxSuggest/CodeBlock.md | 71 - example/ruby/SyntaxSuggest/CodeFrontier.md | 102 - example/ruby/SyntaxSuggest/CodeLine.md | 145 - example/ruby/SyntaxSuggest/CodeSearch.md | 68 - example/ruby/SyntaxSuggest/CurrentIndex.md | 20 - .../DisplayCodeWithLineNumbers.md | 30 - .../SyntaxSuggest/DisplayInvalidBlocks.md | 23 - example/ruby/SyntaxSuggest/Error.md | 7 - example/ruby/SyntaxSuggest/ExplainSyntax.md | 59 - example/ruby/SyntaxSuggest/FakeExit.md | 22 - example/ruby/SyntaxSuggest/GetParseErrors.md | 9 - .../ruby/SyntaxSuggest/LeftRightLexCount.md | 55 - example/ruby/SyntaxSuggest/LexAll.md | 2089 ------- example/ruby/SyntaxSuggest/LexValue.md | 60 - example/ruby/SyntaxSuggest/MiniStringIO.md | 30 - .../ParseBlocksFromIndentLine.md | 44 - .../ruby/SyntaxSuggest/PathnameFromMessage.md | 36 - .../ruby/SyntaxSuggest/PriorityEngulfQueue.md | 29 - example/ruby/SyntaxSuggest/PriorityQueue.md | 48 - example/ruby/SyntaxSuggest/RipperErrors.md | 26 - example/ruby/SyntaxSuggest/ScanHistory.md | 61 - example/ruby/SyntaxSuggest/UnvisitedLines.md | 24 - example/ruby/SystemCallError.md | 37 - example/ruby/SystemExit.md | 31 - example/ruby/SystemStackError.md | 17 - example/ruby/TCPServer.md | 173 - example/ruby/TCPSocket.md | 79 - example/ruby/TC_Enumerable.md | 10 - example/ruby/TC_IPAddr.md | 40 - example/ruby/TC_OpenStruct.md | 82 - example/ruby/TC_Operator.md | 46 - example/ruby/TC_Set.md | 114 - example/ruby/TC_Set/Set2.md | 7 - example/ruby/TC_Set_Builtin.md | 12 - example/ruby/TC_SortedSet.md | 18 - example/ruby/TSort.md | 359 -- example/ruby/TSort/Cyclic.md | 7 - example/ruby/TSortArray.md | 135 - example/ruby/TSortHash.md | 135 - example/ruby/TSortTest.md | 25 - example/ruby/TagAction.md | 67 - example/ruby/TagFilter.md | 22 - example/ruby/TagListAction.md | 37 - example/ruby/TagPurgeAction.md | 34 - example/ruby/TagsVisitor.md | 79 - example/ruby/Tally.md | 64 - example/ruby/TallyAction.md | 37 - example/ruby/Tarball.md | 54 - example/ruby/Tempfile.md | 422 -- example/ruby/Tempfile/FinalizerManager.md | 21 - example/ruby/Tempfile/PathAttr.md | 13 - example/ruby/TerminationChecker.md | 10 - example/ruby/Test.md | 14 - example/ruby/Test/ASAN.md | 11 - example/ruby/Test/BacktraceFilter.md | 11 - example/ruby/Test/Unit.md | 12 - .../ruby/Test/Unit/AssertionFailedError.md | 8 - example/ruby/Test/Unit/Assertions.md | 327 - example/ruby/Test/Unit/AutoRunner.md | 26 - example/ruby/Test/Unit/AutoRunner/Runner.md | 18 - example/ruby/Test/Unit/CoreAssertions.md | 197 - .../Test/Unit/CoreAssertions/AllFailures.md | 26 - example/ruby/Test/Unit/ExcludesOption.md | 12 - .../Unit/ExcludesOption/ExcludedMethods.md | 20 - example/ruby/Test/Unit/FileAssertions.md | 33 - example/ruby/Test/Unit/GCOption.md | 12 - example/ruby/Test/Unit/GlobOption.md | 16 - example/ruby/Test/Unit/Guard.md | 40 - example/ruby/Test/Unit/LaunchableOption.md | 11 - .../Test/Unit/LaunchableOption/Nothing.md | 6 - example/ruby/Test/Unit/LifecycleHooks.md | 60 - example/ruby/Test/Unit/LoadPathOption.md | 12 - example/ruby/Test/Unit/Options.md | 14 - example/ruby/Test/Unit/Order.md | 6 - example/ruby/Test/Unit/Order/Alpha.md | 12 - example/ruby/Test/Unit/Order/NoSort.md | 16 - example/ruby/Test/Unit/Order/Shuffle.md | 30 - example/ruby/Test/Unit/OutputOption.md | 12 - example/ruby/Test/Unit/Parallel.md | 16 - example/ruby/Test/Unit/Parallel/FakeClass.md | 7 - example/ruby/Test/Unit/Parallel/Worker.md | 65 - example/ruby/Test/Unit/PendedError.md | 8 - example/ruby/Test/Unit/ProxyError.md | 20 - example/ruby/Test/Unit/RepeatOption.md | 12 - example/ruby/Test/Unit/RequireFiles.md | 12 - example/ruby/Test/Unit/RunCount.md | 15 - example/ruby/Test/Unit/Runner.md | 171 - example/ruby/Test/Unit/Skipping.md | 10 - example/ruby/Test/Unit/Statistics.md | 13 - example/ruby/Test/Unit/StatusLine.md | 36 - example/ruby/Test/Unit/StatusLine/Output.md | 19 - example/ruby/Test/Unit/TestCase.md | 603 -- example/ruby/Test/Unit/TimeoutOption.md | 11 - example/ruby/Test/Unit/Worker.md | 32 - example/ruby/TestA.md | 10 - example/ruby/TestABI.md | 16 - example/ruby/TestAddressResolve.md | 37 - .../ruby/TestAddressResolve/NullScheduler.md | 10 - .../ruby/TestAddressResolve/StubScheduler.md | 10 - example/ruby/TestAlias.md | 44 - example/ruby/TestAlias/Alias0.md | 10 - example/ruby/TestAlias/Alias1.md | 12 - example/ruby/TestAlias/Alias2.md | 7 - example/ruby/TestAlias/Alias3.md | 14 - example/ruby/TestAlias/Alias4.md | 7 - example/ruby/TestAlias/Alias5.md | 7 - example/ruby/TestAlias/C0.md | 10 - example/ruby/TestAlias/C1.md | 7 - example/ruby/TestAlias/C2.md | 7 - .../TestAlias/SuperInAliasedModuleMethod.md | 6 - .../SuperInAliasedModuleMethod/Base.md | 10 - .../SuperInAliasedModuleMethod/Derived.md | 12 - .../TestAlias/SuperInAliasedModuleMethod/M.md | 9 - example/ruby/TestAllRubyQuine.md | 11 - example/ruby/TestAllocation.md | 12 - example/ruby/TestAllocation/Literal.md | 12 - example/ruby/TestAllocation/MethodCall.md | 48 - .../TestAllocation/MethodCall/WithBlock.md | 10 - example/ruby/TestAllocation/ProcCall.md | 12 - .../ruby/TestAllocation/ProcCall/WithBlock.md | 10 - example/ruby/TestArgf.md | 168 - example/ruby/TestArithmeticSequence.md | 84 - example/ruby/TestArity.md | 28 - example/ruby/TestArray.md | 514 -- example/ruby/TestArraySubclass.md | 14 - example/ruby/TestAssertion.md | 44 - example/ruby/TestAssertion/VersionClass.md | 18 - example/ruby/TestAssignment.md | 62 - example/ruby/TestAssignment/Base.md | 7 - example/ruby/TestAssignment/MyObj.md | 10 - example/ruby/TestAssignmentGen.md | 32 - example/ruby/TestAst.md | 150 - example/ruby/TestAst/Helper.md | 22 - example/ruby/TestAst/TestLocation.md | 50 - example/ruby/TestAutoload.md | 72 - example/ruby/TestB.md | 10 - example/ruby/TestBacktrace.md | 76 - example/ruby/TestBasicInstructions.md | 70 - example/ruby/TestBasicInstructions/CVarA.md | 17 - example/ruby/TestBasicInstructions/CVarB.md | 16 - example/ruby/TestBasicInstructions/Const.md | 12 - example/ruby/TestBasicInstructions/Const/A.md | 15 - .../ruby/TestBasicInstructions/Const/A/B.md | 15 - .../ruby/TestBasicInstructions/Const/AA.md | 12 - .../ruby/TestBasicInstructions/Const/AAA.md | 12 - example/ruby/TestBasicInstructions/OP.md | 19 - example/ruby/TestBeginEndBlock.md | 40 - example/ruby/TestBenchmark.md | 43 - example/ruby/TestBig5.md | 20 - example/ruby/TestBignum_Big2str.md | 14 - example/ruby/TestBignum_BigZero.md | 14 - example/ruby/TestBignum_Div.md | 12 - example/ruby/TestBignum_Mul.md | 48 - example/ruby/TestBignum_Pack.md | 64 - example/ruby/TestBignum_Str2big.md | 16 - example/ruby/TestBugReporter.md | 10 - example/ruby/TestBundlerGem.md | 50 - example/ruby/TestC.md | 10 - example/ruby/TestCESU8.md | 21 - example/ruby/TestCP949.md | 20 - example/ruby/TestCall.md | 187 - .../TestCall/RefinedModuleLargeArrayTest.md | 14 - example/ruby/TestCase.md | 20 - example/ruby/TestCase/NilEqq.md | 6 - example/ruby/TestCase/NilEqqClass.md | 10 - example/ruby/TestCaseFold.md | 20 - example/ruby/TestCaseFold/CaseTest.md | 28 - example/ruby/TestCaseForDict.md | 43 - example/ruby/TestCaseMappingPreliminary.md | 62 - example/ruby/TestCaseOptions.md | 27 - example/ruby/TestCiDetector.md | 14 - example/ruby/TestClass.md | 121 - example/ruby/TestClass/ClassFour.md | 7 - example/ruby/TestClass/ClassOne.md | 27 - example/ruby/TestClass/ClassThree.md | 7 - example/ruby/TestClass/ClassTwo.md | 7 - example/ruby/TestClass/CloneTest.md | 10 - example/ruby/TestClass/CloneTest1.md | 7 - example/ruby/TestClass/CloneTest2.md | 7 - example/ruby/TestClone.md | 22 - example/ruby/TestClone/M001.md | 6 - example/ruby/TestClone/M002.md | 8 - example/ruby/TestClone/M003.md | 8 - example/ruby/TestCompactIndexClient.md | 30 - example/ruby/TestComparable.md | 34 - example/ruby/TestComprehensiveCaseMapping.md | 16 - example/ruby/TestConcatStress.md | 14 - example/ruby/TestCondition.md | 13 - example/ruby/TestConst.md | 18 - example/ruby/TestContinuation.md | 30 - example/ruby/TestCoverage.md | 96 - example/ruby/TestCoverage/DummyConstant.md | 10 - example/ruby/TestD.md | 10 - example/ruby/TestData.md | 38 - example/ruby/TestDate.md | 26 - example/ruby/TestDateArith.md | 54 - example/ruby/TestDateArith/Rat.md | 10 - example/ruby/TestDateAttr.md | 14 - example/ruby/TestDateCompat.md | 10 - example/ruby/TestDateConv.md | 34 - example/ruby/TestDateMarshal.md | 12 - example/ruby/TestDateNew.md | 46 - example/ruby/TestDateParse.md | 60 - example/ruby/TestDateParseRactor.md | 12 - example/ruby/TestDateStrftime.md | 39 - example/ruby/TestDateStrptime.md | 34 - example/ruby/TestDebug.md | 18 - example/ruby/TestDebug/MyRelation.md | 2072 ------ example/ruby/TestDefaultGems.md | 12 - example/ruby/TestDefined.md | 84 - .../TestDefined/ExampleRespondToMissing.md | 26 - example/ruby/TestDefined/Foo.md | 22 - example/ruby/TestDefined/RefinedClass.md | 7 - example/ruby/TestDefined/RefiningModule.md | 11 - .../ruby/TestDefined/TestAutoloadedNoload.md | 16 - .../TestDefined/TestAutoloadedSubclass.md | 12 - .../TestDefined/TestAutoloadedSuperclass.md | 7 - example/ruby/TestDelegateClass.md | 80 - example/ruby/TestDelegateClass/Bar.md | 7 - example/ruby/TestDelegateClass/Bug9155.md | 12 - example/ruby/TestDelegateClass/Bug9403.md | 7 - example/ruby/TestDelegateClass/Child.md | 7 - example/ruby/TestDelegateClass/Foo.md | 12 - example/ruby/TestDelegateClass/IV.md | 16 - example/ruby/TestDelegateClass/M.md | 10 - example/ruby/TestDelegateClass/Myclass.md | 7 - example/ruby/TestDelegateClass/Object.md | 10 - example/ruby/TestDelegateClass/Parent.md | 12 - example/ruby/TestDigest.md | 31 - example/ruby/TestDigest/TestBase.md | 10 - example/ruby/TestDigest/TestDigestParen.md | 18 - example/ruby/TestDigest/TestInitCopy.md | 10 - example/ruby/TestDigest/TestMD5.md | 34 - example/ruby/TestDigest/TestRMD160.md | 34 - example/ruby/TestDigest/TestSHA1.md | 34 - example/ruby/TestDigest/TestSHA2.md | 10 - example/ruby/TestDigest/TestSHA256.md | 34 - example/ruby/TestDigest/TestSHA384.md | 34 - example/ruby/TestDigest/TestSHA512.md | 34 - example/ruby/TestDigestExtend.md | 37 - example/ruby/TestDigestExtend/MyDigest.md | 20 - example/ruby/TestDigestRactor.md | 9 - .../ruby/TestDigestRactor/TestMD5Ractor.md | 12 - .../ruby/TestDigestRactor/TestRMD160Ractor.md | 12 - .../ruby/TestDigestRactor/TestSHA1Ractor.md | 12 - .../ruby/TestDigestRactor/TestSHA256Ractor.md | 12 - .../ruby/TestDigestRactor/TestSHA384Ractor.md | 12 - .../ruby/TestDigestRactor/TestSHA512Ractor.md | 12 - example/ruby/TestDir.md | 103 - example/ruby/TestDir_M17N.md | 61 - example/ruby/TestDup.md | 20 - example/ruby/TestDup/M001.md | 6 - example/ruby/TestDup/M002.md | 8 - example/ruby/TestDup/M003.md | 8 - example/ruby/TestE.md | 20 - example/ruby/TestE/UnknownError.md | 7 - example/ruby/TestEOF.md | 17 - example/ruby/TestEOF/Seek.md | 13 - example/ruby/TestERB.md | 34 - example/ruby/TestERB/MyError.md | 7 - example/ruby/TestERBCore.md | 78 - example/ruby/TestERBCore/Foo.md | 7 - example/ruby/TestERBCoreWOStrScan.md | 12 - example/ruby/TestERBEncoding.md | 20 - example/ruby/TestERBEncoding/M.md | 6 - example/ruby/TestEUC_JP.md | 14 - example/ruby/TestEmojiBreaks.md | 25 - example/ruby/TestEmojiBreaks/BreakFile.md | 24 - example/ruby/TestEmojiBreaks/BreakTest.md | 31 - example/ruby/TestEncoding.md | 37 - example/ruby/TestEncodingConverter.md | 180 - example/ruby/TestEnsureAndCallcc.md | 12 - example/ruby/TestEnumerable.md | 194 - example/ruby/TestEnumerable/Foo.md | 2072 ------ example/ruby/TestEnumerator.md | 158 - example/ruby/TestEnumeratorKw.md | 10 - example/ruby/TestEnv.md | 228 - example/ruby/TestErbCommand.md | 12 - example/ruby/TestErrInCallBack.md | 16 - example/ruby/TestEtc.md | 40 - example/ruby/TestEucKr.md | 24 - example/ruby/TestEucTw.md | 20 - example/ruby/TestEval.md | 103 - example/ruby/TestEval/Foo.md | 7 - example/ruby/TestException.md | 209 - example/ruby/TestExtLibs.md | 14 - example/ruby/TestFiber.md | 76 - example/ruby/TestFiberBacktrace.md | 14 - example/ruby/TestFiberCurrentRactor.md | 12 - example/ruby/TestFiberEnumerator.md | 12 - example/ruby/TestFiberIO.md | 30 - example/ruby/TestFiberIOBuffer.md | 24 - example/ruby/TestFiberMutex.md | 26 - example/ruby/TestFiberProcess.md | 16 - example/ruby/TestFiberQueue.md | 12 - example/ruby/TestFiberScheduler.md | 32 - example/ruby/TestFiberSchedulerAutoload.md | 6 - example/ruby/TestFiberSleep.md | 14 - example/ruby/TestFiberStorage.md | 28 - example/ruby/TestFiberThread.md | 20 - example/ruby/TestFiberTimeout.md | 12 - example/ruby/TestFiddle.md | 16 - example/ruby/TestFile.md | 118 - example/ruby/TestFile/NewlineConvTests.md | 92 - example/ruby/TestFileExhaustive.md | 354 -- example/ruby/TestFileUtils.md | 338 - example/ruby/TestFileUtils/Stream.md | 16 - example/ruby/TestFileUtilsClobber.md | 59 - example/ruby/TestFileUtilsDryRun.md | 49 - example/ruby/TestFileUtilsIncVisibility.md | 8 - example/ruby/TestFileUtilsNoWrite.md | 49 - example/ruby/TestFileUtilsVerbose.md | 49 - example/ruby/TestFind.md | 44 - example/ruby/TestFind/TestInclude.md | 12 - example/ruby/TestFixnum.md | 92 - example/ruby/TestFixnum/DummyNumeric.md | 10 - example/ruby/TestFlip.md | 18 - example/ruby/TestFloat.md | 137 - example/ruby/TestFloatExt.md | 7 - example/ruby/TestFnmatch.md | 41 - example/ruby/TestForTestHideSkip.md | 18 - example/ruby/TestForTestRedefinition.md | 10 - example/ruby/TestForTestTimeout.md | 7 - example/ruby/TestFormatter.md | 12 - example/ruby/TestFormatter/CustomFormatter.md | 10 - example/ruby/TestForwardable.md | 64 - example/ruby/TestForwardable/Foo.md | 56 - example/ruby/TestForwardable/Foo2.md | 52 - example/ruby/TestFrozen.md | 16 - example/ruby/TestFrozenError.md | 18 - example/ruby/TestFuncall.md | 22 - example/ruby/TestFuncall/Relay.md | 15 - example/ruby/TestGB18030.md | 24 - example/ruby/TestGBK.md | 20 - example/ruby/TestGCCompact.md | 50 - example/ruby/TestGCCompact/AutoCompact.md | 24 - .../CompactMethodsNotImplemented.md | 26 - .../CompactionSupportInspector.md | 11 - .../OmitUnlessCompactSupported.md | 15 - example/ruby/TestGc.md | 116 - example/ruby/TestGc/S.md | 12 - example/ruby/TestGem.md | 272 - example/ruby/TestGemAvailableSet.md | 24 - example/ruby/TestGemBundledCA.md | 25 - example/ruby/TestGemBundlerVersionFinder.md | 30 - example/ruby/TestGemCommand.md | 57 - example/ruby/TestGemCommandManager.md | 60 - example/ruby/TestGemCommandsBuildCommand.md | 64 - example/ruby/TestGemCommandsCertCommand.md | 82 - example/ruby/TestGemCommandsCheckCommand.md | 20 - example/ruby/TestGemCommandsCleanupCommand.md | 44 - .../ruby/TestGemCommandsContentsCommand.md | 42 - .../ruby/TestGemCommandsDependencyCommand.md | 30 - .../ruby/TestGemCommandsEnvironmentCommand.md | 30 - example/ruby/TestGemCommandsExecCommand.md | 70 - example/ruby/TestGemCommandsFetchCommand.md | 32 - example/ruby/TestGemCommandsHelpCommand.md | 28 - example/ruby/TestGemCommandsInfoCommand.md | 20 - example/ruby/TestGemCommandsInstallCommand.md | 140 - example/ruby/TestGemCommandsListCommand.md | 14 - example/ruby/TestGemCommandsLockCommand.md | 16 - example/ruby/TestGemCommandsMirrorCommand.md | 12 - example/ruby/TestGemCommandsOpenCommand.md | 20 - .../ruby/TestGemCommandsOutdatedCommand.md | 16 - example/ruby/TestGemCommandsOwnerCommand.md | 64 - .../ruby/TestGemCommandsPristineCommand.md | 56 - example/ruby/TestGemCommandsPushCommand.md | 68 - .../ruby/TestGemCommandsQueryCommandSetup.md | 9 - ...emCommandsQueryCommandWithInstalledGems.md | 67 - ...ommandsQueryCommandWithoutInstalledGems.md | 30 - example/ruby/TestGemCommandsRebuildCommand.md | 16 - example/ruby/TestGemCommandsSearchCommand.md | 12 - example/ruby/TestGemCommandsServerCommand.md | 12 - example/ruby/TestGemCommandsSetupCommand.md | 48 - example/ruby/TestGemCommandsSigninCommand.md | 43 - example/ruby/TestGemCommandsSignoutCommand.md | 15 - example/ruby/TestGemCommandsSourcesCommand.md | 52 - .../TestGemCommandsSpecificationCommand.md | 40 - example/ruby/TestGemCommandsStaleCommand.md | 12 - .../ruby/TestGemCommandsUninstallCommand.md | 60 - example/ruby/TestGemCommandsUnpackCommand.md | 34 - example/ruby/TestGemCommandsUpdateCommand.md | 98 - example/ruby/TestGemCommandsWhichCommand.md | 20 - example/ruby/TestGemCommandsYankCommand.md | 36 - example/ruby/TestGemConfig.md | 14 - example/ruby/TestGemConfigFile.md | 88 - example/ruby/TestGemConsoleUI.md | 10 - example/ruby/TestGemDependency.md | 74 - example/ruby/TestGemDependencyInstaller.md | 128 - example/ruby/TestGemDependencyList.md | 49 - .../ruby/TestGemDependencyResolutionError.md | 12 - example/ruby/TestGemDeprecate.md | 26 - example/ruby/TestGemDeprecate/OtherThing.md | 31 - example/ruby/TestGemDeprecate/Thing.md | 31 - example/ruby/TestGemDoctor.md | 22 - example/ruby/TestGemExit.md | 12 - example/ruby/TestGemExtBuilder.md | 40 - example/ruby/TestGemExtCargoBuilder.md | 22 - ...TestGemExtCargoBuilderLinkFlagConverter.md | 7 - example/ruby/TestGemExtCargoBuilderUnit.md | 20 - example/ruby/TestGemExtCmakeBuilder.md | 16 - example/ruby/TestGemExtConfigureBuilder.md | 16 - example/ruby/TestGemExtExtConfBuilder.md | 28 - example/ruby/TestGemExtRakeBuilder.md | 25 - example/ruby/TestGemGemRunner.md | 26 - example/ruby/TestGemGemcutterUtilities.md | 60 - .../SignInFetcher.md | 22 - .../TestGemImpossibleDependenciesError.md | 10 - example/ruby/TestGemInstallUpdateOptions.md | 48 - example/ruby/TestGemInstaller.md | 263 - example/ruby/TestGemKernel.md | 38 - example/ruby/TestGemLocalRemoteOptions.md | 30 - example/ruby/TestGemNameTuple.md | 16 - example/ruby/TestGemPackage.md | 125 - example/ruby/TestGemPackageOld.md | 24 - example/ruby/TestGemPackageTarHeader.md | 34 - example/ruby/TestGemPackageTarReader.md | 22 - example/ruby/TestGemPackageTarReaderEntry.md | 86 - example/ruby/TestGemPackageTarWriter.md | 52 - example/ruby/TestGemPackageTask.md | 18 - example/ruby/TestGemPathSupport.md | 28 - example/ruby/TestGemPlatform.md | 68 - example/ruby/TestGemProjectSanity.md | 16 - example/ruby/TestGemRDoc.md | 34 - example/ruby/TestGemRemoteFetchError.md | 14 - example/ruby/TestGemRemoteFetcher.md | 118 - .../TestGemRemoteFetcherLocalSSLServer.md | 58 - .../ruby/TestGemRemoteFetcherLocalServer.md | 72 - example/ruby/TestGemRemoteFetcherS3.md | 74 - example/ruby/TestGemRequest.md | 96 - example/ruby/TestGemRequest/Conn.md | 30 - example/ruby/TestGemRequestConnectionPool.md | 32 - .../TestGemRequestConnectionPool/FakeHttp.md | 14 - example/ruby/TestGemRequestSet.md | 66 - .../ruby/TestGemRequestSetGemDependencyAPI.md | 136 - example/ruby/TestGemRequestSetLockfile.md | 46 - .../ruby/TestGemRequestSetLockfileParser.md | 50 - .../TestGemRequestSetLockfileTokenizer.md | 32 - example/ruby/TestGemRequire.md | 92 - example/ruby/TestGemRequire/Latch.md | 16 - example/ruby/TestGemRequirement.md | 102 - example/ruby/TestGemRequirement/Exploit.md | 7 - example/ruby/TestGemResolver.md | 99 - example/ruby/TestGemResolverAPISet.md | 36 - .../ruby/TestGemResolverAPISpecification.md | 20 - .../ruby/TestGemResolverActivationRequest.md | 16 - example/ruby/TestGemResolverBestSet.md | 18 - example/ruby/TestGemResolverComposedSet.md | 14 - example/ruby/TestGemResolverConflict.md | 14 - .../ruby/TestGemResolverDependencyRequest.md | 22 - example/ruby/TestGemResolverGitSet.md | 32 - .../ruby/TestGemResolverGitSpecification.md | 21 - example/ruby/TestGemResolverIndexSet.md | 18 - .../ruby/TestGemResolverIndexSpecification.md | 18 - .../TestGemResolverInstalledSpecification.md | 16 - example/ruby/TestGemResolverInstallerSet.md | 52 - .../ruby/TestGemResolverLocalSpecification.md | 14 - example/ruby/TestGemResolverLockSet.md | 18 - .../ruby/TestGemResolverLockSpecification.md | 22 - .../ruby/TestGemResolverRequirementList.md | 12 - example/ruby/TestGemResolverSpecification.md | 14 - .../TestGemResolverSpecification/TestSpec.md | 21 - example/ruby/TestGemResolverVendorSet.md | 20 - .../TestGemResolverVendorSpecification.md | 24 - example/ruby/TestGemSafeMarshal.md | 66 - .../ruby/TestGemSafeMarshal/ArraySubclass.md | 7 - .../ruby/TestGemSafeMarshal/StringSubclass.md | 7 - .../ruby/TestGemSafeMarshal/UserMarshal.md | 12 - example/ruby/TestGemSafeYAML.md | 12 - example/ruby/TestGemSecurity.md | 46 - example/ruby/TestGemSecurityPolicy.md | 108 - example/ruby/TestGemSecuritySigner.md | 46 - example/ruby/TestGemSecurityTrustDir.md | 26 - example/ruby/TestGemSilentUI.md | 26 - example/ruby/TestGemSource.md | 54 - example/ruby/TestGemSourceFetchProblem.md | 14 - example/ruby/TestGemSourceGit.md | 54 - example/ruby/TestGemSourceInstalled.md | 12 - example/ruby/TestGemSourceList.md | 42 - example/ruby/TestGemSourceLocal.md | 34 - example/ruby/TestGemSourceLock.md | 28 - example/ruby/TestGemSourceSpecificFile.md | 26 - example/ruby/TestGemSourceSubpathProblem.md | 18 - example/ruby/TestGemSourceVendor.md | 12 - example/ruby/TestGemSpecFetcher.md | 54 - example/ruby/TestGemSpecification.md | 680 -- example/ruby/TestGemStreamUI.md | 60 - example/ruby/TestGemStreamUI/IsTty.md | 21 - example/ruby/TestGemText.md | 62 - example/ruby/TestGemUninstaller.md | 86 - .../TestGemUnsatisfiableDependencyError.md | 16 - example/ruby/TestGemUriFormatter.md | 14 - example/ruby/TestGemUtil.md | 20 - example/ruby/TestGemValidator.md | 14 - example/ruby/TestGemVersion.md | 92 - example/ruby/TestGemVersion/V.md | 7 - example/ruby/TestGemVersionOption.md | 32 - example/ruby/TestGraphemeBreaksFromFile.md | 22 - .../TestGraphemeBreaksFromFile/BreakTest.md | 25 - example/ruby/TestHash.md | 298 - example/ruby/TestHash/ObjWithHash.md | 23 - example/ruby/TestHash/TestSubHash.md | 10 - example/ruby/TestHash/TestSubHash/SubHash.md | 7 - example/ruby/TestHashOnly.md | 100 - example/ruby/TestHideSkip.md | 10 - example/ruby/TestHung.md | 12 - example/ruby/TestIO.md | 574 -- example/ruby/TestIO/Bug5237.md | 18 - example/ruby/TestIO/Feature.md | 15 - example/ruby/TestIO/Rot13IO.md | 18 - example/ruby/TestIOBuffer.md | 138 - example/ruby/TestIOConsoleInRactor.md | 10 - example/ruby/TestIONonblock.md | 14 - example/ruby/TestIOTimeout.md | 18 - example/ruby/TestIOWait.md | 60 - example/ruby/TestIOWaitInRactor.md | 10 - example/ruby/TestIOWaitUncommon.md | 26 - example/ruby/TestIO_Console.md | 25 - example/ruby/TestIO_M17N.md | 364 -- example/ruby/TestIRB.md | 6 - .../ruby/TestIRB/BacktraceFilteringTest.md | 14 - example/ruby/TestIRB/CDTest.md | 18 - example/ruby/TestIRB/ChwsTest.md | 12 - example/ruby/TestIRB/ColorPrinterTest.md | 14 - .../ColorPrinterTest/IRBTestColorPrinter.md | 13 - example/ruby/TestIRB/ColorTest.md | 24 - example/ruby/TestIRB/CommandTestCase.md | 14 - example/ruby/TestIRB/CompletionTest.md | 24 - .../CompletionTest/CommandCompletionTest.md | 10 - .../CompletionTest/ConstantCompletionTest.md | 10 - .../ConstantCompletionTest/Foo.md | 7 - .../CompletionTest/MethodCompletionTest.md | 22 - .../CompletionTest/RequireComepletionTest.md | 20 - .../CompletionTest/VariableCompletionTest.md | 12 - example/ruby/TestIRB/ConfigValidationTest.md | 22 - example/ruby/TestIRB/ContextTest.md | 64 - .../ContextWithTracerIntegrationTest.md | 18 - .../TestIRB/CustomCommandIntegrationTest.md | 20 - example/ruby/TestIRB/CwwsTest.md | 10 - .../ruby/TestIRB/DebuggerIntegrationTest.md | 64 - .../TestIRB/DeprecatedInputCompletorTest.md | 16 - example/ruby/TestIRB/DisableIRBTest.md | 10 - example/ruby/TestIRB/DisplayDocumentTest.md | 22 - example/ruby/TestIRB/EchoingTest.md | 12 - example/ruby/TestIRB/EditTest.md | 28 - example/ruby/TestIRB/EvalHistoryTest.md | 20 - example/ruby/TestIRB/ForceExitTest.md | 12 - example/ruby/TestIRB/FrozenObjectTest.md | 10 - example/ruby/TestIRB/HelpTest.md | 22 - .../ruby/TestIRB/HelperMethodInsallTest.md | 10 - .../TestIRB/HelperMethodIntegrationTest.md | 14 - example/ruby/TestIRB/HelperMethodTestCase.md | 14 - example/ruby/TestIRB/HistoryCmdTest.md | 16 - example/ruby/TestIRB/HistoryTest.md | 34 - .../TestInputMethodWithReadlineHistory.md | 20 - .../TestInputMethodWithRelineHistory.md | 20 - .../ruby/TestIRB/IRBHistoryIntegrationTest.md | 22 - example/ruby/TestIRB/InfoTest.md | 22 - example/ruby/TestIRB/InitIntegrationTest.md | 14 - example/ruby/TestIRB/InitTest.md | 40 - example/ruby/TestIRB/InputMethodTest.md | 12 - example/ruby/TestIRB/InputTest.md | 24 - example/ruby/TestIRB/IntegrationTestCase.md | 28 - .../ruby/TestIRB/IrbIOConfigurationTest.md | 12 - .../AutoIndentationTest.md | 64 - .../DynamicPromptTest.md | 28 - .../MockIO_AutoIndent.md | 18 - .../MockIO_DynamicPrompt.md | 18 - .../TestIRB/IrbIOConfigurationTest/Row.md | 28 - example/ruby/TestIRB/IrbLoadTest.md | 12 - example/ruby/TestIRB/IrbSourceTest.md | 12 - example/ruby/TestIRB/LocaleTestCase.md | 20 - example/ruby/TestIRB/LsTest.md | 24 - example/ruby/TestIRB/MeasureTest.md | 22 - example/ruby/TestIRB/MultiIRBTest.md | 16 - example/ruby/TestIRB/NestedBindingIrbTest.md | 10 - example/ruby/TestIRB/NestingParserTest.md | 36 - example/ruby/TestIRB/OptionTest.md | 10 - example/ruby/TestIRB/PopwsTest.md | 12 - example/ruby/TestIRB/PushwsTest.md | 16 - example/ruby/TestIRB/RaiseExceptionTest.md | 18 - example/ruby/TestIRB/RelineInputMethodTest.md | 18 - example/ruby/TestIRB/RubyLexTest.md | 40 - example/ruby/TestIRB/ShowDocTest.md | 12 - example/ruby/TestIRB/ShowSourceTest.md | 50 - example/ruby/TestIRB/TestCase.md | 22 - .../ruby/TestIRB/TestCase/TestInputMethod.md | 29 - example/ruby/TestIRB/TestHelperMethod.md | 6 - .../ruby/TestIRB/TestHelperMethod/ConfTest.md | 10 - .../TestIRB/TypeCompletorIntegrationTest.md | 10 - example/ruby/TestIRB/TypeCompletorTest.md | 28 - .../TestIRB/TypeCompletorTest/DummyContext.md | 13 - example/ruby/TestIRB/WhereamiTest.md | 12 - example/ruby/TestIRB/WorkSpaceTest.md | 18 - .../ruby/TestIRB/WorkspaceCommandTestCase.md | 10 - example/ruby/TestIRB/WorkspacesTest.md | 10 - example/ruby/TestISO8859.md | 38 - example/ruby/TestISeq.md | 168 - example/ruby/TestIfUnless.md | 10 - example/ruby/TestInsnsLeaf.md | 10 - example/ruby/TestInsnsLeaf/Id.md | 22 - example/ruby/TestInsnsLeaf/Namespace.md | 11 - example/ruby/TestInteger.md | 89 - example/ruby/TestInteger/CoercionToInt.md | 9 - example/ruby/TestInteger/CoercionToSelf.md | 9 - example/ruby/TestInteger/MimicInteger.md | 13 - example/ruby/TestIntegerComb.md | 93 - example/ruby/TestInvokeVerb.md | 16 - example/ruby/TestIseqLoad.md | 29 - example/ruby/TestIter.md | 6 - example/ruby/TestIter/IterBreak.md | 10 - example/ruby/TestIter/YieldBlock.md | 12 - example/ruby/TestIter/YieldBlock/YieldTest.md | 20 - example/ruby/TestIterator.md | 127 - example/ruby/TestIterator/C.md | 2074 ------ example/ruby/TestIterator/H.md | 12 - example/ruby/TestIterator/ITER_TEST1.md | 10 - example/ruby/TestIterator/ITER_TEST2.md | 326 - example/ruby/TestIterator/ITER_TEST3.md | 10 - example/ruby/TestIterator/ITER_TEST4.md | 326 - example/ruby/TestIterator/IterString.md | 10 - example/ruby/TestIterator/IterTest.md | 32 - example/ruby/TestKOI8.md | 12 - example/ruby/TestKeyError.md | 20 - example/ruby/TestKeywordArguments.md | 278 - .../ruby/TestKeywordArguments/AttrSetTest.md | 11 - .../TestKeywordArgumentsSymProcRefinements.md | 24 - .../C.md | 14 - example/ruby/TestLLDBInit.md | 18 - example/ruby/TestLambdaParameters.md | 77 - example/ruby/TestLastThread.md | 12 - example/ruby/TestLaunchable.md | 10 - example/ruby/TestLazyEnumerator.md | 138 - example/ruby/TestLazyEnumerator/Step.md | 2081 ------ example/ruby/TestLoadFailure.md | 12 - example/ruby/TestLogDevice.md | 68 - example/ruby/TestLogDevice/LogExcnRaiser.md | 14 - example/ruby/TestLogPeriod.md | 16 - example/ruby/TestLogger.md | 62 - example/ruby/TestLogger/CustomLogger.md | 10 - example/ruby/TestLogger/Log.md | 31 - example/ruby/TestLogger/MyError.md | 7 - example/ruby/TestLogger/MyMsg.md | 10 - example/ruby/TestLoggerSeverity.md | 18 - example/ruby/TestM17N.md | 319 - example/ruby/TestM17N/AESU.md | 17 - example/ruby/TestM17NComb.md | 231 - example/ruby/TestM17NComb/AESU.md | 17 - example/ruby/TestMarshal.md | 268 - example/ruby/TestMarshal/Bug12974.md | 10 - example/ruby/TestMarshal/Bug14314.md | 13 - example/ruby/TestMarshal/Bug15968.md | 19 - example/ruby/TestMarshal/Bug15968/Bar.md | 20 - example/ruby/TestMarshal/Bug7627.md | 23 - example/ruby/TestMarshal/Bug8276.md | 12 - example/ruby/TestMarshal/Bug9523.md | 16 - example/ruby/TestMarshal/C.md | 20 - example/ruby/TestMarshal/C2.md | 14 - example/ruby/TestMarshal/C4.md | 14 - example/ruby/TestMarshal/C5.md | 16 - example/ruby/TestMarshal/C6.md | 20 - example/ruby/TestMarshal/DumpTest.md | 12 - example/ruby/TestMarshal/FrozenData.md | 10 - example/ruby/TestMarshal/LoadData.md | 16 - example/ruby/TestMarshal/LoadTest.md | 14 - .../MethodMissingWithoutRespondTo.md | 20 - example/ruby/TestMarshal/TestClass.md | 7 - .../ruby/TestMarshal/TestForRespondToFalse.md | 12 - example/ruby/TestMarshal/TestMarshalFreeze.md | 130 - .../ruby/TestMarshal/TestMarshalFreezeProc.md | 124 - example/ruby/TestMarshal/TestModule.md | 6 - example/ruby/TestMath.md | 80 - example/ruby/TestMemoryView.md | 60 - example/ruby/TestMetaclass.md | 14 - example/ruby/TestMetaclass/Bar.md | 7 - example/ruby/TestMetaclass/Baz.md | 7 - example/ruby/TestMetaclass/Foo.md | 7 - example/ruby/TestMethod.md | 261 - example/ruby/TestMethod/Base.md | 10 - example/ruby/TestMethod/C.md | 10 - example/ruby/TestMethod/Derived.md | 10 - example/ruby/TestMethod/M.md | 11 - example/ruby/TestMethod/T.md | 24 - example/ruby/TestMethod/Visibility.md | 10 - example/ruby/TestMethodCache.md | 16 - example/ruby/TestMethodInlineCache.md | 14 - example/ruby/TestMiniTestGuard.md | 14 - example/ruby/TestMiniTestRunner.md | 15 - example/ruby/TestMiniTestRunner/Latch.md | 16 - example/ruby/TestMiniTestUnit.md | 36 - example/ruby/TestMiniTestUnitInherited.md | 12 - example/ruby/TestMiniTestUnitOrder.md | 17 - example/ruby/TestMiniTestUnitRecording.md | 26 - example/ruby/TestMiniTestUnitTestCase.md | 253 - example/ruby/TestMixedUnicodeEscape.md | 10 - example/ruby/TestMkmf.md | 22 - example/ruby/TestMkmf/Base.md | 21 - example/ruby/TestMkmf/Base/Capture.md | 26 - example/ruby/TestMkmfConfig.md | 18 - example/ruby/TestMkmfConfiguration.md | 14 - example/ruby/TestMkmfConvertible.md | 12 - example/ruby/TestMkmfEgrepCpp.md | 12 - example/ruby/TestMkmfFindExecutable.md | 20 - example/ruby/TestMkmfFlags.md | 16 - example/ruby/TestMkmfGlobal.md | 7 - example/ruby/TestMkmfHaveFramework.md | 18 - example/ruby/TestMkmfHaveFunc.md | 12 - example/ruby/TestMkmfHaveLibrary.md | 22 - example/ruby/TestMkmfHaveMacro.md | 16 - example/ruby/TestMkmfInstall.md | 10 - example/ruby/TestMkmfLibs.md | 30 - example/ruby/TestMkmfPkgConfig.md | 20 - example/ruby/TestMkmfSignedness.md | 12 - example/ruby/TestMkmfSizeof.md | 14 - example/ruby/TestMkmfTryConstant.md | 18 - example/ruby/TestModule.md | 432 -- example/ruby/TestModule/AClass.md | 12 - example/ruby/TestModule/AttrTest.md | 19 - example/ruby/TestModule/BClass.md | 10 - example/ruby/TestModule/Bug18185.md | 16 - example/ruby/TestModule/Bug18185/Foo.md | 16 - .../TestModule/Bug18185/InstanceMethods.md | 6 - example/ruby/TestModule/Bug9413.md | 7 - example/ruby/TestModule/C.md | 10 - example/ruby/TestModule/C0.md | 12 - example/ruby/TestModule/C1.md | 14 - example/ruby/TestModule/CClass.md | 9 - example/ruby/TestModule/CloneTestC1.md | 9 - example/ruby/TestModule/CloneTestC2.md | 9 - example/ruby/TestModule/CloneTestM0.md | 9 - example/ruby/TestModule/CloneTestM1.md | 6 - example/ruby/TestModule/CloneTestM2.md | 6 - example/ruby/TestModule/CloneTestM_simple.md | 8 - example/ruby/TestModule/M0.md | 9 - example/ruby/TestModule/M1.md | 9 - example/ruby/TestModule/M1/M2.md | 6 - example/ruby/TestModule/M2.md | 9 - example/ruby/TestModule/M4.md | 9 - example/ruby/TestModule/Mixin.md | 10 - example/ruby/TestModule/MyClass.md | 7 - .../ruby/TestModule/PrivateConstantReopen.md | 6 - example/ruby/TestModule/User.md | 13 - example/ruby/TestMonitor.md | 38 - .../TestMonitor/KeywordInitializeChild.md | 41 - .../TestMonitor/KeywordInitializeParent.md | 12 - example/ruby/TestMonitor/NewCondTest.md | 45 - example/ruby/TestMyDict.md | 50 - example/ruby/TestNIL2VT_EMPTY.md | 12 - example/ruby/TestNameError.md | 30 - example/ruby/TestNetHTTP.md | 48 - example/ruby/TestNetHTTPContinue.md | 46 - example/ruby/TestNetHTTPForceEncoding.md | 46 - example/ruby/TestNetHTTPKeepAlive.md | 52 - .../ruby/TestNetHTTPKeepAlive/MockSocket.md | 30 - example/ruby/TestNetHTTPLocalBind.md | 38 - example/ruby/TestNetHTTPPartialResponse.md | 36 - .../ruby/TestNetHTTPSIdentityVerifyFailure.md | 38 - example/ruby/TestNetHTTPSwitchingProtocols.md | 38 - example/ruby/TestNetHTTPUtils.md | 33 - example/ruby/TestNetHTTPUtils/Forbidden.md | 7 - example/ruby/TestNetHTTPUtils/HTTPServer.md | 26 - .../TestNetHTTPUtils/HTTPServer/Request.md | 38 - .../TestNetHTTPUtils/HTTPServer/Response.md | 36 - example/ruby/TestNetHTTP_v1_2.md | 120 - example/ruby/TestNetHTTP_v1_2_chunked.md | 120 - .../ruby/TestNetHTTP_version_1_1_methods.md | 53 - .../ruby/TestNetHTTP_version_1_2_methods.md | 45 - example/ruby/TestNoMethodError.md | 24 - example/ruby/TestNot.md | 12 - example/ruby/TestNum2int.md | 52 - example/ruby/TestNumeric.md | 66 - example/ruby/TestObjSpace.md | 138 - example/ruby/TestObjSpace/NotTooComplex.md | 7 - example/ruby/TestObjSpace/TooComplex.md | 7 - example/ruby/TestObjSpaceRactor.md | 10 - example/ruby/TestObject.md | 142 - example/ruby/TestObject/InstanceExec.md | 7 - example/ruby/TestObject/MyInteger.md | 20 - example/ruby/TestObjectSpace.md | 38 - example/ruby/TestOpen3.md | 74 - example/ruby/TestOpenURI.md | 99 - example/ruby/TestOpenURIFtp.md | 14 - example/ruby/TestOpenURIProxy.md | 30 - example/ruby/TestOpenURISSL.md | 36 - example/ruby/TestOpenURIUtils.md | 13 - .../ProxyAuthenticationRequired.md | 7 - example/ruby/TestOpenURIUtils/Unauthorized.md | 7 - example/ruby/TestOptionParser.md | 30 - example/ruby/TestOptionParser/DummyOutput.md | 7 - example/ruby/TestOptionParser/WithPattern.md | 10 - example/ruby/TestOptionParserAcceptable.md | 24 - example/ruby/TestOptionParserAutoConf.md | 24 - .../TestOptionParserAutoConf/DummyOutput.md | 7 - .../ruby/TestOptionParserBashCompletion.md | 26 - example/ruby/TestOptionParserCClass.md | 12 - example/ruby/TestOptionParserDidYouMean.md | 18 - example/ruby/TestOptionParserGetopts.md | 18 - example/ruby/TestOptionParserKwArg.md | 12 - .../ruby/TestOptionParserKwArg/DummyOutput.md | 7 - example/ruby/TestOptionParserKwArg/K.md | 12 - example/ruby/TestOptionParserLoad.md | 40 - example/ruby/TestOptionParserNoArg.md | 19 - example/ruby/TestOptionParserNoArg/Def1.md | 22 - example/ruby/TestOptionParserNoArg/Def2.md | 22 - example/ruby/TestOptionParserOptArg.md | 22 - example/ruby/TestOptionParserPlaceArg.md | 24 - example/ruby/TestOptionParserReqArg.md | 19 - example/ruby/TestOptionParserReqArg/Def1.md | 22 - example/ruby/TestOptionParserReqArg/Def2.md | 22 - example/ruby/TestOptionParserReqArg/Def3.md | 22 - example/ruby/TestOptionParserReqArg/Def4.md | 22 - example/ruby/TestOptionParserSummaryTest.md | 23 - example/ruby/TestOptionParserZshCompletion.md | 12 - example/ruby/TestPTY.md | 38 - example/ruby/TestPack.md | 120 - example/ruby/TestParallel.md | 6 - example/ruby/TestParallel/TestParallel.md | 28 - .../ruby/TestParallel/TestParallelWorker.md | 24 - example/ruby/TestParse.md | 229 - example/ruby/TestPath.md | 20 - example/ruby/TestPathname.md | 348 -- .../ruby/TestPathname/AnotherStringLike.md | 17 - example/ruby/TestPathnameRactor.md | 12 - example/ruby/TestPipe.md | 24 - example/ruby/TestPipe/WithConversion.md | 10 - example/ruby/TestPopenDeadlock.md | 7 - example/ruby/TestPostponed_job.md | 20 - example/ruby/TestProc.md | 327 - example/ruby/TestProcKeywords.md | 14 - example/ruby/TestProcess.md | 371 -- example/ruby/TestProfileFrames.md | 18 - example/ruby/TestProtocol.md | 35 - .../ruby/TestProtocol/FakeReadPartialIO.md | 14 - example/ruby/TestPsych.md | 132 - example/ruby/TestPsychRactor.md | 16 - example/ruby/TestRDocAlias.md | 10 - example/ruby/TestRDocAnyMethod.md | 90 - example/ruby/TestRDocAttr.md | 36 - example/ruby/TestRDocClassModule.md | 119 - .../TestRDocClassModuleMixins.md | 14 - example/ruby/TestRDocCodeObject.md | 80 - example/ruby/TestRDocComment.md | 86 - example/ruby/TestRDocConstant.md | 28 - example/ruby/TestRDocContext.md | 168 - example/ruby/TestRDocContextSection.md | 32 - example/ruby/TestRDocCrossReference.md | 42 - example/ruby/TestRDocEncoding.md | 38 - example/ruby/TestRDocExtend.md | 14 - example/ruby/TestRDocGeneratorJsonIndex.md | 36 - example/ruby/TestRDocGeneratorMarkup.md | 84 - example/ruby/TestRDocGeneratorPOT.md | 14 - example/ruby/TestRDocGeneratorPOTPO.md | 14 - example/ruby/TestRDocGeneratorPOTPOEntry.md | 36 - example/ruby/TestRDocGeneratorRI.md | 16 - example/ruby/TestRDocI18nLocale.md | 22 - example/ruby/TestRDocI18nText.md | 16 - example/ruby/TestRDocInclude.md | 16 - example/ruby/TestRDocMarkdown.md | 184 - example/ruby/TestRDocMarkdownTest.md | 54 - example/ruby/TestRDocMarkup.md | 16 - .../ruby/TestRDocMarkupAttributeManager.md | 87 - example/ruby/TestRDocMarkupAttributes.md | 16 - example/ruby/TestRDocMarkupDocument.md | 46 - example/ruby/TestRDocMarkupFormatter.md | 37 - .../ruby/TestRDocMarkupFormatter/ToTest.md | 22 - example/ruby/TestRDocMarkupHardBreak.md | 14 - example/ruby/TestRDocMarkupHeading.md | 16 - example/ruby/TestRDocMarkupInclude.md | 12 - .../ruby/TestRDocMarkupIndentedParagraph.md | 20 - example/ruby/TestRDocMarkupParagraph.md | 14 - example/ruby/TestRDocMarkupParser.md | 213 - example/ruby/TestRDocMarkupRaw.md | 14 - example/ruby/TestRDocMarkupToHtmlSnippet.md | 166 - .../ruby/TestRDocMarkupToJoinedParagraph.md | 14 - example/ruby/TestRDocMarkupToLabel.md | 29 - .../ruby/TestRDocMarkupToTableOfContents.md | 34 - example/ruby/TestRDocMarkupToTtOnly.md | 126 - example/ruby/TestRDocMarkupVerbatim.md | 12 - example/ruby/TestRDocMethodAttr.md | 32 - example/ruby/TestRDocNormalClass.md | 18 - example/ruby/TestRDocNormalModule.md | 18 - example/ruby/TestRDocOptions.md | 160 - example/ruby/TestRDocOptions/DummyCoder.md | 10 - example/ruby/TestRDocParserC.md | 226 - example/ruby/TestRDocParserChangeLog.md | 48 - example/ruby/TestRDocParserMarkdown.md | 20 - example/ruby/TestRDocParserPrismRuby.md | 188 - example/ruby/TestRDocParserRd.md | 20 - example/ruby/TestRDocParserRuby.md | 466 -- ...estRDocParserRubyWithPrismRubyTestCases.md | 189 - example/ruby/TestRDocParserSimple.md | 49 - example/ruby/TestRDocRDoc.md | 80 - example/ruby/TestRDocRIPaths.md | 34 - example/ruby/TestRDocRd.md | 14 - example/ruby/TestRDocRdBlockParser.md | 94 - example/ruby/TestRDocRdInline.md | 26 - example/ruby/TestRDocRdInlineParser.md | 82 - example/ruby/TestRDocRequire.md | 12 - example/ruby/TestRDocRubyGemsHook.md | 54 - example/ruby/TestRDocServlet.md | 94 - example/ruby/TestRDocSingleClass.md | 14 - example/ruby/TestRDocStats.md | 80 - example/ruby/TestRDocStore.md | 141 - example/ruby/TestRDocTask.md | 46 - example/ruby/TestRDocText.md | 148 - example/ruby/TestRDocTokenStream.md | 24 - example/ruby/TestRDocTomDoc.md | 68 - example/ruby/TestRDocTopLevel.md | 66 - example/ruby/TestRand.md | 98 - example/ruby/TestRandomExt.md | 9 - example/ruby/TestRandomExt/TestLoop.md | 18 - example/ruby/TestRandomExt/TestVersionMax.md | 14 - example/ruby/TestRandomExt/TestVersionZero.md | 14 - example/ruby/TestRange.md | 142 - example/ruby/TestRange/CyclicRange.md | 10 - example/ruby/TestRange/DuckRange.md | 23 - example/ruby/TestRational.md | 10 - example/ruby/TestRational/TestGCD.md | 14 - example/ruby/TestRbConfig.md | 18 - example/ruby/TestReadPartial.md | 20 - example/ruby/TestRecursion.md | 16 - example/ruby/TestRedefinition.md | 10 - example/ruby/TestRefinement.md | 260 - .../ruby/TestRefinement/AliasInSubclass.md | 6 - .../ruby/TestRefinement/AliasInSubclass/C.md | 10 - .../ruby/TestRefinement/AliasInSubclass/D.md | 7 - .../ruby/TestRefinement/AliasInSubclass/M.md | 6 - example/ruby/TestRefinement/ArrayEachExt.md | 6 - example/ruby/TestRefinement/Bar.md | 7 - example/ruby/TestRefinement/BarExt.md | 6 - example/ruby/TestRefinement/Bug13446.md | 6 - .../TestRefinement/Bug13446/Enumerable.md | 9 - .../Bug13446/GenericEnumerable.md | 12 - example/ruby/TestRefinement/Bug16242.md | 7 - example/ruby/TestRefinement/Bug16242/M.md | 11 - .../ruby/TestRefinement/Bug16242/OtherM.md | 6 - example/ruby/TestRefinement/Bug16242/X.md | 12 - example/ruby/TestRefinement/Bug17822.md | 7 - .../ruby/TestRefinement/Bug17822/Client.md | 8 - example/ruby/TestRefinement/Bug17822/Ext.md | 6 - example/ruby/TestRefinement/Bug18180.md | 10 - example/ruby/TestRefinement/Bug18180/M.md | 6 - example/ruby/TestRefinement/Foo.md | 18 - example/ruby/TestRefinement/FooBarExt.md | 8 - .../ruby/TestRefinement/FooBarExtClient.md | 8 - example/ruby/TestRefinement/FooExt.md | 6 - example/ruby/TestRefinement/FooExt2.md | 6 - example/ruby/TestRefinement/FooExtClient.md | 7 - example/ruby/TestRefinement/FooExtClient2.md | 7 - example/ruby/TestRefinement/FooFoo2Ext.md | 8 - .../ruby/TestRefinement/FooFoo2ExtClient.md | 9 - example/ruby/TestRefinement/FooSub.md | 12 - example/ruby/TestRefinement/Inspect.md | 6 - example/ruby/TestRefinement/Inspect/M.md | 6 - .../InstanceMethodIntegerPowEx.md | 6 - example/ruby/TestRefinement/IntegerFooExt.md | 6 - example/ruby/TestRefinement/IntegerPlusExt.md | 6 - .../ruby/TestRefinement/IntegerSlashExt.md | 6 - .../ruby/TestRefinement/MethodIntegerPowEx.md | 6 - example/ruby/TestRefinement/MethodMissing.md | 8 - .../ruby/TestRefinement/MethodMissing/Bar.md | 6 - .../ruby/TestRefinement/MethodMissing/Foo.md | 7 - example/ruby/TestRefinement/MixedUsing1.md | 9 - example/ruby/TestRefinement/MixedUsing1/C.md | 10 - example/ruby/TestRefinement/MixedUsing1/R1.md | 6 - example/ruby/TestRefinement/MixedUsing2.md | 9 - example/ruby/TestRefinement/MixedUsing2/C.md | 10 - example/ruby/TestRefinement/MixedUsing2/R1.md | 6 - example/ruby/TestRefinement/MixedUsing2/R2.md | 6 - .../MixinDefiningPrivateMethod.md | 6 - example/ruby/TestRefinement/ModuleUsing.md | 14 - .../NotIncludeSuperclassMethod.md | 6 - .../NotIncludeSuperclassMethod/Bar.md | 6 - .../NotIncludeSuperclassMethod/X.md | 10 - .../NotIncludeSuperclassMethod/Y.md | 7 - .../ParentDefiningPrivateMethod.md | 7 - .../TestRefinement/RedefineRefinedMethod.md | 6 - .../TestRefinement/RedefineRefinedMethod/C.md | 10 - .../TestRefinement/RedefineRefinedMethod/M.md | 6 - example/ruby/TestRefinement/RefineInUsing.md | 9 - .../ruby/TestRefinement/RefineInUsing/M1.md | 6 - .../ruby/TestRefinement/RefineInUsing/M2.md | 6 - example/ruby/TestRefinement/RefineModule.md | 10 - example/ruby/TestRefinement/RefineModule/C.md | 16 - example/ruby/TestRefinement/RefineModule/M.md | 13 - .../ruby/TestRefinement/RefineModule/M2.md | 6 - .../TestRefinement/RefinePrependedClass.md | 6 - .../TestRefinement/RefinePrependedClass/C.md | 12 - .../TestRefinement/RefinePrependedClass/M1.md | 9 - .../TestRefinement/RefinePrependedClass/M2.md | 6 - .../ruby/TestRefinement/RefineSameClass.md | 6 - example/ruby/TestRefinement/RefineScoping.md | 8 - example/ruby/TestRefinement/RespondTo.md | 6 - example/ruby/TestRefinement/RespondTo/M.md | 6 - example/ruby/TestRefinement/RespondTo/Sub.md | 7 - .../ruby/TestRefinement/RespondTo/Super.md | 10 - example/ruby/TestRefinement/Sandbox.md | 6 - .../TestRefinement/SomeChildClassToRefine.md | 9 - example/ruby/TestRefinement/StringCmpExt.md | 6 - example/ruby/TestRefinement/StringExt.md | 6 - .../TestRefinement/StringRecursiveLength.md | 6 - example/ruby/TestRefinement/SuperInBlock.md | 6 - example/ruby/TestRefinement/SuperInBlock/C.md | 10 - example/ruby/TestRefinement/SuperInBlock/R.md | 6 - example/ruby/TestRefinement/SuperToModule.md | 6 - .../TestRefinement/SuperToModule/Child.md | 9 - .../TestRefinement/SuperToModule/FooBar.md | 6 - .../TestRefinement/SuperToModule/Parent.md | 7 - example/ruby/TestRefinement/TestImport.md | 6 - example/ruby/TestRefinement/TestImport/A.md | 10 - example/ruby/TestRefinement/TestImport/B.md | 9 - example/ruby/TestRefinement/TestImport/C.md | 6 - .../ruby/TestRefinement/TestImport/UsingC.md | 8 - example/ruby/TestRefinement/ToJSON.md | 6 - example/ruby/TestRefinement/ToProc.md | 8 - .../TestRefinement/ToProc/MethodMissing.md | 12 - example/ruby/TestRefinement/ToProc/NonProc.md | 10 - .../TestRefinement/ToProc/PrivateToProc.md | 10 - .../TestRefinement/ToProc/ReturnNoProc.md | 10 - .../ruby/TestRefinement/ToProc/ReturnProc.md | 10 - .../ToProc/ToProcAndMethodMissing.md | 12 - .../ToProc/ToProcAndRefinements.md | 12 - example/ruby/TestRefinement/ToString.md | 10 - example/ruby/TestRefinement/ToSymbol.md | 14 - example/ruby/TestRefinement/UsingClass.md | 7 - .../ruby/TestRefinement/VisibleRefinements.md | 6 - .../TestRefinement/VisibleRefinements/Bar.md | 6 - .../VisibleRefinements/Combined.md | 6 - .../TestRefinement/VisibleRefinements/Foo.md | 6 - .../TestRefinement/VisibleRefinements/RefA.md | 6 - .../TestRefinement/VisibleRefinements/RefB.md | 6 - .../TestRefinement/VisibleRefinements/RefC.md | 6 - example/ruby/TestRegexp.md | 344 - example/ruby/TestRequire.md | 120 - example/ruby/TestRequireLib.md | 7 - example/ruby/TestResolvAddr.md | 18 - example/ruby/TestResolvDNS.md | 62 - example/ruby/TestResolvMDNS.md | 10 - example/ruby/TestResolvResource.md | 18 - example/ruby/TestResolvResourceCAA.md | 16 - example/ruby/TestResolvSvcbHttps.md | 37 - example/ruby/TestRipper.md | 6 - example/ruby/TestRipper/DummyParser.md | 96 - example/ruby/TestRipper/Filter.md | 24 - example/ruby/TestRipper/Filter/Filter.md | 10 - example/ruby/TestRipper/Generic.md | 10 - example/ruby/TestRipper/Lexer.md | 66 - example/ruby/TestRipper/Node.md | 23 - example/ruby/TestRipper/Node/Sym.md | 14 - example/ruby/TestRipper/NodeList.md | 24 - example/ruby/TestRipper/ParserEvents.md | 372 -- example/ruby/TestRipper/Ripper.md | 47 - example/ruby/TestRipper/Ripper/TestInput.md | 12 - .../ruby/TestRipper/Ripper/TestInput/Input.md | 16 - example/ruby/TestRipper/ScannerEvents.md | 143 - example/ruby/TestRipper/Sexp.md | 42 - example/ruby/TestRubyKaigi2023_F09FA5A2.md | 16 - example/ruby/TestRubyLiteral.md | 68 - example/ruby/TestRubyOptimization.md | 214 - example/ruby/TestRubyOptimization/Bug10557.md | 12 - example/ruby/TestRubyOptimization/MyObj.md | 10 - .../ruby/TestRubyOptimization/Objtostring.md | 7 - example/ruby/TestRubyOptions.md | 161 - example/ruby/TestRubyOptions/SEGVTest.md | 6 - example/ruby/TestRubyPrimitive.md | 60 - example/ruby/TestRubyPrimitive/A10.md | 11 - example/ruby/TestRubyPrimitive/A2.md | 7 - example/ruby/TestRubyPrimitive/A2/B2.md | 7 - example/ruby/TestRubyPrimitive/A2/B2/C2.md | 7 - example/ruby/TestRubyPrimitive/A3.md | 7 - example/ruby/TestRubyPrimitive/A3/B3.md | 7 - example/ruby/TestRubyPrimitive/A4.md | 7 - example/ruby/TestRubyPrimitive/A5.md | 7 - example/ruby/TestRubyPrimitive/A6.md | 9 - example/ruby/TestRubyPrimitive/B6.md | 7 - example/ruby/TestRubyPrimitive/C6.md | 7 - example/ruby/TestRubyPrimitive/MyArr.md | 10 - example/ruby/TestRubyPrimitive/MyNum.md | 10 - example/ruby/TestRubyPrimitive/MyNum2.md | 10 - example/ruby/TestRubyPrimitive/MyObj.md | 12 - example/ruby/TestRubyPrimitive/MyObj2.md | 10 - example/ruby/TestRubyVM.md | 16 - example/ruby/TestRubyYield.md | 46 - example/ruby/TestRubyYieldGen.md | 40 - example/ruby/TestSH.md | 56 - example/ruby/TestScanArgs.md | 66 - example/ruby/TestSecureRandom.md | 29 - example/ruby/TestServer.md | 12 - example/ruby/TestSetTraceFunc.md | 277 - .../ruby/TestSetTraceFunc/AliasedCMethod.md | 12 - .../TestSetTraceFunc/AliasedRubyMethod.md | 10 - example/ruby/TestSetTraceFunc/BAR_ERROR.md | 7 - example/ruby/TestSetTraceFunc/Bug10724.md | 12 - example/ruby/TestSetTraceFunc/C11492.md | 7 - example/ruby/TestSetTraceFunc/C9759.md | 7 - example/ruby/TestSetTraceFunc/FOO_ERROR.md | 7 - .../ruby/TestSetTraceFunc/XYZZYException.md | 7 - example/ruby/TestShapes.md | 147 - example/ruby/TestShapes/Example.md | 12 - example/ruby/TestShapes/IVOrder.md | 12 - example/ruby/TestShapes/OrderedAlloc.md | 10 - example/ruby/TestShapes/RemoveAndAdd.md | 14 - example/ruby/TestShapes/ShapeOrder.md | 16 - example/ruby/TestShapes/TestObject.md | 7 - example/ruby/TestShapes/TooComplex.md | 25 - example/ruby/TestShellwords.md | 32 - example/ruby/TestShiftJIS.md | 14 - example/ruby/TestSignal.md | 48 - example/ruby/TestSingleton.md | 34 - example/ruby/TestSingleton/SingletonTest.md | 23 - example/ruby/TestSleep.md | 10 - example/ruby/TestSlowTimeout.md | 9 - example/ruby/TestSlowV0.md | 12 - example/ruby/TestSlowV1.md | 12 - example/ruby/TestSocket.md | 114 - example/ruby/TestSocketAddrinfo.md | 106 - example/ruby/TestSocketAncData.md | 16 - example/ruby/TestSocketNonblock.md | 69 - example/ruby/TestSocketOption.md | 22 - example/ruby/TestSocket_BasicSocket.md | 30 - example/ruby/TestSocket_TCPSocket.md | 48 - example/ruby/TestSocket_UDPSocket.md | 26 - example/ruby/TestSocket_UNIXSocket.md | 98 - example/ruby/TestSprintf.md | 74 - ...123456789012345678901234567890123456789.md | 7 - example/ruby/TestSprintfComb.md | 22 - example/ruby/TestStack.md | 27 - example/ruby/TestString.md | 478 -- example/ruby/TestString/Bug9581.md | 10 - example/ruby/TestString/S2.md | 7 - example/ruby/TestString/StringLike.md | 14 - example/ruby/TestString/StringWithIVSet.md | 10 - example/ruby/TestString2.md | 12 - example/ruby/TestStringIO.md | 194 - example/ruby/TestStringIO/C.md | 20 - example/ruby/TestStringIOInRactor.md | 12 - example/ruby/TestStringMemory.md | 16 - example/ruby/TestStringScanner.md | 156 - example/ruby/TestStringScannerFixedAnchor.md | 159 - example/ruby/TestStringScannerRactor.md | 12 - example/ruby/TestStringchar.md | 16 - example/ruby/TestStruct.md | 110 - example/ruby/TestStruct/SubStruct.md | 117 - example/ruby/TestStruct/TopStruct.md | 117 - example/ruby/TestStubSpecification.md | 54 - example/ruby/TestSuper.md | 108 - example/ruby/TestSuper/A.md | 12 - example/ruby/TestSuper/Array1.md | 10 - example/ruby/TestSuper/Array2.md | 10 - example/ruby/TestSuper/Array3.md | 10 - example/ruby/TestSuper/Array4.md | 10 - example/ruby/TestSuper/Base.md | 20 - example/ruby/TestSuper/Double1.md | 10 - example/ruby/TestSuper/Double2.md | 10 - example/ruby/TestSuper/Double3.md | 10 - example/ruby/TestSuper/DoubleInclude.md | 6 - example/ruby/TestSuper/DoubleInclude/A.md | 7 - example/ruby/TestSuper/DoubleInclude/B.md | 7 - example/ruby/TestSuper/DoubleInclude/Base.md | 10 - .../ruby/TestSuper/DoubleInclude/Override.md | 9 - example/ruby/TestSuper/DoubleInclude2.md | 6 - example/ruby/TestSuper/DoubleInclude2/A.md | 10 - example/ruby/TestSuper/DoubleInclude2/B.md | 10 - example/ruby/TestSuper/DoubleInclude2/Base.md | 10 - .../ruby/TestSuper/DoubleInclude2/Override.md | 9 - example/ruby/TestSuper/Forward.md | 10 - example/ruby/TestSuper/Indexed.md | 10 - example/ruby/TestSuper/Keyword1.md | 10 - example/ruby/TestSuper/Keyword2.md | 10 - example/ruby/TestSuper/Optional1.md | 10 - example/ruby/TestSuper/Optional2.md | 10 - example/ruby/TestSuper/Optional3.md | 10 - example/ruby/TestSuper/Optional4.md | 10 - example/ruby/TestSuper/Optional5.md | 10 - example/ruby/TestSuper/Single1.md | 10 - example/ruby/TestSuper/Single2.md | 10 - example/ruby/TestSuper/SubSeq.md | 14 - ...tFor_super_with_modified_rest_parameter.md | 10 - ...super_with_modified_rest_parameter_base.md | 10 - example/ruby/TestSuper/X.md | 10 - example/ruby/TestSuper/Y.md | 7 - example/ruby/TestSymbol.md | 155 - .../TestToPRocArgWithRefinements.md | 7 - example/ruby/TestSyntax.md | 332 - example/ruby/TestSyntax/KW2.md | 10 - example/ruby/TestSystem.md | 24 - example/ruby/TestTRICK2013.md | 20 - example/ruby/TestTRICK2015.md | 18 - example/ruby/TestTRICK2018.md | 18 - example/ruby/TestTRICK2022.md | 14 - example/ruby/TestTempfile.md | 108 - example/ruby/TestTempfile/M.md | 6 - example/ruby/TestTestUnitSorting.md | 20 - example/ruby/TestTestUnitSorting/Item.md | 13 - example/ruby/TestThread.md | 200 - example/ruby/TestThread/Thread.md | 9 - example/ruby/TestThreadConditionVariable.md | 36 - example/ruby/TestThreadFdClose.md | 10 - example/ruby/TestThreadGroup.md | 14 - example/ruby/TestThreadInstrumentation.md | 41 - example/ruby/TestThreadLockNativeThread.md | 12 - example/ruby/TestThreadQueue.md | 101 - example/ruby/TestTiemout.md | 10 - example/ruby/TestTime.md | 204 - example/ruby/TestTimeExtension.md | 82 - example/ruby/TestTimeExtension/MyDate.md | 22 - example/ruby/TestTimeTZ.md | 72 - example/ruby/TestTimeTZ/DummyTZ.md | 44 - example/ruby/TestTimeTZ/DummyTZ/TIME_CLASS.md | 9 - example/ruby/TestTimeTZ/TZ.md | 32 - example/ruby/TestTimeTZ/Util.md | 19 - example/ruby/TestTimeTZ/WithTZ.md | 37 - example/ruby/TestTimeout.md | 69 - example/ruby/TestTimeout/MyNewErrorInner.md | 7 - example/ruby/TestTimeout/MyNewErrorOuter.md | 7 - example/ruby/TestTmpdir.md | 30 - example/ruby/TestTrace.md | 16 - example/ruby/TestTracepointObj.md | 20 - example/ruby/TestTranscode.md | 201 - example/ruby/TestUTF16.md | 89 - example/ruby/TestUTF32.md | 34 - example/ruby/TestUbfAsyncSafe.md | 10 - example/ruby/TestUndef.md | 14 - example/ruby/TestUndef/Undef0.md | 10 - example/ruby/TestUndef/Undef1.md | 10 - example/ruby/TestUndef/Undef2.md | 7 - example/ruby/TestUnicodeEscape.md | 25 - example/ruby/TestUnicodeNormalize.md | 29 - example/ruby/TestUpdateSuggestion.md | 38 - example/ruby/TestUri.md | 24 - example/ruby/TestVM.md | 12 - example/ruby/TestVMDump.md | 16 - example/ruby/TestVariable.md | 56 - example/ruby/TestVariable/ExIvar.md | 14 - example/ruby/TestVariable/Gods.md | 14 - ...ludeRefinedModuleClassVariableNoWarning.md | 12 - .../Mod.md | 6 - .../Mod2.md | 6 - example/ruby/TestVariable/Olympians.md | 9 - example/ruby/TestVariable/Titans.md | 14 - example/ruby/TestWIN32OLE_EVENT.md | 12 - example/ruby/TestWIN32OLE_EVENT_ADO.md | 54 - example/ruby/TestWIN32OLE_EVENT_ADO/ADO.md | 6 - .../ruby/TestWIN32OLE_EVENT_ADO/Handler1.md | 31 - .../ruby/TestWIN32OLE_EVENT_ADO/Handler2.md | 18 - example/ruby/TestWIN32OLE_EVENT_SWbemSink.md | 26 - .../ruby/TestWIN32OLE_FOR_PROPERTYPUTREF.md | 14 - example/ruby/TestWIN32OLE_METHOD.md | 52 - example/ruby/TestWIN32OLE_METHOD_EVENT.md | 20 - example/ruby/TestWIN32OLE_PARAM.md | 40 - example/ruby/TestWIN32OLE_PARAM_EVENT.md | 20 - example/ruby/TestWIN32OLE_PROPERTYPUTREF.md | 14 - example/ruby/TestWIN32OLE_RECORD.md | 7 - .../ruby/TestWIN32OLE_RECORD_BY_RBCOMTEST.md | 44 - example/ruby/TestWIN32OLE_THREAD.md | 17 - example/ruby/TestWIN32OLE_TYPE.md | 58 - example/ruby/TestWIN32OLE_TYPELIB.md | 39 - example/ruby/TestWIN32OLE_TYPE_EVENT.md | 20 - example/ruby/TestWIN32OLE_VARIABLE.md | 32 - example/ruby/TestWIN32OLE_VARIANT.md | 117 - example/ruby/TestWIN32OLE_VARIANT_OUTARG.md | 14 - .../ruby/TestWIN32OLE_VARIANT_OUTARG/ADO.md | 6 - example/ruby/TestWIN32OLE_WITH_WORD.md | 18 - example/ruby/TestWait.md | 14 - example/ruby/TestWarning.md | 10 - example/ruby/TestWeakKeyMap.md | 38 - example/ruby/TestWeakMap.md | 46 - example/ruby/TestWeakRef.md | 20 - example/ruby/TestWhileuntil.md | 14 - example/ruby/TestWin32OLE.md | 126 - example/ruby/TestWin32OLE_VARIANT_MODULE.md | 12 - example/ruby/TestWin32Registry.md | 57 - example/ruby/TestWindows1251.md | 10 - example/ruby/TestWindows1252.md | 12 - example/ruby/TestYAMLDBM.md | 22 - example/ruby/TestYJIT.md | 279 - example/ruby/TestYJITExitLocations.md | 14 - example/ruby/TestZlib.md | 36 - example/ruby/TestZlibDeflate.md | 44 - example/ruby/TestZlibGzipFile.md | 38 - example/ruby/TestZlibGzipReader.md | 58 - example/ruby/TestZlibGzipWriter.md | 24 - example/ruby/TestZlibInflate.md | 44 - example/ruby/Test_ArithSeq.md | 16 - example/ruby/Test_Array.md | 7 - example/ruby/Test_Array/TestResize.md | 10 - example/ruby/Test_BUG_14834.md | 10 - example/ruby/Test_BUG_3571.md | 10 - example/ruby/Test_BUG_5832.md | 10 - example/ruby/Test_Class.md | 7 - example/ruby/Test_Class/Test_Class2Name.md | 14 - example/ruby/Test_DotDot.md | 10 - example/ruby/Test_EConvAppend.md | 12 - example/ruby/Test_FileStat.md | 12 - example/ruby/Test_Hash.md | 7 - example/ruby/Test_Hash/TestDelete.md | 10 - example/ruby/Test_Integer.md | 12 - example/ruby/Test_JISX0208_Char.md | 20 - example/ruby/Test_Load_Protect.md | 10 - example/ruby/Test_Load_ResolveSymbol.md | 10 - example/ruby/Test_Load_stringify_symbols.md | 14 - example/ruby/Test_Method.md | 7 - example/ruby/Test_Method/TestArity.md | 12 - example/ruby/Test_Method/TestArity/A.md | 18 - example/ruby/Test_Method/TestArity/B.md | 7 - example/ruby/Test_MyInteger.md | 12 - example/ruby/Test_NotImplement.md | 20 - example/ruby/Test_PathToClass.md | 12 - example/ruby/Test_Proc.md | 7 - example/ruby/Test_Proc/TestBMethod.md | 14 - example/ruby/Test_Proc/TestBMethod/Base.md | 10 - example/ruby/Test_Proc/TestBMethod/Bound.md | 7 - example/ruby/Test_RbInternedStr.md | 10 - example/ruby/Test_RbStrDup.md | 12 - example/ruby/Test_SPrintf.md | 27 - example/ruby/Test_StForeachUnpack.md | 12 - example/ruby/Test_StrEncAssociate.md | 10 - example/ruby/Test_StrSetLen.md | 24 - example/ruby/Test_StringCStr.md | 48 - example/ruby/Test_StringCapacity.md | 24 - example/ruby/Test_StringCoderange.md | 16 - example/ruby/Test_StringEllipsize.md | 20 - example/ruby/Test_StringEncStrBufCat.md | 12 - example/ruby/Test_StringExternalNew.md | 12 - example/ruby/Test_StringModifyExpand.md | 12 - example/ruby/Test_StringNoFree.md | 10 - example/ruby/Test_StringNormalize.md | 16 - example/ruby/Test_StringQSort.md | 12 - example/ruby/Test_String_Fstring.md | 32 - example/ruby/Test_String_Fstring/S.md | 7 - example/ruby/Test_Symbol.md | 6 - example/ruby/Test_Symbol/NonInterned.md | 8 - example/ruby/Test_Symbol/TestInadvertent.md | 130 - example/ruby/Test_Symbol/TestType.md | 32 - example/ruby/Test_SyncDefaultGems.md | 6 - .../Test_SyncDefaultGems/TestMessageFilter.md | 22 - .../TestSyncWithCommits.md | 38 - example/ruby/Test_TooManyDummyEncodings.md | 10 - example/ruby/Test_TypedData.md | 12 - example/ruby/Test_Win32Console.md | 22 - example/ruby/Thread.md | 1078 ---- example/ruby/Thread/Backtrace.md | 55 - example/ruby/Thread/Backtrace/Location.md | 83 - example/ruby/Thread/ConditionVariable.md | 57 - example/ruby/Thread/Mutex.md | 78 - example/ruby/Thread/Queue.md | 150 - example/ruby/Thread/SizedQueue.md | 83 - example/ruby/ThreadBacktraceLocationSpecs.md | 11 - .../MethodAddedAbsolutePath.md | 14 - example/ruby/ThreadError.md | 17 - example/ruby/ThreadGroup.md | 66 - example/ruby/ThreadInstrumentation.md | 6 - .../ruby/ThreadInstrumentation/TestHelper.md | 6 - example/ruby/ThreadSpecs.md | 41 - example/ruby/ThreadSpecs/Status.md | 33 - example/ruby/ThreadSpecs/SubThread.md | 12 - example/ruby/Tick.md | 14 - example/ruby/Time.md | 1545 ----- example/ruby/Time/tm.md | 8 - example/ruby/TimeSpecs.md | 6 - example/ruby/TimeSpecs/MethodHolder.md | 7 - example/ruby/TimeSpecs/SubTime.md | 7 - .../TimeSpecs/TimeLikeArgumentRecorder.md | 9 - .../ruby/TimeSpecs/TimeWithFindTimezone.md | 9 - example/ruby/TimeSpecs/Timezone.md | 16 - .../TimeSpecs/TimezoneMethodCallRecorder.md | 16 - example/ruby/TimeSpecs/TimezoneWithName.md | 30 - example/ruby/TimeSpecs/Z.md | 18 - example/ruby/TimeSpecs/Zone.md | 23 - example/ruby/Timeout.md | 65 - example/ruby/Timeout/Error.md | 11 - example/ruby/Timeout/ExitException.md | 12 - example/ruby/TimeoutAction.md | 22 - example/ruby/TimerAction.md | 18 - example/ruby/Titans.md | 14 - example/ruby/Toggle.md | 18 - example/ruby/TracePoint.md | 399 -- example/ruby/TracePointChecker.md | 15 - .../TracePointChecker/ZombieTraceHunter.md | 13 - example/ruby/TracePointSpec.md | 11 - example/ruby/TracePointSpec/A.md | 9 - example/ruby/TracePointSpec/B.md | 14 - example/ruby/TracePointSpec/C.md | 16 - .../TracePointSpec/ClassWithMethodAlias.md | 10 - example/ruby/Transformation.md | 33 - example/ruby/TreeSpell.md | 7 - example/ruby/TreeSpell/ChangeWord.md | 28 - example/ruby/TreeSpell/HumanTypo.md | 16 - example/ruby/TreeSpellCheckerTest.md | 42 - example/ruby/TrueClass.md | 65 - example/ruby/TupleSpace.md | 22 - example/ruby/TupleSpace/Template.md | 18 - example/ruby/TurboTests.md | 6 - example/ruby/TurboTests/CLI.md | 14 - example/ruby/TurboTests/FakeExample.md | 43 - example/ruby/TurboTests/FakeException.md | 25 - .../ruby/TurboTests/FakeExecutionResult.md | 40 - example/ruby/TurboTests/JsonRowsFormatter.md | 35 - example/ruby/TurboTests/Reporter.md | 53 - example/ruby/TurboTests/Runner.md | 16 - example/ruby/TypeError.md | 21 - example/ruby/UDPSocket.md | 114 - example/ruby/UN.md | 9 - example/ruby/UNIXServer.md | 151 - example/ruby/UNIXSocket.md | 147 - example/ruby/URI.md | 381 -- example/ruby/URI/BadURIError.md | 8 - example/ruby/URI/Error.md | 8 - example/ruby/URI/FTP.md | 323 - example/ruby/URI/File.md | 70 - example/ruby/URI/Generic.md | 438 -- example/ruby/URI/HTTP.md | 308 - example/ruby/URI/HTTPS.md | 10 - example/ruby/URI/InvalidComponentError.md | 8 - example/ruby/URI/InvalidURIError.md | 8 - example/ruby/URI/LDAP.md | 85 - example/ruby/URI/LDAPS.md | 10 - example/ruby/URI/MailTo.md | 70 - example/ruby/URI/RFC2396_Parser.md | 154 - example/ruby/URI/RFC2396_REGEXP.md | 7 - example/ruby/URI/RFC2396_REGEXP/PATTERN.md | 7 - example/ruby/URI/RFC3986_Parser.md | 40 - example/ruby/URI/TestCommon.md | 44 - example/ruby/URI/TestFTP.md | 20 - example/ruby/URI/TestFile.md | 12 - example/ruby/URI/TestGeneric.md | 76 - .../URI/TestGeneric/CaseInsensitiveEnv.md | 30 - example/ruby/URI/TestHTTP.md | 30 - example/ruby/URI/TestLDAP.md | 20 - example/ruby/URI/TestMailTo.md | 26 - example/ruby/URI/TestParser.md | 30 - example/ruby/URI/TestWS.md | 26 - example/ruby/URI/TestWSS.md | 26 - example/ruby/URI/Util.md | 9 - example/ruby/URI/WS.md | 49 - example/ruby/URI/WSS.md | 9 - example/ruby/URISpec.md | 8 - example/ruby/UnboundMethod.md | 287 - example/ruby/UnboundMethodSpecs.md | 6 - example/ruby/UnboundMethodSpecs/A.md | 12 - example/ruby/UnboundMethodSpecs/B.md | 10 - example/ruby/UnboundMethodSpecs/C.md | 10 - example/ruby/UnboundMethodSpecs/Child1.md | 7 - example/ruby/UnboundMethodSpecs/Child2.md | 7 - example/ruby/UnboundMethodSpecs/Child3.md | 7 - example/ruby/UnboundMethodSpecs/HashSpecs.md | 6 - .../UnboundMethodSpecs/HashSpecs/SubClass.md | 7 - .../HashSpecs/SuperClass.md | 10 - example/ruby/UnboundMethodSpecs/Methods.md | 44 - example/ruby/UnboundMethodSpecs/Mod.md | 11 - example/ruby/UnboundMethodSpecs/Parent.md | 14 - .../ruby/UnboundMethodSpecs/SourceLocation.md | 14 - example/ruby/UncaughtThrowError.md | 41 - example/ruby/UncorrectableNameCheckTest.md | 12 - .../FirstNameError.md | 7 - example/ruby/UnexpectedException.md | 7 - example/ruby/UnicodeNormalize.md | 20 - example/ruby/Unifdef.md | 41 - example/ruby/UnitdiffFormatter.md | 10 - example/ruby/UpdateEnv.md | 9 - example/ruby/UserArray.md | 7 - example/ruby/UserCustomConstructorString.md | 12 - example/ruby/UserDefined.md | 25 - example/ruby/UserDefined/Nested.md | 10 - example/ruby/UserDefinedImmediate.md | 12 - example/ruby/UserDefinedString.md | 20 - example/ruby/UserDefinedWithIvar.md | 28 - example/ruby/UserHash.md | 7 - example/ruby/UserHashInitParams.md | 12 - example/ruby/UserMarshal.md | 22 - example/ruby/UserMarshalWithClassName.md | 9 - example/ruby/UserMarshalWithIvar.md | 22 - example/ruby/UserObject.md | 7 - ...serPreviouslyDefinedWithInitializedIvar.md | 14 - example/ruby/UserRegexp.md | 7 - example/ruby/UserString.md | 7 - example/ruby/VCS.md | 68 - example/ruby/VCS/GIT.md | 59 - example/ruby/VCS/GIT/Branch.md | 13 - example/ruby/VCS/GITSVN.md | 14 - example/ruby/VCS/NotFoundError.md | 7 - example/ruby/VCS/Null.md | 12 - example/ruby/VCS/SVN.md | 39 - example/ruby/VPath.md | 36 - example/ruby/VariableMatcher.md | 27 - example/ruby/VariableNameCheckTest.md | 36 - example/ruby/VariableNameCheckTest/User.md | 16 - .../ruby/VariableNameCheckTest/UserModule.md | 9 - example/ruby/VariablesSpecs.md | 9 - example/ruby/VariablesSpecs/ArrayLike.md | 14 - example/ruby/VariablesSpecs/ArraySubclass.md | 7 - example/ruby/VariablesSpecs/Chain.md | 9 - example/ruby/VariablesSpecs/EvalOrder.md | 30 - .../ruby/VariablesSpecs/EvalOrder/BarClass.md | 18 - .../ruby/VariablesSpecs/EvalOrder/FooClass.md | 18 - example/ruby/VariablesSpecs/EvalOrder/Node.md | 14 - example/ruby/VariablesSpecs/Hashalike.md | 12 - example/ruby/VariablesSpecs/OpAsgn.md | 24 - example/ruby/VariablesSpecs/ParAsgn.md | 20 - example/ruby/VariablesSpecs/PrivateMethods.md | 7 - example/ruby/VariablesSpecs/ToAryNil.md | 10 - example/ruby/Vec.md | 34 - example/ruby/VersionGuard.md | 18 - example/ruby/WIN32COMGen.md | 64 - example/ruby/WIN32OLE.md | 366 -- example/ruby/WIN32OLE/Event.md | 127 - example/ruby/WIN32OLE/Method.md | 172 - example/ruby/WIN32OLE/Param.md | 136 - example/ruby/WIN32OLE/Property.md | 19 - example/ruby/WIN32OLE/QueryInterfaceError.md | 8 - example/ruby/WIN32OLE/Record.md | 213 - example/ruby/WIN32OLE/RuntimeError.md | 18 - example/ruby/WIN32OLE/Type.md | 185 - example/ruby/WIN32OLE/TypeLib.md | 124 - example/ruby/WIN32OLE/Variable.md | 134 - example/ruby/WIN32OLE/Variant.md | 108 - example/ruby/WIN32OLE/VariantType.md | 11 - example/ruby/WIN32OLESpecs.md | 8 - example/ruby/Warning.md | 77 - example/ruby/Warning/buffer.md | 11 - example/ruby/WeakRef.md | 36 - example/ruby/WeakRef/RefError.md | 9 - example/ruby/WeakRefSpec.md | 11 - example/ruby/WebauthnListenerResponseTest.md | 20 - example/ruby/WebauthnListenerTest.md | 30 - example/ruby/WebauthnPollerTest.md | 28 - example/ruby/Win32.md | 6 - example/ruby/Win32/Registry.md | 2309 ------- example/ruby/Win32/Registry/API.md | 166 - example/ruby/Win32/Registry/Constants.md | 32 - example/ruby/Win32/Registry/Error.md | 17 - example/ruby/Win32/Registry/Error/Kernel32.md | 139 - example/ruby/Win32/Registry/PredefinedKey.md | 21 - example/ruby/Win32/Resolv.md | 10 - example/ruby/Win32/Resolv/SZ.md | 6 - example/ruby/Windows.md | 7 - example/ruby/Word.md | 6 - example/ruby/X.md | 6 - example/ruby/XMP.md | 62 - example/ruby/XMP/StringInputMethod.md | 34 - example/ruby/XrefTestCase.md | 10 - example/ruby/YAML.md | 53 - example/ruby/YAML/DBM.md | 194 - example/ruby/YAML/Store.md | 69 - example/ruby/YAMLSpecs.md | 6 - example/ruby/YAMLSpecs/Example.md | 12 - example/ruby/YAMLStoreTest.md | 38 - example/ruby/YamlFormatter.md | 16 - example/ruby/YieldSpecs.md | 6 - example/ruby/YieldSpecs/Yielder.md | 34 - example/ruby/Zero.md | 17 - example/ruby/ZeroDivisionError.md | 16 - example/ruby/Zlib.md | 188 - example/ruby/Zlib/BufError.md | 10 - example/ruby/Zlib/DataError.md | 10 - example/ruby/Zlib/Deflate.md | 184 - example/ruby/Zlib/Error.md | 20 - example/ruby/Zlib/GzipFile.md | 100 - example/ruby/Zlib/GzipFile/CRCError.md | 9 - example/ruby/Zlib/GzipFile/Error.md | 16 - example/ruby/Zlib/GzipFile/LengthError.md | 9 - example/ruby/Zlib/GzipFile/NoFooter.md | 8 - example/ruby/Zlib/GzipReader.md | 2233 ------- example/ruby/Zlib/GzipWriter.md | 105 - example/ruby/Zlib/InProgressError.md | 16 - example/ruby/Zlib/Inflate.md | 158 - example/ruby/Zlib/MemError.md | 10 - example/ruby/Zlib/NeedDict.md | 13 - example/ruby/Zlib/StreamEnd.md | 11 - example/ruby/Zlib/StreamError.md | 11 - example/ruby/Zlib/VersionError.md | 11 - example/ruby/Zlib/ZStream.md | 141 - example/ruby/ZombieHunter.md | 9 - example/ruby/fatal.md | 9 - 5611 files changed, 7 insertions(+), 388508 deletions(-) delete mode 100644 example/ruby/A.md delete mode 100644 example/ruby/ACRONYM.md delete mode 100644 example/ruby/Action.md delete mode 100644 example/ruby/ActionFilter.md delete mode 100644 example/ruby/ActionMap.md delete mode 100644 example/ruby/Addrinfo.md delete mode 100644 example/ruby/Alias0.md delete mode 100644 example/ruby/Alias1.md delete mode 100644 example/ruby/Alias2.md delete mode 100644 example/ruby/Alias3.md delete mode 100644 example/ruby/AliasObject.md delete mode 100644 example/ruby/AllPairs.md delete mode 100644 example/ruby/AnError.md delete mode 100644 example/ruby/Apache.md delete mode 100644 example/ruby/Apache/Request.md delete mode 100644 example/ruby/ApplicationController.md delete mode 100644 example/ruby/ArbitraryException.md delete mode 100644 example/ruby/ArgumentError.md delete mode 100644 example/ruby/Array.md delete mode 100644 example/ruby/ArrayCode.md delete mode 100644 example/ruby/ArraySpec.md delete mode 100644 example/ruby/ArraySpec/SideEffect.md delete mode 100644 example/ruby/ArraySpec/Splat.md delete mode 100644 example/ruby/ArraySpecs.md delete mode 100644 example/ruby/ArraySpecs/ArrayConvertible.md delete mode 100644 example/ruby/ArraySpecs/ArrayMethodMissing.md delete mode 100644 example/ruby/ArraySpecs/AssocKey.md delete mode 100644 example/ruby/ArraySpecs/ComparableWithInteger.md delete mode 100644 example/ruby/ArraySpecs/D.md delete mode 100644 example/ruby/ArraySpecs/MockForCompared.md delete mode 100644 example/ruby/ArraySpecs/MyArray.md delete mode 100644 example/ruby/ArraySpecs/MyRange.md delete mode 100644 example/ruby/ArraySpecs/PrivateToAry.md delete mode 100644 example/ruby/ArraySpecs/Sexp.md delete mode 100644 example/ruby/ArraySpecs/SortSame.md delete mode 100644 example/ruby/ArraySpecs/SubArray.md delete mode 100644 example/ruby/ArraySpecs/ToAryArray.md delete mode 100644 example/ruby/ArraySpecs/UFOSceptic.md delete mode 100644 example/ruby/ArraySpecs/Uncomparable.md delete mode 100644 example/ruby/ArraySub.md delete mode 100644 example/ruby/ArraySubPush.md delete mode 100644 example/ruby/Artifice.md delete mode 100644 example/ruby/Artifice/Net.md delete mode 100644 example/ruby/Artifice/Net/HTTP.md delete mode 100644 example/ruby/Artifice/Net/RackRequest.md delete mode 100644 example/ruby/Assertion.md delete mode 100644 example/ruby/AutoIndent.md delete mode 100644 example/ruby/AvailableOLE.md delete mode 100644 example/ruby/B.md delete mode 100644 example/ruby/Bar.md delete mode 100644 example/ruby/BaseFormatter.md delete mode 100644 example/ruby/BasicObject.md delete mode 100644 example/ruby/BasicObjectSpecs.md delete mode 100644 example/ruby/BasicObjectSpecs/BOSubclass.md delete mode 100644 example/ruby/BasicObjectSpecs/IVars.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Get.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Get/BlockDefinitionScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Get/CallerScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Get/CallerWithoutCVarScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Get/ReceiverScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Set.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Set/BlockDefinitionScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Set/CallerScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/CVar/Set/ReceiverScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope/Caller.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope/CallerParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope/Receiver.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope/ReceiverParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope/Caller.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope/CallerParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope/Receiver.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope/ReceiverParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope/Caller.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope/CallerParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope/Receiver.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope/ReceiverParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope/Caller.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope/CallerParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope/Receiver.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope/ReceiverParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope/Caller.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope/CallerParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope/Receiver.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope/ReceiverParent.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEvalConst.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEvalOuter.md delete mode 100644 example/ruby/BasicObjectSpecs/InstEvalOuter/Inner.md delete mode 100644 example/ruby/BasicObjectSpecs/InstExec.md delete mode 100644 example/ruby/BasicObjectSpecs/InstExecIncluded.md delete mode 100644 example/ruby/BasicObjectSpecs/SingletonMethod.md delete mode 100644 example/ruby/BasicSocket.md delete mode 100644 example/ruby/BeAnInOfSpecs.md delete mode 100644 example/ruby/BeAnInOfSpecs/A.md delete mode 100644 example/ruby/BeAnInOfSpecs/B.md delete mode 100644 example/ruby/BeAnInOfSpecs/C.md delete mode 100644 example/ruby/BeAnInstanceOfMatcher.md delete mode 100644 example/ruby/BeAncestorOfMatcher.md delete mode 100644 example/ruby/BeCloseMatcher.md delete mode 100644 example/ruby/BeCloseToMatrixMatcher.md delete mode 100644 example/ruby/BeComputedByMatcher.md delete mode 100644 example/ruby/BeEmptyMatcher.md delete mode 100644 example/ruby/BeFalseMatcher.md delete mode 100644 example/ruby/BeKindOfMatcher.md delete mode 100644 example/ruby/BeNaNMatcher.md delete mode 100644 example/ruby/BeNilMatcher.md delete mode 100644 example/ruby/BeTrueMatcher.md delete mode 100644 example/ruby/BeTrueOrFalseMatcher.md delete mode 100644 example/ruby/Benchmark.md delete mode 100644 example/ruby/Benchmark/Job.md delete mode 100644 example/ruby/Benchmark/Report.md delete mode 100644 example/ruby/Benchmark/Tms.md delete mode 100644 example/ruby/BenchmarkDriver/Output/Driver.md delete mode 100644 example/ruby/BenchmarkDriver/Runner/Cstime.md delete mode 100644 example/ruby/BenchmarkDriver/Runner/Cutime.md delete mode 100644 example/ruby/BenchmarkDriver/Runner/Peak.md delete mode 100644 example/ruby/BenchmarkDriver/Runner/Ractor.md delete mode 100644 example/ruby/BenchmarkDriver/Runner/Size.md delete mode 100644 example/ruby/BenchmarkDriver/Runner/Stime.md delete mode 100644 example/ruby/BenchmarkDriver/Runner/Total.md delete mode 100644 example/ruby/BenchmarkDriver/Runner/Utime.md delete mode 100644 example/ruby/Biff.md delete mode 100644 example/ruby/BigDecimal.md delete mode 100644 example/ruby/BigDecimalSpecs.md delete mode 100644 example/ruby/BigEndianGuard.md delete mode 100644 example/ruby/Binding.md delete mode 100644 example/ruby/BindingGenerator.md delete mode 100644 example/ruby/BindingSpecs.md delete mode 100644 example/ruby/BindingSpecs/AddFooToString.md delete mode 100644 example/ruby/BindingSpecs/Demo.md delete mode 100644 example/ruby/BindingSpecs/LocationMethod.md delete mode 100644 example/ruby/BindingSpecs/Refined.md delete mode 100644 example/ruby/BlockDeviceGuard.md delete mode 100644 example/ruby/BlockSpecs.md delete mode 100644 example/ruby/BlockSpecs/OverwriteBlockVariable.md delete mode 100644 example/ruby/BlockSpecs/Yield.md delete mode 100644 example/ruby/BlockSpecs/Yielder.md delete mode 100644 example/ruby/BlockingMatcher.md delete mode 100644 example/ruby/Board.md delete mode 100644 example/ruby/Book.md delete mode 100644 example/ruby/Book/Page.md delete mode 100644 example/ruby/Book/Spine.md delete mode 100644 example/ruby/Book/TableOfContents.md delete mode 100644 example/ruby/Branch.md delete mode 100644 example/ruby/BreakSpecs.md delete mode 100644 example/ruby/BreakSpecs/Block.md delete mode 100644 example/ruby/BreakSpecs/Driver.md delete mode 100644 example/ruby/BreakSpecs/Lambda.md delete mode 100644 example/ruby/BrokenUnblockScheduler.md delete mode 100644 example/ruby/Bug.md delete mode 100644 example/ruby/Bug/Array.md delete mode 100644 example/ruby/Bug/Array/DataError.md delete mode 100644 example/ruby/Bug/Bar.md delete mode 100644 example/ruby/Bug/Bignum.md delete mode 100644 example/ruby/Bug/Bug7802.md delete mode 100644 example/ruby/Bug/Class.md delete mode 100644 example/ruby/Bug/Class/Loop.md delete mode 100644 example/ruby/Bug/Class/VersionMax.md delete mode 100644 example/ruby/Bug/Class/VersionZero.md delete mode 100644 example/ruby/Bug/Debug.md delete mode 100644 example/ruby/Bug/EnumeratorKw.md delete mode 100644 example/ruby/Bug/Exception.md delete mode 100644 example/ruby/Bug/File.md delete mode 100644 example/ruby/Bug/File/NewlineConv.md delete mode 100644 example/ruby/Bug/File/Stat.md delete mode 100644 example/ruby/Bug/Float.md delete mode 100644 example/ruby/Bug/Float/Breakable.md delete mode 100644 example/ruby/Bug/Float/Yield.md delete mode 100644 example/ruby/Bug/Hash.md delete mode 100644 example/ruby/Bug/Integer.md delete mode 100644 example/ruby/Bug/Iter.md delete mode 100644 example/ruby/Bug/Marshal.md delete mode 100644 example/ruby/Bug/Marshal/TestInternalIVar.md delete mode 100644 example/ruby/Bug/Marshal/TestUsrMarshal.md delete mode 100644 example/ruby/Bug/Method.md delete mode 100644 example/ruby/Bug/NotImplement.md delete mode 100644 example/ruby/Bug/NotImplement/MyInteger.md delete mode 100644 example/ruby/Bug/Proc.md delete mode 100644 example/ruby/Bug/Rational.md delete mode 100644 example/ruby/Bug/RbCallSuperKw.md delete mode 100644 example/ruby/Bug/Regexp.md delete mode 100644 example/ruby/Bug/ScanArgs.md delete mode 100644 example/ruby/Bug/StNumHash.md delete mode 100644 example/ruby/Bug/StNumHash/Test_NumHash.md delete mode 100644 example/ruby/Bug/StTable.md delete mode 100644 example/ruby/Bug/StTable/Test_Update.md delete mode 100644 example/ruby/Bug/String.md delete mode 100644 example/ruby/Bug/Struct.md delete mode 100644 example/ruby/Bug/Struct/Test_Data.md delete mode 100644 example/ruby/Bug/Struct/Test_Duplicate.md delete mode 100644 example/ruby/Bug/Struct/Test_Len.md delete mode 100644 example/ruby/Bug/Struct/Test_Member.md delete mode 100644 example/ruby/Bug/Symbol.md delete mode 100644 example/ruby/Bug/Test_ExceptionAT.md delete mode 100644 example/ruby/Bug/Test_ExceptionDE.md delete mode 100644 example/ruby/Bug/Test_ExceptionE.md delete mode 100644 example/ruby/Bug/Test_ExceptionER.md delete mode 100644 example/ruby/Bug/Thread.md delete mode 100644 example/ruby/Bug/ThreadInstrumentation.md delete mode 100644 example/ruby/Bug/Time.md delete mode 100644 example/ruby/Bug/Time/Test_New.md delete mode 100644 example/ruby/Bug/TypedData.md delete mode 100644 example/ruby/Bug/VM.md delete mode 100644 example/ruby/Bug/Win32.md delete mode 100644 example/ruby/Bug/Win32/TestDln.md delete mode 100644 example/ruby/Bug/Win32/TestFdSetSize.md delete mode 100644 example/ruby/BugGuard.md delete mode 100644 example/ruby/BundledGem.md delete mode 100644 example/ruby/Bundler.md delete mode 100644 example/ruby/Bundler/APIResponseInvalidDependenciesError.md delete mode 100644 example/ruby/Bundler/APIResponseMismatchError.md delete mode 100644 example/ruby/Bundler/BuildMetadata.md delete mode 100644 example/ruby/Bundler/BundlerError.md delete mode 100644 example/ruby/Bundler/CIDetector.md delete mode 100644 example/ruby/Bundler/CLI.md delete mode 100644 example/ruby/Bundler/CLI/Add.md delete mode 100644 example/ruby/Bundler/CLI/Binstubs.md delete mode 100644 example/ruby/Bundler/CLI/Cache.md delete mode 100644 example/ruby/Bundler/CLI/Check.md delete mode 100644 example/ruby/Bundler/CLI/Clean.md delete mode 100644 example/ruby/Bundler/CLI/Common.md delete mode 100644 example/ruby/Bundler/CLI/Config.md delete mode 100644 example/ruby/Bundler/CLI/Config/Base.md delete mode 100644 example/ruby/Bundler/CLI/Console.md delete mode 100644 example/ruby/Bundler/CLI/Doctor.md delete mode 100644 example/ruby/Bundler/CLI/Exec.md delete mode 100644 example/ruby/Bundler/CLI/Fund.md delete mode 100644 example/ruby/Bundler/CLI/Gem.md delete mode 100644 example/ruby/Bundler/CLI/Info.md delete mode 100644 example/ruby/Bundler/CLI/Init.md delete mode 100644 example/ruby/Bundler/CLI/Inject.md delete mode 100644 example/ruby/Bundler/CLI/Install.md delete mode 100644 example/ruby/Bundler/CLI/Issue.md delete mode 100644 example/ruby/Bundler/CLI/List.md delete mode 100644 example/ruby/Bundler/CLI/Lock.md delete mode 100644 example/ruby/Bundler/CLI/Open.md delete mode 100644 example/ruby/Bundler/CLI/Outdated.md delete mode 100644 example/ruby/Bundler/CLI/Platform.md delete mode 100644 example/ruby/Bundler/CLI/Plugin.md delete mode 100644 example/ruby/Bundler/CLI/Pristine.md delete mode 100644 example/ruby/Bundler/CLI/Remove.md delete mode 100644 example/ruby/Bundler/CLI/Show.md delete mode 100644 example/ruby/Bundler/CLI/Update.md delete mode 100644 example/ruby/Bundler/CLI/Viz.md delete mode 100644 example/ruby/Bundler/Checksum.md delete mode 100644 example/ruby/Bundler/Checksum/Source.md delete mode 100644 example/ruby/Bundler/Checksum/Store.md delete mode 100644 example/ruby/Bundler/ChecksumMismatchError.md delete mode 100644 example/ruby/Bundler/CompactIndexClient.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/Cache.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/CacheFile.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/CacheFile/ClosedError.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/CacheFile/DigestMismatchError.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/CacheFile/Error.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/Error.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/GemParser.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/Parser.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/Updater.md delete mode 100644 example/ruby/Bundler/CompactIndexClient/Updater/MismatchedChecksumError.md delete mode 100644 example/ruby/Bundler/ConnectionPool.md delete mode 100644 example/ruby/Bundler/ConnectionPool/Error.md delete mode 100644 example/ruby/Bundler/ConnectionPool/ForkTracker.md delete mode 100644 example/ruby/Bundler/ConnectionPool/PoolShuttingDownError.md delete mode 100644 example/ruby/Bundler/ConnectionPool/TimedStack.md delete mode 100644 example/ruby/Bundler/ConnectionPool/TimeoutError.md delete mode 100644 example/ruby/Bundler/ConnectionPool/Wrapper.md delete mode 100644 example/ruby/Bundler/CorruptBundlerInstallError.md delete mode 100644 example/ruby/Bundler/CurrentRuby.md delete mode 100644 example/ruby/Bundler/CyclicDependencyError.md delete mode 100644 example/ruby/Bundler/Definition.md delete mode 100644 example/ruby/Bundler/Dependency.md delete mode 100644 example/ruby/Bundler/Deployment.md delete mode 100644 example/ruby/Bundler/Deprecate.md delete mode 100644 example/ruby/Bundler/DeprecatedError.md delete mode 100644 example/ruby/Bundler/Digest.md delete mode 100644 example/ruby/Bundler/DirectoryRemovalError.md delete mode 100644 example/ruby/Bundler/Dsl.md delete mode 100644 example/ruby/Bundler/Dsl/DSLError.md delete mode 100644 example/ruby/Bundler/EndpointSpecification.md delete mode 100644 example/ruby/Bundler/Env.md delete mode 100644 example/ruby/Bundler/EnvironmentPreserver.md delete mode 100644 example/ruby/Bundler/FeatureFlag.md delete mode 100644 example/ruby/Bundler/FetchMetadata.md delete mode 100644 example/ruby/Bundler/Fetcher.md delete mode 100644 example/ruby/Bundler/Fetcher/AuthenticationForbiddenError.md delete mode 100644 example/ruby/Bundler/Fetcher/AuthenticationRequiredError.md delete mode 100644 example/ruby/Bundler/Fetcher/BadAuthenticationError.md delete mode 100644 example/ruby/Bundler/Fetcher/Base.md delete mode 100644 example/ruby/Bundler/Fetcher/CertificateFailureError.md delete mode 100644 example/ruby/Bundler/Fetcher/CompactIndex.md delete mode 100644 example/ruby/Bundler/Fetcher/CompactIndex/ClientFetcher.md delete mode 100644 example/ruby/Bundler/Fetcher/Dependency.md delete mode 100644 example/ruby/Bundler/Fetcher/Downloader.md delete mode 100644 example/ruby/Bundler/Fetcher/FallbackError.md delete mode 100644 example/ruby/Bundler/Fetcher/GemRemoteFetcher.md delete mode 100644 example/ruby/Bundler/Fetcher/Index.md delete mode 100644 example/ruby/Bundler/Fetcher/NetworkDownError.md delete mode 100644 example/ruby/Bundler/Fetcher/SSLError.md delete mode 100644 example/ruby/Bundler/Fetcher/TooManyRequestsError.md delete mode 100644 example/ruby/Bundler/FileUtils.md delete mode 100644 example/ruby/Bundler/FileUtils/DryRun.md delete mode 100644 example/ruby/Bundler/FileUtils/Entry_.md delete mode 100644 example/ruby/Bundler/FileUtils/LowMethods.md delete mode 100644 example/ruby/Bundler/FileUtils/NoWrite.md delete mode 100644 example/ruby/Bundler/FileUtils/StreamUtils_.md delete mode 100644 example/ruby/Bundler/FileUtils/Verbose.md delete mode 100644 example/ruby/Bundler/ForcePlatform.md delete mode 100644 example/ruby/Bundler/FriendlyErrors.md delete mode 100644 example/ruby/Bundler/GemHelper.md delete mode 100644 example/ruby/Bundler/GemHelpers.md delete mode 100644 example/ruby/Bundler/GemHelpers/PlatformMatch.md delete mode 100644 example/ruby/Bundler/GemInstaller.md delete mode 100644 example/ruby/Bundler/GemNotFound.md delete mode 100644 example/ruby/Bundler/GemRequireError.md delete mode 100644 example/ruby/Bundler/GemVersionPromoter.md delete mode 100644 example/ruby/Bundler/GemfileError.md delete mode 100644 example/ruby/Bundler/GemfileEvalError.md delete mode 100644 example/ruby/Bundler/GemfileLockNotFound.md delete mode 100644 example/ruby/Bundler/GemfileNotFound.md delete mode 100644 example/ruby/Bundler/GemspecError.md delete mode 100644 example/ruby/Bundler/GenericSystemCallError.md delete mode 100644 example/ruby/Bundler/GitError.md delete mode 100644 example/ruby/Bundler/Graph.md delete mode 100644 example/ruby/Bundler/Graph/GraphVizClient.md delete mode 100644 example/ruby/Bundler/HTTPError.md delete mode 100644 example/ruby/Bundler/IncorrectLockfileDependencies.md delete mode 100644 example/ruby/Bundler/Index.md delete mode 100644 example/ruby/Bundler/Injector.md delete mode 100644 example/ruby/Bundler/InsecureInstallPathError.md delete mode 100644 example/ruby/Bundler/InstallError.md delete mode 100644 example/ruby/Bundler/InstallHookError.md delete mode 100644 example/ruby/Bundler/Installer.md delete mode 100644 example/ruby/Bundler/InvalidArgumentError.md delete mode 100644 example/ruby/Bundler/InvalidOption.md delete mode 100644 example/ruby/Bundler/LazySpecification.md delete mode 100644 example/ruby/Bundler/LockfileError.md delete mode 100644 example/ruby/Bundler/LockfileGenerator.md delete mode 100644 example/ruby/Bundler/LockfileParser.md delete mode 100644 example/ruby/Bundler/LockfileParser/Position.md delete mode 100644 example/ruby/Bundler/MarshalError.md delete mode 100644 example/ruby/Bundler/MatchMetadata.md delete mode 100644 example/ruby/Bundler/MatchPlatform.md delete mode 100644 example/ruby/Bundler/MatchRemoteMetadata.md delete mode 100644 example/ruby/Bundler/Materialization.md delete mode 100644 example/ruby/Bundler/MirrorSockets.md delete mode 100644 example/ruby/Bundler/NoSpaceOnDeviceError.md delete mode 100644 example/ruby/Bundler/OperationNotSupportedError.md delete mode 100644 example/ruby/Bundler/ParallelInstaller.md delete mode 100644 example/ruby/Bundler/ParallelInstaller/SpecInstallation.md delete mode 100644 example/ruby/Bundler/PathError.md delete mode 100644 example/ruby/Bundler/PermissionError.md delete mode 100644 example/ruby/Bundler/Persistent.md delete mode 100644 example/ruby/Bundler/Persistent/Net.md delete mode 100644 example/ruby/Bundler/Persistent/Net/HTTP.md delete mode 100644 example/ruby/Bundler/Plugin.md delete mode 100644 example/ruby/Bundler/Plugin/API.md delete mode 100644 example/ruby/Bundler/Plugin/API/Source.md delete mode 100644 example/ruby/Bundler/Plugin/DSL.md delete mode 100644 example/ruby/Bundler/Plugin/DSL/PluginGemfileError.md delete mode 100644 example/ruby/Bundler/Plugin/Events.md delete mode 100644 example/ruby/Bundler/Plugin/Index.md delete mode 100644 example/ruby/Bundler/Plugin/Index/CommandConflict.md delete mode 100644 example/ruby/Bundler/Plugin/Index/SourceConflict.md delete mode 100644 example/ruby/Bundler/Plugin/Installer.md delete mode 100644 example/ruby/Bundler/Plugin/Installer/Git.md delete mode 100644 example/ruby/Bundler/Plugin/Installer/Path.md delete mode 100644 example/ruby/Bundler/Plugin/Installer/Rubygems.md delete mode 100644 example/ruby/Bundler/Plugin/MalformattedPlugin.md delete mode 100644 example/ruby/Bundler/Plugin/PluginInstallError.md delete mode 100644 example/ruby/Bundler/Plugin/SourceList.md delete mode 100644 example/ruby/Bundler/Plugin/UndefinedCommandError.md delete mode 100644 example/ruby/Bundler/Plugin/UnknownSourceError.md delete mode 100644 example/ruby/Bundler/PluginError.md delete mode 100644 example/ruby/Bundler/ProcessLock.md delete mode 100644 example/ruby/Bundler/ProductionError.md delete mode 100644 example/ruby/Bundler/PubGrub.md delete mode 100644 example/ruby/Bundler/PubGrub/Assignment.md delete mode 100644 example/ruby/Bundler/PubGrub/BasicPackageSource.md delete mode 100644 example/ruby/Bundler/PubGrub/FailureWriter.md delete mode 100644 example/ruby/Bundler/PubGrub/Incompatibility.md delete mode 100644 example/ruby/Bundler/PubGrub/Incompatibility/ConflictCause.md delete mode 100644 example/ruby/Bundler/PubGrub/Incompatibility/InvalidDependency.md delete mode 100644 example/ruby/Bundler/PubGrub/Incompatibility/NoVersions.md delete mode 100644 example/ruby/Bundler/PubGrub/Package.md delete mode 100644 example/ruby/Bundler/PubGrub/PartialSolution.md delete mode 100644 example/ruby/Bundler/PubGrub/RubyGems.md delete mode 100644 example/ruby/Bundler/PubGrub/SolveFailure.md delete mode 100644 example/ruby/Bundler/PubGrub/StaticPackageSource.md delete mode 100644 example/ruby/Bundler/PubGrub/StaticPackageSource/DSL.md delete mode 100644 example/ruby/Bundler/PubGrub/Term.md delete mode 100644 example/ruby/Bundler/PubGrub/VersionConstraint.md delete mode 100644 example/ruby/Bundler/PubGrub/VersionRange.md delete mode 100644 example/ruby/Bundler/PubGrub/VersionRange/Empty.md delete mode 100644 example/ruby/Bundler/PubGrub/VersionSolver.md delete mode 100644 example/ruby/Bundler/PubGrub/VersionUnion.md delete mode 100644 example/ruby/Bundler/RemoteSpecification.md delete mode 100644 example/ruby/Bundler/Resolver.md delete mode 100644 example/ruby/Bundler/Resolver/Base.md delete mode 100644 example/ruby/Bundler/Resolver/Candidate.md delete mode 100644 example/ruby/Bundler/Resolver/Incompatibility.md delete mode 100644 example/ruby/Bundler/Resolver/Package.md delete mode 100644 example/ruby/Bundler/Resolver/Root.md delete mode 100644 example/ruby/Bundler/Resolver/SpecGroup.md delete mode 100644 example/ruby/Bundler/Retry.md delete mode 100644 example/ruby/Bundler/RubyDsl.md delete mode 100644 example/ruby/Bundler/RubyGemsGemInstaller.md delete mode 100644 example/ruby/Bundler/RubyVersion.md delete mode 100644 example/ruby/Bundler/RubyVersionMismatch.md delete mode 100644 example/ruby/Bundler/RubygemsIntegration.md delete mode 100644 example/ruby/Bundler/Runtime.md delete mode 100644 example/ruby/Bundler/SafeMarshal.md delete mode 100644 example/ruby/Bundler/SecureRandom.md delete mode 100644 example/ruby/Bundler/SecurityError.md delete mode 100644 example/ruby/Bundler/SelfManager.md delete mode 100644 example/ruby/Bundler/Settings.md delete mode 100644 example/ruby/Bundler/Settings/Mirror.md delete mode 100644 example/ruby/Bundler/Settings/MirrorConfig.md delete mode 100644 example/ruby/Bundler/Settings/Mirrors.md delete mode 100644 example/ruby/Bundler/Settings/Path.md delete mode 100644 example/ruby/Bundler/Settings/TCPSocketProbe.md delete mode 100644 example/ruby/Bundler/Settings/Validator.md delete mode 100644 example/ruby/Bundler/Settings/Validator/Rule.md delete mode 100644 example/ruby/Bundler/SharedHelpers.md delete mode 100644 example/ruby/Bundler/SimilarityDetector.md delete mode 100644 example/ruby/Bundler/SimilarityDetector/SimilarityScore.md delete mode 100644 example/ruby/Bundler/SocketAddress.md delete mode 100644 example/ruby/Bundler/SolveFailure.md delete mode 100644 example/ruby/Bundler/Source.md delete mode 100644 example/ruby/Bundler/Source/Gemspec.md delete mode 100644 example/ruby/Bundler/Source/Git.md delete mode 100644 example/ruby/Bundler/Source/Git/AmbiguousGitReference.md delete mode 100644 example/ruby/Bundler/Source/Git/GitCommandError.md delete mode 100644 example/ruby/Bundler/Source/Git/GitNotAllowedError.md delete mode 100644 example/ruby/Bundler/Source/Git/GitNotInstalledError.md delete mode 100644 example/ruby/Bundler/Source/Git/GitProxy.md delete mode 100644 example/ruby/Bundler/Source/Git/MissingGitRevisionError.md delete mode 100644 example/ruby/Bundler/Source/Metadata.md delete mode 100644 example/ruby/Bundler/Source/Path.md delete mode 100644 example/ruby/Bundler/Source/Path/Installer.md delete mode 100644 example/ruby/Bundler/Source/Rubygems.md delete mode 100644 example/ruby/Bundler/Source/Rubygems/Remote.md delete mode 100644 example/ruby/Bundler/Source/RubygemsAggregate.md delete mode 100644 example/ruby/Bundler/SourceList.md delete mode 100644 example/ruby/Bundler/SourceMap.md delete mode 100644 example/ruby/Bundler/SpecSet.md delete mode 100644 example/ruby/Bundler/Standalone.md delete mode 100644 example/ruby/Bundler/StubSpecification.md delete mode 100644 example/ruby/Bundler/TSort.md delete mode 100644 example/ruby/Bundler/TSort/Cyclic.md delete mode 100644 example/ruby/Bundler/TemporaryResourceError.md delete mode 100644 example/ruby/Bundler/Thor.md delete mode 100644 example/ruby/Bundler/Thor/Actions.md delete mode 100644 example/ruby/Bundler/Thor/Actions/CapturableERB.md delete mode 100644 example/ruby/Bundler/Thor/Actions/ClassMethods.md delete mode 100644 example/ruby/Bundler/Thor/Actions/CreateFile.md delete mode 100644 example/ruby/Bundler/Thor/Actions/CreateLink.md delete mode 100644 example/ruby/Bundler/Thor/Actions/Directory.md delete mode 100644 example/ruby/Bundler/Thor/Actions/EmptyDirectory.md delete mode 100644 example/ruby/Bundler/Thor/Actions/InjectIntoFile.md delete mode 100644 example/ruby/Bundler/Thor/AmbiguousCommandError.md delete mode 100644 example/ruby/Bundler/Thor/Argument.md delete mode 100644 example/ruby/Bundler/Thor/Arguments.md delete mode 100644 example/ruby/Bundler/Thor/AtLeastOneRequiredArgumentError.md delete mode 100644 example/ruby/Bundler/Thor/Base.md delete mode 100644 example/ruby/Bundler/Thor/Base/ClassMethods.md delete mode 100644 example/ruby/Bundler/Thor/Command.md delete mode 100644 example/ruby/Bundler/Thor/CoreExt.md delete mode 100644 example/ruby/Bundler/Thor/CoreExt/HashWithIndifferentAccess.md delete mode 100644 example/ruby/Bundler/Thor/DynamicCommand.md delete mode 100644 example/ruby/Bundler/Thor/Error.md delete mode 100644 example/ruby/Bundler/Thor/ExclusiveArgumentError.md delete mode 100644 example/ruby/Bundler/Thor/Group.md delete mode 100644 example/ruby/Bundler/Thor/HiddenCommand.md delete mode 100644 example/ruby/Bundler/Thor/Invocation.md delete mode 100644 example/ruby/Bundler/Thor/Invocation/ClassMethods.md delete mode 100644 example/ruby/Bundler/Thor/InvocationError.md delete mode 100644 example/ruby/Bundler/Thor/LineEditor.md delete mode 100644 example/ruby/Bundler/Thor/LineEditor/Basic.md delete mode 100644 example/ruby/Bundler/Thor/LineEditor/Readline.md delete mode 100644 example/ruby/Bundler/Thor/LineEditor/Readline/PathCompletion.md delete mode 100644 example/ruby/Bundler/Thor/MalformattedArgumentError.md delete mode 100644 example/ruby/Bundler/Thor/NestedContext.md delete mode 100644 example/ruby/Bundler/Thor/Option.md delete mode 100644 example/ruby/Bundler/Thor/Options.md delete mode 100644 example/ruby/Bundler/Thor/RakeCompat.md delete mode 100644 example/ruby/Bundler/Thor/RequiredArgumentMissingError.md delete mode 100644 example/ruby/Bundler/Thor/Runner.md delete mode 100644 example/ruby/Bundler/Thor/Sandbox.md delete mode 100644 example/ruby/Bundler/Thor/Shell.md delete mode 100644 example/ruby/Bundler/Thor/Shell/Basic.md delete mode 100644 example/ruby/Bundler/Thor/Shell/Color.md delete mode 100644 example/ruby/Bundler/Thor/Shell/ColumnPrinter.md delete mode 100644 example/ruby/Bundler/Thor/Shell/HTML.md delete mode 100644 example/ruby/Bundler/Thor/Shell/TablePrinter.md delete mode 100644 example/ruby/Bundler/Thor/Shell/Terminal.md delete mode 100644 example/ruby/Bundler/Thor/Shell/WrappedPrinter.md delete mode 100644 example/ruby/Bundler/Thor/UndefinedCommandError.md delete mode 100644 example/ruby/Bundler/Thor/UndefinedCommandError/SpellChecker.md delete mode 100644 example/ruby/Bundler/Thor/UnknownArgumentError.md delete mode 100644 example/ruby/Bundler/Thor/UnknownArgumentError/SpellChecker.md delete mode 100644 example/ruby/Bundler/Thor/Util.md delete mode 100644 example/ruby/Bundler/ThreadCreationError.md delete mode 100644 example/ruby/Bundler/UI.md delete mode 100644 example/ruby/Bundler/UI/RGProxy.md delete mode 100644 example/ruby/Bundler/UI/Shell.md delete mode 100644 example/ruby/Bundler/UI/Silent.md delete mode 100644 example/ruby/Bundler/URI.md delete mode 100644 example/ruby/Bundler/URI/BadURIError.md delete mode 100644 example/ruby/Bundler/URI/Error.md delete mode 100644 example/ruby/Bundler/URI/FTP.md delete mode 100644 example/ruby/Bundler/URI/File.md delete mode 100644 example/ruby/Bundler/URI/Generic.md delete mode 100644 example/ruby/Bundler/URI/HTTP.md delete mode 100644 example/ruby/Bundler/URI/HTTPS.md delete mode 100644 example/ruby/Bundler/URI/InvalidComponentError.md delete mode 100644 example/ruby/Bundler/URI/InvalidURIError.md delete mode 100644 example/ruby/Bundler/URI/LDAP.md delete mode 100644 example/ruby/Bundler/URI/LDAPS.md delete mode 100644 example/ruby/Bundler/URI/MailTo.md delete mode 100644 example/ruby/Bundler/URI/RFC2396_Parser.md delete mode 100644 example/ruby/Bundler/URI/RFC2396_REGEXP.md delete mode 100644 example/ruby/Bundler/URI/RFC2396_REGEXP/PATTERN.md delete mode 100644 example/ruby/Bundler/URI/RFC3986_Parser.md delete mode 100644 example/ruby/Bundler/URI/Util.md delete mode 100644 example/ruby/Bundler/URI/WS.md delete mode 100644 example/ruby/Bundler/URI/WSS.md delete mode 100644 example/ruby/Bundler/URICredentialsFilter.md delete mode 100644 example/ruby/Bundler/URINormalizer.md delete mode 100644 example/ruby/Bundler/VirtualProtocolError.md delete mode 100644 example/ruby/Bundler/Worker.md delete mode 100644 example/ruby/Bundler/Worker/WrappedException.md delete mode 100644 example/ruby/Bundler/YAMLSerializer.md delete mode 100644 example/ruby/Bundler/YamlSyntaxError.md delete mode 100644 example/ruby/BundlerVCRHTTP.md delete mode 100644 example/ruby/BundlerVCRHTTP/RequestHandler.md delete mode 100644 example/ruby/C.md delete mode 100644 example/ruby/CApiClassSpecs.md delete mode 100644 example/ruby/CApiClassSpecs/A.md delete mode 100644 example/ruby/CApiClassSpecs/A/B.md delete mode 100644 example/ruby/CApiClassSpecs/A/D.md delete mode 100644 example/ruby/CApiClassSpecs/A/M.md delete mode 100644 example/ruby/CApiClassSpecs/Alloc.md delete mode 100644 example/ruby/CApiClassSpecs/Attr.md delete mode 100644 example/ruby/CApiClassSpecs/CVars.md delete mode 100644 example/ruby/CApiClassSpecs/Inherited.md delete mode 100644 example/ruby/CApiClassSpecs/KeywordAlloc.md delete mode 100644 example/ruby/CApiClassSpecs/M.md delete mode 100644 example/ruby/CApiClassSpecs/NewClass.md delete mode 100644 example/ruby/CApiClassSpecs/Sub.md delete mode 100644 example/ruby/CApiClassSpecs/SubM.md delete mode 100644 example/ruby/CApiClassSpecs/SubSelf.md delete mode 100644 example/ruby/CApiClassSpecs/SubSub.md delete mode 100644 example/ruby/CApiClassSpecs/Super.md delete mode 100644 example/ruby/CApiClassSpecs/SuperSelf.md delete mode 100644 example/ruby/CApiEncodingSpecs.md delete mode 100644 example/ruby/CApiEncodingSpecs/S.md delete mode 100644 example/ruby/CApiKernelSpecs.md delete mode 100644 example/ruby/CApiKernelSpecs/ClassWithPrivateMethod.md delete mode 100644 example/ruby/CApiKernelSpecs/ClassWithProtectedMethod.md delete mode 100644 example/ruby/CApiKernelSpecs/ClassWithPublicMethod.md delete mode 100644 example/ruby/CApiKernelSpecs/Exc.md delete mode 100644 example/ruby/CApiModuleSpecs.md delete mode 100644 example/ruby/CApiModuleSpecs/A.md delete mode 100644 example/ruby/CApiModuleSpecs/B.md delete mode 100644 example/ruby/CApiModuleSpecs/C.md delete mode 100644 example/ruby/CApiModuleSpecs/M.md delete mode 100644 example/ruby/CApiModuleSpecs/RubyUnderAutoload.md delete mode 100644 example/ruby/CApiModuleSpecs/Super.md delete mode 100644 example/ruby/CApiObjectSpecs.md delete mode 100644 example/ruby/CApiObjectSpecs/Alloc.md delete mode 100644 example/ruby/CApiObjectSpecs/CVars.md delete mode 100644 example/ruby/CApiObjectSpecs/IVars.md delete mode 100644 example/ruby/CApiObjectSpecs/MVars.md delete mode 100644 example/ruby/CApiObjectSpecs/SubArray.md delete mode 100644 example/ruby/CApiProcSpecs.md delete mode 100644 example/ruby/CApiStringSpecs.md delete mode 100644 example/ruby/CApiStringSpecs/InvalidTostrTest.md delete mode 100644 example/ruby/CApiStringSpecs/ToSOrInspect.md delete mode 100644 example/ruby/CApiStringSpecs/ValidTostrTest.md delete mode 100644 example/ruby/CGI.md delete mode 100644 example/ruby/CGI/Cookie.md delete mode 100644 example/ruby/CGI/Escape.md delete mode 100644 example/ruby/CGI/HTML3.md delete mode 100644 example/ruby/CGI/HTML4.md delete mode 100644 example/ruby/CGI/HTML4Fr.md delete mode 100644 example/ruby/CGI/HTML4Tr.md delete mode 100644 example/ruby/CGI/HTML5.md delete mode 100644 example/ruby/CGI/Html3.md delete mode 100644 example/ruby/CGI/Html4.md delete mode 100644 example/ruby/CGI/Html4Fr.md delete mode 100644 example/ruby/CGI/Html4Tr.md delete mode 100644 example/ruby/CGI/Html5.md delete mode 100644 example/ruby/CGI/HtmlExtension.md delete mode 100644 example/ruby/CGI/InvalidEncoding.md delete mode 100644 example/ruby/CGI/QueryExtension.md delete mode 100644 example/ruby/CGI/Session.md delete mode 100644 example/ruby/CGI/Session/FileStore.md delete mode 100644 example/ruby/CGI/Session/MemoryStore.md delete mode 100644 example/ruby/CGI/Session/NoSession.md delete mode 100644 example/ruby/CGI/Session/NullStore.md delete mode 100644 example/ruby/CGI/Session/PStore.md delete mode 100644 example/ruby/CGI/TagMaker.md delete mode 100644 example/ruby/CGI/Util.md delete mode 100644 example/ruby/CGICookieTest.md delete mode 100644 example/ruby/CGICoreTest.md delete mode 100644 example/ruby/CGIHeaderTest.md delete mode 100644 example/ruby/CGIModrubyTest.md delete mode 100644 example/ruby/CGIMultipartTest.md delete mode 100644 example/ruby/CGISessionTest.md delete mode 100644 example/ruby/CGISpecs.md delete mode 100644 example/ruby/CGITagHelperTest.md delete mode 100644 example/ruby/CGIUtilPureRubyTest.md delete mode 100644 example/ruby/CGIUtilTest.md delete mode 100644 example/ruby/CGIUtilTest/UnescapeHTMLTests.md delete mode 100644 example/ruby/CHashDir.md delete mode 100644 example/ruby/CONST1.md delete mode 100644 example/ruby/CONST2_.md delete mode 100644 example/ruby/CSAutoloadA.md delete mode 100644 example/ruby/CSAutoloadB.md delete mode 100644 example/ruby/CSAutoloadC.md delete mode 100644 example/ruby/CSAutoloadD.md delete mode 100644 example/ruby/CSAutoloadD/InnerModule.md delete mode 100644 example/ruby/CS_CONST_AUTOLOAD.md delete mode 100644 example/ruby/Cal.md delete mode 100644 example/ruby/CaseFolding.md delete mode 100644 example/ruby/CaseFolding/Util.md delete mode 100644 example/ruby/CaseInsensitiveRegularExpressionVisitor.md delete mode 100644 example/ruby/CaseMapping.md delete mode 100644 example/ruby/CaseMappingDummy.md delete mode 100644 example/ruby/CertStore.md delete mode 100644 example/ruby/ChangeWordTest.md delete mode 100644 example/ruby/ChatClient.md delete mode 100644 example/ruby/ChatEntry.md delete mode 100644 example/ruby/ChatServer.md delete mode 100644 example/ruby/Checksum.md delete mode 100644 example/ruby/Child.md delete mode 100644 example/ruby/Class.md delete mode 100644 example/ruby/ClassNameCheckTest.md delete mode 100644 example/ruby/ClassSpecs.md delete mode 100644 example/ruby/ClassSpecs/A.md delete mode 100644 example/ruby/ClassSpecs/B.md delete mode 100644 example/ruby/ClassSpecs/C.md delete mode 100644 example/ruby/ClassSpecs/Container.md delete mode 100644 example/ruby/ClassSpecs/Container/A.md delete mode 100644 example/ruby/ClassSpecs/Container/B.md delete mode 100644 example/ruby/ClassSpecs/D.md delete mode 100644 example/ruby/ClassSpecs/E.md delete mode 100644 example/ruby/ClassSpecs/F.md delete mode 100644 example/ruby/ClassSpecs/G.md delete mode 100644 example/ruby/ClassSpecs/H.md delete mode 100644 example/ruby/ClassSpecs/I.md delete mode 100644 example/ruby/ClassSpecs/I/J.md delete mode 100644 example/ruby/ClassSpecs/K.md delete mode 100644 example/ruby/ClassSpecs/L.md delete mode 100644 example/ruby/ClassSpecs/M.md delete mode 100644 example/ruby/ClassVariablesSpec.md delete mode 100644 example/ruby/ClassVariablesSpec/ClassA.md delete mode 100644 example/ruby/ClassVariablesSpec/ClassB.md delete mode 100644 example/ruby/ClassVariablesSpec/ClassC.md delete mode 100644 example/ruby/ClassVariablesSpec/ModuleM.md delete mode 100644 example/ruby/ClassVariablesSpec/ModuleN.md delete mode 100644 example/ruby/ClassVariablesSpec/ModuleO.md delete mode 100644 example/ruby/Clock.md delete mode 100644 example/ruby/ClosedQueueError.md delete mode 100644 example/ruby/CodeLoadingSpecs.md delete mode 100644 example/ruby/CodeLoadingSpecs/Method.md delete mode 100644 example/ruby/CodingUS_ASCII.md delete mode 100644 example/ruby/CodingUTF_8.md delete mode 100644 example/ruby/Colorize.md delete mode 100644 example/ruby/CommandSyntaxError.md delete mode 100644 example/ruby/CommentStripper.md delete mode 100644 example/ruby/CompactIndexAPI.md delete mode 100644 example/ruby/CompactIndexApiMissing.md delete mode 100644 example/ruby/CompactIndexBasicAuthentication.md delete mode 100644 example/ruby/CompactIndexChecksumMismatch.md delete mode 100644 example/ruby/CompactIndexConcurrentDownload.md delete mode 100644 example/ruby/CompactIndexCredsDiffHost.md delete mode 100644 example/ruby/CompactIndexEtagMatch.md delete mode 100644 example/ruby/CompactIndexExtra.md delete mode 100644 example/ruby/CompactIndexExtraAPIMissing.md delete mode 100644 example/ruby/CompactIndexExtraApi.md delete mode 100644 example/ruby/CompactIndexExtraMissing.md delete mode 100644 example/ruby/CompactIndexForbidden.md delete mode 100644 example/ruby/CompactIndexHostRedirect.md delete mode 100644 example/ruby/CompactIndexNoGem.md delete mode 100644 example/ruby/CompactIndexPartialUpdate.md delete mode 100644 example/ruby/CompactIndexPartialUpdateBadDigest.md delete mode 100644 example/ruby/CompactIndexPartialUpdateNoDigestNotIncremental.md delete mode 100644 example/ruby/CompactIndexPrecompiledBefore.md delete mode 100644 example/ruby/CompactIndexRangeIgnored.md delete mode 100644 example/ruby/CompactIndexRangeNotSatisfiable.md delete mode 100644 example/ruby/CompactIndexRateLimited.md delete mode 100644 example/ruby/CompactIndexRateLimited/RequestCounter.md delete mode 100644 example/ruby/CompactIndexRedirect.md delete mode 100644 example/ruby/CompactIndexStrictBasicAuthentication.md delete mode 100644 example/ruby/CompactIndexWrongDependencies.md delete mode 100644 example/ruby/CompactIndexWrongGemChecksum.md delete mode 100644 example/ruby/Comparable.md delete mode 100644 example/ruby/ComparableSpecs.md delete mode 100644 example/ruby/ComparableSpecs/CompareCallingSuper.md delete mode 100644 example/ruby/ComparableSpecs/Weird.md delete mode 100644 example/ruby/ComparableSpecs/WithOnlyCompareDefined.md delete mode 100644 example/ruby/ComparableSpecs/WithoutCompareDefined.md delete mode 100644 example/ruby/CompileWarning.md delete mode 100644 example/ruby/ComplainMatcher.md delete mode 100644 example/ruby/Complex.md delete mode 100644 example/ruby/Complex/compatible.md delete mode 100644 example/ruby/ComplexRational_Test.md delete mode 100644 example/ruby/ComplexSub.md delete mode 100644 example/ruby/Complex_Test.md delete mode 100644 example/ruby/Complex_Test/ObjectX.md delete mode 100644 example/ruby/Complex_Test2.md delete mode 100644 example/ruby/ConflictsGuard.md delete mode 100644 example/ruby/Const.md delete mode 100644 example/ruby/Const2.md delete mode 100644 example/ruby/ConstantLeakError.md delete mode 100644 example/ruby/ConstantSpecs.md delete mode 100644 example/ruby/ConstantSpecs/ClassA.md delete mode 100644 example/ruby/ConstantSpecs/ClassB.md delete mode 100644 example/ruby/ConstantSpecs/ClassC.md delete mode 100644 example/ruby/ConstantSpecs/ClassC/ClassE.md delete mode 100644 example/ruby/ConstantSpecs/ClassD.md delete mode 100644 example/ruby/ConstantSpecs/ConstSource.md delete mode 100644 example/ruby/ConstantSpecs/ContainerA.md delete mode 100644 example/ruby/ConstantSpecs/ContainerA/ChildA.md delete mode 100644 example/ruby/ConstantSpecs/ContainerB.md delete mode 100644 example/ruby/ConstantSpecs/ContainerB/ChildB.md delete mode 100644 example/ruby/ConstantSpecs/ContainerPrepend.md delete mode 100644 example/ruby/ConstantSpecs/ModuleA.md delete mode 100644 example/ruby/ConstantSpecs/ModuleB.md delete mode 100644 example/ruby/ConstantSpecs/ModuleC.md delete mode 100644 example/ruby/ConstantSpecs/ModuleD.md delete mode 100644 example/ruby/ConstantSpecs/ModuleE.md delete mode 100644 example/ruby/ConstantSpecs/ModuleF.md delete mode 100644 example/ruby/ConstantSpecs/ModuleG.md delete mode 100644 example/ruby/ConstantSpecs/ModuleH.md delete mode 100644 example/ruby/ConstantSpecs/ModuleIncludePrepended.md delete mode 100644 example/ruby/ConstantSpecs/ModuleM.md delete mode 100644 example/ruby/ConstantSpecs/ParentA.md delete mode 100644 example/ruby/ConstantSpecs/ParentB.md delete mode 100644 example/ruby/ConstantSpecsThree.md delete mode 100644 example/ruby/ConstantSpecsThree/ConstantSpecsTwo.md delete mode 100644 example/ruby/ConstantSpecsTwo.md delete mode 100644 example/ruby/ConstantUnicodeSpecs.md delete mode 100644 example/ruby/ConstantVisibility.md delete mode 100644 example/ruby/ConstantVisibility/ClassContainer.md delete mode 100644 example/ruby/ConstantVisibility/ClassIncludingPrivConstModule.md delete mode 100644 example/ruby/ConstantVisibility/ModuleContainer.md delete mode 100644 example/ruby/ConstantVisibility/ModuleIncludingPrivConstModule.md delete mode 100644 example/ruby/ConstantVisibility/PrivConstClass.md delete mode 100644 example/ruby/ConstantVisibility/PrivConstClass/Nested.md delete mode 100644 example/ruby/ConstantVisibility/PrivConstClassChild.md delete mode 100644 example/ruby/ConstantVisibility/PrivConstModule.md delete mode 100644 example/ruby/ConstantVisibility/PrivConstModule/Nested.md delete mode 100644 example/ruby/ConstantsLeakCheckerAction.md delete mode 100644 example/ruby/ConstantsLockFile.md delete mode 100644 example/ruby/ContextState.md delete mode 100644 example/ruby/Continuation.md delete mode 100644 example/ruby/CoreClassSpecs.md delete mode 100644 example/ruby/CoreClassSpecs/A.md delete mode 100644 example/ruby/CoreClassSpecs/F.md delete mode 100644 example/ruby/CoreClassSpecs/H.md delete mode 100644 example/ruby/CoreClassSpecs/Inherited.md delete mode 100644 example/ruby/CoreClassSpecs/Inherited/A.md delete mode 100644 example/ruby/CoreClassSpecs/Inherited/B.md delete mode 100644 example/ruby/CoreClassSpecs/Inherited/C.md delete mode 100644 example/ruby/CoreClassSpecs/Inherited/D.md delete mode 100644 example/ruby/CoreClassSpecs/M.md delete mode 100644 example/ruby/CoreClassSpecs/Record.md delete mode 100644 example/ruby/CoreDumpError.md delete mode 100644 example/ruby/CoreExtensions.md delete mode 100644 example/ruby/CoreExtensions/TCPSocketExt.md delete mode 100644 example/ruby/CoreExtensions/TCPSocketExt/Initializer.md delete mode 100644 example/ruby/Coverage.md delete mode 100644 example/ruby/CoverageSpecs.md delete mode 100644 example/ruby/CrlStore.md delete mode 100644 example/ruby/DQEntry.md delete mode 100644 example/ruby/DRb.md delete mode 100644 example/ruby/DRb/HTTP0.md delete mode 100644 example/ruby/DRb/HTTP0/Callback.md delete mode 100644 example/ruby/DRb/HTTP0/ClientSide.md delete mode 100644 example/ruby/DRb/HTTP0/Server.md delete mode 100644 example/ruby/DRb/HTTP0/ServerSide.md delete mode 100644 example/ruby/DRb/HTTP0/StrStream.md delete mode 100644 example/ruby/DRbEx.md delete mode 100644 example/ruby/DRbEx2.md delete mode 100644 example/ruby/DRbEx3.md delete mode 100644 example/ruby/DRbEx4.md delete mode 100644 example/ruby/DRbNamedIdConv.md delete mode 100644 example/ruby/DRbNamedObject.md delete mode 100644 example/ruby/DSL.md delete mode 100644 example/ruby/DSL/Var.md delete mode 100644 example/ruby/DSL/Var/Table.md delete mode 100644 example/ruby/DTrace.md delete mode 100644 example/ruby/DTrace/TestArrayCreate.md delete mode 100644 example/ruby/DTrace/TestCMethod.md delete mode 100644 example/ruby/DTrace/TestCase.md delete mode 100644 example/ruby/DTrace/TestFunctionEntry.md delete mode 100644 example/ruby/DTrace/TestGC.md delete mode 100644 example/ruby/DTrace/TestHashCreate.md delete mode 100644 example/ruby/DTrace/TestLoad.md delete mode 100644 example/ruby/DTrace/TestMethodCacheClear.md delete mode 100644 example/ruby/DTrace/TestObjectCreateStart.md delete mode 100644 example/ruby/DTrace/TestRaise.md delete mode 100644 example/ruby/DTrace/TestRequire.md delete mode 100644 example/ruby/DTrace/TestSingletonFunctionEntry.md delete mode 100644 example/ruby/DTrace/TestStringProbes.md delete mode 100644 example/ruby/DataSpecs.md delete mode 100644 example/ruby/Data_.md delete mode 100644 example/ruby/Date.md delete mode 100644 example/ruby/Date/Error.md delete mode 100644 example/ruby/Date/Infinity.md delete mode 100644 example/ruby/DateSub.md delete mode 100644 example/ruby/DateTime.md delete mode 100644 example/ruby/DateTimeSub.md delete mode 100644 example/ruby/DebugPOpen.md delete mode 100644 example/ruby/DebugSystem.md delete mode 100644 example/ruby/DefineMethodSpecClass.md delete mode 100644 example/ruby/DefinedSpecs.md delete mode 100644 example/ruby/DefinedSpecs/Basic.md delete mode 100644 example/ruby/DefinedSpecs/Child.md delete mode 100644 example/ruby/DefinedSpecs/ClassUndefiningMethod.md delete mode 100644 example/ruby/DefinedSpecs/ClassWithMethod.md delete mode 100644 example/ruby/DefinedSpecs/ClassWithoutMethod.md delete mode 100644 example/ruby/DefinedSpecs/IntermediateModule1.md delete mode 100644 example/ruby/DefinedSpecs/IntermediateModule2.md delete mode 100644 example/ruby/DefinedSpecs/Mixin.md delete mode 100644 example/ruby/DefinedSpecs/ModuleWithConstMissing.md delete mode 100644 example/ruby/DefinedSpecs/Parent.md delete mode 100644 example/ruby/DefinedSpecs/Super.md delete mode 100644 example/ruby/DefinedSpecs/SuperWithIntermediateModules.md delete mode 100644 example/ruby/DefinedSpecs/Superclass.md delete mode 100644 example/ruby/DelegateSpecs.md delete mode 100644 example/ruby/DelegateSpecs/DelegateClass.md delete mode 100644 example/ruby/DelegateSpecs/Delegator.md delete mode 100644 example/ruby/DelegateSpecs/Extra.md delete mode 100644 example/ruby/DelegateSpecs/Simple.md delete mode 100644 example/ruby/DelegationSpecs.md delete mode 100644 example/ruby/DelegationSpecs/Target.md delete mode 100644 example/ruby/Delegator.md delete mode 100644 example/ruby/DescribeFormatter.md delete mode 100644 example/ruby/DetailedMessageSpec.md delete mode 100644 example/ruby/Dhasen.md delete mode 100644 example/ruby/DidYouMean.md delete mode 100644 example/ruby/DidYouMean/ClassNameChecker.md delete mode 100644 example/ruby/DidYouMean/Correctable.md delete mode 100644 example/ruby/DidYouMean/Formatter.md delete mode 100644 example/ruby/DidYouMean/Jaro.md delete mode 100644 example/ruby/DidYouMean/JaroWinkler.md delete mode 100644 example/ruby/DidYouMean/KeyErrorChecker.md delete mode 100644 example/ruby/DidYouMean/Levenshtein.md delete mode 100644 example/ruby/DidYouMean/MethodNameChecker.md delete mode 100644 example/ruby/DidYouMean/NullChecker.md delete mode 100644 example/ruby/DidYouMean/PatternKeyNameChecker.md delete mode 100644 example/ruby/DidYouMean/RequirePathChecker.md delete mode 100644 example/ruby/DidYouMean/SpellChecker.md delete mode 100644 example/ruby/DidYouMean/TestHelper.md delete mode 100644 example/ruby/DidYouMean/TreeSpellChecker.md delete mode 100644 example/ruby/DidYouMean/VariableNameChecker.md delete mode 100644 example/ruby/DifferentOFS.md delete mode 100644 example/ruby/DifferentOFS/WithDifferentOFS.md delete mode 100644 example/ruby/Digest.md delete mode 100644 example/ruby/Digest/Base.md delete mode 100644 example/ruby/Digest/Class.md delete mode 100644 example/ruby/Digest/DigestError.md delete mode 100644 example/ruby/Digest/Foo.md delete mode 100644 example/ruby/Digest/Instance.md delete mode 100644 example/ruby/Digest/MD5.md delete mode 100644 example/ruby/Digest/RMD160.md delete mode 100644 example/ruby/Digest/SHA1.md delete mode 100644 example/ruby/Digest/SHA2.md delete mode 100644 example/ruby/Digest/SHA256.md delete mode 100644 example/ruby/Digest/SHA384.md delete mode 100644 example/ruby/Digest/SHA512.md delete mode 100644 example/ruby/Dir.md delete mode 100644 example/ruby/Dir/Tmpname.md delete mode 100644 example/ruby/DirSpecs.md delete mode 100644 example/ruby/DivmodSpecs.md delete mode 100644 example/ruby/DottedFormatter.md delete mode 100644 example/ruby/Downloader.md delete mode 100644 example/ruby/Downloader/GNU.md delete mode 100644 example/ruby/Downloader/RubyGems.md delete mode 100644 example/ruby/Downloader/Unicode.md delete mode 100644 example/ruby/ENV.md delete mode 100644 example/ruby/ENVSpecs.md delete mode 100644 example/ruby/EOFError.md delete mode 100644 example/ruby/ERB.md delete mode 100644 example/ruby/ERB/Compiler.md delete mode 100644 example/ruby/ERB/Compiler/Buffer.md delete mode 100644 example/ruby/ERB/Compiler/PercentLine.md delete mode 100644 example/ruby/ERB/Compiler/Scanner.md delete mode 100644 example/ruby/ERB/Compiler/TrimScanner.md delete mode 100644 example/ruby/ERB/DefMethod.md delete mode 100644 example/ruby/ERB/Escape.md delete mode 100644 example/ruby/ERB/Util.md delete mode 100644 example/ruby/ERBSpecs.md delete mode 100644 example/ruby/Emoji.md delete mode 100644 example/ruby/Emoji/TestDoCoMo.md delete mode 100644 example/ruby/Emoji/TestKDDI.md delete mode 100644 example/ruby/Emoji/TestRenameSJIS.md delete mode 100644 example/ruby/Emoji/TestSoftBank.md delete mode 100644 example/ruby/Emoji/TestUTF8_BLACK_SUN_WITH_RAYS.md delete mode 100644 example/ruby/EmojiTable.md delete mode 100644 example/ruby/Encoding.md delete mode 100644 example/ruby/Encoding/CompatibilityError.md delete mode 100644 example/ruby/Encoding/Converter.md delete mode 100644 example/ruby/Encoding/ConverterNotFoundError.md delete mode 100644 example/ruby/Encoding/InvalidByteSequenceError.md delete mode 100644 example/ruby/Encoding/UndefinedConversionError.md delete mode 100644 example/ruby/EncodingError.md delete mode 100644 example/ruby/EncodingSpecs.md delete mode 100644 example/ruby/EncodingSpecs/InvalidByteSequenceError.md delete mode 100644 example/ruby/EncodingSpecs/InvalidByteSequenceErrorIndirect.md delete mode 100644 example/ruby/EncodingSpecs/UndefinedConversionError.md delete mode 100644 example/ruby/EncodingSpecs/UndefinedConversionErrorIndirect.md delete mode 100644 example/ruby/EndianGuard.md delete mode 100644 example/ruby/Endpoint.md delete mode 100644 example/ruby/Endpoint500.md delete mode 100644 example/ruby/EndpointApiForbidden.md delete mode 100644 example/ruby/EndpointBasicAuthentication.md delete mode 100644 example/ruby/EndpointCredsDiffHost.md delete mode 100644 example/ruby/EndpointExtra.md delete mode 100644 example/ruby/EndpointExtraApi.md delete mode 100644 example/ruby/EndpointExtraMissing.md delete mode 100644 example/ruby/EndpointFallback.md delete mode 100644 example/ruby/EndpointHostRedirect.md delete mode 100644 example/ruby/EndpointMarshalFail.md delete mode 100644 example/ruby/EndpointMarshalFailBasicAuthentication.md delete mode 100644 example/ruby/EndpointMirrorSource.md delete mode 100644 example/ruby/EndpointRedirect.md delete mode 100644 example/ruby/EndpointStrictBasicAuthentication.md delete mode 100644 example/ruby/EndpointTimeout.md delete mode 100644 example/ruby/English.md delete mode 100644 example/ruby/EnsureAndCallcc.md delete mode 100644 example/ruby/EnsureSpec.md delete mode 100644 example/ruby/EnsureSpec/Container.md delete mode 100644 example/ruby/EnsureSpec/Error.md delete mode 100644 example/ruby/EnsureSpec/Test.md delete mode 100644 example/ruby/EnumSpecs.md delete mode 100644 example/ruby/EnumSpecs/Numerous.md delete mode 100644 example/ruby/Enumerable.md delete mode 100644 example/ruby/EnumerableSpecs.md delete mode 100644 example/ruby/EnumerableSpecs/ArrayConvertible.md delete mode 100644 example/ruby/EnumerableSpecs/ComparableWithInteger.md delete mode 100644 example/ruby/EnumerableSpecs/ComparesByVowelCount.md delete mode 100644 example/ruby/EnumerableSpecs/EachCounter.md delete mode 100644 example/ruby/EnumerableSpecs/EachDefiner.md delete mode 100644 example/ruby/EnumerableSpecs/Empty.md delete mode 100644 example/ruby/EnumerableSpecs/EmptyWithSize.md delete mode 100644 example/ruby/EnumerableSpecs/EnumConvertible.md delete mode 100644 example/ruby/EnumerableSpecs/Equals.md delete mode 100644 example/ruby/EnumerableSpecs/Freezy.md delete mode 100644 example/ruby/EnumerableSpecs/InvalidComparable.md delete mode 100644 example/ruby/EnumerableSpecs/MapReturnsEnumerable.md delete mode 100644 example/ruby/EnumerableSpecs/MapReturnsEnumerable/EnumerableMapping.md delete mode 100644 example/ruby/EnumerableSpecs/NoEach.md delete mode 100644 example/ruby/EnumerableSpecs/Numerous.md delete mode 100644 example/ruby/EnumerableSpecs/NumerousWithSize.md delete mode 100644 example/ruby/EnumerableSpecs/Pattern.md delete mode 100644 example/ruby/EnumerableSpecs/ReverseComparable.md delete mode 100644 example/ruby/EnumerableSpecs/SortByDummy.md delete mode 100644 example/ruby/EnumerableSpecs/ThrowingEach.md delete mode 100644 example/ruby/EnumerableSpecs/Uncomparable.md delete mode 100644 example/ruby/EnumerableSpecs/Undupable.md delete mode 100644 example/ruby/EnumerableSpecs/YieldsMixed.md delete mode 100644 example/ruby/EnumerableSpecs/YieldsMixed2.md delete mode 100644 example/ruby/EnumerableSpecs/YieldsMulti.md delete mode 100644 example/ruby/EnumerableSpecs/YieldsMultiWithFalse.md delete mode 100644 example/ruby/EnumerableSpecs/YieldsMultiWithSingleTrue.md delete mode 100644 example/ruby/Enumerator.md delete mode 100644 example/ruby/Enumerator/ArithmeticSequence.md delete mode 100644 example/ruby/Enumerator/Chain.md delete mode 100644 example/ruby/Enumerator/Generator.md delete mode 100644 example/ruby/Enumerator/Lazy.md delete mode 100644 example/ruby/Enumerator/Producer.md delete mode 100644 example/ruby/Enumerator/Product.md delete mode 100644 example/ruby/Enumerator/Yielder.md delete mode 100644 example/ruby/EnumeratorLazySpecs.md delete mode 100644 example/ruby/EnumeratorLazySpecs/EventsMixed.md delete mode 100644 example/ruby/EnumeratorLazySpecs/SpecificError.md delete mode 100644 example/ruby/EnumeratorLazySpecs/YieldsMixed.md delete mode 100644 example/ruby/EnumeratorSpecs.md delete mode 100644 example/ruby/EnumeratorSpecs/Feed.md delete mode 100644 example/ruby/EnvUtil.md delete mode 100644 example/ruby/EqlMatcher.md delete mode 100644 example/ruby/EqualElementMatcher.md delete mode 100644 example/ruby/EqualMatcher.md delete mode 100644 example/ruby/Errno.md delete mode 100644 example/ruby/ErrorHighlight.md delete mode 100644 example/ruby/ErrorHighlight/CoreExt.md delete mode 100644 example/ruby/ErrorHighlight/DefaultFormatter.md delete mode 100644 example/ruby/ErrorHighlightTest.md delete mode 100644 example/ruby/ErrorHighlightTest/DummyFormatter.md delete mode 100644 example/ruby/ErrorHighlightTest/OP_CDECL_TEST.md delete mode 100644 example/ruby/Etc.md delete mode 100644 example/ruby/Etc/Group.md delete mode 100644 example/ruby/Etc/Passwd.md delete mode 100644 example/ruby/EvTest.md delete mode 100644 example/ruby/EvalSpecs.md delete mode 100644 example/ruby/EvalSpecs/A.md delete mode 100644 example/ruby/EvalSpecs/CoercedObject.md delete mode 100644 example/ruby/EvalTest.md delete mode 100644 example/ruby/ExampleState.md delete mode 100644 example/ruby/Exception.md delete mode 100644 example/ruby/ExceptionSpecs.md delete mode 100644 example/ruby/ExceptionSpecs/Backtrace.md delete mode 100644 example/ruby/ExceptionSpecs/ConstructorException.md delete mode 100644 example/ruby/ExceptionSpecs/EmptyToS.md delete mode 100644 example/ruby/ExceptionSpecs/ExceptionModule.md delete mode 100644 example/ruby/ExceptionSpecs/Exceptional.md delete mode 100644 example/ruby/ExceptionSpecs/InitializeException.md delete mode 100644 example/ruby/ExceptionSpecs/OverrideToS.md delete mode 100644 example/ruby/ExceptionSpecs/UnExceptional.md delete mode 100644 example/ruby/ExceptionState.md delete mode 100644 example/ruby/ExpectedException.md delete mode 100644 example/ruby/Exports.md delete mode 100644 example/ruby/Exports/Cygwin.md delete mode 100644 example/ruby/Exports/Mingw.md delete mode 100644 example/ruby/Exports/Mswin.md delete mode 100644 example/ruby/Exports/Msys.md delete mode 100644 example/ruby/ExtArray.md delete mode 100644 example/ruby/ExtLibs.md delete mode 100644 example/ruby/ExtLibs/Colorize.md delete mode 100644 example/ruby/ExtLibs/Vars.md delete mode 100644 example/ruby/Fail.md delete mode 100644 example/ruby/FalseClass.md delete mode 100644 example/ruby/Fcntl.md delete mode 100644 example/ruby/FeatureGuard.md delete mode 100644 example/ruby/Fiber.md delete mode 100644 example/ruby/Fiber/Pool.md delete mode 100644 example/ruby/Fiber/Scheduler.md delete mode 100644 example/ruby/FiberError.md delete mode 100644 example/ruby/FiberSpecs.md delete mode 100644 example/ruby/FiberSpecs/CustomError.md delete mode 100644 example/ruby/FiberSpecs/NewFiberToRaise.md delete mode 100644 example/ruby/Fiddle.md delete mode 100644 example/ruby/Fiddle/BasicTypes.md delete mode 100644 example/ruby/Fiddle/CParser.md delete mode 100644 example/ruby/Fiddle/CStruct.md delete mode 100644 example/ruby/Fiddle/CStructBuilder.md delete mode 100644 example/ruby/Fiddle/CStructEntity.md delete mode 100644 example/ruby/Fiddle/CUnion.md delete mode 100644 example/ruby/Fiddle/CUnionEntity.md delete mode 100644 example/ruby/Fiddle/ClearedReferenceError.md delete mode 100644 example/ruby/Fiddle/Closure.md delete mode 100644 example/ruby/Fiddle/Closure/BlockCaller.md delete mode 100644 example/ruby/Fiddle/CompositeHandler.md delete mode 100644 example/ruby/Fiddle/DLError.md delete mode 100644 example/ruby/Fiddle/Error.md delete mode 100644 example/ruby/Fiddle/FFIBackend.md delete mode 100644 example/ruby/Fiddle/Function.md delete mode 100644 example/ruby/Fiddle/Handle.md delete mode 100644 example/ruby/Fiddle/Importer.md delete mode 100644 example/ruby/Fiddle/LIBC.md delete mode 100644 example/ruby/Fiddle/MemoryView.md delete mode 100644 example/ruby/Fiddle/PackInfo.md delete mode 100644 example/ruby/Fiddle/Packer.md delete mode 100644 example/ruby/Fiddle/Pinned.md delete mode 100644 example/ruby/Fiddle/Pointer.md delete mode 100644 example/ruby/Fiddle/Pointer/LibC.md delete mode 100644 example/ruby/Fiddle/StructArray.md delete mode 100644 example/ruby/Fiddle/TestCParser.md delete mode 100644 example/ruby/Fiddle/TestCStructBuilder.md delete mode 100644 example/ruby/Fiddle/TestCStructEntity.md delete mode 100644 example/ruby/Fiddle/TestCUnionEntity.md delete mode 100644 example/ruby/Fiddle/TestCase.md delete mode 100644 example/ruby/Fiddle/TestClosure.md delete mode 100644 example/ruby/Fiddle/TestFunc.md delete mode 100644 example/ruby/Fiddle/TestFunction.md delete mode 100644 example/ruby/Fiddle/TestHandle.md delete mode 100644 example/ruby/Fiddle/TestImport.md delete mode 100644 example/ruby/Fiddle/TestMemoryView.md delete mode 100644 example/ruby/Fiddle/TestPack.md delete mode 100644 example/ruby/Fiddle/TestPinned.md delete mode 100644 example/ruby/Fiddle/TestPointer.md delete mode 100644 example/ruby/Fiddle/TestPointer/MimicInteger.md delete mode 100644 example/ruby/Fiddle/Types.md delete mode 100644 example/ruby/Fiddle/ValueUtil.md delete mode 100644 example/ruby/Fiddle/Win32Types.md delete mode 100644 example/ruby/File.md delete mode 100644 example/ruby/File/Constants.md delete mode 100644 example/ruby/File/Stat.md delete mode 100644 example/ruby/FileFormatter.md delete mode 100644 example/ruby/FileSpecs.md delete mode 100644 example/ruby/FileSpecs/SubString.md delete mode 100644 example/ruby/FileStat.md delete mode 100644 example/ruby/FileTest.md delete mode 100644 example/ruby/FileUtils.md delete mode 100644 example/ruby/FileUtils/DryRun.md delete mode 100644 example/ruby/FileUtils/Entry_.md delete mode 100644 example/ruby/FileUtils/LowMethods.md delete mode 100644 example/ruby/FileUtils/NoWrite.md delete mode 100644 example/ruby/FileUtils/StreamUtils_.md delete mode 100644 example/ruby/FileUtils/Verbose.md delete mode 100644 example/ruby/Find.md delete mode 100644 example/ruby/FindDirSpecs.md delete mode 100644 example/ruby/FindMethodComments.md delete mode 100644 example/ruby/Float.md delete mode 100644 example/ruby/FloatDomainError.md delete mode 100644 example/ruby/FloatSpecs.md delete mode 100644 example/ruby/FloatSpecs/CanCoerce.md delete mode 100644 example/ruby/FloatSpecs/CoerceError.md delete mode 100644 example/ruby/Foo.md delete mode 100644 example/ruby/Foo/Unknown.md delete mode 100644 example/ruby/FooError.md delete mode 100644 example/ruby/ForSpecs.md delete mode 100644 example/ruby/ForSpecs/ForInClassMethod.md delete mode 100644 example/ruby/FormatterOverrides.md delete mode 100644 example/ruby/Forwardable.md delete mode 100644 example/ruby/Front.md delete mode 100644 example/ruby/FrozenError.md delete mode 100644 example/ruby/GC.md delete mode 100644 example/ruby/GC/Profiler.md delete mode 100644 example/ruby/GCCompactChecker.md delete mode 100644 example/ruby/GCDisabledChecker.md delete mode 100644 example/ruby/Gem.md delete mode 100644 example/ruby/Gem/AvailableSet.md delete mode 100644 example/ruby/Gem/AvailableSet/Tuple.md delete mode 100644 example/ruby/Gem/BUNDLED_GEMS.md delete mode 100644 example/ruby/Gem/BasicSpecification.md delete mode 100644 example/ruby/Gem/BetterPermissionError.md delete mode 100644 example/ruby/Gem/BundlerVersionFinder.md delete mode 100644 example/ruby/Gem/CIDetector.md delete mode 100644 example/ruby/Gem/Command.md delete mode 100644 example/ruby/Gem/CommandLineError.md delete mode 100644 example/ruby/Gem/CommandManager.md delete mode 100644 example/ruby/Gem/Commands.md delete mode 100644 example/ruby/Gem/Commands/BuildCommand.md delete mode 100644 example/ruby/Gem/Commands/CertCommand.md delete mode 100644 example/ruby/Gem/Commands/CheckCommand.md delete mode 100644 example/ruby/Gem/Commands/CleanupCommand.md delete mode 100644 example/ruby/Gem/Commands/ContentsCommand.md delete mode 100644 example/ruby/Gem/Commands/CrashCommand.md delete mode 100644 example/ruby/Gem/Commands/DependencyCommand.md delete mode 100644 example/ruby/Gem/Commands/EnvironmentCommand.md delete mode 100644 example/ruby/Gem/Commands/ExecCommand.md delete mode 100644 example/ruby/Gem/Commands/FetchCommand.md delete mode 100644 example/ruby/Gem/Commands/GenerateIndexCommand.md delete mode 100644 example/ruby/Gem/Commands/HelpCommand.md delete mode 100644 example/ruby/Gem/Commands/InfoCommand.md delete mode 100644 example/ruby/Gem/Commands/InsCommand.md delete mode 100644 example/ruby/Gem/Commands/InstallCommand.md delete mode 100644 example/ruby/Gem/Commands/InterruptCommand.md delete mode 100644 example/ruby/Gem/Commands/ListCommand.md delete mode 100644 example/ruby/Gem/Commands/LockCommand.md delete mode 100644 example/ruby/Gem/Commands/MirrorCommand.md delete mode 100644 example/ruby/Gem/Commands/OpenCommand.md delete mode 100644 example/ruby/Gem/Commands/OutdatedCommand.md delete mode 100644 example/ruby/Gem/Commands/OwnerCommand.md delete mode 100644 example/ruby/Gem/Commands/PristineCommand.md delete mode 100644 example/ruby/Gem/Commands/PushCommand.md delete mode 100644 example/ruby/Gem/Commands/QueryCommand.md delete mode 100644 example/ruby/Gem/Commands/RdocCommand.md delete mode 100644 example/ruby/Gem/Commands/RebuildCommand.md delete mode 100644 example/ruby/Gem/Commands/SearchCommand.md delete mode 100644 example/ruby/Gem/Commands/ServerCommand.md delete mode 100644 example/ruby/Gem/Commands/SetupCommand.md delete mode 100644 example/ruby/Gem/Commands/SetupCommand/MakeDirs.md delete mode 100644 example/ruby/Gem/Commands/SigninCommand.md delete mode 100644 example/ruby/Gem/Commands/SignoutCommand.md delete mode 100644 example/ruby/Gem/Commands/SourcesCommand.md delete mode 100644 example/ruby/Gem/Commands/SpecificationCommand.md delete mode 100644 example/ruby/Gem/Commands/StaleCommand.md delete mode 100644 example/ruby/Gem/Commands/UninstallCommand.md delete mode 100644 example/ruby/Gem/Commands/UnpackCommand.md delete mode 100644 example/ruby/Gem/Commands/UpdateCommand.md delete mode 100644 example/ruby/Gem/Commands/WhichCommand.md delete mode 100644 example/ruby/Gem/Commands/YankCommand.md delete mode 100644 example/ruby/Gem/ConfigFile.md delete mode 100644 example/ruby/Gem/ConflictError.md delete mode 100644 example/ruby/Gem/ConsoleUI.md delete mode 100644 example/ruby/Gem/DefaultUserInteraction.md delete mode 100644 example/ruby/Gem/Dependency.md delete mode 100644 example/ruby/Gem/Dependency/FilterIgnoredSpecs.md delete mode 100644 example/ruby/Gem/DependencyError.md delete mode 100644 example/ruby/Gem/DependencyInstaller.md delete mode 100644 example/ruby/Gem/DependencyList.md delete mode 100644 example/ruby/Gem/DependencyRemovalException.md delete mode 100644 example/ruby/Gem/DependencyResolutionError.md delete mode 100644 example/ruby/Gem/Deprecate.md delete mode 100644 example/ruby/Gem/Doctor.md delete mode 100644 example/ruby/Gem/DocumentError.md delete mode 100644 example/ruby/Gem/EndOfYAMLException.md delete mode 100644 example/ruby/Gem/ErrorReason.md delete mode 100644 example/ruby/Gem/Exception.md delete mode 100644 example/ruby/Gem/Ext.md delete mode 100644 example/ruby/Gem/Ext/BuildError.md delete mode 100644 example/ruby/Gem/Ext/Builder.md delete mode 100644 example/ruby/Gem/Ext/CargoBuilder.md delete mode 100644 example/ruby/Gem/Ext/CargoBuilder/DylibNotFoundError.md delete mode 100644 example/ruby/Gem/Ext/CargoBuilder/LinkFlagConverter.md delete mode 100644 example/ruby/Gem/Ext/CmakeBuilder.md delete mode 100644 example/ruby/Gem/Ext/ConfigureBuilder.md delete mode 100644 example/ruby/Gem/Ext/ExtConfBuilder.md delete mode 100644 example/ruby/Gem/Ext/RakeBuilder.md delete mode 100644 example/ruby/Gem/FakeFetcher.md delete mode 100644 example/ruby/Gem/FakeFetcher/FakeSocket.md delete mode 100644 example/ruby/Gem/FilePermissionError.md delete mode 100644 example/ruby/Gem/FixFullNameEncoding.md delete mode 100644 example/ruby/Gem/FormatException.md delete mode 100644 example/ruby/Gem/GemNotFoundException.md delete mode 100644 example/ruby/Gem/GemNotInHomeException.md delete mode 100644 example/ruby/Gem/GemRunner.md delete mode 100644 example/ruby/Gem/GemcutterUtilities.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnListener.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnListener/BadRequestResponse.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnListener/MethodNotAllowedResponse.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnListener/NoContentResponse.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnListener/NotFoundResponse.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnListener/OkResponse.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnListener/Response.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnListener/SocketResponder.md delete mode 100644 example/ruby/Gem/GemcutterUtilities/WebauthnPoller.md delete mode 100644 example/ruby/Gem/GemspecHelpers.md delete mode 100644 example/ruby/Gem/HTTPResponseFactory.md delete mode 100644 example/ruby/Gem/ImpossibleDependenciesError.md delete mode 100644 example/ruby/Gem/InstallError.md delete mode 100644 example/ruby/Gem/InstallUpdateOptions.md delete mode 100644 example/ruby/Gem/Installer.md delete mode 100644 example/ruby/Gem/Installer/FakePackage.md delete mode 100644 example/ruby/Gem/InstallerTestCase.md delete mode 100644 example/ruby/Gem/InstallerUninstallerUtils.md delete mode 100644 example/ruby/Gem/InvalidSpecificationException.md delete mode 100644 example/ruby/Gem/Licenses.md delete mode 100644 example/ruby/Gem/List.md delete mode 100644 example/ruby/Gem/LoadError.md delete mode 100644 example/ruby/Gem/LocalRemoteOptions.md delete mode 100644 example/ruby/Gem/MissingSpecError.md delete mode 100644 example/ruby/Gem/MissingSpecVersionError.md delete mode 100644 example/ruby/Gem/MockBrowser.md delete mode 100644 example/ruby/Gem/MockGemUi.md delete mode 100644 example/ruby/Gem/MockGemUi/InputEOFError.md delete mode 100644 example/ruby/Gem/MockGemUi/SystemExitException.md delete mode 100644 example/ruby/Gem/MockGemUi/TTY.md delete mode 100644 example/ruby/Gem/MockGemUi/TermError.md delete mode 100644 example/ruby/Gem/MockTCPServer.md delete mode 100644 example/ruby/Gem/Molinillo.md delete mode 100644 example/ruby/Gem/Molinillo/CircularDependencyError.md delete mode 100644 example/ruby/Gem/Molinillo/Delegates/ResolutionState.md delete mode 100644 example/ruby/Gem/Molinillo/Delegates/SpecificationProvider.md delete mode 100644 example/ruby/Gem/Molinillo/DependencyGraph.md delete mode 100644 example/ruby/Gem/Molinillo/DependencyGraph/Action.md delete mode 100644 example/ruby/Gem/Molinillo/DependencyGraph/Edge.md delete mode 100644 example/ruby/Gem/Molinillo/DependencyGraph/Log.md delete mode 100644 example/ruby/Gem/Molinillo/DependencyGraph/Vertex.md delete mode 100644 example/ruby/Gem/Molinillo/DependencyState.md delete mode 100644 example/ruby/Gem/Molinillo/NoSuchDependencyError.md delete mode 100644 example/ruby/Gem/Molinillo/PossibilityState.md delete mode 100644 example/ruby/Gem/Molinillo/ResolutionState.md delete mode 100644 example/ruby/Gem/Molinillo/Resolver.md delete mode 100644 example/ruby/Gem/Molinillo/Resolver/Resolution.md delete mode 100644 example/ruby/Gem/Molinillo/Resolver/Resolution/Conflict.md delete mode 100644 example/ruby/Gem/Molinillo/Resolver/Resolution/PossibilitySet.md delete mode 100644 example/ruby/Gem/Molinillo/Resolver/Resolution/UnwindDetails.md delete mode 100644 example/ruby/Gem/Molinillo/ResolverError.md delete mode 100644 example/ruby/Gem/Molinillo/SpecificationProvider.md delete mode 100644 example/ruby/Gem/Molinillo/UI.md delete mode 100644 example/ruby/Gem/Molinillo/VersionConflict.md delete mode 100644 example/ruby/Gem/MultifactorAuthFetcher.md delete mode 100644 example/ruby/Gem/NameTuple.md delete mode 100644 example/ruby/Gem/Net.md delete mode 100644 example/ruby/Gem/Net/BufferedIO.md delete mode 100644 example/ruby/Gem/Net/HTTP.md delete mode 100644 example/ruby/Gem/Net/HTTP/Copy.md delete mode 100644 example/ruby/Gem/Net/HTTP/Delete.md delete mode 100644 example/ruby/Gem/Net/HTTP/Get.md delete mode 100644 example/ruby/Gem/Net/HTTP/Head.md delete mode 100644 example/ruby/Gem/Net/HTTP/Lock.md delete mode 100644 example/ruby/Gem/Net/HTTP/Mkcol.md delete mode 100644 example/ruby/Gem/Net/HTTP/Move.md delete mode 100644 example/ruby/Gem/Net/HTTP/Options.md delete mode 100644 example/ruby/Gem/Net/HTTP/Patch.md delete mode 100644 example/ruby/Gem/Net/HTTP/Persistent.md delete mode 100644 example/ruby/Gem/Net/HTTP/Persistent/Connection.md delete mode 100644 example/ruby/Gem/Net/HTTP/Persistent/Error.md delete mode 100644 example/ruby/Gem/Net/HTTP/Persistent/Pool.md delete mode 100644 example/ruby/Gem/Net/HTTP/Persistent/TimedStackMulti.md delete mode 100644 example/ruby/Gem/Net/HTTP/Post.md delete mode 100644 example/ruby/Gem/Net/HTTP/Propfind.md delete mode 100644 example/ruby/Gem/Net/HTTP/Proppatch.md delete mode 100644 example/ruby/Gem/Net/HTTP/ProxyDelta.md delete mode 100644 example/ruby/Gem/Net/HTTP/Put.md delete mode 100644 example/ruby/Gem/Net/HTTP/Trace.md delete mode 100644 example/ruby/Gem/Net/HTTP/Unlock.md delete mode 100644 example/ruby/Gem/Net/HTTPAccepted.md delete mode 100644 example/ruby/Gem/Net/HTTPAlreadyReported.md delete mode 100644 example/ruby/Gem/Net/HTTPBadGateway.md delete mode 100644 example/ruby/Gem/Net/HTTPBadRequest.md delete mode 100644 example/ruby/Gem/Net/HTTPBadResponse.md delete mode 100644 example/ruby/Gem/Net/HTTPClientError.md delete mode 100644 example/ruby/Gem/Net/HTTPClientException.md delete mode 100644 example/ruby/Gem/Net/HTTPConflict.md delete mode 100644 example/ruby/Gem/Net/HTTPContinue.md delete mode 100644 example/ruby/Gem/Net/HTTPCreated.md delete mode 100644 example/ruby/Gem/Net/HTTPEarlyHints.md delete mode 100644 example/ruby/Gem/Net/HTTPError.md delete mode 100644 example/ruby/Gem/Net/HTTPExceptions.md delete mode 100644 example/ruby/Gem/Net/HTTPExpectationFailed.md delete mode 100644 example/ruby/Gem/Net/HTTPFailedDependency.md delete mode 100644 example/ruby/Gem/Net/HTTPFatalError.md delete mode 100644 example/ruby/Gem/Net/HTTPForbidden.md delete mode 100644 example/ruby/Gem/Net/HTTPFound.md delete mode 100644 example/ruby/Gem/Net/HTTPGatewayTimeout.md delete mode 100644 example/ruby/Gem/Net/HTTPGenericRequest.md delete mode 100644 example/ruby/Gem/Net/HTTPGenericRequest/Chunker.md delete mode 100644 example/ruby/Gem/Net/HTTPGone.md delete mode 100644 example/ruby/Gem/Net/HTTPHeader.md delete mode 100644 example/ruby/Gem/Net/HTTPHeaderSyntaxError.md delete mode 100644 example/ruby/Gem/Net/HTTPIMUsed.md delete mode 100644 example/ruby/Gem/Net/HTTPInformation.md delete mode 100644 example/ruby/Gem/Net/HTTPInsufficientStorage.md delete mode 100644 example/ruby/Gem/Net/HTTPInternalServerError.md delete mode 100644 example/ruby/Gem/Net/HTTPLengthRequired.md delete mode 100644 example/ruby/Gem/Net/HTTPLocked.md delete mode 100644 example/ruby/Gem/Net/HTTPLoopDetected.md delete mode 100644 example/ruby/Gem/Net/HTTPMethodNotAllowed.md delete mode 100644 example/ruby/Gem/Net/HTTPMisdirectedRequest.md delete mode 100644 example/ruby/Gem/Net/HTTPMovedPermanently.md delete mode 100644 example/ruby/Gem/Net/HTTPMultiStatus.md delete mode 100644 example/ruby/Gem/Net/HTTPMultipleChoices.md delete mode 100644 example/ruby/Gem/Net/HTTPNetworkAuthenticationRequired.md delete mode 100644 example/ruby/Gem/Net/HTTPNoContent.md delete mode 100644 example/ruby/Gem/Net/HTTPNonAuthoritativeInformation.md delete mode 100644 example/ruby/Gem/Net/HTTPNotAcceptable.md delete mode 100644 example/ruby/Gem/Net/HTTPNotExtended.md delete mode 100644 example/ruby/Gem/Net/HTTPNotFound.md delete mode 100644 example/ruby/Gem/Net/HTTPNotImplemented.md delete mode 100644 example/ruby/Gem/Net/HTTPNotModified.md delete mode 100644 example/ruby/Gem/Net/HTTPOK.md delete mode 100644 example/ruby/Gem/Net/HTTPPartialContent.md delete mode 100644 example/ruby/Gem/Net/HTTPPayloadTooLarge.md delete mode 100644 example/ruby/Gem/Net/HTTPPaymentRequired.md delete mode 100644 example/ruby/Gem/Net/HTTPPermanentRedirect.md delete mode 100644 example/ruby/Gem/Net/HTTPPreconditionFailed.md delete mode 100644 example/ruby/Gem/Net/HTTPPreconditionRequired.md delete mode 100644 example/ruby/Gem/Net/HTTPProcessing.md delete mode 100644 example/ruby/Gem/Net/HTTPProxyAuthenticationRequired.md delete mode 100644 example/ruby/Gem/Net/HTTPRangeNotSatisfiable.md delete mode 100644 example/ruby/Gem/Net/HTTPRedirection.md delete mode 100644 example/ruby/Gem/Net/HTTPRequest.md delete mode 100644 example/ruby/Gem/Net/HTTPRequestHeaderFieldsTooLarge.md delete mode 100644 example/ruby/Gem/Net/HTTPRequestTimeout.md delete mode 100644 example/ruby/Gem/Net/HTTPResetContent.md delete mode 100644 example/ruby/Gem/Net/HTTPResponse.md delete mode 100644 example/ruby/Gem/Net/HTTPResponse/Inflater.md delete mode 100644 example/ruby/Gem/Net/HTTPRetriableError.md delete mode 100644 example/ruby/Gem/Net/HTTPSeeOther.md delete mode 100644 example/ruby/Gem/Net/HTTPServerError.md delete mode 100644 example/ruby/Gem/Net/HTTPServiceUnavailable.md delete mode 100644 example/ruby/Gem/Net/HTTPSuccess.md delete mode 100644 example/ruby/Gem/Net/HTTPSwitchProtocol.md delete mode 100644 example/ruby/Gem/Net/HTTPTemporaryRedirect.md delete mode 100644 example/ruby/Gem/Net/HTTPTooManyRequests.md delete mode 100644 example/ruby/Gem/Net/HTTPURITooLong.md delete mode 100644 example/ruby/Gem/Net/HTTPUnauthorized.md delete mode 100644 example/ruby/Gem/Net/HTTPUnavailableForLegalReasons.md delete mode 100644 example/ruby/Gem/Net/HTTPUnknownResponse.md delete mode 100644 example/ruby/Gem/Net/HTTPUnprocessableEntity.md delete mode 100644 example/ruby/Gem/Net/HTTPUnsupportedMediaType.md delete mode 100644 example/ruby/Gem/Net/HTTPUpgradeRequired.md delete mode 100644 example/ruby/Gem/Net/HTTPUseProxy.md delete mode 100644 example/ruby/Gem/Net/HTTPVariantAlsoNegotiates.md delete mode 100644 example/ruby/Gem/Net/HTTPVersionNotSupported.md delete mode 100644 example/ruby/Gem/Net/InternetMessageIO.md delete mode 100644 example/ruby/Gem/Net/NetPrivate.md delete mode 100644 example/ruby/Gem/Net/OpenTimeout.md delete mode 100644 example/ruby/Gem/Net/ProtoAuthError.md delete mode 100644 example/ruby/Gem/Net/ProtoCommandError.md delete mode 100644 example/ruby/Gem/Net/ProtoFatalError.md delete mode 100644 example/ruby/Gem/Net/ProtoRetriableError.md delete mode 100644 example/ruby/Gem/Net/ProtoServerError.md delete mode 100644 example/ruby/Gem/Net/ProtoSyntaxError.md delete mode 100644 example/ruby/Gem/Net/ProtoUnknownError.md delete mode 100644 example/ruby/Gem/Net/Protocol.md delete mode 100644 example/ruby/Gem/Net/ProtocolError.md delete mode 100644 example/ruby/Gem/Net/ReadAdapter.md delete mode 100644 example/ruby/Gem/Net/ReadTimeout.md delete mode 100644 example/ruby/Gem/Net/WriteAdapter.md delete mode 100644 example/ruby/Gem/Net/WriteTimeout.md delete mode 100644 example/ruby/Gem/NoAliasYAMLTree.md delete mode 100644 example/ruby/Gem/OperationNotSupportedError.md delete mode 100644 example/ruby/Gem/OptionParser.md delete mode 100644 example/ruby/Gem/OptionParser/AC.md delete mode 100644 example/ruby/Gem/OptionParser/Acceptables.md delete mode 100644 example/ruby/Gem/OptionParser/AmbiguousArgument.md delete mode 100644 example/ruby/Gem/OptionParser/AmbiguousOption.md delete mode 100644 example/ruby/Gem/OptionParser/Arguable.md delete mode 100644 example/ruby/Gem/OptionParser/CompletingHash.md delete mode 100644 example/ruby/Gem/OptionParser/Completion.md delete mode 100644 example/ruby/Gem/OptionParser/InvalidArgument.md delete mode 100644 example/ruby/Gem/OptionParser/InvalidOption.md delete mode 100644 example/ruby/Gem/OptionParser/List.md delete mode 100644 example/ruby/Gem/OptionParser/MissingArgument.md delete mode 100644 example/ruby/Gem/OptionParser/NeedlessArgument.md delete mode 100644 example/ruby/Gem/OptionParser/OptionMap.md delete mode 100644 example/ruby/Gem/OptionParser/ParseError.md delete mode 100644 example/ruby/Gem/OptionParser/Switch.md delete mode 100644 example/ruby/Gem/OptionParser/Switch/NoArgument.md delete mode 100644 example/ruby/Gem/OptionParser/Switch/OptionalArgument.md delete mode 100644 example/ruby/Gem/OptionParser/Switch/PlacedArgument.md delete mode 100644 example/ruby/Gem/OptionParser/Switch/RequiredArgument.md delete mode 100644 example/ruby/Gem/Package.md delete mode 100644 example/ruby/Gem/Package/DigestIO.md delete mode 100644 example/ruby/Gem/Package/Error.md delete mode 100644 example/ruby/Gem/Package/FileSource.md delete mode 100644 example/ruby/Gem/Package/FormatError.md delete mode 100644 example/ruby/Gem/Package/IOSource.md delete mode 100644 example/ruby/Gem/Package/NonSeekableIO.md delete mode 100644 example/ruby/Gem/Package/Old.md delete mode 100644 example/ruby/Gem/Package/PathError.md delete mode 100644 example/ruby/Gem/Package/Source.md delete mode 100644 example/ruby/Gem/Package/SymlinkError.md delete mode 100644 example/ruby/Gem/Package/TarHeader.md delete mode 100644 example/ruby/Gem/Package/TarInvalidError.md delete mode 100644 example/ruby/Gem/Package/TarReader.md delete mode 100644 example/ruby/Gem/Package/TarReader/Entry.md delete mode 100644 example/ruby/Gem/Package/TarTestCase.md delete mode 100644 example/ruby/Gem/Package/TarWriter.md delete mode 100644 example/ruby/Gem/Package/TarWriter/BoundedStream.md delete mode 100644 example/ruby/Gem/Package/TarWriter/FileOverflow.md delete mode 100644 example/ruby/Gem/Package/TarWriter/RestrictedStream.md delete mode 100644 example/ruby/Gem/Package/TooLongFileName.md delete mode 100644 example/ruby/Gem/PackageTask.md delete mode 100644 example/ruby/Gem/PathSupport.md delete mode 100644 example/ruby/Gem/Platform.md delete mode 100644 example/ruby/Gem/PlatformMismatch.md delete mode 100644 example/ruby/Gem/QueryUtils.md delete mode 100644 example/ruby/Gem/RemoteError.md delete mode 100644 example/ruby/Gem/RemoteFetcher.md delete mode 100644 example/ruby/Gem/RemoteFetcher/FetchError.md delete mode 100644 example/ruby/Gem/RemoteFetcher/UnknownHostError.md delete mode 100644 example/ruby/Gem/RemoteInstallationCancelled.md delete mode 100644 example/ruby/Gem/RemoteInstallationSkipped.md delete mode 100644 example/ruby/Gem/RemoteSourceException.md delete mode 100644 example/ruby/Gem/Request.md delete mode 100644 example/ruby/Gem/Request/ConnectionPools.md delete mode 100644 example/ruby/Gem/Request/HTTPPool.md delete mode 100644 example/ruby/Gem/Request/HTTPSPool.md delete mode 100644 example/ruby/Gem/RequestSet.md delete mode 100644 example/ruby/Gem/RequestSet/GemDependencyAPI.md delete mode 100644 example/ruby/Gem/RequestSet/Lockfile.md delete mode 100644 example/ruby/Gem/RequestSet/Lockfile/ParseError.md delete mode 100644 example/ruby/Gem/RequestSet/Lockfile/Parser.md delete mode 100644 example/ruby/Gem/RequestSet/Lockfile/Tokenizer.md delete mode 100644 example/ruby/Gem/RequestSet/Lockfile/Tokenizer/Token.md delete mode 100644 example/ruby/Gem/Requirement.md delete mode 100644 example/ruby/Gem/Requirement/BadRequirementError.md delete mode 100644 example/ruby/Gem/Resolv.md delete mode 100644 example/ruby/Gem/Resolv/DNS.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Config.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Config/NXDomain.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Config/OtherResolvError.md delete mode 100644 example/ruby/Gem/Resolv/DNS/DecodeError.md delete mode 100644 example/ruby/Gem/Resolv/DNS/EncodeError.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Label.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Label/Str.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Message.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Message/MessageDecoder.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Message/MessageEncoder.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Name.md delete mode 100644 example/ruby/Gem/Resolv/DNS/OpCode.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Query.md delete mode 100644 example/ruby/Gem/Resolv/DNS/RCode.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/ConnectedUDP.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/ConnectedUDP/Sender.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/MDNSOneShot.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/RequestError.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/Sender.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/TCP.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/TCP/Sender.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/UnconnectedUDP.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Requester/UnconnectedUDP/Sender.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/ANY.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/CAA.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/CNAME.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/DomainName.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/Generic.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/HINFO.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/IN.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/IN/A.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/IN/AAAA.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/IN/HTTPS.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/IN/SRV.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/IN/SVCB.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/IN/ServiceBinding.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/IN/WKS.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/LOC.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/MINFO.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/MX.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/NS.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/PTR.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/SOA.md delete mode 100644 example/ruby/Gem/Resolv/DNS/Resource/TXT.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam/ALPN.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam/DoHPath.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam/Generic.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam/IPv4Hint.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam/IPv6Hint.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam/Mandatory.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam/NoDefaultALPN.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParam/Port.md delete mode 100644 example/ruby/Gem/Resolv/DNS/SvcParams.md delete mode 100644 example/ruby/Gem/Resolv/Hosts.md delete mode 100644 example/ruby/Gem/Resolv/IPv4.md delete mode 100644 example/ruby/Gem/Resolv/IPv6.md delete mode 100644 example/ruby/Gem/Resolv/LOC.md delete mode 100644 example/ruby/Gem/Resolv/LOC/Alt.md delete mode 100644 example/ruby/Gem/Resolv/LOC/Coord.md delete mode 100644 example/ruby/Gem/Resolv/LOC/Size.md delete mode 100644 example/ruby/Gem/Resolv/MDNS.md delete mode 100644 example/ruby/Gem/Resolv/ResolvError.md delete mode 100644 example/ruby/Gem/Resolv/ResolvTimeout.md delete mode 100644 example/ruby/Gem/Resolver.md delete mode 100644 example/ruby/Gem/Resolver/APISet.md delete mode 100644 example/ruby/Gem/Resolver/APISet/GemParser.md delete mode 100644 example/ruby/Gem/Resolver/APISpecification.md delete mode 100644 example/ruby/Gem/Resolver/ActivationRequest.md delete mode 100644 example/ruby/Gem/Resolver/BestSet.md delete mode 100644 example/ruby/Gem/Resolver/ComposedSet.md delete mode 100644 example/ruby/Gem/Resolver/Conflict.md delete mode 100644 example/ruby/Gem/Resolver/CurrentSet.md delete mode 100644 example/ruby/Gem/Resolver/DependencyRequest.md delete mode 100644 example/ruby/Gem/Resolver/GitSet.md delete mode 100644 example/ruby/Gem/Resolver/GitSpecification.md delete mode 100644 example/ruby/Gem/Resolver/IndexSet.md delete mode 100644 example/ruby/Gem/Resolver/IndexSpecification.md delete mode 100644 example/ruby/Gem/Resolver/InstalledSpecification.md delete mode 100644 example/ruby/Gem/Resolver/InstallerSet.md delete mode 100644 example/ruby/Gem/Resolver/LocalSpecification.md delete mode 100644 example/ruby/Gem/Resolver/LockSet.md delete mode 100644 example/ruby/Gem/Resolver/LockSpecification.md delete mode 100644 example/ruby/Gem/Resolver/RequirementList.md delete mode 100644 example/ruby/Gem/Resolver/Set.md delete mode 100644 example/ruby/Gem/Resolver/SourceSet.md delete mode 100644 example/ruby/Gem/Resolver/SpecSpecification.md delete mode 100644 example/ruby/Gem/Resolver/Specification.md delete mode 100644 example/ruby/Gem/Resolver/Stats.md delete mode 100644 example/ruby/Gem/Resolver/VendorSet.md delete mode 100644 example/ruby/Gem/Resolver/VendorSpecification.md delete mode 100644 example/ruby/Gem/RubyVersionMismatch.md delete mode 100644 example/ruby/Gem/RuntimeRequirementNotMetError.md delete mode 100644 example/ruby/Gem/S3URISigner.md delete mode 100644 example/ruby/Gem/S3URISigner/ConfigurationError.md delete mode 100644 example/ruby/Gem/S3URISigner/InstanceProfileError.md delete mode 100644 example/ruby/Gem/S3URISigner/S3Config.md delete mode 100644 example/ruby/Gem/SafeMarshal.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Array.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Bignum.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Element.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/False.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Float.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Hash.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/HashWithDefaultValue.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Integer.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Nil.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Object.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/ObjectLink.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/String.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/Symbol.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/SymbolLink.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/True.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/UserClass.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/UserDefined.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/UserMarshal.md delete mode 100644 example/ruby/Gem/SafeMarshal/Elements/WithIvars.md delete mode 100644 example/ruby/Gem/SafeMarshal/Reader.md delete mode 100644 example/ruby/Gem/SafeMarshal/Reader/DataTooShortError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Reader/EOFError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Reader/Error.md delete mode 100644 example/ruby/Gem/SafeMarshal/Reader/NegativeLengthError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Reader/NotImplementedError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Reader/UnconsumedBytesError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Reader/UnsupportedVersionError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/StreamPrinter.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby/Error.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby/FormatError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby/MethodCallError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby/TimeTooLargeError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedClassError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedIvarError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedSymbolError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnsupportedError.md delete mode 100644 example/ruby/Gem/SafeMarshal/Visitors/Visitor.md delete mode 100644 example/ruby/Gem/SafeYAML.md delete mode 100644 example/ruby/Gem/SecureRandom.md delete mode 100644 example/ruby/Gem/Security.md delete mode 100644 example/ruby/Gem/Security/Exception.md delete mode 100644 example/ruby/Gem/Security/Policy.md delete mode 100644 example/ruby/Gem/Security/Signer.md delete mode 100644 example/ruby/Gem/Security/TrustDir.md delete mode 100644 example/ruby/Gem/SecurityOption.md delete mode 100644 example/ruby/Gem/SilentUI.md delete mode 100644 example/ruby/Gem/SilentUI/NullIO.md delete mode 100644 example/ruby/Gem/Source.md delete mode 100644 example/ruby/Gem/Source/Git.md delete mode 100644 example/ruby/Gem/Source/Installed.md delete mode 100644 example/ruby/Gem/Source/Local.md delete mode 100644 example/ruby/Gem/Source/Lock.md delete mode 100644 example/ruby/Gem/Source/SpecificFile.md delete mode 100644 example/ruby/Gem/Source/Vendor.md delete mode 100644 example/ruby/Gem/SourceFetchProblem.md delete mode 100644 example/ruby/Gem/SourceList.md delete mode 100644 example/ruby/Gem/SpecFetcher.md delete mode 100644 example/ruby/Gem/SpecificGemNotFoundException.md delete mode 100644 example/ruby/Gem/Specification.md delete mode 100644 example/ruby/Gem/Specification/AllowSettingSource.md delete mode 100644 example/ruby/Gem/Specification/RequirePathFlattener.md delete mode 100644 example/ruby/Gem/SpecificationPolicy.md delete mode 100644 example/ruby/Gem/SpecificationRecord.md delete mode 100644 example/ruby/Gem/StreamUI.md delete mode 100644 example/ruby/Gem/StreamUI/SilentDownloadReporter.md delete mode 100644 example/ruby/Gem/StreamUI/SilentProgressReporter.md delete mode 100644 example/ruby/Gem/StreamUI/SimpleProgressReporter.md delete mode 100644 example/ruby/Gem/StreamUI/ThreadedDownloadReporter.md delete mode 100644 example/ruby/Gem/StreamUI/VerboseProgressReporter.md delete mode 100644 example/ruby/Gem/StubSpecification.md delete mode 100644 example/ruby/Gem/StubSpecification/StubLine.md delete mode 100644 example/ruby/Gem/SystemExitException.md delete mode 100644 example/ruby/Gem/TSort.md delete mode 100644 example/ruby/Gem/TSort/Cyclic.md delete mode 100644 example/ruby/Gem/TargetRbConfig.md delete mode 100644 example/ruby/Gem/TempIO.md delete mode 100644 example/ruby/Gem/TestCase.md delete mode 100644 example/ruby/Gem/TestCase/SpecFetcherSetup.md delete mode 100644 example/ruby/Gem/TestCase/StaticSet.md delete mode 100644 example/ruby/Gem/Text.md delete mode 100644 example/ruby/Gem/Timeout.md delete mode 100644 example/ruby/Gem/Timeout/Error.md delete mode 100644 example/ruby/Gem/Timeout/ExitException.md delete mode 100644 example/ruby/Gem/URI.md delete mode 100644 example/ruby/Gem/URI/BadURIError.md delete mode 100644 example/ruby/Gem/URI/Error.md delete mode 100644 example/ruby/Gem/URI/FTP.md delete mode 100644 example/ruby/Gem/URI/File.md delete mode 100644 example/ruby/Gem/URI/Generic.md delete mode 100644 example/ruby/Gem/URI/HTTP.md delete mode 100644 example/ruby/Gem/URI/HTTPS.md delete mode 100644 example/ruby/Gem/URI/InvalidComponentError.md delete mode 100644 example/ruby/Gem/URI/InvalidURIError.md delete mode 100644 example/ruby/Gem/URI/LDAP.md delete mode 100644 example/ruby/Gem/URI/LDAPS.md delete mode 100644 example/ruby/Gem/URI/MailTo.md delete mode 100644 example/ruby/Gem/URI/RFC2396_Parser.md delete mode 100644 example/ruby/Gem/URI/RFC2396_REGEXP.md delete mode 100644 example/ruby/Gem/URI/RFC2396_REGEXP/PATTERN.md delete mode 100644 example/ruby/Gem/URI/RFC3986_Parser.md delete mode 100644 example/ruby/Gem/URI/Util.md delete mode 100644 example/ruby/Gem/URI/WS.md delete mode 100644 example/ruby/Gem/URI/WSS.md delete mode 100644 example/ruby/Gem/UninstallError.md delete mode 100644 example/ruby/Gem/Uninstaller.md delete mode 100644 example/ruby/Gem/UnknownCommandError.md delete mode 100644 example/ruby/Gem/UnknownCommandSpellChecker.md delete mode 100644 example/ruby/Gem/UnsatisfiableDependencyError.md delete mode 100644 example/ruby/Gem/UpdateSuggestion.md delete mode 100644 example/ruby/Gem/Uri.md delete mode 100644 example/ruby/Gem/UriFormatter.md delete mode 100644 example/ruby/Gem/UserInteraction.md delete mode 100644 example/ruby/Gem/Util.md delete mode 100644 example/ruby/Gem/Validator.md delete mode 100644 example/ruby/Gem/Validator/ErrorData.md delete mode 100644 example/ruby/Gem/VerificationError.md delete mode 100644 example/ruby/Gem/Version.md delete mode 100644 example/ruby/Gem/VersionOption.md delete mode 100644 example/ruby/Gem/WebauthnVerificationError.md delete mode 100644 example/ruby/Gem/YAMLSerializer.md delete mode 100644 example/ruby/GemTest.md delete mode 100644 example/ruby/Git.md delete mode 100644 example/ruby/Gods.md delete mode 100644 example/ruby/HCMSpecs.md delete mode 100644 example/ruby/HIMMSpecs.md delete mode 100644 example/ruby/HIMMSpecs/Subclass.md delete mode 100644 example/ruby/HMACConstants.md delete mode 100644 example/ruby/HMMSpecs.md delete mode 100644 example/ruby/HMMSpecs/Subclass.md delete mode 100644 example/ruby/HPIMMSpecs.md delete mode 100644 example/ruby/HPIMMSpecs/Subclass.md delete mode 100644 example/ruby/HPMMSpecs.md delete mode 100644 example/ruby/HSMMSpecs.md delete mode 100644 example/ruby/HTTPHeaderTest.md delete mode 100644 example/ruby/HTTPHeaderTest/C.md delete mode 100644 example/ruby/HTTPHeaderTest/D.md delete mode 100644 example/ruby/HTTPRequestTest.md delete mode 100644 example/ruby/HTTPResponseTest.md delete mode 100644 example/ruby/HTTPResponsesTest.md delete mode 100644 example/ruby/HTTPSProxyTest.md delete mode 100644 example/ruby/Hash.md delete mode 100644 example/ruby/HashSpecs.md delete mode 100644 example/ruby/HashSpecs/ByIdentityKey.md delete mode 100644 example/ruby/HashSpecs/ByValueKey.md delete mode 100644 example/ruby/HashSpecs/DefaultHash.md delete mode 100644 example/ruby/HashSpecs/KeyWithPrivateHash.md delete mode 100644 example/ruby/HashSpecs/MyHash.md delete mode 100644 example/ruby/HashSpecs/MyInitializerHash.md delete mode 100644 example/ruby/HashSpecs/NewHash.md delete mode 100644 example/ruby/HashSpecs/SubHashSettingInInitialize.md delete mode 100644 example/ruby/HashSpecs/ToHashHash.md delete mode 100644 example/ruby/HashStringsBinary.md delete mode 100644 example/ruby/HashStringsUSASCII.md delete mode 100644 example/ruby/HashStringsUTF8.md delete mode 100644 example/ruby/HaveClassVariableMatcher.md delete mode 100644 example/ruby/HaveConstantMatcher.md delete mode 100644 example/ruby/HaveInstanceMethodMatcher.md delete mode 100644 example/ruby/HaveInstanceVariableMatcher.md delete mode 100644 example/ruby/HaveMethodMatcher.md delete mode 100644 example/ruby/HavePrivateInstanceMethodMatcher.md delete mode 100644 example/ruby/HavePrivateMethodMatcher.md delete mode 100644 example/ruby/HaveProtectedInstanceMethodMatcher.md delete mode 100644 example/ruby/HavePublicInstanceMethodMatcher.md delete mode 100644 example/ruby/HaveSingletonMethodMatcher.md delete mode 100644 example/ruby/HeaderParser.md delete mode 100644 example/ruby/HelloWorld.md delete mode 100644 example/ruby/Hi_Exception.md delete mode 100644 example/ruby/Hoge.md delete mode 100644 example/ruby/HtmlFormatter.md delete mode 100644 example/ruby/HumanTypoTest.md delete mode 100644 example/ruby/IEHandler.md delete mode 100644 example/ruby/IE_CONST.md delete mode 100644 example/ruby/IO.md delete mode 100644 example/ruby/IO/Buffer.md delete mode 100644 example/ruby/IO/Buffer/AccessError.md delete mode 100644 example/ruby/IO/Buffer/AllocationError.md delete mode 100644 example/ruby/IO/Buffer/InvalidatedError.md delete mode 100644 example/ruby/IO/Buffer/LockedError.md delete mode 100644 example/ruby/IO/Buffer/MaskError.md delete mode 100644 example/ruby/IO/ConsoleMode.md delete mode 100644 example/ruby/IO/EAGAINWaitReadable.md delete mode 100644 example/ruby/IO/EAGAINWaitWritable.md delete mode 100644 example/ruby/IO/EINPROGRESSWaitReadable.md delete mode 100644 example/ruby/IO/EINPROGRESSWaitWritable.md delete mode 100644 example/ruby/IO/EWOULDBLOCKWaitReadable.md delete mode 100644 example/ruby/IO/EWOULDBLOCKWaitWritable.md delete mode 100644 example/ruby/IO/TimeoutError.md delete mode 100644 example/ruby/IO/WaitReadable.md delete mode 100644 example/ruby/IO/WaitWritable.md delete mode 100644 example/ruby/IO/generic_readable.md delete mode 100644 example/ruby/IO/generic_writable.md delete mode 100644 example/ruby/IOBufferScheduler.md delete mode 100644 example/ruby/IOError.md delete mode 100644 example/ruby/IOSpec.md delete mode 100644 example/ruby/IOSpecs.md delete mode 100644 example/ruby/IOSpecs/CopyStream.md delete mode 100644 example/ruby/IOSpecs/CopyStreamRead.md delete mode 100644 example/ruby/IOSpecs/CopyStreamReadPartial.md delete mode 100644 example/ruby/IOSpecs/SubIO.md delete mode 100644 example/ruby/IOSpecs/SubIOWithRedefinedNew.md delete mode 100644 example/ruby/IOStub.md delete mode 100644 example/ruby/IPAddr.md delete mode 100644 example/ruby/IPAddr/AddressFamilyError.md delete mode 100644 example/ruby/IPAddr/Error.md delete mode 100644 example/ruby/IPAddr/InvalidAddressError.md delete mode 100644 example/ruby/IPAddr/InvalidPrefixError.md delete mode 100644 example/ruby/IPSocket.md delete mode 100644 example/ruby/IRB.md delete mode 100644 example/ruby/IRB/Abort.md delete mode 100644 example/ruby/IRB/BaseCompletor.md delete mode 100644 example/ruby/IRB/CallTracer.md delete mode 100644 example/ruby/IRB/CantChangeBinding.md delete mode 100644 example/ruby/IRB/CantReturnToNormalMode.md delete mode 100644 example/ruby/IRB/Canvas.md delete mode 100644 example/ruby/IRB/Color.md delete mode 100644 example/ruby/IRB/ColorPrinter.md delete mode 100644 example/ruby/IRB/Command.md delete mode 100644 example/ruby/IRB/Command/Backtrace.md delete mode 100644 example/ruby/IRB/Command/Base.md delete mode 100644 example/ruby/IRB/Command/Break.md delete mode 100644 example/ruby/IRB/Command/CD.md delete mode 100644 example/ruby/IRB/Command/Catch.md delete mode 100644 example/ruby/IRB/Command/ChangeWorkspace.md delete mode 100644 example/ruby/IRB/Command/CommandArgumentError.md delete mode 100644 example/ruby/IRB/Command/Context.md delete mode 100644 example/ruby/IRB/Command/Continue.md delete mode 100644 example/ruby/IRB/Command/CurrentWorkingWorkspace.md delete mode 100644 example/ruby/IRB/Command/Debug.md delete mode 100644 example/ruby/IRB/Command/DebugCommand.md delete mode 100644 example/ruby/IRB/Command/Delete.md delete mode 100644 example/ruby/IRB/Command/DisableIrb.md delete mode 100644 example/ruby/IRB/Command/Edit.md delete mode 100644 example/ruby/IRB/Command/Exit.md delete mode 100644 example/ruby/IRB/Command/Finish.md delete mode 100644 example/ruby/IRB/Command/ForceExit.md delete mode 100644 example/ruby/IRB/Command/Foreground.md delete mode 100644 example/ruby/IRB/Command/Help.md delete mode 100644 example/ruby/IRB/Command/History.md delete mode 100644 example/ruby/IRB/Command/Info.md delete mode 100644 example/ruby/IRB/Command/IrbCommand.md delete mode 100644 example/ruby/IRB/Command/IrbInfo.md delete mode 100644 example/ruby/IRB/Command/Jobs.md delete mode 100644 example/ruby/IRB/Command/Kill.md delete mode 100644 example/ruby/IRB/Command/Load.md delete mode 100644 example/ruby/IRB/Command/LoaderCommand.md delete mode 100644 example/ruby/IRB/Command/Ls.md delete mode 100644 example/ruby/IRB/Command/Ls/EvaluationError.md delete mode 100644 example/ruby/IRB/Command/Measure.md delete mode 100644 example/ruby/IRB/Command/MultiIRBCommand.md delete mode 100644 example/ruby/IRB/Command/Next.md delete mode 100644 example/ruby/IRB/Command/PopWorkspace.md delete mode 100644 example/ruby/IRB/Command/PushWorkspace.md delete mode 100644 example/ruby/IRB/Command/Require.md delete mode 100644 example/ruby/IRB/Command/RubyArgsExtractor.md delete mode 100644 example/ruby/IRB/Command/ShowDoc.md delete mode 100644 example/ruby/IRB/Command/ShowSource.md delete mode 100644 example/ruby/IRB/Command/Source.md delete mode 100644 example/ruby/IRB/Command/Step.md delete mode 100644 example/ruby/IRB/Command/Whereami.md delete mode 100644 example/ruby/IRB/Command/Workspaces.md delete mode 100644 example/ruby/IRB/Context.md delete mode 100644 example/ruby/IRB/Debug.md delete mode 100644 example/ruby/IRB/Debug/SkipPathHelperForIRB.md delete mode 100644 example/ruby/IRB/Debug/UI.md delete mode 100644 example/ruby/IRB/EvalHistory.md delete mode 100644 example/ruby/IRB/ExtendCommandBundle.md delete mode 100644 example/ruby/IRB/FileInputMethod.md delete mode 100644 example/ruby/IRB/Frame.md delete mode 100644 example/ruby/IRB/Frame/FrameOverflow.md delete mode 100644 example/ruby/IRB/Frame/FrameUnderflow.md delete mode 100644 example/ruby/IRB/HelperMethod.md delete mode 100644 example/ruby/IRB/HelperMethod/Base.md delete mode 100644 example/ruby/IRB/HelperMethod/Conf.md delete mode 100644 example/ruby/IRB/HelpersContainer.md delete mode 100644 example/ruby/IRB/History.md delete mode 100644 example/ruby/IRB/HistorySavingAbility.md delete mode 100644 example/ruby/IRB/IllegalParameter.md delete mode 100644 example/ruby/IRB/InputCompletor.md delete mode 100644 example/ruby/IRB/InputMethod.md delete mode 100644 example/ruby/IRB/Inspector.md delete mode 100644 example/ruby/IRB/Irb.md delete mode 100644 example/ruby/IRB/IrbAlreadyDead.md delete mode 100644 example/ruby/IRB/IrbLoader.md delete mode 100644 example/ruby/IRB/IrbSwitchedToCurrentThread.md delete mode 100644 example/ruby/IRB/JobManager.md delete mode 100644 example/ruby/IRB/LoadAbort.md delete mode 100644 example/ruby/IRB/Locale.md delete mode 100644 example/ruby/IRB/NestingParser.md delete mode 100644 example/ruby/IRB/NoSuchJob.md delete mode 100644 example/ruby/IRB/Notifier.md delete mode 100644 example/ruby/IRB/Notifier/AbstractNotifier.md delete mode 100644 example/ruby/IRB/Notifier/CompositeNotifier.md delete mode 100644 example/ruby/IRB/Notifier/ErrUndefinedNotifier.md delete mode 100644 example/ruby/IRB/Notifier/ErrUnrecognizedLevel.md delete mode 100644 example/ruby/IRB/Notifier/LeveledNotifier.md delete mode 100644 example/ruby/IRB/Notifier/NoMsgNotifier.md delete mode 100644 example/ruby/IRB/OutputMethod.md delete mode 100644 example/ruby/IRB/Pager.md delete mode 100644 example/ruby/IRB/ReadlineInputMethod.md delete mode 100644 example/ruby/IRB/RegexpCompletor.md delete mode 100644 example/ruby/IRB/ReidlineInputMethod.md delete mode 100644 example/ruby/IRB/RelineInputMethod.md delete mode 100644 example/ruby/IRB/RenderingTest.md delete mode 100644 example/ruby/IRB/RubyLex.md delete mode 100644 example/ruby/IRB/RubyLex/TerminateLineInput.md delete mode 100644 example/ruby/IRB/RubyModel.md delete mode 100644 example/ruby/IRB/SourceFinder.md delete mode 100644 example/ruby/IRB/SourceFinder/EvaluationError.md delete mode 100644 example/ruby/IRB/Statement.md delete mode 100644 example/ruby/IRB/Statement/Command.md delete mode 100644 example/ruby/IRB/Statement/EmptyInput.md delete mode 100644 example/ruby/IRB/Statement/Expression.md delete mode 100644 example/ruby/IRB/StdioInputMethod.md delete mode 100644 example/ruby/IRB/StdioOutputMethod.md delete mode 100644 example/ruby/IRB/TypeCompletor.md delete mode 100644 example/ruby/IRB/UndefinedPromptMode.md delete mode 100644 example/ruby/IRB/UnrecognizedSwitch.md delete mode 100644 example/ruby/IRB/Vec.md delete mode 100644 example/ruby/IRB/WorkSpace.md delete mode 100644 example/ruby/ITER_TEST1.md delete mode 100644 example/ruby/ITER_TEST2.md delete mode 100644 example/ruby/ITER_TEST3.md delete mode 100644 example/ruby/ITER_TEST4.md delete mode 100644 example/ruby/ITER_TEST5.md delete mode 100644 example/ruby/ITER_TEST6.md delete mode 100644 example/ruby/IVarModMock.md delete mode 100644 example/ruby/IXMLDOMAttribute.md delete mode 100644 example/ruby/IXMLDOMCDATASection.md delete mode 100644 example/ruby/IXMLDOMCharacterData.md delete mode 100644 example/ruby/IXMLDOMComment.md delete mode 100644 example/ruby/IXMLDOMDocument.md delete mode 100644 example/ruby/IXMLDOMDocumentFragment.md delete mode 100644 example/ruby/IXMLDOMDocumentType.md delete mode 100644 example/ruby/IXMLDOMElement.md delete mode 100644 example/ruby/IXMLDOMEntity.md delete mode 100644 example/ruby/IXMLDOMEntityReference.md delete mode 100644 example/ruby/IXMLDOMImplementation.md delete mode 100644 example/ruby/IXMLDOMNamedNodeMap.md delete mode 100644 example/ruby/IXMLDOMNode.md delete mode 100644 example/ruby/IXMLDOMNodeList.md delete mode 100644 example/ruby/IXMLDOMNotation.md delete mode 100644 example/ruby/IXMLDOMParseError.md delete mode 100644 example/ruby/IXMLDOMProcessingInstruction.md delete mode 100644 example/ruby/IXMLDOMText.md delete mode 100644 example/ruby/IXMLHttpRequest.md delete mode 100644 example/ruby/IXTLRuntime.md delete mode 100644 example/ruby/ImmutableString.md delete mode 100644 example/ruby/IncludeAnyOfMatcher.md delete mode 100644 example/ruby/IncludeMatcher.md delete mode 100644 example/ruby/IncludesMath.md delete mode 100644 example/ruby/IndexError.md delete mode 100644 example/ruby/Indexer.md delete mode 100644 example/ruby/Indexer/Repository.md delete mode 100644 example/ruby/Indexer/Visitor.md delete mode 100644 example/ruby/InfinityMatcher.md delete mode 100644 example/ruby/Inspector.md delete mode 100644 example/ruby/IntWrapper.md delete mode 100644 example/ruby/Integer.md delete mode 100644 example/ruby/IntegerSpecs.md delete mode 100644 example/ruby/IntegerSpecs/CoerceError.md delete mode 100644 example/ruby/Interrupt.md delete mode 100644 example/ruby/Isect.md delete mode 100644 example/ruby/IterTest.md delete mode 100644 example/ruby/JISX0208.md delete mode 100644 example/ruby/JISX0208/Char.md delete mode 100644 example/ruby/JITSupport.md delete mode 100644 example/ruby/JSON.md delete mode 100644 example/ruby/JSON/CircularDatastructure.md delete mode 100644 example/ruby/JSON/Ext.md delete mode 100644 example/ruby/JSON/Ext/Generator.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/Array.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/Bignum.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/FalseClass.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/Fixnum.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/Float.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/Hash.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/Integer.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/NilClass.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/Object.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/String.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/String/Extend.md delete mode 100644 example/ruby/JSON/Ext/Generator/GeneratorMethods/TrueClass.md delete mode 100644 example/ruby/JSON/Ext/Generator/State.md delete mode 100644 example/ruby/JSON/Ext/Parser.md delete mode 100644 example/ruby/JSON/GeneratorError.md delete mode 100644 example/ruby/JSON/GenericObject.md delete mode 100644 example/ruby/JSON/JSONError.md delete mode 100644 example/ruby/JSON/MissingUnicodeSupport.md delete mode 100644 example/ruby/JSON/NestingError.md delete mode 100644 example/ruby/JSON/ParserError.md delete mode 100644 example/ruby/JSONAdditionTest.md delete mode 100644 example/ruby/JSONAdditionTest/A.md delete mode 100644 example/ruby/JSONAdditionTest/A2.md delete mode 100644 example/ruby/JSONAdditionTest/B.md delete mode 100644 example/ruby/JSONAdditionTest/C.md delete mode 100644 example/ruby/JSONAdditionTest/MyJsonStruct.md delete mode 100644 example/ruby/JSONCommonInterfaceTest.md delete mode 100644 example/ruby/JSONCommonInterfaceTest/MethodMissing.md delete mode 100644 example/ruby/JSONEncodingTest.md delete mode 100644 example/ruby/JSONExtParserTest.md delete mode 100644 example/ruby/JSONFixturesTest.md delete mode 100644 example/ruby/JSONGeneratorTest.md delete mode 100644 example/ruby/JSONGeneratorTest/ArrayWithToJSON.md delete mode 100644 example/ruby/JSONGeneratorTest/ArrayWithToS.md delete mode 100644 example/ruby/JSONGeneratorTest/CustomToJSON.md delete mode 100644 example/ruby/JSONGeneratorTest/CustomToS.md delete mode 100644 example/ruby/JSONGeneratorTest/FakeString.md delete mode 100644 example/ruby/JSONGeneratorTest/HashWithToJSON.md delete mode 100644 example/ruby/JSONGeneratorTest/HashWithToS.md delete mode 100644 example/ruby/JSONGeneratorTest/MyCustomString.md delete mode 100644 example/ruby/JSONGeneratorTest/StringWithToJSON.md delete mode 100644 example/ruby/JSONGeneratorTest/StringWithToS.md delete mode 100644 example/ruby/JSONGenericObjectTest.md delete mode 100644 example/ruby/JSONInRactorTest.md delete mode 100644 example/ruby/JSONParserTest.md delete mode 100644 example/ruby/JSONParserTest/SubArray.md delete mode 100644 example/ruby/JSONParserTest/SubArray2.md delete mode 100644 example/ruby/JSONParserTest/SubArrayWrapper.md delete mode 100644 example/ruby/JSONParserTest/SubHash.md delete mode 100644 example/ruby/JSONParserTest/SubHash2.md delete mode 100644 example/ruby/JSONParserTest/SubOpenStruct.md delete mode 100644 example/ruby/JSONSpecs.md delete mode 100644 example/ruby/JSONSpecs/MyClass.md delete mode 100644 example/ruby/JSONStringMatchingTest.md delete mode 100644 example/ruby/JSONStringMatchingTest/TestTime.md delete mode 100644 example/ruby/JUnitFormatter.md delete mode 100644 example/ruby/JaroWinklerTest.md delete mode 100644 example/ruby/KSAutoloadB.md delete mode 100644 example/ruby/KSAutoloadD.md delete mode 100644 example/ruby/Kernel.md delete mode 100644 example/ruby/KernelSpecs.md delete mode 100644 example/ruby/KernelSpecs/A.md delete mode 100644 example/ruby/KernelSpecs/AncestorClass.md delete mode 100644 example/ruby/KernelSpecs/AncestorModule.md delete mode 100644 example/ruby/KernelSpecs/AutoloadMethod.md delete mode 100644 example/ruby/KernelSpecs/AutoloadMethod/AutoloadFromIncludedModule.md delete mode 100644 example/ruby/KernelSpecs/AutoloadMethod2.md delete mode 100644 example/ruby/KernelSpecs/AutoloadMethod2/AutoloadFromIncludedModule2.md delete mode 100644 example/ruby/KernelSpecs/AutoloadMethodIncluder.md delete mode 100644 example/ruby/KernelSpecs/AutoloadMethodIncluder2.md delete mode 100644 example/ruby/KernelSpecs/B.md delete mode 100644 example/ruby/KernelSpecs/Binding.md delete mode 100644 example/ruby/KernelSpecs/BlockGiven.md delete mode 100644 example/ruby/KernelSpecs/CalleeTest.md delete mode 100644 example/ruby/KernelSpecs/CallerLocationsTest.md delete mode 100644 example/ruby/KernelSpecs/CallerTest.md delete mode 100644 example/ruby/KernelSpecs/Child.md delete mode 100644 example/ruby/KernelSpecs/ClassMM.md delete mode 100644 example/ruby/KernelSpecs/ClassNoMM.md delete mode 100644 example/ruby/KernelSpecs/Clone.md delete mode 100644 example/ruby/KernelSpecs/CloneFreeze.md delete mode 100644 example/ruby/KernelSpecs/CustomRangeFloat.md delete mode 100644 example/ruby/KernelSpecs/CustomRangeInteger.md delete mode 100644 example/ruby/KernelSpecs/Dup.md delete mode 100644 example/ruby/KernelSpecs/Duplicate.md delete mode 100644 example/ruby/KernelSpecs/DuplicateM.md delete mode 100644 example/ruby/KernelSpecs/EvalTest.md delete mode 100644 example/ruby/KernelSpecs/Grandchild.md delete mode 100644 example/ruby/KernelSpecs/InstanceClass.md delete mode 100644 example/ruby/KernelSpecs/InstanceVariable.md delete mode 100644 example/ruby/KernelSpecs/KernelBlockGiven.md delete mode 100644 example/ruby/KernelSpecs/KindaClass.md delete mode 100644 example/ruby/KernelSpecs/Lambda.md delete mode 100644 example/ruby/KernelSpecs/LambdaSpecs.md delete mode 100644 example/ruby/KernelSpecs/LambdaSpecs/Ampersand.md delete mode 100644 example/ruby/KernelSpecs/LambdaSpecs/ForwardBlockWithZSuper.md delete mode 100644 example/ruby/KernelSpecs/LambdaSpecs/SuperAmpersand.md delete mode 100644 example/ruby/KernelSpecs/LambdaSpecs/ZSuper.md delete mode 100644 example/ruby/KernelSpecs/M.md delete mode 100644 example/ruby/KernelSpecs/Method.md delete mode 100644 example/ruby/KernelSpecs/MethodTest.md delete mode 100644 example/ruby/KernelSpecs/Methods.md delete mode 100644 example/ruby/KernelSpecs/Methods/MetaclassMethods.md delete mode 100644 example/ruby/KernelSpecs/ModuleMM.md delete mode 100644 example/ruby/KernelSpecs/ModuleNoMM.md delete mode 100644 example/ruby/KernelSpecs/MyExtensionModule.md delete mode 100644 example/ruby/KernelSpecs/MyModule.md delete mode 100644 example/ruby/KernelSpecs/MyPrependedModule.md delete mode 100644 example/ruby/KernelSpecs/Parent.md delete mode 100644 example/ruby/KernelSpecs/ParentMixin.md delete mode 100644 example/ruby/KernelSpecs/PrivateSup.md delete mode 100644 example/ruby/KernelSpecs/PrivateToA.md delete mode 100644 example/ruby/KernelSpecs/PrivateToAry.md delete mode 100644 example/ruby/KernelSpecs/PublicSub.md delete mode 100644 example/ruby/KernelSpecs/RespondViaMissing.md delete mode 100644 example/ruby/KernelSpecs/SelfBlockGiven.md delete mode 100644 example/ruby/KernelSpecs/SomeOtherModule.md delete mode 100644 example/ruby/KernelSpecs/VisibilityChange.md delete mode 100644 example/ruby/KernelSpecs/WarnInNestedCall.md delete mode 100644 example/ruby/KeyError.md delete mode 100644 example/ruby/KeyNameCheckTest.md delete mode 100644 example/ruby/LangSendSpecs.md delete mode 100644 example/ruby/LangSendSpecs/Attr19Set.md delete mode 100644 example/ruby/LangSendSpecs/AttrSet.md delete mode 100644 example/ruby/LangSendSpecs/MethodMissing.md delete mode 100644 example/ruby/LangSendSpecs/PrivateGetter.md delete mode 100644 example/ruby/LangSendSpecs/PrivateSetter.md delete mode 100644 example/ruby/LangSendSpecs/ToAry.md delete mode 100644 example/ruby/LangSendSpecs/ToProc.md delete mode 100644 example/ruby/LanguageSpecs.md delete mode 100644 example/ruby/Launchable.md delete mode 100644 example/ruby/Launchable/JsonStreamWriter.md delete mode 100644 example/ruby/LaunchableFormatter.md delete mode 100644 example/ruby/LeakChecker.md delete mode 100644 example/ruby/LeakCheckerAction.md delete mode 100644 example/ruby/LeakError.md delete mode 100644 example/ruby/Lo_Exception.md delete mode 100644 example/ruby/LoadError.md delete mode 100644 example/ruby/LoadSpecWrap.md delete mode 100644 example/ruby/LocalBarrier.md delete mode 100644 example/ruby/LocalJumpError.md delete mode 100644 example/ruby/Logger.md delete mode 100644 example/ruby/Logger/Error.md delete mode 100644 example/ruby/Logger/Formatter.md delete mode 100644 example/ruby/Logger/LogDevice.md delete mode 100644 example/ruby/Logger/Period.md delete mode 100644 example/ruby/Logger/Severity.md delete mode 100644 example/ruby/Logger/ShiftingError.md delete mode 100644 example/ruby/LoggerSpecs.md delete mode 100644 example/ruby/Lrama.md delete mode 100644 example/ruby/Lrama/Bitmap.md delete mode 100644 example/ruby/Lrama/Command.md delete mode 100644 example/ruby/Lrama/Context.md delete mode 100644 example/ruby/Lrama/Counterexamples.md delete mode 100644 example/ruby/Lrama/Counterexamples/Derivation.md delete mode 100644 example/ruby/Lrama/Counterexamples/Example.md delete mode 100644 example/ruby/Lrama/Counterexamples/Path.md delete mode 100644 example/ruby/Lrama/Counterexamples/ProductionPath.md delete mode 100644 example/ruby/Lrama/Counterexamples/StartPath.md delete mode 100644 example/ruby/Lrama/Counterexamples/StateItem.md delete mode 100644 example/ruby/Lrama/Counterexamples/TransitionPath.md delete mode 100644 example/ruby/Lrama/Counterexamples/Triple.md delete mode 100644 example/ruby/Lrama/Diagnostics.md delete mode 100644 example/ruby/Lrama/Digraph.md delete mode 100644 example/ruby/Lrama/Grammar.md delete mode 100644 example/ruby/Lrama/Grammar/Auxiliary.md delete mode 100644 example/ruby/Lrama/Grammar/Binding.md delete mode 100644 example/ruby/Lrama/Grammar/Code.md delete mode 100644 example/ruby/Lrama/Grammar/Code/DestructorCode.md delete mode 100644 example/ruby/Lrama/Grammar/Code/InitialActionCode.md delete mode 100644 example/ruby/Lrama/Grammar/Code/NoReferenceCode.md delete mode 100644 example/ruby/Lrama/Grammar/Code/PrinterCode.md delete mode 100644 example/ruby/Lrama/Grammar/Code/RuleAction.md delete mode 100644 example/ruby/Lrama/Grammar/Counter.md delete mode 100644 example/ruby/Lrama/Grammar/Destructor.md delete mode 100644 example/ruby/Lrama/Grammar/ErrorToken.md delete mode 100644 example/ruby/Lrama/Grammar/ParameterizingRule.md delete mode 100644 example/ruby/Lrama/Grammar/ParameterizingRule/Resolver.md delete mode 100644 example/ruby/Lrama/Grammar/ParameterizingRule/Rhs.md delete mode 100644 example/ruby/Lrama/Grammar/ParameterizingRule/Rule.md delete mode 100644 example/ruby/Lrama/Grammar/PercentCode.md delete mode 100644 example/ruby/Lrama/Grammar/Precedence.md delete mode 100644 example/ruby/Lrama/Grammar/Printer.md delete mode 100644 example/ruby/Lrama/Grammar/Reference.md delete mode 100644 example/ruby/Lrama/Grammar/Rule.md delete mode 100644 example/ruby/Lrama/Grammar/RuleBuilder.md delete mode 100644 example/ruby/Lrama/Grammar/Symbol.md delete mode 100644 example/ruby/Lrama/Grammar/Symbols.md delete mode 100644 example/ruby/Lrama/Grammar/Symbols/Resolver.md delete mode 100644 example/ruby/Lrama/Grammar/Type.md delete mode 100644 example/ruby/Lrama/Grammar/Union.md delete mode 100644 example/ruby/Lrama/GrammarValidator.md delete mode 100644 example/ruby/Lrama/Lexer.md delete mode 100644 example/ruby/Lrama/Lexer/GrammarFile.md delete mode 100644 example/ruby/Lrama/Lexer/GrammarFile/Text.md delete mode 100644 example/ruby/Lrama/Lexer/Location.md delete mode 100644 example/ruby/Lrama/Lexer/Token.md delete mode 100644 example/ruby/Lrama/Lexer/Token/Char.md delete mode 100644 example/ruby/Lrama/Lexer/Token/Ident.md delete mode 100644 example/ruby/Lrama/Lexer/Token/InstantiateRule.md delete mode 100644 example/ruby/Lrama/Lexer/Token/Tag.md delete mode 100644 example/ruby/Lrama/Lexer/Token/UserCode.md delete mode 100644 example/ruby/Lrama/Logger.md delete mode 100644 example/ruby/Lrama/OptionParser.md delete mode 100644 example/ruby/Lrama/Options.md delete mode 100644 example/ruby/Lrama/Output.md delete mode 100644 example/ruby/Lrama/Parser.md delete mode 100644 example/ruby/Lrama/Report.md delete mode 100644 example/ruby/Lrama/Report/Duration.md delete mode 100644 example/ruby/Lrama/Report/Profile.md delete mode 100644 example/ruby/Lrama/State.md delete mode 100644 example/ruby/Lrama/State/Reduce.md delete mode 100644 example/ruby/Lrama/State/ReduceReduceConflict.md delete mode 100644 example/ruby/Lrama/State/ResolvedConflict.md delete mode 100644 example/ruby/Lrama/State/Shift.md delete mode 100644 example/ruby/Lrama/State/ShiftReduceConflict.md delete mode 100644 example/ruby/Lrama/States.md delete mode 100644 example/ruby/Lrama/States/Item.md delete mode 100644 example/ruby/Lrama/StatesReporter.md delete mode 100644 example/ruby/Lrama/TraceReporter.md delete mode 100644 example/ruby/M001.md delete mode 100644 example/ruby/M002.md delete mode 100644 example/ruby/M003.md delete mode 100644 example/ruby/MD5Constants.md delete mode 100644 example/ruby/MOSConfig.md delete mode 100644 example/ruby/MPart.md delete mode 100644 example/ruby/MSpec.md delete mode 100644 example/ruby/MSpecCI.md delete mode 100644 example/ruby/MSpecEnv.md delete mode 100644 example/ruby/MSpecExampleError.md delete mode 100644 example/ruby/MSpecMain.md delete mode 100644 example/ruby/MSpecMatchers.md delete mode 100644 example/ruby/MSpecOption.md delete mode 100644 example/ruby/MSpecOptions.md delete mode 100644 example/ruby/MSpecOptions/OptionError.md delete mode 100644 example/ruby/MSpecOptions/ParseError.md delete mode 100644 example/ruby/MSpecRun.md delete mode 100644 example/ruby/MSpecScript.md delete mode 100644 example/ruby/MSpecTag.md delete mode 100644 example/ruby/MainSpecs.md delete mode 100644 example/ruby/MainSpecs/Module.md delete mode 100644 example/ruby/MainSpecs/WrapIncludeModule.md delete mode 100644 example/ruby/MakeMakefile.md delete mode 100644 example/ruby/MakeMakefile/Logging.md delete mode 100644 example/ruby/MapItem.md delete mode 100644 example/ruby/Marshal.md delete mode 100644 example/ruby/Marshal/InternalIVar.md delete mode 100644 example/ruby/Marshal/InternalIVar/compat.md delete mode 100644 example/ruby/Marshal/UsrMarshal.md delete mode 100644 example/ruby/MarshalSpec.md delete mode 100644 example/ruby/MarshalSpec/ArrayWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/BasicObjectSubWithRespondToFalse.md delete mode 100644 example/ruby/MarshalSpec/ClassWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/DataSpec.md delete mode 100644 example/ruby/MarshalSpec/DataSpec/MeasureWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/HashWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/M1.md delete mode 100644 example/ruby/MarshalSpec/ModuleToExtendBy.md delete mode 100644 example/ruby/MarshalSpec/ModuleWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/Multibyte_E38181_E38182_E38183_E38184Class.md delete mode 100644 example/ruby/MarshalSpec/Multibyte_E38181_E38182_E38183_E38184Time.md delete mode 100644 example/ruby/MarshalSpec/Multibyte_E38191_E38192_E38193_E38194Module.md delete mode 100644 example/ruby/MarshalSpec/ObjectWithFreezeRaisingException.md delete mode 100644 example/ruby/MarshalSpec/ObjectWithoutFreeze.md delete mode 100644 example/ruby/MarshalSpec/RegexpWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/StringWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/StructToDump.md delete mode 100644 example/ruby/MarshalSpec/StructWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/StructWithUserInitialize.md delete mode 100644 example/ruby/MarshalSpec/TimeWithOverriddenName.md delete mode 100644 example/ruby/MarshalSpec/UserDefinedWithOverriddenName.md delete mode 100644 example/ruby/MarshalTestLib.md delete mode 100644 example/ruby/MarshalTestLib/CyclicRange.md delete mode 100644 example/ruby/MarshalTestLib/Mod1.md delete mode 100644 example/ruby/MarshalTestLib/Mod2.md delete mode 100644 example/ruby/MarshalTestLib/MyArray.md delete mode 100644 example/ruby/MarshalTestLib/MyException.md delete mode 100644 example/ruby/MarshalTestLib/MyHash.md delete mode 100644 example/ruby/MarshalTestLib/MyObject.md delete mode 100644 example/ruby/MarshalTestLib/MyRange.md delete mode 100644 example/ruby/MarshalTestLib/MyRegexp.md delete mode 100644 example/ruby/MarshalTestLib/MyString.md delete mode 100644 example/ruby/MarshalTestLib/MyStruct.md delete mode 100644 example/ruby/MarshalTestLib/MyStruct2.md delete mode 100644 example/ruby/MarshalTestLib/MySubStruct.md delete mode 100644 example/ruby/MarshalTestLib/MyTime.md delete mode 100644 example/ruby/MatchData.md delete mode 100644 example/ruby/MatchDataSpecs.md delete mode 100644 example/ruby/MatchDataSpecs/MyString.md delete mode 100644 example/ruby/MatchFilter.md delete mode 100644 example/ruby/MatchYAMLMatcher.md delete mode 100644 example/ruby/Math.md delete mode 100644 example/ruby/Math/DomainError.md delete mode 100644 example/ruby/MathSpecs.md delete mode 100644 example/ruby/MathSpecs/Float.md delete mode 100644 example/ruby/MathSpecs/Integer.md delete mode 100644 example/ruby/MathSpecs/StringSubClass.md delete mode 100644 example/ruby/MathSpecs/UserClass.md delete mode 100644 example/ruby/MatrixSub.md delete mode 100644 example/ruby/Mdoc2Man.md delete mode 100644 example/ruby/Memory.md delete mode 100644 example/ruby/Memory/Status.md delete mode 100644 example/ruby/MemoryViewTestUtils.md delete mode 100644 example/ruby/MemoryViewTestUtils/ExportableString.md delete mode 100644 example/ruby/MemoryViewTestUtils/MultiDimensionalView.md delete mode 100644 example/ruby/Merger_3DObject.new.md delete mode 100644 example/ruby/MetaClassSpecs.md delete mode 100644 example/ruby/MetaClassSpecs/A.md delete mode 100644 example/ruby/MetaClassSpecs/B.md delete mode 100644 example/ruby/MetaClassSpecs/C.md delete mode 100644 example/ruby/MetaClassSpecs/D.md delete mode 100644 example/ruby/MetaMetaMetaTestCase.md delete mode 100644 example/ruby/Method.md delete mode 100644 example/ruby/MethodFormatter.md delete mode 100644 example/ruby/MethodMatcher.md delete mode 100644 example/ruby/MethodNameCheckTest.md delete mode 100644 example/ruby/MethodNameCheckTest/User.md delete mode 100644 example/ruby/MethodNameCheckTest/UserModule.md delete mode 100644 example/ruby/MethodSpecs.md delete mode 100644 example/ruby/MethodSpecs/A.md delete mode 100644 example/ruby/MethodSpecs/B.md delete mode 100644 example/ruby/MethodSpecs/BetweenBAndC.md delete mode 100644 example/ruby/MethodSpecs/C.md delete mode 100644 example/ruby/MethodSpecs/Composition.md delete mode 100644 example/ruby/MethodSpecs/D.md delete mode 100644 example/ruby/MethodSpecs/Eql.md delete mode 100644 example/ruby/MethodSpecs/Eql2.md delete mode 100644 example/ruby/MethodSpecs/InheritedMethods.md delete mode 100644 example/ruby/MethodSpecs/InheritedMethods/A.md delete mode 100644 example/ruby/MethodSpecs/InheritedMethods/B.md delete mode 100644 example/ruby/MethodSpecs/InheritedMethods/C.md delete mode 100644 example/ruby/MethodSpecs/Methods.md delete mode 100644 example/ruby/MethodSpecs/MyMod.md delete mode 100644 example/ruby/MethodSpecs/MySub.md delete mode 100644 example/ruby/MethodSpecs/MySuper.md delete mode 100644 example/ruby/MethodSpecs/OverrideAgain.md delete mode 100644 example/ruby/MethodSpecs/SourceLocation.md delete mode 100644 example/ruby/MethodSpecs/ToProc.md delete mode 100644 example/ruby/MethodSpecs/ToProcBeta.md delete mode 100644 example/ruby/Meths.md delete mode 100644 example/ruby/MethsMore.md delete mode 100644 example/ruby/Microsoft_FreeThreadedXMLDOM_1_0.md delete mode 100644 example/ruby/Microsoft_XMLDOM_1_0.md delete mode 100644 example/ruby/Microsoft_XMLDSO_1_0.md delete mode 100644 example/ruby/Microsoft_XMLHTTP_1.md delete mode 100644 example/ruby/MkSpec.md delete mode 100644 example/ruby/Mock.md delete mode 100644 example/ruby/MockAndRaiseError.md delete mode 100644 example/ruby/MockIntObject.md delete mode 100644 example/ruby/MockObject.md delete mode 100644 example/ruby/MockProxy.md delete mode 100644 example/ruby/Module.md delete mode 100644 example/ruby/ModuleSpecs.md delete mode 100644 example/ruby/ModuleSpecs/A.md delete mode 100644 example/ruby/ModuleSpecs/AddConstant.md delete mode 100644 example/ruby/ModuleSpecs/Alias.md delete mode 100644 example/ruby/ModuleSpecs/Aliasing.md delete mode 100644 example/ruby/ModuleSpecs/AliasingSubclass.md delete mode 100644 example/ruby/ModuleSpecs/AliasingSuper.md delete mode 100644 example/ruby/ModuleSpecs/AliasingSuper/Child.md delete mode 100644 example/ruby/ModuleSpecs/AliasingSuper/Parent.md delete mode 100644 example/ruby/ModuleSpecs/AliasingSuper/RedefineAfterAlias.md delete mode 100644 example/ruby/ModuleSpecs/AliasingSuper/Target.md delete mode 100644 example/ruby/ModuleSpecs/Allonym.md delete mode 100644 example/ruby/ModuleSpecs/Ancestor.md delete mode 100644 example/ruby/ModuleSpecs/Anonymous.md delete mode 100644 example/ruby/ModuleSpecs/Anonymous/Child.md delete mode 100644 example/ruby/ModuleSpecs/Autoload.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/AutoloadDuringRequire.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/AutoloadSelfDuringRequire.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/Child.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/DuringAutoload.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/DuringAutoloadAfterDefine.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/DynClass.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/DynClass/C.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/DynModule.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/DynModule/D.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/E.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/EX1.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/F.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/Foo.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/Foo/Bar.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/Foo/Baz.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/FromThread.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/FromThread/A.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/FromThread/A/B.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/FromThread/A/B/C.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/FromThread/D.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/G.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/GoodParent.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/GoodParent/Nested.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/H.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/KHash.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/LoadPath.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/Parent.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/R.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/RequiredDirectly.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/S.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/U.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/U/V.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/XX.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/XX/CS_CONST_AUTOLOAD.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/YY.md delete mode 100644 example/ruby/ModuleSpecs/Autoload/Z.md delete mode 100644 example/ruby/ModuleSpecs/B.md delete mode 100644 example/ruby/ModuleSpecs/Basic.md delete mode 100644 example/ruby/ModuleSpecs/C.md delete mode 100644 example/ruby/ModuleSpecs/CVars.md delete mode 100644 example/ruby/ModuleSpecs/CaseCompareOnSingleton.md delete mode 100644 example/ruby/ModuleSpecs/Child.md delete mode 100644 example/ruby/ModuleSpecs/Child2.md delete mode 100644 example/ruby/ModuleSpecs/ChildPrivateMethodMadePublic.md delete mode 100644 example/ruby/ModuleSpecs/ClassEvalTest.md delete mode 100644 example/ruby/ModuleSpecs/ClassVars.md delete mode 100644 example/ruby/ModuleSpecs/ClassVars/A.md delete mode 100644 example/ruby/ModuleSpecs/ClassVars/B.md delete mode 100644 example/ruby/ModuleSpecs/ClassVars/M.md delete mode 100644 example/ruby/ModuleSpecs/ClassWithFoo.md delete mode 100644 example/ruby/ModuleSpecs/ClassWithSuperFoo.md delete mode 100644 example/ruby/ModuleSpecs/ConstAddedSpecs.md delete mode 100644 example/ruby/ModuleSpecs/CountsChild.md delete mode 100644 example/ruby/ModuleSpecs/CountsMixin.md delete mode 100644 example/ruby/ModuleSpecs/CountsParent.md delete mode 100644 example/ruby/ModuleSpecs/CyclicAppendA.md delete mode 100644 example/ruby/ModuleSpecs/CyclicAppendB.md delete mode 100644 example/ruby/ModuleSpecs/CyclicBarrier.md delete mode 100644 example/ruby/ModuleSpecs/CyclicPrepend.md delete mode 100644 example/ruby/ModuleSpecs/Detached.md delete mode 100644 example/ruby/ModuleSpecs/ExtendObject.md delete mode 100644 example/ruby/ModuleSpecs/ExtendObjectPrivate.md delete mode 100644 example/ruby/ModuleSpecs/First.md delete mode 100644 example/ruby/ModuleSpecs/Grandchild.md delete mode 100644 example/ruby/ModuleSpecs/IncludedInObject.md delete mode 100644 example/ruby/ModuleSpecs/IncludedInObject/IncludedModuleSpecs.md delete mode 100644 example/ruby/ModuleSpecs/IncludedModule.md delete mode 100644 example/ruby/ModuleSpecs/InstanceMeth.md delete mode 100644 example/ruby/ModuleSpecs/InstanceMethChild.md delete mode 100644 example/ruby/ModuleSpecs/InstanceMethMod.md delete mode 100644 example/ruby/ModuleSpecs/Internal.md delete mode 100644 example/ruby/ModuleSpecs/Lookup.md delete mode 100644 example/ruby/ModuleSpecs/LookupChild.md delete mode 100644 example/ruby/ModuleSpecs/LookupMod.md delete mode 100644 example/ruby/ModuleSpecs/LookupModInMod.md delete mode 100644 example/ruby/ModuleSpecs/M1.md delete mode 100644 example/ruby/ModuleSpecs/M2.md delete mode 100644 example/ruby/ModuleSpecs/M3.md delete mode 100644 example/ruby/ModuleSpecs/MA.md delete mode 100644 example/ruby/ModuleSpecs/MB.md delete mode 100644 example/ruby/ModuleSpecs/MC.md delete mode 100644 example/ruby/ModuleSpecs/MVars.md delete mode 100644 example/ruby/ModuleSpecs/ModuleWithPrepend.md delete mode 100644 example/ruby/ModuleSpecs/Modules.md delete mode 100644 example/ruby/ModuleSpecs/Modules/Klass.md delete mode 100644 example/ruby/ModuleSpecs/MultipleIncludes.md delete mode 100644 example/ruby/ModuleSpecs/NameEncoding.md delete mode 100644 example/ruby/ModuleSpecs/NameEncoding/C_C39F.md delete mode 100644 example/ruby/ModuleSpecs/NameSpecs.md delete mode 100644 example/ruby/ModuleSpecs/NamedClass.md delete mode 100644 example/ruby/ModuleSpecs/Nesting.md delete mode 100644 example/ruby/ModuleSpecs/Nesting/NestedClass.md delete mode 100644 example/ruby/ModuleSpecs/Parent.md delete mode 100644 example/ruby/ModuleSpecs/ParentPrivateMethodRedef.md delete mode 100644 example/ruby/ModuleSpecs/PrependedModule.md delete mode 100644 example/ruby/ModuleSpecs/PrivConstModule.md delete mode 100644 example/ruby/ModuleSpecs/RecordIncludedModules.md delete mode 100644 example/ruby/ModuleSpecs/RemoveClassVariable.md delete mode 100644 example/ruby/ModuleSpecs/ReopeningModule.md delete mode 100644 example/ruby/ModuleSpecs/Second.md delete mode 100644 example/ruby/ModuleSpecs/ShadowingOuter.md delete mode 100644 example/ruby/ModuleSpecs/ShadowingOuter/M.md delete mode 100644 example/ruby/ModuleSpecs/ShadowingOuter/N.md delete mode 100644 example/ruby/ModuleSpecs/SingletonOnModuleCase.md delete mode 100644 example/ruby/ModuleSpecs/SingletonOnModuleCase/Bar.md delete mode 100644 example/ruby/ModuleSpecs/SingletonOnModuleCase/Foo.md delete mode 100644 example/ruby/ModuleSpecs/SubCVars.md delete mode 100644 example/ruby/ModuleSpecs/SubModule.md delete mode 100644 example/ruby/ModuleSpecs/Subclass.md delete mode 100644 example/ruby/ModuleSpecs/SubclassSpec.md delete mode 100644 example/ruby/ModuleSpecs/Super.md delete mode 100644 example/ruby/ModuleSpecs/Super/SuperChild.md delete mode 100644 example/ruby/ModuleSpecs/ThreadSafeCounter.md delete mode 100644 example/ruby/ModuleSpecs/UnboundMethodTest.md delete mode 100644 example/ruby/ModuleSpecs/UndefinedInstanceMethods.md delete mode 100644 example/ruby/ModuleSpecs/UndefinedInstanceMethods/Child.md delete mode 100644 example/ruby/ModuleSpecs/UndefinedInstanceMethods/Grandchild.md delete mode 100644 example/ruby/ModuleSpecs/UndefinedInstanceMethods/Parent.md delete mode 100644 example/ruby/ModuleSpecs/UndefinedInstanceMethods/Super.md delete mode 100644 example/ruby/ModuleSpecs/WithPrependedModule.md delete mode 100644 example/ruby/ModuleSpecs/Z.md delete mode 100644 example/ruby/Monitor.md delete mode 100644 example/ruby/MonitorMixin.md delete mode 100644 example/ruby/MonitorMixin/ConditionVariable.md delete mode 100644 example/ruby/Msxml.md delete mode 100644 example/ruby/MultiFormatter.md delete mode 100644 example/ruby/MultiPart.md delete mode 100644 example/ruby/MyApp.md delete mode 100644 example/ruby/MyDict.md delete mode 100644 example/ruby/MyElem.md delete mode 100644 example/ruby/MyList.md delete mode 100644 example/ruby/MyModule.md delete mode 100644 example/ruby/MyTimeout.md delete mode 100644 example/ruby/NameError.md delete mode 100644 example/ruby/NameError/message.md delete mode 100644 example/ruby/NameErrorExtensionTest.md delete mode 100644 example/ruby/NameErrorExtensionTest/TestSpellChecker.md delete mode 100644 example/ruby/NameErrorSpecs.md delete mode 100644 example/ruby/NameErrorSpecs/ReceiverClass.md delete mode 100644 example/ruby/NameMap.md delete mode 100644 example/ruby/NameMapSpecs.md delete mode 100644 example/ruby/NameMapSpecs/A.md delete mode 100644 example/ruby/NameMapSpecs/A/B.md delete mode 100644 example/ruby/NameMapSpecs/Error.md delete mode 100644 example/ruby/NameMapSpecs/Fixnum.md delete mode 100644 example/ruby/NamespaceTest.md delete mode 100644 example/ruby/Net.md delete mode 100644 example/ruby/Net/BufferedIO.md delete mode 100644 example/ruby/Net/HTTP.md delete mode 100644 example/ruby/Net/HTTP/Copy.md delete mode 100644 example/ruby/Net/HTTP/Delete.md delete mode 100644 example/ruby/Net/HTTP/Get.md delete mode 100644 example/ruby/Net/HTTP/Head.md delete mode 100644 example/ruby/Net/HTTP/Lock.md delete mode 100644 example/ruby/Net/HTTP/Mkcol.md delete mode 100644 example/ruby/Net/HTTP/Move.md delete mode 100644 example/ruby/Net/HTTP/Options.md delete mode 100644 example/ruby/Net/HTTP/Patch.md delete mode 100644 example/ruby/Net/HTTP/Post.md delete mode 100644 example/ruby/Net/HTTP/Propfind.md delete mode 100644 example/ruby/Net/HTTP/Proppatch.md delete mode 100644 example/ruby/Net/HTTP/ProxyDelta.md delete mode 100644 example/ruby/Net/HTTP/Put.md delete mode 100644 example/ruby/Net/HTTP/Trace.md delete mode 100644 example/ruby/Net/HTTP/Unlock.md delete mode 100644 example/ruby/Net/HTTPAccepted.md delete mode 100644 example/ruby/Net/HTTPAlreadyReported.md delete mode 100644 example/ruby/Net/HTTPBadGateway.md delete mode 100644 example/ruby/Net/HTTPBadRequest.md delete mode 100644 example/ruby/Net/HTTPBadResponse.md delete mode 100644 example/ruby/Net/HTTPClientError.md delete mode 100644 example/ruby/Net/HTTPClientException.md delete mode 100644 example/ruby/Net/HTTPConflict.md delete mode 100644 example/ruby/Net/HTTPContinue.md delete mode 100644 example/ruby/Net/HTTPCreated.md delete mode 100644 example/ruby/Net/HTTPEarlyHints.md delete mode 100644 example/ruby/Net/HTTPError.md delete mode 100644 example/ruby/Net/HTTPExceptions.md delete mode 100644 example/ruby/Net/HTTPExpectationFailed.md delete mode 100644 example/ruby/Net/HTTPFailedDependency.md delete mode 100644 example/ruby/Net/HTTPFatalError.md delete mode 100644 example/ruby/Net/HTTPForbidden.md delete mode 100644 example/ruby/Net/HTTPFound.md delete mode 100644 example/ruby/Net/HTTPGatewayTimeout.md delete mode 100644 example/ruby/Net/HTTPGenericRequest.md delete mode 100644 example/ruby/Net/HTTPGenericRequest/Chunker.md delete mode 100644 example/ruby/Net/HTTPGone.md delete mode 100644 example/ruby/Net/HTTPHeader.md delete mode 100644 example/ruby/Net/HTTPHeaderSyntaxError.md delete mode 100644 example/ruby/Net/HTTPIMUsed.md delete mode 100644 example/ruby/Net/HTTPInformation.md delete mode 100644 example/ruby/Net/HTTPInsufficientStorage.md delete mode 100644 example/ruby/Net/HTTPInternalServerError.md delete mode 100644 example/ruby/Net/HTTPLengthRequired.md delete mode 100644 example/ruby/Net/HTTPLocked.md delete mode 100644 example/ruby/Net/HTTPLoopDetected.md delete mode 100644 example/ruby/Net/HTTPMethodNotAllowed.md delete mode 100644 example/ruby/Net/HTTPMisdirectedRequest.md delete mode 100644 example/ruby/Net/HTTPMovedPermanently.md delete mode 100644 example/ruby/Net/HTTPMultiStatus.md delete mode 100644 example/ruby/Net/HTTPMultipleChoices.md delete mode 100644 example/ruby/Net/HTTPNetworkAuthenticationRequired.md delete mode 100644 example/ruby/Net/HTTPNoContent.md delete mode 100644 example/ruby/Net/HTTPNonAuthoritativeInformation.md delete mode 100644 example/ruby/Net/HTTPNotAcceptable.md delete mode 100644 example/ruby/Net/HTTPNotExtended.md delete mode 100644 example/ruby/Net/HTTPNotFound.md delete mode 100644 example/ruby/Net/HTTPNotImplemented.md delete mode 100644 example/ruby/Net/HTTPNotModified.md delete mode 100644 example/ruby/Net/HTTPOK.md delete mode 100644 example/ruby/Net/HTTPPartialContent.md delete mode 100644 example/ruby/Net/HTTPPayloadTooLarge.md delete mode 100644 example/ruby/Net/HTTPPaymentRequired.md delete mode 100644 example/ruby/Net/HTTPPermanentRedirect.md delete mode 100644 example/ruby/Net/HTTPPreconditionFailed.md delete mode 100644 example/ruby/Net/HTTPPreconditionRequired.md delete mode 100644 example/ruby/Net/HTTPProcessing.md delete mode 100644 example/ruby/Net/HTTPProxyAuthenticationRequired.md delete mode 100644 example/ruby/Net/HTTPRangeNotSatisfiable.md delete mode 100644 example/ruby/Net/HTTPRedirection.md delete mode 100644 example/ruby/Net/HTTPRequest.md delete mode 100644 example/ruby/Net/HTTPRequestHeaderFieldsTooLarge.md delete mode 100644 example/ruby/Net/HTTPRequestTimeout.md delete mode 100644 example/ruby/Net/HTTPResetContent.md delete mode 100644 example/ruby/Net/HTTPResponse.md delete mode 100644 example/ruby/Net/HTTPResponse/Inflater.md delete mode 100644 example/ruby/Net/HTTPRetriableError.md delete mode 100644 example/ruby/Net/HTTPSeeOther.md delete mode 100644 example/ruby/Net/HTTPServerError.md delete mode 100644 example/ruby/Net/HTTPServiceUnavailable.md delete mode 100644 example/ruby/Net/HTTPSuccess.md delete mode 100644 example/ruby/Net/HTTPSwitchProtocol.md delete mode 100644 example/ruby/Net/HTTPTemporaryRedirect.md delete mode 100644 example/ruby/Net/HTTPTooManyRequests.md delete mode 100644 example/ruby/Net/HTTPURITooLong.md delete mode 100644 example/ruby/Net/HTTPUnauthorized.md delete mode 100644 example/ruby/Net/HTTPUnavailableForLegalReasons.md delete mode 100644 example/ruby/Net/HTTPUnknownResponse.md delete mode 100644 example/ruby/Net/HTTPUnprocessableEntity.md delete mode 100644 example/ruby/Net/HTTPUnsupportedMediaType.md delete mode 100644 example/ruby/Net/HTTPUpgradeRequired.md delete mode 100644 example/ruby/Net/HTTPUseProxy.md delete mode 100644 example/ruby/Net/HTTPVariantAlsoNegotiates.md delete mode 100644 example/ruby/Net/HTTPVersionNotSupported.md delete mode 100644 example/ruby/Net/InternetMessageIO.md delete mode 100644 example/ruby/Net/NetPrivate.md delete mode 100644 example/ruby/Net/OpenTimeout.md delete mode 100644 example/ruby/Net/ProtoAuthError.md delete mode 100644 example/ruby/Net/ProtoCommandError.md delete mode 100644 example/ruby/Net/ProtoFatalError.md delete mode 100644 example/ruby/Net/ProtoRetriableError.md delete mode 100644 example/ruby/Net/ProtoServerError.md delete mode 100644 example/ruby/Net/ProtoSyntaxError.md delete mode 100644 example/ruby/Net/ProtoUnknownError.md delete mode 100644 example/ruby/Net/Protocol.md delete mode 100644 example/ruby/Net/ProtocolError.md delete mode 100644 example/ruby/Net/ReadAdapter.md delete mode 100644 example/ruby/Net/ReadTimeout.md delete mode 100644 example/ruby/Net/TestBufferedIO.md delete mode 100644 example/ruby/Net/WriteAdapter.md delete mode 100644 example/ruby/Net/WriteTimeout.md delete mode 100644 example/ruby/NetFTPSpecs.md delete mode 100644 example/ruby/NetFTPSpecs/DummyFTP.md delete mode 100644 example/ruby/NetHTTPExceptionsSpecs.md delete mode 100644 example/ruby/NetHTTPExceptionsSpecs/Simple.md delete mode 100644 example/ruby/NetHTTPHeaderSpecs.md delete mode 100644 example/ruby/NetHTTPHeaderSpecs/Example.md delete mode 100644 example/ruby/NetHTTPRequestSpecs.md delete mode 100644 example/ruby/NetHTTPRequestSpecs/TestRequest.md delete mode 100644 example/ruby/NetHTTPSpecs.md delete mode 100644 example/ruby/NetHTTPSpecs/NullWriter.md delete mode 100644 example/ruby/NetHTTPSpecs/SmallHTTPServer.md delete mode 100644 example/ruby/NextSpecs.md delete mode 100644 example/ruby/NextSpecs/Block.md delete mode 100644 example/ruby/NilClass.md delete mode 100644 example/ruby/NoMatchingPatternError.md delete mode 100644 example/ruby/NoMatchingPatternKeyError.md delete mode 100644 example/ruby/NoMemoryError.md delete mode 100644 example/ruby/NoMethodError.md delete mode 100644 example/ruby/NoMethodErrorSpecs.md delete mode 100644 example/ruby/NoMethodErrorSpecs/InstanceException.md delete mode 100644 example/ruby/NoMethodErrorSpecs/NoMethodErrorA.md delete mode 100644 example/ruby/NoMethodErrorSpecs/NoMethodErrorB.md delete mode 100644 example/ruby/NoMethodErrorSpecs/NoMethodErrorC.md delete mode 100644 example/ruby/NoMethodErrorSpecs/NoMethodErrorD.md delete mode 100644 example/ruby/Node.md delete mode 100644 example/ruby/NotImplementedError.md delete mode 100644 example/ruby/Notify.md delete mode 100644 example/ruby/NthToggle.md delete mode 100644 example/ruby/Num2int.md delete mode 100644 example/ruby/Numeric.md delete mode 100644 example/ruby/NumericMockObject.md delete mode 100644 example/ruby/NumericSpecs.md delete mode 100644 example/ruby/NumericSpecs/Comparison.md delete mode 100644 example/ruby/NumericSpecs/Subclass.md delete mode 100644 example/ruby/OLEtagDOMNodeType.md delete mode 100644 example/ruby/OLEtagXMLEMEM_TYPE.md delete mode 100644 example/ruby/Object.md delete mode 100644 example/ruby/Object/CApiModuleSpecsModuleA.md delete mode 100644 example/ruby/Object/ConstantSpecs.md delete mode 100644 example/ruby/Object/ConstantSpecs/ContainerA.md delete mode 100644 example/ruby/Object/ConstantSpecs/ContainerA/ChildA.md delete mode 100644 example/ruby/Object/ConstantSpecs/ContainerB.md delete mode 100644 example/ruby/Object/ConstantSpecs/ContainerB/ChildB.md delete mode 100644 example/ruby/ObjectSpace.md delete mode 100644 example/ruby/ObjectSpace/InternalObjectWrapper.md delete mode 100644 example/ruby/ObjectSpace/WeakKeyMap.md delete mode 100644 example/ruby/ObjectSpace/WeakMap.md delete mode 100644 example/ruby/ObjectSpaceFixtures.md delete mode 100644 example/ruby/ObjectSpaceFixtures/ObjectToBeFound.md delete mode 100644 example/ruby/ObjectSpaceFixtures/ObjectWithInstanceVariable.md delete mode 100644 example/ruby/ObjectSpecDup.md delete mode 100644 example/ruby/ObjectSpecDupInitCopy.md delete mode 100644 example/ruby/ObjectWithInstanceVariables.md delete mode 100644 example/ruby/ObservableSpecs.md delete mode 100644 example/ruby/ObserverCallbackSpecs.md delete mode 100644 example/ruby/Olympians.md delete mode 100644 example/ruby/Open3.md delete mode 100644 example/ruby/OpenSSL.md delete mode 100644 example/ruby/OpenSSL/ASN1.md delete mode 100644 example/ruby/OpenSSL/ASN1/ASN1Data.md delete mode 100644 example/ruby/OpenSSL/ASN1/ASN1Error.md delete mode 100644 example/ruby/OpenSSL/ASN1/BitString.md delete mode 100644 example/ruby/OpenSSL/ASN1/Boolean.md delete mode 100644 example/ruby/OpenSSL/ASN1/Constructive.md delete mode 100644 example/ruby/OpenSSL/ASN1/EndOfContent.md delete mode 100644 example/ruby/OpenSSL/ASN1/Enumerated.md delete mode 100644 example/ruby/OpenSSL/ASN1/Integer.md delete mode 100644 example/ruby/OpenSSL/ASN1/ObjectId.md delete mode 100644 example/ruby/OpenSSL/ASN1/Primitive.md delete mode 100644 example/ruby/OpenSSL/ASN1/TaggedASN1Data.md delete mode 100644 example/ruby/OpenSSL/BN.md delete mode 100644 example/ruby/OpenSSL/BNError.md delete mode 100644 example/ruby/OpenSSL/Buffering.md delete mode 100644 example/ruby/OpenSSL/Buffering/Buffer.md delete mode 100644 example/ruby/OpenSSL/Certs.md delete mode 100644 example/ruby/OpenSSL/Cipher.md delete mode 100644 example/ruby/OpenSSL/Cipher/Cipher.md delete mode 100644 example/ruby/OpenSSL/Cipher/CipherError.md delete mode 100644 example/ruby/OpenSSL/Config.md delete mode 100644 example/ruby/OpenSSL/ConfigError.md delete mode 100644 example/ruby/OpenSSL/Digest.md delete mode 100644 example/ruby/OpenSSL/Digest/Digest.md delete mode 100644 example/ruby/OpenSSL/Digest/DigestError.md delete mode 100644 example/ruby/OpenSSL/Engine.md delete mode 100644 example/ruby/OpenSSL/Engine/EngineError.md delete mode 100644 example/ruby/OpenSSL/HMAC.md delete mode 100644 example/ruby/OpenSSL/HMACError.md delete mode 100644 example/ruby/OpenSSL/KDF.md delete mode 100644 example/ruby/OpenSSL/KDF/KDFError.md delete mode 100644 example/ruby/OpenSSL/Marshal.md delete mode 100644 example/ruby/OpenSSL/Marshal/ClassMethods.md delete mode 100644 example/ruby/OpenSSL/Netscape.md delete mode 100644 example/ruby/OpenSSL/Netscape/SPKI.md delete mode 100644 example/ruby/OpenSSL/Netscape/SPKIError.md delete mode 100644 example/ruby/OpenSSL/OCSP.md delete mode 100644 example/ruby/OpenSSL/OCSP/BasicResponse.md delete mode 100644 example/ruby/OpenSSL/OCSP/CertificateId.md delete mode 100644 example/ruby/OpenSSL/OCSP/OCSPError.md delete mode 100644 example/ruby/OpenSSL/OCSP/Request.md delete mode 100644 example/ruby/OpenSSL/OCSP/Response.md delete mode 100644 example/ruby/OpenSSL/OCSP/SingleResponse.md delete mode 100644 example/ruby/OpenSSL/OSSL.md delete mode 100644 example/ruby/OpenSSL/OpenSSLError.md delete mode 100644 example/ruby/OpenSSL/PKCS12.md delete mode 100644 example/ruby/OpenSSL/PKCS12/PKCS12Error.md delete mode 100644 example/ruby/OpenSSL/PKCS5.md delete mode 100644 example/ruby/OpenSSL/PKCS7.md delete mode 100644 example/ruby/OpenSSL/PKCS7/PKCS7Error.md delete mode 100644 example/ruby/OpenSSL/PKCS7/RecipientInfo.md delete mode 100644 example/ruby/OpenSSL/PKCS7/SignerInfo.md delete mode 100644 example/ruby/OpenSSL/PKey.md delete mode 100644 example/ruby/OpenSSL/PKey/DH.md delete mode 100644 example/ruby/OpenSSL/PKey/DHError.md delete mode 100644 example/ruby/OpenSSL/PKey/DSA.md delete mode 100644 example/ruby/OpenSSL/PKey/DSAError.md delete mode 100644 example/ruby/OpenSSL/PKey/EC.md delete mode 100644 example/ruby/OpenSSL/PKey/EC/Group.md delete mode 100644 example/ruby/OpenSSL/PKey/EC/Group/Error.md delete mode 100644 example/ruby/OpenSSL/PKey/EC/Point.md delete mode 100644 example/ruby/OpenSSL/PKey/EC/Point/Error.md delete mode 100644 example/ruby/OpenSSL/PKey/ECError.md delete mode 100644 example/ruby/OpenSSL/PKey/PKey.md delete mode 100644 example/ruby/OpenSSL/PKey/PKeyError.md delete mode 100644 example/ruby/OpenSSL/PKey/RSA.md delete mode 100644 example/ruby/OpenSSL/PKey/RSAError.md delete mode 100644 example/ruby/OpenSSL/PKeyTestCase.md delete mode 100644 example/ruby/OpenSSL/Provider.md delete mode 100644 example/ruby/OpenSSL/Provider/ProviderError.md delete mode 100644 example/ruby/OpenSSL/Random.md delete mode 100644 example/ruby/OpenSSL/Random/RandomError.md delete mode 100644 example/ruby/OpenSSL/SSL.md delete mode 100644 example/ruby/OpenSSL/SSL/SSLContext.md delete mode 100644 example/ruby/OpenSSL/SSL/SSLError.md delete mode 100644 example/ruby/OpenSSL/SSL/SSLErrorWaitReadable.md delete mode 100644 example/ruby/OpenSSL/SSL/SSLErrorWaitWritable.md delete mode 100644 example/ruby/OpenSSL/SSL/SSLServer.md delete mode 100644 example/ruby/OpenSSL/SSL/SSLSocket.md delete mode 100644 example/ruby/OpenSSL/SSL/Session.md delete mode 100644 example/ruby/OpenSSL/SSL/Session/SessionError.md delete mode 100644 example/ruby/OpenSSL/SSL/SocketForwarder.md delete mode 100644 example/ruby/OpenSSL/SSLPair.md delete mode 100644 example/ruby/OpenSSL/SSLPairLowlevelSocket.md delete mode 100644 example/ruby/OpenSSL/SSLPairM.md delete mode 100644 example/ruby/OpenSSL/SSLTestCase.md delete mode 100644 example/ruby/OpenSSL/TestASN1.md delete mode 100644 example/ruby/OpenSSL/TestBN.md delete mode 100644 example/ruby/OpenSSL/TestBuffering.md delete mode 100644 example/ruby/OpenSSL/TestBuffering/IO.md delete mode 100644 example/ruby/OpenSSL/TestCase.md delete mode 100644 example/ruby/OpenSSL/TestCipher.md delete mode 100644 example/ruby/OpenSSL/TestCipher/Helper.md delete mode 100644 example/ruby/OpenSSL/TestConfig.md delete mode 100644 example/ruby/OpenSSL/TestDigest.md delete mode 100644 example/ruby/OpenSSL/TestEC.md delete mode 100644 example/ruby/OpenSSL/TestEOF.md delete mode 100644 example/ruby/OpenSSL/TestEOF/Seek.md delete mode 100644 example/ruby/OpenSSL/TestEOF1.md delete mode 100644 example/ruby/OpenSSL/TestEOF1LowlevelSocket.md delete mode 100644 example/ruby/OpenSSL/TestEOF1M.md delete mode 100644 example/ruby/OpenSSL/TestEOF2.md delete mode 100644 example/ruby/OpenSSL/TestEOF2LowlevelSocket.md delete mode 100644 example/ruby/OpenSSL/TestEOF2M.md delete mode 100644 example/ruby/OpenSSL/TestEngine.md delete mode 100644 example/ruby/OpenSSL/TestFIPS.md delete mode 100644 example/ruby/OpenSSL/TestHMAC.md delete mode 100644 example/ruby/OpenSSL/TestKDF.md delete mode 100644 example/ruby/OpenSSL/TestNSSPI.md delete mode 100644 example/ruby/OpenSSL/TestOCSP.md delete mode 100644 example/ruby/OpenSSL/TestPKCS12.md delete mode 100644 example/ruby/OpenSSL/TestPKCS7.md delete mode 100644 example/ruby/OpenSSL/TestPKey.md delete mode 100644 example/ruby/OpenSSL/TestPKeyDH.md delete mode 100644 example/ruby/OpenSSL/TestPKeyDSA.md delete mode 100644 example/ruby/OpenSSL/TestPKeyRSA.md delete mode 100644 example/ruby/OpenSSL/TestPair.md delete mode 100644 example/ruby/OpenSSL/TestPairLowlevelSocket.md delete mode 100644 example/ruby/OpenSSL/TestPairM.md delete mode 100644 example/ruby/OpenSSL/TestProvider.md delete mode 100644 example/ruby/OpenSSL/TestRandom.md delete mode 100644 example/ruby/OpenSSL/TestSSL.md delete mode 100644 example/ruby/OpenSSL/TestSSLSession.md delete mode 100644 example/ruby/OpenSSL/TestTimestamp.md delete mode 100644 example/ruby/OpenSSL/TestUtils.md delete mode 100644 example/ruby/OpenSSL/TestUtils/Fixtures.md delete mode 100644 example/ruby/OpenSSL/TestX509Attribute.md delete mode 100644 example/ruby/OpenSSL/TestX509CRL.md delete mode 100644 example/ruby/OpenSSL/TestX509Certificate.md delete mode 100644 example/ruby/OpenSSL/TestX509Extension.md delete mode 100644 example/ruby/OpenSSL/TestX509Name.md delete mode 100644 example/ruby/OpenSSL/TestX509Request.md delete mode 100644 example/ruby/OpenSSL/TestX509Store.md delete mode 100644 example/ruby/OpenSSL/Timestamp.md delete mode 100644 example/ruby/OpenSSL/Timestamp/Factory.md delete mode 100644 example/ruby/OpenSSL/Timestamp/Request.md delete mode 100644 example/ruby/OpenSSL/Timestamp/Response.md delete mode 100644 example/ruby/OpenSSL/Timestamp/TimestampError.md delete mode 100644 example/ruby/OpenSSL/Timestamp/TokenInfo.md delete mode 100644 example/ruby/OpenSSL/X509.md delete mode 100644 example/ruby/OpenSSL/X509/Attribute.md delete mode 100644 example/ruby/OpenSSL/X509/AttributeError.md delete mode 100644 example/ruby/OpenSSL/X509/CRL.md delete mode 100644 example/ruby/OpenSSL/X509/CRLError.md delete mode 100644 example/ruby/OpenSSL/X509/Certificate.md delete mode 100644 example/ruby/OpenSSL/X509/CertificateError.md delete mode 100644 example/ruby/OpenSSL/X509/Extension.md delete mode 100644 example/ruby/OpenSSL/X509/Extension/AuthorityInfoAccess.md delete mode 100644 example/ruby/OpenSSL/X509/Extension/AuthorityKeyIdentifier.md delete mode 100644 example/ruby/OpenSSL/X509/Extension/CRLDistributionPoints.md delete mode 100644 example/ruby/OpenSSL/X509/Extension/Helpers.md delete mode 100644 example/ruby/OpenSSL/X509/Extension/SubjectKeyIdentifier.md delete mode 100644 example/ruby/OpenSSL/X509/ExtensionError.md delete mode 100644 example/ruby/OpenSSL/X509/ExtensionFactory.md delete mode 100644 example/ruby/OpenSSL/X509/Name.md delete mode 100644 example/ruby/OpenSSL/X509/Name/RFC2253DN.md delete mode 100644 example/ruby/OpenSSL/X509/NameError.md delete mode 100644 example/ruby/OpenSSL/X509/Request.md delete mode 100644 example/ruby/OpenSSL/X509/RequestError.md delete mode 100644 example/ruby/OpenSSL/X509/Revoked.md delete mode 100644 example/ruby/OpenSSL/X509/RevokedError.md delete mode 100644 example/ruby/OpenSSL/X509/Store.md delete mode 100644 example/ruby/OpenSSL/X509/StoreContext.md delete mode 100644 example/ruby/OpenSSL/X509/StoreError.md delete mode 100644 example/ruby/OpenStruct.md delete mode 100644 example/ruby/OpenStructSpecs.md delete mode 100644 example/ruby/OpenStructSpecs/OpenStructSub.md delete mode 100644 example/ruby/OpenURI.md delete mode 100644 example/ruby/OpenURI/Buffer.md delete mode 100644 example/ruby/OpenURI/HTTPError.md delete mode 100644 example/ruby/OpenURI/HTTPRedirect.md delete mode 100644 example/ruby/OpenURI/Meta.md delete mode 100644 example/ruby/OpenURI/OpenRead.md delete mode 100644 example/ruby/OpenURI/TooManyRedirects.md delete mode 100644 example/ruby/OperatorImplementor.md delete mode 100644 example/ruby/OptionParser.md delete mode 100644 example/ruby/OptionParser/AC.md delete mode 100644 example/ruby/OptionParser/Acceptables.md delete mode 100644 example/ruby/OptionParser/AmbiguousArgument.md delete mode 100644 example/ruby/OptionParser/AmbiguousOption.md delete mode 100644 example/ruby/OptionParser/Arguable.md delete mode 100644 example/ruby/OptionParser/CompletingHash.md delete mode 100644 example/ruby/OptionParser/Completion.md delete mode 100644 example/ruby/OptionParser/InvalidArgument.md delete mode 100644 example/ruby/OptionParser/InvalidOption.md delete mode 100644 example/ruby/OptionParser/List.md delete mode 100644 example/ruby/OptionParser/MissingArgument.md delete mode 100644 example/ruby/OptionParser/NeedlessArgument.md delete mode 100644 example/ruby/OptionParser/OptionMap.md delete mode 100644 example/ruby/OptionParser/ParseError.md delete mode 100644 example/ruby/OptionParser/Switch.md delete mode 100644 example/ruby/OptionParser/Switch/NoArgument.md delete mode 100644 example/ruby/OptionParser/Switch/OptionalArgument.md delete mode 100644 example/ruby/OptionParser/Switch/PlacedArgument.md delete mode 100644 example/ruby/OptionParser/Switch/RequiredArgument.md delete mode 100644 example/ruby/OtherCustomException.md delete mode 100644 example/ruby/Output.md delete mode 100644 example/ruby/OutputMatcher.md delete mode 100644 example/ruby/OutputToFDMatcher.md delete mode 100644 example/ruby/PP.md delete mode 100644 example/ruby/PP/ObjectMixin.md delete mode 100644 example/ruby/PP/PPMethods.md delete mode 100644 example/ruby/PP/SingleLine.md delete mode 100644 example/ruby/PPTestModule.md delete mode 100644 example/ruby/PPTestModule/HasBoth.md delete mode 100644 example/ruby/PPTestModule/HasInspect.md delete mode 100644 example/ruby/PPTestModule/HasPrettyPrint.md delete mode 100644 example/ruby/PPTestModule/PPAbstractSyntaxTree.md delete mode 100644 example/ruby/PPTestModule/PPCycleTest.md delete mode 100644 example/ruby/PPTestModule/PPCycleTest/S.md delete mode 100644 example/ruby/PPTestModule/PPDelegateTest.md delete mode 100644 example/ruby/PPTestModule/PPDelegateTest/A.md delete mode 100644 example/ruby/PPTestModule/PPFileStatTest.md delete mode 100644 example/ruby/PPTestModule/PPInheritedTest.md delete mode 100644 example/ruby/PPTestModule/PPInheritedTest/PPSymbolHash.md delete mode 100644 example/ruby/PPTestModule/PPInspectTest.md delete mode 100644 example/ruby/PPTestModule/PPSingleLineTest.md delete mode 100644 example/ruby/PPTestModule/PPTest.md delete mode 100644 example/ruby/PPTestModule/PPTest/OverriddenStruct.md delete mode 100644 example/ruby/PPTestModule/PrettyPrintInspect.md delete mode 100644 example/ruby/PPTestModule/PrettyPrintInspectWithoutPrettyPrint.md delete mode 100644 example/ruby/PStore.md delete mode 100644 example/ruby/PStore/Error.md delete mode 100644 example/ruby/PStoreTest.md delete mode 100644 example/ruby/PTY.md delete mode 100644 example/ruby/PTY/ChildExited.md delete mode 100644 example/ruby/ParallelRunner.md delete mode 100644 example/ruby/ParamList.md delete mode 100644 example/ruby/Parent.md delete mode 100644 example/ruby/ParserSupport.md delete mode 100644 example/ruby/Path.md delete mode 100644 example/ruby/Path/HardlinkExcutable.md delete mode 100644 example/ruby/Path/Mswin.md delete mode 100644 example/ruby/Pathname.md delete mode 100644 example/ruby/PatternKeyNameCheckTest.md delete mode 100644 example/ruby/PiDigitSpigot.md delete mode 100644 example/ruby/Piece.md delete mode 100644 example/ruby/Plane.md delete mode 100644 example/ruby/Planet.md delete mode 100644 example/ruby/PlatformGuard.md delete mode 100644 example/ruby/Point.md delete mode 100644 example/ruby/PrecedenceSpecs.md delete mode 100644 example/ruby/PrecedenceSpecs/NonUnaryOpTest.md delete mode 100644 example/ruby/PrettyPrint.md delete mode 100644 example/ruby/PrettyPrint/Breakable.md delete mode 100644 example/ruby/PrettyPrint/Group.md delete mode 100644 example/ruby/PrettyPrint/GroupQueue.md delete mode 100644 example/ruby/PrettyPrint/SingleLine.md delete mode 100644 example/ruby/PrettyPrint/Text.md delete mode 100644 example/ruby/PrettyPrintTest.md delete mode 100644 example/ruby/PrettyPrintTest/Fill.md delete mode 100644 example/ruby/PrettyPrintTest/NonString.md delete mode 100644 example/ruby/PrettyPrintTest/StrictPrettyExample.md delete mode 100644 example/ruby/PrettyPrintTest/TailGroup.md delete mode 100644 example/ruby/PrettyPrintTest/WadlerExample.md delete mode 100644 example/ruby/PrettyPrintTest/WadlerExample/Tree.md delete mode 100644 example/ruby/Prism.md delete mode 100644 example/ruby/Prism/ASCIISource.md delete mode 100644 example/ruby/Prism/AttributeWriteTest.md delete mode 100644 example/ruby/Prism/AttributeWriteTest/Target.md delete mode 100644 example/ruby/Prism/BOMTest.md delete mode 100644 example/ruby/Prism/BeginNode.md delete mode 100644 example/ruby/Prism/BreadthFirstSearchTest.md delete mode 100644 example/ruby/Prism/CallNode.md delete mode 100644 example/ruby/Prism/CallOperatorWriteNode.md delete mode 100644 example/ruby/Prism/CaseMatchNode.md delete mode 100644 example/ruby/Prism/CaseNode.md delete mode 100644 example/ruby/Prism/ClassVariableAndWriteNode.md delete mode 100644 example/ruby/Prism/ClassVariableOperatorWriteNode.md delete mode 100644 example/ruby/Prism/ClassVariableOrWriteNode.md delete mode 100644 example/ruby/Prism/CodeUnitsCache.md delete mode 100644 example/ruby/Prism/CommandLineTest.md delete mode 100644 example/ruby/Prism/Comment.md delete mode 100644 example/ruby/Prism/CommentsTest.md delete mode 100644 example/ruby/Prism/CompilerTest.md delete mode 100644 example/ruby/Prism/CompilerTest/SExpressions.md delete mode 100644 example/ruby/Prism/ConstantAndWriteNode.md delete mode 100644 example/ruby/Prism/ConstantOperatorWriteNode.md delete mode 100644 example/ruby/Prism/ConstantOrWriteNode.md delete mode 100644 example/ruby/Prism/ConstantPathNode.md delete mode 100644 example/ruby/Prism/ConstantPathNode/DynamicPartsInConstantPathError.md delete mode 100644 example/ruby/Prism/ConstantPathNode/MissingNodesInConstantPathError.md delete mode 100644 example/ruby/Prism/ConstantPathNodeTest.md delete mode 100644 example/ruby/Prism/ConstantPathOperatorWriteNode.md delete mode 100644 example/ruby/Prism/ConstantPathTargetNode.md delete mode 100644 example/ruby/Prism/ConstantReadNode.md delete mode 100644 example/ruby/Prism/ConstantTargetNode.md delete mode 100644 example/ruby/Prism/ConstantWriteNode.md delete mode 100644 example/ruby/Prism/DesugarCompiler.md delete mode 100644 example/ruby/Prism/DesugarCompilerTest.md delete mode 100644 example/ruby/Prism/DispatcherTest.md delete mode 100644 example/ruby/Prism/DispatcherTest/TestListener.md delete mode 100644 example/ruby/Prism/DumpTest.md delete mode 100644 example/ruby/Prism/EmbDocComment.md delete mode 100644 example/ruby/Prism/EncodingsTest.md delete mode 100644 example/ruby/Prism/EncodingsTest/ConstantContext.md delete mode 100644 example/ruby/Prism/EncodingsTest/IdentifierContext.md delete mode 100644 example/ruby/Prism/EqualityTest.md delete mode 100644 example/ruby/Prism/ErrorsTest.md delete mode 100644 example/ruby/Prism/FixturesTest.md delete mode 100644 example/ruby/Prism/FuzzerTest.md delete mode 100644 example/ruby/Prism/GlobalVariableAndWriteNode.md delete mode 100644 example/ruby/Prism/GlobalVariableOperatorWriteNode.md delete mode 100644 example/ruby/Prism/GlobalVariableOrWriteNode.md delete mode 100644 example/ruby/Prism/HeredocDedentTest.md delete mode 100644 example/ruby/Prism/HeredocTest.md delete mode 100644 example/ruby/Prism/IfNode.md delete mode 100644 example/ruby/Prism/ImaginaryNode.md delete mode 100644 example/ruby/Prism/ImplicitArrayTest.md delete mode 100644 example/ruby/Prism/IndexOperatorWriteNode.md delete mode 100644 example/ruby/Prism/IndexWriteTest.md delete mode 100644 example/ruby/Prism/InlineComment.md delete mode 100644 example/ruby/Prism/InstanceVariableAndWriteNode.md delete mode 100644 example/ruby/Prism/InstanceVariableOperatorWriteNode.md delete mode 100644 example/ruby/Prism/InstanceVariableOrWriteNode.md delete mode 100644 example/ruby/Prism/IntegerBaseFlagsTest.md delete mode 100644 example/ruby/Prism/IntegerParseTest.md delete mode 100644 example/ruby/Prism/InterpolatedMatchLastLineNode.md delete mode 100644 example/ruby/Prism/InterpolatedRegularExpressionNode.md delete mode 100644 example/ruby/Prism/InterpolatedStringNode.md delete mode 100644 example/ruby/Prism/InterpolatedSymbolNode.md delete mode 100644 example/ruby/Prism/InterpolatedXStringNode.md delete mode 100644 example/ruby/Prism/LexCompat/EndContentToken.md delete mode 100644 example/ruby/Prism/LexCompat/Heredoc/DashHeredoc.md delete mode 100644 example/ruby/Prism/LexCompat/Heredoc/DedentingHeredoc.md delete mode 100644 example/ruby/Prism/LexCompat/Heredoc/PlainHeredoc.md delete mode 100644 example/ruby/Prism/LexCompat/IdentToken.md delete mode 100644 example/ruby/Prism/LexCompat/IgnoreStateToken.md delete mode 100644 example/ruby/Prism/LexCompat/IgnoredNewlineToken.md delete mode 100644 example/ruby/Prism/LexCompat/ParamToken.md delete mode 100644 example/ruby/Prism/LexCompat/Result.md delete mode 100644 example/ruby/Prism/LexCompat/Token.md delete mode 100644 example/ruby/Prism/LexResult.md delete mode 100644 example/ruby/Prism/LexTest.md delete mode 100644 example/ruby/Prism/LibRubyParser/PrismBuffer.md delete mode 100644 example/ruby/Prism/LibRubyParser/PrismString.md delete mode 100644 example/ruby/Prism/LibrarySymbolsTest.md delete mode 100644 example/ruby/Prism/LocalVariableAndWriteNode.md delete mode 100644 example/ruby/Prism/LocalVariableOperatorWriteNode.md delete mode 100644 example/ruby/Prism/LocalVariableOrWriteNode.md delete mode 100644 example/ruby/Prism/LocalsTest.md delete mode 100644 example/ruby/Prism/LocalsTest/ISeq.md delete mode 100644 example/ruby/Prism/Location.md delete mode 100644 example/ruby/Prism/LocationTest.md delete mode 100644 example/ruby/Prism/MagicComment.md delete mode 100644 example/ruby/Prism/MagicCommentTest.md delete mode 100644 example/ruby/Prism/MagicCommentTest/MagicCommentRipper.md delete mode 100644 example/ruby/Prism/MatchLastLineNode.md delete mode 100644 example/ruby/Prism/NewlineOffsetsTest.md delete mode 100644 example/ruby/Prism/NewlineTest.md delete mode 100644 example/ruby/Prism/Node.md delete mode 100644 example/ruby/Prism/NodeIdTest.md delete mode 100644 example/ruby/Prism/NumericValueTest.md delete mode 100644 example/ruby/Prism/OnigmoTest.md delete mode 100644 example/ruby/Prism/OverlapTest.md delete mode 100644 example/ruby/Prism/Pack.md delete mode 100644 example/ruby/Prism/Pack/Directive.md delete mode 100644 example/ruby/Prism/Pack/Format.md delete mode 100644 example/ruby/Prism/ParametersNode.md delete mode 100644 example/ruby/Prism/ParametersSignatureTest.md delete mode 100644 example/ruby/Prism/ParenthesesNode.md delete mode 100644 example/ruby/Prism/ParseCommentsTest.md delete mode 100644 example/ruby/Prism/ParseError.md delete mode 100644 example/ruby/Prism/ParseLexResult.md delete mode 100644 example/ruby/Prism/ParseResult.md delete mode 100644 example/ruby/Prism/ParseResult/Comments/LocationTarget.md delete mode 100644 example/ruby/Prism/ParseResult/Comments/NodeTarget.md delete mode 100644 example/ruby/Prism/ParseStreamTest.md delete mode 100644 example/ruby/Prism/ParseSuccessTest.md delete mode 100644 example/ruby/Prism/ParseTest.md delete mode 100644 example/ruby/Prism/ParseWarning.md delete mode 100644 example/ruby/Prism/ParserTest.md delete mode 100644 example/ruby/Prism/Pattern.md delete mode 100644 example/ruby/Prism/Pattern/CompilationError.md delete mode 100644 example/ruby/Prism/PatternTest.md delete mode 100644 example/ruby/Prism/PercentDelimiterRegexpTest.md delete mode 100644 example/ruby/Prism/PercentDelimiterStringTest.md delete mode 100644 example/ruby/Prism/PercentDelimiterTests.md delete mode 100644 example/ruby/Prism/RationalNode.md delete mode 100644 example/ruby/Prism/ReflectionTest.md delete mode 100644 example/ruby/Prism/RegexpTest.md delete mode 100644 example/ruby/Prism/RegularExpressionEncodingTest.md delete mode 100644 example/ruby/Prism/RegularExpressionNode.md delete mode 100644 example/ruby/Prism/RegularExpressionOptionsTest.md delete mode 100644 example/ruby/Prism/Relocation.md delete mode 100644 example/ruby/Prism/Relocation/CharacterColumnsField.md delete mode 100644 example/ruby/Prism/Relocation/CharacterOffsetsField.md delete mode 100644 example/ruby/Prism/Relocation/CodeUnitColumnsField.md delete mode 100644 example/ruby/Prism/Relocation/CodeUnitOffsetsField.md delete mode 100644 example/ruby/Prism/Relocation/ColumnsField.md delete mode 100644 example/ruby/Prism/Relocation/CommentsField.md delete mode 100644 example/ruby/Prism/Relocation/CommentsField/Comment.md delete mode 100644 example/ruby/Prism/Relocation/Entry.md delete mode 100644 example/ruby/Prism/Relocation/Entry/MissingValueError.md delete mode 100644 example/ruby/Prism/Relocation/FilepathField.md delete mode 100644 example/ruby/Prism/Relocation/LeadingCommentsField.md delete mode 100644 example/ruby/Prism/Relocation/LinesField.md delete mode 100644 example/ruby/Prism/Relocation/OffsetsField.md delete mode 100644 example/ruby/Prism/Relocation/Repository.md delete mode 100644 example/ruby/Prism/Relocation/Repository/ConfigurationError.md delete mode 100644 example/ruby/Prism/Relocation/Source.md delete mode 100644 example/ruby/Prism/Relocation/SourceFilepath.md delete mode 100644 example/ruby/Prism/Relocation/SourceString.md delete mode 100644 example/ruby/Prism/Relocation/TrailingCommentsField.md delete mode 100644 example/ruby/Prism/RelocationTest.md delete mode 100644 example/ruby/Prism/RescueModifierNode.md delete mode 100644 example/ruby/Prism/RescueNode.md delete mode 100644 example/ruby/Prism/Result.md delete mode 100644 example/ruby/Prism/RipperTest.md delete mode 100644 example/ruby/Prism/RubyParserTest.md delete mode 100644 example/ruby/Prism/SnippetsTest.md delete mode 100644 example/ruby/Prism/Source.md delete mode 100644 example/ruby/Prism/SourceLocationTest.md delete mode 100644 example/ruby/Prism/StaticInspectTest.md delete mode 100644 example/ruby/Prism/StaticLiteralsTest.md delete mode 100644 example/ruby/Prism/StaticLiteralsTest/NullWarning.md delete mode 100644 example/ruby/Prism/StringEncodingTest.md delete mode 100644 example/ruby/Prism/StringNode.md delete mode 100644 example/ruby/Prism/StringQuery.md delete mode 100644 example/ruby/Prism/StringQueryTest.md delete mode 100644 example/ruby/Prism/SymbolEncodingTest.md delete mode 100644 example/ruby/Prism/Template.md delete mode 100644 example/ruby/Prism/Template/ConfigComment.md delete mode 100644 example/ruby/Prism/Template/ConstantField.md delete mode 100644 example/ruby/Prism/Template/ConstantListField.md delete mode 100644 example/ruby/Prism/Template/DoubleField.md delete mode 100644 example/ruby/Prism/Template/Error.md delete mode 100644 example/ruby/Prism/Template/Field.md delete mode 100644 example/ruby/Prism/Template/Flags.md delete mode 100644 example/ruby/Prism/Template/Flags/Flag.md delete mode 100644 example/ruby/Prism/Template/IntegerField.md delete mode 100644 example/ruby/Prism/Template/JavaDoc.md delete mode 100644 example/ruby/Prism/Template/LocationField.md delete mode 100644 example/ruby/Prism/Template/NodeField.md delete mode 100644 example/ruby/Prism/Template/NodeKindField.md delete mode 100644 example/ruby/Prism/Template/NodeListField.md delete mode 100644 example/ruby/Prism/Template/NodeType.md delete mode 100644 example/ruby/Prism/Template/OptionalConstantField.md delete mode 100644 example/ruby/Prism/Template/OptionalLocationField.md delete mode 100644 example/ruby/Prism/Template/OptionalNodeField.md delete mode 100644 example/ruby/Prism/Template/StringField.md delete mode 100644 example/ruby/Prism/Template/Token.md delete mode 100644 example/ruby/Prism/Template/UInt32Field.md delete mode 100644 example/ruby/Prism/Template/UInt8Field.md delete mode 100644 example/ruby/Prism/Template/Warning.md delete mode 100644 example/ruby/Prism/TestCase.md delete mode 100644 example/ruby/Prism/TestCase/Fixture.md delete mode 100644 example/ruby/Prism/TestCompilePrism.md delete mode 100644 example/ruby/Prism/TestCompilePrism/Subclass.md delete mode 100644 example/ruby/Prism/Token.md delete mode 100644 example/ruby/Prism/Translation.md delete mode 100644 example/ruby/Prism/Translation/Parser.md delete mode 100644 example/ruby/Prism/Translation/Parser/Compiler.md delete mode 100644 example/ruby/Prism/Translation/Parser/Compiler/CompilationError.md delete mode 100644 example/ruby/Prism/Translation/Parser/PrismDiagnostic.md delete mode 100644 example/ruby/Prism/Translation/Parser33.md delete mode 100644 example/ruby/Prism/Translation/Parser34.md delete mode 100644 example/ruby/Prism/Translation/Parser35.md delete mode 100644 example/ruby/Prism/Translation/Ripper.md delete mode 100644 example/ruby/Prism/Translation/Ripper/SexpBuilder.md delete mode 100644 example/ruby/Prism/Translation/Ripper/SexpBuilderPP.md delete mode 100644 example/ruby/Prism/Translation/RubyParser.md delete mode 100644 example/ruby/Prism/TunnelTest.md delete mode 100644 example/ruby/Prism/UnescapeTest.md delete mode 100644 example/ruby/Prism/UnescapeTest/Context.md delete mode 100644 example/ruby/Prism/UnescapeTest/Context/Base.md delete mode 100644 example/ruby/Prism/UnescapeTest/Context/Heredoc.md delete mode 100644 example/ruby/Prism/UnescapeTest/Context/List.md delete mode 100644 example/ruby/Prism/UnescapeTest/Context/RegExp.md delete mode 100644 example/ruby/Prism/UnescapeTest/Context/String.md delete mode 100644 example/ruby/Prism/UnescapeTest/Context/Symbol.md delete mode 100644 example/ruby/Prism/UnlessNode.md delete mode 100644 example/ruby/Prism/UntilNode.md delete mode 100644 example/ruby/Prism/VersionTest.md delete mode 100644 example/ruby/Prism/WarningsTest.md delete mode 100644 example/ruby/Prism/WhileNode.md delete mode 100644 example/ruby/Prism/XStringNode.md delete mode 100644 example/ruby/Private.md delete mode 100644 example/ruby/Private/A.md delete mode 100644 example/ruby/Private/B.md delete mode 100644 example/ruby/Private/B/C.md delete mode 100644 example/ruby/Private/D.md delete mode 100644 example/ruby/Private/E.md delete mode 100644 example/ruby/Private/G.md delete mode 100644 example/ruby/Private/H.md delete mode 100644 example/ruby/Proc.md delete mode 100644 example/ruby/ProcArefFrozenSpecs.md delete mode 100644 example/ruby/ProcArefSpecs.md delete mode 100644 example/ruby/ProcSpecs.md delete mode 100644 example/ruby/ProcSpecs/Arity.md delete mode 100644 example/ruby/ProcSpecs/MyProc.md delete mode 100644 example/ruby/ProcSpecs/MyProc2.md delete mode 100644 example/ruby/ProcSpecs/ProcSubclass.md delete mode 100644 example/ruby/ProcSpecs/SourceLocation.md delete mode 100644 example/ruby/ProcSpecs/ToAryAsNil.md delete mode 100644 example/ruby/Process.md delete mode 100644 example/ruby/Process/GID.md delete mode 100644 example/ruby/Process/Status.md delete mode 100644 example/ruby/Process/Sys.md delete mode 100644 example/ruby/Process/Tms.md delete mode 100644 example/ruby/Process/UID.md delete mode 100644 example/ruby/Process/Waiter.md delete mode 100644 example/ruby/ProcessSpecs.md delete mode 100644 example/ruby/ProcessSpecs/Daemon.md delete mode 100644 example/ruby/ProcessSpecs/Daemonizer.md delete mode 100644 example/ruby/ProcessSpecs/Signalizer.md delete mode 100644 example/ruby/ProfileAction.md delete mode 100644 example/ruby/ProfileFilter.md delete mode 100644 example/ruby/ProfileFormatter.md delete mode 100644 example/ruby/Progress.md delete mode 100644 example/ruby/Progress/Rotator.md delete mode 100644 example/ruby/Project.md delete mode 100644 example/ruby/Psych.md delete mode 100644 example/ruby/Psych/AliasesNotEnabled.md delete mode 100644 example/ruby/Psych/AnchorNotDefined.md delete mode 100644 example/ruby/Psych/BadAlias.md delete mode 100644 example/ruby/Psych/ClassLoader.md delete mode 100644 example/ruby/Psych/ClassLoader/Restricted.md delete mode 100644 example/ruby/Psych/Coder.md delete mode 100644 example/ruby/Psych/Config.md delete mode 100644 example/ruby/Psych/DisallowedClass.md delete mode 100644 example/ruby/Psych/Emitter.md delete mode 100644 example/ruby/Psych/Exception.md delete mode 100644 example/ruby/Psych/Foo.md delete mode 100644 example/ruby/Psych/Handler.md delete mode 100644 example/ruby/Psych/Handler/DumperOptions.md delete mode 100644 example/ruby/Psych/Handlers.md delete mode 100644 example/ruby/Psych/Handlers/DocumentStream.md delete mode 100644 example/ruby/Psych/Handlers/Recorder.md delete mode 100644 example/ruby/Psych/Handlers/TestRecorder.md delete mode 100644 example/ruby/Psych/JSON.md delete mode 100644 example/ruby/Psych/JSON/RubyEvents.md delete mode 100644 example/ruby/Psych/JSON/Stream.md delete mode 100644 example/ruby/Psych/JSON/Stream/Emitter.md delete mode 100644 example/ruby/Psych/JSON/TestStream.md delete mode 100644 example/ruby/Psych/JSON/TestStream/Bar.md delete mode 100644 example/ruby/Psych/JSON/TestStream/Foo.md delete mode 100644 example/ruby/Psych/JSON/TreeBuilder.md delete mode 100644 example/ruby/Psych/JSON/YAMLEvents.md delete mode 100644 example/ruby/Psych/Nodes.md delete mode 100644 example/ruby/Psych/Nodes/Alias.md delete mode 100644 example/ruby/Psych/Nodes/Document.md delete mode 100644 example/ruby/Psych/Nodes/Mapping.md delete mode 100644 example/ruby/Psych/Nodes/Node.md delete mode 100644 example/ruby/Psych/Nodes/Scalar.md delete mode 100644 example/ruby/Psych/Nodes/Sequence.md delete mode 100644 example/ruby/Psych/Nodes/Stream.md delete mode 100644 example/ruby/Psych/Nodes/TestEnumerable.md delete mode 100644 example/ruby/Psych/Omap.md delete mode 100644 example/ruby/Psych/Parser.md delete mode 100644 example/ruby/Psych/Parser/Mark.md delete mode 100644 example/ruby/Psych/ScalarScanner.md delete mode 100644 example/ruby/Psych/Set.md delete mode 100644 example/ruby/Psych/Stream.md delete mode 100644 example/ruby/Psych/Stream/Emitter.md delete mode 100644 example/ruby/Psych/Streaming.md delete mode 100644 example/ruby/Psych/Streaming/ClassMethods.md delete mode 100644 example/ruby/Psych/SyntaxError.md delete mode 100644 example/ruby/Psych/Tagged.md delete mode 100644 example/ruby/Psych/TestAliasAndAnchor.md delete mode 100644 example/ruby/Psych/TestArray.md delete mode 100644 example/ruby/Psych/TestArray/X.md delete mode 100644 example/ruby/Psych/TestArray/Y.md delete mode 100644 example/ruby/Psych/TestBoolean.md delete mode 100644 example/ruby/Psych/TestCase.md delete mode 100644 example/ruby/Psych/TestClass.md delete mode 100644 example/ruby/Psych/TestClass/Foo.md delete mode 100644 example/ruby/Psych/TestCoder.md delete mode 100644 example/ruby/Psych/TestCoder/CustomEncode.md delete mode 100644 example/ruby/Psych/TestCoder/InitApi.md delete mode 100644 example/ruby/Psych/TestCoder/Referential.md delete mode 100644 example/ruby/Psych/TestCoder/Represent.md delete mode 100644 example/ruby/Psych/TestCoder/RepresentWithInit.md delete mode 100644 example/ruby/Psych/TestCoder/RepresentWithMap.md delete mode 100644 example/ruby/Psych/TestCoder/RepresentWithObject.md delete mode 100644 example/ruby/Psych/TestCoder/RepresentWithSeq.md delete mode 100644 example/ruby/Psych/TestCoder/ScalarCoder.md delete mode 100644 example/ruby/Psych/TestCoder/TaggingCoder.md delete mode 100644 example/ruby/Psych/TestDateTime.md delete mode 100644 example/ruby/Psych/TestDeprecated.md delete mode 100644 example/ruby/Psych/TestDeprecated/QuickEmitter.md delete mode 100644 example/ruby/Psych/TestDeprecated/QuickEmitterEncodeWith.md delete mode 100644 example/ruby/Psych/TestDeprecated/YamlInitAndInitWith.md delete mode 100644 example/ruby/Psych/TestDocument.md delete mode 100644 example/ruby/Psych/TestEmitter.md delete mode 100644 example/ruby/Psych/TestEncoding.md delete mode 100644 example/ruby/Psych/TestEncoding/EncodingCatcher.md delete mode 100644 example/ruby/Psych/TestException.md delete mode 100644 example/ruby/Psych/TestException/Wups.md delete mode 100644 example/ruby/Psych/TestHash.md delete mode 100644 example/ruby/Psych/TestHash/HashWithCustomInit.md delete mode 100644 example/ruby/Psych/TestHash/HashWithCustomInitNoIvar.md delete mode 100644 example/ruby/Psych/TestHash/HashWithIvar.md delete mode 100644 example/ruby/Psych/TestHash/X.md delete mode 100644 example/ruby/Psych/TestJSONTree.md delete mode 100644 example/ruby/Psych/TestJSONTree/Bar.md delete mode 100644 example/ruby/Psych/TestMarshalable.md delete mode 100644 example/ruby/Psych/TestMarshalable/PsychCustomMarshalable.md delete mode 100644 example/ruby/Psych/TestMergeKeys.md delete mode 100644 example/ruby/Psych/TestMergeKeys/Product.md delete mode 100644 example/ruby/Psych/TestNil.md delete mode 100644 example/ruby/Psych/TestNull.md delete mode 100644 example/ruby/Psych/TestNumeric.md delete mode 100644 example/ruby/Psych/TestObject.md delete mode 100644 example/ruby/Psych/TestObjectReferences.md delete mode 100644 example/ruby/Psych/TestOmap.md delete mode 100644 example/ruby/Psych/TestParser.md delete mode 100644 example/ruby/Psych/TestParser/EventCatcher.md delete mode 100644 example/ruby/Psych/TestSafeLoad.md delete mode 100644 example/ruby/Psych/TestSafeLoad/Foo.md delete mode 100644 example/ruby/Psych/TestSafeLoad/X.md delete mode 100644 example/ruby/Psych/TestScalar.md delete mode 100644 example/ruby/Psych/TestScalarScanner.md delete mode 100644 example/ruby/Psych/TestScalarScanner/MatchCallCounter.md delete mode 100644 example/ruby/Psych/TestSerializeSubclasses.md delete mode 100644 example/ruby/Psych/TestSerializeSubclasses/SomeObject.md delete mode 100644 example/ruby/Psych/TestSerializeSubclasses/StructSubclass.md delete mode 100644 example/ruby/Psych/TestSet.md delete mode 100644 example/ruby/Psych/TestStream.md delete mode 100644 example/ruby/Psych/TestString.md delete mode 100644 example/ruby/Psych/TestString/X.md delete mode 100644 example/ruby/Psych/TestString/Y.md delete mode 100644 example/ruby/Psych/TestString/Z.md delete mode 100644 example/ruby/Psych/TestStruct.md delete mode 100644 example/ruby/Psych/TestStruct/StructSubclass.md delete mode 100644 example/ruby/Psych/TestSymbol.md delete mode 100644 example/ruby/Psych/TestTreeBuilder.md delete mode 100644 example/ruby/Psych/TestYamlSpecialCases.md delete mode 100644 example/ruby/Psych/TreeBuilder.md delete mode 100644 example/ruby/Psych/Visitors.md delete mode 100644 example/ruby/Psych/Visitors/DepthFirst.md delete mode 100644 example/ruby/Psych/Visitors/Emitter.md delete mode 100644 example/ruby/Psych/Visitors/JSONTree.md delete mode 100644 example/ruby/Psych/Visitors/NoAliasRuby.md delete mode 100644 example/ruby/Psych/Visitors/RestrictedYAMLTree.md delete mode 100644 example/ruby/Psych/Visitors/TestDepthFirst.md delete mode 100644 example/ruby/Psych/Visitors/TestDepthFirst/Collector.md delete mode 100644 example/ruby/Psych/Visitors/TestEmitter.md delete mode 100644 example/ruby/Psych/Visitors/TestToRuby.md delete mode 100644 example/ruby/Psych/Visitors/TestToRuby/A.md delete mode 100644 example/ruby/Psych/Visitors/TestYAMLTree.md delete mode 100644 example/ruby/Psych/Visitors/TestYAMLTree/A.md delete mode 100644 example/ruby/Psych/Visitors/TestYAMLTree/TestDelegatorClass.md delete mode 100644 example/ruby/Psych/Visitors/TestYAMLTree/TestSimpleDelegatorClass.md delete mode 100644 example/ruby/Psych/Visitors/ToRuby.md delete mode 100644 example/ruby/Psych/Visitors/Visitor.md delete mode 100644 example/ruby/Psych/Visitors/YAMLTree.md delete mode 100644 example/ruby/Psych/Visitors/YAMLTree/Registrar.md delete mode 100644 example/ruby/Psych/YAMLDBMTest.md delete mode 100644 example/ruby/Psych/YAMLStoreTest.md delete mode 100644 example/ruby/PsychStructWithIvar.md delete mode 100644 example/ruby/Psych_Tests.md delete mode 100644 example/ruby/Psych_Tests/StructTest.md delete mode 100644 example/ruby/Psych_Unit_Tests.md delete mode 100644 example/ruby/Psych_Unit_Tests/NumericTest.md delete mode 100644 example/ruby/QuarantineGuard.md delete mode 100644 example/ruby/QuxParameterVisitor.md delete mode 100644 example/ruby/RDoc.md delete mode 100644 example/ruby/RDoc/Alias.md delete mode 100644 example/ruby/RDoc/AnonClass.md delete mode 100644 example/ruby/RDoc/AnyMethod.md delete mode 100644 example/ruby/RDoc/Attr.md delete mode 100644 example/ruby/RDoc/ClassModule.md delete mode 100644 example/ruby/RDoc/CodeObject.md delete mode 100644 example/ruby/RDoc/Comment.md delete mode 100644 example/ruby/RDoc/Constant.md delete mode 100644 example/ruby/RDoc/Context.md delete mode 100644 example/ruby/RDoc/Context/Section.md delete mode 100644 example/ruby/RDoc/CrossReference.md delete mode 100644 example/ruby/RDoc/ERBIO.md delete mode 100644 example/ruby/RDoc/ERBPartial.md delete mode 100644 example/ruby/RDoc/Encoding.md delete mode 100644 example/ruby/RDoc/Error.md delete mode 100644 example/ruby/RDoc/Extend.md delete mode 100644 example/ruby/RDoc/Generator.md delete mode 100644 example/ruby/RDoc/Generator/Darkfish.md delete mode 100644 example/ruby/RDoc/Generator/JsonIndex.md delete mode 100644 example/ruby/RDoc/Generator/Markup.md delete mode 100644 example/ruby/RDoc/Generator/POT.md delete mode 100644 example/ruby/RDoc/Generator/POT/MessageExtractor.md delete mode 100644 example/ruby/RDoc/Generator/POT/PO.md delete mode 100644 example/ruby/RDoc/Generator/POT/POEntry.md delete mode 100644 example/ruby/RDoc/Generator/RI.md delete mode 100644 example/ruby/RDoc/GhostMethod.md delete mode 100644 example/ruby/RDoc/I18n.md delete mode 100644 example/ruby/RDoc/I18n/Locale.md delete mode 100644 example/ruby/RDoc/I18n/Text.md delete mode 100644 example/ruby/RDoc/Include.md delete mode 100644 example/ruby/RDoc/Markdown.md delete mode 100644 example/ruby/RDoc/Markdown/KpegPosInfo.md delete mode 100644 example/ruby/RDoc/Markdown/Literals.md delete mode 100644 example/ruby/RDoc/Markdown/Literals/KpegPosInfo.md delete mode 100644 example/ruby/RDoc/Markdown/Literals/MemoEntry.md delete mode 100644 example/ruby/RDoc/Markdown/Literals/ParseError.md delete mode 100644 example/ruby/RDoc/Markdown/Literals/RuleInfo.md delete mode 100644 example/ruby/RDoc/Markdown/MemoEntry.md delete mode 100644 example/ruby/RDoc/Markdown/ParseError.md delete mode 100644 example/ruby/RDoc/Markdown/RuleInfo.md delete mode 100644 example/ruby/RDoc/Markup.md delete mode 100644 example/ruby/RDoc/Markup/AttrChanger.md delete mode 100644 example/ruby/RDoc/Markup/AttrSpan.md delete mode 100644 example/ruby/RDoc/Markup/AttributeManager.md delete mode 100644 example/ruby/RDoc/Markup/Attributes.md delete mode 100644 example/ruby/RDoc/Markup/BlankLine.md delete mode 100644 example/ruby/RDoc/Markup/BlockQuote.md delete mode 100644 example/ruby/RDoc/Markup/Document.md delete mode 100644 example/ruby/RDoc/Markup/Formatter.md delete mode 100644 example/ruby/RDoc/Markup/Formatter/InlineTag.md delete mode 100644 example/ruby/RDoc/Markup/FormatterTestCase.md delete mode 100644 example/ruby/RDoc/Markup/HardBreak.md delete mode 100644 example/ruby/RDoc/Markup/Include.md delete mode 100644 example/ruby/RDoc/Markup/IndentedParagraph.md delete mode 100644 example/ruby/RDoc/Markup/List.md delete mode 100644 example/ruby/RDoc/Markup/ListItem.md delete mode 100644 example/ruby/RDoc/Markup/Paragraph.md delete mode 100644 example/ruby/RDoc/Markup/Parser.md delete mode 100644 example/ruby/RDoc/Markup/Parser/Error.md delete mode 100644 example/ruby/RDoc/Markup/Parser/MyStringScanner.md delete mode 100644 example/ruby/RDoc/Markup/Parser/ParseError.md delete mode 100644 example/ruby/RDoc/Markup/PreProcess.md delete mode 100644 example/ruby/RDoc/Markup/PreProcessTest.md delete mode 100644 example/ruby/RDoc/Markup/Raw.md delete mode 100644 example/ruby/RDoc/Markup/RegexpHandling.md delete mode 100644 example/ruby/RDoc/Markup/Rule.md delete mode 100644 example/ruby/RDoc/Markup/Table.md delete mode 100644 example/ruby/RDoc/Markup/TextFormatterTestCase.md delete mode 100644 example/ruby/RDoc/Markup/ToAnsi.md delete mode 100644 example/ruby/RDoc/Markup/ToBs.md delete mode 100644 example/ruby/RDoc/Markup/ToHtml.md delete mode 100644 example/ruby/RDoc/Markup/ToHtmlCrossref.md delete mode 100644 example/ruby/RDoc/Markup/ToHtmlSnippet.md delete mode 100644 example/ruby/RDoc/Markup/ToJoinedParagraph.md delete mode 100644 example/ruby/RDoc/Markup/ToLabel.md delete mode 100644 example/ruby/RDoc/Markup/ToMarkdown.md delete mode 100644 example/ruby/RDoc/Markup/ToRdoc.md delete mode 100644 example/ruby/RDoc/Markup/ToTableOfContents.md delete mode 100644 example/ruby/RDoc/Markup/ToTest.md delete mode 100644 example/ruby/RDoc/Markup/ToTtOnly.md delete mode 100644 example/ruby/RDoc/Markup/Verbatim.md delete mode 100644 example/ruby/RDoc/MarkupReference.md delete mode 100644 example/ruby/RDoc/MarkupReference/DummyClass.md delete mode 100644 example/ruby/RDoc/MarkupReference/DummyModule.md delete mode 100644 example/ruby/RDoc/MetaMethod.md delete mode 100644 example/ruby/RDoc/MethodAttr.md delete mode 100644 example/ruby/RDoc/Mixin.md delete mode 100644 example/ruby/RDoc/NormalClass.md delete mode 100644 example/ruby/RDoc/NormalModule.md delete mode 100644 example/ruby/RDoc/Options.md delete mode 100644 example/ruby/RDoc/Parser.md delete mode 100644 example/ruby/RDoc/Parser/C.md delete mode 100644 example/ruby/RDoc/Parser/ChangeLog.md delete mode 100644 example/ruby/RDoc/Parser/ChangeLog/Git.md delete mode 100644 example/ruby/RDoc/Parser/ChangeLog/Git/LogEntry.md delete mode 100644 example/ruby/RDoc/Parser/Markdown.md delete mode 100644 example/ruby/RDoc/Parser/PrismRuby.md delete mode 100644 example/ruby/RDoc/Parser/PrismRuby/RDocVisitor.md delete mode 100644 example/ruby/RDoc/Parser/PrismRuby/RDocVisitor/MethodSignatureVisitor.md delete mode 100644 example/ruby/RDoc/Parser/RD.md delete mode 100644 example/ruby/RDoc/Parser/RipperStateLex.md delete mode 100644 example/ruby/RDoc/Parser/RipperStateLex/InnerStateLex.md delete mode 100644 example/ruby/RDoc/Parser/RipperStateLex/Token.md delete mode 100644 example/ruby/RDoc/Parser/Ruby.md delete mode 100644 example/ruby/RDoc/Parser/RubyTools.md delete mode 100644 example/ruby/RDoc/Parser/Simple.md delete mode 100644 example/ruby/RDoc/Parser/Text.md delete mode 100644 example/ruby/RDoc/RD.md delete mode 100644 example/ruby/RDoc/RD/BlockParser.md delete mode 100644 example/ruby/RDoc/RD/Inline.md delete mode 100644 example/ruby/RDoc/RD/InlineParser.md delete mode 100644 example/ruby/RDoc/RDoc.md delete mode 100644 example/ruby/RDoc/RI.md delete mode 100644 example/ruby/RDoc/RI/Driver.md delete mode 100644 example/ruby/RDoc/RI/Driver/Error.md delete mode 100644 example/ruby/RDoc/RI/Driver/NotFoundError.md delete mode 100644 example/ruby/RDoc/RI/Error.md delete mode 100644 example/ruby/RDoc/RI/Formatter.md delete mode 100644 example/ruby/RDoc/RI/Paths.md delete mode 100644 example/ruby/RDoc/RI/Task.md delete mode 100644 example/ruby/RDoc/Require.md delete mode 100644 example/ruby/RDoc/RubyGemsHook.md delete mode 100644 example/ruby/RDoc/RubygemsHook.md delete mode 100644 example/ruby/RDoc/Servlet.md delete mode 100644 example/ruby/RDoc/SingleClass.md delete mode 100644 example/ruby/RDoc/Stats.md delete mode 100644 example/ruby/RDoc/Stats/Normal.md delete mode 100644 example/ruby/RDoc/Stats/Quiet.md delete mode 100644 example/ruby/RDoc/Stats/Verbose.md delete mode 100644 example/ruby/RDoc/Store.md delete mode 100644 example/ruby/RDoc/Store/Error.md delete mode 100644 example/ruby/RDoc/Store/MissingFileError.md delete mode 100644 example/ruby/RDoc/Task.md delete mode 100644 example/ruby/RDoc/TestCase.md delete mode 100644 example/ruby/RDoc/Text.md delete mode 100644 example/ruby/RDoc/TokenStream.md delete mode 100644 example/ruby/RDoc/TomDoc.md delete mode 100644 example/ruby/RDoc/TopLevel.md delete mode 100644 example/ruby/RDocGeneratorDarkfishTest.md delete mode 100644 example/ruby/RDocMarkupToAnsiTest.md delete mode 100644 example/ruby/RDocMarkupToBsTest.md delete mode 100644 example/ruby/RDocMarkupToHtmlCrossrefTest.md delete mode 100644 example/ruby/RDocMarkupToHtmlTest.md delete mode 100644 example/ruby/RDocMarkupToMarkdownTest.md delete mode 100644 example/ruby/RDocMarkupToRDocTest.md delete mode 100644 example/ruby/RDocParserPrismTestCases.md delete mode 100644 example/ruby/RDocParserTest.md delete mode 100644 example/ruby/RDocRIDriverTest.md delete mode 100644 example/ruby/RSpecExt.md delete mode 100644 example/ruby/Racc.md delete mode 100644 example/ruby/Racc/ParseError.md delete mode 100644 example/ruby/Racc/Parser.md delete mode 100644 example/ruby/Ractor.md delete mode 100644 example/ruby/Ractor/ClosedError.md delete mode 100644 example/ruby/Ractor/Error.md delete mode 100644 example/ruby/Ractor/IsolationError.md delete mode 100644 example/ruby/Ractor/MovedError.md delete mode 100644 example/ruby/Ractor/MovedObject.md delete mode 100644 example/ruby/Ractor/RemoteError.md delete mode 100644 example/ruby/Ractor/Selector.md delete mode 100644 example/ruby/Ractor/UnsafeError.md delete mode 100644 example/ruby/RactorCompatibilityTest.md delete mode 100644 example/ruby/RactorLocalSingleton.md delete mode 100644 example/ruby/RactorLocalSingleton/RactorLocalSingletonClassMethods.md delete mode 100644 example/ruby/RaiseErrorMatcher.md delete mode 100644 example/ruby/Rake.md delete mode 100644 example/ruby/Rake/ExtensionTask.md delete mode 100644 example/ruby/Random.md delete mode 100644 example/ruby/Random/Formatter.md delete mode 100644 example/ruby/Random/Formatter/FormatterTest.md delete mode 100644 example/ruby/Random/Formatter/NotDefaultTest.md delete mode 100644 example/ruby/Random/Formatter/TestClassMethods.md delete mode 100644 example/ruby/Random/Formatter/TestInstanceMethods.md delete mode 100644 example/ruby/RandomSpecs.md delete mode 100644 example/ruby/RandomSpecs/CustomRangeFloat.md delete mode 100644 example/ruby/RandomSpecs/CustomRangeInteger.md delete mode 100644 example/ruby/Range.md delete mode 100644 example/ruby/RangeError.md delete mode 100644 example/ruby/RangeSpecs.md delete mode 100644 example/ruby/RangeSpecs/ComparisonError.md delete mode 100644 example/ruby/RangeSpecs/Custom.md delete mode 100644 example/ruby/RangeSpecs/MyRange.md delete mode 100644 example/ruby/RangeSpecs/TenfoldSucc.md delete mode 100644 example/ruby/RangeSpecs/WithoutSucc.md delete mode 100644 example/ruby/RangeSpecs/Xs.md delete mode 100644 example/ruby/RangeSpecs/Ys.md delete mode 100644 example/ruby/Rational.md delete mode 100644 example/ruby/Rational/compatible.md delete mode 100644 example/ruby/RationalSpecs.md delete mode 100644 example/ruby/RationalSpecs/CoerceError.md delete mode 100644 example/ruby/RationalSpecs/SubNumeric.md delete mode 100644 example/ruby/RationalSub.md delete mode 100644 example/ruby/Rational_Test.md delete mode 100644 example/ruby/Rational_Test/ObjectX.md delete mode 100644 example/ruby/Rational_Test2.md delete mode 100644 example/ruby/Ray.md delete mode 100644 example/ruby/RbConfig.md delete mode 100644 example/ruby/RbInstall.md delete mode 100644 example/ruby/RbInstall/DirPackage.md delete mode 100644 example/ruby/RbInstall/Specs.md delete mode 100644 example/ruby/RbInstall/Specs/FileCollector.md delete mode 100644 example/ruby/RbInstall/Specs/FileCollector/Ext.md delete mode 100644 example/ruby/RbInstall/Specs/FileCollector/Lib.md delete mode 100644 example/ruby/RbInstall/UnpackedInstaller.md delete mode 100644 example/ruby/RealSuperUserGuard.md delete mode 100644 example/ruby/RedBlackTree.md delete mode 100644 example/ruby/RedBlackTree/NilNode.md delete mode 100644 example/ruby/RedBlackTree/Node.md delete mode 100644 example/ruby/Refinement.md delete mode 100644 example/ruby/RefinementSpec.md delete mode 100644 example/ruby/RefinementSpec/ModuleWithAncestors.md delete mode 100644 example/ruby/ReflectSpecs.md delete mode 100644 example/ruby/ReflectSpecs/A.md delete mode 100644 example/ruby/ReflectSpecs/B.md delete mode 100644 example/ruby/ReflectSpecs/C.md delete mode 100644 example/ruby/ReflectSpecs/D.md delete mode 100644 example/ruby/ReflectSpecs/E.md delete mode 100644 example/ruby/ReflectSpecs/F.md delete mode 100644 example/ruby/ReflectSpecs/K.md delete mode 100644 example/ruby/ReflectSpecs/L.md delete mode 100644 example/ruby/ReflectSpecs/M.md delete mode 100644 example/ruby/ReflectSpecs/N.md delete mode 100644 example/ruby/ReflectSpecs/O.md delete mode 100644 example/ruby/ReflectSpecs/P.md delete mode 100644 example/ruby/Regexp.md delete mode 100644 example/ruby/Regexp/TimeoutError.md delete mode 100644 example/ruby/RegexpError.md delete mode 100644 example/ruby/RegexpFilter.md delete mode 100644 example/ruby/Reline.md delete mode 100644 example/ruby/Reline/ANSI.md delete mode 100644 example/ruby/Reline/ANSITest.md delete mode 100644 example/ruby/Reline/Config.md delete mode 100644 example/ruby/Reline/Config/InvalidInputrc.md delete mode 100644 example/ruby/Reline/Config/Test.md delete mode 100644 example/ruby/Reline/ConfigEncodingConversionError.md delete mode 100644 example/ruby/Reline/Core.md delete mode 100644 example/ruby/Reline/Core/DialogProc.md delete mode 100644 example/ruby/Reline/CursorPos.md delete mode 100644 example/ruby/Reline/DialogRenderInfo.md delete mode 100644 example/ruby/Reline/Dumb.md delete mode 100644 example/ruby/Reline/Face.md delete mode 100644 example/ruby/Reline/Face/Test.md delete mode 100644 example/ruby/Reline/Face/Test/ConfigTest.md delete mode 100644 example/ruby/Reline/Face/Test/WithInsufficientSetupTest.md delete mode 100644 example/ruby/Reline/Face/Test/WithSetupTest.md delete mode 100644 example/ruby/Reline/Face/Test/WithoutSetupTest.md delete mode 100644 example/ruby/Reline/History.md delete mode 100644 example/ruby/Reline/History/Test.md delete mode 100644 example/ruby/Reline/IO.md delete mode 100644 example/ruby/Reline/Key.md delete mode 100644 example/ruby/Reline/KeyActor.md delete mode 100644 example/ruby/Reline/KeyActor/Base.md delete mode 100644 example/ruby/Reline/KeyActor/Composite.md delete mode 100644 example/ruby/Reline/KeyActor/EmacsTest.md delete mode 100644 example/ruby/Reline/KeyStroke.md delete mode 100644 example/ruby/Reline/KeyStroke/Test.md delete mode 100644 example/ruby/Reline/KillRing.md delete mode 100644 example/ruby/Reline/KillRing/RingBuffer.md delete mode 100644 example/ruby/Reline/KillRing/RingPoint.md delete mode 100644 example/ruby/Reline/KillRing/State.md delete mode 100644 example/ruby/Reline/KillRing/Test.md delete mode 100644 example/ruby/Reline/LineEditor.md delete mode 100644 example/ruby/Reline/LineEditor/CompletionBlockTest.md delete mode 100644 example/ruby/Reline/LineEditor/CompletionJourneyState.md delete mode 100644 example/ruby/Reline/LineEditor/CompletionState.md delete mode 100644 example/ruby/Reline/LineEditor/CursorPositionTest.md delete mode 100644 example/ruby/Reline/LineEditor/Dialog.md delete mode 100644 example/ruby/Reline/LineEditor/DialogProcScope.md delete mode 100644 example/ruby/Reline/LineEditor/DialogProcScope/CompletionJourneyData.md delete mode 100644 example/ruby/Reline/LineEditor/MenuInfo.md delete mode 100644 example/ruby/Reline/LineEditor/RenderLineDifferentialTest.md delete mode 100644 example/ruby/Reline/LineEditor/RenderLineDifferentialTest/TestIO.md delete mode 100644 example/ruby/Reline/LineEditor/RenderedScreen.md delete mode 100644 example/ruby/Reline/LineEditor/StringProcessingTest.md delete mode 100644 example/ruby/Reline/MacroTest.md delete mode 100644 example/ruby/Reline/Test.md delete mode 100644 example/ruby/Reline/Test/DummyCallbackObject.md delete mode 100644 example/ruby/Reline/TestCase.md delete mode 100644 example/ruby/Reline/TestKey.md delete mode 100644 example/ruby/Reline/Unicode.md delete mode 100644 example/ruby/Reline/Unicode/EastAsianWidth.md delete mode 100644 example/ruby/Reline/Unicode/Test.md delete mode 100644 example/ruby/Reline/ViInsertTest.md delete mode 100644 example/ruby/Reline/Windows.md delete mode 100644 example/ruby/Reline/Windows/KeyEventRecord.md delete mode 100644 example/ruby/Reline/Windows/KeyEventRecord/Test.md delete mode 100644 example/ruby/Reline/Windows/Win32API.md delete mode 100644 example/ruby/Reline/WithinPipeTest.md delete mode 100644 example/ruby/RelocationVisitor.md delete mode 100644 example/ruby/Removal.md delete mode 100644 example/ruby/RequirePathCheckTest.md delete mode 100644 example/ruby/RequirementChecker.md delete mode 100644 example/ruby/RescueSpecs.md delete mode 100644 example/ruby/RescueSpecs/Captor.md delete mode 100644 example/ruby/RescueSpecs/ClassVariableCaptor.md delete mode 100644 example/ruby/RescueSpecs/ConstantCaptor.md delete mode 100644 example/ruby/RescueSpecs/GlobalVariableCaptor.md delete mode 100644 example/ruby/RescueSpecs/InstanceVariableCaptor.md delete mode 100644 example/ruby/RescueSpecs/LocalVariableCaptor.md delete mode 100644 example/ruby/RescueSpecs/SafeNavigationSetterCaptor.md delete mode 100644 example/ruby/RescueSpecs/SetterCaptor.md delete mode 100644 example/ruby/RescueSpecs/SquareBracketsCaptor.md delete mode 100644 example/ruby/Resolv.md delete mode 100644 example/ruby/Resolv/DNS.md delete mode 100644 example/ruby/Resolv/DNS/Config.md delete mode 100644 example/ruby/Resolv/DNS/Config/NXDomain.md delete mode 100644 example/ruby/Resolv/DNS/Config/OtherResolvError.md delete mode 100644 example/ruby/Resolv/DNS/DecodeError.md delete mode 100644 example/ruby/Resolv/DNS/EncodeError.md delete mode 100644 example/ruby/Resolv/DNS/Label.md delete mode 100644 example/ruby/Resolv/DNS/Label/Str.md delete mode 100644 example/ruby/Resolv/DNS/Message.md delete mode 100644 example/ruby/Resolv/DNS/Message/MessageDecoder.md delete mode 100644 example/ruby/Resolv/DNS/Message/MessageEncoder.md delete mode 100644 example/ruby/Resolv/DNS/Name.md delete mode 100644 example/ruby/Resolv/DNS/OpCode.md delete mode 100644 example/ruby/Resolv/DNS/Query.md delete mode 100644 example/ruby/Resolv/DNS/RCode.md delete mode 100644 example/ruby/Resolv/DNS/Requester.md delete mode 100644 example/ruby/Resolv/DNS/Requester/ConnectedUDP.md delete mode 100644 example/ruby/Resolv/DNS/Requester/ConnectedUDP/Sender.md delete mode 100644 example/ruby/Resolv/DNS/Requester/MDNSOneShot.md delete mode 100644 example/ruby/Resolv/DNS/Requester/RequestError.md delete mode 100644 example/ruby/Resolv/DNS/Requester/Sender.md delete mode 100644 example/ruby/Resolv/DNS/Requester/TCP.md delete mode 100644 example/ruby/Resolv/DNS/Requester/TCP/Sender.md delete mode 100644 example/ruby/Resolv/DNS/Requester/UnconnectedUDP.md delete mode 100644 example/ruby/Resolv/DNS/Requester/UnconnectedUDP/Sender.md delete mode 100644 example/ruby/Resolv/DNS/Resource.md delete mode 100644 example/ruby/Resolv/DNS/Resource/ANY.md delete mode 100644 example/ruby/Resolv/DNS/Resource/CAA.md delete mode 100644 example/ruby/Resolv/DNS/Resource/CNAME.md delete mode 100644 example/ruby/Resolv/DNS/Resource/DomainName.md delete mode 100644 example/ruby/Resolv/DNS/Resource/Generic.md delete mode 100644 example/ruby/Resolv/DNS/Resource/HINFO.md delete mode 100644 example/ruby/Resolv/DNS/Resource/IN.md delete mode 100644 example/ruby/Resolv/DNS/Resource/IN/A.md delete mode 100644 example/ruby/Resolv/DNS/Resource/IN/AAAA.md delete mode 100644 example/ruby/Resolv/DNS/Resource/IN/HTTPS.md delete mode 100644 example/ruby/Resolv/DNS/Resource/IN/SRV.md delete mode 100644 example/ruby/Resolv/DNS/Resource/IN/SVCB.md delete mode 100644 example/ruby/Resolv/DNS/Resource/IN/ServiceBinding.md delete mode 100644 example/ruby/Resolv/DNS/Resource/IN/WKS.md delete mode 100644 example/ruby/Resolv/DNS/Resource/LOC.md delete mode 100644 example/ruby/Resolv/DNS/Resource/MINFO.md delete mode 100644 example/ruby/Resolv/DNS/Resource/MX.md delete mode 100644 example/ruby/Resolv/DNS/Resource/NS.md delete mode 100644 example/ruby/Resolv/DNS/Resource/PTR.md delete mode 100644 example/ruby/Resolv/DNS/Resource/SOA.md delete mode 100644 example/ruby/Resolv/DNS/Resource/TXT.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam/ALPN.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam/DoHPath.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam/Generic.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam/IPv4Hint.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam/IPv6Hint.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam/Mandatory.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam/NoDefaultALPN.md delete mode 100644 example/ruby/Resolv/DNS/SvcParam/Port.md delete mode 100644 example/ruby/Resolv/DNS/SvcParams.md delete mode 100644 example/ruby/Resolv/Hosts.md delete mode 100644 example/ruby/Resolv/IPv4.md delete mode 100644 example/ruby/Resolv/IPv6.md delete mode 100644 example/ruby/Resolv/LOC.md delete mode 100644 example/ruby/Resolv/LOC/Alt.md delete mode 100644 example/ruby/Resolv/LOC/Coord.md delete mode 100644 example/ruby/Resolv/LOC/Size.md delete mode 100644 example/ruby/Resolv/MDNS.md delete mode 100644 example/ruby/Resolv/ResolvError.md delete mode 100644 example/ruby/Resolv/ResolvTimeout.md delete mode 100644 example/ruby/ResolveSymbolResolver.md delete mode 100644 example/ruby/ResolveSymbolTarget.md delete mode 100644 example/ruby/RespondToMatcher.md delete mode 100644 example/ruby/ReturnSpecs.md delete mode 100644 example/ruby/ReturnSpecs/Blocks.md delete mode 100644 example/ruby/ReturnSpecs/DefineMethod.md delete mode 100644 example/ruby/ReturnSpecs/MethodWithBlock.md delete mode 100644 example/ruby/ReturnSpecs/NestedBlocks.md delete mode 100644 example/ruby/ReturnSpecs/NestedCalls.md delete mode 100644 example/ruby/ReturnSpecs/SavedInnerBlock.md delete mode 100644 example/ruby/ReturnSpecs/ThroughDefineMethod.md delete mode 100644 example/ruby/Ring.md delete mode 100644 example/ruby/RingEcho.md delete mode 100644 example/ruby/Ripper.md delete mode 100644 example/ruby/Ripper/Filter.md delete mode 100644 example/ruby/Ripper/Lexer.md delete mode 100644 example/ruby/Ripper/Lexer/Elem.md delete mode 100644 example/ruby/Ripper/Lexer/State.md delete mode 100644 example/ruby/Ripper/SexpBuilder.md delete mode 100644 example/ruby/Ripper/SexpBuilderPP.md delete mode 100644 example/ruby/Ripper/TokenPattern.md delete mode 100644 example/ruby/Ripper/TokenPattern/CompileError.md delete mode 100644 example/ruby/Ripper/TokenPattern/Error.md delete mode 100644 example/ruby/Ripper/TokenPattern/MatchData.md delete mode 100644 example/ruby/Ripper/TokenPattern/MatchError.md delete mode 100644 example/ruby/Rotation.md delete mode 100644 example/ruby/Ruby.md delete mode 100644 example/ruby/Ruby2HTML.md delete mode 100644 example/ruby/RubyExeSpecs.md delete mode 100644 example/ruby/RubyImplementation.md delete mode 100644 example/ruby/RubyVM.md delete mode 100644 example/ruby/RubyVM/AbstractSyntaxTree.md delete mode 100644 example/ruby/RubyVM/AbstractSyntaxTree/Location.md delete mode 100644 example/ruby/RubyVM/AbstractSyntaxTree/Node.md delete mode 100644 example/ruby/RubyVM/AbstractSyntaxTree/Node/CodePosition.md delete mode 100644 example/ruby/RubyVM/Attribute.md delete mode 100644 example/ruby/RubyVM/BareInstructions.md delete mode 100644 example/ruby/RubyVM/CEscape.md delete mode 100644 example/ruby/RubyVM/CExpr.md delete mode 100644 example/ruby/RubyVM/Dumper.md delete mode 100644 example/ruby/RubyVM/Insns2VM.md delete mode 100644 example/ruby/RubyVM/InstructionSequence.md delete mode 100644 example/ruby/RubyVM/InstructionSequence/BasicStorage.md delete mode 100644 example/ruby/RubyVM/InstructionSequence/DBMStorage.md delete mode 100644 example/ruby/RubyVM/InstructionSequence/FS2Storage.md delete mode 100644 example/ruby/RubyVM/InstructionSequence/FSStorage.md delete mode 100644 example/ruby/RubyVM/InstructionSequence/NullStorage.md delete mode 100644 example/ruby/RubyVM/InstructionsUnifications.md delete mode 100644 example/ruby/RubyVM/OperandsUnifications.md delete mode 100644 example/ruby/RubyVM/RJIT.md delete mode 100644 example/ruby/RubyVM/RJIT/Assembler.md delete mode 100644 example/ruby/RubyVM/RJIT/Assembler/Label.md delete mode 100644 example/ruby/RubyVM/RJIT/Assembler/ModRM.md delete mode 100644 example/ruby/RubyVM/RJIT/Assembler/Rel32.md delete mode 100644 example/ruby/RubyVM/RJIT/Block.md delete mode 100644 example/ruby/RubyVM/RJIT/BranchStub.md delete mode 100644 example/ruby/RubyVM/RJIT/BranchTarget.md delete mode 100644 example/ruby/RubyVM/RJIT/BytePtr.md delete mode 100644 example/ruby/RubyVM/RJIT/CPointer.md delete mode 100644 example/ruby/RubyVM/RJIT/CPointer/Array.md delete mode 100644 example/ruby/RubyVM/RJIT/CPointer/BitField.md delete mode 100644 example/ruby/RubyVM/RJIT/CPointer/Bool.md delete mode 100644 example/ruby/RubyVM/RJIT/CPointer/Immediate.md delete mode 100644 example/ruby/RubyVM/RJIT/CPointer/Pointer.md delete mode 100644 example/ruby/RubyVM/RJIT/CPointer/Struct.md delete mode 100644 example/ruby/RubyVM/RJIT/CPointer/Union.md delete mode 100644 example/ruby/RubyVM/RJIT/CType.md delete mode 100644 example/ruby/RubyVM/RJIT/CType/Array.md delete mode 100644 example/ruby/RubyVM/RJIT/CType/BitField.md delete mode 100644 example/ruby/RubyVM/RJIT/CType/Bool.md delete mode 100644 example/ruby/RubyVM/RJIT/CType/Immediate.md delete mode 100644 example/ruby/RubyVM/RJIT/CType/Pointer.md delete mode 100644 example/ruby/RubyVM/RJIT/CType/Struct.md delete mode 100644 example/ruby/RubyVM/RJIT/CType/Stub.md delete mode 100644 example/ruby/RubyVM/RJIT/CType/Union.md delete mode 100644 example/ruby/RubyVM/RJIT/C_3DModule.new.md delete mode 100644 example/ruby/RubyVM/RJIT/CodeBlock.md delete mode 100644 example/ruby/RubyVM/RJIT/Compiler.md delete mode 100644 example/ruby/RubyVM/RJIT/Context.md delete mode 100644 example/ruby/RubyVM/RJIT/DwordPtr.md delete mode 100644 example/ruby/RubyVM/RJIT/EntryStub.md delete mode 100644 example/ruby/RubyVM/RJIT/ExitCompiler.md delete mode 100644 example/ruby/RubyVM/RJIT/Hooks.md delete mode 100644 example/ruby/RubyVM/RJIT/Invariants.md delete mode 100644 example/ruby/RubyVM/RJIT/JITState.md delete mode 100644 example/ruby/RubyVM/RJIT/OperandMatcher.md delete mode 100644 example/ruby/RubyVM/RJIT/TestAssembler.md delete mode 100644 example/ruby/RubyVM/RJIT/TypeDiff.md delete mode 100644 example/ruby/RubyVM/Scanner.md delete mode 100644 example/ruby/RubyVM/Shape.md delete mode 100644 example/ruby/RubyVM/TraceInstructions.md delete mode 100644 example/ruby/RubyVM/YJIT.md delete mode 100644 example/ruby/RubygemsVersionManager.md delete mode 100644 example/ruby/RuntimeError.md delete mode 100644 example/ruby/S.md delete mode 100644 example/ruby/SHA1Constants.md delete mode 100644 example/ruby/SHA256Constants.md delete mode 100644 example/ruby/SHA384Constants.md delete mode 100644 example/ruby/SHA512Constants.md delete mode 100644 example/ruby/SOCKSSocket.md delete mode 100644 example/ruby/SameName.md delete mode 100644 example/ruby/SampleClassForTestProfileFrames.md delete mode 100644 example/ruby/SampleClassForTestProfileFrames/Sample2.md delete mode 100644 example/ruby/SampleClassForTestProfileFrames/Sample3.md delete mode 100644 example/ruby/SampleClassForTestProfileThreadFrames.md delete mode 100644 example/ruby/Scene.md delete mode 100644 example/ruby/Scheduler.md delete mode 100644 example/ruby/ScratchPad.md delete mode 100644 example/ruby/ScriptError.md delete mode 100644 example/ruby/SecondClass.md delete mode 100644 example/ruby/SecureRandom.md delete mode 100644 example/ruby/SecurityError.md delete mode 100644 example/ruby/Segfault.md delete mode 100644 example/ruby/SendSpecs.md delete mode 100644 example/ruby/Sentence.md delete mode 100644 example/ruby/Sentence/Gen.md delete mode 100644 example/ruby/Seq.md delete mode 100644 example/ruby/Set.md delete mode 100644 example/ruby/SetSpecs.md delete mode 100644 example/ruby/SetSpecs/SetLike.md delete mode 100644 example/ruby/Shellwords.md delete mode 100644 example/ruby/ShouldSpecsMonitor.md delete mode 100644 example/ruby/Signal.md delete mode 100644 example/ruby/SignalException.md delete mode 100644 example/ruby/SignedZeroMatcher.md delete mode 100644 example/ruby/SimpleDelegator.md delete mode 100644 example/ruby/SimpleHTTPProxyServer.md delete mode 100644 example/ruby/SimpleHTTPProxyServer/Request.md delete mode 100644 example/ruby/SimpleHTTPSServer.md delete mode 100644 example/ruby/SimpleHTTPServer.md delete mode 100644 example/ruby/SimpleHTTPServer/Request.md delete mode 100644 example/ruby/SimpleHTTPServer/Response.md delete mode 100644 example/ruby/SimpleRat.md delete mode 100644 example/ruby/SimpleTupleSpace.md delete mode 100644 example/ruby/SingleForwardable.md delete mode 100644 example/ruby/Singleton.md delete mode 100644 example/ruby/Singleton/SingletonClassMethods.md delete mode 100644 example/ruby/Singleton/SingletonClassProperties.md delete mode 100644 example/ruby/Singleton/SingletonInstanceMethods.md delete mode 100644 example/ruby/SingletonMethodsSpecs.md delete mode 100644 example/ruby/SingletonMethodsSpecs/Prepended.md delete mode 100644 example/ruby/SingletonMethodsSpecs/SelfExtending.md delete mode 100644 example/ruby/SingletonSpecs.md delete mode 100644 example/ruby/SingletonSpecs/MyClass.md delete mode 100644 example/ruby/SingletonSpecs/MyClassChild.md delete mode 100644 example/ruby/SingletonSpecs/NewSpec.md delete mode 100644 example/ruby/SingletonSpecs/NotInstantiated.md delete mode 100644 example/ruby/SkippedSpecError.md delete mode 100644 example/ruby/SleepingBlockingScheduler.md delete mode 100644 example/ruby/SleepingUnblockScheduler.md delete mode 100644 example/ruby/Socket.md delete mode 100644 example/ruby/Socket/AncillaryData.md delete mode 100644 example/ruby/Socket/Ifaddr.md delete mode 100644 example/ruby/Socket/Option.md delete mode 100644 example/ruby/Socket/ResolutionError.md delete mode 100644 example/ruby/Socket/UDPSource.md delete mode 100644 example/ruby/SocketError.md delete mode 100644 example/ruby/SocketSpecs.md delete mode 100644 example/ruby/SocketSpecs/ServerLoopPortFinder.md delete mode 100644 example/ruby/SocketSpecs/SpecTCPServer.md delete mode 100644 example/ruby/SomeClass.md delete mode 100644 example/ruby/SortedSet.md delete mode 100644 example/ruby/Spec.md delete mode 100644 example/ruby/Spec/BuildMetadata.md delete mode 100644 example/ruby/Spec/Builders.md delete mode 100644 example/ruby/Spec/Builders/BundlerBuilder.md delete mode 100644 example/ruby/Spec/Builders/DepBuilder.md delete mode 100644 example/ruby/Spec/Builders/GemBuilder.md delete mode 100644 example/ruby/Spec/Builders/GitBareBuilder.md delete mode 100644 example/ruby/Spec/Builders/GitBuilder.md delete mode 100644 example/ruby/Spec/Builders/GitReader.md delete mode 100644 example/ruby/Spec/Builders/GitUpdater.md delete mode 100644 example/ruby/Spec/Builders/IndexBuilder.md delete mode 100644 example/ruby/Spec/Builders/LibBuilder.md delete mode 100644 example/ruby/Spec/Builders/PluginBuilder.md delete mode 100644 example/ruby/Spec/Checksums.md delete mode 100644 example/ruby/Spec/Checksums/ChecksumsBuilder.md delete mode 100644 example/ruby/Spec/CommandExecution.md delete mode 100644 example/ruby/Spec/Env.md delete mode 100644 example/ruby/Spec/Helpers.md delete mode 100644 example/ruby/Spec/Indexes.md delete mode 100644 example/ruby/Spec/Matchers.md delete mode 100644 example/ruby/Spec/Matchers/Precondition.md delete mode 100644 example/ruby/Spec/Options.md delete mode 100644 example/ruby/Spec/Path.md delete mode 100644 example/ruby/Spec/Permissions.md delete mode 100644 example/ruby/Spec/Platforms.md delete mode 100644 example/ruby/Spec/Rubygems.md delete mode 100644 example/ruby/Spec/SilentLogger.md delete mode 100644 example/ruby/Spec/Subprocess.md delete mode 100644 example/ruby/Spec/Subprocess/TimeoutExceeded.md delete mode 100644 example/ruby/Spec/TheBundle.md delete mode 100644 example/ruby/SpecEvaluate.md delete mode 100644 example/ruby/SpecExpectation.md delete mode 100644 example/ruby/SpecExpectationNotFoundError.md delete mode 100644 example/ruby/SpecExpectationNotMetError.md delete mode 100644 example/ruby/SpecGuard.md delete mode 100644 example/ruby/SpecNegativeOperatorMatcher.md delete mode 100644 example/ruby/SpecPositiveOperatorMatcher.md delete mode 100644 example/ruby/SpecTag.md delete mode 100644 example/ruby/SpecVersion.md delete mode 100644 example/ruby/SpecdocFormatter.md delete mode 100644 example/ruby/SpecificExampleException.md delete mode 100644 example/ruby/Specs.md delete mode 100644 example/ruby/Specs/Kernel.md delete mode 100644 example/ruby/Specs/Kernel/HasEqual.md delete mode 100644 example/ruby/Specs/Kernel/HasNone.md delete mode 100644 example/ruby/Specs/Kernel/HasOpEqual.md delete mode 100644 example/ruby/Specs/Kernel/HasOppoOpEqual.md delete mode 100644 example/ruby/SpellCheckerTest.md delete mode 100644 example/ruby/Sphere.md delete mode 100644 example/ruby/SpinnerFormatter.md delete mode 100644 example/ruby/SquigglyHeredocSpecs.md delete mode 100644 example/ruby/StandardError.md delete mode 100644 example/ruby/StatsPerFileFormatter.md delete mode 100644 example/ruby/StopIteration.md delete mode 100644 example/ruby/String.md delete mode 100644 example/ruby/StringIO.md delete mode 100644 example/ruby/StringIOSpecs.md delete mode 100644 example/ruby/StringRefinement.md delete mode 100644 example/ruby/StringScanner.md delete mode 100644 example/ruby/StringScanner/Error.md delete mode 100644 example/ruby/StringScannerTests.md delete mode 100644 example/ruby/StringSpecs.md delete mode 100644 example/ruby/StringSpecs/ISO88599Encoding.md delete mode 100644 example/ruby/StringSpecs/InitializeString.md delete mode 100644 example/ruby/StringSpecs/MyArray.md delete mode 100644 example/ruby/StringSpecs/MyRange.md delete mode 100644 example/ruby/StringSpecs/MyString.md delete mode 100644 example/ruby/StringSpecs/SpecialVarProcessor.md delete mode 100644 example/ruby/StringSpecs/StringModule.md delete mode 100644 example/ruby/StringSpecs/StringWithRaisingConstructor.md delete mode 100644 example/ruby/StringSpecs/SubString.md delete mode 100644 example/ruby/StringSubclass.md delete mode 100644 example/ruby/StringifySymbols.md delete mode 100644 example/ruby/StringifyTarget.md delete mode 100644 example/ruby/Struct.md delete mode 100644 example/ruby/StructClasses.md delete mode 100644 example/ruby/StructClasses/Apple.md delete mode 100644 example/ruby/StructClasses/Car.md delete mode 100644 example/ruby/StructClasses/Honda.md delete mode 100644 example/ruby/StructClasses/Ruby.md delete mode 100644 example/ruby/StructClasses/StructWithOverriddenName.md delete mode 100644 example/ruby/StructClasses/SubclassX.md delete mode 100644 example/ruby/SubStringWithInstanceVariables.md delete mode 100644 example/ruby/SummaryFormatter.md delete mode 100644 example/ruby/SuperSpecs.md delete mode 100644 example/ruby/SuperSpecs/Alias1.md delete mode 100644 example/ruby/SuperSpecs/Alias2.md delete mode 100644 example/ruby/SuperSpecs/Alias3.md delete mode 100644 example/ruby/SuperSpecs/AliasWithSuper.md delete mode 100644 example/ruby/SuperSpecs/AliasWithSuper/AS1.md delete mode 100644 example/ruby/SuperSpecs/AliasWithSuper/BS1.md delete mode 100644 example/ruby/SuperSpecs/AliasWithSuper/Base.md delete mode 100644 example/ruby/SuperSpecs/AliasWithSuper/Trigger.md delete mode 100644 example/ruby/SuperSpecs/AnonymousModuleIncludedTwice.md delete mode 100644 example/ruby/SuperSpecs/AnonymousModuleIncludedTwiceBase.md delete mode 100644 example/ruby/SuperSpecs/FromBasicObject.md delete mode 100644 example/ruby/SuperSpecs/IncludesFromBasic.md delete mode 100644 example/ruby/SuperSpecs/IncludesIntermediate.md delete mode 100644 example/ruby/SuperSpecs/IntermediateBasic.md delete mode 100644 example/ruby/SuperSpecs/Keywords.md delete mode 100644 example/ruby/SuperSpecs/Keywords/Arguments.md delete mode 100644 example/ruby/SuperSpecs/Keywords/OptionalAndPlaceholderArguments.md delete mode 100644 example/ruby/SuperSpecs/Keywords/OptionalArguments.md delete mode 100644 example/ruby/SuperSpecs/Keywords/PlaceholderArguments.md delete mode 100644 example/ruby/SuperSpecs/Keywords/RequiredAndOptionalAndPlaceholderArguments.md delete mode 100644 example/ruby/SuperSpecs/Keywords/RequiredAndOptionalArguments.md delete mode 100644 example/ruby/SuperSpecs/Keywords/RequiredAndPlaceholderArguments.md delete mode 100644 example/ruby/SuperSpecs/Keywords/RequiredArguments.md delete mode 100644 example/ruby/SuperSpecs/MM_A.md delete mode 100644 example/ruby/SuperSpecs/MM_B.md delete mode 100644 example/ruby/SuperSpecs/MS1.md delete mode 100644 example/ruby/SuperSpecs/MS1/A.md delete mode 100644 example/ruby/SuperSpecs/MS1/B.md delete mode 100644 example/ruby/SuperSpecs/MS1/ModA.md delete mode 100644 example/ruby/SuperSpecs/MS1/ModB.md delete mode 100644 example/ruby/SuperSpecs/MS2.md delete mode 100644 example/ruby/SuperSpecs/MS2/A.md delete mode 100644 example/ruby/SuperSpecs/MS2/B.md delete mode 100644 example/ruby/SuperSpecs/MS2/C.md delete mode 100644 example/ruby/SuperSpecs/MS2/ModB.md delete mode 100644 example/ruby/SuperSpecs/MS3.md delete mode 100644 example/ruby/SuperSpecs/MS3/A.md delete mode 100644 example/ruby/SuperSpecs/MS3/B.md delete mode 100644 example/ruby/SuperSpecs/MS3/ModA.md delete mode 100644 example/ruby/SuperSpecs/MS4.md delete mode 100644 example/ruby/SuperSpecs/MS4/A.md delete mode 100644 example/ruby/SuperSpecs/MS4/Layer1.md delete mode 100644 example/ruby/SuperSpecs/MS4/Layer2.md delete mode 100644 example/ruby/SuperSpecs/MultiSuperTargets.md delete mode 100644 example/ruby/SuperSpecs/MultiSuperTargets/A.md delete mode 100644 example/ruby/SuperSpecs/MultiSuperTargets/B.md delete mode 100644 example/ruby/SuperSpecs/MultiSuperTargets/BaseA.md delete mode 100644 example/ruby/SuperSpecs/MultiSuperTargets/BaseB.md delete mode 100644 example/ruby/SuperSpecs/MultiSuperTargets/M.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords/Arguments.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords/OptionalAndPlaceholderArguments.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords/OptionalArguments.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords/PlaceholderArguments.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndOptionalAndPlaceholderArguments.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndOptionalArguments.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndPlaceholderArguments.md delete mode 100644 example/ruby/SuperSpecs/RegularAndKeywords/RequiredArguments.md delete mode 100644 example/ruby/SuperSpecs/RestArgsWithSuper.md delete mode 100644 example/ruby/SuperSpecs/RestArgsWithSuper/A.md delete mode 100644 example/ruby/SuperSpecs/RestArgsWithSuper/B.md delete mode 100644 example/ruby/SuperSpecs/S1.md delete mode 100644 example/ruby/SuperSpecs/S1/A.md delete mode 100644 example/ruby/SuperSpecs/S1/B.md delete mode 100644 example/ruby/SuperSpecs/S2.md delete mode 100644 example/ruby/SuperSpecs/S2/A.md delete mode 100644 example/ruby/SuperSpecs/S2/B.md delete mode 100644 example/ruby/SuperSpecs/S2/C.md delete mode 100644 example/ruby/SuperSpecs/S3.md delete mode 100644 example/ruby/SuperSpecs/S3/A.md delete mode 100644 example/ruby/SuperSpecs/S3/B.md delete mode 100644 example/ruby/SuperSpecs/S4.md delete mode 100644 example/ruby/SuperSpecs/S4/A.md delete mode 100644 example/ruby/SuperSpecs/S4/B.md delete mode 100644 example/ruby/SuperSpecs/S5.md delete mode 100644 example/ruby/SuperSpecs/S6.md delete mode 100644 example/ruby/SuperSpecs/S7.md delete mode 100644 example/ruby/SuperSpecs/SingletonAliasCase.md delete mode 100644 example/ruby/SuperSpecs/SingletonAliasCase/Base.md delete mode 100644 example/ruby/SuperSpecs/SingletonAliasCase/Foo.md delete mode 100644 example/ruby/SuperSpecs/SingletonCase.md delete mode 100644 example/ruby/SuperSpecs/SingletonCase/Base.md delete mode 100644 example/ruby/SuperSpecs/SingletonCase/Foo.md delete mode 100644 example/ruby/SuperSpecs/SplatAndKeywords.md delete mode 100644 example/ruby/SuperSpecs/SplatAndKeywords/AllArguments.md delete mode 100644 example/ruby/SuperSpecs/SplatAndKeywords/Arguments.md delete mode 100644 example/ruby/SuperSpecs/ZSuperInBlock.md delete mode 100644 example/ruby/SuperSpecs/ZSuperInBlock/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperInBlock/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithBlock.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithBlock/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithBlock/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithOptional.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithOptional/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithOptional/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithOptional/C.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRest.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRest/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRest/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestAndOthers.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestAndOthers/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestAndOthers/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestAndPost.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestAndPost/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestAndPost/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestReassigned.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestReassigned/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestReassigned/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar/B.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithUnderscores.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithUnderscores/A.md delete mode 100644 example/ruby/SuperSpecs/ZSuperWithUnderscores/B.md delete mode 100644 example/ruby/SuperUserGuard.md delete mode 100644 example/ruby/SupportedGuard.md delete mode 100644 example/ruby/Symbol.md delete mode 100644 example/ruby/SymbolSpecs.md delete mode 100644 example/ruby/SymbolSpecs/MyRange.md delete mode 100644 example/ruby/SyncDefaultGems.md delete mode 100644 example/ruby/SyntaxError.md delete mode 100644 example/ruby/SyntaxSuggest.md delete mode 100644 example/ruby/SyntaxSuggest/AroundBlockScan.md delete mode 100644 example/ruby/SyntaxSuggest/BlockExpand.md delete mode 100644 example/ruby/SyntaxSuggest/Capture.md delete mode 100644 example/ruby/SyntaxSuggest/Capture/BeforeAfterKeywordEnds.md delete mode 100644 example/ruby/SyntaxSuggest/Capture/FallingIndentLines.md delete mode 100644 example/ruby/SyntaxSuggest/CaptureCodeContext.md delete mode 100644 example/ruby/SyntaxSuggest/CleanDocument.md delete mode 100644 example/ruby/SyntaxSuggest/Cli.md delete mode 100644 example/ruby/SyntaxSuggest/CodeBlock.md delete mode 100644 example/ruby/SyntaxSuggest/CodeFrontier.md delete mode 100644 example/ruby/SyntaxSuggest/CodeLine.md delete mode 100644 example/ruby/SyntaxSuggest/CodeSearch.md delete mode 100644 example/ruby/SyntaxSuggest/CurrentIndex.md delete mode 100644 example/ruby/SyntaxSuggest/DisplayCodeWithLineNumbers.md delete mode 100644 example/ruby/SyntaxSuggest/DisplayInvalidBlocks.md delete mode 100644 example/ruby/SyntaxSuggest/Error.md delete mode 100644 example/ruby/SyntaxSuggest/ExplainSyntax.md delete mode 100644 example/ruby/SyntaxSuggest/FakeExit.md delete mode 100644 example/ruby/SyntaxSuggest/GetParseErrors.md delete mode 100644 example/ruby/SyntaxSuggest/LeftRightLexCount.md delete mode 100644 example/ruby/SyntaxSuggest/LexAll.md delete mode 100644 example/ruby/SyntaxSuggest/LexValue.md delete mode 100644 example/ruby/SyntaxSuggest/MiniStringIO.md delete mode 100644 example/ruby/SyntaxSuggest/ParseBlocksFromIndentLine.md delete mode 100644 example/ruby/SyntaxSuggest/PathnameFromMessage.md delete mode 100644 example/ruby/SyntaxSuggest/PriorityEngulfQueue.md delete mode 100644 example/ruby/SyntaxSuggest/PriorityQueue.md delete mode 100644 example/ruby/SyntaxSuggest/RipperErrors.md delete mode 100644 example/ruby/SyntaxSuggest/ScanHistory.md delete mode 100644 example/ruby/SyntaxSuggest/UnvisitedLines.md delete mode 100644 example/ruby/SystemCallError.md delete mode 100644 example/ruby/SystemExit.md delete mode 100644 example/ruby/SystemStackError.md delete mode 100644 example/ruby/TCPServer.md delete mode 100644 example/ruby/TCPSocket.md delete mode 100644 example/ruby/TC_Enumerable.md delete mode 100644 example/ruby/TC_IPAddr.md delete mode 100644 example/ruby/TC_OpenStruct.md delete mode 100644 example/ruby/TC_Operator.md delete mode 100644 example/ruby/TC_Set.md delete mode 100644 example/ruby/TC_Set/Set2.md delete mode 100644 example/ruby/TC_Set_Builtin.md delete mode 100644 example/ruby/TC_SortedSet.md delete mode 100644 example/ruby/TSort.md delete mode 100644 example/ruby/TSort/Cyclic.md delete mode 100644 example/ruby/TSortArray.md delete mode 100644 example/ruby/TSortHash.md delete mode 100644 example/ruby/TSortTest.md delete mode 100644 example/ruby/TagAction.md delete mode 100644 example/ruby/TagFilter.md delete mode 100644 example/ruby/TagListAction.md delete mode 100644 example/ruby/TagPurgeAction.md delete mode 100644 example/ruby/TagsVisitor.md delete mode 100644 example/ruby/Tally.md delete mode 100644 example/ruby/TallyAction.md delete mode 100644 example/ruby/Tarball.md delete mode 100644 example/ruby/Tempfile.md delete mode 100644 example/ruby/Tempfile/FinalizerManager.md delete mode 100644 example/ruby/Tempfile/PathAttr.md delete mode 100644 example/ruby/TerminationChecker.md delete mode 100644 example/ruby/Test.md delete mode 100644 example/ruby/Test/ASAN.md delete mode 100644 example/ruby/Test/BacktraceFilter.md delete mode 100644 example/ruby/Test/Unit.md delete mode 100644 example/ruby/Test/Unit/AssertionFailedError.md delete mode 100644 example/ruby/Test/Unit/Assertions.md delete mode 100644 example/ruby/Test/Unit/AutoRunner.md delete mode 100644 example/ruby/Test/Unit/AutoRunner/Runner.md delete mode 100644 example/ruby/Test/Unit/CoreAssertions.md delete mode 100644 example/ruby/Test/Unit/CoreAssertions/AllFailures.md delete mode 100644 example/ruby/Test/Unit/ExcludesOption.md delete mode 100644 example/ruby/Test/Unit/ExcludesOption/ExcludedMethods.md delete mode 100644 example/ruby/Test/Unit/FileAssertions.md delete mode 100644 example/ruby/Test/Unit/GCOption.md delete mode 100644 example/ruby/Test/Unit/GlobOption.md delete mode 100644 example/ruby/Test/Unit/Guard.md delete mode 100644 example/ruby/Test/Unit/LaunchableOption.md delete mode 100644 example/ruby/Test/Unit/LaunchableOption/Nothing.md delete mode 100644 example/ruby/Test/Unit/LifecycleHooks.md delete mode 100644 example/ruby/Test/Unit/LoadPathOption.md delete mode 100644 example/ruby/Test/Unit/Options.md delete mode 100644 example/ruby/Test/Unit/Order.md delete mode 100644 example/ruby/Test/Unit/Order/Alpha.md delete mode 100644 example/ruby/Test/Unit/Order/NoSort.md delete mode 100644 example/ruby/Test/Unit/Order/Shuffle.md delete mode 100644 example/ruby/Test/Unit/OutputOption.md delete mode 100644 example/ruby/Test/Unit/Parallel.md delete mode 100644 example/ruby/Test/Unit/Parallel/FakeClass.md delete mode 100644 example/ruby/Test/Unit/Parallel/Worker.md delete mode 100644 example/ruby/Test/Unit/PendedError.md delete mode 100644 example/ruby/Test/Unit/ProxyError.md delete mode 100644 example/ruby/Test/Unit/RepeatOption.md delete mode 100644 example/ruby/Test/Unit/RequireFiles.md delete mode 100644 example/ruby/Test/Unit/RunCount.md delete mode 100644 example/ruby/Test/Unit/Runner.md delete mode 100644 example/ruby/Test/Unit/Skipping.md delete mode 100644 example/ruby/Test/Unit/Statistics.md delete mode 100644 example/ruby/Test/Unit/StatusLine.md delete mode 100644 example/ruby/Test/Unit/StatusLine/Output.md delete mode 100644 example/ruby/Test/Unit/TestCase.md delete mode 100644 example/ruby/Test/Unit/TimeoutOption.md delete mode 100644 example/ruby/Test/Unit/Worker.md delete mode 100644 example/ruby/TestA.md delete mode 100644 example/ruby/TestABI.md delete mode 100644 example/ruby/TestAddressResolve.md delete mode 100644 example/ruby/TestAddressResolve/NullScheduler.md delete mode 100644 example/ruby/TestAddressResolve/StubScheduler.md delete mode 100644 example/ruby/TestAlias.md delete mode 100644 example/ruby/TestAlias/Alias0.md delete mode 100644 example/ruby/TestAlias/Alias1.md delete mode 100644 example/ruby/TestAlias/Alias2.md delete mode 100644 example/ruby/TestAlias/Alias3.md delete mode 100644 example/ruby/TestAlias/Alias4.md delete mode 100644 example/ruby/TestAlias/Alias5.md delete mode 100644 example/ruby/TestAlias/C0.md delete mode 100644 example/ruby/TestAlias/C1.md delete mode 100644 example/ruby/TestAlias/C2.md delete mode 100644 example/ruby/TestAlias/SuperInAliasedModuleMethod.md delete mode 100644 example/ruby/TestAlias/SuperInAliasedModuleMethod/Base.md delete mode 100644 example/ruby/TestAlias/SuperInAliasedModuleMethod/Derived.md delete mode 100644 example/ruby/TestAlias/SuperInAliasedModuleMethod/M.md delete mode 100644 example/ruby/TestAllRubyQuine.md delete mode 100644 example/ruby/TestAllocation.md delete mode 100644 example/ruby/TestAllocation/Literal.md delete mode 100644 example/ruby/TestAllocation/MethodCall.md delete mode 100644 example/ruby/TestAllocation/MethodCall/WithBlock.md delete mode 100644 example/ruby/TestAllocation/ProcCall.md delete mode 100644 example/ruby/TestAllocation/ProcCall/WithBlock.md delete mode 100644 example/ruby/TestArgf.md delete mode 100644 example/ruby/TestArithmeticSequence.md delete mode 100644 example/ruby/TestArity.md delete mode 100644 example/ruby/TestArray.md delete mode 100644 example/ruby/TestArraySubclass.md delete mode 100644 example/ruby/TestAssertion.md delete mode 100644 example/ruby/TestAssertion/VersionClass.md delete mode 100644 example/ruby/TestAssignment.md delete mode 100644 example/ruby/TestAssignment/Base.md delete mode 100644 example/ruby/TestAssignment/MyObj.md delete mode 100644 example/ruby/TestAssignmentGen.md delete mode 100644 example/ruby/TestAst.md delete mode 100644 example/ruby/TestAst/Helper.md delete mode 100644 example/ruby/TestAst/TestLocation.md delete mode 100644 example/ruby/TestAutoload.md delete mode 100644 example/ruby/TestB.md delete mode 100644 example/ruby/TestBacktrace.md delete mode 100644 example/ruby/TestBasicInstructions.md delete mode 100644 example/ruby/TestBasicInstructions/CVarA.md delete mode 100644 example/ruby/TestBasicInstructions/CVarB.md delete mode 100644 example/ruby/TestBasicInstructions/Const.md delete mode 100644 example/ruby/TestBasicInstructions/Const/A.md delete mode 100644 example/ruby/TestBasicInstructions/Const/A/B.md delete mode 100644 example/ruby/TestBasicInstructions/Const/AA.md delete mode 100644 example/ruby/TestBasicInstructions/Const/AAA.md delete mode 100644 example/ruby/TestBasicInstructions/OP.md delete mode 100644 example/ruby/TestBeginEndBlock.md delete mode 100644 example/ruby/TestBenchmark.md delete mode 100644 example/ruby/TestBig5.md delete mode 100644 example/ruby/TestBignum_Big2str.md delete mode 100644 example/ruby/TestBignum_BigZero.md delete mode 100644 example/ruby/TestBignum_Div.md delete mode 100644 example/ruby/TestBignum_Mul.md delete mode 100644 example/ruby/TestBignum_Pack.md delete mode 100644 example/ruby/TestBignum_Str2big.md delete mode 100644 example/ruby/TestBugReporter.md delete mode 100644 example/ruby/TestBundlerGem.md delete mode 100644 example/ruby/TestC.md delete mode 100644 example/ruby/TestCESU8.md delete mode 100644 example/ruby/TestCP949.md delete mode 100644 example/ruby/TestCall.md delete mode 100644 example/ruby/TestCall/RefinedModuleLargeArrayTest.md delete mode 100644 example/ruby/TestCase.md delete mode 100644 example/ruby/TestCase/NilEqq.md delete mode 100644 example/ruby/TestCase/NilEqqClass.md delete mode 100644 example/ruby/TestCaseFold.md delete mode 100644 example/ruby/TestCaseFold/CaseTest.md delete mode 100644 example/ruby/TestCaseForDict.md delete mode 100644 example/ruby/TestCaseMappingPreliminary.md delete mode 100644 example/ruby/TestCaseOptions.md delete mode 100644 example/ruby/TestCiDetector.md delete mode 100644 example/ruby/TestClass.md delete mode 100644 example/ruby/TestClass/ClassFour.md delete mode 100644 example/ruby/TestClass/ClassOne.md delete mode 100644 example/ruby/TestClass/ClassThree.md delete mode 100644 example/ruby/TestClass/ClassTwo.md delete mode 100644 example/ruby/TestClass/CloneTest.md delete mode 100644 example/ruby/TestClass/CloneTest1.md delete mode 100644 example/ruby/TestClass/CloneTest2.md delete mode 100644 example/ruby/TestClone.md delete mode 100644 example/ruby/TestClone/M001.md delete mode 100644 example/ruby/TestClone/M002.md delete mode 100644 example/ruby/TestClone/M003.md delete mode 100644 example/ruby/TestCompactIndexClient.md delete mode 100644 example/ruby/TestComparable.md delete mode 100644 example/ruby/TestComprehensiveCaseMapping.md delete mode 100644 example/ruby/TestConcatStress.md delete mode 100644 example/ruby/TestCondition.md delete mode 100644 example/ruby/TestConst.md delete mode 100644 example/ruby/TestContinuation.md delete mode 100644 example/ruby/TestCoverage.md delete mode 100644 example/ruby/TestCoverage/DummyConstant.md delete mode 100644 example/ruby/TestD.md delete mode 100644 example/ruby/TestData.md delete mode 100644 example/ruby/TestDate.md delete mode 100644 example/ruby/TestDateArith.md delete mode 100644 example/ruby/TestDateArith/Rat.md delete mode 100644 example/ruby/TestDateAttr.md delete mode 100644 example/ruby/TestDateCompat.md delete mode 100644 example/ruby/TestDateConv.md delete mode 100644 example/ruby/TestDateMarshal.md delete mode 100644 example/ruby/TestDateNew.md delete mode 100644 example/ruby/TestDateParse.md delete mode 100644 example/ruby/TestDateParseRactor.md delete mode 100644 example/ruby/TestDateStrftime.md delete mode 100644 example/ruby/TestDateStrptime.md delete mode 100644 example/ruby/TestDebug.md delete mode 100644 example/ruby/TestDebug/MyRelation.md delete mode 100644 example/ruby/TestDefaultGems.md delete mode 100644 example/ruby/TestDefined.md delete mode 100644 example/ruby/TestDefined/ExampleRespondToMissing.md delete mode 100644 example/ruby/TestDefined/Foo.md delete mode 100644 example/ruby/TestDefined/RefinedClass.md delete mode 100644 example/ruby/TestDefined/RefiningModule.md delete mode 100644 example/ruby/TestDefined/TestAutoloadedNoload.md delete mode 100644 example/ruby/TestDefined/TestAutoloadedSubclass.md delete mode 100644 example/ruby/TestDefined/TestAutoloadedSuperclass.md delete mode 100644 example/ruby/TestDelegateClass.md delete mode 100644 example/ruby/TestDelegateClass/Bar.md delete mode 100644 example/ruby/TestDelegateClass/Bug9155.md delete mode 100644 example/ruby/TestDelegateClass/Bug9403.md delete mode 100644 example/ruby/TestDelegateClass/Child.md delete mode 100644 example/ruby/TestDelegateClass/Foo.md delete mode 100644 example/ruby/TestDelegateClass/IV.md delete mode 100644 example/ruby/TestDelegateClass/M.md delete mode 100644 example/ruby/TestDelegateClass/Myclass.md delete mode 100644 example/ruby/TestDelegateClass/Object.md delete mode 100644 example/ruby/TestDelegateClass/Parent.md delete mode 100644 example/ruby/TestDigest.md delete mode 100644 example/ruby/TestDigest/TestBase.md delete mode 100644 example/ruby/TestDigest/TestDigestParen.md delete mode 100644 example/ruby/TestDigest/TestInitCopy.md delete mode 100644 example/ruby/TestDigest/TestMD5.md delete mode 100644 example/ruby/TestDigest/TestRMD160.md delete mode 100644 example/ruby/TestDigest/TestSHA1.md delete mode 100644 example/ruby/TestDigest/TestSHA2.md delete mode 100644 example/ruby/TestDigest/TestSHA256.md delete mode 100644 example/ruby/TestDigest/TestSHA384.md delete mode 100644 example/ruby/TestDigest/TestSHA512.md delete mode 100644 example/ruby/TestDigestExtend.md delete mode 100644 example/ruby/TestDigestExtend/MyDigest.md delete mode 100644 example/ruby/TestDigestRactor.md delete mode 100644 example/ruby/TestDigestRactor/TestMD5Ractor.md delete mode 100644 example/ruby/TestDigestRactor/TestRMD160Ractor.md delete mode 100644 example/ruby/TestDigestRactor/TestSHA1Ractor.md delete mode 100644 example/ruby/TestDigestRactor/TestSHA256Ractor.md delete mode 100644 example/ruby/TestDigestRactor/TestSHA384Ractor.md delete mode 100644 example/ruby/TestDigestRactor/TestSHA512Ractor.md delete mode 100644 example/ruby/TestDir.md delete mode 100644 example/ruby/TestDir_M17N.md delete mode 100644 example/ruby/TestDup.md delete mode 100644 example/ruby/TestDup/M001.md delete mode 100644 example/ruby/TestDup/M002.md delete mode 100644 example/ruby/TestDup/M003.md delete mode 100644 example/ruby/TestE.md delete mode 100644 example/ruby/TestE/UnknownError.md delete mode 100644 example/ruby/TestEOF.md delete mode 100644 example/ruby/TestEOF/Seek.md delete mode 100644 example/ruby/TestERB.md delete mode 100644 example/ruby/TestERB/MyError.md delete mode 100644 example/ruby/TestERBCore.md delete mode 100644 example/ruby/TestERBCore/Foo.md delete mode 100644 example/ruby/TestERBCoreWOStrScan.md delete mode 100644 example/ruby/TestERBEncoding.md delete mode 100644 example/ruby/TestERBEncoding/M.md delete mode 100644 example/ruby/TestEUC_JP.md delete mode 100644 example/ruby/TestEmojiBreaks.md delete mode 100644 example/ruby/TestEmojiBreaks/BreakFile.md delete mode 100644 example/ruby/TestEmojiBreaks/BreakTest.md delete mode 100644 example/ruby/TestEncoding.md delete mode 100644 example/ruby/TestEncodingConverter.md delete mode 100644 example/ruby/TestEnsureAndCallcc.md delete mode 100644 example/ruby/TestEnumerable.md delete mode 100644 example/ruby/TestEnumerable/Foo.md delete mode 100644 example/ruby/TestEnumerator.md delete mode 100644 example/ruby/TestEnumeratorKw.md delete mode 100644 example/ruby/TestEnv.md delete mode 100644 example/ruby/TestErbCommand.md delete mode 100644 example/ruby/TestErrInCallBack.md delete mode 100644 example/ruby/TestEtc.md delete mode 100644 example/ruby/TestEucKr.md delete mode 100644 example/ruby/TestEucTw.md delete mode 100644 example/ruby/TestEval.md delete mode 100644 example/ruby/TestEval/Foo.md delete mode 100644 example/ruby/TestException.md delete mode 100644 example/ruby/TestExtLibs.md delete mode 100644 example/ruby/TestFiber.md delete mode 100644 example/ruby/TestFiberBacktrace.md delete mode 100644 example/ruby/TestFiberCurrentRactor.md delete mode 100644 example/ruby/TestFiberEnumerator.md delete mode 100644 example/ruby/TestFiberIO.md delete mode 100644 example/ruby/TestFiberIOBuffer.md delete mode 100644 example/ruby/TestFiberMutex.md delete mode 100644 example/ruby/TestFiberProcess.md delete mode 100644 example/ruby/TestFiberQueue.md delete mode 100644 example/ruby/TestFiberScheduler.md delete mode 100644 example/ruby/TestFiberSchedulerAutoload.md delete mode 100644 example/ruby/TestFiberSleep.md delete mode 100644 example/ruby/TestFiberStorage.md delete mode 100644 example/ruby/TestFiberThread.md delete mode 100644 example/ruby/TestFiberTimeout.md delete mode 100644 example/ruby/TestFiddle.md delete mode 100644 example/ruby/TestFile.md delete mode 100644 example/ruby/TestFile/NewlineConvTests.md delete mode 100644 example/ruby/TestFileExhaustive.md delete mode 100644 example/ruby/TestFileUtils.md delete mode 100644 example/ruby/TestFileUtils/Stream.md delete mode 100644 example/ruby/TestFileUtilsClobber.md delete mode 100644 example/ruby/TestFileUtilsDryRun.md delete mode 100644 example/ruby/TestFileUtilsIncVisibility.md delete mode 100644 example/ruby/TestFileUtilsNoWrite.md delete mode 100644 example/ruby/TestFileUtilsVerbose.md delete mode 100644 example/ruby/TestFind.md delete mode 100644 example/ruby/TestFind/TestInclude.md delete mode 100644 example/ruby/TestFixnum.md delete mode 100644 example/ruby/TestFixnum/DummyNumeric.md delete mode 100644 example/ruby/TestFlip.md delete mode 100644 example/ruby/TestFloat.md delete mode 100644 example/ruby/TestFloatExt.md delete mode 100644 example/ruby/TestFnmatch.md delete mode 100644 example/ruby/TestForTestHideSkip.md delete mode 100644 example/ruby/TestForTestRedefinition.md delete mode 100644 example/ruby/TestForTestTimeout.md delete mode 100644 example/ruby/TestFormatter.md delete mode 100644 example/ruby/TestFormatter/CustomFormatter.md delete mode 100644 example/ruby/TestForwardable.md delete mode 100644 example/ruby/TestForwardable/Foo.md delete mode 100644 example/ruby/TestForwardable/Foo2.md delete mode 100644 example/ruby/TestFrozen.md delete mode 100644 example/ruby/TestFrozenError.md delete mode 100644 example/ruby/TestFuncall.md delete mode 100644 example/ruby/TestFuncall/Relay.md delete mode 100644 example/ruby/TestGB18030.md delete mode 100644 example/ruby/TestGBK.md delete mode 100644 example/ruby/TestGCCompact.md delete mode 100644 example/ruby/TestGCCompact/AutoCompact.md delete mode 100644 example/ruby/TestGCCompact/CompactMethodsNotImplemented.md delete mode 100644 example/ruby/TestGCCompact/CompactionSupportInspector.md delete mode 100644 example/ruby/TestGCCompact/OmitUnlessCompactSupported.md delete mode 100644 example/ruby/TestGc.md delete mode 100644 example/ruby/TestGc/S.md delete mode 100644 example/ruby/TestGem.md delete mode 100644 example/ruby/TestGemAvailableSet.md delete mode 100644 example/ruby/TestGemBundledCA.md delete mode 100644 example/ruby/TestGemBundlerVersionFinder.md delete mode 100644 example/ruby/TestGemCommand.md delete mode 100644 example/ruby/TestGemCommandManager.md delete mode 100644 example/ruby/TestGemCommandsBuildCommand.md delete mode 100644 example/ruby/TestGemCommandsCertCommand.md delete mode 100644 example/ruby/TestGemCommandsCheckCommand.md delete mode 100644 example/ruby/TestGemCommandsCleanupCommand.md delete mode 100644 example/ruby/TestGemCommandsContentsCommand.md delete mode 100644 example/ruby/TestGemCommandsDependencyCommand.md delete mode 100644 example/ruby/TestGemCommandsEnvironmentCommand.md delete mode 100644 example/ruby/TestGemCommandsExecCommand.md delete mode 100644 example/ruby/TestGemCommandsFetchCommand.md delete mode 100644 example/ruby/TestGemCommandsHelpCommand.md delete mode 100644 example/ruby/TestGemCommandsInfoCommand.md delete mode 100644 example/ruby/TestGemCommandsInstallCommand.md delete mode 100644 example/ruby/TestGemCommandsListCommand.md delete mode 100644 example/ruby/TestGemCommandsLockCommand.md delete mode 100644 example/ruby/TestGemCommandsMirrorCommand.md delete mode 100644 example/ruby/TestGemCommandsOpenCommand.md delete mode 100644 example/ruby/TestGemCommandsOutdatedCommand.md delete mode 100644 example/ruby/TestGemCommandsOwnerCommand.md delete mode 100644 example/ruby/TestGemCommandsPristineCommand.md delete mode 100644 example/ruby/TestGemCommandsPushCommand.md delete mode 100644 example/ruby/TestGemCommandsQueryCommandSetup.md delete mode 100644 example/ruby/TestGemCommandsQueryCommandWithInstalledGems.md delete mode 100644 example/ruby/TestGemCommandsQueryCommandWithoutInstalledGems.md delete mode 100644 example/ruby/TestGemCommandsRebuildCommand.md delete mode 100644 example/ruby/TestGemCommandsSearchCommand.md delete mode 100644 example/ruby/TestGemCommandsServerCommand.md delete mode 100644 example/ruby/TestGemCommandsSetupCommand.md delete mode 100644 example/ruby/TestGemCommandsSigninCommand.md delete mode 100644 example/ruby/TestGemCommandsSignoutCommand.md delete mode 100644 example/ruby/TestGemCommandsSourcesCommand.md delete mode 100644 example/ruby/TestGemCommandsSpecificationCommand.md delete mode 100644 example/ruby/TestGemCommandsStaleCommand.md delete mode 100644 example/ruby/TestGemCommandsUninstallCommand.md delete mode 100644 example/ruby/TestGemCommandsUnpackCommand.md delete mode 100644 example/ruby/TestGemCommandsUpdateCommand.md delete mode 100644 example/ruby/TestGemCommandsWhichCommand.md delete mode 100644 example/ruby/TestGemCommandsYankCommand.md delete mode 100644 example/ruby/TestGemConfig.md delete mode 100644 example/ruby/TestGemConfigFile.md delete mode 100644 example/ruby/TestGemConsoleUI.md delete mode 100644 example/ruby/TestGemDependency.md delete mode 100644 example/ruby/TestGemDependencyInstaller.md delete mode 100644 example/ruby/TestGemDependencyList.md delete mode 100644 example/ruby/TestGemDependencyResolutionError.md delete mode 100644 example/ruby/TestGemDeprecate.md delete mode 100644 example/ruby/TestGemDeprecate/OtherThing.md delete mode 100644 example/ruby/TestGemDeprecate/Thing.md delete mode 100644 example/ruby/TestGemDoctor.md delete mode 100644 example/ruby/TestGemExit.md delete mode 100644 example/ruby/TestGemExtBuilder.md delete mode 100644 example/ruby/TestGemExtCargoBuilder.md delete mode 100644 example/ruby/TestGemExtCargoBuilderLinkFlagConverter.md delete mode 100644 example/ruby/TestGemExtCargoBuilderUnit.md delete mode 100644 example/ruby/TestGemExtCmakeBuilder.md delete mode 100644 example/ruby/TestGemExtConfigureBuilder.md delete mode 100644 example/ruby/TestGemExtExtConfBuilder.md delete mode 100644 example/ruby/TestGemExtRakeBuilder.md delete mode 100644 example/ruby/TestGemGemRunner.md delete mode 100644 example/ruby/TestGemGemcutterUtilities.md delete mode 100644 example/ruby/TestGemGemcutterUtilities/SignInFetcher.md delete mode 100644 example/ruby/TestGemImpossibleDependenciesError.md delete mode 100644 example/ruby/TestGemInstallUpdateOptions.md delete mode 100644 example/ruby/TestGemInstaller.md delete mode 100644 example/ruby/TestGemKernel.md delete mode 100644 example/ruby/TestGemLocalRemoteOptions.md delete mode 100644 example/ruby/TestGemNameTuple.md delete mode 100644 example/ruby/TestGemPackage.md delete mode 100644 example/ruby/TestGemPackageOld.md delete mode 100644 example/ruby/TestGemPackageTarHeader.md delete mode 100644 example/ruby/TestGemPackageTarReader.md delete mode 100644 example/ruby/TestGemPackageTarReaderEntry.md delete mode 100644 example/ruby/TestGemPackageTarWriter.md delete mode 100644 example/ruby/TestGemPackageTask.md delete mode 100644 example/ruby/TestGemPathSupport.md delete mode 100644 example/ruby/TestGemPlatform.md delete mode 100644 example/ruby/TestGemProjectSanity.md delete mode 100644 example/ruby/TestGemRDoc.md delete mode 100644 example/ruby/TestGemRemoteFetchError.md delete mode 100644 example/ruby/TestGemRemoteFetcher.md delete mode 100644 example/ruby/TestGemRemoteFetcherLocalSSLServer.md delete mode 100644 example/ruby/TestGemRemoteFetcherLocalServer.md delete mode 100644 example/ruby/TestGemRemoteFetcherS3.md delete mode 100644 example/ruby/TestGemRequest.md delete mode 100644 example/ruby/TestGemRequest/Conn.md delete mode 100644 example/ruby/TestGemRequestConnectionPool.md delete mode 100644 example/ruby/TestGemRequestConnectionPool/FakeHttp.md delete mode 100644 example/ruby/TestGemRequestSet.md delete mode 100644 example/ruby/TestGemRequestSetGemDependencyAPI.md delete mode 100644 example/ruby/TestGemRequestSetLockfile.md delete mode 100644 example/ruby/TestGemRequestSetLockfileParser.md delete mode 100644 example/ruby/TestGemRequestSetLockfileTokenizer.md delete mode 100644 example/ruby/TestGemRequire.md delete mode 100644 example/ruby/TestGemRequire/Latch.md delete mode 100644 example/ruby/TestGemRequirement.md delete mode 100644 example/ruby/TestGemRequirement/Exploit.md delete mode 100644 example/ruby/TestGemResolver.md delete mode 100644 example/ruby/TestGemResolverAPISet.md delete mode 100644 example/ruby/TestGemResolverAPISpecification.md delete mode 100644 example/ruby/TestGemResolverActivationRequest.md delete mode 100644 example/ruby/TestGemResolverBestSet.md delete mode 100644 example/ruby/TestGemResolverComposedSet.md delete mode 100644 example/ruby/TestGemResolverConflict.md delete mode 100644 example/ruby/TestGemResolverDependencyRequest.md delete mode 100644 example/ruby/TestGemResolverGitSet.md delete mode 100644 example/ruby/TestGemResolverGitSpecification.md delete mode 100644 example/ruby/TestGemResolverIndexSet.md delete mode 100644 example/ruby/TestGemResolverIndexSpecification.md delete mode 100644 example/ruby/TestGemResolverInstalledSpecification.md delete mode 100644 example/ruby/TestGemResolverInstallerSet.md delete mode 100644 example/ruby/TestGemResolverLocalSpecification.md delete mode 100644 example/ruby/TestGemResolverLockSet.md delete mode 100644 example/ruby/TestGemResolverLockSpecification.md delete mode 100644 example/ruby/TestGemResolverRequirementList.md delete mode 100644 example/ruby/TestGemResolverSpecification.md delete mode 100644 example/ruby/TestGemResolverSpecification/TestSpec.md delete mode 100644 example/ruby/TestGemResolverVendorSet.md delete mode 100644 example/ruby/TestGemResolverVendorSpecification.md delete mode 100644 example/ruby/TestGemSafeMarshal.md delete mode 100644 example/ruby/TestGemSafeMarshal/ArraySubclass.md delete mode 100644 example/ruby/TestGemSafeMarshal/StringSubclass.md delete mode 100644 example/ruby/TestGemSafeMarshal/UserMarshal.md delete mode 100644 example/ruby/TestGemSafeYAML.md delete mode 100644 example/ruby/TestGemSecurity.md delete mode 100644 example/ruby/TestGemSecurityPolicy.md delete mode 100644 example/ruby/TestGemSecuritySigner.md delete mode 100644 example/ruby/TestGemSecurityTrustDir.md delete mode 100644 example/ruby/TestGemSilentUI.md delete mode 100644 example/ruby/TestGemSource.md delete mode 100644 example/ruby/TestGemSourceFetchProblem.md delete mode 100644 example/ruby/TestGemSourceGit.md delete mode 100644 example/ruby/TestGemSourceInstalled.md delete mode 100644 example/ruby/TestGemSourceList.md delete mode 100644 example/ruby/TestGemSourceLocal.md delete mode 100644 example/ruby/TestGemSourceLock.md delete mode 100644 example/ruby/TestGemSourceSpecificFile.md delete mode 100644 example/ruby/TestGemSourceSubpathProblem.md delete mode 100644 example/ruby/TestGemSourceVendor.md delete mode 100644 example/ruby/TestGemSpecFetcher.md delete mode 100644 example/ruby/TestGemSpecification.md delete mode 100644 example/ruby/TestGemStreamUI.md delete mode 100644 example/ruby/TestGemStreamUI/IsTty.md delete mode 100644 example/ruby/TestGemText.md delete mode 100644 example/ruby/TestGemUninstaller.md delete mode 100644 example/ruby/TestGemUnsatisfiableDependencyError.md delete mode 100644 example/ruby/TestGemUriFormatter.md delete mode 100644 example/ruby/TestGemUtil.md delete mode 100644 example/ruby/TestGemValidator.md delete mode 100644 example/ruby/TestGemVersion.md delete mode 100644 example/ruby/TestGemVersion/V.md delete mode 100644 example/ruby/TestGemVersionOption.md delete mode 100644 example/ruby/TestGraphemeBreaksFromFile.md delete mode 100644 example/ruby/TestGraphemeBreaksFromFile/BreakTest.md delete mode 100644 example/ruby/TestHash.md delete mode 100644 example/ruby/TestHash/ObjWithHash.md delete mode 100644 example/ruby/TestHash/TestSubHash.md delete mode 100644 example/ruby/TestHash/TestSubHash/SubHash.md delete mode 100644 example/ruby/TestHashOnly.md delete mode 100644 example/ruby/TestHideSkip.md delete mode 100644 example/ruby/TestHung.md delete mode 100644 example/ruby/TestIO.md delete mode 100644 example/ruby/TestIO/Bug5237.md delete mode 100644 example/ruby/TestIO/Feature.md delete mode 100644 example/ruby/TestIO/Rot13IO.md delete mode 100644 example/ruby/TestIOBuffer.md delete mode 100644 example/ruby/TestIOConsoleInRactor.md delete mode 100644 example/ruby/TestIONonblock.md delete mode 100644 example/ruby/TestIOTimeout.md delete mode 100644 example/ruby/TestIOWait.md delete mode 100644 example/ruby/TestIOWaitInRactor.md delete mode 100644 example/ruby/TestIOWaitUncommon.md delete mode 100644 example/ruby/TestIO_Console.md delete mode 100644 example/ruby/TestIO_M17N.md delete mode 100644 example/ruby/TestIRB.md delete mode 100644 example/ruby/TestIRB/BacktraceFilteringTest.md delete mode 100644 example/ruby/TestIRB/CDTest.md delete mode 100644 example/ruby/TestIRB/ChwsTest.md delete mode 100644 example/ruby/TestIRB/ColorPrinterTest.md delete mode 100644 example/ruby/TestIRB/ColorPrinterTest/IRBTestColorPrinter.md delete mode 100644 example/ruby/TestIRB/ColorTest.md delete mode 100644 example/ruby/TestIRB/CommandTestCase.md delete mode 100644 example/ruby/TestIRB/CompletionTest.md delete mode 100644 example/ruby/TestIRB/CompletionTest/CommandCompletionTest.md delete mode 100644 example/ruby/TestIRB/CompletionTest/ConstantCompletionTest.md delete mode 100644 example/ruby/TestIRB/CompletionTest/ConstantCompletionTest/Foo.md delete mode 100644 example/ruby/TestIRB/CompletionTest/MethodCompletionTest.md delete mode 100644 example/ruby/TestIRB/CompletionTest/RequireComepletionTest.md delete mode 100644 example/ruby/TestIRB/CompletionTest/VariableCompletionTest.md delete mode 100644 example/ruby/TestIRB/ConfigValidationTest.md delete mode 100644 example/ruby/TestIRB/ContextTest.md delete mode 100644 example/ruby/TestIRB/ContextWithTracerIntegrationTest.md delete mode 100644 example/ruby/TestIRB/CustomCommandIntegrationTest.md delete mode 100644 example/ruby/TestIRB/CwwsTest.md delete mode 100644 example/ruby/TestIRB/DebuggerIntegrationTest.md delete mode 100644 example/ruby/TestIRB/DeprecatedInputCompletorTest.md delete mode 100644 example/ruby/TestIRB/DisableIRBTest.md delete mode 100644 example/ruby/TestIRB/DisplayDocumentTest.md delete mode 100644 example/ruby/TestIRB/EchoingTest.md delete mode 100644 example/ruby/TestIRB/EditTest.md delete mode 100644 example/ruby/TestIRB/EvalHistoryTest.md delete mode 100644 example/ruby/TestIRB/ForceExitTest.md delete mode 100644 example/ruby/TestIRB/FrozenObjectTest.md delete mode 100644 example/ruby/TestIRB/HelpTest.md delete mode 100644 example/ruby/TestIRB/HelperMethodInsallTest.md delete mode 100644 example/ruby/TestIRB/HelperMethodIntegrationTest.md delete mode 100644 example/ruby/TestIRB/HelperMethodTestCase.md delete mode 100644 example/ruby/TestIRB/HistoryCmdTest.md delete mode 100644 example/ruby/TestIRB/HistoryTest.md delete mode 100644 example/ruby/TestIRB/HistoryTest/TestInputMethodWithReadlineHistory.md delete mode 100644 example/ruby/TestIRB/HistoryTest/TestInputMethodWithRelineHistory.md delete mode 100644 example/ruby/TestIRB/IRBHistoryIntegrationTest.md delete mode 100644 example/ruby/TestIRB/InfoTest.md delete mode 100644 example/ruby/TestIRB/InitIntegrationTest.md delete mode 100644 example/ruby/TestIRB/InitTest.md delete mode 100644 example/ruby/TestIRB/InputMethodTest.md delete mode 100644 example/ruby/TestIRB/InputTest.md delete mode 100644 example/ruby/TestIRB/IntegrationTestCase.md delete mode 100644 example/ruby/TestIRB/IrbIOConfigurationTest.md delete mode 100644 example/ruby/TestIRB/IrbIOConfigurationTest/AutoIndentationTest.md delete mode 100644 example/ruby/TestIRB/IrbIOConfigurationTest/DynamicPromptTest.md delete mode 100644 example/ruby/TestIRB/IrbIOConfigurationTest/MockIO_AutoIndent.md delete mode 100644 example/ruby/TestIRB/IrbIOConfigurationTest/MockIO_DynamicPrompt.md delete mode 100644 example/ruby/TestIRB/IrbIOConfigurationTest/Row.md delete mode 100644 example/ruby/TestIRB/IrbLoadTest.md delete mode 100644 example/ruby/TestIRB/IrbSourceTest.md delete mode 100644 example/ruby/TestIRB/LocaleTestCase.md delete mode 100644 example/ruby/TestIRB/LsTest.md delete mode 100644 example/ruby/TestIRB/MeasureTest.md delete mode 100644 example/ruby/TestIRB/MultiIRBTest.md delete mode 100644 example/ruby/TestIRB/NestedBindingIrbTest.md delete mode 100644 example/ruby/TestIRB/NestingParserTest.md delete mode 100644 example/ruby/TestIRB/OptionTest.md delete mode 100644 example/ruby/TestIRB/PopwsTest.md delete mode 100644 example/ruby/TestIRB/PushwsTest.md delete mode 100644 example/ruby/TestIRB/RaiseExceptionTest.md delete mode 100644 example/ruby/TestIRB/RelineInputMethodTest.md delete mode 100644 example/ruby/TestIRB/RubyLexTest.md delete mode 100644 example/ruby/TestIRB/ShowDocTest.md delete mode 100644 example/ruby/TestIRB/ShowSourceTest.md delete mode 100644 example/ruby/TestIRB/TestCase.md delete mode 100644 example/ruby/TestIRB/TestCase/TestInputMethod.md delete mode 100644 example/ruby/TestIRB/TestHelperMethod.md delete mode 100644 example/ruby/TestIRB/TestHelperMethod/ConfTest.md delete mode 100644 example/ruby/TestIRB/TypeCompletorIntegrationTest.md delete mode 100644 example/ruby/TestIRB/TypeCompletorTest.md delete mode 100644 example/ruby/TestIRB/TypeCompletorTest/DummyContext.md delete mode 100644 example/ruby/TestIRB/WhereamiTest.md delete mode 100644 example/ruby/TestIRB/WorkSpaceTest.md delete mode 100644 example/ruby/TestIRB/WorkspaceCommandTestCase.md delete mode 100644 example/ruby/TestIRB/WorkspacesTest.md delete mode 100644 example/ruby/TestISO8859.md delete mode 100644 example/ruby/TestISeq.md delete mode 100644 example/ruby/TestIfUnless.md delete mode 100644 example/ruby/TestInsnsLeaf.md delete mode 100644 example/ruby/TestInsnsLeaf/Id.md delete mode 100644 example/ruby/TestInsnsLeaf/Namespace.md delete mode 100644 example/ruby/TestInteger.md delete mode 100644 example/ruby/TestInteger/CoercionToInt.md delete mode 100644 example/ruby/TestInteger/CoercionToSelf.md delete mode 100644 example/ruby/TestInteger/MimicInteger.md delete mode 100644 example/ruby/TestIntegerComb.md delete mode 100644 example/ruby/TestInvokeVerb.md delete mode 100644 example/ruby/TestIseqLoad.md delete mode 100644 example/ruby/TestIter.md delete mode 100644 example/ruby/TestIter/IterBreak.md delete mode 100644 example/ruby/TestIter/YieldBlock.md delete mode 100644 example/ruby/TestIter/YieldBlock/YieldTest.md delete mode 100644 example/ruby/TestIterator.md delete mode 100644 example/ruby/TestIterator/C.md delete mode 100644 example/ruby/TestIterator/H.md delete mode 100644 example/ruby/TestIterator/ITER_TEST1.md delete mode 100644 example/ruby/TestIterator/ITER_TEST2.md delete mode 100644 example/ruby/TestIterator/ITER_TEST3.md delete mode 100644 example/ruby/TestIterator/ITER_TEST4.md delete mode 100644 example/ruby/TestIterator/IterString.md delete mode 100644 example/ruby/TestIterator/IterTest.md delete mode 100644 example/ruby/TestKOI8.md delete mode 100644 example/ruby/TestKeyError.md delete mode 100644 example/ruby/TestKeywordArguments.md delete mode 100644 example/ruby/TestKeywordArguments/AttrSetTest.md delete mode 100644 example/ruby/TestKeywordArgumentsSymProcRefinements.md delete mode 100644 example/ruby/TestKeywordArgumentsSymProcRefinements/C.md delete mode 100644 example/ruby/TestLLDBInit.md delete mode 100644 example/ruby/TestLambdaParameters.md delete mode 100644 example/ruby/TestLastThread.md delete mode 100644 example/ruby/TestLaunchable.md delete mode 100644 example/ruby/TestLazyEnumerator.md delete mode 100644 example/ruby/TestLazyEnumerator/Step.md delete mode 100644 example/ruby/TestLoadFailure.md delete mode 100644 example/ruby/TestLogDevice.md delete mode 100644 example/ruby/TestLogDevice/LogExcnRaiser.md delete mode 100644 example/ruby/TestLogPeriod.md delete mode 100644 example/ruby/TestLogger.md delete mode 100644 example/ruby/TestLogger/CustomLogger.md delete mode 100644 example/ruby/TestLogger/Log.md delete mode 100644 example/ruby/TestLogger/MyError.md delete mode 100644 example/ruby/TestLogger/MyMsg.md delete mode 100644 example/ruby/TestLoggerSeverity.md delete mode 100644 example/ruby/TestM17N.md delete mode 100644 example/ruby/TestM17N/AESU.md delete mode 100644 example/ruby/TestM17NComb.md delete mode 100644 example/ruby/TestM17NComb/AESU.md delete mode 100644 example/ruby/TestMarshal.md delete mode 100644 example/ruby/TestMarshal/Bug12974.md delete mode 100644 example/ruby/TestMarshal/Bug14314.md delete mode 100644 example/ruby/TestMarshal/Bug15968.md delete mode 100644 example/ruby/TestMarshal/Bug15968/Bar.md delete mode 100644 example/ruby/TestMarshal/Bug7627.md delete mode 100644 example/ruby/TestMarshal/Bug8276.md delete mode 100644 example/ruby/TestMarshal/Bug9523.md delete mode 100644 example/ruby/TestMarshal/C.md delete mode 100644 example/ruby/TestMarshal/C2.md delete mode 100644 example/ruby/TestMarshal/C4.md delete mode 100644 example/ruby/TestMarshal/C5.md delete mode 100644 example/ruby/TestMarshal/C6.md delete mode 100644 example/ruby/TestMarshal/DumpTest.md delete mode 100644 example/ruby/TestMarshal/FrozenData.md delete mode 100644 example/ruby/TestMarshal/LoadData.md delete mode 100644 example/ruby/TestMarshal/LoadTest.md delete mode 100644 example/ruby/TestMarshal/MethodMissingWithoutRespondTo.md delete mode 100644 example/ruby/TestMarshal/TestClass.md delete mode 100644 example/ruby/TestMarshal/TestForRespondToFalse.md delete mode 100644 example/ruby/TestMarshal/TestMarshalFreeze.md delete mode 100644 example/ruby/TestMarshal/TestMarshalFreezeProc.md delete mode 100644 example/ruby/TestMarshal/TestModule.md delete mode 100644 example/ruby/TestMath.md delete mode 100644 example/ruby/TestMemoryView.md delete mode 100644 example/ruby/TestMetaclass.md delete mode 100644 example/ruby/TestMetaclass/Bar.md delete mode 100644 example/ruby/TestMetaclass/Baz.md delete mode 100644 example/ruby/TestMetaclass/Foo.md delete mode 100644 example/ruby/TestMethod.md delete mode 100644 example/ruby/TestMethod/Base.md delete mode 100644 example/ruby/TestMethod/C.md delete mode 100644 example/ruby/TestMethod/Derived.md delete mode 100644 example/ruby/TestMethod/M.md delete mode 100644 example/ruby/TestMethod/T.md delete mode 100644 example/ruby/TestMethod/Visibility.md delete mode 100644 example/ruby/TestMethodCache.md delete mode 100644 example/ruby/TestMethodInlineCache.md delete mode 100644 example/ruby/TestMiniTestGuard.md delete mode 100644 example/ruby/TestMiniTestRunner.md delete mode 100644 example/ruby/TestMiniTestRunner/Latch.md delete mode 100644 example/ruby/TestMiniTestUnit.md delete mode 100644 example/ruby/TestMiniTestUnitInherited.md delete mode 100644 example/ruby/TestMiniTestUnitOrder.md delete mode 100644 example/ruby/TestMiniTestUnitRecording.md delete mode 100644 example/ruby/TestMiniTestUnitTestCase.md delete mode 100644 example/ruby/TestMixedUnicodeEscape.md delete mode 100644 example/ruby/TestMkmf.md delete mode 100644 example/ruby/TestMkmf/Base.md delete mode 100644 example/ruby/TestMkmf/Base/Capture.md delete mode 100644 example/ruby/TestMkmfConfig.md delete mode 100644 example/ruby/TestMkmfConfiguration.md delete mode 100644 example/ruby/TestMkmfConvertible.md delete mode 100644 example/ruby/TestMkmfEgrepCpp.md delete mode 100644 example/ruby/TestMkmfFindExecutable.md delete mode 100644 example/ruby/TestMkmfFlags.md delete mode 100644 example/ruby/TestMkmfGlobal.md delete mode 100644 example/ruby/TestMkmfHaveFramework.md delete mode 100644 example/ruby/TestMkmfHaveFunc.md delete mode 100644 example/ruby/TestMkmfHaveLibrary.md delete mode 100644 example/ruby/TestMkmfHaveMacro.md delete mode 100644 example/ruby/TestMkmfInstall.md delete mode 100644 example/ruby/TestMkmfLibs.md delete mode 100644 example/ruby/TestMkmfPkgConfig.md delete mode 100644 example/ruby/TestMkmfSignedness.md delete mode 100644 example/ruby/TestMkmfSizeof.md delete mode 100644 example/ruby/TestMkmfTryConstant.md delete mode 100644 example/ruby/TestModule.md delete mode 100644 example/ruby/TestModule/AClass.md delete mode 100644 example/ruby/TestModule/AttrTest.md delete mode 100644 example/ruby/TestModule/BClass.md delete mode 100644 example/ruby/TestModule/Bug18185.md delete mode 100644 example/ruby/TestModule/Bug18185/Foo.md delete mode 100644 example/ruby/TestModule/Bug18185/InstanceMethods.md delete mode 100644 example/ruby/TestModule/Bug9413.md delete mode 100644 example/ruby/TestModule/C.md delete mode 100644 example/ruby/TestModule/C0.md delete mode 100644 example/ruby/TestModule/C1.md delete mode 100644 example/ruby/TestModule/CClass.md delete mode 100644 example/ruby/TestModule/CloneTestC1.md delete mode 100644 example/ruby/TestModule/CloneTestC2.md delete mode 100644 example/ruby/TestModule/CloneTestM0.md delete mode 100644 example/ruby/TestModule/CloneTestM1.md delete mode 100644 example/ruby/TestModule/CloneTestM2.md delete mode 100644 example/ruby/TestModule/CloneTestM_simple.md delete mode 100644 example/ruby/TestModule/M0.md delete mode 100644 example/ruby/TestModule/M1.md delete mode 100644 example/ruby/TestModule/M1/M2.md delete mode 100644 example/ruby/TestModule/M2.md delete mode 100644 example/ruby/TestModule/M4.md delete mode 100644 example/ruby/TestModule/Mixin.md delete mode 100644 example/ruby/TestModule/MyClass.md delete mode 100644 example/ruby/TestModule/PrivateConstantReopen.md delete mode 100644 example/ruby/TestModule/User.md delete mode 100644 example/ruby/TestMonitor.md delete mode 100644 example/ruby/TestMonitor/KeywordInitializeChild.md delete mode 100644 example/ruby/TestMonitor/KeywordInitializeParent.md delete mode 100644 example/ruby/TestMonitor/NewCondTest.md delete mode 100644 example/ruby/TestMyDict.md delete mode 100644 example/ruby/TestNIL2VT_EMPTY.md delete mode 100644 example/ruby/TestNameError.md delete mode 100644 example/ruby/TestNetHTTP.md delete mode 100644 example/ruby/TestNetHTTPContinue.md delete mode 100644 example/ruby/TestNetHTTPForceEncoding.md delete mode 100644 example/ruby/TestNetHTTPKeepAlive.md delete mode 100644 example/ruby/TestNetHTTPKeepAlive/MockSocket.md delete mode 100644 example/ruby/TestNetHTTPLocalBind.md delete mode 100644 example/ruby/TestNetHTTPPartialResponse.md delete mode 100644 example/ruby/TestNetHTTPSIdentityVerifyFailure.md delete mode 100644 example/ruby/TestNetHTTPSwitchingProtocols.md delete mode 100644 example/ruby/TestNetHTTPUtils.md delete mode 100644 example/ruby/TestNetHTTPUtils/Forbidden.md delete mode 100644 example/ruby/TestNetHTTPUtils/HTTPServer.md delete mode 100644 example/ruby/TestNetHTTPUtils/HTTPServer/Request.md delete mode 100644 example/ruby/TestNetHTTPUtils/HTTPServer/Response.md delete mode 100644 example/ruby/TestNetHTTP_v1_2.md delete mode 100644 example/ruby/TestNetHTTP_v1_2_chunked.md delete mode 100644 example/ruby/TestNetHTTP_version_1_1_methods.md delete mode 100644 example/ruby/TestNetHTTP_version_1_2_methods.md delete mode 100644 example/ruby/TestNoMethodError.md delete mode 100644 example/ruby/TestNot.md delete mode 100644 example/ruby/TestNum2int.md delete mode 100644 example/ruby/TestNumeric.md delete mode 100644 example/ruby/TestObjSpace.md delete mode 100644 example/ruby/TestObjSpace/NotTooComplex.md delete mode 100644 example/ruby/TestObjSpace/TooComplex.md delete mode 100644 example/ruby/TestObjSpaceRactor.md delete mode 100644 example/ruby/TestObject.md delete mode 100644 example/ruby/TestObject/InstanceExec.md delete mode 100644 example/ruby/TestObject/MyInteger.md delete mode 100644 example/ruby/TestObjectSpace.md delete mode 100644 example/ruby/TestOpen3.md delete mode 100644 example/ruby/TestOpenURI.md delete mode 100644 example/ruby/TestOpenURIFtp.md delete mode 100644 example/ruby/TestOpenURIProxy.md delete mode 100644 example/ruby/TestOpenURISSL.md delete mode 100644 example/ruby/TestOpenURIUtils.md delete mode 100644 example/ruby/TestOpenURIUtils/ProxyAuthenticationRequired.md delete mode 100644 example/ruby/TestOpenURIUtils/Unauthorized.md delete mode 100644 example/ruby/TestOptionParser.md delete mode 100644 example/ruby/TestOptionParser/DummyOutput.md delete mode 100644 example/ruby/TestOptionParser/WithPattern.md delete mode 100644 example/ruby/TestOptionParserAcceptable.md delete mode 100644 example/ruby/TestOptionParserAutoConf.md delete mode 100644 example/ruby/TestOptionParserAutoConf/DummyOutput.md delete mode 100644 example/ruby/TestOptionParserBashCompletion.md delete mode 100644 example/ruby/TestOptionParserCClass.md delete mode 100644 example/ruby/TestOptionParserDidYouMean.md delete mode 100644 example/ruby/TestOptionParserGetopts.md delete mode 100644 example/ruby/TestOptionParserKwArg.md delete mode 100644 example/ruby/TestOptionParserKwArg/DummyOutput.md delete mode 100644 example/ruby/TestOptionParserKwArg/K.md delete mode 100644 example/ruby/TestOptionParserLoad.md delete mode 100644 example/ruby/TestOptionParserNoArg.md delete mode 100644 example/ruby/TestOptionParserNoArg/Def1.md delete mode 100644 example/ruby/TestOptionParserNoArg/Def2.md delete mode 100644 example/ruby/TestOptionParserOptArg.md delete mode 100644 example/ruby/TestOptionParserPlaceArg.md delete mode 100644 example/ruby/TestOptionParserReqArg.md delete mode 100644 example/ruby/TestOptionParserReqArg/Def1.md delete mode 100644 example/ruby/TestOptionParserReqArg/Def2.md delete mode 100644 example/ruby/TestOptionParserReqArg/Def3.md delete mode 100644 example/ruby/TestOptionParserReqArg/Def4.md delete mode 100644 example/ruby/TestOptionParserSummaryTest.md delete mode 100644 example/ruby/TestOptionParserZshCompletion.md delete mode 100644 example/ruby/TestPTY.md delete mode 100644 example/ruby/TestPack.md delete mode 100644 example/ruby/TestParallel.md delete mode 100644 example/ruby/TestParallel/TestParallel.md delete mode 100644 example/ruby/TestParallel/TestParallelWorker.md delete mode 100644 example/ruby/TestParse.md delete mode 100644 example/ruby/TestPath.md delete mode 100644 example/ruby/TestPathname.md delete mode 100644 example/ruby/TestPathname/AnotherStringLike.md delete mode 100644 example/ruby/TestPathnameRactor.md delete mode 100644 example/ruby/TestPipe.md delete mode 100644 example/ruby/TestPipe/WithConversion.md delete mode 100644 example/ruby/TestPopenDeadlock.md delete mode 100644 example/ruby/TestPostponed_job.md delete mode 100644 example/ruby/TestProc.md delete mode 100644 example/ruby/TestProcKeywords.md delete mode 100644 example/ruby/TestProcess.md delete mode 100644 example/ruby/TestProfileFrames.md delete mode 100644 example/ruby/TestProtocol.md delete mode 100644 example/ruby/TestProtocol/FakeReadPartialIO.md delete mode 100644 example/ruby/TestPsych.md delete mode 100644 example/ruby/TestPsychRactor.md delete mode 100644 example/ruby/TestRDocAlias.md delete mode 100644 example/ruby/TestRDocAnyMethod.md delete mode 100644 example/ruby/TestRDocAttr.md delete mode 100644 example/ruby/TestRDocClassModule.md delete mode 100644 example/ruby/TestRDocClassModule/TestRDocClassModuleMixins.md delete mode 100644 example/ruby/TestRDocCodeObject.md delete mode 100644 example/ruby/TestRDocComment.md delete mode 100644 example/ruby/TestRDocConstant.md delete mode 100644 example/ruby/TestRDocContext.md delete mode 100644 example/ruby/TestRDocContextSection.md delete mode 100644 example/ruby/TestRDocCrossReference.md delete mode 100644 example/ruby/TestRDocEncoding.md delete mode 100644 example/ruby/TestRDocExtend.md delete mode 100644 example/ruby/TestRDocGeneratorJsonIndex.md delete mode 100644 example/ruby/TestRDocGeneratorMarkup.md delete mode 100644 example/ruby/TestRDocGeneratorPOT.md delete mode 100644 example/ruby/TestRDocGeneratorPOTPO.md delete mode 100644 example/ruby/TestRDocGeneratorPOTPOEntry.md delete mode 100644 example/ruby/TestRDocGeneratorRI.md delete mode 100644 example/ruby/TestRDocI18nLocale.md delete mode 100644 example/ruby/TestRDocI18nText.md delete mode 100644 example/ruby/TestRDocInclude.md delete mode 100644 example/ruby/TestRDocMarkdown.md delete mode 100644 example/ruby/TestRDocMarkdownTest.md delete mode 100644 example/ruby/TestRDocMarkup.md delete mode 100644 example/ruby/TestRDocMarkupAttributeManager.md delete mode 100644 example/ruby/TestRDocMarkupAttributes.md delete mode 100644 example/ruby/TestRDocMarkupDocument.md delete mode 100644 example/ruby/TestRDocMarkupFormatter.md delete mode 100644 example/ruby/TestRDocMarkupFormatter/ToTest.md delete mode 100644 example/ruby/TestRDocMarkupHardBreak.md delete mode 100644 example/ruby/TestRDocMarkupHeading.md delete mode 100644 example/ruby/TestRDocMarkupInclude.md delete mode 100644 example/ruby/TestRDocMarkupIndentedParagraph.md delete mode 100644 example/ruby/TestRDocMarkupParagraph.md delete mode 100644 example/ruby/TestRDocMarkupParser.md delete mode 100644 example/ruby/TestRDocMarkupRaw.md delete mode 100644 example/ruby/TestRDocMarkupToHtmlSnippet.md delete mode 100644 example/ruby/TestRDocMarkupToJoinedParagraph.md delete mode 100644 example/ruby/TestRDocMarkupToLabel.md delete mode 100644 example/ruby/TestRDocMarkupToTableOfContents.md delete mode 100644 example/ruby/TestRDocMarkupToTtOnly.md delete mode 100644 example/ruby/TestRDocMarkupVerbatim.md delete mode 100644 example/ruby/TestRDocMethodAttr.md delete mode 100644 example/ruby/TestRDocNormalClass.md delete mode 100644 example/ruby/TestRDocNormalModule.md delete mode 100644 example/ruby/TestRDocOptions.md delete mode 100644 example/ruby/TestRDocOptions/DummyCoder.md delete mode 100644 example/ruby/TestRDocParserC.md delete mode 100644 example/ruby/TestRDocParserChangeLog.md delete mode 100644 example/ruby/TestRDocParserMarkdown.md delete mode 100644 example/ruby/TestRDocParserPrismRuby.md delete mode 100644 example/ruby/TestRDocParserRd.md delete mode 100644 example/ruby/TestRDocParserRuby.md delete mode 100644 example/ruby/TestRDocParserRubyWithPrismRubyTestCases.md delete mode 100644 example/ruby/TestRDocParserSimple.md delete mode 100644 example/ruby/TestRDocRDoc.md delete mode 100644 example/ruby/TestRDocRIPaths.md delete mode 100644 example/ruby/TestRDocRd.md delete mode 100644 example/ruby/TestRDocRdBlockParser.md delete mode 100644 example/ruby/TestRDocRdInline.md delete mode 100644 example/ruby/TestRDocRdInlineParser.md delete mode 100644 example/ruby/TestRDocRequire.md delete mode 100644 example/ruby/TestRDocRubyGemsHook.md delete mode 100644 example/ruby/TestRDocServlet.md delete mode 100644 example/ruby/TestRDocSingleClass.md delete mode 100644 example/ruby/TestRDocStats.md delete mode 100644 example/ruby/TestRDocStore.md delete mode 100644 example/ruby/TestRDocTask.md delete mode 100644 example/ruby/TestRDocText.md delete mode 100644 example/ruby/TestRDocTokenStream.md delete mode 100644 example/ruby/TestRDocTomDoc.md delete mode 100644 example/ruby/TestRDocTopLevel.md delete mode 100644 example/ruby/TestRand.md delete mode 100644 example/ruby/TestRandomExt.md delete mode 100644 example/ruby/TestRandomExt/TestLoop.md delete mode 100644 example/ruby/TestRandomExt/TestVersionMax.md delete mode 100644 example/ruby/TestRandomExt/TestVersionZero.md delete mode 100644 example/ruby/TestRange.md delete mode 100644 example/ruby/TestRange/CyclicRange.md delete mode 100644 example/ruby/TestRange/DuckRange.md delete mode 100644 example/ruby/TestRational.md delete mode 100644 example/ruby/TestRational/TestGCD.md delete mode 100644 example/ruby/TestRbConfig.md delete mode 100644 example/ruby/TestReadPartial.md delete mode 100644 example/ruby/TestRecursion.md delete mode 100644 example/ruby/TestRedefinition.md delete mode 100644 example/ruby/TestRefinement.md delete mode 100644 example/ruby/TestRefinement/AliasInSubclass.md delete mode 100644 example/ruby/TestRefinement/AliasInSubclass/C.md delete mode 100644 example/ruby/TestRefinement/AliasInSubclass/D.md delete mode 100644 example/ruby/TestRefinement/AliasInSubclass/M.md delete mode 100644 example/ruby/TestRefinement/ArrayEachExt.md delete mode 100644 example/ruby/TestRefinement/Bar.md delete mode 100644 example/ruby/TestRefinement/BarExt.md delete mode 100644 example/ruby/TestRefinement/Bug13446.md delete mode 100644 example/ruby/TestRefinement/Bug13446/Enumerable.md delete mode 100644 example/ruby/TestRefinement/Bug13446/GenericEnumerable.md delete mode 100644 example/ruby/TestRefinement/Bug16242.md delete mode 100644 example/ruby/TestRefinement/Bug16242/M.md delete mode 100644 example/ruby/TestRefinement/Bug16242/OtherM.md delete mode 100644 example/ruby/TestRefinement/Bug16242/X.md delete mode 100644 example/ruby/TestRefinement/Bug17822.md delete mode 100644 example/ruby/TestRefinement/Bug17822/Client.md delete mode 100644 example/ruby/TestRefinement/Bug17822/Ext.md delete mode 100644 example/ruby/TestRefinement/Bug18180.md delete mode 100644 example/ruby/TestRefinement/Bug18180/M.md delete mode 100644 example/ruby/TestRefinement/Foo.md delete mode 100644 example/ruby/TestRefinement/FooBarExt.md delete mode 100644 example/ruby/TestRefinement/FooBarExtClient.md delete mode 100644 example/ruby/TestRefinement/FooExt.md delete mode 100644 example/ruby/TestRefinement/FooExt2.md delete mode 100644 example/ruby/TestRefinement/FooExtClient.md delete mode 100644 example/ruby/TestRefinement/FooExtClient2.md delete mode 100644 example/ruby/TestRefinement/FooFoo2Ext.md delete mode 100644 example/ruby/TestRefinement/FooFoo2ExtClient.md delete mode 100644 example/ruby/TestRefinement/FooSub.md delete mode 100644 example/ruby/TestRefinement/Inspect.md delete mode 100644 example/ruby/TestRefinement/Inspect/M.md delete mode 100644 example/ruby/TestRefinement/InstanceMethodIntegerPowEx.md delete mode 100644 example/ruby/TestRefinement/IntegerFooExt.md delete mode 100644 example/ruby/TestRefinement/IntegerPlusExt.md delete mode 100644 example/ruby/TestRefinement/IntegerSlashExt.md delete mode 100644 example/ruby/TestRefinement/MethodIntegerPowEx.md delete mode 100644 example/ruby/TestRefinement/MethodMissing.md delete mode 100644 example/ruby/TestRefinement/MethodMissing/Bar.md delete mode 100644 example/ruby/TestRefinement/MethodMissing/Foo.md delete mode 100644 example/ruby/TestRefinement/MixedUsing1.md delete mode 100644 example/ruby/TestRefinement/MixedUsing1/C.md delete mode 100644 example/ruby/TestRefinement/MixedUsing1/R1.md delete mode 100644 example/ruby/TestRefinement/MixedUsing2.md delete mode 100644 example/ruby/TestRefinement/MixedUsing2/C.md delete mode 100644 example/ruby/TestRefinement/MixedUsing2/R1.md delete mode 100644 example/ruby/TestRefinement/MixedUsing2/R2.md delete mode 100644 example/ruby/TestRefinement/MixinDefiningPrivateMethod.md delete mode 100644 example/ruby/TestRefinement/ModuleUsing.md delete mode 100644 example/ruby/TestRefinement/NotIncludeSuperclassMethod.md delete mode 100644 example/ruby/TestRefinement/NotIncludeSuperclassMethod/Bar.md delete mode 100644 example/ruby/TestRefinement/NotIncludeSuperclassMethod/X.md delete mode 100644 example/ruby/TestRefinement/NotIncludeSuperclassMethod/Y.md delete mode 100644 example/ruby/TestRefinement/ParentDefiningPrivateMethod.md delete mode 100644 example/ruby/TestRefinement/RedefineRefinedMethod.md delete mode 100644 example/ruby/TestRefinement/RedefineRefinedMethod/C.md delete mode 100644 example/ruby/TestRefinement/RedefineRefinedMethod/M.md delete mode 100644 example/ruby/TestRefinement/RefineInUsing.md delete mode 100644 example/ruby/TestRefinement/RefineInUsing/M1.md delete mode 100644 example/ruby/TestRefinement/RefineInUsing/M2.md delete mode 100644 example/ruby/TestRefinement/RefineModule.md delete mode 100644 example/ruby/TestRefinement/RefineModule/C.md delete mode 100644 example/ruby/TestRefinement/RefineModule/M.md delete mode 100644 example/ruby/TestRefinement/RefineModule/M2.md delete mode 100644 example/ruby/TestRefinement/RefinePrependedClass.md delete mode 100644 example/ruby/TestRefinement/RefinePrependedClass/C.md delete mode 100644 example/ruby/TestRefinement/RefinePrependedClass/M1.md delete mode 100644 example/ruby/TestRefinement/RefinePrependedClass/M2.md delete mode 100644 example/ruby/TestRefinement/RefineSameClass.md delete mode 100644 example/ruby/TestRefinement/RefineScoping.md delete mode 100644 example/ruby/TestRefinement/RespondTo.md delete mode 100644 example/ruby/TestRefinement/RespondTo/M.md delete mode 100644 example/ruby/TestRefinement/RespondTo/Sub.md delete mode 100644 example/ruby/TestRefinement/RespondTo/Super.md delete mode 100644 example/ruby/TestRefinement/Sandbox.md delete mode 100644 example/ruby/TestRefinement/SomeChildClassToRefine.md delete mode 100644 example/ruby/TestRefinement/StringCmpExt.md delete mode 100644 example/ruby/TestRefinement/StringExt.md delete mode 100644 example/ruby/TestRefinement/StringRecursiveLength.md delete mode 100644 example/ruby/TestRefinement/SuperInBlock.md delete mode 100644 example/ruby/TestRefinement/SuperInBlock/C.md delete mode 100644 example/ruby/TestRefinement/SuperInBlock/R.md delete mode 100644 example/ruby/TestRefinement/SuperToModule.md delete mode 100644 example/ruby/TestRefinement/SuperToModule/Child.md delete mode 100644 example/ruby/TestRefinement/SuperToModule/FooBar.md delete mode 100644 example/ruby/TestRefinement/SuperToModule/Parent.md delete mode 100644 example/ruby/TestRefinement/TestImport.md delete mode 100644 example/ruby/TestRefinement/TestImport/A.md delete mode 100644 example/ruby/TestRefinement/TestImport/B.md delete mode 100644 example/ruby/TestRefinement/TestImport/C.md delete mode 100644 example/ruby/TestRefinement/TestImport/UsingC.md delete mode 100644 example/ruby/TestRefinement/ToJSON.md delete mode 100644 example/ruby/TestRefinement/ToProc.md delete mode 100644 example/ruby/TestRefinement/ToProc/MethodMissing.md delete mode 100644 example/ruby/TestRefinement/ToProc/NonProc.md delete mode 100644 example/ruby/TestRefinement/ToProc/PrivateToProc.md delete mode 100644 example/ruby/TestRefinement/ToProc/ReturnNoProc.md delete mode 100644 example/ruby/TestRefinement/ToProc/ReturnProc.md delete mode 100644 example/ruby/TestRefinement/ToProc/ToProcAndMethodMissing.md delete mode 100644 example/ruby/TestRefinement/ToProc/ToProcAndRefinements.md delete mode 100644 example/ruby/TestRefinement/ToString.md delete mode 100644 example/ruby/TestRefinement/ToSymbol.md delete mode 100644 example/ruby/TestRefinement/UsingClass.md delete mode 100644 example/ruby/TestRefinement/VisibleRefinements.md delete mode 100644 example/ruby/TestRefinement/VisibleRefinements/Bar.md delete mode 100644 example/ruby/TestRefinement/VisibleRefinements/Combined.md delete mode 100644 example/ruby/TestRefinement/VisibleRefinements/Foo.md delete mode 100644 example/ruby/TestRefinement/VisibleRefinements/RefA.md delete mode 100644 example/ruby/TestRefinement/VisibleRefinements/RefB.md delete mode 100644 example/ruby/TestRefinement/VisibleRefinements/RefC.md delete mode 100644 example/ruby/TestRegexp.md delete mode 100644 example/ruby/TestRequire.md delete mode 100644 example/ruby/TestRequireLib.md delete mode 100644 example/ruby/TestResolvAddr.md delete mode 100644 example/ruby/TestResolvDNS.md delete mode 100644 example/ruby/TestResolvMDNS.md delete mode 100644 example/ruby/TestResolvResource.md delete mode 100644 example/ruby/TestResolvResourceCAA.md delete mode 100644 example/ruby/TestResolvSvcbHttps.md delete mode 100644 example/ruby/TestRipper.md delete mode 100644 example/ruby/TestRipper/DummyParser.md delete mode 100644 example/ruby/TestRipper/Filter.md delete mode 100644 example/ruby/TestRipper/Filter/Filter.md delete mode 100644 example/ruby/TestRipper/Generic.md delete mode 100644 example/ruby/TestRipper/Lexer.md delete mode 100644 example/ruby/TestRipper/Node.md delete mode 100644 example/ruby/TestRipper/Node/Sym.md delete mode 100644 example/ruby/TestRipper/NodeList.md delete mode 100644 example/ruby/TestRipper/ParserEvents.md delete mode 100644 example/ruby/TestRipper/Ripper.md delete mode 100644 example/ruby/TestRipper/Ripper/TestInput.md delete mode 100644 example/ruby/TestRipper/Ripper/TestInput/Input.md delete mode 100644 example/ruby/TestRipper/ScannerEvents.md delete mode 100644 example/ruby/TestRipper/Sexp.md delete mode 100644 example/ruby/TestRubyKaigi2023_F09FA5A2.md delete mode 100644 example/ruby/TestRubyLiteral.md delete mode 100644 example/ruby/TestRubyOptimization.md delete mode 100644 example/ruby/TestRubyOptimization/Bug10557.md delete mode 100644 example/ruby/TestRubyOptimization/MyObj.md delete mode 100644 example/ruby/TestRubyOptimization/Objtostring.md delete mode 100644 example/ruby/TestRubyOptions.md delete mode 100644 example/ruby/TestRubyOptions/SEGVTest.md delete mode 100644 example/ruby/TestRubyPrimitive.md delete mode 100644 example/ruby/TestRubyPrimitive/A10.md delete mode 100644 example/ruby/TestRubyPrimitive/A2.md delete mode 100644 example/ruby/TestRubyPrimitive/A2/B2.md delete mode 100644 example/ruby/TestRubyPrimitive/A2/B2/C2.md delete mode 100644 example/ruby/TestRubyPrimitive/A3.md delete mode 100644 example/ruby/TestRubyPrimitive/A3/B3.md delete mode 100644 example/ruby/TestRubyPrimitive/A4.md delete mode 100644 example/ruby/TestRubyPrimitive/A5.md delete mode 100644 example/ruby/TestRubyPrimitive/A6.md delete mode 100644 example/ruby/TestRubyPrimitive/B6.md delete mode 100644 example/ruby/TestRubyPrimitive/C6.md delete mode 100644 example/ruby/TestRubyPrimitive/MyArr.md delete mode 100644 example/ruby/TestRubyPrimitive/MyNum.md delete mode 100644 example/ruby/TestRubyPrimitive/MyNum2.md delete mode 100644 example/ruby/TestRubyPrimitive/MyObj.md delete mode 100644 example/ruby/TestRubyPrimitive/MyObj2.md delete mode 100644 example/ruby/TestRubyVM.md delete mode 100644 example/ruby/TestRubyYield.md delete mode 100644 example/ruby/TestRubyYieldGen.md delete mode 100644 example/ruby/TestSH.md delete mode 100644 example/ruby/TestScanArgs.md delete mode 100644 example/ruby/TestSecureRandom.md delete mode 100644 example/ruby/TestServer.md delete mode 100644 example/ruby/TestSetTraceFunc.md delete mode 100644 example/ruby/TestSetTraceFunc/AliasedCMethod.md delete mode 100644 example/ruby/TestSetTraceFunc/AliasedRubyMethod.md delete mode 100644 example/ruby/TestSetTraceFunc/BAR_ERROR.md delete mode 100644 example/ruby/TestSetTraceFunc/Bug10724.md delete mode 100644 example/ruby/TestSetTraceFunc/C11492.md delete mode 100644 example/ruby/TestSetTraceFunc/C9759.md delete mode 100644 example/ruby/TestSetTraceFunc/FOO_ERROR.md delete mode 100644 example/ruby/TestSetTraceFunc/XYZZYException.md delete mode 100644 example/ruby/TestShapes.md delete mode 100644 example/ruby/TestShapes/Example.md delete mode 100644 example/ruby/TestShapes/IVOrder.md delete mode 100644 example/ruby/TestShapes/OrderedAlloc.md delete mode 100644 example/ruby/TestShapes/RemoveAndAdd.md delete mode 100644 example/ruby/TestShapes/ShapeOrder.md delete mode 100644 example/ruby/TestShapes/TestObject.md delete mode 100644 example/ruby/TestShapes/TooComplex.md delete mode 100644 example/ruby/TestShellwords.md delete mode 100644 example/ruby/TestShiftJIS.md delete mode 100644 example/ruby/TestSignal.md delete mode 100644 example/ruby/TestSingleton.md delete mode 100644 example/ruby/TestSingleton/SingletonTest.md delete mode 100644 example/ruby/TestSleep.md delete mode 100644 example/ruby/TestSlowTimeout.md delete mode 100644 example/ruby/TestSlowV0.md delete mode 100644 example/ruby/TestSlowV1.md delete mode 100644 example/ruby/TestSocket.md delete mode 100644 example/ruby/TestSocketAddrinfo.md delete mode 100644 example/ruby/TestSocketAncData.md delete mode 100644 example/ruby/TestSocketNonblock.md delete mode 100644 example/ruby/TestSocketOption.md delete mode 100644 example/ruby/TestSocket_BasicSocket.md delete mode 100644 example/ruby/TestSocket_TCPSocket.md delete mode 100644 example/ruby/TestSocket_UDPSocket.md delete mode 100644 example/ruby/TestSocket_UNIXSocket.md delete mode 100644 example/ruby/TestSprintf.md delete mode 100644 example/ruby/TestSprintf/T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.md delete mode 100644 example/ruby/TestSprintfComb.md delete mode 100644 example/ruby/TestStack.md delete mode 100644 example/ruby/TestString.md delete mode 100644 example/ruby/TestString/Bug9581.md delete mode 100644 example/ruby/TestString/S2.md delete mode 100644 example/ruby/TestString/StringLike.md delete mode 100644 example/ruby/TestString/StringWithIVSet.md delete mode 100644 example/ruby/TestString2.md delete mode 100644 example/ruby/TestStringIO.md delete mode 100644 example/ruby/TestStringIO/C.md delete mode 100644 example/ruby/TestStringIOInRactor.md delete mode 100644 example/ruby/TestStringMemory.md delete mode 100644 example/ruby/TestStringScanner.md delete mode 100644 example/ruby/TestStringScannerFixedAnchor.md delete mode 100644 example/ruby/TestStringScannerRactor.md delete mode 100644 example/ruby/TestStringchar.md delete mode 100644 example/ruby/TestStruct.md delete mode 100644 example/ruby/TestStruct/SubStruct.md delete mode 100644 example/ruby/TestStruct/TopStruct.md delete mode 100644 example/ruby/TestStubSpecification.md delete mode 100644 example/ruby/TestSuper.md delete mode 100644 example/ruby/TestSuper/A.md delete mode 100644 example/ruby/TestSuper/Array1.md delete mode 100644 example/ruby/TestSuper/Array2.md delete mode 100644 example/ruby/TestSuper/Array3.md delete mode 100644 example/ruby/TestSuper/Array4.md delete mode 100644 example/ruby/TestSuper/Base.md delete mode 100644 example/ruby/TestSuper/Double1.md delete mode 100644 example/ruby/TestSuper/Double2.md delete mode 100644 example/ruby/TestSuper/Double3.md delete mode 100644 example/ruby/TestSuper/DoubleInclude.md delete mode 100644 example/ruby/TestSuper/DoubleInclude/A.md delete mode 100644 example/ruby/TestSuper/DoubleInclude/B.md delete mode 100644 example/ruby/TestSuper/DoubleInclude/Base.md delete mode 100644 example/ruby/TestSuper/DoubleInclude/Override.md delete mode 100644 example/ruby/TestSuper/DoubleInclude2.md delete mode 100644 example/ruby/TestSuper/DoubleInclude2/A.md delete mode 100644 example/ruby/TestSuper/DoubleInclude2/B.md delete mode 100644 example/ruby/TestSuper/DoubleInclude2/Base.md delete mode 100644 example/ruby/TestSuper/DoubleInclude2/Override.md delete mode 100644 example/ruby/TestSuper/Forward.md delete mode 100644 example/ruby/TestSuper/Indexed.md delete mode 100644 example/ruby/TestSuper/Keyword1.md delete mode 100644 example/ruby/TestSuper/Keyword2.md delete mode 100644 example/ruby/TestSuper/Optional1.md delete mode 100644 example/ruby/TestSuper/Optional2.md delete mode 100644 example/ruby/TestSuper/Optional3.md delete mode 100644 example/ruby/TestSuper/Optional4.md delete mode 100644 example/ruby/TestSuper/Optional5.md delete mode 100644 example/ruby/TestSuper/Single1.md delete mode 100644 example/ruby/TestSuper/Single2.md delete mode 100644 example/ruby/TestSuper/SubSeq.md delete mode 100644 example/ruby/TestSuper/TestFor_super_with_modified_rest_parameter.md delete mode 100644 example/ruby/TestSuper/TestFor_super_with_modified_rest_parameter_base.md delete mode 100644 example/ruby/TestSuper/X.md delete mode 100644 example/ruby/TestSuper/Y.md delete mode 100644 example/ruby/TestSymbol.md delete mode 100644 example/ruby/TestSymbol/TestToPRocArgWithRefinements.md delete mode 100644 example/ruby/TestSyntax.md delete mode 100644 example/ruby/TestSyntax/KW2.md delete mode 100644 example/ruby/TestSystem.md delete mode 100644 example/ruby/TestTRICK2013.md delete mode 100644 example/ruby/TestTRICK2015.md delete mode 100644 example/ruby/TestTRICK2018.md delete mode 100644 example/ruby/TestTRICK2022.md delete mode 100644 example/ruby/TestTempfile.md delete mode 100644 example/ruby/TestTempfile/M.md delete mode 100644 example/ruby/TestTestUnitSorting.md delete mode 100644 example/ruby/TestTestUnitSorting/Item.md delete mode 100644 example/ruby/TestThread.md delete mode 100644 example/ruby/TestThread/Thread.md delete mode 100644 example/ruby/TestThreadConditionVariable.md delete mode 100644 example/ruby/TestThreadFdClose.md delete mode 100644 example/ruby/TestThreadGroup.md delete mode 100644 example/ruby/TestThreadInstrumentation.md delete mode 100644 example/ruby/TestThreadLockNativeThread.md delete mode 100644 example/ruby/TestThreadQueue.md delete mode 100644 example/ruby/TestTiemout.md delete mode 100644 example/ruby/TestTime.md delete mode 100644 example/ruby/TestTimeExtension.md delete mode 100644 example/ruby/TestTimeExtension/MyDate.md delete mode 100644 example/ruby/TestTimeTZ.md delete mode 100644 example/ruby/TestTimeTZ/DummyTZ.md delete mode 100644 example/ruby/TestTimeTZ/DummyTZ/TIME_CLASS.md delete mode 100644 example/ruby/TestTimeTZ/TZ.md delete mode 100644 example/ruby/TestTimeTZ/Util.md delete mode 100644 example/ruby/TestTimeTZ/WithTZ.md delete mode 100644 example/ruby/TestTimeout.md delete mode 100644 example/ruby/TestTimeout/MyNewErrorInner.md delete mode 100644 example/ruby/TestTimeout/MyNewErrorOuter.md delete mode 100644 example/ruby/TestTmpdir.md delete mode 100644 example/ruby/TestTrace.md delete mode 100644 example/ruby/TestTracepointObj.md delete mode 100644 example/ruby/TestTranscode.md delete mode 100644 example/ruby/TestUTF16.md delete mode 100644 example/ruby/TestUTF32.md delete mode 100644 example/ruby/TestUbfAsyncSafe.md delete mode 100644 example/ruby/TestUndef.md delete mode 100644 example/ruby/TestUndef/Undef0.md delete mode 100644 example/ruby/TestUndef/Undef1.md delete mode 100644 example/ruby/TestUndef/Undef2.md delete mode 100644 example/ruby/TestUnicodeEscape.md delete mode 100644 example/ruby/TestUnicodeNormalize.md delete mode 100644 example/ruby/TestUpdateSuggestion.md delete mode 100644 example/ruby/TestUri.md delete mode 100644 example/ruby/TestVM.md delete mode 100644 example/ruby/TestVMDump.md delete mode 100644 example/ruby/TestVariable.md delete mode 100644 example/ruby/TestVariable/ExIvar.md delete mode 100644 example/ruby/TestVariable/Gods.md delete mode 100644 example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning.md delete mode 100644 example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning/Mod.md delete mode 100644 example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning/Mod2.md delete mode 100644 example/ruby/TestVariable/Olympians.md delete mode 100644 example/ruby/TestVariable/Titans.md delete mode 100644 example/ruby/TestWIN32OLE_EVENT.md delete mode 100644 example/ruby/TestWIN32OLE_EVENT_ADO.md delete mode 100644 example/ruby/TestWIN32OLE_EVENT_ADO/ADO.md delete mode 100644 example/ruby/TestWIN32OLE_EVENT_ADO/Handler1.md delete mode 100644 example/ruby/TestWIN32OLE_EVENT_ADO/Handler2.md delete mode 100644 example/ruby/TestWIN32OLE_EVENT_SWbemSink.md delete mode 100644 example/ruby/TestWIN32OLE_FOR_PROPERTYPUTREF.md delete mode 100644 example/ruby/TestWIN32OLE_METHOD.md delete mode 100644 example/ruby/TestWIN32OLE_METHOD_EVENT.md delete mode 100644 example/ruby/TestWIN32OLE_PARAM.md delete mode 100644 example/ruby/TestWIN32OLE_PARAM_EVENT.md delete mode 100644 example/ruby/TestWIN32OLE_PROPERTYPUTREF.md delete mode 100644 example/ruby/TestWIN32OLE_RECORD.md delete mode 100644 example/ruby/TestWIN32OLE_RECORD_BY_RBCOMTEST.md delete mode 100644 example/ruby/TestWIN32OLE_THREAD.md delete mode 100644 example/ruby/TestWIN32OLE_TYPE.md delete mode 100644 example/ruby/TestWIN32OLE_TYPELIB.md delete mode 100644 example/ruby/TestWIN32OLE_TYPE_EVENT.md delete mode 100644 example/ruby/TestWIN32OLE_VARIABLE.md delete mode 100644 example/ruby/TestWIN32OLE_VARIANT.md delete mode 100644 example/ruby/TestWIN32OLE_VARIANT_OUTARG.md delete mode 100644 example/ruby/TestWIN32OLE_VARIANT_OUTARG/ADO.md delete mode 100644 example/ruby/TestWIN32OLE_WITH_WORD.md delete mode 100644 example/ruby/TestWait.md delete mode 100644 example/ruby/TestWarning.md delete mode 100644 example/ruby/TestWeakKeyMap.md delete mode 100644 example/ruby/TestWeakMap.md delete mode 100644 example/ruby/TestWeakRef.md delete mode 100644 example/ruby/TestWhileuntil.md delete mode 100644 example/ruby/TestWin32OLE.md delete mode 100644 example/ruby/TestWin32OLE_VARIANT_MODULE.md delete mode 100644 example/ruby/TestWin32Registry.md delete mode 100644 example/ruby/TestWindows1251.md delete mode 100644 example/ruby/TestWindows1252.md delete mode 100644 example/ruby/TestYAMLDBM.md delete mode 100644 example/ruby/TestYJIT.md delete mode 100644 example/ruby/TestYJITExitLocations.md delete mode 100644 example/ruby/TestZlib.md delete mode 100644 example/ruby/TestZlibDeflate.md delete mode 100644 example/ruby/TestZlibGzipFile.md delete mode 100644 example/ruby/TestZlibGzipReader.md delete mode 100644 example/ruby/TestZlibGzipWriter.md delete mode 100644 example/ruby/TestZlibInflate.md delete mode 100644 example/ruby/Test_ArithSeq.md delete mode 100644 example/ruby/Test_Array.md delete mode 100644 example/ruby/Test_Array/TestResize.md delete mode 100644 example/ruby/Test_BUG_14834.md delete mode 100644 example/ruby/Test_BUG_3571.md delete mode 100644 example/ruby/Test_BUG_5832.md delete mode 100644 example/ruby/Test_Class.md delete mode 100644 example/ruby/Test_Class/Test_Class2Name.md delete mode 100644 example/ruby/Test_DotDot.md delete mode 100644 example/ruby/Test_EConvAppend.md delete mode 100644 example/ruby/Test_FileStat.md delete mode 100644 example/ruby/Test_Hash.md delete mode 100644 example/ruby/Test_Hash/TestDelete.md delete mode 100644 example/ruby/Test_Integer.md delete mode 100644 example/ruby/Test_JISX0208_Char.md delete mode 100644 example/ruby/Test_Load_Protect.md delete mode 100644 example/ruby/Test_Load_ResolveSymbol.md delete mode 100644 example/ruby/Test_Load_stringify_symbols.md delete mode 100644 example/ruby/Test_Method.md delete mode 100644 example/ruby/Test_Method/TestArity.md delete mode 100644 example/ruby/Test_Method/TestArity/A.md delete mode 100644 example/ruby/Test_Method/TestArity/B.md delete mode 100644 example/ruby/Test_MyInteger.md delete mode 100644 example/ruby/Test_NotImplement.md delete mode 100644 example/ruby/Test_PathToClass.md delete mode 100644 example/ruby/Test_Proc.md delete mode 100644 example/ruby/Test_Proc/TestBMethod.md delete mode 100644 example/ruby/Test_Proc/TestBMethod/Base.md delete mode 100644 example/ruby/Test_Proc/TestBMethod/Bound.md delete mode 100644 example/ruby/Test_RbInternedStr.md delete mode 100644 example/ruby/Test_RbStrDup.md delete mode 100644 example/ruby/Test_SPrintf.md delete mode 100644 example/ruby/Test_StForeachUnpack.md delete mode 100644 example/ruby/Test_StrEncAssociate.md delete mode 100644 example/ruby/Test_StrSetLen.md delete mode 100644 example/ruby/Test_StringCStr.md delete mode 100644 example/ruby/Test_StringCapacity.md delete mode 100644 example/ruby/Test_StringCoderange.md delete mode 100644 example/ruby/Test_StringEllipsize.md delete mode 100644 example/ruby/Test_StringEncStrBufCat.md delete mode 100644 example/ruby/Test_StringExternalNew.md delete mode 100644 example/ruby/Test_StringModifyExpand.md delete mode 100644 example/ruby/Test_StringNoFree.md delete mode 100644 example/ruby/Test_StringNormalize.md delete mode 100644 example/ruby/Test_StringQSort.md delete mode 100644 example/ruby/Test_String_Fstring.md delete mode 100644 example/ruby/Test_String_Fstring/S.md delete mode 100644 example/ruby/Test_Symbol.md delete mode 100644 example/ruby/Test_Symbol/NonInterned.md delete mode 100644 example/ruby/Test_Symbol/TestInadvertent.md delete mode 100644 example/ruby/Test_Symbol/TestType.md delete mode 100644 example/ruby/Test_SyncDefaultGems.md delete mode 100644 example/ruby/Test_SyncDefaultGems/TestMessageFilter.md delete mode 100644 example/ruby/Test_SyncDefaultGems/TestSyncWithCommits.md delete mode 100644 example/ruby/Test_TooManyDummyEncodings.md delete mode 100644 example/ruby/Test_TypedData.md delete mode 100644 example/ruby/Test_Win32Console.md delete mode 100644 example/ruby/Thread.md delete mode 100644 example/ruby/Thread/Backtrace.md delete mode 100644 example/ruby/Thread/Backtrace/Location.md delete mode 100644 example/ruby/Thread/ConditionVariable.md delete mode 100644 example/ruby/Thread/Mutex.md delete mode 100644 example/ruby/Thread/Queue.md delete mode 100644 example/ruby/Thread/SizedQueue.md delete mode 100644 example/ruby/ThreadBacktraceLocationSpecs.md delete mode 100644 example/ruby/ThreadBacktraceLocationSpecs/MethodAddedAbsolutePath.md delete mode 100644 example/ruby/ThreadError.md delete mode 100644 example/ruby/ThreadGroup.md delete mode 100644 example/ruby/ThreadInstrumentation.md delete mode 100644 example/ruby/ThreadInstrumentation/TestHelper.md delete mode 100644 example/ruby/ThreadSpecs.md delete mode 100644 example/ruby/ThreadSpecs/Status.md delete mode 100644 example/ruby/ThreadSpecs/SubThread.md delete mode 100644 example/ruby/Tick.md delete mode 100644 example/ruby/Time.md delete mode 100644 example/ruby/Time/tm.md delete mode 100644 example/ruby/TimeSpecs.md delete mode 100644 example/ruby/TimeSpecs/MethodHolder.md delete mode 100644 example/ruby/TimeSpecs/SubTime.md delete mode 100644 example/ruby/TimeSpecs/TimeLikeArgumentRecorder.md delete mode 100644 example/ruby/TimeSpecs/TimeWithFindTimezone.md delete mode 100644 example/ruby/TimeSpecs/Timezone.md delete mode 100644 example/ruby/TimeSpecs/TimezoneMethodCallRecorder.md delete mode 100644 example/ruby/TimeSpecs/TimezoneWithName.md delete mode 100644 example/ruby/TimeSpecs/Z.md delete mode 100644 example/ruby/TimeSpecs/Zone.md delete mode 100644 example/ruby/Timeout.md delete mode 100644 example/ruby/Timeout/Error.md delete mode 100644 example/ruby/Timeout/ExitException.md delete mode 100644 example/ruby/TimeoutAction.md delete mode 100644 example/ruby/TimerAction.md delete mode 100644 example/ruby/Titans.md delete mode 100644 example/ruby/Toggle.md delete mode 100644 example/ruby/TracePoint.md delete mode 100644 example/ruby/TracePointChecker.md delete mode 100644 example/ruby/TracePointChecker/ZombieTraceHunter.md delete mode 100644 example/ruby/TracePointSpec.md delete mode 100644 example/ruby/TracePointSpec/A.md delete mode 100644 example/ruby/TracePointSpec/B.md delete mode 100644 example/ruby/TracePointSpec/C.md delete mode 100644 example/ruby/TracePointSpec/ClassWithMethodAlias.md delete mode 100644 example/ruby/Transformation.md delete mode 100644 example/ruby/TreeSpell.md delete mode 100644 example/ruby/TreeSpell/ChangeWord.md delete mode 100644 example/ruby/TreeSpell/HumanTypo.md delete mode 100644 example/ruby/TreeSpellCheckerTest.md delete mode 100644 example/ruby/TrueClass.md delete mode 100644 example/ruby/TupleSpace.md delete mode 100644 example/ruby/TupleSpace/Template.md delete mode 100644 example/ruby/TurboTests.md delete mode 100644 example/ruby/TurboTests/CLI.md delete mode 100644 example/ruby/TurboTests/FakeExample.md delete mode 100644 example/ruby/TurboTests/FakeException.md delete mode 100644 example/ruby/TurboTests/FakeExecutionResult.md delete mode 100644 example/ruby/TurboTests/JsonRowsFormatter.md delete mode 100644 example/ruby/TurboTests/Reporter.md delete mode 100644 example/ruby/TurboTests/Runner.md delete mode 100644 example/ruby/TypeError.md delete mode 100644 example/ruby/UDPSocket.md delete mode 100644 example/ruby/UN.md delete mode 100644 example/ruby/UNIXServer.md delete mode 100644 example/ruby/UNIXSocket.md delete mode 100644 example/ruby/URI.md delete mode 100644 example/ruby/URI/BadURIError.md delete mode 100644 example/ruby/URI/Error.md delete mode 100644 example/ruby/URI/FTP.md delete mode 100644 example/ruby/URI/File.md delete mode 100644 example/ruby/URI/Generic.md delete mode 100644 example/ruby/URI/HTTP.md delete mode 100644 example/ruby/URI/HTTPS.md delete mode 100644 example/ruby/URI/InvalidComponentError.md delete mode 100644 example/ruby/URI/InvalidURIError.md delete mode 100644 example/ruby/URI/LDAP.md delete mode 100644 example/ruby/URI/LDAPS.md delete mode 100644 example/ruby/URI/MailTo.md delete mode 100644 example/ruby/URI/RFC2396_Parser.md delete mode 100644 example/ruby/URI/RFC2396_REGEXP.md delete mode 100644 example/ruby/URI/RFC2396_REGEXP/PATTERN.md delete mode 100644 example/ruby/URI/RFC3986_Parser.md delete mode 100644 example/ruby/URI/TestCommon.md delete mode 100644 example/ruby/URI/TestFTP.md delete mode 100644 example/ruby/URI/TestFile.md delete mode 100644 example/ruby/URI/TestGeneric.md delete mode 100644 example/ruby/URI/TestGeneric/CaseInsensitiveEnv.md delete mode 100644 example/ruby/URI/TestHTTP.md delete mode 100644 example/ruby/URI/TestLDAP.md delete mode 100644 example/ruby/URI/TestMailTo.md delete mode 100644 example/ruby/URI/TestParser.md delete mode 100644 example/ruby/URI/TestWS.md delete mode 100644 example/ruby/URI/TestWSS.md delete mode 100644 example/ruby/URI/Util.md delete mode 100644 example/ruby/URI/WS.md delete mode 100644 example/ruby/URI/WSS.md delete mode 100644 example/ruby/URISpec.md delete mode 100644 example/ruby/UnboundMethod.md delete mode 100644 example/ruby/UnboundMethodSpecs.md delete mode 100644 example/ruby/UnboundMethodSpecs/A.md delete mode 100644 example/ruby/UnboundMethodSpecs/B.md delete mode 100644 example/ruby/UnboundMethodSpecs/C.md delete mode 100644 example/ruby/UnboundMethodSpecs/Child1.md delete mode 100644 example/ruby/UnboundMethodSpecs/Child2.md delete mode 100644 example/ruby/UnboundMethodSpecs/Child3.md delete mode 100644 example/ruby/UnboundMethodSpecs/HashSpecs.md delete mode 100644 example/ruby/UnboundMethodSpecs/HashSpecs/SubClass.md delete mode 100644 example/ruby/UnboundMethodSpecs/HashSpecs/SuperClass.md delete mode 100644 example/ruby/UnboundMethodSpecs/Methods.md delete mode 100644 example/ruby/UnboundMethodSpecs/Mod.md delete mode 100644 example/ruby/UnboundMethodSpecs/Parent.md delete mode 100644 example/ruby/UnboundMethodSpecs/SourceLocation.md delete mode 100644 example/ruby/UncaughtThrowError.md delete mode 100644 example/ruby/UncorrectableNameCheckTest.md delete mode 100644 example/ruby/UncorrectableNameCheckTest/FirstNameError.md delete mode 100644 example/ruby/UnexpectedException.md delete mode 100644 example/ruby/UnicodeNormalize.md delete mode 100644 example/ruby/Unifdef.md delete mode 100644 example/ruby/UnitdiffFormatter.md delete mode 100644 example/ruby/UpdateEnv.md delete mode 100644 example/ruby/UserArray.md delete mode 100644 example/ruby/UserCustomConstructorString.md delete mode 100644 example/ruby/UserDefined.md delete mode 100644 example/ruby/UserDefined/Nested.md delete mode 100644 example/ruby/UserDefinedImmediate.md delete mode 100644 example/ruby/UserDefinedString.md delete mode 100644 example/ruby/UserDefinedWithIvar.md delete mode 100644 example/ruby/UserHash.md delete mode 100644 example/ruby/UserHashInitParams.md delete mode 100644 example/ruby/UserMarshal.md delete mode 100644 example/ruby/UserMarshalWithClassName.md delete mode 100644 example/ruby/UserMarshalWithIvar.md delete mode 100644 example/ruby/UserObject.md delete mode 100644 example/ruby/UserPreviouslyDefinedWithInitializedIvar.md delete mode 100644 example/ruby/UserRegexp.md delete mode 100644 example/ruby/UserString.md delete mode 100644 example/ruby/VCS.md delete mode 100644 example/ruby/VCS/GIT.md delete mode 100644 example/ruby/VCS/GIT/Branch.md delete mode 100644 example/ruby/VCS/GITSVN.md delete mode 100644 example/ruby/VCS/NotFoundError.md delete mode 100644 example/ruby/VCS/Null.md delete mode 100644 example/ruby/VCS/SVN.md delete mode 100644 example/ruby/VPath.md delete mode 100644 example/ruby/VariableMatcher.md delete mode 100644 example/ruby/VariableNameCheckTest.md delete mode 100644 example/ruby/VariableNameCheckTest/User.md delete mode 100644 example/ruby/VariableNameCheckTest/UserModule.md delete mode 100644 example/ruby/VariablesSpecs.md delete mode 100644 example/ruby/VariablesSpecs/ArrayLike.md delete mode 100644 example/ruby/VariablesSpecs/ArraySubclass.md delete mode 100644 example/ruby/VariablesSpecs/Chain.md delete mode 100644 example/ruby/VariablesSpecs/EvalOrder.md delete mode 100644 example/ruby/VariablesSpecs/EvalOrder/BarClass.md delete mode 100644 example/ruby/VariablesSpecs/EvalOrder/FooClass.md delete mode 100644 example/ruby/VariablesSpecs/EvalOrder/Node.md delete mode 100644 example/ruby/VariablesSpecs/Hashalike.md delete mode 100644 example/ruby/VariablesSpecs/OpAsgn.md delete mode 100644 example/ruby/VariablesSpecs/ParAsgn.md delete mode 100644 example/ruby/VariablesSpecs/PrivateMethods.md delete mode 100644 example/ruby/VariablesSpecs/ToAryNil.md delete mode 100644 example/ruby/Vec.md delete mode 100644 example/ruby/VersionGuard.md delete mode 100644 example/ruby/WIN32COMGen.md delete mode 100644 example/ruby/WIN32OLE.md delete mode 100644 example/ruby/WIN32OLE/Event.md delete mode 100644 example/ruby/WIN32OLE/Method.md delete mode 100644 example/ruby/WIN32OLE/Param.md delete mode 100644 example/ruby/WIN32OLE/Property.md delete mode 100644 example/ruby/WIN32OLE/QueryInterfaceError.md delete mode 100644 example/ruby/WIN32OLE/Record.md delete mode 100644 example/ruby/WIN32OLE/RuntimeError.md delete mode 100644 example/ruby/WIN32OLE/Type.md delete mode 100644 example/ruby/WIN32OLE/TypeLib.md delete mode 100644 example/ruby/WIN32OLE/Variable.md delete mode 100644 example/ruby/WIN32OLE/Variant.md delete mode 100644 example/ruby/WIN32OLE/VariantType.md delete mode 100644 example/ruby/WIN32OLESpecs.md delete mode 100644 example/ruby/Warning.md delete mode 100644 example/ruby/Warning/buffer.md delete mode 100644 example/ruby/WeakRef.md delete mode 100644 example/ruby/WeakRef/RefError.md delete mode 100644 example/ruby/WeakRefSpec.md delete mode 100644 example/ruby/WebauthnListenerResponseTest.md delete mode 100644 example/ruby/WebauthnListenerTest.md delete mode 100644 example/ruby/WebauthnPollerTest.md delete mode 100644 example/ruby/Win32.md delete mode 100644 example/ruby/Win32/Registry.md delete mode 100644 example/ruby/Win32/Registry/API.md delete mode 100644 example/ruby/Win32/Registry/Constants.md delete mode 100644 example/ruby/Win32/Registry/Error.md delete mode 100644 example/ruby/Win32/Registry/Error/Kernel32.md delete mode 100644 example/ruby/Win32/Registry/PredefinedKey.md delete mode 100644 example/ruby/Win32/Resolv.md delete mode 100644 example/ruby/Win32/Resolv/SZ.md delete mode 100644 example/ruby/Windows.md delete mode 100644 example/ruby/Word.md delete mode 100644 example/ruby/X.md delete mode 100644 example/ruby/XMP.md delete mode 100644 example/ruby/XMP/StringInputMethod.md delete mode 100644 example/ruby/XrefTestCase.md delete mode 100644 example/ruby/YAML.md delete mode 100644 example/ruby/YAML/DBM.md delete mode 100644 example/ruby/YAML/Store.md delete mode 100644 example/ruby/YAMLSpecs.md delete mode 100644 example/ruby/YAMLSpecs/Example.md delete mode 100644 example/ruby/YAMLStoreTest.md delete mode 100644 example/ruby/YamlFormatter.md delete mode 100644 example/ruby/YieldSpecs.md delete mode 100644 example/ruby/YieldSpecs/Yielder.md delete mode 100644 example/ruby/Zero.md delete mode 100644 example/ruby/ZeroDivisionError.md delete mode 100644 example/ruby/Zlib.md delete mode 100644 example/ruby/Zlib/BufError.md delete mode 100644 example/ruby/Zlib/DataError.md delete mode 100644 example/ruby/Zlib/Deflate.md delete mode 100644 example/ruby/Zlib/Error.md delete mode 100644 example/ruby/Zlib/GzipFile.md delete mode 100644 example/ruby/Zlib/GzipFile/CRCError.md delete mode 100644 example/ruby/Zlib/GzipFile/Error.md delete mode 100644 example/ruby/Zlib/GzipFile/LengthError.md delete mode 100644 example/ruby/Zlib/GzipFile/NoFooter.md delete mode 100644 example/ruby/Zlib/GzipReader.md delete mode 100644 example/ruby/Zlib/GzipWriter.md delete mode 100644 example/ruby/Zlib/InProgressError.md delete mode 100644 example/ruby/Zlib/Inflate.md delete mode 100644 example/ruby/Zlib/MemError.md delete mode 100644 example/ruby/Zlib/NeedDict.md delete mode 100644 example/ruby/Zlib/StreamEnd.md delete mode 100644 example/ruby/Zlib/StreamError.md delete mode 100644 example/ruby/Zlib/VersionError.md delete mode 100644 example/ruby/Zlib/ZStream.md delete mode 100644 example/ruby/ZombieHunter.md delete mode 100644 example/ruby/fatal.md diff --git a/.gitignore b/.gitignore index 1674cd0..3825ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ /tmp/ .vscode/ .DS_Store -// file is just to big. -example/ruby/index.csv + + +example/ruby/ diff --git a/Rakefile b/Rakefile index fe65fe9..69f0940 100644 --- a/Rakefile +++ b/Rakefile @@ -13,22 +13,23 @@ task default: %i[test stree:write] namespace :examples do - desc "Generate example/rdoc/ documentation using yard-markdown plugin" + desc "Generate basic example documentation using yard-markdown plugin" task :generate do Rake::Task["examples:yard"].invoke Rake::Task["examples:rdoc"].invoke - Rake::Task["examples:ruby"].invoke end - + desc "Generate example documentation for code annotated with yard" task :yard do sh "yardoc --output-dir example/yard example_yard.rb" end + desc "Generate example documentation for code annotated with rdoc" task :rdoc do sh "yardoc --output-dir example/rdoc example_rdoc.rb" end + desc "Generate example documentation for code annotated with ruby source code" task :ruby do sh "yardoc source_ruby --output-dir example/ruby" end diff --git a/example/ruby/A.md b/example/ruby/A.md deleted file mode 100644 index e921a5c..0000000 --- a/example/ruby/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: A -**Inherits:** Object - - - - - diff --git a/example/ruby/ACRONYM.md b/example/ruby/ACRONYM.md deleted file mode 100644 index 1f4316f..0000000 --- a/example/ruby/ACRONYM.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ACRONYM - - - - - diff --git a/example/ruby/Action.md b/example/ruby/Action.md deleted file mode 100644 index efe1485..0000000 --- a/example/ruby/Action.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Action -**Inherits:** Object - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(value) [](#method-i-initialize) - -**@return** [Action] a new instance of Action - diff --git a/example/ruby/ActionFilter.md b/example/ruby/ActionFilter.md deleted file mode 100644 index 328bd37..0000000 --- a/example/ruby/ActionFilter.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: ActionFilter -**Inherits:** Object - - -ActionFilter is a base class for actions that are triggered by specs that -match the filter. The filter may be specified by strings that match spec -descriptions or by tags for strings that match spec descriptions. - -Unlike TagFilter and RegexpFilter, ActionFilter instances do not affect the -specs that are run. The filter is only used to trigger the action. - - - -#Instance Methods -## ===(string) [](#method-i-===) - -## initialize(tagsnil, descsnil) [](#method-i-initialize) - -**@return** [ActionFilter] a new instance of ActionFilter - -## load() [](#method-i-load) - -## register() [](#method-i-register) - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/ActionMap.md b/example/ruby/ActionMap.md deleted file mode 100644 index c471298..0000000 --- a/example/ruby/ActionMap.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: ActionMap -**Inherits:** Object - - - - -# Class Methods -## build_tree(rects ) [](#method-c-build_tree) -## each_firstbyte_range(prefix , region_rects ) [](#method-c-each_firstbyte_range) -## expand(rects , &block ) [](#method-c-expand) -## expand_rec(prefix , region_rects , &block ) [](#method-c-expand_rec) -## merge(*mappings , &block ) [](#method-c-merge) -## merge2(map1 , map2 , &block ) [](#method-c-merge2) -## merge_rects(*rects_list ) [](#method-c-merge_rects) -## parse(mapping ) [](#method-c-parse) -## parse_to_rects(mapping ) [](#method-c-parse_to_rects) -## unambiguous_action(actions0 ) [](#method-c-unambiguous_action) - -#Instance Methods -## empty_action() [](#method-i-empty_action) - -## format_infos(infos) [](#method-i-format_infos) - -## format_offsets(min, max, offsets) [](#method-i-format_offsets) - -## gen_str(bytes) [](#method-i-gen_str) - -## generate_info(info) [](#method-i-generate_info) - -## generate_lookup_node(name, table) [](#method-i-generate_lookup_node) - -## generate_node(name_hintnil) [](#method-i-generate_node) - -## gennode(bytes_code, words_code, name_hintnil) [](#method-i-gennode) - -## initialize(tree) [](#method-i-initialize) - -**@return** [ActionMap] a new instance of ActionMap - -## inspect() [](#method-i-inspect) - -## max_input_length() [](#method-i-max_input_length) - -## max_input_length_rec(tree) [](#method-i-max_input_length_rec) - -## str_name(bytes) [](#method-i-str_name) - diff --git a/example/ruby/Addrinfo.md b/example/ruby/Addrinfo.md deleted file mode 100644 index 2ba3ded..0000000 --- a/example/ruby/Addrinfo.md +++ /dev/null @@ -1,516 +0,0 @@ -# Class: Addrinfo -**Inherits:** Object - - - - -# Class Methods -## foreach(nodename , service , family nil, socktype nil, protocol nil, flags nil, timeout: nil, &block ) [](#method-c-foreach) -iterates over the list of Addrinfo objects obtained by Addrinfo.getaddrinfo. - - Addrinfo.foreach(nil, 80) {|x| p x } - #=> # - # # - # # - # # -## getaddrinfo(*args ) [](#method-c-getaddrinfo) -returns a list of addrinfo objects as an array. - -This method converts nodename (hostname) and service (port) to addrinfo. Since -the conversion is not unique, the result is a list of addrinfo objects. - -nodename or service can be nil if no conversion intended. - -family, socktype and protocol are hint for preferred protocol. If the result -will be used for a socket with SOCK_STREAM, SOCK_STREAM should be specified as -socktype. If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for -SOCK_STREAM. If they are omitted or nil is given, the result is not -restricted. - -Similarly, PF_INET6 as family restricts for IPv6. - -flags should be bitwise OR of Socket::AI_??? constants such as follows. Note -that the exact list of the constants depends on OS. - - AI_PASSIVE Get address to use with bind() - AI_CANONNAME Fill in the canonical name - AI_NUMERICHOST Prevent host name resolution - AI_NUMERICSERV Prevent service name resolution - AI_V4MAPPED Accept IPv4-mapped IPv6 addresses - AI_ALL Allow all addresses - AI_ADDRCONFIG Accept only if any address is assigned - -Note that socktype should be specified whenever application knows the usage of -the address. Some platform causes an error when socktype is omitted and -servname is specified as an integer because some port numbers, 512 for -example, are ambiguous without socktype. - - Addrinfo.getaddrinfo("www.kame.net", 80, nil, :STREAM) - #=> [#, - # #] -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## ip(host ) [](#method-c-ip) -returns an addrinfo object for IP address. - -The port, socktype, protocol of the result is filled by zero. So, it is not -appropriate to create a socket. - - Addrinfo.ip("localhost") #=> # -**@overload** [] - -## tcp(host , port ) [](#method-c-tcp) -returns an addrinfo object for TCP address. - - Addrinfo.tcp("localhost", "smtp") #=> # -**@overload** [] - -## udp(host , port ) [](#method-c-udp) -returns an addrinfo object for UDP address. - - Addrinfo.udp("localhost", "daytime") #=> # -**@overload** [] - -## unix(*args ) [](#method-c-unix) -returns an addrinfo object for UNIX socket address. - -*socktype* specifies the socket type. If it is omitted, :STREAM is used. - - Addrinfo.unix("/tmp/sock") #=> # - Addrinfo.unix("/tmp/sock", :DGRAM) #=> # -**@overload** [] - - -#Instance Methods -## afamily() [](#method-i-afamily) -returns the address family as an integer. - - Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true - -**@overload** [] - -## bind() [](#method-i-bind) -creates a socket bound to self. - -If a block is given, it is called with the socket and the value of the block -is returned. The socket is returned otherwise. - - Addrinfo.udp("0.0.0.0", 9981).bind {|s| - s.local_address.connect {|s| s.send "hello", 0 } - p s.recv(10) #=> "hello" - } - -## canonname() [](#method-i-canonname) -returns the canonical name as a string. - -nil is returned if no canonical name. - -The canonical name is set by Addrinfo.getaddrinfo when AI_CANONNAME is -specified. - - list = Addrinfo.getaddrinfo("www.ruby-lang.org", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME) - p list[0] #=> # - p list[0].canonname #=> "carbon.ruby-lang.org" - -**@overload** [] - -## connect(timeout:nil, &block) [](#method-i-connect) -:call-seq: - addrinfo.connect([opts]) {|socket| ... } - addrinfo.connect([opts]) - -creates a socket connected to the address of self. - -The optional argument *opts* is options represented by a hash. *opts* may have -following options: - -:timeout -: specify the timeout in seconds. - - -If a block is given, it is called with the socket and the value of the block -is returned. The socket is returned otherwise. - - Addrinfo.tcp("www.ruby-lang.org", 80).connect {|s| - s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n" - puts s.read - } - -## connect_from(*args, timeout:nil, &block) [](#method-i-connect_from) -:call-seq: - addrinfo.connect_from([local_addr_args], [opts]) {|socket| ... } - addrinfo.connect_from([local_addr_args], [opts]) - -creates a socket connected to the address of self. - -If one or more arguments given as *local_addr_args*, it is used as the local -address of the socket. *local_addr_args* is given for family_addrinfo to -obtain actual address. - -If *local_addr_args* is not given, the local address of the socket is not -bound. - -The optional last argument *opts* is options represented by a hash. *opts* may -have following options: - -:timeout -: specify the timeout in seconds. - - -If a block is given, it is called with the socket and the value of the block -is returned. The socket is returned otherwise. - - Addrinfo.tcp("www.ruby-lang.org", 80).connect_from("0.0.0.0", 4649) {|s| - s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n" - puts s.read - } - - # Addrinfo object can be taken for the argument. - Addrinfo.tcp("www.ruby-lang.org", 80).connect_from(Addrinfo.tcp("0.0.0.0", 4649)) {|s| - s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n" - puts s.read - } - -## connect_to(*args, timeout:nil, &block) [](#method-i-connect_to) -:call-seq: - addrinfo.connect_to([remote_addr_args], [opts]) {|socket| ... } - addrinfo.connect_to([remote_addr_args], [opts]) - -creates a socket connected to *remote_addr_args* and bound to self. - -The optional last argument *opts* is options represented by a hash. *opts* may -have following options: - -:timeout -: specify the timeout in seconds. - - -If a block is given, it is called with the socket and the value of the block -is returned. The socket is returned otherwise. - - Addrinfo.tcp("0.0.0.0", 4649).connect_to("www.ruby-lang.org", 80) {|s| - s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n" - puts s.read - } - -## family_addrinfo(*args) [](#method-i-family_addrinfo) -creates an Addrinfo object from the arguments. - -The arguments are interpreted as similar to self. - - Addrinfo.tcp("0.0.0.0", 4649).family_addrinfo("www.ruby-lang.org", 80) - #=> # - - Addrinfo.unix("/tmp/sock").family_addrinfo("/tmp/sock2") - #=> # - -## getnameinfo(*args) [](#method-i-getnameinfo) -returns nodename and service as a pair of strings. This converts struct -sockaddr in addrinfo to textual representation. - -flags should be bitwise OR of Socket::NI_??? constants. - - Addrinfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"] - - Addrinfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV) - #=> ["localhost", "80"] - -**@overload** [] - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -returns a new instance of Addrinfo. The instance contains sockaddr, family, -socktype, protocol. sockaddr means struct sockaddr which can be used for -connect(2), etc. family, socktype and protocol are integers which is used for -arguments of socket(2). - -sockaddr is specified as an array or a string. The array should be compatible -to the value of IPSocket#addr or UNIXSocket#addr. The string should be struct -sockaddr as generated by Socket.sockaddr_in or Socket.unpack_sockaddr_un. - -sockaddr examples: -* `["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"]` -* `["AF_INET6", 42304, "ip6-localhost", "::1"]` -* `["AF_UNIX", "/tmp/sock"]` -* `Socket.sockaddr_in("smtp", "2001:DB8::1")` -* `Socket.sockaddr_in(80, "172.18.22.42")` -* `Socket.sockaddr_in(80, "www.ruby-lang.org")` -* `Socket.sockaddr_un("/tmp/sock")` - -In an AF_INET/AF_INET6 sockaddr array, the 4th element, numeric IP address, is -used to construct socket address in the Addrinfo instance. If the 3rd element, -textual host name, is non-nil, it is also recorded but used only for -Addrinfo#inspect. - -family is specified as an integer to specify the protocol family such as -Socket::PF_INET. It can be a symbol or a string which is the constant name -with or without PF_ prefix such as :INET, :INET6, :UNIX, "PF_INET", etc. If -omitted, PF_UNSPEC is assumed. - -socktype is specified as an integer to specify the socket type such as -Socket::SOCK_STREAM. It can be a symbol or a string which is the constant name -with or without SOCK_ prefix such as :STREAM, :DGRAM, :RAW, "SOCK_STREAM", -etc. If omitted, 0 is assumed. - -protocol is specified as an integer to specify the protocol such as -Socket::IPPROTO_TCP. It must be an integer, unlike family and socktype. If -omitted, 0 is assumed. Note that 0 is reasonable value for most protocols, -except raw socket. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -returns a string which shows addrinfo in human-readable form. - - Addrinfo.tcp("localhost", 80).inspect #=> "#" - Addrinfo.unix("/tmp/sock").inspect #=> "#" - -**@overload** [] - -## inspect_sockaddr() [](#method-i-inspect_sockaddr) -returns a string which shows the sockaddr in *addrinfo* with human-readable -form. - - Addrinfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80" - Addrinfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80" - Addrinfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock" - -**@overload** [] - -## ip?() [](#method-i-ip?) -returns true if addrinfo is internet (IPv4/IPv6) address. returns false -otherwise. - - Addrinfo.tcp("127.0.0.1", 80).ip? #=> true - Addrinfo.tcp("::1", 80).ip? #=> true - Addrinfo.unix("/tmp/sock").ip? #=> false - -**@overload** [] - -## ip_address() [](#method-i-ip_address) -Returns the IP address as a string. - - Addrinfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1" - Addrinfo.tcp("::1", 80).ip_address #=> "::1" - -**@overload** [] - -## ip_port() [](#method-i-ip_port) -Returns the port number as an integer. - - Addrinfo.tcp("127.0.0.1", 80).ip_port #=> 80 - Addrinfo.tcp("::1", 80).ip_port #=> 80 - -**@overload** [] - -## ip_unpack() [](#method-i-ip_unpack) -Returns the IP address and port number as 2-element array. - - Addrinfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80] - Addrinfo.tcp("::1", 80).ip_unpack #=> ["::1", 80] - -**@overload** [] - -## ipv4?() [](#method-i-ipv4?) -returns true if addrinfo is IPv4 address. returns false otherwise. - - Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true - Addrinfo.tcp("::1", 80).ipv4? #=> false - Addrinfo.unix("/tmp/sock").ipv4? #=> false - -**@overload** [] - -## ipv4_loopback?() [](#method-i-ipv4_loopback?) -Returns true for IPv4 loopback address (127.0.0.0/8). It returns false -otherwise. - -**@return** [Boolean] - -## ipv4_multicast?() [](#method-i-ipv4_multicast?) -Returns true for IPv4 multicast address (224.0.0.0/4). It returns false -otherwise. - -**@return** [Boolean] - -## ipv4_private?() [](#method-i-ipv4_private?) -Returns true for IPv4 private address (10.0.0.0/8, 172.16.0.0/12, -192.168.0.0/16). It returns false otherwise. - -**@return** [Boolean] - -## ipv6?() [](#method-i-ipv6?) -returns true if addrinfo is IPv6 address. returns false otherwise. - - Addrinfo.tcp("127.0.0.1", 80).ipv6? #=> false - Addrinfo.tcp("::1", 80).ipv6? #=> true - Addrinfo.unix("/tmp/sock").ipv6? #=> false - -**@overload** [] - -## ipv6_linklocal?() [](#method-i-ipv6_linklocal?) -Returns true for IPv6 link local address (fe80::/10). It returns false -otherwise. - -**@return** [Boolean] - -## ipv6_loopback?() [](#method-i-ipv6_loopback?) -Returns true for IPv6 loopback address (::1). It returns false otherwise. - -**@return** [Boolean] - -## ipv6_mc_global?() [](#method-i-ipv6_mc_global?) -Returns true for IPv6 multicast global scope address. It returns false -otherwise. - -**@return** [Boolean] - -## ipv6_mc_linklocal?() [](#method-i-ipv6_mc_linklocal?) -Returns true for IPv6 multicast link-local scope address. It returns false -otherwise. - -**@return** [Boolean] - -## ipv6_mc_nodelocal?() [](#method-i-ipv6_mc_nodelocal?) -Returns true for IPv6 multicast node-local scope address. It returns false -otherwise. - -**@return** [Boolean] - -## ipv6_mc_orglocal?() [](#method-i-ipv6_mc_orglocal?) -Returns true for IPv6 multicast organization-local scope address. It returns -false otherwise. - -**@return** [Boolean] - -## ipv6_mc_sitelocal?() [](#method-i-ipv6_mc_sitelocal?) -Returns true for IPv6 multicast site-local scope address. It returns false -otherwise. - -**@return** [Boolean] - -## ipv6_multicast?() [](#method-i-ipv6_multicast?) -Returns true for IPv6 multicast address (ff00::/8). It returns false -otherwise. - -**@return** [Boolean] - -## ipv6_sitelocal?() [](#method-i-ipv6_sitelocal?) -Returns true for IPv6 site local address (fec0::/10). It returns false -otherwise. - -**@return** [Boolean] - -## ipv6_to_ipv4() [](#method-i-ipv6_to_ipv4) -Returns IPv4 address of IPv4 mapped/compatible IPv6 address. It returns nil if -`self` is not IPv4 mapped/compatible IPv6 address. - - Addrinfo.ip("::192.0.2.3").ipv6_to_ipv4 #=> # - Addrinfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4 #=> # - Addrinfo.ip("::1").ipv6_to_ipv4 #=> nil - Addrinfo.ip("192.0.2.3").ipv6_to_ipv4 #=> nil - Addrinfo.unix("/tmp/sock").ipv6_to_ipv4 #=> nil - -## ipv6_unique_local?() [](#method-i-ipv6_unique_local?) -Returns true for IPv6 unique local address (fc00::/7, RFC4193). It returns -false otherwise. - -**@return** [Boolean] - -## ipv6_unspecified?() [](#method-i-ipv6_unspecified?) -Returns true for IPv6 unspecified address (::). It returns false otherwise. - -**@return** [Boolean] - -## ipv6_v4compat?() [](#method-i-ipv6_v4compat?) -Returns true for IPv4-compatible IPv6 address (::/80). It returns false -otherwise. - -**@return** [Boolean] - -## ipv6_v4mapped?() [](#method-i-ipv6_v4mapped?) -Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80). It returns false -otherwise. - -**@return** [Boolean] - -## listen(backlogSocket::SOMAXCONN) [](#method-i-listen) -creates a listening socket bound to self. - -## marshal_dump() [](#method-i-marshal_dump) -:nodoc: - -## marshal_load(ary) [](#method-i-marshal_load) -:nodoc: - -## pfamily() [](#method-i-pfamily) -returns the protocol family as an integer. - - Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true - -**@overload** [] - -## protocol() [](#method-i-protocol) -returns the socket type as an integer. - - Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true - -**@overload** [] - -## socktype() [](#method-i-socktype) -returns the socket type as an integer. - - Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true - -**@overload** [] - -## to_s() [](#method-i-to_s) -returns the socket address as packed struct sockaddr string. - - Addrinfo.tcp("localhost", 80).to_sockaddr - #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" - -**@overload** [] - -**@overload** [] - -## to_sockaddr() [](#method-i-to_sockaddr) -returns the socket address as packed struct sockaddr string. - - Addrinfo.tcp("localhost", 80).to_sockaddr - #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" - -**@overload** [] - -**@overload** [] - -## unix?() [](#method-i-unix?) -returns true if addrinfo is UNIX address. returns false otherwise. - - Addrinfo.tcp("127.0.0.1", 80).unix? #=> false - Addrinfo.tcp("::1", 80).unix? #=> false - Addrinfo.unix("/tmp/sock").unix? #=> true - -**@overload** [] - -## unix_path() [](#method-i-unix_path) -Returns the socket path as a string. - - Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock" - -**@overload** [] - diff --git a/example/ruby/Alias0.md b/example/ruby/Alias0.md deleted file mode 100644 index 7d27c6e..0000000 --- a/example/ruby/Alias0.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Alias0 -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/Alias1.md b/example/ruby/Alias1.md deleted file mode 100644 index 23a3682..0000000 --- a/example/ruby/Alias1.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Alias1 -**Inherits:** Alias0 - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## foo() [](#method-i-foo) - diff --git a/example/ruby/Alias2.md b/example/ruby/Alias2.md deleted file mode 100644 index 74358f4..0000000 --- a/example/ruby/Alias2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Alias2 -**Inherits:** Alias1 - - - - - diff --git a/example/ruby/Alias3.md b/example/ruby/Alias3.md deleted file mode 100644 index 8fa4e6b..0000000 --- a/example/ruby/Alias3.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Alias3 -**Inherits:** Alias2 - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## foo() [](#method-i-foo) - -## quux() [](#method-i-quux) - diff --git a/example/ruby/AliasObject.md b/example/ruby/AliasObject.md deleted file mode 100644 index 6ecd791..0000000 --- a/example/ruby/AliasObject.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: AliasObject -**Inherits:** Object - - - - -# Class Methods -## klass_method() [](#method-c-klass_method) -# Attributes -## bar[RW] [](#attribute-i-bar) -Returns the value of attribute bar. - -## baz[RW] [](#attribute-i-baz) -Returns the value of attribute baz. - -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - -#Instance Methods -## false_value() [](#method-i-false_value) - -## prep() [](#method-i-prep) - -## value() [](#method-i-value) - diff --git a/example/ruby/AllPairs.md b/example/ruby/AllPairs.md deleted file mode 100644 index cb224b5..0000000 --- a/example/ruby/AllPairs.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: AllPairs - - - - -# Class Methods -## combine_block(tbl1 , tbl2 ) [](#method-c-combine_block) -## each(*args ) [](#method-c-each) -generate all pairs test. -## each_index(*vs ) [](#method-c-each_index) -## exhaustive_each(*args ) [](#method-c-exhaustive_each) -generate all combination in cartesian product. (not all-pairs test) -## make_basic_block(prime ) [](#method-c-make_basic_block) -## make_large_block(v , prime ) [](#method-c-make_large_block) -## make_prime(v ) [](#method-c-make_prime) - diff --git a/example/ruby/AnError.md b/example/ruby/AnError.md deleted file mode 100644 index 73816e8..0000000 --- a/example/ruby/AnError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: AnError -**Inherits:** StandardError - -**Includes:** MyModule - - - - - diff --git a/example/ruby/Apache.md b/example/ruby/Apache.md deleted file mode 100644 index cd4cd5e..0000000 --- a/example/ruby/Apache.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Apache -**Inherits:** Object - - -dummy class for mod_ruby - - -# Class Methods -## _reset() [](#method-c-_reset) -:nodoc: -## request() [](#method-c-request) - diff --git a/example/ruby/Apache/Request.md b/example/ruby/Apache/Request.md deleted file mode 100644 index 2575ae5..0000000 --- a/example/ruby/Apache/Request.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Apache::Request -**Inherits:** Object - - - - -# Attributes -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## content_encoding[RW] [](#attribute-i-content_encoding) -Returns the value of attribute content_encoding. - -## content_type[RW] [](#attribute-i-content_type) -Returns the value of attribute content_type. - -## headers_out[RW] [](#attribute-i-headers_out) -Returns the value of attribute headers_out. - -## status[RW] [](#attribute-i-status) -Returns the value of attribute status. - -## status_line[RW] [](#attribute-i-status_line) -Returns the value of attribute status_line. - - -#Instance Methods -## _send_http_header_invoked?() [](#method-i-_send_http_header_invoked?) - -**@return** [Boolean] - -## _setup_cgi_env_invoked?() [](#method-i-_setup_cgi_env_invoked?) - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [Request] a new instance of Request - -## send_http_header() [](#method-i-send_http_header) -def args - return ENV['QUERY_STRING'] - -end - -## setup_cgi_env() [](#method-i-setup_cgi_env) - diff --git a/example/ruby/ApplicationController.md b/example/ruby/ApplicationController.md deleted file mode 100644 index edde803..0000000 --- a/example/ruby/ApplicationController.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ApplicationController -**Inherits:** Object - - - - - -#Instance Methods -## generate(i, destdir, basedir) [](#method-i-generate) - diff --git a/example/ruby/ArbitraryException.md b/example/ruby/ArbitraryException.md deleted file mode 100644 index 3652b9b..0000000 --- a/example/ruby/ArbitraryException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: ArbitraryException -**Inherits:** StandardError - - - - - diff --git a/example/ruby/ArgumentError.md b/example/ruby/ArgumentError.md deleted file mode 100644 index 513b529..0000000 --- a/example/ruby/ArgumentError.md +++ /dev/null @@ -1,32 +0,0 @@ -# Exception: ArgumentError -**Inherits:** StandardError - -**Includes:** ErrorHighlight::CoreExt - - -Raised when the arguments are wrong and there isn't a more specific Exception -class. - -Ex: passing the wrong number of arguments - - [1, 2, 3].first(4, 5) - -*raises the exception:* - - ArgumentError: wrong number of arguments (given 2, expected 1) - -Ex: passing an argument that is not acceptable: - - [1, 2, 3].first(-4) - -*raises the exception:* - - ArgumentError: negative array size - - - -#Instance Methods -## detailed_message(highlight:false, error_highlight:true) [](#method-i-detailed_message) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Array.md b/example/ruby/Array.md deleted file mode 100644 index 3a0a263..0000000 --- a/example/ruby/Array.md +++ /dev/null @@ -1,4567 +0,0 @@ -# Class: Array -**Inherits:** Object - -**Includes:** Enumerable - - -append method to built-in class - - -# Class Methods -## [](*args ) [](#method-c-[]) -Returns a new array, populated with the given objects: - - Array[1, 'a', /^A/] # => [1, "a", /^A/] - Array[] # => [] - Array.[](1, 'a', /^A/) # => [1, "a", /^A/] - -Related: see [Methods for Creating an -Array](rdoc-ref:Array@Methods+for+Creating+an+Array). -## new(*args ) [](#method-c-new) -:nodoc: -## try_convert(ary ) [](#method-c-try_convert) -Attempts to return an array, based on the given `object`. - -If `object` is an array, returns `object`. - -Otherwise if `object` responds to `:to_ary`. calls `object.to_ary`: if the -return value is an array or `nil`, returns that value; if not, raises -TypeError. - -Otherwise returns `nil`. - -Related: see [Methods for Creating an -Array](rdoc-ref:Array@Methods+for+Creating+an+Array). -**@overload** [] - - -#Instance Methods -## &(ary2) [](#method-i-&) -Returns a new array containing the *intersection* of `self` and `other_array`; -that is, containing those elements found in both `self` and `other_array`: - - [0, 1, 2, 3] & [1, 2] # => [1, 2] - -Omits duplicates: - - [0, 1, 1, 0] & [0, 1] # => [0, 1] - -Preserves order from `self`: - - [0, 1, 2] & [3, 2, 1, 0] # => [0, 1, 2] - -Identifies common elements using method `#eql?` (as defined in each element of -`self`). - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -## *(times) [](#method-i-*) -When non-negative integer argument `n` is given, returns a new array built by -concatenating `n` copies of `self`: - - a = ['x', 'y'] - a * 3 # => ["x", "y", "x", "y", "x", "y"] - -When string argument `string_separator` is given, equivalent to -`self.join(string_separator)`: - - [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {foo: 0}" - -**@overload** [] - -**@overload** [] - -## -(a) [](#method-i--) -Returns a new array containing only those elements of `self` that are not -found in `other_array`; the order from `self` is preserved: - - [0, 1, 1, 2, 1, 1, 3, 1, 1] - [1] # => [0, 2, 3] - [0, 1, 1, 2, 1, 1, 3, 1, 1] - [3, 2, 0, :foo] # => [1, 1, 1, 1, 1, 1] - [0, 1, 2] - [:foo] # => [0, 1, 2] - -Element are compared using method `#eql?` (as defined in each element of -`self`). - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -## -@() [](#method-i--@) - -## <<(item) [](#method-i-<<) -Appends `object` as the last element in `self`; returns `self`: - - [:foo, 'bar', 2] << :baz # => [:foo, "bar", 2, :baz] - -Appends `object` as a single element, even if it is another array: - - [:foo, 'bar', 2] << [3, 4] # => [:foo, "bar", 2, [3, 4]] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -## <=>(ary2) [](#method-i-<=>) -Returns -1, 0, or 1 as `self` is determined to be less than, equal to, or -greater than `other_array`. - -Iterates over each index `i` in `(0...self.size)`: - -* Computes `result[i]` as `self[i] <=> other_array[i]`. -* Immediately returns 1 if `result[i]` is 1: - - [0, 1, 2] <=> [0, 0, 2] # => 1 - -* Immediately returns -1 if `result[i]` is -1: - - [0, 1, 2] <=> [0, 2, 2] # => -1 - -* Continues if `result[i]` is 0. - -When every `result` is 0, returns `self.size <=> other_array.size` (see -Integer#<=>): - - [0, 1, 2] <=> [0, 1] # => 1 - [0, 1, 2] <=> [0, 1, 2] # => 0 - [0, 1, 2] <=> [0, 1, 2, 3] # => -1 - -Note that when `other_array` is larger than `self`, its trailing elements do -not affect the result: - - [0, 1, 2] <=> [0, 1, 2, -3] # => -1 - [0, 1, 2] <=> [0, 1, 2, 0] # => -1 - [0, 1, 2] <=> [0, 1, 2, 3] # => -1 - -Related: see [Methods for Comparing](rdoc-ref:Array@Methods+for+Comparing). - -**@overload** [] - -## ==(ary2) [](#method-i-==) -Returns whether both: - -* `self` and `other_array` are the same size. -* Their corresponding elements are the same; that is, for each index `i` in - `(0...self.size)`, `self[i] == other_array[i]`. - -Examples: - - [:foo, 'bar', 2] == [:foo, 'bar', 2] # => true - [:foo, 'bar', 2] == [:foo, 'bar', 2.0] # => true - [:foo, 'bar', 2] == [:foo, 'bar'] # => false # Different sizes. - [:foo, 'bar', 2] == [:foo, 'bar', 3] # => false # Different elements. - -This method is different from method Array#eql?, which compares elements using -`Object#eql?`. - -Related: see [Methods for Comparing](rdoc-ref:Array@Methods+for+Comparing). - -**@overload** [] - -## [](*args) [](#method-i-[]) -Returns elements from `self`; does not modify `self`. - -In brief: - - a = [:foo, 'bar', 2] - - # Single argument index: returns one element. - a[0] # => :foo # Zero-based index. - a[-1] # => 2 # Negative index counts backwards from end. - - # Arguments start and length: returns an array. - a[1, 2] # => ["bar", 2] - a[-2, 2] # => ["bar", 2] # Negative start counts backwards from end. - - # Single argument range: returns an array. - a[0..1] # => [:foo, "bar"] - a[0..-2] # => [:foo, "bar"] # Negative range-begin counts backwards from end. - a[-2..2] # => ["bar", 2] # Negative range-end counts backwards from end. - -When a single integer argument `index` is given, returns the element at offset -`index`: - - a = [:foo, 'bar', 2] - a[0] # => :foo - a[2] # => 2 - a # => [:foo, "bar", 2] - -If `index` is negative, counts backwards from the end of `self`: - - a = [:foo, 'bar', 2] - a[-1] # => 2 - a[-2] # => "bar" - -If `index` is out of range, returns `nil`. - -When two Integer arguments `start` and `length` are given, returns a new -`Array` of size `length` containing successive elements beginning at offset -`start`: - - a = [:foo, 'bar', 2] - a[0, 2] # => [:foo, "bar"] - a[1, 2] # => ["bar", 2] - -If `start + length` is greater than `self.length`, returns all elements from -offset `start` to the end: - - a = [:foo, 'bar', 2] - a[0, 4] # => [:foo, "bar", 2] - a[1, 3] # => ["bar", 2] - a[2, 2] # => [2] - -If `start == self.size` and `length >= 0`, returns a new empty `Array`. - -If `length` is negative, returns `nil`. - -When a single Range argument `range` is given, treats `range.min` as `start` -above and `range.size` as `length` above: - - a = [:foo, 'bar', 2] - a[0..1] # => [:foo, "bar"] - a[1..2] # => ["bar", 2] - -Special case: If `range.start == a.size`, returns a new empty `Array`. - -If `range.end` is negative, calculates the end index from the end: - - a = [:foo, 'bar', 2] - a[0..-1] # => [:foo, "bar", 2] - a[0..-2] # => [:foo, "bar"] - a[0..-3] # => [:foo] - -If `range.start` is negative, calculates the start index from the end: - - a = [:foo, 'bar', 2] - a[-1..2] # => [2] - a[-2..2] # => ["bar", 2] - a[-3..2] # => [:foo, "bar", 2] - -If `range.start` is larger than the array size, returns `nil`. - - a = [:foo, 'bar', 2] - a[4..1] # => nil - a[4..0] # => nil - a[4..-1] # => nil - -When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns -an `Array` of elements corresponding to the indexes produced by the sequence. - - a = ['--', 'data1', '--', 'data2', '--', 'data3'] - a[(1..).step(2)] # => ["data1", "data2", "data3"] - -Unlike slicing with range, if the start or the end of the arithmetic sequence -is larger than array size, throws RangeError. - - a = ['--', 'data1', '--', 'data2', '--', 'data3'] - a[(1..11).step(2)] - # RangeError (((1..11).step(2)) out of range) - a[(7..).step(2)] - # RangeError (((7..).step(2)) out of range) - -If given a single argument, and its type is not one of the listed, tries to -convert it to Integer, and raises if it is impossible: - - a = [:foo, 'bar', 2] - # Raises TypeError (no implicit conversion of Symbol into Integer): - a[:foo] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## []=(*args) [](#method-i-[]=) -Assigns elements in `self`, based on the given `object`; returns `object`. - -In brief: - - a_orig = [:foo, 'bar', 2] - - # With argument index. - a = a_orig.dup - a[0] = 'foo' # => "foo" - a # => ["foo", "bar", 2] - a = a_orig.dup - a[7] = 'foo' # => "foo" - a # => [:foo, "bar", 2, nil, nil, nil, nil, "foo"] - - # With arguments start and length. - a = a_orig.dup - a[0, 2] = 'foo' # => "foo" - a # => ["foo", 2] - a = a_orig.dup - a[6, 50] = 'foo' # => "foo" - a # => [:foo, "bar", 2, nil, nil, nil, "foo"] - - # With argument range. - a = a_orig.dup - a[0..1] = 'foo' # => "foo" - a # => ["foo", 2] - a = a_orig.dup - a[6..50] = 'foo' # => "foo" - a # => [:foo, "bar", 2, nil, nil, nil, "foo"] - -When Integer argument `index` is given, assigns `object` to an element in -`self`. - -If `index` is non-negative, assigns `object` the element at offset `index`: - - a = [:foo, 'bar', 2] - a[0] = 'foo' # => "foo" - a # => ["foo", "bar", 2] - -If `index` is greater than `self.length`, extends the array: - - a = [:foo, 'bar', 2] - a[7] = 'foo' # => "foo" - a # => [:foo, "bar", 2, nil, nil, nil, nil, "foo"] - -If `index` is negative, counts backwards from the end of the array: - - a = [:foo, 'bar', 2] - a[-1] = 'two' # => "two" - a # => [:foo, "bar", "two"] - -When Integer arguments `start` and `length` are given and `object` is not an -`Array`, removes `length - 1` elements beginning at offset `start`, and -assigns `object` at offset `start`: - - a = [:foo, 'bar', 2] - a[0, 2] = 'foo' # => "foo" - a # => ["foo", 2] - -If `start` is negative, counts backwards from the end of the array: - - a = [:foo, 'bar', 2] - a[-2, 2] = 'foo' # => "foo" - a # => [:foo, "foo"] - -If `start` is non-negative and outside the array (` >= self.size`), extends -the array with `nil`, assigns `object` at offset `start`, and ignores -`length`: - - a = [:foo, 'bar', 2] - a[6, 50] = 'foo' # => "foo" - a # => [:foo, "bar", 2, nil, nil, nil, "foo"] - -If `length` is zero, shifts elements at and following offset `start` and -assigns `object` at offset `start`: - - a = [:foo, 'bar', 2] - a[1, 0] = 'foo' # => "foo" - a # => [:foo, "foo", "bar", 2] - -If `length` is too large for the existing array, does not extend the array: - - a = [:foo, 'bar', 2] - a[1, 5] = 'foo' # => "foo" - a # => [:foo, "foo"] - -When Range argument `range` is given and `object` is not an `Array`, removes -`length - 1` elements beginning at offset `start`, and assigns `object` at -offset `start`: - - a = [:foo, 'bar', 2] - a[0..1] = 'foo' # => "foo" - a # => ["foo", 2] - -if `range.begin` is negative, counts backwards from the end of the array: - - a = [:foo, 'bar', 2] - a[-2..2] = 'foo' # => "foo" - a # => [:foo, "foo"] - -If the array length is less than `range.begin`, extends the array with `nil`, -assigns `object` at offset `range.begin`, and ignores `length`: - - a = [:foo, 'bar', 2] - a[6..50] = 'foo' # => "foo" - a # => [:foo, "bar", 2, nil, nil, nil, "foo"] - -If `range.end` is zero, shifts elements at and following offset `start` and -assigns `object` at offset `start`: - - a = [:foo, 'bar', 2] - a[1..0] = 'foo' # => "foo" - a # => [:foo, "foo", "bar", 2] - -If `range.end` is negative, assigns `object` at offset `start`, retains -`range.end.abs -1` elements past that, and removes those beyond: - - a = [:foo, 'bar', 2] - a[1..-1] = 'foo' # => "foo" - a # => [:foo, "foo"] - a = [:foo, 'bar', 2] - a[1..-2] = 'foo' # => "foo" - a # => [:foo, "foo", 2] - a = [:foo, 'bar', 2] - a[1..-3] = 'foo' # => "foo" - a # => [:foo, "foo", "bar", 2] - a = [:foo, 'bar', 2] - -If `range.end` is too large for the existing array, replaces array elements, -but does not extend the array with `nil` values: - - a = [:foo, 'bar', 2] - a[1..5] = 'foo' # => "foo" - a # => [:foo, "foo"] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## all?(*args) [](#method-i-all?) -Returns whether for every element of `self`, a given criterion is satisfied. - -With no block and no argument, returns whether every element of `self` is -truthy: - - [[], {}, '', 0, 0.0, Object.new].all? # => true # All truthy objects. - [[], {}, '', 0, 0.0, nil].all? # => false # nil is not truthy. - [[], {}, '', 0, 0.0, false].all? # => false # false is not truthy. - -With argument `object` given, returns whether `object === ele` for every -element `ele` in `self`: - - [0, 0, 0].all?(0) # => true - [0, 1, 2].all?(1) # => false - ['food', 'fool', 'foot'].all?(/foo/) # => true - ['food', 'drink'].all?(/foo/) # => false - -With a block given, calls the block with each element in `self`; returns -whether the block returns only truthy values: - - [0, 1, 2].all? { |ele| ele < 3 } # => true - [0, 1, 2].all? { |ele| ele < 2 } # => false - -With both a block and argument `object` given, ignores the block and uses -`object` as above. - -**Special case**: returns `true` if `self` is empty (regardless of any given -argument or block). - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether for any element of `self`, a given criterion is satisfied. - -With no block and no argument, returns whether any element of `self` is -truthy: - - [nil, false, []].any? # => true # Array object is truthy. - [nil, false, {}].any? # => true # Hash object is truthy. - [nil, false, ''].any? # => true # String object is truthy. - [nil, false].any? # => false # Nil and false are not truthy. - -With argument `object` given, returns whether `object === ele` for any element -`ele` in `self`: - - [nil, false, 0].any?(0) # => true - [nil, false, 1].any?(0) # => false - [nil, false, 'food'].any?(/foo/) # => true - [nil, false, 'food'].any?(/bar/) # => false - -With a block given, calls the block with each element in `self`; returns -whether the block returns any truthy value: - - [0, 1, 2].any? {|ele| ele < 1 } # => true - [0, 1, 2].any? {|ele| ele < 0 } # => false - -With both a block and argument `object` given, ignores the block and uses -`object` as above. - -**Special case**: returns `false` if `self` is empty (regardless of any given -argument or block). - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## assoc(key) [](#method-i-assoc) -Returns the first element `ele` in `self` such that `ele` is an array and -`ele[0] == object`: - - a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] - a.assoc(4) # => [4, 5, 6] - -Returns `nil` if no such element is found. - -Related: Array#rassoc; see also [Methods for -Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -## at(pos) [](#method-i-at) -Returns the element of `self` specified by the given `index` or `nil` if there -is no such element; `index` must be an [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects). - -For non-negative `index`, returns the element of `self` at offset `index`: - - a = [:foo, 'bar', 2] - a.at(0) # => :foo - a.at(2) # => 2 - a.at(2.0) # => 2 - -For negative `index`, counts backwards from the end of `self`: - - a.at(-2) # => "bar" - -Related: Array#[]; see also [Methods for -Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -## bsearch() [](#method-i-bsearch) -Returns the element from `self` found by a binary search, or `nil` if the -search found no suitable element. - -See [Binary Searching](rdoc-ref:bsearch.rdoc). - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -## bsearch_index() [](#method-i-bsearch_index) -Returns the integer index of the element from `self` found by a binary search, -or `nil` if the search found no suitable element. - -See [Binary Searching](rdoc-ref:bsearch.rdoc). - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## clear() [](#method-i-clear) -Removes all elements from `self`; returns `self`: - - a = [:foo, 'bar', 2] - a.clear # => [] - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -## collect() [](#method-i-collect) -With a block given, calls the block with each element of `self`; returns a new -array whose elements are the return values from the block: - - a = [:foo, 'bar', 2] - a1 = a.map {|element| element.class } - a1 # => [Symbol, String, Integer] - -With no block given, returns a new Enumerator. - -Related: #collect!; see also [Methods for -Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## collect!() [](#method-i-collect!) -With a block given, calls the block with each element of `self` and replaces -the element with the block's return value; returns `self`: - - a = [:foo, 'bar', 2] - a.map! { |element| element.class } # => [Symbol, String, Integer] - -With no block given, returns a new Enumerator. - -Related: #collect; see also [Methods for -Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## combination(num) [](#method-i-combination) -When a block and a positive [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects) -argument `count` (`0 < count <= self.size`) are given, calls the block with -each combination of `self` of size `count`; returns `self`: - - a = %w[a b c] # => ["a", "b", "c"] - a.combination(2) {|combination| p combination } # => ["a", "b", "c"] - -Output: - - ["a", "b"] - ["a", "c"] - ["b", "c"] - -The order of the yielded combinations is not guaranteed. - -When `count` is zero, calls the block once with a new empty array: - - a.combination(0) {|combination| p combination } - [].combination(0) {|combination| p combination } - -Output: - - [] - [] - -When `count` is negative or larger than `self.size` and `self` is non-empty, -does not call the block: - - a.combination(-1) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"] - a.combination(4) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"] - -With no block given, returns a new Enumerator. - -Related: Array#permutation; see also [Methods for -Iterating](rdoc-ref:Array@Methods+for+Iterating). - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns a new array containing only the non-`nil` elements from `self`; -element order is preserved: - - a = [nil, 0, nil, false, nil, '', nil, [], nil, {}] - a.compact # => [0, false, "", [], {}] - -Related: Array#compact!; see also [Methods for -Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -## compact!() [](#method-i-compact!) -Removes all `nil` elements from `self`; Returns `self` if any elements are -removed, `nil` otherwise: - - a = [nil, 0, nil, false, nil, '', nil, [], nil, {}] - a.compact! # => [0, false, "", [], {}] - a # => [0, false, "", [], {}] - a.compact! # => nil - -Related: Array#compact; see also [Methods for -Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -## concat(*args) [](#method-i-concat) -Adds to `self` all elements from each array in `other_arrays`; returns `self`: - - a = [0, 1] - a.concat(['two', 'three'], [:four, :five], a) - # => [0, 1, "two", "three", :four, :five, 0, 1] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns a count of specified elements. - -With no argument and no block, returns the count of all elements: - - [0, :one, 'two', 3, 3.0].count # => 5 - -With argument `object` given, returns the count of elements `==` to `object`: - - [0, :one, 'two', 3, 3.0].count(3) # => 2 - -With no argument and a block given, calls the block with each element; returns -the count of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element > 1 } # => 2 - -With argument `object` and a block given, issues a warning, ignores the block, -and returns the count of elements `==` to `object`. - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -With a block given, may call the block, depending on the value of argument -`count`; `count` must be an [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects), or -`nil`. - -When `count` is positive, calls the block with each element, then does so -repeatedly, until it has done so `count` times; returns `nil`: - - output = [] - [0, 1].cycle(2) {|element| output.push(element) } # => nil - output # => [0, 1, 0, 1] - -When `count` is zero or negative, does not call the block: - - [0, 1].cycle(0) {|element| fail 'Cannot happen' } # => nil - [0, 1].cycle(-1) {|element| fail 'Cannot happen' } # => nil - -When `count` is `nil`, cycles forever: - - # Prints 0 and 1 forever. - [0, 1].cycle {|element| puts element } - [0, 1].cycle(nil) {|element| puts element } - -With no block given, returns a new Enumerator. - -Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating). - -**@overload** [] - -**@overload** [] - -## deconstruct() [](#method-i-deconstruct) -:nodoc: - -## delete(item) [](#method-i-delete) -Removes zero or more elements from `self`. - -With no block given, removes from `self` each element `ele` such that `ele == -object`; returns the last removed element: - - a = [0, 1, 2, 2.0] - a.delete(2) # => 2.0 - a # => [0, 1] - -Returns `nil` if no elements removed: - - a.delete(2) # => nil - -With a block given, removes from `self` each element `ele` such that `ele == -object`. - -If any such elements are found, ignores the block and returns the last removed -element: - - a = [0, 1, 2, 2.0] - a.delete(2) {|element| fail 'Cannot happen' } # => 2.0 - a # => [0, 1] - -If no such element is found, returns the block's return value: - - a.delete(2) {|element| "Element #{element} not found." } - # => "Element 2 not found." - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -## delete_at(pos) [](#method-i-delete_at) -Removes the element of `self` at the given `index`, which must be an -[integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects). - -When `index` is non-negative, deletes the element at offset `index`: - - a = [:foo, 'bar', 2] - a.delete_at(1) # => "bar" - a # => [:foo, 2] - -When `index` is negative, counts backward from the end of the array: - - a = [:foo, 'bar', 2] - a.delete_at(-2) # => "bar" - a # => [:foo, 2] - -When `index` is out of range, returns `nil`. - - a = [:foo, 'bar', 2] - a.delete_at(3) # => nil - a.delete_at(-4) # => nil - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -## delete_if() [](#method-i-delete_if) -With a block given, calls the block with each element of `self`; removes the -element if the block returns a truthy value; returns `self`: - - a = [:foo, 'bar', 2, 'bat'] - a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2] - -With no block given, returns a new Enumerator. - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## difference(*args) [](#method-i-difference) -Returns a new array containing only those elements from `self` that are not -found in any of the given `other_arrays`; items are compared using `eql?`; -order from `self` is preserved: - - [0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3] - [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2] - [0, 1, 2].difference([4]) # => [0, 1, 2] - [0, 1, 2].difference # => [0, 1, 2] - -Returns a copy of `self` if no arguments are given. - -Related: Array#-; see also [Methods for -Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -## dig(*args) [](#method-i-dig) -Finds and returns the object in nested object specified by `index` and -`identifiers`; the nested objects may be instances of various classes. See -[Dig Methods](rdoc-ref:dig_methods.rdoc). - -Examples: - - a = [:foo, [:bar, :baz, [:bat, :bam]]] - a.dig(1) # => [:bar, :baz, [:bat, :bam]] - a.dig(1, 2) # => [:bat, :bam] - a.dig(1, 2, 0) # => :bat - a.dig(1, 2, 3) # => nil - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -## drop(n) [](#method-i-drop) -Returns a new array containing all but the first `count` element of `self`, -where `count` is a non-negative integer; does not modify `self`. - -Examples: - - a = [0, 1, 2, 3, 4, 5] - a.drop(0) # => [0, 1, 2, 3, 4, 5] - a.drop(1) # => [1, 2, 3, 4, 5] - a.drop(2) # => [2, 3, 4, 5] - a.drop(9) # => [] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -With a block given, calls the block with each successive element of `self`; -stops if the block returns `false` or `nil`; returns a new array *omitting* -those elements for which the block returned a truthy value; does not modify -`self`: - - a = [0, 1, 2, 3, 4, 5] - a.drop_while {|element| element < 3 } # => [3, 4, 5] - -With no block given, returns a new Enumerator. - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -With a block given, iterates over the elements of `self`, passing each element -to the block; returns `self`: - - a = [:foo, 'bar', 2] - a.each {|element| puts "#{element.class} #{element}" } - -Output: - - Symbol foo - String bar - Integer 2 - -Allows the array to be modified during iteration: - - a = [:foo, 'bar', 2] - a.each {|element| puts element; a.clear if element.to_s.start_with?('b') } - -Output: - - foo - bar - -With no block given, returns a new Enumerator. - -Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating). - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_index() [](#method-i-each_index) -With a block given, iterates over the elements of `self`, passing each *array -index* to the block; returns `self`: - - a = [:foo, 'bar', 2] - a.each_index {|index| puts "#{index} #{a[index]}" } - -Output: - - 0 foo - 1 bar - 2 2 - -Allows the array to be modified during iteration: - - a = [:foo, 'bar', 2] - a.each_index {|index| puts index; a.clear if index > 0 } - a # => [] - -Output: - - 0 - 1 - -With no block given, returns a new Enumerator. - -Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating). - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Returns `true` if the count of elements in `self` is zero, `false` otherwise. - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eql?(ary2) [](#method-i-eql?) -Returns `true` if `self` and `other_array` are the same size, and if, for each -index `i` in `self`, `self[i].eql?(other_array[i])`: - - a0 = [:foo, 'bar', 2] - a1 = [:foo, 'bar', 2] - a1.eql?(a0) # => true - -Otherwise, returns `false`. - -This method is different from method Array#==, which compares using method -`Object#==`. - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -## fetch(*args) [](#method-i-fetch) -Returns the element of `self` at offset `index` if `index` is in range; -`index` must be an [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects). - -With the single argument `index` and no block, returns the element at offset -`index`: - - a = [:foo, 'bar', 2] - a.fetch(1) # => "bar" - a.fetch(1.1) # => "bar" - -If `index` is negative, counts from the end of the array: - - a = [:foo, 'bar', 2] - a.fetch(-1) # => 2 - a.fetch(-2) # => "bar" - -With arguments `index` and `default_value` (which may be any object) and no -block, returns `default_value` if `index` is out-of-range: - - a = [:foo, 'bar', 2] - a.fetch(1, nil) # => "bar" - a.fetch(3, :foo) # => :foo - -With argument `index` and a block, returns the element at offset `index` if -index is in range (and the block is not called); otherwise calls the block -with index and returns its return value: - - a = [:foo, 'bar', 2] - a.fetch(1) {|index| raise 'Cannot happen' } # => "bar" - a.fetch(50) {|index| "Value for #{index}" } # => "Value for 50" - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## fetch_values(*indexes, &block) [](#method-i-fetch_values) -call-seq: - fetch_values(*indexes) -> new_array - fetch_values(*indexes) { |index| ... } -> new_array - -With no block given, returns a new array containing the elements of `self` at -the offsets specified by `indexes`. Each of the `indexes` must be an -[integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects): - - a = [:foo, :bar, :baz] - a.fetch_values(2, 0) # => [:baz, :foo] - a.fetch_values(2.1, 0) # => [:baz, :foo] - a.fetch_values # => [] - -For a negative index, counts backwards from the end of the array: - - a.fetch_values(-2, -1) # [:bar, :baz] - -When no block is given, raises an exception if any index is out of range. - -With a block given, for each index: - -* If the index is in range, uses an element of `self` (as above). -* Otherwise, calls the block with the index and uses the block's return - value. - -Example: - - a = [:foo, :bar, :baz] - a.fetch_values(1, 0, 42, 777) { |index| index.to_s } - # => [:bar, :foo, "42", "777"] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -## fill(*args) [](#method-i-fill) -Replaces selected elements in `self`; may add elements to `self`; always -returns `self` (never a new array). - -In brief: - - # Non-negative start. - ['a', 'b', 'c', 'd'].fill('-', 1, 2) # => ["a", "-", "-", "d"] - ['a', 'b', 'c', 'd'].fill(1, 2) {|e| e.to_s } # => ["a", "1", "2", "d"] - - # Extends with specified values if necessary. - ['a', 'b', 'c', 'd'].fill('-', 3, 2) # => ["a", "b", "c", "-", "-"] - ['a', 'b', 'c', 'd'].fill(3, 2) {|e| e.to_s } # => ["a", "b", "c", "3", "4"] - - # Fills with nils if necessary. - ['a', 'b', 'c', 'd'].fill('-', 6, 2) # => ["a", "b", "c", "d", nil, nil, "-", "-"] - ['a', 'b', 'c', 'd'].fill(6, 2) {|e| e.to_s } # => ["a", "b", "c", "d", nil, nil, "6", "7"] - - # For negative start, counts backwards from the end. - ['a', 'b', 'c', 'd'].fill('-', -3, 3) # => ["a", "-", "-", "-"] - ['a', 'b', 'c', 'd'].fill(-3, 3) {|e| e.to_s } # => ["a", "1", "2", "3"] - - # Range. - ['a', 'b', 'c', 'd'].fill('-', 1..2) # => ["a", "-", "-", "d"] - ['a', 'b', 'c', 'd'].fill(1..2) {|e| e.to_s } # => ["a", "1", "2", "d"] - -When arguments `start` and `count` are given, they select the elements of -`self` to be replaced; each must be an [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects) (or -`nil`): - -* `start` specifies the zero-based offset of the first element to be - replaced; `nil` means zero. -* `count` is the number of consecutive elements to be replaced; `nil` means - "all the rest." - -With argument `object` given, that one object is used for all replacements: - - o = Object.new # => # - a = ['a', 'b', 'c', 'd'] # => ["a", "b", "c", "d"] - a.fill(o, 1, 2) - # => ["a", #, #, "d"] - -With a block given, the block is called once for each element to be replaced; -the value passed to the block is the *index* of the element to be replaced -(not the element itself); the block's return value replaces the element: - - a = ['a', 'b', 'c', 'd'] # => ["a", "b", "c", "d"] - a.fill(1, 2) {|element| element.to_s } # => ["a", "1", "2", "d"] - -For arguments `start` and `count`: - -* If `start` is non-negative, replaces `count` elements beginning at offset - `start`: - - ['a', 'b', 'c', 'd'].fill('-', 0, 2) # => ["-", "-", "c", "d"] - ['a', 'b', 'c', 'd'].fill('-', 1, 2) # => ["a", "-", "-", "d"] - ['a', 'b', 'c', 'd'].fill('-', 2, 2) # => ["a", "b", "-", "-"] - - ['a', 'b', 'c', 'd'].fill(0, 2) {|e| e.to_s } # => ["0", "1", "c", "d"] - ['a', 'b', 'c', 'd'].fill(1, 2) {|e| e.to_s } # => ["a", "1", "2", "d"] - ['a', 'b', 'c', 'd'].fill(2, 2) {|e| e.to_s } # => ["a", "b", "2", "3"] - - Extends `self` if necessary: - - ['a', 'b', 'c', 'd'].fill('-', 3, 2) # => ["a", "b", "c", "-", "-"] - ['a', 'b', 'c', 'd'].fill('-', 4, 2) # => ["a", "b", "c", "d", "-", "-"] - - ['a', 'b', 'c', 'd'].fill(3, 2) {|e| e.to_s } # => ["a", "b", "c", "3", "4"] - ['a', 'b', 'c', 'd'].fill(4, 2) {|e| e.to_s } # => ["a", "b", "c", "d", "4", "5"] - - Fills with `nil` if necessary: - - ['a', 'b', 'c', 'd'].fill('-', 5, 2) # => ["a", "b", "c", "d", nil, "-", "-"] - ['a', 'b', 'c', 'd'].fill('-', 6, 2) # => ["a", "b", "c", "d", nil, nil, "-", "-"] - - ['a', 'b', 'c', 'd'].fill(5, 2) {|e| e.to_s } # => ["a", "b", "c", "d", nil, "5", "6"] - ['a', 'b', 'c', 'd'].fill(6, 2) {|e| e.to_s } # => ["a", "b", "c", "d", nil, nil, "6", "7"] - - Does nothing if `count` is non-positive: - - ['a', 'b', 'c', 'd'].fill('-', 2, 0) # => ["a", "b", "c", "d"] - ['a', 'b', 'c', 'd'].fill('-', 2, -100) # => ["a", "b", "c", "d"] - ['a', 'b', 'c', 'd'].fill('-', 6, -100) # => ["a", "b", "c", "d"] - - ['a', 'b', 'c', 'd'].fill(2, 0) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"] - ['a', 'b', 'c', 'd'].fill(2, -100) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"] - ['a', 'b', 'c', 'd'].fill(6, -100) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"] - -* If `start` is negative, counts backwards from the end of `self`: - - ['a', 'b', 'c', 'd'].fill('-', -4, 3) # => ["-", "-", "-", "d"] - ['a', 'b', 'c', 'd'].fill('-', -3, 3) # => ["a", "-", "-", "-"] - - ['a', 'b', 'c', 'd'].fill(-4, 3) {|e| e.to_s } # => ["0", "1", "2", "d"] - ['a', 'b', 'c', 'd'].fill(-3, 3) {|e| e.to_s } # => ["a", "1", "2", "3"] - - Extends `self` if necessary: - - ['a', 'b', 'c', 'd'].fill('-', -2, 3) # => ["a", "b", "-", "-", "-"] - ['a', 'b', 'c', 'd'].fill('-', -1, 3) # => ["a", "b", "c", "-", "-", "-"] - - ['a', 'b', 'c', 'd'].fill(-2, 3) {|e| e.to_s } # => ["a", "b", "2", "3", "4"] - ['a', 'b', 'c', 'd'].fill(-1, 3) {|e| e.to_s } # => ["a", "b", "c", "3", "4", "5"] - - Starts at the beginning of `self` if `start` is negative and out-of-range: - - ['a', 'b', 'c', 'd'].fill('-', -5, 2) # => ["-", "-", "c", "d"] - ['a', 'b', 'c', 'd'].fill('-', -6, 2) # => ["-", "-", "c", "d"] - - ['a', 'b', 'c', 'd'].fill(-5, 2) {|e| e.to_s } # => ["0", "1", "c", "d"] - ['a', 'b', 'c', 'd'].fill(-6, 2) {|e| e.to_s } # => ["0", "1", "c", "d"] - - Does nothing if `count` is non-positive: - - ['a', 'b', 'c', 'd'].fill('-', -2, 0) # => ["a", "b", "c", "d"] - ['a', 'b', 'c', 'd'].fill('-', -2, -1) # => ["a", "b", "c", "d"] - - ['a', 'b', 'c', 'd'].fill(-2, 0) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"] - ['a', 'b', 'c', 'd'].fill(-2, -1) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"] - -When argument `range` is given, it must be a Range object whose members are -numeric; its `begin` and `end` values determine the elements of `self` to be -replaced: - -* If both `begin` and `end` are positive, they specify the first and last - elements to be replaced: - - ['a', 'b', 'c', 'd'].fill('-', 1..2) # => ["a", "-", "-", "d"] - ['a', 'b', 'c', 'd'].fill(1..2) {|e| e.to_s } # => ["a", "1", "2", "d"] - - If `end` is smaller than `begin`, replaces no elements: - - ['a', 'b', 'c', 'd'].fill('-', 2..1) # => ["a", "b", "c", "d"] - ['a', 'b', 'c', 'd'].fill(2..1) {|e| e.to_s } # => ["a", "b", "c", "d"] - -* If either is negative (or both are negative), counts backwards from the - end of `self`: - - ['a', 'b', 'c', 'd'].fill('-', -3..2) # => ["a", "-", "-", "d"] - ['a', 'b', 'c', 'd'].fill('-', 1..-2) # => ["a", "-", "-", "d"] - ['a', 'b', 'c', 'd'].fill('-', -3..-2) # => ["a", "-", "-", "d"] - - ['a', 'b', 'c', 'd'].fill(-3..2) {|e| e.to_s } # => ["a", "1", "2", "d"] - ['a', 'b', 'c', 'd'].fill(1..-2) {|e| e.to_s } # => ["a", "1", "2", "d"] - ['a', 'b', 'c', 'd'].fill(-3..-2) {|e| e.to_s } # => ["a", "1", "2", "d"] - -* If the `end` value is excluded (see Range#exclude_end?), omits the last - replacement: - - ['a', 'b', 'c', 'd'].fill('-', 1...2) # => ["a", "-", "c", "d"] - ['a', 'b', 'c', 'd'].fill('-', 1...-2) # => ["a", "-", "c", "d"] - - ['a', 'b', 'c', 'd'].fill(1...2) {|e| e.to_s } # => ["a", "1", "c", "d"] - ['a', 'b', 'c', 'd'].fill(1...-2) {|e| e.to_s } # => ["a", "1", "c", "d"] - -* If the range is endless (see [Endless - Ranges](rdoc-ref:Range@Endless+Ranges)), replaces elements to the end of - `self`: - - ['a', 'b', 'c', 'd'].fill('-', 1..) # => ["a", "-", "-", "-"] - ['a', 'b', 'c', 'd'].fill(1..) {|e| e.to_s } # => ["a", "1", "2", "3"] - -* If the range is beginless (see [Beginless - Ranges](rdoc-ref:Range@Beginless+Ranges)), replaces elements from the - beginning of `self`: - - ['a', 'b', 'c', 'd'].fill('-', ..2) # => ["-", "-", "-", "d"] - ['a', 'b', 'c', 'd'].fill(..2) {|e| e.to_s } # => ["0", "1", "2", "d"] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## filter() [](#method-i-filter) -With a block given, calls the block with each element of `self`; returns a new -array containing those elements of `self` for which the block returns a truthy -value: - - a = [:foo, 'bar', 2, :bam] - a.select {|element| element.to_s.start_with?('b') } - # => ["bar", :bam] - -With no block given, returns a new Enumerator. - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## filter!() [](#method-i-filter!) -With a block given, calls the block with each element of `self`; removes from -`self` those elements for which the block returns `false` or `nil`. - -Returns `self` if any elements were removed: - - a = [:foo, 'bar', 2, :bam] - a.select! {|element| element.to_s.start_with?('b') } # => ["bar", :bam] - -Returns `nil` if no elements were removed. - -With no block given, returns a new Enumerator. - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the zero-based integer index of a specified element, or `nil`. - -With only argument `object` given, returns the index of the first element -`element` for which `object == element`: - - a = [:foo, 'bar', 2, 'bar'] - a.index('bar') # => 1 - -Returns `nil` if no such element found. - -With only a block given, calls the block with each successive element; returns -the index of the first element for which the block returns a truthy value: - - a = [:foo, 'bar', 2, 'bar'] - a.index {|element| element == 'bar' } # => 1 - -Returns `nil` if the block never returns a truthy value. - -With neither an argument nor a block given, returns a new Enumerator. - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(nunspecified = true) [](#method-i-first) -call-seq: - first -> object or nil - first(count) -> new_array - -Returns elements from `self`, or `nil`; does not modify `self`. - -With no argument given, returns the first element (if available): - - a = [:foo, 'bar', 2] - a.first # => :foo - a # => [:foo, "bar", 2] - -If `self` is empty, returns `nil`. - - [].first # => nil - -With a non-negative integer argument `count` given, returns the first `count` -elements (as available) in a new array: - - a.first(0) # => [] - a.first(2) # => [:foo, "bar"] - a.first(50) # => [:foo, "bar", 2] - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flatten(*args) [](#method-i-flatten) -Returns a new array that is a recursive flattening of `self` to `depth` levels -of recursion; `depth` must be an [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects) or -`nil`. At each level of recursion: - -* Each element that is an array is "flattened" (that is, replaced by its - individual array elements). -* Each element that is not an array is unchanged (even if the element is an - object that has instance method `flatten`). - -With non-negative integer argument `depth`, flattens recursively through -`depth` levels: - - a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ] - a # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #] - a.flatten(0) # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #] - a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #] - a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #] - a.flatten(2) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - a.flatten(3) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - -With `nil` or negative `depth`, flattens all levels. - - a.flatten # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - -Related: Array#flatten!; see also [Methods for -Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -## flatten!(*args) [](#method-i-flatten!) -Returns `self` as a recursively flattening of `self` to `depth` levels of -recursion; `depth` must be an [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects), or -`nil`. At each level of recursion: - -* Each element that is an array is "flattened" (that is, replaced by its - individual array elements). -* Each element that is not an array is unchanged (even if the element is an - object that has instance method `flatten`). - -Returns `nil` if no elements were flattened. - -With non-negative integer argument `depth`, flattens recursively through -`depth` levels: - - a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ] - a # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #] - a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #] - a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #] - a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - -With `nil` or negative argument `depth`, flattens all levels: - - a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - -Related: Array#flatten; see also [Methods for -Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -## freeze() [](#method-i-freeze) -Freezes `self` (if not already frozen); returns `self`: - - a = [] - a.frozen? # => false - a.freeze - a.frozen? # => true - -No further changes may be made to `self`; raises FrozenError if a change is -attempted. - -Related: Kernel#frozen?. - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -Returns the integer hash value for `self`. - -Two arrays with the same content will have the same hash value (and will -compare using eql?): - - ['a', 'b'].hash == ['a', 'b'].hash # => true - ['a', 'b'].hash == ['a', 'c'].hash # => false - ['a', 'b'].hash == ['a'].hash # => false - -**@overload** [] - -## include?(item) [](#method-i-include?) -Returns whether for some element `element` in `self`, `object == element`: - - [0, 1, 2].include?(2) # => true - [0, 1, 2].include?(2.0) # => true - [0, 1, 2].include?(2.1) # => false - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -## index(*args) [](#method-i-index) -Returns the zero-based integer index of a specified element, or `nil`. - -With only argument `object` given, returns the index of the first element -`element` for which `object == element`: - - a = [:foo, 'bar', 2, 'bar'] - a.index('bar') # => 1 - -Returns `nil` if no such element found. - -With only a block given, calls the block with each successive element; returns -the index of the first element for which the block returns a truthy value: - - a = [:foo, 'bar', 2, 'bar'] - a.index {|element| element == 'bar' } # => 1 - -Returns `nil` if the block never returns a truthy value. - -With neither an argument nor a block given, returns a new Enumerator. - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Returns a new array. - -With no block and no argument given, returns a new empty array: - - Array.new # => [] - -With no block and array argument given, returns a new array with the same -elements: - - Array.new([:foo, 'bar', 2]) # => [:foo, "bar", 2] - -With no block and integer argument given, returns a new array containing that -many instances of the given `default_value`: - - Array.new(0) # => [] - Array.new(3) # => [nil, nil, nil] - Array.new(2, 3) # => [3, 3] - -With a block given, returns an array of the given `size`; calls the block with -each `index` in the range `(0...size)`; the element at that `index` in the -returned array is the blocks return value: - - Array.new(3) {|index| "Element #{index}" } # => ["Element 0", "Element 1", "Element 2"] - -A common pitfall for new Rubyists is providing an expression as -`default_value`: - - array = Array.new(2, {}) - array # => [{}, {}] - array[0][:a] = 1 - array # => [{a: 1}, {a: 1}], as array[0] and array[1] are same object - -If you want the elements of the array to be distinct, you should pass a block: - - array = Array.new(2) { {} } - array # => [{}, {}] - array[0][:a] = 1 - array # => [{a: 1}, {}], as array[0] and array[1] are different objects - -Raises TypeError if the first argument is not either an array or an -[integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects)). -Raises ArgumentError if the first argument is a negative integer. - -Related: see [Methods for Creating an -Array](rdoc-ref:Array@Methods+for+Creating+an+Array). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -Replaces the elements of `self` with the elements of `other_array`, which must -be an [array-convertible -object](rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Objects); returns -`self`: - - a = ['a', 'b', 'c'] # => ["a", "b", "c"] - a.replace(['d', 'e']) # => ["d", "e"] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## insert(*args) [](#method-i-insert) -Inserts the given `objects` as elements of `self`; returns `self`. - -When `index` is non-negative, inserts `objects` *before* the element at offset -`index`: - - a = ['a', 'b', 'c'] # => ["a", "b", "c"] - a.insert(1, :x, :y, :z) # => ["a", :x, :y, :z, "b", "c"] - -Extends the array if `index` is beyond the array (`index >= self.size`): - - a = ['a', 'b', 'c'] # => ["a", "b", "c"] - a.insert(5, :x, :y, :z) # => ["a", "b", "c", nil, nil, :x, :y, :z] - -When `index` is negative, inserts `objects` *after* the element at offset -`index + self.size`: - - a = ['a', 'b', 'c'] # => ["a", "b", "c"] - a.insert(-2, :x, :y, :z) # => ["a", "b", :x, :y, :z, "c"] - -With no `objects` given, does nothing: - - a = ['a', 'b', 'c'] # => ["a", "b", "c"] - a.insert(1) # => ["a", "b", "c"] - a.insert(50) # => ["a", "b", "c"] - a.insert(-50) # => ["a", "b", "c"] - -Raises IndexError if `objects` are given and `index` is negative and out of -range. - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns the new string formed by calling method `#inspect` on each array -element: - - a = [:foo, 'bar', 2] - a.inspect # => "[:foo, \"bar\", 2]" - -Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -**@overload** [] - -## intersect?(ary2) [](#method-i-intersect?) -Returns whether `other_array` has at least one element that is `#eql?` to some -element of `self`: - - [1, 2, 3].intersect?([3, 4, 5]) # => true - [1, 2, 3].intersect?([4, 5, 6]) # => false - -Each element must correctly implement method `#hash`. - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -## intersection(*args) [](#method-i-intersection) -Returns a new array containing each element in `self` that is `#eql?` to at -least one element in each of the given `other_arrays`; duplicates are omitted: - - [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1] - -Each element must correctly implement method `#hash`. - -Order from `self` is preserved: - - [0, 1, 2].intersection([2, 1, 0]) # => [0, 1, 2] - -Returns a copy of `self` if no arguments are given. - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -## iter_test1() [](#method-i-iter_test1) - -## iter_test2() [](#method-i-iter_test2) - -## join(*args) [](#method-i-join) -Returns the new string formed by joining the converted elements of `self`; for -each element `element`: - -* Converts recursively using `element.join(separator)` if `element` is a - `kind_of?(Array)`. -* Otherwise, converts using `element.to_s`. - -With no argument given, joins using the output field separator, `$,`: - - a = [:foo, 'bar', 2] - $, # => nil - a.join # => "foobar2" - -With string argument `separator` given, joins using that separator: - - a = [:foo, 'bar', 2] - a.join("\n") # => "foo\nbar\n2" - -Joins recursively for nested arrays: - - a = [:foo, [:bar, [:baz, :bat]]] - a.join # => "foobarbazbat" - -Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -## keep_if() [](#method-i-keep_if) -With a block given, calls the block with each element of `self`; removes the -element from `self` if the block does not return a truthy value: - - a = [:foo, 'bar', 2, :bam] - a.keep_if {|element| element.to_s.start_with?('b') } # => ["bar", :bam] - -With no block given, returns a new Enumerator. - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -## last(nunspecified = true) [](#method-i-last) -call-seq: - last -> last_object or nil - last(count) -> new_array - -Returns elements from `self`, or `nil`; `self` is not modified. - -With no argument given, returns the last element, or `nil` if `self` is empty: - - a = [:foo, 'bar', 2] - a.last # => 2 - a # => [:foo, "bar", 2] - [].last # => nil - -With non-negative integer argument `count` given, returns a new array -containing the trailing `count` elements of `self`, as available: - - a = [:foo, 'bar', 2] - a.last(2) # => ["bar", 2] - a.last(50) # => [:foo, "bar", 2] - a.last(0) # => [] - [].last(3) # => [] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## length() [](#method-i-length) -Returns the count of elements in `self`: - - [0, 1, 2].length # => 3 - [].length # => 0 - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -## map() [](#method-i-map) -With a block given, calls the block with each element of `self`; returns a new -array whose elements are the return values from the block: - - a = [:foo, 'bar', 2] - a1 = a.map {|element| element.class } - a1 # => [Symbol, String, Integer] - -With no block given, returns a new Enumerator. - -Related: #collect!; see also [Methods for -Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## map!() [](#method-i-map!) -With a block given, calls the block with each element of `self` and replaces -the element with the block's return value; returns `self`: - - a = [:foo, 'bar', 2] - a.map! { |element| element.class } # => [Symbol, String, Integer] - -With no block given, returns a new Enumerator. - -Related: #collect; see also [Methods for -Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns one of the following: - -* The maximum-valued element from `self`. -* A new array of maximum-valued elements from `self`. - -Does not modify `self`. - -With no block given, each element in `self` must respond to method `#<=>` with -a numeric. - -With no argument and no block, returns the element in `self` having the -maximum value per method `#<=>`: - - [1, 0, 3, 2].max # => 3 - -With non-negative numeric argument `count` and no block, returns a new array -with at most `count` elements, in descending order, per method `#<=>`: - - [1, 0, 3, 2].max(3) # => [3, 2, 1] - [1, 0, 3, 2].max(3.0) # => [3, 2, 1] - [1, 0, 3, 2].max(9) # => [3, 2, 1, 0] - [1, 0, 3, 2].max(0) # => [] - -With a block given, the block must return a numeric. - -With a block and no argument, calls the block `self.size - 1` times to compare -elements; returns the element having the maximum value per the block: - - ['0', '', '000', '00'].max {|a, b| a.size <=> b.size } - # => "000" - -With non-negative numeric argument `count` and a block, returns a new array -with at most `count` elements, in descending order, per the block: - - ['0', '', '000', '00'].max(2) {|a, b| a.size <=> b.size } - # => ["000", "00"] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns one of the following: - -* The minimum-valued element from `self`. -* A new array of minimum-valued elements from `self`. - -Does not modify `self`. - -With no block given, each element in `self` must respond to method `#<=>` with -a numeric. - -With no argument and no block, returns the element in `self` having the -minimum value per method `#<=>`: - - [1, 0, 3, 2].min # => 0 - -With non-negative numeric argument `count` and no block, returns a new array -with at most `count` elements, in ascending order, per method `#<=>`: - - [1, 0, 3, 2].min(3) # => [0, 1, 2] - [1, 0, 3, 2].min(3.0) # => [0, 1, 2] - [1, 0, 3, 2].min(9) # => [0, 1, 2, 3] - [1, 0, 3, 2].min(0) # => [] - -With a block given, the block must return a numeric. - -With a block and no argument, calls the block `self.size - 1` times to compare -elements; returns the element having the minimum value per the block: - - ['0', '', '000', '00'].min {|a, b| a.size <=> b.size } - # => "" - -With non-negative numeric argument `count` and a block, returns a new array -with at most `count` elements, in ascending order, per the block: - - ['0', '', '000', '00'].min(2) {|a, b| a.size <=> b.size } - # => ["", "0"] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum-valued and maximum-valued -elements from `self`; does not modify `self`. - -With no block given, the minimum and maximum values are determined using -method `#<=>`: - - [1, 0, 3, 2].minmax # => [0, 3] - -With a block given, the block must return a numeric; the block is called -`self.size - 1` times to compare elements; returns the elements having the -minimum and maximum values per the block: - - ['0', '', '000', '00'].minmax {|a, b| a.size <=> b.size } - # => ["", "000"] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns `true` if no element of `self` meets a given criterion, `false` -otherwise. - -With no block given and no argument, returns `true` if `self` has no truthy -elements, `false` otherwise: - - [nil, false].none? # => true - [nil, 0, false].none? # => false - [].none? # => true - -With argument `object` given, returns `false` if for any element `element`, -`object === element`; `true` otherwise: - - ['food', 'drink'].none?(/bar/) # => true - ['food', 'drink'].none?(/foo/) # => false - [].none?(/foo/) # => true - [0, 1, 2].none?(3) # => true - [0, 1, 2].none?(1) # => false - -With a block given, calls the block with each element in `self`; returns -`true` if the block returns no truthy value, `false` otherwise: - - [0, 1, 2].none? {|element| element > 3 } # => true - [0, 1, 2].none? {|element| element > 1 } # => false - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns `true` if exactly one element of `self` meets a given criterion. - -With no block given and no argument, returns `true` if `self` has exactly one -truthy element, `false` otherwise: - - [nil, 0].one? # => true - [0, 0].one? # => false - [nil, nil].one? # => false - [].one? # => false - -With a block given, calls the block with each element in `self`; returns -`true` if the block a truthy value for exactly one element, `false` otherwise: - - [0, 1, 2].one? {|element| element > 0 } # => false - [0, 1, 2].one? {|element| element > 1 } # => true - [0, 1, 2].one? {|element| element > 2 } # => false - -With argument `object` given, returns `true` if for exactly one element -`element`, `object === element`; `false` otherwise: - - [0, 1, 2].one?(0) # => true - [0, 0, 1].one?(0) # => false - [1, 1, 2].one?(0) # => false - ['food', 'drink'].one?(/bar/) # => false - ['food', 'drink'].one?(/foo/) # => true - [].one?(/foo/) # => false - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## pack(fmt, buffer:nil) [](#method-i-pack) -call-seq: - pack(template, buffer: nil) -> string - - Formats each element in +self+ into a binary string; returns that string. - See {Packed Data}[rdoc-ref:packed_data.rdoc]. - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## permutation(*args) [](#method-i-permutation) -Iterates over permutations of the elements of `self`; the order of -permutations is indeterminate. - -With a block and an in-range positive integer argument `count` (`0 < count <= -self.size`) given, calls the block with each permutation of `self` of size -`count`; returns `self`: - - a = [0, 1, 2] - perms = [] - a.permutation(1) {|perm| perms.push(perm) } - perms # => [[0], [1], [2]] - - perms = [] - a.permutation(2) {|perm| perms.push(perm) } - perms # => [[0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1]] - - perms = [] - a.permutation(3) {|perm| perms.push(perm) } - perms # => [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]] - -When `count` is zero, calls the block once with a new empty array: - - perms = [] - a.permutation(0) {|perm| perms.push(perm) } - perms # => [[]] - -When `count` is out of range (negative or larger than `self.size`), does not -call the block: - - a.permutation(-1) {|permutation| fail 'Cannot happen' } - a.permutation(4) {|permutation| fail 'Cannot happen' } - -With no block given, returns a new Enumerator. - -Related: [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating). - -**@overload** [] - -**@overload** [] - -## pop(*args) [](#method-i-pop) -Removes and returns trailing elements of `self`. - -With no argument given, removes and returns the last element, if available; -otherwise returns `nil`: - - a = [:foo, 'bar', 2] - a.pop # => 2 - a # => [:foo, "bar"] - [].pop # => nil - -With non-negative integer argument `count` given, returns a new array -containing the trailing `count` elements of `self`, as available: - - a = [:foo, 'bar', 2] - a.pop(2) # => ["bar", 2] - a # => [:foo] - - a = [:foo, 'bar', 2] - a.pop(50) # => [:foo, "bar", 2] - a # => [] - -Related: Array#push; see also [Methods for -Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## pretty_print_cycle(q) [](#method-i-pretty_print_cycle) -:nodoc: - -## product(*args) [](#method-i-product) -Computes all combinations of elements from all the arrays, including both -`self` and `other_arrays`: - -* The number of combinations is the product of the sizes of all the arrays, - including both `self` and `other_arrays`. -* The order of the returned combinations is indeterminate. - -With no block given, returns the combinations as an array of arrays: - - p = [0, 1].product([2, 3]) - # => [[0, 2], [0, 3], [1, 2], [1, 3]] - p.size # => 4 - p = [0, 1].product([2, 3], [4, 5]) - # => [[0, 2, 4], [0, 2, 5], [0, 3, 4], [0, 3, 5], [1, 2, 4], [1, 2, 5], [1, 3, 4], [1, 3,... - p.size # => 8 - -If `self` or any argument is empty, returns an empty array: - - [].product([2, 3], [4, 5]) # => [] - [0, 1].product([2, 3], []) # => [] - -If no argument is given, returns an array of 1-element arrays, each containing -an element of `self`: - - a.product # => [[0], [1], [2]] - -With a block given, calls the block with each combination; returns `self`: - - p = [] - [0, 1].product([2, 3]) {|combination| p.push(combination) } - p # => [[0, 2], [0, 3], [1, 2], [1, 3]] - -If `self` or any argument is empty, does not call the block: - - [].product([2, 3], [4, 5]) {|combination| fail 'Cannot happen' } - # => [] - [0, 1].product([2, 3], []) {|combination| fail 'Cannot happen' } - # => [0, 1] - -If no argument is given, calls the block with each element of `self` as a -1-element array: - - p = [] - [0, 1].product {|combination| p.push(combination) } - p # => [[0], [1]] - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -**@overload** [] - -## push(*args) [](#method-i-push) -Appends each argument in `objects` to `self`; returns `self`: - - a = [:foo, 'bar', 2] # => [:foo, "bar", 2] - a.push(:baz, :bat) # => [:foo, "bar", 2, :baz, :bat] - -Appends each argument as a single element, even if it is another array: - - a = [:foo, 'bar', 2] # => [:foo, "bar", 2] - a.push([:baz, :bat], [:bam, :bad]) # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -**@overload** [] - -## quote() [](#method-i-quote) -Wraps all strings in escaped quotes if they contain whitespace. - -## rassoc(value) [](#method-i-rassoc) -Returns the first element `ele` in `self` such that `ele` is an array and -`ele[1] == object`: - - a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] - a.rassoc(4) # => [2, 4] - a.rassoc(5) # => [4, 5, 6] - -Returns `nil` if no such element is found. - -Related: Array#assoc; see also [Methods for -Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -With a block given, returns a new array whose elements are all those from -`self` for which the block returns `false` or `nil`: - - a = [:foo, 'bar', 2, 'bat'] - a1 = a.reject {|element| element.to_s.start_with?('b') } - a1 # => [:foo, 2] - -With no block given, returns a new Enumerator. - -Related: [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -## reject!() [](#method-i-reject!) -With a block given, calls the block with each element of `self`; removes each -element for which the block returns a truthy value. - -Returns `self` if any elements removed: - - a = [:foo, 'bar', 2, 'bat'] - a.reject! {|element| element.to_s.start_with?('b') } # => [:foo, 2] - -Returns `nil` if no elements removed. - -With no block given, returns a new Enumerator. - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -## repeated_combination(num) [](#method-i-repeated_combination) -With a block given, calls the block with each repeated combination of length -`size` of the elements of `self`; each combination is an array; returns -`self`. The order of the combinations is indeterminate. - -If a positive integer argument `size` is given, calls the block with each -`size`-tuple repeated combination of the elements of `self`. The number of -combinations is `(size+1)(size+2)/2`. - -Examples: - -* `size` is 1: - - c = [] - [0, 1, 2].repeated_combination(1) {|combination| c.push(combination) } - c # => [[0], [1], [2]] - -* `size` is 2: - - c = [] - [0, 1, 2].repeated_combination(2) {|combination| c.push(combination) } - c # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]] - -If `size` is zero, calls the block once with an empty array. - -If `size` is negative, does not call the block: - - [0, 1, 2].repeated_combination(-1) {|combination| fail 'Cannot happen' } - -With no block given, returns a new Enumerator. - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -**@overload** [] - -## repeated_permutation(num) [](#method-i-repeated_permutation) -With a block given, calls the block with each repeated permutation of length -`size` of the elements of `self`; each permutation is an array; returns -`self`. The order of the permutations is indeterminate. - -If a positive integer argument `size` is given, calls the block with each -`size`-tuple repeated permutation of the elements of `self`. The number of -permutations is `self.size**size`. - -Examples: - -* `size` is 1: - - p = [] - [0, 1, 2].repeated_permutation(1) {|permutation| p.push(permutation) } - p # => [[0], [1], [2]] - -* `size` is 2: - - p = [] - [0, 1, 2].repeated_permutation(2) {|permutation| p.push(permutation) } - p # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]] - -If `size` is zero, calls the block once with an empty array. - -If `size` is negative, does not call the block: - - [0, 1, 2].repeated_permutation(-1) {|permutation| fail 'Cannot happen' } - -With no block given, returns a new Enumerator. - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -**@overload** [] - -## replace(orig) [](#method-i-replace) -Replaces the elements of `self` with the elements of `other_array`, which must -be an [array-convertible -object](rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Objects); returns -`self`: - - a = ['a', 'b', 'c'] # => ["a", "b", "c"] - a.replace(['d', 'e']) # => ["d", "e"] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -**@overload** [] - -## reverse() [](#method-i-reverse) -Returns a new array containing the elements of `self` in reverse order: - - [0, 1, 2].reverse # => [2, 1, 0] - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -## reverse!() [](#method-i-reverse!) -Reverses the order of the elements of `self`; returns `self`: - - a = [0, 1, 2] - a.reverse! # => [2, 1, 0] - a # => [2, 1, 0] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -## reverse_each() [](#method-i-reverse_each) -When a block given, iterates backwards over the elements of `self`, passing, -in reverse order, each element to the block; returns `self`: - - a = [] - [0, 1, 2].reverse_each {|element| a.push(element) } - a # => [2, 1, 0] - -Allows the array to be modified during iteration: - - a = ['a', 'b', 'c'] - a.reverse_each {|element| a.clear if element.start_with?('b') } - a # => [] - -When no block given, returns a new Enumerator. - -Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating). - -**@overload** [] - -**@overload** [] - -## rindex(*args) [](#method-i-rindex) -Returns the index of the last element for which `object == element`. - -With argument `object` given, returns the index of the last such element -found: - - a = [:foo, 'bar', 2, 'bar'] - a.rindex('bar') # => 3 - -Returns `nil` if no such object found. - -With a block given, calls the block with each successive element; returns the -index of the last element for which the block returns a truthy value: - - a = [:foo, 'bar', 2, 'bar'] - a.rindex {|element| element == 'bar' } # => 3 - -Returns `nil` if the block never returns a truthy value. - -When neither an argument nor a block is given, returns a new Enumerator. - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## rotate(*args) [](#method-i-rotate) -Returns a new array formed from `self` with elements rotated from one end to -the other. - -With non-negative numeric `count`, rotates elements from the beginning to the -end: - - [0, 1, 2, 3].rotate(2) # => [2, 3, 0, 1] - [0, 1, 2, 3].rotate(2.1) # => [2, 3, 0, 1] - -If `count` is large, uses `count % array.size` as the count: - - [0, 1, 2, 3].rotate(22) # => [2, 3, 0, 1] - -With a `count` of zero, rotates no elements: - - [0, 1, 2, 3].rotate(0) # => [0, 1, 2, 3] - -With negative numeric `count`, rotates in the opposite direction, from the end -to the beginning: - - [0, 1, 2, 3].rotate(-1) # => [3, 0, 1, 2] - -If `count` is small (far from zero), uses `count % array.size` as the count: - - [0, 1, 2, 3].rotate(-21) # => [3, 0, 1, 2] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -## rotate!(*args) [](#method-i-rotate!) -Rotates `self` in place by moving elements from one end to the other; returns -`self`. - -With non-negative numeric `count`, rotates `count` elements from the beginning -to the end: - - [0, 1, 2, 3].rotate!(2) # => [2, 3, 0, 1] - [0, 1, 2, 3].rotate!(2.1) # => [2, 3, 0, 1] - -If `count` is large, uses `count % array.size` as the count: - - [0, 1, 2, 3].rotate!(21) # => [1, 2, 3, 0] - -If `count` is zero, rotates no elements: - - [0, 1, 2, 3].rotate!(0) # => [0, 1, 2, 3] - -With a negative numeric `count`, rotates in the opposite direction, from end -to beginning: - - [0, 1, 2, 3].rotate!(-1) # => [3, 0, 1, 2] - -If `count` is small (far from zero), uses `count % array.size` as the count: - - [0, 1, 2, 3].rotate!(-21) # => [3, 0, 1, 2] - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -## sample(n(ary = false), random:Random) [](#method-i-sample) -call-seq: - sample(random: Random) -> object - sample(count, random: Random) -> new_ary - -Returns random elements from `self`, as selected by the object given by the -keyword argument `random`. - -With no argument `count` given, returns one random element from `self`: - - a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - a.sample # => 3 - a.sample # => 8 - -Returns `nil` if `self` is empty: - - [].sample # => nil - -With a non-negative numeric argument `count` given, returns a new array -containing `count` random elements from `self`: - - a.sample(3) # => [8, 9, 2] - a.sample(6) # => [9, 6, 0, 3, 1, 4] - -The order of the result array is unrelated to the order of `self`. - -Returns a new empty `Array` if `self` is empty: - - [].sample(4) # => [] - -May return duplicates in `self`: - - a = [1, 1, 1, 2, 2, 3] - a.sample(a.size) # => [1, 1, 3, 2, 1, 2] - -Returns no more than `a.size` elements (because no new duplicates are -introduced): - - a.sample(50) # => [6, 4, 1, 8, 5, 9, 0, 2, 3, 7] - -The object given with the keyword argument `random` is used as the random -number generator: - - a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - a.sample(random: Random.new(1)) # => 6 - a.sample(4, random: Random.new(1)) # => [6, 10, 9, 2] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -## select() [](#method-i-select) -With a block given, calls the block with each element of `self`; returns a new -array containing those elements of `self` for which the block returns a truthy -value: - - a = [:foo, 'bar', 2, :bam] - a.select {|element| element.to_s.start_with?('b') } - # => ["bar", :bam] - -With no block given, returns a new Enumerator. - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## select!() [](#method-i-select!) -With a block given, calls the block with each element of `self`; removes from -`self` those elements for which the block returns `false` or `nil`. - -Returns `self` if any elements were removed: - - a = [:foo, 'bar', 2, :bam] - a.select! {|element| element.to_s.start_with?('b') } # => ["bar", :bam] - -Returns `nil` if no elements were removed. - -With no block given, returns a new Enumerator. - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## shelljoin() [](#method-i-shelljoin) -call-seq: - array.shelljoin => string - -Builds a command line string from an argument list `array` joining all -elements escaped for the Bourne shell and separated by a space. - -See Shellwords.shelljoin for details. - -## shift(*args) [](#method-i-shift) -Removes and returns leading elements from `self`. - -With no argument, removes and returns one element, if available, or `nil` -otherwise: - - a = [0, 1, 2, 3] - a.shift # => 0 - a # => [1, 2, 3] - [].shift # => nil - -With non-negative numeric argument `count` given, removes and returns the -first `count` elements: - - a = [0, 1, 2, 3] - a.shift(2) # => [0, 1] - a # => [2, 3] - a.shift(1.1) # => [2] - a # => [3] - a.shift(0) # => [] - a # => [3] - -If `count` is large, removes and returns all elements: - - a = [0, 1, 2, 3] - a.shift(50) # => [0, 1, 2, 3] - a # => [] - -If `self` is empty, returns a new empty array. - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -## shuffle(random:Random) [](#method-i-shuffle) -call-seq: - shuffle(random: Random) -> new_array - -Returns a new array containing all elements from `self` in a random order, as -selected by the object given by the keyword argument `random`: - - a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - a.shuffle # => [0, 8, 1, 9, 6, 3, 4, 7, 2, 5] - a.shuffle # => [8, 9, 0, 5, 1, 2, 6, 4, 7, 3] - -Duplicate elements are included: - - a = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1] - a.shuffle # => [1, 0, 1, 1, 0, 0, 1, 0, 0, 1] - a.shuffle # => [1, 1, 0, 0, 0, 1, 1, 0, 0, 1] - -The object given with the keyword argument `random` is used as the random -number generator. - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -## shuffle!(random:Random) [](#method-i-shuffle!) -call-seq: - shuffle!(random: Random) -> self - -Shuffles all elements in `self` into a random order, as selected by the object -given by the keyword argument `random`. Returns `self`: - - a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - a.shuffle! # => [5, 3, 8, 7, 6, 1, 9, 4, 2, 0] - a.shuffle! # => [9, 4, 0, 6, 2, 8, 1, 5, 3, 7] - -Duplicate elements are included: - - a = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1] - a.shuffle! # => [1, 0, 0, 1, 1, 0, 1, 0, 0, 1] - a.shuffle! # => [0, 1, 0, 1, 1, 0, 1, 0, 1, 0] - -The object given with the keyword argument `random` is used as the random -number generator. - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -## size() [](#method-i-size) -Returns the count of elements in `self`: - - [0, 1, 2].length # => 3 - [].length # => 0 - -Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). - -**@overload** [] - -**@overload** [] - -## slice(*args) [](#method-i-slice) -Returns elements from `self`; does not modify `self`. - -In brief: - - a = [:foo, 'bar', 2] - - # Single argument index: returns one element. - a[0] # => :foo # Zero-based index. - a[-1] # => 2 # Negative index counts backwards from end. - - # Arguments start and length: returns an array. - a[1, 2] # => ["bar", 2] - a[-2, 2] # => ["bar", 2] # Negative start counts backwards from end. - - # Single argument range: returns an array. - a[0..1] # => [:foo, "bar"] - a[0..-2] # => [:foo, "bar"] # Negative range-begin counts backwards from end. - a[-2..2] # => ["bar", 2] # Negative range-end counts backwards from end. - -When a single integer argument `index` is given, returns the element at offset -`index`: - - a = [:foo, 'bar', 2] - a[0] # => :foo - a[2] # => 2 - a # => [:foo, "bar", 2] - -If `index` is negative, counts backwards from the end of `self`: - - a = [:foo, 'bar', 2] - a[-1] # => 2 - a[-2] # => "bar" - -If `index` is out of range, returns `nil`. - -When two Integer arguments `start` and `length` are given, returns a new -`Array` of size `length` containing successive elements beginning at offset -`start`: - - a = [:foo, 'bar', 2] - a[0, 2] # => [:foo, "bar"] - a[1, 2] # => ["bar", 2] - -If `start + length` is greater than `self.length`, returns all elements from -offset `start` to the end: - - a = [:foo, 'bar', 2] - a[0, 4] # => [:foo, "bar", 2] - a[1, 3] # => ["bar", 2] - a[2, 2] # => [2] - -If `start == self.size` and `length >= 0`, returns a new empty `Array`. - -If `length` is negative, returns `nil`. - -When a single Range argument `range` is given, treats `range.min` as `start` -above and `range.size` as `length` above: - - a = [:foo, 'bar', 2] - a[0..1] # => [:foo, "bar"] - a[1..2] # => ["bar", 2] - -Special case: If `range.start == a.size`, returns a new empty `Array`. - -If `range.end` is negative, calculates the end index from the end: - - a = [:foo, 'bar', 2] - a[0..-1] # => [:foo, "bar", 2] - a[0..-2] # => [:foo, "bar"] - a[0..-3] # => [:foo] - -If `range.start` is negative, calculates the start index from the end: - - a = [:foo, 'bar', 2] - a[-1..2] # => [2] - a[-2..2] # => ["bar", 2] - a[-3..2] # => [:foo, "bar", 2] - -If `range.start` is larger than the array size, returns `nil`. - - a = [:foo, 'bar', 2] - a[4..1] # => nil - a[4..0] # => nil - a[4..-1] # => nil - -When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns -an `Array` of elements corresponding to the indexes produced by the sequence. - - a = ['--', 'data1', '--', 'data2', '--', 'data3'] - a[(1..).step(2)] # => ["data1", "data2", "data3"] - -Unlike slicing with range, if the start or the end of the arithmetic sequence -is larger than array size, throws RangeError. - - a = ['--', 'data1', '--', 'data2', '--', 'data3'] - a[(1..11).step(2)] - # RangeError (((1..11).step(2)) out of range) - a[(7..).step(2)] - # RangeError (((7..).step(2)) out of range) - -If given a single argument, and its type is not one of the listed, tries to -convert it to Integer, and raises if it is impossible: - - a = [:foo, 'bar', 2] - # Raises TypeError (no implicit conversion of Symbol into Integer): - a[:foo] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## slice!(*args) [](#method-i-slice!) -Removes and returns elements from `self`. - -With numeric argument `index` given, removes and returns the element at offset -`index`: - - a = ['a', 'b', 'c', 'd'] - a.slice!(2) # => "c" - a # => ["a", "b", "d"] - a.slice!(2.1) # => "d" - a # => ["a", "b"] - -If `index` is negative, counts backwards from the end of `self`: - - a = ['a', 'b', 'c', 'd'] - a.slice!(-2) # => "c" - a # => ["a", "b", "d"] - -If `index` is out of range, returns `nil`. - -With numeric arguments `start` and `length` given, removes `length` elements -from `self` beginning at zero-based offset `start`; returns the removed -objects in a new array: - - a = ['a', 'b', 'c', 'd'] - a.slice!(1, 2) # => ["b", "c"] - a # => ["a", "d"] - a.slice!(0.1, 1.1) # => ["a"] - a # => ["d"] - -If `start` is negative, counts backwards from the end of `self`: - - a = ['a', 'b', 'c', 'd'] - a.slice!(-2, 1) # => ["c"] - a # => ["a", "b", "d"] - -If `start` is out-of-range, returns `nil`: - - a = ['a', 'b', 'c', 'd'] - a.slice!(5, 1) # => nil - a.slice!(-5, 1) # => nil - -If `start + length` exceeds the array size, removes and returns all elements -from offset `start` to the end: - - a = ['a', 'b', 'c', 'd'] - a.slice!(2, 50) # => ["c", "d"] - a # => ["a", "b"] - -If `start == a.size` and `length` is non-negative, returns a new empty array. - -If `length` is negative, returns `nil`. - -With Range argument `range` given, treats `range.min` as `start` (as above) -and `range.size` as `length` (as above): - - a = ['a', 'b', 'c', 'd'] - a.slice!(1..2) # => ["b", "c"] - a # => ["a", "d"] - -If `range.start == a.size`, returns a new empty array: - - a = ['a', 'b', 'c', 'd'] - a.slice!(4..5) # => [] - -If `range.start` is larger than the array size, returns `nil`: - - a = ['a', 'b', 'c', 'd'] - a.slice!(5..6) # => nil - -If `range.start` is negative, calculates the start index by counting backwards -from the end of `self`: - - a = ['a', 'b', 'c', 'd'] - a.slice!(-2..2) # => ["c"] - -If `range.end` is negative, calculates the end index by counting backwards -from the end of `self`: - - a = ['a', 'b', 'c', 'd'] - a.slice!(0..-2) # => ["a", "b", "c"] - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns a new array containing the elements of `self`, sorted. - -With no block given, compares elements using operator `#<=>` (see Object#<=>): - - [0, 2, 3, 1].sort # => [0, 1, 2, 3] - -With a block given, calls the block with each combination of pairs of elements -from `self`; for each pair `a` and `b`, the block should return a numeric: - -* Negative when `b` is to follow `a`. -* Zero when `a` and `b` are equivalent. -* Positive when `a` is to follow `b`. - -Example: - - a = [3, 2, 0, 1] - a.sort {|a, b| a <=> b } # => [0, 1, 2, 3] - a.sort {|a, b| b <=> a } # => [3, 2, 1, 0] - -When the block returns zero, the order for `a` and `b` is indeterminate, and -may be unstable. - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -## sort!() [](#method-i-sort!) -Like Array#sort, but returns `self` with its elements sorted in place. - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sort_by!() [](#method-i-sort_by!) -With a block given, sorts the elements of `self` in place; returns self. - -Calls the block with each successive element; sorts elements based on the -values returned from the block: - - a = ['aaaa', 'bbb', 'cc', 'd'] - a.sort_by! {|element| element.size } - a # => ["d", "cc", "bbb", "aaaa"] - -For duplicate values returned by the block, the ordering is indeterminate, and -may be unstable. - -With no block given, returns a new Enumerator. - -Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `init` and all elements of `self`; - for array +array+ and value +init+, equivalent to: - - sum = init - array.each {|element| sum += element } - sum - - For example, [e0, e1, e2].sum returns init + e0 + e1 + e2. - - Examples: - - [0, 1, 2, 3].sum # => 6 - [0, 1, 2, 3].sum(100) # => 106 - ['abc', 'def', 'ghi'].sum('jkl') # => "jklabcdefghi" - [[:foo, :bar], ['foo', 'bar']].sum([2, 3]) - # => [2, 3, :foo, :bar, "foo", "bar"] - - The +init+ value and elements need not be numeric, but must all be +-compatible: - - # Raises TypeError: Array can't be coerced into Integer. - [[:foo, :bar], ['foo', 'bar']].sum(2) - - With a block given, calls the block with each element of +self+; - the block's return value (instead of the element itself) is used as the addend: - - ['zero', 1, :two].sum('Coerced and concatenated: ') {|element| element.to_s } - # => "Coerced and concatenated: zero1two" - - Notes: - - - Array#join and Array#flatten may be faster than Array#sum - for an array of strings or an array of arrays. - - Array#sum method may not respect method redefinition of "+" methods such as Integer#+. - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -Returns a new array containing the first `count` element of `self` (as -available); `count` must be a non-negative numeric; does not modify `self`: - - a = ['a', 'b', 'c', 'd'] - a.take(2) # => ["a", "b"] - a.take(2.1) # => ["a", "b"] - a.take(50) # => ["a", "b", "c", "d"] - a.take(0) # => [] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -## take_while() [](#method-i-take_while) -With a block given, calls the block with each successive element of `self`; -stops iterating if the block returns `false` or `nil`; returns a new array -containing those elements for which the block returned a truthy value: - - a = [0, 1, 2, 3, 4, 5] - a.take_while {|element| element < 3 } # => [0, 1, 2] - a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5] - a.take_while {|element| false } # => [] - -With no block given, returns a new Enumerator. - -Does not modify `self`. - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) -When `self` is an instance of `Array`, returns `self`. - -Otherwise, returns a new array containing the elements of `self`: - - class MyArray < Array; end - my_a = MyArray.new(['foo', 'bar', 'two']) - a = my_a.to_a - a # => ["foo", "bar", "two"] - a.class # => Array # Not MyArray. - -Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -## to_ary() [](#method-i-to_ary) -Returns `self`. - -**@overload** [] - -## to_h() [](#method-i-to_h) -Returns a new hash formed from `self`. - -With no block given, each element of `self` must be a 2-element sub-array; -forms each sub-array into a key-value pair in the new hash: - - a = [['foo', 'zero'], ['bar', 'one'], ['baz', 'two']] - a.to_h # => {"foo"=>"zero", "bar"=>"one", "baz"=>"two"} - [].to_h # => {} - -With a block given, the block must return a 2-element array; calls the block -with each element of `self`; forms each returned array into a key-value pair -in the returned hash: - - a = ['foo', :bar, 1, [2, 3], {baz: 4}] - a.to_h {|element| [element, element.class] } - # => {"foo"=>String, :bar=>Symbol, 1=>Integer, [2, 3]=>Array, {:baz=>4}=>Hash} - -Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## transpose() [](#method-i-transpose) -Returns a new array that is `self` as a [transposed -matrix](https://en.wikipedia.org/wiki/Transpose): - - a = [[:a0, :a1], [:b0, :b1], [:c0, :c1]] - a.transpose # => [[:a0, :b0, :c0], [:a1, :b1, :c1]] - -The elements of `self` must all be the same size. - -Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -## union(*args) [](#method-i-union) -Returns a new array that is the union of the elements of `self` and all given -arrays `other_arrays`; items are compared using `eql?`: - - [0, 1, 2, 3].union([4, 5], [6, 7]) # => [0, 1, 2, 3, 4, 5, 6, 7] - -Removes duplicates (preserving the first found): - - [0, 1, 1].union([2, 1], [3, 1]) # => [0, 1, 2, 3] - -Preserves order (preserving the position of the first found): - - [3, 2, 1, 0].union([5, 3], [4, 2]) # => [3, 2, 1, 0, 5, 4] - -With no arguments given, returns a copy of `self`. - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - -## uniq() [](#method-i-uniq) -Returns a new array containing those elements from `self` that are not -duplicates, the first occurrence always being retained. - -With no block given, identifies and omits duplicate elements using method -`eql?` to compare elements: - - a = [0, 0, 1, 1, 2, 2] - a.uniq # => [0, 1, 2] - -With a block given, calls the block for each element; identifies and omits -"duplicate" elements using method `eql?` to compare *block return values*; -that is, an element is a duplicate if its block return value is the same as -that of a previous element: - - a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] - a.uniq {|element| element.size } # => ["a", "aa", "aaa"] - -Related: [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -**@overload** [] - -## uniq!() [](#method-i-uniq!) -Removes duplicate elements from `self`, the first occurrence always being -retained; returns `self` if any elements removed, `nil` otherwise. - -With no block given, identifies and removes elements using method `eql?` to -compare elements: - - a = [0, 0, 1, 1, 2, 2] - a.uniq! # => [0, 1, 2] - a.uniq! # => nil - -With a block given, calls the block for each element; identifies and omits -"duplicate" elements using method `eql?` to compare *block return values*; -that is, an element is a duplicate if its block return value is the same as -that of a previous element: - - a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] - a.uniq! {|element| element.size } # => ["a", "aa", "aaa"] - a.uniq! {|element| element.size } # => nil - -Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). - -**@overload** [] - -**@overload** [] - -## unshift(*args) [](#method-i-unshift) -Prepends the given `objects` to `self`: - - a = [:foo, 'bar', 2] - a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2] - -Related: Array#shift; see also [Methods for -Assigning](rdoc-ref:Array@Methods+for+Assigning). - -**@overload** [] - -**@overload** [] - -## values_at(*args) [](#method-i-values_at) -Returns elements from `self` in a new array; does not modify `self`. - -The objects included in the returned array are the elements of `self` selected -by the given `specifiers`, each of which must be a numeric index or a Range. - -In brief: - - a = ['a', 'b', 'c', 'd'] - - # Index specifiers. - a.values_at(2, 0, 2, 0) # => ["c", "a", "c", "a"] # May repeat. - a.values_at(-4, -3, -2, -1) # => ["a", "b", "c", "d"] # Counts backwards if negative. - a.values_at(-50, 50) # => [nil, nil] # Outside of self. - - # Range specifiers. - a.values_at(1..3) # => ["b", "c", "d"] # From range.begin to range.end. - a.values_at(1...3) # => ["b", "c"] # End excluded. - a.values_at(3..1) # => [] # No such elements. - - a.values_at(-3..3) # => ["b", "c", "d"] # Negative range.begin counts backwards. - a.values_at(-50..3) # Raises RangeError. - - a.values_at(1..-2) # => ["b", "c"] # Negative range.end counts backwards. - a.values_at(1..-50) # => [] # No such elements. - - # Mixture of specifiers. - a.values_at(2..3, 3, 0..1, 0) # => ["c", "d", "d", "a", "b", "a"] - -With no `specifiers` given, returns a new empty array: - - a = ['a', 'b', 'c', 'd'] - a.values_at # => [] - -For each numeric specifier `index`, includes an element: - -* For each non-negative numeric specifier `index` that is in-range (less - than `self.size`), includes the element at offset `index`: - - a.values_at(0, 2) # => ["a", "c"] - a.values_at(0.1, 2.9) # => ["a", "c"] - -* For each negative numeric `index` that is in-range (greater than or equal - to `- self.size`), counts backwards from the end of `self`: - - a.values_at(-1, -4) # => ["d", "a"] - -The given indexes may be in any order, and may repeat: - - a.values_at(2, 0, 1, 0, 2) # => ["c", "a", "b", "a", "c"] - -For each `index` that is out-of-range, includes `nil`: - - a.values_at(4, -5) # => [nil, nil] - -For each Range specifier `range`, includes elements according to `range.begin` -and `range.end`: - -* If both `range.begin` and `range.end` are non-negative and in-range (less - than `self.size`), includes elements from index `range.begin` through - `range.end - 1` (if `range.exclude_end?`), or through `range.end` - (otherwise): - - a.values_at(1..2) # => ["b", "c"] - a.values_at(1...2) # => ["b"] - -* If `range.begin` is negative and in-range (greater than or equal to `- - self.size`), counts backwards from the end of `self`: - - a.values_at(-2..3) # => ["c", "d"] - -* If `range.begin` is negative and out-of-range, raises an exception: - - a.values_at(-5..3) # Raises RangeError. - -* If `range.end` is positive and out-of-range, extends the returned array - with `nil` elements: - - a.values_at(1..5) # => ["b", "c", "d", nil, nil] - -* If `range.end` is negative and in-range, counts backwards from the end of - `self`: - - a.values_at(1..-2) # => ["b", "c"] - -* If `range.end` is negative and out-of-range, returns an empty array: - - a.values_at(1..-5) # => [] - -The given ranges may be in any order and may repeat: - - a.values_at(2..3, 0..1, 2..3) # => ["c", "d", "a", "b", "c", "d"] - -The given specifiers may be any mixture of indexes and ranges: - - a.values_at(3, 1..2, 0, 2..3) # => ["d", "b", "c", "a", "c", "d"] - -Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching). - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, combines `self` with the collection of `other_arrays`; -returns a new array of sub-arrays: - - [0, 1].zip(['zero', 'one'], [:zero, :one]) - # => [[0, "zero", :zero], [1, "one", :one]] - -Returned: - -* The outer array is of size `self.size`. -* Each sub-array is of size `other_arrays.size + 1`. -* The *nth* sub-array contains (in order): - - * The *nth* element of `self`. - * The *nth* element of each of the other arrays, as available. - -Example: - - a = [0, 1] - zipped = a.zip(['zero', 'one'], [:zero, :one]) - # => [[0, "zero", :zero], [1, "one", :one]] - zipped.size # => 2 # Same size as a. - zipped.first.size # => 3 # Size of other arrays plus 1. - -When the other arrays are all the same size as `self`, the returned sub-arrays -are a rearrangement containing exactly elements of all the arrays (including -`self`), with no omissions or additions: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - pp d - # => - [[:a0, :b0, :c0], - [:a1, :b1, :c1], - [:a2, :b2, :c2], - [:a3, :b3, :c3]] - -When one of the other arrays is smaller than `self`, pads the corresponding -sub-array with `nil` elements: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - pp d - # => - [[:a0, :b0, :c0], - [:a1, :b1, :c1], - [:a2, :b2, nil], - [:a3, nil, nil]] - -When one of the other arrays is larger than `self`, *ignores* its trailing -elements: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - pp d - # => - [[:a0, :b0, :c0], - [:a1, :b1, :c1], - [:a2, :b2, :c2], - [:a3, :b3, :c3]] - -With a block given, calls the block with each of the other arrays; returns -`nil`: - - d = [] - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| d.push(sub_array.reverse) } # => nil - pp d - # => - [[:c0, :b0, :a0], - [:c1, :b1, :a1], - [:c2, :b2, :a2], - [:c3, :b3, :a3]] - -For an **object** in **other_arrays** that is not actually an array, forms the -the "other array" as `object.to_ary`, if defined, or as `object.each.to_a` -otherwise. - -Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting). - -**@overload** [] - -**@overload** [] - -## |(ary2) [](#method-i-|) -Returns the union of `self` and `other_array`; duplicates are removed; order -is preserved; items are compared using `eql?`: - - [0, 1] | [2, 3] # => [0, 1, 2, 3] - [0, 1, 1] | [2, 2, 3] # => [0, 1, 2, 3] - [0, 1, 2] | [3, 2, 1, 0] # => [0, 1, 2, 3] - -Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining). - -**@overload** [] - diff --git a/example/ruby/ArrayCode.md b/example/ruby/ArrayCode.md deleted file mode 100644 index 83c9e9f..0000000 --- a/example/ruby/ArrayCode.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ArrayCode -**Inherits:** Object - - - - - -#Instance Methods -## initialize(type, name) [](#method-i-initialize) - -**@return** [ArrayCode] a new instance of ArrayCode - -## insert_at_last(num, str) [](#method-i-insert_at_last) - -## length() [](#method-i-length) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/ArraySpec.md b/example/ruby/ArraySpec.md deleted file mode 100644 index 307c12e..0000000 --- a/example/ruby/ArraySpec.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ArraySpec - - - - - diff --git a/example/ruby/ArraySpec/SideEffect.md b/example/ruby/ArraySpec/SideEffect.md deleted file mode 100644 index 5425f6a..0000000 --- a/example/ruby/ArraySpec/SideEffect.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: ArraySpec::SideEffect -**Inherits:** Object - - - - -# Attributes -## call_count[RW] [](#attribute-i-call_count) -Returns the value of attribute call_count. - - -#Instance Methods -## array_result(a_number) [](#method-i-array_result) - -## initialize() [](#method-i-initialize) - -**@return** [SideEffect] a new instance of SideEffect - -## result(a_number) [](#method-i-result) - diff --git a/example/ruby/ArraySpec/Splat.md b/example/ruby/ArraySpec/Splat.md deleted file mode 100644 index 5a9c910..0000000 --- a/example/ruby/ArraySpec/Splat.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ArraySpec::Splat -**Inherits:** Object - - - - - -#Instance Methods -## unpack_3args(a, b, c) [](#method-i-unpack_3args) - -## unpack_4args(a, b, c, d) [](#method-i-unpack_4args) - diff --git a/example/ruby/ArraySpecs.md b/example/ruby/ArraySpecs.md deleted file mode 100644 index d263b3c..0000000 --- a/example/ruby/ArraySpecs.md +++ /dev/null @@ -1,23 +0,0 @@ -# Module: ArraySpecs - - - - -# Class Methods -## array_with_7bit_utf8_and_usascii_strings() [](#method-c-array_with_7bit_utf8_and_usascii_strings) -## array_with_usascii_and_7bit_binary_strings() [](#method-c-array_with_usascii_and_7bit_binary_strings) -## array_with_usascii_and_7bit_utf8_strings() [](#method-c-array_with_usascii_and_7bit_utf8_strings) -## array_with_usascii_and_binary_strings() [](#method-c-array_with_usascii_and_binary_strings) -## array_with_usascii_and_utf8_strings() [](#method-c-array_with_usascii_and_utf8_strings) -## array_with_utf8_and_7bit_binary_strings() [](#method-c-array_with_utf8_and_7bit_binary_strings) -## array_with_utf8_and_binary_strings() [](#method-c-array_with_utf8_and_binary_strings) -## array_with_utf8_and_usascii_strings() [](#method-c-array_with_utf8_and_usascii_strings) -## empty_frozen_array() [](#method-c-empty_frozen_array) -## empty_recursive_array() [](#method-c-empty_recursive_array) -## frozen_array() [](#method-c-frozen_array) -## head_recursive_array() [](#method-c-head_recursive_array) -## measure_sample_fairness(size , samples , iters ) [](#method-c-measure_sample_fairness) -## measure_sample_fairness_large_sample_size(size , samples , iters ) [](#method-c-measure_sample_fairness_large_sample_size) -## recursive_array() [](#method-c-recursive_array) -## universal_pack_object() [](#method-c-universal_pack_object) - diff --git a/example/ruby/ArraySpecs/ArrayConvertible.md b/example/ruby/ArraySpecs/ArrayConvertible.md deleted file mode 100644 index fa353e2..0000000 --- a/example/ruby/ArraySpecs/ArrayConvertible.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: ArraySpecs::ArrayConvertible -**Inherits:** Object - - - - -# Attributes -## called[RW] [](#attribute-i-called) -Returns the value of attribute called. - - -#Instance Methods -## initialize(*values, &block) [](#method-i-initialize) - -**@return** [ArrayConvertible] a new instance of ArrayConvertible - -## to_a() [](#method-i-to_a) - -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/ArraySpecs/ArrayMethodMissing.md b/example/ruby/ArraySpecs/ArrayMethodMissing.md deleted file mode 100644 index 2891e5a..0000000 --- a/example/ruby/ArraySpecs/ArrayMethodMissing.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ArraySpecs::ArrayMethodMissing -**Inherits:** Object - - - - - -#Instance Methods -## initialize(*values, &block) [](#method-i-initialize) - -**@return** [ArrayMethodMissing] a new instance of ArrayMethodMissing - -## method_missing(name, *args) [](#method-i-method_missing) - diff --git a/example/ruby/ArraySpecs/AssocKey.md b/example/ruby/ArraySpecs/AssocKey.md deleted file mode 100644 index e2d34e9..0000000 --- a/example/ruby/ArraySpecs/AssocKey.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ArraySpecs::AssocKey -**Inherits:** Object - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - diff --git a/example/ruby/ArraySpecs/ComparableWithInteger.md b/example/ruby/ArraySpecs/ComparableWithInteger.md deleted file mode 100644 index c483ca6..0000000 --- a/example/ruby/ArraySpecs/ComparableWithInteger.md +++ /dev/null @@ -1,99 +0,0 @@ -# Class: ArraySpecs::ComparableWithInteger -**Inherits:** Object - -**Includes:** Comparable - - - - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(fixnum) [](#method-i-<=>) - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## initialize(num) [](#method-i-initialize) - -**@return** [ComparableWithInteger] a new instance of ComparableWithInteger - diff --git a/example/ruby/ArraySpecs/D.md b/example/ruby/ArraySpecs/D.md deleted file mode 100644 index 4d59dc5..0000000 --- a/example/ruby/ArraySpecs/D.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ArraySpecs::D -**Inherits:** Object - - - - - -#Instance Methods -## <=>(obj) [](#method-i-<=>) - diff --git a/example/ruby/ArraySpecs/MockForCompared.md b/example/ruby/ArraySpecs/MockForCompared.md deleted file mode 100644 index 35efd63..0000000 --- a/example/ruby/ArraySpecs/MockForCompared.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ArraySpecs::MockForCompared -**Inherits:** Object - - - - -# Class Methods -## compared?() [](#method-c-compared?) -**@return** [Boolean] - - -#Instance Methods -## <=>(rhs) [](#method-i-<=>) - -## initialize() [](#method-i-initialize) - -**@return** [MockForCompared] a new instance of MockForCompared - diff --git a/example/ruby/ArraySpecs/MyArray.md b/example/ruby/ArraySpecs/MyArray.md deleted file mode 100644 index c573658..0000000 --- a/example/ruby/ArraySpecs/MyArray.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: ArraySpecs::MyArray -**Inherits:** Array - - - - - -#Instance Methods -## initialize(a, b) [](#method-i-initialize) -The #initialize method has a different signature than Array to help catch -places in the specs that do not assert the #initialize is not called when -Array methods make new instances. - -**@return** [MyArray] a new instance of MyArray - diff --git a/example/ruby/ArraySpecs/MyRange.md b/example/ruby/ArraySpecs/MyRange.md deleted file mode 100644 index 700cac7..0000000 --- a/example/ruby/ArraySpecs/MyRange.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ArraySpecs::MyRange -**Inherits:** Range - - - - - diff --git a/example/ruby/ArraySpecs/PrivateToAry.md b/example/ruby/ArraySpecs/PrivateToAry.md deleted file mode 100644 index 6c385a6..0000000 --- a/example/ruby/ArraySpecs/PrivateToAry.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ArraySpecs::PrivateToAry -**Inherits:** Object - - - - - diff --git a/example/ruby/ArraySpecs/Sexp.md b/example/ruby/ArraySpecs/Sexp.md deleted file mode 100644 index 3f2bdd7..0000000 --- a/example/ruby/ArraySpecs/Sexp.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ArraySpecs::Sexp -**Inherits:** Array - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [Sexp] a new instance of Sexp - diff --git a/example/ruby/ArraySpecs/SortSame.md b/example/ruby/ArraySpecs/SortSame.md deleted file mode 100644 index 2f87bb3..0000000 --- a/example/ruby/ArraySpecs/SortSame.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ArraySpecs::SortSame -**Inherits:** Object - - - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - -## ==(other) [](#method-i-==) - diff --git a/example/ruby/ArraySpecs/SubArray.md b/example/ruby/ArraySpecs/SubArray.md deleted file mode 100644 index 78fd890..0000000 --- a/example/ruby/ArraySpecs/SubArray.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ArraySpecs::SubArray -**Inherits:** Array - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [SubArray] a new instance of SubArray - diff --git a/example/ruby/ArraySpecs/ToAryArray.md b/example/ruby/ArraySpecs/ToAryArray.md deleted file mode 100644 index bf29645..0000000 --- a/example/ruby/ArraySpecs/ToAryArray.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ArraySpecs::ToAryArray -**Inherits:** Array - - -TODO: replace specs that use this with #should_not_receive(:to_ary) -expectations on regular objects (e.g. Array instances). - - - -#Instance Methods -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/ArraySpecs/UFOSceptic.md b/example/ruby/ArraySpecs/UFOSceptic.md deleted file mode 100644 index 14fce9c..0000000 --- a/example/ruby/ArraySpecs/UFOSceptic.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ArraySpecs::UFOSceptic -**Inherits:** Object - - - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - diff --git a/example/ruby/ArraySpecs/Uncomparable.md b/example/ruby/ArraySpecs/Uncomparable.md deleted file mode 100644 index 3b577e1..0000000 --- a/example/ruby/ArraySpecs/Uncomparable.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ArraySpecs::Uncomparable -**Inherits:** Object - - - - - -#Instance Methods -## <=>(obj) [](#method-i-<=>) - diff --git a/example/ruby/ArraySub.md b/example/ruby/ArraySub.md deleted file mode 100644 index 931f2d5..0000000 --- a/example/ruby/ArraySub.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ArraySub -**Inherits:** Array - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [ArraySub] a new instance of ArraySub - diff --git a/example/ruby/ArraySubPush.md b/example/ruby/ArraySubPush.md deleted file mode 100644 index 10863ef..0000000 --- a/example/ruby/ArraySubPush.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ArraySubPush -**Inherits:** Array - - - - - -#Instance Methods -## <<(value) [](#method-i-<<) - diff --git a/example/ruby/Artifice.md b/example/ruby/Artifice.md deleted file mode 100644 index be3ce09..0000000 --- a/example/ruby/Artifice.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: Artifice - - -This module was initially borrowed from https://github.com/wycats/artifice - - -# Class Methods -## activate_with(endpoint ) [](#method-c-activate_with) -Activate Artifice with a particular Rack endpoint. - -Calling this method will replace the Gem::Net::HTTP system with a replacement -that routes all requests to the Rack endpoint. -**@param** [#call] A valid Rack endpoint - -## deactivate() [](#method-c-deactivate) -Deactivate the Artifice replacement. -## replace_net_http(value ) [](#method-c-replace_net_http) - diff --git a/example/ruby/Artifice/Net.md b/example/ruby/Artifice/Net.md deleted file mode 100644 index f63d4d5..0000000 --- a/example/ruby/Artifice/Net.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Artifice::Net - - - - - diff --git a/example/ruby/Artifice/Net/HTTP.md b/example/ruby/Artifice/Net/HTTP.md deleted file mode 100644 index 5a6a243..0000000 --- a/example/ruby/Artifice/Net/HTTP.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Artifice::Net::HTTP -**Inherits:** Gem::Net::HTTP - - - - -# Attributes -## endpoint[RW] [](#attribute-c-endpoint) -Returns the value of attribute endpoint. - - -#Instance Methods -## connect() [](#method-i-connect) -We don't need to connect, so blank out this method - -## request(req, bodynil, &block) [](#method-i-request) -Replace the Gem::Net::HTTP request method with a method that converts the -request into a Rack request and dispatches it to the Rack endpoint. - -**@param** [Net::HTTPRequest] A Gem::Net::HTTPRequest -object, or one if its subclasses - -**@param** [optional, String, #read] This should -be sent as "rack.input". If it's a String, it will -be converted to a StringIO. - -**@return** [Net::HTTPResponse] - -**@yield** [Net::HTTPResponse] If a block is provided, -this method will yield the Gem::Net::HTTPResponse to -it after the body is read. - diff --git a/example/ruby/Artifice/Net/RackRequest.md b/example/ruby/Artifice/Net/RackRequest.md deleted file mode 100644 index cbecd40..0000000 --- a/example/ruby/Artifice/Net/RackRequest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Artifice::Net::RackRequest -**Inherits:** Object - -**Includes:** Rack::Test::Methods - - -This is an internal object that can receive Rack requests to the application -using the Rack::Test API - - -# Attributes -## app[RW] [](#attribute-i-app) -Returns the value of attribute app. - - -#Instance Methods -## initialize(app) [](#method-i-initialize) - -**@return** [RackRequest] a new instance of RackRequest - diff --git a/example/ruby/Assertion.md b/example/ruby/Assertion.md deleted file mode 100644 index 3130313..0000000 --- a/example/ruby/Assertion.md +++ /dev/null @@ -1,67 +0,0 @@ -# Class: Assertion -**Inherits:** Struct - -**Includes:** Launchable - - - - -# Class Methods -## add(as ) [](#method-c-add) -## all() [](#method-c-all) -# Attributes -## count[RW] [](#attribute-c-count) -Returns the value of attribute count. - -## errbuf[RW] [](#attribute-c-errbuf) -Returns the value of attribute errbuf. - -## category[RW] [](#attribute-i-category) -Returns the value of attribute category. - -## err[RW] [](#attribute-i-err) -Returns the value of attribute err. - -## id[RW] [](#attribute-i-id) -Returns the value of attribute id. - -## lineno[RW] [](#attribute-i-lineno) -Returns the value of attribute lineno - -**@return** [Object] the current value of lineno - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path - -**@return** [Object] the current value of path - -## proc[RW] [](#attribute-i-proc) -Returns the value of attribute proc - -**@return** [Object] the current value of proc - -## src[RW] [](#attribute-i-src) -Returns the value of attribute src - -**@return** [Object] the current value of src - - -#Instance Methods -## assert_check(message'', opt'', **argh) [](#method-i-assert_check) - -## call() [](#method-i-call) - -## get_result_string(opt'', timeout:BT.timeout, **argh) [](#method-i-get_result_string) - -## initialize(*args) [](#method-i-initialize) - -**@return** [Assertion] a new instance of Assertion - -## make_srcfile(frozen_string_literal:nil) [](#method-i-make_srcfile) - -## show_error(msg, additional_message) [](#method-i-show_error) - -## show_progress(message'') [](#method-i-show_progress) - -## with_stderr() [](#method-i-with_stderr) - diff --git a/example/ruby/AutoIndent.md b/example/ruby/AutoIndent.md deleted file mode 100644 index c2688b3..0000000 --- a/example/ruby/AutoIndent.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: AutoIndent - - - - -# Class Methods -## calculate_indent(lines , line_index , byte_pointer , is_newline ) [](#method-c-calculate_indent) -## nesting_level(lines ) [](#method-c-nesting_level) - diff --git a/example/ruby/AvailableOLE.md b/example/ruby/AvailableOLE.md deleted file mode 100644 index d673387..0000000 --- a/example/ruby/AvailableOLE.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: AvailableOLE - - - - -# Class Methods -## ado_available?() [](#method-c-ado_available?) -**@return** [Boolean] - -## event_param() [](#method-c-event_param) -## msxml_available?() [](#method-c-msxml_available?) -**@return** [Boolean] - -## sysmon_available?() [](#method-c-sysmon_available?) -**@return** [Boolean] - - diff --git a/example/ruby/B.md b/example/ruby/B.md deleted file mode 100644 index 67812a0..0000000 --- a/example/ruby/B.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: B - - - - - diff --git a/example/ruby/Bar.md b/example/ruby/Bar.md deleted file mode 100644 index 2ce5c37..0000000 --- a/example/ruby/Bar.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bar -**Inherits:** Foo - - - - - -#Instance Methods -## initialize(foo) [](#method-i-initialize) - -**@return** [Bar] a new instance of Bar - -## quux() [](#method-i-quux) - diff --git a/example/ruby/BaseFormatter.md b/example/ruby/BaseFormatter.md deleted file mode 100644 index ab9b369..0000000 --- a/example/ruby/BaseFormatter.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: BaseFormatter -**Inherits:** Object - - - - -# Attributes -## exceptions[RW] [](#attribute-i-exceptions) -Returns the value of attribute exceptions. - -## tally[RW] [](#attribute-i-tally) -Returns the value of attribute tally. - -## timer[RW] [](#attribute-i-timer) -Returns the value of attribute timer. - - -#Instance Methods -## abort() [](#method-i-abort) - -## after(statenil) [](#method-i-after) -Callback for the MSpec :after event. - -## before(statenil) [](#method-i-before) -Callback for the MSpec :before event. Resets the `#exception?` and `#failure` -flags. - -## exception(exception) [](#method-i-exception) -Callback for the MSpec :exception event. Stores the `ExceptionState` object to -generate the list of backtraces after all the specs are run. Also updates the -internal `#exception?` and `#failure?` flags. - -## exception?() [](#method-i-exception?) -Returns true if any exception is raised while running an example. This flag is -reset before each example is evaluated. - -**@return** [Boolean] - -## failure?() [](#method-i-failure?) -Returns true if all exceptions during the evaluation of an example are -failures rather than errors. See `ExceptionState#failure`. This flag is reset -before each example is evaluated. - -**@return** [Boolean] - -## finish() [](#method-i-finish) -Callback for the MSpec :finish event. Prints a description and backtrace for -every exception that occurred while evaluating the examples. - -## initialize(outnil) [](#method-i-initialize) - -**@return** [BaseFormatter] a new instance of BaseFormatter - -## print(*args) [](#method-i-print) -A convenience method to allow printing to different outputs. - -## print_exception(exc, count) [](#method-i-print_exception) - -## register() [](#method-i-register) -Creates the `TimerAction` and `TallyAction` instances and registers them. - -## start() [](#method-i-start) -Callback for the MSpec :start event. Calls :after event. Defined here, in the -base class, and used by MultiFormatter. - -## unload() [](#method-i-unload) -Callback for the MSpec :unload event. Calls :after event. Defined here, in the -base class, and used by MultiFormatter. - diff --git a/example/ruby/BasicObject.md b/example/ruby/BasicObject.md deleted file mode 100644 index 534bfdc..0000000 --- a/example/ruby/BasicObject.md +++ /dev/null @@ -1,251 +0,0 @@ -# Class: BasicObject -**Inherits:** Qnil - - -`BasicObject` is the parent class of all classes in Ruby. In particular, -`BasicObject` is the parent class of class Object, which is itself the default -parent class of every Ruby class: - - class Foo; end - Foo.superclass # => Object - Object.superclass # => BasicObject - -`BasicObject` is the only class that has no parent: - - BasicObject.superclass # => nil - -Class `BasicObject` can be used to create an object hierarchy (e.g., class -Delegator) that is independent of Ruby's object hierarchy. Such objects: - -* Do not have namespace "pollution" from the many methods provided in class - Object and its included module Kernel. -* Do not have definitions of common classes, and so references to such - common classes must be fully qualified (`::String`, not `String`). - -A variety of strategies can be used to provide useful portions of the Standard -Library in subclasses of `BasicObject`: - -* The immediate subclass could `include Kernel`, which would define methods - such as `puts`, `exit`, etc. -* A custom Kernel-like module could be created and included. -* Delegation can be used via #method_missing: - - class MyObjectSystem < BasicObject - DELEGATE = [:puts, :p] - - def method_missing(name, *args, &block) - return super unless DELEGATE.include? name - ::Kernel.send(name, *args, &block) - end - - def respond_to_missing?(name, include_private = false) - DELEGATE.include?(name) - end - end - -### What's Here - -These are the methods defined for BasicObject: - -* ::new: Returns a new BasicObject instance. -* #!: Returns the boolean negation of `self`: `true` or `false`. -* #!=: Returns whether `self` and the given object are *not* equal. -* #==: Returns whether `self` and the given object are equivalent. -* #__id__: Returns the integer object identifier for `self`. -* #__send__: Calls the method identified by the given symbol. -* #equal?: Returns whether `self` and the given object are the same object. -* #instance_eval: Evaluates the given string or block in the context of - `self`. -* #instance_exec: Executes the given block in the context of `self`, passing - the given arguments. -* #method_missing: Called when `self` is called with a method it does not - define. -* #singleton_method_added: Called when a singleton method is added to - `self`. -* #singleton_method_removed: Called when a singleton method is removed from - `self`. -* #singleton_method_undefined: Called when a singleton method is undefined - in `self`. - - - -#Instance Methods -## !() [](#method-i-!) -Boolean negate. - -**@overload** [] - -## !=(obj2) [](#method-i-!=) -Returns true if two objects are not-equal, otherwise false. - -**@overload** [] - -## ==(obj2) [](#method-i-==) -Equality --- At the Object level, #== returns `true` only if `obj` and `other` -are the same object. Typically, this method is overridden in descendant -classes to provide class-specific meaning. - -Unlike #==, the #equal? method should never be overridden by subclasses as it -is used to determine object identity (that is, `a.equal?(b)` if and only if -`a` is the same object as `b`): - - obj = "a" - other = obj.dup - - obj == other #=> true - obj.equal? other #=> false - obj.equal? obj #=> true - -The #eql? method returns `true` if `obj` and `other` refer to the same hash -key. This is used by Hash to test members for equality. For any pair of -objects where #eql? returns `true`, the #hash value of both objects must be -equal. So any subclass that overrides #eql? should also override #hash -appropriately. - -For objects of class Object, #eql? is synonymous with #==. Subclasses -normally continue this tradition by aliasing #eql? to their overridden #== -method, but there are exceptions. Numeric types, for example, perform type -conversion across #==, but not across #eql?, so: - - 1 == 1.0 #=> true - 1.eql? 1.0 #=> false - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## __id__() [](#method-i-__id__) -call-seq: - obj.__id__ -> integer - obj.object_id -> integer - -Returns an integer identifier for `obj`. - -The same number will be returned on all calls to `object_id` for a given -object, and no two active objects will share an id. - -Note: that some objects of builtin classes are reused for optimization. This -is the case for immediate values and frozen string literals. - -BasicObject implements `__id__`, Kernel implements `object_id`. - -Immediate values are not passed by reference but are passed by value: `nil`, -`true`, `false`, Fixnums, Symbols, and some Floats. - - Object.new.object_id == Object.new.object_id # => false - (21 * 2).object_id == (21 * 2).object_id # => true - "hello".object_id == "hello".object_id # => false - "hi".freeze.object_id == "hi".freeze.object_id # => true - -## __send__(*args) [](#method-i-__send__) -Invokes the method identified by *symbol*, passing it any - arguments specified. - When the method is identified by a string, the string is converted - to a symbol. - - BasicObject implements +__send__+, Kernel implements +send+. - __send__ is safer than +send+ - when _obj_ has the same method name like Socket. - See also public_send. - - class Klass - def hello(*args) - "Hello " + args.join(' ') - end - end - k = Klass.new - k.send :hello, "gentle", "readers" #=> "Hello gentle readers" - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## equal?(obj2) [](#method-i-equal?) -Equality --- At the Object level, #== returns `true` only if `obj` and `other` -are the same object. Typically, this method is overridden in descendant -classes to provide class-specific meaning. - -Unlike #==, the #equal? method should never be overridden by subclasses as it -is used to determine object identity (that is, `a.equal?(b)` if and only if -`a` is the same object as `b`): - - obj = "a" - other = obj.dup - - obj == other #=> true - obj.equal? other #=> false - obj.equal? obj #=> true - -The #eql? method returns `true` if `obj` and `other` refer to the same hash -key. This is used by Hash to test members for equality. For any pair of -objects where #eql? returns `true`, the #hash value of both objects must be -equal. So any subclass that overrides #eql? should also override #hash -appropriately. - -For objects of class Object, #eql? is synonymous with #==. Subclasses -normally continue this tradition by aliasing #eql? to their overridden #== -method, but there are exceptions. Numeric types, for example, perform type -conversion across #==, but not across #eql?, so: - - 1 == 1.0 #=> true - 1.eql? 1.0 #=> false - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## instance_eval(*args) [](#method-i-instance_eval) -Evaluates a string containing Ruby source code, or the given block, within the -context of the receiver (*obj*). In order to set the context, the variable -`self` is set to *obj* while the code is executing, giving the code access to -*obj*'s instance variables and private methods. - -When `instance_eval` is given a block, *obj* is also passed in as the block's -only argument. - -When `instance_eval` is given a `String`, the optional second and third -parameters supply a filename and starting line number that are used when -reporting compilation errors. - - class KlassWithSecret - def initialize - @secret = 99 - end - private - def the_secret - "Ssssh! The secret is #{@secret}." - end - end - k = KlassWithSecret.new - k.instance_eval { @secret } #=> 99 - k.instance_eval { the_secret } #=> "Ssssh! The secret is 99." - k.instance_eval {|obj| obj == self } #=> true - -**@overload** [] - -**@overload** [] - -## instance_exec(*args) [](#method-i-instance_exec) -Executes the given block within the context of the receiver (*obj*). In order -to set the context, the variable `self` is set to *obj* while the code is -executing, giving the code access to *obj*'s instance variables. Arguments -are passed as block parameters. - - class KlassWithSecret - def initialize - @secret = 99 - end - end - k = KlassWithSecret.new - k.instance_exec(5) {|x| @secret+x } #=> 104 - -**@overload** [] - diff --git a/example/ruby/BasicObjectSpecs.md b/example/ruby/BasicObjectSpecs.md deleted file mode 100644 index b4d7a65..0000000 --- a/example/ruby/BasicObjectSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs - - - - - diff --git a/example/ruby/BasicObjectSpecs/BOSubclass.md b/example/ruby/BasicObjectSpecs/BOSubclass.md deleted file mode 100644 index 8d470d0..0000000 --- a/example/ruby/BasicObjectSpecs/BOSubclass.md +++ /dev/null @@ -1,1951 +0,0 @@ -# Class: BasicObjectSpecs::BOSubclass -**Inherits:** BasicObject - -**Includes:** Kernel - - - - -# Class Methods -## kernel_defined?() [](#method-c-kernel_defined?) -**@return** [Boolean] - - -#Instance Methods -## Array(arg) [](#method-i-Array) -Returns an array converted from `object`. - -Tries to convert `object` to an array using `to_ary` first and `to_a` second: - - Array([0, 1, 2]) # => [0, 1, 2] - Array({foo: 0, bar: 1}) # => [[:foo, 0], [:bar, 1]] - Array(0..4) # => [0, 1, 2, 3, 4] - -Returns `object` in an array, `[object]`, if `object` cannot be converted: - - Array(:foo) # => [:foo] - -**@overload** [] - -## Complex(*args) [](#method-i-Complex) -Returns a new Complex object if the arguments are valid; otherwise raises an -exception if `exception` is `true`; otherwise returns `nil`. - -With Numeric arguments `real` and `imag`, returns `Complex.rect(real, imag)` -if the arguments are valid. - -With string argument `s`, returns a new Complex object if the argument is -valid; the string may have: - -* One or two numeric substrings, each of which specifies a Complex, Float, - Integer, Numeric, or Rational value, specifying [rectangular - coordinates](rdoc-ref:Complex@Rectangular+Coordinates): - - * Sign-separated real and imaginary numeric substrings (with trailing - character `'i'`): - - Complex('1+2i') # => (1+2i) - Complex('+1+2i') # => (1+2i) - Complex('+1-2i') # => (1-2i) - Complex('-1+2i') # => (-1+2i) - Complex('-1-2i') # => (-1-2i) - - * Real-only numeric string (without trailing character `'i'`): - - Complex('1') # => (1+0i) - Complex('+1') # => (1+0i) - Complex('-1') # => (-1+0i) - - * Imaginary-only numeric string (with trailing character `'i'`): - - Complex('1i') # => (0+1i) - Complex('+1i') # => (0+1i) - Complex('-1i') # => (0-1i) - -* At-sign separated real and imaginary rational substrings, each of which - specifies a Rational value, specifying [polar - coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex('1/2@3/4') # => (0.36584443443691045+0.34081938001166706i) - Complex('+1/2@+3/4') # => (0.36584443443691045+0.34081938001166706i) - Complex('+1/2@-3/4') # => (0.36584443443691045-0.34081938001166706i) - Complex('-1/2@+3/4') # => (-0.36584443443691045-0.34081938001166706i) - Complex('-1/2@-3/4') # => (-0.36584443443691045+0.34081938001166706i) - -**@overload** [] - -**@overload** [] - -## Hash(arg) [](#method-i-Hash) -Returns a hash converted from `object`. - -* If `object` is: - - * A hash, returns `object`. - * An empty array or `nil`, returns an empty hash. - -* Otherwise, if `object.to_hash` returns a hash, returns that hash. -* Otherwise, returns TypeError. - -Examples: - - Hash({foo: 0, bar: 1}) # => {:foo=>0, :bar=>1} - Hash(nil) # => {} - Hash([]) # => {} - -**@overload** [] - -## Pathname(str) [](#method-i-Pathname) -:call-seq: - Pathname(path) -> pathname - -Creates a new Pathname object from the given string, `path`, and returns -pathname object. - -In order to use this constructor, you must first require the Pathname standard -library extension. - -require 'pathname' Pathname("/home/zzak") #=> # - -See also Pathname::new for more information. - -## Rational(*args) [](#method-i-Rational) -Returns `x/y` or `arg` as a Rational. - - Rational(2, 3) #=> (2/3) - Rational(5) #=> (5/1) - Rational(0.5) #=> (1/2) - Rational(0.3) #=> (5404319552844595/18014398509481984) - - Rational("2/3") #=> (2/3) - Rational("0.3") #=> (3/10) - - Rational("10 cents") #=> ArgumentError - Rational(nil) #=> TypeError - Rational(1, nil) #=> TypeError - - Rational("10 cents", exception: false) #=> nil - -Syntax of the string form: - - string form = extra spaces , rational , extra spaces ; - rational = [ sign ] , unsigned rational ; - unsigned rational = numerator | numerator , "/" , denominator ; - numerator = integer part | fractional part | integer part , fractional part ; - denominator = digits ; - integer part = digits ; - fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; - sign = "-" | "+" ; - digits = digit , { digit | "_" , digit } ; - digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; - extra spaces = ? \s* ? ; - -See also String#to_r. - -**@overload** [] - -**@overload** [] - -## String(arg) [](#method-i-String) -Returns a string converted from `object`. - -Tries to convert `object` to a string using `to_str` first and `to_s` second: - - String([0, 1, 2]) # => "[0, 1, 2]" - String(0..5) # => "0..5" - String({foo: 0, bar: 1}) # => "{foo: 0, bar: 1}" - -Raises `TypeError` if `object` cannot be converted to a string. - -**@overload** [] - -## __callee__() [](#method-i-__callee__) -Returns the called name of the current method as a Symbol. If called outside -of a method, it returns `nil`. - -**@overload** [] - -## __dir__() [](#method-i-__dir__) -Returns the canonicalized absolute path of the directory of the file from -which this method is called. It means symlinks in the path is resolved. If -`__FILE__` is `nil`, it returns `nil`. The return value equals to -`File.dirname(File.realpath(__FILE__))`. - -**@overload** [] - -## __method__() [](#method-i-__method__) -Returns the name at the definition of the current method as a Symbol. If -called outside of a method, it returns `nil`. - -**@overload** [] - -## `(str) [](#method-i-`) -Returns the `$stdout` output from running `command` in a subshell; sets global -variable `$?` to the process status. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Examples: - - $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n" - $ `echo oops && exit 99` # => "oops\n" - $ $? # => # - $ $?.status # => 99> - -The built-in syntax `%x{...}` uses this method. - -**@overload** [] - -## abort(*a, _) [](#method-i-abort) -Terminates execution immediately, effectively by calling `Kernel.exit(false)`. - -If string argument `msg` is given, it is written to STDERR prior to -termination; otherwise, if an exception was raised, prints its message and -backtrace. - -**@overload** [] - -**@overload** [] - -## at_exit() [](#method-i-at_exit) -Converts *block* to a `Proc` object (and therefore binds it at the point of -call) and registers it for execution when the program exits. If multiple -handlers are registered, they are executed in reverse order of registration. - - def do_at_exit(str1) - at_exit { print str1 } - end - at_exit { puts "cruel world" } - do_at_exit("goodbye ") - exit - -*produces:* - - goodbye cruel world - -**@overload** [] - -## autoload(sym, file) [](#method-i-autoload) -Registers *filename* to be loaded (using Kernel::require) the first time that -*const* (which may be a String or a symbol) is accessed. - - autoload(:MyModule, "/usr/local/lib/modules/my_module.rb") - -If *const* is defined as autoload, the file name to be loaded is replaced with -*filename*. If *const* is defined but not as autoload, does nothing. - -**@overload** [] - -## autoload?(*args) [](#method-i-autoload?) -Returns *filename* to be loaded if *name* is registered as `autoload` in the -current namespace or one of its ancestors. - - autoload(:B, "b") - autoload?(:B) #=> "b" - - module C - autoload(:D, "d") - autoload?(:D) #=> "d" - autoload?(:B) #=> nil - end - - class E - autoload(:F, "f") - autoload?(:F) #=> "f" - autoload?(:B) #=> "b" - end - -**@overload** [] - -## binding() [](#method-i-binding) -Returns a Binding object, describing the variable and method bindings at the -point of call. This object can be used when calling Binding#eval to execute -the evaluated command in this environment, or extracting its local variables. - - class User - def initialize(name, position) - @name = name - @position = position - end - - def get_binding - binding - end - end - - user = User.new('Joan', 'manager') - template = '{name: @name, position: @position}' - - # evaluate template in context of the object - eval(template, user.get_binding) - #=> {:name=>"Joan", :position=>"manager"} - -Binding#local_variable_get can be used to access the variables whose names are -reserved Ruby keywords: - - # This is valid parameter declaration, but `if` parameter can't - # be accessed by name, because it is a reserved word. - def validate(field, validation, if: nil) - condition = binding.local_variable_get('if') - return unless condition - - # ...Some implementation ... - end - - validate(:name, :empty?, if: false) # skips validation - validate(:name, :empty?, if: true) # performs validation - -**@overload** [] - -## block_given?() [](#method-i-block_given?) -Returns `true` if `yield` would execute a block in the current context. The -`iterator?` form is mildly deprecated. - - def try - if block_given? - yield - else - "no block" - end - end - try #=> "no block" - try { "hello" } #=> "hello" - try do "hello" end #=> "hello" - -**@overload** [] - -## callcc() [](#method-i-callcc) -Generates a Continuation object, which it passes to the associated block. You -need to `require 'continuation'` before using this method. Performing a -*cont*`.call` will cause the #callcc to return (as will falling through the -end of the block). The value returned by the #callcc is the value of the -block, or the value passed to *cont*`.call`. See class Continuation for more -details. Also see Kernel#throw for an alternative mechanism for unwinding a -call stack. - -**@overload** [] - -## caller(*args) [](#method-i-caller) -Returns the current execution stack---an array containing strings in the form -`file:line` or `file:line: in `method'`. - -The optional *start* parameter determines the number of initial stack entries -to omit from the top of the stack. - -A second optional `length` parameter can be used to limit how many entries are -returned from the stack. - -Returns `nil` if *start* is greater than the size of current execution stack. - -Optionally you can pass a range, which will return an array containing the -entries within the specified range. - - def a(skip) - caller(skip) - end - def b(skip) - a(skip) - end - def c(skip) - b(skip) - end - c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `
'"] - c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `
'"] - c(2) #=> ["prog:8:in `c'", "prog:12:in `
'"] - c(3) #=> ["prog:13:in `
'"] - c(4) #=> [] - c(5) #=> nil - -**@overload** [] - -**@overload** [] - -## caller_locations(*args) [](#method-i-caller_locations) -Returns the current execution stack---an array containing backtrace location -objects. - -See Thread::Backtrace::Location for more information. - -The optional *start* parameter determines the number of initial stack entries -to omit from the top of the stack. - -A second optional `length` parameter can be used to limit how many entries are -returned from the stack. - -Returns `nil` if *start* is greater than the size of current execution stack. - -Optionally you can pass a range, which will return an array containing the -entries within the specified range. - -**@overload** [] - -**@overload** [] - -## catch(*args) [](#method-i-catch) -`catch` executes its block. If `throw` is not called, the block executes -normally, and `catch` returns the value of the last expression evaluated. - - catch(1) { 123 } # => 123 - -If `throw(tag2, val)` is called, Ruby searches up its stack for a `catch` -block whose `tag` has the same `object_id` as *tag2*. When found, the block -stops executing and returns *val* (or `nil` if no second argument was given to -`throw`). - - catch(1) { throw(1, 456) } # => 456 - catch(1) { throw(1) } # => nil - -When `tag` is passed as the first argument, `catch` yields it as the parameter -of the block. - - catch(1) {|x| x + 2 } # => 3 - -When no `tag` is given, `catch` yields a new unique object (as from -`Object.new`) as the block parameter. This object can then be used as the -argument to `throw`, and will match the correct `catch` block. - - catch do |obj_A| - catch do |obj_B| - throw(obj_B, 123) - puts "This puts is not reached" - end - - puts "This puts is displayed" - 456 - end - - # => 456 - - catch do |obj_A| - catch do |obj_B| - throw(obj_A, 123) - puts "This puts is still not reached" - end - - puts "Now this puts is also not reached" - 456 - end - - # => 123 - -**@overload** [] - -## chomp(*args) [](#method-i-chomp) -Equivalent to `$_ = $_.chomp(*string*)`. See String#chomp. Available only when --p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## chop() [](#method-i-chop) -Equivalent to `($_.dup).chop!`, except `nil` is never returned. See -String#chop!. Available only when -p/-n command line option specified. - -**@overload** [] - -## class() [](#method-i-class) -call-seq: - obj.class -> class - - Returns the class of obj. This method must always be called - with an explicit receiver, as #class is also a reserved word in - Ruby. - - 1.class #=> Integer - self.class #=> Object - --- Equivalent to c Object#class in Ruby. - -Returns the class of c obj, skipping singleton classes or module inclusions. -++ - -## clone(freeze:nil) [](#method-i-clone) -call-seq: - obj.clone(freeze: nil) -> an_object - - Produces a shallow copy of obj---the instance variables of - obj are copied, but not the objects they reference. - #clone copies the frozen value state of obj, unless the - +:freeze+ keyword argument is given with a false or true value. - See also the discussion under Object#dup. - - class Klass - attr_accessor :str - end - s1 = Klass.new #=> # - s1.str = "Hello" #=> "Hello" - s2 = s1.clone #=> # - s2.str[1,4] = "i" #=> "i" - s1.inspect #=> "#" - s2.inspect #=> "#" - - This method may have class-specific behavior. If so, that - behavior will be documented under the #+initialize_copy+ method of - the class. - -## eval(*args) [](#method-i-eval) -Evaluates the Ruby expression(s) in *string*. If *binding* is given, which -must be a Binding object, the evaluation is performed in its context. If the -optional *filename* and *lineno* parameters are present, they will be used -when reporting syntax errors. - - def get_binding(str) - return binding - end - str = "hello" - eval "str + ' Fred'" #=> "hello Fred" - eval "str + ' Fred'", get_binding("bye") #=> "bye Fred" - -**@overload** [] - -## exec(*a, _) [](#method-i-exec) -Replaces the current process by doing one of the following: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -The new process is created using the [exec system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e -xecve.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - exec('if true; then echo "Foo"; fi') # Shell reserved word. - exec('exit') # Built-in. - exec('date > date.tmp') # Contains meta character. - -The command line may also contain arguments and options for the command: - - exec('echo "Foo"') - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - exec('/usr/bin/date') - -Output: - - Sat Aug 26 09:38:00 AM CDT 2023 - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - - exec('doesnt_exist') # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - exec('echo', 'C*') - exec('echo', 'hello', 'world') - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## exit(*a, _) [](#method-i-exit) -Initiates termination of the Ruby script by raising SystemExit; the exception -may be caught. Returns exit status `status` to the underlying operating -system. - -Values `true` and `false` for argument `status` indicate, respectively, -success and failure; The meanings of integer values are system-dependent. - -Example: - - begin - exit - puts 'Never get here.' - rescue SystemExit - puts 'Rescued a SystemExit exception.' - end - puts 'After begin block.' - -Output: - - Rescued a SystemExit exception. - After begin block. - -Just prior to final termination, Ruby executes any at-exit procedures (see -Kernel::at_exit) and any object finalizers (see -ObjectSpace::define_finalizer). - -Example: - - at_exit { puts 'In at_exit function.' } - ObjectSpace.define_finalizer('string', proc { puts 'In finalizer.' }) - exit - -Output: - - In at_exit function. - In finalizer. - -**@overload** [] - -**@overload** [] - -## exit!(*args) [](#method-i-exit!) -Exits the process immediately; no exit handlers are called. Returns exit -status `status` to the underlying operating system. - - Process.exit!(true) - -Values `true` and `false` for argument `status` indicate, respectively, -success and failure; The meanings of integer values are system-dependent. - -**@overload** [] - -**@overload** [] - -## fail(*v, _) [](#method-i-fail) -Raises an exception; see [Exceptions](rdoc-ref:exceptions.md). - -Argument `exception` sets the class of the new exception; it should be class -Exception or one of its subclasses (most commonly, RuntimeError or -StandardError), or an instance of one of those classes: - - begin - raise(StandardError) - rescue => x - p x.class - end - # => StandardError - -Argument `message` sets the stored message in the new exception, which may be -retrieved by method Exception#message; the message must be a -[string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or -`nil`: - - begin - raise(StandardError, 'Boom') - rescue => x - p x.message - end - # => "Boom" - -If argument `message` is not given, the message is the exception class name. - -See [Messages](rdoc-ref:exceptions.md@Messages). - -Argument `backtrace` might be used to modify the backtrace of the new -exception, as reported by Exception#backtrace and -Exception#backtrace_locations; the backtrace must be an array of -Thread::Backtrace::Location, an array of strings, a single string, or `nil`. - -Using the array of Thread::Backtrace::Location instances is the most -consistent option and should be preferred when possible. The necessary value -might be obtained from #caller_locations, or copied from -Exception#backtrace_locations of another error: - - begin - do_some_work() - rescue ZeroDivisionError => ex - raise(LogicalError, "You have an error in your math", ex.backtrace_locations) - end - -The ways, both Exception#backtrace and Exception#backtrace_locations of the -raised error are set to the same backtrace. - -When the desired stack of locations is not available and should be constructed -from scratch, an array of strings or a singular string can be used. In this -case, only Exception#backtrace is set: - - begin - raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1]) - rescue => ex - p ex.backtrace - # => ["dsl.rb:3", "framework.rb:1"] - p ex.backtrace_locations - # => nil - end - -If argument `backtrace` is not given, the backtrace is set according to an -array of Thread::Backtrace::Location objects, as derived from the call stack. - -See [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -Keyword argument `cause` sets the stored cause in the new exception, which may -be retrieved by method Exception#cause; the cause must be an exception object -(Exception or one of its subclasses), or `nil`: - - begin - raise(StandardError, cause: RuntimeError.new) - rescue => x - p x.cause - end - # => # - -If keyword argument `cause` is not given, the cause is the value of `$!`. - -See [Cause](rdoc-ref:exceptions.md@Cause). - -In the alternate calling sequence, where argument `exception` *not* given, -raises a new exception of the class given by `$!`, or of class RuntimeError if -`$!` is `nil`: - - begin - raise - rescue => x - p x - end - # => RuntimeError - -With argument `exception` not given, argument `message` and keyword argument -`cause` may be given, but argument `backtrace` may not be given. - -**@overload** [] - -**@overload** [] - -## fork() [](#method-i-fork) -Creates a child process. - -With a block given, runs the block in the child process; on block exit, the -child terminates with a status of zero: - - puts "Before the fork: #{Process.pid}" - fork do - puts "In the child process: #{Process.pid}" - end # => 382141 - puts "After the fork: #{Process.pid}" - -Output: - - Before the fork: 420496 - After the fork: 420496 - In the child process: 420520 - -With no block given, the `fork` call returns twice: - -* Once in the parent process, returning the pid of the child process. -* Once in the child process, returning `nil`. - -Example: - - puts "This is the first line before the fork (pid #{Process.pid})" - puts fork - puts "This is the second line after the fork (pid #{Process.pid})" - -Output: - - This is the first line before the fork (pid 420199) - 420223 - This is the second line after the fork (pid 420199) - - This is the second line after the fork (pid 420223) - -In either case, the child process may exit using Kernel.exit! to avoid the -call to Kernel#at_exit. - -To avoid zombie processes, the parent process should call either: - -* Process.wait, to collect the termination statuses of its children. -* Process.detach, to register disinterest in their status. - -The thread calling `fork` is the only thread in the created child process; -`fork` doesn't copy other threads. - -Note that method `fork` is available on some platforms, but not on others: - - Process.respond_to?(:fork) # => true # Would be false on some. - -If not, you may use ::spawn instead of `fork`. - -**@overload** [] - -**@overload** [] - -## format(*v, _) [](#method-i-format) -Returns the string resulting from formatting `objects` into `format_string`. - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -**@overload** [] - -## frozen?() [](#method-i-frozen?) -call-seq: - obj.frozen? -> true or false - - Returns the freeze status of obj. - - a = [ "a", "b", "c" ] - a.freeze #=> ["a", "b", "c"] - a.frozen? #=> true - --- Determines if the object is frozen. Equivalent to `Object#frozen?` in Ruby. -@[param](in) obj the object to be determines ++ - -**@return** [Boolean] - -## gets(*args) [](#method-i-gets) -Returns (and assigns to `$_`) the next line from the list of files in `ARGV` -(or `$*`), or from standard input if no files are present on the command line. -Returns `nil` at end of file. The optional argument specifies the record -separator. The separator is included with the contents of each record. A -separator of `nil` reads the entire contents, and a zero-length separator -reads the input one paragraph at a time, where paragraphs are divided by two -consecutive newlines. If the first argument is an integer, or optional second -argument is given, the returning string would not be longer than the given -value in bytes. If multiple filenames are present in `ARGV`, `gets(nil)` will -read the contents one file at a time. - - ARGV << "testfile" - print while gets - -*produces:* - - This is line one - This is line two - This is line three - And so on... - -The style of programming using `$_` as an implicit parameter is gradually -losing favor in the Ruby community. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## global_variables() [](#method-i-global_variables) -Returns an array of the names of global variables. This includes special -regexp global variables such as `$~` and `$+`, but does not include the -numbered regexp global variables (`$1`, `$2`, etc.). - - global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr] - -**@overload** [] - -## gsub(*args) [](#method-i-gsub) -Equivalent to `$_.gsub...`, except that `$_` will be updated if substitution -occurs. Available only when -p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## iterator?() [](#method-i-iterator?) -Deprecated. Use block_given? instead. - -**@overload** [] - -## lambda() [](#method-i-lambda) -Equivalent to Proc.new, except the resulting Proc objects check the number of -parameters passed when called. - -**@overload** [] - -## local_variables() [](#method-i-local_variables) -Returns the names of the current local variables. - - fred = 1 - for i in 1..10 - # ... - end - local_variables #=> [:fred, :i] - -**@overload** [] - -## module_specs_public_method_on_kernel() [](#method-i-module_specs_public_method_on_kernel) - -## open(*args) [](#method-i-open) -Creates an IO object connected to the given file. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -With no block given, file stream is returned: - - open('t.txt') # => # - -With a block given, calls the block with the open file stream, then closes the -stream: - - open('t.txt') {|f| p f } # => # - -Output: - - # - -See File.open for details. - -**@overload** [] - -**@overload** [] - -## p(*args) [](#method-i-p) -For each object `obj`, executes: - - $stdout.write(obj.inspect, "\n") - -With one object given, returns the object; with multiple objects given, -returns an array containing the objects; with no object given, returns `nil`. - -Examples: - - r = Range.new(0, 4) - p r # => 0..4 - p [r, r, r] # => [0..4, 0..4, 0..4] - p # => nil - -Output: - - 0..4 - [0..4, 0..4, 0..4] - -Kernel#p is designed for debugging purposes. Ruby implementations may define -Kernel#p to be uninterruptible in whole or in part. On CRuby, Kernel#p's -writing of data is uninterruptible. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## pretty_inspect() [](#method-i-pretty_inspect) -Returns a pretty printed object as a string. - -See the PP module for more information. - -## print(*args) [](#method-i-print) -Equivalent to `$stdout.print(*objects)`, this method is the straightforward -way to write to `$stdout`. - -Writes the given objects to `$stdout`; returns `nil`. Appends the output -record separator `$OUTPUT_RECORD_SEPARATOR` `$\`), if it is not `nil`. - -With argument `objects` given, for each object: - -* Converts via its method `to_s` if not a string. -* Writes to `stdout`. -* If not the last object, writes the output field separator - `$OUTPUT_FIELD_SEPARATOR` (`$,` if it is not `nil`. - -With default separators: - - objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero'] - $OUTPUT_RECORD_SEPARATOR - $OUTPUT_FIELD_SEPARATOR - print(*objects) - -Output: - - nil - nil - 00.00/10+0izerozero - -With specified separators: - - $OUTPUT_RECORD_SEPARATOR = "\n" - $OUTPUT_FIELD_SEPARATOR = ',' - print(*objects) - -Output: - - 0,0.0,0/1,0+0i,zero,zero - -With no argument given, writes the content of `$_` (which is usually the most -recent user input): - - gets # Sets $_ to the most recent user input. - print # Prints $_. - -**@overload** [] - -## printf(*args) [](#method-i-printf) -Equivalent to: - - io.write(sprintf(format_string, *objects)) - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -With the single argument `format_string`, formats `objects` into the string, -then writes the formatted string to $stdout: - - printf('%4.4d %10s %2.2f', 24, 24, 24.0) - -Output (on $stdout): - - 0024 24 24.00# - -With arguments `io` and `format_string`, formats `objects` into the string, -then writes the formatted string to `io`: - - printf($stderr, '%4.4d %10s %2.2f', 24, 24, 24.0) - -Output (on $stderr): - - 0024 24 24.00# => nil - -With no arguments, does nothing. - -**@overload** [] - -**@overload** [] - -## proc() [](#method-i-proc) -Equivalent to Proc.new. - -**@overload** [] - -## putc(ch) [](#method-i-putc) -Equivalent to: - - $stdout.putc(int) - -See IO#putc for important information regarding multi-byte characters. - -**@overload** [] - -## puts(*args) [](#method-i-puts) -Equivalent to - - $stdout.puts(objects) - -**@overload** [] - -## raise(*v, _) [](#method-i-raise) -Raises an exception; see [Exceptions](rdoc-ref:exceptions.md). - -Argument `exception` sets the class of the new exception; it should be class -Exception or one of its subclasses (most commonly, RuntimeError or -StandardError), or an instance of one of those classes: - - begin - raise(StandardError) - rescue => x - p x.class - end - # => StandardError - -Argument `message` sets the stored message in the new exception, which may be -retrieved by method Exception#message; the message must be a -[string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or -`nil`: - - begin - raise(StandardError, 'Boom') - rescue => x - p x.message - end - # => "Boom" - -If argument `message` is not given, the message is the exception class name. - -See [Messages](rdoc-ref:exceptions.md@Messages). - -Argument `backtrace` might be used to modify the backtrace of the new -exception, as reported by Exception#backtrace and -Exception#backtrace_locations; the backtrace must be an array of -Thread::Backtrace::Location, an array of strings, a single string, or `nil`. - -Using the array of Thread::Backtrace::Location instances is the most -consistent option and should be preferred when possible. The necessary value -might be obtained from #caller_locations, or copied from -Exception#backtrace_locations of another error: - - begin - do_some_work() - rescue ZeroDivisionError => ex - raise(LogicalError, "You have an error in your math", ex.backtrace_locations) - end - -The ways, both Exception#backtrace and Exception#backtrace_locations of the -raised error are set to the same backtrace. - -When the desired stack of locations is not available and should be constructed -from scratch, an array of strings or a singular string can be used. In this -case, only Exception#backtrace is set: - - begin - raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1]) - rescue => ex - p ex.backtrace - # => ["dsl.rb:3", "framework.rb:1"] - p ex.backtrace_locations - # => nil - end - -If argument `backtrace` is not given, the backtrace is set according to an -array of Thread::Backtrace::Location objects, as derived from the call stack. - -See [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -Keyword argument `cause` sets the stored cause in the new exception, which may -be retrieved by method Exception#cause; the cause must be an exception object -(Exception or one of its subclasses), or `nil`: - - begin - raise(StandardError, cause: RuntimeError.new) - rescue => x - p x.cause - end - # => # - -If keyword argument `cause` is not given, the cause is the value of `$!`. - -See [Cause](rdoc-ref:exceptions.md@Cause). - -In the alternate calling sequence, where argument `exception` *not* given, -raises a new exception of the class given by `$!`, or of class RuntimeError if -`$!` is `nil`: - - begin - raise - rescue => x - p x - end - # => RuntimeError - -With argument `exception` not given, argument `message` and keyword argument -`cause` may be given, but argument `backtrace` may not be given. - -**@overload** [] - -**@overload** [] - -## rand(*args) [](#method-i-rand) -If called without an argument, or if `max.to_i.abs == 0`, rand returns a -pseudo-random floating point number between 0.0 and 1.0, including 0.0 and -excluding 1.0. - - rand #=> 0.2725926052826416 - -When `max.abs` is greater than or equal to 1, `rand` returns a pseudo-random -integer greater than or equal to 0 and less than `max.to_i.abs`. - - rand(100) #=> 12 - -When `max` is a Range, `rand` returns a random number where -`range.member?(number) == true`. - -Negative or floating point values for `max` are allowed, but may give -surprising results. - - rand(-100) # => 87 - rand(-0.5) # => 0.8130921818028143 - rand(1.9) # equivalent to rand(1), which is always 0 - -Kernel.srand may be used to ensure that sequences of random numbers are -reproducible between different runs of a program. - -See also Random.rand. - -**@overload** [] - -## rb_eval_string(str) [](#method-i-rb_eval_string) - -## readline(*args) [](#method-i-readline) -Equivalent to method Kernel#gets, except that it raises an exception if called -at end-of-stream: - - $ cat t.txt | ruby -e "p readlines; readline" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - in `readline': end of file reached (EOFError) - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## readlines(*args) [](#method-i-readlines) -Returns an array containing the lines returned by calling Kernel#gets until -the end-of-stream is reached; (see [Line IO](rdoc-ref:IO@Line+IO)). - -With only string argument `sep` given, returns the remaining lines as -determined by line separator `sep`, or `nil` if none; see [Line -Separator](rdoc-ref:IO@Line+Separator): - - # Default separator. - $ cat t.txt | ruby -e "p readlines" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - - # Specified separator. - $ cat t.txt | ruby -e "p readlines 'li'" - ["First li", "ne\nSecond li", "ne\n\nFourth li", "ne\nFifth li", "ne\n"] - - # Get-all separator. - $ cat t.txt | ruby -e "p readlines nil" - ["First line\nSecond line\n\nFourth line\nFifth line\n"] - - # Get-paragraph separator. - $ cat t.txt | ruby -e "p readlines ''" - ["First line\nSecond line\n\n", "Fourth line\nFifth line\n"] - -With only integer argument `limit` given, limits the number of bytes in the -line; see [Line Limit](rdoc-ref:IO@Line+Limit): - - $cat t.txt | ruby -e "p readlines 10" - ["First line", "\n", "Second lin", "e\n", "\n", "Fourth lin", "e\n", "Fifth line", "\n"] - - $cat t.txt | ruby -e "p readlines 11" - ["First line\n", "Second line", "\n", "\n", "Fourth line", "\n", "Fifth line\n"] - - $cat t.txt | ruby -e "p readlines 12" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted: - - $ cat t.txt | ruby -e "p readlines(chomp: true)" - ["First line", "Second line", "", "Fourth line", "Fifth line"] - -Optional keyword arguments `enc_opts` specify encoding options; see [Encoding -options](rdoc-ref:encodings.rdoc@Encoding+Options). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## register_sample_bug_reporter(obj) [](#method-i-register_sample_bug_reporter) - -## select(*args) [](#method-i-select) -Invokes system call [select(2)](https://linux.die.net/man/2/select), which -monitors multiple file descriptors, waiting until one or more of the file -descriptors becomes ready for some class of I/O operation. - -Not implemented on all platforms. - -Each of the arguments `read_ios`, `write_ios`, and `error_ios` is an array of -IO objects. - -Argument `timeout` is a numeric value (such as integer or float) timeout -interval in seconds. - -The method monitors the IO objects given in all three arrays, waiting for some -to be ready; returns a 3-element array whose elements are: - -* An array of the objects in `read_ios` that are ready for reading. -* An array of the objects in `write_ios` that are ready for writing. -* An array of the objects in `error_ios` have pending exceptions. - -If no object becomes ready within the given `timeout`, `nil` is returned. - -IO.select peeks the buffer of IO objects for testing readability. If the IO -buffer is not empty, IO.select immediately notifies readability. This "peek" -only happens for IO objects. It does not happen for IO-like objects such as -OpenSSL::SSL::SSLSocket. - -The best way to use IO.select is invoking it after non-blocking methods such -as #read_nonblock, #write_nonblock, etc. The methods raise an exception which -is extended by IO::WaitReadable or IO::WaitWritable. The modules notify how -the caller should wait with IO.select. If IO::WaitReadable is raised, the -caller should wait for reading. If IO::WaitWritable is raised, the caller -should wait for writing. - -So, blocking read (#readpartial) can be emulated using #read_nonblock and -IO.select as follows: - - begin - result = io_like.read_nonblock(maxlen) - rescue IO::WaitReadable - IO.select([io_like]) - retry - rescue IO::WaitWritable - IO.select(nil, [io_like]) - retry - end - -Especially, the combination of non-blocking methods and IO.select is preferred -for IO like objects such as OpenSSL::SSL::SSLSocket. It has #to_io method to -return underlying IO object. IO.select calls #to_io to obtain the file -descriptor to wait. - -This means that readability notified by IO.select doesn't mean readability -from OpenSSL::SSL::SSLSocket object. - -The most likely situation is that OpenSSL::SSL::SSLSocket buffers some data. -IO.select doesn't see the buffer. So IO.select can block when -OpenSSL::SSL::SSLSocket#readpartial doesn't block. - -However, several more complicated situations exist. - -SSL is a protocol which is sequence of records. The record consists of -multiple bytes. So, the remote side of SSL sends a partial record, IO.select -notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a byte and -OpenSSL::SSL::SSLSocket#readpartial will block. - -Also, the remote side can request SSL renegotiation which forces the local SSL -engine to write some data. This means OpenSSL::SSL::SSLSocket#readpartial may -invoke #write system call and it can block. In such a situation, -OpenSSL::SSL::SSLSocket#read_nonblock raises IO::WaitWritable instead of -blocking. So, the caller should wait for ready for writability as above -example. - -The combination of non-blocking methods and IO.select is also useful for -streams such as tty, pipe socket socket when multiple processes read from a -stream. - -Finally, Linux kernel developers don't guarantee that readability of select(2) -means readability of following read(2) even for a single process; see -[select(2)](https://linux.die.net/man/2/select) - -Invoking IO.select before IO#readpartial works well as usual. However it is -not the best way to use IO.select. - -The writability notified by select(2) doesn't show how many bytes are -writable. IO#write method blocks until given whole string is written. So, -`IO#write(two or more bytes)` can block after writability is notified by -IO.select. IO#write_nonblock is required to avoid the blocking. - -Blocking write (#write) can be emulated using #write_nonblock and IO.select as -follows: IO::WaitReadable should also be rescued for SSL renegotiation in -OpenSSL::SSL::SSLSocket. - - while 0 < string.bytesize - begin - written = io_like.write_nonblock(string) - rescue IO::WaitReadable - IO.select([io_like]) - retry - rescue IO::WaitWritable - IO.select(nil, [io_like]) - retry - end - string = string.byteslice(written..-1) - end - -Example: - - rp, wp = IO.pipe - mesg = "ping " - 100.times { - # IO.select follows IO#read. Not the best way to use IO.select. - rs, ws, = IO.select([rp], [wp]) - if r = rs[0] - ret = r.read(5) - print ret - case ret - when /ping/ - mesg = "pong\n" - when /pong/ - mesg = "ping " - end - end - if w = ws[0] - w.write(mesg) - end - } - -Output: - - ping pong - ping pong - ping pong - (snipped) - ping - -**@overload** [] - -## set_trace_func(trace) [](#method-i-set_trace_func) -Establishes *proc* as the handler for tracing, or disables tracing if the -parameter is `nil`. - -**Note:** this method is obsolete, please use TracePoint instead. - -*proc* takes up to six parameters: - -* an event name string -* a filename string -* a line number -* a method name symbol, or nil -* a binding, or nil -* the class, module, or nil - -*proc* is invoked whenever an event occurs. - -Events are: - -`"c-call"` -: call a C-language routine - -`"c-return"` -: return from a C-language routine - -`"call"` -: call a Ruby method - -`"class"` -: start a class or module definition - -`"end"` -: finish a class or module definition - -`"line"` -: execute code on a new line - -`"raise"` -: raise an exception - -`"return"` -: return from a Ruby method - - -Tracing is disabled within the context of *proc*. - - class Test - def test - a = 1 - b = 2 - end - end - - set_trace_func proc { |event, file, line, id, binding, class_or_module| - printf "%8s %s:%-2d %16p %14p\n", event, file, line, id, class_or_module - } - t = Test.new - t.test - -Produces: - - c-return prog.rb:8 :set_trace_func Kernel - line prog.rb:11 nil nil - c-call prog.rb:11 :new Class - c-call prog.rb:11 :initialize BasicObject - c-return prog.rb:11 :initialize BasicObject - c-return prog.rb:11 :new Class - line prog.rb:12 nil nil - call prog.rb:2 :test Test - line prog.rb:3 :test Test - line prog.rb:4 :test Test - return prog.rb:5 :test Test - -**@overload** [] - -**@overload** [] - -## sleep(*args) [](#method-i-sleep) -Suspends execution of the current thread for the number of seconds specified -by numeric argument `secs`, or forever if `secs` is `nil`; returns the integer -number of seconds suspended (rounded). - - Time.new # => 2008-03-08 19:56:19 +0900 - sleep 1.2 # => 1 - Time.new # => 2008-03-08 19:56:20 +0900 - sleep 1.9 # => 2 - Time.new # => 2008-03-08 19:56:22 +0900 - -**@overload** [] - -## spawn(*args) [](#method-i-spawn) -Creates a new child process by doing one of the following in that process: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Returns the process ID (pid) of the new process, without waiting for it to -complete. - -To avoid zombie processes, the parent process should call either: - -* Process.wait, to collect the termination statuses of its children. -* Process.detach, to register disinterest in their status. - -The new process is created using the [exec system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e -xecve.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word. - Process.wait # => 798847 - spawn('exit') # => 798848 # Built-in. - Process.wait # => 798848 - spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character. - Process.wait # => 798849 - spawn('date > /nop/date.tmp') # => 798882 # Issues error message. - Process.wait # => 798882 - -The command line may also contain arguments and options for the command: - - spawn('echo "Foo"') # => 799031 - Process.wait # => 799031 - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable to be called, and - the string to be used as the name of the executing process. - - spawn('/usr/bin/date') # Path to date on Unix-style system. - Process.wait - - Output: - - Mon Aug 28 11:43:10 AM CDT 2023 - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - spawn('echo', 'C*') # => 799392 - Process.wait # => 799392 - spawn('echo', 'hello', 'world') # => 799393 - Process.wait # => 799393 - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## sprintf(*v, _) [](#method-i-sprintf) -Returns the string resulting from formatting `objects` into `format_string`. - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -**@overload** [] - -## srand(*args) [](#method-i-srand) -Seeds the system pseudo-random number generator, with `number`. The previous -seed value is returned. - -If `number` is omitted, seeds the generator using a source of entropy provided -by the operating system, if available (/dev/urandom on Unix systems or the RSA -cryptographic provider on Windows), which is then combined with the time, the -process id, and a sequence number. - -srand may be used to ensure repeatable sequences of pseudo-random numbers -between different runs of the program. By setting the seed to a known value, -programs can be made deterministic during testing. - - srand 1234 # => 268519324636777531569100071560086917274 - [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] - [ rand(10), rand(1000) ] # => [4, 664] - srand 1234 # => 1234 - [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] - -**@overload** [] - -## sub(*args) [](#method-i-sub) -Equivalent to `$_.sub(*args*)`, except that `$_` will be updated if -substitution occurs. Available only when -p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## syscall(*args) [](#method-i-syscall) -Invokes Posix system call [syscall(2)](https://linux.die.net/man/2/syscall), -which calls a specified function. - -Calls the operating system function identified by `integer_callno`; returns -the result of the function or raises SystemCallError if it failed. The effect -of the call is platform-dependent. The arguments and returned value are -platform-dependent. - -For each of `arguments`: if it is an integer, it is passed directly; if it is -a string, it is interpreted as a binary sequence of bytes. There may be as -many as nine such arguments. - -Arguments `integer_callno` and `argument`, as well as the returned value, are -platform-dependent. - -Note: Method `syscall` is essentially unsafe and unportable. The DL (Fiddle) -library is preferred for safer and a bit more portable programming. - -Not implemented on all platforms. - -**@overload** [] - -## system(*args) [](#method-i-system) -Creates a new child process by doing one of the following in that process: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Returns: - -* `true` if the command exits with status zero. -* `false` if the exit status is a non-zero integer. -* `nil` if the command could not execute. - -Raises an exception (instead of returning `false` or `nil`) if keyword -argument `exception` is set to `true`. - -Assigns the command's error status to `$?`. - -The new process is created using the [system system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/s -ystem.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - system('if true; then echo "Foo"; fi') # => true # Shell reserved word. - system('exit') # => true # Built-in. - system('date > /tmp/date.tmp') # => true # Contains meta character. - system('date > /nop/date.tmp') # => false - system('date > /nop/date.tmp', exception: true) # Raises RuntimeError. - -Assigns the command's error status to `$?`: - - system('exit') # => true # Built-in. - $? # => # - system('date > /nop/date.tmp') # => false - $? # => # - -The command line may also contain arguments and options for the command: - - system('echo "Foo"') # => true - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - system('/usr/bin/date') # => true # Path to date on Unix-style system. - system('foo') # => nil # Command failed. - -Output: - - Mon Aug 28 11:43:10 AM CDT 2023 - -Assigns the command's error status to `$?`: - - system('/usr/bin/date') # => true - $? # => # - system('foo') # => nil - $? # => # - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - - system('doesnt_exist') # => nil - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - system('echo', 'C*') # => true - system('echo', 'hello', 'world') # => true - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## tap() [](#method-i-tap) -call-seq: - obj.tap {|x| block } -> obj - - Yields self to the block and then returns self. - The primary purpose of this method is to "tap into" a method chain, - in order to perform operations on intermediate results within the chain. - - (1..10) .tap {|x| puts "original: #{x}" } - .to_a .tap {|x| puts "array: #{x}" } - .select {|x| x.even? } .tap {|x| puts "evens: #{x}" } - .map {|x| x*x } .tap {|x| puts "squares: #{x}" } - --- private ++ - -**@yield** [_self] - -**@yieldparam** [Kernel] the object that the method was called on - -## test(*args) [](#method-i-test) -:markup: markdown - -call-seq: - test(char, path0, path1 = nil) -> object - -Performs a test on one or both of the *filesystem entities* at the given paths -`path0` and `path1`: - -* Each path `path0` or `path1` points to a file, directory, device, pipe, - etc. -* Character `char` selects a specific test. - -The tests: - -* Each of these tests operates only on the entity at `path0`, and returns - `true` or `false`; for a non-existent entity, returns `false` (does not - raise exception): - - | Character | Test | - |:------------:|:--------------------------------------------------------------------------| - | 'b' | Whether the entity is a block device. | - | 'c' | Whether the entity is a character device. | - | 'd' | Whether the entity is a directory. | - | 'e' | Whether the entity is an existing entity. | - | 'f' | Whether the entity is an existing regular file. | - | 'g' | Whether the entity's setgid bit is set. | - | 'G' | Whether the entity's group ownership is equal to the caller's. | - | 'k' | Whether the entity's sticky bit is set. | - | 'l' | Whether the entity is a symbolic link. | - | 'o' | Whether the entity is owned by the caller's effective uid. | - | 'O' | Like 'o', but uses the real uid (not the effective uid). | - | 'p' | Whether the entity is a FIFO device (named pipe). | - | 'r' | Whether the entity is readable by the caller's effective uid/gid. | - | 'R' | Like 'r', but uses the real uid/gid (not the effective uid/gid). | - | 'S' | Whether the entity is a socket. | - | 'u' | Whether the entity's setuid bit is set. | - | 'w' | Whether the entity is writable by the caller's effective uid/gid. | - | 'W' | Like 'w', but uses the real uid/gid (not the effective uid/gid). | - | 'x' | Whether the entity is executable by the caller's effective uid/gid. | - | 'X' | Like 'x', but uses the real uid/gid (not the effective uid/git). | - | 'z' | Whether the entity exists and is of length zero. | - -* This test operates only on the entity at `path0`, and returns an integer - size or `nil`: - - | Character | Test | - |:------------:|:---------------------------------------------------------------------------------------------| - | 's' | Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise. | - -* Each of these tests operates only on the entity at `path0`, and returns a - Time object; raises an exception if the entity does not exist: - - | Character | Test | - |:------------:|:---------------------------------------| - | 'A' | Last access time for the entity. | - | 'C' | Last change time for the entity. | - | 'M' | Last modification time for the entity. | - -* Each of these tests operates on the modification time (`mtime`) of each of - the entities at `path0` and `path1`, and returns a `true` or `false`; - returns `false` if either entity does not exist: - - | Character | Test | - |:------------:|:----------------------------------------------------------------| - | '<' | Whether the `mtime` at `path0` is less than that at `path1`. | - | '=' | Whether the `mtime` at `path0` is equal to that at `path1`. | - | '>' | Whether the `mtime` at `path0` is greater than that at `path1`. | - -* This test operates on the content of each of the entities at `path0` and - `path1`, and returns a `true` or `false`; returns `false` if either entity - does not exist: - - | Character | Test | - |:------------:|:----------------------------------------------| - | '-' | Whether the entities exist and are identical. | - -## then() [](#method-i-then) -call-seq: - obj.then {|x| block } -> an_object - - Yields self to the block and returns the result of the block. - - 3.next.then {|x| x**x }.to_s #=> "256" - - A good use of +then+ is value piping in method chains: - - require 'open-uri' - require 'json' - - construct_url(arguments) - .then {|url| URI(url).read } - .then {|response| JSON.parse(response) } - - When called without a block, the method returns an +Enumerator+, - which can be used, for example, for conditional - circuit-breaking: - - # Meets condition, no-op - 1.then.detect(&:odd?) # => 1 - # Does not meet condition, drop value - 2.then.detect(&:odd?) # => nil - -**@yield** [_self] - -**@yieldparam** [Kernel] the object that the method was called on - -## throw(*args) [](#method-i-throw) -Transfers control to the end of the active `catch` block waiting for *tag*. -Raises `UncaughtThrowError` if there is no `catch` block for the *tag*. The -optional second parameter supplies a return value for the `catch` block, which -otherwise defaults to `nil`. For examples, see Kernel::catch. - -**@overload** [] - -## trace_var(*a, _) [](#method-i-trace_var) -Controls tracing of assignments to global variables. The parameter `symbol` -identifies the variable (as either a string name or a symbol identifier). -*cmd* (which may be a string or a `Proc` object) or block is executed whenever -the variable is assigned. The block or `Proc` object receives the variable's -new value as a parameter. Also see #untrace_var. - - trace_var :$_, proc {|v| puts "$_ is now '#{v}'" } - $_ = "hello" - $_ = ' there' - -*produces:* - - $_ is now 'hello' - $_ is now ' there' - -**@overload** [] - -**@overload** [] - -## trap(*args) [](#method-i-trap) -Specifies the handling of signals. The first parameter is a signal name (a -string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The -characters ``SIG'' may be omitted from the signal name. The command or block -specifies code to be run when the signal is raised. If the command is the -string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command -is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If -the command is ``EXIT'', the script will be terminated by the signal. If the -command is ``SYSTEM_DEFAULT'', the operating system's default handler will be -invoked. Otherwise, the given command or block will be run. The special signal -name ``EXIT'' or signal number zero will be invoked just prior to program -termination. trap returns the previous handler for the given signal. - - Signal.trap(0, proc { puts "Terminating: #{$$}" }) - Signal.trap("CLD") { puts "Child died" } - fork && Process.wait - -*produces:* - Terminating: 27461 - Child died - Terminating: 27460 - -**@overload** [] - -**@overload** [] - -## untrace_var(*a, _) [](#method-i-untrace_var) -Removes tracing for the specified command on the given global variable and -returns `nil`. If no command is specified, removes all tracing for that -variable and returns an array containing the commands actually removed. - -**@overload** [] - diff --git a/example/ruby/BasicObjectSpecs/IVars.md b/example/ruby/BasicObjectSpecs/IVars.md deleted file mode 100644 index 758e183..0000000 --- a/example/ruby/BasicObjectSpecs/IVars.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: BasicObjectSpecs::IVars -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [IVars] a new instance of IVars - diff --git a/example/ruby/BasicObjectSpecs/InstEval.md b/example/ruby/BasicObjectSpecs/InstEval.md deleted file mode 100644 index d54c3bf..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar.md b/example/ruby/BasicObjectSpecs/InstEval/CVar.md deleted file mode 100644 index 32fe045..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::CVar - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Get.md deleted file mode 100644 index aeee985..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::CVar::Get - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/BlockDefinitionScope.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/BlockDefinitionScope.md deleted file mode 100644 index f74c444..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/BlockDefinitionScope.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::CVar::Get::BlockDefinitionScope -**Inherits:** Object - - - - - -#Instance Methods -## block() [](#method-i-block) - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/CallerScope.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/CallerScope.md deleted file mode 100644 index 06ef2c9..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/CallerScope.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::CVar::Get::CallerScope -**Inherits:** Object - - - - - -#Instance Methods -## get_class_variable_with_block(obj, block) [](#method-i-get_class_variable_with_block) - -## get_class_variable_with_string(obj) [](#method-i-get_class_variable_with_string) - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/CallerWithoutCVarScope.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/CallerWithoutCVarScope.md deleted file mode 100644 index 7bb268e..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/CallerWithoutCVarScope.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::CVar::Get::CallerWithoutCVarScope -**Inherits:** Object - - - - - -#Instance Methods -## get_class_variable_with_string(obj) [](#method-i-get_class_variable_with_string) - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/ReceiverScope.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/ReceiverScope.md deleted file mode 100644 index cb5c38f..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Get/ReceiverScope.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::CVar::Get::ReceiverScope -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Set.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Set.md deleted file mode 100644 index f100881..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Set.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::CVar::Set - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/BlockDefinitionScope.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/BlockDefinitionScope.md deleted file mode 100644 index 8667974..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/BlockDefinitionScope.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::CVar::Set::BlockDefinitionScope -**Inherits:** Object - - - - -# Class Methods -## get_class_variable() [](#method-c-get_class_variable) - -#Instance Methods -## block_to_assign(value) [](#method-i-block_to_assign) - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/CallerScope.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/CallerScope.md deleted file mode 100644 index 3073820..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/CallerScope.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::CVar::Set::CallerScope -**Inherits:** Object - - - - -# Class Methods -## get_class_variable() [](#method-c-get_class_variable) - -#Instance Methods -## set_class_variable_with_block(obj, block) [](#method-i-set_class_variable_with_block) - -## set_class_variable_with_string(obj, value) [](#method-i-set_class_variable_with_string) - diff --git a/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/ReceiverScope.md b/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/ReceiverScope.md deleted file mode 100644 index 3ad4d53..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/CVar/Set/ReceiverScope.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::CVar::Set::ReceiverScope -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants.md b/example/ruby/BasicObjectSpecs/InstEval/Constants.md deleted file mode 100644 index 2a77207..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass.md deleted file mode 100644 index ffe09e4..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope.md deleted file mode 100644 index 86c9d4e..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass::CallerScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope/Caller.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope/Caller.md deleted file mode 100644 index 78525f3..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope/Caller.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass::CallerScope::Caller -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass::CallerScope::CallerParent - - - - - -#Instance Methods -## get_constant_with_string(receiver) [](#method-i-get_constant_with_string) - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope/CallerParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope/CallerParent.md deleted file mode 100644 index 556c2f8..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/CallerScope/CallerParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass::CallerScope::CallerParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope.md deleted file mode 100644 index 1fd3a3d..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass::ReceiverScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope/Receiver.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope/Receiver.md deleted file mode 100644 index 7fe10c4..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope/Receiver.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass::ReceiverScope::Receiver -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass::ReceiverScope::ReceiverParent - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope/ReceiverParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope/ReceiverParent.md deleted file mode 100644 index 5226f7f..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerClass/ReceiverScope/ReceiverParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInCallerClass::ReceiverScope::ReceiverParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes.md deleted file mode 100644 index d97d874..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope.md deleted file mode 100644 index 87efbb1..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes::CallerScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope/Caller.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope/Caller.md deleted file mode 100644 index adca388..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope/Caller.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes::CallerScope::Caller -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes::CallerScope::CallerParent - - - - - -#Instance Methods -## get_constant_with_string(receiver) [](#method-i-get_constant_with_string) -FOO is not declared in a caller class - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope/CallerParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope/CallerParent.md deleted file mode 100644 index 0b7f312..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/CallerScope/CallerParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes::CallerScope::CallerParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope.md deleted file mode 100644 index 854b4f3..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes::ReceiverScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope/Receiver.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope/Receiver.md deleted file mode 100644 index b609464..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope/Receiver.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes::ReceiverScope::Receiver -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes::ReceiverScope::ReceiverParent - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope/ReceiverParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope/ReceiverParent.md deleted file mode 100644 index e95d6da..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInCallerOuterScopes/ReceiverScope/ReceiverParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInCallerOuterScopes::ReceiverScope::ReceiverParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass.md deleted file mode 100644 index 6be35ee..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope.md deleted file mode 100644 index 0200247..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::CallerScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope/Caller.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope/Caller.md deleted file mode 100644 index 1e944e7..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope/Caller.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::CallerScope::Caller -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::CallerScope::CallerParent - - - - - -#Instance Methods -## get_constant_with_string(receiver) [](#method-i-get_constant_with_string) - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope/CallerParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope/CallerParent.md deleted file mode 100644 index 95af4b9..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/CallerScope/CallerParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::CallerScope::CallerParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope.md deleted file mode 100644 index 8f8d009..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::ReceiverScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope/Receiver.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope/Receiver.md deleted file mode 100644 index 19b8135..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope/Receiver.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::ReceiverScope::Receiver -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::ReceiverScope::ReceiverParent - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope/ReceiverParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope/ReceiverParent.md deleted file mode 100644 index 1a83958..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverClass/ReceiverScope/ReceiverParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::ReceiverScope::ReceiverParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass.md deleted file mode 100644 index 30fef1c..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope.md deleted file mode 100644 index 00c26b1..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass::CallerScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope/Caller.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope/Caller.md deleted file mode 100644 index 31d4513..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope/Caller.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass::CallerScope::Caller -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass::CallerScope::CallerParent - - - - - -#Instance Methods -## get_constant_with_string(receiver) [](#method-i-get_constant_with_string) -FOO is not declared in a caller class - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope/CallerParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope/CallerParent.md deleted file mode 100644 index 3bd48a7..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/CallerScope/CallerParent.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass::CallerScope::CallerParent -**Inherits:** Object - - -FOO is not declared in a caller outer scopes - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope.md deleted file mode 100644 index 2662c34..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass::ReceiverScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope/Receiver.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope/Receiver.md deleted file mode 100644 index 2ff436d..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope/Receiver.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass::ReceiverScope::Receiver -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass::ReceiverScope::ReceiverParent - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope/ReceiverParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope/ReceiverParent.md deleted file mode 100644 index 63151e5..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverParentClass/ReceiverScope/ReceiverParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverParentClass::ReceiverScope::ReceiverParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass.md deleted file mode 100644 index 6e74894..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope.md deleted file mode 100644 index d4120fa..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass::CallerScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope/Caller.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope/Caller.md deleted file mode 100644 index 103f61d..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope/Caller.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass::CallerScope::Caller -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass::CallerScope::CallerParent - - - - - -#Instance Methods -## get_constant_with_string(receiver) [](#method-i-get_constant_with_string) - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope/CallerParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope/CallerParent.md deleted file mode 100644 index 0919b56..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/CallerScope/CallerParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass::CallerScope::CallerParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope.md deleted file mode 100644 index 4a1bb6b..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass::ReceiverScope - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope/Receiver.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope/Receiver.md deleted file mode 100644 index dbc87d3..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope/Receiver.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass::ReceiverScope::Receiver -**Inherits:** BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass::ReceiverScope::ReceiverParent - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Receiver] a new instance of Receiver - diff --git a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope/ReceiverParent.md b/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope/ReceiverParent.md deleted file mode 100644 index d613b28..0000000 --- a/example/ruby/BasicObjectSpecs/InstEval/Constants/ConstantInReceiverSingletonClass/ReceiverScope/ReceiverParent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEval::Constants::ConstantInReceiverSingletonClass::ReceiverScope::ReceiverParent -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEvalConst.md b/example/ruby/BasicObjectSpecs/InstEvalConst.md deleted file mode 100644 index 0d663af..0000000 --- a/example/ruby/BasicObjectSpecs/InstEvalConst.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BasicObjectSpecs::InstEvalConst -**Inherits:** Object - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEvalOuter.md b/example/ruby/BasicObjectSpecs/InstEvalOuter.md deleted file mode 100644 index 1600ccf..0000000 --- a/example/ruby/BasicObjectSpecs/InstEvalOuter.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEvalOuter - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstEvalOuter/Inner.md b/example/ruby/BasicObjectSpecs/InstEvalOuter/Inner.md deleted file mode 100644 index 592103a..0000000 --- a/example/ruby/BasicObjectSpecs/InstEvalOuter/Inner.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BasicObjectSpecs::InstEvalOuter::Inner - - - - - diff --git a/example/ruby/BasicObjectSpecs/InstExec.md b/example/ruby/BasicObjectSpecs/InstExec.md deleted file mode 100644 index f7ff022..0000000 --- a/example/ruby/BasicObjectSpecs/InstExec.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: BasicObjectSpecs::InstExec - - - - -# Class Methods -## included(base ) [](#method-c-included) -**@private** [] - - diff --git a/example/ruby/BasicObjectSpecs/InstExecIncluded.md b/example/ruby/BasicObjectSpecs/InstExecIncluded.md deleted file mode 100644 index 5ff1020..0000000 --- a/example/ruby/BasicObjectSpecs/InstExecIncluded.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: BasicObjectSpecs::InstExecIncluded - -**Includes:** BasicObjectSpecs::InstExec - - - - - diff --git a/example/ruby/BasicObjectSpecs/SingletonMethod.md b/example/ruby/BasicObjectSpecs/SingletonMethod.md deleted file mode 100644 index 4acd085..0000000 --- a/example/ruby/BasicObjectSpecs/SingletonMethod.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: BasicObjectSpecs::SingletonMethod -**Inherits:** Object - - - - -# Class Methods -## singleton_method_added(name ) [](#method-c-singleton_method_added) -## singleton_method_to_alias() [](#method-c-singleton_method_to_alias) - diff --git a/example/ruby/BasicSocket.md b/example/ruby/BasicSocket.md deleted file mode 100644 index 460dd4d..0000000 --- a/example/ruby/BasicSocket.md +++ /dev/null @@ -1,514 +0,0 @@ -# Class: BasicSocket -**Inherits:** IO - - -BasicSocket is the super class for all the Socket classes. - - -# Class Methods -## do_not_reverse_lookup() [](#method-c-do_not_reverse_lookup) -Gets the global do_not_reverse_lookup flag. - - BasicSocket.do_not_reverse_lookup #=> false -**@overload** [] - -## do_not_reverse_lookup=(val ) [](#method-c-do_not_reverse_lookup=) -Sets the global do_not_reverse_lookup flag. - -The flag is used for initial value of do_not_reverse_lookup for each socket. - - s1 = TCPSocket.new("localhost", 80) - p s1.do_not_reverse_lookup #=> true - BasicSocket.do_not_reverse_lookup = false - s2 = TCPSocket.new("localhost", 80) - p s2.do_not_reverse_lookup #=> false - p s1.do_not_reverse_lookup #=> true -**@overload** [] - -## for_fd(_descriptor ) [](#method-c-for_fd) -Returns a socket object which contains the file descriptor, *fd*. - - # If invoked by inetd, STDIN/STDOUT/STDERR is a socket. - STDIN_SOCK = Socket.for_fd(STDIN.fileno) - p STDIN_SOCK.remote_address -**@overload** [] - - -#Instance Methods -## close_read() [](#method-i-close_read) -Disallows further read using shutdown system call. - - s1, s2 = UNIXSocket.pair - s1.close_read - s2.puts #=> Broken pipe (Errno::EPIPE) - -**@overload** [] - -## close_write() [](#method-i-close_write) -Disallows further write using shutdown system call. - - UNIXSocket.pair {|s1, s2| - s1.print "ping" - s1.close_write - p s2.read #=> "ping" - s2.print "pong" - s2.close - p s1.read #=> "pong" - } - -**@overload** [] - -## connect_address() [](#method-i-connect_address) -Returns an address of the socket suitable for connect in the local machine. - -This method returns *self*.local_address, except following condition. - -* IPv4 unspecified address (0.0.0.0) is replaced by IPv4 loopback address - (127.0.0.1). -* IPv6 unspecified address (::) is replaced by IPv6 loopback address (::1). - -If the local address is not suitable for connect, SocketError is raised. IPv4 -and IPv6 address which port is 0 is not suitable for connect. Unix domain -socket which has no path is not suitable for connect. - - Addrinfo.tcp("0.0.0.0", 0).listen {|serv| - p serv.connect_address #=> # - serv.connect_address.connect {|c| - s, _ = serv.accept - p [c, s] #=> [#, #] - } - } - -## do_not_reverse_lookup() [](#method-i-do_not_reverse_lookup) -Gets the do_not_reverse_lookup flag of *basicsocket*. - - require 'socket' - - BasicSocket.do_not_reverse_lookup = false - TCPSocket.open("www.ruby-lang.org", 80) {|sock| - p sock.do_not_reverse_lookup #=> false - } - BasicSocket.do_not_reverse_lookup = true - TCPSocket.open("www.ruby-lang.org", 80) {|sock| - p sock.do_not_reverse_lookup #=> true - } - -**@overload** [] - -## do_not_reverse_lookup=(state) [](#method-i-do_not_reverse_lookup=) -Sets the do_not_reverse_lookup flag of *basicsocket*. - - TCPSocket.open("www.ruby-lang.org", 80) {|sock| - p sock.do_not_reverse_lookup #=> true - p sock.peeraddr #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] - sock.do_not_reverse_lookup = false - p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "54.163.249.195"] - } - -**@overload** [] - -## getpeereid() [](#method-i-getpeereid) -Returns the user and group on the peer of the UNIX socket. The result is a two -element array which contains the effective uid and the effective gid. - - Socket.unix_server_loop("/tmp/sock") {|s| - begin - euid, egid = s.getpeereid - - # Check the connected client is myself or not. - next if euid != Process.uid - - # do something about my resource. - - ensure - s.close - end - } - -**@overload** [] - -## getpeername() [](#method-i-getpeername) -Returns the remote address of the socket as a sockaddr string. - - TCPServer.open("127.0.0.1", 1440) {|serv| - c = TCPSocket.new("127.0.0.1", 1440) - s = serv.accept - p s.getpeername #=> "\x02\x00\x82u\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" - } - -If Addrinfo object is preferred over the binary string, use -BasicSocket#remote_address. - -**@overload** [] - -## getsockname() [](#method-i-getsockname) -Returns the local address of the socket as a sockaddr string. - - TCPServer.open("127.0.0.1", 15120) {|serv| - p serv.getsockname #=> "\x02\x00;\x10\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" - } - -If Addrinfo object is preferred over the binary string, use -BasicSocket#local_address. - -**@overload** [] - -## getsockopt(lev, optname) [](#method-i-getsockopt) -Gets a socket option. These are protocol and system specific, see your local -system documentation for details. The option is returned as a Socket::Option -object. - -### Parameters -* `level` is an integer, usually one of the SOL_ constants such as - Socket::SOL_SOCKET, or a protocol level. A string or symbol of the name, - possibly without prefix, is also accepted. -* `optname` is an integer, usually one of the SO_ constants, such as - Socket::SO_REUSEADDR. A string or symbol of the name, possibly without - prefix, is also accepted. - -### Examples - -Some socket options are integers with boolean values, in this case #getsockopt -could be called like this: - - reuseaddr = sock.getsockopt(:SOCKET, :REUSEADDR).bool - - optval = sock.getsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR) - optval = optval.unpack "i" - reuseaddr = optval[0] == 0 ? false : true - -Some socket options are integers with numeric values, in this case #getsockopt -could be called like this: - - ipttl = sock.getsockopt(:IP, :TTL).int - - optval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) - ipttl = optval.unpack1("i") - -Option values may be structs. Decoding them can be complex as it involves -examining your system headers to determine the correct definition. An example -is a +struct linger+, which may be defined in your system headers as: - struct linger { - int l_onoff; - int l_linger; - }; - -In this case #getsockopt could be called like this: - - # Socket::Option knows linger structure. - onoff, linger = sock.getsockopt(:SOCKET, :LINGER).linger - - optval = sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER) - onoff, linger = optval.unpack "ii" - onoff = onoff == 0 ? false : true - -**@overload** [] - -## local_address() [](#method-i-local_address) -Returns an Addrinfo object for local address obtained by getsockname. - -Note that addrinfo.protocol is filled by 0. - - TCPSocket.open("www.ruby-lang.org", 80) {|s| - p s.local_address #=> # - } - - TCPServer.open("127.0.0.1", 1512) {|serv| - p serv.local_address #=> # - } - -**@overload** [] - -## read_nonblock(len, strnil, exception:true) [](#method-i-read_nonblock) -:nodoc: - -## recv(*args) [](#method-i-recv) -Receives a message. - -*maxlen* is the maximum number of bytes to receive. - -*flags* should be a bitwise OR of Socket::MSG_* constants. - -*outbuf* will contain only the received data after the method call even if it -is not empty at the beginning. - - UNIXSocket.pair {|s1, s2| - s1.puts "Hello World" - p s2.recv(4) #=> "Hell" - p s2.recv(4, Socket::MSG_PEEK) #=> "o Wo" - p s2.recv(4) #=> "o Wo" - p s2.recv(10) #=> "rld\n" - } - -**@overload** [] - -## recv_nonblock(len, flag0, strnil, exception:true) [](#method-i-recv_nonblock) -call-seq: basicsocket.recv_nonblock(maxlen [, flags [, buf [, options ]]]) => -mesg - -Receives up to *maxlen* bytes from `socket` using recvfrom(2) after O_NONBLOCK -is set for the underlying file descriptor. *flags* is zero or more of the -`MSG_` options. The result, *mesg*, is the data received. - -When recvfrom(2) returns 0, Socket#recv_nonblock returns nil. In most cases it -means the connection was closed, but for UDP connections it may mean an empty -packet was received, as the underlying API makes it impossible to distinguish -these two cases. - -### Parameters -* `maxlen` - the number of bytes to receive from the socket -* `flags` - zero or more of the `MSG_` options -* `buf` - destination String buffer -* `options` - keyword hash, supporting `exception: false` - -### Example - serv = TCPServer.new("127.0.0.1", 0) af, port, host, addr = serv.addr c = -TCPSocket.new(addr, port) s = serv.accept c.send "aaa", 0 begin # emulate -blocking recv. p s.recv_nonblock(10) #=> "aaa" rescue IO::WaitReadable -[IO.select(](s)) retry end - -Refer to Socket#recvfrom for the exceptions that may be thrown if the call to -*recv_nonblock* fails. - -BasicSocket#recv_nonblock may raise any error corresponding to recvfrom(2) -failure, including Errno::EWOULDBLOCK. - -If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, it is extended by -IO::WaitReadable. So IO::WaitReadable can be used to rescue the exceptions for -retrying recv_nonblock. - -By specifying a keyword argument *exception* to `false`, you can indicate that -recv_nonblock should not raise an IO::WaitReadable exception, but return the -symbol `:wait_readable` instead. - -### See -* Socket#recvfrom - -## recvmsg(dlennil, flags0, clennil, scm_rights:false) [](#method-i-recvmsg) -call-seq: - basicsocket.recvmsg(maxmesglen=nil, flags=0, maxcontrollen=nil, opts={}) => [mesg, sender_addrinfo, rflags, *controls] - -recvmsg receives a message using recvmsg(2) system call in blocking manner. - -*maxmesglen* is the maximum length of mesg to receive. - -*flags* is bitwise OR of MSG_* constants such as Socket::MSG_PEEK. - -*maxcontrollen* is the maximum length of controls (ancillary data) to receive. - -*opts* is option hash. Currently :scm_rights=>bool is the only option. - -:scm_rights option specifies that application expects SCM_RIGHTS control -message. If the value is nil or false, application don't expects SCM_RIGHTS -control message. In this case, recvmsg closes the passed file descriptors -immediately. This is the default behavior. - -If :scm_rights value is neither nil nor false, application expects SCM_RIGHTS -control message. In this case, recvmsg creates IO objects for each file -descriptors for Socket::AncillaryData#unix_rights method. - -The return value is 4-elements array. - -*mesg* is a string of the received message. - -*sender_addrinfo* is a sender socket address for connection-less socket. It is -an Addrinfo object. For connection-oriented socket such as TCP, -sender_addrinfo is platform dependent. - -*rflags* is a flags on the received message which is bitwise OR of MSG_* -constants such as Socket::MSG_TRUNC. It will be nil if the system uses 4.3BSD -style old recvmsg system call. - -*controls* is ancillary data which is an array of Socket::AncillaryData -objects such as: - - # - -*maxmesglen* and *maxcontrollen* can be nil. In that case, the buffer will be -grown until the message is not truncated. Internally, MSG_PEEK is used. Buffer -full and MSG_CTRUNC are checked for truncation. - -recvmsg can be used to implement recv_io as follows: - - mesg, sender_sockaddr, rflags, *controls = sock.recvmsg(:scm_rights=>true) - controls.each {|ancdata| - if ancdata.cmsg_is?(:SOCKET, :RIGHTS) - return ancdata.unix_rights[0] - end - } - -## recvmsg_nonblock(dlennil, flags0, clennil, scm_rights:false, exception:true) [](#method-i-recvmsg_nonblock) -call-seq: - basicsocket.recvmsg_nonblock(maxdatalen=nil, flags=0, maxcontrollen=nil, opts={}) => [data, sender_addrinfo, rflags, *controls] - -recvmsg receives a message using recvmsg(2) system call in non-blocking -manner. - -It is similar to BasicSocket#recvmsg but non-blocking flag is set before the -system call and it doesn't retry the system call. - -By specifying a keyword argument *exception* to `false`, you can indicate that -recvmsg_nonblock should not raise an IO::WaitReadable exception, but return -the symbol `:wait_readable` instead. - -## remote_address() [](#method-i-remote_address) -Returns an Addrinfo object for remote address obtained by getpeername. - -Note that addrinfo.protocol is filled by 0. - - TCPSocket.open("www.ruby-lang.org", 80) {|s| - p s.remote_address #=> # - } - - TCPServer.open("127.0.0.1", 1728) {|serv| - c = TCPSocket.new("127.0.0.1", 1728) - s = serv.accept - p s.remote_address #=> # - } - -**@overload** [] - -## send(*args) [](#method-i-send) -send *mesg* via *basicsocket*. - -*mesg* should be a string. - -*flags* should be a bitwise OR of Socket::MSG_* constants. - -*dest_sockaddr* should be a packed sockaddr string or an addrinfo. - - TCPSocket.open("localhost", 80) {|s| - s.send "GET / HTTP/1.0\r\n\r\n", 0 - p s.read - } - -**@overload** [] - -## sendmsg(mesg, flags0, dest_sockaddrnil, *controls) [](#method-i-sendmsg) -call-seq: - basicsocket.sendmsg(mesg, flags=0, dest_sockaddr=nil, *controls) => numbytes_sent - -sendmsg sends a message using sendmsg(2) system call in blocking manner. - -*mesg* is a string to send. - -*flags* is bitwise OR of MSG_* constants such as Socket::MSG_OOB. - -*dest_sockaddr* is a destination socket address for connection-less socket. It -should be a sockaddr such as a result of Socket.sockaddr_in. An Addrinfo -object can be used too. - -*controls* is a list of ancillary data. The element of *controls* should be -Socket::AncillaryData or 3-elements array. The 3-element array should contains -cmsg_level, cmsg_type and data. - -The return value, *numbytes_sent* is an integer which is the number of bytes -sent. - -sendmsg can be used to implement send_io as follows: - - # use Socket::AncillaryData. - ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, io.fileno) - sock.sendmsg("a", 0, nil, ancdata) - - # use 3-element array. - ancdata = [:SOCKET, :RIGHTS, [io.fileno].pack("i!")] - sock.sendmsg("\0", 0, nil, ancdata) - -## sendmsg_nonblock(mesg, flags0, dest_sockaddrnil, *controls, exception:true) [](#method-i-sendmsg_nonblock) -call-seq: - basicsocket.sendmsg_nonblock(mesg, flags=0, dest_sockaddr=nil, *controls, opts={}) => numbytes_sent - -sendmsg_nonblock sends a message using sendmsg(2) system call in non-blocking -manner. - -It is similar to BasicSocket#sendmsg but the non-blocking flag is set before -the system call and it doesn't retry the system call. - -By specifying a keyword argument *exception* to `false`, you can indicate that -sendmsg_nonblock should not raise an IO::WaitWritable exception, but return -the symbol `:wait_writable` instead. - -## setsockopt(*args) [](#method-i-setsockopt) -Sets a socket option. These are protocol and system specific, see your local -system documentation for details. - -### Parameters -* `level` is an integer, usually one of the SOL_ constants such as - Socket::SOL_SOCKET, or a protocol level. A string or symbol of the name, - possibly without prefix, is also accepted. -* `optname` is an integer, usually one of the SO_ constants, such as - Socket::SO_REUSEADDR. A string or symbol of the name, possibly without - prefix, is also accepted. -* `optval` is the value of the option, it is passed to the underlying - setsockopt() as a pointer to a certain number of bytes. How this is done - depends on the type: - * Integer: value is assigned to an int, and a pointer to the int is - passed, with length of sizeof(int). - * true or false: 1 or 0 (respectively) is assigned to an int, and the - int is passed as for an Integer. Note that `false` must be passed, not - `nil`. - * String: the string's data and length is passed to the socket. -* `socketoption` is an instance of Socket::Option - -### Examples - -Some socket options are integers with boolean values, in this case #setsockopt -could be called like this: - sock.setsockopt(:SOCKET, :REUSEADDR, true) - sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true) - sock.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true)) - -Some socket options are integers with numeric values, in this case #setsockopt -could be called like this: - sock.setsockopt(:IP, :TTL, 255) - sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255) - sock.setsockopt(Socket::Option.int(:INET, :IP, :TTL, 255)) - -Option values may be structs. Passing them can be complex as it involves -examining your system headers to determine the correct definition. An example -is an `ip_mreq`, which may be defined in your system headers as: - struct ip_mreq { - struct in_addr imr_multiaddr; - struct in_addr imr_interface; - }; - -In this case #setsockopt could be called like this: - optval = IPAddr.new("224.0.0.251").hton + - IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton - sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, optval) - -**@overload** [] - -**@overload** [] - -## shutdown(*args) [](#method-i-shutdown) -Calls shutdown(2) system call. - -s.shutdown(Socket::SHUT_RD) disallows further read. - -s.shutdown(Socket::SHUT_WR) disallows further write. - -s.shutdown(Socket::SHUT_RDWR) disallows further read and write. - -*how* can be symbol or string: -* :RD, :SHUT_RD, "RD" and "SHUT_RD" are accepted as Socket::SHUT_RD. -* :WR, :SHUT_WR, "WR" and "SHUT_WR" are accepted as Socket::SHUT_WR. -* :RDWR, :SHUT_RDWR, "RDWR" and "SHUT_RDWR" are accepted as - Socket::SHUT_RDWR. - - UNIXSocket.pair {|s1, s2| - s1.puts "ping" - s1.shutdown(:WR) - p s2.read #=> "ping\n" - s2.puts "pong" - s2.close - p s1.read #=> "pong\n" - - } - -**@overload** [] - -## write_nonblock(buf, exception:true) [](#method-i-write_nonblock) -:nodoc: - diff --git a/example/ruby/BeAnInOfSpecs.md b/example/ruby/BeAnInOfSpecs.md deleted file mode 100644 index 2e44cd9..0000000 --- a/example/ruby/BeAnInOfSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BeAnInOfSpecs - - - - - diff --git a/example/ruby/BeAnInOfSpecs/A.md b/example/ruby/BeAnInOfSpecs/A.md deleted file mode 100644 index 571830f..0000000 --- a/example/ruby/BeAnInOfSpecs/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BeAnInOfSpecs::A -**Inherits:** Object - - - - - diff --git a/example/ruby/BeAnInOfSpecs/B.md b/example/ruby/BeAnInOfSpecs/B.md deleted file mode 100644 index 2c76399..0000000 --- a/example/ruby/BeAnInOfSpecs/B.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BeAnInOfSpecs::B -**Inherits:** BeAnInOfSpecs::A - - - - - diff --git a/example/ruby/BeAnInOfSpecs/C.md b/example/ruby/BeAnInOfSpecs/C.md deleted file mode 100644 index 498cc79..0000000 --- a/example/ruby/BeAnInOfSpecs/C.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BeAnInOfSpecs::C -**Inherits:** BeAnInOfSpecs::B - - - - - diff --git a/example/ruby/BeAnInstanceOfMatcher.md b/example/ruby/BeAnInstanceOfMatcher.md deleted file mode 100644 index 0e8be56..0000000 --- a/example/ruby/BeAnInstanceOfMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: BeAnInstanceOfMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected) [](#method-i-initialize) - -**@return** [BeAnInstanceOfMatcher] a new instance of BeAnInstanceOfMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeAncestorOfMatcher.md b/example/ruby/BeAncestorOfMatcher.md deleted file mode 100644 index 010b853..0000000 --- a/example/ruby/BeAncestorOfMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: BeAncestorOfMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected) [](#method-i-initialize) - -**@return** [BeAncestorOfMatcher] a new instance of BeAncestorOfMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeCloseMatcher.md b/example/ruby/BeCloseMatcher.md deleted file mode 100644 index 281561f..0000000 --- a/example/ruby/BeCloseMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: BeCloseMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected, tolerance) [](#method-i-initialize) - -**@return** [BeCloseMatcher] a new instance of BeCloseMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeCloseToMatrixMatcher.md b/example/ruby/BeCloseToMatrixMatcher.md deleted file mode 100644 index 23d45fb..0000000 --- a/example/ruby/BeCloseToMatrixMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: BeCloseToMatrixMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected, toleranceTOLERANCE) [](#method-i-initialize) - -**@return** [BeCloseToMatrixMatcher] a new instance of BeCloseToMatrixMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeComputedByMatcher.md b/example/ruby/BeComputedByMatcher.md deleted file mode 100644 index 0b1a13b..0000000 --- a/example/ruby/BeComputedByMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: BeComputedByMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(sym, *args) [](#method-i-initialize) - -**@return** [BeComputedByMatcher] a new instance of BeComputedByMatcher - -## matches?(array) [](#method-i-matches?) - -**@return** [Boolean] - -## method_call() [](#method-i-method_call) - diff --git a/example/ruby/BeEmptyMatcher.md b/example/ruby/BeEmptyMatcher.md deleted file mode 100644 index d024d53..0000000 --- a/example/ruby/BeEmptyMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: BeEmptyMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeFalseMatcher.md b/example/ruby/BeFalseMatcher.md deleted file mode 100644 index 28b2131..0000000 --- a/example/ruby/BeFalseMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: BeFalseMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeKindOfMatcher.md b/example/ruby/BeKindOfMatcher.md deleted file mode 100644 index 7590232..0000000 --- a/example/ruby/BeKindOfMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: BeKindOfMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected) [](#method-i-initialize) - -**@return** [BeKindOfMatcher] a new instance of BeKindOfMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeNaNMatcher.md b/example/ruby/BeNaNMatcher.md deleted file mode 100644 index b027765..0000000 --- a/example/ruby/BeNaNMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: BeNaNMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeNilMatcher.md b/example/ruby/BeNilMatcher.md deleted file mode 100644 index 1321030..0000000 --- a/example/ruby/BeNilMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: BeNilMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeTrueMatcher.md b/example/ruby/BeTrueMatcher.md deleted file mode 100644 index 0b809a8..0000000 --- a/example/ruby/BeTrueMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: BeTrueMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/BeTrueOrFalseMatcher.md b/example/ruby/BeTrueOrFalseMatcher.md deleted file mode 100644 index 8784f28..0000000 --- a/example/ruby/BeTrueOrFalseMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: BeTrueOrFalseMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/Benchmark.md b/example/ruby/Benchmark.md deleted file mode 100644 index db51afd..0000000 --- a/example/ruby/Benchmark.md +++ /dev/null @@ -1,224 +0,0 @@ -# Module: Benchmark - - -The Benchmark module provides methods to measure and report the time used to -execute Ruby code. - -* Measure the time to construct the string given by the expression - `"a"*1_000_000_000`: - - require 'benchmark' - - puts Benchmark.measure { "a"*1_000_000_000 } - - On my machine (OSX 10.8.3 on i5 1.7 GHz) this generates: - - 0.350000 0.400000 0.750000 ( 0.835234) - - This report shows the user CPU time, system CPU time, the sum of the user - and system CPU times, and the elapsed real time. The unit of time is - seconds. - -* Do some experiments sequentially using the #bm method: - - require 'benchmark' - - n = 5000000 - Benchmark.bm do |x| - x.report { for i in 1..n; a = "1"; end } - x.report { n.times do ; a = "1"; end } - x.report { 1.upto(n) do ; a = "1"; end } - end - - The result: - - user system total real - 1.010000 0.000000 1.010000 ( 1.014479) - 1.000000 0.000000 1.000000 ( 0.998261) - 0.980000 0.000000 0.980000 ( 0.981335) - -* Continuing the previous example, put a label in each report: - - require 'benchmark' - - n = 5000000 - Benchmark.bm(7) do |x| - x.report("for:") { for i in 1..n; a = "1"; end } - x.report("times:") { n.times do ; a = "1"; end } - x.report("upto:") { 1.upto(n) do ; a = "1"; end } - end - -The result: - - user system total real - for: 1.010000 0.000000 1.010000 ( 1.015688) - times: 1.000000 0.000000 1.000000 ( 1.003611) - upto: 1.030000 0.000000 1.030000 ( 1.028098) - -* The times for some benchmarks depend on the order in which items are run. - These differences are due to the cost of memory allocation and garbage - collection. To avoid these discrepancies, the #bmbm method is provided. - For example, to compare ways to sort an array of floats: - - require 'benchmark' - - array = (1..1000000).map { rand } - - Benchmark.bmbm do |x| - x.report("sort!") { array.dup.sort! } - x.report("sort") { array.dup.sort } - end - - The result: - - Rehearsal ----------------------------------------- - sort! 1.490000 0.010000 1.500000 ( 1.490520) - sort 1.460000 0.000000 1.460000 ( 1.463025) - -------------------------------- total: 2.960000sec - - user system total real - sort! 1.460000 0.000000 1.460000 ( 1.460465) - sort 1.450000 0.010000 1.460000 ( 1.448327) - -* Report statistics of sequential experiments with unique labels, using the - #benchmark method: - - require 'benchmark' - include Benchmark # we need the CAPTION and FORMAT constants - - n = 5000000 - Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| - tf = x.report("for:") { for i in 1..n; a = "1"; end } - tt = x.report("times:") { n.times do ; a = "1"; end } - tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end } - [tf+tt+tu, (tf+tt+tu)/3] - end - - The result: - - user system total real - for: 0.950000 0.000000 0.950000 ( 0.952039) - times: 0.980000 0.000000 0.980000 ( 0.984938) - upto: 0.950000 0.000000 0.950000 ( 0.946787) - >total: 2.880000 0.000000 2.880000 ( 2.883764) - >avg: 0.960000 0.000000 0.960000 ( 0.961255) - - -# Class Methods -## benchmark(caption "", label_width nil, format nil, *labels ) [](#method-c-benchmark) -Invokes the block with a Benchmark::Report object, which may be used to -collect and report on the results of individual benchmark tests. Reserves -`label_width` leading spaces for labels on each line. Prints `caption` at the -top of the report, and uses `format` to format each line. (Note: `caption` -must contain a terminating newline character, see the default -Benchmark::Tms::CAPTION for an example.) - -Returns an array of Benchmark::Tms objects. - -If the block returns an array of Benchmark::Tms objects, these will be used to -format additional lines of output. If `labels` parameter are given, these are -used to label these extra lines. - -*Note*: Other methods provide a simpler interface to this one, and are -suitable for nearly all benchmarking requirements. See the examples in -Benchmark, and the #bm and #bmbm methods. - -Example: - - require 'benchmark' - include Benchmark # we need the CAPTION and FORMAT constants - - n = 5000000 - Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| - tf = x.report("for:") { for i in 1..n; a = "1"; end } - tt = x.report("times:") { n.times do ; a = "1"; end } - tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end } - [tf+tt+tu, (tf+tt+tu)/3] - end - -Generates: - - user system total real - for: 0.970000 0.000000 0.970000 ( 0.970493) - times: 0.990000 0.000000 0.990000 ( 0.989542) - upto: 0.970000 0.000000 0.970000 ( 0.972854) - >total: 2.930000 0.000000 2.930000 ( 2.932889) - >avg: 0.976667 0.000000 0.976667 ( 0.977630) -## bm(label_width 0, *labels , &blk ) [](#method-c-bm) -A simple interface to the #benchmark method, #bm generates sequential reports -with labels. `label_width` and `labels` parameters have the same meaning as -for #benchmark. - - require 'benchmark' - - n = 5000000 - Benchmark.bm(7) do |x| - x.report("for:") { for i in 1..n; a = "1"; end } - x.report("times:") { n.times do ; a = "1"; end } - x.report("upto:") { 1.upto(n) do ; a = "1"; end } - end - -Generates: - - user system total real - for: 0.960000 0.000000 0.960000 ( 0.957966) - times: 0.960000 0.000000 0.960000 ( 0.960423) - upto: 0.950000 0.000000 0.950000 ( 0.954864) -## bmbm(width 0) [](#method-c-bmbm) -Sometimes benchmark results are skewed because code executed earlier -encounters different garbage collection overheads than that run later. #bmbm -attempts to minimize this effect by running the tests twice, the first time as -a rehearsal in order to get the runtime environment stable, the second time -for real. GC.start is executed before the start of each of the real timings; -the cost of this is not included in the timings. In reality, though, there's -only so much that #bmbm can do, and the results are not guaranteed to be -isolated from garbage collection and other effects. - -Because #bmbm takes two passes through the tests, it can calculate the -required label width. - - require 'benchmark' - - array = (1..1000000).map { rand } - - Benchmark.bmbm do |x| - x.report("sort!") { array.dup.sort! } - x.report("sort") { array.dup.sort } - end - -Generates: - - Rehearsal ----------------------------------------- - sort! 1.440000 0.010000 1.450000 ( 1.446833) - sort 1.440000 0.000000 1.440000 ( 1.448257) - -------------------------------- total: 2.890000sec - - user system total real - sort! 1.460000 0.000000 1.460000 ( 1.458065) - sort 1.450000 0.000000 1.450000 ( 1.455963) - -#bmbm yields a Benchmark::Job object and returns an array of Benchmark::Tms -objects. -## measure(label "") [](#method-c-measure) -Returns the time used to execute the given block as a Benchmark::Tms object. -Takes `label` option. - - require 'benchmark' - - n = 1000000 - - time = Benchmark.measure do - n.times { a = "1" } - end - puts time - -Generates: - - 0.220000 0.000000 0.220000 ( 0.227313) -## realtime() [](#method-c-realtime) -Returns the elapsed real time used to execute the given block. The unit of -time is seconds. - - Benchmark.realtime { "a" * 1_000_000_000 } - #=> 0.5098029999935534 - diff --git a/example/ruby/Benchmark/Job.md b/example/ruby/Benchmark/Job.md deleted file mode 100644 index 6b27f2b..0000000 --- a/example/ruby/Benchmark/Job.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Benchmark::Job -**Inherits:** Object - - -A Job is a sequence of labelled blocks to be processed by the Benchmark.bmbm -method. It is of little direct interest to the user. - - -# Attributes -## list[RW] [](#attribute-i-list) -An array of 2-element arrays, consisting of label and block pairs. - -## width[RW] [](#attribute-i-width) -Length of the widest label in the #list. - - -#Instance Methods -## initialize(width) [](#method-i-initialize) -Returns an initialized Job instance. Usually, one doesn't call this method -directly, as new Job objects are created by the #bmbm method. `width` is a -initial value for the label offset used in formatting; the #bmbm method passes -its `width` argument to this constructor. - -**@return** [Job] a new instance of Job - -## item(label"", &blk) [](#method-i-item) -Registers the given label and block pair in the job list. - -**@raise** [ArgumentError] - diff --git a/example/ruby/Benchmark/Report.md b/example/ruby/Benchmark/Report.md deleted file mode 100644 index e7386b5..0000000 --- a/example/ruby/Benchmark/Report.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Benchmark::Report -**Inherits:** Object - - -This class is used by the Benchmark.benchmark and Benchmark.bm methods. It is -of little direct interest to the user. - - -# Attributes -## format[RW] [](#attribute-i-format) -An array of Benchmark::Tms objects representing each item. - -## list[RW] [](#attribute-i-list) -An array of Benchmark::Tms objects representing each item. - -## width[RW] [](#attribute-i-width) -An array of Benchmark::Tms objects representing each item. - - -#Instance Methods -## initialize(width0, formatnil) [](#method-i-initialize) -Returns an initialized Report instance. Usually, one doesn't call this method -directly, as new Report objects are created by the #benchmark and #bm methods. -`width` and `format` are the label offset and format string used by -Tms#format. - -**@return** [Report] a new instance of Report - -## item(label"", *format, &blk) [](#method-i-item) -Prints the `label` and measured time for the block, formatted by `format`. See -Tms#format for the formatting rules. - diff --git a/example/ruby/Benchmark/Tms.md b/example/ruby/Benchmark/Tms.md deleted file mode 100644 index 787ce56..0000000 --- a/example/ruby/Benchmark/Tms.md +++ /dev/null @@ -1,109 +0,0 @@ -# Class: Benchmark::Tms -**Inherits:** Object - - -A data object, representing the times associated with a benchmark measurement. - - -# Attributes -## cstime[RW] [](#attribute-i-cstime) -System CPU time of children - -## cutime[RW] [](#attribute-i-cutime) -User CPU time of children - -## label[RW] [](#attribute-i-label) -Label - -## real[RW] [](#attribute-i-real) -Elapsed real time - -## stime[RW] [](#attribute-i-stime) -System CPU time - -## total[RW] [](#attribute-i-total) -Total time, that is `utime` + `stime` + `cutime` + `cstime` - -## utime[RW] [](#attribute-i-utime) -User CPU time - - -#Instance Methods -## *(x) [](#method-i-*) -Returns a new Tms object obtained by memberwise multiplication of the -individual times for this Tms object by `x`. - -## +(other) [](#method-i-+) -Returns a new Tms object obtained by memberwise summation of the individual -times for this Tms object with those of the `other` Tms object. This method -and #/() are useful for taking statistics. - -## -(other) [](#method-i--) -Returns a new Tms object obtained by memberwise subtraction of the individual -times for the `other` Tms object from those of this Tms object. - -## /(x) [](#method-i-/) -Returns a new Tms object obtained by memberwise division of the individual -times for this Tms object by `x`. This method and #+() are useful for taking -statistics. - -## add(&blk) [](#method-i-add) -Returns a new Tms object whose times are the sum of the times for this Tms -object, plus the time required to execute the code block (`blk`). - -## add!(&blk) [](#method-i-add!) -An in-place version of #add. Changes the times of this Tms object by making it -the sum of the times for this Tms object, plus the time required to execute -the code block (`blk`). - -## format(formatnil, *args) [](#method-i-format) -Returns the contents of this Tms object as a formatted string, according to a -`format` string like that passed to Kernel.format. In addition, #format -accepts the following extensions: - -`%u` -: Replaced by the user CPU time, as reported by Tms#utime. - -`%y` -: Replaced by the system CPU time, as reported by #stime (Mnemonic: y of - "s*y*stem") - -`%U` -: Replaced by the children's user CPU time, as reported by Tms#cutime - -`%Y` -: Replaced by the children's system CPU time, as reported by Tms#cstime - -`%t` -: Replaced by the total CPU time, as reported by Tms#total - -`%r` -: Replaced by the elapsed real time, as reported by Tms#real - -`%n` -: Replaced by the label string, as reported by Tms#label (Mnemonic: n of - "*n*ame") - - -If `format` is not given, FORMAT is used as default value, detailing the user, -system and real elapsed time. - -## initialize(utime0.0, stime0.0, cutime0.0, cstime0.0, real0.0, labelnil) [](#method-i-initialize) -Returns an initialized Tms object which has `utime` as the user CPU time, -`stime` as the system CPU time, `cutime` as the children's user CPU time, -`cstime` as the children's system CPU time, `real` as the elapsed real time -and `label` as the label. - -**@return** [Tms] a new instance of Tms - -## to_a() [](#method-i-to_a) -Returns a new 6-element array, consisting of the label, user CPU time, system -CPU time, children's user CPU time, children's system CPU time and elapsed -real time. - -## to_h() [](#method-i-to_h) -Returns a hash containing the same data as `to_a`. - -## to_s() [](#method-i-to_s) -Same as #format. - diff --git a/example/ruby/BenchmarkDriver/Output/Driver.md b/example/ruby/BenchmarkDriver/Output/Driver.md deleted file mode 100644 index c1f0117..0000000 --- a/example/ruby/BenchmarkDriver/Output/Driver.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: BenchmarkDriver::Output::Driver -**Inherits:** BenchmarkDriver::Output::Simple - - -This replicates the legacy benchmark/driver.rb behavior. - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Driver] a new instance of Driver - -## with_benchmark() [](#method-i-with_benchmark) - diff --git a/example/ruby/BenchmarkDriver/Runner/Cstime.md b/example/ruby/BenchmarkDriver/Runner/Cstime.md deleted file mode 100644 index e641913..0000000 --- a/example/ruby/BenchmarkDriver/Runner/Cstime.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BenchmarkDriver::Runner::Cstime -**Inherits:** BenchmarkDriver::Runner::Total - - - - - diff --git a/example/ruby/BenchmarkDriver/Runner/Cutime.md b/example/ruby/BenchmarkDriver/Runner/Cutime.md deleted file mode 100644 index 1df67b3..0000000 --- a/example/ruby/BenchmarkDriver/Runner/Cutime.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BenchmarkDriver::Runner::Cutime -**Inherits:** BenchmarkDriver::Runner::Total - - - - - diff --git a/example/ruby/BenchmarkDriver/Runner/Peak.md b/example/ruby/BenchmarkDriver/Runner/Peak.md deleted file mode 100644 index fa4c4fa..0000000 --- a/example/ruby/BenchmarkDriver/Runner/Peak.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: BenchmarkDriver::Runner::Peak -**Inherits:** Object - - - - - -#Instance Methods -## initialize(config:, output:, contexts:) [](#method-i-initialize) - -**@param** [BenchmarkDriver::Config::RunnerConfig] - -**@param** [BenchmarkDriver::Output] - -**@param** [BenchmarkDriver::Context] - -**@return** [Peak] a new instance of Peak - -## run(jobs) [](#method-i-run) -This method is dynamically called by `BenchmarkDriver::JobRunner.run` - -**@param** [Array] - diff --git a/example/ruby/BenchmarkDriver/Runner/Ractor.md b/example/ruby/BenchmarkDriver/Runner/Ractor.md deleted file mode 100644 index c0777a7..0000000 --- a/example/ruby/BenchmarkDriver/Runner/Ractor.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: BenchmarkDriver::Runner::Ractor -**Inherits:** BenchmarkDriver::Runner::Ips - - -A runner to measure performance **inside** Ractor - - - diff --git a/example/ruby/BenchmarkDriver/Runner/Size.md b/example/ruby/BenchmarkDriver/Runner/Size.md deleted file mode 100644 index baf7570..0000000 --- a/example/ruby/BenchmarkDriver/Runner/Size.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: BenchmarkDriver::Runner::Size -**Inherits:** BenchmarkDriver::Runner::Peak - - -Actually the same as BenchmarkDriver::Runner::Memory - - - diff --git a/example/ruby/BenchmarkDriver/Runner/Stime.md b/example/ruby/BenchmarkDriver/Runner/Stime.md deleted file mode 100644 index 0149524..0000000 --- a/example/ruby/BenchmarkDriver/Runner/Stime.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BenchmarkDriver::Runner::Stime -**Inherits:** BenchmarkDriver::Runner::Total - - - - - diff --git a/example/ruby/BenchmarkDriver/Runner/Total.md b/example/ruby/BenchmarkDriver/Runner/Total.md deleted file mode 100644 index 2cd0186..0000000 --- a/example/ruby/BenchmarkDriver/Runner/Total.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: BenchmarkDriver::Runner::Total -**Inherits:** Object - - - - - -#Instance Methods -## initialize(config:, output:, contexts:) [](#method-i-initialize) - -**@param** [BenchmarkDriver::Config::RunnerConfig] - -**@param** [BenchmarkDriver::Output] - -**@param** [BenchmarkDriver::Context] - -**@return** [Total] a new instance of Total - -## run(jobs) [](#method-i-run) -This method is dynamically called by `BenchmarkDriver::JobRunner.run` - -**@param** [Array] - diff --git a/example/ruby/BenchmarkDriver/Runner/Utime.md b/example/ruby/BenchmarkDriver/Runner/Utime.md deleted file mode 100644 index 72d126f..0000000 --- a/example/ruby/BenchmarkDriver/Runner/Utime.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: BenchmarkDriver::Runner::Utime -**Inherits:** BenchmarkDriver::Runner::Total - - - - - diff --git a/example/ruby/Biff.md b/example/ruby/Biff.md deleted file mode 100644 index dda5576..0000000 --- a/example/ruby/Biff.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Biff -**Inherits:** Object - -**Includes:** DRb::DRbObservable - - - - - -#Instance Methods -## initialize(filename, interval) [](#method-i-initialize) - -**@return** [Biff] a new instance of Biff - -## run() [](#method-i-run) - diff --git a/example/ruby/BigDecimal.md b/example/ruby/BigDecimal.md deleted file mode 100644 index 3d0944b..0000000 --- a/example/ruby/BigDecimal.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: BigDecimal -**Inherits:** Object - - - - -# Class Methods -## json_create(object ) [](#method-c-json_create) -See #as_json. - -#Instance Methods -## as_json() [](#method-i-as_json) -Methods `BigDecimal#as_json` and `BigDecimal.json_create` may be used to -serialize and deserialize a BigDecimal object; see -[Marshal](rdoc-ref:Marshal). - -Method `BigDecimal#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/bigdecimal' - x = BigDecimal(2).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"} - y = BigDecimal(2.0, 4).as_json # => {"json_class"=>"BigDecimal", "b"=>"36:0.2e1"} - z = BigDecimal(Complex(2, 0)).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"} - -Method `JSON.create` deserializes such a hash, returning a BigDecimal object: - - BigDecimal.json_create(x) # => 0.2e1 - BigDecimal.json_create(y) # => 0.2e1 - BigDecimal.json_create(z) # => 0.2e1 - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/bigdecimal' - puts BigDecimal(2).to_json - puts BigDecimal(2.0, 4).to_json - puts BigDecimal(Complex(2, 0)).to_json - -Output: - - {"json_class":"BigDecimal","b":"27:0.2e1"} - {"json_class":"BigDecimal","b":"36:0.2e1"} - {"json_class":"BigDecimal","b":"27:0.2e1"} - diff --git a/example/ruby/BigDecimalSpecs.md b/example/ruby/BigDecimalSpecs.md deleted file mode 100644 index ae570db..0000000 --- a/example/ruby/BigDecimalSpecs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: BigDecimalSpecs - - - - -# Class Methods -## with_limit(l ) [](#method-c-with_limit) -helper method to sure that the global limit is reset back -## with_rounding(r ) [](#method-c-with_rounding) - diff --git a/example/ruby/BigEndianGuard.md b/example/ruby/BigEndianGuard.md deleted file mode 100644 index 1f7c145..0000000 --- a/example/ruby/BigEndianGuard.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: BigEndianGuard -**Inherits:** EndianGuard - - - - - -#Instance Methods -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/Binding.md b/example/ruby/Binding.md deleted file mode 100644 index fc1cd5e..0000000 --- a/example/ruby/Binding.md +++ /dev/null @@ -1,122 +0,0 @@ -# Class: Binding -**Inherits:** Object - - -Objects of class Binding encapsulate the execution context at some particular -place in the code and retain this context for future use. The variables, -methods, value of `self`, and possibly an iterator block that can be accessed -in this context are all retained. Binding objects can be created using -Kernel#binding, and are made available to the callback of -Kernel#set_trace_func and instances of TracePoint. - -These binding objects can be passed as the second argument of the Kernel#eval -method, establishing an environment for the evaluation. - - class Demo - def initialize(n) - @secret = n - end - def get_binding - binding - end - end - - k1 = Demo.new(99) - b1 = k1.get_binding - k2 = Demo.new(-3) - b2 = k2.get_binding - - eval("@secret", b1) #=> 99 - eval("@secret", b2) #=> -3 - eval("@secret") #=> nil - -Binding objects have no class-specific methods. - - - -#Instance Methods -## clone() [](#method-i-clone) -:nodoc: - -## dup() [](#method-i-dup) -:nodoc: - -## eval(*args) [](#method-i-eval) -Evaluates the Ruby expression(s) in *string*, in the *binding*'s context. If -the optional *filename* and *lineno* parameters are present, they will be used -when reporting syntax errors. - - def get_binding(param) - binding - end - b = get_binding("hello") - b.eval("param") #=> "hello" - -**@overload** [] - -## local_variable_defined?(sym) [](#method-i-local_variable_defined?) -Returns `true` if a local variable `symbol` exists. - -def foo a = 1 binding.local_variable_defined?(:a) #=> true -binding.local_variable_defined?(:b) #=> false end - -This method is the short version of the following code: - -binding.eval("defined?(#{symbol}) == 'local-variable'") - -**@overload** [] - -## local_variable_get(sym) [](#method-i-local_variable_get) -Returns the value of the local variable `symbol`. - -def foo a = 1 binding.local_variable_get(:a) #=> 1 -binding.local_variable_get(:b) #=> NameError end - -This method is the short version of the following code: - -binding.eval("#{symbol}") - -**@overload** [] - -## local_variable_set(sym, val) [](#method-i-local_variable_set) -Set local variable named `symbol` as `obj`. - -def foo a = 1 bind = binding bind.local_variable_set(:a, 2) # set -existing local variable `a' bind.local_variable_set(:b, 3) # create new -local variable `b' # `b' exists only in -binding - - p bind.local_variable_get(:a) #=> 2 p bind.local_variable_get(:b) #=> -3 p a #=> 2 p b -#=> NameError end - -This method behaves similarly to the following code: - - binding.eval("#{symbol} = #{obj}") - -if `obj` can be dumped in Ruby code. - -**@overload** [] - -## local_variables() [](#method-i-local_variables) -Returns the names of the binding's local variables as symbols. - -def foo a = 1 2.times do |n| binding.local_variables #=> [:a, :n] - end end - -This method is the short version of the following code: - -binding.eval("local_variables") - -**@overload** [] - -## receiver() [](#method-i-receiver) -Returns the bound receiver of the binding object. - -**@overload** [] - -## source_location() [](#method-i-source_location) -Returns the Ruby source filename and line number of the binding object. - -**@overload** [] - diff --git a/example/ruby/BindingGenerator.md b/example/ruby/BindingGenerator.md deleted file mode 100644 index 919d162..0000000 --- a/example/ruby/BindingGenerator.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: BindingGenerator -**Inherits:** Object - - -Convert Node objects to a Ruby binding source. - - -# Attributes -## src[RW] [](#attribute-i-src) -Returns the value of attribute src. - - -#Instance Methods -## generate(nodes) [](#method-i-generate) - -## initialize(src_path:, consts:, values:, funcs:, types:, dynamic_types:, skip_fields:, ruby_fields:) [](#method-i-initialize) - -**@param** [String] - -**@param** [Hash{ Symbol => Array }] - -**@param** [Hash{ Symbol => Array }] - -**@param** [Array] - -**@param** [Array] - -**@param** [Array] #ifdef-dependent immediate types, which need Primitive.cexpr! for type detection - -**@param** [Hash{ Symbol => Array }] Struct fields that are skipped from bindgen - -**@param** [Hash{ Symbol => Array }] Struct VALUE fields that are considered Ruby objects - -**@return** [BindingGenerator] a new instance of BindingGenerator - diff --git a/example/ruby/BindingSpecs.md b/example/ruby/BindingSpecs.md deleted file mode 100644 index d0dca57..0000000 --- a/example/ruby/BindingSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BindingSpecs - - - - - diff --git a/example/ruby/BindingSpecs/AddFooToString.md b/example/ruby/BindingSpecs/AddFooToString.md deleted file mode 100644 index 6b39bd0..0000000 --- a/example/ruby/BindingSpecs/AddFooToString.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BindingSpecs::AddFooToString - - - - - diff --git a/example/ruby/BindingSpecs/Demo.md b/example/ruby/BindingSpecs/Demo.md deleted file mode 100644 index fe1a6cf..0000000 --- a/example/ruby/BindingSpecs/Demo.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: BindingSpecs::Demo -**Inherits:** Object - - - - - -#Instance Methods -## get_binding() [](#method-i-get_binding) - -## get_binding_and_line() [](#method-i-get_binding_and_line) - -## get_binding_and_method() [](#method-i-get_binding_and_method) - -## get_binding_in_block() [](#method-i-get_binding_in_block) - -## get_binding_with_send_and_line() [](#method-i-get_binding_with_send_and_line) - -## get_binding_with_send_and_method() [](#method-i-get_binding_with_send_and_method) - -## get_empty_binding() [](#method-i-get_empty_binding) - -## get_file_of_binding() [](#method-i-get_file_of_binding) - -## get_line_of_binding() [](#method-i-get_line_of_binding) - -## initialize(n) [](#method-i-initialize) - -**@return** [Demo] a new instance of Demo - -## square(n) [](#method-i-square) - diff --git a/example/ruby/BindingSpecs/LocationMethod.md b/example/ruby/BindingSpecs/LocationMethod.md deleted file mode 100644 index b8d9f22..0000000 --- a/example/ruby/BindingSpecs/LocationMethod.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BindingSpecs::LocationMethod - - - - - diff --git a/example/ruby/BindingSpecs/Refined.md b/example/ruby/BindingSpecs/Refined.md deleted file mode 100644 index f21dd46..0000000 --- a/example/ruby/BindingSpecs/Refined.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: BindingSpecs::Refined -**Inherits:** Object - - - - -# Class Methods -## refined_binding() [](#method-c-refined_binding) - diff --git a/example/ruby/BlockDeviceGuard.md b/example/ruby/BlockDeviceGuard.md deleted file mode 100644 index 04c62a4..0000000 --- a/example/ruby/BlockDeviceGuard.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: BlockDeviceGuard -**Inherits:** SpecGuard - - - - - -#Instance Methods -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/BlockSpecs.md b/example/ruby/BlockSpecs.md deleted file mode 100644 index 01c4fc3..0000000 --- a/example/ruby/BlockSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BlockSpecs - - - - - diff --git a/example/ruby/BlockSpecs/OverwriteBlockVariable.md b/example/ruby/BlockSpecs/OverwriteBlockVariable.md deleted file mode 100644 index 99f7c4e..0000000 --- a/example/ruby/BlockSpecs/OverwriteBlockVariable.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: BlockSpecs::OverwriteBlockVariable -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [OverwriteBlockVariable] a new instance of OverwriteBlockVariable - -## method_missing(method, *args, &block) [](#method-i-method_missing) - diff --git a/example/ruby/BlockSpecs/Yield.md b/example/ruby/BlockSpecs/Yield.md deleted file mode 100644 index ec72a39..0000000 --- a/example/ruby/BlockSpecs/Yield.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: BlockSpecs::Yield -**Inherits:** Object - - -TODO: rewrite all specs that use Yield to use Yielder - - - -#Instance Methods -## splat(*args) [](#method-i-splat) - -**@yield** [args] - -## two_arg_array() [](#method-i-two_arg_array) - -**@yield** [[1, 2]] - -## two_args() [](#method-i-two_args) - -**@yield** [1, 2] - -## yield_splat_inside_block() [](#method-i-yield_splat_inside_block) - -## yield_this(obj) [](#method-i-yield_this) - -**@yield** [obj] - diff --git a/example/ruby/BlockSpecs/Yielder.md b/example/ruby/BlockSpecs/Yielder.md deleted file mode 100644 index ef7e2ac..0000000 --- a/example/ruby/BlockSpecs/Yielder.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: BlockSpecs::Yielder -**Inherits:** Object - - - - - -#Instance Methods -## k(*a) [](#method-i-k) - -**@yield** [a, b: true] - -## m(*a) [](#method-i-m) - -**@yield** [a] - -## r(a) [](#method-i-r) - -**@yield** [a] - -## s(a) [](#method-i-s) - -**@yield** [a] - -## z() [](#method-i-z) - diff --git a/example/ruby/BlockingMatcher.md b/example/ruby/BlockingMatcher.md deleted file mode 100644 index 49e985d..0000000 --- a/example/ruby/BlockingMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: BlockingMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(block) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/Board.md b/example/ruby/Board.md deleted file mode 100644 index 23659e3..0000000 --- a/example/ruby/Board.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Board -**Inherits:** Object - - - - - -#Instance Methods -## count(x, y) [](#method-i-count) - -## down() [](#method-i-down) - -## fetch(x, y) [](#method-i-fetch) - -## initialize(h, w, m) [](#method-i-initialize) - -**@return** [Board] a new instance of Board - -## left() [](#method-i-left) - -## mark() [](#method-i-mark) - -## open(x@cx, y@cy) [](#method-i-open) - -## over(win) [](#method-i-over) - -## over?() [](#method-i-over?) - -**@return** [Boolean] - -## quit() [](#method-i-quit) - -## reset() [](#method-i-reset) - -## right() [](#method-i-right) - -## up() [](#method-i-up) - diff --git a/example/ruby/Book.md b/example/ruby/Book.md deleted file mode 100644 index 076949b..0000000 --- a/example/ruby/Book.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Book -**Inherits:** Object - - - - - -#Instance Methods -## tableof_contents() [](#method-i-tableof_contents) - diff --git a/example/ruby/Book/Page.md b/example/ruby/Book/Page.md deleted file mode 100644 index 9a61315..0000000 --- a/example/ruby/Book/Page.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Book::Page -**Inherits:** Object - - - - -# Class Methods -## tableof_contents() [](#method-c-tableof_contents) - -#Instance Methods -## tableof_contents() [](#method-i-tableof_contents) - diff --git a/example/ruby/Book/Spine.md b/example/ruby/Book/Spine.md deleted file mode 100644 index 6c77738..0000000 --- a/example/ruby/Book/Spine.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Book::Spine -**Inherits:** Object - - - - - diff --git a/example/ruby/Book/TableOfContents.md b/example/ruby/Book/TableOfContents.md deleted file mode 100644 index 7949b77..0000000 --- a/example/ruby/Book/TableOfContents.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Book::TableOfContents -**Inherits:** Object - - - - - diff --git a/example/ruby/Branch.md b/example/ruby/Branch.md deleted file mode 100644 index 08afcf4..0000000 --- a/example/ruby/Branch.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Branch -**Inherits:** Object - - - - -# Attributes -## byte_max[RW] [](#attribute-i-byte_max) -Returns the value of attribute byte_max. - -## byte_min[RW] [](#attribute-i-byte_min) -Returns the value of attribute byte_min. - -## child_tree[RW] [](#attribute-i-child_tree) -Returns the value of attribute child_tree. - -## hash[RW] [](#attribute-i-hash) -Returns the value of attribute hash. - - -#Instance Methods -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## initialize(byte_min, byte_max, child_tree) [](#method-i-initialize) - -**@return** [Branch] a new instance of Branch - diff --git a/example/ruby/BreakSpecs.md b/example/ruby/BreakSpecs.md deleted file mode 100644 index c37c84c..0000000 --- a/example/ruby/BreakSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: BreakSpecs - - - - - diff --git a/example/ruby/BreakSpecs/Block.md b/example/ruby/BreakSpecs/Block.md deleted file mode 100644 index 053432f..0000000 --- a/example/ruby/BreakSpecs/Block.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: BreakSpecs::Block -**Inherits:** BreakSpecs::Driver - - - - - -#Instance Methods -## break_in_block_in_while() [](#method-i-break_in_block_in_while) - -## break_in_method() [](#method-i-break_in_method) - -## break_in_method_captured() [](#method-i-break_in_method_captured) - -## break_in_nested_method() [](#method-i-break_in_nested_method) - -## break_in_yield_captured() [](#method-i-break_in_yield_captured) - -## break_in_yielding_method() [](#method-i-break_in_yielding_method) - -## break_nil() [](#method-i-break_nil) - -## break_value() [](#method-i-break_value) - -## call_method(b) [](#method-i-call_method) - -## capture_block(&b) [](#method-i-capture_block) - -## create_block() [](#method-i-create_block) - -## invoke_yield_in_while() [](#method-i-invoke_yield_in_while) - -## looped_break_in_captured_block() [](#method-i-looped_break_in_captured_block) - -## method(v) [](#method-i-method) - -**@yield** [v] - -## yielding() [](#method-i-yielding) - diff --git a/example/ruby/BreakSpecs/Driver.md b/example/ruby/BreakSpecs/Driver.md deleted file mode 100644 index 306cbf6..0000000 --- a/example/ruby/BreakSpecs/Driver.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: BreakSpecs::Driver -**Inherits:** Object - - - - - -#Instance Methods -## initialize(ensuresfalse) [](#method-i-initialize) - -**@return** [Driver] a new instance of Driver - -## note(value) [](#method-i-note) - diff --git a/example/ruby/BreakSpecs/Lambda.md b/example/ruby/BreakSpecs/Lambda.md deleted file mode 100644 index fabf50c..0000000 --- a/example/ruby/BreakSpecs/Lambda.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: BreakSpecs::Lambda -**Inherits:** BreakSpecs::Driver - - - - - -#Instance Methods -## break_in_block_in_method() [](#method-i-break_in_block_in_method) - -## break_in_defining_scope(valuetrue) [](#method-i-break_in_defining_scope) -Cases for the invocation of the scope defining the lambda still active on the -call stack when the lambda is invoked. - -## break_in_method() [](#method-i-break_in_method) - -## break_in_method_yield() [](#method-i-break_in_method_yield) - -## break_in_nested_scope() [](#method-i-break_in_nested_scope) - -## break_in_nested_scope_block() [](#method-i-break_in_nested_scope_block) - -## break_in_nested_scope_yield() [](#method-i-break_in_nested_scope_yield) - -## create_lambda() [](#method-i-create_lambda) -Cases for the invocation of the scope defining the lambda NOT still active on -the call stack when the lambda is invoked. - -## invoke_lambda(l) [](#method-i-invoke_lambda) - -## invoke_lambda_block(b) [](#method-i-invoke_lambda_block) - -## invoke_yield() [](#method-i-invoke_yield) - -## note_invoke_yield() [](#method-i-note_invoke_yield) - diff --git a/example/ruby/BrokenUnblockScheduler.md b/example/ruby/BrokenUnblockScheduler.md deleted file mode 100644 index ff66a43..0000000 --- a/example/ruby/BrokenUnblockScheduler.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: BrokenUnblockScheduler -**Inherits:** Scheduler - - -This scheduler has a broken implementation of `unblock`` in the sense that it -raises an exception. This is used to test the behavior of the scheduler when -unblock raises an exception. - - - -#Instance Methods -## unblock(blocker, fiber) [](#method-i-unblock) - diff --git a/example/ruby/Bug.md b/example/ruby/Bug.md deleted file mode 100644 index ccd9743..0000000 --- a/example/ruby/Bug.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: Bug - - - - -# Class Methods -## bug_14834() [](#method-c-bug_14834) -## call(*args ) [](#method-c-call) -## dlntest() [](#method-c-dlntest) -## funcall(*args ) [](#method-c-funcall) -## funcall_callback(obj ) [](#method-c-funcall_callback) -## invalid_access(address ) [](#method-c-invalid_access) -## invalid_call(address ) [](#method-c-invalid_call) -## load_protect(*args ) [](#method-c-load_protect) -## notimplement(*args ) [](#method-c-notimplement) -## postponed_job_call_direct(obj ) [](#method-c-postponed_job_call_direct) -## postponed_job_preregister_and_call_with_sleep(obj ) [](#method-c-postponed_job_preregister_and_call_with_sleep) -## postponed_job_preregister_and_call_without_sleep(obj ) [](#method-c-postponed_job_preregister_and_call_without_sleep) -## postponed_job_preregister_calls_with_last_argument() [](#method-c-postponed_job_preregister_calls_with_last_argument) -## postponed_job_preregister_multiple_times() [](#method-c-postponed_job_preregister_multiple_times) -## postponed_job_register(obj ) [](#method-c-postponed_job_register) -## postponed_job_register_in_c_thread(obj ) [](#method-c-postponed_job_register_in_c_thread) -## postponed_job_register_one(obj ) [](#method-c-postponed_job_register_one) -## postponed_job_register_one_same() [](#method-c-postponed_job_register_one_same) -## q(obj ) [](#method-c-q) -## rb_fatal(msg ) [](#method-c-rb_fatal) -## s(obj ) [](#method-c-s) -## sncount(str ) [](#method-c-sncount) -## start() [](#method-c-start) -## tracepoint_specify_normal_and_internal_events() [](#method-c-tracepoint_specify_normal_and_internal_events) -## tracepoint_track_objspace_events() [](#method-c-tracepoint_track_objspace_events) -## unp_st_foreach(test ) [](#method-c-unp_st_foreach) -## unp_st_foreach_check(test ) [](#method-c-unp_st_foreach_check) -## v(obj ) [](#method-c-v) - diff --git a/example/ruby/Bug/Array.md b/example/ruby/Bug/Array.md deleted file mode 100644 index f7f2f47..0000000 --- a/example/ruby/Bug/Array.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Array -**Inherits:** Object - - - - -# Class Methods -## __resize__(ary , len ) [](#method-c-__resize__) -## enc_raise(encoding , mesg ) [](#method-c-enc_raise) - diff --git a/example/ruby/Bug/Array/DataError.md b/example/ruby/Bug/Array/DataError.md deleted file mode 100644 index 5ac7c26..0000000 --- a/example/ruby/Bug/Array/DataError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bug::Array::DataError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Bug/Bar.md b/example/ruby/Bug/Bar.md deleted file mode 100644 index 4d98163..0000000 --- a/example/ruby/Bug/Bar.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Bar -**Inherits:** Object - - - - - -#Instance Methods -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/Bug/Bignum.md b/example/ruby/Bug/Bignum.md deleted file mode 100644 index fc9afc6..0000000 --- a/example/ruby/Bug/Bignum.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Bignum -**Inherits:** String - - - - - -#Instance Methods -## delete!(key) [](#method-i-delete!) - diff --git a/example/ruby/Bug/Bug7802.md b/example/ruby/Bug/Bug7802.md deleted file mode 100644 index 392c59b..0000000 --- a/example/ruby/Bug/Bug7802.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bug::Bug7802 -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/Bug/Class.md b/example/ruby/Bug/Class.md deleted file mode 100644 index dc51d9d..0000000 --- a/example/ruby/Bug/Class.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bug::Class - - - - -# Class Methods -## mod_method_arity(mod , mid ) [](#method-c-mod_method_arity) -## obj_method_arity(obj , mid ) [](#method-c-obj_method_arity) - diff --git a/example/ruby/Bug/Class/Loop.md b/example/ruby/Bug/Class/Loop.md deleted file mode 100644 index fdc2db0..0000000 --- a/example/ruby/Bug/Class/Loop.md +++ /dev/null @@ -1,6 +0,0 @@ -# Class: Bug::Class::Loop - - - - - diff --git a/example/ruby/Bug/Class/VersionMax.md b/example/ruby/Bug/Class/VersionMax.md deleted file mode 100644 index 314c262..0000000 --- a/example/ruby/Bug/Class/VersionMax.md +++ /dev/null @@ -1,6 +0,0 @@ -# Class: Bug::Class::VersionMax - - - - - diff --git a/example/ruby/Bug/Class/VersionZero.md b/example/ruby/Bug/Class/VersionZero.md deleted file mode 100644 index 9576360..0000000 --- a/example/ruby/Bug/Class/VersionZero.md +++ /dev/null @@ -1,6 +0,0 @@ -# Class: Bug::Class::VersionZero - - - - - diff --git a/example/ruby/Bug/Debug.md b/example/ruby/Bug/Debug.md deleted file mode 100644 index 99dcb41..0000000 --- a/example/ruby/Bug/Debug.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bug::Debug - - - - - diff --git a/example/ruby/Bug/EnumeratorKw.md b/example/ruby/Bug/EnumeratorKw.md deleted file mode 100644 index fc3f211..0000000 --- a/example/ruby/Bug/EnumeratorKw.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bug::EnumeratorKw - - - - - -#Instance Methods -## m(*args) [](#method-i-m) - diff --git a/example/ruby/Bug/Exception.md b/example/ruby/Bug/Exception.md deleted file mode 100644 index 942a279..0000000 --- a/example/ruby/Bug/Exception.md +++ /dev/null @@ -1,32 +0,0 @@ -# Exception: Bug::Exception -**Inherits:** StandardError - - - - -# Class Methods -## bignum?(self ) [](#method-c-bignum?) -**@return** [Boolean] - -## capacity(str ) [](#method-c-capacity) -## class2name(klass ) [](#method-c-class2name) -## fixnum?(self ) [](#method-c-fixnum?) -**@return** [Boolean] - -## fstring(str ) [](#method-c-fstring) -## fstring_fake_str() [](#method-c-fstring_fake_str) -## inspector() [](#method-c-inspector) -## missing_nextafter(vx , vy ) [](#method-c-missing_nextafter) -## positive_pow(x , y ) [](#method-c-positive_pow) -## rb_enc_interned_str(encoding ) [](#method-c-rb_enc_interned_str) -## rb_enc_str_new(encoding ) [](#method-c-rb_enc_str_new) -## system_nextafter(vx , vy ) [](#method-c-system_nextafter) -## to_bignum(x ) [](#method-c-to_bignum) - -#Instance Methods -## append(addendum) [](#method-i-append) - -## resize(len) [](#method-i-resize) - -## set_len(len) [](#method-i-set_len) - diff --git a/example/ruby/Bug/File.md b/example/ruby/Bug/File.md deleted file mode 100644 index bd91e3c..0000000 --- a/example/ruby/Bug/File.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bug::File - - - - -# Class Methods -## after_gc_exit_hook=(proc ) [](#method-c-after_gc_exit_hook=) -## after_gc_start_hook=(proc ) [](#method-c-after_gc_start_hook=) - diff --git a/example/ruby/Bug/File/NewlineConv.md b/example/ruby/Bug/File/NewlineConv.md deleted file mode 100644 index 1f14847..0000000 --- a/example/ruby/Bug/File/NewlineConv.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bug::File::NewlineConv - - - - -# Class Methods -## rb_file_open(filename , read_or_write , binary_or_text ) [](#method-c-rb_file_open) -## rb_io_fdopen(filename , read_or_write , binary_or_text ) [](#method-c-rb_io_fdopen) - diff --git a/example/ruby/Bug/File/Stat.md b/example/ruby/Bug/File/Stat.md deleted file mode 100644 index 7071fb6..0000000 --- a/example/ruby/Bug/File/Stat.md +++ /dev/null @@ -1,26 +0,0 @@ -# Module: Bug::File::Stat - - - - -# Class Methods -## for_fd(fileno ) [](#method-c-for_fd) -## for_path(path ) [](#method-c-for_path) - -#Instance Methods -## [](key) [](#method-i-[]) - -## []=(key, data) [](#method-i-[]=) - -## delete_safe(key) [](#method-i-delete_safe) - -## each() [](#method-i-each) - -## initialize() [](#method-i-initialize) - -## size() [](#method-i-size) - -## st_update(key) [](#method-i-st_update) - -## update(key) [](#method-i-update) - diff --git a/example/ruby/Bug/Float.md b/example/ruby/Bug/Float.md deleted file mode 100644 index 042b18e..0000000 --- a/example/ruby/Bug/Float.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bug::Float -**Inherits:** Object - - - - -# Class Methods -## buf_new(len ) [](#method-c-buf_new) -## external_new(len , enc ) [](#method-c-external_new) -## make_call_super(procarg ) [](#method-c-make_call_super) - -#Instance Methods -## rstruct_len() [](#method-i-rstruct_len) - diff --git a/example/ruby/Bug/Float/Breakable.md b/example/ruby/Bug/Float/Breakable.md deleted file mode 100644 index 705b20c..0000000 --- a/example/ruby/Bug/Float/Breakable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bug::Float::Breakable - - - - -# Class Methods -## iter_break() [](#method-c-iter_break) -## iter_break_value(val ) [](#method-c-iter_break_value) - diff --git a/example/ruby/Bug/Float/Yield.md b/example/ruby/Bug/Float/Yield.md deleted file mode 100644 index e6670d8..0000000 --- a/example/ruby/Bug/Float/Yield.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bug::Float::Yield - - - - - -#Instance Methods -## yield_block(*args) [](#method-i-yield_block) - diff --git a/example/ruby/Bug/Hash.md b/example/ruby/Bug/Hash.md deleted file mode 100644 index 792dadb..0000000 --- a/example/ruby/Bug/Hash.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Bug::Hash -**Inherits:** Hash - - - - - diff --git a/example/ruby/Bug/Integer.md b/example/ruby/Bug/Integer.md deleted file mode 100644 index 4dd6b64..0000000 --- a/example/ruby/Bug/Integer.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Bug::Integer -**Inherits:** Object - - - - - diff --git a/example/ruby/Bug/Iter.md b/example/ruby/Bug/Iter.md deleted file mode 100644 index 26b7832..0000000 --- a/example/ruby/Bug/Iter.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bug::Iter - - - - - diff --git a/example/ruby/Bug/Marshal.md b/example/ruby/Bug/Marshal.md deleted file mode 100644 index 7031549..0000000 --- a/example/ruby/Bug/Marshal.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bug::Marshal - - - - - diff --git a/example/ruby/Bug/Marshal/TestInternalIVar.md b/example/ruby/Bug/Marshal/TestInternalIVar.md deleted file mode 100644 index 9e3d2c4..0000000 --- a/example/ruby/Bug/Marshal/TestInternalIVar.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Marshal::TestInternalIVar -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_marshal() [](#method-i-test_marshal) - diff --git a/example/ruby/Bug/Marshal/TestUsrMarshal.md b/example/ruby/Bug/Marshal/TestUsrMarshal.md deleted file mode 100644 index 3520fb2..0000000 --- a/example/ruby/Bug/Marshal/TestUsrMarshal.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bug::Marshal::TestUsrMarshal -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## old_dump() [](#method-i-old_dump) - -## test_compat() [](#method-i-test_compat) - -## test_incompat() [](#method-i-test_incompat) - -## test_marshal() [](#method-i-test_marshal) - diff --git a/example/ruby/Bug/Method.md b/example/ruby/Bug/Method.md deleted file mode 100644 index 34e7c80..0000000 --- a/example/ruby/Bug/Method.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bug::Method - - - - - diff --git a/example/ruby/Bug/NotImplement.md b/example/ruby/Bug/NotImplement.md deleted file mode 100644 index f20d316..0000000 --- a/example/ruby/Bug/NotImplement.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Bug::NotImplement -**Inherits:** Object - - - - -# Class Methods -## ensure_raise(object , exc ) [](#method-c-ensure_raise) -## ensured(object ) [](#method-c-ensured) -## new_duplicate(name , mem ) [](#method-c-new_duplicate) -## new_duplicate_under(name , mem ) [](#method-c-new_duplicate_under) -## rb_define_dummy_encoding(name ) [](#method-c-rb_define_dummy_encoding) -## rb_str_dup(str ) [](#method-c-rb_str_dup) -## reset_leap_second_info() [](#method-c-reset_leap_second_info) -## shared_string?(str ) [](#method-c-shared_string?) -**@return** [Boolean] - -## sharing_with_shared?(str ) [](#method-c-sharing_with_shared?) -**@return** [Boolean] - - -#Instance Methods -## coderange() [](#method-i-coderange) -return coderange without scan - -## coderange_scan() [](#method-i-coderange_scan) -scan coderange and return the result - -## ellipsize(len) [](#method-i-ellipsize) - -## normalize_ospath() [](#method-i-normalize_ospath) - -## notimplement(*args) [](#method-i-notimplement) - diff --git a/example/ruby/Bug/NotImplement/MyInteger.md b/example/ruby/Bug/NotImplement/MyInteger.md deleted file mode 100644 index 868c562..0000000 --- a/example/ruby/Bug/NotImplement/MyInteger.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Bug::NotImplement::MyInteger -**Inherits:** Integer - - - - -# Class Methods -## new() [](#method-c-new) - diff --git a/example/ruby/Bug/Proc.md b/example/ruby/Bug/Proc.md deleted file mode 100644 index f78ec94..0000000 --- a/example/ruby/Bug/Proc.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bug::Proc - - - - - diff --git a/example/ruby/Bug/Rational.md b/example/ruby/Bug/Rational.md deleted file mode 100644 index d059c5b..0000000 --- a/example/ruby/Bug/Rational.md +++ /dev/null @@ -1,36 +0,0 @@ -# Module: Bug::Rational - - - - -# Class Methods -## big2str_generic(x , vbase ) [](#method-c-big2str_generic) -## big2str_gmp(x , vbase ) [](#method-c-big2str_gmp) -## big2str_poweroftwo(x , vbase ) [](#method-c-big2str_poweroftwo) -## gcd_gmp(x , y ) [](#method-c-gcd_gmp) -## gcd_normal(x , y ) [](#method-c-gcd_normal) -## gettid() [](#method-c-gettid) -## make_call_receiver(procarg ) [](#method-c-make_call_receiver) -## negzero(length ) [](#method-c-negzero) -## nofree() [](#method-c-nofree) -## raw(x , y ) [](#method-c-raw) -## str2big_gmp(str , vbase , badcheck ) [](#method-c-str2big_gmp) -## str2big_karatsuba(str , vbase , badcheck ) [](#method-c-str2big_karatsuba) -## str2big_normal(str , vbase , badcheck ) [](#method-c-str2big_normal) -## str2big_poweroftwo(str , vbase , badcheck ) [](#method-c-str2big_poweroftwo) -## test_numbits_2comp_without_sign(val ) [](#method-c-test_numbits_2comp_without_sign) -## test_numbytes_2comp_with_sign(val ) [](#method-c-test_numbytes_2comp_with_sign) -## test_pack(val , numwords_arg , wordsize_arg , nails , flags ) [](#method-c-test_pack) -## test_pack_raw(val , buf , numwords_arg , wordsize_arg , nails , flags ) [](#method-c-test_pack_raw) -## test_unpack(buf , numwords , wordsize , nails , flags ) [](#method-c-test_unpack) -## zero(length ) [](#method-c-zero) - -#Instance Methods -## get(name) [](#method-i-get) - -## modify!() [](#method-i-modify!) - -## modify_expand!(expand) [](#method-i-modify_expand!) - -## qsort!(*args) [](#method-i-qsort!) - diff --git a/example/ruby/Bug/RbCallSuperKw.md b/example/ruby/Bug/RbCallSuperKw.md deleted file mode 100644 index c8f5bc3..0000000 --- a/example/ruby/Bug/RbCallSuperKw.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bug::RbCallSuperKw - - - - - -#Instance Methods -## m(*args) [](#method-i-m) - diff --git a/example/ruby/Bug/Regexp.md b/example/ruby/Bug/Regexp.md deleted file mode 100644 index cdeee05..0000000 --- a/example/ruby/Bug/Regexp.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Bug::Regexp -**Inherits:** Regexp - - - - -# Class Methods -## cstr_embedded?(str ) [](#method-c-cstr_embedded?) -**@return** [Boolean] - -## cstr_noembed(str ) [](#method-c-cstr_noembed) -## cstr_term(str ) [](#method-c-cstr_term) -## cstr_term_char(str ) [](#method-c-cstr_term_char) -## cstr_unterm(str , c ) [](#method-c-cstr_unterm) -## rb_str_new_frozen(str ) [](#method-c-rb_str_new_frozen) - -#Instance Methods -## cstr_term() [](#method-i-cstr_term) - -## cstr_term_char() [](#method-i-cstr_term_char) - -## cstr_unterm(c) [](#method-i-cstr_unterm) - -## unterminated_substring(vbeg, vlen) [](#method-i-unterminated_substring) - diff --git a/example/ruby/Bug/ScanArgs.md b/example/ruby/Bug/ScanArgs.md deleted file mode 100644 index 17228e3..0000000 --- a/example/ruby/Bug/ScanArgs.md +++ /dev/null @@ -1,39 +0,0 @@ -# Module: Bug::ScanArgs - - - - -# Class Methods -## hash(*args ) [](#method-c-hash) -hash -## k_lead_opt_hash(*args ) [](#method-c-k_lead_opt_hash) -## lead(*args ) [](#method-c-lead) -## lead_hash(*args ) [](#method-c-lead_hash) -## lead_opt(*args ) [](#method-c-lead_opt) -## lead_opt_hash(*args ) [](#method-c-lead_opt_hash) -## lead_opt_trail(*args ) [](#method-c-lead_opt_trail) -## lead_opt_trail_hash(*args ) [](#method-c-lead_opt_trail_hash) -## lead_opt_var(*args ) [](#method-c-lead_opt_var) -## lead_opt_var_hash(*args ) [](#method-c-lead_opt_var_hash) -## lead_opt_var_trail(*args ) [](#method-c-lead_opt_var_trail) -## lead_opt_var_trail_hash(*args ) [](#method-c-lead_opt_var_trail_hash) -## lead_var(*args ) [](#method-c-lead_var) -## lead_var_hash(*args ) [](#method-c-lead_var_hash) -## lead_var_trail(*args ) [](#method-c-lead_var_trail) -## lead_var_trail_hash(*args ) [](#method-c-lead_var_trail_hash) -## n_lead_opt_hash(*args ) [](#method-c-n_lead_opt_hash) -## opt(*args ) [](#method-c-opt) -## opt_hash(*args ) [](#method-c-opt_hash) -## opt_trail(*args ) [](#method-c-opt_trail) -trail -## opt_trail_hash(*args ) [](#method-c-opt_trail_hash) -## opt_var(*args ) [](#method-c-opt_var) -## opt_var_hash(*args ) [](#method-c-opt_var_hash) -## opt_var_trail(*args ) [](#method-c-opt_var_trail) -## opt_var_trail_hash(*args ) [](#method-c-opt_var_trail_hash) -## var(*args ) [](#method-c-var) -var -## var_hash(*args ) [](#method-c-var_hash) -## var_trail(*args ) [](#method-c-var_trail) -## var_trail_hash(*args ) [](#method-c-var_trail_hash) - diff --git a/example/ruby/Bug/StNumHash.md b/example/ruby/Bug/StNumHash.md deleted file mode 100644 index 35b3b4a..0000000 --- a/example/ruby/Bug/StNumHash.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Bug::StNumHash -**Inherits:** Object - - - - - diff --git a/example/ruby/Bug/StNumHash/Test_NumHash.md b/example/ruby/Bug/StNumHash/Test_NumHash.md deleted file mode 100644 index 0393ad1..0000000 --- a/example/ruby/Bug/StNumHash/Test_NumHash.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bug::StNumHash::Test_NumHash -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_check() [](#method-i-test_check) - -## test_delete_safe_on_iteration() [](#method-i-test_delete_safe_on_iteration) - -## test_size_after_delete_safe() [](#method-i-test_size_after_delete_safe) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/Bug/StTable.md b/example/ruby/Bug/StTable.md deleted file mode 100644 index 49e9939..0000000 --- a/example/ruby/Bug/StTable.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Bug::StTable -**Inherits:** Object - - - - - diff --git a/example/ruby/Bug/StTable/Test_Update.md b/example/ruby/Bug/StTable/Test_Update.md deleted file mode 100644 index 826a315..0000000 --- a/example/ruby/Bug/StTable/Test_Update.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Bug::StTable::Test_Update -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_continue() [](#method-i-test_continue) - -## test_delete() [](#method-i-test_delete) - -## test_notfound() [](#method-i-test_notfound) - -## test_pass_objects_in_st_table() [](#method-i-test_pass_objects_in_st_table) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/Bug/String.md b/example/ruby/Bug/String.md deleted file mode 100644 index 5ca4162..0000000 --- a/example/ruby/Bug/String.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Bug::String -**Inherits:** String - - - - -# Class Methods -## data_new(super ) [](#method-c-data_new) - diff --git a/example/ruby/Bug/Struct.md b/example/ruby/Bug/Struct.md deleted file mode 100644 index 94d57a1..0000000 --- a/example/ruby/Bug/Struct.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Bug::Struct -**Inherits:** Struct - - - - - diff --git a/example/ruby/Bug/Struct/Test_Data.md b/example/ruby/Bug/Struct/Test_Data.md deleted file mode 100644 index 935b669..0000000 --- a/example/ruby/Bug/Struct/Test_Data.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bug::Struct::Test_Data -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_data_new_default() [](#method-i-test_data_new_default) - -## test_data_new_superclass() [](#method-i-test_data_new_superclass) - diff --git a/example/ruby/Bug/Struct/Test_Duplicate.md b/example/ruby/Bug/Struct/Test_Duplicate.md deleted file mode 100644 index 5fcf755..0000000 --- a/example/ruby/Bug/Struct/Test_Duplicate.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bug::Struct::Test_Duplicate -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_new_duplicate() [](#method-i-test_new_duplicate) - -## test_new_duplicate_under() [](#method-i-test_new_duplicate_under) - diff --git a/example/ruby/Bug/Struct/Test_Len.md b/example/ruby/Bug/Struct/Test_Len.md deleted file mode 100644 index 15da61c..0000000 --- a/example/ruby/Bug/Struct/Test_Len.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Struct::Test_Len -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_rstruct_len() [](#method-i-test_rstruct_len) - diff --git a/example/ruby/Bug/Struct/Test_Member.md b/example/ruby/Bug/Struct/Test_Member.md deleted file mode 100644 index 38d1386..0000000 --- a/example/ruby/Bug/Struct/Test_Member.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Struct::Test_Member -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_member_get() [](#method-i-test_member_get) - diff --git a/example/ruby/Bug/Symbol.md b/example/ruby/Bug/Symbol.md deleted file mode 100644 index 60a9f93..0000000 --- a/example/ruby/Bug/Symbol.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Bug::Symbol -**Inherits:** Symbol - - - - -# Class Methods -## attrset() [](#method-c-attrset) -## dynamic?(sym ) [](#method-c-dynamic?) -**@return** [Boolean] - -## find(sym ) [](#method-c-find) -## id2str(sym ) [](#method-c-id2str) -## iv_get(obj , name ) [](#method-c-iv_get) -## pindown(sym ) [](#method-c-pindown) -## pinneddown?(sym ) [](#method-c-pinneddown?) -**@return** [Boolean] - -## static?(sym ) [](#method-c-static?) -**@return** [Boolean] - - -#Instance Methods -## append(src, dst) [](#method-i-append) - diff --git a/example/ruby/Bug/Test_ExceptionAT.md b/example/ruby/Bug/Test_ExceptionAT.md deleted file mode 100644 index 5b33673..0000000 --- a/example/ruby/Bug/Test_ExceptionAT.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Test_ExceptionAT -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_exception_at_throwing() [](#method-i-test_exception_at_throwing) - diff --git a/example/ruby/Bug/Test_ExceptionDE.md b/example/ruby/Bug/Test_ExceptionDE.md deleted file mode 100644 index 6af910a..0000000 --- a/example/ruby/Bug/Test_ExceptionDE.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Test_ExceptionDE -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_cleanup_data_error() [](#method-i-test_cleanup_data_error) - diff --git a/example/ruby/Bug/Test_ExceptionE.md b/example/ruby/Bug/Test_ExceptionE.md deleted file mode 100644 index 03e51b6..0000000 --- a/example/ruby/Bug/Test_ExceptionE.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Test_ExceptionE -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_ensured() [](#method-i-test_ensured) - diff --git a/example/ruby/Bug/Test_ExceptionER.md b/example/ruby/Bug/Test_ExceptionER.md deleted file mode 100644 index 40ca373..0000000 --- a/example/ruby/Bug/Test_ExceptionER.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bug::Test_ExceptionER -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_enc_raise() [](#method-i-test_enc_raise) - diff --git a/example/ruby/Bug/Thread.md b/example/ruby/Bug/Thread.md deleted file mode 100644 index df32380..0000000 --- a/example/ruby/Bug/Thread.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bug::Thread - - - - -# Class Methods -## runnable_sleep(timeout ) [](#method-c-runnable_sleep) -## ubf_async_safe(notify_fd ) [](#method-c-ubf_async_safe) - diff --git a/example/ruby/Bug/ThreadInstrumentation.md b/example/ruby/Bug/ThreadInstrumentation.md deleted file mode 100644 index 9c61b15..0000000 --- a/example/ruby/Bug/ThreadInstrumentation.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Bug::ThreadInstrumentation - - - - -# Class Methods -## register_and_unregister_callbacks() [](#method-c-register_and_unregister_callbacks) -## register_callback(strict ) [](#method-c-register_callback) -## unregister_callback() [](#method-c-unregister_callback) - diff --git a/example/ruby/Bug/Time.md b/example/ruby/Bug/Time.md deleted file mode 100644 index a0c927a..0000000 --- a/example/ruby/Bug/Time.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bug::Time -**Inherits:** Time - - - - -# Class Methods -## big_divrem_gmp(x , y ) [](#method-c-big_divrem_gmp) -## big_divrem_normal(x , y ) [](#method-c-big_divrem_normal) -## big_mul_balance(x , y ) [](#method-c-big_mul_balance) -## big_mul_gmp(x , y ) [](#method-c-big_mul_gmp) -## big_mul_karatsuba(x , y ) [](#method-c-big_mul_karatsuba) -## big_mul_normal(x , y ) [](#method-c-big_mul_normal) -## big_mul_toom3(x , y ) [](#method-c-big_mul_toom3) -## big_sq_fast(x ) [](#method-c-big_sq_fast) - diff --git a/example/ruby/Bug/Time/Test_New.md b/example/ruby/Bug/Time/Test_New.md deleted file mode 100644 index b206f28..0000000 --- a/example/ruby/Bug/Time/Test_New.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bug::Time::Test_New -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_time_equal(a, b, msgnil) [](#method-i-assert_time_equal) - -## test_nano_new() [](#method-i-test_nano_new) - -## test_timespec_new() [](#method-i-test_timespec_new) - -## test_timespec_now() [](#method-i-test_timespec_now) - diff --git a/example/ruby/Bug/TypedData.md b/example/ruby/Bug/TypedData.md deleted file mode 100644 index 28e1260..0000000 --- a/example/ruby/Bug/TypedData.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Bug::TypedData -**Inherits:** Object - - - - -# Class Methods -## check(obj ) [](#method-c-check) -## encoding_index(str ) [](#method-c-encoding_index) -## make(num ) [](#method-c-make) -## parse_depth_limit() [](#method-c-parse_depth_limit) -## parse_depth_limit=(depth ) [](#method-c-parse_depth_limit=) -## profile_frames(start_v , num_v ) [](#method-c-profile_frames) -## profile_thread_frames(thread , start_v , num_v ) [](#method-c-profile_thread_frames) -## rb_interned_str_dup(str ) [](#method-c-rb_interned_str_dup) - -#Instance Methods -## associate_encoding!(enc) [](#method-i-associate_encoding!) - -## enc_str_buf_cat(str2) [](#method-i-enc_str_buf_cat) - -## str_conv_enc_opts(from, to, ecflags, ecopts) [](#method-i-str_conv_enc_opts) - diff --git a/example/ruby/Bug/VM.md b/example/ruby/Bug/VM.md deleted file mode 100644 index 7dd70eb..0000000 --- a/example/ruby/Bug/VM.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Bug::VM -**Inherits:** Object - - - - -# Class Methods -## register_at_exit(t ) [](#method-c-register_at_exit) - diff --git a/example/ruby/Bug/Win32.md b/example/ruby/Bug/Win32.md deleted file mode 100644 index 0e77d5c..0000000 --- a/example/ruby/Bug/Win32.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: Bug::Win32 - - - - -# Class Methods -## console_attribute(io , attr ) [](#method-c-console_attribute) -## console_info(io ) [](#method-c-console_info) -## test_fdset() [](#method-c-test_fdset) -## test_select() [](#method-c-test_select) - -#Instance Methods -## exec_recursive(mid) [](#method-i-exec_recursive) - -## exec_recursive_outer(mid) [](#method-i-exec_recursive_outer) - diff --git a/example/ruby/Bug/Win32/TestDln.md b/example/ruby/Bug/Win32/TestDln.md deleted file mode 100644 index cd3c513..0000000 --- a/example/ruby/Bug/Win32/TestDln.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bug::Win32::TestDln -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_check_imported() [](#method-i-test_check_imported) - -## test_nonascii_load() [](#method-i-test_nonascii_load) - diff --git a/example/ruby/Bug/Win32/TestFdSetSize.md b/example/ruby/Bug/Win32/TestFdSetSize.md deleted file mode 100644 index 85889ed..0000000 --- a/example/ruby/Bug/Win32/TestFdSetSize.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bug::Win32::TestFdSetSize -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_fdset_with_unmatched_fd_setsize() [](#method-i-test_fdset_with_unmatched_fd_setsize) - -## test_select_with_unmatched_fd_setsize() [](#method-i-test_select_with_unmatched_fd_setsize) - diff --git a/example/ruby/BugGuard.md b/example/ruby/BugGuard.md deleted file mode 100644 index d76d3a9..0000000 --- a/example/ruby/BugGuard.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: BugGuard -**Inherits:** VersionGuard - - - - - -#Instance Methods -## initialize(bug, requirement) [](#method-i-initialize) - -**@return** [BugGuard] a new instance of BugGuard - -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/BundledGem.md b/example/ruby/BundledGem.md deleted file mode 100644 index 03a4d3f..0000000 --- a/example/ruby/BundledGem.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: BundledGem - - -This library is used by "make extract-gems" to unpack bundled gem files. - - -# Class Methods -## build(gemspec , version , outdir ".", validation: true) [](#method-c-build) -## checkout(gemdir , repo , rev , git: $git) [](#method-c-checkout) -## copy(path , *rest ) [](#method-c-copy) -## dummy_gemspec(gemspec ) [](#method-c-dummy_gemspec) -## prepare_test(spec , dir ".") [](#method-c-prepare_test) -**@yield** [gem_dir] - -## unpack(file , *rest ) [](#method-c-unpack) - diff --git a/example/ruby/Bundler.md b/example/ruby/Bundler.md deleted file mode 100644 index 83db7c7..0000000 --- a/example/ruby/Bundler.md +++ /dev/null @@ -1,180 +0,0 @@ -# Module: Bundler - - -module Bundler::URI - - -# Class Methods -## URI(uri ) [](#method-c-URI) -Returns a Bundler::URI object derived from the given `uri`, which may be a -Bundler::URI string or an existing Bundler::URI object: - - # Returns a new Bundler::URI. - uri = Bundler::URI('http://github.com/ruby/ruby') - # => # - # Returns the given Bundler::URI. - Bundler::URI(uri) - # => # -## app_cache(custom_path nil) [](#method-c-app_cache) -## app_config_path() [](#method-c-app_config_path) -## auto_install() [](#method-c-auto_install) -Automatically install dependencies if [Bundler.settings](:auto_install) -exists. This is set through config cmd `bundle config set --global -auto_install 1`. - -Note that this method `nil`s out the global Definition object, so it should be -called first, before you instantiate anything like an `Installer` that'll keep -a reference to the old one instead. -## auto_switch() [](#method-c-auto_switch) -## bin_path() [](#method-c-bin_path) -Returns absolute location of where binstubs are installed to. -## bundle_path() [](#method-c-bundle_path) -Returns absolute path of where gems are installed on the filesystem. -## bundler_major_version() [](#method-c-bundler_major_version) -## clean_env() [](#method-c-clean_env) -**@deprecated** [] Use `unbundled_env` instead - -## clean_exec(*args ) [](#method-c-clean_exec) -**@deprecated** [] Use `unbundled_exec` instead - -## clean_system(*args ) [](#method-c-clean_system) -**@deprecated** [] Use `unbundled_system` instead - -## clear_gemspec_cache() [](#method-c-clear_gemspec_cache) -## configure() [](#method-c-configure) -## configure_gem_home_and_path(path bundle_path) [](#method-c-configure_gem_home_and_path) -## configured_bundle_path() [](#method-c-configured_bundle_path) -## create_bundle_path() [](#method-c-create_bundle_path) -## current_ruby() [](#method-c-current_ruby) -Returns current version of Ruby -**@return** [CurrentRuby] Current version of Ruby - -## default_bundle_dir() [](#method-c-default_bundle_dir) -## default_gemfile() [](#method-c-default_gemfile) -## default_lockfile() [](#method-c-default_lockfile) -## definition(unlock nil, lockfile default_lockfile) [](#method-c-definition) -Returns an instance of Bundler::Definition for given Gemfile and lockfile -**@param** [Hash, Boolean, nil] Gems that have been requested -to be updated or true if all gems should be updated - -**@param** [Pathname] Path to Gemfile.lock - -**@return** [Bundler::Definition] - -## environment() [](#method-c-environment) -## feature_flag() [](#method-c-feature_flag) -## find_executable(path ) [](#method-c-find_executable) -## frozen_bundle?() [](#method-c-frozen_bundle?) -**@return** [Boolean] - -## gem_version() [](#method-c-gem_version) -## git_present?() [](#method-c-git_present?) -**@return** [Boolean] - -## home() [](#method-c-home) -## install_path() [](#method-c-install_path) -## load() [](#method-c-load) -## load_gemspec(file , validate false) [](#method-c-load_gemspec) -## load_gemspec_uncached(file , validate false) [](#method-c-load_gemspec_uncached) -## load_plugins(definition Bundler.definition) [](#method-c-load_plugins) -## local_platform() [](#method-c-local_platform) -## locked_gems() [](#method-c-locked_gems) -## mkdir_p(path ) [](#method-c-mkdir_p) -## original_env() [](#method-c-original_env) -**@return** [Hash] Environment present before Bundler was activated - -## original_exec(*args ) [](#method-c-original_exec) -Run a `Kernel.exec` to a subcommand with the environment present before -Bundler was activated -## original_system(*args ) [](#method-c-original_system) -Run subcommand with the environment present before Bundler was activated -## preferred_gemfile_name() [](#method-c-preferred_gemfile_name) -## read_file(file ) [](#method-c-read_file) -## require(*groups ) [](#method-c-require) -Setups Bundler environment (see Bundler.setup) if it is not already set, and -loads all gems from groups specified. Unlike ::setup, can be called multiple -times with different groups (if they were allowed by setup). - -Assuming Gemfile - - gem 'first_gem', '= 1.0' - group :test do - gem 'second_gem', '= 1.0' - end - -The code will work as follows: - - Bundler.setup # allow all groups - Bundler.require(:default) # requires only first_gem - # ...later - Bundler.require(:test) # requires second_gem -## require_thor_actions() [](#method-c-require_thor_actions) -## reset!() [](#method-c-reset!) -## reset_paths!() [](#method-c-reset_paths!) -## reset_rubygems!() [](#method-c-reset_rubygems!) -## reset_settings_and_root!() [](#method-c-reset_settings_and_root!) -## rm_rf(path ) [](#method-c-rm_rf) -## root() [](#method-c-root) -## ruby_scope() [](#method-c-ruby_scope) -## rubygems() [](#method-c-rubygems) -## safe_load_marshal(data ) [](#method-c-safe_load_marshal) -## self_manager() [](#method-c-self_manager) -## settings() [](#method-c-settings) -## setup(*groups ) [](#method-c-setup) -Turns on the Bundler runtime. After `Bundler.setup` call, all `load` or -`require` of the gems would be allowed only if they are part of the Gemfile or -Ruby's standard library. If the versions specified in Gemfile, only those -versions would be loaded. - -Assuming Gemfile - - gem 'first_gem', '= 1.0' - group :test do - gem 'second_gem', '= 1.0' - end - -The code using Bundler.setup works as follows: - - require 'third_gem' # allowed, required from global gems - require 'first_gem' # allowed, loads the last installed version - Bundler.setup - require 'fourth_gem' # fails with LoadError - require 'second_gem' # loads exactly version 1.0 - -`Bundler.setup` can be called only once, all subsequent calls are no-op. - -If *groups* list is provided, only gems from specified groups would be allowed -(gems specified outside groups belong to special `:default` group). - -To require all gems from Gemfile (or only some groups), see Bundler.require. -## specs_path() [](#method-c-specs_path) -## system_bindir() [](#method-c-system_bindir) -## tmp(name Process.pid.to_s) [](#method-c-tmp) -## ui() [](#method-c-ui) -## ui=(ui ) [](#method-c-ui=) -## unbundle_env!() [](#method-c-unbundle_env!) -Remove all bundler-related variables from ENV -## unbundled_env() [](#method-c-unbundled_env) -**@return** [Hash] Environment with all bundler-related variables removed - -## unbundled_exec(*args ) [](#method-c-unbundled_exec) -Run a `Kernel.exec` to a subcommand in an environment with all bundler related -variables removed -## unbundled_system(*args ) [](#method-c-unbundled_system) -Run subcommand in an environment with all bundler related variables removed -## use_system_gems?() [](#method-c-use_system_gems?) -**@return** [Boolean] - -## user_bundle_path(dir "home") [](#method-c-user_bundle_path) -## user_cache() [](#method-c-user_cache) -## user_home() [](#method-c-user_home) -## which(executable ) [](#method-c-which) -## with_clean_env() [](#method-c-with_clean_env) -**@deprecated** [] Use `with_unbundled_env` instead - -## with_friendly_errors() [](#method-c-with_friendly_errors) -## with_original_env() [](#method-c-with_original_env) -Run block with environment present before Bundler was activated -## with_unbundled_env() [](#method-c-with_unbundled_env) -Run block with all bundler-related variables removed - diff --git a/example/ruby/Bundler/APIResponseInvalidDependenciesError.md b/example/ruby/Bundler/APIResponseInvalidDependenciesError.md deleted file mode 100644 index cd93918..0000000 --- a/example/ruby/Bundler/APIResponseInvalidDependenciesError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::APIResponseInvalidDependenciesError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/APIResponseMismatchError.md b/example/ruby/Bundler/APIResponseMismatchError.md deleted file mode 100644 index 507c4a7..0000000 --- a/example/ruby/Bundler/APIResponseMismatchError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::APIResponseMismatchError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/BuildMetadata.md b/example/ruby/Bundler/BuildMetadata.md deleted file mode 100644 index e3cf896..0000000 --- a/example/ruby/Bundler/BuildMetadata.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: Bundler::BuildMetadata - - -Represents metadata from when the Bundler gem was built. - - -# Class Methods -## built_at() [](#method-c-built_at) -A string representing the date the bundler gem was built. -## git_commit_sha() [](#method-c-git_commit_sha) -The SHA for the git commit the bundler gem was built from. -## release?() [](#method-c-release?) -Whether this is an official release build of Bundler. -**@return** [Boolean] - -## to_h() [](#method-c-to_h) -A hash representation of the build metadata. - diff --git a/example/ruby/Bundler/BundlerError.md b/example/ruby/Bundler/BundlerError.md deleted file mode 100644 index b2c16b3..0000000 --- a/example/ruby/Bundler/BundlerError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Bundler::BundlerError -**Inherits:** StandardError - - - - -# Class Methods -## all_errors() [](#method-c-all_errors) -## status_code(code ) [](#method-c-status_code) - diff --git a/example/ruby/Bundler/CIDetector.md b/example/ruby/Bundler/CIDetector.md deleted file mode 100644 index 5635b79..0000000 --- a/example/ruby/Bundler/CIDetector.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Bundler::CIDetector - - - - -# Class Methods -## ci?() [](#method-c-ci?) -**@return** [Boolean] - -## ci_strings() [](#method-c-ci_strings) - diff --git a/example/ruby/Bundler/CLI.md b/example/ruby/Bundler/CLI.md deleted file mode 100644 index 7769444..0000000 --- a/example/ruby/Bundler/CLI.md +++ /dev/null @@ -1,600 +0,0 @@ -# Class: Bundler::CLI -**Inherits:** Bundler::Thor - -**Includes:** Bundler::Thor::Actions - - - - -# Class Methods -## aliases_for(command_name ) [](#method-c-aliases_for) -## all_aliases() [](#method-c-all_aliases) -## check_deprecated_ext_option(arguments ) [](#method-c-check_deprecated_ext_option) -## deprecated_ext_value?(arguments ) [](#method-c-deprecated_ext_value?) -**@return** [Boolean] - -## dispatch() [](#method-c-dispatch) -## handle_no_command_error(command , has_namespace $thor_runner) [](#method-c-handle_no_command_error) -## reformatted_help_args(args ) [](#method-c-reformatted_help_args) -Reformat the arguments passed to bundle that include a --help flag into the -corresponding `bundle help #{command}` call -## source_root() [](#method-c-source_root) -## start() [](#method-c-start) - -#Instance Methods -## action(instance) [](#method-i-action) -Wraps an action object and call it accordingly to the thor class behavior. - -## add(*gems) [](#method-i-add) - -## append_to_file(path, *args, &block) [](#method-i-append_to_file) -Append text to a file. Since it depends on insert_into_file, it's reversible. - -#### Parameters -path -: path of the file to be changed - -data -: the data to append to the file, can be also given as a block. - -config -: give :verbose => false to not log the status. - - -#### Example - - append_to_file 'config/environments/test.rb', 'config.gem "rspec"' - - append_to_file 'config/environments/test.rb' do - 'config.gem "rspec"' - end - -## apply(path, config{}) [](#method-i-apply) -Loads an external file and execute it in the instance binding. - -#### Parameters -path -: The path to the file to execute. Can be a web address or a relative path - from the source root. - - -#### Examples - - apply "http://gist.github.com/103208" - - apply "recipes/jquery.rb" - -## binstubs(*gems) [](#method-i-binstubs) - -## cache() [](#method-i-cache) - -## check() [](#method-i-check) - -## chmod(path, mode, config{}) [](#method-i-chmod) -Changes the mode of the given file or directory. - -#### Parameters -mode -: the file mode - -path -: the name of the file to change mode - -config -: give :verbose => false to not log the status. - - -#### Example - - chmod "script/server", 0755 - -## clean() [](#method-i-clean) - -## cli_help() [](#method-i-cli_help) - -## comment_lines(path, flag, *args) [](#method-i-comment_lines) -Comment all lines matching a given regex. It will leave the space which -existed before the beginning of the line in tact and will insert a single -space after the comment hash. - -#### Parameters -path -: path of the file to be changed - -flag -: the regexp or string used to decide which lines to comment - -config -: give :verbose => false to not log the status. - - -#### Example - - comment_lines 'config/initializers/session_store.rb', /cookie_store/ - -## console(groupnil) [](#method-i-console) - -## copy_file(source, *args, &block) [](#method-i-copy_file) -Copies the file from the relative source to the relative destination. If the -destination is not given it's assumed to be equal to the source. - -#### Parameters -source -: the relative path to the source root. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status, and :mode => :preserve, to - preserve the file mode from the source. - - -#### Examples - - copy_file "README", "doc/README" - - copy_file "doc/README" - -## create_file(destination, *args, &block) [](#method-i-create_file) -Create a new file relative to the destination root with the given data, which -is the return value of a block or a data string. - -#### Parameters -destination -: the relative path to the destination root. - -data -: the data to append to the file. - -config -: give :verbose => false to not log the status. - - -#### Examples - - create_file "lib/fun_party.rb" do - hostname = ask("What is the virtual hostname I should use?") - "vhost.name = #{hostname}" - end - - create_file "config/apache.conf", "your apache config" - -## create_link(destination, *args) [](#method-i-create_link) -Create a new file relative to the destination root from the given source. - -#### Parameters -destination -: the relative path to the destination root. - -source -: the relative path to the source root. - -config -: give :verbose => false to not log the status. - -: give :symbolic => false for hard link. - - -#### Examples - - create_link "config/apache.conf", "/etc/apache.conf" - -## destination_root() [](#method-i-destination_root) -Returns the root for this thor class (also aliased as destination root). - -## destination_root=(root) [](#method-i-destination_root=) -Sets the root for this thor class. Relatives path are added to the directory -where the script was invoked and expanded. - -## directory(source, *args, &block) [](#method-i-directory) -Copies recursively the files from source directory to root directory. If any -of the files finishes with .tt, it's considered to be a template and is placed -in the destination without the extension .tt. If any empty directory is found, -it's copied and all .empty_directory files are ignored. If any file name is -wrapped within % signs, the text within the % signs will be executed as a -method and replaced with the returned value. Let's suppose a doc directory -with the following files: - - doc/ - components/.empty_directory - README - rdoc.rb.tt - %app_name%.rb - -When invoked as: - - directory "doc" - -It will create a doc directory in the destination with the following files -(assuming that the `app_name` method returns the value "blog"): - - doc/ - components/ - README - rdoc.rb - blog.rb - -**Encoded path note:** Since Bundler::Thor internals use Object#respond_to? to -check if it can expand %something%, this `something` should be a public method -in the class calling #directory. If a method is private, Bundler::Thor stack -raises PrivateMethodEncodedError. - -#### Parameters -source -: the relative path to the source root. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status. If :recursive => false, does - not look for paths recursively. If :mode => :preserve, preserve the file - mode from the source. If :exclude_pattern => /regexp/, prevents copying - files that match that regexp. - - -#### Examples - - directory "doc" - directory "doc", "docs", :recursive => false - -## doctor() [](#method-i-doctor) - -## empty_directory(destination, config{}) [](#method-i-empty_directory) -Creates an empty directory. - -#### Parameters -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status. - - -#### Examples - - empty_directory "doc" - -## env() [](#method-i-env) - -## exec(*args) [](#method-i-exec) - -## find_in_source_paths(file) [](#method-i-find_in_source_paths) -Receives a file or directory and search for it in the source paths. - -**@raise** [Error] - -## fund() [](#method-i-fund) - -## gem(name) [](#method-i-gem) - -## get(source, *args, &block) [](#method-i-get) -Gets the content at the given address and places it at the given relative -destination. If a block is given instead of destination, the content of the -url is yielded and used as location. - -`get` relies on open-uri, so passing application user input would provide a -command injection attack vector. - -#### Parameters -source -: the address of the given content. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status, and :http_headers => - to add headers to an http request. - - -#### Examples - - get "http://gist.github.com/103208", "doc/README" - - get "http://gist.github.com/103208", "doc/README", :http_headers => {"Content-Type" => "application/json"} - - get "http://gist.github.com/103208" do |content| - content.split("\n").first - end - -## gsub_file(path, flag, *args, &block) [](#method-i-gsub_file) -Run a regular expression replacement on a file. - -#### Parameters -path -: path of the file to be changed - -flag -: the regexp or string to be replaced - -replacement -: the replacement, can be also given as a block - -config -: give :verbose => false to not log the status, and :force => true, to force - the replacement regardless of runner behavior. - - -#### Example - - gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' - - gsub_file 'README', /rake/, :green do |match| - match << " no more. Use thor!" - end - -## help(clinil) [](#method-i-help) - -## in_root() [](#method-i-in_root) -Goes to the root and execute the given block. - -## info(gem_name) [](#method-i-info) - -## init() [](#method-i-init) - -## initialize(*args) [](#method-i-initialize) - -**@return** [CLI] a new instance of CLI - -## inject(name, version) [](#method-i-inject) - -## inject_into_class(path, klass, *args, &block) [](#method-i-inject_into_class) -Injects text right after the class definition. Since it depends on -insert_into_file, it's reversible. - -#### Parameters -path -: path of the file to be changed - -klass -: the class to be manipulated - -data -: the data to append to the class, can be also given as a block. - -config -: give :verbose => false to not log the status. - - -#### Examples - - inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " filter_parameter :password\n" - - inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do - " filter_parameter :password\n" - end - -## inject_into_module(path, module_name, *args, &block) [](#method-i-inject_into_module) -Injects text right after the module definition. Since it depends on -insert_into_file, it's reversible. - -#### Parameters -path -: path of the file to be changed - -module_name -: the module to be manipulated - -data -: the data to append to the class, can be also given as a block. - -config -: give :verbose => false to not log the status. - - -#### Examples - - inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper", " def help; 'help'; end\n" - - inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper" do - " def help; 'help'; end\n" - end - -## insert_into_file(destination, *args, &block) [](#method-i-insert_into_file) - -## inside(dir"", config{}, &block) [](#method-i-inside) -Do something in the root or on a provided subfolder. If a relative path is -given it's referenced from the current root. The full path is yielded to the -block you provide. The path is set back to the previous path when the method -exits. - -Returns the value yielded by the block. - -#### Parameters -dir -: the directory to move to. - -config -: give :verbose => true to log and use padding. - - -## install() [](#method-i-install) - -## issue() [](#method-i-issue) - -## licenses() [](#method-i-licenses) - -## link_file(source, *args) [](#method-i-link_file) -Links the file from the relative source to the relative destination. If the -destination is not given it's assumed to be equal to the source. - -#### Parameters -source -: the relative path to the source root. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status. - - -#### Examples - - link_file "README", "doc/README" - - link_file "doc/README" - -## list() [](#method-i-list) - -## lock() [](#method-i-lock) - -## open(name) [](#method-i-open) - -## outdated(*gems) [](#method-i-outdated) - -## platform() [](#method-i-platform) - -## prepend_to_file(path, *args, &block) [](#method-i-prepend_to_file) -Prepend text to a file. Since it depends on insert_into_file, it's reversible. - -#### Parameters -path -: path of the file to be changed - -data -: the data to prepend to the file, can be also given as a block. - -config -: give :verbose => false to not log the status. - - -#### Example - - prepend_to_file 'config/environments/test.rb', 'config.gem "rspec"' - - prepend_to_file 'config/environments/test.rb' do - 'config.gem "rspec"' - end - -## pristine(*gems) [](#method-i-pristine) - -## relative_to_original_destination_root(path, remove_dottrue) [](#method-i-relative_to_original_destination_root) -Returns the given path relative to the absolute root (ie, root where the -script started). - -## remove(*gems) [](#method-i-remove) - -## remove_file(path, config{}) [](#method-i-remove_file) -Removes a file at the given location. - -#### Parameters -path -: path of the file to be changed - -config -: give :verbose => false to not log the status. - - -#### Example - - remove_file 'README' - remove_file 'app/controllers/application_controller.rb' - -## run(command, config{}) [](#method-i-run) -Executes a command returning the contents of the command. - -#### Parameters -command -: the command to be executed. - -config -: give :verbose => false to not log the status, :capture => true to hide to - output. Specify :with to append an executable to command execution. - - -#### Example - - inside('vendor') do - run('ln -s ~/edge rails') - end - -## run_ruby_script(command, config{}) [](#method-i-run_ruby_script) -Executes a ruby script (taking into account WIN32 platform quirks). - -#### Parameters -command -: the command to be executed. - -config -: give :verbose => false to not log the status. - - -## show(gem_namenil) [](#method-i-show) - -## source_paths() [](#method-i-source_paths) -Holds source paths in instance so they can be manipulated. - -## template(source, *args, &block) [](#method-i-template) -Gets an ERB template at the relative source, executes it and makes a copy at -the relative destination. If the destination is not given it's assumed to be -equal to the source removing .tt from the filename. - -#### Parameters -source -: the relative path to the source root. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status. - - -#### Examples - - template "README", "doc/README" - - template "doc/README" - -## thor(command, *args) [](#method-i-thor) -Run a thor command. A hash of options can be given and it's converted to -switches. - -#### Parameters -command -: the command to be invoked - -args -: arguments to the command - -config -: give :verbose => false to not log the status, :capture => true to hide to - output. Other options are given as parameter to Bundler::Thor. - - -#### Examples - - thor :install, "http://gist.github.com/103208" - #=> thor install http://gist.github.com/103208 - - thor :list, :all => true, :substring => 'rails' - #=> thor list --all --substring=rails - -## uncomment_lines(path, flag, *args) [](#method-i-uncomment_lines) -Uncomment all lines matching a given regex. Preserves indentation before the -comment hash and removes the hash and any immediate following space. - -#### Parameters -path -: path of the file to be changed - -flag -: the regexp or string used to decide which lines to uncomment - -config -: give :verbose => false to not log the status. - - -#### Example - - uncomment_lines 'config/initializers/session_store.rb', /active_record/ - -## update(*gems) [](#method-i-update) - -## version() [](#method-i-version) - -## viz() [](#method-i-viz) - diff --git a/example/ruby/Bundler/CLI/Add.md b/example/ruby/Bundler/CLI/Add.md deleted file mode 100644 index 169a4c3..0000000 --- a/example/ruby/Bundler/CLI/Add.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Bundler::CLI::Add -**Inherits:** Object - - - - -# Attributes -## gems[RW] [](#attribute-i-gems) -Returns the value of attribute gems. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## initialize(options, gems) [](#method-i-initialize) - -**@return** [Add] a new instance of Add - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Binstubs.md b/example/ruby/Bundler/CLI/Binstubs.md deleted file mode 100644 index 14cc214..0000000 --- a/example/ruby/Bundler/CLI/Binstubs.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Bundler::CLI::Binstubs -**Inherits:** Object - - - - -# Attributes -## gems[RW] [](#attribute-i-gems) -Returns the value of attribute gems. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options, gems) [](#method-i-initialize) - -**@return** [Binstubs] a new instance of Binstubs - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Cache.md b/example/ruby/Bundler/CLI/Cache.md deleted file mode 100644 index 4173eb0..0000000 --- a/example/ruby/Bundler/CLI/Cache.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Cache -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Cache] a new instance of Cache - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Check.md b/example/ruby/Bundler/CLI/Check.md deleted file mode 100644 index 6483373..0000000 --- a/example/ruby/Bundler/CLI/Check.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Check -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Check] a new instance of Check - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Clean.md b/example/ruby/Bundler/CLI/Clean.md deleted file mode 100644 index 63988a3..0000000 --- a/example/ruby/Bundler/CLI/Clean.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Clean -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Clean] a new instance of Clean - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Common.md b/example/ruby/Bundler/CLI/Common.md deleted file mode 100644 index cd6d415..0000000 --- a/example/ruby/Bundler/CLI/Common.md +++ /dev/null @@ -1,25 +0,0 @@ -# Module: Bundler::CLI::Common - - - - -# Class Methods -## ask_for_spec_from(specs ) [](#method-c-ask_for_spec_from) -## clean_after_install?() [](#method-c-clean_after_install?) -**@return** [Boolean] - -## configure_gem_version_promoter(definition , options ) [](#method-c-configure_gem_version_promoter) -**@raise** [InvalidOption] - -## default_gem_spec(name ) [](#method-c-default_gem_spec) -## ensure_all_gems_in_lockfile!(names , locked_gems Bundler.locked_gems) [](#method-c-ensure_all_gems_in_lockfile!) -## gem_not_found_message(missing_gem_name , alternatives ) [](#method-c-gem_not_found_message) -## output_fund_metadata_summary() [](#method-c-output_fund_metadata_summary) -## output_post_install_messages(messages ) [](#method-c-output_post_install_messages) -## output_without_groups_message(command ) [](#method-c-output_without_groups_message) -## patch_level_options(options ) [](#method-c-patch_level_options) -## print_post_install_message(name , msg ) [](#method-c-print_post_install_message) -## select_spec(name , regex_match nil) [](#method-c-select_spec) -## verbalize_groups(groups ) [](#method-c-verbalize_groups) -## without_groups_message(command ) [](#method-c-without_groups_message) - diff --git a/example/ruby/Bundler/CLI/Config.md b/example/ruby/Bundler/CLI/Config.md deleted file mode 100644 index 200a262..0000000 --- a/example/ruby/Bundler/CLI/Config.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Config -**Inherits:** Bundler::Thor - - - - - -#Instance Methods -## base(namenil, *value) [](#method-i-base) - -## get(name) [](#method-i-get) - -## list() [](#method-i-list) - -## set(name, value, *value_) [](#method-i-set) - -## unset(name) [](#method-i-unset) - diff --git a/example/ruby/Bundler/CLI/Config/Base.md b/example/ruby/Bundler/CLI/Config/Base.md deleted file mode 100644 index fd028df..0000000 --- a/example/ruby/Bundler/CLI/Config/Base.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Bundler::CLI::Config::Base -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## scope[RW] [](#attribute-i-scope) -Returns the value of attribute scope. - -## thor[RW] [](#attribute-i-thor) -Returns the value of attribute thor. - -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## confirm(name) [](#method-i-confirm) - -## confirm_all() [](#method-i-confirm_all) - -## explicit_scope?() [](#method-i-explicit_scope?) - -**@return** [Boolean] - -## initialize(options, name, value, thor) [](#method-i-initialize) - -**@return** [Base] a new instance of Base - -## message() [](#method-i-message) - -## new_value() [](#method-i-new_value) - -## run() [](#method-i-run) - -## show_pretty_values_for(setting) [](#method-i-show_pretty_values_for) - -## validate_scope!() [](#method-i-validate_scope!) - -## warn_unused_scope(msg) [](#method-i-warn_unused_scope) - diff --git a/example/ruby/Bundler/CLI/Console.md b/example/ruby/Bundler/CLI/Console.md deleted file mode 100644 index 2d130ad..0000000 --- a/example/ruby/Bundler/CLI/Console.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Bundler::CLI::Console -**Inherits:** Object - - - - -# Attributes -## group[RW] [](#attribute-i-group) -Returns the value of attribute group. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## get_console(name) [](#method-i-get_console) - -## get_constant(name) [](#method-i-get_constant) - -## initialize(options, group) [](#method-i-initialize) - -**@return** [Console] a new instance of Console - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Doctor.md b/example/ruby/Bundler/CLI/Doctor.md deleted file mode 100644 index 725e9e9..0000000 --- a/example/ruby/Bundler/CLI/Doctor.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Bundler::CLI::Doctor -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## bundles_for_gem(spec) [](#method-i-bundles_for_gem) - -## check!() [](#method-i-check!) - -## dylibs(path) [](#method-i-dylibs) - -## dylibs_darwin(path) [](#method-i-dylibs_darwin) - -## dylibs_ldd(path) [](#method-i-dylibs_ldd) - -## initialize(options) [](#method-i-initialize) - -**@return** [Doctor] a new instance of Doctor - -## ldd_available?() [](#method-i-ldd_available?) - -**@return** [Boolean] - -## otool_available?() [](#method-i-otool_available?) - -**@return** [Boolean] - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Exec.md b/example/ruby/Bundler/CLI/Exec.md deleted file mode 100644 index 531e66f..0000000 --- a/example/ruby/Bundler/CLI/Exec.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Bundler::CLI::Exec -**Inherits:** Object - - - - -# Attributes -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## cmd[RW] [](#attribute-i-cmd) -Returns the value of attribute cmd. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options, args) [](#method-i-initialize) - -**@return** [Exec] a new instance of Exec - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Fund.md b/example/ruby/Bundler/CLI/Fund.md deleted file mode 100644 index 5477ed8..0000000 --- a/example/ruby/Bundler/CLI/Fund.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Fund -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Fund] a new instance of Fund - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Gem.md b/example/ruby/Bundler/CLI/Gem.md deleted file mode 100644 index 45583be..0000000 --- a/example/ruby/Bundler/CLI/Gem.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Bundler::CLI::Gem -**Inherits:** Object - - - - -# Attributes -## extension[RW] [](#attribute-i-extension) -Returns the value of attribute extension. - -## gem_name[RW] [](#attribute-i-gem_name) -Returns the value of attribute gem_name. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## target[RW] [](#attribute-i-target) -Returns the value of attribute target. - -## thor[RW] [](#attribute-i-thor) -Returns the value of attribute thor. - - -#Instance Methods -## initialize(options, gem_name, thor) [](#method-i-initialize) - -**@return** [Gem] a new instance of Gem - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Info.md b/example/ruby/Bundler/CLI/Info.md deleted file mode 100644 index 39c4a80..0000000 --- a/example/ruby/Bundler/CLI/Info.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Bundler::CLI::Info -**Inherits:** Object - - - - -# Attributes -## gem_name[RW] [](#attribute-i-gem_name) -Returns the value of attribute gem_name. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options, gem_name) [](#method-i-initialize) - -**@return** [Info] a new instance of Info - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Init.md b/example/ruby/Bundler/CLI/Init.md deleted file mode 100644 index e19a94a..0000000 --- a/example/ruby/Bundler/CLI/Init.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Init -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Init] a new instance of Init - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Inject.md b/example/ruby/Bundler/CLI/Inject.md deleted file mode 100644 index aec964d..0000000 --- a/example/ruby/Bundler/CLI/Inject.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Bundler::CLI::Inject -**Inherits:** Object - - - - -# Attributes -## gems[RW] [](#attribute-i-gems) -Returns the value of attribute gems. - -## group[RW] [](#attribute-i-group) -Returns the value of attribute group. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## source[RW] [](#attribute-i-source) -Returns the value of attribute source. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## initialize(options, name, version) [](#method-i-initialize) - -**@return** [Inject] a new instance of Inject - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Install.md b/example/ruby/Bundler/CLI/Install.md deleted file mode 100644 index ba10299..0000000 --- a/example/ruby/Bundler/CLI/Install.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Install -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Install] a new instance of Install - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Issue.md b/example/ruby/Bundler/CLI/Issue.md deleted file mode 100644 index d10f237..0000000 --- a/example/ruby/Bundler/CLI/Issue.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bundler::CLI::Issue -**Inherits:** Object - - - - - -#Instance Methods -## doctor() [](#method-i-doctor) - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/List.md b/example/ruby/Bundler/CLI/List.md deleted file mode 100644 index 6e8bf9e..0000000 --- a/example/ruby/Bundler/CLI/List.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bundler::CLI::List -**Inherits:** Object - - - - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [List] a new instance of List - -## run() [](#method-i-run) - -**@raise** [InvalidOption] - diff --git a/example/ruby/Bundler/CLI/Lock.md b/example/ruby/Bundler/CLI/Lock.md deleted file mode 100644 index 19323ac..0000000 --- a/example/ruby/Bundler/CLI/Lock.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Lock -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Lock] a new instance of Lock - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Open.md b/example/ruby/Bundler/CLI/Open.md deleted file mode 100644 index 7b55953..0000000 --- a/example/ruby/Bundler/CLI/Open.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Bundler::CLI::Open -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - -#Instance Methods -## initialize(options, name) [](#method-i-initialize) - -**@return** [Open] a new instance of Open - -## run() [](#method-i-run) - -**@raise** [InvalidOption] - diff --git a/example/ruby/Bundler/CLI/Outdated.md b/example/ruby/Bundler/CLI/Outdated.md deleted file mode 100644 index 35438a1..0000000 --- a/example/ruby/Bundler/CLI/Outdated.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Bundler::CLI::Outdated -**Inherits:** Object - - - - -# Attributes -## filter_options_patch[RW] [](#attribute-i-filter_options_patch) -Returns the value of attribute filter_options_patch. - -## gems[RW] [](#attribute-i-gems) -Returns the value of attribute gems. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## options_include_groups[RW] [](#attribute-i-options_include_groups) -Returns the value of attribute options_include_groups. - -## outdated_gems[RW] [](#attribute-i-outdated_gems) -Returns the value of attribute outdated_gems. - -## sources[RW] [](#attribute-i-sources) -Returns the value of attribute sources. - -## strict[RW] [](#attribute-i-strict) -Returns the value of attribute strict. - - -#Instance Methods -## initialize(options, gems) [](#method-i-initialize) - -**@return** [Outdated] a new instance of Outdated - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Platform.md b/example/ruby/Bundler/CLI/Platform.md deleted file mode 100644 index ace25b3..0000000 --- a/example/ruby/Bundler/CLI/Platform.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::CLI::Platform -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Platform] a new instance of Platform - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Plugin.md b/example/ruby/Bundler/CLI/Plugin.md deleted file mode 100644 index 39aeb6a..0000000 --- a/example/ruby/Bundler/CLI/Plugin.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::CLI::Plugin -**Inherits:** Bundler::Thor - - - - - -#Instance Methods -## install(*plugins) [](#method-i-install) - -## list() [](#method-i-list) - -## uninstall(*plugins) [](#method-i-uninstall) - diff --git a/example/ruby/Bundler/CLI/Pristine.md b/example/ruby/Bundler/CLI/Pristine.md deleted file mode 100644 index f51a79e..0000000 --- a/example/ruby/Bundler/CLI/Pristine.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::CLI::Pristine -**Inherits:** Object - - - - - -#Instance Methods -## initialize(gems) [](#method-i-initialize) - -**@return** [Pristine] a new instance of Pristine - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Remove.md b/example/ruby/Bundler/CLI/Remove.md deleted file mode 100644 index 308771a..0000000 --- a/example/ruby/Bundler/CLI/Remove.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bundler::CLI::Remove -**Inherits:** Object - - - - - -#Instance Methods -## initialize(gems, options) [](#method-i-initialize) - -**@return** [Remove] a new instance of Remove - -## run() [](#method-i-run) - -**@raise** [InvalidOption] - diff --git a/example/ruby/Bundler/CLI/Show.md b/example/ruby/Bundler/CLI/Show.md deleted file mode 100644 index 7bf4d0a..0000000 --- a/example/ruby/Bundler/CLI/Show.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Bundler::CLI::Show -**Inherits:** Object - - - - -# Attributes -## gem_name[RW] [](#attribute-i-gem_name) -Returns the value of attribute gem_name. - -## latest_specs[RW] [](#attribute-i-latest_specs) -Returns the value of attribute latest_specs. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options, gem_name) [](#method-i-initialize) - -**@return** [Show] a new instance of Show - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Update.md b/example/ruby/Bundler/CLI/Update.md deleted file mode 100644 index 931a544..0000000 --- a/example/ruby/Bundler/CLI/Update.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Bundler::CLI::Update -**Inherits:** Object - - - - -# Attributes -## gems[RW] [](#attribute-i-gems) -Returns the value of attribute gems. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options, gems) [](#method-i-initialize) - -**@return** [Update] a new instance of Update - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/CLI/Viz.md b/example/ruby/Bundler/CLI/Viz.md deleted file mode 100644 index 9619302..0000000 --- a/example/ruby/Bundler/CLI/Viz.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Bundler::CLI::Viz -**Inherits:** Object - - - - -# Attributes -## gem_name[RW] [](#attribute-i-gem_name) -Returns the value of attribute gem_name. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Viz] a new instance of Viz - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/Checksum.md b/example/ruby/Bundler/Checksum.md deleted file mode 100644 index 2ee2fa2..0000000 --- a/example/ruby/Bundler/Checksum.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: Bundler::Checksum -**Inherits:** Object - - - - -# Class Methods -## from_api(digest , source_uri , algo DEFAULT_ALGORITHM) [](#method-c-from_api) -## from_gem(io , pathname , algo DEFAULT_ALGORITHM) [](#method-c-from_gem) -## from_gem_package(gem_package , algo DEFAULT_ALGORITHM) [](#method-c-from_gem_package) -## from_lock(lock_checksum , lockfile_location ) [](#method-c-from_lock) -## to_hexdigest(digest , algo DEFAULT_ALGORITHM) [](#method-c-to_hexdigest) -# Attributes -## algo[RW] [](#attribute-i-algo) -Returns the value of attribute algo. - -## digest[RW] [](#attribute-i-digest) -Returns the value of attribute digest. - -## sources[RW] [](#attribute-i-sources) -Returns the value of attribute sources. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## formatted_sources() [](#method-i-formatted_sources) - -## hash() [](#method-i-hash) - -## initialize(algo, digest, source) [](#method-i-initialize) - -**@return** [Checksum] a new instance of Checksum - -## inspect() [](#method-i-inspect) - -## match?(other) [](#method-i-match?) - -**@return** [Boolean] - -## merge!(other) [](#method-i-merge!) - -## removable?() [](#method-i-removable?) - -**@return** [Boolean] - -## removal_instructions() [](#method-i-removal_instructions) - -## same_source?(other) [](#method-i-same_source?) - -**@return** [Boolean] - -## to_lock() [](#method-i-to_lock) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/Checksum/Source.md b/example/ruby/Bundler/Checksum/Source.md deleted file mode 100644 index dcafa45..0000000 --- a/example/ruby/Bundler/Checksum/Source.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Bundler::Checksum::Source -**Inherits:** Object - - - - -# Attributes -## location[RW] [](#attribute-i-location) -Returns the value of attribute location. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(type, location) [](#method-i-initialize) - -**@return** [Source] a new instance of Source - -## removable?() [](#method-i-removable?) - -**@return** [Boolean] - -## removal() [](#method-i-removal) -A full sentence describing how to remove the checksum - -## to_s() [](#method-i-to_s) -phrased so that the usual string format is grammatically correct - rake (10.3.2) sha256=abc123 from #{to_s} - diff --git a/example/ruby/Bundler/Checksum/Store.md b/example/ruby/Bundler/Checksum/Store.md deleted file mode 100644 index e3bd049..0000000 --- a/example/ruby/Bundler/Checksum/Store.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Bundler::Checksum::Store -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Store] a new instance of Store - -## inspect() [](#method-i-inspect) - -## merge!(other) [](#method-i-merge!) - -## register(spec, checksum) [](#method-i-register) - -## replace(spec, checksum) [](#method-i-replace) -Replace when the new checksum is from the same source. The primary purpose is -registering checksums from gems where there are duplicates of the same gem -(according to full_name) in the index. - -In particular, this is when 2 gems have two similar platforms, e.g. "darwin20" -and "darwin-20", both of which resolve to darwin-20. In the Index, the later -gem replaces the former, so we do that here. - -However, if the new checksum is from a different source, we register like -normal. This ensures a mismatch error where there are multiple top level -sources that contain the same gem with different checksums. - -## to_lock(spec) [](#method-i-to_lock) - diff --git a/example/ruby/Bundler/ChecksumMismatchError.md b/example/ruby/Bundler/ChecksumMismatchError.md deleted file mode 100644 index cffc6ca..0000000 --- a/example/ruby/Bundler/ChecksumMismatchError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Bundler::ChecksumMismatchError -**Inherits:** Bundler::SecurityError - - - - - -#Instance Methods -## initialize(lock_name, existing, checksum) [](#method-i-initialize) - -**@return** [ChecksumMismatchError] a new instance of ChecksumMismatchError - -## message() [](#method-i-message) - -## mismatch_resolution_instructions() [](#method-i-mismatch_resolution_instructions) - diff --git a/example/ruby/Bundler/CompactIndexClient.md b/example/ruby/Bundler/CompactIndexClient.md deleted file mode 100644 index 153829d..0000000 --- a/example/ruby/Bundler/CompactIndexClient.md +++ /dev/null @@ -1,57 +0,0 @@ -# Class: Bundler::CompactIndexClient -**Inherits:** Object - - -The CompactIndexClient is responsible for fetching and parsing the compact -index. - -The compact index is a set of caching optimized files that are used to fetch -gem information. The files are: -* names: a list of all gem names -* versions: a list of all gem versions -* [info/](gem): a list of all versions of a gem - -The client is instantiated with: -* `directory`: the root directory where the cache files are stored. -* `fetcher`: (optional) an object that responds to #call(uri_path, headers) - and returns an http response. -If the `fetcher` is not provided, the client will only read cached files from -disk. - -The client is organized into: -* `Updater`: updates the cached files on disk using the fetcher. -* `Cache`: calls the updater, caches files, read and return them from disk -* `Parser`: parses the compact index file data -* `CacheFile`: a concurrency safe file reader/writer that verifies checksums - -The client is intended to optimize memory usage and performance. It is called -100s or 1000s of times, parsing files with hundreds of thousands of lines. It -may be called concurrently without global interpreter lock in some Rubies. As -a result, some methods may look more complex than necessary to save memory or -time. - - -# Class Methods -## debug() [](#method-c-debug) - -#Instance Methods -## available?() [](#method-i-available?) - -**@return** [Boolean] - -## dependencies(names) [](#method-i-dependencies) - -## info(name) [](#method-i-info) - -## initialize(directory, fetchernil) [](#method-i-initialize) - -**@return** [CompactIndexClient] a new instance of CompactIndexClient - -## latest_version(name) [](#method-i-latest_version) - -## names() [](#method-i-names) - -## reset!() [](#method-i-reset!) - -## versions() [](#method-i-versions) - diff --git a/example/ruby/Bundler/CompactIndexClient/Cache.md b/example/ruby/Bundler/CompactIndexClient/Cache.md deleted file mode 100644 index 4404739..0000000 --- a/example/ruby/Bundler/CompactIndexClient/Cache.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Bundler::CompactIndexClient::Cache -**Inherits:** Object - - - - -# Attributes -## directory[RW] [](#attribute-i-directory) -Returns the value of attribute directory. - - -#Instance Methods -## info(name, remote_checksumnil) [](#method-i-info) - -## initialize(directory, fetchernil) [](#method-i-initialize) - -**@return** [Cache] a new instance of Cache - -## names() [](#method-i-names) - -## reset!() [](#method-i-reset!) - -## versions() [](#method-i-versions) - diff --git a/example/ruby/Bundler/CompactIndexClient/CacheFile.md b/example/ruby/Bundler/CompactIndexClient/CacheFile.md deleted file mode 100644 index dfdacc6..0000000 --- a/example/ruby/Bundler/CompactIndexClient/CacheFile.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Bundler::CompactIndexClient::CacheFile -**Inherits:** Object - - -write cache files in a way that is robust to concurrent modifications if -digests are given, the checksums will be verified - - -# Class Methods -## copy(path , &block ) [](#method-c-copy) -Initialize with a copy of the original file, then yield the instance. -## write(path , data , digests nil) [](#method-c-write) -Write data to a temp file, then replace the original file with it verifying -the digests if given. -# Attributes -## original_path[RW] [](#attribute-i-original_path) -Returns the value of attribute original_path. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - -#Instance Methods -## append(data) [](#method-i-append) -Returns false without appending when no digests since appending is too error -prone to do without digests. - -## close() [](#method-i-close) -Remove the temp file without replacing the original file. The file is -permanently closed. - -## commit() [](#method-i-commit) -Replace the original file with the temp file without verifying digests. The -file is permanently closed. - -**@raise** [ClosedError] - -## commit!() [](#method-i-commit!) - -## digests=(expected_digests) [](#method-i-digests=) -set the digests that will be verified at the end - -## digests?() [](#method-i-digests?) - -**@return** [Boolean] - -## initialize(original_path, &block) [](#method-i-initialize) - -**@return** [CacheFile] a new instance of CacheFile - -## initialize_digests(keysnil) [](#method-i-initialize_digests) -initialize the digests using CompactIndexClient::SUPPORTED_DIGESTS, or a -subset based on keys. - -## open(write_mode"wb", perm@perm, &block) [](#method-i-open) -Open the temp file for writing, reusing original permissions, yielding the IO -object. - -**@raise** [ClosedError] - -## reset_digests() [](#method-i-reset_digests) -reset the digests so they don't contain any previously read data - -## size() [](#method-i-size) - -## verify() [](#method-i-verify) -Verify the digests, returning true on match, false on mismatch. - -## write(data) [](#method-i-write) - diff --git a/example/ruby/Bundler/CompactIndexClient/CacheFile/ClosedError.md b/example/ruby/Bundler/CompactIndexClient/CacheFile/ClosedError.md deleted file mode 100644 index 1500eae..0000000 --- a/example/ruby/Bundler/CompactIndexClient/CacheFile/ClosedError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::CompactIndexClient::CacheFile::ClosedError -**Inherits:** Bundler::CompactIndexClient::CacheFile::Error - - - - - diff --git a/example/ruby/Bundler/CompactIndexClient/CacheFile/DigestMismatchError.md b/example/ruby/Bundler/CompactIndexClient/CacheFile/DigestMismatchError.md deleted file mode 100644 index 8b6a4d9..0000000 --- a/example/ruby/Bundler/CompactIndexClient/CacheFile/DigestMismatchError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::CompactIndexClient::CacheFile::DigestMismatchError -**Inherits:** Bundler::CompactIndexClient::CacheFile::Error - - - - - -#Instance Methods -## initialize(digests, expected_digests) [](#method-i-initialize) - -**@return** [DigestMismatchError] a new instance of DigestMismatchError - diff --git a/example/ruby/Bundler/CompactIndexClient/CacheFile/Error.md b/example/ruby/Bundler/CompactIndexClient/CacheFile/Error.md deleted file mode 100644 index 84a6e59..0000000 --- a/example/ruby/Bundler/CompactIndexClient/CacheFile/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::CompactIndexClient::CacheFile::Error -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/Bundler/CompactIndexClient/Error.md b/example/ruby/Bundler/CompactIndexClient/Error.md deleted file mode 100644 index 784957c..0000000 --- a/example/ruby/Bundler/CompactIndexClient/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::CompactIndexClient::Error -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Bundler/CompactIndexClient/GemParser.md b/example/ruby/Bundler/CompactIndexClient/GemParser.md deleted file mode 100644 index 1fec64b..0000000 --- a/example/ruby/Bundler/CompactIndexClient/GemParser.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bundler::CompactIndexClient::GemParser -**Inherits:** Object - - - - - -#Instance Methods -## parse(line) [](#method-i-parse) - diff --git a/example/ruby/Bundler/CompactIndexClient/Parser.md b/example/ruby/Bundler/CompactIndexClient/Parser.md deleted file mode 100644 index f044fd2..0000000 --- a/example/ruby/Bundler/CompactIndexClient/Parser.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Bundler::CompactIndexClient::Parser -**Inherits:** Object - - - - - -#Instance Methods -## available?() [](#method-i-available?) - -**@return** [Boolean] - -## info(name) [](#method-i-info) - -## initialize(compact_index) [](#method-i-initialize) -`compact_index` - an object responding to #names, #versions, #info(name, -checksum), - returning the file contents as a string - -**@return** [Parser] a new instance of Parser - -## names() [](#method-i-names) - -## versions() [](#method-i-versions) - diff --git a/example/ruby/Bundler/CompactIndexClient/Updater.md b/example/ruby/Bundler/CompactIndexClient/Updater.md deleted file mode 100644 index 4220d64..0000000 --- a/example/ruby/Bundler/CompactIndexClient/Updater.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::CompactIndexClient::Updater -**Inherits:** Object - - - - - -#Instance Methods -## initialize(fetcher) [](#method-i-initialize) - -**@return** [Updater] a new instance of Updater - -## update(remote_path, local_path, etag_path) [](#method-i-update) - diff --git a/example/ruby/Bundler/CompactIndexClient/Updater/MismatchedChecksumError.md b/example/ruby/Bundler/CompactIndexClient/Updater/MismatchedChecksumError.md deleted file mode 100644 index dd4ea56..0000000 --- a/example/ruby/Bundler/CompactIndexClient/Updater/MismatchedChecksumError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::CompactIndexClient::Updater::MismatchedChecksumError -**Inherits:** Bundler::CompactIndexClient::Error - - - - - -#Instance Methods -## initialize(path, message) [](#method-i-initialize) - -**@return** [MismatchedChecksumError] a new instance of MismatchedChecksumError - diff --git a/example/ruby/Bundler/ConnectionPool.md b/example/ruby/Bundler/ConnectionPool.md deleted file mode 100644 index e63210e..0000000 --- a/example/ruby/Bundler/ConnectionPool.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Bundler::ConnectionPool -**Inherits:** Object - -**Includes:** Bundler::ConnectionPool::ForkTracker - - -Generic connection pool class for sharing a limited number of objects or -network connections among many threads. Note: pool elements are lazily -created. - -Example usage with block (faster): - - @pool = Bundler::ConnectionPool.new { Redis.new } - @pool.with do |redis| - redis.lpop('my-list') if redis.llen('my-list') > 0 - end - -Using optional timeout override (for that single invocation) - - @pool.with(timeout: 2.0) do |redis| - redis.lpop('my-list') if redis.llen('my-list') > 0 - end - -Example usage replacing an existing connection (slower): - - $redis = Bundler::ConnectionPool.wrap { Redis.new } - - def do_work - $redis.lpop('my-list') if $redis.llen('my-list') > 0 - end - -Accepts the following options: -* :size - number of connections to pool, defaults to 5 -* :timeout - amount of time to wait for a connection if none currently - available, defaults to 5 seconds -* :auto_reload_after_fork - automatically drop all connections after fork, - defaults to true - - -# Class Methods -## after_fork() [](#method-c-after_fork) -## wrap(options , &block ) [](#method-c-wrap) -# Attributes -## auto_reload_after_fork[RW] [](#attribute-i-auto_reload_after_fork) -Automatically drop all connections after fork - -## size[RW] [](#attribute-i-size) -Size of this connection pool - - -#Instance Methods -## _fork() [](#method-i-_fork) - -## available() [](#method-i-available) -Number of pool entries available for checkout at this instant. - -## checkin(force:false) [](#method-i-checkin) - -## checkout(options{}) [](#method-i-checkout) - -## initialize(options{}, &block) [](#method-i-initialize) - -**@raise** [ArgumentError] - -**@return** [ConnectionPool] a new instance of ConnectionPool - -## reload(&block) [](#method-i-reload) -Reloads the Bundler::ConnectionPool by passing each connection to `block` and -then removing it the pool. Subsequent checkouts will create new connections as -needed. - -## shutdown(&block) [](#method-i-shutdown) -Shuts down the Bundler::ConnectionPool by passing each connection to `block` -and then removing it from the pool. Attempting to checkout a connection after -shutdown will raise `Bundler::ConnectionPool::PoolShuttingDownError`. - -## with(options{}) [](#method-i-with) - diff --git a/example/ruby/Bundler/ConnectionPool/Error.md b/example/ruby/Bundler/ConnectionPool/Error.md deleted file mode 100644 index 6278595..0000000 --- a/example/ruby/Bundler/ConnectionPool/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::ConnectionPool::Error -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/Bundler/ConnectionPool/ForkTracker.md b/example/ruby/Bundler/ConnectionPool/ForkTracker.md deleted file mode 100644 index acdcfd1..0000000 --- a/example/ruby/Bundler/ConnectionPool/ForkTracker.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bundler::ConnectionPool::ForkTracker - - - - - -#Instance Methods -## _fork() [](#method-i-_fork) - diff --git a/example/ruby/Bundler/ConnectionPool/PoolShuttingDownError.md b/example/ruby/Bundler/ConnectionPool/PoolShuttingDownError.md deleted file mode 100644 index eb37305..0000000 --- a/example/ruby/Bundler/ConnectionPool/PoolShuttingDownError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::ConnectionPool::PoolShuttingDownError -**Inherits:** Bundler::ConnectionPool::Error - - - - - diff --git a/example/ruby/Bundler/ConnectionPool/TimedStack.md b/example/ruby/Bundler/ConnectionPool/TimedStack.md deleted file mode 100644 index 77c1fbf..0000000 --- a/example/ruby/Bundler/ConnectionPool/TimedStack.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: Bundler::ConnectionPool::TimedStack -**Inherits:** Object - - -Examples: - - ts = TimedStack.new(1) { MyConnection.new } - - # fetch a connection - conn = ts.pop - - # return a connection - ts.push conn - - conn = ts.pop - ts.pop timeout: 5 - #=> raises Bundler::ConnectionPool::TimeoutError after 5 seconds - - -# Attributes -## max[RW] [](#attribute-i-max) -Returns the value of attribute max. - - -#Instance Methods -## empty?() [](#method-i-empty?) -Returns `true` if there are no available connections. - -**@return** [Boolean] - -## initialize(size0, &block) [](#method-i-initialize) -Creates a new pool with `size` connections that are created from the given -`block`. - -**@return** [TimedStack] a new instance of TimedStack - -## length() [](#method-i-length) -The number of connections available on the stack. - -## pop(timeout0.5, options{}) [](#method-i-pop) -Retrieves a connection from the stack. If a connection is available it is -immediately returned. If no connection is available within the given timeout -a Bundler::ConnectionPool::TimeoutError is raised. - -`:timeout` is the only checked entry in `options` and is preferred over the -`timeout` argument (which will be removed in a future release). Other options -may be used by subclasses that extend TimedStack. - -## push(obj, options{}) [](#method-i-push) -Returns `obj` to the stack. `options` is ignored in TimedStack but may be -used by subclasses that extend TimedStack. - -## shutdown(reload:false, &block) [](#method-i-shutdown) -Shuts down the TimedStack by passing each connection to `block` and then -removing it from the pool. Attempting to checkout a connection after shutdown -will raise `Bundler::ConnectionPool::PoolShuttingDownError` unless `:reload` -is `true`. - -**@raise** [ArgumentError] - diff --git a/example/ruby/Bundler/ConnectionPool/TimeoutError.md b/example/ruby/Bundler/ConnectionPool/TimeoutError.md deleted file mode 100644 index ffcd725..0000000 --- a/example/ruby/Bundler/ConnectionPool/TimeoutError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::ConnectionPool::TimeoutError -**Inherits:** Gem::Timeout::Error - - - - - diff --git a/example/ruby/Bundler/ConnectionPool/Wrapper.md b/example/ruby/Bundler/ConnectionPool/Wrapper.md deleted file mode 100644 index 4529b5e..0000000 --- a/example/ruby/Bundler/ConnectionPool/Wrapper.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Bundler::ConnectionPool::Wrapper -**Inherits:** BasicObject - - - - - -#Instance Methods -## initialize(options{}, &block) [](#method-i-initialize) - -**@return** [Wrapper] a new instance of Wrapper - -## method_missing(name, *args, &block) [](#method-i-method_missing) - -## pool_available() [](#method-i-pool_available) - -## pool_shutdown(&block) [](#method-i-pool_shutdown) - -## pool_size() [](#method-i-pool_size) - -## respond_to?(id, *args) [](#method-i-respond_to?) - -**@return** [Boolean] - -## with(&block) [](#method-i-with) - -## wrapped_pool() [](#method-i-wrapped_pool) - diff --git a/example/ruby/Bundler/CorruptBundlerInstallError.md b/example/ruby/Bundler/CorruptBundlerInstallError.md deleted file mode 100644 index 82cd864..0000000 --- a/example/ruby/Bundler/CorruptBundlerInstallError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: Bundler::CorruptBundlerInstallError -**Inherits:** Bundler::BundlerError - - - - - -#Instance Methods -## initialize(loaded_spec) [](#method-i-initialize) - -**@return** [CorruptBundlerInstallError] a new instance of CorruptBundlerInstallError - -## message() [](#method-i-message) - diff --git a/example/ruby/Bundler/CurrentRuby.md b/example/ruby/Bundler/CurrentRuby.md deleted file mode 100644 index 6dc9e13..0000000 --- a/example/ruby/Bundler/CurrentRuby.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Bundler::CurrentRuby -**Inherits:** Object - - - - - -#Instance Methods -## jruby?() [](#method-i-jruby?) - -**@return** [Boolean] - -## maglev?() [](#method-i-maglev?) - -**@return** [Boolean] - -## mri?() [](#method-i-mri?) - -**@return** [Boolean] - -## rbx?() [](#method-i-rbx?) - -**@return** [Boolean] - -## ruby?() [](#method-i-ruby?) - -**@return** [Boolean] - -## truffleruby?() [](#method-i-truffleruby?) - -**@return** [Boolean] - -## windows?() [](#method-i-windows?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/CyclicDependencyError.md b/example/ruby/Bundler/CyclicDependencyError.md deleted file mode 100644 index 21f20cf..0000000 --- a/example/ruby/Bundler/CyclicDependencyError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::CyclicDependencyError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/Definition.md b/example/ruby/Bundler/Definition.md deleted file mode 100644 index 615a85e..0000000 --- a/example/ruby/Bundler/Definition.md +++ /dev/null @@ -1,197 +0,0 @@ -# Class: Bundler::Definition -**Inherits:** Object - -**Includes:** Bundler::GemHelpers - - - - -# Class Methods -## build(gemfile , lockfile , unlock ) [](#method-c-build) -Given a gemfile and lockfile creates a Bundler definition -**@param** [Pathname] Path to Gemfile - -**@param** [Pathname, nil] Path to Gemfile.lock - -**@param** [Hash, Boolean, nil] Gems that have been requested -to be updated or true if all gems should be updated - -**@raise** [GemfileNotFound] - -**@return** [Bundler::Definition] - -# Attributes -## no_lock[RW] [](#attribute-c-no_lock) -Do not create or modify a lockfile (Makes #lock a noop) - -## dependencies[RW] [](#attribute-i-dependencies) -Returns the value of attribute dependencies. - -## gemfiles[RW] [](#attribute-i-gemfiles) -Returns the value of attribute gemfiles. - -## locked_checksums[RW] [](#attribute-i-locked_checksums) -Returns the value of attribute locked_checksums. - -## locked_deps[RW] [](#attribute-i-locked_deps) -Returns the value of attribute locked_deps. - -## locked_gems[RW] [](#attribute-i-locked_gems) -Returns the value of attribute locked_gems. - -## lockfile[RW] [](#attribute-i-lockfile) -Returns the value of attribute lockfile. - -## platforms[RW] [](#attribute-i-platforms) -Returns the value of attribute platforms. - -## ruby_version[RW] [](#attribute-i-ruby_version) -Returns the value of attribute ruby_version. - -## source_requirements=[R] [](#attribute-i-source_requirements=) -Sets the attribute source_requirements - -**@param** [] the value to set the attribute source_requirements to. - -## sources[RW] [](#attribute-i-sources) -Returns the value of attribute sources. - - -#Instance Methods -## add_checksums() [](#method-i-add_checksums) - -## add_platform(platform) [](#method-i-add_platform) - -## bundler_version_to_lock() [](#method-i-bundler_version_to_lock) - -## check!() [](#method-i-check!) - -## current_dependencies() [](#method-i-current_dependencies) - -## current_locked_dependencies() [](#method-i-current_locked_dependencies) - -## deleted_deps() [](#method-i-deleted_deps) - -## dependencies_for(groups) [](#method-i-dependencies_for) - -## ensure_equivalent_gemfile_and_lockfile(explicit_flagfalse) [](#method-i-ensure_equivalent_gemfile_and_lockfile) - -**@raise** [ProductionError] - -## filter_relevant(dependencies) [](#method-i-filter_relevant) - -## gem_version_promoter() [](#method-i-gem_version_promoter) - -## groups() [](#method-i-groups) - -## initialize(lockfile, dependencies, sources, unlock, ruby_versionnil, optional_groups[], gemfiles[]) [](#method-i-initialize) -How does the new system work? - -* Load information from Gemfile and Lockfile -* Invalidate stale locked specs -* All specs from stale source are stale -* All specs that are reachable only through a stale dependency are stale. -* If all fresh dependencies are satisfied by the locked - specs, then we can try to resolve locally. - -**@param** [Pathname] Path to Gemfile.lock - -**@param** [Array(Bundler::Dependency)] array of dependencies from Gemfile - -**@param** [Bundler::SourceList] - -**@param** [Hash, Boolean, nil] Gems that have been requested -to be updated or true if all gems should be updated - -**@param** [Bundler::RubyVersion, nil] Requested Ruby Version - -**@param** [Array(String)] A list of optional groups - -**@return** [Definition] a new instance of Definition - -## lock(file_or_preserve_unknown_sectionsfalse, preserve_unknown_sections_or_unusedfalse) [](#method-i-lock) - -## locked_dependencies() [](#method-i-locked_dependencies) - -## locked_ruby_version() [](#method-i-locked_ruby_version) - -## locked_ruby_version_object() [](#method-i-locked_ruby_version_object) - -## missing_specs() [](#method-i-missing_specs) - -## missing_specs?() [](#method-i-missing_specs?) - -**@return** [Boolean] - -## new_deps() [](#method-i-new_deps) - -## new_specs() [](#method-i-new_specs) - -## no_resolve_needed?() [](#method-i-no_resolve_needed?) - -**@return** [Boolean] - -## normalize_platforms() [](#method-i-normalize_platforms) - -## nothing_changed?() [](#method-i-nothing_changed?) - -**@return** [Boolean] - -## prefer_local!() [](#method-i-prefer_local!) - -## remotely!() [](#method-i-remotely!) - -## remove_platform(platform) [](#method-i-remove_platform) - -**@raise** [InvalidOption] - -## removed_specs() [](#method-i-removed_specs) - -## requested_dependencies() [](#method-i-requested_dependencies) - -## requested_specs() [](#method-i-requested_specs) - -## resolve() [](#method-i-resolve) -Resolve all the dependencies specified in Gemfile. It ensures that -dependencies that have been already resolved via locked file and are fresh are -reused when resolving dependencies - -**@return** [SpecSet] resolved dependencies - -## resolve_remotely!() [](#method-i-resolve_remotely!) - -## resolve_with_cache!() [](#method-i-resolve_with_cache!) - -## setup_domain!(options{}) [](#method-i-setup_domain!) -Setup sources according to the given options and the state of the definition. - -**@return** [Boolean] Whether fetching remote information will be necessary or not - -## spec_git_paths() [](#method-i-spec_git_paths) - -## specs() [](#method-i-specs) -For given dependency list returns a SpecSet with Gemspec of all the required -dependencies. - 1. The method first resolves the dependencies specified in Gemfile - 2. After that it tries and fetches gemspec of resolved dependencies - -**@return** [Bundler::SpecSet] - -## specs_for(groups) [](#method-i-specs_for) - -## to_lock() [](#method-i-to_lock) - -## unlocking?() [](#method-i-unlocking?) - -**@return** [Boolean] - -## validate_platforms!() [](#method-i-validate_platforms!) - -**@raise** [ProductionError] - -## validate_ruby!() [](#method-i-validate_ruby!) - -## validate_runtime!() [](#method-i-validate_runtime!) - -## with_cache!() [](#method-i-with_cache!) - diff --git a/example/ruby/Bundler/Dependency.md b/example/ruby/Bundler/Dependency.md deleted file mode 100644 index 9a3a5ba..0000000 --- a/example/ruby/Bundler/Dependency.md +++ /dev/null @@ -1,71 +0,0 @@ -# Class: Bundler::Dependency -**Inherits:** Gem::Dependency - - - - -# Attributes -## autorequire[RW] [](#attribute-i-autorequire) -Returns the value of attribute autorequire. - -## branch[RW] [](#attribute-i-branch) -Returns the value of attribute branch. - -## gemfile[RW] [](#attribute-i-gemfile) -Returns the value of attribute gemfile. - -## git[RW] [](#attribute-i-git) -Returns the value of attribute git. - -## github[RW] [](#attribute-i-github) -Returns the value of attribute github. - -## glob[RW] [](#attribute-i-glob) -Returns the value of attribute glob. - -## groups[RW] [](#attribute-i-groups) -Returns the value of attribute groups. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - -## platforms[RW] [](#attribute-i-platforms) -Returns the value of attribute platforms. - -## ref[RW] [](#attribute-i-ref) -Returns the value of attribute ref. - - -#Instance Methods -## current_env?() [](#method-i-current_env?) - -**@return** [Boolean] - -## current_platform?() [](#method-i-current_platform?) - -**@return** [Boolean] - -## expanded_platforms() [](#method-i-expanded_platforms) - -## gem_platforms(valid_platforms) [](#method-i-gem_platforms) -Returns the platforms this dependency is valid for, in the same order as -passed in the `valid_platforms` parameter - -## gemspec_dev_dep?() [](#method-i-gemspec_dev_dep?) - -**@return** [Boolean] - -## initialize(name, version, options{}, &blk) [](#method-i-initialize) - -**@return** [Dependency] a new instance of Dependency - -## should_include?() [](#method-i-should_include?) - -**@return** [Boolean] - -## specific?() [](#method-i-specific?) - -**@return** [Boolean] - -## to_lock() [](#method-i-to_lock) - diff --git a/example/ruby/Bundler/Deployment.md b/example/ruby/Bundler/Deployment.md deleted file mode 100644 index 4425f05..0000000 --- a/example/ruby/Bundler/Deployment.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Bundler::Deployment -**Inherits:** Object - - - - -# Class Methods -## define_task(context , task_method :task, opts {}) [](#method-c-define_task) - diff --git a/example/ruby/Bundler/Deprecate.md b/example/ruby/Bundler/Deprecate.md deleted file mode 100644 index 6fb7939..0000000 --- a/example/ruby/Bundler/Deprecate.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Bundler::Deprecate -**Inherits:** Object - - - - -# Class Methods -## skip() [](#method-c-skip) -## skip=(skip ) [](#method-c-skip=) -## skip_during() [](#method-c-skip_during) - diff --git a/example/ruby/Bundler/DeprecatedError.md b/example/ruby/Bundler/DeprecatedError.md deleted file mode 100644 index 6194451..0000000 --- a/example/ruby/Bundler/DeprecatedError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::DeprecatedError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/Digest.md b/example/ruby/Bundler/Digest.md deleted file mode 100644 index 415e20f..0000000 --- a/example/ruby/Bundler/Digest.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: Bundler::Digest - - - - -# Class Methods -## sha1(string ) [](#method-c-sha1) - diff --git a/example/ruby/Bundler/DirectoryRemovalError.md b/example/ruby/Bundler/DirectoryRemovalError.md deleted file mode 100644 index c70d710..0000000 --- a/example/ruby/Bundler/DirectoryRemovalError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::DirectoryRemovalError -**Inherits:** Bundler::BundlerError - - - - - -#Instance Methods -## initialize(orig_exception, msg) [](#method-i-initialize) - -**@return** [DirectoryRemovalError] a new instance of DirectoryRemovalError - diff --git a/example/ruby/Bundler/Dsl.md b/example/ruby/Bundler/Dsl.md deleted file mode 100644 index b9e1820..0000000 --- a/example/ruby/Bundler/Dsl.md +++ /dev/null @@ -1,81 +0,0 @@ -# Class: Bundler::Dsl -**Inherits:** Object - -**Includes:** Bundler::RubyDsl - - - - -# Class Methods -## evaluate(gemfile , lockfile , unlock ) [](#method-c-evaluate) -# Attributes -## dependencies[RW] [](#attribute-i-dependencies) -Returns the value of attribute dependencies. - -## gemfile[RW] [](#attribute-i-gemfile) -Returns the value of attribute gemfile. - -## gemspecs[RW] [](#attribute-i-gemspecs) -Returns the value of attribute gemspecs. - - -#Instance Methods -## check_primary_source_safety() [](#method-i-check_primary_source_safety) - -## env(name) [](#method-i-env) - -## eval_gemfile(gemfile, contentsnil) [](#method-i-eval_gemfile) - -## gem(name, *args) [](#method-i-gem) - -## gemspec(optsnil) [](#method-i-gemspec) - -## git(uri, options{}, &blk) [](#method-i-git) - -## git_source(name, &block) [](#method-i-git_source) - -## github(repo, options{}) [](#method-i-github) - -**@raise** [InvalidArgumentError] - -## group(*args, &blk) [](#method-i-group) - -## initialize() [](#method-i-initialize) - -**@return** [Dsl] a new instance of Dsl - -## install_if(*args) [](#method-i-install_if) - -## method_missing(name, *args) [](#method-i-method_missing) - -**@raise** [GemfileError] - -## normalize_ruby_file(filename) [](#method-i-normalize_ruby_file) -Support the various file formats found in .ruby-version files. - - 3.2.2 - ruby-3.2.2 - -Also supports .tool-versions files for asdf. Lines not starting with "ruby" -are ignored. - - ruby 2.5.1 # comment is ignored - ruby 2.5.1# close comment and extra spaces doesn't confuse - -Intentionally does not support `3.2.1@gemset` since rvm recommends using -.ruby-gemset instead - -Loads the file relative to the dirname of the Gemfile itself. - -## path(path, options{}, &blk) [](#method-i-path) - -## platforms(*platforms) [](#method-i-platforms) - -## plugin(*args) [](#method-i-plugin) - -## ruby(*ruby_version) [](#method-i-ruby) - -## source(source, *args, &blk) [](#method-i-source) - -## to_definition(lockfile, unlock) [](#method-i-to_definition) - diff --git a/example/ruby/Bundler/Dsl/DSLError.md b/example/ruby/Bundler/Dsl/DSLError.md deleted file mode 100644 index a42eaee..0000000 --- a/example/ruby/Bundler/Dsl/DSLError.md +++ /dev/null @@ -1,58 +0,0 @@ -# Exception: Bundler::Dsl::DSLError -**Inherits:** Bundler::GemfileError - - - - -# Attributes -## backtrace[RW] [](#attribute-i-backtrace) - -**@return** [Exception] the backtrace of the exception raised by the -evaluation of the dsl file. - -## description[RW] [](#attribute-i-description) - -**@return** [String] the description that should be presented to the user. - -## dsl_path[RW] [](#attribute-i-dsl_path) - -**@return** [String] the path of the dsl file that raised the exception. - - -#Instance Methods -## contents() [](#method-i-contents) - -**@return** [String] the contents of the DSL that cause the exception to -be raised. - -## initialize(description, dsl_path, backtrace, contentsnil) [](#method-i-initialize) - -**@param** [Exception] @see backtrace - -**@param** [String] @see dsl_path - -**@return** [DSLError] a new instance of DSLError - -## status_code() [](#method-i-status_code) - -## to_s() [](#method-i-to_s) -The message of the exception reports the content of podspec for the line that -generated the original exception. - -**@return** [String] the message of the exception. - - -**@example** -```ruby - -Invalid podspec at `RestKit.podspec` - undefined method -`exclude_header_search_paths=' for # - - from spec-repos/master/RestKit/0.9.3/RestKit.podspec:36 - ------------------------------------------- - # because it would break: #import - > ns.exclude_header_search_paths = 'Code/RestKit.h' - end - ------------------------------------------- -``` \ No newline at end of file diff --git a/example/ruby/Bundler/EndpointSpecification.md b/example/ruby/Bundler/EndpointSpecification.md deleted file mode 100644 index 05dfe90..0000000 --- a/example/ruby/Bundler/EndpointSpecification.md +++ /dev/null @@ -1,83 +0,0 @@ -# Class: Bundler::EndpointSpecification -**Inherits:** Gem::Specification - -**Includes:** Bundler::MatchRemoteMetadata - - -used for Creating Specifications from the Gemcutter Endpoint - - -# Attributes -## checksum[RW] [](#attribute-i-checksum) -Returns the value of attribute checksum. - -## dependencies[RW] [](#attribute-i-dependencies) -Returns the value of attribute dependencies. - -## locked_platform[RW] [](#attribute-i-locked_platform) -Returns the value of attribute locked_platform. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## platform[RW] [](#attribute-i-platform) -Returns the value of attribute platform. - -## remote[RW] [](#attribute-i-remote) -Returns the value of attribute remote. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## __swap__(spec) [](#method-i-__swap__) - -## _local_specification() [](#method-i-_local_specification) - -## bindir() [](#method-i-bindir) -needed for bundle clean - -## executables() [](#method-i-executables) -needed for binstubs - -## extensions() [](#method-i-extensions) -needed for "with native extensions" during install - -## fetch_platform() [](#method-i-fetch_platform) - -## initialize(name, version, platform, spec_fetcher, dependencies, metadatanil) [](#method-i-initialize) - -**@return** [EndpointSpecification] a new instance of EndpointSpecification - -## insecurely_materialized?() [](#method-i-insecurely_materialized?) - -**@return** [Boolean] - -## inspect() [](#method-i-inspect) - -## load_paths() [](#method-i-load_paths) -needed for inline - -## matches_current_metadata?() [](#method-i-matches_current_metadata?) - -**@return** [Boolean] - -## matches_current_ruby?() [](#method-i-matches_current_ruby?) - -**@return** [Boolean] - -## matches_current_rubygems?() [](#method-i-matches_current_rubygems?) - -**@return** [Boolean] - -## metadata() [](#method-i-metadata) -needed for `bundle fund` - -## post_install_message() [](#method-i-post_install_message) -needed for post_install_messages during install - -## require_paths() [](#method-i-require_paths) -needed for standalone, load required_paths from local gemspec after the gem is -installed - diff --git a/example/ruby/Bundler/Env.md b/example/ruby/Bundler/Env.md deleted file mode 100644 index 83e21c9..0000000 --- a/example/ruby/Bundler/Env.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Bundler::Env -**Inherits:** Object - - - - -# Class Methods -## environment() [](#method-c-environment) -## report(options {}) [](#method-c-report) -## write(io ) [](#method-c-write) - diff --git a/example/ruby/Bundler/EnvironmentPreserver.md b/example/ruby/Bundler/EnvironmentPreserver.md deleted file mode 100644 index ef39790..0000000 --- a/example/ruby/Bundler/EnvironmentPreserver.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Bundler::EnvironmentPreserver -**Inherits:** Object - - - - -# Class Methods -## from_env() [](#method-c-from_env) - -#Instance Methods -## backup() [](#method-i-backup) - -**@return** [Hash] - -## initialize(env, keys) [](#method-i-initialize) - -**@param** [Hash] - -**@param** [Array] - -**@return** [EnvironmentPreserver] a new instance of EnvironmentPreserver - -## replace_with_backup() [](#method-i-replace_with_backup) -Replaces `ENV` with the bundler environment variables backed up - -## restore() [](#method-i-restore) - -**@return** [Hash] - diff --git a/example/ruby/Bundler/FeatureFlag.md b/example/ruby/Bundler/FeatureFlag.md deleted file mode 100644 index 4058e84..0000000 --- a/example/ruby/Bundler/FeatureFlag.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bundler::FeatureFlag -**Inherits:** Object - - - - - -#Instance Methods -## initialize(bundler_version) [](#method-i-initialize) - -**@return** [FeatureFlag] a new instance of FeatureFlag - diff --git a/example/ruby/Bundler/FetchMetadata.md b/example/ruby/Bundler/FetchMetadata.md deleted file mode 100644 index 952e453..0000000 --- a/example/ruby/Bundler/FetchMetadata.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: Bundler::FetchMetadata - - - - - -#Instance Methods -## matches_current_ruby?() [](#method-i-matches_current_ruby?) -A fallback is included because the original version of the specification API -didn't include that field, so some marshalled specs in the index have it set -to `nil`. - -**@return** [Boolean] - -## matches_current_rubygems?() [](#method-i-matches_current_rubygems?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/Fetcher.md b/example/ruby/Bundler/Fetcher.md deleted file mode 100644 index b1a61ff..0000000 --- a/example/ruby/Bundler/Fetcher.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Bundler::Fetcher -**Inherits:** Object - - -Handles all the fetching with the rubygems server - - -# Attributes -## api_timeout[RW] [](#attribute-c-api_timeout) -Returns the value of attribute api_timeout. - -## disable_endpoint[RW] [](#attribute-c-disable_endpoint) -Returns the value of attribute disable_endpoint. - -## max_retries[RW] [](#attribute-c-max_retries) -Returns the value of attribute max_retries. - -## redirect_limit[RW] [](#attribute-c-redirect_limit) -Returns the value of attribute redirect_limit. - - -#Instance Methods -## api_fetcher?() [](#method-i-api_fetcher?) - -**@return** [Boolean] - -## fetch_spec(spec) [](#method-i-fetch_spec) -fetch a gem specification - -## gem_remote_fetcher() [](#method-i-gem_remote_fetcher) - -## http_proxy() [](#method-i-http_proxy) - -## initialize(remote) [](#method-i-initialize) - -**@return** [Fetcher] a new instance of Fetcher - -## inspect() [](#method-i-inspect) - -## specs(gem_names, source) [](#method-i-specs) -return the specs in the bundler format as an index - -## specs_with_retry(gem_names, source) [](#method-i-specs_with_retry) -return the specs in the bundler format as an index with retries - -## uri() [](#method-i-uri) - -## user_agent() [](#method-i-user_agent) - diff --git a/example/ruby/Bundler/Fetcher/AuthenticationForbiddenError.md b/example/ruby/Bundler/Fetcher/AuthenticationForbiddenError.md deleted file mode 100644 index f644788..0000000 --- a/example/ruby/Bundler/Fetcher/AuthenticationForbiddenError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: Bundler::Fetcher::AuthenticationForbiddenError -**Inherits:** Bundler::HTTPError - - -This error is raised if HTTP authentication is correct, but lacks necessary -permissions. - - - -#Instance Methods -## initialize(remote_uri) [](#method-i-initialize) - -**@return** [AuthenticationForbiddenError] a new instance of AuthenticationForbiddenError - diff --git a/example/ruby/Bundler/Fetcher/AuthenticationRequiredError.md b/example/ruby/Bundler/Fetcher/AuthenticationRequiredError.md deleted file mode 100644 index bb3ebeb..0000000 --- a/example/ruby/Bundler/Fetcher/AuthenticationRequiredError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Bundler::Fetcher::AuthenticationRequiredError -**Inherits:** Bundler::HTTPError - - -This error is raised if HTTP authentication is required, but not provided. - - - -#Instance Methods -## initialize(remote_uri) [](#method-i-initialize) - -**@return** [AuthenticationRequiredError] a new instance of AuthenticationRequiredError - diff --git a/example/ruby/Bundler/Fetcher/BadAuthenticationError.md b/example/ruby/Bundler/Fetcher/BadAuthenticationError.md deleted file mode 100644 index 8ff28f3..0000000 --- a/example/ruby/Bundler/Fetcher/BadAuthenticationError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Bundler::Fetcher::BadAuthenticationError -**Inherits:** Bundler::HTTPError - - -This error is raised if HTTP authentication is provided, but incorrect. - - - -#Instance Methods -## initialize(remote_uri) [](#method-i-initialize) - -**@return** [BadAuthenticationError] a new instance of BadAuthenticationError - diff --git a/example/ruby/Bundler/Fetcher/Base.md b/example/ruby/Bundler/Fetcher/Base.md deleted file mode 100644 index 005cdec..0000000 --- a/example/ruby/Bundler/Fetcher/Base.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: Bundler::Fetcher::Base -**Inherits:** Object - - - - -# Attributes -## display_uri[RW] [](#attribute-i-display_uri) -Returns the value of attribute display_uri. - -## downloader[RW] [](#attribute-i-downloader) -Returns the value of attribute downloader. - -## gem_remote_fetcher[RW] [](#attribute-i-gem_remote_fetcher) -Returns the value of attribute gem_remote_fetcher. - -## remote[RW] [](#attribute-i-remote) -Returns the value of attribute remote. - - -#Instance Methods -## api_fetcher?() [](#method-i-api_fetcher?) - -**@return** [Boolean] - -## available?() [](#method-i-available?) - -**@return** [Boolean] - -## fetch_uri() [](#method-i-fetch_uri) - -## initialize(downloader, remote, display_uri, gem_remote_fetcher) [](#method-i-initialize) - -**@return** [Base] a new instance of Base - -## remote_uri() [](#method-i-remote_uri) - diff --git a/example/ruby/Bundler/Fetcher/CertificateFailureError.md b/example/ruby/Bundler/Fetcher/CertificateFailureError.md deleted file mode 100644 index 20556d2..0000000 --- a/example/ruby/Bundler/Fetcher/CertificateFailureError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Bundler::Fetcher::CertificateFailureError -**Inherits:** Bundler::HTTPError - - -This is the error raised if OpenSSL fails the cert verification - - - -#Instance Methods -## initialize(remote_uri) [](#method-i-initialize) - -**@return** [CertificateFailureError] a new instance of CertificateFailureError - diff --git a/example/ruby/Bundler/Fetcher/CompactIndex.md b/example/ruby/Bundler/Fetcher/CompactIndex.md deleted file mode 100644 index e021ed3..0000000 --- a/example/ruby/Bundler/Fetcher/CompactIndex.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Bundler::Fetcher::CompactIndex -**Inherits:** Bundler::Fetcher::Base - - - - -# Class Methods -## compact_index_request(method_name ) [](#method-c-compact_index_request) - -#Instance Methods -## api_fetcher?() [](#method-i-api_fetcher?) - -**@return** [Boolean] - -## available?() [](#method-i-available?) - -**@return** [Boolean] - -## specs(gem_names) [](#method-i-specs) - -## specs_for_names(gem_names) [](#method-i-specs_for_names) - diff --git a/example/ruby/Bundler/Fetcher/CompactIndex/ClientFetcher.md b/example/ruby/Bundler/Fetcher/CompactIndex/ClientFetcher.md deleted file mode 100644 index 028b05e..0000000 --- a/example/ruby/Bundler/Fetcher/CompactIndex/ClientFetcher.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bundler::Fetcher::CompactIndex::ClientFetcher -**Inherits:** Struct - - - - - -#Instance Methods -## call(path, headers) [](#method-i-call) - diff --git a/example/ruby/Bundler/Fetcher/Dependency.md b/example/ruby/Bundler/Fetcher/Dependency.md deleted file mode 100644 index 8aebaca..0000000 --- a/example/ruby/Bundler/Fetcher/Dependency.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Bundler::Fetcher::Dependency -**Inherits:** Bundler::Fetcher::Base - - - - - -#Instance Methods -## api_fetcher?() [](#method-i-api_fetcher?) - -**@return** [Boolean] - -## available?() [](#method-i-available?) - -**@return** [Boolean] - -## dependency_api_uri(gem_names[]) [](#method-i-dependency_api_uri) - -## dependency_specs(gem_names) [](#method-i-dependency_specs) - -## get_formatted_specs_and_deps(gem_list) [](#method-i-get_formatted_specs_and_deps) - -## specs(gem_names, full_dependency_list[], last_spec_list[]) [](#method-i-specs) - -## unmarshalled_dep_gems(gem_names) [](#method-i-unmarshalled_dep_gems) - diff --git a/example/ruby/Bundler/Fetcher/Downloader.md b/example/ruby/Bundler/Fetcher/Downloader.md deleted file mode 100644 index f345786..0000000 --- a/example/ruby/Bundler/Fetcher/Downloader.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Bundler::Fetcher::Downloader -**Inherits:** Object - - - - -# Attributes -## connection[RW] [](#attribute-i-connection) -Returns the value of attribute connection. - -## redirect_limit[RW] [](#attribute-i-redirect_limit) -Returns the value of attribute redirect_limit. - - -#Instance Methods -## fetch(uri, headers{}, counter0) [](#method-i-fetch) - -**@raise** [HTTPError] - -## initialize(connection, redirect_limit) [](#method-i-initialize) - -**@return** [Downloader] a new instance of Downloader - -## request(uri, headers) [](#method-i-request) - diff --git a/example/ruby/Bundler/Fetcher/FallbackError.md b/example/ruby/Bundler/Fetcher/FallbackError.md deleted file mode 100644 index db2c627..0000000 --- a/example/ruby/Bundler/Fetcher/FallbackError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::Fetcher::FallbackError -**Inherits:** Bundler::HTTPError - - -This error is raised if the API returns a 413 (only printed in verbose) - - - diff --git a/example/ruby/Bundler/Fetcher/GemRemoteFetcher.md b/example/ruby/Bundler/Fetcher/GemRemoteFetcher.md deleted file mode 100644 index ae9840f..0000000 --- a/example/ruby/Bundler/Fetcher/GemRemoteFetcher.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bundler::Fetcher::GemRemoteFetcher -**Inherits:** Gem::RemoteFetcher - - - - - -#Instance Methods -## request(*args) [](#method-i-request) - diff --git a/example/ruby/Bundler/Fetcher/Index.md b/example/ruby/Bundler/Fetcher/Index.md deleted file mode 100644 index 5885856..0000000 --- a/example/ruby/Bundler/Fetcher/Index.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bundler::Fetcher::Index -**Inherits:** Bundler::Fetcher::Base - - - - - -#Instance Methods -## specs(_gem_names) [](#method-i-specs) - diff --git a/example/ruby/Bundler/Fetcher/NetworkDownError.md b/example/ruby/Bundler/Fetcher/NetworkDownError.md deleted file mode 100644 index 6dba270..0000000 --- a/example/ruby/Bundler/Fetcher/NetworkDownError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::Fetcher::NetworkDownError -**Inherits:** Bundler::HTTPError - - -This error is raised when it looks like the network is down - - - diff --git a/example/ruby/Bundler/Fetcher/SSLError.md b/example/ruby/Bundler/Fetcher/SSLError.md deleted file mode 100644 index b3fe855..0000000 --- a/example/ruby/Bundler/Fetcher/SSLError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Bundler::Fetcher::SSLError -**Inherits:** Bundler::HTTPError - - -This is the error raised when a source is HTTPS and OpenSSL didn't load - - - -#Instance Methods -## initialize(msgnil) [](#method-i-initialize) - -**@return** [SSLError] a new instance of SSLError - diff --git a/example/ruby/Bundler/Fetcher/TooManyRequestsError.md b/example/ruby/Bundler/Fetcher/TooManyRequestsError.md deleted file mode 100644 index 7adec17..0000000 --- a/example/ruby/Bundler/Fetcher/TooManyRequestsError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::Fetcher::TooManyRequestsError -**Inherits:** Bundler::HTTPError - - -This error is raised if we should rate limit our requests to the API - - - diff --git a/example/ruby/Bundler/FileUtils.md b/example/ruby/Bundler/FileUtils.md deleted file mode 100644 index b88c26b..0000000 --- a/example/ruby/Bundler/FileUtils.md +++ /dev/null @@ -1,1779 +0,0 @@ -# Module: Bundler::FileUtils - -**Extended by:** Bundler::FileUtils::StreamUtils_ - -**Includes:** Bundler::FileUtils::StreamUtils_ - - -Namespace for file utility methods for copying, moving, removing, etc. - -## What's Here - -First, what’s elsewhere. Module Bundler::FileUtils: - -* Inherits from [class Object](rdoc-ref:Object). -* Supplements [class File](rdoc-ref:File) (but is not included or extended - there). - -Here, module Bundler::FileUtils provides methods that are useful for: - -* [Creating](rdoc-ref:FileUtils@Creating). -* [Deleting](rdoc-ref:FileUtils@Deleting). -* [Querying](rdoc-ref:FileUtils@Querying). -* [Setting](rdoc-ref:FileUtils@Setting). -* [Comparing](rdoc-ref:FileUtils@Comparing). -* [Copying](rdoc-ref:FileUtils@Copying). -* [Moving](rdoc-ref:FileUtils@Moving). -* [Options](rdoc-ref:FileUtils@Options). - -### Creating - -* ::mkdir: Creates directories. -* ::mkdir_p, ::makedirs, ::mkpath: Creates directories, also creating - ancestor directories as needed. -* ::link_entry: Creates a hard link. -* ::ln, ::link: Creates hard links. -* ::ln_s, ::symlink: Creates symbolic links. -* ::ln_sf: Creates symbolic links, overwriting if necessary. -* ::ln_sr: Creates symbolic links relative to targets - -### Deleting - -* ::remove_dir: Removes a directory and its descendants. -* ::remove_entry: Removes an entry, including its descendants if it is a - directory. -* ::remove_entry_secure: Like ::remove_entry, but removes securely. -* ::remove_file: Removes a file entry. -* ::rm, ::remove: Removes entries. -* ::rm_f, ::safe_unlink: Like ::rm, but removes forcibly. -* ::rm_r: Removes entries and their descendants. -* ::rm_rf, ::rmtree: Like ::rm_r, but removes forcibly. -* ::rmdir: Removes directories. - -### Querying - -* ::pwd, ::getwd: Returns the path to the working directory. -* ::uptodate?: Returns whether a given entry is newer than given other - entries. - -### Setting - -* ::cd, ::chdir: Sets the working directory. -* ::chmod: Sets permissions for an entry. -* ::chmod_R: Sets permissions for an entry and its descendants. -* ::chown: Sets the owner and group for entries. -* ::chown_R: Sets the owner and group for entries and their descendants. -* ::touch: Sets modification and access times for entries, creating if - necessary. - -### Comparing - -* ::compare_file, ::cmp, ::identical?: Returns whether two entries are - identical. -* ::compare_stream: Returns whether two streams are identical. - -### Copying - -* ::copy_entry: Recursively copies an entry. -* ::copy_file: Copies an entry. -* ::copy_stream: Copies a stream. -* ::cp, ::copy: Copies files. -* ::cp_lr: Recursively creates hard links. -* ::cp_r: Recursively copies files, retaining mode, owner, and group. -* ::install: Recursively copies files, optionally setting mode, owner, and - group. - -### Moving - -* ::mv, ::move: Moves entries. - -### Options - -* ::collect_method: Returns the names of methods that accept a given option. -* ::commands: Returns the names of methods that accept options. -* ::have_option?: Returns whether a given method accepts a given option. -* ::options: Returns all option names. -* ::options_of: Returns the names of the options for a given method. - -## Path Arguments - -Some methods in Bundler::FileUtils accept *path* arguments, which are -interpreted as paths to filesystem entries: - -* If the argument is a string, that value is the path. -* If the argument has method `:to_path`, it is converted via that method. -* If the argument has method `:to_str`, it is converted via that method. - -## About the Examples - -Some examples here involve trees of file entries. For these, we sometimes -display trees using the [tree command-line -utility](https://en.wikipedia.org/wiki/Tree_(command)), which is a recursive -directory-listing utility that produces a depth-indented listing of files and -directories. - -We use a helper method to launch the command and control the format: - - def tree(dirpath = '.') - command = "tree --noreport --charset=ascii #{dirpath}" - system(command) - end - -To illustrate: - - tree('src0') - # => src0 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - -## Avoiding the TOCTTOU Vulnerability - -For certain methods that recursively remove entries, there is a potential -vulnerability called the [Time-of-check to -time-of-use](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use), or -TOCTTOU, vulnerability that can exist when: - -* An ancestor directory of the entry at the target path is world writable; - such directories include `/tmp`. -* The directory tree at the target path includes: - - * A world-writable descendant directory. - * A symbolic link. - -To avoid that vulnerability, you can use this method to remove entries: - -* Bundler::FileUtils.remove_entry_secure: removes recursively if the target - path points to a directory. - -Also available are these methods, each of which calls -Bundler::FileUtils.remove_entry_secure: - -* Bundler::FileUtils.rm_r with keyword argument `secure: true`. -* Bundler::FileUtils.rm_rf with keyword argument `secure: true`. - -Finally, this method for moving entries calls -Bundler::FileUtils.remove_entry_secure if the source and destination are on -different file systems (which means that the "move" is really a copy and -remove): - -* Bundler::FileUtils.mv with keyword argument `secure: true`. - -Method Bundler::FileUtils.remove_entry_secure removes securely by applying a -special pre-process: - -* If the target path points to a directory, this method uses methods - [File#chown](rdoc-ref:File#chown) and [File#chmod](rdoc-ref:File#chmod) in - removing directories. -* The owner of the target directory should be either the current process or - the super user (root). - -WARNING: You must ensure that **ALL** parent directories cannot be moved by -other untrusted users. For example, parent directories should not be owned by -untrusted users, and should not be world writable except when the sticky bit -is set. - -For details of this security vulnerability, see Perl cases: - -* [CVE-2005-0448](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-04 - 48). -* [CVE-2004-0452](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-04 - 52). - - -# Class Methods -## cd(dir , verbose: nil, &block ) [](#method-c-cd) -Changes the working directory to the given `dir`, which should be -[interpretable as a path](rdoc-ref:FileUtils@Path+Arguments): - -With no block given, changes the current directory to the directory at `dir`; -returns zero: - - Bundler::FileUtils.pwd # => "/rdoc/fileutils" - Bundler::FileUtils.cd('..') - Bundler::FileUtils.pwd # => "/rdoc" - Bundler::FileUtils.cd('fileutils') - -With a block given, changes the current directory to the directory at `dir`, -calls the block with argument `dir`, and restores the original current -directory; returns the block's value: - - Bundler::FileUtils.pwd # => "/rdoc/fileutils" - Bundler::FileUtils.cd('..') { |arg| [arg, Bundler::FileUtils.pwd] } # => ["..", "/rdoc"] - Bundler::FileUtils.pwd # => "/rdoc/fileutils" - -Keyword arguments: - -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.cd('..') - Bundler::FileUtils.cd('fileutils') - - Output: - - cd .. - cd fileutils - -Related: Bundler::FileUtils.pwd. -## chdir() [](#method-c-chdir) -Changes the working directory to the given `dir`, which should be -[interpretable as a path](rdoc-ref:FileUtils@Path+Arguments): - -With no block given, changes the current directory to the directory at `dir`; -returns zero: - - Bundler::FileUtils.pwd # => "/rdoc/fileutils" - Bundler::FileUtils.cd('..') - Bundler::FileUtils.pwd # => "/rdoc" - Bundler::FileUtils.cd('fileutils') - -With a block given, changes the current directory to the directory at `dir`, -calls the block with argument `dir`, and restores the original current -directory; returns the block's value: - - Bundler::FileUtils.pwd # => "/rdoc/fileutils" - Bundler::FileUtils.cd('..') { |arg| [arg, Bundler::FileUtils.pwd] } # => ["..", "/rdoc"] - Bundler::FileUtils.pwd # => "/rdoc/fileutils" - -Keyword arguments: - -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.cd('..') - Bundler::FileUtils.cd('fileutils') - - Output: - - cd .. - cd fileutils - -Related: Bundler::FileUtils.pwd. -## chmod(mode , list , noop: nil, verbose: nil) [](#method-c-chmod) -Changes permissions on the entries at the paths given in `list` (a single path -or an array of paths) to the permissions given by `mode`; returns `list` if it -is an array, `[list]` otherwise: - -* Modifies each entry that is a regular file using - [File.chmod](rdoc-ref:File.chmod). -* Modifies each entry that is a symbolic link using - [File.lchmod](rdoc-ref:File.lchmod). - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -Argument `mode` may be either an integer or a string: - -* Integer `mode`: represents the permission bits to be set: - - Bundler::FileUtils.chmod(0755, 'src0.txt') - Bundler::FileUtils.chmod(0644, ['src0.txt', 'src0.dat']) - -* String `mode`: represents the permissions to be set: - - The string is of the form `[targets][[operator][perms[,perms]]`, where: - - * `targets` may be any combination of these letters: - - * `'u'`: permissions apply to the file's owner. - * `'g'`: permissions apply to users in the file's group. - * `'o'`: permissions apply to other users not in the file's group. - * `'a'` (the default): permissions apply to all users. - - * `operator` may be one of these letters: - - * `'+'`: adds permissions. - * `'-'`: removes permissions. - * `'='`: sets (replaces) permissions. - - * `perms` (may be repeated, with separating commas) may be any - combination of these letters: - - * `'r'`: Read. - * `'w'`: Write. - * `'x'`: Execute (search, for a directory). - * `'X'`: Search (for a directories only; must be used with `'+'`) - * `'s'`: Uid or gid. - * `'t'`: Sticky bit. - - Examples: - - Bundler::FileUtils.chmod('u=wrx,go=rx', 'src1.txt') - Bundler::FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby') - -Keyword arguments: - -* `noop: true` - does not change permissions; returns `nil`. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.chmod(0755, 'src0.txt', noop: true, verbose: true) - Bundler::FileUtils.chmod(0644, ['src0.txt', 'src0.dat'], noop: true, verbose: true) - Bundler::FileUtils.chmod('u=wrx,go=rx', 'src1.txt', noop: true, verbose: true) - Bundler::FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby', noop: true, verbose: true) - - Output: - - chmod 755 src0.txt - chmod 644 src0.txt src0.dat - chmod u=wrx,go=rx src1.txt - chmod u=wrx,go=rx /usr/bin/ruby - -Related: Bundler::FileUtils.chmod_R. -## chmod_R(mode , list , noop: nil, verbose: nil, force: nil) [](#method-c-chmod_R) -Like Bundler::FileUtils.chmod, but changes permissions recursively. -## chown(user , group , list , noop: nil, verbose: nil) [](#method-c-chown) -Changes the owner and group on the entries at the paths given in `list` (a -single path or an array of paths) to the given `user` and `group`; returns -`list` if it is an array, `[list]` otherwise: - -* Modifies each entry that is a regular file using - [File.chown](rdoc-ref:File.chown). -* Modifies each entry that is a symbolic link using - [File.lchown](rdoc-ref:File.lchown). - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -User and group: - -* Argument `user` may be a user name or a user id; if `nil` or `-1`, the - user is not changed. -* Argument `group` may be a group name or a group id; if `nil` or `-1`, the - group is not changed. -* The user must be a member of the group. - -Examples: - - # One path. - # User and group as string names. - File.stat('src0.txt').uid # => 1004 - File.stat('src0.txt').gid # => 1004 - Bundler::FileUtils.chown('user2', 'group1', 'src0.txt') - File.stat('src0.txt').uid # => 1006 - File.stat('src0.txt').gid # => 1005 - - # User and group as uid and gid. - Bundler::FileUtils.chown(1004, 1004, 'src0.txt') - File.stat('src0.txt').uid # => 1004 - File.stat('src0.txt').gid # => 1004 - - # Array of paths. - Bundler::FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat']) - - # Directory (not recursive). - Bundler::FileUtils.chown('user2', 'group1', '.') - -Keyword arguments: - -* `noop: true` - does not change permissions; returns `nil`. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.chown('user2', 'group1', 'src0.txt', noop: true, verbose: true) - Bundler::FileUtils.chown(1004, 1004, 'src0.txt', noop: true, verbose: true) - Bundler::FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat'], noop: true, verbose: true) - Bundler::FileUtils.chown('user2', 'group1', path, noop: true, verbose: true) - Bundler::FileUtils.chown('user2', 'group1', '.', noop: true, verbose: true) - - Output: - - chown user2:group1 src0.txt - chown 1004:1004 src0.txt - chown 1006:1005 src0.txt src0.dat - chown user2:group1 src0.txt - chown user2:group1 . - -Related: Bundler::FileUtils.chown_R. -## chown_R(user , group , list , noop: nil, verbose: nil, force: nil) [](#method-c-chown_R) -Like Bundler::FileUtils.chown, but changes owner and group recursively. -## cmp() [](#method-c-cmp) -Returns `true` if the contents of files `a` and `b` are identical, `false` -otherwise. - -Arguments `a` and `b` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Bundler::FileUtils.identical? and Bundler::FileUtils.cmp are aliases for -Bundler::FileUtils.compare_file. - -Related: Bundler::FileUtils.compare_stream. -## collect_method(opt ) [](#method-c-collect_method) -Returns an array of the string method names of the methods that accept the -given keyword option `opt`; the argument must be a symbol: - - Bundler::FileUtils.collect_method(:preserve) # => ["cp", "copy", "cp_r", "install"] -## commands() [](#method-c-commands) -Returns an array of the string names of Bundler::FileUtils methods that accept -one or more keyword arguments: - - Bundler::FileUtils.commands.sort.take(3) # => ["cd", "chdir", "chmod"] -## compare_file(a , b ) [](#method-c-compare_file) -Returns `true` if the contents of files `a` and `b` are identical, `false` -otherwise. - -Arguments `a` and `b` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Bundler::FileUtils.identical? and Bundler::FileUtils.cmp are aliases for -Bundler::FileUtils.compare_file. - -Related: Bundler::FileUtils.compare_stream. -## compare_stream(a , b ) [](#method-c-compare_stream) -Returns `true` if the contents of streams `a` and `b` are identical, `false` -otherwise. - -Arguments `a` and `b` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Related: Bundler::FileUtils.compare_file. -## copy() [](#method-c-copy) -Copies files. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a file and `dest` is not the path to a directory, -copies `src` to `dest`: - - Bundler::FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - Bundler::FileUtils.cp('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is the path to a file and `dest` is the path to a directory, copies -`src` to `dest/src`: - - Bundler::FileUtils.touch('src1.txt') - Bundler::FileUtils.mkdir('dest1') - Bundler::FileUtils.cp('src1.txt', 'dest1') - File.file?('dest1/src1.txt') # => true - -If `src` is an array of paths to files and `dest` is the path to a directory, -copies from each `src` to `dest`: - - src_file_paths = ['src2.txt', 'src2.dat'] - Bundler::FileUtils.touch(src_file_paths) - Bundler::FileUtils.mkdir('dest2') - Bundler::FileUtils.cp(src_file_paths, 'dest2') - File.file?('dest2/src2.txt') # => true - File.file?('dest2/src2.dat') # => true - -Keyword arguments: - -* `preserve: true` - preserves file times. -* `noop: true` - does not copy files. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.cp('src0.txt', 'dest0.txt', noop: true, verbose: true) - Bundler::FileUtils.cp('src1.txt', 'dest1', noop: true, verbose: true) - Bundler::FileUtils.cp(src_file_paths, 'dest2', noop: true, verbose: true) - - Output: - - cp src0.txt dest0.txt - cp src1.txt dest1 - cp src2.txt src2.dat dest2 - -Raises an exception if `src` is a directory. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## copy_entry(src , dest , preserve false, dereference_root false, remove_destination false) [](#method-c-copy_entry) -Recursively copies files from `src` to `dest`. - -Arguments `src` and `dest` should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a file, copies `src` to `dest`: - - Bundler::FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - Bundler::FileUtils.copy_entry('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is a directory, recursively copies `src` to `dest`: - - tree('src1') - # => src1 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - Bundler::FileUtils.copy_entry('src1', 'dest1') - tree('dest1') - # => dest1 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - -The recursive copying preserves file types for regular files, directories, and -symbolic links; other file types (FIFO streams, device files, etc.) are not -supported. - -Keyword arguments: - -* `dereference_root: true` - if `src` is a symbolic link, follows the link. -* `preserve: true` - preserves file times. -* `remove_destination: true` - removes `dest` before copying files. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## copy_file(src , dest , preserve false, dereference true) [](#method-c-copy_file) -Copies file from `src` to `dest`, which should not be directories. - -Arguments `src` and `dest` should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -Examples: - - Bundler::FileUtils.touch('src0.txt') - Bundler::FileUtils.copy_file('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -Keyword arguments: - -* `dereference: false` - if `src` is a symbolic link, does not follow the - link. -* `preserve: true` - preserves file times. -* `remove_destination: true` - removes `dest` before copying files. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## copy_stream(src , dest ) [](#method-c-copy_stream) -Copies IO stream `src` to IO stream `dest` via -[IO.copy_stream](rdoc-ref:IO.copy_stream). - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## cp(src , dest , preserve: nil, noop: nil, verbose: nil) [](#method-c-cp) -Copies files. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a file and `dest` is not the path to a directory, -copies `src` to `dest`: - - Bundler::FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - Bundler::FileUtils.cp('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is the path to a file and `dest` is the path to a directory, copies -`src` to `dest/src`: - - Bundler::FileUtils.touch('src1.txt') - Bundler::FileUtils.mkdir('dest1') - Bundler::FileUtils.cp('src1.txt', 'dest1') - File.file?('dest1/src1.txt') # => true - -If `src` is an array of paths to files and `dest` is the path to a directory, -copies from each `src` to `dest`: - - src_file_paths = ['src2.txt', 'src2.dat'] - Bundler::FileUtils.touch(src_file_paths) - Bundler::FileUtils.mkdir('dest2') - Bundler::FileUtils.cp(src_file_paths, 'dest2') - File.file?('dest2/src2.txt') # => true - File.file?('dest2/src2.dat') # => true - -Keyword arguments: - -* `preserve: true` - preserves file times. -* `noop: true` - does not copy files. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.cp('src0.txt', 'dest0.txt', noop: true, verbose: true) - Bundler::FileUtils.cp('src1.txt', 'dest1', noop: true, verbose: true) - Bundler::FileUtils.cp(src_file_paths, 'dest2', noop: true, verbose: true) - - Output: - - cp src0.txt dest0.txt - cp src1.txt dest1 - cp src2.txt src2.dat dest2 - -Raises an exception if `src` is a directory. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## cp_lr(src , dest , noop: nil, verbose: nil, dereference_root: true, remove_destination: false) [](#method-c-cp_lr) -Creates [hard links](https://en.wikipedia.org/wiki/Hard_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a directory and `dest` does not exist, creates links -`dest` and descendents pointing to `src` and its descendents: - - tree('src0') - # => src0 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - File.exist?('dest0') # => false - Bundler::FileUtils.cp_lr('src0', 'dest0') - tree('dest0') - # => dest0 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - -If `src` and `dest` are both paths to directories, creates links `dest/src` -and descendents pointing to `src` and its descendents: - - tree('src1') - # => src1 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - Bundler::FileUtils.mkdir('dest1') - Bundler::FileUtils.cp_lr('src1', 'dest1') - tree('dest1') - # => dest1 - # `-- src1 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - -If `src` is an array of paths to entries and `dest` is the path to a -directory, for each path `filepath` in `src`, creates a link at -`dest/filepath` pointing to that path: - - tree('src2') - # => src2 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - Bundler::FileUtils.mkdir('dest2') - Bundler::FileUtils.cp_lr(['src2/sub0', 'src2/sub1'], 'dest2') - tree('dest2') - # => dest2 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - -Keyword arguments: - -* `dereference_root: false` - if `src` is a symbolic link, does not - dereference it. -* `noop: true` - does not create links. -* `remove_destination: true` - removes `dest` before creating links. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.cp_lr('src0', 'dest0', noop: true, verbose: true) - Bundler::FileUtils.cp_lr('src1', 'dest1', noop: true, verbose: true) - Bundler::FileUtils.cp_lr(['src2/sub0', 'src2/sub1'], 'dest2', noop: true, verbose: true) - - Output: - - cp -lr src0 dest0 - cp -lr src1 dest1 - cp -lr src2/sub0 src2/sub1 dest2 - -Raises an exception if `dest` is the path to an existing file or directory and -keyword argument `remove_destination: true` is not given. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## cp_r(src , dest , preserve: nil, noop: nil, verbose: nil, dereference_root: true, remove_destination: nil) [](#method-c-cp_r) -Recursively copies files. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -The mode, owner, and group are retained in the copy; to change those, use -Bundler::FileUtils.install instead. - -If `src` is the path to a file and `dest` is not the path to a directory, -copies `src` to `dest`: - - Bundler::FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - Bundler::FileUtils.cp_r('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is the path to a file and `dest` is the path to a directory, copies -`src` to `dest/src`: - - Bundler::FileUtils.touch('src1.txt') - Bundler::FileUtils.mkdir('dest1') - Bundler::FileUtils.cp_r('src1.txt', 'dest1') - File.file?('dest1/src1.txt') # => true - -If `src` is the path to a directory and `dest` does not exist, recursively -copies `src` to `dest`: - - tree('src2') - # => src2 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - Bundler::FileUtils.exist?('dest2') # => false - Bundler::FileUtils.cp_r('src2', 'dest2') - tree('dest2') - # => dest2 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - -If `src` and `dest` are paths to directories, recursively copies `src` to -`dest/src`: - - tree('src3') - # => src3 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - Bundler::FileUtils.mkdir('dest3') - Bundler::FileUtils.cp_r('src3', 'dest3') - tree('dest3') - # => dest3 - # `-- src3 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - -If `src` is an array of paths and `dest` is a directory, recursively copies -from each path in `src` to `dest`; the paths in `src` may point to files -and/or directories. - -Keyword arguments: - -* `dereference_root: false` - if `src` is a symbolic link, does not - dereference it. -* `noop: true` - does not copy files. -* `preserve: true` - preserves file times. -* `remove_destination: true` - removes `dest` before copying files. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.cp_r('src0.txt', 'dest0.txt', noop: true, verbose: true) - Bundler::FileUtils.cp_r('src1.txt', 'dest1', noop: true, verbose: true) - Bundler::FileUtils.cp_r('src2', 'dest2', noop: true, verbose: true) - Bundler::FileUtils.cp_r('src3', 'dest3', noop: true, verbose: true) - - Output: - - cp -r src0.txt dest0.txt - cp -r src1.txt dest1 - cp -r src2 dest2 - cp -r src3 dest3 - -Raises an exception of `src` is the path to a directory and `dest` is the path -to a file. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## getwd() [](#method-c-getwd) -Returns a string containing the path to the current directory: - - Bundler::FileUtils.pwd # => "/rdoc/fileutils" - -Related: Bundler::FileUtils.cd. -## have_option?(mid , opt ) [](#method-c-have_option?) -Returns `true` if method `mid` accepts the given option `opt`, `false` -otherwise; the arguments may be strings or symbols: - - Bundler::FileUtils.have_option?(:chmod, :noop) # => true - Bundler::FileUtils.have_option?('chmod', 'secure') # => false -**@return** [Boolean] - -## identical?() [](#method-c-identical?) -Returns `true` if the contents of files `a` and `b` are identical, `false` -otherwise. - -Arguments `a` and `b` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Bundler::FileUtils.identical? and Bundler::FileUtils.cmp are aliases for -Bundler::FileUtils.compare_file. - -Related: Bundler::FileUtils.compare_stream. -## install(src , dest , mode: nil, owner: nil, group: nil, preserve: nil, noop: nil, verbose: nil) [](#method-c-install) -Copies a file entry. See -[install(1)](https://man7.org/linux/man-pages/man1/install.1.html). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments); - -If the entry at `dest` does not exist, copies from `src` to `dest`: - - File.read('src0.txt') # => "aaa\n" - File.exist?('dest0.txt') # => false - Bundler::FileUtils.install('src0.txt', 'dest0.txt') - File.read('dest0.txt') # => "aaa\n" - -If `dest` is a file entry, copies from `src` to `dest`, overwriting: - - File.read('src1.txt') # => "aaa\n" - File.read('dest1.txt') # => "bbb\n" - Bundler::FileUtils.install('src1.txt', 'dest1.txt') - File.read('dest1.txt') # => "aaa\n" - -If `dest` is a directory entry, copies from `src` to `dest/src`, overwriting -if necessary: - - File.read('src2.txt') # => "aaa\n" - File.read('dest2/src2.txt') # => "bbb\n" - Bundler::FileUtils.install('src2.txt', 'dest2') - File.read('dest2/src2.txt') # => "aaa\n" - -If `src` is an array of paths and `dest` points to a directory, copies each -path `path` in `src` to `dest/path`: - - File.file?('src3.txt') # => true - File.file?('src3.dat') # => true - Bundler::FileUtils.mkdir('dest3') - Bundler::FileUtils.install(['src3.txt', 'src3.dat'], 'dest3') - File.file?('dest3/src3.txt') # => true - File.file?('dest3/src3.dat') # => true - -Keyword arguments: - -* `group: *group`* - changes the group if not `nil`, using - [File.chown](rdoc-ref:File.chown). -* `mode: *permissions`* - changes the permissions. using - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not copy entries; returns `nil`. -* `owner: *owner`* - changes the owner if not `nil`, using - [File.chown](rdoc-ref:File.chown). -* `preserve: true` - preserve timestamps using - [File.utime](rdoc-ref:File.utime). -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.install('src0.txt', 'dest0.txt', noop: true, verbose: true) - Bundler::FileUtils.install('src1.txt', 'dest1.txt', noop: true, verbose: true) - Bundler::FileUtils.install('src2.txt', 'dest2', noop: true, verbose: true) - - Output: - - install -c src0.txt dest0.txt - install -c src1.txt dest1.txt - install -c src2.txt dest2 - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## link() [](#method-c-link) -Creates [hard links](https://en.wikipedia.org/wiki/Hard_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -When `src` is the path to an existing file and `dest` is the path to a -non-existent file, creates a hard link at `dest` pointing to `src`; returns -zero: - - Dir.children('tmp0/') # => ["t.txt"] - Dir.children('tmp1/') # => [] - Bundler::FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk') # => 0 - Dir.children('tmp1/') # => ["t.lnk"] - -When `src` is the path to an existing file and `dest` is the path to an -existing directory, creates a hard link at `dest/src` pointing to `src`; -returns zero: - - Dir.children('tmp2') # => ["t.dat"] - Dir.children('tmp3') # => [] - Bundler::FileUtils.ln('tmp2/t.dat', 'tmp3') # => 0 - Dir.children('tmp3') # => ["t.dat"] - -When `src` is an array of paths to existing files and `dest` is the path to an -existing directory, then for each path `target` in `src`, creates a hard link -at `dest/target` pointing to `target`; returns `src`: - - Dir.children('tmp4/') # => [] - Bundler::FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/') # => ["tmp0/t.txt", "tmp2/t.dat"] - Dir.children('tmp4/') # => ["t.dat", "t.txt"] - -Keyword arguments: - -* `force: true` - overwrites `dest` if it exists. -* `noop: true` - does not create links. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk', verbose: true) - Bundler::FileUtils.ln('tmp2/t.dat', 'tmp3', verbose: true) - Bundler::FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/', verbose: true) - - Output: - - ln tmp0/t.txt tmp1/t.lnk - ln tmp2/t.dat tmp3 - ln tmp0/t.txt tmp2/t.dat tmp4/ - -Raises an exception if `dest` is the path to an existing file and keyword -argument `force` is not `true`. - -Related: Bundler::FileUtils.link_entry (has different options). -## link_entry(src , dest , dereference_root false, remove_destination false) [](#method-c-link_entry) -Creates [hard links](https://en.wikipedia.org/wiki/Hard_link); returns `nil`. - -Arguments `src` and `dest` should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a file and `dest` does not exist, creates a hard link -at `dest` pointing to `src`: - - Bundler::FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - Bundler::FileUtils.link_entry('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is the path to a directory and `dest` does not exist, recursively -creates hard links at `dest` pointing to paths in `src`: - - Bundler::FileUtils.mkdir_p(['src1/dir0', 'src1/dir1']) - src_file_paths = [ - 'src1/dir0/t0.txt', - 'src1/dir0/t1.txt', - 'src1/dir1/t2.txt', - 'src1/dir1/t3.txt', - ] - Bundler::FileUtils.touch(src_file_paths) - File.directory?('dest1') # => true - Bundler::FileUtils.link_entry('src1', 'dest1') - File.file?('dest1/dir0/t0.txt') # => true - File.file?('dest1/dir0/t1.txt') # => true - File.file?('dest1/dir1/t2.txt') # => true - File.file?('dest1/dir1/t3.txt') # => true - -Keyword arguments: - -* `dereference_root: true` - dereferences `src` if it is a symbolic link. -* `remove_destination: true` - removes `dest` before creating links. - -Raises an exception if `dest` is the path to an existing file or directory and -keyword argument `remove_destination: true` is not given. - -Related: Bundler::FileUtils.ln (has different options). -## ln(src , dest , force: nil, noop: nil, verbose: nil) [](#method-c-ln) -Creates [hard links](https://en.wikipedia.org/wiki/Hard_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -When `src` is the path to an existing file and `dest` is the path to a -non-existent file, creates a hard link at `dest` pointing to `src`; returns -zero: - - Dir.children('tmp0/') # => ["t.txt"] - Dir.children('tmp1/') # => [] - Bundler::FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk') # => 0 - Dir.children('tmp1/') # => ["t.lnk"] - -When `src` is the path to an existing file and `dest` is the path to an -existing directory, creates a hard link at `dest/src` pointing to `src`; -returns zero: - - Dir.children('tmp2') # => ["t.dat"] - Dir.children('tmp3') # => [] - Bundler::FileUtils.ln('tmp2/t.dat', 'tmp3') # => 0 - Dir.children('tmp3') # => ["t.dat"] - -When `src` is an array of paths to existing files and `dest` is the path to an -existing directory, then for each path `target` in `src`, creates a hard link -at `dest/target` pointing to `target`; returns `src`: - - Dir.children('tmp4/') # => [] - Bundler::FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/') # => ["tmp0/t.txt", "tmp2/t.dat"] - Dir.children('tmp4/') # => ["t.dat", "t.txt"] - -Keyword arguments: - -* `force: true` - overwrites `dest` if it exists. -* `noop: true` - does not create links. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk', verbose: true) - Bundler::FileUtils.ln('tmp2/t.dat', 'tmp3', verbose: true) - Bundler::FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/', verbose: true) - - Output: - - ln tmp0/t.txt tmp1/t.lnk - ln tmp2/t.dat tmp3 - ln tmp0/t.txt tmp2/t.dat tmp4/ - -Raises an exception if `dest` is the path to an existing file and keyword -argument `force` is not `true`. - -Related: Bundler::FileUtils.link_entry (has different options). -## ln_s(src , dest , force: nil, relative: false, target_directory: true, noop: nil, verbose: nil) [](#method-c-ln_s) -Creates [symbolic links](https://en.wikipedia.org/wiki/Symbolic_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to an existing file: - -* When `dest` is the path to a non-existent file, creates a symbolic link at - `dest` pointing to `src`: - - Bundler::FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - Bundler::FileUtils.ln_s('src0.txt', 'dest0.txt') - File.symlink?('dest0.txt') # => true - -* When `dest` is the path to an existing file, creates a symbolic link at - `dest` pointing to `src` if and only if keyword argument `force: true` is - given (raises an exception otherwise): - - Bundler::FileUtils.touch('src1.txt') - Bundler::FileUtils.touch('dest1.txt') - Bundler::FileUtils.ln_s('src1.txt', 'dest1.txt', force: true) - FileTest.symlink?('dest1.txt') # => true - - Bundler::FileUtils.ln_s('src1.txt', 'dest1.txt') # Raises Errno::EEXIST. - -If `dest` is the path to a directory, creates a symbolic link at `dest/src` -pointing to `src`: - - Bundler::FileUtils.touch('src2.txt') - Bundler::FileUtils.mkdir('destdir2') - Bundler::FileUtils.ln_s('src2.txt', 'destdir2') - File.symlink?('destdir2/src2.txt') # => true - -If `src` is an array of paths to existing files and `dest` is a directory, for -each child `child` in `src` creates a symbolic link `dest/child` pointing to -`child`: - - Bundler::FileUtils.mkdir('srcdir3') - Bundler::FileUtils.touch('srcdir3/src0.txt') - Bundler::FileUtils.touch('srcdir3/src1.txt') - Bundler::FileUtils.mkdir('destdir3') - Bundler::FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3') - File.symlink?('destdir3/src0.txt') # => true - File.symlink?('destdir3/src1.txt') # => true - -Keyword arguments: - -* `force: true` - overwrites `dest` if it exists. -* `relative: false` - create links relative to `dest`. -* `noop: true` - does not create links. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.ln_s('src0.txt', 'dest0.txt', noop: true, verbose: true) - Bundler::FileUtils.ln_s('src1.txt', 'destdir1', noop: true, verbose: true) - Bundler::FileUtils.ln_s('src2.txt', 'dest2.txt', force: true, noop: true, verbose: true) - Bundler::FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3', noop: true, verbose: true) - - Output: - - ln -s src0.txt dest0.txt - ln -s src1.txt destdir1 - ln -sf src2.txt dest2.txt - ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3 - -Related: Bundler::FileUtils.ln_sf. -## ln_sf(src , dest , noop: nil, verbose: nil) [](#method-c-ln_sf) -Like Bundler::FileUtils.ln_s, but always with keyword argument `force: true` -given. -## ln_sr(src , dest , target_directory: true, force: nil, noop: nil, verbose: nil) [](#method-c-ln_sr) -Like Bundler::FileUtils.ln_s, but create links relative to `dest`. -## makedirs() [](#method-c-makedirs) -Creates directories at the paths in the given `list` (a single path or an -array of paths), also creating ancestor directories as needed; returns `list` -if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, creates a directory at each `path` in `list`, along -with any needed ancestor directories, by calling: `Dir.mkdir(path, mode)`; see -[Dir.mkdir](rdoc-ref:Dir.mkdir): - - Bundler::FileUtils.mkdir_p(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"] - Bundler::FileUtils.mkdir_p('tmp4/tmp5') # => ["tmp4/tmp5"] - -Keyword arguments: - -* `mode: *mode`* - also calls `File.chmod(mode, path)`; see - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not create directories. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.mkdir_p(%w[tmp0 tmp1], verbose: true) - Bundler::FileUtils.mkdir_p(%w[tmp2 tmp3], mode: 0700, verbose: true) - - Output: - - mkdir -p tmp0 tmp1 - mkdir -p -m 700 tmp2 tmp3 - -Raises an exception if for any reason a directory cannot be created. - -Bundler::FileUtils.mkpath and Bundler::FileUtils.makedirs are aliases for -Bundler::FileUtils.mkdir_p. - -Related: Bundler::FileUtils.mkdir. -## mkdir(list , mode: nil, noop: nil, verbose: nil) [](#method-c-mkdir) -Creates directories at the paths in the given `list` (a single path or an -array of paths); returns `list` if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, creates a directory at each `path` in `list` by -calling: `Dir.mkdir(path, mode)`; see [Dir.mkdir](rdoc-ref:Dir.mkdir): - - Bundler::FileUtils.mkdir(%w[tmp0 tmp1]) # => ["tmp0", "tmp1"] - Bundler::FileUtils.mkdir('tmp4') # => ["tmp4"] - -Keyword arguments: - -* `mode: *mode`* - also calls `File.chmod(mode, path)`; see - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not create directories. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.mkdir(%w[tmp0 tmp1], verbose: true) - Bundler::FileUtils.mkdir(%w[tmp2 tmp3], mode: 0700, verbose: true) - - Output: - - mkdir tmp0 tmp1 - mkdir -m 700 tmp2 tmp3 - -Raises an exception if any path points to an existing file or directory, or if -for any reason a directory cannot be created. - -Related: Bundler::FileUtils.mkdir_p. -## mkdir_p(list , mode: nil, noop: nil, verbose: nil) [](#method-c-mkdir_p) -Creates directories at the paths in the given `list` (a single path or an -array of paths), also creating ancestor directories as needed; returns `list` -if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, creates a directory at each `path` in `list`, along -with any needed ancestor directories, by calling: `Dir.mkdir(path, mode)`; see -[Dir.mkdir](rdoc-ref:Dir.mkdir): - - Bundler::FileUtils.mkdir_p(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"] - Bundler::FileUtils.mkdir_p('tmp4/tmp5') # => ["tmp4/tmp5"] - -Keyword arguments: - -* `mode: *mode`* - also calls `File.chmod(mode, path)`; see - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not create directories. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.mkdir_p(%w[tmp0 tmp1], verbose: true) - Bundler::FileUtils.mkdir_p(%w[tmp2 tmp3], mode: 0700, verbose: true) - - Output: - - mkdir -p tmp0 tmp1 - mkdir -p -m 700 tmp2 tmp3 - -Raises an exception if for any reason a directory cannot be created. - -Bundler::FileUtils.mkpath and Bundler::FileUtils.makedirs are aliases for -Bundler::FileUtils.mkdir_p. - -Related: Bundler::FileUtils.mkdir. -## mkpath() [](#method-c-mkpath) -Creates directories at the paths in the given `list` (a single path or an -array of paths), also creating ancestor directories as needed; returns `list` -if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, creates a directory at each `path` in `list`, along -with any needed ancestor directories, by calling: `Dir.mkdir(path, mode)`; see -[Dir.mkdir](rdoc-ref:Dir.mkdir): - - Bundler::FileUtils.mkdir_p(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"] - Bundler::FileUtils.mkdir_p('tmp4/tmp5') # => ["tmp4/tmp5"] - -Keyword arguments: - -* `mode: *mode`* - also calls `File.chmod(mode, path)`; see - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not create directories. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.mkdir_p(%w[tmp0 tmp1], verbose: true) - Bundler::FileUtils.mkdir_p(%w[tmp2 tmp3], mode: 0700, verbose: true) - - Output: - - mkdir -p tmp0 tmp1 - mkdir -p -m 700 tmp2 tmp3 - -Raises an exception if for any reason a directory cannot be created. - -Bundler::FileUtils.mkpath and Bundler::FileUtils.makedirs are aliases for -Bundler::FileUtils.mkdir_p. - -Related: Bundler::FileUtils.mkdir. -## move() [](#method-c-move) -Moves entries. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` and `dest` are on different file systems, first copies, then removes -`src`. - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -If `src` is the path to a single file or directory and `dest` does not exist, -moves `src` to `dest`: - - tree('src0') - # => src0 - # |-- src0.txt - # `-- src1.txt - File.exist?('dest0') # => false - Bundler::FileUtils.mv('src0', 'dest0') - File.exist?('src0') # => false - tree('dest0') - # => dest0 - # |-- src0.txt - # `-- src1.txt - -If `src` is an array of paths to files and directories and `dest` is the path -to a directory, copies from each path in the array to `dest`: - - File.file?('src1.txt') # => true - tree('src1') - # => src1 - # |-- src.dat - # `-- src.txt - Dir.empty?('dest1') # => true - Bundler::FileUtils.mv(['src1.txt', 'src1'], 'dest1') - tree('dest1') - # => dest1 - # |-- src1 - # | |-- src.dat - # | `-- src.txt - # `-- src1.txt - -Keyword arguments: - -* `force: true` - if the move includes removing `src` (that is, if `src` and - `dest` are on different file systems), ignores raised exceptions of - StandardError and its descendants. -* `noop: true` - does not move files. -* `secure: true` - removes `src` securely; see details at - Bundler::FileUtils.remove_entry_secure. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.mv('src0', 'dest0', noop: true, verbose: true) - Bundler::FileUtils.mv(['src1.txt', 'src1'], 'dest1', noop: true, verbose: true) - - Output: - - mv src0 dest0 - mv src1.txt src1 dest1 -## mv(src , dest , force: nil, noop: nil, verbose: nil, secure: nil) [](#method-c-mv) -Moves entries. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` and `dest` are on different file systems, first copies, then removes -`src`. - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -If `src` is the path to a single file or directory and `dest` does not exist, -moves `src` to `dest`: - - tree('src0') - # => src0 - # |-- src0.txt - # `-- src1.txt - File.exist?('dest0') # => false - Bundler::FileUtils.mv('src0', 'dest0') - File.exist?('src0') # => false - tree('dest0') - # => dest0 - # |-- src0.txt - # `-- src1.txt - -If `src` is an array of paths to files and directories and `dest` is the path -to a directory, copies from each path in the array to `dest`: - - File.file?('src1.txt') # => true - tree('src1') - # => src1 - # |-- src.dat - # `-- src.txt - Dir.empty?('dest1') # => true - Bundler::FileUtils.mv(['src1.txt', 'src1'], 'dest1') - tree('dest1') - # => dest1 - # |-- src1 - # | |-- src.dat - # | `-- src.txt - # `-- src1.txt - -Keyword arguments: - -* `force: true` - if the move includes removing `src` (that is, if `src` and - `dest` are on different file systems), ignores raised exceptions of - StandardError and its descendants. -* `noop: true` - does not move files. -* `secure: true` - removes `src` securely; see details at - Bundler::FileUtils.remove_entry_secure. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.mv('src0', 'dest0', noop: true, verbose: true) - Bundler::FileUtils.mv(['src1.txt', 'src1'], 'dest1', noop: true, verbose: true) - - Output: - - mv src0 dest0 - mv src1.txt src1 dest1 -## options() [](#method-c-options) -Returns an array of the string keyword names: - - Bundler::FileUtils.options.take(3) # => ["noop", "verbose", "force"] -## options_of(mid ) [](#method-c-options_of) -Returns an array of the string keyword name for method `mid`; the argument may -be a string or a symbol: - - Bundler::FileUtils.options_of(:rm) # => ["force", "noop", "verbose"] - Bundler::FileUtils.options_of('mv') # => ["force", "noop", "verbose", "secure"] -## private_module_function(name ) [](#method-c-private_module_function) -:nodoc: -## pwd() [](#method-c-pwd) -Returns a string containing the path to the current directory: - - Bundler::FileUtils.pwd # => "/rdoc/fileutils" - -Related: Bundler::FileUtils.cd. -## remove() [](#method-c-remove) -Removes entries at the paths in the given `list` (a single path or an array of -paths) returns `list`, if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, removes files at the paths given in `list`: - - Bundler::FileUtils.touch(['src0.txt', 'src0.dat']) - Bundler::FileUtils.rm(['src0.dat', 'src0.txt']) # => ["src0.dat", "src0.txt"] - -Keyword arguments: - -* `force: true` - ignores raised exceptions of StandardError and its - descendants. -* `noop: true` - does not remove files; returns `nil`. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.rm(['src0.dat', 'src0.txt'], noop: true, verbose: true) - - Output: - - rm src0.dat src0.txt - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## remove_dir(path , force false) [](#method-c-remove_dir) -Recursively removes the directory entry given by `path`, which should be the -entry for a regular file, a symbolic link, or a directory. - -Argument `path` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Optional argument `force` specifies whether to ignore raised exceptions of -StandardError and its descendants. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## remove_entry(path , force false) [](#method-c-remove_entry) -Removes the entry given by `path`, which should be the entry for a regular -file, a symbolic link, or a directory. - -Argument `path` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Optional argument `force` specifies whether to ignore raised exceptions of -StandardError and its descendants. - -Related: Bundler::FileUtils.remove_entry_secure. -## remove_entry_secure(path , force false) [](#method-c-remove_entry_secure) -Securely removes the entry given by `path`, which should be the entry for a -regular file, a symbolic link, or a directory. - -Argument `path` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Avoids a local vulnerability that can exist in certain circumstances; see -[Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -Optional argument `force` specifies whether to ignore raised exceptions of -StandardError and its descendants. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## remove_file(path , force false) [](#method-c-remove_file) -Removes the file entry given by `path`, which should be the entry for a -regular file or a symbolic link. - -Argument `path` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Optional argument `force` specifies whether to ignore raised exceptions of -StandardError and its descendants. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rm(list , force: nil, noop: nil, verbose: nil) [](#method-c-rm) -Removes entries at the paths in the given `list` (a single path or an array of -paths) returns `list`, if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, removes files at the paths given in `list`: - - Bundler::FileUtils.touch(['src0.txt', 'src0.dat']) - Bundler::FileUtils.rm(['src0.dat', 'src0.txt']) # => ["src0.dat", "src0.txt"] - -Keyword arguments: - -* `force: true` - ignores raised exceptions of StandardError and its - descendants. -* `noop: true` - does not remove files; returns `nil`. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.rm(['src0.dat', 'src0.txt'], noop: true, verbose: true) - - Output: - - rm src0.dat src0.txt - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rm_f(list , noop: nil, verbose: nil) [](#method-c-rm_f) -Equivalent to: - - Bundler::FileUtils.rm(list, force: true, **kwargs) - -Argument `list` (a single path or an array of paths) should be [interpretable -as paths](rdoc-ref:FileUtils@Path+Arguments). - -See Bundler::FileUtils.rm for keyword arguments. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rm_r(list , force: nil, noop: nil, verbose: nil, secure: nil) [](#method-c-rm_r) -Removes entries at the paths in the given `list` (a single path or an array of -paths); returns `list`, if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -For each file path, removes the file at that path: - - Bundler::FileUtils.touch(['src0.txt', 'src0.dat']) - Bundler::FileUtils.rm_r(['src0.dat', 'src0.txt']) - File.exist?('src0.txt') # => false - File.exist?('src0.dat') # => false - -For each directory path, recursively removes files and directories: - - tree('src1') - # => src1 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - Bundler::FileUtils.rm_r('src1') - File.exist?('src1') # => false - -Keyword arguments: - -* `force: true` - ignores raised exceptions of StandardError and its - descendants. -* `noop: true` - does not remove entries; returns `nil`. -* `secure: true` - removes `src` securely; see details at - Bundler::FileUtils.remove_entry_secure. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.rm_r(['src0.dat', 'src0.txt'], noop: true, verbose: true) - Bundler::FileUtils.rm_r('src1', noop: true, verbose: true) - - Output: - - rm -r src0.dat src0.txt - rm -r src1 - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rm_rf(list , noop: nil, verbose: nil, secure: nil) [](#method-c-rm_rf) -Equivalent to: - - Bundler::FileUtils.rm_r(list, force: true, **kwargs) - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -See Bundler::FileUtils.rm_r for keyword arguments. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rmdir(list , parents: nil, noop: nil, verbose: nil) [](#method-c-rmdir) -Removes directories at the paths in the given `list` (a single path or an -array of paths); returns `list`, if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, removes the directory at each `path` in `list`, by -calling: `Dir.rmdir(path)`; see [Dir.rmdir](rdoc-ref:Dir.rmdir): - - Bundler::FileUtils.rmdir(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"] - Bundler::FileUtils.rmdir('tmp4/tmp5') # => ["tmp4/tmp5"] - -Keyword arguments: - -* `parents: true` - removes successive ancestor directories if empty. -* `noop: true` - does not remove directories. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.rmdir(%w[tmp0/tmp1 tmp2/tmp3], parents: true, verbose: true) - Bundler::FileUtils.rmdir('tmp4/tmp5', parents: true, verbose: true) - - Output: - - rmdir -p tmp0/tmp1 tmp2/tmp3 - rmdir -p tmp4/tmp5 - -Raises an exception if a directory does not exist or if for any reason a -directory cannot be removed. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rmtree() [](#method-c-rmtree) -Equivalent to: - - Bundler::FileUtils.rm_r(list, force: true, **kwargs) - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -See Bundler::FileUtils.rm_r for keyword arguments. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## safe_unlink() [](#method-c-safe_unlink) -Equivalent to: - - Bundler::FileUtils.rm(list, force: true, **kwargs) - -Argument `list` (a single path or an array of paths) should be [interpretable -as paths](rdoc-ref:FileUtils@Path+Arguments). - -See Bundler::FileUtils.rm for keyword arguments. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## symlink() [](#method-c-symlink) -Creates [symbolic links](https://en.wikipedia.org/wiki/Symbolic_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to an existing file: - -* When `dest` is the path to a non-existent file, creates a symbolic link at - `dest` pointing to `src`: - - Bundler::FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - Bundler::FileUtils.ln_s('src0.txt', 'dest0.txt') - File.symlink?('dest0.txt') # => true - -* When `dest` is the path to an existing file, creates a symbolic link at - `dest` pointing to `src` if and only if keyword argument `force: true` is - given (raises an exception otherwise): - - Bundler::FileUtils.touch('src1.txt') - Bundler::FileUtils.touch('dest1.txt') - Bundler::FileUtils.ln_s('src1.txt', 'dest1.txt', force: true) - FileTest.symlink?('dest1.txt') # => true - - Bundler::FileUtils.ln_s('src1.txt', 'dest1.txt') # Raises Errno::EEXIST. - -If `dest` is the path to a directory, creates a symbolic link at `dest/src` -pointing to `src`: - - Bundler::FileUtils.touch('src2.txt') - Bundler::FileUtils.mkdir('destdir2') - Bundler::FileUtils.ln_s('src2.txt', 'destdir2') - File.symlink?('destdir2/src2.txt') # => true - -If `src` is an array of paths to existing files and `dest` is a directory, for -each child `child` in `src` creates a symbolic link `dest/child` pointing to -`child`: - - Bundler::FileUtils.mkdir('srcdir3') - Bundler::FileUtils.touch('srcdir3/src0.txt') - Bundler::FileUtils.touch('srcdir3/src1.txt') - Bundler::FileUtils.mkdir('destdir3') - Bundler::FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3') - File.symlink?('destdir3/src0.txt') # => true - File.symlink?('destdir3/src1.txt') # => true - -Keyword arguments: - -* `force: true` - overwrites `dest` if it exists. -* `relative: false` - create links relative to `dest`. -* `noop: true` - does not create links. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.ln_s('src0.txt', 'dest0.txt', noop: true, verbose: true) - Bundler::FileUtils.ln_s('src1.txt', 'destdir1', noop: true, verbose: true) - Bundler::FileUtils.ln_s('src2.txt', 'dest2.txt', force: true, noop: true, verbose: true) - Bundler::FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3', noop: true, verbose: true) - - Output: - - ln -s src0.txt dest0.txt - ln -s src1.txt destdir1 - ln -sf src2.txt dest2.txt - ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3 - -Related: Bundler::FileUtils.ln_sf. -## touch(list , noop: nil, verbose: nil, mtime: nil, nocreate: nil) [](#method-c-touch) -Updates modification times (mtime) and access times (atime) of the entries -given by the paths in `list` (a single path or an array of paths); returns -`list` if it is an array, `[list]` otherwise. - -By default, creates an empty file for any path to a non-existent entry; use -keyword argument `nocreate` to raise an exception instead. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -Examples: - - # Single path. - f = File.new('src0.txt') # Existing file. - f.atime # => 2022-06-10 11:11:21.200277 -0700 - f.mtime # => 2022-06-10 11:11:21.200277 -0700 - Bundler::FileUtils.touch('src0.txt') - f = File.new('src0.txt') - f.atime # => 2022-06-11 08:28:09.8185343 -0700 - f.mtime # => 2022-06-11 08:28:09.8185343 -0700 - - # Array of paths. - Bundler::FileUtils.touch(['src0.txt', 'src0.dat']) - -Keyword arguments: - -* `mtime: *time`* - sets the entry's mtime to the given time, instead of the - current time. -* `nocreate: true` - raises an exception if the entry does not exist. -* `noop: true` - does not touch entries; returns `nil`. -* `verbose: true` - prints an equivalent command: - - Bundler::FileUtils.touch('src0.txt', noop: true, verbose: true) - Bundler::FileUtils.touch(['src0.txt', 'src0.dat'], noop: true, verbose: true) - Bundler::FileUtils.touch(path, noop: true, verbose: true) - - Output: - - touch src0.txt - touch src0.txt src0.dat - touch src0.txt - -Related: Bundler::FileUtils.uptodate?. -## uptodate?(new , old_list ) [](#method-c-uptodate?) -Returns `true` if the file at path `new` is newer than all the files at paths -in array `old_list`; `false` otherwise. - -Argument `new` and the elements of `old_list` should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments): - - Bundler::FileUtils.uptodate?('Rakefile', ['Gemfile', 'README.md']) # => true - Bundler::FileUtils.uptodate?('Gemfile', ['Rakefile', 'README.md']) # => false - -A non-existent file is considered to be infinitely old. - -Related: Bundler::FileUtils.touch. -**@return** [Boolean] - - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/Bundler/FileUtils/DryRun.md b/example/ruby/Bundler/FileUtils/DryRun.md deleted file mode 100644 index c4afc61..0000000 --- a/example/ruby/Bundler/FileUtils/DryRun.md +++ /dev/null @@ -1,78 +0,0 @@ -# Module: Bundler::FileUtils::DryRun - -**Extended by:** Bundler::FileUtils::DryRun - -**Includes:** Bundler::FileUtils, Bundler::FileUtils::LowMethods - - -This module has all methods of Bundler::FileUtils module, but never changes -files/directories, with printing message before acting. This equates to -passing the `:noop` and `:verbose` flag to methods in Bundler::FileUtils. - - -# Class Methods -## apply_mask(mode , user_mask , op , mode_mask ) [](#method-c-apply_mask) -:nodoc: -## fu_get_gid(group ) [](#method-c-fu_get_gid) -:nodoc: -## fu_get_uid(user ) [](#method-c-fu_get_uid) -:nodoc: -## fu_have_symlink?() [](#method-c-fu_have_symlink?) -:nodoc: -**@return** [Boolean] - -## fu_mkdir(path , mode ) [](#method-c-fu_mkdir) -:nodoc: -## fu_mode(mode , path ) [](#method-c-fu_mode) -:nodoc: -## fu_stat_identical_entry?(a , b ) [](#method-c-fu_stat_identical_entry?) -:nodoc: -**@return** [Boolean] - -## mode_to_s(mode ) [](#method-c-mode_to_s) -:nodoc: -## remove_trailing_slash(dir ) [](#method-c-remove_trailing_slash) -:nodoc: -## symbolic_modes_to_i(mode_sym , path ) [](#method-c-symbolic_modes_to_i) -:nodoc: -## user_mask(target ) [](#method-c-user_mask) -:nodoc: - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/Bundler/FileUtils/Entry_.md b/example/ruby/Bundler/FileUtils/Entry_.md deleted file mode 100644 index 8a74bc7..0000000 --- a/example/ruby/Bundler/FileUtils/Entry_.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: Bundler::FileUtils::Entry_ -**Inherits:** Object - -**Includes:** Bundler::FileUtils::StreamUtils_ - - -:nodoc: internal use only - - - -#Instance Methods -## blockdev?() [](#method-i-blockdev?) - -**@return** [Boolean] - -## chardev?() [](#method-i-chardev?) - -**@return** [Boolean] - -## chmod(mode) [](#method-i-chmod) - -## chown(uid, gid) [](#method-i-chown) - -## copy(dest) [](#method-i-copy) - -## copy_file(dest) [](#method-i-copy_file) - -## copy_metadata(path) [](#method-i-copy_metadata) - -## dereference?() [](#method-i-dereference?) - -**@return** [Boolean] - -## directory?() [](#method-i-directory?) - -**@return** [Boolean] - -## door?() [](#method-i-door?) - -**@return** [Boolean] - -## entries() [](#method-i-entries) - -## exist?() [](#method-i-exist?) - -**@return** [Boolean] - -## file?() [](#method-i-file?) - -**@return** [Boolean] - -## initialize(a, bnil, dereffalse) [](#method-i-initialize) - -**@return** [Entry_] a new instance of Entry_ - -## inspect() [](#method-i-inspect) - -## link(dest) [](#method-i-link) - -## lstat() [](#method-i-lstat) - -## lstat!() [](#method-i-lstat!) - -## path() [](#method-i-path) - -## pipe?() [](#method-i-pipe?) - -**@return** [Boolean] - -## platform_support() [](#method-i-platform_support) - -## postorder_traverse() [](#method-i-postorder_traverse) - -**@yield** [_self] - -**@yieldparam** [Bundler::FileUtils::Entry_] the object that the method was called on - -## prefix() [](#method-i-prefix) - -## preorder_traverse() [](#method-i-preorder_traverse) - -## rel() [](#method-i-rel) - -## remove() [](#method-i-remove) - -## remove_dir1() [](#method-i-remove_dir1) - -## remove_file() [](#method-i-remove_file) - -## socket?() [](#method-i-socket?) - -**@return** [Boolean] - -## stat() [](#method-i-stat) - -## stat!() [](#method-i-stat!) - -## symlink?() [](#method-i-symlink?) - -**@return** [Boolean] - -## wrap_traverse(pre, post) [](#method-i-wrap_traverse) - diff --git a/example/ruby/Bundler/FileUtils/LowMethods.md b/example/ruby/Bundler/FileUtils/LowMethods.md deleted file mode 100644 index 78429f0..0000000 --- a/example/ruby/Bundler/FileUtils/LowMethods.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Bundler::FileUtils::LowMethods - - -:nodoc: internal use only - - - diff --git a/example/ruby/Bundler/FileUtils/NoWrite.md b/example/ruby/Bundler/FileUtils/NoWrite.md deleted file mode 100644 index 685f914..0000000 --- a/example/ruby/Bundler/FileUtils/NoWrite.md +++ /dev/null @@ -1,78 +0,0 @@ -# Module: Bundler::FileUtils::NoWrite - -**Extended by:** Bundler::FileUtils::NoWrite - -**Includes:** Bundler::FileUtils, Bundler::FileUtils::LowMethods - - -This module has all methods of Bundler::FileUtils module, but never changes -files/directories. This equates to passing the `:noop` flag to methods in -Bundler::FileUtils. - - -# Class Methods -## apply_mask(mode , user_mask , op , mode_mask ) [](#method-c-apply_mask) -:nodoc: -## fu_get_gid(group ) [](#method-c-fu_get_gid) -:nodoc: -## fu_get_uid(user ) [](#method-c-fu_get_uid) -:nodoc: -## fu_have_symlink?() [](#method-c-fu_have_symlink?) -:nodoc: -**@return** [Boolean] - -## fu_mkdir(path , mode ) [](#method-c-fu_mkdir) -:nodoc: -## fu_mode(mode , path ) [](#method-c-fu_mode) -:nodoc: -## fu_stat_identical_entry?(a , b ) [](#method-c-fu_stat_identical_entry?) -:nodoc: -**@return** [Boolean] - -## mode_to_s(mode ) [](#method-c-mode_to_s) -:nodoc: -## remove_trailing_slash(dir ) [](#method-c-remove_trailing_slash) -:nodoc: -## symbolic_modes_to_i(mode_sym , path ) [](#method-c-symbolic_modes_to_i) -:nodoc: -## user_mask(target ) [](#method-c-user_mask) -:nodoc: - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/Bundler/FileUtils/StreamUtils_.md b/example/ruby/Bundler/FileUtils/StreamUtils_.md deleted file mode 100644 index 36bcb90..0000000 --- a/example/ruby/Bundler/FileUtils/StreamUtils_.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Bundler::FileUtils::StreamUtils_ - - -:nodoc: - - - diff --git a/example/ruby/Bundler/FileUtils/Verbose.md b/example/ruby/Bundler/FileUtils/Verbose.md deleted file mode 100644 index 72aeb9c..0000000 --- a/example/ruby/Bundler/FileUtils/Verbose.md +++ /dev/null @@ -1,78 +0,0 @@ -# Module: Bundler::FileUtils::Verbose - -**Extended by:** Bundler::FileUtils::Verbose - -**Includes:** Bundler::FileUtils - - -This module has all methods of Bundler::FileUtils module, but it outputs -messages before acting. This equates to passing the `:verbose` flag to -methods in Bundler::FileUtils. - - -# Class Methods -## apply_mask(mode , user_mask , op , mode_mask ) [](#method-c-apply_mask) -:nodoc: -## fu_get_gid(group ) [](#method-c-fu_get_gid) -:nodoc: -## fu_get_uid(user ) [](#method-c-fu_get_uid) -:nodoc: -## fu_have_symlink?() [](#method-c-fu_have_symlink?) -:nodoc: -**@return** [Boolean] - -## fu_mkdir(path , mode ) [](#method-c-fu_mkdir) -:nodoc: -## fu_mode(mode , path ) [](#method-c-fu_mode) -:nodoc: -## fu_stat_identical_entry?(a , b ) [](#method-c-fu_stat_identical_entry?) -:nodoc: -**@return** [Boolean] - -## mode_to_s(mode ) [](#method-c-mode_to_s) -:nodoc: -## remove_trailing_slash(dir ) [](#method-c-remove_trailing_slash) -:nodoc: -## symbolic_modes_to_i(mode_sym , path ) [](#method-c-symbolic_modes_to_i) -:nodoc: -## user_mask(target ) [](#method-c-user_mask) -:nodoc: - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/Bundler/ForcePlatform.md b/example/ruby/Bundler/ForcePlatform.md deleted file mode 100644 index 7401190..0000000 --- a/example/ruby/Bundler/ForcePlatform.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: Bundler::ForcePlatform - - - - - -#Instance Methods -## default_force_ruby_platform() [](#method-i-default_force_ruby_platform) -The `:force_ruby_platform` value used by dependencies for resolution, and by -locked specifications for materialization is `false` by default, except for -TruffleRuby. TruffleRuby generally needs to force the RUBY platform variant -unless the name is explicitly allowlisted. - diff --git a/example/ruby/Bundler/FriendlyErrors.md b/example/ruby/Bundler/FriendlyErrors.md deleted file mode 100644 index 720485b..0000000 --- a/example/ruby/Bundler/FriendlyErrors.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: Bundler::FriendlyErrors - - - - -# Class Methods -## disable!() [](#method-c-disable!) -## disabled?() [](#method-c-disabled?) -**@return** [Boolean] - -## enable!() [](#method-c-enable!) -## exception_message(error ) [](#method-c-exception_message) -## exit_status(error ) [](#method-c-exit_status) -## issues_url(exception ) [](#method-c-issues_url) -## log_error(error ) [](#method-c-log_error) -## new_issue_url() [](#method-c-new_issue_url) -## request_issue_report_for(e ) [](#method-c-request_issue_report_for) -## serialized_exception_for(e ) [](#method-c-serialized_exception_for) - diff --git a/example/ruby/Bundler/GemHelper.md b/example/ruby/Bundler/GemHelper.md deleted file mode 100644 index 5fe0488..0000000 --- a/example/ruby/Bundler/GemHelper.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Bundler::GemHelper -**Inherits:** Object - -**Includes:** Rake::DSL - - - - -# Class Methods -## gemspec(&block ) [](#method-c-gemspec) -## install_tasks(opts {}) [](#method-c-install_tasks) -## tag_prefix=(prefix ) [](#method-c-tag_prefix=) -# Attributes -## instance[RW] [](#attribute-c-instance) -set when install'd. - -## base[RW] [](#attribute-i-base) -Returns the value of attribute base. - -## gemspec[RW] [](#attribute-i-gemspec) -Returns the value of attribute gemspec. - -## spec_path[RW] [](#attribute-i-spec_path) -Returns the value of attribute spec_path. - -## tag_prefix=[R] [](#attribute-i-tag_prefix=) -Sets the attribute tag_prefix - -**@param** [] the value to set the attribute tag_prefix to. - - -#Instance Methods -## build_checksum(built_gem_pathnil) [](#method-i-build_checksum) - -## build_gem() [](#method-i-build_gem) - -## initialize(basenil, namenil) [](#method-i-initialize) - -**@return** [GemHelper] a new instance of GemHelper - -## install() [](#method-i-install) - -## install_gem(built_gem_pathnil, localfalse) [](#method-i-install_gem) - diff --git a/example/ruby/Bundler/GemHelpers.md b/example/ruby/Bundler/GemHelpers.md deleted file mode 100644 index 45dfdfd..0000000 --- a/example/ruby/Bundler/GemHelpers.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: Bundler::GemHelpers - - - - -# Class Methods -## generic(p ) [](#method-c-generic) -## generic_local_platform() [](#method-c-generic_local_platform) -## generic_local_platform_is_ruby?() [](#method-c-generic_local_platform_is_ruby?) -**@return** [Boolean] - -## local_platform() [](#method-c-local_platform) -## platform_specificity_match(spec_platform , user_platform ) [](#method-c-platform_specificity_match) -## same_deps(spec , exemplary_spec ) [](#method-c-same_deps) -## same_specificity(platform , spec , exemplary_spec ) [](#method-c-same_specificity) -## select_all_platform_match(specs , platform , force_ruby: false, prefer_locked: false) [](#method-c-select_all_platform_match) -## select_best_local_platform_match(specs , force_ruby: false) [](#method-c-select_best_local_platform_match) -## select_best_platform_match(specs , platform , force_ruby: false, prefer_locked: false) [](#method-c-select_best_platform_match) -## sort_and_filter_best_platform_match(matching , platform ) [](#method-c-sort_and_filter_best_platform_match) -## sort_best_platform_match(matching , platform ) [](#method-c-sort_best_platform_match) - diff --git a/example/ruby/Bundler/GemHelpers/PlatformMatch.md b/example/ruby/Bundler/GemHelpers/PlatformMatch.md deleted file mode 100644 index a7b835c..0000000 --- a/example/ruby/Bundler/GemHelpers/PlatformMatch.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bundler::GemHelpers::PlatformMatch -**Inherits:** Object - - - - -# Class Methods -## cpu_match(spec_platform , user_platform ) [](#method-c-cpu_match) -## os_match(spec_platform , user_platform ) [](#method-c-os_match) -## platform_version_match(spec_platform , user_platform ) [](#method-c-platform_version_match) -## specificity_score(spec_platform , user_platform ) [](#method-c-specificity_score) - diff --git a/example/ruby/Bundler/GemInstaller.md b/example/ruby/Bundler/GemInstaller.md deleted file mode 100644 index 4c0d8f6..0000000 --- a/example/ruby/Bundler/GemInstaller.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Bundler::GemInstaller -**Inherits:** Object - - - - -# Attributes -## force[RW] [](#attribute-i-force) -Returns the value of attribute force. - -## installer[RW] [](#attribute-i-installer) -Returns the value of attribute installer. - -## local[RW] [](#attribute-i-local) -Returns the value of attribute local. - -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - -## standalone[RW] [](#attribute-i-standalone) -Returns the value of attribute standalone. - -## worker[RW] [](#attribute-i-worker) -Returns the value of attribute worker. - - -#Instance Methods -## initialize(spec, installer, standalonefalse, worker0, forcefalse, localfalse) [](#method-i-initialize) - -**@return** [GemInstaller] a new instance of GemInstaller - -## install_from_spec() [](#method-i-install_from_spec) - diff --git a/example/ruby/Bundler/GemNotFound.md b/example/ruby/Bundler/GemNotFound.md deleted file mode 100644 index 8a03760..0000000 --- a/example/ruby/Bundler/GemNotFound.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::GemNotFound -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/GemRequireError.md b/example/ruby/Bundler/GemRequireError.md deleted file mode 100644 index 82c294a..0000000 --- a/example/ruby/Bundler/GemRequireError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Bundler::GemRequireError -**Inherits:** Bundler::BundlerError - - - - -# Attributes -## orig_exception[RW] [](#attribute-i-orig_exception) -Returns the value of attribute orig_exception. - - -#Instance Methods -## initialize(orig_exception, msg) [](#method-i-initialize) - -**@return** [GemRequireError] a new instance of GemRequireError - diff --git a/example/ruby/Bundler/GemVersionPromoter.md b/example/ruby/Bundler/GemVersionPromoter.md deleted file mode 100644 index 684cac6..0000000 --- a/example/ruby/Bundler/GemVersionPromoter.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: Bundler::GemVersionPromoter -**Inherits:** Object - - -This class contains all of the logic for determining the next version of a Gem -to update to based on the requested level (patch, minor, major). Primarily -designed to work with Resolver which will provide it the list of available -dependency versions as found in its index, before returning it to to the -resolution engine to select the best version. - - -# Attributes -## level[RW] [](#attribute-i-level) -Returns the value of attribute level. - -## pre[RW] [](#attribute-i-pre) -Returns the value of attribute pre. - -## strict[RW] [](#attribute-i-strict) -By default, strict is false, meaning every available version of a gem is -returned from sort_versions. The order gives preference to the requested level -(:patch, :minor, :major) but in complicated requirement cases some gems will -by necessity be promoted past the requested level, or even reverted to older -versions. - -If strict is set to true, the results from sort_versions will be truncated, -eliminating any version outside the current level scope. This can lead to -unexpected outcomes or even VersionConflict exceptions that report a version -of a gem not existing for versions that indeed do existing in the referenced -source. - - -#Instance Methods -## filter_versions(package, specs) [](#method-i-filter_versions) -Given a Resolver::Package and an Array of Specifications of available versions -for a gem, this method will truncate the Array if strict is true. That means -filtering out downgrades from the version currently locked, and filtering out -upgrades that go past the selected level (major, minor, or patch). - -**@param** [Resolver::Package] The package being resolved. - -**@param** [Specification] An array of Specifications for the package. - -**@return** [Specification] A new instance of the Specification Array -truncated. - -## initialize() [](#method-i-initialize) -Creates a GemVersionPromoter instance. - -**@return** [GemVersionPromoter] - -## major?() [](#method-i-major?) - -**@return** [bool] Convenience method for testing value of level variable. - -## minor?() [](#method-i-minor?) - -**@return** [bool] Convenience method for testing value of level variable. - -## pre?() [](#method-i-pre?) - -**@return** [bool] Convenience method for testing value of pre variable. - -## sort_versions(package, specs) [](#method-i-sort_versions) -Given a Resolver::Package and an Array of Specifications of available versions -for a gem, this method will return the Array of Specifications sorted in an -order to give preference to the current level (:major, :minor or :patch) when -resolution is deciding what versions best resolve all dependencies in the -bundle. - -**@param** [Resolver::Package] The package being resolved. - -**@param** [Specification] An array of Specifications for the package. - -**@return** [Specification] A new instance of the Specification Array sorted. - diff --git a/example/ruby/Bundler/GemfileError.md b/example/ruby/Bundler/GemfileError.md deleted file mode 100644 index acf4cab..0000000 --- a/example/ruby/Bundler/GemfileError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::GemfileError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/GemfileEvalError.md b/example/ruby/Bundler/GemfileEvalError.md deleted file mode 100644 index dcadd6a..0000000 --- a/example/ruby/Bundler/GemfileEvalError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::GemfileEvalError -**Inherits:** Bundler::GemfileError - - - - - diff --git a/example/ruby/Bundler/GemfileLockNotFound.md b/example/ruby/Bundler/GemfileLockNotFound.md deleted file mode 100644 index d35dc53..0000000 --- a/example/ruby/Bundler/GemfileLockNotFound.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::GemfileLockNotFound -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/GemfileNotFound.md b/example/ruby/Bundler/GemfileNotFound.md deleted file mode 100644 index 9dcc9f9..0000000 --- a/example/ruby/Bundler/GemfileNotFound.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::GemfileNotFound -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/GemspecError.md b/example/ruby/Bundler/GemspecError.md deleted file mode 100644 index 9dfa238..0000000 --- a/example/ruby/Bundler/GemspecError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::GemspecError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/GenericSystemCallError.md b/example/ruby/Bundler/GenericSystemCallError.md deleted file mode 100644 index f2fb59b..0000000 --- a/example/ruby/Bundler/GenericSystemCallError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Bundler::GenericSystemCallError -**Inherits:** Bundler::BundlerError - - - - -# Attributes -## underlying_error[RW] [](#attribute-i-underlying_error) -Returns the value of attribute underlying_error. - - -#Instance Methods -## initialize(underlying_error, message) [](#method-i-initialize) - -**@return** [GenericSystemCallError] a new instance of GenericSystemCallError - diff --git a/example/ruby/Bundler/GitError.md b/example/ruby/Bundler/GitError.md deleted file mode 100644 index c09ed04..0000000 --- a/example/ruby/Bundler/GitError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::GitError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/Graph.md b/example/ruby/Bundler/Graph.md deleted file mode 100644 index 2405184..0000000 --- a/example/ruby/Bundler/Graph.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Bundler::Graph -**Inherits:** Object - - - - -# Attributes -## edge_options[RW] [](#attribute-i-edge_options) -Returns the value of attribute edge_options. - -## groups[RW] [](#attribute-i-groups) -Returns the value of attribute groups. - -## node_options[RW] [](#attribute-i-node_options) -Returns the value of attribute node_options. - -## output_file[RW] [](#attribute-i-output_file) -Returns the value of attribute output_file. - -## output_format[RW] [](#attribute-i-output_format) -Returns the value of attribute output_format. - -## relations[RW] [](#attribute-i-relations) -Returns the value of attribute relations. - - -#Instance Methods -## initialize(env, output_file, show_versionfalse, show_requirementsfalse, output_format"png", without[]) [](#method-i-initialize) - -**@return** [Graph] a new instance of Graph - -## viz() [](#method-i-viz) - diff --git a/example/ruby/Bundler/Graph/GraphVizClient.md b/example/ruby/Bundler/Graph/GraphVizClient.md deleted file mode 100644 index 3460209..0000000 --- a/example/ruby/Bundler/Graph/GraphVizClient.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bundler::Graph::GraphVizClient -**Inherits:** Object - - - - - -#Instance Methods -## g() [](#method-i-g) - -## initialize(graph_instance) [](#method-i-initialize) - -**@return** [GraphVizClient] a new instance of GraphVizClient - -## run() [](#method-i-run) - diff --git a/example/ruby/Bundler/HTTPError.md b/example/ruby/Bundler/HTTPError.md deleted file mode 100644 index 12f7ee3..0000000 --- a/example/ruby/Bundler/HTTPError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Bundler::HTTPError -**Inherits:** Bundler::BundlerError - - - - - -#Instance Methods -## filter_uri(uri) [](#method-i-filter_uri) - diff --git a/example/ruby/Bundler/IncorrectLockfileDependencies.md b/example/ruby/Bundler/IncorrectLockfileDependencies.md deleted file mode 100644 index 31fc44a..0000000 --- a/example/ruby/Bundler/IncorrectLockfileDependencies.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Bundler::IncorrectLockfileDependencies -**Inherits:** Bundler::BundlerError - - - - -# Attributes -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - -#Instance Methods -## initialize(spec) [](#method-i-initialize) - -**@return** [IncorrectLockfileDependencies] a new instance of IncorrectLockfileDependencies - diff --git a/example/ruby/Bundler/Index.md b/example/ruby/Bundler/Index.md deleted file mode 100644 index 87ac4b3..0000000 --- a/example/ruby/Bundler/Index.md +++ /dev/null @@ -1,2129 +0,0 @@ -# Class: Bundler::Index -**Inherits:** Object - -**Includes:** Enumerable - - - - -# Class Methods -## build() [](#method-c-build) -**@yield** [i] - -# Attributes -## sources[RW] [](#attribute-i-sources) -Returns the value of attribute sources. - - -#Instance Methods -## add(spec) [](#method-i-add) - -## add_source(index) [](#method-i-add_source) - -**@raise** [ArgumentError] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## dependencies_eql?(spec, other_spec) [](#method-i-dependencies_eql?) - -**@return** [Boolean] - -## dependency_names() [](#method-i-dependency_names) - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&blk) [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) - -**@return** [Index] a new instance of Index - -## initialize_copy(o) [](#method-i-initialize_copy) - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## local_search(query) [](#method-i-local_search) - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## merge!(other) [](#method-i-merge!) -Combines indexes proritizing specs from `other`, like `Hash#merge!` Duplicate -specs found in `self` are saved in `@duplicates`. - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## search(query) [](#method-i-search) -Search this index's specs, and any source indexes that this index knows about, -returning all of the results. - -## search_all(name, &blk) [](#method-i-search_all) - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## spec_names() [](#method-i-spec_names) - -## subset?(other) [](#method-i-subset?) -Whether all the specs in self are in other - -**@return** [Boolean] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## unmet_dependency_names() [](#method-i-unmet_dependency_names) - -## use(other) [](#method-i-use) -Combines indexes proritizing existing specs, like `Hash#reverse_merge!` -Duplicate specs found in `other` are stored in `@duplicates`. - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Bundler/Injector.md b/example/ruby/Bundler/Injector.md deleted file mode 100644 index d01fd24..0000000 --- a/example/ruby/Bundler/Injector.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Bundler::Injector -**Inherits:** Object - - - - -# Class Methods -## inject(new_deps , options {}) [](#method-c-inject) -## remove(gems , options {}) [](#method-c-remove) - -#Instance Methods -## initialize(deps, options{}) [](#method-i-initialize) - -**@return** [Injector] a new instance of Injector - -## inject(gemfile_path, lockfile_path) [](#method-i-inject) - -**@param** [Pathname] The Gemfile in which to inject the new dependency. - -**@param** [Pathname] The lockfile in which to inject the new dependency. - -**@return** [Array] - -## remove(gemfile_path, lockfile_path) [](#method-i-remove) - -**@param** [Pathname] The Gemfile from which to remove dependencies. - -**@param** [Pathname] The lockfile from which to remove dependencies. - -**@return** [Array] - diff --git a/example/ruby/Bundler/InsecureInstallPathError.md b/example/ruby/Bundler/InsecureInstallPathError.md deleted file mode 100644 index f79ce9b..0000000 --- a/example/ruby/Bundler/InsecureInstallPathError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: Bundler::InsecureInstallPathError -**Inherits:** Bundler::BundlerError - - - - - -#Instance Methods -## initialize(name, path) [](#method-i-initialize) - -**@return** [InsecureInstallPathError] a new instance of InsecureInstallPathError - -## message() [](#method-i-message) - diff --git a/example/ruby/Bundler/InstallError.md b/example/ruby/Bundler/InstallError.md deleted file mode 100644 index e047472..0000000 --- a/example/ruby/Bundler/InstallError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::InstallError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/InstallHookError.md b/example/ruby/Bundler/InstallHookError.md deleted file mode 100644 index 7c19485..0000000 --- a/example/ruby/Bundler/InstallHookError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::InstallHookError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/Installer.md b/example/ruby/Bundler/Installer.md deleted file mode 100644 index beb53d9..0000000 --- a/example/ruby/Bundler/Installer.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: Bundler::Installer -**Inherits:** Object - - - - -# Class Methods -## install(root , definition , options {}) [](#method-c-install) -Begins the installation process for Bundler. For more information see the #run -method on this class. -# Attributes -## ambiguous_gems[RW] [](#attribute-c-ambiguous_gems) -Returns the value of attribute ambiguous_gems. - -## definition[RW] [](#attribute-i-definition) -Returns the value of attribute definition. - -## post_install_messages[RW] [](#attribute-i-post_install_messages) -Returns the value of attribute post_install_messages. - - -#Instance Methods -## generate_bundler_executable_stubs(spec, options{}) [](#method-i-generate_bundler_executable_stubs) - -## generate_standalone_bundler_executable_stubs(spec, options{}) [](#method-i-generate_standalone_bundler_executable_stubs) - -## initialize(root, definition) [](#method-i-initialize) - -**@return** [Installer] a new instance of Installer - -## run(options) [](#method-i-run) -Runs the install procedures for a specific Gemfile. - -Firstly, this method will check to see if `Bundler.bundle_path` exists and if -not then Bundler will create the directory. This is usually the same location -as RubyGems which typically is the `~/.gem` directory unless other specified. - -Secondly, it checks if Bundler has been configured to be "frozen". Frozen -ensures that the Gemfile and the Gemfile.lock file are matching. This stops a -situation where a developer may update the Gemfile but may not run `bundle -install`, which leads to the Gemfile.lock file not being correctly updated. If -this file is not correctly updated then any other developer running `bundle -install` will potentially not install the correct gems. - -Thirdly, Bundler checks if there are any dependencies specified in the -Gemfile. If there are no dependencies specified then Bundler returns a warning -message stating so and this method returns. - -Fourthly, Bundler checks if the Gemfile.lock exists, and if so then proceeds -to set up a definition based on the Gemfile and the Gemfile.lock. During this -step Bundler will also download information about any new gems that are not in -the Gemfile.lock and resolve any dependencies if needed. - -Fifthly, Bundler resolves the dependencies either through a cache of gems or -by remote. This then leads into the gems being installed, along with stubs for -their executables, but only if the --binstubs option has been passed or -[Bundler.options](:bin) has been set earlier. - -Sixthly, a new Gemfile.lock is created from the installed gems to ensure that -the next time that a user runs `bundle install` they will receive any updates -from this process. - -Finally, if the user has specified the standalone flag, Bundler will generate -the needed require paths and save them in a `setup.rb` file. See `bundle -standalone --help` for more information. - diff --git a/example/ruby/Bundler/InvalidArgumentError.md b/example/ruby/Bundler/InvalidArgumentError.md deleted file mode 100644 index 6968c9c..0000000 --- a/example/ruby/Bundler/InvalidArgumentError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::InvalidArgumentError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/InvalidOption.md b/example/ruby/Bundler/InvalidOption.md deleted file mode 100644 index e368f20..0000000 --- a/example/ruby/Bundler/InvalidOption.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::InvalidOption -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/LazySpecification.md b/example/ruby/Bundler/LazySpecification.md deleted file mode 100644 index 78333f5..0000000 --- a/example/ruby/Bundler/LazySpecification.md +++ /dev/null @@ -1,139 +0,0 @@ -# Class: Bundler::LazySpecification -**Inherits:** Object - -**Includes:** Bundler::ForcePlatform, Bundler::MatchMetadata, Bundler::MatchPlatform - - - - -# Class Methods -## from_spec(s ) [](#method-c-from_spec) -# Attributes -## dependencies[RW] [](#attribute-i-dependencies) -Returns the value of attribute dependencies. - -## force_ruby_platform[RW] [](#attribute-i-force_ruby_platform) -Returns the value of attribute force_ruby_platform. - -## materialization[RW] [](#attribute-i-materialization) -Returns the value of attribute materialization. - -## most_specific_locked_platform[RW] [](#attribute-i-most_specific_locked_platform) -For backwards compatibility with existing lockfiles, if the most specific -locked platform is not a specific platform like x86_64-linux or -universal-java-11, then we keep the previous behaviour of resolving the best -platform variant at materiliazation time. For previous bundler versions -(before 2.2.0) this was always the case (except when the lockfile only -included non-ruby platforms), but we're also keeping this behaviour on newer -bundlers unless users generate the lockfile from scratch or explicitly add a -more specific platform. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## platform[RW] [](#attribute-i-platform) -Returns the value of attribute platform. - -## remote[RW] [](#attribute-i-remote) -Returns the value of attribute remote. - -## required_ruby_version[RW] [](#attribute-i-required_ruby_version) -Returns the value of attribute required_ruby_version. - -## required_rubygems_version[RW] [](#attribute-i-required_rubygems_version) -Returns the value of attribute required_rubygems_version. - -## source[RW] [](#attribute-i-source) -Returns the value of attribute source. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## __materialize__(candidates, fallback_to_non_installable:Bundler.frozen_bundle?) [](#method-i-__materialize__) -If in frozen mode, we fallback to a non-installable candidate because by doing -this we avoid re-resolving and potentially end up changing the lock file, -which is not allowed. In that case, we will give a proper error about the -mismatch higher up the stack, right before trying to install the bad gem. - -## default_force_ruby_platform() [](#method-i-default_force_ruby_platform) -The `:force_ruby_platform` value used by dependencies for resolution, and by -locked specifications for materialization is `false` by default, except for -TruffleRuby. TruffleRuby generally needs to force the RUBY platform variant -unless the name is explicitly allowlisted. - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## force_ruby_platform!() [](#method-i-force_ruby_platform!) - -## full_name() [](#method-i-full_name) - -## git_version() [](#method-i-git_version) - -## hash() [](#method-i-hash) - -## incomplete?() [](#method-i-incomplete?) - -**@return** [Boolean] - -## initialize(name, version, platform, sourcenil) [](#method-i-initialize) - -**@return** [LazySpecification] a new instance of LazySpecification - -## inspect() [](#method-i-inspect) - -## lock_name() [](#method-i-lock_name) - -## match_platform(p) [](#method-i-match_platform) - -## matches_current_metadata?() [](#method-i-matches_current_metadata?) - -**@return** [Boolean] - -## matches_current_ruby?() [](#method-i-matches_current_ruby?) - -**@return** [Boolean] - -## matches_current_rubygems?() [](#method-i-matches_current_rubygems?) - -**@return** [Boolean] - -## materialize_for_installation() [](#method-i-materialize_for_installation) - -## materialize_strictly() [](#method-i-materialize_strictly) - -## materialized_for_installation() [](#method-i-materialized_for_installation) - -## missing?() [](#method-i-missing?) - -**@return** [Boolean] - -## name_tuple() [](#method-i-name_tuple) - -## satisfies?(dependency) [](#method-i-satisfies?) -Does this locked specification satisfy `dependency`? - -NOTE: Rubygems default requirement is ">= 0", which doesn't match prereleases -of 0 versions, like "0.0.0.dev" or "0.0.0.SNAPSHOT". However, bundler users -expect those to work. We need to make sure that Gemfile dependencies without -explicit requirements (which use ">= 0" under the hood by default) are still -valid for locked specs using this kind of versions. The method implements an -ad-hoc fix for that. A better solution might be to change default rubygems -requirement of dependencies to be ">= 0.A" but that's a major refactoring -likely to break things. Hopefully we can attempt it in the future. - -**@return** [Boolean] - -## source_changed?() [](#method-i-source_changed?) - -**@return** [Boolean] - -## to_lock() [](#method-i-to_lock) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/LockfileError.md b/example/ruby/Bundler/LockfileError.md deleted file mode 100644 index 04c4d3d..0000000 --- a/example/ruby/Bundler/LockfileError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::LockfileError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/LockfileGenerator.md b/example/ruby/Bundler/LockfileGenerator.md deleted file mode 100644 index cd48249..0000000 --- a/example/ruby/Bundler/LockfileGenerator.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Bundler::LockfileGenerator -**Inherits:** Object - - - - -# Class Methods -## generate(definition ) [](#method-c-generate) -# Attributes -## definition[RW] [](#attribute-i-definition) -Returns the value of attribute definition. - -## out[RW] [](#attribute-i-out) -Returns the value of attribute out. - - -#Instance Methods -## generate!() [](#method-i-generate!) - -## initialize(definition) [](#method-i-initialize) - -**@private** [] - -**@return** [LockfileGenerator] a new instance of LockfileGenerator - diff --git a/example/ruby/Bundler/LockfileParser.md b/example/ruby/Bundler/LockfileParser.md deleted file mode 100644 index 755bebc..0000000 --- a/example/ruby/Bundler/LockfileParser.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: Bundler::LockfileParser -**Inherits:** Object - -**Includes:** Bundler::GemHelpers - - - - -# Class Methods -## bundled_with() [](#method-c-bundled_with) -## sections_in_lockfile(lockfile_contents ) [](#method-c-sections_in_lockfile) -## sections_to_ignore(base_version nil) [](#method-c-sections_to_ignore) -## unknown_sections_in_lockfile(lockfile_contents ) [](#method-c-unknown_sections_in_lockfile) -# Attributes -## bundler_version[RW] [](#attribute-i-bundler_version) -Returns the value of attribute bundler_version. - -## dependencies[RW] [](#attribute-i-dependencies) -Returns the value of attribute dependencies. - -## most_specific_locked_platform[RW] [](#attribute-i-most_specific_locked_platform) -Returns the value of attribute most_specific_locked_platform. - -## platforms[RW] [](#attribute-i-platforms) -Returns the value of attribute platforms. - -## ruby_version[RW] [](#attribute-i-ruby_version) -Returns the value of attribute ruby_version. - -## sources[RW] [](#attribute-i-sources) -Returns the value of attribute sources. - -## specs[RW] [](#attribute-i-specs) -Returns the value of attribute specs. - - -#Instance Methods -## initialize(lockfile) [](#method-i-initialize) - -**@return** [LockfileParser] a new instance of LockfileParser - -## may_include_redundant_platform_specific_gems?() [](#method-i-may_include_redundant_platform_specific_gems?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/LockfileParser/Position.md b/example/ruby/Bundler/LockfileParser/Position.md deleted file mode 100644 index 8532031..0000000 --- a/example/ruby/Bundler/LockfileParser/Position.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Bundler::LockfileParser::Position -**Inherits:** Object - - - - -# Attributes -## column[RW] [](#attribute-i-column) -Returns the value of attribute column. - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line. - - -#Instance Methods -## advance!(string) [](#method-i-advance!) - -## initialize(line, column) [](#method-i-initialize) - -**@return** [Position] a new instance of Position - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/MarshalError.md b/example/ruby/Bundler/MarshalError.md deleted file mode 100644 index ebd1df7..0000000 --- a/example/ruby/Bundler/MarshalError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::MarshalError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Bundler/MatchMetadata.md b/example/ruby/Bundler/MatchMetadata.md deleted file mode 100644 index 7967b58..0000000 --- a/example/ruby/Bundler/MatchMetadata.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: Bundler::MatchMetadata - - - - - -#Instance Methods -## matches_current_metadata?() [](#method-i-matches_current_metadata?) - -**@return** [Boolean] - -## matches_current_ruby?() [](#method-i-matches_current_ruby?) - -**@return** [Boolean] - -## matches_current_rubygems?() [](#method-i-matches_current_rubygems?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/MatchPlatform.md b/example/ruby/Bundler/MatchPlatform.md deleted file mode 100644 index e489209..0000000 --- a/example/ruby/Bundler/MatchPlatform.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: Bundler::MatchPlatform - -**Includes:** Bundler::GemHelpers - - - - -# Class Methods -## platforms_match?(gemspec_platform , local_platform ) [](#method-c-platforms_match?) -**@return** [Boolean] - - -#Instance Methods -## match_platform(p) [](#method-i-match_platform) - diff --git a/example/ruby/Bundler/MatchRemoteMetadata.md b/example/ruby/Bundler/MatchRemoteMetadata.md deleted file mode 100644 index bb529a3..0000000 --- a/example/ruby/Bundler/MatchRemoteMetadata.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: Bundler::MatchRemoteMetadata - -**Includes:** Bundler::FetchMetadata, Bundler::MatchMetadata - - - - - -#Instance Methods -## matches_current_metadata?() [](#method-i-matches_current_metadata?) - -**@return** [Boolean] - -## matches_current_ruby?() [](#method-i-matches_current_ruby?) - -**@return** [Boolean] - -## matches_current_rubygems?() [](#method-i-matches_current_rubygems?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/Materialization.md b/example/ruby/Bundler/Materialization.md deleted file mode 100644 index 477748b..0000000 --- a/example/ruby/Bundler/Materialization.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Bundler::Materialization -**Inherits:** Object - - -This class materializes a set of resolved specifications (`LazySpecification`) -for a given gem into the most appropriate real specifications -(`StubSepecification`, `EndpointSpecification`, etc), given a dependency and a -target platform. - - - -#Instance Methods -## complete?() [](#method-i-complete?) - -**@return** [Boolean] - -## completely_missing_specs() [](#method-i-completely_missing_specs) - -## dependencies() [](#method-i-dependencies) - -## incomplete_specs() [](#method-i-incomplete_specs) - -## initialize(dep, platform, candidates:) [](#method-i-initialize) - -**@return** [Materialization] a new instance of Materialization - -## materialized_spec() [](#method-i-materialized_spec) - -## partially_missing_specs() [](#method-i-partially_missing_specs) - -## specs() [](#method-i-specs) - diff --git a/example/ruby/Bundler/MirrorSockets.md b/example/ruby/Bundler/MirrorSockets.md deleted file mode 100644 index c98f7bb..0000000 --- a/example/ruby/Bundler/MirrorSockets.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Bundler::MirrorSockets -**Inherits:** Object - - -Class used to build the list of sockets that correspond to - a given mirror. - -One mirror may correspond to many different addresses, both - because of it having many dns entries or because - the network interface is both ipv4 and ipv5 - - - -#Instance Methods -## any?() [](#method-i-any?) - -**@return** [Boolean] - -## initialize(mirror) [](#method-i-initialize) - -**@return** [MirrorSockets] a new instance of MirrorSockets - diff --git a/example/ruby/Bundler/NoSpaceOnDeviceError.md b/example/ruby/Bundler/NoSpaceOnDeviceError.md deleted file mode 100644 index c32b62e..0000000 --- a/example/ruby/Bundler/NoSpaceOnDeviceError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Bundler::NoSpaceOnDeviceError -**Inherits:** Bundler::PermissionError - - - - - -#Instance Methods -## message() [](#method-i-message) - diff --git a/example/ruby/Bundler/OperationNotSupportedError.md b/example/ruby/Bundler/OperationNotSupportedError.md deleted file mode 100644 index 836ed4a..0000000 --- a/example/ruby/Bundler/OperationNotSupportedError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Bundler::OperationNotSupportedError -**Inherits:** Bundler::PermissionError - - - - - -#Instance Methods -## message() [](#method-i-message) - diff --git a/example/ruby/Bundler/ParallelInstaller.md b/example/ruby/Bundler/ParallelInstaller.md deleted file mode 100644 index 74d6436..0000000 --- a/example/ruby/Bundler/ParallelInstaller.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Bundler::ParallelInstaller -**Inherits:** Object - - - - -# Class Methods -## call(*args , **kwargs ) [](#method-c-call) -# Attributes -## size[RW] [](#attribute-i-size) -Returns the value of attribute size. - - -#Instance Methods -## call() [](#method-i-call) - -## initialize(installer, all_specs, size, standalone, force, local:false, skip:nil) [](#method-i-initialize) - -**@return** [ParallelInstaller] a new instance of ParallelInstaller - diff --git a/example/ruby/Bundler/ParallelInstaller/SpecInstallation.md b/example/ruby/Bundler/ParallelInstaller/SpecInstallation.md deleted file mode 100644 index 5920269..0000000 --- a/example/ruby/Bundler/ParallelInstaller/SpecInstallation.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Bundler::ParallelInstaller::SpecInstallation -**Inherits:** Object - - - - -# Attributes -## error[RW] [](#attribute-i-error) -Returns the value of attribute error. - -## full_name[RW] [](#attribute-i-full_name) -Returns the value of attribute full_name. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## post_install_message[RW] [](#attribute-i-post_install_message) -Returns the value of attribute post_install_message. - -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - -## state[RW] [](#attribute-i-state) -Returns the value of attribute state. - - -#Instance Methods -## all_dependencies() [](#method-i-all_dependencies) -Represents all dependencies - -## dependencies() [](#method-i-dependencies) -Represents only the non-development dependencies, the ones that are itself and -are in the total list. - -## dependencies_installed?(installed_specs) [](#method-i-dependencies_installed?) -Checks installed dependencies against spec's dependencies to make sure needed -dependencies have been installed. - -**@return** [Boolean] - -## enqueued?() [](#method-i-enqueued?) - -**@return** [Boolean] - -## failed?() [](#method-i-failed?) - -**@return** [Boolean] - -## has_post_install_message?() [](#method-i-has_post_install_message?) - -**@return** [Boolean] - -## ignorable_dependency?(dep) [](#method-i-ignorable_dependency?) - -**@return** [Boolean] - -## initialize(spec) [](#method-i-initialize) - -**@return** [SpecInstallation] a new instance of SpecInstallation - -## installed?() [](#method-i-installed?) - -**@return** [Boolean] - -## ready_to_enqueue?() [](#method-i-ready_to_enqueue?) - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/PathError.md b/example/ruby/Bundler/PathError.md deleted file mode 100644 index 6961a66..0000000 --- a/example/ruby/Bundler/PathError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::PathError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/PermissionError.md b/example/ruby/Bundler/PermissionError.md deleted file mode 100644 index 78d9f69..0000000 --- a/example/ruby/Bundler/PermissionError.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: Bundler::PermissionError -**Inherits:** Bundler::BundlerError - - - - - -#Instance Methods -## action() [](#method-i-action) - -## initialize(path, permission_type:write) [](#method-i-initialize) - -**@return** [PermissionError] a new instance of PermissionError - -## message() [](#method-i-message) - -## parent_folder() [](#method-i-parent_folder) - -## permission_type() [](#method-i-permission_type) - diff --git a/example/ruby/Bundler/Persistent.md b/example/ruby/Bundler/Persistent.md deleted file mode 100644 index 723b919..0000000 --- a/example/ruby/Bundler/Persistent.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bundler::Persistent - - - - - diff --git a/example/ruby/Bundler/Persistent/Net.md b/example/ruby/Bundler/Persistent/Net.md deleted file mode 100644 index d6307e3..0000000 --- a/example/ruby/Bundler/Persistent/Net.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bundler::Persistent::Net - - - - - diff --git a/example/ruby/Bundler/Persistent/Net/HTTP.md b/example/ruby/Bundler/Persistent/Net/HTTP.md deleted file mode 100644 index 279bc2e..0000000 --- a/example/ruby/Bundler/Persistent/Net/HTTP.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bundler::Persistent::Net::HTTP - - - - - diff --git a/example/ruby/Bundler/Plugin.md b/example/ruby/Bundler/Plugin.md deleted file mode 100644 index d445ca3..0000000 --- a/example/ruby/Bundler/Plugin.md +++ /dev/null @@ -1,130 +0,0 @@ -# Module: Bundler::Plugin - - -SourceList object to be used while parsing the Gemfile, setting the -approptiate options to be used with Source classes for plugin installation - - -# Class Methods -## add_command(command , cls ) [](#method-c-add_command) -To be called via the API to register to handle a command -## add_hook(event , &block ) [](#method-c-add_hook) -To be called via the API to register a hooks and corresponding block that will -be called to handle the hook -## add_source(source , cls ) [](#method-c-add_source) -To be called via the API to register to handle a source plugin -## cache() [](#method-c-cache) -The cache directory for plugin stuffs -## command?(command ) [](#method-c-command?) -Checks if any plugin handles the command -**@return** [Boolean] - -## exec_command(command , args ) [](#method-c-exec_command) -To be called from Cli class to pass the command and argument to appropriate -plugin class -**@raise** [UndefinedCommandError] - -## from_lock(locked_opts ) [](#method-c-from_lock) -**@param** [Hash] options that are present in the lock file - -**@return** [API::Source] the instance of the class that handles the source -type passed in locked_opts - -## gemfile_install(gemfile nil, &inline ) [](#method-c-gemfile_install) -Evaluates the Gemfile with a limited DSL and installs the plugins specified by -plugin method -**@param** [Pathname] path - -**@param** [Proc] that can be evaluated for (inline) Gemfile - -## global_root() [](#method-c-global_root) -The global directory root for all plugin related data -## hook(event , *args , &arg_blk ) [](#method-c-hook) -Runs all the hooks that are registered for the passed event - -It passes the passed arguments and block to the block registered with the api. -**@param** [String] - -## index() [](#method-c-index) -The index object used to store the details about the plugin -## install(names , options ) [](#method-c-install) -Installs a new plugin by the given name -**@param** [Array] the name of plugin to be installed - -**@param** [Hash] various parameters as described in description. -Refer to cli/plugin for available options - -## installed?(plugin ) [](#method-c-installed?) -currently only intended for specs -**@return** [String, nil] installed path - -## list() [](#method-c-list) -List installed plugins and commands -## load_plugin(name ) [](#method-c-load_plugin) -Executes the plugins.rb file -**@param** [String] of the plugin - -## loaded?(plugin ) [](#method-c-loaded?) -**@return** [true, false] whether the plugin is loaded - -## local_root() [](#method-c-local_root) -## register_plugin(name , spec , optional_plugin false) [](#method-c-register_plugin) -Runs the plugins.rb file in an isolated namespace, records the plugin actions -it registers for and then passes the data to index to be stored. -**@param** [String] the name of the plugin - -**@param** [Specification] of installed plugin - -**@param** [Boolean] removed if there is conflict with any -other plugin (used for default source plugins) - -**@raise** [MalformattedPlugin] if plugins.rb raises any error - -## reset!() [](#method-c-reset!) -## root() [](#method-c-root) -The directory root for all plugin related data - -If run in an app, points to local root, in app_config_path Otherwise, points -to global root, in Bundler.user_bundle_path("plugin") -## save_plugin(name , spec , optional_plugin false) [](#method-c-save_plugin) -Validates and registers a plugin. -**@param** [String] the name of the plugin - -**@param** [Specification] of installed plugin - -**@param** [Boolean] removed if there is conflict with any -other plugin (used for default source plugins) - -**@raise** [PluginInstallError] if validation or registration raises any error - -## save_plugins(plugins , specs , optional_plugins []) [](#method-c-save_plugins) -Post installation processing and registering with index -**@param** [Array] list to be installed - -**@param** [Hash] of plugins mapped to installation path (currently they -contain all the installed specs, including plugins) - -**@param** [Array] of inferred source plugins that can be ignored - -## source(name ) [](#method-c-source) -**@raise** [UnknownSourceError] - -**@return** [Class] that handles the source. The class includes API::Source - -## source?(name ) [](#method-c-source?) -Checks if any plugin declares the source -**@return** [Boolean] - -## uninstall(names , options ) [](#method-c-uninstall) -Uninstalls plugins by the given names -**@param** [Array] the names of plugins to be uninstalled - -## validate_plugin!(plugin_path ) [](#method-c-validate_plugin!) -Checks if the gem is good to be a plugin - -At present it only checks whether it contains plugins.rb file -**@param** [Pathname] the path plugin is installed at - -**@raise** [MalformattedPlugin] if plugins.rb file is not found - - diff --git a/example/ruby/Bundler/Plugin/API.md b/example/ruby/Bundler/Plugin/API.md deleted file mode 100644 index ddd6a1d..0000000 --- a/example/ruby/Bundler/Plugin/API.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: Bundler::Plugin::API -**Inherits:** Object - - - - -# Class Methods -## command(command , cls self) [](#method-c-command) -The plugins should declare that they handle a command through this helper. -**@param** [String] being handled by them - -**@param** [Class] class that handles the command. If not -provided, the `self` class will be used. - -## hook(event , &block ) [](#method-c-hook) -## source(source , cls self) [](#method-c-source) -The plugins should declare that they provide a installation source through -this helper. -**@param** [String] source type they provide - -**@param** [Class] class that handles the source. If not -provided, the `self` class will be used. - - -#Instance Methods -## cache_dir() [](#method-i-cache_dir) -The cache dir to be used by the plugins for storage - -**@return** [Pathname] path of the cache dir - -## method_missing(name, *args, &blk) [](#method-i-method_missing) - -## respond_to_missing?(name, include_privatefalse) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - -## tmp(*names) [](#method-i-tmp) -A tmp dir to be used by plugins Accepts names that get concatenated as suffix - -**@return** [Pathname] object for the new directory created - diff --git a/example/ruby/Bundler/Plugin/API/Source.md b/example/ruby/Bundler/Plugin/API/Source.md deleted file mode 100644 index 828238d..0000000 --- a/example/ruby/Bundler/Plugin/API/Source.md +++ /dev/null @@ -1,236 +0,0 @@ -# Module: Bundler::Plugin::API::Source - - -This class provides the base to build source plugins All the method here are -required to build a source plugin (except `uri_hash`, `gem_install_dir`; they -are helpers). - -Defaults for methods, where ever possible are provided which is expected to -work. But, all source plugins have to override `fetch_gemspec_files` and -`install`. Defaults are also not provided for `remote!`, `cache!` and -`unlock!`. - -The defaults shall work for most situations but nevertheless they can be -(preferably should be) overridden as per the plugins' needs safely (as long as -they behave as expected). On overriding `initialize` you should call super -first. - -If required plugin should override `hash`, `==` and `eql?` methods to be able -to match objects representing same sources, but may be created in different -situation (like form gemfile and lockfile). The default ones checks only for -class and uri, but elaborate source plugins may need more comparisons (e.g. -git checking on branch or tag). - - -# Attributes -## checksum_store[RW] [](#attribute-i-checksum_store) -Returns the value of attribute checksum_store. - -## dependency_names[RW] [](#attribute-i-dependency_names) - -**@return** [Array] Names of dependencies that the source should -try to resolve. It is not necessary to use this list internally. This -is present to be compatible with `Definition` and is used by -rubygems source. - -## name[RW] [](#attribute-i-name) - -**@return** [String] name that can be used to uniquely identify a source - -## options[RW] [](#attribute-i-options) - -**@return** [String] options passed during initialization (either from -lockfile or Gemfile) - -## uri[RW] [](#attribute-i-uri) - -**@return** [String] the remote specified with `source` block in Gemfile - - -#Instance Methods -## ==(other) [](#method-i-==) -This shall check if two source object represent the same source. - -The comparison shall take place only on the attribute that can be inferred -from the options passed from Gemfile and not on attributes that are used to -pin down the gem to specific version (e.g. Git sources should compare on -branch and tag but not on commit hash) - -The sources objects are constructed from Gemfile as well as from lockfile. To -converge the sources, it is necessary that they match. - -The same applies for `eql?` and `hash` - -## add_dependency_names(names) [](#method-i-add_dependency_names) -Used by definition. - -Note: Do not override if you don't know what you are doing. - -## app_cache_dirname() [](#method-i-app_cache_dirname) -Name of directory where plugin the is expected to cache the gems when #cache -is called. - -Also this name is matched against the directories in cache for pruning - -This is used by `app_cache_path` - -## app_cache_path(custom_pathnil) [](#method-i-app_cache_path) -The full path where the plugin should cache the gem so that it can be -installed latter. - -Note: Do not override if you don't know what you are doing. - -## cache(spec, custom_pathnil) [](#method-i-cache) -This method is called while caching to save copy of the gems that the source -can resolve to path provided by `app_cache_app`so that they can be reinstalled -from the cache without querying the remote (i.e. an alternative to remote) - -This is stored with the app and source plugins should try to provide specs and -install only from this cache when `cached!` is called. - -This cache is different from the internal caching that can be done at sub -paths of `cache_path` (from API). This can be though as caching by bundler. - -## cached!() [](#method-i-cached!) -Set internal representation to fetch the gems/specs from app cache. - -When this is called, the source should try to fetch the specs and install from -the path provided by `app_cache_path`. - -## can_lock?(spec) [](#method-i-can_lock?) -NOTE: Do not override if you don't know what you are doing. - -**@return** [Boolean] - -## double_check_for() [](#method-i-double_check_for) -This API on source might not be stable, and for now we expect plugins to -download all specs in `#specs`, so we implement the method for compatibility -purposes and leave it undocumented (and don't support) overriding it) - -**@private** [] - -## fetch_gemspec_files() [](#method-i-fetch_gemspec_files) -This is used by the default `spec` method to constructs the Specification -objects for the gems and versions that can be installed by this source plugin. - -Note: If the spec method is overridden, this function is not necessary - -**@return** [Array] paths of the gemspec files for gems that can -be installed - -## gem_install_dir() [](#method-i-gem_install_dir) -NOTE: Do not override if you don't know what you are doing. - -## hash() [](#method-i-hash) -When overriding `hash` please preserve the behaviour as mentioned in docstring -for `==` method, i.e. two methods equal by above comparison should have same -hash. - -## include?(other) [](#method-i-include?) -NOTE: Do not override if you don't know what you are doing. - -**@return** [Boolean] - -## initialize(opts) [](#method-i-initialize) - -## install(spec, opts) [](#method-i-install) -Install the gem specified by the spec at appropriate path. `install_path` -provides a sufficient default, if the source can only satisfy one gem, but is -not binding. - -**@raise** [MalformattedPlugin] - -**@return** [String] post installation message (if any) - -## install_path() [](#method-i-install_path) -A default installation path to install a single gem. If the source servers -multiple gems, it's not of much use and the source should one of its own. - -## installed?() [](#method-i-installed?) -A helper method, not necessary if not used internally. - -**@return** [Boolean] - -## local!() [](#method-i-local!) -Set internal representation to fetch the gems/specs locally. - -When this is called, the source should try to fetch the specs and install from -the local system. - -## options_to_lock() [](#method-i-options_to_lock) -Options to be saved in the lockfile so that the source plugin is able to check -out same version of gem later. - -There options are passed when the source plugin is created from the lock file. - -**@return** [Hash] - -## post_install(spec, disable_extsfalse) [](#method-i-post_install) -It builds extensions, generates bins and installs them for the spec provided. - -It depends on `spec.loaded_from` to get full_gem_path. The source plugins -should set that. - -It should be called in `install` after the plugin is done placing the gem at -correct install location. - -It also runs Gem hooks `pre_install`, `post_build` and `post_install` - -Note: Do not override if you don't know what you are doing. - -## remote!() [](#method-i-remote!) -Set internal representation to fetch the gems/specs from remote. - -When this is called, the source should try to fetch the specs and install from -remote path. - -## root() [](#method-i-root) -It is used to obtain the full_gem_path. - -spec's loaded_from path is expanded against this to get full_gem_path - -Note: Do not override if you don't know what you are doing. - -## spec_names() [](#method-i-spec_names) -Used by definition. - -Note: Do not override if you don't know what you are doing. - -## specs() [](#method-i-specs) -Parses the gemspec files to find the specs for the gems that can be satisfied -by the source. - -Few important points to keep in mind: - - If the gems are not installed then it shall return specs for all - the gems it can satisfy - - If gem is installed (that is to be detected by the plugin itself) - then it shall return at least the specs that are installed. - - The `loaded_from` for each of the specs shall be correct (it is - used to find the load path) - -**@return** [Bundler::Index] index containing the specs - -## to_lock() [](#method-i-to_lock) -Generates the content to be entered into the lockfile. Saves type and remote -and also calls to `options_to_lock`. - -Plugin should use `options_to_lock` to save information in lockfile and not -override this. - -Note: Do not override if you don't know what you are doing. - -## to_s() [](#method-i-to_s) - -## unlock!() [](#method-i-unlock!) -This is called to update the spec and installation. - -If the source plugin is loaded from lockfile or otherwise, it shall refresh -the cache/specs (e.g. git sources can make a fresh clone). - -## unmet_deps() [](#method-i-unmet_deps) -Used by definition. - -Note: Do not override if you don't know what you are doing. - -## uri_hash() [](#method-i-uri_hash) - diff --git a/example/ruby/Bundler/Plugin/DSL.md b/example/ruby/Bundler/Plugin/DSL.md deleted file mode 100644 index 2f08a2f..0000000 --- a/example/ruby/Bundler/Plugin/DSL.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Bundler::Plugin::DSL -**Inherits:** Bundler::Dsl - - -Dsl to parse the Gemfile looking for plugins to install - - -# Attributes -## inferred_plugins[RW] [](#attribute-i-inferred_plugins) -This lists the plugins that was added automatically and not specified by the -user. - -When we encounter :type attribute with a source block, we add a plugin by name -bundler-source- to list of plugins to be installed. - -These plugins are optional and are not installed when there is conflict with -any other plugin. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [DSL] a new instance of DSL - -## method_missing(name, *args) [](#method-i-method_missing) - -**@raise** [PluginGemfileError] - -## plugin(name, *args) [](#method-i-plugin) - -## source(source, *args, &blk) [](#method-i-source) - diff --git a/example/ruby/Bundler/Plugin/DSL/PluginGemfileError.md b/example/ruby/Bundler/Plugin/DSL/PluginGemfileError.md deleted file mode 100644 index 9cf5072..0000000 --- a/example/ruby/Bundler/Plugin/DSL/PluginGemfileError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Plugin::DSL::PluginGemfileError -**Inherits:** Bundler::PluginError - - - - - diff --git a/example/ruby/Bundler/Plugin/Events.md b/example/ruby/Bundler/Plugin/Events.md deleted file mode 100644 index 09bcd13..0000000 --- a/example/ruby/Bundler/Plugin/Events.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: Bundler::Plugin::Events - - - - -# Class Methods -## defined_event?(event ) [](#method-c-defined_event?) -Check if an event has been defined -**@param** [String] An event to check - -**@return** [Boolean] A boolean indicating if the event has been defined - - diff --git a/example/ruby/Bundler/Plugin/Index.md b/example/ruby/Bundler/Plugin/Index.md deleted file mode 100644 index 2ff65d5..0000000 --- a/example/ruby/Bundler/Plugin/Index.md +++ /dev/null @@ -1,72 +0,0 @@ -# Class: Bundler::Plugin::Index -**Inherits:** Object - - - - -# Attributes -## commands[RW] [](#attribute-i-commands) -Returns the value of attribute commands. - - -#Instance Methods -## command_plugin(command) [](#method-i-command_plugin) -Fetch the name of plugin handling the command - -## global_index_file() [](#method-i-global_index_file) -Path where the global index file is stored - -## hook_plugins(event) [](#method-i-hook_plugins) -Returns the list of plugin names handling the passed event - -## index_file() [](#method-i-index_file) -Path of default index file - -## initialize() [](#method-i-initialize) - -**@return** [Index] a new instance of Index - -## installed?(name) [](#method-i-installed?) - -**@return** [Boolean] - -## installed_in_plugin_root?(name) [](#method-i-installed_in_plugin_root?) -This plugin is installed inside the .bundle/plugin directory, and thus is -managed solely by Bundler - -**@return** [Boolean] - -## installed_plugins() [](#method-i-installed_plugins) - -## load_paths(name) [](#method-i-load_paths) - -## local_index_file() [](#method-i-local_index_file) -Path where the local index file is stored - -## plugin_commands(plugin) [](#method-i-plugin_commands) - -## plugin_path(name) [](#method-i-plugin_path) - -## register_plugin(name, path, load_paths, commands, sources, hooks) [](#method-i-register_plugin) -This function is to be called when a new plugin is installed. This function -shall add the functions of the plugin to existing maps and also the name to -source location. - -**@param** [String] of the plugin to be registered - -**@param** [String] where the plugin is installed - -**@param** [Array] for the plugin - -**@param** [Array] that are handled by the plugin - -**@param** [Array] that are handled by the plugin - -## source?(source) [](#method-i-source?) - -**@return** [Boolean] - -## source_plugin(name) [](#method-i-source_plugin) - -## unregister_plugin(name) [](#method-i-unregister_plugin) - diff --git a/example/ruby/Bundler/Plugin/Index/CommandConflict.md b/example/ruby/Bundler/Plugin/Index/CommandConflict.md deleted file mode 100644 index 898601b..0000000 --- a/example/ruby/Bundler/Plugin/Index/CommandConflict.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::Plugin::Index::CommandConflict -**Inherits:** Bundler::PluginError - - - - - -#Instance Methods -## initialize(plugin, commands) [](#method-i-initialize) - -**@return** [CommandConflict] a new instance of CommandConflict - diff --git a/example/ruby/Bundler/Plugin/Index/SourceConflict.md b/example/ruby/Bundler/Plugin/Index/SourceConflict.md deleted file mode 100644 index 39ce23e..0000000 --- a/example/ruby/Bundler/Plugin/Index/SourceConflict.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::Plugin::Index::SourceConflict -**Inherits:** Bundler::PluginError - - - - - -#Instance Methods -## initialize(plugin, sources) [](#method-i-initialize) - -**@return** [SourceConflict] a new instance of SourceConflict - diff --git a/example/ruby/Bundler/Plugin/Installer.md b/example/ruby/Bundler/Plugin/Installer.md deleted file mode 100644 index 5974b32..0000000 --- a/example/ruby/Bundler/Plugin/Installer.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::Plugin::Installer -**Inherits:** Object - - - - - -#Instance Methods -## install(names, options) [](#method-i-install) - -## install_definition(definition) [](#method-i-install_definition) -Installs the plugin from Definition object created by limited parsing of -Gemfile searching for plugins to be installed - -**@param** [Definition] object - -**@return** [Hash] map of names to their specs they are installed with - diff --git a/example/ruby/Bundler/Plugin/Installer/Git.md b/example/ruby/Bundler/Plugin/Installer/Git.md deleted file mode 100644 index 7f00aeb..0000000 --- a/example/ruby/Bundler/Plugin/Installer/Git.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bundler::Plugin::Installer::Git -**Inherits:** Bundler::Source::Git - - - - - -#Instance Methods -## cache_path() [](#method-i-cache_path) - -## generate_bin(spec, disable_extensionsfalse) [](#method-i-generate_bin) - -## install_path() [](#method-i-install_path) - -## root() [](#method-i-root) - diff --git a/example/ruby/Bundler/Plugin/Installer/Path.md b/example/ruby/Bundler/Plugin/Installer/Path.md deleted file mode 100644 index a52a836..0000000 --- a/example/ruby/Bundler/Plugin/Installer/Path.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bundler::Plugin::Installer::Path -**Inherits:** Bundler::Source::Path - - - - - -#Instance Methods -## generate_bin(spec, disable_extensionsfalse) [](#method-i-generate_bin) - -## root() [](#method-i-root) - diff --git a/example/ruby/Bundler/Plugin/Installer/Rubygems.md b/example/ruby/Bundler/Plugin/Installer/Rubygems.md deleted file mode 100644 index bd0cadc..0000000 --- a/example/ruby/Bundler/Plugin/Installer/Rubygems.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Bundler::Plugin::Installer::Rubygems -**Inherits:** Bundler::Source::Rubygems - - - - - diff --git a/example/ruby/Bundler/Plugin/MalformattedPlugin.md b/example/ruby/Bundler/Plugin/MalformattedPlugin.md deleted file mode 100644 index 108f3f7..0000000 --- a/example/ruby/Bundler/Plugin/MalformattedPlugin.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Plugin::MalformattedPlugin -**Inherits:** Bundler::PluginError - - - - - diff --git a/example/ruby/Bundler/Plugin/PluginInstallError.md b/example/ruby/Bundler/Plugin/PluginInstallError.md deleted file mode 100644 index ae6d46c..0000000 --- a/example/ruby/Bundler/Plugin/PluginInstallError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Plugin::PluginInstallError -**Inherits:** Bundler::PluginError - - - - - diff --git a/example/ruby/Bundler/Plugin/SourceList.md b/example/ruby/Bundler/Plugin/SourceList.md deleted file mode 100644 index 254b34b..0000000 --- a/example/ruby/Bundler/Plugin/SourceList.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bundler::Plugin::SourceList -**Inherits:** Bundler::SourceList - - - - - -#Instance Methods -## add_git_source(options{}) [](#method-i-add_git_source) - -## add_path_source(options{}) [](#method-i-add_path_source) - -## add_rubygems_source(options{}) [](#method-i-add_rubygems_source) - -## all_sources() [](#method-i-all_sources) - diff --git a/example/ruby/Bundler/Plugin/UndefinedCommandError.md b/example/ruby/Bundler/Plugin/UndefinedCommandError.md deleted file mode 100644 index fbdc92a..0000000 --- a/example/ruby/Bundler/Plugin/UndefinedCommandError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Plugin::UndefinedCommandError -**Inherits:** Bundler::PluginError - - - - - diff --git a/example/ruby/Bundler/Plugin/UnknownSourceError.md b/example/ruby/Bundler/Plugin/UnknownSourceError.md deleted file mode 100644 index cc45e33..0000000 --- a/example/ruby/Bundler/Plugin/UnknownSourceError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Plugin::UnknownSourceError -**Inherits:** Bundler::PluginError - - - - - diff --git a/example/ruby/Bundler/PluginError.md b/example/ruby/Bundler/PluginError.md deleted file mode 100644 index 55383dd..0000000 --- a/example/ruby/Bundler/PluginError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::PluginError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/ProcessLock.md b/example/ruby/Bundler/ProcessLock.md deleted file mode 100644 index a5cf99f..0000000 --- a/example/ruby/Bundler/ProcessLock.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Bundler::ProcessLock -**Inherits:** Object - - - - -# Class Methods -## lock(bundle_path Bundler.bundle_path, &block ) [](#method-c-lock) - diff --git a/example/ruby/Bundler/ProductionError.md b/example/ruby/Bundler/ProductionError.md deleted file mode 100644 index 40cdaef..0000000 --- a/example/ruby/Bundler/ProductionError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::ProductionError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/PubGrub.md b/example/ruby/Bundler/PubGrub.md deleted file mode 100644 index dc3af7a..0000000 --- a/example/ruby/Bundler/PubGrub.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bundler::PubGrub - - - - -# Attributes -## logger[RW] [](#attribute-c-logger) - - diff --git a/example/ruby/Bundler/PubGrub/Assignment.md b/example/ruby/Bundler/PubGrub/Assignment.md deleted file mode 100644 index 9e50a53..0000000 --- a/example/ruby/Bundler/PubGrub/Assignment.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Bundler::PubGrub::Assignment -**Inherits:** Object - - - - -# Class Methods -## decision(package , version , decision_level , index ) [](#method-c-decision) -# Attributes -## cause[RW] [](#attribute-i-cause) -Returns the value of attribute cause. - -## decision_level[RW] [](#attribute-i-decision_level) -Returns the value of attribute decision_level. - -## index[RW] [](#attribute-i-index) -Returns the value of attribute index. - -## term[RW] [](#attribute-i-term) -Returns the value of attribute term. - - -#Instance Methods -## decision?() [](#method-i-decision?) - -**@return** [Boolean] - -## initialize(term, cause, decision_level, index) [](#method-i-initialize) - -**@return** [Assignment] a new instance of Assignment - diff --git a/example/ruby/Bundler/PubGrub/BasicPackageSource.md b/example/ruby/Bundler/PubGrub/BasicPackageSource.md deleted file mode 100644 index 34833be..0000000 --- a/example/ruby/Bundler/PubGrub/BasicPackageSource.md +++ /dev/null @@ -1,99 +0,0 @@ -# Class: Bundler::PubGrub::BasicPackageSource -**Inherits:** Object - - -Types: - -Where possible, Bundler::PubGrub will accept user-defined types, so long as -they quack. - -## "Package": - -This class will be used to represent the various packages being solved for. -.to_s will be called when displaying errors and debugging info, it should -probably return the package's name. It must also have a reasonable definition -of #== and #hash - -Example classes: String ("rails") - -## "Version": - -This class will be used to represent a single version number. - -Versions don't need to store their associated package, however they will only -be compared against other versions of the same package. - -It must be Comparible (and implement <=> reasonably) - -Example classes: Gem::Version, Integer - -## "Dependency" - -This class represents the requirement one package has on another. It is -returned by dependencies_for(package, version) and will be passed to -parse_dependency to convert it to a format Bundler::PubGrub understands. - -It must also have a reasonable definition of #== - -Example classes: String ("~> 1.0"), Gem::Requirement - - - -#Instance Methods -## all_versions_for(package) [](#method-i-all_versions_for) -Override me! - -This is called per package to find all possible versions of a package. - -It is called at most once per-package - -Returns: Array of versions for a package, in preferred order of selection - -**@raise** [NotImplementedError] - -## dependencies_for(package, version) [](#method-i-dependencies_for) -Override me! - -Returns: Hash in the form of { package => requirement, ... } - -**@raise** [NotImplementedError] - -## incompatibilities_for(package, version) [](#method-i-incompatibilities_for) - -## initialize() [](#method-i-initialize) - -**@return** [BasicPackageSource] a new instance of BasicPackageSource - -## no_versions_incompatibility_for(_package, unsatisfied_term) [](#method-i-no_versions_incompatibility_for) - -## parse_dependency(package, dependency) [](#method-i-parse_dependency) -Override me! - -Convert a (user-defined) dependency into a format Bundler::PubGrub -understands. - -Package is passed to this method but for many implementations is not needed. - -Returns: either a Bundler::PubGrub::VersionRange, -Bundler::PubGrub::VersionUnion, or a - Bundler::PubGrub::VersionConstraint - -**@raise** [NotImplementedError] - -## root_dependencies() [](#method-i-root_dependencies) -Override me! - -If not overridden, this will call dependencies_for with the root package. - -Returns: Hash in the form of { package => requirement, ... } (see -dependencies_for) - -## sort_versions_by_preferred(package, sorted_versions) [](#method-i-sort_versions_by_preferred) -Override me (maybe) - -If not overridden, the order returned by all_versions_for will be used - -Returns: Array of versions in preferred order - -## versions_for(package, rangeVersionRange.any) [](#method-i-versions_for) - diff --git a/example/ruby/Bundler/PubGrub/FailureWriter.md b/example/ruby/Bundler/PubGrub/FailureWriter.md deleted file mode 100644 index 76ffbf3..0000000 --- a/example/ruby/Bundler/PubGrub/FailureWriter.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::PubGrub::FailureWriter -**Inherits:** Object - - - - - -#Instance Methods -## initialize(root) [](#method-i-initialize) - -**@return** [FailureWriter] a new instance of FailureWriter - -## write() [](#method-i-write) - diff --git a/example/ruby/Bundler/PubGrub/Incompatibility.md b/example/ruby/Bundler/PubGrub/Incompatibility.md deleted file mode 100644 index 4fbe2d4..0000000 --- a/example/ruby/Bundler/PubGrub/Incompatibility.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: Bundler::PubGrub::Incompatibility -**Inherits:** Object - - - - -# Attributes -## cause[RW] [](#attribute-i-cause) -Returns the value of attribute cause. - -## terms[RW] [](#attribute-i-terms) -Returns the value of attribute terms. - - -#Instance Methods -## conflict?() [](#method-i-conflict?) - -**@return** [Boolean] - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## external_incompatibilities() [](#method-i-external_incompatibilities) -Returns all external incompatibilities in this incompatibility's derivation -graph - -## failure?() [](#method-i-failure?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(terms, cause:, custom_explanation:nil) [](#method-i-initialize) - -**@return** [Incompatibility] a new instance of Incompatibility - -## inspect() [](#method-i-inspect) - -## pretty_print(q) [](#method-i-pretty_print) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/PubGrub/Incompatibility/ConflictCause.md b/example/ruby/Bundler/PubGrub/Incompatibility/ConflictCause.md deleted file mode 100644 index 2b2ba7a..0000000 --- a/example/ruby/Bundler/PubGrub/Incompatibility/ConflictCause.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::PubGrub::Incompatibility::ConflictCause -**Inherits:** Struct - - - - -# Attributes -## incompatibility[RW] [](#attribute-i-incompatibility) -Returns the value of attribute incompatibility - -**@return** [Object] the current value of incompatibility - -## satisfier[RW] [](#attribute-i-satisfier) -Returns the value of attribute satisfier - -**@return** [Object] the current value of satisfier - - diff --git a/example/ruby/Bundler/PubGrub/Incompatibility/InvalidDependency.md b/example/ruby/Bundler/PubGrub/Incompatibility/InvalidDependency.md deleted file mode 100644 index 1c2d0f3..0000000 --- a/example/ruby/Bundler/PubGrub/Incompatibility/InvalidDependency.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::PubGrub::Incompatibility::InvalidDependency -**Inherits:** Struct - - - - -# Attributes -## constraint[RW] [](#attribute-i-constraint) -Returns the value of attribute constraint - -**@return** [Object] the current value of constraint - -## package[RW] [](#attribute-i-package) -Returns the value of attribute package - -**@return** [Object] the current value of package - - diff --git a/example/ruby/Bundler/PubGrub/Incompatibility/NoVersions.md b/example/ruby/Bundler/PubGrub/Incompatibility/NoVersions.md deleted file mode 100644 index bed12e9..0000000 --- a/example/ruby/Bundler/PubGrub/Incompatibility/NoVersions.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Bundler::PubGrub::Incompatibility::NoVersions -**Inherits:** Struct - - - - -# Attributes -## constraint[RW] [](#attribute-i-constraint) -Returns the value of attribute constraint - -**@return** [Object] the current value of constraint - - diff --git a/example/ruby/Bundler/PubGrub/Package.md b/example/ruby/Bundler/PubGrub/Package.md deleted file mode 100644 index 4c94cce..0000000 --- a/example/ruby/Bundler/PubGrub/Package.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Bundler::PubGrub::Package -**Inherits:** Object - - - - -# Class Methods -## root() [](#method-c-root) -## root?(package ) [](#method-c-root?) -**@return** [Boolean] - -## root_version() [](#method-c-root_version) -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - -## initialize(name) [](#method-i-initialize) - -**@return** [Package] a new instance of Package - -## inspect() [](#method-i-inspect) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/PubGrub/PartialSolution.md b/example/ruby/Bundler/PubGrub/PartialSolution.md deleted file mode 100644 index bce19c1..0000000 --- a/example/ruby/Bundler/PubGrub/PartialSolution.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: Bundler::PubGrub::PartialSolution -**Inherits:** Object - - - - -# Attributes -## assignments[RW] [](#attribute-i-assignments) -Returns the value of attribute assignments. - -## attempted_solutions[RW] [](#attribute-i-attempted_solutions) -Returns the value of attribute attempted_solutions. - -## decisions[RW] [](#attribute-i-decisions) -Returns the value of attribute decisions. - - -#Instance Methods -## backtrack(previous_level) [](#method-i-backtrack) - -## decide(package, version) [](#method-i-decide) - -## decision_level() [](#method-i-decision_level) - -## derive(term, cause) [](#method-i-derive) - -## initialize() [](#method-i-initialize) - -**@return** [PartialSolution] a new instance of PartialSolution - -## relation(term) [](#method-i-relation) - -## satisfier(term) [](#method-i-satisfier) - -## satisfies?(term) [](#method-i-satisfies?) - -**@return** [Boolean] - -## unsatisfied() [](#method-i-unsatisfied) -A list of unsatisfied terms - diff --git a/example/ruby/Bundler/PubGrub/RubyGems.md b/example/ruby/Bundler/PubGrub/RubyGems.md deleted file mode 100644 index 6a6601e..0000000 --- a/example/ruby/Bundler/PubGrub/RubyGems.md +++ /dev/null @@ -1,22 +0,0 @@ -# Module: Bundler::PubGrub::RubyGems - -**Extended by:** Bundler::PubGrub::RubyGems - - - - -# Class Methods -## parse_constraint(package , dep ) [](#method-c-parse_constraint) -## parse_range(dep ) [](#method-c-parse_range) -## requirement_to_constraint(package , requirement ) [](#method-c-requirement_to_constraint) -## requirement_to_range(requirement ) [](#method-c-requirement_to_range) - -#Instance Methods -## parse_constraint(package, dep) [](#method-i-parse_constraint) - -## parse_range(dep) [](#method-i-parse_range) - -## requirement_to_constraint(package, requirement) [](#method-i-requirement_to_constraint) - -## requirement_to_range(requirement) [](#method-i-requirement_to_range) - diff --git a/example/ruby/Bundler/PubGrub/SolveFailure.md b/example/ruby/Bundler/PubGrub/SolveFailure.md deleted file mode 100644 index 19aeaff..0000000 --- a/example/ruby/Bundler/PubGrub/SolveFailure.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: Bundler::PubGrub::SolveFailure -**Inherits:** StandardError - - - - -# Attributes -## incompatibility[RW] [](#attribute-i-incompatibility) -Returns the value of attribute incompatibility. - - -#Instance Methods -## explanation() [](#method-i-explanation) - -## initialize(incompatibility) [](#method-i-initialize) - -**@return** [SolveFailure] a new instance of SolveFailure - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/PubGrub/StaticPackageSource.md b/example/ruby/Bundler/PubGrub/StaticPackageSource.md deleted file mode 100644 index 2cb1dd9..0000000 --- a/example/ruby/Bundler/PubGrub/StaticPackageSource.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Bundler::PubGrub::StaticPackageSource -**Inherits:** Bundler::PubGrub::BasicPackageSource - - - - - -#Instance Methods -## all_versions_for(package) [](#method-i-all_versions_for) - -## dependencies_for(package, version) [](#method-i-dependencies_for) - -## initialize() [](#method-i-initialize) - -**@return** [StaticPackageSource] a new instance of StaticPackageSource - -**@yield** [DSL.new(@packages, @root_deps)] - -## parse_dependency(package, dependency) [](#method-i-parse_dependency) - -## root_dependencies() [](#method-i-root_dependencies) - diff --git a/example/ruby/Bundler/PubGrub/StaticPackageSource/DSL.md b/example/ruby/Bundler/PubGrub/StaticPackageSource/DSL.md deleted file mode 100644 index 7955674..0000000 --- a/example/ruby/Bundler/PubGrub/StaticPackageSource/DSL.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::PubGrub::StaticPackageSource::DSL -**Inherits:** Object - - - - - -#Instance Methods -## add(name, version, deps:{}) [](#method-i-add) - -**@raise** [ArgumentError] - -## initialize(packages, root_deps) [](#method-i-initialize) - -**@return** [DSL] a new instance of DSL - -## root(deps:) [](#method-i-root) - diff --git a/example/ruby/Bundler/PubGrub/Term.md b/example/ruby/Bundler/PubGrub/Term.md deleted file mode 100644 index b7dcacf..0000000 --- a/example/ruby/Bundler/PubGrub/Term.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: Bundler::PubGrub::Term -**Inherits:** Object - - - - -# Attributes -## constraint[RW] [](#attribute-i-constraint) -Returns the value of attribute constraint. - -## package[RW] [](#attribute-i-package) -Returns the value of attribute package. - -## positive[RW] [](#attribute-i-positive) -Returns the value of attribute positive. - - -#Instance Methods -## difference(other) [](#method-i-difference) - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(constraint, positive) [](#method-i-initialize) - -**@return** [Term] a new instance of Term - -## inspect() [](#method-i-inspect) - -## intersect(other) [](#method-i-intersect) - -**@raise** [ArgumentError] - -## invert() [](#method-i-invert) - -## negative?() [](#method-i-negative?) - -**@return** [Boolean] - -## normalized_constraint() [](#method-i-normalized_constraint) - -## positive?() [](#method-i-positive?) - -**@return** [Boolean] - -## relation(other) [](#method-i-relation) - -## satisfies?(other) [](#method-i-satisfies?) - -**@raise** [ArgumentError] - -**@return** [Boolean] - -## to_s(allow_every:false) [](#method-i-to_s) - diff --git a/example/ruby/Bundler/PubGrub/VersionConstraint.md b/example/ruby/Bundler/PubGrub/VersionConstraint.md deleted file mode 100644 index 34767c1..0000000 --- a/example/ruby/Bundler/PubGrub/VersionConstraint.md +++ /dev/null @@ -1,80 +0,0 @@ -# Class: Bundler::PubGrub::VersionConstraint -**Inherits:** Object - - - - -# Class Methods -## any(package ) [](#method-c-any) -## empty(package ) [](#method-c-empty) -## exact(package , version ) [](#method-c-exact) -# Attributes -## package[RW] [](#attribute-i-package) -Returns the value of attribute package. - -## range[RW] [](#attribute-i-range) -Returns the value of attribute range. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## allows_all?(other) [](#method-i-allows_all?) - -**@return** [Boolean] - -## allows_any?(other) [](#method-i-allows_any?) - -**@return** [Boolean] - -## any?() [](#method-i-any?) -Does this match every version of the package - -**@return** [Boolean] - -## constraint_string() [](#method-i-constraint_string) - -## difference(other) [](#method-i-difference) - -## disjoint?(other) [](#method-i-disjoint?) - -**@return** [Boolean] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(package, range:nil) [](#method-i-initialize) - -**@param** [Bundler::PubGrub::Package] - -**@param** [Bundler::PubGrub::VersionRange] - -**@return** [VersionConstraint] a new instance of VersionConstraint - -## inspect() [](#method-i-inspect) - -## intersect(other) [](#method-i-intersect) - -## invert() [](#method-i-invert) - -## overlap?(other) [](#method-i-overlap?) - -**@return** [Boolean] - -## relation(other) [](#method-i-relation) - -## subset?(other) [](#method-i-subset?) - -**@return** [Boolean] - -## to_s(allow_every:false) [](#method-i-to_s) - -## union(other) [](#method-i-union) - diff --git a/example/ruby/Bundler/PubGrub/VersionRange.md b/example/ruby/Bundler/PubGrub/VersionRange.md deleted file mode 100644 index 36ebcdd..0000000 --- a/example/ruby/Bundler/PubGrub/VersionRange.md +++ /dev/null @@ -1,100 +0,0 @@ -# Class: Bundler::PubGrub::VersionRange -**Inherits:** Object - - - - -# Class Methods -## any() [](#method-c-any) -## empty() [](#method-c-empty) -# Attributes -## include_max[RW] [](#attribute-i-include_max) -Returns the value of attribute include_max. - -## include_min[RW] [](#attribute-i-include_min) -Returns the value of attribute include_min. - -## max[RW] [](#attribute-i-max) -Returns the value of attribute max. - -## min[RW] [](#attribute-i-min) -Returns the value of attribute min. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## allows_all?(other) [](#method-i-allows_all?) - -**@return** [Boolean] - -## any?() [](#method-i-any?) - -**@return** [Boolean] - -## compare_version(version) [](#method-i-compare_version) - -## contiguous_to?(other) [](#method-i-contiguous_to?) - -**@return** [Boolean] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## include?(version) [](#method-i-include?) - -**@return** [Boolean] - -## initialize(min:nil, max:nil, include_min:false, include_max:false, name:nil) [](#method-i-initialize) - -**@return** [VersionRange] a new instance of VersionRange - -## inspect() [](#method-i-inspect) - -## intersect(other) [](#method-i-intersect) - -## intersects?(other) [](#method-i-intersects?) - -**@return** [Boolean] - -## invert() [](#method-i-invert) - -## partition_versions(versions) [](#method-i-partition_versions) -Partitions passed versions into [lower, within, higher] - -versions must be sorted - -## ranges() [](#method-i-ranges) - -## select_versions(versions) [](#method-i-select_versions) -Returns versions which are included by this range. - -versions must be sorted - -## span(other) [](#method-i-span) -The span covered by two ranges - -If self and other are contiguous, this builds a union of the two ranges. (if -they aren't you are probably calling the wrong method) - -## strictly_higher?(other) [](#method-i-strictly_higher?) - -**@return** [Boolean] - -## strictly_lower?(other) [](#method-i-strictly_lower?) - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) - -## union(other) [](#method-i-union) - -## upper_invert() [](#method-i-upper_invert) - diff --git a/example/ruby/Bundler/PubGrub/VersionRange/Empty.md b/example/ruby/Bundler/PubGrub/VersionRange/Empty.md deleted file mode 100644 index 1b83db6..0000000 --- a/example/ruby/Bundler/PubGrub/VersionRange/Empty.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Bundler::PubGrub::VersionRange::Empty -**Inherits:** Bundler::PubGrub::VersionRange - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## allows_all?(other) [](#method-i-allows_all?) - -**@return** [Boolean] - -## any?() [](#method-i-any?) - -**@return** [Boolean] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## include?(_) [](#method-i-include?) - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [Empty] a new instance of Empty - -## intersect(other) [](#method-i-intersect) - -## intersects?(_) [](#method-i-intersects?) - -**@return** [Boolean] - -## invert() [](#method-i-invert) - -## select_versions(_) [](#method-i-select_versions) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/PubGrub/VersionSolver.md b/example/ruby/Bundler/PubGrub/VersionSolver.md deleted file mode 100644 index 9cee7aa..0000000 --- a/example/ruby/Bundler/PubGrub/VersionSolver.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Bundler::PubGrub::VersionSolver -**Inherits:** Object - - - - -# Attributes -## logger[RW] [](#attribute-i-logger) -Returns the value of attribute logger. - -## solution[RW] [](#attribute-i-solution) -Returns the value of attribute solution. - -## source[RW] [](#attribute-i-source) -Returns the value of attribute source. - - -#Instance Methods -## initialize(source:, root:Package.root, logger:Bundler::PubGrub.logger) [](#method-i-initialize) - -**@return** [VersionSolver] a new instance of VersionSolver - -## solve() [](#method-i-solve) - -## solved?() [](#method-i-solved?) - -**@return** [Boolean] - -## work() [](#method-i-work) -Returns true if there is more work to be done, false otherwise - diff --git a/example/ruby/Bundler/PubGrub/VersionUnion.md b/example/ruby/Bundler/PubGrub/VersionUnion.md deleted file mode 100644 index 91c534e..0000000 --- a/example/ruby/Bundler/PubGrub/VersionUnion.md +++ /dev/null @@ -1,63 +0,0 @@ -# Class: Bundler::PubGrub::VersionUnion -**Inherits:** Object - - - - -# Class Methods -## normalize_ranges(ranges ) [](#method-c-normalize_ranges) -## union(ranges , normalize: true) [](#method-c-union) -# Attributes -## ranges[RW] [](#attribute-i-ranges) -Returns the value of attribute ranges. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## allows_all?(other) [](#method-i-allows_all?) - -**@return** [Boolean] - -## any?() [](#method-i-any?) - -**@return** [Boolean] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## include?(version) [](#method-i-include?) - -**@return** [Boolean] - -## initialize(ranges) [](#method-i-initialize) - -**@raise** [ArgumentError] - -**@return** [VersionUnion] a new instance of VersionUnion - -## inspect() [](#method-i-inspect) - -## intersect(other) [](#method-i-intersect) - -## intersects?(other) [](#method-i-intersects?) - -**@return** [Boolean] - -## invert() [](#method-i-invert) - -## select_versions(all_versions) [](#method-i-select_versions) - -## to_s() [](#method-i-to_s) - -## union(other) [](#method-i-union) - -## upper_invert() [](#method-i-upper_invert) - diff --git a/example/ruby/Bundler/RemoteSpecification.md b/example/ruby/Bundler/RemoteSpecification.md deleted file mode 100644 index a9f2067..0000000 --- a/example/ruby/Bundler/RemoteSpecification.md +++ /dev/null @@ -1,179 +0,0 @@ -# Class: Bundler::RemoteSpecification -**Inherits:** Object - -**Includes:** Bundler::MatchPlatform, Bundler::MatchRemoteMetadata, Comparable - - -Represents a lazily loaded gem specification, where the full specification is -on the source server in rubygems' "quick" index. The proxy object is to be -seeded with what we're given from the source's abbreviated index - the full -specification will only be fetched when necessary. - - -# Attributes -## dependencies[RW] [](#attribute-i-dependencies) - -## locked_platform[RW] [](#attribute-i-locked_platform) -Returns the value of attribute locked_platform. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## platform[RW] [](#attribute-i-platform) -Returns the value of attribute platform. - -## remote[RW] [](#attribute-i-remote) -Returns the value of attribute remote. - -## source[RW] [](#attribute-i-source) -Returns the value of attribute source. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Compare this specification against another object. Using sort_obj is -compatible with Gem::Specification and other Bundler or RubyGems objects. -Otherwise, use the default Object comparison. - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## __swap__(spec) [](#method-i-__swap__) -Because Rubyforge cannot be trusted to provide valid specifications once the -remote gem is downloaded, the backend specification will be swapped out. - -**@raise** [APIResponseInvalidDependenciesError] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## fetch_platform() [](#method-i-fetch_platform) -Needed before installs, since the arch matters then and quick specs don't -bother to include the arch in the platform string - -## full_name() [](#method-i-full_name) - -## git_version() [](#method-i-git_version) - -## initialize(name, version, platform, spec_fetcher) [](#method-i-initialize) - -**@return** [RemoteSpecification] a new instance of RemoteSpecification - -## insecurely_materialized?() [](#method-i-insecurely_materialized?) - -**@return** [Boolean] - -## match_platform(p) [](#method-i-match_platform) - -## matches_current_metadata?() [](#method-i-matches_current_metadata?) - -**@return** [Boolean] - -## matches_current_ruby?() [](#method-i-matches_current_ruby?) - -**@return** [Boolean] - -## matches_current_rubygems?() [](#method-i-matches_current_rubygems?) - -**@return** [Boolean] - -## respond_to?(method, include_allfalse) [](#method-i-respond_to?) - -**@return** [Boolean] - -## runtime_dependencies() [](#method-i-runtime_dependencies) - -## sort_obj() [](#method-i-sort_obj) -Create a delegate used for sorting. This strategy is copied from RubyGems 2.23 -and ensures that Bundler's specifications can be compared and sorted with -RubyGems' own specifications. - -**@return** [Array] an object you can use to compare and sort this -specification against other specifications - -**@see** [] - -**@see** [] - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/Resolver.md b/example/ruby/Bundler/Resolver.md deleted file mode 100644 index 426effd..0000000 --- a/example/ruby/Bundler/Resolver.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: Bundler::Resolver -**Inherits:** Object - -**Includes:** Bundler::GemHelpers - - -This class implements the interface needed by PubGrub for resolution. It is -equivalent to the `PubGrub::BasicPackageSource` class provided by PubGrub by -default and used by the most simple PubGrub consumers. - - - -#Instance Methods -## all_versions_for(package) [](#method-i-all_versions_for) - -## bundler_pinned_to_current_version?() [](#method-i-bundler_pinned_to_current_version?) - -**@return** [Boolean] - -## debug?() [](#method-i-debug?) - -**@return** [Boolean] - -## default_bundler_source() [](#method-i-default_bundler_source) - -## find_names_to_relax(incompatibility) [](#method-i-find_names_to_relax) - -## incompatibilities_for(package, version) [](#method-i-incompatibilities_for) - -## initialize(base, gem_version_promoter, most_specific_locked_platformnil) [](#method-i-initialize) - -**@return** [Resolver] a new instance of Resolver - -## name_for_explicit_dependency_source() [](#method-i-name_for_explicit_dependency_source) - -## no_versions_incompatibility_for(package, unsatisfied_term) [](#method-i-no_versions_incompatibility_for) - -## parse_dependency(package, dependency) [](#method-i-parse_dependency) - -## raise_not_found!(package) [](#method-i-raise_not_found!) - -**@raise** [GemNotFound] - -## setup_solver() [](#method-i-setup_solver) - -## solve_versions(root:, logger:) [](#method-i-solve_versions) - -## source_for(name) [](#method-i-source_for) - -## start() [](#method-i-start) - -## versions_for(package, rangeVersionRange.any) [](#method-i-versions_for) - diff --git a/example/ruby/Bundler/Resolver/Base.md b/example/ruby/Bundler/Resolver/Base.md deleted file mode 100644 index 2ba1f67..0000000 --- a/example/ruby/Bundler/Resolver/Base.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Bundler::Resolver::Base -**Inherits:** Object - - - - -# Attributes -## packages[RW] [](#attribute-i-packages) -Returns the value of attribute packages. - -## requirements[RW] [](#attribute-i-requirements) -Returns the value of attribute requirements. - -## source_requirements[RW] [](#attribute-i-source_requirements) -Returns the value of attribute source_requirements. - - -#Instance Methods -## [](name) [](#method-i-[]) - -## base_requirements() [](#method-i-base_requirements) - -## delete(specs) [](#method-i-delete) - -## get_package(name) [](#method-i-get_package) - -## include_prereleases(names) [](#method-i-include_prereleases) - -## include_remote_specs(names) [](#method-i-include_remote_specs) - -## initialize(source_requirements, dependencies, base, platforms, options) [](#method-i-initialize) - -**@return** [Base] a new instance of Base - -## unlock_names(names) [](#method-i-unlock_names) - diff --git a/example/ruby/Bundler/Resolver/Candidate.md b/example/ruby/Bundler/Resolver/Candidate.md deleted file mode 100644 index bc3b0ae..0000000 --- a/example/ruby/Bundler/Resolver/Candidate.md +++ /dev/null @@ -1,132 +0,0 @@ -# Class: Bundler::Resolver::Candidate -**Inherits:** Object - -**Includes:** Comparable - - -This class is a PubGrub compatible "Version" class that takes Bundler -resolution complexities into account. - -Each Resolver::Candidate has a underlying `Gem::Version` plus a set of -platforms. For example, 1.1.0-x86_64-linux is a different resolution candidate -from 1.1.0 (generic). This is because different platform variants of the same -gem version can bring different dependencies, so they need to be considered -separately. - -Some candidates may also keep some information explicitly about the package -they refer to. These candidates are referred to as "canonical" and are used -when materializing resolution results back into RubyGems specifications that -can be installed, written to lock files, and so on. - - -# Attributes -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## ==(other) [](#method-i-==) - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## dependencies() [](#method-i-dependencies) - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(version, group:nil, priority:-1)) [](#method-i-initialize) - -**@return** [Candidate] a new instance of Candidate - -## prerelease?() [](#method-i-prerelease?) - -**@return** [Boolean] - -## segments() [](#method-i-segments) - -## sort_obj() [](#method-i-sort_obj) - -## to_s() [](#method-i-to_s) - -## to_specs(package, most_specific_locked_platform) [](#method-i-to_specs) - diff --git a/example/ruby/Bundler/Resolver/Incompatibility.md b/example/ruby/Bundler/Resolver/Incompatibility.md deleted file mode 100644 index 75bd085..0000000 --- a/example/ruby/Bundler/Resolver/Incompatibility.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bundler::Resolver::Incompatibility -**Inherits:** Bundler::PubGrub::Incompatibility - - - - -# Attributes -## extended_explanation[RW] [](#attribute-i-extended_explanation) -Returns the value of attribute extended_explanation. - - -#Instance Methods -## initialize(terms, cause:, custom_explanation:nil, extended_explanation:nil) [](#method-i-initialize) - -**@return** [Incompatibility] a new instance of Incompatibility - diff --git a/example/ruby/Bundler/Resolver/Package.md b/example/ruby/Bundler/Resolver/Package.md deleted file mode 100644 index 611f7d3..0000000 --- a/example/ruby/Bundler/Resolver/Package.md +++ /dev/null @@ -1,81 +0,0 @@ -# Class: Bundler::Resolver::Package -**Inherits:** Object - - -Represents a gem being resolved, in a format PubGrub likes. - -The class holds the following information: - -* Platforms this gem will be resolved on. -* The locked version of this gem resolution should favor (if any). -* Whether the gem should be unlocked to its latest version. -* The dependency explicit set in the Gemfile for this gem (if any). - - -# Attributes -## dependency[RW] [](#attribute-i-dependency) -Returns the value of attribute dependency. - -## locked_version[RW] [](#attribute-i-locked_version) -Returns the value of attribute locked_version. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## platforms[RW] [](#attribute-i-platforms) -Returns the value of attribute platforms. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## consider_prereleases!() [](#method-i-consider_prereleases!) - -## consider_remote_versions!() [](#method-i-consider_remote_versions!) - -## current_platform?() [](#method-i-current_platform?) - -**@return** [Boolean] - -## force_ruby_platform?() [](#method-i-force_ruby_platform?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## ignores_prereleases?() [](#method-i-ignores_prereleases?) - -**@return** [Boolean] - -## initialize(name, platforms, locked_specs:, unlock:, prerelease:false, prefer_local:false, dependency:nil) [](#method-i-initialize) - -**@return** [Package] a new instance of Package - -## meta?() [](#method-i-meta?) - -**@return** [Boolean] - -## platform_specs(specs) [](#method-i-platform_specs) - -## prefer_local?() [](#method-i-prefer_local?) - -**@return** [Boolean] - -## prerelease_specified?() [](#method-i-prerelease_specified?) - -**@return** [Boolean] - -## root?() [](#method-i-root?) - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) - -## top_level?() [](#method-i-top_level?) - -**@return** [Boolean] - -## unlock?() [](#method-i-unlock?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/Resolver/Root.md b/example/ruby/Bundler/Resolver/Root.md deleted file mode 100644 index 7a7ef2d..0000000 --- a/example/ruby/Bundler/Resolver/Root.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Bundler::Resolver::Root -**Inherits:** Bundler::Resolver::Package - - -Represents the Gemfile from the resolver's perspective. It's the root package -and Gemfile entries depend on it. - - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [Root] a new instance of Root - -## meta?() [](#method-i-meta?) - -**@return** [Boolean] - -## root?() [](#method-i-root?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/Resolver/SpecGroup.md b/example/ruby/Bundler/Resolver/SpecGroup.md deleted file mode 100644 index a0aaa7a..0000000 --- a/example/ruby/Bundler/Resolver/SpecGroup.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Bundler::Resolver::SpecGroup -**Inherits:** Object - - - - -# Attributes -## specs[RW] [](#attribute-i-specs) -Returns the value of attribute specs. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## dependencies() [](#method-i-dependencies) - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## initialize(specs) [](#method-i-initialize) - -**@return** [SpecGroup] a new instance of SpecGroup - -## merge(other) [](#method-i-merge) - -## name() [](#method-i-name) - -## source() [](#method-i-source) - -## to_s() [](#method-i-to_s) - -## to_specs(force_ruby_platform, most_specific_locked_platform) [](#method-i-to_specs) - -## version() [](#method-i-version) - diff --git a/example/ruby/Bundler/Retry.md b/example/ruby/Bundler/Retry.md deleted file mode 100644 index b2dc96d..0000000 --- a/example/ruby/Bundler/Retry.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Bundler::Retry -**Inherits:** Object - - -General purpose class for retrying code that may fail - - -# Class Methods -## default_attempts() [](#method-c-default_attempts) -## default_retries() [](#method-c-default_retries) -# Attributes -## current_run[RW] [](#attribute-i-current_run) -Returns the value of attribute current_run. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## total_runs[RW] [](#attribute-i-total_runs) -Returns the value of attribute total_runs. - - -#Instance Methods -## attempt(&block) [](#method-i-attempt) - -## initialize(name, exceptionsnil, retriesself.class.default_retries) [](#method-i-initialize) - -**@return** [Retry] a new instance of Retry - diff --git a/example/ruby/Bundler/RubyDsl.md b/example/ruby/Bundler/RubyDsl.md deleted file mode 100644 index d281052..0000000 --- a/example/ruby/Bundler/RubyDsl.md +++ /dev/null @@ -1,26 +0,0 @@ -# Module: Bundler::RubyDsl - - - - - -#Instance Methods -## normalize_ruby_file(filename) [](#method-i-normalize_ruby_file) -Support the various file formats found in .ruby-version files. - - 3.2.2 - ruby-3.2.2 - -Also supports .tool-versions files for asdf. Lines not starting with "ruby" -are ignored. - - ruby 2.5.1 # comment is ignored - ruby 2.5.1# close comment and extra spaces doesn't confuse - -Intentionally does not support `3.2.1@gemset` since rvm recommends using -.ruby-gemset instead - -Loads the file relative to the dirname of the Gemfile itself. - -## ruby(*ruby_version) [](#method-i-ruby) - diff --git a/example/ruby/Bundler/RubyGemsGemInstaller.md b/example/ruby/Bundler/RubyGemsGemInstaller.md deleted file mode 100644 index 15ed2fc..0000000 --- a/example/ruby/Bundler/RubyGemsGemInstaller.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Bundler::RubyGemsGemInstaller -**Inherits:** Gem::Installer - - - - - -#Instance Methods -## build_extensions() [](#method-i-build_extensions) - -## check_executable_overwrite(filename) [](#method-i-check_executable_overwrite) - -## ensure_writable_dir(dir) [](#method-i-ensure_writable_dir) - -## gem_checksum() [](#method-i-gem_checksum) - -## generate_bin_script(filename, bindir) [](#method-i-generate_bin_script) - -## generate_plugins() [](#method-i-generate_plugins) - -## install() [](#method-i-install) - -## pre_install_checks() [](#method-i-pre_install_checks) - -## spec() [](#method-i-spec) - diff --git a/example/ruby/Bundler/RubyVersion.md b/example/ruby/Bundler/RubyVersion.md deleted file mode 100644 index 46077be..0000000 --- a/example/ruby/Bundler/RubyVersion.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: Bundler::RubyVersion -**Inherits:** Object - - - - -# Class Methods -## from_string(string ) [](#method-c-from_string) -Returns a RubyVersion from the given string. -**@param** [String] version string to match. - -**@return** [RubyVersion, Nil] The version if the string is a valid RubyVersion -description, and nil otherwise. - -## system() [](#method-c-system) -# Attributes -## engine[RW] [](#attribute-i-engine) -Returns the value of attribute engine. - -## engine_gem_version[RW] [](#attribute-i-engine_gem_version) -Returns the value of attribute engine_gem_version. - -## engine_versions[RW] [](#attribute-i-engine_versions) -Returns the value of attribute engine_versions. - -## gem_version[RW] [](#attribute-i-gem_version) -Returns the value of attribute gem_version. - -## patchlevel[RW] [](#attribute-i-patchlevel) -Returns the value of attribute patchlevel. - -## versions[RW] [](#attribute-i-versions) -Returns the value of attribute versions. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## diff(other) [](#method-i-diff) -Returns a tuple of these things: - [diff, this, other] - The priority of attributes are - 1. engine - 2. ruby_version - 3. engine_version - -**@raise** [ArgumentError] - -## host() [](#method-i-host) - -## initialize(versions, patchlevel, engine, engine_version) [](#method-i-initialize) - -**@return** [RubyVersion] a new instance of RubyVersion - -## single_version_string() [](#method-i-single_version_string) - -## to_s(versionsself.versions) [](#method-i-to_s) - -## versions_string(versions) [](#method-i-versions_string) - diff --git a/example/ruby/Bundler/RubyVersionMismatch.md b/example/ruby/Bundler/RubyVersionMismatch.md deleted file mode 100644 index 1fa7e65..0000000 --- a/example/ruby/Bundler/RubyVersionMismatch.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::RubyVersionMismatch -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/RubygemsIntegration.md b/example/ruby/Bundler/RubygemsIntegration.md deleted file mode 100644 index f4e38f4..0000000 --- a/example/ruby/Bundler/RubygemsIntegration.md +++ /dev/null @@ -1,132 +0,0 @@ -# Class: Bundler::RubygemsIntegration -**Inherits:** Object - - - - - -#Instance Methods -## add_default_gems_to(specs) [](#method-i-add_default_gems_to) -Add default gems not already present in specs, and return them as a hash. - -## all_specs() [](#method-i-all_specs) - -## bin_path(gem, bin, ver) [](#method-i-bin_path) - -## build(spec, skip_validationfalse) [](#method-i-build) - -## build_args() [](#method-i-build_args) - -## build_args=(args) [](#method-i-build_args=) - -## build_gem(gem_dir, spec) [](#method-i-build_gem) - -## clear_paths() [](#method-i-clear_paths) - -## default_specs() [](#method-i-default_specs) - -## default_stubs() [](#method-i-default_stubs) - -## download_gem(spec, uri, cache_dir, fetcher) [](#method-i-download_gem) - -## ext_lock() [](#method-i-ext_lock) - -## fetch_all_remote_specs(remote, gem_remote_fetcher) [](#method-i-fetch_all_remote_specs) - -## fetch_specs(remote, name, fetcher) [](#method-i-fetch_specs) - -## find_bundler(version) [](#method-i-find_bundler) - -## find_name(name) [](#method-i-find_name) - -## gem_bindir() [](#method-i-gem_bindir) - -## gem_cache() [](#method-i-gem_cache) - -## gem_dir() [](#method-i-gem_dir) - -## gem_path() [](#method-i-gem_path) - -## inflate(obj) [](#method-i-inflate) - -## initialize() [](#method-i-initialize) - -**@return** [RubygemsIntegration] a new instance of RubygemsIntegration - -## installed_specs() [](#method-i-installed_specs) - -## load_env_plugins() [](#method-i-load_env_plugins) - -## load_plugin_files(plugin_files) [](#method-i-load_plugin_files) - -## load_plugins() [](#method-i-load_plugins) - -## loaded_gem_paths() [](#method-i-loaded_gem_paths) - -## loaded_specs(name) [](#method-i-loaded_specs) - -## mark_loaded(spec) [](#method-i-mark_loaded) - -## marshal_spec_dir() [](#method-i-marshal_spec_dir) - -## method_visibility(klass, method) [](#method-i-method_visibility) - -## path(obj) [](#method-i-path) - -## path_separator() [](#method-i-path_separator) - -## plain_specs() [](#method-i-plain_specs) - -## plain_specs=(specs) [](#method-i-plain_specs=) - -## post_reset_hooks() [](#method-i-post_reset_hooks) - -## provides?(req_str) [](#method-i-provides?) - -**@return** [Boolean] - -## read_binary(path) [](#method-i-read_binary) - -## redefine_method(klass, method, unbound_methodnil, &block) [](#method-i-redefine_method) - -## replace_bin_path(specs_by_name) [](#method-i-replace_bin_path) -Used to give better error messages when activating specs outside of the -current bundle - -## replace_entrypoints(specs) [](#method-i-replace_entrypoints) -Replace or hook into RubyGems to provide a bundlerized view of the world. - -## replace_gem(specs, specs_by_name) [](#method-i-replace_gem) - -## reset() [](#method-i-reset) - -## reverse_rubygems_kernel_mixin() [](#method-i-reverse_rubygems_kernel_mixin) - -## ruby_engine() [](#method-i-ruby_engine) - -## security_policies() [](#method-i-security_policies) - -## security_policy_keys() [](#method-i-security_policy_keys) - -## set_target_rbconfig(path) [](#method-i-set_target_rbconfig) - -## spec_cache_dirs() [](#method-i-spec_cache_dirs) - -## spec_from_gem(path) [](#method-i-spec_from_gem) - -## stub_rubygems(specs) [](#method-i-stub_rubygems) - -## stub_set_spec(stub, spec) [](#method-i-stub_set_spec) - -## suffix_pattern() [](#method-i-suffix_pattern) - -## ui=(obj) [](#method-i-ui=) - -## undo_replacements() [](#method-i-undo_replacements) - -## user_home() [](#method-i-user_home) - -## validate(spec) [](#method-i-validate) - -## version() [](#method-i-version) - diff --git a/example/ruby/Bundler/Runtime.md b/example/ruby/Bundler/Runtime.md deleted file mode 100644 index 3f43a91..0000000 --- a/example/ruby/Bundler/Runtime.md +++ /dev/null @@ -1,109 +0,0 @@ -# Class: Bundler::Runtime -**Inherits:** Object - -**Includes:** Bundler::SharedHelpers - - - - - -#Instance Methods -## bundle_bin_path() [](#method-i-bundle_bin_path) - -## cache(custom_pathnil, localfalse) [](#method-i-cache) - -## chdir(dir, &blk) [](#method-i-chdir) - -## checksum_for_file(path, digest) [](#method-i-checksum_for_file) - -## clean(dry_runfalse) [](#method-i-clean) - -## default_bundle_dir() [](#method-i-default_bundle_dir) - -## default_gemfile() [](#method-i-default_gemfile) - -**@raise** [GemfileNotFound] - -## default_lockfile() [](#method-i-default_lockfile) - -## digest(name) [](#method-i-digest) - -## ensure_same_dependencies(spec, old_deps, new_deps) [](#method-i-ensure_same_dependencies) - -**@raise** [APIResponseMismatchError] - -## filesystem_access(path, action:write, &block) [](#method-i-filesystem_access) -Rescues permissions errors raised by file system operations (ie. -Errno:EACCESS, Errno::EAGAIN) and raises more friendly errors instead. - -**@param** [String] the path that the action will be attempted to - -**@param** [Symbol, #to_s] the type of operation that will be -performed. For example: :write, :read, :exec - -**@raise** [Bundler::PermissionError] if Errno:EACCES is raised in the -given block - -**@raise** [Bundler::TemporaryResourceError] if Errno:EAGAIN is raised in the -given block - -**@see** [] - -**@yield** [] path - - -**@example** -```ruby -filesystem_access("vendor/cache", :create) do - FileUtils.mkdir_p("vendor/cache") -end -```## gemspec_path() [](#method-i-gemspec_path) - -## in_bundle?() [](#method-i-in_bundle?) - -**@return** [Boolean] - -## initialize(root, definition) [](#method-i-initialize) - -**@return** [Runtime] a new instance of Runtime - -## lock(opts{}) [](#method-i-lock) - -## major_deprecation(major_version, message, removed_message:nil, print_caller_location:false) [](#method-i-major_deprecation) - -## md5_available?() [](#method-i-md5_available?) - -**@return** [Boolean] - -## pretty_dependency(dep) [](#method-i-pretty_dependency) - -## print_major_deprecations!() [](#method-i-print_major_deprecations!) - -## prune_cache(cache_path) [](#method-i-prune_cache) - -## pwd() [](#method-i-pwd) - -## relative_gemfile_path() [](#method-i-relative_gemfile_path) - -## relative_lockfile_path() [](#method-i-relative_lockfile_path) - -## relative_path_to(destination, from:pwd) [](#method-i-relative_path_to) - -## require(*groups) [](#method-i-require) - -## root() [](#method-i-root) - -**@raise** [GemfileNotFound] - -## set_bundle_environment() [](#method-i-set_bundle_environment) - -## set_env(key, value) [](#method-i-set_env) - -**@raise** [ArgumentError] - -## setup(*groups) [](#method-i-setup) - -## with_clean_git_env(&block) [](#method-i-with_clean_git_env) - -## write_to_gemfile(gemfile_path, contents) [](#method-i-write_to_gemfile) - diff --git a/example/ruby/Bundler/SafeMarshal.md b/example/ruby/Bundler/SafeMarshal.md deleted file mode 100644 index d3f40fc..0000000 --- a/example/ruby/Bundler/SafeMarshal.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: Bundler::SafeMarshal - - - - -# Class Methods -## proc() [](#method-c-proc) - diff --git a/example/ruby/Bundler/SecureRandom.md b/example/ruby/Bundler/SecureRandom.md deleted file mode 100644 index 291b0ad..0000000 --- a/example/ruby/Bundler/SecureRandom.md +++ /dev/null @@ -1,266 +0,0 @@ -# Module: Bundler::SecureRandom - -**Extended by:** Random::Formatter - - -## Secure random number generator interface. - -This library is an interface to secure random number generators which are -suitable for generating session keys in HTTP cookies, etc. - -You can use this library in your application by requiring it: - - require 'bundler/vendor/securerandom/lib/securerandom' - -It supports the following secure random number generators: - -* openssl -* /dev/urandom -* Win32 - -Bundler::SecureRandom is extended by the Random::Formatter module which -defines the following methods: - -* alphanumeric -* base64 -* choose -* gen_random -* hex -* rand -* random_bytes -* random_number -* urlsafe_base64 -* uuid - -These methods are usable as class methods of Bundler::SecureRandom such as -`Bundler::SecureRandom.hex`. - -If a secure random number generator is not available, `NotImplementedError` is -raised. - - -# Class Methods -## alphanumeric(n nil, chars: ALPHANUMERIC) [](#method-c-alphanumeric) -Generate a random alphanumeric string. - -The argument *n* specifies the length, in characters, of the alphanumeric -string to be generated. The argument *chars* specifies the character list -which the result is consist of. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain A-Z, a-z and 0-9, unless *chars* is specified. - - require 'random/formatter' - - Random.alphanumeric #=> "2BuBuLf3WfSKyQbR" - # or - prng = Random.new - prng.alphanumeric(10) #=> "i6K93NdqiH" - - Random.alphanumeric(4, chars: [*"0".."9"]) #=> "2952" - # or - prng = Random.new - prng.alphanumeric(10, chars: [*"!".."/"]) #=> ",.,++%/''." -## base64(n nil) [](#method-c-base64) -Generate a random base64 string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the result string is about 4/3 of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain A-Z, a-z, 0-9, "+", "/" and "=". - - require 'random/formatter' - - Random.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A==" - # or - prng = Random.new - prng.base64 #=> "6BbW0pxO0YENxn38HMUbcQ==" - -See RFC 3548 for the definition of base64. -## bytes(n ) [](#method-c-bytes) -Returns a random binary string containing `size` bytes. - -See Random.bytes -## hex(n nil) [](#method-c-hex) -Generate a random hexadecimal string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the resulting hexadecimal string is twice of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain 0-9 and a-f. - - require 'random/formatter' - - Random.hex #=> "eb693ec8252cd630102fd0d0fb7c3485" - # or - prng = Random.new - prng.hex #=> "91dc3bfb4de5b11d029d376634589b61" -## rand(*args ) [](#method-c-rand) -Generates formatted random number from raw random bytes. See Random#rand. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## random_bytes(n nil) [](#method-c-random_bytes) -Generate a random binary string. - -The argument *n* specifies the length of the result string. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in future. - -The result may contain any byte: "x00" - "xff". - - require 'random/formatter' - - Random.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6" - # or - prng = Random.new - prng.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97" -## random_number(*args ) [](#method-c-random_number) -Generates formatted random number from raw random bytes. See Random#rand. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## urlsafe_base64(n nil, padding false) [](#method-c-urlsafe_base64) -Generate a random URL-safe base64 string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the result string is about 4/3 of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The boolean argument *padding* specifies the padding. If it is false or nil, -padding is not generated. Otherwise padding is generated. By default, padding -is not generated because "=" may be used as a URL delimiter. - -The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if -*padding* is true. - - require 'random/formatter' - - Random.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg" - # or - prng = Random.new - prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg" - - prng.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ==" - prng.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg==" - -See RFC 3548 for the definition of URL-safe base64. -## uuid() [](#method-c-uuid) -Generate a random v4 UUID (Universally Unique IDentifier). - - require 'random/formatter' - - Random.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594" - Random.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab" - # or - prng = Random.new - prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b" - -The version 4 UUID is purely random (except the version). It doesn't contain -meaningful information such as MAC addresses, timestamps, etc. - -The result contains 122 random bits (15.25 random bytes). - -See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv4. -## uuid_v7(extra_timestamp_bits: 0) [](#method-c-uuid_v7) -Generate a random v7 UUID (Universally Unique IDentifier). - - require 'random/formatter' - - Random.uuid_v7 # => "0188d4c3-1311-7f96-85c7-242a7aa58f1e" - Random.uuid_v7 # => "0188d4c3-16fe-744f-86af-38fa04c62bb5" - Random.uuid_v7 # => "0188d4c3-1af8-764f-b049-c204ce0afa23" - Random.uuid_v7 # => "0188d4c3-1e74-7085-b14f-ef6415dc6f31" - # |<--sorted-->| |<----- random ---->| - - # or - prng = Random.new - prng.uuid_v7 # => "0188ca51-5e72-7950-a11d-def7ff977c98" - -The version 7 UUID starts with the least significant 48 bits of a 64 bit Unix -timestamp (milliseconds since the epoch) and fills the remaining bits with -random data, excluding the version and variant bits. - -This allows version 7 UUIDs to be sorted by creation time. Time ordered UUIDs -can be used for better database index locality of newly inserted records, -which may have a significant performance benefit compared to random data -inserts. - -The result contains 74 random bits (9.25 random bytes). - -Note that this method cannot be made reproducible because its output includes -not only random bits but also timestamp. - -See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv7. - -#### Monotonicity - -UUIDv7 has millisecond precision by default, so multiple UUIDs created within -the same millisecond are not issued in monotonically increasing order. To -create UUIDs that are time-ordered with sub-millisecond precision, up to 12 -bits of additional timestamp may added with `extra_timestamp_bits`. The extra -timestamp precision comes at the expense of random bits. Setting -`extra_timestamp_bits: 12` provides ~244ns of precision, but only 62 random -bits (7.75 random bytes). - - prng = Random.new - Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 12) } - # => - ["0188d4c7-13da-74f9-8b53-22a786ffdd5a", - "0188d4c7-13da-753b-83a5-7fb9b2afaeea", - "0188d4c7-13da-754a-88ea-ac0baeedd8db", - "0188d4c7-13da-7557-83e1-7cad9cda0d8d"] - # |<--- sorted --->| |<-- random --->| - - Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 8) } - # => - ["0188d4c7-3333-7a95-850a-de6edb858f7e", - "0188d4c7-3333-7ae8-842e-bc3a8b7d0cf9", # <- out of order - "0188d4c7-3333-7ae2-995a-9f135dc44ead", # <- out of order - "0188d4c7-3333-7af9-87c3-8f612edac82e"] - # |<--- sorted -->||<---- random --->| - -Any rollbacks of the system clock will break monotonicity. UUIDv7 is based on -UTC, which excludes leap seconds and can rollback the clock. To avoid this, -the system clock can synchronize with an NTP server configured to use a "leap -smear" approach. NTP or PTP will also be needed to synchronize across -distributed nodes. - -Counters and other mechanisms for stronger guarantees of monotonicity are not -implemented. Applications with stricter requirements should follow [Section -6.2](https://www.rfc-editor.org/rfc/rfc9562.html#name-monotonicity-and-counter -s) of the specification. - -#Instance Methods -## alphanumeric(nnil, chars:ALPHANUMERIC) [](#method-i-alphanumeric) -Compatibility methods for Ruby 3.2, we can remove this after dropping to -support Ruby 3.2 - diff --git a/example/ruby/Bundler/SecurityError.md b/example/ruby/Bundler/SecurityError.md deleted file mode 100644 index 91e859c..0000000 --- a/example/ruby/Bundler/SecurityError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::SecurityError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/SelfManager.md b/example/ruby/Bundler/SelfManager.md deleted file mode 100644 index 8f39299..0000000 --- a/example/ruby/Bundler/SelfManager.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Bundler::SelfManager -**Inherits:** Object - - -This class handles installing and switching to the version of bundler needed -by an application. - - - -#Instance Methods -## install_locked_bundler_and_restart_with_it_if_needed() [](#method-i-install_locked_bundler_and_restart_with_it_if_needed) - -## restart_with_locked_bundler_if_needed() [](#method-i-restart_with_locked_bundler_if_needed) - -## update_bundler_and_restart_with_it_if_needed(target) [](#method-i-update_bundler_and_restart_with_it_if_needed) - diff --git a/example/ruby/Bundler/Settings.md b/example/ruby/Bundler/Settings.md deleted file mode 100644 index fdb6511..0000000 --- a/example/ruby/Bundler/Settings.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: Bundler::Settings -**Inherits:** Object - - - - - -#Instance Methods -## [](name) [](#method-i-[]) - -## all() [](#method-i-all) - -## app_cache_path() [](#method-i-app_cache_path) - -## credentials_for(uri) [](#method-i-credentials_for) - -## gem_mirrors() [](#method-i-gem_mirrors) - -## ignore_config?() [](#method-i-ignore_config?) - -**@return** [Boolean] - -## initialize(rootnil) [](#method-i-initialize) - -**@return** [Settings] a new instance of Settings - -## key_for(key) [](#method-i-key_for) - -## local_overrides() [](#method-i-local_overrides) - -## locations(key) [](#method-i-locations) - -## mirror_for(uri) [](#method-i-mirror_for) - -## path() [](#method-i-path) -for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems - -## pretty_values_for(exposed_key) [](#method-i-pretty_values_for) - -## processor_count() [](#method-i-processor_count) - -## set_command_option(key, value) [](#method-i-set_command_option) - -## set_command_option_if_given(key, value) [](#method-i-set_command_option_if_given) - -## set_global(key, value) [](#method-i-set_global) - -## set_local(key, value) [](#method-i-set_local) - -## temporary(update) [](#method-i-temporary) - -## validate!() [](#method-i-validate!) - diff --git a/example/ruby/Bundler/Settings/Mirror.md b/example/ruby/Bundler/Settings/Mirror.md deleted file mode 100644 index df2bd8f..0000000 --- a/example/ruby/Bundler/Settings/Mirror.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Bundler::Settings::Mirror -**Inherits:** Object - - -A mirror - -Contains both the uri that should be used as a mirror and the - fallback timeout which will be used for probing if the mirror - replies on time or not. - - -# Attributes -## fallback_timeout[RW] [](#attribute-i-fallback_timeout) -Returns the value of attribute fallback_timeout. - -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(urinil, fallback_timeout0) [](#method-i-initialize) - -**@return** [Mirror] a new instance of Mirror - -## valid?() [](#method-i-valid?) - -**@return** [Boolean] - -## validate!(probenil) [](#method-i-validate!) - diff --git a/example/ruby/Bundler/Settings/MirrorConfig.md b/example/ruby/Bundler/Settings/MirrorConfig.md deleted file mode 100644 index 45cd86f..0000000 --- a/example/ruby/Bundler/Settings/MirrorConfig.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Bundler::Settings::MirrorConfig -**Inherits:** Object - - -Class used to parse one configuration line - -Gets the configuration line and the value. - This object provides a `update_mirror` method - used to setup the given mirror value. - - -# Attributes -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## all?() [](#method-i-all?) - -**@return** [Boolean] - -## initialize(config_line, value) [](#method-i-initialize) - -**@return** [MirrorConfig] a new instance of MirrorConfig - -## update_mirror(mirror) [](#method-i-update_mirror) - diff --git a/example/ruby/Bundler/Settings/Mirrors.md b/example/ruby/Bundler/Settings/Mirrors.md deleted file mode 100644 index e721eb1..0000000 --- a/example/ruby/Bundler/Settings/Mirrors.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Bundler::Settings::Mirrors -**Inherits:** Object - - -Class used to build the mirror set and then find a mirror for a given URI - -**@param** [Prober object, nil] by default a TCPSocketProbe, this object -will be used to probe the mirror address to validate that the mirror replies. - - - -#Instance Methods -## each() [](#method-i-each) - -## for(uri) [](#method-i-for) -Returns a mirror for the given uri. - -Depending on the uri having a valid mirror or not, it may be a - mirror that points to the provided uri - -## initialize(probernil) [](#method-i-initialize) - -**@return** [Mirrors] a new instance of Mirrors - -## parse(key, value) [](#method-i-parse) - diff --git a/example/ruby/Bundler/Settings/Path.md b/example/ruby/Bundler/Settings/Path.md deleted file mode 100644 index 0a686a7..0000000 --- a/example/ruby/Bundler/Settings/Path.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Bundler::Settings::Path -**Inherits:** Struct - - - - -# Attributes -## explicit_path[RW] [](#attribute-i-explicit_path) -Returns the value of attribute explicit_path - -**@return** [Object] the current value of explicit_path - -## system_path[RW] [](#attribute-i-system_path) -Returns the value of attribute system_path - -**@return** [Object] the current value of system_path - - -#Instance Methods -## base_path() [](#method-i-base_path) - -## base_path_relative_to_pwd() [](#method-i-base_path_relative_to_pwd) - -## path() [](#method-i-path) - -## use_system_gems?() [](#method-i-use_system_gems?) - -**@return** [Boolean] - -## validate!() [](#method-i-validate!) - -**@raise** [InvalidOption] - diff --git a/example/ruby/Bundler/Settings/TCPSocketProbe.md b/example/ruby/Bundler/Settings/TCPSocketProbe.md deleted file mode 100644 index 91a2f14..0000000 --- a/example/ruby/Bundler/Settings/TCPSocketProbe.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Bundler::Settings::TCPSocketProbe -**Inherits:** Object - - -Class used for probing TCP availability for a given mirror. - - - -#Instance Methods -## replies?(mirror) [](#method-i-replies?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/Settings/Validator.md b/example/ruby/Bundler/Settings/Validator.md deleted file mode 100644 index 5962d2a..0000000 --- a/example/ruby/Bundler/Settings/Validator.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Bundler::Settings::Validator -**Inherits:** Object - - - - -# Class Methods -## validate!(key , value , settings ) [](#method-c-validate!) - diff --git a/example/ruby/Bundler/Settings/Validator/Rule.md b/example/ruby/Bundler/Settings/Validator/Rule.md deleted file mode 100644 index bc75793..0000000 --- a/example/ruby/Bundler/Settings/Validator/Rule.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Bundler::Settings::Validator::Rule -**Inherits:** Object - - - - -# Attributes -## description[RW] [](#attribute-i-description) -Returns the value of attribute description. - - -#Instance Methods -## fail!(key, value, *reasons) [](#method-i-fail!) - -**@raise** [InvalidOption] - -## initialize(keys, description, &validate) [](#method-i-initialize) - -**@return** [Rule] a new instance of Rule - -## k(key) [](#method-i-k) - -## set(settings, key, value, *reasons) [](#method-i-set) - -## validate!(key, value, settings) [](#method-i-validate!) - diff --git a/example/ruby/Bundler/SharedHelpers.md b/example/ruby/Bundler/SharedHelpers.md deleted file mode 100644 index 5a6f50f..0000000 --- a/example/ruby/Bundler/SharedHelpers.md +++ /dev/null @@ -1,152 +0,0 @@ -# Module: Bundler::SharedHelpers - -**Extended by:** Bundler::SharedHelpers - - - - -# Class Methods -## bundle_bin_path() [](#method-c-bundle_bin_path) -## chdir(dir , &blk ) [](#method-c-chdir) -## checksum_for_file(path , digest ) [](#method-c-checksum_for_file) -## default_bundle_dir() [](#method-c-default_bundle_dir) -## default_gemfile() [](#method-c-default_gemfile) -**@raise** [GemfileNotFound] - -## default_lockfile() [](#method-c-default_lockfile) -## digest(name ) [](#method-c-digest) -## ensure_same_dependencies(spec , old_deps , new_deps ) [](#method-c-ensure_same_dependencies) -**@raise** [APIResponseMismatchError] - -## filesystem_access(path , action :write, &block ) [](#method-c-filesystem_access) -Rescues permissions errors raised by file system operations (ie. -Errno:EACCESS, Errno::EAGAIN) and raises more friendly errors instead. -**@param** [String] the path that the action will be attempted to - -**@param** [Symbol, #to_s] the type of operation that will be -performed. For example: :write, :read, :exec - -**@raise** [Bundler::PermissionError] if Errno:EACCES is raised in the -given block - -**@raise** [Bundler::TemporaryResourceError] if Errno:EAGAIN is raised in the -given block - -**@see** [] - -**@yield** [] path - - -**@example** -```ruby -filesystem_access("vendor/cache", :create) do - FileUtils.mkdir_p("vendor/cache") -end -```## gemspec_path() [](#method-c-gemspec_path) -## in_bundle?() [](#method-c-in_bundle?) -**@return** [Boolean] - -## major_deprecation(major_version , message , removed_message: nil, print_caller_location: false) [](#method-c-major_deprecation) -## md5_available?() [](#method-c-md5_available?) -**@return** [Boolean] - -## pretty_dependency(dep ) [](#method-c-pretty_dependency) -## print_major_deprecations!() [](#method-c-print_major_deprecations!) -## pwd() [](#method-c-pwd) -## relative_gemfile_path() [](#method-c-relative_gemfile_path) -## relative_lockfile_path() [](#method-c-relative_lockfile_path) -## relative_path_to(destination , from: pwd) [](#method-c-relative_path_to) -## root() [](#method-c-root) -**@raise** [GemfileNotFound] - -## set_bundle_environment() [](#method-c-set_bundle_environment) -## set_env(key , value ) [](#method-c-set_env) -**@raise** [ArgumentError] - -## with_clean_git_env(&block ) [](#method-c-with_clean_git_env) -## write_to_gemfile(gemfile_path , contents ) [](#method-c-write_to_gemfile) - -#Instance Methods -## bundle_bin_path() [](#method-i-bundle_bin_path) - -## chdir(dir, &blk) [](#method-i-chdir) - -## checksum_for_file(path, digest) [](#method-i-checksum_for_file) - -## default_bundle_dir() [](#method-i-default_bundle_dir) - -## default_gemfile() [](#method-i-default_gemfile) - -**@raise** [GemfileNotFound] - -## default_lockfile() [](#method-i-default_lockfile) - -## digest(name) [](#method-i-digest) - -## ensure_same_dependencies(spec, old_deps, new_deps) [](#method-i-ensure_same_dependencies) - -**@raise** [APIResponseMismatchError] - -## filesystem_access(path, action:write, &block) [](#method-i-filesystem_access) -Rescues permissions errors raised by file system operations (ie. -Errno:EACCESS, Errno::EAGAIN) and raises more friendly errors instead. - -**@param** [String] the path that the action will be attempted to - -**@param** [Symbol, #to_s] the type of operation that will be -performed. For example: :write, :read, :exec - -**@raise** [Bundler::PermissionError] if Errno:EACCES is raised in the -given block - -**@raise** [Bundler::TemporaryResourceError] if Errno:EAGAIN is raised in the -given block - -**@see** [] - -**@yield** [] path - - -**@example** -```ruby -filesystem_access("vendor/cache", :create) do - FileUtils.mkdir_p("vendor/cache") -end -```## gemspec_path() [](#method-i-gemspec_path) - -## in_bundle?() [](#method-i-in_bundle?) - -**@return** [Boolean] - -## major_deprecation(major_version, message, removed_message:nil, print_caller_location:false) [](#method-i-major_deprecation) - -## md5_available?() [](#method-i-md5_available?) - -**@return** [Boolean] - -## pretty_dependency(dep) [](#method-i-pretty_dependency) - -## print_major_deprecations!() [](#method-i-print_major_deprecations!) - -## pwd() [](#method-i-pwd) - -## relative_gemfile_path() [](#method-i-relative_gemfile_path) - -## relative_lockfile_path() [](#method-i-relative_lockfile_path) - -## relative_path_to(destination, from:pwd) [](#method-i-relative_path_to) - -## root() [](#method-i-root) - -**@raise** [GemfileNotFound] - -## set_bundle_environment() [](#method-i-set_bundle_environment) - -## set_env(key, value) [](#method-i-set_env) - -**@raise** [ArgumentError] - -## with_clean_git_env(&block) [](#method-i-with_clean_git_env) - -## write_to_gemfile(gemfile_path, contents) [](#method-i-write_to_gemfile) - diff --git a/example/ruby/Bundler/SimilarityDetector.md b/example/ruby/Bundler/SimilarityDetector.md deleted file mode 100644 index 7f79ca1..0000000 --- a/example/ruby/Bundler/SimilarityDetector.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Bundler::SimilarityDetector -**Inherits:** Object - - - - - -#Instance Methods -## initialize(corpus) [](#method-i-initialize) -initialize with an array of words to be matched against - -**@return** [SimilarityDetector] a new instance of SimilarityDetector - -## similar_word_list(word, limit3) [](#method-i-similar_word_list) -return the result of 'similar_words', concatenated into a list (eg "a, b, or -c") - -## similar_words(word, limit3) [](#method-i-similar_words) -return an array of words similar to 'word' from the corpus - diff --git a/example/ruby/Bundler/SimilarityDetector/SimilarityScore.md b/example/ruby/Bundler/SimilarityDetector/SimilarityScore.md deleted file mode 100644 index d2092e3..0000000 --- a/example/ruby/Bundler/SimilarityDetector/SimilarityScore.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::SimilarityDetector::SimilarityScore -**Inherits:** Struct - - - - -# Attributes -## distance[RW] [](#attribute-i-distance) -Returns the value of attribute distance - -**@return** [Object] the current value of distance - -## string[RW] [](#attribute-i-string) -Returns the value of attribute string - -**@return** [Object] the current value of string - - diff --git a/example/ruby/Bundler/SocketAddress.md b/example/ruby/Bundler/SocketAddress.md deleted file mode 100644 index 3f36820..0000000 --- a/example/ruby/Bundler/SocketAddress.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Bundler::SocketAddress -**Inherits:** Object - - -Socket address builder. - -Given a socket type, a host and a port, - provides a method to build sockaddr string - - -# Attributes -## host[RW] [](#attribute-i-host) -Returns the value of attribute host. - -## port[RW] [](#attribute-i-port) -Returns the value of attribute port. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## initialize(type, host, port) [](#method-i-initialize) - -**@return** [SocketAddress] a new instance of SocketAddress - -## to_socket_address() [](#method-i-to_socket_address) - diff --git a/example/ruby/Bundler/SolveFailure.md b/example/ruby/Bundler/SolveFailure.md deleted file mode 100644 index e910446..0000000 --- a/example/ruby/Bundler/SolveFailure.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::SolveFailure -**Inherits:** Bundler::BundlerError - - -Internal error, should be rescued - - - diff --git a/example/ruby/Bundler/Source.md b/example/ruby/Bundler/Source.md deleted file mode 100644 index f1e006a..0000000 --- a/example/ruby/Bundler/Source.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: Bundler::Source -**Inherits:** Object - - - - -# Attributes -## checksum_store[RW] [](#attribute-i-checksum_store) -Returns the value of attribute checksum_store. - -## dependency_names[RW] [](#attribute-i-dependency_names) -Returns the value of attribute dependency_names. - - -#Instance Methods -## add_dependency_names(names) [](#method-i-add_dependency_names) - -## cached!() [](#method-i-cached!) - -## can_lock?(spec) [](#method-i-can_lock?) - -**@return** [Boolean] - -## dependency_names_to_double_check() [](#method-i-dependency_names_to_double_check) - -## double_check_for() [](#method-i-double_check_for) -it's possible that gems from one source depend on gems from some other source, -so now we download gemspecs and iterate over those dependencies, looking for -gems we don't have info on yet. - -## extension_cache_path(spec) [](#method-i-extension_cache_path) - -## identifier() [](#method-i-identifier) - -## include?(other) [](#method-i-include?) - -**@return** [Boolean] - -## inspect() [](#method-i-inspect) - -## local!() [](#method-i-local!) - -## local_only!() [](#method-i-local_only!) - -## path?() [](#method-i-path?) - -**@return** [Boolean] - -## remote!() [](#method-i-remote!) - -## spec_names() [](#method-i-spec_names) - -## unmet_deps() [](#method-i-unmet_deps) - -## version_message(spec, locked_specnil) [](#method-i-version_message) - diff --git a/example/ruby/Bundler/Source/Gemspec.md b/example/ruby/Bundler/Source/Gemspec.md deleted file mode 100644 index b30c0ae..0000000 --- a/example/ruby/Bundler/Source/Gemspec.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::Source::Gemspec -**Inherits:** Bundler::Source::Path - - - - -# Attributes -## gemspec[RW] [](#attribute-i-gemspec) -Returns the value of attribute gemspec. - - -#Instance Methods -## as_path_source() [](#method-i-as_path_source) - -## initialize(options) [](#method-i-initialize) - -**@return** [Gemspec] a new instance of Gemspec - diff --git a/example/ruby/Bundler/Source/Git.md b/example/ruby/Bundler/Source/Git.md deleted file mode 100644 index 957f389..0000000 --- a/example/ruby/Bundler/Source/Git.md +++ /dev/null @@ -1,98 +0,0 @@ -# Class: Bundler::Source::Git -**Inherits:** Path - - - - -# Class Methods -## from_lock(options ) [](#method-c-from_lock) -# Attributes -## branch[RW] [](#attribute-i-branch) -Returns the value of attribute branch. - -## glob[RW] [](#attribute-i-glob) -Returns the value of attribute glob. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## ref[RW] [](#attribute-i-ref) -Returns the value of attribute ref. - -## submodules[RW] [](#attribute-i-submodules) -Returns the value of attribute submodules. - -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - - -#Instance Methods -## allow_git_ops?() [](#method-i-allow_git_ops?) - -**@return** [Boolean] - -## app_cache_dirname() [](#method-i-app_cache_dirname) - -## cache(spec, custom_pathnil) [](#method-i-cache) - -## cache_path() [](#method-i-cache_path) -This is the path which is going to contain a cache of the git repository. When -using the same git repository across different projects, this cache will be -shared. When using local git repos, this is set to the local repo. - -## cached!() [](#method-i-cached!) - -## current_branch() [](#method-i-current_branch) - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## extension_dir_name() [](#method-i-extension_dir_name) - -## hash() [](#method-i-hash) - -## identifier() [](#method-i-identifier) - -## include?(other) [](#method-i-include?) - -**@return** [Boolean] - -## initialize(options) [](#method-i-initialize) - -**@return** [Git] a new instance of Git - -## install(spec, options{}) [](#method-i-install) - -## install_path() [](#method-i-install_path) -This is the path which is going to contain a specific checkout of the git -repository. When using local git repos, this is set to the local repo. - -## load_spec_files() [](#method-i-load_spec_files) - -## local?() [](#method-i-local?) - -**@return** [Boolean] - -## local_override!(path) [](#method-i-local_override!) - -## migrate_cache(custom_pathnil, local:false) [](#method-i-migrate_cache) - -## name() [](#method-i-name) - -## remote!() [](#method-i-remote!) - -## revision() [](#method-i-revision) - -## specs() [](#method-i-specs) - -## to_gemfile() [](#method-i-to_gemfile) - -## to_lock() [](#method-i-to_lock) - -## to_s() [](#method-i-to_s) - -## unlock!() [](#method-i-unlock!) - -## uri_with_specifiers(specifiers) [](#method-i-uri_with_specifiers) - diff --git a/example/ruby/Bundler/Source/Git/AmbiguousGitReference.md b/example/ruby/Bundler/Source/Git/AmbiguousGitReference.md deleted file mode 100644 index 44d36ea..0000000 --- a/example/ruby/Bundler/Source/Git/AmbiguousGitReference.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::Source::Git::AmbiguousGitReference -**Inherits:** Bundler::GitError - - - - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [AmbiguousGitReference] a new instance of AmbiguousGitReference - diff --git a/example/ruby/Bundler/Source/Git/GitCommandError.md b/example/ruby/Bundler/Source/Git/GitCommandError.md deleted file mode 100644 index af00e4d..0000000 --- a/example/ruby/Bundler/Source/Git/GitCommandError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Bundler::Source::Git::GitCommandError -**Inherits:** Bundler::GitError - - - - -# Attributes -## command[RW] [](#attribute-i-command) -Returns the value of attribute command. - - -#Instance Methods -## initialize(command, path, extra_infonil) [](#method-i-initialize) - -**@return** [GitCommandError] a new instance of GitCommandError - diff --git a/example/ruby/Bundler/Source/Git/GitNotAllowedError.md b/example/ruby/Bundler/Source/Git/GitNotAllowedError.md deleted file mode 100644 index 14e5cf3..0000000 --- a/example/ruby/Bundler/Source/Git/GitNotAllowedError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::Source::Git::GitNotAllowedError -**Inherits:** Bundler::GitError - - - - - -#Instance Methods -## initialize(command) [](#method-i-initialize) - -**@return** [GitNotAllowedError] a new instance of GitNotAllowedError - diff --git a/example/ruby/Bundler/Source/Git/GitNotInstalledError.md b/example/ruby/Bundler/Source/Git/GitNotInstalledError.md deleted file mode 100644 index ec5f6bb..0000000 --- a/example/ruby/Bundler/Source/Git/GitNotInstalledError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::Source::Git::GitNotInstalledError -**Inherits:** Bundler::GitError - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [GitNotInstalledError] a new instance of GitNotInstalledError - diff --git a/example/ruby/Bundler/Source/Git/GitProxy.md b/example/ruby/Bundler/Source/Git/GitProxy.md deleted file mode 100644 index 6bd9728..0000000 --- a/example/ruby/Bundler/Source/Git/GitProxy.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Bundler::Source::Git::GitProxy -**Inherits:** Object - - -The GitProxy is responsible to interact with git repositories. All actions -required by the Git source is encapsulated in this object. - - -# Attributes -## branch[RW] [](#attribute-i-branch) -Returns the value of attribute branch. - -## explicit_ref[RW] [](#attribute-i-explicit_ref) -Returns the value of attribute explicit_ref. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - -## ref[RW] [](#attribute-i-ref) -Returns the value of attribute ref. - -## revision[RW] [](#attribute-i-revision) - -## tag[RW] [](#attribute-i-tag) -Returns the value of attribute tag. - -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - - -#Instance Methods -## checkout() [](#method-i-checkout) - -## contains?(commit) [](#method-i-contains?) - -**@return** [Boolean] - -## copy_to(destination, submodulesfalse) [](#method-i-copy_to) - -## current_branch() [](#method-i-current_branch) - -## full_version() [](#method-i-full_version) - -## initialize(path, uri, options{}, revisionnil, gitnil) [](#method-i-initialize) - -**@return** [GitProxy] a new instance of GitProxy - -## version() [](#method-i-version) - diff --git a/example/ruby/Bundler/Source/Git/MissingGitRevisionError.md b/example/ruby/Bundler/Source/Git/MissingGitRevisionError.md deleted file mode 100644 index e5edeec..0000000 --- a/example/ruby/Bundler/Source/Git/MissingGitRevisionError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Bundler::Source::Git::MissingGitRevisionError -**Inherits:** Bundler::Source::Git::GitCommandError - - - - - -#Instance Methods -## initialize(command, destination_path, ref, repo) [](#method-i-initialize) - -**@return** [MissingGitRevisionError] a new instance of MissingGitRevisionError - diff --git a/example/ruby/Bundler/Source/Metadata.md b/example/ruby/Bundler/Source/Metadata.md deleted file mode 100644 index 47b88b6..0000000 --- a/example/ruby/Bundler/Source/Metadata.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Bundler::Source::Metadata -**Inherits:** Bundler::Source - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## hash() [](#method-i-hash) - -## install(spec, _opts{}) [](#method-i-install) - -## options() [](#method-i-options) - -## specs() [](#method-i-specs) - -## to_s() [](#method-i-to_s) - -## version_message(spec) [](#method-i-version_message) - diff --git a/example/ruby/Bundler/Source/Path.md b/example/ruby/Bundler/Source/Path.md deleted file mode 100644 index 6bf7e94..0000000 --- a/example/ruby/Bundler/Source/Path.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: Bundler::Source::Path -**Inherits:** Bundler::Source - - - - -# Class Methods -## from_lock(options ) [](#method-c-from_lock) -# Attributes -## name[RW] [](#attribute-i-name) - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - -## root_path[RW] [](#attribute-i-root_path) -Returns the value of attribute root_path. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## app_cache_dirname() [](#method-i-app_cache_dirname) - -## cache(spec, custom_pathnil) [](#method-i-cache) - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## expanded_original_path() [](#method-i-expanded_original_path) - -## hash() [](#method-i-hash) - -## initialize(options) [](#method-i-initialize) - -**@return** [Path] a new instance of Path - -## install(spec, options{}) [](#method-i-install) - -## local_specs() [](#method-i-local_specs) - -## root() [](#method-i-root) - -## specs() [](#method-i-specs) - -## to_lock() [](#method-i-to_lock) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/Source/Path/Installer.md b/example/ruby/Bundler/Source/Path/Installer.md deleted file mode 100644 index 1ba230a..0000000 --- a/example/ruby/Bundler/Source/Path/Installer.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::Source::Path::Installer -**Inherits:** Bundler::RubyGemsGemInstaller - - - - -# Attributes -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - -#Instance Methods -## initialize(spec, options{}) [](#method-i-initialize) - -**@return** [Installer] a new instance of Installer - -## post_install() [](#method-i-post_install) - diff --git a/example/ruby/Bundler/Source/Rubygems.md b/example/ruby/Bundler/Source/Rubygems.md deleted file mode 100644 index 2a307d4..0000000 --- a/example/ruby/Bundler/Source/Rubygems.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: Bundler::Source::Rubygems -**Inherits:** Bundler::Source - - - - -# Class Methods -## from_lock(options ) [](#method-c-from_lock) -# Attributes -## remotes[RW] [](#attribute-i-remotes) -Returns the value of attribute remotes. - - -#Instance Methods -## add_remote(source) [](#method-i-add_remote) - -## cache(spec, custom_pathnil) [](#method-i-cache) - -## cached!() [](#method-i-cached!) - -## cached_built_in_gem(spec, local:false) [](#method-i-cached_built_in_gem) - -## caches() [](#method-i-caches) - -## can_lock?(spec) [](#method-i-can_lock?) - -**@return** [Boolean] - -## dependency_api_available?() [](#method-i-dependency_api_available?) - -**@return** [Boolean] - -## dependency_names_to_double_check() [](#method-i-dependency_names_to_double_check) - -## double_check_for(unmet_dependency_names) [](#method-i-double_check_for) - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## fetchers() [](#method-i-fetchers) - -## hash() [](#method-i-hash) - -## identifier() [](#method-i-identifier) - -## include?(o) [](#method-i-include?) - -**@return** [Boolean] - -## initialize(options{}) [](#method-i-initialize) - -**@return** [Rubygems] a new instance of Rubygems - -## install(spec, options{}) [](#method-i-install) - -**@raise** [GemNotFound] - -## local!() [](#method-i-local!) - -## local_only!() [](#method-i-local_only!) - -## multiple_remotes?() [](#method-i-multiple_remotes?) - -**@return** [Boolean] - -## no_remotes?() [](#method-i-no_remotes?) - -**@return** [Boolean] - -## options() [](#method-i-options) - -## remote!() [](#method-i-remote!) - -## remote_fetchers() [](#method-i-remote_fetchers) - -## spec_names() [](#method-i-spec_names) - -## specs() [](#method-i-specs) - -## to_lock() [](#method-i-to_lock) - -## to_s() [](#method-i-to_s) - -## unmet_deps() [](#method-i-unmet_deps) - diff --git a/example/ruby/Bundler/Source/Rubygems/Remote.md b/example/ruby/Bundler/Source/Rubygems/Remote.md deleted file mode 100644 index f9c067b..0000000 --- a/example/ruby/Bundler/Source/Rubygems/Remote.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Bundler::Source::Rubygems::Remote -**Inherits:** Object - - - - -# Attributes -## anonymized_uri[RW] [](#attribute-i-anonymized_uri) -Returns the value of attribute anonymized_uri. - -## original_uri[RW] [](#attribute-i-original_uri) -Returns the value of attribute original_uri. - -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - - -#Instance Methods -## cache_slug() [](#method-i-cache_slug) - -**@return** [String] A slug suitable for use as a cache key for this -remote. - -## initialize(uri) [](#method-i-initialize) - -**@return** [Remote] a new instance of Remote - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/Source/RubygemsAggregate.md b/example/ruby/Bundler/Source/RubygemsAggregate.md deleted file mode 100644 index 2a7cfd9..0000000 --- a/example/ruby/Bundler/Source/RubygemsAggregate.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Bundler::Source::RubygemsAggregate -**Inherits:** Object - - - - -# Attributes -## source_map[RW] [](#attribute-i-source_map) -Returns the value of attribute source_map. - -## sources[RW] [](#attribute-i-sources) -Returns the value of attribute sources. - - -#Instance Methods -## identifier() [](#method-i-identifier) - -## initialize(sources, source_map) [](#method-i-initialize) - -**@return** [RubygemsAggregate] a new instance of RubygemsAggregate - -## specs() [](#method-i-specs) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Bundler/SourceList.md b/example/ruby/Bundler/SourceList.md deleted file mode 100644 index e1b542f..0000000 --- a/example/ruby/Bundler/SourceList.md +++ /dev/null @@ -1,94 +0,0 @@ -# Class: Bundler::SourceList -**Inherits:** Object - - - - -# Attributes -## git_sources[RW] [](#attribute-i-git_sources) -Returns the value of attribute git_sources. - -## global_path_source[RW] [](#attribute-i-global_path_source) -Returns the value of attribute global_path_source. - -## metadata_source[RW] [](#attribute-i-metadata_source) -Returns the value of attribute metadata_source. - -## path_sources[RW] [](#attribute-i-path_sources) -Returns the value of attribute path_sources. - -## plugin_sources[RW] [](#attribute-i-plugin_sources) -Returns the value of attribute plugin_sources. - - -#Instance Methods -## add_git_source(options{}) [](#method-i-add_git_source) - -## add_global_rubygems_remote(uri) [](#method-i-add_global_rubygems_remote) - -## add_path_source(options{}) [](#method-i-add_path_source) - -## add_plugin_source(source, options{}) [](#method-i-add_plugin_source) - -## add_rubygems_source(options{}) [](#method-i-add_rubygems_source) - -## aggregate_global_source?() [](#method-i-aggregate_global_source?) - -**@return** [Boolean] - -## all_sources() [](#method-i-all_sources) - -## cached!() [](#method-i-cached!) - -## default_source() [](#method-i-default_source) - -## expired_sources?(replacement_sources) [](#method-i-expired_sources?) -Returns true if there are changes - -**@return** [Boolean] - -## get(source) [](#method-i-get) - -## global_rubygems_source() [](#method-i-global_rubygems_source) - -## implicit_global_source?() [](#method-i-implicit_global_source?) - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [SourceList] a new instance of SourceList - -## local!() [](#method-i-local!) - -## local_mode?() [](#method-i-local_mode?) - -**@return** [Boolean] - -## local_only!() [](#method-i-local_only!) - -## lock_other_sources() [](#method-i-lock_other_sources) - -## lock_rubygems_sources() [](#method-i-lock_rubygems_sources) - -## lock_sources() [](#method-i-lock_sources) - -## merged_gem_lockfile_sections!(replacement_source) [](#method-i-merged_gem_lockfile_sections!) - -## merged_gem_lockfile_sections?() [](#method-i-merged_gem_lockfile_sections?) - -**@return** [Boolean] - -## non_default_explicit_sources() [](#method-i-non_default_explicit_sources) - -## non_global_rubygems_sources() [](#method-i-non_global_rubygems_sources) - -## remote!() [](#method-i-remote!) - -## replace_sources!(replacement_sources) [](#method-i-replace_sources!) -Returns true if there are changes - -## rubygems_remotes() [](#method-i-rubygems_remotes) - -## rubygems_sources() [](#method-i-rubygems_sources) - diff --git a/example/ruby/Bundler/SourceMap.md b/example/ruby/Bundler/SourceMap.md deleted file mode 100644 index 7b784f8..0000000 --- a/example/ruby/Bundler/SourceMap.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Bundler::SourceMap -**Inherits:** Object - - - - -# Attributes -## dependencies[RW] [](#attribute-i-dependencies) -Returns the value of attribute dependencies. - -## locked_specs[RW] [](#attribute-i-locked_specs) -Returns the value of attribute locked_specs. - -## sources[RW] [](#attribute-i-sources) -Returns the value of attribute sources. - - -#Instance Methods -## all_requirements() [](#method-i-all_requirements) - -## direct_requirements() [](#method-i-direct_requirements) - -## initialize(sources, dependencies, locked_specs) [](#method-i-initialize) - -**@return** [SourceMap] a new instance of SourceMap - -## locked_requirements() [](#method-i-locked_requirements) - -## pinned_spec_names(skipnil) [](#method-i-pinned_spec_names) - diff --git a/example/ruby/Bundler/SpecSet.md b/example/ruby/Bundler/SpecSet.md deleted file mode 100644 index 30782b8..0000000 --- a/example/ruby/Bundler/SpecSet.md +++ /dev/null @@ -1,2255 +0,0 @@ -# Class: Bundler::SpecSet -**Inherits:** Object - -**Includes:** Enumerable, TSort - - - - - -#Instance Methods -## -(other) [](#method-i--) - -## <<(spec) [](#method-i-<<) - -## [](key) [](#method-i-[]) - -## []=(key, value) [](#method-i-[]=) - -## add_extra_platforms!(platforms) [](#method-i-add_extra_platforms!) - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete(specs) [](#method-i-delete) - -## delete_by_name(name) [](#method-i-delete_by_name) - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&b) [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_by_name_and_platform(name, platform) [](#method-i-find_by_name_and_platform) - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## for(dependencies, platforms_or_legacy_check[nil], legacy_platforms[nil], skips:[]) [](#method-i-for) - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## incomplete_for_platform?(deps, platform) [](#method-i-incomplete_for_platform?) - -**@return** [Boolean] - -## incomplete_specs() [](#method-i-incomplete_specs) - -## initialize(specs) [](#method-i-initialize) - -**@return** [SpecSet] a new instance of SpecSet - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## insecurely_materialized_specs() [](#method-i-insecurely_materialized_specs) - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## length() [](#method-i-length) - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## materialize(deps) [](#method-i-materialize) - -## materialized_for_all_platforms() [](#method-i-materialized_for_all_platforms) -Materialize for all the specs in the spec set, regardless of what platform -they're for - -**@return** [Array] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## missing_specs() [](#method-i-missing_specs) - -## missing_specs_for(dependencies) [](#method-i-missing_specs_for) - -## names() [](#method-i-names) - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## normalize_platforms!(deps, platforms) [](#method-i-normalize_platforms!) - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partially_missing_specs() [](#method-i-partially_missing_specs) - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort!() [](#method-i-sort!) - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_hash() [](#method-i-to_hash) - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, TSort::Cyclic is raised. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, TSort::Cyclic is raised. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## valid?(s) [](#method-i-valid?) - -**@return** [Boolean] - -## validate_deps(s) [](#method-i-validate_deps) - -## what_required(spec) [](#method-i-what_required) - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Bundler/Standalone.md b/example/ruby/Bundler/Standalone.md deleted file mode 100644 index 2f64fe1..0000000 --- a/example/ruby/Bundler/Standalone.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::Standalone -**Inherits:** Object - - - - - -#Instance Methods -## generate() [](#method-i-generate) - -## initialize(groups, definition) [](#method-i-initialize) - -**@return** [Standalone] a new instance of Standalone - diff --git a/example/ruby/Bundler/StubSpecification.md b/example/ruby/Bundler/StubSpecification.md deleted file mode 100644 index 45c05aa..0000000 --- a/example/ruby/Bundler/StubSpecification.md +++ /dev/null @@ -1,75 +0,0 @@ -# Class: Bundler::StubSpecification -**Inherits:** Bundler::RemoteSpecification - - - - -# Class Methods -## from_stub(stub ) [](#method-c-from_stub) -# Attributes -## checksum[RW] [](#attribute-i-checksum) -Returns the value of attribute checksum. - -## ignored[RW] [](#attribute-i-ignored) -Returns the value of attribute ignored. - -## stub[RW] [](#attribute-i-stub) -Returns the value of attribute stub. - - -#Instance Methods -## activated=(activated) [](#method-i-activated=) - -## activated?() [](#method-i-activated?) - -**@return** [Boolean] - -## base_dir=(path) [](#method-i-base_dir=) - -## default_gem?() [](#method-i-default_gem?) - -**@return** [Boolean] - -## extensions() [](#method-i-extensions) - -## full_gem_path() [](#method-i-full_gem_path) - -## full_gem_path=(path) [](#method-i-full_gem_path=) - -## full_require_paths() [](#method-i-full_require_paths) - -## gem_build_complete_path() [](#method-i-gem_build_complete_path) - -## ignored?() [](#method-i-ignored?) - -**@return** [Boolean] - -## insecurely_materialized?() [](#method-i-insecurely_materialized?) - -**@return** [Boolean] - -## inspect() [](#method-i-inspect) - -## load_paths() [](#method-i-load_paths) - -## loaded_from() [](#method-i-loaded_from) - -## manually_installed?() [](#method-i-manually_installed?) - -**@return** [Boolean] - -## matches_for_glob(glob) [](#method-i-matches_for_glob) - -## missing_extensions?() [](#method-i-missing_extensions?) -This is defined directly to avoid having to loading the full spec - -**@return** [Boolean] - -## raw_require_paths() [](#method-i-raw_require_paths) - -## require_paths() [](#method-i-require_paths) - -## source=(source) [](#method-i-source=) - -## to_yaml() [](#method-i-to_yaml) - diff --git a/example/ruby/Bundler/TSort.md b/example/ruby/Bundler/TSort.md deleted file mode 100644 index 5edded7..0000000 --- a/example/ruby/Bundler/TSort.md +++ /dev/null @@ -1,361 +0,0 @@ -# Module: Bundler::TSort - - -Bundler::TSort implements topological sorting using Tarjan's algorithm for -strongly connected components. - -Bundler::TSort is designed to be able to be used with any object which can be -interpreted as a directed graph. - -Bundler::TSort requires two methods to interpret an object as a graph, -tsort_each_node and tsort_each_child. - -* tsort_each_node is used to iterate for all nodes over a graph. -* tsort_each_child is used to iterate for child nodes of a given node. - -The equality of nodes are defined by eql? and hash since Bundler::TSort uses -Hash internally. - -## A Simple Example - -The following example demonstrates how to mix the Bundler::TSort module into -an existing class (in this case, Hash). Here, we're treating each key in the -hash as a node in the graph, and so we simply alias the required -#tsort_each_node method to Hash's #each_key method. For each key in the hash, -the associated value is an array of the node's child nodes. This choice in -turn leads to our implementation of the required #tsort_each_child method, -which fetches the array of child nodes and then iterates over that array using -the user-supplied block. - - require 'bundler/vendor/tsort/lib/tsort' - - class Hash - include Bundler::TSort - alias tsort_each_node each_key - def tsort_each_child(node, &block) - fetch(node).each(&block) - end - end - - {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort - #=> [3, 2, 1, 4] - - {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components - #=> [[4], [2, 3], [1]] - -## A More Realistic Example - -A very simple `make' like tool can be implemented as follows: - - require 'bundler/vendor/tsort/lib/tsort' - - class Make - def initialize - @dep = {} - @dep.default = [] - end - - def rule(outputs, inputs=[], &block) - triple = [outputs, inputs, block] - outputs.each {|f| @dep[f] = [triple]} - @dep[triple] = inputs - end - - def build(target) - each_strongly_connected_component_from(target) {|ns| - if ns.length != 1 - fs = ns.delete_if {|n| Array === n} - raise Bundler::TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}") - end - n = ns.first - if Array === n - outputs, inputs, block = n - inputs_time = inputs.map {|f| File.mtime f}.max - begin - outputs_time = outputs.map {|f| File.mtime f}.min - rescue Errno::ENOENT - outputs_time = nil - end - if outputs_time == nil || - inputs_time != nil && outputs_time <= inputs_time - sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i - block.call - end - end - } - end - - def tsort_each_child(node, &block) - @dep[node].each(&block) - end - include Bundler::TSort - end - - def command(arg) - print arg, "\n" - system arg - end - - m = Make.new - m.rule(%w[t1]) { command 'date > t1' } - m.rule(%w[t2]) { command 'date > t2' } - m.rule(%w[t3]) { command 'date > t3' } - m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' } - m.rule(%w[t5], %w[t4 t2]) { command 'cat t4 t2 > t5' } - m.build('t5') - -## Bugs - -* 'tsort.rb' is wrong name because this library uses Tarjan's algorithm for - strongly connected components. Although 'strongly_connected_components.rb' - is correct but too long. - -## References - - 1. Tarjan, "Depth First Search and Linear Graph Algorithms", -*SIAM Journal on Computing*, Vol. 1, No. 2, pp. 146-160, June 1972. - - -# Class Methods -## each_strongly_connected_component(each_node , each_child ) [](#method-c-each_strongly_connected_component) -The iterator version of the Bundler::TSort.strongly_connected_components -method. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - Bundler::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - Bundler::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc } - #=> [4] - # [2, 3] - # [1] -## each_strongly_connected_component_from(node , each_child , id_map {}, stack []) [](#method-c-each_strongly_connected_component_from) -Iterates over strongly connected components in a graph. The graph is -represented by *node* and *each_child*. - -*node* is the first node. *each_child* should have `call` method which takes a -node argument and yields for each child node. - -Return value is unspecified. - -#Bundler::TSort.each_strongly_connected_component_from is a class method and -it doesn't need a class to represent a graph which includes Bundler::TSort. - - graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_child = lambda {|n, &b| graph[n].each(&b) } - Bundler::TSort.each_strongly_connected_component_from(1, each_child) {|scc| - p scc - } - #=> [4] - # [2, 3] - # [1] -## strongly_connected_components(each_node , each_child ) [](#method-c-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p Bundler::TSort.strongly_connected_components(each_node, each_child) - #=> [[4], [2], [3], [1]] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p Bundler::TSort.strongly_connected_components(each_node, each_child) - #=> [[4], [2, 3], [1]] -## tsort(each_node , each_child ) [](#method-c-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - -If there is a cycle, Bundler::TSort::Cyclic is raised. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p Bundler::TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p Bundler::TSort.tsort(each_node, each_child) # raises Bundler::TSort::Cyclic -## tsort_each(each_node , each_child ) [](#method-c-tsort_each) -The iterator version of the Bundler::TSort.tsort method. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - Bundler::TSort.tsort_each(each_node, each_child) {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -#Instance Methods -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include Bundler::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include Bundler::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include Bundler::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, Bundler::TSort::Cyclic is raised. - - class G - include Bundler::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises Bundler::TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, Bundler::TSort::Cyclic is -raised. - - class G - include Bundler::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## tsort_each_child(node) [](#method-i-tsort_each_child) -Should be implemented by a extended class. - -#tsort_each_child is used to iterate for child nodes of *node*. - -**@raise** [NotImplementedError] - -## tsort_each_node() [](#method-i-tsort_each_node) -Should be implemented by a extended class. - -#tsort_each_node is used to iterate for all nodes over a graph. - -**@raise** [NotImplementedError] - diff --git a/example/ruby/Bundler/TSort/Cyclic.md b/example/ruby/Bundler/TSort/Cyclic.md deleted file mode 100644 index 928f257..0000000 --- a/example/ruby/Bundler/TSort/Cyclic.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::TSort::Cyclic -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Bundler/TemporaryResourceError.md b/example/ruby/Bundler/TemporaryResourceError.md deleted file mode 100644 index fc1a7fe..0000000 --- a/example/ruby/Bundler/TemporaryResourceError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Bundler::TemporaryResourceError -**Inherits:** Bundler::PermissionError - - - - - -#Instance Methods -## message() [](#method-i-message) - diff --git a/example/ruby/Bundler/Thor.md b/example/ruby/Bundler/Thor.md deleted file mode 100644 index 1f3f636..0000000 --- a/example/ruby/Bundler/Thor.md +++ /dev/null @@ -1,296 +0,0 @@ -# Class: Bundler::Thor -**Inherits:** Object - -**Includes:** Bundler::Thor::Base - - - - -# Class Methods -## check_unknown_options!(options {}) [](#method-c-check_unknown_options!) -Extend check unknown options to accept a hash of conditions. - -### Parameters -options: A hash containing :only and/or :except keys -## check_unknown_options?(config ) [](#method-c-check_unknown_options?) -Overwrite check_unknown_options? to take subcommands and options into account. -**@return** [Boolean] - -## command_exists?(command_name ) [](#method-c-command_exists?) -Checks if a specified command exists. - -#### Parameters -command_name -: The name of the command to check for existence. - - -#### Returns -Boolean -: `true` if the command exists, `false` otherwise. - -**@return** [Boolean] - -## command_help(shell , command_name ) [](#method-c-command_help) -Prints help information for the given command. - -#### Parameters -shell command_name -## default_command(meth nil) [](#method-c-default_command) -Sets the default command when thor is executed without an explicit command to -be called. - -#### Parameters -meth -: name of the default command - -## deprecation_warning(message ) [](#method-c-deprecation_warning) -:nodoc: -## desc(usage , description , options {}) [](#method-c-desc) -Defines the usage and the description of the next command. - -#### Parameters -usage description options -## disable_required_check!(*command_names ) [](#method-c-disable_required_check!) -Disable the check for required options for the given commands. This is useful -if you have a command that does not need the required options to work, like -help. - -#### Parameters -Symbol ... -: A list of commands that should be affected. - -## disable_required_check?(command ) [](#method-c-disable_required_check?) -:nodoc: -**@return** [Boolean] - -## help(shell , subcommand false) [](#method-c-help) -Prints help information for this class. - -#### Parameters -shell -## long_desc(long_description , options {}) [](#method-c-long_desc) -Defines the long description of the next command. - -Long description is by default indented, line-wrapped and repeated whitespace -merged. In order to print long description verbatim, with indentation and -spacing exactly as found in the code, use the `wrap` option - - long_desc 'your very long description', wrap: false - -#### Parameters -long description options -## map(mappings nil, **kw ) [](#method-c-map) -Maps an input to a command. If you define: - - map "-T" => "list" - -Running: - - thor -T - -Will invoke the list command. - -#### Parameters -Hash[String|Array => Symbol] -: Maps the string or the strings in the array to the given command. - -## method_at_least_one(*args , &block ) [](#method-c-method_at_least_one) -Adds and declares option group for required at least one of options in the -block of arguments. You can declare options as the outside of the block. - -If :for is given as option, it allows you to change the options from a -previous defined command. - -#### Parameters -[Array](Bundler::Thor::Option.name) -options -: :for is applied for previous defined command. - - -#### Examples - - at_least_one do - option :one - option :two - end - -Or - - option :one - option :two - at_least_one :one, :two - -If you do not give "--one" and "--two" AtLeastOneRequiredArgumentError will be -raised. - -You can use at_least_one and exclusive at the same time. - - exclusive do - at_least_one do - option :one - option :two - end - end - -Then it is required either only one of "--one" or "--two". -## method_exclusive(*args , &block ) [](#method-c-method_exclusive) -Adds and declares option group for exclusive options in the block and -arguments. You can declare options as the outside of the block. - -If :for is given as option, it allows you to change the options from a -previous defined command. - -#### Parameters -[Array](Bundler::Thor::Option.name) -options -: :for is applied for previous defined command. - - -#### Examples - - exclusive do - option :one - option :two - end - -Or - - option :one - option :two - exclusive :one, :two - -If you give "--one" and "--two" at the same time ExclusiveArgumentsError will -be raised. -## method_option(name , options {}) [](#method-c-method_option) -Adds an option to the set of method options. If :for is given as option, it -allows you to change the options from a previous defined command. - - def previous_command - # magic - end - - method_option :foo, :for => :previous_command - - def next_command - # magic - end - -#### Parameters -name -: The name of the argument. - -options -: Described below. - - -#### Options -:desc - Description for the argument. :required - If the argument is -required or not. :default - Default value for this argument. It cannot be -required and have default values. :aliases - Aliases for this option. :type - - The type of the argument, can be :string, :hash, :array, :numeric or -:boolean. :banner - String to show on usage notes. :hide - If you want -to hide this option from the help. -## method_options(options nil) [](#method-c-method_options) -Declares the options for the next command to be declared. - -#### Parameters -Hash[Symbol => Object] -: The hash key is the name of the option and the value - -is the type of the option. Can be :string, :array, :hash, :boolean, :numeric -or :required (string). If you give a value, the type of the value is used. -## package_name(name , _ {}) [](#method-c-package_name) -Allows for custom "Command" package naming. - -### Parameters -name options -## printable_commands(all true, subcommand false) [](#method-c-printable_commands) -Returns commands ready to be printed. -## register(klass , subcommand_name , usage , description , options {}) [](#method-c-register) -Registers another Bundler::Thor subclass as a command. - -#### Parameters -klass -: Bundler::Thor subclass to register - -command -: Subcommand name to use - -usage -: Short usage for the subcommand - -description -: Description for the subcommand - -## stop_on_unknown_option!(*command_names ) [](#method-c-stop_on_unknown_option!) -Stop parsing of options as soon as an unknown option or a regular argument is -encountered. All remaining arguments are passed to the command. This is -useful if you have a command that can receive arbitrary additional options, -and where those additional options should not be handled by Bundler::Thor. - -#### Example - -To better understand how this is useful, let's consider a command that calls -an external command. A user may want to pass arbitrary options and arguments -to that command. The command itself also accepts some options, which should -be handled by Bundler::Thor. - - class_option "verbose", :type => :boolean - stop_on_unknown_option! :exec - check_unknown_options! :except => :exec - - desc "exec", "Run a shell command" - def exec(*args) - puts "diagnostic output" if options[:verbose] - Kernel.exec(*args) - end - -Here `exec` can be called with `--verbose` to get diagnostic output, e.g.: - - $ thor exec --verbose echo foo - diagnostic output - foo - -But if `--verbose` is given after `echo`, it is passed to `echo` instead: - - $ thor exec echo --verbose foo - --verbose foo - -#### Parameters -Symbol ... -: A list of commands that should be affected. - -## stop_on_unknown_option?(command ) [](#method-c-stop_on_unknown_option?) -:nodoc: -**@return** [Boolean] - -## subcommand(subcommand , subcommand_class ) [](#method-c-subcommand) -## subcommand_classes() [](#method-c-subcommand_classes) -## subcommands() [](#method-c-subcommands) - -#Instance Methods -## help(commandnil, subcommandfalse) [](#method-i-help) - -## initialize(args[], local_options{}, config{}) [](#method-i-initialize) -It receives arguments in an Array and two hashes, one for options and other -for configuration. - -Notice that it does not check if all required arguments were supplied. It -should be done by the parser. - -#### Parameters -[args -: An array of objects. The objects are applied to their respective accessors - declared with `argument`. - - -options -: An options hash that will be available as self.options. The hash given is - converted to a hash with indifferent access, magic predicates - (options.skip?) and then frozen. - - -config -: Configuration for this Bundler::Thor class. - - diff --git a/example/ruby/Bundler/Thor/Actions.md b/example/ruby/Bundler/Thor/Actions.md deleted file mode 100644 index 7df352b..0000000 --- a/example/ruby/Bundler/Thor/Actions.md +++ /dev/null @@ -1,539 +0,0 @@ -# Module: Bundler::Thor::Actions - - - - -# Class Methods -## included(base ) [](#method-c-included) -:nodoc: -# Attributes -## behavior[RW] [](#attribute-i-behavior) -Returns the value of attribute behavior. - - -#Instance Methods -## action(instance) [](#method-i-action) -Wraps an action object and call it accordingly to the thor class behavior. - -## append_to_file(path, *args, &block) [](#method-i-append_to_file) -Append text to a file. Since it depends on insert_into_file, it's reversible. - -#### Parameters -path -: path of the file to be changed - -data -: the data to append to the file, can be also given as a block. - -config -: give :verbose => false to not log the status. - - -#### Example - - append_to_file 'config/environments/test.rb', 'config.gem "rspec"' - - append_to_file 'config/environments/test.rb' do - 'config.gem "rspec"' - end - -## apply(path, config{}) [](#method-i-apply) -Loads an external file and execute it in the instance binding. - -#### Parameters -path -: The path to the file to execute. Can be a web address or a relative path - from the source root. - - -#### Examples - - apply "http://gist.github.com/103208" - - apply "recipes/jquery.rb" - -## chmod(path, mode, config{}) [](#method-i-chmod) -Changes the mode of the given file or directory. - -#### Parameters -mode -: the file mode - -path -: the name of the file to change mode - -config -: give :verbose => false to not log the status. - - -#### Example - - chmod "script/server", 0755 - -## comment_lines(path, flag, *args) [](#method-i-comment_lines) -Comment all lines matching a given regex. It will leave the space which -existed before the beginning of the line in tact and will insert a single -space after the comment hash. - -#### Parameters -path -: path of the file to be changed - -flag -: the regexp or string used to decide which lines to comment - -config -: give :verbose => false to not log the status. - - -#### Example - - comment_lines 'config/initializers/session_store.rb', /cookie_store/ - -## copy_file(source, *args, &block) [](#method-i-copy_file) -Copies the file from the relative source to the relative destination. If the -destination is not given it's assumed to be equal to the source. - -#### Parameters -source -: the relative path to the source root. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status, and :mode => :preserve, to - preserve the file mode from the source. - - -#### Examples - - copy_file "README", "doc/README" - - copy_file "doc/README" - -## create_file(destination, *args, &block) [](#method-i-create_file) -Create a new file relative to the destination root with the given data, which -is the return value of a block or a data string. - -#### Parameters -destination -: the relative path to the destination root. - -data -: the data to append to the file. - -config -: give :verbose => false to not log the status. - - -#### Examples - - create_file "lib/fun_party.rb" do - hostname = ask("What is the virtual hostname I should use?") - "vhost.name = #{hostname}" - end - - create_file "config/apache.conf", "your apache config" - -## create_link(destination, *args) [](#method-i-create_link) -Create a new file relative to the destination root from the given source. - -#### Parameters -destination -: the relative path to the destination root. - -source -: the relative path to the source root. - -config -: give :verbose => false to not log the status. - -: give :symbolic => false for hard link. - - -#### Examples - - create_link "config/apache.conf", "/etc/apache.conf" - -## destination_root() [](#method-i-destination_root) -Returns the root for this thor class (also aliased as destination root). - -## destination_root=(root) [](#method-i-destination_root=) -Sets the root for this thor class. Relatives path are added to the directory -where the script was invoked and expanded. - -## directory(source, *args, &block) [](#method-i-directory) -Copies recursively the files from source directory to root directory. If any -of the files finishes with .tt, it's considered to be a template and is placed -in the destination without the extension .tt. If any empty directory is found, -it's copied and all .empty_directory files are ignored. If any file name is -wrapped within % signs, the text within the % signs will be executed as a -method and replaced with the returned value. Let's suppose a doc directory -with the following files: - - doc/ - components/.empty_directory - README - rdoc.rb.tt - %app_name%.rb - -When invoked as: - - directory "doc" - -It will create a doc directory in the destination with the following files -(assuming that the `app_name` method returns the value "blog"): - - doc/ - components/ - README - rdoc.rb - blog.rb - -**Encoded path note:** Since Bundler::Thor internals use Object#respond_to? to -check if it can expand %something%, this `something` should be a public method -in the class calling #directory. If a method is private, Bundler::Thor stack -raises PrivateMethodEncodedError. - -#### Parameters -source -: the relative path to the source root. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status. If :recursive => false, does - not look for paths recursively. If :mode => :preserve, preserve the file - mode from the source. If :exclude_pattern => /regexp/, prevents copying - files that match that regexp. - - -#### Examples - - directory "doc" - directory "doc", "docs", :recursive => false - -## empty_directory(destination, config{}) [](#method-i-empty_directory) -Creates an empty directory. - -#### Parameters -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status. - - -#### Examples - - empty_directory "doc" - -## find_in_source_paths(file) [](#method-i-find_in_source_paths) -Receives a file or directory and search for it in the source paths. - -**@raise** [Error] - -## get(source, *args, &block) [](#method-i-get) -Gets the content at the given address and places it at the given relative -destination. If a block is given instead of destination, the content of the -url is yielded and used as location. - -`get` relies on open-uri, so passing application user input would provide a -command injection attack vector. - -#### Parameters -source -: the address of the given content. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status, and :http_headers => - to add headers to an http request. - - -#### Examples - - get "http://gist.github.com/103208", "doc/README" - - get "http://gist.github.com/103208", "doc/README", :http_headers => {"Content-Type" => "application/json"} - - get "http://gist.github.com/103208" do |content| - content.split("\n").first - end - -## gsub_file(path, flag, *args, &block) [](#method-i-gsub_file) -Run a regular expression replacement on a file. - -#### Parameters -path -: path of the file to be changed - -flag -: the regexp or string to be replaced - -replacement -: the replacement, can be also given as a block - -config -: give :verbose => false to not log the status, and :force => true, to force - the replacement regardless of runner behavior. - - -#### Example - - gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' - - gsub_file 'README', /rake/, :green do |match| - match << " no more. Use thor!" - end - -## in_root() [](#method-i-in_root) -Goes to the root and execute the given block. - -## initialize(args[], options{}, config{}) [](#method-i-initialize) -Extends initializer to add more configuration options. - -#### Configuration -behavior -: The actions default behavior. Can be :invoke or :revoke. It also accepts - :force, :skip and :pretend to set the behavior and the respective option. - - -destination_root -: The root directory needed for some actions. - - -## inject_into_class(path, klass, *args, &block) [](#method-i-inject_into_class) -Injects text right after the class definition. Since it depends on -insert_into_file, it's reversible. - -#### Parameters -path -: path of the file to be changed - -klass -: the class to be manipulated - -data -: the data to append to the class, can be also given as a block. - -config -: give :verbose => false to not log the status. - - -#### Examples - - inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " filter_parameter :password\n" - - inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do - " filter_parameter :password\n" - end - -## inject_into_module(path, module_name, *args, &block) [](#method-i-inject_into_module) -Injects text right after the module definition. Since it depends on -insert_into_file, it's reversible. - -#### Parameters -path -: path of the file to be changed - -module_name -: the module to be manipulated - -data -: the data to append to the class, can be also given as a block. - -config -: give :verbose => false to not log the status. - - -#### Examples - - inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper", " def help; 'help'; end\n" - - inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper" do - " def help; 'help'; end\n" - end - -## insert_into_file(destination, *args, &block) [](#method-i-insert_into_file) - -## inside(dir"", config{}, &block) [](#method-i-inside) -Do something in the root or on a provided subfolder. If a relative path is -given it's referenced from the current root. The full path is yielded to the -block you provide. The path is set back to the previous path when the method -exits. - -Returns the value yielded by the block. - -#### Parameters -dir -: the directory to move to. - -config -: give :verbose => true to log and use padding. - - -## link_file(source, *args) [](#method-i-link_file) -Links the file from the relative source to the relative destination. If the -destination is not given it's assumed to be equal to the source. - -#### Parameters -source -: the relative path to the source root. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status. - - -#### Examples - - link_file "README", "doc/README" - - link_file "doc/README" - -## prepend_to_file(path, *args, &block) [](#method-i-prepend_to_file) -Prepend text to a file. Since it depends on insert_into_file, it's reversible. - -#### Parameters -path -: path of the file to be changed - -data -: the data to prepend to the file, can be also given as a block. - -config -: give :verbose => false to not log the status. - - -#### Example - - prepend_to_file 'config/environments/test.rb', 'config.gem "rspec"' - - prepend_to_file 'config/environments/test.rb' do - 'config.gem "rspec"' - end - -## relative_to_original_destination_root(path, remove_dottrue) [](#method-i-relative_to_original_destination_root) -Returns the given path relative to the absolute root (ie, root where the -script started). - -## remove_file(path, config{}) [](#method-i-remove_file) -Removes a file at the given location. - -#### Parameters -path -: path of the file to be changed - -config -: give :verbose => false to not log the status. - - -#### Example - - remove_file 'README' - remove_file 'app/controllers/application_controller.rb' - -## run(command, config{}) [](#method-i-run) -Executes a command returning the contents of the command. - -#### Parameters -command -: the command to be executed. - -config -: give :verbose => false to not log the status, :capture => true to hide to - output. Specify :with to append an executable to command execution. - - -#### Example - - inside('vendor') do - run('ln -s ~/edge rails') - end - -## run_ruby_script(command, config{}) [](#method-i-run_ruby_script) -Executes a ruby script (taking into account WIN32 platform quirks). - -#### Parameters -command -: the command to be executed. - -config -: give :verbose => false to not log the status. - - -## source_paths() [](#method-i-source_paths) -Holds source paths in instance so they can be manipulated. - -## template(source, *args, &block) [](#method-i-template) -Gets an ERB template at the relative source, executes it and makes a copy at -the relative destination. If the destination is not given it's assumed to be -equal to the source removing .tt from the filename. - -#### Parameters -source -: the relative path to the source root. - -destination -: the relative path to the destination root. - -config -: give :verbose => false to not log the status. - - -#### Examples - - template "README", "doc/README" - - template "doc/README" - -## thor(command, *args) [](#method-i-thor) -Run a thor command. A hash of options can be given and it's converted to -switches. - -#### Parameters -command -: the command to be invoked - -args -: arguments to the command - -config -: give :verbose => false to not log the status, :capture => true to hide to - output. Other options are given as parameter to Bundler::Thor. - - -#### Examples - - thor :install, "http://gist.github.com/103208" - #=> thor install http://gist.github.com/103208 - - thor :list, :all => true, :substring => 'rails' - #=> thor list --all --substring=rails - -## uncomment_lines(path, flag, *args) [](#method-i-uncomment_lines) -Uncomment all lines matching a given regex. Preserves indentation before the -comment hash and removes the hash and any immediate following space. - -#### Parameters -path -: path of the file to be changed - -flag -: the regexp or string used to decide which lines to uncomment - -config -: give :verbose => false to not log the status. - - -#### Example - - uncomment_lines 'config/initializers/session_store.rb', /active_record/ - diff --git a/example/ruby/Bundler/Thor/Actions/CapturableERB.md b/example/ruby/Bundler/Thor/Actions/CapturableERB.md deleted file mode 100644 index 991201c..0000000 --- a/example/ruby/Bundler/Thor/Actions/CapturableERB.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Bundler::Thor::Actions::CapturableERB -**Inherits:** ERB - - -Bundler::Thor::Actions#capture depends on what kind of buffer is used in ERB. -Thus CapturableERB fixes ERB to use String buffer. - - - -#Instance Methods -## set_eoutvar(compiler, eoutvar"_erbout") [](#method-i-set_eoutvar) - diff --git a/example/ruby/Bundler/Thor/Actions/ClassMethods.md b/example/ruby/Bundler/Thor/Actions/ClassMethods.md deleted file mode 100644 index f3cf543..0000000 --- a/example/ruby/Bundler/Thor/Actions/ClassMethods.md +++ /dev/null @@ -1,25 +0,0 @@ -# Module: Bundler::Thor::Actions::ClassMethods - - - - - -#Instance Methods -## add_runtime_options!() [](#method-i-add_runtime_options!) -Add runtime options that help actions execution. - -## source_paths() [](#method-i-source_paths) -Hold source paths for one Bundler::Thor instance. source_paths_for_search is -the method responsible to gather source_paths from this current class, -inherited paths and the source root. - -## source_paths_for_search() [](#method-i-source_paths_for_search) -Returns the source paths in the following order: - - 1) This class source paths - 2) Source root - 3) Parents source paths - -## source_root(pathnil) [](#method-i-source_root) -Stores and return the source root for this class - diff --git a/example/ruby/Bundler/Thor/Actions/CreateFile.md b/example/ruby/Bundler/Thor/Actions/CreateFile.md deleted file mode 100644 index efefbc0..0000000 --- a/example/ruby/Bundler/Thor/Actions/CreateFile.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Bundler::Thor::Actions::CreateFile -**Inherits:** Bundler::Thor::Actions::EmptyDirectory - - -CreateFile is a subset of Template, which instead of rendering a file with -ERB, it gets the content from the user. - - -# Attributes -## data[RW] [](#attribute-i-data) -:nodoc: - - -#Instance Methods -## identical?() [](#method-i-identical?) -Checks if the content of the file at the destination is identical to the -rendered result. - -#### Returns -Boolean -: true if it is identical, false otherwise. - - -**@return** [Boolean] - -## initialize(base, destination, data, config{}) [](#method-i-initialize) - -**@return** [CreateFile] a new instance of CreateFile - -## invoke!() [](#method-i-invoke!) - -## render() [](#method-i-render) -Holds the content to be added to the file. - diff --git a/example/ruby/Bundler/Thor/Actions/CreateLink.md b/example/ruby/Bundler/Thor/Actions/CreateLink.md deleted file mode 100644 index 386b747..0000000 --- a/example/ruby/Bundler/Thor/Actions/CreateLink.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Bundler::Thor::Actions::CreateLink -**Inherits:** Bundler::Thor::Actions::CreateFile - - -CreateLink is a subset of CreateFile, which instead of taking a block of data, -just takes a source string from the user. - - -# Attributes -## data[RW] [](#attribute-i-data) -:nodoc: - - -#Instance Methods -## exists?() [](#method-i-exists?) - -**@return** [Boolean] - -## identical?() [](#method-i-identical?) -Checks if the content of the file at the destination is identical to the -rendered result. - -#### Returns -Boolean -: true if it is identical, false otherwise. - - -**@return** [Boolean] - -## invoke!() [](#method-i-invoke!) - diff --git a/example/ruby/Bundler/Thor/Actions/Directory.md b/example/ruby/Bundler/Thor/Actions/Directory.md deleted file mode 100644 index 2750563..0000000 --- a/example/ruby/Bundler/Thor/Actions/Directory.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Bundler::Thor::Actions::Directory -**Inherits:** Bundler::Thor::Actions::EmptyDirectory - - -:nodoc: - - -# Attributes -## source[RW] [](#attribute-i-source) -Returns the value of attribute source. - - -#Instance Methods -## initialize(base, source, destinationnil, config{}, &block) [](#method-i-initialize) - -**@return** [Directory] a new instance of Directory - -## invoke!() [](#method-i-invoke!) - -## revoke!() [](#method-i-revoke!) - diff --git a/example/ruby/Bundler/Thor/Actions/EmptyDirectory.md b/example/ruby/Bundler/Thor/Actions/EmptyDirectory.md deleted file mode 100644 index 1ef9282..0000000 --- a/example/ruby/Bundler/Thor/Actions/EmptyDirectory.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: Bundler::Thor::Actions::EmptyDirectory -**Inherits:** Object - - -Class which holds create directory logic. This is the base class for other -actions like create_file and directory. - -This implementation is based in Templater actions, created by Jonas Nicklas -and Michael S. Klishin under MIT LICENSE. - - -# Attributes -## base[RW] [](#attribute-i-base) -:nodoc: - -## config[RW] [](#attribute-i-config) -:nodoc: - -## destination[RW] [](#attribute-i-destination) -:nodoc: - -## given_destination[RW] [](#attribute-i-given_destination) -:nodoc: - -## relative_destination[RW] [](#attribute-i-relative_destination) -:nodoc: - - -#Instance Methods -## exists?() [](#method-i-exists?) -Checks if the destination file already exists. - -#### Returns -Boolean -: true if the file exists, false otherwise. - - -**@return** [Boolean] - -## initialize(base, destination, config{}) [](#method-i-initialize) -Initializes given the source and destination. - -#### Parameters -base -: A Bundler::Thor::Base instance - -source -: Relative path to the source of this file - -destination -: Relative path to the destination of this file - -config -: give :verbose => false to not log the status. - - -**@return** [EmptyDirectory] a new instance of EmptyDirectory - -## invoke!() [](#method-i-invoke!) - -## revoke!() [](#method-i-revoke!) - diff --git a/example/ruby/Bundler/Thor/Actions/InjectIntoFile.md b/example/ruby/Bundler/Thor/Actions/InjectIntoFile.md deleted file mode 100644 index a0023f2..0000000 --- a/example/ruby/Bundler/Thor/Actions/InjectIntoFile.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Bundler::Thor::Actions::InjectIntoFile -**Inherits:** Bundler::Thor::Actions::EmptyDirectory - - -:nodoc: - - -# Attributes -## behavior[RW] [](#attribute-i-behavior) -Returns the value of attribute behavior. - -## flag[RW] [](#attribute-i-flag) -Returns the value of attribute flag. - -## replacement[RW] [](#attribute-i-replacement) -Returns the value of attribute replacement. - - -#Instance Methods -## initialize(base, destination, data, config) [](#method-i-initialize) - -**@return** [InjectIntoFile] a new instance of InjectIntoFile - -## invoke!() [](#method-i-invoke!) - -## revoke!() [](#method-i-revoke!) - diff --git a/example/ruby/Bundler/Thor/AmbiguousCommandError.md b/example/ruby/Bundler/Thor/AmbiguousCommandError.md deleted file mode 100644 index 6f5000a..0000000 --- a/example/ruby/Bundler/Thor/AmbiguousCommandError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Thor::AmbiguousCommandError -**Inherits:** Bundler::Thor::Error - - - - - diff --git a/example/ruby/Bundler/Thor/Argument.md b/example/ruby/Bundler/Thor/Argument.md deleted file mode 100644 index 2a38f6a..0000000 --- a/example/ruby/Bundler/Thor/Argument.md +++ /dev/null @@ -1,51 +0,0 @@ -# Class: Bundler::Thor::Argument -**Inherits:** Object - - -:nodoc: - - -# Attributes -## banner[RW] [](#attribute-i-banner) -Returns the value of attribute banner. - -## default[RW] [](#attribute-i-default) -Returns the value of attribute default. - -## description[RW] [](#attribute-i-description) -Returns the value of attribute description. - -## enum[RW] [](#attribute-i-enum) -Returns the value of attribute enum. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## required[RW] [](#attribute-i-required) -Returns the value of attribute required. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## enum_to_s() [](#method-i-enum_to_s) - -## initialize(name, options{}) [](#method-i-initialize) - -**@raise** [ArgumentError] - -**@return** [Argument] a new instance of Argument - -## print_default() [](#method-i-print_default) - -## required?() [](#method-i-required?) - -**@return** [Boolean] - -## show_default?() [](#method-i-show_default?) - -**@return** [Boolean] - -## usage() [](#method-i-usage) - diff --git a/example/ruby/Bundler/Thor/Arguments.md b/example/ruby/Bundler/Thor/Arguments.md deleted file mode 100644 index 61188c3..0000000 --- a/example/ruby/Bundler/Thor/Arguments.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Bundler::Thor::Arguments -**Inherits:** Object - - -:nodoc: - - -# Class Methods -## parse(*args ) [](#method-c-parse) -## split(args ) [](#method-c-split) -Receives an array of args and returns two arrays, one with arguments and one -with switches. - -#Instance Methods -## initialize(arguments[]) [](#method-i-initialize) -Takes an array of Bundler::Thor::Argument objects. - -**@return** [Arguments] a new instance of Arguments - -## parse(args) [](#method-i-parse) - -## remaining() [](#method-i-remaining) - diff --git a/example/ruby/Bundler/Thor/AtLeastOneRequiredArgumentError.md b/example/ruby/Bundler/Thor/AtLeastOneRequiredArgumentError.md deleted file mode 100644 index dfe53c7..0000000 --- a/example/ruby/Bundler/Thor/AtLeastOneRequiredArgumentError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Thor::AtLeastOneRequiredArgumentError -**Inherits:** Bundler::Thor::InvocationError - - - - - diff --git a/example/ruby/Bundler/Thor/Base.md b/example/ruby/Bundler/Thor/Base.md deleted file mode 100644 index d68fb02..0000000 --- a/example/ruby/Bundler/Thor/Base.md +++ /dev/null @@ -1,62 +0,0 @@ -# Module: Bundler::Thor::Base - - - - -# Class Methods -## included(base ) [](#method-c-included) -:nodoc: -## register_klass_file(klass ) [](#method-c-register_klass_file) -Whenever a class inherits from Bundler::Thor or Bundler::Thor::Group, we -should track the class and the file on Bundler::Thor::Base. This is the method -responsible for it. -## subclass_files() [](#method-c-subclass_files) -Returns the files where the subclasses are kept. - -#### Returns -Hash[path => Class] -## subclasses() [](#method-c-subclasses) -Returns the classes that inherits from Bundler::Thor or Bundler::Thor::Group. - -#### Returns -[Array](Class) -# Attributes -## shell[RW] [](#attribute-c-shell) -Returns the shell used in all Bundler::Thor classes. If you are in a Unix -platform it will use a colored log, otherwise it will use a basic one without -color. - -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## parent_options[RW] [](#attribute-i-parent_options) -Returns the value of attribute parent_options. - - -#Instance Methods -## initialize(args[], local_options{}, config{}) [](#method-i-initialize) -It receives arguments in an Array and two hashes, one for options and other -for configuration. - -Notice that it does not check if all required arguments were supplied. It -should be done by the parser. - -#### Parameters -[args -: An array of objects. The objects are applied to their respective accessors - declared with `argument`. - - -options -: An options hash that will be available as self.options. The hash given is - converted to a hash with indifferent access, magic predicates - (options.skip?) and then frozen. - - -config -: Configuration for this Bundler::Thor class. - - diff --git a/example/ruby/Bundler/Thor/Base/ClassMethods.md b/example/ruby/Bundler/Thor/Base/ClassMethods.md deleted file mode 100644 index 136142f..0000000 --- a/example/ruby/Bundler/Thor/Base/ClassMethods.md +++ /dev/null @@ -1,386 +0,0 @@ -# Module: Bundler::Thor::Base::ClassMethods - - - - - -#Instance Methods -## all_commands() [](#method-i-all_commands) -Returns the commands for this Bundler::Thor class and all subclasses. - -#### Returns -Hash -: An ordered hash with commands names as keys and Bundler::Thor::Command - objects as values. - - -## allow_incompatible_default_type!() [](#method-i-allow_incompatible_default_type!) -If you want to use defaults that don't match the type of an option, either -specify `check_default_type: false` or call `allow_incompatible_default_type!` - -## argument(name, options{}) [](#method-i-argument) -Adds an argument to the class and creates an attr_accessor for it. - -Arguments are different from options in several aspects. The first one is how -they are parsed from the command line, arguments are retrieved from position: - - thor command NAME - -Instead of: - - thor command --name=NAME - -Besides, arguments are used inside your code as an accessor (self.argument), -while options are all kept in a hash (self.options). - -Finally, arguments cannot have type :default or :boolean but can be optional -(supplying :optional => :true or :required => false), although you cannot have -a required argument after a non-required argument. If you try it, an error is -raised. - -#### Parameters -name -: The name of the argument. - -options -: Described below. - - -#### Options -:desc - Description for the argument. :required - If the argument is -required or not. :optional - If the argument is optional or not. :type - -The type of the argument, can be :string, :hash, :array, :numeric. :default - -Default value for this argument. It cannot be required and have default -values. :banner - String to show on usage notes. - -#### Errors -ArgumentError -: Raised if you supply a required argument after a non required one. - - -## arguments() [](#method-i-arguments) -Returns this class arguments, looking up in the ancestors chain. - -#### Returns -[Array](Bundler::Thor::Argument) - -## attr_accessor() [](#method-i-attr_accessor) -:nodoc: - -## attr_reader() [](#method-i-attr_reader) -:nodoc: - -## attr_writer() [](#method-i-attr_writer) -:nodoc: - -## check_default_type() [](#method-i-check_default_type) -:nodoc: - -## check_default_type!() [](#method-i-check_default_type!) -If you want to raise an error when the default value of an option does not -match the type call check_default_type! This will be the default; for -compatibility a deprecation warning is issued if necessary. - -## check_unknown_options() [](#method-i-check_unknown_options) -:nodoc: - -## check_unknown_options!() [](#method-i-check_unknown_options!) -If you want to raise an error for unknown options, call check_unknown_options! -This is disabled by default to allow dynamic invocations. - -## check_unknown_options?(config) [](#method-i-check_unknown_options?) -:nodoc: - -**@return** [Boolean] - -## class_at_least_one(*args, &block) [](#method-i-class_at_least_one) -Adds and declares option group for required at least one of options in the -block and arguments. You can declare options as the outside of the block. - -#### Examples - - class_at_least_one do - class_option :one - class_option :two - end - -Or - - class_option :one - class_option :two - class_at_least_one :one, :two - -If you do not give "--one" and "--two" AtLeastOneRequiredArgumentError will be -raised. - -You can use class_at_least_one and class_exclusive at the same time. - - class_exclusive do - class_at_least_one do - class_option :one - class_option :two - end - end - -Then it is required either only one of "--one" or "--two". - -## class_at_least_one_option_names() [](#method-i-class_at_least_one_option_names) -Returns this class at least one of required options array set, looking up in -the ancestors chain. - -#### Returns -[Array[Array](Bundler::Thor::Option.name)] - -## class_exclusive(*args, &block) [](#method-i-class_exclusive) -Adds and declares option group for exclusive options in the block and -arguments. You can declare options as the outside of the block. - -#### Parameters -[Array](Bundler::Thor::Option.name) - -#### Examples - - class_exclusive do - class_option :one - class_option :two - end - -Or - - class_option :one - class_option :two - class_exclusive :one, :two - -If you give "--one" and "--two" at the same time ExclusiveArgumentsError will -be raised. - -## class_exclusive_option_names() [](#method-i-class_exclusive_option_names) -Returns this class exclusive options array set, looking up in the ancestors -chain. - -#### Returns -[Array[Array](Bundler::Thor::Option.name)] - -## class_option(name, options{}) [](#method-i-class_option) -Adds an option to the set of class options - -#### Parameters -name -: The name of the argument. - -options -: Described below. - - -#### Options -:desc -: -- Description for the argument. - -:required -: -- If the argument is required or not. - -:default -: -- Default value for this argument. - -:group -: -- The group for this options. Use by class options to output options in - different levels. - -:aliases -: -- Aliases for this option. **Note:** Bundler::Thor follows a convention - of one-dash-one-letter options. Thus aliases like "-something" wouldn't be - parsed; use either "--something" or "-s" instead. - -:type -: -- The type of the argument, can be :string, :hash, :array, :numeric or - :boolean. - -:banner -: -- String to show on usage notes. - -:hide -: -- If you want to hide this option from the help. - - -## class_options(optionsnil) [](#method-i-class_options) -Adds a bunch of options to the set of class options. - - class_options :foo => false, :bar => :required, :baz => :string - -If you prefer more detailed declaration, check class_option. - -#### Parameters -Hash[Symbol => Object] - -## commands() [](#method-i-commands) -Returns the commands for this Bundler::Thor class. - -#### Returns -Hash -: An ordered hash with commands names as keys and Bundler::Thor::Command - objects as values. - - -## disable_required_check?(command_name) [](#method-i-disable_required_check?) -If true, option set will not suspend the execution of the command when a -required option is not provided. - -**@return** [Boolean] - -## exit_on_failure?() [](#method-i-exit_on_failure?) -A flag that makes the process exit with status 1 if any error happens. - -**@return** [Boolean] - -## group(namenil) [](#method-i-group) -Defines the group. This is used when thor list is invoked so you can specify -that only commands from a pre-defined group will be shown. Defaults to -standard. - -#### Parameters -name - -## handle_argument_error(command, error, args, arity) [](#method-i-handle_argument_error) -:nodoc: - -**@raise** [InvocationError] - -## handle_no_command_error(command, has_namespace$thor_runner) [](#method-i-handle_no_command_error) -:nodoc: - -**@raise** [UndefinedCommandError] - -## namespace(namenil) [](#method-i-namespace) -Sets the namespace for the Bundler::Thor or Bundler::Thor::Group class. By -default the namespace is retrieved from the class name. If your Bundler::Thor -class is named Scripts::MyScript, the help method, for example, will be called -as: - - thor scripts:my_script -h - -If you change the namespace: - - namespace :my_scripts - -You change how your commands are invoked: - - thor my_scripts -h - -Finally, if you change your namespace to default: - - namespace :default - -Your commands can be invoked with a shortcut. Instead of: - - thor :my_command - -## no_commands(&block) [](#method-i-no_commands) -All methods defined inside the given block are not added as commands. - -So you can do: - - class MyScript < Bundler::Thor - no_commands do - def this_is_not_a_command - end - end - end - -You can also add the method and remove it from the command list: - - class MyScript < Bundler::Thor - def this_is_not_a_command - end - remove_command :this_is_not_a_command - end - -## no_commands?() [](#method-i-no_commands?) - -**@return** [Boolean] - -## no_commands_context() [](#method-i-no_commands_context) - -## public_command(*names) [](#method-i-public_command) -Allows to use private methods from parent in child classes as commands. - -#### Parameters - names:: Method names to be used as commands - -#### Examples - - public_command :foo - public_command :foo, :bar, :baz - -## remove_argument(*names) [](#method-i-remove_argument) -Removes a previous defined argument. If :undefine is given, undefine accessors -as well. - -#### Parameters -names -: Arguments to be removed - - -#### Examples - - remove_argument :foo - remove_argument :foo, :bar, :baz, :undefine => true - -## remove_class_option(*names) [](#method-i-remove_class_option) -Removes a previous defined class option. - -#### Parameters -names -: Class options to be removed - - -#### Examples - - remove_class_option :foo - remove_class_option :foo, :bar, :baz - -## remove_command(*names) [](#method-i-remove_command) -Removes a given command from this Bundler::Thor class. This is usually done if -you are inheriting from another class and don't want it to be available -anymore. - -By default it only remove the mapping to the command. But you can supply -:undefine => true to undefine the method from the class as well. - -#### Parameters -name -: The name of the command to be removed - -options -: You can give :undefine => true if you want commands the method to be - undefined from the class as well. - - -## start(given_argsARGV, config{}) [](#method-i-start) -Parses the command and options from the given args, instantiate the class and -invoke the command. This method is used when the arguments must be parsed from -an array. If you are inside Ruby and want to use a Bundler::Thor class, you -can simply initialize it: - - script = MyScript.new(args, options, config) - script.invoke(:command, first_arg, second_arg, third_arg) - -## stop_on_unknown_option?(command_name) [](#method-i-stop_on_unknown_option?) -If true, option parsing is suspended as soon as an unknown option or a regular -argument is encountered. All remaining arguments are passed to the command as -regular arguments. - -**@return** [Boolean] - -## strict_args_position() [](#method-i-strict_args_position) -:nodoc: - -## strict_args_position!() [](#method-i-strict_args_position!) -If you want only strict string args (useful when cascading thor classes), call -strict_args_position! This is disabled by default to allow dynamic -invocations. - -## strict_args_position?(config) [](#method-i-strict_args_position?) -:nodoc: - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/Thor/Command.md b/example/ruby/Bundler/Thor/Command.md deleted file mode 100644 index 4424765..0000000 --- a/example/ruby/Bundler/Thor/Command.md +++ /dev/null @@ -1,74 +0,0 @@ -# Class: Bundler::Thor::Command -**Inherits:** Struct - - - - -# Attributes -## ancestor_name[RW] [](#attribute-i-ancestor_name) -Returns the value of attribute ancestor_name - -**@return** [Object] the current value of ancestor_name - -## description[RW] [](#attribute-i-description) -Returns the value of attribute description - -**@return** [Object] the current value of description - -## long_description[RW] [](#attribute-i-long_description) -Returns the value of attribute long_description - -**@return** [Object] the current value of long_description - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name - -**@return** [Object] the current value of name - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options - -**@return** [Object] the current value of options - -## options_relation[RW] [](#attribute-i-options_relation) -Returns the value of attribute options_relation - -**@return** [Object] the current value of options_relation - -## usage[RW] [](#attribute-i-usage) -Returns the value of attribute usage - -**@return** [Object] the current value of usage - -## wrap_long_description[RW] [](#attribute-i-wrap_long_description) -Returns the value of attribute wrap_long_description - -**@return** [Object] the current value of wrap_long_description - - -#Instance Methods -## formatted_usage(klass, namespacetrue, subcommandfalse) [](#method-i-formatted_usage) -Returns the formatted usage by injecting given required arguments and required -options into the given usage. - -## hidden?() [](#method-i-hidden?) - -**@return** [Boolean] - -## initialize(name, description, long_description, wrap_long_description, usage, optionsnil, options_relationnil) [](#method-i-initialize) - -**@return** [Command] a new instance of Command - -## initialize_copy(other) [](#method-i-initialize_copy) -:nodoc: - -## method_at_least_one_option_names() [](#method-i-method_at_least_one_option_names) -:nodoc: - -## method_exclusive_option_names() [](#method-i-method_exclusive_option_names) -:nodoc: - -## run(instance, args[]) [](#method-i-run) -By default, a command invokes a method in the thor class. You can change this -implementation to create custom commands. - diff --git a/example/ruby/Bundler/Thor/CoreExt.md b/example/ruby/Bundler/Thor/CoreExt.md deleted file mode 100644 index 758aa7e..0000000 --- a/example/ruby/Bundler/Thor/CoreExt.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Bundler::Thor::CoreExt - - -:nodoc: - - - diff --git a/example/ruby/Bundler/Thor/CoreExt/HashWithIndifferentAccess.md b/example/ruby/Bundler/Thor/CoreExt/HashWithIndifferentAccess.md deleted file mode 100644 index 15d91ae..0000000 --- a/example/ruby/Bundler/Thor/CoreExt/HashWithIndifferentAccess.md +++ /dev/null @@ -1,51 +0,0 @@ -# Class: Bundler::Thor::CoreExt::HashWithIndifferentAccess -**Inherits:** Hash - - -A hash with indifferent access and magic predicates. - - hash = Bundler::Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true - - hash[:foo] #=> 'bar' - hash['foo'] #=> 'bar' - hash.foo? #=> true - - - -#Instance Methods -## [](key) [](#method-i-[]) - -## []=(key, value) [](#method-i-[]=) - -## delete(key) [](#method-i-delete) - -## except(*keys) [](#method-i-except) - -## fetch(key, *args) [](#method-i-fetch) - -## initialize(hash{}) [](#method-i-initialize) -:nodoc: - -**@return** [HashWithIndifferentAccess] a new instance of HashWithIndifferentAccess - -## key?(key) [](#method-i-key?) - -**@return** [Boolean] - -## merge(other) [](#method-i-merge) - -## merge!(other) [](#method-i-merge!) - -## replace(other_hash) [](#method-i-replace) - -## reverse_merge(other) [](#method-i-reverse_merge) - -## reverse_merge!(other_hash) [](#method-i-reverse_merge!) - -## slice(*keys) [](#method-i-slice) - -## to_hash() [](#method-i-to_hash) -Convert to a Hash with String keys. - -## values_at(*indices) [](#method-i-values_at) - diff --git a/example/ruby/Bundler/Thor/DynamicCommand.md b/example/ruby/Bundler/Thor/DynamicCommand.md deleted file mode 100644 index f802041..0000000 --- a/example/ruby/Bundler/Thor/DynamicCommand.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Bundler::Thor::DynamicCommand -**Inherits:** Bundler::Thor::Command - - -A dynamic command that handles method missing scenarios. - - - -#Instance Methods -## initialize(name, optionsnil) [](#method-i-initialize) - -**@return** [DynamicCommand] a new instance of DynamicCommand - -## run(instance, args[]) [](#method-i-run) - diff --git a/example/ruby/Bundler/Thor/Error.md b/example/ruby/Bundler/Thor/Error.md deleted file mode 100644 index 5605202..0000000 --- a/example/ruby/Bundler/Thor/Error.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: Bundler::Thor::Error -**Inherits:** StandardError - - -Bundler::Thor::Error is raised when it's caused by wrong usage of thor -classes. Those errors have their backtrace suppressed and are nicely shown to -the user. - -Errors that are caused by the developer, like declaring a method which -overwrites a thor keyword, SHOULD NOT raise a Bundler::Thor::Error. This way, -we ensure that developer errors are shown with full backtrace. - - - diff --git a/example/ruby/Bundler/Thor/ExclusiveArgumentError.md b/example/ruby/Bundler/Thor/ExclusiveArgumentError.md deleted file mode 100644 index 66a2a60..0000000 --- a/example/ruby/Bundler/Thor/ExclusiveArgumentError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Thor::ExclusiveArgumentError -**Inherits:** Bundler::Thor::InvocationError - - - - - diff --git a/example/ruby/Bundler/Thor/Group.md b/example/ruby/Bundler/Thor/Group.md deleted file mode 100644 index 1b7c460..0000000 --- a/example/ruby/Bundler/Thor/Group.md +++ /dev/null @@ -1,128 +0,0 @@ -# Class: Bundler::Thor::Group -**Inherits:** Object - -**Includes:** Bundler::Thor::Base - - -Bundler::Thor has a special class called Bundler::Thor::Group. The main -difference to Bundler::Thor class is that it invokes all commands at once. It -also include some methods that allows invocations to be done at the class -method, which are not available to Bundler::Thor commands. - - -# Class Methods -## class_options_help(shell , groups {}) [](#method-c-class_options_help) -Overwrite class options help to allow invoked generators options to be shown -recursively when invoking a generator. -## command_exists?(command_name ) [](#method-c-command_exists?) -Checks if a specified command exists. - -#### Parameters -command_name -: The name of the command to check for existence. - - -#### Returns -Boolean -: `true` if the command exists, `false` otherwise. - -**@return** [Boolean] - -## desc(description nil) [](#method-c-desc) -The description for this Bundler::Thor::Group. If none is provided, but a -source root exists, tries to find the USAGE one folder above it, otherwise -searches in the superclass. - -#### Parameters -description -: The description for this Bundler::Thor::Group. - -## get_options_from_invocations(group_options , base_options ) [](#method-c-get_options_from_invocations) -Get invocations array and merge options from invocations. Those options are -added to group_options hash. Options that already exists in base_options are -not added twice. -## handle_argument_error(command , error , _args , arity ) [](#method-c-handle_argument_error) -:nodoc: -**@raise** [error] - -## help(shell ) [](#method-c-help) -Prints help information. - -#### Options -short -: When true, shows only usage. - -## invocation_blocks() [](#method-c-invocation_blocks) -Stores invocation blocks used on invoke_from_option. -## invocations() [](#method-c-invocations) -Stores invocations for this class merging with superclass values. -## invoke(*names , &block ) [](#method-c-invoke) -Invoke the given namespace or class given. It adds an instance method that -will invoke the klass and command. You can give a block to configure how it -will be invoked. - -The namespace/class given will have its options showed on the help usage. -Check invoke_from_option for more information. -## invoke_from_option(*names , &block ) [](#method-c-invoke_from_option) -Invoke a thor class based on the value supplied by the user to the given -option named "name". A class option must be created before this method is -invoked for each name given. - -#### Examples - - class GemGenerator < Bundler::Thor::Group - class_option :test_framework, :type => :string - invoke_from_option :test_framework - end - -#### Boolean options - -In some cases, you want to invoke a thor class if some option is true or -false. This is automatically handled by invoke_from_option. Then the option -name is used to invoke the generator. - -#### Preparing for invocation - -In some cases you want to customize how a specified hook is going to be -invoked. You can do that by overwriting the class method -prepare_for_invocation. The class method must necessarily return a klass and -an optional command. - -#### Custom invocations - -You can also supply a block to customize how the option is going to be -invoked. The block receives two parameters, an instance of the current class -and the klass to be invoked. -## printable_commands() [](#method-c-printable_commands) -Returns commands ready to be printed. -## remove_invocation(*names ) [](#method-c-remove_invocation) -Remove a previously added invocation. - -#### Examples - - remove_invocation :test_framework - -#Instance Methods -## initialize(args[], local_options{}, config{}) [](#method-i-initialize) -It receives arguments in an Array and two hashes, one for options and other -for configuration. - -Notice that it does not check if all required arguments were supplied. It -should be done by the parser. - -#### Parameters -[args -: An array of objects. The objects are applied to their respective accessors - declared with `argument`. - - -options -: An options hash that will be available as self.options. The hash given is - converted to a hash with indifferent access, magic predicates - (options.skip?) and then frozen. - - -config -: Configuration for this Bundler::Thor class. - - diff --git a/example/ruby/Bundler/Thor/HiddenCommand.md b/example/ruby/Bundler/Thor/HiddenCommand.md deleted file mode 100644 index 091dcd5..0000000 --- a/example/ruby/Bundler/Thor/HiddenCommand.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Bundler::Thor::HiddenCommand -**Inherits:** Bundler::Thor::Command - - -A command that is hidden in help messages but still invocable. - - - -#Instance Methods -## hidden?() [](#method-i-hidden?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/Thor/Invocation.md b/example/ruby/Bundler/Thor/Invocation.md deleted file mode 100644 index 298d9bb..0000000 --- a/example/ruby/Bundler/Thor/Invocation.md +++ /dev/null @@ -1,96 +0,0 @@ -# Module: Bundler::Thor::Invocation - - - - -# Class Methods -## included(base ) [](#method-c-included) -:nodoc: - -#Instance Methods -## current_command_chain() [](#method-i-current_command_chain) -Make the current command chain accessible with in a Bundler::Thor-(sub)command - -## initialize(args[], options{}, config{}, &block) [](#method-i-initialize) -Make initializer aware of invocations and the initialization args. - -## invoke(namenil, *args) [](#method-i-invoke) -Receives a name and invokes it. The name can be a string (either "command" or -"namespace:command"), a Bundler::Thor::Command, a Class or a Bundler::Thor -instance. If the command cannot be guessed by name, it can also be supplied as -second argument. - -You can also supply the arguments, options and configuration values for the -command to be invoked, if none is given, the same values used to initialize -the invoker are used to initialize the invoked. - -When no name is given, it will invoke the default command of the current -class. - -#### Examples - - class A < Bundler::Thor - def foo - invoke :bar - invoke "b:hello", ["Erik"] - end - - def bar - invoke "b:hello", ["Erik"] - end - end - - class B < Bundler::Thor - def hello(name) - puts "hello #{name}" - end - end - -You can notice that the method "foo" above invokes two commands: "bar", which -belongs to the same class and "hello" which belongs to the class B. - -By using an invocation system you ensure that a command is invoked only once. -In the example above, invoking "foo" will invoke "b:hello" just once, even if -it's invoked later by "bar" method. - -When class A invokes class B, all arguments used on A initialization are -supplied to B. This allows lazy parse of options. Let's suppose you have some -rspec commands: - - class Rspec < Bundler::Thor::Group - class_option :mock_framework, :type => :string, :default => :rr - - def invoke_mock_framework - invoke "rspec:#{options[:mock_framework]}" - end - end - -As you noticed, it invokes the given mock framework, which might have its own -options: - - class Rspec::RR < Bundler::Thor::Group - class_option :style, :type => :string, :default => :mock - end - -Since it's not rspec concern to parse mock framework options, when RR is -invoked all options are parsed again, so RR can extract only the options that -it's going to use. - -If you want Rspec::RR to be initialized with its own set of options, you have -to do that explicitly: - - invoke "rspec:rr", [], :style => :foo - -Besides giving an instance, you can also give a class to invoke: - - invoke Rspec::RR, [], :style => :foo - -## invoke_all() [](#method-i-invoke_all) -Invoke all commands for the current instance. - -## invoke_command(command, *args) [](#method-i-invoke_command) -Invoke the given command if the given args. - -## invoke_with_padding(*args) [](#method-i-invoke_with_padding) -Invokes using shell padding. - diff --git a/example/ruby/Bundler/Thor/Invocation/ClassMethods.md b/example/ruby/Bundler/Thor/Invocation/ClassMethods.md deleted file mode 100644 index 0b997b0..0000000 --- a/example/ruby/Bundler/Thor/Invocation/ClassMethods.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Bundler::Thor::Invocation::ClassMethods - - - - - -#Instance Methods -## prepare_for_invocation(key, name) [](#method-i-prepare_for_invocation) -This method is responsible for receiving a name and find the proper class and -command for it. The key is an optional parameter which is available only in -class methods invocations (i.e. in Bundler::Thor::Group). - diff --git a/example/ruby/Bundler/Thor/InvocationError.md b/example/ruby/Bundler/Thor/InvocationError.md deleted file mode 100644 index 1fbd7b4..0000000 --- a/example/ruby/Bundler/Thor/InvocationError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::Thor::InvocationError -**Inherits:** Bundler::Thor::Error - - -Raised when a command was found, but not invoked properly. - - - diff --git a/example/ruby/Bundler/Thor/LineEditor.md b/example/ruby/Bundler/Thor/LineEditor.md deleted file mode 100644 index 4488707..0000000 --- a/example/ruby/Bundler/Thor/LineEditor.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bundler::Thor::LineEditor - - - - -# Class Methods -## best_available() [](#method-c-best_available) -## readline(prompt , options {}) [](#method-c-readline) - diff --git a/example/ruby/Bundler/Thor/LineEditor/Basic.md b/example/ruby/Bundler/Thor/LineEditor/Basic.md deleted file mode 100644 index f153f97..0000000 --- a/example/ruby/Bundler/Thor/LineEditor/Basic.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Bundler::Thor::LineEditor::Basic -**Inherits:** Object - - - - -# Class Methods -## available?() [](#method-c-available?) -**@return** [Boolean] - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## prompt[RW] [](#attribute-i-prompt) -Returns the value of attribute prompt. - - -#Instance Methods -## initialize(prompt, options) [](#method-i-initialize) - -**@return** [Basic] a new instance of Basic - -## readline() [](#method-i-readline) - diff --git a/example/ruby/Bundler/Thor/LineEditor/Readline.md b/example/ruby/Bundler/Thor/LineEditor/Readline.md deleted file mode 100644 index a5641ef..0000000 --- a/example/ruby/Bundler/Thor/LineEditor/Readline.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::Thor::LineEditor::Readline -**Inherits:** Bundler::Thor::LineEditor::Basic - - - - -# Class Methods -## available?() [](#method-c-available?) -**@return** [Boolean] - - -#Instance Methods -## readline() [](#method-i-readline) - diff --git a/example/ruby/Bundler/Thor/LineEditor/Readline/PathCompletion.md b/example/ruby/Bundler/Thor/LineEditor/Readline/PathCompletion.md deleted file mode 100644 index 852dd56..0000000 --- a/example/ruby/Bundler/Thor/LineEditor/Readline/PathCompletion.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::Thor::LineEditor::Readline::PathCompletion -**Inherits:** Object - - - - - -#Instance Methods -## initialize(text) [](#method-i-initialize) - -**@return** [PathCompletion] a new instance of PathCompletion - -## matches() [](#method-i-matches) - diff --git a/example/ruby/Bundler/Thor/MalformattedArgumentError.md b/example/ruby/Bundler/Thor/MalformattedArgumentError.md deleted file mode 100644 index 645abba..0000000 --- a/example/ruby/Bundler/Thor/MalformattedArgumentError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Thor::MalformattedArgumentError -**Inherits:** Bundler::Thor::InvocationError - - - - - diff --git a/example/ruby/Bundler/Thor/NestedContext.md b/example/ruby/Bundler/Thor/NestedContext.md deleted file mode 100644 index 0bf0fd4..0000000 --- a/example/ruby/Bundler/Thor/NestedContext.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Bundler::Thor::NestedContext -**Inherits:** Object - - - - - -#Instance Methods -## enter() [](#method-i-enter) - -## entered?() [](#method-i-entered?) - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [NestedContext] a new instance of NestedContext - diff --git a/example/ruby/Bundler/Thor/Option.md b/example/ruby/Bundler/Thor/Option.md deleted file mode 100644 index f56065a..0000000 --- a/example/ruby/Bundler/Thor/Option.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: Bundler::Thor::Option -**Inherits:** Bundler::Thor::Argument - - -:nodoc: - - -# Class Methods -## parse(key , value ) [](#method-c-parse) -This parse quick options given as method_options. It makes several -assumptions, but you can be more specific using the option method. - - parse :foo => "bar" - #=> Option foo with default value bar - - parse [:foo, :baz] => "bar" - #=> Option foo with default value bar and alias :baz - - parse :foo => :required - #=> Required option foo without default value - - parse :foo => 2 - #=> Option foo with default value 2 and type numeric - - parse :foo => :numeric - #=> Option foo without default value and type numeric - - parse :foo => true - #=> Option foo with default value true and type boolean - -The valid types are :boolean, :numeric, :hash, :array and :string. If none is -given a default type is assumed. This default type accepts arguments as string -(--foo=value) or booleans (just --foo). - -By default all options are optional, unless :required is given. -# Attributes -## aliases[RW] [](#attribute-i-aliases) -Returns the value of attribute aliases. - -## group[RW] [](#attribute-i-group) -Returns the value of attribute group. - -## hide[RW] [](#attribute-i-hide) -Returns the value of attribute hide. - -## lazy_default[RW] [](#attribute-i-lazy_default) -Returns the value of attribute lazy_default. - -## repeatable[RW] [](#attribute-i-repeatable) -Returns the value of attribute repeatable. - - -#Instance Methods -## aliases_for_usage() [](#method-i-aliases_for_usage) - -## human_name() [](#method-i-human_name) - -## initialize(name, options{}) [](#method-i-initialize) - -**@return** [Option] a new instance of Option - -## show_default?() [](#method-i-show_default?) - -**@return** [Boolean] - -## switch_name() [](#method-i-switch_name) - -## usage(padding0) [](#method-i-usage) - diff --git a/example/ruby/Bundler/Thor/Options.md b/example/ruby/Bundler/Thor/Options.md deleted file mode 100644 index 00a397d..0000000 --- a/example/ruby/Bundler/Thor/Options.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Bundler::Thor::Options -**Inherits:** Bundler::Thor::Arguments - - -:nodoc: - - -# Class Methods -## to_switches(options ) [](#method-c-to_switches) -Receives a hash and makes it switches. - -#Instance Methods -## check_at_least_one!() [](#method-i-check_at_least_one!) - -## check_exclusive!() [](#method-i-check_exclusive!) - -## check_unknown!() [](#method-i-check_unknown!) - -**@raise** [UnknownArgumentError] - -## initialize(hash_options{}, defaults{}, stop_on_unknownfalse, disable_required_checkfalse, relations{}) [](#method-i-initialize) -Takes a hash of Bundler::Thor::Option and a hash with defaults. - -If `stop_on_unknown` is true, #parse will stop as soon as it encounters an -unknown option or a regular argument. - -**@return** [Options] a new instance of Options - -## parse(args) [](#method-i-parse) -rubocop:disable Metrics/MethodLength - -## peek() [](#method-i-peek) - -## remaining() [](#method-i-remaining) - -## shift() [](#method-i-shift) - -## unshift(arg, is_value:false) [](#method-i-unshift) - diff --git a/example/ruby/Bundler/Thor/RakeCompat.md b/example/ruby/Bundler/Thor/RakeCompat.md deleted file mode 100644 index 78e819e..0000000 --- a/example/ruby/Bundler/Thor/RakeCompat.md +++ /dev/null @@ -1,27 +0,0 @@ -# Module: Bundler::Thor::RakeCompat - -**Includes:** Rake::DSL - - -Adds a compatibility layer to your Bundler::Thor classes which allows you to -use rake package tasks. For example, to use rspec rake tasks, one can do: - - require 'bundler/vendor/thor/lib/thor/rake_compat' - require 'rspec/core/rake_task' - - class Default < Bundler::Thor - include Bundler::Thor::RakeCompat - - RSpec::Core::RakeTask.new(:spec) do |t| - t.spec_opts = ['--options', './.rspec'] - t.spec_files = FileList['spec/**/*_spec.rb'] - end - end - - -# Class Methods -## included(base ) [](#method-c-included) -**@private** [] - -## rake_classes() [](#method-c-rake_classes) - diff --git a/example/ruby/Bundler/Thor/RequiredArgumentMissingError.md b/example/ruby/Bundler/Thor/RequiredArgumentMissingError.md deleted file mode 100644 index 0eabff1..0000000 --- a/example/ruby/Bundler/Thor/RequiredArgumentMissingError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::Thor::RequiredArgumentMissingError -**Inherits:** Bundler::Thor::InvocationError - - - - - diff --git a/example/ruby/Bundler/Thor/Runner.md b/example/ruby/Bundler/Thor/Runner.md deleted file mode 100644 index f7fc8e8..0000000 --- a/example/ruby/Bundler/Thor/Runner.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Bundler::Thor::Runner -**Inherits:** Bundler::Thor - - -:nodoc: - - -# Class Methods -## banner(command , all false, subcommand false) [](#method-c-banner) -## exit_on_failure?() [](#method-c-exit_on_failure?) -**@return** [Boolean] - - -#Instance Methods -## help(methnil) [](#method-i-help) -Override Bundler::Thor#help so it can give information about any class and any -method. - -## install(name) [](#method-i-install) -rubocop:disable Metrics/MethodLength - -## installed() [](#method-i-installed) - -## list(search"") [](#method-i-list) - -## method_missing(meth, *args) [](#method-i-method_missing) -If a command is not found on Bundler::Thor::Runner, method missing is invoked -and Bundler::Thor::Runner is then responsible for finding the command in all -classes. - -## uninstall(name) [](#method-i-uninstall) - -**@raise** [Error] - -## update(name) [](#method-i-update) - -**@raise** [Error] - -## version() [](#method-i-version) - diff --git a/example/ruby/Bundler/Thor/Sandbox.md b/example/ruby/Bundler/Thor/Sandbox.md deleted file mode 100644 index b6c6ab8..0000000 --- a/example/ruby/Bundler/Thor/Sandbox.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Bundler::Thor::Sandbox - - -:nodoc: - - - diff --git a/example/ruby/Bundler/Thor/Shell.md b/example/ruby/Bundler/Thor/Shell.md deleted file mode 100644 index 988d6f1..0000000 --- a/example/ruby/Bundler/Thor/Shell.md +++ /dev/null @@ -1,31 +0,0 @@ -# Module: Bundler::Thor::Shell - - - - -# Attributes -## shell[RW] [](#attribute-i-shell) -Holds the shell for the given Bundler::Thor instance. If no shell is given, it -gets a default shell from Bundler::Thor::Base.shell. - - -#Instance Methods -## initialize(args[], options{}, config{}) [](#method-i-initialize) -Add shell to initialize config values. - -#### Configuration -shell -: An instance of the shell to be used. - - -#### Examples - - class MyScript < Bundler::Thor - argument :first, :type => :numeric - end - - MyScript.new [1.0], { :foo => :bar }, :shell => Bundler::Thor::Shell::Basic.new - -## with_padding() [](#method-i-with_padding) -Yields the given block with padding. - diff --git a/example/ruby/Bundler/Thor/Shell/Basic.md b/example/ruby/Bundler/Thor/Shell/Basic.md deleted file mode 100644 index c2befc7..0000000 --- a/example/ruby/Bundler/Thor/Shell/Basic.md +++ /dev/null @@ -1,151 +0,0 @@ -# Class: Bundler::Thor::Shell::Basic -**Inherits:** Object - - - - -# Attributes -## base[RW] [](#attribute-i-base) -Returns the value of attribute base. - -## padding[RW] [](#attribute-i-padding) -Returns the value of attribute padding. - - -#Instance Methods -## ask(statement, *args) [](#method-i-ask) -Asks something to the user and receives a response. - -If a default value is specified it will be presented to the user and allows -them to select that value with an empty response. This option is ignored when -limited answers are supplied. - -If asked to limit the correct responses, you can pass in an array of -acceptable answers. If one of those is not supplied, they will be shown a -message stating that one of those answers must be given and re-asked the -question. - -If asking for sensitive information, the :echo option can be set to false to -mask user input from $stdin. - -If the required input is a path, then set the path option to true. This will -enable tab completion for file paths relative to the current working directory -on systems that support Readline. - -#### Example - ask("What is your name?") - - ask("What is the planet furthest from the sun?", :default => "Neptune") - - ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"]) - - ask("What is your password?", :echo => false) - - ask("Where should the file be saved?", :path => true) - -## error(statement) [](#method-i-error) -Called if something goes wrong during the execution. This is used by -Bundler::Thor internally and should not be used inside your scripts. If -something went wrong, you can always raise an exception. If you raise a -Bundler::Thor::Error, it will be rescued and wrapped in the method below. - -## file_collision(destination) [](#method-i-file_collision) -Deals with file collision and returns true if the file should be overwritten -and false otherwise. If a block is given, it uses the block response as the -content for the diff. - -#### Parameters -destination -: the destination file to solve conflicts - -block -: an optional block that returns the value to be used in diff and merge - - -## indent(count1) [](#method-i-indent) -Sets the output padding while executing a block and resets it. - -## initialize() [](#method-i-initialize) -Initialize base, mute and padding to nil. - -**@return** [Basic] a new instance of Basic - -## mute() [](#method-i-mute) -Mute everything that's inside given block - -## mute?() [](#method-i-mute?) -Check if base is muted - -**@return** [Boolean] - -## no?(statement, colornil) [](#method-i-no?) -Asks the user a question and returns true if the user replies "n" or "no". - -**@return** [Boolean] - -## print_in_columns(array) [](#method-i-print_in_columns) -Prints values in columns - -#### Parameters -Array[String, String, ...] - -## print_table(array, options{}) [](#method-i-print_table) -Prints a table. - -#### Parameters -Array[Array[String, String, ...]] - -#### Options -indent -: Indent the first column by indent value. - -colwidth -: Force the first column to colwidth spaces wide. - -borders -: Adds ascii borders. - - -## print_wrapped(message, options{}) [](#method-i-print_wrapped) -Prints a long string, word-wrapping the text to the current width of the -terminal display. Ideal for printing heredocs. - -#### Parameters -String - -#### Options -indent -: Indent each line of the printed paragraph by indent value. - - -## say(message"", colornil, force_new_line(message.to_s !~ /( |\t)\Z/)) [](#method-i-say) -Say (print) something to the user. If the sentence ends with a whitespace or -tab character, a new line is not appended (print + flush). Otherwise are -passed straight to puts (behavior got from Highline). - -#### Example - say("I know you knew that.") - -## say_error(message"", colornil, force_new_line(message.to_s !~ /( |\t)\Z/)) [](#method-i-say_error) -Say (print) an error to the user. If the sentence ends with a whitespace or -tab character, a new line is not appended (print + flush). Otherwise are -passed straight to puts (behavior got from Highline). - -#### Example - say_error("error: something went wrong") - -## say_status(status, message, log_statustrue) [](#method-i-say_status) -Say a status with the given color and appends the message. Since this method -is used frequently by actions, it allows nil or false to be given in -log_status, avoiding the message from being shown. If a Symbol is given in -log_status, it's used as the color. - -## set_color(string) [](#method-i-set_color) -Apply color to the given string with optional bold. Disabled in the -Bundler::Thor::Shell::Basic class. - -## yes?(statement, colornil) [](#method-i-yes?) -Asks the user a question and returns true if the user replies "y" or "yes". - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/Thor/Shell/Color.md b/example/ruby/Bundler/Thor/Shell/Color.md deleted file mode 100644 index f72df3a..0000000 --- a/example/ruby/Bundler/Thor/Shell/Color.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Bundler::Thor::Shell::Color -**Inherits:** Bundler::Thor::Shell::Basic - - -Inherit from Bundler::Thor::Shell::Basic and add set_color behavior. Check -Bundler::Thor::Shell::Basic to see all available methods. - - - -#Instance Methods -## set_color(string, *colors) [](#method-i-set_color) -Set color by using a string or one of the defined constants. If a third option -is set to true, it also adds bold to the string. This is based on Highline -implementation and it automatically appends CLEAR to the end of the returned -String. - -Pass foreground, background and bold options to this method as symbols. - -Example: - - set_color "Hi!", :red, :on_white, :bold - -The available colors are: - - :bold - :black - :red - :green - :yellow - :blue - :magenta - :cyan - :white - :on_black - :on_red - :on_green - :on_yellow - :on_blue - :on_magenta - :on_cyan - :on_white - diff --git a/example/ruby/Bundler/Thor/Shell/ColumnPrinter.md b/example/ruby/Bundler/Thor/Shell/ColumnPrinter.md deleted file mode 100644 index acd9c16..0000000 --- a/example/ruby/Bundler/Thor/Shell/ColumnPrinter.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Bundler::Thor::Shell::ColumnPrinter -**Inherits:** Object - - - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## stdout[RW] [](#attribute-i-stdout) -Returns the value of attribute stdout. - - -#Instance Methods -## initialize(stdout, options{}) [](#method-i-initialize) - -**@return** [ColumnPrinter] a new instance of ColumnPrinter - -## print(array) [](#method-i-print) - diff --git a/example/ruby/Bundler/Thor/Shell/HTML.md b/example/ruby/Bundler/Thor/Shell/HTML.md deleted file mode 100644 index 4dca6f9..0000000 --- a/example/ruby/Bundler/Thor/Shell/HTML.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Bundler::Thor::Shell::HTML -**Inherits:** Bundler::Thor::Shell::Basic - - -Inherit from Bundler::Thor::Shell::Basic and add set_color behavior. Check -Bundler::Thor::Shell::Basic to see all available methods. - - - -#Instance Methods -## ask(statement, colornil) [](#method-i-ask) -Ask something to the user and receives a response. - -#### Example - ask("What is your name?") - -TODO: Implement #ask for Bundler::Thor::Shell::HTML - -**@raise** [NotImplementedError] - -## set_color(string, *colors) [](#method-i-set_color) -Set color by using a string or one of the defined constants. If a third option -is set to true, it also adds bold to the string. This is based on Highline -implementation and it automatically appends CLEAR to the end of the returned -String. - diff --git a/example/ruby/Bundler/Thor/Shell/TablePrinter.md b/example/ruby/Bundler/Thor/Shell/TablePrinter.md deleted file mode 100644 index 46421cb..0000000 --- a/example/ruby/Bundler/Thor/Shell/TablePrinter.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::Thor::Shell::TablePrinter -**Inherits:** Bundler::Thor::Shell::ColumnPrinter - - - - - -#Instance Methods -## initialize(stdout, options{}) [](#method-i-initialize) - -**@return** [TablePrinter] a new instance of TablePrinter - -## print(array) [](#method-i-print) - diff --git a/example/ruby/Bundler/Thor/Shell/Terminal.md b/example/ruby/Bundler/Thor/Shell/Terminal.md deleted file mode 100644 index e308408..0000000 --- a/example/ruby/Bundler/Thor/Shell/Terminal.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: Bundler::Thor::Shell::Terminal - - - - -# Class Methods -## terminal_width() [](#method-c-terminal_width) -This code was copied from Rake, available under MIT-LICENSE Copyright (c) -2003, 2004 Jim Weirich -## unix?() [](#method-c-unix?) -**@return** [Boolean] - - diff --git a/example/ruby/Bundler/Thor/Shell/WrappedPrinter.md b/example/ruby/Bundler/Thor/Shell/WrappedPrinter.md deleted file mode 100644 index bccbcef..0000000 --- a/example/ruby/Bundler/Thor/Shell/WrappedPrinter.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bundler::Thor::Shell::WrappedPrinter -**Inherits:** Bundler::Thor::Shell::ColumnPrinter - - - - - -#Instance Methods -## print(message) [](#method-i-print) - diff --git a/example/ruby/Bundler/Thor/UndefinedCommandError.md b/example/ruby/Bundler/Thor/UndefinedCommandError.md deleted file mode 100644 index 02a1351..0000000 --- a/example/ruby/Bundler/Thor/UndefinedCommandError.md +++ /dev/null @@ -1,33 +0,0 @@ -# Exception: Bundler::Thor::UndefinedCommandError -**Inherits:** Bundler::Thor::Error - -**Includes:** Bundler::Thor::UndefinedCommandError.if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName - Moduleif defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName - Module.new do - def to_s - super + DidYouMean.formatter.message_for(corrections) - end - - def corrections - @corrections ||= self.class.const_get(:SpellChecker).new(self).corrections - end - end -end - - -Raised when a command was not found. - - -# Attributes -## all_commands[RW] [](#attribute-i-all_commands) -Returns the value of attribute all_commands. - -## command[RW] [](#attribute-i-command) -Returns the value of attribute command. - - -#Instance Methods -## initialize(command, all_commands, namespace) [](#method-i-initialize) - -**@return** [UndefinedCommandError] a new instance of UndefinedCommandError - diff --git a/example/ruby/Bundler/Thor/UndefinedCommandError/SpellChecker.md b/example/ruby/Bundler/Thor/UndefinedCommandError/SpellChecker.md deleted file mode 100644 index 9e81c7c..0000000 --- a/example/ruby/Bundler/Thor/UndefinedCommandError/SpellChecker.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Bundler::Thor::UndefinedCommandError::SpellChecker -**Inherits:** Object - - - - -# Attributes -## error[RW] [](#attribute-i-error) -Returns the value of attribute error. - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize(error) [](#method-i-initialize) - -**@return** [SpellChecker] a new instance of SpellChecker - -## spell_checker() [](#method-i-spell_checker) - diff --git a/example/ruby/Bundler/Thor/UnknownArgumentError.md b/example/ruby/Bundler/Thor/UnknownArgumentError.md deleted file mode 100644 index 5b93284..0000000 --- a/example/ruby/Bundler/Thor/UnknownArgumentError.md +++ /dev/null @@ -1,32 +0,0 @@ -# Exception: Bundler::Thor::UnknownArgumentError -**Inherits:** Bundler::Thor::Error - -**Includes:** Bundler::Thor::UnknownArgumentError.if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName - Moduleif defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName - Module.new do - def to_s - super + DidYouMean.formatter.message_for(corrections) - end - - def corrections - @corrections ||= self.class.const_get(:SpellChecker).new(self).corrections - end - end -end - - - - -# Attributes -## switches[RW] [](#attribute-i-switches) -Returns the value of attribute switches. - -## unknown[RW] [](#attribute-i-unknown) -Returns the value of attribute unknown. - - -#Instance Methods -## initialize(switches, unknown) [](#method-i-initialize) - -**@return** [UnknownArgumentError] a new instance of UnknownArgumentError - diff --git a/example/ruby/Bundler/Thor/UnknownArgumentError/SpellChecker.md b/example/ruby/Bundler/Thor/UnknownArgumentError/SpellChecker.md deleted file mode 100644 index 0c9b140..0000000 --- a/example/ruby/Bundler/Thor/UnknownArgumentError/SpellChecker.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Bundler::Thor::UnknownArgumentError::SpellChecker -**Inherits:** Object - - - - -# Attributes -## error[RW] [](#attribute-i-error) -Returns the value of attribute error. - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize(error) [](#method-i-initialize) - -**@return** [SpellChecker] a new instance of SpellChecker - -## spell_checker() [](#method-i-spell_checker) - diff --git a/example/ruby/Bundler/Thor/Util.md b/example/ruby/Bundler/Thor/Util.md deleted file mode 100644 index 383e578..0000000 --- a/example/ruby/Bundler/Thor/Util.md +++ /dev/null @@ -1,134 +0,0 @@ -# Module: Bundler::Thor::Util - - -This module holds several utilities: - -1) Methods to convert thor namespaces to constants and vice-versa. - - Bundler::Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz" - -2) Loading thor files and sandboxing: - - Bundler::Thor::Util.load_thorfile("~/.thor/foo") - - -# Class Methods -## camel_case(str ) [](#method-c-camel_case) -Receives a string and convert it to camel case. camel_case returns CamelCase. - -#### Parameters -String - -#### Returns -String -## escape_globs(path ) [](#method-c-escape_globs) -Returns a string that has had any glob characters escaped. The glob characters -are `* ? { } [ ]`. - -#### Examples - - Bundler::Thor::Util.escape_globs('[apps]') # => '\[apps\]' - -#### Parameters -String - -#### Returns -String -## escape_html(string ) [](#method-c-escape_html) -Returns a string that has had any HTML characters escaped. - -#### Examples - - Bundler::Thor::Util.escape_html('
') # => "<div>" - -#### Parameters -String - -#### Returns -String -## find_by_namespace(namespace ) [](#method-c-find_by_namespace) -Receives a namespace and search for it in the Bundler::Thor::Base subclasses. - -#### Parameters -namespace -: The namespace to search for. - -## find_class_and_command_by_namespace(namespace , fallback true) [](#method-c-find_class_and_command_by_namespace) -Receives a namespace and tries to retrieve a Bundler::Thor or -Bundler::Thor::Group class from it. It first searches for a class using the -all the given namespace, if it's not found, removes the highest entry and -searches for the class again. If found, returns the highest entry as the class -name. - -#### Examples - - class Foo::Bar < Bundler::Thor - def baz - end - end - - class Baz::Foo < Bundler::Thor::Group - end - - Bundler::Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command - Bundler::Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil - Bundler::Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz" - -#### Parameters -namespace -## globs_for(path ) [](#method-c-globs_for) -Where to look for Bundler::Thor files. -## load_thorfile(path , content nil, debug false) [](#method-c-load_thorfile) -Receives a path and load the thor file in the path. The file is evaluated -inside the sandbox to avoid namespacing conflicts. -## namespace_from_thor_class(constant ) [](#method-c-namespace_from_thor_class) -Receives a constant and converts it to a Bundler::Thor namespace. Since -Bundler::Thor commands can be added to a sandbox, this method is also -responsible for removing the sandbox namespace. - -This method should not be used in general because it's used to deal with older -versions of Bundler::Thor. On current versions, if you need to get the -namespace from a class, just call namespace on it. - -#### Parameters -constant -: The constant to be converted to the thor path. - - -#### Returns -String -: If we receive Foo::Bar::Baz it returns "foo:bar:baz" - -## namespaces_in_content(contents , file __FILE__) [](#method-c-namespaces_in_content) -Given the contents, evaluate it inside the sandbox and returns the namespaces -defined in the sandbox. - -#### Parameters -contents - -#### Returns -[Array](Object) -## ruby_command() [](#method-c-ruby_command) -Return the path to the ruby interpreter taking into account multiple -installations and windows extensions. -## snake_case(str ) [](#method-c-snake_case) -Receives a string and convert it to snake case. SnakeCase returns snake_case. - -#### Parameters -String - -#### Returns -String -## thor_classes_in(klass ) [](#method-c-thor_classes_in) -Returns the thor classes declared inside the given class. -## thor_root() [](#method-c-thor_root) -Returns the root where thor files are located, depending on the OS. -## thor_root_glob() [](#method-c-thor_root_glob) -Returns the files in the thor root. On Windows thor_root will be something -like this: - - C:\Documents and Settings\james\.thor - -If we don't #gsub the \ character, Dir.glob will fail. -## user_home() [](#method-c-user_home) - diff --git a/example/ruby/Bundler/ThreadCreationError.md b/example/ruby/Bundler/ThreadCreationError.md deleted file mode 100644 index b48213a..0000000 --- a/example/ruby/Bundler/ThreadCreationError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Bundler::ThreadCreationError -**Inherits:** Bundler::BundlerError - - - - - diff --git a/example/ruby/Bundler/UI.md b/example/ruby/Bundler/UI.md deleted file mode 100644 index 4257ceb..0000000 --- a/example/ruby/Bundler/UI.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Bundler::UI - - - - - diff --git a/example/ruby/Bundler/UI/RGProxy.md b/example/ruby/Bundler/UI/RGProxy.md deleted file mode 100644 index 8d0dcfa..0000000 --- a/example/ruby/Bundler/UI/RGProxy.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Bundler::UI::RGProxy -**Inherits:** Gem::SilentUI - - - - - -#Instance Methods -## initialize(ui) [](#method-i-initialize) - -**@return** [RGProxy] a new instance of RGProxy - -## say(message) [](#method-i-say) - diff --git a/example/ruby/Bundler/UI/Shell.md b/example/ruby/Bundler/UI/Shell.md deleted file mode 100644 index 8759b13..0000000 --- a/example/ruby/Bundler/UI/Shell.md +++ /dev/null @@ -1,81 +0,0 @@ -# Class: Bundler::UI::Shell -**Inherits:** Object - - - - -# Attributes -## output_stream[RW] [](#attribute-i-output_stream) -Returns the value of attribute output_stream. - -## shell=[R] [](#attribute-i-shell=) -Sets the attribute shell - -**@param** [] the value to set the attribute shell to. - - -#Instance Methods -## add_color(string, *color) [](#method-i-add_color) - -## ask(msg) [](#method-i-ask) - -## confirm(msgnil, newlinenil) [](#method-i-confirm) - -## confirm?() [](#method-i-confirm?) - -**@return** [Boolean] - -## debug(msgnil, newlinenil) [](#method-i-debug) - -## debug?() [](#method-i-debug?) - -**@return** [Boolean] - -## error(msgnil, newlinenil, color:red) [](#method-i-error) - -## error?() [](#method-i-error?) - -**@return** [Boolean] - -## info(msgnil, newlinenil) [](#method-i-info) - -## info?() [](#method-i-info?) - -**@return** [Boolean] - -## initialize(options{}) [](#method-i-initialize) - -**@return** [Shell] a new instance of Shell - -## level(namenil) [](#method-i-level) - -## level=(level) [](#method-i-level=) - -**@raise** [ArgumentError] - -## no?(msg) [](#method-i-no?) - -**@return** [Boolean] - -## progress(&blk) [](#method-i-progress) - -## quiet?() [](#method-i-quiet?) - -**@return** [Boolean] - -## silence(&blk) [](#method-i-silence) - -## trace(e, newlinenil, forcefalse) [](#method-i-trace) - -## unprinted_warnings() [](#method-i-unprinted_warnings) - -## warn(msgnil, newlinenil, color:yellow) [](#method-i-warn) - -## warn?() [](#method-i-warn?) - -**@return** [Boolean] - -## yes?(msg) [](#method-i-yes?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/UI/Silent.md b/example/ruby/Bundler/UI/Silent.md deleted file mode 100644 index 4c204a3..0000000 --- a/example/ruby/Bundler/UI/Silent.md +++ /dev/null @@ -1,80 +0,0 @@ -# Class: Bundler::UI::Silent -**Inherits:** Object - - - - -# Attributes -## shell=[R] [](#attribute-i-shell=) -Sets the attribute shell - -**@param** [] the value to set the attribute shell to. - - -#Instance Methods -## add_color(string, color) [](#method-i-add_color) - -## ask(message) [](#method-i-ask) - -## confirm(messagenil, newlinenil) [](#method-i-confirm) - -## confirm?() [](#method-i-confirm?) - -**@return** [Boolean] - -## debug(messagenil, newlinenil) [](#method-i-debug) - -## debug?() [](#method-i-debug?) - -**@return** [Boolean] - -## error(messagenil, newlinenil) [](#method-i-error) - -## error?() [](#method-i-error?) - -**@return** [Boolean] - -## info(messagenil, newlinenil) [](#method-i-info) - -## info?() [](#method-i-info?) - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [Silent] a new instance of Silent - -## level(namenil) [](#method-i-level) - -## level=(name) [](#method-i-level=) - -## no?(msg) [](#method-i-no?) - -**@return** [Boolean] - -## output_stream() [](#method-i-output_stream) - -## output_stream=(_symbol) [](#method-i-output_stream=) - -## progress() [](#method-i-progress) - -## quiet?() [](#method-i-quiet?) - -**@return** [Boolean] - -## silence() [](#method-i-silence) - -## trace(message, newlinenil, forcefalse) [](#method-i-trace) - -## unprinted_warnings() [](#method-i-unprinted_warnings) - -## warn(messagenil, newlinenil) [](#method-i-warn) - -## warn?() [](#method-i-warn?) - -**@return** [Boolean] - -## yes?(msg) [](#method-i-yes?) - -**@return** [Boolean] - diff --git a/example/ruby/Bundler/URI.md b/example/ruby/Bundler/URI.md deleted file mode 100644 index e971c79..0000000 --- a/example/ruby/Bundler/URI.md +++ /dev/null @@ -1,366 +0,0 @@ -# Module: Bundler::URI - - --- -# uri/common.rb - -Author -: Akira Yamada - -License -: You can redistribute it and/or modify it under the same term as Ruby. - - -See Bundler::URI for general documentation - - -# Class Methods -## const_missing(const ) [](#method-c-const_missing) -## decode_uri_component(str , enc Encoding::UTF_8) [](#method-c-decode_uri_component) -Like Bundler::URI.decode_www_form_component, except that `'+'` is preserved. -## decode_www_form(str , enc Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false) [](#method-c-decode_www_form) -Returns name/value pairs derived from the given string `str`, which must be an -ASCII string. - -The method may be used to decode the body of Net::HTTPResponse object `res` -for which `res['Content-Type']` is `'application/x-www-form-urlencoded'`. - -The returned data is an array of 2-element subarrays; each subarray is a -name/value pair (both are strings). Each returned string has encoding `enc`, -and has had invalid characters removed via -[String#scrub](rdoc-ref:String#scrub). - -A simple example: - - Bundler::URI.decode_www_form('foo=0&bar=1&baz') - # => [["foo", "0"], ["bar", "1"], ["baz", ""]] - -The returned strings have certain conversions, similar to those performed in -Bundler::URI.decode_www_form_component: - - Bundler::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40') - # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]] - -The given string may contain consecutive separators: - - Bundler::URI.decode_www_form('foo=0&&bar=1&&baz=2') - # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]] - -A different separator may be specified: - - Bundler::URI.decode_www_form('foo=0--bar=1--baz', separator: '--') - # => [["foo", "0"], ["bar", "1"], ["baz", ""]] -**@raise** [ArgumentError] - -## decode_www_form_component(str , enc Encoding::UTF_8) [](#method-c-decode_www_form_component) -Returns a string decoded from the given URL-encoded string `str`. - -The given string is first encoded as Encoding::ASCII-8BIT (using String#b), -then decoded (as below), and finally force-encoded to the given encoding -`enc`. - -The returned string: - -* Preserves: - - * Characters `'*'`, `'.'`, `'-'`, and `'_'`. - * Character in ranges `'a'..'z'`, `'A'..'Z'`, and `'0'..'9'`. - - Example: - - Bundler::URI.decode_www_form_component('*.-_azAZ09') - # => "*.-_azAZ09" - -* Converts: - - * Character `'+'` to character `' '`. - * Each "percent notation" to an ASCII character. - - Example: - - Bundler::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A') - # => "Here are some punctuation characters: ,;?:" - -Related: Bundler::URI.decode_uri_component (preserves `'+'`). -## encode_uri_component(str , enc nil) [](#method-c-encode_uri_component) -Like Bundler::URI.encode_www_form_component, except that `' '` (space) is -encoded as `'%20'` (instead of `'+'`). -## encode_www_form(enum , enc nil) [](#method-c-encode_www_form) -Returns a URL-encoded string derived from the given -[Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) `enum`. - -The result is suitable for use as form data for an HTTP request whose -`Content-Type` is `'application/x-www-form-urlencoded'`. - -The returned string consists of the elements of `enum`, each converted to one -or more URL-encoded strings, and all joined with character `'&'`. - -Simple examples: - - Bundler::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]]) - # => "foo=0&bar=1&baz=2" - Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2}) - # => "foo=0&bar=1&baz=2" - -The returned string is formed using method -Bundler::URI.encode_www_form_component, which converts certain characters: - - Bundler::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@') - # => "f%23o=%2F&b-r=%24&b+z=%40" - -When `enum` is Array-like, each element `ele` is converted to a field: - -* If `ele` is an array of two or more elements, the field is formed from its - first two elements (and any additional elements are ignored): - - name = Bundler::URI.encode_www_form_component(ele[0], enc) - value = Bundler::URI.encode_www_form_component(ele[1], enc) - "#{name}=#{value}" - - Examples: - - Bundler::URI.encode_www_form([%w[foo bar], %w[baz bat bah]]) - # => "foo=bar&baz=bat" - Bundler::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']]) - # => "foo=0&bar=baz" - -* If `ele` is an array of one element, the field is formed from `ele[0]`: - - Bundler::URI.encode_www_form_component(ele[0]) - - Example: - - Bundler::URI.encode_www_form([['foo'], [:bar], [0]]) - # => "foo&bar&0" - -* Otherwise the field is formed from `ele`: - - Bundler::URI.encode_www_form_component(ele) - - Example: - - Bundler::URI.encode_www_form(['foo', :bar, 0]) - # => "foo&bar&0" - -The elements of an Array-like `enum` may be mixture: - - Bundler::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat]) - # => "foo=0&bar=1&baz&bat" - -When `enum` is Hash-like, each `key`/`value` pair is converted to one or more -fields: - -* If `value` is - [Array-convertible](rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Ob - jects), each element `ele` in `value` is paired with `key` to form a - field: - - name = Bundler::URI.encode_www_form_component(key, enc) - value = Bundler::URI.encode_www_form_component(ele, enc) - "#{name}=#{value}" - - Example: - - Bundler::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]}) - # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2" - -* Otherwise, `key` and `value` are paired to form a field: - - name = Bundler::URI.encode_www_form_component(key, enc) - value = Bundler::URI.encode_www_form_component(value, enc) - "#{name}=#{value}" - - Example: - - Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2}) - # => "foo=0&bar=1&baz=2" - -The elements of a Hash-like `enum` may be mixture: - - Bundler::URI.encode_www_form({foo: [0, 1], bar: 2}) - # => "foo=0&foo=1&bar=2" -## encode_www_form_component(str , enc nil) [](#method-c-encode_www_form_component) -Returns a URL-encoded string derived from the given string `str`. - -The returned string: - -* Preserves: - - * Characters `'*'`, `'.'`, `'-'`, and `'_'`. - * Character in ranges `'a'..'z'`, `'A'..'Z'`, and `'0'..'9'`. - - Example: - - Bundler::URI.encode_www_form_component('*.-_azAZ09') - # => "*.-_azAZ09" - -* Converts: - - * Character `' '` to character `'+'`. - * Any other character to "percent notation"; the percent notation for - character *c* is `'%%%X' % c.ord`. - - Example: - - Bundler::URI.encode_www_form_component('Here are some punctuation characters: ,;?:') - # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A" - -Encoding: - -* If `str` has encoding Encoding::ASCII_8BIT, argument `enc` is ignored. -* Otherwise `str` is converted first to Encoding::UTF_8 (with suitable - character replacements), and then to encoding `enc`. - -In either case, the returned string has forced encoding Encoding::US_ASCII. - -Related: Bundler::URI.encode_uri_component (encodes `' '` as `'%20'`). -## extract(str , schemes nil, &block ) [](#method-c-extract) -## Synopsis - - Bundler::URI::extract(str[, schemes][,&blk]) - -## Args - -`str` -: String to extract URIs from. - -`schemes` -: Limit Bundler::URI matching to specific schemes. - - -## Description - -Extracts URIs from a string. If block given, iterates through all matched -URIs. Returns nil if block given or array with matches. - -## Usage - - require "bundler/vendor/uri/lib/uri" - - Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") - # => ["http://foo.example.com/bla", "mailto:test@example.com"] -## for(scheme , *arguments , default: Generic) [](#method-c-for) -Returns a new object constructed from the given `scheme`, `arguments`, and -`default`: - -* The new object is an instance of - `Bundler::URI.scheme_list[scheme.upcase]`. -* The object is initialized by calling the class initializer using `scheme` - and `arguments`. See Bundler::URI::Generic.new. - -Examples: - - values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top'] - Bundler::URI.for('https', *values) - # => # - Bundler::URI.for('foo', *values, default: Bundler::URI::HTTP) - # => # -## join(*str ) [](#method-c-join) -Merges the given Bundler::URI strings `str` per [RFC -2396](https://www.rfc-editor.org/rfc/rfc2396.html). - -Each string in `str` is converted to an [RFC3986 -Bundler::URI](https://www.rfc-editor.org/rfc/rfc3986.html) before being -merged. - -Examples: - - Bundler::URI.join("http://example.com/","main.rbx") - # => # - - Bundler::URI.join('http://example.com', 'foo') - # => # - - Bundler::URI.join('http://example.com', '/foo', '/bar') - # => # - - Bundler::URI.join('http://example.com', '/foo', 'bar') - # => # - - Bundler::URI.join('http://example.com', '/foo/', 'bar') - # => # -## parse(uri ) [](#method-c-parse) -Returns a new Bundler::URI object constructed from the given string `uri`: - - Bundler::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - # => # - Bundler::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - # => # - -It's recommended to first ::escape string `uri` if it may contain invalid -Bundler::URI characters. -## parser=(parser RFC3986_PARSER) [](#method-c-parser=) -## regexp(schemes nil) [](#method-c-regexp) -## Synopsis - - Bundler::URI::regexp([match_schemes]) - -## Args - -`match_schemes` -: Array of schemes. If given, resulting regexp matches to URIs whose scheme - is one of the match_schemes. - - -## Description - -Returns a Regexp object which matches to Bundler::URI-like strings. The Regexp -object returned by this method includes arbitrary number of capture group -(parentheses). Never rely on its number. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - # extract first Bundler::URI from html_string - html_string.slice(Bundler::URI.regexp) - - # remove ftp URIs - html_string.sub(Bundler::URI.regexp(['ftp']), '') - - # You should not rely on the number of parentheses - html_string.scan(Bundler::URI.regexp) do |*matches| - p $& - end -## register_scheme(scheme , klass ) [](#method-c-register_scheme) -Registers the given `klass` as the class to be instantiated when parsing a -Bundler::URI with the given `scheme`: - - Bundler::URI.register_scheme('MS_SEARCH', Bundler::URI::Generic) # => Bundler::URI::Generic - Bundler::URI.scheme_list['MS_SEARCH'] # => Bundler::URI::Generic - -Note that after calling String#upcase on `scheme`, it must be a valid constant -name. -## scheme_list() [](#method-c-scheme_list) -Returns a hash of the defined schemes: - - Bundler::URI.scheme_list - # => - {"MAILTO"=>Bundler::URI::MailTo, - "LDAPS"=>Bundler::URI::LDAPS, - "WS"=>Bundler::URI::WS, - "HTTP"=>Bundler::URI::HTTP, - "HTTPS"=>Bundler::URI::HTTPS, - "LDAP"=>Bundler::URI::LDAP, - "FILE"=>Bundler::URI::File, - "FTP"=>Bundler::URI::FTP} - -Related: Bundler::URI.register_scheme. -## split(uri ) [](#method-c-split) -Returns a 9-element array representing the parts of the Bundler::URI formed -from the string `uri`; each array element is a string or `nil`: - - names = %w[scheme userinfo host port registry path opaque query fragment] - values = Bundler::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - names.zip(values) - # => - [["scheme", "https"], - ["userinfo", "john.doe"], - ["host", "www.example.com"], - ["port", "123"], - ["registry", nil], - ["path", "/forum/questions/"], - ["opaque", nil], - ["query", "tag=networking&order=newest"], - ["fragment", "top"]] - diff --git a/example/ruby/Bundler/URI/BadURIError.md b/example/ruby/Bundler/URI/BadURIError.md deleted file mode 100644 index d524d67..0000000 --- a/example/ruby/Bundler/URI/BadURIError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::URI::BadURIError -**Inherits:** Bundler::URI::Error - - -Bundler::URI is valid, bad usage is not. - - - diff --git a/example/ruby/Bundler/URI/Error.md b/example/ruby/Bundler/URI/Error.md deleted file mode 100644 index 0a6a7a9..0000000 --- a/example/ruby/Bundler/URI/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::URI::Error -**Inherits:** StandardError - - -Base class for all Bundler::URI exceptions. - - - diff --git a/example/ruby/Bundler/URI/FTP.md b/example/ruby/Bundler/URI/FTP.md deleted file mode 100644 index 48c63b0..0000000 --- a/example/ruby/Bundler/URI/FTP.md +++ /dev/null @@ -1,91 +0,0 @@ -# Class: Bundler::URI::FTP -**Inherits:** Bundler::URI::Generic - - -FTP Bundler::URI syntax is defined by RFC1738 section 3.2. - -This class will be redesigned because of difference of implementations; the -structure of its path. draft-hoffman-ftp-uri-04 is a draft but it is a good -summary about the de facto spec. -https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04 - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Bundler::URI::FTP object from components, with syntax checking. - -The components accepted are `userinfo`, `host`, `port`, `path`, and -`typecode`. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, typecode]`. - -If the path supplied is absolute, it will be escaped in order to make it -absolute in the Bundler::URI. - -Examples: - - require 'bundler/vendor/uri/lib/uri' - - uri1 = Bundler::URI::FTP.build(['user:password', 'ftp.example.com', nil, - '/path/file.zip', 'i']) - uri1.to_s # => "ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i" - - uri2 = Bundler::URI::FTP.build({:host => 'ftp.example.com', - :path => 'ruby/src'}) - uri2.to_s # => "ftp://ftp.example.com/ruby/src" -## new2(user , password , host , port , path , typecode nil, arg_check true) [](#method-c-new2) -# Attributes -## typecode[RW] [](#attribute-i-typecode) -typecode accessor. - -See Bundler::URI::FTP::COMPONENT. - - -#Instance Methods -## initialize(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parsernil, arg_checkfalse) [](#method-i-initialize) -## Description - -Creates a new Bundler::URI::FTP object from generic URL components with no -syntax checking. - -Unlike build(), this method does not escape the path component as required by -RFC1738; instead it is treated as per RFC2396. - -Arguments are `scheme`, `userinfo`, `host`, `port`, `registry`, `path`, -`opaque`, `query`, and `fragment`, in that order. - -**@raise** [InvalidURIError] - -**@return** [FTP] a new instance of FTP - -## merge(oth) [](#method-i-merge) -:nodoc: - -## path() [](#method-i-path) -Returns the path from an FTP Bundler::URI. - -RFC 1738 specifically states that the path for an FTP Bundler::URI does not -include the / which separates the Bundler::URI path from the Bundler::URI -host. Example: - -`ftp://ftp.example.com/pub/ruby` - -The above Bundler::URI indicates that the client should connect to -ftp.example.com then cd to pub/ruby from the initial login directory. - -If you want to cd to an absolute directory, you must include an escaped / -(%2F) in the path. Example: - -`ftp://ftp.example.com/%2Fpub/ruby` - -This method will then return "/pub/ruby". - -## to_s() [](#method-i-to_s) -Returns a String representation of the Bundler::URI::FTP. - diff --git a/example/ruby/Bundler/URI/File.md b/example/ruby/Bundler/URI/File.md deleted file mode 100644 index 410b660..0000000 --- a/example/ruby/Bundler/URI/File.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Bundler::URI::File -**Inherits:** Bundler::URI::Generic - - -The "file" Bundler::URI is defined by RFC8089. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Bundler::URI::File object from components, with syntax checking. - -The components accepted are `host` and `path`. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[host, -path]`. - -A path from e.g. the File class should be escaped before being passed. - -Examples: - - require 'bundler/vendor/uri/lib/uri' - - uri1 = Bundler::URI::File.build(['host.example.com', '/path/file.zip']) - uri1.to_s # => "file://host.example.com/path/file.zip" - - uri2 = Bundler::URI::File.build({:host => 'host.example.com', - :path => '/ruby/src'}) - uri2.to_s # => "file://host.example.com/ruby/src" - - uri3 = Bundler::URI::File.build({:path => Bundler::URI::escape('/path/my file.txt')}) - uri3.to_s # => "file:///path/my%20file.txt" - -#Instance Methods -## check_password(user) [](#method-i-check_password) -raise InvalidURIError - -**@raise** [Bundler::URI::InvalidURIError] - -## check_user(user) [](#method-i-check_user) -raise InvalidURIError - -**@raise** [Bundler::URI::InvalidURIError] - -## check_userinfo(user) [](#method-i-check_userinfo) -raise InvalidURIError - -**@raise** [Bundler::URI::InvalidURIError] - -## set_host(v) [](#method-i-set_host) -Protected setter for the host component `v`. - -See also Bundler::URI::Generic.host=. - -## set_password(v) [](#method-i-set_password) -do nothing - -## set_port(v) [](#method-i-set_port) -do nothing - -## set_user(v) [](#method-i-set_user) -do nothing - -## set_userinfo(v) [](#method-i-set_userinfo) -do nothing - diff --git a/example/ruby/Bundler/URI/Generic.md b/example/ruby/Bundler/URI/Generic.md deleted file mode 100644 index 39ab8bc..0000000 --- a/example/ruby/Bundler/URI/Generic.md +++ /dev/null @@ -1,444 +0,0 @@ -# Class: Bundler::URI::Generic -**Inherits:** Object - -**Includes:** Bundler::URI - - -Base class for all Bundler::URI classes. Implements generic Bundler::URI -syntax as per RFC 2396. - - -# Class Methods -## build(args ) [](#method-c-build) -## Synopsis - -See ::new. - -## Description - -Creates a new Bundler::URI::Generic instance from components of -Bundler::URI::Generic with check. Components are: scheme, userinfo, host, -port, registry, path, opaque, query, and fragment. You can provide arguments -either by an Array or a Hash. See ::new for hash keys to use or for order of -array items. -## build2(args ) [](#method-c-build2) -## Synopsis - -See ::new. - -## Description - -At first, tries to create a new Bundler::URI::Generic instance using -Bundler::URI::Generic::build. But, if exception -Bundler::URI::InvalidComponentError is raised, then it does -Bundler::URI::Escape.escape all Bundler::URI components and tries again. -## component() [](#method-c-component) -Components of the Bundler::URI in the order. -## default_port() [](#method-c-default_port) -Returns default port. -## use_proxy?(hostname , addr , port , no_proxy ) [](#method-c-use_proxy?) -:nodoc: -**@return** [Boolean] - -## use_registry() [](#method-c-use_registry) -:nodoc: -# Attributes -## fragment[RW] [](#attribute-i-fragment) -Returns the fragment component of the Bundler::URI. - - Bundler::URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies" - -## host[RW] [](#attribute-i-host) -Returns the host component of the Bundler::URI. - - Bundler::URI("http://foo/bar/baz").host #=> "foo" - -It returns nil if no host component exists. - - Bundler::URI("mailto:foo@example.org").host #=> nil - -The component does not contain the port number. - - Bundler::URI("http://foo:8080/bar/baz").host #=> "foo" - -Since IPv6 addresses are wrapped with brackets in URIs, this method returns -IPv6 addresses wrapped with brackets. This form is not appropriate to pass to -socket methods such as TCPSocket.open. If unwrapped host names are required, -use the #hostname method. - - Bundler::URI("http://[::1]/bar/baz").host #=> "[::1]" - Bundler::URI("http://[::1]/bar/baz").hostname #=> "::1" - -## opaque[RW] [](#attribute-i-opaque) -Returns the opaque part of the Bundler::URI. - - Bundler::URI("mailto:foo@example.org").opaque #=> "foo@example.org" - Bundler::URI("http://foo/bar/baz").opaque #=> nil - -The portion of the path that does not make use of the slash '/'. The path -typically refers to an absolute path or an opaque part. (See RFC2396 Section 3 -and 5.2.) - -## path[RW] [](#attribute-i-path) -Returns the path component of the Bundler::URI. - - Bundler::URI("http://foo/bar/baz").path #=> "/bar/baz" - -## port[RW] [](#attribute-i-port) -Returns the port component of the Bundler::URI. - - Bundler::URI("http://foo/bar/baz").port #=> 80 - Bundler::URI("http://foo:8080/bar/baz").port #=> 8080 - -## query[RW] [](#attribute-i-query) -Returns the query component of the Bundler::URI. - - Bundler::URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar" - -## scheme[RW] [](#attribute-i-scheme) -Returns the scheme component of the Bundler::URI. - - Bundler::URI("http://foo/bar/baz").scheme #=> "http" - - -#Instance Methods -## ==(oth) [](#method-i-==) -Compares two URIs. - -## absolute?() [](#method-i-absolute?) -Returns true if Bundler::URI has a scheme (e.g. http:// or https://) -specified. - -**@return** [Boolean] - -## coerce(oth) [](#method-i-coerce) -## Args - -`v` -: Bundler::URI or String - - -## Description - -Attempts to parse other Bundler::URI `oth`, returns [parsed_oth, self]. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse("http://my.example.com") - uri.coerce("http://foo.com") - #=> [#, #] - -## component() [](#method-i-component) -Components of the Bundler::URI in the order. - -## decoded_password() [](#method-i-decoded_password) -Returns the password component after Bundler::URI decoding. - -## decoded_user() [](#method-i-decoded_user) -Returns the user component after Bundler::URI decoding. - -## default_port() [](#method-i-default_port) -Returns default port. - -## eql?(oth) [](#method-i-eql?) - -**@return** [Boolean] - -## find_proxy(envENV) [](#method-i-find_proxy) -Returns a proxy Bundler::URI. The proxy Bundler::URI is obtained from -environment variables such as http_proxy, ftp_proxy, no_proxy, etc. If there -is no proper proxy, nil is returned. - -If the optional parameter `env` is specified, it is used instead of ENV. - -Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are -examined, too. - -But http_proxy and HTTP_PROXY is treated specially under CGI environment. It's -because HTTP_PROXY may be set by Proxy: header. So HTTP_PROXY is not used. -http_proxy is not used too if the variable is case insensitive. CGI_HTTP_PROXY -can be used instead. - -**@raise** [BadURIError] - -## hash() [](#method-i-hash) - -## hierarchical?() [](#method-i-hierarchical?) -Returns true if Bundler::URI is hierarchical. - -## Description - -Bundler::URI has components listed in order of decreasing significance from -left to right, see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse("http://my.example.com/") - uri.hierarchical? - #=> true - uri = Bundler::URI.parse("mailto:joe@example.com") - uri.hierarchical? - #=> false - -**@return** [Boolean] - -## hostname() [](#method-i-hostname) -Extract the host part of the Bundler::URI and unwrap brackets for IPv6 -addresses. - -This method is the same as Bundler::URI::Generic#host except brackets for IPv6 -(and future IP) addresses are removed. - - uri = Bundler::URI("http://[::1]/bar") - uri.hostname #=> "::1" - uri.host #=> "[::1]" - -## hostname=(v) [](#method-i-hostname=) -Sets the host part of the Bundler::URI as the argument with brackets for IPv6 -addresses. - -This method is the same as Bundler::URI::Generic#host= except the argument can -be a bare IPv6 address. - - uri = Bundler::URI("http://foo/bar") - uri.hostname = "::1" - uri.to_s #=> "http://[::1]/bar" - -If the argument seems to be an IPv6 address, it is wrapped with brackets. - -## initialize(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parserDEFAULT_PARSER, arg_checkfalse) [](#method-i-initialize) -## Args - -`scheme` -: Protocol scheme, i.e. 'http','ftp','mailto' and so on. - -`userinfo` -: User name and password, i.e. 'sdmitry:bla'. - -`host` -: Server host name. - -`port` -: Server port. - -`registry` -: Registry of naming authorities. - -`path` -: Path on server. - -`opaque` -: Opaque part. - -`query` -: Query data. - -`fragment` -: Part of the Bundler::URI after '#' character. - -`parser` -: Parser for internal use [Bundler::URI::DEFAULT_PARSER by default]. - -`arg_check` -: Check arguments [false by default]. - - -## Description - -Creates a new Bundler::URI::Generic instance from ``generic'' components -without check. - -**@return** [Generic] a new instance of Generic - -## inspect() [](#method-i-inspect) - -## merge(oth) [](#method-i-merge) -## Args - -`oth` -: Bundler::URI or String - - -## Description - -Merges two URIs. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse("http://my.example.com") - uri.merge("/main.rbx?page=1") - # => "http://my.example.com/main.rbx?page=1" - -## merge!(oth) [](#method-i-merge!) -## Args - -`oth` -: Bundler::URI or String - - -## Description - -Destructive form of #merge. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse("http://my.example.com") - uri.merge!("/main.rbx?page=1") - uri.to_s # => "http://my.example.com/main.rbx?page=1" - -## normalize() [](#method-i-normalize) -Returns normalized Bundler::URI. - - require 'bundler/vendor/uri/lib/uri' - - Bundler::URI("HTTP://my.EXAMPLE.com").normalize - #=> # - -Normalization here means: - -* scheme and host are converted to lowercase, -* an empty path component is set to "/". - -## normalize!() [](#method-i-normalize!) -Destructive version of #normalize. - -## parser() [](#method-i-parser) -Returns the parser to be used. - -Unless a Bundler::URI::Parser is defined, DEFAULT_PARSER is used. - -## password() [](#method-i-password) -Returns the password component (without Bundler::URI decoding). - -## password=(password) [](#method-i-password=) -## Args - -`v` -: String - - -## Description - -Public setter for the `password` component (with validation). - -See also Bundler::URI::Generic.check_password. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse("http://john:S3nsit1ve@my.example.com") - uri.password = "V3ry_S3nsit1ve" - uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com" - -## registry() [](#method-i-registry) -:nodoc: - -## registry=(v) [](#method-i-registry=) - -**@raise** [InvalidURIError] - -## relative?() [](#method-i-relative?) -Returns true if Bundler::URI does not have a scheme (e.g. http:// or https://) -specified. - -**@return** [Boolean] - -## route_from(oth) [](#method-i-route_from) -## Args - -`oth` -: Bundler::URI or String - - -## Description - -Calculates relative path from oth to self. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse('http://my.example.com/main.rbx?page=1') - uri.route_from('http://my.example.com') - #=> # - -## route_to(oth) [](#method-i-route_to) -## Args - -`oth` -: Bundler::URI or String - - -## Description - -Calculates relative path to oth from self. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse('http://my.example.com') - uri.route_to('http://my.example.com/main.rbx?page=1') - #=> # - -## select(*components) [](#method-i-select) -## Args - -`components` -: Multiple Symbol arguments defined in Bundler::URI::HTTP. - - -## Description - -Selects specified components from Bundler::URI. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse('http://myuser:mypass@my.example.com/test.rbx') - uri.select(:userinfo, :host, :path) - # => ["myuser:mypass", "my.example.com", "/test.rbx"] - -## to_s() [](#method-i-to_s) -Constructs String from Bundler::URI. - -## user() [](#method-i-user) -Returns the user component (without Bundler::URI decoding). - -## user=(user) [](#method-i-user=) -## Args - -`v` -: String - - -## Description - -Public setter for the `user` component (with validation). - -See also Bundler::URI::Generic.check_user. - -## Usage - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse("http://john:S3nsit1ve@my.example.com") - uri.user = "sam" - uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com" - -## userinfo() [](#method-i-userinfo) -Returns the userinfo, either as 'user' or 'user:password'. - -## userinfo=(userinfo) [](#method-i-userinfo=) -Sets userinfo, argument is string like 'name:pass'. - diff --git a/example/ruby/Bundler/URI/HTTP.md b/example/ruby/Bundler/URI/HTTP.md deleted file mode 100644 index 9c1234b..0000000 --- a/example/ruby/Bundler/URI/HTTP.md +++ /dev/null @@ -1,75 +0,0 @@ -# Class: Bundler::URI::HTTP -**Inherits:** Bundler::URI::Generic - - -The syntax of HTTP URIs is defined in RFC1738 section 3.3. - -Note that the Ruby Bundler::URI library allows HTTP URLs containing usernames -and passwords. This is not legal as per the RFC, but used to be supported in -Internet Explorer 5 and 6, before the MS04-004 security update. See -. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Bundler::URI::HTTP object from components, with syntax checking. - -The components accepted are userinfo, host, port, path, query, and fragment. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, query, fragment]`. - -Example: - - uri = Bundler::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar') - - uri = Bundler::URI::HTTP.build([nil, "www.example.com", nil, "/path", - "query", 'fragment']) - -Currently, if passed userinfo components this method generates invalid HTTP -URIs as per RFC 1738. - -#Instance Methods -## authority() [](#method-i-authority) -## Description - -Returns the authority for an HTTP uri, as defined in -https://www.rfc-editor.org/rfc/rfc3986#section-3.2. - -Example: - - Bundler::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com" - Bundler::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000" - Bundler::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com" - -## origin() [](#method-i-origin) -## Description - -Returns the origin for an HTTP uri, as defined in -https://www.rfc-editor.org/rfc/rfc6454. - -Example: - - Bundler::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com" - Bundler::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000" - Bundler::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com" - Bundler::URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com" - -## request_uri() [](#method-i-request_uri) -## Description - -Returns the full path for an HTTP request, as required by Net::HTTP::Get. - -If the Bundler::URI contains a query, the full path is Bundler::URI#path + '?' -+ Bundler::URI#query. Otherwise, the path is simply Bundler::URI#path. - -Example: - - uri = Bundler::URI::HTTP.build(path: '/foo/bar', query: 'test=true') - uri.request_uri # => "/foo/bar?test=true" - diff --git a/example/ruby/Bundler/URI/HTTPS.md b/example/ruby/Bundler/URI/HTTPS.md deleted file mode 100644 index 085a271..0000000 --- a/example/ruby/Bundler/URI/HTTPS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bundler::URI::HTTPS -**Inherits:** Bundler::URI::HTTP - - -The default port for HTTPS URIs is 443, and the scheme is 'https:' rather than -'http:'. Other than that, HTTPS URIs are identical to HTTP URIs; see -Bundler::URI::HTTP. - - - diff --git a/example/ruby/Bundler/URI/InvalidComponentError.md b/example/ruby/Bundler/URI/InvalidComponentError.md deleted file mode 100644 index 9f7df17..0000000 --- a/example/ruby/Bundler/URI/InvalidComponentError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::URI::InvalidComponentError -**Inherits:** Bundler::URI::Error - - -Not a Bundler::URI component. - - - diff --git a/example/ruby/Bundler/URI/InvalidURIError.md b/example/ruby/Bundler/URI/InvalidURIError.md deleted file mode 100644 index 420ea5f..0000000 --- a/example/ruby/Bundler/URI/InvalidURIError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Bundler::URI::InvalidURIError -**Inherits:** Bundler::URI::Error - - -Not a Bundler::URI. - - - diff --git a/example/ruby/Bundler/URI/LDAP.md b/example/ruby/Bundler/URI/LDAP.md deleted file mode 100644 index 2fde363..0000000 --- a/example/ruby/Bundler/URI/LDAP.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: Bundler::URI::LDAP -**Inherits:** Bundler::URI::Generic - - -LDAP Bundler::URI SCHEMA (described in RFC2255). -- -[ldap:///[?[?[?](?)]]] ++ - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Bundler::URI::LDAP object from components, with syntax checking. - -The components accepted are host, port, dn, attributes, scope, filter, and -extensions. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[host, port, -dn, attributes, scope, filter, extensions]`. - -Example: - - uri = Bundler::URI::LDAP.build({:host => 'ldap.example.com', - :dn => '/dc=example'}) - - uri = Bundler::URI::LDAP.build(["ldap.example.com", nil, - "/dc=example;dc=com", "query", nil, nil, nil]) - -#Instance Methods -## attributes() [](#method-i-attributes) -Returns attributes. - -## attributes=(val) [](#method-i-attributes=) -Setter for attributes `val`. - -## dn() [](#method-i-dn) -Returns dn. - -## dn=(val) [](#method-i-dn=) -Setter for dn `val`. - -## extensions() [](#method-i-extensions) -Returns extensions. - -## extensions=(val) [](#method-i-extensions=) -Setter for extensions `val`. - -## filter() [](#method-i-filter) -Returns filter. - -## filter=(val) [](#method-i-filter=) -Setter for filter `val`. - -## hierarchical?() [](#method-i-hierarchical?) -Checks if Bundler::URI has a path. For Bundler::URI::LDAP this will return -`false`. - -**@return** [Boolean] - -## initialize(*arg) [](#method-i-initialize) -## Description - -Creates a new Bundler::URI::LDAP object from generic Bundler::URI components -as per RFC 2396. No LDAP-specific syntax checking is performed. - -Arguments are `scheme`, `userinfo`, `host`, `port`, `registry`, `path`, -`opaque`, `query`, and `fragment`, in that order. - -Example: - - uri = Bundler::URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil, - "/dc=example;dc=com", nil, "query", nil) - -See also Bundler::URI::Generic.new. - -**@return** [LDAP] a new instance of LDAP - -## scope() [](#method-i-scope) -Returns scope. - -## scope=(val) [](#method-i-scope=) -Setter for scope `val`. - diff --git a/example/ruby/Bundler/URI/LDAPS.md b/example/ruby/Bundler/URI/LDAPS.md deleted file mode 100644 index a915455..0000000 --- a/example/ruby/Bundler/URI/LDAPS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bundler::URI::LDAPS -**Inherits:** Bundler::URI::LDAP - - -The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather than -'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs; see -Bundler::URI::LDAP. - - - diff --git a/example/ruby/Bundler/URI/MailTo.md b/example/ruby/Bundler/URI/MailTo.md deleted file mode 100644 index 07e5218..0000000 --- a/example/ruby/Bundler/URI/MailTo.md +++ /dev/null @@ -1,71 +0,0 @@ -# Class: Bundler::URI::MailTo -**Inherits:** Bundler::URI::Generic - -**Includes:** Bundler::URI::RFC2396_REGEXP - - -RFC6068, the mailto URL scheme. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Bundler::URI::MailTo object from components, with syntax -checking. - -Components can be provided as an Array or Hash. If an Array is used, the -components must be supplied as `[to, headers]`. - -If a Hash is used, the keys are the component names preceded by colons. - -The headers can be supplied as a pre-encoded string, such as -`"subject=subscribe&cc=address"`, or as an Array of Arrays like `[['subject', -'subscribe'], ['cc', 'address']]`. - -Examples: - - require 'bundler/vendor/uri/lib/uri' - - m1 = Bundler::URI::MailTo.build(['joe@example.com', 'subject=Ruby']) - m1.to_s # => "mailto:joe@example.com?subject=Ruby" - - m2 = Bundler::URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]]) - m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com" - - m3 = Bundler::URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]}) - m3.to_s # => "mailto:listman@example.com?subject=subscribe" -# Attributes -## headers[RW] [](#attribute-i-headers) -E-mail headers set by the URL, as an Array of Arrays. - -## to[RW] [](#attribute-i-to) -The primary e-mail address of the URL, as a String. - - -#Instance Methods -## initialize(*arg) [](#method-i-initialize) -## Description - -Creates a new Bundler::URI::MailTo object from generic URL components with no -syntax checking. - -This method is usually called from Bundler::URI::parse, which checks the -validity of each component. - -**@return** [MailTo] a new instance of MailTo - -## to_mailtext() [](#method-i-to_mailtext) -Returns the RFC822 e-mail text equivalent of the URL, as a String. - -Example: - - require 'bundler/vendor/uri/lib/uri' - - uri = Bundler::URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr") - uri.to_mailtext - # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n" - -## to_s() [](#method-i-to_s) -Constructs String from Bundler::URI. - diff --git a/example/ruby/Bundler/URI/RFC2396_Parser.md b/example/ruby/Bundler/URI/RFC2396_Parser.md deleted file mode 100644 index 27c58a7..0000000 --- a/example/ruby/Bundler/URI/RFC2396_Parser.md +++ /dev/null @@ -1,154 +0,0 @@ -# Class: Bundler::URI::RFC2396_Parser -**Inherits:** Object - -**Includes:** Bundler::URI::RFC2396_REGEXP - - -Class that parses String's into Bundler::URI's. - -It contains a Hash set of patterns and Regexp's that match and validate. - - -# Attributes -## pattern[RW] [](#attribute-i-pattern) -The Hash of patterns. - -See also Bundler::URI::Parser.initialize_pattern. - -## regexp[RW] [](#attribute-i-regexp) -The Hash of Regexp. - -See also Bundler::URI::Parser.initialize_regexp. - - -#Instance Methods -## escape(str, unsafe) [](#method-i-escape) -:call-seq: - escape( str ) - escape( str, unsafe ) - -## Args - -`str` -: String to make safe - -`unsafe` -: Regexp to apply. Defaults to `self.regexp[:UNSAFE]` - - -## Description - -Constructs a safe String from `str`, removing unsafe characters, replacing -them with codes. - -## extract(str, schemesnil) [](#method-i-extract) -:call-seq: - extract( str ) - extract( str, schemes ) - extract( str, schemes ) {|item| block } - -## Args - -`str` -: String to search - -`schemes` -: Patterns to apply to `str` - - -## Description - -Attempts to parse and merge a set of URIs. If no `block` given, then returns -the result, else it calls `block` for each element in result. - -See also Bundler::URI::Parser.make_regexp. - -## initialize(opts{}) [](#method-i-initialize) -## Synopsis - - Bundler::URI::Parser.new([opts]) - -## Args - -The constructor accepts a hash as options for parser. Keys of options are -pattern names of Bundler::URI components and values of options are pattern -strings. The constructor generates set of regexps for parsing URIs. - -You can use the following keys: - - * :ESCAPED (Bundler::URI::PATTERN::ESCAPED in default) - * :UNRESERVED (Bundler::URI::PATTERN::UNRESERVED in default) - * :DOMLABEL (Bundler::URI::PATTERN::DOMLABEL in default) - * :TOPLABEL (Bundler::URI::PATTERN::TOPLABEL in default) - * :HOSTNAME (Bundler::URI::PATTERN::HOSTNAME in default) - -## Examples - - p = Bundler::URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})") - u = p.parse("http://example.jp/%uABCD") #=> # - Bundler::URI.parse(u.to_s) #=> raises Bundler::URI::InvalidURIError - - s = "http://example.com/ABCD" - u1 = p.parse(s) #=> # - u2 = Bundler::URI.parse(s) #=> # - u1 == u2 #=> true - u1.eql?(u2) #=> false - -**@return** [RFC2396_Parser] a new instance of RFC2396_Parser - -## inspect() [](#method-i-inspect) - -## join(*uris) [](#method-i-join) -## Args - -`uris` -: an Array of Strings - - -## Description - -Attempts to parse and merge a set of URIs. - -## make_regexp(schemesnil) [](#method-i-make_regexp) -Returns Regexp that is default `self.regexp[:ABS_URI_REF]`, unless `schemes` -is provided. Then it is a Regexp.union with `self.pattern[:X_ABS_URI]`. - -## parse(uri) [](#method-i-parse) -## Args - -`uri` -: String - - -## Description - -Parses `uri` and constructs either matching Bundler::URI scheme object (File, -FTP, HTTP, HTTPS, LDAP, LDAPS, or MailTo) or Bundler::URI::Generic. - -## Usage - - p = Bundler::URI::Parser.new - p.parse("ldap://ldap.example.com/dc=example?user=john") - #=> # - -## split(uri) [](#method-i-split) -Returns a split Bundler::URI against `regexp[:ABS_URI]`. - -## unescape(str, escaped) [](#method-i-unescape) -:call-seq: - unescape( str ) - unescape( str, escaped ) - -## Args - -`str` -: String to remove escapes from - -`escaped` -: Regexp to apply. Defaults to `self.regexp[:ESCAPED]` - - -## Description - -Removes escapes from `str`. - diff --git a/example/ruby/Bundler/URI/RFC2396_REGEXP.md b/example/ruby/Bundler/URI/RFC2396_REGEXP.md deleted file mode 100644 index 8ac02e2..0000000 --- a/example/ruby/Bundler/URI/RFC2396_REGEXP.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Bundler::URI::RFC2396_REGEXP - - -Includes Bundler::URI::REGEXP::PATTERN - - - diff --git a/example/ruby/Bundler/URI/RFC2396_REGEXP/PATTERN.md b/example/ruby/Bundler/URI/RFC2396_REGEXP/PATTERN.md deleted file mode 100644 index 8c640d5..0000000 --- a/example/ruby/Bundler/URI/RFC2396_REGEXP/PATTERN.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Bundler::URI::RFC2396_REGEXP::PATTERN - - -Patterns used to parse Bundler::URI's - - - diff --git a/example/ruby/Bundler/URI/RFC3986_Parser.md b/example/ruby/Bundler/URI/RFC3986_Parser.md deleted file mode 100644 index 2b7a61a..0000000 --- a/example/ruby/Bundler/URI/RFC3986_Parser.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Bundler::URI::RFC3986_Parser -**Inherits:** Object - - -:nodoc: - - -# Attributes -## regexp[RW] [](#attribute-i-regexp) -Returns the value of attribute regexp. - - -#Instance Methods -## escape(str, unsafenil) [](#method-i-escape) -Compatibility for RFC2396 parser - -## extract(str, schemesnil, &block) [](#method-i-extract) -Compatibility for RFC2396 parser - -## initialize() [](#method-i-initialize) - -**@return** [RFC3986_Parser] a new instance of RFC3986_Parser - -## inspect() [](#method-i-inspect) - -## join(*uris) [](#method-i-join) -:nodoc: - -## make_regexp(schemesnil) [](#method-i-make_regexp) -Compatibility for RFC2396 parser - -## parse(uri) [](#method-i-parse) -:nodoc: - -## split(uri) [](#method-i-split) -:nodoc: - -## unescape(str, escapednil) [](#method-i-unescape) -Compatibility for RFC2396 parser - diff --git a/example/ruby/Bundler/URI/Util.md b/example/ruby/Bundler/URI/Util.md deleted file mode 100644 index 3064be3..0000000 --- a/example/ruby/Bundler/URI/Util.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bundler::URI::Util - - -:nodoc: - - -# Class Methods -## make_components_hash(klass , array_hash ) [](#method-c-make_components_hash) - diff --git a/example/ruby/Bundler/URI/WS.md b/example/ruby/Bundler/URI/WS.md deleted file mode 100644 index ea0b23f..0000000 --- a/example/ruby/Bundler/URI/WS.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Bundler::URI::WS -**Inherits:** Bundler::URI::Generic - - -The syntax of WS URIs is defined in RFC6455 section 3. - -Note that the Ruby Bundler::URI library allows WS URLs containing usernames -and passwords. This is not legal as per the RFC, but used to be supported in -Internet Explorer 5 and 6, before the MS04-004 security update. See -. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Bundler::URI::WS object from components, with syntax checking. - -The components accepted are userinfo, host, port, path, and query. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, query]`. - -Example: - - uri = Bundler::URI::WS.build(host: 'www.example.com', path: '/foo/bar') - - uri = Bundler::URI::WS.build([nil, "www.example.com", nil, "/path", "query"]) - -Currently, if passed userinfo components this method generates invalid WS URIs -as per RFC 1738. - -#Instance Methods -## request_uri() [](#method-i-request_uri) -## Description - -Returns the full path for a WS Bundler::URI, as required by Net::HTTP::Get. - -If the Bundler::URI contains a query, the full path is Bundler::URI#path + '?' -+ Bundler::URI#query. Otherwise, the path is simply Bundler::URI#path. - -Example: - - uri = Bundler::URI::WS.build(path: '/foo/bar', query: 'test=true') - uri.request_uri # => "/foo/bar?test=true" - diff --git a/example/ruby/Bundler/URI/WSS.md b/example/ruby/Bundler/URI/WSS.md deleted file mode 100644 index c1e4f86..0000000 --- a/example/ruby/Bundler/URI/WSS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Bundler::URI::WSS -**Inherits:** Bundler::URI::WS - - -The default port for WSS URIs is 443, and the scheme is 'wss:' rather than -'ws:'. Other than that, WSS URIs are identical to WS URIs; see -Bundler::URI::WS. - - - diff --git a/example/ruby/Bundler/URICredentialsFilter.md b/example/ruby/Bundler/URICredentialsFilter.md deleted file mode 100644 index 45cb08c..0000000 --- a/example/ruby/Bundler/URICredentialsFilter.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Bundler::URICredentialsFilter - - - - -# Class Methods -## credential_filtered_string(str_to_filter , uri ) [](#method-c-credential_filtered_string) -## credential_filtered_uri(uri_to_anonymize ) [](#method-c-credential_filtered_uri) - diff --git a/example/ruby/Bundler/URINormalizer.md b/example/ruby/Bundler/URINormalizer.md deleted file mode 100644 index 0170fcd..0000000 --- a/example/ruby/Bundler/URINormalizer.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: Bundler::URINormalizer - - - - -# Class Methods -## normalize_suffix(uri , trailing_slash: true) [](#method-c-normalize_suffix) -Normalizes uri to a consistent version, either with or without trailing slash. - -TODO: Currently gem sources are locked with a trailing slash, while git -sources are locked without a trailing slash. This should be normalized but the -inconsistency is there for now to avoid changing all lockfiles including GIT -sources. We could normalize this on the next major. - diff --git a/example/ruby/Bundler/VirtualProtocolError.md b/example/ruby/Bundler/VirtualProtocolError.md deleted file mode 100644 index c9f3d80..0000000 --- a/example/ruby/Bundler/VirtualProtocolError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Bundler::VirtualProtocolError -**Inherits:** Bundler::BundlerError - - - - - -#Instance Methods -## message() [](#method-i-message) - diff --git a/example/ruby/Bundler/Worker.md b/example/ruby/Bundler/Worker.md deleted file mode 100644 index 4f38703..0000000 --- a/example/ruby/Bundler/Worker.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Bundler::Worker -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) - -**@return** [String] the name of the worker - - -#Instance Methods -## deq() [](#method-i-deq) -Retrieves results of job function being executed in worker pool - -## enq(obj) [](#method-i-enq) -Enqueue a request to be executed in the worker pool - -**@param** [String] mostly it is name of spec that should be downloaded - -## initialize(size, name, func) [](#method-i-initialize) -Creates a worker pool of specified size - -**@param** [Integer] Size of pool - -**@param** [String] name the name of the worker - -**@param** [Proc] job to run in inside the worker pool - -**@return** [Worker] a new instance of Worker - -## stop() [](#method-i-stop) - diff --git a/example/ruby/Bundler/Worker/WrappedException.md b/example/ruby/Bundler/Worker/WrappedException.md deleted file mode 100644 index 7119d00..0000000 --- a/example/ruby/Bundler/Worker/WrappedException.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Bundler::Worker::WrappedException -**Inherits:** StandardError - - - - -# Attributes -## exception[RW] [](#attribute-i-exception) -Returns the value of attribute exception. - - -#Instance Methods -## initialize(exn) [](#method-i-initialize) - -**@return** [WrappedException] a new instance of WrappedException - diff --git a/example/ruby/Bundler/YAMLSerializer.md b/example/ruby/Bundler/YAMLSerializer.md deleted file mode 100644 index a08c5f2..0000000 --- a/example/ruby/Bundler/YAMLSerializer.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Bundler::YAMLSerializer - - -A stub yaml serializer that can handle only hashes and strings (as of now). - - -# Class Methods -## dump(hash ) [](#method-c-dump) -## dump_hash(hash ) [](#method-c-dump_hash) -## load(str ) [](#method-c-load) -## strip_comment(val ) [](#method-c-strip_comment) - diff --git a/example/ruby/Bundler/YamlSyntaxError.md b/example/ruby/Bundler/YamlSyntaxError.md deleted file mode 100644 index eaa4a64..0000000 --- a/example/ruby/Bundler/YamlSyntaxError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Bundler::YamlSyntaxError -**Inherits:** Bundler::BundlerError - - - - -# Attributes -## orig_exception[RW] [](#attribute-i-orig_exception) -Returns the value of attribute orig_exception. - - -#Instance Methods -## initialize(orig_exception, msg) [](#method-i-initialize) - -**@return** [YamlSyntaxError] a new instance of YamlSyntaxError - diff --git a/example/ruby/BundlerVCRHTTP.md b/example/ruby/BundlerVCRHTTP.md deleted file mode 100644 index 5b2825f..0000000 --- a/example/ruby/BundlerVCRHTTP.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: BundlerVCRHTTP -**Inherits:** Gem::Net::HTTP - - - - - -#Instance Methods -## request_with_vcr(request, *args, &block) [](#method-i-request_with_vcr) - -## start_with_vcr() [](#method-i-start_with_vcr) - diff --git a/example/ruby/BundlerVCRHTTP/RequestHandler.md b/example/ruby/BundlerVCRHTTP/RequestHandler.md deleted file mode 100644 index a60edf8..0000000 --- a/example/ruby/BundlerVCRHTTP/RequestHandler.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: BundlerVCRHTTP::RequestHandler -**Inherits:** Object - - - - -# Attributes -## body[RW] [](#attribute-i-body) -Returns the value of attribute body. - -## http[RW] [](#attribute-i-http) -Returns the value of attribute http. - -## request[RW] [](#attribute-i-request) -Returns the value of attribute request. - -## response_block[RW] [](#attribute-i-response_block) -Returns the value of attribute response_block. - - -#Instance Methods -## binwrite(path, contents) [](#method-i-binwrite) - -## file_name_for_key(key) [](#method-i-file_name_for_key) - -## handle_request() [](#method-i-handle_request) - -## initialize(http, request, bodynil, &response_block) [](#method-i-initialize) - -**@return** [RequestHandler] a new instance of RequestHandler - -## key() [](#method-i-key) - -## record_response() [](#method-i-record_response) - -## recorded_response() [](#method-i-recorded_response) - -## recorded_response?() [](#method-i-recorded_response?) - -**@return** [Boolean] - -## request_pair_paths() [](#method-i-request_pair_paths) - -## request_to_string(request) [](#method-i-request_to_string) - -## response_to_string(response) [](#method-i-response_to_string) - diff --git a/example/ruby/C.md b/example/ruby/C.md deleted file mode 100644 index 20cadec..0000000 --- a/example/ruby/C.md +++ /dev/null @@ -1,2254 +0,0 @@ -# Class: C -**Inherits:** Object - -**Includes:** Enumerable - - - - -# Class Methods -## CALL_DATA() [](#method-c-CALL_DATA) -## IC() [](#method-c-IC) -## ID() [](#method-c-ID) -## IVC() [](#method-c-IVC) -## RArray() [](#method-c-RArray) -## RB_BUILTIN() [](#method-c-RB_BUILTIN) -## RBasic() [](#method-c-RBasic) -## RObject() [](#method-c-RObject) -## RString() [](#method-c-RString) -## RStruct() [](#method-c-RStruct) -## VALUE() [](#method-c-VALUE) -## _Bool() [](#method-c-_Bool) -## attr_index_t() [](#method-c-attr_index_t) -## block_type_iseq() [](#method-c-block_type_iseq) -## ccan_list_head() [](#method-c-ccan_list_head) -## ccan_list_node() [](#method-c-ccan_list_node) -## idRespond_to_missing() [](#method-c-idRespond_to_missing) -## imemo_callinfo() [](#method-c-imemo_callinfo) -## imemo_iseq() [](#method-c-imemo_iseq) -## iseq_bits_t() [](#method-c-iseq_bits_t) -## iseq_catch_table() [](#method-c-iseq_catch_table) -## iseq_compile_data() [](#method-c-iseq_compile_data) -## iseq_inline_constant_cache() [](#method-c-iseq_inline_constant_cache) -## iseq_inline_constant_cache_entry() [](#method-c-iseq_inline_constant_cache_entry) -## iseq_inline_iv_cache_entry() [](#method-c-iseq_inline_iv_cache_entry) -## iseq_inline_storage_entry() [](#method-c-iseq_inline_storage_entry) -## iseq_insn_info() [](#method-c-iseq_insn_info) -## method_missing_reason() [](#method-c-method_missing_reason) -## method_optimized_type() [](#method-c-method_optimized_type) -## rb_ary_clear() [](#method-c-rb_ary_clear) -## rb_ary_dup() [](#method-c-rb_ary_dup) -## rb_ary_entry_internal() [](#method-c-rb_ary_entry_internal) -## rb_ary_push() [](#method-c-rb_ary_push) -## rb_ary_resurrect() [](#method-c-rb_ary_resurrect) -## rb_ary_store() [](#method-c-rb_ary_store) -## rb_ary_tmp_new_from_values() [](#method-c-rb_ary_tmp_new_from_values) -## rb_ary_unshift_m() [](#method-c-rb_ary_unshift_m) -## rb_atomic_t() [](#method-c-rb_atomic_t) -## rb_backref_get() [](#method-c-rb_backref_get) -## rb_block() [](#method-c-rb_block) -## rb_block_param_proxy() [](#method-c-rb_block_param_proxy) -## rb_block_type() [](#method-c-rb_block_type) -## rb_builtin_function() [](#method-c-rb_builtin_function) -## rb_cArray() [](#method-c-rb_cArray) -## rb_cFalseClass() [](#method-c-rb_cFalseClass) -## rb_cFloat() [](#method-c-rb_cFloat) -## rb_cInteger() [](#method-c-rb_cInteger) -## rb_cNilClass() [](#method-c-rb_cNilClass) -## rb_cString() [](#method-c-rb_cString) -## rb_cSymbol() [](#method-c-rb_cSymbol) -## rb_cTrueClass() [](#method-c-rb_cTrueClass) -## rb_call_data() [](#method-c-rb_call_data) -## rb_callable_method_entry_struct() [](#method-c-rb_callable_method_entry_struct) -## rb_callable_method_entry_t() [](#method-c-rb_callable_method_entry_t) -## rb_callcache() [](#method-c-rb_callcache) -## rb_callinfo() [](#method-c-rb_callinfo) -## rb_callinfo_kwarg() [](#method-c-rb_callinfo_kwarg) -## rb_calling_info() [](#method-c-rb_calling_info) -## rb_captured_block() [](#method-c-rb_captured_block) -## rb_cfunc_t() [](#method-c-rb_cfunc_t) -## rb_code_location_t() [](#method-c-rb_code_location_t) -## rb_control_frame_t() [](#method-c-rb_control_frame_t) -## rb_cref_struct() [](#method-c-rb_cref_struct) -## rb_cref_t() [](#method-c-rb_cref_t) -## rb_ec_ary_new_from_values() [](#method-c-rb_ec_ary_new_from_values) -## rb_ec_str_resurrect() [](#method-c-rb_ec_str_resurrect) -## rb_ensure_iv_list_size() [](#method-c-rb_ensure_iv_list_size) -## rb_event_flag_t() [](#method-c-rb_event_flag_t) -## rb_execution_context_struct() [](#method-c-rb_execution_context_struct) -## rb_execution_context_t() [](#method-c-rb_execution_context_t) -## rb_ext_config() [](#method-c-rb_ext_config) -## rb_fiber_t() [](#method-c-rb_fiber_t) -## rb_fix_aref() [](#method-c-rb_fix_aref) -## rb_fix_div_fix() [](#method-c-rb_fix_div_fix) -## rb_fix_mod_fix() [](#method-c-rb_fix_mod_fix) -## rb_fix_mul_fix() [](#method-c-rb_fix_mul_fix) -## rb_gc_writebarrier() [](#method-c-rb_gc_writebarrier) -## rb_get_symbol_id() [](#method-c-rb_get_symbol_id) -## rb_gvar_get() [](#method-c-rb_gvar_get) -## rb_hash_aref() [](#method-c-rb_hash_aref) -## rb_hash_aset() [](#method-c-rb_hash_aset) -## rb_hash_bulk_insert() [](#method-c-rb_hash_bulk_insert) -## rb_hash_new() [](#method-c-rb_hash_new) -## rb_hash_new_with_size() [](#method-c-rb_hash_new_with_size) -## rb_hash_resurrect() [](#method-c-rb_hash_resurrect) -## rb_hook_list_struct() [](#method-c-rb_hook_list_struct) -## rb_id_table() [](#method-c-rb_id_table) -## rb_iseq_constant_body() [](#method-c-rb_iseq_constant_body) -## rb_iseq_location_t() [](#method-c-rb_iseq_location_t) -## rb_iseq_param_keyword() [](#method-c-rb_iseq_param_keyword) -## rb_iseq_struct() [](#method-c-rb_iseq_struct) -## rb_iseq_t() [](#method-c-rb_iseq_t) -## rb_iseq_type() [](#method-c-rb_iseq_type) -## rb_iseqw_to_iseq(iseqw ) [](#method-c-rb_iseqw_to_iseq) -Convert RubyVM::InstructionSequence to C.rb_iseq_t. -## rb_ivar_defined() [](#method-c-rb_ivar_defined) -## rb_ivar_get() [](#method-c-rb_ivar_get) -## rb_jit_func_t() [](#method-c-rb_jit_func_t) -## rb_mRubyVMFrozenCore() [](#method-c-rb_mRubyVMFrozenCore) -## rb_method_alias_t() [](#method-c-rb_method_alias_t) -## rb_method_attr_t() [](#method-c-rb_method_attr_t) -## rb_method_bmethod_t() [](#method-c-rb_method_bmethod_t) -## rb_method_cfunc_t() [](#method-c-rb_method_cfunc_t) -## rb_method_definition_struct() [](#method-c-rb_method_definition_struct) -## rb_method_entry_t() [](#method-c-rb_method_entry_t) -## rb_method_iseq_t() [](#method-c-rb_method_iseq_t) -## rb_method_optimized_t() [](#method-c-rb_method_optimized_t) -## rb_method_refined_t() [](#method-c-rb_method_refined_t) -## rb_method_type_t() [](#method-c-rb_method_type_t) -## rb_mutex_struct() [](#method-c-rb_mutex_struct) -## rb_native_thread() [](#method-c-rb_native_thread) -## rb_nativethread_lock_t() [](#method-c-rb_nativethread_lock_t) -## rb_obj_as_string_result() [](#method-c-rb_obj_as_string_result) -## rb_obj_is_kind_of() [](#method-c-rb_obj_is_kind_of) -## rb_proc_t() [](#method-c-rb_proc_t) -## rb_ractor_t() [](#method-c-rb_ractor_t) -## rb_range_new() [](#method-c-rb_range_new) -## rb_reg_last_match() [](#method-c-rb_reg_last_match) -## rb_reg_match_last() [](#method-c-rb_reg_match_last) -## rb_reg_match_post() [](#method-c-rb_reg_match_post) -## rb_reg_match_pre() [](#method-c-rb_reg_match_pre) -## rb_reg_new_ary() [](#method-c-rb_reg_new_ary) -## rb_reg_nth_match() [](#method-c-rb_reg_nth_match) -## rb_rjit_branch_stub_hit() [](#method-c-rb_rjit_branch_stub_hit) -## rb_rjit_entry_stub_hit() [](#method-c-rb_rjit_entry_stub_hit) -## rb_rjit_global_events() [](#method-c-rb_rjit_global_events) -## rb_rjit_options() [](#method-c-rb_rjit_options) -## rb_rjit_runtime_counters() [](#method-c-rb_rjit_runtime_counters) -## rb_scope_visibility_t() [](#method-c-rb_scope_visibility_t) -## rb_serial_t() [](#method-c-rb_serial_t) -## rb_shape() [](#method-c-rb_shape) -## rb_shape_t() [](#method-c-rb_shape_t) -## rb_snum_t() [](#method-c-rb_snum_t) -## rb_str_buf_append() [](#method-c-rb_str_buf_append) -## rb_str_bytesize() [](#method-c-rb_str_bytesize) -## rb_str_concat_literals() [](#method-c-rb_str_concat_literals) -## rb_str_dup() [](#method-c-rb_str_dup) -## rb_str_eql_internal() [](#method-c-rb_str_eql_internal) -## rb_str_getbyte() [](#method-c-rb_str_getbyte) -## rb_str_intern() [](#method-c-rb_str_intern) -## rb_sym_to_proc() [](#method-c-rb_sym_to_proc) -## rb_thread_sched_item() [](#method-c-rb_thread_sched_item) -## rb_thread_struct() [](#method-c-rb_thread_struct) -## rb_trace_arg_struct() [](#method-c-rb_trace_arg_struct) -## rb_unblock_callback() [](#method-c-rb_unblock_callback) -## rb_vm_bh_to_procval() [](#method-c-rb_vm_bh_to_procval) -## rb_vm_concat_array() [](#method-c-rb_vm_concat_array) -## rb_vm_defined() [](#method-c-rb_vm_defined) -## rb_vm_get_ev_const() [](#method-c-rb_vm_get_ev_const) -## rb_vm_getclassvariable() [](#method-c-rb_vm_getclassvariable) -## rb_vm_ic_hit_p() [](#method-c-rb_vm_ic_hit_p) -## rb_vm_insn_encode(bin ) [](#method-c-rb_vm_insn_encode) -Convert insn BINs to encoded VM pointers. -## rb_vm_insns_count() [](#method-c-rb_vm_insns_count) -## rb_vm_opt_newarray_hash() [](#method-c-rb_vm_opt_newarray_hash) -## rb_vm_opt_newarray_max() [](#method-c-rb_vm_opt_newarray_max) -## rb_vm_opt_newarray_min() [](#method-c-rb_vm_opt_newarray_min) -## rb_vm_opt_newarray_pack() [](#method-c-rb_vm_opt_newarray_pack) -## rb_vm_set_ivar_id() [](#method-c-rb_vm_set_ivar_id) -## rb_vm_setclassvariable() [](#method-c-rb_vm_setclassvariable) -## rb_vm_setinstancevariable() [](#method-c-rb_vm_setinstancevariable) -## rb_vm_splat_array() [](#method-c-rb_vm_splat_array) -## rb_vm_t() [](#method-c-rb_vm_t) -## rb_vm_tag() [](#method-c-rb_vm_tag) -## rb_vm_throw() [](#method-c-rb_vm_throw) -## rb_vm_yield_with_cfunc() [](#method-c-rb_vm_yield_with_cfunc) -## rb_waiting_list() [](#method-c-rb_waiting_list) -## redblack_node_t() [](#method-c-redblack_node_t) -## rjit_build_kwhash() [](#method-c-rjit_build_kwhash) -## rjit_full_cfunc_return() [](#method-c-rjit_full_cfunc_return) -## rjit_optimized_call() [](#method-c-rjit_optimized_call) -## rjit_rb_ary_subseq_length() [](#method-c-rjit_rb_ary_subseq_length) -## rjit_record_exit_stack() [](#method-c-rjit_record_exit_stack) -## rjit_str_neq_internal() [](#method-c-rjit_str_neq_internal) -## rjit_str_simple_append() [](#method-c-rjit_str_simple_append) -## shape_id_t() [](#method-c-shape_id_t) -## thread_invoke_type() [](#method-c-thread_invoke_type) -## vm_call_handler() [](#method-c-vm_call_handler) -## vm_ifunc() [](#method-c-vm_ifunc) - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) - -**@return** [C] a new instance of C - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/CApiClassSpecs.md b/example/ruby/CApiClassSpecs.md deleted file mode 100644 index 139042d..0000000 --- a/example/ruby/CApiClassSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiClassSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiClassSpecs/A.md b/example/ruby/CApiClassSpecs/A.md deleted file mode 100644 index b90c5b7..0000000 --- a/example/ruby/CApiClassSpecs/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiClassSpecs::A -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiClassSpecs/A/B.md b/example/ruby/CApiClassSpecs/A/B.md deleted file mode 100644 index 4288749..0000000 --- a/example/ruby/CApiClassSpecs/A/B.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiClassSpecs::A::B -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiClassSpecs/A/D.md b/example/ruby/CApiClassSpecs/A/D.md deleted file mode 100644 index b0bd110..0000000 --- a/example/ruby/CApiClassSpecs/A/D.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CApiClassSpecs::A::D - - - - - diff --git a/example/ruby/CApiClassSpecs/A/M.md b/example/ruby/CApiClassSpecs/A/M.md deleted file mode 100644 index de486dc..0000000 --- a/example/ruby/CApiClassSpecs/A/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CApiClassSpecs::A::M - - - - - diff --git a/example/ruby/CApiClassSpecs/Alloc.md b/example/ruby/CApiClassSpecs/Alloc.md deleted file mode 100644 index fd436b6..0000000 --- a/example/ruby/CApiClassSpecs/Alloc.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: CApiClassSpecs::Alloc -**Inherits:** Object - - - - -# Attributes -## arguments[RW] [](#attribute-i-arguments) -Returns the value of attribute arguments. - -## initialized[RW] [](#attribute-i-initialized) -Returns the value of attribute initialized. - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [Alloc] a new instance of Alloc - diff --git a/example/ruby/CApiClassSpecs/Attr.md b/example/ruby/CApiClassSpecs/Attr.md deleted file mode 100644 index e3f4378..0000000 --- a/example/ruby/CApiClassSpecs/Attr.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: CApiClassSpecs::Attr -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Attr] a new instance of Attr - diff --git a/example/ruby/CApiClassSpecs/CVars.md b/example/ruby/CApiClassSpecs/CVars.md deleted file mode 100644 index 2c6db70..0000000 --- a/example/ruby/CApiClassSpecs/CVars.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: CApiClassSpecs::CVars -**Inherits:** Object - - - - - -#Instance Methods -## new_cv() [](#method-i-new_cv) - -## new_cvar() [](#method-i-new_cvar) - -## rbdcv_cvar() [](#method-i-rbdcv_cvar) - diff --git a/example/ruby/CApiClassSpecs/Inherited.md b/example/ruby/CApiClassSpecs/Inherited.md deleted file mode 100644 index c263385..0000000 --- a/example/ruby/CApiClassSpecs/Inherited.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: CApiClassSpecs::Inherited -**Inherits:** Object - - - - -# Class Methods -## inherited(klass ) [](#method-c-inherited) -**@private** [] - - diff --git a/example/ruby/CApiClassSpecs/KeywordAlloc.md b/example/ruby/CApiClassSpecs/KeywordAlloc.md deleted file mode 100644 index f01518f..0000000 --- a/example/ruby/CApiClassSpecs/KeywordAlloc.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: CApiClassSpecs::KeywordAlloc -**Inherits:** Object - - - - -# Attributes -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## initialized[RW] [](#attribute-i-initialized) -Returns the value of attribute initialized. - -## kwargs[RW] [](#attribute-i-kwargs) -Returns the value of attribute kwargs. - - -#Instance Methods -## initialize(*args, **kwargs) [](#method-i-initialize) - -**@return** [KeywordAlloc] a new instance of KeywordAlloc - diff --git a/example/ruby/CApiClassSpecs/M.md b/example/ruby/CApiClassSpecs/M.md deleted file mode 100644 index ec3ff4a..0000000 --- a/example/ruby/CApiClassSpecs/M.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: CApiClassSpecs::M - - - - - -#Instance Methods -## included?() [](#method-i-included?) - -**@return** [Boolean] - diff --git a/example/ruby/CApiClassSpecs/NewClass.md b/example/ruby/CApiClassSpecs/NewClass.md deleted file mode 100644 index b8bb8dd..0000000 --- a/example/ruby/CApiClassSpecs/NewClass.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: CApiClassSpecs::NewClass -**Inherits:** Object - - - - -# Class Methods -## inherited(klass ) [](#method-c-inherited) -**@private** [] - - diff --git a/example/ruby/CApiClassSpecs/Sub.md b/example/ruby/CApiClassSpecs/Sub.md deleted file mode 100644 index 7dad633..0000000 --- a/example/ruby/CApiClassSpecs/Sub.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: CApiClassSpecs::Sub -**Inherits:** CApiClassSpecs::Super - - - - - -#Instance Methods -## call_super_method() [](#method-i-call_super_method) - diff --git a/example/ruby/CApiClassSpecs/SubM.md b/example/ruby/CApiClassSpecs/SubM.md deleted file mode 100644 index 2cf85d8..0000000 --- a/example/ruby/CApiClassSpecs/SubM.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: CApiClassSpecs::SubM -**Inherits:** CApiClassSpecs::Super - -**Includes:** CApiClassSpecs::M - - - - - -#Instance Methods -## included?() [](#method-i-included?) - -**@return** [Boolean] - diff --git a/example/ruby/CApiClassSpecs/SubSelf.md b/example/ruby/CApiClassSpecs/SubSelf.md deleted file mode 100644 index 8a9b80a..0000000 --- a/example/ruby/CApiClassSpecs/SubSelf.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiClassSpecs::SubSelf -**Inherits:** CApiClassSpecs::SuperSelf - - - - - diff --git a/example/ruby/CApiClassSpecs/SubSub.md b/example/ruby/CApiClassSpecs/SubSub.md deleted file mode 100644 index 34f7ca7..0000000 --- a/example/ruby/CApiClassSpecs/SubSub.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: CApiClassSpecs::SubSub -**Inherits:** CApiClassSpecs::Sub - - - - - -#Instance Methods -## call_super_method() [](#method-i-call_super_method) - diff --git a/example/ruby/CApiClassSpecs/Super.md b/example/ruby/CApiClassSpecs/Super.md deleted file mode 100644 index 786b039..0000000 --- a/example/ruby/CApiClassSpecs/Super.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: CApiClassSpecs::Super -**Inherits:** Object - - - - - -#Instance Methods -## call_super_method() [](#method-i-call_super_method) - diff --git a/example/ruby/CApiClassSpecs/SuperSelf.md b/example/ruby/CApiClassSpecs/SuperSelf.md deleted file mode 100644 index 17554b9..0000000 --- a/example/ruby/CApiClassSpecs/SuperSelf.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: CApiClassSpecs::SuperSelf -**Inherits:** Object - - - - - -#Instance Methods -## call_super_method() [](#method-i-call_super_method) - diff --git a/example/ruby/CApiEncodingSpecs.md b/example/ruby/CApiEncodingSpecs.md deleted file mode 100644 index 5d76f7c..0000000 --- a/example/ruby/CApiEncodingSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiEncodingSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiEncodingSpecs/S.md b/example/ruby/CApiEncodingSpecs/S.md deleted file mode 100644 index 23acf6f..0000000 --- a/example/ruby/CApiEncodingSpecs/S.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiEncodingSpecs::S -**Inherits:** String - - - - - diff --git a/example/ruby/CApiKernelSpecs.md b/example/ruby/CApiKernelSpecs.md deleted file mode 100644 index 70ef677..0000000 --- a/example/ruby/CApiKernelSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiKernelSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiKernelSpecs/ClassWithPrivateMethod.md b/example/ruby/CApiKernelSpecs/ClassWithPrivateMethod.md deleted file mode 100644 index 37a10db..0000000 --- a/example/ruby/CApiKernelSpecs/ClassWithPrivateMethod.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiKernelSpecs::ClassWithPrivateMethod -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiKernelSpecs/ClassWithProtectedMethod.md b/example/ruby/CApiKernelSpecs/ClassWithProtectedMethod.md deleted file mode 100644 index 56ae176..0000000 --- a/example/ruby/CApiKernelSpecs/ClassWithProtectedMethod.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiKernelSpecs::ClassWithProtectedMethod -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiKernelSpecs/ClassWithPublicMethod.md b/example/ruby/CApiKernelSpecs/ClassWithPublicMethod.md deleted file mode 100644 index 17a5492..0000000 --- a/example/ruby/CApiKernelSpecs/ClassWithPublicMethod.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: CApiKernelSpecs::ClassWithPublicMethod -**Inherits:** Object - - - - - -#Instance Methods -## public_method() [](#method-i-public_method) - diff --git a/example/ruby/CApiKernelSpecs/Exc.md b/example/ruby/CApiKernelSpecs/Exc.md deleted file mode 100644 index 63c2c58..0000000 --- a/example/ruby/CApiKernelSpecs/Exc.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: CApiKernelSpecs::Exc -**Inherits:** StandardError - - - - - diff --git a/example/ruby/CApiModuleSpecs.md b/example/ruby/CApiModuleSpecs.md deleted file mode 100644 index eb52025..0000000 --- a/example/ruby/CApiModuleSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiModuleSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiModuleSpecs/A.md b/example/ruby/CApiModuleSpecs/A.md deleted file mode 100644 index 42a308f..0000000 --- a/example/ruby/CApiModuleSpecs/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiModuleSpecs::A -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiModuleSpecs/B.md b/example/ruby/CApiModuleSpecs/B.md deleted file mode 100644 index 9244e43..0000000 --- a/example/ruby/CApiModuleSpecs/B.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiModuleSpecs::B -**Inherits:** CApiModuleSpecs::A - - - - - diff --git a/example/ruby/CApiModuleSpecs/C.md b/example/ruby/CApiModuleSpecs/C.md deleted file mode 100644 index 0385841..0000000 --- a/example/ruby/CApiModuleSpecs/C.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiModuleSpecs::C -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiModuleSpecs/M.md b/example/ruby/CApiModuleSpecs/M.md deleted file mode 100644 index 024bf06..0000000 --- a/example/ruby/CApiModuleSpecs/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CApiModuleSpecs::M - - - - - diff --git a/example/ruby/CApiModuleSpecs/RubyUnderAutoload.md b/example/ruby/CApiModuleSpecs/RubyUnderAutoload.md deleted file mode 100644 index 3c6bddd..0000000 --- a/example/ruby/CApiModuleSpecs/RubyUnderAutoload.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CApiModuleSpecs::RubyUnderAutoload - - - - - diff --git a/example/ruby/CApiModuleSpecs/Super.md b/example/ruby/CApiModuleSpecs/Super.md deleted file mode 100644 index 0c79fee..0000000 --- a/example/ruby/CApiModuleSpecs/Super.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiModuleSpecs::Super -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiObjectSpecs.md b/example/ruby/CApiObjectSpecs.md deleted file mode 100644 index b9a29ac..0000000 --- a/example/ruby/CApiObjectSpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: CApiObjectSpecs -**Inherits:** Object - - -TODO: fix all these specs - - - diff --git a/example/ruby/CApiObjectSpecs/Alloc.md b/example/ruby/CApiObjectSpecs/Alloc.md deleted file mode 100644 index 5661ed4..0000000 --- a/example/ruby/CApiObjectSpecs/Alloc.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: CApiObjectSpecs::Alloc -**Inherits:** Object - - - - -# Attributes -## arguments[RW] [](#attribute-i-arguments) -Returns the value of attribute arguments. - -## initialized[RW] [](#attribute-i-initialized) -Returns the value of attribute initialized. - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [Alloc] a new instance of Alloc - diff --git a/example/ruby/CApiObjectSpecs/CVars.md b/example/ruby/CApiObjectSpecs/CVars.md deleted file mode 100644 index ce5ec47..0000000 --- a/example/ruby/CApiObjectSpecs/CVars.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CApiObjectSpecs::CVars - - - - - diff --git a/example/ruby/CApiObjectSpecs/IVars.md b/example/ruby/CApiObjectSpecs/IVars.md deleted file mode 100644 index fa258bf..0000000 --- a/example/ruby/CApiObjectSpecs/IVars.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: CApiObjectSpecs::IVars -**Inherits:** Object - - - - -# Class Methods -## set_class_variables() [](#method-c-set_class_variables) - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [IVars] a new instance of IVars - diff --git a/example/ruby/CApiObjectSpecs/MVars.md b/example/ruby/CApiObjectSpecs/MVars.md deleted file mode 100644 index ab96971..0000000 --- a/example/ruby/CApiObjectSpecs/MVars.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CApiObjectSpecs::MVars - - - - - diff --git a/example/ruby/CApiObjectSpecs/SubArray.md b/example/ruby/CApiObjectSpecs/SubArray.md deleted file mode 100644 index 91cedff..0000000 --- a/example/ruby/CApiObjectSpecs/SubArray.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: CApiObjectSpecs::SubArray -**Inherits:** Array - - - - - -#Instance Methods -## to_array() [](#method-i-to_array) - diff --git a/example/ruby/CApiProcSpecs.md b/example/ruby/CApiProcSpecs.md deleted file mode 100644 index 3132638..0000000 --- a/example/ruby/CApiProcSpecs.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: CApiProcSpecs -**Inherits:** Object - - - - - -#Instance Methods -## call_Proc_new() [](#method-i-call_Proc_new) - -## call_block_given?() [](#method-i-call_block_given?) - -**@return** [Boolean] - -## call_nothing() [](#method-i-call_nothing) - -## call_rb_Proc_new() [](#method-i-call_rb_Proc_new) - -## call_rb_Proc_new_with_block() [](#method-i-call_rb_Proc_new_with_block) - diff --git a/example/ruby/CApiStringSpecs.md b/example/ruby/CApiStringSpecs.md deleted file mode 100644 index de0b24a..0000000 --- a/example/ruby/CApiStringSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CApiStringSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/CApiStringSpecs/InvalidTostrTest.md b/example/ruby/CApiStringSpecs/InvalidTostrTest.md deleted file mode 100644 index 8e7e2b6..0000000 --- a/example/ruby/CApiStringSpecs/InvalidTostrTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: CApiStringSpecs::InvalidTostrTest -**Inherits:** Object - - - - - -#Instance Methods -## to_str() [](#method-i-to_str) - diff --git a/example/ruby/CApiStringSpecs/ToSOrInspect.md b/example/ruby/CApiStringSpecs/ToSOrInspect.md deleted file mode 100644 index 8d7b753..0000000 --- a/example/ruby/CApiStringSpecs/ToSOrInspect.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: CApiStringSpecs::ToSOrInspect -**Inherits:** Object - - - - - -#Instance Methods -## inspect() [](#method-i-inspect) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/CApiStringSpecs/ValidTostrTest.md b/example/ruby/CApiStringSpecs/ValidTostrTest.md deleted file mode 100644 index 2391e66..0000000 --- a/example/ruby/CApiStringSpecs/ValidTostrTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: CApiStringSpecs::ValidTostrTest -**Inherits:** Object - - - - - -#Instance Methods -## to_str() [](#method-i-to_str) - diff --git a/example/ruby/CGI.md b/example/ruby/CGI.md deleted file mode 100644 index 9d87545..0000000 --- a/example/ruby/CGI.md +++ /dev/null @@ -1,494 +0,0 @@ -# Class: CGI -**Inherits:** Object - -**Extended by:** CGI::Util - -**Includes:** CGI::Util - - --- Methods for generating HTML, parsing CGI-related parameters, and generating -HTTP responses. ++ - - -# Class Methods -## accept_charset() [](#method-c-accept_charset) -Return the accept character set for all new CGI instances. -## accept_charset=(accept_charset ) [](#method-c-accept_charset=) -Set the accept character set for all new CGI instances. -## escape(string ) [](#method-c-escape) -URL-encode a string into application/x-www-form-urlencoded. Space characters -(+" "+) are encoded with plus signs (+"+"+) - url_encoded_string = CGI.escape("'Stop!' said Fred") - # => "%27Stop%21%27+said+Fred" -## escapeElement(string , *elements ) [](#method-c-escapeElement) -Escape only the tags of certain HTML elements in `string`. - -Takes an element or elements or array of elements. Each element is specified -by the name of the element, without angle brackets. This matches both the -start and the end tag of that element. The attribute list of the open tag will -also be escaped (for instance, the double-quotes surrounding attribute -values). - - print CGI.escapeElement('
', "A", "IMG") - # "
<A HREF="url"></A>" - - print CGI.escapeElement('
', ["A", "IMG"]) - # "
<A HREF="url"></A>" -## escapeHTML(string ) [](#method-c-escapeHTML) -Escape special characters in HTML, namely '&"<> - CGI.escapeHTML('Usage: foo "bar" ') - # => "Usage: foo "bar" <baz>" -## escapeURIComponent(string ) [](#method-c-escapeURIComponent) -URL-encode a string following RFC 3986 Space characters (+" "+) are encoded -with (+"%20"+) - url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred") - # => "%27Stop%21%27%20said%20Fred" -## parse(query ) [](#method-c-parse) -Parse an HTTP query string into a hash of key=>value pairs. - - params = CGI.parse("query_string") - # {"name1" => ["value1", "value2", ...], - # "name2" => ["value1", "value2", ...], ... } -## pretty(string , shift " ") [](#method-c-pretty) -Prettify (indent) an HTML string. - -`string` is the HTML string to indent. `shift` is the indentation unit to -use; it defaults to two spaces. - - print CGI.pretty("") - # - # - # - # - - print CGI.pretty("", "\t") - # - # - # - # -## rfc1123_date(time ) [](#method-c-rfc1123_date) -Format a `Time` object as a String using the format specified by RFC 1123. - - CGI.rfc1123_date(Time.now) - # Sat, 01 Jan 2000 00:00:00 GMT -## unescape(string , encoding @@accept_charset) [](#method-c-unescape) -URL-decode an application/x-www-form-urlencoded string with -encoding(optional). - string = CGI.unescape("%27Stop%21%27+said+Fred") - # => "'Stop!' said Fred" -## unescapeElement(string , *elements ) [](#method-c-unescapeElement) -Undo escaping such as that done by CGI.escapeElement() - - print CGI.unescapeElement( - CGI.escapeHTML('
'), "A", "IMG") - # "<BR>" - - print CGI.unescapeElement( - CGI.escapeHTML('
'), ["A", "IMG"]) - # "<BR>" -## unescapeHTML(string ) [](#method-c-unescapeHTML) -Unescape a string that has been HTML-escaped - CGI.unescapeHTML("Usage: foo "bar" <baz>") - # => "Usage: foo \"bar\" " -## unescapeURIComponent(string , encoding @@accept_charset) [](#method-c-unescapeURIComponent) -URL-decode a string following RFC 3986 with encoding(optional). - string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred") - # => "'Stop!'+said Fred" -# Attributes -## accept_charset[RW] [](#attribute-i-accept_charset) -Return the accept character set for this CGI instance. - - -#Instance Methods -## escape(string) [](#method-i-escape) -URL-encode a string into application/x-www-form-urlencoded. Space characters -(+" "+) are encoded with plus signs (+"+"+) - url_encoded_string = CGI.escape("'Stop!' said Fred") - # => "%27Stop%21%27+said+Fred" - -## escapeElement(string, *elements) [](#method-i-escapeElement) -Escape only the tags of certain HTML elements in `string`. - -Takes an element or elements or array of elements. Each element is specified -by the name of the element, without angle brackets. This matches both the -start and the end tag of that element. The attribute list of the open tag will -also be escaped (for instance, the double-quotes surrounding attribute -values). - - print CGI.escapeElement('
', "A", "IMG") - # "
<A HREF="url"></A>" - - print CGI.escapeElement('
', ["A", "IMG"]) - # "
<A HREF="url"></A>" - -## escapeHTML(string) [](#method-i-escapeHTML) -Escape special characters in HTML, namely '&"<> - CGI.escapeHTML('Usage: foo "bar" ') - # => "Usage: foo "bar" <baz>" - -## escapeURIComponent(string) [](#method-i-escapeURIComponent) -URL-encode a string following RFC 3986 Space characters (+" "+) are encoded -with (+"%20"+) - url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred") - # => "%27Stop%21%27%20said%20Fred" - -## http_header(options'text/html') [](#method-i-http_header) -Create an HTTP header block as a string. - -:call-seq: - http_header(content_type_string="text/html") - http_header(headers_hash) - -Includes the empty line that ends the header block. - -`content_type_string` -: If this form is used, this string is the `Content-Type` - -`headers_hash` -: A Hash of header values. The following header keys are recognized: - - type -: The Content-Type header. Defaults to "text/html" - - charset -: The charset of the body, appended to the Content-Type header. - - nph -: A boolean value. If true, prepend protocol string and status code, - and date; and sets default values for "server" and "connection" if not - explicitly set. - - status -: The HTTP status code as a String, returned as the Status header. The - values are: - - OK -: 200 OK - - PARTIAL_CONTENT -: 206 Partial Content - - MULTIPLE_CHOICES -: 300 Multiple Choices - - MOVED -: 301 Moved Permanently - - REDIRECT -: 302 Found - - NOT_MODIFIED -: 304 Not Modified - - BAD_REQUEST -: 400 Bad Request - - AUTH_REQUIRED -: 401 Authorization Required - - FORBIDDEN -: 403 Forbidden - - NOT_FOUND -: 404 Not Found - - METHOD_NOT_ALLOWED -: 405 Method Not Allowed - - NOT_ACCEPTABLE -: 406 Not Acceptable - - LENGTH_REQUIRED -: 411 Length Required - - PRECONDITION_FAILED -: 412 Precondition Failed - - SERVER_ERROR -: 500 Internal Server Error - - NOT_IMPLEMENTED -: 501 Method Not Implemented - - BAD_GATEWAY -: 502 Bad Gateway - - VARIANT_ALSO_VARIES -: 506 Variant Also Negotiates - - - - server -: The server software, returned as the Server header. - - connection -: The connection type, returned as the Connection header (for instance, - "close". - - length -: The length of the content that will be sent, returned as the - Content-Length header. - - language -: The language of the content, returned as the Content-Language header. - - expires -: The time on which the current content expires, as a `Time` object, - returned as the Expires header. - - cookie -: A cookie or cookies, returned as one or more Set-Cookie headers. The - value can be the literal string of the cookie; a CGI::Cookie object; - an Array of literal cookie strings or Cookie objects; or a hash all of - whose values are literal cookie strings or Cookie objects. - - These cookies are in addition to the cookies held in the - @output_cookies field. - - - Other headers can also be set; they are appended as key: value. - - -Examples: - - http_header - # Content-Type: text/html - - http_header("text/plain") - # Content-Type: text/plain - - http_header("nph" => true, - "status" => "OK", # == "200 OK" - # "status" => "200 GOOD", - "server" => ENV['SERVER_SOFTWARE'], - "connection" => "close", - "type" => "text/html", - "charset" => "iso-2022-jp", - # Content-Type: text/html; charset=iso-2022-jp - "length" => 103, - "language" => "ja", - "expires" => Time.now + 30, - "cookie" => [cookie1, cookie2], - "my_header1" => "my_value", - "my_header2" => "my_value") - -This method does not perform charset conversion. - -## initialize(options{}, &block) [](#method-i-initialize) -Create a new CGI instance. - -:call-seq: - CGI.new(tag_maker) { block } - CGI.new(options_hash = {}) { block } - -`tag_maker` -: This is the same as using the `options_hash` form with the value `{ - :tag_maker => tag_maker }` Note that it is recommended to use the - `options_hash` form, since it also allows you specify the charset you will - accept. - -`options_hash` -: A Hash that recognizes three options: - - `:accept_charset` -: specifies encoding of received query string. If omitted, - `@@accept_charset` is used. If the encoding is not valid, a - CGI::InvalidEncoding will be raised. - - Example. Suppose `@@accept_charset` is "UTF-8" - - when not specified: - - cgi=CGI.new # @accept_charset # => "UTF-8" - - when specified as "EUC-JP": - - cgi=CGI.new(:accept_charset => "EUC-JP") # => "EUC-JP" - - - `:tag_maker` -: String that specifies which version of the HTML generation methods to - use. If not specified, no HTML generation methods will be loaded. - - The following values are supported: - - "html3" -: HTML 3.x - - "html4" -: HTML 4.0 - - "html4Tr" -: HTML 4.0 Transitional - - "html4Fr" -: HTML 4.0 with Framesets - - "html5" -: HTML 5 - - - - `:max_multipart_length` -: Specifies maximum length of multipart data. Can be an Integer scalar - or a lambda, that will be evaluated when the request is parsed. This - allows more complex logic to be set when determining whether to accept - multipart data (e.g. consult a registered users upload allowance) - - Default is 128 * 1024 * 1024 bytes - - cgi=CGI.new(:max_multipart_length => 268435456) # simple scalar - - cgi=CGI.new(:max_multipart_length => -> {check_filesystem}) # lambda - - - -`block` -: If provided, the block is called when an invalid encoding is encountered. - For example: - - encoding_errors={} - cgi=CGI.new(:accept_charset=>"EUC-JP") do |name,value| - encoding_errors[name] = value - end - - -Finally, if the CGI object is not created in a standard CGI call environment -(that is, it can't locate REQUEST_METHOD in its environment), then it will run -in "offline" mode. In this mode, it reads its parameters from the command -line or (failing that) from standard input. Otherwise, cookies and other -parameters are parsed automatically from the standard CGI locations, which -varies according to the REQUEST_METHOD. - -**@return** [CGI] a new instance of CGI - -## nph?() [](#method-i-nph?) -:nodoc: - -**@return** [Boolean] - -## out(options"text/html") [](#method-i-out) -Print an HTTP header and body to $DEFAULT_OUTPUT ($>) - -:call-seq: - cgi.out(content_type_string='text/html') - cgi.out(headers_hash) - -`content_type_string` -: If a string is passed, it is assumed to be the content type. - -`headers_hash` -: This is a Hash of headers, similar to that used by #http_header. - -`block` -: A block is required and should evaluate to the body of the response. - - -`Content-Length` is automatically calculated from the size of the String -returned by the content block. - -If `ENV['REQUEST_METHOD'] == "HEAD"`, then only the header is output (the -content block is still required, but it is ignored). - -If the charset is "iso-2022-jp" or "euc-jp" or "shift_jis" then the content is -converted to this charset, and the language is set to "ja". - -Example: - - cgi = CGI.new - cgi.out{ "string" } - # Content-Type: text/html - # Content-Length: 6 - # - # string - - cgi.out("text/plain") { "string" } - # Content-Type: text/plain - # Content-Length: 6 - # - # string - - cgi.out("nph" => true, - "status" => "OK", # == "200 OK" - "server" => ENV['SERVER_SOFTWARE'], - "connection" => "close", - "type" => "text/html", - "charset" => "iso-2022-jp", - # Content-Type: text/html; charset=iso-2022-jp - "language" => "ja", - "expires" => Time.now + (3600 * 24 * 30), - "cookie" => [cookie1, cookie2], - "my_header1" => "my_value", - "my_header2" => "my_value") { "string" } - # HTTP/1.1 200 OK - # Date: Sun, 15 May 2011 17:35:54 GMT - # Server: Apache 2.2.0 - # Connection: close - # Content-Type: text/html; charset=iso-2022-jp - # Content-Length: 6 - # Content-Language: ja - # Expires: Tue, 14 Jun 2011 17:35:54 GMT - # Set-Cookie: foo - # Set-Cookie: bar - # my_header1: my_value - # my_header2: my_value - # - # string - -## pretty(string, shift" ") [](#method-i-pretty) -Prettify (indent) an HTML string. - -`string` is the HTML string to indent. `shift` is the indentation unit to -use; it defaults to two spaces. - - print CGI.pretty("") - # - # - # - # - - print CGI.pretty("", "\t") - # - # - # - # - -## print(*options) [](#method-i-print) -Print an argument or list of arguments to the default output stream - - cgi = CGI.new - cgi.print # default: cgi.print == $DEFAULT_OUTPUT.print - -## rfc1123_date(time) [](#method-i-rfc1123_date) -Format a `Time` object as a String using the format specified by RFC 1123. - - CGI.rfc1123_date(Time.now) - # Sat, 01 Jan 2000 00:00:00 GMT - -## unescape(string, encoding@@accept_charset) [](#method-i-unescape) -URL-decode an application/x-www-form-urlencoded string with -encoding(optional). - string = CGI.unescape("%27Stop%21%27+said+Fred") - # => "'Stop!' said Fred" - -## unescapeElement(string, *elements) [](#method-i-unescapeElement) -Undo escaping such as that done by CGI.escapeElement() - - print CGI.unescapeElement( - CGI.escapeHTML('
'), "A", "IMG") - # "<BR>" - - print CGI.unescapeElement( - CGI.escapeHTML('
'), ["A", "IMG"]) - # "<BR>" - -## unescapeHTML(string) [](#method-i-unescapeHTML) -Unescape a string that has been HTML-escaped - CGI.unescapeHTML("Usage: foo "bar" <baz>") - # => "Usage: foo \"bar\" " - -## unescapeURIComponent(string, encoding@@accept_charset) [](#method-i-unescapeURIComponent) -URL-decode a string following RFC 3986 with encoding(optional). - string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred") - # => "'Stop!'+said Fred" - diff --git a/example/ruby/CGI/Cookie.md b/example/ruby/CGI/Cookie.md deleted file mode 100644 index 65aa4e9..0000000 --- a/example/ruby/CGI/Cookie.md +++ /dev/null @@ -1,129 +0,0 @@ -# Class: CGI::Cookie -**Inherits:** Array - - -Class representing an HTTP cookie. - -In addition to its specific fields and methods, a Cookie instance is a -delegator to the array of its values. - -See RFC 2965. - -## Examples of use - cookie1 = CGI::Cookie.new("name", "value1", "value2", ...) - cookie1 = CGI::Cookie.new("name" => "name", "value" => "value") - cookie1 = CGI::Cookie.new('name' => 'name', - 'value' => ['value1', 'value2', ...], - 'path' => 'path', # optional - 'domain' => 'domain', # optional - 'expires' => Time.now, # optional - 'secure' => true, # optional - 'httponly' => true # optional - ) - - cgi.out("cookie" => [cookie1, cookie2]) { "string" } - - name = cookie1.name - values = cookie1.value - path = cookie1.path - domain = cookie1.domain - expires = cookie1.expires - secure = cookie1.secure - httponly = cookie1.httponly - - cookie1.name = 'name' - cookie1.value = ['value1', 'value2', ...] - cookie1.path = 'path' - cookie1.domain = 'domain' - cookie1.expires = Time.now + 30 - cookie1.secure = true - cookie1.httponly = true - - -# Class Methods -## parse(raw_cookie ) [](#method-c-parse) -Parse a raw cookie string into a hash of cookie-name=>Cookie pairs. - - cookies = CGI::Cookie.parse("raw_cookie_string") - # { "name1" => cookie1, "name2" => cookie2, ... } -# Attributes -## domain[RW] [](#attribute-i-domain) -Domain for which this cookie applies, as a `String` - -## expires[RW] [](#attribute-i-expires) -Time at which this cookie expires, as a `Time` - -## httponly[RW] [](#attribute-i-httponly) -True if this cookie is httponly; false otherwise - -## name[RW] [](#attribute-i-name) -Name of this cookie, as a `String` - -## path[RW] [](#attribute-i-path) -Path for which this cookie applies, as a `String` - -## secure[RW] [](#attribute-i-secure) -True if this cookie is secure; false otherwise - - -#Instance Methods -## initialize(name"", *value) [](#method-i-initialize) -Create a new CGI::Cookie object. - -:call-seq: - Cookie.new(name_string,*value) - Cookie.new(options_hash) - -`name_string` -: The name of the cookie; in this form, there is no #domain or #expiration. - The #path is gleaned from the `SCRIPT_NAME` environment variable, and - #secure is false. - -`*value` -: value or list of values of the cookie - -`options_hash` -: A Hash of options to initialize this Cookie. Possible options are: - - name -: the name of the cookie. Required. - - value -: the cookie's value or list of values. - - path -: the path for which this cookie applies. Defaults to the value of the - `SCRIPT_NAME` environment variable. - - domain -: the domain for which this cookie applies. - - expires -: the time at which this cookie expires, as a `Time` object. - - secure -: whether this cookie is a secure cookie or not (default to false). - Secure cookies are only transmitted to HTTPS servers. - - httponly -: whether this cookie is a HttpOnly cookie or not (default to - - false). HttpOnly cookies are not available to javascript. - - These keywords correspond to attributes of the cookie object. - - -**@return** [Cookie] a new instance of Cookie - -## inspect() [](#method-i-inspect) -A summary of cookie string. - -## to_s() [](#method-i-to_s) -Convert the Cookie to its string representation. - -## value() [](#method-i-value) -Returns the value or list of values for this cookie. - -## value=(val) [](#method-i-value=) -Replaces the value of this cookie with a new value or list of values. - diff --git a/example/ruby/CGI/Escape.md b/example/ruby/CGI/Escape.md deleted file mode 100644 index ff8aff6..0000000 --- a/example/ruby/CGI/Escape.md +++ /dev/null @@ -1,37 +0,0 @@ -# Module: CGI::Escape - - - - - -#Instance Methods -## escape(str) [](#method-i-escape) -Returns URL-escaped string (`application/x-www-form-urlencoded`). - -**@overload** [] - -## escapeHTML(str) [](#method-i-escapeHTML) -Returns HTML-escaped string. - -**@overload** [] - -## escapeURIComponent(str) [](#method-i-escapeURIComponent) -Returns URL-escaped string following RFC 3986. - -**@overload** [] - -## unescape(*args) [](#method-i-unescape) -Returns URL-unescaped string (`application/x-www-form-urlencoded`). - -**@overload** [] - -## unescapeHTML(str) [](#method-i-unescapeHTML) -Returns HTML-unescaped string. - -**@overload** [] - -## unescapeURIComponent(*args) [](#method-i-unescapeURIComponent) -Returns URL-unescaped string following RFC 3986. - -**@overload** [] - diff --git a/example/ruby/CGI/HTML3.md b/example/ruby/CGI/HTML3.md deleted file mode 100644 index 14ed933..0000000 --- a/example/ruby/CGI/HTML3.md +++ /dev/null @@ -1,488 +0,0 @@ -# Class: CGI::HTML3 -**Inherits:** Object - -**Includes:** CGI::Html3, CGI::HtmlExtension - - -Html5 - - - -#Instance Methods -## a(href"") [](#method-i-a) -Generate an Anchor element as a string. - -`href` can either be a string, giving the URL for the HREF attribute, or it -can be a hash of the element's attributes. - -The body of the element is the string returned by the no-argument block passed -in. - - a("http://www.example.com") { "Example" } - # => "Example" - - a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" } - # => "Example" - -## base(href"") [](#method-i-base) -Generate a Document Base URI element as a String. - -`href` can either by a string, giving the base URL for the HREF attribute, or -it can be a has of the element's attributes. - -The passed-in no-argument block is ignored. - - base("http://www.example.com/cgi") - # => "" - -## blockquote(cite{}) [](#method-i-blockquote) -Generate a BlockQuote element as a string. - -`cite` can either be a string, give the URI for the source of the quoted text, -or a hash, giving all attributes of the element, or it can be omitted, in -which case the element has no attributes. - -The body is provided by the passed-in no-argument block - - blockquote("http://www.example.com/quotes/foo.html") { "Foo!" } - #=> "
Foo!
- -## caption(align{}) [](#method-i-caption) -Generate a Table Caption element as a string. - -`align` can be a string, giving the alignment of the caption (one of top, -bottom, left, or right). It can be a hash of all the attributes of the -element. Or it can be omitted. - -The body of the element is provided by the passed-in no-argument block. - - caption("left") { "Capital Cities" } - # => Capital Cities - -## checkbox(name"", valuenil, checkednil) [](#method-i-checkbox) -Generate a Checkbox Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`value`, and `checked`. `checked` is a boolean value; if true, the CHECKED -attribute will be included in the element. - -Alternatively, the attributes can be specified as a hash. - - checkbox("name") - # = checkbox("NAME" => "name") - - checkbox("name", "value") - # = checkbox("NAME" => "name", "VALUE" => "value") - - checkbox("name", "value", true) - # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true) - -## checkbox_group(name"", *values) [](#method-i-checkbox_group) -Generate a sequence of checkbox elements, as a String. - -The checkboxes will all have the same `name` attribute. Each checkbox is -followed by a label. There will be one checkbox for each value. Each value -can be specified as a String, which will be used both as the value of the -VALUE attribute and as the label for that checkbox. A single-element array -has the same effect. - -Each value can also be specified as a three-element array. The first element -is the VALUE attribute; the second is the label; and the third is a boolean -specifying whether this checkbox is CHECKED. - -Each value can also be specified as a two-element array, by omitting either -the value element (defaults to the same as the label), or the boolean checked -element (defaults to false). - - checkbox_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - checkbox_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - checkbox_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## file_field(name"", size20, maxlengthnil) [](#method-i-file_field) -Generate an File Upload Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`size`, and `maxlength`. `maxlength` is the maximum length of the file's -*name*, not of the file's *contents*. - -Alternatively, the attributes can be specified as a hash. - -See #multipart_form() for forms that include file uploads. - - file_field("name") - # - - file_field("name", 40) - # - - file_field("name", 40, 100) - # - - file_field("NAME" => "name", "SIZE" => 40) - # - -## form(method"post", actionscript_name, enctype"application/x-www-form-urlencoded") [](#method-i-form) -Generate a Form element as a string. - -`method` should be either "get" or "post", and defaults to the latter. -`action` defaults to the current CGI script name. `enctype` defaults to -"application/x-www-form-urlencoded". - -Alternatively, the attributes can be specified as a hash. - -See also #multipart_form() for forms that include file uploads. - - form{ "string" } - #
string
- - form("get") { "string" } - #
string
- - form("get", "url") { "string" } - #
string
- - form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" } - #
string
- -## hidden(name"", valuenil) [](#method-i-hidden) -Generate a Hidden Input element as a string. - -The attributes of the element can be specified as two arguments, `name` and -`value`. - -Alternatively, the attributes can be specified as a hash. - - hidden("name") - # - - hidden("name", "value") - # - - hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo") - # - -## html(attributes{}) [](#method-i-html) -Generate a top-level HTML element as a string. - -The attributes of the element are specified as a hash. The pseudo-attribute -"PRETTY" can be used to specify that the generated HTML string should be -indented. "PRETTY" can also be specified as a string as the sole argument to -this method. The pseudo-attribute "DOCTYPE", if given, is used as the leading -DOCTYPE SGML tag; it should include the entire text of this tag, including -angle brackets. - -The body of the html element is supplied as a block. - - html{ "string" } - # string - - html("LANG" => "ja") { "string" } - # string - - html("DOCTYPE" => false) { "string" } - # string - - html("DOCTYPE" => '') { "string" } - # string - - html("PRETTY" => " ") { "" } - # - # - # - # - # - - html("PRETTY" => "\t") { "" } - # - # - # - # - # - - html("PRETTY") { "" } - # = html("PRETTY" => " ") { "" } - - html(if $VERBOSE then "PRETTY" end) { "HTML string" } - -## image_button(src"", namenil, altnil) [](#method-i-image_button) -Generate an Image Button Input element as a string. - -`src` is the URL of the image to use for the button. `name` is the input -name. `alt` is the alternative text for the image. - -Alternatively, the attributes can be specified as a hash. - - image_button("url") - # - - image_button("url", "name", "string") - # - - image_button("SRC" => "url", "ALT" => "string") - # - -## img(src"", alt"", widthnil, heightnil) [](#method-i-img) -Generate an Image element as a string. - -`src` is the URL of the image. `alt` is the alternative text for the image. -`width` is the width of the image, and `height` is its height. - -Alternatively, the attributes can be specified as a hash. - - img("src", "alt", 100, 50) - # alt - - img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50) - # alt - -## multipart_form(actionnil, enctype"multipart/form-data") [](#method-i-multipart_form) -Generate a Form element with multipart encoding as a String. - -Multipart encoding is used for forms that include file uploads. - -`action` is the action to perform. `enctype` is the encoding type, which -defaults to "multipart/form-data". - -Alternatively, the attributes can be specified as a hash. - - multipart_form{ "string" } - #
string
- - multipart_form("url") { "string" } - #
string
- -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - -## password_field(name"", valuenil, size40, maxlengthnil) [](#method-i-password_field) -Generate a Password Input element as a string. - -`name` is the name of the input field. `value` is its default value. `size` -is the size of the input field display. `maxlength` is the maximum length of -the inputted password. - -Alternatively, attributes can be specified as a hash. - - password_field("name") - # - - password_field("name", "value") - # - - password_field("password", "value", 80, 200) - # - - password_field("NAME" => "name", "VALUE" => "value") - # - -## popup_menu(name"", *values) [](#method-i-popup_menu) -Generate a Select element as a string. - -`name` is the name of the element. The `values` are the options that can be -selected from the Select menu. Each value can be a String or a one, two, or -three-element Array. If a String or a one-element Array, this is both the -value of that option and the text displayed for it. If a three-element Array, -the elements are the option value, displayed text, and a boolean value -specifying whether this option starts as selected. The two-element version -omits either the option value (defaults to the same as the display text) or -the boolean selected specifier (defaults to false). - -The attributes and options can also be specified as a hash. In this case, -options are specified as an array of values as described above, with the hash -key of "VALUES". - - popup_menu("name", "foo", "bar", "baz") - # - - popup_menu("name", ["foo"], ["bar", true], "baz") - # - - popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # - - popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true, - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - # - -## radio_button(name"", valuenil, checkednil) [](#method-i-radio_button) -Generates a radio-button Input element. - -`name` is the name of the input field. `value` is the value of the field if -checked. `checked` specifies whether the field starts off checked. - -Alternatively, the attributes can be specified as a hash. - - radio_button("name", "value") - # - - radio_button("name", "value", true) - # - - radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo") - # - -## radio_group(name"", *values) [](#method-i-radio_group) -Generate a sequence of radio button Input elements, as a String. - -This works the same as #checkbox_group(). However, it is not valid to have -more than one radiobutton in a group checked. - - radio_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - radio_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - radio_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## reset(valuenil, namenil) [](#method-i-reset) -Generate a reset button Input element, as a String. - -This resets the values on a form to their initial values. `value` is the text -displayed on the button. `name` is the name of this button. - -Alternatively, the attributes can be specified as a hash. - - reset - # - - reset("reset") - # - - reset("VALUE" => "reset", "ID" => "foo") - # - -## submit(valuenil, namenil) [](#method-i-submit) -Generate a submit button Input element, as a String. - -`value` is the text to display on the button. `name` is the name of the -input. - -Alternatively, the attributes can be specified as a hash. - - submit - # - - submit("ok") - # - - submit("ok", "button1") - # - - submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") - # - -## text_field(name"", valuenil, size40, maxlengthnil) [](#method-i-text_field) -Generate a text field Input element, as a String. - -`name` is the name of the input field. `value` is its initial value. `size` -is the size of the input area. `maxlength` is the maximum length of input -accepted. - -Alternatively, the attributes can be specified as a hash. - - text_field("name") - # - - text_field("name", "value") - # - - text_field("name", "value", 80) - # - - text_field("name", "value", 80, 200) - # - - text_field("NAME" => "name", "VALUE" => "value") - # - -## textarea(name"", cols70, rows10) [](#method-i-textarea) -Generate a TextArea element, as a String. - -`name` is the name of the textarea. `cols` is the number of columns and -`rows` is the number of rows in the display. - -Alternatively, the attributes can be specified as a hash. - -The body is provided by the passed-in no-argument block - - textarea("name") - # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10) - - textarea("name", 40, 5) - # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5) - diff --git a/example/ruby/CGI/HTML4.md b/example/ruby/CGI/HTML4.md deleted file mode 100644 index a3bc9f9..0000000 --- a/example/ruby/CGI/HTML4.md +++ /dev/null @@ -1,487 +0,0 @@ -# Class: CGI::HTML4 -**Inherits:** Object - -**Includes:** CGI::Html4, CGI::HtmlExtension - - - - - -#Instance Methods -## a(href"") [](#method-i-a) -Generate an Anchor element as a string. - -`href` can either be a string, giving the URL for the HREF attribute, or it -can be a hash of the element's attributes. - -The body of the element is the string returned by the no-argument block passed -in. - - a("http://www.example.com") { "Example" } - # => "Example" - - a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" } - # => "Example" - -## base(href"") [](#method-i-base) -Generate a Document Base URI element as a String. - -`href` can either by a string, giving the base URL for the HREF attribute, or -it can be a has of the element's attributes. - -The passed-in no-argument block is ignored. - - base("http://www.example.com/cgi") - # => "" - -## blockquote(cite{}) [](#method-i-blockquote) -Generate a BlockQuote element as a string. - -`cite` can either be a string, give the URI for the source of the quoted text, -or a hash, giving all attributes of the element, or it can be omitted, in -which case the element has no attributes. - -The body is provided by the passed-in no-argument block - - blockquote("http://www.example.com/quotes/foo.html") { "Foo!" } - #=> "
Foo!
- -## caption(align{}) [](#method-i-caption) -Generate a Table Caption element as a string. - -`align` can be a string, giving the alignment of the caption (one of top, -bottom, left, or right). It can be a hash of all the attributes of the -element. Or it can be omitted. - -The body of the element is provided by the passed-in no-argument block. - - caption("left") { "Capital Cities" } - # => Capital Cities - -## checkbox(name"", valuenil, checkednil) [](#method-i-checkbox) -Generate a Checkbox Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`value`, and `checked`. `checked` is a boolean value; if true, the CHECKED -attribute will be included in the element. - -Alternatively, the attributes can be specified as a hash. - - checkbox("name") - # = checkbox("NAME" => "name") - - checkbox("name", "value") - # = checkbox("NAME" => "name", "VALUE" => "value") - - checkbox("name", "value", true) - # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true) - -## checkbox_group(name"", *values) [](#method-i-checkbox_group) -Generate a sequence of checkbox elements, as a String. - -The checkboxes will all have the same `name` attribute. Each checkbox is -followed by a label. There will be one checkbox for each value. Each value -can be specified as a String, which will be used both as the value of the -VALUE attribute and as the label for that checkbox. A single-element array -has the same effect. - -Each value can also be specified as a three-element array. The first element -is the VALUE attribute; the second is the label; and the third is a boolean -specifying whether this checkbox is CHECKED. - -Each value can also be specified as a two-element array, by omitting either -the value element (defaults to the same as the label), or the boolean checked -element (defaults to false). - - checkbox_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - checkbox_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - checkbox_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## file_field(name"", size20, maxlengthnil) [](#method-i-file_field) -Generate an File Upload Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`size`, and `maxlength`. `maxlength` is the maximum length of the file's -*name*, not of the file's *contents*. - -Alternatively, the attributes can be specified as a hash. - -See #multipart_form() for forms that include file uploads. - - file_field("name") - # - - file_field("name", 40) - # - - file_field("name", 40, 100) - # - - file_field("NAME" => "name", "SIZE" => 40) - # - -## form(method"post", actionscript_name, enctype"application/x-www-form-urlencoded") [](#method-i-form) -Generate a Form element as a string. - -`method` should be either "get" or "post", and defaults to the latter. -`action` defaults to the current CGI script name. `enctype` defaults to -"application/x-www-form-urlencoded". - -Alternatively, the attributes can be specified as a hash. - -See also #multipart_form() for forms that include file uploads. - - form{ "string" } - #
string
- - form("get") { "string" } - #
string
- - form("get", "url") { "string" } - #
string
- - form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" } - #
string
- -## hidden(name"", valuenil) [](#method-i-hidden) -Generate a Hidden Input element as a string. - -The attributes of the element can be specified as two arguments, `name` and -`value`. - -Alternatively, the attributes can be specified as a hash. - - hidden("name") - # - - hidden("name", "value") - # - - hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo") - # - -## html(attributes{}) [](#method-i-html) -Generate a top-level HTML element as a string. - -The attributes of the element are specified as a hash. The pseudo-attribute -"PRETTY" can be used to specify that the generated HTML string should be -indented. "PRETTY" can also be specified as a string as the sole argument to -this method. The pseudo-attribute "DOCTYPE", if given, is used as the leading -DOCTYPE SGML tag; it should include the entire text of this tag, including -angle brackets. - -The body of the html element is supplied as a block. - - html{ "string" } - # string - - html("LANG" => "ja") { "string" } - # string - - html("DOCTYPE" => false) { "string" } - # string - - html("DOCTYPE" => '') { "string" } - # string - - html("PRETTY" => " ") { "" } - # - # - # - # - # - - html("PRETTY" => "\t") { "" } - # - # - # - # - # - - html("PRETTY") { "" } - # = html("PRETTY" => " ") { "" } - - html(if $VERBOSE then "PRETTY" end) { "HTML string" } - -## image_button(src"", namenil, altnil) [](#method-i-image_button) -Generate an Image Button Input element as a string. - -`src` is the URL of the image to use for the button. `name` is the input -name. `alt` is the alternative text for the image. - -Alternatively, the attributes can be specified as a hash. - - image_button("url") - # - - image_button("url", "name", "string") - # - - image_button("SRC" => "url", "ALT" => "string") - # - -## img(src"", alt"", widthnil, heightnil) [](#method-i-img) -Generate an Image element as a string. - -`src` is the URL of the image. `alt` is the alternative text for the image. -`width` is the width of the image, and `height` is its height. - -Alternatively, the attributes can be specified as a hash. - - img("src", "alt", 100, 50) - # alt - - img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50) - # alt - -## multipart_form(actionnil, enctype"multipart/form-data") [](#method-i-multipart_form) -Generate a Form element with multipart encoding as a String. - -Multipart encoding is used for forms that include file uploads. - -`action` is the action to perform. `enctype` is the encoding type, which -defaults to "multipart/form-data". - -Alternatively, the attributes can be specified as a hash. - - multipart_form{ "string" } - #
string
- - multipart_form("url") { "string" } - #
string
- -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - -## password_field(name"", valuenil, size40, maxlengthnil) [](#method-i-password_field) -Generate a Password Input element as a string. - -`name` is the name of the input field. `value` is its default value. `size` -is the size of the input field display. `maxlength` is the maximum length of -the inputted password. - -Alternatively, attributes can be specified as a hash. - - password_field("name") - # - - password_field("name", "value") - # - - password_field("password", "value", 80, 200) - # - - password_field("NAME" => "name", "VALUE" => "value") - # - -## popup_menu(name"", *values) [](#method-i-popup_menu) -Generate a Select element as a string. - -`name` is the name of the element. The `values` are the options that can be -selected from the Select menu. Each value can be a String or a one, two, or -three-element Array. If a String or a one-element Array, this is both the -value of that option and the text displayed for it. If a three-element Array, -the elements are the option value, displayed text, and a boolean value -specifying whether this option starts as selected. The two-element version -omits either the option value (defaults to the same as the display text) or -the boolean selected specifier (defaults to false). - -The attributes and options can also be specified as a hash. In this case, -options are specified as an array of values as described above, with the hash -key of "VALUES". - - popup_menu("name", "foo", "bar", "baz") - # - - popup_menu("name", ["foo"], ["bar", true], "baz") - # - - popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # - - popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true, - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - # - -## radio_button(name"", valuenil, checkednil) [](#method-i-radio_button) -Generates a radio-button Input element. - -`name` is the name of the input field. `value` is the value of the field if -checked. `checked` specifies whether the field starts off checked. - -Alternatively, the attributes can be specified as a hash. - - radio_button("name", "value") - # - - radio_button("name", "value", true) - # - - radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo") - # - -## radio_group(name"", *values) [](#method-i-radio_group) -Generate a sequence of radio button Input elements, as a String. - -This works the same as #checkbox_group(). However, it is not valid to have -more than one radiobutton in a group checked. - - radio_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - radio_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - radio_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## reset(valuenil, namenil) [](#method-i-reset) -Generate a reset button Input element, as a String. - -This resets the values on a form to their initial values. `value` is the text -displayed on the button. `name` is the name of this button. - -Alternatively, the attributes can be specified as a hash. - - reset - # - - reset("reset") - # - - reset("VALUE" => "reset", "ID" => "foo") - # - -## submit(valuenil, namenil) [](#method-i-submit) -Generate a submit button Input element, as a String. - -`value` is the text to display on the button. `name` is the name of the -input. - -Alternatively, the attributes can be specified as a hash. - - submit - # - - submit("ok") - # - - submit("ok", "button1") - # - - submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") - # - -## text_field(name"", valuenil, size40, maxlengthnil) [](#method-i-text_field) -Generate a text field Input element, as a String. - -`name` is the name of the input field. `value` is its initial value. `size` -is the size of the input area. `maxlength` is the maximum length of input -accepted. - -Alternatively, the attributes can be specified as a hash. - - text_field("name") - # - - text_field("name", "value") - # - - text_field("name", "value", 80) - # - - text_field("name", "value", 80, 200) - # - - text_field("NAME" => "name", "VALUE" => "value") - # - -## textarea(name"", cols70, rows10) [](#method-i-textarea) -Generate a TextArea element, as a String. - -`name` is the name of the textarea. `cols` is the number of columns and -`rows` is the number of rows in the display. - -Alternatively, the attributes can be specified as a hash. - -The body is provided by the passed-in no-argument block - - textarea("name") - # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10) - - textarea("name", 40, 5) - # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5) - diff --git a/example/ruby/CGI/HTML4Fr.md b/example/ruby/CGI/HTML4Fr.md deleted file mode 100644 index ef86942..0000000 --- a/example/ruby/CGI/HTML4Fr.md +++ /dev/null @@ -1,487 +0,0 @@ -# Class: CGI::HTML4Fr -**Inherits:** Object - -**Includes:** CGI::Html4Fr, CGI::Html4Tr, CGI::HtmlExtension - - - - - -#Instance Methods -## a(href"") [](#method-i-a) -Generate an Anchor element as a string. - -`href` can either be a string, giving the URL for the HREF attribute, or it -can be a hash of the element's attributes. - -The body of the element is the string returned by the no-argument block passed -in. - - a("http://www.example.com") { "Example" } - # => "Example" - - a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" } - # => "Example" - -## base(href"") [](#method-i-base) -Generate a Document Base URI element as a String. - -`href` can either by a string, giving the base URL for the HREF attribute, or -it can be a has of the element's attributes. - -The passed-in no-argument block is ignored. - - base("http://www.example.com/cgi") - # => "" - -## blockquote(cite{}) [](#method-i-blockquote) -Generate a BlockQuote element as a string. - -`cite` can either be a string, give the URI for the source of the quoted text, -or a hash, giving all attributes of the element, or it can be omitted, in -which case the element has no attributes. - -The body is provided by the passed-in no-argument block - - blockquote("http://www.example.com/quotes/foo.html") { "Foo!" } - #=> "
Foo!
- -## caption(align{}) [](#method-i-caption) -Generate a Table Caption element as a string. - -`align` can be a string, giving the alignment of the caption (one of top, -bottom, left, or right). It can be a hash of all the attributes of the -element. Or it can be omitted. - -The body of the element is provided by the passed-in no-argument block. - - caption("left") { "Capital Cities" } - # => Capital Cities - -## checkbox(name"", valuenil, checkednil) [](#method-i-checkbox) -Generate a Checkbox Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`value`, and `checked`. `checked` is a boolean value; if true, the CHECKED -attribute will be included in the element. - -Alternatively, the attributes can be specified as a hash. - - checkbox("name") - # = checkbox("NAME" => "name") - - checkbox("name", "value") - # = checkbox("NAME" => "name", "VALUE" => "value") - - checkbox("name", "value", true) - # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true) - -## checkbox_group(name"", *values) [](#method-i-checkbox_group) -Generate a sequence of checkbox elements, as a String. - -The checkboxes will all have the same `name` attribute. Each checkbox is -followed by a label. There will be one checkbox for each value. Each value -can be specified as a String, which will be used both as the value of the -VALUE attribute and as the label for that checkbox. A single-element array -has the same effect. - -Each value can also be specified as a three-element array. The first element -is the VALUE attribute; the second is the label; and the third is a boolean -specifying whether this checkbox is CHECKED. - -Each value can also be specified as a two-element array, by omitting either -the value element (defaults to the same as the label), or the boolean checked -element (defaults to false). - - checkbox_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - checkbox_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - checkbox_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## file_field(name"", size20, maxlengthnil) [](#method-i-file_field) -Generate an File Upload Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`size`, and `maxlength`. `maxlength` is the maximum length of the file's -*name*, not of the file's *contents*. - -Alternatively, the attributes can be specified as a hash. - -See #multipart_form() for forms that include file uploads. - - file_field("name") - # - - file_field("name", 40) - # - - file_field("name", 40, 100) - # - - file_field("NAME" => "name", "SIZE" => 40) - # - -## form(method"post", actionscript_name, enctype"application/x-www-form-urlencoded") [](#method-i-form) -Generate a Form element as a string. - -`method` should be either "get" or "post", and defaults to the latter. -`action` defaults to the current CGI script name. `enctype` defaults to -"application/x-www-form-urlencoded". - -Alternatively, the attributes can be specified as a hash. - -See also #multipart_form() for forms that include file uploads. - - form{ "string" } - #
string
- - form("get") { "string" } - #
string
- - form("get", "url") { "string" } - #
string
- - form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" } - #
string
- -## hidden(name"", valuenil) [](#method-i-hidden) -Generate a Hidden Input element as a string. - -The attributes of the element can be specified as two arguments, `name` and -`value`. - -Alternatively, the attributes can be specified as a hash. - - hidden("name") - # - - hidden("name", "value") - # - - hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo") - # - -## html(attributes{}) [](#method-i-html) -Generate a top-level HTML element as a string. - -The attributes of the element are specified as a hash. The pseudo-attribute -"PRETTY" can be used to specify that the generated HTML string should be -indented. "PRETTY" can also be specified as a string as the sole argument to -this method. The pseudo-attribute "DOCTYPE", if given, is used as the leading -DOCTYPE SGML tag; it should include the entire text of this tag, including -angle brackets. - -The body of the html element is supplied as a block. - - html{ "string" } - # string - - html("LANG" => "ja") { "string" } - # string - - html("DOCTYPE" => false) { "string" } - # string - - html("DOCTYPE" => '') { "string" } - # string - - html("PRETTY" => " ") { "" } - # - # - # - # - # - - html("PRETTY" => "\t") { "" } - # - # - # - # - # - - html("PRETTY") { "" } - # = html("PRETTY" => " ") { "" } - - html(if $VERBOSE then "PRETTY" end) { "HTML string" } - -## image_button(src"", namenil, altnil) [](#method-i-image_button) -Generate an Image Button Input element as a string. - -`src` is the URL of the image to use for the button. `name` is the input -name. `alt` is the alternative text for the image. - -Alternatively, the attributes can be specified as a hash. - - image_button("url") - # - - image_button("url", "name", "string") - # - - image_button("SRC" => "url", "ALT" => "string") - # - -## img(src"", alt"", widthnil, heightnil) [](#method-i-img) -Generate an Image element as a string. - -`src` is the URL of the image. `alt` is the alternative text for the image. -`width` is the width of the image, and `height` is its height. - -Alternatively, the attributes can be specified as a hash. - - img("src", "alt", 100, 50) - # alt - - img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50) - # alt - -## multipart_form(actionnil, enctype"multipart/form-data") [](#method-i-multipart_form) -Generate a Form element with multipart encoding as a String. - -Multipart encoding is used for forms that include file uploads. - -`action` is the action to perform. `enctype` is the encoding type, which -defaults to "multipart/form-data". - -Alternatively, the attributes can be specified as a hash. - - multipart_form{ "string" } - #
string
- - multipart_form("url") { "string" } - #
string
- -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - -## password_field(name"", valuenil, size40, maxlengthnil) [](#method-i-password_field) -Generate a Password Input element as a string. - -`name` is the name of the input field. `value` is its default value. `size` -is the size of the input field display. `maxlength` is the maximum length of -the inputted password. - -Alternatively, attributes can be specified as a hash. - - password_field("name") - # - - password_field("name", "value") - # - - password_field("password", "value", 80, 200) - # - - password_field("NAME" => "name", "VALUE" => "value") - # - -## popup_menu(name"", *values) [](#method-i-popup_menu) -Generate a Select element as a string. - -`name` is the name of the element. The `values` are the options that can be -selected from the Select menu. Each value can be a String or a one, two, or -three-element Array. If a String or a one-element Array, this is both the -value of that option and the text displayed for it. If a three-element Array, -the elements are the option value, displayed text, and a boolean value -specifying whether this option starts as selected. The two-element version -omits either the option value (defaults to the same as the display text) or -the boolean selected specifier (defaults to false). - -The attributes and options can also be specified as a hash. In this case, -options are specified as an array of values as described above, with the hash -key of "VALUES". - - popup_menu("name", "foo", "bar", "baz") - # - - popup_menu("name", ["foo"], ["bar", true], "baz") - # - - popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # - - popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true, - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - # - -## radio_button(name"", valuenil, checkednil) [](#method-i-radio_button) -Generates a radio-button Input element. - -`name` is the name of the input field. `value` is the value of the field if -checked. `checked` specifies whether the field starts off checked. - -Alternatively, the attributes can be specified as a hash. - - radio_button("name", "value") - # - - radio_button("name", "value", true) - # - - radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo") - # - -## radio_group(name"", *values) [](#method-i-radio_group) -Generate a sequence of radio button Input elements, as a String. - -This works the same as #checkbox_group(). However, it is not valid to have -more than one radiobutton in a group checked. - - radio_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - radio_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - radio_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## reset(valuenil, namenil) [](#method-i-reset) -Generate a reset button Input element, as a String. - -This resets the values on a form to their initial values. `value` is the text -displayed on the button. `name` is the name of this button. - -Alternatively, the attributes can be specified as a hash. - - reset - # - - reset("reset") - # - - reset("VALUE" => "reset", "ID" => "foo") - # - -## submit(valuenil, namenil) [](#method-i-submit) -Generate a submit button Input element, as a String. - -`value` is the text to display on the button. `name` is the name of the -input. - -Alternatively, the attributes can be specified as a hash. - - submit - # - - submit("ok") - # - - submit("ok", "button1") - # - - submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") - # - -## text_field(name"", valuenil, size40, maxlengthnil) [](#method-i-text_field) -Generate a text field Input element, as a String. - -`name` is the name of the input field. `value` is its initial value. `size` -is the size of the input area. `maxlength` is the maximum length of input -accepted. - -Alternatively, the attributes can be specified as a hash. - - text_field("name") - # - - text_field("name", "value") - # - - text_field("name", "value", 80) - # - - text_field("name", "value", 80, 200) - # - - text_field("NAME" => "name", "VALUE" => "value") - # - -## textarea(name"", cols70, rows10) [](#method-i-textarea) -Generate a TextArea element, as a String. - -`name` is the name of the textarea. `cols` is the number of columns and -`rows` is the number of rows in the display. - -Alternatively, the attributes can be specified as a hash. - -The body is provided by the passed-in no-argument block - - textarea("name") - # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10) - - textarea("name", 40, 5) - # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5) - diff --git a/example/ruby/CGI/HTML4Tr.md b/example/ruby/CGI/HTML4Tr.md deleted file mode 100644 index 4e8fa56..0000000 --- a/example/ruby/CGI/HTML4Tr.md +++ /dev/null @@ -1,487 +0,0 @@ -# Class: CGI::HTML4Tr -**Inherits:** Object - -**Includes:** CGI::Html4Tr, CGI::HtmlExtension - - - - - -#Instance Methods -## a(href"") [](#method-i-a) -Generate an Anchor element as a string. - -`href` can either be a string, giving the URL for the HREF attribute, or it -can be a hash of the element's attributes. - -The body of the element is the string returned by the no-argument block passed -in. - - a("http://www.example.com") { "Example" } - # => "Example" - - a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" } - # => "Example" - -## base(href"") [](#method-i-base) -Generate a Document Base URI element as a String. - -`href` can either by a string, giving the base URL for the HREF attribute, or -it can be a has of the element's attributes. - -The passed-in no-argument block is ignored. - - base("http://www.example.com/cgi") - # => "" - -## blockquote(cite{}) [](#method-i-blockquote) -Generate a BlockQuote element as a string. - -`cite` can either be a string, give the URI for the source of the quoted text, -or a hash, giving all attributes of the element, or it can be omitted, in -which case the element has no attributes. - -The body is provided by the passed-in no-argument block - - blockquote("http://www.example.com/quotes/foo.html") { "Foo!" } - #=> "
Foo!
- -## caption(align{}) [](#method-i-caption) -Generate a Table Caption element as a string. - -`align` can be a string, giving the alignment of the caption (one of top, -bottom, left, or right). It can be a hash of all the attributes of the -element. Or it can be omitted. - -The body of the element is provided by the passed-in no-argument block. - - caption("left") { "Capital Cities" } - # => Capital Cities - -## checkbox(name"", valuenil, checkednil) [](#method-i-checkbox) -Generate a Checkbox Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`value`, and `checked`. `checked` is a boolean value; if true, the CHECKED -attribute will be included in the element. - -Alternatively, the attributes can be specified as a hash. - - checkbox("name") - # = checkbox("NAME" => "name") - - checkbox("name", "value") - # = checkbox("NAME" => "name", "VALUE" => "value") - - checkbox("name", "value", true) - # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true) - -## checkbox_group(name"", *values) [](#method-i-checkbox_group) -Generate a sequence of checkbox elements, as a String. - -The checkboxes will all have the same `name` attribute. Each checkbox is -followed by a label. There will be one checkbox for each value. Each value -can be specified as a String, which will be used both as the value of the -VALUE attribute and as the label for that checkbox. A single-element array -has the same effect. - -Each value can also be specified as a three-element array. The first element -is the VALUE attribute; the second is the label; and the third is a boolean -specifying whether this checkbox is CHECKED. - -Each value can also be specified as a two-element array, by omitting either -the value element (defaults to the same as the label), or the boolean checked -element (defaults to false). - - checkbox_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - checkbox_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - checkbox_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## file_field(name"", size20, maxlengthnil) [](#method-i-file_field) -Generate an File Upload Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`size`, and `maxlength`. `maxlength` is the maximum length of the file's -*name*, not of the file's *contents*. - -Alternatively, the attributes can be specified as a hash. - -See #multipart_form() for forms that include file uploads. - - file_field("name") - # - - file_field("name", 40) - # - - file_field("name", 40, 100) - # - - file_field("NAME" => "name", "SIZE" => 40) - # - -## form(method"post", actionscript_name, enctype"application/x-www-form-urlencoded") [](#method-i-form) -Generate a Form element as a string. - -`method` should be either "get" or "post", and defaults to the latter. -`action` defaults to the current CGI script name. `enctype` defaults to -"application/x-www-form-urlencoded". - -Alternatively, the attributes can be specified as a hash. - -See also #multipart_form() for forms that include file uploads. - - form{ "string" } - #
string
- - form("get") { "string" } - #
string
- - form("get", "url") { "string" } - #
string
- - form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" } - #
string
- -## hidden(name"", valuenil) [](#method-i-hidden) -Generate a Hidden Input element as a string. - -The attributes of the element can be specified as two arguments, `name` and -`value`. - -Alternatively, the attributes can be specified as a hash. - - hidden("name") - # - - hidden("name", "value") - # - - hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo") - # - -## html(attributes{}) [](#method-i-html) -Generate a top-level HTML element as a string. - -The attributes of the element are specified as a hash. The pseudo-attribute -"PRETTY" can be used to specify that the generated HTML string should be -indented. "PRETTY" can also be specified as a string as the sole argument to -this method. The pseudo-attribute "DOCTYPE", if given, is used as the leading -DOCTYPE SGML tag; it should include the entire text of this tag, including -angle brackets. - -The body of the html element is supplied as a block. - - html{ "string" } - # string - - html("LANG" => "ja") { "string" } - # string - - html("DOCTYPE" => false) { "string" } - # string - - html("DOCTYPE" => '') { "string" } - # string - - html("PRETTY" => " ") { "" } - # - # - # - # - # - - html("PRETTY" => "\t") { "" } - # - # - # - # - # - - html("PRETTY") { "" } - # = html("PRETTY" => " ") { "" } - - html(if $VERBOSE then "PRETTY" end) { "HTML string" } - -## image_button(src"", namenil, altnil) [](#method-i-image_button) -Generate an Image Button Input element as a string. - -`src` is the URL of the image to use for the button. `name` is the input -name. `alt` is the alternative text for the image. - -Alternatively, the attributes can be specified as a hash. - - image_button("url") - # - - image_button("url", "name", "string") - # - - image_button("SRC" => "url", "ALT" => "string") - # - -## img(src"", alt"", widthnil, heightnil) [](#method-i-img) -Generate an Image element as a string. - -`src` is the URL of the image. `alt` is the alternative text for the image. -`width` is the width of the image, and `height` is its height. - -Alternatively, the attributes can be specified as a hash. - - img("src", "alt", 100, 50) - # alt - - img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50) - # alt - -## multipart_form(actionnil, enctype"multipart/form-data") [](#method-i-multipart_form) -Generate a Form element with multipart encoding as a String. - -Multipart encoding is used for forms that include file uploads. - -`action` is the action to perform. `enctype` is the encoding type, which -defaults to "multipart/form-data". - -Alternatively, the attributes can be specified as a hash. - - multipart_form{ "string" } - #
string
- - multipart_form("url") { "string" } - #
string
- -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - -## password_field(name"", valuenil, size40, maxlengthnil) [](#method-i-password_field) -Generate a Password Input element as a string. - -`name` is the name of the input field. `value` is its default value. `size` -is the size of the input field display. `maxlength` is the maximum length of -the inputted password. - -Alternatively, attributes can be specified as a hash. - - password_field("name") - # - - password_field("name", "value") - # - - password_field("password", "value", 80, 200) - # - - password_field("NAME" => "name", "VALUE" => "value") - # - -## popup_menu(name"", *values) [](#method-i-popup_menu) -Generate a Select element as a string. - -`name` is the name of the element. The `values` are the options that can be -selected from the Select menu. Each value can be a String or a one, two, or -three-element Array. If a String or a one-element Array, this is both the -value of that option and the text displayed for it. If a three-element Array, -the elements are the option value, displayed text, and a boolean value -specifying whether this option starts as selected. The two-element version -omits either the option value (defaults to the same as the display text) or -the boolean selected specifier (defaults to false). - -The attributes and options can also be specified as a hash. In this case, -options are specified as an array of values as described above, with the hash -key of "VALUES". - - popup_menu("name", "foo", "bar", "baz") - # - - popup_menu("name", ["foo"], ["bar", true], "baz") - # - - popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # - - popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true, - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - # - -## radio_button(name"", valuenil, checkednil) [](#method-i-radio_button) -Generates a radio-button Input element. - -`name` is the name of the input field. `value` is the value of the field if -checked. `checked` specifies whether the field starts off checked. - -Alternatively, the attributes can be specified as a hash. - - radio_button("name", "value") - # - - radio_button("name", "value", true) - # - - radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo") - # - -## radio_group(name"", *values) [](#method-i-radio_group) -Generate a sequence of radio button Input elements, as a String. - -This works the same as #checkbox_group(). However, it is not valid to have -more than one radiobutton in a group checked. - - radio_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - radio_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - radio_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## reset(valuenil, namenil) [](#method-i-reset) -Generate a reset button Input element, as a String. - -This resets the values on a form to their initial values. `value` is the text -displayed on the button. `name` is the name of this button. - -Alternatively, the attributes can be specified as a hash. - - reset - # - - reset("reset") - # - - reset("VALUE" => "reset", "ID" => "foo") - # - -## submit(valuenil, namenil) [](#method-i-submit) -Generate a submit button Input element, as a String. - -`value` is the text to display on the button. `name` is the name of the -input. - -Alternatively, the attributes can be specified as a hash. - - submit - # - - submit("ok") - # - - submit("ok", "button1") - # - - submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") - # - -## text_field(name"", valuenil, size40, maxlengthnil) [](#method-i-text_field) -Generate a text field Input element, as a String. - -`name` is the name of the input field. `value` is its initial value. `size` -is the size of the input area. `maxlength` is the maximum length of input -accepted. - -Alternatively, the attributes can be specified as a hash. - - text_field("name") - # - - text_field("name", "value") - # - - text_field("name", "value", 80) - # - - text_field("name", "value", 80, 200) - # - - text_field("NAME" => "name", "VALUE" => "value") - # - -## textarea(name"", cols70, rows10) [](#method-i-textarea) -Generate a TextArea element, as a String. - -`name` is the name of the textarea. `cols` is the number of columns and -`rows` is the number of rows in the display. - -Alternatively, the attributes can be specified as a hash. - -The body is provided by the passed-in no-argument block - - textarea("name") - # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10) - - textarea("name", 40, 5) - # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5) - diff --git a/example/ruby/CGI/HTML5.md b/example/ruby/CGI/HTML5.md deleted file mode 100644 index 0b6399b..0000000 --- a/example/ruby/CGI/HTML5.md +++ /dev/null @@ -1,487 +0,0 @@ -# Class: CGI::HTML5 -**Inherits:** Object - -**Includes:** CGI::Html5, CGI::HtmlExtension - - - - - -#Instance Methods -## a(href"") [](#method-i-a) -Generate an Anchor element as a string. - -`href` can either be a string, giving the URL for the HREF attribute, or it -can be a hash of the element's attributes. - -The body of the element is the string returned by the no-argument block passed -in. - - a("http://www.example.com") { "Example" } - # => "Example" - - a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" } - # => "Example" - -## base(href"") [](#method-i-base) -Generate a Document Base URI element as a String. - -`href` can either by a string, giving the base URL for the HREF attribute, or -it can be a has of the element's attributes. - -The passed-in no-argument block is ignored. - - base("http://www.example.com/cgi") - # => "" - -## blockquote(cite{}) [](#method-i-blockquote) -Generate a BlockQuote element as a string. - -`cite` can either be a string, give the URI for the source of the quoted text, -or a hash, giving all attributes of the element, or it can be omitted, in -which case the element has no attributes. - -The body is provided by the passed-in no-argument block - - blockquote("http://www.example.com/quotes/foo.html") { "Foo!" } - #=> "
Foo!
- -## caption(align{}) [](#method-i-caption) -Generate a Table Caption element as a string. - -`align` can be a string, giving the alignment of the caption (one of top, -bottom, left, or right). It can be a hash of all the attributes of the -element. Or it can be omitted. - -The body of the element is provided by the passed-in no-argument block. - - caption("left") { "Capital Cities" } - # => Capital Cities - -## checkbox(name"", valuenil, checkednil) [](#method-i-checkbox) -Generate a Checkbox Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`value`, and `checked`. `checked` is a boolean value; if true, the CHECKED -attribute will be included in the element. - -Alternatively, the attributes can be specified as a hash. - - checkbox("name") - # = checkbox("NAME" => "name") - - checkbox("name", "value") - # = checkbox("NAME" => "name", "VALUE" => "value") - - checkbox("name", "value", true) - # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true) - -## checkbox_group(name"", *values) [](#method-i-checkbox_group) -Generate a sequence of checkbox elements, as a String. - -The checkboxes will all have the same `name` attribute. Each checkbox is -followed by a label. There will be one checkbox for each value. Each value -can be specified as a String, which will be used both as the value of the -VALUE attribute and as the label for that checkbox. A single-element array -has the same effect. - -Each value can also be specified as a three-element array. The first element -is the VALUE attribute; the second is the label; and the third is a boolean -specifying whether this checkbox is CHECKED. - -Each value can also be specified as a two-element array, by omitting either -the value element (defaults to the same as the label), or the boolean checked -element (defaults to false). - - checkbox_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - checkbox_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - checkbox_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## file_field(name"", size20, maxlengthnil) [](#method-i-file_field) -Generate an File Upload Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`size`, and `maxlength`. `maxlength` is the maximum length of the file's -*name*, not of the file's *contents*. - -Alternatively, the attributes can be specified as a hash. - -See #multipart_form() for forms that include file uploads. - - file_field("name") - # - - file_field("name", 40) - # - - file_field("name", 40, 100) - # - - file_field("NAME" => "name", "SIZE" => 40) - # - -## form(method"post", actionscript_name, enctype"application/x-www-form-urlencoded") [](#method-i-form) -Generate a Form element as a string. - -`method` should be either "get" or "post", and defaults to the latter. -`action` defaults to the current CGI script name. `enctype` defaults to -"application/x-www-form-urlencoded". - -Alternatively, the attributes can be specified as a hash. - -See also #multipart_form() for forms that include file uploads. - - form{ "string" } - #
string
- - form("get") { "string" } - #
string
- - form("get", "url") { "string" } - #
string
- - form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" } - #
string
- -## hidden(name"", valuenil) [](#method-i-hidden) -Generate a Hidden Input element as a string. - -The attributes of the element can be specified as two arguments, `name` and -`value`. - -Alternatively, the attributes can be specified as a hash. - - hidden("name") - # - - hidden("name", "value") - # - - hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo") - # - -## html(attributes{}) [](#method-i-html) -Generate a top-level HTML element as a string. - -The attributes of the element are specified as a hash. The pseudo-attribute -"PRETTY" can be used to specify that the generated HTML string should be -indented. "PRETTY" can also be specified as a string as the sole argument to -this method. The pseudo-attribute "DOCTYPE", if given, is used as the leading -DOCTYPE SGML tag; it should include the entire text of this tag, including -angle brackets. - -The body of the html element is supplied as a block. - - html{ "string" } - # string - - html("LANG" => "ja") { "string" } - # string - - html("DOCTYPE" => false) { "string" } - # string - - html("DOCTYPE" => '') { "string" } - # string - - html("PRETTY" => " ") { "" } - # - # - # - # - # - - html("PRETTY" => "\t") { "" } - # - # - # - # - # - - html("PRETTY") { "" } - # = html("PRETTY" => " ") { "" } - - html(if $VERBOSE then "PRETTY" end) { "HTML string" } - -## image_button(src"", namenil, altnil) [](#method-i-image_button) -Generate an Image Button Input element as a string. - -`src` is the URL of the image to use for the button. `name` is the input -name. `alt` is the alternative text for the image. - -Alternatively, the attributes can be specified as a hash. - - image_button("url") - # - - image_button("url", "name", "string") - # - - image_button("SRC" => "url", "ALT" => "string") - # - -## img(src"", alt"", widthnil, heightnil) [](#method-i-img) -Generate an Image element as a string. - -`src` is the URL of the image. `alt` is the alternative text for the image. -`width` is the width of the image, and `height` is its height. - -Alternatively, the attributes can be specified as a hash. - - img("src", "alt", 100, 50) - # alt - - img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50) - # alt - -## multipart_form(actionnil, enctype"multipart/form-data") [](#method-i-multipart_form) -Generate a Form element with multipart encoding as a String. - -Multipart encoding is used for forms that include file uploads. - -`action` is the action to perform. `enctype` is the encoding type, which -defaults to "multipart/form-data". - -Alternatively, the attributes can be specified as a hash. - - multipart_form{ "string" } - #
string
- - multipart_form("url") { "string" } - #
string
- -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - -## password_field(name"", valuenil, size40, maxlengthnil) [](#method-i-password_field) -Generate a Password Input element as a string. - -`name` is the name of the input field. `value` is its default value. `size` -is the size of the input field display. `maxlength` is the maximum length of -the inputted password. - -Alternatively, attributes can be specified as a hash. - - password_field("name") - # - - password_field("name", "value") - # - - password_field("password", "value", 80, 200) - # - - password_field("NAME" => "name", "VALUE" => "value") - # - -## popup_menu(name"", *values) [](#method-i-popup_menu) -Generate a Select element as a string. - -`name` is the name of the element. The `values` are the options that can be -selected from the Select menu. Each value can be a String or a one, two, or -three-element Array. If a String or a one-element Array, this is both the -value of that option and the text displayed for it. If a three-element Array, -the elements are the option value, displayed text, and a boolean value -specifying whether this option starts as selected. The two-element version -omits either the option value (defaults to the same as the display text) or -the boolean selected specifier (defaults to false). - -The attributes and options can also be specified as a hash. In this case, -options are specified as an array of values as described above, with the hash -key of "VALUES". - - popup_menu("name", "foo", "bar", "baz") - # - - popup_menu("name", ["foo"], ["bar", true], "baz") - # - - popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # - - popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true, - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - # - -## radio_button(name"", valuenil, checkednil) [](#method-i-radio_button) -Generates a radio-button Input element. - -`name` is the name of the input field. `value` is the value of the field if -checked. `checked` specifies whether the field starts off checked. - -Alternatively, the attributes can be specified as a hash. - - radio_button("name", "value") - # - - radio_button("name", "value", true) - # - - radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo") - # - -## radio_group(name"", *values) [](#method-i-radio_group) -Generate a sequence of radio button Input elements, as a String. - -This works the same as #checkbox_group(). However, it is not valid to have -more than one radiobutton in a group checked. - - radio_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - radio_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - radio_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## reset(valuenil, namenil) [](#method-i-reset) -Generate a reset button Input element, as a String. - -This resets the values on a form to their initial values. `value` is the text -displayed on the button. `name` is the name of this button. - -Alternatively, the attributes can be specified as a hash. - - reset - # - - reset("reset") - # - - reset("VALUE" => "reset", "ID" => "foo") - # - -## submit(valuenil, namenil) [](#method-i-submit) -Generate a submit button Input element, as a String. - -`value` is the text to display on the button. `name` is the name of the -input. - -Alternatively, the attributes can be specified as a hash. - - submit - # - - submit("ok") - # - - submit("ok", "button1") - # - - submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") - # - -## text_field(name"", valuenil, size40, maxlengthnil) [](#method-i-text_field) -Generate a text field Input element, as a String. - -`name` is the name of the input field. `value` is its initial value. `size` -is the size of the input area. `maxlength` is the maximum length of input -accepted. - -Alternatively, the attributes can be specified as a hash. - - text_field("name") - # - - text_field("name", "value") - # - - text_field("name", "value", 80) - # - - text_field("name", "value", 80, 200) - # - - text_field("NAME" => "name", "VALUE" => "value") - # - -## textarea(name"", cols70, rows10) [](#method-i-textarea) -Generate a TextArea element, as a String. - -`name` is the name of the textarea. `cols` is the number of columns and -`rows` is the number of rows in the display. - -Alternatively, the attributes can be specified as a hash. - -The body is provided by the passed-in no-argument block - - textarea("name") - # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10) - - textarea("name", 40, 5) - # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5) - diff --git a/example/ruby/CGI/Html3.md b/example/ruby/CGI/Html3.md deleted file mode 100644 index 6cf55de..0000000 --- a/example/ruby/CGI/Html3.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: CGI::Html3 - -**Includes:** CGI::TagMaker - - -Mixin module for HTML version 3 generation methods. - - - -#Instance Methods -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - diff --git a/example/ruby/CGI/Html4.md b/example/ruby/CGI/Html4.md deleted file mode 100644 index 1c9cd87..0000000 --- a/example/ruby/CGI/Html4.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: CGI::Html4 - -**Includes:** CGI::TagMaker - - -Mixin module for HTML version 4 generation methods. - - - -#Instance Methods -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - diff --git a/example/ruby/CGI/Html4Fr.md b/example/ruby/CGI/Html4Fr.md deleted file mode 100644 index c2904b6..0000000 --- a/example/ruby/CGI/Html4Fr.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: CGI::Html4Fr - -**Includes:** CGI::TagMaker - - -Mixin module for generating HTML version 4 with framesets. - - - -#Instance Methods -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - diff --git a/example/ruby/CGI/Html4Tr.md b/example/ruby/CGI/Html4Tr.md deleted file mode 100644 index 502247c..0000000 --- a/example/ruby/CGI/Html4Tr.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: CGI::Html4Tr - -**Includes:** CGI::TagMaker - - -Mixin module for HTML version 4 transitional generation methods. - - - -#Instance Methods -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - diff --git a/example/ruby/CGI/Html5.md b/example/ruby/CGI/Html5.md deleted file mode 100644 index 35a28f2..0000000 --- a/example/ruby/CGI/Html5.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: CGI::Html5 - -**Includes:** CGI::TagMaker - - -Mixin module for HTML version 5 generation methods. - - - -#Instance Methods -## doctype() [](#method-i-doctype) -The DOCTYPE declaration for this version of HTML - -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - diff --git a/example/ruby/CGI/HtmlExtension.md b/example/ruby/CGI/HtmlExtension.md deleted file mode 100644 index 966efb6..0000000 --- a/example/ruby/CGI/HtmlExtension.md +++ /dev/null @@ -1,469 +0,0 @@ -# Module: CGI::HtmlExtension - - -Mixin module providing HTML generation methods. - -For example, - cgi.a("http://www.example.com") { "Example" } - # => "Example" - -Modules Html3, Html4, etc., contain more basic HTML-generation methods -(`#title`, `#h1`, etc.). - -See class CGI for a detailed example. - - - -#Instance Methods -## a(href"") [](#method-i-a) -Generate an Anchor element as a string. - -`href` can either be a string, giving the URL for the HREF attribute, or it -can be a hash of the element's attributes. - -The body of the element is the string returned by the no-argument block passed -in. - - a("http://www.example.com") { "Example" } - # => "Example" - - a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" } - # => "Example" - -## base(href"") [](#method-i-base) -Generate a Document Base URI element as a String. - -`href` can either by a string, giving the base URL for the HREF attribute, or -it can be a has of the element's attributes. - -The passed-in no-argument block is ignored. - - base("http://www.example.com/cgi") - # => "" - -## blockquote(cite{}) [](#method-i-blockquote) -Generate a BlockQuote element as a string. - -`cite` can either be a string, give the URI for the source of the quoted text, -or a hash, giving all attributes of the element, or it can be omitted, in -which case the element has no attributes. - -The body is provided by the passed-in no-argument block - - blockquote("http://www.example.com/quotes/foo.html") { "Foo!" } - #=> "
Foo!
- -## caption(align{}) [](#method-i-caption) -Generate a Table Caption element as a string. - -`align` can be a string, giving the alignment of the caption (one of top, -bottom, left, or right). It can be a hash of all the attributes of the -element. Or it can be omitted. - -The body of the element is provided by the passed-in no-argument block. - - caption("left") { "Capital Cities" } - # => Capital Cities - -## checkbox(name"", valuenil, checkednil) [](#method-i-checkbox) -Generate a Checkbox Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`value`, and `checked`. `checked` is a boolean value; if true, the CHECKED -attribute will be included in the element. - -Alternatively, the attributes can be specified as a hash. - - checkbox("name") - # = checkbox("NAME" => "name") - - checkbox("name", "value") - # = checkbox("NAME" => "name", "VALUE" => "value") - - checkbox("name", "value", true) - # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true) - -## checkbox_group(name"", *values) [](#method-i-checkbox_group) -Generate a sequence of checkbox elements, as a String. - -The checkboxes will all have the same `name` attribute. Each checkbox is -followed by a label. There will be one checkbox for each value. Each value -can be specified as a String, which will be used both as the value of the -VALUE attribute and as the label for that checkbox. A single-element array -has the same effect. - -Each value can also be specified as a three-element array. The first element -is the VALUE attribute; the second is the label; and the third is a boolean -specifying whether this checkbox is CHECKED. - -Each value can also be specified as a two-element array, by omitting either -the value element (defaults to the same as the label), or the boolean checked -element (defaults to false). - - checkbox_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - checkbox_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - checkbox_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - checkbox_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## file_field(name"", size20, maxlengthnil) [](#method-i-file_field) -Generate an File Upload Input element as a string. - -The attributes of the element can be specified as three arguments, `name`, -`size`, and `maxlength`. `maxlength` is the maximum length of the file's -*name*, not of the file's *contents*. - -Alternatively, the attributes can be specified as a hash. - -See #multipart_form() for forms that include file uploads. - - file_field("name") - # - - file_field("name", 40) - # - - file_field("name", 40, 100) - # - - file_field("NAME" => "name", "SIZE" => 40) - # - -## form(method"post", actionscript_name, enctype"application/x-www-form-urlencoded") [](#method-i-form) -Generate a Form element as a string. - -`method` should be either "get" or "post", and defaults to the latter. -`action` defaults to the current CGI script name. `enctype` defaults to -"application/x-www-form-urlencoded". - -Alternatively, the attributes can be specified as a hash. - -See also #multipart_form() for forms that include file uploads. - - form{ "string" } - #
string
- - form("get") { "string" } - #
string
- - form("get", "url") { "string" } - #
string
- - form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" } - #
string
- -## hidden(name"", valuenil) [](#method-i-hidden) -Generate a Hidden Input element as a string. - -The attributes of the element can be specified as two arguments, `name` and -`value`. - -Alternatively, the attributes can be specified as a hash. - - hidden("name") - # - - hidden("name", "value") - # - - hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo") - # - -## html(attributes{}) [](#method-i-html) -Generate a top-level HTML element as a string. - -The attributes of the element are specified as a hash. The pseudo-attribute -"PRETTY" can be used to specify that the generated HTML string should be -indented. "PRETTY" can also be specified as a string as the sole argument to -this method. The pseudo-attribute "DOCTYPE", if given, is used as the leading -DOCTYPE SGML tag; it should include the entire text of this tag, including -angle brackets. - -The body of the html element is supplied as a block. - - html{ "string" } - # string - - html("LANG" => "ja") { "string" } - # string - - html("DOCTYPE" => false) { "string" } - # string - - html("DOCTYPE" => '') { "string" } - # string - - html("PRETTY" => " ") { "" } - # - # - # - # - # - - html("PRETTY" => "\t") { "" } - # - # - # - # - # - - html("PRETTY") { "" } - # = html("PRETTY" => " ") { "" } - - html(if $VERBOSE then "PRETTY" end) { "HTML string" } - -## image_button(src"", namenil, altnil) [](#method-i-image_button) -Generate an Image Button Input element as a string. - -`src` is the URL of the image to use for the button. `name` is the input -name. `alt` is the alternative text for the image. - -Alternatively, the attributes can be specified as a hash. - - image_button("url") - # - - image_button("url", "name", "string") - # - - image_button("SRC" => "url", "ALT" => "string") - # - -## img(src"", alt"", widthnil, heightnil) [](#method-i-img) -Generate an Image element as a string. - -`src` is the URL of the image. `alt` is the alternative text for the image. -`width` is the width of the image, and `height` is its height. - -Alternatively, the attributes can be specified as a hash. - - img("src", "alt", 100, 50) - # alt - - img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50) - # alt - -## multipart_form(actionnil, enctype"multipart/form-data") [](#method-i-multipart_form) -Generate a Form element with multipart encoding as a String. - -Multipart encoding is used for forms that include file uploads. - -`action` is the action to perform. `enctype` is the encoding type, which -defaults to "multipart/form-data". - -Alternatively, the attributes can be specified as a hash. - - multipart_form{ "string" } - #
string
- - multipart_form("url") { "string" } - #
string
- -## password_field(name"", valuenil, size40, maxlengthnil) [](#method-i-password_field) -Generate a Password Input element as a string. - -`name` is the name of the input field. `value` is its default value. `size` -is the size of the input field display. `maxlength` is the maximum length of -the inputted password. - -Alternatively, attributes can be specified as a hash. - - password_field("name") - # - - password_field("name", "value") - # - - password_field("password", "value", 80, 200) - # - - password_field("NAME" => "name", "VALUE" => "value") - # - -## popup_menu(name"", *values) [](#method-i-popup_menu) -Generate a Select element as a string. - -`name` is the name of the element. The `values` are the options that can be -selected from the Select menu. Each value can be a String or a one, two, or -three-element Array. If a String or a one-element Array, this is both the -value of that option and the text displayed for it. If a three-element Array, -the elements are the option value, displayed text, and a boolean value -specifying whether this option starts as selected. The two-element version -omits either the option value (defaults to the same as the display text) or -the boolean selected specifier (defaults to false). - -The attributes and options can also be specified as a hash. In this case, -options are specified as an array of values as described above, with the hash -key of "VALUES". - - popup_menu("name", "foo", "bar", "baz") - # - - popup_menu("name", ["foo"], ["bar", true], "baz") - # - - popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # - - popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true, - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - # - -## radio_button(name"", valuenil, checkednil) [](#method-i-radio_button) -Generates a radio-button Input element. - -`name` is the name of the input field. `value` is the value of the field if -checked. `checked` specifies whether the field starts off checked. - -Alternatively, the attributes can be specified as a hash. - - radio_button("name", "value") - # - - radio_button("name", "value", true) - # - - radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo") - # - -## radio_group(name"", *values) [](#method-i-radio_group) -Generate a sequence of radio button Input elements, as a String. - -This works the same as #checkbox_group(). However, it is not valid to have -more than one radiobutton in a group checked. - - radio_group("name", "foo", "bar", "baz") - # foo - # bar - # baz - - radio_group("name", ["foo"], ["bar", true], "baz") - # foo - # bar - # baz - - radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") - # Foo - # Bar - # Baz - - radio_group("NAME" => "name", - "VALUES" => ["foo", "bar", "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["foo"], ["bar", true], "baz"]) - - radio_group("NAME" => "name", - "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]) - -## reset(valuenil, namenil) [](#method-i-reset) -Generate a reset button Input element, as a String. - -This resets the values on a form to their initial values. `value` is the text -displayed on the button. `name` is the name of this button. - -Alternatively, the attributes can be specified as a hash. - - reset - # - - reset("reset") - # - - reset("VALUE" => "reset", "ID" => "foo") - # - -## submit(valuenil, namenil) [](#method-i-submit) -Generate a submit button Input element, as a String. - -`value` is the text to display on the button. `name` is the name of the -input. - -Alternatively, the attributes can be specified as a hash. - - submit - # - - submit("ok") - # - - submit("ok", "button1") - # - - submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") - # - -## text_field(name"", valuenil, size40, maxlengthnil) [](#method-i-text_field) -Generate a text field Input element, as a String. - -`name` is the name of the input field. `value` is its initial value. `size` -is the size of the input area. `maxlength` is the maximum length of input -accepted. - -Alternatively, the attributes can be specified as a hash. - - text_field("name") - # - - text_field("name", "value") - # - - text_field("name", "value", 80) - # - - text_field("name", "value", 80, 200) - # - - text_field("NAME" => "name", "VALUE" => "value") - # - -## textarea(name"", cols70, rows10) [](#method-i-textarea) -Generate a TextArea element, as a String. - -`name` is the name of the textarea. `cols` is the number of columns and -`rows` is the number of rows in the display. - -Alternatively, the attributes can be specified as a hash. - -The body is provided by the passed-in no-argument block - - textarea("name") - # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10) - - textarea("name", 40, 5) - # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5) - diff --git a/example/ruby/CGI/InvalidEncoding.md b/example/ruby/CGI/InvalidEncoding.md deleted file mode 100644 index 2814a77..0000000 --- a/example/ruby/CGI/InvalidEncoding.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: CGI::InvalidEncoding -**Inherits:** Exception - - -Exception raised when there is an invalid encoding detected - - - diff --git a/example/ruby/CGI/QueryExtension.md b/example/ruby/CGI/QueryExtension.md deleted file mode 100644 index 911f2f6..0000000 --- a/example/ruby/CGI/QueryExtension.md +++ /dev/null @@ -1,66 +0,0 @@ -# Module: CGI::QueryExtension - - -Mixin module that provides the following: - -1. Access to the CGI environment variables as methods. See documentation to - the CGI class for a list of these variables. The methods are exposed by - removing the leading `HTTP_` (if it exists) and downcasing the name. For - example, `auth_type` will return the environment variable `AUTH_TYPE`, and - `accept` will return the value for `HTTP_ACCEPT`. - -2. Access to cookies, including the cookies attribute. - -3. Access to parameters, including the params attribute, and overloading #[] - to perform parameter value lookup by key. - -4. The initialize_query method, for initializing the above mechanisms, - handling multipart forms, and allowing the class to be used in "offline" - mode. - - -# Attributes -## cookies[RW] [](#attribute-i-cookies) -Get the cookies as a hash of cookie-name=>Cookie pairs. - -## files[RW] [](#attribute-i-files) -Get the uploaded files as a hash of name=>values pairs - -## params[RW] [](#attribute-i-params) -Get the parameters as a hash of name=>values pairs, where values is an Array. - - -#Instance Methods -## [](key) [](#method-i-[]) -Get the value for the parameter with a given key. - -If the parameter has multiple values, only the first will be retrieved; use -#params to get the array of values. - -## create_body(is_large) [](#method-i-create_body) -:nodoc: - -## has_key?(*args) [](#method-i-has_key?) -Returns true if a given query string parameter exists. - -**@return** [Boolean] - -## keys(*args) [](#method-i-keys) -Return all query parameter names as an array of String. - -## multipart?() [](#method-i-multipart?) -Returns whether the form contained multipart/form-data - -**@return** [Boolean] - -## raw_cookie() [](#method-i-raw_cookie) -Get the raw cookies as a string. - -## raw_cookie2() [](#method-i-raw_cookie2) -Get the raw RFC2965 cookies as a string. - -## unescape_filename?() [](#method-i-unescape_filename?) -:nodoc: - -**@return** [Boolean] - diff --git a/example/ruby/CGI/Session.md b/example/ruby/CGI/Session.md deleted file mode 100644 index b4e54e9..0000000 --- a/example/ruby/CGI/Session.md +++ /dev/null @@ -1,258 +0,0 @@ -# Class: CGI::Session -**Inherits:** Object - - -## Overview - -This file provides the CGI::Session class, which provides session support for -CGI scripts. A session is a sequence of HTTP requests and responses linked -together and associated with a single client. Information associated with the -session is stored on the server between requests. A session id is passed -between client and server with every request and response, transparently to -the user. This adds state information to the otherwise stateless HTTP -request/response protocol. - -## Lifecycle - -A CGI::Session instance is created from a CGI object. By default, this -CGI::Session instance will start a new session if none currently exists, or -continue the current session for this client if one does exist. The -`new_session` option can be used to either always or never create a new -session. See #new() for more details. - -#delete() deletes a session from session storage. It does not however remove -the session id from the client. If the client makes another request with the -same id, the effect will be to start a new session with the old session's id. - -## Setting and retrieving session data. - -The Session class associates data with a session as key-value pairs. This data -can be set and retrieved by indexing the Session instance using '[]', much the -same as hashes (although other hash methods are not supported). - -When session processing has been completed for a request, the session should -be closed using the close() method. This will store the session's state to -persistent storage. If you want to store the session's state to persistent -storage without finishing session processing for this request, call the -update() method. - -## Storing session state - -The caller can specify what form of storage to use for the session's data with -the `database_manager` option to CGI::Session::new. The following storage -classes are provided as part of the standard library: - -CGI::Session::FileStore -: stores data as plain text in a flat file. Only works with String data. - This is the default storage type. - -CGI::Session::MemoryStore -: stores data in an in-memory hash. The data only persists for as long as - the current Ruby interpreter instance does. - -CGI::Session::PStore -: stores data in Marshalled format. Provided by cgi/session/pstore.rb. - Supports data of any type, and provides file-locking and transaction - support. - - -Custom storage types can also be created by defining a class with the -following methods: - - new(session, options) - restore # returns hash of session data. - update - close - delete - -Changing storage type mid-session does not work. Note in particular that by -default the FileStore and PStore session data files have the same name. If -your application switches from one to the other without making sure that -filenames will be different and clients still have old sessions lying around -in cookies, then things will break nastily! - -## Maintaining the session id. - -Most session state is maintained on the server. However, a session id must be -passed backwards and forwards between client and server to maintain a -reference to this session state. - -The simplest way to do this is via cookies. The CGI::Session class provides -transparent support for session id communication via cookies if the client has -cookies enabled. - -If the client has cookies disabled, the session id must be included as a -parameter of all requests sent by the client to the server. The CGI::Session -class in conjunction with the CGI class will transparently add the session id -as a hidden input field to all forms generated using the CGI#form() HTML -generation method. No built-in support is provided for other mechanisms, such -as URL re-writing. The caller is responsible for extracting the session id -from the session_id attribute and manually encoding it in URLs and adding it -as a hidden input to HTML forms created by other mechanisms. Also, session -expiry is not automatically handled. - -## Examples of use - -### Setting the user's name - - require 'cgi' - require 'cgi/session' - require 'cgi/session/pstore' # provides CGI::Session::PStore - - cgi = CGI.new("html4") - - session = CGI::Session.new(cgi, - 'database_manager' => CGI::Session::PStore, # use PStore - 'session_key' => '_rb_sess_id', # custom session key - 'session_expires' => Time.now + 30 * 60, # 30 minute timeout - 'prefix' => 'pstore_sid_') # PStore option - if cgi.has_key?('user_name') and cgi['user_name'] != '' - # coerce to String: cgi[] returns the - # string-like CGI::QueryExtension::Value - session['user_name'] = cgi['user_name'].to_s - elsif !session['user_name'] - session['user_name'] = "guest" - end - session.close - -### Creating a new session safely - - require 'cgi' - require 'cgi/session' - - cgi = CGI.new("html4") - - # We make sure to delete an old session if one exists, - # not just to free resources, but to prevent the session - # from being maliciously hijacked later on. - begin - session = CGI::Session.new(cgi, 'new_session' => false) - session.delete - rescue ArgumentError # if no old session - end - session = CGI::Session.new(cgi, 'new_session' => true) - session.close - - -# Class Methods -## callback(dbman ) [](#method-c-callback) -:nodoc: -# Attributes -## new_session[RW] [](#attribute-i-new_session) -The id of this session. - -## session_id[RW] [](#attribute-i-session_id) -The id of this session. - - -#Instance Methods -## [](key) [](#method-i-[]) -Retrieve the session data for key `key`. - -## []=(key, val) [](#method-i-[]=) -Set the session data for key `key`. - -## close() [](#method-i-close) -Store session data on the server and close the session storage. For some -session storage types, this is a no-op. - -## delete() [](#method-i-delete) -Delete the session from storage. Also closes the storage. - -Note that the session's data is *not* automatically deleted upon the session -expiring. - -## initialize(request, option{}) [](#method-i-initialize) -Create a new CGI::Session object for `request`. - -`request` is an instance of the `CGI` class (see cgi.rb). `option` is a hash -of options for initialising this CGI::Session instance. The following options -are recognised: - -session_key -: the parameter name used for the session id. Defaults to '_session_id'. - -session_id -: the session id to use. If not provided, then it is retrieved from the - `session_key` parameter of the request, or automatically generated for a - new session. - -new_session -: if true, force creation of a new session. If not set, a new session is - only created if none currently exists. If false, a new session is never - created, and if none currently exists and the `session_id` option is not - set, an ArgumentError is raised. - -database_manager -: the name of the class providing storage facilities for session state - persistence. Built-in support is provided for `FileStore` (the default), - `MemoryStore`, and `PStore` (from cgi/session/pstore.rb). See the - documentation for these classes for more details. - - -The following options are also recognised, but only apply if the session id is -stored in a cookie. - -session_expires -: the time the current session expires, as a `Time` object. If not set, the - session will terminate when the user's browser is closed. - -session_domain -: the hostname domain for which this session is valid. If not set, defaults - to the hostname of the server. - -session_secure -: if `true`, this session will only work over HTTPS. - -session_path -: the path for which this session applies. Defaults to the directory of the - CGI script. - - -`option` is also passed on to the session storage class initializer; see the -documentation for each session storage class for the options they support. - -The retrieved or created session is automatically added to `request` as a -cookie, and also to its `output_hidden` table, which is used to add hidden -input elements to forms. - -**WARNING** the `output_hidden` fields are surrounded by a
tag in -HTML 4 generation, which is *not* invisible on many browsers; you may wish to -disable the use of fieldsets with code similar to the following (see -https://blade.ruby-lang.org/ruby-list/37805) - - cgi = CGI.new("html4") - class << cgi - undef_method :fieldset - end - -**@return** [Session] a new instance of Session - -## new_store_file(option{}) [](#method-i-new_store_file) -Create a new file to store the session data. - -This file will be created if it does not exist, or opened if it does. - -This path is generated under *tmpdir* from *prefix*, the digested session id, -and *suffix*. - -`option` is a hash of options for the initializer. The following options are -recognised: - -tmpdir -: the directory to use for storing the FileStore file. Defaults to - Dir::tmpdir (generally "/tmp" on Unix systems). - -prefix -: the prefix to add to the session id when generating the filename for this - session's FileStore file. Defaults to "cgi_sid_". - -suffix -: the prefix to add to the session id when generating the filename for this - session's FileStore file. Defaults to the empty string. - - -## update() [](#method-i-update) -Store session data on the server. For some session storage types, this is a -no-op. - diff --git a/example/ruby/CGI/Session/FileStore.md b/example/ruby/CGI/Session/FileStore.md deleted file mode 100644 index 286b3d8..0000000 --- a/example/ruby/CGI/Session/FileStore.md +++ /dev/null @@ -1,59 +0,0 @@ -# Class: CGI::Session::FileStore -**Inherits:** Object - - -File-based session storage class. - -Implements session storage as a flat file of 'key=value' values. This storage -type only works directly with String values; the user is responsible for -converting other types to Strings when storing and from Strings when -retrieving. - - - -#Instance Methods -## close() [](#method-i-close) -Update and close the session's FileStore file. - -## delete() [](#method-i-delete) -Close and delete the session's FileStore file. - -## initialize(session, option{}) [](#method-i-initialize) -Create a new FileStore instance. - -This constructor is used internally by CGI::Session. The user does not -generally need to call it directly. - -`session` is the session for which this instance is being created. The -session id must only contain alphanumeric characters; automatically generated -session ids observe this requirement. - -`option` is a hash of options for the initializer. The following options are -recognised: - -tmpdir -: the directory to use for storing the FileStore file. Defaults to - Dir::tmpdir (generally "/tmp" on Unix systems). - -prefix -: the prefix to add to the session id when generating the filename for this - session's FileStore file. Defaults to "cgi_sid_". - -suffix -: the prefix to add to the session id when generating the filename for this - session's FileStore file. Defaults to the empty string. - - -This session's FileStore file will be created if it does not exist, or opened -if it does. - -**@return** [FileStore] a new instance of FileStore - -## restore() [](#method-i-restore) -Restore session state from the session's FileStore file. - -Returns the session state as a hash. - -## update() [](#method-i-update) -Save session state to the session's FileStore file. - diff --git a/example/ruby/CGI/Session/MemoryStore.md b/example/ruby/CGI/Session/MemoryStore.md deleted file mode 100644 index 45baaaf..0000000 --- a/example/ruby/CGI/Session/MemoryStore.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: CGI::Session::MemoryStore -**Inherits:** Object - - -In-memory session storage class. - -Implements session storage as a global in-memory hash. Session data will only -persist for as long as the Ruby interpreter instance does. - - - -#Instance Methods -## close() [](#method-i-close) -Close session storage. - -A no-op. - -## delete() [](#method-i-delete) -Delete the session state. - -## initialize(session, optionnil) [](#method-i-initialize) -Create a new MemoryStore instance. - -`session` is the session this instance is associated with. `option` is a list -of initialisation options. None are currently recognized. - -**@return** [MemoryStore] a new instance of MemoryStore - -## restore() [](#method-i-restore) -Restore session state. - -Returns session data as a hash. - -## update() [](#method-i-update) -Update session state. - -A no-op. - diff --git a/example/ruby/CGI/Session/NoSession.md b/example/ruby/CGI/Session/NoSession.md deleted file mode 100644 index 73dcd7d..0000000 --- a/example/ruby/CGI/Session/NoSession.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: CGI::Session::NoSession -**Inherits:** RuntimeError - - -:nodoc: - - - diff --git a/example/ruby/CGI/Session/NullStore.md b/example/ruby/CGI/Session/NullStore.md deleted file mode 100644 index c2da300..0000000 --- a/example/ruby/CGI/Session/NullStore.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: CGI::Session::NullStore -**Inherits:** Object - - -Dummy session storage class. - -Implements session storage place holder. No actual storage will be done. - - - -#Instance Methods -## close() [](#method-i-close) -Close session storage. - -A no-op. - -## delete() [](#method-i-delete) -Delete the session state. - -A no-op. - -## initialize(session, optionnil) [](#method-i-initialize) -Create a new NullStore instance. - -`session` is the session this instance is associated with. `option` is a list -of initialisation options. None are currently recognised. - -**@return** [NullStore] a new instance of NullStore - -## restore() [](#method-i-restore) -Restore (empty) session state. - -## update() [](#method-i-update) -Update session state. - -A no-op. - diff --git a/example/ruby/CGI/Session/PStore.md b/example/ruby/CGI/Session/PStore.md deleted file mode 100644 index bb901bd..0000000 --- a/example/ruby/CGI/Session/PStore.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: CGI::Session::PStore -**Inherits:** Object - - -PStore-based session storage class. - -This builds upon the top-level PStore class provided by the library file -pstore.rb. Session data is marshalled and stored in a file. File locking and -transaction services are provided. - - - -#Instance Methods -## close() [](#method-i-close) -Update and close the session's PStore file. - -## delete() [](#method-i-delete) -Close and delete the session's PStore file. - -## initialize(session, option{}) [](#method-i-initialize) -Create a new CGI::Session::PStore instance - -This constructor is used internally by CGI::Session. The user does not -generally need to call it directly. - -`session` is the session for which this instance is being created. The -session id must only contain alphanumeric characters; automatically generated -session ids observe this requirement. - -`option` is a hash of options for the initializer. The following options are -recognised: - -tmpdir -: the directory to use for storing the PStore file. Defaults to Dir::tmpdir - (generally "/tmp" on Unix systems). - -prefix -: the prefix to add to the session id when generating the filename for this - session's PStore file. Defaults to the empty string. - - -This session's PStore file will be created if it does not exist, or opened if -it does. - -**@return** [PStore] a new instance of PStore - -## restore() [](#method-i-restore) -Restore session state from the session's PStore file. - -Returns the session state as a hash. - -## update() [](#method-i-update) -Save session state to the session's PStore file. - diff --git a/example/ruby/CGI/TagMaker.md b/example/ruby/CGI/TagMaker.md deleted file mode 100644 index 3fb027e..0000000 --- a/example/ruby/CGI/TagMaker.md +++ /dev/null @@ -1,33 +0,0 @@ -# Module: CGI::TagMaker - - -Base module for HTML-generation mixins. - -Provides methods for code generation for tags following the various DTD -element types. - - - -#Instance Methods -## nOE_element(element, attributes{}) [](#method-i-nOE_element) -Generate code for an empty element. - - - O EMPTY - -## nOE_element_def(attributes{}, &block) [](#method-i-nOE_element_def) - -## nO_element(element, attributes{}) [](#method-i-nO_element) -Generate code for an element for which the end (and possibly the start) tag is -optional. - - O O or - O - -## nO_element_def(attributes{}, &block) [](#method-i-nO_element_def) - -## nn_element(element, attributes{}) [](#method-i-nn_element) -Generate code for an element with required start and end tags. - - - - - -## nn_element_def(attributes{}, &block) [](#method-i-nn_element_def) - diff --git a/example/ruby/CGI/Util.md b/example/ruby/CGI/Util.md deleted file mode 100644 index 0a6f9ed..0000000 --- a/example/ruby/CGI/Util.md +++ /dev/null @@ -1,90 +0,0 @@ -# Module: CGI::Util - - - - - -#Instance Methods -## escape(string) [](#method-i-escape) -URL-encode a string into application/x-www-form-urlencoded. Space characters -(+" "+) are encoded with plus signs (+"+"+) - url_encoded_string = CGI.escape("'Stop!' said Fred") - # => "%27Stop%21%27+said+Fred" - -## escapeElement(string, *elements) [](#method-i-escapeElement) -Escape only the tags of certain HTML elements in `string`. - -Takes an element or elements or array of elements. Each element is specified -by the name of the element, without angle brackets. This matches both the -start and the end tag of that element. The attribute list of the open tag will -also be escaped (for instance, the double-quotes surrounding attribute -values). - - print CGI.escapeElement('
', "A", "IMG") - # "
<A HREF="url"></A>" - - print CGI.escapeElement('
', ["A", "IMG"]) - # "
<A HREF="url"></A>" - -## escapeHTML(string) [](#method-i-escapeHTML) -Escape special characters in HTML, namely '&"<> - CGI.escapeHTML('Usage: foo "bar" ') - # => "Usage: foo "bar" <baz>" - -## escapeURIComponent(string) [](#method-i-escapeURIComponent) -URL-encode a string following RFC 3986 Space characters (+" "+) are encoded -with (+"%20"+) - url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred") - # => "%27Stop%21%27%20said%20Fred" - -## pretty(string, shift" ") [](#method-i-pretty) -Prettify (indent) an HTML string. - -`string` is the HTML string to indent. `shift` is the indentation unit to -use; it defaults to two spaces. - - print CGI.pretty("") - # - # - # - # - - print CGI.pretty("", "\t") - # - # - # - # - -## rfc1123_date(time) [](#method-i-rfc1123_date) -Format a `Time` object as a String using the format specified by RFC 1123. - - CGI.rfc1123_date(Time.now) - # Sat, 01 Jan 2000 00:00:00 GMT - -## unescape(string, encoding@@accept_charset) [](#method-i-unescape) -URL-decode an application/x-www-form-urlencoded string with -encoding(optional). - string = CGI.unescape("%27Stop%21%27+said+Fred") - # => "'Stop!' said Fred" - -## unescapeElement(string, *elements) [](#method-i-unescapeElement) -Undo escaping such as that done by CGI.escapeElement() - - print CGI.unescapeElement( - CGI.escapeHTML('
'), "A", "IMG") - # "<BR>" - - print CGI.unescapeElement( - CGI.escapeHTML('
'), ["A", "IMG"]) - # "<BR>" - -## unescapeHTML(string) [](#method-i-unescapeHTML) -Unescape a string that has been HTML-escaped - CGI.unescapeHTML("Usage: foo "bar" <baz>") - # => "Usage: foo \"bar\" " - -## unescapeURIComponent(string, encoding@@accept_charset) [](#method-i-unescapeURIComponent) -URL-decode a string following RFC 3986 with encoding(optional). - string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred") - # => "'Stop!'+said Fred" - diff --git a/example/ruby/CGICookieTest.md b/example/ruby/CGICookieTest.md deleted file mode 100644 index f0667d1..0000000 --- a/example/ruby/CGICookieTest.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: CGICookieTest -**Inherits:** Test::Unit::TestCase - -**Includes:** UpdateEnv - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_cookie_arrayinterface() [](#method-i-test_cgi_cookie_arrayinterface) - -## test_cgi_cookie_domain_injection_into_name() [](#method-i-test_cgi_cookie_domain_injection_into_name) - -## test_cgi_cookie_injection_into_domain() [](#method-i-test_cgi_cookie_injection_into_domain) - -## test_cgi_cookie_injection_into_path() [](#method-i-test_cgi_cookie_injection_into_path) - -## test_cgi_cookie_multibyte_injection_into_name() [](#method-i-test_cgi_cookie_multibyte_injection_into_name) - -## test_cgi_cookie_new_complex() [](#method-i-test_cgi_cookie_new_complex) - -## test_cgi_cookie_new_simple() [](#method-i-test_cgi_cookie_new_simple) - -## test_cgi_cookie_new_with_domain() [](#method-i-test_cgi_cookie_new_with_domain) - -## test_cgi_cookie_newline_injection_into_name() [](#method-i-test_cgi_cookie_newline_injection_into_name) - -## test_cgi_cookie_parse() [](#method-i-test_cgi_cookie_parse) - -## test_cgi_cookie_parse_not_decode_name() [](#method-i-test_cgi_cookie_parse_not_decode_name) - -## test_cgi_cookie_scriptname() [](#method-i-test_cgi_cookie_scriptname) - -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/CGICoreTest.md b/example/ruby/CGICoreTest.md deleted file mode 100644 index e1c3180..0000000 --- a/example/ruby/CGICoreTest.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: CGICoreTest -**Inherits:** Test::Unit::TestCase - -**Includes:** UpdateEnv - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_core_cookie() [](#method-i-test_cgi_core_cookie) - -## test_cgi_core_environs() [](#method-i-test_cgi_core_environs) - -## test_cgi_core_htmltype_header() [](#method-i-test_cgi_core_htmltype_header) - -## test_cgi_core_maxcontentlength() [](#method-i-test_cgi_core_maxcontentlength) - -## test_cgi_core_out() [](#method-i-test_cgi_core_out) - -## test_cgi_core_params_GET() [](#method-i-test_cgi_core_params_GET) - -## test_cgi_core_params_POST() [](#method-i-test_cgi_core_params_POST) - -## test_cgi_core_params_encoding_check() [](#method-i-test_cgi_core_params_encoding_check) - -## test_cgi_core_print() [](#method-i-test_cgi_core_print) - -## test_cgi_parse_illegal_query() [](#method-i-test_cgi_parse_illegal_query) - -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/CGIHeaderTest.md b/example/ruby/CGIHeaderTest.md deleted file mode 100644 index bcda43f..0000000 --- a/example/ruby/CGIHeaderTest.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: CGIHeaderTest -**Inherits:** Test::Unit::TestCase - -**Includes:** UpdateEnv - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_http_header_argerr() [](#method-i-test_cgi_http_header_argerr) - -## test_cgi_http_header_complex() [](#method-i-test_cgi_http_header_complex) - -## test_cgi_http_header_cookie() [](#method-i-test_cgi_http_header_cookie) - -## test_cgi_http_header_crlf_injection() [](#method-i-test_cgi_http_header_crlf_injection) - -## test_cgi_http_header_nph() [](#method-i-test_cgi_http_header_nph) - -## test_cgi_http_header_output_cookies() [](#method-i-test_cgi_http_header_output_cookies) - -## test_cgi_http_header_simple() [](#method-i-test_cgi_http_header_simple) - -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/CGIModrubyTest.md b/example/ruby/CGIModrubyTest.md deleted file mode 100644 index c0d190f..0000000 --- a/example/ruby/CGIModrubyTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: CGIModrubyTest -**Inherits:** Test::Unit::TestCase - -**Includes:** UpdateEnv - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_modruby_complex() [](#method-i-test_cgi_modruby_complex) - -## test_cgi_modruby_location() [](#method-i-test_cgi_modruby_location) - -## test_cgi_modruby_requestparams() [](#method-i-test_cgi_modruby_requestparams) - -## test_cgi_modruby_simple() [](#method-i-test_cgi_modruby_simple) - -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/CGIMultipartTest.md b/example/ruby/CGIMultipartTest.md deleted file mode 100644 index cb0f7f6..0000000 --- a/example/ruby/CGIMultipartTest.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: CGIMultipartTest -**Inherits:** Test::Unit::TestCase - -**Includes:** UpdateEnv - - - - - -#Instance Methods -## _prepare(data) [](#method-i-_prepare) - -## _read(basename) [](#method-i-_read) - -## _set_const(klass, name, value) [](#method-i-_set_const) - -## _test_multipart(cgi_options{}) [](#method-i-_test_multipart) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_multipart_badbody() [](#method-i-test_cgi_multipart_badbody) -ruby-dev:28470 -: - -## test_cgi_multipart_boundary_10240() [](#method-i-test_cgi_multipart_boundary_10240) -Bug #3866 -: - -## test_cgi_multipart_maxmultipartcount() [](#method-i-test_cgi_multipart_maxmultipartcount) - -## test_cgi_multipart_maxmultipartlength() [](#method-i-test_cgi_multipart_maxmultipartlength) - -## test_cgi_multipart_maxmultipartlength_lambda() [](#method-i-test_cgi_multipart_maxmultipartlength_lambda) - -## test_cgi_multipart_quoteboundary() [](#method-i-test_cgi_multipart_quoteboundary) -JVN#84798830 -: - -## test_cgi_multipart_stringio() [](#method-i-test_cgi_multipart_stringio) - -## test_cgi_multipart_tempfile() [](#method-i-test_cgi_multipart_tempfile) - -## test_cgi_multipart_without_tempfile() [](#method-i-test_cgi_multipart_without_tempfile) - -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/CGISessionTest.md b/example/ruby/CGISessionTest.md deleted file mode 100644 index acfc548..0000000 --- a/example/ruby/CGISessionTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: CGISessionTest -**Inherits:** Test::Unit::TestCase - -**Includes:** UpdateEnv - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_session_filestore() [](#method-i-test_cgi_session_filestore) - -## test_cgi_session_pstore() [](#method-i-test_cgi_session_pstore) - -## test_cgi_session_specify_session_id() [](#method-i-test_cgi_session_specify_session_id) - -## test_cgi_session_specify_session_key() [](#method-i-test_cgi_session_specify_session_key) - -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/CGISpecs.md b/example/ruby/CGISpecs.md deleted file mode 100644 index aadad9e..0000000 --- a/example/ruby/CGISpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: CGISpecs - - - - -# Class Methods -## cgi_new(html "html4") [](#method-c-cgi_new) -## split(string ) [](#method-c-split) - diff --git a/example/ruby/CGITagHelperTest.md b/example/ruby/CGITagHelperTest.md deleted file mode 100644 index 853547a..0000000 --- a/example/ruby/CGITagHelperTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: CGITagHelperTest -**Inherits:** Test::Unit::TestCase - -**Includes:** UpdateEnv - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_tag_helper_html3() [](#method-i-test_cgi_tag_helper_html3) - -## test_cgi_tag_helper_html5() [](#method-i-test_cgi_tag_helper_html5) -def test_cgi_tag_helper_html4 - ## html4 - cgi = CGI.new('html4') - ## html4 transitional - cgi = CGI.new('html4Tr') - ## html4 frameset - cgi = CGI.new('html4Fr') - end - -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/CGIUtilPureRubyTest.md b/example/ruby/CGIUtilPureRubyTest.md deleted file mode 100644 index 80a5840..0000000 --- a/example/ruby/CGIUtilPureRubyTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: CGIUtilPureRubyTest -**Inherits:** Test::Unit::TestCase - -**Includes:** CGIUtilTest::UnescapeHTMLTests - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_escapeHTML_with_invalid_byte_sequence() [](#method-i-test_cgi_escapeHTML_with_invalid_byte_sequence) - -## test_cgi_unescapeHTML_following_invalid_numeric() [](#method-i-test_cgi_unescapeHTML_following_invalid_numeric) - -## test_cgi_unescapeHTML_following_known_first_letter() [](#method-i-test_cgi_unescapeHTML_following_known_first_letter) - -## test_cgi_unescapeHTML_following_number_sign() [](#method-i-test_cgi_unescapeHTML_following_number_sign) - -## test_cgi_unescapeHTML_with_invalid_byte_sequence() [](#method-i-test_cgi_unescapeHTML_with_invalid_byte_sequence) - diff --git a/example/ruby/CGIUtilTest.md b/example/ruby/CGIUtilTest.md deleted file mode 100644 index f2728e2..0000000 --- a/example/ruby/CGIUtilTest.md +++ /dev/null @@ -1,171 +0,0 @@ -# Class: CGIUtilTest -**Inherits:** Test::Unit::TestCase - -**Includes:** CGI::Util, CGIUtilTest::UnescapeHTMLTests, UpdateEnv - - - - - -#Instance Methods -## assert_cgi_escape_html_preserve_encoding(str, encoding) [](#method-i-assert_cgi_escape_html_preserve_encoding) - -## escape(string) [](#method-i-escape) -URL-encode a string into application/x-www-form-urlencoded. Space characters -(+" "+) are encoded with plus signs (+"+"+) - url_encoded_string = CGI.escape("'Stop!' said Fred") - # => "%27Stop%21%27+said+Fred" - -## escapeElement(string, *elements) [](#method-i-escapeElement) -Escape only the tags of certain HTML elements in `string`. - -Takes an element or elements or array of elements. Each element is specified -by the name of the element, without angle brackets. This matches both the -start and the end tag of that element. The attribute list of the open tag will -also be escaped (for instance, the double-quotes surrounding attribute -values). - - print CGI.escapeElement('
', "A", "IMG") - # "
<A HREF="url"></A>" - - print CGI.escapeElement('
', ["A", "IMG"]) - # "
<A HREF="url"></A>" - -## escapeHTML(string) [](#method-i-escapeHTML) -Escape special characters in HTML, namely '&"<> - CGI.escapeHTML('Usage: foo "bar" ') - # => "Usage: foo "bar" <baz>" - -## escapeURIComponent(string) [](#method-i-escapeURIComponent) -URL-encode a string following RFC 3986 Space characters (+" "+) are encoded -with (+"%20"+) - url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred") - # => "%27Stop%21%27%20said%20Fred" - -## pretty(string, shift" ") [](#method-i-pretty) -Prettify (indent) an HTML string. - -`string` is the HTML string to indent. `shift` is the indentation unit to -use; it defaults to two spaces. - - print CGI.pretty("") - # - # - # - # - - print CGI.pretty("", "\t") - # - # - # - # - -## rfc1123_date(time) [](#method-i-rfc1123_date) -Format a `Time` object as a String using the format specified by RFC 1123. - - CGI.rfc1123_date(Time.now) - # Sat, 01 Jan 2000 00:00:00 GMT - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_cgi_escape() [](#method-i-test_cgi_escape) - -## test_cgi_escapeElement() [](#method-i-test_cgi_escapeElement) - -## test_cgi_escapeHTML() [](#method-i-test_cgi_escapeHTML) - -## test_cgi_escapeURIComponent() [](#method-i-test_cgi_escapeURIComponent) - -## test_cgi_escapeURIComponent_preserve_encoding() [](#method-i-test_cgi_escapeURIComponent_preserve_encoding) - -## test_cgi_escapeURIComponent_with_invalid_byte_sequence() [](#method-i-test_cgi_escapeURIComponent_with_invalid_byte_sequence) - -## test_cgi_escapeURIComponent_with_unreserved_characters() [](#method-i-test_cgi_escapeURIComponent_with_unreserved_characters) - -## test_cgi_escape_html_dont_freeze() [](#method-i-test_cgi_escape_html_dont_freeze) - -## test_cgi_escape_html_duplicated() [](#method-i-test_cgi_escape_html_duplicated) - -## test_cgi_escape_html_large() [](#method-i-test_cgi_escape_html_large) - -## test_cgi_escape_html_preserve_encoding() [](#method-i-test_cgi_escape_html_preserve_encoding) - -## test_cgi_escape_preserve_encoding() [](#method-i-test_cgi_escape_preserve_encoding) - -## test_cgi_escape_uri_component() [](#method-i-test_cgi_escape_uri_component) - -## test_cgi_escape_with_invalid_byte_sequence() [](#method-i-test_cgi_escape_with_invalid_byte_sequence) - -## test_cgi_escape_with_unreserved_characters() [](#method-i-test_cgi_escape_with_unreserved_characters) - -## test_cgi_include_escape() [](#method-i-test_cgi_include_escape) - -## test_cgi_include_escapeHTML() [](#method-i-test_cgi_include_escapeHTML) - -## test_cgi_include_h() [](#method-i-test_cgi_include_h) - -## test_cgi_include_unescape() [](#method-i-test_cgi_include_unescape) - -## test_cgi_include_unescapeHTML() [](#method-i-test_cgi_include_unescapeHTML) - -## test_cgi_pretty() [](#method-i-test_cgi_pretty) - -## test_cgi_unescape() [](#method-i-test_cgi_unescape) - -## test_cgi_unescapeElement() [](#method-i-test_cgi_unescapeElement) - -## test_cgi_unescapeHTML() [](#method-i-test_cgi_unescapeHTML) - -## test_cgi_unescapeHTML_following_invalid_numeric() [](#method-i-test_cgi_unescapeHTML_following_invalid_numeric) - -## test_cgi_unescapeHTML_following_known_first_letter() [](#method-i-test_cgi_unescapeHTML_following_known_first_letter) - -## test_cgi_unescapeHTML_following_number_sign() [](#method-i-test_cgi_unescapeHTML_following_number_sign) - -## test_cgi_unescapeHTML_invalid() [](#method-i-test_cgi_unescapeHTML_invalid) - -## test_cgi_unescapeHTML_uppercasecharacter() [](#method-i-test_cgi_unescapeHTML_uppercasecharacter) - -## test_cgi_unescapeURIComponent() [](#method-i-test_cgi_unescapeURIComponent) - -## test_cgi_unescapeURIComponent_accept_charset() [](#method-i-test_cgi_unescapeURIComponent_accept_charset) - -## test_cgi_unescapeURIComponent_preserve_encoding() [](#method-i-test_cgi_unescapeURIComponent_preserve_encoding) - -## test_cgi_unescape_accept_charset() [](#method-i-test_cgi_unescape_accept_charset) - -## test_cgi_unescape_preserve_encoding() [](#method-i-test_cgi_unescape_preserve_encoding) - -## test_cgi_unescape_uri_component() [](#method-i-test_cgi_unescape_uri_component) - -## unescape(string, encoding@@accept_charset) [](#method-i-unescape) -URL-decode an application/x-www-form-urlencoded string with -encoding(optional). - string = CGI.unescape("%27Stop%21%27+said+Fred") - # => "'Stop!' said Fred" - -## unescapeElement(string, *elements) [](#method-i-unescapeElement) -Undo escaping such as that done by CGI.escapeElement() - - print CGI.unescapeElement( - CGI.escapeHTML('
'), "A", "IMG") - # "<BR>" - - print CGI.unescapeElement( - CGI.escapeHTML('
'), ["A", "IMG"]) - # "<BR>" - -## unescapeHTML(string) [](#method-i-unescapeHTML) -Unescape a string that has been HTML-escaped - CGI.unescapeHTML("Usage: foo "bar" <baz>") - # => "Usage: foo \"bar\" " - -## unescapeURIComponent(string, encoding@@accept_charset) [](#method-i-unescapeURIComponent) -URL-decode a string following RFC 3986 with encoding(optional). - string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred") - # => "'Stop!'+said Fred" - -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/CGIUtilTest/UnescapeHTMLTests.md b/example/ruby/CGIUtilTest/UnescapeHTMLTests.md deleted file mode 100644 index 93acbec..0000000 --- a/example/ruby/CGIUtilTest/UnescapeHTMLTests.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: CGIUtilTest::UnescapeHTMLTests - - - - - -#Instance Methods -## test_cgi_unescapeHTML_following_invalid_numeric() [](#method-i-test_cgi_unescapeHTML_following_invalid_numeric) - -## test_cgi_unescapeHTML_following_known_first_letter() [](#method-i-test_cgi_unescapeHTML_following_known_first_letter) - -## test_cgi_unescapeHTML_following_number_sign() [](#method-i-test_cgi_unescapeHTML_following_number_sign) - diff --git a/example/ruby/CHashDir.md b/example/ruby/CHashDir.md deleted file mode 100644 index b0e3b73..0000000 --- a/example/ruby/CHashDir.md +++ /dev/null @@ -1,2084 +0,0 @@ -# Class: CHashDir -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## add_crl(crl) [](#method-i-add_crl) - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete_crl(crl) [](#method-i-delete_crl) - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## get_certs(namenil) [](#method-i-get_certs) - -## get_crls(namenil) [](#method-i-get_crls) - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## hash_dir(silentfalse) [](#method-i-hash_dir) - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(dirpath) [](#method-i-initialize) - -**@return** [CHashDir] a new instance of CHashDir - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## load_pem_file(filepath) [](#method-i-load_pem_file) - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/CONST1.md b/example/ruby/CONST1.md deleted file mode 100644 index 46fe844..0000000 --- a/example/ruby/CONST1.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CONST1 - - - - - diff --git a/example/ruby/CONST2_.md b/example/ruby/CONST2_.md deleted file mode 100644 index 5803942..0000000 --- a/example/ruby/CONST2_.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CONST2 - - - - - diff --git a/example/ruby/CSAutoloadA.md b/example/ruby/CSAutoloadA.md deleted file mode 100644 index 8314999..0000000 --- a/example/ruby/CSAutoloadA.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CSAutoloadA - - - - - diff --git a/example/ruby/CSAutoloadB.md b/example/ruby/CSAutoloadB.md deleted file mode 100644 index 13a6480..0000000 --- a/example/ruby/CSAutoloadB.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CSAutoloadB - - - - - diff --git a/example/ruby/CSAutoloadC.md b/example/ruby/CSAutoloadC.md deleted file mode 100644 index f6351e8..0000000 --- a/example/ruby/CSAutoloadC.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CSAutoloadC - - - - - diff --git a/example/ruby/CSAutoloadD.md b/example/ruby/CSAutoloadD.md deleted file mode 100644 index 096401a..0000000 --- a/example/ruby/CSAutoloadD.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CSAutoloadD - - - - - diff --git a/example/ruby/CSAutoloadD/InnerModule.md b/example/ruby/CSAutoloadD/InnerModule.md deleted file mode 100644 index 0fcb6d4..0000000 --- a/example/ruby/CSAutoloadD/InnerModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CSAutoloadD::InnerModule - - - - - diff --git a/example/ruby/CS_CONST_AUTOLOAD.md b/example/ruby/CS_CONST_AUTOLOAD.md deleted file mode 100644 index 65d6c3b..0000000 --- a/example/ruby/CS_CONST_AUTOLOAD.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CS_CONST_AUTOLOAD -**Inherits:** Object - - - - - diff --git a/example/ruby/Cal.md b/example/ruby/Cal.md deleted file mode 100644 index 323936c..0000000 --- a/example/ruby/Cal.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Cal -**Inherits:** Object - - - - - -#Instance Methods -## addmon(y, m, n) [](#method-i-addmon) - -## block(xs, n) [](#method-i-block) - -## group(xs, n) [](#method-i-group) - -## initialize() [](#method-i-initialize) - -**@return** [Cal] a new instance of Cal - -## monthly(y, m) [](#method-i-monthly) - -## opt_c(argDEFAULT_START) [](#method-i-opt_c) - -## opt_j(flagfalse) [](#method-i-opt_j) - -## opt_m(flagfalse) [](#method-i-opt_m) - -## opt_t(flagfalse) [](#method-i-opt_t) - -## opt_y(flagfalse) [](#method-i-opt_y) - -## pict(y, m) [](#method-i-pict) - -## print(y, m) [](#method-i-print) - -## set_params() [](#method-i-set_params) - -## stack(xs) [](#method-i-stack) - -## trans(xs) [](#method-i-trans) - -## unlines(xs) [](#method-i-unlines) - -## yearly(y) [](#method-i-yearly) - diff --git a/example/ruby/CaseFolding.md b/example/ruby/CaseFolding.md deleted file mode 100644 index 482b155..0000000 --- a/example/ruby/CaseFolding.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: CaseFolding -**Inherits:** Object - -**Includes:** CaseFolding::Util - - -Usage (for case folding only): - $ wget http://www.unicode.org/Public/UNIDATA/CaseFolding.txt - $ ruby enc-case-folding.rb CaseFolding.txt -o casefold.h - or (for case folding and case mapping): - $ wget http://www.unicode.org/Public/UNIDATA/CaseFolding.txt - $ wget http://www.unicode.org/Public/UNIDATA/UnicodeData.txt - $ wget http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt - $ ruby enc-case-folding.rb -m . -o casefold.h - -using -d or --debug will include UTF-8 characters in comments for debugging - - -# Class Methods -## load(*args ) [](#method-c-load) -# Attributes -## fold[RW] [](#attribute-i-fold) -Returns the value of attribute fold. - -## fold_locale[RW] [](#attribute-i-fold_locale) -Returns the value of attribute fold_locale. - -## unfold[RW] [](#attribute-i-unfold) -Returns the value of attribute unfold. - -## unfold_locale[RW] [](#attribute-i-unfold_locale) -Returns the value of attribute unfold_locale. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## debug!() [](#method-i-debug!) - -## display(dest, mapping_data) [](#method-i-display) - -## load(filename) [](#method-i-load) - -## lookup_hash(key, type, data) [](#method-i-lookup_hash) - -## range_check(code) [](#method-i-range_check) - diff --git a/example/ruby/CaseFolding/Util.md b/example/ruby/CaseFolding/Util.md deleted file mode 100644 index 83ee203..0000000 --- a/example/ruby/CaseFolding/Util.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: CaseFolding::Util - - - - -# Class Methods -## hex_seq(v ) [](#method-c-hex_seq) -## print_table(dest , type , mapping_data , data ) [](#method-c-print_table) -## print_table_1(dest , type , mapping_data , data ) [](#method-c-print_table_1) - diff --git a/example/ruby/CaseInsensitiveRegularExpressionVisitor.md b/example/ruby/CaseInsensitiveRegularExpressionVisitor.md deleted file mode 100644 index 2e11699..0000000 --- a/example/ruby/CaseInsensitiveRegularExpressionVisitor.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: CaseInsensitiveRegularExpressionVisitor -**Inherits:** Prism::Visitor - - - - - -#Instance Methods -## initialize(regexps) [](#method-i-initialize) - -**@return** [CaseInsensitiveRegularExpressionVisitor] a new instance of CaseInsensitiveRegularExpressionVisitor - -## visit_interpolated_regular_expression_node(node) [](#method-i-visit_interpolated_regular_expression_node) - -## visit_regular_expression_node(node) [](#method-i-visit_regular_expression_node) -As the visitor is walking the tree, this method will only be called when it -encounters a regular expression node. We can then call any regular expression --specific APIs. In this case, we are only interested in the regular -expressions that are case-insensitive, which we can retrieve with the -#ignore_case? method. - diff --git a/example/ruby/CaseMapping.md b/example/ruby/CaseMapping.md deleted file mode 100644 index 53bc3a3..0000000 --- a/example/ruby/CaseMapping.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: CaseMapping -**Inherits:** Object - - - - -# Class Methods -## load(*args ) [](#method-c-load) -# Attributes -## filename[RW] [](#attribute-i-filename) -Returns the value of attribute filename. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## debug!() [](#method-i-debug!) - -## flags(from, type, to) [](#method-i-flags) - -## initialize(mapping_directory) [](#method-i-initialize) - -**@return** [CaseMapping] a new instance of CaseMapping - -## map(from) [](#method-i-map) - -## specials_output() [](#method-i-specials_output) - diff --git a/example/ruby/CaseMappingDummy.md b/example/ruby/CaseMappingDummy.md deleted file mode 100644 index aa6b7b8..0000000 --- a/example/ruby/CaseMappingDummy.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: CaseMappingDummy -**Inherits:** Object - - - - - -#Instance Methods -## debug!() [](#method-i-debug!) - -## flags(from, type, to) [](#method-i-flags) - -## titlecase_output() [](#method-i-titlecase_output) - diff --git a/example/ruby/CertStore.md b/example/ruby/CertStore.md deleted file mode 100644 index ebcc486..0000000 --- a/example/ruby/CertStore.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: CertStore -**Inherits:** Object - - - - -# Attributes -## crl[RW] [](#attribute-i-crl) -Returns the value of attribute crl. - -## ee[RW] [](#attribute-i-ee) -Returns the value of attribute ee. - -## other_ca[RW] [](#attribute-i-other_ca) -Returns the value of attribute other_ca. - -## request[RW] [](#attribute-i-request) -Returns the value of attribute request. - -## self_signed_ca[RW] [](#attribute-i-self_signed_ca) -Returns the value of attribute self_signed_ca. - - -#Instance Methods -## generate_cert(filename) [](#method-i-generate_cert) - -## initialize(certs_dir) [](#method-i-initialize) - -**@return** [CertStore] a new instance of CertStore - -## is_ca?(cert) [](#method-i-is_ca?) - -**@return** [Boolean] - -## match_cert(cert1, cert2) [](#method-i-match_cert) - -## scan_certs() [](#method-i-scan_certs) - -## verify(cert) [](#method-i-verify) - diff --git a/example/ruby/ChangeWordTest.md b/example/ruby/ChangeWordTest.md deleted file mode 100644 index 923c72f..0000000 --- a/example/ruby/ChangeWordTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ChangeWordTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_deletion() [](#method-i-test_deletion) - -## test_insertion() [](#method-i-test_insertion) - -## test_substitution() [](#method-i-test_substitution) - -## test_transposition() [](#method-i-test_transposition) - diff --git a/example/ruby/ChatClient.md b/example/ruby/ChatClient.md deleted file mode 100644 index 146b137..0000000 --- a/example/ruby/ChatClient.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: ChatClient -**Inherits:** Object - -**Includes:** DRbUndumped - - - - -# Attributes -## key[RW] [](#attribute-i-key) -Returns the value of attribute key. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [ChatClient] a new instance of ChatClient - -## message(there, str) [](#method-i-message) - diff --git a/example/ruby/ChatEntry.md b/example/ruby/ChatEntry.md deleted file mode 100644 index 4bd8ce0..0000000 --- a/example/ruby/ChatEntry.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: ChatEntry -**Inherits:** Object - -**Includes:** DRbUndumped - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## there[RW] [](#attribute-i-there) -Returns the value of attribute there. - - -#Instance Methods -## initialize(server, there) [](#method-i-initialize) - -**@return** [ChatEntry] a new instance of ChatEntry - -## listen(str) [](#method-i-listen) - -## say(str) [](#method-i-say) - diff --git a/example/ruby/ChatServer.md b/example/ruby/ChatServer.md deleted file mode 100644 index 49f6b4f..0000000 --- a/example/ruby/ChatServer.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ChatServer -**Inherits:** Object - - - - - -#Instance Methods -## add_member(there) [](#method-i-add_member) - -## distribute(there, str) [](#method-i-distribute) - -## initialize() [](#method-i-initialize) - -**@return** [ChatServer] a new instance of ChatServer - diff --git a/example/ruby/Checksum.md b/example/ruby/Checksum.md deleted file mode 100644 index 2608b5b..0000000 --- a/example/ruby/Checksum.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Checksum -**Inherits:** Object - - - - -# Class Methods -## update(argv ) [](#method-c-update) -# Attributes -## source[RW] [](#attribute-i-source) -Returns the value of attribute source. - -## target[RW] [](#attribute-i-target) -Returns the value of attribute target. - - -#Instance Methods -## copy(name) [](#method-i-copy) - -## def_options(opt(require 'optparse'; OptionParser.new)) [](#method-i-def_options) - -## initialize(vpath) [](#method-i-initialize) - -**@return** [Checksum] a new instance of Checksum - -## make(*args) [](#method-i-make) - -## update() [](#method-i-update) - -## update!() [](#method-i-update!) - -## update?() [](#method-i-update?) - -**@return** [Boolean] - diff --git a/example/ruby/Child.md b/example/ruby/Child.md deleted file mode 100644 index 4c526f7..0000000 --- a/example/ruby/Child.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Child -**Inherits:** Parent - - - - - diff --git a/example/ruby/Class.md b/example/ruby/Class.md deleted file mode 100644 index 11319af..0000000 --- a/example/ruby/Class.md +++ /dev/null @@ -1,142 +0,0 @@ -# Class: Class -**Inherits:** Module - - -Extends any Class to include *json_creatable?* method. - - -# Class Methods -## example_class_method_of_class() [](#method-c-example_class_method_of_class) -## example_class_method_of_singleton_class() [](#method-c-example_class_method_of_singleton_class) -## example_instance_method_of_singleton_class() [](#method-c-example_instance_method_of_singleton_class) - -#Instance Methods -## allocate() [](#method-i-allocate) -Allocates space for a new object of *class*'s class and does not call -initialize on the new instance. The returned object must be an instance of -*class*. - - klass = Class.new do - def initialize(*args) - @initialized = true - end - - def initialized? - @initialized || false - end - end - - klass.allocate.initialized? #=> false - -**@overload** [] - -## attached_object() [](#method-i-attached_object) -Returns the object for which the receiver is the singleton class. - -Raises an TypeError if the class is not a singleton class. - - class Foo; end - - Foo.singleton_class.attached_object #=> Foo - Foo.attached_object #=> TypeError: `Foo' is not a singleton class - Foo.new.singleton_class.attached_object #=> # - TrueClass.attached_object #=> TypeError: `TrueClass' is not a singleton class - NilClass.attached_object #=> TypeError: `NilClass' is not a singleton class - -**@overload** [] - -## example_instance_method_of_class() [](#method-i-example_instance_method_of_class) - -## initialize(*args) [](#method-i-initialize) -Creates a new anonymous (unnamed) class with the given superclass (or Object -if no parameter is given). You can give a class a name by assigning the class -object to a constant. - -If a block is given, it is passed the class object, and the block is evaluated -in the context of this class like #class_eval. - - fred = Class.new do - def meth1 - "hello" - end - def meth2 - "bye" - end - end - - a = fred.new #=> #<#:0x100376b98> - a.meth1 #=> "hello" - a.meth2 #=> "bye" - -Assign the class to a constant (name starting uppercase) if you want to treat -it like a regular class. - -**@overload** [] - -**@overload** [] - -## json_creatable?() [](#method-i-json_creatable?) -Returns true if this class can be used to create an instance from a serialised -JSON string. The class has to implement a class method *json_create* that -expects a hash as first parameter. The hash should include the required data. - -**@return** [Boolean] - -## new(*args) [](#method-i-new) -Calls #allocate to create a new object of *class*'s class, then invokes that -object's #initialize method, passing it *args*. This is the method that ends -up getting called whenever an object is constructed using `.new`. - -**@overload** [] - -## subclasses() [](#method-i-subclasses) -Returns an array of classes where the receiver is the direct superclass of the -class, excluding singleton classes. The order of the returned array is not -defined. - - class A; end - class B < A; end - class C < B; end - class D < A; end - - A.subclasses #=> [D, B] - B.subclasses #=> [C] - C.subclasses #=> [] - -Anonymous subclasses (not associated with a constant) are returned, too: - - c = Class.new(A) - A.subclasses # => [#, D, B] - -Note that the parent does not hold references to subclasses and doesn't -prevent them from being garbage collected. This means that the subclass might -disappear when all references to it are dropped: - - # drop the reference to subclass, it can be garbage-collected now - c = nil - - A.subclasses - # It can be - # => [#, D, B] - # ...or just - # => [D, B] - # ...depending on whether garbage collector was run - -**@overload** [] - -## superclass() [](#method-i-superclass) -Returns the superclass of *class*, or `nil`. - - File.superclass #=> IO - IO.superclass #=> Object - Object.superclass #=> BasicObject - class Foo; end - class Bar < Foo; end - Bar.superclass #=> Foo - -Returns nil when the given class does not have a parent class: - - BasicObject.superclass #=> nil - -**@overload** [] - diff --git a/example/ruby/ClassNameCheckTest.md b/example/ruby/ClassNameCheckTest.md deleted file mode 100644 index de723c9..0000000 --- a/example/ruby/ClassNameCheckTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: ClassNameCheckTest -**Inherits:** Test::Unit::TestCase - -**Includes:** DidYouMean::TestHelper - - - - - -#Instance Methods -## assert_correction(expected, array) [](#method-i-assert_correction) - -## test_corrections() [](#method-i-test_corrections) - -## test_corrections_candidates_for_names_in_upper_level_scopes() [](#method-i-test_corrections_candidates_for_names_in_upper_level_scopes) - -## test_corrections_include_case_specific_class_name() [](#method-i-test_corrections_include_case_specific_class_name) - -## test_corrections_include_top_level_class_name() [](#method-i-test_corrections_include_top_level_class_name) - -## test_corrections_should_work_from_within_instance_method() [](#method-i-test_corrections_should_work_from_within_instance_method) - -## test_corrections_should_work_from_within_instance_method_on_nested_class() [](#method-i-test_corrections_should_work_from_within_instance_method_on_nested_class) - -## test_does_not_suggest_user_input() [](#method-i-test_does_not_suggest_user_input) - -## test_names_in_corrections_have_namespaces() [](#method-i-test_names_in_corrections_have_namespaces) - diff --git a/example/ruby/ClassSpecs.md b/example/ruby/ClassSpecs.md deleted file mode 100644 index e2b5410..0000000 --- a/example/ruby/ClassSpecs.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: ClassSpecs - - - - -# Class Methods -## sclass_with_block() [](#method-c-sclass_with_block) -## sclass_with_return() [](#method-c-sclass_with_return) -## string_class_variables(obj ) [](#method-c-string_class_variables) -## string_instance_variables(obj ) [](#method-c-string_instance_variables) - diff --git a/example/ruby/ClassSpecs/A.md b/example/ruby/ClassSpecs/A.md deleted file mode 100644 index 29ea273..0000000 --- a/example/ruby/ClassSpecs/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::A -**Inherits:** Object - - - - - diff --git a/example/ruby/ClassSpecs/B.md b/example/ruby/ClassSpecs/B.md deleted file mode 100644 index c1419d6..0000000 --- a/example/ruby/ClassSpecs/B.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::B -**Inherits:** Object - - - - - diff --git a/example/ruby/ClassSpecs/C.md b/example/ruby/ClassSpecs/C.md deleted file mode 100644 index d0f6fca..0000000 --- a/example/ruby/ClassSpecs/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ClassSpecs::C -**Inherits:** Object - - - - -# Class Methods -## make_class_instance_variable() [](#method-c-make_class_instance_variable) -## make_class_variable() [](#method-c-make_class_variable) - diff --git a/example/ruby/ClassSpecs/Container.md b/example/ruby/ClassSpecs/Container.md deleted file mode 100644 index 344d506..0000000 --- a/example/ruby/ClassSpecs/Container.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::Container -**Inherits:** Object - - - - - diff --git a/example/ruby/ClassSpecs/Container/A.md b/example/ruby/ClassSpecs/Container/A.md deleted file mode 100644 index 3ecc497..0000000 --- a/example/ruby/ClassSpecs/Container/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::Container::A -**Inherits:** Object - - - - - diff --git a/example/ruby/ClassSpecs/Container/B.md b/example/ruby/ClassSpecs/Container/B.md deleted file mode 100644 index 9759b49..0000000 --- a/example/ruby/ClassSpecs/Container/B.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::Container::B -**Inherits:** Object - - - - - diff --git a/example/ruby/ClassSpecs/D.md b/example/ruby/ClassSpecs/D.md deleted file mode 100644 index 2c691ec..0000000 --- a/example/ruby/ClassSpecs/D.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ClassSpecs::D -**Inherits:** Object - - - - - -#Instance Methods -## make_class_variable() [](#method-i-make_class_variable) - diff --git a/example/ruby/ClassSpecs/E.md b/example/ruby/ClassSpecs/E.md deleted file mode 100644 index 593125f..0000000 --- a/example/ruby/ClassSpecs/E.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: ClassSpecs::E -**Inherits:** Object - - - - -# Class Methods -## cmeth() [](#method-c-cmeth) -## smeth() [](#method-c-smeth) - -#Instance Methods -## meth() [](#method-i-meth) - diff --git a/example/ruby/ClassSpecs/F.md b/example/ruby/ClassSpecs/F.md deleted file mode 100644 index 4852d5d..0000000 --- a/example/ruby/ClassSpecs/F.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ClassSpecs::F -**Inherits:** Object - - - - - -#Instance Methods -## another() [](#method-i-another) - -## meth() [](#method-i-meth) - diff --git a/example/ruby/ClassSpecs/G.md b/example/ruby/ClassSpecs/G.md deleted file mode 100644 index fb17acb..0000000 --- a/example/ruby/ClassSpecs/G.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ClassSpecs::G -**Inherits:** Object - - - - - -#Instance Methods -## override() [](#method-i-override) - diff --git a/example/ruby/ClassSpecs/H.md b/example/ruby/ClassSpecs/H.md deleted file mode 100644 index 7c6f621..0000000 --- a/example/ruby/ClassSpecs/H.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ClassSpecs::H -**Inherits:** Object - - - - -# Class Methods -## inherited(sub ) [](#method-c-inherited) -**@private** [] - -## track_inherited() [](#method-c-track_inherited) - diff --git a/example/ruby/ClassSpecs/I.md b/example/ruby/ClassSpecs/I.md deleted file mode 100644 index fea333f..0000000 --- a/example/ruby/ClassSpecs/I.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::I -**Inherits:** Object - - - - - diff --git a/example/ruby/ClassSpecs/I/J.md b/example/ruby/ClassSpecs/I/J.md deleted file mode 100644 index 9470ffa..0000000 --- a/example/ruby/ClassSpecs/I/J.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::I::J -**Inherits:** ClassSpecs::I - - - - - diff --git a/example/ruby/ClassSpecs/K.md b/example/ruby/ClassSpecs/K.md deleted file mode 100644 index c5f705e..0000000 --- a/example/ruby/ClassSpecs/K.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ClassSpecs::K -**Inherits:** ClassSpecs::H - - - - -# Class Methods -## example_class_method() [](#method-c-example_class_method) - -#Instance Methods -## example_instance_method() [](#method-i-example_instance_method) - diff --git a/example/ruby/ClassSpecs/L.md b/example/ruby/ClassSpecs/L.md deleted file mode 100644 index bf11b72..0000000 --- a/example/ruby/ClassSpecs/L.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::L -**Inherits:** Object - - - - - diff --git a/example/ruby/ClassSpecs/M.md b/example/ruby/ClassSpecs/M.md deleted file mode 100644 index 1c1f8ad..0000000 --- a/example/ruby/ClassSpecs/M.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassSpecs::M -**Inherits:** ClassSpecs::L - - - - - diff --git a/example/ruby/ClassVariablesSpec.md b/example/ruby/ClassVariablesSpec.md deleted file mode 100644 index b62f7d2..0000000 --- a/example/ruby/ClassVariablesSpec.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ClassVariablesSpec - - - - - diff --git a/example/ruby/ClassVariablesSpec/ClassA.md b/example/ruby/ClassVariablesSpec/ClassA.md deleted file mode 100644 index c2b6dbd..0000000 --- a/example/ruby/ClassVariablesSpec/ClassA.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ClassVariablesSpec::ClassA -**Inherits:** Object - - - - - -#Instance Methods -## cvar_a() [](#method-i-cvar_a) - -## cvar_a=(val) [](#method-i-cvar_a=) - diff --git a/example/ruby/ClassVariablesSpec/ClassB.md b/example/ruby/ClassVariablesSpec/ClassB.md deleted file mode 100644 index 656e43e..0000000 --- a/example/ruby/ClassVariablesSpec/ClassB.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ClassVariablesSpec::ClassB -**Inherits:** ClassVariablesSpec::ClassA - - - - - diff --git a/example/ruby/ClassVariablesSpec/ClassC.md b/example/ruby/ClassVariablesSpec/ClassC.md deleted file mode 100644 index 7e7fed7..0000000 --- a/example/ruby/ClassVariablesSpec/ClassC.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ClassVariablesSpec::ClassC -**Inherits:** Object - -**Extended by:** ClassVariablesSpec::ModuleM - - - - -# Class Methods -## cvar_c=(val ) [](#method-c-cvar_c=) -## cvar_defined?() [](#method-c-cvar_defined?) -**@return** [Boolean] - -## cvar_m() [](#method-c-cvar_m) -## cvar_m=(val ) [](#method-c-cvar_m=) - diff --git a/example/ruby/ClassVariablesSpec/ModuleM.md b/example/ruby/ClassVariablesSpec/ModuleM.md deleted file mode 100644 index a28ece0..0000000 --- a/example/ruby/ClassVariablesSpec/ModuleM.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: ClassVariablesSpec::ModuleM - - -Extended in ClassC - - - -#Instance Methods -## cvar_m() [](#method-i-cvar_m) - -## cvar_m=(val) [](#method-i-cvar_m=) - diff --git a/example/ruby/ClassVariablesSpec/ModuleN.md b/example/ruby/ClassVariablesSpec/ModuleN.md deleted file mode 100644 index 8655d97..0000000 --- a/example/ruby/ClassVariablesSpec/ModuleN.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: ClassVariablesSpec::ModuleN - - -Extended in ModuleO - - - -#Instance Methods -## cvar_n() [](#method-i-cvar_n) - -## cvar_n=(val) [](#method-i-cvar_n=) - diff --git a/example/ruby/ClassVariablesSpec/ModuleO.md b/example/ruby/ClassVariablesSpec/ModuleO.md deleted file mode 100644 index 210ef53..0000000 --- a/example/ruby/ClassVariablesSpec/ModuleO.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: ClassVariablesSpec::ModuleO - -**Extended by:** ClassVariablesSpec::ModuleN - - - - -# Class Methods -## cvar_n() [](#method-c-cvar_n) -## cvar_n=(val ) [](#method-c-cvar_n=) - diff --git a/example/ruby/Clock.md b/example/ruby/Clock.md deleted file mode 100644 index 5496386..0000000 --- a/example/ruby/Clock.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Clock -**Inherits:** Object - - - - - -#Instance Methods -## initialize(tick) [](#method-i-initialize) - -**@return** [Clock] a new instance of Clock - -## update(h, m, s) [](#method-i-update) - diff --git a/example/ruby/ClosedQueueError.md b/example/ruby/ClosedQueueError.md deleted file mode 100644 index 27d495b..0000000 --- a/example/ruby/ClosedQueueError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: ClosedQueueError -**Inherits:** StopIteration - - -The exception class which will be raised when pushing into a closed Queue. -See Thread::Queue#close and Thread::SizedQueue#close. - - - diff --git a/example/ruby/CodeLoadingSpecs.md b/example/ruby/CodeLoadingSpecs.md deleted file mode 100644 index 49a39e5..0000000 --- a/example/ruby/CodeLoadingSpecs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: CodeLoadingSpecs - - - - -# Class Methods -## preload_rubygems() [](#method-c-preload_rubygems) -## spec_cleanup() [](#method-c-spec_cleanup) -## spec_setup() [](#method-c-spec_setup) - diff --git a/example/ruby/CodeLoadingSpecs/Method.md b/example/ruby/CodeLoadingSpecs/Method.md deleted file mode 100644 index e797462..0000000 --- a/example/ruby/CodeLoadingSpecs/Method.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: CodeLoadingSpecs::Method -**Inherits:** Object - - -The #require instance method is private, so this class enables calling -#require like obj.require(file). This is used to share specs between -Kernel#require and Kernel.require. - - - -#Instance Methods -## load(name, wrapfalse) [](#method-i-load) - -## require(name) [](#method-i-require) - diff --git a/example/ruby/CodingUS_ASCII.md b/example/ruby/CodingUS_ASCII.md deleted file mode 100644 index a338226..0000000 --- a/example/ruby/CodingUS_ASCII.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: CodingUS_ASCII - - - - -# Class Methods -## encoding() [](#method-c-encoding) -## string_literal() [](#method-c-string_literal) - diff --git a/example/ruby/CodingUTF_8.md b/example/ruby/CodingUTF_8.md deleted file mode 100644 index 382d38f..0000000 --- a/example/ruby/CodingUTF_8.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: CodingUTF_8 - - - - -# Class Methods -## encoding() [](#method-c-encoding) -## string_literal() [](#method-c-string_literal) - diff --git a/example/ruby/Colorize.md b/example/ruby/Colorize.md deleted file mode 100644 index 728cb2e..0000000 --- a/example/ruby/Colorize.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Colorize -**Inherits:** Object - - - - - -#Instance Methods -## coloring?() [](#method-i-coloring?) - -**@return** [Boolean] - -## decorate(str, name@color) [](#method-i-decorate) -colorize.decorate(str, name = color_name) - -## initialize(colornil, opts((_, color = color, nil)[0] if Hash === color)) [](#method-i-initialize) -call-seq: - Colorize.new(colorize = nil) - Colorize.new(color: color, colors_file: colors_file) - -**@return** [Colorize] a new instance of Colorize - -## resolve_color(color@color, seen{}, colorsnil) [](#method-i-resolve_color) - diff --git a/example/ruby/CommandSyntaxError.md b/example/ruby/CommandSyntaxError.md deleted file mode 100644 index e732590..0000000 --- a/example/ruby/CommandSyntaxError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: CommandSyntaxError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/CommentStripper.md b/example/ruby/CommentStripper.md deleted file mode 100644 index b83e3a4..0000000 --- a/example/ruby/CommentStripper.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: CommentStripper -**Inherits:** Ripper::Filter - - - - -# Class Methods -## strip(src ) [](#method-c-strip) - -#Instance Methods -## on_comment(token, data) [](#method-i-on_comment) - -## on_default(event, token, data) [](#method-i-on_default) - diff --git a/example/ruby/CompactIndexAPI.md b/example/ruby/CompactIndexAPI.md deleted file mode 100644 index a371d64..0000000 --- a/example/ruby/CompactIndexAPI.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexAPI -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/CompactIndexApiMissing.md b/example/ruby/CompactIndexApiMissing.md deleted file mode 100644 index b00446f..0000000 --- a/example/ruby/CompactIndexApiMissing.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexApiMissing -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexBasicAuthentication.md b/example/ruby/CompactIndexBasicAuthentication.md deleted file mode 100644 index 613882c..0000000 --- a/example/ruby/CompactIndexBasicAuthentication.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexBasicAuthentication -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexChecksumMismatch.md b/example/ruby/CompactIndexChecksumMismatch.md deleted file mode 100644 index 70a8a92..0000000 --- a/example/ruby/CompactIndexChecksumMismatch.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexChecksumMismatch -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexConcurrentDownload.md b/example/ruby/CompactIndexConcurrentDownload.md deleted file mode 100644 index 7dbbb24..0000000 --- a/example/ruby/CompactIndexConcurrentDownload.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexConcurrentDownload -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexCredsDiffHost.md b/example/ruby/CompactIndexCredsDiffHost.md deleted file mode 100644 index b3eaa65..0000000 --- a/example/ruby/CompactIndexCredsDiffHost.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexCredsDiffHost -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexEtagMatch.md b/example/ruby/CompactIndexEtagMatch.md deleted file mode 100644 index 6415902..0000000 --- a/example/ruby/CompactIndexEtagMatch.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexEtagMatch -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexExtra.md b/example/ruby/CompactIndexExtra.md deleted file mode 100644 index ec27fd5..0000000 --- a/example/ruby/CompactIndexExtra.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexExtra -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexExtraAPIMissing.md b/example/ruby/CompactIndexExtraAPIMissing.md deleted file mode 100644 index 1026424..0000000 --- a/example/ruby/CompactIndexExtraAPIMissing.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexExtraAPIMissing -**Inherits:** CompactIndexExtraApi - - - - - diff --git a/example/ruby/CompactIndexExtraApi.md b/example/ruby/CompactIndexExtraApi.md deleted file mode 100644 index dbce6a6..0000000 --- a/example/ruby/CompactIndexExtraApi.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexExtraApi -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexExtraMissing.md b/example/ruby/CompactIndexExtraMissing.md deleted file mode 100644 index 1b6712a..0000000 --- a/example/ruby/CompactIndexExtraMissing.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexExtraMissing -**Inherits:** CompactIndexExtra - - - - - diff --git a/example/ruby/CompactIndexForbidden.md b/example/ruby/CompactIndexForbidden.md deleted file mode 100644 index 8c5e529..0000000 --- a/example/ruby/CompactIndexForbidden.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexForbidden -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexHostRedirect.md b/example/ruby/CompactIndexHostRedirect.md deleted file mode 100644 index 2f1e2f7..0000000 --- a/example/ruby/CompactIndexHostRedirect.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexHostRedirect -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexNoGem.md b/example/ruby/CompactIndexNoGem.md deleted file mode 100644 index e3631c8..0000000 --- a/example/ruby/CompactIndexNoGem.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexNoGem -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexPartialUpdate.md b/example/ruby/CompactIndexPartialUpdate.md deleted file mode 100644 index 416efb8..0000000 --- a/example/ruby/CompactIndexPartialUpdate.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: CompactIndexPartialUpdate -**Inherits:** CompactIndexAPI - - - - - -#Instance Methods -## not_modified?(_checksum) [](#method-i-not_modified?) -Stub the server to never return 304s. This simulates the behaviour of Fastly / -Rubygems ignoring ETag headers. - -**@return** [Boolean] - diff --git a/example/ruby/CompactIndexPartialUpdateBadDigest.md b/example/ruby/CompactIndexPartialUpdateBadDigest.md deleted file mode 100644 index b4f8bdb..0000000 --- a/example/ruby/CompactIndexPartialUpdateBadDigest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: CompactIndexPartialUpdateBadDigest -**Inherits:** CompactIndexAPI - - -The purpose of this Artifice is to test that an incremental response is -invalidated and a second request is issued for the full content. - - - -#Instance Methods -## partial_update_bad_digest() [](#method-i-partial_update_bad_digest) - diff --git a/example/ruby/CompactIndexPartialUpdateNoDigestNotIncremental.md b/example/ruby/CompactIndexPartialUpdateNoDigestNotIncremental.md deleted file mode 100644 index ce9641e..0000000 --- a/example/ruby/CompactIndexPartialUpdateNoDigestNotIncremental.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: CompactIndexPartialUpdateNoDigestNotIncremental -**Inherits:** CompactIndexAPI - - -The purpose of this Artifice is to test that an incremental response is -ignored when the digest is not present to verify that the partial response is -valid. - - - -#Instance Methods -## partial_update_no_digest() [](#method-i-partial_update_no_digest) - diff --git a/example/ruby/CompactIndexPrecompiledBefore.md b/example/ruby/CompactIndexPrecompiledBefore.md deleted file mode 100644 index 8a3de42..0000000 --- a/example/ruby/CompactIndexPrecompiledBefore.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexPrecompiledBefore -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexRangeIgnored.md b/example/ruby/CompactIndexRangeIgnored.md deleted file mode 100644 index fc11871..0000000 --- a/example/ruby/CompactIndexRangeIgnored.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: CompactIndexRangeIgnored -**Inherits:** CompactIndexAPI - - - - - -#Instance Methods -## not_modified?(_checksum) [](#method-i-not_modified?) -Stub the server to not return 304 so that we don't bypass all the logic - -**@return** [Boolean] - diff --git a/example/ruby/CompactIndexRangeNotSatisfiable.md b/example/ruby/CompactIndexRangeNotSatisfiable.md deleted file mode 100644 index 3aeb04c..0000000 --- a/example/ruby/CompactIndexRangeNotSatisfiable.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexRangeNotSatisfiable -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexRateLimited.md b/example/ruby/CompactIndexRateLimited.md deleted file mode 100644 index 6412bce..0000000 --- a/example/ruby/CompactIndexRateLimited.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexRateLimited -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexRateLimited/RequestCounter.md b/example/ruby/CompactIndexRateLimited/RequestCounter.md deleted file mode 100644 index 74869b7..0000000 --- a/example/ruby/CompactIndexRateLimited/RequestCounter.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: CompactIndexRateLimited::RequestCounter -**Inherits:** Object - - - - -# Class Methods -## deq() [](#method-c-deq) -## enq(name ) [](#method-c-enq) -## queue() [](#method-c-queue) -## size() [](#method-c-size) - diff --git a/example/ruby/CompactIndexRedirect.md b/example/ruby/CompactIndexRedirect.md deleted file mode 100644 index 78bb230..0000000 --- a/example/ruby/CompactIndexRedirect.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexRedirect -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexStrictBasicAuthentication.md b/example/ruby/CompactIndexStrictBasicAuthentication.md deleted file mode 100644 index 7efc37b..0000000 --- a/example/ruby/CompactIndexStrictBasicAuthentication.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexStrictBasicAuthentication -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexWrongDependencies.md b/example/ruby/CompactIndexWrongDependencies.md deleted file mode 100644 index eae31d7..0000000 --- a/example/ruby/CompactIndexWrongDependencies.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexWrongDependencies -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/CompactIndexWrongGemChecksum.md b/example/ruby/CompactIndexWrongGemChecksum.md deleted file mode 100644 index 9a5322e..0000000 --- a/example/ruby/CompactIndexWrongGemChecksum.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CompactIndexWrongGemChecksum -**Inherits:** CompactIndexAPI - - - - - diff --git a/example/ruby/Comparable.md b/example/ruby/Comparable.md deleted file mode 100644 index 7e55318..0000000 --- a/example/ruby/Comparable.md +++ /dev/null @@ -1,142 +0,0 @@ -# Module: Comparable - - -The Comparable mixin is used by classes whose objects may be ordered. The -class must define the `<=>` operator, which compares the receiver against -another object, returning a value less than 0, returning 0, or returning a -value greater than 0, depending on whether the receiver is less than, equal -to, or greater than the other object. If the other object is not comparable -then the `<=>` operator should return `nil`. Comparable uses `<=>` to -implement the conventional comparison operators (`<`, `<=`, `==`, `>=`, and -`>`) and the method `between?`. - - class StringSorter - include Comparable - - attr :str - def <=>(other) - str.size <=> other.str.size - end - - def initialize(str) - @str = str - end - - def inspect - @str - end - end - - s1 = StringSorter.new("Z") - s2 = StringSorter.new("YY") - s3 = StringSorter.new("XXX") - s4 = StringSorter.new("WWWW") - s5 = StringSorter.new("VVVVV") - - s1 < s2 #=> true - s4.between?(s1, s3) #=> false - s4.between?(s3, s5) #=> true - [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV] - -## What's Here - -Module Comparable provides these methods, all of which use method `#<=>`: - -* #<: Returns whether `self` is less than the given object. -* #<=: Returns whether `self` is less than or equal to the given object. -* #==: Returns whether `self` is equal to the given object. -* #>: Returns whether `self` is greater than the given object. -* #>=: Returns whether `self` is greater than or equal to the given object. -* #between?: Returns `true` if `self` is between two given objects. -* #clamp: For given objects `min` and `max`, or range `(min..max)`, returns: - - * `min` if `(self <=> min) < 0`. - * `max` if `(self <=> max) > 0`. - * `self` otherwise. - - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/ComparableSpecs.md b/example/ruby/ComparableSpecs.md deleted file mode 100644 index 8c3d108..0000000 --- a/example/ruby/ComparableSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ComparableSpecs - - - - - diff --git a/example/ruby/ComparableSpecs/CompareCallingSuper.md b/example/ruby/ComparableSpecs/CompareCallingSuper.md deleted file mode 100644 index e120428..0000000 --- a/example/ruby/ComparableSpecs/CompareCallingSuper.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: ComparableSpecs::CompareCallingSuper -**Inherits:** Object - -**Includes:** Comparable - - - - -# Attributes -## calls[RW] [](#attribute-i-calls) -Returns the value of attribute calls. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## initialize() [](#method-i-initialize) - -**@return** [CompareCallingSuper] a new instance of CompareCallingSuper - diff --git a/example/ruby/ComparableSpecs/Weird.md b/example/ruby/ComparableSpecs/Weird.md deleted file mode 100644 index 2fe0b8d..0000000 --- a/example/ruby/ComparableSpecs/Weird.md +++ /dev/null @@ -1,93 +0,0 @@ -# Class: ComparableSpecs::Weird -**Inherits:** ComparableSpecs::WithOnlyCompareDefined - -**Includes:** Comparable - - - - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/ComparableSpecs/WithOnlyCompareDefined.md b/example/ruby/ComparableSpecs/WithOnlyCompareDefined.md deleted file mode 100644 index 9146d6a..0000000 --- a/example/ruby/ComparableSpecs/WithOnlyCompareDefined.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ComparableSpecs::WithOnlyCompareDefined -**Inherits:** Object - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - -## initialize(value) [](#method-i-initialize) - -**@return** [WithOnlyCompareDefined] a new instance of WithOnlyCompareDefined - diff --git a/example/ruby/ComparableSpecs/WithoutCompareDefined.md b/example/ruby/ComparableSpecs/WithoutCompareDefined.md deleted file mode 100644 index 271e068..0000000 --- a/example/ruby/ComparableSpecs/WithoutCompareDefined.md +++ /dev/null @@ -1,93 +0,0 @@ -# Class: ComparableSpecs::WithoutCompareDefined -**Inherits:** Object - -**Includes:** Comparable - - - - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/CompileWarning.md b/example/ruby/CompileWarning.md deleted file mode 100644 index b1908d4..0000000 --- a/example/ruby/CompileWarning.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: CompileWarning - - - - -# Class Methods -## reset() [](#method-c-reset) - -#Instance Methods -## warn(message) [](#method-i-warn) - diff --git a/example/ruby/ComplainMatcher.md b/example/ruby/ComplainMatcher.md deleted file mode 100644 index dcd6ea4..0000000 --- a/example/ruby/ComplainMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: ComplainMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(complaintnil, optionsnil) [](#method-i-initialize) - -**@return** [ComplainMatcher] a new instance of ComplainMatcher - -## matches?(proc) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/Complex.md b/example/ruby/Complex.md deleted file mode 100644 index 3c3fc7a..0000000 --- a/example/ruby/Complex.md +++ /dev/null @@ -1,665 +0,0 @@ -# Class: Complex -**Inherits:** Numeric - - -A Complex object houses a pair of values, given when the object is created as -either *rectangular coordinates* or *polar coordinates*. - -## Rectangular Coordinates - -The rectangular coordinates of a complex number are called the *real* and -*imaginary* parts; see [Complex number -definition](https://en.wikipedia.org/wiki/Complex_number#Definition_and_basic_ -operations). - -You can create a Complex object from rectangular coordinates with: - -* A [complex literal](rdoc-ref:syntax/literals.rdoc@Complex+Literals). -* Method Complex.rect. -* Method Kernel#Complex, either with numeric arguments or with certain - string arguments. -* Method String#to_c, for certain strings. - -Note that each of the stored parts may be a an instance one of the classes -Complex, Float, Integer, or Rational; they may be retrieved: - -* Separately, with methods Complex#real and Complex#imaginary. -* Together, with method Complex#rect. - -The corresponding (computed) polar values may be retrieved: - -* Separately, with methods Complex#abs and Complex#arg. -* Together, with method Complex#polar. - -## Polar Coordinates - -The polar coordinates of a complex number are called the *absolute* and -*argument* parts; see [Complex polar -plane](https://en.wikipedia.org/wiki/Complex_number#Polar_form). - -In this class, the argument part in expressed -[radians](https://en.wikipedia.org/wiki/Radian) (not -[degrees](https://en.wikipedia.org/wiki/Degree_(angle))). - -You can create a Complex object from polar coordinates with: - -* Method Complex.polar. -* Method Kernel#Complex, with certain string arguments. -* Method String#to_c, for certain strings. - -Note that each of the stored parts may be a an instance one of the classes -Complex, Float, Integer, or Rational; they may be retrieved: - -* Separately, with methods Complex#abs and Complex#arg. -* Together, with method Complex#polar. - -The corresponding (computed) rectangular values may be retrieved: - -* Separately, with methods Complex#real and Complex#imag. -* Together, with method Complex#rect. - -## What's Here - -First, what's elsewhere: - -* Class Complex inherits (directly or indirectly) from classes - [Numeric](rdoc-ref:Numeric@What-27s+Here) and - [Object](rdoc-ref:Object@What-27s+Here). -* Includes (indirectly) module - [Comparable](rdoc-ref:Comparable@What-27s+Here). - -Here, class Complex has methods for: - -### Creating Complex Objects - -* ::polar: Returns a new Complex object based on given polar coordinates. -* ::rect (and its alias ::rectangular): Returns a new Complex object based - on given rectangular coordinates. - -### Querying - -* #abs (and its alias #magnitude): Returns the absolute value for `self`. -* #arg (and its aliases #angle and #phase): Returns the argument (angle) for - `self` in radians. -* #denominator: Returns the denominator of `self`. -* #finite?: Returns whether both `self.real` and `self.image` are finite. -* #hash: Returns the integer hash value for `self`. -* #imag (and its alias #imaginary): Returns the imaginary value for `self`. -* #infinite?: Returns whether `self.real` or `self.image` is infinite. -* #numerator: Returns the numerator of `self`. -* #polar: Returns the array `[self.abs, self.arg]`. -* #inspect: Returns a string representation of `self`. -* #real: Returns the real value for `self`. -* #real?: Returns `false`; for compatibility with Numeric#real?. -* #rect (and its alias #rectangular): Returns the array `[self.real, - self.imag]`. - -### Comparing - -* #<=>: Returns whether `self` is less than, equal to, or greater than the - given argument. -* #==: Returns whether `self` is equal to the given argument. - -### Converting - -* #rationalize: Returns a Rational object whose value is exactly or - approximately equivalent to that of `self.real`. -* #to_c: Returns `self`. -* #to_d: Returns the value as a BigDecimal object. -* #to_f: Returns the value of `self.real` as a Float, if possible. -* #to_i: Returns the value of `self.real` as an Integer, if possible. -* #to_r: Returns the value of `self.real` as a Rational, if possible. -* #to_s: Returns a string representation of `self`. - -### Performing Complex Arithmetic - -* #*: Returns the product of `self` and the given numeric. -* #**: Returns `self` raised to power of the given numeric. -* #+: Returns the sum of `self` and the given numeric. -* #-: Returns the difference of `self` and the given numeric. -* #-@: Returns the negation of `self`. -* #/: Returns the quotient of `self` and the given numeric. -* #abs2: Returns square of the absolute value (magnitude) for `self`. -* #conj (and its alias #conjugate): Returns the conjugate of `self`. -* #fdiv: Returns `Complex.rect(self.real/numeric, self.imag/numeric)`. - -### Working with JSON - -* ::json_create: Returns a new Complex object, deserialized from the given - serialized hash. -* #as_json: Returns a serialized hash constructed from `self`. -* #to_json: Returns a JSON string representing `self`. - -These methods are provided by the [JSON gem](https://github.com/ruby/json). To -make these methods available: - - require 'json/add/complex' - - -# Class Methods -## json_create(object ) [](#method-c-json_create) -See #as_json. -## polar(*args ) [](#method-c-polar) -Returns a new Complex object formed from the arguments, each of which must be -an instance of Numeric, or an instance of one of its subclasses: Complex, -Float, Integer, Rational. Argument `arg` is given in radians; see [Polar -Coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex.polar(3) # => (3+0i) - Complex.polar(3, 2.0) # => (-1.2484405096414273+2.727892280477045i) - Complex.polar(-3, -2.0) # => (1.2484405096414273+2.727892280477045i) -**@overload** [] - -## rect(*args ) [](#method-c-rect) -Returns a new Complex object formed from the arguments, each of which must be -an instance of Numeric, or an instance of one of its subclasses: Complex, -Float, Integer, Rational; see [Rectangular -Coordinates](rdoc-ref:Complex@Rectangular+Coordinates): - - Complex.rect(3) # => (3+0i) - Complex.rect(3, Math::PI) # => (3+3.141592653589793i) - Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i) - -Complex.rectangular is an alias for Complex.rect. -**@overload** [] - -## rectangular(*args ) [](#method-c-rectangular) -Returns a new Complex object formed from the arguments, each of which must be -an instance of Numeric, or an instance of one of its subclasses: Complex, -Float, Integer, Rational; see [Rectangular -Coordinates](rdoc-ref:Complex@Rectangular+Coordinates): - - Complex.rect(3) # => (3+0i) - Complex.rect(3, Math::PI) # => (3+3.141592653589793i) - Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i) - -Complex.rectangular is an alias for Complex.rect. -**@overload** [] - - -#Instance Methods -## *(other) [](#method-i-*) -Returns the product of `self` and `numeric`: - - Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i) - Complex.rect(900) * Complex.rect(1) # => (900+0i) - Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i) - Complex.rect(9, 8) * 4 # => (36+32i) - Complex.rect(20, 9) * 9.8 # => (196.0+88.2i) - -**@overload** [] - -## **(other) [](#method-i-**) -Returns `self` raised to power `numeric`: - - Complex.rect(0, 1) ** 2 # => (-1+0i) - Complex.rect(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i) - -**@overload** [] - -## +(other) [](#method-i-+) -Returns the sum of `self` and `numeric`: - - Complex.rect(2, 3) + Complex.rect(2, 3) # => (4+6i) - Complex.rect(900) + Complex.rect(1) # => (901+0i) - Complex.rect(-2, 9) + Complex.rect(-9, 2) # => (-11+11i) - Complex.rect(9, 8) + 4 # => (13+8i) - Complex.rect(20, 9) + 9.8 # => (29.8+9i) - -**@overload** [] - -## -(other) [](#method-i--) -Returns the difference of `self` and `numeric`: - - Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i) - Complex.rect(900) - Complex.rect(1) # => (899+0i) - Complex.rect(-2, 9) - Complex.rect(-9, 2) # => (7+7i) - Complex.rect(9, 8) - 4 # => (5+8i) - Complex.rect(20, 9) - 9.8 # => (10.2+9i) - -**@overload** [] - -## -@() [](#method-i--@) -Returns the negation of `self`, which is the negation of each of its parts: - - -Complex.rect(1, 2) # => (-1-2i) - -Complex.rect(-1, -2) # => (1+2i) - -**@overload** [] - -## /(other) [](#method-i-/) -Returns the quotient of `self` and `numeric`: - - Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i) - Complex.rect(900) / Complex.rect(1) # => (900+0i) - Complex.rect(-2, 9) / Complex.rect(-9, 2) # => ((36/85)-(77/85)*i) - Complex.rect(9, 8) / 4 # => ((9/4)+2i) - Complex.rect(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i) - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Returns: - -* `self.real <=> object.real` if both of the following are true: - - * `self.imag == 0`. - * `object.imag == 0`. # Always true if object is numeric but not - complex. - -* `nil` otherwise. - -Examples: - - Complex.rect(2) <=> 3 # => -1 - Complex.rect(2) <=> 2 # => 0 - Complex.rect(2) <=> 1 # => 1 - Complex.rect(2, 1) <=> 1 # => nil # self.imag not zero. - Complex.rect(1) <=> Complex.rect(1, 1) # => nil # object.imag not zero. - Complex.rect(1) <=> 'Foo' # => nil # object.imag not defined. - -**@overload** [] - -## ==(other) [](#method-i-==) -Returns `true` if `self.real == object.real` and `self.imag == object.imag`: - - Complex.rect(2, 3) == Complex.rect(2.0, 3.0) # => true - -**@overload** [] - -## abs() [](#method-i-abs) -Returns the absolute value (magnitude) for `self`; see [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex.polar(-1, 0).abs # => 1.0 - -If `self` was created with [rectangular -coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is -computed, and may be inexact: - - Complex.rectangular(1, 1).abs # => 1.4142135623730951 # The square root of 2. - -**@overload** [] - -## abs2() [](#method-i-abs2) -Returns square of the absolute value (magnitude) for `self`; see [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex.polar(2, 2).abs2 # => 4.0 - -If `self` was created with [rectangular -coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is -computed, and may be inexact: - - Complex.rectangular(1.0/3, 1.0/3).abs2 # => 0.2222222222222222 - -**@overload** [] - -## angle() [](#method-i-angle) -Returns the argument (angle) for `self` in radians; see [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex.polar(3, Math::PI/2).arg # => 1.57079632679489660 - -If `self` was created with [rectangular -coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is -computed, and may be inexact: - - Complex.polar(1, 1.0/3).arg # => 0.33333333333333326 - -**@overload** [] - -## arg() [](#method-i-arg) -Returns the argument (angle) for `self` in radians; see [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex.polar(3, Math::PI/2).arg # => 1.57079632679489660 - -If `self` was created with [rectangular -coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is -computed, and may be inexact: - - Complex.polar(1, 1.0/3).arg # => 0.33333333333333326 - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Complex#as_json` and `Complex.json_create` may be used to serialize -and deserialize a Complex object; see [Marshal](rdoc-ref:Marshal). - -Method `Complex#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/complex' - x = Complex(2).as_json # => {"json_class"=>"Complex", "r"=>2, "i"=>0} - y = Complex(2.0, 4).as_json # => {"json_class"=>"Complex", "r"=>2.0, "i"=>4} - -Method `JSON.create` deserializes such a hash, returning a Complex object: - - Complex.json_create(x) # => (2+0i) - Complex.json_create(y) # => (2.0+4i) - -## coerce(other) [](#method-i-coerce) -:nodoc: - -## conj() [](#method-i-conj) -Returns the conjugate of `self`, `Complex.rect(self.imag, self.real)`: - - Complex.rect(1, 2).conj # => (1-2i) - -**@overload** [] - -## conjugate() [](#method-i-conjugate) -Returns the conjugate of `self`, `Complex.rect(self.imag, self.real)`: - - Complex.rect(1, 2).conj # => (1-2i) - -**@overload** [] - -## denominator() [](#method-i-denominator) -Returns the denominator of `self`, which is the [least common -multiple](https://en.wikipedia.org/wiki/Least_common_multiple) of -`self.real.denominator` and `self.imag.denominator`: - - Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6 - -Note that `n.denominator` of a non-rational numeric is `1`. - -Related: Complex#numerator. - -**@overload** [] - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## fdiv(other) [](#method-i-fdiv) -Returns `Complex.rect(self.real/numeric, self.imag/numeric)`: - - Complex.rect(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i) - -**@overload** [] - -## finite?() [](#method-i-finite?) -Returns `true` if both `self.real.finite?` and `self.imag.finite?` are true, -`false` otherwise: - - Complex.rect(1, 1).finite? # => true - Complex.rect(Float::INFINITY, 0).finite? # => false - -Related: Numeric#finite?, Float#finite?. - -**@overload** [] - -## hash() [](#method-i-hash) -:call-seq: - hash -> integer - -Returns the integer hash value for `self`. - -Two Complex objects created from the same values will have the same hash value -(and will compare using #eql?): - - Complex.rect(1, 2).hash == Complex.rect(1, 2).hash # => true - -## imag() [](#method-i-imag) -Returns the imaginary value for `self`: - - Complex.rect(7).imag # => 0 - Complex.rect(9, -4).imag # => -4 - -If `self` was created with [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is -computed, and may be inexact: - - Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2. - -**@overload** [] - -## imaginary() [](#method-i-imaginary) -Returns the imaginary value for `self`: - - Complex.rect(7).imag # => 0 - Complex.rect(9, -4).imag # => -4 - -If `self` was created with [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is -computed, and may be inexact: - - Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2. - -**@overload** [] - -## infinite?() [](#method-i-infinite?) -Returns `1` if either `self.real.infinite?` or `self.imag.infinite?` is true, -`nil` otherwise: - - Complex.rect(Float::INFINITY, 0).infinite? # => 1 - Complex.rect(1, 1).infinite? # => nil - -Related: Numeric#infinite?, Float#infinite?. - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - Complex.rect(2).inspect # => "(2+0i)" - Complex.rect(-8, 6).inspect # => "(-8+6i)" - Complex.rect(0, Rational(1, 2)).inspect # => "(0+(1/2)*i)" - Complex.rect(0, Float::INFINITY).inspect # => "(0+Infinity*i)" - Complex.rect(Float::NAN, Float::NAN).inspect # => "(NaN+NaN*i)" - -**@overload** [] - -## magnitude() [](#method-i-magnitude) -Returns the absolute value (magnitude) for `self`; see [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex.polar(-1, 0).abs # => 1.0 - -If `self` was created with [rectangular -coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is -computed, and may be inexact: - - Complex.rectangular(1, 1).abs # => 1.4142135623730951 # The square root of 2. - -**@overload** [] - -## numerator() [](#method-i-numerator) -Returns the Complex object created from the numerators of the real and -imaginary parts of `self`, after converting each part to the [lowest common -denominator](https://en.wikipedia.org/wiki/Lowest_common_denominator) of the -two: - - c = Complex.rect(Rational(2, 3), Rational(3, 4)) # => ((2/3)+(3/4)*i) - c.numerator # => (8+9i) - -In this example, the lowest common denominator of the two parts is 12; the two -converted parts may be thought of as Rational(8, 12) and Rational(9, 12), -whose numerators, respectively, are 8 and 9; so the returned value of -`c.numerator` is `Complex.rect(8, 9)`. - -Related: Complex#denominator. - -**@overload** [] - -## phase() [](#method-i-phase) -Returns the argument (angle) for `self` in radians; see [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex.polar(3, Math::PI/2).arg # => 1.57079632679489660 - -If `self` was created with [rectangular -coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is -computed, and may be inexact: - - Complex.polar(1, 1.0/3).arg # => 0.33333333333333326 - -**@overload** [] - -## polar() [](#method-i-polar) -Returns the array `[self.abs, self.arg]`: - - Complex.polar(1, 2).polar # => [1.0, 2.0] - -See [Polar Coordinates](rdoc-ref:Complex@Polar+Coordinates). - -If `self` was created with [rectangular -coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is -computed, and may be inexact: - - Complex.rect(1, 1).polar # => [1.4142135623730951, 0.7853981633974483] - -**@overload** [] - -## quo() [](#method-i-quo) - -## rationalize(*args) [](#method-i-rationalize) -Returns a Rational object whose value is exactly or approximately equivalent -to that of `self.real`. - -With no argument `epsilon` given, returns a Rational object whose value is -exactly equal to that of `self.real.rationalize`: - - Complex.rect(1, 0).rationalize # => (1/1) - Complex.rect(1, Rational(0, 1)).rationalize # => (1/1) - Complex.rect(3.14159, 0).rationalize # => (314159/100000) - -With argument `epsilon` given, returns a Rational object whose value is -exactly or approximately equal to that of `self.real` to the given precision: - - Complex.rect(3.14159, 0).rationalize(0.1) # => (16/5) - Complex.rect(3.14159, 0).rationalize(0.01) # => (22/7) - Complex.rect(3.14159, 0).rationalize(0.001) # => (201/64) - Complex.rect(3.14159, 0).rationalize(0.0001) # => (333/106) - Complex.rect(3.14159, 0).rationalize(0.00001) # => (355/113) - Complex.rect(3.14159, 0).rationalize(0.000001) # => (7433/2366) - Complex.rect(3.14159, 0).rationalize(0.0000001) # => (9208/2931) - Complex.rect(3.14159, 0).rationalize(0.00000001) # => (47460/15107) - Complex.rect(3.14159, 0).rationalize(0.000000001) # => (76149/24239) - Complex.rect(3.14159, 0).rationalize(0.0000000001) # => (314159/100000) - Complex.rect(3.14159, 0).rationalize(0.0) # => (3537115888337719/1125899906842624) - -Related: Complex#to_r. - -**@overload** [] - -## real() [](#method-i-real) -Returns the real value for `self`: - - Complex.rect(7).real # => 7 - Complex.rect(9, -4).real # => 9 - -If `self` was created with [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is -computed, and may be inexact: - - Complex.polar(1, Math::PI/4).real # => 0.7071067811865476 # Square root of 2. - -**@overload** [] - -## real?() [](#method-i-real?) -Returns `false`; for compatibility with Numeric#real?. - -**@overload** [] - -## rect() [](#method-i-rect) -Returns the array `[self.real, self.imag]`: - - Complex.rect(1, 2).rect # => [1, 2] - -See [Rectangular Coordinates](rdoc-ref:Complex@Rectangular+Coordinates). - -If `self` was created with [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is -computed, and may be inexact: - - Complex.polar(1.0, 1.0).rect # => [0.5403023058681398, 0.8414709848078965] - -Complex#rectangular is an alias for Complex#rect. - -**@overload** [] - -## rectangular() [](#method-i-rectangular) -Returns the array `[self.real, self.imag]`: - - Complex.rect(1, 2).rect # => [1, 2] - -See [Rectangular Coordinates](rdoc-ref:Complex@Rectangular+Coordinates). - -If `self` was created with [polar -coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is -computed, and may be inexact: - - Complex.polar(1.0, 1.0).rect # => [0.5403023058681398, 0.8414709848078965] - -Complex#rectangular is an alias for Complex#rect. - -**@overload** [] - -## to_c() [](#method-i-to_c) -Returns `self`. - -**@overload** [] - -## to_f() [](#method-i-to_f) -Returns the value of `self.real` as a Float, if possible: - - Complex.rect(1, 0).to_f # => 1.0 - Complex.rect(1, Rational(0, 1)).to_f # => 1.0 - -Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or -`Rational(0, *n*)`). - -**@overload** [] - -## to_i() [](#method-i-to_i) -Returns the value of `self.real` as an Integer, if possible: - - Complex.rect(1, 0).to_i # => 1 - Complex.rect(1, Rational(0, 1)).to_i # => 1 - -Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or -`Rational(0, *n*)`). - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/complex' - puts Complex(2).to_json - puts Complex(2.0, 4).to_json - -Output: - - {"json_class":"Complex","r":2,"i":0} - {"json_class":"Complex","r":2.0,"i":4} - -## to_r() [](#method-i-to_r) -Returns the value of `self.real` as a Rational, if possible: - - Complex.rect(1, 0).to_r # => (1/1) - Complex.rect(1, Rational(0, 1)).to_r # => (1/1) - Complex.rect(1, 0.0).to_r # => (1/1) - -Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or -`Rational(0, *n*)`) and `self.imag.to_r` is not exactly zero. - -Related: Complex#rationalize. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns a string representation of `self`: - - Complex.rect(2).to_s # => "2+0i" - Complex.rect(-8, 6).to_s # => "-8+6i" - Complex.rect(0, Rational(1, 2)).to_s # => "0+1/2i" - Complex.rect(0, Float::INFINITY).to_s # => "0+Infinity*i" - Complex.rect(Float::NAN, Float::NAN).to_s # => "NaN+NaN*i" - -**@overload** [] - diff --git a/example/ruby/Complex/compatible.md b/example/ruby/Complex/compatible.md deleted file mode 100644 index 2780160..0000000 --- a/example/ruby/Complex/compatible.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Complex::compatible -**Inherits:** Object - - - - - diff --git a/example/ruby/ComplexRational_Test.md b/example/ruby/ComplexRational_Test.md deleted file mode 100644 index a3223ed..0000000 --- a/example/ruby/ComplexRational_Test.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ComplexRational_Test -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_comp_srat() [](#method-i-test_comp_srat) - -## test_rat_srat() [](#method-i-test_rat_srat) - diff --git a/example/ruby/ComplexSub.md b/example/ruby/ComplexSub.md deleted file mode 100644 index 685fbec..0000000 --- a/example/ruby/ComplexSub.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ComplexSub -**Inherits:** Complex - - - - - diff --git a/example/ruby/Complex_Test.md b/example/ruby/Complex_Test.md deleted file mode 100644 index 6fecccb..0000000 --- a/example/ruby/Complex_Test.md +++ /dev/null @@ -1,124 +0,0 @@ -# Class: Complex_Test -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_complex_with_exception(error, *args, message:"") [](#method-i-assert_complex_with_exception) - -## test_Complex_with_exception() [](#method-i-test_Complex_with_exception) - -## test_Complex_with_invalid_exception() [](#method-i-test_Complex_with_invalid_exception) - -## test_add() [](#method-i-test_add) - -## test_add_with_redefining_float_plus() [](#method-i-test_add_with_redefining_float_plus) - -## test_add_with_redefining_int_plus() [](#method-i-test_add_with_redefining_int_plus) - -## test_add_with_redefining_rational_plus() [](#method-i-test_add_with_redefining_rational_plus) - -## test_attr() [](#method-i-test_attr) - -## test_attr2() [](#method-i-test_attr2) - -## test_canonicalize_internal() [](#method-i-test_canonicalize_internal) - -## test_canonicalize_polar() [](#method-i-test_canonicalize_polar) - -## test_cmp() [](#method-i-test_cmp) - -## test_coerce() [](#method-i-test_coerce) - -## test_coerce2() [](#method-i-test_coerce2) - -## test_compsub() [](#method-i-test_compsub) - -## test_conv() [](#method-i-test_conv) - -## test_div() [](#method-i-test_div) - -## test_eqeq() [](#method-i-test_eqeq) - -## test_eql_p() [](#method-i-test_eql_p) - -## test_expt() [](#method-i-test_expt) - -## test_expt_for_special_angle() [](#method-i-test_expt_for_special_angle) - -## test_fdiv() [](#method-i-test_fdiv) - -## test_finite_p() [](#method-i-test_finite_p) - -## test_fixed_bug() [](#method-i-test_fixed_bug) - -## test_freeze() [](#method-i-test_freeze) - -## test_hash() [](#method-i-test_hash) - -## test_infinite_p() [](#method-i-test_infinite_p) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect_to_s_frozen_bug_20337() [](#method-i-test_inspect_to_s_frozen_bug_20337) - -## test_known_bug() [](#method-i-test_known_bug) - -## test_marshal() [](#method-i-test_marshal) - -## test_marshal_compatibility() [](#method-i-test_marshal_compatibility) - -## test_math() [](#method-i-test_math) - -## test_mul() [](#method-i-test_mul) - -## test_mul_with_redefining_float_mult() [](#method-i-test_mul_with_redefining_float_mult) - -## test_mul_with_redefining_int_mult() [](#method-i-test_mul_with_redefining_int_mult) - -## test_mul_with_redefining_rational_mult() [](#method-i-test_mul_with_redefining_rational_mult) - -## test_negate() [](#method-i-test_negate) - -## test_parse() [](#method-i-test_parse) - -## test_polar() [](#method-i-test_polar) - -## test_quo() [](#method-i-test_quo) - -## test_rationalize() [](#method-i-test_rationalize) - -## test_rect() [](#method-i-test_rect) - -## test_respond() [](#method-i-test_respond) - -## test_ruby19() [](#method-i-test_ruby19) - -## test_sub() [](#method-i-test_sub) - -## test_sub_with_redefining_float_minus() [](#method-i-test_sub_with_redefining_float_minus) - -## test_sub_with_redefining_int_minus() [](#method-i-test_sub_with_redefining_int_minus) - -## test_sub_with_redefining_rational_minus() [](#method-i-test_sub_with_redefining_rational_minus) - -## test_supp() [](#method-i-test_supp) - -## test_to_c() [](#method-i-test_to_c) - -## test_to_f() [](#method-i-test_to_f) - -## test_to_i() [](#method-i-test_to_i) - -## test_to_r() [](#method-i-test_to_r) - -## test_to_r_with_float() [](#method-i-test_to_r_with_float) - -## test_to_r_with_numeric_obj() [](#method-i-test_to_r_with_numeric_obj) - -## test_to_s() [](#method-i-test_to_s) - -## test_uplus() [](#method-i-test_uplus) - diff --git a/example/ruby/Complex_Test/ObjectX.md b/example/ruby/Complex_Test/ObjectX.md deleted file mode 100644 index 67545ec..0000000 --- a/example/ruby/Complex_Test/ObjectX.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Complex_Test::ObjectX -**Inherits:** Numeric - - - - - -#Instance Methods -## +(x) [](#method-i-+) - -## coerce(x) [](#method-i-coerce) - -## initialize(realtrue, n1) [](#method-i-initialize) - -**@return** [ObjectX] a new instance of ObjectX - -## real?() [](#method-i-real?) - -**@return** [Boolean] - diff --git a/example/ruby/Complex_Test2.md b/example/ruby/Complex_Test2.md deleted file mode 100644 index 13af4e5..0000000 --- a/example/ruby/Complex_Test2.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Complex_Test2 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_kumi() [](#method-i-test_kumi) - -## test_kumi2() [](#method-i-test_kumi2) - diff --git a/example/ruby/ConflictsGuard.md b/example/ruby/ConflictsGuard.md deleted file mode 100644 index ed541d0..0000000 --- a/example/ruby/ConflictsGuard.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ConflictsGuard -**Inherits:** SpecGuard - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [ConflictsGuard] a new instance of ConflictsGuard - -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/Const.md b/example/ruby/Const.md deleted file mode 100644 index e25e739..0000000 --- a/example/ruby/Const.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Const - - - - - diff --git a/example/ruby/Const2.md b/example/ruby/Const2.md deleted file mode 100644 index 5f8f513..0000000 --- a/example/ruby/Const2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Const2 - - - - - diff --git a/example/ruby/ConstantLeakError.md b/example/ruby/ConstantLeakError.md deleted file mode 100644 index 980f9c8..0000000 --- a/example/ruby/ConstantLeakError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: ConstantLeakError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/ConstantSpecs.md b/example/ruby/ConstantSpecs.md deleted file mode 100644 index 02b7f40..0000000 --- a/example/ruby/ConstantSpecs.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: ConstantSpecs - - - - -# Class Methods -## get_const() [](#method-c-get_const) -Methods - -#Instance Methods -## const10() [](#method-i-const10) - diff --git a/example/ruby/ConstantSpecs/ClassA.md b/example/ruby/ConstantSpecs/ClassA.md deleted file mode 100644 index 85a1fdc..0000000 --- a/example/ruby/ConstantSpecs/ClassA.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: ConstantSpecs::ClassA -**Inherits:** Object - - -The following classes/modules have all the constants set "statically". -Contrast with the classes below where the constants are set as the specs are -run. - - -# Class Methods -## const10() [](#method-c-const10) -## const16() [](#method-c-const16) -## const22() [](#method-c-const22) -## const_missing(const ) [](#method-c-const_missing) -## constx() [](#method-c-constx) - -#Instance Methods -## const10() [](#method-i-const10) - -## constx() [](#method-i-constx) - diff --git a/example/ruby/ConstantSpecs/ClassB.md b/example/ruby/ConstantSpecs/ClassB.md deleted file mode 100644 index ac8099a..0000000 --- a/example/ruby/ConstantSpecs/ClassB.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ConstantSpecs::ClassB -**Inherits:** Object - - -The following classes/modules have the same structure as the ones above but -the constants are set as the specs are run. - - -# Class Methods -## const201() [](#method-c-const201) -## const209() [](#method-c-const209) -## const210() [](#method-c-const210) - -#Instance Methods -## const201() [](#method-i-const201) - diff --git a/example/ruby/ConstantSpecs/ClassC.md b/example/ruby/ConstantSpecs/ClassC.md deleted file mode 100644 index e21450c..0000000 --- a/example/ruby/ConstantSpecs/ClassC.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ConstantSpecs::ClassC -**Inherits:** Object - - - - - diff --git a/example/ruby/ConstantSpecs/ClassC/ClassE.md b/example/ruby/ConstantSpecs/ClassC/ClassE.md deleted file mode 100644 index 321a1ed..0000000 --- a/example/ruby/ConstantSpecs/ClassC/ClassE.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ConstantSpecs::ClassC::ClassE -**Inherits:** Object - - - - - diff --git a/example/ruby/ConstantSpecs/ClassD.md b/example/ruby/ConstantSpecs/ClassD.md deleted file mode 100644 index 4aba0a8..0000000 --- a/example/ruby/ConstantSpecs/ClassD.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ConstantSpecs::ClassD -**Inherits:** ConstantSpecs::ClassC - - - - - diff --git a/example/ruby/ConstantSpecs/ConstSource.md b/example/ruby/ConstantSpecs/ConstSource.md deleted file mode 100644 index ba31d79..0000000 --- a/example/ruby/ConstantSpecs/ConstSource.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ConstantSpecs::ConstSource - - - - - diff --git a/example/ruby/ConstantSpecs/ContainerA.md b/example/ruby/ConstantSpecs/ContainerA.md deleted file mode 100644 index 8da961e..0000000 --- a/example/ruby/ConstantSpecs/ContainerA.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ConstantSpecs::ContainerA -**Inherits:** Object - -**Includes:** ConstantSpecs::ModuleD - - - - -# Class Methods -## const10() [](#method-c-const10) - -#Instance Methods -## const10() [](#method-i-const10) - diff --git a/example/ruby/ConstantSpecs/ContainerA/ChildA.md b/example/ruby/ConstantSpecs/ContainerA/ChildA.md deleted file mode 100644 index 27a3e08..0000000 --- a/example/ruby/ConstantSpecs/ContainerA/ChildA.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: ConstantSpecs::ContainerA::ChildA -**Inherits:** ConstantSpecs::ParentA - -**Extended by:** ConstantSpecs::ModuleH - -**Includes:** ConstantSpecs::ModuleC - - - - -# Class Methods -## const10() [](#method-c-const10) -## const11() [](#method-c-const11) -## const12() [](#method-c-const12) -## const13() [](#method-c-const13) -## const15() [](#method-c-const15) -## const19() [](#method-c-const19) -## const21() [](#method-c-const21) -## const23() [](#method-c-const23) - -#Instance Methods -## const10() [](#method-i-const10) - -## const11() [](#method-i-const11) - -## const12() [](#method-i-const12) - -## const13() [](#method-i-const13) - -## const15() [](#method-i-const15) - diff --git a/example/ruby/ConstantSpecs/ContainerB.md b/example/ruby/ConstantSpecs/ContainerB.md deleted file mode 100644 index 606d901..0000000 --- a/example/ruby/ConstantSpecs/ContainerB.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: ConstantSpecs::ContainerB -**Inherits:** Object - -**Includes:** ConstantSpecs::ModuleG - - - - -# Class Methods -## const201() [](#method-c-const201) - diff --git a/example/ruby/ConstantSpecs/ContainerB/ChildB.md b/example/ruby/ConstantSpecs/ContainerB/ChildB.md deleted file mode 100644 index 03ce89e..0000000 --- a/example/ruby/ConstantSpecs/ContainerB/ChildB.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: ConstantSpecs::ContainerB::ChildB -**Inherits:** ConstantSpecs::ParentB - -**Includes:** ConstantSpecs::ModuleF - - - - -# Class Methods -## const201() [](#method-c-const201) -## const202() [](#method-c-const202) -## const203() [](#method-c-const203) -## const204() [](#method-c-const204) -## const205() [](#method-c-const205) -## const206() [](#method-c-const206) -## const212() [](#method-c-const212) -## const213() [](#method-c-const213) -## const214() [](#method-c-const214) - -#Instance Methods -## const201() [](#method-i-const201) - -## const202() [](#method-i-const202) - -## const203() [](#method-i-const203) - -## const204() [](#method-i-const204) - -## const205() [](#method-i-const205) - -## const213() [](#method-i-const213) - diff --git a/example/ruby/ConstantSpecs/ContainerPrepend.md b/example/ruby/ConstantSpecs/ContainerPrepend.md deleted file mode 100644 index 703b8c6..0000000 --- a/example/ruby/ConstantSpecs/ContainerPrepend.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ConstantSpecs::ContainerPrepend -**Inherits:** Object - -**Includes:** ConstantSpecs::ModuleIncludePrepended - - - - - diff --git a/example/ruby/ConstantSpecs/ModuleA.md b/example/ruby/ConstantSpecs/ModuleA.md deleted file mode 100644 index 0ac79d9..0000000 --- a/example/ruby/ConstantSpecs/ModuleA.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ConstantSpecs::ModuleA - - -Included at toplevel - - - diff --git a/example/ruby/ConstantSpecs/ModuleB.md b/example/ruby/ConstantSpecs/ModuleB.md deleted file mode 100644 index 8931ad0..0000000 --- a/example/ruby/ConstantSpecs/ModuleB.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ConstantSpecs::ModuleB - - -Included in ParentA - - - diff --git a/example/ruby/ConstantSpecs/ModuleC.md b/example/ruby/ConstantSpecs/ModuleC.md deleted file mode 100644 index 510b338..0000000 --- a/example/ruby/ConstantSpecs/ModuleC.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ConstantSpecs::ModuleC - - -Included in ChildA - - - diff --git a/example/ruby/ConstantSpecs/ModuleD.md b/example/ruby/ConstantSpecs/ModuleD.md deleted file mode 100644 index 146c64c..0000000 --- a/example/ruby/ConstantSpecs/ModuleD.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ConstantSpecs::ModuleD - -**Includes:** ConstantSpecs::ModuleM - - -Included in ContainerA - - - diff --git a/example/ruby/ConstantSpecs/ModuleE.md b/example/ruby/ConstantSpecs/ModuleE.md deleted file mode 100644 index ce2f48d..0000000 --- a/example/ruby/ConstantSpecs/ModuleE.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ConstantSpecs::ModuleE - - -Included in ParentB - - - diff --git a/example/ruby/ConstantSpecs/ModuleF.md b/example/ruby/ConstantSpecs/ModuleF.md deleted file mode 100644 index f61bc58..0000000 --- a/example/ruby/ConstantSpecs/ModuleF.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ConstantSpecs::ModuleF - - -Included in ChildB - - - diff --git a/example/ruby/ConstantSpecs/ModuleG.md b/example/ruby/ConstantSpecs/ModuleG.md deleted file mode 100644 index 7a4673a..0000000 --- a/example/ruby/ConstantSpecs/ModuleG.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ConstantSpecs::ModuleG - - -Included in ContainerB - - - diff --git a/example/ruby/ConstantSpecs/ModuleH.md b/example/ruby/ConstantSpecs/ModuleH.md deleted file mode 100644 index 86e3cf2..0000000 --- a/example/ruby/ConstantSpecs/ModuleH.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ConstantSpecs::ModuleH - - -Included in ChildA metaclass - - - diff --git a/example/ruby/ConstantSpecs/ModuleIncludePrepended.md b/example/ruby/ConstantSpecs/ModuleIncludePrepended.md deleted file mode 100644 index cb11084..0000000 --- a/example/ruby/ConstantSpecs/ModuleIncludePrepended.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ConstantSpecs::ModuleIncludePrepended - -**Includes:** ConstantSpecs::ModuleD - - -Included in ContainerA - - - diff --git a/example/ruby/ConstantSpecs/ModuleM.md b/example/ruby/ConstantSpecs/ModuleM.md deleted file mode 100644 index f0070b4..0000000 --- a/example/ruby/ConstantSpecs/ModuleM.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ConstantSpecs::ModuleM - - -Included in ModuleD - - - diff --git a/example/ruby/ConstantSpecs/ParentA.md b/example/ruby/ConstantSpecs/ParentA.md deleted file mode 100644 index c0c1efb..0000000 --- a/example/ruby/ConstantSpecs/ParentA.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: ConstantSpecs::ParentA -**Inherits:** Object - -**Includes:** ConstantSpecs::ModuleB - - - - -# Class Methods -## const10() [](#method-c-const10) -## const16() [](#method-c-const16) -## const22() [](#method-c-const22) -## constx() [](#method-c-constx) - -#Instance Methods -## const10() [](#method-i-const10) - -## constx() [](#method-i-constx) - diff --git a/example/ruby/ConstantSpecs/ParentB.md b/example/ruby/ConstantSpecs/ParentB.md deleted file mode 100644 index f98e3fa..0000000 --- a/example/ruby/ConstantSpecs/ParentB.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ConstantSpecs::ParentB -**Inherits:** Object - -**Includes:** ConstantSpecs::ModuleE - - - - -# Class Methods -## const201() [](#method-c-const201) -## const209() [](#method-c-const209) -## const210() [](#method-c-const210) - -#Instance Methods -## const201() [](#method-i-const201) - diff --git a/example/ruby/ConstantSpecsThree.md b/example/ruby/ConstantSpecsThree.md deleted file mode 100644 index a308a98..0000000 --- a/example/ruby/ConstantSpecsThree.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ConstantSpecsThree - - - - - diff --git a/example/ruby/ConstantSpecsThree/ConstantSpecsTwo.md b/example/ruby/ConstantSpecsThree/ConstantSpecsTwo.md deleted file mode 100644 index 457043c..0000000 --- a/example/ruby/ConstantSpecsThree/ConstantSpecsTwo.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ConstantSpecsThree::ConstantSpecsTwo - - - - - diff --git a/example/ruby/ConstantSpecsTwo.md b/example/ruby/ConstantSpecsTwo.md deleted file mode 100644 index 221c84e..0000000 --- a/example/ruby/ConstantSpecsTwo.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ConstantSpecsTwo - - - - - diff --git a/example/ruby/ConstantUnicodeSpecs.md b/example/ruby/ConstantUnicodeSpecs.md deleted file mode 100644 index 70e5463..0000000 --- a/example/ruby/ConstantUnicodeSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ConstantUnicodeSpecs - - - - - diff --git a/example/ruby/ConstantVisibility.md b/example/ruby/ConstantVisibility.md deleted file mode 100644 index 7fda800..0000000 --- a/example/ruby/ConstantVisibility.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ConstantVisibility - - - - -# Class Methods -## reset_private_constants() [](#method-c-reset_private_constants) - diff --git a/example/ruby/ConstantVisibility/ClassContainer.md b/example/ruby/ConstantVisibility/ClassContainer.md deleted file mode 100644 index 97cd155..0000000 --- a/example/ruby/ConstantVisibility/ClassContainer.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ConstantVisibility::ClassContainer -**Inherits:** Object - - - - - diff --git a/example/ruby/ConstantVisibility/ClassIncludingPrivConstModule.md b/example/ruby/ConstantVisibility/ClassIncludingPrivConstModule.md deleted file mode 100644 index 0e9ade7..0000000 --- a/example/ruby/ConstantVisibility/ClassIncludingPrivConstModule.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ConstantVisibility::ClassIncludingPrivConstModule -**Inherits:** Object - -**Includes:** ConstantVisibility::PrivConstModule - - - - - -#Instance Methods -## defined_from_include() [](#method-i-defined_from_include) - -## private_constant_from_include() [](#method-i-private_constant_from_include) - diff --git a/example/ruby/ConstantVisibility/ModuleContainer.md b/example/ruby/ConstantVisibility/ModuleContainer.md deleted file mode 100644 index 5d2a64c..0000000 --- a/example/ruby/ConstantVisibility/ModuleContainer.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ConstantVisibility::ModuleContainer - - - - - diff --git a/example/ruby/ConstantVisibility/ModuleIncludingPrivConstModule.md b/example/ruby/ConstantVisibility/ModuleIncludingPrivConstModule.md deleted file mode 100644 index 95a3629..0000000 --- a/example/ruby/ConstantVisibility/ModuleIncludingPrivConstModule.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: ConstantVisibility::ModuleIncludingPrivConstModule - -**Includes:** ConstantVisibility::PrivConstModule - - - - -# Class Methods -## private_constant_from_include() [](#method-c-private_constant_from_include) -## private_constant_named_from_include() [](#method-c-private_constant_named_from_include) -## private_constant_self_from_include() [](#method-c-private_constant_self_from_include) - diff --git a/example/ruby/ConstantVisibility/PrivConstClass.md b/example/ruby/ConstantVisibility/PrivConstClass.md deleted file mode 100644 index 6777aa4..0000000 --- a/example/ruby/ConstantVisibility/PrivConstClass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ConstantVisibility::PrivConstClass -**Inherits:** Object - - - - -# Class Methods -## defined_from_self() [](#method-c-defined_from_self) -## private_constant_from_self() [](#method-c-private_constant_from_self) - diff --git a/example/ruby/ConstantVisibility/PrivConstClass/Nested.md b/example/ruby/ConstantVisibility/PrivConstClass/Nested.md deleted file mode 100644 index 436ba75..0000000 --- a/example/ruby/ConstantVisibility/PrivConstClass/Nested.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ConstantVisibility::PrivConstClass::Nested - - - - -# Class Methods -## defined_from_scope() [](#method-c-defined_from_scope) -## private_constant_from_scope() [](#method-c-private_constant_from_scope) - diff --git a/example/ruby/ConstantVisibility/PrivConstClassChild.md b/example/ruby/ConstantVisibility/PrivConstClassChild.md deleted file mode 100644 index 3cb2c3e..0000000 --- a/example/ruby/ConstantVisibility/PrivConstClassChild.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ConstantVisibility::PrivConstClassChild -**Inherits:** ConstantVisibility::PrivConstClass - - - - - -#Instance Methods -## defined_from_subclass() [](#method-i-defined_from_subclass) - -## private_constant_from_subclass() [](#method-i-private_constant_from_subclass) - diff --git a/example/ruby/ConstantVisibility/PrivConstModule.md b/example/ruby/ConstantVisibility/PrivConstModule.md deleted file mode 100644 index 92d2b92..0000000 --- a/example/ruby/ConstantVisibility/PrivConstModule.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ConstantVisibility::PrivConstModule - - - - -# Class Methods -## defined_from_self() [](#method-c-defined_from_self) -## private_constant_from_self() [](#method-c-private_constant_from_self) - diff --git a/example/ruby/ConstantVisibility/PrivConstModule/Nested.md b/example/ruby/ConstantVisibility/PrivConstModule/Nested.md deleted file mode 100644 index 918ed6d..0000000 --- a/example/ruby/ConstantVisibility/PrivConstModule/Nested.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ConstantVisibility::PrivConstModule::Nested - - - - -# Class Methods -## defined_from_scope() [](#method-c-defined_from_scope) -## private_constant_from_scope() [](#method-c-private_constant_from_scope) - diff --git a/example/ruby/ConstantsLeakCheckerAction.md b/example/ruby/ConstantsLeakCheckerAction.md deleted file mode 100644 index d732785..0000000 --- a/example/ruby/ConstantsLeakCheckerAction.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: ConstantsLeakCheckerAction -**Inherits:** Object - - - - - -#Instance Methods -## after(state) [](#method-i-after) - -## before(state) [](#method-i-before) - -## finish() [](#method-i-finish) - -## initialize(save) [](#method-i-initialize) - -**@return** [ConstantsLeakCheckerAction] a new instance of ConstantsLeakCheckerAction - -## register() [](#method-i-register) - -## start() [](#method-i-start) - diff --git a/example/ruby/ConstantsLockFile.md b/example/ruby/ConstantsLockFile.md deleted file mode 100644 index 8f27e69..0000000 --- a/example/ruby/ConstantsLockFile.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: ConstantsLockFile -**Inherits:** Object - - - - -# Class Methods -## dump(ary ) [](#method-c-dump) -## load() [](#method-c-load) -## lock_file() [](#method-c-lock_file) - diff --git a/example/ruby/ContextState.md b/example/ruby/ContextState.md deleted file mode 100644 index 514c7ac..0000000 --- a/example/ruby/ContextState.md +++ /dev/null @@ -1,102 +0,0 @@ -# Class: ContextState -**Inherits:** Object - - -Holds the state of the `describe` block that is being evaluated. Every example -(i.e. `it` block) is evaluated in a context, which may include state set up in -`before :each` or `before :all` blocks. - --- A note on naming: this is named *ContextState* rather than *DescribeState* -because `describe` is the keyword in the DSL for referring to the context in -which an example is evaluated, just as `it` refers to the example itself. ++ - - -# Attributes -## children[RW] [](#attribute-i-children) -Returns the value of attribute children. - -## examples[RW] [](#attribute-i-examples) -Returns the value of attribute examples. - -## parent[RW] [](#attribute-i-parent) -Returns the value of attribute parent. - -## parents[RW] [](#attribute-i-parents) -Returns the value of attribute parents. - -## state[RW] [](#attribute-i-state) -Returns the value of attribute state. - -## to_s[RW] [](#attribute-i-to_s) -Returns the value of attribute to_s. - - -#Instance Methods -## adopt(parent) [](#method-i-adopt) -Adds a nested ContextState in a shared ContextState to a containing -ContextState. - -Normal adoption is from the parent's perspective. But adopt is a good verb and -it's reasonable for the child to adopt the parent as well. In this case, -manipulating state from inside the child avoids needlessly exposing the state -to manipulate it externally in the dup. (See #it_should_behave_like) - -## after(what, &block) [](#method-i-after) -Records after(:each) and after(:all) blocks. - -## before(what, &block) [](#method-i-before) -Records before(:each) and before(:all) blocks. - -## child(child) [](#method-i-child) -Add the ContextState instance `child` to the list of nested describe blocks. - -## describe(&block) [](#method-i-describe) -Evaluates the block and resets the toplevel `ContextState` to #parent. - -## description() [](#method-i-description) -Returns a description string generated from self and all parents - -## filter_examples() [](#method-i-filter_examples) -Removes filtered examples. Returns true if there are examples left to -evaluate. - -## initialize(description, optionsnil) [](#method-i-initialize) - -**@return** [ContextState] a new instance of ContextState - -## initialize_copy(other) [](#method-i-initialize_copy) -Remove caching when a ContextState is dup'd for shared specs. - -## it(desc, &block) [](#method-i-it) -Creates an ExampleState instance for the block and stores it in a list of -examples to evaluate unless the example is filtered. - -## it_should_behave_like(desc) [](#method-i-it_should_behave_like) -Injects the before/after blocks and examples from the shared describe block -into this `ContextState` instance. - -## post(what) [](#method-i-post) -Returns a list of all after(`what`) blocks from self and any parents. The list -is in reverse order. In other words, the blocks defined in inner describes are -in the list before those defined in outer describes, and in a particular -describe block those defined later are in the list before those defined -earlier. - -## pre(what) [](#method-i-pre) -Returns a list of all before(`what`) blocks from self and any parents. - -## process() [](#method-i-process) -Evaluates the examples in a `ContextState`. Invokes the MSpec events for -:enter, :before, :after, :leave. - -## protect(what, blocks, checktrue) [](#method-i-protect) -Evaluates each block in `blocks` using the `MSpec.protect` method so that -exceptions are handled and tallied. Returns true and does NOT evaluate any -blocks if `check` is true and `MSpec.mode?(:pretend)` is true. - -## shared?() [](#method-i-shared?) -Returns true if this is a shared `ContextState`. Essentially, when created -with: describe "Something", :shared => true { ... } - -**@return** [Boolean] - diff --git a/example/ruby/Continuation.md b/example/ruby/Continuation.md deleted file mode 100644 index c7f1062..0000000 --- a/example/ruby/Continuation.md +++ /dev/null @@ -1,97 +0,0 @@ -# Class: Continuation -**Inherits:** Object - - -Continuation objects are generated by Kernel#callcc, after having +require+d -*continuation*. They hold a return address and execution context, allowing a -nonlocal return to the end of the #callcc block from anywhere within a -program. Continuations are somewhat analogous to a structured version of C's -`setjmp/longjmp` (although they contain more state, so you might consider them -closer to threads). - -For instance: - - require "continuation" - arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] - callcc{|cc| $cc = cc} - puts(message = arr.shift) - $cc.call unless message =~ /Max/ - -*produces:* - - Freddie - Herbie - Ron - Max - -Also you can call callcc in other methods: - - require "continuation" - - def g - arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] - cc = callcc { |cc| cc } - puts arr.shift - return cc, arr.size - end - - def f - c, size = g - c.call(c) if size > 1 - end - - f - -This (somewhat contrived) example allows the inner loop to abandon processing -early: - - require "continuation" - callcc {|cont| - for i in 0..4 - print "#{i}: " - for j in i*5...(i+1)*5 - cont.call() if j == 17 - printf "%3d", j - end - end - } - puts - -*produces:* - - 0: 0 1 2 3 4 - 1: 5 6 7 8 9 - 2: 10 11 12 13 14 - 3: 15 16 - - - -#Instance Methods -## [](*args) [](#method-i-[]) -Invokes the continuation. The program continues from the end of the #callcc -block. If no arguments are given, the original #callcc returns `nil`. If one -argument is given, #callcc returns it. Otherwise, an array containing *args* -is returned. - - callcc {|cont| cont.call } #=> nil - callcc {|cont| cont.call 1 } #=> 1 - callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3] - -**@overload** [] - -**@overload** [] - -## call(*args) [](#method-i-call) -Invokes the continuation. The program continues from the end of the #callcc -block. If no arguments are given, the original #callcc returns `nil`. If one -argument is given, #callcc returns it. Otherwise, an array containing *args* -is returned. - - callcc {|cont| cont.call } #=> nil - callcc {|cont| cont.call 1 } #=> 1 - callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/CoreClassSpecs.md b/example/ruby/CoreClassSpecs.md deleted file mode 100644 index f158d84..0000000 --- a/example/ruby/CoreClassSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CoreClassSpecs - - - - - diff --git a/example/ruby/CoreClassSpecs/A.md b/example/ruby/CoreClassSpecs/A.md deleted file mode 100644 index 0723085..0000000 --- a/example/ruby/CoreClassSpecs/A.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: CoreClassSpecs::A -**Inherits:** Object - - - - -# Class Methods -## inherited(klass ) [](#method-c-inherited) -**@private** [] - - diff --git a/example/ruby/CoreClassSpecs/F.md b/example/ruby/CoreClassSpecs/F.md deleted file mode 100644 index 188b376..0000000 --- a/example/ruby/CoreClassSpecs/F.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: CoreClassSpecs::F -**Inherits:** Object - -**Extended by:** CoreClassSpecs::M - - - - -# Class Methods -## inherited(klass ) [](#method-c-inherited) - diff --git a/example/ruby/CoreClassSpecs/H.md b/example/ruby/CoreClassSpecs/H.md deleted file mode 100644 index 52fa48f..0000000 --- a/example/ruby/CoreClassSpecs/H.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: CoreClassSpecs::H -**Inherits:** CoreClassSpecs::A - - - - -# Class Methods -## inherited(klass ) [](#method-c-inherited) -**@private** [] - - diff --git a/example/ruby/CoreClassSpecs/Inherited.md b/example/ruby/CoreClassSpecs/Inherited.md deleted file mode 100644 index 1143dea..0000000 --- a/example/ruby/CoreClassSpecs/Inherited.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CoreClassSpecs::Inherited - - - - - diff --git a/example/ruby/CoreClassSpecs/Inherited/A.md b/example/ruby/CoreClassSpecs/Inherited/A.md deleted file mode 100644 index 72b7b0c..0000000 --- a/example/ruby/CoreClassSpecs/Inherited/A.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: CoreClassSpecs::Inherited::A -**Inherits:** Object - - - - -# Class Methods -## inherited(subclass ) [](#method-c-inherited) -**@private** [] - - diff --git a/example/ruby/CoreClassSpecs/Inherited/B.md b/example/ruby/CoreClassSpecs/Inherited/B.md deleted file mode 100644 index fbfaab9..0000000 --- a/example/ruby/CoreClassSpecs/Inherited/B.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: CoreClassSpecs::Inherited::B -**Inherits:** CoreClassSpecs::Inherited::A - - -reopen - - - diff --git a/example/ruby/CoreClassSpecs/Inherited/C.md b/example/ruby/CoreClassSpecs/Inherited/C.md deleted file mode 100644 index 3abf143..0000000 --- a/example/ruby/CoreClassSpecs/Inherited/C.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CoreClassSpecs::Inherited::C -**Inherits:** CoreClassSpecs::Inherited::B - - - - - diff --git a/example/ruby/CoreClassSpecs/Inherited/D.md b/example/ruby/CoreClassSpecs/Inherited/D.md deleted file mode 100644 index 6992682..0000000 --- a/example/ruby/CoreClassSpecs/Inherited/D.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: CoreClassSpecs::Inherited::D -**Inherits:** Object - - - - -# Class Methods -## inherited(subclass ) [](#method-c-inherited) -**@private** [] - - diff --git a/example/ruby/CoreClassSpecs/M.md b/example/ruby/CoreClassSpecs/M.md deleted file mode 100644 index 7328fc9..0000000 --- a/example/ruby/CoreClassSpecs/M.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: CoreClassSpecs::M - - - - - -#Instance Methods -## inherited(klass) [](#method-i-inherited) - diff --git a/example/ruby/CoreClassSpecs/Record.md b/example/ruby/CoreClassSpecs/Record.md deleted file mode 100644 index 5ec13ce..0000000 --- a/example/ruby/CoreClassSpecs/Record.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: CoreClassSpecs::Record -**Inherits:** Object - - - - - diff --git a/example/ruby/CoreDumpError.md b/example/ruby/CoreDumpError.md deleted file mode 100644 index 9cd531a..0000000 --- a/example/ruby/CoreDumpError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: CoreDumpError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/CoreExtensions.md b/example/ruby/CoreExtensions.md deleted file mode 100644 index 43870cb..0000000 --- a/example/ruby/CoreExtensions.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CoreExtensions - - - - - diff --git a/example/ruby/CoreExtensions/TCPSocketExt.md b/example/ruby/CoreExtensions/TCPSocketExt.md deleted file mode 100644 index a8e01be..0000000 --- a/example/ruby/CoreExtensions/TCPSocketExt.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: CoreExtensions::TCPSocketExt - - - - -# Class Methods -## prepended(base ) [](#method-c-prepended) - diff --git a/example/ruby/CoreExtensions/TCPSocketExt/Initializer.md b/example/ruby/CoreExtensions/TCPSocketExt/Initializer.md deleted file mode 100644 index 88a746d..0000000 --- a/example/ruby/CoreExtensions/TCPSocketExt/Initializer.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: CoreExtensions::TCPSocketExt::Initializer - - - - - -#Instance Methods -## initialize(host, serv, *rest) [](#method-i-initialize) - diff --git a/example/ruby/Coverage.md b/example/ruby/Coverage.md deleted file mode 100644 index 6342208..0000000 --- a/example/ruby/Coverage.md +++ /dev/null @@ -1,85 +0,0 @@ -# Module: Coverage - - - - -# Class Methods -## line_stub(file ) [](#method-c-line_stub) -## peek_result() [](#method-c-peek_result) -Returns a hash that contains filename as key and coverage array as value. This -is the same as `Coverage.result(stop: false, clear: false)`. - - { - "file.rb" => [1, 2, nil], - ... - } -**@overload** [] - -## result(*args ) [](#method-c-result) -Returns a hash that contains filename as key and coverage array as value. If -`clear` is true, it clears the counters to zero. If `stop` is true, it -disables coverage measurement. -**@overload** [] - -## resume() [](#method-c-resume) -Start/resume the coverage measurement. - -Caveat: Currently, only process-global coverage measurement is supported. You -cannot measure per-thread coverage. If your process has multiple thread, using -Coverage.resume/suspend to capture code coverage executed from only a limited -code block, may yield misleading results. -**@overload** [] - -## running?() [](#method-c-running?) -Returns true if coverage stats are currently being collected (after -Coverage.start call, but before Coverage.result call) -**@overload** [] - -## setup(*args ) [](#method-c-setup) -Set up the coverage measurement. - -Note that this method does not start the measurement itself. Use -Coverage.resume to start the measurement. - -You may want to use Coverage.start to setup and then start the measurement. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## start(*args ) [](#method-c-start) -Enables the coverage measurement. See the documentation of Coverage class in -detail. This is equivalent to Coverage.setup and Coverage.resume. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## state() [](#method-c-state) -Returns the state of the coverage measurement. -**@overload** [] - -## supported?(_mode ) [](#method-c-supported?) -Returns true if coverage measurement is supported for the given mode. - -The mode should be one of the following symbols: `:lines`, `:oneshot_lines`, -`:branches`, `:methods`, `:eval`. - -Example: - - Coverage.supported?(:lines) #=> true - Coverage.supported?(:all) #=> false -**@overload** [] - -## suspend() [](#method-c-suspend) -Suspend the coverage measurement. You can use Coverage.resume to restart the -measurement. -**@overload** [] - - diff --git a/example/ruby/CoverageSpecs.md b/example/ruby/CoverageSpecs.md deleted file mode 100644 index 6b9852e..0000000 --- a/example/ruby/CoverageSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: CoverageSpecs - - - - - diff --git a/example/ruby/CrlStore.md b/example/ruby/CrlStore.md deleted file mode 100644 index 6a03c68..0000000 --- a/example/ruby/CrlStore.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: CrlStore -**Inherits:** Object - - - - - -#Instance Methods -## find_crl(cert) [](#method-i-find_crl) - -## initialize(c_store) [](#method-i-initialize) - -**@return** [CrlStore] a new instance of CrlStore - diff --git a/example/ruby/DQEntry.md b/example/ruby/DQEntry.md deleted file mode 100644 index 7201dc5..0000000 --- a/example/ruby/DQEntry.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DQEntry -**Inherits:** Object - - - - - -#Instance Methods -## greeting() [](#method-i-greeting) - -## initialize(name) [](#method-i-initialize) - -**@return** [DQEntry] a new instance of DQEntry - diff --git a/example/ruby/DRb.md b/example/ruby/DRb.md deleted file mode 100644 index 4101f21..0000000 --- a/example/ruby/DRb.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: DRb - - - - - diff --git a/example/ruby/DRb/HTTP0.md b/example/ruby/DRb/HTTP0.md deleted file mode 100644 index 89c8c5a..0000000 --- a/example/ruby/DRb/HTTP0.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: DRb::HTTP0 - - - - -# Class Methods -## open(uri , config ) [](#method-c-open) -## open_server(uri , config ) [](#method-c-open_server) -## uri_option(uri , config ) [](#method-c-uri_option) - diff --git a/example/ruby/DRb/HTTP0/Callback.md b/example/ruby/DRb/HTTP0/Callback.md deleted file mode 100644 index 9e0a53d..0000000 --- a/example/ruby/DRb/HTTP0/Callback.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: DRb::HTTP0::Callback -**Inherits:** WEBrick::HTTPServlet::AbstractServlet - - - - - -#Instance Methods -## close() [](#method-i-close) - -## do_POST(req, res) [](#method-i-do_POST) - -## initialize(config, drb) [](#method-i-initialize) - -**@return** [Callback] a new instance of Callback - -## reply(body) [](#method-i-reply) - -## req_body() [](#method-i-req_body) - diff --git a/example/ruby/DRb/HTTP0/ClientSide.md b/example/ruby/DRb/HTTP0/ClientSide.md deleted file mode 100644 index bdc0559..0000000 --- a/example/ruby/DRb/HTTP0/ClientSide.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: DRb::HTTP0::ClientSide -**Inherits:** Object - - - - - -#Instance Methods -## alive?() [](#method-i-alive?) - -**@return** [Boolean] - -## close() [](#method-i-close) - -## initialize(uri, config) [](#method-i-initialize) - -**@return** [ClientSide] a new instance of ClientSide - -## post(url, data) [](#method-i-post) - -## recv_reply() [](#method-i-recv_reply) - -## send_request(ref, msg_id, *arg, &b) [](#method-i-send_request) - diff --git a/example/ruby/DRb/HTTP0/Server.md b/example/ruby/DRb/HTTP0/Server.md deleted file mode 100644 index 8109a18..0000000 --- a/example/ruby/DRb/HTTP0/Server.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: DRb::HTTP0::Server -**Inherits:** Object - - - - -# Attributes -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - - -#Instance Methods -## accept() [](#method-i-accept) - -## close() [](#method-i-close) - -## initialize(uri, config) [](#method-i-initialize) - -**@return** [Server] a new instance of Server - -## push(callback) [](#method-i-push) - -## setup_webrick(uri) [](#method-i-setup_webrick) - diff --git a/example/ruby/DRb/HTTP0/ServerSide.md b/example/ruby/DRb/HTTP0/ServerSide.md deleted file mode 100644 index 26bb09b..0000000 --- a/example/ruby/DRb/HTTP0/ServerSide.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: DRb::HTTP0::ServerSide -**Inherits:** Object - - - - -# Attributes -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - - -#Instance Methods -## alive?() [](#method-i-alive?) - -**@return** [Boolean] - -## close() [](#method-i-close) - -## initialize(uri, callback, config) [](#method-i-initialize) - -**@return** [ServerSide] a new instance of ServerSide - -## recv_request() [](#method-i-recv_request) - -## send_reply(succ, result) [](#method-i-send_reply) - diff --git a/example/ruby/DRb/HTTP0/StrStream.md b/example/ruby/DRb/HTTP0/StrStream.md deleted file mode 100644 index fcb2ef9..0000000 --- a/example/ruby/DRb/HTTP0/StrStream.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: DRb::HTTP0::StrStream -**Inherits:** Object - - - - -# Attributes -## buf[RW] [](#attribute-i-buf) -Returns the value of attribute buf. - - -#Instance Methods -## initialize(str'') [](#method-i-initialize) - -**@return** [StrStream] a new instance of StrStream - -## read(n) [](#method-i-read) - -## write(s) [](#method-i-write) - diff --git a/example/ruby/DRbEx.md b/example/ruby/DRbEx.md deleted file mode 100644 index 5b81f26..0000000 --- a/example/ruby/DRbEx.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: DRbEx -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## err() [](#method-i-err) - -**@raise** [FooError] - -## hello() [](#method-i-hello) - -## initialize() [](#method-i-initialize) - -**@return** [DRbEx] a new instance of DRbEx - -## sample(a, b, c) [](#method-i-sample) - diff --git a/example/ruby/DRbEx2.md b/example/ruby/DRbEx2.md deleted file mode 100644 index 0d96d57..0000000 --- a/example/ruby/DRbEx2.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DRbEx2 -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## initialize(n) [](#method-i-initialize) - -**@return** [DRbEx2] a new instance of DRbEx2 - -## to_i() [](#method-i-to_i) - diff --git a/example/ruby/DRbEx3.md b/example/ruby/DRbEx3.md deleted file mode 100644 index 7ba5b8d..0000000 --- a/example/ruby/DRbEx3.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DRbEx3 -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## initialize(n) [](#method-i-initialize) - -**@return** [DRbEx3] a new instance of DRbEx3 - -## sample(list) [](#method-i-sample) - diff --git a/example/ruby/DRbEx4.md b/example/ruby/DRbEx4.md deleted file mode 100644 index 8731f84..0000000 --- a/example/ruby/DRbEx4.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DRbEx4 -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## gen() [](#method-i-gen) - -## initialize() [](#method-i-initialize) - -**@return** [DRbEx4] a new instance of DRbEx4 - diff --git a/example/ruby/DRbNamedIdConv.md b/example/ruby/DRbNamedIdConv.md deleted file mode 100644 index fd70353..0000000 --- a/example/ruby/DRbNamedIdConv.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DRbNamedIdConv -**Inherits:** DRb::DRbIdConv - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [DRbNamedIdConv] a new instance of DRbNamedIdConv - -## to_id(obj) [](#method-i-to_id) - -## to_obj(ref) [](#method-i-to_obj) - diff --git a/example/ruby/DRbNamedObject.md b/example/ruby/DRbNamedObject.md deleted file mode 100644 index 5c463a6..0000000 --- a/example/ruby/DRbNamedObject.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: DRbNamedObject - - - - -# Attributes -## drb_name[RW] [](#attribute-i-drb_name) -Returns the value of attribute drb_name. - - diff --git a/example/ruby/DSL.md b/example/ruby/DSL.md deleted file mode 100644 index c5442d0..0000000 --- a/example/ruby/DSL.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: DSL -**Inherits:** Object - - -Simple DSL implementation for Ripper code generation - -input: /*% ripper: stmts_add!(stmts_new!, void_stmt!) %*/ output: - VALUE v1, v2; - v1 = dispatch0(stmts_new); - v2 = dispatch0(void_stmt); - $$ = dispatch2(stmts_add, v1, v2); - -* The code must be a single line. - -* The code is basically Ruby code, even if it appears like in C and the - result will be processed as C. e.g., comments need to be in Ruby style. - - -# Class Methods -## comma_split(str ) [](#method-c-comma_split) -## const_missing(name ) [](#method-c-const_missing) -## line?(line , lineno nil, indent: nil) [](#method-c-line?) -**@return** [Boolean] - -# Attributes -## events[RW] [](#attribute-i-events) -Returns the value of attribute events. - - -#Instance Methods -## add_event(event, args) [](#method-i-add_event) - -## dsl_binding(p"p") [](#method-i-dsl_binding) - -## generate() [](#method-i-generate) - -## initialize(code, options, linenonil, indent:"\t\t\t") [](#method-i-initialize) - -**@return** [DSL] a new instance of DSL - -## method_missing(event, *args) [](#method-i-method_missing) - diff --git a/example/ruby/DSL/Var.md b/example/ruby/DSL/Var.md deleted file mode 100644 index d03a3e3..0000000 --- a/example/ruby/DSL/Var.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: DSL::Var -**Inherits:** Object - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - -## var[RW] [](#attribute-i-var) -Returns the value of attribute var. - - -#Instance Methods -## [](idx) [](#method-i-[]) -Indexing. - - $:1 -> v1=get_value($:1) - $:1[0] -> rb_ary_entry(v1, 0) - $:1[0..1] -> [rb_ary_entry(v1, 0), rb_ary_entry(v1, 1)] - *$:1[0..1] -> rb_ary_entry(v1, 0), rb_ary_entry(v1, 1) - -Splat needs `[range]` because `Var` does not have the length info. - -## initialize(table, arg, &block) [](#method-i-initialize) - -**@return** [Var] a new instance of Var - -## pretty_print_instance_variables() [](#method-i-pretty_print_instance_variables) - diff --git a/example/ruby/DSL/Var/Table.md b/example/ruby/DSL/Var/Table.md deleted file mode 100644 index fa7714c..0000000 --- a/example/ruby/DSL/Var/Table.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: DSL::Var::Table -**Inherits:** Hash - - - - - -#Instance Methods -## add(&block) [](#method-i-add) - -## defined?(name) [](#method-i-defined?) - -**@return** [Boolean] - -## fetch(arg, &block) [](#method-i-fetch) - -## initialize(&block) [](#method-i-initialize) - -**@return** [Table] a new instance of Table - -## new_var() [](#method-i-new_var) - diff --git a/example/ruby/DTrace.md b/example/ruby/DTrace.md deleted file mode 100644 index 88a6265..0000000 --- a/example/ruby/DTrace.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: DTrace - - - - - diff --git a/example/ruby/DTrace/TestArrayCreate.md b/example/ruby/DTrace/TestArrayCreate.md deleted file mode 100644 index ae3585e..0000000 --- a/example/ruby/DTrace/TestArrayCreate.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: DTrace::TestArrayCreate -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## test_lit() [](#method-i-test_lit) - -## test_many_lit() [](#method-i-test_many_lit) - diff --git a/example/ruby/DTrace/TestCMethod.md b/example/ruby/DTrace/TestCMethod.md deleted file mode 100644 index 0f2a775..0000000 --- a/example/ruby/DTrace/TestCMethod.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DTrace::TestCMethod -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## ruby_program() [](#method-i-ruby_program) - -## test_entry() [](#method-i-test_entry) - -## test_exit() [](#method-i-test_exit) - diff --git a/example/ruby/DTrace/TestCase.md b/example/ruby/DTrace/TestCase.md deleted file mode 100644 index 8124ba1..0000000 --- a/example/ruby/DTrace/TestCase.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DTrace::TestCase -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## dtrace2systemtap(d_program) [](#method-i-dtrace2systemtap) -only handles simple cases, use a Hash for d_program if there are more complex -cases - -## trap_probe(d_program, ruby_program) [](#method-i-trap_probe) - -**@yield** [d_path, rb_path, probes] - diff --git a/example/ruby/DTrace/TestFunctionEntry.md b/example/ruby/DTrace/TestFunctionEntry.md deleted file mode 100644 index 9fe2bf5..0000000 --- a/example/ruby/DTrace/TestFunctionEntry.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DTrace::TestFunctionEntry -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## test_function_entry() [](#method-i-test_function_entry) - -## test_function_return() [](#method-i-test_function_return) - -## test_return_from_raise() [](#method-i-test_return_from_raise) - diff --git a/example/ruby/DTrace/TestGC.md b/example/ruby/DTrace/TestGC.md deleted file mode 100644 index 20fe36b..0000000 --- a/example/ruby/DTrace/TestGC.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: DTrace::TestGC -**Inherits:** DTrace::TestCase - - - - - diff --git a/example/ruby/DTrace/TestHashCreate.md b/example/ruby/DTrace/TestHashCreate.md deleted file mode 100644 index 2a92e5e..0000000 --- a/example/ruby/DTrace/TestHashCreate.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DTrace::TestHashCreate -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## test_hash_lit() [](#method-i-test_hash_lit) - -## test_hash_lit_elements() [](#method-i-test_hash_lit_elements) - -## test_hash_lit_elements_string() [](#method-i-test_hash_lit_elements_string) - -## test_hash_new() [](#method-i-test_hash_new) - diff --git a/example/ruby/DTrace/TestLoad.md b/example/ruby/DTrace/TestLoad.md deleted file mode 100644 index d1e0205..0000000 --- a/example/ruby/DTrace/TestLoad.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DTrace::TestLoad -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_load_entry() [](#method-i-test_load_entry) - -## test_load_return() [](#method-i-test_load_return) - diff --git a/example/ruby/DTrace/TestMethodCacheClear.md b/example/ruby/DTrace/TestMethodCacheClear.md deleted file mode 100644 index 939fad3..0000000 --- a/example/ruby/DTrace/TestMethodCacheClear.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: DTrace::TestMethodCacheClear -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## test_method_cache_clear() [](#method-i-test_method_cache_clear) - diff --git a/example/ruby/DTrace/TestObjectCreateStart.md b/example/ruby/DTrace/TestObjectCreateStart.md deleted file mode 100644 index 66b8e76..0000000 --- a/example/ruby/DTrace/TestObjectCreateStart.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: DTrace::TestObjectCreateStart -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## test_object_create_start() [](#method-i-test_object_create_start) - -## test_object_create_start_name() [](#method-i-test_object_create_start_name) - diff --git a/example/ruby/DTrace/TestRaise.md b/example/ruby/DTrace/TestRaise.md deleted file mode 100644 index 1a2b75c..0000000 --- a/example/ruby/DTrace/TestRaise.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: DTrace::TestRaise -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## test_raise() [](#method-i-test_raise) - diff --git a/example/ruby/DTrace/TestRequire.md b/example/ruby/DTrace/TestRequire.md deleted file mode 100644 index 6d7fb75..0000000 --- a/example/ruby/DTrace/TestRequire.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: DTrace::TestRequire -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## test_require_entry() [](#method-i-test_require_entry) - -## test_require_return() [](#method-i-test_require_return) - diff --git a/example/ruby/DTrace/TestSingletonFunctionEntry.md b/example/ruby/DTrace/TestSingletonFunctionEntry.md deleted file mode 100644 index 61d10a6..0000000 --- a/example/ruby/DTrace/TestSingletonFunctionEntry.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DTrace::TestSingletonFunctionEntry -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## ruby_program() [](#method-i-ruby_program) - -## test_entry() [](#method-i-test_entry) - -## test_exit() [](#method-i-test_exit) - diff --git a/example/ruby/DTrace/TestStringProbes.md b/example/ruby/DTrace/TestStringProbes.md deleted file mode 100644 index 90899f0..0000000 --- a/example/ruby/DTrace/TestStringProbes.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: DTrace::TestStringProbes -**Inherits:** DTrace::TestCase - - - - - -#Instance Methods -## test_object_create_start_string_lit() [](#method-i-test_object_create_start_string_lit) - diff --git a/example/ruby/DataSpecs.md b/example/ruby/DataSpecs.md deleted file mode 100644 index db7f3ea..0000000 --- a/example/ruby/DataSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: DataSpecs - - - - - diff --git a/example/ruby/Data_.md b/example/ruby/Data_.md deleted file mode 100644 index 821d070..0000000 --- a/example/ruby/Data_.md +++ /dev/null @@ -1,167 +0,0 @@ -# Class: Data -**Inherits:** Object - - -:nodoc: - - -# Class Methods -## define(*args ) [](#method-c-define) -Defines a new Data class. - - measure = Data.define(:amount, :unit) - #=> # - measure.new(1, 'km') - #=> # - - # It you store the new class in the constant, it will - # affect #inspect and will be more natural to use: - Measure = Data.define(:amount, :unit) - #=> Measure - Measure.new(1, 'km') - #=> # - - Note that member-less \Data is acceptable and might be a useful technique - for defining several homogeneous data classes, like - - class HTTPFetcher - Response = Data.define(:body) - NotFound = Data.define - # ... implementation - end - - Now, different kinds of responses from +HTTPFetcher+ would have consistent - representation: - - # - # - - And are convenient to use in pattern matching: - - case fetcher.get(url) - in HTTPFetcher::Response(body) - # process body variable - in HTTPFetcher::NotFound - # handle not found case - end -**@overload** [] - -## members() [](#method-c-members) - -#Instance Methods -## ==() [](#method-i-==) - -## deconstruct() [](#method-i-deconstruct) - -## deconstruct_keys() [](#method-i-deconstruct_keys) - -## eql?() [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(*args) [](#method-i-initialize) -::[](**kwargs) -> instance - - Constructors for classes defined with ::define accept both positional and - keyword arguments. - - Measure = Data.define(:amount, :unit) - - Measure.new(1, 'km') - #=> # - Measure.new(amount: 1, unit: 'km') - #=> # - - # Alternative shorter initialization with [] - Measure[1, 'km'] - #=> # - Measure[amount: 1, unit: 'km'] - #=> # - - All arguments are mandatory (unlike Struct), and converted to keyword arguments: - - Measure.new(amount: 1) - # in `initialize': missing keyword: :unit (ArgumentError) - - Measure.new(1) - # in `initialize': missing keyword: :unit (ArgumentError) - - Note that Measure#initialize always receives keyword arguments, and that - mandatory arguments are checked in +initialize+, not in +new+. This can be - important for redefining initialize in order to convert arguments or provide - defaults: - - Measure = Data.define(:amount, :unit) do - NONE = Data.define - - def initialize(amount:, unit: NONE.new) - super(amount: Float(amount), unit:) - end - end - - Measure.new('10', 'km') # => # - Measure.new(10_000) # => #> - -**@overload** [] - -**@overload** [] - -## initialize_copy(s) [](#method-i-initialize_copy) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - Measure = Data.define(:amount, :unit) - - distance = Measure[10, 'km'] - - p distance # uses #inspect underneath - # - - puts distance # uses #to_s underneath, same representation - # - -**@overload** [] - -**@overload** [] - -## members() [](#method-i-members) - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## pretty_print_cycle(q) [](#method-i-pretty_print_cycle) -:nodoc: - -## to_h() [](#method-i-to_h) - -## with(*args) [](#method-i-with) -Returns a shallow copy of `self` --- the instance variables of `self` are -copied, but not the objects they reference. - -If the method is supplied any keyword arguments, the copy will be created with -the respective field values updated to use the supplied keyword argument -values. Note that it is an error to supply a keyword that the Data class does -not have as a member. - - Point = Data.define(:x, :y) - - origin = Point.new(x: 0, y: 0) - - up = origin.with(x: 1) - right = origin.with(y: 1) - up_and_right = up.with(y: 1) - - p origin # # - p up # # - p right # # - p up_and_right # # - - out = origin.with(z: 1) # ArgumentError: unknown keyword: :z - some_point = origin.with(1, 2) # ArgumentError: expected keyword arguments, got positional arguments - -**@overload** [] - diff --git a/example/ruby/Date.md b/example/ruby/Date.md deleted file mode 100644 index 433a1b6..0000000 --- a/example/ruby/Date.md +++ /dev/null @@ -1,1327 +0,0 @@ -# Class: Date -**Inherits:** Object - -**Includes:** Comparable - - - - -# Class Methods -## _httpdate(*args ) [](#method-c-_httpdate) -Returns a hash of values parsed from `string`, which should be a valid [HTTP -date format](rdoc-ref:strftime_formatting.rdoc@HTTP+Format): - - d = Date.new(2001, 2, 3) - s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT" - Date._httpdate(s) - # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0} - -Related: Date.httpdate (returns a Date object). -**@overload** [] - -## _iso8601(*args ) [](#method-c-_iso8601) -Returns a hash of values parsed from `string`, which should contain an [ISO -8601 formatted -date](rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications): - - d = Date.new(2001, 2, 3) - s = d.iso8601 # => "2001-02-03" - Date._iso8601(s) # => {:mday=>3, :year=>2001, :mon=>2} - -See argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date.iso8601 (returns a Date object). -**@overload** [] - -## _jisx0301(*args ) [](#method-c-_jisx0301) -Returns a hash of values parsed from `string`, which should be a valid [JIS X -0301 date format](rdoc-ref:strftime_formatting.rdoc@JIS+X+0301+Format): - - d = Date.new(2001, 2, 3) - s = d.jisx0301 # => "H13.02.03" - Date._jisx0301(s) # => {:year=>2001, :mon=>2, :mday=>3} - -See argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date.jisx0301 (returns a Date object). -**@overload** [] - -## _load(s ) [](#method-c-_load) -:nodoc: -## _parse(*args ) [](#method-c-_parse) -**Note**: This method recognizes many forms in `string`, but it is not a -validator. For formats, see ["Specialized Format Strings" in Formats for Dates -and Times](rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings) - -If `string` does not specify a valid date, the result is unpredictable; -consider using Date._strptime instead. - -Returns a hash of values parsed from `string`: - - Date._parse('2001-02-03') # => {:year=>2001, :mon=>2, :mday=>3} - -If `comp` is `true` and the given year is in the range `(0..99)`, the current -century is supplied; otherwise, the year is taken as given: - - Date._parse('01-02-03', true) # => {:year=>2001, :mon=>2, :mday=>3} - Date._parse('01-02-03', false) # => {:year=>1, :mon=>2, :mday=>3} - -See argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date.parse(returns a Date object). -**@overload** [] - -## _rfc2822(*args ) [](#method-c-_rfc2822) -Returns a hash of values parsed from `string`, which should be a valid [RFC -2822 date format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format): - - d = Date.new(2001, 2, 3) - s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000" - Date._rfc2822(s) - # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0} - -See argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date.rfc2822 (returns a Date object). -**@overload** [] - -## _rfc3339(*args ) [](#method-c-_rfc3339) -Returns a hash of values parsed from `string`, which should be a valid [RFC -3339 format](rdoc-ref:strftime_formatting.rdoc@RFC+3339+Format): - - d = Date.new(2001, 2, 3) - s = d.rfc3339 # => "2001-02-03T00:00:00+00:00" - Date._rfc3339(s) - # => {:year=>2001, :mon=>2, :mday=>3, :hour=>0, :min=>0, :sec=>0, :zone=>"+00:00", :offset=>0} - -See argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date.rfc3339 (returns a Date object). -**@overload** [] - -## _rfc822(*args ) [](#method-c-_rfc822) -Returns a hash of values parsed from `string`, which should be a valid [RFC -2822 date format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format): - - d = Date.new(2001, 2, 3) - s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000" - Date._rfc2822(s) - # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0} - -See argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date.rfc2822 (returns a Date object). -**@overload** [] - -## _strptime(*args ) [](#method-c-_strptime) -Returns a hash of values parsed from `string` according to the given `format`: - - Date._strptime('2001-02-03', '%Y-%m-%d') # => {:year=>2001, :mon=>2, :mday=>3} - -For other formats, see [Formats for Dates and -Times](rdoc-ref:strftime_formatting.rdoc). (Unlike Date.strftime, does not -support flags and width.) - -See also [strptime(3)](https://man7.org/linux/man-pages/man3/strptime.3.html). - -Related: Date.strptime (returns a Date object). -**@overload** [] - -## _xmlschema(*args ) [](#method-c-_xmlschema) -Returns a hash of values parsed from `string`, which should be a valid XML -date format: - - d = Date.new(2001, 2, 3) - s = d.xmlschema # => "2001-02-03" - Date._xmlschema(s) # => {:year=>2001, :mon=>2, :mday=>3} - -See argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date.xmlschema (returns a Date object). -**@overload** [] - -## civil(*args ) [](#method-c-civil) -Same as Date.new. -## commercial(*args ) [](#method-c-commercial) -Returns a new Date object constructed from the arguments. - -Argument `cwyear` gives the year, and should be an integer. - -Argument `cweek` gives the index of the week within the year, and should be in -range (1..53) or (-53..-1); in some years, 53 or -53 will be out-of-range; if -negative, counts backward from the end of the year: - - Date.commercial(2022, 1, 1).to_s # => "2022-01-03" - Date.commercial(2022, 52, 1).to_s # => "2022-12-26" - -Argument `cwday` gives the indes of the weekday within the week, and should be -in range (1..7) or (-7..-1); 1 or -7 is Monday; if negative, counts backward -from the end of the week: - - Date.commercial(2022, 1, 1).to_s # => "2022-01-03" - Date.commercial(2022, 1, -7).to_s # => "2022-01-03" - -When `cweek` is 1: - -* If January 1 is a Friday, Saturday, or Sunday, the first week begins in - the week after: - - Date::ABBR_DAYNAMES[Date.new(2023, 1, 1).wday] # => "Sun" - Date.commercial(2023, 1, 1).to_s # => "2023-01-02" - Date.commercial(2023, 1, 7).to_s # => "2023-01-08" - -* Otherwise, the first week is the week of January 1, which may mean some of - the days fall on the year before: - - Date::ABBR_DAYNAMES[Date.new(2020, 1, 1).wday] # => "Wed" - Date.commercial(2020, 1, 1).to_s # => "2019-12-30" - Date.commercial(2020, 1, 7).to_s # => "2020-01-05" - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.jd, Date.new, Date.ordinal. -**@overload** [] - -## gregorian_leap?(y ) [](#method-c-gregorian_leap?) -Returns `true` if the given year is a leap year in the [proleptic Gregorian -calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar), `false` -otherwise: - - Date.gregorian_leap?(2000) # => true - Date.gregorian_leap?(2001) # => false - -Related: Date.julian_leap?. -**@overload** [] - -## httpdate(*args ) [](#method-c-httpdate) -Returns a new Date object with values parsed from `string`, which should be a -valid [HTTP date format](rdoc-ref:strftime_formatting.rdoc@HTTP+Format): - - d = Date.new(2001, 2, 3) - s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT" - Date.httpdate(s) # => # - -See: - -* Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -* Argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date._httpdate (returns a hash). -**@overload** [] - -## iso8601(*args ) [](#method-c-iso8601) -Returns a new Date object with values parsed from `string`, which should -contain an [ISO 8601 formatted -date](rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications): - - d = Date.new(2001, 2, 3) - s = d.iso8601 # => "2001-02-03" - Date.iso8601(s) # => # - -See: - -* Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -* Argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date._iso8601 (returns a hash). -**@overload** [] - -## jd(*args ) [](#method-c-jd) -Returns a new Date object formed from the arguments: - - Date.jd(2451944).to_s # => "2001-02-03" - Date.jd(2451945).to_s # => "2001-02-04" - Date.jd(0).to_s # => "-4712-01-01" - -The returned date is: - -* Gregorian, if the argument is greater than or equal to `start`: - - Date::ITALY # => 2299161 - Date.jd(Date::ITALY).gregorian? # => true - Date.jd(Date::ITALY + 1).gregorian? # => true - -* Julian, otherwise - - Date.jd(Date::ITALY - 1).julian? # => true - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.new. -**@overload** [] - -## jisx0301(*args ) [](#method-c-jisx0301) -Returns a new Date object with values parsed from `string`, which should be a -valid [JIS X 0301 -format](rdoc-ref:strftime_formatting.rdoc@JIS+X+0301+Format): - - d = Date.new(2001, 2, 3) - s = d.jisx0301 # => "H13.02.03" - Date.jisx0301(s) # => # - -For no-era year, legacy format, Heisei is assumed. - - Date.jisx0301('13.02.03') # => # - -See: - -* Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -* Argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date._jisx0301 (returns a hash). -**@overload** [] - -## json_create(object ) [](#method-c-json_create) -See #as_json. -## julian_leap?(y ) [](#method-c-julian_leap?) -Returns `true` if the given year is a leap year in the [proleptic Julian -calendar](https://en.wikipedia.org/wiki/Proleptic_Julian_calendar), `false` -otherwise: - - Date.julian_leap?(1900) # => true - Date.julian_leap?(1901) # => false - -Related: Date.gregorian_leap?. -**@overload** [] - -## leap?(y ) [](#method-c-leap?) -Returns `true` if the given year is a leap year in the [proleptic Gregorian -calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar), `false` -otherwise: - - Date.gregorian_leap?(2000) # => true - Date.gregorian_leap?(2001) # => false - -Related: Date.julian_leap?. -**@overload** [] - -## new!(*args ) [](#method-c-new!) -:nodoc: -## nth_kday(*args ) [](#method-c-nth_kday) -:nodoc: -## ordinal(*args ) [](#method-c-ordinal) -Returns a new Date object formed fom the arguments. - -With no arguments, returns the date for January 1, -4712: - - Date.ordinal.to_s # => "-4712-01-01" - -With argument `year`, returns the date for January 1 of that year: - - Date.ordinal(2001).to_s # => "2001-01-01" - Date.ordinal(-2001).to_s # => "-2001-01-01" - -With positive argument `yday` == `n`, returns the date for the `nth` day of -the given year: - - Date.ordinal(2001, 14).to_s # => "2001-01-14" - -With negative argument `yday`, counts backward from the end of the year: - - Date.ordinal(2001, -14).to_s # => "2001-12-18" - -Raises an exception if `yday` is zero or out of range. - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.jd, Date.new. -**@overload** [] - -## parse(*args ) [](#method-c-parse) -**Note**: This method recognizes many forms in `string`, but it is not a -validator. For formats, see ["Specialized Format Strings" in Formats for Dates -and Times](rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings) If -`string` does not specify a valid date, the result is unpredictable; consider -using Date._strptime instead. - -Returns a new Date object with values parsed from `string`: - - Date.parse('2001-02-03') # => # - Date.parse('20010203') # => # - Date.parse('3rd Feb 2001') # => # - -If `comp` is `true` and the given year is in the range `(0..99)`, the current -century is supplied; otherwise, the year is taken as given: - - Date.parse('01-02-03', true) # => # - Date.parse('01-02-03', false) # => # - -See: - -* Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -* Argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date._parse (returns a hash). -**@overload** [] - -## rfc2822(*args ) [](#method-c-rfc2822) -Returns a new Date object with values parsed from `string`, which should be a -valid [RFC 2822 date -format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format): - - d = Date.new(2001, 2, 3) - s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000" - Date.rfc2822(s) # => # - -See: - -* Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -* Argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date._rfc2822 (returns a hash). -**@overload** [] - -## rfc3339(*args ) [](#method-c-rfc3339) -Returns a new Date object with values parsed from `string`, which should be a -valid [RFC 3339 format](rdoc-ref:strftime_formatting.rdoc@RFC+3339+Format): - - d = Date.new(2001, 2, 3) - s = d.rfc3339 # => "2001-02-03T00:00:00+00:00" - Date.rfc3339(s) # => # - -See: - -* Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -* Argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date._rfc3339 (returns a hash). -**@overload** [] - -## rfc822(*args ) [](#method-c-rfc822) -Returns a new Date object with values parsed from `string`, which should be a -valid [RFC 2822 date -format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format): - - d = Date.new(2001, 2, 3) - s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000" - Date.rfc2822(s) # => # - -See: - -* Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -* Argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date._rfc2822 (returns a hash). -**@overload** [] - -## strptime(*args ) [](#method-c-strptime) -Returns a new Date object with values parsed from `string`, according to the -given `format`: - - Date.strptime('2001-02-03', '%Y-%m-%d') # => # - Date.strptime('03-02-2001', '%d-%m-%Y') # => # - Date.strptime('2001-034', '%Y-%j') # => # - Date.strptime('2001-W05-6', '%G-W%V-%u') # => # - Date.strptime('2001 04 6', '%Y %U %w') # => # - Date.strptime('2001 05 6', '%Y %W %u') # => # - Date.strptime('sat3feb01', '%a%d%b%y') # => # - -For other formats, see [Formats for Dates and -Times](rdoc-ref:strftime_formatting.rdoc). (Unlike Date.strftime, does not -support flags and width.) - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -See also [strptime(3)](https://man7.org/linux/man-pages/man3/strptime.3.html). - -Related: Date._strptime (returns a hash). -**@overload** [] - -## test_all() [](#method-c-test_all) -:nodoc: -## test_civil() [](#method-c-test_civil) -:nodoc: -## test_commercial() [](#method-c-test_commercial) -:nodoc: -## test_nth_kday() [](#method-c-test_nth_kday) -:nodoc: -## test_ordinal() [](#method-c-test_ordinal) -:nodoc: -## test_unit_conv() [](#method-c-test_unit_conv) -:nodoc: -## test_weeknum() [](#method-c-test_weeknum) -:nodoc: -## today(*args ) [](#method-c-today) -Returns a new Date object constructed from the present date: - - Date.today.to_s # => "2022-07-06" - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -**@overload** [] - -## valid_civil?(*args ) [](#method-c-valid_civil?) -Returns `true` if the arguments define a valid ordinal date, `false` -otherwise: - - Date.valid_date?(2001, 2, 3) # => true - Date.valid_date?(2001, 2, 29) # => false - Date.valid_date?(2001, 2, -1) # => true - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.jd, Date.new. -**@overload** [] - -## valid_commercial?(*args ) [](#method-c-valid_commercial?) -Returns `true` if the arguments define a valid commercial date, `false` -otherwise: - - Date.valid_commercial?(2001, 5, 6) # => true - Date.valid_commercial?(2001, 5, 8) # => false - -See Date.commercial. - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.jd, Date.commercial. -**@overload** [] - -## valid_date?(*args ) [](#method-c-valid_date?) -Returns `true` if the arguments define a valid ordinal date, `false` -otherwise: - - Date.valid_date?(2001, 2, 3) # => true - Date.valid_date?(2001, 2, 29) # => false - Date.valid_date?(2001, 2, -1) # => true - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.jd, Date.new. -**@overload** [] - -## valid_jd?(*args ) [](#method-c-valid_jd?) -Implemented for compatibility; returns `true` unless `jd` is invalid (i.e., -not a Numeric). - - Date.valid_jd?(2451944) # => true - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.jd. -**@overload** [] - -## valid_ordinal?(*args ) [](#method-c-valid_ordinal?) -Returns `true` if the arguments define a valid ordinal date, `false` -otherwise: - - Date.valid_ordinal?(2001, 34) # => true - Date.valid_ordinal?(2001, 366) # => false - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.jd, Date.ordinal. -**@overload** [] - -## weeknum(*args ) [](#method-c-weeknum) -:nodoc: -## xmlschema(*args ) [](#method-c-xmlschema) -Returns a new Date object with values parsed from `string`, which should be a -valid XML date format: - - d = Date.new(2001, 2, 3) - s = d.xmlschema # => "2001-02-03" - Date.xmlschema(s) # => # - -See: - -* Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). -* Argument [limit](rdoc-ref:Date@Argument+limit). - -Related: Date._xmlschema (returns a hash). -**@overload** [] - - -#Instance Methods -## +(other) [](#method-i-+) -Returns a date object pointing `other` days after self. The other should be a -numeric value. If the other is a fractional number, assumes its precision is -at most nanosecond. - - Date.new(2001,2,3) + 1 #=> # - DateTime.new(2001,2,3) + Rational(1,2) - - #=> # - DateTime.new(2001,2,3) + Rational(-1,2) - - #=> # - DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd - - #=> # - -**@overload** [] - -## -(other) [](#method-i--) -If the other is a date object, returns a Rational whose value is the -difference between the two dates in days. If the other is a numeric value, -returns a date object pointing `other` days before self. If the other is a -fractional number, assumes its precision is at most nanosecond. - - Date.new(2001,2,3) - 1 #=> # - DateTime.new(2001,2,3) - Rational(1,2) - - #=> # - Date.new(2001,2,3) - Date.new(2001) - - #=> (33/1) - DateTime.new(2001,2,3) - DateTime.new(2001,2,2,12) - - #=> (1/2) - -**@overload** [] - -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <<(other) [](#method-i-<<) -Returns a new Date object representing the date `n` months earlier; `n` should -be a numeric: - - (Date.new(2001, 2, 3) << 1).to_s # => "2001-01-03" - (Date.new(2001, 2, 3) << -2).to_s # => "2001-04-03" - -When the same day does not exist for the new month, the last day of that month -is used instead: - - (Date.new(2001, 3, 31) << 1).to_s # => "2001-02-28" - (Date.new(2001, 3, 31) << -6).to_s # => "2001-09-30" - -This results in the following, possibly unexpected, behaviors: - - d0 = Date.new(2001, 3, 31) - d0 << 2 # => # - d0 << 1 << 1 # => # - - d0 = Date.new(2001, 3, 31) - d1 = d0 << 1 # => # - d2 = d1 << -1 # => # - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Compares `self` and `other`, returning: - -* `-1` if `other` is larger. -* `0` if the two are equal. -* `1` if `other` is smaller. -* `nil` if the two are incomparable. - -Argument `other` may be: - -* Another Date object: - - d = Date.new(2022, 7, 27) # => # - prev_date = d.prev_day # => # - next_date = d.next_day # => # - d <=> next_date # => -1 - d <=> d # => 0 - d <=> prev_date # => 1 - -* A DateTime object: - - d <=> DateTime.new(2022, 7, 26) # => 1 - d <=> DateTime.new(2022, 7, 27) # => 0 - d <=> DateTime.new(2022, 7, 28) # => -1 - -* A numeric (compares `self.ajd` to `other`): - - d <=> 2459788 # => -1 - d <=> 2459787 # => 1 - d <=> 2459786 # => 1 - d <=> d.ajd # => 0 - -* Any other object: - - d <=> Object.new # => nil - -**@overload** [] - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## ===(other) [](#method-i-===) -Returns `true` if `self` and `other` represent the same date, `false` if not, -`nil` if the two are not comparable. - -Argument `other` may be: - -* Another Date object: - - d = Date.new(2022, 7, 27) # => # - prev_date = d.prev_day # => # - next_date = d.next_day # => # - d === prev_date # => false - d === d # => true - d === next_date # => false - -* A DateTime object: - - d === DateTime.new(2022, 7, 26) # => false - d === DateTime.new(2022, 7, 27) # => true - d === DateTime.new(2022, 7, 28) # => false - -* A numeric (compares `self.jd` to `other`): - - d === 2459788 # => true - d === 2459787 # => false - d === 2459786 # => false - d === d.jd # => true - -* An object not comparable: - - d === Object.new # => nil - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## >>(other) [](#method-i->>) -Returns a new Date object representing the date `n` months later; `n` should -be a numeric: - - (Date.new(2001, 2, 3) >> 1).to_s # => "2001-03-03" - (Date.new(2001, 2, 3) >> -2).to_s # => "2000-12-03" - -When the same day does not exist for the new month, the last day of that month -is used instead: - - (Date.new(2001, 1, 31) >> 1).to_s # => "2001-02-28" - (Date.new(2001, 1, 31) >> -4).to_s # => "2000-09-30" - -This results in the following, possibly unexpected, behaviors: - - d0 = Date.new(2001, 1, 31) - d1 = d0 >> 1 # => # - d2 = d1 >> 1 # => # - - d0 = Date.new(2001, 1, 31) - d1 = d0 >> 1 # => # - d2 = d1 >> -1 # => # - -**@overload** [] - -## ajd() [](#method-i-ajd) -Returns the astronomical Julian day number. This is a fractional number, -which is not adjusted by the offset. - - DateTime.new(2001,2,3,4,5,6,'+7').ajd #=> (11769328217/4800) - DateTime.new(2001,2,2,14,5,6,'-7').ajd #=> (11769328217/4800) - -**@overload** [] - -## amjd() [](#method-i-amjd) -Returns the astronomical modified Julian day number. This is a fractional -number, which is not adjusted by the offset. - - DateTime.new(2001,2,3,4,5,6,'+7').amjd #=> (249325817/4800) - DateTime.new(2001,2,2,14,5,6,'-7').amjd #=> (249325817/4800) - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Date#as_json` and `Date.json_create` may be used to serialize and -deserialize a Date object; see [Marshal](rdoc-ref:Marshal). - -Method `Date#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/date' - x = Date.today.as_json - # => {"json_class"=>"Date", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0} - -Method `JSON.create` deserializes such a hash, returning a Date object: - - Date.json_create(x) - # => # - -## asctime() [](#method-i-asctime) -Equivalent to #strftime with argument `'%a %b %e %T %Y'` (or its [shorthand -form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers) -`'%c'`): - - Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001" - -See [asctime](https://linux.die.net/man/3/asctime). - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## ctime() [](#method-i-ctime) -Equivalent to #strftime with argument `'%a %b %e %T %Y'` (or its [shorthand -form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers) -`'%c'`): - - Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001" - -See [asctime](https://linux.die.net/man/3/asctime). - -**@overload** [] - -## cwday() [](#method-i-cwday) -Returns the commercial-date weekday index for `self` (see Date.commercial); 1 -is Monday: - - Date.new(2001, 2, 3).cwday # => 6 - -**@overload** [] - -## cweek() [](#method-i-cweek) -Returns commercial-date week index for `self` (see Date.commercial): - - Date.new(2001, 2, 3).cweek # => 5 - -**@overload** [] - -## cwyear() [](#method-i-cwyear) -Returns commercial-date year for `self` (see Date.commercial): - - Date.new(2001, 2, 3).cwyear # => 2001 - Date.new(2000, 1, 1).cwyear # => 1999 - -**@overload** [] - -## day() [](#method-i-day) -Returns the day of the month in range (1..31): - - Date.new(2001, 2, 3).mday # => 3 - -**@overload** [] - -## day_fraction() [](#method-i-day_fraction) -Returns the fractional part of the day in range (Rational(0, 1)...Rational(1, -1)): - - DateTime.new(2001,2,3,12).day_fraction # => (1/2) - -**@overload** [] - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Returns a hash of the name/value pairs, to use in pattern matching. Possible -keys are: `:year`, `:month`, `:day`, `:wday`, `:yday`. - -Possible usages: - - d = Date.new(2022, 10, 5) - - if d in wday: 3, day: ..7 # uses deconstruct_keys underneath - puts "first Wednesday of the month" - end - #=> prints "first Wednesday of the month" - - case d - in year: ...2022 - puts "too old" - in month: ..9 - puts "quarter 1-3" - in wday: 1..5, month: - puts "working day in month #{month}" - end - #=> prints "working day in month 10" - -Note that deconstruction by pattern can also be combined with class check: - - if d in Date(wday: 3, day: ..7) - puts "first Wednesday of the month" - end - -**@overload** [] - -## downto(min) [](#method-i-downto) -Equivalent to #step with arguments `min` and `-1`. - -**@overload** [] - -## england() [](#method-i-england) -Equivalent to Date#new_start with argument Date::ENGLAND. - -**@overload** [] - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## fill() [](#method-i-fill) -:nodoc: - -## friday?() [](#method-i-friday?) -Returns `true` if `self` is a Friday, `false` otherwise. - -**@overload** [] - -## gregorian() [](#method-i-gregorian) -Equivalent to Date#new_start with argument Date::GREGORIAN. - -**@overload** [] - -## gregorian?() [](#method-i-gregorian?) -Returns `true` if the date is on or after the date of calendar reform, `false` -otherwise: - - Date.new(1582, 10, 15).gregorian? # => true - (Date.new(1582, 10, 15) - 1).gregorian? # => false - -**@overload** [] - -## hash() [](#method-i-hash) -:nodoc: - -## httpdate() [](#method-i-httpdate) -Equivalent to #strftime with argument `'%a, %d %b %Y %T GMT'`; see [Formats -for Dates and Times](rdoc-ref:strftime_formatting.rdoc): - - Date.new(2001, 2, 3).httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT" - -**@overload** [] - -## infinite?() [](#method-i-infinite?) -call-seq: - infinite? -> false - -Returns `false` - -**@return** [Boolean] - -## initialize(*args) [](#method-i-initialize) -Returns a new Date object constructed from the given arguments: - - Date.new(2022).to_s # => "2022-01-01" - Date.new(2022, 2).to_s # => "2022-02-01" - Date.new(2022, 2, 4).to_s # => "2022-02-04" - -Argument `month` should be in range (1..12) or range (-12..-1); when the -argument is negative, counts backward from the end of the year: - - Date.new(2022, -11, 4).to_s # => "2022-02-04" - -Argument `mday` should be in range (1..n) or range (-n..-1) where `n` is the -number of days in the month; when the argument is negative, counts backward -from the end of the month. - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -Related: Date.jd. - -**@overload** [] - -## initialize_copy(date) [](#method-i-initialize_copy) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - Date.new(2001, 2, 3).inspect - # => "#" - -**@overload** [] - -## inspect_raw() [](#method-i-inspect_raw) -:nodoc: - -## iso8601() [](#method-i-iso8601) -Equivalent to #strftime with argument `'%Y-%m-%d'` (or its [shorthand -form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers) -`'%F'`); - - Date.new(2001, 2, 3).iso8601 # => "2001-02-03" - -**@overload** [] - -## italy() [](#method-i-italy) -Equivalent to Date#new_start with argument Date::ITALY. - -**@overload** [] - -## jd() [](#method-i-jd) -Returns the Julian day number. This is a whole number, which is adjusted by -the offset as the local time. - - DateTime.new(2001,2,3,4,5,6,'+7').jd #=> 2451944 - DateTime.new(2001,2,3,4,5,6,'-7').jd #=> 2451944 - -**@overload** [] - -## jisx0301() [](#method-i-jisx0301) -Returns a string representation of the date in `self` in JIS X 0301 format. - - Date.new(2001, 2, 3).jisx0301 # => "H13.02.03" - -**@overload** [] - -## julian() [](#method-i-julian) -Equivalent to Date#new_start with argument Date::JULIAN. - -**@overload** [] - -## julian?() [](#method-i-julian?) -Returns `true` if the date is before the date of calendar reform, `false` -otherwise: - - (Date.new(1582, 10, 15) - 1).julian? # => true - Date.new(1582, 10, 15).julian? # => false - -**@overload** [] - -## ld() [](#method-i-ld) -Returns the [Lilian day number](https://en.wikipedia.org/wiki/Lilian_date), -which is the number of days since the beginning of the Gregorian calendar, -October 15, 1582. - - Date.new(2001, 2, 3).ld # => 152784 - -**@overload** [] - -## leap?() [](#method-i-leap?) -Returns `true` if the year is a leap year, `false` otherwise: - - Date.new(2000).leap? # => true - Date.new(2001).leap? # => false - -**@overload** [] - -## marshal_dump() [](#method-i-marshal_dump) -:nodoc: - -## marshal_dump_old() [](#method-i-marshal_dump_old) -:nodoc: - -## marshal_load(a) [](#method-i-marshal_load) -:nodoc: - -## mday() [](#method-i-mday) -Returns the day of the month in range (1..31): - - Date.new(2001, 2, 3).mday # => 3 - -**@overload** [] - -## mjd() [](#method-i-mjd) -Returns the modified Julian day number. This is a whole number, which is -adjusted by the offset as the local time. - - DateTime.new(2001,2,3,4,5,6,'+7').mjd #=> 51943 - DateTime.new(2001,2,3,4,5,6,'-7').mjd #=> 51943 - -**@overload** [] - -## mon() [](#method-i-mon) -Returns the month in range (1..12): - - Date.new(2001, 2, 3).mon # => 2 - -**@overload** [] - -## monday?() [](#method-i-monday?) -Returns `true` if `self` is a Monday, `false` otherwise. - -**@overload** [] - -## month() [](#method-i-month) -Returns the month in range (1..12): - - Date.new(2001, 2, 3).mon # => 2 - -**@overload** [] - -## new_start(*args) [](#method-i-new_start) -Returns a copy of `self` with the given `start` value: - - d0 = Date.new(2000, 2, 3) - d0.julian? # => false - d1 = d0.new_start(Date::JULIAN) - d1.julian? # => true - -See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start). - -**@overload** [] - -## next() [](#method-i-next) -Returns a new Date object representing the following day: - - d = Date.new(2001, 2, 3) - d.to_s # => "2001-02-03" - d.next.to_s # => "2001-02-04" - -**@overload** [] - -## next_day(*args) [](#method-i-next_day) -Equivalent to Date#+ with argument `n`. - -**@overload** [] - -## next_month(*args) [](#method-i-next_month) -Equivalent to #>> with argument `n`. - -**@overload** [] - -## next_year(*args) [](#method-i-next_year) -Equivalent to #>> with argument `n * 12`. - -**@overload** [] - -## nth_kday?(n, k) [](#method-i-nth_kday?) -:nodoc: - -**@return** [Boolean] - -## prev_day(*args) [](#method-i-prev_day) -Equivalent to Date#- with argument `n`. - -**@overload** [] - -## prev_month(*args) [](#method-i-prev_month) -Equivalent to #<< with argument `n`. - -**@overload** [] - -## prev_year(*args) [](#method-i-prev_year) -Equivalent to #<< with argument `n * 12`. - -**@overload** [] - -## rfc2822() [](#method-i-rfc2822) -Equivalent to #strftime with argument `'%a, %-d %b %Y %T %z'`; see [Formats -for Dates and Times](rdoc-ref:strftime_formatting.rdoc): - - Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000" - -**@overload** [] - -## rfc3339() [](#method-i-rfc3339) -Equivalent to #strftime with argument `'%FT%T%:z'`; see [Formats for Dates and -Times](rdoc-ref:strftime_formatting.rdoc): - - Date.new(2001, 2, 3).rfc3339 # => "2001-02-03T00:00:00+00:00" - -**@overload** [] - -## rfc822() [](#method-i-rfc822) -Equivalent to #strftime with argument `'%a, %-d %b %Y %T %z'`; see [Formats -for Dates and Times](rdoc-ref:strftime_formatting.rdoc): - - Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000" - -**@overload** [] - -## saturday?() [](#method-i-saturday?) -Returns `true` if `self` is a Saturday, `false` otherwise. - -**@overload** [] - -## step(*args) [](#method-i-step) -Calls the block with specified dates; returns `self`. - -* The first `date` is `self`. -* Each successive `date` is `date + step`, where `step` is the numeric step - size in days. -* The last date is the last one that is before or equal to `limit`, which - should be a Date object. - -Example: - - limit = Date.new(2001, 12, 31) - Date.new(2001).step(limit){|date| p date.to_s if date.mday == 31 } - -Output: - - "2001-01-31" - "2001-03-31" - "2001-05-31" - "2001-07-31" - "2001-08-31" - "2001-10-31" - "2001-12-31" - -Returns an Enumerator if no block is given. - -**@overload** [] - -## strftime(*args) [](#method-i-strftime) -Returns a string representation of the date in `self`, formatted according the -given `format`: - - Date.new(2001, 2, 3).strftime # => "2001-02-03" - -For other formats, see [Formats for Dates and -Times](rdoc-ref:strftime_formatting.rdoc). - -**@overload** [] - -## succ() [](#method-i-succ) -Returns a new Date object representing the following day: - - d = Date.new(2001, 2, 3) - d.to_s # => "2001-02-03" - d.next.to_s # => "2001-02-04" - -**@overload** [] - -## sunday?() [](#method-i-sunday?) -Returns `true` if `self` is a Sunday, `false` otherwise. - -**@overload** [] - -## thursday?() [](#method-i-thursday?) -Returns `true` if `self` is a Thursday, `false` otherwise. - -**@overload** [] - -## to_date() [](#method-i-to_date) -Returns `self`. - -**@overload** [] - -## to_datetime() [](#method-i-to_datetime) -Returns a DateTime whose value is the same as `self`: - - Date.new(2001, 2, 3).to_datetime # => # - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/date' - puts Date.today.to_json - -Output: - - {"json_class":"Date","y":2023,"m":11,"d":21,"sg":2299161.0} - -## to_s() [](#method-i-to_s) -Returns a string representation of the date in `self` in [ISO 8601 extended -date format](rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications) -(`'%Y-%m-%d'`): - - Date.new(2001, 2, 3).to_s # => "2001-02-03" - -**@overload** [] - -## to_time() [](#method-i-to_time) -Returns a new Time object with the same value as `self`; if `self` is a Julian -date, derives its Gregorian date for conversion to the Time object: - - Date.new(2001, 2, 3).to_time # => 2001-02-03 00:00:00 -0600 - Date.new(2001, 2, 3, Date::JULIAN).to_time # => 2001-02-16 00:00:00 -0600 - -**@overload** [] - -## tuesday?() [](#method-i-tuesday?) -Returns `true` if `self` is a Tuesday, `false` otherwise. - -**@overload** [] - -## upto(max) [](#method-i-upto) -Equivalent to #step with arguments `max` and `1`. - -**@overload** [] - -## wday() [](#method-i-wday) -Returns the day of week in range (0..6); Sunday is 0: - - Date.new(2001, 2, 3).wday # => 6 - -**@overload** [] - -## wednesday?() [](#method-i-wednesday?) -Returns `true` if `self` is a Wednesday, `false` otherwise. - -**@overload** [] - -## xmlschema() [](#method-i-xmlschema) -Equivalent to #strftime with argument `'%Y-%m-%d'` (or its [shorthand -form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers) -`'%F'`); - - Date.new(2001, 2, 3).iso8601 # => "2001-02-03" - -**@overload** [] - -## yday() [](#method-i-yday) -Returns the day of the year, in range (1..366): - - Date.new(2001, 2, 3).yday # => 34 - -**@overload** [] - -## year() [](#method-i-year) -Returns the year: - - Date.new(2001, 2, 3).year # => 2001 - (Date.new(1, 1, 1) - 1).year # => 0 - -**@overload** [] - diff --git a/example/ruby/Date/Error.md b/example/ruby/Date/Error.md deleted file mode 100644 index e353124..0000000 --- a/example/ruby/Date/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Date::Error -**Inherits:** ArgumentError - - - - - diff --git a/example/ruby/Date/Infinity.md b/example/ruby/Date/Infinity.md deleted file mode 100644 index 17c1a7f..0000000 --- a/example/ruby/Date/Infinity.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: Date::Infinity -**Inherits:** Numeric - - -:nodoc: - - - -#Instance Methods -## +@() [](#method-i-+@) - -## -@() [](#method-i--@) - -## <=>(other) [](#method-i-<=>) - -## abs() [](#method-i-abs) - -## coerce(other) [](#method-i-coerce) - -## finite?() [](#method-i-finite?) - -**@return** [Boolean] - -## infinite?() [](#method-i-infinite?) - -**@return** [Boolean] - -## initialize(d1) [](#method-i-initialize) - -**@return** [Infinity] a new instance of Infinity - -## nan?() [](#method-i-nan?) - -**@return** [Boolean] - -## to_f() [](#method-i-to_f) - -## zero?() [](#method-i-zero?) - -**@return** [Boolean] - diff --git a/example/ruby/DateSub.md b/example/ruby/DateSub.md deleted file mode 100644 index 1f51078..0000000 --- a/example/ruby/DateSub.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: DateSub -**Inherits:** Date - - - - - diff --git a/example/ruby/DateTime.md b/example/ruby/DateTime.md deleted file mode 100644 index 4df0d63..0000000 --- a/example/ruby/DateTime.md +++ /dev/null @@ -1,443 +0,0 @@ -# Class: DateTime -**Inherits:** Date - - - - -# Class Methods -## _strptime(*args ) [](#method-c-_strptime) -Parses the given representation of date and time with the given template, and -returns a hash of parsed elements. _strptime does not support specification -of flags and width unlike strftime. - -See also strptime(3) and #strftime. -**@overload** [] - -## civil(*args ) [](#method-c-civil) -Same as DateTime.new. -## commercial(*args ) [](#method-c-commercial) -Creates a DateTime object denoting the given week date. - - DateTime.commercial(2001) #=> # - DateTime.commercial(2002) #=> # - DateTime.commercial(2001,5,6,4,5,6,'+7') - - #=> # -**@overload** [] - -## httpdate(*args ) [](#method-c-httpdate) -Creates a new DateTime object by parsing from a string according to some RFC -2616 format. - - DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT') - - #=> # - -Raise an ArgumentError when the string length is longer than *limit*. You can -stop this check by passing `limit: nil`, but note that it may take a long time -to parse. -**@overload** [] - -## iso8601(*args ) [](#method-c-iso8601) -Creates a new DateTime object by parsing from a string according to some -typical ISO 8601 formats. - - DateTime.iso8601('2001-02-03T04:05:06+07:00') - - #=> # - DateTime.iso8601('20010203T040506+0700') - - #=> # - DateTime.iso8601('2001-W05-6T04:05:06+07:00') - - #=> # - -Raise an ArgumentError when the string length is longer than *limit*. You can -stop this check by passing `limit: nil`, but note that it may take a long time -to parse. -**@overload** [] - -## jd(*args ) [](#method-c-jd) -Creates a DateTime object denoting the given chronological Julian day number. - - DateTime.jd(2451944) #=> # - DateTime.jd(2451945) #=> # - DateTime.jd(Rational('0.5')) - - #=> # -**@overload** [] - -## jisx0301(*args ) [](#method-c-jisx0301) -Creates a new DateTime object by parsing from a string according to some -typical JIS X 0301 formats. - - DateTime.jisx0301('H13.02.03T04:05:06+07:00') - - #=> # - -For no-era year, legacy format, Heisei is assumed. - - DateTime.jisx0301('13.02.03T04:05:06+07:00') - - #=> # - -Raise an ArgumentError when the string length is longer than *limit*. You can -stop this check by passing `limit: nil`, but note that it may take a long time -to parse. -**@overload** [] - -## json_create(object ) [](#method-c-json_create) -See #as_json. -## new(*args ) [](#method-c-new) -Same as DateTime.new. -## now(*args ) [](#method-c-now) -Creates a DateTime object denoting the present time. - - DateTime.now #=> # -**@overload** [] - -## nth_kday(*args ) [](#method-c-nth_kday) -:nodoc: -## ordinal(*args ) [](#method-c-ordinal) -Creates a DateTime object denoting the given ordinal date. - - DateTime.ordinal(2001,34) #=> # - DateTime.ordinal(2001,34,4,5,6,'+7') - - #=> # - DateTime.ordinal(2001,-332,-20,-55,-54,'+7') - - #=> # -**@overload** [] - -## parse(*args ) [](#method-c-parse) -Parses the given representation of date and time, and creates a DateTime -object. - -This method **does** **not** function as a validator. If the input string -does not match valid formats strictly, you may get a cryptic result. Should -consider to use DateTime.strptime instead of this method as possible. - -If the optional second argument is true and the detected year is in the range -"00" to "99", makes it full. - - DateTime.parse('2001-02-03T04:05:06+07:00') - - #=> # - DateTime.parse('20010203T040506+0700') - - #=> # - DateTime.parse('3rd Feb 2001 04:05:06 PM') - - #=> # - -Raise an ArgumentError when the string length is longer than *limit*. You can -stop this check by passing `limit: nil`, but note that it may take a long time -to parse. -**@overload** [] - -## rfc2822(*args ) [](#method-c-rfc2822) -Creates a new DateTime object by parsing from a string according to some -typical RFC 2822 formats. - - DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700') - - #=> # - -Raise an ArgumentError when the string length is longer than *limit*. You can -stop this check by passing `limit: nil`, but note that it may take a long time -to parse. -**@overload** [] - -**@overload** [] - -## rfc3339(*args ) [](#method-c-rfc3339) -Creates a new DateTime object by parsing from a string according to some -typical RFC 3339 formats. - - DateTime.rfc3339('2001-02-03T04:05:06+07:00') - - #=> # - -Raise an ArgumentError when the string length is longer than *limit*. You can -stop this check by passing `limit: nil`, but note that it may take a long time -to parse. -**@overload** [] - -## rfc822(*args ) [](#method-c-rfc822) -Creates a new DateTime object by parsing from a string according to some -typical RFC 2822 formats. - - DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700') - - #=> # - -Raise an ArgumentError when the string length is longer than *limit*. You can -stop this check by passing `limit: nil`, but note that it may take a long time -to parse. -**@overload** [] - -**@overload** [] - -## strptime(*args ) [](#method-c-strptime) -Parses the given representation of date and time with the given template, and -creates a DateTime object. strptime does not support specification of flags -and width unlike strftime. - - DateTime.strptime('2001-02-03T04:05:06+07:00', '%Y-%m-%dT%H:%M:%S%z') - - #=> # - DateTime.strptime('03-02-2001 04:05:06 PM', '%d-%m-%Y %I:%M:%S %p') - - #=> # - DateTime.strptime('2001-W05-6T04:05:06+07:00', '%G-W%V-%uT%H:%M:%S%z') - - #=> # - DateTime.strptime('2001 04 6 04 05 06 +7', '%Y %U %w %H %M %S %z') - - #=> # - DateTime.strptime('2001 05 6 04 05 06 +7', '%Y %W %u %H %M %S %z') - - #=> # - DateTime.strptime('-1', '%s') - - #=> # - DateTime.strptime('-1000', '%Q') - - #=> # - DateTime.strptime('sat3feb014pm+7', '%a%d%b%y%H%p%z') - - #=> # - -See also strptime(3) and #strftime. -**@overload** [] - -## weeknum(*args ) [](#method-c-weeknum) -:nodoc: -## xmlschema(*args ) [](#method-c-xmlschema) -Creates a new DateTime object by parsing from a string according to some -typical XML Schema formats. - - DateTime.xmlschema('2001-02-03T04:05:06+07:00') - - #=> # - -Raise an ArgumentError when the string length is longer than *limit*. You can -stop this check by passing `limit: nil`, but note that it may take a long time -to parse. -**@overload** [] - - -#Instance Methods -## as_json() [](#method-i-as_json) -Methods `DateTime#as_json` and `DateTime.json_create` may be used to serialize -and deserialize a DateTime object; see [Marshal](rdoc-ref:Marshal). - -Method `DateTime#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/datetime' - x = DateTime.now.as_json - # => {"json_class"=>"DateTime", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0} - -Method `JSON.create` deserializes such a hash, returning a DateTime object: - - DateTime.json_create(x) # BUG? Raises Date::Error "invalid date" - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Returns a hash of the name/value pairs, to use in pattern matching. Possible -keys are: `:year`, `:month`, `:day`, `:wday`, `:yday`, `:hour`, `:min`, -`:sec`, `:sec_fraction`, `:zone`. - -Possible usages: - - dt = DateTime.new(2022, 10, 5, 13, 30) - - if d in wday: 1..5, hour: 10..18 # uses deconstruct_keys underneath - puts "Working time" - end - #=> prints "Working time" - - case dt - in year: ...2022 - puts "too old" - in month: ..9 - puts "quarter 1-3" - in wday: 1..5, month: - puts "working day in month #{month}" - end - #=> prints "working day in month 10" - -Note that deconstruction by pattern can also be combined with class check: - - if d in DateTime(wday: 1..5, hour: 10..18, day: ..7) - puts "Working time, first week of the month" - end - -**@overload** [] - -## hour() [](#method-i-hour) -Returns the hour in range (0..23): - - DateTime.new(2001, 2, 3, 4, 5, 6).hour # => 4 - -**@overload** [] - -## iso8601(*args) [](#method-i-iso8601) -This method is equivalent to strftime('%FT%T%:z'). The optional argument `n` -is the number of digits for fractional seconds. - - DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9) - - #=> "2001-02-03T04:05:06.123456789+07:00" - -**@overload** [] - -**@overload** [] - -## jisx0301(*args) [](#method-i-jisx0301) -Returns a string in a JIS X 0301 format. The optional argument `n` is the -number of digits for fractional seconds. - - DateTime.parse('2001-02-03T04:05:06.123456789+07:00').jisx0301(9) - - #=> "H13.02.03T04:05:06.123456789+07:00" - -**@overload** [] - -## min() [](#method-i-min) -Returns the minute in range (0..59): - - DateTime.new(2001, 2, 3, 4, 5, 6).min # => 5 - -**@overload** [] - -## minute() [](#method-i-minute) -Returns the minute in range (0..59): - - DateTime.new(2001, 2, 3, 4, 5, 6).min # => 5 - -**@overload** [] - -## new_offset(*args) [](#method-i-new_offset) -Duplicates self and resets its offset. - - d = DateTime.new(2001,2,3,4,5,6,'-02:00') - - #=> # - d.new_offset('+09:00') #=> # - -**@overload** [] - -## offset() [](#method-i-offset) -Returns the offset. - - DateTime.parse('04pm+0730').offset #=> (5/16) - -**@overload** [] - -## rfc3339(*args) [](#method-i-rfc3339) -This method is equivalent to strftime('%FT%T%:z'). The optional argument `n` -is the number of digits for fractional seconds. - - DateTime.parse('2001-02-03T04:05:06.123456789+07:00').rfc3339(9) - - #=> "2001-02-03T04:05:06.123456789+07:00" - -**@overload** [] - -## sec() [](#method-i-sec) -Returns the second in range (0..59): - - DateTime.new(2001, 2, 3, 4, 5, 6).sec # => 6 - -**@overload** [] - -## sec_fraction() [](#method-i-sec_fraction) -Returns the fractional part of the second in range (Rational(0, -1)...Rational(1, 1)): - - DateTime.new(2001, 2, 3, 4, 5, 6.5).sec_fraction # => (1/2) - -**@overload** [] - -## second() [](#method-i-second) -Returns the second in range (0..59): - - DateTime.new(2001, 2, 3, 4, 5, 6).sec # => 6 - -**@overload** [] - -## second_fraction() [](#method-i-second_fraction) -Returns the fractional part of the second in range (Rational(0, -1)...Rational(1, 1)): - - DateTime.new(2001, 2, 3, 4, 5, 6.5).sec_fraction # => (1/2) - -**@overload** [] - -## strftime(*args) [](#method-i-strftime) -Returns a string representation of `self`, formatted according the given -+format: - - DateTime.now.strftime # => "2022-07-01T11:03:19-05:00" - -For other formats, see [Formats for Dates and -Times](rdoc-ref:strftime_formatting.rdoc): - -**@overload** [] - -## to_date() [](#method-i-to_date) -Returns a Date object which denotes self. - -**@overload** [] - -## to_datetime() [](#method-i-to_datetime) -Returns self. - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/datetime' - puts DateTime.now.to_json - -Output: - - {"json_class":"DateTime","y":2023,"m":11,"d":21,"sg":2299161.0} - -## to_s() [](#method-i-to_s) -Returns a string in an ISO 8601 format. (This method doesn't use the expanded -representations.) - - DateTime.new(2001,2,3,4,5,6,'-7').to_s - - #=> "2001-02-03T04:05:06-07:00" - -**@overload** [] - -## to_time() [](#method-i-to_time) -Returns a Time object which denotes self. - -**@overload** [] - -## xmlschema(*args) [](#method-i-xmlschema) -This method is equivalent to strftime('%FT%T%:z'). The optional argument `n` -is the number of digits for fractional seconds. - - DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9) - - #=> "2001-02-03T04:05:06.123456789+07:00" - -**@overload** [] - -**@overload** [] - -## zone() [](#method-i-zone) -Returns the timezone. - - DateTime.parse('04pm+0730').zone #=> "+07:30" - -**@overload** [] - diff --git a/example/ruby/DateTimeSub.md b/example/ruby/DateTimeSub.md deleted file mode 100644 index 2a89c57..0000000 --- a/example/ruby/DateTimeSub.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: DateTimeSub -**Inherits:** DateTime - - - - - diff --git a/example/ruby/DebugPOpen.md b/example/ruby/DebugPOpen.md deleted file mode 100644 index ce2d682..0000000 --- a/example/ruby/DebugPOpen.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: DebugPOpen - - - - - diff --git a/example/ruby/DebugSystem.md b/example/ruby/DebugSystem.md deleted file mode 100644 index 75a1158..0000000 --- a/example/ruby/DebugSystem.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: DebugSystem - - - - - -#Instance Methods -## system(*args) [](#method-i-system) - diff --git a/example/ruby/DefineMethodSpecClass.md b/example/ruby/DefineMethodSpecClass.md deleted file mode 100644 index cb5dd57..0000000 --- a/example/ruby/DefineMethodSpecClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: DefineMethodSpecClass -**Inherits:** Object - - - - - diff --git a/example/ruby/DefinedSpecs.md b/example/ruby/DefinedSpecs.md deleted file mode 100644 index 922faa2..0000000 --- a/example/ruby/DefinedSpecs.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: DefinedSpecs - - - - -# Class Methods -## any_args() [](#method-c-any_args) -## defined_method() [](#method-c-defined_method) -## exception_method() [](#method-c-exception_method) -## fixnum_method() [](#method-c-fixnum_method) -## side_effects() [](#method-c-side_effects) - diff --git a/example/ruby/DefinedSpecs/Basic.md b/example/ruby/DefinedSpecs/Basic.md deleted file mode 100644 index 91cffb2..0000000 --- a/example/ruby/DefinedSpecs/Basic.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: DefinedSpecs::Basic -**Inherits:** Object - - - - - -#Instance Methods -## a_defined_method() [](#method-i-a_defined_method) - -## class_variable_defined() [](#method-i-class_variable_defined) - -## class_variable_undefined() [](#method-i-class_variable_undefined) - -## defined_method() [](#method-i-defined_method) - -## global_variable_defined() [](#method-i-global_variable_defined) - -## global_variable_defined_as_nil() [](#method-i-global_variable_defined_as_nil) - -## global_variable_read() [](#method-i-global_variable_read) - -## global_variable_undefined() [](#method-i-global_variable_undefined) - -## instance_variable_defined() [](#method-i-instance_variable_defined) - -## instance_variable_defined_nil() [](#method-i-instance_variable_defined_nil) - -## instance_variable_read() [](#method-i-instance_variable_read) - -## instance_variable_undefined() [](#method-i-instance_variable_undefined) - -## local_variable_defined() [](#method-i-local_variable_defined) - -## local_variable_defined_nil() [](#method-i-local_variable_defined_nil) - -## no_yield_block() [](#method-i-no_yield_block) - -## no_yield_block_parameter() [](#method-i-no_yield_block_parameter) - -## private_method_defined() [](#method-i-private_method_defined) - -## private_predicate_defined() [](#method-i-private_predicate_defined) - -## yield_block() [](#method-i-yield_block) - -## yield_block_parameter() [](#method-i-yield_block_parameter) - -## yield_defined_method() [](#method-i-yield_defined_method) - -## yield_defined_parameter_method(&block) [](#method-i-yield_defined_parameter_method) - diff --git a/example/ruby/DefinedSpecs/Child.md b/example/ruby/DefinedSpecs/Child.md deleted file mode 100644 index 278f3a9..0000000 --- a/example/ruby/DefinedSpecs/Child.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DefinedSpecs::Child -**Inherits:** DefinedSpecs::Parent - -**Includes:** DefinedSpecs::Mixin - - - - -# Class Methods -## module_constant_defined() [](#method-c-module_constant_defined) -## module_defined() [](#method-c-module_defined) -## parent_constant_defined() [](#method-c-parent_constant_defined) - -#Instance Methods -## defined_super() [](#method-i-defined_super) - diff --git a/example/ruby/DefinedSpecs/ClassUndefiningMethod.md b/example/ruby/DefinedSpecs/ClassUndefiningMethod.md deleted file mode 100644 index ec42200..0000000 --- a/example/ruby/DefinedSpecs/ClassUndefiningMethod.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: DefinedSpecs::ClassUndefiningMethod -**Inherits:** DefinedSpecs::ClassWithMethod - - - - - diff --git a/example/ruby/DefinedSpecs/ClassWithMethod.md b/example/ruby/DefinedSpecs/ClassWithMethod.md deleted file mode 100644 index fc7dae7..0000000 --- a/example/ruby/DefinedSpecs/ClassWithMethod.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: DefinedSpecs::ClassWithMethod -**Inherits:** Object - - - - - -#Instance Methods -## test() [](#method-i-test) - diff --git a/example/ruby/DefinedSpecs/ClassWithoutMethod.md b/example/ruby/DefinedSpecs/ClassWithoutMethod.md deleted file mode 100644 index 994cafa..0000000 --- a/example/ruby/DefinedSpecs/ClassWithoutMethod.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: DefinedSpecs::ClassWithoutMethod -**Inherits:** DefinedSpecs::ClassUndefiningMethod - - - - - -#Instance Methods -## test() [](#method-i-test) -If an undefined method overridden in descendants define?(super) should return -nil - diff --git a/example/ruby/DefinedSpecs/IntermediateModule1.md b/example/ruby/DefinedSpecs/IntermediateModule1.md deleted file mode 100644 index 09004b4..0000000 --- a/example/ruby/DefinedSpecs/IntermediateModule1.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: DefinedSpecs::IntermediateModule1 - - - - - -#Instance Methods -## method_no_args() [](#method-i-method_no_args) - diff --git a/example/ruby/DefinedSpecs/IntermediateModule2.md b/example/ruby/DefinedSpecs/IntermediateModule2.md deleted file mode 100644 index 6e821be..0000000 --- a/example/ruby/DefinedSpecs/IntermediateModule2.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: DefinedSpecs::IntermediateModule2 - - - - - -#Instance Methods -## method_no_args() [](#method-i-method_no_args) - diff --git a/example/ruby/DefinedSpecs/Mixin.md b/example/ruby/DefinedSpecs/Mixin.md deleted file mode 100644 index 6a429c9..0000000 --- a/example/ruby/DefinedSpecs/Mixin.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: DefinedSpecs::Mixin - - - - - -#Instance Methods -## defined_super() [](#method-i-defined_super) - diff --git a/example/ruby/DefinedSpecs/ModuleWithConstMissing.md b/example/ruby/DefinedSpecs/ModuleWithConstMissing.md deleted file mode 100644 index 4887522..0000000 --- a/example/ruby/DefinedSpecs/ModuleWithConstMissing.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: DefinedSpecs::ModuleWithConstMissing - - - - -# Class Methods -## const_missing(const ) [](#method-c-const_missing) - diff --git a/example/ruby/DefinedSpecs/Parent.md b/example/ruby/DefinedSpecs/Parent.md deleted file mode 100644 index 6f2eb5a..0000000 --- a/example/ruby/DefinedSpecs/Parent.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: DefinedSpecs::Parent -**Inherits:** Object - - - - - -#Instance Methods -## defined_super() [](#method-i-defined_super) - diff --git a/example/ruby/DefinedSpecs/Super.md b/example/ruby/DefinedSpecs/Super.md deleted file mode 100644 index b8d69d4..0000000 --- a/example/ruby/DefinedSpecs/Super.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: DefinedSpecs::Super -**Inherits:** DefinedSpecs::Superclass - - - - - -#Instance Methods -## method_args() [](#method-i-method_args) - -## method_block_args() [](#method-i-method_block_args) - -## method_block_no_args() [](#method-i-method_block_no_args) - -## method_no_args() [](#method-i-method_no_args) - -## no_super_method_args() [](#method-i-no_super_method_args) - -## no_super_method_block_args() [](#method-i-no_super_method_block_args) - -## no_super_method_block_no_args() [](#method-i-no_super_method_block_no_args) - -## no_super_method_no_args() [](#method-i-no_super_method_no_args) - diff --git a/example/ruby/DefinedSpecs/SuperWithIntermediateModules.md b/example/ruby/DefinedSpecs/SuperWithIntermediateModules.md deleted file mode 100644 index 190fae1..0000000 --- a/example/ruby/DefinedSpecs/SuperWithIntermediateModules.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: DefinedSpecs::SuperWithIntermediateModules -**Inherits:** Object - -**Includes:** DefinedSpecs::IntermediateModule1, DefinedSpecs::IntermediateModule2 - - - - - -#Instance Methods -## method_no_args() [](#method-i-method_no_args) - diff --git a/example/ruby/DefinedSpecs/Superclass.md b/example/ruby/DefinedSpecs/Superclass.md deleted file mode 100644 index 008c598..0000000 --- a/example/ruby/DefinedSpecs/Superclass.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: DefinedSpecs::Superclass -**Inherits:** Object - - - - - -#Instance Methods -## define_method_args() [](#method-i-define_method_args) - -## define_method_block_args() [](#method-i-define_method_block_args) - -## define_method_block_no_args() [](#method-i-define_method_block_no_args) - -## define_method_no_args() [](#method-i-define_method_no_args) - -## method_args() [](#method-i-method_args) - -## method_block_args() [](#method-i-method_block_args) - -## method_block_no_args() [](#method-i-method_block_no_args) - -## method_no_args() [](#method-i-method_no_args) - -## yield_method() [](#method-i-yield_method) - diff --git a/example/ruby/DelegateSpecs.md b/example/ruby/DelegateSpecs.md deleted file mode 100644 index 6483023..0000000 --- a/example/ruby/DelegateSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: DelegateSpecs - - - - - diff --git a/example/ruby/DelegateSpecs/DelegateClass.md b/example/ruby/DelegateSpecs/DelegateClass.md deleted file mode 100644 index 0256f25..0000000 --- a/example/ruby/DelegateSpecs/DelegateClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: DelegateSpecs::DelegateClass -**Inherits:** DelegateSpecs::Simple - -**Includes:** DelegateSpecs::Extra - - - - - -#Instance Methods -## extra() [](#method-i-extra) - diff --git a/example/ruby/DelegateSpecs/Delegator.md b/example/ruby/DelegateSpecs/Delegator.md deleted file mode 100644 index 3239a01..0000000 --- a/example/ruby/DelegateSpecs/Delegator.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: DelegateSpecs::Delegator -**Inherits:** Delegator - -**Includes:** DelegateSpecs::Extra - - - - -# Attributes -## __getobj__[RW] [](#attribute-i-__getobj__) -Returns the value of attribute __getobj__. - -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## __setobj__(o) [](#method-i-__setobj__) - -## extra() [](#method-i-extra) - diff --git a/example/ruby/DelegateSpecs/Extra.md b/example/ruby/DelegateSpecs/Extra.md deleted file mode 100644 index 1192ace..0000000 --- a/example/ruby/DelegateSpecs/Extra.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: DelegateSpecs::Extra - - - - - -#Instance Methods -## extra() [](#method-i-extra) - diff --git a/example/ruby/DelegateSpecs/Simple.md b/example/ruby/DelegateSpecs/Simple.md deleted file mode 100644 index 4263f02..0000000 --- a/example/ruby/DelegateSpecs/Simple.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: DelegateSpecs::Simple -**Inherits:** Object - - - - - -#Instance Methods -## method_missing(method, *args) [](#method-i-method_missing) - -## pub() [](#method-i-pub) - -## respond_to_missing?(method, privfalse) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - diff --git a/example/ruby/DelegationSpecs.md b/example/ruby/DelegationSpecs.md deleted file mode 100644 index 0a021e8..0000000 --- a/example/ruby/DelegationSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: DelegationSpecs - - - - - diff --git a/example/ruby/DelegationSpecs/Target.md b/example/ruby/DelegationSpecs/Target.md deleted file mode 100644 index 280d49c..0000000 --- a/example/ruby/DelegationSpecs/Target.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DelegationSpecs::Target -**Inherits:** Object - - - - - -#Instance Methods -## target(*args, **kwargs, &block) [](#method-i-target) - -## target_block(*args, **kwargs) [](#method-i-target_block) - -**@yield** [[kwargs, args]] - diff --git a/example/ruby/Delegator.md b/example/ruby/Delegator.md deleted file mode 100644 index 0dd33e9..0000000 --- a/example/ruby/Delegator.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: Delegator -**Inherits:** BasicObject - - -This library provides three different ways to delegate method calls to an -object. The easiest to use is SimpleDelegator. Pass an object to the -constructor and all methods supported by the object will be delegated. This -object can be changed later. - -Going a step further, the top level DelegateClass method allows you to easily -setup delegation through class inheritance. This is considerably more -flexible and thus probably the most common use for this library. - -Finally, if you need full control over the delegation scheme, you can inherit -from the abstract class Delegator and customize as needed. (If you find -yourself needing this control, have a look at Forwardable which is also in the -standard library. It may suit your needs better.) - -SimpleDelegator's implementation serves as a nice example of the use of -Delegator: - - require 'delegate' - - class SimpleDelegator < Delegator - def __getobj__ - @delegate_sd_obj # return object we are delegating to, required - end - - def __setobj__(obj) - @delegate_sd_obj = obj # change delegation object, - # a feature we're providing - end - end - -## Notes - -Be advised, RDoc will not detect delegated methods. - - -# Class Methods -## const_missing(n ) [](#method-c-const_missing) -:stopdoc: -## delegating_block(mid ) [](#method-c-delegating_block) -:nodoc: -## public_api() [](#method-c-public_api) -:nodoc: - -#Instance Methods -## !() [](#method-i-!) -Delegates ! to the _*getobj*_ - -## !=(obj) [](#method-i-!=) -Returns true if two objects are not considered of equal value. - -## ==(obj) [](#method-i-==) -Returns true if two objects are considered of equal value. - -## __getobj__() [](#method-i-__getobj__) -This method must be overridden by subclasses and should return the object -method calls are being delegated to. - -## __setobj__(obj) [](#method-i-__setobj__) -This method must be overridden by subclasses and change the object delegate to -*obj*. - -## eql?(obj) [](#method-i-eql?) -Returns true if two objects are considered of equal value. - -**@return** [Boolean] - -## freeze() [](#method-i-freeze) -:method: freeze Freeze both the object returned by _*getobj*_ and self. - -## initialize(obj) [](#method-i-initialize) -Pass in the *obj* to delegate method calls to. All methods supported by *obj* -will be delegated to. - -**@return** [Delegator] a new instance of Delegator - -## marshal_dump() [](#method-i-marshal_dump) -Serialization support for the object returned by _*getobj*_. - -## marshal_load(data) [](#method-i-marshal_load) -Reinitializes delegation from a serialized object. - -## methods(alltrue) [](#method-i-methods) -Returns the methods available to this delegate object as the union of this -object's and _*getobj*_ methods. - -## protected_methods(alltrue) [](#method-i-protected_methods) -Returns the methods available to this delegate object as the union of this -object's and _*getobj*_ protected methods. - -## public_methods(alltrue) [](#method-i-public_methods) -Returns the methods available to this delegate object as the union of this -object's and _*getobj*_ public methods. - -## respond_to_missing?(m, include_private) [](#method-i-respond_to_missing?) -Checks for a method provided by this the delegate object by forwarding the -call through _*getobj*_. - -**@return** [Boolean] - diff --git a/example/ruby/DescribeFormatter.md b/example/ruby/DescribeFormatter.md deleted file mode 100644 index 05bca6e..0000000 --- a/example/ruby/DescribeFormatter.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: DescribeFormatter -**Inherits:** DottedFormatter - - - - - -#Instance Methods -## finish() [](#method-i-finish) -Callback for the MSpec :finish event. Prints a summary of the number of errors -and failures for each `describe` block. - diff --git a/example/ruby/DetailedMessageSpec.md b/example/ruby/DetailedMessageSpec.md deleted file mode 100644 index b22ebea..0000000 --- a/example/ruby/DetailedMessageSpec.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: DetailedMessageSpec - - - - - diff --git a/example/ruby/Dhasen.md b/example/ruby/Dhasen.md deleted file mode 100644 index 4c59645..0000000 --- a/example/ruby/Dhasen.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Dhasen -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Dhasen] a new instance of Dhasen - -## sparse(str, *arg) [](#method-i-sparse) - diff --git a/example/ruby/DidYouMean.md b/example/ruby/DidYouMean.md deleted file mode 100644 index a644598..0000000 --- a/example/ruby/DidYouMean.md +++ /dev/null @@ -1,87 +0,0 @@ -# Module: DidYouMean - - -The `DidYouMean` gem adds functionality to suggest possible method/class names -upon errors such as `NameError` and `NoMethodError`. In Ruby 2.3 or later, it -is automatically activated during startup. - -## Disabling `did_you_mean` - -Occasionally, you may want to disable the `did_you_mean` gem for e.g. -debugging issues in the error object itself. You can disable it entirely by -specifying `--disable-did_you_mean` option to the `ruby` command: - - $ ruby --disable-did_you_mean -e "1.zeor?" - -e:1:in `
': undefined method `zeor?' for 1:Integer (NameError) - -When you do not have direct access to the `ruby` command (e.g. +rails -console+, `irb`), you could applyoptions using the `RUBYOPT` environment -variable: - - $ RUBYOPT='--disable-did_you_mean' irb - irb:0> 1.zeor? - # => NoMethodError (undefined method `zeor?' for 1:Integer) - -## Getting the original error message - -Sometimes, you do not want to disable the gem entirely, but need to get the -original error message without suggestions (e.g. testing). In this case, you -could use the `#original_message` method on the error object: - - no_method_error = begin - 1.zeor? - rescue NoMethodError => error - error - end - - no_method_error.message - # => NoMethodError (undefined method `zeor?' for 1:Integer) - # Did you mean? zero? - - no_method_error.original_message - # => NoMethodError (undefined method `zeor?' for 1:Integer) - - -**@example** -```ruby - -methosd -# => NameError: undefined local variable or method `methosd' for main:Object -# Did you mean? methods -# method - -OBject -# => NameError: uninitialized constant OBject -# Did you mean? Object - -@full_name = "Yuki Nishijima" -first_name, last_name = full_name.split(" ") -# => NameError: undefined local variable or method `full_name' for main:Object -# Did you mean? @full_name - -@@full_name = "Yuki Nishijima" -@@full_anme -# => NameError: uninitialized class variable @@full_anme in Object -# Did you mean? @@full_name - -full_name = "Yuki Nishijima" -full_name.starts_with?("Y") -# => NoMethodError: undefined method `starts_with?' for "Yuki Nishijima":String -# Did you mean? start_with? - -hash = {foo: 1, bar: 2, baz: 3} -hash.fetch(:fooo) -# => KeyError: key not found: :fooo -# Did you mean? :foo -``` -# Class Methods -## correct_error(error_class , spell_checker ) [](#method-c-correct_error) -Adds `DidYouMean` functionality to an error using a given spell checker -## formatter() [](#method-c-formatter) -Returns the currently set formatter. By default, it is set to -`DidYouMean::Formatter`. -## formatter=(formatter ) [](#method-c-formatter=) -Updates the primary formatter used to format the suggestions. -## spell_checkers() [](#method-c-spell_checkers) -Returns a sharable hash map of error types and spell checker objects. - diff --git a/example/ruby/DidYouMean/ClassNameChecker.md b/example/ruby/DidYouMean/ClassNameChecker.md deleted file mode 100644 index 1cf91ea..0000000 --- a/example/ruby/DidYouMean/ClassNameChecker.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: DidYouMean::ClassNameChecker -**Inherits:** Object - - - - -# Attributes -## class_name[RW] [](#attribute-i-class_name) -Returns the value of attribute class_name. - - -#Instance Methods -## class_names() [](#method-i-class_names) - -## corrections() [](#method-i-corrections) - -## initialize(exception) [](#method-i-initialize) - -**@return** [ClassNameChecker] a new instance of ClassNameChecker - -## scopes() [](#method-i-scopes) - diff --git a/example/ruby/DidYouMean/Correctable.md b/example/ruby/DidYouMean/Correctable.md deleted file mode 100644 index 8c8b64e..0000000 --- a/example/ruby/DidYouMean/Correctable.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: DidYouMean::Correctable - - - - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## detailed_message(highlight:true, did_you_mean:true) [](#method-i-detailed_message) - -## original_message() [](#method-i-original_message) -just for compatibility - -## spell_checker() [](#method-i-spell_checker) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/DidYouMean/Formatter.md b/example/ruby/DidYouMean/Formatter.md deleted file mode 100644 index df1d95c..0000000 --- a/example/ruby/DidYouMean/Formatter.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: DidYouMean::Formatter -**Inherits:** Object - - -The `DidYouMean::Formatter` is the basic, default formatter for the gem. The -formatter responds to the `message_for` method and it returns a human readable -string. - - -# Class Methods -## message_for(corrections ) [](#method-c-message_for) -Returns a human readable string that contains `corrections`. This formatter is -designed to be less verbose to not take too much screen space while being -helpful enough to the user. - -**@example** -```ruby - -formatter = DidYouMean::Formatter.new - -# displays suggestions in two lines with the leading empty line -puts formatter.message_for(["methods", "method"]) - -Did you mean? methods - method -# => nil - -# displays an empty line -puts formatter.message_for([]) - -# => nil -``` -#Instance Methods -## message_for(corrections) [](#method-i-message_for) - diff --git a/example/ruby/DidYouMean/Jaro.md b/example/ruby/DidYouMean/Jaro.md deleted file mode 100644 index 296cbe8..0000000 --- a/example/ruby/DidYouMean/Jaro.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: DidYouMean::Jaro - - - - -# Class Methods -## distance(str1 , str2 ) [](#method-c-distance) - diff --git a/example/ruby/DidYouMean/JaroWinkler.md b/example/ruby/DidYouMean/JaroWinkler.md deleted file mode 100644 index d27ab27..0000000 --- a/example/ruby/DidYouMean/JaroWinkler.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: DidYouMean::JaroWinkler - - - - -# Class Methods -## distance(str1 , str2 ) [](#method-c-distance) - diff --git a/example/ruby/DidYouMean/KeyErrorChecker.md b/example/ruby/DidYouMean/KeyErrorChecker.md deleted file mode 100644 index f642325..0000000 --- a/example/ruby/DidYouMean/KeyErrorChecker.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DidYouMean::KeyErrorChecker -**Inherits:** Object - - - - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize(key_error) [](#method-i-initialize) - -**@return** [KeyErrorChecker] a new instance of KeyErrorChecker - diff --git a/example/ruby/DidYouMean/Levenshtein.md b/example/ruby/DidYouMean/Levenshtein.md deleted file mode 100644 index 1c4d5bc..0000000 --- a/example/ruby/DidYouMean/Levenshtein.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: DidYouMean::Levenshtein - - -:nodoc: - - -# Class Methods -## distance(str1 , str2 ) [](#method-c-distance) -This code is based directly on the Text gem implementation Copyright (c) -2006-2013 Paul Battley, Michael Neumann, Tim Fletcher. - -Returns a value representing the "cost" of transforming str1 into str2 -## min3(a , b , c ) [](#method-c-min3) -detects the minimum value out of three arguments. This method is faster than -`[a, b, c].min` and puts less GC pressure. See -https://github.com/ruby/did_you_mean/pull/1 for a performance benchmark. - diff --git a/example/ruby/DidYouMean/MethodNameChecker.md b/example/ruby/DidYouMean/MethodNameChecker.md deleted file mode 100644 index 9375535..0000000 --- a/example/ruby/DidYouMean/MethodNameChecker.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: DidYouMean::MethodNameChecker -**Inherits:** Object - - - - -# Attributes -## method_name[RW] [](#attribute-i-method_name) -Returns the value of attribute method_name. - -## receiver[RW] [](#attribute-i-receiver) -Returns the value of attribute receiver. - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize(exception) [](#method-i-initialize) - -**@return** [MethodNameChecker] a new instance of MethodNameChecker - -## method_names() [](#method-i-method_names) - -## names_to_exclude() [](#method-i-names_to_exclude) - diff --git a/example/ruby/DidYouMean/NullChecker.md b/example/ruby/DidYouMean/NullChecker.md deleted file mode 100644 index 5f38e48..0000000 --- a/example/ruby/DidYouMean/NullChecker.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DidYouMean::NullChecker -**Inherits:** Object - - - - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize() [](#method-i-initialize) - -**@return** [NullChecker] a new instance of NullChecker - diff --git a/example/ruby/DidYouMean/PatternKeyNameChecker.md b/example/ruby/DidYouMean/PatternKeyNameChecker.md deleted file mode 100644 index 983e18c..0000000 --- a/example/ruby/DidYouMean/PatternKeyNameChecker.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DidYouMean::PatternKeyNameChecker -**Inherits:** Object - - - - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize(no_matching_pattern_key_error) [](#method-i-initialize) - -**@return** [PatternKeyNameChecker] a new instance of PatternKeyNameChecker - diff --git a/example/ruby/DidYouMean/RequirePathChecker.md b/example/ruby/DidYouMean/RequirePathChecker.md deleted file mode 100644 index 50ed7b7..0000000 --- a/example/ruby/DidYouMean/RequirePathChecker.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: DidYouMean::RequirePathChecker -**Inherits:** Object - - - - -# Class Methods -## requireables() [](#method-c-requireables) -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize(exception) [](#method-i-initialize) - -**@return** [RequirePathChecker] a new instance of RequirePathChecker - diff --git a/example/ruby/DidYouMean/SpellChecker.md b/example/ruby/DidYouMean/SpellChecker.md deleted file mode 100644 index 0a7f82f..0000000 --- a/example/ruby/DidYouMean/SpellChecker.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: DidYouMean::SpellChecker -**Inherits:** Object - - - - - -#Instance Methods -## correct(input) [](#method-i-correct) - -## initialize(dictionary:) [](#method-i-initialize) - -**@return** [SpellChecker] a new instance of SpellChecker - diff --git a/example/ruby/DidYouMean/TestHelper.md b/example/ruby/DidYouMean/TestHelper.md deleted file mode 100644 index 3e3de94..0000000 --- a/example/ruby/DidYouMean/TestHelper.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: DidYouMean::TestHelper - - - - -# Class Methods -## get_message(err ) [](#method-c-get_message) -## ractor_compatible?() [](#method-c-ractor_compatible?) -**@return** [Boolean] - -# Attributes -## root[RW] [](#attribute-c-root) -Returns the value of attribute root. - - -#Instance Methods -## assert_correction(expected, array) [](#method-i-assert_correction) - diff --git a/example/ruby/DidYouMean/TreeSpellChecker.md b/example/ruby/DidYouMean/TreeSpellChecker.md deleted file mode 100644 index a670778..0000000 --- a/example/ruby/DidYouMean/TreeSpellChecker.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: DidYouMean::TreeSpellChecker -**Inherits:** Object - - -spell checker for a dictionary that has a tree structure, see -doc/tree_spell_checker_api.md - - -# Attributes -## augment[RW] [](#attribute-i-augment) -Returns the value of attribute augment. - -## dictionary[RW] [](#attribute-i-dictionary) -Returns the value of attribute dictionary. - -## separator[RW] [](#attribute-i-separator) -Returns the value of attribute separator. - - -#Instance Methods -## correct(input) [](#method-i-correct) - -## dictionary_without_leaves() [](#method-i-dictionary_without_leaves) - -## dimensions() [](#method-i-dimensions) - -## find_leaves(path) [](#method-i-find_leaves) - -## initialize(dictionary:, separator:'/', augment:nil) [](#method-i-initialize) - -**@return** [TreeSpellChecker] a new instance of TreeSpellChecker - -## plausible_dimensions(input) [](#method-i-plausible_dimensions) - -## possible_paths(states) [](#method-i-possible_paths) - -## tree_depth() [](#method-i-tree_depth) - diff --git a/example/ruby/DidYouMean/VariableNameChecker.md b/example/ruby/DidYouMean/VariableNameChecker.md deleted file mode 100644 index 60bab46..0000000 --- a/example/ruby/DidYouMean/VariableNameChecker.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: DidYouMean::VariableNameChecker -**Inherits:** Object - - - - -# Attributes -## cvar_names[RW] [](#attribute-i-cvar_names) -Returns the value of attribute cvar_names. - -## ivar_names[RW] [](#attribute-i-ivar_names) -Returns the value of attribute ivar_names. - -## lvar_names[RW] [](#attribute-i-lvar_names) -Returns the value of attribute lvar_names. - -## method_names[RW] [](#attribute-i-method_names) -Returns the value of attribute method_names. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize(exception) [](#method-i-initialize) - -**@return** [VariableNameChecker] a new instance of VariableNameChecker - diff --git a/example/ruby/DifferentOFS.md b/example/ruby/DifferentOFS.md deleted file mode 100644 index be49cd0..0000000 --- a/example/ruby/DifferentOFS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: DifferentOFS - - - - -# Class Methods -## extended(klass ) [](#method-c-extended) -**@private** [] - - diff --git a/example/ruby/DifferentOFS/WithDifferentOFS.md b/example/ruby/DifferentOFS/WithDifferentOFS.md deleted file mode 100644 index f886739..0000000 --- a/example/ruby/DifferentOFS/WithDifferentOFS.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: DifferentOFS::WithDifferentOFS - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/Digest.md b/example/ruby/Digest.md deleted file mode 100644 index 2d98289..0000000 --- a/example/ruby/Digest.md +++ /dev/null @@ -1,161 +0,0 @@ -# Module: Digest - - -This module provides a framework for message digest libraries. - -You may want to look at OpenSSL::Digest as it supports more algorithms. - -A cryptographic hash function is a procedure that takes data and returns a -fixed bit string: the hash value, also known as *digest*. Hash functions are -also called one-way functions, it is easy to compute a digest from a message, -but it is infeasible to generate a message from a digest. - -## Examples - - require 'digest' - - # Compute a complete digest - Digest::SHA256.digest 'message' #=> "\xABS\n\x13\xE4Y..." - - sha256 = Digest::SHA256.new - sha256.digest 'message' #=> "\xABS\n\x13\xE4Y..." - - # Other encoding formats - Digest::SHA256.hexdigest 'message' #=> "ab530a13e459..." - Digest::SHA256.base64digest 'message' #=> "q1MKE+RZFJgr..." - - # Compute digest by chunks - md5 = Digest::MD5.new - md5.update 'message1' - md5 << 'message2' # << is an alias for update - - md5.hexdigest #=> "94af09c09bb9..." - - # Compute digest for a file - sha256 = Digest::SHA256.file 'testfile' - sha256.hexdigest - -Additionally digests can be encoded in "bubble babble" format as a sequence of -consonants and vowels which is more recognizable and comparable than a -hexadecimal digest. - - require 'digest/bubblebabble' - - Digest::SHA256.bubblebabble 'message' #=> "xopoh-fedac-fenyh-..." - -See the bubble babble specification at -http://web.mit.edu/kenta/www/one/bubblebabble/spec/jrtrjwzi/draft-huima-01.txt -. - -## Digest algorithms - -Different digest algorithms (or hash functions) are available: - -MD5 -: See RFC 1321 The MD5 Message-Digest Algorithm - -RIPEMD-160 -: As Digest::RMD160. See - http://homes.esat.kuleuven.be/~bosselae/ripemd160.html. - -SHA1 -: See FIPS 180 Secure Hash Standard. - -SHA2 family -: See FIPS 180 Secure Hash Standard which defines the following algorithms: - * SHA512 - * SHA384 - * SHA256 - - -The latest versions of the FIPS publications can be found here: -http://csrc.nist.gov/publications/PubsFIPS.html. - - -# Class Methods -## bubblebabble(str ) [](#method-c-bubblebabble) -call-seq: - Digest.bubblebabble(string) -> bubblebabble_string - -Returns a BubbleBabble encoded version of a given *string*. -## const_missing(name ) [](#method-c-const_missing) -:nodoc: -## digests() [](#method-c-digests) -Returns the names of all available digests in an array. -**@overload** [] - -## hexencode(str ) [](#method-c-hexencode) -Generates a hex-encoded version of a given *string*. -**@overload** [] - - -#Instance Methods -## block_length() [](#method-i-block_length) -Returns the block length of the digest algorithm, i.e. the length in bytes of -an individual block. Most modern algorithms partition a message to be digested -into a sequence of fix-sized blocks that are processed consecutively. - -### Example - digest = OpenSSL::Digest.new('SHA1') - puts digest.block_length # => 64 - -**@overload** [] - -## digest_length() [](#method-i-digest_length) -Returns the output size of the digest, i.e. the length in bytes of the final -message digest result. - -### Example - digest = OpenSSL::Digest.new('SHA1') - puts digest.digest_length # => 20 - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a Digest instance based on *string*, which is either the ln (long -name) or sn (short name) of a supported digest algorithm. A list of supported -algorithms can be obtained by calling OpenSSL::Digest.digests. - -If *data* (a String) is given, it is used as the initial input to the Digest -instance, i.e. - - digest = OpenSSL::Digest.new('sha256', 'digestdata') - -is equivalent to - - digest = OpenSSL::Digest.new('sha256') - digest.update('digestdata') - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## name() [](#method-i-name) -Returns the short name of this Digest algorithm which may differ slightly from -the original name provided. - -### Example - digest = OpenSSL::Digest.new('SHA512') - puts digest.name # => SHA512 - -**@overload** [] - -## reset() [](#method-i-reset) -Resets the Digest in the sense that any Digest#update that has been performed -is abandoned and the Digest is set to its initial state again. - -**@overload** [] - -## update(data) [](#method-i-update) -Not every message digest can be computed in one single pass. If a message -digest is to be computed from several subsequent sources, then each may be -passed individually to the Digest instance. - -### Example - digest = OpenSSL::Digest.new('SHA256') - digest.update('First input') - digest << 'Second input' # equivalent to digest.update('Second input') - result = digest.digest - -**@overload** [] - diff --git a/example/ruby/Digest/Base.md b/example/ruby/Digest/Base.md deleted file mode 100644 index 2689aa1..0000000 --- a/example/ruby/Digest/Base.md +++ /dev/null @@ -1,75 +0,0 @@ -# Class: Digest::Base -**Inherits:** Digest::Class - - -This abstract class provides a common interface to message digest -implementation classes written in C. - -## Write a Digest subclass in C -Digest::Base provides a common interface to message digest classes written in -C. These classes must provide a struct of type rb_digest_metadata_t: - typedef int (*rb_digest_hash_init_func_t)(void *); - typedef void (*rb_digest_hash_update_func_t)(void *, unsigned char *, size_t); - typedef int (*rb_digest_hash_finish_func_t)(void *, unsigned char *); - - typedef struct { - int api_version; - size_t digest_len; - size_t block_len; - size_t ctx_size; - rb_digest_hash_init_func_t init_func; - rb_digest_hash_update_func_t update_func; - rb_digest_hash_finish_func_t finish_func; - } rb_digest_metadata_t; - -This structure must be set as an instance variable named `metadata` (without -the +@+ in front of the name). By example: - static const rb_digest_metadata_t sha1 = { - RUBY_DIGEST_API_VERSION, - SHA1_DIGEST_LENGTH, - SHA1_BLOCK_LENGTH, - sizeof(SHA1_CTX), - (rb_digest_hash_init_func_t)SHA1_Init, - (rb_digest_hash_update_func_t)SHA1_Update, - (rb_digest_hash_finish_func_t)SHA1_Finish, - }; - - rb_ivar_set(cDigest_SHA1, rb_intern("metadata"), - - rb_digest_make_metadata(&sha1)); - - - -#Instance Methods -## <<(str) [](#method-i-<<) -Update the digest using given *string* and return `self`. - -**@overload** [] - -**@overload** [] - -## block_length() [](#method-i-block_length) -Return the block length of the digest in bytes. - -**@overload** [] - -## digest_length() [](#method-i-digest_length) -Return the length of the hash value in bytes. - -**@overload** [] - -## initialize_copy(obj) [](#method-i-initialize_copy) -:nodoc: - -## reset() [](#method-i-reset) -Reset the digest to its initial state and return `self`. - -**@overload** [] - -## update(str) [](#method-i-update) -Update the digest using given *string* and return `self`. - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Digest/Class.md b/example/ruby/Digest/Class.md deleted file mode 100644 index 7e9d11f..0000000 --- a/example/ruby/Digest/Class.md +++ /dev/null @@ -1,179 +0,0 @@ -# Class: Digest::Class -**Inherits:** Object - -**Includes:** Digest::Instance - - -This module stands as a base class for digest implementation classes. - - -# Class Methods -## base64digest(str , *args ) [](#method-c-base64digest) -Returns the base64 encoded hash value of a given *string*. The return value -is properly padded with '=' and contains no line feeds. -## bubblebabble(*args ) [](#method-c-bubblebabble) -call-seq: - Digest::Class.bubblebabble(string, ...) -> hash_string - -Returns the BubbleBabble encoded hash value of a given *string*. -## digest(*args ) [](#method-c-digest) -Returns the hash value of a given *string*. This is equivalent to -Digest::Class.new(*parameters).digest(string), where extra *parameters*, if -any, are passed through to the constructor and the *string* is passed to -#digest(). -**@overload** [] - -## file(name , *args ) [](#method-c-file) -Creates a digest object and reads a given file, *name*. Optional arguments are -passed to the constructor of the digest class. - - p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest - # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534" -## hexdigest(*args ) [](#method-c-hexdigest) -Returns the hex-encoded hash value of a given *string*. This is almost -equivalent to Digest.hexencode(Digest::Class.new(*parameters).digest(string)). -**@overload** [] - - -#Instance Methods -## <<(str) [](#method-i-<<) -Updates the digest using a given *string* and returns self. - -The update() method and the left-shift operator are overridden by each -implementation subclass. (One should be an alias for the other) - -**@overload** [] - -**@overload** [] - -## ==(other) [](#method-i-==) -If a string is given, checks whether it is equal to the hex-encoded hash value -of the digest object. If another digest instance is given, checks whether -they have the same hash value. Otherwise returns false. - -**@overload** [] - -**@overload** [] - -## base64digest(strnil) [](#method-i-base64digest) -If none is given, returns the resulting hash value of the digest in a base64 -encoded form, keeping the digest's state. - -If a `string` is given, returns the hash value for the given `string` in a -base64 encoded form, resetting the digest to the initial state before and -after the process. - -In either case, the return value is properly padded with '=' and contains no -line feeds. - -## base64digest!() [](#method-i-base64digest!) -Returns the resulting hash value and resets the digest to the initial state. - -## block_length() [](#method-i-block_length) -Returns the block length of the digest. - -This method is overridden by each implementation subclass. - -**@overload** [] - -## bubblebabble() [](#method-i-bubblebabble) -call-seq: - digest_obj.bubblebabble -> hash_string - -Returns the resulting hash value in a Bubblebabble encoded form. - -## digest(*args) [](#method-i-digest) -If none is given, returns the resulting hash value of the digest, keeping the -digest's state. - -If a *string* is given, returns the hash value for the given *string*, -resetting the digest to the initial state before and after the process. - -**@overload** [] - -**@overload** [] - -## digest!() [](#method-i-digest!) -Returns the resulting hash value and resets the digest to the initial state. - -**@overload** [] - -## digest_length() [](#method-i-digest_length) -Returns the length of the hash value of the digest. - -This method should be overridden by each implementation subclass. If not, -digest_obj.digest().length() is returned. - -**@overload** [] - -## file(name) [](#method-i-file) -Updates the digest with the contents of a given file *name* and returns self. - -## hexdigest(*args) [](#method-i-hexdigest) -If none is given, returns the resulting hash value of the digest in a -hex-encoded form, keeping the digest's state. - -If a *string* is given, returns the hash value for the given *string* in a -hex-encoded form, resetting the digest to the initial state before and after -the process. - -**@overload** [] - -**@overload** [] - -## hexdigest!() [](#method-i-hexdigest!) -Returns the resulting hash value in a hex-encoded form and resets the digest -to the initial state. - -**@overload** [] - -## initialize() [](#method-i-initialize) -:nodoc: - -## inspect() [](#method-i-inspect) -Creates a printable version of the digest object. - -**@overload** [] - -## length() [](#method-i-length) -Returns digest_obj.digest_length(). - -**@overload** [] - -**@overload** [] - -## new() [](#method-i-new) -Returns a new, initialized copy of the digest object. Equivalent to -digest_obj.clone().reset(). - -**@overload** [] - -## reset() [](#method-i-reset) -Resets the digest to the initial state and returns self. - -This method is overridden by each implementation subclass. - -**@overload** [] - -## size() [](#method-i-size) -Returns digest_obj.digest_length(). - -**@overload** [] - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns digest_obj.hexdigest(). - -**@overload** [] - -## update(str) [](#method-i-update) -Updates the digest using a given *string* and returns self. - -The update() method and the left-shift operator are overridden by each -implementation subclass. (One should be an alias for the other) - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Digest/DigestError.md b/example/ruby/Digest/DigestError.md deleted file mode 100644 index 2b4f740..0000000 --- a/example/ruby/Digest/DigestError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Digest::DigestError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/Digest/Foo.md b/example/ruby/Digest/Foo.md deleted file mode 100644 index 948ed77..0000000 --- a/example/ruby/Digest/Foo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Digest::Foo -**Inherits:** Digest::Class - - - - - diff --git a/example/ruby/Digest/Instance.md b/example/ruby/Digest/Instance.md deleted file mode 100644 index bf8b9c0..0000000 --- a/example/ruby/Digest/Instance.md +++ /dev/null @@ -1,147 +0,0 @@ -# Module: Digest::Instance - - -This module provides instance methods for a digest implementation object to -calculate message digest values. - - - -#Instance Methods -## <<(str) [](#method-i-<<) -Updates the digest using a given *string* and returns self. - -The update() method and the left-shift operator are overridden by each -implementation subclass. (One should be an alias for the other) - -**@overload** [] - -**@overload** [] - -## ==(other) [](#method-i-==) -If a string is given, checks whether it is equal to the hex-encoded hash value -of the digest object. If another digest instance is given, checks whether -they have the same hash value. Otherwise returns false. - -**@overload** [] - -**@overload** [] - -## base64digest(strnil) [](#method-i-base64digest) -If none is given, returns the resulting hash value of the digest in a base64 -encoded form, keeping the digest's state. - -If a `string` is given, returns the hash value for the given `string` in a -base64 encoded form, resetting the digest to the initial state before and -after the process. - -In either case, the return value is properly padded with '=' and contains no -line feeds. - -## base64digest!() [](#method-i-base64digest!) -Returns the resulting hash value and resets the digest to the initial state. - -## block_length() [](#method-i-block_length) -Returns the block length of the digest. - -This method is overridden by each implementation subclass. - -**@overload** [] - -## bubblebabble() [](#method-i-bubblebabble) -call-seq: - digest_obj.bubblebabble -> hash_string - -Returns the resulting hash value in a Bubblebabble encoded form. - -## digest(*args) [](#method-i-digest) -If none is given, returns the resulting hash value of the digest, keeping the -digest's state. - -If a *string* is given, returns the hash value for the given *string*, -resetting the digest to the initial state before and after the process. - -**@overload** [] - -**@overload** [] - -## digest!() [](#method-i-digest!) -Returns the resulting hash value and resets the digest to the initial state. - -**@overload** [] - -## digest_length() [](#method-i-digest_length) -Returns the length of the hash value of the digest. - -This method should be overridden by each implementation subclass. If not, -digest_obj.digest().length() is returned. - -**@overload** [] - -## file(name) [](#method-i-file) -Updates the digest with the contents of a given file *name* and returns self. - -## hexdigest(*args) [](#method-i-hexdigest) -If none is given, returns the resulting hash value of the digest in a -hex-encoded form, keeping the digest's state. - -If a *string* is given, returns the hash value for the given *string* in a -hex-encoded form, resetting the digest to the initial state before and after -the process. - -**@overload** [] - -**@overload** [] - -## hexdigest!() [](#method-i-hexdigest!) -Returns the resulting hash value in a hex-encoded form and resets the digest -to the initial state. - -**@overload** [] - -## inspect() [](#method-i-inspect) -Creates a printable version of the digest object. - -**@overload** [] - -## length() [](#method-i-length) -Returns digest_obj.digest_length(). - -**@overload** [] - -**@overload** [] - -## new() [](#method-i-new) -Returns a new, initialized copy of the digest object. Equivalent to -digest_obj.clone().reset(). - -**@overload** [] - -## reset() [](#method-i-reset) -Resets the digest to the initial state and returns self. - -This method is overridden by each implementation subclass. - -**@overload** [] - -## size() [](#method-i-size) -Returns digest_obj.digest_length(). - -**@overload** [] - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns digest_obj.hexdigest(). - -**@overload** [] - -## update(str) [](#method-i-update) -Updates the digest using a given *string* and returns self. - -The update() method and the left-shift operator are overridden by each -implementation subclass. (One should be an alias for the other) - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Digest/MD5.md b/example/ruby/Digest/MD5.md deleted file mode 100644 index 290145f..0000000 --- a/example/ruby/Digest/MD5.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Digest::MD5 -**Inherits:** Digest_Base - - -A class for calculating message digests using the MD5 Message-Digest Algorithm -by RSA Data Security, Inc., described in RFC1321. - -MD5 calculates a digest of 128 bits (16 bytes). - -## Examples - require 'digest' - - # Compute a complete digest - Digest::MD5.hexdigest 'abc' #=> "90015098..." - - # Compute digest by chunks - md5 = Digest::MD5.new # =># - md5.update "ab" - md5 << "c" # alias for #update - md5.hexdigest # => "90015098..." - - # Use the same object to compute another digest - md5.reset - md5 << "message" - md5.hexdigest # => "78e73102..." - - - diff --git a/example/ruby/Digest/RMD160.md b/example/ruby/Digest/RMD160.md deleted file mode 100644 index 9fce4aa..0000000 --- a/example/ruby/Digest/RMD160.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Digest::RMD160 -**Inherits:** Digest_Base - - -A class for calculating message digests using RIPEMD-160 cryptographic hash -function, designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel. - -RMD160 calculates a digest of 160 bits (20 bytes). - -## Examples - require 'digest' - - # Compute a complete digest - Digest::RMD160.hexdigest 'abc' #=> "8eb208f7..." - - # Compute digest by chunks - rmd160 = Digest::RMD160.new # =># - rmd160.update "ab" - rmd160 << "c" # alias for #update - rmd160.hexdigest # => "8eb208f7..." - - # Use the same object to compute another digest - rmd160.reset - rmd160 << "message" - rmd160.hexdigest # => "1dddbe1b..." - - - diff --git a/example/ruby/Digest/SHA1.md b/example/ruby/Digest/SHA1.md deleted file mode 100644 index ea784f3..0000000 --- a/example/ruby/Digest/SHA1.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Digest::SHA1 -**Inherits:** Digest_Base - - -A class for calculating message digests using the SHA-1 Secure Hash Algorithm -by NIST (the US' National Institute of Standards and Technology), described in -FIPS PUB 180-1. - -See Digest::Instance for digest API. - -SHA-1 calculates a digest of 160 bits (20 bytes). - -## Examples - require 'digest' - - # Compute a complete digest - Digest::SHA1.hexdigest 'abc' #=> "a9993e36..." - - # Compute digest by chunks - sha1 = Digest::SHA1.new # =># - sha1.update "ab" - sha1 << "c" # alias for #update - sha1.hexdigest # => "a9993e36..." - - # Use the same object to compute another digest - sha1.reset - sha1 << "message" - sha1.hexdigest # => "6f9b9af3..." - - - diff --git a/example/ruby/Digest/SHA2.md b/example/ruby/Digest/SHA2.md deleted file mode 100644 index 09a0bd8..0000000 --- a/example/ruby/Digest/SHA2.md +++ /dev/null @@ -1,101 +0,0 @@ -# Class: Digest::SHA2 -**Inherits:** Digest::Class - - -A meta digest provider class for SHA256, SHA384 and SHA512. - -FIPS 180-2 describes SHA2 family of digest algorithms. It defines three -algorithms: -* one which works on chunks of 512 bits and returns a 256-bit digest - (SHA256), -* one which works on chunks of 1024 bits and returns a 384-bit digest - (SHA384), -* and one which works on chunks of 1024 bits and returns a 512-bit digest - (SHA512). - -## Examples - require 'digest' - - # Compute a complete digest - Digest::SHA2.hexdigest 'abc' # => "ba7816bf8..." - Digest::SHA2.new(256).hexdigest 'abc' # => "ba7816bf8..." - Digest::SHA256.hexdigest 'abc' # => "ba7816bf8..." - - Digest::SHA2.new(384).hexdigest 'abc' # => "cb00753f4..." - Digest::SHA384.hexdigest 'abc' # => "cb00753f4..." - - Digest::SHA2.new(512).hexdigest 'abc' # => "ddaf35a19..." - Digest::SHA512.hexdigest 'abc' # => "ddaf35a19..." - - # Compute digest by chunks - sha2 = Digest::SHA2.new # =># - sha2.update "ab" - sha2 << "c" # alias for #update - sha2.hexdigest # => "ba7816bf8..." - - # Use the same object to compute another digest - sha2.reset - sha2 << "message" - sha2.hexdigest # => "ab530a13e..." - - - -#Instance Methods -## block_length() [](#method-i-block_length) -call-seq: - digest_obj.block_length -> Integer - -Return the block length of the digest in bytes. - - Digest::SHA256.new.block_length * 8 - # => 512 - Digest::SHA384.new.block_length * 8 - # => 1024 - Digest::SHA512.new.block_length * 8 - # => 1024 - -## digest_length() [](#method-i-digest_length) -call-seq: - digest_obj.digest_length -> Integer - -Return the length of the hash value (the digest) in bytes. - - Digest::SHA256.new.digest_length * 8 - # => 256 - Digest::SHA384.new.digest_length * 8 - # => 384 - Digest::SHA512.new.digest_length * 8 - # => 512 - -For example, digests produced by Digest::SHA256 will always be 32 bytes (256 -bits) in size. - -## initialize(bitlen256) [](#method-i-initialize) -call-seq: - Digest::SHA2.new(bitlen = 256) -> digest_obj - -Create a new SHA2 hash object with a given bit length. - -Valid bit lengths are 256, 384 and 512. - -**@return** [SHA2] a new instance of SHA2 - -## initialize_copy(other) [](#method-i-initialize_copy) -:nodoc: - -## inspect() [](#method-i-inspect) -:nodoc: - -## reset() [](#method-i-reset) -call-seq: - digest_obj.reset -> digest_obj - -Reset the digest to the initial state and return self. - -## update(str) [](#method-i-update) -call-seq: - digest_obj.update(string) -> digest_obj - digest_obj << string -> digest_obj - -Update the digest using a given *string* and return self. - diff --git a/example/ruby/Digest/SHA256.md b/example/ruby/Digest/SHA256.md deleted file mode 100644 index 49a258d..0000000 --- a/example/ruby/Digest/SHA256.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Digest::SHA256 -**Inherits:** Digest_Base - - -Classes for calculating message digests using the SHA-256/384/512 Secure Hash -Algorithm(s) by NIST (the US' National Institute of Standards and Technology), -described in FIPS PUB 180-2. - -See SHA2. - - - diff --git a/example/ruby/Digest/SHA384.md b/example/ruby/Digest/SHA384.md deleted file mode 100644 index a4f6683..0000000 --- a/example/ruby/Digest/SHA384.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Digest::SHA384 -**Inherits:** Digest_Base - - -Classes for calculating message digests using the SHA-256/384/512 Secure Hash -Algorithm(s) by NIST (the US' National Institute of Standards and Technology), -described in FIPS PUB 180-2. - -See SHA2. - - - diff --git a/example/ruby/Digest/SHA512.md b/example/ruby/Digest/SHA512.md deleted file mode 100644 index 8570dcf..0000000 --- a/example/ruby/Digest/SHA512.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Digest::SHA512 -**Inherits:** Digest_Base - - -Classes for calculating message digests using the SHA-256/384/512 Secure Hash -Algorithm(s) by NIST (the US' National Institute of Standards and Technology), -described in FIPS PUB 180-2. - -See SHA2. - - - diff --git a/example/ruby/Dir.md b/example/ruby/Dir.md deleted file mode 100644 index f222723..0000000 --- a/example/ruby/Dir.md +++ /dev/null @@ -1,2935 +0,0 @@ -# Class: Dir -**Inherits:** Object - -**Includes:** Enumerable - - -An object of class Dir represents a directory in the underlying file system. - -It consists mainly of: - -* A string *path*, given when the object is created, that specifies a - directory in the underlying file system; method #path returns the path. -* A collection of string *entry names*, each of which is the name of a - directory or file in the underlying file system; the entry names may be - retrieved in an [array-like fashion](rdoc-ref:Dir@Dir+As+Array-Like) or in - a [stream-like fashion](rdoc-ref:Dir@Dir+As+Stream-Like). - -## About the Examples - -Some examples on this page use this simple file tree: - - example/ - ├── config.h - ├── lib/ - │ ├── song/ - │ │ └── karaoke.rb - │ └── song.rb - └── main.rb - -Others use the file tree for the [Ruby project -itself](https://github.com/ruby/ruby). - -## Dir As Array-Like - -A Dir object is in some ways array-like: - -* It has instance methods #children, #each, and #each_child. -* It includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here). - -## Dir As Stream-Like - -A Dir object is in some ways stream-like. - -The stream is initially open for reading, but may be closed manually (using -method #close), and will be closed on block exit if created by Dir.open called -with a block. The closed stream may not be further manipulated, and may not be -reopened. - -The stream has a *position*, which is the index of an entry in the directory: - -* The initial position is zero (before the first entry). -* Method #tell (aliased as #pos) returns the position. -* Method #pos= sets the position (but ignores a value outside the stream), - and returns the position. -* Method #seek is like #pos=, but returns `self` (convenient for chaining). -* Method #read, if not at end-of-stream, reads the next entry and increments - the position; if at end-of-stream, does not increment the position. -* Method #rewind sets the position to zero. - -Examples (using the [simple file tree](rdoc-ref:Dir@About+the+Examples)): - - dir = Dir.new('example') # => # - dir.pos # => 0 - - dir.read # => "." - dir.read # => ".." - dir.read # => "config.h" - dir.read # => "lib" - dir.read # => "main.rb" - dir.pos # => 5 - dir.read # => nil - dir.pos # => 5 - - dir.rewind # => # - dir.pos # => 0 - - dir.pos = 3 # => 3 - dir.pos # => 3 - - dir.seek(4) # => # - dir.pos # => 4 - - dir.close # => nil - dir.read # Raises IOError. - -## What's Here - -First, what's elsewhere. Class Dir: - -* Inherits from [class Object](rdoc-ref:Object@What-27s+Here). -* Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which - provides dozens of additional methods. - -Here, class Dir provides methods that are useful for: - -* [Reading](rdoc-ref:Dir@Reading) -* [Setting](rdoc-ref:Dir@Setting) -* [Querying](rdoc-ref:Dir@Querying) -* [Iterating](rdoc-ref:Dir@Iterating) -* [Other](rdoc-ref:Dir@Other) - -### Reading - -* #close: Closes the directory stream for `self`. -* #pos=: Sets the position in the directory stream for `self`. -* #read: Reads and returns the next entry in the directory stream for - `self`. -* #rewind: Sets the position in the directory stream for `self` to the first - entry. -* #seek: Sets the position in the directory stream for `self` the entry at - the given offset. - -### Setting - -* ::chdir: Changes the working directory of the current process to the given - directory. -* ::chroot: Changes the file-system root for the current process to the - given directory. - -### Querying - -* ::[]: Same as ::glob without the ability to pass flags. -* ::children: Returns an array of names of the children (both files and - directories) of the given directory, but not including `.` or `..`. -* ::empty?: Returns whether the given path is an empty directory. -* ::entries: Returns an array of names of the children (both files and - directories) of the given directory, including `.` and `..`. -* ::exist?: Returns whether the given path is a directory. -* ::getwd (aliased as #pwd): Returns the path to the current working - directory. -* ::glob: Returns an array of file paths matching the given pattern and - flags. -* ::home: Returns the home directory path for a given user or the current - user. -* #children: Returns an array of names of the children (both files and - directories) of `self`, but not including `.` or `..`. -* #fileno: Returns the integer file descriptor for `self`. -* #path (aliased as #to_path): Returns the path used to create `self`. -* #tell (aliased as #pos): Returns the integer position in the directory - stream for `self`. - -### Iterating - -* ::each_child: Calls the given block with each entry in the given - directory, but not including `.` or `..`. -* ::foreach: Calls the given block with each entry in the given directory, - including `.` and `..`. -* #each: Calls the given block with each entry in `self`, including `.` and - `..`. -* #each_child: Calls the given block with each entry in `self`, but not - including `.` or `..`. - -### Other - -* ::mkdir: Creates a directory at the given path, with optional permissions. -* ::new: Returns a new Dir for the given path, with optional encoding. -* ::open: Same as ::new, but if a block is given, yields the Dir to the - block, closing it upon block exit. -* ::unlink (aliased as ::delete and ::rmdir): Removes the given directory. -* #inspect: Returns a string description of `self`. - - -# Class Methods -## [](*args , base: nil, sort: true) [](#method-c-[]) -call-seq: - Dir[*patterns, base: nil, sort: true] -> array - -Calls Dir.glob with argument `patterns` and the values of keyword arguments -`base` and `sort`; returns the array of selected entry names. -## chdir(*args ) [](#method-c-chdir) -Changes the current working directory. - -With argument `new_dirpath` and no block, changes to the given `dirpath`: - - Dir.pwd # => "/example" - Dir.chdir('..') # => 0 - Dir.pwd # => "/" - -With no argument and no block: - -* Changes to the value of environment variable `HOME` if defined. -* Otherwise changes to the value of environment variable `LOGDIR` if - defined. -* Otherwise makes no change. - -With argument `new_dirpath` and a block, temporarily changes the working -directory: - -* Calls the block with the argument. -* Changes to the given directory. -* Executes the block (yielding the new path). -* Restores the previous working directory. -* Returns the block's return value. - -Example: - - Dir.chdir('/var/spool/mail') - Dir.pwd # => "/var/spool/mail" - Dir.chdir('/tmp') do - Dir.pwd # => "/tmp" - end - Dir.pwd # => "/var/spool/mail" - -With no argument and a block, calls the block with the current working -directory (string) and returns the block's return value. - -Calls to Dir.chdir with blocks may be nested: - - Dir.chdir('/var/spool/mail') - Dir.pwd # => "/var/spool/mail" - Dir.chdir('/tmp') do - Dir.pwd # => "/tmp" - Dir.chdir('/usr') do - Dir.pwd # => "/usr" - end - Dir.pwd # => "/tmp" - end - Dir.pwd # => "/var/spool/mail" - -In a multi-threaded program an error is raised if a thread attempts to open a -`chdir` block while another thread has one open, or a call to `chdir` without -a block occurs inside a block passed to `chdir` (even in the same thread). - -Raises an exception if the target directory does not exist. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## children(*args ) [](#method-c-children) -Returns an array of the entry names in the directory at `dirpath` except for -`'.'` and `'..'`; sets the given encoding onto each returned entry name: - - Dir.children('/example') # => ["config.h", "lib", "main.rb"] - Dir.children('/example').first.encoding - # => # - Dir.children('/example', encoding: 'US-ASCII').first.encoding - # => # - -See [String Encoding](rdoc-ref:encodings.rdoc@String+Encoding). - -Raises an exception if the directory does not exist. -**@overload** [] - -**@overload** [] - -## chroot(path ) [](#method-c-chroot) -Changes the root directory of the calling process to that specified in -`dirpath`. The new root directory is used for pathnames beginning with `'/'`. -The root directory is inherited by all children of the calling process. - -Only a privileged process may call `chroot`. - -See [Linux chroot](https://man7.org/linux/man-pages/man2/chroot.2.html). -**@overload** [] - -## delete(dir ) [](#method-c-delete) -Removes the directory at `dirpath` from the underlying file system: - - Dir.rmdir('foo') # => 0 - -Raises an exception if the directory is not empty. -**@overload** [] - -## each_child(*args ) [](#method-c-each_child) -Like Dir.foreach, except that entries `'.'` and `'..'` are not included. -**@overload** [] - -**@overload** [] - -## empty?(dirname ) [](#method-c-empty?) -Returns whether `dirpath` specifies an empty directory: - - dirpath = '/tmp/foo' - Dir.mkdir(dirpath) - Dir.empty?(dirpath) # => true - Dir.empty?('/example') # => false - Dir.empty?('/example/main.rb') # => false - -Raises an exception if `dirpath` does not specify a directory or file in the -underlying file system. -**@overload** [] - -## entries(*args ) [](#method-c-entries) -Returns an array of the entry names in the directory at `dirpath`; sets the -given encoding onto each returned entry name: - - Dir.entries('/example') # => ["config.h", "lib", "main.rb", "..", "."] - Dir.entries('/example').first.encoding - # => # - Dir.entries('/example', encoding: 'US-ASCII').first.encoding - # => # - -See [String Encoding](rdoc-ref:encodings.rdoc@String+Encoding). - -Raises an exception if the directory does not exist. -**@overload** [] - -## exist?() [](#method-c-exist?) -Returns whether `dirpath` is a directory in the underlying file system: - - Dir.exist?('/example') # => true - Dir.exist?('/nosuch') # => false - Dir.exist?('/example/main.rb') # => false - -Same as File.directory?. -**@overload** [] - -## fchdir(fd_value ) [](#method-c-fchdir) -Changes the current working directory to the directory specified by the -integer file descriptor `fd`. - -When passing a file descriptor over a UNIX socket or to a child process, using -`fchdir` instead of `chdir` avoids the [time-of-check to time-of-use -vulnerability](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use) - -With no block, changes to the directory given by `fd`: - - Dir.chdir('/var/spool/mail') - Dir.pwd # => "/var/spool/mail" - dir = Dir.new('/usr') - fd = dir.fileno - Dir.fchdir(fd) - Dir.pwd # => "/usr" - -With a block, temporarily changes the working directory: - -* Calls the block with the argument. -* Changes to the given directory. -* Executes the block (yields no args). -* Restores the previous working directory. -* Returns the block's return value. - -Example: - - Dir.chdir('/var/spool/mail') - Dir.pwd # => "/var/spool/mail" - dir = Dir.new('/tmp') - fd = dir.fileno - Dir.fchdir(fd) do - Dir.pwd # => "/tmp" - end - Dir.pwd # => "/var/spool/mail" - -This method uses the -[fchdir()](https://www.man7.org/linux/man-pages/man3/fchdir.3p.html) function -defined by POSIX 2008; the method is not implemented on non-POSIX platforms -(raises NotImplementedError). - -Raises an exception if the file descriptor is not valid. - -In a multi-threaded program an error is raised if a thread attempts to open a -`chdir` block while another thread has one open, or a call to `chdir` without -a block occurs inside a block passed to `chdir` (even in the same thread). -**@overload** [] - -**@overload** [] - -## for_fd(fd ) [](#method-c-for_fd) -Returns a new Dir object representing the directory specified by the given -integer directory file descriptor `fd`: - - d0 = Dir.new('..') - d1 = Dir.for_fd(d0.fileno) - -Note that the returned `d1` does not have an associated path: - - d0.path # => '..' - d1.path # => nil - -This method uses the -[fdopendir()](https://www.man7.org/linux/man-pages/man3/fdopendir.3p.html) -function defined by POSIX 2008; the method is not implemented on non-POSIX -platforms (raises NotImplementedError). -**@overload** [] - -## foreach(*args ) [](#method-c-foreach) -Calls the block with each entry name in the directory at `dirpath`; sets the -given encoding onto each passed `entry_name`: - - Dir.foreach('/example') {|entry_name| p entry_name } - -Output: - - "config.h" - "lib" - "main.rb" - ".." - "." - -Encoding: - - Dir.foreach('/example') {|entry_name| p entry_name.encoding; break } - Dir.foreach('/example', encoding: 'US-ASCII') {|entry_name| p entry_name.encoding; break } - -Output: - - # - # - -See [String Encoding](rdoc-ref:encodings.rdoc@String+Encoding). - -Returns an enumerator if no block is given. -**@overload** [] - -## getwd() [](#method-c-getwd) -Returns the path to the current working directory: - - Dir.chdir("/tmp") # => 0 - Dir.pwd # => "/tmp" -**@overload** [] - -## glob(pattern , _flags 0, flags: _flags, base: nil, sort: true) [](#method-c-glob) -call-seq: - Dir.glob(*patterns, flags: 0, base: nil, sort: true) -> array - Dir.glob(*patterns, flags: 0, base: nil, sort: true) {|entry_name| ... } -> nil - -Forms an array *entry_names* of the entry names selected by the arguments. - -Argument `patterns` is a string pattern or an array of string patterns; note -that these are not regexps; see below. - -Notes for the following examples: - -* `'*'` is the pattern that matches any entry name except those that begin - with `'.'`. -* We use method Array#take to shorten returned arrays that otherwise would - be very large. - -With no block, returns array *entry_names*; example (using the [simple file -tree](rdoc-ref:Dir@About+the+Examples)): - - Dir.glob('*') # => ["config.h", "lib", "main.rb"] - -With a block, calls the block with each of the *entry_names* and returns -`nil`: - - Dir.glob('*') {|entry_name| puts entry_name } # => nil - -Output: - - config.h - lib - main.rb - -If optional keyword argument `flags` is given, the value modifies the -matching; see below. - -If optional keyword argument `base` is given, its value specifies the base -directory. Each pattern string specifies entries relative to the base -directory; the default is `'.'`. The base directory is not prepended to the -entry names in the result: - - Dir.glob(pattern, base: 'lib').take(5) - # => ["abbrev.gemspec", "abbrev.rb", "base64.gemspec", "base64.rb", "benchmark.gemspec"] - Dir.glob(pattern, base: 'lib/irb').take(5) - # => ["cmd", "color.rb", "color_printer.rb", "completion.rb", "context.rb"] - -If optional keyword `sort` is given, its value specifies whether the array is -to be sorted; the default is `true`. Passing value `false` with that keyword -disables sorting (though the underlying file system may already have sorted -the array). - -**Patterns** - -Each pattern string is expanded according to certain metacharacters; examples -below use the [Ruby file tree](rdoc-ref:Dir@About+the+Examples): - -* `'*'`: Matches any substring in an entry name, similar in meaning to - regexp `/.*/mx`; may be restricted by other values in the pattern strings: - - * `'*'` matches all entry names: - - Dir.glob('*').take(3) # => ["BSDL", "CONTRIBUTING.md", "COPYING"] - - * `'c*'` matches entry names beginning with `'c'`: - - Dir.glob('c*').take(3) # => ["CONTRIBUTING.md", "COPYING", "COPYING.ja"] - - * `'*c'` matches entry names ending with `'c'`: - - Dir.glob('*c').take(3) # => ["addr2line.c", "array.c", "ast.c"] - - * `'*c*'` matches entry names that contain `'c'`, even at the beginning - or end: - - Dir.glob('*c*').take(3) # => ["CONTRIBUTING.md", "COPYING", "COPYING.ja"] - - Does not match Unix-like hidden entry names ("dot files"). To include - those in the matched entry names, use flag IO::FNM_DOTMATCH or something - like `'{*,.*}'`. - -* `'**'`: Matches entry names recursively if followed by the slash - character `'/'`: - - Dir.glob('**/').take(3) # => ["basictest/", "benchmark/", "benchmark/gc/"] - - If the string pattern contains other characters or is not followed by a - slash character, it is equivalent to `'*'`. - -* `'?'` Matches any single character; similar in meaning to regexp `/./`: - - Dir.glob('io.?') # => ["io.c"] - -* `'[*set*]'`: Matches any one character in the string *set*; behaves like a - [Regexp character class](rdoc-ref:Regexp@Character+Classes), including set - negation (`'[^a-z]'`): - - Dir.glob('*.[a-z][a-z]').take(3) - # => ["CONTRIBUTING.md", "COPYING.ja", "KNOWNBUGS.rb"] - -* `'{*abc*,*xyz*}'`: Matches either string *abc* or string *xyz*; behaves - like [Regexp alternation](rdoc-ref:Regexp@Alternation): - - Dir.glob('{LEGAL,BSDL}') # => ["LEGAL", "BSDL"] - - More than two alternatives may be given. - -* `\`: Escapes the following metacharacter. - - Note that on Windows, the backslash character may not be used in a string - pattern: `Dir['c:\\foo*']` will not work, use `Dir['c:/foo*']` instead. - -More examples (using the [simple file tree](rdoc-ref:Dir@About+the+Examples)): - - # We're in the example directory. - File.basename(Dir.pwd) # => "example" - Dir.glob('config.?') # => ["config.h"] - Dir.glob('*.[a-z][a-z]') # => ["main.rb"] - Dir.glob('*.[^r]*') # => ["config.h"] - Dir.glob('*.{rb,h}') # => ["main.rb", "config.h"] - Dir.glob('*') # => ["config.h", "lib", "main.rb"] - Dir.glob('*', File::FNM_DOTMATCH) # => [".", "config.h", "lib", "main.rb"] - Dir.glob(["*.rb", "*.h"]) # => ["main.rb", "config.h"] - - Dir.glob('**/*.rb') - => ["lib/song/karaoke.rb", "lib/song.rb", "main.rb"] - - Dir.glob('**/*.rb', base: 'lib') # => ["song/karaoke.rb", "song.rb"] - - Dir.glob('**/lib') # => ["lib"] - - Dir.glob('**/lib/**/*.rb') # => ["lib/song/karaoke.rb", "lib/song.rb"] - - Dir.glob('**/lib/*.rb') # => ["lib/song.rb"] - -**Flags** - -If optional keyword argument `flags` is given (the default is zero -- no -flags), its value should be the bitwise OR of one or more of the constants -defined in module File::Constants. - -Example: - - flags = File::FNM_EXTGLOB | File::FNM_DOTMATCH - -Specifying flags can extend, restrict, or otherwise modify the matching. - -The flags for this method (other constants in File::Constants do not apply): - -* File::FNM_DOTMATCH: specifies that entry names beginning with `'.'` should - be considered for matching: - - Dir.glob('*').take(5) - # => ["BSDL", "CONTRIBUTING.md", "COPYING", "COPYING.ja", "GPL"] - Dir.glob('*', flags: File::FNM_DOTMATCH).take(5) - # => [".", ".appveyor.yml", ".cirrus.yml", ".dir-locals.el", ".document"] - -* File::FNM_EXTGLOB: enables the pattern extension `'{*a*,*b*}'`, which - matches pattern *a* and pattern *b*; behaves like a [regexp - union](rdoc-ref:Regexp.union) (e.g., `'(?:*a*|*b*)'`): - - pattern = '{LEGAL,BSDL}' - Dir.glob(pattern) # => ["LEGAL", "BSDL"] - -* File::FNM_NOESCAPE: specifies that escaping with the backslash character - `'\'` is disabled; the character is not an escape character. - -* File::FNM_PATHNAME: specifies that metacharacters `'*'` and `'?'` do not - match directory separators. - -* File::FNM_SHORTNAME: specifies that patterns may match short names if they - exist; Windows only. -## home(*args ) [](#method-c-home) -Returns the home directory path of the user specified with `user_name` if it -is not `nil`, or the current login user: - - Dir.home # => "/home/me" - Dir.home('root') # => "/root" - -Raises ArgumentError if `user_name` is not a user name. -**@overload** [] - -## mkdir(*args ) [](#method-c-mkdir) -Creates a directory in the underlying file system at `dirpath` with the given -`permissions`; returns zero: - - Dir.mkdir('foo') - File.stat(Dir.new('foo')).mode.to_s(8)[1..4] # => "0755" - Dir.mkdir('bar', 0644) - File.stat(Dir.new('bar')).mode.to_s(8)[1..4] # => "0644" - -See [File Permissions](rdoc-ref:File@File+Permissions). Note that argument -`permissions` is ignored on Windows. -**@overload** [] - -## mktmpdir(prefix_suffix nil, tmpdir nil) [](#method-c-mktmpdir) -copied from lib/tmpdir.rb -## open(name , encoding: nil, &block ) [](#method-c-open) -call-seq: - Dir.open(dirpath) -> dir - Dir.open(dirpath, encoding: nil) -> dir - Dir.open(dirpath) {|dir| ... } -> object - Dir.open(dirpath, encoding: nil) {|dir| ... } -> object - -Creates a new Dir object *dir* for the directory at `dirpath`. - -With no block, the method equivalent to Dir.new(dirpath, encoding): - - Dir.open('.') # => # - -With a block given, the block is called with the created *dir*; on block exit -*dir* is closed and the block's value is returned: - - Dir.open('.') {|dir| dir.inspect } # => "#" - -The value given with optional keyword argument `encoding` specifies the -encoding for the directory entry names; if `nil` (the default), the file -system's encoding is used: - - Dir.open('.').read.encoding # => # - Dir.open('.', encoding: 'US-ASCII').read.encoding # => # -## pwd() [](#method-c-pwd) -Returns the path to the current working directory: - - Dir.chdir("/tmp") # => 0 - Dir.pwd # => "/tmp" -**@overload** [] - -## rmdir(dir ) [](#method-c-rmdir) -Removes the directory at `dirpath` from the underlying file system: - - Dir.rmdir('foo') # => 0 - -Raises an exception if the directory is not empty. -**@overload** [] - -## tmpdir() [](#method-c-tmpdir) -Returns the operating system's temporary file path. - - require 'tmpdir' - Dir.tmpdir # => "/tmp" -## unlink(dir ) [](#method-c-unlink) -Removes the directory at `dirpath` from the underlying file system: - - Dir.rmdir('foo') # => 0 - -Raises an exception if the directory is not empty. -**@overload** [] - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chdir() [](#method-i-chdir) -Changes the current working directory to `self`: - - Dir.pwd # => "/" - dir = Dir.new('example') - dir.chdir - Dir.pwd # => "/example" - -With a block, temporarily changes the working directory: - -* Calls the block. -* Changes to the given directory. -* Executes the block (yields no args). -* Restores the previous working directory. -* Returns the block's return value. - -Uses Dir.fchdir if available, and Dir.chdir if not, see those methods for -caveats. - -**@overload** [] - -**@overload** [] - -## children() [](#method-i-children) -Returns an array of the entry names in `self` except for `'.'` and `'..'`: - - dir = Dir.new('/example') - dir.children # => ["config.h", "lib", "main.rb"] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## close() [](#method-i-close) -Closes the stream in `self`, if it is open, and returns `nil`; ignored if -`self` is already closed: - - dir = Dir.new('example') - dir.read # => "." - dir.close # => nil - dir.close # => nil - dir.read # Raises IOError. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Calls the block with each entry name in `self`: - - Dir.new('example').each {|entry_name| p entry_name } - -Output: - - "." - ".." - "config.h" - "lib" - "main.rb" - -With no block given, returns an Enumerator. - -**@overload** [] - -## each_child() [](#method-i-each_child) -Calls the block with each entry name in `self` except `'.'` and `'..'`: - - dir = Dir.new('/example') - dir.each_child {|entry_name| p entry_name } - -Output: - - "config.h" - "lib" - "main.rb" - -If no block is given, returns an enumerator. - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## fileno() [](#method-i-fileno) -Returns the file descriptor used in *dir*. - - d = Dir.new('..') - d.fileno # => 8 - -This method uses the -[dirfd()](https://www.man7.org/linux/man-pages/man3/dirfd.3.html) function -defined by POSIX 2008; the method is not implemented on non-POSIX platforms -(raises NotImplementedError). - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(name, encoding:nil) [](#method-i-initialize) -call-seq: - Dir.new(dirpath) -> dir - Dir.new(dirpath, encoding: nil) -> dir - -Returns a new Dir object for the directory at `dirpath`: - - Dir.new('.') # => # - -The value given with optional keyword argument `encoding` specifies the -encoding for the directory entry names; if `nil` (the default), the file -system's encoding is used: - - Dir.new('.').read.encoding # => # - Dir.new('.', encoding: 'US-ASCII').read.encoding # => # - -**@return** [Dir] a new instance of Dir - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string description of `self`: - - Dir.new('example').inspect # => "#" - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## path() [](#method-i-path) -Returns the `dirpath` string that was used to create `self` (or `nil` if -created by method Dir.for_fd): - - Dir.new('example').path # => "example" - -**@overload** [] - -## pos() [](#method-i-pos) -Returns the current position of `self`; see [Dir As -Stream-Like](rdoc-ref:Dir@Dir+As+Stream-Like): - - dir = Dir.new('example') - dir.tell # => 0 - dir.read # => "." - dir.tell # => 1 - -**@overload** [] - -## pos=(pos) [](#method-i-pos=) -Sets the position in `self` and returns `position`. The value of `position` -should have been returned from an earlier call to #tell; if not, the return -values from subsequent calls to #read are unspecified. - -See [Dir As Stream-Like](rdoc-ref:Dir@Dir+As+Stream-Like). - -Examples: - - dir = Dir.new('example') - dir.pos # => 0 - dir.pos = 3 # => 3 - dir.pos # => 3 - dir.pos = 30 # => 30 - dir.pos # => 5 - -**@overload** [] - -## read() [](#method-i-read) -Reads and returns the next entry name from `self`; returns `nil` if at -end-of-stream; see [Dir As Stream-Like](rdoc-ref:Dir@Dir+As+Stream-Like): - - dir = Dir.new('example') - dir.read # => "." - dir.read # => ".." - dir.read # => "config.h" - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## rewind() [](#method-i-rewind) -Sets the position in `self` to zero; see [Dir As -Stream-Like](rdoc-ref:Dir@Dir+As+Stream-Like): - - dir = Dir.new('example') - dir.read # => "." - dir.read # => ".." - dir.pos # => 2 - dir.rewind # => # - dir.pos # => 0 - -**@overload** [] - -## seek(pos) [](#method-i-seek) -Sets the position in `self` and returns `self`. The value of `position` should -have been returned from an earlier call to #tell; if not, the return values -from subsequent calls to #read are unspecified. - -See [Dir As Stream-Like](rdoc-ref:Dir@Dir+As+Stream-Like). - -Examples: - - dir = Dir.new('example') - dir.pos # => 0 - dir.seek(3) # => # - dir.pos # => 3 - dir.seek(30) # => # - dir.pos # => 5 - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## tell() [](#method-i-tell) -Returns the current position of `self`; see [Dir As -Stream-Like](rdoc-ref:Dir@Dir+As+Stream-Like): - - dir = Dir.new('example') - dir.tell # => 0 - dir.read # => "." - dir.tell # => 1 - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_path() [](#method-i-to_path) -Returns the `dirpath` string that was used to create `self` (or `nil` if -created by method Dir.for_fd): - - Dir.new('example').path # => "example" - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Dir/Tmpname.md b/example/ruby/Dir/Tmpname.md deleted file mode 100644 index a1d426b..0000000 --- a/example/ruby/Dir/Tmpname.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Dir::Tmpname - - -Temporary name generator - - -# Class Methods -## create(basename , tmpdir nil, max_try: nil, **opts ) [](#method-c-create) -Generates and yields random names to create a temporary name -## tmpdir() [](#method-c-tmpdir) - diff --git a/example/ruby/DirSpecs.md b/example/ruby/DirSpecs.md deleted file mode 100644 index 1070b13..0000000 --- a/example/ruby/DirSpecs.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: DirSpecs - - - - -# Class Methods -## clear_dirs() [](#method-c-clear_dirs) -TODO: make these relative to the mock_dir -## create_mock_dirs() [](#method-c-create_mock_dirs) -## delete_mock_dirs() [](#method-c-delete_mock_dirs) -## expected_glob_paths() [](#method-c-expected_glob_paths) -## expected_paths() [](#method-c-expected_paths) -## mock_dir(dirs ['dir_specs_mock']) [](#method-c-mock_dir) -## mock_dir_files() [](#method-c-mock_dir_files) -The names of the fixture directories and files used by various Dir specs. -## mock_dir_links() [](#method-c-mock_dir_links) -## mock_rmdir(*dirs ) [](#method-c-mock_rmdir) -## nonexistent() [](#method-c-nonexistent) -## rmdir_dirs(create true) [](#method-c-rmdir_dirs) - diff --git a/example/ruby/DivmodSpecs.md b/example/ruby/DivmodSpecs.md deleted file mode 100644 index 17637be..0000000 --- a/example/ruby/DivmodSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: DivmodSpecs - - - - -# Class Methods -## check_both_bigdecimal(array ) [](#method-c-check_both_bigdecimal) -## check_both_nan(array ) [](#method-c-check_both_nan) - diff --git a/example/ruby/DottedFormatter.md b/example/ruby/DottedFormatter.md deleted file mode 100644 index e68a083..0000000 --- a/example/ruby/DottedFormatter.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: DottedFormatter -**Inherits:** BaseFormatter - - - - - -#Instance Methods -## after(statenil) [](#method-i-after) -Callback for the MSpec :after event. Prints an indicator for the result of -evaluating this example as follows: - . = No failure or error - F = An SpecExpectationNotMetError was raised - E = Any exception other than SpecExpectationNotMetError - -## register() [](#method-i-register) - diff --git a/example/ruby/Downloader.md b/example/ruby/Downloader.md deleted file mode 100644 index 40c48ee..0000000 --- a/example/ruby/Downloader.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Downloader -**Inherits:** Object - - - - -# Class Methods -## cache_file(url , name , cache_dir nil) [](#method-c-cache_file) -## download(url , name , dir nil, since true, options {}) [](#method-c-download) -Downloader.download(url, name, [dir, [since]]) - -Update a file from url if newer version is available. Creates the file if the -file doesn't yet exist; however, the directory where the file is being created -has to exist already. The `since` parameter can take the following values, -with associated meanings: - true :: - Take the last-modified time of the current file on disk, and only download - if the server has a file that was modified later. Download unconditionally - if we don't have the file yet. Default. - +some time value+ :: - Use this time value instead of the time of modification of the file on disk. - nil :: - Only download the file if it doesn't exist yet. - false :: - always download url regardless of whether we already have a file, - and regardless of modification times. (This is essentially just a waste of - network resources, except in the case that the file we have is somehow damaged. - Please note that using this recurringly might create or be seen as a - denial of service attack.) - -Example usage: - download 'http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt', - 'UnicodeData.txt', 'enc/unicode/data' -## find(dlname ) [](#method-c-find) -## get_option(argv , options ) [](#method-c-get_option) -## http_options(file , since ) [](#method-c-http_options) -## httpdate(date ) [](#method-c-httpdate) -## https() [](#method-c-https) -## https=(https ) [](#method-c-https=) -## https?() [](#method-c-https?) -**@return** [Boolean] - -## link_cache(cache , file , name , verbose false) [](#method-c-link_cache) -## mode_for(data ) [](#method-c-mode_for) -## save_cache(cache , file , name ) [](#method-c-save_cache) -## under(dir , name ) [](#method-c-under) - diff --git a/example/ruby/Downloader/GNU.md b/example/ruby/Downloader/GNU.md deleted file mode 100644 index 60b241e..0000000 --- a/example/ruby/Downloader/GNU.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Downloader::GNU -**Inherits:** Downloader - - - - -# Class Methods -## download(name , *rest ) [](#method-c-download) - diff --git a/example/ruby/Downloader/RubyGems.md b/example/ruby/Downloader/RubyGems.md deleted file mode 100644 index 3f2a991..0000000 --- a/example/ruby/Downloader/RubyGems.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Downloader::RubyGems -**Inherits:** Downloader - - - - -# Class Methods -## download(name , dir nil, since true, options {}) [](#method-c-download) - diff --git a/example/ruby/Downloader/Unicode.md b/example/ruby/Downloader/Unicode.md deleted file mode 100644 index d3592a7..0000000 --- a/example/ruby/Downloader/Unicode.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Downloader::Unicode -**Inherits:** Downloader - - - - -# Class Methods -## download(name , dir nil, since true, options {}) [](#method-c-download) -## get_option(argv , options ) [](#method-c-get_option) - diff --git a/example/ruby/ENV.md b/example/ruby/ENV.md deleted file mode 100644 index da47873..0000000 --- a/example/ruby/ENV.md +++ /dev/null @@ -1,176 +0,0 @@ -# Class: ENV -**Inherits:** Object - - -`ENV` is a hash-like accessor for environment variables. - -### Interaction with the Operating System - -The `ENV` object interacts with the operating system's environment variables: - -* When you get the value for a name in `ENV`, the value is retrieved from - among the current environment variables. -* When you create or set a name-value pair in `ENV`, the name and value are - immediately set in the environment variables. -* When you delete a name-value pair in `ENV`, it is immediately deleted from - the environment variables. - -### Names and Values - -Generally, a name or value is a String. - -#### Valid Names and Values - -Each name or value must be one of the following: - -* A String. -* An object that responds to #to_str by returning a String, in which case - that String will be used as the name or value. - -#### Invalid Names and Values - -A new name: - -* May not be the empty string: - ENV[''] = '0' - # Raises Errno::EINVAL (Invalid argument - ruby_setenv()) - -* May not contain character `"="`: - ENV['='] = '0' - # Raises Errno::EINVAL (Invalid argument - ruby_setenv(=)) - -A new name or value: - -* May not be a non-String that does not respond to #to_str: - - ENV['foo'] = Object.new - # Raises TypeError (no implicit conversion of Object into String) - ENV[Object.new] = '0' - # Raises TypeError (no implicit conversion of Object into String) - -* May not contain the NUL character `"\0"`: - - ENV['foo'] = "\0" - # Raises ArgumentError (bad environment variable value: contains null byte) - ENV["\0"] == '0' - # Raises ArgumentError (bad environment variable name: contains null byte) - -* May not have an ASCII-incompatible encoding such as UTF-16LE or - ISO-2022-JP: - - ENV['foo'] = '0'.force_encoding(Encoding::ISO_2022_JP) - # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP) - ENV["foo".force_encoding(Encoding::ISO_2022_JP)] = '0' - # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP) - -### About Ordering - -`ENV` enumerates its name/value pairs in the order found in the operating -system's environment variables. Therefore the ordering of `ENV` content is -OS-dependent, and may be indeterminate. - -This will be seen in: -* A Hash returned by an `ENV` method. -* An Enumerator returned by an `ENV` method. -* An Array returned by ENV.keys, ENV.values, or ENV.to_a. -* The String returned by ENV.inspect. -* The Array returned by ENV.shift. -* The name returned by ENV.key. - -### About the Examples -Some methods in `ENV` return `ENV` itself. Typically, there are many -environment variables. It's not useful to display a large `ENV` in the -examples here, so most example snippets begin by resetting the contents of -`ENV`: -* ENV.replace replaces `ENV` with a new collection of entries. -* ENV.clear empties `ENV`. - -### What's Here - -First, what's elsewhere. Class `ENV`: - -* Inherits from [class Object](rdoc-ref:Object@What-27s+Here). -* Extends [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), - -Here, class `ENV` provides methods that are useful for: - -* [Querying](rdoc-ref:ENV@Methods+for+Querying) -* [Assigning](rdoc-ref:ENV@Methods+for+Assigning) -* [Deleting](rdoc-ref:ENV@Methods+for+Deleting) -* [Iterating](rdoc-ref:ENV@Methods+for+Iterating) -* [Converting](rdoc-ref:ENV@Methods+for+Converting) -* [And more ....](rdoc-ref:ENV@More+Methods) - -#### Methods for Querying - -* ::[]: Returns the value for the given environment variable name if it - exists: -* ::empty?: Returns whether `ENV` is empty. -* ::has_value?, ::value?: Returns whether the given value is in `ENV`. -* ::include?, ::has_key?, ::key?, ::member?: Returns whether the given name - is in +ENV+. - -* ::key: Returns the name of the first entry with the given value. -* ::size, ::length: Returns the number of entries. -* ::value?: Returns whether any entry has the given value. - -#### Methods for Assigning - -* ::[]=, ::store: Creates, updates, or deletes the named environment - variable. -* ::clear: Removes every environment variable; returns `ENV`: -* ::update, ::merge!: Adds to `ENV` each key/value pair in the given hash. -* ::replace: Replaces the entire content of the `ENV` with the name/value - pairs in the given hash. - -#### Methods for Deleting - -* ::delete: Deletes the named environment variable name if it exists. -* ::delete_if: Deletes entries selected by the block. -* ::keep_if: Deletes entries not selected by the block. -* ::reject!: Similar to #delete_if, but returns `nil` if no change was made. -* ::select!, ::filter!: Deletes entries selected by the block. -* ::shift: Removes and returns the first entry. - -#### Methods for Iterating - -* ::each, ::each_pair: Calls the block with each name/value pair. -* ::each_key: Calls the block with each name. -* ::each_value: Calls the block with each value. - -#### Methods for Converting - -* ::assoc: Returns a 2-element array containing the name and value of the - named environment variable if it exists: -* ::clone: Returns `ENV` (and issues a warning). -* ::except: Returns a hash of all name/value pairs except those given. -* ::fetch: Returns the value for the given name. -* ::inspect: Returns the contents of `ENV` as a string. -* ::invert: Returns a hash whose keys are the `ENV` values, - and whose values are the corresponding +ENV+ names. - -* ::keys: Returns an array of all names. -* ::rassoc: Returns the name and value of the first found entry that has the - given value. -* ::reject: Returns a hash of those entries not rejected by the block. -* ::select, ::filter: Returns a hash of name/value pairs selected by the - block. -* ::slice: Returns a hash of the given names and their corresponding values. -* ::to_a: Returns the entries as an array of 2-element Arrays. -* ::to_h: Returns a hash of entries selected by the block. -* ::to_hash: Returns a hash of all entries. -* ::to_s: Returns the string `'ENV'`. -* ::values: Returns all values as an array. -* ::values_at: Returns an array of the values for the given name. - -#### More Methods - -* ::dup: Raises an exception. -* ::freeze: Raises an exception. -* ::rehash: Returns `nil`, without modifying `ENV`. - - -# Class Methods -## pretty_print(q ) [](#method-c-pretty_print) -:nodoc: - diff --git a/example/ruby/ENVSpecs.md b/example/ruby/ENVSpecs.md deleted file mode 100644 index 774aa90..0000000 --- a/example/ruby/ENVSpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ENVSpecs - - - - -# Class Methods -## encoding() [](#method-c-encoding) - diff --git a/example/ruby/EOFError.md b/example/ruby/EOFError.md deleted file mode 100644 index 66151cb..0000000 --- a/example/ruby/EOFError.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: EOFError -**Inherits:** IOError - - -Raised by some IO operations when reaching the end of file. Many IO methods -exist in two forms, - -one that returns `nil` when the end of file is reached, the other raises -EOFError. - -EOFError is a subclass of IOError. - - file = File.open("/etc/hosts") - file.read - file.gets #=> nil - file.readline #=> EOFError: end of file reached - file.close - - - diff --git a/example/ruby/ERB.md b/example/ruby/ERB.md deleted file mode 100644 index 2407a7a..0000000 --- a/example/ruby/ERB.md +++ /dev/null @@ -1,399 +0,0 @@ -# Class: ERB -**Inherits:** Object - - -# ERB -- Ruby Templating - -## Introduction - -ERB provides an easy to use but powerful templating system for Ruby. Using -ERB, actual Ruby code can be added to any plain text document for the purposes -of generating document information details and/or flow control. - -A very simple example is this: - - require 'erb' - - x = 42 - template = ERB.new <<-EOF - The value of x is: <%= x %> - EOF - puts template.result(binding) - -*Prints:* The value of x is: 42 - -More complex examples are given below. - -## Recognized Tags - -ERB recognizes certain tags in the provided template and converts them based -on the rules below: - - <% Ruby code -- inline with output %> - <%= Ruby expression -- replace with result %> - <%# comment -- ignored -- useful in testing %> (`<% #` doesn't work. Don't use Ruby comments.) - % a line of Ruby code -- treated as <% line %> (optional -- see ERB.new) - %% replaced with % if first thing on a line and % processing is used - <%% or %%> -- replace with <% or %> respectively - -All other text is passed through ERB filtering unchanged. - -## Options - -There are several settings you can change when you use ERB: -* the nature of the tags that are recognized; -* the binding used to resolve local variables in the template. - -See the ERB.new and ERB#result methods for more detail. - -## Character encodings - -ERB (or Ruby code generated by ERB) returns a string in the same character -encoding as the input string. When the input string has a magic comment, -however, it returns a string in the encoding specified by the magic comment. - - # -*- coding: utf-8 -*- - require 'erb' - - template = ERB.new < - \_\_ENCODING\_\_ is <%= \_\_ENCODING\_\_ %>. - EOF - puts template.result - -*Prints:* _*ENCODING*_ is Big5. - -## Examples - -### Plain Text - -ERB is useful for any generic templating situation. Note that in this -example, we use the convenient "% at start of line" tag, and we quote the -template literally with `%q{...}` to avoid trouble with the backslash. - - require "erb" - - # Create template. - template = %q{ - From: James Edward Gray II - To: <%= to %> - Subject: Addressing Needs - - <%= to[/\w+/] %>: - - Just wanted to send a quick note assuring that your needs are being - addressed. - - I want you to know that my team will keep working on the issues, - especially: - - <%# ignore numerous minor requests -- focus on priorities %> - % priorities.each do |priority| - * <%= priority %> - % end - - Thanks for your patience. - - James Edward Gray II - }.gsub(/^ /, '') - - message = ERB.new(template, trim_mode: "%<>") - - # Set up template data. - to = "Community Spokesman " - priorities = [ "Run Ruby Quiz", - "Document Modules", - "Answer Questions on Ruby Talk" ] - - # Produce result. - email = message.result - puts email - -*Generates:* - - From: James Edward Gray II - To: Community Spokesman - Subject: Addressing Needs - - Community: - - Just wanted to send a quick note assuring that your needs are being addressed. - - I want you to know that my team will keep working on the issues, especially: - - * Run Ruby Quiz - * Document Modules - * Answer Questions on Ruby Talk - - Thanks for your patience. - - James Edward Gray II - -### Ruby in HTML - -ERB is often used in `.rhtml` files (HTML with embedded Ruby). Notice the -need in this example to provide a special binding when the template is run, so -that the instance variables in the Product object can be resolved. - - require "erb" - - # Build template data class. - class Product - def initialize( code, name, desc, cost ) - @code = code - @name = name - @desc = desc - @cost = cost - - @features = [ ] - end - - def add_feature( feature ) - @features << feature - end - - # Support templating of member data. - def get_binding - binding - end - - # ... - end - - # Create template. - template = %{ - - Ruby Toys -- <%= @name %> - - -

<%= @name %> (<%= @code %>)

-

<%= @desc %>

- -
    - <% @features.each do |f| %> -
  • <%= f %>
  • - <% end %> -
- -

- <% if @cost < 10 %> - Only <%= @cost %>!!! - <% else %> - Call for a price, today! - <% end %> -

- - - - }.gsub(/^ /, '') - - rhtml = ERB.new(template) - - # Set up template data. - toy = Product.new( "TZ-1002", - "Rubysapien", - "Geek's Best Friend! Responds to Ruby commands...", - 999.95 ) - toy.add_feature("Listens for verbal commands in the Ruby language!") - toy.add_feature("Ignores Perl, Java, and all C variants.") - toy.add_feature("Karate-Chop Action!!!") - toy.add_feature("Matz signature on left leg.") - toy.add_feature("Gem studded eyes... Rubies, of course!") - - # Produce result. - rhtml.run(toy.get_binding) - -*Generates (some blank lines removed):* - - - Ruby Toys -- Rubysapien - - -

Rubysapien (TZ-1002)

-

Geek's Best Friend! Responds to Ruby commands...

- -
    -
  • Listens for verbal commands in the Ruby language!
  • -
  • Ignores Perl, Java, and all C variants.
  • -
  • Karate-Chop Action!!!
  • -
  • Matz signature on left leg.
  • -
  • Gem studded eyes... Rubies, of course!
  • -
- -

- Call for a price, today! -

- - - - -## Notes - -There are a variety of templating solutions available in various Ruby -projects. For example, RDoc, distributed with Ruby, uses its own template -engine, which can be reused elsewhere. - -Other popular engines could be found in the corresponding -[Category](https://www.ruby-toolbox.com/categories/template_engines) of The -Ruby Toolbox. - - -# Class Methods -## version() [](#method-c-version) -Returns revision information for the erb.rb module. -# Attributes -## encoding[RW] [](#attribute-i-encoding) -The encoding to eval - -## filename[RW] [](#attribute-i-filename) -The optional *filename* argument passed to Kernel#eval when the ERB code is -run - -## lineno[RW] [](#attribute-i-lineno) -The optional *lineno* argument passed to Kernel#eval when the ERB code is run - -## src[RW] [](#attribute-i-src) -The Ruby code generated by ERB - - -#Instance Methods -## def_class(superklassObject, methodname'result') [](#method-i-def_class) -Define unnamed class which has *methodname* as instance method, and return it. - -example: - class MyClass_ - def initialize(arg1, arg2) - @arg1 = arg1; @arg2 = arg2 - end - end - filename = 'example.rhtml' # @arg1 and @arg2 are used in example.rhtml - erb = ERB.new(File.read(filename)) - erb.filename = filename - MyClass = erb.def_class(MyClass_, 'render()') - print MyClass.new('foo', 123).render() - -## def_method(mod, methodname, fname'(ERB)') [](#method-i-def_method) -Define *methodname* as instance method of *mod* from compiled Ruby source. - -example: - filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml - erb = ERB.new(File.read(filename)) - erb.def_method(MyClass, 'render(arg1, arg2)', filename) - print MyClass.new.render('foo', 123) - -## def_module(methodname'erb') [](#method-i-def_module) -Create unnamed module, define *methodname* as instance method of it, and -return it. - -example: - filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml - erb = ERB.new(File.read(filename)) - erb.filename = filename - MyModule = erb.def_module('render(arg1, arg2)') - class MyClass - include MyModule - end - -## initialize(str, safe_levelNOT_GIVEN, legacy_trim_modeNOT_GIVEN, legacy_eoutvarNOT_GIVEN, trim_mode:nil, eoutvar:'_erbout') [](#method-i-initialize) -Constructs a new ERB object with the template specified in *str*. - -An ERB object works by building a chunk of Ruby code that will output the -completed template when run. - -If *trim_mode* is passed a String containing one or more of the following -modifiers, ERB will adjust its code generation as listed: - - % enables Ruby code processing for lines beginning with % - <> omit newline for lines starting with <% and ending in %> - > omit newline for lines ending in %> - - omit blank lines ending in -%> - -*eoutvar* can be used to set the name of the variable ERB will build up its -output in. This is useful when you need to run multiple ERB templates through -the same binding and/or when you want to control where output ends up. Pass -the name of the variable to be used inside a String. - -### Example - - require "erb" - - # build data class - class Listings - PRODUCT = { :name => "Chicken Fried Steak", - :desc => "A well messaged pattie, breaded and fried.", - :cost => 9.95 } - - attr_reader :product, :price - - def initialize( product = "", price = "" ) - @product = product - @price = price - end - - def build - b = binding - # create and run templates, filling member data variables - ERB.new(<<~'END_PRODUCT', trim_mode: "", eoutvar: "@product").result b - <%= PRODUCT[:name] %> - <%= PRODUCT[:desc] %> - END_PRODUCT - ERB.new(<<~'END_PRICE', trim_mode: "", eoutvar: "@price").result b - <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %> - <%= PRODUCT[:desc] %> - END_PRICE - end - end - - # setup template data - listings = Listings.new - listings.build - - puts listings.product + "\n" + listings.price - -*Generates* - - Chicken Fried Steak - A well massaged pattie, breaded and fried. - - Chicken Fried Steak -- 9.95 - A well massaged pattie, breaded and fried. - -**@return** [ERB] a new instance of ERB - -## location=(filename, lineno) [](#method-i-location=) -Sets optional filename and line number that will be used in ERB code -evaluation and error reporting. See also #filename= and #lineno= - - erb = ERB.new('<%= some_x %>') - erb.render - # undefined local variable or method `some_x' - # from (erb):1 - - erb.location = ['file.erb', 3] - # All subsequent error reporting would use new location - erb.render - # undefined local variable or method `some_x' - # from file.erb:4 - -## make_compiler(trim_mode) [](#method-i-make_compiler) -Creates a new compiler for ERB. See ERB::Compiler.new for details - -## result(b) [](#method-i-result) -Executes the generated ERB code to produce a completed template, returning the -results of that code. - -*b* accepts a Binding object which is used to set the context of code -evaluation. - -## result_with_hash(hash) [](#method-i-result_with_hash) -Render a template on a new toplevel binding with local variables specified by -a Hash object. - -## run(bnew_toplevel) [](#method-i-run) -Generate results and print them. (see ERB#result) - -## set_eoutvar(compiler, eoutvar'_erbout') [](#method-i-set_eoutvar) -Can be used to set *eoutvar* as described in ERB::new. It's probably easier -to just use the constructor though, since calling this method requires the -setup of an ERB *compiler* object. - diff --git a/example/ruby/ERB/Compiler.md b/example/ruby/ERB/Compiler.md deleted file mode 100644 index 2c5b960..0000000 --- a/example/ruby/ERB/Compiler.md +++ /dev/null @@ -1,125 +0,0 @@ -# Class: ERB::Compiler -**Inherits:** Object - - --- ERB::Compiler - -Compiles ERB templates into Ruby code; the compiled code produces the template -result when evaluated. ERB::Compiler provides hooks to define how generated -output is handled. - -Internally ERB does something like this to generate the code returned by -ERB#src: - - compiler = ERB::Compiler.new('<>') - compiler.pre_cmd = ["_erbout=+''"] - compiler.put_cmd = "_erbout.<<" - compiler.insert_cmd = "_erbout.<<" - compiler.post_cmd = ["_erbout"] - - code, enc = compiler.compile("Got <%= obj %>!\n") - puts code - -*Generates*: - - #coding:UTF-8 - _erbout=+''; _erbout.<< "Got ".freeze; _erbout.<<(( obj ).to_s); _erbout.<< "!\n".freeze; _erbout - -By default the output is sent to the print method. For example: - - compiler = ERB::Compiler.new('<>') - code, enc = compiler.compile("Got <%= obj %>!\n") - puts code - -*Generates*: - - #coding:UTF-8 - print "Got ".freeze; print(( obj ).to_s); print "!\n".freeze - -## Evaluation - -The compiled code can be used in any context where the names in the code -correctly resolve. Using the last example, each of these print 'Got It!' - -Evaluate using a variable: - - obj = 'It' - eval code - -Evaluate using an input: - - mod = Module.new - mod.module_eval %{ - def get(obj) - #{code} - end - } - extend mod - get('It') - -Evaluate using an accessor: - - klass = Class.new Object - klass.class_eval %{ - attr_accessor :obj - def initialize(obj) - @obj = obj - end - def get_it - #{code} - end - } - klass.new('It').get_it - -Good! See also ERB#def_method, ERB#def_module, and ERB#def_class. - - -# Attributes -## insert_cmd[RW] [](#attribute-i-insert_cmd) -The command to handle text that is inserted prior to a newline - -## percent[RW] [](#attribute-i-percent) -Returns the value of attribute percent. - -## post_cmd[RW] [](#attribute-i-post_cmd) -An array of commands appended to compiled code - -## pre_cmd[RW] [](#attribute-i-pre_cmd) -An array of commands prepended to compiled code - -## put_cmd[RW] [](#attribute-i-put_cmd) -The command to handle text that ends with a newline - -## trim_mode[RW] [](#attribute-i-trim_mode) -Returns the value of attribute trim_mode. - - -#Instance Methods -## add_insert_cmd(out, content) [](#method-i-add_insert_cmd) - -## add_put_cmd(out, content) [](#method-i-add_put_cmd) - -## compile(s) [](#method-i-compile) -Compiles an ERB template into Ruby code. Returns an array of the code and -encoding like ["code", Encoding]. - -**@raise** [ArgumentError] - -## compile_content(stag, out) [](#method-i-compile_content) - -## compile_etag(etag, out, scanner) [](#method-i-compile_etag) - -## compile_stag(stag, out, scanner) [](#method-i-compile_stag) - -## initialize(trim_mode) [](#method-i-initialize) -Construct a new compiler using the trim_mode. See ERB::new for available trim -modes. - -**@return** [Compiler] a new instance of Compiler - -## make_scanner(src) [](#method-i-make_scanner) -:nodoc: - -## prepare_trim_mode(mode) [](#method-i-prepare_trim_mode) -:nodoc: - diff --git a/example/ruby/ERB/Compiler/Buffer.md b/example/ruby/ERB/Compiler/Buffer.md deleted file mode 100644 index bce2275..0000000 --- a/example/ruby/ERB/Compiler/Buffer.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: ERB::Compiler::Buffer -**Inherits:** Object - - -:nodoc: - - -# Attributes -## script[RW] [](#attribute-i-script) -Returns the value of attribute script. - - -#Instance Methods -## close() [](#method-i-close) - -## cr() [](#method-i-cr) - -## initialize(compiler, encnil, frozennil) [](#method-i-initialize) - -**@return** [Buffer] a new instance of Buffer - -## push(cmd) [](#method-i-push) - diff --git a/example/ruby/ERB/Compiler/PercentLine.md b/example/ruby/ERB/Compiler/PercentLine.md deleted file mode 100644 index 83a69ac..0000000 --- a/example/ruby/ERB/Compiler/PercentLine.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ERB::Compiler::PercentLine -**Inherits:** Object - - -:nodoc: - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## initialize(str) [](#method-i-initialize) -:nodoc: - -**@return** [PercentLine] a new instance of PercentLine - diff --git a/example/ruby/ERB/Compiler/Scanner.md b/example/ruby/ERB/Compiler/Scanner.md deleted file mode 100644 index ece8a5a..0000000 --- a/example/ruby/ERB/Compiler/Scanner.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: ERB::Compiler::Scanner -**Inherits:** Object - - -:nodoc: - - -# Class Methods -## default_scanner=(klass ) [](#method-c-default_scanner=) -## make_scanner(src , trim_mode , percent ) [](#method-c-make_scanner) -## register_scanner(klass , trim_mode , percent ) [](#method-c-register_scanner) -# Attributes -## etags[RW] [](#attribute-i-etags) -Returns the value of attribute etags. - -## stag[RW] [](#attribute-i-stag) -Returns the value of attribute stag. - -## stags[RW] [](#attribute-i-stags) -Returns the value of attribute stags. - - -#Instance Methods -## initialize(src, trim_mode, percent) [](#method-i-initialize) - -**@return** [Scanner] a new instance of Scanner - -## scan() [](#method-i-scan) - diff --git a/example/ruby/ERB/Compiler/TrimScanner.md b/example/ruby/ERB/Compiler/TrimScanner.md deleted file mode 100644 index ebe2886..0000000 --- a/example/ruby/ERB/Compiler/TrimScanner.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: ERB::Compiler::TrimScanner -**Inherits:** ERB::Compiler::Scanner - - -:nodoc: - - - -#Instance Methods -## explicit_trim_line(line) [](#method-i-explicit_trim_line) - -## initialize(src, trim_mode, percent) [](#method-i-initialize) - -**@return** [TrimScanner] a new instance of TrimScanner - -## is_erb_stag?(s) [](#method-i-is_erb_stag?) - -**@return** [Boolean] - -## percent_line(line, &block) [](#method-i-percent_line) - -## scan(&block) [](#method-i-scan) - -## scan_line(line) [](#method-i-scan_line) - -## trim_line1(line) [](#method-i-trim_line1) - -## trim_line2(line) [](#method-i-trim_line2) - diff --git a/example/ruby/ERB/DefMethod.md b/example/ruby/ERB/DefMethod.md deleted file mode 100644 index f04c5c6..0000000 --- a/example/ruby/ERB/DefMethod.md +++ /dev/null @@ -1,39 +0,0 @@ -# Module: ERB::DefMethod - - --- ERB::DefMethod - -Utility module to define eRuby script as instance method. - -### Example - -example.rhtml: - <% for item in @items %> - <%= item %> - <% end %> - -example.rb: - require 'erb' - class MyClass - extend ERB::DefMethod - def_erb_method('render()', 'example.rhtml') - def initialize(items) - @items = items - end - end - print MyClass.new([10,20,30]).render() - -result: - - 10 - - 20 - - 30 - - -# Class Methods -## def_erb_method(methodname , erb_or_fname ) [](#method-c-def_erb_method) -define *methodname* as instance method of current module, using ERB object or -eRuby file - diff --git a/example/ruby/ERB/Escape.md b/example/ruby/ERB/Escape.md deleted file mode 100644 index 2b71ec5..0000000 --- a/example/ruby/ERB/Escape.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: ERB::Escape - - - - -# Class Methods -## html_escape(str ) [](#method-c-html_escape) -ERB::Util.html_escape does not allocate a new string when nothing needs to be -escaped - diff --git a/example/ruby/ERB/Util.md b/example/ruby/ERB/Util.md deleted file mode 100644 index 4a1d0ac..0000000 --- a/example/ruby/ERB/Util.md +++ /dev/null @@ -1,36 +0,0 @@ -# Module: ERB::Util - -**Includes:** ERB::Escape - - --- ERB::Util - -A utility module for conversion routines, often handy in HTML generation. - - -# Class Methods -## h() [](#method-c-h) -## html_escape() [](#method-c-html_escape) -## u() [](#method-c-u) -A utility method for encoding the String *s* as a URL. - - require "erb" - include ERB::Util - - puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide") - -*Generates* - - Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide -## url_encode(s ) [](#method-c-url_encode) -A utility method for encoding the String *s* as a URL. - - require "erb" - include ERB::Util - - puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide") - -*Generates* - - Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide - diff --git a/example/ruby/ERBSpecs.md b/example/ruby/ERBSpecs.md deleted file mode 100644 index bd65cee..0000000 --- a/example/ruby/ERBSpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ERBSpecs - - - - -# Class Methods -## new_erb(input , trim_mode: nil) [](#method-c-new_erb) - diff --git a/example/ruby/Emoji.md b/example/ruby/Emoji.md deleted file mode 100644 index cbc9331..0000000 --- a/example/ruby/Emoji.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Emoji - - - - - diff --git a/example/ruby/Emoji/TestDoCoMo.md b/example/ruby/Emoji/TestDoCoMo.md deleted file mode 100644 index cc236aa..0000000 --- a/example/ruby/Emoji/TestDoCoMo.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Emoji::TestDoCoMo -**Inherits:** Test::Unit::TestCase - -**Includes:** Emoji - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_comparison() [](#method-i-test_comparison) - -## test_docomo() [](#method-i-test_docomo) - -## test_encoding_name() [](#method-i-test_encoding_name) - -## test_from_sjis() [](#method-i-test_from_sjis) - -## test_from_utf8() [](#method-i-test_from_utf8) - -## test_to_eucjp() [](#method-i-test_to_eucjp) - -## test_to_kddi() [](#method-i-test_to_kddi) - -## test_to_sjis() [](#method-i-test_to_sjis) - -## test_to_softbank() [](#method-i-test_to_softbank) - -## test_to_utf8() [](#method-i-test_to_utf8) - diff --git a/example/ruby/Emoji/TestKDDI.md b/example/ruby/Emoji/TestKDDI.md deleted file mode 100644 index e589c64..0000000 --- a/example/ruby/Emoji/TestKDDI.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Emoji::TestKDDI -**Inherits:** Test::Unit::TestCase - -**Includes:** Emoji - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_comparison() [](#method-i-test_comparison) - -## test_encoding_name() [](#method-i-test_encoding_name) - -## test_from_iso2022jp() [](#method-i-test_from_iso2022jp) - -## test_from_sjis() [](#method-i-test_from_sjis) - -## test_from_utf8() [](#method-i-test_from_utf8) - -## test_kddi() [](#method-i-test_kddi) - -## test_to_docomo() [](#method-i-test_to_docomo) - -## test_to_eucjp() [](#method-i-test_to_eucjp) - -## test_to_sjis() [](#method-i-test_to_sjis) - -## test_to_softbank() [](#method-i-test_to_softbank) - -## test_to_utf8() [](#method-i-test_to_utf8) - diff --git a/example/ruby/Emoji/TestRenameSJIS.md b/example/ruby/Emoji/TestRenameSJIS.md deleted file mode 100644 index a175eeb..0000000 --- a/example/ruby/Emoji/TestRenameSJIS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Emoji::TestRenameSJIS -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_shift_jis() [](#method-i-test_shift_jis) - diff --git a/example/ruby/Emoji/TestSoftBank.md b/example/ruby/Emoji/TestSoftBank.md deleted file mode 100644 index 068e258..0000000 --- a/example/ruby/Emoji/TestSoftBank.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Emoji::TestSoftBank -**Inherits:** Test::Unit::TestCase - -**Includes:** Emoji - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_comparison() [](#method-i-test_comparison) - -## test_encoding_name() [](#method-i-test_encoding_name) - -## test_from_sjis() [](#method-i-test_from_sjis) - -## test_from_utf8() [](#method-i-test_from_utf8) - -## test_softbank() [](#method-i-test_softbank) - -## test_to_docomo() [](#method-i-test_to_docomo) - -## test_to_eucjp() [](#method-i-test_to_eucjp) - -## test_to_kddi() [](#method-i-test_to_kddi) - -## test_to_sjis() [](#method-i-test_to_sjis) - -## test_to_utf8() [](#method-i-test_to_utf8) - diff --git a/example/ruby/Emoji/TestUTF8_BLACK_SUN_WITH_RAYS.md b/example/ruby/Emoji/TestUTF8_BLACK_SUN_WITH_RAYS.md deleted file mode 100644 index e32ac88..0000000 --- a/example/ruby/Emoji/TestUTF8_BLACK_SUN_WITH_RAYS.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Emoji::TestUTF8_BLACK_SUN_WITH_RAYS -**Inherits:** Test::Unit::TestCase - -**Includes:** Emoji - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_convert() [](#method-i-test_convert) - diff --git a/example/ruby/EmojiTable.md b/example/ruby/EmojiTable.md deleted file mode 100644 index 6939795..0000000 --- a/example/ruby/EmojiTable.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: EmojiTable -**Inherits:** Object - - - - - -#Instance Methods -## conversion(from_carrier, to_carrier, &block) [](#method-i-conversion) - -## generate(io, from_carrier, to_carrier) [](#method-i-generate) - -## initialize(xml_path) [](#method-i-initialize) - -**@return** [EmojiTable] a new instance of EmojiTable - diff --git a/example/ruby/Encoding.md b/example/ruby/Encoding.md deleted file mode 100644 index 212d8a9..0000000 --- a/example/ruby/Encoding.md +++ /dev/null @@ -1,245 +0,0 @@ -# Class: Encoding -**Inherits:** Object - - -An Encoding instance represents a character encoding usable in Ruby. It is -defined as a constant under the Encoding namespace. It has a name and, -optionally, aliases: - - Encoding::US_ASCII.name # => "US-ASCII" - Encoding::US_ASCII.names # => ["US-ASCII", "ASCII", "ANSI_X3.4-1968", "646"] - -A Ruby method that accepts an encoding as an argument will accept: - -* An Encoding object. -* The name of an encoding. -* An alias for an encoding name. - -These are equivalent: - - 'foo'.encode(Encoding::US_ASCII) # Encoding object. - 'foo'.encode('US-ASCII') # Encoding name. - 'foo'.encode('ASCII') # Encoding alias. - -For a full discussion of encodings and their uses, see [the Encodings -document](rdoc-ref:encodings.rdoc). - -Encoding::ASCII_8BIT is a special-purpose encoding that is usually used for a -string of bytes, not a string of characters. But as the name indicates, its -characters in the ASCII range are considered as ASCII characters. This is -useful when you use other ASCII-compatible encodings. - - -# Class Methods -## _load(str ) [](#method-c-_load) -:nodoc: -## aliases() [](#method-c-aliases) -Returns the hash of available encoding alias and original encoding name. - - Encoding.aliases - #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1968"=>"US-ASCII", - "SJIS"=>"Windows-31J", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"} -**@overload** [] - -## compatible?(str1 , str2 ) [](#method-c-compatible?) -Checks the compatibility of two objects. - -If the objects are both strings they are compatible when they are -concatenatable. The encoding of the concatenated string will be returned if -they are compatible, nil if they are not. - - Encoding.compatible?("\xa1".force_encoding("iso-8859-1"), "b") - #=> # - - Encoding.compatible?( - "\xa1".force_encoding("iso-8859-1"), - "\xa1\xa1".force_encoding("euc-jp")) - #=> nil - -If the objects are non-strings their encodings are compatible when they have -an encoding and: -* Either encoding is US-ASCII compatible -* One of the encodings is a 7-bit encoding -**@overload** [] - -## default_external() [](#method-c-default_external) -Returns default external encoding. - -The default external encoding is used by default for strings created from the -following locations: - -* CSV -* File data read from disk -* SDBM -* StringIO -* Zlib::GzipReader -* Zlib::GzipWriter -* String#inspect -* Regexp#inspect - -While strings created from these locations will have this encoding, the -encoding may not be valid. Be sure to check String#valid_encoding?. - -File data written to disk will be transcoded to the default external encoding -when written, if default_internal is not nil. - -The default external encoding is initialized by the -E option. If -E isn't -set, it is initialized to UTF-8 on Windows and the locale on other operating -systems. -**@overload** [] - -## default_external=(encoding ) [](#method-c-default_external=) -Sets default external encoding. You should not set Encoding::default_external -in ruby code as strings created before changing the value may have a different -encoding from strings created after the value was changed., instead you should -use `ruby -E` to invoke ruby with the correct default_external. - -See Encoding::default_external for information on how the default external -encoding is used. -**@overload** [] - -## default_internal() [](#method-c-default_internal) -Returns default internal encoding. Strings will be transcoded to the default -internal encoding in the following places if the default internal encoding is -not nil: - -* CSV -* Etc.sysconfdir and Etc.systmpdir -* File data read from disk -* File names from Dir -* Integer#chr -* String#inspect and Regexp#inspect -* Strings returned from Readline -* Strings returned from SDBM -* Time#zone -* Values from ENV -* Values in ARGV including $PROGRAM_NAME - -Additionally String#encode and String#encode! use the default internal -encoding if no encoding is given. - -The script encoding (__ENCODING__), not default_internal, is used as the -encoding of created strings. - -Encoding::default_internal is initialized with -E option or nil otherwise. -**@overload** [] - -## default_internal=(encoding ) [](#method-c-default_internal=) -Sets default internal encoding or removes default internal encoding when -passed nil. You should not set Encoding::default_internal in ruby code as -strings created before changing the value may have a different encoding from -strings created after the change. Instead you should use `ruby -E` to invoke -ruby with the correct default_internal. - -See Encoding::default_internal for information on how the default internal -encoding is used. -**@overload** [] - -## find(enc ) [](#method-c-find) -Search the encoding with specified *name*. *name* should be a string. - - Encoding.find("US-ASCII") #=> # - -Names which this method accept are encoding names and aliases including -following special aliases - -"external" -: default external encoding - -"internal" -: default internal encoding - -"locale" -: locale encoding - -"filesystem" -: filesystem encoding - - -An ArgumentError is raised when no encoding with *name*. Only -`Encoding.find("internal")` however returns nil when no encoding named -"internal", in other words, when Ruby has no default internal encoding. -**@overload** [] - -## list() [](#method-c-list) -Returns the list of loaded encodings. - - Encoding.list - #=> [#, #, - #] - - Encoding.find("US-ASCII") - #=> # - - Encoding.list - #=> [#, #, - #, #] -**@overload** [] - -## locale_charmap() [](#method-c-locale_charmap) -## name_list() [](#method-c-name_list) -Returns the list of available encoding names. - - Encoding.name_list - #=> ["US-ASCII", "ASCII-8BIT", "UTF-8", - "ISO-8859-1", "Shift_JIS", "EUC-JP", - "Windows-31J", - "BINARY", "CP932", "eucJP"] -**@overload** [] - - -#Instance Methods -## _dump(*args) [](#method-i-_dump) -:nodoc: - -## ascii_compatible?() [](#method-i-ascii_compatible?) -Returns whether ASCII-compatible or not. - - Encoding::UTF_8.ascii_compatible? #=> true - Encoding::UTF_16BE.ascii_compatible? #=> false - -**@overload** [] - -## dummy?() [](#method-i-dummy?) -Returns true for dummy encodings. A dummy encoding is an encoding for which -character handling is not properly implemented. It is used for stateful -encodings. - - Encoding::ISO_2022_JP.dummy? #=> true - Encoding::UTF_8.dummy? #=> false - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string which represents the encoding for programmers. - - Encoding::UTF_8.inspect #=> "#" - Encoding::ISO_2022_JP.inspect #=> "#" - -**@overload** [] - -## name() [](#method-i-name) -Returns the name of the encoding. - - Encoding::UTF_8.name #=> "UTF-8" - -**@overload** [] - -**@overload** [] - -## names() [](#method-i-names) -Returns the list of name and aliases of the encoding. - - Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J", "SJIS", "PCK"] - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns the name of the encoding. - - Encoding::UTF_8.name #=> "UTF-8" - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Encoding/CompatibilityError.md b/example/ruby/Encoding/CompatibilityError.md deleted file mode 100644 index d179139..0000000 --- a/example/ruby/Encoding/CompatibilityError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Encoding::CompatibilityError -**Inherits:** EncodingError - - -Raised by Encoding and String methods when the source encoding is incompatible -with the target encoding. - - - diff --git a/example/ruby/Encoding/Converter.md b/example/ruby/Encoding/Converter.md deleted file mode 100644 index 4026931..0000000 --- a/example/ruby/Encoding/Converter.md +++ /dev/null @@ -1,503 +0,0 @@ -# Class: Encoding::Converter -**Inherits:** Object - - -Encoding conversion class. - - -# Class Methods -## asciicompat_encoding(arg ) [](#method-c-asciicompat_encoding) -Returns the corresponding ASCII compatible encoding. - -Returns nil if the argument is an ASCII compatible encoding. - -"corresponding ASCII compatible encoding" is an ASCII compatible encoding -which can represents exactly the same characters as the given ASCII -incompatible encoding. So, no conversion undefined error occurs when -converting between the two encodings. - - Encoding::Converter.asciicompat_encoding("ISO-2022-JP") #=> # - Encoding::Converter.asciicompat_encoding("UTF-16BE") #=> # - Encoding::Converter.asciicompat_encoding("UTF-8") #=> nil -**@overload** [] - -**@overload** [] - -## search_convpath(*args ) [](#method-c-search_convpath) -Returns a conversion path. - - p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP") - #=> [[#, #], - # [#, #]] - - p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", universal_newline: true) - or - p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", newline: :universal) - #=> [[#, #], - # [#, #], - # "universal_newline"] - - p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", universal_newline: true) - or - p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", newline: :universal) - #=> [[#, #], - # "universal_newline", - # [#, #]] -**@overload** [] - -**@overload** [] - - -#Instance Methods -## ==(other) [](#method-i-==) - -**@overload** [] - -## convert(source_string) [](#method-i-convert) -Convert source_string and return destination_string. - -source_string is assumed as a part of source. i.e. :partial_input=>true is -specified internally. finish method should be used last. - - ec = Encoding::Converter.new("utf-8", "euc-jp") - puts ec.convert("\u3042").dump #=> "\xA4\xA2" - puts ec.finish.dump #=> "" - - ec = Encoding::Converter.new("euc-jp", "utf-8") - puts ec.convert("\xA4").dump #=> "" - puts ec.convert("\xA2").dump #=> "\xE3\x81\x82" - puts ec.finish.dump #=> "" - - ec = Encoding::Converter.new("utf-8", "iso-2022-jp") - puts ec.convert("\xE3").dump #=> "".force_encoding("ISO-2022-JP") - puts ec.convert("\x81").dump #=> "".force_encoding("ISO-2022-JP") - puts ec.convert("\x82").dump #=> "\e$B$\"".force_encoding("ISO-2022-JP") - puts ec.finish.dump #=> "\e(B".force_encoding("ISO-2022-JP") - -If a conversion error occur, Encoding::UndefinedConversionError or -Encoding::InvalidByteSequenceError is raised. Encoding::Converter#convert -doesn't supply methods to recover or restart from these exceptions. When you -want to handle these conversion errors, use -Encoding::Converter#primitive_convert. - -**@overload** [] - -## convpath() [](#method-i-convpath) -Returns the conversion path of ec. - -The result is an array of conversions. - - ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP", crlf_newline: true) - p ec.convpath - #=> [[#, #], - # [#, #], - # "crlf_newline"] - -Each element of the array is a pair of encodings or a string. A pair means an -encoding conversion. A string means a decorator. - -In the above example, [#, #] means a -converter from ISO-8859-1 to UTF-8. "crlf_newline" means newline converter -from LF to CRLF. - -**@overload** [] - -## destination_encoding() [](#method-i-destination_encoding) -Returns the destination encoding as an Encoding object. - -**@overload** [] - -## finish() [](#method-i-finish) -Finishes the converter. It returns the last part of the converted string. - - ec = Encoding::Converter.new("utf-8", "iso-2022-jp") - p ec.convert("\u3042") #=> "\e$B$\"" - p ec.finish #=> "\e(B" - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -possible options elements: - hash form: - :invalid => nil # raise error on invalid byte sequence (default) - :invalid => :replace # replace invalid byte sequence - :undef => nil # raise error on undefined conversion (default) - :undef => :replace # replace undefined conversion - :replace => string # replacement string ("?" or "\uFFFD" if not specified) - :newline => :universal # decorator for converting CRLF and CR to LF - :newline => :lf # decorator for converting CRLF and CR to LF when writing - :newline => :crlf # decorator for converting LF to CRLF - :newline => :cr # decorator for converting LF to CR - :universal_newline => true # decorator for converting CRLF and CR to LF - :crlf_newline => true # decorator for converting LF to CRLF - :cr_newline => true # decorator for converting LF to CR - :lf_newline => true # decorator for converting CRLF and CR to LF when writing - :xml => :text # escape as XML CharData. - :xml => :attr # escape as XML AttValue - integer form: - Encoding::Converter::INVALID_REPLACE - Encoding::Converter::UNDEF_REPLACE - Encoding::Converter::UNDEF_HEX_CHARREF - Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR - Encoding::Converter::LF_NEWLINE_DECORATOR - Encoding::Converter::CRLF_NEWLINE_DECORATOR - Encoding::Converter::CR_NEWLINE_DECORATOR - Encoding::Converter::XML_TEXT_DECORATOR - Encoding::Converter::XML_ATTR_CONTENT_DECORATOR - Encoding::Converter::XML_ATTR_QUOTE_DECORATOR - -Encoding::Converter.new creates an instance of Encoding::Converter. - -Source_encoding and destination_encoding should be a string or Encoding -object. - -opt should be nil, a hash or an integer. - -convpath should be an array. convpath may contain -* two-element arrays which contain encodings or encoding names, or -* strings representing decorator names. - -Encoding::Converter.new optionally takes an option. The option should be a -hash or an integer. The option hash can contain :invalid => nil, etc. The -option integer should be logical-or of constants such as -Encoding::Converter::INVALID_REPLACE, etc. - -:invalid => nil -: Raise error on invalid byte sequence. This is a default behavior. - -:invalid => :replace -: Replace invalid byte sequence by replacement string. - -:undef => nil -: Raise an error if a character in source_encoding is not defined in - destination_encoding. This is a default behavior. - -:undef => :replace -: Replace undefined character in destination_encoding with replacement - string. - -:replace => string -: Specify the replacement string. If not specified, "uFFFD" is used for - Unicode encodings and "?" for others. - -:universal_newline => true -: Convert CRLF and CR to LF. - -:crlf_newline => true -: Convert LF to CRLF. - -:cr_newline => true -: Convert LF to CR. - -:lf_newline => true -: Convert CRLF and CR to LF (when writing). - -:xml => :text -: Escape as XML CharData. This form can be used as an HTML 4.0 #PCDATA. - * '&' -> '&' - * '<' -> '<' - * '>' -> '>' - * undefined characters in destination_encoding -> hexadecimal CharRef - such as &#xHH; - -:xml => :attr -: Escape as XML AttValue. The converted result is quoted as "...". This form - can be used as an HTML 4.0 attribute value. - * '&' -> '&' - * '<' -> '<' - * '>' -> '>' - * '"' -> '"' - * undefined characters in destination_encoding -> hexadecimal CharRef - such as &#xHH; - - -Examples: - # UTF-16BE to UTF-8 - ec = Encoding::Converter.new("UTF-16BE", "UTF-8") - - # Usually, decorators such as newline conversion are inserted last. - ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true) - p ec.convpath #=> [[#, #], - # "universal_newline"] - - # But, if the last encoding is ASCII incompatible, - # decorators are inserted before the last conversion. - ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true) - p ec.convpath #=> ["crlf_newline", - # [#, #]] - - # Conversion path can be specified directly. - ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UTF-8", "UTF-16BE"]]) - p ec.convpath #=> ["universal_newline", - # [#, #], - # [#, #]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## insert_output(string) [](#method-i-insert_output) -Inserts string into the encoding converter. The string will be converted to -the destination encoding and output on later conversions. - -If the destination encoding is stateful, string is converted according to the -state and the state is updated. - -This method should be used only when a conversion error occurs. - - ec = Encoding::Converter.new("utf-8", "iso-8859-1") - src = "HIRAGANA LETTER A is \u{3042}." - dst = "" - p ec.primitive_convert(src, dst) #=> :undefined_conversion - puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is ", "."] - ec.insert_output("") - p ec.primitive_convert(src, dst) #=> :finished - puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is .", ""] - - ec = Encoding::Converter.new("utf-8", "iso-2022-jp") - src = "\u{306F 3041 3068 2661 3002}" # U+2661 is not representable in iso-2022-jp - dst = "" - p ec.primitive_convert(src, dst) #=> :undefined_conversion - puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H".force_encoding("ISO-2022-JP"), "\xE3\x80\x82"] - ec.insert_output "?" # state change required to output "?". - p ec.primitive_convert(src, dst) #=> :finished - puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H\e(B?\e$B!#\e(B".force_encoding("ISO-2022-JP"), ""] - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a printable version of *ec* - - ec = Encoding::Converter.new("iso-8859-1", "utf-8") - puts ec.inspect #=> # - -**@overload** [] - -## last_error() [](#method-i-last_error) -Returns an exception object for the last conversion. Returns nil if the last -conversion did not produce an error. - -"error" means that Encoding::InvalidByteSequenceError and -Encoding::UndefinedConversionError for Encoding::Converter#convert and -:invalid_byte_sequence, :incomplete_input and :undefined_conversion for -Encoding::Converter#primitive_convert. - - ec = Encoding::Converter.new("utf-8", "iso-8859-1") - p ec.primitive_convert(src="\xf1abcd", dst="") #=> :invalid_byte_sequence - p ec.last_error #=> # - p ec.primitive_convert(src, dst, nil, 1) #=> :destination_buffer_full - p ec.last_error #=> nil - -**@overload** [] - -## primitive_convert(*args) [](#method-i-primitive_convert) -possible opt elements: - hash form: - :partial_input => true # source buffer may be part of larger source - :after_output => true # stop conversion after output before input - integer form: - Encoding::Converter::PARTIAL_INPUT - Encoding::Converter::AFTER_OUTPUT - -possible results: - :invalid_byte_sequence - :incomplete_input - :undefined_conversion - :after_output - :destination_buffer_full - :source_buffer_empty - :finished - -primitive_convert converts source_buffer into destination_buffer. - -source_buffer should be a string or nil. nil means an empty string. - -destination_buffer should be a string. - -destination_byteoffset should be an integer or nil. nil means the end of -destination_buffer. If it is omitted, nil is assumed. - -destination_bytesize should be an integer or nil. nil means unlimited. If it -is omitted, nil is assumed. - -opt should be nil, a hash or an integer. nil means no flags. If it is omitted, -nil is assumed. - -primitive_convert converts the content of source_buffer from beginning and -store the result into destination_buffer. - -destination_byteoffset and destination_bytesize specify the region which the -converted result is stored. destination_byteoffset specifies the start -position in destination_buffer in bytes. If destination_byteoffset is nil, -destination_buffer.bytesize is used for appending the result. -destination_bytesize specifies maximum number of bytes. If -destination_bytesize is nil, destination size is unlimited. After conversion, -destination_buffer is resized to destination_byteoffset + actually produced -number of bytes. Also destination_buffer's encoding is set to -destination_encoding. - -primitive_convert drops the converted part of source_buffer. the dropped part -is converted in destination_buffer or buffered in Encoding::Converter object. - -primitive_convert stops conversion when one of following condition met. -* invalid byte sequence found in source buffer (:invalid_byte_sequence) - `primitive_errinfo` and `last_error` methods returns the detail of the - error. -* unexpected end of source buffer (:incomplete_input) this occur only when - :partial_input is not specified. `primitive_errinfo` and `last_error` - methods returns the detail of the error. -* character not representable in output encoding (:undefined_conversion) - `primitive_errinfo` and `last_error` methods returns the detail of the - error. -* after some output is generated, before input is done (:after_output) this - occur only when :after_output is specified. -* destination buffer is full (:destination_buffer_full) this occur only when - destination_bytesize is non-nil. -* source buffer is empty (:source_buffer_empty) this occur only when - :partial_input is specified. -* conversion is finished (:finished) - -example: - ec = Encoding::Converter.new("UTF-8", "UTF-16BE") - ret = ec.primitive_convert(src="pi", dst="", nil, 100) - p [ret, src, dst] #=> [:finished, "", "\x00p\x00i"] - - ec = Encoding::Converter.new("UTF-8", "UTF-16BE") - ret = ec.primitive_convert(src="pi", dst="", nil, 1) - p [ret, src, dst] #=> [:destination_buffer_full, "i", "\x00"] - ret = ec.primitive_convert(src, dst="", nil, 1) - p [ret, src, dst] #=> [:destination_buffer_full, "", "p"] - ret = ec.primitive_convert(src, dst="", nil, 1) - p [ret, src, dst] #=> [:destination_buffer_full, "", "\x00"] - ret = ec.primitive_convert(src, dst="", nil, 1) - p [ret, src, dst] #=> [:finished, "", "i"] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## primitive_errinfo() [](#method-i-primitive_errinfo) -primitive_errinfo returns important information regarding the last error as a -5-element array: - - [result, enc1, enc2, error_bytes, readagain_bytes] - -result is the last result of primitive_convert. - -Other elements are only meaningful when result is :invalid_byte_sequence, -:incomplete_input or :undefined_conversion. - -enc1 and enc2 indicate a conversion step as a pair of strings. For example, a -converter from EUC-JP to ISO-8859-1 converts a string as follows: EUC-JP -> -UTF-8 -> ISO-8859-1. So [enc1, enc2] is either ["EUC-JP", "UTF-8"] or -["UTF-8", "ISO-8859-1"]. - -error_bytes and readagain_bytes indicate the byte sequences which caused the -error. error_bytes is discarded portion. readagain_bytes is buffered portion -which is read again on next conversion. - -Example: - - # \xff is invalid as EUC-JP. - ec = Encoding::Converter.new("EUC-JP", "Shift_JIS") - ec.primitive_convert(src="\xff", dst="", nil, 10) - p ec.primitive_errinfo - #=> [:invalid_byte_sequence, "EUC-JP", "Shift_JIS", "\xFF", ""] - - # HIRAGANA LETTER A (\xa4\xa2 in EUC-JP) is not representable in ISO-8859-1. - # Since this error is occur in UTF-8 to ISO-8859-1 conversion, - # error_bytes is HIRAGANA LETTER A in UTF-8 (\xE3\x81\x82). - ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - ec.primitive_convert(src="\xa4\xa2", dst="", nil, 10) - p ec.primitive_errinfo - #=> [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE3\x81\x82", ""] - - # partial character is invalid - ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - ec.primitive_convert(src="\xa4", dst="", nil, 10) - p ec.primitive_errinfo - #=> [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""] - - # Encoding::Converter::PARTIAL_INPUT prevents invalid errors by - # partial characters. - ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT) - p ec.primitive_errinfo - #=> [:source_buffer_empty, nil, nil, nil, nil] - - # \xd8\x00\x00@ is invalid as UTF-16BE because - # no low surrogate after high surrogate (\xd8\x00). - # It is detected by 3rd byte (\00) which is part of next character. - # So the high surrogate (\xd8\x00) is discarded and - # the 3rd byte is read again later. - # Since the byte is buffered in ec, it is dropped from src. - ec = Encoding::Converter.new("UTF-16BE", "UTF-8") - ec.primitive_convert(src="\xd8\x00\x00@", dst="", nil, 10) - p ec.primitive_errinfo - #=> [:invalid_byte_sequence, "UTF-16BE", "UTF-8", "\xD8\x00", "\x00"] - p src - #=> "@" - - # Similar to UTF-16BE, \x00\xd8@\x00 is invalid as UTF-16LE. - # The problem is detected by 4th byte. - ec = Encoding::Converter.new("UTF-16LE", "UTF-8") - ec.primitive_convert(src="\x00\xd8@\x00", dst="", nil, 10) - p ec.primitive_errinfo - #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "@\x00"] - p src - #=> "" - -**@overload** [] - -## putback(*args) [](#method-i-putback) -Put back the bytes which will be converted. - -The bytes are caused by invalid_byte_sequence error. When -invalid_byte_sequence error, some bytes are discarded and some bytes are -buffered to be converted later. The latter bytes can be put back. It can be -observed by Encoding::InvalidByteSequenceError#readagain_bytes and -Encoding::Converter#primitive_errinfo. - - ec = Encoding::Converter.new("utf-16le", "iso-8859-1") - src = "\x00\xd8\x61\x00" - dst = "" - p ec.primitive_convert(src, dst) #=> :invalid_byte_sequence - p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"] - p ec.putback #=> "a\x00" - p ec.putback #=> "" # no more bytes to put back - -**@overload** [] - -**@overload** [] - -## replacement() [](#method-i-replacement) -Returns the replacement string. - - ec = Encoding::Converter.new("euc-jp", "us-ascii") - p ec.replacement #=> "?" - - ec = Encoding::Converter.new("euc-jp", "utf-8") - p ec.replacement #=> "\uFFFD" - -**@overload** [] - -## replacement=(arg) [](#method-i-replacement=) -Sets the replacement string. - - ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace) - ec.replacement = "" - p ec.convert("a \u3042 b") #=> "a b" - -**@overload** [] - -## source_encoding() [](#method-i-source_encoding) -Returns the source encoding as an Encoding object. - -**@overload** [] - diff --git a/example/ruby/Encoding/ConverterNotFoundError.md b/example/ruby/Encoding/ConverterNotFoundError.md deleted file mode 100644 index 45ea395..0000000 --- a/example/ruby/Encoding/ConverterNotFoundError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Encoding::ConverterNotFoundError -**Inherits:** EncodingError - - -Raised by transcoding methods when a named encoding does not correspond with a -known converter. - - - diff --git a/example/ruby/Encoding/InvalidByteSequenceError.md b/example/ruby/Encoding/InvalidByteSequenceError.md deleted file mode 100644 index f4facb7..0000000 --- a/example/ruby/Encoding/InvalidByteSequenceError.md +++ /dev/null @@ -1,86 +0,0 @@ -# Exception: Encoding::InvalidByteSequenceError -**Inherits:** EncodingError - - -Raised by Encoding and String methods when the string being transcoded -contains a byte invalid for the either the source or target encoding. - - - -#Instance Methods -## destination_encoding() [](#method-i-destination_encoding) -Returns the destination encoding as an encoding object. - -**@overload** [] - -## destination_encoding_name() [](#method-i-destination_encoding_name) -Returns the destination encoding name as a string. - -**@overload** [] - -## error_bytes() [](#method-i-error_bytes) -Returns the discarded bytes when Encoding::InvalidByteSequenceError occurs. - - ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - begin - ec.convert("abc\xA1\xFFdef") - rescue Encoding::InvalidByteSequenceError - p $! #=> # - puts $!.error_bytes.dump #=> "\xA1" - puts $!.readagain_bytes.dump #=> "\xFF" - end - -**@overload** [] - -## incomplete_input?() [](#method-i-incomplete_input?) -Returns true if the invalid byte sequence error is caused by premature end of -string. - - ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - - begin - ec.convert("abc\xA1z") - rescue Encoding::InvalidByteSequenceError - p $! #=> # - p $!.incomplete_input? #=> false - end - - begin - ec.convert("abc\xA1") - ec.finish - rescue Encoding::InvalidByteSequenceError - p $! #=> # - p $!.incomplete_input? #=> true - end - -**@overload** [] - -## readagain_bytes() [](#method-i-readagain_bytes) -Returns the bytes to be read again when Encoding::InvalidByteSequenceError -occurs. - -**@overload** [] - -## source_encoding() [](#method-i-source_encoding) -Returns the source encoding as an encoding object. - -Note that the result may not be equal to the source encoding of the encoding -converter if the conversion has multiple steps. - - ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP - begin - ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP. - rescue Encoding::UndefinedConversionError - p $!.source_encoding #=> # - p $!.destination_encoding #=> # - p $!.source_encoding_name #=> "UTF-8" - p $!.destination_encoding_name #=> "EUC-JP" - end - -**@overload** [] - -## source_encoding_name() [](#method-i-source_encoding_name) -Returns the source encoding name as a string. - -**@overload** [] - diff --git a/example/ruby/Encoding/UndefinedConversionError.md b/example/ruby/Encoding/UndefinedConversionError.md deleted file mode 100644 index afb053c..0000000 --- a/example/ruby/Encoding/UndefinedConversionError.md +++ /dev/null @@ -1,56 +0,0 @@ -# Exception: Encoding::UndefinedConversionError -**Inherits:** EncodingError - - -Raised by Encoding and String methods when a transcoding operation fails. - - - -#Instance Methods -## destination_encoding() [](#method-i-destination_encoding) -Returns the destination encoding as an encoding object. - -**@overload** [] - -## destination_encoding_name() [](#method-i-destination_encoding_name) -Returns the destination encoding name as a string. - -**@overload** [] - -## error_char() [](#method-i-error_char) -Returns the one-character string which cause -Encoding::UndefinedConversionError. - - ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") - begin - ec.convert("\xa0") - rescue Encoding::UndefinedConversionError - puts $!.error_char.dump #=> "\xC2\xA0" - p $!.error_char.encoding #=> # - end - -**@overload** [] - -## source_encoding() [](#method-i-source_encoding) -Returns the source encoding as an encoding object. - -Note that the result may not be equal to the source encoding of the encoding -converter if the conversion has multiple steps. - - ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP - begin - ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP. - rescue Encoding::UndefinedConversionError - p $!.source_encoding #=> # - p $!.destination_encoding #=> # - p $!.source_encoding_name #=> "UTF-8" - p $!.destination_encoding_name #=> "EUC-JP" - end - -**@overload** [] - -## source_encoding_name() [](#method-i-source_encoding_name) -Returns the source encoding name as a string. - -**@overload** [] - diff --git a/example/ruby/EncodingError.md b/example/ruby/EncodingError.md deleted file mode 100644 index 6c11589..0000000 --- a/example/ruby/EncodingError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: EncodingError -**Inherits:** StandardError - - -EncodingError is the base class for encoding errors. - - - diff --git a/example/ruby/EncodingSpecs.md b/example/ruby/EncodingSpecs.md deleted file mode 100644 index ef24008..0000000 --- a/example/ruby/EncodingSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: EncodingSpecs - - - - - diff --git a/example/ruby/EncodingSpecs/InvalidByteSequenceError.md b/example/ruby/EncodingSpecs/InvalidByteSequenceError.md deleted file mode 100644 index b916565..0000000 --- a/example/ruby/EncodingSpecs/InvalidByteSequenceError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: EncodingSpecs::InvalidByteSequenceError -**Inherits:** Object - - - - -# Class Methods -## exception() [](#method-c-exception) - diff --git a/example/ruby/EncodingSpecs/InvalidByteSequenceErrorIndirect.md b/example/ruby/EncodingSpecs/InvalidByteSequenceErrorIndirect.md deleted file mode 100644 index 17945fa..0000000 --- a/example/ruby/EncodingSpecs/InvalidByteSequenceErrorIndirect.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: EncodingSpecs::InvalidByteSequenceErrorIndirect -**Inherits:** Object - - - - -# Class Methods -## exception() [](#method-c-exception) - diff --git a/example/ruby/EncodingSpecs/UndefinedConversionError.md b/example/ruby/EncodingSpecs/UndefinedConversionError.md deleted file mode 100644 index 0233f9d..0000000 --- a/example/ruby/EncodingSpecs/UndefinedConversionError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: EncodingSpecs::UndefinedConversionError -**Inherits:** Object - - - - -# Class Methods -## exception() [](#method-c-exception) - diff --git a/example/ruby/EncodingSpecs/UndefinedConversionErrorIndirect.md b/example/ruby/EncodingSpecs/UndefinedConversionErrorIndirect.md deleted file mode 100644 index 16c7095..0000000 --- a/example/ruby/EncodingSpecs/UndefinedConversionErrorIndirect.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: EncodingSpecs::UndefinedConversionErrorIndirect -**Inherits:** Object - - - - -# Class Methods -## exception() [](#method-c-exception) - diff --git a/example/ruby/EndianGuard.md b/example/ruby/EndianGuard.md deleted file mode 100644 index e66e853..0000000 --- a/example/ruby/EndianGuard.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: EndianGuard -**Inherits:** SpecGuard - - -Despite that these are inverses, the two classes are used to simplify MSpec -guard reporting modes - - - diff --git a/example/ruby/Endpoint.md b/example/ruby/Endpoint.md deleted file mode 100644 index 07c8e08..0000000 --- a/example/ruby/Endpoint.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Endpoint -**Inherits:** Sinatra::Base - - - - -# Class Methods -## all_requests() [](#method-c-all_requests) - -#Instance Methods -## call!() [](#method-i-call!) - diff --git a/example/ruby/Endpoint500.md b/example/ruby/Endpoint500.md deleted file mode 100644 index 1623e26..0000000 --- a/example/ruby/Endpoint500.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Endpoint500 -**Inherits:** Sinatra::Base - - - - - diff --git a/example/ruby/EndpointApiForbidden.md b/example/ruby/EndpointApiForbidden.md deleted file mode 100644 index fd737c8..0000000 --- a/example/ruby/EndpointApiForbidden.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointApiForbidden -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointBasicAuthentication.md b/example/ruby/EndpointBasicAuthentication.md deleted file mode 100644 index 8b12a9f..0000000 --- a/example/ruby/EndpointBasicAuthentication.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointBasicAuthentication -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointCredsDiffHost.md b/example/ruby/EndpointCredsDiffHost.md deleted file mode 100644 index 1f90fa9..0000000 --- a/example/ruby/EndpointCredsDiffHost.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointCredsDiffHost -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointExtra.md b/example/ruby/EndpointExtra.md deleted file mode 100644 index a9d05d9..0000000 --- a/example/ruby/EndpointExtra.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointExtra -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointExtraApi.md b/example/ruby/EndpointExtraApi.md deleted file mode 100644 index 9dfc2fb..0000000 --- a/example/ruby/EndpointExtraApi.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointExtraApi -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointExtraMissing.md b/example/ruby/EndpointExtraMissing.md deleted file mode 100644 index ca0357c..0000000 --- a/example/ruby/EndpointExtraMissing.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointExtraMissing -**Inherits:** EndpointExtra - - - - - diff --git a/example/ruby/EndpointFallback.md b/example/ruby/EndpointFallback.md deleted file mode 100644 index b9aef8d..0000000 --- a/example/ruby/EndpointFallback.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointFallback -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointHostRedirect.md b/example/ruby/EndpointHostRedirect.md deleted file mode 100644 index 7cf4781..0000000 --- a/example/ruby/EndpointHostRedirect.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointHostRedirect -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointMarshalFail.md b/example/ruby/EndpointMarshalFail.md deleted file mode 100644 index 9d40113..0000000 --- a/example/ruby/EndpointMarshalFail.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointMarshalFail -**Inherits:** EndpointFallback - - - - - diff --git a/example/ruby/EndpointMarshalFailBasicAuthentication.md b/example/ruby/EndpointMarshalFailBasicAuthentication.md deleted file mode 100644 index 7f3137f..0000000 --- a/example/ruby/EndpointMarshalFailBasicAuthentication.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointMarshalFailBasicAuthentication -**Inherits:** EndpointMarshalFail - - - - - diff --git a/example/ruby/EndpointMirrorSource.md b/example/ruby/EndpointMirrorSource.md deleted file mode 100644 index 6256825..0000000 --- a/example/ruby/EndpointMirrorSource.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointMirrorSource -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointRedirect.md b/example/ruby/EndpointRedirect.md deleted file mode 100644 index 1322674..0000000 --- a/example/ruby/EndpointRedirect.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointRedirect -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointStrictBasicAuthentication.md b/example/ruby/EndpointStrictBasicAuthentication.md deleted file mode 100644 index 628f178..0000000 --- a/example/ruby/EndpointStrictBasicAuthentication.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointStrictBasicAuthentication -**Inherits:** Endpoint - - - - - diff --git a/example/ruby/EndpointTimeout.md b/example/ruby/EndpointTimeout.md deleted file mode 100644 index 88b9c19..0000000 --- a/example/ruby/EndpointTimeout.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: EndpointTimeout -**Inherits:** EndpointFallback - - - - - diff --git a/example/ruby/English.md b/example/ruby/English.md deleted file mode 100644 index 9977947..0000000 --- a/example/ruby/English.md +++ /dev/null @@ -1,51 +0,0 @@ -# Module: English - - -Include the English library file in a Ruby script, and you can - reference the global variables such as $_ using less - cryptic names, listed below. - - Without 'English': - - $\ = ' -- ' - "waterbuffalo" =~ /buff/ - print $', $$, "\n" - - With English: - - require "English" - - $OUTPUT_FIELD_SEPARATOR = ' -- ' - "waterbuffalo" =~ /buff/ - print $POSTMATCH, $PID, "\n" - - Below is a full list of descriptive aliases and their associated global - variable: - - $ERROR_INFO:: $! - $ERROR_POSITION:: $@ - $FS:: $; - $FIELD_SEPARATOR:: $; - $OFS:: $, - $OUTPUT_FIELD_SEPARATOR:: $, - $RS:: $/ - $INPUT_RECORD_SEPARATOR:: $/ - $ORS:: $\ - $OUTPUT_RECORD_SEPARATOR:: $\ - $INPUT_LINE_NUMBER:: $. - $NR:: $. - $LAST_READ_LINE:: $_ - $DEFAULT_OUTPUT:: $> - $DEFAULT_INPUT:: $< - $PID:: $$ - $PROCESS_ID:: $$ - $CHILD_STATUS:: $? - $LAST_MATCH_INFO:: $~ - $ARGV:: $* - $MATCH:: $& - $PREMATCH:: $` - $POSTMATCH:: $' - $LAST_PAREN_MATCH:: $+ - - - diff --git a/example/ruby/EnsureAndCallcc.md b/example/ruby/EnsureAndCallcc.md deleted file mode 100644 index a9463e1..0000000 --- a/example/ruby/EnsureAndCallcc.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: EnsureAndCallcc - - - - -# Class Methods -## ensure_called() [](#method-c-ensure_called) -## require_with_ensure(fname ) [](#method-c-require_with_ensure) -## reset() [](#method-c-reset) - diff --git a/example/ruby/EnsureSpec.md b/example/ruby/EnsureSpec.md deleted file mode 100644 index 30c6dd1..0000000 --- a/example/ruby/EnsureSpec.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: EnsureSpec - - - - - diff --git a/example/ruby/EnsureSpec/Container.md b/example/ruby/EnsureSpec/Container.md deleted file mode 100644 index 5988123..0000000 --- a/example/ruby/EnsureSpec/Container.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: EnsureSpec::Container -**Inherits:** Object - - - - -# Attributes -## executed[RW] [](#attribute-i-executed) -Returns the value of attribute executed. - - -#Instance Methods -## explicit_return_in_method_with_ensure() [](#method-i-explicit_return_in_method_with_ensure) - -## explicit_return_in_rescue_and_explicit_return_in_ensure() [](#method-i-explicit_return_in_rescue_and_explicit_return_in_ensure) - -## explicit_return_in_rescue_and_implicit_return_in_ensure() [](#method-i-explicit_return_in_rescue_and_implicit_return_in_ensure) - -## implicit_return_in_method_with_ensure() [](#method-i-implicit_return_in_method_with_ensure) - -## initialize() [](#method-i-initialize) - -**@return** [Container] a new instance of Container - -## raise_and_explicit_return_in_ensure() [](#method-i-raise_and_explicit_return_in_ensure) - -## raise_and_rescue_in_method_with_ensure() [](#method-i-raise_and_rescue_in_method_with_ensure) - -## raise_in_method_and_raise_in_ensure() [](#method-i-raise_in_method_and_raise_in_ensure) - -## raise_in_method_with_ensure() [](#method-i-raise_in_method_with_ensure) - -## raise_in_rescue_and_explicit_return_in_ensure() [](#method-i-raise_in_rescue_and_explicit_return_in_ensure) - -## raise_in_rescue_and_raise_in_ensure() [](#method-i-raise_in_rescue_and_raise_in_ensure) - -## throw_in_method_with_ensure() [](#method-i-throw_in_method_with_ensure) - diff --git a/example/ruby/EnsureSpec/Error.md b/example/ruby/EnsureSpec/Error.md deleted file mode 100644 index 6a1196b..0000000 --- a/example/ruby/EnsureSpec/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: EnsureSpec::Error -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/EnsureSpec/Test.md b/example/ruby/EnsureSpec/Test.md deleted file mode 100644 index 6a53600..0000000 --- a/example/ruby/EnsureSpec/Test.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: EnsureSpec::Test -**Inherits:** Object - - - - -# Attributes -## values[RW] [](#attribute-i-values) -Returns the value of attribute values. - - -#Instance Methods -## call_block() [](#method-i-call_block) - -## do_test() [](#method-i-do_test) - -## initialize() [](#method-i-initialize) - -**@return** [Test] a new instance of Test - diff --git a/example/ruby/EnumSpecs.md b/example/ruby/EnumSpecs.md deleted file mode 100644 index 533a6a6..0000000 --- a/example/ruby/EnumSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: EnumSpecs - - - - - diff --git a/example/ruby/EnumSpecs/Numerous.md b/example/ruby/EnumSpecs/Numerous.md deleted file mode 100644 index 1bc681c..0000000 --- a/example/ruby/EnumSpecs/Numerous.md +++ /dev/null @@ -1,2074 +0,0 @@ -# Class: EnumSpecs::Numerous -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*list) [](#method-i-initialize) - -**@return** [Numerous] a new instance of Numerous - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Enumerable.md b/example/ruby/Enumerable.md deleted file mode 100644 index 8faf54b..0000000 --- a/example/ruby/Enumerable.md +++ /dev/null @@ -1,2256 +0,0 @@ -# Module: Enumerable - - -## What's Here - -Module Enumerable provides methods that are useful to a collection class for: - -* [Querying](rdoc-ref:Enumerable@Methods+for+Querying) -* [Fetching](rdoc-ref:Enumerable@Methods+for+Fetching) -* [Searching and - Filtering](rdoc-ref:Enumerable@Methods+for+Searching+and+Filtering) -* [Sorting](rdoc-ref:Enumerable@Methods+for+Sorting) -* [Iterating](rdoc-ref:Enumerable@Methods+for+Iterating) -* [And more....](rdoc-ref:Enumerable@Other+Methods) - -### Methods for Querying - -These methods return information about the Enumerable other than the elements -themselves: - -* #member? (aliased as #include?): Returns `true` if `self == object`, - `false` otherwise. -* #all?: Returns `true` if all elements meet a specified criterion; `false` - otherwise. -* #any?: Returns `true` if any element meets a specified criterion; `false` - otherwise. -* #none?: Returns `true` if no element meets a specified criterion; `false` - otherwise. -* #one?: Returns `true` if exactly one element meets a specified criterion; - `false` otherwise. -* #count: Returns the count of elements, based on an argument or block - criterion, if given. -* #tally: Returns a new Hash containing the counts of occurrences of each - element. - -### Methods for Fetching - -These methods return entries from the Enumerable, without modifying it: - -*Leading, trailing, or all elements*: - -* #to_a (aliased as #entries): Returns all elements. -* #first: Returns the first element or leading elements. -* #take: Returns a specified number of leading elements. -* #drop: Returns a specified number of trailing elements. -* #take_while: Returns leading elements as specified by the given block. -* #drop_while: Returns trailing elements as specified by the given block. - -*Minimum and maximum value elements*: - -* #min: Returns the elements whose values are smallest among the elements, - as determined by `#<=>` or a given block. -* #max: Returns the elements whose values are largest among the elements, as - determined by `#<=>` or a given block. -* #minmax: Returns a 2-element Array containing the smallest and largest - elements. -* #min_by: Returns the smallest element, as determined by the given block. -* #max_by: Returns the largest element, as determined by the given block. -* #minmax_by: Returns the smallest and largest elements, as determined by - the given block. - -*Groups, slices, and partitions*: - -* #group_by: Returns a Hash that partitions the elements into groups. -* #partition: Returns elements partitioned into two new Arrays, as - determined by the given block. -* #slice_after: Returns a new Enumerator whose entries are a partition of - `self`, based either on a given `object` or a given block. -* #slice_before: Returns a new Enumerator whose entries are a partition of - `self`, based either on a given `object` or a given block. -* #slice_when: Returns a new Enumerator whose entries are a partition of - `self` based on the given block. -* #chunk: Returns elements organized into chunks as specified by the given - block. -* #chunk_while: Returns elements organized into chunks as specified by the - given block. - -### Methods for Searching and Filtering - -These methods return elements that meet a specified criterion: - -* #find (aliased as #detect): Returns an element selected by the block. -* #find_all (aliased as #filter, #select): Returns elements selected by the - block. -* #find_index: Returns the index of an element selected by a given object or - block. -* #reject: Returns elements not rejected by the block. -* #uniq: Returns elements that are not duplicates. - -### Methods for Sorting - -These methods return elements in sorted order: - -* #sort: Returns the elements, sorted by `#<=>` or the given block. -* #sort_by: Returns the elements, sorted by the given block. - -### Methods for Iterating - -* #each_entry: Calls the block with each successive element (slightly - different from #each). -* #each_with_index: Calls the block with each successive element and its - index. -* #each_with_object: Calls the block with each successive element and a - given object. -* #each_slice: Calls the block with successive non-overlapping slices. -* #each_cons: Calls the block with successive overlapping slices. (different - from #each_slice). -* #reverse_each: Calls the block with each successive element, in reverse - order. - -### Other Methods - -* #collect (aliased as #map): Returns objects returned by the block. -* #filter_map: Returns truthy objects returned by the block. -* #flat_map (aliased as #collect_concat): Returns flattened objects returned - by the block. -* #grep: Returns elements selected by a given object or objects returned by - a given block. -* #grep_v: Returns elements selected by a given object or objects returned - by a given block. -* #inject (aliased as #reduce): Returns the object formed by combining all - elements. -* #sum: Returns the sum of the elements, using method `+`. -* #zip: Combines each element with elements from other enumerables; returns - the n-tuples or calls the block with each. -* #cycle: Calls the block with each element, cycling repeatedly. - -## Usage - -To use module Enumerable in a collection class: - -* Include it: - - include Enumerable - -* Implement method `#each` which must yield successive elements of the - collection. The method will be called by almost any Enumerable method. - -Example: - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry{ |element| p element } - -Output: - - 1 - [1, 2] - nil - -## Enumerable in Ruby Classes - -These Ruby core classes include (or extend) Enumerable: - -* ARGF -* Array -* Dir -* Enumerator -* ENV (extends) -* Hash -* IO -* Range -* Struct - -These Ruby standard library classes include Enumerable: - -* CSV -* CSV::Table -* CSV::Row -* Set - -Virtually all methods in Enumerable call method `#each` in the including -class: - -* `Hash#each` yields the next key-value pair as a 2-element Array. -* `Struct#each` yields the next name-value pair as a 2-element Array. -* For the other classes above, `#each` yields the next object from the - collection. - -## About the Examples - -The example code snippets for the Enumerable methods: - -* Always show the use of one or more Array-like classes (often Array - itself). -* Sometimes show the use of a Hash-like class. For some methods, though, the - usage would not make sense, and so it is not shown. Example: #tally would - find exactly one of each Hash entry. - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs.md b/example/ruby/EnumerableSpecs.md deleted file mode 100644 index d695f08..0000000 --- a/example/ruby/EnumerableSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: EnumerableSpecs - - - - - diff --git a/example/ruby/EnumerableSpecs/ArrayConvertible.md b/example/ruby/EnumerableSpecs/ArrayConvertible.md deleted file mode 100644 index f17283c..0000000 --- a/example/ruby/EnumerableSpecs/ArrayConvertible.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: EnumerableSpecs::ArrayConvertible -**Inherits:** Object - - - - -# Attributes -## called[RW] [](#attribute-i-called) -Returns the value of attribute called. - - -#Instance Methods -## initialize(*values) [](#method-i-initialize) - -**@return** [ArrayConvertible] a new instance of ArrayConvertible - -## to_a() [](#method-i-to_a) - -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/EnumerableSpecs/ComparableWithInteger.md b/example/ruby/EnumerableSpecs/ComparableWithInteger.md deleted file mode 100644 index 5f44f0e..0000000 --- a/example/ruby/EnumerableSpecs/ComparableWithInteger.md +++ /dev/null @@ -1,99 +0,0 @@ -# Class: EnumerableSpecs::ComparableWithInteger -**Inherits:** Object - -**Includes:** Comparable - - - - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(fixnum) [](#method-i-<=>) - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## initialize(num) [](#method-i-initialize) - -**@return** [ComparableWithInteger] a new instance of ComparableWithInteger - diff --git a/example/ruby/EnumerableSpecs/ComparesByVowelCount.md b/example/ruby/EnumerableSpecs/ComparesByVowelCount.md deleted file mode 100644 index dc8a6c6..0000000 --- a/example/ruby/EnumerableSpecs/ComparesByVowelCount.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: EnumerableSpecs::ComparesByVowelCount -**Inherits:** Object - - - - -# Class Methods -## wrap(*args ) [](#method-c-wrap) -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - -## vowels[RW] [](#attribute-i-vowels) -Returns the value of attribute vowels. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - -## initialize(string) [](#method-i-initialize) - -**@return** [ComparesByVowelCount] a new instance of ComparesByVowelCount - diff --git a/example/ruby/EnumerableSpecs/EachCounter.md b/example/ruby/EnumerableSpecs/EachCounter.md deleted file mode 100644 index 78e05a2..0000000 --- a/example/ruby/EnumerableSpecs/EachCounter.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: EnumerableSpecs::EachCounter -**Inherits:** EnumerableSpecs::Numerous - - - - -# Attributes -## arguments_passed[RW] [](#attribute-i-arguments_passed) -Returns the value of attribute arguments_passed. - -## times_called[RW] [](#attribute-i-times_called) -Returns the value of attribute times_called. - -## times_yielded[RW] [](#attribute-i-times_yielded) -Returns the value of attribute times_yielded. - - -#Instance Methods -## each(*arg) [](#method-i-each) - -## initialize(*list) [](#method-i-initialize) - -**@return** [EachCounter] a new instance of EachCounter - diff --git a/example/ruby/EnumerableSpecs/EachDefiner.md b/example/ruby/EnumerableSpecs/EachDefiner.md deleted file mode 100644 index 9fb1345..0000000 --- a/example/ruby/EnumerableSpecs/EachDefiner.md +++ /dev/null @@ -1,2079 +0,0 @@ -# Class: EnumerableSpecs::EachDefiner -**Inherits:** Object - -**Includes:** Enumerable - - -(Legacy form rubycon) - - -# Attributes -## arr[RW] [](#attribute-i-arr) -Returns the value of attribute arr. - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*arr) [](#method-i-initialize) - -**@return** [EachDefiner] a new instance of EachDefiner - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/Empty.md b/example/ruby/EnumerableSpecs/Empty.md deleted file mode 100644 index df33d46..0000000 --- a/example/ruby/EnumerableSpecs/Empty.md +++ /dev/null @@ -1,2070 +0,0 @@ -# Class: EnumerableSpecs::Empty -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/EmptyWithSize.md b/example/ruby/EnumerableSpecs/EmptyWithSize.md deleted file mode 100644 index 79756b5..0000000 --- a/example/ruby/EnumerableSpecs/EmptyWithSize.md +++ /dev/null @@ -1,2072 +0,0 @@ -# Class: EnumerableSpecs::EmptyWithSize -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/EnumConvertible.md b/example/ruby/EnumerableSpecs/EnumConvertible.md deleted file mode 100644 index 1942a6a..0000000 --- a/example/ruby/EnumerableSpecs/EnumConvertible.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: EnumerableSpecs::EnumConvertible -**Inherits:** Object - - - - -# Attributes -## called[RW] [](#attribute-i-called) -Returns the value of attribute called. - -## sym[RW] [](#attribute-i-sym) -Returns the value of attribute sym. - - -#Instance Methods -## initialize(delegate) [](#method-i-initialize) - -**@return** [EnumConvertible] a new instance of EnumConvertible - -## respond_to_missing?(*args) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - -## to_enum(sym) [](#method-i-to_enum) - diff --git a/example/ruby/EnumerableSpecs/Equals.md b/example/ruby/EnumerableSpecs/Equals.md deleted file mode 100644 index e4b15dc..0000000 --- a/example/ruby/EnumerableSpecs/Equals.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: EnumerableSpecs::Equals -**Inherits:** Object - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(obj) [](#method-i-initialize) - -**@return** [Equals] a new instance of Equals - diff --git a/example/ruby/EnumerableSpecs/Freezy.md b/example/ruby/EnumerableSpecs/Freezy.md deleted file mode 100644 index 9fcf5d8..0000000 --- a/example/ruby/EnumerableSpecs/Freezy.md +++ /dev/null @@ -1,2067 +0,0 @@ -# Class: EnumerableSpecs::Freezy -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -**@yield** [1] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/InvalidComparable.md b/example/ruby/EnumerableSpecs/InvalidComparable.md deleted file mode 100644 index 6ca655c..0000000 --- a/example/ruby/EnumerableSpecs/InvalidComparable.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: EnumerableSpecs::InvalidComparable -**Inherits:** Object - - - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - diff --git a/example/ruby/EnumerableSpecs/MapReturnsEnumerable.md b/example/ruby/EnumerableSpecs/MapReturnsEnumerable.md deleted file mode 100644 index 4d148ac..0000000 --- a/example/ruby/EnumerableSpecs/MapReturnsEnumerable.md +++ /dev/null @@ -1,2059 +0,0 @@ -# Class: EnumerableSpecs::MapReturnsEnumerable -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -**@yield** [1] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map(&block) [](#method-i-map) - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/MapReturnsEnumerable/EnumerableMapping.md b/example/ruby/EnumerableSpecs/MapReturnsEnumerable/EnumerableMapping.md deleted file mode 100644 index 297c352..0000000 --- a/example/ruby/EnumerableSpecs/MapReturnsEnumerable/EnumerableMapping.md +++ /dev/null @@ -1,2074 +0,0 @@ -# Class: EnumerableSpecs::MapReturnsEnumerable::EnumerableMapping -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(items, block) [](#method-i-initialize) - -**@return** [EnumerableMapping] a new instance of EnumerableMapping - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/NoEach.md b/example/ruby/EnumerableSpecs/NoEach.md deleted file mode 100644 index f377cce..0000000 --- a/example/ruby/EnumerableSpecs/NoEach.md +++ /dev/null @@ -1,2068 +0,0 @@ -# Class: EnumerableSpecs::NoEach -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/Numerous.md b/example/ruby/EnumerableSpecs/Numerous.md deleted file mode 100644 index 34ac34c..0000000 --- a/example/ruby/EnumerableSpecs/Numerous.md +++ /dev/null @@ -1,2074 +0,0 @@ -# Class: EnumerableSpecs::Numerous -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*list) [](#method-i-initialize) - -**@return** [Numerous] a new instance of Numerous - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/NumerousWithSize.md b/example/ruby/EnumerableSpecs/NumerousWithSize.md deleted file mode 100644 index abeedc6..0000000 --- a/example/ruby/EnumerableSpecs/NumerousWithSize.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: EnumerableSpecs::NumerousWithSize -**Inherits:** EnumerableSpecs::Numerous - - - - - -#Instance Methods -## size() [](#method-i-size) - diff --git a/example/ruby/EnumerableSpecs/Pattern.md b/example/ruby/EnumerableSpecs/Pattern.md deleted file mode 100644 index c78721a..0000000 --- a/example/ruby/EnumerableSpecs/Pattern.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: EnumerableSpecs::Pattern -**Inherits:** Object - - - - -# Attributes -## yielded[RW] [](#attribute-i-yielded) -Returns the value of attribute yielded. - - -#Instance Methods -## ===(*args) [](#method-i-===) - -## initialize(&block) [](#method-i-initialize) - -**@return** [Pattern] a new instance of Pattern - diff --git a/example/ruby/EnumerableSpecs/ReverseComparable.md b/example/ruby/EnumerableSpecs/ReverseComparable.md deleted file mode 100644 index 6bb862b..0000000 --- a/example/ruby/EnumerableSpecs/ReverseComparable.md +++ /dev/null @@ -1,104 +0,0 @@ -# Class: EnumerableSpecs::ReverseComparable -**Inherits:** Object - -**Includes:** Comparable - - - - -# Attributes -## num[RW] [](#attribute-i-num) -Returns the value of attribute num. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Reverse comparison - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## initialize(num) [](#method-i-initialize) - -**@return** [ReverseComparable] a new instance of ReverseComparable - diff --git a/example/ruby/EnumerableSpecs/SortByDummy.md b/example/ruby/EnumerableSpecs/SortByDummy.md deleted file mode 100644 index 240e878..0000000 --- a/example/ruby/EnumerableSpecs/SortByDummy.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: EnumerableSpecs::SortByDummy -**Inherits:** Object - - - - - -#Instance Methods -## initialize(s) [](#method-i-initialize) - -**@return** [SortByDummy] a new instance of SortByDummy - -## s() [](#method-i-s) - diff --git a/example/ruby/EnumerableSpecs/ThrowingEach.md b/example/ruby/EnumerableSpecs/ThrowingEach.md deleted file mode 100644 index afaa48c..0000000 --- a/example/ruby/EnumerableSpecs/ThrowingEach.md +++ /dev/null @@ -1,2070 +0,0 @@ -# Class: EnumerableSpecs::ThrowingEach -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/Uncomparable.md b/example/ruby/EnumerableSpecs/Uncomparable.md deleted file mode 100644 index 6343701..0000000 --- a/example/ruby/EnumerableSpecs/Uncomparable.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: EnumerableSpecs::Uncomparable -**Inherits:** Object - - - - - -#Instance Methods -## <=>(obj) [](#method-i-<=>) - diff --git a/example/ruby/EnumerableSpecs/Undupable.md b/example/ruby/EnumerableSpecs/Undupable.md deleted file mode 100644 index 7809fe3..0000000 --- a/example/ruby/EnumerableSpecs/Undupable.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: EnumerableSpecs::Undupable -**Inherits:** Object - - - - -# Attributes -## initialize_called[RW] [](#attribute-i-initialize_called) -Returns the value of attribute initialize_called. - -## initialize_dup_called[RW] [](#attribute-i-initialize_dup_called) -Returns the value of attribute initialize_dup_called. - - -#Instance Methods -## clone() [](#method-i-clone) - -## dup() [](#method-i-dup) - -## initialize() [](#method-i-initialize) - -**@return** [Undupable] a new instance of Undupable - -## initialize_dup(arg) [](#method-i-initialize_dup) - diff --git a/example/ruby/EnumerableSpecs/YieldsMixed.md b/example/ruby/EnumerableSpecs/YieldsMixed.md deleted file mode 100644 index 7cfdc74..0000000 --- a/example/ruby/EnumerableSpecs/YieldsMixed.md +++ /dev/null @@ -1,2072 +0,0 @@ -# Class: EnumerableSpecs::YieldsMixed -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -**@yield** [1] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/YieldsMixed2.md b/example/ruby/EnumerableSpecs/YieldsMixed2.md deleted file mode 100644 index 011a966..0000000 --- a/example/ruby/EnumerableSpecs/YieldsMixed2.md +++ /dev/null @@ -1,2077 +0,0 @@ -# Class: EnumerableSpecs::YieldsMixed2 -**Inherits:** Object - -**Includes:** Enumerable - - - - -# Class Methods -## first_yields() [](#method-c-first_yields) -## gathered_yields() [](#method-c-gathered_yields) -## gathered_yields_with_args(arg , *args ) [](#method-c-gathered_yields_with_args) -## greedy_yields() [](#method-c-greedy_yields) - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(arg:default_arg, *args) [](#method-i-each) - -**@yield** [0] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/YieldsMulti.md b/example/ruby/EnumerableSpecs/YieldsMulti.md deleted file mode 100644 index 97112c5..0000000 --- a/example/ruby/EnumerableSpecs/YieldsMulti.md +++ /dev/null @@ -1,2072 +0,0 @@ -# Class: EnumerableSpecs::YieldsMulti -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -**@yield** [1, 2] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/YieldsMultiWithFalse.md b/example/ruby/EnumerableSpecs/YieldsMultiWithFalse.md deleted file mode 100644 index 9770917..0000000 --- a/example/ruby/EnumerableSpecs/YieldsMultiWithFalse.md +++ /dev/null @@ -1,2072 +0,0 @@ -# Class: EnumerableSpecs::YieldsMultiWithFalse -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -**@yield** [false, 2] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/EnumerableSpecs/YieldsMultiWithSingleTrue.md b/example/ruby/EnumerableSpecs/YieldsMultiWithSingleTrue.md deleted file mode 100644 index 4352627..0000000 --- a/example/ruby/EnumerableSpecs/YieldsMultiWithSingleTrue.md +++ /dev/null @@ -1,2072 +0,0 @@ -# Class: EnumerableSpecs::YieldsMultiWithSingleTrue -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -**@yield** [false, 2] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Enumerator.md b/example/ruby/Enumerator.md deleted file mode 100644 index 6009fb7..0000000 --- a/example/ruby/Enumerator.md +++ /dev/null @@ -1,2521 +0,0 @@ -# Class: Enumerator -**Inherits:** Object - -**Includes:** Enumerable - - -A class which allows both internal and external iteration. - -An Enumerator can be created by the following methods. -* Object#to_enum -* Object#enum_for -* Enumerator.new - -Most methods have two forms: a block form where the contents are evaluated for -each item in the enumeration, and a non-block form which returns a new -Enumerator wrapping the iteration. - - enumerator = %w(one two three).each - puts enumerator.class # => Enumerator - - enumerator.each_with_object("foo") do |item, obj| - puts "#{obj}: #{item}" - end - - # foo: one - # foo: two - # foo: three - - enum_with_obj = enumerator.each_with_object("foo") - puts enum_with_obj.class # => Enumerator - - enum_with_obj.each do |item, obj| - puts "#{obj}: #{item}" - end - - # foo: one - # foo: two - # foo: three - -This allows you to chain Enumerators together. For example, you can map a -list's elements to strings containing the index and the element as a string -via: - - puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" } - # => ["0:foo", "1:bar", "2:baz"] - -## External Iteration - -An Enumerator can also be used as an external iterator. For example, -Enumerator#next returns the next value of the iterator or raises StopIteration -if the Enumerator is at the end. - - e = [1,2,3].each # returns an enumerator object. - puts e.next # => 1 - puts e.next # => 2 - puts e.next # => 3 - puts e.next # raises StopIteration - -`next`, `next_values`, `peek`, and `peek_values` are the only methods which -use external iteration (and Array#zip(Enumerable-not-Array) which uses `next` -internally). - -These methods do not affect other internal enumeration methods, unless the -underlying iteration method itself has side-effect, e.g. IO#each_line. - -FrozenError will be raised if these methods are called against a frozen -enumerator. Since `rewind` and `feed` also change state for external -iteration, these methods may raise FrozenError too. - -External iteration differs **significantly** from internal iteration due to -using a Fiber: -* The Fiber adds some overhead compared to internal enumeration. -* The stacktrace will only include the stack from the Enumerator, not above. -* Fiber-local variables are **not** inherited inside the Enumerator Fiber, - which instead starts with no Fiber-local variables. -* Fiber storage variables **are** inherited and are designed to handle - Enumerator Fibers. Assigning to a Fiber storage variable only affects the - current Fiber, so if you want to change state in the caller Fiber of the - Enumerator Fiber, you need to use an extra indirection (e.g., use some - object in the Fiber storage variable and mutate some ivar of it). - -Concretely: - - Thread.current[:fiber_local] = 1 - Fiber[:storage_var] = 1 - e = Enumerator.new do |y| - p Thread.current[:fiber_local] # for external iteration: nil, for internal iteration: 1 - p Fiber[:storage_var] # => 1, inherited - Fiber[:storage_var] += 1 - y << 42 - end - - p e.next # => 42 - p Fiber[:storage_var] # => 1 (it ran in a different Fiber) - - e.each { p _1 } - p Fiber[:storage_var] # => 2 (it ran in the same Fiber/"stack" as the current Fiber) - -## Convert External Iteration to Internal Iteration - -You can use an external iterator to implement an internal iterator as follows: - - def ext_each(e) - while true - begin - vs = e.next_values - rescue StopIteration - return $!.result - end - y = yield(*vs) - e.feed y - end - end - - o = Object.new - - def o.each - puts yield - puts yield(1) - puts yield(1, 2) - 3 - end - - # use o.each as an internal iterator directly. - puts o.each {|*x| puts x; [:b, *x] } - # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3 - - # convert o.each to an external iterator for - # implementing an internal iterator. - puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] } - # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3 - - -# Class Methods -## produce(*args ) [](#method-c-produce) -Creates an infinite enumerator from any block, just called over and over. The -result of the previous iteration is passed to the next one. If `initial` is -provided, it is passed to the first iteration, and becomes the first element -of the enumerator; if it is not provided, the first iteration receives `nil`, -and its result becomes the first element of the iterator. - -Raising StopIteration from the block stops an iteration. - - Enumerator.produce(1, &:succ) # => enumerator of 1, 2, 3, 4, .... - - Enumerator.produce { rand(10) } # => infinite random number sequence - - ancestors = Enumerator.produce(node) { |prev| node = prev.parent or raise StopIteration } - enclosing_section = ancestors.find { |n| n.type == :section } - -Using ::produce together with Enumerable methods like Enumerable#detect, -Enumerable#slice_after, Enumerable#take_while can provide Enumerator-based -alternatives for `while` and `until` cycles: - - # Find next Tuesday - require "date" - Enumerator.produce(Date.today, &:succ).detect(&:tuesday?) - - # Simple lexer: - require "strscan" - scanner = StringScanner.new("7+38/6") - PATTERN = %r{\d+|[-/+*]} - Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first - # => ["7", "+", "38", "/", "6"] -**@overload** [] - -## product(*args ) [](#method-c-product) -Generates a new enumerator object that generates a Cartesian product of given -enumerable objects. This is equivalent to Enumerator::Product.new. - - e = Enumerator.product(1..3, [4, 5]) - e.to_a #=> [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]] - e.size #=> 6 - -When a block is given, calls the block with each N-element array generated and -returns `nil`. -**@overload** [] - -**@overload** [] - - -#Instance Methods -## +(eobj) [](#method-i-+) -Returns an enumerator object generated from this enumerator and a given -enumerable. - - e = (1..3).each + [4, 5] - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(*args) [](#method-i-each) -Iterates over the block according to how this Enumerator was constructed. If -no block and no arguments are given, returns self. - -### Examples - - "Hello, world!".scan(/\w+/) #=> ["Hello", "world"] - "Hello, world!".to_enum(:scan, /\w+/).to_a #=> ["Hello", "world"] - "Hello, world!".to_enum(:scan).each(/\w+/).to_a #=> ["Hello", "world"] - - obj = Object.new - - def obj.each_arg(a, b=:b, *rest) - yield a - yield b - yield rest - :method_returned - end - - enum = obj.to_enum :each_arg, :a, :x - - enum.each.to_a #=> [:a, :x, []] - enum.each.equal?(enum) #=> true - enum.each { |elm| elm } #=> :method_returned - - enum.each(:y, :z).to_a #=> [:a, :x, [:y, :z]] - enum.each(:y, :z).equal?(enum) #=> false - enum.each(:y, :z) { |elm| elm } #=> :method_returned - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index() [](#method-i-each_with_index) -Same as Enumerator#with_index(0), i.e. there is no starting offset. - -If no block is given, a new Enumerator is returned that includes the index. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Iterates the given block for each element with an arbitrary object, `obj`, and -returns `obj` - -If no block is given, returns a new Enumerator. - -### Example - - to_three = Enumerator.new do |y| - 3.times do |x| - y << x - end - end - - to_three_with_string = to_three.with_object("foo") - to_three_with_string.each do |x,string| - puts "#{string}: #{x}" - end - - # => foo: 0 - # => foo: 1 - # => foo: 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## feed(v) [](#method-i-feed) -Sets the value to be returned by the next yield inside `e`. - -If the value is not set, the yield returns nil. - -This value is cleared after being yielded. - - # Array#map passes the array's elements to "yield" and collects the - # results of "yield" as an array. - # Following example shows that "next" returns the passed elements and - # values passed to "feed" are collected as an array which can be - # obtained by StopIteration#result. - e = [1,2,3].map - p e.next #=> 1 - e.feed "a" - p e.next #=> 2 - e.feed "b" - p e.next #=> 3 - e.feed "c" - begin - e.next - rescue StopIteration - p $!.result #=> ["a", "b", "c"] - end - - o = Object.new - def o.each - x = yield # (2) blocks - p x # (5) => "foo" - x = yield # (6) blocks - p x # (8) => nil - x = yield # (9) blocks - p x # not reached w/o another e.next - end - - e = o.to_enum - e.next # (1) - e.feed "foo" # (3) - e.next # (4) - e.next # (7) - # (10) - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new Enumerator object, which can be used as an Enumerable. - -Iteration is defined by the given block, in which a "yielder" object, given as -block parameter, can be used to yield a value by calling the `yield` method -(aliased as `<<`): - - fib = Enumerator.new do |y| - a = b = 1 - loop do - y << a - a, b = b, a + b - end - end - - fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] - -The optional parameter can be used to specify how to calculate the size in a -lazy fashion (see Enumerator#size). It can either be a value or a callable -object. - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## next() [](#method-i-next) -Returns the next object in the enumerator, and move the internal position -forward. When the position reached at the end, StopIteration is raised. - -### Example - - a = [1,2,3] - e = a.to_enum - p e.next #=> 1 - p e.next #=> 2 - p e.next #=> 3 - p e.next #raises StopIteration - -See class-level notes about external iterators. - -**@overload** [] - -## next_values() [](#method-i-next_values) -Returns the next object as an array in the enumerator, and move the internal -position forward. When the position reached at the end, StopIteration is -raised. - -See class-level notes about external iterators. - -This method can be used to distinguish `yield` and `yield nil`. - -### Example - - o = Object.new - def o.each - yield - yield 1 - yield 1, 2 - yield nil - yield [1, 2] - end - e = o.to_enum - p e.next_values - p e.next_values - p e.next_values - p e.next_values - p e.next_values - e = o.to_enum - p e.next - p e.next - p e.next - p e.next - p e.next - - ## yield args next_values next - # yield [] nil - # yield 1 [1] 1 - # yield 1, 2 [1, 2] [1, 2] - # yield nil [nil] nil - # yield [1, 2] [[1, 2]] [1, 2] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## peek() [](#method-i-peek) -Returns the next object in the enumerator, but doesn't move the internal -position forward. If the position is already at the end, StopIteration is -raised. - -See class-level notes about external iterators. - -### Example - - a = [1,2,3] - e = a.to_enum - p e.next #=> 1 - p e.peek #=> 2 - p e.peek #=> 2 - p e.peek #=> 2 - p e.next #=> 2 - p e.next #=> 3 - p e.peek #raises StopIteration - -**@overload** [] - -## peek_values() [](#method-i-peek_values) -Returns the next object as an array, similar to Enumerator#next_values, but -doesn't move the internal position forward. If the position is already at the -end, StopIteration is raised. - -See class-level notes about external iterators. - -### Example - - o = Object.new - def o.each - yield - yield 1 - yield 1, 2 - end - e = o.to_enum - p e.peek_values #=> [] - e.next - p e.peek_values #=> [1] - p e.peek_values #=> [1] - e.next - p e.peek_values #=> [1, 2] - e.next - p e.peek_values # raises StopIteration - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## rewind() [](#method-i-rewind) -Rewinds the enumeration sequence to the beginning. - -If the enclosed object responds to a "rewind" method, it is called. - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) -Returns the size of the enumerator, or `nil` if it can't be calculated lazily. - - (1..100).to_a.permutation(4).size # => 94109400 - loop.size # => Float::INFINITY - (1..100).drop_while.size # => nil - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## with_index(*args) [](#method-i-with_index) -Iterates the given block for each element with an index, which starts from -`offset`. If no block is given, returns a new Enumerator that includes the -index, starting from `offset` - -`offset` -: the starting index to use - - -**@overload** [] - -**@overload** [] - -## with_object(memo) [](#method-i-with_object) -Iterates the given block for each element with an arbitrary object, `obj`, and -returns `obj` - -If no block is given, returns a new Enumerator. - -### Example - - to_three = Enumerator.new do |y| - 3.times do |x| - y << x - end - end - - to_three_with_string = to_three.with_object("foo") - to_three_with_string.each do |x,string| - puts "#{string}: #{x}" - end - - # => foo: 0 - # => foo: 1 - # => foo: 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Enumerator/ArithmeticSequence.md b/example/ruby/Enumerator/ArithmeticSequence.md deleted file mode 100644 index 9877050..0000000 --- a/example/ruby/Enumerator/ArithmeticSequence.md +++ /dev/null @@ -1,87 +0,0 @@ -# Class: Enumerator::ArithmeticSequence -**Inherits:** Enumerator - - -Enumerator::ArithmeticSequence is a subclass of Enumerator, that is a -representation of sequences of numbers with common difference. Instances of -this class can be generated by the Range#step and Numeric#step methods. - -The class can be used for slicing Array (see Array#slice) or custom -collections. - - -# Class Methods -## __beg_len_step__(obj , len , err ) [](#method-c-__beg_len_step__) -## __extract__(obj ) [](#method-c-__extract__) - -#Instance Methods -## ==(other) [](#method-i-==) -Returns `true` only if `obj` is an Enumerator::ArithmeticSequence, has -equivalent begin, end, step, and exclude_end? settings. - -**@overload** [] - -## ===(other) [](#method-i-===) -Returns `true` only if `obj` is an Enumerator::ArithmeticSequence, has -equivalent begin, end, step, and exclude_end? settings. - -**@overload** [] - -## begin() [](#method-i-begin) - -## each() [](#method-i-each) - -**@overload** [] - -**@overload** [] - -## end() [](#method-i-end) - -## eql?(other) [](#method-i-eql?) -Returns `true` only if `obj` is an Enumerator::ArithmeticSequence, has -equivalent begin, end, step, and exclude_end? settings. - -**@overload** [] - -## exclude_end?() [](#method-i-exclude_end?) - -**@return** [Boolean] - -## first(*args) [](#method-i-first) -Returns the first number in this arithmetic sequence, or an array of the first -`n` elements. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -Compute a hash-value for this arithmetic sequence. Two arithmetic sequences -with same begin, end, step, and exclude_end? values will generate the same -hash-value. - -See also Object#hash. - -**@overload** [] - -## inspect() [](#method-i-inspect) -Convert this arithmetic sequence to a printable form. - -**@overload** [] - -## last(*args) [](#method-i-last) -Returns the last number in this arithmetic sequence, or an array of the last -`n` elements. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) -Returns the number of elements in this arithmetic sequence if it is a finite -sequence. Otherwise, returns `nil`. - -**@overload** [] - -## step() [](#method-i-step) - diff --git a/example/ruby/Enumerator/Chain.md b/example/ruby/Enumerator/Chain.md deleted file mode 100644 index 9f9fa9d..0000000 --- a/example/ruby/Enumerator/Chain.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: Enumerator::Chain -**Inherits:** Enumerator - - -Enumerator::Chain is a subclass of Enumerator, which represents a chain of -enumerables that works as a single enumerator. - -This type of objects can be created by Enumerable#chain and Enumerator#+. - - - -#Instance Methods -## each(*args) [](#method-i-each) -Iterates over the elements of the first enumerable by calling the "each" -method on it with the given arguments, then proceeds to the following -enumerables in sequence until all of the enumerables are exhausted. - -If no block is given, returns an enumerator. - -**@overload** [] - -**@overload** [] - -## initialize(enums) [](#method-i-initialize) -Generates a new enumerator object that iterates over the elements of given -enumerable objects in sequence. - - e = Enumerator::Chain.new(1..3, [4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - e.size #=> 5 - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a printable version of the enumerator chain. - -**@overload** [] - -## rewind() [](#method-i-rewind) -Rewinds the enumerator chain by calling the "rewind" method on each enumerable -in reverse order. Each call is performed only if the enumerable responds to -the method. - -**@overload** [] - -## size() [](#method-i-size) -Returns the total size of the enumerator chain calculated by summing up the -size of each enumerable in the chain. If any of the enumerables reports its -size as nil or Float::INFINITY, that value is returned as the total size. - -**@overload** [] - diff --git a/example/ruby/Enumerator/Generator.md b/example/ruby/Enumerator/Generator.md deleted file mode 100644 index 7c70c36..0000000 --- a/example/ruby/Enumerator/Generator.md +++ /dev/null @@ -1,2077 +0,0 @@ -# Class: Enumerator::Generator -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(*args) [](#method-i-each) -:nodoc: - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -:nodoc: - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Enumerator/Lazy.md b/example/ruby/Enumerator/Lazy.md deleted file mode 100644 index bf73ecd..0000000 --- a/example/ruby/Enumerator/Lazy.md +++ /dev/null @@ -1,366 +0,0 @@ -# Class: Enumerator::Lazy -**Inherits:** Enumerator - - -Enumerator::Lazy is a special type of Enumerator, that allows constructing -chains of operations without evaluating them immediately, and evaluating -values on as-needed basis. In order to do so it redefines most of Enumerable -methods so that they just construct another lazy enumerator. - -Enumerator::Lazy can be constructed from any Enumerable with the -Enumerable#lazy method. - - lazy = (1..Float::INFINITY).lazy.select(&:odd?).drop(10).take_while { |i| i < 30 } - # => #:select>:drop(10)>:take_while> - -The real enumeration is performed when any non-redefined Enumerable method is -called, like Enumerable#first or Enumerable#to_a (the latter is aliased as -#force for more semantic code): - - lazy.first(2) - #=> [21, 23] - - lazy.force - #=> [21, 23, 25, 27, 29] - -Note that most Enumerable methods that could be called with or without a -block, on Enumerator::Lazy will always require a block: - - [1, 2, 3].map #=> # - [1, 2, 3].lazy.map # ArgumentError: tried to call lazy map without a block - -This class allows idiomatic calculations on long or infinite sequences, as -well as chaining of calculations without constructing intermediate arrays. - -Example for working with a slowly calculated sequence: - - require 'open-uri' - - # This will fetch all URLs before selecting - # necessary data - URLS.map { |u| JSON.parse(URI.open(u).read) } - .select { |data| data.key?('stats') } - .first(5) - - # This will fetch URLs one-by-one, only till - # there is enough data to satisfy the condition - URLS.lazy.map { |u| JSON.parse(URI.open(u).read) } - .select { |data| data.key?('stats') } - .first(5) - -Ending a chain with ".eager" generates a non-lazy enumerator, which is -suitable for returning or passing to another method that expects a normal -enumerator. - - def active_items - groups - .lazy - .flat_map(&:items) - .reject(&:disabled) - .eager - end - - # This works lazily; if a checked item is found, it stops - # iteration and does not look into remaining groups. - first_checked = active_items.find(&:checked) - - # This returns an array of items like a normal enumerator does. - all_checked = active_items.select(&:checked) - - - -#Instance Methods -## chunk() [](#method-i-chunk) -Like Enumerable#chunk, but chains operation to be lazy-evaluated. - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Like Enumerable#chunk_while, but chains operation to be lazy-evaluated. - -**@overload** [] - -## collect() [](#method-i-collect) -Like Enumerable#map, but chains operation to be lazy-evaluated. - - (1..Float::INFINITY).lazy.map {|i| i**2 } - #=> #:map> - (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) - #=> [1, 4, 9] - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns a new lazy enumerator with the concatenated results of running `block` -once for every element in the lazy enumerator. - - ["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force - #=> ["f", "o", "o", "b", "a", "r"] - -A value `x` returned by `block` is decomposed if either of the following -conditions is true: - -* `x` responds to both each and force, which means that `x` is a lazy - enumerator. -* `x` is an array or responds to to_ary. - -Otherwise, `x` is contained as-is in the return value. - - [{a:1}, {b:2}].lazy.flat_map {|i| i}.force - #=> [{:a=>1}, {:b=>2}] - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Like Enumerable#compact, but chains operation to be lazy-evaluated. - -**@overload** [] - -## drop(n) [](#method-i-drop) -Like Enumerable#drop, but chains operation to be lazy-evaluated. - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Like Enumerable#drop_while, but chains operation to be lazy-evaluated. - -**@overload** [] - -## eager() [](#method-i-eager) -Returns a non-lazy Enumerator converted from the lazy enumerator. - -**@overload** [] - -## enum_for(*args) [](#method-i-enum_for) -Similar to Object#to_enum, except it returns a lazy enumerator. This makes it -easy to define Enumerable methods that will naturally remain lazy if called -from a lazy enumerator. - -For example, continuing from the example in Object#to_enum: - - # See Object#to_enum for the definition of repeat - r = 1..Float::INFINITY - r.repeat(2).first(5) # => [1, 1, 2, 2, 3] - r.repeat(2).class # => Enumerator - r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop! - # works naturally on lazy enumerator: - r.lazy.repeat(2).class # => Enumerator::Lazy - r.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## filter() [](#method-i-filter) -Like Enumerable#select, but chains operation to be lazy-evaluated. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Like Enumerable#filter_map, but chains operation to be lazy-evaluated. - - (1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5) - #=> [4, 8, 12, 16, 20] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Like Enumerable#select, but chains operation to be lazy-evaluated. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns a new lazy enumerator with the concatenated results of running `block` -once for every element in the lazy enumerator. - - ["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force - #=> ["f", "o", "o", "b", "a", "r"] - -A value `x` returned by `block` is decomposed if either of the following -conditions is true: - -* `x` responds to both each and force, which means that `x` is a lazy - enumerator. -* `x` is an array or responds to to_ary. - -Otherwise, `x` is contained as-is in the return value. - - [{a:1}, {b:2}].lazy.flat_map {|i| i}.force - #=> [{:a=>1}, {:b=>2}] - -**@overload** [] - -**@overload** [] - -## grep(pattern) [](#method-i-grep) -Like Enumerable#grep, but chains operation to be lazy-evaluated. - -**@overload** [] - -**@overload** [] - -## grep_v(pattern) [](#method-i-grep_v) -Like Enumerable#grep_v, but chains operation to be lazy-evaluated. - -**@overload** [] - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new Lazy enumerator. When the enumerator is actually enumerated -(e.g. by calling #force), `obj` will be enumerated and each value passed to -the given block. The block can yield values back using `yielder`. For example, -to create a "filter+map" enumerator: - - def filter_map(sequence) - Lazy.new(sequence) do |yielder, *values| - result = yield *values - yielder << result if result - end - end - - filter_map(1..Float::INFINITY) {|i| i*i if i.even?}.first(5) - #=> [4, 16, 36, 64, 100] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns self. - -**@overload** [] - -## map() [](#method-i-map) -Like Enumerable#map, but chains operation to be lazy-evaluated. - - (1..Float::INFINITY).lazy.map {|i| i**2 } - #=> #:map> - (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) - #=> [1, 4, 9] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Like Enumerable#reject, but chains operation to be lazy-evaluated. - -**@overload** [] - -## select() [](#method-i-select) -Like Enumerable#select, but chains operation to be lazy-evaluated. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## slice_after() [](#method-i-slice_after) -Like Enumerable#slice_after, but chains operation to be lazy-evaluated. - -**@overload** [] - -**@overload** [] - -## slice_before() [](#method-i-slice_before) -Like Enumerable#slice_before, but chains operation to be lazy-evaluated. - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Like Enumerable#slice_when, but chains operation to be lazy-evaluated. - -**@overload** [] - -## take(n) [](#method-i-take) -Like Enumerable#take, but chains operation to be lazy-evaluated. - -**@overload** [] - -## take_while() [](#method-i-take_while) -Like Enumerable#take_while, but chains operation to be lazy-evaluated. - -**@overload** [] - -## to_a() [](#method-i-to_a) -Expands `lazy` enumerator to an array. See Enumerable#to_a. - -**@overload** [] - -**@overload** [] - -## to_enum(*args) [](#method-i-to_enum) -Similar to Object#to_enum, except it returns a lazy enumerator. This makes it -easy to define Enumerable methods that will naturally remain lazy if called -from a lazy enumerator. - -For example, continuing from the example in Object#to_enum: - - # See Object#to_enum for the definition of repeat - r = 1..Float::INFINITY - r.repeat(2).first(5) # => [1, 1, 2, 2, 3] - r.repeat(2).class # => Enumerator - r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop! - # works naturally on lazy enumerator: - r.lazy.repeat(2).class # => Enumerator::Lazy - r.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## uniq() [](#method-i-uniq) -Like Enumerable#uniq, but chains operation to be lazy-evaluated. - -**@overload** [] - -**@overload** [] - -## with_index(*args) [](#method-i-with_index) -If a block is given, returns a lazy enumerator that will iterate over the -given block for each element with an index, which starts from `offset`, and -returns a lazy enumerator that yields the same values (without the index). - -If a block is not given, returns a new lazy enumerator that includes the -index, starting from `offset`. - -`offset` -: the starting index to use - - -See Enumerator#with_index. - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -Like Enumerable#zip, but chains operation to be lazy-evaluated. However, if a -block is given to zip, values are enumerated immediately. - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Enumerator/Producer.md b/example/ruby/Enumerator/Producer.md deleted file mode 100644 index 1cac948..0000000 --- a/example/ruby/Enumerator/Producer.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Enumerator::Producer -**Inherits:** Object - - - - - -#Instance Methods -## each() [](#method-i-each) -:nodoc: - diff --git a/example/ruby/Enumerator/Product.md b/example/ruby/Enumerator/Product.md deleted file mode 100644 index 2f6e15a..0000000 --- a/example/ruby/Enumerator/Product.md +++ /dev/null @@ -1,79 +0,0 @@ -# Class: Enumerator::Product -**Inherits:** Enumerator - - -Enumerator::Product generates a Cartesian product of any number of enumerable -objects. Iterating over the product of enumerable objects is roughly -equivalent to nested each_entry loops where the loop for the rightmost object -is put innermost. - - innings = Enumerator::Product.new(1..9, ['top', 'bottom']) - - innings.each do |i, h| - p [i, h] - end - # [1, "top"] - # [1, "bottom"] - # [2, "top"] - # [2, "bottom"] - # [3, "top"] - # [3, "bottom"] - # ... - # [9, "top"] - # [9, "bottom"] - -The method used against each enumerable object is `each_entry` instead of -`each` so that the product of N enumerable objects yields an array of exactly -N elements in each iteration. - -When no enumerator is given, it calls a given block once yielding an empty -argument list. - -This type of objects can be created by Enumerator.product. - - - -#Instance Methods -## each() [](#method-i-each) -Iterates over the elements of the first enumerable by calling the "each_entry" -method on it with the given arguments, then proceeds to the following -enumerables in sequence until all of the enumerables are exhausted. - -If no block is given, returns an enumerator. Otherwise, returns self. - -**@overload** [] - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Generates a new enumerator object that generates a Cartesian product of given -enumerable objects. - - e = Enumerator::Product.new(1..3, [4, 5]) - e.to_a #=> [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]] - e.size #=> 6 - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a printable version of the product enumerator. - -**@overload** [] - -## rewind() [](#method-i-rewind) -Rewinds the product enumerator by calling the "rewind" method on each -enumerable in reverse order. Each call is performed only if the enumerable -responds to the method. - -**@overload** [] - -## size() [](#method-i-size) -Returns the total size of the enumerator product calculated by multiplying the -sizes of enumerables in the product. If any of the enumerables reports its -size as nil or Float::INFINITY, that value is returned as the size. - -**@overload** [] - diff --git a/example/ruby/Enumerator/Yielder.md b/example/ruby/Enumerator/Yielder.md deleted file mode 100644 index aa17295..0000000 --- a/example/ruby/Enumerator/Yielder.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Enumerator::Yielder -**Inherits:** Object - - - - - -#Instance Methods -## <<(arg) [](#method-i-<<) -:nodoc: - -## initialize() [](#method-i-initialize) -:nodoc: - -## to_proc() [](#method-i-to_proc) -Returns a Proc object that takes arguments and yields them. - -This method is implemented so that a Yielder object can be directly passed to -another method as a block argument. - - enum = Enumerator.new { |y| - Dir.glob("*.rb") { |file| - File.open(file) { |f| f.each_line(&y) } - } - } - -## yield(args) [](#method-i-yield) -:nodoc: - diff --git a/example/ruby/EnumeratorLazySpecs.md b/example/ruby/EnumeratorLazySpecs.md deleted file mode 100644 index 31ccde7..0000000 --- a/example/ruby/EnumeratorLazySpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: EnumeratorLazySpecs - - - - - diff --git a/example/ruby/EnumeratorLazySpecs/EventsMixed.md b/example/ruby/EnumeratorLazySpecs/EventsMixed.md deleted file mode 100644 index cb0cea6..0000000 --- a/example/ruby/EnumeratorLazySpecs/EventsMixed.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: EnumeratorLazySpecs::EventsMixed -**Inherits:** Object - - - - - -#Instance Methods -## each() [](#method-i-each) - -**@raise** [SpecificError] - -**@yield** [0] - diff --git a/example/ruby/EnumeratorLazySpecs/SpecificError.md b/example/ruby/EnumeratorLazySpecs/SpecificError.md deleted file mode 100644 index b48ce27..0000000 --- a/example/ruby/EnumeratorLazySpecs/SpecificError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: EnumeratorLazySpecs::SpecificError -**Inherits:** Exception - - - - - diff --git a/example/ruby/EnumeratorLazySpecs/YieldsMixed.md b/example/ruby/EnumeratorLazySpecs/YieldsMixed.md deleted file mode 100644 index 021e25f..0000000 --- a/example/ruby/EnumeratorLazySpecs/YieldsMixed.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: EnumeratorLazySpecs::YieldsMixed -**Inherits:** Object - - - - -# Class Methods -## gathered_non_array_yields() [](#method-c-gathered_non_array_yields) -## gathered_yields() [](#method-c-gathered_yields) -## gathered_yields_with_args(arg , *args ) [](#method-c-gathered_yields_with_args) -## initial_yields() [](#method-c-initial_yields) - -#Instance Methods -## each(arg:default_arg, *args) [](#method-i-each) - -**@yield** [0] - diff --git a/example/ruby/EnumeratorSpecs.md b/example/ruby/EnumeratorSpecs.md deleted file mode 100644 index 8574280..0000000 --- a/example/ruby/EnumeratorSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: EnumeratorSpecs - - - - - diff --git a/example/ruby/EnumeratorSpecs/Feed.md b/example/ruby/EnumeratorSpecs/Feed.md deleted file mode 100644 index 43838ef..0000000 --- a/example/ruby/EnumeratorSpecs/Feed.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: EnumeratorSpecs::Feed -**Inherits:** Object - - - - - -#Instance Methods -## each() [](#method-i-each) - diff --git a/example/ruby/EnvUtil.md b/example/ruby/EnvUtil.md deleted file mode 100644 index c10dd7d..0000000 --- a/example/ruby/EnvUtil.md +++ /dev/null @@ -1,45 +0,0 @@ -# Module: EnvUtil - - - - -# Class Methods -## apply_timeout_scale(t ) [](#method-c-apply_timeout_scale) -## capture_global_values() [](#method-c-capture_global_values) -## default_warning() [](#method-c-default_warning) -## diagnostic_reports(signame , pid , now ) [](#method-c-diagnostic_reports) -## failure_description(status , now , message "", out "") [](#method-c-failure_description) -## find_executable(cmd , *args ) [](#method-c-find_executable) -## gc_stress_to_class?() [](#method-c-gc_stress_to_class?) -**@return** [Boolean] - -## invoke_ruby(args , stdin_data "", capture_stdout false, capture_stderr false, encoding: nil, timeout: 10, reprieve: 1, timeout_error: Timeout::Error, stdout_filter: nil, stderr_filter: nil, ios: nil, signal: :TERM, rubybin: EnvUtil.rubybin, precommand: nil, **opt ) [](#method-c-invoke_ruby) -## labeled_class(name , superclass Object, &block ) [](#method-c-labeled_class) -## labeled_module(name , &block ) [](#method-c-labeled_module) -## rubybin() [](#method-c-rubybin) -## suppress_warning() [](#method-c-suppress_warning) -## terminate(pid , signal :TERM, pgroup nil, reprieve 1) [](#method-c-terminate) -## timeout(sec , klass nil, message nil, &blk ) [](#method-c-timeout) -## under_gc_compact_stress(val :empty, &block ) [](#method-c-under_gc_compact_stress) -## under_gc_stress(stress true) [](#method-c-under_gc_stress) -## verbose_warning() [](#method-c-verbose_warning) -## with_default_external(enc ) [](#method-c-with_default_external) -## with_default_internal(enc ) [](#method-c-with_default_internal) -## without_gc() [](#method-c-without_gc) -# Attributes -## original_external_encoding[RW] [](#attribute-c-original_external_encoding) -Returns the value of attribute original_external_encoding. - -## original_internal_encoding[RW] [](#attribute-c-original_internal_encoding) -Returns the value of attribute original_internal_encoding. - -## original_verbose[RW] [](#attribute-c-original_verbose) -Returns the value of attribute original_verbose. - -## original_warning[RW] [](#attribute-c-original_warning) -Returns the value of attribute original_warning. - -## timeout_scale[RW] [](#attribute-c-timeout_scale) -Returns the value of attribute timeout_scale. - - diff --git a/example/ruby/EqlMatcher.md b/example/ruby/EqlMatcher.md deleted file mode 100644 index b66472c..0000000 --- a/example/ruby/EqlMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: EqlMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected) [](#method-i-initialize) - -**@return** [EqlMatcher] a new instance of EqlMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/EqualElementMatcher.md b/example/ruby/EqualElementMatcher.md deleted file mode 100644 index 24fc588..0000000 --- a/example/ruby/EqualElementMatcher.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: EqualElementMatcher -**Inherits:** Object - - - - - -#Instance Methods -## attributes_for_failure_message() [](#method-i-attributes_for_failure_message) - -## content_for_failure_message() [](#method-i-content_for_failure_message) - -## failure_message() [](#method-i-failure_message) - -## initialize(element, attributesnil, contentnil, options{}) [](#method-i-initialize) - -**@return** [EqualElementMatcher] a new instance of EqualElementMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/EqualMatcher.md b/example/ruby/EqualMatcher.md deleted file mode 100644 index 8085296..0000000 --- a/example/ruby/EqualMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: EqualMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected) [](#method-i-initialize) - -**@return** [EqualMatcher] a new instance of EqualMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/Errno.md b/example/ruby/Errno.md deleted file mode 100644 index be7803a..0000000 --- a/example/ruby/Errno.md +++ /dev/null @@ -1,44 +0,0 @@ -# Module: Errno - - -When an operating system encounters an error, it typically reports the error -as an integer error code: - - $ ls nosuch.txt - ls: cannot access 'nosuch.txt': No such file or directory - $ echo $? # Code for last error. - 2 - -When the Ruby interpreter interacts with the operating system and receives -such an error code (e.g., `2`), it maps the code to a particular Ruby -exception class (e.g., `Errno::ENOENT`): - - File.open('nosuch.txt') - # => No such file or directory @ rb_sysopen - nosuch.txt (Errno::ENOENT) - -Each such class is: - -* A nested class in this module, `Errno`. -* A subclass of class SystemCallError. -* Associated with an error code. - -Thus: - - Errno::ENOENT.superclass # => SystemCallError - Errno::ENOENT::Errno # => 2 - -The names of nested classes are returned by method `Errno.constants`: - - Errno.constants.size # => 158 - Errno.constants.sort.take(5) # => [:E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, :EADV] - -As seen above, the error code associated with each class is available as the -value of a constant; the value for a particular class may vary among operating -systems. If the class is not needed for the particular operating system, the -value is zero: - - Errno::ENOENT::Errno # => 2 - Errno::ENOTCAPABLE::Errno # => 0 - - - diff --git a/example/ruby/ErrorHighlight.md b/example/ruby/ErrorHighlight.md deleted file mode 100644 index 8c13932..0000000 --- a/example/ruby/ErrorHighlight.md +++ /dev/null @@ -1,39 +0,0 @@ -# Module: ErrorHighlight - - - - -# Class Methods -## formatter() [](#method-c-formatter) -## formatter=(formatter ) [](#method-c-formatter=) -## spot(obj , **opts ) [](#method-c-spot) -Identify the code fragment at that a given exception occurred. - -Options: - -point_type: :name | :args - :name (default) points the method/variable name that the exception occurred. - :args points the arguments of the method call that the exception occurred. - -backtrace_location: Thread::Backtrace::Location - It locates the code fragment of the given backtrace_location. - By default, it uses the first frame of backtrace_locations of the given exception. - -Returns: - { - first_lineno: Integer, - first_column: Integer, - last_lineno: Integer, - last_column: Integer, - snippet: String, - script_lines: [String], - } | nil - -Limitations: - -Currently, ErrorHighlight.spot only supports a single-line code fragment. -Therefore, if the return value is not nil, first_lineno and last_lineno will -have the same value. If the relevant code fragment spans multiple lines (e.g., -Array#[] of +[ary]((newline)expr(newline))+), the method will return nil. This -restriction may be removed in the future. - diff --git a/example/ruby/ErrorHighlight/CoreExt.md b/example/ruby/ErrorHighlight/CoreExt.md deleted file mode 100644 index 848f31f..0000000 --- a/example/ruby/ErrorHighlight/CoreExt.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: ErrorHighlight::CoreExt - - - - - -#Instance Methods -## detailed_message(highlight:false, error_highlight:true) [](#method-i-detailed_message) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/ErrorHighlight/DefaultFormatter.md b/example/ruby/ErrorHighlight/DefaultFormatter.md deleted file mode 100644 index 2744dcb..0000000 --- a/example/ruby/ErrorHighlight/DefaultFormatter.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ErrorHighlight::DefaultFormatter -**Inherits:** Object - - - - -# Class Methods -## max_snippet_width() [](#method-c-max_snippet_width) -## max_snippet_width=(width ) [](#method-c-max_snippet_width=) -## message_for(spot ) [](#method-c-message_for) -## terminal_width() [](#method-c-terminal_width) - diff --git a/example/ruby/ErrorHighlightTest.md b/example/ruby/ErrorHighlightTest.md deleted file mode 100644 index 19b2a20..0000000 --- a/example/ruby/ErrorHighlightTest.md +++ /dev/null @@ -1,226 +0,0 @@ -# Class: ErrorHighlightTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_error_message(klass, expected_msg, &blk) [](#method-i-assert_error_message) - -## raise_name_error() [](#method-i-raise_name_error) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_ATTRASGN_1() [](#method-i-test_ATTRASGN_1) - -## test_ATTRASGN_2() [](#method-i-test_ATTRASGN_2) - -## test_ATTRASGN_3() [](#method-i-test_ATTRASGN_3) - -## test_ATTRASGN_4() [](#method-i-test_ATTRASGN_4) - -## test_ATTRASGN_5() [](#method-i-test_ATTRASGN_5) - -## test_CALL_aref_1() [](#method-i-test_CALL_aref_1) - -## test_CALL_aref_2() [](#method-i-test_CALL_aref_2) - -## test_CALL_aref_3() [](#method-i-test_CALL_aref_3) - -## test_CALL_aref_4() [](#method-i-test_CALL_aref_4) - -## test_CALL_aref_5() [](#method-i-test_CALL_aref_5) - -## test_CALL_arg_1() [](#method-i-test_CALL_arg_1) - -## test_CALL_arg_2() [](#method-i-test_CALL_arg_2) - -## test_CALL_arg_3() [](#method-i-test_CALL_arg_3) - -## test_CALL_arg_4() [](#method-i-test_CALL_arg_4) - -## test_CALL_arg_5() [](#method-i-test_CALL_arg_5) - -## test_CALL_arg_6() [](#method-i-test_CALL_arg_6) - -## test_CALL_arg_7() [](#method-i-test_CALL_arg_7) - -## test_CALL_aset() [](#method-i-test_CALL_aset) - -## test_CALL_noarg_1() [](#method-i-test_CALL_noarg_1) - -## test_CALL_noarg_2() [](#method-i-test_CALL_noarg_2) - -## test_CALL_noarg_3() [](#method-i-test_CALL_noarg_3) - -## test_CALL_noarg_4() [](#method-i-test_CALL_noarg_4) - -## test_CALL_op_asgn() [](#method-i-test_CALL_op_asgn) - -## test_CALL_send() [](#method-i-test_CALL_send) - -## test_CALL_special_call_1() [](#method-i-test_CALL_special_call_1) - -## test_CALL_special_call_2() [](#method-i-test_CALL_special_call_2) - -## test_COLON2_1() [](#method-i-test_COLON2_1) - -## test_COLON2_2() [](#method-i-test_COLON2_2) - -## test_COLON2_3() [](#method-i-test_COLON2_3) - -## test_COLON2_4() [](#method-i-test_COLON2_4) - -## test_COLON2_5() [](#method-i-test_COLON2_5) - -## test_COLON3() [](#method-i-test_COLON3) - -## test_CONST() [](#method-i-test_CONST) - -## test_FCALL_1() [](#method-i-test_FCALL_1) - -## test_FCALL_2() [](#method-i-test_FCALL_2) - -## test_OPCALL_binary_1() [](#method-i-test_OPCALL_binary_1) - -## test_OPCALL_binary_2() [](#method-i-test_OPCALL_binary_2) - -## test_OPCALL_binary_3() [](#method-i-test_OPCALL_binary_3) - -## test_OPCALL_unary_1() [](#method-i-test_OPCALL_unary_1) - -## test_OPCALL_unary_2() [](#method-i-test_OPCALL_unary_2) - -## test_OP_ASGN1_aref_1() [](#method-i-test_OP_ASGN1_aref_1) - -## test_OP_ASGN1_aref_2() [](#method-i-test_OP_ASGN1_aref_2) - -## test_OP_ASGN1_aref_3() [](#method-i-test_OP_ASGN1_aref_3) - -## test_OP_ASGN1_aref_4() [](#method-i-test_OP_ASGN1_aref_4) - -## test_OP_ASGN1_aset_1() [](#method-i-test_OP_ASGN1_aset_1) - -## test_OP_ASGN1_aset_2() [](#method-i-test_OP_ASGN1_aset_2) - -## test_OP_ASGN1_aset_3() [](#method-i-test_OP_ASGN1_aset_3) - -## test_OP_ASGN1_aset_4() [](#method-i-test_OP_ASGN1_aset_4) - -## test_OP_ASGN1_op_1() [](#method-i-test_OP_ASGN1_op_1) - -## test_OP_ASGN1_op_2() [](#method-i-test_OP_ASGN1_op_2) - -## test_OP_ASGN1_op_3() [](#method-i-test_OP_ASGN1_op_3) - -## test_OP_ASGN1_op_4() [](#method-i-test_OP_ASGN1_op_4) - -## test_OP_ASGN2_op_1() [](#method-i-test_OP_ASGN2_op_1) - -## test_OP_ASGN2_op_2() [](#method-i-test_OP_ASGN2_op_2) - -## test_OP_ASGN2_op_3() [](#method-i-test_OP_ASGN2_op_3) - -## test_OP_ASGN2_read_1() [](#method-i-test_OP_ASGN2_read_1) - -## test_OP_ASGN2_read_2() [](#method-i-test_OP_ASGN2_read_2) - -## test_OP_ASGN2_read_3() [](#method-i-test_OP_ASGN2_read_3) - -## test_OP_ASGN2_write_1() [](#method-i-test_OP_ASGN2_write_1) - -## test_OP_ASGN2_write_2() [](#method-i-test_OP_ASGN2_write_2) - -## test_OP_ASGN2_write_3() [](#method-i-test_OP_ASGN2_write_3) - -## test_OP_CDECL_op_1() [](#method-i-test_OP_CDECL_op_1) - -## test_OP_CDECL_op_2() [](#method-i-test_OP_CDECL_op_2) - -## test_OP_CDECL_op_3() [](#method-i-test_OP_CDECL_op_3) - -## test_OP_CDECL_read_1() [](#method-i-test_OP_CDECL_read_1) - -## test_OP_CDECL_read_2() [](#method-i-test_OP_CDECL_read_2) - -## test_OP_CDECL_read_3() [](#method-i-test_OP_CDECL_read_3) - -## test_OP_CDECL_toplevel_1() [](#method-i-test_OP_CDECL_toplevel_1) - -## test_OP_CDECL_toplevel_2() [](#method-i-test_OP_CDECL_toplevel_2) - -## test_QCALL_1() [](#method-i-test_QCALL_1) - -## test_QCALL_2() [](#method-i-test_QCALL_2) - -## test_VCALL_2() [](#method-i-test_VCALL_2) - -## test_args_ATTRASGN_1() [](#method-i-test_args_ATTRASGN_1) - -## test_args_ATTRASGN_2() [](#method-i-test_args_ATTRASGN_2) - -## test_args_ATTRASGN_3() [](#method-i-test_args_ATTRASGN_3) - -## test_args_CALL_1() [](#method-i-test_args_CALL_1) - -## test_args_CALL_2() [](#method-i-test_args_CALL_2) - -## test_args_FCALL_1() [](#method-i-test_args_FCALL_1) - -## test_args_FCALL_2() [](#method-i-test_args_FCALL_2) - -## test_args_OPCALL() [](#method-i-test_args_OPCALL) - -## test_args_OP_ASGN1_aref_1() [](#method-i-test_args_OP_ASGN1_aref_1) - -## test_args_OP_ASGN1_aref_2() [](#method-i-test_args_OP_ASGN1_aref_2) - -## test_args_OP_ASGN1_op() [](#method-i-test_args_OP_ASGN1_op) - -## test_args_OP_ASGN2() [](#method-i-test_args_OP_ASGN2) - -## test_const_get() [](#method-i-test_const_get) - -## test_custom_formatter() [](#method-i-test_custom_formatter) - -## test_errors_on_extremely_small_terminal_window() [](#method-i-test_errors_on_extremely_small_terminal_window) - -## test_errors_on_small_terminal_window_at_the_beginning() [](#method-i-test_errors_on_small_terminal_window_at_the_beginning) - -## test_errors_on_small_terminal_window_at_the_end() [](#method-i-test_errors_on_small_terminal_window_at_the_end) - -## test_errors_on_small_terminal_window_at_the_middle() [](#method-i-test_errors_on_small_terminal_window_at_the_middle) - -## test_errors_on_small_terminal_window_at_the_middle_near_beginning() [](#method-i-test_errors_on_small_terminal_window_at_the_middle_near_beginning) - -## test_errors_on_small_terminal_window_when_exact_size_of_viewport() [](#method-i-test_errors_on_small_terminal_window_when_exact_size_of_viewport) - -## test_errors_on_small_terminal_window_when_larger_than_viewport() [](#method-i-test_errors_on_small_terminal_window_when_larger_than_viewport) - -## test_errors_on_terminal_window_smaller_than_min_width() [](#method-i-test_errors_on_terminal_window_smaller_than_min_width) - -## test_errors_on_terminal_window_when_truncation_is_disabled() [](#method-i-test_errors_on_terminal_window_when_truncation_is_disabled) - -## test_explicit_raise_name_error() [](#method-i-test_explicit_raise_name_error) - -## test_explicit_raise_no_method_error() [](#method-i-test_explicit_raise_no_method_error) - -## test_hard_tabs() [](#method-i-test_hard_tabs) - -## test_local_variable_get() [](#method-i-test_local_variable_get) - -## test_multibyte() [](#method-i-test_multibyte) - -## test_no_final_newline() [](#method-i-test_no_final_newline) - -## test_simulate_funcallv_from_embedded_ruby() [](#method-i-test_simulate_funcallv_from_embedded_ruby) - -## test_spoofed_filename() [](#method-i-test_spoofed_filename) - -## test_spot_with_backtrace_location() [](#method-i-test_spot_with_backtrace_location) - -## test_spot_with_node() [](#method-i-test_spot_with_node) - diff --git a/example/ruby/ErrorHighlightTest/DummyFormatter.md b/example/ruby/ErrorHighlightTest/DummyFormatter.md deleted file mode 100644 index 2859b83..0000000 --- a/example/ruby/ErrorHighlightTest/DummyFormatter.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ErrorHighlightTest::DummyFormatter -**Inherits:** Object - - - - -# Class Methods -## message_for(corrections ) [](#method-c-message_for) - diff --git a/example/ruby/ErrorHighlightTest/OP_CDECL_TEST.md b/example/ruby/ErrorHighlightTest/OP_CDECL_TEST.md deleted file mode 100644 index f2e9dab..0000000 --- a/example/ruby/ErrorHighlightTest/OP_CDECL_TEST.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ErrorHighlightTest::OP_CDECL_TEST - - - - - diff --git a/example/ruby/Etc.md b/example/ruby/Etc.md deleted file mode 100644 index d1164d9..0000000 --- a/example/ruby/Etc.md +++ /dev/null @@ -1,242 +0,0 @@ -# Module: Etc - - - - -# Class Methods -## confstr(arg ) [](#method-c-confstr) -confstr(name) -> String - -Returns system configuration variable using confstr(). - -*name* should be a constant under `Etc` which begins with `CS_`. - -The return value is a string or nil. nil means no configuration-defined value. - (confstr() returns 0 but errno is not set.) - - Etc.confstr(Etc::CS_PATH) #=> "/bin:/usr/bin" - - # GNU/Linux - Etc.confstr(Etc::CS_GNU_LIBC_VERSION) #=> "glibc 2.18" - Etc.confstr(Etc::CS_GNU_LIBPTHREAD_VERSION) #=> "NPTL 2.18" -## endgrent() [](#method-c-endgrent) -endgrent - -Ends the process of scanning through the `/etc/group` file begun by -::getgrent, and closes the file. -## endpwent() [](#method-c-endpwent) -endpwent - -Ends the process of scanning through the `/etc/passwd` file begun with -::getpwent, and closes the file. -## getgrent() [](#method-c-getgrent) -getgrent -> Etc::Group - -Returns an entry from the `/etc/group` file. - -The first time it is called it opens the file and returns the first entry; -each successive call returns the next entry, or `nil` if the end of the file -has been reached. - -To close the file when processing is complete, call ::endgrent. - -Each entry is returned as a Group struct -## getgrgid(*args ) [](#method-c-getgrgid) -getgrgid(group_id) -> Etc::Group - -Returns information about the group with specified integer `group_id`, as -found in `/etc/group`. - -The information is returned as a Group struct. - -See the unix manpage for `getgrgid(3)` for more detail. - -**Example:** - -Etc.getgrgid(100) #=> # -## getgrnam(nam ) [](#method-c-getgrnam) -getgrnam(name) -> Etc::Group - -Returns information about the group with specified `name`, as found in -`/etc/group`. - -The information is returned as a Group struct. - -See the unix manpage for `getgrnam(3)` for more detail. - -**Example:** - -Etc.getgrnam('users') #=> # -## getlogin() [](#method-c-getlogin) -getlogin -> String - -Returns the short user name of the currently logged in user. Unfortunately, it -is often rather easy to fool ::getlogin. - -Avoid ::getlogin for security-related purposes. - -If ::getlogin fails, try ::getpwuid. - -See the unix manpage for `getpwuid(3)` for more detail. - -e.g. - Etc.getlogin -> 'guest' -## getpwent() [](#method-c-getpwent) -getpwent -> Etc::Passwd - -Returns an entry from the `/etc/passwd` file. - -The first time it is called it opens the file and returns the first entry; -each successive call returns the next entry, or `nil` if the end of the file -has been reached. - -To close the file when processing is complete, call ::endpwent. - -Each entry is returned as a Passwd struct. -## getpwnam(nam ) [](#method-c-getpwnam) -getpwnam(name) -> Etc::Passwd - -Returns the `/etc/passwd` information for the user with specified login -`name`. - -The information is returned as a Passwd struct. - -See the unix manpage for `getpwnam(3)` for more detail. - -**Example:** - -Etc.getpwnam('root') #=> # -## getpwuid(*args ) [](#method-c-getpwuid) -getpwuid(uid) -> Etc::Passwd - -Returns the `/etc/passwd` information for the user with the given integer -`uid`. - -The information is returned as a Passwd struct. - -If `uid` is omitted, the value from `Passwd[:uid]` is returned instead. - -See the unix manpage for `getpwuid(3)` for more detail. - -**Example:** - -Etc.getpwuid(0) #=> # -## group() [](#method-c-group) -group { |struct| block } group -> Etc::Group - -Provides a convenient Ruby iterator which executes a block for each entry in -the `/etc/group` file. - -The code block is passed an Group struct. - -See ::getgrent above for details. - -**Example:** - - require 'etc' - - Etc.group {|g| - puts g.name + ": " + g.mem.join(', ') - } -## nprocessors() [](#method-c-nprocessors) -nprocessors -> Integer - -Returns the number of online processors. - -The result is intended as the number of processes to use all available -processors. - -This method is implemented using: -* sched_getaffinity(): Linux -* sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, - DragonFly BSD, OpenIndiana, Mac OS X, AIX - -**Example:** - - require 'etc' - p Etc.nprocessors #=> 4 - -The result might be smaller number than physical cpus especially when ruby -process is bound to specific cpus. This is intended for getting better -parallel processing. - -**Example:** (Linux) - - linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors" #=> 2 -## passwd() [](#method-c-passwd) -passwd { |struct| block } passwd -> Etc::Passwd - -Provides a convenient Ruby iterator which executes a block for each entry in -the `/etc/passwd` file. - -The code block is passed an Passwd struct. - -See ::getpwent above for details. - -**Example:** - - require 'etc' - - Etc.passwd {|u| - puts u.name + " = " + u.gecos - } -## setgrent() [](#method-c-setgrent) -setgrent - -Resets the process of reading the `/etc/group` file, so that the next call to -::getgrent will return the first entry again. -## setpwent() [](#method-c-setpwent) -setpwent - -Resets the process of reading the `/etc/passwd` file, so that the next call to -::getpwent will return the first entry again. -## sysconf(arg ) [](#method-c-sysconf) -sysconf(name) -> Integer - -Returns system configuration variable using sysconf(). - -*name* should be a constant under `Etc` which begins with `SC_`. - -The return value is an integer or nil. nil means indefinite limit. (sysconf() -returns -1 but errno is not set.) - - Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152 - Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256 -## sysconfdir() [](#method-c-sysconfdir) -sysconfdir -> String - -Returns system configuration directory. - -This is typically `"/etc"`, but is modified by the prefix used when Ruby was -compiled. For example, if Ruby is built and installed in `/usr/local`, returns -`"/usr/local/etc"` on other platforms than Windows. - -On Windows, this always returns the directory provided by the system. -## systmpdir() [](#method-c-systmpdir) -systmpdir -> String - -Returns system temporary directory; typically "/tmp". -## uname() [](#method-c-uname) -uname -> hash - -Returns the system information obtained by uname system call. - -The return value is a hash which has 5 keys at least: - :sysname, :nodename, :release, :version, :machine - -**Example:** - - require 'etc' - require 'pp' - - pp Etc.uname - #=> {:sysname=>"Linux", - # :nodename=>"boron", - # :release=>"2.6.18-6-xen-686", - # :version=>"#1 SMP Thu Nov 5 19:54:42 UTC 2009", - # :machine=>"i686"} - diff --git a/example/ruby/Etc/Group.md b/example/ruby/Etc/Group.md deleted file mode 100644 index 69a7b9c..0000000 --- a/example/ruby/Etc/Group.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Etc::Group -**Inherits:** Struct - - - - -# Class Methods -## each() [](#method-c-each) -Etc::Group.each { |group| block } -> Etc::Group Etc::Group.each --> Enumerator - -Iterates for each entry in the `/etc/group` file if a block is given. - -If no block is given, returns the Enumerator. - -The code block is passed a Group struct. - -**Example:** - - require 'etc' - - Etc::Group.each {|g| - puts g.name + ": " + g.mem.join(', ') - } - - Etc::Group.collect {|g| g.name} - Etc::Group.select {|g| !g.mem.empty?} - diff --git a/example/ruby/Etc/Passwd.md b/example/ruby/Etc/Passwd.md deleted file mode 100644 index 0c71084..0000000 --- a/example/ruby/Etc/Passwd.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Etc::Passwd -**Inherits:** Struct - - - - -# Class Methods -## each() [](#method-c-each) -Etc::Passwd.each { |struct| block } -> Etc::Passwd Etc::Passwd.each -> -Enumerator - -Iterates for each entry in the `/etc/passwd` file if a block is given. - -If no block is given, returns the Enumerator. - -The code block is passed an Passwd struct. - -See Etc.getpwent above for details. - -**Example:** - - require 'etc' - - Etc::Passwd.each {|u| - puts u.name + " = " + u.gecos - } - - Etc::Passwd.collect {|u| u.gecos} - Etc::Passwd.collect {|u| u.gecos} - diff --git a/example/ruby/EvTest.md b/example/ruby/EvTest.md deleted file mode 100644 index 4cbd918..0000000 --- a/example/ruby/EvTest.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: EvTest - - - - - diff --git a/example/ruby/EvalSpecs.md b/example/ruby/EvalSpecs.md deleted file mode 100644 index 72af135..0000000 --- a/example/ruby/EvalSpecs.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: EvalSpecs -**Inherits:** Object - - - - -# Class Methods -## call_eval() [](#method-c-call_eval) - -#Instance Methods -## f() [](#method-i-f) - diff --git a/example/ruby/EvalSpecs/A.md b/example/ruby/EvalSpecs/A.md deleted file mode 100644 index 58b17aa..0000000 --- a/example/ruby/EvalSpecs/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: EvalSpecs::A -**Inherits:** Object - - - - - -#Instance Methods -## c() [](#method-i-c) - diff --git a/example/ruby/EvalSpecs/CoercedObject.md b/example/ruby/EvalSpecs/CoercedObject.md deleted file mode 100644 index cbfd789..0000000 --- a/example/ruby/EvalSpecs/CoercedObject.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: EvalSpecs::CoercedObject -**Inherits:** Object - - - - - -#Instance Methods -## hash() [](#method-i-hash) - -## to_str() [](#method-i-to_str) - diff --git a/example/ruby/EvalTest.md b/example/ruby/EvalTest.md deleted file mode 100644 index 131e578..0000000 --- a/example/ruby/EvalTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: EvalTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_rb_eval_string() [](#method-i-test_rb_eval_string) - diff --git a/example/ruby/ExampleState.md b/example/ruby/ExampleState.md deleted file mode 100644 index 196d4fa..0000000 --- a/example/ruby/ExampleState.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: ExampleState -**Inherits:** Object - - -Holds some of the state of the example (i.e. `it` block) that is being -evaluated. See also `ContextState`. - - -# Attributes -## context[RW] [](#attribute-i-context) -Returns the value of attribute context. - -## example[RW] [](#attribute-i-example) -Returns the value of attribute example. - -## it[RW] [](#attribute-i-it) -Returns the value of attribute it. - - -#Instance Methods -## describe() [](#method-i-describe) - -## description() [](#method-i-description) - -## filtered?() [](#method-i-filtered?) - -**@return** [Boolean] - -## initialize(context, it, examplenil) [](#method-i-initialize) - -**@return** [ExampleState] a new instance of ExampleState - diff --git a/example/ruby/Exception.md b/example/ruby/Exception.md deleted file mode 100644 index 5cc0bbc..0000000 --- a/example/ruby/Exception.md +++ /dev/null @@ -1,472 +0,0 @@ -# Exception: Exception -**Inherits:** Object - - -Class `Exception` and its subclasses are used to indicate that an error or -other problem has occurred, and may need to be handled. See -[Exceptions](rdoc-ref:exceptions.md). - -An `Exception` object carries certain information: - -* The type (the exception's class), commonly StandardError, RuntimeError, or - a subclass of one or the other; see [Built-In Exception Class - Hierarchy](rdoc-ref:Exception@Built-In+Exception+Class+Hierarchy). -* An optional descriptive message; see methods ::new, #message. -* Optional backtrace information; see methods #backtrace, - #backtrace_locations, #set_backtrace. -* An optional cause; see method #cause. - -## Built-In Exception Class Hierarchy - -The hierarchy of built-in subclasses of class `Exception`: - -* NoMemoryError -* ScriptError - * LoadError - * NotImplementedError - * SyntaxError -* SecurityError -* SignalException - * Interrupt -* StandardError - * ArgumentError - * UncaughtThrowError - * EncodingError - * FiberError - * IOError - * EOFError - * IndexError - * KeyError - * StopIteration - * ClosedQueueError - * LocalJumpError - * NameError - * NoMethodError - * RangeError - * FloatDomainError - * RegexpError - * RuntimeError - * FrozenError - * SystemCallError - * Errno (and its subclasses, representing system errors) - * ThreadError - * TypeError - * ZeroDivisionError -* SystemExit -* SystemStackError -* [fatal](rdoc-ref:fatal) - - -# Class Methods -## exception(*args ) [](#method-c-exception) -call-seq: - exception(message = nil) -> self or new_exception - -Returns an exception object of the same class as `self`; useful for creating a -similar exception, but with a different message. - -With `message` `nil`, returns `self`: - - x0 = StandardError.new('Boom') # => # - x1 = x0.exception # => # - x0.__id__ == x1.__id__ # => true - -With [string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) -`message` (even the same as the original message), returns a new exception -object whose class is the same as `self`, and whose message is the given -`message`: - - x1 = x0.exception('Boom') # => # - x0..equal?(x1) # => false -## json_create(object ) [](#method-c-json_create) -See #as_json. -## to_tty?() [](#method-c-to_tty?) -Returns `true` if exception messages will be sent to a terminal device. -**@overload** [] - - -#Instance Methods -## ==(obj) [](#method-i-==) -Returns whether `object` is the same class as `self` and its #message and -#backtrace are equal to those of `self`. - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Exception#as_json` and `Exception.json_create` may be used to -serialize and deserialize a Exception object; see [Marshal](rdoc-ref:Marshal). - -Method `Exception#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/exception' - x = Exception.new('Foo').as_json # => {"json_class"=>"Exception", "m"=>"Foo", "b"=>nil} - -Method `JSON.create` deserializes such a hash, returning a Exception object: - - Exception.json_create(x) # => # - -## backtrace() [](#method-i-backtrace) -Returns the backtrace (the list of code locations that led to the exception), -as an array of strings. - -Example (assuming the code is stored in the file named `t.rb`): - - def division(numerator, denominator) - numerator / denominator - end - - begin - division(1, 0) - rescue => ex - p ex.backtrace - # ["t.rb:2:in 'Integer#/'", "t.rb:2:in 'Object#division'", "t.rb:6:in '
'"] - loc = ex.backtrace.first - p loc.class - # String - end - -The value returned by this method migth be adjusted when raising (see -Kernel#raise), or during intermediate handling by #set_backtrace. - -See also #backtrace_locations that provide the same value, as structured -objects. (Note though that two values might not be consistent with each other -when backtraces are manually adjusted.) - -see [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -**@overload** [] - -## backtrace_locations() [](#method-i-backtrace_locations) -Returns the backtrace (the list of code locations that led to the exception), -as an array of Thread::Backtrace::Location instances. - -Example (assuming the code is stored in the file named `t.rb`): - - def division(numerator, denominator) - numerator / denominator - end - - begin - division(1, 0) - rescue => ex - p ex.backtrace_locations - # ["t.rb:2:in 'Integer#/'", "t.rb:2:in 'Object#division'", "t.rb:6:in '
'"] - loc = ex.backtrace_locations.first - p loc.class - # Thread::Backtrace::Location - p loc.path - # "t.rb" - p loc.lineno - # 2 - p loc.label - # "Integer#/" - end - -The value returned by this method might be adjusted when raising (see -Kernel#raise), or during intermediate handling by #set_backtrace. - -See also #backtrace that provide the same value as an array of strings. (Note -though that two values might not be consistent with each other when backtraces -are manually adjusted.) - -See [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -**@overload** [] - -## cause() [](#method-i-cause) -Returns the previous value of global variable `$!`, which may be `nil` (see -[Global Variables](rdoc-ref:exceptions.md@Global+Variables)): - - begin - raise('Boom 0') - rescue => x0 - puts "Exception: #{x0}; $!: #{$!}; cause: #{x0.cause.inspect}." - begin - raise('Boom 1') - rescue => x1 - puts "Exception: #{x1}; $!: #{$!}; cause: #{x1.cause}." - begin - raise('Boom 2') - rescue => x2 - puts "Exception: #{x2}; $!: #{$!}; cause: #{x2.cause}." - end - end - end - -Output: - - Exception: Boom 0; $!: Boom 0; cause: nil. - Exception: Boom 1; $!: Boom 1; cause: Boom 0. - Exception: Boom 2; $!: Boom 2; cause: Boom 1. - -**@overload** [] - -## detailed_message(*args) [](#method-i-detailed_message) -Returns the message string with enhancements: - -* Includes the exception class name in the first line. -* If the value of keyword `highlight` is `true`, includes bolding and - underlining ANSI codes (see below) to enhance the appearance of the - message. - -Examples: - - begin - 1 / 0 - rescue => x - p x.message - p x.detailed_message # Class name added. - p x.detailed_message(highlight: true) # Class name, bolding, and underlining added. - end - -Output: - - "divided by 0" - "divided by 0 (ZeroDivisionError)" - "\e[1mdivided by 0 (\e[1;4mZeroDivisionError\e[m\e[1m)\e[m" - -This method is overridden by some gems in the Ruby standard library to add -information: - -* DidYouMean::Correctable#detailed_message. -* ErrorHighlight::CoreExt#detailed_message. -* SyntaxSuggest#detailed_message. - -An overriding method must be tolerant of passed keyword arguments, which may -include (but may not be limited to): - -* `:highlight`. -* `:did_you_mean`. -* `:error_highlight`. -* `:syntax_suggest`. - -An overriding method should also be careful with ANSI code enhancements; see -[Messages](rdoc-ref:exceptions.md@Messages). - -**@overload** [] - -## exception(*args) [](#method-i-exception) -call-seq: - exception(message = nil) -> self or new_exception - -Returns an exception object of the same class as `self`; useful for creating a -similar exception, but with a different message. - -With `message` `nil`, returns `self`: - - x0 = StandardError.new('Boom') # => # - x1 = x0.exception # => # - x0.__id__ == x1.__id__ # => true - -With [string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) -`message` (even the same as the original message), returns a new exception -object whose class is the same as `self`, and whose message is the given -`message`: - - x1 = x0.exception('Boom') # => # - x0..equal?(x1) # => false - -## full_message(*args) [](#method-i-full_message) -Returns an enhanced message string: - -* Includes the exception class name. -* If the value of keyword `highlight` is true (not `nil` or `false`), - includes bolding ANSI codes (see below) to enhance the appearance of the - message. -* Includes the [backtrace](rdoc-ref:exceptions.md@Backtraces): - - * If the value of keyword `order` is `:top` (the default), lists the - error message and the innermost backtrace entry first. - * If the value of keyword `order` is `:bottom`, lists the error message - the the innermost entry last. - -Example: - - def baz - begin - 1 / 0 - rescue => x - pp x.message - pp x.full_message(highlight: false).split("\n") - pp x.full_message.split("\n") - end - end - def bar; baz; end - def foo; bar; end - foo - -Output: - - "divided by 0" - ["t.rb:3:in 'Integer#/': divided by 0 (ZeroDivisionError)", - "\tfrom t.rb:3:in 'Object#baz'", - "\tfrom t.rb:10:in 'Object#bar'", - "\tfrom t.rb:11:in 'Object#foo'", - "\tfrom t.rb:12:in '
'"] - ["t.rb:3:in 'Integer#/': \e[1mdivided by 0 (\e[1;4mZeroDivisionError\e[m\e[1m)\e[m", - "\tfrom t.rb:3:in 'Object#baz'", - "\tfrom t.rb:10:in 'Object#bar'", - "\tfrom t.rb:11:in 'Object#foo'", - "\tfrom t.rb:12:in '
'"] - -An overriding method should be careful with ANSI code enhancements; see -[Messages](rdoc-ref:exceptions.md@Messages). - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Returns a new exception object. - -The given `message` should be a [string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects); see -method #message; if not given, the message is the class name of the new -instance (which may be the name of a subclass): - -Examples: - - Exception.new # => # - LoadError.new # => # # Subclass of Exception. - Exception.new('Boom') # => # - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - x = RuntimeError.new('Boom') - x.inspect # => "#" - x = RuntimeError.new - x.inspect # => "#" - -**@overload** [] - -## message() [](#method-i-message) -Returns #to_s. - -See [Messages](rdoc-ref:exceptions.md@Messages). - -**@overload** [] - -## set_backtrace(bt) [](#method-i-set_backtrace) -Sets the backtrace value for `self`; returns the given `value`. - -The `value` might be: - -* an array of Thread::Backtrace::Location; -* an array of String instances; -* a single String instance; or -* `nil`. - -Using array of Thread::Backtrace::Location is the most consistent option: it -sets both #backtrace and #backtrace_locations. It should be preferred when -possible. The suitable array of locations can be obtained from -Kernel#caller_locations, copied from another error, or just set to the -adjusted result of the current error's #backtrace_locations: - - require 'json' - - def parse_payload(text) - JSON.parse(text) # test.rb, line 4 - rescue JSON::ParserError => ex - ex.set_backtrace(ex.backtrace_locations[2...]) - raise - end - - parse_payload('{"wrong: "json"') - # test.rb:4:in 'Object#parse_payload': unexpected token at '{"wrong: "json"' (JSON::ParserError) - # - # An error points to the body of parse_payload method, - # hiding the parts of the backtrace related to the internals - # of the "json" library - - # The error has both #backtace and #backtrace_locations set - # consistently: - begin - parse_payload('{"wrong: "json"') - rescue => ex - p ex.backtrace - # ["test.rb:4:in 'Object#parse_payload'", "test.rb:20:in '
'"] - p ex.backtrace_locations - # ["test.rb:4:in 'Object#parse_payload'", "test.rb:20:in '
'"] - end - -When the desired stack of locations is not available and should be constructed -from scratch, an array of strings or a singular string can be used. In this -case, only #backtrace is affected: - - def parse_payload(text) - JSON.parse(text) - rescue JSON::ParserError => ex - ex.set_backtrace(["dsl.rb:34", "framework.rb:1"]) - # The error have the new value in #backtrace: - p ex.backtrace - # ["dsl.rb:34", "framework.rb:1"] - - # but the original one in #backtrace_locations - p ex.backtrace_locations - # [".../json/common.rb:221:in 'JSON::Ext::Parser.parse'", ...] - end - - parse_payload('{"wrong: "json"') - -Calling #set_backtrace with `nil` clears up #backtrace but doesn't affect -#backtrace_locations: - - def parse_payload(text) - JSON.parse(text) - rescue JSON::ParserError => ex - ex.set_backtrace(nil) - p ex.backtrace - # nil - p ex.backtrace_locations - # [".../json/common.rb:221:in 'JSON::Ext::Parser.parse'", ...] - end - - parse_payload('{"wrong: "json"') - -On reraising of such an exception, both #backtrace and #backtrace_locations is -set to the place of reraising: - - def parse_payload(text) - JSON.parse(text) - rescue JSON::ParserError => ex - ex.set_backtrace(nil) - raise # test.rb, line 7 - end - - begin - parse_payload('{"wrong: "json"') - rescue => ex - p ex.backtrace - # ["test.rb:7:in 'Object#parse_payload'", "test.rb:11:in '
'"] - p ex.backtrace_locations - # ["test.rb:7:in 'Object#parse_payload'", "test.rb:11:in '
'"] - end - -See [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/exception' - puts Exception.new('Foo').to_json - -Output: - - {"json_class":"Exception","m":"Foo","b":null} - -## to_s() [](#method-i-to_s) -Returns a string representation of `self`: - - x = RuntimeError.new('Boom') - x.to_s # => "Boom" - x = RuntimeError.new - x.to_s # => "RuntimeError" - -**@overload** [] - diff --git a/example/ruby/ExceptionSpecs.md b/example/ruby/ExceptionSpecs.md deleted file mode 100644 index 288e3d9..0000000 --- a/example/ruby/ExceptionSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ExceptionSpecs - - - - - diff --git a/example/ruby/ExceptionSpecs/Backtrace.md b/example/ruby/ExceptionSpecs/Backtrace.md deleted file mode 100644 index 263e8d6..0000000 --- a/example/ruby/ExceptionSpecs/Backtrace.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ExceptionSpecs::Backtrace -**Inherits:** Object - - - - -# Class Methods -## backtrace() [](#method-c-backtrace) -## backtrace_locations() [](#method-c-backtrace_locations) - diff --git a/example/ruby/ExceptionSpecs/ConstructorException.md b/example/ruby/ExceptionSpecs/ConstructorException.md deleted file mode 100644 index 0e51f5d..0000000 --- a/example/ruby/ExceptionSpecs/ConstructorException.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: ExceptionSpecs::ConstructorException -**Inherits:** Exception - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ConstructorException] a new instance of ConstructorException - diff --git a/example/ruby/ExceptionSpecs/EmptyToS.md b/example/ruby/ExceptionSpecs/EmptyToS.md deleted file mode 100644 index 3c52133..0000000 --- a/example/ruby/ExceptionSpecs/EmptyToS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: ExceptionSpecs::EmptyToS -**Inherits:** RuntimeError - - - - - -#Instance Methods -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/ExceptionSpecs/ExceptionModule.md b/example/ruby/ExceptionSpecs/ExceptionModule.md deleted file mode 100644 index 3de9f28..0000000 --- a/example/ruby/ExceptionSpecs/ExceptionModule.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ExceptionSpecs::ExceptionModule - - - - - -#Instance Methods -## repr() [](#method-i-repr) - diff --git a/example/ruby/ExceptionSpecs/Exceptional.md b/example/ruby/ExceptionSpecs/Exceptional.md deleted file mode 100644 index 3d21bf9..0000000 --- a/example/ruby/ExceptionSpecs/Exceptional.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: ExceptionSpecs::Exceptional -**Inherits:** Exception - - - - - diff --git a/example/ruby/ExceptionSpecs/InitializeException.md b/example/ruby/ExceptionSpecs/InitializeException.md deleted file mode 100644 index 3f443ae..0000000 --- a/example/ruby/ExceptionSpecs/InitializeException.md +++ /dev/null @@ -1,18 +0,0 @@ -# Exception: ExceptionSpecs::InitializeException -**Inherits:** StandardError - - - - -# Attributes -## ivar[RW] [](#attribute-i-ivar) -Returns the value of attribute ivar. - - -#Instance Methods -## initialize(messagenil) [](#method-i-initialize) - -**@return** [InitializeException] a new instance of InitializeException - -## initialize_copy(other) [](#method-i-initialize_copy) - diff --git a/example/ruby/ExceptionSpecs/OverrideToS.md b/example/ruby/ExceptionSpecs/OverrideToS.md deleted file mode 100644 index 3e18cf0..0000000 --- a/example/ruby/ExceptionSpecs/OverrideToS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: ExceptionSpecs::OverrideToS -**Inherits:** RuntimeError - - - - - -#Instance Methods -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/ExceptionSpecs/UnExceptional.md b/example/ruby/ExceptionSpecs/UnExceptional.md deleted file mode 100644 index edbc717..0000000 --- a/example/ruby/ExceptionSpecs/UnExceptional.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: ExceptionSpecs::UnExceptional -**Inherits:** Exception - - - - - -#Instance Methods -## backtrace() [](#method-i-backtrace) - -## message() [](#method-i-message) - diff --git a/example/ruby/ExceptionState.md b/example/ruby/ExceptionState.md deleted file mode 100644 index fcd3574..0000000 --- a/example/ruby/ExceptionState.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: ExceptionState -**Inherits:** Object - - - - -# Attributes -## describe[RW] [](#attribute-i-describe) -Returns the value of attribute describe. - -## description[RW] [](#attribute-i-description) -Returns the value of attribute description. - -## exception[RW] [](#attribute-i-exception) -Returns the value of attribute exception. - -## it[RW] [](#attribute-i-it) -Returns the value of attribute it. - - -#Instance Methods -## backtrace() [](#method-i-backtrace) - -## failure?() [](#method-i-failure?) - -**@return** [Boolean] - -## initialize(state, location, exception) [](#method-i-initialize) - -**@return** [ExceptionState] a new instance of ExceptionState - -## message() [](#method-i-message) - diff --git a/example/ruby/ExpectedException.md b/example/ruby/ExpectedException.md deleted file mode 100644 index 57a60e6..0000000 --- a/example/ruby/ExpectedException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: ExpectedException -**Inherits:** Exception - - - - - diff --git a/example/ruby/Exports.md b/example/ruby/Exports.md deleted file mode 100644 index c6c373c..0000000 --- a/example/ruby/Exports.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Exports -**Inherits:** Object - - - - -# Class Methods -## create(*args , &block ) [](#method-c-create) -## extract(objs , *rest ) [](#method-c-extract) -## output(output $output, &block ) [](#method-c-output) - -#Instance Methods -## exports(name$name, library$library, description$description) [](#method-i-exports) - -## initialize(objs) [](#method-i-initialize) - -**@return** [Exports] a new instance of Exports - -## read_substitution(header, syms, winapis) [](#method-i-read_substitution) - diff --git a/example/ruby/Exports/Cygwin.md b/example/ruby/Exports/Cygwin.md deleted file mode 100644 index fa45f5e..0000000 --- a/example/ruby/Exports/Cygwin.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Exports::Cygwin -**Inherits:** Exports - - - - -# Class Methods -## nm() [](#method-c-nm) - -#Instance Methods -## each_export(objs) [](#method-i-each_export) - -## each_line(objs, &block) [](#method-i-each_line) - -## exports() [](#method-i-exports) - diff --git a/example/ruby/Exports/Mingw.md b/example/ruby/Exports/Mingw.md deleted file mode 100644 index 77aeaa0..0000000 --- a/example/ruby/Exports/Mingw.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Exports::Mingw -**Inherits:** Exports::Cygwin - - - - - -#Instance Methods -## each_export(objs) [](#method-i-each_export) - -**@yield** ["strcasecmp", "_stricmp"] - diff --git a/example/ruby/Exports/Mswin.md b/example/ruby/Exports/Mswin.md deleted file mode 100644 index 8342271..0000000 --- a/example/ruby/Exports/Mswin.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Exports::Mswin -**Inherits:** Exports - - - - - -#Instance Methods -## each_export(objs) [](#method-i-each_export) - -**@yield** ["strcasecmp", "msvcrt.stricmp"] - -## each_line(objs, &block) [](#method-i-each_line) - diff --git a/example/ruby/Exports/Msys.md b/example/ruby/Exports/Msys.md deleted file mode 100644 index 0499d40..0000000 --- a/example/ruby/Exports/Msys.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Exports::Msys -**Inherits:** Exports::Cygwin - - - - - diff --git a/example/ruby/ExtArray.md b/example/ruby/ExtArray.md deleted file mode 100644 index 28bdea3..0000000 --- a/example/ruby/ExtArray.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ExtArray -**Inherits:** Array - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ExtArray] a new instance of ExtArray - diff --git a/example/ruby/ExtLibs.md b/example/ruby/ExtLibs.md deleted file mode 100644 index cdec02e..0000000 --- a/example/ruby/ExtLibs.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: ExtLibs -**Inherits:** Object - - - - -# Class Methods -## run(argv ) [](#method-c-run) - -#Instance Methods -## cache_file(url, cache_dir) [](#method-i-cache_file) - -## do_checksum(cache, chksums) [](#method-i-do_checksum) - -## do_command(mode, dest, url, cache_dir, chksums) [](#method-i-do_command) - -## do_download(url, cache_dir) [](#method-i-do_download) - -## do_exec(command, dir, dest) [](#method-i-do_exec) - -## do_extract(cache, dir) [](#method-i-do_extract) - -## do_link(file, src, dest) [](#method-i-do_link) - -## do_patch(dest, patch, args) [](#method-i-do_patch) - -## initialize(mode:all, cache_dir:nil) [](#method-i-initialize) - -**@return** [ExtLibs] a new instance of ExtLibs - -## process(list) [](#method-i-process) - -## process_under(dir) [](#method-i-process_under) - diff --git a/example/ruby/ExtLibs/Colorize.md b/example/ruby/ExtLibs/Colorize.md deleted file mode 100644 index 9adfa76..0000000 --- a/example/ruby/ExtLibs/Colorize.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ExtLibs::Colorize -**Inherits:** Object - - - - - -#Instance Methods -## fail(str) [](#method-i-fail) - -## pass(str) [](#method-i-pass) - diff --git a/example/ruby/ExtLibs/Vars.md b/example/ruby/ExtLibs/Vars.md deleted file mode 100644 index 1b4ced2..0000000 --- a/example/ruby/ExtLibs/Vars.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ExtLibs::Vars -**Inherits:** Hash - - - - - -#Instance Methods -## expand(str) [](#method-i-expand) - -## pattern() [](#method-i-pattern) - diff --git a/example/ruby/Fail.md b/example/ruby/Fail.md deleted file mode 100644 index 91b37ef..0000000 --- a/example/ruby/Fail.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Fail -**Inherits:** Gem::Net::HTTP - - - - - -#Instance Methods -## connect() [](#method-i-connect) -Ensure we don't start a connect here - -## exception(req) [](#method-i-exception) - -## request(req, bodynil, &block) [](#method-i-request) - diff --git a/example/ruby/FalseClass.md b/example/ruby/FalseClass.md deleted file mode 100644 index 5a6badd..0000000 --- a/example/ruby/FalseClass.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: FalseClass -**Inherits:** Object - - -The global value `false` is the only instance of class FalseClass and -represents a logically false value in boolean expressions. The class provides -operators allowing `false` to participate correctly in logical expressions. - - - -#Instance Methods -## &(obj2) [](#method-i-&) -Returns `false`: - - false & true # => false - false & Object.new # => false - -Argument `object` is evaluated: - - false & raise # Raises RuntimeError. - -**@overload** [] - -**@overload** [] - -## ===() [](#method-i-===) - -## ^() [](#method-i-^) - -## hash() [](#method-i-hash) - -## inspect() [](#method-i-inspect) -The string representation of `false` is "false". - -**@overload** [] - -## old_to_s() [](#method-i-old_to_s) -The string representation of `false` is "false". - -**@overload** [] - -## to_s() [](#method-i-to_s) -The string representation of `false` is "false". - -**@overload** [] - -## |() [](#method-i-|) - diff --git a/example/ruby/Fcntl.md b/example/ruby/Fcntl.md deleted file mode 100644 index ec5ffa0..0000000 --- a/example/ruby/Fcntl.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: Fcntl - - -Fcntl loads the constants defined in the system's C header file, and -used with both the fcntl(2) and open(2) POSIX system calls. - -To perform a fcntl(2) operation, use IO::fcntl. - -To perform an open(2) operation, use IO::sysopen. - -The set of operations and constants available depends upon specific operating -system. Some values listed below may not be supported on your system. - -See your fcntl(2) man page for complete details. - -Open /tmp/tempfile as a write-only file that is created if it doesn't exist: - - require 'fcntl' - - fd = IO.sysopen('/tmp/tempfile', - Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT) - f = IO.open(fd) - f.syswrite("TEMP DATA") - f.close - -Get the flags on file `s`: - - m = s.fcntl(Fcntl::F_GETFL, 0) - -Set the non-blocking flag on `f` in addition to the existing flags in `m`. - - f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m) - - - diff --git a/example/ruby/FeatureGuard.md b/example/ruby/FeatureGuard.md deleted file mode 100644 index eb09c5e..0000000 --- a/example/ruby/FeatureGuard.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: FeatureGuard -**Inherits:** SpecGuard - - - - -# Class Methods -## enabled?(*features ) [](#method-c-enabled?) -**@return** [Boolean] - - -#Instance Methods -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/Fiber.md b/example/ruby/Fiber.md deleted file mode 100644 index d914412..0000000 --- a/example/ruby/Fiber.md +++ /dev/null @@ -1,487 +0,0 @@ -# Class: Fiber -**Inherits:** Object - - -Fibers are primitives for implementing light weight cooperative concurrency in -Ruby. Basically they are a means of creating code blocks that can be paused -and resumed, much like threads. The main difference is that they are never -preempted and that the scheduling must be done by the programmer and not the -VM. - -As opposed to other stackless light weight concurrency models, each fiber -comes with a stack. This enables the fiber to be paused from deeply nested -function calls within the fiber block. See the ruby(1) manpage to configure -the size of the fiber stack(s). - -When a fiber is created it will not run automatically. Rather it must be -explicitly asked to run using the Fiber#resume method. The code running inside -the fiber can give up control by calling Fiber.yield in which case it yields -control back to caller (the caller of the Fiber#resume). - -Upon yielding or termination the Fiber returns the value of the last executed -expression - -For instance: - - fiber = Fiber.new do - Fiber.yield 1 - 2 - end - - puts fiber.resume - puts fiber.resume - puts fiber.resume - -*produces* - - 1 - 2 - FiberError: dead fiber called - -The Fiber#resume method accepts an arbitrary number of parameters, if it is -the first call to #resume then they will be passed as block arguments. -Otherwise they will be the return value of the call to Fiber.yield - -Example: - - fiber = Fiber.new do |first| - second = Fiber.yield first + 2 - end - - puts fiber.resume 10 - puts fiber.resume 1_000_000 - puts fiber.resume "The fiber will be dead before I can cause trouble" - -*produces* - - 12 - 1000000 - FiberError: dead fiber called - -## Non-blocking Fibers - -The concept of *non-blocking fiber* was introduced in Ruby 3.0. A non-blocking -fiber, when reaching a operation that would normally block the fiber (like -`sleep`, or wait for another process or I/O) will yield control to other -fibers and allow the *scheduler* to handle blocking and waking up (resuming) -this fiber when it can proceed. - -For a Fiber to behave as non-blocking, it need to be created in Fiber.new with -`blocking: false` (which is the default), and Fiber.scheduler should be set -with Fiber.set_scheduler. If Fiber.scheduler is not set in the current thread, -blocking and non-blocking fibers' behavior is identical. - -Ruby doesn't provide a scheduler class: it is expected to be implemented by -the user and correspond to Fiber::Scheduler. - -There is also Fiber.schedule method, which is expected to immediately perform -the given block in a non-blocking manner. Its actual implementation is up to -the scheduler. - - -# Class Methods -## [](key ) [](#method-c-[]) -Returns the value of the fiber storage variable identified by `key`. - -The `key` must be a symbol, and the value is set by Fiber#[]= or Fiber#store. - -See also Fiber::[]=. -**@overload** [] - -## []=(key , value ) [](#method-c-[]=) -Assign `value` to the fiber storage variable identified by `key`. The variable -is created if it doesn't exist. - -`key` must be a Symbol, otherwise a TypeError is raised. - -See also Fiber::[]. -**@overload** [] - -## blocking() [](#method-c-blocking) -Forces the fiber to be blocking for the duration of the block. Returns the -result of the block. - -See the "Non-blocking fibers" section in class docs for details. -**@overload** [] - -## blocking?() [](#method-c-blocking?) -Returns `false` if the current fiber is non-blocking. Fiber is non-blocking if -it was created via passing `blocking: false` to Fiber.new, or via -Fiber.schedule. - -If the current Fiber is blocking, the method returns 1. Future developments -may allow for situations where larger integers could be returned. - -Note that, even if the method returns `false`, Fiber behaves differently only -if Fiber.scheduler is set in the current thread. - -See the "Non-blocking fibers" section in class docs for details. -**@overload** [] - -## current() [](#method-c-current) -Returns the current fiber. If you are not running in the context of a fiber -this method will return the root fiber. -**@overload** [] - -## current_scheduler() [](#method-c-current_scheduler) -Returns the Fiber scheduler, that was last set for the current thread with -Fiber.set_scheduler if and only if the current fiber is non-blocking. -**@overload** [] - -## schedule(*args ) [](#method-c-schedule) -The method is *expected* to immediately run the provided block of code in a -separate non-blocking fiber. - - puts "Go to sleep!" - - Fiber.set_scheduler(MyScheduler.new) - - Fiber.schedule do - puts "Going to sleep" - sleep(1) - puts "I slept well" - end - - puts "Wakey-wakey, sleepyhead" - -Assuming MyScheduler is properly implemented, this program will produce: - - Go to sleep! - Going to sleep - Wakey-wakey, sleepyhead - ...1 sec pause here... - I slept well - -...e.g. on the first blocking operation inside the Fiber (`sleep(1)`), the -control is yielded to the outside code (main fiber), and *at the end of that -execution*, the scheduler takes care of properly resuming all the blocked -fibers. - -Note that the behavior described above is how the method is *expected* to -behave, actual behavior is up to the current scheduler's implementation of -Fiber::Scheduler#fiber method. Ruby doesn't enforce this method to behave in -any particular way. - -If the scheduler is not set, the method raises `RuntimeError (No scheduler is -available!)`. -**@overload** [] - -## scheduler() [](#method-c-scheduler) -Returns the Fiber scheduler, that was last set for the current thread with -Fiber.set_scheduler. Returns `nil` if no scheduler is set (which is the -default), and non-blocking fibers' behavior is the same as blocking. (see -"Non-blocking fibers" section in class docs for details about the scheduler -concept). -**@overload** [] - -## set_scheduler(scheduler ) [](#method-c-set_scheduler) -Sets the Fiber scheduler for the current thread. If the scheduler is set, -non-blocking fibers (created by Fiber.new with `blocking: false`, or by -Fiber.schedule) call that scheduler's hook methods on potentially blocking -operations, and the current thread will call scheduler's `close` method on -finalization (allowing the scheduler to properly manage all non-finished -fibers). - -`scheduler` can be an object of any class corresponding to Fiber::Scheduler. -Its implementation is up to the user. - -See also the "Non-blocking fibers" section in class docs. -**@overload** [] - -## yield(*args ) [](#method-c-yield) -Yields control back to the context that resumed the fiber, passing along any -arguments that were passed to it. The fiber will resume processing at this -point when #resume is called next. Any arguments passed to the next #resume -will be the value that this Fiber.yield expression evaluates to. -**@overload** [] - - -#Instance Methods -## alive?() [](#method-i-alive?) -Returns true if the fiber can still be resumed (or transferred to). After -finishing execution of the fiber block this method will always return `false`. - -**@overload** [] - -## backtrace(*args) [](#method-i-backtrace) -Returns the current execution stack of the fiber. `start`, `count` and `end` -allow to select only parts of the backtrace. - - def level3 - Fiber.yield - end - - def level2 - level3 - end - - def level1 - level2 - end - - f = Fiber.new { level1 } - - # It is empty before the fiber started - f.backtrace - #=> [] - - f.resume - - f.backtrace - #=> ["test.rb:2:in `yield'", "test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'", "test.rb:13:in `block in
'"] - p f.backtrace(1) # start from the item 1 - #=> ["test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'", "test.rb:13:in `block in
'"] - p f.backtrace(2, 2) # start from item 2, take 2 - #=> ["test.rb:6:in `level2'", "test.rb:10:in `level1'"] - p f.backtrace(1..3) # take items from 1 to 3 - #=> ["test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'"] - - f.resume - - # It is nil after the fiber is finished - f.backtrace - #=> nil - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## backtrace_locations(*args) [](#method-i-backtrace_locations) -Like #backtrace, but returns each line of the execution stack as a -Thread::Backtrace::Location. Accepts the same arguments as #backtrace. - - f = Fiber.new { Fiber.yield } - f.resume - loc = f.backtrace_locations.first - loc.label #=> "yield" - loc.path #=> "test.rb" - loc.lineno #=> 1 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## blocking?() [](#method-i-blocking?) -Returns `true` if `fiber` is blocking and `false` otherwise. Fiber is -non-blocking if it was created via passing `blocking: false` to Fiber.new, or -via Fiber.schedule. - -Note that, even if the method returns `false`, the fiber behaves differently -only if Fiber.scheduler is set in the current thread. - -See the "Non-blocking fibers" section in class docs for details. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates new Fiber. Initially, the fiber is not running and can be resumed with -#resume. Arguments to the first #resume call will be passed to the block: - - f = Fiber.new do |initial| - current = initial - loop do - puts "current: #{current.inspect}" - current = Fiber.yield - end - end - f.resume(100) # prints: current: 100 - f.resume(1, 2, 3) # prints: current: [1, 2, 3] - f.resume # prints: current: nil - # ... and so on ... - -If `blocking: false` is passed to `Fiber.new`, *and* current thread has a -Fiber.scheduler defined, the Fiber becomes non-blocking (see "Non-blocking -Fibers" section in class docs). - -If the `storage` is unspecified, the default is to inherit a copy of the -storage from the current fiber. This is the same as specifying `storage: -true`. - - Fiber[:x] = 1 - Fiber.new do - Fiber[:x] # => 1 - Fiber[:x] = 2 - end.resume - Fiber[:x] # => 1 - -If the given `storage` is `nil`, this function will lazy initialize the -internal storage, which starts as an empty hash. - - Fiber[:x] = "Hello World" - Fiber.new(storage: nil) do - Fiber[:x] # nil - end - -Otherwise, the given `storage` is used as the new fiber's storage, and it must -be an instance of Hash. - -Explicitly using `storage: true` is currently experimental and may change in -the future. - -**@overload** [] - -## kill() [](#method-i-kill) -Terminates the fiber by raising an uncatchable exception. It only terminates -the given fiber and no other fiber, returning `nil` to another fiber if that -fiber was calling #resume or #transfer. - -`Fiber#kill` only interrupts another fiber when it is in Fiber.yield. If -called on the current fiber then it raises that exception at the `Fiber#kill` -call site. - -If the fiber has not been started, transition directly to the terminated -state. - -If the fiber is already terminated, does nothing. - -Raises FiberError if called on a fiber belonging to another thread. - -**@overload** [] - -## raise(*args) [](#method-i-raise) -Raises an exception in the fiber at the point at which the last `Fiber.yield` -was called. If the fiber has not been started or has already run to -completion, raises `FiberError`. If the fiber is yielding, it is resumed. If -it is transferring, it is transferred into. But if it is resuming, raises -`FiberError`. - -With no arguments, raises a `RuntimeError`. With a single `String` argument, -raises a `RuntimeError` with the string as a message. Otherwise, the first -parameter should be the name of an `Exception` class (or an object that -returns an `Exception` object when sent an `exception` message). The optional -second parameter sets the message associated with the exception, and the third -parameter is an array of callback information. Exceptions are caught by the -`rescue` clause of `begin...end` blocks. - -Raises `FiberError` if called on a Fiber belonging to another `Thread`. - -See Kernel#raise for more information. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## resume(*args) [](#method-i-resume) -Resumes the fiber from the point at which the last Fiber.yield was called, or -starts running it if it is the first call to #resume. Arguments passed to -resume will be the value of the Fiber.yield expression or will be passed as -block parameters to the fiber's block if this is the first #resume. - -Alternatively, when resume is called it evaluates to the arguments passed to -the next Fiber.yield statement inside the fiber's block or to the block value -if it runs to completion without any Fiber.yield - -**@overload** [] - -## storage() [](#method-i-storage) -Returns a copy of the storage hash for the fiber. The method can only be -called on the Fiber.current. - -**@overload** [] - -## storage=(value) [](#method-i-storage=) -Sets the storage hash for the fiber. This feature is experimental and may -change in the future. The method can only be called on the Fiber.current. - -You should be careful about using this method as you may inadvertently clear -important fiber-storage state. You should mostly prefer to assign specific -keys in the storage using Fiber::[]=. - -You can also use `Fiber.new(storage: nil)` to create a fiber with an empty -storage. - -Example: - - while request = request_queue.pop - # Reset the per-request state: - Fiber.current.storage = nil - handle_request(request) - end - -**@overload** [] - -## to_s() [](#method-i-to_s) - -## transfer(*args) [](#method-i-transfer) -Transfer control to another fiber, resuming it from where it last stopped or -starting it if it was not resumed before. The calling fiber will be suspended -much like in a call to Fiber.yield. - -The fiber which receives the transfer call treats it much like a resume call. -Arguments passed to transfer are treated like those passed to resume. - -The two style of control passing to and from fiber (one is #resume and -Fiber::yield, another is #transfer to and from fiber) can't be freely mixed. - -* If the Fiber's lifecycle had started with transfer, it will never be able - to yield or be resumed control passing, only finish or transfer back. (It - still can resume other fibers that are allowed to be resumed.) -* If the Fiber's lifecycle had started with resume, it can yield or transfer - to another Fiber, but can receive control back only the way compatible - with the way it was given away: if it had transferred, it only can be - transferred back, and if it had yielded, it only can be resumed back. - After that, it again can transfer or yield. - -If those rules are broken FiberError is raised. - -For an individual Fiber design, yield/resume is easier to use (the Fiber just -gives away control, it doesn't need to think about who the control is given -to), while transfer is more flexible for complex cases, allowing to build -arbitrary graphs of Fibers dependent on each other. - -Example: - - manager = nil # For local var to be visible inside worker block - - # This fiber would be started with transfer - # It can't yield, and can't be resumed - worker = Fiber.new { |work| - puts "Worker: starts" - puts "Worker: Performed #{work.inspect}, transferring back" - # Fiber.yield # this would raise FiberError: attempt to yield on a not resumed fiber - # manager.resume # this would raise FiberError: attempt to resume a resumed fiber (double resume) - manager.transfer(work.capitalize) - } - - # This fiber would be started with resume - # It can yield or transfer, and can be transferred - # back or resumed - manager = Fiber.new { - puts "Manager: starts" - puts "Manager: transferring 'something' to worker" - result = worker.transfer('something') - puts "Manager: worker returned #{result.inspect}" - # worker.resume # this would raise FiberError: attempt to resume a transferring fiber - Fiber.yield # this is OK, the fiber transferred from and to, now it can yield - puts "Manager: finished" - } - - puts "Starting the manager" - manager.resume - puts "Resuming the manager" - # manager.transfer # this would raise FiberError: attempt to transfer to a yielding fiber - manager.resume - -*produces* - - Starting the manager - Manager: starts - Manager: transferring 'something' to worker - Worker: starts - Worker: Performed "something", transferring back - Manager: worker returned "Something" - Resuming the manager - Manager: finished - -**@overload** [] - diff --git a/example/ruby/Fiber/Pool.md b/example/ruby/Fiber/Pool.md deleted file mode 100644 index c3b1b5d..0000000 --- a/example/ruby/Fiber/Pool.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Fiber::Pool -**Inherits:** Object - - -:nodoc: experimental - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - diff --git a/example/ruby/Fiber/Scheduler.md b/example/ruby/Fiber/Scheduler.md deleted file mode 100644 index 7ba1e93..0000000 --- a/example/ruby/Fiber/Scheduler.md +++ /dev/null @@ -1,89 +0,0 @@ -# Class: Fiber::Scheduler -**Inherits:** Object - - -This is not an existing class, but documentation of the interface that -Scheduler object should comply to in order to be used as argument to -Fiber.scheduler and handle non-blocking fibers. See also the "Non-blocking -fibers" section in Fiber class docs for explanations of some concepts. - -Scheduler's behavior and usage are expected to be as follows: - -* When the execution in the non-blocking Fiber reaches some blocking - operation (like sleep, wait for a process, or a non-ready I/O), it calls - some of the scheduler's hook methods, listed below. -* Scheduler somehow registers what the current fiber is waiting on, and - yields control to other fibers with Fiber.yield (so the fiber would be - suspended while expecting its wait to end, and other fibers in the same - thread can perform) -* At the end of the current thread execution, the scheduler's method - #scheduler_close is called -* The scheduler runs into a wait loop, checking all the blocked fibers - (which it has registered on hook calls) and resuming them when the awaited - resource is ready (e.g. I/O ready or sleep time elapsed). - -This way concurrent execution will be achieved transparently for every -individual Fiber's code. - -Scheduler implementations are provided by gems, like -[Async](https://github.com/socketry/async). - -Hook methods are: - -* #io_wait, #io_read, #io_write, #io_pread, #io_pwrite, and #io_select, - #io_close -* #process_wait -* #kernel_sleep -* #timeout_after -* #address_resolve -* #block and #unblock -* #blocking_operation_wait -* (the list is expanded as Ruby developers make more methods having - non-blocking calls) - -When not specified otherwise, the hook implementations are mandatory: if they -are not implemented, the methods trying to call hook will fail. To provide -backward compatibility, in the future hooks will be optional (if they are not -implemented, due to the scheduler being created for the older Ruby version, -the code which needs this hook will not fail, and will just behave in a -blocking fashion). - -It is also strongly recommended that the scheduler implements the #fiber -method, which is delegated to by Fiber.schedule. - -Sample *toy* implementation of the scheduler can be found in Ruby's code, in -`test/fiber/scheduler.rb` - - - -#Instance Methods -## address_resolve() [](#method-i-address_resolve) - -## block() [](#method-i-block) - -## blocking_operation_wait() [](#method-i-blocking_operation_wait) - -## close() [](#method-i-close) - -## fiber() [](#method-i-fiber) - -## io_pread() [](#method-i-io_pread) - -## io_pwrite() [](#method-i-io_pwrite) - -## io_read() [](#method-i-io_read) - -## io_select() [](#method-i-io_select) - -## io_wait() [](#method-i-io_wait) - -## io_write() [](#method-i-io_write) - -## kernel_sleep() [](#method-i-kernel_sleep) - -## process_wait() [](#method-i-process_wait) - -## timeout_after() [](#method-i-timeout_after) - -## unblock() [](#method-i-unblock) - diff --git a/example/ruby/FiberError.md b/example/ruby/FiberError.md deleted file mode 100644 index 40d9e45..0000000 --- a/example/ruby/FiberError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: FiberError -**Inherits:** StandardError - - -Raised when an invalid operation is attempted on a Fiber, in particular when -attempting to call/resume a dead fiber, attempting to yield from the root -fiber, or calling a fiber across threads. - - fiber = Fiber.new{} - fiber.resume #=> nil - fiber.resume #=> FiberError: dead fiber called - - - diff --git a/example/ruby/FiberSpecs.md b/example/ruby/FiberSpecs.md deleted file mode 100644 index ab95b26..0000000 --- a/example/ruby/FiberSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: FiberSpecs - - - - - diff --git a/example/ruby/FiberSpecs/CustomError.md b/example/ruby/FiberSpecs/CustomError.md deleted file mode 100644 index f812ef1..0000000 --- a/example/ruby/FiberSpecs/CustomError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: FiberSpecs::CustomError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/FiberSpecs/NewFiberToRaise.md b/example/ruby/FiberSpecs/NewFiberToRaise.md deleted file mode 100644 index 71fc214..0000000 --- a/example/ruby/FiberSpecs/NewFiberToRaise.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: FiberSpecs::NewFiberToRaise -**Inherits:** Object - - - - -# Class Methods -## raise(*args ) [](#method-c-raise) - diff --git a/example/ruby/Fiddle.md b/example/ruby/Fiddle.md deleted file mode 100644 index 76d87cc..0000000 --- a/example/ruby/Fiddle.md +++ /dev/null @@ -1,112 +0,0 @@ -# Module: Fiddle - - -A libffi wrapper for Ruby. - -## Description - -Fiddle is an extension to translate a foreign function interface (FFI) with -ruby. - -It wraps [libffi](http://sourceware.org/libffi/), a popular C library which -provides a portable interface that allows code written in one language to call -code written in another language. - -## Example - -Here we will use Fiddle::Function to wrap [floor(3) from -libm](http://linux.die.net/man/3/floor) - - require 'fiddle' - - libm = Fiddle.dlopen('/lib/libm.so.6') - - floor = Fiddle::Function.new( - libm['floor'], - [Fiddle::TYPE_DOUBLE], - Fiddle::TYPE_DOUBLE - ) - - puts floor.call(3.14159) #=> 3.0 - - -# Class Methods -## dlopen(library ) [](#method-c-dlopen) -call-seq: dlopen(library) => Fiddle::Handle - -Creates a new handler that opens `library`, and returns an instance of -Fiddle::Handle. - -If `nil` is given for the `library`, Fiddle::Handle::DEFAULT is used, which is -the equivalent to RTLD_DEFAULT. See `man 3 dlopen` for more. - - lib = Fiddle.dlopen(nil) - -The default is dependent on OS, and provide a handle for all libraries already -loaded. For example, in most cases you can use this to access `libc` -functions, or ruby functions like `rb_str_new`. - -See Fiddle::Handle.new for more. -## dlunwrap(addr ) [](#method-c-dlunwrap) -Returns the Ruby object stored at the memory address `addr` - -Example: - - x = Object.new - # => # - Fiddle.dlwrap(x) - # => 4425504880 - Fiddle.dlunwrap(_) - # => # -**@overload** [] - -## dlwrap(val ) [](#method-c-dlwrap) -Returns the memory address of the Ruby object stored at `val` - -Example: - - x = Object.new - # => # - Fiddle.dlwrap(x) - # => 4425504880 - -In the case `val` is not a heap allocated object, this method will return the -tagged pointer value. - -Example: - - Fiddle.dlwrap(123) - # => 247 -**@overload** [] - -## free(ptr ) [](#method-c-free) -Free the memory at address `addr` -**@overload** [] - -## last_error() [](#method-c-last_error) -Returns the last `Error` of the current executing `Thread` or nil if none -## last_error=(error ) [](#method-c-last_error=) -Sets the last `Error` of the current executing `Thread` to `error` -## malloc(size ) [](#method-c-malloc) -Allocate `size` bytes of memory and return the integer memory address for the -allocated memory. -**@overload** [] - -## realloc(addr , size ) [](#method-c-realloc) -Change the size of the memory allocated at the memory location `addr` to -`size` bytes. Returns the memory address of the reallocated memory, which may -be different than the address passed in. -**@overload** [] - -## win32_last_error() [](#method-c-win32_last_error) -Returns the last win32 `Error` of the current executing `Thread` or nil if -none -## win32_last_error=(error ) [](#method-c-win32_last_error=) -Sets the last win32 `Error` of the current executing `Thread` to `error` -## win32_last_socket_error() [](#method-c-win32_last_socket_error) -Returns the last win32 socket `Error` of the current executing `Thread` or nil -if none -## win32_last_socket_error=(error ) [](#method-c-win32_last_socket_error=) -Sets the last win32 socket `Error` of the current executing `Thread` to -`error` - diff --git a/example/ruby/Fiddle/BasicTypes.md b/example/ruby/Fiddle/BasicTypes.md deleted file mode 100644 index 2b658ee..0000000 --- a/example/ruby/Fiddle/BasicTypes.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: Fiddle::BasicTypes - - -Adds basic type aliases to the including class for use with Fiddle::Importer. - -The aliases added are `uint` and `u_int` (`unsigned int`) and `ulong` and -`u_long` (`unsigned long`) - - -# Class Methods -## included(m ) [](#method-c-included) -:nodoc: - diff --git a/example/ruby/Fiddle/CParser.md b/example/ruby/Fiddle/CParser.md deleted file mode 100644 index 5832d3b..0000000 --- a/example/ruby/Fiddle/CParser.md +++ /dev/null @@ -1,87 +0,0 @@ -# Module: Fiddle::CParser - - -A mixin that provides methods for parsing C struct and prototype signatures. - -## Example - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - - -#Instance Methods -## parse_ctype(ty, tymapnil) [](#method-i-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP - -## parse_signature(signature, tymapnil) [](#method-i-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] - -## parse_struct_signature(signature, tymapnil) [](#method-i-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] - diff --git a/example/ruby/Fiddle/CStruct.md b/example/ruby/Fiddle/CStruct.md deleted file mode 100644 index 8b0389c..0000000 --- a/example/ruby/Fiddle/CStruct.md +++ /dev/null @@ -1,2063 +0,0 @@ -# Class: Fiddle::CStruct -**Inherits:** Object - -**Includes:** Enumerable - - -A base class for objects representing a C structure - - -# Class Methods -## entity_class() [](#method-c-entity_class) -accessor to Fiddle::CStructEntity -## offsetof(name , members , types ) [](#method-c-offsetof) -:nodoc: - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_pair() [](#method-i-each_pair) - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## replace(another) [](#method-i-replace) - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h() [](#method-i-to_h) - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Fiddle/CStructBuilder.md b/example/ruby/Fiddle/CStructBuilder.md deleted file mode 100644 index 48a77f4..0000000 --- a/example/ruby/Fiddle/CStructBuilder.md +++ /dev/null @@ -1,49 +0,0 @@ -# Module: Fiddle::CStructBuilder - - -Used to construct C classes (CUnion, CStruct, etc) - -Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in -an easy-to-use manner. - - -# Class Methods -## create(klass , types , members ) [](#method-c-create) -Construct a new class given a C: -* class `klass` (CUnion, CStruct, or other that provide an #entity_class) -* `types` (Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types - constants) -* corresponding `members` - -Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in -an easy-to-use manner. - -Examples: - - require 'fiddle/struct' - require 'fiddle/cparser' - - include Fiddle::CParser - - types, members = parse_struct_signature(['int i','char c']) - - MyStruct = Fiddle::CStructBuilder.create(Fiddle::CUnion, types, members) - - MyStruct.malloc(Fiddle::RUBY_FREE) do |obj| - ... - end - - obj = MyStruct.malloc(Fiddle::RUBY_FREE) - begin - ... - ensure - obj.call_free - end - - obj = MyStruct.malloc - begin - ... - ensure - Fiddle.free obj.to_ptr - end - diff --git a/example/ruby/Fiddle/CStructEntity.md b/example/ruby/Fiddle/CStructEntity.md deleted file mode 100644 index efd3f4e..0000000 --- a/example/ruby/Fiddle/CStructEntity.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Fiddle::CStructEntity -**Inherits:** Fiddle::Pointer - -**Includes:** Fiddle::PackInfo, Fiddle::ValueUtil - - -A pointer to a C structure - - -# Class Methods -## alignment(types ) [](#method-c-alignment) -## malloc(types , func nil, size size(types)) [](#method-c-malloc) -Allocates a C struct with the `types` provided. - -See Fiddle::Pointer.malloc for memory management issues. -## size(types ) [](#method-c-size) -Returns the offset for the packed sizes for the given `types`. - - Fiddle::CStructEntity.size( - [ Fiddle::TYPE_DOUBLE, - Fiddle::TYPE_INT, - Fiddle::TYPE_CHAR, - Fiddle::TYPE_VOIDP ]) #=> 24 - -#Instance Methods -## +(delta) [](#method-i-+) - -## -(delta) [](#method-i--) - -## [](*args) [](#method-i-[]) -Fetch struct member `name` if only one argument is specified. If two arguments -are specified, the first is an offset and the second is a length and this -method returns the string of `length` bytes beginning at `offset`. - -Examples: - - my_struct = struct(['int id']).malloc - my_struct.id = 1 - my_struct['id'] # => 1 - my_struct[0, 4] # => "\x01\x00\x00\x00".b - -## []=(*args) [](#method-i-[]=) -Set struct member `name`, to value `val`. If more arguments are specified, -writes the string of bytes to the memory at the given `offset` and `length`. - -Examples: - - my_struct = struct(['int id']).malloc - my_struct['id'] = 1 - my_struct[0, 4] = "\x01\x00\x00\x00".b - my_struct.id # => 1 - -## assign_names(members) [](#method-i-assign_names) -Set the names of the `members` in this C struct - -## initialize(addr, types, funcnil) [](#method-i-initialize) -Wraps the C pointer `addr` as a C struct with the given `types`. - -When the instance is garbage collected, the C function `func` is called. - -See also Fiddle::Pointer.new - -**@return** [CStructEntity] a new instance of CStructEntity - -## set_ctypes(types) [](#method-i-set_ctypes) -Calculates the offsets and sizes for the given `types` in the struct. - -## signed_value(val, ty) [](#method-i-signed_value) - -## to_s() [](#method-i-to_s) -:nodoc: - -## unsigned_value(val, ty) [](#method-i-unsigned_value) - -## wrap_arg(arg, ty, funcs[], &block) [](#method-i-wrap_arg) - -## wrap_args(args, tys, funcs, &block) [](#method-i-wrap_args) - diff --git a/example/ruby/Fiddle/CUnion.md b/example/ruby/Fiddle/CUnion.md deleted file mode 100644 index e4ea90f..0000000 --- a/example/ruby/Fiddle/CUnion.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Fiddle::CUnion -**Inherits:** Object - - -A base class for objects representing a C union - - -# Class Methods -## entity_class() [](#method-c-entity_class) -accessor to Fiddle::CUnionEntity -## offsetof(name , members , types ) [](#method-c-offsetof) -:nodoc: - diff --git a/example/ruby/Fiddle/CUnionEntity.md b/example/ruby/Fiddle/CUnionEntity.md deleted file mode 100644 index 6f478b0..0000000 --- a/example/ruby/Fiddle/CUnionEntity.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Fiddle::CUnionEntity -**Inherits:** Fiddle::CStructEntity - -**Includes:** Fiddle::PackInfo - - -A pointer to a C union - - -# Class Methods -## size(types ) [](#method-c-size) -Returns the size needed for the union with the given `types`. - - Fiddle::CUnionEntity.size( - [ Fiddle::TYPE_DOUBLE, - Fiddle::TYPE_INT, - Fiddle::TYPE_CHAR, - Fiddle::TYPE_VOIDP ]) #=> 8 - -#Instance Methods -## set_ctypes(types) [](#method-i-set_ctypes) -Calculate the necessary offset and for each union member with the given -`types` - diff --git a/example/ruby/Fiddle/ClearedReferenceError.md b/example/ruby/Fiddle/ClearedReferenceError.md deleted file mode 100644 index d5a6085..0000000 --- a/example/ruby/Fiddle/ClearedReferenceError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Fiddle::ClearedReferenceError -**Inherits:** Fiddle::Error - - -Cleared reference exception - - - diff --git a/example/ruby/Fiddle/Closure.md b/example/ruby/Fiddle/Closure.md deleted file mode 100644 index d630635..0000000 --- a/example/ruby/Fiddle/Closure.md +++ /dev/null @@ -1,73 +0,0 @@ -# Class: Fiddle::Closure -**Inherits:** Object - - -## Description - -An FFI closure wrapper, for handling callbacks. - -## Example - - closure = Class.new(Fiddle::Closure) { - def call - 10 - end - }.new(Fiddle::TYPE_INT, []) - #=> #<#:0x0000000150d240> - func = Fiddle::Function.new(closure, [], Fiddle::TYPE_INT) - #=> # - func.call - #=> 10 - - -# Class Methods -## create(*args ) [](#method-c-create) -Create a new closure. If a block is given, the created closure is -automatically freed after the given block is executed. - -The all given arguments are passed to Fiddle::Closure.new. So using this -method without block equals to Fiddle::Closure.new. - -## Example - - Fiddle::Closure.create(TYPE_INT, [TYPE_INT]) do |closure| - # closure is freed automatically when this block is finished. - end -# Attributes -## args[RW] [](#attribute-i-args) -arguments of the FFI closure - -## ctype[RW] [](#attribute-i-ctype) -the C type of the return of the FFI closure - - -#Instance Methods -## free() [](#method-i-free) -Free this closure explicitly. You can't use this closure anymore. - -If this closure is already freed, this does nothing. - -## freed?() [](#method-i-freed?) -Whether this closure was freed explicitly. - -**@return** [Boolean] - -## initialize(ret, args, abiFunction::DEFAULT) [](#method-i-initialize) -call-seq: new(ret, args, abi = Fiddle::DEFAULT) - -Construct a new Closure object. - -* `ret` is the C type to be returned -* `args` is an Array of arguments, passed to the callback function -* `abi` is the abi of the closure - -If there is an error in preparing the ffi_cif or ffi_prep_closure, then a -RuntimeError will be raised. - -**@return** [Closure] a new instance of Closure - -## to_i() [](#method-i-to_i) -Returns the memory address for this closure. - -## to_ptr() [](#method-i-to_ptr) - diff --git a/example/ruby/Fiddle/Closure/BlockCaller.md b/example/ruby/Fiddle/Closure/BlockCaller.md deleted file mode 100644 index 663b539..0000000 --- a/example/ruby/Fiddle/Closure/BlockCaller.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Fiddle::Closure::BlockCaller -**Inherits:** Fiddle::Closure - - -Extends Fiddle::Closure to allow for building the closure in a block - - - -#Instance Methods -## call(*args) [](#method-i-call) -Calls the constructed BlockCaller, with `args` - -For an example see Fiddle::Closure::BlockCaller.new - -## initialize(ctype, args, abiFiddle::Function::DEFAULT, &block) [](#method-i-initialize) -## Description - -Construct a new BlockCaller object. - -* `ctype` is the C type to be returned -* `args` are passed the callback -* `abi` is the abi of the closure - -If there is an error in preparing the `ffi_cif` or `ffi_prep_closure`, then a -RuntimeError will be raised. - -## Example - - include Fiddle - - cb = Closure::BlockCaller.new(TYPE_INT, [TYPE_INT]) do |one| - one - end - - func = Function.new(cb, [TYPE_INT], TYPE_INT) - -**@return** [BlockCaller] a new instance of BlockCaller - diff --git a/example/ruby/Fiddle/CompositeHandler.md b/example/ruby/Fiddle/CompositeHandler.md deleted file mode 100644 index aeb88f0..0000000 --- a/example/ruby/Fiddle/CompositeHandler.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Fiddle::CompositeHandler -**Inherits:** Object - - -Used internally by Fiddle::Importer - - - -#Instance Methods -## [](symbol) [](#method-i-[]) -See Fiddle::CompositeHandler.sym - -## handlers() [](#method-i-handlers) -Array of the currently loaded libraries. - -## initialize(handlers) [](#method-i-initialize) -Create a new handler with the open `handlers` - -Used internally by Fiddle::Importer.dlload - -**@return** [CompositeHandler] a new instance of CompositeHandler - -## sym(symbol) [](#method-i-sym) -Returns the address as an Integer from any handlers with the function named -`symbol`. - -Raises a DLError if the handle is closed. - diff --git a/example/ruby/Fiddle/DLError.md b/example/ruby/Fiddle/DLError.md deleted file mode 100644 index 22a8aa5..0000000 --- a/example/ruby/Fiddle/DLError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Fiddle::DLError -**Inherits:** Fiddle::Error - - -standard dynamic load exception - - - diff --git a/example/ruby/Fiddle/Error.md b/example/ruby/Fiddle/Error.md deleted file mode 100644 index ac85f57..0000000 --- a/example/ruby/Fiddle/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Fiddle::Error -**Inherits:** StandardError - - -Generic error class for Fiddle - - - diff --git a/example/ruby/Fiddle/FFIBackend.md b/example/ruby/Fiddle/FFIBackend.md deleted file mode 100644 index 481dcf6..0000000 --- a/example/ruby/Fiddle/FFIBackend.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Fiddle::FFIBackend - - - - -# Class Methods -## to_ffi_type(fiddle_type ) [](#method-c-to_ffi_type) -**@raise** [TypeError] - - diff --git a/example/ruby/Fiddle/Function.md b/example/ruby/Fiddle/Function.md deleted file mode 100644 index 71795ad..0000000 --- a/example/ruby/Fiddle/Function.md +++ /dev/null @@ -1,93 +0,0 @@ -# Class: Fiddle::Function -**Inherits:** Object - - -## Description - -A representation of a C function - -## Examples - -### 'strcpy' - - @libc = Fiddle.dlopen "/lib/libc.so.6" - #=> # - f = Fiddle::Function.new( - @libc['strcpy'], - [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], - Fiddle::TYPE_VOIDP) - #=> # - buff = "000" - #=> "000" - str = f.call(buff, "123") - #=> # - str.to_s - => "123" - -### ABI check - - @libc = Fiddle.dlopen "/lib/libc.so.6" - #=> # - f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP) - #=> # - f.abi == Fiddle::Function::DEFAULT - #=> true - - -# Attributes -## abi[RW] [](#attribute-i-abi) -The ABI of the Function. - -## name[RW] [](#attribute-i-name) -The name of this function - -## ptr[RW] [](#attribute-i-ptr) -The address of this function - - -#Instance Methods -## call(*args, &block) [](#method-i-call) -Calls the constructed Function, with `args`. Caller must ensure the underlying -function is called in a thread-safe manner if running in a multi-threaded -process. - -Note that it is not thread-safe to use this method to directly or indirectly -call many Ruby C-extension APIs unless you don't pass +need_gvl: true+ to -Fiddle::Function#new. - -For an example see Fiddle::Function - -## initialize(ptr, args, return_type, abiDEFAULT, kwargsnil) [](#method-i-initialize) -Constructs a Function object. -* `ptr` is a referenced function, of a Fiddle::Handle -* `args` is an Array of arguments, passed to the `ptr` function -* `ret_type` is the return type of the function -* `abi` is the ABI of the function -* `name` is the name of the function -* `need_gvl` is whether GVL is needed to call the function - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@return** [Function] a new instance of Function - -## need_gvl?() [](#method-i-need_gvl?) -Whether GVL is needed to call this function - -**@return** [Boolean] - -## to_i() [](#method-i-to_i) -The integer memory location of this function - -## to_proc() [](#method-i-to_proc) -Turn this function in to a proc - diff --git a/example/ruby/Fiddle/Handle.md b/example/ruby/Fiddle/Handle.md deleted file mode 100644 index 98669c8..0000000 --- a/example/ruby/Fiddle/Handle.md +++ /dev/null @@ -1,133 +0,0 @@ -# Class: Fiddle::Handle -**Inherits:** Object - - -The Fiddle::Handle is the manner to access the dynamic library - -## Example - -### Setup - - libc_so = "/lib64/libc.so.6" - => "/lib64/libc.so.6" - @handle = Fiddle::Handle.new(libc_so) - => # - -### Setup, with flags - - libc_so = "/lib64/libc.so.6" - => "/lib64/libc.so.6" - @handle = Fiddle::Handle.new(libc_so, Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL) - => # - -See RTLD_LAZY and RTLD_GLOBAL - -### Addresses to symbols - - strcpy_addr = @handle['strcpy'] - => 140062278451968 - -or - - strcpy_addr = @handle.sym('strcpy') - => 140062278451968 - - -# Class Methods -## [](func ) [](#method-c-[]) -call-seq: sym(name) - -Get the address as an Integer for the function named `name`. The function is -searched via dlsym on RTLD_NEXT. - -See man(3) dlsym() for more info. -## sym(func ) [](#method-c-sym) -call-seq: sym(name) - -Get the address as an Integer for the function named `name`. The function is -searched via dlsym on RTLD_NEXT. - -See man(3) dlsym() for more info. -## sym_defined?(func ) [](#method-c-sym_defined?) -**@return** [Boolean] - - -#Instance Methods -## [](func) [](#method-i-[]) -call-seq: sym(name) - -Get the address as an Integer for the function named `name`. - -## close() [](#method-i-close) -Close this handle. - -Calling close more than once will raise a Fiddle::DLError exception. - -**@overload** [] - -**@raise** [DLError] - -## close_enabled?() [](#method-i-close_enabled?) -Returns `true` if dlclose() will be called when this handle is garbage -collected. - -See man(3) dlclose() for more info. - -**@overload** [] - -**@return** [Boolean] - -## disable_close() [](#method-i-disable_close) -Disable a call to dlclose() when this handle is garbage collected. - -**@overload** [] - -## enable_close() [](#method-i-enable_close) -Enable a call to dlclose() when this handle is garbage collected. - -**@overload** [] - -## file_name() [](#method-i-file_name) -Returns the file name of this handle. - -**@overload** [] - -## initialize(libnamenil, flagsRTLD_LAZY | RTLD_GLOBAL) [](#method-i-initialize) -Create a new handler that opens `library` with `flags`. - -If no `library` is specified or `nil` is given, DEFAULT is used, which is the -equivalent to RTLD_DEFAULT. See `man 3 dlopen` for more. - -lib = Fiddle::Handle.new - -The default is dependent on OS, and provide a handle for all libraries already -loaded. For example, in most cases you can use this to access `libc` -functions, or ruby functions like `rb_str_new`. - -**@overload** [] - -**@return** [Handle] a new instance of Handle - -## sym(func) [](#method-i-sym) -call-seq: sym(name) - -Get the address as an Integer for the function named `name`. - -**@raise** [TypeError] - -## sym_defined?(func) [](#method-i-sym_defined?) - -**@raise** [TypeError] - -**@return** [Boolean] - -## to_i() [](#method-i-to_i) -Returns the memory address for this handle. - -**@overload** [] - -## to_ptr() [](#method-i-to_ptr) -Returns the Fiddle::Pointer of this handle. - -**@overload** [] - diff --git a/example/ruby/Fiddle/Importer.md b/example/ruby/Fiddle/Importer.md deleted file mode 100644 index 4043b6f..0000000 --- a/example/ruby/Fiddle/Importer.md +++ /dev/null @@ -1,304 +0,0 @@ -# Module: Fiddle::Importer - -**Extended by:** Fiddle::Importer - -**Includes:** Fiddle, Fiddle::CParser - - -A DSL that provides the means to dynamically load libraries and build modules -around them including calling extern functions within the C library that has -been loaded. - -## Example - - require 'fiddle' - require 'fiddle/import' - - module LibSum - extend Fiddle::Importer - dlload './libsum.so' - extern 'double sum(double*, int)' - extern 'double split(double)' - end - - -# Class Methods -## [](name ) [](#method-c-[]) -Returns the function mapped to `name`, that was created by either -Fiddle::Importer.extern or Fiddle::Importer.bind -## bind(signature , *opts , &blk ) [](#method-c-bind) -Creates a global method from the given C `signature` using the given `opts` as -bind parameters with the given block. -## bind_function(name , ctype , argtype , call_type nil, &block ) [](#method-c-bind_function) -Returns a new closure wrapper for the `name` function. - -* `ctype` is the return type of the function -* `argtype` is an Array of arguments, passed to the callback function -* `call_type` is the abi of the closure -* `block` is passed to the callback - -See Fiddle::Closure -## create_value(ty , val nil) [](#method-c-create_value) -Creates a class to wrap the C struct with the value `ty` - -See also Fiddle::Importer.struct -## dlload(*libs ) [](#method-c-dlload) -Creates an array of handlers for the given `libs`, can be an instance of -Fiddle::Handle, Fiddle::Importer, or will create a new instance of -Fiddle::Handle using Fiddle.dlopen - -Raises a DLError if the library cannot be loaded. - -See Fiddle.dlopen -## extern(signature , *opts ) [](#method-c-extern) -Creates a global method from the given C `signature`. -## handler() [](#method-c-handler) -The Fiddle::CompositeHandler instance - -Will raise an error if no handlers are open. -## import_function(name , ctype , argtype , call_type nil) [](#method-c-import_function) -Returns a new Fiddle::Function instance at the memory address of the given -`name` function. - -Raises a DLError if the `name` doesn't exist. - -* `argtype` is an Array of arguments, passed to the `name` function. -* `ctype` is the return type of the function -* `call_type` is the ABI of the function - -See also Fiddle:Function.new - -See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym -## import_symbol(name ) [](#method-c-import_symbol) -Returns a new Fiddle::Pointer instance at the memory address of the given -`name` symbol. - -Raises a DLError if the `name` doesn't exist. - -See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym -## import_value(ty , addr ) [](#method-c-import_value) -Returns a new instance of the C struct with the value `ty` at the `addr` -address. -## parse_ctype(ty , tymap nil) [](#method-c-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP -## parse_signature(signature , tymap nil) [](#method-c-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] -## parse_struct_signature(signature , tymap nil) [](#method-c-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] -## sizeof(ty ) [](#method-c-sizeof) -Returns the sizeof `ty`, using Fiddle::Importer.parse_ctype to determine the C -type and the appropriate Fiddle constant. -## struct(signature ) [](#method-c-struct) -Creates a class to wrap the C struct described by `signature`. - - MyStruct = struct ['int i', 'char c'] -## typealias(alias_type , orig_type ) [](#method-c-typealias) -Sets the type alias for `alias_type` as `orig_type` -## union(signature ) [](#method-c-union) -Creates a class to wrap the C union described by `signature`. - - MyUnion = union ['int i', 'char c'] - -#Instance Methods -## [](name) [](#method-i-[]) -Returns the function mapped to `name`, that was created by either -Fiddle::Importer.extern or Fiddle::Importer.bind - -## bind(signature, *opts, &blk) [](#method-i-bind) -Creates a global method from the given C `signature` using the given `opts` as -bind parameters with the given block. - -## bind_function(name, ctype, argtype, call_typenil, &block) [](#method-i-bind_function) -Returns a new closure wrapper for the `name` function. - -* `ctype` is the return type of the function -* `argtype` is an Array of arguments, passed to the callback function -* `call_type` is the abi of the closure -* `block` is passed to the callback - -See Fiddle::Closure - -## create_value(ty, valnil) [](#method-i-create_value) -Creates a class to wrap the C struct with the value `ty` - -See also Fiddle::Importer.struct - -## dlload(*libs) [](#method-i-dlload) -Creates an array of handlers for the given `libs`, can be an instance of -Fiddle::Handle, Fiddle::Importer, or will create a new instance of -Fiddle::Handle using Fiddle.dlopen - -Raises a DLError if the library cannot be loaded. - -See Fiddle.dlopen - -## extern(signature, *opts) [](#method-i-extern) -Creates a global method from the given C `signature`. - -## handler() [](#method-i-handler) -The Fiddle::CompositeHandler instance - -Will raise an error if no handlers are open. - -## import_function(name, ctype, argtype, call_typenil) [](#method-i-import_function) -Returns a new Fiddle::Function instance at the memory address of the given -`name` function. - -Raises a DLError if the `name` doesn't exist. - -* `argtype` is an Array of arguments, passed to the `name` function. -* `ctype` is the return type of the function -* `call_type` is the ABI of the function - -See also Fiddle:Function.new - -See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym - -## import_symbol(name) [](#method-i-import_symbol) -Returns a new Fiddle::Pointer instance at the memory address of the given -`name` symbol. - -Raises a DLError if the `name` doesn't exist. - -See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym - -## import_value(ty, addr) [](#method-i-import_value) -Returns a new instance of the C struct with the value `ty` at the `addr` -address. - -## parse_ctype(ty, tymapnil) [](#method-i-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP - -## parse_signature(signature, tymapnil) [](#method-i-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] - -## parse_struct_signature(signature, tymapnil) [](#method-i-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] - -## sizeof(ty) [](#method-i-sizeof) -Returns the sizeof `ty`, using Fiddle::Importer.parse_ctype to determine the C -type and the appropriate Fiddle constant. - -## struct(signature) [](#method-i-struct) -Creates a class to wrap the C struct described by `signature`. - - MyStruct = struct ['int i', 'char c'] - -## typealias(alias_type, orig_type) [](#method-i-typealias) -Sets the type alias for `alias_type` as `orig_type` - -## union(signature) [](#method-i-union) -Creates a class to wrap the C union described by `signature`. - - MyUnion = union ['int i', 'char c'] - diff --git a/example/ruby/Fiddle/LIBC.md b/example/ruby/Fiddle/LIBC.md deleted file mode 100644 index abe2f51..0000000 --- a/example/ruby/Fiddle/LIBC.md +++ /dev/null @@ -1,139 +0,0 @@ -# Module: Fiddle::LIBC - -**Extended by:** Fiddle::Importer - - - - -# Class Methods -## [](name ) [](#method-c-[]) -Returns the function mapped to `name`, that was created by either -Fiddle::Importer.extern or Fiddle::Importer.bind -## bind(signature , *opts , &blk ) [](#method-c-bind) -Creates a global method from the given C `signature` using the given `opts` as -bind parameters with the given block. -## bind_function(name , ctype , argtype , call_type nil, &block ) [](#method-c-bind_function) -Returns a new closure wrapper for the `name` function. - -* `ctype` is the return type of the function -* `argtype` is an Array of arguments, passed to the callback function -* `call_type` is the abi of the closure -* `block` is passed to the callback - -See Fiddle::Closure -## create_value(ty , val nil) [](#method-c-create_value) -Creates a class to wrap the C struct with the value `ty` - -See also Fiddle::Importer.struct -## dlload(*libs ) [](#method-c-dlload) -Creates an array of handlers for the given `libs`, can be an instance of -Fiddle::Handle, Fiddle::Importer, or will create a new instance of -Fiddle::Handle using Fiddle.dlopen - -Raises a DLError if the library cannot be loaded. - -See Fiddle.dlopen -## extern(signature , *opts ) [](#method-c-extern) -Creates a global method from the given C `signature`. -## handler() [](#method-c-handler) -The Fiddle::CompositeHandler instance - -Will raise an error if no handlers are open. -## import_function(name , ctype , argtype , call_type nil) [](#method-c-import_function) -Returns a new Fiddle::Function instance at the memory address of the given -`name` function. - -Raises a DLError if the `name` doesn't exist. - -* `argtype` is an Array of arguments, passed to the `name` function. -* `ctype` is the return type of the function -* `call_type` is the ABI of the function - -See also Fiddle:Function.new - -See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym -## import_symbol(name ) [](#method-c-import_symbol) -Returns a new Fiddle::Pointer instance at the memory address of the given -`name` symbol. - -Raises a DLError if the `name` doesn't exist. - -See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym -## import_value(ty , addr ) [](#method-c-import_value) -Returns a new instance of the C struct with the value `ty` at the `addr` -address. -## parse_ctype(ty , tymap nil) [](#method-c-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP -## parse_signature(signature , tymap nil) [](#method-c-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] -## parse_struct_signature(signature , tymap nil) [](#method-c-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] -## sizeof(ty ) [](#method-c-sizeof) -Returns the sizeof `ty`, using Fiddle::Importer.parse_ctype to determine the C -type and the appropriate Fiddle constant. -## struct(signature ) [](#method-c-struct) -Creates a class to wrap the C struct described by `signature`. - - MyStruct = struct ['int i', 'char c'] -## typealias(alias_type , orig_type ) [](#method-c-typealias) -Sets the type alias for `alias_type` as `orig_type` -## union(signature ) [](#method-c-union) -Creates a class to wrap the C union described by `signature`. - - MyUnion = union ['int i', 'char c'] - diff --git a/example/ruby/Fiddle/MemoryView.md b/example/ruby/Fiddle/MemoryView.md deleted file mode 100644 index 044cbf5..0000000 --- a/example/ruby/Fiddle/MemoryView.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Fiddle::MemoryView -**Inherits:** Object - - - - -# Class Methods -## export(target ) [](#method-c-export) - -#Instance Methods -## [](*args) [](#method-i-[]) - -## byte_size() [](#method-i-byte_size) - -## format() [](#method-i-format) - -## initialize(target) [](#method-i-initialize) - -## item_size() [](#method-i-item_size) - -## ndim() [](#method-i-ndim) - -## obj() [](#method-i-obj) - -## readonly?() [](#method-i-readonly?) - -**@return** [Boolean] - -## release() [](#method-i-release) - -## shape() [](#method-i-shape) - -## strides() [](#method-i-strides) - -## sub_offsets() [](#method-i-sub_offsets) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Fiddle/PackInfo.md b/example/ruby/Fiddle/PackInfo.md deleted file mode 100644 index d09da55..0000000 --- a/example/ruby/Fiddle/PackInfo.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Fiddle::PackInfo - - -:nodoc: all - - -# Class Methods -## align(addr , align ) [](#method-c-align) - diff --git a/example/ruby/Fiddle/Packer.md b/example/ruby/Fiddle/Packer.md deleted file mode 100644 index 05853d5..0000000 --- a/example/ruby/Fiddle/Packer.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Fiddle::Packer -**Inherits:** Object - -**Includes:** Fiddle::PackInfo - - -:nodoc: all - - -# Class Methods -## [](*types ) [](#method-c-[]) - -#Instance Methods -## initialize(types) [](#method-i-initialize) - -**@return** [Packer] a new instance of Packer - -## pack(ary) [](#method-i-pack) - -## size() [](#method-i-size) - -## unpack(ary) [](#method-i-unpack) - diff --git a/example/ruby/Fiddle/Pinned.md b/example/ruby/Fiddle/Pinned.md deleted file mode 100644 index e971966..0000000 --- a/example/ruby/Fiddle/Pinned.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Fiddle::Pinned -**Inherits:** Object - - - - - -#Instance Methods -## clear() [](#method-i-clear) -Clear the reference to the object this is pinning. - -**@overload** [] - -## cleared?() [](#method-i-cleared?) -Returns true if the reference has been cleared, otherwise returns false. - -**@overload** [] - -**@return** [Boolean] - -## initialize(object) [](#method-i-initialize) -Create a new pinned object reference. The Fiddle::Pinned instance will -prevent the GC from moving `object`. - -**@overload** [] - -**@return** [Pinned] a new instance of Pinned - -## ref() [](#method-i-ref) -Return the object that this pinned instance references. - -**@overload** [] - diff --git a/example/ruby/Fiddle/Pointer.md b/example/ruby/Fiddle/Pointer.md deleted file mode 100644 index 7043fab..0000000 --- a/example/ruby/Fiddle/Pointer.md +++ /dev/null @@ -1,261 +0,0 @@ -# Class: Fiddle::Pointer -**Inherits:** Object - -**Extended by:** FFI::DataConverter - - -Fiddle::Pointer is a class to handle C pointers - - -# Class Methods -## [](val ) [](#method-c-[]) -Get the underlying pointer for ruby object `val` and return it as a -Fiddle::Pointer object. -**@overload** [] - -**@overload** [] - -## from_native(value , ctx ) [](#method-c-from_native) -## malloc(size , free nil) [](#method-c-malloc) -## Examples - - # Automatically freeing the pointer when the block is exited - recommended - Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) do |pointer| - ... - end - - # Manually freeing but relying on the garbage collector otherwise - pointer = Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) - ... - pointer.call_free - - # Relying on the garbage collector - may lead to unlimited memory allocated before freeing any, but safe - pointer = Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) - ... - - # Only manually freeing - pointer = Fiddle::Pointer.malloc(size) - begin - ... - ensure - Fiddle.free pointer - end - - # No free function and no call to free - the native memory will leak if the pointer is garbage collected - pointer = Fiddle::Pointer.malloc(size) - ... - -Allocate `size` bytes of memory and associate it with an optional `freefunc`. - -If a block is supplied, the pointer will be yielded to the block instead of -being returned, and the return value of the block will be returned. A -`freefunc` must be supplied if a block is. - -If a `freefunc` is supplied it will be called once, when the pointer is -garbage collected or when the block is left if a block is supplied or when the -user calls `call_free`, whichever happens first. `freefunc` must be an address -pointing to a function or an instance of `Fiddle::Function`. -**@overload** [] - -**@overload** [] - -## read(addr , len ) [](#method-c-read) -Or read the memory at address `address` with length `len` and return a string -with that memory -**@overload** [] - -## to_native(value , ctx ) [](#method-c-to_native) -## to_ptr(value ) [](#method-c-to_ptr) -Get the underlying pointer for ruby object `val` and return it as a -Fiddle::Pointer object. -**@overload** [] - -**@overload** [] - -## write(addr , bytes ) [](#method-c-write) -Write bytes in `str` to the location pointed to by `address`. -**@overload** [] - -# Attributes -## ffi_ptr[RW] [](#attribute-i-ffi_ptr) -Returns the value of attribute ffi_ptr. - - -#Instance Methods -## +(delta) [](#method-i-+) -Returns a new pointer instance that has been advanced `n` bytes. - -**@overload** [] - -## +@() [](#method-i-+@) -Returns a new Fiddle::Pointer instance that is a dereferenced pointer for this -pointer. - -Analogous to the star operator in C. - -**@overload** [] - -## -(delta) [](#method-i--) -Returns a new pointer instance that has been moved back `n` bytes. - -**@overload** [] - -## -@() [](#method-i--@) -Returns a new Fiddle::Pointer instance that is a reference pointer for this -pointer. - -Analogous to the ampersand operator in C. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Returns -1 if less than, 0 if equal to, 1 if greater than `other`. - -Returns nil if `ptr` cannot be compared to `other`. - -**@overload** [] - -## ==(other) [](#method-i-==) -Returns true if `other` wraps the same pointer, otherwise returns false. - -**@overload** [] - -**@overload** [] - -## [](index, lengthnil) [](#method-i-[]) -Returns integer stored at *index*. - -If *start* and *length* are given, a string containing the bytes from *start* -of *length* will be returned. - -**@overload** [] - -**@overload** [] - -## []=(*args, value) [](#method-i-[]=) -Set the value at `index` to `int`. - -Or, set the memory at `start` until `length` with the contents of `string`, -the memory from `dl_cptr`, or the memory pointed at by the memory address -`addr`. - -**@overload** [] - -**@overload** [] - -## call_free() [](#method-i-call_free) -Call the free function for this pointer. Calling more than once will do -nothing. Does nothing if there is no free function attached. - -**@overload** [] - -## eql?(other) [](#method-i-eql?) -Returns true if `other` wraps the same pointer, otherwise returns false. - -**@overload** [] - -**@overload** [] - -## free() [](#method-i-free) -Get the free function for this pointer. - -Returns a new instance of Fiddle::Function. - -See Fiddle::Function.new - -**@overload** [] - -## free=(free) [](#method-i-free=) -Set the free function for this pointer to `function` in the given -Fiddle::Function. - -**@overload** [] - -## freed?() [](#method-i-freed?) -Returns if the free function for this pointer has been called. - -**@overload** [] - -## initialize(addr, sizenil, freenil) [](#method-i-initialize) -Create a new pointer to `address` with an optional `size` and `freefunc`. - -`freefunc` will be called when the instance is garbage collected. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@return** [Pointer] a new instance of Pointer - -## inspect() [](#method-i-inspect) -Returns a string formatted with an easily readable representation of the -internal state of the pointer. - -**@overload** [] - -## null?() [](#method-i-null?) -Returns `true` if this is a null pointer. - -**@overload** [] - -**@return** [Boolean] - -## ptr() [](#method-i-ptr) -Returns a new Fiddle::Pointer instance that is a dereferenced pointer for this -pointer. - -Analogous to the star operator in C. - -**@overload** [] - -## ref() [](#method-i-ref) -Returns a new Fiddle::Pointer instance that is a reference pointer for this -pointer. - -Analogous to the ampersand operator in C. - -**@overload** [] - -## size() [](#method-i-size) -Get the size of this pointer. - -**@overload** [] - -## size=(size) [](#method-i-size=) -Set the size of this pointer to `size` - -**@overload** [] - -## to_i() [](#method-i-to_i) -Returns the integer memory location of this pointer. - -**@overload** [] - -## to_ptr() [](#method-i-to_ptr) - -## to_s(lennil) [](#method-i-to_s) -without 0 - -## to_str(lennil) [](#method-i-to_str) -Returns the pointer contents as a string. - -When called with no arguments, this method will return the contents with the -length of this pointer's `size`. - -When called with `len`, a string of `len` bytes will be returned. - -See to_s - -**@overload** [] - -**@overload** [] - -## to_value() [](#method-i-to_value) -Cast this pointer to a ruby object. - -**@overload** [] - -**@raise** [NotImplementedError] - diff --git a/example/ruby/Fiddle/Pointer/LibC.md b/example/ruby/Fiddle/Pointer/LibC.md deleted file mode 100644 index a87d5f7..0000000 --- a/example/ruby/Fiddle/Pointer/LibC.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: Fiddle::Pointer::LibC - -**Extended by:** FFI::Library - - - - - diff --git a/example/ruby/Fiddle/StructArray.md b/example/ruby/Fiddle/StructArray.md deleted file mode 100644 index acd9e87..0000000 --- a/example/ruby/Fiddle/StructArray.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Fiddle::StructArray -**Inherits:** Array - -**Includes:** Fiddle::ValueUtil - - -Wrapper for arrays within a struct - - - -#Instance Methods -## []=(index, value) [](#method-i-[]=) - -## initialize(ptr, type, initial_values) [](#method-i-initialize) - -**@return** [StructArray] a new instance of StructArray - -## signed_value(val, ty) [](#method-i-signed_value) - -## to_ptr() [](#method-i-to_ptr) - -## unsigned_value(val, ty) [](#method-i-unsigned_value) - -## wrap_arg(arg, ty, funcs[], &block) [](#method-i-wrap_arg) - -## wrap_args(args, tys, funcs, &block) [](#method-i-wrap_args) - diff --git a/example/ruby/Fiddle/TestCParser.md b/example/ruby/Fiddle/TestCParser.md deleted file mode 100644 index 511abb8..0000000 --- a/example/ruby/Fiddle/TestCParser.md +++ /dev/null @@ -1,156 +0,0 @@ -# Class: Fiddle::TestCParser -**Inherits:** Fiddle::TestCase - -**Includes:** Fiddle::CParser - - - - - -#Instance Methods -## expand_struct_types(types) [](#method-i-expand_struct_types) - -## parse_ctype(ty, tymapnil) [](#method-i-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP - -## parse_signature(signature, tymapnil) [](#method-i-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] - -## parse_struct_signature(signature, tymapnil) [](#method-i-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] - -## test_bool_ctype() [](#method-i-test_bool_ctype) - -## test_char_ctype() [](#method-i-test_char_ctype) - -## test_int_ctype() [](#method-i-test_int_ctype) - -## test_intptr_t_ctype() [](#method-i-test_intptr_t_ctype) - -## test_long_ctype() [](#method-i-test_long_ctype) - -## test_ptrdiff_t_ctype() [](#method-i-test_ptrdiff_t_ctype) - -## test_short_ctype() [](#method-i-test_short_ctype) - -## test_signature_array_variable() [](#method-i-test_signature_array_variable) - -## test_signature_basic() [](#method-i-test_signature_basic) - -## test_signature_function_pointer() [](#method-i-test_signature_function_pointer) - -## test_signature_multiple_variables() [](#method-i-test_signature_multiple_variables) - -## test_signature_return_array() [](#method-i-test_signature_return_array) - -## test_signature_return_array_with_args() [](#method-i-test_signature_return_array_with_args) - -## test_signature_return_function_pointer() [](#method-i-test_signature_return_function_pointer) - -## test_signature_return_function_pointer_with_args() [](#method-i-test_signature_return_function_pointer_with_args) - -## test_signature_return_pointer() [](#method-i-test_signature_return_pointer) - -## test_signature_semi() [](#method-i-test_signature_semi) - -## test_signature_single_variable() [](#method-i-test_signature_single_variable) - -## test_signature_type_args() [](#method-i-test_signature_type_args) - -## test_signature_variadic_arguments() [](#method-i-test_signature_variadic_arguments) - -## test_signature_void_arg() [](#method-i-test_signature_void_arg) - -## test_size_t_ctype() [](#method-i-test_size_t_ctype) - -## test_ssize_t_ctype() [](#method-i-test_ssize_t_ctype) - -## test_struct_array() [](#method-i-test_struct_array) - -## test_struct_array_str() [](#method-i-test_struct_array_str) - -## test_struct_basic() [](#method-i-test_struct_basic) - -## test_struct_double_nested_struct() [](#method-i-test_struct_double_nested_struct) - -## test_struct_double_nested_struct_inner_array() [](#method-i-test_struct_double_nested_struct_inner_array) - -## test_struct_double_nested_struct_outer_array() [](#method-i-test_struct_double_nested_struct_outer_array) - -## test_struct_function_pointer() [](#method-i-test_struct_function_pointer) - -## test_struct_function_pointer_str() [](#method-i-test_struct_function_pointer_str) - -## test_struct_nested_defined_struct() [](#method-i-test_struct_nested_defined_struct) - -## test_struct_nested_struct() [](#method-i-test_struct_nested_struct) - -## test_struct_nested_struct_array() [](#method-i-test_struct_nested_struct_array) - -## test_struct_string() [](#method-i-test_struct_string) - -## test_struct_undefined() [](#method-i-test_struct_undefined) - -## test_struct_undefined_with_type_alias() [](#method-i-test_struct_undefined_with_type_alias) - -## test_uintptr_t_ctype() [](#method-i-test_uintptr_t_ctype) - -## test_undefined_ctype() [](#method-i-test_undefined_ctype) - -## test_undefined_ctype_with_type_alias() [](#method-i-test_undefined_ctype_with_type_alias) - diff --git a/example/ruby/Fiddle/TestCStructBuilder.md b/example/ruby/Fiddle/TestCStructBuilder.md deleted file mode 100644 index 80b5979..0000000 --- a/example/ruby/Fiddle/TestCStructBuilder.md +++ /dev/null @@ -1,219 +0,0 @@ -# Class: Fiddle::TestCStructBuilder -**Inherits:** Fiddle::TestCase - -**Extended by:** Fiddle::Importer - -**Includes:** Fiddle::CParser - - - - -# Class Methods -## [](name ) [](#method-c-[]) -Returns the function mapped to `name`, that was created by either -Fiddle::Importer.extern or Fiddle::Importer.bind -## bind(signature , *opts , &blk ) [](#method-c-bind) -Creates a global method from the given C `signature` using the given `opts` as -bind parameters with the given block. -## bind_function(name , ctype , argtype , call_type nil, &block ) [](#method-c-bind_function) -Returns a new closure wrapper for the `name` function. - -* `ctype` is the return type of the function -* `argtype` is an Array of arguments, passed to the callback function -* `call_type` is the abi of the closure -* `block` is passed to the callback - -See Fiddle::Closure -## create_value(ty , val nil) [](#method-c-create_value) -Creates a class to wrap the C struct with the value `ty` - -See also Fiddle::Importer.struct -## dlload(*libs ) [](#method-c-dlload) -Creates an array of handlers for the given `libs`, can be an instance of -Fiddle::Handle, Fiddle::Importer, or will create a new instance of -Fiddle::Handle using Fiddle.dlopen - -Raises a DLError if the library cannot be loaded. - -See Fiddle.dlopen -## extern(signature , *opts ) [](#method-c-extern) -Creates a global method from the given C `signature`. -## handler() [](#method-c-handler) -The Fiddle::CompositeHandler instance - -Will raise an error if no handlers are open. -## import_function(name , ctype , argtype , call_type nil) [](#method-c-import_function) -Returns a new Fiddle::Function instance at the memory address of the given -`name` function. - -Raises a DLError if the `name` doesn't exist. - -* `argtype` is an Array of arguments, passed to the `name` function. -* `ctype` is the return type of the function -* `call_type` is the ABI of the function - -See also Fiddle:Function.new - -See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym -## import_symbol(name ) [](#method-c-import_symbol) -Returns a new Fiddle::Pointer instance at the memory address of the given -`name` symbol. - -Raises a DLError if the `name` doesn't exist. - -See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym -## import_value(ty , addr ) [](#method-c-import_value) -Returns a new instance of the C struct with the value `ty` at the `addr` -address. -## parse_ctype(ty , tymap nil) [](#method-c-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP -## parse_signature(signature , tymap nil) [](#method-c-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] -## parse_struct_signature(signature , tymap nil) [](#method-c-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] -## sizeof(ty ) [](#method-c-sizeof) -Returns the sizeof `ty`, using Fiddle::Importer.parse_ctype to determine the C -type and the appropriate Fiddle constant. -## struct(signature ) [](#method-c-struct) -Creates a class to wrap the C struct described by `signature`. - - MyStruct = struct ['int i', 'char c'] -## typealias(alias_type , orig_type ) [](#method-c-typealias) -Sets the type alias for `alias_type` as `orig_type` -## union(signature ) [](#method-c-union) -Creates a class to wrap the C union described by `signature`. - - MyUnion = union ['int i', 'char c'] - -#Instance Methods -## parse_ctype(ty, tymapnil) [](#method-i-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP - -## parse_signature(signature, tymapnil) [](#method-i-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] - -## parse_struct_signature(signature, tymapnil) [](#method-i-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] - -## test_as_ary() [](#method-i-test_as_ary) - -## test_basic_embedded_members() [](#method-i-test_basic_embedded_members) - -## test_embedded_union_members() [](#method-i-test_embedded_union_members) - -## test_offset_with_gap() [](#method-i-test_offset_with_gap) - -## test_offsetof() [](#method-i-test_offsetof) - -## test_union_offsetof() [](#method-i-test_union_offsetof) - diff --git a/example/ruby/Fiddle/TestCStructEntity.md b/example/ruby/Fiddle/TestCStructEntity.md deleted file mode 100644 index 99f21f2..0000000 --- a/example/ruby/Fiddle/TestCStructEntity.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Fiddle::TestCStructEntity -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## test_aref_pointer() [](#method-i-test_aref_pointer) - -## test_aref_pointer_array() [](#method-i-test_aref_pointer_array) - -## test_class_size() [](#method-i-test_class_size) - -## test_class_size_with_count() [](#method-i-test_class_size_with_count) - -## test_free() [](#method-i-test_free) - -## test_free_with_func() [](#method-i-test_free_with_func) - -## test_free_with_no_func() [](#method-i-test_free_with_no_func) - -## test_freed?() [](#method-i-test_freed?) - -**@return** [Boolean] - -## test_malloc_block() [](#method-i-test_malloc_block) - -## test_malloc_block_no_free() [](#method-i-test_malloc_block_no_free) - -## test_new_double_free() [](#method-i-test_new_double_free) - -## test_null?() [](#method-i-test_null?) - -**@return** [Boolean] - -## test_set_ctypes() [](#method-i-test_set_ctypes) - -## test_size() [](#method-i-test_size) - -## test_size=() [](#method-i-test_size=) - diff --git a/example/ruby/Fiddle/TestCUnionEntity.md b/example/ruby/Fiddle/TestCUnionEntity.md deleted file mode 100644 index ad77c5f..0000000 --- a/example/ruby/Fiddle/TestCUnionEntity.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Fiddle::TestCUnionEntity -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## test_class_size() [](#method-i-test_class_size) - -## test_class_size_with_count() [](#method-i-test_class_size_with_count) - -## test_set_ctypes() [](#method-i-test_set_ctypes) - diff --git a/example/ruby/Fiddle/TestCase.md b/example/ruby/Fiddle/TestCase.md deleted file mode 100644 index fc15658..0000000 --- a/example/ruby/Fiddle/TestCase.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Fiddle::TestCase -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_ractor_shareable(object) [](#method-i-assert_ractor_shareable) - -## ffi_backend?() [](#method-i-ffi_backend?) - -**@return** [Boolean] - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## under_gc_stress() [](#method-i-under_gc_stress) - diff --git a/example/ruby/Fiddle/TestClosure.md b/example/ruby/Fiddle/TestClosure.md deleted file mode 100644 index 2596639..0000000 --- a/example/ruby/Fiddle/TestClosure.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Fiddle::TestClosure -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## teardown() [](#method-i-teardown) - -## test_argument_errors() [](#method-i-test_argument_errors) - -## test_block_caller() [](#method-i-test_block_caller) - -## test_bool() [](#method-i-test_bool) - -## test_call() [](#method-i-test_call) - -## test_const_string() [](#method-i-test_const_string) - -## test_free() [](#method-i-test_free) - -## test_memsize_ruby_dev_42480() [](#method-i-test_memsize_ruby_dev_42480) - -## test_ractor_shareable() [](#method-i-test_ractor_shareable) - -## test_returner() [](#method-i-test_returner) - diff --git a/example/ruby/Fiddle/TestFunc.md b/example/ruby/Fiddle/TestFunc.md deleted file mode 100644 index 9a6c6ba..0000000 --- a/example/ruby/Fiddle/TestFunc.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Fiddle::TestFunc -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## test_atof() [](#method-i-test_atof) - -## test_isdigit() [](#method-i-test_isdigit) - -## test_qsort1() [](#method-i-test_qsort1) - -## test_random() [](#method-i-test_random) - -## test_rb_memory_view_available_p() [](#method-i-test_rb_memory_view_available_p) - -## test_sin() [](#method-i-test_sin) - -## test_sinf() [](#method-i-test_sinf) - -## test_snprintf() [](#method-i-test_snprintf) - -## test_string() [](#method-i-test_string) - -## test_strtod() [](#method-i-test_strtod) - diff --git a/example/ruby/Fiddle/TestFunction.md b/example/ruby/Fiddle/TestFunction.md deleted file mode 100644 index 5c50011..0000000 --- a/example/ruby/Fiddle/TestFunction.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: Fiddle::TestFunction -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## call_proc(string_to_copy) [](#method-i-call_proc) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_argument_count() [](#method-i-test_argument_count) - -## test_argument_errors() [](#method-i-test_argument_errors) - -## test_argument_type_conversion() [](#method-i-test_argument_type_conversion) - -## test_call() [](#method-i-test_call) - -## test_default_abi() [](#method-i-test_default_abi) - -## test_function_as_method() [](#method-i-test_function_as_method) - -## test_function_as_proc() [](#method-i-test_function_as_proc) - -## test_integer_pointer_conversion() [](#method-i-test_integer_pointer_conversion) - -## test_last_error() [](#method-i-test_last_error) - -## test_name() [](#method-i-test_name) - -## test_name_symbol() [](#method-i-test_name_symbol) - -## test_need_gvl?() [](#method-i-test_need_gvl?) - -**@return** [Boolean] - -## test_no_memory_leak() [](#method-i-test_no_memory_leak) - -## test_nogvl_poll() [](#method-i-test_nogvl_poll) - -## test_ractor_shareable() [](#method-i-test_ractor_shareable) - -## test_ractor_shareable_name() [](#method-i-test_ractor_shareable_name) - -## test_ractor_shareable_name_symbol() [](#method-i-test_ractor_shareable_name_symbol) - -## test_strcpy() [](#method-i-test_strcpy) - -## test_win32_last_error() [](#method-i-test_win32_last_error) - -## test_win32_last_socket_error() [](#method-i-test_win32_last_socket_error) - diff --git a/example/ruby/Fiddle/TestHandle.md b/example/ruby/Fiddle/TestHandle.md deleted file mode 100644 index 1178732..0000000 --- a/example/ruby/Fiddle/TestHandle.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: Fiddle::TestHandle -**Inherits:** Fiddle::TestCase - -**Includes:** Fiddle - - - - - -#Instance Methods -## test_DEFAULT() [](#method-i-test_DEFAULT) - -## test_NEXT() [](#method-i-test_NEXT) - -## test_disable_close() [](#method-i-test_disable_close) - -## test_dlerror() [](#method-i-test_dlerror) - -## test_dlopen_returns_handle() [](#method-i-test_dlopen_returns_handle) - -## test_enable_close() [](#method-i-test_enable_close) - -## test_fallback_to_ansi() [](#method-i-test_fallback_to_ansi) - -## test_file_name() [](#method-i-test_file_name) - -## test_handle_close() [](#method-i-test_handle_close) - -## test_handle_close_twice() [](#method-i-test_handle_close_twice) - -## test_initialize_flags() [](#method-i-test_initialize_flags) - -## test_initialize_noargs() [](#method-i-test_initialize_noargs) - -## test_library_unavailable() [](#method-i-test_library_unavailable) - -## test_ractor_shareable() [](#method-i-test_ractor_shareable) - -## test_static_sym() [](#method-i-test_static_sym) - -## test_static_sym_unknown() [](#method-i-test_static_sym_unknown) - -## test_sym() [](#method-i-test_sym) - -## test_sym_closed_handle() [](#method-i-test_sym_closed_handle) - -## test_sym_unknown() [](#method-i-test_sym_unknown) - -## test_sym_with_bad_args() [](#method-i-test_sym_with_bad_args) - -## test_to_i() [](#method-i-test_to_i) - -## test_to_ptr() [](#method-i-test_to_ptr) - diff --git a/example/ruby/Fiddle/TestImport.md b/example/ruby/Fiddle/TestImport.md deleted file mode 100644 index 2b780fc..0000000 --- a/example/ruby/Fiddle/TestImport.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: Fiddle::TestImport -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## test_atof() [](#method-i-test_atof) - -## test_ensure_call_dlload() [](#method-i-test_ensure_call_dlload) - -## test_gettimeofday() [](#method-i-test_gettimeofday) - -## test_io() [](#method-i-test_io) - -## test_isdigit() [](#method-i-test_isdigit) - -## test_malloc() [](#method-i-test_malloc) - -## test_nested_struct_alignment_is_not_its_size() [](#method-i-test_nested_struct_alignment_is_not_its_size) - -## test_nested_struct_reusing_other_structs() [](#method-i-test_nested_struct_reusing_other_structs) - -## test_sizeof() [](#method-i-test_sizeof) - -## test_strcpy() [](#method-i-test_strcpy) - -## test_struct() [](#method-i-test_struct) - -## test_struct_array_assignment() [](#method-i-test_struct_array_assignment) - -## test_struct_memory_access() [](#method-i-test_struct_memory_access) - -## test_struct_nested_struct_members() [](#method-i-test_struct_nested_struct_members) - -## test_struct_nested_struct_replace_array_element() [](#method-i-test_struct_nested_struct_replace_array_element) - -## test_struct_nested_struct_replace_array_element_hash() [](#method-i-test_struct_nested_struct_replace_array_element_hash) - -## test_struct_nested_struct_replace_array_element_nil() [](#method-i-test_struct_nested_struct_replace_array_element_nil) - -## test_struct_nested_struct_replace_entire_array() [](#method-i-test_struct_nested_struct_replace_entire_array) - -## test_struct_nested_struct_replace_entire_array_with_different_struct() [](#method-i-test_struct_nested_struct_replace_entire_array_with_different_struct) - -## test_struct_ptr_array_subscript_multiarg() [](#method-i-test_struct_ptr_array_subscript_multiarg) - -## test_type_constants() [](#method-i-test_type_constants) - -## test_union_nested_struct_members() [](#method-i-test_union_nested_struct_members) - -## test_unsigned_equals_negative_signed() [](#method-i-test_unsigned_equals_negative_signed) -Assert that the unsigned constants are equal to the "negative" signed ones for -backwards compatibility - -## test_unsigned_result() [](#method-i-test_unsigned_result) - -## test_value() [](#method-i-test_value) - diff --git a/example/ruby/Fiddle/TestMemoryView.md b/example/ruby/Fiddle/TestMemoryView.md deleted file mode 100644 index 898fd51..0000000 --- a/example/ruby/Fiddle/TestMemoryView.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Fiddle::TestMemoryView -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_export() [](#method-i-test_export) - -## test_memory_view_from_pointer() [](#method-i-test_memory_view_from_pointer) - -## test_memory_view_from_unsupported_obj() [](#method-i-test_memory_view_from_unsupported_obj) - -## test_memory_view_multi_dimensional() [](#method-i-test_memory_view_multi_dimensional) - -## test_memory_view_multi_dimensional_with_multiple_members() [](#method-i-test_memory_view_multi_dimensional_with_multiple_members) - -## test_memory_view_multi_dimensional_with_strides() [](#method-i-test_memory_view_multi_dimensional_with_strides) - -## test_null_ptr() [](#method-i-test_null_ptr) - -## test_ractor_shareable() [](#method-i-test_ractor_shareable) - -## test_release() [](#method-i-test_release) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/Fiddle/TestPack.md b/example/ruby/Fiddle/TestPack.md deleted file mode 100644 index 4a73221..0000000 --- a/example/ruby/Fiddle/TestPack.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Fiddle::TestPack -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## test_pack_map() [](#method-i-test_pack_map) - diff --git a/example/ruby/Fiddle/TestPinned.md b/example/ruby/Fiddle/TestPinned.md deleted file mode 100644 index 11a2ed6..0000000 --- a/example/ruby/Fiddle/TestPinned.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Fiddle::TestPinned -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## test_clear() [](#method-i-test_clear) - -## test_pin_object() [](#method-i-test_pin_object) - -## test_ractor_shareable() [](#method-i-test_ractor_shareable) - diff --git a/example/ruby/Fiddle/TestPointer.md b/example/ruby/Fiddle/TestPointer.md deleted file mode 100644 index 0f98e03..0000000 --- a/example/ruby/Fiddle/TestPointer.md +++ /dev/null @@ -1,81 +0,0 @@ -# Class: Fiddle::TestPointer -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## dlwrap(arg) [](#method-i-dlwrap) - -## test_aref_aset() [](#method-i-test_aref_aset) - -## test_can_read_write_memory() [](#method-i-test_can_read_write_memory) - -## test_cmp() [](#method-i-test_cmp) - -## test_cptr_to_int() [](#method-i-test_cptr_to_int) - -## test_equals() [](#method-i-test_equals) - -## test_free() [](#method-i-test_free) - -## test_free=() [](#method-i-test_free=) - -## test_free_with_func() [](#method-i-test_free_with_func) - -## test_free_with_no_func() [](#method-i-test_free_with_no_func) - -## test_freed?() [](#method-i-test_freed?) - -**@return** [Boolean] - -## test_inspect() [](#method-i-test_inspect) - -## test_malloc_block() [](#method-i-test_malloc_block) - -## test_malloc_block_no_free() [](#method-i-test_malloc_block_no_free) - -## test_malloc_free_func() [](#method-i-test_malloc_free_func) - -## test_malloc_free_func_int() [](#method-i-test_malloc_free_func_int) - -## test_malloc_subclass() [](#method-i-test_malloc_subclass) - -## test_minus() [](#method-i-test_minus) - -## test_not_equals() [](#method-i-test_not_equals) - -## test_null?() [](#method-i-test_null?) - -**@return** [Boolean] - -## test_null_pointer() [](#method-i-test_null_pointer) - -## test_plus() [](#method-i-test_plus) -TODO: what if the pointer size is 0? raise an exception? do we care? - -## test_ractor_shareable() [](#method-i-test_ractor_shareable) - -## test_ref_ptr() [](#method-i-test_ref_ptr) - -## test_size() [](#method-i-test_size) - -## test_size=() [](#method-i-test_size=) - -## test_to_ptr_io() [](#method-i-test_to_ptr_io) - -## test_to_ptr_string() [](#method-i-test_to_ptr_string) - -## test_to_ptr_with_int() [](#method-i-test_to_ptr_with_int) - -## test_to_ptr_with_ptr() [](#method-i-test_to_ptr_with_ptr) - -## test_to_ptr_with_to_int() [](#method-i-test_to_ptr_with_to_int) - -## test_to_s() [](#method-i-test_to_s) - -## test_to_str() [](#method-i-test_to_str) - -## test_to_value() [](#method-i-test_to_value) - diff --git a/example/ruby/Fiddle/TestPointer/MimicInteger.md b/example/ruby/Fiddle/TestPointer/MimicInteger.md deleted file mode 100644 index 912950c..0000000 --- a/example/ruby/Fiddle/TestPointer/MimicInteger.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Fiddle::TestPointer::MimicInteger -**Inherits:** Struct - - - - -# Attributes -## to_int[RW] [](#attribute-i-to_int) -Returns the value of attribute to_int - -**@return** [Object] the current value of to_int - - diff --git a/example/ruby/Fiddle/Types.md b/example/ruby/Fiddle/Types.md deleted file mode 100644 index db9f7ff..0000000 --- a/example/ruby/Fiddle/Types.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Fiddle::Types - - - - - diff --git a/example/ruby/Fiddle/ValueUtil.md b/example/ruby/Fiddle/ValueUtil.md deleted file mode 100644 index 6166c28..0000000 --- a/example/ruby/Fiddle/ValueUtil.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: Fiddle::ValueUtil - - -:nodoc: all - - - -#Instance Methods -## signed_value(val, ty) [](#method-i-signed_value) - -## unsigned_value(val, ty) [](#method-i-unsigned_value) - -## wrap_arg(arg, ty, funcs[], &block) [](#method-i-wrap_arg) - -## wrap_args(args, tys, funcs, &block) [](#method-i-wrap_args) - diff --git a/example/ruby/Fiddle/Win32Types.md b/example/ruby/Fiddle/Win32Types.md deleted file mode 100644 index fcd9ba6..0000000 --- a/example/ruby/Fiddle/Win32Types.md +++ /dev/null @@ -1,34 +0,0 @@ -# Module: Fiddle::Win32Types - - -Adds Windows type aliases to the including class for use with -Fiddle::Importer. - -The aliases added are: -* ATOM -* BOOL -* BYTE -* DWORD -* DWORD32 -* DWORD64 -* HANDLE -* HDC -* HINSTANCE -* HWND -* LPCSTR -* LPSTR -* PBYTE -* PDWORD -* PHANDLE -* PVOID -* PWORD -* UCHAR -* UINT -* ULONG -* WORD - - -# Class Methods -## included(m ) [](#method-c-included) -:nodoc: - diff --git a/example/ruby/File.md b/example/ruby/File.md deleted file mode 100644 index f88be96..0000000 --- a/example/ruby/File.md +++ /dev/null @@ -1,833 +0,0 @@ -# Class: File -**Inherits:** IO - - -Used by Makefile and configure for building Ruby. See common.mk and -Makefile.in for details. - - -# Class Methods -## absolute_path(* , _ ) [](#method-c-absolute_path) -Converts a pathname to an absolute pathname. Relative paths are referenced -from the current working directory of the process unless *dir_string* is -given, in which case it will be used as the starting point. If the given -pathname starts with a ```~`'' it is NOT expanded, it is treated as a normal -directory name. - - File.absolute_path("~oracle/bin") #=> "/~oracle/bin" -**@overload** [] - -## absolute_path?(fname ) [](#method-c-absolute_path?) -Returns `true` if `file_name` is an absolute path, and `false` otherwise. - - File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows) -**@overload** [] - -## atime(fname ) [](#method-c-atime) -Returns the last access time for the named file as a Time object. - -*file_name* can be an IO object. - - File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003 -**@overload** [] - -## basename(*args ) [](#method-c-basename) -Returns the last component of the filename given in *file_name* (after first -stripping trailing separators), which can be formed using both File::SEPARATOR -and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not -`nil`. If *suffix* is given and present at the end of *file_name*, it is -removed. If *suffix* is ".*", any extension will be removed. - - File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb" - File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby" - File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby" -**@overload** [] - -## birthtime(fname ) [](#method-c-birthtime) -Returns the birth time for the named file. - -*file_name* can be an IO object. - - File.birthtime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003 - -If the platform doesn't have birthtime, raises NotImplementedError. -**@overload** [] - -## blockdev?(fname ) [](#method-c-blockdev?) -Returns `true` if `filepath` points to a block device, `false` otherwise: - - File.blockdev?('/dev/sda1') # => true - File.blockdev?(File.new('t.tmp')) # => false -**@overload** [] - -## chardev?(fname ) [](#method-c-chardev?) -Returns `true` if `filepath` points to a character device, `false` otherwise. - - File.chardev?($stdin) # => true - File.chardev?('t.txt') # => false -**@overload** [] - -## chmod(*args ) [](#method-c-chmod) -Changes permission bits on the named file(s) to the bit pattern represented by -*mode_int*. Actual effects are operating system dependent (see the beginning -of this section). On Unix systems, see `chmod(2)` for details. Returns the -number of files processed. - - File.chmod(0644, "testfile", "out") #=> 2 -**@overload** [] - -## chown(*args ) [](#method-c-chown) -Changes the owner and group of the named file(s) to the given numeric owner -and group id's. Only a process with superuser privileges may change the owner -of a file. The current owner of a file may change the file's group to any -group to which the owner belongs. A `nil` or -1 owner or group id is ignored. -Returns the number of files processed. - - File.chown(nil, 100, "testfile") -**@overload** [] - -## ctime(fname ) [](#method-c-ctime) -Returns the change time for the named file (the time at which directory -information about the file was changed, not the file itself). - -*file_name* can be an IO object. - -Note that on Windows (NTFS), returns creation time (birth time). - - File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003 -**@overload** [] - -## delete(*args ) [](#method-c-delete) -Deletes the named files, returning the number of names passed as arguments. -Raises an exception on any error. Since the underlying implementation relies -on the `unlink(2)` system call, the type of exception raised depends on its -error type (see https://linux.die.net/man/2/unlink) and has the form of e.g. -Errno::ENOENT. - -See also Dir::rmdir. -**@overload** [] - -**@overload** [] - -## directory?(fname ) [](#method-c-directory?) -With string `object` given, returns `true` if `path` is a string path leading -to a directory, or to a symbolic link to a directory; `false` otherwise: - - File.directory?('.') # => true - File.directory?('foo') # => false - File.symlink('.', 'dirlink') # => 0 - File.directory?('dirlink') # => true - File.symlink('t,txt', 'filelink') # => 0 - File.directory?('filelink') # => false - -Argument `path` can be an IO object. -**@overload** [] - -## dirname(*args ) [](#method-c-dirname) -Returns all components of the filename given in *file_name* except the last -one (after first stripping trailing separators). The filename can be formed -using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when -File::ALT_SEPARATOR is not `nil`. - - File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work" - -If `level` is given, removes the last `level` components, not only one. - - File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby" - File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/" -**@overload** [] - -## empty?(fname ) [](#method-c-empty?) -Returns `true` if the named file exists and has a zero size. - -*file_name* can be an IO object. -**@overload** [] - -## executable?(fname ) [](#method-c-executable?) -Returns `true` if the named file is executable by the effective user and group -id of this process. See eaccess(3). - -Windows does not support execute permissions separately from read permissions. -On Windows, a file is only considered executable if it ends in .bat, .cmd, -.com, or .exe. - -Note that some OS-level security features may cause this to return true even -though the file is not executable by the effective user/group. -**@overload** [] - -## executable_real?(fname ) [](#method-c-executable_real?) -Returns `true` if the named file is executable by the real user and group id -of this process. See access(3). - -Windows does not support execute permissions separately from read permissions. -On Windows, a file is only considered executable if it ends in .bat, .cmd, -.com, or .exe. - -Note that some OS-level security features may cause this to return true even -though the file is not executable by the real user/group. -**@overload** [] - -## exist?(fname ) [](#method-c-exist?) -Return `true` if the named file exists. - -*file_name* can be an IO object. - -"file exists" means that stat() or fstat() system call is successful. -**@overload** [] - -## expand_path(* , _ ) [](#method-c-expand_path) -Converts a pathname to an absolute pathname. Relative paths are referenced -from the current working directory of the process unless `dir_string` is -given, in which case it will be used as the starting point. The given pathname -may start with a ```~`'', which expands to the process owner's home directory -(the environment variable `HOME` must be set correctly). ```~`*user*'' expands -to the named user's home directory. - - File.expand_path("~oracle/bin") #=> "/home/oracle/bin" - -A simple example of using `dir_string` is as follows. - File.expand_path("ruby", "/usr/bin") #=> "/usr/bin/ruby" - -A more complex example which also resolves parent directory is as follows. -Suppose we are in bin/mygem and want the absolute path of lib/mygem.rb. - - File.expand_path("../../lib/mygem.rb", __FILE__) - #=> ".../path/to/project/lib/mygem.rb" - -So first it resolves the parent of __FILE__, that is bin/, then go to the -parent, the root of the project and appends `lib/mygem.rb`. -**@overload** [] - -## extname(fname ) [](#method-c-extname) -Returns the extension (the portion of file name in `path` starting from the -last period). - -If `path` is a dotfile, or starts with a period, then the starting dot is not -dealt with the start of the extension. - -An empty string will also be returned when the period is the last character in -`path`. - -On Windows, trailing dots are truncated. - - File.extname("test.rb") #=> ".rb" - File.extname("a/b/d/test.rb") #=> ".rb" - File.extname(".a/b/d/test.rb") #=> ".rb" - File.extname("foo.") #=> "" on Windows - File.extname("foo.") #=> "." on non-Windows - File.extname("test") #=> "" - File.extname(".profile") #=> "" - File.extname(".profile.sh") #=> ".sh" -**@overload** [] - -## file?(fname ) [](#method-c-file?) -Returns `true` if the named `file` exists and is a regular file. - -`file` can be an IO object. - -If the `file` argument is a symbolic link, it will resolve the symbolic link -and use the file referenced by the link. -**@overload** [] - -## fnmatch(pattern , path , flags 0) [](#method-c-fnmatch) -call-seq: - File.fnmatch( pattern, path, [flags] ) -> (true or false) - File.fnmatch?( pattern, path, [flags] ) -> (true or false) - -Returns true if `path` matches against `pattern`. The pattern is not a -regular expression; instead it follows rules similar to shell filename -globbing. It may contain the following metacharacters: - -`*` -: Matches any file. Can be restricted by other values in the glob. - Equivalent to `/.*/x` in regexp. - - `*` -: Matches all regular files - - `c*` -: Matches all files beginning with `c` - - `*c` -: Matches all files ending with `c` - - `*c*` -: Matches all files that have `c` in them (including at the beginning or - end). - - - To match hidden files (that start with a `.`) set the File::FNM_DOTMATCH - flag. - - -`**` -: Matches directories recursively or files expansively. - - -`?` -: Matches any one character. Equivalent to `/.{1}/` in regexp. - - -`[set]` -: Matches any one character in `set`. Behaves exactly like character sets - in Regexp, including set negation (`[^a-z]`). - - -`\` -: Escapes the next metacharacter. - - -`{a,b}` -: Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled. - Behaves like a Regexp union (`(?:a|b)`). - - -`flags` is a bitwise OR of the `FNM_XXX` constants. The same glob pattern and -flags are used by Dir::glob. - -Examples: - - File.fnmatch('cat', 'cat') #=> true # match entire string - File.fnmatch('cat', 'category') #=> false # only match partial string - - File.fnmatch('c{at,ub}s', 'cats') #=> false # { } isn't supported by default - File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> true # { } is supported on FNM_EXTGLOB - - File.fnmatch('c?t', 'cat') #=> true # '?' match only 1 character - File.fnmatch('c??t', 'cat') #=> false # ditto - File.fnmatch('c*', 'cats') #=> true # '*' match 0 or more characters - File.fnmatch('c*t', 'c/a/b/t') #=> true # ditto - File.fnmatch('ca[a-z]', 'cat') #=> true # inclusive bracket expression - File.fnmatch('ca[^t]', 'cat') #=> false # exclusive bracket expression ('^' or '!') - - File.fnmatch('cat', 'CAT') #=> false # case sensitive - File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive - File.fnmatch('cat', 'CAT', File::FNM_SYSCASE) #=> true or false # depends on the system default - - File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME - File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto - File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false # ditto - - File.fnmatch('\?', '?') #=> true # escaped wildcard becomes ordinary - File.fnmatch('\a', 'a') #=> true # escaped ordinary remains ordinary - File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true # FNM_NOESCAPE makes '\' ordinary - File.fnmatch('[\?]', '?') #=> true # can escape inside bracket expression - - File.fnmatch('*', '.profile') #=> false # wildcard doesn't match leading - File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default. - File.fnmatch('.*', '.profile') #=> true - - File.fnmatch('**/*.rb', 'main.rb') #=> false - File.fnmatch('**/*.rb', './main.rb') #=> false - File.fnmatch('**/*.rb', 'lib/song.rb') #=> true - File.fnmatch('**.rb', 'main.rb') #=> true - File.fnmatch('**.rb', './main.rb') #=> false - File.fnmatch('**.rb', 'lib/song.rb') #=> true - File.fnmatch('*', 'dave/.profile') #=> true - - File.fnmatch('**/foo', 'a/b/c/foo', File::FNM_PATHNAME) #=> true - File.fnmatch('**/foo', '/a/b/c/foo', File::FNM_PATHNAME) #=> true - File.fnmatch('**/foo', 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true - File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false - File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true -## ftype(fname ) [](#method-c-ftype) -Identifies the type of the named file; the return string is one of ```file`'', -```directory`'', ```characterSpecial`'', ```blockSpecial`'', ```fifo`'', -```link`'', ```socket`'', or ```unknown`''. - - File.ftype("testfile") #=> "file" - File.ftype("/dev/tty") #=> "characterSpecial" - File.ftype("/tmp/.X11-unix/X0") #=> "socket" -**@overload** [] - -## grpowned?(fname ) [](#method-c-grpowned?) -Returns `true` if the named file exists and the effective group id of the -calling process is the owner of the file. Returns `false` on Windows. - -*file_name* can be an IO object. -**@overload** [] - -## identical?(fname1 , fname2 ) [](#method-c-identical?) -Returns `true` if the named files are identical. - -*file_1* and *file_2* can be an IO object. - - open("a", "w") {} - p File.identical?("a", "a") #=> true - p File.identical?("a", "./a") #=> true - File.link("a", "b") - p File.identical?("a", "b") #=> true - File.symlink("a", "c") - p File.identical?("a", "c") #=> true - open("d", "w") {} - p File.identical?("a", "d") #=> false -**@overload** [] - -## join(args ) [](#method-c-join) -Returns a new string formed by joining the strings using `"/"`. - - File.join("usr", "mail", "gumby") #=> "usr/mail/gumby" -**@overload** [] - -## lchmod(*args ) [](#method-c-lchmod) -Equivalent to File::chmod, but does not follow symbolic links (so it will -change the permissions associated with the link, not the file referenced by -the link). Often not available. -**@overload** [] - -## lchown(*args ) [](#method-c-lchown) -Equivalent to File::chown, but does not follow symbolic links (so it will -change the owner associated with the link, not the file referenced by the -link). Often not available. Returns number of files in the argument list. -**@overload** [] - -## link(from , to ) [](#method-c-link) -Creates a new name for an existing file using a hard link. Will not overwrite -*new_name* if it already exists (raising a subclass of SystemCallError). Not -available on all platforms. - - File.link("testfile", ".testfile") #=> 0 - IO.readlines(".testfile")[0] #=> "This is line one\n" -**@overload** [] - -## lstat(fname ) [](#method-c-lstat) -Like File::stat, but does not follow the last symbolic link; instead, returns -a File::Stat object for the link itself. - - File.symlink('t.txt', 'symlink') - File.stat('symlink').size # => 47 - File.lstat('symlink').size # => 5 -**@overload** [] - -## lutime(*args ) [](#method-c-lutime) -Sets the access and modification times of each named file to the first two -arguments. If a file is a symlink, this method acts upon the link itself as -opposed to its referent; for the inverse behavior, see File.utime. Returns the -number of file names in the argument list. -**@overload** [] - -## mkfifo(*args ) [](#method-c-mkfifo) -Creates a FIFO special file with name *file_name*. *mode* specifies the -FIFO's permissions. It is modified by the process's umask in the usual way: -the permissions of the created file are (mode & ~umask). -**@overload** [] - -## mtime(fname ) [](#method-c-mtime) -Returns the modification time for the named file as a Time object. - -*file_name* can be an IO object. - - File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003 -**@overload** [] - -## open(*args ) [](#method-c-open) -call-seq: - IO.open(fd, mode = 'r', **opts) -> io - IO.open(fd, mode = 'r', **opts) {|io| ... } -> object - -Creates a new IO object, via IO.new with the given arguments. - -With no block given, returns the IO object. - -With a block given, calls the block with the IO object and returns the block's -value. -## owned?(fname ) [](#method-c-owned?) -Returns `true` if the named file exists and the effective used id of the -calling process is the owner of the file. - -*file_name* can be an IO object. -**@overload** [] - -## path(fname ) [](#method-c-path) -Returns the string representation of the path - - File.path(File::NULL) #=> "/dev/null" - File.path(Pathname.new("/tmp")) #=> "/tmp" -**@overload** [] - -## pipe?(fname ) [](#method-c-pipe?) -Returns `true` if `filepath` points to a pipe, `false` otherwise: - - File.mkfifo('tmp/fifo') - File.pipe?('tmp/fifo') # => true - File.pipe?('t.txt') # => false -**@overload** [] - -## readable?(fname ) [](#method-c-readable?) -Returns `true` if the named file is readable by the effective user and group -id of this process. See eaccess(3). - -Note that some OS-level security features may cause this to return true even -though the file is not readable by the effective user/group. -**@overload** [] - -## readable_real?(fname ) [](#method-c-readable_real?) -Returns `true` if the named file is readable by the real user and group id of -this process. See access(3). - -Note that some OS-level security features may cause this to return true even -though the file is not readable by the real user/group. -**@overload** [] - -## readlink(path ) [](#method-c-readlink) -Returns the name of the file referenced by the given link. Not available on -all platforms. - - File.symlink("testfile", "link2test") #=> 0 - File.readlink("link2test") #=> "testfile" -**@overload** [] - -## realdirpath(*args ) [](#method-c-realdirpath) -Returns the real (absolute) pathname of *pathname* in the actual filesystem. - The real pathname doesn't contain symlinks or useless dots. - - If _dir_string_ is given, it is used as a base directory - for interpreting relative pathname instead of the current directory. - - The last component of the real pathname can be nonexistent. -**@overload** [] - -## realpath(*args ) [](#method-c-realpath) -Returns the real (absolute) pathname of *pathname* in the actual - filesystem not containing symlinks or useless dots. - - If _dir_string_ is given, it is used as a base directory - for interpreting relative pathname instead of the current directory. - - All components of the pathname must exist when this method is - called. -**@overload** [] - -## rename(from , to ) [](#method-c-rename) -Renames the given file to the new name. Raises a SystemCallError if the file -cannot be renamed. - - File.rename("afile", "afile.bak") #=> 0 -**@overload** [] - -## setgid?(fname ) [](#method-c-setgid?) -Returns `true` if the named file has the setgid bit set. - -*file_name* can be an IO object. -**@overload** [] - -## setuid?(fname ) [](#method-c-setuid?) -Returns `true` if the named file has the setuid bit set. - -*file_name* can be an IO object. -**@overload** [] - -## size(fname ) [](#method-c-size) -Returns the size of `file_name`. - -*file_name* can be an IO object. -**@overload** [] - -## size?(fname ) [](#method-c-size?) -Returns `nil` if `file_name` doesn't exist or has zero size, the size of the -file otherwise. - -*file_name* can be an IO object. -**@overload** [] - -## socket?(fname ) [](#method-c-socket?) -Returns `true` if `filepath` points to a socket, `false` otherwise: - - require 'socket' - File.socket?(Socket.new(:INET, :STREAM)) # => true - File.socket?(File.new('t.txt')) # => false -**@overload** [] - -## split(path ) [](#method-c-split) -Splits the given string into a directory and a file component and returns them -in a two-element array. See also File::dirname and File::basename. - - File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"] -**@overload** [] - -## stat(fname ) [](#method-c-stat) -Returns a File::Stat object for the file at `filepath` (see File::Stat): - - File.stat('t.txt').class # => File::Stat -**@overload** [] - -## sticky?(fname ) [](#method-c-sticky?) -Returns `true` if the named file has the sticky bit set. - -*file_name* can be an IO object. -**@overload** [] - -## symlink(from , to ) [](#method-c-symlink) -Creates a symbolic link called *new_name* for the existing file *old_name*. -Raises a NotImplemented exception on platforms that do not support symbolic -links. - - File.symlink("testfile", "link2test") #=> 0 -**@overload** [] - -## symlink?(fname ) [](#method-c-symlink?) -Returns `true` if `filepath` points to a symbolic link, `false` otherwise: - - symlink = File.symlink('t.txt', 'symlink') - File.symlink?('symlink') # => true - File.symlink?('t.txt') # => false -**@overload** [] - -## truncate(path , len ) [](#method-c-truncate) -Truncates the file *file_name* to be at most *integer* bytes long. Not -available on all platforms. - - f = File.new("out", "w") - f.write("1234567890") #=> 10 - f.close #=> nil - File.truncate("out", 5) #=> 0 - File.size("out") #=> 5 -**@overload** [] - -## umask(*args ) [](#method-c-umask) -Returns the current umask value for this process. If the optional argument is -given, set the umask to that value and return the previous value. Umask values -are *subtracted* from the default permissions, so a umask of `0222` would make -a file read-only for everyone. - - File.umask(0006) #=> 18 - File.umask #=> 6 -**@overload** [] - -**@overload** [] - -## unlink(*args ) [](#method-c-unlink) -Deletes the named files, returning the number of names passed as arguments. -Raises an exception on any error. Since the underlying implementation relies -on the `unlink(2)` system call, the type of exception raised depends on its -error type (see https://linux.die.net/man/2/unlink) and has the form of e.g. -Errno::ENOENT. - -See also Dir::rmdir. -**@overload** [] - -**@overload** [] - -## utime(*args ) [](#method-c-utime) -Sets the access and modification times of each named file to the first two -arguments. If a file is a symlink, this method acts upon its referent rather -than the link itself; for the inverse behavior see File.lutime. Returns the -number of file names in the argument list. -**@overload** [] - -## world_readable?(fname ) [](#method-c-world_readable?) -If *file_name* is readable by others, returns an integer representing the file -permission bits of *file_name*. Returns `nil` otherwise. The meaning of the -bits is platform dependent; on Unix systems, see `stat(2)`. - -*file_name* can be an IO object. - - File.world_readable?("/etc/passwd") #=> 420 - m = File.world_readable?("/etc/passwd") - sprintf("%o", m) #=> "644" -**@overload** [] - -## world_writable?(fname ) [](#method-c-world_writable?) -If *file_name* is writable by others, returns an integer representing the file -permission bits of *file_name*. Returns `nil` otherwise. The meaning of the -bits is platform dependent; on Unix systems, see `stat(2)`. - -*file_name* can be an IO object. - - File.world_writable?("/tmp") #=> 511 - m = File.world_writable?("/tmp") - sprintf("%o", m) #=> "777" -**@overload** [] - -## writable?(fname ) [](#method-c-writable?) -Returns `true` if the named file is writable by the effective user and group -id of this process. See eaccess(3). - -Note that some OS-level security features may cause this to return true even -though the file is not writable by the effective user/group. -**@overload** [] - -## writable_real?(fname ) [](#method-c-writable_real?) -Returns `true` if the named file is writable by the real user and group id of -this process. See access(3). - -Note that some OS-level security features may cause this to return true even -though the file is not writable by the real user/group. -**@overload** [] - -## zero?(fname ) [](#method-c-zero?) -Returns `true` if the named file exists and has a zero size. - -*file_name* can be an IO object. -**@overload** [] - - -#Instance Methods -## atime() [](#method-i-atime) -Returns the last access time (a Time object) for *file*, or epoch if *file* -has not been accessed. - - File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969 - -**@overload** [] - -## birthtime() [](#method-i-birthtime) -Returns the birth time for *file*. - - File.new("testfile").birthtime #=> Wed Apr 09 08:53:14 CDT 2003 - -If the platform doesn't have birthtime, raises NotImplementedError. - -**@overload** [] - -## chmod(vmode) [](#method-i-chmod) -Changes permission bits on *file* to the bit pattern represented by -*mode_int*. Actual effects are platform dependent; on Unix systems, see -`chmod(2)` for details. Follows symbolic links. Also see File#lchmod. - - f = File.new("out", "w"); - f.chmod(0644) #=> 0 - -**@overload** [] - -## chown(owner, group) [](#method-i-chown) -Changes the owner and group of *file* to the given numeric owner and group -id's. Only a process with superuser privileges may change the owner of a file. -The current owner of a file may change the file's group to any group to which -the owner belongs. A `nil` or -1 owner or group id is ignored. Follows -symbolic links. See also File#lchown. - - File.new("testfile").chown(502, 1000) - -**@overload** [] - -## ctime() [](#method-i-ctime) -Returns the change time for *file* (that is, the time directory information -about the file was changed, not the file itself). - -Note that on Windows (NTFS), returns creation time (birth time). - - File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003 - -**@overload** [] - -## flock(operation) [](#method-i-flock) -:markup: markdown - -call-seq: - flock(locking_constant) -> 0 or false - -Locks or unlocks file `self` according to the given `locking_constant`, a -bitwise OR of the values in the table below. - -Not available on all platforms. - -Returns `false` if `File::LOCK_NB` is specified and the operation would have -blocked; otherwise returns `0`. - -| Constant | Lock | Effect -|-----------------|--------------|-------------------------------------------- ----------------------------------------------------------------------| | -`File::LOCK_EX` | Exclusive | Only one process may hold an exclusive lock -for `self` at a time. | | -`File::LOCK_NB` | Non-blocking | No blocking; may be combined with -`File::LOCK_SH` or `File::LOCK_EX` using the bitwise OR operator `\|`. | | -`File::LOCK_SH` | Shared | Multiple processes may each hold a shared -lock for `self` at the same time. | | -`File::LOCK_UN` | Unlock | Remove an existing lock held by this process. - | - -Example: - -```ruby # Update a counter using an exclusive lock. # Don't use File::WRONLY -because it truncates the file. File.open('counter', File::RDWR | File::CREAT, -0644) do |f| - f.flock(File::LOCK_EX) - value = f.read.to_i + 1 - f.rewind - f.write("#{value}\n") - f.flush - f.truncate(f.pos) - -end - -# Read the counter using a shared lock. File.open('counter', 'r') do |f| - f.flock(File::LOCK_SH) - f.read - -end ``` - -## initialize(*args) [](#method-i-initialize) -Opens the file at the given `path` according to the given `mode`; creates and -returns a new File object for that file. - -The new File object is buffered mode (or non-sync mode), unless `filename` is -a tty. See IO#flush, IO#fsync, IO#fdatasync, and IO#sync=. - -Argument `path` must be a valid file path: - - f = File.new('/etc/fstab') - f.close - f = File.new('t.txt') - f.close - -Optional argument `mode` (defaults to 'r') must specify a valid mode; see -[Access Modes](rdoc-ref:File@Access+Modes): - - f = File.new('t.tmp', 'w') - f.close - f = File.new('t.tmp', File::RDONLY) - f.close - -Optional argument `perm` (defaults to 0666) must specify valid permissions see -[File Permissions](rdoc-ref:File@File+Permissions): - - f = File.new('t.tmp', File::CREAT, 0644) - f.close - f = File.new('t.tmp', File::CREAT, 0444) - f.close - -Optional keyword arguments `opts` specify: - -* [Open Options](rdoc-ref:IO@Open+Options). -* [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). - -**@overload** [] - -## lstat() [](#method-i-lstat) -Like File#stat, but does not follow the last symbolic link; instead, returns a -File::Stat object for the link itself: - - File.symlink('t.txt', 'symlink') - f = File.new('symlink') - f.stat.size # => 47 - f.lstat.size # => 11 - -**@overload** [] - -## mtime() [](#method-i-mtime) -Returns the modification time for *file*. - - File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 - -**@overload** [] - -## size() [](#method-i-size) -Returns the size of *file* in bytes. - - File.new("testfile").size #=> 66 - -**@overload** [] - -## truncate(len) [](#method-i-truncate) -Truncates *file* to at most *integer* bytes. The file must be opened for -writing. Not available on all platforms. - - f = File.new("out", "w") - f.syswrite("1234567890") #=> 10 - f.truncate(5) #=> 0 - f.close() #=> nil - File.size("out") #=> 5 - -**@overload** [] - diff --git a/example/ruby/File/Constants.md b/example/ruby/File/Constants.md deleted file mode 100644 index 3dea687..0000000 --- a/example/ruby/File/Constants.md +++ /dev/null @@ -1,312 +0,0 @@ -# Module: File::Constants - - -Module `File::Constants` defines file-related constants. - -There are two families of constants here: - -* Those having to do with [file - access](rdoc-ref:File::Constants@File+Access). -* Those having to do with [filename - globbing](rdoc-ref:File::Constants@Filename+Globbing+Constants+-28File-3A- - 3AFNM_-2A-29). - -File constants defined for the local process may be retrieved with method -File::Constants.constants: - - File::Constants.constants.take(5) - # => [:RDONLY, :WRONLY, :RDWR, :APPEND, :CREAT] - -## File Access - -File-access constants may be used with optional argument `mode` in calls to -the following methods: - -* File.new. -* File.open. -* IO.for_fd. -* IO.new. -* IO.open. -* IO.popen. -* IO.reopen. -* IO.sysopen. -* StringIO.new. -* StringIO.open. -* StringIO#reopen. - -### Read/Write Access - -Read-write access for a stream may be specified by a file-access constant. - -The constant may be specified as part of a bitwise OR of other such constants. - -Any combination of the constants in this section may be specified. - -#### File::RDONLY - -Flag File::RDONLY specifies the stream should be opened for reading only: - - filepath = '/tmp/t.tmp' - f = File.new(filepath, File::RDONLY) - f.write('Foo') # Raises IOError (not opened for writing). - -#### File::WRONLY - -Flag File::WRONLY specifies that the stream should be opened for writing only: - - f = File.new(filepath, File::WRONLY) - f.read # Raises IOError (not opened for reading). - -#### File::RDWR - -Flag File::RDWR specifies that the stream should be opened for both reading -and writing: - - f = File.new(filepath, File::RDWR) - f.write('Foo') # => 3 - f.rewind # => 0 - f.read # => "Foo" - -### File Positioning - -#### File::APPEND - -Flag File::APPEND specifies that the stream should be opened in append mode. - -Before each write operation, the position is set to end-of-stream. The -modification of the position and the following write operation are performed -as a single atomic step. - -#### File::TRUNC - -Flag File::TRUNC specifies that the stream should be truncated at its -beginning. If the file exists and is successfully opened for writing, it is to -be truncated to position zero; its ctime and mtime are updated. - -There is no effect on a FIFO special file or a terminal device. The effect on -other file types is implementation-defined. The result of using File::TRUNC -with File::RDONLY is undefined. - -### Creating and Preserving - -#### File::CREAT - -Flag File::CREAT specifies that the stream should be created if it does not -already exist. - -If the file exists: - - - Raise an exception if File::EXCL is also specified. - - Otherwise, do nothing. - -If the file does not exist, then it is created. Upon successful completion, -the atime, ctime, and mtime of the file are updated, and the ctime and mtime -of the parent directory are updated. - -#### File::EXCL - -Flag File::EXCL specifies that the stream should not already exist; If flags -File::CREAT and File::EXCL are both specified and the stream already exists, -an exception is raised. - -The check for the existence and creation of the file is performed as an atomic -operation. - -If both File::EXCL and File::CREAT are specified and the path names a symbolic -link, an exception is raised regardless of the contents of the symbolic link. - -If File::EXCL is specified and File::CREAT is not specified, the result is -undefined. - -### POSIX File Constants - -Some file-access constants are defined only on POSIX-compliant systems; those -are: - -* File::SYNC. -* File::DSYNC. -* File::RSYNC. -* File::DIRECT. -* File::NOATIME. -* File::NOCTTY. -* File::NOFOLLOW. -* File::TMPFILE. - -#### File::SYNC, File::RSYNC, and File::DSYNC - -Flag File::SYNC, File::RSYNC, or File::DSYNC specifies synchronization of I/O -operations with the underlying file system. - -These flags are valid only for POSIX-compliant systems. - -* File::SYNC specifies that all write operations (both data and metadata) - are immediately to be flushed to the underlying storage device. This means - that the data is written to the storage device, and the file's metadata - (e.g., file size, timestamps, permissions) are also synchronized. This - guarantees that data is safely stored on the storage medium before - returning control to the calling program. This flag can have a significant - impact on performance since it requires synchronous writes, which can be - slower compared to asynchronous writes. - -* File::RSYNC specifies that any read operations on the file will not return - until all outstanding write operations (those that have been issued but - not completed) are also synchronized. This is useful when you want to read - the most up-to-date data, which may still be in the process of being - written. - -* File::DSYNC specifies that all *data* write operations are immediately to - be flushed to the underlying storage device; this differs from File::SYNC, - which requires that *metadata* also be synchronized. - -Note that the behavior of these flags may vary slightly depending on the -operating system and filesystem being used. Additionally, using these flags -can have an impact on performance due to the synchronous nature of the I/O -operations, so they should be used judiciously, especially in -performance-critical applications. - -#### File::NOCTTY - -Flag File::NOCTTY specifies that if the stream is a terminal device, that -device does not become the controlling terminal for the process. - -Defined only for POSIX-compliant systems. - -#### File::DIRECT - -Flag File::DIRECT requests that cache effects of the I/O to and from the -stream be minimized. - -Defined only for POSIX-compliant systems. - -#### File::NOATIME - -Flag File::NOATIME specifies that act of opening the stream should not modify -its access time (atime). - -Defined only for POSIX-compliant systems. - -#### File::NOFOLLOW - -Flag File::NOFOLLOW specifies that if path is a symbolic link, it should not -be followed. - -Defined only for POSIX-compliant systems. - -#### File::TMPFILE - -Flag File::TMPFILE specifies that the opened stream should be a new temporary -file. - -Defined only for POSIX-compliant systems. - -### Other File-Access Constants - -#### File::NONBLOCK - -When possible, the file is opened in nonblocking mode. Neither the open -operation nor any subsequent I/O operations on the file will cause the calling -process to wait. - -#### File::BINARY - -Flag File::BINARY specifies that the stream is to be accessed in binary mode. - -#### File::SHARE_DELETE - -Flag File::SHARE_DELETE enables other processes to open the stream with delete -access. - -Windows only. - -If the stream is opened for (local) delete access without File::SHARE_DELETE, -and another process attempts to open it with delete access, the attempt fails -and the stream is not opened for that process. - -## Locking - -Four file constants relate to stream locking; see File#flock: - -#### File::LOCK_EX - -Flag File::LOCK_EX specifies an exclusive lock; only one process a a time may -lock the stream. - -#### File::LOCK_NB - -Flag File::LOCK_NB specifies non-blocking locking for the stream; may be -combined with File::LOCK_EX or File::LOCK_SH. - -#### File::LOCK_SH - -Flag File::LOCK_SH specifies that multiple processes may lock the stream at -the same time. - -#### File::LOCK_UN - -Flag File::LOCK_UN specifies that the stream is not to be locked. - -## Filename Globbing Constants (File::FNM_*) - -Filename-globbing constants may be used with optional argument `flags` in -calls to the following methods: - -* Dir.glob. -* File.fnmatch. -* Pathname#fnmatch. -* Pathname.glob. -* Pathname#glob. - -The constants are: - -#### File::FNM_CASEFOLD - -Flag File::FNM_CASEFOLD makes patterns case insensitive for File.fnmatch (but -not Dir.glob). - -#### File::FNM_DOTMATCH - -Flag File::FNM_DOTMATCH makes the `'*'` pattern match a filename starting with -`'.'`. - -#### File::FNM_EXTGLOB - -Flag File::FNM_EXTGLOB enables pattern `'{*a*,*b*}'`, which matches pattern -'*a*' and pattern '*b*'; behaves like a [regexp union](rdoc-ref:Regexp.union) -(e.g., `'(?:*a*|*b*)'`): - - pattern = '{LEGAL,BSDL}' - Dir.glob(pattern) # => ["LEGAL", "BSDL"] - Pathname.glob(pattern) # => [#, #] - pathname.glob(pattern) # => [#, #] - -#### File::FNM_NOESCAPE - -Flag File::FNM_NOESCAPE disables `'\'` escaping. - -#### File::FNM_PATHNAME - -Flag File::FNM_PATHNAME specifies that patterns `'*'` and `'?'` do not match -the directory separator (the value of constant File::SEPARATOR). - -#### File::FNM_SHORTNAME - -Flag File::FNM_SHORTNAME allows patterns to match short names if they exist. - -Windows only. - -#### File::FNM_SYSCASE - -Flag File::FNM_SYSCASE specifies that case sensitivity is the same as in the -underlying operating system; effective for File.fnmatch, but not Dir.glob. - -## Other Constants - -#### File::NULL - -Flag File::NULL contains the string value of the null device: - -* On a Unix-like OS, `'/dev/null'`. -* On Windows, `'NUL'`. - - - diff --git a/example/ruby/File/Stat.md b/example/ruby/File/Stat.md deleted file mode 100644 index a80ff56..0000000 --- a/example/ruby/File/Stat.md +++ /dev/null @@ -1,472 +0,0 @@ -# Class: File::Stat -**Inherits:** Object - -**Includes:** Comparable - - -:nodoc: - - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Compares File::Stat objects by comparing their respective modification times. - -`nil` is returned if `other_stat` is not a File::Stat object - - f1 = File.new("f1", "w") - sleep 1 - f2 = File.new("f2", "w") - f1.stat <=> f2.stat #=> -1 - -**@overload** [] - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## atime() [](#method-i-atime) -Returns the last access time for this file as an object of class Time. - - File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969 - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## birthtime() [](#method-i-birthtime) -Returns the birth time for *stat*. - -If the platform doesn't have birthtime, raises NotImplementedError. - - File.write("testfile", "foo") - sleep 10 - File.write("testfile", "bar") - sleep 10 - File.chmod(0644, "testfile") - sleep 10 - File.read("testfile") - File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900 - File.stat("testfile").mtime #=> 2014-02-24 11:19:27 +0900 - File.stat("testfile").ctime #=> 2014-02-24 11:19:37 +0900 - File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900 - -**@overload** [] - -## blksize() [](#method-i-blksize) -Returns the native file system's block size. Will return `nil` on platforms -that don't support this information. - - File.stat("testfile").blksize #=> 4096 - -**@overload** [] - -## blockdev?() [](#method-i-blockdev?) -Returns `true` if the file is a block device, `false` if it isn't or if the -operating system doesn't support this feature. - - File.stat("testfile").blockdev? #=> false - File.stat("/dev/hda1").blockdev? #=> true - -**@overload** [] - -## blocks() [](#method-i-blocks) -Returns the number of native file system blocks allocated for this file, or -`nil` if the operating system doesn't support this feature. - - File.stat("testfile").blocks #=> 2 - -**@overload** [] - -## chardev?() [](#method-i-chardev?) -Returns `true` if the file is a character device, `false` if it isn't or if -the operating system doesn't support this feature. - - File.stat("/dev/tty").chardev? #=> true - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## ctime() [](#method-i-ctime) -Returns the change time for *stat* (that is, the time directory information -about the file was changed, not the file itself). - -Note that on Windows (NTFS), returns creation time (birth time). - - File.stat("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003 - -**@overload** [] - -## dev() [](#method-i-dev) -Returns an integer representing the device on which *stat* resides. - - File.stat("testfile").dev #=> 774 - -**@overload** [] - -## dev_major() [](#method-i-dev_major) -Returns the major part of `File_Stat#dev` or `nil`. - - File.stat("/dev/fd1").dev_major #=> 2 - File.stat("/dev/tty").dev_major #=> 5 - -**@overload** [] - -## dev_minor() [](#method-i-dev_minor) -Returns the minor part of `File_Stat#dev` or `nil`. - - File.stat("/dev/fd1").dev_minor #=> 1 - File.stat("/dev/tty").dev_minor #=> 0 - -**@overload** [] - -## directory?() [](#method-i-directory?) -Returns `true` if *stat* is a directory, `false` otherwise. - - File.stat("testfile").directory? #=> false - File.stat(".").directory? #=> true - -**@overload** [] - -## executable?() [](#method-i-executable?) -Returns `true` if *stat* is executable or if the operating system doesn't -distinguish executable files from nonexecutable files. The tests are made -using the effective owner of the process. - - File.stat("testfile").executable? #=> false - -**@overload** [] - -## executable_real?() [](#method-i-executable_real?) -Same as `executable?`, but tests using the real owner of the process. - -**@overload** [] - -## file?() [](#method-i-file?) -Returns `true` if *stat* is a regular file (not a device file, pipe, socket, -etc.). - - File.stat("testfile").file? #=> true - -**@overload** [] - -## ftype() [](#method-i-ftype) -Identifies the type of *stat*. The return string is one of: ```file`'', -```directory`'', ```characterSpecial`'', ```blockSpecial`'', ```fifo`'', -```link`'', ```socket`'', or ```unknown`''. - - File.stat("/dev/tty").ftype #=> "characterSpecial" - -**@overload** [] - -## gid() [](#method-i-gid) -Returns the numeric group id of the owner of *stat*. - - File.stat("testfile").gid #=> 500 - -**@overload** [] - -## grpowned?() [](#method-i-grpowned?) -Returns true if the effective group id of the process is the same as the group -id of *stat*. On Windows, returns `false`. - - File.stat("testfile").grpowned? #=> true - File.stat("/etc/passwd").grpowned? #=> false - -**@overload** [] - -## initialize(fname) [](#method-i-initialize) -Create a File::Stat object for the given file name (raising an exception if -the file doesn't exist). - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## ino() [](#method-i-ino) -Returns the inode number for *stat*. - - File.stat("testfile").ino #=> 1083669 - -**@overload** [] - -## inspect() [](#method-i-inspect) -Produce a nicely formatted description of *stat*. - - File.stat("/etc/passwd").inspect - #=> "#" - -**@overload** [] - -## mode() [](#method-i-mode) -Returns an integer representing the permission bits of *stat*. The meaning of -the bits is platform dependent; on Unix systems, see `stat(2)`. - - File.chmod(0644, "testfile") #=> 1 - s = File.stat("testfile") - sprintf("%o", s.mode) #=> "100644" - -**@overload** [] - -## mtime() [](#method-i-mtime) -Returns the modification time of *stat*. - - File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 - -**@overload** [] - -## nlink() [](#method-i-nlink) -Returns the number of hard links to *stat*. - - File.stat("testfile").nlink #=> 1 - File.link("testfile", "testfile.bak") #=> 0 - File.stat("testfile").nlink #=> 2 - -**@overload** [] - -## owned?() [](#method-i-owned?) -Returns `true` if the effective user id of the process is the same as the -owner of *stat*. - - File.stat("testfile").owned? #=> true - File.stat("/etc/passwd").owned? #=> false - -**@overload** [] - -## pipe?() [](#method-i-pipe?) -Returns `true` if the operating system supports pipes and *stat* is a pipe; -`false` otherwise. - -**@overload** [] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## rdev() [](#method-i-rdev) -Returns an integer representing the device type on which *stat* resides. -Returns `nil` if the operating system doesn't support this feature. - - File.stat("/dev/fd1").rdev #=> 513 - File.stat("/dev/tty").rdev #=> 1280 - -**@overload** [] - -## rdev_major() [](#method-i-rdev_major) -Returns the major part of `File_Stat#rdev` or `nil`. - - File.stat("/dev/fd1").rdev_major #=> 2 - File.stat("/dev/tty").rdev_major #=> 5 - -**@overload** [] - -## rdev_minor() [](#method-i-rdev_minor) -Returns the minor part of `File_Stat#rdev` or `nil`. - - File.stat("/dev/fd1").rdev_minor #=> 1 - File.stat("/dev/tty").rdev_minor #=> 0 - -**@overload** [] - -## readable?() [](#method-i-readable?) -Returns `true` if *stat* is readable by the effective user id of this process. - - File.stat("testfile").readable? #=> true - -**@overload** [] - -## readable_real?() [](#method-i-readable_real?) -Returns `true` if *stat* is readable by the real user id of this process. - - File.stat("testfile").readable_real? #=> true - -**@overload** [] - -## setgid?() [](#method-i-setgid?) -Returns `true` if *stat* has the set-group-id permission bit set, `false` if -it doesn't or if the operating system doesn't support this feature. - - File.stat("/usr/sbin/lpc").setgid? #=> true - -**@overload** [] - -## setuid?() [](#method-i-setuid?) -Returns `true` if *stat* has the set-user-id permission bit set, `false` if it -doesn't or if the operating system doesn't support this feature. - - File.stat("/bin/su").setuid? #=> true - -**@overload** [] - -## size() [](#method-i-size) -Returns the size of *stat* in bytes. - - File.stat("testfile").size #=> 66 - -**@overload** [] - -## size?() [](#method-i-size?) -Returns `nil` if *stat* is a zero-length file, the size of the file otherwise. - - File.stat("testfile").size? #=> 66 - File.stat(File::NULL).size? #=> nil - -**@overload** [] - -## socket?() [](#method-i-socket?) -Returns `true` if *stat* is a socket, `false` if it isn't or if the operating -system doesn't support this feature. - - File.stat("testfile").socket? #=> false - -**@overload** [] - -## sticky?() [](#method-i-sticky?) -Returns `true` if *stat* has its sticky bit set, `false` if it doesn't or if -the operating system doesn't support this feature. - - File.stat("testfile").sticky? #=> false - -**@overload** [] - -## symlink?() [](#method-i-symlink?) -Returns `true` if *stat* is a symbolic link, `false` if it isn't or if the -operating system doesn't support this feature. As File::stat automatically -follows symbolic links, #symlink? will always be `false` for an object -returned by File::stat. - - File.symlink("testfile", "alink") #=> 0 - File.stat("alink").symlink? #=> false - File.lstat("alink").symlink? #=> true - -**@overload** [] - -## uid() [](#method-i-uid) -Returns the numeric user id of the owner of *stat*. - - File.stat("testfile").uid #=> 501 - -**@overload** [] - -## world_readable?() [](#method-i-world_readable?) -If *stat* is readable by others, returns an integer representing the file -permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is -platform dependent; on Unix systems, see `stat(2)`. - - m = File.stat("/etc/passwd").world_readable? #=> 420 - sprintf("%o", m) #=> "644" - -**@overload** [] - -## world_writable?() [](#method-i-world_writable?) -If *stat* is writable by others, returns an integer representing the file -permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is -platform dependent; on Unix systems, see `stat(2)`. - - m = File.stat("/tmp").world_writable? #=> 511 - sprintf("%o", m) #=> "777" - -**@overload** [] - -## writable?() [](#method-i-writable?) -Returns `true` if *stat* is writable by the effective user id of this process. - - File.stat("testfile").writable? #=> true - -**@overload** [] - -## writable_real?() [](#method-i-writable_real?) -Returns `true` if *stat* is writable by the real user id of this process. - - File.stat("testfile").writable_real? #=> true - -**@overload** [] - -## zero?() [](#method-i-zero?) -Returns `true` if *stat* is a zero-length file; `false` otherwise. - - File.stat("testfile").zero? #=> false - -**@overload** [] - diff --git a/example/ruby/FileFormatter.md b/example/ruby/FileFormatter.md deleted file mode 100644 index ce627ae..0000000 --- a/example/ruby/FileFormatter.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: FileFormatter -**Inherits:** DottedFormatter - - - - - -#Instance Methods -## load(statenil) [](#method-i-load) - -## register() [](#method-i-register) -Unregisters DottedFormatter#before, #after methods and registers #load, -#unload, which perform the same duties as #before, #after in DottedFormatter. - -## unload(statenil) [](#method-i-unload) - diff --git a/example/ruby/FileSpecs.md b/example/ruby/FileSpecs.md deleted file mode 100644 index c926034..0000000 --- a/example/ruby/FileSpecs.md +++ /dev/null @@ -1,22 +0,0 @@ -# Module: FileSpecs - - - - -# Class Methods -## block_device() [](#method-c-block_device) -**@yield** [@block] - -## character_device() [](#method-c-character_device) -**@yield** [@char] - -## configure_types() [](#method-c-configure_types) -## directory() [](#method-c-directory) -**@yield** [@dir] - -## fifo() [](#method-c-fifo) -## make_closer(obj , exc nil) [](#method-c-make_closer) -## normal_file() [](#method-c-normal_file) -## socket() [](#method-c-socket) -## symlink() [](#method-c-symlink) - diff --git a/example/ruby/FileSpecs/SubString.md b/example/ruby/FileSpecs/SubString.md deleted file mode 100644 index 92c0c9e..0000000 --- a/example/ruby/FileSpecs/SubString.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: FileSpecs::SubString -**Inherits:** String - - - - - diff --git a/example/ruby/FileStat.md b/example/ruby/FileStat.md deleted file mode 100644 index 77121f7..0000000 --- a/example/ruby/FileStat.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: FileStat -**Inherits:** Object - - - - -# Class Methods -## method_missing(meth , file ) [](#method-c-method_missing) - diff --git a/example/ruby/FileTest.md b/example/ruby/FileTest.md deleted file mode 100644 index 062d9c5..0000000 --- a/example/ruby/FileTest.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: FileTest - - - - - diff --git a/example/ruby/FileUtils.md b/example/ruby/FileUtils.md deleted file mode 100644 index 21d7b04..0000000 --- a/example/ruby/FileUtils.md +++ /dev/null @@ -1,1771 +0,0 @@ -# Module: FileUtils - -**Extended by:** FileUtils::StreamUtils_ - -**Includes:** FileUtils::StreamUtils_ - - -Namespace for file utility methods for copying, moving, removing, etc. - -## What's Here - -First, what’s elsewhere. Module FileUtils: - -* Inherits from [class Object](rdoc-ref:Object). -* Supplements [class File](rdoc-ref:File) (but is not included or extended - there). - -Here, module FileUtils provides methods that are useful for: - -* [Creating](rdoc-ref:FileUtils@Creating). -* [Deleting](rdoc-ref:FileUtils@Deleting). -* [Querying](rdoc-ref:FileUtils@Querying). -* [Setting](rdoc-ref:FileUtils@Setting). -* [Comparing](rdoc-ref:FileUtils@Comparing). -* [Copying](rdoc-ref:FileUtils@Copying). -* [Moving](rdoc-ref:FileUtils@Moving). -* [Options](rdoc-ref:FileUtils@Options). - -### Creating - -* ::mkdir: Creates directories. -* ::mkdir_p, ::makedirs, ::mkpath: Creates directories, also creating - ancestor directories as needed. -* ::link_entry: Creates a hard link. -* ::ln, ::link: Creates hard links. -* ::ln_s, ::symlink: Creates symbolic links. -* ::ln_sf: Creates symbolic links, overwriting if necessary. -* ::ln_sr: Creates symbolic links relative to targets - -### Deleting - -* ::remove_dir: Removes a directory and its descendants. -* ::remove_entry: Removes an entry, including its descendants if it is a - directory. -* ::remove_entry_secure: Like ::remove_entry, but removes securely. -* ::remove_file: Removes a file entry. -* ::rm, ::remove: Removes entries. -* ::rm_f, ::safe_unlink: Like ::rm, but removes forcibly. -* ::rm_r: Removes entries and their descendants. -* ::rm_rf, ::rmtree: Like ::rm_r, but removes forcibly. -* ::rmdir: Removes directories. - -### Querying - -* ::pwd, ::getwd: Returns the path to the working directory. -* ::uptodate?: Returns whether a given entry is newer than given other - entries. - -### Setting - -* ::cd, ::chdir: Sets the working directory. -* ::chmod: Sets permissions for an entry. -* ::chmod_R: Sets permissions for an entry and its descendants. -* ::chown: Sets the owner and group for entries. -* ::chown_R: Sets the owner and group for entries and their descendants. -* ::touch: Sets modification and access times for entries, creating if - necessary. - -### Comparing - -* ::compare_file, ::cmp, ::identical?: Returns whether two entries are - identical. -* ::compare_stream: Returns whether two streams are identical. - -### Copying - -* ::copy_entry: Recursively copies an entry. -* ::copy_file: Copies an entry. -* ::copy_stream: Copies a stream. -* ::cp, ::copy: Copies files. -* ::cp_lr: Recursively creates hard links. -* ::cp_r: Recursively copies files, retaining mode, owner, and group. -* ::install: Recursively copies files, optionally setting mode, owner, and - group. - -### Moving - -* ::mv, ::move: Moves entries. - -### Options - -* ::collect_method: Returns the names of methods that accept a given option. -* ::commands: Returns the names of methods that accept options. -* ::have_option?: Returns whether a given method accepts a given option. -* ::options: Returns all option names. -* ::options_of: Returns the names of the options for a given method. - -## Path Arguments - -Some methods in FileUtils accept *path* arguments, which are interpreted as -paths to filesystem entries: - -* If the argument is a string, that value is the path. -* If the argument has method `:to_path`, it is converted via that method. -* If the argument has method `:to_str`, it is converted via that method. - -## About the Examples - -Some examples here involve trees of file entries. For these, we sometimes -display trees using the [tree command-line -utility](https://en.wikipedia.org/wiki/Tree_(command)), which is a recursive -directory-listing utility that produces a depth-indented listing of files and -directories. - -We use a helper method to launch the command and control the format: - - def tree(dirpath = '.') - command = "tree --noreport --charset=ascii #{dirpath}" - system(command) - end - -To illustrate: - - tree('src0') - # => src0 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - -## Avoiding the TOCTTOU Vulnerability - -For certain methods that recursively remove entries, there is a potential -vulnerability called the [Time-of-check to -time-of-use](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use), or -TOCTTOU, vulnerability that can exist when: - -* An ancestor directory of the entry at the target path is world writable; - such directories include `/tmp`. -* The directory tree at the target path includes: - - * A world-writable descendant directory. - * A symbolic link. - -To avoid that vulnerability, you can use this method to remove entries: - -* FileUtils.remove_entry_secure: removes recursively if the target path - points to a directory. - -Also available are these methods, each of which calls -FileUtils.remove_entry_secure: - -* FileUtils.rm_r with keyword argument `secure: true`. -* FileUtils.rm_rf with keyword argument `secure: true`. - -Finally, this method for moving entries calls FileUtils.remove_entry_secure if -the source and destination are on different file systems (which means that the -"move" is really a copy and remove): - -* FileUtils.mv with keyword argument `secure: true`. - -Method FileUtils.remove_entry_secure removes securely by applying a special -pre-process: - -* If the target path points to a directory, this method uses methods - [File#chown](rdoc-ref:File#chown) and [File#chmod](rdoc-ref:File#chmod) in - removing directories. -* The owner of the target directory should be either the current process or - the super user (root). - -WARNING: You must ensure that **ALL** parent directories cannot be moved by -other untrusted users. For example, parent directories should not be owned by -untrusted users, and should not be world writable except when the sticky bit -is set. - -For details of this security vulnerability, see Perl cases: - -* [CVE-2005-0448](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-04 - 48). -* [CVE-2004-0452](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-04 - 52). - - -# Class Methods -## cd(dir , verbose: nil, &block ) [](#method-c-cd) -Changes the working directory to the given `dir`, which should be -[interpretable as a path](rdoc-ref:FileUtils@Path+Arguments): - -With no block given, changes the current directory to the directory at `dir`; -returns zero: - - FileUtils.pwd # => "/rdoc/fileutils" - FileUtils.cd('..') - FileUtils.pwd # => "/rdoc" - FileUtils.cd('fileutils') - -With a block given, changes the current directory to the directory at `dir`, -calls the block with argument `dir`, and restores the original current -directory; returns the block's value: - - FileUtils.pwd # => "/rdoc/fileutils" - FileUtils.cd('..') { |arg| [arg, FileUtils.pwd] } # => ["..", "/rdoc"] - FileUtils.pwd # => "/rdoc/fileutils" - -Keyword arguments: - -* `verbose: true` - prints an equivalent command: - - FileUtils.cd('..') - FileUtils.cd('fileutils') - - Output: - - cd .. - cd fileutils - -Related: FileUtils.pwd. -## chdir() [](#method-c-chdir) -Changes the working directory to the given `dir`, which should be -[interpretable as a path](rdoc-ref:FileUtils@Path+Arguments): - -With no block given, changes the current directory to the directory at `dir`; -returns zero: - - FileUtils.pwd # => "/rdoc/fileutils" - FileUtils.cd('..') - FileUtils.pwd # => "/rdoc" - FileUtils.cd('fileutils') - -With a block given, changes the current directory to the directory at `dir`, -calls the block with argument `dir`, and restores the original current -directory; returns the block's value: - - FileUtils.pwd # => "/rdoc/fileutils" - FileUtils.cd('..') { |arg| [arg, FileUtils.pwd] } # => ["..", "/rdoc"] - FileUtils.pwd # => "/rdoc/fileutils" - -Keyword arguments: - -* `verbose: true` - prints an equivalent command: - - FileUtils.cd('..') - FileUtils.cd('fileutils') - - Output: - - cd .. - cd fileutils - -Related: FileUtils.pwd. -## chmod(mode , list , noop: nil, verbose: nil) [](#method-c-chmod) -Changes permissions on the entries at the paths given in `list` (a single path -or an array of paths) to the permissions given by `mode`; returns `list` if it -is an array, `[list]` otherwise: - -* Modifies each entry that is a regular file using - [File.chmod](rdoc-ref:File.chmod). -* Modifies each entry that is a symbolic link using - [File.lchmod](rdoc-ref:File.lchmod). - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -Argument `mode` may be either an integer or a string: - -* Integer `mode`: represents the permission bits to be set: - - FileUtils.chmod(0755, 'src0.txt') - FileUtils.chmod(0644, ['src0.txt', 'src0.dat']) - -* String `mode`: represents the permissions to be set: - - The string is of the form `[targets][[operator][perms[,perms]]`, where: - - * `targets` may be any combination of these letters: - - * `'u'`: permissions apply to the file's owner. - * `'g'`: permissions apply to users in the file's group. - * `'o'`: permissions apply to other users not in the file's group. - * `'a'` (the default): permissions apply to all users. - - * `operator` may be one of these letters: - - * `'+'`: adds permissions. - * `'-'`: removes permissions. - * `'='`: sets (replaces) permissions. - - * `perms` (may be repeated, with separating commas) may be any - combination of these letters: - - * `'r'`: Read. - * `'w'`: Write. - * `'x'`: Execute (search, for a directory). - * `'X'`: Search (for a directories only; must be used with `'+'`) - * `'s'`: Uid or gid. - * `'t'`: Sticky bit. - - Examples: - - FileUtils.chmod('u=wrx,go=rx', 'src1.txt') - FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby') - -Keyword arguments: - -* `noop: true` - does not change permissions; returns `nil`. -* `verbose: true` - prints an equivalent command: - - FileUtils.chmod(0755, 'src0.txt', noop: true, verbose: true) - FileUtils.chmod(0644, ['src0.txt', 'src0.dat'], noop: true, verbose: true) - FileUtils.chmod('u=wrx,go=rx', 'src1.txt', noop: true, verbose: true) - FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby', noop: true, verbose: true) - - Output: - - chmod 755 src0.txt - chmod 644 src0.txt src0.dat - chmod u=wrx,go=rx src1.txt - chmod u=wrx,go=rx /usr/bin/ruby - -Related: FileUtils.chmod_R. -## chmod_R(mode , list , noop: nil, verbose: nil, force: nil) [](#method-c-chmod_R) -Like FileUtils.chmod, but changes permissions recursively. -## chown(user , group , list , noop: nil, verbose: nil) [](#method-c-chown) -Changes the owner and group on the entries at the paths given in `list` (a -single path or an array of paths) to the given `user` and `group`; returns -`list` if it is an array, `[list]` otherwise: - -* Modifies each entry that is a regular file using - [File.chown](rdoc-ref:File.chown). -* Modifies each entry that is a symbolic link using - [File.lchown](rdoc-ref:File.lchown). - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -User and group: - -* Argument `user` may be a user name or a user id; if `nil` or `-1`, the - user is not changed. -* Argument `group` may be a group name or a group id; if `nil` or `-1`, the - group is not changed. -* The user must be a member of the group. - -Examples: - - # One path. - # User and group as string names. - File.stat('src0.txt').uid # => 1004 - File.stat('src0.txt').gid # => 1004 - FileUtils.chown('user2', 'group1', 'src0.txt') - File.stat('src0.txt').uid # => 1006 - File.stat('src0.txt').gid # => 1005 - - # User and group as uid and gid. - FileUtils.chown(1004, 1004, 'src0.txt') - File.stat('src0.txt').uid # => 1004 - File.stat('src0.txt').gid # => 1004 - - # Array of paths. - FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat']) - - # Directory (not recursive). - FileUtils.chown('user2', 'group1', '.') - -Keyword arguments: - -* `noop: true` - does not change permissions; returns `nil`. -* `verbose: true` - prints an equivalent command: - - FileUtils.chown('user2', 'group1', 'src0.txt', noop: true, verbose: true) - FileUtils.chown(1004, 1004, 'src0.txt', noop: true, verbose: true) - FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat'], noop: true, verbose: true) - FileUtils.chown('user2', 'group1', path, noop: true, verbose: true) - FileUtils.chown('user2', 'group1', '.', noop: true, verbose: true) - - Output: - - chown user2:group1 src0.txt - chown 1004:1004 src0.txt - chown 1006:1005 src0.txt src0.dat - chown user2:group1 src0.txt - chown user2:group1 . - -Related: FileUtils.chown_R. -## chown_R(user , group , list , noop: nil, verbose: nil, force: nil) [](#method-c-chown_R) -Like FileUtils.chown, but changes owner and group recursively. -## cmp() [](#method-c-cmp) -Returns `true` if the contents of files `a` and `b` are identical, `false` -otherwise. - -Arguments `a` and `b` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -FileUtils.identical? and FileUtils.cmp are aliases for FileUtils.compare_file. - -Related: FileUtils.compare_stream. -## collect_method(opt ) [](#method-c-collect_method) -Returns an array of the string method names of the methods that accept the -given keyword option `opt`; the argument must be a symbol: - - FileUtils.collect_method(:preserve) # => ["cp", "copy", "cp_r", "install"] -## commands() [](#method-c-commands) -Returns an array of the string names of FileUtils methods that accept one or -more keyword arguments: - - FileUtils.commands.sort.take(3) # => ["cd", "chdir", "chmod"] -## compare_file(a , b ) [](#method-c-compare_file) -Returns `true` if the contents of files `a` and `b` are identical, `false` -otherwise. - -Arguments `a` and `b` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -FileUtils.identical? and FileUtils.cmp are aliases for FileUtils.compare_file. - -Related: FileUtils.compare_stream. -## compare_stream(a , b ) [](#method-c-compare_stream) -Returns `true` if the contents of streams `a` and `b` are identical, `false` -otherwise. - -Arguments `a` and `b` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Related: FileUtils.compare_file. -## copy() [](#method-c-copy) -Copies files. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a file and `dest` is not the path to a directory, -copies `src` to `dest`: - - FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - FileUtils.cp('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is the path to a file and `dest` is the path to a directory, copies -`src` to `dest/src`: - - FileUtils.touch('src1.txt') - FileUtils.mkdir('dest1') - FileUtils.cp('src1.txt', 'dest1') - File.file?('dest1/src1.txt') # => true - -If `src` is an array of paths to files and `dest` is the path to a directory, -copies from each `src` to `dest`: - - src_file_paths = ['src2.txt', 'src2.dat'] - FileUtils.touch(src_file_paths) - FileUtils.mkdir('dest2') - FileUtils.cp(src_file_paths, 'dest2') - File.file?('dest2/src2.txt') # => true - File.file?('dest2/src2.dat') # => true - -Keyword arguments: - -* `preserve: true` - preserves file times. -* `noop: true` - does not copy files. -* `verbose: true` - prints an equivalent command: - - FileUtils.cp('src0.txt', 'dest0.txt', noop: true, verbose: true) - FileUtils.cp('src1.txt', 'dest1', noop: true, verbose: true) - FileUtils.cp(src_file_paths, 'dest2', noop: true, verbose: true) - - Output: - - cp src0.txt dest0.txt - cp src1.txt dest1 - cp src2.txt src2.dat dest2 - -Raises an exception if `src` is a directory. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## copy_entry(src , dest , preserve false, dereference_root false, remove_destination false) [](#method-c-copy_entry) -Recursively copies files from `src` to `dest`. - -Arguments `src` and `dest` should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a file, copies `src` to `dest`: - - FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - FileUtils.copy_entry('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is a directory, recursively copies `src` to `dest`: - - tree('src1') - # => src1 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - FileUtils.copy_entry('src1', 'dest1') - tree('dest1') - # => dest1 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - -The recursive copying preserves file types for regular files, directories, and -symbolic links; other file types (FIFO streams, device files, etc.) are not -supported. - -Keyword arguments: - -* `dereference_root: true` - if `src` is a symbolic link, follows the link. -* `preserve: true` - preserves file times. -* `remove_destination: true` - removes `dest` before copying files. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## copy_file(src , dest , preserve false, dereference true) [](#method-c-copy_file) -Copies file from `src` to `dest`, which should not be directories. - -Arguments `src` and `dest` should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -Examples: - - FileUtils.touch('src0.txt') - FileUtils.copy_file('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -Keyword arguments: - -* `dereference: false` - if `src` is a symbolic link, does not follow the - link. -* `preserve: true` - preserves file times. -* `remove_destination: true` - removes `dest` before copying files. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## copy_stream(src , dest ) [](#method-c-copy_stream) -Copies IO stream `src` to IO stream `dest` via -[IO.copy_stream](rdoc-ref:IO.copy_stream). - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## cp(src , dest , preserve: nil, noop: nil, verbose: nil) [](#method-c-cp) -Copies files. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a file and `dest` is not the path to a directory, -copies `src` to `dest`: - - FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - FileUtils.cp('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is the path to a file and `dest` is the path to a directory, copies -`src` to `dest/src`: - - FileUtils.touch('src1.txt') - FileUtils.mkdir('dest1') - FileUtils.cp('src1.txt', 'dest1') - File.file?('dest1/src1.txt') # => true - -If `src` is an array of paths to files and `dest` is the path to a directory, -copies from each `src` to `dest`: - - src_file_paths = ['src2.txt', 'src2.dat'] - FileUtils.touch(src_file_paths) - FileUtils.mkdir('dest2') - FileUtils.cp(src_file_paths, 'dest2') - File.file?('dest2/src2.txt') # => true - File.file?('dest2/src2.dat') # => true - -Keyword arguments: - -* `preserve: true` - preserves file times. -* `noop: true` - does not copy files. -* `verbose: true` - prints an equivalent command: - - FileUtils.cp('src0.txt', 'dest0.txt', noop: true, verbose: true) - FileUtils.cp('src1.txt', 'dest1', noop: true, verbose: true) - FileUtils.cp(src_file_paths, 'dest2', noop: true, verbose: true) - - Output: - - cp src0.txt dest0.txt - cp src1.txt dest1 - cp src2.txt src2.dat dest2 - -Raises an exception if `src` is a directory. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## cp_lr(src , dest , noop: nil, verbose: nil, dereference_root: true, remove_destination: false) [](#method-c-cp_lr) -Creates [hard links](https://en.wikipedia.org/wiki/Hard_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a directory and `dest` does not exist, creates links -`dest` and descendents pointing to `src` and its descendents: - - tree('src0') - # => src0 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - File.exist?('dest0') # => false - FileUtils.cp_lr('src0', 'dest0') - tree('dest0') - # => dest0 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - -If `src` and `dest` are both paths to directories, creates links `dest/src` -and descendents pointing to `src` and its descendents: - - tree('src1') - # => src1 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - FileUtils.mkdir('dest1') - FileUtils.cp_lr('src1', 'dest1') - tree('dest1') - # => dest1 - # `-- src1 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - -If `src` is an array of paths to entries and `dest` is the path to a -directory, for each path `filepath` in `src`, creates a link at -`dest/filepath` pointing to that path: - - tree('src2') - # => src2 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - FileUtils.mkdir('dest2') - FileUtils.cp_lr(['src2/sub0', 'src2/sub1'], 'dest2') - tree('dest2') - # => dest2 - # |-- sub0 - # | |-- src0.txt - # | `-- src1.txt - # `-- sub1 - # |-- src2.txt - # `-- src3.txt - -Keyword arguments: - -* `dereference_root: false` - if `src` is a symbolic link, does not - dereference it. -* `noop: true` - does not create links. -* `remove_destination: true` - removes `dest` before creating links. -* `verbose: true` - prints an equivalent command: - - FileUtils.cp_lr('src0', 'dest0', noop: true, verbose: true) - FileUtils.cp_lr('src1', 'dest1', noop: true, verbose: true) - FileUtils.cp_lr(['src2/sub0', 'src2/sub1'], 'dest2', noop: true, verbose: true) - - Output: - - cp -lr src0 dest0 - cp -lr src1 dest1 - cp -lr src2/sub0 src2/sub1 dest2 - -Raises an exception if `dest` is the path to an existing file or directory and -keyword argument `remove_destination: true` is not given. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## cp_r(src , dest , preserve: nil, noop: nil, verbose: nil, dereference_root: true, remove_destination: nil) [](#method-c-cp_r) -Recursively copies files. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -The mode, owner, and group are retained in the copy; to change those, use -FileUtils.install instead. - -If `src` is the path to a file and `dest` is not the path to a directory, -copies `src` to `dest`: - - FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - FileUtils.cp_r('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is the path to a file and `dest` is the path to a directory, copies -`src` to `dest/src`: - - FileUtils.touch('src1.txt') - FileUtils.mkdir('dest1') - FileUtils.cp_r('src1.txt', 'dest1') - File.file?('dest1/src1.txt') # => true - -If `src` is the path to a directory and `dest` does not exist, recursively -copies `src` to `dest`: - - tree('src2') - # => src2 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - FileUtils.exist?('dest2') # => false - FileUtils.cp_r('src2', 'dest2') - tree('dest2') - # => dest2 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - -If `src` and `dest` are paths to directories, recursively copies `src` to -`dest/src`: - - tree('src3') - # => src3 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - FileUtils.mkdir('dest3') - FileUtils.cp_r('src3', 'dest3') - tree('dest3') - # => dest3 - # `-- src3 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - -If `src` is an array of paths and `dest` is a directory, recursively copies -from each path in `src` to `dest`; the paths in `src` may point to files -and/or directories. - -Keyword arguments: - -* `dereference_root: false` - if `src` is a symbolic link, does not - dereference it. -* `noop: true` - does not copy files. -* `preserve: true` - preserves file times. -* `remove_destination: true` - removes `dest` before copying files. -* `verbose: true` - prints an equivalent command: - - FileUtils.cp_r('src0.txt', 'dest0.txt', noop: true, verbose: true) - FileUtils.cp_r('src1.txt', 'dest1', noop: true, verbose: true) - FileUtils.cp_r('src2', 'dest2', noop: true, verbose: true) - FileUtils.cp_r('src3', 'dest3', noop: true, verbose: true) - - Output: - - cp -r src0.txt dest0.txt - cp -r src1.txt dest1 - cp -r src2 dest2 - cp -r src3 dest3 - -Raises an exception of `src` is the path to a directory and `dest` is the path -to a file. - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## getwd() [](#method-c-getwd) -Returns a string containing the path to the current directory: - - FileUtils.pwd # => "/rdoc/fileutils" - -Related: FileUtils.cd. -## have_option?(mid , opt ) [](#method-c-have_option?) -Returns `true` if method `mid` accepts the given option `opt`, `false` -otherwise; the arguments may be strings or symbols: - - FileUtils.have_option?(:chmod, :noop) # => true - FileUtils.have_option?('chmod', 'secure') # => false -**@return** [Boolean] - -## identical?() [](#method-c-identical?) -Returns `true` if the contents of files `a` and `b` are identical, `false` -otherwise. - -Arguments `a` and `b` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -FileUtils.identical? and FileUtils.cmp are aliases for FileUtils.compare_file. - -Related: FileUtils.compare_stream. -## install(src , dest , mode: nil, owner: nil, group: nil, preserve: nil, noop: nil, verbose: nil) [](#method-c-install) -Copies a file entry. See -[install(1)](https://man7.org/linux/man-pages/man1/install.1.html). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments); - -If the entry at `dest` does not exist, copies from `src` to `dest`: - - File.read('src0.txt') # => "aaa\n" - File.exist?('dest0.txt') # => false - FileUtils.install('src0.txt', 'dest0.txt') - File.read('dest0.txt') # => "aaa\n" - -If `dest` is a file entry, copies from `src` to `dest`, overwriting: - - File.read('src1.txt') # => "aaa\n" - File.read('dest1.txt') # => "bbb\n" - FileUtils.install('src1.txt', 'dest1.txt') - File.read('dest1.txt') # => "aaa\n" - -If `dest` is a directory entry, copies from `src` to `dest/src`, overwriting -if necessary: - - File.read('src2.txt') # => "aaa\n" - File.read('dest2/src2.txt') # => "bbb\n" - FileUtils.install('src2.txt', 'dest2') - File.read('dest2/src2.txt') # => "aaa\n" - -If `src` is an array of paths and `dest` points to a directory, copies each -path `path` in `src` to `dest/path`: - - File.file?('src3.txt') # => true - File.file?('src3.dat') # => true - FileUtils.mkdir('dest3') - FileUtils.install(['src3.txt', 'src3.dat'], 'dest3') - File.file?('dest3/src3.txt') # => true - File.file?('dest3/src3.dat') # => true - -Keyword arguments: - -* `group: *group`* - changes the group if not `nil`, using - [File.chown](rdoc-ref:File.chown). -* `mode: *permissions`* - changes the permissions. using - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not copy entries; returns `nil`. -* `owner: *owner`* - changes the owner if not `nil`, using - [File.chown](rdoc-ref:File.chown). -* `preserve: true` - preserve timestamps using - [File.utime](rdoc-ref:File.utime). -* `verbose: true` - prints an equivalent command: - - FileUtils.install('src0.txt', 'dest0.txt', noop: true, verbose: true) - FileUtils.install('src1.txt', 'dest1.txt', noop: true, verbose: true) - FileUtils.install('src2.txt', 'dest2', noop: true, verbose: true) - - Output: - - install -c src0.txt dest0.txt - install -c src1.txt dest1.txt - install -c src2.txt dest2 - -Related: [methods for copying](rdoc-ref:FileUtils@Copying). -## link() [](#method-c-link) -Creates [hard links](https://en.wikipedia.org/wiki/Hard_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -When `src` is the path to an existing file and `dest` is the path to a -non-existent file, creates a hard link at `dest` pointing to `src`; returns -zero: - - Dir.children('tmp0/') # => ["t.txt"] - Dir.children('tmp1/') # => [] - FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk') # => 0 - Dir.children('tmp1/') # => ["t.lnk"] - -When `src` is the path to an existing file and `dest` is the path to an -existing directory, creates a hard link at `dest/src` pointing to `src`; -returns zero: - - Dir.children('tmp2') # => ["t.dat"] - Dir.children('tmp3') # => [] - FileUtils.ln('tmp2/t.dat', 'tmp3') # => 0 - Dir.children('tmp3') # => ["t.dat"] - -When `src` is an array of paths to existing files and `dest` is the path to an -existing directory, then for each path `target` in `src`, creates a hard link -at `dest/target` pointing to `target`; returns `src`: - - Dir.children('tmp4/') # => [] - FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/') # => ["tmp0/t.txt", "tmp2/t.dat"] - Dir.children('tmp4/') # => ["t.dat", "t.txt"] - -Keyword arguments: - -* `force: true` - overwrites `dest` if it exists. -* `noop: true` - does not create links. -* `verbose: true` - prints an equivalent command: - - FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk', verbose: true) - FileUtils.ln('tmp2/t.dat', 'tmp3', verbose: true) - FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/', verbose: true) - - Output: - - ln tmp0/t.txt tmp1/t.lnk - ln tmp2/t.dat tmp3 - ln tmp0/t.txt tmp2/t.dat tmp4/ - -Raises an exception if `dest` is the path to an existing file and keyword -argument `force` is not `true`. - -Related: FileUtils.link_entry (has different options). -## link_entry(src , dest , dereference_root false, remove_destination false) [](#method-c-link_entry) -Creates [hard links](https://en.wikipedia.org/wiki/Hard_link); returns `nil`. - -Arguments `src` and `dest` should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to a file and `dest` does not exist, creates a hard link -at `dest` pointing to `src`: - - FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - FileUtils.link_entry('src0.txt', 'dest0.txt') - File.file?('dest0.txt') # => true - -If `src` is the path to a directory and `dest` does not exist, recursively -creates hard links at `dest` pointing to paths in `src`: - - FileUtils.mkdir_p(['src1/dir0', 'src1/dir1']) - src_file_paths = [ - 'src1/dir0/t0.txt', - 'src1/dir0/t1.txt', - 'src1/dir1/t2.txt', - 'src1/dir1/t3.txt', - ] - FileUtils.touch(src_file_paths) - File.directory?('dest1') # => true - FileUtils.link_entry('src1', 'dest1') - File.file?('dest1/dir0/t0.txt') # => true - File.file?('dest1/dir0/t1.txt') # => true - File.file?('dest1/dir1/t2.txt') # => true - File.file?('dest1/dir1/t3.txt') # => true - -Keyword arguments: - -* `dereference_root: true` - dereferences `src` if it is a symbolic link. -* `remove_destination: true` - removes `dest` before creating links. - -Raises an exception if `dest` is the path to an existing file or directory and -keyword argument `remove_destination: true` is not given. - -Related: FileUtils.ln (has different options). -## ln(src , dest , force: nil, noop: nil, verbose: nil) [](#method-c-ln) -Creates [hard links](https://en.wikipedia.org/wiki/Hard_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -When `src` is the path to an existing file and `dest` is the path to a -non-existent file, creates a hard link at `dest` pointing to `src`; returns -zero: - - Dir.children('tmp0/') # => ["t.txt"] - Dir.children('tmp1/') # => [] - FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk') # => 0 - Dir.children('tmp1/') # => ["t.lnk"] - -When `src` is the path to an existing file and `dest` is the path to an -existing directory, creates a hard link at `dest/src` pointing to `src`; -returns zero: - - Dir.children('tmp2') # => ["t.dat"] - Dir.children('tmp3') # => [] - FileUtils.ln('tmp2/t.dat', 'tmp3') # => 0 - Dir.children('tmp3') # => ["t.dat"] - -When `src` is an array of paths to existing files and `dest` is the path to an -existing directory, then for each path `target` in `src`, creates a hard link -at `dest/target` pointing to `target`; returns `src`: - - Dir.children('tmp4/') # => [] - FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/') # => ["tmp0/t.txt", "tmp2/t.dat"] - Dir.children('tmp4/') # => ["t.dat", "t.txt"] - -Keyword arguments: - -* `force: true` - overwrites `dest` if it exists. -* `noop: true` - does not create links. -* `verbose: true` - prints an equivalent command: - - FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk', verbose: true) - FileUtils.ln('tmp2/t.dat', 'tmp3', verbose: true) - FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/', verbose: true) - - Output: - - ln tmp0/t.txt tmp1/t.lnk - ln tmp2/t.dat tmp3 - ln tmp0/t.txt tmp2/t.dat tmp4/ - -Raises an exception if `dest` is the path to an existing file and keyword -argument `force` is not `true`. - -Related: FileUtils.link_entry (has different options). -## ln_s(src , dest , force: nil, relative: false, target_directory: true, noop: nil, verbose: nil) [](#method-c-ln_s) -Creates [symbolic links](https://en.wikipedia.org/wiki/Symbolic_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to an existing file: - -* When `dest` is the path to a non-existent file, creates a symbolic link at - `dest` pointing to `src`: - - FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - FileUtils.ln_s('src0.txt', 'dest0.txt') - File.symlink?('dest0.txt') # => true - -* When `dest` is the path to an existing file, creates a symbolic link at - `dest` pointing to `src` if and only if keyword argument `force: true` is - given (raises an exception otherwise): - - FileUtils.touch('src1.txt') - FileUtils.touch('dest1.txt') - FileUtils.ln_s('src1.txt', 'dest1.txt', force: true) - FileTest.symlink?('dest1.txt') # => true - - FileUtils.ln_s('src1.txt', 'dest1.txt') # Raises Errno::EEXIST. - -If `dest` is the path to a directory, creates a symbolic link at `dest/src` -pointing to `src`: - - FileUtils.touch('src2.txt') - FileUtils.mkdir('destdir2') - FileUtils.ln_s('src2.txt', 'destdir2') - File.symlink?('destdir2/src2.txt') # => true - -If `src` is an array of paths to existing files and `dest` is a directory, for -each child `child` in `src` creates a symbolic link `dest/child` pointing to -`child`: - - FileUtils.mkdir('srcdir3') - FileUtils.touch('srcdir3/src0.txt') - FileUtils.touch('srcdir3/src1.txt') - FileUtils.mkdir('destdir3') - FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3') - File.symlink?('destdir3/src0.txt') # => true - File.symlink?('destdir3/src1.txt') # => true - -Keyword arguments: - -* `force: true` - overwrites `dest` if it exists. -* `relative: false` - create links relative to `dest`. -* `noop: true` - does not create links. -* `verbose: true` - prints an equivalent command: - - FileUtils.ln_s('src0.txt', 'dest0.txt', noop: true, verbose: true) - FileUtils.ln_s('src1.txt', 'destdir1', noop: true, verbose: true) - FileUtils.ln_s('src2.txt', 'dest2.txt', force: true, noop: true, verbose: true) - FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3', noop: true, verbose: true) - - Output: - - ln -s src0.txt dest0.txt - ln -s src1.txt destdir1 - ln -sf src2.txt dest2.txt - ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3 - -Related: FileUtils.ln_sf. -## ln_sf(src , dest , noop: nil, verbose: nil) [](#method-c-ln_sf) -Like FileUtils.ln_s, but always with keyword argument `force: true` given. -## ln_sr(src , dest , target_directory: true, force: nil, noop: nil, verbose: nil) [](#method-c-ln_sr) -Like FileUtils.ln_s, but create links relative to `dest`. -## makedirs() [](#method-c-makedirs) -Creates directories at the paths in the given `list` (a single path or an -array of paths), also creating ancestor directories as needed; returns `list` -if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, creates a directory at each `path` in `list`, along -with any needed ancestor directories, by calling: `Dir.mkdir(path, mode)`; see -[Dir.mkdir](rdoc-ref:Dir.mkdir): - - FileUtils.mkdir_p(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"] - FileUtils.mkdir_p('tmp4/tmp5') # => ["tmp4/tmp5"] - -Keyword arguments: - -* `mode: *mode`* - also calls `File.chmod(mode, path)`; see - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not create directories. -* `verbose: true` - prints an equivalent command: - - FileUtils.mkdir_p(%w[tmp0 tmp1], verbose: true) - FileUtils.mkdir_p(%w[tmp2 tmp3], mode: 0700, verbose: true) - - Output: - - mkdir -p tmp0 tmp1 - mkdir -p -m 700 tmp2 tmp3 - -Raises an exception if for any reason a directory cannot be created. - -FileUtils.mkpath and FileUtils.makedirs are aliases for FileUtils.mkdir_p. - -Related: FileUtils.mkdir. -## mkdir(list , mode: nil, noop: nil, verbose: nil) [](#method-c-mkdir) -Creates directories at the paths in the given `list` (a single path or an -array of paths); returns `list` if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, creates a directory at each `path` in `list` by -calling: `Dir.mkdir(path, mode)`; see [Dir.mkdir](rdoc-ref:Dir.mkdir): - - FileUtils.mkdir(%w[tmp0 tmp1]) # => ["tmp0", "tmp1"] - FileUtils.mkdir('tmp4') # => ["tmp4"] - -Keyword arguments: - -* `mode: *mode`* - also calls `File.chmod(mode, path)`; see - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not create directories. -* `verbose: true` - prints an equivalent command: - - FileUtils.mkdir(%w[tmp0 tmp1], verbose: true) - FileUtils.mkdir(%w[tmp2 tmp3], mode: 0700, verbose: true) - - Output: - - mkdir tmp0 tmp1 - mkdir -m 700 tmp2 tmp3 - -Raises an exception if any path points to an existing file or directory, or if -for any reason a directory cannot be created. - -Related: FileUtils.mkdir_p. -## mkdir_p(list , mode: nil, noop: nil, verbose: nil) [](#method-c-mkdir_p) -Creates directories at the paths in the given `list` (a single path or an -array of paths), also creating ancestor directories as needed; returns `list` -if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, creates a directory at each `path` in `list`, along -with any needed ancestor directories, by calling: `Dir.mkdir(path, mode)`; see -[Dir.mkdir](rdoc-ref:Dir.mkdir): - - FileUtils.mkdir_p(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"] - FileUtils.mkdir_p('tmp4/tmp5') # => ["tmp4/tmp5"] - -Keyword arguments: - -* `mode: *mode`* - also calls `File.chmod(mode, path)`; see - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not create directories. -* `verbose: true` - prints an equivalent command: - - FileUtils.mkdir_p(%w[tmp0 tmp1], verbose: true) - FileUtils.mkdir_p(%w[tmp2 tmp3], mode: 0700, verbose: true) - - Output: - - mkdir -p tmp0 tmp1 - mkdir -p -m 700 tmp2 tmp3 - -Raises an exception if for any reason a directory cannot be created. - -FileUtils.mkpath and FileUtils.makedirs are aliases for FileUtils.mkdir_p. - -Related: FileUtils.mkdir. -## mkpath() [](#method-c-mkpath) -Creates directories at the paths in the given `list` (a single path or an -array of paths), also creating ancestor directories as needed; returns `list` -if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, creates a directory at each `path` in `list`, along -with any needed ancestor directories, by calling: `Dir.mkdir(path, mode)`; see -[Dir.mkdir](rdoc-ref:Dir.mkdir): - - FileUtils.mkdir_p(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"] - FileUtils.mkdir_p('tmp4/tmp5') # => ["tmp4/tmp5"] - -Keyword arguments: - -* `mode: *mode`* - also calls `File.chmod(mode, path)`; see - [File.chmod](rdoc-ref:File.chmod). -* `noop: true` - does not create directories. -* `verbose: true` - prints an equivalent command: - - FileUtils.mkdir_p(%w[tmp0 tmp1], verbose: true) - FileUtils.mkdir_p(%w[tmp2 tmp3], mode: 0700, verbose: true) - - Output: - - mkdir -p tmp0 tmp1 - mkdir -p -m 700 tmp2 tmp3 - -Raises an exception if for any reason a directory cannot be created. - -FileUtils.mkpath and FileUtils.makedirs are aliases for FileUtils.mkdir_p. - -Related: FileUtils.mkdir. -## move() [](#method-c-move) -Moves entries. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` and `dest` are on different file systems, first copies, then removes -`src`. - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -If `src` is the path to a single file or directory and `dest` does not exist, -moves `src` to `dest`: - - tree('src0') - # => src0 - # |-- src0.txt - # `-- src1.txt - File.exist?('dest0') # => false - FileUtils.mv('src0', 'dest0') - File.exist?('src0') # => false - tree('dest0') - # => dest0 - # |-- src0.txt - # `-- src1.txt - -If `src` is an array of paths to files and directories and `dest` is the path -to a directory, copies from each path in the array to `dest`: - - File.file?('src1.txt') # => true - tree('src1') - # => src1 - # |-- src.dat - # `-- src.txt - Dir.empty?('dest1') # => true - FileUtils.mv(['src1.txt', 'src1'], 'dest1') - tree('dest1') - # => dest1 - # |-- src1 - # | |-- src.dat - # | `-- src.txt - # `-- src1.txt - -Keyword arguments: - -* `force: true` - if the move includes removing `src` (that is, if `src` and - `dest` are on different file systems), ignores raised exceptions of - StandardError and its descendants. -* `noop: true` - does not move files. -* `secure: true` - removes `src` securely; see details at - FileUtils.remove_entry_secure. -* `verbose: true` - prints an equivalent command: - - FileUtils.mv('src0', 'dest0', noop: true, verbose: true) - FileUtils.mv(['src1.txt', 'src1'], 'dest1', noop: true, verbose: true) - - Output: - - mv src0 dest0 - mv src1.txt src1 dest1 -## mv(src , dest , force: nil, noop: nil, verbose: nil, secure: nil) [](#method-c-mv) -Moves entries. - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` and `dest` are on different file systems, first copies, then removes -`src`. - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -If `src` is the path to a single file or directory and `dest` does not exist, -moves `src` to `dest`: - - tree('src0') - # => src0 - # |-- src0.txt - # `-- src1.txt - File.exist?('dest0') # => false - FileUtils.mv('src0', 'dest0') - File.exist?('src0') # => false - tree('dest0') - # => dest0 - # |-- src0.txt - # `-- src1.txt - -If `src` is an array of paths to files and directories and `dest` is the path -to a directory, copies from each path in the array to `dest`: - - File.file?('src1.txt') # => true - tree('src1') - # => src1 - # |-- src.dat - # `-- src.txt - Dir.empty?('dest1') # => true - FileUtils.mv(['src1.txt', 'src1'], 'dest1') - tree('dest1') - # => dest1 - # |-- src1 - # | |-- src.dat - # | `-- src.txt - # `-- src1.txt - -Keyword arguments: - -* `force: true` - if the move includes removing `src` (that is, if `src` and - `dest` are on different file systems), ignores raised exceptions of - StandardError and its descendants. -* `noop: true` - does not move files. -* `secure: true` - removes `src` securely; see details at - FileUtils.remove_entry_secure. -* `verbose: true` - prints an equivalent command: - - FileUtils.mv('src0', 'dest0', noop: true, verbose: true) - FileUtils.mv(['src1.txt', 'src1'], 'dest1', noop: true, verbose: true) - - Output: - - mv src0 dest0 - mv src1.txt src1 dest1 -## options() [](#method-c-options) -Returns an array of the string keyword names: - - FileUtils.options.take(3) # => ["noop", "verbose", "force"] -## options_of(mid ) [](#method-c-options_of) -Returns an array of the string keyword name for method `mid`; the argument may -be a string or a symbol: - - FileUtils.options_of(:rm) # => ["force", "noop", "verbose"] - FileUtils.options_of('mv') # => ["force", "noop", "verbose", "secure"] -## private_module_function(name ) [](#method-c-private_module_function) -:nodoc: -## pwd() [](#method-c-pwd) -Returns a string containing the path to the current directory: - - FileUtils.pwd # => "/rdoc/fileutils" - -Related: FileUtils.cd. -## remove() [](#method-c-remove) -Removes entries at the paths in the given `list` (a single path or an array of -paths) returns `list`, if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, removes files at the paths given in `list`: - - FileUtils.touch(['src0.txt', 'src0.dat']) - FileUtils.rm(['src0.dat', 'src0.txt']) # => ["src0.dat", "src0.txt"] - -Keyword arguments: - -* `force: true` - ignores raised exceptions of StandardError and its - descendants. -* `noop: true` - does not remove files; returns `nil`. -* `verbose: true` - prints an equivalent command: - - FileUtils.rm(['src0.dat', 'src0.txt'], noop: true, verbose: true) - - Output: - - rm src0.dat src0.txt - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## remove_dir(path , force false) [](#method-c-remove_dir) -Recursively removes the directory entry given by `path`, which should be the -entry for a regular file, a symbolic link, or a directory. - -Argument `path` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Optional argument `force` specifies whether to ignore raised exceptions of -StandardError and its descendants. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## remove_entry(path , force false) [](#method-c-remove_entry) -Removes the entry given by `path`, which should be the entry for a regular -file, a symbolic link, or a directory. - -Argument `path` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Optional argument `force` specifies whether to ignore raised exceptions of -StandardError and its descendants. - -Related: FileUtils.remove_entry_secure. -## remove_entry_secure(path , force false) [](#method-c-remove_entry_secure) -Securely removes the entry given by `path`, which should be the entry for a -regular file, a symbolic link, or a directory. - -Argument `path` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Avoids a local vulnerability that can exist in certain circumstances; see -[Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -Optional argument `force` specifies whether to ignore raised exceptions of -StandardError and its descendants. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## remove_file(path , force false) [](#method-c-remove_file) -Removes the file entry given by `path`, which should be the entry for a -regular file or a symbolic link. - -Argument `path` should be [interpretable as a -path](rdoc-ref:FileUtils@Path+Arguments). - -Optional argument `force` specifies whether to ignore raised exceptions of -StandardError and its descendants. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rm(list , force: nil, noop: nil, verbose: nil) [](#method-c-rm) -Removes entries at the paths in the given `list` (a single path or an array of -paths) returns `list`, if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, removes files at the paths given in `list`: - - FileUtils.touch(['src0.txt', 'src0.dat']) - FileUtils.rm(['src0.dat', 'src0.txt']) # => ["src0.dat", "src0.txt"] - -Keyword arguments: - -* `force: true` - ignores raised exceptions of StandardError and its - descendants. -* `noop: true` - does not remove files; returns `nil`. -* `verbose: true` - prints an equivalent command: - - FileUtils.rm(['src0.dat', 'src0.txt'], noop: true, verbose: true) - - Output: - - rm src0.dat src0.txt - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rm_f(list , noop: nil, verbose: nil) [](#method-c-rm_f) -Equivalent to: - - FileUtils.rm(list, force: true, **kwargs) - -Argument `list` (a single path or an array of paths) should be [interpretable -as paths](rdoc-ref:FileUtils@Path+Arguments). - -See FileUtils.rm for keyword arguments. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rm_r(list , force: nil, noop: nil, verbose: nil, secure: nil) [](#method-c-rm_r) -Removes entries at the paths in the given `list` (a single path or an array of -paths); returns `list`, if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -For each file path, removes the file at that path: - - FileUtils.touch(['src0.txt', 'src0.dat']) - FileUtils.rm_r(['src0.dat', 'src0.txt']) - File.exist?('src0.txt') # => false - File.exist?('src0.dat') # => false - -For each directory path, recursively removes files and directories: - - tree('src1') - # => src1 - # |-- dir0 - # | |-- src0.txt - # | `-- src1.txt - # `-- dir1 - # |-- src2.txt - # `-- src3.txt - FileUtils.rm_r('src1') - File.exist?('src1') # => false - -Keyword arguments: - -* `force: true` - ignores raised exceptions of StandardError and its - descendants. -* `noop: true` - does not remove entries; returns `nil`. -* `secure: true` - removes `src` securely; see details at - FileUtils.remove_entry_secure. -* `verbose: true` - prints an equivalent command: - - FileUtils.rm_r(['src0.dat', 'src0.txt'], noop: true, verbose: true) - FileUtils.rm_r('src1', noop: true, verbose: true) - - Output: - - rm -r src0.dat src0.txt - rm -r src1 - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rm_rf(list , noop: nil, verbose: nil, secure: nil) [](#method-c-rm_rf) -Equivalent to: - - FileUtils.rm_r(list, force: true, **kwargs) - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -See FileUtils.rm_r for keyword arguments. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rmdir(list , parents: nil, noop: nil, verbose: nil) [](#method-c-rmdir) -Removes directories at the paths in the given `list` (a single path or an -array of paths); returns `list`, if it is an array, `[list]` otherwise. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -With no keyword arguments, removes the directory at each `path` in `list`, by -calling: `Dir.rmdir(path)`; see [Dir.rmdir](rdoc-ref:Dir.rmdir): - - FileUtils.rmdir(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"] - FileUtils.rmdir('tmp4/tmp5') # => ["tmp4/tmp5"] - -Keyword arguments: - -* `parents: true` - removes successive ancestor directories if empty. -* `noop: true` - does not remove directories. -* `verbose: true` - prints an equivalent command: - - FileUtils.rmdir(%w[tmp0/tmp1 tmp2/tmp3], parents: true, verbose: true) - FileUtils.rmdir('tmp4/tmp5', parents: true, verbose: true) - - Output: - - rmdir -p tmp0/tmp1 tmp2/tmp3 - rmdir -p tmp4/tmp5 - -Raises an exception if a directory does not exist or if for any reason a -directory cannot be removed. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## rmtree() [](#method-c-rmtree) -Equivalent to: - - FileUtils.rm_r(list, force: true, **kwargs) - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -May cause a local vulnerability if not called with keyword argument `secure: -true`; see [Avoiding the TOCTTOU -Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability). - -See FileUtils.rm_r for keyword arguments. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## safe_unlink() [](#method-c-safe_unlink) -Equivalent to: - - FileUtils.rm(list, force: true, **kwargs) - -Argument `list` (a single path or an array of paths) should be [interpretable -as paths](rdoc-ref:FileUtils@Path+Arguments). - -See FileUtils.rm for keyword arguments. - -Related: [methods for deleting](rdoc-ref:FileUtils@Deleting). -## symlink() [](#method-c-symlink) -Creates [symbolic links](https://en.wikipedia.org/wiki/Symbolic_link). - -Arguments `src` (a single path or an array of paths) and `dest` (a single -path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments). - -If `src` is the path to an existing file: - -* When `dest` is the path to a non-existent file, creates a symbolic link at - `dest` pointing to `src`: - - FileUtils.touch('src0.txt') - File.exist?('dest0.txt') # => false - FileUtils.ln_s('src0.txt', 'dest0.txt') - File.symlink?('dest0.txt') # => true - -* When `dest` is the path to an existing file, creates a symbolic link at - `dest` pointing to `src` if and only if keyword argument `force: true` is - given (raises an exception otherwise): - - FileUtils.touch('src1.txt') - FileUtils.touch('dest1.txt') - FileUtils.ln_s('src1.txt', 'dest1.txt', force: true) - FileTest.symlink?('dest1.txt') # => true - - FileUtils.ln_s('src1.txt', 'dest1.txt') # Raises Errno::EEXIST. - -If `dest` is the path to a directory, creates a symbolic link at `dest/src` -pointing to `src`: - - FileUtils.touch('src2.txt') - FileUtils.mkdir('destdir2') - FileUtils.ln_s('src2.txt', 'destdir2') - File.symlink?('destdir2/src2.txt') # => true - -If `src` is an array of paths to existing files and `dest` is a directory, for -each child `child` in `src` creates a symbolic link `dest/child` pointing to -`child`: - - FileUtils.mkdir('srcdir3') - FileUtils.touch('srcdir3/src0.txt') - FileUtils.touch('srcdir3/src1.txt') - FileUtils.mkdir('destdir3') - FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3') - File.symlink?('destdir3/src0.txt') # => true - File.symlink?('destdir3/src1.txt') # => true - -Keyword arguments: - -* `force: true` - overwrites `dest` if it exists. -* `relative: false` - create links relative to `dest`. -* `noop: true` - does not create links. -* `verbose: true` - prints an equivalent command: - - FileUtils.ln_s('src0.txt', 'dest0.txt', noop: true, verbose: true) - FileUtils.ln_s('src1.txt', 'destdir1', noop: true, verbose: true) - FileUtils.ln_s('src2.txt', 'dest2.txt', force: true, noop: true, verbose: true) - FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3', noop: true, verbose: true) - - Output: - - ln -s src0.txt dest0.txt - ln -s src1.txt destdir1 - ln -sf src2.txt dest2.txt - ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3 - -Related: FileUtils.ln_sf. -## touch(list , noop: nil, verbose: nil, mtime: nil, nocreate: nil) [](#method-c-touch) -Updates modification times (mtime) and access times (atime) of the entries -given by the paths in `list` (a single path or an array of paths); returns -`list` if it is an array, `[list]` otherwise. - -By default, creates an empty file for any path to a non-existent entry; use -keyword argument `nocreate` to raise an exception instead. - -Argument `list` or its elements should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments). - -Examples: - - # Single path. - f = File.new('src0.txt') # Existing file. - f.atime # => 2022-06-10 11:11:21.200277 -0700 - f.mtime # => 2022-06-10 11:11:21.200277 -0700 - FileUtils.touch('src0.txt') - f = File.new('src0.txt') - f.atime # => 2022-06-11 08:28:09.8185343 -0700 - f.mtime # => 2022-06-11 08:28:09.8185343 -0700 - - # Array of paths. - FileUtils.touch(['src0.txt', 'src0.dat']) - -Keyword arguments: - -* `mtime: *time`* - sets the entry's mtime to the given time, instead of the - current time. -* `nocreate: true` - raises an exception if the entry does not exist. -* `noop: true` - does not touch entries; returns `nil`. -* `verbose: true` - prints an equivalent command: - - FileUtils.touch('src0.txt', noop: true, verbose: true) - FileUtils.touch(['src0.txt', 'src0.dat'], noop: true, verbose: true) - FileUtils.touch(path, noop: true, verbose: true) - - Output: - - touch src0.txt - touch src0.txt src0.dat - touch src0.txt - -Related: FileUtils.uptodate?. -## uptodate?(new , old_list ) [](#method-c-uptodate?) -Returns `true` if the file at path `new` is newer than all the files at paths -in array `old_list`; `false` otherwise. - -Argument `new` and the elements of `old_list` should be [interpretable as -paths](rdoc-ref:FileUtils@Path+Arguments): - - FileUtils.uptodate?('Rakefile', ['Gemfile', 'README.md']) # => true - FileUtils.uptodate?('Gemfile', ['Rakefile', 'README.md']) # => false - -A non-existent file is considered to be infinitely old. - -Related: FileUtils.touch. -**@return** [Boolean] - - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/FileUtils/DryRun.md b/example/ruby/FileUtils/DryRun.md deleted file mode 100644 index 0d1030d..0000000 --- a/example/ruby/FileUtils/DryRun.md +++ /dev/null @@ -1,78 +0,0 @@ -# Module: FileUtils::DryRun - -**Extended by:** FileUtils::DryRun - -**Includes:** FileUtils, FileUtils::LowMethods - - -This module has all methods of FileUtils module, but never changes -files/directories, with printing message before acting. This equates to -passing the `:noop` and `:verbose` flag to methods in FileUtils. - - -# Class Methods -## apply_mask(mode , user_mask , op , mode_mask ) [](#method-c-apply_mask) -:nodoc: -## fu_get_gid(group ) [](#method-c-fu_get_gid) -:nodoc: -## fu_get_uid(user ) [](#method-c-fu_get_uid) -:nodoc: -## fu_have_symlink?() [](#method-c-fu_have_symlink?) -:nodoc: -**@return** [Boolean] - -## fu_mkdir(path , mode ) [](#method-c-fu_mkdir) -:nodoc: -## fu_mode(mode , path ) [](#method-c-fu_mode) -:nodoc: -## fu_stat_identical_entry?(a , b ) [](#method-c-fu_stat_identical_entry?) -:nodoc: -**@return** [Boolean] - -## mode_to_s(mode ) [](#method-c-mode_to_s) -:nodoc: -## remove_trailing_slash(dir ) [](#method-c-remove_trailing_slash) -:nodoc: -## symbolic_modes_to_i(mode_sym , path ) [](#method-c-symbolic_modes_to_i) -:nodoc: -## user_mask(target ) [](#method-c-user_mask) -:nodoc: - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/FileUtils/Entry_.md b/example/ruby/FileUtils/Entry_.md deleted file mode 100644 index 432051a..0000000 --- a/example/ruby/FileUtils/Entry_.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: FileUtils::Entry_ -**Inherits:** Object - -**Includes:** FileUtils::StreamUtils_ - - -:nodoc: internal use only - - - -#Instance Methods -## blockdev?() [](#method-i-blockdev?) - -**@return** [Boolean] - -## chardev?() [](#method-i-chardev?) - -**@return** [Boolean] - -## chmod(mode) [](#method-i-chmod) - -## chown(uid, gid) [](#method-i-chown) - -## copy(dest) [](#method-i-copy) - -## copy_file(dest) [](#method-i-copy_file) - -## copy_metadata(path) [](#method-i-copy_metadata) - -## dereference?() [](#method-i-dereference?) - -**@return** [Boolean] - -## directory?() [](#method-i-directory?) - -**@return** [Boolean] - -## door?() [](#method-i-door?) - -**@return** [Boolean] - -## entries() [](#method-i-entries) - -## exist?() [](#method-i-exist?) - -**@return** [Boolean] - -## file?() [](#method-i-file?) - -**@return** [Boolean] - -## initialize(a, bnil, dereffalse) [](#method-i-initialize) - -**@return** [Entry_] a new instance of Entry_ - -## inspect() [](#method-i-inspect) - -## link(dest) [](#method-i-link) - -## lstat() [](#method-i-lstat) - -## lstat!() [](#method-i-lstat!) - -## path() [](#method-i-path) - -## pipe?() [](#method-i-pipe?) - -**@return** [Boolean] - -## platform_support() [](#method-i-platform_support) - -## postorder_traverse() [](#method-i-postorder_traverse) - -**@yield** [_self] - -**@yieldparam** [FileUtils::Entry_] the object that the method was called on - -## prefix() [](#method-i-prefix) - -## preorder_traverse() [](#method-i-preorder_traverse) - -## rel() [](#method-i-rel) - -## remove() [](#method-i-remove) - -## remove_dir1() [](#method-i-remove_dir1) - -## remove_file() [](#method-i-remove_file) - -## socket?() [](#method-i-socket?) - -**@return** [Boolean] - -## stat() [](#method-i-stat) - -## stat!() [](#method-i-stat!) - -## symlink?() [](#method-i-symlink?) - -**@return** [Boolean] - -## wrap_traverse(pre, post) [](#method-i-wrap_traverse) - diff --git a/example/ruby/FileUtils/LowMethods.md b/example/ruby/FileUtils/LowMethods.md deleted file mode 100644 index 66d8fd4..0000000 --- a/example/ruby/FileUtils/LowMethods.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: FileUtils::LowMethods - - -:nodoc: internal use only - - - diff --git a/example/ruby/FileUtils/NoWrite.md b/example/ruby/FileUtils/NoWrite.md deleted file mode 100644 index e836eea..0000000 --- a/example/ruby/FileUtils/NoWrite.md +++ /dev/null @@ -1,78 +0,0 @@ -# Module: FileUtils::NoWrite - -**Extended by:** FileUtils::NoWrite - -**Includes:** FileUtils, FileUtils::LowMethods - - -This module has all methods of FileUtils module, but never changes -files/directories. This equates to passing the `:noop` flag to methods in -FileUtils. - - -# Class Methods -## apply_mask(mode , user_mask , op , mode_mask ) [](#method-c-apply_mask) -:nodoc: -## fu_get_gid(group ) [](#method-c-fu_get_gid) -:nodoc: -## fu_get_uid(user ) [](#method-c-fu_get_uid) -:nodoc: -## fu_have_symlink?() [](#method-c-fu_have_symlink?) -:nodoc: -**@return** [Boolean] - -## fu_mkdir(path , mode ) [](#method-c-fu_mkdir) -:nodoc: -## fu_mode(mode , path ) [](#method-c-fu_mode) -:nodoc: -## fu_stat_identical_entry?(a , b ) [](#method-c-fu_stat_identical_entry?) -:nodoc: -**@return** [Boolean] - -## mode_to_s(mode ) [](#method-c-mode_to_s) -:nodoc: -## remove_trailing_slash(dir ) [](#method-c-remove_trailing_slash) -:nodoc: -## symbolic_modes_to_i(mode_sym , path ) [](#method-c-symbolic_modes_to_i) -:nodoc: -## user_mask(target ) [](#method-c-user_mask) -:nodoc: - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/FileUtils/StreamUtils_.md b/example/ruby/FileUtils/StreamUtils_.md deleted file mode 100644 index 59b003c..0000000 --- a/example/ruby/FileUtils/StreamUtils_.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: FileUtils::StreamUtils_ - - -:nodoc: - - - diff --git a/example/ruby/FileUtils/Verbose.md b/example/ruby/FileUtils/Verbose.md deleted file mode 100644 index d4f95fe..0000000 --- a/example/ruby/FileUtils/Verbose.md +++ /dev/null @@ -1,78 +0,0 @@ -# Module: FileUtils::Verbose - -**Extended by:** FileUtils::Verbose - -**Includes:** FileUtils - - -This module has all methods of FileUtils module, but it outputs messages -before acting. This equates to passing the `:verbose` flag to methods in -FileUtils. - - -# Class Methods -## apply_mask(mode , user_mask , op , mode_mask ) [](#method-c-apply_mask) -:nodoc: -## fu_get_gid(group ) [](#method-c-fu_get_gid) -:nodoc: -## fu_get_uid(user ) [](#method-c-fu_get_uid) -:nodoc: -## fu_have_symlink?() [](#method-c-fu_have_symlink?) -:nodoc: -**@return** [Boolean] - -## fu_mkdir(path , mode ) [](#method-c-fu_mkdir) -:nodoc: -## fu_mode(mode , path ) [](#method-c-fu_mode) -:nodoc: -## fu_stat_identical_entry?(a , b ) [](#method-c-fu_stat_identical_entry?) -:nodoc: -**@return** [Boolean] - -## mode_to_s(mode ) [](#method-c-mode_to_s) -:nodoc: -## remove_trailing_slash(dir ) [](#method-c-remove_trailing_slash) -:nodoc: -## symbolic_modes_to_i(mode_sym , path ) [](#method-c-symbolic_modes_to_i) -:nodoc: -## user_mask(target ) [](#method-c-user_mask) -:nodoc: - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/Find.md b/example/ruby/Find.md deleted file mode 100644 index 89e99b9..0000000 --- a/example/ruby/Find.md +++ /dev/null @@ -1,40 +0,0 @@ -# Module: Find - - -The `Find` module supports the top-down traversal of a set of file paths. - -For example, to total the size of all files under your home directory, -ignoring anything in a "dot" directory (e.g. $HOME/.ssh): - - require 'find' - - total_size = 0 - - Find.find(ENV["HOME"]) do |path| - if FileTest.directory?(path) - if File.basename(path).start_with?('.') - Find.prune # Don't look any further into this directory. - else - next - end - else - total_size += FileTest.size(path) - end - end - - -# Class Methods -## find(*paths , ignore_error: true) [](#method-c-find) -Calls the associated block with the name of every file and directory listed as -arguments, then recursively on their subdirectories, and so on. - -Returns an enumerator if no block is given. - -See the `Find` module documentation for an example. -## prune() [](#method-c-prune) -Skips the current file or directory, restarting the loop with the next entry. -If the current file is a directory, that directory will not be recursively -entered. Meaningful only within the block associated with Find::find. - -See the `Find` module documentation for an example. - diff --git a/example/ruby/FindDirSpecs.md b/example/ruby/FindDirSpecs.md deleted file mode 100644 index 5ebe49a..0000000 --- a/example/ruby/FindDirSpecs.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: FindDirSpecs - - - - -# Class Methods -## create_mock_dirs() [](#method-c-create_mock_dirs) -## delete_mock_dirs() [](#method-c-delete_mock_dirs) -## expected_paths() [](#method-c-expected_paths) -## mock_dir(dirs ['find_specs_mock']) [](#method-c-mock_dir) -## mock_dir_files() [](#method-c-mock_dir_files) -The names of the fixture directories and files used by various Find specs. - diff --git a/example/ruby/FindMethodComments.md b/example/ruby/FindMethodComments.md deleted file mode 100644 index 0fb69cb..0000000 --- a/example/ruby/FindMethodComments.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: FindMethodComments -**Inherits:** Prism::Visitor - - - - - -#Instance Methods -## initialize(target, comments, nesting[]) [](#method-i-initialize) - -**@return** [FindMethodComments] a new instance of FindMethodComments - -## visit_class_node(node) [](#method-i-visit_class_node) - -## visit_def_node(node) [](#method-i-visit_def_node) - -## visit_module_node(node) [](#method-i-visit_module_node) -These visit methods are specific to each class. Defining a visitor allows you -to group functionality that applies to all node types into a single class. You -can find which method corresponds to which node type by looking at the class -name, calling #type on the node, or by looking at the #accept method -definition on the node. - diff --git a/example/ruby/Float.md b/example/ruby/Float.md deleted file mode 100644 index 1725b88..0000000 --- a/example/ruby/Float.md +++ /dev/null @@ -1,814 +0,0 @@ -# Class: Float -**Inherits:** Numeric - - -****************************************************************** - - A \Float object represents a sometimes-inexact real number using the native - architecture's double-precision floating point representation. - - Floating point has a different arithmetic and is an inexact number. - So you should know its esoteric system. See following: - - - https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html - - https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rubys-floats-imprecise - - https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems - - You can create a \Float object explicitly with: - - - A {floating-point literal}[rdoc-ref:syntax/literals.rdoc@Float+Literals]. - - You can convert certain objects to Floats with: - - - \Method #Float. - - == What's Here - - First, what's elsewhere. \Class \Float: - - - Inherits from - {class Numeric}[rdoc-ref:Numeric@What-27s+Here] - and {class Object}[rdoc-ref:Object@What-27s+Here]. - - Includes {module Comparable}[rdoc-ref:Comparable@What-27s+Here]. - - Here, class \Float provides methods for: - - - {Querying}[rdoc-ref:Float@Querying] - - {Comparing}[rdoc-ref:Float@Comparing] - - {Converting}[rdoc-ref:Float@Converting] - - === Querying - - - #finite?: Returns whether +self+ is finite. - - #hash: Returns the integer hash code for +self+. - - #infinite?: Returns whether +self+ is infinite. - - #nan?: Returns whether +self+ is a NaN (not-a-number). - - === Comparing - - - #<: Returns whether +self+ is less than the given value. - - #<=: Returns whether +self+ is less than or equal to the given value. - - #<=>: Returns a number indicating whether +self+ is less than, equal - to, or greater than the given value. - - #== (aliased as #=== and #eql?): Returns whether +self+ is equal to - the given value. - - #>: Returns whether +self+ is greater than the given value. - - #>=: Returns whether +self+ is greater than or equal to the given value. - - === Converting - - - #% (aliased as #modulo): Returns +self+ modulo the given value. - - #*: Returns the product of +self+ and the given value. - - #**: Returns the value of +self+ raised to the power of the given value. - - #+: Returns the sum of +self+ and the given value. - - #-: Returns the difference of +self+ and the given value. - - #/: Returns the quotient of +self+ and the given value. - - #ceil: Returns the smallest number greater than or equal to +self+. - - #coerce: Returns a 2-element array containing the given value converted to a \Float - and +self+ - - #divmod: Returns a 2-element array containing the quotient and remainder - results of dividing +self+ by the given value. - - #fdiv: Returns the \Float result of dividing +self+ by the given value. - - #floor: Returns the greatest number smaller than or equal to +self+. - - #next_float: Returns the next-larger representable \Float. - - #prev_float: Returns the next-smaller representable \Float. - - #quo: Returns the quotient from dividing +self+ by the given value. - - #round: Returns +self+ rounded to the nearest value, to a given precision. - - #to_i (aliased as #to_int): Returns +self+ truncated to an Integer. - - #to_s (aliased as #inspect): Returns a string containing the place-value - representation of +self+ in the given radix. - - #truncate: Returns +self+ truncated to a given precision. - - - -#Instance Methods -## %(y) [](#method-i-%) -Returns `self` modulo `other` as a float. - -For float `f` and real number `r`, these expressions are equivalent: - - f % r - f-r*(f/r).floor - f.divmod(r)[1] - -See Numeric#divmod. - -Examples: - - 10.0 % 2 # => 0.0 - 10.0 % 3 # => 1.0 - 10.0 % 4 # => 2.0 - - 10.0 % -2 # => 0.0 - 10.0 % -3 # => -2.0 - 10.0 % -4 # => -2.0 - - 10.0 % 4.0 # => 2.0 - 10.0 % Rational(4, 1) # => 2.0 - -**@overload** [] - -## *(y) [](#method-i-*) -Returns a new Float which is the product of `self` and `other`: - - f = 3.14 - f * 2 # => 6.28 - f * 2.0 # => 6.28 - f * Rational(1, 2) # => 1.57 - f * Complex(2, 0) # => (6.28+0.0i) - -**@overload** [] - -## **(y) [](#method-i-**) -Raises `self` to the power of `other`: - - f = 3.14 - f ** 2 # => 9.8596 - f ** -2 # => 0.1014239928597509 - f ** 2.1 # => 11.054834900588839 - f ** Rational(2, 1) # => 9.8596 - f ** Complex(2, 0) # => (9.8596+0i) - -**@overload** [] - -## +(y) [](#method-i-+) -Returns a new Float which is the sum of `self` and `other`: - - f = 3.14 - f + 1 # => 4.140000000000001 - f + 1.0 # => 4.140000000000001 - f + Rational(1, 1) # => 4.140000000000001 - f + Complex(1, 0) # => (4.140000000000001+0i) - -**@overload** [] - -## -(y) [](#method-i--) -Returns a new Float which is the difference of `self` and `other`: - - f = 3.14 - f - 1 # => 2.14 - f - 1.0 # => 2.14 - f - Rational(1, 1) # => 2.14 - f - Complex(1, 0) # => (2.14+0i) - -**@overload** [] - -## -@() [](#method-i--@) -call-seq: - -float -> float - -Returns `self`, negated. - -## /(y) [](#method-i-/) -Returns a new Float which is the result of dividing `self` by `other`: - - f = 3.14 - f / 2 # => 1.57 - f / 2.0 # => 1.57 - f / Rational(2, 1) # => 1.57 - f / Complex(2, 0) # => (1.57+0.0i) - -**@overload** [] - -## <(y) [](#method-i-<) -Returns `true` if `self` is numerically less than `other`: - - 2.0 < 3 # => true - 2.0 < 3.0 # => true - 2.0 < Rational(3, 1) # => true - 2.0 < 2.0 # => false - -`Float::NAN < Float::NAN` returns an implementation-dependent value. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Returns `true` if `self` is numerically less than or equal to `other`: - - 2.0 <= 3 # => true - 2.0 <= 3.0 # => true - 2.0 <= Rational(3, 1) # => true - 2.0 <= 2.0 # => true - 2.0 <= 1.0 # => false - -`Float::NAN <= Float::NAN` returns an implementation-dependent value. - -**@overload** [] - -## <=>(y) [](#method-i-<=>) -Returns a value that depends on the numeric relation between `self` and -`other`: - -* -1, if `self` is less than `other`. -* 0, if `self` is equal to `other`. -* 1, if `self` is greater than `other`. -* `nil`, if the two values are incommensurate. - -Examples: - - 2.0 <=> 2 # => 0 - 2.0 <=> 2.0 # => 0 - 2.0 <=> Rational(2, 1) # => 0 - 2.0 <=> Complex(2, 0) # => 0 - 2.0 <=> 1.9 # => 1 - 2.0 <=> 2.1 # => -1 - 2.0 <=> 'foo' # => nil - -This is the basis for the tests in the Comparable module. - -`Float::NAN <=> Float::NAN` returns an implementation-dependent value. - -**@overload** [] - -## ==() [](#method-i-==) - -## ===() [](#method-i-===) - -## >(y) [](#method-i->) -Returns `true` if `self` is numerically greater than `other`: - - 2.0 > 1 # => true - 2.0 > 1.0 # => true - 2.0 > Rational(1, 2) # => true - 2.0 > 2.0 # => false - -`Float::NAN > Float::NAN` returns an implementation-dependent value. - -**@overload** [] - -## >=(y) [](#method-i->=) -Returns `true` if `self` is numerically greater than or equal to `other`: - - 2.0 >= 1 # => true - 2.0 >= 1.0 # => true - 2.0 >= Rational(1, 2) # => true - 2.0 >= 2.0 # => true - 2.0 >= 2.1 # => false - -`Float::NAN >= Float::NAN` returns an implementation-dependent value. - -**@overload** [] - -## abs() [](#method-i-abs) -call-seq: - float.abs -> float - - Returns the absolute value of +self+: - - (-34.56).abs # => 34.56 - -34.56.abs # => 34.56 - 34.56.abs # => 34.56 - -## angle() [](#method-i-angle) -Returns 0 if `self` is positive, Math::PI otherwise. - -**@overload** [] - -## arg() [](#method-i-arg) -Returns 0 if `self` is positive, Math::PI otherwise. - -**@overload** [] - -## ceil(*args) [](#method-i-ceil) -:markup: markdown - -call-seq: - ceil(ndigits = 0) -> float or integer - -Returns a numeric that is a "ceiling" value for `self`, as specified by the -given `ndigits`, which must be an [integer-convertible -object](implicit_conversion.rdoc@Integer-Convertible+Objects). - -When `ndigits` is positive, returns a Float with `ndigits` decimal digits -after the decimal point (as available, but no fewer than 1): - -``` f = 12345.6789 f.ceil(1) # => 12345.7 f.ceil(3) # => 12345.679 f.ceil(30) -# => 12345.6789 f = -12345.6789 f.ceil(1) # => -12345.6 f.ceil(3) # => --12345.678 f.ceil(30) # => -12345.6789 f = 0.0 f.ceil(1) # => 0.0 -f.ceil(100) # => 0.0 ``` - -When `ndigits` is non-positive, returns an Integer based on a computed -granularity: - -* The granularity is `10 ** ndigits.abs`. -* The returned value is the largest multiple of the granularity that is less - than or equal to `self`. - -Examples with positive `self`: - -| ndigits | Granularity | 12345.6789.ceil(ndigits) | -|--------:|------------:|-------------------------:| | 0 | 1 | -12346 | | -1 | 10 | 12350 -| | -2 | 100 | 12400 | | -3 | 1000 -| 13000 | | -4 | 10000 | 20000 - | | -5 | 100000 | 100000 | - -Examples with negative `self`: - -| ndigits | Granularity | -12345.6789.ceil(ndigits) | -|--------:|------------:|--------------------------:| | 0 | 1 -| -12345 | | -1 | 10 | -12340 - | | -2 | 100 | -12300 | | -3 | 1000 - | -12000 | | -4 | 10000 | -10000 - | | -5 | 100000 | 0 | - -When `self` is zero and `ndigits` is non-positive, returns Integer zero: - -``` 0.0.ceil(0) # => 0 0.0.ceil(-1) # => 0 0.0.ceil(-2) # => 0 ``` - -Note that the limited precision of floating-point arithmetic may lead to -surprising results: - -``` (2.1 / 0.7).ceil #=> 4 # Not 3 (because 2.1 / 0.7 # => -3.0000000000000004, not 3.0) ``` - -Related: Float#floor. - -## coerce(y) [](#method-i-coerce) -Returns a 2-element array containing `other` converted to a Float and `self`: - - f = 3.14 # => 3.14 - f.coerce(2) # => [2.0, 3.14] - f.coerce(2.0) # => [2.0, 3.14] - f.coerce(Rational(1, 2)) # => [0.5, 3.14] - f.coerce(Complex(1, 0)) # => [1.0, 3.14] - -Raises an exception if a type conversion fails. - -**@overload** [] - -## denominator() [](#method-i-denominator) -Returns the denominator (always positive). The result is machine dependent. - -See also Float#numerator. - -**@overload** [] - -## divmod(y) [](#method-i-divmod) -Returns a 2-element array `[q, r]`, where - - q = (self/other).floor # Quotient - r = self % other # Remainder - -Examples: - - 11.0.divmod(4) # => [2, 3.0] - 11.0.divmod(-4) # => [-3, -1.0] - -11.0.divmod(4) # => [-3, 1.0] - -11.0.divmod(-4) # => [2, -3.0] - - 12.0.divmod(4) # => [3, 0.0] - 12.0.divmod(-4) # => [-3, 0.0] - -12.0.divmod(4) # => [-3, -0.0] - -12.0.divmod(-4) # => [3, -0.0] - - 13.0.divmod(4.0) # => [3, 1.0] - 13.0.divmod(Rational(4, 1)) # => [3, 1.0] - -**@overload** [] - -## eql?() [](#method-i-eql?) - -**@return** [Boolean] - -## fdiv(y) [](#method-i-fdiv) -Returns the quotient from dividing `self` by `other`: - - f = 3.14 - f.quo(2) # => 1.57 - f.quo(-2) # => -1.57 - f.quo(Rational(2, 1)) # => 1.57 - f.quo(Complex(2, 0)) # => (1.57+0.0i) - -**@overload** [] - -## finite?() [](#method-i-finite?) -Returns `true` if `self` is not `Infinity`, `-Infinity`, or `NaN`, `false` -otherwise: - - f = 2.0 # => 2.0 - f.finite? # => true - f = 1.0/0.0 # => Infinity - f.finite? # => false - f = -1.0/0.0 # => -Infinity - f.finite? # => false - f = 0.0/0.0 # => NaN - f.finite? # => false - -**@overload** [] - -## floor(*args) [](#method-i-floor) -:markup: markdown - -call-seq: - floor(ndigits = 0) -> float or integer - -Returns a float or integer that is a "floor" value for `self`, as specified by -`ndigits`, which must be an [integer-convertible -object](implicit_conversion.rdoc@Integer-Convertible+Objects). - -When `self` is zero, returns a zero value: a float if `ndigits` is positive, -an integer otherwise: - -``` f = 0.0 # => 0.0 f.floor(20) # => 0.0 f.floor(0) # => 0 -f.floor(-20) # => 0 ``` - -When `self` is non-zero and `ndigits` is positive, returns a float with -`ndigits` digits after the decimal point (as available): - -``` f = 12345.6789 f.floor(1) # => 12345.6 f.floor(3) # => 12345.678 -f.floor(30) # => 12345.6789 f = -12345.6789 f.floor(1) # => -12345.7 -f.floor(3) # => -12345.679 f.floor(30) # => -12345.6789 ``` - -When `self` is non-zero and `ndigits` is non-positive, returns an integer -value based on a computed granularity: - -* The granularity is `10 ** ndigits.abs`. -* The returned value is the largest multiple of the granularity that is less - than or equal to `self`. - -Examples with positive `self`: - -| ndigits | Granularity | 12345.6789.floor(ndigits) | -|--------:|------------:|--------------------------:| | 0 | 1 -| 12345 | | -1 | 10 | -12340 | | -2 | 100 | 12300 | | -3 | - 1000 | 12000 | | -4 | 10000 | - 10000 | | -5 | 100000 | 0 | - -Examples with negative `self`: - -| ndigits | Granularity | -12345.6789.floor(ndigits) | -|--------:|------------:|---------------------------:| | 0 | 1 -| -12346 | | -1 | 10 | --12350 | | -2 | 100 | -12400 | | -3 | - 1000 | -13000 | | -4 | 10000 | - -20000 | | -5 | 100000 | -100000 | | --6 | 1000000 | -1000000 | - -Note that the limited precision of floating-point arithmetic may lead to -surprising results: - -``` (0.3 / 0.1).floor # => 2 # Not 3, (because (0.3 / 0.1) # => -2.9999999999999996, not 3.0) ``` - -Related: Float#ceil. - -## hash() [](#method-i-hash) -Returns the integer hash value for `self`. - -See also Object#hash. - -**@overload** [] - -## infinite?() [](#method-i-infinite?) -Returns: - -* 1, if `self` is `Infinity`. -* -1 if `self` is `-Infinity`. -* `nil`, otherwise. - -Examples: - - f = 1.0/0.0 # => Infinity - f.infinite? # => 1 - f = -1.0/0.0 # => -Infinity - f.infinite? # => -1 - f = 1.0 # => 1.0 - f.infinite? # => nil - f = 0.0/0.0 # => NaN - f.infinite? # => nil - -**@overload** [] - -## modulo(y) [](#method-i-modulo) -Returns `self` modulo `other` as a float. - -For float `f` and real number `r`, these expressions are equivalent: - - f % r - f-r*(f/r).floor - f.divmod(r)[1] - -See Numeric#divmod. - -Examples: - - 10.0 % 2 # => 0.0 - 10.0 % 3 # => 1.0 - 10.0 % 4 # => 2.0 - - 10.0 % -2 # => 0.0 - 10.0 % -3 # => -2.0 - 10.0 % -4 # => -2.0 - - 10.0 % 4.0 # => 2.0 - 10.0 % Rational(4, 1) # => 2.0 - -**@overload** [] - -## nan?() [](#method-i-nan?) -Returns `true` if `self` is a NaN, `false` otherwise. - - f = -1.0 #=> -1.0 - f.nan? #=> false - f = 0.0/0.0 #=> NaN - f.nan? #=> true - -**@overload** [] - -## negative?() [](#method-i-negative?) -call-seq: - negative? -> true or false - - Returns +true+ if +self+ is less than 0, +false+ otherwise. - -**@return** [Boolean] - -## next_float() [](#method-i-next_float) -Returns the next-larger representable Float. - -These examples show the internally stored values (64-bit hexadecimal) for each -Float `f` and for the corresponding `f.next_float`: - - f = 0.0 # 0x0000000000000000 - f.next_float # 0x0000000000000001 - - f = 0.01 # 0x3f847ae147ae147b - f.next_float # 0x3f847ae147ae147c - -In the remaining examples here, the output is shown in the usual way (result -`to_s`): - - 0.01.next_float # => 0.010000000000000002 - 1.0.next_float # => 1.0000000000000002 - 100.0.next_float # => 100.00000000000001 - - f = 0.01 - (0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.next_float } - -Output: - - 0 0x1.47ae147ae147bp-7 0.01 - 1 0x1.47ae147ae147cp-7 0.010000000000000002 - 2 0x1.47ae147ae147dp-7 0.010000000000000004 - 3 0x1.47ae147ae147ep-7 0.010000000000000005 - - f = 0.0; 100.times { f += 0.1 } - f # => 9.99999999999998 # should be 10.0 in the ideal world. - 10-f # => 1.9539925233402755e-14 # the floating point error. - 10.0.next_float-10 # => 1.7763568394002505e-15 # 1 ulp (unit in the last place). - (10-f)/(10.0.next_float-10) # => 11.0 # the error is 11 ulp. - (10-f)/(10*Float::EPSILON) # => 8.8 # approximation of the above. - "%a" % 10 # => "0x1.4p+3" - "%a" % f # => "0x1.3fffffffffff5p+3" # the last hex digit is 5. 16 - 5 = 11 ulp. - -Related: Float#prev_float - -**@overload** [] - -## numerator() [](#method-i-numerator) -Returns the numerator. The result is machine dependent. - - n = 0.3.numerator #=> 5404319552844595 - d = 0.3.denominator #=> 18014398509481984 - n.fdiv(d) #=> 0.3 - -See also Float#denominator. - -**@overload** [] - -## phase() [](#method-i-phase) -Returns 0 if `self` is positive, Math::PI otherwise. - -**@overload** [] - -## positive?() [](#method-i-positive?) -call-seq: - positive? -> true or false - - Returns +true+ if +self+ is greater than 0, +false+ otherwise. - -**@return** [Boolean] - -## prev_float() [](#method-i-prev_float) -Returns the next-smaller representable Float. - -These examples show the internally stored values (64-bit hexadecimal) for each -Float `f` and for the corresponding `f.pev_float`: - - f = 5e-324 # 0x0000000000000001 - f.prev_float # 0x0000000000000000 - - f = 0.01 # 0x3f847ae147ae147b - f.prev_float # 0x3f847ae147ae147a - -In the remaining examples here, the output is shown in the usual way (result -`to_s`): - - 0.01.prev_float # => 0.009999999999999998 - 1.0.prev_float # => 0.9999999999999999 - 100.0.prev_float # => 99.99999999999999 - - f = 0.01 - (0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.prev_float } - -Output: - - 0 0x1.47ae147ae147bp-7 0.01 - 1 0x1.47ae147ae147ap-7 0.009999999999999998 - 2 0x1.47ae147ae1479p-7 0.009999999999999997 - 3 0x1.47ae147ae1478p-7 0.009999999999999995 - -Related: Float#next_float. - -**@overload** [] - -## quo(y) [](#method-i-quo) -Returns the quotient from dividing `self` by `other`: - - f = 3.14 - f.quo(2) # => 1.57 - f.quo(-2) # => -1.57 - f.quo(Rational(2, 1)) # => 1.57 - f.quo(Complex(2, 0)) # => (1.57+0.0i) - -**@overload** [] - -## rationalize(*args) [](#method-i-rationalize) -Returns a simpler approximation of the value (flt-|eps| <= result <= -flt+|eps|). If the optional argument `eps` is not given, it will be chosen -automatically. - - 0.3.rationalize #=> (3/10) - 1.333.rationalize #=> (1333/1000) - 1.333.rationalize(0.01) #=> (4/3) - -See also Float#to_r. - -**@overload** [] - -## round(*args) [](#method-i-round) -Returns `self` rounded to the nearest value with a precision of `ndigits` -decimal digits. - -When `ndigits` is non-negative, returns a float with `ndigits` after the -decimal point (as available): - - f = 12345.6789 - f.round(1) # => 12345.7 - f.round(3) # => 12345.679 - f = -12345.6789 - f.round(1) # => -12345.7 - f.round(3) # => -12345.679 - -When `ndigits` is negative, returns an integer with at least `ndigits.abs` -trailing zeros: - - f = 12345.6789 - f.round(0) # => 12346 - f.round(-3) # => 12000 - f = -12345.6789 - f.round(0) # => -12346 - f.round(-3) # => -12000 - -If keyword argument `half` is given, and `self` is equidistant from the two -candidate values, the rounding is according to the given `half` value: - -* `:up` or `nil`: round away from zero: - - 2.5.round(half: :up) # => 3 - 3.5.round(half: :up) # => 4 - (-2.5).round(half: :up) # => -3 - -* `:down`: round toward zero: - - 2.5.round(half: :down) # => 2 - 3.5.round(half: :down) # => 3 - (-2.5).round(half: :down) # => -2 - -* `:even`: round toward the candidate whose last nonzero digit is even: - - 2.5.round(half: :even) # => 2 - 3.5.round(half: :even) # => 4 - (-2.5).round(half: :even) # => -2 - -Raises and exception if the value for `half` is invalid. - -Related: Float#truncate. - -**@overload** [] - -## to_f() [](#method-i-to_f) -call-seq: - to_f -> self - - Returns +self+ (which is already a \Float). - -## to_i() [](#method-i-to_i) -Returns `self` truncated to an Integer. - - 1.2.to_i # => 1 - (-1.2).to_i # => -1 - -Note that the limited precision of floating-point arithmetic may lead to -surprising results: - - (0.3 / 0.1).to_i # => 2 (!) - -**@overload** [] - -## to_int() [](#method-i-to_int) -Returns `self` truncated to an Integer. - - 1.2.to_i # => 1 - (-1.2).to_i # => -1 - -Note that the limited precision of floating-point arithmetic may lead to -surprising results: - - (0.3 / 0.1).to_i # => 2 (!) - -**@overload** [] - -## to_r() [](#method-i-to_r) -Returns the value as a rational. - - 2.0.to_r #=> (2/1) - 2.5.to_r #=> (5/2) - -0.75.to_r #=> (-3/4) - 0.0.to_r #=> (0/1) - 0.3.to_r #=> (5404319552844595/18014398509481984) - -NOTE: 0.3.to_r isn't the same as "0.3".to_r. The latter is equivalent to -"3/10".to_r, but the former isn't so. - - 0.3.to_r == 3/10r #=> false - "0.3".to_r == 3/10r #=> true - -See also Float#rationalize. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns a string containing a representation of `self`; depending of the value -of `self`, the string representation may contain: - -* A fixed-point number. - 3.14.to_s # => "3.14" - -* A number in "scientific notation" (containing an exponent). - (10.1**50).to_s # => "1.644631821843879e+50" - -* 'Infinity'. - (10.1**500).to_s # => "Infinity" - -* '-Infinity'. - (-10.1**500).to_s # => "-Infinity" - -* 'NaN' (indicating not-a-number). - (0.0/0.0).to_s # => "NaN" - -**@overload** [] - -## truncate(*args) [](#method-i-truncate) -Returns `self` truncated (toward zero) to a precision of `ndigits` decimal -digits. - -When `ndigits` is positive, returns a float with `ndigits` digits after the -decimal point (as available): - - f = 12345.6789 - f.truncate(1) # => 12345.6 - f.truncate(3) # => 12345.678 - f = -12345.6789 - f.truncate(1) # => -12345.6 - f.truncate(3) # => -12345.678 - -When `ndigits` is negative, returns an integer with at least `ndigits.abs` -trailing zeros: - - f = 12345.6789 - f.truncate(0) # => 12345 - f.truncate(-3) # => 12000 - f = -12345.6789 - f.truncate(0) # => -12345 - f.truncate(-3) # => -12000 - -Note that the limited precision of floating-point arithmetic may lead to -surprising results: - - (0.3 / 0.1).truncate #=> 2 (!) - -Related: Float#round. - -**@overload** [] - -## zero?() [](#method-i-zero?) -call-seq: - zero? -> true or false - - Returns +true+ if +self+ is 0.0, +false+ otherwise. - -**@return** [Boolean] - diff --git a/example/ruby/FloatDomainError.md b/example/ruby/FloatDomainError.md deleted file mode 100644 index f48dd82..0000000 --- a/example/ruby/FloatDomainError.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: FloatDomainError -**Inherits:** RangeError - - -Raised when attempting to convert special float values (in particular -`Infinity` or `NaN`) to numerical classes which don't support them. - - Float::INFINITY.to_r #=> FloatDomainError: Infinity - - - diff --git a/example/ruby/FloatSpecs.md b/example/ruby/FloatSpecs.md deleted file mode 100644 index 0417026..0000000 --- a/example/ruby/FloatSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: FloatSpecs - - - - - diff --git a/example/ruby/FloatSpecs/CanCoerce.md b/example/ruby/FloatSpecs/CanCoerce.md deleted file mode 100644 index 87999c7..0000000 --- a/example/ruby/FloatSpecs/CanCoerce.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: FloatSpecs::CanCoerce -**Inherits:** Object - - - - - -#Instance Methods -## /(b) [](#method-i-/) - -## coerce(b) [](#method-i-coerce) - -## initialize(a) [](#method-i-initialize) - -**@return** [CanCoerce] a new instance of CanCoerce - diff --git a/example/ruby/FloatSpecs/CoerceError.md b/example/ruby/FloatSpecs/CoerceError.md deleted file mode 100644 index a76b62d..0000000 --- a/example/ruby/FloatSpecs/CoerceError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: FloatSpecs::CoerceError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Foo.md b/example/ruby/Foo.md deleted file mode 100644 index 05b78a6..0000000 --- a/example/ruby/Foo.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Foo -**Inherits:** Object - -**Includes:** DRbUndumped - - -Foo.private :printf - - -# Attributes -## i[RW] [](#attribute-i-i) -Returns the value of attribute i. - - -#Instance Methods -## bar(n) [](#method-i-bar) - -## foo(i) [](#method-i-foo) - -## hello(it) [](#method-i-hello) - -## initialize(str) [](#method-i-initialize) - -**@return** [Foo] a new instance of Foo - -## quux() [](#method-i-quux) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Foo/Unknown.md b/example/ruby/Foo/Unknown.md deleted file mode 100644 index e75bc98..0000000 --- a/example/ruby/Foo/Unknown.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Foo::Unknown -**Inherits:** Object - - - - - diff --git a/example/ruby/FooError.md b/example/ruby/FooError.md deleted file mode 100644 index b767f57..0000000 --- a/example/ruby/FooError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: FooError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/ForSpecs.md b/example/ruby/ForSpecs.md deleted file mode 100644 index 88e23bf..0000000 --- a/example/ruby/ForSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ForSpecs - - - - - diff --git a/example/ruby/ForSpecs/ForInClassMethod.md b/example/ruby/ForSpecs/ForInClassMethod.md deleted file mode 100644 index 039c321..0000000 --- a/example/ruby/ForSpecs/ForInClassMethod.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ForSpecs::ForInClassMethod -**Inherits:** Object - - - - -# Class Methods -## foo() [](#method-c-foo) - diff --git a/example/ruby/FormatterOverrides.md b/example/ruby/FormatterOverrides.md deleted file mode 100644 index 42a90ac..0000000 --- a/example/ruby/FormatterOverrides.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: FormatterOverrides - - - - - -#Instance Methods -## dump_pending(_) [](#method-i-dump_pending) - -## example_pending(_) [](#method-i-example_pending) - diff --git a/example/ruby/Forwardable.md b/example/ruby/Forwardable.md deleted file mode 100644 index c9c19c7..0000000 --- a/example/ruby/Forwardable.md +++ /dev/null @@ -1,65 +0,0 @@ -# Module: Forwardable - - -:stopdoc: - - -# Class Methods -## _compile_method(src , file , line ) [](#method-c-_compile_method) -## _delegator_method(obj , accessor , method , ali ) [](#method-c-_delegator_method) -:nodoc: -## _valid_method?(method ) [](#method-c-_valid_method?) -:stopdoc: -**@return** [Boolean] - -# Attributes -## debug[RW] [](#attribute-c-debug) -ignored - - -#Instance Methods -## def_instance_delegator(accessor, method, alimethod) [](#method-i-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 - -## def_instance_delegators(accessor, *methods) [](#method-i-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map - -## instance_delegate(hash) [](#method-i-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor - diff --git a/example/ruby/Front.md b/example/ruby/Front.md deleted file mode 100644 index 7332283..0000000 --- a/example/ruby/Front.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Front -**Inherits:** Object - - - - - -#Instance Methods -## [](k) [](#method-i-[]) - -## initialize() [](#method-i-initialize) - -**@return** [Front] a new instance of Front - diff --git a/example/ruby/FrozenError.md b/example/ruby/FrozenError.md deleted file mode 100644 index 94f7a34..0000000 --- a/example/ruby/FrozenError.md +++ /dev/null @@ -1,29 +0,0 @@ -# Exception: FrozenError -**Inherits:** RuntimeError - - -Raised when there is an attempt to modify a frozen object. - - [1, 2, 3].freeze << 4 - -*raises the exception:* - - FrozenError: can't modify frozen Array - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Construct a new FrozenError exception. If given the *receiver* parameter may -subsequently be examined using the FrozenError#receiver method. - - a = [].freeze - raise FrozenError.new("can't modify frozen array", receiver: a) - -**@overload** [] - -## receiver() [](#method-i-receiver) -Return the receiver associated with this FrozenError exception. - -**@overload** [] - diff --git a/example/ruby/GC.md b/example/ruby/GC.md deleted file mode 100644 index 250c0ac..0000000 --- a/example/ruby/GC.md +++ /dev/null @@ -1,449 +0,0 @@ -# Module: GC - - -The GC module provides an interface to Ruby's mark-and-sweep garbage -collection mechanism. - - Some of the underlying methods are also available via the ObjectSpace module. - - You may obtain information about the operation of the \GC through GC::Profiler. - - -# Class Methods -## auto_compact(*args ) [](#method-c-auto_compact) -Returns whether or not automatic compaction has been enabled. -**@overload** [] - -## auto_compact=(*args ) [](#method-c-auto_compact=) -Updates automatic compaction mode. - -When enabled, the compactor will execute on every major collection. - -Enabling compaction will degrade performance on major collections. -**@overload** [] - -## compact(*args ) [](#method-c-compact) -This function compacts objects together in Ruby's heap. It eliminates unused -space (or fragmentation) in the heap by moving objects in to that unused -space. - -The returned `hash` contains statistics about the objects that were moved; see -GC.latest_compact_info. - -This method is only expected to work on CRuby. - -To test whether GC compaction is supported, use the idiom: - - GC.respond_to?(:compact) -**@overload** [] - -## config(hash nil) [](#method-c-config) -call-seq: - GC.config -> hash - GC.config(hash) -> hash - -Sets or gets information about the current GC config. - -Configuration parameters are GC implementation-specific and may change without -notice. - -This method can be called without parameters to retrieve the current config as -a `Hash` with `Symbol` keys. - -This method can also be called with a `Hash` argument to assign values to -valid config keys. Config keys missing from the passed `Hash` will be left -unmodified. - -If a key/value pair is passed to this function that does not correspond to a -valid config key for the GC implementation being used, no config will be -updated, the key will be present in the returned Hash, and its value will be -`nil`. This is to facilitate easy migration between GC implementations. - -In both call-seqs, the return value of `GC.config` will be a `Hash` containing -the most recent full configuration, i.e., all keys and values defined by the -specific GC implementation being used. In the case of a config update, the -return value will include the new values being updated. - -This method is only expected to work on CRuby. - -### GC Implementation independent values - -The `GC.config` hash can also contain keys that are global and read-only. -These keys are not specific to any one GC library implementation and -attempting to write to them will raise `ArgumentError`. - -There is currently only one global, read-only key: - -implementation -: Returns a `String` containing the name of the currently loaded GC library, - if one has been loaded using `RUBY_GC_LIBRARY`, and "default" in all other - cases - - -### GC Implementation specific values - -GC libraries are expected to document their own configuration. Valid keys for -Ruby's default GC implementation are: - -rgengc_allow_full_mark -: Controls whether the GC is allowed to run a full mark (young & old - objects). - - When `true`, GC interleaves major and minor collections. This is the - default. GC will function as intended. - - When `false`, the GC will never trigger a full marking cycle unless - explicitly requested by user code. Instead, only a minor mark will - run—only young objects will be marked. When the heap space is exhausted, - new pages will be allocated immediately instead of running a full mark. - - A flag will be set to notify that a full mark has been requested. This - flag is accessible using `GC.latest_gc_info(:needs_major_by)` - - The user can trigger a major collection at any time using - `GC.start(full_mark: true)` - - When `false`, Young to Old object promotion is disabled. For performance - reasons, it is recommended to warm up an application using - `Process.warmup` before setting this parameter to `false`. - -## count() [](#method-c-count) -call-seq: - GC.count -> Integer - -Returns the number of times GC has occurred since the process started. -## disable() [](#method-c-disable) -call-seq: - GC.disable -> true or false - -Disables garbage collection, returning `true` if garbage collection was -already disabled. - - GC.disable #=> false - GC.disable #=> true -## enable() [](#method-c-enable) -call-seq: - GC.enable -> true or false - -Enables garbage collection, returning `true` if garbage collection was -previously disabled. - - GC.disable #=> false - GC.enable #=> true - GC.enable #=> false -## latest_compact_info(*args ) [](#method-c-latest_compact_info) -Returns information about object moved in the most recent GC compaction. - -The returned `hash` contains the following keys: - -considered -: Hash containing the type of the object as the key and the number of - objects of that type that were considered for movement. - -moved -: Hash containing the type of the object as the key and the number of - objects of that type that were actually moved. - -moved_up -: Hash containing the type of the object as the key and the number of - objects of that type that were increased in size. - -moved_down -: Hash containing the type of the object as the key and the number of - objects of that type that were decreased in size. - - -Some objects can't be moved (due to pinning) so these numbers can be used to -calculate compaction efficiency. -**@overload** [] - -## latest_gc_info(hash_or_key nil) [](#method-c-latest_gc_info) -call-seq: - GC.latest_gc_info -> hash - GC.latest_gc_info(hash) -> hash - GC.latest_gc_info(key) -> value - -Returns information about the most recent garbage collection. - -If the argument `hash` is given and is a Hash object, it is overwritten and -returned. This is intended to avoid the probe effect. - -If the argument `key` is given and is a Symbol object, it returns the value -associated with the key. This is equivalent to `GC.latest_gc_info[key]`. -## malloc_allocated_size() [](#method-c-malloc_allocated_size) -Returns the size of memory allocated by malloc(). - -Only available if ruby was built with `CALC_EXACT_MALLOC_SIZE`. -**@overload** [] - -## malloc_allocations() [](#method-c-malloc_allocations) -Returns the number of malloc() allocations. - -Only available if ruby was built with `CALC_EXACT_MALLOC_SIZE`. -**@overload** [] - -## measure_total_time() [](#method-c-measure_total_time) -call-seq: - GC.measure_total_time -> true/false - -Returns the measure_total_time flag (default: `true`). Note that measurement -can affect the application's performance. -## measure_total_time=(flag ) [](#method-c-measure_total_time=) -call-seq: - GC.measure_total_time = true/false - -Enables measuring GC time. You can get the result with `GC.stat(:time)`. Note -that GC time measurement can cause some performance overhead. -## start(full_mark: true, immediate_mark: true, immediate_sweep: true) [](#method-c-start) -Initiates garbage collection, even if manually disabled. - -The `full_mark` keyword argument determines whether or not to perform a major -garbage collection cycle. When set to `true`, a major garbage collection cycle -is run, meaning all objects are marked. When set to `false`, a minor garbage -collection cycle is run, meaning only young objects are marked. - -The `immediate_mark` keyword argument determines whether or not to perform -incremental marking. When set to `true`, marking is completed during the call -to this method. When set to `false`, marking is performed in steps that are -interleaved with future Ruby code execution, so marking might not be completed -during this method call. Note that if `full_mark` is `false`, then marking -will always be immediate, regardless of the value of `immediate_mark`. - -The `immediate_sweep` keyword argument determines whether or not to defer -sweeping (using lazy sweep). When set to `false`, sweeping is performed in -steps that are interleaved with future Ruby code execution, so sweeping might -not be completed during this method call. When set to `true`, sweeping is -completed during the call to this method. - -Note: These keyword arguments are implementation and version-dependent. They -are not guaranteed to be future-compatible and may be ignored if the -underlying implementation does not support them. -## stat(hash_or_key nil) [](#method-c-stat) -call-seq: - GC.stat -> Hash - GC.stat(hash) -> Hash - GC.stat(:key) -> Numeric - -Returns a Hash containing information about the GC. - -The contents of the hash are implementation-specific and may change in the -future without notice. - -The hash includes internal statistics about GC such as: - -count -: The total number of garbage collections run since application start (count - includes both minor and major garbage collections) - -time -: The total time spent in garbage collections (in milliseconds) - -heap_allocated_pages -: The total number of `:heap_eden_pages` + `:heap_tomb_pages` - -heap_sorted_length -: The number of pages that can fit into the buffer that holds references to - all pages - -heap_allocatable_pages -: The total number of pages the application could allocate without - additional GC - -heap_available_slots -: The total number of slots in all `:heap_allocated_pages` - -heap_live_slots -: The total number of slots which contain live objects - -heap_free_slots -: The total number of slots which do not contain live objects - -heap_final_slots -: The total number of slots with pending finalizers to be run - -heap_marked_slots -: The total number of objects marked in the last GC - -heap_eden_pages -: The total number of pages which contain at least one live slot - -heap_tomb_pages -: The total number of pages which do not contain any live slots - -total_allocated_pages -: The cumulative number of pages allocated since application start - -total_freed_pages -: The cumulative number of pages freed since application start - -total_allocated_objects -: The cumulative number of objects allocated since application start - -total_freed_objects -: The cumulative number of objects freed since application start - -malloc_increase_bytes -: Amount of memory allocated on the heap for objects. Decreased by any GC - -malloc_increase_bytes_limit -: When `:malloc_increase_bytes` crosses this limit, GC is triggered - -minor_gc_count -: The total number of minor garbage collections run since process start - -major_gc_count -: The total number of major garbage collections run since process start - -compact_count -: The total number of compactions run since process start - -read_barrier_faults -: The total number of times the read barrier was triggered during compaction - -total_moved_objects -: The total number of objects compaction has moved - -remembered_wb_unprotected_objects -: The total number of objects without write barriers - -remembered_wb_unprotected_objects_limit -: When `:remembered_wb_unprotected_objects` crosses this limit, major GC is - triggered - -old_objects -: Number of live, old objects which have survived at least 3 garbage - collections - -old_objects_limit -: When `:old_objects` crosses this limit, major GC is triggered - -oldmalloc_increase_bytes -: Amount of memory allocated on the heap for objects. Decreased by major GC - -oldmalloc_increase_bytes_limit -: When `:oldmalloc_increase_bytes` crosses this limit, major GC is triggered - - -If the optional argument, hash, is given, it is overwritten and returned. This -is intended to avoid the probe effect. - -This method is only expected to work on CRuby. -## stat_heap(heap_name nil, hash_or_key nil) [](#method-c-stat_heap) -call-seq: - GC.stat_heap -> Hash - GC.stat_heap(nil, hash) -> Hash - GC.stat_heap(heap_name) -> Hash - GC.stat_heap(heap_name, hash) -> Hash - GC.stat_heap(heap_name, :key) -> Numeric - -Returns information for heaps in the GC. - -If the first optional argument, `heap_name`, is passed in and not `nil`, it -returns a `Hash` containing information about the particular heap. Otherwise, -it will return a `Hash` with heap names as keys and a `Hash` containing -information about the heap as values. - -If the second optional argument, `hash_or_key`, is given as a `Hash`, it will -be overwritten and returned. This is intended to avoid the probe effect. - -If both optional arguments are passed in and the second optional argument is a -symbol, it will return a `Numeric` value for the particular heap. - -On CRuby, `heap_name` is of the type `Integer` but may be of type `String` on -other implementations. - -The contents of the hash are implementation-specific and may change in the -future without notice. - -If the optional argument, hash, is given, it is overwritten and returned. - -This method is only expected to work on CRuby. - -The hash includes the following keys about the internal information in the GC: - -slot_size -: The slot size of the heap in bytes. - -heap_allocatable_pages -: The number of pages that can be allocated without triggering a new garbage - collection cycle. - -heap_eden_pages -: The number of pages in the eden heap. - -heap_eden_slots -: The total number of slots in all of the pages in the eden heap. - -heap_tomb_pages -: The number of pages in the tomb heap. The tomb heap only contains pages - that do not have any live objects. - -heap_tomb_slots -: The total number of slots in all of the pages in the tomb heap. - -total_allocated_pages -: The total number of pages that have been allocated in the heap. - -total_freed_pages -: The total number of pages that have been freed and released back to the - system in the heap. - -force_major_gc_count -: The number of times this heap has forced major garbage collection cycles - to start due to running out of free slots. - -force_incremental_marking_finish_count -: The number of times this heap has forced incremental marking to complete - due to running out of pooled slots. - -## stress() [](#method-c-stress) -call-seq: - GC.stress -> integer, true, or false - -Returns the current status of GC stress mode. -## stress=(flag ) [](#method-c-stress=) -call-seq: - GC.stress = flag -> flag - -Updates the GC stress mode. - -When stress mode is enabled, the GC is invoked at every GC opportunity: all -memory and object allocations. - -Enabling stress mode will degrade performance; it is only for debugging. - -The flag can be true, false, or an integer bitwise-ORed with the following -flags: - 0x01:: no major GC - 0x02:: no immediate sweep - 0x04:: full mark after malloc/calloc/realloc -## total_time() [](#method-c-total_time) -call-seq: - GC.total_time -> int - -Returns the measured GC total time in nanoseconds. -## verify_compaction_references(*args ) [](#method-c-verify_compaction_references) -Verify compaction reference consistency. - -This method is implementation specific. During compaction, objects that were -moved are replaced with T_MOVED objects. No object should have a reference to -a T_MOVED object after compaction. - -This function expands the heap to ensure room to move all objects, compacts -the heap to make sure everything moves, updates all references, then performs -a full GC. If any object contains a reference to a T_MOVED object, that -object should be pushed on the mark stack, and will make a SEGV. -**@overload** [] - -## verify_internal_consistency() [](#method-c-verify_internal_consistency) -Verify internal consistency. - -This method is implementation specific. Now this method checks generational -consistency if RGenGC is supported. -**@overload** [] - - -#Instance Methods -## garbage_collect(full_mark:true, immediate_mark:true, immediate_sweep:true) [](#method-i-garbage_collect) -Alias of GC.start - diff --git a/example/ruby/GC/Profiler.md b/example/ruby/GC/Profiler.md deleted file mode 100644 index 0a9e5e4..0000000 --- a/example/ruby/GC/Profiler.md +++ /dev/null @@ -1,98 +0,0 @@ -# Module: GC::Profiler - - - - -# Class Methods -## clear() [](#method-c-clear) -Clears the GC profiler data. -**@overload** [] - -## disable() [](#method-c-disable) -Stops the GC profiler. -**@overload** [] - -## enable() [](#method-c-enable) -Starts the GC profiler. -**@overload** [] - -## enabled?() [](#method-c-enabled?) -The current status of GC profile mode. -**@overload** [] - -**@return** [Boolean] - -## raw_data() [](#method-c-raw_data) -Returns an Array of individual raw profile data Hashes ordered from earliest -to latest by `:GC_INVOKE_TIME`. - -For example: - - [ - -{ - :GC_TIME=>1.3000000000000858e-05, - :GC_INVOKE_TIME=>0.010634999999999999, - :HEAP_USE_SIZE=>289640, - :HEAP_TOTAL_SIZE=>588960, - :HEAP_TOTAL_OBJECTS=>14724, - :GC_IS_MARKED=>false - -}, - # ... - ] - -The keys mean: - -`:GC_TIME` -: Time elapsed in seconds for this GC run - `:GC_INVOKE_TIME` -: Time elapsed in seconds from startup to when the GC was invoked - `:HEAP_USE_SIZE` -: Total bytes of heap used - `:HEAP_TOTAL_SIZE` -: Total size of heap in bytes - `:HEAP_TOTAL_OBJECTS` -: Total number of objects - `:GC_IS_MARKED` -: Returns `true` if the GC is in mark phase - - If ruby was built with `GC_PROFILE_MORE_DETAIL`, you - will also have access to the following hash keys: - - `:GC_MARK_TIME` -`:GC_SWEEP_TIME` -`:ALLOCATE_INCREASE` -`:ALLOCATE_LIMIT` -`:HEAP_USE_PAGES` -`:HEAP_LIVE_OBJECTS` -`:HEAP_FREE_OBJECTS` -`:HAVE_FINALIZE` -: - - - - - - -**@overload** [] - -## report(*args ) [](#method-c-report) -Writes the GC::Profiler.result to `$stdout` or the given IO object. -**@overload** [] - -**@overload** [] - -## result() [](#method-c-result) -Returns a profile data report such as: - - GC 1 invokes. - Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms) - 1 0.012 159240 212940 10647 0.00000000000001530000 -**@overload** [] - -## total_time() [](#method-c-total_time) -The total time used for garbage collection in seconds -**@overload** [] - - diff --git a/example/ruby/GCCompactChecker.md b/example/ruby/GCCompactChecker.md deleted file mode 100644 index 3dd1b40..0000000 --- a/example/ruby/GCCompactChecker.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: GCCompactChecker - - - - - -#Instance Methods -## after_teardown() [](#method-i-after_teardown) - diff --git a/example/ruby/GCDisabledChecker.md b/example/ruby/GCDisabledChecker.md deleted file mode 100644 index cfa082f..0000000 --- a/example/ruby/GCDisabledChecker.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: GCDisabledChecker - - - - - -#Instance Methods -## after_teardown() [](#method-i-after_teardown) - -## before_setup() [](#method-i-before_setup) - diff --git a/example/ruby/Gem.md b/example/ruby/Gem.md deleted file mode 100644 index af67e8c..0000000 --- a/example/ruby/Gem.md +++ /dev/null @@ -1,457 +0,0 @@ -# Module: Gem - - -module Gem::URI - - -# Class Methods -## URI(uri ) [](#method-c-URI) -Returns a Gem::URI object derived from the given `uri`, which may be a -Gem::URI string or an existing Gem::URI object: - - # Returns a new Gem::URI. - uri = Gem::URI('http://github.com/ruby/ruby') - # => # - # Returns the given Gem::URI. - Gem::URI(uri) - # => # -## activate_bin_path(name , exec_name nil, *requirements ) [](#method-c-activate_bin_path) -Find the full path to the executable for gem `name`. If the `exec_name` is -not given, an exception will be raised, otherwise the specified executable's -path is returned. `requirements` allows you to specify specific gem versions. - -A side effect of this method is that it will activate the gem that contains -the executable. - -This method should **only** be used in bin stub files. -## activated_gem_paths() [](#method-c-activated_gem_paths) -The number of paths in the +$LOAD_PATH+ from activated gems. Used to -prioritize `-I` and `ENV['RUBYLIB']` entries during `require`. -## add_to_load_path(*paths ) [](#method-c-add_to_load_path) -Add a list of paths to the $LOAD_PATH at the proper place. -## bin_path(name , exec_name nil, *requirements ) [](#method-c-bin_path) -Find the full path to the executable for gem `name`. If the `exec_name` is -not given, an exception will be raised, otherwise the specified executable's -path is returned. `requirements` allows you to specify specific gem versions. -## binary_mode() [](#method-c-binary_mode) -The mode needed to read a file as straight binary. -## bindir(install_dir Gem.dir) [](#method-c-bindir) -The path where gem executables are to be installed. -## cache_home() [](#method-c-cache_home) -The path to standard location of the user's cache directory. -## clear_default_specs() [](#method-c-clear_default_specs) -Clear default gem related variables. It is for test -## clear_paths() [](#method-c-clear_paths) -Reset the `dir` and `path` values. The next time `dir` or `path` is -requested, the values will be calculated from scratch. This is mainly used by -the unit tests to provide test isolation. -## config_file() [](#method-c-config_file) -The path to standard location of the user's .gemrc file. -## config_home() [](#method-c-config_home) -The path to standard location of the user's configuration directory. -## configuration() [](#method-c-configuration) -The standard configuration object for gems. -## configuration=(config ) [](#method-c-configuration=) -Use the given configuration object (which implements the ConfigFile protocol) -as the standard configuration object. -## data_home() [](#method-c-data_home) -The path to standard location of the user's data directory. -## default_bindir() [](#method-c-default_bindir) -The default directory for binaries -## default_cert_path() [](#method-c-default_cert_path) -The default signing certificate chain path -## default_dir() [](#method-c-default_dir) -Default home directory path to be used if an alternate value is not specified -in the environment -## default_exec_format() [](#method-c-default_exec_format) -Deduce Ruby's --program-prefix and --program-suffix from its install name -## default_ext_dir_for(base_dir ) [](#method-c-default_ext_dir_for) -Returns binary extensions dir for specified RubyGems base dir or nil if such -directory cannot be determined. - -By default, the binary extensions are located side by side with their Ruby -counterparts, therefore nil is returned -## default_key_path() [](#method-c-default_key_path) -The default signing key path -## default_path() [](#method-c-default_path) -Default gem load path -## default_rubygems_dirs() [](#method-c-default_rubygems_dirs) -Paths where RubyGems' .rb files and bin files are installed -## default_sources() [](#method-c-default_sources) -An Array of the default sources that come with RubyGems -## default_spec_cache_dir() [](#method-c-default_spec_cache_dir) -Default spec directory path to be used if an alternate value is not specified -in the environment -## default_specifications_dir() [](#method-c-default_specifications_dir) -Path to specification files of default gems. -## default_user_install() [](#method-c-default_user_install) -Enables automatic installation into user directory -## deflate(data ) [](#method-c-deflate) -A Zlib::Deflate.deflate wrapper -## dir() [](#method-c-dir) -The path where gems are to be installed. -## done_installing(&hook ) [](#method-c-done_installing) -Adds a post-installs hook that will be passed a Gem::DependencyInstaller and a -list of installed specifications when Gem::DependencyInstaller#install is -complete -## dynamic_library_suffixes() [](#method-c-dynamic_library_suffixes) -Suffixes for dynamic library require-able paths. -## ensure_default_gem_subdirectories(dir Gem.dir, mode nil) [](#method-c-ensure_default_gem_subdirectories) -Quietly ensure the Gem directory `dir` contains all the proper subdirectories -for handling default gems. If we can't create a directory due to a permission -problem, then we will silently continue. - -If `mode` is given, missing directories are created with this mode. - -World-writable directories will never be created. -## ensure_gem_subdirectories(dir Gem.dir, mode nil) [](#method-c-ensure_gem_subdirectories) -Quietly ensure the Gem directory `dir` contains all the proper subdirectories. - If we can't create a directory due to a permission problem, then we will -silently continue. - -If `mode` is given, missing directories are created with this mode. - -World-writable directories will never be created. -## ensure_subdirectories(dir , mode , subdirs ) [](#method-c-ensure_subdirectories) -:nodoc: -## env_requirement(gem_name ) [](#method-c-env_requirement) -## extension_api_version() [](#method-c-extension_api_version) -The extension API version of ruby. This includes the static vs non-static -distinction as extensions cannot be shared between the two. -## find_config_file() [](#method-c-find_config_file) -Finds the user's config file -## find_default_spec(path ) [](#method-c-find_default_spec) -Find a Gem::Specification of default gem from `path` -## find_files(glob , check_load_path true) [](#method-c-find_files) -Returns a list of paths matching `glob` that can be used by a gem to pick up -features from other gems. For example: - - Gem.find_files('rdoc/discover').each do |path| load path end - -if `check_load_path` is true (the default), then find_files also searches -$LOAD_PATH for files as well as gems. - -Note that find_files will return all files even if they are from different -versions of the same gem. See also find_latest_files -## find_files_from_load_path(glob ) [](#method-c-find_files_from_load_path) -:nodoc: -## find_latest_files(glob , check_load_path true) [](#method-c-find_latest_files) -Returns a list of paths matching `glob` from the latest gems that can be used -by a gem to pick up features from other gems. For example: - - Gem.find_latest_files('rdoc/discover').each do |path| load path end - -if `check_load_path` is true (the default), then find_latest_files also -searches $LOAD_PATH for files as well as gems. - -Unlike find_files, find_latest_files will return only files from the latest -version of a gem. -## find_unresolved_default_spec(path ) [](#method-c-find_unresolved_default_spec) -Find an unresolved Gem::Specification of default gem from `path` -## finish_resolve(request_set Gem::RequestSet.new) [](#method-c-finish_resolve) -## freebsd_platform?() [](#method-c-freebsd_platform?) -Is this platform FreeBSD -**@return** [Boolean] - -## host() [](#method-c-host) -Get the default RubyGems API host. This is normally `https://rubygems.org`. -## host=(host ) [](#method-c-host=) -Set the default RubyGems API host. -## install(name , version Gem::Requirement.default, *options ) [](#method-c-install) -Top level install helper method. Allows you to install gems interactively: - - % irb - >> Gem.install "minitest" - Fetching: minitest-5.14.0.gem (100%) - => [#] -## install_extension_in_lib() [](#method-c-install_extension_in_lib) -Install extensions into lib as well as into the extension directory. -## java_platform?() [](#method-c-java_platform?) -Is this a java platform? -**@return** [Boolean] - -## latest_rubygems_version() [](#method-c-latest_rubygems_version) -Returns the latest release version of RubyGems. -## latest_spec_for(name ) [](#method-c-latest_spec_for) -Returns the latest release-version specification for the gem `name`. -## latest_version_for(name ) [](#method-c-latest_version_for) -Returns the version of the latest release-version of gem `name` -## load_env_plugins() [](#method-c-load_env_plugins) -Find all 'rubygems_plugin' files in $LOAD_PATH and load them -## load_path_insert_index() [](#method-c-load_path_insert_index) -The index to insert activated gem paths into the $LOAD_PATH. The activated -gem's paths are inserted before site lib directory by default. -## load_plugin_files(plugins ) [](#method-c-load_plugin_files) -Load `plugins` as Ruby files -## load_plugins() [](#method-c-load_plugins) -Find rubygems plugin files in the standard location and load them -## load_safe_marshal() [](#method-c-load_safe_marshal) -## load_yaml() [](#method-c-load_yaml) -Loads YAML, preferring Psych -## location_of_caller(depth 1) [](#method-c-location_of_caller) -The file name and line number of the caller of the caller of this method. - -`depth` is how many layers up the call stack it should go. - -e.g., - -def a; Gem.location_of_caller; end a #=> ["x.rb", 2] # (it'll vary depending -on file name and line number) - -def b; c; end def c; Gem.location_of_caller(2); end b #=> ["x.rb", 6] # -(it'll vary depending on file name and line number) -## marshal_version() [](#method-c-marshal_version) -The version of the Marshal format for your Ruby. -## needs() [](#method-c-needs) -**@yield** [rs] - -## open_file(path , flags , &block ) [](#method-c-open_file) -Open a file with given flags -## open_file_with_flock(path , &block ) [](#method-c-open_file_with_flock) -Open a file with given flags, and protect access with flock -## open_file_with_lock(path , &block ) [](#method-c-open_file_with_lock) -Open a file with given flags, and protect access with a file lock -## operating_system_defaults() [](#method-c-operating_system_defaults) -Default options for gem commands for Ruby packagers. - -The options here should be structured as an array of string "gem" command -names as keys and a string of the default options as values. - -Example: - -def self.operating_system_defaults - { - 'install' => '--no-rdoc --no-ri --env-shebang', - 'update' => '--no-rdoc --no-ri --env-shebang' - } - -end -## path() [](#method-c-path) -## path_separator() [](#method-c-path_separator) -How String Gem paths should be split. Overridable for esoteric platforms. -## paths() [](#method-c-paths) -Retrieve the PathSupport object that RubyGems uses to lookup files. -## paths=(env ) [](#method-c-paths=) -Initialize the filesystem paths to use from `env`. `env` is a hash-like object -(typically ENV) that is queried for 'GEM_HOME', 'GEM_PATH', and -'GEM_SPEC_CACHE' Keys for the `env` hash should be Strings, and values of the -hash should be Strings or `nil`. -## platform_defaults() [](#method-c-platform_defaults) -Default options for gem commands for Ruby implementers. - -The options here should be structured as an array of string "gem" command -names as keys and a string of the default options as values. - -Example: - -def self.platform_defaults - { - 'install' => '--no-rdoc --no-ri --env-shebang', - 'update' => '--no-rdoc --no-ri --env-shebang' - } - -end -## platforms() [](#method-c-platforms) -Array of platforms this RubyGems supports. -## platforms=(platforms ) [](#method-c-platforms=) -Set array of platforms this RubyGems supports (primarily for testing). -## plugin_suffix_pattern() [](#method-c-plugin_suffix_pattern) -Glob pattern for require-able plugin suffixes. -## plugin_suffix_regexp() [](#method-c-plugin_suffix_regexp) -Regexp for require-able plugin suffixes. -## plugindir(install_dir Gem.dir) [](#method-c-plugindir) -The path were rubygems plugins are to be installed. -## post_build(&hook ) [](#method-c-post_build) -Adds a post-build hook that will be passed an Gem::Installer instance when -Gem::Installer#install is called. The hook is called after the gem has been -extracted and extensions have been built but before the executables or gemspec -has been written. If the hook returns `false` then the gem's files will be -removed and the install will be aborted. -## post_install(&hook ) [](#method-c-post_install) -Adds a post-install hook that will be passed an Gem::Installer instance when -Gem::Installer#install is called -## post_reset(&hook ) [](#method-c-post_reset) -Adds a hook that will get run after Gem::Specification.reset is run. -## post_uninstall(&hook ) [](#method-c-post_uninstall) -Adds a post-uninstall hook that will be passed a Gem::Uninstaller instance and -the spec that was uninstalled when Gem::Uninstaller#uninstall is called -## pre_install(&hook ) [](#method-c-pre_install) -Adds a pre-install hook that will be passed an Gem::Installer instance when -Gem::Installer#install is called. If the hook returns `false` then the -install will be aborted. -## pre_reset(&hook ) [](#method-c-pre_reset) -Adds a hook that will get run before Gem::Specification.reset is run. -## pre_uninstall(&hook ) [](#method-c-pre_uninstall) -Adds a pre-uninstall hook that will be passed an Gem::Uninstaller instance and -the spec that will be uninstalled when Gem::Uninstaller#uninstall is called -## prefix() [](#method-c-prefix) -The directory prefix this RubyGems was installed at. If your prefix is in a -standard location (ie, rubygems is installed where you'd expect it to be), -then prefix returns nil. -## read_binary(path ) [](#method-c-read_binary) -Safely read a file in binary mode on all platforms. -## refresh() [](#method-c-refresh) -Refresh available gems from disk. -## register_default_spec(spec ) [](#method-c-register_default_spec) -Register a Gem::Specification for default gem. - -Two formats for the specification are supported: - -* MRI 2.0 style, where spec.files contains unprefixed require names. The - spec's filenames will be registered as-is. -* New style, where spec.files contains files prefixed with paths from - spec.require_paths. The prefixes are stripped before registering the - spec's filenames. Unprefixed files are omitted. -## ruby() [](#method-c-ruby) -The path to the running Ruby interpreter. -## ruby=(ruby ) [](#method-c-ruby=) -Allows setting path to Ruby. -## ruby_api_version() [](#method-c-ruby_api_version) -Returns a String containing the API compatibility version of Ruby -## ruby_engine() [](#method-c-ruby_engine) -## ruby_version() [](#method-c-ruby_version) -A Gem::Version for the currently running Ruby. -## rubygems_version() [](#method-c-rubygems_version) -A Gem::Version for the currently running RubyGems -## searcher=(searcher ) [](#method-c-searcher=) -Allows setting the gem path searcher. -## set_target_rbconfig(rbconfig_path ) [](#method-c-set_target_rbconfig) -## solaris_platform?() [](#method-c-solaris_platform?) -Is this platform Solaris? -**@return** [Boolean] - -## source_date_epoch() [](#method-c-source_date_epoch) -Returns the value of Gem.source_date_epoch_string, as a Time object. - -This is used throughout RubyGems for enabling reproducible builds. -## source_date_epoch_string() [](#method-c-source_date_epoch_string) -If the SOURCE_DATE_EPOCH environment variable is set, returns it's value. -Otherwise, returns the time that `Gem.source_date_epoch_string` was first -called in the same format as SOURCE_DATE_EPOCH. - -NOTE(@duckinator): The implementation is a tad weird because we want to: - 1. Make builds reproducible by default, by having this function always - return the same result during a given run. - 2. Allow changing ENV['SOURCE_DATE_EPOCH'] at runtime, since multiple - tests that set this variable will be run in a single process. - -If you simplify this function and a lot of tests fail, that is likely due to -#2 above. - -Details on SOURCE_DATE_EPOCH: -https://reproducible-builds.org/specs/source-date-epoch/ -## sources() [](#method-c-sources) -Returns an Array of sources to fetch remote gems from. Uses default_sources if -the sources list is empty. -## sources=(new_sources ) [](#method-c-sources=) -Need to be able to set the sources without calling Gem.sources.replace since -that would cause an infinite loop. - -DOC: This comment is not documentation about the method itself, it's more of a -code comment about the implementation. -## spec_cache_dir() [](#method-c-spec_cache_dir) -## state_file() [](#method-c-state_file) -The path to standard location of the user's state file. -## state_home() [](#method-c-state_home) -The path to standard location of the user's state directory. -## suffix_pattern() [](#method-c-suffix_pattern) -Glob pattern for require-able path suffixes. -## suffix_regexp() [](#method-c-suffix_regexp) -Regexp for require-able path suffixes. -## suffixes() [](#method-c-suffixes) -Suffixes for require-able paths. -## target_rbconfig() [](#method-c-target_rbconfig) -The RbConfig object for the deployment target platform. - -This is usually the same as the running platform, but may be different if you -are cross-compiling. -## time(msg , width 0, display Gem.configuration.verbose) [](#method-c-time) -Prints the amount of time the supplied block takes to run using the debug UI -output. -## try_activate(path ) [](#method-c-try_activate) -Try to activate a gem containing `path`. Returns true if activation succeeded -or wasn't needed because it was already activated. Returns false if it can't -find the path in a gem. -## ui() [](#method-c-ui) -Lazily loads DefaultUserInteraction and returns the default UI. -## use_gemdeps(path nil) [](#method-c-use_gemdeps) -Looks for a gem dependency file at `path` and activates the gems in the file -if found. If the file is not found an ArgumentError is raised. - -If `path` is not given the RUBYGEMS_GEMDEPS environment variable is used, but -if no file is found no exception is raised. - -If '-' is given for `path` RubyGems searches up from the current working -directory for gem dependency files (gem.deps.rb, Gemfile, Isolate) and -activates the gems in the first one found. - -You can run this automatically when rubygems starts. To enable, set the -`RUBYGEMS_GEMDEPS` environment variable to either the path of your gem -dependencies file or "-" to auto-discover in parent directories. - -NOTE: Enabling automatic discovery on multiuser systems can lead to execution -of arbitrary code when used from directories outside your control. -## use_paths(home , *paths ) [](#method-c-use_paths) -Use the `home` and `paths` values for Gem.dir and Gem.path. Used mainly by -the unit tests to provide environment isolation. -## user_dir() [](#method-c-user_dir) -Path for gems in the user's home directory -## user_home() [](#method-c-user_home) -The home directory for the user. -## vendor_dir() [](#method-c-vendor_dir) -Directory where vendor gems are installed. -## win_platform=(val ) [](#method-c-win_platform=) -Allows toggling Windows behavior. -## win_platform?() [](#method-c-win_platform?) -Is this a windows platform? -**@return** [Boolean] - -## write_binary(path , data ) [](#method-c-write_binary) -Safely write a file in binary mode on all platforms. -# Attributes -## disable_system_update_message[RW] [](#attribute-c-disable_system_update_message) -RubyGems distributors (like operating system package managers) can disable -RubyGems update by setting this to error message printed to end-users on gem -update --system instead of actual update. - -## discover_gems_on_require[RW] [](#attribute-c-discover_gems_on_require) -Whether RubyGems should enhance builtin `require` to automatically check -whether the path required is present in installed gems, and automatically -activate them and add them to `$LOAD_PATH`. - -## done_installing_hooks[RW] [](#attribute-c-done_installing_hooks) -The list of hooks to be run after Gem::DependencyInstaller installs a set of -gems - -## gemdeps[RW] [](#attribute-c-gemdeps) -GemDependencyAPI object, which is set when .use_gemdeps is called. This -contains all the information from the Gemfile. - -## loaded_specs[RW] [](#attribute-c-loaded_specs) -Hash of loaded Gem::Specification keyed by name - -## post_build_hooks[RW] [](#attribute-c-post_build_hooks) -The list of hooks to be run after Gem::Installer#install extracts files and -builds extensions - -## post_install_hooks[RW] [](#attribute-c-post_install_hooks) -The list of hooks to be run after Gem::Installer#install completes -installation - -## post_reset_hooks[RW] [](#attribute-c-post_reset_hooks) -The list of hooks to be run after Gem::Specification.reset is run. - -## post_uninstall_hooks[RW] [](#attribute-c-post_uninstall_hooks) -The list of hooks to be run after Gem::Uninstaller#uninstall completes -installation - -## pre_install_hooks[RW] [](#attribute-c-pre_install_hooks) -The list of hooks to be run before Gem::Installer#install does any work - -## pre_reset_hooks[RW] [](#attribute-c-pre_reset_hooks) -The list of hooks to be run before Gem::Specification.reset is run. - -## pre_uninstall_hooks[RW] [](#attribute-c-pre_uninstall_hooks) -The list of hooks to be run before Gem::Uninstaller#uninstall does any work - - diff --git a/example/ruby/Gem/AvailableSet.md b/example/ruby/Gem/AvailableSet.md deleted file mode 100644 index 120b674..0000000 --- a/example/ruby/Gem/AvailableSet.md +++ /dev/null @@ -1,2103 +0,0 @@ -# Class: Gem::AvailableSet -**Inherits:** Object - -**Includes:** Enumerable - - - - -# Attributes -## remote[RW] [](#attribute-i-remote) -:nodoc: - -## set[RW] [](#attribute-i-set) -Returns the value of attribute set. - - -#Instance Methods -## <<(o) [](#method-i-<<) - -## add(spec, source) [](#method-i-add) - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## all_specs() [](#method-i-all_specs) - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Yields each Tuple in this AvailableSet - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_spec() [](#method-i-each_spec) -Yields the Gem::Specification for each Tuple in this AvailableSet - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all(req) [](#method-i-find_all) -Used by the Resolver, the protocol to use a AvailableSet as a search Set. - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) - -**@return** [AvailableSet] a new instance of AvailableSet - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inject_into_list(dep_list) [](#method-i-inject_into_list) - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## match_platform!() [](#method-i-match_platform!) - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pick_best!() [](#method-i-pick_best!) - -## prefetch(reqs) [](#method-i-prefetch) - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## remove_installed!(dep) [](#method-i-remove_installed!) - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sorted() [](#method-i-sorted) - -## source_for(spec) [](#method-i-source_for) - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_request_set(development:none) [](#method-i-to_request_set) -Converts this AvailableSet into a RequestSet that can be used to install gems. - -If `development` is :none then no development dependencies are installed. -Other options are :shallow for only direct development dependencies of the -gems in this set or :all for all development dependencies. - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/AvailableSet/Tuple.md b/example/ruby/Gem/AvailableSet/Tuple.md deleted file mode 100644 index 5ee6f82..0000000 --- a/example/ruby/Gem/AvailableSet/Tuple.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Gem::AvailableSet::Tuple -**Inherits:** Struct - - - - -# Attributes -## source[RW] [](#attribute-i-source) -Returns the value of attribute source - -**@return** [Object] the current value of source - -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec - -**@return** [Object] the current value of spec - - diff --git a/example/ruby/Gem/BUNDLED_GEMS.md b/example/ruby/Gem/BUNDLED_GEMS.md deleted file mode 100644 index 16cad50..0000000 --- a/example/ruby/Gem/BUNDLED_GEMS.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: Gem::BUNDLED_GEMS - - -:nodoc: - - -# Class Methods -## build_message(gem ) [](#method-c-build_message) -## find_gem(path ) [](#method-c-find_gem) -## replace_require(specs ) [](#method-c-replace_require) -## uplevel() [](#method-c-uplevel) -## warning?(name , specs: nil) [](#method-c-warning?) -**@return** [Boolean] - - diff --git a/example/ruby/Gem/BasicSpecification.md b/example/ruby/Gem/BasicSpecification.md deleted file mode 100644 index bcb8dc8..0000000 --- a/example/ruby/Gem/BasicSpecification.md +++ /dev/null @@ -1,179 +0,0 @@ -# Class: Gem::BasicSpecification -**Inherits:** Object - -**Extended by:** Gem::Deprecate - - -BasicSpecification is an abstract class which implements some common code used -by both Specification and StubSpecification. - - -# Class Methods -## default_specifications_dir() [](#method-c-default_specifications_dir) -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -# Attributes -## base_dir[RW] [](#attribute-i-base_dir) -Returns the full path to the base gem directory. - -eg: /usr/local/lib/ruby/gems/1.8 - -**@raise** [NotImplementedError] - -## extension_dir[RW] [](#attribute-i-extension_dir) -Returns full path to the directory where gem's extensions are installed. - -## full_gem_path[RW] [](#attribute-i-full_gem_path) -The full path to the gem (install path + full name). - -TODO: This is duplicated with #gem_dir. Eventually either of them should be -deprecated. - -## ignored=[R] [](#attribute-i-ignored=) -Is this specification ignored for activation purposes? - -## loaded_from[RW] [](#attribute-i-loaded_from) -The path this gemspec was loaded from. This attribute is not persisted. - - -#Instance Methods -## activated?() [](#method-i-activated?) -True when the gem has been activated - -**@raise** [NotImplementedError] - -**@return** [Boolean] - -## base_dir_priority(gem_path) [](#method-i-base_dir_priority) -Gems higher up in `gem_path` take precedence - -## contains_requirable_file?(file) [](#method-i-contains_requirable_file?) -Return true if this spec can require `file`. - -**@return** [Boolean] - -## datadir() [](#method-i-datadir) -The path to the data directory for this gem. - -## default_gem?() [](#method-i-default_gem?) - -**@return** [Boolean] - -## default_gem_priority() [](#method-i-default_gem_priority) -Regular gems take precedence over default gems - -## extensions_dir() [](#method-i-extensions_dir) -Returns path to the extensions directory. - -## full_name() [](#method-i-full_name) -Returns the full name (name-version) of this Gem. Platform information is -included (name-version-platform) if it is specified and not the default Ruby -platform. - -## full_name_with_location() [](#method-i-full_name_with_location) -Returns the full name of this Gem (see `Gem::BasicSpecification#full_name`). -Information about where the gem is installed is also included if not installed -in the default GEM_HOME. - -## full_require_paths() [](#method-i-full_require_paths) -Full paths in the gem to add to `$LOAD_PATH` when this gem is activated. - -## gem_build_complete_path() [](#method-i-gem_build_complete_path) -The path to the gem.build_complete file within the extension install -directory. - -## gem_dir() [](#method-i-gem_dir) -Returns the full path to this spec's gem directory. eg: -/usr/local/lib/ruby/1.8/gems/mygem-1.0 - -TODO: This is duplicated with #full_gem_path. Eventually either of them should -be deprecated. - -## gems_dir() [](#method-i-gems_dir) -Returns the full path to the gems directory containing this spec's gem -directory. eg: /usr/local/lib/ruby/1.8/gems - -**@raise** [NotImplementedError] - -## ignored?() [](#method-i-ignored?) -Return true if this spec should be ignored because it's missing extensions. - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [BasicSpecification] a new instance of BasicSpecification - -## internal_init() [](#method-i-internal_init) -:nodoc: - -## lib_dirs_glob() [](#method-i-lib_dirs_glob) -Returns a string usable in Dir.glob to match all requirable paths for this -spec. - -## matches_for_glob(glob) [](#method-i-matches_for_glob) -Return all files in this gem that match for `glob`. - -## name() [](#method-i-name) -Name of the gem - -**@raise** [NotImplementedError] - -## platform() [](#method-i-platform) -Platform of the gem - -**@raise** [NotImplementedError] - -## plugins() [](#method-i-plugins) -Returns the list of plugins in this spec. - -## raw_require_paths() [](#method-i-raw_require_paths) -:nodoc: - -**@raise** [NotImplementedError] - -## require_paths() [](#method-i-require_paths) -Paths in the gem to add to `$LOAD_PATH` when this gem is activated. - -See also #require_paths= - -If you have an extension you do not need to add `"ext"` to the require path, -the extension build process will copy the extension files into "lib" for you. - -The default value is `"lib"` - -Usage: - - # If all library files are in the root directory... - spec.require_path = '.' - -## source_paths() [](#method-i-source_paths) -Returns the paths to the source files for use with analysis and documentation -tools. These paths are relative to full_gem_path. - -## stubbed?() [](#method-i-stubbed?) -Whether this specification is stubbed - i.e. we have information about the gem -from a stub line, without having to evaluate the entire gemspec file. - -**@raise** [NotImplementedError] - -**@return** [Boolean] - -## this() [](#method-i-this) - -## to_fullpath(path) [](#method-i-to_fullpath) -Full path of the target library file. If the file is not in this gem, return -nil. - -## to_spec() [](#method-i-to_spec) -Return a Gem::Specification from this gem - -**@raise** [NotImplementedError] - -## version() [](#method-i-version) -Version of the gem - -**@raise** [NotImplementedError] - diff --git a/example/ruby/Gem/BetterPermissionError.md b/example/ruby/Gem/BetterPermissionError.md deleted file mode 100644 index 24d1457..0000000 --- a/example/ruby/Gem/BetterPermissionError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::BetterPermissionError - - - - - -#Instance Methods -## data() [](#method-i-data) - diff --git a/example/ruby/Gem/BundlerVersionFinder.md b/example/ruby/Gem/BundlerVersionFinder.md deleted file mode 100644 index 8d8463f..0000000 --- a/example/ruby/Gem/BundlerVersionFinder.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::BundlerVersionFinder - - - - -# Class Methods -## bundler_version() [](#method-c-bundler_version) -## prioritize!(specs ) [](#method-c-prioritize!) - diff --git a/example/ruby/Gem/CIDetector.md b/example/ruby/Gem/CIDetector.md deleted file mode 100644 index 330132d..0000000 --- a/example/ruby/Gem/CIDetector.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Gem::CIDetector - - - - -# Class Methods -## ci?() [](#method-c-ci?) -**@return** [Boolean] - -## ci_strings() [](#method-c-ci_strings) - diff --git a/example/ruby/Gem/Command.md b/example/ruby/Gem/Command.md deleted file mode 100644 index e631bf5..0000000 --- a/example/ruby/Gem/Command.md +++ /dev/null @@ -1,266 +0,0 @@ -# Class: Gem::Command -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - -Base class for all Gem commands. When creating a new gem command, define -#initialize, #execute, #arguments, #defaults_str, #description and #usage (as -appropriate). See the above mentioned methods for details. - -A very good example to look at is Gem::Commands::ContentsCommand - - -# Class Methods -## add_common_option(*args , &handler ) [](#method-c-add_common_option) -## add_specific_extra_args(cmd , args ) [](#method-c-add_specific_extra_args) -Add a list of extra arguments for the given command. `args` may be an array -or a string to be split on white space. -## build_args() [](#method-c-build_args) -Arguments used when building gems -## build_args=(value ) [](#method-c-build_args=) -## common_options() [](#method-c-common_options) -## extra_args() [](#method-c-extra_args) -## extra_args=(value ) [](#method-c-extra_args=) -## specific_extra_args(cmd ) [](#method-c-specific_extra_args) -Return an array of extra arguments for the command. The extra arguments come -from the gem configuration file read at program startup. -## specific_extra_args_hash() [](#method-c-specific_extra_args_hash) -Accessor for the specific extra args hash (self initializing). -## specific_extra_args_hash=(value ) [](#method-c-specific_extra_args_hash=) -Allows resetting the hash of specific args per command. -# Attributes -## command[RW] [](#attribute-i-command) -The name of the command. - -## defaults[RW] [](#attribute-i-defaults) -The default options for the command. - -## options[RW] [](#attribute-i-options) -The options for the command. - -## program_name[RW] [](#attribute-i-program_name) -The name of the command for command-line invocation. - -## summary[RW] [](#attribute-i-summary) -A short description of the command. - - -#Instance Methods -## add_extra_args(args) [](#method-i-add_extra_args) -Adds extra args from ~/.gemrc - -## add_option(*opts, &handler) [](#method-i-add_option) -Add a command-line option and handler to the command. - -See Gem::OptionParser#make_switch for an explanation of `opts`. - -`handler` will be called with two values, the value of the argument and the -options hash. - -If the first argument of add_option is a Symbol, it's used to group options in -output. See `gem help list` for an example. - -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## arguments() [](#method-i-arguments) -Override to provide details of the arguments a command takes. It should -return a left-justified string, one argument per line. - -For example: - - def usage - "#{program_name} FILE [FILE ...]" - end - - def arguments - "FILE name of file to find" - end - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## begins?(long, short) [](#method-i-begins?) -True if `long` begins with the characters from `short`. - -**@return** [Boolean] - -## check_deprecated_options(options) [](#method-i-check_deprecated_options) - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## defaults_str() [](#method-i-defaults_str) -Override to display the default values of the command options. (similar to -`arguments`, but displays the default values). - -For example: - - def defaults_str - --no-gems-first --no-all - end - -## deprecate_option(name, version:nil, extra_msg:nil) [](#method-i-deprecate_option) -Mark a command-line option as deprecated, and optionally specify a deprecation -horizon. - -Note that with the current implementation, every version of the option needs -to be explicitly deprecated, so to deprecate an option defined as - - add_option('-t', '--[no-]test', 'Set test mode') do |value, options| - # ... stuff ... - end - -you would need to explicitly add a call to `deprecate_option` for every -version of the option you want to deprecate, like - - deprecate_option('-t') - deprecate_option('--test') - deprecate_option('--no-test') - -## deprecated?() [](#method-i-deprecated?) - -**@return** [Boolean] - -## description() [](#method-i-description) -Override to display a longer description of what this command does. - -## execute() [](#method-i-execute) -Override to provide command handling. - -#options will be filled in with your parsed options, unparsed options will be -left in `options[:args]`. - -See also: #get_all_gem_names, #get_one_gem_name, #get_one_optional_argument - -**@raise** [Gem::Exception] - -## extract_gem_name_and_version(name) [](#method-i-extract_gem_name_and_version) -:nodoc: - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## get_all_gem_names() [](#method-i-get_all_gem_names) -Get all gem names from the command line. - -## get_all_gem_names_and_versions() [](#method-i-get_all_gem_names_and_versions) -Get all [gem, version] from the command line. - -An argument in the form gem:ver is pull apart into the gen name and version, -respectively. - -## get_one_gem_name() [](#method-i-get_one_gem_name) -Get a single gem name from the command line. Fail if there is no gem name or -if there is more than one gem name given. - -## get_one_optional_argument() [](#method-i-get_one_optional_argument) -Get a single optional argument from the command line. If more than one -argument is given, return only the first. Return nil if none are given. - -## handle_options(args) [](#method-i-handle_options) -Handle the given list of arguments by parsing them and recording the results. - -## handles?(args) [](#method-i-handles?) -True if the command handles the given argument list. - -**@return** [Boolean] - -## initialize(command, summarynil, defaults{}) [](#method-i-initialize) -Initializes a generic gem command named `command`. `summary` is a short -description displayed in `gem help commands`. `defaults` are the default -options. Defaults should be mirrored in #defaults_str, unless there are none. - -When defining a new command subclass, use add_option to add command-line -switches. - -Unhandled arguments (gem names, files, etc.) are left in `options[:args]`. - -**@return** [Command] a new instance of Command - -## invoke(*args) [](#method-i-invoke) -Invoke the command with the given list of arguments. - -## invoke_with_build_args(args, build_args) [](#method-i-invoke_with_build_args) -Invoke the command with the given list of normal arguments and additional -build arguments. - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## merge_options(new_options) [](#method-i-merge_options) -Merge a set of command options with the set of default options (without -modifying the default option hash). - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## parser() [](#method-i-parser) -Create on demand parser. - -## remove_option(name) [](#method-i-remove_option) -Remove previously defined command-line argument `name`. - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## show_help() [](#method-i-show_help) -Display the help message for the command. - -## show_lookup_failure(gem_name, version, errors, suppress_suggestionsfalse, required_bynil) [](#method-i-show_lookup_failure) -Display to the user that a gem couldn't be found and reasons why -- - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## usage() [](#method-i-usage) -Override to display the usage for an individual gem command. - -The text "[options]" is automatically appended to the usage text. - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - -## when_invoked(&block) [](#method-i-when_invoked) -Call the given block when invoked. - -Normal command invocations just executes the `execute` method of the command. -Specifying an invocation block allows the test methods to override the normal -action of a command to determine that it has been invoked correctly. - diff --git a/example/ruby/Gem/CommandLineError.md b/example/ruby/Gem/CommandLineError.md deleted file mode 100644 index d5b0408..0000000 --- a/example/ruby/Gem/CommandLineError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::CommandLineError -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/CommandManager.md b/example/ruby/Gem/CommandManager.md deleted file mode 100644 index 1721e01..0000000 --- a/example/ruby/Gem/CommandManager.md +++ /dev/null @@ -1,129 +0,0 @@ -# Class: Gem::CommandManager -**Inherits:** Object - -**Includes:** Gem::Text, Gem::UserInteraction - - -The command manager registers and installs all the individual sub-commands -supported by the gem command. - -Extra commands can be provided by writing a rubygems_plugin.rb file in an -installed gem. You should register your command against the -Gem::CommandManager instance, like this: - - # file rubygems_plugin.rb - require 'rubygems/command_manager' - - Gem::CommandManager.instance.register_command :edit - -You should put the implementation of your command in rubygems/commands. - - # file rubygems/commands/edit_command.rb - class Gem::Commands::EditCommand < Gem::Command - # ... - end - -See Gem::Command for instructions on writing gem commands. - - -# Class Methods -## instance() [](#method-c-instance) -Return the authoritative instance of the command manager. -## reset() [](#method-c-reset) -Reset the authoritative instance of the command manager. - -#Instance Methods -## [](command_name) [](#method-i-[]) -Returns a Command instance for `command_name` - -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## command_names() [](#method-i-command_names) -Return a sorted list of all command names as strings. - -## find_alias_command(cmd_name) [](#method-i-find_alias_command) - -## find_command(cmd_name) [](#method-i-find_command) - -## find_command_possibilities(cmd_name) [](#method-i-find_command_possibilities) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize() [](#method-i-initialize) -Register all the subcommands supported by the gem command. - -**@return** [CommandManager] a new instance of CommandManager - -## instance() [](#method-i-instance) -Returns self. Allows a CommandManager instance to stand in for the class -itself. - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## process_args(args, build_argsnil) [](#method-i-process_args) - -## register_command(command, objfalse) [](#method-i-register_command) -Register the Symbol `command` as a gem command. - -## run(args, build_argsnil) [](#method-i-run) -Run the command specified by `args`. - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## unregister_command(command) [](#method-i-unregister_command) -Unregister the Symbol `command` as a gem command. - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/Commands.md b/example/ruby/Gem/Commands.md deleted file mode 100644 index 0c5c007..0000000 --- a/example/ruby/Gem/Commands.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Commands - - -Commands will be placed in this namespace - - - diff --git a/example/ruby/Gem/Commands/BuildCommand.md b/example/ruby/Gem/Commands/BuildCommand.md deleted file mode 100644 index fccc482..0000000 --- a/example/ruby/Gem/Commands/BuildCommand.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Gem::Commands::BuildCommand -**Inherits:** Gem::Command - -**Includes:** Gem::GemspecHelpers, Gem::VersionOption - - - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## find_gemspec(glob"*.gemspec") [](#method-i-find_gemspec) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [BuildCommand] a new instance of BuildCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/CertCommand.md b/example/ruby/Gem/Commands/CertCommand.md deleted file mode 100644 index 34297f3..0000000 --- a/example/ruby/Gem/Commands/CertCommand.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: Gem::Commands::CertCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## add_certificate(certificate) [](#method-i-add_certificate) -:nodoc: - -## build(email) [](#method-i-build) - -## build_cert(email, key) [](#method-i-build_cert) -:nodoc: - -## build_key() [](#method-i-build_key) -:nodoc: - -**@raise** [Gem::CommandLineError] - -## certificates_matching(filter) [](#method-i-certificates_matching) - -## check_openssl() [](#method-i-check_openssl) - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) - -**@return** [CertCommand] a new instance of CertCommand - -## list_certificates_matching(filter) [](#method-i-list_certificates_matching) -:nodoc: - -## load_default_cert() [](#method-i-load_default_cert) - -## load_default_key() [](#method-i-load_default_key) - -## load_defaults() [](#method-i-load_defaults) -:nodoc: - -## open_cert(certificate_file) [](#method-i-open_cert) - -## open_private_key(key_file) [](#method-i-open_private_key) - -## re_sign_cert(cert, cert_path, private_key) [](#method-i-re_sign_cert) - -## remove_certificates_matching(filter) [](#method-i-remove_certificates_matching) -:nodoc: - -## sign(cert_file) [](#method-i-sign) - -## sign_certificates() [](#method-i-sign_certificates) -:nodoc: - diff --git a/example/ruby/Gem/Commands/CheckCommand.md b/example/ruby/Gem/Commands/CheckCommand.md deleted file mode 100644 index 6905058..0000000 --- a/example/ruby/Gem/Commands/CheckCommand.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Gem::Commands::CheckCommand -**Inherits:** Gem::Command - -**Includes:** Gem::VersionOption - - - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## check_gems() [](#method-i-check_gems) - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## doctor() [](#method-i-doctor) - -## execute() [](#method-i-execute) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [CheckCommand] a new instance of CheckCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/CleanupCommand.md b/example/ruby/Gem/Commands/CleanupCommand.md deleted file mode 100644 index ffbc23a..0000000 --- a/example/ruby/Gem/Commands/CleanupCommand.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Gem::Commands::CleanupCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## arguments() [](#method-i-arguments) -:nodoc: - -## clean_gems() [](#method-i-clean_gems) - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## get_candidate_gems() [](#method-i-get_candidate_gems) - -## get_gems_to_cleanup() [](#method-i-get_gems_to_cleanup) - -## get_primary_gems() [](#method-i-get_primary_gems) - -## initialize() [](#method-i-initialize) - -**@return** [CleanupCommand] a new instance of CleanupCommand - -## uninstall_dep(spec) [](#method-i-uninstall_dep) - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/ContentsCommand.md b/example/ruby/Gem/Commands/ContentsCommand.md deleted file mode 100644 index 19b5c47..0000000 --- a/example/ruby/Gem/Commands/ContentsCommand.md +++ /dev/null @@ -1,63 +0,0 @@ -# Class: Gem::Commands::ContentsCommand -**Inherits:** Gem::Command - -**Includes:** Gem::VersionOption - - - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## files_in(spec) [](#method-i-files_in) - -## files_in_default_gem(spec) [](#method-i-files_in_default_gem) - -## files_in_gem(spec) [](#method-i-files_in_gem) - -## gem_contents(name) [](#method-i-gem_contents) - -## gem_install_dir(name) [](#method-i-gem_install_dir) - -## gem_names() [](#method-i-gem_names) -:nodoc: - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [ContentsCommand] a new instance of ContentsCommand - -## path_description(spec_dirs) [](#method-i-path_description) -:nodoc: - -## show_files(files) [](#method-i-show_files) - -## spec_for(name) [](#method-i-spec_for) - -## specification_directories() [](#method-i-specification_directories) -:nodoc: - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/CrashCommand.md b/example/ruby/Gem/Commands/CrashCommand.md deleted file mode 100644 index 93b6015..0000000 --- a/example/ruby/Gem/Commands/CrashCommand.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::Commands::CrashCommand -**Inherits:** Gem::Command - - - - - diff --git a/example/ruby/Gem/Commands/DependencyCommand.md b/example/ruby/Gem/Commands/DependencyCommand.md deleted file mode 100644 index 4438e1f..0000000 --- a/example/ruby/Gem/Commands/DependencyCommand.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: Gem::Commands::DependencyCommand -**Inherits:** Gem::Command - -**Includes:** Gem::LocalRemoteOptions, Gem::VersionOption - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## display_pipe(specs) [](#method-i-display_pipe) -:nodoc: - -## display_readable(specs, reverse) [](#method-i-display_readable) -:nodoc: - -## ensure_local_only_reverse_dependencies() [](#method-i-ensure_local_only_reverse_dependencies) -:nodoc: - -## ensure_specs(specs) [](#method-i-ensure_specs) -:nodoc: - -## execute() [](#method-i-execute) - -## fetch_remote_specs(name, requirement, prerelease) [](#method-i-fetch_remote_specs) -:nodoc: - -## fetch_specs(name_pattern, requirement, prerelease) [](#method-i-fetch_specs) -:nodoc: - -## find_reverse_dependencies(spec) [](#method-i-find_reverse_dependencies) -Returns an Array of [specification, dep] that are satisfied by `spec`. - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [DependencyCommand] a new instance of DependencyCommand - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## print_dependencies(spec, level0) [](#method-i-print_dependencies) -:nodoc: - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## reverse_dependencies(specs) [](#method-i-reverse_dependencies) -:nodoc: - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/EnvironmentCommand.md b/example/ruby/Gem/Commands/EnvironmentCommand.md deleted file mode 100644 index 6c9c6a3..0000000 --- a/example/ruby/Gem/Commands/EnvironmentCommand.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Gem::Commands::EnvironmentCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## add_path(out, path) [](#method-i-add_path) - -## arguments() [](#method-i-arguments) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) - -**@return** [EnvironmentCommand] a new instance of EnvironmentCommand - -## show_environment() [](#method-i-show_environment) -:nodoc: - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/ExecCommand.md b/example/ruby/Gem/Commands/ExecCommand.md deleted file mode 100644 index 44d1631..0000000 --- a/example/ruby/Gem/Commands/ExecCommand.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Gem::Commands::ExecCommand -**Inherits:** Gem::Command - -**Includes:** Gem::VersionOption - - - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [ExecCommand] a new instance of ExecCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/FetchCommand.md b/example/ruby/Gem/Commands/FetchCommand.md deleted file mode 100644 index 857f960..0000000 --- a/example/ruby/Gem/Commands/FetchCommand.md +++ /dev/null @@ -1,79 +0,0 @@ -# Class: Gem::Commands::FetchCommand -**Inherits:** Gem::Command - -**Includes:** Gem::LocalRemoteOptions, Gem::VersionOption - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## check_version() [](#method-i-check_version) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [FetchCommand] a new instance of FetchCommand - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/GenerateIndexCommand.md b/example/ruby/Gem/Commands/GenerateIndexCommand.md deleted file mode 100644 index 4892d31..0000000 --- a/example/ruby/Gem/Commands/GenerateIndexCommand.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Gem::Commands::GenerateIndexCommand -**Inherits:** Gem::Command - - - - -# Class Methods -## new() [](#method-c-new) -remove_method(:initialize) warns, but removing new does not warn - diff --git a/example/ruby/Gem/Commands/HelpCommand.md b/example/ruby/Gem/Commands/HelpCommand.md deleted file mode 100644 index 53c78ee..0000000 --- a/example/ruby/Gem/Commands/HelpCommand.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Commands::HelpCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) -:startdoc: - -**@return** [HelpCommand] a new instance of HelpCommand - -## show_command_help(command_name) [](#method-i-show_command_help) -:nodoc: - -## show_commands() [](#method-i-show_commands) -:nodoc: - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/InfoCommand.md b/example/ruby/Gem/Commands/InfoCommand.md deleted file mode 100644 index 6da9549..0000000 --- a/example/ruby/Gem/Commands/InfoCommand.md +++ /dev/null @@ -1,98 +0,0 @@ -# Class: Gem::Commands::InfoCommand -**Inherits:** Gem::Command - -**Includes:** Gem::QueryUtils - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_query_options() [](#method-i-add_query_options) - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## defaults_str() [](#method-i-defaults_str) - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [InfoCommand] a new instance of InfoCommand - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/InsCommand.md b/example/ruby/Gem/Commands/InsCommand.md deleted file mode 100644 index e000696..0000000 --- a/example/ruby/Gem/Commands/InsCommand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Gem::Commands::InsCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [InsCommand] a new instance of InsCommand - diff --git a/example/ruby/Gem/Commands/InstallCommand.md b/example/ruby/Gem/Commands/InstallCommand.md deleted file mode 100644 index b46569b..0000000 --- a/example/ruby/Gem/Commands/InstallCommand.md +++ /dev/null @@ -1,123 +0,0 @@ -# Class: Gem::Commands::InstallCommand -**Inherits:** Gem::Command - -**Includes:** Gem::InstallUpdateOptions, Gem::LocalRemoteOptions, Gem::UpdateSuggestion, Gem::VersionOption - - -Gem installer command line tool - -See `gem help install` - - -# Attributes -## installed_specs[RW] [](#attribute-i-installed_specs) -:nodoc: - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_install_update_options() [](#method-i-add_install_update_options) -Add the install/update options to the option parser. - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_security_option() [](#method-i-add_security_option) - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## check_version() [](#method-i-check_version) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## eligible_for_update?() [](#method-i-eligible_for_update?) -Determines if current environment is eligible for update suggestion. - -**@return** [Boolean] - -## execute() [](#method-i-execute) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [InstallCommand] a new instance of InstallCommand - -## install_from_gemdeps() [](#method-i-install_from_gemdeps) -:nodoc: - -## install_gem(name, version) [](#method-i-install_gem) -:nodoc: - -## install_gems() [](#method-i-install_gems) -:nodoc: - -## install_update_defaults_str() [](#method-i-install_update_defaults_str) -Default description for the gem install and update commands. - -## install_update_options() [](#method-i-install_update_options) -Default options for the gem install and update commands. - -## load_hooks() [](#method-i-load_hooks) -Loads post-install hooks - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## show_install_errors(errors) [](#method-i-show_install_errors) -:nodoc: - -## show_installed() [](#method-i-show_installed) -:nodoc: - -## update_suggestion() [](#method-i-update_suggestion) -Message to promote available RubyGems update with related gem update command. - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/InterruptCommand.md b/example/ruby/Gem/Commands/InterruptCommand.md deleted file mode 100644 index 0d7ed8d..0000000 --- a/example/ruby/Gem/Commands/InterruptCommand.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::Commands::InterruptCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## execute() [](#method-i-execute) - -**@raise** [Interrupt] - -## initialize() [](#method-i-initialize) - -**@return** [InterruptCommand] a new instance of InterruptCommand - diff --git a/example/ruby/Gem/Commands/ListCommand.md b/example/ruby/Gem/Commands/ListCommand.md deleted file mode 100644 index 2f0ae72..0000000 --- a/example/ruby/Gem/Commands/ListCommand.md +++ /dev/null @@ -1,100 +0,0 @@ -# Class: Gem::Commands::ListCommand -**Inherits:** Gem::Command - -**Includes:** Gem::QueryUtils - - -Searches for gems starting with the supplied argument. - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_query_options() [](#method-i-add_query_options) - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [ListCommand] a new instance of ListCommand - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/LockCommand.md b/example/ruby/Gem/Commands/LockCommand.md deleted file mode 100644 index a93254b..0000000 --- a/example/ruby/Gem/Commands/LockCommand.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Gem::Commands::LockCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## arguments() [](#method-i-arguments) -:nodoc: - -## complain(message) [](#method-i-complain) - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) - -**@return** [LockCommand] a new instance of LockCommand - -## spec_path(gem_full_name) [](#method-i-spec_path) - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/MirrorCommand.md b/example/ruby/Gem/Commands/MirrorCommand.md deleted file mode 100644 index 8cb3760..0000000 --- a/example/ruby/Gem/Commands/MirrorCommand.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Commands::MirrorCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) - -**@return** [MirrorCommand] a new instance of MirrorCommand - diff --git a/example/ruby/Gem/Commands/OpenCommand.md b/example/ruby/Gem/Commands/OpenCommand.md deleted file mode 100644 index 045bdb3..0000000 --- a/example/ruby/Gem/Commands/OpenCommand.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Gem::Commands::OpenCommand -**Inherits:** Gem::Command - -**Includes:** Gem::VersionOption - - - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## get_env_editor() [](#method-i-get_env_editor) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [OpenCommand] a new instance of OpenCommand - -## open_editor(path) [](#method-i-open_editor) - -## open_gem(name) [](#method-i-open_gem) - -## spec_for(name) [](#method-i-spec_for) - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/OutdatedCommand.md b/example/ruby/Gem/Commands/OutdatedCommand.md deleted file mode 100644 index 7515a64..0000000 --- a/example/ruby/Gem/Commands/OutdatedCommand.md +++ /dev/null @@ -1,67 +0,0 @@ -# Class: Gem::Commands::OutdatedCommand -**Inherits:** Gem::Command - -**Includes:** Gem::LocalRemoteOptions, Gem::VersionOption - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [OutdatedCommand] a new instance of OutdatedCommand - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Commands/OwnerCommand.md b/example/ruby/Gem/Commands/OwnerCommand.md deleted file mode 100644 index db33b37..0000000 --- a/example/ruby/Gem/Commands/OwnerCommand.md +++ /dev/null @@ -1,137 +0,0 @@ -# Class: Gem::Commands::OwnerCommand -**Inherits:** Gem::Command - -**Includes:** Gem::GemcutterUtilities, Gem::LocalRemoteOptions, Gem::Text - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_key_option() [](#method-i-add_key_option) -Add the --key option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_otp_option() [](#method-i-add_otp_option) -Add the --otp option - -## add_owners(name, owners) [](#method-i-add_owners) - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## api_key() [](#method-i-api_key) -The API key from the command options or from the user's configuration. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize() [](#method-i-initialize) - -**@return** [OwnerCommand] a new instance of OwnerCommand - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## manage_owners(method, name, owners) [](#method-i-manage_owners) - -## mfa_unauthorized?(response) [](#method-i-mfa_unauthorized?) - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## otp() [](#method-i-otp) -The OTP code from the command options or from the user's configuration. - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## remove_owners(name, owners) [](#method-i-remove_owners) - -## rubygems_api_request(method, path, hostnil, allowed_push_hostnil, scope:nil, credentials:{}, &block) [](#method-i-rubygems_api_request) -Creates an RubyGems API to `host` and `path` with the given HTTP `method`. - -If `allowed_push_host` metadata is present, then it will only allow that host. - -## set_api_key(host, key) [](#method-i-set_api_key) -Returns true when the user has enabled multifactor authentication from -`response` text and no otp provided by options. - -## show_owners(name) [](#method-i-show_owners) - -## sign_in(sign_in_hostnil, scope:nil) [](#method-i-sign_in) -Signs in with the RubyGems API at `sign_in_host` and sets the rubygems API -key. - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## update_scope(scope) [](#method-i-update_scope) - -## usage() [](#method-i-usage) -:nodoc: - -## verify_api_key(key) [](#method-i-verify_api_key) -Retrieves the pre-configured API key `key` or terminates interaction with an -error. - -## webauthn_enabled?() [](#method-i-webauthn_enabled?) - -**@return** [Boolean] - -## with_response(response, error_prefixnil) [](#method-i-with_response) -If `response` is an HTTP Success (2XX) response, yields the response if a -block was given or shows the response body to the user. - -If the response was not successful, shows an error to the user including the -`error_prefix` and the response body. If the response was a permanent -redirect, shows an error to the user including the redirect location. - diff --git a/example/ruby/Gem/Commands/PristineCommand.md b/example/ruby/Gem/Commands/PristineCommand.md deleted file mode 100644 index a6f6c1d..0000000 --- a/example/ruby/Gem/Commands/PristineCommand.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Gem::Commands::PristineCommand -**Inherits:** Gem::Command - -**Includes:** Gem::VersionOption - - - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [PristineCommand] a new instance of PristineCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/PushCommand.md b/example/ruby/Gem/Commands/PushCommand.md deleted file mode 100644 index 89e7bc6..0000000 --- a/example/ruby/Gem/Commands/PushCommand.md +++ /dev/null @@ -1,131 +0,0 @@ -# Class: Gem::Commands::PushCommand -**Inherits:** Gem::Command - -**Includes:** Gem::GemcutterUtilities, Gem::LocalRemoteOptions - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_key_option() [](#method-i-add_key_option) -Add the --key option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_otp_option() [](#method-i-add_otp_option) -Add the --otp option - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## api_key() [](#method-i-api_key) -The API key from the command options or from the user's configuration. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize() [](#method-i-initialize) - -**@return** [PushCommand] a new instance of PushCommand - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## mfa_unauthorized?(response) [](#method-i-mfa_unauthorized?) - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## otp() [](#method-i-otp) -The OTP code from the command options or from the user's configuration. - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## rubygems_api_request(method, path, hostnil, allowed_push_hostnil, scope:nil, credentials:{}, &block) [](#method-i-rubygems_api_request) -Creates an RubyGems API to `host` and `path` with the given HTTP `method`. - -If `allowed_push_host` metadata is present, then it will only allow that host. - -## send_gem(name) [](#method-i-send_gem) - -## set_api_key(host, key) [](#method-i-set_api_key) -Returns true when the user has enabled multifactor authentication from -`response` text and no otp provided by options. - -## sign_in(sign_in_hostnil, scope:nil) [](#method-i-sign_in) -Signs in with the RubyGems API at `sign_in_host` and sets the rubygems API -key. - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## update_scope(scope) [](#method-i-update_scope) - -## usage() [](#method-i-usage) -:nodoc: - -## verify_api_key(key) [](#method-i-verify_api_key) -Retrieves the pre-configured API key `key` or terminates interaction with an -error. - -## webauthn_enabled?() [](#method-i-webauthn_enabled?) - -**@return** [Boolean] - -## with_response(response, error_prefixnil) [](#method-i-with_response) -If `response` is an HTTP Success (2XX) response, yields the response if a -block was given or shows the response body to the user. - -If the response was not successful, shows an error to the user including the -`error_prefix` and the response body. If the response was a permanent -redirect, shows an error to the user including the redirect location. - diff --git a/example/ruby/Gem/Commands/QueryCommand.md b/example/ruby/Gem/Commands/QueryCommand.md deleted file mode 100644 index 147ce4f..0000000 --- a/example/ruby/Gem/Commands/QueryCommand.md +++ /dev/null @@ -1,104 +0,0 @@ -# Class: Gem::Commands::QueryCommand -**Inherits:** Gem::Command - -**Extended by:** Gem::Deprecate - -**Includes:** Gem::QueryUtils - - - - -# Class Methods -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_query_options() [](#method-i-add_query_options) - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## deprecation_warning() [](#method-i-deprecation_warning) - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize(name"query", summary"Query gem information in local or remote repositories") [](#method-i-initialize) - -**@return** [QueryCommand] a new instance of QueryCommand - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## warning_without_suggested_alternatives() [](#method-i-warning_without_suggested_alternatives) - diff --git a/example/ruby/Gem/Commands/RdocCommand.md b/example/ruby/Gem/Commands/RdocCommand.md deleted file mode 100644 index 30e8760..0000000 --- a/example/ruby/Gem/Commands/RdocCommand.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Gem::Commands::RdocCommand -**Inherits:** Gem::Command - -**Includes:** Gem::VersionOption - - - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [RdocCommand] a new instance of RdocCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/RebuildCommand.md b/example/ruby/Gem/Commands/RebuildCommand.md deleted file mode 100644 index 48ff310..0000000 --- a/example/ruby/Gem/Commands/RebuildCommand.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Gem::Commands::RebuildCommand -**Inherits:** Gem::Command - -**Includes:** Gem::GemspecHelpers - - - - - -#Instance Methods -## arguments() [](#method-i-arguments) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## find_gemspec(glob"*.gemspec") [](#method-i-find_gemspec) - -## initialize() [](#method-i-initialize) - -**@return** [RebuildCommand] a new instance of RebuildCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/SearchCommand.md b/example/ruby/Gem/Commands/SearchCommand.md deleted file mode 100644 index 079b52c..0000000 --- a/example/ruby/Gem/Commands/SearchCommand.md +++ /dev/null @@ -1,99 +0,0 @@ -# Class: Gem::Commands::SearchCommand -**Inherits:** Gem::Command - -**Includes:** Gem::QueryUtils - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_query_options() [](#method-i-add_query_options) - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [SearchCommand] a new instance of SearchCommand - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/ServerCommand.md b/example/ruby/Gem/Commands/ServerCommand.md deleted file mode 100644 index 378123c..0000000 --- a/example/ruby/Gem/Commands/ServerCommand.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Commands::ServerCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) - -**@return** [ServerCommand] a new instance of ServerCommand - diff --git a/example/ruby/Gem/Commands/SetupCommand.md b/example/ruby/Gem/Commands/SetupCommand.md deleted file mode 100644 index 5b4424e..0000000 --- a/example/ruby/Gem/Commands/SetupCommand.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: Gem::Commands::SetupCommand -**Inherits:** Gem::Command - - -Installs RubyGems itself. This command is ordinarily only available from a -RubyGems checkout or tarball. - - - -#Instance Methods -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## files_in(dir) [](#method-i-files_in) - -## generate_default_dirs() [](#method-i-generate_default_dirs) - -## generate_default_man_dir() [](#method-i-generate_default_man_dir) - -## initialize() [](#method-i-initialize) - -**@return** [SetupCommand] a new instance of SetupCommand - -## install_default_bundler_gem(bin_dir) [](#method-i-install_default_bundler_gem) - -## install_executables(bin_dir) [](#method-i-install_executables) - -## install_lib(lib_dir) [](#method-i-install_lib) - -## install_rdoc() [](#method-i-install_rdoc) - -## make_destination_dirs() [](#method-i-make_destination_dirs) - -## regenerate_binstubs(bindir) [](#method-i-regenerate_binstubs) - -## regenerate_plugins(bindir) [](#method-i-regenerate_plugins) - -## remove_old_bin_files(bin_dir) [](#method-i-remove_old_bin_files) - -## remove_old_lib_files(lib_dir) [](#method-i-remove_old_lib_files) - -## remove_old_man_files(old_man_dir) [](#method-i-remove_old_man_files) - -## shebang() [](#method-i-shebang) - -## show_release_notes() [](#method-i-show_release_notes) - -## uninstall_old_gemcutter() [](#method-i-uninstall_old_gemcutter) - diff --git a/example/ruby/Gem/Commands/SetupCommand/MakeDirs.md b/example/ruby/Gem/Commands/SetupCommand/MakeDirs.md deleted file mode 100644 index c3cf447..0000000 --- a/example/ruby/Gem/Commands/SetupCommand/MakeDirs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::Commands::SetupCommand::MakeDirs - - - - - -#Instance Methods -## mkdir_p(path, **opts) [](#method-i-mkdir_p) - diff --git a/example/ruby/Gem/Commands/SigninCommand.md b/example/ruby/Gem/Commands/SigninCommand.md deleted file mode 100644 index e0ed928..0000000 --- a/example/ruby/Gem/Commands/SigninCommand.md +++ /dev/null @@ -1,90 +0,0 @@ -# Class: Gem::Commands::SigninCommand -**Inherits:** Gem::Command - -**Includes:** Gem::GemcutterUtilities - - - - - -#Instance Methods -## add_key_option() [](#method-i-add_key_option) -Add the --key option - -## add_otp_option() [](#method-i-add_otp_option) -Add the --otp option - -## api_key() [](#method-i-api_key) -The API key from the command options or from the user's configuration. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize() [](#method-i-initialize) - -**@return** [SigninCommand] a new instance of SigninCommand - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## mfa_unauthorized?(response) [](#method-i-mfa_unauthorized?) - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## otp() [](#method-i-otp) -The OTP code from the command options or from the user's configuration. - -## rubygems_api_request(method, path, hostnil, allowed_push_hostnil, scope:nil, credentials:{}, &block) [](#method-i-rubygems_api_request) -Creates an RubyGems API to `host` and `path` with the given HTTP `method`. - -If `allowed_push_host` metadata is present, then it will only allow that host. - -## set_api_key(host, key) [](#method-i-set_api_key) -Returns true when the user has enabled multifactor authentication from -`response` text and no otp provided by options. - -## sign_in(sign_in_hostnil, scope:nil) [](#method-i-sign_in) -Signs in with the RubyGems API at `sign_in_host` and sets the rubygems API -key. - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## update_scope(scope) [](#method-i-update_scope) - -## usage() [](#method-i-usage) -:nodoc: - -## verify_api_key(key) [](#method-i-verify_api_key) -Retrieves the pre-configured API key `key` or terminates interaction with an -error. - -## webauthn_enabled?() [](#method-i-webauthn_enabled?) - -**@return** [Boolean] - -## with_response(response, error_prefixnil) [](#method-i-with_response) -If `response` is an HTTP Success (2XX) response, yields the response if a -block was given or shows the response body to the user. - -If the response was not successful, shows an error to the user including the -`error_prefix` and the response body. If the response was a permanent -redirect, shows an error to the user including the redirect location. - diff --git a/example/ruby/Gem/Commands/SignoutCommand.md b/example/ruby/Gem/Commands/SignoutCommand.md deleted file mode 100644 index 37d04e5..0000000 --- a/example/ruby/Gem/Commands/SignoutCommand.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Commands::SignoutCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) - -**@return** [SignoutCommand] a new instance of SignoutCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/SourcesCommand.md b/example/ruby/Gem/Commands/SourcesCommand.md deleted file mode 100644 index aea8b90..0000000 --- a/example/ruby/Gem/Commands/SourcesCommand.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: Gem::Commands::SourcesCommand -**Inherits:** Gem::Command - -**Includes:** Gem::LocalRemoteOptions - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source(source_uri) [](#method-i-add_source) -:nodoc: - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## check_rubygems_https(source_uri) [](#method-i-check_rubygems_https) -:nodoc: - -## check_typo_squatting(source) [](#method-i-check_typo_squatting) - -## clear_all() [](#method-i-clear_all) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) - -**@return** [SourcesCommand] a new instance of SourcesCommand - -## list() [](#method-i-list) -:nodoc: - -## list?() [](#method-i-list?) -:nodoc: - -**@return** [Boolean] - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## remove_cache_file(desc, path) [](#method-i-remove_cache_file) -:nodoc: - -## remove_source(source_uri) [](#method-i-remove_source) -:nodoc: - -## update() [](#method-i-update) -:nodoc: - diff --git a/example/ruby/Gem/Commands/SpecificationCommand.md b/example/ruby/Gem/Commands/SpecificationCommand.md deleted file mode 100644 index c607ae9..0000000 --- a/example/ruby/Gem/Commands/SpecificationCommand.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Gem::Commands::SpecificationCommand -**Inherits:** Gem::Command - -**Includes:** Gem::LocalRemoteOptions, Gem::VersionOption - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -**@raise** [Gem::CommandLineError] - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [SpecificationCommand] a new instance of SpecificationCommand - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/StaleCommand.md b/example/ruby/Gem/Commands/StaleCommand.md deleted file mode 100644 index 91ce761..0000000 --- a/example/ruby/Gem/Commands/StaleCommand.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Commands::StaleCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## initialize() [](#method-i-initialize) - -**@return** [StaleCommand] a new instance of StaleCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/UninstallCommand.md b/example/ruby/Gem/Commands/UninstallCommand.md deleted file mode 100644 index 2106627..0000000 --- a/example/ruby/Gem/Commands/UninstallCommand.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: Gem::Commands::UninstallCommand -**Inherits:** Gem::Command - -**Includes:** Gem::VersionOption - - -Gem uninstaller command line tool - -See `gem help uninstall` - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## check_version() [](#method-i-check_version) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [UninstallCommand] a new instance of UninstallCommand - -## uninstall(gem_name) [](#method-i-uninstall) - -## uninstall_all() [](#method-i-uninstall_all) - -## uninstall_gem(gem_name) [](#method-i-uninstall_gem) - -## uninstall_specific() [](#method-i-uninstall_specific) - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/UnpackCommand.md b/example/ruby/Gem/Commands/UnpackCommand.md deleted file mode 100644 index 59cb5a8..0000000 --- a/example/ruby/Gem/Commands/UnpackCommand.md +++ /dev/null @@ -1,61 +0,0 @@ -# Class: Gem::Commands::UnpackCommand -**Inherits:** Gem::Command - -**Includes:** Gem::SecurityOption, Gem::VersionOption - - - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_security_option() [](#method-i-add_security_option) - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) - -## execute() [](#method-i-execute) --- TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for -this, so that it works for uninstall as well. (And check other commands at -the same time.) - -## find_in_cache(filename) [](#method-i-find_in_cache) -Find cached filename in Gem.path. Returns nil if the file cannot be found. - --- TODO: see comments in get_path() about general service. - -## get_path(dependency) [](#method-i-get_path) -Return the full path to the cached gem file matching the given name and -version requirement. Returns 'nil' if no match. - -Example: - - get_path 'rake', '> 0.4' # "/usr/lib/ruby/gems/1.8/cache/rake-0.4.2.gem" - get_path 'rake', '< 0.1' # nil - get_path 'rak' # nil (exact name required) - --- - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [UnpackCommand] a new instance of UnpackCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/UpdateCommand.md b/example/ruby/Gem/Commands/UpdateCommand.md deleted file mode 100644 index c9582e6..0000000 --- a/example/ruby/Gem/Commands/UpdateCommand.md +++ /dev/null @@ -1,131 +0,0 @@ -# Class: Gem::Commands::UpdateCommand -**Inherits:** Gem::Command - -**Includes:** Gem::InstallUpdateOptions, Gem::LocalRemoteOptions, Gem::VersionOption - - - - -# Attributes -## installer[RW] [](#attribute-i-installer) -:nodoc: - -## updated[RW] [](#attribute-i-updated) -:nodoc: - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_install_update_options() [](#method-i-add_install_update_options) -Add the install/update options to the option parser. - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_security_option() [](#method-i-add_security_option) - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## check_latest_rubygems(version) [](#method-i-check_latest_rubygems) -:nodoc: - -## check_oldest_rubygems(version) [](#method-i-check_oldest_rubygems) -:nodoc: - -## check_update_arguments() [](#method-i-check_update_arguments) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## fetch_remote_gems(spec) [](#method-i-fetch_remote_gems) -:nodoc: - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## highest_installed_gems() [](#method-i-highest_installed_gems) -:nodoc: - -## highest_remote_name_tuple(spec) [](#method-i-highest_remote_name_tuple) -:nodoc: - -## initialize() [](#method-i-initialize) - -**@return** [UpdateCommand] a new instance of UpdateCommand - -## install_rubygems(spec) [](#method-i-install_rubygems) -:nodoc: - -## install_update_defaults_str() [](#method-i-install_update_defaults_str) -Default description for the gem install and update commands. - -## install_update_options() [](#method-i-install_update_options) -Default options for the gem install and update commands. - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## preparing_gem_layout_for(version) [](#method-i-preparing_gem_layout_for) - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## rubygems_target_version() [](#method-i-rubygems_target_version) - -## update_gem(name, versionGem::Requirement.default) [](#method-i-update_gem) - -## update_gems(gems_to_update) [](#method-i-update_gems) - -## update_rubygems() [](#method-i-update_rubygems) -Update RubyGems software to the latest version. - -## update_rubygems_arguments() [](#method-i-update_rubygems_arguments) -:nodoc: - -## usage() [](#method-i-usage) -:nodoc: - -## which_to_update(highest_installed_gems, gem_names) [](#method-i-which_to_update) - diff --git a/example/ruby/Gem/Commands/WhichCommand.md b/example/ruby/Gem/Commands/WhichCommand.md deleted file mode 100644 index 276c679..0000000 --- a/example/ruby/Gem/Commands/WhichCommand.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Gem::Commands::WhichCommand -**Inherits:** Gem::Command - - - - - -#Instance Methods -## arguments() [](#method-i-arguments) -:nodoc: - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## find_paths(package_name, dirs) [](#method-i-find_paths) - -## initialize() [](#method-i-initialize) - -**@return** [WhichCommand] a new instance of WhichCommand - -## usage() [](#method-i-usage) -:nodoc: - diff --git a/example/ruby/Gem/Commands/YankCommand.md b/example/ruby/Gem/Commands/YankCommand.md deleted file mode 100644 index 93e6b89..0000000 --- a/example/ruby/Gem/Commands/YankCommand.md +++ /dev/null @@ -1,143 +0,0 @@ -# Class: Gem::Commands::YankCommand -**Inherits:** Gem::Command - -**Includes:** Gem::GemcutterUtilities, Gem::LocalRemoteOptions, Gem::VersionOption - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_key_option() [](#method-i-add_key_option) -Add the --key option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_otp_option() [](#method-i-add_otp_option) -Add the --otp option - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## api_key() [](#method-i-api_key) -The API key from the command options or from the user's configuration. - -## arguments() [](#method-i-arguments) -:nodoc: - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## description() [](#method-i-description) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## initialize() [](#method-i-initialize) - -**@return** [YankCommand] a new instance of YankCommand - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## mfa_unauthorized?(response) [](#method-i-mfa_unauthorized?) - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## otp() [](#method-i-otp) -The OTP code from the command options or from the user's configuration. - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## rubygems_api_request(method, path, hostnil, allowed_push_hostnil, scope:nil, credentials:{}, &block) [](#method-i-rubygems_api_request) -Creates an RubyGems API to `host` and `path` with the given HTTP `method`. - -If `allowed_push_host` metadata is present, then it will only allow that host. - -## set_api_key(host, key) [](#method-i-set_api_key) -Returns true when the user has enabled multifactor authentication from -`response` text and no otp provided by options. - -## sign_in(sign_in_hostnil, scope:nil) [](#method-i-sign_in) -Signs in with the RubyGems API at `sign_in_host` and sets the rubygems API -key. - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## update_scope(scope) [](#method-i-update_scope) - -## usage() [](#method-i-usage) -:nodoc: - -## verify_api_key(key) [](#method-i-verify_api_key) -Retrieves the pre-configured API key `key` or terminates interaction with an -error. - -## webauthn_enabled?() [](#method-i-webauthn_enabled?) - -**@return** [Boolean] - -## with_response(response, error_prefixnil) [](#method-i-with_response) -If `response` is an HTTP Success (2XX) response, yields the response if a -block was given or shows the response body to the user. - -If the response was not successful, shows an error to the user including the -`error_prefix` and the response body. If the response was a permanent -redirect, shows an error to the user including the redirect location. - -## yank_gem(version, platform) [](#method-i-yank_gem) - diff --git a/example/ruby/Gem/ConfigFile.md b/example/ruby/Gem/ConfigFile.md deleted file mode 100644 index 23a1cf0..0000000 --- a/example/ruby/Gem/ConfigFile.md +++ /dev/null @@ -1,257 +0,0 @@ -# Class: Gem::ConfigFile -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - -Gem::ConfigFile RubyGems options and gem command options from gemrc. - -gemrc is a YAML file that uses strings to match gem command arguments and -symbols to match RubyGems options. - -Gem command arguments use a String key that matches the command name and allow -you to specify default arguments: - - install: --no-rdoc --no-ri - update: --no-rdoc --no-ri - -You can use `gem:` to set default arguments for all commands. - -RubyGems options use symbol keys. Valid options are: - -`:backtrace` -: See #backtrace - -`:sources` -: Sets Gem::sources - -`:verbose` -: See #verbose - -`:concurrent_downloads` -: See #concurrent_downloads - - -gemrc files may exist in various locations and are read and merged in the -following order: - -* system wide (/etc/gemrc) -* per user (~/.gemrc) -* per environment (gemrc files listed in the GEMRC environment variable) - - -# Class Methods -## dump_with_rubygems_yaml(content ) [](#method-c-dump_with_rubygems_yaml) -## load_with_rubygems_config_hash(yaml ) [](#method-c-load_with_rubygems_config_hash) -# Attributes -## args[RW] [](#attribute-i-args) -List of arguments supplied to the config file object. - -## backtrace[RW] [](#attribute-i-backtrace) -True if the backtrace option has been specified, or debug is on. - -## bulk_threshold[RW] [](#attribute-i-bulk_threshold) -Bulk threshold value. If the number of missing gems are above this threshold -value, then a bulk download technique is used. (deprecated) - -## cert_expiration_length_days[RW] [](#attribute-i-cert_expiration_length_days) -Expiration length to sign a certificate - -## concurrent_downloads[RW] [](#attribute-i-concurrent_downloads) -Number of gem downloads that should be performed concurrently. - -## disable_default_gem_server[RW] [](#attribute-i-disable_default_gem_server) -True if we want to force specification of gem server when pushing a gem - -## home[RW] [](#attribute-i-home) -Where to install gems (deprecated) - -## install_extension_in_lib[RW] [](#attribute-i-install_extension_in_lib) -Install extensions into lib as well as into the extension directory. - -## ipv4_fallback_enabled[RW] [](#attribute-i-ipv4_fallback_enabled) -## Experimental == -Fallback to IPv4 when IPv6 is not reachable or slow (default: false) - -## path[RW] [](#attribute-i-path) -Where to look for gems (deprecated) - -## sources[RW] [](#attribute-i-sources) -sources to look for gems - -## ssl_ca_cert[RW] [](#attribute-i-ssl_ca_cert) -Path name of directory or file of openssl CA certificate, used for remote -https connection - -## ssl_client_cert[RW] [](#attribute-i-ssl_client_cert) -Path name of directory or file of openssl client certificate, used for remote -https connection with client authentication - -## ssl_verify_mode[RW] [](#attribute-i-ssl_verify_mode) -openssl verify mode value, used for remote https connection - -## update_sources[RW] [](#attribute-i-update_sources) -True if we want to update the SourceInfoCache every time, false otherwise - -## verbose[RW] [](#attribute-i-verbose) -Verbose level of output: -* false -- No output -* true -- Normal output -* :loud -- Extra output - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## [](key) [](#method-i-[]) -Return the configuration information for `key`. - -## []=(key, value) [](#method-i-[]=) -Set configuration option `key` to `value`. - -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## api_keys() [](#method-i-api_keys) -Hash of RubyGems.org and alternate API keys - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## check_credentials_permissions() [](#method-i-check_credentials_permissions) -Checks the permissions of the credentials file. If they are not 0600 an error -message is displayed and RubyGems aborts. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## config_file_name() [](#method-i-config_file_name) -The name of the configuration file. - -## credentials_path() [](#method-i-credentials_path) -Location of RubyGems.org credentials - -## each(&block) [](#method-i-each) -Delegates to @hash - -**@yield** [:update_sources, @update_sources] - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## handle_arguments(arg_list) [](#method-i-handle_arguments) -Handle the command arguments. - -## initialize(args) [](#method-i-initialize) -Create the config file object. `args` is the list of arguments from the -command line. - -The following command line options are handled early here rather than later at -the time most command options are processed. - -`--config-file`, `--config-file==NAME` -: Obviously these need to be handled by the ConfigFile object to ensure we - get the right config file. - - -`--backtrace` -: Backtrace needs to be turned on early so that errors before normal option - parsing can be properly handled. - - -`--debug` -: Enable Ruby level debug messages. Handled early for the same reason as - --backtrace. - --- TODO: parse options upstream, pass in options directly - -**@return** [ConfigFile] a new instance of ConfigFile - -## last_update_check() [](#method-i-last_update_check) -Reads time of last update check from state file - -## last_update_check=(timestamp) [](#method-i-last_update_check=) -Writes time of last update check to state file - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## load_api_keys() [](#method-i-load_api_keys) - -## load_file(filename) [](#method-i-load_file) - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## really_verbose() [](#method-i-really_verbose) -Really verbose mode gives you extra output. - -## rubygems_api_key() [](#method-i-rubygems_api_key) -Returns the RubyGems.org API key - -## rubygems_api_key=(api_key) [](#method-i-rubygems_api_key=) -Sets the RubyGems.org API key to `api_key` - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## set_api_key(host, api_key) [](#method-i-set_api_key) -Set a specific host's API key to `api_key` - -## state_file_name() [](#method-i-state_file_name) -The name of the state file. - -## state_file_writable?() [](#method-i-state_file_writable?) -Check state file is writable. Creates empty file if not present to ensure we -can write to it. - -**@return** [Boolean] - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## to_yaml() [](#method-i-to_yaml) -to_yaml only overwrites things you can't override on the command line. - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## unset_api_key!() [](#method-i-unset_api_key!) -Remove the +~/.gem/credentials+ file to clear all the current sessions. - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## write() [](#method-i-write) -Writes out this config file, replacing its source. - diff --git a/example/ruby/Gem/ConflictError.md b/example/ruby/Gem/ConflictError.md deleted file mode 100644 index 61ea86c..0000000 --- a/example/ruby/Gem/ConflictError.md +++ /dev/null @@ -1,21 +0,0 @@ -# Exception: Gem::ConflictError -**Inherits:** Gem::LoadError - - -Raised when there are conflicting gem specs loaded - - -# Attributes -## conflicts[RW] [](#attribute-i-conflicts) -A Hash mapping conflicting specifications to the dependencies that caused the -conflict - -## target[RW] [](#attribute-i-target) -The specification that had the conflict - - -#Instance Methods -## initialize(target, conflicts) [](#method-i-initialize) - -**@return** [ConflictError] a new instance of ConflictError - diff --git a/example/ruby/Gem/ConsoleUI.md b/example/ruby/Gem/ConsoleUI.md deleted file mode 100644 index 89c7f9e..0000000 --- a/example/ruby/Gem/ConsoleUI.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::ConsoleUI -**Inherits:** Gem::StreamUI - - -Subclass of StreamUI that instantiates the user interaction using $stdin, -$stdout, and $stderr. - - - -#Instance Methods -## initialize() [](#method-i-initialize) -The Console UI has no arguments as it defaults to reading input from stdin, -output to stdout and warnings or errors to stderr. - -**@return** [ConsoleUI] a new instance of ConsoleUI - diff --git a/example/ruby/Gem/DefaultUserInteraction.md b/example/ruby/Gem/DefaultUserInteraction.md deleted file mode 100644 index 5b9379f..0000000 --- a/example/ruby/Gem/DefaultUserInteraction.md +++ /dev/null @@ -1,49 +0,0 @@ -# Module: Gem::DefaultUserInteraction - -**Includes:** Gem::Text - - -Module that defines the default UserInteraction. Any class including this -module will have access to the `ui` method that returns the default UI. - - -# Class Methods -## ui() [](#method-c-ui) -Return the default UI. -## ui=(new_ui ) [](#method-c-ui=) -Set the default UI. If the default UI is never explicitly set, a simple -console based UserInteraction will be used automatically. -## use_ui(new_ui ) [](#method-c-use_ui) -Use `new_ui` for the duration of `block`. - -#Instance Methods -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - diff --git a/example/ruby/Gem/Dependency.md b/example/ruby/Gem/Dependency.md deleted file mode 100644 index 04b0358..0000000 --- a/example/ruby/Gem/Dependency.md +++ /dev/null @@ -1,129 +0,0 @@ -# Class: Gem::Dependency -**Inherits:** Object - -**Includes:** Bundler::ForcePlatform, Gem::Dependency::FilterIgnoredSpecs - - -The Dependency class holds a Gem name and a Gem::Requirement. - - -# Attributes -## force_ruby_platform[RW] [](#attribute-i-force_ruby_platform) -Returns the value of attribute force_ruby_platform. - -## groups[RW] [](#attribute-i-groups) -Returns the value of attribute groups. - -## name[RW] [](#attribute-i-name) -Dependency name or regular expression. - -## prerelease=[R] [](#attribute-i-prerelease=) -Allows you to force this dependency to be a prerelease. - -## source[RW] [](#attribute-i-source) -Returns the value of attribute source. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -Dependencies are ordered by name. - -## ==(other) [](#method-i-==) -:nodoc: - -## =~(other) [](#method-i-=~) -Uses this dependency as a pattern to compare to `other`. This dependency will -match if the name matches the other's name, and other has only an equal -version requirement that satisfies this dependency. - -## default_force_ruby_platform() [](#method-i-default_force_ruby_platform) -The `:force_ruby_platform` value used by dependencies for resolution, and by -locked specifications for materialization is `false` by default, except for -TruffleRuby. TruffleRuby generally needs to force the RUBY platform variant -unless the name is explicitly allowlisted. - -## encode_with(coder) [](#method-i-encode_with) -:nodoc: - -## hash() [](#method-i-hash) -A dependency's hash is the XOR of the hashes of `name`, `type`, and -`requirement`. - -## identity() [](#method-i-identity) - -## initialize(name, *requirements) [](#method-i-initialize) -Constructs a dependency with `name` and `requirements`. The last argument can -optionally be the dependency type, which defaults to `:runtime`. - -**@return** [Dependency] a new instance of Dependency - -## inspect() [](#method-i-inspect) -:nodoc: - -## latest_version?() [](#method-i-latest_version?) -Is this dependency simply asking for the latest version of a gem? - -**@return** [Boolean] - -## match?(obj, versionnil, allow_prereleasefalse) [](#method-i-match?) -:call-seq: - dep.match? name => true or false - dep.match? name, version => true or false - dep.match? spec => true or false - -Does this dependency match the specification described by `name` and `version` -or match `spec`? - -NOTE: Unlike #matches_spec? this method does not return true when the version -is a prerelease version unless this is a prerelease dependency. - -**@return** [Boolean] - -## matches_spec?(spec) [](#method-i-matches_spec?) -Does this dependency match `spec`? - -NOTE: This is not a convenience method. Unlike #match? this method returns -true when `spec` is a prerelease version even if this dependency is not a -prerelease dependency. - -**@return** [Boolean] - -## matching_specs(platform_onlyfalse) [](#method-i-matching_specs) - -## merge(other) [](#method-i-merge) -Merges the requirements of `other` into this dependency - -## prerelease?() [](#method-i-prerelease?) -Does this dependency require a prerelease? - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## requirement() [](#method-i-requirement) -What does this dependency require? - -## requirements_list() [](#method-i-requirements_list) - -## runtime?() [](#method-i-runtime?) - -**@return** [Boolean] - -## specific?() [](#method-i-specific?) -True if the dependency will not always match the latest version. - -**@return** [Boolean] - -## to_lock() [](#method-i-to_lock) - -## to_s() [](#method-i-to_s) -:nodoc: - -## to_spec() [](#method-i-to_spec) - -## to_specs() [](#method-i-to_specs) - -## type() [](#method-i-type) -Dependency type. - diff --git a/example/ruby/Gem/Dependency/FilterIgnoredSpecs.md b/example/ruby/Gem/Dependency/FilterIgnoredSpecs.md deleted file mode 100644 index e23f31e..0000000 --- a/example/ruby/Gem/Dependency/FilterIgnoredSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::Dependency::FilterIgnoredSpecs - - - - - -#Instance Methods -## matching_specs(platform_onlyfalse) [](#method-i-matching_specs) - diff --git a/example/ruby/Gem/DependencyError.md b/example/ruby/Gem/DependencyError.md deleted file mode 100644 index 71dd1d7..0000000 --- a/example/ruby/Gem/DependencyError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::DependencyError -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/DependencyInstaller.md b/example/ruby/Gem/DependencyInstaller.md deleted file mode 100644 index e44a54a..0000000 --- a/example/ruby/Gem/DependencyInstaller.md +++ /dev/null @@ -1,174 +0,0 @@ -# Class: Gem::DependencyInstaller -**Inherits:** Object - -**Extended by:** Gem::Deprecate - -**Includes:** Gem::UserInteraction - - -Installs a gem along with all its dependencies from local and remote gems. - - -# Class Methods -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -# Attributes -## document[RW] [](#attribute-i-document) -Documentation types. For use by the Gem.done_installing hook - -## errors[RW] [](#attribute-i-errors) -Errors from SpecFetcher while searching for remote specifications - -## installed_gems[RW] [](#attribute-i-installed_gems) -List of gems installed by #install in alphabetic order - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## consider_local?() [](#method-i-consider_local?) -Indicated, based on the requested domain, if local gems should be considered. - -**@return** [Boolean] - -## consider_remote?() [](#method-i-consider_remote?) -Indicated, based on the requested domain, if remote gems should be considered. - -**@return** [Boolean] - -## find_gems_with_sources(dep, best_onlyfalse) [](#method-i-find_gems_with_sources) -Returns a list of pairs of gemspecs and source_uris that match Gem::Dependency -`dep` from both local (Dir.pwd) and remote (Gem.sources) sources. Gems are -sorted with newer gems preferred over older gems, and local gems preferred -over remote gems. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## in_background(what) [](#method-i-in_background) -:nodoc: - -## initialize(options{}) [](#method-i-initialize) -Creates a new installer instance. - -Options are: -:cache_dir -: Alternate repository path to store .gem files in. - -:domain -: :local, :remote, or :both. :local only searches gems in the current - directory. :remote searches only gems in Gem::sources. :both searches - both. - -:env_shebang -: See Gem::Installer::new. - -:force -: See Gem::Installer#install. - -:format_executable -: See Gem::Installer#initialize. - -:ignore_dependencies -: Don't install any dependencies. - -:install_dir -: See Gem::Installer#install. - -:prerelease -: Allow prerelease versions. See #install. - -:security_policy -: See Gem::Installer::new and Gem::Security. - -:user_install -: See Gem::Installer.new - -:wrappers -: See Gem::Installer::new - -:build_args -: See Gem::Installer::new - - -**@return** [DependencyInstaller] a new instance of DependencyInstaller - -## install(dep_or_name, versionGem::Requirement.default) [](#method-i-install) -Installs the gem `dep_or_name` and all its dependencies. Returns an Array of -installed gem specifications. - -If the `:prerelease` option is set and there is a prerelease for `dep_or_name` -the prerelease version will be installed. - -Unless explicitly specified as a prerelease dependency, prerelease gems that -`dep_or_name` depend on will not be installed. - -If c-1.a depends on b-1 and a-1.a and there is a gem b-1.a available then -c-1.a, b-1 and a-1.a will be installed. b-1.a will need to be installed -separately. - -## install_development_deps() [](#method-i-install_development_deps) -:nodoc: - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## resolve_dependencies(dep_or_name, version) [](#method-i-resolve_dependencies) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/DependencyList.md b/example/ruby/Gem/DependencyList.md deleted file mode 100644 index 291fc73..0000000 --- a/example/ruby/Gem/DependencyList.md +++ /dev/null @@ -1,2268 +0,0 @@ -# Class: Gem::DependencyList -**Inherits:** Object - -**Includes:** Enumerable, Gem::TSort - - -Gem::DependencyList is used for installing and uninstalling gems in the -correct order to avoid conflicts. -- TODO: It appears that all but topo-sort -functionality is being duplicated (or is planned to be duplicated) elsewhere -in rubygems. Is the majority of this class necessary anymore? Especially -#ok?, #why_not_ok? - - -# Class Methods -## from_specs() [](#method-c-from_specs) -Creates a DependencyList from the current specs. -# Attributes -## development[RW] [](#attribute-i-development) -Allows enabling/disabling use of development dependencies - -## specs[RW] [](#attribute-i-specs) -Returns the value of attribute specs. - - -#Instance Methods -## add(*gemspecs) [](#method-i-add) -Adds `gemspecs` to the dependency list. - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## clear() [](#method-i-clear) - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## dependency_order() [](#method-i-dependency_order) -Return a list of the gem specifications in the dependency list, sorted in -order so that no gemspec in the list depends on a gemspec earlier in the list. - -This is useful when removing gems from a set of installed gems. By removing -them in the returned order, you don't get into as many dependency issues. - -If there are circular dependencies (yuck!), then gems will be returned in -order until only the circular dependents and anything they reference are left. - Then arbitrary gemspecs will be returned until the circular dependency is -broken, after which gems will be returned in dependency order again. - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) -Iterator over dependency_order - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## find_name(full_name) [](#method-i-find_name) - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(developmentfalse) [](#method-i-initialize) -Creates a new DependencyList. If `development` is true, development -dependencies will be included. - -**@return** [DependencyList] a new instance of DependencyList - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -:nodoc: - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## ok?() [](#method-i-ok?) -Are all the dependencies in the list satisfied? - -**@return** [Boolean] - -## ok_to_remove?(full_name, check_devtrue) [](#method-i-ok_to_remove?) -It is ok to remove a gemspec from the dependency list? - -If removing the gemspec creates breaks a currently ok dependency, then it is -NOT ok to remove the gemspec. - -**@return** [Boolean] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## remove_by_name(full_name) [](#method-i-remove_by_name) -Removes the gemspec matching `full_name` from the dependency list - -## remove_specs_unsatisfied_by(dependencies) [](#method-i-remove_specs_unsatisfied_by) -Remove everything in the DependencyList that matches but doesn't satisfy items -in `dependencies` (a hash of gem names to arrays of dependencies). - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## spec_predecessors() [](#method-i-spec_predecessors) -Return a hash of predecessors. `result[spec]` is an Array of gemspecs that -have a dependency satisfied by the named gemspec. - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, Gem::TSort::Cyclic is raised. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises Gem::TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, Gem::TSort::Cyclic is raised. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## tsort_each_child(node) [](#method-i-tsort_each_child) - -## tsort_each_node(&block) [](#method-i-tsort_each_node) - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## why_not_ok?(quickfalse) [](#method-i-why_not_ok?) - -**@return** [Boolean] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/DependencyRemovalException.md b/example/ruby/Gem/DependencyRemovalException.md deleted file mode 100644 index c248bf4..0000000 --- a/example/ruby/Gem/DependencyRemovalException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::DependencyRemovalException -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/DependencyResolutionError.md b/example/ruby/Gem/DependencyResolutionError.md deleted file mode 100644 index a9d37bc..0000000 --- a/example/ruby/Gem/DependencyResolutionError.md +++ /dev/null @@ -1,21 +0,0 @@ -# Exception: Gem::DependencyResolutionError -**Inherits:** Gem::DependencyError - - -Raised by Gem::Resolver when a Gem::Dependency::Conflict reaches the toplevel. - Indicates which dependencies were incompatible through #conflict and -#conflicting_dependencies - - -# Attributes -## conflict[RW] [](#attribute-i-conflict) -Returns the value of attribute conflict. - - -#Instance Methods -## conflicting_dependencies() [](#method-i-conflicting_dependencies) - -## initialize(conflict) [](#method-i-initialize) - -**@return** [DependencyResolutionError] a new instance of DependencyResolutionError - diff --git a/example/ruby/Gem/Deprecate.md b/example/ruby/Gem/Deprecate.md deleted file mode 100644 index d2e34c4..0000000 --- a/example/ruby/Gem/Deprecate.md +++ /dev/null @@ -1,28 +0,0 @@ -# Module: Gem::Deprecate - - - - -# Class Methods -## next_rubygems_major_version() [](#method-c-next_rubygems_major_version) -:nodoc: -## rubygems_deprecate(name , replacement :none) [](#method-c-rubygems_deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the Rubygems version that it is planned to go -away. -## rubygems_deprecate_command(version Gem::Deprecate.next_rubygems_major_version) [](#method-c-rubygems_deprecate_command) -Deprecation method to deprecate Rubygems commands -## skip() [](#method-c-skip) -:nodoc: -## skip=(v ) [](#method-c-skip=) -:nodoc: -## skip_during() [](#method-c-skip_during) -Temporarily turn off warnings. Intended for tests only. - -#Instance Methods -## deprecate(name, repl, year, month) [](#method-i-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. - diff --git a/example/ruby/Gem/Doctor.md b/example/ruby/Gem/Doctor.md deleted file mode 100644 index d7a7a7d..0000000 --- a/example/ruby/Gem/Doctor.md +++ /dev/null @@ -1,104 +0,0 @@ -# Class: Gem::Doctor -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - -Cleans up after a partially-failed uninstall or for an invalid -Gem::Specification. - -If a specification was removed by hand this will remove any remaining files. - -If a corrupt specification was installed this will clean up warnings by -removing the bogus specification. - - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## doctor() [](#method-i-doctor) -Cleans up uninstalled files and invalid gem specifications - -## doctor_child(sub_directory, extension) [](#method-i-doctor_child) -Removes files in `sub_directory` with `extension` - -## doctor_children() [](#method-i-doctor_children) -Cleans up children of this gem repository - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## gem_repository?() [](#method-i-gem_repository?) -Are we doctoring a gem repository? - -**@return** [Boolean] - -## initialize(gem_repository, dry_runfalse) [](#method-i-initialize) -Creates a new Gem::Doctor that will clean up `gem_repository`. Only one gem -repository may be cleaned at a time. - -If `dry_run` is true no files or directories will be removed. - -**@return** [Doctor] a new instance of Doctor - -## installed_specs() [](#method-i-installed_specs) -Specs installed in this gem repository - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/DocumentError.md b/example/ruby/Gem/DocumentError.md deleted file mode 100644 index 10395f8..0000000 --- a/example/ruby/Gem/DocumentError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::DocumentError -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/EndOfYAMLException.md b/example/ruby/Gem/EndOfYAMLException.md deleted file mode 100644 index 1bcf19e..0000000 --- a/example/ruby/Gem/EndOfYAMLException.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::EndOfYAMLException -**Inherits:** Gem::Exception - - -Potentially raised when a specification is validated. - - - diff --git a/example/ruby/Gem/ErrorReason.md b/example/ruby/Gem/ErrorReason.md deleted file mode 100644 index df2584f..0000000 --- a/example/ruby/Gem/ErrorReason.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::ErrorReason -**Inherits:** Object - - - - - diff --git a/example/ruby/Gem/Exception.md b/example/ruby/Gem/Exception.md deleted file mode 100644 index e3846ac..0000000 --- a/example/ruby/Gem/Exception.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Gem::Exception -**Inherits:** RuntimeError - - -Base exception class for RubyGems. All exception raised by RubyGems are a -subclass of this one. - - - diff --git a/example/ruby/Gem/Ext.md b/example/ruby/Gem/Ext.md deleted file mode 100644 index 74f7b05..0000000 --- a/example/ruby/Gem/Ext.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Ext - - -Classes for building C extensions live here. - - - diff --git a/example/ruby/Gem/Ext/BuildError.md b/example/ruby/Gem/Ext/BuildError.md deleted file mode 100644 index 6ca778e..0000000 --- a/example/ruby/Gem/Ext/BuildError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Ext::BuildError -**Inherits:** Gem::InstallError - - - - - diff --git a/example/ruby/Gem/Ext/Builder.md b/example/ruby/Gem/Ext/Builder.md deleted file mode 100644 index 4450700..0000000 --- a/example/ruby/Gem/Ext/Builder.md +++ /dev/null @@ -1,107 +0,0 @@ -# Class: Gem::Ext::Builder -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - - - -# Class Methods -## class_name() [](#method-c-class_name) -## make(dest_path , results , make_dir Dir.pwd, sitedir nil, targets ["clean", "", "install"], target_rbconfig: Gem.target_rbconfig) [](#method-c-make) -## ruby() [](#method-c-ruby) -## run(command , results , command_name nil, dir Dir.pwd, env {}) [](#method-c-run) -**@yield** [status, results] - -# Attributes -## build_args[RW] [](#attribute-i-build_args) -:nodoc: - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## build_error(output, backtracenil) [](#method-i-build_error) -Logs the build `output`, then raises Gem::Ext::BuildError. - -**@raise** [Gem::Ext::BuildError] - -## build_extension(extension, dest_path) [](#method-i-build_extension) -:nodoc: - -## build_extensions() [](#method-i-build_extensions) -Builds extensions. Valid types of extensions are extconf.rb files, configure -scripts and rakefiles or mkrf_conf files. - -## builder_for(extension) [](#method-i-builder_for) -Chooses the extension builder class for `extension` - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(spec, build_argsspec.build_args, target_rbconfigGem.target_rbconfig) [](#method-i-initialize) -Creates a new extension builder for `spec`. If the `spec` does not yet have -build arguments, saved, set `build_args` which is an ARGV-style array. - -**@return** [Builder] a new instance of Builder - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - -## write_gem_make_out(output) [](#method-i-write_gem_make_out) -Writes `output` to gem_make.out in the extension install directory. - diff --git a/example/ruby/Gem/Ext/CargoBuilder.md b/example/ruby/Gem/Ext/CargoBuilder.md deleted file mode 100644 index 65e4dac..0000000 --- a/example/ruby/Gem/Ext/CargoBuilder.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Gem::Ext::CargoBuilder -**Inherits:** Gem::Ext::Builder - - -This class is used by rubygems to build Rust extensions. It is a thin-wrapper -over the `cargo rustc` command which takes care of building Rust code in a way -that Ruby can use. - - -# Attributes -## profile[RW] [](#attribute-i-profile) -Returns the value of attribute profile. - -## runner[RW] [](#attribute-i-runner) -Returns the value of attribute runner. - -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - -#Instance Methods -## build(extension, dest_path, results, args[], lib_dirnil, cargo_dirDir.pwd, target_rbconfigGem.target_rbconfig) [](#method-i-build) - -## build_env() [](#method-i-build_env) - -## cargo_command(cargo_toml, dest_path, args[], crate_namenil) [](#method-i-cargo_command) - -## initialize() [](#method-i-initialize) - -**@return** [CargoBuilder] a new instance of CargoBuilder - diff --git a/example/ruby/Gem/Ext/CargoBuilder/DylibNotFoundError.md b/example/ruby/Gem/Ext/CargoBuilder/DylibNotFoundError.md deleted file mode 100644 index 6d7c89c..0000000 --- a/example/ruby/Gem/Ext/CargoBuilder/DylibNotFoundError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Gem::Ext::CargoBuilder::DylibNotFoundError -**Inherits:** StandardError - - -Error raised when no cdylib artifact was created - - - -#Instance Methods -## initialize(dir) [](#method-i-initialize) - -**@return** [DylibNotFoundError] a new instance of DylibNotFoundError - diff --git a/example/ruby/Gem/Ext/CargoBuilder/LinkFlagConverter.md b/example/ruby/Gem/Ext/CargoBuilder/LinkFlagConverter.md deleted file mode 100644 index 84b18a9..0000000 --- a/example/ruby/Gem/Ext/CargoBuilder/LinkFlagConverter.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Gem::Ext::CargoBuilder::LinkFlagConverter -**Inherits:** Object - - -Converts Ruby link flags into something cargo understands - - -# Class Methods -## convert(arg ) [](#method-c-convert) - diff --git a/example/ruby/Gem/Ext/CmakeBuilder.md b/example/ruby/Gem/Ext/CmakeBuilder.md deleted file mode 100644 index 8aaefc1..0000000 --- a/example/ruby/Gem/Ext/CmakeBuilder.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Gem::Ext::CmakeBuilder -**Inherits:** Gem::Ext::Builder - - - - -# Class Methods -## build(extension , dest_path , results , args [], lib_dir nil, cmake_dir Dir.pwd, target_rbconfig Gem.target_rbconfig) [](#method-c-build) - diff --git a/example/ruby/Gem/Ext/ConfigureBuilder.md b/example/ruby/Gem/Ext/ConfigureBuilder.md deleted file mode 100644 index f389012..0000000 --- a/example/ruby/Gem/Ext/ConfigureBuilder.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Gem::Ext::ConfigureBuilder -**Inherits:** Gem::Ext::Builder - - --- Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. All -rights reserved. See LICENSE.txt for permissions. ++ - - -# Class Methods -## build(extension , dest_path , results , args [], lib_dir nil, configure_dir Dir.pwd, target_rbconfig Gem.target_rbconfig) [](#method-c-build) - diff --git a/example/ruby/Gem/Ext/ExtConfBuilder.md b/example/ruby/Gem/Ext/ExtConfBuilder.md deleted file mode 100644 index ee0a719..0000000 --- a/example/ruby/Gem/Ext/ExtConfBuilder.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Gem::Ext::ExtConfBuilder -**Inherits:** Gem::Ext::Builder - - --- Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. All -rights reserved. See LICENSE.txt for permissions. ++ - - -# Class Methods -## build(extension , dest_path , results , args [], lib_dir nil, extension_dir Dir.pwd, target_rbconfig Gem.target_rbconfig) [](#method-c-build) -## get_relative_path(path , base ) [](#method-c-get_relative_path) - diff --git a/example/ruby/Gem/Ext/RakeBuilder.md b/example/ruby/Gem/Ext/RakeBuilder.md deleted file mode 100644 index 8bf5534..0000000 --- a/example/ruby/Gem/Ext/RakeBuilder.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Gem::Ext::RakeBuilder -**Inherits:** Gem::Ext::Builder - - --- Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. All -rights reserved. See LICENSE.txt for permissions. ++ - - -# Class Methods -## build(extension , dest_path , results , args [], lib_dir nil, extension_dir Dir.pwd, target_rbconfig Gem.target_rbconfig) [](#method-c-build) - diff --git a/example/ruby/Gem/FakeFetcher.md b/example/ruby/Gem/FakeFetcher.md deleted file mode 100644 index 40505c9..0000000 --- a/example/ruby/Gem/FakeFetcher.md +++ /dev/null @@ -1,77 +0,0 @@ -# Class: Gem::FakeFetcher -**Inherits:** Object - - -A fake Gem::RemoteFetcher for use in tests or to avoid real live HTTP requests -when testing code that uses RubyGems. - -Example: - - @fetcher = Gem::FakeFetcher.new - @fetcher.data['http://gems.example.com/yaml'] = source_index.to_yaml - Gem::RemoteFetcher.fetcher = @fetcher - - use nested array if multiple response is needed - - @fetcher.data['http://gems.example.com/sequence'] = [['Success', 200, 'OK'], ['Failed', 401, 'Unauthorized']] - - @fetcher.fetch_path('http://gems.example.com/sequence') # => ['Success', 200, 'OK'] - @fetcher.fetch_path('http://gems.example.com/sequence') # => ['Failed', 401, 'Unauthorized'] - - # invoke RubyGems code - - paths = @fetcher.paths - assert_equal 'http://gems.example.com/yaml', paths.shift - assert paths.empty?, paths.join(', ') - -See RubyGems' tests for more examples of FakeFetcher. - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - -## paths[RW] [](#attribute-i-paths) -Returns the value of attribute paths. - -## requests[RW] [](#attribute-i-requests) -Returns the value of attribute requests. - - -#Instance Methods -## cache_update_path(uri, pathnil, updatetrue) [](#method-i-cache_update_path) - -## create_response(uri) [](#method-i-create_response) - -**@raise** [TypeError] - -## download(spec, source_uri, install_dirGem.dir) [](#method-i-download) - -## download_to_cache(dependency) [](#method-i-download_to_cache) - -## fetch_path(path, mtimenil, headfalse) [](#method-i-fetch_path) - -## fetch_size(path) [](#method-i-fetch_size) - -**@raise** [ArgumentError] - -## find_data(path) [](#method-i-find_data) - -**@raise** [ArgumentError] - -## initialize() [](#method-i-initialize) - -**@return** [FakeFetcher] a new instance of FakeFetcher - -## last_request() [](#method-i-last_request) - -## open_uri_or_path(path) [](#method-i-open_uri_or_path) -Thanks, FakeWeb! - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## request(uri, request_class, last_modifiednil) [](#method-i-request) - -**@yield** [last_request] - diff --git a/example/ruby/Gem/FakeFetcher/FakeSocket.md b/example/ruby/Gem/FakeFetcher/FakeSocket.md deleted file mode 100644 index c077f10..0000000 --- a/example/ruby/Gem/FakeFetcher/FakeSocket.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Gem::FakeFetcher::FakeSocket -**Inherits:** StringIO - - - - - -#Instance Methods -## continue_timeout() [](#method-i-continue_timeout) - diff --git a/example/ruby/Gem/FilePermissionError.md b/example/ruby/Gem/FilePermissionError.md deleted file mode 100644 index 286f154..0000000 --- a/example/ruby/Gem/FilePermissionError.md +++ /dev/null @@ -1,18 +0,0 @@ -# Exception: Gem::FilePermissionError -**Inherits:** Gem::Exception - - -Signals that a file permission error is preventing the user from operating on -the given directory. - - -# Attributes -## directory[RW] [](#attribute-i-directory) -Returns the value of attribute directory. - - -#Instance Methods -## initialize(directory) [](#method-i-initialize) - -**@return** [FilePermissionError] a new instance of FilePermissionError - diff --git a/example/ruby/Gem/FixFullNameEncoding.md b/example/ruby/Gem/FixFullNameEncoding.md deleted file mode 100644 index aeadf8f..0000000 --- a/example/ruby/Gem/FixFullNameEncoding.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::FixFullNameEncoding - - - - - -#Instance Methods -## full_name() [](#method-i-full_name) - diff --git a/example/ruby/Gem/FormatException.md b/example/ruby/Gem/FormatException.md deleted file mode 100644 index a218473..0000000 --- a/example/ruby/Gem/FormatException.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::FormatException -**Inherits:** Gem::Exception - - -Used to raise parsing and loading errors - - -# Attributes -## file_path[RW] [](#attribute-i-file_path) -Returns the value of attribute file_path. - - diff --git a/example/ruby/Gem/GemNotFoundException.md b/example/ruby/Gem/GemNotFoundException.md deleted file mode 100644 index f052c6e..0000000 --- a/example/ruby/Gem/GemNotFoundException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::GemNotFoundException -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/GemNotInHomeException.md b/example/ruby/Gem/GemNotInHomeException.md deleted file mode 100644 index f758839..0000000 --- a/example/ruby/Gem/GemNotInHomeException.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::GemNotInHomeException -**Inherits:** Gem::Exception - - -Raised when attempting to uninstall a gem that isn't in GEM_HOME. - - -# Attributes -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - diff --git a/example/ruby/Gem/GemRunner.md b/example/ruby/Gem/GemRunner.md deleted file mode 100644 index 19ecb05..0000000 --- a/example/ruby/Gem/GemRunner.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Gem::GemRunner -**Inherits:** Object - - -Run an instance of the gem program. - -Gem::GemRunner is only intended for internal use by RubyGems itself. It does -not form any public API and may change at any time for any reason. - -If you would like to duplicate functionality of `gem` commands, use the -classes they call directly. - - - -#Instance Methods -## extract_build_args(args) [](#method-i-extract_build_args) -Separates the build arguments (those following `--`) from the other arguments -in the list. - -## initialize() [](#method-i-initialize) - -**@return** [GemRunner] a new instance of GemRunner - -## run(args) [](#method-i-run) -Run the gem command with the following arguments. - diff --git a/example/ruby/Gem/GemcutterUtilities.md b/example/ruby/Gem/GemcutterUtilities.md deleted file mode 100644 index db80a37..0000000 --- a/example/ruby/Gem/GemcutterUtilities.md +++ /dev/null @@ -1,108 +0,0 @@ -# Module: Gem::GemcutterUtilities - -**Includes:** Gem::Text - - -The WebauthnListener Response class is used by the WebauthnListener to create -responses to be sent to the Gem host. It creates a Gem::Net::HTTPResponse -instance when initialized and can be converted to the appropriate format to be -sent by a socket using `to_s`. Gem::Net::HTTPResponse instances cannot be -directly sent over a socket. - -Types of response classes: - - OkResponse - - NoContentResponse - - BadRequestResponse - - NotFoundResponse - - MethodNotAllowedResponse - -Example usage: - - server = TCPServer.new(0) - socket = server.accept - - response = OkResponse.for("https://rubygems.example") - socket.print response.to_s - socket.close - - -# Attributes -## host[RW] [](#attribute-i-host) -The host to connect to either from the RUBYGEMS_HOST environment variable or -from the user's configuration - -## scope=[R] [](#attribute-i-scope=) -Sets the attribute scope - -**@param** [] the value to set the attribute scope to. - - -#Instance Methods -## add_key_option() [](#method-i-add_key_option) -Add the --key option - -## add_otp_option() [](#method-i-add_otp_option) -Add the --otp option - -## api_key() [](#method-i-api_key) -The API key from the command options or from the user's configuration. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## mfa_unauthorized?(response) [](#method-i-mfa_unauthorized?) - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## otp() [](#method-i-otp) -The OTP code from the command options or from the user's configuration. - -## rubygems_api_request(method, path, hostnil, allowed_push_hostnil, scope:nil, credentials:{}, &block) [](#method-i-rubygems_api_request) -Creates an RubyGems API to `host` and `path` with the given HTTP `method`. - -If `allowed_push_host` metadata is present, then it will only allow that host. - -## set_api_key(host, key) [](#method-i-set_api_key) -Returns true when the user has enabled multifactor authentication from -`response` text and no otp provided by options. - -## sign_in(sign_in_hostnil, scope:nil) [](#method-i-sign_in) -Signs in with the RubyGems API at `sign_in_host` and sets the rubygems API -key. - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## update_scope(scope) [](#method-i-update_scope) - -## verify_api_key(key) [](#method-i-verify_api_key) -Retrieves the pre-configured API key `key` or terminates interaction with an -error. - -## webauthn_enabled?() [](#method-i-webauthn_enabled?) - -**@return** [Boolean] - -## with_response(response, error_prefixnil) [](#method-i-with_response) -If `response` is an HTTP Success (2XX) response, yields the response if a -block was given or shows the response body to the user. - -If the response was not successful, shows an error to the user including the -`error_prefix` and the response body. If the response was a permanent -redirect, shows an error to the user including the redirect location. - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnListener.md b/example/ruby/Gem/GemcutterUtilities/WebauthnListener.md deleted file mode 100644 index c32f0c2..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnListener.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnListener -**Inherits:** Object - - - - -# Class Methods -## listener_thread(host , server ) [](#method-c-listener_thread) -# Attributes -## host[RW] [](#attribute-i-host) -Returns the value of attribute host. - - -#Instance Methods -## initialize(host) [](#method-i-initialize) - -**@return** [WebauthnListener] a new instance of WebauthnListener - -## wait_for_otp_code(server) [](#method-i-wait_for_otp_code) - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/BadRequestResponse.md b/example/ruby/Gem/GemcutterUtilities/WebauthnListener/BadRequestResponse.md deleted file mode 100644 index 0e19fd8..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/BadRequestResponse.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnListener::BadRequestResponse -**Inherits:** Gem::GemcutterUtilities::WebauthnListener::Response - - - - - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/MethodNotAllowedResponse.md b/example/ruby/Gem/GemcutterUtilities/WebauthnListener/MethodNotAllowedResponse.md deleted file mode 100644 index a4d4db4..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/MethodNotAllowedResponse.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnListener::MethodNotAllowedResponse -**Inherits:** Gem::GemcutterUtilities::WebauthnListener::Response - - - - - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/NoContentResponse.md b/example/ruby/Gem/GemcutterUtilities/WebauthnListener/NoContentResponse.md deleted file mode 100644 index 6343f0b..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/NoContentResponse.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnListener::NoContentResponse -**Inherits:** Gem::GemcutterUtilities::WebauthnListener::Response - - - - - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/NotFoundResponse.md b/example/ruby/Gem/GemcutterUtilities/WebauthnListener/NotFoundResponse.md deleted file mode 100644 index c3ee3c8..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/NotFoundResponse.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnListener::NotFoundResponse -**Inherits:** Gem::GemcutterUtilities::WebauthnListener::Response - - - - - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/OkResponse.md b/example/ruby/Gem/GemcutterUtilities/WebauthnListener/OkResponse.md deleted file mode 100644 index 2e690bc..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/OkResponse.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnListener::OkResponse -**Inherits:** Gem::GemcutterUtilities::WebauthnListener::Response - - - - - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/Response.md b/example/ruby/Gem/GemcutterUtilities/WebauthnListener/Response.md deleted file mode 100644 index 0e7c8bb..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/Response.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnListener::Response -**Inherits:** Object - - - - -# Class Methods -## for(host ) [](#method-c-for) -# Attributes -## http_response[RW] [](#attribute-i-http_response) -Returns the value of attribute http_response. - - -#Instance Methods -## initialize(host) [](#method-i-initialize) - -**@return** [Response] a new instance of Response - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/SocketResponder.md b/example/ruby/Gem/GemcutterUtilities/WebauthnListener/SocketResponder.md deleted file mode 100644 index 49abfee..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnListener/SocketResponder.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnListener::SocketResponder -**Inherits:** Object - - - - - -#Instance Methods -## initialize(socket) [](#method-i-initialize) - -**@return** [SocketResponder] a new instance of SocketResponder - -## send(response) [](#method-i-send) - diff --git a/example/ruby/Gem/GemcutterUtilities/WebauthnPoller.md b/example/ruby/Gem/GemcutterUtilities/WebauthnPoller.md deleted file mode 100644 index 6a74634..0000000 --- a/example/ruby/Gem/GemcutterUtilities/WebauthnPoller.md +++ /dev/null @@ -1,93 +0,0 @@ -# Class: Gem::GemcutterUtilities::WebauthnPoller -**Inherits:** Object - -**Includes:** Gem::GemcutterUtilities - - - - -# Class Methods -## poll_thread(options , host , webauthn_url , credentials ) [](#method-c-poll_thread) -# Attributes -## host[RW] [](#attribute-i-host) -Returns the value of attribute host. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## add_key_option() [](#method-i-add_key_option) -Add the --key option - -## add_otp_option() [](#method-i-add_otp_option) -Add the --otp option - -## api_key() [](#method-i-api_key) -The API key from the command options or from the user's configuration. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(options, host) [](#method-i-initialize) - -**@return** [WebauthnPoller] a new instance of WebauthnPoller - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## mfa_unauthorized?(response) [](#method-i-mfa_unauthorized?) - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## otp() [](#method-i-otp) -The OTP code from the command options or from the user's configuration. - -## poll_for_otp(webauthn_url, credentials) [](#method-i-poll_for_otp) - -## rubygems_api_request(method, path, hostnil, allowed_push_hostnil, scope:nil, credentials:{}, &block) [](#method-i-rubygems_api_request) -Creates an RubyGems API to `host` and `path` with the given HTTP `method`. - -If `allowed_push_host` metadata is present, then it will only allow that host. - -## set_api_key(host, key) [](#method-i-set_api_key) -Returns true when the user has enabled multifactor authentication from -`response` text and no otp provided by options. - -## sign_in(sign_in_hostnil, scope:nil) [](#method-i-sign_in) -Signs in with the RubyGems API at `sign_in_host` and sets the rubygems API -key. - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## update_scope(scope) [](#method-i-update_scope) - -## verify_api_key(key) [](#method-i-verify_api_key) -Retrieves the pre-configured API key `key` or terminates interaction with an -error. - -## webauthn_enabled?() [](#method-i-webauthn_enabled?) - -**@return** [Boolean] - -## with_response(response, error_prefixnil) [](#method-i-with_response) -If `response` is an HTTP Success (2XX) response, yields the response if a -block was given or shows the response body to the user. - -If the response was not successful, shows an error to the user including the -`error_prefix` and the response body. If the response was a permanent -redirect, shows an error to the user including the redirect location. - diff --git a/example/ruby/Gem/GemspecHelpers.md b/example/ruby/Gem/GemspecHelpers.md deleted file mode 100644 index 397d892..0000000 --- a/example/ruby/Gem/GemspecHelpers.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Gem::GemspecHelpers - - -Mixin methods for commands that work with gemspecs. - - - -#Instance Methods -## find_gemspec(glob"*.gemspec") [](#method-i-find_gemspec) - diff --git a/example/ruby/Gem/HTTPResponseFactory.md b/example/ruby/Gem/HTTPResponseFactory.md deleted file mode 100644 index 60bf3d6..0000000 --- a/example/ruby/Gem/HTTPResponseFactory.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::HTTPResponseFactory -**Inherits:** Object - - -The HTTPResponseFactory allows easy creation of Gem::Net::HTTPResponse -instances in RubyGems tests: - -Example: - - Gem::HTTPResponseFactory.create( - body: "", - code: 301, - msg: "Moved Permanently", - headers: { "location" => "http://example.com" } - ) - - -# Class Methods -## create(body: , code: , msg: , headers: {}) [](#method-c-create) - diff --git a/example/ruby/Gem/ImpossibleDependenciesError.md b/example/ruby/Gem/ImpossibleDependenciesError.md deleted file mode 100644 index e9eb3ab..0000000 --- a/example/ruby/Gem/ImpossibleDependenciesError.md +++ /dev/null @@ -1,26 +0,0 @@ -# Exception: Gem::ImpossibleDependenciesError -**Inherits:** Gem::Exception - - -Raised by Gem::Resolver when dependencies conflict and create the inability to -find a valid possible spec for a request. - - -# Attributes -## conflicts[RW] [](#attribute-i-conflicts) -Returns the value of attribute conflicts. - -## request[RW] [](#attribute-i-request) -Returns the value of attribute request. - - -#Instance Methods -## build_message() [](#method-i-build_message) -:nodoc: - -## dependency() [](#method-i-dependency) - -## initialize(request, conflicts) [](#method-i-initialize) - -**@return** [ImpossibleDependenciesError] a new instance of ImpossibleDependenciesError - diff --git a/example/ruby/Gem/InstallError.md b/example/ruby/Gem/InstallError.md deleted file mode 100644 index b3129c6..0000000 --- a/example/ruby/Gem/InstallError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::InstallError -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/InstallUpdateOptions.md b/example/ruby/Gem/InstallUpdateOptions.md deleted file mode 100644 index 83a90d4..0000000 --- a/example/ruby/Gem/InstallUpdateOptions.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: Gem::InstallUpdateOptions - -**Includes:** Gem::SecurityOption - - -Mixin methods for install and update options for Gem::Commands - - - -#Instance Methods -## add_install_update_options() [](#method-i-add_install_update_options) -Add the install/update options to the option parser. - -## add_security_option() [](#method-i-add_security_option) - -## install_update_defaults_str() [](#method-i-install_update_defaults_str) -Default description for the gem install and update commands. - -## install_update_options() [](#method-i-install_update_options) -Default options for the gem install and update commands. - diff --git a/example/ruby/Gem/Installer.md b/example/ruby/Gem/Installer.md deleted file mode 100644 index 4b7d67f..0000000 --- a/example/ruby/Gem/Installer.md +++ /dev/null @@ -1,386 +0,0 @@ -# Class: Gem::Installer -**Inherits:** Object - -**Extended by:** Gem::Deprecate - -**Includes:** Gem::InstallerUninstallerUtils, Gem::UserInteraction - - -The installer installs the files contained in the .gem into the Gem.home. - -Gem::Installer does the work of putting files in all the right places on the -filesystem including unpacking the gem into its gem dir, installing the -gemspec in the specifications dir, storing the cached gem in the cache dir, -and installing either wrappers or symlinks for executables. - -The installer invokes pre and post install hooks. Hooks can be added either -through a rubygems_plugin.rb file in an installed gem or via a -rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb -file. See Gem.pre_install and Gem.post_install for details. - - -# Class Methods -## at(path , options {}) [](#method-c-at) -Construct an installer object for the gem file located at `path` -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -## for_spec(spec , options {}) [](#method-c-for_spec) -Construct an installer object for an ephemeral gem (one where we don't -actually have a .gem file, just a spec) -## inherited(klass ) [](#method-c-inherited) -Changes in rubygems to lazily loading `rubygems/command` (in order to lazily -load `optparse` as a side effect) affect bundler's custom installer which uses -`Gem::Command` without requiring it (up until bundler 2.2.29). This hook is to -compensate for that missing require. - -TODO: Remove when rubygems no longer supports running on bundler older than -2.2.29. -# Attributes -## exec_format[RW] [](#attribute-c-exec_format) -Defaults to use Ruby's program prefix and suffix. - -## bin_dir[RW] [](#attribute-i-bin_dir) -The directory a gem's executables will be installed into - -## build_args=[R] [](#attribute-i-build_args=) -Available through requiring rubygems/installer_test_case - -## build_root[RW] [](#attribute-i-build_root) -:nodoc: - -## env_shebang=[R] [](#attribute-i-env_shebang=) -Available through requiring rubygems/installer_test_case - -## force=[R] [](#attribute-i-force=) -Available through requiring rubygems/installer_test_case - -## format=[R] [](#attribute-i-format=) -Available through requiring rubygems/installer_test_case - -## format_executable=[R] [](#attribute-i-format_executable=) -Available through requiring rubygems/installer_test_case - -## gem_dir[RW] [](#attribute-i-gem_dir) -Lazy accessor for the spec's gem directory. - -## gem_home[RW] [](#attribute-i-gem_home) -The gem repository the gem will be installed into - -## ignore_dependencies=[R] [](#attribute-i-ignore_dependencies=) -Available through requiring rubygems/installer_test_case - -## options[RW] [](#attribute-i-options) -The options passed when the Gem::Installer was instantiated. - -## package[RW] [](#attribute-i-package) -The gem package instance. - -## security_policy=[R] [](#attribute-i-security_policy=) -Available through requiring rubygems/installer_test_case - -## wrappers=[R] [](#attribute-i-wrappers=) -Available through requiring rubygems/installer_test_case - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## app_script_text(bin_file_name) [](#method-i-app_script_text) -Return the text for an application file. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## build_extensions() [](#method-i-build_extensions) -Builds extensions. Valid types of extensions are extconf.rb files, configure -scripts and rakefiles or mkrf_conf files. - -## check_executable_overwrite(filename) [](#method-i-check_executable_overwrite) -Checks if `filename` exists in +@bin_dir+. - -If +@force+ is set `filename` is overwritten. - -If `filename` exists and it is a RubyGems wrapper for a different gem, then -the user is consulted. - -If `filename` exists and +@bin_dir+ is Gem.default_bindir (/usr/local) the -user is consulted. - -Otherwise `filename` is overwritten. - -**@raise** [Gem::InstallError] - -## check_that_user_bin_dir_is_in_path(executables) [](#method-i-check_that_user_bin_dir_is_in_path) -:nodoc: - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## default_spec_file() [](#method-i-default_spec_file) -The location of the default spec file for default gems. - -## dir() [](#method-i-dir) -Return the target directory where the gem is to be installed. This directory -is not guaranteed to be populated. - -## ensure_dependencies_met() [](#method-i-ensure_dependencies_met) -:nodoc: - -## ensure_dependency(spec, dependency) [](#method-i-ensure_dependency) -Ensure that the dependency is satisfied by the current installation of gem. -If it is not an exception is raised. - -spec -: Gem::Specification - -dependency -: Gem::Dependency - - -## ensure_loadable_spec() [](#method-i-ensure_loadable_spec) -Ensures the Gem::Specification written out for this gem is loadable upon -installation. - -## ensure_writable_dir(dir) [](#method-i-ensure_writable_dir) -:nodoc: - -**@raise** [Gem::FilePermissionError] - -## explicit_version_requirement(name) [](#method-i-explicit_version_requirement) - -## extract_bin() [](#method-i-extract_bin) -Extracts only the bin/ files from the gem into the gem directory. This is used -by default gems to allow a gem-aware stub to function without the full gem -installed. - -## extract_files() [](#method-i-extract_files) -Reads the file index and extracts each file into the gem directory. - -Ensures that files can't be installed outside the gem directory. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## formatted_program_filename(filename) [](#method-i-formatted_program_filename) -Prefix and suffix the program filename the same as ruby. - -## gem() [](#method-i-gem) -Filename of the gem being installed. - -## gemdeps_load(name) [](#method-i-gemdeps_load) - -## generate_bin() [](#method-i-generate_bin) -:nodoc: - -## generate_bin_script(filename, bindir) [](#method-i-generate_bin_script) -Creates the scripts to run the applications in the gem. -- The Windows script -is generated in addition to the regular one due to a bug or misfeature in the -Windows shell's pipe. See https://blade.ruby-lang.org/ruby-talk/193379 - -## generate_bin_symlink(filename, bindir) [](#method-i-generate_bin_symlink) -Creates the symlinks to run the applications in the gem. Moves the symlink if -the gem being installed has a newer version. - -## generate_plugins() [](#method-i-generate_plugins) -:nodoc: - -## generate_windows_script(filename, bindir) [](#method-i-generate_windows_script) -Creates windows .bat files for easy running of commands - -## initialize(package, options{}) [](#method-i-initialize) -Constructs an Installer instance that will install the gem at `package` which -can either be a path or an instance of Gem::Package. `options` is a Hash with -the following keys: - -:bin_dir -: Where to put a bin wrapper if needed. - -:development -: Whether or not development dependencies should be installed. - -:env_shebang -: Use /usr/bin/env in bin wrappers. - -:force -: Overrides all version checks and security policy checks, except for a - signed-gems-only policy. - -:format_executable -: Format the executable the same as the Ruby executable. If your Ruby is - ruby18, foo_exec will be installed as foo_exec18. - -:ignore_dependencies -: Don't raise if a dependency is missing. - -:install_dir -: The directory to install the gem into. - -:security_policy -: Use the specified security policy. See Gem::Security - -:user_install -: Indicate that the gem should be unpacked into the users personal gem - directory. - -:only_install_dir -: Only validate dependencies against what is in the install_dir - -:wrappers -: Install wrappers if true, symlinks if false. - -:build_args -: An Array of arguments to pass to the extension builder process. If not - set, then Gem::Command.build_args is used - -:post_install_message -: Print gem post install message if true - - -**@return** [Installer] a new instance of Installer - -## install() [](#method-i-install) -Installs the gem and returns a loaded Gem::Specification for the installed -gem. - -The gem will be installed with the following structure: - - @gem_home/ - cache/.gem #=> a cached copy of the installed gem - gems//... #=> extracted files - specifications/.gemspec #=> the Gem::Specification - -## installation_satisfies_dependency?(dependency) [](#method-i-installation_satisfies_dependency?) -True if the gems in the system satisfy `dependency`. - -**@return** [Boolean] - -## installed_specs() [](#method-i-installed_specs) -Return an Array of Specifications contained within the gem_home we'll be -installing into. - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## pre_install_checks() [](#method-i-pre_install_checks) -Performs various checks before installing the gem such as the install -repository is writable and its directories exist, required Ruby and rubygems -versions are met and that dependencies are installed. - -Version and dependency checks are skipped if this install is forced. - -The dependent check will be skipped if the install is ignoring dependencies. - -## process_options() [](#method-i-process_options) -:nodoc: - -## regenerate_plugins_for(spec, plugins_dir) [](#method-i-regenerate_plugins_for) - -## remove_plugins_for(spec, plugins_dir) [](#method-i-remove_plugins_for) - -## run_post_build_hooks() [](#method-i-run_post_build_hooks) -:nodoc: - -## run_post_install_hooks() [](#method-i-run_post_install_hooks) -:nodoc: - -## run_pre_install_hooks() [](#method-i-run_pre_install_hooks) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## shebang(bin_file_name) [](#method-i-shebang) -Generates a #! line for `bin_file_name`'s wrapper copying arguments if -necessary. - -If the :custom_shebang config is set, then it is used as a template for how to -create the shebang used for to run a gem's executables. - -The template supports 4 expansions: - - $env the path to the unix env utility - $ruby the path to the currently running ruby interpreter - $exec the path to the gem's executable - $name the name of the gem the executable is for - -## spec() [](#method-i-spec) -Lazy accessor for the installer's spec. - -## spec_file() [](#method-i-spec_file) -The location of the spec file that is installed. - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## unpack(directory) [](#method-i-unpack) -Unpacks the gem into the given directory. - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - -## verify_gem_home() [](#method-i-verify_gem_home) -:nodoc: - -## verify_spec() [](#method-i-verify_spec) - -## windows_stub_script(bindir, bin_file_name) [](#method-i-windows_stub_script) -return the stub script text used to launch the true Ruby script - -## write_build_info_file() [](#method-i-write_build_info_file) -Writes the file containing the arguments for building this gem's extensions. - -## write_cache_file() [](#method-i-write_cache_file) -Writes the .gem file to the cache directory - -## write_default_spec() [](#method-i-write_default_spec) -Writes the full .gemspec specification (in Ruby) to the gem home's -specifications/default directory. - -In contrast to #write_spec, this keeps file lists, so the `gem contents` -command works. - -## write_spec() [](#method-i-write_spec) -Writes the .gemspec specification (in Ruby) to the gem home's specifications -directory. - diff --git a/example/ruby/Gem/Installer/FakePackage.md b/example/ruby/Gem/Installer/FakePackage.md deleted file mode 100644 index be3a128..0000000 --- a/example/ruby/Gem/Installer/FakePackage.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Gem::Installer::FakePackage -**Inherits:** Object - - - - -# Attributes -## data_mode[RW] [](#attribute-i-data_mode) -Returns the value of attribute data_mode. - -## dir_mode[RW] [](#attribute-i-dir_mode) -Returns the value of attribute dir_mode. - -## prog_mode[RW] [](#attribute-i-prog_mode) -Returns the value of attribute prog_mode. - -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - -#Instance Methods -## copy_to(path) [](#method-i-copy_to) - -## extract_files(destination_dir, pattern"*") [](#method-i-extract_files) - -## initialize(spec) [](#method-i-initialize) - -**@return** [FakePackage] a new instance of FakePackage - diff --git a/example/ruby/Gem/InstallerTestCase.md b/example/ruby/Gem/InstallerTestCase.md deleted file mode 100644 index a163c5f..0000000 --- a/example/ruby/Gem/InstallerTestCase.md +++ /dev/null @@ -1,84 +0,0 @@ -# Class: Gem::InstallerTestCase -**Inherits:** Gem::TestCase - - -A test case for Gem::Installer. - - - -#Instance Methods -## setup_base_gem() [](#method-i-setup_base_gem) -Creates the following instance variables: - -@spec -: a spec named 'a', intended for regular installs - - -And returns a gem built for the @spec - -## setup_base_installer(forcetrue) [](#method-i-setup_base_installer) -Creates the following instance variables: - -@spec -: a spec named 'a', intended for regular installs - - -@gem -: the path to a built gem from @spec - - -And returns a Gem::Installer for the @spec that installs into @gemhome - -## setup_base_spec() [](#method-i-setup_base_spec) -Sets up a generic specification for testing the rubygems installer - -And returns it - -## setup_base_user_installer() [](#method-i-setup_base_user_installer) -Creates the following instance variables: - -@spec -: a spec named 'a', intended for regular installs - -@user_spec -: a spec named 'b', intended for user installs - - -@gem -: the path to a built gem from @spec - -@user_gem -: the path to a built gem from @user_spec - - -And returns a Gem::Installer for the @user_spec that installs into -Gem.user_dir - -## symlink_supported?() [](#method-i-symlink_supported?) -This is needed for Windows environment without symlink support enabled (the -default for non admin) to be able to skip test for features using symlinks. - -**@return** [Boolean] - -## util_inst_bindir() [](#method-i-util_inst_bindir) -The path where installed executables live - -## util_installer(spec, gem_home, forcetrue) [](#method-i-util_installer) -Creates an installer for `spec` that will install into `gem_home`. - -## util_make_exec(spec@spec, shebang"#!/usr/bin/ruby", bindir"bin") [](#method-i-util_make_exec) -Adds an executable named "executable" to `spec` with the given `shebang`. - -The executable is also written to the bin dir in @tmpdir and the installed gem -directory for `spec`. - -## util_setup_gem(ui@ui, forcetrue) [](#method-i-util_setup_gem) -Builds the @spec gem and returns an installer for it. The built gem includes: - - bin/executable - lib/code.rb - ext/a/mkrf_conf.rb - -## util_setup_installer(&block) [](#method-i-util_setup_installer) -Sets up the base @gem, builds it and returns an installer for it. - diff --git a/example/ruby/Gem/InstallerUninstallerUtils.md b/example/ruby/Gem/InstallerUninstallerUtils.md deleted file mode 100644 index d04b80d..0000000 --- a/example/ruby/Gem/InstallerUninstallerUtils.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Gem::InstallerUninstallerUtils - - -Helper methods for both Gem::Installer and Gem::Uninstaller - - - -#Instance Methods -## regenerate_plugins_for(spec, plugins_dir) [](#method-i-regenerate_plugins_for) - -## remove_plugins_for(spec, plugins_dir) [](#method-i-remove_plugins_for) - diff --git a/example/ruby/Gem/InvalidSpecificationException.md b/example/ruby/Gem/InvalidSpecificationException.md deleted file mode 100644 index e32ed14..0000000 --- a/example/ruby/Gem/InvalidSpecificationException.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::InvalidSpecificationException -**Inherits:** Gem::Exception - - -Potentially raised when a specification is validated. - - - diff --git a/example/ruby/Gem/Licenses.md b/example/ruby/Gem/Licenses.md deleted file mode 100644 index a3fd5e8..0000000 --- a/example/ruby/Gem/Licenses.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Gem::Licenses -**Inherits:** Object - -**Extended by:** Gem::Text - - - - -# Class Methods -## clean_text(text ) [](#method-c-clean_text) -Remove any non-printable characters and make the text suitable for printing. -## deprecated_exception_id?(license ) [](#method-c-deprecated_exception_id?) -**@return** [Boolean] - -## deprecated_license_id?(license ) [](#method-c-deprecated_license_id?) -**@return** [Boolean] - -## format_text(text , wrap , indent 0) [](#method-c-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters -## levenshtein_distance(str1 , str2 ) [](#method-c-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 -## match?(license ) [](#method-c-match?) -**@return** [Boolean] - -## min3(a , b , c ) [](#method-c-min3) -:nodoc: -## suggestions(license ) [](#method-c-suggestions) -## truncate_text(text , description , max_length 100_000) [](#method-c-truncate_text) -**@raise** [ArgumentError] - - diff --git a/example/ruby/Gem/List.md b/example/ruby/Gem/List.md deleted file mode 100644 index af12b98..0000000 --- a/example/ruby/Gem/List.md +++ /dev/null @@ -1,2085 +0,0 @@ -# Class: Gem::List -**Inherits:** Object - -**Includes:** Enumerable - - -The Gem::List class is currently unused and will be removed in the next major -rubygems version - - -# Class Methods -## prepend(list , value ) [](#method-c-prepend) -# Attributes -## tail[RW] [](#attribute-i-tail) -Returns the value of attribute tail. - -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(valuenil, tailnil) [](#method-i-initialize) - -**@return** [List] a new instance of List - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## prepend(value) [](#method-i-prepend) - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/LoadError.md b/example/ruby/Gem/LoadError.md deleted file mode 100644 index 6e8f8b1..0000000 --- a/example/ruby/Gem/LoadError.md +++ /dev/null @@ -1,17 +0,0 @@ -# Exception: Gem::LoadError -**Inherits:** LoadError - - -Raised when RubyGems is unable to load or activate a gem. Contains the name -and version requirements of the gem that either conflicts with already -activated gems or that RubyGems is otherwise unable to activate. - - -# Attributes -## name[RW] [](#attribute-i-name) -Name of gem - -## requirement[RW] [](#attribute-i-requirement) -Version requirement of gem - - diff --git a/example/ruby/Gem/LocalRemoteOptions.md b/example/ruby/Gem/LocalRemoteOptions.md deleted file mode 100644 index bfbec9f..0000000 --- a/example/ruby/Gem/LocalRemoteOptions.md +++ /dev/null @@ -1,44 +0,0 @@ -# Module: Gem::LocalRemoteOptions - - -Mixin methods for local and remote Gem::Command options. - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - diff --git a/example/ruby/Gem/MissingSpecError.md b/example/ruby/Gem/MissingSpecError.md deleted file mode 100644 index c9b18b4..0000000 --- a/example/ruby/Gem/MissingSpecError.md +++ /dev/null @@ -1,18 +0,0 @@ -# Exception: Gem::MissingSpecError -**Inherits:** Gem::LoadError - - -Raised when trying to activate a gem, and that gem does not exist on the -system. Instead of rescuing from this class, make sure to rescue from the -superclass Gem::LoadError to catch all types of load errors. - - - -#Instance Methods -## initialize(name, requirement, extra_messagenil) [](#method-i-initialize) - -**@return** [MissingSpecError] a new instance of MissingSpecError - -## message() [](#method-i-message) -:nodoc: - diff --git a/example/ruby/Gem/MissingSpecVersionError.md b/example/ruby/Gem/MissingSpecVersionError.md deleted file mode 100644 index 0604346..0000000 --- a/example/ruby/Gem/MissingSpecVersionError.md +++ /dev/null @@ -1,19 +0,0 @@ -# Exception: Gem::MissingSpecVersionError -**Inherits:** Gem::MissingSpecError - - -Raised when trying to activate a gem, and the gem exists on the system, but -not the requested version. Instead of rescuing from this class, make sure to -rescue from the superclass Gem::LoadError to catch all types of load errors. - - -# Attributes -## specs[RW] [](#attribute-i-specs) -Returns the value of attribute specs. - - -#Instance Methods -## initialize(name, requirement, specs) [](#method-i-initialize) - -**@return** [MissingSpecVersionError] a new instance of MissingSpecVersionError - diff --git a/example/ruby/Gem/MockBrowser.md b/example/ruby/Gem/MockBrowser.md deleted file mode 100644 index 76d4658..0000000 --- a/example/ruby/Gem/MockBrowser.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::MockBrowser -**Inherits:** Object - - -A Gem::MockBrowser is used in tests to mock a browser in that it can send HTTP -requests to the defined URI. - -Example: - - # Sends a get request to http://localhost:5678 - Gem::MockBrowser.get Gem::URI("http://localhost:5678") - -See RubyGems' tests for more examples of MockBrowser. - - -# Class Methods -## get(uri ) [](#method-c-get) -## options(uri ) [](#method-c-options) -## post(uri , content_type: "application/x-www-form-urlencoded") [](#method-c-post) - diff --git a/example/ruby/Gem/MockGemUi.md b/example/ruby/Gem/MockGemUi.md deleted file mode 100644 index 27c83d2..0000000 --- a/example/ruby/Gem/MockGemUi.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Gem::MockGemUi -**Inherits:** Gem::StreamUI - - -This Gem::StreamUI subclass records input and output to StringIO for retrieval -during tests. - - - -#Instance Methods -## ask(question) [](#method-i-ask) - -**@raise** [InputEOFError] - -## error() [](#method-i-error) - -## initialize(input"") [](#method-i-initialize) - -**@return** [MockGemUi] a new instance of MockGemUi - -## input() [](#method-i-input) - -## output() [](#method-i-output) - -## terminate_interaction(status0) [](#method-i-terminate_interaction) - -**@raise** [TermError] - -## terminated?() [](#method-i-terminated?) - -**@return** [Boolean] - diff --git a/example/ruby/Gem/MockGemUi/InputEOFError.md b/example/ruby/Gem/MockGemUi/InputEOFError.md deleted file mode 100644 index 67cc3fa..0000000 --- a/example/ruby/Gem/MockGemUi/InputEOFError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Gem::MockGemUi::InputEOFError -**Inherits:** RuntimeError - - -Raised when you haven't provided enough input to your MockGemUi - - - -#Instance Methods -## initialize(question) [](#method-i-initialize) - -**@return** [InputEOFError] a new instance of InputEOFError - diff --git a/example/ruby/Gem/MockGemUi/SystemExitException.md b/example/ruby/Gem/MockGemUi/SystemExitException.md deleted file mode 100644 index 623674e..0000000 --- a/example/ruby/Gem/MockGemUi/SystemExitException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::MockGemUi::SystemExitException -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/Gem/MockGemUi/TTY.md b/example/ruby/Gem/MockGemUi/TTY.md deleted file mode 100644 index 5ea211b..0000000 --- a/example/ruby/Gem/MockGemUi/TTY.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: Gem::MockGemUi::TTY - - - - -# Attributes -## tty[RW] [](#attribute-i-tty) -Returns the value of attribute tty. - - -#Instance Methods -## noecho() [](#method-i-noecho) - -**@yield** [_self] - -**@yieldparam** [Gem::MockGemUi::TTY] the object that the method was called on - -## tty?() [](#method-i-tty?) - -**@return** [Boolean] - diff --git a/example/ruby/Gem/MockGemUi/TermError.md b/example/ruby/Gem/MockGemUi/TermError.md deleted file mode 100644 index 92a6925..0000000 --- a/example/ruby/Gem/MockGemUi/TermError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Gem::MockGemUi::TermError -**Inherits:** SystemExit - - - - -# Attributes -## exit_code[RW] [](#attribute-i-exit_code) -Returns the value of attribute exit_code. - - -#Instance Methods -## initialize(exit_code) [](#method-i-initialize) - -**@return** [TermError] a new instance of TermError - diff --git a/example/ruby/Gem/MockTCPServer.md b/example/ruby/Gem/MockTCPServer.md deleted file mode 100644 index 65dc2ab..0000000 --- a/example/ruby/Gem/MockTCPServer.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Gem::MockTCPServer -**Inherits:** Object - - -The MockTCPServer for use in tests or to avoid real TCPServer instances to be -created when testing code related to the WebAuthn listener. - -Example: - - server = Gem::MockTCPServer - port = server.addr[1].to_s - - # this mocks waiting for a request by calling sleep - server.accept - - # this mocks the server closing - server.close - - -# Attributes -## port[RW] [](#attribute-i-port) -Returns the value of attribute port. - - -#Instance Methods -## accept() [](#method-i-accept) - -## addr() [](#method-i-addr) - -## close() [](#method-i-close) - -## initialize(port5678) [](#method-i-initialize) - -**@return** [MockTCPServer] a new instance of MockTCPServer - diff --git a/example/ruby/Gem/Molinillo.md b/example/ruby/Gem/Molinillo.md deleted file mode 100644 index be7c6cf..0000000 --- a/example/ruby/Gem/Molinillo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Molinillo - - -Gem::Molinillo is a generic dependency resolution algorithm. - - - diff --git a/example/ruby/Gem/Molinillo/CircularDependencyError.md b/example/ruby/Gem/Molinillo/CircularDependencyError.md deleted file mode 100644 index b693d1d..0000000 --- a/example/ruby/Gem/Molinillo/CircularDependencyError.md +++ /dev/null @@ -1,27 +0,0 @@ -# Exception: Gem::Molinillo::CircularDependencyError -**Inherits:** Gem::Molinillo::ResolverError - - -An error caused by attempting to fulfil a dependency that was circular - -**@note** [] This exception will be thrown if and only if a {Vertex} is added to a -{DependencyGraph} that has a {DependencyGraph::Vertex#path_to?} an -existing {DependencyGraph::Vertex} - - -# Attributes -## dependencies[RW] [](#attribute-i-dependencies) -Set -: the dependencies responsible for causing the error - - - -#Instance Methods -## initialize(vertices) [](#method-i-initialize) -Initializes a new error with the given circular vertices. - -**@param** [Array] the vertices in the dependency -that caused the error - -**@return** [CircularDependencyError] a new instance of CircularDependencyError - diff --git a/example/ruby/Gem/Molinillo/Delegates/ResolutionState.md b/example/ruby/Gem/Molinillo/Delegates/ResolutionState.md deleted file mode 100644 index c9bc560..0000000 --- a/example/ruby/Gem/Molinillo/Delegates/ResolutionState.md +++ /dev/null @@ -1,33 +0,0 @@ -# Module: Gem::Molinillo::Delegates::ResolutionState - - -Delegates all {Gem::Molinillo::ResolutionState} methods to a `#state` -property. - - - -#Instance Methods -## activated() [](#method-i-activated) -the graph of activated dependencies - -## conflicts() [](#method-i-conflicts) -unresolved conflicts, indexed by dependency name - -## depth() [](#method-i-depth) -the depth of the resolution - -## name() [](#method-i-name) -the name of the current requirement - -## possibilities() [](#method-i-possibilities) -the possibilities to satisfy the current requirement - -## requirement() [](#method-i-requirement) -the current requirement - -## requirements() [](#method-i-requirements) -currently unsatisfied requirements - -## unused_unwind_options() [](#method-i-unused_unwind_options) -unwinds for previous conflicts that weren't explored - diff --git a/example/ruby/Gem/Molinillo/Delegates/SpecificationProvider.md b/example/ruby/Gem/Molinillo/Delegates/SpecificationProvider.md deleted file mode 100644 index 6963095..0000000 --- a/example/ruby/Gem/Molinillo/Delegates/SpecificationProvider.md +++ /dev/null @@ -1,103 +0,0 @@ -# Module: Gem::Molinillo::Delegates::SpecificationProvider - - -Delegates all {Gem::Molinillo::SpecificationProvider} methods to a -`#specification_provider` property. - - - -#Instance Methods -## allow_missing?(dependency) [](#method-i-allow_missing?) -Returns whether this dependency, which has no possible matching -specifications, can safely be ignored. - -**@param** [Object] - -**@return** [Boolean] whether this dependency can safely be skipped. - -## dependencies_equal?(dependencies, other_dependencies) [](#method-i-dependencies_equal?) -Determines whether two arrays of dependencies are equal, and thus can be -grouped. - -**@param** [Array] - -**@param** [Array] - -**@return** [Boolean] whether `dependencies` and `other_dependencies` should -be considered equal. - -## dependencies_for(specification) [](#method-i-dependencies_for) -Returns the dependencies of `specification`. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `specification` parameter. - -**@param** [Object] - -**@return** [Array] the dependencies that are required by the given -`specification`. - -## name_for(dependency) [](#method-i-name_for) -Returns the name for the given `dependency`. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `dependency` parameter. - -**@param** [Object] - -**@return** [String] the name for the given `dependency`. - -## name_for_explicit_dependency_source() [](#method-i-name_for_explicit_dependency_source) - -**@return** [String] the name of the source of explicit dependencies, i.e. -those passed to {Resolver#resolve} directly. - -## name_for_locking_dependency_source() [](#method-i-name_for_locking_dependency_source) - -**@return** [String] the name of the source of 'locked' dependencies, i.e. -those passed to {Resolver#resolve} directly as the `base` - -## requirement_satisfied_by?(requirement, activated, spec) [](#method-i-requirement_satisfied_by?) -Determines whether the given `requirement` is satisfied by the given `spec`, -in the context of the current `activated` dependency graph. - -**@param** [Object] - -**@param** [DependencyGraph] the current dependency graph in the -resolution process. - -**@param** [Object] - -**@return** [Boolean] whether `requirement` is satisfied by `spec` in the -context of the current `activated` dependency graph. - -## search_for(dependency) [](#method-i-search_for) -Search for the specifications that match the given dependency. The -specifications in the returned array will be considered in reverse order, so -the latest version ought to be last. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `dependency` parameter. - -**@param** [Object] - -**@return** [Array] the specifications that satisfy the given -`dependency`. - -## sort_dependencies(dependencies, activated, conflicts) [](#method-i-sort_dependencies) -Sort dependencies so that the ones that are easiest to resolve are first. -Easiest to resolve is (usually) defined by: - 1) Is this dependency already activated? - 2) How relaxed are the requirements? - 3) Are there any conflicts for this dependency? - 4) How many possibilities are there to satisfy this dependency? - -**@param** [Array] - -**@param** [DependencyGraph] the current dependency graph in the -resolution process. - -**@param** [{String => Array}] - -**@return** [Array] a sorted copy of `dependencies`. - diff --git a/example/ruby/Gem/Molinillo/DependencyGraph.md b/example/ruby/Gem/Molinillo/DependencyGraph.md deleted file mode 100644 index fb48b68..0000000 --- a/example/ruby/Gem/Molinillo/DependencyGraph.md +++ /dev/null @@ -1,2327 +0,0 @@ -# Class: Gem::Molinillo::DependencyGraph -**Inherits:** Object - -**Includes:** Enumerable, Gem::TSort - - -A directed acyclic graph that is tuned to hold named dependencies - - -# Class Methods -## tsort(vertices ) [](#method-c-tsort) -Topologically sorts the given vertices. -**@param** [Enumerable] the vertices to be sorted, which must -all belong to the same graph. - -**@return** [Array] The sorted vertices. - -# Attributes -## log[RW] [](#attribute-i-log) - -**@return** [Log] the op log for this graph - -## vertices[RW] [](#attribute-i-vertices) - -**@return** [{String => Vertex}] the vertices of the dependency graph, keyed -by {Vertex#name} - - -#Instance Methods -## ==(other) [](#method-i-==) - -**@param** [DependencyGraph] - -**@return** [Boolean] whether the two dependency graphs are equal, determined -by a recursive traversal of each {#root_vertices} and its -{Vertex#successors} - -## add_child_vertex(name, payload, parent_names, requirement) [](#method-i-add_child_vertex) - -**@param** [String] - -**@param** [Object] - -**@param** [Array] - -**@param** [Object] the requirement that is requiring the child - -**@return** [void] - -## add_edge(origin, destination, requirement) [](#method-i-add_edge) -Adds a new {Edge} to the dependency graph - -**@param** [Vertex] - -**@param** [Vertex] - -**@param** [Object] the requirement that this edge represents - -**@return** [Edge] the added edge - -## add_vertex(name, payload, rootfalse) [](#method-i-add_vertex) -Adds a vertex with the given name, or updates the existing one. - -**@param** [String] - -**@param** [Object] - -**@return** [Vertex] the vertex that was added to `self` - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete_edge(edge) [](#method-i-delete_edge) -Deletes an {Edge} from the dependency graph - -**@param** [Edge] - -**@return** [Void] - -## detach_vertex_named(name) [](#method-i-detach_vertex_named) -Detaches the {#vertex_named} `name` {Vertex} from the graph, recursively -removing any non-root vertices that were orphaned in the process - -**@param** [String] - -**@return** [Array] the vertices which have been detached - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Enumerates through the vertices of the graph. - -**@return** [Array] The graph's vertices. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) -Initializes an empty dependency graph - -**@return** [DependencyGraph] a new instance of DependencyGraph - -## initialize_copy(other) [](#method-i-initialize_copy) -Initializes a copy of a {DependencyGraph}, ensuring that all {#vertices} are -properly copied. - -**@param** [DependencyGraph] the graph to copy. - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) - -**@return** [String] a string suitable for debugging - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## rewind_to(tag) [](#method-i-rewind_to) -Rewinds the graph to the state tagged as `tag` - -**@param** [Object] the tag to rewind to - -**@return** [Void] - -## root_vertex_named(name) [](#method-i-root_vertex_named) - -**@param** [String] - -**@return** [Vertex, nil] the root vertex with the given name - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## set_payload(name, payload) [](#method-i-set_payload) -Sets the payload of the vertex with the given name - -**@param** [String] the name of the vertex - -**@param** [Object] the payload - -**@return** [Void] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## tag(tag) [](#method-i-tag) -Tags the current state of the dependency as the given tag - -**@param** [Object] an opaque tag for the current state of the graph - -**@return** [Void] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_dot(options{}) [](#method-i-to_dot) - -**@param** [Hash] options for dot output. - -**@raise** [ArgumentError] - -**@return** [String] Returns a dot format representation of the graph - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, Gem::TSort::Cyclic is raised. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises Gem::TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, Gem::TSort::Cyclic is raised. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## vertex_named(name) [](#method-i-vertex_named) - -**@param** [String] - -**@return** [Vertex, nil] the vertex with the given name - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/Molinillo/DependencyGraph/Action.md b/example/ruby/Gem/Molinillo/DependencyGraph/Action.md deleted file mode 100644 index 392f759..0000000 --- a/example/ruby/Gem/Molinillo/DependencyGraph/Action.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Gem::Molinillo::DependencyGraph::Action -**Inherits:** Object - - -An action that modifies a {DependencyGraph} that is reversible. - -**@abstract** [] - - -# Class Methods -## action_name() [](#method-c-action_name) -**@return** [Symbol] The name of the action. - -# Attributes -## next[RW] [](#attribute-i-next) - -**@return** [Action, Nil] The next action - -## previous[RW] [](#attribute-i-previous) - -**@return** [Action, Nil] The previous action - - -#Instance Methods -## down(graph) [](#method-i-down) -Reverses the action on the given graph. - -**@param** [DependencyGraph] the graph to reverse the action on. - -**@return** [Void] - -## up(graph) [](#method-i-up) -Performs the action on the given graph. - -**@param** [DependencyGraph] the graph to perform the action on. - -**@return** [Void] - diff --git a/example/ruby/Gem/Molinillo/DependencyGraph/Edge.md b/example/ruby/Gem/Molinillo/DependencyGraph/Edge.md deleted file mode 100644 index 18f434f..0000000 --- a/example/ruby/Gem/Molinillo/DependencyGraph/Edge.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Gem::Molinillo::DependencyGraph::Edge -**Inherits:** Struct - - -A directed edge of a {DependencyGraph} - -**@attr** [Vertex] The origin of the directed edge - -**@attr** [Vertex] The destination of the directed edge - -**@attr** [Object] The requirement the directed edge represents - - -# Attributes -## destination[RW] [](#attribute-i-destination) -The destination of the directed edge - -**@return** [Vertex] the current value of destination - -## origin[RW] [](#attribute-i-origin) -The origin of the directed edge - -**@return** [Vertex] the current value of origin - -## requirement[RW] [](#attribute-i-requirement) -The requirement the directed edge represents - -**@return** [Object] the current value of requirement - - diff --git a/example/ruby/Gem/Molinillo/DependencyGraph/Log.md b/example/ruby/Gem/Molinillo/DependencyGraph/Log.md deleted file mode 100644 index 15933d3..0000000 --- a/example/ruby/Gem/Molinillo/DependencyGraph/Log.md +++ /dev/null @@ -1,2096 +0,0 @@ -# Class: Gem::Molinillo::DependencyGraph::Log -**Inherits:** Object - -**Extended by:** Enumerable - - -A log for dependency graph actions - - -# Class Methods -## all?(*args ) [](#method-c-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args ) [](#method-c-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args ) [](#method-c-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] -**@overload** [] - -## chunk() [](#method-c-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } -**@overload** [] - -## chunk_while() [](#method-c-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. -**@overload** [] - -## collect() [](#method-c-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-c-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. -**@overload** [] - -**@overload** [] - -## compact() [](#method-c-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] -**@overload** [] - -## count(*args ) [](#method-c-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args ) [](#method-c-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## detect(*args ) [](#method-c-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## drop(n ) [](#method-c-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] -**@overload** [] - -## drop_while() [](#method-c-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_cons(n ) [](#method-c-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_entry(*args ) [](#method-c-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_slice(n ) [](#method-c-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_with_index(*args ) [](#method-c-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_with_object(memo ) [](#method-c-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## entries(*args ) [](#method-c-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] -**@overload** [] - -## filter() [](#method-c-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-c-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## find(*args ) [](#method-c-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## find_all() [](#method-c-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. -**@overload** [] - -**@overload** [] - -## find_index(*args ) [](#method-c-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args ) [](#method-c-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-c-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. -**@overload** [] - -**@overload** [] - -## grep(pat ) [](#method-c-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. -**@overload** [] - -**@overload** [] - -## grep_v(pat ) [](#method-c-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. -**@overload** [] - -**@overload** [] - -## group_by() [](#method-c-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## include?(val ) [](#method-c-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false -**@overload** [] - -## inject(*args ) [](#method-c-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-c-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force -**@overload** [] - -## map() [](#method-c-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## max(*args ) [](#method-c-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args ) [](#method-c-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val ) [](#method-c-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false -**@overload** [] - -## min(*args ) [](#method-c-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args ) [](#method-c-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-c-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-c-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. -**@overload** [] - -**@overload** [] - -## none?(*args ) [](#method-c-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args ) [](#method-c-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-c-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. -**@overload** [] - -**@overload** [] - -## reduce(*args ) [](#method-c-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-c-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. -**@overload** [] - -**@overload** [] - -## reverse_each(*args ) [](#method-c-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## select() [](#method-c-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. -**@overload** [] - -**@overload** [] - -## slice_after(*args ) [](#method-c-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] -**@overload** [] - -**@overload** [] - -## slice_before(*args ) [](#method-c-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-c-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. -**@overload** [] - -## sort() [](#method-c-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-c-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! -**@overload** [] - -**@overload** [] - -## sum(*args ) [](#method-c-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" -**@overload** [] - -**@overload** [] - -## take(n ) [](#method-c-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] -**@overload** [] - -## take_while() [](#method-c-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## tally(*args ) [](#method-c-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} -**@overload** [] - -## to_a(*args ) [](#method-c-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] -**@overload** [] - -## to_h(*args ) [](#method-c-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. -**@overload** [] - -**@overload** [] - -## to_set(klass Set, *args , &block ) [](#method-c-to_set) -Makes a set from the enumerable object with given arguments. -## uniq() [](#method-c-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] -**@overload** [] - -**@overload** [] - -## zip(*args ) [](#method-c-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] -**@overload** [] - -**@overload** [] - - -#Instance Methods -## add_edge_no_circular(graph, origin, destination, requirement) [](#method-i-add_edge_no_circular) -{include:DependencyGraph#add_edge_no_circular} - -**@param** [Graph] the graph to perform the action on - -**@param** [Vertex] - -**@param** [Vertex] - -**@param** [Object] the requirement that this edge represents - -**@return** [Edge] the added edge - -## add_vertex(graph, name, payload, root) [](#method-i-add_vertex) -{include:DependencyGraph#add_vertex} - -**@param** [Graph] the graph to perform the action on - -**@param** [String] - -**@param** [Object] - -**@return** [Vertex] the vertex that was added to `self` - -## delete_edge(graph, origin_name, destination_name, requirement) [](#method-i-delete_edge) -{include:DependencyGraph#delete_edge} - -**@param** [Graph] the graph to perform the action on - -**@param** [String] - -**@param** [String] - -**@param** [Object] - -**@return** [Void] - -## detach_vertex_named(graph, name) [](#method-i-detach_vertex_named) -{include:DependencyGraph#detach_vertex_named} - -**@param** [Graph] the graph to perform the action on - -**@param** [String] - -**@return** [Array] the vertices which have been detached - -## initialize() [](#method-i-initialize) -Initializes an empty log - -**@return** [Log] a new instance of Log - -## pop!(graph) [](#method-i-pop!) -Pops the most recent action from the log and undoes the action - -**@param** [DependencyGraph] - -**@return** [Action] the action that was popped off the log - -## rewind_to(graph, tag) [](#method-i-rewind_to) -{include:DependencyGraph#rewind_to} - -**@param** [Graph] the graph to perform the action on - -**@param** [Object] the tag to rewind to - -**@return** [Void] - -## set_payload(graph, name, payload) [](#method-i-set_payload) -{include:DependencyGraph#set_payload} - -**@param** [Graph] the graph to perform the action on - -**@param** [String] the name of the vertex - -**@param** [Object] the payload - -**@return** [Void] - -## tag(graph, tag) [](#method-i-tag) -{include:DependencyGraph#tag} - -**@param** [Graph] the graph to perform the action on - -**@param** [Object] an opaque tag for the current state of the graph - -**@return** [Void] - diff --git a/example/ruby/Gem/Molinillo/DependencyGraph/Vertex.md b/example/ruby/Gem/Molinillo/DependencyGraph/Vertex.md deleted file mode 100644 index 89ff37f..0000000 --- a/example/ruby/Gem/Molinillo/DependencyGraph/Vertex.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: Gem::Molinillo::DependencyGraph::Vertex -**Inherits:** Object - - -A vertex in a {DependencyGraph} that encapsulates a {#name} and a {#payload} - - -# Attributes -## explicit_requirements[RW] [](#attribute-i-explicit_requirements) - -**@return** [Array] the explicit requirements that required -this vertex - -## incoming_edges[RW] [](#attribute-i-incoming_edges) - -**@return** [Array] the edges of {#graph} that have `self` as their -{Edge#destination} - -## name[RW] [](#attribute-i-name) - -**@return** [String] the name of the vertex - -## outgoing_edges[RW] [](#attribute-i-outgoing_edges) - -**@return** [Array] the edges of {#graph} that have `self` as their -{Edge#origin} - -## payload[RW] [](#attribute-i-payload) - -**@return** [Object] the payload the vertex holds - -## root[RW] [](#attribute-i-root) - -**@return** [Boolean] whether the vertex is considered a root vertex - - -#Instance Methods -## ==(other) [](#method-i-==) - -**@return** [Boolean] whether the two vertices are equal, determined -by a recursive traversal of each {Vertex#successors} - -## ancestor?(other) [](#method-i-ancestor?) -Is there a path from `other` to `self` following edges in the dependency -graph? - -**@return** [Boolean] whether there is a path following edges within this {#graph} - -## hash() [](#method-i-hash) - -**@return** [Fixnum] a hash for the vertex based upon its {#name} - -## initialize(name, payload) [](#method-i-initialize) -Initializes a vertex with the given name and payload. - -**@param** [String] see {#name} - -**@param** [Object] see {#payload} - -**@return** [Vertex] a new instance of Vertex - -## inspect() [](#method-i-inspect) - -**@return** [String] a string suitable for debugging - -## path_to?(other) [](#method-i-path_to?) -Is there a path from `self` to `other` following edges in the dependency -graph? - -**@return** [Boolean] whether there is a path following edges within this {#graph} - -## predecessors() [](#method-i-predecessors) - -**@return** [Array] the vertices of {#graph} that have an edge with -`self` as their {Edge#destination} - -## recursive_predecessors() [](#method-i-recursive_predecessors) - -**@return** [Set] the vertices of {#graph} where `self` is a -{#descendent?} - -## recursive_successors() [](#method-i-recursive_successors) - -**@return** [Set] the vertices of {#graph} where `self` is an -{#ancestor?} - -## requirements() [](#method-i-requirements) - -**@return** [Array] all of the requirements that required -this vertex - -## shallow_eql?(other) [](#method-i-shallow_eql?) - -**@param** [Vertex] the other vertex to compare to - -**@return** [Boolean] whether the two vertices are equal, determined -solely by {#name} and {#payload} equality - -## successors() [](#method-i-successors) - -**@return** [Array] the vertices of {#graph} that have an edge with -`self` as their {Edge#origin} - diff --git a/example/ruby/Gem/Molinillo/DependencyState.md b/example/ruby/Gem/Molinillo/DependencyState.md deleted file mode 100644 index e8eba34..0000000 --- a/example/ruby/Gem/Molinillo/DependencyState.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::Molinillo::DependencyState -**Inherits:** Gem::Molinillo::ResolutionState - - -A state that encapsulates a set of {#requirements} with an {Array} of -possibilities - - - -#Instance Methods -## pop_possibility_state() [](#method-i-pop_possibility_state) -Removes a possibility from `self` - -**@return** [PossibilityState] a state with a single possibility, -the possibility that was removed from `self` - diff --git a/example/ruby/Gem/Molinillo/NoSuchDependencyError.md b/example/ruby/Gem/Molinillo/NoSuchDependencyError.md deleted file mode 100644 index 1e2e7bc..0000000 --- a/example/ruby/Gem/Molinillo/NoSuchDependencyError.md +++ /dev/null @@ -1,32 +0,0 @@ -# Exception: Gem::Molinillo::NoSuchDependencyError -**Inherits:** Gem::Molinillo::ResolverError - - -An error caused by searching for a dependency that is completely unknown, i.e. -has no versions available whatsoever. - - -# Attributes -## dependency[RW] [](#attribute-i-dependency) - -**@return** [Object] the dependency that could not be found - -## required_by[RW] [](#attribute-i-required_by) - -**@return** [Array] the specifications that depended upon {#dependency} - - -#Instance Methods -## initialize(dependency, required_by[]) [](#method-i-initialize) -Initializes a new error with the given missing dependency. - -**@param** [Object] @see {#dependency} - -**@param** [Array] @see {#required_by} - -**@return** [NoSuchDependencyError] a new instance of NoSuchDependencyError - -## message() [](#method-i-message) -The error message for the missing dependency, including the specifications -that had this dependency. - diff --git a/example/ruby/Gem/Molinillo/PossibilityState.md b/example/ruby/Gem/Molinillo/PossibilityState.md deleted file mode 100644 index aab2d11..0000000 --- a/example/ruby/Gem/Molinillo/PossibilityState.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Gem::Molinillo::PossibilityState -**Inherits:** Gem::Molinillo::ResolutionState - - -A state that encapsulates a single possibility to fulfill the given -{#requirement} - - - diff --git a/example/ruby/Gem/Molinillo/ResolutionState.md b/example/ruby/Gem/Molinillo/ResolutionState.md deleted file mode 100644 index ff25431..0000000 --- a/example/ruby/Gem/Molinillo/ResolutionState.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Gem::Molinillo::ResolutionState -**Inherits:** Struct - - -A state that a {Resolution} can be in - -**@attr** [String] the name of the current requirement - -**@attr** [Array] currently unsatisfied requirements - -**@attr** [DependencyGraph] the graph of activated dependencies - -**@attr** [Object] the current requirement - -**@attr** [Object] the possibilities to satisfy the current requirement - -**@attr** [Integer] the depth of the resolution - -**@attr** [Hash] unresolved conflicts, indexed by dependency name - -**@attr** [Array] unwinds for previous conflicts that weren't explored - - -# Class Methods -## empty() [](#method-c-empty) -Returns an empty resolution state -**@return** [ResolutionState] an empty state - -# Attributes -## activated[RW] [](#attribute-i-activated) -the graph of activated dependencies - -**@return** [DependencyGraph] the current value of activated - -## conflicts[RW] [](#attribute-i-conflicts) -unresolved conflicts, indexed by dependency name - -**@return** [Hash] the current value of conflicts - -## depth[RW] [](#attribute-i-depth) -the depth of the resolution - -**@return** [Integer] the current value of depth - -## name[RW] [](#attribute-i-name) -the name of the current requirement - -**@return** [String] the current value of name - -## possibilities[RW] [](#attribute-i-possibilities) -the possibilities to satisfy the current requirement - -**@return** [Object] the current value of possibilities - -## requirement[RW] [](#attribute-i-requirement) -the current requirement - -**@return** [Object] the current value of requirement - -## requirements[RW] [](#attribute-i-requirements) -currently unsatisfied requirements - -**@return** [Array] the current value of requirements - -## unused_unwind_options[RW] [](#attribute-i-unused_unwind_options) -unwinds for previous conflicts that weren't explored - -**@return** [Array] the current value of unused_unwind_options - - diff --git a/example/ruby/Gem/Molinillo/Resolver.md b/example/ruby/Gem/Molinillo/Resolver.md deleted file mode 100644 index 168ac38..0000000 --- a/example/ruby/Gem/Molinillo/Resolver.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: Gem::Molinillo::Resolver -**Inherits:** Object - - -This class encapsulates a dependency resolver. The resolver is responsible for -determining which set of dependencies to activate, with feedback from the -{#specification_provider} - - -# Attributes -## resolver_ui[RW] [](#attribute-i-resolver_ui) - -**@return** [UI] the UI module used to communicate back to the user -during the resolution process - -## specification_provider[RW] [](#attribute-i-specification_provider) - -**@return** [SpecificationProvider] the specification provider used -in the resolution process - - -#Instance Methods -## initialize(specification_provider, resolver_ui) [](#method-i-initialize) -Initializes a new resolver. - -**@param** [SpecificationProvider] see {#specification_provider} - -**@param** [UI] see {#resolver_ui} - -**@return** [Resolver] a new instance of Resolver - -## resolve(requested, baseDependencyGraph.new) [](#method-i-resolve) -Resolves the requested dependencies into a {DependencyGraph}, locking to the -base dependency graph (if specified) - -**@param** [Array] an array of 'requested' dependencies that the -{#specification_provider} can understand - -**@param** [DependencyGraph, nil] the base dependency graph to which -dependencies should be 'locked' - diff --git a/example/ruby/Gem/Molinillo/Resolver/Resolution.md b/example/ruby/Gem/Molinillo/Resolver/Resolution.md deleted file mode 100644 index 0be40ed..0000000 --- a/example/ruby/Gem/Molinillo/Resolver/Resolution.md +++ /dev/null @@ -1,184 +0,0 @@ -# Class: Gem::Molinillo::Resolver::Resolution -**Inherits:** Object - -**Includes:** Gem::Molinillo::Delegates::ResolutionState, Gem::Molinillo::Delegates::SpecificationProvider - - -A specific resolution from a given {Resolver} - - -# Attributes -## base[RW] [](#attribute-i-base) - -**@return** [DependencyGraph] the base dependency graph to which -dependencies should be 'locked' - -## iteration_rate=[R] [](#attribute-i-iteration_rate=) - -**@return** [Integer] the number of resolver iterations in between calls to -{#resolver_ui}'s {UI#indicate_progress} method - -## original_requested[RW] [](#attribute-i-original_requested) - -**@return** [Array] the dependencies that were explicitly required - -## resolver_ui[RW] [](#attribute-i-resolver_ui) - -**@return** [UI] the UI that knows how to communicate feedback about the -resolution process back to the user - -## specification_provider[RW] [](#attribute-i-specification_provider) - -**@return** [SpecificationProvider] the provider that knows about -dependencies, requirements, specifications, versions, etc. - -## started_at=[R] [](#attribute-i-started_at=) - -**@return** [Time] the time at which resolution began - -## states=[R] [](#attribute-i-states=) - -**@return** [Array] the stack of states for the resolution - - -#Instance Methods -## activated() [](#method-i-activated) -the graph of activated dependencies - -## allow_missing?(dependency) [](#method-i-allow_missing?) -Returns whether this dependency, which has no possible matching -specifications, can safely be ignored. - -**@param** [Object] - -**@return** [Boolean] whether this dependency can safely be skipped. - -## conflicts() [](#method-i-conflicts) -unresolved conflicts, indexed by dependency name - -## dependencies_equal?(dependencies, other_dependencies) [](#method-i-dependencies_equal?) -Determines whether two arrays of dependencies are equal, and thus can be -grouped. - -**@param** [Array] - -**@param** [Array] - -**@return** [Boolean] whether `dependencies` and `other_dependencies` should -be considered equal. - -## dependencies_for(specification) [](#method-i-dependencies_for) -Returns the dependencies of `specification`. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `specification` parameter. - -**@param** [Object] - -**@return** [Array] the dependencies that are required by the given -`specification`. - -## depth() [](#method-i-depth) -the depth of the resolution - -## initialize(specification_provider, resolver_ui, requested, base) [](#method-i-initialize) -Initializes a new resolution. - -**@param** [SpecificationProvider] see {#specification_provider} - -**@param** [UI] see {#resolver_ui} - -**@param** [Array] see {#original_requested} - -**@param** [DependencyGraph] see {#base} - -**@return** [Resolution] a new instance of Resolution - -## name() [](#method-i-name) -the name of the current requirement - -## name_for(dependency) [](#method-i-name_for) -Returns the name for the given `dependency`. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `dependency` parameter. - -**@param** [Object] - -**@return** [String] the name for the given `dependency`. - -## name_for_explicit_dependency_source() [](#method-i-name_for_explicit_dependency_source) - -**@return** [String] the name of the source of explicit dependencies, i.e. -those passed to {Resolver#resolve} directly. - -## name_for_locking_dependency_source() [](#method-i-name_for_locking_dependency_source) - -**@return** [String] the name of the source of 'locked' dependencies, i.e. -those passed to {Resolver#resolve} directly as the `base` - -## possibilities() [](#method-i-possibilities) -the possibilities to satisfy the current requirement - -## requirement() [](#method-i-requirement) -the current requirement - -## requirement_satisfied_by?(requirement, activated, spec) [](#method-i-requirement_satisfied_by?) -Determines whether the given `requirement` is satisfied by the given `spec`, -in the context of the current `activated` dependency graph. - -**@param** [Object] - -**@param** [DependencyGraph] the current dependency graph in the -resolution process. - -**@param** [Object] - -**@return** [Boolean] whether `requirement` is satisfied by `spec` in the -context of the current `activated` dependency graph. - -## requirements() [](#method-i-requirements) -currently unsatisfied requirements - -## resolve() [](#method-i-resolve) -Resolves the {#original_requested} dependencies into a full dependency - graph - -**@raise** [ResolverError] if successful resolution is impossible - -**@return** [DependencyGraph] the dependency graph of successfully resolved -dependencies - -## search_for(dependency) [](#method-i-search_for) -Search for the specifications that match the given dependency. The -specifications in the returned array will be considered in reverse order, so -the latest version ought to be last. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `dependency` parameter. - -**@param** [Object] - -**@return** [Array] the specifications that satisfy the given -`dependency`. - -## sort_dependencies(dependencies, activated, conflicts) [](#method-i-sort_dependencies) -Sort dependencies so that the ones that are easiest to resolve are first. -Easiest to resolve is (usually) defined by: - 1) Is this dependency already activated? - 2) How relaxed are the requirements? - 3) Are there any conflicts for this dependency? - 4) How many possibilities are there to satisfy this dependency? - -**@param** [Array] - -**@param** [DependencyGraph] the current dependency graph in the -resolution process. - -**@param** [{String => Array}] - -**@return** [Array] a sorted copy of `dependencies`. - -## unused_unwind_options() [](#method-i-unused_unwind_options) -unwinds for previous conflicts that weren't explored - diff --git a/example/ruby/Gem/Molinillo/Resolver/Resolution/Conflict.md b/example/ruby/Gem/Molinillo/Resolver/Resolution/Conflict.md deleted file mode 100644 index 727afc4..0000000 --- a/example/ruby/Gem/Molinillo/Resolver/Resolution/Conflict.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: Gem::Molinillo::Resolver::Resolution::Conflict -**Inherits:** Struct - - -A conflict that the resolution process encountered - -**@attr** [Object] the requirement that immediately led to the conflict - -**@attr** [{String,Nil=>[Object]}] the requirements that caused the conflict - -**@attr** [Object, nil] the existing spec that was in conflict with -the {#possibility} - -**@attr** [Object] the set of specs that was unable to be -activated due to a conflict. - -**@attr** [Object] the relevant locking requirement. - -**@attr** [Array>] the different requirement -trees that led to every requirement for the conflicting name. - -**@attr** [{String=>Object}] the already-activated specs. - -**@attr** [Object] an error that has occurred during resolution, and -will be raised at the end of it if no resolution is found. - - -# Attributes -## activated_by_name[RW] [](#attribute-i-activated_by_name) -the already-activated specs. - -**@return** [{String=>Object}] the current value of activated_by_name - -## existing[RW] [](#attribute-i-existing) -the existing spec that was in conflict with the {#possibility} - -**@return** [Object, nil] the current value of existing - -## locked_requirement[RW] [](#attribute-i-locked_requirement) -the relevant locking requirement. - -**@return** [Object] the current value of locked_requirement - -## possibility_set[RW] [](#attribute-i-possibility_set) -the set of specs that was unable to be activated due to a conflict. - -**@return** [Object] the current value of possibility_set - -## requirement[RW] [](#attribute-i-requirement) -the requirement that immediately led to the conflict - -**@return** [Object] the current value of requirement - -## requirement_trees[RW] [](#attribute-i-requirement_trees) -the different requirement trees that led to every requirement for the -conflicting name. - -**@return** [Array>] the current value of requirement_trees - -## requirements[RW] [](#attribute-i-requirements) -the requirements that caused the conflict - -**@return** [{String,Nil=>[Object]}] the current value of requirements - -## underlying_error[RW] [](#attribute-i-underlying_error) -an error that has occurred during resolution, and will be raised at the end of -it if no resolution is found. - -**@return** [Object] the current value of underlying_error - - -#Instance Methods -## possibility() [](#method-i-possibility) - -**@return** [Object] a spec that was unable to be activated due to a conflict - diff --git a/example/ruby/Gem/Molinillo/Resolver/Resolution/PossibilitySet.md b/example/ruby/Gem/Molinillo/Resolver/Resolution/PossibilitySet.md deleted file mode 100644 index 833c6b5..0000000 --- a/example/ruby/Gem/Molinillo/Resolver/Resolution/PossibilitySet.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Gem::Molinillo::Resolver::Resolution::PossibilitySet -**Inherits:** Struct - - -A collection of possibility states that share the same dependencies - -**@attr** [Array] the dependencies for this set of possibilities - -**@attr** [Array] the possibilities - - -# Attributes -## dependencies[RW] [](#attribute-i-dependencies) -the dependencies for this set of possibilities - -**@return** [Array] the current value of dependencies - -## possibilities[RW] [](#attribute-i-possibilities) -the possibilities - -**@return** [Array] the current value of possibilities - - -#Instance Methods -## latest_version() [](#method-i-latest_version) - -**@return** [Object] most up-to-date dependency in the possibility set - -## to_s() [](#method-i-to_s) -String representation of the possibility set, for debugging - diff --git a/example/ruby/Gem/Molinillo/Resolver/Resolution/UnwindDetails.md b/example/ruby/Gem/Molinillo/Resolver/Resolution/UnwindDetails.md deleted file mode 100644 index f0423c2..0000000 --- a/example/ruby/Gem/Molinillo/Resolver/Resolution/UnwindDetails.md +++ /dev/null @@ -1,174 +0,0 @@ -# Class: Gem::Molinillo::Resolver::Resolution::UnwindDetails -**Inherits:** Struct - -**Includes:** Comparable - - -Details of the state to unwind to when a conflict occurs, and the cause of the -unwind - -**@attr** [Integer] the index of the state to unwind to - -**@attr** [Object] the requirement of the state we're unwinding to - -**@attr** [Array] for the requirement we're relaxing - -**@attr** [Array] the requirements that combined to cause the conflict - -**@attr** [Array] for the conflict - -**@attr** [Array] array of unwind requirements that were chosen over this unwind - - -# Attributes -## conflicting_requirements[RW] [](#attribute-i-conflicting_requirements) -the requirements that combined to cause the conflict - -**@return** [Array] the current value of conflicting_requirements - -## requirement_tree[RW] [](#attribute-i-requirement_tree) -for the requirement we're relaxing - -**@return** [Array] the current value of requirement_tree - -## requirement_trees[RW] [](#attribute-i-requirement_trees) -for the conflict - -**@return** [Array] the current value of requirement_trees - -## requirements_unwound_to_instead[RW] [](#attribute-i-requirements_unwound_to_instead) -array of unwind requirements that were chosen over this unwind - -**@return** [Array] the current value of requirements_unwound_to_instead - -## state_index[RW] [](#attribute-i-state_index) -the index of the state to unwind to - -**@return** [Integer] the current value of state_index - -## state_requirement[RW] [](#attribute-i-state_requirement) -the requirement of the state we're unwinding to - -**@return** [Object] the current value of state_requirement - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -We compare UnwindDetails when choosing which state to unwind to. If two -options have the same state_index we prefer the one most removed from a -requirement that caused the conflict. Both options would unwind to the same -state, but a `grandparent` option will filter out fewer of its possibilities -after doing so - where a state is both a `parent` and a `grandparent` to -requirements that have caused a conflict this is the correct behaviour. - -**@param** [UnwindDetail] UnwindDetail to be compared - -**@return** [Integer] integer specifying ordering - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## all_requirements() [](#method-i-all_requirements) - -**@return** [Array] array of all the requirements that led to the need for -this unwind - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## reversed_requirement_tree_index() [](#method-i-reversed_requirement_tree_index) - -**@return** [Integer] index of state requirement in reversed requirement tree -(the conflicting requirement itself will be at position 0) - -## sub_dependencies_to_avoid() [](#method-i-sub_dependencies_to_avoid) - -**@return** [Array] array of sub-dependencies to avoid when choosing a -new possibility for the state we've unwound to. Only relevant for -non-primary unwinds - -## unwinding_to_primary_requirement?() [](#method-i-unwinding_to_primary_requirement?) - -**@return** [Boolean] where the requirement of the state we're unwinding -to directly caused the conflict. Note: in this case, it is -impossible for the state we're unwinding to be a parent of -any of the other conflicting requirements (or we would have -circularity) - diff --git a/example/ruby/Gem/Molinillo/ResolverError.md b/example/ruby/Gem/Molinillo/ResolverError.md deleted file mode 100644 index aadb49b..0000000 --- a/example/ruby/Gem/Molinillo/ResolverError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Molinillo::ResolverError -**Inherits:** StandardError - - -An error that occurred during the resolution process - - - diff --git a/example/ruby/Gem/Molinillo/SpecificationProvider.md b/example/ruby/Gem/Molinillo/SpecificationProvider.md deleted file mode 100644 index 083f7c1..0000000 --- a/example/ruby/Gem/Molinillo/SpecificationProvider.md +++ /dev/null @@ -1,107 +0,0 @@ -# Module: Gem::Molinillo::SpecificationProvider - - -Provides information about specifications and dependencies to the resolver, -allowing the {Resolver} class to remain generic while still providing power -and flexibility. - -This module contains the methods that users of Gem::Molinillo must to -implement, using knowledge of their own model classes. - - - -#Instance Methods -## allow_missing?(dependency) [](#method-i-allow_missing?) -Returns whether this dependency, which has no possible matching -specifications, can safely be ignored. - -**@param** [Object] - -**@return** [Boolean] whether this dependency can safely be skipped. - -## dependencies_equal?(dependencies, other_dependencies) [](#method-i-dependencies_equal?) -Determines whether two arrays of dependencies are equal, and thus can be -grouped. - -**@param** [Array] - -**@param** [Array] - -**@return** [Boolean] whether `dependencies` and `other_dependencies` should -be considered equal. - -## dependencies_for(specification) [](#method-i-dependencies_for) -Returns the dependencies of `specification`. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `specification` parameter. - -**@param** [Object] - -**@return** [Array] the dependencies that are required by the given -`specification`. - -## name_for(dependency) [](#method-i-name_for) -Returns the name for the given `dependency`. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `dependency` parameter. - -**@param** [Object] - -**@return** [String] the name for the given `dependency`. - -## name_for_explicit_dependency_source() [](#method-i-name_for_explicit_dependency_source) - -**@return** [String] the name of the source of explicit dependencies, i.e. -those passed to {Resolver#resolve} directly. - -## name_for_locking_dependency_source() [](#method-i-name_for_locking_dependency_source) - -**@return** [String] the name of the source of 'locked' dependencies, i.e. -those passed to {Resolver#resolve} directly as the `base` - -## requirement_satisfied_by?(requirement, activated, spec) [](#method-i-requirement_satisfied_by?) -Determines whether the given `requirement` is satisfied by the given `spec`, -in the context of the current `activated` dependency graph. - -**@param** [Object] - -**@param** [DependencyGraph] the current dependency graph in the -resolution process. - -**@param** [Object] - -**@return** [Boolean] whether `requirement` is satisfied by `spec` in the -context of the current `activated` dependency graph. - -## search_for(dependency) [](#method-i-search_for) -Search for the specifications that match the given dependency. The -specifications in the returned array will be considered in reverse order, so -the latest version ought to be last. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `dependency` parameter. - -**@param** [Object] - -**@return** [Array] the specifications that satisfy the given -`dependency`. - -## sort_dependencies(dependencies, activated, conflicts) [](#method-i-sort_dependencies) -Sort dependencies so that the ones that are easiest to resolve are first. -Easiest to resolve is (usually) defined by: - 1) Is this dependency already activated? - 2) How relaxed are the requirements? - 3) Are there any conflicts for this dependency? - 4) How many possibilities are there to satisfy this dependency? - -**@param** [Array] - -**@param** [DependencyGraph] the current dependency graph in the -resolution process. - -**@param** [{String => Array}] - -**@return** [Array] a sorted copy of `dependencies`. - diff --git a/example/ruby/Gem/Molinillo/UI.md b/example/ruby/Gem/Molinillo/UI.md deleted file mode 100644 index 732d4fb..0000000 --- a/example/ruby/Gem/Molinillo/UI.md +++ /dev/null @@ -1,49 +0,0 @@ -# Module: Gem::Molinillo::UI - - -Conveys information about the resolution process to a user. - - - -#Instance Methods -## after_resolution() [](#method-i-after_resolution) -Called after resolution ends (either successfully or with an error). By -default, prints a newline. - -**@return** [void] - -## before_resolution() [](#method-i-before_resolution) -Called before resolution begins. - -**@return** [void] - -## debug(depth0) [](#method-i-debug) -Conveys debug information to the user. - -**@param** [Integer] the current depth of the resolution process. - -**@return** [void] - -## debug?() [](#method-i-debug?) -Whether or not debug messages should be printed. By default, whether or not -the `MOLINILLO_DEBUG` environment variable is set. - -**@return** [Boolean] - -## indicate_progress() [](#method-i-indicate_progress) -Called roughly every {#progress_rate}, this method should convey progress to -the user. - -**@return** [void] - -## output() [](#method-i-output) -The {IO} object that should be used to print output. `STDOUT`, by default. - -**@return** [IO] - -## progress_rate() [](#method-i-progress_rate) -How often progress should be conveyed to the user via {#indicate_progress}, in -seconds. A third of a second, by default. - -**@return** [Float] - diff --git a/example/ruby/Gem/Molinillo/VersionConflict.md b/example/ruby/Gem/Molinillo/VersionConflict.md deleted file mode 100644 index 1836560..0000000 --- a/example/ruby/Gem/Molinillo/VersionConflict.md +++ /dev/null @@ -1,144 +0,0 @@ -# Exception: Gem::Molinillo::VersionConflict -**Inherits:** Gem::Molinillo::ResolverError - -**Includes:** Gem::Molinillo::Delegates::SpecificationProvider - - -An error caused by conflicts in version - - -# Attributes -## conflicts[RW] [](#attribute-i-conflicts) - -**@return** [{String => Resolution::Conflict}] the conflicts that caused -resolution to fail - -## specification_provider[RW] [](#attribute-i-specification_provider) - -**@return** [SpecificationProvider] the specification provider used during -resolution - - -#Instance Methods -## allow_missing?(dependency) [](#method-i-allow_missing?) -Returns whether this dependency, which has no possible matching -specifications, can safely be ignored. - -**@param** [Object] - -**@return** [Boolean] whether this dependency can safely be skipped. - -## dependencies_equal?(dependencies, other_dependencies) [](#method-i-dependencies_equal?) -Determines whether two arrays of dependencies are equal, and thus can be -grouped. - -**@param** [Array] - -**@param** [Array] - -**@return** [Boolean] whether `dependencies` and `other_dependencies` should -be considered equal. - -## dependencies_for(specification) [](#method-i-dependencies_for) -Returns the dependencies of `specification`. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `specification` parameter. - -**@param** [Object] - -**@return** [Array] the dependencies that are required by the given -`specification`. - -## initialize(conflicts, specification_provider) [](#method-i-initialize) -Initializes a new error with the given version conflicts. - -**@param** [{String => Resolution::Conflict}] see {#conflicts} - -**@param** [SpecificationProvider] see {#specification_provider} - -**@return** [VersionConflict] a new instance of VersionConflict - -## message_with_trees(opts{}) [](#method-i-message_with_trees) - -**@option** [] - -**@option** [] - -**@option** [] - -**@option** [] - -**@option** [] - -**@option** [] - -**@param** [Hash] the options to create a message with. - -**@return** [String] An error message that includes requirement trees, -which is much more detailed & customizable than the default message - -## name_for(dependency) [](#method-i-name_for) -Returns the name for the given `dependency`. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `dependency` parameter. - -**@param** [Object] - -**@return** [String] the name for the given `dependency`. - -## name_for_explicit_dependency_source() [](#method-i-name_for_explicit_dependency_source) - -**@return** [String] the name of the source of explicit dependencies, i.e. -those passed to {Resolver#resolve} directly. - -## name_for_locking_dependency_source() [](#method-i-name_for_locking_dependency_source) - -**@return** [String] the name of the source of 'locked' dependencies, i.e. -those passed to {Resolver#resolve} directly as the `base` - -## requirement_satisfied_by?(requirement, activated, spec) [](#method-i-requirement_satisfied_by?) -Determines whether the given `requirement` is satisfied by the given `spec`, -in the context of the current `activated` dependency graph. - -**@param** [Object] - -**@param** [DependencyGraph] the current dependency graph in the -resolution process. - -**@param** [Object] - -**@return** [Boolean] whether `requirement` is satisfied by `spec` in the -context of the current `activated` dependency graph. - -## search_for(dependency) [](#method-i-search_for) -Search for the specifications that match the given dependency. The -specifications in the returned array will be considered in reverse order, so -the latest version ought to be last. - -**@note** [] This method should be 'pure', i.e. the return value should depend -only on the `dependency` parameter. - -**@param** [Object] - -**@return** [Array] the specifications that satisfy the given -`dependency`. - -## sort_dependencies(dependencies, activated, conflicts) [](#method-i-sort_dependencies) -Sort dependencies so that the ones that are easiest to resolve are first. -Easiest to resolve is (usually) defined by: - 1) Is this dependency already activated? - 2) How relaxed are the requirements? - 3) Are there any conflicts for this dependency? - 4) How many possibilities are there to satisfy this dependency? - -**@param** [Array] - -**@param** [DependencyGraph] the current dependency graph in the -resolution process. - -**@param** [{String => Array}] - -**@return** [Array] a sorted copy of `dependencies`. - diff --git a/example/ruby/Gem/MultifactorAuthFetcher.md b/example/ruby/Gem/MultifactorAuthFetcher.md deleted file mode 100644 index b4db5c2..0000000 --- a/example/ruby/Gem/MultifactorAuthFetcher.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Gem::MultifactorAuthFetcher -**Inherits:** Gem::FakeFetcher - - - - -# Attributes -## host[RW] [](#attribute-i-host) -Returns the value of attribute host. - -## webauthn_url[RW] [](#attribute-i-webauthn_url) -Returns the value of attribute webauthn_url. - - -#Instance Methods -## initialize(host:nil) [](#method-i-initialize) -GET /api/v1/webauthn_verification defaults to user does not have any security -devices - -**@return** [MultifactorAuthFetcher] a new instance of MultifactorAuthFetcher - -## respond_with_require_otp(url, success_body) [](#method-i-respond_with_require_otp) -given a url, return a response that requires multifactor authentication - -## respond_with_webauthn_polling(code) [](#method-i-respond_with_webauthn_polling) -GET /api/v1/webauthn_verification/:token/status.json returns success status -with OTP code - -## respond_with_webauthn_polling_failure() [](#method-i-respond_with_webauthn_polling_failure) -GET /api/v1/webauthn_verification/:token/status.json returns expired status - -## respond_with_webauthn_url() [](#method-i-respond_with_webauthn_url) -GET /api/v1/webauthn_verification returns a webauthn url GET -/api/v1/webauthn_verification/:token/status.json (polling url) returns pending -status - -## webauthn_url_with_port(port) [](#method-i-webauthn_url_with_port) - diff --git a/example/ruby/Gem/NameTuple.md b/example/ruby/Gem/NameTuple.md deleted file mode 100644 index defb7b1..0000000 --- a/example/ruby/Gem/NameTuple.md +++ /dev/null @@ -1,151 +0,0 @@ -# Class: Gem::NameTuple -**Inherits:** Object - -**Includes:** Comparable - - -Represents a gem of name `name` at `version` of `platform`. These wrap the -data returned from the indexes. - - -# Class Methods -## from_list(list ) [](#method-c-from_list) -Turn an array of [name, version, platform] into an array of NameTuple objects. -## null() [](#method-c-null) -A null NameTuple, ie name=nil, version=0 -## to_basic(list ) [](#method-c-to_basic) -Turn an array of NameTuple objects back into an array of -name, version, platform -: tuples. - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## platform[RW] [](#attribute-i-platform) -Returns the value of attribute platform. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## ==(other) [](#method-i-==) -Compare with `other`. Supports another NameTuple or an Array in the [name, -version, platform] format. - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## full_name() [](#method-i-full_name) -Returns the full name (name-version) of this Gem. Platform information is -included if it is not the default Ruby platform. This mimics the behavior of -Gem::Specification#full_name. - -## hash() [](#method-i-hash) - -## initialize(name, version, platformGem::Platform::RUBY) [](#method-i-initialize) - -**@return** [NameTuple] a new instance of NameTuple - -## initialize_with_platform() [](#method-i-initialize_with_platform) - -**@return** [NameTuple] a new instance of NameTuple - -## inspect() [](#method-i-inspect) -:nodoc: - -## lock_name() [](#method-i-lock_name) - -## match_platform?() [](#method-i-match_platform?) -Indicate if this NameTuple matches the current platform. - -**@return** [Boolean] - -## prerelease?() [](#method-i-prerelease?) -Indicate if this NameTuple is for a prerelease version. - -**@return** [Boolean] - -## spec_name() [](#method-i-spec_name) -Return the name that the gemspec file would be - -## to_a() [](#method-i-to_a) -Convert back to the [name, version, platform] tuple - diff --git a/example/ruby/Gem/Net.md b/example/ruby/Gem/Net.md deleted file mode 100644 index eef66d9..0000000 --- a/example/ruby/Gem/Net.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Net - - --- https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml - - - diff --git a/example/ruby/Gem/Net/BufferedIO.md b/example/ruby/Gem/Net/BufferedIO.md deleted file mode 100644 index f317c3a..0000000 --- a/example/ruby/Gem/Net/BufferedIO.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: Gem::Net::BufferedIO -**Inherits:** Object - - -:nodoc: internal use only - - -# Attributes -## continue_timeout[RW] [](#attribute-i-continue_timeout) -Returns the value of attribute continue_timeout. - -## debug_output[RW] [](#attribute-i-debug_output) -Returns the value of attribute debug_output. - -## io[RW] [](#attribute-i-io) -Returns the value of attribute io. - -## read_timeout[RW] [](#attribute-i-read_timeout) -Returns the value of attribute read_timeout. - -## write_timeout[RW] [](#attribute-i-write_timeout) -Returns the value of attribute write_timeout. - - -#Instance Methods -## close() [](#method-i-close) - -## closed?() [](#method-i-closed?) - -**@return** [Boolean] - -## eof?() [](#method-i-eof?) - -**@return** [Boolean] - -## initialize(io, read_timeout:60, write_timeout:60, continue_timeout:nil, debug_output:nil) [](#method-i-initialize) - -**@return** [BufferedIO] a new instance of BufferedIO - -## inspect() [](#method-i-inspect) - -## read(len, dest''.b, ignore_eoffalse) [](#method-i-read) - -## read_all(dest''.b) [](#method-i-read_all) - -## readline() [](#method-i-readline) - -## readuntil(terminator, ignore_eoffalse) [](#method-i-readuntil) - -## write(*strs) [](#method-i-write) - -## writeline(str) [](#method-i-writeline) - diff --git a/example/ruby/Gem/Net/HTTP.md b/example/ruby/Gem/Net/HTTP.md deleted file mode 100644 index e427a4a..0000000 --- a/example/ruby/Gem/Net/HTTP.md +++ /dev/null @@ -1,1667 +0,0 @@ -# Class: Gem::Net::HTTP -**Inherits:** Gem::Net::Protocol - - -Class Gem::Net::HTTP provides a rich library that implements the client in a -client-server model that uses the HTTP request-response protocol. For -information about HTTP, see: - -* [Hypertext Transfer - Protocol](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol). -* [Technical - overview](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Techni - cal_overview). - -## About the Examples - -:include: doc/net-http/examples.rdoc - -## Strategies - -* If you will make only a few GET requests, consider using - [OpenURI](rdoc-ref:OpenURI). -* If you will make only a few requests of all kinds, consider using the - various singleton convenience methods in this class. Each of the following - methods automatically starts and finishes a - [session](rdoc-ref:Gem::Net::HTTP@Sessions) that sends a single request: - - # Return string response body. - Gem::Net::HTTP.get(hostname, path) - Gem::Net::HTTP.get(uri) - - # Write string response body to $stdout. - Gem::Net::HTTP.get_print(hostname, path) - Gem::Net::HTTP.get_print(uri) - - # Return response as Gem::Net::HTTPResponse object. - Gem::Net::HTTP.get_response(hostname, path) - Gem::Net::HTTP.get_response(uri) - data = '{"title": "foo", "body": "bar", "userId": 1}' - Gem::Net::HTTP.post(uri, data) - params = {title: 'foo', body: 'bar', userId: 1} - Gem::Net::HTTP.post_form(uri, params) - data = '{"title": "foo", "body": "bar", "userId": 1}' - Gem::Net::HTTP.put(uri, data) - -* If performance is important, consider using sessions, which lower request - overhead. This [session](rdoc-ref:Gem::Net::HTTP@Sessions) has multiple - requests for [HTTP - methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request - _methods) and [WebDAV - methods](https://en.wikipedia.org/wiki/WebDAV#Implementation): - - Gem::Net::HTTP.start(hostname) do |http| - # Session started automatically before block execution. - http.get(path) - http.head(path) - body = 'Some text' - http.post(path, body) # Can also have a block. - http.put(path, body) - http.delete(path) - http.options(path) - http.trace(path) - http.patch(path, body) # Can also have a block. - http.copy(path) - http.lock(path, body) - http.mkcol(path, body) - http.move(path) - http.propfind(path, body) - http.proppatch(path, body) - http.unlock(path, body) - # Session finished automatically at block exit. - end - -The methods cited above are convenience methods that, via their few arguments, -allow minimal control over the requests. For greater control, consider using -[request objects](rdoc-ref:Gem::Net::HTTPRequest). - -## URIs - -On the internet, a URI ([Universal Resource -Identifier](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)) is a -string that identifies a particular resource. It consists of some or all of: -scheme, hostname, path, query, and fragment; see [URI -syntax](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax). - -A Ruby [Gem::URI::Generic](rdoc-ref:Gem::URI::Generic) object represents an -internet URI. It provides, among others, methods `scheme`, `hostname`, `path`, -`query`, and `fragment`. - -### Schemes - -An internet Gem::URI has a -[scheme](https://en.wikipedia.org/wiki/List_of_URI_schemes). - -The two schemes supported in Gem::Net::HTTP are `'https'` and `'http'`: - - uri.scheme # => "https" - Gem::URI('http://example.com').scheme # => "http" - -### Hostnames - -A hostname identifies a server (host) to which requests may be sent: - - hostname = uri.hostname # => "jsonplaceholder.typicode.com" - Gem::Net::HTTP.start(hostname) do |http| - # Some HTTP stuff. - end - -### Paths - -A host-specific path identifies a resource on the host: - - _uri = uri.dup - _uri.path = '/todos/1' - hostname = _uri.hostname - path = _uri.path - Gem::Net::HTTP.get(hostname, path) - -### Queries - -A host-specific query adds name/value pairs to the URI: - - _uri = uri.dup - params = {userId: 1, completed: false} - _uri.query = Gem::URI.encode_www_form(params) - _uri # => # - Gem::Net::HTTP.get(_uri) - -### Fragments - -A [URI fragment](https://en.wikipedia.org/wiki/URI_fragment) has no effect in -Gem::Net::HTTP; the same data is returned, regardless of whether a fragment is -included. - -## Request Headers - -Request headers may be used to pass additional information to the host, -similar to arguments passed in a method call; each header is a name/value -pair. - -Each of the Gem::Net::HTTP methods that sends a request to the host has -optional argument `headers`, where the headers are expressed as a hash of -field-name/value pairs: - - headers = {Accept: 'application/json', Connection: 'Keep-Alive'} - Gem::Net::HTTP.get(uri, headers) - -See lists of both standard request fields and common request fields at -[Request -Fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_field -s). A host may also accept other custom fields. - -## HTTP Sessions - -A *session* is a connection between a server (host) and a client that: - -* Is begun by instance method Gem::Net::HTTP#start. -* May contain any number of requests. -* Is ended by instance method Gem::Net::HTTP#finish. - -See example sessions at [Strategies](rdoc-ref:Gem::Net::HTTP@Strategies). - -### Session Using Gem::Net::HTTP.start - -If you have many requests to make to a single host (and port), consider using -singleton method Gem::Net::HTTP.start with a block; the method handles the -session automatically by: - -* Calling #start before block execution. -* Executing the block. -* Calling #finish after block execution. - -In the block, you can use these instance methods, each of which that sends a -single request: - -* [HTTP - methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request - _methods): - - * #get, #request_get: GET. - * #head, #request_head: HEAD. - * #post, #request_post: POST. - * #delete: DELETE. - * #options: OPTIONS. - * #trace: TRACE. - * #patch: PATCH. - -* [WebDAV methods](https://en.wikipedia.org/wiki/WebDAV#Implementation): - - * #copy: COPY. - * #lock: LOCK. - * #mkcol: MKCOL. - * #move: MOVE. - * #propfind: PROPFIND. - * #proppatch: PROPPATCH. - * #unlock: UNLOCK. - -### Session Using Gem::Net::HTTP.start and Gem::Net::HTTP.finish - -You can manage a session manually using methods #start and #finish: - - http = Gem::Net::HTTP.new(hostname) - http.start - http.get('/todos/1') - http.get('/todos/2') - http.delete('/posts/1') - http.finish # Needed to free resources. - -### Single-Request Session - -Certain convenience methods automatically handle a session by: - -* Creating an HTTP object -* Starting a session. -* Sending a single request. -* Finishing the session. -* Destroying the object. - -Such methods that send GET requests: - -* ::get: Returns the string response body. -* ::get_print: Writes the string response body to $stdout. -* ::get_response: Returns a Gem::Net::HTTPResponse object. - -Such methods that send POST requests: - -* ::post: Posts data to the host. -* ::post_form: Posts form data to the host. - -## HTTP Requests and Responses - -Many of the methods above are convenience methods, each of which sends a -request and returns a string without directly using Gem::Net::HTTPRequest and -Gem::Net::HTTPResponse objects. - -You can, however, directly create a request object, send the request, and -retrieve the response object; see: - -* Gem::Net::HTTPRequest. -* Gem::Net::HTTPResponse. - -## Following Redirection - -Each returned response is an instance of a subclass of Gem::Net::HTTPResponse. -See the [response class -hierarchy](rdoc-ref:Gem::Net::HTTPResponse@Response+Subclasses). - -In particular, class Gem::Net::HTTPRedirection is the parent of all -redirection classes. This allows you to craft a case statement to handle -redirections properly: - - def fetch(uri, limit = 10) - # You should choose a better exception. - raise ArgumentError, 'Too many HTTP redirects' if limit == 0 - - res = Gem::Net::HTTP.get_response(Gem::URI(uri)) - case res - when Gem::Net::HTTPSuccess # Any success class. - res - when Gem::Net::HTTPRedirection # Any redirection class. - location = res['Location'] - warn "Redirected to #{location}" - fetch(location, limit - 1) - else # Any other class. - res.value - end - end - - fetch(uri) - -## Basic Authentication - -Basic authentication is performed according to -[RFC2617](http://www.ietf.org/rfc/rfc2617.txt): - - req = Gem::Net::HTTP::Get.new(uri) - req.basic_auth('user', 'pass') - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -## Streaming Response Bodies - -By default Gem::Net::HTTP reads an entire response into memory. If you are -handling large files or wish to implement a progress bar you can instead -stream the body directly to an IO. - - Gem::Net::HTTP.start(hostname) do |http| - req = Gem::Net::HTTP::Get.new(uri) - http.request(req) do |res| - open('t.tmp', 'w') do |f| - res.read_body do |chunk| - f.write chunk - end - end - end - end - -## HTTPS - -HTTPS is enabled for an HTTP connection by Gem::Net::HTTP#use_ssl=: - - Gem::Net::HTTP.start(hostname, :use_ssl => true) do |http| - req = Gem::Net::HTTP::Get.new(uri) - res = http.request(req) - end - -Or if you simply want to make a GET request, you may pass in a URI object that -has an HTTPS URL. Gem::Net::HTTP automatically turns on TLS verification if -the URI object has a 'https' :URI scheme: - - uri # => # - Gem::Net::HTTP.get(uri) - -## Proxy Server - -An HTTP object can have a [proxy -server](https://en.wikipedia.org/wiki/Proxy_server). - -You can create an HTTP object with a proxy server using method -Gem::Net::HTTP.new or method Gem::Net::HTTP.start. - -The proxy may be defined either by argument `p_addr` or by environment -variable `'http_proxy'`. - -### Proxy Using Argument `p_addr` as a String - -When argument `p_addr` is a string hostname, the returned `http` has the given -host as its proxy: - - http = Gem::Net::HTTP.new(hostname, nil, 'proxy.example') - http.proxy? # => true - http.proxy_from_env? # => false - http.proxy_address # => "proxy.example" - # These use default values. - http.proxy_port # => 80 - http.proxy_user # => nil - http.proxy_pass # => nil - -The port, username, and password for the proxy may also be given: - - http = Gem::Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass') - # => # - http.proxy? # => true - http.proxy_from_env? # => false - http.proxy_address # => "proxy.example" - http.proxy_port # => 8000 - http.proxy_user # => "pname" - http.proxy_pass # => "ppass" - -### Proxy Using '`ENV['http_proxy']`' - -When environment variable `'http_proxy'` is set to a Gem::URI string, the -returned `http` will have the server at that URI as its proxy; note that the -Gem::URI string must have a protocol such as `'http'` or `'https'`: - - ENV['http_proxy'] = 'http://example.com' - http = Gem::Net::HTTP.new(hostname) - http.proxy? # => true - http.proxy_from_env? # => true - http.proxy_address # => "example.com" - # These use default values. - http.proxy_port # => 80 - http.proxy_user # => nil - http.proxy_pass # => nil - -The Gem::URI string may include proxy username, password, and port number: - - ENV['http_proxy'] = 'http://pname:ppass@example.com:8000' - http = Gem::Net::HTTP.new(hostname) - http.proxy? # => true - http.proxy_from_env? # => true - http.proxy_address # => "example.com" - http.proxy_port # => 8000 - http.proxy_user # => "pname" - http.proxy_pass # => "ppass" - -### Filtering Proxies - -With method Gem::Net::HTTP.new (but not Gem::Net::HTTP.start), you can use -argument `p_no_proxy` to filter proxies: - -* Reject a certain address: - - http = Gem::Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example') - http.proxy_address # => nil - -* Reject certain domains or subdomains: - - http = Gem::Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example') - http.proxy_address # => nil - -* Reject certain addresses and port combinations: - - http = Gem::Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234') - http.proxy_address # => "proxy.example" - - http = Gem::Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000') - http.proxy_address # => nil - -* Reject a list of the types above delimited using a comma: - - http = Gem::Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') - http.proxy_address # => nil - - http = Gem::Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') - http.proxy_address # => nil - -## Compression and Decompression - -Gem::Net::HTTP does not compress the body of a request before sending. - -By default, Gem::Net::HTTP adds header `'Accept-Encoding'` to a new [request -object](rdoc-ref:Gem::Net::HTTPRequest): - - Gem::Net::HTTP::Get.new(uri)['Accept-Encoding'] - # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" - -This requests the server to zip-encode the response body if there is one; the -server is not required to do so. - -Gem::Net::HTTP does not automatically decompress a response body if the -response has header `'Content-Range'`. - -Otherwise decompression (or not) depends on the value of header -[Content-Encoding](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#co -ntent-encoding-response-header): - -* `'deflate'`, `'gzip'`, or `'x-gzip'`: decompresses the body and deletes - the header. -* `'none'` or `'identity'`: does not decompress the body, but deletes the - header. -* Any other value: leaves the body and header unchanged. - -## What's Here - -First, what's elsewhere. Class Gem::Net::HTTP: - -* Inherits from [class Object](rdoc-ref:Object@What-27s+Here). - -This is a categorized summary of methods and attributes. - -### Gem::Net::HTTP Objects - -* [::new](rdoc-ref:Gem::Net::HTTP.new): Creates a new instance. -* [#inspect](rdoc-ref:Gem::Net::HTTP#inspect): Returns a string - representation of `self`. - -### Sessions - -* [::start](rdoc-ref:Gem::Net::HTTP.start): Begins a new session in a new - Gem::Net::HTTP object. -* [#started?](rdoc-ref:Gem::Net::HTTP#started?) (aliased as - [#active?](rdoc-ref:Gem::Net::HTTP#active?)): Returns whether in a - session. -* [#finish](rdoc-ref:Gem::Net::HTTP#finish): Ends an active session. -* [#start](rdoc-ref:Gem::Net::HTTP#start): Begins a new session in an - existing Gem::Net::HTTP object (`self`). - -### Connections - -* [:continue_timeout](rdoc-ref:Gem::Net::HTTP#continue_timeout): Returns the - continue timeout. -* [#continue_timeout=](rdoc-ref:Gem::Net::HTTP#continue_timeout=): Sets the - continue timeout seconds. -* [:keep_alive_timeout](rdoc-ref:Gem::Net::HTTP#keep_alive_timeout): Returns - the keep-alive timeout. -* [:keep_alive_timeout=](rdoc-ref:Gem::Net::HTTP#keep_alive_timeout=): Sets - the keep-alive timeout. -* [:max_retries](rdoc-ref:Gem::Net::HTTP#max_retries): Returns the maximum - retries. -* [#max_retries=](rdoc-ref:Gem::Net::HTTP#max_retries=): Sets the maximum - retries. -* [:open_timeout](rdoc-ref:Gem::Net::HTTP#open_timeout): Returns the open - timeout. -* [:open_timeout=](rdoc-ref:Gem::Net::HTTP#open_timeout=): Sets the open - timeout. -* [:read_timeout](rdoc-ref:Gem::Net::HTTP#read_timeout): Returns the open - timeout. -* [:read_timeout=](rdoc-ref:Gem::Net::HTTP#read_timeout=): Sets the read - timeout. -* [:ssl_timeout](rdoc-ref:Gem::Net::HTTP#ssl_timeout): Returns the ssl - timeout. -* [:ssl_timeout=](rdoc-ref:Gem::Net::HTTP#ssl_timeout=): Sets the ssl - timeout. -* [:write_timeout](rdoc-ref:Gem::Net::HTTP#write_timeout): Returns the write - timeout. -* [write_timeout=](rdoc-ref:Gem::Net::HTTP#write_timeout=): Sets the write - timeout. - -### Requests - -* [::get](rdoc-ref:Gem::Net::HTTP.get): Sends a GET request and returns the - string response body. -* [::get_print](rdoc-ref:Gem::Net::HTTP.get_print): Sends a GET request and - write the string response body to $stdout. -* [::get_response](rdoc-ref:Gem::Net::HTTP.get_response): Sends a GET - request and returns a response object. -* [::post_form](rdoc-ref:Gem::Net::HTTP.post_form): Sends a POST request - with form data and returns a response object. -* [::post](rdoc-ref:Gem::Net::HTTP.post): Sends a POST request with data and - returns a response object. -* [::put](rdoc-ref:Gem::Net::HTTP.put): Sends a PUT request with data and - returns a response object. -* [#copy](rdoc-ref:Gem::Net::HTTP#copy): Sends a COPY request and returns a - response object. -* [#delete](rdoc-ref:Gem::Net::HTTP#delete): Sends a DELETE request and - returns a response object. -* [#get](rdoc-ref:Gem::Net::HTTP#get): Sends a GET request and returns a - response object. -* [#head](rdoc-ref:Gem::Net::HTTP#head): Sends a HEAD request and returns a - response object. -* [#lock](rdoc-ref:Gem::Net::HTTP#lock): Sends a LOCK request and returns a - response object. -* [#mkcol](rdoc-ref:Gem::Net::HTTP#mkcol): Sends a MKCOL request and returns - a response object. -* [#move](rdoc-ref:Gem::Net::HTTP#move): Sends a MOVE request and returns a - response object. -* [#options](rdoc-ref:Gem::Net::HTTP#options): Sends a OPTIONS request and - returns a response object. -* [#patch](rdoc-ref:Gem::Net::HTTP#patch): Sends a PATCH request and returns - a response object. -* [#post](rdoc-ref:Gem::Net::HTTP#post): Sends a POST request and returns a - response object. -* [#propfind](rdoc-ref:Gem::Net::HTTP#propfind): Sends a PROPFIND request - and returns a response object. -* [#proppatch](rdoc-ref:Gem::Net::HTTP#proppatch): Sends a PROPPATCH request - and returns a response object. -* [#put](rdoc-ref:Gem::Net::HTTP#put): Sends a PUT request and returns a - response object. -* [#request](rdoc-ref:Gem::Net::HTTP#request): Sends a request and returns a - response object. -* [#request_get](rdoc-ref:Gem::Net::HTTP#request_get) (aliased as - [#get2](rdoc-ref:Gem::Net::HTTP#get2)): Sends a GET request and forms a - response object; if a block given, calls the block with the object, - otherwise returns the object. -* [#request_head](rdoc-ref:Gem::Net::HTTP#request_head) (aliased as - [#head2](rdoc-ref:Gem::Net::HTTP#head2)): Sends a HEAD request and forms a - response object; if a block given, calls the block with the object, - otherwise returns the object. -* [#request_post](rdoc-ref:Gem::Net::HTTP#request_post) (aliased as - [#post2](rdoc-ref:Gem::Net::HTTP#post2)): Sends a POST request and forms a - response object; if a block given, calls the block with the object, - otherwise returns the object. -* [#send_request](rdoc-ref:Gem::Net::HTTP#send_request): Sends a request and - returns a response object. -* [#trace](rdoc-ref:Gem::Net::HTTP#trace): Sends a TRACE request and returns - a response object. -* [#unlock](rdoc-ref:Gem::Net::HTTP#unlock): Sends an UNLOCK request and - returns a response object. - -### Responses - -* [:close_on_empty_response](rdoc-ref:Gem::Net::HTTP#close_on_empty_response - ): Returns whether to close connection on empty response. -* [:close_on_empty_response=](rdoc-ref:Gem::Net::HTTP#close_on_empty_respons - e=): Sets whether to close connection on empty response. -* [:ignore_eof](rdoc-ref:Gem::Net::HTTP#ignore_eof): Returns whether to - ignore end-of-file when reading a response body with `Content-Length` - headers. -* [:ignore_eof=](rdoc-ref:Gem::Net::HTTP#ignore_eof=): Sets whether to - ignore end-of-file when reading a response body with `Content-Length` - headers. -* [:response_body_encoding](rdoc-ref:Gem::Net::HTTP#response_body_encoding): - Returns the encoding to use for the response body. -* [#response_body_encoding=](rdoc-ref:Gem::Net::HTTP#response_body_encoding= - ): Sets the response body encoding. - -### Proxies - -* [:proxy_address](rdoc-ref:Gem::Net::HTTP#proxy_address): Returns the proxy - address. -* [:proxy_address=](rdoc-ref:Gem::Net::HTTP#proxy_address=): Sets the proxy - address. -* [::proxy_class?](rdoc-ref:Gem::Net::HTTP.proxy_class?): Returns whether - `self` is a proxy class. -* [#proxy?](rdoc-ref:Gem::Net::HTTP#proxy?): Returns whether `self` has a - proxy. -* [#proxy_address](rdoc-ref:Gem::Net::HTTP#proxy_address) (aliased as - [#proxyaddr](rdoc-ref:Gem::Net::HTTP#proxyaddr)): Returns the proxy - address. -* [#proxy_from_env?](rdoc-ref:Gem::Net::HTTP#proxy_from_env?): Returns - whether the proxy is taken from an environment variable. -* [:proxy_from_env=](rdoc-ref:Gem::Net::HTTP#proxy_from_env=): Sets whether - the proxy is to be taken from an environment variable. -* [:proxy_pass](rdoc-ref:Gem::Net::HTTP#proxy_pass): Returns the proxy - password. -* [:proxy_pass=](rdoc-ref:Gem::Net::HTTP#proxy_pass=): Sets the proxy - password. -* [:proxy_port](rdoc-ref:Gem::Net::HTTP#proxy_port): Returns the proxy port. -* [:proxy_port=](rdoc-ref:Gem::Net::HTTP#proxy_port=): Sets the proxy port. -* [#proxy_user](rdoc-ref:Gem::Net::HTTP#proxy_user): Returns the proxy user - name. -* [:proxy_user=](rdoc-ref:Gem::Net::HTTP#proxy_user=): Sets the proxy user. - -### Security - -* [:ca_file](rdoc-ref:Gem::Net::HTTP#ca_file): Returns the path to a CA - certification file. -* [:ca_file=](rdoc-ref:Gem::Net::HTTP#ca_file=): Sets the path to a CA - certification file. -* [:ca_path](rdoc-ref:Gem::Net::HTTP#ca_path): Returns the path of to CA - directory containing certification files. -* [:ca_path=](rdoc-ref:Gem::Net::HTTP#ca_path=): Sets the path of to CA - directory containing certification files. -* [:cert](rdoc-ref:Gem::Net::HTTP#cert): Returns the - OpenSSL::X509::Certificate object to be used for client certification. -* [:cert=](rdoc-ref:Gem::Net::HTTP#cert=): Sets the - OpenSSL::X509::Certificate object to be used for client certification. -* [:cert_store](rdoc-ref:Gem::Net::HTTP#cert_store): Returns the X509::Store - to be used for verifying peer certificate. -* [:cert_store=](rdoc-ref:Gem::Net::HTTP#cert_store=): Sets the X509::Store - to be used for verifying peer certificate. -* [:ciphers](rdoc-ref:Gem::Net::HTTP#ciphers): Returns the available SSL - ciphers. -* [:ciphers=](rdoc-ref:Gem::Net::HTTP#ciphers=): Sets the available SSL - ciphers. -* [:extra_chain_cert](rdoc-ref:Gem::Net::HTTP#extra_chain_cert): Returns the - extra X509 certificates to be added to the certificate chain. -* [:extra_chain_cert=](rdoc-ref:Gem::Net::HTTP#extra_chain_cert=): Sets the - extra X509 certificates to be added to the certificate chain. -* [:key](rdoc-ref:Gem::Net::HTTP#key): Returns the OpenSSL::PKey::RSA or - OpenSSL::PKey::DSA object. -* [:key=](rdoc-ref:Gem::Net::HTTP#key=): Sets the OpenSSL::PKey::RSA or - OpenSSL::PKey::DSA object. -* [:max_version](rdoc-ref:Gem::Net::HTTP#max_version): Returns the maximum - SSL version. -* [:max_version=](rdoc-ref:Gem::Net::HTTP#max_version=): Sets the maximum - SSL version. -* [:min_version](rdoc-ref:Gem::Net::HTTP#min_version): Returns the minimum - SSL version. -* [:min_version=](rdoc-ref:Gem::Net::HTTP#min_version=): Sets the minimum - SSL version. -* [#peer_cert](rdoc-ref:Gem::Net::HTTP#peer_cert): Returns the X509 - certificate chain for the session's socket peer. -* [:ssl_version](rdoc-ref:Gem::Net::HTTP#ssl_version): Returns the SSL - version. -* [:ssl_version=](rdoc-ref:Gem::Net::HTTP#ssl_version=): Sets the SSL - version. -* [#use_ssl=](rdoc-ref:Gem::Net::HTTP#use_ssl=): Sets whether a new session - is to use Transport Layer Security. -* [#use_ssl?](rdoc-ref:Gem::Net::HTTP#use_ssl?): Returns whether `self` uses - SSL. -* [:verify_callback](rdoc-ref:Gem::Net::HTTP#verify_callback): Returns the - callback for the server certification verification. -* [:verify_callback=](rdoc-ref:Gem::Net::HTTP#verify_callback=): Sets the - callback for the server certification verification. -* [:verify_depth](rdoc-ref:Gem::Net::HTTP#verify_depth): Returns the maximum - depth for the certificate chain verification. -* [:verify_depth=](rdoc-ref:Gem::Net::HTTP#verify_depth=): Sets the maximum - depth for the certificate chain verification. -* [:verify_hostname](rdoc-ref:Gem::Net::HTTP#verify_hostname): Returns the - flags for server the certification verification at the beginning of the - SSL/TLS session. -* [:verify_hostname=](rdoc-ref:Gem::Net::HTTP#verify_hostname=): Sets he - flags for server the certification verification at the beginning of the - SSL/TLS session. -* [:verify_mode](rdoc-ref:Gem::Net::HTTP#verify_mode): Returns the flags for - server the certification verification at the beginning of the SSL/TLS - session. -* [:verify_mode=](rdoc-ref:Gem::Net::HTTP#verify_mode=): Sets the flags for - server the certification verification at the beginning of the SSL/TLS - session. - -### Addresses and Ports - -* [:address](rdoc-ref:Gem::Net::HTTP#address): Returns the string host name - or host IP. -* [::default_port](rdoc-ref:Gem::Net::HTTP.default_port): Returns integer - 80, the default port to use for HTTP requests. -* [::http_default_port](rdoc-ref:Gem::Net::HTTP.http_default_port): Returns - integer 80, the default port to use for HTTP requests. -* [::https_default_port](rdoc-ref:Gem::Net::HTTP.https_default_port): - Returns integer 443, the default port to use for HTTPS requests. -* [#ipaddr](rdoc-ref:Gem::Net::HTTP#ipaddr): Returns the IP address for the - connection. -* [#ipaddr=](rdoc-ref:Gem::Net::HTTP#ipaddr=): Sets the IP address for the - connection. -* [:local_host](rdoc-ref:Gem::Net::HTTP#local_host): Returns the string - local host used to establish the connection. -* [:local_host=](rdoc-ref:Gem::Net::HTTP#local_host=): Sets the string local - host used to establish the connection. -* [:local_port](rdoc-ref:Gem::Net::HTTP#local_port): Returns the integer - local port used to establish the connection. -* [:local_port=](rdoc-ref:Gem::Net::HTTP#local_port=): Sets the integer - local port used to establish the connection. -* [:port](rdoc-ref:Gem::Net::HTTP#port): Returns the integer port number. - -### HTTP Version - -* [::version_1_2?](rdoc-ref:Gem::Net::HTTP.version_1_2?) (aliased as - [::is_version_1_2?](rdoc-ref:Gem::Net::HTTP.is_version_1_2?) and - [::version_1_2](rdoc-ref:Gem::Net::HTTP.version_1_2)): Returns true; - retained for compatibility. - -### Debugging - -* [#set_debug_output](rdoc-ref:Gem::Net::HTTP#set_debug_output): Sets the - output stream for debugging. - - -# Class Methods -## Proxy(p_addr :ENV, p_port nil, p_user nil, p_pass nil, p_use_ssl nil) [](#method-c-Proxy) -Creates an HTTP proxy class which behaves like Gem::Net::HTTP, but performs -all access via the specified proxy. - -This class is obsolete. You may pass these same parameters directly to -Gem::Net::HTTP.new. See Gem::Net::HTTP.new for details of the arguments. -## default_port() [](#method-c-default_port) -Returns integer `80`, the default port to use for HTTP requests: - - Gem::Net::HTTP.default_port # => 80 -## get(uri_or_host , path_or_headers nil, port nil) [](#method-c-get) -:call-seq: - Gem::Net::HTTP.get(hostname, path, port = 80) -> body - Gem::Net::HTTP:get(uri, headers = {}, port = uri.port) -> body - -Sends a GET request and returns the HTTP response body as a string. - -With string arguments `hostname` and `path`: - - hostname = 'jsonplaceholder.typicode.com' - path = '/todos/1' - puts Gem::Net::HTTP.get(hostname, path) - -Output: - - { - "userId": 1, - "id": 1, - "title": "delectus aut autem", - "completed": false - } - -With URI object `uri` and optional hash argument `headers`: - - uri = Gem::URI('https://jsonplaceholder.typicode.com/todos/1') - headers = {'Content-type' => 'application/json; charset=UTF-8'} - Gem::Net::HTTP.get(uri, headers) - -Related: - -* Gem::Net::HTTP::Get: request class for HTTP method `GET`. -* Gem::Net::HTTP#get: convenience method for HTTP method `GET`. -## get_print(uri_or_host , path_or_headers nil, port nil) [](#method-c-get_print) -:call-seq: - Gem::Net::HTTP.get_print(hostname, path, port = 80) -> nil - Gem::Net::HTTP:get_print(uri, headers = {}, port = uri.port) -> nil - -Like Gem::Net::HTTP.get, but writes the returned body to $stdout; returns -`nil`. -## get_response(uri_or_host , path_or_headers nil, port nil, &block ) [](#method-c-get_response) -:call-seq: - Gem::Net::HTTP.get_response(hostname, path, port = 80) -> http_response - Gem::Net::HTTP:get_response(uri, headers = {}, port = uri.port) -> http_response - -Like Gem::Net::HTTP.get, but returns a Gem::Net::HTTPResponse object instead -of the body string. -## http_default_port() [](#method-c-http_default_port) -Returns integer `80`, the default port to use for HTTP requests: - - Gem::Net::HTTP.http_default_port # => 80 -## https_default_port() [](#method-c-https_default_port) -Returns integer `443`, the default port to use for HTTPS requests: - - Gem::Net::HTTP.https_default_port # => 443 -## new(address , port nil, p_addr :ENV, p_port nil, p_user nil, p_pass nil, p_no_proxy nil, p_use_ssl nil) [](#method-c-new) -Returns a new Gem::Net::HTTP object `http` (but does not open a TCP connection -or HTTP session). - -With only string argument `address` given (and `ENV['http_proxy']` undefined -or `nil`), the returned `http`: - -* Has the given address. -* Has the default port number, Gem::Net::HTTP.default_port (80). -* Has no proxy. - -Example: - - http = Gem::Net::HTTP.new(hostname) - # => # - http.address # => "jsonplaceholder.typicode.com" - http.port # => 80 - http.proxy? # => false - -With integer argument `port` also given, the returned `http` has the given -port: - - http = Gem::Net::HTTP.new(hostname, 8000) - # => # - http.port # => 8000 - -For proxy-defining arguments `p_addr` through `p_no_proxy`, see [Proxy -Server](rdoc-ref:Gem::Net::HTTP@Proxy+Server). -## newobj() [](#method-c-newobj) -:nodoc: -## post(url , data , header nil) [](#method-c-post) -Posts data to a host; returns a Gem::Net::HTTPResponse object. - -Argument `url` must be a URL; argument `data` must be a string: - - _uri = uri.dup - _uri.path = '/posts' - data = '{"title": "foo", "body": "bar", "userId": 1}' - headers = {'content-type': 'application/json'} - res = Gem::Net::HTTP.post(_uri, data, headers) # => # - puts res.body - -Output: - - { - "title": "foo", - "body": "bar", - "userId": 1, - "id": 101 - } - -Related: - -* Gem::Net::HTTP::Post: request class for HTTP method `POST`. -* Gem::Net::HTTP#post: convenience method for HTTP method `POST`. -## post_form(url , params ) [](#method-c-post_form) -Posts data to a host; returns a Gem::Net::HTTPResponse object. - -Argument `url` must be a URI; argument `data` must be a hash: - - _uri = uri.dup - _uri.path = '/posts' - data = {title: 'foo', body: 'bar', userId: 1} - res = Gem::Net::HTTP.post_form(_uri, data) # => # - puts res.body - -Output: - - { - "title": "foo", - "body": "bar", - "userId": "1", - "id": 101 - } -## proxy_class?() [](#method-c-proxy_class?) -Returns true if self is a class which was created by HTTP::Proxy. -**@return** [Boolean] - -## put(url , data , header nil) [](#method-c-put) -Sends a PUT request to the server; returns a Gem::Net::HTTPResponse object. - -Argument `url` must be a URL; argument `data` must be a string: - - _uri = uri.dup - _uri.path = '/posts' - data = '{"title": "foo", "body": "bar", "userId": 1}' - headers = {'content-type': 'application/json'} - res = Gem::Net::HTTP.put(_uri, data, headers) # => # - puts res.body - -Output: - - { - "title": "foo", - "body": "bar", - "userId": 1, - "id": 101 - } - -Related: - -* Gem::Net::HTTP::Put: request class for HTTP method `PUT`. -* Gem::Net::HTTP#put: convenience method for HTTP method `PUT`. -## socket_type() [](#method-c-socket_type) -:nodoc: obsolete -## start(address , *arg , &block ) [](#method-c-start) -:call-seq: - HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) -> http - HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) {|http| ... } -> object - -Creates a new Gem::Net::HTTP object, `http`, via Gem::Net::HTTP.new: - -* For arguments `address` and `port`, see Gem::Net::HTTP.new. -* For proxy-defining arguments `p_addr` through `p_pass`, see [Proxy - Server](rdoc-ref:Gem::Net::HTTP@Proxy+Server). -* For argument `opts`, see below. - -With no block given: - -* Calls `http.start` with no block (see #start), which opens a TCP - connection and HTTP session. -* Returns `http`. -* The caller should call #finish to close the session: - - http = Gem::Net::HTTP.start(hostname) - http.started? # => true - http.finish - http.started? # => false - -With a block given: - -* Calls `http.start` with the block (see #start), which: - - * Opens a TCP connection and HTTP session. - * Calls the block, which may make any number of requests to the host. - * Closes the HTTP session and TCP connection on block exit. - * Returns the block's value `object`. - -* Returns `object`. - -Example: - - hostname = 'jsonplaceholder.typicode.com' - Gem::Net::HTTP.start(hostname) do |http| - puts http.get('/todos/1').body - puts http.get('/todos/2').body - end - -Output: - - { - "userId": 1, - "id": 1, - "title": "delectus aut autem", - "completed": false - } - { - "userId": 1, - "id": 2, - "title": "quis ut nam facilis et officia qui", - "completed": false - } - -If the last argument given is a hash, it is the `opts` hash, where each key is -a method or accessor to be called, and its value is the value to be set. - -The keys may include: - -* #ca_file -* #ca_path -* #cert -* #cert_store -* #ciphers -* #close_on_empty_response -* `ipaddr` (calls #ipaddr=) -* #keep_alive_timeout -* #key -* #open_timeout -* #read_timeout -* #ssl_timeout -* #ssl_version -* `use_ssl` (calls #use_ssl=) -* #verify_callback -* #verify_depth -* #verify_mode -* #write_timeout - -Note: If `port` is `nil` and `opts[:use_ssl]` is a truthy value, the value -passed to `new` is Gem::Net::HTTP.https_default_port, not `port`. -## version_1_1?() [](#method-c-version_1_1?) -Returns `false`; retained for compatibility. -**@return** [Boolean] - -## version_1_2() [](#method-c-version_1_2) -Returns `true`; retained for compatibility. -## version_1_2?() [](#method-c-version_1_2?) -Returns `true`; retained for compatibility. -**@return** [Boolean] - -# Attributes -## default_configuration[RW] [](#attribute-c-default_configuration) -Allows to set the default configuration that will be used when creating a new -connection. - -Example: - - Gem::Net::HTTP.default_configuration = { - read_timeout: 1, - write_timeout: 1 - } - http = Gem::Net::HTTP.new(hostname) - http.open_timeout # => 60 - http.read_timeout # => 1 - http.write_timeout # => 1 - -## proxy_address[RW] [](#attribute-c-proxy_address) -Returns the address of the proxy host, or `nil` if none; see -Gem::Net::HTTP@Proxy+Server. - -## proxy_pass[RW] [](#attribute-c-proxy_pass) -Returns the password for accessing the proxy, or `nil` if none; see -Gem::Net::HTTP@Proxy+Server. - -## proxy_port[RW] [](#attribute-c-proxy_port) -Returns the port number of the proxy host, or `nil` if none; see -Gem::Net::HTTP@Proxy+Server. - -## proxy_use_ssl[RW] [](#attribute-c-proxy_use_ssl) -Use SSL when talking to the proxy. If Gem::Net::HTTP does not use a proxy, -nil. - -## proxy_user[RW] [](#attribute-c-proxy_user) -Returns the user name for accessing the proxy, or `nil` if none; see -Gem::Net::HTTP@Proxy+Server. - -## address[RW] [](#attribute-i-address) -Returns the string host name or host IP given as argument `address` in ::new. - -## ca_file[RW] [](#attribute-i-ca_file) -Sets or returns the path to a CA certification file in PEM format. - -## ca_path[RW] [](#attribute-i-ca_path) -Sets or returns the path of to CA directory containing certification files in -PEM format. - -## cert[RW] [](#attribute-i-cert) -Sets or returns the OpenSSL::X509::Certificate object to be used for client -certification. - -## cert_store[RW] [](#attribute-i-cert_store) -Sets or returns the X509::Store to be used for verifying peer certificate. - -## ciphers[RW] [](#attribute-i-ciphers) -Sets or returns the available SSL ciphers. See -[OpenSSL::SSL::SSLContext#ciphers=](rdoc-ref:OpenSSL::SSL::SSLContext#ciphers- -3D). - -## close_on_empty_response[RW] [](#attribute-i-close_on_empty_response) -Sets or returns whether to close the connection when the response is empty; -initially `false`. - -## continue_timeout[RW] [](#attribute-i-continue_timeout) -Returns the continue timeout value; see continue_timeout=. - -## extra_chain_cert[RW] [](#attribute-i-extra_chain_cert) -Sets or returns the extra X509 certificates to be added to the certificate -chain. See -[OpenSSL::SSL::SSLContext#add_certificate](rdoc-ref:OpenSSL::SSL::SSLContext#a -dd_certificate). - -## ignore_eof[RW] [](#attribute-i-ignore_eof) -Sets or returns whether to ignore end-of-file when reading a response body -with `Content-Length` headers; initially `true`. - -## keep_alive_timeout[RW] [](#attribute-i-keep_alive_timeout) -Sets or returns the numeric (Integer or Float) number of seconds to keep the -connection open after a request is sent; initially 2. If a new request is made -during the given interval, the still-open connection is used; otherwise the -connection will have been closed and a new connection is opened. - -## key[RW] [](#attribute-i-key) -Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object. - -## local_host[RW] [](#attribute-i-local_host) -Sets or returns the string local host used to establish the connection; -initially `nil`. - -## local_port[RW] [](#attribute-i-local_port) -Sets or returns the integer local port used to establish the connection; -initially `nil`. - -## max_retries[RW] [](#attribute-i-max_retries) -Returns the maximum number of times to retry an idempotent request; see -#max_retries=. - -## max_version[RW] [](#attribute-i-max_version) -Sets or returns the maximum SSL version. See -[OpenSSL::SSL::SSLContext#max_version=](rdoc-ref:OpenSSL::SSL::SSLContext#max_ -version-3D). - -## min_version[RW] [](#attribute-i-min_version) -Sets or returns the minimum SSL version. See -[OpenSSL::SSL::SSLContext#min_version=](rdoc-ref:OpenSSL::SSL::SSLContext#min_ -version-3D). - -## open_timeout[RW] [](#attribute-i-open_timeout) -Sets or returns the numeric (Integer or Float) number of seconds to wait for a -connection to open; initially 60. If the connection is not made in the given -interval, an exception is raised. - -## port[RW] [](#attribute-i-port) -Returns the integer port number given as argument `port` in ::new. - -## proxy_address[RW] [](#attribute-i-proxy_address) -Returns the address of the proxy server, if defined, `nil` otherwise; see -[Proxy Server](rdoc-ref:Gem::Net::HTTP@Proxy+Server). - -## proxy_from_env=[R] [](#attribute-i-proxy_from_env=) -Sets whether to determine the proxy from environment variable -'`ENV['http_proxy']`'; see [Proxy Using -ENV['http_proxy']](rdoc-ref:Gem::Net::HTTP@Proxy+Using+-27ENV-5B-27http_proxy- -27-5D-27). - -## proxy_pass[RW] [](#attribute-i-proxy_pass) -Returns the password of the proxy server, if defined, `nil` otherwise; see -[Proxy Server](rdoc-ref:Gem::Net::HTTP@Proxy+Server). - -## proxy_port[RW] [](#attribute-i-proxy_port) -Returns the port number of the proxy server, if defined, `nil` otherwise; see -[Proxy Server](rdoc-ref:Gem::Net::HTTP@Proxy+Server). - -## proxy_use_ssl=[R] [](#attribute-i-proxy_use_ssl=) -Sets the attribute proxy_use_ssl - -**@param** [] the value to set the attribute proxy_use_ssl to. - -## proxy_user[RW] [](#attribute-i-proxy_user) -Returns the user name of the proxy server, if defined, `nil` otherwise; see -[Proxy Server](rdoc-ref:Gem::Net::HTTP@Proxy+Server). - -## read_timeout[RW] [](#attribute-i-read_timeout) -Returns the numeric (Integer or Float) number of seconds to wait for one block -to be read (via one read(2) call); see #read_timeout=. - -## response_body_encoding[RW] [](#attribute-i-response_body_encoding) -Returns the encoding to use for the response body; see -#response_body_encoding=. - -## ssl_timeout[RW] [](#attribute-i-ssl_timeout) -Sets or returns the SSL timeout seconds. - -## ssl_version[RW] [](#attribute-i-ssl_version) -Sets or returns the SSL version. See -[OpenSSL::SSL::SSLContext#ssl_version=](rdoc-ref:OpenSSL::SSL::SSLContext#ssl_ -version-3D). - -## verify_callback[RW] [](#attribute-i-verify_callback) -Sets or returns the callback for the server certification verification. - -## verify_depth[RW] [](#attribute-i-verify_depth) -Sets or returns the maximum depth for the certificate chain verification. - -## verify_hostname[RW] [](#attribute-i-verify_hostname) -Sets or returns whether to verify that the server certificate is valid for the -hostname. See -[OpenSSL::SSL::SSLContext#verify_hostname=](rdoc-ref:OpenSSL::SSL::SSLContext# -attribute-i-verify_mode). - -## verify_mode[RW] [](#attribute-i-verify_mode) -Sets or returns the flags for server the certification verification at the -beginning of the SSL/TLS session. OpenSSL::SSL::VERIFY_NONE or -OpenSSL::SSL::VERIFY_PEER are acceptable. - -## write_timeout[RW] [](#attribute-i-write_timeout) -Returns the numeric (Integer or Float) number of seconds to wait for one block -to be written (via one write(2) call); see #write_timeout=. - - -#Instance Methods -## copy(path, initheadernil) [](#method-i-copy) -Sends a COPY request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Copy object created from string -`path` and initial headers hash `initheader`. - - http = Gem::Net::HTTP.new(hostname) - http.copy('/todos/1') - -## delete(path, initheader{'Depth' => 'Infinity'}) [](#method-i-delete) -Sends a DELETE request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Delete object created from string -`path` and initial headers hash `initheader`. - - http = Gem::Net::HTTP.new(hostname) - http.delete('/todos/1') - -## finish() [](#method-i-finish) -Finishes the HTTP session: - - http = Gem::Net::HTTP.new(hostname) - http.start - http.started? # => true - http.finish # => nil - http.started? # => false - -Raises IOError if not in a session. - -**@raise** [IOError] - -## get(path, initheadernil, destnil, &block) [](#method-i-get) -:call-seq: - get(path, initheader = nil) {|res| ... } - -Sends a GET request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Get object created from string -`path` and initial headers hash `initheader`. - -With a block given, calls the block with the response body: - - http = Gem::Net::HTTP.new(hostname) - http.get('/todos/1') do |res| - p res - end # => # - -Output: - - "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}" - -With no block given, simply returns the response object: - - http.get('/') # => # - -Related: - -* Gem::Net::HTTP::Get: request class for HTTP method GET. -* Gem::Net::HTTP.get: sends GET request, returns response body. - -## head(path, initheadernil) [](#method-i-head) -Sends a HEAD request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Head object created from string -`path` and initial headers hash `initheader`: - - res = http.head('/todos/1') # => # - res.body # => nil - res.to_hash.take(3) - # => - [["date", ["Wed, 15 Feb 2023 15:25:42 GMT"]], - ["content-type", ["application/json; charset=utf-8"]], - ["connection", ["close"]]] - -## initialize(address, portnil) [](#method-i-initialize) -Creates a new Gem::Net::HTTP object for the specified server address, without -opening the TCP connection or initializing the HTTP session. The `address` -should be a DNS hostname or IP address. - -**@return** [HTTP] a new instance of HTTP - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - Gem::Net::HTTP.new(hostname).inspect - # => "#" - -## ipaddr() [](#method-i-ipaddr) -Returns the IP address for the connection. - -If the session has not been started, returns the value set by #ipaddr=, or -`nil` if it has not been set: - - http = Gem::Net::HTTP.new(hostname) - http.ipaddr # => nil - http.ipaddr = '172.67.155.76' - http.ipaddr # => "172.67.155.76" - -If the session has been started, returns the IP address from the socket: - - http = Gem::Net::HTTP.new(hostname) - http.start - http.ipaddr # => "172.67.155.76" - http.finish - -## ipaddr=(addr) [](#method-i-ipaddr=) -Sets the IP address for the connection: - - http = Gem::Net::HTTP.new(hostname) - http.ipaddr # => nil - http.ipaddr = '172.67.155.76' - http.ipaddr # => "172.67.155.76" - -The IP address may not be set if the session has been started. - -**@raise** [IOError] - -## lock(path, body, initheadernil) [](#method-i-lock) -Sends a LOCK request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Lock object created from string -`path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Gem::Net::HTTP.new(hostname) - http.lock('/todos/1', data) - -## mkcol(path, bodynil, initheadernil) [](#method-i-mkcol) -Sends a MKCOL request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Mkcol object created from string -`path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http.mkcol('/todos/1', data) - http = Gem::Net::HTTP.new(hostname) - -## move(path, initheadernil) [](#method-i-move) -Sends a MOVE request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Move object created from string -`path` and initial headers hash `initheader`. - - http = Gem::Net::HTTP.new(hostname) - http.move('/todos/1') - -## options(path, initheadernil) [](#method-i-options) -Sends an Options request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Options object created from string -`path` and initial headers hash `initheader`. - - http = Gem::Net::HTTP.new(hostname) - http.options('/') - -## patch(path, data, initheadernil, destnil, &block) [](#method-i-patch) -:call-seq: - patch(path, data, initheader = nil) {|res| ... } - -Sends a PATCH request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Patch object created from string -`path`, string `data`, and initial headers hash `initheader`. - -With a block given, calls the block with the response body: - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Gem::Net::HTTP.new(hostname) - http.patch('/todos/1', data) do |res| - p res - end # => # - -Output: - - "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false,\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\"\n}" - -With no block given, simply returns the response object: - - http.patch('/todos/1', data) # => # - -## peer_cert() [](#method-i-peer_cert) -Returns the X509 certificate chain (an array of strings) for the session's -socket peer, or `nil` if none. - -## post(path, data, initheadernil, destnil, &block) [](#method-i-post) -:call-seq: - post(path, data, initheader = nil) {|res| ... } - -Sends a POST request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Post object created from string -`path`, string `data`, and initial headers hash `initheader`. - -With a block given, calls the block with the response body: - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Gem::Net::HTTP.new(hostname) - http.post('/todos', data) do |res| - p res - end # => # - -Output: - - "{\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\",\n \"id\": 201\n}" - -With no block given, simply returns the response object: - - http.post('/todos', data) # => # - -Related: - -* Gem::Net::HTTP::Post: request class for HTTP method POST. -* Gem::Net::HTTP.post: sends POST request, returns response body. - -## propfind(path, bodynil, initheader{'Depth' => '0'}) [](#method-i-propfind) -Sends a PROPFIND request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Propfind object created from -string `path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Gem::Net::HTTP.new(hostname) - http.propfind('/todos/1', data) - -## proppatch(path, body, initheadernil) [](#method-i-proppatch) -Sends a PROPPATCH request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Proppatch object created from -string `path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Gem::Net::HTTP.new(hostname) - http.proppatch('/todos/1', data) - -## proxy?() [](#method-i-proxy?) -Returns `true` if a proxy server is defined, `false` otherwise; see [Proxy -Server](rdoc-ref:Gem::Net::HTTP@Proxy+Server). - -**@return** [Boolean] - -## proxy_from_env?() [](#method-i-proxy_from_env?) -Returns `true` if the proxy server is defined in the environment, `false` -otherwise; see [Proxy Server](rdoc-ref:Gem::Net::HTTP@Proxy+Server). - -**@return** [Boolean] - -## proxy_uri() [](#method-i-proxy_uri) -The proxy URI determined from the environment for this connection. - -## put(path, data, initheadernil) [](#method-i-put) -Sends a PUT request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Put object created from string -`path`, string `data`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Gem::Net::HTTP.new(hostname) - http.put('/todos/1', data) # => # - -Related: - -* Gem::Net::HTTP::Put: request class for HTTP method PUT. -* Gem::Net::HTTP.put: sends PUT request, returns response body. - -## request(req, bodynil, &block) [](#method-i-request) -Sends the given request `req` to the server; forms the response into a -Gem::Net::HTTPResponse object. - -The given `req` must be an instance of a [subclass of -Gem::Net::HTTPRequest](rdoc-ref:Gem::Net::HTTPRequest@Request+Subclasses). -Argument `body` should be given only if needed for the request. - -With no block given, returns the response object: - - http = Gem::Net::HTTP.new(hostname) - - req = Gem::Net::HTTP::Get.new('/todos/1') - http.request(req) - # => # - - req = Gem::Net::HTTP::Post.new('/todos') - http.request(req, 'xyzzy') - # => # - -With a block given, calls the block with the response and returns the -response: - - req = Gem::Net::HTTP::Get.new('/todos/1') - http.request(req) do |res| - p res - end # => # - -Output: - - # - -## request_get(path, initheadernil, &block) [](#method-i-request_get) -Sends a GET request to the server; forms the response into a -Gem::Net::HTTPResponse object. - -The request is based on the Gem::Net::HTTP::Get object created from string -`path` and initial headers hash `initheader`. - -With no block given, returns the response object: - - http = Gem::Net::HTTP.new(hostname) - http.request_get('/todos') # => # - -With a block given, calls the block with the response object and returns the -response object: - - http.request_get('/todos') do |res| - p res - end # => # - -Output: - - # - -## request_head(path, initheadernil, &block) [](#method-i-request_head) -Sends a HEAD request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Head object created from string -`path` and initial headers hash `initheader`. - - http = Gem::Net::HTTP.new(hostname) - http.head('/todos/1') # => # - -## request_post(path, data, initheadernil, &block) [](#method-i-request_post) -Sends a POST request to the server; forms the response into a -Gem::Net::HTTPResponse object. - -The request is based on the Gem::Net::HTTP::Post object created from string -`path`, string `data`, and initial headers hash `initheader`. - -With no block given, returns the response object: - - http = Gem::Net::HTTP.new(hostname) - http.post('/todos', 'xyzzy') - # => # - -With a block given, calls the block with the response body and returns the -response object: - - http.post('/todos', 'xyzzy') do |res| - p res - end # => # - -Output: - - "{\n \"xyzzy\": \"\",\n \"id\": 201\n}" - -## request_put(path, data, initheadernil, &block) [](#method-i-request_put) -Sends a PUT request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Put object created from string -`path`, string `data`, and initial headers hash `initheader`. - - http = Gem::Net::HTTP.new(hostname) - http.put('/todos/1', 'xyzzy') - # => # - -## send_request(name, path, datanil, headernil) [](#method-i-send_request) -Sends an HTTP request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTPRequest object created from string -`path`, string `data`, and initial headers hash `header`. That object is an -instance of the [subclass of -Gem::Net::HTTPRequest](rdoc-ref:Gem::Net::HTTPRequest@Request+Subclasses), -that corresponds to the given uppercase string `name`, which must be an [HTTP -request method](https://en.wikipedia.org/wiki/HTTP#Request_methods) or a -[WebDAV request method](https://en.wikipedia.org/wiki/WebDAV#Implementation). - -Examples: - - http = Gem::Net::HTTP.new(hostname) - http.send_request('GET', '/todos/1') - # => # - http.send_request('POST', '/todos', 'xyzzy') - # => # - -## set_debug_output(output) [](#method-i-set_debug_output) -**WARNING** This method opens a serious security hole. Never use this method -in production code. - -Sets the output stream for debugging: - - http = Gem::Net::HTTP.new(hostname) - File.open('t.tmp', 'w') do |file| - http.set_debug_output(file) - http.start - http.get('/nosuch/1') - http.finish - end - puts File.read('t.tmp') - -Output: - - opening connection to jsonplaceholder.typicode.com:80... - opened - <- "GET /nosuch/1 HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: jsonplaceholder.typicode.com\r\n\r\n" - -> "HTTP/1.1 404 Not Found\r\n" - -> "Date: Mon, 12 Dec 2022 21:14:11 GMT\r\n" - -> "Content-Type: application/json; charset=utf-8\r\n" - -> "Content-Length: 2\r\n" - -> "Connection: keep-alive\r\n" - -> "X-Powered-By: Express\r\n" - -> "X-Ratelimit-Limit: 1000\r\n" - -> "X-Ratelimit-Remaining: 999\r\n" - -> "X-Ratelimit-Reset: 1670879660\r\n" - -> "Vary: Origin, Accept-Encoding\r\n" - -> "Access-Control-Allow-Credentials: true\r\n" - -> "Cache-Control: max-age=43200\r\n" - -> "Pragma: no-cache\r\n" - -> "Expires: -1\r\n" - -> "X-Content-Type-Options: nosniff\r\n" - -> "Etag: W/\"2-vyGp6PvFo4RvsFtPoIWeCReyIC8\"\r\n" - -> "Via: 1.1 vegur\r\n" - -> "CF-Cache-Status: MISS\r\n" - -> "Server-Timing: cf-q-config;dur=1.3000000762986e-05\r\n" - -> "Report-To: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=yOr40jo%2BwS1KHzhTlVpl54beJ5Wx2FcG4gGV0XVrh3X9OlR5q4drUn2dkt5DGO4GDcE%2BVXT7CNgJvGs%2BZleIyMu8CLieFiDIvOviOY3EhHg94m0ZNZgrEdpKD0S85S507l1vsEwEHkoTm%2Ff19SiO\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\n" - -> "NEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\n" - -> "Server: cloudflare\r\n" - -> "CF-RAY: 778977dc484ce591-DFW\r\n" - -> "alt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r\n" - -> "\r\n" - reading 2 bytes... - -> "{}" - read 2 bytes - Conn keep-alive - -## start() [](#method-i-start) -Starts an HTTP session. - -Without a block, returns `self`: - - http = Gem::Net::HTTP.new(hostname) - # => # - http.start - # => # - http.started? # => true - http.finish - -With a block, calls the block with `self`, finishes the session when the block -exits, and returns the block's value: - - http.start do |http| - http - end - # => # - http.started? # => false - -**@raise** [IOError] - -## started?() [](#method-i-started?) -Returns `true` if the HTTP session has been started: - - http = Gem::Net::HTTP.new(hostname) - http.started? # => false - http.start - http.started? # => true - http.finish # => nil - http.started? # => false - - Gem::Net::HTTP.start(hostname) do |http| - http.started? - end # => true - http.started? # => false - -**@return** [Boolean] - -## trace(path, initheadernil) [](#method-i-trace) -Sends a TRACE request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Trace object created from string -`path` and initial headers hash `initheader`. - - http = Gem::Net::HTTP.new(hostname) - http.trace('/todos/1') - -## unlock(path, body, initheadernil) [](#method-i-unlock) -Sends an UNLOCK request to the server; returns an instance of a subclass of -Gem::Net::HTTPResponse. - -The request is based on the Gem::Net::HTTP::Unlock object created from string -`path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Gem::Net::HTTP.new(hostname) - http.unlock('/todos/1', data) - -## use_ssl=(flag) [](#method-i-use_ssl=) -Sets whether a new session is to use [Transport Layer -Security](https://en.wikipedia.org/wiki/Transport_Layer_Security): - -Raises IOError if attempting to change during a session. - -Raises OpenSSL::SSL::SSLError if the port is not an HTTPS port. - -## use_ssl?() [](#method-i-use_ssl?) -Returns `true` if `self` uses SSL, `false` otherwise. See -Gem::Net::HTTP#use_ssl=. - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Net/HTTP/Copy.md b/example/ruby/Gem/Net/HTTP/Copy.md deleted file mode 100644 index 4a5a767..0000000 --- a/example/ruby/Gem/Net/HTTP/Copy.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Net::HTTP::Copy -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [WebDAV method -COPY](http://www.webdav.org/specs/rfc4918.html#METHOD_COPY): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Copy.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Related: - -* Gem::Net::HTTP#copy: sends `COPY` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Delete.md b/example/ruby/Gem/Net/HTTP/Delete.md deleted file mode 100644 index 4ce0e44..0000000 --- a/example/ruby/Gem/Net/HTTP/Delete.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Gem::Net::HTTP::Delete -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [HTTP method -DELETE](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol -#DELETE_method): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - uri.path = '/posts/1' - req = Gem::Net::HTTP::Delete.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: optional. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): no. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Gem::Net::HTTP#delete: sends `DELETE` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Get.md b/example/ruby/Gem/Net/HTTP/Get.md deleted file mode 100644 index 9b002cf..0000000 --- a/example/ruby/Gem/Net/HTTP/Get.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Gem::Net::HTTP::Get -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [HTTP method -GET](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#GE -T_method): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Get.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: optional. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): yes. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): yes. - -Related: - -* Gem::Net::HTTP.get: sends `GET` request, returns response body. -* Gem::Net::HTTP#get: sends `GET` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Head.md b/example/ruby/Gem/Net/HTTP/Head.md deleted file mode 100644 index 1df875c..0000000 --- a/example/ruby/Gem/Net/HTTP/Head.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Gem::Net::HTTP::Head -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [HTTP method -HEAD](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#H -EAD_method): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Head.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: optional. -* Response body: no. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): yes. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): yes. - -Related: - -* Gem::Net::HTTP#head: sends `HEAD` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Lock.md b/example/ruby/Gem/Net/HTTP/Lock.md deleted file mode 100644 index b390a7d..0000000 --- a/example/ruby/Gem/Net/HTTP/Lock.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Net::HTTP::Lock -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [WebDAV method -LOCK](http://www.webdav.org/specs/rfc4918.html#METHOD_LOCK): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Lock.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Related: - -* Gem::Net::HTTP#lock: sends `LOCK` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Mkcol.md b/example/ruby/Gem/Net/HTTP/Mkcol.md deleted file mode 100644 index 2a9c524..0000000 --- a/example/ruby/Gem/Net/HTTP/Mkcol.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Net::HTTP::Mkcol -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [WebDAV method -MKCOL](http://www.webdav.org/specs/rfc4918.html#METHOD_MKCOL): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Mkcol.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Related: - -* Gem::Net::HTTP#mkcol: sends `MKCOL` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Move.md b/example/ruby/Gem/Net/HTTP/Move.md deleted file mode 100644 index 283cf66..0000000 --- a/example/ruby/Gem/Net/HTTP/Move.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Net::HTTP::Move -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [WebDAV method -MOVE](http://www.webdav.org/specs/rfc4918.html#METHOD_MOVE): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Move.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Related: - -* Gem::Net::HTTP#move: sends `MOVE` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Options.md b/example/ruby/Gem/Net/HTTP/Options.md deleted file mode 100644 index 83454d0..0000000 --- a/example/ruby/Gem/Net/HTTP/Options.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Gem::Net::HTTP::Options -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [HTTP method -OPTIONS](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protoco -l#OPTIONS_method): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Options.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: optional. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): yes. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Gem::Net::HTTP#options: sends `OPTIONS` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Patch.md b/example/ruby/Gem/Net/HTTP/Patch.md deleted file mode 100644 index ea2ed1a..0000000 --- a/example/ruby/Gem/Net/HTTP/Patch.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Gem::Net::HTTP::Patch -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [HTTP method -PATCH](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol# -PATCH_method): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - uri.path = '/posts' - req = Gem::Net::HTTP::Patch.new(uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_type = 'application/json' - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: yes. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): no. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): no. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Gem::Net::HTTP#patch: sends `PATCH` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Persistent.md b/example/ruby/Gem/Net/HTTP/Persistent.md deleted file mode 100644 index 9d7286d..0000000 --- a/example/ruby/Gem/Net/HTTP/Persistent.md +++ /dev/null @@ -1,454 +0,0 @@ -# Class: Gem::Net::HTTP::Persistent -**Inherits:** Object - - -Persistent connections for Gem::Net::HTTP - -Gem::Net::HTTP::Persistent maintains persistent connections across all the -servers you wish to talk to. For each host:port you communicate with a single -persistent connection is created. - -Connections will be shared across threads through a connection pool to -increase reuse of connections. - -You can shut down any remaining HTTP connections when done by calling -#shutdown. - -Example: - - require 'bundler/vendor/net-http-persistent/lib/net/http/persistent' - - uri = Gem::URI 'http://example.com/awesome/web/service' - - http = Gem::Net::HTTP::Persistent.new - - # perform a GET - response = http.request uri - - # or - - get = Gem::Net::HTTP::Get.new uri.request_uri - response = http.request get - - # create a POST - post_uri = uri + 'create' - post = Gem::Net::HTTP::Post.new post_uri.path - post.set_form_data 'some' => 'cool data' - - # perform the POST, the Gem::URI is always required - response http.request post_uri, post - -Note that for GET, HEAD and other requests that do not have a body you want to -use Gem::URI#request_uri not Gem::URI#path. The request_uri contains the -query params which are sent in the body for other requests. - -## TLS/SSL - -TLS connections are automatically created depending upon the scheme of the -Gem::URI. TLS connections are automatically verified against the default -certificate store for your computer. You can override this by changing -verify_mode or by specifying an alternate cert_store. - -Here are the TLS settings, see the individual methods for documentation: - -#certificate -: This client's certificate - -#ca_file -: The certificate-authorities - -#ca_path -: Directory with certificate-authorities - -#cert_store -: An SSL certificate store - -#ciphers -: List of SSl ciphers allowed - -#private_key -: The client's SSL private key - -#reuse_ssl_sessions -: Reuse a previously opened SSL session for a new connection - -#ssl_timeout -: Session lifetime - -#ssl_version -: Which specific SSL version to use - -#verify_callback -: For server certificate verification - -#verify_depth -: Depth of certificate verification - -#verify_mode -: How connections should be verified - -#verify_hostname -: Use hostname verification for server certificate during the handshake - - -## Proxies - -A proxy can be set through #proxy= or at initialization time by providing a -second argument to ::new. The proxy may be the Gem::URI of the proxy server -or `:ENV` which will consult environment variables. - -See #proxy= and #proxy_from_env for details. - -## Headers - -Headers may be specified for use in every request. #headers are appended to -any headers on the request. #override_headers replace existing headers on the -request. - -The difference between the two can be seen in setting the User-Agent. Using -`http.headers['User-Agent'] = 'MyUserAgent'` will send "Ruby, MyUserAgent" -while `http.override_headers['User-Agent'] = 'MyUserAgent'` will send -"MyUserAgent". - -## Tuning - -### Segregation - -Each Gem::Net::HTTP::Persistent instance has its own pool of connections. -There is no sharing with other instances (as was true in earlier versions). - -### Idle Timeout - -If a connection hasn't been used for this number of seconds it will -automatically be reset upon the next use to avoid attempting to send to a -closed connection. The default value is 5 seconds. nil means no timeout. Set -through #idle_timeout. - -Reducing this value may help avoid the "too many connection resets" error when -sending non-idempotent requests while increasing this value will cause fewer -round-trips. - -### Read Timeout - -The amount of time allowed between reading two chunks from the socket. Set -through #read_timeout - -### Max Requests - -The number of requests that should be made before opening a new connection. -Typically many keep-alive capable servers tune this to 100 or less, so the -101st request will fail with ECONNRESET. If unset (default), this value has no -effect, if set, connections will be reset on the request after max_requests. - -### Open Timeout - -The amount of time to wait for a connection to be opened. Set through -#open_timeout. - -### Socket Options - -Socket options may be set on newly-created connections. See #socket_options -for details. - -### Connection Termination - -If you are done using the Gem::Net::HTTP::Persistent instance you may shut -down all the connections in the current thread with #shutdown. This is not -recommended for normal use, it should only be used when it will be several -minutes before you make another HTTP request. - -If you are using multiple threads, call #shutdown in each thread when the -thread is done making requests. If you don't call shutdown, that's OK. Ruby -will automatically garbage collect and shutdown your HTTP connections when the -thread terminates. - - -# Class Methods -## detect_idle_timeout(uri , max 10) [](#method-c-detect_idle_timeout) -Use this method to detect the idle timeout of the host at `uri`. The value -returned can be used to configure #idle_timeout. `max` controls the maximum -idle timeout to detect. - -After - -Idle timeout detection is performed by creating a connection then performing a -HEAD request in a loop until the connection terminates waiting one additional -second per loop. - -NOTE: This may not work on ruby > 1.9. -# Attributes -## ca_file[RW] [](#attribute-i-ca_file) -An SSL certificate authority. Setting this will set verify_mode to -VERIFY_PEER. - -## ca_path[RW] [](#attribute-i-ca_path) -A directory of SSL certificates to be used as certificate authorities. Setting -this will set verify_mode to VERIFY_PEER. - -## cert_store[RW] [](#attribute-i-cert_store) -An SSL certificate store. Setting this will override the default certificate -store. See verify_mode for more information. - -## certificate[RW] [](#attribute-i-certificate) -This client's OpenSSL::X509::Certificate - -## ciphers[RW] [](#attribute-i-ciphers) -The ciphers allowed for SSL connections - -## debug_output[RW] [](#attribute-i-debug_output) -Sends debug_output to this IO via Gem::Net::HTTP#set_debug_output. - -Never use this method in production code, it causes a serious security hole. - -## generation[RW] [](#attribute-i-generation) -Current connection generation - -## headers[RW] [](#attribute-i-headers) -Headers that are added to every request using Gem::Net::HTTP#add_field - -## http_versions[RW] [](#attribute-i-http_versions) -Maps host:port to an HTTP version. This allows us to enable version specific -features. - -## idle_timeout[RW] [](#attribute-i-idle_timeout) -Maximum time an unused connection can remain idle before being automatically -closed. - -## keep_alive[RW] [](#attribute-i-keep_alive) -The value sent in the Keep-Alive header. Defaults to 30. Not needed for -HTTP/1.1 servers. - -This may not work correctly for HTTP/1.0 servers - -This method may be removed in a future version as RFC 2616 does not require -this header. - -## max_requests[RW] [](#attribute-i-max_requests) -Maximum number of requests on a connection before it is considered expired and -automatically closed. - -## max_retries[RW] [](#attribute-i-max_retries) -Number of retries to perform if a request fails. - -See also #max_retries=, Gem::Net::HTTP#max_retries=. - -## max_version[RW] [](#attribute-i-max_version) -Maximum SSL version to use, e.g. :TLS1_2 - -By default, the version will be negotiated automatically between client and -server. Ruby 2.5 and newer only. - -## min_version[RW] [](#attribute-i-min_version) -Minimum SSL version to use, e.g. :TLS1_1 - -By default, the version will be negotiated automatically between client and -server. Ruby 2.5 and newer only. - -## name[RW] [](#attribute-i-name) -The name for this collection of persistent connections. - -## no_proxy[RW] [](#attribute-i-no_proxy) -List of host suffixes which will not be proxied - -## open_timeout[RW] [](#attribute-i-open_timeout) -Seconds to wait until a connection is opened. See Gem::Net::HTTP#open_timeout - -## override_headers[RW] [](#attribute-i-override_headers) -Headers that are added to every request using Gem::Net::HTTP#[]= - -## pool[RW] [](#attribute-i-pool) -Test-only accessor for the connection pool - -## private_key[RW] [](#attribute-i-private_key) -This client's SSL private key - -## proxy_uri[RW] [](#attribute-i-proxy_uri) -The URL through which requests will be proxied - -## read_timeout[RW] [](#attribute-i-read_timeout) -Seconds to wait until reading one block. See Gem::Net::HTTP#read_timeout - -## reuse_ssl_sessions[RW] [](#attribute-i-reuse_ssl_sessions) -By default SSL sessions are reused to avoid extra SSL handshakes. Set this to -false if you have problems communicating with an HTTPS server like: - - SSL_connect [...] read finished A: unexpected message (OpenSSL::SSL::SSLError) - -## socket_options[RW] [](#attribute-i-socket_options) -An array of options for Socket#setsockopt. - -By default the TCP_NODELAY option is set on sockets. - -To set additional options append them to this array: - - http.socket_options << [Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1] - -## ssl_generation[RW] [](#attribute-i-ssl_generation) -Current SSL connection generation - -## ssl_timeout[RW] [](#attribute-i-ssl_timeout) -SSL session lifetime - -## ssl_version[RW] [](#attribute-i-ssl_version) -SSL version to use. - -By default, the version will be negotiated automatically between client and -server. Ruby 1.9 and newer only. Deprecated since Ruby 2.5. - -## timeout_key[RW] [](#attribute-i-timeout_key) -Where this instance's last-use times live in the thread local variables - -## verify_callback[RW] [](#attribute-i-verify_callback) -SSL verification callback. Used when ca_file or ca_path is set. - -## verify_depth[RW] [](#attribute-i-verify_depth) -Sets the depth of SSL certificate verification - -## verify_hostname[RW] [](#attribute-i-verify_hostname) -HTTPS verify_hostname. - -If a client sets this to true and enables SNI with SSLSocket#hostname=, the -hostname verification on the server certificate is performed automatically -during the handshake using OpenSSL::SSL.verify_certificate_identity(). - -You can set `verify_hostname` as true to use hostname verification during the -handshake. - -NOTE: This works with Ruby > 3.0. - -## verify_mode[RW] [](#attribute-i-verify_mode) -HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER which verifies the -server certificate. - -If no ca_file, ca_path or cert_store is set the default system certificate -store is used. - -You can use `verify_mode` to override any default values. - -## write_timeout[RW] [](#attribute-i-write_timeout) -Seconds to wait until writing one block. See Gem::Net::HTTP#write_timeout - - -#Instance Methods -## connection_for(uri) [](#method-i-connection_for) -Creates a new connection for `uri` - -## escape(str) [](#method-i-escape) -CGI::escape wrapper - -## expired?(connection) [](#method-i-expired?) -Returns true if the connection should be reset due to an idle timeout, or -maximum request count, false otherwise. - -**@return** [Boolean] - -## finish(connection) [](#method-i-finish) -Finishes the Gem::Net::HTTP `connection` - -## http_version(uri) [](#method-i-http_version) -Returns the HTTP protocol version for `uri` - -## initialize(name:nil, proxy:nil, pool_size:DEFAULT_POOL_SIZE) [](#method-i-initialize) -Creates a new Gem::Net::HTTP::Persistent. - -Set a `name` for fun. Your library name should be good enough, but this -otherwise has no purpose. - -`proxy` may be set to a Gem::URI::HTTP or :ENV to pick up proxy options from -the environment. See proxy_from_env for details. - -In order to use a Gem::URI for the proxy you may need to do some extra work -beyond Gem::URI parsing if the proxy requires a password: - - proxy = Gem::URI 'http://proxy.example' - proxy.user = 'AzureDiamond' - proxy.password = 'hunter2' - -Set `pool_size` to limit the maximum number of connections allowed. Defaults -to 1/4 the number of allowed file handles or 256 if your OS does not support a -limit on allowed file handles. You can have no more than this many threads -with active HTTP transactions. - -**@return** [Persistent] a new instance of Persistent - -## normalize_uri(uri) [](#method-i-normalize_uri) -Adds "http://" to the String `uri` if it is missing. - -## proxy=(proxy) [](#method-i-proxy=) -Sets the proxy server. The `proxy` may be the Gem::URI of the proxy server, -the symbol `:ENV` which will read the proxy from the environment or nil to -disable use of a proxy. See #proxy_from_env for details on setting the proxy -from the environment. - -If the proxy Gem::URI is set after requests have been made, the next request -will shut-down and re-open all connections. - -The `no_proxy` query parameter can be used to specify hosts which shouldn't be -reached via proxy; if set it should be a comma separated list of hostname -suffixes, optionally with `:port` appended, for example -`example.com,some.host:8080`. - -## proxy_bypass?(host, port) [](#method-i-proxy_bypass?) -Returns true when proxy should by bypassed for host. - -**@return** [Boolean] - -## proxy_from_env() [](#method-i-proxy_from_env) -Creates a Gem::URI for an HTTP proxy server from ENV variables. - -If `HTTP_PROXY` is set a proxy will be returned. - -If `HTTP_PROXY_USER` or `HTTP_PROXY_PASS` are set the Gem::URI is given the -indicated user and password unless HTTP_PROXY contains either of these in the -Gem::URI. - -The `NO_PROXY` ENV variable can be used to specify hosts which shouldn't be -reached via proxy; if set it should be a comma separated list of hostname -suffixes, optionally with `:port` appended, for example -`example.com,some.host:8080`. When set to `*` no proxy will be returned. - -For Windows users, lowercase ENV variables are preferred over uppercase ENV -variables. - -## reconnect() [](#method-i-reconnect) -Forces reconnection of all HTTP connections, including TLS/SSL connections. - -## reconnect_ssl() [](#method-i-reconnect_ssl) -Forces reconnection of only TLS/SSL connections. - -## request(uri, reqnil, &block) [](#method-i-request) -Makes a request on `uri`. If `req` is nil a Gem::Net::HTTP::Get is performed -against `uri`. - -If a block is passed #request behaves like Gem::Net::HTTP#request (the body of -the response will not have been read). - -`req` must be a Gem::Net::HTTPGenericRequest subclass (see Gem::Net::HTTP for -a list). - -## request_setup(req_or_uri) [](#method-i-request_setup) -Creates a GET request if `req_or_uri` is a Gem::URI and adds headers to the -request. - -Returns the request. - -## reset(connection) [](#method-i-reset) -Finishes then restarts the Gem::Net::HTTP `connection` - -## shutdown() [](#method-i-shutdown) -Shuts down all connections - -**NOTE**: Calling shutdown for can be dangerous! - -If any thread is still using a connection it may cause an error! Call -#shutdown when you are completely done making requests! - -## ssl(connection) [](#method-i-ssl) -Enables SSL on `connection` - -## start(http) [](#method-i-start) -Starts the Gem::Net::HTTP `connection` - -## unescape(str) [](#method-i-unescape) -CGI::unescape wrapper - diff --git a/example/ruby/Gem/Net/HTTP/Persistent/Connection.md b/example/ruby/Gem/Net/HTTP/Persistent/Connection.md deleted file mode 100644 index c770d63..0000000 --- a/example/ruby/Gem/Net/HTTP/Persistent/Connection.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Gem::Net::HTTP::Persistent::Connection -**Inherits:** Object - - -A Gem::Net::HTTP connection wrapper that holds extra information for managing -the connection's lifetime. - - -# Attributes -## http[RW] [](#attribute-i-http) -:nodoc: - -## last_use[RW] [](#attribute-i-last_use) -Returns the value of attribute last_use. - -## requests[RW] [](#attribute-i-requests) -Returns the value of attribute requests. - -## ssl_generation[RW] [](#attribute-i-ssl_generation) -Returns the value of attribute ssl_generation. - - -#Instance Methods -## finish() [](#method-i-finish) - -## initialize(http_class, http_args, ssl_generation) [](#method-i-initialize) - -**@return** [Connection] a new instance of Connection - -## reset() [](#method-i-reset) - -## ressl(ssl_generation) [](#method-i-ressl) - diff --git a/example/ruby/Gem/Net/HTTP/Persistent/Error.md b/example/ruby/Gem/Net/HTTP/Persistent/Error.md deleted file mode 100644 index 0e57100..0000000 --- a/example/ruby/Gem/Net/HTTP/Persistent/Error.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Gem::Net::HTTP::Persistent::Error -**Inherits:** StandardError - - -Error class for errors raised by Gem::Net::HTTP::Persistent. Various -SystemCallErrors are re-raised with a human-readable message under this class. - - - diff --git a/example/ruby/Gem/Net/HTTP/Persistent/Pool.md b/example/ruby/Gem/Net/HTTP/Persistent/Pool.md deleted file mode 100644 index 15c6a94..0000000 --- a/example/ruby/Gem/Net/HTTP/Persistent/Pool.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Gem::Net::HTTP::Persistent::Pool -**Inherits:** Bundler::ConnectionPool - - -:nodoc: - - -# Attributes -## available[RW] [](#attribute-i-available) -:nodoc: - -## key[RW] [](#attribute-i-key) -:nodoc: - - -#Instance Methods -## checkin(net_http_args) [](#method-i-checkin) - -## checkout(net_http_args) [](#method-i-checkout) - -## initialize(options{}, &block) [](#method-i-initialize) - -**@return** [Pool] a new instance of Pool - -## shutdown() [](#method-i-shutdown) - diff --git a/example/ruby/Gem/Net/HTTP/Persistent/TimedStackMulti.md b/example/ruby/Gem/Net/HTTP/Persistent/TimedStackMulti.md deleted file mode 100644 index 7be89ed..0000000 --- a/example/ruby/Gem/Net/HTTP/Persistent/TimedStackMulti.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Gem::Net::HTTP::Persistent::TimedStackMulti -**Inherits:** Bundler::ConnectionPool::TimedStack - - -:nodoc: - - -# Class Methods -## hash_of_arrays() [](#method-c-hash_of_arrays) -Returns a new hash that has arrays for keys - -Using a class method to limit the bindings referenced by the hash's -default_proc - -#Instance Methods -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## initialize(size0, &block) [](#method-i-initialize) - -**@return** [TimedStackMulti] a new instance of TimedStackMulti - -## length() [](#method-i-length) - diff --git a/example/ruby/Gem/Net/HTTP/Post.md b/example/ruby/Gem/Net/HTTP/Post.md deleted file mode 100644 index 42b2c41..0000000 --- a/example/ruby/Gem/Net/HTTP/Post.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Gem::Net::HTTP::Post -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [HTTP method -POST](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#P -OST_method): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - uri.path = '/posts' - req = Gem::Net::HTTP::Post.new(uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_type = 'application/json' - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: yes. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): no. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): no. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): yes. - -Related: - -* Gem::Net::HTTP.post: sends `POST` request, returns response object. -* Gem::Net::HTTP#post: sends `POST` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Propfind.md b/example/ruby/Gem/Net/HTTP/Propfind.md deleted file mode 100644 index de27f4e..0000000 --- a/example/ruby/Gem/Net/HTTP/Propfind.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Net::HTTP::Propfind -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [WebDAV method -PROPFIND](http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Propfind.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Related: - -* Gem::Net::HTTP#propfind: sends `PROPFIND` request, returns response - object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Proppatch.md b/example/ruby/Gem/Net/HTTP/Proppatch.md deleted file mode 100644 index 66f8149..0000000 --- a/example/ruby/Gem/Net/HTTP/Proppatch.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Net::HTTP::Proppatch -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [WebDAV method -PROPPATCH](http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Proppatch.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Related: - -* Gem::Net::HTTP#proppatch: sends `PROPPATCH` request, returns response - object. - - - diff --git a/example/ruby/Gem/Net/HTTP/ProxyDelta.md b/example/ruby/Gem/Net/HTTP/ProxyDelta.md deleted file mode 100644 index eeddbe6..0000000 --- a/example/ruby/Gem/Net/HTTP/ProxyDelta.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Net::HTTP::ProxyDelta - - -:nodoc: internal use only - - - diff --git a/example/ruby/Gem/Net/HTTP/Put.md b/example/ruby/Gem/Net/HTTP/Put.md deleted file mode 100644 index 59caad8..0000000 --- a/example/ruby/Gem/Net/HTTP/Put.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Gem::Net::HTTP::Put -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [HTTP method -PUT](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#PU -T_method): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - uri.path = '/posts' - req = Gem::Net::HTTP::Put.new(uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_type = 'application/json' - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: yes. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): no. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Gem::Net::HTTP.put: sends `PUT` request, returns response object. -* Gem::Net::HTTP#put: sends `PUT` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Trace.md b/example/ruby/Gem/Net/HTTP/Trace.md deleted file mode 100644 index a91f8a6..0000000 --- a/example/ruby/Gem/Net/HTTP/Trace.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Gem::Net::HTTP::Trace -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [HTTP method -TRACE](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol# -TRACE_method): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Trace.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: no. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): yes. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Gem::Net::HTTP#trace: sends `TRACE` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTP/Unlock.md b/example/ruby/Gem/Net/HTTP/Unlock.md deleted file mode 100644 index ae0d03b..0000000 --- a/example/ruby/Gem/Net/HTTP/Unlock.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Net::HTTP::Unlock -**Inherits:** Gem::Net::HTTPRequest - - -Class for representing [WebDAV method -UNLOCK](http://www.webdav.org/specs/rfc4918.html#METHOD_UNLOCK): - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Gem::Net::HTTP::Unlock.new(uri) # => # - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Gem::Net::HTTPRequest@Request+Headers). - -Related: - -* Gem::Net::HTTP#unlock: sends `UNLOCK` request, returns response object. - - - diff --git a/example/ruby/Gem/Net/HTTPAccepted.md b/example/ruby/Gem/Net/HTTPAccepted.md deleted file mode 100644 index e516140..0000000 --- a/example/ruby/Gem/Net/HTTPAccepted.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPAccepted -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `Accepted` responses (status code 202). - -The `Accepted` response indicates that the server has received and is -processing a request, but the processing has not yet been completed. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-202-accepted). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202). - - - diff --git a/example/ruby/Gem/Net/HTTPAlreadyReported.md b/example/ruby/Gem/Net/HTTPAlreadyReported.md deleted file mode 100644 index 06eb939..0000000 --- a/example/ruby/Gem/Net/HTTPAlreadyReported.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPAlreadyReported -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `Already Reported (WebDAV)` responses (status code 208). - -The `Already Reported (WebDAV)` response indicates that the server has -received the request, and that the members of a DAV binding have already been -enumerated in a preceding part of the (multi-status) response, and are not -being included again. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 5842](https://www.rfc-editor.org/rfc/rfc5842.html#section-7.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208). - - - diff --git a/example/ruby/Gem/Net/HTTPBadGateway.md b/example/ruby/Gem/Net/HTTPBadGateway.md deleted file mode 100644 index 2ba5e0d..0000000 --- a/example/ruby/Gem/Net/HTTPBadGateway.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPBadGateway -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Bad Gateway` responses (status code 502). - -The server was acting as a gateway or proxy and received an invalid response -from the upstream server. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-502-bad-gateway). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502). - - - diff --git a/example/ruby/Gem/Net/HTTPBadRequest.md b/example/ruby/Gem/Net/HTTPBadRequest.md deleted file mode 100644 index 616ec55..0000000 --- a/example/ruby/Gem/Net/HTTPBadRequest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPBadRequest -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Bad Request` responses (status code 400). - -The server cannot or will not process the request due to an apparent client -error. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-400-bad-request). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400). - - - diff --git a/example/ruby/Gem/Net/HTTPBadResponse.md b/example/ruby/Gem/Net/HTTPBadResponse.md deleted file mode 100644 index fe00080..0000000 --- a/example/ruby/Gem/Net/HTTPBadResponse.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Net::HTTPBadResponse -**Inherits:** StandardError - - -:stopdoc: - - - diff --git a/example/ruby/Gem/Net/HTTPClientError.md b/example/ruby/Gem/Net/HTTPClientError.md deleted file mode 100644 index 2ede790..0000000 --- a/example/ruby/Gem/Net/HTTPClientError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::Net::HTTPClientError -**Inherits:** Gem::Net::HTTPResponse - - -Parent class for client error (4xx) HTTP response classes. - -A client error response indicates that the client may have caused an error. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.4xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_cl - ient_errors). - - - diff --git a/example/ruby/Gem/Net/HTTPClientException.md b/example/ruby/Gem/Net/HTTPClientException.md deleted file mode 100644 index 0d97afa..0000000 --- a/example/ruby/Gem/Net/HTTPClientException.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Gem::Net::HTTPClientException -**Inherits:** Gem::Net::ProtoServerError - -**Includes:** Gem::Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Gem/Net/HTTPConflict.md b/example/ruby/Gem/Net/HTTPConflict.md deleted file mode 100644 index 3094940..0000000 --- a/example/ruby/Gem/Net/HTTPConflict.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPConflict -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Conflict` responses (status code 409). - -The request could not be processed because of conflict in the current state of -the resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-409-conflict). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409). - - - diff --git a/example/ruby/Gem/Net/HTTPContinue.md b/example/ruby/Gem/Net/HTTPContinue.md deleted file mode 100644 index 74fb067..0000000 --- a/example/ruby/Gem/Net/HTTPContinue.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPContinue -**Inherits:** Gem::Net::HTTPInformation - - -Response class for `Continue` responses (status code 100). - -A `Continue` response indicates that the server has received the request -headers. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-100-continue). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100). - - - diff --git a/example/ruby/Gem/Net/HTTPCreated.md b/example/ruby/Gem/Net/HTTPCreated.md deleted file mode 100644 index c243a93..0000000 --- a/example/ruby/Gem/Net/HTTPCreated.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPCreated -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `Created` responses (status code 201). - -The `Created` response indicates that the server has received and has -fulfilled a request to create a new resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-201-created). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201). - - - diff --git a/example/ruby/Gem/Net/HTTPEarlyHints.md b/example/ruby/Gem/Net/HTTPEarlyHints.md deleted file mode 100644 index b9ae638..0000000 --- a/example/ruby/Gem/Net/HTTPEarlyHints.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPEarlyHints -**Inherits:** Gem::Net::HTTPInformation - - -Response class for `Early Hints` responses (status code 103). - -The `Early Hints` indicates that the server has received and is processing the -request, and contains certain headers; the final response is not available -yet. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103). -* [RFC 8297](https://www.rfc-editor.org/rfc/rfc8297.html#section-2). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103). - - - diff --git a/example/ruby/Gem/Net/HTTPError.md b/example/ruby/Gem/Net/HTTPError.md deleted file mode 100644 index 0c02f8e..0000000 --- a/example/ruby/Gem/Net/HTTPError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Gem::Net::HTTPError -**Inherits:** Gem::Net::ProtocolError - -**Includes:** Gem::Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Gem/Net/HTTPExceptions.md b/example/ruby/Gem/Net/HTTPExceptions.md deleted file mode 100644 index 8f398b2..0000000 --- a/example/ruby/Gem/Net/HTTPExceptions.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: Gem::Net::HTTPExceptions - - -Gem::Net::HTTP exception class. You cannot use Gem::Net::HTTPExceptions -directly; instead, you must use its subclasses. - - -# Attributes -## response[RW] [](#attribute-i-response) -Returns the value of attribute response. - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Gem/Net/HTTPExpectationFailed.md b/example/ruby/Gem/Net/HTTPExpectationFailed.md deleted file mode 100644 index 6c38f6b..0000000 --- a/example/ruby/Gem/Net/HTTPExpectationFailed.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPExpectationFailed -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Expectation Failed` responses (status code 417). - -The server cannot meet the requirements of the Expect request-header field. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-417-expectation-fai - led). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417). - - - diff --git a/example/ruby/Gem/Net/HTTPFailedDependency.md b/example/ruby/Gem/Net/HTTPFailedDependency.md deleted file mode 100644 index 8c292e3..0000000 --- a/example/ruby/Gem/Net/HTTPFailedDependency.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPFailedDependency -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Failed Dependency (WebDAV)` responses (status code 424). - -The request failed because it depended on another request and that request -failed. See [424 Failed Dependency -(WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424). - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.4). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424). - - - diff --git a/example/ruby/Gem/Net/HTTPFatalError.md b/example/ruby/Gem/Net/HTTPFatalError.md deleted file mode 100644 index 5dfdff4..0000000 --- a/example/ruby/Gem/Net/HTTPFatalError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Gem::Net::HTTPFatalError -**Inherits:** Gem::Net::ProtoFatalError - -**Includes:** Gem::Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Gem/Net/HTTPForbidden.md b/example/ruby/Gem/Net/HTTPForbidden.md deleted file mode 100644 index 10312c8..0000000 --- a/example/ruby/Gem/Net/HTTPForbidden.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPForbidden -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Forbidden` responses (status code 403). - -The request contained valid data and was understood by the server, but the -server is refusing action. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-403-forbidden). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403). - - - diff --git a/example/ruby/Gem/Net/HTTPFound.md b/example/ruby/Gem/Net/HTTPFound.md deleted file mode 100644 index b819f66..0000000 --- a/example/ruby/Gem/Net/HTTPFound.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPFound -**Inherits:** Gem::Net::HTTPRedirection - - -Response class for `Found` responses (status code 302). - -The `Found` response indicates that the client should look at (browse to) -another URL. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-302-found). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302). - - - diff --git a/example/ruby/Gem/Net/HTTPGatewayTimeout.md b/example/ruby/Gem/Net/HTTPGatewayTimeout.md deleted file mode 100644 index 145093c..0000000 --- a/example/ruby/Gem/Net/HTTPGatewayTimeout.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPGatewayTimeout -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Gateway Gem::Timeout` responses (status code 504). - -The server was acting as a gateway or proxy and did not receive a timely -response from the upstream server. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-504-gateway-timeout - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504). - - - diff --git a/example/ruby/Gem/Net/HTTPGenericRequest.md b/example/ruby/Gem/Net/HTTPGenericRequest.md deleted file mode 100644 index 07a42a1..0000000 --- a/example/ruby/Gem/Net/HTTPGenericRequest.md +++ /dev/null @@ -1,615 +0,0 @@ -# Class: Gem::Net::HTTPGenericRequest -**Inherits:** Object - -**Includes:** Gem::Net::HTTPHeader - - -HTTPGenericRequest is the parent of the Gem::Net::HTTPRequest class. - -Do not use this directly; instead, use a subclass of Gem::Net::HTTPRequest. - -## About the Examples - -:include: doc/net-http/examples.rdoc - - -# Attributes -## body[RW] [](#attribute-i-body) -Returns the string body for the request, or `nil` if there is none: - - req = Gem::Net::HTTP::Post.new(uri) - req.body # => nil - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}" - -## body_stream[RW] [](#attribute-i-body_stream) -Returns the body stream object for the request, or `nil` if there is none: - - req = Gem::Net::HTTP::Post.new(uri) # => # - req.body_stream # => nil - require 'stringio' - req.body_stream = StringIO.new('xyzzy') # => # - req.body_stream # => # - -## decode_content[RW] [](#attribute-i-decode_content) -Returns `false` if the request's header `'Accept-Encoding'` has been set -manually or deleted (indicating that the user intends to handle encoding in -the response), `true` otherwise: - - req = Gem::Net::HTTP::Get.new(uri) # => # - req['Accept-Encoding'] # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" - req.decode_content # => true - req['Accept-Encoding'] = 'foo' - req.decode_content # => false - req.delete('Accept-Encoding') - req.decode_content # => false - -## method[RW] [](#attribute-i-method) -Returns the string method name for the request: - - Gem::Net::HTTP::Get.new(uri).method # => "GET" - Gem::Net::HTTP::Post.new(uri).method # => "POST" - -## path[RW] [](#attribute-i-path) -Returns the string path for the request: - - Gem::Net::HTTP::Get.new(uri).path # => "/" - Gem::Net::HTTP::Post.new('example.com').path # => "example.com" - -## uri[RW] [](#attribute-i-uri) -Returns the Gem::URI object for the request, or `nil` if none: - - Gem::Net::HTTP::Get.new(uri).uri - # => # - Gem::Net::HTTP::Get.new('example.com').uri # => nil - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Gem::Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Don't automatically decode response content-encoding if the user indicates -they want to handle it. - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - req = Gem::Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## body_exist?() [](#method-i-body_exist?) -:nodoc: - -**@return** [Boolean] - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Gem::Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Gem::Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Gem::Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Gem::Net::HTTPHeader#canonical_each is an alias for -Gem::Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](https://docs.ruby-lang.org/en/master/case_mapping_rdoc.html). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Gem::Net::HTTPHeader#each is an alias for Gem::Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Gem::Net::HTTPHeader#each_name is an alias for Gem::Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## exec(sock, ver, path) [](#method-i-exec) -write - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## initialize(m, reqbody, resbody, uri_or_path, initheadernil) [](#method-i-initialize) -:nodoc: - -**@return** [HTTPGenericRequest] a new instance of HTTPGenericRequest - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a string representation of the request: - - Gem::Net::HTTP::Post.new(uri).inspect # => "#" - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Gem::Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Gem::Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## request_body_permitted?() [](#method-i-request_body_permitted?) -Returns whether the request may have a body: - - Gem::Net::HTTP::Post.new(uri).request_body_permitted? # => true - Gem::Net::HTTP::Get.new(uri).request_body_permitted? # => false - -**@return** [Boolean] - -## response_body_permitted?() [](#method-i-response_body_permitted?) -Returns whether the response may have a body: - - Gem::Net::HTTP::Post.new(uri).response_body_permitted? # => true - Gem::Net::HTTP::Head.new(uri).response_body_permitted? # => false - -**@return** [Boolean] - -## set_body_internal(str) [](#method-i-set_body_internal) -:nodoc: internal use only - -**@raise** [ArgumentError] - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Gem::Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Gem::Net::HTTPHeader#content_type= is an alias for -Gem::Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enume -rable-label-Enumerable+in+Ruby+Classes) (method `params.map` will be called), -and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Gem::Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[Gem::URI.encode_www_form](https://docs.ruby-lang.org/en/master/Gem::URI.html# -method-c-encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Gem::Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Gem::Net::HTTPHeader#form_data= is an alias for -Gem::Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Gem::Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Gem::Net::HTTPHeader#range= is an alias for Gem::Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Gem::Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - -## update_uri(addr, port, ssl) [](#method-i-update_uri) -:nodoc: internal use only - diff --git a/example/ruby/Gem/Net/HTTPGenericRequest/Chunker.md b/example/ruby/Gem/Net/HTTPGenericRequest/Chunker.md deleted file mode 100644 index ccd7945..0000000 --- a/example/ruby/Gem/Net/HTTPGenericRequest/Chunker.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Net::HTTPGenericRequest::Chunker -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## finish() [](#method-i-finish) - -## initialize(sock) [](#method-i-initialize) - -**@return** [Chunker] a new instance of Chunker - -## write(buf) [](#method-i-write) - diff --git a/example/ruby/Gem/Net/HTTPGone.md b/example/ruby/Gem/Net/HTTPGone.md deleted file mode 100644 index 015c9ce..0000000 --- a/example/ruby/Gem/Net/HTTPGone.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPGone -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Gone` responses (status code 410). - -The resource requested was previously in use but is no longer available and -will not be available again. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-410-gone). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410). - - - diff --git a/example/ruby/Gem/Net/HTTPHeader.md b/example/ruby/Gem/Net/HTTPHeader.md deleted file mode 100644 index b6e6124..0000000 --- a/example/ruby/Gem/Net/HTTPHeader.md +++ /dev/null @@ -1,706 +0,0 @@ -# Module: Gem::Net::HTTPHeader - - -The HTTPHeader module provides access to HTTP headers. - -The module is included in: - -* Gem::Net::HTTPGenericRequest (and therefore Gem::Net::HTTPRequest). -* Gem::Net::HTTPResponse. - -The headers are a hash-like collection of key/value pairs called *fields*. - -## Request and Response Fields - -Headers may be included in: - -* A Gem::Net::HTTPRequest object: the object's headers will be sent with the - request. Any fields may be defined in the request; see - [Setters](rdoc-ref:Gem::Net::HTTPHeader@Setters). -* A Gem::Net::HTTPResponse object: the objects headers are usually those - returned from the host. Fields may be retrieved from the object; see - [Getters](rdoc-ref:Gem::Net::HTTPHeader@Getters) and - [Iterators](rdoc-ref:Gem::Net::HTTPHeader@Iterators). - -Exactly which fields should be sent or expected depends on the host; see: - -* [Request - fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_f - ields). -* [Response - fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_ - fields). - -## About the Examples - -:include: doc/net-http/examples.rdoc - -## Fields - -A header field is a key/value pair. - -### Field Keys - -A field key may be: - -* A string: Key `'Accept'` is treated as if it were `'Accept'.downcase`; - i.e., `'accept'`. -* A symbol: Key `:Accept` is treated as if it were `:Accept.to_s.downcase`; - i.e., `'accept'`. - -Examples: - - req = Gem::Net::HTTP::Get.new(uri) - req[:accept] # => "*/*" - req['Accept'] # => "*/*" - req['ACCEPT'] # => "*/*" - - req['accept'] = 'text/html' - req[:accept] = 'text/html' - req['ACCEPT'] = 'text/html' - -### Field Values - -A field value may be returned as an array of strings or as a string: - -* These methods return field values as arrays: - - * #get_fields: Returns the array value for the given key, or `nil` if it - does not exist. - * #to_hash: Returns a hash of all header fields: each key is a field - name; its value is the array value for the field. - -* These methods return field values as string; the string value for a field - is equivalent to `self[key.downcase.to_s].join(', '))`: - - * #[]: Returns the string value for the given key, or `nil` if it does - not exist. - * #fetch: Like #[], but accepts a default value to be returned if the - key does not exist. - -The field value may be set: - -* #[]=: Sets the value for the given key; the given value may be a string, a - symbol, an array, or a hash. -* #add_field: Adds a given value to a value for the given key (not - overwriting the existing value). -* #delete: Deletes the field for the given key. - -Example field values: - -* String: - - req['Accept'] = 'text/html' # => "text/html" - req['Accept'] # => "text/html" - req.get_fields('Accept') # => ["text/html"] - -* Symbol: - - req['Accept'] = :text # => :text - req['Accept'] # => "text" - req.get_fields('Accept') # => ["text"] - -* Simple array: - - req[:foo] = %w[bar baz bat] - req[:foo] # => "bar, baz, bat" - req.get_fields(:foo) # => ["bar", "baz", "bat"] - -* Simple hash: - - req[:foo] = {bar: 0, baz: 1, bat: 2} - req[:foo] # => "bar, 0, baz, 1, bat, 2" - req.get_fields(:foo) # => ["bar", "0", "baz", "1", "bat", "2"] - -* Nested: - - req[:foo] = [%w[bar baz], {bat: 0, bam: 1}] - req[:foo] # => "bar, baz, bat, 0, bam, 1" - req.get_fields(:foo) # => ["bar", "baz", "bat", "0", "bam", "1"] - - req[:foo] = {bar: %w[baz bat], bam: {bah: 0, bad: 1}} - req[:foo] # => "bar, baz, bat, bam, bah, 0, bad, 1" - req.get_fields(:foo) # => ["bar", "baz", "bat", "bam", "bah", "0", "bad", "1"] - -## Convenience Methods - -Various convenience methods retrieve values, set values, query values, set -form values, or iterate over fields. - -### Setters - -Method #[]= can set any field, but does little to validate the new value; some -of the other setter methods provide some validation: - -* #[]=: Sets the string or array value for the given key. -* #add_field: Creates or adds to the array value for the given key. -* #basic_auth: Sets the string authorization header for `'Authorization'`. -* #content_length=: Sets the integer length for field `'Content-Length`. -* #content_type=: Sets the string value for field `'Content-Type'`. -* #proxy_basic_auth: Sets the string authorization header for - `'Proxy-Authorization'`. -* #set_range: Sets the value for field `'Range'`. - -### Form Setters - -* #set_form: Sets an HTML form data set. -* #set_form_data: Sets header fields and a body from HTML form data. - -### Getters - -Method #[] can retrieve the value of any field that exists, but always as a -string; some of the other getter methods return something different from the -simple string value: - -* #[]: Returns the string field value for the given key. -* #content_length: Returns the integer value of field `'Content-Length'`. -* #content_range: Returns the Range value of field `'Content-Range'`. -* #content_type: Returns the string value of field `'Content-Type'`. -* #fetch: Returns the string field value for the given key. -* #get_fields: Returns the array field value for the given `key`. -* #main_type: Returns first part of the string value of field - `'Content-Type'`. -* #sub_type: Returns second part of the string value of field - `'Content-Type'`. -* #range: Returns an array of Range objects of field `'Range'`, or `nil`. -* #range_length: Returns the integer length of the range given in field - `'Content-Range'`. -* #type_params: Returns the string parameters for `'Content-Type'`. - -### Queries - -* #chunked?: Returns whether field `'Transfer-Encoding'` is set to - `'chunked'`. -* #connection_close?: Returns whether field `'Connection'` is set to - `'close'`. -* #connection_keep_alive?: Returns whether field `'Connection'` is set to - `'keep-alive'`. -* #key?: Returns whether a given key exists. - -### Iterators - -* #each_capitalized: Passes each field capitalized-name/value pair to the - block. -* #each_capitalized_name: Passes each capitalized field name to the block. -* #each_header: Passes each field name/value pair to the block. -* #each_name: Passes each field name to the block. -* #each_value: Passes each string field value to the block. - - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Gem::Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Sets the value for the case-insensitive `key` to `val`, overwriting the -previous value if the field exists; see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - req = Gem::Net::HTTP::Get.new(uri) - req['Accept'] # => "*/*" - req['Accept'] = 'text/html' - req['Accept'] # => "text/html" - -Note that some field values may be set via convenience methods; see -[Setters](rdoc-ref:Gem::Net::HTTPHeader@Setters). - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - req = Gem::Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Gem::Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Gem::Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Gem::Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Gem::Net::HTTPHeader#canonical_each is an alias for -Gem::Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](https://docs.ruby-lang.org/en/master/case_mapping_rdoc.html). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Gem::Net::HTTPHeader#each is an alias for Gem::Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Gem::Net::HTTPHeader#each_name is an alias for Gem::Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Gem::Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Gem::Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Gem::Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Gem::Net::HTTPHeader#content_type= is an alias for -Gem::Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enume -rable-label-Enumerable+in+Ruby+Classes) (method `params.map` will be called), -and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Gem::Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[Gem::URI.encode_www_form](https://docs.ruby-lang.org/en/master/Gem::URI.html# -method-c-encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Gem::Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Gem::Net::HTTPHeader#form_data= is an alias for -Gem::Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Gem::Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Gem::Net::HTTPHeader#range= is an alias for Gem::Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Gem::Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - diff --git a/example/ruby/Gem/Net/HTTPHeaderSyntaxError.md b/example/ruby/Gem/Net/HTTPHeaderSyntaxError.md deleted file mode 100644 index 1b77f90..0000000 --- a/example/ruby/Gem/Net/HTTPHeaderSyntaxError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::HTTPHeaderSyntaxError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Gem/Net/HTTPIMUsed.md b/example/ruby/Gem/Net/HTTPIMUsed.md deleted file mode 100644 index e5f48fa..0000000 --- a/example/ruby/Gem/Net/HTTPIMUsed.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPIMUsed -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `IM Used` responses (status code 226). - -The `IM Used` response indicates that the server has fulfilled a request for -the resource, and the response is a representation of the result of one or -more instance-manipulations applied to the current instance. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 3229](https://www.rfc-editor.org/rfc/rfc3229.html#section-10.4.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226). - - - diff --git a/example/ruby/Gem/Net/HTTPInformation.md b/example/ruby/Gem/Net/HTTPInformation.md deleted file mode 100644 index f991e69..0000000 --- a/example/ruby/Gem/Net/HTTPInformation.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Net::HTTPInformation -**Inherits:** Gem::Net::HTTPResponse - - -Parent class for informational (1xx) HTTP response classes. - -An informational response indicates that the request was received and -understood. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.1xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_in - formational_response). - - - diff --git a/example/ruby/Gem/Net/HTTPInsufficientStorage.md b/example/ruby/Gem/Net/HTTPInsufficientStorage.md deleted file mode 100644 index 3e48270..0000000 --- a/example/ruby/Gem/Net/HTTPInsufficientStorage.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPInsufficientStorage -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Insufficient Storage (WebDAV)` responses (status code -507). - -The server is unable to store the representation needed to complete the -request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507). -* [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.5). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507). - - - diff --git a/example/ruby/Gem/Net/HTTPInternalServerError.md b/example/ruby/Gem/Net/HTTPInternalServerError.md deleted file mode 100644 index be81294..0000000 --- a/example/ruby/Gem/Net/HTTPInternalServerError.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPInternalServerError -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Internal Server Error` responses (status code 500). - -An unexpected condition was encountered and no more specific message is -suitable. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-500-internal-server - -error). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500). - - - diff --git a/example/ruby/Gem/Net/HTTPLengthRequired.md b/example/ruby/Gem/Net/HTTPLengthRequired.md deleted file mode 100644 index e21aee7..0000000 --- a/example/ruby/Gem/Net/HTTPLengthRequired.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPLengthRequired -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Length Required` responses (status code 411). - -The request did not specify the length of its content, which is required by -the requested resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-411-length-required - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411). - - - diff --git a/example/ruby/Gem/Net/HTTPLocked.md b/example/ruby/Gem/Net/HTTPLocked.md deleted file mode 100644 index f43d770..0000000 --- a/example/ruby/Gem/Net/HTTPLocked.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Net::HTTPLocked -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Locked (WebDAV)` responses (status code 423). - -The requested resource is locked. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.3). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423). - - - diff --git a/example/ruby/Gem/Net/HTTPLoopDetected.md b/example/ruby/Gem/Net/HTTPLoopDetected.md deleted file mode 100644 index 72c78bb..0000000 --- a/example/ruby/Gem/Net/HTTPLoopDetected.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Gem::Net::HTTPLoopDetected -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Loop Detected (WebDAV)` responses (status code 508). - -The server detected an infinite loop while processing the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508). -* [RFC 5942](https://www.rfc-editor.org/rfc/rfc5842.html#section-7.2). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508). - - - diff --git a/example/ruby/Gem/Net/HTTPMethodNotAllowed.md b/example/ruby/Gem/Net/HTTPMethodNotAllowed.md deleted file mode 100644 index 01a489b..0000000 --- a/example/ruby/Gem/Net/HTTPMethodNotAllowed.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPMethodNotAllowed -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Method Not Allowed` responses (status code 405). - -The request method is not supported for the requested resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-405-method-not-allo - wed). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405). - - - diff --git a/example/ruby/Gem/Net/HTTPMisdirectedRequest.md b/example/ruby/Gem/Net/HTTPMisdirectedRequest.md deleted file mode 100644 index aca3d4d..0000000 --- a/example/ruby/Gem/Net/HTTPMisdirectedRequest.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPMisdirectedRequest -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Misdirected Request` responses (status code 421). - -The request was directed at a server that is not able to produce a response. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-421-misdirected-req - uest). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421). - - - diff --git a/example/ruby/Gem/Net/HTTPMovedPermanently.md b/example/ruby/Gem/Net/HTTPMovedPermanently.md deleted file mode 100644 index 7b8a796..0000000 --- a/example/ruby/Gem/Net/HTTPMovedPermanently.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPMovedPermanently -**Inherits:** Gem::Net::HTTPRedirection - - -Response class for `Moved Permanently` responses (status code 301). - -The `Moved Permanently` response indicates that links or records returning -this response should be updated to use the given URL. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-301-moved-permanent - ly). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301). - - - diff --git a/example/ruby/Gem/Net/HTTPMultiStatus.md b/example/ruby/Gem/Net/HTTPMultiStatus.md deleted file mode 100644 index e0dca89..0000000 --- a/example/ruby/Gem/Net/HTTPMultiStatus.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPMultiStatus -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `Multi-Status (WebDAV)` responses (status code 207). - -The `Multi-Status (WebDAV)` response indicates that the server has received -the request, and that the message body can contain a number of separate -response codes. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 4818](https://www.rfc-editor.org/rfc/rfc4918#section-11.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207). - - - diff --git a/example/ruby/Gem/Net/HTTPMultipleChoices.md b/example/ruby/Gem/Net/HTTPMultipleChoices.md deleted file mode 100644 index cc4025a..0000000 --- a/example/ruby/Gem/Net/HTTPMultipleChoices.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPMultipleChoices -**Inherits:** Gem::Net::HTTPRedirection - - -Response class for `Multiple Choices` responses (status code 300). - -The `Multiple Choices` response indicates that the server offers multiple -options for the resource from which the client may choose. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-300-multiple-choice - s). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300). - - - diff --git a/example/ruby/Gem/Net/HTTPNetworkAuthenticationRequired.md b/example/ruby/Gem/Net/HTTPNetworkAuthenticationRequired.md deleted file mode 100644 index dde1cd4..0000000 --- a/example/ruby/Gem/Net/HTTPNetworkAuthenticationRequired.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPNetworkAuthenticationRequired -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Network Authentication Required` responses (status code -511). - -The client needs to authenticate to gain network access. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511). -* [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-6). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511). - - - diff --git a/example/ruby/Gem/Net/HTTPNoContent.md b/example/ruby/Gem/Net/HTTPNoContent.md deleted file mode 100644 index 5daedbc..0000000 --- a/example/ruby/Gem/Net/HTTPNoContent.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPNoContent -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `No Content` responses (status code 204). - -The `No Content` response indicates that the server successfully processed the -request, and is not returning any content. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-204-no-content). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204). - - - diff --git a/example/ruby/Gem/Net/HTTPNonAuthoritativeInformation.md b/example/ruby/Gem/Net/HTTPNonAuthoritativeInformation.md deleted file mode 100644 index 2e885f7..0000000 --- a/example/ruby/Gem/Net/HTTPNonAuthoritativeInformation.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Net::HTTPNonAuthoritativeInformation -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `Non-Authoritative Information` responses (status code -203). - -The `Non-Authoritative Information` response indicates that the server is a -transforming proxy (such as a Web accelerator) that received a 200 OK response -from its origin, and is returning a modified version of the origin's response. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-203-non-authoritati - ve-infor). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203). - - - diff --git a/example/ruby/Gem/Net/HTTPNotAcceptable.md b/example/ruby/Gem/Net/HTTPNotAcceptable.md deleted file mode 100644 index cd57c41..0000000 --- a/example/ruby/Gem/Net/HTTPNotAcceptable.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPNotAcceptable -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Not Acceptable` responses (status code 406). - -The requested resource is capable of generating only content that not -acceptable according to the Accept headers sent in the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-406-not-acceptable) - . -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406). - - - diff --git a/example/ruby/Gem/Net/HTTPNotExtended.md b/example/ruby/Gem/Net/HTTPNotExtended.md deleted file mode 100644 index 5b28309..0000000 --- a/example/ruby/Gem/Net/HTTPNotExtended.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Gem::Net::HTTPNotExtended -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Not Extended` responses (status code 510). - -Further extensions to the request are required for the server to fulfill it. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510). -* [RFC 2774](https://www.rfc-editor.org/rfc/rfc2774.html#section-7). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510). - - - diff --git a/example/ruby/Gem/Net/HTTPNotFound.md b/example/ruby/Gem/Net/HTTPNotFound.md deleted file mode 100644 index e5c3569..0000000 --- a/example/ruby/Gem/Net/HTTPNotFound.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPNotFound -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Not Found` responses (status code 404). - -The requested resource could not be found but may be available in the future. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404). - - - diff --git a/example/ruby/Gem/Net/HTTPNotImplemented.md b/example/ruby/Gem/Net/HTTPNotImplemented.md deleted file mode 100644 index 6724f0c..0000000 --- a/example/ruby/Gem/Net/HTTPNotImplemented.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPNotImplemented -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Not Implemented` responses (status code 501). - -The server either does not recognize the request method, or it lacks the -ability to fulfil the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-501-not-implemented - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501). - - - diff --git a/example/ruby/Gem/Net/HTTPNotModified.md b/example/ruby/Gem/Net/HTTPNotModified.md deleted file mode 100644 index a6c7a71..0000000 --- a/example/ruby/Gem/Net/HTTPNotModified.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPNotModified -**Inherits:** Gem::Net::HTTPRedirection - - -Response class for `Not Modified` responses (status code 304). - -Indicates that the resource has not been modified since the version specified -by the request headers. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-304-not-modified). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304). - - - diff --git a/example/ruby/Gem/Net/HTTPOK.md b/example/ruby/Gem/Net/HTTPOK.md deleted file mode 100644 index 048857d..0000000 --- a/example/ruby/Gem/Net/HTTPOK.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPOK -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `OK` responses (status code 200). - -The `OK` response indicates that the server has received a request and has -responded successfully. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200). - - - diff --git a/example/ruby/Gem/Net/HTTPPartialContent.md b/example/ruby/Gem/Net/HTTPPartialContent.md deleted file mode 100644 index a59ec4f..0000000 --- a/example/ruby/Gem/Net/HTTPPartialContent.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPPartialContent -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `Partial Content` responses (status code 206). - -The `Partial Content` response indicates that the server is delivering only -part of the resource (byte serving) due to a Range header in the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-206-partial-content - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206). - - - diff --git a/example/ruby/Gem/Net/HTTPPayloadTooLarge.md b/example/ruby/Gem/Net/HTTPPayloadTooLarge.md deleted file mode 100644 index ae60cfe..0000000 --- a/example/ruby/Gem/Net/HTTPPayloadTooLarge.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPPayloadTooLarge -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Payload Too Large` responses (status code 413). - -The request is larger than the server is willing or able to process. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-413-content-too-lar - ge). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413). - - - diff --git a/example/ruby/Gem/Net/HTTPPaymentRequired.md b/example/ruby/Gem/Net/HTTPPaymentRequired.md deleted file mode 100644 index be741e6..0000000 --- a/example/ruby/Gem/Net/HTTPPaymentRequired.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPPaymentRequired -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Payment Required` responses (status code 402). - -Reserved for future use. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-402-payment-require - d). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402). - - - diff --git a/example/ruby/Gem/Net/HTTPPermanentRedirect.md b/example/ruby/Gem/Net/HTTPPermanentRedirect.md deleted file mode 100644 index e3829b1..0000000 --- a/example/ruby/Gem/Net/HTTPPermanentRedirect.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPPermanentRedirect -**Inherits:** Gem::Net::HTTPRedirection - - -Response class for `Permanent Redirect` responses (status code 308). - -This and all future requests should be directed to the given Gem::URI. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-308-permanent-redir - ect). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308). - - - diff --git a/example/ruby/Gem/Net/HTTPPreconditionFailed.md b/example/ruby/Gem/Net/HTTPPreconditionFailed.md deleted file mode 100644 index ac4a4fc..0000000 --- a/example/ruby/Gem/Net/HTTPPreconditionFailed.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPPreconditionFailed -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Precondition Failed` responses (status code 412). - -The server does not meet one of the preconditions specified in the request -headers. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-412-precondition-fa - iled). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412). - - - diff --git a/example/ruby/Gem/Net/HTTPPreconditionRequired.md b/example/ruby/Gem/Net/HTTPPreconditionRequired.md deleted file mode 100644 index dd4e207..0000000 --- a/example/ruby/Gem/Net/HTTPPreconditionRequired.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Gem::Net::HTTPPreconditionRequired -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Precondition Required` responses (status code 428). - -The origin server requires the request to be conditional. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428). -* [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-3). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428). - - - diff --git a/example/ruby/Gem/Net/HTTPProcessing.md b/example/ruby/Gem/Net/HTTPProcessing.md deleted file mode 100644 index 80d8125..0000000 --- a/example/ruby/Gem/Net/HTTPProcessing.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Gem::Net::HTTPProcessing -**Inherits:** Gem::Net::HTTPInformation - - -Response class for `Processing` responses (status code 102). - -The `Processing` response indicates that the server has received and is -processing the request, but no response is available yet. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 2518](https://www.rfc-editor.org/rfc/rfc2518#section-10.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102). - - - diff --git a/example/ruby/Gem/Net/HTTPProxyAuthenticationRequired.md b/example/ruby/Gem/Net/HTTPProxyAuthenticationRequired.md deleted file mode 100644 index d2b4337..0000000 --- a/example/ruby/Gem/Net/HTTPProxyAuthenticationRequired.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPProxyAuthenticationRequired -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Proxy Authentication Required` responses (status code -407). - -The client must first authenticate itself with the proxy. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-407-proxy-authentic - ation-re). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407). - - - diff --git a/example/ruby/Gem/Net/HTTPRangeNotSatisfiable.md b/example/ruby/Gem/Net/HTTPRangeNotSatisfiable.md deleted file mode 100644 index 8cfc856..0000000 --- a/example/ruby/Gem/Net/HTTPRangeNotSatisfiable.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPRangeNotSatisfiable -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Range Not Satisfiable` responses (status code 416). - -The request entity has a media type which the server or resource does not -support. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-416-range-not-satis - fiable). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416). - - - diff --git a/example/ruby/Gem/Net/HTTPRedirection.md b/example/ruby/Gem/Net/HTTPRedirection.md deleted file mode 100644 index 7e8763d..0000000 --- a/example/ruby/Gem/Net/HTTPRedirection.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Net::HTTPRedirection -**Inherits:** Gem::Net::HTTPResponse - - -Parent class for redirection (3xx) HTTP response classes. - -A redirection response indicates the client must take additional action to -complete the request. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.3xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_re - direction). - - - diff --git a/example/ruby/Gem/Net/HTTPRequest.md b/example/ruby/Gem/Net/HTTPRequest.md deleted file mode 100644 index b3645c2..0000000 --- a/example/ruby/Gem/Net/HTTPRequest.md +++ /dev/null @@ -1,97 +0,0 @@ -# Class: Gem::Net::HTTPRequest -**Inherits:** Gem::Net::HTTPGenericRequest - - -This class is the base class for Gem::Net::HTTP request classes. The class -should not be used directly; instead you should use its subclasses, listed -below. - -## Creating a Request - -An request object may be created with either a Gem::URI or a string hostname: - - require 'rubygems/vendor/net-http/lib/net/http' - uri = Gem::URI('https://jsonplaceholder.typicode.com/') - req = Gem::Net::HTTP::Get.new(uri) # => # - req = Gem::Net::HTTP::Get.new(uri.hostname) # => # - -And with any of the subclasses: - - req = Gem::Net::HTTP::Head.new(uri) # => # - req = Gem::Net::HTTP::Post.new(uri) # => # - req = Gem::Net::HTTP::Put.new(uri) # => # - # ... - -The new instance is suitable for use as the argument to -Gem::Net::HTTP#request. - -## Request Headers - -A new request object has these header fields by default: - - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -See: - -* [Request header - Accept-Encoding](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields# - Accept-Encoding) and [Compression and - Decompression](rdoc-ref:Gem::Net::HTTP@Compression+and+Decompression). -* [Request header - Accept](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#accept-re - quest-header). -* [Request header - User-Agent](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#user- - agent-request-header). -* [Request header - Host](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#host-reques - t-header). - -You can add headers or override default headers: - - # res = Gem::Net::HTTP::Get.new(uri, {'foo' => '0', 'bar' => '1'}) - -This class (and therefore its subclasses) also includes (indirectly) module -Gem::Net::HTTPHeader, which gives access to its [methods for setting -headers](rdoc-ref:Gem::Net::HTTPHeader@Setters). - -## Request Subclasses - -Subclasses for HTTP requests: - -* Gem::Net::HTTP::Get -* Gem::Net::HTTP::Head -* Gem::Net::HTTP::Post -* Gem::Net::HTTP::Put -* Gem::Net::HTTP::Delete -* Gem::Net::HTTP::Options -* Gem::Net::HTTP::Trace -* Gem::Net::HTTP::Patch - -Subclasses for WebDAV requests: - -* Gem::Net::HTTP::Propfind -* Gem::Net::HTTP::Proppatch -* Gem::Net::HTTP::Mkcol -* Gem::Net::HTTP::Copy -* Gem::Net::HTTP::Move -* Gem::Net::HTTP::Lock -* Gem::Net::HTTP::Unlock - - - -#Instance Methods -## initialize(path, initheadernil) [](#method-i-initialize) -Creates an HTTP request object for `path`. - -`initheader` are the default headers to use. Gem::Net::HTTP adds -Accept-Encoding to enable compression of the response body unless -Accept-Encoding or Range are supplied in `initheader`. - -**@return** [HTTPRequest] a new instance of HTTPRequest - diff --git a/example/ruby/Gem/Net/HTTPRequestHeaderFieldsTooLarge.md b/example/ruby/Gem/Net/HTTPRequestHeaderFieldsTooLarge.md deleted file mode 100644 index b56b97d..0000000 --- a/example/ruby/Gem/Net/HTTPRequestHeaderFieldsTooLarge.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPRequestHeaderFieldsTooLarge -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Request Header Fields Too Large` responses (status code -431). - -An individual header field is too large, or all the header fields -collectively, are too large. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431). -* [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-5). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431). - - - diff --git a/example/ruby/Gem/Net/HTTPRequestTimeout.md b/example/ruby/Gem/Net/HTTPRequestTimeout.md deleted file mode 100644 index 77db59b..0000000 --- a/example/ruby/Gem/Net/HTTPRequestTimeout.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPRequestTimeout -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Request Gem::Timeout` responses (status code 408). - -The server timed out waiting for the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-408-request-timeout - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408). - - - diff --git a/example/ruby/Gem/Net/HTTPResetContent.md b/example/ruby/Gem/Net/HTTPResetContent.md deleted file mode 100644 index fe7ab7e..0000000 --- a/example/ruby/Gem/Net/HTTPResetContent.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPResetContent -**Inherits:** Gem::Net::HTTPSuccess - - -Response class for `Reset Content` responses (status code 205). - -The `Reset Content` response indicates that the server successfully processed -the request, asks that the client reset its document view, and is not -returning any content. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-205-reset-content). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205). - - - diff --git a/example/ruby/Gem/Net/HTTPResponse.md b/example/ruby/Gem/Net/HTTPResponse.md deleted file mode 100644 index 601f1c1..0000000 --- a/example/ruby/Gem/Net/HTTPResponse.md +++ /dev/null @@ -1,774 +0,0 @@ -# Class: Gem::Net::HTTPResponse -**Inherits:** Object - -**Includes:** Gem::Net::HTTPHeader - - -This class is the base class for Gem::Net::HTTP response classes. - -## About the Examples - -:include: doc/net-http/examples.rdoc - -## Returned Responses - -Method Gem::Net::HTTP.get_response returns an instance of one of the -subclasses of Gem::Net::HTTPResponse: - - Gem::Net::HTTP.get_response(uri) - # => # - Gem::Net::HTTP.get_response(hostname, '/nosuch') - # => # - -As does method Gem::Net::HTTP#request: - - req = Gem::Net::HTTP::Get.new(uri) - Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -Class Gem::Net::HTTPResponse includes module Gem::Net::HTTPHeader, which -provides access to response header values via (among others): - -* Hash-like method `[]`. -* Specific reader methods, such as `content_type`. - -Examples: - - res = Gem::Net::HTTP.get_response(uri) # => # - res['Content-Type'] # => "text/html; charset=UTF-8" - res.content_type # => "text/html" - -## Response Subclasses - -Class Gem::Net::HTTPResponse has a subclass for each [HTTP status -code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). You can look -up the response class for a given code: - - Gem::Net::HTTPResponse::CODE_TO_OBJ['200'] # => Gem::Net::HTTPOK - Gem::Net::HTTPResponse::CODE_TO_OBJ['400'] # => Gem::Net::HTTPBadRequest - Gem::Net::HTTPResponse::CODE_TO_OBJ['404'] # => Gem::Net::HTTPNotFound - -And you can retrieve the status code for a response object: - - Gem::Net::HTTP.get_response(uri).code # => "200" - Gem::Net::HTTP.get_response(hostname, '/nosuch').code # => "404" - -The response subclasses (indentation shows class hierarchy): - -* Gem::Net::HTTPUnknownResponse (for unhandled HTTP extensions). - -* Gem::Net::HTTPInformation: - - * Gem::Net::HTTPContinue (100) - * Gem::Net::HTTPSwitchProtocol (101) - * Gem::Net::HTTPProcessing (102) - * Gem::Net::HTTPEarlyHints (103) - -* Gem::Net::HTTPSuccess: - - * Gem::Net::HTTPOK (200) - * Gem::Net::HTTPCreated (201) - * Gem::Net::HTTPAccepted (202) - * Gem::Net::HTTPNonAuthoritativeInformation (203) - * Gem::Net::HTTPNoContent (204) - * Gem::Net::HTTPResetContent (205) - * Gem::Net::HTTPPartialContent (206) - * Gem::Net::HTTPMultiStatus (207) - * Gem::Net::HTTPAlreadyReported (208) - * Gem::Net::HTTPIMUsed (226) - -* Gem::Net::HTTPRedirection: - - * Gem::Net::HTTPMultipleChoices (300) - * Gem::Net::HTTPMovedPermanently (301) - * Gem::Net::HTTPFound (302) - * Gem::Net::HTTPSeeOther (303) - * Gem::Net::HTTPNotModified (304) - * Gem::Net::HTTPUseProxy (305) - * Gem::Net::HTTPTemporaryRedirect (307) - * Gem::Net::HTTPPermanentRedirect (308) - -* Gem::Net::HTTPClientError: - - * Gem::Net::HTTPBadRequest (400) - * Gem::Net::HTTPUnauthorized (401) - * Gem::Net::HTTPPaymentRequired (402) - * Gem::Net::HTTPForbidden (403) - * Gem::Net::HTTPNotFound (404) - * Gem::Net::HTTPMethodNotAllowed (405) - * Gem::Net::HTTPNotAcceptable (406) - * Gem::Net::HTTPProxyAuthenticationRequired (407) - * Gem::Net::HTTPRequestTimeOut (408) - * Gem::Net::HTTPConflict (409) - * Gem::Net::HTTPGone (410) - * Gem::Net::HTTPLengthRequired (411) - * Gem::Net::HTTPPreconditionFailed (412) - * Gem::Net::HTTPRequestEntityTooLarge (413) - * Gem::Net::HTTPRequestURITooLong (414) - * Gem::Net::HTTPUnsupportedMediaType (415) - * Gem::Net::HTTPRequestedRangeNotSatisfiable (416) - * Gem::Net::HTTPExpectationFailed (417) - * Gem::Net::HTTPMisdirectedRequest (421) - * Gem::Net::HTTPUnprocessableEntity (422) - * Gem::Net::HTTPLocked (423) - * Gem::Net::HTTPFailedDependency (424) - * Gem::Net::HTTPUpgradeRequired (426) - * Gem::Net::HTTPPreconditionRequired (428) - * Gem::Net::HTTPTooManyRequests (429) - * Gem::Net::HTTPRequestHeaderFieldsTooLarge (431) - * Gem::Net::HTTPUnavailableForLegalReasons (451) - -* Gem::Net::HTTPServerError: - - * Gem::Net::HTTPInternalServerError (500) - * Gem::Net::HTTPNotImplemented (501) - * Gem::Net::HTTPBadGateway (502) - * Gem::Net::HTTPServiceUnavailable (503) - * Gem::Net::HTTPGatewayTimeOut (504) - * Gem::Net::HTTPVersionNotSupported (505) - * Gem::Net::HTTPVariantAlsoNegotiates (506) - * Gem::Net::HTTPInsufficientStorage (507) - * Gem::Net::HTTPLoopDetected (508) - * Gem::Net::HTTPNotExtended (510) - * Gem::Net::HTTPNetworkAuthenticationRequired (511) - -There is also the Gem::Net::HTTPBadResponse exception which is raised when -there is a protocol error. - - -# Class Methods -## body_permitted?() [](#method-c-body_permitted?) -true if the response has a body. -**@return** [Boolean] - -## exception_type() [](#method-c-exception_type) -:nodoc: internal use only -## read_new(sock ) [](#method-c-read_new) -:nodoc: internal use only -# Attributes -## body_encoding[RW] [](#attribute-i-body_encoding) -Returns the value set by body_encoding=, or `false` if none; see -#body_encoding=. - -## code[RW] [](#attribute-i-code) -The HTTP result code string. For example, '302'. You can also determine the -response type by examining which response subclass the response object is an -instance of. - -## decode_content[RW] [](#attribute-i-decode_content) -Set to true automatically when the request did not contain an Accept-Encoding -header from the user. - -## http_version[RW] [](#attribute-i-http_version) -The HTTP version supported by the server. - -## ignore_eof[RW] [](#attribute-i-ignore_eof) -Whether to ignore EOF when reading bodies with a specified Content-Length -header. - -## message[RW] [](#attribute-i-message) -The HTTP result message sent by the server. For example, 'Not Found'. - -## uri[RW] [](#attribute-i-uri) -The Gem::URI used to fetch this response. The response Gem::URI is only -available if a Gem::URI was used to create the request. - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Gem::Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Sets the value for the case-insensitive `key` to `val`, overwriting the -previous value if the field exists; see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - req = Gem::Net::HTTP::Get.new(uri) - req['Accept'] # => "*/*" - req['Accept'] = 'text/html' - req['Accept'] # => "text/html" - -Note that some field values may be set via convenience methods; see -[Setters](rdoc-ref:Gem::Net::HTTPHeader@Setters). - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - req = Gem::Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## body() [](#method-i-body) -Returns the string response body; note that repeated calls for the unmodified -body return a cached string: - - path = '/todos/1' - Gem::Net::HTTP.start(hostname) do |http| - res = http.get(path) - p res.body - p http.head(path).body # No body. - end - -Output: - - "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}" - nil - -## body=(value) [](#method-i-body=) -Sets the body of the response to the given value. - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## code_type() [](#method-i-code_type) -response <-> exception relationship - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Gem::Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Gem::Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Gem::Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Gem::Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Gem::Net::HTTPHeader#canonical_each is an alias for -Gem::Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](https://docs.ruby-lang.org/en/master/case_mapping_rdoc.html). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Gem::Net::HTTPHeader#each is an alias for Gem::Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Gem::Net::HTTPHeader#each_name is an alias for Gem::Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## error!() [](#method-i-error!) -:nodoc: - -**@raise** [error_type()] - -## error_type() [](#method-i-error_type) -:nodoc: - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Gem::Net::HTTPHeader@Fields): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## header() [](#method-i-header) -:nodoc: - -## initialize(httpv, code, msg) [](#method-i-initialize) -:nodoc: internal use only - -**@return** [HTTPResponse] a new instance of HTTPResponse - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## inspect() [](#method-i-inspect) - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Gem::Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Gem::Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## read_body(destnil, &block) [](#method-i-read_body) -Gets the entity body returned by the remote HTTP server. - -If a block is given, the body is passed to the block, and the body is provided -in fragments, as it is read in from the socket. - -If `dest` argument is given, response is read into that variable, with -`dest#<<` method (it could be String or IO, or any other object responding to -`<<`). - -Calling this method a second or subsequent time for the same HTTPResponse -object will return the value already read. - - http.request_get('/index.html') {|res| - puts res.read_body - } - - http.request_get('/index.html') {|res| - p res.read_body.object_id # 538149362 - p res.read_body.object_id # 538149362 - } - - # using iterator - http.request_get('/index.html') {|res| - res.read_body do |segment| - print segment - end - } - -## read_header() [](#method-i-read_header) -:nodoc: - -## reading_body(sock, reqmethodallowbody) [](#method-i-reading_body) -body - -## response() [](#method-i-response) -header (for backward compatibility only; DO NOT USE) - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Gem::Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Gem::Net::HTTPHeader#content_type= is an alias for -Gem::Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enume -rable-label-Enumerable+in+Ruby+Classes) (method `params.map` will be called), -and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Gem::Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[Gem::URI.encode_www_form](https://docs.ruby-lang.org/en/master/Gem::URI.html# -method-c-encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Gem::Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Gem::Net::HTTPHeader#form_data= is an alias for -Gem::Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Gem::Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Gem::Net::HTTPHeader#range= is an alias for Gem::Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Gem::Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Gem::Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - -## value() [](#method-i-value) -Raises an HTTP error if the response is not 2xx (success). - diff --git a/example/ruby/Gem/Net/HTTPResponse/Inflater.md b/example/ruby/Gem/Net/HTTPResponse/Inflater.md deleted file mode 100644 index d45d1f5..0000000 --- a/example/ruby/Gem/Net/HTTPResponse/Inflater.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Gem::Net::HTTPResponse::Inflater -**Inherits:** Object - - -Inflater is a wrapper around Gem::Net::BufferedIO that transparently inflates -zlib and gzip streams. - - - -#Instance Methods -## bytes_inflated() [](#method-i-bytes_inflated) -The number of bytes inflated, used to update the Content-Length of the -response. - -## finish() [](#method-i-finish) -Finishes the inflate stream. - -## inflate_adapter(dest) [](#method-i-inflate_adapter) -Returns a Gem::Net::ReadAdapter that inflates each read chunk into `dest`. - -This allows a large response body to be inflated without storing the entire -body in memory. - -## initialize(socket) [](#method-i-initialize) -Creates a new Inflater wrapping `socket` - -**@return** [Inflater] a new instance of Inflater - -## read(clen, dest, ignore_eoffalse) [](#method-i-read) -Reads `clen` bytes from the socket, inflates them, then writes them to `dest`. - `ignore_eof` is passed down to Gem::Net::BufferedIO#read - -Unlike Gem::Net::BufferedIO#read, this method returns more than `clen` bytes. -At this time there is no way for a user of Gem::Net::HTTPResponse to read a -specific number of bytes from the HTTP response body, so this internal API -does not return the same number of bytes as were requested. - -See https://bugs.ruby-lang.org/issues/6492 for further discussion. - -## read_all(dest) [](#method-i-read_all) -Reads the rest of the socket, inflates it, then writes it to `dest`. - diff --git a/example/ruby/Gem/Net/HTTPRetriableError.md b/example/ruby/Gem/Net/HTTPRetriableError.md deleted file mode 100644 index 6ccad99..0000000 --- a/example/ruby/Gem/Net/HTTPRetriableError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Gem::Net::HTTPRetriableError -**Inherits:** Gem::Net::ProtoRetriableError - -**Includes:** Gem::Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Gem/Net/HTTPSeeOther.md b/example/ruby/Gem/Net/HTTPSeeOther.md deleted file mode 100644 index 63e9584..0000000 --- a/example/ruby/Gem/Net/HTTPSeeOther.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPSeeOther -**Inherits:** Gem::Net::HTTPRedirection - - -Response class for `See Other` responses (status code 303). - -The response to the request can be found under another Gem::URI using the GET -method. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-303-see-other). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303). - - - diff --git a/example/ruby/Gem/Net/HTTPServerError.md b/example/ruby/Gem/Net/HTTPServerError.md deleted file mode 100644 index 517b299..0000000 --- a/example/ruby/Gem/Net/HTTPServerError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::Net::HTTPServerError -**Inherits:** Gem::Net::HTTPResponse - - -Parent class for server error (5xx) HTTP response classes. - -A server error response indicates that the server failed to fulfill a request. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.5xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_se - rver_errors). - - - diff --git a/example/ruby/Gem/Net/HTTPServiceUnavailable.md b/example/ruby/Gem/Net/HTTPServiceUnavailable.md deleted file mode 100644 index d6c10df..0000000 --- a/example/ruby/Gem/Net/HTTPServiceUnavailable.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPServiceUnavailable -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Service Unavailable` responses (status code 503). - -The server cannot handle the request (because it is overloaded or down for -maintenance). - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-503-service-unavail - able). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503). - - - diff --git a/example/ruby/Gem/Net/HTTPSuccess.md b/example/ruby/Gem/Net/HTTPSuccess.md deleted file mode 100644 index 4f232d2..0000000 --- a/example/ruby/Gem/Net/HTTPSuccess.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Net::HTTPSuccess -**Inherits:** Gem::Net::HTTPResponse - - -Parent class for success (2xx) HTTP response classes. - -A success response indicates the action requested by the client was received, -understood, and accepted. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.2xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_su - ccess). - - - diff --git a/example/ruby/Gem/Net/HTTPSwitchProtocol.md b/example/ruby/Gem/Net/HTTPSwitchProtocol.md deleted file mode 100644 index a7d1566..0000000 --- a/example/ruby/Gem/Net/HTTPSwitchProtocol.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPSwitchProtocol -**Inherits:** Gem::Net::HTTPInformation - - -Response class for `Switching Protocol` responses (status code 101). - -The Switching Protocol response indicates that the server has received -a request to switch protocols, and has agreed to do so. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-101-switching-proto - cols). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101). - - - diff --git a/example/ruby/Gem/Net/HTTPTemporaryRedirect.md b/example/ruby/Gem/Net/HTTPTemporaryRedirect.md deleted file mode 100644 index a9ba1b4..0000000 --- a/example/ruby/Gem/Net/HTTPTemporaryRedirect.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPTemporaryRedirect -**Inherits:** Gem::Net::HTTPRedirection - - -Response class for `Temporary Redirect` responses (status code 307). - -The request should be repeated with another Gem::URI; however, future requests -should still use the original Gem::URI. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-307-temporary-redir - ect). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307). - - - diff --git a/example/ruby/Gem/Net/HTTPTooManyRequests.md b/example/ruby/Gem/Net/HTTPTooManyRequests.md deleted file mode 100644 index 2aa7d6a..0000000 --- a/example/ruby/Gem/Net/HTTPTooManyRequests.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Gem::Net::HTTPTooManyRequests -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Too Many Requests` responses (status code 429). - -The user has sent too many requests in a given amount of time. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429). -* [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-4). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429). - - - diff --git a/example/ruby/Gem/Net/HTTPURITooLong.md b/example/ruby/Gem/Net/HTTPURITooLong.md deleted file mode 100644 index f3dfbce..0000000 --- a/example/ruby/Gem/Net/HTTPURITooLong.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPURITooLong -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Gem::URI Too Long` responses (status code 414). - -The Gem::URI provided was too long for the server to process. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-414-uri-too-long). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414). - - - diff --git a/example/ruby/Gem/Net/HTTPUnauthorized.md b/example/ruby/Gem/Net/HTTPUnauthorized.md deleted file mode 100644 index 7512813..0000000 --- a/example/ruby/Gem/Net/HTTPUnauthorized.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPUnauthorized -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Unauthorized` responses (status code 401). - -Authentication is required, but either was not provided or failed. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-401-unauthorized). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401). - - - diff --git a/example/ruby/Gem/Net/HTTPUnavailableForLegalReasons.md b/example/ruby/Gem/Net/HTTPUnavailableForLegalReasons.md deleted file mode 100644 index e9b55cc..0000000 --- a/example/ruby/Gem/Net/HTTPUnavailableForLegalReasons.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPUnavailableForLegalReasons -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Unavailable For Legal Reasons` responses (status code -451). - -A server operator has received a legal demand to deny access to a resource or -to a set of resources that includes the requested resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451). -* [RFC 7725](https://www.rfc-editor.org/rfc/rfc7725.html#section-3). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451). - - - diff --git a/example/ruby/Gem/Net/HTTPUnknownResponse.md b/example/ruby/Gem/Net/HTTPUnknownResponse.md deleted file mode 100644 index 8d6a46a..0000000 --- a/example/ruby/Gem/Net/HTTPUnknownResponse.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::Net::HTTPUnknownResponse -**Inherits:** Gem::Net::HTTPResponse - - - - - diff --git a/example/ruby/Gem/Net/HTTPUnprocessableEntity.md b/example/ruby/Gem/Net/HTTPUnprocessableEntity.md deleted file mode 100644 index 0a5d0a2..0000000 --- a/example/ruby/Gem/Net/HTTPUnprocessableEntity.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPUnprocessableEntity -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Unprocessable Entity` responses (status code 422). - -The request was well-formed but had semantic errors. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-422-unprocessable-c - ontent). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422). - - - diff --git a/example/ruby/Gem/Net/HTTPUnsupportedMediaType.md b/example/ruby/Gem/Net/HTTPUnsupportedMediaType.md deleted file mode 100644 index e6be0c9..0000000 --- a/example/ruby/Gem/Net/HTTPUnsupportedMediaType.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Net::HTTPUnsupportedMediaType -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Unsupported Media Type` responses (status code 415). - -The request entity has a media type which the server or resource does not -support. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-415-unsupported-med - ia-type). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415). - - - diff --git a/example/ruby/Gem/Net/HTTPUpgradeRequired.md b/example/ruby/Gem/Net/HTTPUpgradeRequired.md deleted file mode 100644 index 71beb26..0000000 --- a/example/ruby/Gem/Net/HTTPUpgradeRequired.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPUpgradeRequired -**Inherits:** Gem::Net::HTTPClientError - - -Response class for `Upgrade Required` responses (status code 426). - -The client should switch to the protocol given in the Upgrade header field. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-426-upgrade-require - d). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426). - - - diff --git a/example/ruby/Gem/Net/HTTPUseProxy.md b/example/ruby/Gem/Net/HTTPUseProxy.md deleted file mode 100644 index 884abb4..0000000 --- a/example/ruby/Gem/Net/HTTPUseProxy.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPUseProxy -**Inherits:** Gem::Net::HTTPRedirection - - -Response class for `Use Proxy` responses (status code 305). - -The requested resource is available only through a proxy, whose address is -provided in the response. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-305-use-proxy). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305). - - - diff --git a/example/ruby/Gem/Net/HTTPVariantAlsoNegotiates.md b/example/ruby/Gem/Net/HTTPVariantAlsoNegotiates.md deleted file mode 100644 index 2737f89..0000000 --- a/example/ruby/Gem/Net/HTTPVariantAlsoNegotiates.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Net::HTTPVariantAlsoNegotiates -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `Variant Also Negotiates` responses (status code 506). - -Transparent content negotiation for the request results in a circular -reference. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506). -* [RFC 2295](https://www.rfc-editor.org/rfc/rfc2295#section-8.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506). - - - diff --git a/example/ruby/Gem/Net/HTTPVersionNotSupported.md b/example/ruby/Gem/Net/HTTPVersionNotSupported.md deleted file mode 100644 index 5afe2e8..0000000 --- a/example/ruby/Gem/Net/HTTPVersionNotSupported.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Net::HTTPVersionNotSupported -**Inherits:** Gem::Net::HTTPServerError - - -Response class for `HTTP Version Not Supported` responses (status code 505). - -The server does not support the HTTP version used in the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-505-http-version-no - t-suppor). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505). - - - diff --git a/example/ruby/Gem/Net/InternetMessageIO.md b/example/ruby/Gem/Net/InternetMessageIO.md deleted file mode 100644 index 83e72ce..0000000 --- a/example/ruby/Gem/Net/InternetMessageIO.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Gem::Net::InternetMessageIO -**Inherits:** Gem::Net::BufferedIO - - -:nodoc: internal use only - - - -#Instance Methods -## each_list_item() [](#method-i-each_list_item) -*library private* (cannot handle 'break') - -## each_message_chunk() [](#method-i-each_message_chunk) -Read - -## initialize() [](#method-i-initialize) - -**@return** [InternetMessageIO] a new instance of InternetMessageIO - -## write_message(src) [](#method-i-write_message) -Write - -## write_message_0(src) [](#method-i-write_message_0) - -## write_message_by_block(&block) [](#method-i-write_message_by_block) - diff --git a/example/ruby/Gem/Net/NetPrivate.md b/example/ruby/Gem/Net/NetPrivate.md deleted file mode 100644 index 00bde93..0000000 --- a/example/ruby/Gem/Net/NetPrivate.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Net::NetPrivate - - -:nodoc: obsolete - - - diff --git a/example/ruby/Gem/Net/OpenTimeout.md b/example/ruby/Gem/Net/OpenTimeout.md deleted file mode 100644 index 5d911fb..0000000 --- a/example/ruby/Gem/Net/OpenTimeout.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Gem::Net::OpenTimeout -**Inherits:** Gem::Timeout::Error - - -OpenTimeout, a subclass of Gem::Timeout::Error, is raised if a connection -cannot be created within the open_timeout. - - - diff --git a/example/ruby/Gem/Net/ProtoAuthError.md b/example/ruby/Gem/Net/ProtoAuthError.md deleted file mode 100644 index 4a69db8..0000000 --- a/example/ruby/Gem/Net/ProtoAuthError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::ProtoAuthError -**Inherits:** Gem::Net::ProtocolError - - - - - diff --git a/example/ruby/Gem/Net/ProtoCommandError.md b/example/ruby/Gem/Net/ProtoCommandError.md deleted file mode 100644 index 801298b..0000000 --- a/example/ruby/Gem/Net/ProtoCommandError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::ProtoCommandError -**Inherits:** Gem::Net::ProtocolError - - - - - diff --git a/example/ruby/Gem/Net/ProtoFatalError.md b/example/ruby/Gem/Net/ProtoFatalError.md deleted file mode 100644 index 612476a..0000000 --- a/example/ruby/Gem/Net/ProtoFatalError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::ProtoFatalError -**Inherits:** Gem::Net::ProtocolError - - - - - diff --git a/example/ruby/Gem/Net/ProtoRetriableError.md b/example/ruby/Gem/Net/ProtoRetriableError.md deleted file mode 100644 index 6342612..0000000 --- a/example/ruby/Gem/Net/ProtoRetriableError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::ProtoRetriableError -**Inherits:** Gem::Net::ProtocolError - - - - - diff --git a/example/ruby/Gem/Net/ProtoServerError.md b/example/ruby/Gem/Net/ProtoServerError.md deleted file mode 100644 index cabf884..0000000 --- a/example/ruby/Gem/Net/ProtoServerError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::ProtoServerError -**Inherits:** Gem::Net::ProtocolError - - - - - diff --git a/example/ruby/Gem/Net/ProtoSyntaxError.md b/example/ruby/Gem/Net/ProtoSyntaxError.md deleted file mode 100644 index d8d5d0a..0000000 --- a/example/ruby/Gem/Net/ProtoSyntaxError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::ProtoSyntaxError -**Inherits:** Gem::Net::ProtocolError - - - - - diff --git a/example/ruby/Gem/Net/ProtoUnknownError.md b/example/ruby/Gem/Net/ProtoUnknownError.md deleted file mode 100644 index 5653213..0000000 --- a/example/ruby/Gem/Net/ProtoUnknownError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::ProtoUnknownError -**Inherits:** Gem::Net::ProtocolError - - - - - diff --git a/example/ruby/Gem/Net/Protocol.md b/example/ruby/Gem/Net/Protocol.md deleted file mode 100644 index 58dc9b6..0000000 --- a/example/ruby/Gem/Net/Protocol.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Net::Protocol -**Inherits:** Object - - -:nodoc: internal use only - - - diff --git a/example/ruby/Gem/Net/ProtocolError.md b/example/ruby/Gem/Net/ProtocolError.md deleted file mode 100644 index f99b460..0000000 --- a/example/ruby/Gem/Net/ProtocolError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Net::ProtocolError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Gem/Net/ReadAdapter.md b/example/ruby/Gem/Net/ReadAdapter.md deleted file mode 100644 index 07ba872..0000000 --- a/example/ruby/Gem/Net/ReadAdapter.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Net::ReadAdapter -**Inherits:** Object - - -:nodoc: internal use only - - - -#Instance Methods -## <<(str) [](#method-i-<<) - -## initialize(block) [](#method-i-initialize) - -**@return** [ReadAdapter] a new instance of ReadAdapter - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/Gem/Net/ReadTimeout.md b/example/ruby/Gem/Net/ReadTimeout.md deleted file mode 100644 index 49d2937..0000000 --- a/example/ruby/Gem/Net/ReadTimeout.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: Gem::Net::ReadTimeout -**Inherits:** Gem::Timeout::Error - - -ReadTimeout, a subclass of Gem::Timeout::Error, is raised if a chunk of the -response cannot be read within the read_timeout. - - -# Attributes -## io[RW] [](#attribute-i-io) -Returns the value of attribute io. - - -#Instance Methods -## initialize(ionil) [](#method-i-initialize) - -**@return** [ReadTimeout] a new instance of ReadTimeout - -## message() [](#method-i-message) - diff --git a/example/ruby/Gem/Net/WriteAdapter.md b/example/ruby/Gem/Net/WriteAdapter.md deleted file mode 100644 index f816de0..0000000 --- a/example/ruby/Gem/Net/WriteAdapter.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Net::WriteAdapter -**Inherits:** Object - - -The writer adapter class - - - -#Instance Methods -## <<(str) [](#method-i-<<) - -## initialize(writer) [](#method-i-initialize) - -**@return** [WriteAdapter] a new instance of WriteAdapter - -## inspect() [](#method-i-inspect) - -## printf(*args) [](#method-i-printf) - -## puts(str'') [](#method-i-puts) - -## write(str) [](#method-i-write) - diff --git a/example/ruby/Gem/Net/WriteTimeout.md b/example/ruby/Gem/Net/WriteTimeout.md deleted file mode 100644 index 81b85cd..0000000 --- a/example/ruby/Gem/Net/WriteTimeout.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: Gem::Net::WriteTimeout -**Inherits:** Gem::Timeout::Error - - -WriteTimeout, a subclass of Gem::Timeout::Error, is raised if a chunk of the -response cannot be written within the write_timeout. Not raised on Windows. - - -# Attributes -## io[RW] [](#attribute-i-io) -Returns the value of attribute io. - - -#Instance Methods -## initialize(ionil) [](#method-i-initialize) - -**@return** [WriteTimeout] a new instance of WriteTimeout - -## message() [](#method-i-message) - diff --git a/example/ruby/Gem/NoAliasYAMLTree.md b/example/ruby/Gem/NoAliasYAMLTree.md deleted file mode 100644 index 52a5558..0000000 --- a/example/ruby/Gem/NoAliasYAMLTree.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::NoAliasYAMLTree -**Inherits:** Psych::Visitors::YAMLTree - - - - -# Class Methods -## create() [](#method-c-create) - -#Instance Methods -## register(target, obj) [](#method-i-register) -Noop this out so there are no anchors - -## visit_Hash(o) [](#method-i-visit_Hash) - -## visit_String(str) [](#method-i-visit_String) - diff --git a/example/ruby/Gem/OperationNotSupportedError.md b/example/ruby/Gem/OperationNotSupportedError.md deleted file mode 100644 index 860da3a..0000000 --- a/example/ruby/Gem/OperationNotSupportedError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::OperationNotSupportedError -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/OptionParser.md b/example/ruby/Gem/OptionParser.md deleted file mode 100644 index df3960e..0000000 --- a/example/ruby/Gem/OptionParser.md +++ /dev/null @@ -1,750 +0,0 @@ -# Class: Gem::OptionParser -**Inherits:** Object - - --- -## Developer Documentation (not for RDoc output) - -### Class tree - - Gem::OptionParser -: front end - - Gem::OptionParser::Switch -: each switches - - Gem::OptionParser::List -: options list - - Gem::OptionParser::ParseError -: errors on parsing - - * Gem::OptionParser::AmbiguousOption - * Gem::OptionParser::NeedlessArgument - * Gem::OptionParser::MissingArgument - * Gem::OptionParser::InvalidOption - * Gem::OptionParser::InvalidArgument - * Gem::OptionParser::AmbiguousArgument - -### Object relationship diagram - - +--------------+ - | Gem::OptionParser |<>-----+ - +--------------+ | +--------+ - | ,-| Switch | - on_head -------->+---------------+ / +--------+ - accept/reject -->| List |<|>- - | |<|>- +----------+ - on ------------->+---------------+ `-| argument | - : : | class | - +---------------+ |==========| - on_tail -------->| | |pattern | - +---------------+ |----------| - Gem::OptionParser.accept ->| DefaultList | |converter | - reject |(shared between| +----------+ - | all instances)| - +---------------+ - -++ - -## Gem::OptionParser - -### New to `Gem::OptionParser`? - -See the [Tutorial](optparse/tutorial.rdoc). - -### Introduction - -Gem::OptionParser is a class for command-line option analysis. It is much -more advanced, yet also easier to use, than GetoptLong, and is a more -Ruby-oriented solution. - -### Features - -1. The argument specification and the code to handle it are written in the - same place. -2. It can output an option summary; you don't need to maintain this string - separately. -3. Optional and mandatory arguments are specified very gracefully. -4. Arguments can be automatically converted to a specified class. -5. Arguments can be restricted to a certain set. - -All of these features are demonstrated in the examples below. See -#make_switch for full documentation. - -### Minimal example - - require 'rubygems/vendor/optparse/lib/optparse' - - options = {} - Gem::OptionParser.new do |parser| - parser.banner = "Usage: example.rb [options]" - - parser.on("-v", "--[no-]verbose", "Run verbosely") do |v| - options[:verbose] = v - end - end.parse! - - p options - p ARGV - -### Generating Help - -Gem::OptionParser can be used to automatically generate help for the commands -you write: - - require 'rubygems/vendor/optparse/lib/optparse' - - Options = Struct.new(:name) - - class Parser - def self.parse(options) - args = Options.new("world") - - opt_parser = Gem::OptionParser.new do |parser| - parser.banner = "Usage: example.rb [options]" - - parser.on("-nNAME", "--name=NAME", "Name to say hello to") do |n| - args.name = n - end - - parser.on("-h", "--help", "Prints this help") do - puts parser - exit - end - end - - opt_parser.parse!(options) - return args - end - end - options = Parser.parse %w[--help] - - #=> - # Usage: example.rb [options] - # -n, --name=NAME Name to say hello to - # -h, --help Prints this help - -### Required Arguments - -For options that require an argument, option specification strings may include -an option name in all caps. If an option is used without the required -argument, an exception will be raised. - - require 'rubygems/vendor/optparse/lib/optparse' - - options = {} - Gem::OptionParser.new do |parser| - parser.on("-r", "--require LIBRARY", - "Require the LIBRARY before executing your script") do |lib| - puts "You required #{lib}!" - end - end.parse! - -Used: - - $ ruby optparse-test.rb -r - optparse-test.rb:9:in `
': missing argument: -r (Gem::OptionParser::MissingArgument) - $ ruby optparse-test.rb -r my-library - You required my-library! - -### Type Coercion - -Gem::OptionParser supports the ability to coerce command line arguments into -objects for us. - -Gem::OptionParser comes with a few ready-to-use kinds of type coercion. They -are: - -* Date -- Anything accepted by `Date.parse` (need to require - `optparse/date`) -* DateTime -- Anything accepted by `DateTime.parse` (need to require - `optparse/date`) -* Time -- Anything accepted by `Time.httpdate` or `Time.parse` (need to - require `optparse/time`) -* URI -- Anything accepted by `Gem::URI.parse` (need to require - `optparse/uri`) -* Shellwords -- Anything accepted by `Shellwords.shellwords` (need to - require `optparse/shellwords`) -* String -- Any non-empty string -* Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040) -* Float -- Any float. (e.g. 10, 3.14, -100E+13) -* Numeric -- Any integer, float, or rational (1, 3.4, 1/3) -* DecimalInteger -- Like `Integer`, but no octal format. -* OctalInteger -- Like `Integer`, but no decimal format. -* DecimalNumeric -- Decimal integer or float. -* TrueClass -- Accepts '+, yes, true, -, no, false' and defaults as `true` -* FalseClass -- Same as `TrueClass`, but defaults to `false` -* Array -- Strings separated by ',' (e.g. 1,2,3) -* Regexp -- Regular expressions. Also includes options. - -We can also add our own coercions, which we will cover below. - -#### Using Built-in Conversions - -As an example, the built-in `Time` conversion is used. The other built-in -conversions behave in the same way. Gem::OptionParser will attempt to parse -the argument as a `Time`. If it succeeds, that time will be passed to the -handler block. Otherwise, an exception will be raised. - - require 'rubygems/vendor/optparse/lib/optparse' - require 'rubygems/vendor/optparse/lib/optparse/time' - Gem::OptionParser.new do |parser| - parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time| - p time - end - end.parse! - -Used: - - $ ruby optparse-test.rb -t nonsense - ... invalid argument: -t nonsense (Gem::OptionParser::InvalidArgument) - $ ruby optparse-test.rb -t 10-11-12 - 2010-11-12 00:00:00 -0500 - $ ruby optparse-test.rb -t 9:30 - 2014-08-13 09:30:00 -0400 - -#### Creating Custom Conversions - -The `accept` method on Gem::OptionParser may be used to create converters. It -specifies which conversion block to call whenever a class is specified. The -example below uses it to fetch a `User` object before the `on` handler -receives it. - - require 'rubygems/vendor/optparse/lib/optparse' - - User = Struct.new(:id, :name) - - def find_user id - not_found = ->{ raise "No User Found for id #{id}" } - [ User.new(1, "Sam"), - User.new(2, "Gandalf") ].find(not_found) do |u| - u.id == id - end - end - - op = Gem::OptionParser.new - op.accept(User) do |user_id| - find_user user_id.to_i - end - - op.on("--user ID", User) do |user| - puts user - end - - op.parse! - -Used: - - $ ruby optparse-test.rb --user 1 - # - $ ruby optparse-test.rb --user 2 - # - $ ruby optparse-test.rb --user 3 - optparse-test.rb:15:in `block in find_user': No User Found for id 3 (RuntimeError) - -### Store options to a Hash - -The `into` option of `order`, `parse` and so on methods stores command line -options into a Hash. - - require 'rubygems/vendor/optparse/lib/optparse' - - options = {} - Gem::OptionParser.new do |parser| - parser.on('-a') - parser.on('-b NUM', Integer) - parser.on('-v', '--verbose') - end.parse!(into: options) - - p options - -Used: - - $ ruby optparse-test.rb -a - {:a=>true} - $ ruby optparse-test.rb -a -v - {:a=>true, :verbose=>true} - $ ruby optparse-test.rb -a -b 100 - {:a=>true, :b=>100} - -### Complete example - -The following example is a complete Ruby program. You can run it and see the -effect of specifying various options. This is probably the best way to learn -the features of `optparse`. - - require 'rubygems/vendor/optparse/lib/optparse' - require 'rubygems/vendor/optparse/lib/optparse/time' - require 'ostruct' - require 'pp' - - class OptparseExample - Version = '1.0.0' - - CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary] - CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" } - - class ScriptOptions - attr_accessor :library, :inplace, :encoding, :transfer_type, - :verbose, :extension, :delay, :time, :record_separator, - :list - - def initialize - self.library = [] - self.inplace = false - self.encoding = "utf8" - self.transfer_type = :auto - self.verbose = false - end - - def define_options(parser) - parser.banner = "Usage: example.rb [options]" - parser.separator "" - parser.separator "Specific options:" - - # add additional options - perform_inplace_option(parser) - delay_execution_option(parser) - execute_at_time_option(parser) - specify_record_separator_option(parser) - list_example_option(parser) - specify_encoding_option(parser) - optional_option_argument_with_keyword_completion_option(parser) - boolean_verbose_option(parser) - - parser.separator "" - parser.separator "Common options:" - # No argument, shows at tail. This will print an options summary. - # Try it and see! - parser.on_tail("-h", "--help", "Show this message") do - puts parser - exit - end - # Another typical switch to print the version. - parser.on_tail("--version", "Show version") do - puts Version - exit - end - end - - def perform_inplace_option(parser) - # Specifies an optional option argument - parser.on("-i", "--inplace [EXTENSION]", - "Edit ARGV files in place", - "(make backup if EXTENSION supplied)") do |ext| - self.inplace = true - self.extension = ext || '' - self.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot. - end - end - - def delay_execution_option(parser) - # Cast 'delay' argument to a Float. - parser.on("--delay N", Float, "Delay N seconds before executing") do |n| - self.delay = n - end - end - - def execute_at_time_option(parser) - # Cast 'time' argument to a Time object. - parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time| - self.time = time - end - end - - def specify_record_separator_option(parser) - # Cast to octal integer. - parser.on("-F", "--irs [OCTAL]", Gem::OptionParser::OctalInteger, - "Specify record separator (default \\0)") do |rs| - self.record_separator = rs - end - end - - def list_example_option(parser) - # List of arguments. - parser.on("--list x,y,z", Array, "Example 'list' of arguments") do |list| - self.list = list - end - end - - def specify_encoding_option(parser) - # Keyword completion. We are specifying a specific set of arguments (CODES - # and CODE_ALIASES - notice the latter is a Hash), and the user may provide - # the shortest unambiguous text. - code_list = (CODE_ALIASES.keys + CODES).join(', ') - parser.on("--code CODE", CODES, CODE_ALIASES, "Select encoding", - "(#{code_list})") do |encoding| - self.encoding = encoding - end - end - - def optional_option_argument_with_keyword_completion_option(parser) - # Optional '--type' option argument with keyword completion. - parser.on("--type [TYPE]", [:text, :binary, :auto], - "Select transfer type (text, binary, auto)") do |t| - self.transfer_type = t - end - end - - def boolean_verbose_option(parser) - # Boolean switch. - parser.on("-v", "--[no-]verbose", "Run verbosely") do |v| - self.verbose = v - end - end - end - - # - # Return a structure describing the options. - # - def parse(args) - # The options specified on the command line will be collected in - # *options*. - - @options = ScriptOptions.new - @args = Gem::OptionParser.new do |parser| - @options.define_options(parser) - parser.parse!(args) - end - @options - end - - attr_reader :parser, :options - end # class OptparseExample - - example = OptparseExample.new - options = example.parse(ARGV) - pp options # example.options - pp ARGV - -### Shell Completion - -For modern shells (e.g. bash, zsh, etc.), you can use shell completion for -command line options. - -### Further documentation - -The above examples, along with the accompanying -[Tutorial](optparse/tutorial.rdoc), should be enough to learn how to use this -class. If you have any questions, file a ticket at http://bugs.ruby-lang.org. - - -# Class Methods -## accept(*args , &blk ) [](#method-c-accept) -See #accept. -## each_const(path , base ::Object) [](#method-c-each_const) -:stopdoc: -## getopts(*args , symbolize_names: false) [](#method-c-getopts) -See #getopts. -## inc(arg , default nil) [](#method-c-inc) -Returns an incremented value of `default` according to `arg`. -## reject(*args , &blk ) [](#method-c-reject) -See #reject. -## search_const(klass , name ) [](#method-c-search_const) -## show_version(*pkgs ) [](#method-c-show_version) -Shows version string in packages if Version is defined. - -`pkgs` -: package list - -## terminate(arg nil) [](#method-c-terminate) -See #terminate. -## top() [](#method-c-top) -Returns the global top option list. - -Do not use directly. -## with(*args , &block ) [](#method-c-with) -Initializes a new instance and evaluates the optional block in context of the -instance. Arguments `args` are passed to #new, see there for description of -parameters. - -This method is **deprecated**, its behavior corresponds to the older #new -method. -# Attributes -## banner[RW] [](#attribute-i-banner) -Heading banner preceding summary. - -## default_argv[RW] [](#attribute-i-default_argv) -Strings to be parsed in default. - -## program_name[RW] [](#attribute-i-program_name) -Program name to be emitted in error message and default banner, defaults to -$0. - -## raise_unknown[RW] [](#attribute-i-raise_unknown) -Whether to raise at unknown option. - -## release[RW] [](#attribute-i-release) -Release code - -## require_exact[RW] [](#attribute-i-require_exact) -Whether to require that options match exactly (disallows providing abbreviated -long option as short option). - -## summary_indent[RW] [](#attribute-i-summary_indent) -Indentation for summary. Must be String (or have + String method). - -## summary_width[RW] [](#attribute-i-summary_width) -Width for option list portion of summary. Must be Numeric. - -## version[RW] [](#attribute-i-version) -Version - - -#Instance Methods -## abort(mesg$!) [](#method-i-abort) -Shows message with the program name then aborts. - -`mesg` -: Message, defaulted to +$!+. - - -See Kernel#abort. - -## accept(*args, &blk) [](#method-i-accept) -Directs to accept specified class `t`. The argument string is passed to the -block in which it should be converted to the desired class. - -`t` -: Argument class specifier, any object including Class. - -`pat` -: Pattern for argument, defaults to `t` if it responds to match. - - - accept(t, pat, &block) - -## add_officious() [](#method-i-add_officious) -:nodoc: - -## additional_message(typ, opt) [](#method-i-additional_message) -Returns additional info. - -## base() [](#method-i-base) -Subject of #on_tail. - -## candidate(word) [](#method-i-candidate) -Return candidates for `word`. - -## compsys(to, nameFile.basename($0)) [](#method-i-compsys) -:nodoc: - -## define(*opts, &block) [](#method-i-define) -:call-seq: - define(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -## define_by_keywords(options, method, **params) [](#method-i-define_by_keywords) -:call-seq: - define_by_keywords(options, method, **params) - -:include: ../../doc/optparse/creates_option.rdoc - -Defines options which set in to *options* for keyword parameters of *method*. - -Parameters for each keywords are given as elements of *params*. - -## define_head(*opts, &block) [](#method-i-define_head) -:call-seq: - define_head(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -## define_tail(*opts, &block) [](#method-i-define_tail) -:call-seq: - define_tail(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -## environment(envFile.basename($0, '.*'), **keywords) [](#method-i-environment) -Parses environment variable `env` or its uppercase with splitting like a -shell. - -`env` defaults to the basename of the program. - -## getopts(*args, symbolize_names:false, **keywords) [](#method-i-getopts) -Wrapper method for getopts.rb. - - params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option") - # params["a"] = true # -a - # params["b"] = "1" # -b1 - # params["foo"] = "1" # --foo - # params["bar"] = "x" # --bar x - # params["zot"] = "z" # --zot Z - -Option `symbolize_names` (boolean) specifies whether returned Hash keys should -be Symbols; defaults to `false` (use Strings). - - params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option", symbolize_names: true) - # params[:a] = true # -a - # params[:b] = "1" # -b1 - # params[:foo] = "1" # --foo - # params[:bar] = "x" # --bar x - # params[:zot] = "z" # --zot Z - -## help() [](#method-i-help) -Returns option summary string. - -## help_exit() [](#method-i-help_exit) - -## inc(*args) [](#method-i-inc) -See self.inc - -## initialize(bannernil, width32, indent' ' * 4) [](#method-i-initialize) -Initializes the instance and yields itself if called with a block. - -`banner` -: Banner message. - -`width` -: Summary width. - -`indent` -: Summary indent. - - -**@return** [OptionParser] a new instance of OptionParser - -**@yield** [_self] - -**@yieldparam** [Gem::OptionParser] the object that the method was called on - -## inspect() [](#method-i-inspect) -:nodoc: - -## load(filenamenil, **keywords) [](#method-i-load) -Loads options from file names as `filename`. Does nothing when the file is not -present. Returns whether successfully loaded. - -`filename` defaults to basename of the program without suffix in a directory -~/.options, then the basename with '.options' suffix under XDG and Haiku -standard places. - -The optional `into` keyword argument works exactly like that accepted in -method #parse. - -## make_switch(opts, blocknil) [](#method-i-make_switch) -:call-seq: - make_switch(params, block = nil) - -:include: ../doc/optparse/creates_option.rdoc - -## new() [](#method-i-new) -Pushes a new List. - -If a block is given, yields `self` and returns the result of the block, -otherwise returns `self`. - -## on(*opts, &block) [](#method-i-on) -:call-seq: - on(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -## on_head(*opts, &block) [](#method-i-on_head) -:call-seq: - on_head(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -The new option is added at the head of the summary. - -## on_tail(*opts, &block) [](#method-i-on_tail) -:call-seq: - on_tail(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -The new option is added at the tail of the summary. - -## order(*argv, **keywords, &nonopt) [](#method-i-order) -Parses command line arguments `argv` in order. When a block is given, each -non-option argument is yielded. When optional `into` keyword argument is -provided, the parsed option values are stored there via `[]=` method (so it -can be Hash, or OpenStruct, or other similar object). - -Returns the rest of `argv` left unparsed. - -## order!(argvdefault_argv, into:nil, **keywords, &nonopt) [](#method-i-order!) -Same as #order, but removes switches destructively. Non-option arguments -remain in `argv`. - -## parse(*argv, **keywords) [](#method-i-parse) -Parses command line arguments `argv` in order when environment variable -POSIXLY_CORRECT is set, and in permutation mode otherwise. When optional -`into` keyword argument is provided, the parsed option values are stored there -via `[]=` method (so it can be Hash, or OpenStruct, or other similar object). - -## parse!(argvdefault_argv, **keywords) [](#method-i-parse!) -Same as #parse, but removes switches destructively. Non-option arguments -remain in `argv`. - -## permute(*argv, **keywords) [](#method-i-permute) -Parses command line arguments `argv` in permutation mode and returns list of -non-option arguments. When optional `into` keyword argument is provided, the -parsed option values are stored there via `[]=` method (so it can be Hash, or -OpenStruct, or other similar object). - -## permute!(argvdefault_argv, **keywords) [](#method-i-permute!) -Same as #permute, but removes switches destructively. Non-option arguments -remain in `argv`. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## reject(*args, &blk) [](#method-i-reject) -Directs to reject specified class argument. - -`type` -: Argument class specifier, any object including Class. - - - reject(type) - -## remove() [](#method-i-remove) -Removes the last List. - -## separator(string) [](#method-i-separator) -Add separator in summary. - -## summarize(to[], width@summary_width, maxwidth - 1, indent@summary_indent, &blk) [](#method-i-summarize) -Puts option summary into `to` and returns `to`. Yields each line if a block is -given. - -`to` -: Output destination, which must have method <<. Defaults to []. - -`width` -: Width of left side, defaults to @summary_width. - -`max` -: Maximum length allowed for left side, defaults to `width` - 1. - -`indent` -: Indentation, defaults to @summary_indent. - - -## terminate(argnil) [](#method-i-terminate) -Terminates option parsing. Optional parameter `arg` is a string pushed back to -be the first non-option argument. - -## to_a() [](#method-i-to_a) -Returns option summary list. - -## top() [](#method-i-top) -Subject of #on / #on_head, #accept / #reject - -## ver() [](#method-i-ver) -Returns version string from program_name, version and release. - -## warn(mesg$!) [](#method-i-warn) -Shows warning message with the program name - -`mesg` -: Message, defaulted to +$!+. - - -See Kernel#warn. - diff --git a/example/ruby/Gem/OptionParser/AC.md b/example/ruby/Gem/OptionParser/AC.md deleted file mode 100644 index b0905a5..0000000 --- a/example/ruby/Gem/OptionParser/AC.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::OptionParser::AC -**Inherits:** Gem::OptionParser - - -autoconf-like options. - - - -#Instance Methods -## ac_arg_disable(name, help_string, &block) [](#method-i-ac_arg_disable) -Define `--enable` / `--disable` style option - -Appears as `--disable-*name`* in help message. - -## ac_arg_enable(name, help_string, &block) [](#method-i-ac_arg_enable) -Define `--enable` / `--disable` style option - -Appears as `--enable-*name`* in help message. - -## ac_arg_with(name, help_string, &block) [](#method-i-ac_arg_with) -Define `--with` / `--without` style option - -Appears as `--with-*name`* in help message. - diff --git a/example/ruby/Gem/OptionParser/Acceptables.md b/example/ruby/Gem/OptionParser/Acceptables.md deleted file mode 100644 index e2277b6..0000000 --- a/example/ruby/Gem/OptionParser/Acceptables.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: Gem::OptionParser::Acceptables - - -Acceptable argument classes. Now contains DecimalInteger, OctalInteger and -DecimalNumeric. See Acceptable argument classes (in source code). - - - diff --git a/example/ruby/Gem/OptionParser/AmbiguousArgument.md b/example/ruby/Gem/OptionParser/AmbiguousArgument.md deleted file mode 100644 index bde001d..0000000 --- a/example/ruby/Gem/OptionParser/AmbiguousArgument.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::OptionParser::AmbiguousArgument -**Inherits:** Gem::OptionParser::InvalidArgument - - -Raises when the given argument word can't be completed uniquely. - - - diff --git a/example/ruby/Gem/OptionParser/AmbiguousOption.md b/example/ruby/Gem/OptionParser/AmbiguousOption.md deleted file mode 100644 index 66e8073..0000000 --- a/example/ruby/Gem/OptionParser/AmbiguousOption.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::OptionParser::AmbiguousOption -**Inherits:** Gem::OptionParser::ParseError - - -Raises when ambiguously completable string is encountered. - - - diff --git a/example/ruby/Gem/OptionParser/Arguable.md b/example/ruby/Gem/OptionParser/Arguable.md deleted file mode 100644 index 52aae80..0000000 --- a/example/ruby/Gem/OptionParser/Arguable.md +++ /dev/null @@ -1,51 +0,0 @@ -# Module: Gem::OptionParser::Arguable - - -Extends command line arguments array (ARGV) to parse itself. - - -# Class Methods -## extend_object(obj ) [](#method-c-extend_object) -Initializes instance variable. - -#Instance Methods -## getopts(*args, symbolize_names:false, **keywords) [](#method-i-getopts) -Substitution of getopts is possible as follows. Also see -Gem::OptionParser#getopts. - - def getopts(*args) - ($OPT = ARGV.getopts(*args)).each do |opt, val| - eval "$OPT_#{opt.gsub(/[^A-Za-z0-9_]/, '_')} = val" - end - rescue Gem::OptionParser::ParseError - end - -## initialize(*args) [](#method-i-initialize) -:nodoc: - -## options() [](#method-i-options) -Actual Gem::OptionParser object, automatically created if nonexistent. - -If called with a block, yields the Gem::OptionParser object and returns the -result of the block. If an Gem::OptionParser::ParseError exception occurs in -the block, it is rescued, a error message printed to STDERR and `nil` -returned. - -## options=(opt) [](#method-i-options=) -Sets Gem::OptionParser object, when `opt` is `false` or `nil`, methods -Gem::OptionParser::Arguable#options and Gem::OptionParser::Arguable#options= -are undefined. Thus, there is no ways to access the Gem::OptionParser object -via the receiver object. - -## order!(**keywords, &blk) [](#method-i-order!) -Parses `self` destructively in order and returns `self` containing the rest -arguments left unparsed. - -## parse!(**keywords) [](#method-i-parse!) -Parses `self` destructively and returns `self` containing the rest arguments -left unparsed. - -## permute!(**keywords) [](#method-i-permute!) -Parses `self` destructively in permutation mode and returns `self` containing -the rest arguments left unparsed. - diff --git a/example/ruby/Gem/OptionParser/CompletingHash.md b/example/ruby/Gem/OptionParser/CompletingHash.md deleted file mode 100644 index 33ee5eb..0000000 --- a/example/ruby/Gem/OptionParser/CompletingHash.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::OptionParser::CompletingHash -**Inherits:** Hash - -**Includes:** Gem::OptionParser::Completion - - -Hash with completion search feature. See Gem::OptionParser::Completion. - - - -#Instance Methods -## candidate(key, icasefalse, patnil, &_) [](#method-i-candidate) - -## complete(key, icasefalse, patnil) [](#method-i-complete) - -## convert(optnil, valnil) [](#method-i-convert) - -## match(key) [](#method-i-match) -Completion for hash key. - diff --git a/example/ruby/Gem/OptionParser/Completion.md b/example/ruby/Gem/OptionParser/Completion.md deleted file mode 100644 index 6962752..0000000 --- a/example/ruby/Gem/OptionParser/Completion.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: Gem::OptionParser::Completion - - -Keyword completion module. This allows partial arguments to be specified and -resolved against a list of acceptable values. - - -# Class Methods -## candidate(key , icase false, pat nil, &block ) [](#method-c-candidate) -## regexp(key , icase ) [](#method-c-regexp) -:nodoc: - -#Instance Methods -## candidate(key, icasefalse, patnil, &_) [](#method-i-candidate) - -## complete(key, icasefalse, patnil) [](#method-i-complete) - -## convert(optnil, valnil) [](#method-i-convert) - diff --git a/example/ruby/Gem/OptionParser/InvalidArgument.md b/example/ruby/Gem/OptionParser/InvalidArgument.md deleted file mode 100644 index 842e395..0000000 --- a/example/ruby/Gem/OptionParser/InvalidArgument.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::OptionParser::InvalidArgument -**Inherits:** Gem::OptionParser::ParseError - - -Raises when the given argument does not match required format. - - - diff --git a/example/ruby/Gem/OptionParser/InvalidOption.md b/example/ruby/Gem/OptionParser/InvalidOption.md deleted file mode 100644 index 44ad076..0000000 --- a/example/ruby/Gem/OptionParser/InvalidOption.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::OptionParser::InvalidOption -**Inherits:** Gem::OptionParser::ParseError - - -Raises when switch is undefined. - - - diff --git a/example/ruby/Gem/OptionParser/List.md b/example/ruby/Gem/OptionParser/List.md deleted file mode 100644 index 74d5183..0000000 --- a/example/ruby/Gem/OptionParser/List.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: Gem::OptionParser::List -**Inherits:** Object - - -Simple option list providing mapping from short and/or long option string to -Gem::OptionParser::Switch and mapping from acceptable argument to matching -pattern and converter pair. Also provides summary feature. - - -# Attributes -## atype[RW] [](#attribute-i-atype) -Map from acceptable argument types to pattern and converter pairs. - -## list[RW] [](#attribute-i-list) -List of all switches and summary string. - -## long[RW] [](#attribute-i-long) -Map from long style option switches to actual switch objects. - -## short[RW] [](#attribute-i-short) -Map from short style option switches to actual switch objects. - - -#Instance Methods -## accept(t, pat/.*/m, &block) [](#method-i-accept) -See Gem::OptionParser.accept. - -## add_banner(to) [](#method-i-add_banner) -:nodoc: - -## append(*args) [](#method-i-append) -Appends `switch` at the tail of the list, and associates short, long and -negated long options. Arguments are: - -`switch` -: Gem::OptionParser::Switch instance to be inserted. - -`short_opts` -: List of short style options. - -`long_opts` -: List of long style options. - -`nolong_opts` -: List of long style options with "no-" prefix. - - - append(switch, short_opts, long_opts, nolong_opts) - -## complete(id, opt, icasefalse, *pat, &block) [](#method-i-complete) -Searches list `id` for `opt` and the optional patterns for completion `pat`. -If `icase` is true, the search is case insensitive. The result is returned or -yielded if a block is given. If it isn't found, nil is returned. - -## compsys(*args, &block) [](#method-i-compsys) -:nodoc: - -## each_option(&block) [](#method-i-each_option) -Iterates over each option, passing the option to the `block`. - -## get_candidates(id) [](#method-i-get_candidates) - -**@yield** [__send__(id).keys] - -## initialize() [](#method-i-initialize) -Just initializes all instance variables. - -**@return** [List] a new instance of List - -## prepend(*args) [](#method-i-prepend) -Inserts `switch` at the head of the list, and associates short, long and -negated long options. Arguments are: - -`switch` -: Gem::OptionParser::Switch instance to be inserted. - -`short_opts` -: List of short style options. - -`long_opts` -: List of long style options. - -`nolong_opts` -: List of long style options with "no-" prefix. - - - prepend(switch, short_opts, long_opts, nolong_opts) - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## reject(t) [](#method-i-reject) -See Gem::OptionParser.reject. - -## search(id, key) [](#method-i-search) -Searches `key` in `id` list. The result is returned or yielded if a block is -given. If it isn't found, nil is returned. - -## summarize(*args, &block) [](#method-i-summarize) -Creates the summary table, passing each line to the `block` (without newline). -The arguments `args` are passed along to the summarize method which is called -on every option. - diff --git a/example/ruby/Gem/OptionParser/MissingArgument.md b/example/ruby/Gem/OptionParser/MissingArgument.md deleted file mode 100644 index cc34abe..0000000 --- a/example/ruby/Gem/OptionParser/MissingArgument.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::OptionParser::MissingArgument -**Inherits:** Gem::OptionParser::ParseError - - -Raises when a switch with mandatory argument has no argument. - - - diff --git a/example/ruby/Gem/OptionParser/NeedlessArgument.md b/example/ruby/Gem/OptionParser/NeedlessArgument.md deleted file mode 100644 index e8601a1..0000000 --- a/example/ruby/Gem/OptionParser/NeedlessArgument.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::OptionParser::NeedlessArgument -**Inherits:** Gem::OptionParser::ParseError - - -Raises when there is an argument for a switch which takes no argument. - - - diff --git a/example/ruby/Gem/OptionParser/OptionMap.md b/example/ruby/Gem/OptionParser/OptionMap.md deleted file mode 100644 index cca2d63..0000000 --- a/example/ruby/Gem/OptionParser/OptionMap.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::OptionParser::OptionMap -**Inherits:** Hash - -**Includes:** Gem::OptionParser::Completion - - -Map from option/keyword string to object with completion. - - - -#Instance Methods -## candidate(key, icasefalse, patnil, &_) [](#method-i-candidate) - -## complete(key, icasefalse, patnil) [](#method-i-complete) - -## convert(optnil, valnil) [](#method-i-convert) - diff --git a/example/ruby/Gem/OptionParser/ParseError.md b/example/ruby/Gem/OptionParser/ParseError.md deleted file mode 100644 index eb5f9a9..0000000 --- a/example/ruby/Gem/OptionParser/ParseError.md +++ /dev/null @@ -1,38 +0,0 @@ -# Exception: Gem::OptionParser::ParseError -**Inherits:** RuntimeError - - -Base class of exceptions from Gem::OptionParser. - - -# Class Methods -## filter_backtrace(array ) [](#method-c-filter_backtrace) -# Attributes -## additional[RW] [](#attribute-i-additional) -Returns the value of attribute additional. - -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## reason[RW] [](#attribute-i-reason) -Returns error reason. Override this for I18N. - - -#Instance Methods -## initialize(*args, additional:nil) [](#method-i-initialize) -:nodoc: - -**@return** [ParseError] a new instance of ParseError - -## inspect() [](#method-i-inspect) - -## message() [](#method-i-message) -Default stringizing method to emit standard error message. - -## recover(argv) [](#method-i-recover) -Pushes back erred argument(s) to `argv`. - -## set_backtrace(array) [](#method-i-set_backtrace) - -## set_option(opt, eq) [](#method-i-set_option) - diff --git a/example/ruby/Gem/OptionParser/Switch.md b/example/ruby/Gem/OptionParser/Switch.md deleted file mode 100644 index 8570c47..0000000 --- a/example/ruby/Gem/OptionParser/Switch.md +++ /dev/null @@ -1,90 +0,0 @@ -# Class: Gem::OptionParser::Switch -**Inherits:** Object - - -Individual switch class. Not important to the user. - -Defined within Switch are several Switch-derived classes: NoArgument, -RequiredArgument, etc. - - -# Class Methods -## guess(arg ) [](#method-c-guess) -Guesses argument style from `arg`. Returns corresponding -Gem::OptionParser::Switch class (OptionalArgument, etc.). -## incompatible_argument_styles(arg , t ) [](#method-c-incompatible_argument_styles) -**@raise** [ArgumentError] - -## pattern() [](#method-c-pattern) -# Attributes -## arg[RW] [](#attribute-i-arg) -:nodoc: - -## block[RW] [](#attribute-i-block) -:nodoc: - -## conv[RW] [](#attribute-i-conv) -:nodoc: - -## desc[RW] [](#attribute-i-desc) -:nodoc: - -## long[RW] [](#attribute-i-long) -:nodoc: - -## pattern[RW] [](#attribute-i-pattern) -:nodoc: - -## short[RW] [](#attribute-i-short) -:nodoc: - - -#Instance Methods -## add_banner(to) [](#method-i-add_banner) -:nodoc: - -## compsys(sdone, ldone) [](#method-i-compsys) -:nodoc: - -## initialize(patternnil, convnil, shortnil, longnil, argnil, desc([] if short or long), blocknil, &_block) [](#method-i-initialize) - -**@return** [Switch] a new instance of Switch - -## match_nonswitch?(str) [](#method-i-match_nonswitch?) -:nodoc: - -**@return** [Boolean] - -## omitted_argument(val) [](#method-i-omitted_argument) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## pretty_print_contents(q) [](#method-i-pretty_print_contents) -:nodoc: - -## summarize(sdone{}, ldone{}, width1, maxwidth - 1, indent"") [](#method-i-summarize) -Produces the summary text. Each line of the summary is yielded to the block -(without newline). - -`sdone` -: Already summarized short style options keyed hash. - -`ldone` -: Already summarized long style options keyed hash. - -`width` -: Width of left side (option part). In other words, the right side - (description part) starts after `width` columns. - -`max` -: Maximum width of left side -> the options are filled within `max` columns. - -`indent` -: Prefix string indents all summarized lines. - - -## switch_name() [](#method-i-switch_name) -Main name of the switch. - diff --git a/example/ruby/Gem/OptionParser/Switch/NoArgument.md b/example/ruby/Gem/OptionParser/Switch/NoArgument.md deleted file mode 100644 index 5b02540..0000000 --- a/example/ruby/Gem/OptionParser/Switch/NoArgument.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Gem::OptionParser::Switch::NoArgument -**Inherits:** Gem::OptionParser::Switch - - -Switch that takes no arguments. - - -# Class Methods -## incompatible_argument_styles() [](#method-c-incompatible_argument_styles) -:nodoc: -## pattern() [](#method-c-pattern) -:nodoc: - -#Instance Methods -## parse(arg, argv) [](#method-i-parse) -Raises an exception if any arguments given. - -**@yield** [NeedlessArgument, arg] - -## pretty_head() [](#method-i-pretty_head) -:nodoc: - diff --git a/example/ruby/Gem/OptionParser/Switch/OptionalArgument.md b/example/ruby/Gem/OptionParser/Switch/OptionalArgument.md deleted file mode 100644 index 59749a8..0000000 --- a/example/ruby/Gem/OptionParser/Switch/OptionalArgument.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Gem::OptionParser::Switch::OptionalArgument -**Inherits:** Gem::OptionParser::Switch - - -Switch that can omit argument. - - - -#Instance Methods -## parse(arg, argv, &error) [](#method-i-parse) -Parses argument if given, or uses default value. - -## pretty_head() [](#method-i-pretty_head) -:nodoc: - diff --git a/example/ruby/Gem/OptionParser/Switch/PlacedArgument.md b/example/ruby/Gem/OptionParser/Switch/PlacedArgument.md deleted file mode 100644 index 44a7ab1..0000000 --- a/example/ruby/Gem/OptionParser/Switch/PlacedArgument.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Gem::OptionParser::Switch::PlacedArgument -**Inherits:** Gem::OptionParser::Switch - - -Switch that takes an argument, which does not begin with '-' or is '-'. - - - -#Instance Methods -## parse(arg, argv, &error) [](#method-i-parse) -Returns nil if argument is not present or begins with '-' and is not '-'. - -## pretty_head() [](#method-i-pretty_head) -:nodoc: - diff --git a/example/ruby/Gem/OptionParser/Switch/RequiredArgument.md b/example/ruby/Gem/OptionParser/Switch/RequiredArgument.md deleted file mode 100644 index d6823f2..0000000 --- a/example/ruby/Gem/OptionParser/Switch/RequiredArgument.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Gem::OptionParser::Switch::RequiredArgument -**Inherits:** Gem::OptionParser::Switch - - -Switch that takes an argument. - - - -#Instance Methods -## parse(arg, argv, &_) [](#method-i-parse) -Raises an exception if argument is not present. - -## pretty_head() [](#method-i-pretty_head) -:nodoc: - diff --git a/example/ruby/Gem/Package.md b/example/ruby/Gem/Package.md deleted file mode 100644 index 6448a3d..0000000 --- a/example/ruby/Gem/Package.md +++ /dev/null @@ -1,254 +0,0 @@ -# Class: Gem::Package -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - -Example using a Gem::Package - -Builds a .gem file given a Gem::Specification. A .gem file is a tarball which -contains a data.tar.gz, metadata.gz, checksums.yaml.gz and possibly -signatures. - - require 'rubygems' - require 'rubygems/package' - - spec = Gem::Specification.new do |s| - s.summary = "Ruby based make-like utility." - s.name = 'rake' - s.version = PKG_VERSION - s.requirements << 'none' - s.files = PKG_FILES - s.description = <<-EOF - Rake is a Make-like program implemented in Ruby. Tasks - and dependencies are specified in standard Ruby syntax. - EOF - end - - Gem::Package.build spec - -Reads a .gem file. - - require 'rubygems' - require 'rubygems/package' - - the_gem = Gem::Package.new(path_to_dot_gem) - the_gem.contents # get the files in the gem - the_gem.extract_files destination_directory # extract the gem into a directory - the_gem.spec # get the spec out of the gem - the_gem.verify # check the gem is OK (contains valid gem specification, contains a not corrupt contents archive) - -#files are the files in the .gem tar file, not the Ruby files in the gem -#extract_files and #contents automatically call #verify - - -# Class Methods -## build(spec , skip_validation false, strict_validation false, file_name nil) [](#method-c-build) -## new(gem , security_policy nil) [](#method-c-new) -Creates a new Gem::Package for the file at `gem`. `gem` can also be provided -as an IO object. - -If `gem` is an existing file in the old format a Gem::Package::Old will be -returned. -## raw_spec(path , security_policy nil) [](#method-c-raw_spec) -Extracts the Gem::Specification and raw metadata from the .gem file at `path`. --- -# Attributes -## build_time[RW] [](#attribute-i-build_time) -:nodoc: - -## checksums[RW] [](#attribute-i-checksums) -Checksums for the contents of the package - -## data_mode[RW] [](#attribute-i-data_mode) -Permission for other files - -## dir_mode[RW] [](#attribute-i-dir_mode) -Permission for directories - -## files[RW] [](#attribute-i-files) -The files in this package. This is not the contents of the gem, just the -files in the top-level container. - -## gem[RW] [](#attribute-i-gem) -Reference to the gem being packaged. - -## prog_mode[RW] [](#attribute-i-prog_mode) -Permission for program files - -## security_policy[RW] [](#attribute-i-security_policy) -The security policy used for verifying the contents of this package. - -## spec[RW] [](#attribute-i-spec) -The spec for this gem. - -If this is a package for a built gem the spec is loaded from the gem and -returned. If this is a package for a gem being built the provided spec is -returned. - - -#Instance Methods -## add_checksums(tar) [](#method-i-add_checksums) -Adds a checksum for each entry in the gem to checksums.yaml.gz. - -## add_contents(tar) [](#method-i-add_contents) -Adds the files listed in the packages's Gem::Specification to data.tar.gz and -adds this file to the `tar`. - -## add_files(tar) [](#method-i-add_files) -Adds files included the package's Gem::Specification to the `tar` file - -## add_metadata(tar) [](#method-i-add_metadata) -Adds the package's Gem::Specification to the `tar` file - -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## build(skip_validationfalse, strict_validationfalse) [](#method-i-build) -Builds this package based on the specification set by #spec= - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## contents() [](#method-i-contents) -A list of file names contained in this gem - -## copy_stream(src, dst) [](#method-i-copy_stream) -:nodoc: - -## copy_to(path) [](#method-i-copy_to) -Copies this package to `path` (if possible) - -## digest(entry) [](#method-i-digest) -Creates a digest of the TarEntry `entry` from the digest algorithm set by the -security policy. - -## extract_files(destination_dir, pattern"*") [](#method-i-extract_files) -Extracts the files in this package into `destination_dir` - -If `pattern` is specified, only entries matching that glob will be extracted. - -## extract_tar_gz(io, destination_dir, pattern"*") [](#method-i-extract_tar_gz) -Extracts all the files in the gzipped tar archive `io` into `destination_dir`. - -If an entry in the archive contains a relative path above `destination_dir` or -an absolute path is encountered an exception is raised. - -If `pattern` is specified, only entries matching that glob will be extracted. - -## file_mode(mode) [](#method-i-file_mode) -:nodoc: - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## gzip_to(io) [](#method-i-gzip_to) -Gzips content written to `gz_io` to `io`. -- Also sets the gzip modification -time to the package build time to ease testing. - -## initialize(gem, security_policy) [](#method-i-initialize) -Creates a new package that will read or write to the file `gem`. - -**@return** [Package] a new instance of Package - -## install_location(filename, destination_dir) [](#method-i-install_location) -Returns the full path for installing `filename`. - -If `filename` is not inside `destination_dir` an exception is raised. - -**@raise** [Gem::Package::PathError] - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## limit_read(io, name, limit) [](#method-i-limit_read) - -**@raise** [Gem::Package::FormatError] - -## load_spec(entry) [](#method-i-load_spec) -Loads a Gem::Specification from the TarEntry `entry` - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## normalize_path(pathname) [](#method-i-normalize_path) - -## open_tar_gz(io) [](#method-i-open_tar_gz) -Opens `io` as a gzipped tar archive - -## read_checksums(gem) [](#method-i-read_checksums) -Reads and loads checksums.yaml.gz from the tar file `gem` - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## setup_signer(signer_options:{}) [](#method-i-setup_signer) -Prepares the gem for signing and checksum generation. If a signing -certificate and key are not present only checksum generation is set up. - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - -## verify() [](#method-i-verify) -Verifies that this gem: - -* Contains a valid gem specification -* Contains a contents archive -* The contents archive is not corrupt - -After verification the gem specification from the gem is available from #spec - -## verify_checksums(digests, checksums) [](#method-i-verify_checksums) -Verifies the `checksums` against the `digests`. This check is not -cryptographically secure. Missing checksums are ignored. - -## verify_entry(entry) [](#method-i-verify_entry) -Verifies `entry` in a .gem file. - -## verify_files(gem) [](#method-i-verify_files) -Verifies the files of the `gem` - -## verify_gz(entry) [](#method-i-verify_gz) -Verifies that `entry` is a valid gzipped file. - diff --git a/example/ruby/Gem/Package/DigestIO.md b/example/ruby/Gem/Package/DigestIO.md deleted file mode 100644 index 23df30e..0000000 --- a/example/ruby/Gem/Package/DigestIO.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: Gem::Package::DigestIO -**Inherits:** Object - - -IO wrapper that creates digests of contents written to the IO it wraps. - - -# Class Methods -## wrap(io , digests ) [](#method-c-wrap) -Wraps `io` and updates digest for each of the digest algorithms in the -`digests` Hash. Returns the digests hash. Example: - - io = StringIO.new - digests = { - 'SHA1' => OpenSSL::Digest.new('SHA1'), - 'SHA512' => OpenSSL::Digest.new('SHA512'), - } - - Gem::Package::DigestIO.wrap io, digests do |digest_io| - digest_io.write "hello" - end - - digests['SHA1'].hexdigest #=> "aaf4c61d[...]" - digests['SHA512'].hexdigest #=> "9b71d224[...]" -**@yield** [digest_io] - -# Attributes -## digests[RW] [](#attribute-i-digests) -Collected digests for wrapped writes. - - { - 'SHA1' => #, - 'SHA512' => #, - } - - -#Instance Methods -## initialize(io, digests) [](#method-i-initialize) -Creates a new DigestIO instance. Using ::wrap is recommended, see the ::wrap -documentation for documentation of `io` and `digests`. - -**@return** [DigestIO] a new instance of DigestIO - -## write(data) [](#method-i-write) -Writes `data` to the underlying IO and updates the digests - diff --git a/example/ruby/Gem/Package/Error.md b/example/ruby/Gem/Package/Error.md deleted file mode 100644 index b1440fa..0000000 --- a/example/ruby/Gem/Package/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Package::Error -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/Package/FileSource.md b/example/ruby/Gem/Package/FileSource.md deleted file mode 100644 index 9fd488b..0000000 --- a/example/ruby/Gem/Package/FileSource.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Gem::Package::FileSource -**Inherits:** Gem::Package::Source - - -The primary source of gems is a file on disk, including all usages internal to -rubygems. - -This is a private class, do not depend on it directly. Instead, pass a path -object to `Gem::Package.new`. - - -# Attributes -## path[RW] [](#attribute-i-path) -:nodoc: all - - -#Instance Methods -## initialize(path) [](#method-i-initialize) - -**@return** [FileSource] a new instance of FileSource - -## present?() [](#method-i-present?) - -**@return** [Boolean] - -## start() [](#method-i-start) - -## with_read_io(&block) [](#method-i-with_read_io) - -## with_write_io(&block) [](#method-i-with_write_io) - diff --git a/example/ruby/Gem/Package/FormatError.md b/example/ruby/Gem/Package/FormatError.md deleted file mode 100644 index 4effa47..0000000 --- a/example/ruby/Gem/Package/FormatError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Gem::Package::FormatError -**Inherits:** Gem::Package::Error - - - - -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - -#Instance Methods -## initialize(message, sourcenil) [](#method-i-initialize) - -**@return** [FormatError] a new instance of FormatError - diff --git a/example/ruby/Gem/Package/IOSource.md b/example/ruby/Gem/Package/IOSource.md deleted file mode 100644 index 474543a..0000000 --- a/example/ruby/Gem/Package/IOSource.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Gem::Package::IOSource -**Inherits:** Gem::Package::Source - - -Supports reading and writing gems from/to a generic IO object. This is useful -for other applications built on top of rubygems, such as rubygems.org. - -This is a private class, do not depend on it directly. Instead, pass an IO -object to `Gem::Package.new`. - - -# Attributes -## io[RW] [](#attribute-i-io) -:nodoc: all - - -#Instance Methods -## initialize(io) [](#method-i-initialize) - -**@return** [IOSource] a new instance of IOSource - -## path() [](#method-i-path) - -## present?() [](#method-i-present?) - -**@return** [Boolean] - -## start() [](#method-i-start) - -## with_read_io() [](#method-i-with_read_io) - -## with_write_io() [](#method-i-with_write_io) - diff --git a/example/ruby/Gem/Package/NonSeekableIO.md b/example/ruby/Gem/Package/NonSeekableIO.md deleted file mode 100644 index 482fdcb..0000000 --- a/example/ruby/Gem/Package/NonSeekableIO.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Package::NonSeekableIO -**Inherits:** Gem::Package::Error - - - - - diff --git a/example/ruby/Gem/Package/Old.md b/example/ruby/Gem/Package/Old.md deleted file mode 100644 index ef15fff..0000000 --- a/example/ruby/Gem/Package/Old.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Gem::Package::Old -**Inherits:** Gem::Package - - -The format class knows the guts of the ancient .gem file format and provides -the capability to read such ancient gems. - -Please pretend this doesn't exist. - - - -#Instance Methods -## contents() [](#method-i-contents) -A list of file names contained in this gem - -## extract_files(destination_dir) [](#method-i-extract_files) -Extracts the files in this package into `destination_dir` - -## file_list(io) [](#method-i-file_list) -Reads the file list section from the old-format gem `io` - -## initialize(gem, security_policy) [](#method-i-initialize) -Creates a new old-format package reader for `gem`. Old-format packages cannot -be written. - -**@return** [Old] a new instance of Old - -## read_until_dashes(io) [](#method-i-read_until_dashes) -Reads lines until a "---" separator is found - -## skip_ruby(io) [](#method-i-skip_ruby) -Skips the Ruby self-install header in `io`. - -**@raise** [Gem::Exception] - -## spec() [](#method-i-spec) -The specification for this gem - -## verify() [](#method-i-verify) -Raises an exception if a security policy that verifies data is active. Old -format gems cannot be verified as signed. - -**@raise** [Gem::Security::Exception] - diff --git a/example/ruby/Gem/Package/PathError.md b/example/ruby/Gem/Package/PathError.md deleted file mode 100644 index ce6f579..0000000 --- a/example/ruby/Gem/Package/PathError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::Package::PathError -**Inherits:** Gem::Package::Error - - - - - -#Instance Methods -## initialize(destination, destination_dir) [](#method-i-initialize) - -**@return** [PathError] a new instance of PathError - diff --git a/example/ruby/Gem/Package/Source.md b/example/ruby/Gem/Package/Source.md deleted file mode 100644 index 97e5b85..0000000 --- a/example/ruby/Gem/Package/Source.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Package::Source -**Inherits:** Object - - -:nodoc: - - - diff --git a/example/ruby/Gem/Package/SymlinkError.md b/example/ruby/Gem/Package/SymlinkError.md deleted file mode 100644 index 5a35468..0000000 --- a/example/ruby/Gem/Package/SymlinkError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::Package::SymlinkError -**Inherits:** Gem::Package::Error - - - - - -#Instance Methods -## initialize(name, destination, destination_dir) [](#method-i-initialize) - -**@return** [SymlinkError] a new instance of SymlinkError - diff --git a/example/ruby/Gem/Package/TarHeader.md b/example/ruby/Gem/Package/TarHeader.md deleted file mode 100644 index 1b5286f..0000000 --- a/example/ruby/Gem/Package/TarHeader.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: Gem::Package::TarHeader -**Inherits:** Object - - --- struct tarfile_entry_posix { - char name[100]; # ASCII + (Z unless filled) - char mode[8]; # 0 padded, octal, null - char uid[8]; # ditto - char gid[8]; # ditto - char size[12]; # 0 padded, octal, null - char mtime[12]; # 0 padded, octal, null - char checksum[8]; # 0 padded, octal, null, space - char typeflag[1]; # file: "0" dir: "5" - char linkname[100]; # ASCII + (Z unless filled) - char magic[6]; # "ustar\0" - char version[2]; # "00" - char uname[32]; # ASCIIZ - char gname[32]; # ASCIIZ - char devmajor[8]; # 0 padded, octal, null - char devminor[8]; # o padded, octal, null - char prefix[155]; # ASCII + (Z unless filled) - -}; ++ A header for a tar file - - -# Class Methods -## from(stream ) [](#method-c-from) -Creates a tar header from IO `stream` -## oct_or_256based(str ) [](#method-c-oct_or_256based) -## strict_oct(str ) [](#method-c-strict_oct) -**@raise** [ArgumentError] - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## empty?() [](#method-i-empty?) -Is the tar entry empty? - -**@return** [Boolean] - -## full_name() [](#method-i-full_name) -Header's full name, including prefix - -## initialize(vals) [](#method-i-initialize) -Creates a new TarHeader using `vals` - -**@return** [TarHeader] a new instance of TarHeader - -## to_s() [](#method-i-to_s) -:nodoc: - -## update_checksum() [](#method-i-update_checksum) -Updates the TarHeader's checksum - diff --git a/example/ruby/Gem/Package/TarInvalidError.md b/example/ruby/Gem/Package/TarInvalidError.md deleted file mode 100644 index eb508ec..0000000 --- a/example/ruby/Gem/Package/TarInvalidError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Package::TarInvalidError -**Inherits:** Gem::Package::Error - - -Raised when a tar file is corrupt - - - diff --git a/example/ruby/Gem/Package/TarReader.md b/example/ruby/Gem/Package/TarReader.md deleted file mode 100644 index 143029a..0000000 --- a/example/ruby/Gem/Package/TarReader.md +++ /dev/null @@ -1,2055 +0,0 @@ -# Class: Gem::Package::TarReader -**Inherits:** Object - -**Includes:** Enumerable - - -TarReader reads tar files and allows iteration over their items - - -# Class Methods -## new(io ) [](#method-c-new) -Creates a new TarReader on `io` and yields it to the block, if given. - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## close() [](#method-i-close) -Close the tar file - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Iterates over files in the tarball yielding each entry - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(io) [](#method-i-initialize) -Creates a new tar file reader on `io` which needs to respond to #pos, #eof?, -#read, #getc and #pos= - -**@return** [TarReader] a new instance of TarReader - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## rewind() [](#method-i-rewind) -NOTE: Do not call #rewind during #each - -## seek(name) [](#method-i-seek) -Seeks through the tar file until it finds the `entry` with `name` and yields -it. Rewinds the tar file to the beginning when the block terminates. - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/Package/TarReader/Entry.md b/example/ruby/Gem/Package/TarReader/Entry.md deleted file mode 100644 index cf49acb..0000000 --- a/example/ruby/Gem/Package/TarReader/Entry.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: Gem::Package::TarReader::Entry -**Inherits:** Object - -**Includes:** Gem::FixFullNameEncoding - - -Class for reading entries out of a tar file - - -# Class Methods -## open(header , io , &block ) [](#method-c-open) -Creates a new tar entry for `header` that will be read from `io` If a block is -given, the entry is yielded and then closed. -# Attributes -## header[RW] [](#attribute-i-header) -Header for this tar entry - - -#Instance Methods -## bytes_read() [](#method-i-bytes_read) -Number of bytes read out of the tar entry - -## check_closed() [](#method-i-check_closed) -:nodoc: - -**@raise** [IOError] - -## close() [](#method-i-close) -Closes the tar entry - -## closed?() [](#method-i-closed?) -Is the tar entry closed? - -**@return** [Boolean] - -## directory?() [](#method-i-directory?) -Is this tar entry a directory? - -**@return** [Boolean] - -## eof?() [](#method-i-eof?) -Are we at the end of the tar entry? - -**@return** [Boolean] - -## file?() [](#method-i-file?) -Is this tar entry a file? - -**@return** [Boolean] - -## full_name() [](#method-i-full_name) -Full name of the tar entry - -## getc() [](#method-i-getc) -Read one byte from the tar entry - -## initialize(header, io) [](#method-i-initialize) -Creates a new tar entry for `header` that will be read from `io` - -**@return** [Entry] a new instance of Entry - -## pos() [](#method-i-pos) -The position in the tar entry - -## pos=(new_pos) [](#method-i-pos=) -Seek to the position in the tar entry - -## read(maxlennil) [](#method-i-read) -Reads `maxlen` bytes from the tar file entry, or the rest of the entry if nil - -## readpartial(maxlen, outbuf"".b) [](#method-i-readpartial) - -## rewind() [](#method-i-rewind) -Rewinds to the beginning of the tar file entry - -## seek(offset, whenceIO::SEEK_SET) [](#method-i-seek) -Seeks to `offset` bytes into the tar file entry `whence` can be IO::SEEK_SET, -IO::SEEK_CUR, or IO::SEEK_END - -## size() [](#method-i-size) - -## symlink?() [](#method-i-symlink?) -Is this tar entry a symlink? - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Package/TarTestCase.md b/example/ruby/Gem/Package/TarTestCase.md deleted file mode 100644 index 576e558..0000000 --- a/example/ruby/Gem/Package/TarTestCase.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Gem::Package::TarTestCase -**Inherits:** Gem::TestCase - - -A test case for Gem::Package::Tar* classes - - - -#Instance Methods -## ASCIIZ(str, length) [](#method-i-ASCIIZ) - -## SP(s) [](#method-i-SP) - -## SP_Z(s) [](#method-i-SP_Z) - -## Z(s) [](#method-i-Z) - -## assert_headers_equal(expected, actual) [](#method-i-assert_headers_equal) - -## calc_checksum(header) [](#method-i-calc_checksum) - -## close_util_entry(entry) [](#method-i-close_util_entry) - -## header(type, fname, dname, length, mode, mtime, checksumnil, linkname"") [](#method-i-header) - -## header_with_checksum(type, fname, dname, length, mode, mtime, linkname"") [](#method-i-header_with_checksum) - -## tar_dir_header(name, prefix, mode, mtime) [](#method-i-tar_dir_header) - -## tar_file_contents(content) [](#method-i-tar_file_contents) - -## tar_file_header(fname, dname, mode, length, mtime) [](#method-i-tar_file_header) - -## tar_symlink_header(fname, dname, mode, mtime, linkname) [](#method-i-tar_symlink_header) - -## to_oct(n, pad_size) [](#method-i-to_oct) - -## util_dir_entry() [](#method-i-util_dir_entry) - -## util_entry(tar) [](#method-i-util_entry) - -## util_gem_data_tar(specnil, &block) [](#method-i-util_gem_data_tar) - -## util_symlink_entry() [](#method-i-util_symlink_entry) - -## util_tar(&block) [](#method-i-util_tar) - -## util_tar_gz(&block) [](#method-i-util_tar_gz) - diff --git a/example/ruby/Gem/Package/TarWriter.md b/example/ruby/Gem/Package/TarWriter.md deleted file mode 100644 index c36cb17..0000000 --- a/example/ruby/Gem/Package/TarWriter.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Gem::Package::TarWriter -**Inherits:** Object - - -Allows writing of tar files - - -# Class Methods -## new(io ) [](#method-c-new) -Creates a new TarWriter, yielding it if a block is given - -#Instance Methods -## add_file(name, mode) [](#method-i-add_file) -Adds file `name` with permissions `mode`, and yields an IO for writing the -file to - -**@yield** [RestrictedStream.new(@io)] - -## add_file_digest(name, mode, digest_algorithms) [](#method-i-add_file_digest) -Adds `name` with permissions `mode` to the tar, yielding `io` for writing the -file. The `digest_algorithm` is written to a read-only `name`.sum file -following the given file contents containing the digest name and hexdigest -separated by a tab. - -The created digest object is returned. - -## add_file_signed(name, mode, signer) [](#method-i-add_file_signed) -Adds `name` with permissions `mode` to the tar, yielding `io` for writing the -file. The `signer` is used to add a digest file using its digest_algorithm -per add_file_digest and a cryptographic signature in `name`.sig. If the -signer has no key only the checksum file is added. - -Returns the digest. - -## add_file_simple(name, mode, size) [](#method-i-add_file_simple) -Add file `name` with permissions `mode` `size` bytes long. Yields an IO to -write the file to. - -**@yield** [os] - -## add_symlink(name, target, mode) [](#method-i-add_symlink) -Adds symlink `name` with permissions `mode`, linking to `target`. - -## check_closed() [](#method-i-check_closed) -Raises IOError if the TarWriter is closed - -**@raise** [IOError] - -## close() [](#method-i-close) -Closes the TarWriter - -## closed?() [](#method-i-closed?) -Is the TarWriter closed? - -**@return** [Boolean] - -## flush() [](#method-i-flush) -Flushes the TarWriter's IO - -## initialize(io) [](#method-i-initialize) -Creates a new TarWriter that will write to `io` - -**@return** [TarWriter] a new instance of TarWriter - -## mkdir(name, mode) [](#method-i-mkdir) -Creates a new directory in the tar file `name` with `mode` - -## split_name(name) [](#method-i-split_name) -Splits `name` into a name and prefix that can fit in the TarHeader - diff --git a/example/ruby/Gem/Package/TarWriter/BoundedStream.md b/example/ruby/Gem/Package/TarWriter/BoundedStream.md deleted file mode 100644 index b776367..0000000 --- a/example/ruby/Gem/Package/TarWriter/BoundedStream.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Gem::Package::TarWriter::BoundedStream -**Inherits:** Object - - -IO wrapper that allows writing a limited amount of data - - -# Attributes -## limit[RW] [](#attribute-i-limit) -Maximum number of bytes that can be written - -## written[RW] [](#attribute-i-written) -Number of bytes written - - -#Instance Methods -## initialize(io, limit) [](#method-i-initialize) -Wraps `io` and allows up to `limit` bytes to be written - -**@return** [BoundedStream] a new instance of BoundedStream - -## write(data) [](#method-i-write) -Writes `data` onto the IO, raising a FileOverflow exception if the number of -bytes will be more than #limit - diff --git a/example/ruby/Gem/Package/TarWriter/FileOverflow.md b/example/ruby/Gem/Package/TarWriter/FileOverflow.md deleted file mode 100644 index 6891edf..0000000 --- a/example/ruby/Gem/Package/TarWriter/FileOverflow.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Package::TarWriter::FileOverflow -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Gem/Package/TarWriter/RestrictedStream.md b/example/ruby/Gem/Package/TarWriter/RestrictedStream.md deleted file mode 100644 index c125476..0000000 --- a/example/ruby/Gem/Package/TarWriter/RestrictedStream.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::Package::TarWriter::RestrictedStream -**Inherits:** Object - - -IO wrapper that provides only #write - - - -#Instance Methods -## initialize(io) [](#method-i-initialize) -Creates a new RestrictedStream wrapping `io` - -**@return** [RestrictedStream] a new instance of RestrictedStream - -## write(data) [](#method-i-write) -Writes `data` onto the IO - diff --git a/example/ruby/Gem/Package/TooLongFileName.md b/example/ruby/Gem/Package/TooLongFileName.md deleted file mode 100644 index 3fa5980..0000000 --- a/example/ruby/Gem/Package/TooLongFileName.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::Package::TooLongFileName -**Inherits:** Gem::Package::Error - - - - - diff --git a/example/ruby/Gem/PackageTask.md b/example/ruby/Gem/PackageTask.md deleted file mode 100644 index cf84142..0000000 --- a/example/ruby/Gem/PackageTask.md +++ /dev/null @@ -1,63 +0,0 @@ -# Class: Gem::PackageTask -**Inherits:** Rake::PackageTask - - -Create a package based upon a Gem::Specification. Gem packages, as well as -zip files and tar/gzipped packages can be produced by this task. - -In addition to the Rake targets generated by Rake::PackageTask, a -Gem::PackageTask will also generate the following tasks: - -**"*package_dir*/*name*-*version*.gem"** -: Create a RubyGems package with the given name and version. - - -Example using a Gem::Specification: - - require 'rubygems' - require 'rubygems/package_task' - - spec = Gem::Specification.new do |s| - s.summary = "Ruby based make-like utility." - s.name = 'rake' - s.version = PKG_VERSION - s.requirements << 'none' - s.files = PKG_FILES - s.description = <<-EOF - Rake is a Make-like program implemented in Ruby. Tasks - and dependencies are specified in standard Ruby syntax. - EOF - end - - Gem::PackageTask.new(spec) do |pkg| - pkg.need_zip = true - pkg.need_tar = true - end - - -# Attributes -## gem_spec[RW] [](#attribute-i-gem_spec) -Ruby Gem::Specification containing the metadata for this package. The name, -version and package_files are automatically determined from the gemspec and -don't need to be explicitly provided. - - -#Instance Methods -## define() [](#method-i-define) -Create the Rake tasks and actions specified by this Gem::PackageTask. -(`define` is automatically called if a block is given to `new`). - -## init(gem) [](#method-i-init) -Initialization tasks without the "yield self" or define operations. - -## initialize(gem_spec) [](#method-i-initialize) -Create a Gem Package task library. Automatically define the gem if a block is -given. If no block is supplied, then #define needs to be called to define the -task. - -**@return** [PackageTask] a new instance of PackageTask - -**@yield** [_self] - -**@yieldparam** [Gem::PackageTask] the object that the method was called on - diff --git a/example/ruby/Gem/PathSupport.md b/example/ruby/Gem/PathSupport.md deleted file mode 100644 index 7dbe6d3..0000000 --- a/example/ruby/Gem/PathSupport.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Gem::PathSupport -**Inherits:** Object - - -Gem::PathSupport facilitates the GEM_HOME and GEM_PATH environment settings to -the rest of RubyGems. - - -# Attributes -## home[RW] [](#attribute-i-home) -The default system path for managing Gems. - -## path[RW] [](#attribute-i-path) -Array of paths to search for Gems. - -## spec_cache_dir[RW] [](#attribute-i-spec_cache_dir) -Directory with spec cache - - -#Instance Methods -## initialize(env) [](#method-i-initialize) -Constructor. Takes a single argument which is to be treated like a hashtable, -or defaults to ENV, the system environment. - -**@return** [PathSupport] a new instance of PathSupport - diff --git a/example/ruby/Gem/Platform.md b/example/ruby/Gem/Platform.md deleted file mode 100644 index 319afd0..0000000 --- a/example/ruby/Gem/Platform.md +++ /dev/null @@ -1,87 +0,0 @@ -# Class: Gem::Platform -**Inherits:** Object - -**Extended by:** Gem::Deprecate - - -Available list of platforms for targeting Gem installations. - -See `gem help platform` for information on platform matching. - - -# Class Methods -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -## installable?(spec ) [](#method-c-installable?) -**@return** [Boolean] - -## local(refresh: false) [](#method-c-local) -## match(platform ) [](#method-c-match) -## match_gem?(platform , gem_name ) [](#method-c-match_gem?) -**@return** [Boolean] - -## match_spec?(spec ) [](#method-c-match_spec?) -**@return** [Boolean] - -## new(arch ) [](#method-c-new) -:nodoc: -## sort_priority(platform ) [](#method-c-sort_priority) -# Attributes -## cpu[RW] [](#attribute-i-cpu) -Returns the value of attribute cpu. - -## os[RW] [](#attribute-i-os) -Returns the value of attribute os. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## ==(other) [](#method-i-==) -Is `other` equal to this platform? Two platforms are equal if they have the -same CPU, OS and version. - -## ===(other) [](#method-i-===) -Does `other` match this platform? Two platforms match if they have the same -CPU, or either has a CPU of 'universal', they have the same OS, and they have -the same version, or either one has no version - -Additionally, the platform will match if the local CPU is 'arm' and the other -CPU starts with "armv" (for generic 32-bit ARM family support). - -Of note, this method is not commutative. Indeed the OS 'linux' has a special -case: the version is the libc name, yet while "no version" stands as a -wildcard for a binary gem platform (as for other OSes), for the runtime -platform "no version" stands for 'gnu'. To be able to distinguish these, the -method receiver is the gem platform, while the argument is the runtime -platform. - --- NOTE: Until it can be removed, changes to this method must also be -reflected in `bundler/lib/bundler/rubygems_ext.rb` - -## =~(other) [](#method-i-=~) -Does `other` match this platform? If `other` is a String it will be converted -to a Gem::Platform first. See #=== for matching rules. - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(arch) [](#method-i-initialize) - -**@return** [Platform] a new instance of Platform - -## normalized_linux_version() [](#method-i-normalized_linux_version) --- NOTE: Until it can be removed, changes to this method must also be -reflected in `bundler/lib/bundler/rubygems_ext.rb` - -## normalized_linux_version_ext() [](#method-i-normalized_linux_version_ext) -This is a copy of RubyGems 3.3.23 or higher `normalized_linux_method`. Once -only 3.3.23 is supported, we can use the method in RubyGems. - -## to_a() [](#method-i-to_a) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Gem/PlatformMismatch.md b/example/ruby/Gem/PlatformMismatch.md deleted file mode 100644 index b82b27d..0000000 --- a/example/ruby/Gem/PlatformMismatch.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: Gem::PlatformMismatch -**Inherits:** Gem::ErrorReason - - -Generated when trying to lookup a gem to indicate that the gem was found, but -that it isn't usable on the current platform. - -fetch and install read these and report them to the user to aid in figuring -out why a gem couldn't be installed. - - -# Attributes -## name[RW] [](#attribute-i-name) -the name of the gem - -## platforms[RW] [](#attribute-i-platforms) -The platforms that are mismatched - -## version[RW] [](#attribute-i-version) -the version - - -#Instance Methods -## add_platform(platform) [](#method-i-add_platform) -append a platform to the list of mismatched platforms. - -Platforms are added via this instead of injected via the constructor so that -we can loop over a list of mismatches and just add them rather than perform -some kind of calculation mismatch summary before creation. - -## initialize(name, version) [](#method-i-initialize) - -**@return** [PlatformMismatch] a new instance of PlatformMismatch - -## wordy() [](#method-i-wordy) -A wordy description of the error. - diff --git a/example/ruby/Gem/QueryUtils.md b/example/ruby/Gem/QueryUtils.md deleted file mode 100644 index f787496..0000000 --- a/example/ruby/Gem/QueryUtils.md +++ /dev/null @@ -1,85 +0,0 @@ -# Module: Gem::QueryUtils - -**Includes:** Gem::LocalRemoteOptions, Gem::Text, Gem::VersionOption - - - - - -#Instance Methods -## accept_uri_http() [](#method-i-accept_uri_http) -Allows Gem::OptionParser to handle HTTP URIs. - -## add_bulk_threshold_option() [](#method-i-add_bulk_threshold_option) -Add the --bulk-threshold option - -## add_clear_sources_option() [](#method-i-add_clear_sources_option) -Add the --clear-sources option - -## add_local_remote_options() [](#method-i-add_local_remote_options) -Add local/remote options to the command line parser. - -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_proxy_option() [](#method-i-add_proxy_option) -Add the --http-proxy option - -## add_query_options() [](#method-i-add_query_options) - -## add_source_option() [](#method-i-add_source_option) -Add the --source option - -## add_update_sources_option() [](#method-i-add_update_sources_option) -Add the --update-sources option - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## both?() [](#method-i-both?) -Is fetching of local and remote information enabled? - -**@return** [Boolean] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## defaults_str() [](#method-i-defaults_str) -:nodoc: - -## execute() [](#method-i-execute) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## local?() [](#method-i-local?) -Is local fetching enabled? - -**@return** [Boolean] - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## remote?() [](#method-i-remote?) -Is remote fetching enabled? - -**@return** [Boolean] - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - diff --git a/example/ruby/Gem/RemoteError.md b/example/ruby/Gem/RemoteError.md deleted file mode 100644 index 566fde7..0000000 --- a/example/ruby/Gem/RemoteError.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: Gem::RemoteError -**Inherits:** Gem::Exception - - -Signals that a remote operation cannot be conducted, probably due to not being -connected (or just not finding host). -- TODO: create a method that tests -connection to the preferred gems server. All code dealing with remote -operations will want this. Failure in that method should raise this error. - - - diff --git a/example/ruby/Gem/RemoteFetcher.md b/example/ruby/Gem/RemoteFetcher.md deleted file mode 100644 index afe23e0..0000000 --- a/example/ruby/Gem/RemoteFetcher.md +++ /dev/null @@ -1,139 +0,0 @@ -# Class: Gem::RemoteFetcher -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - -RemoteFetcher handles the details of fetching gems and gem information from a -remote source. - - -# Class Methods -## fetcher() [](#method-c-fetcher) -Cached RemoteFetcher instance. -## fetcher=(fetcher ) [](#method-c-fetcher=) -# Attributes -## headers[RW] [](#attribute-i-headers) -Returns the value of attribute headers. - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## cache_update_path(uri, pathnil, updatetrue) [](#method-i-cache_update_path) -Downloads `uri` to `path` if necessary. If no path is given, it just passes -the data. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## close_all() [](#method-i-close_all) - -## download(spec, source_uri, install_dirGem.dir) [](#method-i-download) -Moves the gem `spec` from `source_uri` to the cache dir unless it is already -there. If the source_uri is local the gem cache dir copy is always replaced. - -## download_to_cache(dependency) [](#method-i-download_to_cache) -Given a name and requirement, downloads this gem into cache and returns the -filename. Returns nil if the gem cannot be located. -- Should probably be -integrated with #download below, but that will be a larger, more encompassing -effort. -erikh - -## fetch_file(uri, *_) [](#method-i-fetch_file) -File Fetcher. Dispatched by `fetch_path`. Use it instead. - -## fetch_http(uri, last_modifiednil, headfalse, depth0) [](#method-i-fetch_http) -HTTP Fetcher. Dispatched by `fetch_path`. Use it instead. - -## fetch_path(uri, mtimenil, headfalse) [](#method-i-fetch_path) -Downloads `uri` and returns it as a String. - -## fetch_s3(uri, mtimenil, headfalse) [](#method-i-fetch_s3) - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## https?(uri) [](#method-i-https?) - -**@return** [Boolean] - -## initialize(proxynil, dnsnil, headers{}) [](#method-i-initialize) -Initialize a remote fetcher using the source URI and possible proxy -information. - -`proxy` -* [String]: explicit specification of proxy; overrides any environment - variable setting - -* nil: respect environment variables (HTTP_PROXY, HTTP_PROXY_USER, - HTTP_PROXY_PASS) - -* `:no_proxy`: ignore environment variables and _don't_ use a proxy - -`headers`: A set of additional HTTP headers to be sent to the server when - fetching the gem. - -**@return** [RemoteFetcher] a new instance of RemoteFetcher - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## request(uri, request_class, last_modifiednil) [](#method-i-request) -Performs a Gem::Net::HTTP request of type `request_class` on `uri` returning a -Gem::Net::HTTP response object. request maintains a table of persistent -connections to reduce connect overhead. - -## s3_uri_signer(uri) [](#method-i-s3_uri_signer) -we have our own signing code here to avoid a dependency on the aws-sdk gem - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/RemoteFetcher/FetchError.md b/example/ruby/Gem/RemoteFetcher/FetchError.md deleted file mode 100644 index cfb5755..0000000 --- a/example/ruby/Gem/RemoteFetcher/FetchError.md +++ /dev/null @@ -1,24 +0,0 @@ -# Exception: Gem::RemoteFetcher::FetchError -**Inherits:** Gem::Exception - - -A FetchError exception wraps up the various possible IO and HTTP failures that -could happen while downloading from the internet. - - -# Attributes -## original_uri[RW] [](#attribute-i-original_uri) -The URI which was being accessed when the exception happened. - -## uri[RW] [](#attribute-i-uri) -The URI which was being accessed when the exception happened. - - -#Instance Methods -## initialize(message, uri) [](#method-i-initialize) - -**@return** [FetchError] a new instance of FetchError - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Gem/RemoteFetcher/UnknownHostError.md b/example/ruby/Gem/RemoteFetcher/UnknownHostError.md deleted file mode 100644 index e9d0f56..0000000 --- a/example/ruby/Gem/RemoteFetcher/UnknownHostError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Gem::RemoteFetcher::UnknownHostError -**Inherits:** Gem::RemoteFetcher::FetchError - - -A FetchError that indicates that the reason for not being able to fetch data -was that the host could not be contacted - - - diff --git a/example/ruby/Gem/RemoteInstallationCancelled.md b/example/ruby/Gem/RemoteInstallationCancelled.md deleted file mode 100644 index 55f2520..0000000 --- a/example/ruby/Gem/RemoteInstallationCancelled.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::RemoteInstallationCancelled -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/RemoteInstallationSkipped.md b/example/ruby/Gem/RemoteInstallationSkipped.md deleted file mode 100644 index 24525a4..0000000 --- a/example/ruby/Gem/RemoteInstallationSkipped.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::RemoteInstallationSkipped -**Inherits:** Gem::Exception - - - - - diff --git a/example/ruby/Gem/RemoteSourceException.md b/example/ruby/Gem/RemoteSourceException.md deleted file mode 100644 index 78e97fa..0000000 --- a/example/ruby/Gem/RemoteSourceException.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::RemoteSourceException -**Inherits:** Gem::Exception - - -Represents an error communicating via HTTP. - - - diff --git a/example/ruby/Gem/Request.md b/example/ruby/Gem/Request.md deleted file mode 100644 index 4dfce32..0000000 --- a/example/ruby/Gem/Request.md +++ /dev/null @@ -1,156 +0,0 @@ -# Class: Gem::Request -**Inherits:** Object - -**Extended by:** Gem::UserInteraction - -**Includes:** Gem::UserInteraction - - - - -# Class Methods -## alert(statement , question nil) [](#method-c-alert) -Displays an alert `statement`. Asks a `question` if given. -## alert_error(statement , question nil) [](#method-c-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. -## alert_warning(statement , question nil) [](#method-c-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. -## ask(question ) [](#method-c-ask) -Asks a `question` and returns the answer. -## ask_for_password(prompt ) [](#method-c-ask_for_password) -Asks for a password with a `prompt` -## ask_yes_no(question , default nil) [](#method-c-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. -## choose_from_list(question , list ) [](#method-c-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. -## clean_text(text ) [](#method-c-clean_text) -Remove any non-printable characters and make the text suitable for printing. -## configure_connection_for_https(connection , cert_files ) [](#method-c-configure_connection_for_https) -**@raise** [Gem::Exception] - -## create_with_proxy(uri , request_class , last_modified , proxy ) [](#method-c-create_with_proxy) -Legacy. This is used in tests. -## format_text(text , wrap , indent 0) [](#method-c-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters -## get_cert_files() [](#method-c-get_cert_files) -## get_proxy_from_env(scheme "http") [](#method-c-get_proxy_from_env) -Returns a proxy URI for the given `scheme` if one is set in the environment -variables. -## levenshtein_distance(str1 , str2 ) [](#method-c-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 -## min3(a , b , c ) [](#method-c-min3) -:nodoc: -## proxy_uri(proxy ) [](#method-c-proxy_uri) -:nodoc: -## say(statement "") [](#method-c-say) -Displays the given `statement` on the standard output (or equivalent). -## terminate_interaction(exit_code 0) [](#method-c-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` -## truncate_text(text , description , max_length 100_000) [](#method-c-truncate_text) -**@raise** [ArgumentError] - -## ui() [](#method-c-ui) -See DefaultUserInteraction::ui -## ui=(new_ui ) [](#method-c-ui=) -See DefaultUserInteraction::ui= -## use_ui(new_ui , &block ) [](#method-c-use_ui) -See DefaultUserInteraction::use_ui -## verbose(msg nil) [](#method-c-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. -## verify_certificate(store_context ) [](#method-c-verify_certificate) -## verify_certificate_message(error_number , cert ) [](#method-c-verify_certificate_message) - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## cert_files() [](#method-i-cert_files) - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## connection_for(uri) [](#method-i-connection_for) -Creates or an HTTP connection based on `uri`, or retrieves an existing -connection, using a proxy if needed. - -## fetch() [](#method-i-fetch) - -**@yield** [request] - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(uri, request_class, last_modified, pool) [](#method-i-initialize) - -**@return** [Request] a new instance of Request - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## perform_request(request) [](#method-i-perform_request) -:nodoc: - -## proxy_uri() [](#method-i-proxy_uri) - -## reset(connection) [](#method-i-reset) -Resets HTTP connection `connection`. - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## user_agent() [](#method-i-user_agent) - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/Request/ConnectionPools.md b/example/ruby/Gem/Request/ConnectionPools.md deleted file mode 100644 index 0e35e68..0000000 --- a/example/ruby/Gem/Request/ConnectionPools.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Request::ConnectionPools -**Inherits:** Object - - -:nodoc: - - -# Attributes -## client[RW] [](#attribute-c-client) -Returns the value of attribute client. - - -#Instance Methods -## close_all() [](#method-i-close_all) - -## initialize(proxy_uri, cert_files) [](#method-i-initialize) - -**@return** [ConnectionPools] a new instance of ConnectionPools - -## pool_for(uri) [](#method-i-pool_for) - diff --git a/example/ruby/Gem/Request/HTTPPool.md b/example/ruby/Gem/Request/HTTPPool.md deleted file mode 100644 index baf0ec4..0000000 --- a/example/ruby/Gem/Request/HTTPPool.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Gem::Request::HTTPPool -**Inherits:** Object - - -A connection "pool" that only manages one connection for now. Provides thread -safe `checkout` and `checkin` methods. The pool consists of one connection -that corresponds to `http_args`. This class is private, do not use it. - - -# Attributes -## cert_files[RW] [](#attribute-i-cert_files) -:nodoc: - -## proxy_uri[RW] [](#attribute-i-proxy_uri) -:nodoc: - - -#Instance Methods -## checkin(connection) [](#method-i-checkin) - -## checkout() [](#method-i-checkout) - -## close_all() [](#method-i-close_all) - -## initialize(http_args, cert_files, proxy_uri) [](#method-i-initialize) - -**@return** [HTTPPool] a new instance of HTTPPool - diff --git a/example/ruby/Gem/Request/HTTPSPool.md b/example/ruby/Gem/Request/HTTPSPool.md deleted file mode 100644 index 99bf3ae..0000000 --- a/example/ruby/Gem/Request/HTTPSPool.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Request::HTTPSPool -**Inherits:** Gem::Request::HTTPPool - - -:nodoc: - - - diff --git a/example/ruby/Gem/RequestSet.md b/example/ruby/Gem/RequestSet.md deleted file mode 100644 index 0c9f57f..0000000 --- a/example/ruby/Gem/RequestSet.md +++ /dev/null @@ -1,255 +0,0 @@ -# Class: Gem::RequestSet -**Inherits:** Object - -**Includes:** Gem::TSort - - -A RequestSet groups a request to activate a set of dependencies. - - nokogiri = Gem::Dependency.new 'nokogiri', '~> 1.6' - pg = Gem::Dependency.new 'pg', '~> 0.14' - - set = Gem::RequestSet.new nokogiri, pg - - requests = set.resolve - - p requests.map { |r| r.full_name } - #=> ["nokogiri-1.6.0", "mini_portile-0.5.1", "pg-0.17.0"] - - -# Attributes -## always_install[RW] [](#attribute-i-always_install) -Array of gems to install even if already installed - -## dependencies[RW] [](#attribute-i-dependencies) -Returns the value of attribute dependencies. - -## development[RW] [](#attribute-i-development) -Returns the value of attribute development. - -## development_shallow[RW] [](#attribute-i-development_shallow) -Set to true if you want to install only direct development dependencies. - -## errors[RW] [](#attribute-i-errors) -Errors fetching gems during resolution. - -## git_set[RW] [](#attribute-i-git_set) -The set of git gems imported via load_gemdeps. - -## ignore_dependencies[RW] [](#attribute-i-ignore_dependencies) -When true, dependency resolution is not performed, only the requested gems are -installed. - -## install_dir[RW] [](#attribute-i-install_dir) -:nodoc: - -## prerelease[RW] [](#attribute-i-prerelease) -If true, allow dependencies to match prerelease gems. - -## remote[RW] [](#attribute-i-remote) -When false no remote sets are used for resolving gems. - -## resolver[RW] [](#attribute-i-resolver) -:nodoc: - -## sets[RW] [](#attribute-i-sets) -Sets used for resolution - -## soft_missing[RW] [](#attribute-i-soft_missing) -Treat missing dependencies as silent errors - -## source_set[RW] [](#attribute-i-source_set) -The set of source gems imported via load_gemdeps. - -## vendor_set[RW] [](#attribute-i-vendor_set) -The set of vendor gems imported via load_gemdeps. - - -#Instance Methods -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## gem(name, *reqs) [](#method-i-gem) -Declare that a gem of name `name` with `reqs` requirements is needed. - -## import(deps) [](#method-i-import) -Add `deps` Gem::Dependency objects to the set. - -## initialize(*deps) [](#method-i-initialize) -Creates a RequestSet for a list of Gem::Dependency objects, `deps`. You can -then #resolve and #install the resolved list of dependencies. - - nokogiri = Gem::Dependency.new 'nokogiri', '~> 1.6' - pg = Gem::Dependency.new 'pg', '~> 0.14' - - set = Gem::RequestSet.new nokogiri, pg - -**@return** [RequestSet] a new instance of RequestSet - -**@yield** [_self] - -**@yieldparam** [Gem::RequestSet] the object that the method was called on - -## install(options, &block) [](#method-i-install) -Installs gems for this RequestSet using the Gem::Installer `options`. - -If a `block` is given an activation `request` and `installer` are yielded. The -`installer` will be `nil` if a gem matching the request was already installed. - -## install_from_gemdeps(options, &block) [](#method-i-install_from_gemdeps) -Installs from the gem dependencies files in the `:gemdeps` option in -`options`, yielding to the `block` as in #install. - -If `:without_groups` is given in the `options`, those groups in the gem -dependencies file are not used. See Gem::Installer for other `options`. - -## install_hooks(requests, options) [](#method-i-install_hooks) -Call hooks on installed gems - -## install_into(dir, forcetrue, options{}) [](#method-i-install_into) - -## load_gemdeps(path, without_groups[], installingfalse) [](#method-i-load_gemdeps) -Load a dependency management file. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## resolve(setGem::Resolver::BestSet.new) [](#method-i-resolve) -Resolve the requested dependencies and return an Array of Specification -objects to be activated. - -## resolve_current() [](#method-i-resolve_current) -Resolve the requested dependencies against the gems available via Gem.path and -return an Array of Specification objects to be activated. - -## sorted_requests() [](#method-i-sorted_requests) - -## specs() [](#method-i-specs) - -## specs_in(dir) [](#method-i-specs_in) - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, Gem::TSort::Cyclic is raised. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises Gem::TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, Gem::TSort::Cyclic is raised. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## tsort_each_child(node) [](#method-i-tsort_each_child) -:nodoc: - -## tsort_each_node(&block) [](#method-i-tsort_each_node) -:nodoc: - diff --git a/example/ruby/Gem/RequestSet/GemDependencyAPI.md b/example/ruby/Gem/RequestSet/GemDependencyAPI.md deleted file mode 100644 index 8e51cc0..0000000 --- a/example/ruby/Gem/RequestSet/GemDependencyAPI.md +++ /dev/null @@ -1,294 +0,0 @@ -# Class: Gem::RequestSet::GemDependencyAPI -**Inherits:** Object - - -A semi-compatible DSL for the Bundler Gemfile and Isolate gem dependencies -files. - -To work with both the Bundler Gemfile and Isolate formats this implementation -takes some liberties to allow compatibility with each, most notably in -#source. - -A basic gem dependencies file will look like the following: - - source 'https://rubygems.org' - - gem 'rails', '3.2.14a - gem 'devise', '~> 2.1', '>= 2.1.3' - gem 'cancan' - gem 'airbrake' - gem 'pg' - -RubyGems recommends saving this as gem.deps.rb over Gemfile or Isolate. - -To install the gems in this Gemfile use `gem install -g` to install it and -create a lockfile. The lockfile will ensure that when you make changes to -your gem dependencies file a minimum amount of change is made to the -dependencies of your gems. - -RubyGems can activate all the gems in your dependencies file at startup using -the RUBYGEMS_GEMDEPS environment variable or through Gem.use_gemdeps. See -Gem.use_gemdeps for details and warnings. - -See `gem help install` and `gem help gem_dependencies` for further details. - - -# Attributes -## dependencies[RW] [](#attribute-i-dependencies) -The gems required by #gem statements in the gem.deps.rb file - -## git_set[RW] [](#attribute-i-git_set) -A set of gems that are loaded via the `:git` option to #gem - -## requires[RW] [](#attribute-i-requires) -A Hash containing gem names and files to require from those gems. - -## vendor_set[RW] [](#attribute-i-vendor_set) -A set of gems that are loaded via the `:path` option to #gem - -## without_groups[RW] [](#attribute-i-without_groups) -The groups of gems to exclude from installation - - -#Instance Methods -## find_gemspec(name, path) [](#method-i-find_gemspec) -Finds a gemspec with the given `name` that lives at `path`. - -## gem(name, *requirements) [](#method-i-gem) -:category: Gem Dependencies DSL - -:call-seq: - gem(name) - gem(name, *requirements) - gem(name, *requirements, options) - -Specifies a gem dependency with the given `name` and `requirements`. You may -also supply `options` following the `requirements` - -`options` include: - -require: -: RubyGems does not provide any autorequire features so requires in a gem - dependencies file are recorded but ignored. - - In bundler the require: option overrides the file to require during - Bundler.require. By default the name of the dependency is required in - Bundler. A single file or an Array of files may be given. - - To disable requiring any file give `false`: - - gem 'rake', require: false - - -group: -: Place the dependencies in the given dependency group. A single group or - an Array of groups may be given. - - See also #group - - -platform: -: Only install the dependency on the given platform. A single platform or - an Array of platforms may be given. - - See #platform for a list of platforms available. - - -path: -: Install this dependency from an unpacked gem in the given directory. - - gem 'modified_gem', path: 'vendor/modified_gem' - - -git: -: Install this dependency from a git repository: - - gem 'private_gem', git: 'git@my.company.example:private_gem.git' - - -gist: -: Install this dependency from the gist ID: - - gem 'bang', gist: '1232884' - - -github: -: Install this dependency from a github git repository: - - gem 'private_gem', github: 'my_company/private_gem' - - -submodules: -: Set to `true` to include submodules when fetching the git repository for - git:, gist: and github: dependencies. - - -ref: -: Use the given commit name or SHA for git:, gist: and github: dependencies. - - -branch: -: Use the given branch for git:, gist: and github: dependencies. - - -tag: -: Use the given tag for git:, gist: and github: dependencies. - - -## gem_deps_file() [](#method-i-gem_deps_file) -Returns the basename of the file the dependencies were loaded from - -## gem_git_reference(options) [](#method-i-gem_git_reference) -Handles the git options from `options` for git gem. - -Returns reference for the git gem. - -## gemspec(options{}) [](#method-i-gemspec) -:category: Gem Dependencies DSL - -Loads dependencies from a gemspec file. - -`options` include: - -name: -: The name portion of the gemspec file. Defaults to searching for any - gemspec file in the current directory. - - gemspec name: 'my_gem' - - -path: -: The path the gemspec lives in. Defaults to the current directory: - - gemspec 'my_gem', path: 'gemspecs', name: 'my_gem' - - -development_group: -: The group to add development dependencies to. By default this is - :development. Only one group may be specified. - - -## git(repository) [](#method-i-git) -:category: Gem Dependencies DSL - -Block form for specifying gems from a git `repository`. - - git 'https://github.com/rails/rails.git' do - gem 'activesupport' - gem 'activerecord' - end - -## git_source(name, &callback) [](#method-i-git_source) -Defines a custom git source that uses `name` to expand git repositories for -use in gems built from git repositories. You must provide a block that -accepts a git repository name for expansion. - -## group(*groups) [](#method-i-group) -:category: Gem Dependencies DSL - -Block form for placing a dependency in the given `groups`. - - group :development do - gem 'debugger' - end - - group :development, :test do - gem 'minitest' - end - -Groups can be excluded at install time using `gem install -g --without -development`. See `gem help install` and `gem help gem_dependencies` for -further details. - -## initialize(set, path) [](#method-i-initialize) -Creates a new GemDependencyAPI that will add dependencies to the -Gem::RequestSet `set` based on the dependency API description in `path`. - -**@return** [GemDependencyAPI] a new instance of GemDependencyAPI - -## installing=(installing) [](#method-i-installing=) -Changes the behavior of gem dependency file loading to installing mode. In -installing mode certain restrictions are ignored such as ruby version mismatch -checks. - -## load() [](#method-i-load) -Loads the gem dependency file and returns self. - -## platform(*platforms) [](#method-i-platform) -:category: Gem Dependencies DSL - -Block form for restricting gems to a set of platforms. - -The gem dependencies platform is different from Gem::Platform. A platform -gem.deps.rb platform matches on the ruby engine, the ruby version and whether -or not windows is allowed. - -:ruby, :ruby_XY -: Matches non-windows, non-jruby implementations where X and Y can be used - to match releases in the 1.8, 1.9, 2.0 or 2.1 series. - - -:mri, :mri_XY -: Matches non-windows C Ruby (Matz Ruby) or only the 1.8, 1.9, 2.0 or 2.1 - series. - - -:mingw, :mingw_XY -: Matches 32 bit C Ruby on MinGW or only the 1.8, 1.9, 2.0 or 2.1 series. - - -:x64_mingw, :x64_mingw_XY -: Matches 64 bit C Ruby on MinGW or only the 1.8, 1.9, 2.0 or 2.1 series. - - -:mswin, :mswin_XY -: Matches 32 bit C Ruby on Microsoft Windows or only the 1.8, 1.9, 2.0 or - 2.1 series. - - -:mswin64, :mswin64_XY -: Matches 64 bit C Ruby on Microsoft Windows or only the 1.8, 1.9, 2.0 or - 2.1 series. - - -:jruby, :jruby_XY -: Matches JRuby or JRuby in 1.8 or 1.9 mode. - - -:maglev -: Matches Maglev - - -:rbx -: Matches non-windows Rubinius - - -NOTE: There is inconsistency in what environment a platform matches. You may -need to read the source to know the exact details. - -## ruby(version, options{}) [](#method-i-ruby) -:category: Gem Dependencies DSL - -Restricts this gem dependencies file to the given ruby `version`. - -You may also provide `engine:` and `engine_version:` options to restrict this -gem dependencies file to a particular ruby engine and its engine version. -This matching is performed by using the RUBY_ENGINE and RUBY_ENGINE_VERSION -constants. - -**@raise** [ArgumentError] - -## source(url) [](#method-i-source) -:category: Gem Dependencies DSL - -Sets `url` as a source for gems for this dependency API. RubyGems uses the -default configured sources if no source was given. If a source is set only -that source is used. - -This method differs in behavior from Bundler: - -* The `:gemcutter`, # `:rubygems` and `:rubyforge` sources are not supported - as they are deprecated in bundler. -* The `prepend:` option is not supported. If you wish to order sources then - list them in your preferred order. - diff --git a/example/ruby/Gem/RequestSet/Lockfile.md b/example/ruby/Gem/RequestSet/Lockfile.md deleted file mode 100644 index 908e295..0000000 --- a/example/ruby/Gem/RequestSet/Lockfile.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: Gem::RequestSet::Lockfile -**Inherits:** Object - - -Parses a gem.deps.rb.lock file and constructs a LockSet containing the -dependencies found inside. If the lock file is missing no LockSet is -constructed. - - -# Class Methods -## build(request_set , gem_deps_file , dependencies nil) [](#method-c-build) -Creates a new Lockfile for the given `request_set` and `gem_deps_file` -location. -## requests_to_deps(requests ) [](#method-c-requests_to_deps) -:nodoc: -# Attributes -## platforms[RW] [](#attribute-i-platforms) -The platforms for this Lockfile - - -#Instance Methods -## add_DEPENDENCIES(out) [](#method-i-add_DEPENDENCIES) -:nodoc: - -## add_GEM(out, spec_groups) [](#method-i-add_GEM) -:nodoc: - -## add_GIT(out, git_requests) [](#method-i-add_GIT) - -## add_PATH(out, path_requests) [](#method-i-add_PATH) -:nodoc: - -## add_PLATFORMS(out) [](#method-i-add_PLATFORMS) -:nodoc: - -## initialize(request_set, gem_deps_file, dependencies) [](#method-i-initialize) - -**@return** [Lockfile] a new instance of Lockfile - -## relative_path_from(dest, base) [](#method-i-relative_path_from) -:nodoc: - -## spec_groups() [](#method-i-spec_groups) - -## to_s() [](#method-i-to_s) -The contents of the lock file. - -## write() [](#method-i-write) -Writes the lock file alongside the gem dependencies file - diff --git a/example/ruby/Gem/RequestSet/Lockfile/ParseError.md b/example/ruby/Gem/RequestSet/Lockfile/ParseError.md deleted file mode 100644 index 9c7d28d..0000000 --- a/example/ruby/Gem/RequestSet/Lockfile/ParseError.md +++ /dev/null @@ -1,25 +0,0 @@ -# Exception: Gem::RequestSet::Lockfile::ParseError -**Inherits:** Gem::Exception - - -Raised when a lockfile cannot be parsed - - -# Attributes -## column[RW] [](#attribute-i-column) -The column where the error was encountered - -## line[RW] [](#attribute-i-line) -The line where the error was encountered - -## path[RW] [](#attribute-i-path) -The location of the lock file - - -#Instance Methods -## initialize(message, column, line, path) [](#method-i-initialize) -Raises a ParseError with the given `message` which was encountered at a `line` -and `column` while parsing. - -**@return** [ParseError] a new instance of ParseError - diff --git a/example/ruby/Gem/RequestSet/Lockfile/Parser.md b/example/ruby/Gem/RequestSet/Lockfile/Parser.md deleted file mode 100644 index b3f53b8..0000000 --- a/example/ruby/Gem/RequestSet/Lockfile/Parser.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: Gem::RequestSet::Lockfile::Parser -**Inherits:** Object - - - - - -#Instance Methods -## get(expected_typesnil, expected_valuenil) [](#method-i-get) -Gets the next token for a Lockfile - -## initialize(tokenizer, set, platforms, filenamenil) [](#method-i-initialize) -Parses lockfiles - -**@return** [Parser] a new instance of Parser - -## parse() [](#method-i-parse) - -## parse_DEPENDENCIES() [](#method-i-parse_DEPENDENCIES) -:nodoc: - -## parse_GEM() [](#method-i-parse_GEM) -:nodoc: - -## parse_GIT() [](#method-i-parse_GIT) -:nodoc: - -## parse_PATH() [](#method-i-parse_PATH) -:nodoc: - -## parse_PLATFORMS() [](#method-i-parse_PLATFORMS) -:nodoc: - -## parse_dependency(name, op) [](#method-i-parse_dependency) -Parses the requirements following the dependency `name` and the `op` for the -first token of the requirements and returns a Gem::Dependency object. - diff --git a/example/ruby/Gem/RequestSet/Lockfile/Tokenizer.md b/example/ruby/Gem/RequestSet/Lockfile/Tokenizer.md deleted file mode 100644 index a7cadb7..0000000 --- a/example/ruby/Gem/RequestSet/Lockfile/Tokenizer.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Gem::RequestSet::Lockfile::Tokenizer -**Inherits:** Object - - - - -# Class Methods -## from_file(file ) [](#method-c-from_file) - -#Instance Methods -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## initialize(input, filenamenil, line0, pos0) [](#method-i-initialize) - -**@return** [Tokenizer] a new instance of Tokenizer - -## make_parser(set, platforms) [](#method-i-make_parser) - -## next_token() [](#method-i-next_token) - -## peek() [](#method-i-peek) - -## skip(type) [](#method-i-skip) - -## to_a() [](#method-i-to_a) - -## token_pos(byte_offset) [](#method-i-token_pos) -Calculates the column (by byte) and the line of the current token based on -`byte_offset`. - -## unshift(token) [](#method-i-unshift) - diff --git a/example/ruby/Gem/RequestSet/Lockfile/Tokenizer/Token.md b/example/ruby/Gem/RequestSet/Lockfile/Tokenizer/Token.md deleted file mode 100644 index de38058..0000000 --- a/example/ruby/Gem/RequestSet/Lockfile/Tokenizer/Token.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Gem::RequestSet::Lockfile::Tokenizer::Token -**Inherits:** Struct - - - - -# Attributes -## column[RW] [](#attribute-i-column) -Returns the value of attribute column - -**@return** [Object] the current value of column - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line - -**@return** [Object] the current value of line - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type - -**@return** [Object] the current value of type - -## value[RW] [](#attribute-i-value) -Returns the value of attribute value - -**@return** [Object] the current value of value - - diff --git a/example/ruby/Gem/Requirement.md b/example/ruby/Gem/Requirement.md deleted file mode 100644 index 2888bfa..0000000 --- a/example/ruby/Gem/Requirement.md +++ /dev/null @@ -1,111 +0,0 @@ -# Class: Gem::Requirement -**Inherits:** Object - - -A Requirement is a set of one or more version restrictions. It supports a few -(`=, !=, >, <, >=, <=, ~>`) different restriction operators. - -See Gem::Version for a description on how versions and requirements work -together in RubyGems. - - -# Class Methods -## create(*inputs ) [](#method-c-create) -Factory method to create a Gem::Requirement object. Input may be a Version, a -String, or nil. Intended to simplify client code. - -If the input is "weird", the default version requirement is returned. -## default() [](#method-c-default) -## default_prerelease() [](#method-c-default_prerelease) -## parse(obj ) [](#method-c-parse) -Parse `obj`, returning an `[op, version]` pair. `obj` can be a String or a -Gem::Version. - -If `obj` is a String, it can be either a full requirement specification, like -`">= 1.2"`, or a simple version number, like `"1.2"`. - - parse("> 1.0") # => [">", Gem::Version.new("1.0")] - parse("1.0") # => ["=", Gem::Version.new("1.0")] - parse(Gem::Version.new("1.0")) # => ["=, Gem::Version.new("1.0")] -## source_set() [](#method-c-source_set) -A source set requirement, used for Gemfiles and lockfiles -# Attributes -## requirements[RW] [](#attribute-i-requirements) -An array of requirement pairs. The first element of the pair is the op, and -the second is the Gem::Version. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## as_list() [](#method-i-as_list) -:nodoc: - -## concat(new) [](#method-i-concat) -Concatenates the `new` requirements onto this requirement. - -## encode_with(coder) [](#method-i-encode_with) -:nodoc: - -## exact?() [](#method-i-exact?) -true if the requirement is for only an exact version - -**@return** [Boolean] - -## for_lockfile() [](#method-i-for_lockfile) -Formats this requirement for use in a Gem::RequestSet::Lockfile. - -## hash() [](#method-i-hash) -:nodoc: - -## init_with(coder) [](#method-i-init_with) -:nodoc: - -## initialize(*requirements) [](#method-i-initialize) -Constructs a requirement from `requirements`. Requirements can be Strings, -Gem::Versions, or Arrays of those. `nil` and duplicate requirements are -ignored. An empty set of `requirements` is the same as `">= 0"`. - -**@return** [Requirement] a new instance of Requirement - -## marshal_dump() [](#method-i-marshal_dump) -:nodoc: - -## marshal_load(array) [](#method-i-marshal_load) -:nodoc: - -**@raise** [TypeError] - -## none?() [](#method-i-none?) -true if this gem has no requirements. - -**@return** [Boolean] - -## prerelease?() [](#method-i-prerelease?) -A requirement is a prerelease if any of the versions inside of it are -prereleases - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## satisfied_by?(version) [](#method-i-satisfied_by?) -True if `version` satisfies this Requirement. - -**@raise** [ArgumentError] - -**@return** [Boolean] - -## specific?() [](#method-i-specific?) -True if the requirement will not always match the latest version. - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) -:nodoc: - -## yaml_initialize(tag, vals) [](#method-i-yaml_initialize) -:nodoc: - diff --git a/example/ruby/Gem/Requirement/BadRequirementError.md b/example/ruby/Gem/Requirement/BadRequirementError.md deleted file mode 100644 index ab4a9bd..0000000 --- a/example/ruby/Gem/Requirement/BadRequirementError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Requirement::BadRequirementError -**Inherits:** ArgumentError - - -Raised when a bad requirement is encountered - - - diff --git a/example/ruby/Gem/Resolv.md b/example/ruby/Gem/Resolv.md deleted file mode 100644 index 732774c..0000000 --- a/example/ruby/Gem/Resolv.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: Gem::Resolv -**Inherits:** Object - - -Gem::Resolv is a thread-aware DNS resolver library written in Ruby. -Gem::Resolv can handle multiple DNS requests concurrently without blocking the -entire Ruby interpreter. - -See also resolv-replace.rb to replace the libc resolver with Gem::Resolv. - -Gem::Resolv can look up various DNS resources using the DNS module directly. - -Examples: - - p Gem::Resolv.getaddress "www.ruby-lang.org" - p Gem::Resolv.getname "210.251.121.214" - - Gem::Resolv::DNS.open do |dns| - ress = dns.getresources "www.ruby-lang.org", Gem::Resolv::DNS::Resource::IN::A - p ress.map(&:address) - ress = dns.getresources "ruby-lang.org", Gem::Resolv::DNS::Resource::IN::MX - p ress.map { |r| [r.exchange.to_s, r.preference] } - end - -## Bugs - -* NIS is not supported. -* /etc/nsswitch.conf is not supported. - - -# Class Methods -## each_address(name , &block ) [](#method-c-each_address) -Iterates over all IP addresses for `name`. -## each_name(address , &proc ) [](#method-c-each_name) -Iterates over all hostnames for `address`. -## getaddress(name ) [](#method-c-getaddress) -Looks up the first IP address for `name`. -## getaddresses(name ) [](#method-c-getaddresses) -Looks up all IP address for `name`. -## getname(address ) [](#method-c-getname) -Looks up the hostname of `address`. -## getnames(address ) [](#method-c-getnames) -Looks up all hostnames for `address`. - -#Instance Methods -## each_address(name) [](#method-i-each_address) -Iterates over all IP addresses for `name`. - -## each_name(address) [](#method-i-each_name) -Iterates over all hostnames for `address`. - -## getaddress(name) [](#method-i-getaddress) -Looks up the first IP address for `name`. - -**@raise** [ResolvError] - -## getaddresses(name) [](#method-i-getaddresses) -Looks up all IP address for `name`. - -## getname(address) [](#method-i-getname) -Looks up the hostname of `address`. - -**@raise** [ResolvError] - -## getnames(address) [](#method-i-getnames) -Looks up all hostnames for `address`. - -## initialize(resolvers(arg_not_set = true; nil), use_ipv6:(keyword_not_set = true; nil)) [](#method-i-initialize) -Creates a new Gem::Resolv using `resolvers`. - -If `resolvers` is not given, a hash, or `nil`, uses a Hosts resolver and and a -DNS resolver. If `resolvers` is a hash, uses the hash as configuration for -the DNS resolver. - -**@return** [Resolv] a new instance of Resolv - diff --git a/example/ruby/Gem/Resolv/DNS.md b/example/ruby/Gem/Resolv/DNS.md deleted file mode 100644 index b0b396f..0000000 --- a/example/ruby/Gem/Resolv/DNS.md +++ /dev/null @@ -1,166 +0,0 @@ -# Class: Gem::Resolv::DNS -**Inherits:** Object - - -Gem::Resolv::DNS is a DNS stub resolver. - -Information taken from the following places: - -* STD0013 -* RFC 1035 -* ftp://ftp.isi.edu/in-notes/iana/assignments/dns-parameters -* etc. - - -# Class Methods -## allocate_request_id(host , port ) [](#method-c-allocate_request_id) -:nodoc: -## bind_random_port(udpsock , bind_host "0.0.0.0") [](#method-c-bind_random_port) -:nodoc: -## free_request_id(host , port , id ) [](#method-c-free_request_id) -:nodoc: -## open(*args ) [](#method-c-open) -Creates a new DNS resolver. See Gem::Resolv::DNS.new for argument details. - -Yields the created DNS resolver to the block, if given, otherwise returns it. -## random(arg ) [](#method-c-random) -:nodoc: - -#Instance Methods -## close() [](#method-i-close) -Closes the DNS resolver. - -## each_address(name) [](#method-i-each_address) -Iterates over all IP addresses for `name` retrieved from the DNS resolver. - -`name` can be a Gem::Resolv::DNS::Name or a String. Retrieved addresses will -be a Gem::Resolv::IPv4 or Gem::Resolv::IPv6 - -## each_name(address) [](#method-i-each_name) -Iterates over all hostnames for `address` retrieved from the DNS resolver. - -`address` must be a Gem::Resolv::IPv4, Gem::Resolv::IPv6 or a String. -Retrieved names will be Gem::Resolv::DNS::Name instances. - -## each_resource(name, typeclass, &proc) [](#method-i-each_resource) -Iterates over all `typeclass` DNS resources for `name`. See #getresource for -argument details. - -## extract_resources(msg, name, typeclass) [](#method-i-extract_resources) -:nodoc: - -## fetch_resource(name, typeclass) [](#method-i-fetch_resource) - -## getaddress(name) [](#method-i-getaddress) -Gets the IP address of `name` from the DNS resolver. - -`name` can be a Gem::Resolv::DNS::Name or a String. Retrieved address will be -a Gem::Resolv::IPv4 or Gem::Resolv::IPv6 - -**@raise** [ResolvError] - -## getaddresses(name) [](#method-i-getaddresses) -Gets all IP addresses for `name` from the DNS resolver. - -`name` can be a Gem::Resolv::DNS::Name or a String. Retrieved addresses will -be a Gem::Resolv::IPv4 or Gem::Resolv::IPv6 - -## getname(address) [](#method-i-getname) -Gets the hostname for `address` from the DNS resolver. - -`address` must be a Gem::Resolv::IPv4, Gem::Resolv::IPv6 or a String. -Retrieved name will be a Gem::Resolv::DNS::Name. - -**@raise** [ResolvError] - -## getnames(address) [](#method-i-getnames) -Gets all hostnames for `address` from the DNS resolver. - -`address` must be a Gem::Resolv::IPv4, Gem::Resolv::IPv6 or a String. -Retrieved names will be Gem::Resolv::DNS::Name instances. - -## getresource(name, typeclass) [](#method-i-getresource) -Look up the `typeclass` DNS resource of `name`. - -`name` must be a Gem::Resolv::DNS::Name or a String. - -`typeclass` should be one of the following: - -* Gem::Resolv::DNS::Resource::IN::A -* Gem::Resolv::DNS::Resource::IN::AAAA -* Gem::Resolv::DNS::Resource::IN::ANY -* Gem::Resolv::DNS::Resource::IN::CNAME -* Gem::Resolv::DNS::Resource::IN::HINFO -* Gem::Resolv::DNS::Resource::IN::MINFO -* Gem::Resolv::DNS::Resource::IN::MX -* Gem::Resolv::DNS::Resource::IN::NS -* Gem::Resolv::DNS::Resource::IN::PTR -* Gem::Resolv::DNS::Resource::IN::SOA -* Gem::Resolv::DNS::Resource::IN::TXT -* Gem::Resolv::DNS::Resource::IN::WKS - -Returned resource is represented as a Gem::Resolv::DNS::Resource instance, -i.e. Gem::Resolv::DNS::Resource::IN::A. - -**@raise** [ResolvError] - -## getresources(name, typeclass) [](#method-i-getresources) -Looks up all `typeclass` DNS resources for `name`. See #getresource for -argument details. - -## initialize(config_infonil) [](#method-i-initialize) -Creates a new DNS resolver. - -`config_info` can be: - -nil -: Uses /etc/resolv.conf. - -String -: Path to a file using /etc/resolv.conf's format. - -Hash -: Must contain :nameserver, :search and :ndots keys. - -:nameserver_port can be used to specify port number of nameserver address. -:raise_timeout_errors can be used to raise timeout errors as exceptions -instead of treating the same as an NXDOMAIN response. - -The value of :nameserver should be an address string or an array of address -strings. -* :nameserver => '8.8.8.8' -* :nameserver => ['8.8.8.8', '8.8.4.4'] - -The value of :nameserver_port should be an array of pair of nameserver address -and port number. -* :nameserver_port => [['8.8.8.8', 53], ['8.8.4.4', 53]] - -Example: - - Gem::Resolv::DNS.new(:nameserver => ['210.251.121.21'], - :search => ['ruby-lang.org'], - :ndots => 1) - -**@return** [DNS] a new instance of DNS - -## lazy_initialize() [](#method-i-lazy_initialize) -:nodoc: - -## make_tcp_requester(host, port) [](#method-i-make_tcp_requester) -:nodoc: - -## make_udp_requester() [](#method-i-make_udp_requester) -:nodoc: - -## timeouts=(values) [](#method-i-timeouts=) -Sets the resolver timeouts. This may be a single positive number or an array -of positive numbers representing timeouts in seconds. If an array is -specified, a DNS request will retry and wait for each successive interval in -the array until a successful response is received. Specifying `nil` reverts -to the default timeouts: -5, second = 5 * 2 / nameserver_count, 2 * second, 4 * second -: Example: - - dns.timeouts = 3 - - diff --git a/example/ruby/Gem/Resolv/DNS/Config.md b/example/ruby/Gem/Resolv/DNS/Config.md deleted file mode 100644 index 68513f4..0000000 --- a/example/ruby/Gem/Resolv/DNS/Config.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Gem::Resolv::DNS::Config -**Inherits:** Object - - -:nodoc: - - -# Class Methods -## default_config_hash(filename "/etc/resolv.conf") [](#method-c-default_config_hash) -## parse_resolv_conf(filename ) [](#method-c-parse_resolv_conf) - -#Instance Methods -## generate_candidates(name) [](#method-i-generate_candidates) - -## generate_timeouts() [](#method-i-generate_timeouts) - -## initialize(config_infonil) [](#method-i-initialize) - -**@return** [Config] a new instance of Config - -## lazy_initialize() [](#method-i-lazy_initialize) - -## nameserver_port() [](#method-i-nameserver_port) - -## resolv(name) [](#method-i-resolv) - -## single?() [](#method-i-single?) - -**@return** [Boolean] - -## timeouts=(values) [](#method-i-timeouts=) - -## use_ipv6?() [](#method-i-use_ipv6?) - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Resolv/DNS/Config/NXDomain.md b/example/ruby/Gem/Resolv/DNS/Config/NXDomain.md deleted file mode 100644 index adc6bbc..0000000 --- a/example/ruby/Gem/Resolv/DNS/Config/NXDomain.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Resolv::DNS::Config::NXDomain -**Inherits:** Gem::Resolv::ResolvError - - -Indicates no such domain was found. - - - diff --git a/example/ruby/Gem/Resolv/DNS/Config/OtherResolvError.md b/example/ruby/Gem/Resolv/DNS/Config/OtherResolvError.md deleted file mode 100644 index 70b164b..0000000 --- a/example/ruby/Gem/Resolv/DNS/Config/OtherResolvError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Resolv::DNS::Config::OtherResolvError -**Inherits:** Gem::Resolv::ResolvError - - -Indicates some other unhandled resolver error was encountered. - - - diff --git a/example/ruby/Gem/Resolv/DNS/DecodeError.md b/example/ruby/Gem/Resolv/DNS/DecodeError.md deleted file mode 100644 index 197519b..0000000 --- a/example/ruby/Gem/Resolv/DNS/DecodeError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Resolv::DNS::DecodeError -**Inherits:** StandardError - - -Indicates that the DNS response was unable to be decoded. - - - diff --git a/example/ruby/Gem/Resolv/DNS/EncodeError.md b/example/ruby/Gem/Resolv/DNS/EncodeError.md deleted file mode 100644 index 90b93ca..0000000 --- a/example/ruby/Gem/Resolv/DNS/EncodeError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Resolv::DNS::EncodeError -**Inherits:** StandardError - - -Indicates that the DNS request was unable to be encoded. - - - diff --git a/example/ruby/Gem/Resolv/DNS/Label.md b/example/ruby/Gem/Resolv/DNS/Label.md deleted file mode 100644 index b0e20bc..0000000 --- a/example/ruby/Gem/Resolv/DNS/Label.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::Resolv::DNS::Label - - -:nodoc: - - -# Class Methods -## split(arg ) [](#method-c-split) - diff --git a/example/ruby/Gem/Resolv/DNS/Label/Str.md b/example/ruby/Gem/Resolv/DNS/Label/Str.md deleted file mode 100644 index ab6fc32..0000000 --- a/example/ruby/Gem/Resolv/DNS/Label/Str.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Gem::Resolv::DNS::Label::Str -**Inherits:** Object - - -:nodoc: - - -# Attributes -## downcase[RW] [](#attribute-i-downcase) -Returns the value of attribute downcase. - -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(string) [](#method-i-initialize) - -**@return** [Str] a new instance of Str - -## inspect() [](#method-i-inspect) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Gem/Resolv/DNS/Message.md b/example/ruby/Gem/Resolv/DNS/Message.md deleted file mode 100644 index 164077d..0000000 --- a/example/ruby/Gem/Resolv/DNS/Message.md +++ /dev/null @@ -1,74 +0,0 @@ -# Class: Gem::Resolv::DNS::Message -**Inherits:** Object - - -:nodoc: - - -# Class Methods -## decode(m ) [](#method-c-decode) -# Attributes -## aa[RW] [](#attribute-i-aa) -Returns the value of attribute aa. - -## additional[RW] [](#attribute-i-additional) -Returns the value of attribute additional. - -## answer[RW] [](#attribute-i-answer) -Returns the value of attribute answer. - -## authority[RW] [](#attribute-i-authority) -Returns the value of attribute authority. - -## id[RW] [](#attribute-i-id) -Returns the value of attribute id. - -## opcode[RW] [](#attribute-i-opcode) -Returns the value of attribute opcode. - -## qr[RW] [](#attribute-i-qr) -Returns the value of attribute qr. - -## question[RW] [](#attribute-i-question) -Returns the value of attribute question. - -## ra[RW] [](#attribute-i-ra) -Returns the value of attribute ra. - -## rcode[RW] [](#attribute-i-rcode) -Returns the value of attribute rcode. - -## rd[RW] [](#attribute-i-rd) -Returns the value of attribute rd. - -## tc[RW] [](#attribute-i-tc) -Returns the value of attribute tc. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## add_additional(name, ttl, data) [](#method-i-add_additional) - -## add_answer(name, ttl, data) [](#method-i-add_answer) - -## add_authority(name, ttl, data) [](#method-i-add_authority) - -## add_question(name, typeclass) [](#method-i-add_question) - -## each_additional() [](#method-i-each_additional) - -## each_answer() [](#method-i-each_answer) - -## each_authority() [](#method-i-each_authority) - -## each_question() [](#method-i-each_question) - -## each_resource() [](#method-i-each_resource) - -## encode() [](#method-i-encode) - -## initialize(id(@@identifier += 1) & 0xffff) [](#method-i-initialize) - -**@return** [Message] a new instance of Message - diff --git a/example/ruby/Gem/Resolv/DNS/Message/MessageDecoder.md b/example/ruby/Gem/Resolv/DNS/Message/MessageDecoder.md deleted file mode 100644 index 6ee50ad..0000000 --- a/example/ruby/Gem/Resolv/DNS/Message/MessageDecoder.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Gem::Resolv::DNS::Message::MessageDecoder -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## get_bytes(len@limit - @index) [](#method-i-get_bytes) - -**@raise** [DecodeError] - -## get_label() [](#method-i-get_label) - -## get_labels() [](#method-i-get_labels) - -## get_length16() [](#method-i-get_length16) - -## get_list() [](#method-i-get_list) - -## get_name() [](#method-i-get_name) - -## get_question() [](#method-i-get_question) - -## get_rr() [](#method-i-get_rr) - -## get_string() [](#method-i-get_string) - -**@raise** [DecodeError] - -## get_string_list() [](#method-i-get_string_list) - -## get_unpack(template) [](#method-i-get_unpack) - -**@raise** [DecodeError] - -## initialize(data) [](#method-i-initialize) - -**@return** [MessageDecoder] a new instance of MessageDecoder - -**@yield** [_self] - -**@yieldparam** [Gem::Resolv::DNS::Message::MessageDecoder] the object that the method was called on - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/Gem/Resolv/DNS/Message/MessageEncoder.md b/example/ruby/Gem/Resolv/DNS/Message/MessageEncoder.md deleted file mode 100644 index 978edec..0000000 --- a/example/ruby/Gem/Resolv/DNS/Message/MessageEncoder.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Gem::Resolv::DNS::Message::MessageEncoder -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MessageEncoder] a new instance of MessageEncoder - -**@yield** [_self] - -**@yieldparam** [Gem::Resolv::DNS::Message::MessageEncoder] the object that the method was called on - -## put_bytes(d) [](#method-i-put_bytes) - -## put_label(d) [](#method-i-put_label) - -## put_labels(d, compress:true) [](#method-i-put_labels) - -## put_length16() [](#method-i-put_length16) - -## put_name(d, compress:true) [](#method-i-put_name) - -## put_pack(template, *d) [](#method-i-put_pack) - -## put_string(d) [](#method-i-put_string) - -## put_string_list(ds) [](#method-i-put_string_list) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Gem/Resolv/DNS/Name.md b/example/ruby/Gem/Resolv/DNS/Name.md deleted file mode 100644 index f4b1b3f..0000000 --- a/example/ruby/Gem/Resolv/DNS/Name.md +++ /dev/null @@ -1,75 +0,0 @@ -# Class: Gem::Resolv::DNS::Name -**Inherits:** Object - - -A representation of a DNS name. - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new DNS name from `arg`. `arg` can be: - -Name -: returns `arg`. - -String -: Creates a new Name. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## [](i) [](#method-i-[]) -:nodoc: - -## absolute?() [](#method-i-absolute?) -True if this name is absolute. - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(labels, absolutetrue) [](#method-i-initialize) -:nodoc: - -**@return** [Name] a new instance of Name - -## inspect() [](#method-i-inspect) -:nodoc: - -## length() [](#method-i-length) -:nodoc: - -## subdomain_of?(other) [](#method-i-subdomain_of?) -Returns true if `other` is a subdomain. - -Example: - - domain = Gem::Resolv::DNS::Name.create("y.z") - p Gem::Resolv::DNS::Name.create("w.x.y.z").subdomain_of?(domain) #=> true - p Gem::Resolv::DNS::Name.create("x.y.z").subdomain_of?(domain) #=> true - p Gem::Resolv::DNS::Name.create("y.z").subdomain_of?(domain) #=> false - p Gem::Resolv::DNS::Name.create("z").subdomain_of?(domain) #=> false - p Gem::Resolv::DNS::Name.create("x.y.z.").subdomain_of?(domain) #=> false - p Gem::Resolv::DNS::Name.create("w.z").subdomain_of?(domain) #=> false - -**@raise** [ArgumentError] - -**@return** [Boolean] - -## to_a() [](#method-i-to_a) -:nodoc: - -## to_s() [](#method-i-to_s) -returns the domain name as a string. - -The domain name doesn't have a trailing dot even if the name object is -absolute. - -Example: - - p Gem::Resolv::DNS::Name.create("x.y.z.").to_s #=> "x.y.z" - p Gem::Resolv::DNS::Name.create("x.y.z").to_s #=> "x.y.z" - diff --git a/example/ruby/Gem/Resolv/DNS/OpCode.md b/example/ruby/Gem/Resolv/DNS/OpCode.md deleted file mode 100644 index 9de1031..0000000 --- a/example/ruby/Gem/Resolv/DNS/OpCode.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Resolv::DNS::OpCode - - -:nodoc: - - - diff --git a/example/ruby/Gem/Resolv/DNS/Query.md b/example/ruby/Gem/Resolv/DNS/Query.md deleted file mode 100644 index ffe1313..0000000 --- a/example/ruby/Gem/Resolv/DNS/Query.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Resolv::DNS::Query -**Inherits:** Object - - -A DNS query abstract class. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -**@raise** [DecodeError] - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -**@raise** [EncodeError] - diff --git a/example/ruby/Gem/Resolv/DNS/RCode.md b/example/ruby/Gem/Resolv/DNS/RCode.md deleted file mode 100644 index 72dad5d..0000000 --- a/example/ruby/Gem/Resolv/DNS/RCode.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Resolv::DNS::RCode - - -:nodoc: - - - diff --git a/example/ruby/Gem/Resolv/DNS/Requester.md b/example/ruby/Gem/Resolv/DNS/Requester.md deleted file mode 100644 index b783b18..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize() [](#method-i-initialize) - -**@return** [Requester] a new instance of Requester - -## request(sender, tout) [](#method-i-request) - -## sender_for(addr, msg) [](#method-i-sender_for) - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/ConnectedUDP.md b/example/ruby/Gem/Resolv/DNS/Requester/ConnectedUDP.md deleted file mode 100644 index fa54093..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/ConnectedUDP.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester::ConnectedUDP -**Inherits:** Gem::Resolv::DNS::Requester - - -:nodoc: - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize(host, portPort) [](#method-i-initialize) - -**@return** [ConnectedUDP] a new instance of ConnectedUDP - -## lazy_initialize() [](#method-i-lazy_initialize) - -## recv_reply(readable_socks) [](#method-i-recv_reply) - -## sender(msg, data, host@host, port@port) [](#method-i-sender) - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/ConnectedUDP/Sender.md b/example/ruby/Gem/Resolv/DNS/Requester/ConnectedUDP/Sender.md deleted file mode 100644 index 93069ea..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/ConnectedUDP/Sender.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester::ConnectedUDP::Sender -**Inherits:** Gem::Resolv::DNS::Requester::Sender - - -:nodoc: - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## send() [](#method-i-send) - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/MDNSOneShot.md b/example/ruby/Gem/Resolv/DNS/Requester/MDNSOneShot.md deleted file mode 100644 index cf8259a..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/MDNSOneShot.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester::MDNSOneShot -**Inherits:** Gem::Resolv::DNS::Requester::UnconnectedUDP - - -:nodoc: - - - -#Instance Methods -## sender(msg, data, host, portPort) [](#method-i-sender) - -## sender_for(addr, msg) [](#method-i-sender_for) - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/RequestError.md b/example/ruby/Gem/Resolv/DNS/Requester/RequestError.md deleted file mode 100644 index f1b6d03..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/RequestError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Resolv::DNS::Requester::RequestError -**Inherits:** StandardError - - -Indicates a problem with the DNS request. - - - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/Sender.md b/example/ruby/Gem/Resolv/DNS/Requester/Sender.md deleted file mode 100644 index 5510d4e..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/Sender.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester::Sender -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## initialize(msg, data, sock) [](#method-i-initialize) - -**@return** [Sender] a new instance of Sender - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/TCP.md b/example/ruby/Gem/Resolv/DNS/Requester/TCP.md deleted file mode 100644 index 2689d7a..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/TCP.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester::TCP -**Inherits:** Gem::Resolv::DNS::Requester - - -:nodoc: - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize(host, portPort) [](#method-i-initialize) - -**@return** [TCP] a new instance of TCP - -## recv_reply(readable_socks) [](#method-i-recv_reply) - -## sender(msg, data, host@host, port@port) [](#method-i-sender) - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/TCP/Sender.md b/example/ruby/Gem/Resolv/DNS/Requester/TCP/Sender.md deleted file mode 100644 index 6a08501..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/TCP/Sender.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester::TCP::Sender -**Inherits:** Gem::Resolv::DNS::Requester::Sender - - -:nodoc: - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## send() [](#method-i-send) - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/UnconnectedUDP.md b/example/ruby/Gem/Resolv/DNS/Requester/UnconnectedUDP.md deleted file mode 100644 index ef3742d..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/UnconnectedUDP.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester::UnconnectedUDP -**Inherits:** Gem::Resolv::DNS::Requester - - -:nodoc: - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize(*nameserver_port) [](#method-i-initialize) - -**@return** [UnconnectedUDP] a new instance of UnconnectedUDP - -## lazy_initialize() [](#method-i-lazy_initialize) - -## recv_reply(readable_socks) [](#method-i-recv_reply) - -## sender(msg, data, host, portPort) [](#method-i-sender) - diff --git a/example/ruby/Gem/Resolv/DNS/Requester/UnconnectedUDP/Sender.md b/example/ruby/Gem/Resolv/DNS/Requester/UnconnectedUDP/Sender.md deleted file mode 100644 index 04bc90b..0000000 --- a/example/ruby/Gem/Resolv/DNS/Requester/UnconnectedUDP/Sender.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::Resolv::DNS::Requester::UnconnectedUDP::Sender -**Inherits:** Gem::Resolv::DNS::Requester::Sender - - -:nodoc: - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## initialize(msg, data, sock, host, port) [](#method-i-initialize) - -**@return** [Sender] a new instance of Sender - -## send() [](#method-i-send) - diff --git a/example/ruby/Gem/Resolv/DNS/Resource.md b/example/ruby/Gem/Resolv/DNS/Resource.md deleted file mode 100644 index 45ca94e..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource -**Inherits:** Gem::Resolv::DNS::Query - - -A DNS resource abstract class. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -**@raise** [NotImplementedError] - -## get_class(type_value , class_value ) [](#method-c-get_class) -:nodoc: -# Attributes -## ttl[RW] [](#attribute-i-ttl) -Remaining Time To Live for this Resource. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -**@raise** [NotImplementedError] - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/ANY.md b/example/ruby/Gem/Resolv/DNS/Resource/ANY.md deleted file mode 100644 index b4464cc..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/ANY.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::ANY -**Inherits:** Gem::Resolv::DNS::Query - - -A Query type requesting any RR. - - - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/CAA.md b/example/ruby/Gem/Resolv/DNS/Resource/CAA.md deleted file mode 100644 index a087975..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/CAA.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::CAA -**Inherits:** Gem::Resolv::DNS::Resource - - -CAA resource record defined in RFC 8659 - -These records identify certificate authority allowed to issue certificates for -the given domain. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## flags[RW] [](#attribute-i-flags) -Flags for this proprty: -* Bit 0 : 0 = not critical, 1 = critical - -## tag[RW] [](#attribute-i-tag) -Property tag ("issue", "issuewild", "iodef"...). - -## value[RW] [](#attribute-i-value) -Property value. - - -#Instance Methods -## critical?() [](#method-i-critical?) -Whether the critical flag is set on this property. - -**@return** [Boolean] - -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(flags, tag, value) [](#method-i-initialize) -Creates a new CAA for `flags`, `tag` and `value`. - -**@return** [CAA] a new instance of CAA - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/CNAME.md b/example/ruby/Gem/Resolv/DNS/Resource/CNAME.md deleted file mode 100644 index ebcc8f9..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/CNAME.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::CNAME -**Inherits:** Gem::Resolv::DNS::Resource::DomainName - - -The canonical name for an alias. - - - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/DomainName.md b/example/ruby/Gem/Resolv/DNS/Resource/DomainName.md deleted file mode 100644 index 9009865..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/DomainName.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::DomainName -**Inherits:** Gem::Resolv::DNS::Resource - - -Domain Name resource abstract class. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## name[RW] [](#attribute-i-name) -The name of this DomainName. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(name) [](#method-i-initialize) -Creates a new DomainName from `name`. - -**@return** [DomainName] a new instance of DomainName - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/Generic.md b/example/ruby/Gem/Resolv/DNS/Resource/Generic.md deleted file mode 100644 index 035ae0e..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/Generic.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::Generic -**Inherits:** Gem::Resolv::DNS::Resource - - -A generic resource abstract class. - - -# Class Methods -## create(type_value , class_value ) [](#method-c-create) -:nodoc: -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## data[RW] [](#attribute-i-data) -Data for this generic resource. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(data) [](#method-i-initialize) -Creates a new generic resource. - -**@return** [Generic] a new instance of Generic - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/HINFO.md b/example/ruby/Gem/Resolv/DNS/Resource/HINFO.md deleted file mode 100644 index af988bc..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/HINFO.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::HINFO -**Inherits:** Gem::Resolv::DNS::Resource - - -Host Information resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## cpu[RW] [](#attribute-i-cpu) -CPU architecture for this resource. - -## os[RW] [](#attribute-i-os) -Operating system for this resource. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(cpu, os) [](#method-i-initialize) -Creates a new HINFO running `os` on `cpu`. - -**@return** [HINFO] a new instance of HINFO - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/IN.md b/example/ruby/Gem/Resolv/DNS/Resource/IN.md deleted file mode 100644 index 49c9f1f..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/IN.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::Resolv::DNS::Resource::IN - - -module IN contains ARPA Internet specific RRs. - - - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/IN/A.md b/example/ruby/Gem/Resolv/DNS/Resource/IN/A.md deleted file mode 100644 index 7f73763..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/IN/A.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::IN::A -**Inherits:** Gem::Resolv::DNS::Resource - - -IPv4 Address resource - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## address[RW] [](#attribute-i-address) -The Gem::Resolv::IPv4 address for this A. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(address) [](#method-i-initialize) -Creates a new A for `address`. - -**@return** [A] a new instance of A - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/IN/AAAA.md b/example/ruby/Gem/Resolv/DNS/Resource/IN/AAAA.md deleted file mode 100644 index ec65a8b..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/IN/AAAA.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::IN::AAAA -**Inherits:** Gem::Resolv::DNS::Resource - - -An IPv6 address record. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## address[RW] [](#attribute-i-address) -The Gem::Resolv::IPv6 address for this AAAA. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(address) [](#method-i-initialize) -Creates a new AAAA for `address`. - -**@return** [AAAA] a new instance of AAAA - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/IN/HTTPS.md b/example/ruby/Gem/Resolv/DNS/Resource/IN/HTTPS.md deleted file mode 100644 index 0355d06..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/IN/HTTPS.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::IN::HTTPS -**Inherits:** Gem::Resolv::DNS::Resource::IN::ServiceBinding - - -HTTPS resource record [RFC9460] - - - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/IN/SRV.md b/example/ruby/Gem/Resolv/DNS/Resource/IN/SRV.md deleted file mode 100644 index 920b3e7..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/IN/SRV.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::IN::SRV -**Inherits:** Gem::Resolv::DNS::Resource - - -SRV resource record defined in RFC 2782 - -These records identify the hostname and port that a service is available at. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## port[RW] [](#attribute-i-port) -The port on this target host of this service. - -The range is 0-65535. - -## priority[RW] [](#attribute-i-priority) -The priority of this target host. - -A client MUST attempt to contact the target host with the lowest-numbered -priority it can reach; target hosts with the same priority SHOULD be tried in -an order defined by the weight field. The range is 0-65535. Note that it is -not widely implemented and should be set to zero. - -## target[RW] [](#attribute-i-target) -The domain name of the target host. - -A target of "." means that the service is decidedly not available at this -domain. - -## weight[RW] [](#attribute-i-weight) -A server selection mechanism. - -The weight field specifies a relative weight for entries with the same -priority. Larger weights SHOULD be given a proportionately higher probability -of being selected. The range of this number is 0-65535. Domain administrators -SHOULD use Weight 0 when there isn't any server selection to do, to make the -RR easier to read for humans (less noisy). Note that it is not widely -implemented and should be set to zero. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(priority, weight, port, target) [](#method-i-initialize) -Create a SRV resource record. - -See the documentation for #priority, #weight, #port and #target for -`priority`, `weight`, +port and `target` respectively. - -**@return** [SRV] a new instance of SRV - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/IN/SVCB.md b/example/ruby/Gem/Resolv/DNS/Resource/IN/SVCB.md deleted file mode 100644 index c439912..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/IN/SVCB.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::IN::SVCB -**Inherits:** Gem::Resolv::DNS::Resource::IN::ServiceBinding - - -SVCB resource record [RFC9460] - - - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/IN/ServiceBinding.md b/example/ruby/Gem/Resolv/DNS/Resource/IN/ServiceBinding.md deleted file mode 100644 index 4bb25ad..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/IN/ServiceBinding.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::IN::ServiceBinding -**Inherits:** Object - - -Common implementation for SVCB-compatible resource records. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## params[RW] [](#attribute-i-params) -The service parameters for the target host. - -## priority[RW] [](#attribute-i-priority) -The priority of this target host. - -The range is 0-65535. If set to 0, this RR is in AliasMode. Otherwise, it is -in ServiceMode. - -## target[RW] [](#attribute-i-target) -The domain name of the target host. - - -#Instance Methods -## alias_mode?() [](#method-i-alias_mode?) -Whether this RR is in AliasMode. - -**@return** [Boolean] - -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(priority, target, params[]) [](#method-i-initialize) -Create a service binding resource record. - -**@return** [ServiceBinding] a new instance of ServiceBinding - -## service_mode?() [](#method-i-service_mode?) -Whether this RR is in ServiceMode. - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/IN/WKS.md b/example/ruby/Gem/Resolv/DNS/Resource/IN/WKS.md deleted file mode 100644 index d4d421b..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/IN/WKS.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::IN::WKS -**Inherits:** Gem::Resolv::DNS::Resource - - -Well Known Service resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## address[RW] [](#attribute-i-address) -The host these services run on. - -## bitmap[RW] [](#attribute-i-bitmap) -A bit map of enabled services on this host. - -If protocol is 6 (TCP) then the 26th bit corresponds to the SMTP service (port -25). If this bit is set, then an SMTP server should be listening on TCP port -25; if zero, SMTP service is not supported. - -## protocol[RW] [](#attribute-i-protocol) -IP protocol number for these services. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(address, protocol, bitmap) [](#method-i-initialize) - -**@return** [WKS] a new instance of WKS - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/LOC.md b/example/ruby/Gem/Resolv/DNS/Resource/LOC.md deleted file mode 100644 index e780e86..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/LOC.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::LOC -**Inherits:** Gem::Resolv::DNS::Resource - - -Location resource - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## altitude[RW] [](#attribute-i-altitude) -The altitude of the LOC above a reference sphere whose surface sits 100km -below the WGS84 spheroid in centimeters as an unsigned 32bit integer - -## hprecision[RW] [](#attribute-i-hprecision) -The horizontal precision using ssize type values in meters using scientific -notation as 2 integers of XeY for precision use value/2 e.g. 2m = +/-1m - -## latitude[RW] [](#attribute-i-latitude) -The latitude for this LOC where 2**31 is the equator in thousandths of an arc -second as an unsigned 32bit integer - -## longitude[RW] [](#attribute-i-longitude) -The longitude for this LOC where 2**31 is the prime meridian in thousandths of -an arc second as an unsigned 32bit integer - -## ssize[RW] [](#attribute-i-ssize) -The spherical size of this LOC in meters using scientific notation as 2 -integers of XeY - -## version[RW] [](#attribute-i-version) -Returns the version value for this LOC record which should always be 00 - -## vprecision[RW] [](#attribute-i-vprecision) -The vertical precision using ssize type values in meters using scientific -notation as 2 integers of XeY for precision use value/2 e.g. 2m = +/-1m - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(version, ssize, hprecision, vprecision, latitude, longitude, altitude) [](#method-i-initialize) - -**@return** [LOC] a new instance of LOC - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/MINFO.md b/example/ruby/Gem/Resolv/DNS/Resource/MINFO.md deleted file mode 100644 index 629962d..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/MINFO.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::MINFO -**Inherits:** Gem::Resolv::DNS::Resource - - -Mailing list or mailbox information. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## emailbx[RW] [](#attribute-i-emailbx) -Mailbox to use for error messages related to the mail list or mailbox. - -## rmailbx[RW] [](#attribute-i-rmailbx) -Domain name responsible for this mail list or mailbox. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(rmailbx, emailbx) [](#method-i-initialize) - -**@return** [MINFO] a new instance of MINFO - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/MX.md b/example/ruby/Gem/Resolv/DNS/Resource/MX.md deleted file mode 100644 index 874a844..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/MX.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::MX -**Inherits:** Gem::Resolv::DNS::Resource - - -Mail Exchanger resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## exchange[RW] [](#attribute-i-exchange) -The host of this MX. - -## preference[RW] [](#attribute-i-preference) -The preference for this MX. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(preference, exchange) [](#method-i-initialize) -Creates a new MX record with `preference`, accepting mail at `exchange`. - -**@return** [MX] a new instance of MX - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/NS.md b/example/ruby/Gem/Resolv/DNS/Resource/NS.md deleted file mode 100644 index 216489e..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/NS.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::NS -**Inherits:** Gem::Resolv::DNS::Resource::DomainName - - -An authoritative name server. - - - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/PTR.md b/example/ruby/Gem/Resolv/DNS/Resource/PTR.md deleted file mode 100644 index dd22a25..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/PTR.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::PTR -**Inherits:** Gem::Resolv::DNS::Resource::DomainName - - -A Pointer to another DNS name. - - - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/SOA.md b/example/ruby/Gem/Resolv/DNS/Resource/SOA.md deleted file mode 100644 index 98f4b66..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/SOA.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::SOA -**Inherits:** Gem::Resolv::DNS::Resource - - -Start Of Authority resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## expire[RW] [](#attribute-i-expire) -Time in seconds that a secondary name server is to use the data before -refreshing from the primary name server. - -## minimum[RW] [](#attribute-i-minimum) -The minimum number of seconds to be used for TTL values in RRs. - -## mname[RW] [](#attribute-i-mname) -Name of the host where the master zone file for this zone resides. - -## refresh[RW] [](#attribute-i-refresh) -How often, in seconds, a secondary name server is to check for updates from -the primary name server. - -## retry[RW] [](#attribute-i-retry) -How often, in seconds, a secondary name server is to retry after a failure to -check for a refresh. - -## rname[RW] [](#attribute-i-rname) -The person responsible for this domain name. - -## serial[RW] [](#attribute-i-serial) -The version number of the zone file. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(mname, rname, serial, refresh, retry_, expire, minimum) [](#method-i-initialize) -Creates a new SOA record. See the attr documentation for the details of each -argument. - -**@return** [SOA] a new instance of SOA - diff --git a/example/ruby/Gem/Resolv/DNS/Resource/TXT.md b/example/ruby/Gem/Resolv/DNS/Resource/TXT.md deleted file mode 100644 index d97697e..0000000 --- a/example/ruby/Gem/Resolv/DNS/Resource/TXT.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Gem::Resolv::DNS::Resource::TXT -**Inherits:** Gem::Resolv::DNS::Resource - - -Unstructured text resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## strings[RW] [](#attribute-i-strings) -Returns an Array of Strings for this TXT record. - - -#Instance Methods -## data() [](#method-i-data) -Returns the concatenated string from `strings`. - -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(first_string, *rest_strings) [](#method-i-initialize) - -**@return** [TXT] a new instance of TXT - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam.md b/example/ruby/Gem/Resolv/DNS/SvcParam.md deleted file mode 100644 index dc35edd..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam -**Inherits:** Object - - -Base class for SvcParam. [RFC9460] - - -# Class Methods -## key_name() [](#method-c-key_name) -Get the presentation name of the SvcParamKey. -## key_number() [](#method-c-key_number) -Get the registered number of the SvcParamKey. - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam/ALPN.md b/example/ruby/Gem/Resolv/DNS/SvcParam/ALPN.md deleted file mode 100644 index ce64003..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam/ALPN.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam::ALPN -**Inherits:** Gem::Resolv::DNS::SvcParam - - -"alpn" SvcParam -- Additional supported protocols - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## protocol_ids[RW] [](#attribute-i-protocol_ids) -Supported protocol IDs. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(protocol_ids) [](#method-i-initialize) -Initialize "alpn" ScvParam. - -**@return** [ALPN] a new instance of ALPN - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam/DoHPath.md b/example/ruby/Gem/Resolv/DNS/SvcParam/DoHPath.md deleted file mode 100644 index 54d5f33..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam/DoHPath.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam::DoHPath -**Inherits:** Gem::Resolv::DNS::SvcParam - - -"dohpath" SvcParam -- DNS over HTTPS path template [RFC9461] - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## template[RW] [](#attribute-i-template) -URI template for DoH queries. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(template) [](#method-i-initialize) -Initialize "dohpath" ScvParam. - -**@return** [DoHPath] a new instance of DoHPath - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam/Generic.md b/example/ruby/Gem/Resolv/DNS/SvcParam/Generic.md deleted file mode 100644 index 7564033..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam/Generic.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam::Generic -**Inherits:** Gem::Resolv::DNS::SvcParam - - -Generic SvcParam abstract class. - - -# Class Methods -## create(key_number ) [](#method-c-create) -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## value[RW] [](#attribute-i-value) -SvcParamValue in wire-format byte string. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(value) [](#method-i-initialize) -Create generic SvcParam - -**@return** [Generic] a new instance of Generic - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam/IPv4Hint.md b/example/ruby/Gem/Resolv/DNS/SvcParam/IPv4Hint.md deleted file mode 100644 index 412dd19..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam/IPv4Hint.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam::IPv4Hint -**Inherits:** Gem::Resolv::DNS::SvcParam - - -"ipv4hint" SvcParam -- IPv4 address hints - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## addresses[RW] [](#attribute-i-addresses) -Set of IPv4 addresses. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(addresses) [](#method-i-initialize) -Initialize "ipv4hint" ScvParam. - -**@return** [IPv4Hint] a new instance of IPv4Hint - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam/IPv6Hint.md b/example/ruby/Gem/Resolv/DNS/SvcParam/IPv6Hint.md deleted file mode 100644 index eb4b956..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam/IPv6Hint.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam::IPv6Hint -**Inherits:** Gem::Resolv::DNS::SvcParam - - -"ipv6hint" SvcParam -- IPv6 address hints - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## addresses[RW] [](#attribute-i-addresses) -Set of IPv6 addresses. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(addresses) [](#method-i-initialize) -Initialize "ipv6hint" ScvParam. - -**@return** [IPv6Hint] a new instance of IPv6Hint - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam/Mandatory.md b/example/ruby/Gem/Resolv/DNS/SvcParam/Mandatory.md deleted file mode 100644 index 6b0236d..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam/Mandatory.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam::Mandatory -**Inherits:** Gem::Resolv::DNS::SvcParam - - -"mandatory" SvcParam -- Mandatory keys in service binding RR - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## keys[RW] [](#attribute-i-keys) -Mandatory keys. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(keys) [](#method-i-initialize) -Initialize "mandatory" ScvParam. - -**@return** [Mandatory] a new instance of Mandatory - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam/NoDefaultALPN.md b/example/ruby/Gem/Resolv/DNS/SvcParam/NoDefaultALPN.md deleted file mode 100644 index 344637a..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam/NoDefaultALPN.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam::NoDefaultALPN -**Inherits:** Gem::Resolv::DNS::SvcParam - - -"no-default-alpn" SvcParam -- No support for default protocol - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParam/Port.md b/example/ruby/Gem/Resolv/DNS/SvcParam/Port.md deleted file mode 100644 index 3bfebf2..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParam/Port.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParam::Port -**Inherits:** Gem::Resolv::DNS::SvcParam - - -"port" SvcParam -- Port for alternative endpoint - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## port[RW] [](#attribute-i-port) -Port number. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(port) [](#method-i-initialize) -Initialize "port" ScvParam. - -**@return** [Port] a new instance of Port - diff --git a/example/ruby/Gem/Resolv/DNS/SvcParams.md b/example/ruby/Gem/Resolv/DNS/SvcParams.md deleted file mode 100644 index c2c149f..0000000 --- a/example/ruby/Gem/Resolv/DNS/SvcParams.md +++ /dev/null @@ -1,2078 +0,0 @@ -# Class: Gem::Resolv::DNS::SvcParams -**Inherits:** Object - -**Includes:** Enumerable - - -SvcParams for service binding RRs. [RFC9460] - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: - -#Instance Methods -## [](key) [](#method-i-[]) -Get SvcParam for the given `key` in this list. - -## add(param) [](#method-i-add) -Add the SvcParam `param` to this list, overwriting the existing one with the -same key. - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count() [](#method-i-count) -Get the number of SvcParams in this list. - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete(key) [](#method-i-delete) -Remove the `SvcParam` with the given `key` and return it. - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) -Enumerate the +SvcParam+s in this list. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Get whether this list is empty. - -**@return** [Boolean] - -## encode(msg) [](#method-i-encode) -:nodoc: - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(params[]) [](#method-i-initialize) -Create a list of SvcParams with the given initial content. - -`params` has to be an enumerable of +SvcParam+s. If its content has -+SvcParam+s with the duplicate key, the one appears last takes precedence. - -**@return** [SvcParams] a new instance of SvcParams - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/Resolv/Hosts.md b/example/ruby/Gem/Resolv/Hosts.md deleted file mode 100644 index 7f9653f..0000000 --- a/example/ruby/Gem/Resolv/Hosts.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Gem::Resolv::Hosts -**Inherits:** Object - - -Gem::Resolv::Hosts is a hostname resolver that uses the system hosts file. - - - -#Instance Methods -## each_address(name, &proc) [](#method-i-each_address) -Iterates over all IP addresses for `name` retrieved from the hosts file. - -## each_name(address, &proc) [](#method-i-each_name) -Iterates over all hostnames for `address` retrieved from the hosts file. - -## getaddress(name) [](#method-i-getaddress) -Gets the IP address of `name` from the hosts file. - -**@raise** [ResolvError] - -## getaddresses(name) [](#method-i-getaddresses) -Gets all IP addresses for `name` from the hosts file. - -## getname(address) [](#method-i-getname) -Gets the hostname of `address` from the hosts file. - -**@raise** [ResolvError] - -## getnames(address) [](#method-i-getnames) -Gets all hostnames for `address` from the hosts file. - -## initialize(filenameDefaultFileName) [](#method-i-initialize) -Creates a new Gem::Resolv::Hosts, using `filename` for its data source. - -**@return** [Hosts] a new instance of Hosts - -## lazy_initialize() [](#method-i-lazy_initialize) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/IPv4.md b/example/ruby/Gem/Resolv/IPv4.md deleted file mode 100644 index 74c501d..0000000 --- a/example/ruby/Gem/Resolv/IPv4.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Gem::Resolv::IPv4 -**Inherits:** Object - - -A Gem::Resolv::DNS IPv4 address. - - -# Class Methods -## create(arg ) [](#method-c-create) -# Attributes -## address[RW] [](#attribute-i-address) -The raw IPv4 address as a String. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(address) [](#method-i-initialize) -:nodoc: - -**@return** [IPv4] a new instance of IPv4 - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_name() [](#method-i-to_name) -Turns this IPv4 address into a Gem::Resolv::DNS::Name. - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/IPv6.md b/example/ruby/Gem/Resolv/IPv6.md deleted file mode 100644 index 78df650..0000000 --- a/example/ruby/Gem/Resolv/IPv6.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Gem::Resolv::IPv6 -**Inherits:** Object - - -A Gem::Resolv::DNS IPv6 address. - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new IPv6 address from `arg` which may be: - -IPv6 -: returns `arg`. - -String -: `arg` must match one of the IPv6::Regex* constants - -# Attributes -## address[RW] [](#attribute-i-address) -The raw IPv6 address as a String. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(address) [](#method-i-initialize) -:nodoc: - -**@return** [IPv6] a new instance of IPv6 - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_name() [](#method-i-to_name) -Turns this IPv6 address into a Gem::Resolv::DNS::Name. -- ip6.arpa should be -searched too. [RFC3152] - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/LOC.md b/example/ruby/Gem/Resolv/LOC.md deleted file mode 100644 index fc6c136..0000000 --- a/example/ruby/Gem/Resolv/LOC.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Gem::Resolv::LOC - - - - - diff --git a/example/ruby/Gem/Resolv/LOC/Alt.md b/example/ruby/Gem/Resolv/LOC/Alt.md deleted file mode 100644 index 85643d8..0000000 --- a/example/ruby/Gem/Resolv/LOC/Alt.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Gem::Resolv::LOC::Alt -**Inherits:** Object - - -A Gem::Resolv::LOC::Alt - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new LOC::Alt from `arg` which may be: - -LOC::Alt -: returns `arg`. - -String -: `arg` must match the LOC::Alt::Regex constant - -# Attributes -## altitude[RW] [](#attribute-i-altitude) -The raw altitude - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(altitude) [](#method-i-initialize) - -**@return** [Alt] a new instance of Alt - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/LOC/Coord.md b/example/ruby/Gem/Resolv/LOC/Coord.md deleted file mode 100644 index e4d11de..0000000 --- a/example/ruby/Gem/Resolv/LOC/Coord.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Gem::Resolv::LOC::Coord -**Inherits:** Object - - -A Gem::Resolv::LOC::Coord - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new LOC::Coord from `arg` which may be: - -LOC::Coord -: returns `arg`. - -String -: `arg` must match the LOC::Coord::Regex constant - -# Attributes -## coordinates[RW] [](#attribute-i-coordinates) -The raw coordinates - -## orientation[RW] [](#attribute-i-orientation) -The orientation of the hemisphere as 'lat' or 'lon' - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(coordinates, orientation) [](#method-i-initialize) - -**@return** [Coord] a new instance of Coord - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/LOC/Size.md b/example/ruby/Gem/Resolv/LOC/Size.md deleted file mode 100644 index 4d5b409..0000000 --- a/example/ruby/Gem/Resolv/LOC/Size.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Gem::Resolv::LOC::Size -**Inherits:** Object - - -A Gem::Resolv::LOC::Size - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new LOC::Size from `arg` which may be: - -LOC::Size -: returns `arg`. - -String -: `arg` must match the LOC::Size::Regex constant - -# Attributes -## scalar[RW] [](#attribute-i-scalar) -The raw size - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(scalar) [](#method-i-initialize) - -**@return** [Size] a new instance of Size - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/MDNS.md b/example/ruby/Gem/Resolv/MDNS.md deleted file mode 100644 index fdca919..0000000 --- a/example/ruby/Gem/Resolv/MDNS.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Gem::Resolv::MDNS -**Inherits:** Gem::Resolv::DNS - - -Gem::Resolv::MDNS is a one-shot Multicast DNS (mDNS) resolver. It blindly -makes queries to the mDNS addresses without understanding anything about -multicast ports. - -Information taken form the following places: - -* RFC 6762 - - - -#Instance Methods -## each_address(name) [](#method-i-each_address) -Iterates over all IP addresses for `name` retrieved from the mDNS resolver, -provided name ends with "local". If the name does not end in "local" no -records will be returned. - -`name` can be a Gem::Resolv::DNS::Name or a String. Retrieved addresses will -be a Gem::Resolv::IPv4 or Gem::Resolv::IPv6 - -## initialize(config_infonil) [](#method-i-initialize) -Creates a new one-shot Multicast DNS (mDNS) resolver. - -`config_info` can be: - -nil -: Uses the default mDNS addresses - - -Hash -: Must contain :nameserver or :nameserver_port like - Gem::Resolv::DNS#initialize. - - -**@return** [MDNS] a new instance of MDNS - -## make_udp_requester() [](#method-i-make_udp_requester) -:nodoc: - diff --git a/example/ruby/Gem/Resolv/ResolvError.md b/example/ruby/Gem/Resolv/ResolvError.md deleted file mode 100644 index 341935d..0000000 --- a/example/ruby/Gem/Resolv/ResolvError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Resolv::ResolvError -**Inherits:** StandardError - - -Indicates a failure to resolve a name or address. - - - diff --git a/example/ruby/Gem/Resolv/ResolvTimeout.md b/example/ruby/Gem/Resolv/ResolvTimeout.md deleted file mode 100644 index 2a1b533..0000000 --- a/example/ruby/Gem/Resolv/ResolvTimeout.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Resolv::ResolvTimeout -**Inherits:** Gem::Timeout::Error - - -Indicates a timeout resolving a name or address. - - - diff --git a/example/ruby/Gem/Resolver.md b/example/ruby/Gem/Resolver.md deleted file mode 100644 index 32e97ac..0000000 --- a/example/ruby/Gem/Resolver.md +++ /dev/null @@ -1,149 +0,0 @@ -# Class: Gem::Resolver -**Inherits:** Object - -**Includes:** Gem::Molinillo::SpecificationProvider, Gem::Molinillo::UI - - -Given a set of Gem::Dependency objects as `needed` and a way to query the set -of available specs via `set`, calculates a set of ActivationRequest objects -which indicate all the specs that should be activated to meet the all the -requirements. - - -# Class Methods -## compose_sets(*sets ) [](#method-c-compose_sets) -Combines `sets` into a ComposedSet that allows specification lookup in a -uniform manner. If one of the `sets` is itself a ComposedSet its sets are -flattened into the result ComposedSet. -## for_current_gems(needed ) [](#method-c-for_current_gems) -Creates a Resolver that queries only against the already installed gems for -the `needed` dependencies. -# Attributes -## development[RW] [](#attribute-i-development) -Set to true if all development dependencies should be considered. - -## development_shallow[RW] [](#attribute-i-development_shallow) -Set to true if immediate development dependencies should be considered. - -## ignore_dependencies[RW] [](#attribute-i-ignore_dependencies) -When true, no dependencies are looked up for requested gems. - -## skip_gems[RW] [](#attribute-i-skip_gems) -Hash of gems to skip resolution. Keyed by gem name, with arrays of gem -specifications as values. - -## soft_missing[RW] [](#attribute-i-soft_missing) -Returns the value of attribute soft_missing. - -## stats[RW] [](#attribute-i-stats) -List of dependencies that could not be found in the configured sources. - - -#Instance Methods -## activation_request(dep, possible) [](#method-i-activation_request) -Creates an ActivationRequest for the given `dep` and the last `possible` -specification. - -Returns the Specification and the ActivationRequest - -## after_resolution() [](#method-i-after_resolution) -Called after resolution ends (either successfully or with an error). By -default, prints a newline. - -**@return** [void] - -## allow_missing?(dependency) [](#method-i-allow_missing?) - -**@return** [Boolean] - -## before_resolution() [](#method-i-before_resolution) -Called before resolution begins. - -**@return** [void] - -## debug(depth0) [](#method-i-debug) -Conveys debug information to the user. - -**@param** [Integer] the current depth of the resolution process. - -**@return** [void] - -## debug?() [](#method-i-debug?) - -**@return** [Boolean] - -## dependencies_equal?(dependencies, other_dependencies) [](#method-i-dependencies_equal?) -Determines whether two arrays of dependencies are equal, and thus can be -grouped. - -**@param** [Array] - -**@param** [Array] - -**@return** [Boolean] whether `dependencies` and `other_dependencies` should -be considered equal. - -## dependencies_for(specification) [](#method-i-dependencies_for) - -## explain(stage, *data) [](#method-i-explain) -:nodoc: - -## explain_list(stage) [](#method-i-explain_list) -:nodoc: - -## find_possible(dependency) [](#method-i-find_possible) -Extracts the specifications that may be able to fulfill `dependency` and -returns those that match the local platform and all those that match. - -## indicate_progress() [](#method-i-indicate_progress) -Called roughly every {#progress_rate}, this method should convey progress to -the user. - -**@return** [void] - -## initialize(needed, setnil) [](#method-i-initialize) -Create Resolver object which will resolve the tree starting with `needed` -Dependency objects. - -`set` is an object that provides where to look for specifications to satisfy -the Dependencies. This defaults to IndexSet, which will query rubygems.org. - -**@return** [Resolver] a new instance of Resolver - -## name_for(dependency) [](#method-i-name_for) - -## name_for_explicit_dependency_source() [](#method-i-name_for_explicit_dependency_source) - -**@return** [String] the name of the source of explicit dependencies, i.e. -those passed to {Resolver#resolve} directly. - -## name_for_locking_dependency_source() [](#method-i-name_for_locking_dependency_source) - -**@return** [String] the name of the source of 'locked' dependencies, i.e. -those passed to {Resolver#resolve} directly as the `base` - -## output() [](#method-i-output) - -## progress_rate() [](#method-i-progress_rate) -How often progress should be conveyed to the user via {#indicate_progress}, in -seconds. A third of a second, by default. - -**@return** [Float] - -## requests(s, act, reqs[]) [](#method-i-requests) -:nodoc: - -## requirement_satisfied_by?(requirement, activated, spec) [](#method-i-requirement_satisfied_by?) - -**@return** [Boolean] - -## resolve() [](#method-i-resolve) -Proceed with resolution! Returns an array of ActivationRequest objects. - -## search_for(dependency) [](#method-i-search_for) - -## select_local_platforms(specs) [](#method-i-select_local_platforms) -Returns the gems in `specs` that match the local platform. - -## sort_dependencies(dependencies, activated, conflicts) [](#method-i-sort_dependencies) - diff --git a/example/ruby/Gem/Resolver/APISet.md b/example/ruby/Gem/Resolver/APISet.md deleted file mode 100644 index 1d25cb2..0000000 --- a/example/ruby/Gem/Resolver/APISet.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: Gem::Resolver::APISet -**Inherits:** Gem::Resolver::Set - - -The global rubygems pool, available via the rubygems.org API. Returns -instances of APISpecification. - - -# Attributes -## dep_uri[RW] [](#attribute-i-dep_uri) -The URI for the dependency API this APISet uses. - -## source[RW] [](#attribute-i-source) -The Gem::Source that gems are fetched from - -## uri[RW] [](#attribute-i-uri) -The corresponding place to fetch gems. - - -#Instance Methods -## find_all(req) [](#method-i-find_all) -Return an array of APISpecification objects matching DependencyRequest `req`. - -## initialize(dep_uri"https://index.rubygems.org/info/") [](#method-i-initialize) -Creates a new APISet that will retrieve gems from `uri` using the RubyGems API -URL `dep_uri` which is described at -https://guides.rubygems.org/rubygems-org-api - -**@return** [APISet] a new instance of APISet - -## prefetch(reqs) [](#method-i-prefetch) -A hint run by the resolver to allow the Set to fetch data for -DependencyRequests `reqs`. - -## prefetch_now() [](#method-i-prefetch_now) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## versions(name) [](#method-i-versions) -Return data for all versions of the gem `name`. - diff --git a/example/ruby/Gem/Resolver/APISet/GemParser.md b/example/ruby/Gem/Resolver/APISet/GemParser.md deleted file mode 100644 index 3b36786..0000000 --- a/example/ruby/Gem/Resolver/APISet/GemParser.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Gem::Resolver::APISet::GemParser -**Inherits:** Object - - - - - -#Instance Methods -## parse(line) [](#method-i-parse) - diff --git a/example/ruby/Gem/Resolver/APISpecification.md b/example/ruby/Gem/Resolver/APISpecification.md deleted file mode 100644 index 3fe3278..0000000 --- a/example/ruby/Gem/Resolver/APISpecification.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: Gem::Resolver::APISpecification -**Inherits:** Gem::Resolver::Specification - - -Represents a specification retrieved via the rubygems.org API. - -This is used to avoid loading the full Specification object when all we need -is the name, version, and dependencies. - - -# Class Methods -## new(set , api_data ) [](#method-c-new) - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## fetch_development_dependencies() [](#method-i-fetch_development_dependencies) -:nodoc: - -## hash() [](#method-i-hash) - -## initialize(set, api_data) [](#method-i-initialize) -Creates an APISpecification for the given `set` from the rubygems.org -`api_data`. - -See https://guides.rubygems.org/rubygems-org-api/#misc-methods for the format -of the `api_data`. - -**@return** [APISpecification] a new instance of APISpecification - -## installable_platform?() [](#method-i-installable_platform?) -:nodoc: - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## source() [](#method-i-source) -:nodoc: - -## spec() [](#method-i-spec) -Fetches a Gem::Specification for this APISpecification. - diff --git a/example/ruby/Gem/Resolver/ActivationRequest.md b/example/ruby/Gem/Resolver/ActivationRequest.md deleted file mode 100644 index cdbe526..0000000 --- a/example/ruby/Gem/Resolver/ActivationRequest.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Gem::Resolver::ActivationRequest -**Inherits:** Object - - -Specifies a Specification object that should be activated. Also contains a -dependency that was used to introduce this activation. - - -# Attributes -## request[RW] [](#attribute-i-request) -The parent request for this activation request. - -## spec[RW] [](#attribute-i-spec) -The specification to be activated. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## development?() [](#method-i-development?) -Is this activation request for a development dependency? - -**@return** [Boolean] - -## download(path) [](#method-i-download) -Downloads a gem at `path` and returns the file path. - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## full_name() [](#method-i-full_name) -The full name of the specification to be activated. - -## full_spec() [](#method-i-full_spec) -The Gem::Specification for this activation request. - -## hash() [](#method-i-hash) - -## initialize(spec, request) [](#method-i-initialize) -Creates a new ActivationRequest that will activate `spec`. The parent -`request` is used to provide diagnostics in case of conflicts. - -**@return** [ActivationRequest] a new instance of ActivationRequest - -## inspect() [](#method-i-inspect) -:nodoc: - -## installed?() [](#method-i-installed?) -True if the requested gem has already been installed. - -**@return** [Boolean] - -## name() [](#method-i-name) -The name of this activation request's specification - -## parent() [](#method-i-parent) -Return the ActivationRequest that contained the dependency that we were -activated for. - -## platform() [](#method-i-platform) -The platform of this activation request's specification - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## version() [](#method-i-version) -The version of this activation request's specification - diff --git a/example/ruby/Gem/Resolver/BestSet.md b/example/ruby/Gem/Resolver/BestSet.md deleted file mode 100644 index 248c2fd..0000000 --- a/example/ruby/Gem/Resolver/BestSet.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Gem::Resolver::BestSet -**Inherits:** Gem::Resolver::ComposedSet - - -The BestSet chooses the best available method to query a remote index. - -It combines IndexSet and APISet - - - -#Instance Methods -## find_all(req) [](#method-i-find_all) -:nodoc: - -## initialize(sourcesGem.sources) [](#method-i-initialize) -Creates a BestSet for the given `sources` or Gem::sources if none are -specified. `sources` must be a Gem::SourceList. - -**@return** [BestSet] a new instance of BestSet - -## pick_sets() [](#method-i-pick_sets) -Picks which sets to use for the configured sources. - -## prefetch(reqs) [](#method-i-prefetch) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Resolver/ComposedSet.md b/example/ruby/Gem/Resolver/ComposedSet.md deleted file mode 100644 index 64f7153..0000000 --- a/example/ruby/Gem/Resolver/ComposedSet.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Gem::Resolver::ComposedSet -**Inherits:** Gem::Resolver::Set - - -A ComposedSet allows multiple sets to be queried like a single set. - -To create a composed set with any number of sets use: - - Gem::Resolver.compose_sets set1, set2 - -This method will eliminate nesting of composed sets. - - -# Attributes -## sets[RW] [](#attribute-i-sets) -:nodoc: - - -#Instance Methods -## errors() [](#method-i-errors) - -## find_all(req) [](#method-i-find_all) -Finds all specs matching `req` in all sets. - -## initialize(*sets) [](#method-i-initialize) -Creates a new ComposedSet containing `sets`. Use Gem::Resolver::compose_sets -instead. - -**@return** [ComposedSet] a new instance of ComposedSet - -## prefetch(reqs) [](#method-i-prefetch) -Prefetches `reqs` in all sets. - -## prerelease=(allow_prerelease) [](#method-i-prerelease=) -When `allow_prerelease` is set to `true` prereleases gems are allowed to match -dependencies. - -## remote=(remote) [](#method-i-remote=) -Sets the remote network access for all composed sets. - diff --git a/example/ruby/Gem/Resolver/Conflict.md b/example/ruby/Gem/Resolver/Conflict.md deleted file mode 100644 index 09567fe..0000000 --- a/example/ruby/Gem/Resolver/Conflict.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: Gem::Resolver::Conflict -**Inherits:** Object - - -Used internally to indicate that a dependency conflicted with a spec that -would be activated. - - -# Attributes -## activated[RW] [](#attribute-i-activated) -The specification that was activated prior to the conflict - -## dependency[RW] [](#attribute-i-dependency) -The dependency that is in conflict with the activated gem. - -## failed_dep[RW] [](#attribute-i-failed_dep) -:nodoc: - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## conflicting_dependencies() [](#method-i-conflicting_dependencies) -Return the 2 dependency objects that conflicted - -## explain() [](#method-i-explain) -A string explanation of the conflict. - -## explanation() [](#method-i-explanation) -Explanation of the conflict used by exceptions to print useful messages - -## for_spec?(spec) [](#method-i-for_spec?) -Returns true if the conflicting dependency's name matches `spec`. - -**@return** [Boolean] - -## initialize(dependency, activated, failed_depdependency) [](#method-i-initialize) -Creates a new resolver conflict when `dependency` is in conflict with an -already `activated` specification. - -**@return** [Conflict] a new instance of Conflict - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## request_path(current) [](#method-i-request_path) -Path of activations from the `current` list. - -## requester() [](#method-i-requester) -Return the Specification that listed the dependency - diff --git a/example/ruby/Gem/Resolver/CurrentSet.md b/example/ruby/Gem/Resolver/CurrentSet.md deleted file mode 100644 index 7467395..0000000 --- a/example/ruby/Gem/Resolver/CurrentSet.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Gem::Resolver::CurrentSet -**Inherits:** Gem::Resolver::Set - - -A set which represents the installed gems. Respects all the normal settings -that control where to look for installed gems. - - - -#Instance Methods -## find_all(req) [](#method-i-find_all) - diff --git a/example/ruby/Gem/Resolver/DependencyRequest.md b/example/ruby/Gem/Resolver/DependencyRequest.md deleted file mode 100644 index e3d3f5a..0000000 --- a/example/ruby/Gem/Resolver/DependencyRequest.md +++ /dev/null @@ -1,75 +0,0 @@ -# Class: Gem::Resolver::DependencyRequest -**Inherits:** Object - - -Used Internally. Wraps a Dependency object to also track which spec contained -the Dependency. - - -# Attributes -## dependency[RW] [](#attribute-i-dependency) -The wrapped Gem::Dependency - -## requester[RW] [](#attribute-i-requester) -The request for this dependency. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## development?() [](#method-i-development?) -Is this dependency a development dependency? - -**@return** [Boolean] - -## explicit?() [](#method-i-explicit?) -Indicate that the request is for a gem explicitly requested by the user - -**@return** [Boolean] - -## implicit?() [](#method-i-implicit?) -Indicate that the request is for a gem requested as a dependency of another -gem - -**@return** [Boolean] - -## initialize(dependency, requester) [](#method-i-initialize) -Creates a new DependencyRequest for `dependency` from `requester`. +requester -may be nil if the request came from a user. - -**@return** [DependencyRequest] a new instance of DependencyRequest - -## match?(spec, allow_prereleasefalse) [](#method-i-match?) -Does this dependency request match `spec`? - -NOTE: #match? only matches prerelease versions when #dependency is a -prerelease dependency. - -**@return** [Boolean] - -## matches_spec?(spec) [](#method-i-matches_spec?) -Does this dependency request match `spec`? - -NOTE: #matches_spec? matches prerelease versions. See also #match? - -**@return** [Boolean] - -## name() [](#method-i-name) -The name of the gem this dependency request is requesting. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## request_context() [](#method-i-request_context) -Return a String indicating who caused this request to be added (only valid for -implicit requests) - -## requirement() [](#method-i-requirement) -The version requirement for this dependency request - -## to_s() [](#method-i-to_s) -:nodoc: - -## type() [](#method-i-type) - diff --git a/example/ruby/Gem/Resolver/GitSet.md b/example/ruby/Gem/Resolver/GitSet.md deleted file mode 100644 index 8cdd480..0000000 --- a/example/ruby/Gem/Resolver/GitSet.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: Gem::Resolver::GitSet -**Inherits:** Gem::Resolver::Set - - -A GitSet represents gems that are sourced from git repositories. - -This is used for gem dependency file support. - -Example: - - set = Gem::Resolver::GitSet.new - set.add_git_gem 'rake', 'git://example/rake.git', tag: 'rake-10.1.0' - - -# Attributes -## need_submodules[RW] [](#attribute-i-need_submodules) -Contains repositories needing submodules - -## repositories[RW] [](#attribute-i-repositories) -A Hash containing git gem names for keys and a Hash of repository and git -commit reference as values. - -## root_dir[RW] [](#attribute-i-root_dir) -The root directory for git gems in this set. This is usually Gem.dir, the -installation directory for regular gems. - -## specs[RW] [](#attribute-i-specs) -A hash of gem names to Gem::Resolver::GitSpecifications - - -#Instance Methods -## add_git_gem(name, repository, reference, submodules) [](#method-i-add_git_gem) -:nodoc: - -## add_git_spec(name, version, repository, reference, submodules) [](#method-i-add_git_spec) -Adds and returns a GitSpecification with the given `name` and `version` which -came from a `repository` at the given `reference`. If `submodules` is true -they are checked out along with the repository. - -This fills in the prefetch information as enough information about the gem is -present in the arguments. - -## find_all(req) [](#method-i-find_all) -Finds all git gems matching `req` - -## initialize() [](#method-i-initialize) -:nodoc: - -**@return** [GitSet] a new instance of GitSet - -## prefetch(reqs) [](#method-i-prefetch) -Prefetches specifications from the git repositories in this set. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Resolver/GitSpecification.md b/example/ruby/Gem/Resolver/GitSpecification.md deleted file mode 100644 index 77eadd4..0000000 --- a/example/ruby/Gem/Resolver/GitSpecification.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Gem::Resolver::GitSpecification -**Inherits:** Gem::Resolver::SpecSpecification - - -A GitSpecification represents a gem that is sourced from a git repository and -is being loaded through a gem dependencies file through the `git:` option. - - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## add_dependency(dependency) [](#method-i-add_dependency) -:nodoc: - -## install(options{}) [](#method-i-install) -Installing a git gem only involves building the extensions and generating the -executables. - -**@yield** [installer] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Resolver/IndexSet.md b/example/ruby/Gem/Resolver/IndexSet.md deleted file mode 100644 index 58f60e9..0000000 --- a/example/ruby/Gem/Resolver/IndexSet.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::Resolver::IndexSet -**Inherits:** Gem::Resolver::Set - - -The global rubygems pool represented via the traditional source index. - - - -#Instance Methods -## find_all(req) [](#method-i-find_all) -Return an array of IndexSpecification objects matching DependencyRequest -`req`. - -## initialize(sourcenil) [](#method-i-initialize) -:nodoc: - -**@return** [IndexSet] a new instance of IndexSet - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Resolver/IndexSpecification.md b/example/ruby/Gem/Resolver/IndexSpecification.md deleted file mode 100644 index ab50bd1..0000000 --- a/example/ruby/Gem/Resolver/IndexSpecification.md +++ /dev/null @@ -1,51 +0,0 @@ -# Class: Gem::Resolver::IndexSpecification -**Inherits:** Gem::Resolver::Specification - - -Represents a possible Specification object returned from IndexSet. Used to -delay needed to download full Specification objects when only the `name` and -`version` are needed. - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## dependencies() [](#method-i-dependencies) -The dependencies of the gem for this specification - -## hash() [](#method-i-hash) - -## initialize(set, name, version, source, platform) [](#method-i-initialize) -An IndexSpecification is created from the index format described in `gem help -generate_index`. - -The `set` contains other specifications for this (URL) `source`. - -The `name`, `version` and `platform` are the name, version and platform of the -gem. - -**@return** [IndexSpecification] a new instance of IndexSpecification - -## inspect() [](#method-i-inspect) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## required_ruby_version() [](#method-i-required_ruby_version) -The required_ruby_version constraint for this specification - -A fallback is included because when generated, some marshalled specs have it -set to `nil`. - -## required_rubygems_version() [](#method-i-required_rubygems_version) -The required_rubygems_version constraint for this specification - -A fallback is included because the original version of the specification API -didn't include that field, so some marshalled specs in the index have it set -to `nil`. - -## spec() [](#method-i-spec) -Fetches a Gem::Specification for this IndexSpecification from the #source. - diff --git a/example/ruby/Gem/Resolver/InstalledSpecification.md b/example/ruby/Gem/Resolver/InstalledSpecification.md deleted file mode 100644 index f34b5b7..0000000 --- a/example/ruby/Gem/Resolver/InstalledSpecification.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Gem::Resolver::InstalledSpecification -**Inherits:** Gem::Resolver::SpecSpecification - - -An InstalledSpecification represents a gem that is already installed locally. - - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## install(options{}) [](#method-i-install) -This is a null install as this specification is already installed. `options` -are ignored. - -**@yield** [nil] - -## installable_platform?() [](#method-i-installable_platform?) -Returns `true` if this gem is installable for the current platform. - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## source() [](#method-i-source) -The source for this specification - diff --git a/example/ruby/Gem/Resolver/InstallerSet.md b/example/ruby/Gem/Resolver/InstallerSet.md deleted file mode 100644 index ab70c56..0000000 --- a/example/ruby/Gem/Resolver/InstallerSet.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Gem::Resolver::InstallerSet -**Inherits:** Gem::Resolver::Set - - -A set of gems for installation sourced from remote sources and local .gem -files - - -# Attributes -## always_install[RW] [](#attribute-i-always_install) -List of Gem::Specification objects that must always be installed. - -## force[RW] [](#attribute-i-force) -Ignore ruby & rubygems specification constraints. - -## ignore_dependencies[RW] [](#attribute-i-ignore_dependencies) -Only install gems in the always_install list - -## ignore_installed[RW] [](#attribute-i-ignore_installed) -Do not look in the installed set when finding specifications. This is used by -the --install-dir option to `gem install` - -## remote_set[RW] [](#attribute-i-remote_set) -The remote_set looks up remote gems for installation. - - -#Instance Methods -## add_always_install(dependency) [](#method-i-add_always_install) -Looks up the latest specification for `dependency` and adds it to the -always_install list. - -## add_local(dep_name, spec, source) [](#method-i-add_local) -Adds a local gem requested using `dep_name` with the given `spec` that can be -loaded and installed using the `source`. - -## consider_local?() [](#method-i-consider_local?) -Should local gems should be considered? - -**@return** [Boolean] - -## consider_remote?() [](#method-i-consider_remote?) -Should remote gems should be considered? - -**@return** [Boolean] - -## errors() [](#method-i-errors) -Errors encountered while resolving gems - -## find_all(req) [](#method-i-find_all) -Returns an array of IndexSpecification objects matching DependencyRequest -`req`. - -## initialize(domain) [](#method-i-initialize) -Creates a new InstallerSet that will look for gems in `domain`. - -**@return** [InstallerSet] a new instance of InstallerSet - -## inspect() [](#method-i-inspect) -:nodoc: - -## load_spec(name, ver, platform, source) [](#method-i-load_spec) -Called from IndexSpecification to get a true Specification object. - -## local?(dep_name) [](#method-i-local?) -Has a local gem for `dep_name` been added to this set? - -**@return** [Boolean] - -## prefetch(reqs) [](#method-i-prefetch) - -## prerelease=(allow_prerelease) [](#method-i-prerelease=) - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## remote=(remote) [](#method-i-remote=) -:nodoc: - diff --git a/example/ruby/Gem/Resolver/LocalSpecification.md b/example/ruby/Gem/Resolver/LocalSpecification.md deleted file mode 100644 index 25df18b..0000000 --- a/example/ruby/Gem/Resolver/LocalSpecification.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Gem::Resolver::LocalSpecification -**Inherits:** Gem::Resolver::SpecSpecification - - -A LocalSpecification comes from a .gem file on the local filesystem. - - - -#Instance Methods -## installable_platform?() [](#method-i-installable_platform?) -Returns `true` if this gem is installable for the current platform. - -**@return** [Boolean] - -## local?() [](#method-i-local?) -:nodoc: - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Resolver/LockSet.md b/example/ruby/Gem/Resolver/LockSet.md deleted file mode 100644 index 0415576..0000000 --- a/example/ruby/Gem/Resolver/LockSet.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Gem::Resolver::LockSet -**Inherits:** Gem::Resolver::Set - - -A set of gems from a gem dependencies lockfile. - - -# Attributes -## specs[RW] [](#attribute-i-specs) -:nodoc: - - -#Instance Methods -## add(name, version, platform) [](#method-i-add) -Creates a new IndexSpecification in this set using the given `name`, `version` -and `platform`. - -The specification's set will be the current set, and the source will be the -current set's source. - -## find_all(req) [](#method-i-find_all) -Returns an Array of IndexSpecification objects matching the DependencyRequest -`req`. - -## initialize(sources) [](#method-i-initialize) -Creates a new LockSet from the given `sources` - -**@return** [LockSet] a new instance of LockSet - -## load_spec(name, version, platform, source) [](#method-i-load_spec) -Loads a Gem::Specification with the given `name`, `version` and `platform`. -`source` is ignored. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Resolver/LockSpecification.md b/example/ruby/Gem/Resolver/LockSpecification.md deleted file mode 100644 index 18899e1..0000000 --- a/example/ruby/Gem/Resolver/LockSpecification.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Gem::Resolver::LockSpecification -**Inherits:** Gem::Resolver::Specification - - -The LockSpecification comes from a lockfile (Gem::RequestSet::Lockfile). - -A LockSpecification's dependency information is pre-filled from the lockfile. - - -# Attributes -## sources[RW] [](#attribute-i-sources) -Returns the value of attribute sources. - - -#Instance Methods -## add_dependency(dependency) [](#method-i-add_dependency) -Adds `dependency` from the lockfile to this specification - -## initialize(set, name, version, sources, platform) [](#method-i-initialize) - -**@return** [LockSpecification] a new instance of LockSpecification - -## install(options{}) [](#method-i-install) -This is a null install as a locked specification is considered installed. -`options` are ignored. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## spec() [](#method-i-spec) -A specification constructed from the lockfile is returned - diff --git a/example/ruby/Gem/Resolver/RequirementList.md b/example/ruby/Gem/Resolver/RequirementList.md deleted file mode 100644 index 019b720..0000000 --- a/example/ruby/Gem/Resolver/RequirementList.md +++ /dev/null @@ -1,2101 +0,0 @@ -# Class: Gem::Resolver::RequirementList -**Inherits:** Object - -**Includes:** Enumerable - - -The RequirementList is used to hold the requirements being considered while -resolving a set of gems. - -The RequirementList acts like a queue where the oldest items are removed -first. - - - -#Instance Methods -## add(req) [](#method-i-add) -Adds Resolver::DependencyRequest `req` to this requirements list. - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Enumerates requirements in the list - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Is the list empty? - -**@return** [Boolean] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) -Creates a new RequirementList. - -**@return** [RequirementList] a new instance of RequirementList - -## initialize_copy(other) [](#method-i-initialize_copy) -:nodoc: - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## next5() [](#method-i-next5) -Returns the oldest five entries from the list. - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## remove() [](#method-i-remove) -Remove the oldest DependencyRequest from the list. - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) -How many elements are in the list - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/Resolver/Set.md b/example/ruby/Gem/Resolver/Set.md deleted file mode 100644 index 14c4c0e..0000000 --- a/example/ruby/Gem/Resolver/Set.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: Gem::Resolver::Set -**Inherits:** Object - - -Resolver sets are used to look up specifications (and their dependencies) used -in resolution. This set is abstract. - - -# Attributes -## errors[RW] [](#attribute-i-errors) -Errors encountered when resolving gems - -## prerelease[RW] [](#attribute-i-prerelease) -When true, allows matching of requests to prerelease gems. - -## remote[RW] [](#attribute-i-remote) -Set to true to disable network access for this set - - -#Instance Methods -## find_all(req) [](#method-i-find_all) -The find_all method must be implemented. It returns all Resolver -Specification objects matching the given DependencyRequest `req`. - -**@raise** [NotImplementedError] - -## initialize() [](#method-i-initialize) -:nodoc: - -**@return** [Set] a new instance of Set - -## prefetch(reqs) [](#method-i-prefetch) -The #prefetch method may be overridden, but this is not necessary. This -default implementation does nothing, which is suitable for sets where looking -up a specification is cheap (such as installed gems). - -When overridden, the #prefetch method should look up specifications matching -`reqs`. - -## remote?() [](#method-i-remote?) -When true, this set is allowed to access the network when looking up -specifications or dependencies. - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Resolver/SourceSet.md b/example/ruby/Gem/Resolver/SourceSet.md deleted file mode 100644 index a3c74f1..0000000 --- a/example/ruby/Gem/Resolver/SourceSet.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Gem::Resolver::SourceSet -**Inherits:** Gem::Resolver::Set - - -The SourceSet chooses the best available method to query a remote index. - -Kind off like BestSet but filters the sources for gems - - - -#Instance Methods -## add_source_gem(name, source) [](#method-i-add_source_gem) - -## find_all(req) [](#method-i-find_all) -:nodoc: - -## initialize() [](#method-i-initialize) -Creates a SourceSet for the given `sources` or Gem::sources if none are -specified. `sources` must be a Gem::SourceList. - -**@return** [SourceSet] a new instance of SourceSet - -## prefetch(reqs) [](#method-i-prefetch) -potentially no-op - diff --git a/example/ruby/Gem/Resolver/SpecSpecification.md b/example/ruby/Gem/Resolver/SpecSpecification.md deleted file mode 100644 index fda3a9f..0000000 --- a/example/ruby/Gem/Resolver/SpecSpecification.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Gem::Resolver::SpecSpecification -**Inherits:** Gem::Resolver::Specification - - -The Resolver::SpecSpecification contains common functionality for Resolver -specifications that are backed by a Gem::Specification. - - - -#Instance Methods -## dependencies() [](#method-i-dependencies) -The dependencies of the gem for this specification - -## full_name() [](#method-i-full_name) -The name and version of the specification. - -Unlike Gem::Specification#full_name, the platform is not included. - -## hash() [](#method-i-hash) -The hash value for this specification. - -## initialize(set, spec, sourcenil) [](#method-i-initialize) -A SpecSpecification is created for a `set` for a Gem::Specification in `spec`. - The `source` is either where the `spec` came from, or should be loaded from. - -**@return** [SpecSpecification] a new instance of SpecSpecification - -## name() [](#method-i-name) -The name of the gem for this specification - -## platform() [](#method-i-platform) -The platform this gem works on. - -## required_ruby_version() [](#method-i-required_ruby_version) -The required_ruby_version constraint for this specification - -## required_rubygems_version() [](#method-i-required_rubygems_version) -The required_rubygems_version constraint for this specification - -## version() [](#method-i-version) -The version of the gem for this specification. - diff --git a/example/ruby/Gem/Resolver/Specification.md b/example/ruby/Gem/Resolver/Specification.md deleted file mode 100644 index b53a17b..0000000 --- a/example/ruby/Gem/Resolver/Specification.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Gem::Resolver::Specification -**Inherits:** Object - - -A Resolver::Specification contains a subset of the information contained in a -Gem::Specification. Only the information necessary for dependency resolution -in the resolver is included. - - -# Attributes -## dependencies[RW] [](#attribute-i-dependencies) -The dependencies of the gem for this specification - -## name[RW] [](#attribute-i-name) -The name of the gem for this specification - -## platform[RW] [](#attribute-i-platform) -The platform this gem works on. - -## required_ruby_version[RW] [](#attribute-i-required_ruby_version) -The required_ruby_version constraint for this specification. - -## required_rubygems_version[RW] [](#attribute-i-required_rubygems_version) -The required_ruby_version constraint for this specification. - -## set[RW] [](#attribute-i-set) -The set this specification came from. - -## source[RW] [](#attribute-i-source) -The source for this specification - -## spec[RW] [](#attribute-i-spec) -The Gem::Specification for this Resolver::Specification. - -Implementers, note that #install updates @spec, so be sure to cache the -Gem::Specification in @spec when overriding. - -## version[RW] [](#attribute-i-version) -The version of the gem for this specification. - - -#Instance Methods -## download(options) [](#method-i-download) - -## fetch_development_dependencies() [](#method-i-fetch_development_dependencies) -Fetches development dependencies if the source does not provide them by -default (see APISpecification). - -## full_name() [](#method-i-full_name) -The name and version of the specification. - -Unlike Gem::Specification#full_name, the platform is not included. - -## initialize() [](#method-i-initialize) -Sets default instance variables for the specification. - -**@return** [Specification] a new instance of Specification - -## install(options{}) [](#method-i-install) -Installs this specification using the Gem::Installer `options`. The install -method yields a Gem::Installer instance, which indicates the gem will be -installed, or `nil`, which indicates the gem is already installed. - -After installation #spec is updated to point to the just-installed -specification. - -**@yield** [installer] - -## installable_platform?() [](#method-i-installable_platform?) -Returns true if this specification is installable on this platform. - -**@return** [Boolean] - -## local?() [](#method-i-local?) -:nodoc: - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Resolver/Stats.md b/example/ruby/Gem/Resolver/Stats.md deleted file mode 100644 index 26b9c61..0000000 --- a/example/ruby/Gem/Resolver/Stats.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::Resolver::Stats -**Inherits:** Object - - - - - -#Instance Methods -## backtracking!() [](#method-i-backtracking!) - -## display() [](#method-i-display) - -## initialize() [](#method-i-initialize) - -**@return** [Stats] a new instance of Stats - -## iteration!() [](#method-i-iteration!) - -## record_depth(stack) [](#method-i-record_depth) - -## record_requirements(reqs) [](#method-i-record_requirements) - -## requirement!() [](#method-i-requirement!) - diff --git a/example/ruby/Gem/Resolver/VendorSet.md b/example/ruby/Gem/Resolver/VendorSet.md deleted file mode 100644 index 372fc56..0000000 --- a/example/ruby/Gem/Resolver/VendorSet.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Gem::Resolver::VendorSet -**Inherits:** Gem::Resolver::Set - - -A VendorSet represents gems that have been unpacked into a specific directory -that contains a gemspec. - -This is used for gem dependency file support. - -Example: - - set = Gem::Resolver::VendorSet.new - - set.add_vendor_gem 'rake', 'vendor/rake' - -The directory vendor/rake must contain an unpacked rake gem along with a -rake.gemspec (watching the given name). - - -# Attributes -## specs[RW] [](#attribute-i-specs) -The specifications for this set. - - -#Instance Methods -## add_vendor_gem(name, directory) [](#method-i-add_vendor_gem) -Adds a specification to the set with the given `name` which has been unpacked -into the given `directory`. - -**@raise** [Gem::GemNotFoundException] - -## find_all(req) [](#method-i-find_all) -Returns an Array of VendorSpecification objects matching the DependencyRequest -`req`. - -## initialize() [](#method-i-initialize) -:nodoc: - -**@return** [VendorSet] a new instance of VendorSet - -## load_spec(name, version, platform, source) [](#method-i-load_spec) -Loads a spec with the given `name`. `version`, `platform` and `source` are -ignored. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Resolver/VendorSpecification.md b/example/ruby/Gem/Resolver/VendorSpecification.md deleted file mode 100644 index 1899701..0000000 --- a/example/ruby/Gem/Resolver/VendorSpecification.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::Resolver::VendorSpecification -**Inherits:** Gem::Resolver::SpecSpecification - - -A VendorSpecification represents a gem that has been unpacked into a project -and is being loaded through a gem dependencies file through the `path:` -option. - - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## install(options{}) [](#method-i-install) -This is a null install as this gem was unpacked into a directory. `options` -are ignored. - -**@yield** [nil] - diff --git a/example/ruby/Gem/RubyVersionMismatch.md b/example/ruby/Gem/RubyVersionMismatch.md deleted file mode 100644 index f111ee6..0000000 --- a/example/ruby/Gem/RubyVersionMismatch.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Gem::RubyVersionMismatch -**Inherits:** Gem::Exception - - -Raised when a gem dependencies file specifies a ruby version that does not -match the current version. - - - diff --git a/example/ruby/Gem/RuntimeRequirementNotMetError.md b/example/ruby/Gem/RuntimeRequirementNotMetError.md deleted file mode 100644 index 06f4808..0000000 --- a/example/ruby/Gem/RuntimeRequirementNotMetError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: Gem::RuntimeRequirementNotMetError -**Inherits:** Gem::InstallError - - - - -# Attributes -## suggestion[RW] [](#attribute-i-suggestion) -Returns the value of attribute suggestion. - - -#Instance Methods -## message() [](#method-i-message) - diff --git a/example/ruby/Gem/S3URISigner.md b/example/ruby/Gem/S3URISigner.md deleted file mode 100644 index ed21997..0000000 --- a/example/ruby/Gem/S3URISigner.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::S3URISigner -**Inherits:** Object - - -S3URISigner implements AWS SigV4 for S3 Source to avoid a dependency on the -aws-sdk-* gems More on AWS SigV4: -https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests -.html - - -# Attributes -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - - -#Instance Methods -## initialize(uri) [](#method-i-initialize) - -**@return** [S3URISigner] a new instance of S3URISigner - -## sign(expiration86_400) [](#method-i-sign) -Signs S3 URI using query-params according to the reference: -https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html - diff --git a/example/ruby/Gem/S3URISigner/ConfigurationError.md b/example/ruby/Gem/S3URISigner/ConfigurationError.md deleted file mode 100644 index ee96b54..0000000 --- a/example/ruby/Gem/S3URISigner/ConfigurationError.md +++ /dev/null @@ -1,15 +0,0 @@ -# Exception: Gem::S3URISigner::ConfigurationError -**Inherits:** Gem::Exception - - - - - -#Instance Methods -## initialize(message) [](#method-i-initialize) - -**@return** [ConfigurationError] a new instance of ConfigurationError - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Gem/S3URISigner/InstanceProfileError.md b/example/ruby/Gem/S3URISigner/InstanceProfileError.md deleted file mode 100644 index 600e3ef..0000000 --- a/example/ruby/Gem/S3URISigner/InstanceProfileError.md +++ /dev/null @@ -1,15 +0,0 @@ -# Exception: Gem::S3URISigner::InstanceProfileError -**Inherits:** Gem::Exception - - - - - -#Instance Methods -## initialize(message) [](#method-i-initialize) - -**@return** [InstanceProfileError] a new instance of InstanceProfileError - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Gem/S3URISigner/S3Config.md b/example/ruby/Gem/S3URISigner/S3Config.md deleted file mode 100644 index 8d952df..0000000 --- a/example/ruby/Gem/S3URISigner/S3Config.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::S3URISigner::S3Config -**Inherits:** Struct - - - - - diff --git a/example/ruby/Gem/SafeMarshal.md b/example/ruby/Gem/SafeMarshal.md deleted file mode 100644 index c8990b8..0000000 --- a/example/ruby/Gem/SafeMarshal.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Gem::SafeMarshal - - -This module is used for safely loading Marshal specs from a gem. The -`safe_load` method defined on this module is specifically designed for loading -Gem specifications. - - -# Class Methods -## load(input , permitted_classes: [::Symbol], permitted_symbols: [], permitted_ivars: {}) [](#method-c-load) -## safe_load(input ) [](#method-c-safe_load) - diff --git a/example/ruby/Gem/SafeMarshal/Elements.md b/example/ruby/Gem/SafeMarshal/Elements.md deleted file mode 100644 index 9335748..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Gem::SafeMarshal::Elements - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Array.md b/example/ruby/Gem/SafeMarshal/Elements/Array.md deleted file mode 100644 index aa8cb61..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Array.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Array -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## elements[RW] [](#attribute-i-elements) -Returns the value of attribute elements. - - -#Instance Methods -## initialize(elements) [](#method-i-initialize) - -**@return** [Array] a new instance of Array - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Bignum.md b/example/ruby/Gem/SafeMarshal/Elements/Bignum.md deleted file mode 100644 index 195f83c..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Bignum.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Bignum -**Inherits:** Gem::SafeMarshal::Elements::Element - - -rubocop:disable Lint/UnifiedInteger - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - -## sign[RW] [](#attribute-i-sign) -Returns the value of attribute sign. - - -#Instance Methods -## initialize(sign, data) [](#method-i-initialize) - -**@return** [Bignum] a new instance of Bignum - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Element.md b/example/ruby/Gem/SafeMarshal/Elements/Element.md deleted file mode 100644 index 4a7090d..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Element.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Element -**Inherits:** Object - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Elements/False.md b/example/ruby/Gem/SafeMarshal/Elements/False.md deleted file mode 100644 index b263e07..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/False.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::False -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [False] a new instance of False - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Float.md b/example/ruby/Gem/SafeMarshal/Elements/Float.md deleted file mode 100644 index 2565228..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Float.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Float -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - - -#Instance Methods -## initialize(string) [](#method-i-initialize) - -**@return** [Float] a new instance of Float - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Hash.md b/example/ruby/Gem/SafeMarshal/Elements/Hash.md deleted file mode 100644 index 18c5eb3..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Hash.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Hash -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## pairs[RW] [](#attribute-i-pairs) -Returns the value of attribute pairs. - - -#Instance Methods -## initialize(pairs) [](#method-i-initialize) - -**@return** [Hash] a new instance of Hash - diff --git a/example/ruby/Gem/SafeMarshal/Elements/HashWithDefaultValue.md b/example/ruby/Gem/SafeMarshal/Elements/HashWithDefaultValue.md deleted file mode 100644 index 5259690..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/HashWithDefaultValue.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::HashWithDefaultValue -**Inherits:** Gem::SafeMarshal::Elements::Hash - - - - -# Attributes -## default[RW] [](#attribute-i-default) -Returns the value of attribute default. - - -#Instance Methods -## initialize(pairs, default) [](#method-i-initialize) - -**@return** [HashWithDefaultValue] a new instance of HashWithDefaultValue - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Integer.md b/example/ruby/Gem/SafeMarshal/Elements/Integer.md deleted file mode 100644 index 34f7bb3..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Integer.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Integer -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## int[RW] [](#attribute-i-int) -Returns the value of attribute int. - - -#Instance Methods -## initialize(int) [](#method-i-initialize) - -**@return** [Integer] a new instance of Integer - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Nil.md b/example/ruby/Gem/SafeMarshal/Elements/Nil.md deleted file mode 100644 index c42f681..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Nil.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Nil -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Object.md b/example/ruby/Gem/SafeMarshal/Elements/Object.md deleted file mode 100644 index 1ebf2b8..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Object.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Object -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [Object] a new instance of Object - diff --git a/example/ruby/Gem/SafeMarshal/Elements/ObjectLink.md b/example/ruby/Gem/SafeMarshal/Elements/ObjectLink.md deleted file mode 100644 index 6fc4f50..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/ObjectLink.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::ObjectLink -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## offset[RW] [](#attribute-i-offset) -Returns the value of attribute offset. - - -#Instance Methods -## initialize(offset) [](#method-i-initialize) - -**@return** [ObjectLink] a new instance of ObjectLink - diff --git a/example/ruby/Gem/SafeMarshal/Elements/String.md b/example/ruby/Gem/SafeMarshal/Elements/String.md deleted file mode 100644 index 75cf09f..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/String.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::String -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## str[RW] [](#attribute-i-str) -Returns the value of attribute str. - - -#Instance Methods -## initialize(str) [](#method-i-initialize) - -**@return** [String] a new instance of String - diff --git a/example/ruby/Gem/SafeMarshal/Elements/Symbol.md b/example/ruby/Gem/SafeMarshal/Elements/Symbol.md deleted file mode 100644 index 99de67b..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/Symbol.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::Symbol -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [Symbol] a new instance of Symbol - diff --git a/example/ruby/Gem/SafeMarshal/Elements/SymbolLink.md b/example/ruby/Gem/SafeMarshal/Elements/SymbolLink.md deleted file mode 100644 index 192160a..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/SymbolLink.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::SymbolLink -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## offset[RW] [](#attribute-i-offset) -Returns the value of attribute offset. - - -#Instance Methods -## initialize(offset) [](#method-i-initialize) - -**@return** [SymbolLink] a new instance of SymbolLink - diff --git a/example/ruby/Gem/SafeMarshal/Elements/True.md b/example/ruby/Gem/SafeMarshal/Elements/True.md deleted file mode 100644 index 6220d65..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/True.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::True -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [True] a new instance of True - diff --git a/example/ruby/Gem/SafeMarshal/Elements/UserClass.md b/example/ruby/Gem/SafeMarshal/Elements/UserClass.md deleted file mode 100644 index f4128a7..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/UserClass.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::UserClass -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## wrapped_object[RW] [](#attribute-i-wrapped_object) -Returns the value of attribute wrapped_object. - - -#Instance Methods -## initialize(name, wrapped_object) [](#method-i-initialize) - -**@return** [UserClass] a new instance of UserClass - diff --git a/example/ruby/Gem/SafeMarshal/Elements/UserDefined.md b/example/ruby/Gem/SafeMarshal/Elements/UserDefined.md deleted file mode 100644 index 2cf4d00..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/UserDefined.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::UserDefined -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## binary_string[RW] [](#attribute-i-binary_string) -Returns the value of attribute binary_string. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name, binary_string) [](#method-i-initialize) - -**@return** [UserDefined] a new instance of UserDefined - diff --git a/example/ruby/Gem/SafeMarshal/Elements/UserMarshal.md b/example/ruby/Gem/SafeMarshal/Elements/UserMarshal.md deleted file mode 100644 index 1770d80..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/UserMarshal.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::UserMarshal -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name, data) [](#method-i-initialize) - -**@return** [UserMarshal] a new instance of UserMarshal - diff --git a/example/ruby/Gem/SafeMarshal/Elements/WithIvars.md b/example/ruby/Gem/SafeMarshal/Elements/WithIvars.md deleted file mode 100644 index 03158f5..0000000 --- a/example/ruby/Gem/SafeMarshal/Elements/WithIvars.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Gem::SafeMarshal::Elements::WithIvars -**Inherits:** Gem::SafeMarshal::Elements::Element - - - - -# Attributes -## ivars[RW] [](#attribute-i-ivars) -Returns the value of attribute ivars. - -## object[RW] [](#attribute-i-object) -Returns the value of attribute object. - - -#Instance Methods -## initialize(object, ivars) [](#method-i-initialize) - -**@return** [WithIvars] a new instance of WithIvars - diff --git a/example/ruby/Gem/SafeMarshal/Reader.md b/example/ruby/Gem/SafeMarshal/Reader.md deleted file mode 100644 index 516be80..0000000 --- a/example/ruby/Gem/SafeMarshal/Reader.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::SafeMarshal::Reader -**Inherits:** Object - - - - - -#Instance Methods -## initialize(io) [](#method-i-initialize) - -**@return** [Reader] a new instance of Reader - -## read!() [](#method-i-read!) - -**@raise** [UnconsumedBytesError] - diff --git a/example/ruby/Gem/SafeMarshal/Reader/DataTooShortError.md b/example/ruby/Gem/SafeMarshal/Reader/DataTooShortError.md deleted file mode 100644 index 2ba43fa..0000000 --- a/example/ruby/Gem/SafeMarshal/Reader/DataTooShortError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Reader::DataTooShortError -**Inherits:** Gem::SafeMarshal::Reader::Error - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Reader/EOFError.md b/example/ruby/Gem/SafeMarshal/Reader/EOFError.md deleted file mode 100644 index 6fdb5fb..0000000 --- a/example/ruby/Gem/SafeMarshal/Reader/EOFError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Reader::EOFError -**Inherits:** Gem::SafeMarshal::Reader::Error - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Reader/Error.md b/example/ruby/Gem/SafeMarshal/Reader/Error.md deleted file mode 100644 index d882be4..0000000 --- a/example/ruby/Gem/SafeMarshal/Reader/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Reader::Error -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Reader/NegativeLengthError.md b/example/ruby/Gem/SafeMarshal/Reader/NegativeLengthError.md deleted file mode 100644 index 760429d..0000000 --- a/example/ruby/Gem/SafeMarshal/Reader/NegativeLengthError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Reader::NegativeLengthError -**Inherits:** Gem::SafeMarshal::Reader::Error - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Reader/NotImplementedError.md b/example/ruby/Gem/SafeMarshal/Reader/NotImplementedError.md deleted file mode 100644 index 0f4a819..0000000 --- a/example/ruby/Gem/SafeMarshal/Reader/NotImplementedError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Reader::NotImplementedError -**Inherits:** Gem::SafeMarshal::Reader::Error - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Reader/UnconsumedBytesError.md b/example/ruby/Gem/SafeMarshal/Reader/UnconsumedBytesError.md deleted file mode 100644 index 83f9d4f..0000000 --- a/example/ruby/Gem/SafeMarshal/Reader/UnconsumedBytesError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Reader::UnconsumedBytesError -**Inherits:** Gem::SafeMarshal::Reader::Error - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Reader/UnsupportedVersionError.md b/example/ruby/Gem/SafeMarshal/Reader/UnsupportedVersionError.md deleted file mode 100644 index e92c675..0000000 --- a/example/ruby/Gem/SafeMarshal/Reader/UnsupportedVersionError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Reader::UnsupportedVersionError -**Inherits:** Gem::SafeMarshal::Reader::Error - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Visitors.md b/example/ruby/Gem/SafeMarshal/Visitors.md deleted file mode 100644 index 5e7d91d..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Gem::SafeMarshal::Visitors - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/StreamPrinter.md b/example/ruby/Gem/SafeMarshal/Visitors/StreamPrinter.md deleted file mode 100644 index 2673fec..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/StreamPrinter.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Gem::SafeMarshal::Visitors::StreamPrinter -**Inherits:** Gem::SafeMarshal::Visitors::Visitor - - - - - -#Instance Methods -## initialize(io, indent:"") [](#method-i-initialize) - -**@return** [StreamPrinter] a new instance of StreamPrinter - -## visit(target) [](#method-i-visit) - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby.md deleted file mode 100644 index 4c2088e..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Gem::SafeMarshal::Visitors::ToRuby -**Inherits:** Gem::SafeMarshal::Visitors::Visitor - - - - - -#Instance Methods -## initialize(permitted_classes:, permitted_symbols:, permitted_ivars:) [](#method-i-initialize) - -**@return** [ToRuby] a new instance of ToRuby - -## inspect() [](#method-i-inspect) -:nodoc: - -## visit(target) [](#method-i-visit) - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/Error.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/Error.md deleted file mode 100644 index 740c741..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Visitors::ToRuby::Error -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/FormatError.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/FormatError.md deleted file mode 100644 index 7b0cd04..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/FormatError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Visitors::ToRuby::FormatError -**Inherits:** Gem::SafeMarshal::Visitors::ToRuby::Error - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/MethodCallError.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/MethodCallError.md deleted file mode 100644 index 5ac5536..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/MethodCallError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::SafeMarshal::Visitors::ToRuby::MethodCallError -**Inherits:** Gem::SafeMarshal::Visitors::ToRuby::Error - - - - - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/TimeTooLargeError.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/TimeTooLargeError.md deleted file mode 100644 index 1a829f2..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/TimeTooLargeError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::SafeMarshal::Visitors::ToRuby::TimeTooLargeError -**Inherits:** Gem::SafeMarshal::Visitors::ToRuby::Error - - - - - -#Instance Methods -## initialize(message, stack:) [](#method-i-initialize) - -**@return** [TimeTooLargeError] a new instance of TimeTooLargeError - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedClassError.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedClassError.md deleted file mode 100644 index b7dd847..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedClassError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::SafeMarshal::Visitors::ToRuby::UnpermittedClassError -**Inherits:** Gem::SafeMarshal::Visitors::ToRuby::Error - - - - - -#Instance Methods -## initialize(name:, stack:) [](#method-i-initialize) - -**@return** [UnpermittedClassError] a new instance of UnpermittedClassError - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedIvarError.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedIvarError.md deleted file mode 100644 index 49f4d55..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedIvarError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::SafeMarshal::Visitors::ToRuby::UnpermittedIvarError -**Inherits:** Gem::SafeMarshal::Visitors::ToRuby::Error - - - - - -#Instance Methods -## initialize(symbol:, klass:, stack:) [](#method-i-initialize) - -**@return** [UnpermittedIvarError] a new instance of UnpermittedIvarError - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedSymbolError.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedSymbolError.md deleted file mode 100644 index b672398..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnpermittedSymbolError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::SafeMarshal::Visitors::ToRuby::UnpermittedSymbolError -**Inherits:** Gem::SafeMarshal::Visitors::ToRuby::Error - - - - - -#Instance Methods -## initialize(symbol:, stack:) [](#method-i-initialize) - -**@return** [UnpermittedSymbolError] a new instance of UnpermittedSymbolError - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnsupportedError.md b/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnsupportedError.md deleted file mode 100644 index b9c252b..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/ToRuby/UnsupportedError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::SafeMarshal::Visitors::ToRuby::UnsupportedError -**Inherits:** Gem::SafeMarshal::Visitors::ToRuby::Error - - - - - -#Instance Methods -## initialize(message, stack:) [](#method-i-initialize) - -**@return** [UnsupportedError] a new instance of UnsupportedError - diff --git a/example/ruby/Gem/SafeMarshal/Visitors/Visitor.md b/example/ruby/Gem/SafeMarshal/Visitors/Visitor.md deleted file mode 100644 index ce58dbe..0000000 --- a/example/ruby/Gem/SafeMarshal/Visitors/Visitor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Gem::SafeMarshal::Visitors::Visitor -**Inherits:** Object - - - - - -#Instance Methods -## visit(target) [](#method-i-visit) - diff --git a/example/ruby/Gem/SafeYAML.md b/example/ruby/Gem/SafeYAML.md deleted file mode 100644 index 8f85994..0000000 --- a/example/ruby/Gem/SafeYAML.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: Gem::SafeYAML - - -This module is used for safely loading YAML specs from a gem. The `safe_load` -method defined on this module is specifically designed for loading Gem -specifications. For loading other YAML safely, please see Psych.safe_load - - -# Class Methods -## aliases_enabled=(value ) [](#method-c-aliases_enabled=) -:nodoc: -## aliases_enabled?() [](#method-c-aliases_enabled?) -:nodoc: -**@return** [Boolean] - -## load(input ) [](#method-c-load) -## safe_load(input ) [](#method-c-safe_load) - diff --git a/example/ruby/Gem/SecureRandom.md b/example/ruby/Gem/SecureRandom.md deleted file mode 100644 index defc6ad..0000000 --- a/example/ruby/Gem/SecureRandom.md +++ /dev/null @@ -1,266 +0,0 @@ -# Module: Gem::SecureRandom - -**Extended by:** Random::Formatter - - -## Secure random number generator interface. - -This library is an interface to secure random number generators which are -suitable for generating session keys in HTTP cookies, etc. - -You can use this library in your application by requiring it: - - require 'rubygems/vendor/securerandom/lib/securerandom' - -It supports the following secure random number generators: - -* openssl -* /dev/urandom -* Win32 - -Gem::SecureRandom is extended by the Random::Formatter module which defines -the following methods: - -* alphanumeric -* base64 -* choose -* gen_random -* hex -* rand -* random_bytes -* random_number -* urlsafe_base64 -* uuid - -These methods are usable as class methods of Gem::SecureRandom such as -`Gem::SecureRandom.hex`. - -If a secure random number generator is not available, `NotImplementedError` is -raised. - - -# Class Methods -## alphanumeric(n nil, chars: ALPHANUMERIC) [](#method-c-alphanumeric) -Generate a random alphanumeric string. - -The argument *n* specifies the length, in characters, of the alphanumeric -string to be generated. The argument *chars* specifies the character list -which the result is consist of. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain A-Z, a-z and 0-9, unless *chars* is specified. - - require 'random/formatter' - - Random.alphanumeric #=> "2BuBuLf3WfSKyQbR" - # or - prng = Random.new - prng.alphanumeric(10) #=> "i6K93NdqiH" - - Random.alphanumeric(4, chars: [*"0".."9"]) #=> "2952" - # or - prng = Random.new - prng.alphanumeric(10, chars: [*"!".."/"]) #=> ",.,++%/''." -## base64(n nil) [](#method-c-base64) -Generate a random base64 string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the result string is about 4/3 of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain A-Z, a-z, 0-9, "+", "/" and "=". - - require 'random/formatter' - - Random.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A==" - # or - prng = Random.new - prng.base64 #=> "6BbW0pxO0YENxn38HMUbcQ==" - -See RFC 3548 for the definition of base64. -## bytes(n ) [](#method-c-bytes) -Returns a random binary string containing `size` bytes. - -See Random.bytes -## hex(n nil) [](#method-c-hex) -Generate a random hexadecimal string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the resulting hexadecimal string is twice of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain 0-9 and a-f. - - require 'random/formatter' - - Random.hex #=> "eb693ec8252cd630102fd0d0fb7c3485" - # or - prng = Random.new - prng.hex #=> "91dc3bfb4de5b11d029d376634589b61" -## rand(*args ) [](#method-c-rand) -Generates formatted random number from raw random bytes. See Random#rand. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## random_bytes(n nil) [](#method-c-random_bytes) -Generate a random binary string. - -The argument *n* specifies the length of the result string. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in future. - -The result may contain any byte: "x00" - "xff". - - require 'random/formatter' - - Random.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6" - # or - prng = Random.new - prng.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97" -## random_number(*args ) [](#method-c-random_number) -Generates formatted random number from raw random bytes. See Random#rand. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## urlsafe_base64(n nil, padding false) [](#method-c-urlsafe_base64) -Generate a random URL-safe base64 string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the result string is about 4/3 of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The boolean argument *padding* specifies the padding. If it is false or nil, -padding is not generated. Otherwise padding is generated. By default, padding -is not generated because "=" may be used as a URL delimiter. - -The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if -*padding* is true. - - require 'random/formatter' - - Random.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg" - # or - prng = Random.new - prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg" - - prng.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ==" - prng.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg==" - -See RFC 3548 for the definition of URL-safe base64. -## uuid() [](#method-c-uuid) -Generate a random v4 UUID (Universally Unique IDentifier). - - require 'random/formatter' - - Random.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594" - Random.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab" - # or - prng = Random.new - prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b" - -The version 4 UUID is purely random (except the version). It doesn't contain -meaningful information such as MAC addresses, timestamps, etc. - -The result contains 122 random bits (15.25 random bytes). - -See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv4. -## uuid_v7(extra_timestamp_bits: 0) [](#method-c-uuid_v7) -Generate a random v7 UUID (Universally Unique IDentifier). - - require 'random/formatter' - - Random.uuid_v7 # => "0188d4c3-1311-7f96-85c7-242a7aa58f1e" - Random.uuid_v7 # => "0188d4c3-16fe-744f-86af-38fa04c62bb5" - Random.uuid_v7 # => "0188d4c3-1af8-764f-b049-c204ce0afa23" - Random.uuid_v7 # => "0188d4c3-1e74-7085-b14f-ef6415dc6f31" - # |<--sorted-->| |<----- random ---->| - - # or - prng = Random.new - prng.uuid_v7 # => "0188ca51-5e72-7950-a11d-def7ff977c98" - -The version 7 UUID starts with the least significant 48 bits of a 64 bit Unix -timestamp (milliseconds since the epoch) and fills the remaining bits with -random data, excluding the version and variant bits. - -This allows version 7 UUIDs to be sorted by creation time. Time ordered UUIDs -can be used for better database index locality of newly inserted records, -which may have a significant performance benefit compared to random data -inserts. - -The result contains 74 random bits (9.25 random bytes). - -Note that this method cannot be made reproducible because its output includes -not only random bits but also timestamp. - -See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv7. - -#### Monotonicity - -UUIDv7 has millisecond precision by default, so multiple UUIDs created within -the same millisecond are not issued in monotonically increasing order. To -create UUIDs that are time-ordered with sub-millisecond precision, up to 12 -bits of additional timestamp may added with `extra_timestamp_bits`. The extra -timestamp precision comes at the expense of random bits. Setting -`extra_timestamp_bits: 12` provides ~244ns of precision, but only 62 random -bits (7.75 random bytes). - - prng = Random.new - Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 12) } - # => - ["0188d4c7-13da-74f9-8b53-22a786ffdd5a", - "0188d4c7-13da-753b-83a5-7fb9b2afaeea", - "0188d4c7-13da-754a-88ea-ac0baeedd8db", - "0188d4c7-13da-7557-83e1-7cad9cda0d8d"] - # |<--- sorted --->| |<-- random --->| - - Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 8) } - # => - ["0188d4c7-3333-7a95-850a-de6edb858f7e", - "0188d4c7-3333-7ae8-842e-bc3a8b7d0cf9", # <- out of order - "0188d4c7-3333-7ae2-995a-9f135dc44ead", # <- out of order - "0188d4c7-3333-7af9-87c3-8f612edac82e"] - # |<--- sorted -->||<---- random --->| - -Any rollbacks of the system clock will break monotonicity. UUIDv7 is based on -UTC, which excludes leap seconds and can rollback the clock. To avoid this, -the system clock can synchronize with an NTP server configured to use a "leap -smear" approach. NTP or PTP will also be needed to synchronize across -distributed nodes. - -Counters and other mechanisms for stronger guarantees of monotonicity are not -implemented. Applications with stricter requirements should follow [Section -6.2](https://www.rfc-editor.org/rfc/rfc9562.html#name-monotonicity-and-counter -s) of the specification. - -#Instance Methods -## alphanumeric(nnil, chars:ALPHANUMERIC) [](#method-i-alphanumeric) -Compatibility methods for Ruby 3.2, we can remove this after dropping to -support Ruby 3.2 - diff --git a/example/ruby/Gem/Security.md b/example/ruby/Gem/Security.md deleted file mode 100644 index 30f959e..0000000 --- a/example/ruby/Gem/Security.md +++ /dev/null @@ -1,52 +0,0 @@ -# Module: Gem::Security - - -forward-declare - - -# Class Methods -## alt_name_or_x509_entry(certificate , x509_entry ) [](#method-c-alt_name_or_x509_entry) -## create_cert(subject , key , age ONE_YEAR, extensions EXTENSIONS, serial 1) [](#method-c-create_cert) -Creates an unsigned certificate for `subject` and `key`. The lifetime of the -key is from the current time to `age` which defaults to one year. - -The `extensions` restrict the key to the indicated uses. -## create_cert_email(email , key , age ONE_YEAR, extensions EXTENSIONS) [](#method-c-create_cert_email) -Creates a self-signed certificate with an issuer and subject from `email`, a -subject alternative name of `email` and the given `extensions` for the `key`. -## create_cert_self_signed(subject , key , age ONE_YEAR, extensions EXTENSIONS, serial 1) [](#method-c-create_cert_self_signed) -Creates a self-signed certificate with an issuer and subject of `subject` and -the given `extensions` for the `key`. -## create_digest(algorithm DIGEST_NAME) [](#method-c-create_digest) -Creates a new digest instance using the specified `algorithm`. The default is -SHA256. -## create_key(algorithm ) [](#method-c-create_key) -Creates a new key pair of the specified `algorithm`. RSA, DSA, and EC are -supported. -## email_to_name(email_address ) [](#method-c-email_to_name) -Turns `email_address` into an OpenSSL::X509::Name -## get_public_key(key ) [](#method-c-get_public_key) -Gets the right public key from a PKey instance -## re_sign(expired_certificate , private_key , age ONE_YEAR, extensions EXTENSIONS) [](#method-c-re_sign) -Signs `expired_certificate` with `private_key` if the keys match and the -expired certificate was self-signed. -- TODO increment serial -**@raise** [Gem::Security::Exception] - -## reset() [](#method-c-reset) -Resets the trust directory for verifying gems. -## sign(certificate , signing_key , signing_cert , age ONE_YEAR, extensions EXTENSIONS, serial 1) [](#method-c-sign) -Sign the public key from `certificate` with the `signing_key` and -`signing_cert`, using the Gem::Security::DIGEST_NAME. Uses the default -certificate validity range and extensions. - -Returns the newly signed certificate. -## trust_dir() [](#method-c-trust_dir) -Returns a Gem::Security::TrustDir which wraps the directory where trusted -certificates live. -## trusted_certificates(&block ) [](#method-c-trusted_certificates) -Enumerates the trusted certificates via Gem::Security::TrustDir. -## write(pemmable , path , permissions 0o600, passphrase nil, cipher KEY_CIPHER) [](#method-c-write) -Writes `pemmable`, which must respond to `to_pem` to `path` with the given -`permissions`. If passed `cipher` and `passphrase` those arguments will be -passed to `to_pem`. - diff --git a/example/ruby/Gem/Security/Exception.md b/example/ruby/Gem/Security/Exception.md deleted file mode 100644 index 5c2c338..0000000 --- a/example/ruby/Gem/Security/Exception.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::Security::Exception -**Inherits:** Gem::Exception - - -Gem::Security default exception type - - - diff --git a/example/ruby/Gem/Security/Policy.md b/example/ruby/Gem/Security/Policy.md deleted file mode 100644 index ec2822b..0000000 --- a/example/ruby/Gem/Security/Policy.md +++ /dev/null @@ -1,151 +0,0 @@ -# Class: Gem::Security::Policy -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - -:nodoc: - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## only_signed[RW] [](#attribute-i-only_signed) -Returns the value of attribute only_signed. - -## only_trusted[RW] [](#attribute-i-only_trusted) -Returns the value of attribute only_trusted. - -## verify_chain[RW] [](#attribute-i-verify_chain) -Returns the value of attribute verify_chain. - -## verify_data[RW] [](#attribute-i-verify_data) -Returns the value of attribute verify_data. - -## verify_root[RW] [](#attribute-i-verify_root) -Returns the value of attribute verify_root. - -## verify_signer[RW] [](#attribute-i-verify_signer) -Returns the value of attribute verify_signer. - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## check_cert(signer, issuer, time) [](#method-i-check_cert) -Ensures that `signer` is valid for `time` and was signed by the `issuer`. If -the `issuer` is `nil` no verification is performed. - -**@raise** [Gem::Security::Exception] - -## check_chain(chain, time) [](#method-i-check_chain) -Verifies each certificate in `chain` has signed the following certificate and -is valid for the given `time`. - -**@raise** [Gem::Security::Exception] - -## check_data(public_key, digest, signature, data) [](#method-i-check_data) -Verifies that `data` matches the `signature` created by `public_key` and the -`digest` algorithm. - -**@raise** [Gem::Security::Exception] - -## check_key(signer, key) [](#method-i-check_key) -Ensures the public key of `key` matches the public key in `signer` - -**@raise** [Gem::Security::Exception] - -## check_root(chain, time) [](#method-i-check_root) -Ensures the root certificate in `chain` is self-signed and valid for `time`. - -**@raise** [Gem::Security::Exception] - -## check_trust(chain, digester, trust_dir) [](#method-i-check_trust) -Ensures the root of `chain` has a trusted certificate in `trust_dir` and the -digests of the two certificates match according to `digester` - -**@raise** [Gem::Security::Exception] - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(name, policy{}, opt{}) [](#method-i-initialize) -Create a new Gem::Security::Policy object with the given mode and options. - -**@return** [Policy] a new instance of Policy - -## inspect() [](#method-i-inspect) -:nodoc: - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## subject(certificate) [](#method-i-subject) -Extracts the email or subject from `certificate` - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - -## verify(chain, keynil, digests{}, signatures{}, full_name"(unknown)") [](#method-i-verify) -For `full_name`, verifies the certificate `chain` is valid, the `digests` -match the signatures `signatures` created by the signer depending on the -`policy` settings. - -If `key` is given it is used to validate the signing certificate. - -## verify_signatures(spec, digests, signatures) [](#method-i-verify_signatures) -Extracts the certificate chain from the `spec` and calls #verify to ensure the -signatures and certificate chain is valid according to the policy.. - diff --git a/example/ruby/Gem/Security/Signer.md b/example/ruby/Gem/Security/Signer.md deleted file mode 100644 index 315051e..0000000 --- a/example/ruby/Gem/Security/Signer.md +++ /dev/null @@ -1,129 +0,0 @@ -# Class: Gem::Security::Signer -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - - - -# Class Methods -## re_sign_cert(expired_cert , expired_cert_path , private_key ) [](#method-c-re_sign_cert) -Attempts to re-sign an expired cert with a given private key -**@yield** [expired_cert_path, new_expired_cert_path] - -# Attributes -## cert_chain[RW] [](#attribute-i-cert_chain) -The chain of certificates for signing including the signing certificate - -## digest_algorithm[RW] [](#attribute-i-digest_algorithm) -The digest algorithm used to create the signature - -## digest_name[RW] [](#attribute-i-digest_name) -The name of the digest algorithm, used to pull digests out of the hash by -name. - -## key[RW] [](#attribute-i-key) -The private key for the signing certificate - -## options[RW] [](#attribute-i-options) -Gem::Security::Signer options - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## extract_name(cert) [](#method-i-extract_name) -Extracts the full name of `cert`. If the certificate has a subjectAltName -this value is preferred, otherwise the subject is used. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(key, cert_chain, passphrasenil, options{}) [](#method-i-initialize) -Creates a new signer with an RSA `key` or path to a key, and a certificate -`chain` containing X509 certificates, encoding certificates or paths to -certificates. - -**@return** [Signer] a new instance of Signer - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## load_cert_chain() [](#method-i-load_cert_chain) -Loads any missing issuers in the cert chain from the trusted certificates. - -If the issuer does not exist it is ignored as it will be checked later. - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## re_sign_key(expiration_length:Gem::Security::ONE_YEAR) [](#method-i-re_sign_key) -Attempts to re-sign the private key if the signing certificate is expired. - -The key will be re-signed if: -* The expired certificate is self-signed -* The expired certificate is saved at ~/.gem/gem-public_cert.pem and the - private key is saved at ~/.gem/gem-private_key.pem -* There is no file matching the expiry date at - ~/.gem/gem-public_cert.pem.expired.%Y%m%d%H%M%S - -If the signing certificate can be re-signed the expired certificate will be -saved as ~/.gem/gem-public_cert.pem.expired.%Y%m%d%H%M%S where the expiry time -(not after) is used for the timestamp. - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## sign(data) [](#method-i-sign) -Sign data with given digest algorithm - -**@raise** [Gem::Security::Exception] - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/Security/TrustDir.md b/example/ruby/Gem/Security/TrustDir.md deleted file mode 100644 index 45c2803..0000000 --- a/example/ruby/Gem/Security/TrustDir.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: Gem::Security::TrustDir -**Inherits:** Object - - -The TrustDir manages the trusted certificates for gem signature verification. - - -# Attributes -## dir[RW] [](#attribute-i-dir) -The directory where trusted certificates will be stored. - - -#Instance Methods -## cert_path(certificate) [](#method-i-cert_path) -Returns the path to the trusted `certificate` - -## each_certificate() [](#method-i-each_certificate) -Enumerates trusted certificates. - -## initialize(dir, permissionsDEFAULT_PERMISSIONS) [](#method-i-initialize) -Creates a new TrustDir using `dir` where the directory and file permissions -will be checked according to `permissions` - -**@return** [TrustDir] a new instance of TrustDir - -## issuer_of(certificate) [](#method-i-issuer_of) -Returns the issuer certificate of the given `certificate` if it exists in the -trust directory. - -## load_certificate(certificate_file) [](#method-i-load_certificate) -Loads the given `certificate_file` - -## name_path(name) [](#method-i-name_path) -Returns the path to the trusted certificate with the given ASN.1 `name` - -## trust_cert(certificate) [](#method-i-trust_cert) -Add a certificate to trusted certificate list. - -## verify() [](#method-i-verify) -Make sure the trust directory exists. If it does exist, make sure it's -actually a directory. If not, then create it with the appropriate -permissions. - diff --git a/example/ruby/Gem/SecurityOption.md b/example/ruby/Gem/SecurityOption.md deleted file mode 100644 index dd6ca58..0000000 --- a/example/ruby/Gem/SecurityOption.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Gem::SecurityOption - - -Mixin methods for security option for Gem::Commands - - - -#Instance Methods -## add_security_option() [](#method-i-add_security_option) - diff --git a/example/ruby/Gem/SilentUI.md b/example/ruby/Gem/SilentUI.md deleted file mode 100644 index e87d4bd..0000000 --- a/example/ruby/Gem/SilentUI.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Gem::SilentUI -**Inherits:** Gem::StreamUI - - -SilentUI is a UI choice that is absolutely silent. - - - -#Instance Methods -## close() [](#method-i-close) - -## download_reporter(*args) [](#method-i-download_reporter) -:nodoc: - -## initialize() [](#method-i-initialize) -The SilentUI has no arguments as it does not use any stream. - -**@return** [SilentUI] a new instance of SilentUI - -## progress_reporter(*args) [](#method-i-progress_reporter) -:nodoc: - diff --git a/example/ruby/Gem/SilentUI/NullIO.md b/example/ruby/Gem/SilentUI/NullIO.md deleted file mode 100644 index 38335e4..0000000 --- a/example/ruby/Gem/SilentUI/NullIO.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Gem::SilentUI::NullIO -**Inherits:** Object - - -An absolutely silent IO. - - - -#Instance Methods -## flush() [](#method-i-flush) - -## gets(*args) [](#method-i-gets) - -## print(*args) [](#method-i-print) - -## puts(*args) [](#method-i-puts) - -## tty?() [](#method-i-tty?) - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Source.md b/example/ruby/Gem/Source.md deleted file mode 100644 index 1019377..0000000 --- a/example/ruby/Gem/Source.md +++ /dev/null @@ -1,162 +0,0 @@ -# Class: Gem::Source -**Inherits:** Object - -**Includes:** Comparable, Gem::Text - - -bundler dependency API and so-forth. - - -# Attributes -## uri[RW] [](#attribute-i-uri) -The URI this source will fetch gems from. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Sources are ordered by installation preference. - -## ==(other) [](#method-i-==) -:nodoc: - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## cache_dir(uri) [](#method-i-cache_dir) -Returns the local directory to write `uri` to. - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## dependency_resolver_set() [](#method-i-dependency_resolver_set) -Returns a Set that can fetch specifications from this source. - -## download(spec, dirDir.pwd) [](#method-i-download) -Downloads `spec` and writes it to `dir`. See also -Gem::RemoteFetcher#download. - -## fetch_spec(name_tuple) [](#method-i-fetch_spec) -Fetches a specification for the given `name_tuple`. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(uri) [](#method-i-initialize) -Creates a new Source which will use the index located at `uri`. - -**@return** [Source] a new instance of Source - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## load_specs(type) [](#method-i-load_specs) -Loads `type` kind of specs fetching from +@uri+ if the on-disk cache is out of -date. - -`type` is one of the following: - -:released => Return the list of all released specs :latest => Return the -list of only the highest version of each gem :prerelease => Return the list of -all prerelease only specs - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## typo_squatting?(host, distance_threshold4) [](#method-i-typo_squatting?) - -**@return** [Boolean] - -## update_cache?() [](#method-i-update_cache?) -Returns true when it is possible and safe to update the cache directory. - -**@return** [Boolean] - diff --git a/example/ruby/Gem/Source/Git.md b/example/ruby/Gem/Source/Git.md deleted file mode 100644 index f57a1ab..0000000 --- a/example/ruby/Gem/Source/Git.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: Gem::Source::Git -**Inherits:** Gem::Source - - -A git gem for use in a gem dependencies file. - -Example: - - source = - Gem::Source::Git.new 'rake', 'git@example:rake.git', 'rake-10.1.0', false - - source.specs - - -# Attributes -## name[RW] [](#attribute-i-name) -The name of the gem created by this git gem. - -## need_submodules[RW] [](#attribute-i-need_submodules) -Does this repository need submodules checked out too? - -## reference[RW] [](#attribute-i-reference) -The commit reference used for checking out this git gem. - -## remote[RW] [](#attribute-i-remote) -When false the cache for this repository will not be updated. - -## repository[RW] [](#attribute-i-repository) -The git repository this gem is sourced from. - -## root_dir[RW] [](#attribute-i-root_dir) -The directory for cache and git gem installation - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - -## ==(other) [](#method-i-==) -:nodoc: - -## base_dir() [](#method-i-base_dir) -Directory where git gems get unpacked and so-forth. - -## cache() [](#method-i-cache) -Creates a local cache repository for the git gem. - -## checkout() [](#method-i-checkout) -Checks out the files for the repository into the install_dir. - -## dir_shortref() [](#method-i-dir_shortref) -A short reference for use in git gem directories - -## download(full_spec, path) [](#method-i-download) -Nothing to download for git gems - -## git_command() [](#method-i-git_command) - -## initialize(name, repository, reference, submodulesfalse) [](#method-i-initialize) -Creates a new git gem source for a gems from loaded from `repository` at the -given `reference`. The `name` is only used to track the repository back to a -gem dependencies file, it has no real significance as a git repository may -contain multiple gems. If `submodules` is true, submodules will be checked -out when the gem is installed. - -**@return** [Git] a new instance of Git - -## install_dir() [](#method-i-install_dir) -The directory where the git gem will be installed. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## repo_cache_dir() [](#method-i-repo_cache_dir) -The directory where the git gem's repository will be cached. - -## rev_parse() [](#method-i-rev_parse) -Converts the git reference for the repository into a commit hash. - -**@raise** [Gem::Exception] - -## specs() [](#method-i-specs) -Loads all gemspecs in the repository - -## uri_hash() [](#method-i-uri_hash) -A hash for the git gem based on the git repository Gem::URI. - diff --git a/example/ruby/Gem/Source/Installed.md b/example/ruby/Gem/Source/Installed.md deleted file mode 100644 index c45e6b2..0000000 --- a/example/ruby/Gem/Source/Installed.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Source::Installed -**Inherits:** Gem::Source - - -Represents an installed gem. This is used for dependency resolution. - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -Installed sources sort before all other sources - -## download(spec, path) [](#method-i-download) -We don't need to download an installed gem - -## initialize() [](#method-i-initialize) -:nodoc: - -**@return** [Installed] a new instance of Installed - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Source/Local.md b/example/ruby/Gem/Source/Local.md deleted file mode 100644 index 4ddbbac..0000000 --- a/example/ruby/Gem/Source/Local.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Gem::Source::Local -**Inherits:** Gem::Source - - -The local source finds gems in the current directory for fulfilling -dependencies. - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -Local sorts before Gem::Source and after Gem::Source::Installed - -## download(spec, cache_dirnil) [](#method-i-download) -:nodoc: - -**@raise** [Gem::Exception] - -## fetch_spec(name) [](#method-i-fetch_spec) -:nodoc: - -## find_gem(gem_name, versionGem::Requirement.default, prereleasefalse) [](#method-i-find_gem) -:nodoc: - -## initialize() [](#method-i-initialize) -:nodoc: - -**@return** [Local] a new instance of Local - -## inspect() [](#method-i-inspect) -:nodoc: - -## load_specs(type) [](#method-i-load_specs) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Source/Lock.md b/example/ruby/Gem/Source/Lock.md deleted file mode 100644 index f40d219..0000000 --- a/example/ruby/Gem/Source/Lock.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Gem::Source::Lock -**Inherits:** Gem::Source - - -A Lock source wraps an installed gem's source and sorts before other sources -during dependency resolution. This allows RubyGems to prefer gems from -dependency lock files. - - -# Attributes -## wrapped[RW] [](#attribute-i-wrapped) -The wrapped Gem::Source - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -:nodoc: - -## ==(other) [](#method-i-==) -:nodoc: - -## fetch_spec(name_tuple) [](#method-i-fetch_spec) -Delegates to the wrapped source's fetch_spec method. - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(source) [](#method-i-initialize) -Creates a new Lock source that wraps `source` and moves it earlier in the sort -list. - -**@return** [Lock] a new instance of Lock - -## uri() [](#method-i-uri) -:nodoc: - diff --git a/example/ruby/Gem/Source/SpecificFile.md b/example/ruby/Gem/Source/SpecificFile.md deleted file mode 100644 index dc8bf1c..0000000 --- a/example/ruby/Gem/Source/SpecificFile.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Gem::Source::SpecificFile -**Inherits:** Gem::Source - - -A source representing a single .gem file. This is used for installation of -local gems. - - -# Attributes -## path[RW] [](#attribute-i-path) -The path to the gem for this specific file. - -## spec[RW] [](#attribute-i-spec) -The Gem::Specification extracted from this .gem. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -Orders this source against `other`. - -If `other` is a SpecificFile from a different gem name `nil` is returned. - -If `other` is a SpecificFile from the same gem name the versions are compared -using Gem::Version#<=> - -Otherwise Gem::Source#<=> is used. - -## download(spec, dirnil) [](#method-i-download) -:nodoc: - -**@raise** [Gem::Exception] - -## fetch_spec(name) [](#method-i-fetch_spec) -:nodoc: - -**@raise** [Gem::Exception] - -## initialize(file) [](#method-i-initialize) -Creates a new SpecificFile for the gem in `file` - -**@return** [SpecificFile] a new instance of SpecificFile - -## load_specs(*a) [](#method-i-load_specs) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/Gem/Source/Vendor.md b/example/ruby/Gem/Source/Vendor.md deleted file mode 100644 index de6c977..0000000 --- a/example/ruby/Gem/Source/Vendor.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Gem::Source::Vendor -**Inherits:** Gem::Source::Installed - - -This represents a vendored source that is similar to an installed gem. - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - -## initialize(path) [](#method-i-initialize) -Creates a new Vendor source for a gem that was unpacked at `path`. - -**@return** [Vendor] a new instance of Vendor - diff --git a/example/ruby/Gem/SourceFetchProblem.md b/example/ruby/Gem/SourceFetchProblem.md deleted file mode 100644 index 9e433d4..0000000 --- a/example/ruby/Gem/SourceFetchProblem.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Gem::SourceFetchProblem -**Inherits:** Gem::ErrorReason - - -An error that indicates we weren't able to fetch some data from a source - - -# Attributes -## error[RW] [](#attribute-i-error) -The fetch error which is an Exception subclass. - -## source[RW] [](#attribute-i-source) -The source that had the fetch problem. - - -#Instance Methods -## initialize(source, error) [](#method-i-initialize) -Creates a new SourceFetchProblem for the given `source` and `error`. - -**@return** [SourceFetchProblem] a new instance of SourceFetchProblem - -## wordy() [](#method-i-wordy) -An English description of the error. - diff --git a/example/ruby/Gem/SourceList.md b/example/ruby/Gem/SourceList.md deleted file mode 100644 index ee0826b..0000000 --- a/example/ruby/Gem/SourceList.md +++ /dev/null @@ -1,2090 +0,0 @@ -# Class: Gem::SourceList -**Inherits:** Object - -**Includes:** Enumerable - - -The SourceList represents the sources rubygems has been configured to use. A -source may be created from an array of sources: - - Gem::SourceList.from %w[https://rubygems.example https://internal.example] - -Or by adding them: - - sources = Gem::SourceList.new - sources << 'https://rubygems.example' - -The most common way to get a SourceList is Gem.sources. - - -# Class Methods -## from(ary ) [](#method-c-from) -Creates a new SourceList from an array of sources. -# Attributes -## sources[RW] [](#attribute-i-sources) -The sources in this list - - -#Instance Methods -## <<(obj) [](#method-i-<<) -Appends `obj` to the source list which may be a Gem::Source, Gem::URI or URI -String. - -## ==(other) [](#method-i-==) -:nodoc: - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## clear() [](#method-i-clear) -Removes all sources from the SourceList. - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete(source) [](#method-i-delete) -Deletes `source` from the source list which may be a Gem::Source or a URI. - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Yields each source URI in the list. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_source(&b) [](#method-i-each_source) -Yields each source in the list. - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Returns true if there are no sources in this SourceList. - -**@return** [Boolean] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first() [](#method-i-first) -Returns the first source in the list. - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(other) [](#method-i-include?) -Returns true if this source list includes `other` which may be a Gem::Source -or a source URI. - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) -Creates a new SourceList - -**@return** [SourceList] a new instance of SourceList - -## initialize_copy(other) [](#method-i-initialize_copy) -:nodoc: - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## replace(other) [](#method-i-replace) -Replaces this SourceList with the sources in `other` See #<< for acceptable -items in `other`. - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) -Returns an Array of source URI Strings. - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/SpecFetcher.md b/example/ruby/Gem/SpecFetcher.md deleted file mode 100644 index cbdd80b..0000000 --- a/example/ruby/Gem/SpecFetcher.md +++ /dev/null @@ -1,130 +0,0 @@ -# Class: Gem::SpecFetcher -**Inherits:** Object - -**Includes:** Gem::Text, Gem::UserInteraction - - -SpecFetcher handles metadata updates from remote gem repositories. - - -# Class Methods -## fetcher() [](#method-c-fetcher) -Default fetcher instance. Use this instead of ::new to reduce object -allocation. -## fetcher=(fetcher ) [](#method-c-fetcher=) -:nodoc: -# Attributes -## latest_specs[RW] [](#attribute-i-latest_specs) -Cache of latest specs - -## prerelease_specs[RW] [](#attribute-i-prerelease_specs) -Cache of prerelease specs - -## sources[RW] [](#attribute-i-sources) -Sources for this SpecFetcher - -## specs[RW] [](#attribute-i-specs) -Cache of all released specs - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## available_specs(type) [](#method-i-available_specs) -Returns a list of gems available for each source in Gem::sources. - -`type` can be one of 3 values: :released => Return the list of all released -specs :complete => Return the list of all specs :latest => Return the -list of only the highest version of each gem :prerelease => Return the list of -all prerelease only specs - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## detect(type:complete) [](#method-i-detect) -Return all gem name tuples who's names match `obj` - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(sourcesnil) [](#method-i-initialize) -Creates a new SpecFetcher. Ordinarily you want to use the default fetcher -from Gem::SpecFetcher::fetcher which uses the Gem.sources. - -If you need to retrieve specifications from a different `source`, you can send -it as an argument. - -**@return** [SpecFetcher] a new instance of SpecFetcher - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## search_for_dependency(dependency, matching_platformtrue) [](#method-i-search_for_dependency) -Find and fetch gem name tuples that match `dependency`. - -If `matching_platform` is false, gems for all platforms are returned. - -## spec_for_dependency(dependency, matching_platformtrue) [](#method-i-spec_for_dependency) -Find and fetch specs that match `dependency`. - -If `matching_platform` is false, gems for all platforms are returned. - -## suggest_gems_from_name(gem_name, type:latest, num_results5) [](#method-i-suggest_gems_from_name) -Suggests gems based on the supplied `gem_name`. Returns an array of -alternative gem names. - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## tuples_for(source, type, gracefully_ignorefalse) [](#method-i-tuples_for) -Retrieves NameTuples from `source` of the given `type` (:prerelease, etc.). -If `gracefully_ignore` is true, errors are ignored. - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/SpecificGemNotFoundException.md b/example/ruby/Gem/SpecificGemNotFoundException.md deleted file mode 100644 index 91fcc7e..0000000 --- a/example/ruby/Gem/SpecificGemNotFoundException.md +++ /dev/null @@ -1,25 +0,0 @@ -# Exception: Gem::SpecificGemNotFoundException -**Inherits:** Gem::GemNotFoundException - - - - -# Attributes -## errors[RW] [](#attribute-i-errors) -Errors encountered attempting to find the gem. - -## name[RW] [](#attribute-i-name) -The name of the gem that could not be found. - -## version[RW] [](#attribute-i-version) -The version of the gem that could not be found. - - -#Instance Methods -## initialize(name, version, errorsnil) [](#method-i-initialize) -Creates a new SpecificGemNotFoundException for a gem with the given `name` and -`version`. Any `errors` encountered when attempting to find the gem are also -stored. - -**@return** [SpecificGemNotFoundException] a new instance of SpecificGemNotFoundException - diff --git a/example/ruby/Gem/Specification.md b/example/ruby/Gem/Specification.md deleted file mode 100644 index 1b2cfb5..0000000 --- a/example/ruby/Gem/Specification.md +++ /dev/null @@ -1,2931 +0,0 @@ -# Class: Gem::Specification -**Inherits:** Gem::BasicSpecification - -**Extended by:** Enumerable, Gem::Deprecate, Gem::Specification::RequirePathFlattener - -**Includes:** Bundler::MatchMetadata, Bundler::MatchPlatform, Gem::Specification::AllowSettingSource - - -The Specification class contains the information for a gem. Typically defined -in a .gemspec file or a Rakefile, and looks like this: - - Gem::Specification.new do |s| - s.name = 'example' - s.version = '0.1.0' - s.licenses = ['MIT'] - s.summary = "This is an example!" - s.description = "Much longer explanation of the example!" - s.authors = ["Ruby Coder"] - s.email = 'rubycoder@example.com' - s.files = ["lib/example.rb"] - s.homepage = 'https://rubygems.org/gems/example' - s.metadata = { "source_code_uri" => "https://github.com/example/example" } - end - -Starting in RubyGems 2.0, a Specification can hold arbitrary metadata. See -#metadata for restrictions on the format and size of metadata items you may -add to a specification. - - -# Class Methods -## _all() [](#method-c-_all) -:nodoc: -## _latest_specs(specs , prerelease false) [](#method-c-_latest_specs) -:nodoc: -## _load(str ) [](#method-c-_load) -Load custom marshal format, re-initializing defaults as needed -## _resort!(specs ) [](#method-c-_resort!) -:nodoc: -## add_spec(spec ) [](#method-c-add_spec) -Adds `spec` to the known specifications, keeping the collection properly -sorted. -## all() [](#method-c-all) -Returns all specifications. This method is discouraged from use. You probably -want to use one of the Enumerable methods instead. -## all=(specs ) [](#method-c-all=) -Sets the known specs to `specs`. -## all?(*args ) [](#method-c-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## all_names() [](#method-c-all_names) -Return full names of all specs in sorted order. -## any?(*args ) [](#method-c-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## array_attributes() [](#method-c-array_attributes) -Return the list of all array-oriented instance variables. -- Not sure why we -need to use so much stupid reflection in here... -## attribute_names() [](#method-c-attribute_names) -Return the list of all instance variables. -- Not sure why we need to use so -much stupid reflection in here... -## chain(*args ) [](#method-c-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] -**@overload** [] - -## chunk() [](#method-c-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } -**@overload** [] - -## chunk_while() [](#method-c-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. -**@overload** [] - -## collect() [](#method-c-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-c-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. -**@overload** [] - -**@overload** [] - -## compact() [](#method-c-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] -**@overload** [] - -## count(*args ) [](#method-c-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args ) [](#method-c-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## default_stubs(pattern "*.gemspec") [](#method-c-default_stubs) -Returns a Gem::StubSpecification for default gems -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -## detect(*args ) [](#method-c-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## dirs() [](#method-c-dirs) -Return the directories that Specification uses to find specs. -## dirs=(dirs ) [](#method-c-dirs=) -Set the directories that Specification uses to find specs. Setting this resets -the list of known specs. -## drop(n ) [](#method-c-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] -**@overload** [] - -## drop_while() [](#method-c-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each(&block ) [](#method-c-each) -Enumerate every known spec. See ::dirs= and ::add_spec to set the list of -specs. -## each_cons(n ) [](#method-c-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_entry(*args ) [](#method-c-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_gemspec(dirs ) [](#method-c-each_gemspec) -:nodoc: -## each_slice(n ) [](#method-c-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_spec(dirs ) [](#method-c-each_spec) -:nodoc: -## each_with_index(*args ) [](#method-c-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## each_with_object(memo ) [](#method-c-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## entries(*args ) [](#method-c-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] -**@overload** [] - -## filter() [](#method-c-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-c-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## find(*args ) [](#method-c-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## find_active_stub_by_path(path ) [](#method-c-find_active_stub_by_path) -Return the best specification that contains the file matching `path`, among -those already activated. -## find_all() [](#method-c-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. -**@overload** [] - -**@overload** [] - -## find_all_by_full_name(full_name ) [](#method-c-find_all_by_full_name) -Returns every spec that has the given `full_name` -## find_all_by_name(name , *requirements ) [](#method-c-find_all_by_name) -Returns every spec that matches `name` and optional `requirements`. -## find_by_full_name(full_name ) [](#method-c-find_by_full_name) -Find the best specification matching a `full_name`. -## find_by_name(name , *requirements ) [](#method-c-find_by_name) -Find the best specification matching a `name` and `requirements`. Raises if -the dependency doesn't resolve to a valid specification. -## find_by_path(path ) [](#method-c-find_by_path) -Return the best specification that contains the file matching `path`. -## find_in_unresolved(path ) [](#method-c-find_in_unresolved) -Return currently unresolved specs that contain the file matching `path`. -## find_in_unresolved_tree(path ) [](#method-c-find_in_unresolved_tree) -Search through all unresolved deps and sub-dependencies and return specs that -contain the file matching `path`. -## find_inactive_by_path(path ) [](#method-c-find_inactive_by_path) -Return the best specification that contains the file matching `path` amongst -the specs that are not activated. -## find_index(*args ) [](#method-c-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args ) [](#method-c-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-c-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. -**@overload** [] - -**@overload** [] - -## from_yaml(input ) [](#method-c-from_yaml) -Special loader for YAML files. When a Specification object is loaded from a -YAML file, it bypasses the normal Ruby object initialization routine -(#initialize). This method makes up for that and deals with gems of different -ages. - -`input` can be anything that YAML.load() accepts: String or IO. -## gemspec_stubs_in(dir , pattern ) [](#method-c-gemspec_stubs_in) -:nodoc: -## grep(pat ) [](#method-c-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. -**@overload** [] - -**@overload** [] - -## grep_v(pat ) [](#method-c-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. -**@overload** [] - -**@overload** [] - -## group_by() [](#method-c-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## include?(val ) [](#method-c-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false -**@overload** [] - -## inject(*args ) [](#method-c-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## latest_spec_for(name ) [](#method-c-latest_spec_for) -Return the latest installed spec for gem `name`. -## latest_specs(prerelease false) [](#method-c-latest_specs) -Return the latest specs, optionally including prerelease specs if `prerelease` -is true. -## lazy() [](#method-c-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force -**@overload** [] - -## load(file ) [](#method-c-load) -Loads Ruby format gemspec from `file`. -## load_defaults() [](#method-c-load_defaults) -Loads the default specifications. It should be called only once. -## map() [](#method-c-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## max(*args ) [](#method-c-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args ) [](#method-c-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val ) [](#method-c-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false -**@overload** [] - -## min(*args ) [](#method-c-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args ) [](#method-c-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-c-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-c-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. -**@overload** [] - -**@overload** [] - -## non_nil_attributes() [](#method-c-non_nil_attributes) -Specification attributes that must be non-nil -## none?(*args ) [](#method-c-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## normalize_yaml_input(input ) [](#method-c-normalize_yaml_input) -Make sure the YAML specification is properly formatted with dashes -## one?(*args ) [](#method-c-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## outdated() [](#method-c-outdated) -Return a list of all outdated local gem names. This method is HEAVY as it -must go fetch specifications from the server. - -Use outdated_and_latest_version if you wish to retrieve the latest remote -version as well. -## outdated_and_latest_version() [](#method-c-outdated_and_latest_version) -Enumerates the outdated local gems yielding the local specification and the -latest remote version. - -This method may take some time to return as it must check each local gem -against the server's index. -## partition() [](#method-c-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. -**@overload** [] - -**@overload** [] - -## reduce(*args ) [](#method-c-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-c-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. -**@overload** [] - -**@overload** [] - -## remove_spec(spec ) [](#method-c-remove_spec) -Removes `spec` from the known specs. -## required_attribute?(name ) [](#method-c-required_attribute?) -Is `name` a required attribute? -**@return** [Boolean] - -## required_attributes() [](#method-c-required_attributes) -Required specification attributes -## reset() [](#method-c-reset) -Reset the list of known specs, running pre and post reset hooks registered in -Gem. -## reverse_each(*args ) [](#method-c-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## select() [](#method-c-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. -**@overload** [] - -**@overload** [] - -## slice_after(*args ) [](#method-c-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] -**@overload** [] - -**@overload** [] - -## slice_before(*args ) [](#method-c-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-c-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. -**@overload** [] - -## sort() [](#method-c-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-c-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! -**@overload** [] - -**@overload** [] - -## specification_record() [](#method-c-specification_record) -Keeps track of all currently known specifications -## stubs() [](#method-c-stubs) -Returns a Gem::StubSpecification for every installed gem -## stubs_for(name ) [](#method-c-stubs_for) -Returns a Gem::StubSpecification for installed gem named `name` only returns -stubs that match Gem.platforms -## stubs_for_pattern(pattern , match_platform true) [](#method-c-stubs_for_pattern) -Finds stub specifications matching a pattern from the standard locations, -optionally filtering out specs not matching the current platform -## sum(*args ) [](#method-c-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" -**@overload** [] - -**@overload** [] - -## take(n ) [](#method-c-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] -**@overload** [] - -## take_while() [](#method-c-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. -**@overload** [] - -**@overload** [] - -## tally(*args ) [](#method-c-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} -**@overload** [] - -## to_a(*args ) [](#method-c-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] -**@overload** [] - -## to_h(*args ) [](#method-c-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. -**@overload** [] - -**@overload** [] - -## to_set(klass Set, *args , &block ) [](#method-c-to_set) -Makes a set from the enumerable object with given arguments. -## uniq() [](#method-c-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] -**@overload** [] - -**@overload** [] - -## unresolved_deps() [](#method-c-unresolved_deps) -DOC: This method needs documented or nodoc'd -## zip(*args ) [](#method-c-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] -**@overload** [] - -**@overload** [] - -# Attributes -## activated[RW] [](#attribute-i-activated) -True when this gemspec has been activated. This attribute is not persisted. - -## autorequire[RW] [](#attribute-i-autorequire) -Autorequire was used by old RubyGems to automatically require a file. - -Deprecated: It is neither supported nor functional. - -## bindir[RW] [](#attribute-i-bindir) -The path in the gem for executable scripts. Usually 'exe' - -Usage: - - spec.bindir = 'exe' - -## cert_chain[RW] [](#attribute-i-cert_chain) -The certificate chain used to sign this gem. See Gem::Security for details. - -## default_executable[RW] [](#attribute-i-default_executable) -The default executable for this gem. - -Deprecated: The name of the gem is assumed to be the name of the executable -now. See Gem.bin_path. - -## description[RW] [](#attribute-i-description) -A long description of this gem - -The description should be more detailed than the summary but not excessively -long. A few paragraphs is a recommended length with no examples or -formatting. - -Usage: - - spec.description = <<~EOF - Rake is a Make-like program implemented in Ruby. Tasks and - dependencies are specified in standard Ruby syntax. - EOF - -## email[RW] [](#attribute-i-email) -A contact email address (or addresses) for this gem - -Usage: - - spec.email = 'john.jones@example.com' - spec.email = ['jack@example.com', 'jill@example.com'] - -## homepage[RW] [](#attribute-i-homepage) -The URL of this gem's home page - -Usage: - - spec.homepage = 'https://github.com/ruby/rake' - -## metadata[RW] [](#attribute-i-metadata) -The metadata holds extra data for this gem that may be useful to other -consumers and is settable by gem authors. - -Metadata items have the following restrictions: - -* The metadata must be a Hash object -* All keys and values must be Strings -* Keys can be a maximum of 128 bytes and values can be a maximum of 1024 - bytes -* All strings must be UTF-8, no binary data is allowed - -You can use metadata to specify links to your gem's homepage, codebase, -documentation, wiki, mailing list, issue tracker and changelog. - - s.metadata = { - "bug_tracker_uri" => "https://example.com/user/bestgemever/issues", - "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md", - "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", - "homepage_uri" => "https://bestgemever.example.io", - "mailing_list_uri" => "https://groups.example.com/bestgemever", - "source_code_uri" => "https://example.com/user/bestgemever", - "wiki_uri" => "https://example.com/user/bestgemever/wiki", - "funding_uri" => "https://example.com/donate" - } - -These links will be used on your gem's page on rubygems.org and must pass -validation against following regex. - - %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z} - -## name[RW] [](#attribute-i-name) -This gem's name. - -Usage: - - spec.name = 'rake' - -## original_platform[RW] [](#attribute-i-original_platform) -Cruft. Use `platform`. - -## post_install_message[RW] [](#attribute-i-post_install_message) -A message that gets displayed after the gem is installed. - -Usage: - - spec.post_install_message = "Thanks for installing!" - -## relative_loaded_from[RW] [](#attribute-i-relative_loaded_from) -Returns the value of attribute relative_loaded_from. - -## remote[RW] [](#attribute-i-remote) -Returns the value of attribute remote. - -## required_ruby_version[RW] [](#attribute-i-required_ruby_version) -The version of Ruby required by this gem - -Usage: - - spec.required_ruby_version = '>= 2.7.0' - -## required_rubygems_version[RW] [](#attribute-i-required_rubygems_version) -The RubyGems version required by this gem - -## rubygems_version[RW] [](#attribute-i-rubygems_version) -The version of RubyGems used to create this gem. - -## signing_key[RW] [](#attribute-i-signing_key) -The key used to sign this gem. See Gem::Security for details. - -## specification_version[RW] [](#attribute-i-specification_version) -The Gem::Specification version of this gemspec. - -Do not set this, it is set automatically when the gem is packaged. - -## summary[RW] [](#attribute-i-summary) -A short summary of this gem's description. Displayed in `gem list -d`. - -The #description should be more detailed than the summary. - -Usage: - - spec.summary = "This is a small summary of my gem" - -## version[RW] [](#attribute-i-version) -This gem's version. - -The version string can contain numbers and periods, such as `1.0.0`. A gem is -a 'prerelease' gem if the version has a letter in it, such as `1.0.0.pre`. - -Usage: - - spec.version = '0.4.1' - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -:nodoc: - -## ==(other) [](#method-i-==) -:nodoc: - -## _dump(limit) [](#method-i-_dump) -Dump only crucial instance variables. -- MAINTAIN ORDER! (down with the man) - -## abbreviate() [](#method-i-abbreviate) -Abbreviate the spec for downloading. Abbreviated specs are only used for -searching, downloading and related activities and do not need deployment -specific information (e.g. list of files). So we abbreviate the spec, making -it much smaller for quicker downloads. - -## activate() [](#method-i-activate) -Activate this spec, registering it as a loaded spec and adding it's lib paths -to $LOAD_PATH. Returns true if the spec was activated, false if it was -previously activated. Freaks out if there are conflicts upon activation. - -## activate_dependencies() [](#method-i-activate_dependencies) -Activate all unambiguously resolved runtime dependencies of this spec. Add any -ambiguous dependencies to the unresolved list to be resolved later, as needed. - -## add_bindir(executables) [](#method-i-add_bindir) -Returns an array with bindir attached to each executable in the `executables` -list - -## add_dependency(gem, *requirements) [](#method-i-add_dependency) -Adds a runtime dependency named `gem` with `requirements` to this gem. - -Usage: - - spec.add_dependency 'example', '~> 1.1', '>= 1.1.4' - -## add_development_dependency(gem, *requirements) [](#method-i-add_development_dependency) -Adds a development dependency named `gem` with `requirements` to this gem. - -Usage: - - spec.add_development_dependency 'example', '~> 1.1', '>= 1.1.4' - -Development dependencies aren't installed by default and aren't activated when -a gem is required. - -## add_self_to_load_path() [](#method-i-add_self_to_load_path) -Adds this spec's require paths to LOAD_PATH, in the proper location. - -## author() [](#method-i-author) -Singular reader for #authors. Returns the first author in the list - -## author=(o) [](#method-i-author=) -Singular (alternative) writer for #authors - -Usage: - - spec.author = 'John Jones' - -## authors() [](#method-i-authors) -The list of author names who wrote this gem. - - spec.authors = ['Chad Fowler', 'Jim Weirich', 'Rich Kilmer'] - -## authors=(value) [](#method-i-authors=) -A list of authors for this gem. - -Alternatively, a single author can be specified by assigning a string to -`spec.author` - -Usage: - - spec.authors = ['John Jones', 'Mary Smith'] - -## base_dir() [](#method-i-base_dir) - -## bin_dir() [](#method-i-bin_dir) -Returns the full path to installed gem's bin directory. - -NOTE: do not confuse this with `bindir`, which is just 'bin', not a full path. - -## bin_file(name) [](#method-i-bin_file) -Returns the full path to an executable named `name` in this gem. - -## build_args() [](#method-i-build_args) -Returns the build_args used to install the gem - -## build_extensions() [](#method-i-build_extensions) -Builds extensions for this platform if the gem has extensions listed and the -gem.build_complete file is missing. - -## build_info_dir() [](#method-i-build_info_dir) -Returns the full path to the build info directory - -## build_info_file() [](#method-i-build_info_file) -Returns the full path to the file containing the build information generated -when the gem was installed - -## cache_dir() [](#method-i-cache_dir) -Returns the full path to the cache directory containing this spec's cached -gem. - -## cache_file() [](#method-i-cache_file) -Returns the full path to the cached gem for this spec. - -## conficts_when_loaded_with?(list_of_specs) [](#method-i-conficts_when_loaded_with?) -return true if there will be conflict when spec if loaded together with the -list of specs. - -**@return** [Boolean] - -## conflicts() [](#method-i-conflicts) -Return any possible conflicts against the currently loaded specs. - -## date() [](#method-i-date) -The date this gem was created. - -If SOURCE_DATE_EPOCH is set as an environment variable, use that to support -reproducible builds; otherwise, default to the current UTC date. - -Details on SOURCE_DATE_EPOCH: -https://reproducible-builds.org/specs/source-date-epoch/ - -## date=(date) [](#method-i-date=) -The date this gem was created - -DO NOT set this, it is set automatically when the gem is packaged. - -## default_value(name) [](#method-i-default_value) -The default value for specification attribute `name` - -## deleted_gem?() [](#method-i-deleted_gem?) - -**@return** [Boolean] - -## dependencies() [](#method-i-dependencies) -A list of Gem::Dependency objects this gem depends on. - -Use #add_dependency or #add_development_dependency to add dependencies to a -gem. - -## dependent_gems(check_devtrue) [](#method-i-dependent_gems) -Return a list of all gems that have a dependency on this gemspec. The list is -structured with entries that conform to: - - [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]] - -## dependent_specs() [](#method-i-dependent_specs) -Returns all specs that matches this spec's runtime dependencies. - -## development_dependencies() [](#method-i-development_dependencies) -List of dependencies that are used for development - -## doc_dir(typenil) [](#method-i-doc_dir) -Returns the full path to this spec's documentation directory. If `type` is -given it will be appended to the end. For example: - - spec.doc_dir # => "/path/to/gem_repo/doc/a-1" - - spec.doc_dir 'ri' # => "/path/to/gem_repo/doc/a-1/ri" - -## encode_with(coder) [](#method-i-encode_with) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## executable() [](#method-i-executable) -Singular accessor for #executables - -## executable=(o) [](#method-i-executable=) -Singular accessor for #executables - -## executables() [](#method-i-executables) -Executables included in the gem. - -For example, the rake gem has rake as an executable. You don't specify the -full path (as in bin/rake); all application-style files are expected to be -found in bindir. These files must be executable Ruby files. Files that use -bash or other interpreters will not work. - -Executables included may only be ruby scripts, not scripts for other languages -or compiled binaries. - -Usage: - - spec.executables << 'rake' - -## executables=(value) [](#method-i-executables=) -Sets executables to `value`, ensuring it is an array. - -## extension_dir() [](#method-i-extension_dir) - -## extensions() [](#method-i-extensions) -Extensions to build when installing the gem, specifically the paths to -extconf.rb-style files used to compile extensions. - -These files will be run when the gem is installed, causing the C (or whatever) -code to be compiled on the user's machine. - -Usage: - - spec.extensions << 'ext/rmagic/extconf.rb' - -See Gem::Ext::Builder for information about writing extensions for gems. - -## extensions=(extensions) [](#method-i-extensions=) -Sets extensions to `extensions`, ensuring it is an array. - -## extensions_dir() [](#method-i-extensions_dir) -The path where this gem installs its extensions. - -## extra_rdoc_files() [](#method-i-extra_rdoc_files) -Extra files to add to RDoc such as README or doc/examples.txt - -When the user elects to generate the RDoc documentation for a gem (typically -at install time), all the library files are sent to RDoc for processing. This -option allows you to have some non-code files included for a more complete set -of documentation. - -Usage: - - spec.extra_rdoc_files = ['README', 'doc/user-guide.txt'] - -## extra_rdoc_files=(files) [](#method-i-extra_rdoc_files=) -Sets extra_rdoc_files to `files`, ensuring it is an array. - -## file_name() [](#method-i-file_name) -The default (generated) file name of the gem. See also #spec_name. - - spec.file_name # => "example-1.0.gem" - -## files() [](#method-i-files) -Files included in this gem. You cannot append to this accessor, you must -assign to it. - -Only add files you can require to this list, not directories, etc. - -Directories are automatically stripped from this list when building a gem, -other non-files cause an error. - -Usage: - - require 'rake' - spec.files = FileList['lib/**/*.rb', - 'bin/*', - '[A-Z]*'].to_a - - # or without Rake... - spec.files = Dir['lib/**/*.rb'] + Dir['bin/*'] - spec.files += Dir['[A-Z]*'] - spec.files.reject! { |fn| fn.include? "CVS" } - -## files=(files) [](#method-i-files=) -Sets files to `files`, ensuring it is an array. - -## flatten_require_paths() [](#method-i-flatten_require_paths) -:nodoc: - -## for_cache() [](#method-i-for_cache) -Creates a duplicate spec without large blobs that aren't used at runtime. - -## full_gem_path() [](#method-i-full_gem_path) - -## full_name() [](#method-i-full_name) - -## gem_dir() [](#method-i-gem_dir) -Work around old bundler versions removing my methods Can be removed once -RubyGems can no longer install Bundler 2.5 - -## gems_dir() [](#method-i-gems_dir) - -## git_version() [](#method-i-git_version) - -## groups() [](#method-i-groups) - -## has_conflicts?() [](#method-i-has_conflicts?) -Return true if there are possible conflicts against the currently loaded -specs. - -**@return** [Boolean] - -## has_rdoc() [](#method-i-has_rdoc) -Deprecated and ignored, defaults to true. - -Formerly used to indicate this gem was RDoc-capable. - -## has_rdoc=(ignored) [](#method-i-has_rdoc=) -Deprecated and ignored. - -Formerly used to indicate this gem was RDoc-capable. - -## has_unit_tests?() [](#method-i-has_unit_tests?) -True if this gem has files in test_files - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:startdoc: - -## init_with(coder) [](#method-i-init_with) -:nodoc: - -## initialize(namenil, versionnil) [](#method-i-initialize) -Specification constructor. Assigns the default values to the attributes and -yields itself for further initialization. Optionally takes `name` and -`version`. - -**@return** [Specification] a new instance of Specification - -**@yield** [_self] - -**@yieldparam** [Gem::Specification] the object that the method was called on - -## initialize_copy(other_spec) [](#method-i-initialize_copy) -Duplicates Array and Gem::Requirement attributes from `other_spec` so state -isn't shared. - -## insecurely_materialized?() [](#method-i-insecurely_materialized?) - -**@return** [Boolean] - -## inspect() [](#method-i-inspect) -:nodoc: - -## installed_by_version() [](#method-i-installed_by_version) -The version of RubyGems that installed this gem. Returns -`Gem::Version.new(0)` for gems installed by versions earlier than RubyGems -2.2.0. - -## installed_by_version=(version) [](#method-i-installed_by_version=) -Sets the version of RubyGems that installed this gem. See also -#installed_by_version. - -## internal_init() [](#method-i-internal_init) -:nodoc: - -## keep_only_files_and_directories() [](#method-i-keep_only_files_and_directories) - -## lib_files() [](#method-i-lib_files) -Files in the Gem under one of the require_paths - -## license() [](#method-i-license) -Singular accessor for #licenses - -## license=(o) [](#method-i-license=) -The license for this gem. - -The license must be no more than 64 characters. - -This should just be the name of your license. The full text of the license -should be inside of the gem (at the top level) when you build it. - -The simplest way is to specify the standard SPDX ID https://spdx.org/licenses/ -for the license. Ideally, you should pick one that is OSI (Open Source -Initiative) https://opensource.org/licenses/ approved. - -The most commonly used OSI-approved licenses are MIT and Apache-2.0. GitHub -also provides a license picker at https://choosealicense.com/. - -You can also use a custom license file along with your gemspec and specify a -LicenseRef-, where idstring is the name of the file containing the -license text. - -You should specify a license for your gem so that people know how they are -permitted to use it and any restrictions you're placing on it. Not specifying -a license means all rights are reserved; others have no right to use the code -for any purpose. - -You can set multiple licenses with #licenses= - -Usage: - spec.license = 'MIT' - -## licenses() [](#method-i-licenses) -Plural accessor for setting licenses - -See #license= for details - -## licenses=(licenses) [](#method-i-licenses=) -The license(s) for the library. - -Each license must be a short name, no more than 64 characters. - -This should just be the name of your license. The full text of the license -should be inside of the gem when you build it. - -See #license= for more discussion - -Usage: - spec.licenses = ['MIT', 'GPL-2.0'] - -## load_paths() [](#method-i-load_paths) - -## loaded_from() [](#method-i-loaded_from) - -## match_platform(p) [](#method-i-match_platform) - -## matches_current_metadata?() [](#method-i-matches_current_metadata?) - -**@return** [Boolean] - -## matches_current_ruby?() [](#method-i-matches_current_ruby?) - -**@return** [Boolean] - -## matches_current_rubygems?() [](#method-i-matches_current_rubygems?) - -**@return** [Boolean] - -## method_missing(sym, *a, &b) [](#method-i-method_missing) -Track removed method calls to warn about during build time. Warn about unknown -attributes while loading a spec. - -## missing_extensions?() [](#method-i-missing_extensions?) -Is this specification missing its extensions? When this returns true you -probably want to build_extensions - -**@return** [Boolean] - -## name_tuple() [](#method-i-name_tuple) -Return a NameTuple that represents this Specification - -## nondevelopment_dependencies() [](#method-i-nondevelopment_dependencies) - -## normalize() [](#method-i-normalize) -Normalize the list of files so that: -* All file lists have redundancies removed. -* Files referenced in the extra_rdoc_files are included in the package file - list. - -## original_name() [](#method-i-original_name) -Returns the full name (name-version) of this gemspec using the original -platform. For use with legacy gems. - -## platform() [](#method-i-platform) -The platform this gem runs on. See Gem::Platform for details. - -## platform=(platform) [](#method-i-platform=) -The platform this gem runs on. - -This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT. - -Most gems contain pure Ruby code; they should simply leave the default value -in place. Some gems contain C (or other) code to be compiled into a Ruby -"extension". The gem should leave the default value in place unless the code -will only compile on a certain type of system. Some gems consist of -pre-compiled code ("binary gems"). It's especially important that they set -the platform attribute appropriately. A shortcut is to set the platform to -Gem::Platform::CURRENT, which will cause the gem builder to set the platform -to the appropriate value for the system on which the build is being performed. - -If this attribute is set to a non-default value, it will be included in the -filename of the gem when it is built such as: nokogiri-1.6.0-x86-mingw32.gem - -Usage: - - spec.platform = Gem::Platform.local - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## raise_if_conflicts() [](#method-i-raise_if_conflicts) -Check the spec for possible conflicts and freak out if there are any. - -## raw_require_paths() [](#method-i-raw_require_paths) -:nodoc: - -## rdoc_options() [](#method-i-rdoc_options) -Specifies the rdoc options to be used when generating API documentation. - -Usage: - - spec.rdoc_options << '--title' << 'Rake -- Ruby Make' << - '--main' << 'README' << - '--line-numbers' - -## rdoc_options=(options) [](#method-i-rdoc_options=) -Sets rdoc_options to `value`, ensuring it is an array. - -## removed_method_calls() [](#method-i-removed_method_calls) - -## require_path() [](#method-i-require_path) -Singular accessor for #require_paths - -## require_path=(path) [](#method-i-require_path=) -Singular accessor for #require_paths - -## require_paths=(val) [](#method-i-require_paths=) -Paths in the gem to add to `$LOAD_PATH` when this gem is activated. -- See -also #require_paths ++ If you have an extension you do not need to add `"ext"` -to the require path, the extension build process will copy the extension files -into "lib" for you. - -The default value is `"lib"` - -Usage: - - # If all library files are in the root directory... - spec.require_paths = ['.'] - -## requirements() [](#method-i-requirements) -Lists the external (to RubyGems) requirements that must be met for this gem to -work. It's simply information for the user. - -Usage: - - spec.requirements << 'libmagick, v6.0' - spec.requirements << 'A good graphics card' - -## requirements=(req) [](#method-i-requirements=) -Set requirements to `req`, ensuring it is an array. - -## reset_nil_attributes_to_default() [](#method-i-reset_nil_attributes_to_default) -Reset nil attributes to their default values to make the spec valid - -## respond_to_missing?(m, include_privatefalse) [](#method-i-respond_to_missing?) -:nodoc: - -**@return** [Boolean] - -## rg_extension_dir() [](#method-i-rg_extension_dir) - -## rg_full_gem_path() [](#method-i-rg_full_gem_path) - -## rg_loaded_from() [](#method-i-rg_loaded_from) - -## rg_required_ruby_version=() [](#method-i-rg_required_ruby_version=) - -## ri_dir() [](#method-i-ri_dir) -Returns the full path to this spec's ri directory. - -## runtime_dependencies() [](#method-i-runtime_dependencies) -List of dependencies that will automatically be activated at runtime. - -## sanitize() [](#method-i-sanitize) -Sanitize the descriptive fields in the spec. Sometimes non-ASCII characters -will garble the site index. Non-ASCII characters will be replaced by their -XML entity equivalent. - -## sanitize_string(string) [](#method-i-sanitize_string) -Sanitize a single string. - -## satisfies_requirement?(dependency) [](#method-i-satisfies_requirement?) -Checks if this specification meets the requirement of `dependency`. - -**@return** [Boolean] - -## sort_obj() [](#method-i-sort_obj) -Returns an object you can use to sort specifications in #sort_by. - -## source() [](#method-i-source) -Used by Gem::Resolver to order Gem::Specification objects - -## spec_dir() [](#method-i-spec_dir) -Returns the full path to the directory containing this spec's gemspec file. -eg: /usr/local/lib/ruby/gems/1.8/specifications - -## spec_file() [](#method-i-spec_file) -Returns the full path to this spec's gemspec file. eg: -/usr/local/lib/ruby/gems/1.8/specifications/mygem-1.0.gemspec - -## spec_name() [](#method-i-spec_name) -The default name of the gemspec. See also #file_name - - spec.spec_name # => "example-1.0.gemspec" - -## stubbed?() [](#method-i-stubbed?) - -**@return** [Boolean] - -## test_file() [](#method-i-test_file) -Singular accessor for #test_files - -## test_file=(file) [](#method-i-test_file=) -Singular mutator for #test_files - -## test_files() [](#method-i-test_files) -Test files included in this gem. You cannot append to this accessor, you must -assign to it. - -## test_files=(files) [](#method-i-test_files=) -A collection of unit test files. They will be loaded as unit tests when the -user requests a gem to be unit tested. - -Usage: - spec.test_files = Dir.glob('test/tc_*.rb') - spec.test_files = ['tests/test-suite.rb'] - -## to_gemfile(pathnil) [](#method-i-to_gemfile) - -## to_ruby() [](#method-i-to_ruby) -Returns a Ruby code representation of this specification, such that it can be -eval'ed and reconstruct the same specification later. Attributes that still -have their default values are omitted. - -## to_ruby_for_cache() [](#method-i-to_ruby_for_cache) -Returns a Ruby lighter-weight code representation of this specification, used -for indexing only. - -See #to_ruby. - -## to_s() [](#method-i-to_s) -:nodoc: - -## to_spec() [](#method-i-to_spec) -Returns self - -## to_yaml(opts{}) [](#method-i-to_yaml) -:nodoc: - -## traverse(trail[], visited{}, &block) [](#method-i-traverse) -Recursively walk dependencies of this spec, executing the `block` for each -hop. - -## validate(packagingtrue, strictfalse) [](#method-i-validate) -Checks that the specification contains all required fields, and does a very -basic sanity check. - -Raises InvalidSpecificationException if the spec does not pass the checks.. - -## validate_dependencies() [](#method-i-validate_dependencies) - -## validate_for_resolution() [](#method-i-validate_for_resolution) - -## validate_metadata() [](#method-i-validate_metadata) - -## validate_permissions() [](#method-i-validate_permissions) - -## yaml_initialize(tag, vals) [](#method-i-yaml_initialize) -:nodoc: - diff --git a/example/ruby/Gem/Specification/AllowSettingSource.md b/example/ruby/Gem/Specification/AllowSettingSource.md deleted file mode 100644 index 3df4de3..0000000 --- a/example/ruby/Gem/Specification/AllowSettingSource.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::Specification::AllowSettingSource - - - - -# Attributes -## source[RW] [](#attribute-i-source) - - diff --git a/example/ruby/Gem/Specification/RequirePathFlattener.md b/example/ruby/Gem/Specification/RequirePathFlattener.md deleted file mode 100644 index 0b39fe3..0000000 --- a/example/ruby/Gem/Specification/RequirePathFlattener.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::Specification::RequirePathFlattener - - - - - -#Instance Methods -## from_yaml(input) [](#method-i-from_yaml) - diff --git a/example/ruby/Gem/SpecificationPolicy.md b/example/ruby/Gem/SpecificationPolicy.md deleted file mode 100644 index 61179c7..0000000 --- a/example/ruby/Gem/SpecificationPolicy.md +++ /dev/null @@ -1,122 +0,0 @@ -# Class: Gem::SpecificationPolicy -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - - - -# Attributes -## packaging[RW] [](#attribute-i-packaging) -If set to true, run packaging-specific checks, as well. - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(specification) [](#method-i-initialize) -:nodoc: - -**@return** [SpecificationPolicy] a new instance of SpecificationPolicy - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## validate(strictfalse) [](#method-i-validate) -Does a sanity check on the specification. - -Raises InvalidSpecificationException if the spec does not pass the checks. - -It also performs some validations that do not raise but print warning messages -instead. - -## validate_dependencies() [](#method-i-validate_dependencies) -Checks that the gem does not depend on itself. Checks that dependencies use -requirements as we recommend. Warnings are issued when dependencies are -open-ended or overly strict for semantic versioning. - -## validate_duplicate_dependencies() [](#method-i-validate_duplicate_dependencies) -Checks that no duplicate dependencies are specified. - -## validate_for_resolution() [](#method-i-validate_for_resolution) -Implementation for Specification#validate_for_resolution - -## validate_metadata() [](#method-i-validate_metadata) -Implementation for Specification#validate_metadata - -## validate_optional(strict) [](#method-i-validate_optional) - -## validate_permissions() [](#method-i-validate_permissions) -Issues a warning for each file to be packaged which is world-readable. - -Implementation for Specification#validate_permissions - -## validate_required!() [](#method-i-validate_required!) -Does a sanity check on the specification. - -Raises InvalidSpecificationException if the spec does not pass the checks. - -Only runs checks that are considered necessary for the specification to be -functional. - -## validate_required_metadata!() [](#method-i-validate_required_metadata!) - -## validate_required_ruby_version() [](#method-i-validate_required_ruby_version) - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/SpecificationRecord.md b/example/ruby/Gem/SpecificationRecord.md deleted file mode 100644 index 8e95c80..0000000 --- a/example/ruby/Gem/SpecificationRecord.md +++ /dev/null @@ -1,2127 +0,0 @@ -# Class: Gem::SpecificationRecord -**Inherits:** Object - -**Includes:** Enumerable - - - - -# Class Methods -## dirs_from(paths ) [](#method-c-dirs_from) -## from_path(path ) [](#method-c-from_path) - -#Instance Methods -## add_spec(spec) [](#method-i-add_spec) -Adds `spec` to the the record, keeping the collection properly sorted. - -## all() [](#method-i-all) -Returns the list of all specifications in the record - -## all=(specs) [](#method-i-all=) -Sets the specs known by the record to `specs`. - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## all_names() [](#method-i-all_names) -Return full names of all specs in the record in sorted order. - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Enumerate every known spec. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_active_stub_by_path(path) [](#method-i-find_active_stub_by_path) -Return the best specification in the record that contains the file matching -`path`, among those already activated. - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_all_by_name(name, *requirements) [](#method-i-find_all_by_name) -Returns every spec in the record that matches `name` and optional -`requirements`. - -## find_by_path(path) [](#method-i-find_by_path) -Return the best specification in the record that contains the file matching -`path`. - -## find_inactive_by_path(path) [](#method-i-find_inactive_by_path) -Return the best specification in the record that contains the file matching -`path` amongst the specs that are not activated. - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(dirs) [](#method-i-initialize) - -**@return** [SpecificationRecord] a new instance of SpecificationRecord - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## latest_spec_for(name) [](#method-i-latest_spec_for) -Return the latest installed spec in the record for gem `name`. - -## latest_specs(prerelease) [](#method-i-latest_specs) -Return the latest specs in the record, optionally including prerelease specs -if `prerelease` is true. - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## remove_spec(spec) [](#method-i-remove_spec) -Removes `spec` from the record. - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## stubs() [](#method-i-stubs) -Returns a Gem::StubSpecification for every specification in the record - -## stubs_for(name) [](#method-i-stubs_for) -Returns a Gem::StubSpecification for every specification in the record named -`name` only returns stubs that match Gem.platforms - -## stubs_for_pattern(pattern, match_platformtrue) [](#method-i-stubs_for_pattern) -Finds stub specifications matching a pattern in the record, optionally -filtering out specs not matching the current platform - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Gem/StreamUI.md b/example/ruby/Gem/StreamUI.md deleted file mode 100644 index 4e6a495..0000000 --- a/example/ruby/Gem/StreamUI.md +++ /dev/null @@ -1,88 +0,0 @@ -# Class: Gem::StreamUI -**Inherits:** Object - -**Extended by:** Gem::Deprecate - - -Gem::StreamUI implements a simple stream based user interface. - - -# Class Methods -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -# Attributes -## errs[RW] [](#attribute-i-errs) -The error stream - -## ins[RW] [](#attribute-i-ins) -The input stream - -## outs[RW] [](#attribute-i-outs) -The output stream - - -#Instance Methods -## _gets_noecho() [](#method-i-_gets_noecho) - -## alert(statement, questionnil) [](#method-i-alert) -Display an informational alert. Will ask `question` if it is not nil. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Display an error message in a location expected to get error messages. Will -ask `question` if it is not nil. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Display a warning on stderr. Will ask `question` if it is not nil. - -## ask(question) [](#method-i-ask) -Ask a question. Returns an answer if connected to a tty, nil otherwise. - -## ask_for_password(question) [](#method-i-ask_for_password) -Ask for a password. Does not echo response to terminal. - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Ask a question. Returns a true for yes, false for no. If not connected to a -tty, raises an exception if default is nil, otherwise returns default. - -## backtrace(exception) [](#method-i-backtrace) -Prints a formatted backtrace to the errors stream if backtraces are enabled. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Choose from a list of options. `question` is a prompt displayed above the -list. `list` is a list of option strings. Returns the pair [option_name, -option_index]. - -## close() [](#method-i-close) - -## download_reporter(*args) [](#method-i-download_reporter) -Return a download reporter object chosen from the current verbosity - -## initialize(in_stream, out_stream, err_stream$stderr, usettytrue) [](#method-i-initialize) -Creates a new StreamUI wrapping `in_stream` for user input, `out_stream` for -standard output, `err_stream` for error output. If `usetty` is true then -special operations (like asking for passwords) will use the TTY commands to -disable character echo. - -**@return** [StreamUI] a new instance of StreamUI - -## progress_reporter(*args) [](#method-i-progress_reporter) -Return a progress reporter object chosen from the current verbosity. - -## require_io_console() [](#method-i-require_io_console) - -## say(statement"") [](#method-i-say) -Display a statement. - -## terminate_interaction(status0) [](#method-i-terminate_interaction) -Terminate the application with exit code `status`, running any exit handlers -that might have been defined. - -**@raise** [Gem::SystemExitException] - -## tty?() [](#method-i-tty?) -Returns true if TTY methods should be used on this StreamUI. - -**@return** [Boolean] - diff --git a/example/ruby/Gem/StreamUI/SilentDownloadReporter.md b/example/ruby/Gem/StreamUI/SilentDownloadReporter.md deleted file mode 100644 index 2237c18..0000000 --- a/example/ruby/Gem/StreamUI/SilentDownloadReporter.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Gem::StreamUI::SilentDownloadReporter -**Inherits:** Object - - -An absolutely silent download reporter. - - - -#Instance Methods -## done() [](#method-i-done) -The silent download reporter won't tell you when the download is done. Because -it is silent. - -## fetch(filename, filesize) [](#method-i-fetch) -The silent download reporter does not display `filename` or care about -`filesize` because it is silent. - -## initialize(out_stream, *args) [](#method-i-initialize) -The silent download reporter ignores all arguments - -**@return** [SilentDownloadReporter] a new instance of SilentDownloadReporter - -## update(current) [](#method-i-update) -Nothing can update the silent download reporter. - diff --git a/example/ruby/Gem/StreamUI/SilentProgressReporter.md b/example/ruby/Gem/StreamUI/SilentProgressReporter.md deleted file mode 100644 index 5517207..0000000 --- a/example/ruby/Gem/StreamUI/SilentProgressReporter.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Gem::StreamUI::SilentProgressReporter -**Inherits:** Object - - -An absolutely silent progress reporter. - - -# Attributes -## count[RW] [](#attribute-i-count) -The count of items is never updated for the silent progress reporter. - - -#Instance Methods -## done() [](#method-i-done) -Does not print anything when complete as this object has taken a vow of -silence. - -## initialize(out_stream, size, initial_message, terminal_messagenil) [](#method-i-initialize) -Creates a silent progress reporter that ignores all input arguments. - -**@return** [SilentProgressReporter] a new instance of SilentProgressReporter - -## updated(message) [](#method-i-updated) -Does not print `message` when updated as this object has taken a vow of -silence. - diff --git a/example/ruby/Gem/StreamUI/SimpleProgressReporter.md b/example/ruby/Gem/StreamUI/SimpleProgressReporter.md deleted file mode 100644 index 11573b7..0000000 --- a/example/ruby/Gem/StreamUI/SimpleProgressReporter.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: Gem::StreamUI::SimpleProgressReporter -**Inherits:** Object - -**Includes:** Gem::DefaultUserInteraction - - -A basic dotted progress reporter. - - -# Attributes -## count[RW] [](#attribute-i-count) -The number of progress items counted so far. - - -#Instance Methods -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## done() [](#method-i-done) -Prints out the terminal message. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(out_stream, size, initial_message, terminal_message"complete") [](#method-i-initialize) -Creates a new progress reporter that will write to `out_stream` for `size` -items. Shows the given `initial_message` when progress starts and the -`terminal_message` when it is complete. - -**@return** [SimpleProgressReporter] a new instance of SimpleProgressReporter - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## updated(message) [](#method-i-updated) -Prints out a dot and ignores `message`. - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - diff --git a/example/ruby/Gem/StreamUI/ThreadedDownloadReporter.md b/example/ruby/Gem/StreamUI/ThreadedDownloadReporter.md deleted file mode 100644 index 4ef0571..0000000 --- a/example/ruby/Gem/StreamUI/ThreadedDownloadReporter.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Gem::StreamUI::ThreadedDownloadReporter -**Inherits:** Object - - -A progress reporter that behaves nicely with threaded downloading. - - -# Attributes -## file_name[RW] [](#attribute-i-file_name) -The current file name being displayed - - -#Instance Methods -## done() [](#method-i-done) -Indicates the download is complete. - -## fetch(file_name, *args) [](#method-i-fetch) -Tells the download reporter that the `file_name` is being fetched. The other -arguments are ignored. - -## initialize(out_stream, *args) [](#method-i-initialize) -Creates a new threaded download reporter that will display on `out_stream`. -The other arguments are ignored. - -**@return** [ThreadedDownloadReporter] a new instance of ThreadedDownloadReporter - -## update(bytes) [](#method-i-update) -Updates the threaded download reporter for the given number of `bytes`. - diff --git a/example/ruby/Gem/StreamUI/VerboseProgressReporter.md b/example/ruby/Gem/StreamUI/VerboseProgressReporter.md deleted file mode 100644 index 257f002..0000000 --- a/example/ruby/Gem/StreamUI/VerboseProgressReporter.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: Gem::StreamUI::VerboseProgressReporter -**Inherits:** Object - -**Includes:** Gem::DefaultUserInteraction - - -A progress reporter that prints out messages about the current progress. - - -# Attributes -## count[RW] [](#attribute-i-count) -The number of progress items counted so far. - - -#Instance Methods -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## done() [](#method-i-done) -Prints out the terminal message. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize(out_stream, size, initial_message, terminal_message"complete") [](#method-i-initialize) -Creates a new progress reporter that will write to `out_stream` for `size` -items. Shows the given `initial_message` when progress starts and the -`terminal_message` when it is complete. - -**@return** [VerboseProgressReporter] a new instance of VerboseProgressReporter - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## updated(message) [](#method-i-updated) -Prints out the position relative to the total and the `message`. - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - diff --git a/example/ruby/Gem/StubSpecification.md b/example/ruby/Gem/StubSpecification.md deleted file mode 100644 index 79083f7..0000000 --- a/example/ruby/Gem/StubSpecification.md +++ /dev/null @@ -1,85 +0,0 @@ -# Class: Gem::StubSpecification -**Inherits:** Gem::BasicSpecification - -**Includes:** Gem::BetterPermissionError - - -Gem::StubSpecification reads the stub: line from the gemspec. This prevents -us having to eval the entire gemspec in order to find out certain information. - - -# Class Methods -## default_gemspec_stub(filename , base_dir , gems_dir ) [](#method-c-default_gemspec_stub) -## gemspec_stub(filename , base_dir , gems_dir ) [](#method-c-gemspec_stub) -# Attributes -## base_dir[RW] [](#attribute-i-base_dir) -Returns the value of attribute base_dir. - -## gems_dir[RW] [](#attribute-i-gems_dir) -Returns the value of attribute gems_dir. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -:nodoc: - -## ==(other) [](#method-i-==) -:nodoc: - -## activated?() [](#method-i-activated?) -True when this gem has been activated - -**@return** [Boolean] - -## build_extensions() [](#method-i-build_extensions) -:nodoc: - -## default_gem?() [](#method-i-default_gem?) - -**@return** [Boolean] - -## extensions() [](#method-i-extensions) -Extensions for this gem - -## full_name() [](#method-i-full_name) - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(filename, base_dir, gems_dir, default_gem) [](#method-i-initialize) - -**@return** [StubSpecification] a new instance of StubSpecification - -## missing_extensions?() [](#method-i-missing_extensions?) - -**@return** [Boolean] - -## name() [](#method-i-name) -Name of the gem - -## platform() [](#method-i-platform) -Platform of the gem - -## raw_require_paths() [](#method-i-raw_require_paths) -:nodoc: - -## sort_obj() [](#method-i-sort_obj) -:nodoc: - -## spec() [](#method-i-spec) -The full Gem::Specification for this gem, loaded from evalling its gemspec - -## stubbed?() [](#method-i-stubbed?) -Is there a stub line present for this StubSpecification? - -**@return** [Boolean] - -## valid?() [](#method-i-valid?) -Is this StubSpecification valid? i.e. have we found a stub line, OR does the -filename contain a valid gemspec? - -**@return** [Boolean] - -## version() [](#method-i-version) -Version of the gem - diff --git a/example/ruby/Gem/StubSpecification/StubLine.md b/example/ruby/Gem/StubSpecification/StubLine.md deleted file mode 100644 index 5a7a3f0..0000000 --- a/example/ruby/Gem/StubSpecification/StubLine.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Gem::StubSpecification::StubLine -**Inherits:** Object - - -:nodoc: all - - -# Attributes -## extensions[RW] [](#attribute-i-extensions) -Returns the value of attribute extensions. - -## full_name[RW] [](#attribute-i-full_name) -Returns the value of attribute full_name. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## platform[RW] [](#attribute-i-platform) -Returns the value of attribute platform. - -## require_paths[RW] [](#attribute-i-require_paths) -Returns the value of attribute require_paths. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## initialize(data, extensions) [](#method-i-initialize) - -**@return** [StubLine] a new instance of StubLine - diff --git a/example/ruby/Gem/SystemExitException.md b/example/ruby/Gem/SystemExitException.md deleted file mode 100644 index 8b35511..0000000 --- a/example/ruby/Gem/SystemExitException.md +++ /dev/null @@ -1,15 +0,0 @@ -# Exception: Gem::SystemExitException -**Inherits:** SystemExit - - -Raised to indicate that a system exit should occur with the specified -exit_code - - - -#Instance Methods -## initialize(exit_code) [](#method-i-initialize) -Creates a new SystemExitException with the given `exit_code` - -**@return** [SystemExitException] a new instance of SystemExitException - diff --git a/example/ruby/Gem/TSort.md b/example/ruby/Gem/TSort.md deleted file mode 100644 index cb25b94..0000000 --- a/example/ruby/Gem/TSort.md +++ /dev/null @@ -1,359 +0,0 @@ -# Module: Gem::TSort - - -Gem::TSort implements topological sorting using Tarjan's algorithm for -strongly connected components. - -Gem::TSort is designed to be able to be used with any object which can be -interpreted as a directed graph. - -Gem::TSort requires two methods to interpret an object as a graph, -tsort_each_node and tsort_each_child. - -* tsort_each_node is used to iterate for all nodes over a graph. -* tsort_each_child is used to iterate for child nodes of a given node. - -The equality of nodes are defined by eql? and hash since Gem::TSort uses Hash -internally. - -## A Simple Example - -The following example demonstrates how to mix the Gem::TSort module into an -existing class (in this case, Hash). Here, we're treating each key in the hash -as a node in the graph, and so we simply alias the required #tsort_each_node -method to Hash's #each_key method. For each key in the hash, the associated -value is an array of the node's child nodes. This choice in turn leads to our -implementation of the required #tsort_each_child method, which fetches the -array of child nodes and then iterates over that array using the user-supplied -block. - - require 'rubygems/vendor/tsort/lib/tsort' - - class Hash - include Gem::TSort - alias tsort_each_node each_key - def tsort_each_child(node, &block) - fetch(node).each(&block) - end - end - - {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort - #=> [3, 2, 1, 4] - - {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components - #=> [[4], [2, 3], [1]] - -## A More Realistic Example - -A very simple `make' like tool can be implemented as follows: - - require 'rubygems/vendor/tsort/lib/tsort' - - class Make - def initialize - @dep = {} - @dep.default = [] - end - - def rule(outputs, inputs=[], &block) - triple = [outputs, inputs, block] - outputs.each {|f| @dep[f] = [triple]} - @dep[triple] = inputs - end - - def build(target) - each_strongly_connected_component_from(target) {|ns| - if ns.length != 1 - fs = ns.delete_if {|n| Array === n} - raise Gem::TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}") - end - n = ns.first - if Array === n - outputs, inputs, block = n - inputs_time = inputs.map {|f| File.mtime f}.max - begin - outputs_time = outputs.map {|f| File.mtime f}.min - rescue Errno::ENOENT - outputs_time = nil - end - if outputs_time == nil || - inputs_time != nil && outputs_time <= inputs_time - sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i - block.call - end - end - } - end - - def tsort_each_child(node, &block) - @dep[node].each(&block) - end - include Gem::TSort - end - - def command(arg) - print arg, "\n" - system arg - end - - m = Make.new - m.rule(%w[t1]) { command 'date > t1' } - m.rule(%w[t2]) { command 'date > t2' } - m.rule(%w[t3]) { command 'date > t3' } - m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' } - m.rule(%w[t5], %w[t4 t2]) { command 'cat t4 t2 > t5' } - m.build('t5') - -## Bugs - -* 'tsort.rb' is wrong name because this library uses Tarjan's algorithm for - strongly connected components. Although 'strongly_connected_components.rb' - is correct but too long. - -## References - - 1. Tarjan, "Depth First Search and Linear Graph Algorithms", -*SIAM Journal on Computing*, Vol. 1, No. 2, pp. 146-160, June 1972. - - -# Class Methods -## each_strongly_connected_component(each_node , each_child ) [](#method-c-each_strongly_connected_component) -The iterator version of the Gem::TSort.strongly_connected_components method. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - Gem::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - Gem::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc } - #=> [4] - # [2, 3] - # [1] -## each_strongly_connected_component_from(node , each_child , id_map {}, stack []) [](#method-c-each_strongly_connected_component_from) -Iterates over strongly connected components in a graph. The graph is -represented by *node* and *each_child*. - -*node* is the first node. *each_child* should have `call` method which takes a -node argument and yields for each child node. - -Return value is unspecified. - -#Gem::TSort.each_strongly_connected_component_from is a class method and it -doesn't need a class to represent a graph which includes Gem::TSort. - - graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_child = lambda {|n, &b| graph[n].each(&b) } - Gem::TSort.each_strongly_connected_component_from(1, each_child) {|scc| - p scc - } - #=> [4] - # [2, 3] - # [1] -## strongly_connected_components(each_node , each_child ) [](#method-c-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p Gem::TSort.strongly_connected_components(each_node, each_child) - #=> [[4], [2], [3], [1]] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p Gem::TSort.strongly_connected_components(each_node, each_child) - #=> [[4], [2, 3], [1]] -## tsort(each_node , each_child ) [](#method-c-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - -If there is a cycle, Gem::TSort::Cyclic is raised. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p Gem::TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p Gem::TSort.tsort(each_node, each_child) # raises Gem::TSort::Cyclic -## tsort_each(each_node , each_child ) [](#method-c-tsort_each) -The iterator version of the Gem::TSort.tsort method. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - Gem::TSort.tsort_each(each_node, each_child) {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -#Instance Methods -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, Gem::TSort::Cyclic is raised. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises Gem::TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, Gem::TSort::Cyclic is raised. - - class G - include Gem::TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## tsort_each_child(node) [](#method-i-tsort_each_child) -Should be implemented by a extended class. - -#tsort_each_child is used to iterate for child nodes of *node*. - -**@raise** [NotImplementedError] - -## tsort_each_node() [](#method-i-tsort_each_node) -Should be implemented by a extended class. - -#tsort_each_node is used to iterate for all nodes over a graph. - -**@raise** [NotImplementedError] - diff --git a/example/ruby/Gem/TSort/Cyclic.md b/example/ruby/Gem/TSort/Cyclic.md deleted file mode 100644 index 5cf52d7..0000000 --- a/example/ruby/Gem/TSort/Cyclic.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Gem::TSort::Cyclic -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Gem/TargetRbConfig.md b/example/ruby/Gem/TargetRbConfig.md deleted file mode 100644 index 4c464b0..0000000 --- a/example/ruby/Gem/TargetRbConfig.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Gem::TargetRbConfig -**Inherits:** Object - - -A TargetConfig is a wrapper around an RbConfig object that provides a -consistent interface for querying configuration for *deployment target -platform*, where the gem being installed is intended to run on. - -The TargetConfig is typically created from the RbConfig of the running Ruby -process, but can also be created from an RbConfig file on disk for cross- -compiling gems. - - -# Class Methods -## for_running_ruby() [](#method-c-for_running_ruby) -Creates a TargetRbConfig for the platform that RubyGems is running on. -## from_path(rbconfig_path ) [](#method-c-from_path) -Creates a TargetRbConfig from the RbConfig file at the given path. Typically -used for cross-compiling gems. -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - -#Instance Methods -## [](key) [](#method-i-[]) -Queries the configuration for the given key. - -## initialize(rbconfig, path) [](#method-i-initialize) - -**@return** [TargetRbConfig] a new instance of TargetRbConfig - diff --git a/example/ruby/Gem/TempIO.md b/example/ruby/Gem/TempIO.md deleted file mode 100644 index 431367b..0000000 --- a/example/ruby/Gem/TempIO.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Gem::TempIO -**Inherits:** Tempfile - - -A StringIO duck-typed class that uses Tempfile instead of String as the -backing store. - -This class was added to flush out problems in Rubinius' IO implementation. - - - -#Instance Methods -## initialize(string"") [](#method-i-initialize) -Creates a new TempIO that will be initialized to contain `string`. - -**@return** [TempIO] a new instance of TempIO - -## string() [](#method-i-string) -The content of the TempIO as a String. - diff --git a/example/ruby/Gem/TestCase.md b/example/ruby/Gem/TestCase.md deleted file mode 100644 index bcc370a..0000000 --- a/example/ruby/Gem/TestCase.md +++ /dev/null @@ -1,370 +0,0 @@ -# Class: Gem::TestCase -**Inherits:** Test::Unit::TestCase - -**Includes:** Gem::DefaultUserInteraction - - -RubyGemTestCase provides a variety of methods for testing rubygems and -gem-related behavior in a sandbox. Through RubyGemTestCase you can install -and uninstall gems, fetch remote gems through a stub fetcher and be assured -your normal set of gems is not affected. - - -# Class Methods -## cert_path(cert_name ) [](#method-c-cert_path) -Returns the path to the certificate named `cert_name` from `test/rubygems/`. -## escape_path(*path ) [](#method-c-escape_path) -:nodoc: - -Return the join path, with escaping backticks, dollars, and double-quotes. -Unlike `shellescape`, equal-sign is not escaped. -## key_path(key_name ) [](#method-c-key_path) -Returns the path to the key named `key_name` from `test/rubygems` -## load_cert(cert_name ) [](#method-c-load_cert) -Loads certificate named `cert_name` from `test/rubygems/`. -## load_key(key_name , passphrase nil) [](#method-c-load_key) -Loads a private key named `key_name` with `passphrase` in `test/rubygems/` -## rubybin() [](#method-c-rubybin) -Finds the path to the Ruby executable -## vc_windows?() [](#method-c-vc_windows?) -Returns whether or not we're on a version of Ruby built with VC++ (or Borland) -versus Cygwin, Mingw, etc. -**@return** [Boolean] - -# Attributes -## fetcher[RW] [](#attribute-i-fetcher) -:nodoc: - -## gem_repo[RW] [](#attribute-i-gem_repo) -:nodoc: - -## uri[RW] [](#attribute-i-uri) -:nodoc: - - -#Instance Methods -## add_to_fetcher(spec, pathnil, repo@gem_repo) [](#method-i-add_to_fetcher) -Add `spec` to +@fetcher+ serving the data in the file `path`. `repo` indicates -which repo to make `spec` appear to be in. - -## all_spec_names() [](#method-i-all_spec_names) - -## assert_activate(expected, *specs) [](#method-i-assert_activate) - -## assert_contains_make_command(target, output, msgnil) [](#method-i-assert_contains_make_command) - -## assert_directory_exists(path, msgnil) [](#method-i-assert_directory_exists) - -## bindir(value) [](#method-i-bindir) -Sets the bindir entry in RbConfig::CONFIG to `value` and restores the original -value when the block ends - -## build_rake_in(goodtrue) [](#method-i-build_rake_in) -Allows the proper version of `rake` to be used for the test. - -## bundler_path() [](#method-i-bundler_path) - -## capture_subprocess_io() [](#method-i-capture_subprocess_io) -Originally copied from minitest/assertions.rb - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## common_installer_setup() [](#method-i-common_installer_setup) - -## common_installer_teardown() [](#method-i-common_installer_teardown) - -## credential_setup() [](#method-i-credential_setup) - -## credential_teardown() [](#method-i-credential_teardown) - -## dep(name, *requirements) [](#method-i-dep) -Construct a new Gem::Dependency. - -## dependency_request(dep, from_name, from_version, parentnil) [](#method-i-dependency_request) -Constructs a Gem::Resolver::DependencyRequest from a Gem::Dependency `dep`, a -`from_name` and `from_version` requesting the dependency and a `parent` -DependencyRequest - -## enable_shared(value) [](#method-i-enable_shared) -Sets the ENABLE_SHARED entry in RbConfig::CONFIG to `value` and restores the -original value when the block ends - -## exeext(value) [](#method-i-exeext) -Sets the EXEEXT entry in RbConfig::CONFIG to `value` and restores the original -value when the block ends - -## extension_in_lib(valuetrue) [](#method-i-extension_in_lib) -Overrides the Gem.install_extension_in_lib function and restores the original -when the block ends - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## git_gem(name"a", version1) [](#method-i-git_gem) -A git_gem is used with a gem dependencies file. The gem created here has no -files, just a gem specification for the given `name` and `version`. - -Yields the `specification` to the block, if given - -## have_git?() [](#method-i-have_git?) -Skips this test unless you have a git executable - -**@return** [Boolean] - -## in_path?(executable) [](#method-i-in_path?) -:nodoc: - -**@return** [Boolean] - -## install_default_gems(*specs) [](#method-i-install_default_gems) -Installs the provided default specs including writing the spec file - -## install_gem(spec, options{}) [](#method-i-install_gem) -Builds and installs the Gem::Specification `spec` - -## install_gem_user(spec) [](#method-i-install_gem_user) -Builds and installs the Gem::Specification `spec` into the user dir - -## install_specs(*specs) [](#method-i-install_specs) -Install the provided specs - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## load_yaml(yaml) [](#method-i-load_yaml) -Load a YAML string, the psych 3 way - -## load_yaml_file(file) [](#method-i-load_yaml_file) -Load a YAML file, the psych 3 way - -## loaded_spec_names() [](#method-i-loaded_spec_names) - -## make_command() [](#method-i-make_command) -Returns the make command for the current platform. For versions of Ruby built -on MS Windows with VC++ or Borland it will return 'nmake'. On all other -platforms, including Cygwin, it will return 'make'. - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## mingw_windows?() [](#method-i-mingw_windows?) -Is this test being run on a version of Ruby built with mingw? - -**@return** [Boolean] - -## mu_pp(obj) [](#method-i-mu_pp) -Enables pretty-print for all tests - -## new_default_spec(name, version, depsnil, *files, executable:false) [](#method-i-new_default_spec) - -## nmake_found?() [](#method-i-nmake_found?) -Returns whether or not the nmake command could be found. - -**@return** [Boolean] - -## parse_make_command_line_targets(line) [](#method-i-parse_make_command_line_targets) - -## quick_gem(name, version"2") [](#method-i-quick_gem) -Creates a Gem::Specification with a minimum of extra work. `name` and -`version` are the gem's name and version, platform, author, email, homepage, -summary and description are defaulted. The specification is yielded for -customization. - -The gem is added to the installed gems in +@gemhome+ and the runtime. - -Use this with #write_file to build an installed gem. - -## read_binary(path) [](#method-i-read_binary) -Reads a binary file at `path` - -## read_cache(path) [](#method-i-read_cache) -Reads a Marshal file at `path` - -## refute_directory_exists(path, msgnil) [](#method-i-refute_directory_exists) - -## req(*requirements) [](#method-i-req) -Constructs a new Gem::Requirement. - -## ruby_repo?() [](#method-i-ruby_repo?) -Is this test being run on a ruby/ruby repository? - -**@return** [Boolean] - -## ruby_with_rubygems_in_load_path() [](#method-i-ruby_with_rubygems_in_load_path) - -## rubygems_path() [](#method-i-rubygems_path) - -## save_gemspec(name"a", version1, directory".") [](#method-i-save_gemspec) -create_gemspec creates gem specification in given `directory` or '.' for the -given `name` and `version`. - -Yields the `specification` to the block, if given - -## scan_make_command_lines(output) [](#method-i-scan_make_command_lines) - -## setup() [](#method-i-setup) -#setup prepares a sandboxed location to install gems. All installs are -directed to a temporary directory. All install plugins are removed. - -If the `RUBY` environment variable is set the given path is used for -Gem::ruby. The local platform is set to `i386-mswin32` for Windows or -`i686-darwin8.10.1` otherwise. - -## silence_warnings() [](#method-i-silence_warnings) - -## spec(name, version, &block) [](#method-i-spec) -Constructs a new Gem::Specification. - -## spec_fetcher(repository@gem_repo) [](#method-i-spec_fetcher) -Creates a SpecFetcher pre-filled with the gems or specs defined in the block. - -Yields a `fetcher` object that responds to `spec` and `gem`. `spec` adds a -specification to the SpecFetcher while `gem` adds both a specification and the -gem data to the RemoteFetcher so the built gem can be downloaded. - -If only the a-3 gem is supposed to be downloaded you can save setup time by -creating only specs for the other versions: - - spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2, 'b' => 3 # dependency on b = 3 - fetcher.gem 'a', 3 do |spec| - # spec is a Gem::Specification - # ... - end - end - -## teardown() [](#method-i-teardown) -#teardown restores the process to its original state and removes the tempdir - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## uninstall_gem(spec) [](#method-i-uninstall_gem) -Uninstalls the Gem::Specification `spec` - -## unresolved_names() [](#method-i-unresolved_names) - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## util_build_gem(spec) [](#method-i-util_build_gem) -Builds a gem from `spec` and places it in `File.join @gemhome, 'cache'`. -Automatically creates files based on `spec.files` - -## util_clear_RUBY_VERSION() [](#method-i-util_clear_RUBY_VERSION) - -## util_clear_gems() [](#method-i-util_clear_gems) -Removes all installed gems from +@gemhome+. - -## util_gem(name, version, depsnil, &block) [](#method-i-util_gem) -Creates a gem with `name`, `version` and `deps`. The specification will be -yielded before gem creation for customization. The gem will be placed in -`File.join @tempdir, 'gems'`. The specification and .gem file location are -returned. - -## util_gzip(data) [](#method-i-util_gzip) -Gzips `data`. - -## util_make_gems(prereleasefalse) [](#method-i-util_make_gems) -Creates several default gems which all have a lib/code.rb file. The gems are -not installed but are available in the cache dir. - -+@a1+ -: gem a version 1, this is the best-described gem. - -+@a2+ -: gem a version 2 - -+@a3a -: gem a version 3.a - -+@a_evil9+ -: gem a_evil version 9, use this to ensure similarly-named gems don't - collide with a. - -+@b2+ -: gem b version 2 - -+@c1_2+ -: gem c version 1.2 - -+@pl1+ -: gem pl version 1, this gem has a legacy platform of i386-linux. - - -Additional `prerelease` gems may also be created: - -+@a2_pre+ -: gem a version 2.a - -TODO: nuke this and fix tests. this should speed up a lot - -## util_remove_gem(spec) [](#method-i-util_remove_gem) - -## util_restore_RUBY_VERSION() [](#method-i-util_restore_RUBY_VERSION) - -## util_set_RUBY_VERSION(version, patchlevel, revision, description, engine"ruby", engine_versionnil) [](#method-i-util_set_RUBY_VERSION) - -## util_set_arch(arch) [](#method-i-util_set_arch) -Set the platform to `arch` - -## util_setup_spec_fetcher(*specs) [](#method-i-util_setup_spec_fetcher) -Sets up Gem::SpecFetcher to return information from the gems in `specs`. - -## util_spec(name, version2, depsnil, *files) [](#method-i-util_spec) -Creates a spec with `name`, `version`. `deps` can specify the dependency or a -`block` can be given for full customization of the specification. - -## util_zip(data) [](#method-i-util_zip) -Deflates `data` - -## v(string) [](#method-i-v) -Construct a new Gem::Version. - -## vc_windows?() [](#method-i-vc_windows?) -see ::vc_windows? - -**@return** [Boolean] - -## vendor_gem(name"a", version1, &block) [](#method-i-vendor_gem) -A vendor_gem is used with a gem dependencies file. The gem created here has -no files, just a gem specification for the given `name` and `version`. - -Yields the `specification` to the block, if given - -## vendordir(value) [](#method-i-vendordir) -Sets the vendordir entry in RbConfig::CONFIG to `value` and restores the -original value when the block ends - -## wait_for_child_process_to_exit() [](#method-i-wait_for_child_process_to_exit) -In case we're building docs in a background process, this method waits for -that process to exit (or if it's already been reaped, or never happened, -swallows the Errno::ECHILD error). - -## with_clean_path_to_ruby() [](#method-i-with_clean_path_to_ruby) - -## with_env(overrides, &block) [](#method-i-with_env) - -## with_internal_encoding(encoding) [](#method-i-with_internal_encoding) - -## without_any_upwards_gemfiles() [](#method-i-without_any_upwards_gemfiles) - -## write_file(path) [](#method-i-write_file) -Writes a binary file to `path` which is relative to +@gemhome+ - -## write_marshalled_gemspecs(*all_specs) [](#method-i-write_marshalled_gemspecs) - diff --git a/example/ruby/Gem/TestCase/SpecFetcherSetup.md b/example/ruby/Gem/TestCase/SpecFetcherSetup.md deleted file mode 100644 index 9c2b615..0000000 --- a/example/ruby/Gem/TestCase/SpecFetcherSetup.md +++ /dev/null @@ -1,72 +0,0 @@ -# Class: Gem::TestCase::SpecFetcherSetup -**Inherits:** Object - - -The SpecFetcherSetup allows easy setup of a remote source in RubyGems tests: - - spec_fetcher do |f| - f.gem 'a', 1 - f.spec 'a', 2 - f.gem 'b', 1' 'a' => '~> 1.0' - end - -The above declaration creates two gems, a-1 and b-1, with a dependency from b -to a. The declaration creates an additional spec a-2, but no gem for it (so -it cannot be installed). - -After the gems are created they are removed from Gem.dir. - - -# Class Methods -## declare(test , repository ) [](#method-c-declare) -Executes a SpecFetcher setup block. Yields an instance then creates the gems -and specifications defined in the instance. -**@yield** [setup] - - -#Instance Methods -## created_specs() [](#method-i-created_specs) -Returns a Hash of created Specification full names and the corresponding -Specification. - -## download(name, version, dependenciesnil, &block) [](#method-i-download) -Creates a gem with `name`, `version` and `deps`. The created gem is -downloaded in to the cache directory but is not installed - -The specification will be yielded before gem creation for customization, but -only the block or the dependencies may be set, not both. - -## execute() [](#method-i-execute) -Creates any defined gems or specifications - -## execute_operations() [](#method-i-execute_operations) -:nodoc: - -## gem(name, version, dependenciesnil, &block) [](#method-i-gem) -Creates a gem with `name`, `version` and `deps`. The created gem can be -downloaded and installed. - -The specification will be yielded before gem creation for customization, but -only the block or the dependencies may be set, not both. - -## initialize(test, repository) [](#method-i-initialize) -:nodoc: - -**@return** [SpecFetcherSetup] a new instance of SpecFetcherSetup - -## legacy_platform() [](#method-i-legacy_platform) -Creates a legacy platform spec with the name 'pl' and version 1 - -## setup_fetcher() [](#method-i-setup_fetcher) -:nodoc: - -## spec(name, version, dependenciesnil, &block) [](#method-i-spec) -Creates a spec with `name`, `version` and `deps`. The created gem can be -downloaded and installed. - -The specification will be yielded before creation for customization, but only -the block or the dependencies may be set, not both. - -## write_spec(spec) [](#method-i-write_spec) -:nodoc: - diff --git a/example/ruby/Gem/TestCase/StaticSet.md b/example/ruby/Gem/TestCase/StaticSet.md deleted file mode 100644 index 86a7391..0000000 --- a/example/ruby/Gem/TestCase/StaticSet.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Gem::TestCase::StaticSet -**Inherits:** Gem::Resolver::Set - - -The StaticSet is a static set of gem specifications used for testing only. It -is available by requiring Gem::TestCase. - - -# Attributes -## remote[RW] [](#attribute-i-remote) -A StaticSet ignores remote because it has a fixed set of gems. - - -#Instance Methods -## add(spec) [](#method-i-add) -Adds `spec` to this set. - -## find_all(dep) [](#method-i-find_all) -Finds all gems matching `dep` in this set. - -## find_spec(dep) [](#method-i-find_spec) -Finds `dep` in this set. - -## initialize(specs) [](#method-i-initialize) -Creates a new StaticSet for the given `specs` - -**@return** [StaticSet] a new instance of StaticSet - -## load_spec(name, ver, platform, source) [](#method-i-load_spec) -Loads a Gem::Specification from this set which has the given `name`, version -`ver`, `platform`. The `source` is ignored. - -## prefetch(reqs) [](#method-i-prefetch) -:nodoc: - diff --git a/example/ruby/Gem/Text.md b/example/ruby/Gem/Text.md deleted file mode 100644 index 84ce958..0000000 --- a/example/ruby/Gem/Text.md +++ /dev/null @@ -1,29 +0,0 @@ -# Module: Gem::Text - - -A collection of text-wrangling methods - - - -#Instance Methods -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - diff --git a/example/ruby/Gem/Timeout.md b/example/ruby/Gem/Timeout.md deleted file mode 100644 index 8689e3b..0000000 --- a/example/ruby/Gem/Timeout.md +++ /dev/null @@ -1,65 +0,0 @@ -# Module: Gem::Timeout - - -Timeout long-running blocks - -## Synopsis - - require 'rubygems/vendor/timeout/lib/timeout' - status = Gem::Timeout.timeout(5) { - # Something that should be interrupted if it takes more than 5 seconds... - } - -## Description - -Gem::Timeout provides a way to auto-terminate a potentially long-running -operation if it hasn't finished in a fixed amount of time. - -## Copyright - -Copyright -: (C) 2000 Network Applied Communication Laboratory, Inc. - -Copyright -: (C) 2000 Information-technology Promotion Agency, Japan - - - -# Class Methods -## ensure_timeout_thread_created() [](#method-c-ensure_timeout_thread_created) -## timeout(sec , klass nil, message nil, &block ) [](#method-c-timeout) -Perform an operation in a block, raising an error if it takes longer than -`sec` seconds to complete. - -`sec` -: Number of seconds to wait for the block to terminate. Any non-negative - number or nil may be used, including Floats to specify fractional seconds. - A value of 0 or `nil` will execute the block without any timeout. Any - negative number will raise an ArgumentError. - -`klass` -: Exception Class to raise if the block fails to terminate in `sec` seconds. - Omitting will use the default, Gem::Timeout::Error - -`message` -: Error message to raise with Exception Class. Omitting will use the - default, "execution expired" - - -Returns the result of the block **if** the block completed before `sec` -seconds, otherwise throws an exception, based on the value of `klass`. - -The exception thrown to terminate the given block cannot be rescued inside the -block unless `klass` is given explicitly. However, the block can use ensure to -prevent the handling of the exception. For that reason, this method cannot be -relied on to enforce timeouts for untrusted blocks. - -If a scheduler is defined, it will be used to handle the timeout by invoking -Scheduler#timeout_after. - -Note that this is both a method of module Gem::Timeout, so you can `include -Gem::Timeout` into your classes so they have a #timeout method, as well as a -module method, so you can call it directly as Gem::Timeout.timeout(). -**@raise** [ArgumentError] - - diff --git a/example/ruby/Gem/Timeout/Error.md b/example/ruby/Gem/Timeout/Error.md deleted file mode 100644 index b43e8bb..0000000 --- a/example/ruby/Gem/Timeout/Error.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: Gem::Timeout::Error -**Inherits:** RuntimeError - - -Raised by Gem::Timeout.timeout when the block times out. - - -# Class Methods -## handle_timeout(message ) [](#method-c-handle_timeout) -:nodoc: - diff --git a/example/ruby/Gem/Timeout/ExitException.md b/example/ruby/Gem/Timeout/ExitException.md deleted file mode 100644 index 14cf1ce..0000000 --- a/example/ruby/Gem/Timeout/ExitException.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::Timeout::ExitException -**Inherits:** Gem::Exception - - -Internal error raised to when a timeout is triggered. - - - -#Instance Methods -## exception() [](#method-i-exception) -:nodoc: - diff --git a/example/ruby/Gem/URI.md b/example/ruby/Gem/URI.md deleted file mode 100644 index cde5d3f..0000000 --- a/example/ruby/Gem/URI.md +++ /dev/null @@ -1,366 +0,0 @@ -# Module: Gem::URI - - --- -# uri/common.rb - -Author -: Akira Yamada - -License -: You can redistribute it and/or modify it under the same term as Ruby. - - -See Gem::URI for general documentation - - -# Class Methods -## const_missing(const ) [](#method-c-const_missing) -## decode_uri_component(str , enc Encoding::UTF_8) [](#method-c-decode_uri_component) -Like Gem::URI.decode_www_form_component, except that `'+'` is preserved. -## decode_www_form(str , enc Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false) [](#method-c-decode_www_form) -Returns name/value pairs derived from the given string `str`, which must be an -ASCII string. - -The method may be used to decode the body of Net::HTTPResponse object `res` -for which `res['Content-Type']` is `'application/x-www-form-urlencoded'`. - -The returned data is an array of 2-element subarrays; each subarray is a -name/value pair (both are strings). Each returned string has encoding `enc`, -and has had invalid characters removed via -[String#scrub](https://docs.ruby-lang.org/en/master/String.html#method-i-scrub -). - -A simple example: - - Gem::URI.decode_www_form('foo=0&bar=1&baz') - # => [["foo", "0"], ["bar", "1"], ["baz", ""]] - -The returned strings have certain conversions, similar to those performed in -Gem::URI.decode_www_form_component: - - Gem::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40') - # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]] - -The given string may contain consecutive separators: - - Gem::URI.decode_www_form('foo=0&&bar=1&&baz=2') - # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]] - -A different separator may be specified: - - Gem::URI.decode_www_form('foo=0--bar=1--baz', separator: '--') - # => [["foo", "0"], ["bar", "1"], ["baz", ""]] -**@raise** [ArgumentError] - -## decode_www_form_component(str , enc Encoding::UTF_8) [](#method-c-decode_www_form_component) -Returns a string decoded from the given URL-encoded string `str`. - -The given string is first encoded as Encoding::ASCII-8BIT (using String#b), -then decoded (as below), and finally force-encoded to the given encoding -`enc`. - -The returned string: - -* Preserves: - - * Characters `'*'`, `'.'`, `'-'`, and `'_'`. - * Character in ranges `'a'..'z'`, `'A'..'Z'`, and `'0'..'9'`. - - Example: - - Gem::URI.decode_www_form_component('*.-_azAZ09') - # => "*.-_azAZ09" - -* Converts: - - * Character `'+'` to character `' '`. - * Each "percent notation" to an ASCII character. - - Example: - - Gem::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A') - # => "Here are some punctuation characters: ,;?:" - -Related: Gem::URI.decode_uri_component (preserves `'+'`). -## encode_uri_component(str , enc nil) [](#method-c-encode_uri_component) -Like Gem::URI.encode_www_form_component, except that `' '` (space) is encoded -as `'%20'` (instead of `'+'`). -## encode_www_form(enum , enc nil) [](#method-c-encode_www_form) -Returns a URL-encoded string derived from the given -[Enumerable](https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enume -rable-label-Enumerable+in+Ruby+Classes) `enum`. - -The result is suitable for use as form data for an HTTP request whose -`Content-Type` is `'application/x-www-form-urlencoded'`. - -The returned string consists of the elements of `enum`, each converted to one -or more URL-encoded strings, and all joined with character `'&'`. - -Simple examples: - - Gem::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]]) - # => "foo=0&bar=1&baz=2" - Gem::URI.encode_www_form({foo: 0, bar: 1, baz: 2}) - # => "foo=0&bar=1&baz=2" - -The returned string is formed using method Gem::URI.encode_www_form_component, -which converts certain characters: - - Gem::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@') - # => "f%23o=%2F&b-r=%24&b+z=%40" - -When `enum` is Array-like, each element `ele` is converted to a field: - -* If `ele` is an array of two or more elements, the field is formed from its - first two elements (and any additional elements are ignored): - - name = Gem::URI.encode_www_form_component(ele[0], enc) - value = Gem::URI.encode_www_form_component(ele[1], enc) - "#{name}=#{value}" - - Examples: - - Gem::URI.encode_www_form([%w[foo bar], %w[baz bat bah]]) - # => "foo=bar&baz=bat" - Gem::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']]) - # => "foo=0&bar=baz" - -* If `ele` is an array of one element, the field is formed from `ele[0]`: - - Gem::URI.encode_www_form_component(ele[0]) - - Example: - - Gem::URI.encode_www_form([['foo'], [:bar], [0]]) - # => "foo&bar&0" - -* Otherwise the field is formed from `ele`: - - Gem::URI.encode_www_form_component(ele) - - Example: - - Gem::URI.encode_www_form(['foo', :bar, 0]) - # => "foo&bar&0" - -The elements of an Array-like `enum` may be mixture: - - Gem::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat]) - # => "foo=0&bar=1&baz&bat" - -When `enum` is Hash-like, each `key`/`value` pair is converted to one or more -fields: - -* If `value` is - [Array-convertible](https://docs.ruby-lang.org/en/master/implicit_conversi - on_rdoc.html#label-Array-Convertible+Objects), each element `ele` in - `value` is paired with `key` to form a field: - - name = Gem::URI.encode_www_form_component(key, enc) - value = Gem::URI.encode_www_form_component(ele, enc) - "#{name}=#{value}" - - Example: - - Gem::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]}) - # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2" - -* Otherwise, `key` and `value` are paired to form a field: - - name = Gem::URI.encode_www_form_component(key, enc) - value = Gem::URI.encode_www_form_component(value, enc) - "#{name}=#{value}" - - Example: - - Gem::URI.encode_www_form({foo: 0, bar: 1, baz: 2}) - # => "foo=0&bar=1&baz=2" - -The elements of a Hash-like `enum` may be mixture: - - Gem::URI.encode_www_form({foo: [0, 1], bar: 2}) - # => "foo=0&foo=1&bar=2" -## encode_www_form_component(str , enc nil) [](#method-c-encode_www_form_component) -Returns a URL-encoded string derived from the given string `str`. - -The returned string: - -* Preserves: - - * Characters `'*'`, `'.'`, `'-'`, and `'_'`. - * Character in ranges `'a'..'z'`, `'A'..'Z'`, and `'0'..'9'`. - - Example: - - Gem::URI.encode_www_form_component('*.-_azAZ09') - # => "*.-_azAZ09" - -* Converts: - - * Character `' '` to character `'+'`. - * Any other character to "percent notation"; the percent notation for - character *c* is `'%%%X' % c.ord`. - - Example: - - Gem::URI.encode_www_form_component('Here are some punctuation characters: ,;?:') - # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A" - -Encoding: - -* If `str` has encoding Encoding::ASCII_8BIT, argument `enc` is ignored. -* Otherwise `str` is converted first to Encoding::UTF_8 (with suitable - character replacements), and then to encoding `enc`. - -In either case, the returned string has forced encoding Encoding::US_ASCII. - -Related: Gem::URI.encode_uri_component (encodes `' '` as `'%20'`). -## extract(str , schemes nil, &block ) [](#method-c-extract) -## Synopsis - - Gem::URI::extract(str[, schemes][,&blk]) - -## Args - -`str` -: String to extract URIs from. - -`schemes` -: Limit Gem::URI matching to specific schemes. - - -## Description - -Extracts URIs from a string. If block given, iterates through all matched -URIs. Returns nil if block given or array with matches. - -## Usage - - require "rubygems/vendor/uri/lib/uri" - - Gem::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") - # => ["http://foo.example.com/bla", "mailto:test@example.com"] -## for(scheme , *arguments , default: Generic) [](#method-c-for) -Returns a new object constructed from the given `scheme`, `arguments`, and -`default`: - -* The new object is an instance of `Gem::URI.scheme_list[scheme.upcase]`. -* The object is initialized by calling the class initializer using `scheme` - and `arguments`. See Gem::URI::Generic.new. - -Examples: - - values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top'] - Gem::URI.for('https', *values) - # => # - Gem::URI.for('foo', *values, default: Gem::URI::HTTP) - # => # -## join(*str ) [](#method-c-join) -Merges the given Gem::URI strings `str` per [RFC -2396](https://www.rfc-editor.org/rfc/rfc2396.html). - -Each string in `str` is converted to an [RFC3986 -Gem::URI](https://www.rfc-editor.org/rfc/rfc3986.html) before being merged. - -Examples: - - Gem::URI.join("http://example.com/","main.rbx") - # => # - - Gem::URI.join('http://example.com', 'foo') - # => # - - Gem::URI.join('http://example.com', '/foo', '/bar') - # => # - - Gem::URI.join('http://example.com', '/foo', 'bar') - # => # - - Gem::URI.join('http://example.com', '/foo/', 'bar') - # => # -## parse(uri ) [](#method-c-parse) -Returns a new Gem::URI object constructed from the given string `uri`: - - Gem::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - # => # - Gem::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - # => # - -It's recommended to first ::escape string `uri` if it may contain invalid -Gem::URI characters. -## parser=(parser RFC3986_PARSER) [](#method-c-parser=) -## regexp(schemes nil) [](#method-c-regexp) -## Synopsis - - Gem::URI::regexp([match_schemes]) - -## Args - -`match_schemes` -: Array of schemes. If given, resulting regexp matches to URIs whose scheme - is one of the match_schemes. - - -## Description - -Returns a Regexp object which matches to Gem::URI-like strings. The Regexp -object returned by this method includes arbitrary number of capture group -(parentheses). Never rely on its number. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - # extract first Gem::URI from html_string - html_string.slice(Gem::URI.regexp) - - # remove ftp URIs - html_string.sub(Gem::URI.regexp(['ftp']), '') - - # You should not rely on the number of parentheses - html_string.scan(Gem::URI.regexp) do |*matches| - p $& - end -## register_scheme(scheme , klass ) [](#method-c-register_scheme) -Registers the given `klass` as the class to be instantiated when parsing a -Gem::URI with the given `scheme`: - - Gem::URI.register_scheme('MS_SEARCH', Gem::URI::Generic) # => Gem::URI::Generic - Gem::URI.scheme_list['MS_SEARCH'] # => Gem::URI::Generic - -Note that after calling String#upcase on `scheme`, it must be a valid constant -name. -## scheme_list() [](#method-c-scheme_list) -Returns a hash of the defined schemes: - - Gem::URI.scheme_list - # => - {"MAILTO"=>Gem::URI::MailTo, - "LDAPS"=>Gem::URI::LDAPS, - "WS"=>Gem::URI::WS, - "HTTP"=>Gem::URI::HTTP, - "HTTPS"=>Gem::URI::HTTPS, - "LDAP"=>Gem::URI::LDAP, - "FILE"=>Gem::URI::File, - "FTP"=>Gem::URI::FTP} - -Related: Gem::URI.register_scheme. -## split(uri ) [](#method-c-split) -Returns a 9-element array representing the parts of the Gem::URI formed from -the string `uri`; each array element is a string or `nil`: - - names = %w[scheme userinfo host port registry path opaque query fragment] - values = Gem::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - names.zip(values) - # => - [["scheme", "https"], - ["userinfo", "john.doe"], - ["host", "www.example.com"], - ["port", "123"], - ["registry", nil], - ["path", "/forum/questions/"], - ["opaque", nil], - ["query", "tag=networking&order=newest"], - ["fragment", "top"]] - diff --git a/example/ruby/Gem/URI/BadURIError.md b/example/ruby/Gem/URI/BadURIError.md deleted file mode 100644 index 7fc3346..0000000 --- a/example/ruby/Gem/URI/BadURIError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::URI::BadURIError -**Inherits:** Gem::URI::Error - - -Gem::URI is valid, bad usage is not. - - - diff --git a/example/ruby/Gem/URI/Error.md b/example/ruby/Gem/URI/Error.md deleted file mode 100644 index 187c5c4..0000000 --- a/example/ruby/Gem/URI/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::URI::Error -**Inherits:** StandardError - - -Base class for all Gem::URI exceptions. - - - diff --git a/example/ruby/Gem/URI/FTP.md b/example/ruby/Gem/URI/FTP.md deleted file mode 100644 index eb31784..0000000 --- a/example/ruby/Gem/URI/FTP.md +++ /dev/null @@ -1,91 +0,0 @@ -# Class: Gem::URI::FTP -**Inherits:** Gem::URI::Generic - - -FTP Gem::URI syntax is defined by RFC1738 section 3.2. - -This class will be redesigned because of difference of implementations; the -structure of its path. draft-hoffman-ftp-uri-04 is a draft but it is a good -summary about the de facto spec. -https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04 - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Gem::URI::FTP object from components, with syntax checking. - -The components accepted are `userinfo`, `host`, `port`, `path`, and -`typecode`. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, typecode]`. - -If the path supplied is absolute, it will be escaped in order to make it -absolute in the Gem::URI. - -Examples: - - require 'rubygems/vendor/uri/lib/uri' - - uri1 = Gem::URI::FTP.build(['user:password', 'ftp.example.com', nil, - '/path/file.zip', 'i']) - uri1.to_s # => "ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i" - - uri2 = Gem::URI::FTP.build({:host => 'ftp.example.com', - :path => 'ruby/src'}) - uri2.to_s # => "ftp://ftp.example.com/ruby/src" -## new2(user , password , host , port , path , typecode nil, arg_check true) [](#method-c-new2) -# Attributes -## typecode[RW] [](#attribute-i-typecode) -typecode accessor. - -See Gem::URI::FTP::COMPONENT. - - -#Instance Methods -## initialize(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parsernil, arg_checkfalse) [](#method-i-initialize) -## Description - -Creates a new Gem::URI::FTP object from generic URL components with no syntax -checking. - -Unlike build(), this method does not escape the path component as required by -RFC1738; instead it is treated as per RFC2396. - -Arguments are `scheme`, `userinfo`, `host`, `port`, `registry`, `path`, -`opaque`, `query`, and `fragment`, in that order. - -**@raise** [InvalidURIError] - -**@return** [FTP] a new instance of FTP - -## merge(oth) [](#method-i-merge) -:nodoc: - -## path() [](#method-i-path) -Returns the path from an FTP Gem::URI. - -RFC 1738 specifically states that the path for an FTP Gem::URI does not -include the / which separates the Gem::URI path from the Gem::URI host. -Example: - -`ftp://ftp.example.com/pub/ruby` - -The above Gem::URI indicates that the client should connect to ftp.example.com -then cd to pub/ruby from the initial login directory. - -If you want to cd to an absolute directory, you must include an escaped / -(%2F) in the path. Example: - -`ftp://ftp.example.com/%2Fpub/ruby` - -This method will then return "/pub/ruby". - -## to_s() [](#method-i-to_s) -Returns a String representation of the Gem::URI::FTP. - diff --git a/example/ruby/Gem/URI/File.md b/example/ruby/Gem/URI/File.md deleted file mode 100644 index 31ee5bf..0000000 --- a/example/ruby/Gem/URI/File.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Gem::URI::File -**Inherits:** Gem::URI::Generic - - -The "file" Gem::URI is defined by RFC8089. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Gem::URI::File object from components, with syntax checking. - -The components accepted are `host` and `path`. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[host, -path]`. - -A path from e.g. the File class should be escaped before being passed. - -Examples: - - require 'rubygems/vendor/uri/lib/uri' - - uri1 = Gem::URI::File.build(['host.example.com', '/path/file.zip']) - uri1.to_s # => "file://host.example.com/path/file.zip" - - uri2 = Gem::URI::File.build({:host => 'host.example.com', - :path => '/ruby/src'}) - uri2.to_s # => "file://host.example.com/ruby/src" - - uri3 = Gem::URI::File.build({:path => Gem::URI::escape('/path/my file.txt')}) - uri3.to_s # => "file:///path/my%20file.txt" - -#Instance Methods -## check_password(user) [](#method-i-check_password) -raise InvalidURIError - -**@raise** [Gem::URI::InvalidURIError] - -## check_user(user) [](#method-i-check_user) -raise InvalidURIError - -**@raise** [Gem::URI::InvalidURIError] - -## check_userinfo(user) [](#method-i-check_userinfo) -raise InvalidURIError - -**@raise** [Gem::URI::InvalidURIError] - -## set_host(v) [](#method-i-set_host) -Protected setter for the host component `v`. - -See also Gem::URI::Generic.host=. - -## set_password(v) [](#method-i-set_password) -do nothing - -## set_port(v) [](#method-i-set_port) -do nothing - -## set_user(v) [](#method-i-set_user) -do nothing - -## set_userinfo(v) [](#method-i-set_userinfo) -do nothing - diff --git a/example/ruby/Gem/URI/Generic.md b/example/ruby/Gem/URI/Generic.md deleted file mode 100644 index cdee663..0000000 --- a/example/ruby/Gem/URI/Generic.md +++ /dev/null @@ -1,441 +0,0 @@ -# Class: Gem::URI::Generic -**Inherits:** Object - -**Includes:** Gem::URI - - -Base class for all Gem::URI classes. Implements generic Gem::URI syntax as per -RFC 2396. - - -# Class Methods -## build(args ) [](#method-c-build) -## Synopsis - -See ::new. - -## Description - -Creates a new Gem::URI::Generic instance from components of Gem::URI::Generic -with check. Components are: scheme, userinfo, host, port, registry, path, -opaque, query, and fragment. You can provide arguments either by an Array or a -Hash. See ::new for hash keys to use or for order of array items. -## build2(args ) [](#method-c-build2) -## Synopsis - -See ::new. - -## Description - -At first, tries to create a new Gem::URI::Generic instance using -Gem::URI::Generic::build. But, if exception Gem::URI::InvalidComponentError is -raised, then it does Gem::URI::Escape.escape all Gem::URI components and tries -again. -## component() [](#method-c-component) -Components of the Gem::URI in the order. -## default_port() [](#method-c-default_port) -Returns default port. -## use_proxy?(hostname , addr , port , no_proxy ) [](#method-c-use_proxy?) -:nodoc: -**@return** [Boolean] - -## use_registry() [](#method-c-use_registry) -:nodoc: -# Attributes -## fragment[RW] [](#attribute-i-fragment) -Returns the fragment component of the Gem::URI. - - Gem::URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies" - -## host[RW] [](#attribute-i-host) -Returns the host component of the Gem::URI. - - Gem::URI("http://foo/bar/baz").host #=> "foo" - -It returns nil if no host component exists. - - Gem::URI("mailto:foo@example.org").host #=> nil - -The component does not contain the port number. - - Gem::URI("http://foo:8080/bar/baz").host #=> "foo" - -Since IPv6 addresses are wrapped with brackets in URIs, this method returns -IPv6 addresses wrapped with brackets. This form is not appropriate to pass to -socket methods such as TCPSocket.open. If unwrapped host names are required, -use the #hostname method. - - Gem::URI("http://[::1]/bar/baz").host #=> "[::1]" - Gem::URI("http://[::1]/bar/baz").hostname #=> "::1" - -## opaque[RW] [](#attribute-i-opaque) -Returns the opaque part of the Gem::URI. - - Gem::URI("mailto:foo@example.org").opaque #=> "foo@example.org" - Gem::URI("http://foo/bar/baz").opaque #=> nil - -The portion of the path that does not make use of the slash '/'. The path -typically refers to an absolute path or an opaque part. (See RFC2396 Section 3 -and 5.2.) - -## path[RW] [](#attribute-i-path) -Returns the path component of the Gem::URI. - - Gem::URI("http://foo/bar/baz").path #=> "/bar/baz" - -## port[RW] [](#attribute-i-port) -Returns the port component of the Gem::URI. - - Gem::URI("http://foo/bar/baz").port #=> 80 - Gem::URI("http://foo:8080/bar/baz").port #=> 8080 - -## query[RW] [](#attribute-i-query) -Returns the query component of the Gem::URI. - - Gem::URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar" - -## scheme[RW] [](#attribute-i-scheme) -Returns the scheme component of the Gem::URI. - - Gem::URI("http://foo/bar/baz").scheme #=> "http" - - -#Instance Methods -## ==(oth) [](#method-i-==) -Compares two URIs. - -## absolute?() [](#method-i-absolute?) -Returns true if Gem::URI has a scheme (e.g. http:// or https://) specified. - -**@return** [Boolean] - -## coerce(oth) [](#method-i-coerce) -## Args - -`v` -: Gem::URI or String - - -## Description - -Attempts to parse other Gem::URI `oth`, returns [parsed_oth, self]. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse("http://my.example.com") - uri.coerce("http://foo.com") - #=> [#, #] - -## component() [](#method-i-component) -Components of the Gem::URI in the order. - -## decoded_password() [](#method-i-decoded_password) -Returns the password component after Gem::URI decoding. - -## decoded_user() [](#method-i-decoded_user) -Returns the user component after Gem::URI decoding. - -## default_port() [](#method-i-default_port) -Returns default port. - -## eql?(oth) [](#method-i-eql?) - -**@return** [Boolean] - -## find_proxy(envENV) [](#method-i-find_proxy) -Returns a proxy Gem::URI. The proxy Gem::URI is obtained from environment -variables such as http_proxy, ftp_proxy, no_proxy, etc. If there is no proper -proxy, nil is returned. - -If the optional parameter `env` is specified, it is used instead of ENV. - -Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are -examined, too. - -But http_proxy and HTTP_PROXY is treated specially under CGI environment. It's -because HTTP_PROXY may be set by Proxy: header. So HTTP_PROXY is not used. -http_proxy is not used too if the variable is case insensitive. CGI_HTTP_PROXY -can be used instead. - -**@raise** [BadURIError] - -## hash() [](#method-i-hash) - -## hierarchical?() [](#method-i-hierarchical?) -Returns true if Gem::URI is hierarchical. - -## Description - -Gem::URI has components listed in order of decreasing significance from left -to right, see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse("http://my.example.com/") - uri.hierarchical? - #=> true - uri = Gem::URI.parse("mailto:joe@example.com") - uri.hierarchical? - #=> false - -**@return** [Boolean] - -## hostname() [](#method-i-hostname) -Extract the host part of the Gem::URI and unwrap brackets for IPv6 addresses. - -This method is the same as Gem::URI::Generic#host except brackets for IPv6 -(and future IP) addresses are removed. - - uri = Gem::URI("http://[::1]/bar") - uri.hostname #=> "::1" - uri.host #=> "[::1]" - -## hostname=(v) [](#method-i-hostname=) -Sets the host part of the Gem::URI as the argument with brackets for IPv6 -addresses. - -This method is the same as Gem::URI::Generic#host= except the argument can be -a bare IPv6 address. - - uri = Gem::URI("http://foo/bar") - uri.hostname = "::1" - uri.to_s #=> "http://[::1]/bar" - -If the argument seems to be an IPv6 address, it is wrapped with brackets. - -## initialize(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parserDEFAULT_PARSER, arg_checkfalse) [](#method-i-initialize) -## Args - -`scheme` -: Protocol scheme, i.e. 'http','ftp','mailto' and so on. - -`userinfo` -: User name and password, i.e. 'sdmitry:bla'. - -`host` -: Server host name. - -`port` -: Server port. - -`registry` -: Registry of naming authorities. - -`path` -: Path on server. - -`opaque` -: Opaque part. - -`query` -: Query data. - -`fragment` -: Part of the Gem::URI after '#' character. - -`parser` -: Parser for internal use [Gem::URI::DEFAULT_PARSER by default]. - -`arg_check` -: Check arguments [false by default]. - - -## Description - -Creates a new Gem::URI::Generic instance from ``generic'' components without -check. - -**@return** [Generic] a new instance of Generic - -## inspect() [](#method-i-inspect) - -## merge(oth) [](#method-i-merge) -## Args - -`oth` -: Gem::URI or String - - -## Description - -Merges two URIs. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse("http://my.example.com") - uri.merge("/main.rbx?page=1") - # => "http://my.example.com/main.rbx?page=1" - -## merge!(oth) [](#method-i-merge!) -## Args - -`oth` -: Gem::URI or String - - -## Description - -Destructive form of #merge. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse("http://my.example.com") - uri.merge!("/main.rbx?page=1") - uri.to_s # => "http://my.example.com/main.rbx?page=1" - -## normalize() [](#method-i-normalize) -Returns normalized Gem::URI. - - require 'rubygems/vendor/uri/lib/uri' - - Gem::URI("HTTP://my.EXAMPLE.com").normalize - #=> # - -Normalization here means: - -* scheme and host are converted to lowercase, -* an empty path component is set to "/". - -## normalize!() [](#method-i-normalize!) -Destructive version of #normalize. - -## parser() [](#method-i-parser) -Returns the parser to be used. - -Unless a Gem::URI::Parser is defined, DEFAULT_PARSER is used. - -## password() [](#method-i-password) -Returns the password component (without Gem::URI decoding). - -## password=(password) [](#method-i-password=) -## Args - -`v` -: String - - -## Description - -Public setter for the `password` component (with validation). - -See also Gem::URI::Generic.check_password. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse("http://john:S3nsit1ve@my.example.com") - uri.password = "V3ry_S3nsit1ve" - uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com" - -## registry() [](#method-i-registry) -:nodoc: - -## registry=(v) [](#method-i-registry=) - -**@raise** [InvalidURIError] - -## relative?() [](#method-i-relative?) -Returns true if Gem::URI does not have a scheme (e.g. http:// or https://) -specified. - -**@return** [Boolean] - -## route_from(oth) [](#method-i-route_from) -## Args - -`oth` -: Gem::URI or String - - -## Description - -Calculates relative path from oth to self. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse('http://my.example.com/main.rbx?page=1') - uri.route_from('http://my.example.com') - #=> # - -## route_to(oth) [](#method-i-route_to) -## Args - -`oth` -: Gem::URI or String - - -## Description - -Calculates relative path to oth from self. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse('http://my.example.com') - uri.route_to('http://my.example.com/main.rbx?page=1') - #=> # - -## select(*components) [](#method-i-select) -## Args - -`components` -: Multiple Symbol arguments defined in Gem::URI::HTTP. - - -## Description - -Selects specified components from Gem::URI. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse('http://myuser:mypass@my.example.com/test.rbx') - uri.select(:userinfo, :host, :path) - # => ["myuser:mypass", "my.example.com", "/test.rbx"] - -## to_s() [](#method-i-to_s) -Constructs String from Gem::URI. - -## user() [](#method-i-user) -Returns the user component (without Gem::URI decoding). - -## user=(user) [](#method-i-user=) -## Args - -`v` -: String - - -## Description - -Public setter for the `user` component (with validation). - -See also Gem::URI::Generic.check_user. - -## Usage - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse("http://john:S3nsit1ve@my.example.com") - uri.user = "sam" - uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com" - -## userinfo() [](#method-i-userinfo) -Returns the userinfo, either as 'user' or 'user:password'. - -## userinfo=(userinfo) [](#method-i-userinfo=) -Sets userinfo, argument is string like 'name:pass'. - diff --git a/example/ruby/Gem/URI/HTTP.md b/example/ruby/Gem/URI/HTTP.md deleted file mode 100644 index 9c6b7f2..0000000 --- a/example/ruby/Gem/URI/HTTP.md +++ /dev/null @@ -1,75 +0,0 @@ -# Class: Gem::URI::HTTP -**Inherits:** Gem::URI::Generic - - -The syntax of HTTP URIs is defined in RFC1738 section 3.3. - -Note that the Ruby Gem::URI library allows HTTP URLs containing usernames and -passwords. This is not legal as per the RFC, but used to be supported in -Internet Explorer 5 and 6, before the MS04-004 security update. See -. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Gem::URI::HTTP object from components, with syntax checking. - -The components accepted are userinfo, host, port, path, query, and fragment. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, query, fragment]`. - -Example: - - uri = Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar') - - uri = Gem::URI::HTTP.build([nil, "www.example.com", nil, "/path", - "query", 'fragment']) - -Currently, if passed userinfo components this method generates invalid HTTP -URIs as per RFC 1738. - -#Instance Methods -## authority() [](#method-i-authority) -## Description - -Returns the authority for an HTTP uri, as defined in -https://www.rfc-editor.org/rfc/rfc3986#section-3.2. - -Example: - - Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com" - Gem::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000" - Gem::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com" - -## origin() [](#method-i-origin) -## Description - -Returns the origin for an HTTP uri, as defined in -https://www.rfc-editor.org/rfc/rfc6454. - -Example: - - Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com" - Gem::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000" - Gem::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com" - Gem::URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com" - -## request_uri() [](#method-i-request_uri) -## Description - -Returns the full path for an HTTP request, as required by Net::HTTP::Get. - -If the Gem::URI contains a query, the full path is Gem::URI#path + '?' + -Gem::URI#query. Otherwise, the path is simply Gem::URI#path. - -Example: - - uri = Gem::URI::HTTP.build(path: '/foo/bar', query: 'test=true') - uri.request_uri # => "/foo/bar?test=true" - diff --git a/example/ruby/Gem/URI/HTTPS.md b/example/ruby/Gem/URI/HTTPS.md deleted file mode 100644 index 429c318..0000000 --- a/example/ruby/Gem/URI/HTTPS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Gem::URI::HTTPS -**Inherits:** Gem::URI::HTTP - - -The default port for HTTPS URIs is 443, and the scheme is 'https:' rather than -'http:'. Other than that, HTTPS URIs are identical to HTTP URIs; see -Gem::URI::HTTP. - - - diff --git a/example/ruby/Gem/URI/InvalidComponentError.md b/example/ruby/Gem/URI/InvalidComponentError.md deleted file mode 100644 index 2a32d7c..0000000 --- a/example/ruby/Gem/URI/InvalidComponentError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::URI::InvalidComponentError -**Inherits:** Gem::URI::Error - - -Not a Gem::URI component. - - - diff --git a/example/ruby/Gem/URI/InvalidURIError.md b/example/ruby/Gem/URI/InvalidURIError.md deleted file mode 100644 index 9169a53..0000000 --- a/example/ruby/Gem/URI/InvalidURIError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::URI::InvalidURIError -**Inherits:** Gem::URI::Error - - -Not a Gem::URI. - - - diff --git a/example/ruby/Gem/URI/LDAP.md b/example/ruby/Gem/URI/LDAP.md deleted file mode 100644 index f7fccf6..0000000 --- a/example/ruby/Gem/URI/LDAP.md +++ /dev/null @@ -1,85 +0,0 @@ -# Class: Gem::URI::LDAP -**Inherits:** Gem::URI::Generic - - -LDAP Gem::URI SCHEMA (described in RFC2255). -- -[ldap:///[?[?[?](?)]]] ++ - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Gem::URI::LDAP object from components, with syntax checking. - -The components accepted are host, port, dn, attributes, scope, filter, and -extensions. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[host, port, -dn, attributes, scope, filter, extensions]`. - -Example: - - uri = Gem::URI::LDAP.build({:host => 'ldap.example.com', - :dn => '/dc=example'}) - - uri = Gem::URI::LDAP.build(["ldap.example.com", nil, - "/dc=example;dc=com", "query", nil, nil, nil]) - -#Instance Methods -## attributes() [](#method-i-attributes) -Returns attributes. - -## attributes=(val) [](#method-i-attributes=) -Setter for attributes `val`. - -## dn() [](#method-i-dn) -Returns dn. - -## dn=(val) [](#method-i-dn=) -Setter for dn `val`. - -## extensions() [](#method-i-extensions) -Returns extensions. - -## extensions=(val) [](#method-i-extensions=) -Setter for extensions `val`. - -## filter() [](#method-i-filter) -Returns filter. - -## filter=(val) [](#method-i-filter=) -Setter for filter `val`. - -## hierarchical?() [](#method-i-hierarchical?) -Checks if Gem::URI has a path. For Gem::URI::LDAP this will return `false`. - -**@return** [Boolean] - -## initialize(*arg) [](#method-i-initialize) -## Description - -Creates a new Gem::URI::LDAP object from generic Gem::URI components as per -RFC 2396. No LDAP-specific syntax checking is performed. - -Arguments are `scheme`, `userinfo`, `host`, `port`, `registry`, `path`, -`opaque`, `query`, and `fragment`, in that order. - -Example: - - uri = Gem::URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil, - "/dc=example;dc=com", nil, "query", nil) - -See also Gem::URI::Generic.new. - -**@return** [LDAP] a new instance of LDAP - -## scope() [](#method-i-scope) -Returns scope. - -## scope=(val) [](#method-i-scope=) -Setter for scope `val`. - diff --git a/example/ruby/Gem/URI/LDAPS.md b/example/ruby/Gem/URI/LDAPS.md deleted file mode 100644 index 3f0bad2..0000000 --- a/example/ruby/Gem/URI/LDAPS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Gem::URI::LDAPS -**Inherits:** Gem::URI::LDAP - - -The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather than -'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs; see -Gem::URI::LDAP. - - - diff --git a/example/ruby/Gem/URI/MailTo.md b/example/ruby/Gem/URI/MailTo.md deleted file mode 100644 index 6907653..0000000 --- a/example/ruby/Gem/URI/MailTo.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Gem::URI::MailTo -**Inherits:** Gem::URI::Generic - -**Includes:** Gem::URI::RFC2396_REGEXP - - -RFC6068, the mailto URL scheme. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Gem::URI::MailTo object from components, with syntax checking. - -Components can be provided as an Array or Hash. If an Array is used, the -components must be supplied as `[to, headers]`. - -If a Hash is used, the keys are the component names preceded by colons. - -The headers can be supplied as a pre-encoded string, such as -`"subject=subscribe&cc=address"`, or as an Array of Arrays like `[['subject', -'subscribe'], ['cc', 'address']]`. - -Examples: - - require 'rubygems/vendor/uri/lib/uri' - - m1 = Gem::URI::MailTo.build(['joe@example.com', 'subject=Ruby']) - m1.to_s # => "mailto:joe@example.com?subject=Ruby" - - m2 = Gem::URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]]) - m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com" - - m3 = Gem::URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]}) - m3.to_s # => "mailto:listman@example.com?subject=subscribe" -# Attributes -## headers[RW] [](#attribute-i-headers) -E-mail headers set by the URL, as an Array of Arrays. - -## to[RW] [](#attribute-i-to) -The primary e-mail address of the URL, as a String. - - -#Instance Methods -## initialize(*arg) [](#method-i-initialize) -## Description - -Creates a new Gem::URI::MailTo object from generic URL components with no -syntax checking. - -This method is usually called from Gem::URI::parse, which checks the validity -of each component. - -**@return** [MailTo] a new instance of MailTo - -## to_mailtext() [](#method-i-to_mailtext) -Returns the RFC822 e-mail text equivalent of the URL, as a String. - -Example: - - require 'rubygems/vendor/uri/lib/uri' - - uri = Gem::URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr") - uri.to_mailtext - # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n" - -## to_s() [](#method-i-to_s) -Constructs String from Gem::URI. - diff --git a/example/ruby/Gem/URI/RFC2396_Parser.md b/example/ruby/Gem/URI/RFC2396_Parser.md deleted file mode 100644 index c013fd8..0000000 --- a/example/ruby/Gem/URI/RFC2396_Parser.md +++ /dev/null @@ -1,154 +0,0 @@ -# Class: Gem::URI::RFC2396_Parser -**Inherits:** Object - -**Includes:** Gem::URI::RFC2396_REGEXP - - -Class that parses String's into Gem::URI's. - -It contains a Hash set of patterns and Regexp's that match and validate. - - -# Attributes -## pattern[RW] [](#attribute-i-pattern) -The Hash of patterns. - -See also Gem::URI::Parser.initialize_pattern. - -## regexp[RW] [](#attribute-i-regexp) -The Hash of Regexp. - -See also Gem::URI::Parser.initialize_regexp. - - -#Instance Methods -## escape(str, unsafe) [](#method-i-escape) -:call-seq: - escape( str ) - escape( str, unsafe ) - -## Args - -`str` -: String to make safe - -`unsafe` -: Regexp to apply. Defaults to `self.regexp[:UNSAFE]` - - -## Description - -Constructs a safe String from `str`, removing unsafe characters, replacing -them with codes. - -## extract(str, schemesnil) [](#method-i-extract) -:call-seq: - extract( str ) - extract( str, schemes ) - extract( str, schemes ) {|item| block } - -## Args - -`str` -: String to search - -`schemes` -: Patterns to apply to `str` - - -## Description - -Attempts to parse and merge a set of URIs. If no `block` given, then returns -the result, else it calls `block` for each element in result. - -See also Gem::URI::Parser.make_regexp. - -## initialize(opts{}) [](#method-i-initialize) -## Synopsis - - Gem::URI::Parser.new([opts]) - -## Args - -The constructor accepts a hash as options for parser. Keys of options are -pattern names of Gem::URI components and values of options are pattern -strings. The constructor generates set of regexps for parsing URIs. - -You can use the following keys: - - * :ESCAPED (Gem::URI::PATTERN::ESCAPED in default) - * :UNRESERVED (Gem::URI::PATTERN::UNRESERVED in default) - * :DOMLABEL (Gem::URI::PATTERN::DOMLABEL in default) - * :TOPLABEL (Gem::URI::PATTERN::TOPLABEL in default) - * :HOSTNAME (Gem::URI::PATTERN::HOSTNAME in default) - -## Examples - - p = Gem::URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})") - u = p.parse("http://example.jp/%uABCD") #=> # - Gem::URI.parse(u.to_s) #=> raises Gem::URI::InvalidURIError - - s = "http://example.com/ABCD" - u1 = p.parse(s) #=> # - u2 = Gem::URI.parse(s) #=> # - u1 == u2 #=> true - u1.eql?(u2) #=> false - -**@return** [RFC2396_Parser] a new instance of RFC2396_Parser - -## inspect() [](#method-i-inspect) - -## join(*uris) [](#method-i-join) -## Args - -`uris` -: an Array of Strings - - -## Description - -Attempts to parse and merge a set of URIs. - -## make_regexp(schemesnil) [](#method-i-make_regexp) -Returns Regexp that is default `self.regexp[:ABS_URI_REF]`, unless `schemes` -is provided. Then it is a Regexp.union with `self.pattern[:X_ABS_URI]`. - -## parse(uri) [](#method-i-parse) -## Args - -`uri` -: String - - -## Description - -Parses `uri` and constructs either matching Gem::URI scheme object (File, FTP, -HTTP, HTTPS, LDAP, LDAPS, or MailTo) or Gem::URI::Generic. - -## Usage - - p = Gem::URI::Parser.new - p.parse("ldap://ldap.example.com/dc=example?user=john") - #=> # - -## split(uri) [](#method-i-split) -Returns a split Gem::URI against `regexp[:ABS_URI]`. - -## unescape(str, escaped) [](#method-i-unescape) -:call-seq: - unescape( str ) - unescape( str, escaped ) - -## Args - -`str` -: String to remove escapes from - -`escaped` -: Regexp to apply. Defaults to `self.regexp[:ESCAPED]` - - -## Description - -Removes escapes from `str`. - diff --git a/example/ruby/Gem/URI/RFC2396_REGEXP.md b/example/ruby/Gem/URI/RFC2396_REGEXP.md deleted file mode 100644 index d9789fa..0000000 --- a/example/ruby/Gem/URI/RFC2396_REGEXP.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::URI::RFC2396_REGEXP - - -Includes Gem::URI::REGEXP::PATTERN - - - diff --git a/example/ruby/Gem/URI/RFC2396_REGEXP/PATTERN.md b/example/ruby/Gem/URI/RFC2396_REGEXP/PATTERN.md deleted file mode 100644 index 45ada6e..0000000 --- a/example/ruby/Gem/URI/RFC2396_REGEXP/PATTERN.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Gem::URI::RFC2396_REGEXP::PATTERN - - -Patterns used to parse Gem::URI's - - - diff --git a/example/ruby/Gem/URI/RFC3986_Parser.md b/example/ruby/Gem/URI/RFC3986_Parser.md deleted file mode 100644 index 788596e..0000000 --- a/example/ruby/Gem/URI/RFC3986_Parser.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Gem::URI::RFC3986_Parser -**Inherits:** Object - - -:nodoc: - - -# Attributes -## regexp[RW] [](#attribute-i-regexp) -Returns the value of attribute regexp. - - -#Instance Methods -## escape(str, unsafenil) [](#method-i-escape) -Compatibility for RFC2396 parser - -## extract(str, schemesnil, &block) [](#method-i-extract) -Compatibility for RFC2396 parser - -## initialize() [](#method-i-initialize) - -**@return** [RFC3986_Parser] a new instance of RFC3986_Parser - -## inspect() [](#method-i-inspect) - -## join(*uris) [](#method-i-join) -:nodoc: - -## make_regexp(schemesnil) [](#method-i-make_regexp) -Compatibility for RFC2396 parser - -## parse(uri) [](#method-i-parse) -:nodoc: - -## split(uri) [](#method-i-split) -:nodoc: - -## unescape(str, escapednil) [](#method-i-unescape) -Compatibility for RFC2396 parser - diff --git a/example/ruby/Gem/URI/Util.md b/example/ruby/Gem/URI/Util.md deleted file mode 100644 index 3413d21..0000000 --- a/example/ruby/Gem/URI/Util.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Gem::URI::Util - - -:nodoc: - - -# Class Methods -## make_components_hash(klass , array_hash ) [](#method-c-make_components_hash) - diff --git a/example/ruby/Gem/URI/WS.md b/example/ruby/Gem/URI/WS.md deleted file mode 100644 index a9c41bc..0000000 --- a/example/ruby/Gem/URI/WS.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Gem::URI::WS -**Inherits:** Gem::URI::Generic - - -The syntax of WS URIs is defined in RFC6455 section 3. - -Note that the Ruby Gem::URI library allows WS URLs containing usernames and -passwords. This is not legal as per the RFC, but used to be supported in -Internet Explorer 5 and 6, before the MS04-004 security update. See -. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new Gem::URI::WS object from components, with syntax checking. - -The components accepted are userinfo, host, port, path, and query. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, query]`. - -Example: - - uri = Gem::URI::WS.build(host: 'www.example.com', path: '/foo/bar') - - uri = Gem::URI::WS.build([nil, "www.example.com", nil, "/path", "query"]) - -Currently, if passed userinfo components this method generates invalid WS URIs -as per RFC 1738. - -#Instance Methods -## request_uri() [](#method-i-request_uri) -## Description - -Returns the full path for a WS Gem::URI, as required by Net::HTTP::Get. - -If the Gem::URI contains a query, the full path is Gem::URI#path + '?' + -Gem::URI#query. Otherwise, the path is simply Gem::URI#path. - -Example: - - uri = Gem::URI::WS.build(path: '/foo/bar', query: 'test=true') - uri.request_uri # => "/foo/bar?test=true" - diff --git a/example/ruby/Gem/URI/WSS.md b/example/ruby/Gem/URI/WSS.md deleted file mode 100644 index 4fab58c..0000000 --- a/example/ruby/Gem/URI/WSS.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Gem::URI::WSS -**Inherits:** Gem::URI::WS - - -The default port for WSS URIs is 443, and the scheme is 'wss:' rather than -'ws:'. Other than that, WSS URIs are identical to WS URIs; see Gem::URI::WS. - - - diff --git a/example/ruby/Gem/UninstallError.md b/example/ruby/Gem/UninstallError.md deleted file mode 100644 index 542d723..0000000 --- a/example/ruby/Gem/UninstallError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Gem::UninstallError -**Inherits:** Gem::Exception - - -Raised when removing a gem with the uninstall command fails - - -# Attributes -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - diff --git a/example/ruby/Gem/Uninstaller.md b/example/ruby/Gem/Uninstaller.md deleted file mode 100644 index ca391b8..0000000 --- a/example/ruby/Gem/Uninstaller.md +++ /dev/null @@ -1,151 +0,0 @@ -# Class: Gem::Uninstaller -**Inherits:** Object - -**Includes:** Gem::InstallerUninstallerUtils, Gem::UserInteraction - - -An Uninstaller. - -The uninstaller fires pre and post uninstall hooks. Hooks can be added either -through a rubygems_plugin.rb file in an installed gem or via a -rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb -file. See Gem.pre_uninstall and Gem.post_uninstall for details. - - -# Attributes -## bin_dir[RW] [](#attribute-i-bin_dir) -The directory a gem's executables will be installed into - -## gem_home[RW] [](#attribute-i-gem_home) -The gem repository the gem will be uninstalled from - -## spec[RW] [](#attribute-i-spec) -The Gem::Specification for the gem being uninstalled, only set during -#uninstall_gem - - -#Instance Methods -## abort_on_dependent?() [](#method-i-abort_on_dependent?) -Should the uninstallation abort if a dependency will go unsatisfied? - -See ::new. - -**@return** [Boolean] - -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_if_ok(spec) [](#method-i-ask_if_ok) -Asks if it is OK to remove `spec`. Returns true if it is OK. - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## dependencies_ok?(spec) [](#method-i-dependencies_ok?) -Returns true if it is OK to remove `spec` or this is a forced uninstallation. - -**@return** [Boolean] - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## formatted_program_filename(filename) [](#method-i-formatted_program_filename) -Returns the formatted version of the executable `filename` - -## initialize(gem, options{}) [](#method-i-initialize) -Constructs an uninstaller that will uninstall `gem` - -**@return** [Uninstaller] a new instance of Uninstaller - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## path_ok?(gem_dir, spec) [](#method-i-path_ok?) -Is `spec` in `gem_dir`? - -**@return** [Boolean] - -## regenerate_plugins() [](#method-i-regenerate_plugins) -Regenerates plugin wrappers after removal. - -## regenerate_plugins_for(spec, plugins_dir) [](#method-i-regenerate_plugins_for) - -## remove(spec) [](#method-i-remove) -spec -: the spec of the gem to be uninstalled - - -**@raise** [Gem::FilePermissionError] - -## remove_all(list) [](#method-i-remove_all) -Removes all gems in `list`. - -NOTE: removes uninstalled gems from `list`. - -## remove_executables(spec) [](#method-i-remove_executables) -Removes installed executables and batch files (windows only) for `spec`. - -## remove_plugins(spec) [](#method-i-remove_plugins) -Remove any plugin wrappers for `spec`. - -## remove_plugins_for(spec, plugins_dir) [](#method-i-remove_plugins_for) - -## safe_delete(&block) [](#method-i-safe_delete) - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## uninstall() [](#method-i-uninstall) -Performs the uninstall of the gem. This removes the spec, the Gem directory, -and the cached .gem file. - -## uninstall_gem(stub) [](#method-i-uninstall_gem) -Uninstalls gem `spec` - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/UnknownCommandError.md b/example/ruby/Gem/UnknownCommandError.md deleted file mode 100644 index 7fdb49d..0000000 --- a/example/ruby/Gem/UnknownCommandError.md +++ /dev/null @@ -1,18 +0,0 @@ -# Exception: Gem::UnknownCommandError -**Inherits:** Gem::Exception - - - - -# Class Methods -## attach_correctable() [](#method-c-attach_correctable) -# Attributes -## unknown_command[RW] [](#attribute-i-unknown_command) -Returns the value of attribute unknown_command. - - -#Instance Methods -## initialize(unknown_command) [](#method-i-initialize) - -**@return** [UnknownCommandError] a new instance of UnknownCommandError - diff --git a/example/ruby/Gem/UnknownCommandSpellChecker.md b/example/ruby/Gem/UnknownCommandSpellChecker.md deleted file mode 100644 index 7f48ff9..0000000 --- a/example/ruby/Gem/UnknownCommandSpellChecker.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Gem::UnknownCommandSpellChecker -**Inherits:** Object - - - - -# Attributes -## error[RW] [](#attribute-i-error) -Returns the value of attribute error. - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize(error) [](#method-i-initialize) - -**@return** [UnknownCommandSpellChecker] a new instance of UnknownCommandSpellChecker - diff --git a/example/ruby/Gem/UnsatisfiableDependencyError.md b/example/ruby/Gem/UnsatisfiableDependencyError.md deleted file mode 100644 index 566d6b7..0000000 --- a/example/ruby/Gem/UnsatisfiableDependencyError.md +++ /dev/null @@ -1,30 +0,0 @@ -# Exception: Gem::UnsatisfiableDependencyError -**Inherits:** Gem::DependencyError - - -Raised by Resolver when a dependency requests a gem for which there is no -spec. - - -# Attributes -## dependency[RW] [](#attribute-i-dependency) -The unsatisfiable dependency. This is a Gem::Resolver::DependencyRequest, not -a Gem::Dependency - -## errors[RW] [](#attribute-i-errors) -Errors encountered which may have contributed to this exception - - -#Instance Methods -## initialize(dep, platform_mismatchnil) [](#method-i-initialize) -Creates a new UnsatisfiableDependencyError for the unsatisfiable -Gem::Resolver::DependencyRequest `dep` - -**@return** [UnsatisfiableDependencyError] a new instance of UnsatisfiableDependencyError - -## name() [](#method-i-name) -The name of the unresolved dependency - -## version() [](#method-i-version) -The Requirement of the unresolved dependency (not Version). - diff --git a/example/ruby/Gem/UpdateSuggestion.md b/example/ruby/Gem/UpdateSuggestion.md deleted file mode 100644 index cc211ef..0000000 --- a/example/ruby/Gem/UpdateSuggestion.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: Gem::UpdateSuggestion - - -Mixin methods for Gem::Command to promote available RubyGems update - - - -#Instance Methods -## eligible_for_update?() [](#method-i-eligible_for_update?) -Determines if current environment is eligible for update suggestion. - -**@return** [Boolean] - -## update_suggestion() [](#method-i-update_suggestion) -Message to promote available RubyGems update with related gem update command. - diff --git a/example/ruby/Gem/Uri.md b/example/ruby/Gem/Uri.md deleted file mode 100644 index 3f7b2ca..0000000 --- a/example/ruby/Gem/Uri.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Gem::Uri -**Inherits:** Object - - -The Uri handles rubygems source URIs. - - -# Class Methods -## parse(uri ) [](#method-c-parse) -Parses uri, returning the original uri if it's invalid -## parse!(uri ) [](#method-c-parse!) -Parses uri, raising if it's invalid -**@raise** [Gem::URI::InvalidURIError] - -## redact(uri ) [](#method-c-redact) -Parses and redacts uri - -#Instance Methods -## initialize(source_uri) [](#method-i-initialize) - -**@return** [Uri] a new instance of Uri - -## method_missing(method_name, *args, &blk) [](#method-i-method_missing) - -## redact_credentials_from(text) [](#method-i-redact_credentials_from) - -## redacted() [](#method-i-redacted) - -## respond_to_missing?(method_name, include_privatefalse) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Gem/UriFormatter.md b/example/ruby/Gem/UriFormatter.md deleted file mode 100644 index 3f3823b..0000000 --- a/example/ruby/Gem/UriFormatter.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Gem::UriFormatter -**Inherits:** Object - - -The UriFormatter handles URIs from user-input and escaping. - - uf = Gem::UriFormatter.new 'example.com' - - p uf.normalize #=> 'http://example.com' - - -# Attributes -## uri[RW] [](#attribute-i-uri) -The URI to be formatted. - - -#Instance Methods -## escape() [](#method-i-escape) -Escapes the #uri for use as a CGI parameter - -## initialize(uri) [](#method-i-initialize) -Creates a new URI formatter for `uri`. - -**@return** [UriFormatter] a new instance of UriFormatter - -## normalize() [](#method-i-normalize) -Normalize the URI by adding "http://" if it is missing. - -## unescape() [](#method-i-unescape) -Unescapes the #uri which came from a CGI parameter - diff --git a/example/ruby/Gem/UserInteraction.md b/example/ruby/Gem/UserInteraction.md deleted file mode 100644 index 9a36ea6..0000000 --- a/example/ruby/Gem/UserInteraction.md +++ /dev/null @@ -1,88 +0,0 @@ -# Module: Gem::UserInteraction - -**Includes:** Gem::DefaultUserInteraction - - -UserInteraction allows RubyGems to interact with the user through standard -methods that can be replaced with more-specific UI methods for different -displays. - -Since UserInteraction dispatches to a concrete UI class you may need to -reference other classes for specific behavior such as Gem::ConsoleUI or -Gem::SilentUI. - -Example: - - class X - include Gem::UserInteraction - - def get_answer - n = ask("What is the meaning of life?") - end - end - - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/Util.md b/example/ruby/Gem/Util.md deleted file mode 100644 index 0f3f8b0..0000000 --- a/example/ruby/Gem/Util.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module: Gem::Util - -**Extended by:** Gem::Deprecate - - -This module contains various utility methods as module methods. - - -# Class Methods -## correct_for_windows_path(path ) [](#method-c-correct_for_windows_path) -Corrects `path` (usually returned by `Gem::URI.parse().path` on Windows), that -comes with a leading slash. -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -## glob_files_in_dir(glob , base_path ) [](#method-c-glob_files_in_dir) -Globs for files matching `pattern` inside of `directory`, returning absolute -paths to the matching files. -## gunzip(data ) [](#method-c-gunzip) -Zlib::GzipReader wrapper that unzips `data`. -## gzip(data ) [](#method-c-gzip) -Zlib::GzipWriter wrapper that zips `data`. -## inflate(data ) [](#method-c-inflate) -A Zlib::Inflate#inflate wrapper -## popen(*command ) [](#method-c-popen) -This calls IO.popen and reads the result -## silent_system(*command ) [](#method-c-silent_system) -Invokes system, but silences all output. -## traverse_parents(directory , &block ) [](#method-c-traverse_parents) -Enumerates the parents of `directory`. - diff --git a/example/ruby/Gem/Validator.md b/example/ruby/Gem/Validator.md deleted file mode 100644 index 73db754..0000000 --- a/example/ruby/Gem/Validator.md +++ /dev/null @@ -1,89 +0,0 @@ -# Class: Gem::Validator -**Inherits:** Object - -**Includes:** Gem::UserInteraction - - -Validator performs various gem file and gem database validation - - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## alien(gems[]) [](#method-i-alien) -Checks the gem directory for the following potential inconsistencies/problems: - -* Checksum gem itself -* For each file in each gem, check consistency of installed versions -* Check for files that aren't part of the gem but are in the gems directory -* 1 cache - 1 spec - 1 directory. - -returns a hash of ErrorData objects, keyed on the problem gem's name. -- TODO -needs further cleanup - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## initialize() [](#method-i-initialize) -:nodoc: - -**@return** [Validator] a new instance of Validator - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/Gem/Validator/ErrorData.md b/example/ruby/Gem/Validator/ErrorData.md deleted file mode 100644 index d181235..0000000 --- a/example/ruby/Gem/Validator/ErrorData.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Gem::Validator::ErrorData -**Inherits:** Struct - - -Describes a problem with a file in a gem. - - -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path - -**@return** [Object] the current value of path - -## problem[RW] [](#attribute-i-problem) -Returns the value of attribute problem - -**@return** [Object] the current value of problem - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -:nodoc: - diff --git a/example/ruby/Gem/VerificationError.md b/example/ruby/Gem/VerificationError.md deleted file mode 100644 index 4a39cab..0000000 --- a/example/ruby/Gem/VerificationError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Gem::VerificationError -**Inherits:** Gem::Exception - - -Raised by Gem::Validator when something is not right in a gem. - - - diff --git a/example/ruby/Gem/Version.md b/example/ruby/Gem/Version.md deleted file mode 100644 index 3d709e0..0000000 --- a/example/ruby/Gem/Version.md +++ /dev/null @@ -1,340 +0,0 @@ -# Class: Gem::Version -**Inherits:** Object - -**Includes:** Comparable - - -The Version class processes string versions into comparable values. A version -string should normally be a series of numbers separated by periods. Each part -(digits separated by periods) is considered its own number, and these are used -for sorting. So for instance, 3.10 sorts higher than 3.2 because ten is -greater than two. - -If any part contains letters (currently only a-z are supported) then that -version is considered prerelease. Versions with a prerelease part in the Nth -part sort less than versions with N-1 parts. Prerelease parts are sorted -alphabetically using the normal Ruby string sorting rules. If a prerelease -part contains both letters and numbers, it will be broken into multiple parts -to provide expected sort behavior (1.0.a10 becomes 1.0.a.10, and is greater -than 1.0.a9). - -Prereleases sort between real releases (newest to oldest): - -1. 1.0 -2. 1.0.b1 -3. 1.0.a.2 -4. 0.9 - -If you want to specify a version restriction that includes both prereleases -and regular releases of the 1.x series this is the best way: - - s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0' - -## How Software Changes - -Users expect to be able to specify a version constraint that gives them some -reasonable expectation that new versions of a library will work with their -software if the version constraint is true, and not work with their software -if the version constraint is false. In other words, the perfect system will -accept all compatible versions of the library and reject all incompatible -versions. - -Libraries change in 3 ways (well, more than 3, but stay focused here!). - -1. The change may be an implementation detail only and have no effect on the - client software. -2. The change may add new features, but do so in a way that client software - written to an earlier version is still compatible. -3. The change may change the public interface of the library in such a way - that old software is no longer compatible. - -Some examples are appropriate at this point. Suppose I have a Stack class -that supports a `push` and a `pop` method. - -### Examples of Category 1 changes: - -* Switch from an array based implementation to a linked-list based - implementation. -* Provide an automatic (and transparent) backing store for large stacks. - -### Examples of Category 2 changes might be: - -* Add a `depth` method to return the current depth of the stack. -* Add a `top` method that returns the current top of stack (without changing - the stack). -* Change `push` so that it returns the item pushed (previously it had no - usable return value). - -### Examples of Category 3 changes might be: - -* Changes `pop` so that it no longer returns a value (you must use `top` to - get the top of the stack). -* Rename the methods to `push_item` and `pop_item`. - -## RubyGems Rational Versioning - -* Versions shall be represented by three non-negative integers, separated by - periods (e.g. 3.1.4). The first integers is the "major" version number, - the second integer is the "minor" version number, and the third integer is - the "build" number. - -* A category 1 change (implementation detail) will increment the build - number. - -* A category 2 change (backwards compatible) will increment the minor - version number and reset the build number. - -* A category 3 change (incompatible) will increment the major build number - and reset the minor and build numbers. - -* Any "public" release of a gem should have a different version. Normally - that means incrementing the build number. This means a developer can - generate builds all day long, but as soon as they make a public release, - the version must be updated. - -### Examples - -Let's work through a project lifecycle using our Stack example from above. - -Version 0.0.1 -: The initial Stack class is release. - -Version 0.0.2 -: Switched to a linked=list implementation because it is cooler. - -Version 0.1.0 -: Added a `depth` method. - -Version 1.0.0 -: Added `top` and made `pop` return nil (`pop` used to return the old top - item). - -Version 1.1.0 -: `push` now returns the value pushed (it used it return nil). - -Version 1.1.1 -: Fixed a bug in the linked list implementation. - -Version 1.1.2 -: Fixed a bug introduced in the last fix. - - -Client A needs a stack with basic push/pop capability. They write to the -original interface (no `top`), so their version constraint looks like: - - gem 'stack', '>= 0.0' - -Essentially, any version is OK with Client A. An incompatible change to the -library will cause them grief, but they are willing to take the chance (we -call Client A optimistic). - -Client B is just like Client A except for two things: (1) They use the `depth` -method and (2) they are worried about future incompatibilities, so they write -their version constraint like this: - - gem 'stack', '~> 0.1' - -The `depth` method was introduced in version 0.1.0, so that version or -anything later is fine, as long as the version stays below version 1.0 where -incompatibilities are introduced. We call Client B pessimistic because they -are worried about incompatible future changes (it is OK to be pessimistic!). - -## Preventing Version Catastrophe: - -From: -https://www.zenspider.com/ruby/2008/10/rubygems-how-to-preventing-catastrophe. -html - -Let's say you're depending on the fnord gem version 2.y.z. If you specify your -dependency as ">= 2.0.0" then, you're good, right? What happens if fnord 3.0 -comes out and it isn't backwards compatible with 2.y.z? Your stuff will break -as a result of using ">=". The better route is to specify your dependency with -an "approximate" version specifier ("~>"). They're a tad confusing, so here is -how the dependency specifiers work: - - Specification From ... To (exclusive) - ">= 3.0" 3.0 ... ∞ - "~> 3.0" 3.0 ... 4.0 - "~> 3.0.0" 3.0.0 ... 3.1 - "~> 3.5" 3.5 ... 4.0 - "~> 3.5.0" 3.5.0 ... 3.6 - "~> 3" 3.0 ... 4.0 - -For the last example, single-digit versions are automatically extended with a -zero to give a sensible result. - - -# Class Methods -## correct?(version ) [](#method-c-correct?) -True if the `version` string matches RubyGems' requirements. -**@return** [Boolean] - -## create(input ) [](#method-c-create) -Factory method to create a Version object. Input may be a Version or a String. -Intended to simplify client code. - - ver1 = Version.create('1.3.17') # -> (Version object) - ver2 = Version.create(ver1) # -> (ver1) - ver3 = Version.create(nil) # -> nil -## new(version ) [](#method-c-new) -:nodoc: - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Compares this version with `other` returning -1, 0, or 1 if the other version -is larger, the same, or smaller than this one. Attempts to compare to -something that's not a `Gem::Version` or a valid version String return `nil`. - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## approximate_recommendation() [](#method-i-approximate_recommendation) -A recommended version for use with a ~> Requirement. - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## bump() [](#method-i-bump) -Return a new version object where the next to the last revision number is one -greater (e.g., 5.3.1 => 5.4). - -Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored. - -## canonical_segments() [](#method-i-canonical_segments) -remove trailing zeros segments before first letter or at the end of the -version - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## encode_with(coder) [](#method-i-encode_with) -:nodoc: - -## eql?(other) [](#method-i-eql?) -A Version is only eql? to another version if it's specified to the same -precision. Version "1.0" is not the same as version "1". - -**@return** [Boolean] - -## freeze() [](#method-i-freeze) - -## hash() [](#method-i-hash) -:nodoc: - -## init_with(coder) [](#method-i-init_with) -:nodoc: - -## initialize(version) [](#method-i-initialize) -Constructs a Version from the `version` string. A version string is a series -of digits or ASCII letters separated by dots. - -**@return** [Version] a new instance of Version - -## inspect() [](#method-i-inspect) -:nodoc: - -## marshal_dump() [](#method-i-marshal_dump) -Dump only the raw version string, not the complete object. It's a string for -backwards (RubyGems 1.3.5 and earlier) compatibility. - -## marshal_load(array) [](#method-i-marshal_load) -Load custom marshal format. It's a string for backwards (RubyGems 1.3.5 and -earlier) compatibility. - -**@raise** [TypeError] - -## prerelease?() [](#method-i-prerelease?) -A version is considered a prerelease if it contains a letter. - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## release() [](#method-i-release) -The release for this version (e.g. 1.2.0.a -> 1.2.0). Non-prerelease versions -return themselves. - -## segments() [](#method-i-segments) -:nodoc: - -## version() [](#method-i-version) -A string representation of this Version. - -## yaml_initialize(tag, map) [](#method-i-yaml_initialize) -:nodoc: - diff --git a/example/ruby/Gem/VersionOption.md b/example/ruby/Gem/VersionOption.md deleted file mode 100644 index 9a862f9..0000000 --- a/example/ruby/Gem/VersionOption.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: Gem::VersionOption - - -Mixin methods for --version and --platform Gem::Command options. - - - -#Instance Methods -## add_platform_option(taskcommand, *wrap) [](#method-i-add_platform_option) -Add the --platform option to the option parser. - -## add_prerelease_option(*wrap) [](#method-i-add_prerelease_option) -Add the --prerelease option to the option parser. - -## add_version_option(taskcommand, *wrap) [](#method-i-add_version_option) -Add the --version option to the option parser. - -## get_platform_from_requirements(requirements) [](#method-i-get_platform_from_requirements) -Extract platform given on the command line - diff --git a/example/ruby/Gem/WebauthnVerificationError.md b/example/ruby/Gem/WebauthnVerificationError.md deleted file mode 100644 index 43abdcb..0000000 --- a/example/ruby/Gem/WebauthnVerificationError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: Gem::WebauthnVerificationError -**Inherits:** Gem::Exception - - -Raised by Gem::WebauthnListener when an error occurs during security device -verification. - - - -#Instance Methods -## initialize(message) [](#method-i-initialize) - -**@return** [WebauthnVerificationError] a new instance of WebauthnVerificationError - diff --git a/example/ruby/Gem/YAMLSerializer.md b/example/ruby/Gem/YAMLSerializer.md deleted file mode 100644 index 75e2a8e..0000000 --- a/example/ruby/Gem/YAMLSerializer.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Gem::YAMLSerializer - - -A stub yaml serializer that can handle only hashes and strings (as of now). - - -# Class Methods -## dump(hash ) [](#method-c-dump) -## dump_hash(hash ) [](#method-c-dump_hash) -## load(str ) [](#method-c-load) -## strip_comment(val ) [](#method-c-strip_comment) - diff --git a/example/ruby/GemTest.md b/example/ruby/GemTest.md deleted file mode 100644 index 166624c..0000000 --- a/example/ruby/GemTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: GemTest -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_operating_system_customizing_default_dir() [](#method-i-test_operating_system_customizing_default_dir) - -## test_operating_system_other_exceptions() [](#method-i-test_operating_system_other_exceptions) - -## test_rubygems_normal_behaviour() [](#method-i-test_rubygems_normal_behaviour) - diff --git a/example/ruby/Git.md b/example/ruby/Git.md deleted file mode 100644 index e41db3c..0000000 --- a/example/ruby/Git.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Git -**Inherits:** Object - - - - - -#Instance Methods -## add(file) [](#method-i-add) - -## initialize(oldrev, newrev) [](#method-i-initialize) - -**@return** [Git] a new instance of Git - -## toplevel() [](#method-i-toplevel) - -## updated_lines(file) [](#method-i-updated_lines) -0, 1, 4, ... -: - -## updated_paths() [](#method-i-updated_paths) -"foo/bar.c", "baz.h", ... -: - diff --git a/example/ruby/Gods.md b/example/ruby/Gods.md deleted file mode 100644 index 3d4e59f..0000000 --- a/example/ruby/Gods.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Gods -**Inherits:** Object - - - - -# Class Methods -## ruler1() [](#method-c-ruler1) -<= per method definition style -## ruler2() [](#method-c-ruler2) - -#Instance Methods -## ruler0() [](#method-i-ruler0) - diff --git a/example/ruby/HCMSpecs.md b/example/ruby/HCMSpecs.md deleted file mode 100644 index bb3ce70..0000000 --- a/example/ruby/HCMSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: HCMSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/HIMMSpecs.md b/example/ruby/HIMMSpecs.md deleted file mode 100644 index 4dc0d60..0000000 --- a/example/ruby/HIMMSpecs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HIMMSpecs -**Inherits:** Object - - - - - -#Instance Methods -## instance_method() [](#method-i-instance_method) - diff --git a/example/ruby/HIMMSpecs/Subclass.md b/example/ruby/HIMMSpecs/Subclass.md deleted file mode 100644 index 3f63777..0000000 --- a/example/ruby/HIMMSpecs/Subclass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HIMMSpecs::Subclass -**Inherits:** HIMMSpecs - - - - - -#Instance Methods -## instance_sub_method() [](#method-i-instance_sub_method) - diff --git a/example/ruby/HMACConstants.md b/example/ruby/HMACConstants.md deleted file mode 100644 index 0735795..0000000 --- a/example/ruby/HMACConstants.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: HMACConstants - - - - - diff --git a/example/ruby/HMMSpecs.md b/example/ruby/HMMSpecs.md deleted file mode 100644 index 02500bf..0000000 --- a/example/ruby/HMMSpecs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HMMSpecs -**Inherits:** Object - - - - - -#Instance Methods -## instance_method() [](#method-i-instance_method) - diff --git a/example/ruby/HMMSpecs/Subclass.md b/example/ruby/HMMSpecs/Subclass.md deleted file mode 100644 index 421f6ab..0000000 --- a/example/ruby/HMMSpecs/Subclass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HMMSpecs::Subclass -**Inherits:** HMMSpecs - - - - - -#Instance Methods -## instance_sub_method() [](#method-i-instance_sub_method) - diff --git a/example/ruby/HPIMMSpecs.md b/example/ruby/HPIMMSpecs.md deleted file mode 100644 index 76b92e7..0000000 --- a/example/ruby/HPIMMSpecs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HPIMMSpecs -**Inherits:** Object - - - - - -#Instance Methods -## public_method() [](#method-i-public_method) - diff --git a/example/ruby/HPIMMSpecs/Subclass.md b/example/ruby/HPIMMSpecs/Subclass.md deleted file mode 100644 index 483e89d..0000000 --- a/example/ruby/HPIMMSpecs/Subclass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HPIMMSpecs::Subclass -**Inherits:** HPIMMSpecs - - - - - -#Instance Methods -## public_sub_method() [](#method-i-public_sub_method) - diff --git a/example/ruby/HPMMSpecs.md b/example/ruby/HPMMSpecs.md deleted file mode 100644 index 6512cf7..0000000 --- a/example/ruby/HPMMSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: HPMMSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/HSMMSpecs.md b/example/ruby/HSMMSpecs.md deleted file mode 100644 index 7f12634..0000000 --- a/example/ruby/HSMMSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: HSMMSpecs -**Inherits:** Object - - - - -# Class Methods -## singleton_method() [](#method-c-singleton_method) - diff --git a/example/ruby/HTTPHeaderTest.md b/example/ruby/HTTPHeaderTest.md deleted file mode 100644 index fe65f48..0000000 --- a/example/ruby/HTTPHeaderTest.md +++ /dev/null @@ -1,96 +0,0 @@ -# Class: HTTPHeaderTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_AREF() [](#method-i-test_AREF) - -## test_ASET() [](#method-i-test_ASET) - -## test_add_field() [](#method-i-test_add_field) - -## test_basic_auth() [](#method-i-test_basic_auth) - -## test_canonical_each() [](#method-i-test_canonical_each) - -## test_chunked?() [](#method-i-test_chunked?) - -**@return** [Boolean] - -## test_content_length() [](#method-i-test_content_length) - -## test_content_length=() [](#method-i-test_content_length=) - -## test_content_range() [](#method-i-test_content_range) - -## test_content_type() [](#method-i-test_content_type) - -## test_delete() [](#method-i-test_delete) - -## test_duplicated_variable_header() [](#method-i-test_duplicated_variable_header) - -## test_each() [](#method-i-test_each) - -## test_each_capitalized() [](#method-i-test_each_capitalized) - -## test_each_capitalized_name() [](#method-i-test_each_capitalized_name) - -## test_each_capitalized_with_symbol() [](#method-i-test_each_capitalized_with_symbol) - -## test_each_key() [](#method-i-test_each_key) - -## test_each_value() [](#method-i-test_each_value) - -## test_form_data=() [](#method-i-test_form_data=) - -## test_get_fields() [](#method-i-test_get_fields) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_with_broken_coderange() [](#method-i-test_initialize_with_broken_coderange) - -## test_initialize_with_symbol() [](#method-i-test_initialize_with_symbol) - -## test_key?() [](#method-i-test_key?) - -**@return** [Boolean] - -## test_main_type() [](#method-i-test_main_type) - -## test_nil_variable_header() [](#method-i-test_nil_variable_header) - -## test_proxy_basic_auth() [](#method-i-test_proxy_basic_auth) - -## test_range() [](#method-i-test_range) - -## test_range=() [](#method-i-test_range=) - -## test_range_length() [](#method-i-test_range_length) - -## test_set_content_type() [](#method-i-test_set_content_type) - -## test_set_form_data() [](#method-i-test_set_form_data) - -## test_size() [](#method-i-test_size) - -## test_sub_type() [](#method-i-test_sub_type) - -## test_to_hash() [](#method-i-test_to_hash) - -## test_type_params() [](#method-i-test_type_params) - -## try_chunked(bool, str) [](#method-i-try_chunked) - -## try_content_length(len, str) [](#method-i-try_content_length) - -## try_invalid_content_range(s) [](#method-i-try_invalid_content_range) - -## try_invalid_range(s) [](#method-i-try_invalid_range) - -## try_range(r, s) [](#method-i-try_range) - diff --git a/example/ruby/HTTPHeaderTest/C.md b/example/ruby/HTTPHeaderTest/C.md deleted file mode 100644 index 37f4c95..0000000 --- a/example/ruby/HTTPHeaderTest/C.md +++ /dev/null @@ -1,530 +0,0 @@ -# Class: HTTPHeaderTest::C -**Inherits:** Object - -**Includes:** Net::HTTPHeader - - - - -# Attributes -## body[RW] [](#attribute-i-body) -Returns the value of attribute body. - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Sets the value for the case-insensitive `key` to `val`, overwriting the -previous value if the field exists; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req['Accept'] # => "*/*" - req['Accept'] = 'text/html' - req['Accept'] # => "text/html" - -Note that some field values may be set via convenience methods; see -[Setters](rdoc-ref:Net::HTTPHeader@Setters). - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Net::HTTPHeader#canonical_each is an alias for -Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## initialize() [](#method-i-initialize) - -**@return** [C] a new instance of C - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Net::HTTPHeader#content_type= is an alias for -Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) (method -`params.map` will be called), and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[URI.encode_www_form](rdoc-ref:URI.encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - diff --git a/example/ruby/HTTPHeaderTest/D.md b/example/ruby/HTTPHeaderTest/D.md deleted file mode 100644 index e03db2b..0000000 --- a/example/ruby/HTTPHeaderTest/D.md +++ /dev/null @@ -1,522 +0,0 @@ -# Class: HTTPHeaderTest::D -**Inherits:** Object - -**Includes:** Net::HTTPHeader - - - - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Sets the value for the case-insensitive `key` to `val`, overwriting the -previous value if the field exists; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req['Accept'] # => "*/*" - req['Accept'] = 'text/html' - req['Accept'] # => "text/html" - -Note that some field values may be set via convenience methods; see -[Setters](rdoc-ref:Net::HTTPHeader@Setters). - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Net::HTTPHeader#canonical_each is an alias for -Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Net::HTTPHeader#content_type= is an alias for -Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) (method -`params.map` will be called), and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[URI.encode_www_form](rdoc-ref:URI.encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - diff --git a/example/ruby/HTTPRequestTest.md b/example/ruby/HTTPRequestTest.md deleted file mode 100644 index 1559cf9..0000000 --- a/example/ruby/HTTPRequestTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: HTTPRequestTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_header_set() [](#method-i-test_header_set) - -## test_initialize_GET() [](#method-i-test_initialize_GET) - -## test_initialize_GET_range() [](#method-i-test_initialize_GET_range) - -## test_initialize_GET_uri() [](#method-i-test_initialize_GET_uri) - -## test_initialize_HEAD() [](#method-i-test_initialize_HEAD) - -## test_initialize_accept_encoding() [](#method-i-test_initialize_accept_encoding) - diff --git a/example/ruby/HTTPResponseTest.md b/example/ruby/HTTPResponseTest.md deleted file mode 100644 index 9597945..0000000 --- a/example/ruby/HTTPResponseTest.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: HTTPResponseTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_allow_empty_reason_code() [](#method-i-test_allow_empty_reason_code) - -## test_allow_trailing_space_after_status() [](#method-i-test_allow_trailing_space_after_status) - -## test_ensure_zero_space_does_not_regress() [](#method-i-test_ensure_zero_space_does_not_regress) - -## test_inspect_response() [](#method-i-test_inspect_response) - -## test_multiline_header() [](#method-i-test_multiline_header) - -## test_normal_status_line() [](#method-i-test_normal_status_line) - -## test_raises_exception_with_missing_reason() [](#method-i-test_raises_exception_with_missing_reason) - -## test_read_body() [](#method-i-test_read_body) - -## test_read_body_block() [](#method-i-test_read_body_block) - -## test_read_body_block_mod() [](#method-i-test_read_body_block_mod) - -## test_read_body_body_encoding_encoding() [](#method-i-test_read_body_body_encoding_encoding) - -## test_read_body_body_encoding_false() [](#method-i-test_read_body_body_encoding_false) - -## test_read_body_body_encoding_string() [](#method-i-test_read_body_body_encoding_string) - -## test_read_body_body_encoding_true_with_iso8859_1_meta_charset() [](#method-i-test_read_body_body_encoding_true_with_iso8859_1_meta_charset) - -## test_read_body_body_encoding_true_with_iso8859_1_meta_content_charset() [](#method-i-test_read_body_body_encoding_true_with_iso8859_1_meta_content_charset) - -## test_read_body_body_encoding_true_with_iso_8859_1_content_type_header() [](#method-i-test_read_body_body_encoding_true_with_iso_8859_1_content_type_header) - -## test_read_body_body_encoding_true_with_utf8_content_type_header() [](#method-i-test_read_body_body_encoding_true_with_utf8_content_type_header) - -## test_read_body_body_encoding_true_with_utf8_meta_charset() [](#method-i-test_read_body_body_encoding_true_with_utf8_meta_charset) - -## test_read_body_body_encoding_true_with_utf8_meta_content_charset() [](#method-i-test_read_body_body_encoding_true_with_utf8_meta_content_charset) - -## test_read_body_body_encoding_true_without_content_type_header() [](#method-i-test_read_body_body_encoding_true_without_content_type_header) - -## test_read_body_content_encoding_deflate() [](#method-i-test_read_body_content_encoding_deflate) - -## test_read_body_content_encoding_deflate_chunked() [](#method-i-test_read_body_content_encoding_deflate_chunked) - -## test_read_body_content_encoding_deflate_content_range() [](#method-i-test_read_body_content_encoding_deflate_content_range) - -## test_read_body_content_encoding_deflate_disabled() [](#method-i-test_read_body_content_encoding_deflate_disabled) - -## test_read_body_content_encoding_deflate_empty_body() [](#method-i-test_read_body_content_encoding_deflate_empty_body) - -## test_read_body_content_encoding_deflate_empty_body_no_length() [](#method-i-test_read_body_content_encoding_deflate_empty_body_no_length) - -## test_read_body_content_encoding_deflate_no_length() [](#method-i-test_read_body_content_encoding_deflate_no_length) - -## test_read_body_content_encoding_deflate_uppercase() [](#method-i-test_read_body_content_encoding_deflate_uppercase) - -## test_read_body_outside_of_reading_body() [](#method-i-test_read_body_outside_of_reading_body) - -## test_read_body_receiving_no_body() [](#method-i-test_read_body_receiving_no_body) - -## test_read_body_string() [](#method-i-test_read_body_string) - -## test_read_code_type() [](#method-i-test_read_code_type) - -## test_singleline_header() [](#method-i-test_singleline_header) - -## test_uri_equals() [](#method-i-test_uri_equals) - diff --git a/example/ruby/HTTPResponsesTest.md b/example/ruby/HTTPResponsesTest.md deleted file mode 100644 index 0dd9121..0000000 --- a/example/ruby/HTTPResponsesTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HTTPResponsesTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_status_code_classes() [](#method-i-test_status_code_classes) - diff --git a/example/ruby/HTTPSProxyTest.md b/example/ruby/HTTPSProxyTest.md deleted file mode 100644 index 309c355..0000000 --- a/example/ruby/HTTPSProxyTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: HTTPSProxyTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## read_fixture(key) [](#method-i-read_fixture) - -## test_https_proxy_authentication() [](#method-i-test_https_proxy_authentication) - -## test_https_proxy_ssl_connection() [](#method-i-test_https_proxy_ssl_connection) - diff --git a/example/ruby/Hash.md b/example/ruby/Hash.md deleted file mode 100644 index d5861dd..0000000 --- a/example/ruby/Hash.md +++ /dev/null @@ -1,3122 +0,0 @@ -# Class: Hash -**Inherits:** Object - -**Includes:** Enumerable - - -:nodoc: - - -# Class Methods -## [](*args ) [](#method-c-[]) -Returns a new `Hash` object populated with the given objects, if any. See -Hash::new. - -With no argument, returns a new empty `Hash`. - -When the single given argument is a `Hash`, returns a new `Hash` populated -with the entries from the given `Hash`, excluding the default value or proc. - - h = {foo: 0, bar: 1, baz: 2} - Hash[h] # => {:foo=>0, :bar=>1, :baz=>2} - -When the single given argument is an Array of 2-element Arrays, returns a new -`Hash` object wherein each 2-element array forms a key-value entry: - - Hash[ [ [:foo, 0], [:bar, 1] ] ] # => {:foo=>0, :bar=>1} - -When the argument count is an even number; returns a new `Hash` object wherein -each successive pair of arguments has become a key-value entry: - - Hash[:foo, 0, :bar, 1] # => {:foo=>0, :bar=>1} - -Raises an exception if the argument list does not conform to any of the above. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## ruby2_keywords_hash(hash ) [](#method-c-ruby2_keywords_hash) -Duplicates a given hash and adds a ruby2_keywords flag. This method is not for -casual use; debugging, researching, and some truly necessary cases like -deserialization of arguments. - - h = {k: 1} - h = Hash.ruby2_keywords_hash(h) - def foo(k: 42) - k - end - foo(*[h]) #=> 1 with neither a warning or an error -**@overload** [] - -## ruby2_keywords_hash?(hash ) [](#method-c-ruby2_keywords_hash?) -Checks if a given hash is flagged by Module#ruby2_keywords (or -Proc#ruby2_keywords). This method is not for casual use; debugging, -researching, and some truly necessary cases like serialization of arguments. - - ruby2_keywords def foo(*args) - Hash.ruby2_keywords_hash?(args.last) - end - foo(k: 1) #=> true - foo({k: 1}) #=> false -**@overload** [] - -## try_convert(hash ) [](#method-c-try_convert) -If `obj` is a `Hash` object, returns `obj`. - -Otherwise if `obj` responds to `:to_hash`, calls `obj.to_hash` and returns the -result. - -Returns `nil` if `obj` does not respond to `:to_hash` - -Raises an exception unless `obj.to_hash` returns a `Hash` object. -**@overload** [] - - -#Instance Methods -## <(other) [](#method-i-<) -Returns `true` if `hash` is a proper subset of `other_hash`, `false` -otherwise: - h1 = {foo: 0, bar: 1} - h2 = {foo: 0, bar: 1, baz: 2} - h1 < h2 # => true - h2 < h1 # => false - h1 < h1 # => false - -**@overload** [] - -## <=(other) [](#method-i-<=) -Returns `true` if `hash` is a subset of `other_hash`, `false` otherwise: - h1 = {foo: 0, bar: 1} - h2 = {foo: 0, bar: 1, baz: 2} - h1 <= h2 # => true - h2 <= h1 # => false - h1 <= h1 # => true - -**@overload** [] - -## ==(hash2) [](#method-i-==) -Returns `true` if all of the following are true: -* `object` is a `Hash` object. -* `hash` and `object` have the same keys (regardless of order). -* For each key `key`, `hash[key] == object[key]`. - -Otherwise, returns `false`. - -Equal: - h1 = {foo: 0, bar: 1, baz: 2} - h2 = {foo: 0, bar: 1, baz: 2} - h1 == h2 # => true - h3 = {baz: 2, bar: 1, foo: 0} - h1 == h3 # => true - -**@overload** [] - -## >(other) [](#method-i->) -Returns `true` if `hash` is a proper superset of `other_hash`, `false` -otherwise: - h1 = {foo: 0, bar: 1, baz: 2} - h2 = {foo: 0, bar: 1} - h1 > h2 # => true - h2 > h1 # => false - h1 > h1 # => false - -**@overload** [] - -## >=(other) [](#method-i->=) -Returns `true` if `hash` is a superset of `other_hash`, `false` otherwise: - h1 = {foo: 0, bar: 1, baz: 2} - h2 = {foo: 0, bar: 1} - h1 >= h2 # => true - h2 >= h1 # => false - h1 >= h1 # => true - -**@overload** [] - -## [](key) [](#method-i-[]) -Returns the value associated with the given `key`, if found: - h = {foo: 0, bar: 1, baz: 2} - h[:foo] # => 0 - -If `key` is not found, returns a default value (see [Default -Values](rdoc-ref:Hash@Default+Values)): - h = {foo: 0, bar: 1, baz: 2} - h[:nosuch] # => nil - -**@overload** [] - -## []=() [](#method-i-[]=) - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns `true` if any element satisfies a given criterion; `false` otherwise. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns `true` if `self` is non-empty; `false` -if empty. - -With argument `object` and no block, returns `true` if for any key `key` -`h.assoc(key) == object`: - h = {foo: 0, bar: 1, baz: 2} - h.any?([:bar, 1]) # => true - h.any?([:bar, 0]) # => false - h.any?([:baz, 1]) # => false - -With no argument and a block, calls the block with each key-value pair; -returns `true` if the block returns any truthy value, `false` otherwise: - h = {foo: 0, bar: 1, baz: 2} - h.any? {|key, value| value < 3 } # => true - h.any? {|key, value| value > 3 } # => false - -Related: Enumerable#any? - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## assoc(key) [](#method-i-assoc) -If the given `key` is found, returns a 2-element Array containing that key and -its value: - h = {foo: 0, bar: 1, baz: 2} - h.assoc(:bar) # => [:bar, 1] - -Returns `nil` if key `key` is not found. - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## clear() [](#method-i-clear) -Removes all hash entries; returns `self`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns a copy of `self` with all `nil`-valued entries removed: - h = {foo: 0, bar: nil, baz: 2, bat: nil} - h1 = h.compact - h1 # => {:foo=>0, :baz=>2} - -**@overload** [] - -## compact!() [](#method-i-compact!) -Returns `self` with all its `nil`-valued entries removed (in place): - h = {foo: 0, bar: nil, baz: 2, bat: nil} - h.compact! # => {:foo=>0, :baz=>2} - -Returns `nil` if no entries were removed. - -**@overload** [] - -## compare_by_identity() [](#method-i-compare_by_identity) -Sets `self` to consider only identity in comparing keys; two keys are -considered the same only if they are the same object; returns `self`. - -By default, these two object are considered to be the same key, so `s1` will -overwrite `s0`: - s0 = 'x' - s1 = 'x' - h = {} - h.compare_by_identity? # => false - h[s0] = 0 - h[s1] = 1 - h # => {"x"=>1} - -After calling #compare_by_identity, the keys are considered to be different, -and therefore do not overwrite each other: - h = {} - h.compare_by_identity # => {} - h.compare_by_identity? # => true - h[s0] = 0 - h[s1] = 1 - h # => {"x"=>0, "x"=>1} - -**@overload** [] - -## compare_by_identity?() [](#method-i-compare_by_identity?) -Returns `true` if #compare_by_identity has been called, `false` otherwise. - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -:nodoc: - -## default(*args) [](#method-i-default) -Returns the default value for the given `key`. The returned value will be -determined either by the default proc or by the default value. See [Default -Values](rdoc-ref:Hash@Default+Values). - -With no argument, returns the current default value: - h = {} - h.default # => nil - -If `key` is given, returns the default value for `key`, regardless of whether -that key exists: - h = Hash.new { |hash, key| hash[key] = "No key #{key}"} - h[:foo] = "Hello" - h.default(:foo) # => "No key foo" - -**@overload** [] - -**@overload** [] - -## default=(ifnone) [](#method-i-default=) -Sets the default value to `value`; returns `value`: - h = {} - h.default # => nil - h.default = false # => false - h.default # => false - -See [Default Values](rdoc-ref:Hash@Default+Values). - -**@overload** [] - -## default_proc() [](#method-i-default_proc) -Returns the default proc for `self` (see [Default -Values](rdoc-ref:Hash@Default+Values)): - h = {} - h.default_proc # => nil - h.default_proc = proc {|hash, key| "Default value for #{key}" } - h.default_proc.class # => Proc - -**@overload** [] - -## default_proc=(proc) [](#method-i-default_proc=) -Sets the default proc for `self` to `proc` (see [Default -Values](rdoc-ref:Hash@Default+Values)): - h = {} - h.default_proc # => nil - h.default_proc = proc { |hash, key| "Default value for #{key}" } - h.default_proc.class # => Proc - h.default_proc = nil - h.default_proc # => nil - -**@overload** [] - -## delete(key) [](#method-i-delete) -Deletes the entry for the given `key` and returns its associated value. - -If no block is given and `key` is found, deletes the entry and returns the -associated value: - h = {foo: 0, bar: 1, baz: 2} - h.delete(:bar) # => 1 - h # => {:foo=>0, :baz=>2} - -If no block given and `key` is not found, returns `nil`. - -If a block is given and `key` is found, ignores the block, deletes the entry, -and returns the associated value: - h = {foo: 0, bar: 1, baz: 2} - h.delete(:baz) { |key| raise 'Will never happen'} # => 2 - h # => {:foo=>0, :bar=>1} - -If a block is given and `key` is not found, calls the block and returns the -block's return value: - h = {foo: 0, bar: 1, baz: 2} - h.delete(:nosuch) { |key| "Key #{key} not found" } # => "Key nosuch not found" - h # => {:foo=>0, :bar=>1, :baz=>2} - -**@overload** [] - -**@overload** [] - -## delete_if() [](#method-i-delete_if) -If a block given, calls the block with each key-value pair; deletes each entry -for which the block returns a truthy value; returns `self`: - h = {foo: 0, bar: 1, baz: 2} - h.delete_if {|key, value| value > 0 } # => {:foo=>0} - -If no block given, returns a new Enumerator: - h = {foo: 0, bar: 1, baz: 2} - e = h.delete_if # => #0, :bar=>1, :baz=>2}:delete_if> - e.each { |key, value| value > 0 } # => {:foo=>0} - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## dig(*args) [](#method-i-dig) -Finds and returns the object in nested objects that is specified by `key` and -`identifiers`. The nested objects may be instances of various classes. See -[Dig Methods](rdoc-ref:dig_methods.rdoc). - -Nested Hashes: - h = {foo: {bar: {baz: 2}}} - h.dig(:foo) # => {:bar=>{:baz=>2}} - h.dig(:foo, :bar) # => {:baz=>2} - h.dig(:foo, :bar, :baz) # => 2 - h.dig(:foo, :bar, :BAZ) # => nil - -Nested Hashes and Arrays: - h = {foo: {bar: [:a, :b, :c]}} - h.dig(:foo, :bar, 2) # => :c - -This method will use the [default values](rdoc-ref:Hash@Default+Values) for -keys that are not present: - h = {foo: {bar: [:a, :b, :c]}} - h.dig(:hello) # => nil - h.default_proc = -> (hash, _key) { hash } - h.dig(:hello, :world) # => h - h.dig(:hello, :world, :foo, :bar, 2) # => :c - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Calls the given block with each key-value pair; returns `self`: - h = {foo: 0, bar: 1, baz: 2} - h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2} - -Output: - foo: 0 - bar: 1 - baz: 2 - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.each_pair # => #0, :bar=>1, :baz=>2}:each_pair> - h1 = e.each {|key, value| puts "#{key}: #{value}"} - h1 # => {:foo=>0, :bar=>1, :baz=>2} - -Output: - foo: 0 - bar: 1 - baz: 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_key() [](#method-i-each_key) -Calls the given block with each key; returns `self`: - h = {foo: 0, bar: 1, baz: 2} - h.each_key {|key| puts key } # => {:foo=>0, :bar=>1, :baz=>2} - -Output: - foo - bar - baz - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.each_key # => #0, :bar=>1, :baz=>2}:each_key> - h1 = e.each {|key| puts key } - h1 # => {:foo=>0, :bar=>1, :baz=>2} - -Output: - foo - bar - baz - -**@overload** [] - -**@overload** [] - -## each_pair() [](#method-i-each_pair) -Calls the given block with each key-value pair; returns `self`: - h = {foo: 0, bar: 1, baz: 2} - h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2} - -Output: - foo: 0 - bar: 1 - baz: 2 - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.each_pair # => #0, :bar=>1, :baz=>2}:each_pair> - h1 = e.each {|key, value| puts "#{key}: #{value}"} - h1 # => {:foo=>0, :bar=>1, :baz=>2} - -Output: - foo: 0 - bar: 1 - baz: 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_value() [](#method-i-each_value) -Calls the given block with each value; returns `self`: - h = {foo: 0, bar: 1, baz: 2} - h.each_value {|value| puts value } # => {:foo=>0, :bar=>1, :baz=>2} - -Output: - 0 - 1 - 2 - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.each_value # => #0, :bar=>1, :baz=>2}:each_value> - h1 = e.each {|value| puts value } - h1 # => {:foo=>0, :bar=>1, :baz=>2} - -Output: - 0 - 1 - 2 - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Returns `true` if there are no hash entries, `false` otherwise: - {}.empty? # => true - {foo: 0, bar: 1, baz: 2}.empty? # => false - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eql?(hash2) [](#method-i-eql?) -Returns `true` if all of the following are true: -* `object` is a `Hash` object. -* `hash` and `object` have the same keys (regardless of order). -* For each key `key`, `h[key].eql?(object[key])`. - -Otherwise, returns `false`. - - h1 = {foo: 0, bar: 1, baz: 2} - h2 = {foo: 0, bar: 1, baz: 2} - h1.eql? h2 # => true - h3 = {baz: 2, bar: 1, foo: 0} - h1.eql? h3 # => true - -**@overload** [] - -## except(*args) [](#method-i-except) -Returns a new `Hash` excluding entries for the given `keys`: - h = { a: 100, b: 200, c: 300 } - h.except(:a) #=> {:b=>200, :c=>300} - -Any given `keys` that are not found are ignored. - -**@overload** [] - -## fetch(*args) [](#method-i-fetch) -Returns the value for the given `key`, if found. - h = {foo: 0, bar: 1, baz: 2} - h.fetch(:bar) # => 1 - -If `key` is not found and no block was given, returns `default_value`: - {}.fetch(:nosuch, :default) # => :default - -If `key` is not found and a block was given, yields `key` to the block and -returns the block's return value: - {}.fetch(:nosuch) {|key| "No key #{key}"} # => "No key nosuch" - -Raises KeyError if neither `default_value` nor a block was given. - -Note that this method does not use the values of either #default or -#default_proc. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## fetch_values(*args) [](#method-i-fetch_values) -Returns a new Array containing the values associated with the given keys -*keys: - h = {foo: 0, bar: 1, baz: 2} - h.fetch_values(:baz, :foo) # => [2, 0] - -Returns a new empty Array if no arguments given. - -When a block is given, calls the block with each missing key, treating the -block's return value as the value for that key: - h = {foo: 0, bar: 1, baz: 2} - values = h.fetch_values(:bar, :foo, :bad, :bam) {|key| key.to_s} - values # => [1, 0, "bad", "bam"] - -When no block is given, raises an exception if any given key is not found. - -**@overload** [] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns a new `Hash` object whose entries are those for which the block -returns a truthy value: - h = {foo: 0, bar: 1, baz: 2} - h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1} - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.select # => #0, :bar=>1, :baz=>2}:select> - e.each {|key, value| value < 2 } # => {:foo=>0, :bar=>1} - -**@overload** [] - -**@overload** [] - -## filter!() [](#method-i-filter!) -Returns `self`, whose entries are those for which the block returns a truthy -value: - h = {foo: 0, bar: 1, baz: 2} - h.select! {|key, value| value < 2 } => {:foo=>0, :bar=>1} - -Returns `nil` if no entries were removed. - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.select! # => #0, :bar=>1, :baz=>2}:select!> - e.each { |key, value| value < 2 } # => {:foo=>0, :bar=>1} - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flatten(*args) [](#method-i-flatten) -Returns a new Array object that is a 1-dimensional flattening of `self`. - ---- - -By default, nested Arrays are not flattened: - h = {foo: 0, bar: [:bat, 3], baz: 2} - h.flatten # => [:foo, 0, :bar, [:bat, 3], :baz, 2] - -Takes the depth of recursive flattening from Integer argument `level`: - h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]} - h.flatten(1) # => [:foo, 0, :bar, [:bat, [:baz, [:bat]]]] - h.flatten(2) # => [:foo, 0, :bar, :bat, [:baz, [:bat]]] - h.flatten(3) # => [:foo, 0, :bar, :bat, :baz, [:bat]] - h.flatten(4) # => [:foo, 0, :bar, :bat, :baz, :bat] - -When `level` is negative, flattens all nested Arrays: - h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]} - h.flatten(-1) # => [:foo, 0, :bar, :bat, :baz, :bat] - h.flatten(-2) # => [:foo, 0, :bar, :bat, :baz, :bat] - -When `level` is zero, returns the equivalent of #to_a : - h = {foo: 0, bar: [:bat, 3], baz: 2} - h.flatten(0) # => [[:foo, 0], [:bar, [:bat, 3]], [:baz, 2]] - h.flatten(0) == h.to_a # => true - -**@overload** [] - -**@overload** [] - -## freeze() [](#method-i-freeze) -:nodoc: - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## has_key?(key) [](#method-i-has_key?) -Returns `true` if `key` is a key in `self`, otherwise `false`. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## has_value?(val) [](#method-i-has_value?) -Returns `true` if `value` is a value in `self`, otherwise `false`. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -Returns the Integer hash-code for the hash. - -Two `Hash` objects have the same hash-code if their content is the same -(regardless of order): - h1 = {foo: 0, bar: 1, baz: 2} - h2 = {baz: 2, bar: 1, foo: 0} - h2.hash == h1.hash # => true - h2.eql? h1 # => true - -**@overload** [] - -## include?(key) [](#method-i-include?) -Returns `true` if `key` is a key in `self`, otherwise `false`. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize(ifnone(ifnone_unset = true), capacity:0, &block) [](#method-i-initialize) -call-seq: - Hash.new(default_value = nil) -> new_hash - Hash.new(default_value = nil, capacity: size) -> new_hash - Hash.new {|hash, key| ... } -> new_hash - Hash.new(capacity: size) {|hash, key| ... } -> new_hash - -Returns a new empty `Hash` object. - -The initial default value and initial default proc for the new hash depend on -which form above was used. See [Default Values](rdoc-ref:Hash@Default+Values). - -If neither an argument nor a block is given, initializes both the default -value and the default proc to `nil`: - h = Hash.new - h.default # => nil - h.default_proc # => nil - -If argument `default_value` is given but no block is given, initializes the -default value to the given `default_value` and the default proc to `nil`: - h = Hash.new(false) - h.default # => false - h.default_proc # => nil - -If a block is given but no `default_value`, stores the block as the default -proc and sets the default value to `nil`: - h = Hash.new {|hash, key| "Default value for #{key}" } - h.default # => nil - h.default_proc.class # => Proc - h[:nosuch] # => "Default value for nosuch" - -If both a block and a `default_value` are given, raises an `ArgumentError` - -If the optional keyword argument `capacity` is given, the hash will be -allocated with enough capacity to accommodate this many keys without having to -be resized. - -**@return** [Hash] a new instance of Hash - -## initialize_copy(hash2) [](#method-i-initialize_copy) -Replaces the entire contents of `self` with the contents of `other_hash`; -returns `self`: - h = {foo: 0, bar: 1, baz: 2} - h.replace({bat: 3, bam: 4}) # => {:bat=>3, :bam=>4} - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a new String containing the hash entries: - - h = {foo: 0, bar: 1, baz: 2} - h.inspect # => "{foo: 0, bar: 1, baz: 2}" - -**@overload** [] - -## invert() [](#method-i-invert) -Returns a new `Hash` object with the each key-value pair inverted: - h = {foo: 0, bar: 1, baz: 2} - h1 = h.invert - h1 # => {0=>:foo, 1=>:bar, 2=>:baz} - -Overwrites any repeated new keys: (see [Entry -Order](rdoc-ref:Hash@Entry+Order)): - h = {foo: 0, bar: 0, baz: 0} - h.invert # => {0=>:baz} - -**@overload** [] - -## keep_if() [](#method-i-keep_if) -Calls the block for each key-value pair; retains the entry if the block -returns a truthy value; otherwise deletes the entry; returns `self`. - h = {foo: 0, bar: 1, baz: 2} - h.keep_if { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2} - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.keep_if # => #0, :bar=>1, :baz=>2}:keep_if> - e.each { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2} - -**@overload** [] - -**@overload** [] - -## key(value) [](#method-i-key) -Returns the key for the first-found entry with the given `value` (see [Entry -Order](rdoc-ref:Hash@Entry+Order)): - h = {foo: 0, bar: 2, baz: 2} - h.key(0) # => :foo - h.key(2) # => :bar - -Returns `nil` if no such value is found. - -**@overload** [] - -## key?(key) [](#method-i-key?) -Returns `true` if `key` is a key in `self`, otherwise `false`. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## keys() [](#method-i-keys) -Returns a new Array containing all keys in `self`: - h = {foo: 0, bar: 1, baz: 2} - h.keys # => [:foo, :bar, :baz] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## length() [](#method-i-length) -Returns the count of entries in `self`: - - {foo: 0, bar: 1, baz: 2}.length # => 3 - -**@overload** [] - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(key) [](#method-i-member?) -Returns `true` if `key` is a key in `self`, otherwise `false`. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## merge(*args) [](#method-i-merge) -Returns the new `Hash` formed by merging each of `other_hashes` into a copy of -`self`. - -Each argument in `other_hashes` must be a `Hash`. - ---- - -With arguments and no block: -* Returns the new `Hash` object formed by merging each successive `Hash` in - `other_hashes` into `self`. -* Each new-key entry is added at the end. -* Each duplicate-key entry's value overwrites the previous value. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h1 = {bat: 3, bar: 4} - h2 = {bam: 5, bat:6} - h.merge(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} - -With arguments and a block: -* Returns a new `Hash` object that is the merge of `self` and each given - hash. -* The given hashes are merged left to right. -* Each new-key entry is added at the end. -* For each duplicate key: - * Calls the block with the key and the old and new values. - * The block's return value becomes the new value for the entry. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h1 = {bat: 3, bar: 4} - h2 = {bam: 5, bat:6} - h3 = h.merge(h1, h2) { |key, old_value, new_value| old_value + new_value } - h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} - -With no arguments: -* Returns a copy of `self`. -* The block, if given, is ignored. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h.merge # => {:foo=>0, :bar=>1, :baz=>2} - h1 = h.merge { |key, old_value, new_value| raise 'Cannot happen' } - h1 # => {:foo=>0, :bar=>1, :baz=>2} - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## merge!(*args) [](#method-i-merge!) -Merges each of `other_hashes` into `self`; returns `self`. - -Each argument in `other_hashes` must be a `Hash`. - -With arguments and no block: -* Returns `self`, after the given hashes are merged into it. -* The given hashes are merged left to right. -* Each new entry is added at the end. -* Each duplicate-key entry's value overwrites the previous value. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h1 = {bat: 3, bar: 4} - h2 = {bam: 5, bat:6} - h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} - -With arguments and a block: -* Returns `self`, after the given hashes are merged. -* The given hashes are merged left to right. -* Each new-key entry is added at the end. -* For each duplicate key: - * Calls the block with the key and the old and new values. - * The block's return value becomes the new value for the entry. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h1 = {bat: 3, bar: 4} - h2 = {bam: 5, bat:6} - h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } - h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} - -With no arguments: -* Returns `self`, unmodified. -* The block, if given, is ignored. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h.merge # => {:foo=>0, :bar=>1, :baz=>2} - h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } - h1 # => {:foo=>0, :bar=>1, :baz=>2} - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## pretty_print_cycle(q) [](#method-i-pretty_print_cycle) -:nodoc: - -## rassoc(obj) [](#method-i-rassoc) -Returns a new 2-element Array consisting of the key and value of the -first-found entry whose value is `==` to value (see [Entry -Order](rdoc-ref:Hash@Entry+Order)): - h = {foo: 0, bar: 1, baz: 1} - h.rassoc(1) # => [:bar, 1] - -Returns `nil` if no such value found. - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## rehash() [](#method-i-rehash) -Rebuilds the hash table by recomputing the hash index for each key; returns -`self`. - -The hash table becomes invalid if the hash value of a key has changed after -the entry was created. See [Modifying an Active Hash -Key](rdoc-ref:Hash@Modifying+an+Active+Hash+Key). - -**@overload** [] - -## reject() [](#method-i-reject) -Returns a new `Hash` object whose entries are all those from `self` for which -the block returns `false` or `nil`: - h = {foo: 0, bar: 1, baz: 2} - h1 = h.reject {|key, value| key.start_with?('b') } - h1 # => {:foo=>0} - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.reject # => #0, :bar=>1, :baz=>2}:reject> - h1 = e.each {|key, value| key.start_with?('b') } - h1 # => {:foo=>0} - -**@overload** [] - -**@overload** [] - -## reject!() [](#method-i-reject!) -Returns `self`, whose remaining entries are those for which the block returns -`false` or `nil`: - h = {foo: 0, bar: 1, baz: 2} - h.reject! {|key, value| value < 2 } # => {:baz=>2} - -Returns `nil` if no entries are removed. - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.reject! # => #0, :bar=>1, :baz=>2}:reject!> - e.each {|key, value| key.start_with?('b') } # => {:foo=>0} - -**@overload** [] - -**@overload** [] - -## replace(hash2) [](#method-i-replace) -Replaces the entire contents of `self` with the contents of `other_hash`; -returns `self`: - h = {foo: 0, bar: 1, baz: 2} - h.replace({bat: 3, bam: 4}) # => {:bat=>3, :bam=>4} - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns a new `Hash` object whose entries are those for which the block -returns a truthy value: - h = {foo: 0, bar: 1, baz: 2} - h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1} - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.select # => #0, :bar=>1, :baz=>2}:select> - e.each {|key, value| value < 2 } # => {:foo=>0, :bar=>1} - -**@overload** [] - -**@overload** [] - -## select!() [](#method-i-select!) -Returns `self`, whose entries are those for which the block returns a truthy -value: - h = {foo: 0, bar: 1, baz: 2} - h.select! {|key, value| value < 2 } => {:foo=>0, :bar=>1} - -Returns `nil` if no entries were removed. - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.select! # => #0, :bar=>1, :baz=>2}:select!> - e.each { |key, value| value < 2 } # => {:foo=>0, :bar=>1} - -**@overload** [] - -**@overload** [] - -## shift() [](#method-i-shift) -Removes the first hash entry (see [Entry Order](rdoc-ref:Hash@Entry+Order)); -returns a 2-element Array containing the removed key and value: - h = {foo: 0, bar: 1, baz: 2} - h.shift # => [:foo, 0] - h # => {:bar=>1, :baz=>2} - -Returns nil if the hash is empty. - -**@overload** [] - -## size() [](#method-i-size) -Returns the count of entries in `self`: - - {foo: 0, bar: 1, baz: 2}.length # => 3 - -**@overload** [] - -**@overload** [] - -## slice(*args) [](#method-i-slice) -Returns a new `Hash` object containing the entries for the given `keys`: - h = {foo: 0, bar: 1, baz: 2} - h.slice(:baz, :foo) # => {:baz=>2, :foo=>0} - -Any given `keys` that are not found are ignored. - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## store() [](#method-i-store) - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) -Returns a new Array of 2-element Array objects; each nested Array contains a -key-value pair from `self`: - h = {foo: 0, bar: 1, baz: 2} - h.to_a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - -**@overload** [] - -## to_h() [](#method-i-to_h) -For an instance of `Hash`, returns `self`. - -For a subclass of `Hash`, returns a new `Hash` containing the content of -`self`. - -When a block is given, returns a new `Hash` object whose content is based on -the block; the block should return a 2-element Array object specifying the -key-value pair to be included in the returned Array: - h = {foo: 0, bar: 1, baz: 2} - h1 = h.to_h {|key, value| [value, key] } - h1 # => {0=>:foo, 1=>:bar, 2=>:baz} - -**@overload** [] - -**@overload** [] - -## to_hash() [](#method-i-to_hash) -Returns `self`. - -**@overload** [] - -## to_proc() [](#method-i-to_proc) -Returns a Proc object that maps a key to its value: - h = {foo: 0, bar: 1, baz: 2} - proc = h.to_proc - proc.class # => Proc - proc.call(:foo) # => 0 - proc.call(:bar) # => 1 - proc.call(:nosuch) # => nil - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## transform_keys(*args) [](#method-i-transform_keys) -Returns a new `Hash` object; each entry has: -* A key provided by the block. -* The value from `self`. - -An optional hash argument can be provided to map keys to new keys. Any key not -given will be mapped using the provided block, or remain the same if no block -is given. - -Transform keys: - h = {foo: 0, bar: 1, baz: 2} - h1 = h.transform_keys {|key| key.to_s } - h1 # => {"foo"=>0, "bar"=>1, "baz"=>2} - - h.transform_keys(foo: :bar, bar: :foo) - #=> {bar: 0, foo: 1, baz: 2} - - h.transform_keys(foo: :hello, &:to_s) - #=> {:hello=>0, "bar"=>1, "baz"=>2} - -Overwrites values for duplicate keys: - h = {foo: 0, bar: 1, baz: 2} - h1 = h.transform_keys {|key| :bat } - h1 # => {:bat=>2} - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.transform_keys # => #0, :bar=>1, :baz=>2}:transform_keys> - h1 = e.each { |key| key.to_s } - h1 # => {"foo"=>0, "bar"=>1, "baz"=>2} - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## transform_keys!(*args) [](#method-i-transform_keys!) -Same as Hash#transform_keys but modifies the receiver in place instead of -returning a new hash. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## transform_values() [](#method-i-transform_values) -Returns a new `Hash` object; each entry has: -* A key from `self`. -* A value provided by the block. - -Transform values: - h = {foo: 0, bar: 1, baz: 2} - h1 = h.transform_values {|value| value * 100} - h1 # => {:foo=>0, :bar=>100, :baz=>200} - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.transform_values # => #0, :bar=>1, :baz=>2}:transform_values> - h1 = e.each { |value| value * 100} - h1 # => {:foo=>0, :bar=>100, :baz=>200} - -**@overload** [] - -**@overload** [] - -## transform_values!() [](#method-i-transform_values!) -Returns `self`, whose keys are unchanged, and whose values are determined by -the given block. - h = {foo: 0, bar: 1, baz: 2} - h.transform_values! {|value| value * 100} # => {:foo=>0, :bar=>100, :baz=>200} - -Returns a new Enumerator if no block given: - h = {foo: 0, bar: 1, baz: 2} - e = h.transform_values! # => #0, :bar=>100, :baz=>200}:transform_values!> - h1 = e.each {|value| value * 100} - h1 # => {:foo=>0, :bar=>100, :baz=>200} - -**@overload** [] - -**@overload** [] - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## update(*args) [](#method-i-update) -Merges each of `other_hashes` into `self`; returns `self`. - -Each argument in `other_hashes` must be a `Hash`. - -With arguments and no block: -* Returns `self`, after the given hashes are merged into it. -* The given hashes are merged left to right. -* Each new entry is added at the end. -* Each duplicate-key entry's value overwrites the previous value. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h1 = {bat: 3, bar: 4} - h2 = {bam: 5, bat:6} - h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} - -With arguments and a block: -* Returns `self`, after the given hashes are merged. -* The given hashes are merged left to right. -* Each new-key entry is added at the end. -* For each duplicate key: - * Calls the block with the key and the old and new values. - * The block's return value becomes the new value for the entry. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h1 = {bat: 3, bar: 4} - h2 = {bam: 5, bat:6} - h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } - h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} - -With no arguments: -* Returns `self`, unmodified. -* The block, if given, is ignored. - -Example: - h = {foo: 0, bar: 1, baz: 2} - h.merge # => {:foo=>0, :bar=>1, :baz=>2} - h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } - h1 # => {:foo=>0, :bar=>1, :baz=>2} - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## value?(val) [](#method-i-value?) -Returns `true` if `value` is a value in `self`, otherwise `false`. - -**@overload** [] - -**@overload** [] - -## values() [](#method-i-values) -Returns a new Array containing all values in `self`: - h = {foo: 0, bar: 1, baz: 2} - h.values # => [0, 1, 2] - -**@overload** [] - -## values_at(*args) [](#method-i-values_at) -Returns a new Array containing values for the given `keys`: - h = {foo: 0, bar: 1, baz: 2} - h.values_at(:baz, :foo) # => [2, 0] - -The [default values](rdoc-ref:Hash@Default+Values) are returned for any keys -that are not found: - h.values_at(:hello, :foo) # => [nil, 0] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/HashSpecs.md b/example/ruby/HashSpecs.md deleted file mode 100644 index 948f546..0000000 --- a/example/ruby/HashSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: HashSpecs - - - - -# Class Methods -## empty_frozen_hash() [](#method-c-empty_frozen_hash) -## frozen_hash() [](#method-c-frozen_hash) - diff --git a/example/ruby/HashSpecs/ByIdentityKey.md b/example/ruby/HashSpecs/ByIdentityKey.md deleted file mode 100644 index 8c25576..0000000 --- a/example/ruby/HashSpecs/ByIdentityKey.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HashSpecs::ByIdentityKey -**Inherits:** Object - - - - - -#Instance Methods -## hash() [](#method-i-hash) - diff --git a/example/ruby/HashSpecs/ByValueKey.md b/example/ruby/HashSpecs/ByValueKey.md deleted file mode 100644 index 0bc5b95..0000000 --- a/example/ruby/HashSpecs/ByValueKey.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: HashSpecs::ByValueKey -**Inherits:** Object - - - - -# Attributes -## n[RW] [](#attribute-i-n) -Returns the value of attribute n. - - -#Instance Methods -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(n) [](#method-i-initialize) - -**@return** [ByValueKey] a new instance of ByValueKey - diff --git a/example/ruby/HashSpecs/DefaultHash.md b/example/ruby/HashSpecs/DefaultHash.md deleted file mode 100644 index 5c4d7e0..0000000 --- a/example/ruby/HashSpecs/DefaultHash.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HashSpecs::DefaultHash -**Inherits:** Hash - - - - - -#Instance Methods -## default(key) [](#method-i-default) - diff --git a/example/ruby/HashSpecs/KeyWithPrivateHash.md b/example/ruby/HashSpecs/KeyWithPrivateHash.md deleted file mode 100644 index e369f72..0000000 --- a/example/ruby/HashSpecs/KeyWithPrivateHash.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: HashSpecs::KeyWithPrivateHash -**Inherits:** Object - - - - - diff --git a/example/ruby/HashSpecs/MyHash.md b/example/ruby/HashSpecs/MyHash.md deleted file mode 100644 index d7c0734..0000000 --- a/example/ruby/HashSpecs/MyHash.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: HashSpecs::MyHash -**Inherits:** Hash - - - - - diff --git a/example/ruby/HashSpecs/MyInitializerHash.md b/example/ruby/HashSpecs/MyInitializerHash.md deleted file mode 100644 index 9417ef2..0000000 --- a/example/ruby/HashSpecs/MyInitializerHash.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: HashSpecs::MyInitializerHash -**Inherits:** Hash - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MyInitializerHash] a new instance of MyInitializerHash - diff --git a/example/ruby/HashSpecs/NewHash.md b/example/ruby/HashSpecs/NewHash.md deleted file mode 100644 index 231051b..0000000 --- a/example/ruby/HashSpecs/NewHash.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: HashSpecs::NewHash -**Inherits:** Hash - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [NewHash] a new instance of NewHash - diff --git a/example/ruby/HashSpecs/SubHashSettingInInitialize.md b/example/ruby/HashSpecs/SubHashSettingInInitialize.md deleted file mode 100644 index 1e3b7e1..0000000 --- a/example/ruby/HashSpecs/SubHashSettingInInitialize.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: HashSpecs::SubHashSettingInInitialize -**Inherits:** Hash - - - - - -#Instance Methods -## initialize(*args, &block) [](#method-i-initialize) - -**@return** [SubHashSettingInInitialize] a new instance of SubHashSettingInInitialize - diff --git a/example/ruby/HashSpecs/ToHashHash.md b/example/ruby/HashSpecs/ToHashHash.md deleted file mode 100644 index 0bea3c0..0000000 --- a/example/ruby/HashSpecs/ToHashHash.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: HashSpecs::ToHashHash -**Inherits:** Hash - - - - - -#Instance Methods -## to_hash() [](#method-i-to_hash) - diff --git a/example/ruby/HashStringsBinary.md b/example/ruby/HashStringsBinary.md deleted file mode 100644 index d4b646a..0000000 --- a/example/ruby/HashStringsBinary.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: HashStringsBinary - - - - -# Class Methods -## literal_hash() [](#method-c-literal_hash) - diff --git a/example/ruby/HashStringsUSASCII.md b/example/ruby/HashStringsUSASCII.md deleted file mode 100644 index da32807..0000000 --- a/example/ruby/HashStringsUSASCII.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: HashStringsUSASCII - - - - -# Class Methods -## literal_hash() [](#method-c-literal_hash) - diff --git a/example/ruby/HashStringsUTF8.md b/example/ruby/HashStringsUTF8.md deleted file mode 100644 index d0ec19b..0000000 --- a/example/ruby/HashStringsUTF8.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: HashStringsUTF8 - - - - -# Class Methods -## literal_hash() [](#method-c-literal_hash) - diff --git a/example/ruby/HaveClassVariableMatcher.md b/example/ruby/HaveClassVariableMatcher.md deleted file mode 100644 index ad7679e..0000000 --- a/example/ruby/HaveClassVariableMatcher.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: HaveClassVariableMatcher -**Inherits:** VariableMatcher - - - - - diff --git a/example/ruby/HaveConstantMatcher.md b/example/ruby/HaveConstantMatcher.md deleted file mode 100644 index cce91b2..0000000 --- a/example/ruby/HaveConstantMatcher.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: HaveConstantMatcher -**Inherits:** VariableMatcher - - - - - diff --git a/example/ruby/HaveInstanceMethodMatcher.md b/example/ruby/HaveInstanceMethodMatcher.md deleted file mode 100644 index 38ea5e4..0000000 --- a/example/ruby/HaveInstanceMethodMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: HaveInstanceMethodMatcher -**Inherits:** MethodMatcher - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(mod) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/HaveInstanceVariableMatcher.md b/example/ruby/HaveInstanceVariableMatcher.md deleted file mode 100644 index c8e9f55..0000000 --- a/example/ruby/HaveInstanceVariableMatcher.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: HaveInstanceVariableMatcher -**Inherits:** VariableMatcher - - - - - diff --git a/example/ruby/HaveMethodMatcher.md b/example/ruby/HaveMethodMatcher.md deleted file mode 100644 index 8878cd7..0000000 --- a/example/ruby/HaveMethodMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: HaveMethodMatcher -**Inherits:** MethodMatcher - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(mod) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/HavePrivateInstanceMethodMatcher.md b/example/ruby/HavePrivateInstanceMethodMatcher.md deleted file mode 100644 index d96d5a3..0000000 --- a/example/ruby/HavePrivateInstanceMethodMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: HavePrivateInstanceMethodMatcher -**Inherits:** MethodMatcher - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(mod) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/HavePrivateMethodMatcher.md b/example/ruby/HavePrivateMethodMatcher.md deleted file mode 100644 index 79343c0..0000000 --- a/example/ruby/HavePrivateMethodMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: HavePrivateMethodMatcher -**Inherits:** MethodMatcher - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(mod) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/HaveProtectedInstanceMethodMatcher.md b/example/ruby/HaveProtectedInstanceMethodMatcher.md deleted file mode 100644 index 53414d0..0000000 --- a/example/ruby/HaveProtectedInstanceMethodMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: HaveProtectedInstanceMethodMatcher -**Inherits:** MethodMatcher - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(mod) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/HavePublicInstanceMethodMatcher.md b/example/ruby/HavePublicInstanceMethodMatcher.md deleted file mode 100644 index d4fac05..0000000 --- a/example/ruby/HavePublicInstanceMethodMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: HavePublicInstanceMethodMatcher -**Inherits:** MethodMatcher - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(mod) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/HaveSingletonMethodMatcher.md b/example/ruby/HaveSingletonMethodMatcher.md deleted file mode 100644 index f6fbffa..0000000 --- a/example/ruby/HaveSingletonMethodMatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: HaveSingletonMethodMatcher -**Inherits:** MethodMatcher - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## matches?(obj) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/HeaderParser.md b/example/ruby/HeaderParser.md deleted file mode 100644 index 8f8cdaa..0000000 --- a/example/ruby/HeaderParser.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: HeaderParser -**Inherits:** Object - - -Parse a C header with ffi-clang and return Node objects. To ease the -maintenance, ffi-clang should be used only inside this class. - - - -#Instance Methods -## initialize(header, cflags:) [](#method-i-initialize) - -**@return** [HeaderParser] a new instance of HeaderParser - -## parse() [](#method-i-parse) - diff --git a/example/ruby/HelloWorld.md b/example/ruby/HelloWorld.md deleted file mode 100644 index f4684ab..0000000 --- a/example/ruby/HelloWorld.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: HelloWorld -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## hello(name) [](#method-i-hello) - diff --git a/example/ruby/Hi_Exception.md b/example/ruby/Hi_Exception.md deleted file mode 100644 index 00d5b30..0000000 --- a/example/ruby/Hi_Exception.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Hi_Exception -**Inherits:** Exception - - - - - -#Instance Methods -## initialize(num) [](#method-i-initialize) - -**@return** [Hi_Exception] a new instance of Hi_Exception - diff --git a/example/ruby/Hoge.md b/example/ruby/Hoge.md deleted file mode 100644 index 1873005..0000000 --- a/example/ruby/Hoge.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Hoge -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## initialize(s) [](#method-i-initialize) - -**@return** [Hoge] a new instance of Hoge - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/HtmlFormatter.md b/example/ruby/HtmlFormatter.md deleted file mode 100644 index caa7adc..0000000 --- a/example/ruby/HtmlFormatter.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: HtmlFormatter -**Inherits:** BaseFormatter - - - - - -#Instance Methods -## after(statenil) [](#method-i-after) - -## enter(describe) [](#method-i-enter) - -## escape(string) [](#method-i-escape) - -## exception(exception) [](#method-i-exception) - -## finish() [](#method-i-finish) - -## leave() [](#method-i-leave) - -## register() [](#method-i-register) - -## start() [](#method-i-start) - diff --git a/example/ruby/HumanTypoTest.md b/example/ruby/HumanTypoTest.md deleted file mode 100644 index 5d19dfa..0000000 --- a/example/ruby/HumanTypoTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: HumanTypoTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_changes() [](#method-i-test_changes) - -## test_check_input() [](#method-i-test_check_input) - diff --git a/example/ruby/IEHandler.md b/example/ruby/IEHandler.md deleted file mode 100644 index b876606..0000000 --- a/example/ruby/IEHandler.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: IEHandler -**Inherits:** Object - - - - -# Attributes -## loop[RW] [](#attribute-i-loop) -Returns the value of attribute loop. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [IEHandler] a new instance of IEHandler - -## method_missing(event, *args) [](#method-i-method_missing) - -## onNavigateComplete2(pdisp, url) [](#method-i-onNavigateComplete2) - -## onOnQuit() [](#method-i-onOnQuit) - -## put_urls() [](#method-i-put_urls) - diff --git a/example/ruby/IE_CONST.md b/example/ruby/IE_CONST.md deleted file mode 100644 index 65d186d..0000000 --- a/example/ruby/IE_CONST.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: IE_CONST - - -WIN32OLE.const_load(ie) WIN32OLE.constants.sort.each do |c| - puts "#{c} = #{WIN32OLE.const_get(c)}" - -end - - - diff --git a/example/ruby/IO.md b/example/ruby/IO.md deleted file mode 100644 index 9ee870d..0000000 --- a/example/ruby/IO.md +++ /dev/null @@ -1,5557 +0,0 @@ -# Class: IO -**Inherits:** Object - -**Includes:** Enumerable, File::Constants - - -An instance of class IO (commonly called a *stream*) represents an -input/output stream in the underlying operating system. Class IO is the basis -for input and output in Ruby. - -Class File is the only class in the Ruby core that is a subclass of IO. Some -classes in the Ruby standard library are also subclasses of IO; these include -TCPSocket and UDPSocket. - -The global constant ARGF (also accessible as `$<`) provides an IO-like stream -that allows access to all file paths found in ARGV (or found in STDIN if ARGV -is empty). ARGF is not itself a subclass of IO. - -Class StringIO provides an IO-like stream that handles a String. StringIO is -not itself a subclass of IO. - -Important objects based on IO include: - -* $stdin. -* $stdout. -* $stderr. -* Instances of class File. - -An instance of IO may be created using: - -* IO.new: returns a new IO object for the given integer file descriptor. -* IO.open: passes a new IO object to the given block. -* IO.popen: returns a new IO object that is connected to the $stdin and - $stdout of a newly-launched subprocess. -* Kernel#open: Returns a new IO object connected to a given source: stream, - file, or subprocess. - -Like a File stream, an IO stream has: - -* A read/write mode, which may be read-only, write-only, or read/write; see - [Read/Write Mode](rdoc-ref:File@Read-2FWrite+Mode). -* A data mode, which may be text-only or binary; see [Data - Mode](rdoc-ref:File@Data+Mode). -* Internal and external encodings; see [Encodings](rdoc-ref:File@Encodings). - -And like other IO streams, it has: - -* A position, which determines where in the stream the next read or write is - to occur; see [Position](rdoc-ref:IO@Position). -* A line number, which is a special, line-oriented, "position" (different - from the position mentioned above); see [Line - Number](rdoc-ref:IO@Line+Number). - -## Extension `io/console` - -Extension `io/console` provides numerous methods for interacting with the -console; requiring it adds numerous methods to class IO. - -## Example Files - -Many examples here use these variables: - - :include: doc/examples/files.rdoc - -## Open Options - -A number of IO methods accept optional keyword arguments that determine how a -new stream is to be opened: - -* `:mode`: Stream mode. -* `:flags`: Integer file open flags; If `mode` is also given, the two are - bitwise-ORed. -* `:external_encoding`: External encoding for the stream. -* `:internal_encoding`: Internal encoding for the stream. `'-'` is a synonym - for the default internal encoding. If the value is `nil` no conversion - occurs. -* `:encoding`: Specifies external and internal encodings as - `'extern:intern'`. -* `:textmode`: If a truthy value, specifies the mode as text-only, binary - otherwise. -* `:binmode`: If a truthy value, specifies the mode as binary, text-only - otherwise. -* `:autoclose`: If a truthy value, specifies that the `fd` will close when - the stream closes; otherwise it remains open. -* `:path:` If a string value is provided, it is used in #inspect and is - available as #path method. - -Also available are the options offered in String#encode, which may control -conversion between external and internal encoding. - -## Basic IO - -You can perform basic stream IO with these methods, which typically operate on -multi-byte strings: - -* IO#read: Reads and returns some or all of the remaining bytes from the - stream. -* IO#write: Writes zero or more strings to the stream; each given object - that is not already a string is converted via `to_s`. - -### Position - -An IO stream has a nonnegative integer *position*, which is the byte offset at -which the next read or write is to occur. A new stream has position zero (and -line number zero); method `rewind` resets the position (and line number) to -zero. - -These methods discard [buffers](rdoc-ref:IO@Buffering) and the -Encoding::Converter instances used for that IO. - -The relevant methods: - -* IO#tell (aliased as `#pos`): Returns the current position (in bytes) in - the stream. -* IO#pos=: Sets the position of the stream to a given integer `new_position` - (in bytes). -* IO#seek: Sets the position of the stream to a given integer `offset` (in - bytes), relative to a given position `whence` (indicating the beginning, - end, or current position). -* IO#rewind: Positions the stream at the beginning (also resetting the line - number). - -### Open and Closed Streams - -A new IO stream may be open for reading, open for writing, or both. - -A stream is automatically closed when claimed by the garbage collector. - -Attempted reading or writing on a closed stream raises an exception. - -The relevant methods: - -* IO#close: Closes the stream for both reading and writing. -* IO#close_read: Closes the stream for reading. -* IO#close_write: Closes the stream for writing. -* IO#closed?: Returns whether the stream is closed. - -### End-of-Stream - -You can query whether a stream is positioned at its end: - -* IO#eof? (also aliased as `#eof`): Returns whether the stream is at - end-of-stream. - -You can reposition to end-of-stream by using method IO#seek: - - f = File.new('t.txt') - f.eof? # => false - f.seek(0, :END) - f.eof? # => true - f.close - -Or by reading all stream content (which is slower than using IO#seek): - - f.rewind - f.eof? # => false - f.read # => "First line\nSecond line\n\nFourth line\nFifth line\n" - f.eof? # => true - -## Line IO - -Class IO supports line-oriented [input](rdoc-ref:IO@Line+Input) and -[output](rdoc-ref:IO@Line+Output) - -### Line Input - -Class IO supports line-oriented input for [files](rdoc-ref:IO@File+Line+Input) -and [IO streams](rdoc-ref:IO@Stream+Line+Input) - -#### File Line Input - -You can read lines from a file using these methods: - -* IO.foreach: Reads each line and passes it to the given block. -* IO.readlines: Reads and returns all lines in an array. - -For each of these methods: - -* You can specify [open options](rdoc-ref:IO@Open+Options). -* Line parsing depends on the effective *line separator*; see [Line - Separator](rdoc-ref:IO@Line+Separator). -* The length of each returned line depends on the effective *line limit*; - see [Line Limit](rdoc-ref:IO@Line+Limit). - -#### Stream Line Input - -You can read lines from an IO stream using these methods: - -* IO#each_line: Reads each remaining line, passing it to the given block. -* IO#gets: Returns the next line. -* IO#readline: Like #gets, but raises an exception at end-of-stream. -* IO#readlines: Returns all remaining lines in an array. - -For each of these methods: - -* Reading may begin mid-line, depending on the stream's *position*; see - [Position](rdoc-ref:IO@Position). -* Line parsing depends on the effective *line separator*; see [Line - Separator](rdoc-ref:IO@Line+Separator). -* The length of each returned line depends on the effective *line limit*; - see [Line Limit](rdoc-ref:IO@Line+Limit). - -##### Line Separator - -Each of the [line input methods](rdoc-ref:IO@Line+Input) uses a *line -separator*: the string that determines what is considered a line; it is -sometimes called the *input record separator*. - -The default line separator is taken from global variable `$/`, whose initial -value is `"\n"`. - -Generally, the line to be read next is all data from the current -[position](rdoc-ref:IO@Position) to the next line separator (but see [Special -Line Separator Values](rdoc-ref:IO@Special+Line+Separator+Values)): - - f = File.new('t.txt') - # Method gets with no sep argument returns the next line, according to $/. - f.gets # => "First line\n" - f.gets # => "Second line\n" - f.gets # => "\n" - f.gets # => "Fourth line\n" - f.gets # => "Fifth line\n" - f.close - -You can use a different line separator by passing argument `sep`: - - f = File.new('t.txt') - f.gets('l') # => "First l" - f.gets('li') # => "ine\nSecond li" - f.gets('lin') # => "ne\n\nFourth lin" - f.gets # => "e\n" - f.close - -Or by setting global variable `$/`: - - f = File.new('t.txt') - $/ = 'l' - f.gets # => "First l" - f.gets # => "ine\nSecond l" - f.gets # => "ine\n\nFourth l" - f.close - -##### Special Line Separator Values - -Each of the [line input methods](rdoc-ref:IO@Line+Input) accepts two special -values for parameter `sep`: - -* `nil`: The entire stream is to be read ("slurped") into a single string: - - f = File.new('t.txt') - f.gets(nil) # => "First line\nSecond line\n\nFourth line\nFifth line\n" - f.close - -* `''` (the empty string): The next "paragraph" is to be read (paragraphs - being separated by two consecutive line separators): - - f = File.new('t.txt') - f.gets('') # => "First line\nSecond line\n\n" - f.gets('') # => "Fourth line\nFifth line\n" - f.close - -##### Line Limit - -Each of the [line input methods](rdoc-ref:IO@Line+Input) uses an integer *line -limit*, which restricts the number of bytes that may be returned. (A -multi-byte character will not be split, and so a returned line may be slightly -longer than the limit). - -The default limit value is `-1`; any negative limit value means that there is -no limit. - -If there is no limit, the line is determined only by `sep`. - - # Text with 1-byte characters. - File.open('t.txt') {|f| f.gets(1) } # => "F" - File.open('t.txt') {|f| f.gets(2) } # => "Fi" - File.open('t.txt') {|f| f.gets(3) } # => "Fir" - File.open('t.txt') {|f| f.gets(4) } # => "Firs" - # No more than one line. - File.open('t.txt') {|f| f.gets(10) } # => "First line" - File.open('t.txt') {|f| f.gets(11) } # => "First line\n" - File.open('t.txt') {|f| f.gets(12) } # => "First line\n" - - # Text with 2-byte characters, which will not be split. - File.open('t.rus') {|f| f.gets(1).size } # => 1 - File.open('t.rus') {|f| f.gets(2).size } # => 1 - File.open('t.rus') {|f| f.gets(3).size } # => 2 - File.open('t.rus') {|f| f.gets(4).size } # => 2 - -##### Line Separator and Line Limit - -With arguments `sep` and `limit` given, combines the two behaviors: - -* Returns the next line as determined by line separator `sep`. -* But returns no more bytes than are allowed by the limit `limit`. - -Example: - - File.open('t.txt') {|f| f.gets('li', 20) } # => "First li" - File.open('t.txt') {|f| f.gets('li', 2) } # => "Fi" - -##### Line Number - -A readable IO stream has a non-negative integer *line number*: - -* IO#lineno: Returns the line number. -* IO#lineno=: Resets and returns the line number. - -Unless modified by a call to method IO#lineno=, the line number is the number -of lines read by certain line-oriented methods, according to the effective -[line separator](rdoc-ref:IO@Line+Separator): - -* IO.foreach: Increments the line number on each call to the block. -* IO#each_line: Increments the line number on each call to the block. -* IO#gets: Increments the line number. -* IO#readline: Increments the line number. -* IO#readlines: Increments the line number for each line read. - -A new stream is initially has line number zero (and position zero); method -`rewind` resets the line number (and position) to zero: - - f = File.new('t.txt') - f.lineno # => 0 - f.gets # => "First line\n" - f.lineno # => 1 - f.rewind - f.lineno # => 0 - f.close - -Reading lines from a stream usually changes its line number: - - f = File.new('t.txt', 'r') - f.lineno # => 0 - f.readline # => "This is line one.\n" - f.lineno # => 1 - f.readline # => "This is the second line.\n" - f.lineno # => 2 - f.readline # => "Here's the third line.\n" - f.lineno # => 3 - f.eof? # => true - f.close - -Iterating over lines in a stream usually changes its line number: - - File.open('t.txt') do |f| - f.each_line do |line| - p "position=#{f.pos} eof?=#{f.eof?} lineno=#{f.lineno}" - end - end - -Output: - - "position=11 eof?=false lineno=1" - "position=23 eof?=false lineno=2" - "position=24 eof?=false lineno=3" - "position=36 eof?=false lineno=4" - "position=47 eof?=true lineno=5" - -Unlike the stream's [position](rdoc-ref:IO@Position), the line number does not -affect where the next read or write will occur: - - f = File.new('t.txt') - f.lineno = 1000 - f.lineno # => 1000 - f.gets # => "First line\n" - f.lineno # => 1001 - f.close - -Associated with the line number is the global variable `$.`: - -* When a stream is opened, `$.` is not set; its value is left over from - previous activity in the process: - - $. = 41 - f = File.new('t.txt') - $. = 41 - # => 41 - f.close - -* When a stream is read, `$.` is set to the line number for that stream: - - f0 = File.new('t.txt') - f1 = File.new('t.dat') - f0.readlines # => ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - $. # => 5 - f1.readlines # => ["\xFE\xFF\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"] - $. # => 1 - f0.close - f1.close - -* Methods IO#rewind and IO#seek do not affect `$.`: - - f = File.new('t.txt') - f.readlines # => ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - $. # => 5 - f.rewind - f.seek(0, :SET) - $. # => 5 - f.close - -### Line Output - -You can write to an IO stream line-by-line using this method: - -* IO#puts: Writes objects to the stream. - -## Character IO - -You can process an IO stream character-by-character using these methods: - -* IO#getc: Reads and returns the next character from the stream. -* IO#readchar: Like #getc, but raises an exception at end-of-stream. -* IO#ungetc: Pushes back ("unshifts") a character or integer onto the - stream. -* IO#putc: Writes a character to the stream. -* IO#each_char: Reads each remaining character in the stream, passing the - character to the given block. - -## Byte IO - -You can process an IO stream byte-by-byte using these methods: - -* IO#getbyte: Returns the next 8-bit byte as an integer in range 0..255. -* IO#readbyte: Like #getbyte, but raises an exception if at end-of-stream. -* IO#ungetbyte: Pushes back ("unshifts") a byte back onto the stream. -* IO#each_byte: Reads each remaining byte in the stream, passing the byte to - the given block. - -## Codepoint IO - -You can process an IO stream codepoint-by-codepoint: - -* IO#each_codepoint: Reads each remaining codepoint, passing it to the given - block. - -## What's Here - -First, what's elsewhere. Class IO: - -* Inherits from [class Object](rdoc-ref:Object@What-27s+Here). -* Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which - provides dozens of additional methods. - -Here, class IO provides methods that are useful for: - -* [Creating](rdoc-ref:IO@Creating) -* [Reading](rdoc-ref:IO@Reading) -* [Writing](rdoc-ref:IO@Writing) -* [Positioning](rdoc-ref:IO@Positioning) -* [Iterating](rdoc-ref:IO@Iterating) -* [Settings](rdoc-ref:IO@Settings) -* [Querying](rdoc-ref:IO@Querying) -* [Buffering](rdoc-ref:IO@Buffering) -* [Low-Level Access](rdoc-ref:IO@Low-Level+Access) -* [Other](rdoc-ref:IO@Other) - -### Creating - -* ::new (aliased as ::for_fd): Creates and returns a new IO object for the - given integer file descriptor. -* ::open: Creates a new IO object. -* ::pipe: Creates a connected pair of reader and writer IO objects. -* ::popen: Creates an IO object to interact with a subprocess. -* ::select: Selects which given IO instances are ready for reading, writing, - or have pending exceptions. - -### Reading - -* ::binread: Returns a binary string with all or a subset of bytes from the - given file. -* ::read: Returns a string with all or a subset of bytes from the given - file. -* ::readlines: Returns an array of strings, which are the lines from the - given file. -* #getbyte: Returns the next 8-bit byte read from `self` as an integer. -* #getc: Returns the next character read from `self` as a string. -* #gets: Returns the line read from `self`. -* #pread: Returns all or the next *n* bytes read from `self`, not updating - the receiver's offset. -* #read: Returns all remaining or the next *n* bytes read from `self` for a - given *n*. -* #read_nonblock: the next *n* bytes read from `self` for a given *n*, in - non-block mode. -* #readbyte: Returns the next byte read from `self`; same as #getbyte, but - raises an exception on end-of-stream. -* #readchar: Returns the next character read from `self`; same as #getc, but - raises an exception on end-of-stream. -* #readline: Returns the next line read from `self`; same as #getline, but - raises an exception of end-of-stream. -* #readlines: Returns an array of all lines read read from `self`. -* #readpartial: Returns up to the given number of bytes from `self`. - -### Writing - -* ::binwrite: Writes the given string to the file at the given filepath, in - binary mode. -* ::write: Writes the given string to `self`. -* #<<: Appends the given string to `self`. -* #print: Prints last read line or given objects to `self`. -* #printf: Writes to `self` based on the given format string and objects. -* #putc: Writes a character to `self`. -* #puts: Writes lines to `self`, making sure line ends with a newline. -* #pwrite: Writes the given string at the given offset, not updating the - receiver's offset. -* #write: Writes one or more given strings to `self`. -* #write_nonblock: Writes one or more given strings to `self` in - non-blocking mode. - -### Positioning - -* #lineno: Returns the current line number in `self`. -* #lineno=: Sets the line number is `self`. -* #pos (aliased as #tell): Returns the current byte offset in `self`. -* #pos=: Sets the byte offset in `self`. -* #reopen: Reassociates `self` with a new or existing IO stream. -* #rewind: Positions `self` to the beginning of input. -* #seek: Sets the offset for `self` relative to given position. - -### Iterating - -* ::foreach: Yields each line of given file to the block. -* #each (aliased as #each_line): Calls the given block with each successive - line in `self`. -* #each_byte: Calls the given block with each successive byte in `self` as - an integer. -* #each_char: Calls the given block with each successive character in `self` - as a string. -* #each_codepoint: Calls the given block with each successive codepoint in - `self` as an integer. - -### Settings - -* #autoclose=: Sets whether `self` auto-closes. -* #binmode: Sets `self` to binary mode. -* #close: Closes `self`. -* #close_on_exec=: Sets the close-on-exec flag. -* #close_read: Closes `self` for reading. -* #close_write: Closes `self` for writing. -* #set_encoding: Sets the encoding for `self`. -* #set_encoding_by_bom: Sets the encoding for `self`, based on its Unicode - byte-order-mark. -* #sync=: Sets the sync-mode to the given value. - -### Querying - -* #autoclose?: Returns whether `self` auto-closes. -* #binmode?: Returns whether `self` is in binary mode. -* #close_on_exec?: Returns the close-on-exec flag for `self`. -* #closed?: Returns whether `self` is closed. -* #eof? (aliased as #eof): Returns whether `self` is at end-of-stream. -* #external_encoding: Returns the external encoding object for `self`. -* #fileno (aliased as #to_i): Returns the integer file descriptor for `self` -* #internal_encoding: Returns the internal encoding object for `self`. -* #pid: Returns the process ID of a child process associated with `self`, if - `self` was created by ::popen. -* #stat: Returns the File::Stat object containing status information for - `self`. -* #sync: Returns whether `self` is in sync-mode. -* #tty? (aliased as #isatty): Returns whether `self` is a terminal. - -### Buffering - -* #fdatasync: Immediately writes all buffered data in `self` to disk. -* #flush: Flushes any buffered data within `self` to the underlying - operating system. -* #fsync: Immediately writes all buffered data and attributes in `self` to - disk. -* #ungetbyte: Prepends buffer for `self` with given integer byte or string. -* #ungetc: Prepends buffer for `self` with given string. - -### Low-Level Access - -* ::sysopen: Opens the file given by its path, returning the integer file - descriptor. -* #advise: Announces the intention to access data from `self` in a specific - way. -* #fcntl: Passes a low-level command to the file specified by the given file - descriptor. -* #ioctl: Passes a low-level command to the device specified by the given - file descriptor. -* #sysread: Returns up to the next *n* bytes read from self using a - low-level read. -* #sysseek: Sets the offset for `self`. -* #syswrite: Writes the given string to `self` using a low-level write. - -### Other - -* ::copy_stream: Copies data from a source to a destination, each of which - is a filepath or an IO-like object. -* ::try_convert: Returns a new IO object resulting from converting the given - object. -* #inspect: Returns the string representation of `self`. - - -# Class Methods -## binread(*args ) [](#method-c-binread) -Behaves like IO.read, except that the stream is opened in binary mode with -ASCII-8BIT encoding. - -When called from class IO (but not subclasses of IO), this method has -potential security vulnerabilities if called with untrusted input; see -[Command Injection](rdoc-ref:command_injection.rdoc). -**@overload** [] - -## binwrite(*args ) [](#method-c-binwrite) -Behaves like IO.write, except that the stream is opened in binary mode with -ASCII-8BIT encoding. - -When called from class IO (but not subclasses of IO), this method has -potential security vulnerabilities if called with untrusted input; see -[Command Injection](rdoc-ref:command_injection.rdoc). -**@overload** [] - -## console(*args ) [](#method-c-console) -Returns an File instance opened console. - -If `sym` is given, it will be sent to the opened console with `args` and the -result will be returned instead of the console IO itself. - -You must require 'io/console' to use this method. -**@overload** [] - -**@overload** [] - -## copy_stream(*args ) [](#method-c-copy_stream) -Copies from the given `src` to the given `dst`, returning the number of bytes -copied. - -* The given `src` must be one of the following: - - * The path to a readable file, from which source data is to be read. - * An IO-like object, opened for reading and capable of responding to - method `:readpartial` or method `:read`. - -* The given `dst` must be one of the following: - - * The path to a writable file, to which data is to be written. - * An IO-like object, opened for writing and capable of responding to - method `:write`. - -The examples here use file `t.txt` as source: - - File.read('t.txt') - # => "First line\nSecond line\n\nThird line\nFourth line\n" - File.read('t.txt').size # => 47 - -If only arguments `src` and `dst` are given, the entire source stream is -copied: - - # Paths. - IO.copy_stream('t.txt', 't.tmp') # => 47 - - # IOs (recall that a File is also an IO). - src_io = File.open('t.txt', 'r') # => # - dst_io = File.open('t.tmp', 'w') # => # - IO.copy_stream(src_io, dst_io) # => 47 - src_io.close - dst_io.close - -With argument `src_length` a non-negative integer, no more than that many -bytes are copied: - - IO.copy_stream('t.txt', 't.tmp', 10) # => 10 - File.read('t.tmp') # => "First line" - -With argument `src_offset` also given, the source stream is read beginning at -that offset: - - IO.copy_stream('t.txt', 't.tmp', 11, 11) # => 11 - IO.read('t.tmp') # => "Second line" -**@overload** [] - -## default_console_size() [](#method-c-default_console_size) -fallback to console window size -## for_fd(*args ) [](#method-c-for_fd) -Synonym for IO.new. -**@overload** [] - -## foreach(*args ) [](#method-c-foreach) -Calls the block with each successive line read from the stream. - -When called from class IO (but not subclasses of IO), this method has -potential security vulnerabilities if called with untrusted input; see -[Command Injection](rdoc-ref:command_injection.rdoc). - -The first argument must be a string that is the path to a file. - -With only argument `path` given, parses lines from the file at the given -`path`, as determined by the default line separator, and calls the block with -each successive line: - - File.foreach('t.txt') {|line| p line } - -Output: the same as above. - -For both forms, command and path, the remaining arguments are the same. - -With argument `sep` given, parses lines as determined by that line separator -(see [Line Separator](rdoc-ref:IO@Line+Separator)): - - File.foreach('t.txt', 'li') {|line| p line } - -Output: - - "First li" - "ne\nSecond li" - "ne\n\nThird li" - "ne\nFourth li" - "ne\n" - -Each paragraph: - - File.foreach('t.txt', '') {|paragraph| p paragraph } - -Output: - - "First line\nSecond line\n\n" - "Third line\nFourth line\n" - -With argument `limit` given, parses lines as determined by the default line -separator and the given line-length limit (see [Line -Separator](rdoc-ref:IO@Line+Separator) and [Line -Limit](rdoc-ref:IO@Line+Limit)): - - File.foreach('t.txt', 7) {|line| p line } - -Output: - - "First l" - "ine\n" - "Second " - "line\n" - "\n" - "Third l" - "ine\n" - "Fourth l" - "line\n" - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword arguments `opts` specify: - -* [Open Options](rdoc-ref:IO@Open+Options). -* [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). -* [Line Options](rdoc-ref:IO@Line+IO). - -Returns an Enumerator if no block is given. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## io_maybe_wait(error , io , events , timeout ) [](#method-c-io_maybe_wait) -## io_maybe_wait_readable(error , io , timeout ) [](#method-c-io_maybe_wait_readable) -## io_maybe_wait_writable(error , io , timeout ) [](#method-c-io_maybe_wait_writable) -## io_wait(io , events , timeout ) [](#method-c-io_wait) -## new(*args ) [](#method-c-new) -:nodoc: -## open(*args ) [](#method-c-open) -call-seq: - IO.open(fd, mode = 'r', **opts) -> io - IO.open(fd, mode = 'r', **opts) {|io| ... } -> object - -Creates a new IO object, via IO.new with the given arguments. - -With no block given, returns the IO object. - -With a block given, calls the block with the IO object and returns the block's -value. -## pipe(*args ) [](#method-c-pipe) -Creates a pair of pipe endpoints, `read_io` and `write_io`, connected to each -other. - -If argument `enc_string` is given, it must be a string containing one of: - -* The name of the encoding to be used as the external encoding. -* The colon-separated names of two encodings to be used as the external and - internal encodings. - -If argument `int_enc` is given, it must be an Encoding object or encoding name -string that specifies the internal encoding to be used; if argument `ext_enc` -is also given, it must be an Encoding object or encoding name string that -specifies the external encoding to be used. - -The string read from `read_io` is tagged with the external encoding; if an -internal encoding is also specified, the string is converted to, and tagged -with, that encoding. - -If any encoding is specified, optional hash arguments specify the conversion -option. - -Optional keyword arguments `opts` specify: - -* [Open Options](rdoc-ref:IO@Open+Options). -* [Encoding Options](rdoc-ref:encodings.rdoc@Encoding+Options). - -With no block given, returns the two endpoints in an array: - - IO.pipe # => [#, #] - -With a block given, calls the block with the two endpoints; closes both -endpoints and returns the value of the block: - - IO.pipe {|read_io, write_io| p read_io; p write_io } - -Output: - - # - # - -Not available on all platforms. - -In the example below, the two processes close the ends of the pipe that they -are not using. This is not just a cosmetic nicety. The read end of a pipe will -not generate an end of file condition if there are any writers with the pipe -still open. In the case of the parent process, the `rd.read` will never return -if it does not first issue a `wr.close`: - - rd, wr = IO.pipe - - if fork - wr.close - puts "Parent got: <#{rd.read}>" - rd.close - Process.wait - else - rd.close - puts 'Sending message to parent' - wr.write "Hi Dad" - wr.close - end - -*produces:* - - Sending message to parent - Parent got: -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## popen(*args ) [](#method-c-popen) -Executes the given command `cmd` as a subprocess whose $stdin and $stdout are -connected to a new stream `io`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -If no block is given, returns the new stream, which depending on given `mode` -may be open for reading, writing, or both. The stream should be explicitly -closed (eventually) to avoid resource leaks. - -If a block is given, the stream is passed to the block (again, open for -reading, writing, or both); when the block exits, the stream is closed, and -the block's value is assigned to global variable `$?` and returned. - -Optional argument `mode` may be any valid IO mode. See [Access -Modes](rdoc-ref:File@Access+Modes). - -Required argument `cmd` determines which of the following occurs: - -* The process forks. -* A specified program runs in a shell. -* A specified program runs with specified arguments. -* A specified program runs with specified arguments and a specified `argv0`. - -Each of these is detailed below. - -The optional hash argument `env` specifies name/value pairs that are to be -added to the environment variables for the subprocess: - - IO.popen({'FOO' => 'bar'}, 'ruby', 'r+') do |pipe| - pipe.puts 'puts ENV["FOO"]' - pipe.close_write - pipe.gets - end => "bar\n" - -Optional keyword arguments `opts` specify: - -* [Open options](rdoc-ref:IO@Open+Options). -* [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). -* Options for Kernel#spawn. - -**Forked \Process** - -When argument `cmd` is the 1-character string `'-'`, causes the process to -fork: - IO.popen('-') do |pipe| - if pipe - $stderr.puts "In parent, child pid is #{pipe.pid}\n" - else - $stderr.puts "In child, pid is #{$$}\n" - end - end - -Output: - - In parent, child pid is 26253 - In child, pid is 26253 - -Note that this is not supported on all platforms. - -**Shell Subprocess** - -When argument `cmd` is a single string (but not `'-'`), the program named -`cmd` is run as a shell command: - - IO.popen('uname') do |pipe| - pipe.readlines - end - -Output: - - ["Linux\n"] - -Another example: - - IO.popen('/bin/sh', 'r+') do |pipe| - pipe.puts('ls') - pipe.close_write - $stderr.puts pipe.readlines.size - end - -Output: - - 213 - -**Program Subprocess** - -When argument `cmd` is an array of strings, the program named `cmd[0]` is run -with all elements of `cmd` as its arguments: - - IO.popen(['du', '..', '.']) do |pipe| - $stderr.puts pipe.readlines.size - end - -Output: - - 1111 - -**Program Subprocess with `argv0`** - -When argument `cmd` is an array whose first element is a 2-element string -array and whose remaining elements (if any) are strings: - -* `cmd[0][0]` (the first string in the nested array) is the name of a - program that is run. -* `cmd[0][1]` (the second string in the nested array) is set as the - program's `argv[0]`. -* `cmd[1..-1]` (the strings in the outer array) are the program's arguments. - -Example (sets `$0` to 'foo'): - - IO.popen([['/bin/sh', 'foo'], '-c', 'echo $0']).read # => "foo\n" - -**Some Special Examples** - - # Set IO encoding. - IO.popen("nkf -e filename", :external_encoding=>"EUC-JP") {|nkf_io| - euc_jp_string = nkf_io.read - } - - # Merge standard output and standard error using Kernel#spawn option. See Kernel#spawn. - IO.popen(["ls", "/", :err=>[:child, :out]]) do |io| - ls_result_with_error = io.read - end - - # Use mixture of spawn options and IO options. - IO.popen(["ls", "/"], :err=>[:child, :out]) do |io| - ls_result_with_error = io.read - end - - f = IO.popen("uname") - p f.readlines - f.close - puts "Parent is #{Process.pid}" - IO.popen("date") {|f| puts f.gets } - IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f.inspect}"} - p $? - IO.popen(%w"sed -e s|^|| -e s&$&;zot;&", "r+") {|f| - f.puts "bar"; f.close_write; puts f.gets - } - -Output (from last section): - - ["Linux\n"] - Parent is 21346 - Thu Jan 15 22:41:19 JST 2009 - 21346 is here, f is # - 21352 is here, f is nil - # - bar;zot; - -Raises exceptions that IO.pipe and Kernel.spawn raise. -**@overload** [] - -**@overload** [] - -## pread(*args ) [](#method-c-pread) -## read(*args ) [](#method-c-read) -Opens the stream, reads and returns some or all of its content, and closes the -stream; returns `nil` if no bytes were read. - -When called from class IO (but not subclasses of IO), this method has -potential security vulnerabilities if called with untrusted input; see -[Command Injection](rdoc-ref:command_injection.rdoc). - -The first argument must be a string that is the path to a file. - -With only argument `path` given, reads in text mode and returns the entire -content of the file at the given path: - - IO.read('t.txt') - # => "First line\nSecond line\n\nThird line\nFourth line\n" - -On Windows, text mode can terminate reading and leave bytes in the file unread -when encountering certain special bytes. Consider using IO.binread if all -bytes in the file should be read. - -With argument `length`, returns `length` bytes if available: - - IO.read('t.txt', 7) # => "First l" - IO.read('t.txt', 700) - # => "First line\r\nSecond line\r\n\r\nFourth line\r\nFifth line\r\n" - -With arguments `length` and `offset`, returns `length` bytes if available, -beginning at the given `offset`: - - IO.read('t.txt', 10, 2) # => "rst line\nS" - IO.read('t.txt', 10, 200) # => nil - -Optional keyword arguments `opts` specify: - -* [Open Options](rdoc-ref:IO@Open+Options). -* [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). -**@overload** [] - -## readlines(*args ) [](#method-c-readlines) -Returns an array of all lines read from the stream. - -When called from class IO (but not subclasses of IO), this method has -potential security vulnerabilities if called with untrusted input; see -[Command Injection](rdoc-ref:command_injection.rdoc). - -The first argument must be a string that is the path to a file. - -With only argument `path` given, parses lines from the file at the given -`path`, as determined by the default line separator, and returns those lines -in an array: - - IO.readlines('t.txt') - # => ["First line\n", "Second line\n", "\n", "Third line\n", "Fourth line\n"] - -With argument `sep` given, parses lines as determined by that line separator -(see [Line Separator](rdoc-ref:IO@Line+Separator)): - - # Ordinary separator. - IO.readlines('t.txt', 'li') - # =>["First li", "ne\nSecond li", "ne\n\nThird li", "ne\nFourth li", "ne\n"] - # Get-paragraphs separator. - IO.readlines('t.txt', '') - # => ["First line\nSecond line\n\n", "Third line\nFourth line\n"] - # Get-all separator. - IO.readlines('t.txt', nil) - # => ["First line\nSecond line\n\nThird line\nFourth line\n"] - -With argument `limit` given, parses lines as determined by the default line -separator and the given line-length limit (see [Line -Separator](rdoc-ref:IO@Line+Separator) and [Line -Limit](rdoc-ref:IO@Line+Limit): - - IO.readlines('t.txt', 7) - # => ["First l", "ine\n", "Second ", "line\n", "\n", "Third l", "ine\n", "Fourth ", "line\n"] - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword arguments `opts` specify: - -* [Open Options](rdoc-ref:IO@Open+Options). -* [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). -* [Line Options](rdoc-ref:IO@Line+IO). -**@overload** [] - -**@overload** [] - -**@overload** [] - -## select(*args ) [](#method-c-select) -Invokes system call [select(2)](https://linux.die.net/man/2/select), which -monitors multiple file descriptors, waiting until one or more of the file -descriptors becomes ready for some class of I/O operation. - -Not implemented on all platforms. - -Each of the arguments `read_ios`, `write_ios`, and `error_ios` is an array of -IO objects. - -Argument `timeout` is a numeric value (such as integer or float) timeout -interval in seconds. - -The method monitors the IO objects given in all three arrays, waiting for some -to be ready; returns a 3-element array whose elements are: - -* An array of the objects in `read_ios` that are ready for reading. -* An array of the objects in `write_ios` that are ready for writing. -* An array of the objects in `error_ios` have pending exceptions. - -If no object becomes ready within the given `timeout`, `nil` is returned. - -IO.select peeks the buffer of IO objects for testing readability. If the IO -buffer is not empty, IO.select immediately notifies readability. This "peek" -only happens for IO objects. It does not happen for IO-like objects such as -OpenSSL::SSL::SSLSocket. - -The best way to use IO.select is invoking it after non-blocking methods such -as #read_nonblock, #write_nonblock, etc. The methods raise an exception which -is extended by IO::WaitReadable or IO::WaitWritable. The modules notify how -the caller should wait with IO.select. If IO::WaitReadable is raised, the -caller should wait for reading. If IO::WaitWritable is raised, the caller -should wait for writing. - -So, blocking read (#readpartial) can be emulated using #read_nonblock and -IO.select as follows: - - begin - result = io_like.read_nonblock(maxlen) - rescue IO::WaitReadable - IO.select([io_like]) - retry - rescue IO::WaitWritable - IO.select(nil, [io_like]) - retry - end - -Especially, the combination of non-blocking methods and IO.select is preferred -for IO like objects such as OpenSSL::SSL::SSLSocket. It has #to_io method to -return underlying IO object. IO.select calls #to_io to obtain the file -descriptor to wait. - -This means that readability notified by IO.select doesn't mean readability -from OpenSSL::SSL::SSLSocket object. - -The most likely situation is that OpenSSL::SSL::SSLSocket buffers some data. -IO.select doesn't see the buffer. So IO.select can block when -OpenSSL::SSL::SSLSocket#readpartial doesn't block. - -However, several more complicated situations exist. - -SSL is a protocol which is sequence of records. The record consists of -multiple bytes. So, the remote side of SSL sends a partial record, IO.select -notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a byte and -OpenSSL::SSL::SSLSocket#readpartial will block. - -Also, the remote side can request SSL renegotiation which forces the local SSL -engine to write some data. This means OpenSSL::SSL::SSLSocket#readpartial may -invoke #write system call and it can block. In such a situation, -OpenSSL::SSL::SSLSocket#read_nonblock raises IO::WaitWritable instead of -blocking. So, the caller should wait for ready for writability as above -example. - -The combination of non-blocking methods and IO.select is also useful for -streams such as tty, pipe socket socket when multiple processes read from a -stream. - -Finally, Linux kernel developers don't guarantee that readability of select(2) -means readability of following read(2) even for a single process; see -[select(2)](https://linux.die.net/man/2/select) - -Invoking IO.select before IO#readpartial works well as usual. However it is -not the best way to use IO.select. - -The writability notified by select(2) doesn't show how many bytes are -writable. IO#write method blocks until given whole string is written. So, -`IO#write(two or more bytes)` can block after writability is notified by -IO.select. IO#write_nonblock is required to avoid the blocking. - -Blocking write (#write) can be emulated using #write_nonblock and IO.select as -follows: IO::WaitReadable should also be rescued for SSL renegotiation in -OpenSSL::SSL::SSLSocket. - - while 0 < string.bytesize - begin - written = io_like.write_nonblock(string) - rescue IO::WaitReadable - IO.select([io_like]) - retry - rescue IO::WaitWritable - IO.select(nil, [io_like]) - retry - end - string = string.byteslice(written..-1) - end - -Example: - - rp, wp = IO.pipe - mesg = "ping " - 100.times { - # IO.select follows IO#read. Not the best way to use IO.select. - rs, ws, = IO.select([rp], [wp]) - if r = rs[0] - ret = r.read(5) - print ret - case ret - when /ping/ - mesg = "pong\n" - when /pong/ - mesg = "ping " - end - end - if w = ws[0] - w.write(mesg) - end - } - -Output: - - ping pong - ping pong - ping pong - (snipped) - ping -**@overload** [] - -## sysopen(*args ) [](#method-c-sysopen) -Opens the file at the given path with the given mode and permissions; returns -the integer file descriptor. - -If the file is to be readable, it must exist; if the file is to be writable -and does not exist, it is created with the given permissions: - - File.write('t.tmp', '') # => 0 - IO.sysopen('t.tmp') # => 8 - IO.sysopen('t.tmp', 'w') # => 9 -**@overload** [] - -## thread_fd_close(fd ) [](#method-c-thread_fd_close) -## thread_fd_wait(fd ) [](#method-c-thread_fd_wait) -## thread_fd_writable(fd ) [](#method-c-thread_fd_writable) -## try_convert(io ) [](#method-c-try_convert) -Attempts to convert `object` into an IO object via method `to_io`; returns the -new IO object if successful, or `nil` otherwise: - - IO.try_convert(STDOUT) # => #> - IO.try_convert(ARGF) # => #> - IO.try_convert('STDOUT') # => nil -**@overload** [] - -## write(*args ) [](#method-c-write) -Opens the stream, writes the given `data` to it, and closes the stream; -returns the number of bytes written. - -When called from class IO (but not subclasses of IO), this method has -potential security vulnerabilities if called with untrusted input; see -[Command Injection](rdoc-ref:command_injection.rdoc). - -The first argument must be a string that is the path to a file. - -With only argument `path` given, writes the given `data` to the file at that -path: - - IO.write('t.tmp', 'abc') # => 3 - File.read('t.tmp') # => "abc" - -If `offset` is zero (the default), the file is overwritten: - - IO.write('t.tmp', 'A') # => 1 - File.read('t.tmp') # => "A" - -If `offset` in within the file content, the file is partly overwritten: - - IO.write('t.tmp', 'abcdef') # => 3 - File.read('t.tmp') # => "abcdef" - # Offset within content. - IO.write('t.tmp', '012', 2) # => 3 - File.read('t.tmp') # => "ab012f" - -If `offset` is outside the file content, the file is padded with null -characters `"\u0000"`: - - IO.write('t.tmp', 'xyz', 10) # => 3 - File.read('t.tmp') # => "ab012f\u0000\u0000\u0000\u0000xyz" - -Optional keyword arguments `opts` specify: - -* [Open Options](rdoc-ref:IO@Open+Options). -* [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). -**@overload** [] - - -#Instance Methods -## <<(str) [](#method-i-<<) -Writes the given `object` to `self`, which must be opened for writing (see -[Access Modes](rdoc-ref:File@Access+Modes)); returns `self`; if `object` is -not a string, it is converted via method `to_s`: - - $stdout << 'Hello' << ', ' << 'World!' << "\n" - $stdout << 'foo' << :bar << 2 << "\n" - -Output: - - Hello, World! - foobar2 - -**@overload** [] - -## advise(*args) [](#method-i-advise) -Invokes Posix system call -[posix_fadvise(2)](https://linux.die.net/man/2/posix_fadvise), which announces -an intention to access data from the current file in a particular manner. - -The arguments and results are platform-dependent. - -The relevant data is specified by: - -* `offset`: The offset of the first byte of data. -* `len`: The number of bytes to be accessed; if `len` is zero, or is larger - than the number of bytes remaining, all remaining bytes will be accessed. - -Argument `advice` is one of the following symbols: - -* `:normal`: The application has no advice to give about its access pattern - for the specified data. If no advice is given for an open file, this is - the default assumption. -* `:sequential`: The application expects to access the specified data - sequentially (with lower offsets read before higher ones). -* `:random`: The specified data will be accessed in random order. -* `:noreuse`: The specified data will be accessed only once. -* `:willneed`: The specified data will be accessed in the near future. -* `:dontneed`: The specified data will not be accessed in the near future. - -Not implemented on all platforms. - -**@overload** [] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## autoclose=(autoclose) [](#method-i-autoclose=) -Sets auto-close flag. - - f = File.open(File::NULL) - IO.for_fd(f.fileno).close - f.gets # raises Errno::EBADF - - f = File.open(File::NULL) - g = IO.for_fd(f.fileno) - g.autoclose = false - g.close - f.gets # won't cause Errno::EBADF - -**@overload** [] - -## autoclose?() [](#method-i-autoclose?) -Returns `true` if the underlying file descriptor of *ios* will be closed at -its finalization or at calling #close, otherwise `false`. - -**@overload** [] - -## beep() [](#method-i-beep) -Beeps on the output console. - -You must require 'io/console' to use this method. - -**@overload** [] - -## binmode() [](#method-i-binmode) -Sets the stream's data mode as binary (see [Data -Mode](rdoc-ref:File@Data+Mode)). - -A stream's data mode may not be changed from binary to text. - -**@overload** [] - -## binmode?() [](#method-i-binmode?) -Returns `true` if the stream is on binary mode, `false` otherwise. See [Data -Mode](rdoc-ref:File@Data+Mode). - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## check_winsize_changed() [](#method-i-check_winsize_changed) -Yields while console input events are queued. - -This method is Windows only. - -You must require 'io/console' to use this method. - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## clear_screen() [](#method-i-clear_screen) -Clears the entire screen and moves the cursor top-left corner. - -You must require 'io/console' to use this method. - -**@overload** [] - -## close() [](#method-i-close) -Closes the stream for both reading and writing if open for either or both; -returns `nil`. See [Open and Closed -Streams](rdoc-ref:IO@Open+and+Closed+Streams). - -If the stream is open for writing, flushes any buffered writes to the -operating system before closing. - -If the stream was opened by IO.popen, sets global variable `$?` (child exit -status). - -It is not an error to close an IO object that has already been closed. It just -returns nil. - -Example: - - IO.popen('ruby', 'r+') do |pipe| - puts pipe.closed? - pipe.close - puts $? - puts pipe.closed? - end - -Output: - - false - pid 13760 exit 0 - true - -Related: IO#close_read, IO#close_write, IO#closed?. - -**@overload** [] - -## close_on_exec=(arg) [](#method-i-close_on_exec=) -Sets a close-on-exec flag. - - f = File.open(File::NULL) - f.close_on_exec = true - system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory - f.closed? #=> false - -Ruby sets close-on-exec flags of all file descriptors by default since Ruby -2.0.0. So you don't need to set by yourself. Also, unsetting a close-on-exec -flag can cause file descriptor leak if another thread use fork() and exec() -(via system() method for example). If you really needs file descriptor -inheritance to child process, use spawn()'s argument such as fd=>fd. - -**@overload** [] - -## close_on_exec?() [](#method-i-close_on_exec?) -Returns `true` if the stream will be closed on exec, `false` otherwise: - - f = File.open('t.txt') - f.close_on_exec? # => true - f.close_on_exec = false - f.close_on_exec? # => false - f.close - -**@overload** [] - -## close_read() [](#method-i-close_read) -Closes the stream for reading if open for reading; returns `nil`. See [Open -and Closed Streams](rdoc-ref:IO@Open+and+Closed+Streams). - -If the stream was opened by IO.popen and is also closed for writing, sets -global variable `$?` (child exit status). - -Example: - - IO.popen('ruby', 'r+') do |pipe| - puts pipe.closed? - pipe.close_write - puts pipe.closed? - pipe.close_read - puts $? - puts pipe.closed? - end - -Output: - - false - false - pid 14748 exit 0 - true - -Related: IO#close, IO#close_write, IO#closed?. - -**@overload** [] - -## close_write() [](#method-i-close_write) -Closes the stream for writing if open for writing; returns `nil`. See [Open -and Closed Streams](rdoc-ref:IO@Open+and+Closed+Streams). - -Flushes any buffered writes to the operating system before closing. - -If the stream was opened by IO.popen and is also closed for reading, sets -global variable `$?` (child exit status). - - IO.popen('ruby', 'r+') do |pipe| - puts pipe.closed? - pipe.close_read - puts pipe.closed? - pipe.close_write - puts $? - puts pipe.closed? - end - -Output: - - false - false - pid 15044 exit 0 - true - -Related: IO#close, IO#close_read, IO#closed?. - -**@overload** [] - -## closed?() [](#method-i-closed?) -Returns `true` if the stream is closed for both reading and writing, `false` -otherwise. See [Open and Closed Streams](rdoc-ref:IO@Open+and+Closed+Streams). - - IO.popen('ruby', 'r+') do |pipe| - puts pipe.closed? - pipe.close_read - puts pipe.closed? - pipe.close_write - puts pipe.closed? - end - -Output: - - false - false - true - -Related: IO#close_read, IO#close_write, IO#close. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## console_mode() [](#method-i-console_mode) -Returns a data represents the current console mode. - -You must require 'io/console' to use this method. - -**@overload** [] - -## console_mode=(mode) [](#method-i-console_mode=) -Sets the console mode to `mode`. - -You must require 'io/console' to use this method. - -**@overload** [] - -## cooked() [](#method-i-cooked) -Yields `self` within cooked mode. - - STDIN.cooked(&:gets) - -will read and return a line with echo back and line editing. - -You must require 'io/console' to use this method. - -**@overload** [] - -## cooked!() [](#method-i-cooked!) -Enables cooked mode. - -If the terminal mode needs to be back, use io.cooked { ... }. - -You must require 'io/console' to use this method. - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cursor() [](#method-i-cursor) -Returns the current cursor position as a two-element array of integers (row, -column) - - io.cursor # => [3, 5] - -You must require 'io/console' to use this method. - -**@overload** [] - -## cursor=(cpos) [](#method-i-cursor=) -Same as `io.goto(line, column)` - -See IO#goto. - -You must require 'io/console' to use this method. - -## cursor_down(val) [](#method-i-cursor_down) -Moves the cursor down `n` lines. - -You must require 'io/console' to use this method. - -**@overload** [] - -## cursor_left(val) [](#method-i-cursor_left) -Moves the cursor left `n` columns. - -You must require 'io/console' to use this method. - -**@overload** [] - -## cursor_right(val) [](#method-i-cursor_right) -Moves the cursor right `n` columns. - -You must require 'io/console' to use this method. - -**@overload** [] - -## cursor_up(val) [](#method-i-cursor_up) -Moves the cursor up `n` lines. - -You must require 'io/console' to use this method. - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(*args) [](#method-i-each) -Calls the block with each remaining line read from the stream; returns `self`. -Does nothing if already at end-of-stream; See [Line IO](rdoc-ref:IO@Line+IO). - -With no arguments given, reads lines as determined by line separator `$/`: - - f = File.new('t.txt') - f.each_line {|line| p line } - f.each_line {|line| fail 'Cannot happen' } - f.close - -Output: - - "First line\n" - "Second line\n" - "\n" - "Fourth line\n" - "Fifth line\n" - -With only string argument `sep` given, reads lines as determined by line -separator `sep`; see [Line Separator](rdoc-ref:IO@Line+Separator): - - f = File.new('t.txt') - f.each_line('li') {|line| p line } - f.close - -Output: - - "First li" - "ne\nSecond li" - "ne\n\nFourth li" - "ne\nFifth li" - "ne\n" - -The two special values for `sep` are honored: - - f = File.new('t.txt') - # Get all into one string. - f.each_line(nil) {|line| p line } - f.close - -Output: - - "First line\nSecond line\n\nFourth line\nFifth line\n" - - f.rewind - # Get paragraphs (up to two line separators). - f.each_line('') {|line| p line } - -Output: - - "First line\nSecond line\n\n" - "Fourth line\nFifth line\n" - -With only integer argument `limit` given, limits the number of bytes in each -line; see [Line Limit](rdoc-ref:IO@Line+Limit): - - f = File.new('t.txt') - f.each_line(8) {|line| p line } - f.close - -Output: - - "First li" - "ne\n" - "Second l" - "ine\n" - "\n" - "Fourth l" - "ine\n" - "Fifth li" - "ne\n" - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted: - - f = File.new('t.txt') - f.each_line(chomp: true) {|line| p line } - f.close - -Output: - - "First line" - "Second line" - "" - "Fourth line" - "Fifth line" - -Returns an Enumerator if no block is given. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## each_byte() [](#method-i-each_byte) -Calls the given block with each byte (0..255) in the stream; returns `self`. -See [Byte IO](rdoc-ref:IO@Byte+IO). - - f = File.new('t.rus') - a = [] - f.each_byte {|b| a << b } - a # => [209, 130, 208, 181, 209, 129, 209, 130] - f.close - -Returns an Enumerator if no block is given. - -Related: IO#each_char, IO#each_codepoint. - -**@overload** [] - -**@overload** [] - -## each_char() [](#method-i-each_char) -Calls the given block with each character in the stream; returns `self`. See -[Character IO](rdoc-ref:IO@Character+IO). - - f = File.new('t.rus') - a = [] - f.each_char {|c| a << c.ord } - a # => [1090, 1077, 1089, 1090] - f.close - -Returns an Enumerator if no block is given. - -Related: IO#each_byte, IO#each_codepoint. - -**@overload** [] - -**@overload** [] - -## each_codepoint() [](#method-i-each_codepoint) -Calls the given block with each codepoint in the stream; returns `self`: - - f = File.new('t.rus') - a = [] - f.each_codepoint {|c| a << c } - a # => [1090, 1077, 1089, 1090] - f.close - -Returns an Enumerator if no block is given. - -Related: IO#each_byte, IO#each_char. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_line(*args) [](#method-i-each_line) -Calls the block with each remaining line read from the stream; returns `self`. -Does nothing if already at end-of-stream; See [Line IO](rdoc-ref:IO@Line+IO). - -With no arguments given, reads lines as determined by line separator `$/`: - - f = File.new('t.txt') - f.each_line {|line| p line } - f.each_line {|line| fail 'Cannot happen' } - f.close - -Output: - - "First line\n" - "Second line\n" - "\n" - "Fourth line\n" - "Fifth line\n" - -With only string argument `sep` given, reads lines as determined by line -separator `sep`; see [Line Separator](rdoc-ref:IO@Line+Separator): - - f = File.new('t.txt') - f.each_line('li') {|line| p line } - f.close - -Output: - - "First li" - "ne\nSecond li" - "ne\n\nFourth li" - "ne\nFifth li" - "ne\n" - -The two special values for `sep` are honored: - - f = File.new('t.txt') - # Get all into one string. - f.each_line(nil) {|line| p line } - f.close - -Output: - - "First line\nSecond line\n\nFourth line\nFifth line\n" - - f.rewind - # Get paragraphs (up to two line separators). - f.each_line('') {|line| p line } - -Output: - - "First line\nSecond line\n\n" - "Fourth line\nFifth line\n" - -With only integer argument `limit` given, limits the number of bytes in each -line; see [Line Limit](rdoc-ref:IO@Line+Limit): - - f = File.new('t.txt') - f.each_line(8) {|line| p line } - f.close - -Output: - - "First li" - "ne\n" - "Second l" - "ine\n" - "\n" - "Fourth l" - "ine\n" - "Fifth li" - "ne\n" - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted: - - f = File.new('t.txt') - f.each_line(chomp: true) {|line| p line } - f.close - -Output: - - "First line" - "Second line" - "" - "Fourth line" - "Fifth line" - -Returns an Enumerator if no block is given. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## echo=(f) [](#method-i-echo=) -Enables/disables echo back. On some platforms, all combinations of this flags -and raw/cooked mode may not be valid. - -You must require 'io/console' to use this method. - -**@overload** [] - -## echo?() [](#method-i-echo?) -Returns `true` if echo back is enabled. - -You must require 'io/console' to use this method. - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eof() [](#method-i-eof) -Returns `true` if the stream is positioned at its end, `false` otherwise; see -[Position](rdoc-ref:IO@Position): - - f = File.open('t.txt') - f.eof # => false - f.seek(0, :END) # => 0 - f.eof # => true - f.close - -Raises an exception unless the stream is opened for reading; see -[Mode](rdoc-ref:File@Access+Modes). - -If `self` is a stream such as pipe or socket, this method blocks until the -other end sends some data or closes it: - - r, w = IO.pipe - Thread.new { sleep 1; w.close } - r.eof? # => true # After 1-second wait. - - r, w = IO.pipe - Thread.new { sleep 1; w.puts "a" } - r.eof? # => false # After 1-second wait. - - r, w = IO.pipe - r.eof? # blocks forever - -Note that this method reads data to the input byte buffer. So IO#sysread may -not behave as you intend with IO#eof?, unless you call IO#rewind first (which -is not available for some streams). - -**@overload** [] - -## eof?() [](#method-i-eof?) -Returns `true` if the stream is positioned at its end, `false` otherwise; see -[Position](rdoc-ref:IO@Position): - - f = File.open('t.txt') - f.eof # => false - f.seek(0, :END) # => 0 - f.eof # => true - f.close - -Raises an exception unless the stream is opened for reading; see -[Mode](rdoc-ref:File@Access+Modes). - -If `self` is a stream such as pipe or socket, this method blocks until the -other end sends some data or closes it: - - r, w = IO.pipe - Thread.new { sleep 1; w.close } - r.eof? # => true # After 1-second wait. - - r, w = IO.pipe - Thread.new { sleep 1; w.puts "a" } - r.eof? # => false # After 1-second wait. - - r, w = IO.pipe - r.eof? # blocks forever - -Note that this method reads data to the input byte buffer. So IO#sysread may -not behave as you intend with IO#eof?, unless you call IO#rewind first (which -is not available for some streams). - -**@overload** [] - -## erase_line(val) [](#method-i-erase_line) -Erases the line at the cursor corresponding to `mode`. `mode` may be either: -0: after cursor 1: before and cursor 2: entire line - -You must require 'io/console' to use this method. - -**@overload** [] - -## erase_screen(val) [](#method-i-erase_screen) -Erases the screen at the cursor corresponding to `mode`. `mode` may be either: -0: after cursor 1: before and cursor 2: entire screen - -You must require 'io/console' to use this method. - -**@overload** [] - -## expect(pat, timeout9999999) [](#method-i-expect) -call-seq: - IO#expect(pattern,timeout=9999999) -> Array - IO#expect(pattern,timeout=9999999) { |result| ... } -> nil - -The `expect` library adds instance method IO#expect, which is similar to the -[TCL expect extension](https://www.tcl.tk/man/expect5.31/expect.1.html). - -To use this method, you must require `expect`: - - require 'expect' - -Reads from the IO until the given `pattern` matches or the `timeout` is over. - -It returns an array with the read buffer, followed by the matches. If a block -is given, the result is yielded to the block and returns nil. - -When called without a block, it waits until the input that matches the given -`pattern` is obtained from the IO or the time specified as the timeout passes. -An array is returned when the pattern is obtained from the IO. The first -element of the array is the entire string obtained from the IO until the -pattern matches, followed by elements indicating which the pattern which -matched to the anchor in the regular expression. - -The optional timeout parameter defines, in seconds, the total time to wait for -the pattern. If the timeout expires or eof is found, nil is returned or -yielded. However, the buffer in a timeout session is kept for the next expect -call. The default timeout is 9999999 seconds. - -## external_encoding() [](#method-i-external_encoding) -Returns the Encoding object that represents the encoding of the stream, or -`nil` if the stream is in write mode and no encoding is specified. - -See [Encodings](rdoc-ref:File@Encodings). - -**@overload** [] - -## fcntl(*args) [](#method-i-fcntl) -Invokes Posix system call [fcntl(2)](https://linux.die.net/man/2/fcntl), which -provides a mechanism for issuing low-level commands to control or query a -file-oriented I/O stream. Arguments and results are platform dependent. - -If `argument` is a number, its value is passed directly; if it is a string, it -is interpreted as a binary sequence of bytes. (Array#pack might be a useful -way to build this string.) - -Not implemented on all platforms. - -**@overload** [] - -## fdatasync() [](#method-i-fdatasync) -Immediately writes to disk all data buffered in the stream, via the operating -system's: `fdatasync(2)`, if supported, otherwise via `fsync(2)`, if -supported; otherwise raises an exception. - -**@overload** [] - -## fileno() [](#method-i-fileno) -Returns the integer file descriptor for the stream: - - $stdin.fileno # => 0 - $stdout.fileno # => 1 - $stderr.fileno # => 2 - File.open('t.txt').fileno # => 10 - f.close - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flush() [](#method-i-flush) -Flushes data buffered in `self` to the operating system (but does not -necessarily flush data buffered in the operating system): - - $stdout.print 'no newline' # Not necessarily flushed. - $stdout.flush # Flushed. - -**@overload** [] - -## fsync() [](#method-i-fsync) -Immediately writes to disk all data buffered in the stream, via the operating -system's `fsync(2)`. - -Note this difference: - -* IO#sync=: Ensures that data is flushed from the stream's internal buffers, - but does not guarantee that the operating system actually writes the data - to disk. -* IO#fsync: Ensures both that data is flushed from internal buffers, and - that data is written to disk. - -Raises an exception if the operating system does not support `fsync(2)`. - -**@overload** [] - -## getbyte() [](#method-i-getbyte) -Reads and returns the next byte (in range 0..255) from the stream; returns -`nil` if already at end-of-stream. See [Byte IO](rdoc-ref:IO@Byte+IO). - - f = File.open('t.txt') - f.getbyte # => 70 - f.close - f = File.open('t.rus') - f.getbyte # => 209 - f.close - -Related: IO#readbyte (may raise EOFError). - -**@overload** [] - -## getc() [](#method-i-getc) -Reads and returns the next 1-character string from the stream; returns `nil` -if already at end-of-stream. See [Character IO](rdoc-ref:IO@Character+IO). - - f = File.open('t.txt') - f.getc # => "F" - f.close - f = File.open('t.rus') - f.getc.ord # => 1090 - f.close - -Related: IO#readchar (may raise EOFError). - -**@overload** [] - -## getch(*args) [](#method-i-getch) -Reads and returns a character in raw mode. - -See IO#raw for details on the parameters. - -You must require 'io/console' to use this method. - -**@overload** [] - -## getpass(*args) [](#method-i-getpass) -Reads and returns a line without echo back. Prints `prompt` unless it is -`nil`. - -The newline character that terminates the read line is removed from the -returned string, see String#chomp!. - -You must require 'io/console' to use this method. - - require 'io/console' - IO::console.getpass("Enter password:") - Enter password: - # => "mypassword" - -**@overload** [] - -## gets(*args) [](#method-i-gets) -Reads and returns a line from the stream; assigns the return value to `$_`. -See [Line IO](rdoc-ref:IO@Line+IO). - -With no arguments given, returns the next line as determined by line separator -`$/`, or `nil` if none: - - f = File.open('t.txt') - f.gets # => "First line\n" - $_ # => "First line\n" - f.gets # => "\n" - f.gets # => "Fourth line\n" - f.gets # => "Fifth line\n" - f.gets # => nil - f.close - -With only string argument `sep` given, returns the next line as determined by -line separator `sep`, or `nil` if none; see [Line -Separator](rdoc-ref:IO@Line+Separator): - - f = File.new('t.txt') - f.gets('l') # => "First l" - f.gets('li') # => "ine\nSecond li" - f.gets('lin') # => "ne\n\nFourth lin" - f.gets # => "e\n" - f.close - -The two special values for `sep` are honored: - - f = File.new('t.txt') - # Get all. - f.gets(nil) # => "First line\nSecond line\n\nFourth line\nFifth line\n" - f.rewind - # Get paragraph (up to two line separators). - f.gets('') # => "First line\nSecond line\n\n" - f.close - -With only integer argument `limit` given, limits the number of bytes in the -line; see [Line Limit](rdoc-ref:IO@Line+Limit): - - # No more than one line. - File.open('t.txt') {|f| f.gets(10) } # => "First line" - File.open('t.txt') {|f| f.gets(11) } # => "First line\n" - File.open('t.txt') {|f| f.gets(12) } # => "First line\n" - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted: - - f = File.open('t.txt') - # Chomp the lines. - f.gets(chomp: true) # => "First line" - f.gets(chomp: true) # => "Second line" - f.gets(chomp: true) # => "" - f.gets(chomp: true) # => "Fourth line" - f.gets(chomp: true) # => "Fifth line" - f.gets(chomp: true) # => nil - f.close - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## goto(y, x) [](#method-i-goto) -Set the cursor position at `line` and `column`. - -You must require 'io/console' to use this method. - -**@overload** [] - -## goto_column(val) [](#method-i-goto_column) -Set the cursor position at `column` in the same line of the current position. - -You must require 'io/console' to use this method. - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## iflush() [](#method-i-iflush) -Flushes input buffer in kernel. - -You must require 'io/console' to use this method. - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates and returns a new IO object (file stream) from a file descriptor. - -IO.new may be useful for interaction with low-level libraries. For -higher-level interactions, it may be simpler to create the file stream using -File.open. - -Argument `fd` must be a valid file descriptor (integer): - - path = 't.tmp' - fd = IO.sysopen(path) # => 3 - IO.new(fd) # => # - -The new IO object does not inherit encoding (because the integer file -descriptor does not have an encoding): - - fd = IO.sysopen('t.rus', 'rb') - io = IO.new(fd) - io.external_encoding # => # # Not ASCII-8BIT. - -Optional argument `mode` (defaults to 'r') must specify a valid mode; see -[Access Modes](rdoc-ref:File@Access+Modes): - - IO.new(fd, 'w') # => # - IO.new(fd, File::WRONLY) # => # - -Optional keyword arguments `opts` specify: - -* [Open Options](rdoc-ref:IO@Open+Options). -* [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). - -Examples: - - IO.new(fd, internal_encoding: nil) # => # - IO.new(fd, autoclose: true) # => # - -**@overload** [] - -## initialize_copy(io) [](#method-i-initialize_copy) -:nodoc: - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - f = File.open('t.txt') - f.inspect # => "#" - f.close - -**@overload** [] - -## internal_encoding() [](#method-i-internal_encoding) -Returns the Encoding object that represents the encoding of the internal -string, if conversion is specified, or `nil` otherwise. - -See [Encodings](rdoc-ref:File@Encodings). - -**@overload** [] - -## ioctl(*args) [](#method-i-ioctl) -Invokes Posix system call [ioctl(2)](https://linux.die.net/man/2/ioctl), which -issues a low-level command to an I/O device. - -Issues a low-level command to an I/O device. The arguments and returned value -are platform-dependent. The effect of the call is platform-dependent. - -If argument `argument` is an integer, it is passed directly; if it is a -string, it is interpreted as a binary sequence of bytes. - -Not implemented on all platforms. - -**@overload** [] - -## ioflush() [](#method-i-ioflush) -Flushes input and output buffers in kernel. - -You must require 'io/console' to use this method. - -**@overload** [] - -## isatty() [](#method-i-isatty) -Returns `true` if the stream is associated with a terminal device (tty), -`false` otherwise: - - f = File.new('t.txt').isatty #=> false - f.close - f = File.new('/dev/tty').isatty #=> true - f.close - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## lineno() [](#method-i-lineno) -Returns the current line number for the stream; see [Line -Number](rdoc-ref:IO@Line+Number). - -**@overload** [] - -## lineno=(lineno) [](#method-i-lineno=) -Sets and returns the line number for the stream; see [Line -Number](rdoc-ref:IO@Line+Number). - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## noecho() [](#method-i-noecho) -Yields `self` with disabling echo back. - - STDIN.noecho(&:gets) - -will read and return a line without echo back. - -You must require 'io/console' to use this method. - -**@overload** [] - -## nonblock(*args) [](#method-i-nonblock) -Yields `self` in non-blocking mode. - -When `false` is given as an argument, `self` is yielded in blocking mode. The -original mode is restored after the block is executed. - -**@overload** [] - -**@overload** [] - -## nonblock=(value) [](#method-i-nonblock=) -Enables non-blocking mode on a stream when set to `true`, and blocking mode -when set to `false`. - -This method set or clear O_NONBLOCK flag for the file descriptor in *ios*. - -The behavior of most IO methods is not affected by this flag because they -retry system calls to complete their task after EAGAIN and partial read/write. -(An exception is IO#syswrite which doesn't retry.) - -This method can be used to clear non-blocking mode of standard I/O. Since -nonblocking methods (read_nonblock, etc.) set non-blocking mode but they -doesn't clear it, this method is usable as follows. - - END { STDOUT.nonblock = false } - STDOUT.write_nonblock("foo") - -Since the flag is shared across processes and many non-Ruby commands doesn't -expect standard I/O with non-blocking mode, it would be safe to clear the flag -before Ruby program exits. - -For example following Ruby program leaves STDIN/STDOUT/STDER non-blocking -mode. (STDIN, STDOUT and STDERR are connected to a terminal. So making one of -them nonblocking-mode effects other two.) Thus cat command try to read from -standard input and it causes "Resource temporarily unavailable" error -(EAGAIN). - - % ruby -e ' - STDOUT.write_nonblock("foo\n")'; cat - foo - cat: -: Resource temporarily unavailable - -Clearing the flag makes the behavior of cat command normal. (cat command waits -input from standard input.) - - % ruby -rio/nonblock -e ' - END { STDOUT.nonblock = false } - STDOUT.write_nonblock("foo") - '; cat - foo - -**@overload** [] - -## nonblock?() [](#method-i-nonblock?) -Returns `true` if an IO object is in non-blocking mode. - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## nread() [](#method-i-nread) -Returns number of bytes that can be read without blocking. Returns zero if no -information available. - -You must require 'io/wait' to use this method. - -**@overload** [] - -## oflush() [](#method-i-oflush) -Flushes output buffer in kernel. - -You must require 'io/console' to use this method. - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## path() [](#method-i-path) -Returns the path associated with the IO, or `nil` if there is no path -associated with the IO. It is not guaranteed that the path exists on the -filesystem. - - $stdin.path # => "" - - File.open("testfile") {|f| f.path} # => "testfile" - -**@overload** [] - -## pathconf(arg) [](#method-i-pathconf) -pathconf(name) -> Integer - -Returns pathname configuration variable using fpathconf(). - -*name* should be a constant under `Etc` which begins with `PC_`. - -The return value is an integer or nil. nil means indefinite limit. -(fpathconf() returns -1 but errno is not set.) - - require 'etc' - IO.pipe {|r, w| - p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096 - } - -## pid() [](#method-i-pid) -Returns the process ID of a child process associated with the stream, which -will have been set by IO#popen, or `nil` if the stream was not created by -IO#popen: - - pipe = IO.popen("-") - if pipe - $stderr.puts "In parent, child pid is #{pipe.pid}" - else - $stderr.puts "In child, pid is #{$$}" - end - -Output: - - In child, pid is 26209 - In parent, child pid is 26209 - -**@overload** [] - -## pos() [](#method-i-pos) -Returns the current position (in bytes) in `self` (see -[Position](rdoc-ref:IO@Position)): - - f = File.open('t.txt') - f.tell # => 0 - f.gets # => "First line\n" - f.tell # => 12 - f.close - -Related: IO#pos=, IO#seek. - -**@overload** [] - -## pos=(offset) [](#method-i-pos=) -Seeks to the given `new_position` (in bytes); see -[Position](rdoc-ref:IO@Position): - - f = File.open('t.txt') - f.tell # => 0 - f.pos = 20 # => 20 - f.tell # => 20 - f.close - -Related: IO#seek, IO#tell. - -**@overload** [] - -## pread(*args) [](#method-i-pread) -Behaves like IO#readpartial, except that it: - -* Reads at the given `offset` (in bytes). -* Disregards, and does not modify, the stream's position (see - [Position](rdoc-ref:IO@Position)). -* Bypasses any user space buffering in the stream. - -Because this method does not disturb the stream's state (its position, in -particular), `pread` allows multiple threads and processes to use the same IO -object for reading at various offsets. - - f = File.open('t.txt') - f.read # => "First line\nSecond line\n\nFourth line\nFifth line\n" - f.pos # => 52 - # Read 12 bytes at offset 0. - f.pread(12, 0) # => "First line\n" - # Read 9 bytes at offset 8. - f.pread(9, 8) # => "ne\nSecon" - f.close - -Not available on some platforms. - -**@overload** [] - -**@overload** [] - -## pressed?(k) [](#method-i-pressed?) -Returns `true` if `key` is pressed. `key` may be a virtual key code or its -name (String or Symbol) with out "VK_" prefix. - -This method is Windows only. - -You must require 'io/console' to use this method. - -**@overload** [] - -## print(*args) [](#method-i-print) -Writes the given objects to the stream; returns `nil`. Appends the output -record separator `$OUTPUT_RECORD_SEPARATOR` (`$\`), if it is not `nil`. See -[Line IO](rdoc-ref:IO@Line+IO). - -With argument `objects` given, for each object: - -* Converts via its method `to_s` if not a string. -* Writes to the stream. -* If not the last object, writes the output field separator - `$OUTPUT_FIELD_SEPARATOR` (`$,`) if it is not `nil`. - -With default separators: - - f = File.open('t.tmp', 'w+') - objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero'] - p $OUTPUT_RECORD_SEPARATOR - p $OUTPUT_FIELD_SEPARATOR - f.print(*objects) - f.rewind - p f.read - f.close - -Output: - - nil - nil - "00.00/10+0izerozero" - -With specified separators: - - $\ = "\n" - $, = ',' - f.rewind - f.print(*objects) - f.rewind - p f.read - -Output: - - "0,0.0,0/1,0+0i,zero,zero\n" - -With no argument given, writes the content of `$_` (which is usually the most -recent user input): - - f = File.open('t.tmp', 'w+') - gets # Sets $_ to the most recent user input. - f.print - f.close - -**@overload** [] - -## printf(*args) [](#method-i-printf) -Formats and writes `objects` to the stream. - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -**@overload** [] - -## putc(ch) [](#method-i-putc) -Writes a character to the stream. See [Character -IO](rdoc-ref:IO@Character+IO). - -If `object` is numeric, converts to integer if necessary, then writes the -character whose code is the least significant byte; if `object` is a string, -writes the first character: - - $stdout.putc "A" - $stdout.putc 65 - -Output: - - AA - -**@overload** [] - -## puts(*args) [](#method-i-puts) -Writes the given `objects` to the stream, which must be open for writing; -returns `nil`.\ Writes a newline after each that does not already end with a -newline sequence. If called without arguments, writes a newline. See [Line -IO](rdoc-ref:IO@Line+IO). - -Note that each added newline is the character `"\n", not the output -record separator ($\`). - -Treatment for each object: - -* String: writes the string. -* Neither string nor array: writes `object.to_s`. -* Array: writes each element of the array; arrays may be nested. - -To keep these examples brief, we define this helper method: - - def show(*objects) - # Puts objects to file. - f = File.new('t.tmp', 'w+') - f.puts(objects) - # Return file content. - f.rewind - p f.read - f.close - end - - # Strings without newlines. - show('foo', 'bar', 'baz') # => "foo\nbar\nbaz\n" - # Strings, some with newlines. - show("foo\n", 'bar', "baz\n") # => "foo\nbar\nbaz\n" - - # Neither strings nor arrays: - show(0, 0.0, Rational(0, 1), Complex(9, 0), :zero) - # => "0\n0.0\n0/1\n9+0i\nzero\n" - - # Array of strings. - show(['foo', "bar\n", 'baz']) # => "foo\nbar\nbaz\n" - # Nested arrays. - show([[[0, 1], 2, 3], 4, 5]) # => "0\n1\n2\n3\n4\n5\n" - -**@overload** [] - -## pwrite(str, offset) [](#method-i-pwrite) -Behaves like IO#write, except that it: - -* Writes at the given `offset` (in bytes). -* Disregards, and does not modify, the stream's position (see - [Position](rdoc-ref:IO@Position)). -* Bypasses any user space buffering in the stream. - -Because this method does not disturb the stream's state (its position, in -particular), `pwrite` allows multiple threads and processes to use the same IO -object for writing at various offsets. - - f = File.open('t.tmp', 'w+') - # Write 6 bytes at offset 3. - f.pwrite('ABCDEF', 3) # => 6 - f.rewind - f.read # => "\u0000\u0000\u0000ABCDEF" - f.close - -Not available on some platforms. - -**@overload** [] - -## raw(*args) [](#method-i-raw) -Yields `self` within raw mode, and returns the result of the block. - - STDIN.raw(&:gets) - -will read and return a line without echo back and line editing. - -The parameter `min` specifies the minimum number of bytes that should be -received when a read operation is performed. (default: 1) - -The parameter `time` specifies the timeout in *seconds* with a precision of -1/10 of a second. (default: 0) - -If the parameter `intr` is `true`, enables break, interrupt, quit, and suspend -special characters. - -Refer to the manual page of termios for further details. - -You must require 'io/console' to use this method. - -**@overload** [] - -## raw!(*args) [](#method-i-raw!) -Enables raw mode, and returns `io`. - -If the terminal mode needs to be back, use `io.raw { ... }`. - -See IO#raw for details on the parameters. - -You must require 'io/console' to use this method. - -**@overload** [] - -## read(*args) [](#method-i-read) -Reads bytes from the stream; the stream must be opened for reading (see -[Access Modes](rdoc-ref:File@Access+Modes)): - -* If `maxlen` is `nil`, reads all bytes using the stream's data mode. -* Otherwise reads up to `maxlen` bytes in binary mode. - -Returns a string (either a new string or the given `out_string`) containing -the bytes read. The encoding of the string depends on both `maxLen` and -`out_string`: - -* `maxlen` is `nil`: uses internal encoding of `self` (regardless of whether - `out_string` was given). -* `maxlen` not `nil`: - - * `out_string` given: encoding of `out_string` not modified. - * `out_string` not given: ASCII-8BIT is used. - -**Without Argument `out_string`** - -When argument `out_string` is omitted, the returned value is a new string: - - f = File.new('t.txt') - f.read - # => "First line\nSecond line\n\nFourth line\nFifth line\n" - f.rewind - f.read(30) # => "First line\r\nSecond line\r\n\r\nFou" - f.read(30) # => "rth line\r\nFifth line\r\n" - f.read(30) # => nil - f.close - -If `maxlen` is zero, returns an empty string. - -** With Argument `out_string`** - -When argument `out_string` is given, the returned value is `out_string`, whose -content is replaced: - - f = File.new('t.txt') - s = 'foo' # => "foo" - f.read(nil, s) # => "First line\nSecond line\n\nFourth line\nFifth line\n" - s # => "First line\nSecond line\n\nFourth line\nFifth line\n" - f.rewind - s = 'bar' - f.read(30, s) # => "First line\r\nSecond line\r\n\r\nFou" - s # => "First line\r\nSecond line\r\n\r\nFou" - s = 'baz' - f.read(30, s) # => "rth line\r\nFifth line\r\n" - s # => "rth line\r\nFifth line\r\n" - s = 'bat' - f.read(30, s) # => nil - s # => "" - f.close - -Note that this method behaves like the fread() function in C. This means it -retries to invoke read(2) system calls to read data with the specified maxlen -(or until EOF). - -This behavior is preserved even if the stream is in non-blocking mode. (This -method is non-blocking-flag insensitive as other methods.) - -If you need the behavior like a single read(2) system call, consider -#readpartial, #read_nonblock, and #sysread. - -Related: IO#write. - -**@overload** [] - -## read_nonblock(len, bufnil, exception:true) [](#method-i-read_nonblock) -call-seq: - ios.read_nonblock(maxlen [, options]) -> string - ios.read_nonblock(maxlen, outbuf [, options]) -> outbuf - -Reads at most *maxlen* bytes from *ios* using the read(2) system call after -O_NONBLOCK is set for the underlying file descriptor. - -If the optional *outbuf* argument is present, it must reference a String, -which will receive the data. The *outbuf* will contain only the received data -after the method call even if it is not empty at the beginning. - -read_nonblock just calls the read(2) system call. It causes all errors the -read(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc. The caller -should care such errors. - -If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, it is extended by -IO::WaitReadable. So IO::WaitReadable can be used to rescue the exceptions for -retrying read_nonblock. - -read_nonblock causes EOFError on EOF. - -On some platforms, such as Windows, non-blocking mode is not supported on IO -objects other than sockets. In such cases, Errno::EBADF will be raised. - -If the read byte buffer is not empty, read_nonblock reads from the buffer like -readpartial. In this case, the read(2) system call is not called. - -When read_nonblock raises an exception kind of IO::WaitReadable, read_nonblock -should not be called until io is readable for avoiding busy loop. This can be -done as follows. - - # emulates blocking read (readpartial). - begin - result = io.read_nonblock(maxlen) - rescue IO::WaitReadable - IO.select([io]) - retry - end - -Although IO#read_nonblock doesn't raise IO::WaitWritable. -OpenSSL::Buffering#read_nonblock can raise IO::WaitWritable. If IO and SSL -should be used polymorphically, IO::WaitWritable should be rescued too. See -the document of OpenSSL::Buffering#read_nonblock for sample code. - -Note that this method is identical to readpartial except the non-blocking flag -is set. - -By specifying a keyword argument *exception* to `false`, you can indicate that -read_nonblock should not raise an IO::WaitReadable exception, but return the -symbol `:wait_readable` instead. At EOF, it will return nil instead of raising -EOFError. - -## readbyte() [](#method-i-readbyte) -Reads and returns the next byte (in range 0..255) from the stream; raises -EOFError if already at end-of-stream. See [Byte IO](rdoc-ref:IO@Byte+IO). - - f = File.open('t.txt') - f.readbyte # => 70 - f.close - f = File.open('t.rus') - f.readbyte # => 209 - f.close - -Related: IO#getbyte (will not raise EOFError). - -**@overload** [] - -## readchar() [](#method-i-readchar) -Reads and returns the next 1-character string from the stream; raises EOFError -if already at end-of-stream. See [Character IO](rdoc-ref:IO@Character+IO). - - f = File.open('t.txt') - f.readchar # => "F" - f.close - f = File.open('t.rus') - f.readchar.ord # => 1090 - f.close - -Related: IO#getc (will not raise EOFError). - -**@overload** [] - -## readline(sep$/, limitnil, chomp:false) [](#method-i-readline) -call-seq: - readline(sep = $/, chomp: false) -> string - readline(limit, chomp: false) -> string - readline(sep, limit, chomp: false) -> string - -Reads a line as with IO#gets, but raises EOFError if already at end-of-stream. - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted. - -## readlines(*args) [](#method-i-readlines) -Reads and returns all remaining line from the stream; does not modify `$_`. -See [Line IO](rdoc-ref:IO@Line+IO). - -With no arguments given, returns lines as determined by line separator `$/`, -or `nil` if none: - - f = File.new('t.txt') - f.readlines - # => ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - f.readlines # => [] - f.close - -With only string argument `sep` given, returns lines as determined by line -separator `sep`, or `nil` if none; see [Line -Separator](rdoc-ref:IO@Line+Separator): - - f = File.new('t.txt') - f.readlines('li') - # => ["First li", "ne\nSecond li", "ne\n\nFourth li", "ne\nFifth li", "ne\n"] - f.close - -The two special values for `sep` are honored: - - f = File.new('t.txt') - # Get all into one string. - f.readlines(nil) - # => ["First line\nSecond line\n\nFourth line\nFifth line\n"] - # Get paragraphs (up to two line separators). - f.rewind - f.readlines('') - # => ["First line\nSecond line\n\n", "Fourth line\nFifth line\n"] - f.close - -With only integer argument `limit` given, limits the number of bytes in each -line; see [Line Limit](rdoc-ref:IO@Line+Limit): - - f = File.new('t.txt') - f.readlines(8) - # => ["First li", "ne\n", "Second l", "ine\n", "\n", "Fourth l", "ine\n", "Fifth li", "ne\n"] - f.close - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted: - - f = File.new('t.txt') - f.readlines(chomp: true) - # => ["First line", "Second line", "", "Fourth line", "Fifth line"] - f.close - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## readpartial(*args) [](#method-i-readpartial) -Reads up to `maxlen` bytes from the stream; returns a string (either a new -string or the given `out_string`). Its encoding is: - -* The unchanged encoding of `out_string`, if `out_string` is given. -* ASCII-8BIT, otherwise. - -* Contains `maxlen` bytes from the stream, if available. -* Otherwise contains all available bytes, if any available. -* Otherwise is an empty string. - -With the single non-negative integer argument `maxlen` given, returns a new -string: - - f = File.new('t.txt') - f.readpartial(20) # => "First line\nSecond l" - f.readpartial(20) # => "ine\n\nFourth line\n" - f.readpartial(20) # => "Fifth line\n" - f.readpartial(20) # Raises EOFError. - f.close - -With both argument `maxlen` and string argument `out_string` given, returns -modified `out_string`: - - f = File.new('t.txt') - s = 'foo' - f.readpartial(20, s) # => "First line\nSecond l" - s = 'bar' - f.readpartial(0, s) # => "" - f.close - -This method is useful for a stream such as a pipe, a socket, or a tty. It -blocks only when no data is immediately available. This means that it blocks -only when *all* of the following are true: - -* The byte buffer in the stream is empty. -* The content of the stream is empty. -* The stream is not at EOF. - -When blocked, the method waits for either more data or EOF on the stream: - -* If more data is read, the method returns the data. -* If EOF is reached, the method raises EOFError. - -When not blocked, the method responds immediately: - -* Returns data from the buffer if there is any. -* Otherwise returns data from the stream if there is any. -* Otherwise raises EOFError if the stream has reached EOF. - -Note that this method is similar to sysread. The differences are: - -* If the byte buffer is not empty, read from the byte buffer instead of - "sysread for buffered IO (IOError)". -* It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR. When readpartial - meets EWOULDBLOCK and EINTR by read system call, readpartial retries the - system call. - -The latter means that readpartial is non-blocking-flag insensitive. It blocks -on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking -mode. - -Examples: - - # # Returned Buffer Content Pipe Content - r, w = IO.pipe # - w << 'abc' # "" "abc". - r.readpartial(4096) # => "abc" "" "" - r.readpartial(4096) # (Blocks because buffer and pipe are empty.) - - # # Returned Buffer Content Pipe Content - r, w = IO.pipe # - w << 'abc' # "" "abc" - w.close # "" "abc" EOF - r.readpartial(4096) # => "abc" "" EOF - r.readpartial(4096) # raises EOFError - - # # Returned Buffer Content Pipe Content - r, w = IO.pipe # - w << "abc\ndef\n" # "" "abc\ndef\n" - r.gets # => "abc\n" "def\n" "" - w << "ghi\n" # "def\n" "ghi\n" - r.readpartial(4096) # => "def\n" "" "ghi\n" - r.readpartial(4096) # => "ghi\n" "" "" - -**@overload** [] - -**@overload** [] - -## ready?() [](#method-i-ready?) -Returns a truthy value if input available without blocking, or a falsy value. - -You must require 'io/wait' to use this method. - -**@overload** [] - -**@return** [Boolean] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reopen(*args) [](#method-i-reopen) -Reassociates the stream with another stream, which may be of a different -class. This method may be used to redirect an existing stream to a new -destination. - -With argument `other_io` given, reassociates with that stream: - - # Redirect $stdin from a file. - f = File.open('t.txt') - $stdin.reopen(f) - f.close - - # Redirect $stdout to a file. - f = File.open('t.tmp', 'w') - $stdout.reopen(f) - f.close - -With argument `path` given, reassociates with a new stream to that file path: - - $stdin.reopen('t.txt') - $stdout.reopen('t.tmp', 'w') - -Optional keyword arguments `opts` specify: - -* [Open Options](rdoc-ref:IO@Open+Options). -* [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## rewind() [](#method-i-rewind) -Repositions the stream to its beginning, setting both the position and the -line number to zero; see [Position](rdoc-ref:IO@Position) and [Line -Number](rdoc-ref:IO@Line+Number): - - f = File.open('t.txt') - f.tell # => 0 - f.lineno # => 0 - f.gets # => "First line\n" - f.tell # => 12 - f.lineno # => 1 - f.rewind # => 0 - f.tell # => 0 - f.lineno # => 0 - f.close - -Note that this method cannot be used with streams such as pipes, ttys, and -sockets. - -**@overload** [] - -## scroll_backward(val) [](#method-i-scroll_backward) -Scrolls the entire scrolls backward `n` lines. - -You must require 'io/console' to use this method. - -**@overload** [] - -## scroll_forward(val) [](#method-i-scroll_forward) -Scrolls the entire scrolls forward `n` lines. - -You must require 'io/console' to use this method. - -**@overload** [] - -## seek(*args) [](#method-i-seek) -Seeks to the position given by integer `offset` (see -[Position](rdoc-ref:IO@Position)) and constant `whence`, which is one of: - -* `:CUR` or `IO::SEEK_CUR`: Repositions the stream to its current position - plus the given `offset`: - - f = File.open('t.txt') - f.tell # => 0 - f.seek(20, :CUR) # => 0 - f.tell # => 20 - f.seek(-10, :CUR) # => 0 - f.tell # => 10 - f.close - -* `:END` or `IO::SEEK_END`: Repositions the stream to its end plus the given - `offset`: - - f = File.open('t.txt') - f.tell # => 0 - f.seek(0, :END) # => 0 # Repositions to stream end. - f.tell # => 52 - f.seek(-20, :END) # => 0 - f.tell # => 32 - f.seek(-40, :END) # => 0 - f.tell # => 12 - f.close - -* `:SET` or `IO:SEEK_SET`: Repositions the stream to the given `offset`: - - f = File.open('t.txt') - f.tell # => 0 - f.seek(20, :SET) # => 0 - f.tell # => 20 - f.seek(40, :SET) # => 0 - f.tell # => 40 - f.close - -Related: IO#pos=, IO#tell. - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## set_encoding(*args) [](#method-i-set_encoding) -See [Encodings](rdoc-ref:File@Encodings). - -Argument `ext_enc`, if given, must be an Encoding object or a String with the -encoding name; it is assigned as the encoding for the stream. - -Argument `int_enc`, if given, must be an Encoding object or a String with the -encoding name; it is assigned as the encoding for the internal string. - -Argument `'ext_enc:int_enc'`, if given, is a string containing two -colon-separated encoding names; corresponding Encoding objects are assigned as -the external and internal encodings for the stream. - -If the external encoding of a string is binary/ASCII-8BIT, the internal -encoding of the string is set to nil, since no transcoding is needed. - -Optional keyword arguments `enc_opts` specify [Encoding -options](rdoc-ref:encodings.rdoc@Encoding+Options). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## set_encoding_by_bom() [](#method-i-set_encoding_by_bom) -If the stream begins with a BOM ([byte order -marker](https://en.wikipedia.org/wiki/Byte_order_mark)), consumes the BOM and -sets the external encoding accordingly; returns the result encoding if found, -or `nil` otherwise: - - File.write('t.tmp', "\u{FEFF}abc") - io = File.open('t.tmp', 'rb') - io.set_encoding_by_bom # => # - io.close - - File.write('t.tmp', 'abc') - io = File.open('t.tmp', 'rb') - io.set_encoding_by_bom # => nil - io.close - -Raises an exception if the stream is not binmode or its encoding has already -been set. - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## stat() [](#method-i-stat) -Returns status information for *ios* as an object of type File::Stat. - - f = File.new("testfile") - s = f.stat - "%o" % s.mode #=> "100644" - s.blksize #=> 4096 - s.atime #=> Wed Apr 09 08:53:54 CDT 2003 - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## sync() [](#method-i-sync) -Returns the current sync mode of the stream. When sync mode is true, all -output is immediately flushed to the underlying operating system and is not -buffered by Ruby internally. See also #fsync. - - f = File.open('t.tmp', 'w') - f.sync # => false - f.sync = true - f.sync # => true - f.close - -**@overload** [] - -## sync=(sync) [](#method-i-sync=) - -## sysread(*args) [](#method-i-sysread) -Behaves like IO#readpartial, except that it uses low-level system functions. - -This method should not be used with other stream-reader methods. - -**@overload** [] - -**@overload** [] - -## sysseek(*args) [](#method-i-sysseek) -Behaves like IO#seek, except that it: - -* Uses low-level system functions. -* Returns the new position. - -**@overload** [] - -## syswrite(str) [](#method-i-syswrite) -Writes the given `object` to self, which must be opened for writing (see -Modes); returns the number bytes written. If `object` is not a string is -converted via method to_s: - - f = File.new('t.tmp', 'w') - f.syswrite('foo') # => 3 - f.syswrite(30) # => 2 - f.syswrite(:foo) # => 3 - f.close - -This methods should not be used with other stream-writer methods. - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## tell() [](#method-i-tell) -Returns the current position (in bytes) in `self` (see -[Position](rdoc-ref:IO@Position)): - - f = File.open('t.txt') - f.tell # => 0 - f.gets # => "First line\n" - f.tell # => 12 - f.close - -Related: IO#pos=, IO#seek. - -**@overload** [] - -## timeout() [](#method-i-timeout) -Get the internal timeout duration or nil if it was not set. - -**@overload** [] - -## timeout=(timeout) [](#method-i-timeout=) -Sets the internal timeout to the specified duration or nil. The timeout -applies to all blocking operations where possible. - -When the operation performs longer than the timeout set, IO::TimeoutError is -raised. - -This affects the following methods (but is not limited to): #gets, #puts, -#read, #write, #wait_readable and #wait_writable. This also affects blocking -socket operations like Socket#accept and Socket#connect. - -Some operations like File#open and IO#close are not affected by the timeout. A -timeout during a write operation may leave the IO in an inconsistent state, -e.g. data was partially written. Generally speaking, a timeout is a last ditch -effort to prevent an application from hanging on slow I/O operations, such as -those that occur during a slowloris attack. - -**@overload** [] - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_io() [](#method-i-to_io) -Returns `self`. - -**@overload** [] - -## to_path() [](#method-i-to_path) -Returns the path associated with the IO, or `nil` if there is no path -associated with the IO. It is not guaranteed that the path exists on the -filesystem. - - $stdin.path # => "" - - File.open("testfile") {|f| f.path} # => "testfile" - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## tty?() [](#method-i-tty?) -Returns `true` if the stream is associated with a terminal device (tty), -`false` otherwise: - - f = File.new('t.txt').isatty #=> false - f.close - f = File.new('/dev/tty').isatty #=> true - f.close - -**@overload** [] - -## ttyname() [](#method-i-ttyname) -Returns name of associated terminal (tty) if `io` is not a tty. Returns `nil` -otherwise. - -**@overload** [] - -## ungetbyte(b) [](#method-i-ungetbyte) -Pushes back ("unshifts") the given data onto the stream's buffer, placing the -data so that it is next to be read; returns `nil`. See [Byte -IO](rdoc-ref:IO@Byte+IO). - -Note that: - -* Calling the method has no effect with unbuffered reads (such as - IO#sysread). -* Calling #rewind on the stream discards the pushed-back data. - -When argument `integer` is given, uses only its low-order byte: - - File.write('t.tmp', '012') - f = File.open('t.tmp') - f.ungetbyte(0x41) # => nil - f.read # => "A012" - f.rewind - f.ungetbyte(0x4243) # => nil - f.read # => "C012" - f.close - -When argument `string` is given, uses all bytes: - - File.write('t.tmp', '012') - f = File.open('t.tmp') - f.ungetbyte('A') # => nil - f.read # => "A012" - f.rewind - f.ungetbyte('BCDE') # => nil - f.read # => "BCDE012" - f.close - -**@overload** [] - -**@overload** [] - -## ungetc(c) [](#method-i-ungetc) -Pushes back ("unshifts") the given data onto the stream's buffer, placing the -data so that it is next to be read; returns `nil`. See [Character -IO](rdoc-ref:IO@Character+IO). - -Note that: - -* Calling the method has no effect with unbuffered reads (such as - IO#sysread). -* Calling #rewind on the stream discards the pushed-back data. - -When argument `integer` is given, interprets the integer as a character: - - File.write('t.tmp', '012') - f = File.open('t.tmp') - f.ungetc(0x41) # => nil - f.read # => "A012" - f.rewind - f.ungetc(0x0442) # => nil - f.getc.ord # => 1090 - f.close - -When argument `string` is given, uses all characters: - - File.write('t.tmp', '012') - f = File.open('t.tmp') - f.ungetc('A') # => nil - f.read # => "A012" - f.rewind - f.ungetc("\u0442\u0435\u0441\u0442") # => nil - f.getc.ord # => 1090 - f.getc.ord # => 1077 - f.getc.ord # => 1089 - f.getc.ord # => 1090 - f.close - -**@overload** [] - -**@overload** [] - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## wait(*args) [](#method-i-wait) -Waits until the IO becomes ready for the specified events and returns the -subset of events that become ready, or a falsy value when times out. - -The events can be a bit mask of `IO::READABLE`, `IO::WRITABLE` or -`IO::PRIORITY`. - -Returns a truthy value immediately when buffered data is available. - -Optional parameter `mode` is one of `:read`, `:write`, or `:read_write`. - -You must require 'io/wait' to use this method. - -**@overload** [] - -**@overload** [] - -## wait_priority(*args) [](#method-i-wait_priority) -Waits until IO is priority and returns a truthy value or a falsy value when -times out. Priority data is sent and received using the Socket::MSG_OOB flag -and is typically limited to streams. - -You must require 'io/wait' to use this method. - -**@overload** [] - -**@overload** [] - -## wait_readable(*args) [](#method-i-wait_readable) -Waits until IO is readable and returns a truthy value, or a falsy value when -times out. Returns a truthy value immediately when buffered data is -available. - -You must require 'io/wait' to use this method. - -**@overload** [] - -**@overload** [] - -## wait_writable(*args) [](#method-i-wait_writable) -Waits until IO is writable and returns a truthy value or a falsy value when -times out. - -You must require 'io/wait' to use this method. - -**@overload** [] - -**@overload** [] - -## winsize() [](#method-i-winsize) -Returns console size. - -You must require 'io/console' to use this method. - -**@overload** [] - -## winsize=(size) [](#method-i-winsize=) -Tries to set console size. The effect depends on the platform and the running -environment. - -You must require 'io/console' to use this method. - -## write(*args) [](#method-i-write) -Writes each of the given `objects` to `self`, which must be opened for writing -(see [Access Modes](rdoc-ref:File@Access+Modes)); returns the total number -bytes written; each of `objects` that is not a string is converted via method -`to_s`: - - $stdout.write('Hello', ', ', 'World!', "\n") # => 14 - $stdout.write('foo', :bar, 2, "\n") # => 8 - -Output: - - Hello, World! - foobar2 - -Related: IO#read. - -**@overload** [] - -## write_nonblock(buf, exception:true) [](#method-i-write_nonblock) -call-seq: - ios.write_nonblock(string) -> integer - ios.write_nonblock(string [, options]) -> integer - -Writes the given string to *ios* using the write(2) system call after -O_NONBLOCK is set for the underlying file descriptor. - -It returns the number of bytes written. - -write_nonblock just calls the write(2) system call. It causes all errors the -write(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc. The result -may also be smaller than string.length (partial write). The caller should care -such errors and partial write. - -If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, it is extended by -IO::WaitWritable. So IO::WaitWritable can be used to rescue the exceptions for -retrying write_nonblock. - - # Creates a pipe. - r, w = IO.pipe - - # write_nonblock writes only 65536 bytes and return 65536. - # (The pipe size is 65536 bytes on this environment.) - s = "a" * 100000 - p w.write_nonblock(s) #=> 65536 - - # write_nonblock cannot write a byte and raise EWOULDBLOCK (EAGAIN). - p w.write_nonblock("b") # Resource temporarily unavailable (Errno::EAGAIN) - -If the write buffer is not empty, it is flushed at first. - -When write_nonblock raises an exception kind of IO::WaitWritable, -write_nonblock should not be called until io is writable for avoiding busy -loop. This can be done as follows. - - begin - result = io.write_nonblock(string) - rescue IO::WaitWritable, Errno::EINTR - IO.select(nil, [io]) - retry - end - -Note that this doesn't guarantee to write all data in string. The length -written is reported as result and it should be checked later. - -On some platforms such as Windows, write_nonblock is not supported according -to the kind of the IO object. In such cases, write_nonblock raises -`Errno::EBADF`. - -By specifying a keyword argument *exception* to `false`, you can indicate that -write_nonblock should not raise an IO::WaitWritable exception, but return the -symbol `:wait_writable` instead. - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/IO/Buffer.md b/example/ruby/IO/Buffer.md deleted file mode 100644 index 2d2c4a6..0000000 --- a/example/ruby/IO/Buffer.md +++ /dev/null @@ -1,841 +0,0 @@ -# Class: IO::Buffer -**Inherits:** Object - -**Includes:** Comparable - - -IO::Buffer is a efficient zero-copy buffer for input/output. There are typical -use cases: - -* Create an empty buffer with ::new, fill it with buffer using #copy or - #set_value, #set_string, get buffer with #get_string or write it directly - to some file with #write. -* Create a buffer mapped to some string with ::for, then it could be used - both for reading with #get_string or #get_value, and writing (writing will - change the source string, too). -* Create a buffer mapped to some file with ::map, then it could be used for - reading and writing the underlying file. -* Create a string of a fixed size with ::string, then #read into it, or - modify it using #set_value. - -Interaction with string and file memory is performed by efficient low-level C -mechanisms like `memcpy`. - -The class is meant to be an utility for implementing more high-level -mechanisms like Fiber::Scheduler#io_read and Fiber::Scheduler#io_write and -parsing binary protocols. - -## Examples of Usage - -Empty buffer: - - buffer = IO::Buffer.new(8) # create empty 8-byte buffer - # => - # # - # ... - buffer - # => - # - # 0x00000000 00 00 00 00 00 00 00 00 - buffer.set_string('test', 2) # put there bytes of the "test" string, starting from offset 2 - # => 4 - buffer.get_string # get the result - # => "\x00\x00test\x00\x00" - -Buffer from string: - - string = 'data' - IO::Buffer.for(string) do |buffer| - buffer - # => - # # - # 0x00000000 64 61 74 61 data - - buffer.get_string(2) # read content starting from offset 2 - # => "ta" - buffer.set_string('---', 1) # write content, starting from offset 1 - # => 3 - buffer - # => - # # - # 0x00000000 64 2d 2d 2d d--- - string # original string changed, too - # => "d---" - end - -Buffer from file: - - File.write('test.txt', 'test data') - # => 9 - buffer = IO::Buffer.map(File.open('test.txt')) - # => - # # - # ... - buffer.get_string(5, 2) # read 2 bytes, starting from offset 5 - # => "da" - buffer.set_string('---', 1) # attempt to write - # in `set_string': Buffer is not writable! (IO::Buffer::AccessError) - - # To create writable file-mapped buffer - # Open file for read-write, pass size, offset, and flags=0 - buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 9, 0, 0) - buffer.set_string('---', 1) - # => 3 -- bytes written - File.read('test.txt') - # => "t--- data" - -**The class is experimental and the interface is subject to change, this is -especially true of file mappings which may be removed entirely in the -future.** - - -# Class Methods -## for(string ) [](#method-c-for) -Creates a zero-copy IO::Buffer from the given string's memory. Without a block -a frozen internal copy of the string is created efficiently and used as the -buffer source. When a block is provided, the buffer is associated directly -with the string's internal buffer and updating the buffer will update the -string. - -Until #free is invoked on the buffer, either explicitly or via the garbage -collector, the source string will be locked and cannot be modified. - -If the string is frozen, it will create a read-only buffer which cannot be -modified. If the string is shared, it may trigger a copy-on-write when using -the block form. - - string = 'test' - buffer = IO::Buffer.for(string) - buffer.external? #=> true - - buffer.get_string(0, 1) - # => "t" - string - # => "best" - - buffer.resize(100) - # in `resize': Cannot resize external buffer! (IO::Buffer::AccessError) - - IO::Buffer.for(string) do |buffer| - buffer.set_string("T") - string - # => "Test" - end -**@overload** [] - -**@overload** [] - -## map(*args ) [](#method-c-map) -Create an IO::Buffer for reading from `file` by memory-mapping the file. -`file_io` should be a `File` instance, opened for reading. - -Optional `size` and `offset` of mapping can be specified. - -By default, the buffer would be immutable (read only); to create a writable -mapping, you need to open a file in read-write mode, and explicitly pass -`flags` argument without IO::Buffer::IMMUTABLE. - - File.write('test.txt', 'test') - - buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) - # => # - - buffer.readonly? # => true - - buffer.get_string - # => "test" - - buffer.set_string('b', 0) - # `set_string': Buffer is not writable! (IO::Buffer::AccessError) - - # create read/write mapping: length 4 bytes, offset 0, flags 0 - buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0) - buffer.set_string('b', 0) - # => 1 - - # Check it - File.read('test.txt') - # => "best" - -Note that some operating systems may not have cache coherency between mapped -buffers and file reads. -**@overload** [] - -## size_of(buffer_type ) [](#method-c-size_of) -Returns the size of the given buffer type(s) in bytes. - - IO::Buffer.size_of(:u32) # => 4 - IO::Buffer.size_of([:u32, :u32]) # => 8 -**@overload** [] - -**@overload** [] - -## string(length ) [](#method-c-string) -Creates a new string of the given length and yields a zero-copy IO::Buffer -instance to the block which uses the string as a source. The block is expected -to write to the buffer and the string will be returned. - - IO::Buffer.string(4) do |buffer| - buffer.set_string("Ruby") - end - # => "Ruby" -**@overload** [] - - -#Instance Methods -## &(mask) [](#method-i-&) -Generate a new buffer the same size as the source by applying the binary AND -operation to the source, using the mask, repeating as necessary. - - IO::Buffer.for("1234567890") & IO::Buffer.for("\xFF\x00\x00\xFF") - # => - # # - # 0x00000000 31 00 00 34 35 00 00 38 39 00 1..45..89. - -**@overload** [] - -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>() [](#method-i-<=>) - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## ^(mask) [](#method-i-^) -Generate a new buffer the same size as the source by applying the binary XOR -operation to the source, using the mask, repeating as necessary. - - IO::Buffer.for("1234567890") ^ IO::Buffer.for("\xFF\x00\x00\xFF") - # => - # # - # 0x00000000 ce 32 33 cb ca 36 37 c7 c6 30 .23..67..0 - -**@overload** [] - -## and!(mask) [](#method-i-and!) -Modify the source buffer in place by applying the binary AND operation to the -source, using the mask, repeating as necessary. - - source = IO::Buffer.for("1234567890").dup # Make a read/write copy. - # => - # # - # 0x00000000 31 32 33 34 35 36 37 38 39 30 1234567890 - - source.and!(IO::Buffer.for("\xFF\x00\x00\xFF")) - # => - # # - # 0x00000000 31 00 00 34 35 00 00 38 39 00 1..45..89. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## clear(*args) [](#method-i-clear) -Fill buffer with `value`, starting with `offset` and going for `length` bytes. - - buffer = IO::Buffer.for('test').dup - # => - # - # 0x00000000 74 65 73 74 test - - buffer.clear - # => - # - # 0x00000000 00 00 00 00 .... - - buf.clear(1) # fill with 1 - # => - # - # 0x00000000 01 01 01 01 .... - - buffer.clear(2, 1, 2) # fill with 2, starting from offset 1, for 2 bytes - # => - # - # 0x00000000 01 02 02 01 .... - - buffer.clear(2, 1) # fill with 2, starting from offset 1 - # => - # - # 0x00000000 01 02 02 02 .... - -**@overload** [] - -## copy(*args) [](#method-i-copy) -Efficiently copy from a source IO::Buffer into the buffer, at `offset` using -`memmove`. For copying String instances, see #set_string. - - buffer = IO::Buffer.new(32) - # => - # # - # 0x00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * - - buffer.copy(IO::Buffer.for("test"), 8) - # => 4 -- size of buffer copied - buffer - # => - # # - # 0x00000000 00 00 00 00 00 00 00 00 74 65 73 74 00 00 00 00 ........test.... - # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * - -#copy can be used to put buffer into strings associated with buffer: - - string = "data: " - # => "data: " - buffer = IO::Buffer.for(string) do |buffer| - buffer.copy(IO::Buffer.for("test"), 5) - end - # => 4 - string - # => "data:test" - -Attempt to copy into a read-only buffer will fail: - - File.write('test.txt', 'test') - buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) - buffer.copy(IO::Buffer.for("test"), 8) - # in `copy': Buffer is not writable! (IO::Buffer::AccessError) - -See ::map for details of creation of mutable file mappings, this will work: - - buffer = IO::Buffer.map(File.open('test.txt', 'r+')) - buffer.copy(IO::Buffer.for("boom"), 0) - # => 4 - File.read('test.txt') - # => "boom" - -Attempt to copy the buffer which will need place outside of buffer's bounds -will fail: - - buffer = IO::Buffer.new(2) - buffer.copy(IO::Buffer.for('test'), 0) - # in `copy': Specified offset+length is bigger than the buffer size! (ArgumentError) - -It is safe to copy between memory regions that overlaps each other. In such -case, the data is copied as if the data was first copied from the source -buffer to a temporary buffer, and then copied from the temporary buffer to the -destination buffer. - - buffer = IO::Buffer.new(10) - buffer.set_string("0123456789") - buffer.copy(buffer, 3, 7) - # => 7 - buffer - # => - # # - # 0x00000000 30 31 32 30 31 32 33 34 35 36 0120123456 - -**@overload** [] - -## each(*args) [](#method-i-each) -Iterates over the buffer, yielding each `value` of `buffer_type` starting from -`offset`. - -If `count` is given, only `count` values will be yielded. - - IO::Buffer.for("Hello World").each(:U8, 2, 2) do |offset, value| - puts "#{offset}: #{value}" - end - # 2: 108 - # 3: 108 - -**@overload** [] - -**@overload** [] - -## each_byte(*args) [](#method-i-each_byte) -Iterates over the buffer, yielding each byte starting from `offset`. - -If `count` is given, only `count` bytes will be yielded. - - IO::Buffer.for("Hello World").each_byte(2, 2) do |offset, byte| - puts "#{offset}: #{byte}" - end - # 2: 108 - # 3: 108 - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## external?() [](#method-i-external?) - -**@return** [Boolean] - -## free() [](#method-i-free) - -## get_string(*args) [](#method-i-get_string) -Read a chunk or all of the buffer into a string, in the specified `encoding`. -If no encoding is provided `Encoding::BINARY` is used. - - buffer = IO::Buffer.for('test') - buffer.get_string - # => "test" - buffer.get_string(2) - # => "st" - buffer.get_string(2, 1) - # => "s" - -**@overload** [] - -## get_value(type, _offset) [](#method-i-get_value) -Read from buffer a value of `type` at `offset`. `buffer_type` should be one of -symbols: - -* `:U8`: unsigned integer, 1 byte -* `:S8`: signed integer, 1 byte -* `:u16`: unsigned integer, 2 bytes, little-endian -* `:U16`: unsigned integer, 2 bytes, big-endian -* `:s16`: signed integer, 2 bytes, little-endian -* `:S16`: signed integer, 2 bytes, big-endian -* `:u32`: unsigned integer, 4 bytes, little-endian -* `:U32`: unsigned integer, 4 bytes, big-endian -* `:s32`: signed integer, 4 bytes, little-endian -* `:S32`: signed integer, 4 bytes, big-endian -* `:u64`: unsigned integer, 8 bytes, little-endian -* `:U64`: unsigned integer, 8 bytes, big-endian -* `:s64`: signed integer, 8 bytes, little-endian -* `:S64`: signed integer, 8 bytes, big-endian -* `:f32`: float, 4 bytes, little-endian -* `:F32`: float, 4 bytes, big-endian -* `:f64`: double, 8 bytes, little-endian -* `:F64`: double, 8 bytes, big-endian - -A buffer type refers specifically to the type of binary buffer that is stored -in the buffer. For example, a `:u32` buffer type is a 32-bit unsigned integer -in little-endian format. - - string = [1.5].pack('f') - # => "\x00\x00\xC0?" - IO::Buffer.for(string).get_value(:f32, 0) - # => 1.5 - -**@overload** [] - -## get_values(buffer_types, _offset) [](#method-i-get_values) -Similar to #get_value, except that it can handle multiple buffer types and -returns an array of values. - - string = [1.5, 2.5].pack('ff') - IO::Buffer.for(string).get_values([:f32, :f32], 0) - # => [1.5, 2.5] - -**@overload** [] - -## hexdump() [](#method-i-hexdump) - -## initialize(*args) [](#method-i-initialize) -Create a new zero-filled IO::Buffer of `size` bytes. By default, the buffer -will be *internal*: directly allocated chunk of the memory. But if the -requested `size` is more than OS-specific IO::Buffer::PAGE_SIZE, the buffer -would be allocated using the virtual memory mechanism (anonymous `mmap` on -Unix, `VirtualAlloc` on Windows). The behavior can be forced by passing -IO::Buffer::MAPPED as a second parameter. - - buffer = IO::Buffer.new(4) - # => - # # - # 0x00000000 00 00 00 00 .... - - buffer.get_string(0, 1) # => "\x00" - - buffer.set_string("test") - buffer - # => - # # - # 0x00000000 74 65 73 74 test - -**@overload** [] - -## initialize_copy(source) [](#method-i-initialize_copy) -Make an internal copy of the source buffer. Updates to the copy will not -affect the source buffer. - - source = IO::Buffer.for("Hello World") - # => - # # - # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World - buffer = source.dup - # => - # # - # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) - -## internal?() [](#method-i-internal?) - -**@return** [Boolean] - -## locked() [](#method-i-locked) -rb_define_method(rb_cIOBuffer, "unlock", rb_io_buffer_unlock, 0); - -## locked?() [](#method-i-locked?) - -**@return** [Boolean] - -## mapped?() [](#method-i-mapped?) - -**@return** [Boolean] - -## not!() [](#method-i-not!) -Modify the source buffer in place by applying the binary NOT operation to the -source. - - source = IO::Buffer.for("1234567890").dup # Make a read/write copy. - # => - # # - # 0x00000000 31 32 33 34 35 36 37 38 39 30 1234567890 - - source.not! - # => - # # - # 0x00000000 ce cd cc cb ca c9 c8 c7 c6 cf .......... - -**@overload** [] - -## null?() [](#method-i-null?) - -**@return** [Boolean] - -## or!(mask) [](#method-i-or!) -Modify the source buffer in place by applying the binary OR operation to the -source, using the mask, repeating as necessary. - - source = IO::Buffer.for("1234567890").dup # Make a read/write copy. - # => - # # - # 0x00000000 31 32 33 34 35 36 37 38 39 30 1234567890 - - source.or!(IO::Buffer.for("\xFF\x00\x00\xFF")) - # => - # # - # 0x00000000 ff 32 33 ff ff 36 37 ff ff 30 .23..67..0 - -**@overload** [] - -## pread(*args) [](#method-i-pread) -Read at least `length` bytes from the `io` starting at the specified `from` -position, into the buffer starting at `offset`. If an error occurs, return -`-errno`. - -If `length` is not given or `nil`, it defaults to the size of the buffer minus -the offset, i.e. the entire buffer. - -If `length` is zero, exactly one `pread` operation will occur. - -If `offset` is not given, it defaults to zero, i.e. the beginning of the -buffer. - - IO::Buffer.for('test') do |buffer| - p buffer - # => - # - # 0x00000000 74 65 73 74 test - - # take 2 bytes from the beginning of urandom, - # put them in buffer starting from position 2 - buffer.pread(File.open('/dev/urandom', 'rb'), 0, 2, 2) - p buffer - # => - # - # 0x00000000 05 35 73 74 te.5 - end - -**@overload** [] - -## private?() [](#method-i-private?) - -**@return** [Boolean] - -## pwrite(*args) [](#method-i-pwrite) -Write at least `length` bytes from the buffer starting at `offset`, into the -`io` starting at the specified `from` position. If an error occurs, return -`-errno`. - -If `length` is not given or `nil`, it defaults to the size of the buffer minus -the offset, i.e. the entire buffer. - -If `length` is zero, exactly one `pwrite` operation will occur. - -If `offset` is not given, it defaults to zero, i.e. the beginning of the -buffer. - -If the `from` position is beyond the end of the file, the gap will be filled -with null (0 value) bytes. - - out = File.open('output.txt', File::RDWR) # open for read/write, no truncation - IO::Buffer.for('1234567').pwrite(out, 2, 3, 1) - -This leads to `234` (3 bytes, starting from position 1) being written into -`output.txt`, starting from file position 2. - -**@overload** [] - -## read(*args) [](#method-i-read) -Read at least `length` bytes from the `io`, into the buffer starting at -`offset`. If an error occurs, return `-errno`. - -If `length` is not given or `nil`, it defaults to the size of the buffer minus -the offset, i.e. the entire buffer. - -If `length` is zero, exactly one `read` operation will occur. - -If `offset` is not given, it defaults to zero, i.e. the beginning of the -buffer. - - IO::Buffer.for('test') do |buffer| - p buffer - # => - # - # 0x00000000 74 65 73 74 test - buffer.read(File.open('/dev/urandom', 'rb'), 2) - p buffer - # => - # - # 0x00000000 05 35 73 74 .5st - end - -**@overload** [] - -## readonly?() [](#method-i-readonly?) - -**@return** [Boolean] - -## resize() [](#method-i-resize) - -## set_string(*args) [](#method-i-set_string) -Efficiently copy from a source String into the buffer, at `offset` using -`memmove`. - - buf = IO::Buffer.new(8) - # => - # # - # 0x00000000 00 00 00 00 00 00 00 00 ........ - - # set buffer starting from offset 1, take 2 bytes starting from string's - # second - buf.set_string('test', 1, 2, 1) - # => 2 - buf - # => - # # - # 0x00000000 00 65 73 00 00 00 00 00 .es..... - -See also #copy for examples of how buffer writing might be used for changing -associated strings and files. - -**@overload** [] - -## set_value(type, _offset, value) [](#method-i-set_value) -Write to a buffer a `value` of `type` at `offset`. `type` should be one of -symbols described in #get_value. - - buffer = IO::Buffer.new(8) - # => - # # - # 0x00000000 00 00 00 00 00 00 00 00 - - buffer.set_value(:U8, 1, 111) - # => 1 - - buffer - # => - # # - # 0x00000000 00 6f 00 00 00 00 00 00 .o...... - -Note that if the `type` is integer and `value` is Float, the implicit -truncation is performed: - - buffer = IO::Buffer.new(8) - buffer.set_value(:U32, 0, 2.5) - - buffer - # => - # # - # 0x00000000 00 00 00 02 00 00 00 00 - # ^^ the same as if we'd pass just integer 2 - -**@overload** [] - -## set_values(buffer_types, _offset, values) [](#method-i-set_values) -Write `values` of `buffer_types` at `offset` to the buffer. `buffer_types` -should be an array of symbols as described in #get_value. `values` should be -an array of values to write. - - buffer = IO::Buffer.new(8) - buffer.set_values([:U8, :U16], 0, [1, 2]) - buffer - # => - # # - # 0x00000000 01 00 02 00 00 00 00 00 ........ - -**@overload** [] - -## shared?() [](#method-i-shared?) - -**@return** [Boolean] - -## size() [](#method-i-size) - -## slice() [](#method-i-slice) -Manipulation: - -## to_s() [](#method-i-to_s) - -## transfer() [](#method-i-transfer) - -## valid?() [](#method-i-valid?) - -**@return** [Boolean] - -## values(*args) [](#method-i-values) -Returns an array of values of `buffer_type` starting from `offset`. - -If `count` is given, only `count` values will be returned. - - IO::Buffer.for("Hello World").values(:U8, 2, 2) - # => [108, 108] - -**@overload** [] - -## write(*args) [](#method-i-write) -Write at least `length` bytes from the buffer starting at `offset`, into the -`io`. If an error occurs, return `-errno`. - -If `length` is not given or `nil`, it defaults to the size of the buffer minus -the offset, i.e. the entire buffer. - -If `length` is zero, exactly one `write` operation will occur. - -If `offset` is not given, it defaults to zero, i.e. the beginning of the -buffer. - - out = File.open('output.txt', 'wb') - IO::Buffer.for('1234567').write(out, 3) - -This leads to `123` being written into `output.txt` - -**@overload** [] - -## xor!(mask) [](#method-i-xor!) -Modify the source buffer in place by applying the binary XOR operation to the -source, using the mask, repeating as necessary. - - source = IO::Buffer.for("1234567890").dup # Make a read/write copy. - # => - # # - # 0x00000000 31 32 33 34 35 36 37 38 39 30 1234567890 - - source.xor!(IO::Buffer.for("\xFF\x00\x00\xFF")) - # => - # # - # 0x00000000 ce 32 33 cb ca 36 37 c7 c6 30 .23..67..0 - -**@overload** [] - -## |(mask) [](#method-i-|) -Generate a new buffer the same size as the source by applying the binary OR -operation to the source, using the mask, repeating as necessary. - - IO::Buffer.for("1234567890") | IO::Buffer.for("\xFF\x00\x00\xFF") - # => - # # - # 0x00000000 ff 32 33 ff ff 36 37 ff ff 30 .23..67..0 - -**@overload** [] - -## ~() [](#method-i-~) -Generate a new buffer the same size as the source by applying the binary NOT -operation to the source. - - ~IO::Buffer.for("1234567890") - # => - # # - # 0x00000000 ce cd cc cb ca c9 c8 c7 c6 cf .......... - -**@overload** [] - diff --git a/example/ruby/IO/Buffer/AccessError.md b/example/ruby/IO/Buffer/AccessError.md deleted file mode 100644 index 4cd79b2..0000000 --- a/example/ruby/IO/Buffer/AccessError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IO::Buffer::AccessError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/IO/Buffer/AllocationError.md b/example/ruby/IO/Buffer/AllocationError.md deleted file mode 100644 index d49b580..0000000 --- a/example/ruby/IO/Buffer/AllocationError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IO::Buffer::AllocationError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/IO/Buffer/InvalidatedError.md b/example/ruby/IO/Buffer/InvalidatedError.md deleted file mode 100644 index 35b80bd..0000000 --- a/example/ruby/IO/Buffer/InvalidatedError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IO::Buffer::InvalidatedError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/IO/Buffer/LockedError.md b/example/ruby/IO/Buffer/LockedError.md deleted file mode 100644 index ed93417..0000000 --- a/example/ruby/IO/Buffer/LockedError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IO::Buffer::LockedError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/IO/Buffer/MaskError.md b/example/ruby/IO/Buffer/MaskError.md deleted file mode 100644 index c38f00b..0000000 --- a/example/ruby/IO/Buffer/MaskError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IO::Buffer::MaskError -**Inherits:** ArgumentError - - - - - diff --git a/example/ruby/IO/ConsoleMode.md b/example/ruby/IO/ConsoleMode.md deleted file mode 100644 index a2eb4df..0000000 --- a/example/ruby/IO/ConsoleMode.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: IO::ConsoleMode -**Inherits:** Object - - - - - -#Instance Methods -## echo=(f) [](#method-i-echo=) - -## initialize_copy(obj2) [](#method-i-initialize_copy) - -## raw(*args) [](#method-i-raw) - -## raw!(*args) [](#method-i-raw!) - diff --git a/example/ruby/IO/EAGAINWaitReadable.md b/example/ruby/IO/EAGAINWaitReadable.md deleted file mode 100644 index 190e675..0000000 --- a/example/ruby/IO/EAGAINWaitReadable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: IO::EAGAINWaitReadable -**Inherits:** EAGAIN - -**Includes:** IO::WaitReadable - - - - - diff --git a/example/ruby/IO/EAGAINWaitWritable.md b/example/ruby/IO/EAGAINWaitWritable.md deleted file mode 100644 index 5ed7762..0000000 --- a/example/ruby/IO/EAGAINWaitWritable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: IO::EAGAINWaitWritable -**Inherits:** EAGAIN - -**Includes:** IO::WaitWritable - - - - - diff --git a/example/ruby/IO/EINPROGRESSWaitReadable.md b/example/ruby/IO/EINPROGRESSWaitReadable.md deleted file mode 100644 index c640995..0000000 --- a/example/ruby/IO/EINPROGRESSWaitReadable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: IO::EINPROGRESSWaitReadable -**Inherits:** EINPROGRESS - -**Includes:** IO::WaitReadable - - - - - diff --git a/example/ruby/IO/EINPROGRESSWaitWritable.md b/example/ruby/IO/EINPROGRESSWaitWritable.md deleted file mode 100644 index cd21f84..0000000 --- a/example/ruby/IO/EINPROGRESSWaitWritable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: IO::EINPROGRESSWaitWritable -**Inherits:** EINPROGRESS - -**Includes:** IO::WaitWritable - - - - - diff --git a/example/ruby/IO/EWOULDBLOCKWaitReadable.md b/example/ruby/IO/EWOULDBLOCKWaitReadable.md deleted file mode 100644 index bac2309..0000000 --- a/example/ruby/IO/EWOULDBLOCKWaitReadable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: IO::EWOULDBLOCKWaitReadable -**Inherits:** EWOULDBLOCK - -**Includes:** IO::WaitReadable - - - - - diff --git a/example/ruby/IO/EWOULDBLOCKWaitWritable.md b/example/ruby/IO/EWOULDBLOCKWaitWritable.md deleted file mode 100644 index f94413d..0000000 --- a/example/ruby/IO/EWOULDBLOCKWaitWritable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: IO::EWOULDBLOCKWaitWritable -**Inherits:** EWOULDBLOCK - -**Includes:** IO::WaitWritable - - - - - diff --git a/example/ruby/IO/TimeoutError.md b/example/ruby/IO/TimeoutError.md deleted file mode 100644 index 3777a06..0000000 --- a/example/ruby/IO/TimeoutError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IO::TimeoutError -**Inherits:** IOError - - - - - diff --git a/example/ruby/IO/WaitReadable.md b/example/ruby/IO/WaitReadable.md deleted file mode 100644 index ff35229..0000000 --- a/example/ruby/IO/WaitReadable.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: IO::WaitReadable - - - - - diff --git a/example/ruby/IO/WaitWritable.md b/example/ruby/IO/WaitWritable.md deleted file mode 100644 index ff50c6e..0000000 --- a/example/ruby/IO/WaitWritable.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: IO::WaitWritable - - - - - diff --git a/example/ruby/IO/generic_readable.md b/example/ruby/IO/generic_readable.md deleted file mode 100644 index 77b1996..0000000 --- a/example/ruby/IO/generic_readable.md +++ /dev/null @@ -1,61 +0,0 @@ -# Module: IO::generic_readable - - - - - -#Instance Methods -## getch(*args) [](#method-i-getch) -See IO#getch. - -**@overload** [] - -## getpass(*args) [](#method-i-getpass) -See IO#getpass. - -**@overload** [] - -## read_nonblock(*args) [](#method-i-read_nonblock) -Similar to #read, but raises `EOFError` at end of string unless the -+exception: false+ option is passed in. - -**@overload** [] - -## readbyte() [](#method-i-readbyte) -Like `getbyte`, but raises an exception if already at end-of-stream; see [Byte -IO](rdoc-ref:IO@Byte+IO). - -**@overload** [] - -## readchar() [](#method-i-readchar) -Like `getc`, but raises an exception if already at end-of-stream; see -[Character IO](rdoc-ref:IO@Character+IO). - -**@overload** [] - -## readline(*args) [](#method-i-readline) -Reads a line as with IO#gets, but raises EOFError if already at end-of-file; -see [Line IO](rdoc-ref:IO@Line+IO). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## readpartial(*args) [](#method-i-readpartial) -Similar to #read, but raises `EOFError` at end of string instead of returning -`nil`, as well as IO#sysread does. - -**@overload** [] - -**@overload** [] - -## sysread(*args) [](#method-i-sysread) -Similar to #read, but raises `EOFError` at end of string instead of returning -`nil`, as well as IO#sysread does. - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/IO/generic_writable.md b/example/ruby/IO/generic_writable.md deleted file mode 100644 index 669720d..0000000 --- a/example/ruby/IO/generic_writable.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: IO::generic_writable - - - - - -#Instance Methods -## <<() [](#method-i-<<) - -## print() [](#method-i-print) - -## printf() [](#method-i-printf) - -## puts() [](#method-i-puts) - -## syswrite() [](#method-i-syswrite) - -## write_nonblock(*args) [](#method-i-write_nonblock) -See IO#write_nonblock - diff --git a/example/ruby/IOBufferScheduler.md b/example/ruby/IOBufferScheduler.md deleted file mode 100644 index ffe8127..0000000 --- a/example/ruby/IOBufferScheduler.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: IOBufferScheduler -**Inherits:** Scheduler - - -This scheduler class implements `io_read` and `io_write` hooks which require -`IO::Buffer`. - - - -#Instance Methods -## blocking(&block) [](#method-i-blocking) - -## io_pread(io, buffer, from, length, offset) [](#method-i-io_pread) - -## io_pwrite(io, buffer, from, length, offset) [](#method-i-io_pwrite) - -## io_read(io, buffer, length, offset) [](#method-i-io_read) - -## io_write(io, buffer, length, offset) [](#method-i-io_write) - diff --git a/example/ruby/IOError.md b/example/ruby/IOError.md deleted file mode 100644 index 1998ee6..0000000 --- a/example/ruby/IOError.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: IOError -**Inherits:** StandardError - - -Raised when an IO operation fails. - - File.open("/etc/hosts") {|f| f << "example"} - #=> IOError: not opened for writing - - File.open("/etc/hosts") {|f| f.close; f.read } - #=> IOError: closed stream - -Note that some IO failures raise `SystemCallError`s and these are not -subclasses of IOError: - - File.open("does/not/exist") - #=> Errno::ENOENT: No such file or directory - does/not/exist - - - diff --git a/example/ruby/IOSpec.md b/example/ruby/IOSpec.md deleted file mode 100644 index 80dc25d..0000000 --- a/example/ruby/IOSpec.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: IOSpec - - - - -# Class Methods -## exhaust_write_buffer(io ) [](#method-c-exhaust_write_buffer) - diff --git a/example/ruby/IOSpecs.md b/example/ruby/IOSpecs.md deleted file mode 100644 index a2e2560..0000000 --- a/example/ruby/IOSpecs.md +++ /dev/null @@ -1,31 +0,0 @@ -# Module: IOSpecs - - - - -# Class Methods -## closed_io() [](#method-c-closed_io) -Returns a closed instance of IO that was opened to reference a fixture file -(i.e. the IO instance was perfectly valid at one point but is now closed). -## collector() [](#method-c-collector) -## io_fixture(name , mode "r:utf-8") [](#method-c-io_fixture) -Creates an IO instance for an existing fixture file. The file should obviously -not be deleted. -## io_mock(obj , method , &block ) [](#method-c-io_mock) -Defines `method` on `obj` using the provided `block`. This special helper is -needed for e.g. IO.open specs to avoid mock methods preventing IO#close from -running. -## lines() [](#method-c-lines) -## lines_arbitrary_separator() [](#method-c-lines_arbitrary_separator) -## lines_empty_separator() [](#method-c-lines_empty_separator) -## lines_limit() [](#method-c-lines_limit) -## lines_r_separator() [](#method-c-lines_r_separator) -## lines_space_separator() [](#method-c-lines_space_separator) -## lines_space_separator_limit() [](#method-c-lines_space_separator_limit) -## lines_space_separator_without_trailing_spaces() [](#method-c-lines_space_separator_without_trailing_spaces) -## lines_without_newline_characters() [](#method-c-lines_without_newline_characters) -## paragraphs() [](#method-c-paragraphs) -## paragraphs_without_trailing_new_line_characters() [](#method-c-paragraphs_without_trailing_new_line_characters) -## pipe_fixture(content ) [](#method-c-pipe_fixture) -Creates a pipe-based IO fixture containing the specified contents - diff --git a/example/ruby/IOSpecs/CopyStream.md b/example/ruby/IOSpecs/CopyStream.md deleted file mode 100644 index 2fec9d2..0000000 --- a/example/ruby/IOSpecs/CopyStream.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: IOSpecs::CopyStream - - - - -# Class Methods -## from() [](#method-c-from) -## from=(from ) [](#method-c-from=) - diff --git a/example/ruby/IOSpecs/CopyStreamRead.md b/example/ruby/IOSpecs/CopyStreamRead.md deleted file mode 100644 index 386e032..0000000 --- a/example/ruby/IOSpecs/CopyStreamRead.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: IOSpecs::CopyStreamRead -**Inherits:** Object - - - - - -#Instance Methods -## initialize(io) [](#method-i-initialize) - -**@return** [CopyStreamRead] a new instance of CopyStreamRead - -## read(size, buf) [](#method-i-read) - -## send(*args) [](#method-i-send) - diff --git a/example/ruby/IOSpecs/CopyStreamReadPartial.md b/example/ruby/IOSpecs/CopyStreamReadPartial.md deleted file mode 100644 index f51e581..0000000 --- a/example/ruby/IOSpecs/CopyStreamReadPartial.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: IOSpecs::CopyStreamReadPartial -**Inherits:** Object - - - - - -#Instance Methods -## initialize(io) [](#method-i-initialize) - -**@return** [CopyStreamReadPartial] a new instance of CopyStreamReadPartial - -## readpartial(size, buf) [](#method-i-readpartial) - -## send(*args) [](#method-i-send) - diff --git a/example/ruby/IOSpecs/SubIO.md b/example/ruby/IOSpecs/SubIO.md deleted file mode 100644 index 06e7b51..0000000 --- a/example/ruby/IOSpecs/SubIO.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: IOSpecs::SubIO -**Inherits:** IO - - - - - diff --git a/example/ruby/IOSpecs/SubIOWithRedefinedNew.md b/example/ruby/IOSpecs/SubIOWithRedefinedNew.md deleted file mode 100644 index 893a4b4..0000000 --- a/example/ruby/IOSpecs/SubIOWithRedefinedNew.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: IOSpecs::SubIOWithRedefinedNew -**Inherits:** IO - - - - -# Class Methods -## new() [](#method-c-new) - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [SubIOWithRedefinedNew] a new instance of SubIOWithRedefinedNew - diff --git a/example/ruby/IOStub.md b/example/ruby/IOStub.md deleted file mode 100644 index 9f03b50..0000000 --- a/example/ruby/IOStub.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: IOStub -**Inherits:** Object - - - - - -#Instance Methods -## <<(str) [](#method-i-<<) - -## ==(other) [](#method-i-==) - -## =~(other) [](#method-i-=~) - -## flush() [](#method-i-flush) - -## initialize() [](#method-i-initialize) - -**@return** [IOStub] a new instance of IOStub - -## inspect() [](#method-i-inspect) - -## method_missing(name, *args, &block) [](#method-i-method_missing) - -## print(*str) [](#method-i-print) - -## printf(format, *args) [](#method-i-printf) - -## puts(*str) [](#method-i-puts) - -## to_s() [](#method-i-to_s) - -## write(*str) [](#method-i-write) - diff --git a/example/ruby/IPAddr.md b/example/ruby/IPAddr.md deleted file mode 100644 index 7590006..0000000 --- a/example/ruby/IPAddr.md +++ /dev/null @@ -1,286 +0,0 @@ -# Class: IPAddr -**Inherits:** Object - -**Includes:** Comparable - - -IPAddr provides a set of methods to manipulate an IP address. Both IPv4 and -IPv6 are supported. - -## Example - - require 'ipaddr' - - ipaddr1 = IPAddr.new "3ffe:505:2::1" - - p ipaddr1 #=> # - - p ipaddr1.to_s #=> "3ffe:505:2::1" - - ipaddr2 = ipaddr1.mask(48) #=> # - - p ipaddr2.to_s #=> "3ffe:505:2::" - - ipaddr3 = IPAddr.new "192.168.2.0/24" - - p ipaddr3 #=> # - - -# Class Methods -## new_ntoh(addr ) [](#method-c-new_ntoh) -Creates a new ipaddr containing the given network byte ordered string form of -an IP address. -## ntop(addr ) [](#method-c-ntop) -Convert a network byte ordered string form of an IP address into human -readable form. It expects the string to be encoded in Encoding::ASCII_8BIT -(BINARY). -# Attributes -## family[RW] [](#attribute-i-family) -Returns the address family of this IP address. - - -#Instance Methods -## &(other) [](#method-i-&) -Returns a new ipaddr built by bitwise AND. - -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <<(num) [](#method-i-<<) -Returns a new ipaddr built by bitwise left shift. - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Compares the ipaddr with another. - -## ==(other) [](#method-i-==) -Returns true if two ipaddrs are equal. - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## >>(num) [](#method-i->>) -Returns a new ipaddr built by bitwise right-shift. - -## as_json() [](#method-i-as_json) -Returns a string containing the IP address representation with prefix. - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## cidr() [](#method-i-cidr) -Returns a string containing the IP address representation in cidr notation - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## eql?(other) [](#method-i-eql?) -Checks equality used by Hash. - -**@return** [Boolean] - -## hash() [](#method-i-hash) -Returns a hash value used by Hash, Set, and Array classes - -## hton() [](#method-i-hton) -Returns a network byte ordered string form of the IP address. - -## include?(other) [](#method-i-include?) -Returns true if the given ipaddr is in the range. - -e.g.: - require 'ipaddr' - net1 = IPAddr.new("192.168.2.0/24") - net2 = IPAddr.new("192.168.2.100") - net3 = IPAddr.new("192.168.3.0") - net4 = IPAddr.new("192.168.2.0/16") - p net1.include?(net2) #=> true - p net1.include?(net3) #=> false - p net1.include?(net4) #=> false - p net4.include?(net1) #=> true - -**@return** [Boolean] - -## inspect() [](#method-i-inspect) -Returns a string containing a human-readable representation of the ipaddr. -("#") - -## ip6_arpa() [](#method-i-ip6_arpa) -Returns a string for DNS reverse lookup compatible with RFC3172. - -## ip6_int() [](#method-i-ip6_int) -Returns a string for DNS reverse lookup compatible with RFC1886. - -## ipv4?() [](#method-i-ipv4?) -Returns true if the ipaddr is an IPv4 address. - -**@return** [Boolean] - -## ipv4_compat() [](#method-i-ipv4_compat) -Returns a new ipaddr built by converting the native IPv4 address into an -IPv4-compatible IPv6 address. - -## ipv4_compat?() [](#method-i-ipv4_compat?) -Returns true if the ipaddr is an IPv4-compatible IPv6 address. - -**@return** [Boolean] - -## ipv4_mapped() [](#method-i-ipv4_mapped) -Returns a new ipaddr built by converting the native IPv4 address into an -IPv4-mapped IPv6 address. - -## ipv4_mapped?() [](#method-i-ipv4_mapped?) -Returns true if the ipaddr is an IPv4-mapped IPv6 address. - -**@return** [Boolean] - -## ipv6?() [](#method-i-ipv6?) -Returns true if the ipaddr is an IPv6 address. - -**@return** [Boolean] - -## link_local?() [](#method-i-link_local?) -Returns true if the ipaddr is a link-local address. IPv4 addresses in -169.254.0.0/16 reserved by RFC 3927 and link-local IPv6 Unicast Addresses in -fe80::/10 reserved by RFC 4291 are considered link-local. Link-local IPv4 -addresses in the IPv4-mapped IPv6 address range are also considered -link-local. - -**@return** [Boolean] - -## loopback?() [](#method-i-loopback?) -Returns true if the ipaddr is a loopback address. Loopback IPv4 addresses in -the IPv4-mapped IPv6 address range are also considered as loopback addresses. - -**@return** [Boolean] - -## mask(prefixlen) [](#method-i-mask) -Returns a new ipaddr built by masking IP address with the given -prefixlen/netmask. (e.g. 8, 64, "255.255.255.0", etc.) - -## native() [](#method-i-native) -Returns a new ipaddr built by converting the IPv6 address into a native IPv4 -address. If the IP address is not an IPv4-mapped or IPv4-compatible IPv6 -address, returns self. - -## netmask() [](#method-i-netmask) -Returns the netmask in string format e.g. 255.255.0.0 - -## prefix() [](#method-i-prefix) -Returns the prefix length in bits for the ipaddr. - -## prefix=(prefix) [](#method-i-prefix=) -Sets the prefix length in bits - -## private?() [](#method-i-private?) -Returns true if the ipaddr is a private address. IPv4 addresses in -10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 as defined in RFC 1918 and IPv6 -Unique Local Addresses in fc00::/7 as defined in RFC 4193 are considered -private. Private IPv4 addresses in the IPv4-mapped IPv6 address range are also -considered private. - -**@return** [Boolean] - -## reverse() [](#method-i-reverse) -Returns a string for DNS reverse lookup. It returns a string in RFC3172 form -for an IPv6 address. - -## succ() [](#method-i-succ) -Returns the successor to the ipaddr. - -## to_i() [](#method-i-to_i) -Returns the integer representation of the ipaddr. - -## to_json(*a) [](#method-i-to_json) -Returns a json string containing the IP address representation. - -## to_range() [](#method-i-to_range) -Creates a Range object for the network address. - -## to_s() [](#method-i-to_s) -Returns a string containing the IP address representation. - -## to_string() [](#method-i-to_string) -Returns a string containing the IP address representation in canonical form. - -## wildcard_mask() [](#method-i-wildcard_mask) -Returns the wildcard mask in string format e.g. 0.0.255.255 - -## zone_id() [](#method-i-zone_id) -Returns the IPv6 zone identifier, if present. Raises InvalidAddressError if -not an IPv6 address. - -## zone_id=(zid) [](#method-i-zone_id=) -Returns the IPv6 zone identifier, if present. Raises InvalidAddressError if -not an IPv6 address. - -## |(other) [](#method-i-|) -Returns a new ipaddr built by bitwise OR. - -## ~() [](#method-i-~) -Returns a new ipaddr built by bitwise negation. - diff --git a/example/ruby/IPAddr/AddressFamilyError.md b/example/ruby/IPAddr/AddressFamilyError.md deleted file mode 100644 index 6aeabbc..0000000 --- a/example/ruby/IPAddr/AddressFamilyError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: IPAddr::AddressFamilyError -**Inherits:** IPAddr::Error - - -Raised when the address family is invalid such as an address with an -unsupported family, an address with an inconsistent family, or an address -who's family cannot be determined. - - - diff --git a/example/ruby/IPAddr/Error.md b/example/ruby/IPAddr/Error.md deleted file mode 100644 index 22b8888..0000000 --- a/example/ruby/IPAddr/Error.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: IPAddr::Error -**Inherits:** ArgumentError - - -Generic IPAddr related error. Exceptions raised in this class should inherit -from Error. - - - diff --git a/example/ruby/IPAddr/InvalidAddressError.md b/example/ruby/IPAddr/InvalidAddressError.md deleted file mode 100644 index 1ce50bc..0000000 --- a/example/ruby/IPAddr/InvalidAddressError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: IPAddr::InvalidAddressError -**Inherits:** IPAddr::Error - - -Raised when the provided IP address is an invalid address. - - - diff --git a/example/ruby/IPAddr/InvalidPrefixError.md b/example/ruby/IPAddr/InvalidPrefixError.md deleted file mode 100644 index 6aab19d..0000000 --- a/example/ruby/IPAddr/InvalidPrefixError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: IPAddr::InvalidPrefixError -**Inherits:** IPAddr::InvalidAddressError - - -Raised when the address is an invalid length. - - - diff --git a/example/ruby/IPSocket.md b/example/ruby/IPSocket.md deleted file mode 100644 index c196302..0000000 --- a/example/ruby/IPSocket.md +++ /dev/null @@ -1,83 +0,0 @@ -# Class: IPSocket -**Inherits:** BasicSocket - - -IPSocket is the super class of TCPSocket and UDPSocket. - - -# Class Methods -## getaddress(host ) [](#method-c-getaddress) -Lookups the IP address of *host*. - - require 'socket' - - IPSocket.getaddress("localhost") #=> "127.0.0.1" - IPSocket.getaddress("ip6-localhost") #=> "::1" -**@overload** [] - - -#Instance Methods -## addr(*args) [](#method-i-addr) -Returns the local address as an array which contains address_family, port, -hostname and numeric_address. - -If `reverse_lookup` is `true` or `:hostname`, hostname is obtained from -numeric_address using reverse lookup. Or if it is `false`, or `:numeric`, -hostname is the same as numeric_address. Or if it is `nil` or omitted, obeys -to `ipsocket.do_not_reverse_lookup`. See `Socket.getaddrinfo` also. - - TCPSocket.open("www.ruby-lang.org", 80) {|sock| - p sock.addr #=> ["AF_INET", 49429, "hal", "192.168.0.128"] - p sock.addr(true) #=> ["AF_INET", 49429, "hal", "192.168.0.128"] - p sock.addr(false) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"] - p sock.addr(:hostname) #=> ["AF_INET", 49429, "hal", "192.168.0.128"] - p sock.addr(:numeric) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"] - } - -**@overload** [] - -## inspect() [](#method-i-inspect) -Return a string describing this IPSocket object. - -**@overload** [] - -## peeraddr(*args) [](#method-i-peeraddr) -Returns the remote address as an array which contains address_family, port, -hostname and numeric_address. It is defined for connection oriented socket -such as TCPSocket. - -If `reverse_lookup` is `true` or `:hostname`, hostname is obtained from -numeric_address using reverse lookup. Or if it is `false`, or `:numeric`, -hostname is the same as numeric_address. Or if it is `nil` or omitted, obeys -to `ipsocket.do_not_reverse_lookup`. See `Socket.getaddrinfo` also. - - TCPSocket.open("www.ruby-lang.org", 80) {|sock| - p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] - p sock.peeraddr(true) #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] - p sock.peeraddr(false) #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] - p sock.peeraddr(:hostname) #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] - p sock.peeraddr(:numeric) #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] - } - -**@overload** [] - -## recvfrom(*args) [](#method-i-recvfrom) -Receives a message and return the message as a string and an address which the -message come from. - -*maxlen* is the maximum number of bytes to receive. - -*flags* should be a bitwise OR of Socket::MSG_* constants. - -ipaddr is the same as IPSocket#{peeraddr,addr}. - - u1 = UDPSocket.new - u1.bind("127.0.0.1", 4913) - u2 = UDPSocket.new - u2.send "uuuu", 0, "127.0.0.1", 4913 - p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/IRB.md b/example/ruby/IRB.md deleted file mode 100644 index 5ed5f5d..0000000 --- a/example/ruby/IRB.md +++ /dev/null @@ -1,66 +0,0 @@ -# Module: IRB - - -history.rb - - by Keiju ISHITSUKA(keiju@ruby-lang.org) - - -# Class Methods -## CurrentContext() [](#method-c-CurrentContext) -The current Context in this session -## Inspector(inspect , init nil) [](#method-c-Inspector) -Convenience method to create a new Inspector, using the given `inspect` proc, -and optional `init` proc and passes them to Inspector.new - - irb(main):001:0> ins = IRB::Inspector(proc{ |v| "omg! #{v}" }) - irb(main):001:0> IRB.CurrentContext.inspect_mode = ins # => omg! # - irb(main):001:0> "what?" #=> omg! what? -## JobManager() [](#method-c-JobManager) -The current JobManager in the session -## conf() [](#method-c-conf) -Displays current configuration. - -Modifying the configuration is achieved by sending a message to IRB.conf. - -See IRB@Configuration for more information. -## init_config(ap_path ) [](#method-c-init_config) -## init_error() [](#method-c-init_error) -## initialized?() [](#method-c-initialized?) -**@return** [Boolean] - -## inspect() [](#method-c-inspect) -## irb(file nil, *main ) [](#method-c-irb) -Creates a new IRB session, see Irb.new. - -The optional `file` argument is given to Context.new, along with the workspace -created with the remaining arguments, see WorkSpace.new -## irb_abort(irb , exception Abort) [](#method-c-irb_abort) -Aborts then interrupts irb. - -Will raise an Abort exception, or the given `exception`. -## irb_exit() [](#method-c-irb_exit) -Quits irb -## irbrc_files() [](#method-c-irbrc_files) -## load_modules() [](#method-c-load_modules) -loading modules -## parse_opts(argv: ::ARGV) [](#method-c-parse_opts) -option analyzing -## print_usage() [](#method-c-print_usage) -Outputs the irb help message, see IRB@Command-Line+Options. -## raise_validation_error(msg ) [](#method-c-raise_validation_error) -**@raise** [TypeError] - -## rc_file(ext ) [](#method-c-rc_file) -## run_config() [](#method-c-run_config) -Run the config file -## set_measure_callback(type nil, arg nil, &block ) [](#method-c-set_measure_callback) -## setup(ap_path , argv: ::ARGV) [](#method-c-setup) -initialize config -## start(ap_path nil) [](#method-c-start) -Initializes IRB and creates a new Irb.irb object at the `TOPLEVEL_BINDING` -## unset_measure_callback(type nil) [](#method-c-unset_measure_callback) -## validate_config() [](#method-c-validate_config) -## version() [](#method-c-version) -Returns the current version of IRB, including release version and last updated -date. - diff --git a/example/ruby/IRB/Abort.md b/example/ruby/IRB/Abort.md deleted file mode 100644 index 6469674..0000000 --- a/example/ruby/IRB/Abort.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: IRB::Abort -**Inherits:** Exception - - -An exception raised by IRB.irb_abort - - - diff --git a/example/ruby/IRB/BaseCompletor.md b/example/ruby/IRB/BaseCompletor.md deleted file mode 100644 index 6966cbf..0000000 --- a/example/ruby/IRB/BaseCompletor.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: IRB::BaseCompletor -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## command_candidates(target) [](#method-i-command_candidates) - -## completion_candidates(preposing, target, postposing, bind:) [](#method-i-completion_candidates) - -**@raise** [NotImplementedError] - -## doc_namespace(preposing, matched, postposing, bind:) [](#method-i-doc_namespace) - -**@raise** [NotImplementedError] - -## retrieve_files_to_require_from_load_path() [](#method-i-retrieve_files_to_require_from_load_path) - -## retrieve_files_to_require_relative_from_current_dir() [](#method-i-retrieve_files_to_require_relative_from_current_dir) - -## retrieve_gem_and_system_load_path() [](#method-i-retrieve_gem_and_system_load_path) - diff --git a/example/ruby/IRB/CallTracer.md b/example/ruby/IRB/CallTracer.md deleted file mode 100644 index 340c5f6..0000000 --- a/example/ruby/IRB/CallTracer.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::CallTracer -**Inherits:** CallTracer - - - - - -#Instance Methods -## skip?(tp) [](#method-i-skip?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/CantChangeBinding.md b/example/ruby/IRB/CantChangeBinding.md deleted file mode 100644 index da779c3..0000000 --- a/example/ruby/IRB/CantChangeBinding.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::CantChangeBinding -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -**@return** [CantChangeBinding] a new instance of CantChangeBinding - diff --git a/example/ruby/IRB/CantReturnToNormalMode.md b/example/ruby/IRB/CantReturnToNormalMode.md deleted file mode 100644 index 418755d..0000000 --- a/example/ruby/IRB/CantReturnToNormalMode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::CantReturnToNormalMode -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [CantReturnToNormalMode] a new instance of CantReturnToNormalMode - diff --git a/example/ruby/IRB/Canvas.md b/example/ruby/IRB/Canvas.md deleted file mode 100644 index f0b31c0..0000000 --- a/example/ruby/IRB/Canvas.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: IRB::Canvas -**Inherits:** Object - - - - - -#Instance Methods -## draw() [](#method-i-draw) - -## initialize(h, w) [](#method-i-initialize) - -**@return** [Canvas] a new instance of Canvas - -## line(x1, y1, x2, y2) [](#method-i-line) - diff --git a/example/ruby/IRB/Color.md b/example/ruby/IRB/Color.md deleted file mode 100644 index 39f241c..0000000 --- a/example/ruby/IRB/Color.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: IRB::Color - - - - -# Class Methods -## clear(colorable: colorable?) -) [](#method-c-clear) -## colorable?() [](#method-c-colorable?) -**@return** [Boolean] - -## colorize(text , seq , colorable: colorable?) -) [](#method-c-colorize) -## colorize_code(code , complete: true, ignore_error: false, colorable: colorable?, , local_variables: []) [](#method-c-colorize_code) -If `complete` is false (code is incomplete), this does not warn compile_error. -This option is needed to avoid warning a user when the compile_error is -happening because the input is not wrong but just incomplete. -## inspect_colorable?(obj , seen: {}.compare_by_identity) [](#method-c-inspect_colorable?) -**@return** [Boolean] - - diff --git a/example/ruby/IRB/ColorPrinter.md b/example/ruby/IRB/ColorPrinter.md deleted file mode 100644 index e447a59..0000000 --- a/example/ruby/IRB/ColorPrinter.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: IRB::ColorPrinter -**Inherits:** PP - - - - -# Class Methods -## pp(obj , out $>, width screen_width) [](#method-c-pp) - -#Instance Methods -## pp(obj) [](#method-i-pp) - -## text(str, widthnil) [](#method-i-text) - diff --git a/example/ruby/IRB/Command.md b/example/ruby/IRB/Command.md deleted file mode 100644 index 486b99d..0000000 --- a/example/ruby/IRB/Command.md +++ /dev/null @@ -1,28 +0,0 @@ -# Module: IRB::Command - - -:stopdoc: - - -# Class Methods -## _register_with_aliases(name , command_class , *aliases ) [](#method-c-_register_with_aliases) -This API is for IRB's internal use only and may change at any time. Please do -NOT use it. -## all_commands_info() [](#method-c-all_commands_info) -## command_names() [](#method-c-command_names) -## command_override_policies() [](#method-c-command_override_policies) -## execute_as_command?(name , public_method: , private_method: ) [](#method-c-execute_as_command?) -**@return** [Boolean] - -## extract_ruby_args(*args , **kwargs ) [](#method-c-extract_ruby_args) -:nodoc: -## load_command(command ) [](#method-c-load_command) -Convert a command name to its implementation class if such command exists -## register(name , command_class ) [](#method-c-register) -Registers a command with the given name. Aliasing is intentionally not -supported at the moment. -# Attributes -## commands[RW] [](#attribute-c-commands) -Returns the value of attribute commands. - - diff --git a/example/ruby/IRB/Command/Backtrace.md b/example/ruby/IRB/Command/Backtrace.md deleted file mode 100644 index 51f3dac..0000000 --- a/example/ruby/IRB/Command/Backtrace.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Backtrace -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Base.md b/example/ruby/IRB/Command/Base.md deleted file mode 100644 index 9be8eed..0000000 --- a/example/ruby/IRB/Command/Base.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: IRB::Command::Base -**Inherits:** Object - - - - -# Class Methods -## category(category nil) [](#method-c-category) -## description(description nil) [](#method-c-description) -## execute(irb_context , arg ) [](#method-c-execute) -## help_message(help_message nil) [](#method-c-help_message) -# Attributes -## irb_context[RW] [](#attribute-i-irb_context) -Returns the value of attribute irb_context. - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## initialize(irb_context) [](#method-i-initialize) - -**@return** [Base] a new instance of Base - diff --git a/example/ruby/IRB/Command/Break.md b/example/ruby/IRB/Command/Break.md deleted file mode 100644 index 4daa337..0000000 --- a/example/ruby/IRB/Command/Break.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Break -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/CD.md b/example/ruby/IRB/Command/CD.md deleted file mode 100644 index 347cc8a..0000000 --- a/example/ruby/IRB/Command/CD.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::CD -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Catch.md b/example/ruby/IRB/Command/Catch.md deleted file mode 100644 index a5744dc..0000000 --- a/example/ruby/IRB/Command/Catch.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Catch -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/ChangeWorkspace.md b/example/ruby/IRB/Command/ChangeWorkspace.md deleted file mode 100644 index 03aa922..0000000 --- a/example/ruby/IRB/Command/ChangeWorkspace.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::ChangeWorkspace -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/CommandArgumentError.md b/example/ruby/IRB/Command/CommandArgumentError.md deleted file mode 100644 index 304cfd4..0000000 --- a/example/ruby/IRB/Command/CommandArgumentError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: IRB::Command::CommandArgumentError -**Inherits:** StandardError - - -:nodoc: - - - diff --git a/example/ruby/IRB/Command/Context.md b/example/ruby/IRB/Command/Context.md deleted file mode 100644 index aac7b84..0000000 --- a/example/ruby/IRB/Command/Context.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Context -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Continue.md b/example/ruby/IRB/Command/Continue.md deleted file mode 100644 index 4cc3afb..0000000 --- a/example/ruby/IRB/Command/Continue.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Continue -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/CurrentWorkingWorkspace.md b/example/ruby/IRB/Command/CurrentWorkingWorkspace.md deleted file mode 100644 index 8a09e29..0000000 --- a/example/ruby/IRB/Command/CurrentWorkingWorkspace.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::CurrentWorkingWorkspace -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Debug.md b/example/ruby/IRB/Command/Debug.md deleted file mode 100644 index bc20ef4..0000000 --- a/example/ruby/IRB/Command/Debug.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::Command::Debug -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - -## execute_debug_command(pre_cmds:nil, do_cmds:nil) [](#method-i-execute_debug_command) - diff --git a/example/ruby/IRB/Command/DebugCommand.md b/example/ruby/IRB/Command/DebugCommand.md deleted file mode 100644 index 85200e5..0000000 --- a/example/ruby/IRB/Command/DebugCommand.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::DebugCommand -**Inherits:** IRB::Command::Debug - - - - -# Class Methods -## category() [](#method-c-category) -## description() [](#method-c-description) - diff --git a/example/ruby/IRB/Command/Delete.md b/example/ruby/IRB/Command/Delete.md deleted file mode 100644 index 4cc1e22..0000000 --- a/example/ruby/IRB/Command/Delete.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Delete -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/DisableIrb.md b/example/ruby/IRB/Command/DisableIrb.md deleted file mode 100644 index 22fa705..0000000 --- a/example/ruby/IRB/Command/DisableIrb.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::DisableIrb -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute() [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Edit.md b/example/ruby/IRB/Command/Edit.md deleted file mode 100644 index ecb0520..0000000 --- a/example/ruby/IRB/Command/Edit.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: IRB::Command::Edit -**Inherits:** IRB::Command::Base - -**Includes:** IRB::Command::RubyArgsExtractor - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## ruby_args(arg) [](#method-i-ruby_args) - -## unwrap_string_literal(str) [](#method-i-unwrap_string_literal) -:nodoc: - diff --git a/example/ruby/IRB/Command/Exit.md b/example/ruby/IRB/Command/Exit.md deleted file mode 100644 index 76b9341..0000000 --- a/example/ruby/IRB/Command/Exit.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Exit -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Finish.md b/example/ruby/IRB/Command/Finish.md deleted file mode 100644 index 96eb761..0000000 --- a/example/ruby/IRB/Command/Finish.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Finish -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/ForceExit.md b/example/ruby/IRB/Command/ForceExit.md deleted file mode 100644 index 444d963..0000000 --- a/example/ruby/IRB/Command/ForceExit.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::ForceExit -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Foreground.md b/example/ruby/IRB/Command/Foreground.md deleted file mode 100644 index 9d0a8eb..0000000 --- a/example/ruby/IRB/Command/Foreground.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: IRB::Command::Foreground -**Inherits:** IRB::Command::MultiIRBCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## execute_internal(keynil) [](#method-i-execute_internal) - -**@raise** [CommandArgumentError] - diff --git a/example/ruby/IRB/Command/Help.md b/example/ruby/IRB/Command/Help.md deleted file mode 100644 index ff8c042..0000000 --- a/example/ruby/IRB/Command/Help.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Help -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(command_name) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/History.md b/example/ruby/IRB/Command/History.md deleted file mode 100644 index 0e3a106..0000000 --- a/example/ruby/IRB/Command/History.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::History -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Info.md b/example/ruby/IRB/Command/Info.md deleted file mode 100644 index b27e859..0000000 --- a/example/ruby/IRB/Command/Info.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Info -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/IrbCommand.md b/example/ruby/IRB/Command/IrbCommand.md deleted file mode 100644 index ff5f1fc..0000000 --- a/example/ruby/IRB/Command/IrbCommand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::Command::IrbCommand -**Inherits:** IRB::Command::MultiIRBCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## execute_internal(*obj) [](#method-i-execute_internal) - diff --git a/example/ruby/IRB/Command/IrbInfo.md b/example/ruby/IRB/Command/IrbInfo.md deleted file mode 100644 index e6b5c8f..0000000 --- a/example/ruby/IRB/Command/IrbInfo.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::IrbInfo -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Jobs.md b/example/ruby/IRB/Command/Jobs.md deleted file mode 100644 index b2080d5..0000000 --- a/example/ruby/IRB/Command/Jobs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Jobs -**Inherits:** IRB::Command::MultiIRBCommand - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Kill.md b/example/ruby/IRB/Command/Kill.md deleted file mode 100644 index 52a6eb2..0000000 --- a/example/ruby/IRB/Command/Kill.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::Command::Kill -**Inherits:** IRB::Command::MultiIRBCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## execute_internal(*keys) [](#method-i-execute_internal) - diff --git a/example/ruby/IRB/Command/Load.md b/example/ruby/IRB/Command/Load.md deleted file mode 100644 index 3d22b94..0000000 --- a/example/ruby/IRB/Command/Load.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::Command::Load -**Inherits:** IRB::Command::LoaderCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## execute_internal(file_namenil, privnil) [](#method-i-execute_internal) - diff --git a/example/ruby/IRB/Command/LoaderCommand.md b/example/ruby/IRB/Command/LoaderCommand.md deleted file mode 100644 index c373a9e..0000000 --- a/example/ruby/IRB/Command/LoaderCommand.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: IRB::Command::LoaderCommand -**Inherits:** IRB::Command::Base - -**Includes:** IRB::Command::RubyArgsExtractor, IRB::IrbLoader - - - - - -#Instance Methods -## irb_load(fn, privnil) [](#method-i-irb_load) -Loads the given file similarly to Kernel#load - -**@raise** [LoadError] - -## load_file(path, privnil) [](#method-i-load_file) -Loads the given file in the current session's context and evaluates it. - -See Irb#suspend_input_method for more information. - -## old() [](#method-i-old) -:nodoc: - -## raise_cmd_argument_error() [](#method-i-raise_cmd_argument_error) - -**@raise** [CommandArgumentError] - -## ruby_args(arg) [](#method-i-ruby_args) - -## search_file_from_ruby_path(fn) [](#method-i-search_file_from_ruby_path) -:nodoc: - -## source_file(path) [](#method-i-source_file) -Loads a given file in the current session and displays the source lines - -See Irb#suspend_input_method for more information. - -## unwrap_string_literal(str) [](#method-i-unwrap_string_literal) -:nodoc: - diff --git a/example/ruby/IRB/Command/Ls.md b/example/ruby/IRB/Command/Ls.md deleted file mode 100644 index 3824743..0000000 --- a/example/ruby/IRB/Command/Ls.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: IRB::Command::Ls -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## class_method_map(classes, dumped_mods) [](#method-i-class_method_map) - -## dump_methods(o, klass, obj) [](#method-i-dump_methods) - -## evaluate(code) [](#method-i-evaluate) - -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Ls/EvaluationError.md b/example/ruby/IRB/Command/Ls/EvaluationError.md deleted file mode 100644 index 5b1867f..0000000 --- a/example/ruby/IRB/Command/Ls/EvaluationError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IRB::Command::Ls::EvaluationError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/IRB/Command/Measure.md b/example/ruby/IRB/Command/Measure.md deleted file mode 100644 index d1a1b50..0000000 --- a/example/ruby/IRB/Command/Measure.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: IRB::Command::Measure -**Inherits:** IRB::Command::Base - -**Includes:** IRB::Command::RubyArgsExtractor - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## execute_internal(typenil, argnil) [](#method-i-execute_internal) - -## initialize(*args) [](#method-i-initialize) - -**@return** [Measure] a new instance of Measure - -## ruby_args(arg) [](#method-i-ruby_args) - -## unwrap_string_literal(str) [](#method-i-unwrap_string_literal) -:nodoc: - diff --git a/example/ruby/IRB/Command/MultiIRBCommand.md b/example/ruby/IRB/Command/MultiIRBCommand.md deleted file mode 100644 index 381cad3..0000000 --- a/example/ruby/IRB/Command/MultiIRBCommand.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: IRB::Command::MultiIRBCommand -**Inherits:** IRB::Command::Base - -**Includes:** IRB::Command::RubyArgsExtractor - - - - - -#Instance Methods -## ruby_args(arg) [](#method-i-ruby_args) - -## unwrap_string_literal(str) [](#method-i-unwrap_string_literal) -:nodoc: - diff --git a/example/ruby/IRB/Command/Next.md b/example/ruby/IRB/Command/Next.md deleted file mode 100644 index 807d455..0000000 --- a/example/ruby/IRB/Command/Next.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Next -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/PopWorkspace.md b/example/ruby/IRB/Command/PopWorkspace.md deleted file mode 100644 index 32afa9d..0000000 --- a/example/ruby/IRB/Command/PopWorkspace.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::PopWorkspace -**Inherits:** IRB::Command::Workspaces - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/PushWorkspace.md b/example/ruby/IRB/Command/PushWorkspace.md deleted file mode 100644 index 1c0218f..0000000 --- a/example/ruby/IRB/Command/PushWorkspace.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::PushWorkspace -**Inherits:** IRB::Command::Workspaces - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Require.md b/example/ruby/IRB/Command/Require.md deleted file mode 100644 index e99bc24..0000000 --- a/example/ruby/IRB/Command/Require.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::Command::Require -**Inherits:** IRB::Command::LoaderCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## execute_internal(file_namenil) [](#method-i-execute_internal) - diff --git a/example/ruby/IRB/Command/RubyArgsExtractor.md b/example/ruby/IRB/Command/RubyArgsExtractor.md deleted file mode 100644 index 856ce4d..0000000 --- a/example/ruby/IRB/Command/RubyArgsExtractor.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: IRB::Command::RubyArgsExtractor - - -Internal use only, for default command's backward compatibility. - - - -#Instance Methods -## ruby_args(arg) [](#method-i-ruby_args) - -## unwrap_string_literal(str) [](#method-i-unwrap_string_literal) -:nodoc: - diff --git a/example/ruby/IRB/Command/ShowDoc.md b/example/ruby/IRB/Command/ShowDoc.md deleted file mode 100644 index 19a1de7..0000000 --- a/example/ruby/IRB/Command/ShowDoc.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: IRB::Command::ShowDoc -**Inherits:** IRB::Command::Base - -**Includes:** IRB::Command::RubyArgsExtractor - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## ruby_args(arg) [](#method-i-ruby_args) - -## unwrap_string_literal(str) [](#method-i-unwrap_string_literal) -:nodoc: - diff --git a/example/ruby/IRB/Command/ShowSource.md b/example/ruby/IRB/Command/ShowSource.md deleted file mode 100644 index 58c6466..0000000 --- a/example/ruby/IRB/Command/ShowSource.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: IRB::Command::ShowSource -**Inherits:** IRB::Command::Base - -**Includes:** IRB::Command::RubyArgsExtractor - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## ruby_args(arg) [](#method-i-ruby_args) - -## unwrap_string_literal(str) [](#method-i-unwrap_string_literal) -:nodoc: - diff --git a/example/ruby/IRB/Command/Source.md b/example/ruby/IRB/Command/Source.md deleted file mode 100644 index d125019..0000000 --- a/example/ruby/IRB/Command/Source.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::Command::Source -**Inherits:** IRB::Command::LoaderCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - -## execute_internal(file_namenil) [](#method-i-execute_internal) - diff --git a/example/ruby/IRB/Command/Step.md b/example/ruby/IRB/Command/Step.md deleted file mode 100644 index 14b3980..0000000 --- a/example/ruby/IRB/Command/Step.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Step -**Inherits:** IRB::Command::DebugCommand - - - - - -#Instance Methods -## execute(arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Whereami.md b/example/ruby/IRB/Command/Whereami.md deleted file mode 100644 index d7f49c4..0000000 --- a/example/ruby/IRB/Command/Whereami.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Whereami -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Command/Workspaces.md b/example/ruby/IRB/Command/Workspaces.md deleted file mode 100644 index e8c4d5c..0000000 --- a/example/ruby/IRB/Command/Workspaces.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::Command::Workspaces -**Inherits:** IRB::Command::Base - - - - - -#Instance Methods -## execute(_arg) [](#method-i-execute) - diff --git a/example/ruby/IRB/Context.md b/example/ruby/IRB/Context.md deleted file mode 100644 index cfcf67f..0000000 --- a/example/ruby/IRB/Context.md +++ /dev/null @@ -1,347 +0,0 @@ -# Class: IRB::Context -**Inherits:** Object - - -:nodoc: - - -# Attributes -## ap_name[RW] [](#attribute-i-ap_name) -A copy of the default `IRB.conf[:AP_NAME]` - -## auto_indent_mode[RW] [](#attribute-i-auto_indent_mode) -Can be either the default `IRB.conf[:AUTO_INDENT]`, or the mode set by -#prompt_mode= - -To disable auto-indentation in irb: - - IRB.conf[:AUTO_INDENT] = false - -or - - irb_context.auto_indent_mode = false - -or - - IRB.CurrentContext.auto_indent_mode = false - -See IRB@Configuration for more information. - -## back_trace_limit[RW] [](#attribute-i-back_trace_limit) -The limit of backtrace lines displayed as top `n` and tail `n`. - -The default value is 16. - -Can also be set using the `--back-trace-limit` command line option. - -## command_aliases[RW] [](#attribute-i-command_aliases) -User-defined IRB command aliases - -## echo[RW] [](#attribute-i-echo) -Whether to echo the return value to output or not. - -Uses `IRB.conf[:ECHO]` if available, or defaults to `true`. - - puts "hello" - # hello - #=> nil - IRB.CurrentContext.echo = false - puts "omg" - # omg - -## echo_on_assignment[RW] [](#attribute-i-echo_on_assignment) -Whether to echo for assignment expressions. - -If set to `false`, the value of assignment will not be shown. - -If set to `true`, the value of assignment will be shown. - -If set to `:truncate`, the value of assignment will be shown and truncated. - -It defaults to `:truncate`. - - a = "omg" - #=> omg - - a = "omg" * 10 - #=> omgomgomgomgomgomgomg... - - IRB.CurrentContext.echo_on_assignment = false - a = "omg" - - IRB.CurrentContext.echo_on_assignment = true - a = "omg" * 10 - #=> omgomgomgomgomgomgomgomgomgomg - -To set the behaviour of showing on assignment in irb: - - IRB.conf[:ECHO_ON_ASSIGNMENT] = :truncate or true or false - -or - - irb_context.echo_on_assignment = :truncate or true or false - -or - - IRB.CurrentContext.echo_on_assignment = :truncate or true or false - -## eval_history[RW] [](#attribute-i-eval_history) -The command result history limit. This method is not available until -#eval_history= was called with non-nil value (directly or via setting -`IRB.conf[:EVAL_HISTORY]` in `.irbrc`). - -## extra_doc_dirs[RW] [](#attribute-i-extra_doc_dirs) -Specify the installation locations of the ri file to be displayed in the -document dialog. - -## ignore_eof[RW] [](#attribute-i-ignore_eof) -Whether `^D` (`control-d`) will be ignored or not. - -If set to `false`, `^D` will quit irb. - -## ignore_sigint[RW] [](#attribute-i-ignore_sigint) -Whether `^C` (`control-c`) will be ignored or not. - -If set to `false`, `^C` will quit irb. - -If set to `true`, - -* during input: cancel input then return to top level. -* during execute: abandon current execution. - -## inspect_mode[RW] [](#attribute-i-inspect_mode) -A copy of the default `IRB.conf[:INSPECT_MODE]` - -## io[RW] [](#attribute-i-io) -The current input method. - -Can be either StdioInputMethod, ReadlineInputMethod, RelineInputMethod, -FileInputMethod or other specified when the context is created. See ::new for -more # information on `input_method`. - -## irb[RW] [](#attribute-i-irb) -Current irb session. - -## irb_name[RW] [](#attribute-i-irb_name) -Can be either name from `IRB.conf[:IRB_NAME]`, or the number of the current -job set by JobManager, such as `irb#2` - -## irb_path[RW] [](#attribute-i-irb_path) -Can be one of the following: -* the #irb_name surrounded by parenthesis -* the `input_method` passed to Context.new -* the file path of the current IRB context in a binding.irb session - -## last_value[RW] [](#attribute-i-last_value) -The return value of the last statement evaluated. - -## load_modules[RW] [](#attribute-i-load_modules) -A copy of the default `IRB.conf[:LOAD_MODULES]` - -## newline_before_multiline_output[RW] [](#attribute-i-newline_before_multiline_output) -Whether a newline is put before multiline output. - -Uses `IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]` if available, or defaults to -`true`. - - "abc\ndef" - #=> - abc - def - IRB.CurrentContext.newline_before_multiline_output = false - "abc\ndef" - #=> abc - def - -## prompt_c[RW] [](#attribute-i-prompt_c) -IRB prompt for continuated statement. (e.g. immediately after an `if`) - -See [Custom Prompts](rdoc-ref:IRB@Custom+Prompts) for more information. - -## prompt_i[RW] [](#attribute-i-prompt_i) -Standard IRB prompt. - -See [Custom Prompts](rdoc-ref:IRB@Custom+Prompts) for more information. - -## prompt_mode[RW] [](#attribute-i-prompt_mode) -A copy of the default `IRB.conf[:PROMPT_MODE]` - -## prompt_s[RW] [](#attribute-i-prompt_s) -IRB prompt for continuated strings. - -See [Custom Prompts](rdoc-ref:IRB@Custom+Prompts) for more information. - -## rc[RW] [](#attribute-i-rc) -A copy of the default `IRB.conf[:RC]` - -## return_format[RW] [](#attribute-i-return_format) -The format of the return statement, set by #prompt_mode= using the `:RETURN` -of the `mode` passed to set the current #prompt_mode. - -## thread[RW] [](#attribute-i-thread) -The current thread in this context. - -## use_autocomplete[RW] [](#attribute-i-use_autocomplete) -Whether colorization is enabled or not. - -A copy of the default `IRB.conf[:USE_AUTOCOMPLETE]` - -## use_multiline[RW] [](#attribute-i-use_multiline) -Whether multiline editor mode is enabled or not. - -A copy of the default `IRB.conf[:USE_MULTILINE]` - -## use_singleline[RW] [](#attribute-i-use_singleline) -Whether singleline editor mode is enabled or not. - -A copy of the default `IRB.conf[:USE_SINGLELINE]` - -## verbose[RW] [](#attribute-i-verbose) -Whether verbose messages are displayed or not. - -A copy of the default `IRB.conf[:VERBOSE]` - -## with_debugger[RW] [](#attribute-i-with_debugger) -Returns the value of attribute with_debugger. - -## workspace_home[RW] [](#attribute-i-workspace_home) -The toplevel workspace, see #home_workspace - - -#Instance Methods -## __inspect__() [](#method-i-__inspect__) - -## _set_last_value() [](#method-i-_set_last_value) -Sets the return value from the last statement evaluated in this context to -#last_value. See #set_last_value - -## change_workspace(*_main) [](#method-i-change_workspace) -Changes the current workspace to given object or binding. - -If the optional argument is omitted, the workspace will be #home_workspace -which is inherited from `TOPLEVEL_BINDING` or the main object, -`IRB.conf[:MAIN_CONTEXT]` when irb was initialized. - -See IRB::WorkSpace.new for more information. - -## colorize_input(input, complete:) [](#method-i-colorize_input) - -## evaluate(statement, line_no) [](#method-i-evaluate) -:nodoc: - -## evaluate_expression(code, line_no) [](#method-i-evaluate_expression) -:nodoc: - -## file_input?() [](#method-i-file_input?) -Whether #io uses a File for the `input_method` passed when creating the -current context, see ::new - -**@return** [Boolean] - -## from_binding?() [](#method-i-from_binding?) - -**@return** [Boolean] - -## history_file() [](#method-i-history_file) -A copy of the default `IRB.conf[:HISTORY_FILE]` - -## history_file=(hist) [](#method-i-history_file=) -Set `IRB.conf[:HISTORY_FILE]` to the given `hist`. - -## home_workspace() [](#method-i-home_workspace) -Inherited from `TOPLEVEL_BINDING`. - -## initialize(irb, workspacenil, input_methodnil) [](#method-i-initialize) -Creates a new IRB context. - -The optional `input_method` argument: - -`nil` -: uses stdin or Reline or Readline - -`String` -: uses a File - -`other` -: uses this as InputMethod - - -**@return** [Context] a new instance of Context - -## inspect() [](#method-i-inspect) -:nodoc: - -## inspect?() [](#method-i-inspect?) -Whether #inspect_mode is set or not, see #inspect_mode= for more detail. - -**@return** [Boolean] - -## inspect_last_value() [](#method-i-inspect_last_value) -:nodoc: - -## local_variables() [](#method-i-local_variables) -:nodoc: - -## main() [](#method-i-main) -The top-level workspace, see WorkSpace#main - -## parse_command(code) [](#method-i-parse_command) - -## pop_workspace() [](#method-i-pop_workspace) -Removes the last element from the current #workspaces stack and returns it, or -`nil` if the current workspace stack is empty. - -Also, see #push_workspace. - -## prompt_n() [](#method-i-prompt_n) -TODO: Remove this when developing v2.0 - -## prompt_n=(_) [](#method-i-prompt_n=) -TODO: Remove this when developing v2.0 - -## prompting?() [](#method-i-prompting?) -Whether #verbose? is `true`, and `input_method` is either StdioInputMethod or -RelineInputMethod or ReadlineInputMethod, see #io for more information. - -**@return** [Boolean] - -## push_workspace(*_main) [](#method-i-push_workspace) -Creates a new workspace with the given object or binding, and appends it onto -the current #workspaces stack. - -See IRB::Context#change_workspace and IRB::WorkSpace.new for more information. - -## replace_workspace(workspace) [](#method-i-replace_workspace) -Replace the current workspace with the given `workspace`. - -## safe_method_call_on_main(method_name) [](#method-i-safe_method_call_on_main) - -## save_history() [](#method-i-save_history) - -## save_history=(val) [](#method-i-save_history=) - -## set_last_value(value) [](#method-i-set_last_value) -Sets the return value from the last statement evaluated in this context to -#last_value. - -## use_loader() [](#method-i-use_loader) -Returns whether `irb`'s own file reader method is used by `load`/`require` or -not. - -This mode is globally affected (irb-wide). - -## use_loader=(opt) [](#method-i-use_loader=) -Sets `IRB.conf[:USE_LOADER]` - -See #use_loader for more information. - -## use_tracer=(val) [](#method-i-use_tracer=) - -## verbose?() [](#method-i-verbose?) -Returns whether messages are displayed or not. - -**@return** [Boolean] - -## workspace() [](#method-i-workspace) -Workspace in the current context. - diff --git a/example/ruby/IRB/Debug.md b/example/ruby/IRB/Debug.md deleted file mode 100644 index 213f9c9..0000000 --- a/example/ruby/IRB/Debug.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: IRB::Debug - - - - -# Class Methods -## insert_debug_break(pre_cmds: nil, do_cmds: nil) [](#method-c-insert_debug_break) -## setup(irb ) [](#method-c-setup) - diff --git a/example/ruby/IRB/Debug/SkipPathHelperForIRB.md b/example/ruby/IRB/Debug/SkipPathHelperForIRB.md deleted file mode 100644 index d499977..0000000 --- a/example/ruby/IRB/Debug/SkipPathHelperForIRB.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: IRB::Debug::SkipPathHelperForIRB - - - - - -#Instance Methods -## skip_internal_path?(path) [](#method-i-skip_internal_path?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/Debug/UI.md b/example/ruby/IRB/Debug/UI.md deleted file mode 100644 index 66c2316..0000000 --- a/example/ruby/IRB/Debug/UI.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: IRB::Debug::UI -**Inherits:** DEBUGGER__::UI_Base - - - - - -#Instance Methods -## activate(session, on_fork:false) [](#method-i-activate) - -## after_fork_parent() [](#method-i-after_fork_parent) - -## ask(prompt) [](#method-i-ask) - -## deactivate() [](#method-i-deactivate) - -## initialize(irb) [](#method-i-initialize) - -**@return** [UI] a new instance of UI - -## puts(strnil) [](#method-i-puts) - -## quit(n) [](#method-i-quit) - -## readline(_) [](#method-i-readline) - -## remote?() [](#method-i-remote?) - -**@return** [Boolean] - -## setup_interrupt() [](#method-i-setup_interrupt) - -## width() [](#method-i-width) - diff --git a/example/ruby/IRB/EvalHistory.md b/example/ruby/IRB/EvalHistory.md deleted file mode 100644 index e6c2015..0000000 --- a/example/ruby/IRB/EvalHistory.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: IRB::EvalHistory -**Inherits:** Object - - -Represents history of results of previously evaluated commands. - -Available via `__` variable, only if `IRB.conf[:EVAL_HISTORY]` or -`IRB::CurrentContext().eval_history` is non-nil integer value (by default it -is `nil`). - -Example (in `irb`): - - # Initialize history - IRB::CurrentContext().eval_history = 10 - # => 10 - - # Perform some commands... - 1 + 2 - # => 3 - puts 'x' - # x - # => nil - raise RuntimeError - # ...error raised - - # Inspect history (format is " ": - __ - # => 1 10 - # 2 3 - # 3 nil - - __[1] - # => 10 - - - -#Instance Methods -## [](idx) [](#method-i-[]) -Get one item of the content (both positive and negative indexes work). - -## initialize(size16) [](#method-i-initialize) -:nodoc: - -**@return** [EvalHistory] a new instance of EvalHistory - -## inspect() [](#method-i-inspect) -:nodoc: - -## push(no, val) [](#method-i-push) -:nodoc: - -## real_inspect() [](#method-i-real_inspect) - -## size(size) [](#method-i-size) -:nodoc: - diff --git a/example/ruby/IRB/ExtendCommandBundle.md b/example/ruby/IRB/ExtendCommandBundle.md deleted file mode 100644 index 21de27e..0000000 --- a/example/ruby/IRB/ExtendCommandBundle.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: IRB::ExtendCommandBundle - - -For backward compatibility, we need to keep this module: -* As a container of helper methods -* As a place to register commands with the deprecated def_extend_command - method - - -# Class Methods -## def_extend_command(cmd_name , cmd_class , _ , *aliases ) [](#method-c-def_extend_command) -Drepcated. Use Command.regiser instead. - -#Instance Methods -## irb_load(*opts, &b) [](#method-i-irb_load) -Loads the given file similarly to Kernel#load, see IrbLoader#irb_load - -## irb_require(*opts, &b) [](#method-i-irb_require) -Loads the given file similarly to Kernel#require - diff --git a/example/ruby/IRB/FileInputMethod.md b/example/ruby/IRB/FileInputMethod.md deleted file mode 100644 index 6144d8c..0000000 --- a/example/ruby/IRB/FileInputMethod.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: IRB::FileInputMethod -**Inherits:** IRB::InputMethod - - -Use a File for IO with irb, see InputMethod - - -# Class Methods -## open(file , &block ) [](#method-c-open) - -#Instance Methods -## close() [](#method-i-close) - -## encoding() [](#method-i-encoding) -The external encoding for standard input. - -## eof?() [](#method-i-eof?) -Whether the end of this input method has been reached, returns `true` if there -is no more data to read. - -See IO#eof? for more information. - -**@return** [Boolean] - -## gets() [](#method-i-gets) -Reads the next line from this input method. - -See IO#gets for more information. - -## initialize(file) [](#method-i-initialize) -Creates a new input method object - -**@return** [FileInputMethod] a new instance of FileInputMethod - -## inspect() [](#method-i-inspect) -For debug message - diff --git a/example/ruby/IRB/Frame.md b/example/ruby/IRB/Frame.md deleted file mode 100644 index d13921a..0000000 --- a/example/ruby/IRB/Frame.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: IRB::Frame -**Inherits:** Object - - - - -# Class Methods -## bottom(n 0) [](#method-c-bottom) -Convenience method for Frame#bottom -## sender() [](#method-c-sender) -Returns the binding context of the caller from the last frame initialized -## top(n 0) [](#method-c-top) -Convenience method for Frame#top - -#Instance Methods -## bottom(n0) [](#method-i-bottom) -Returns the `n` number of frames on the call stack from the first frame -initialized. - -Raises FrameOverflow if there are no frames in the given stack range. - -## initialize() [](#method-i-initialize) -Creates a new stack frame - -**@return** [Frame] a new instance of Frame - -## top(n0) [](#method-i-top) -Returns the `n` number of frames on the call stack from the last frame -initialized. - -Raises FrameUnderflow if there are no frames in the given stack range. - -## trace_func(event, file, line, id, binding) [](#method-i-trace_func) -Used by Kernel#set_trace_func to register each event in the call stack - diff --git a/example/ruby/IRB/Frame/FrameOverflow.md b/example/ruby/IRB/Frame/FrameOverflow.md deleted file mode 100644 index 38156bb..0000000 --- a/example/ruby/IRB/Frame/FrameOverflow.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::Frame::FrameOverflow -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [FrameOverflow] a new instance of FrameOverflow - diff --git a/example/ruby/IRB/Frame/FrameUnderflow.md b/example/ruby/IRB/Frame/FrameUnderflow.md deleted file mode 100644 index 3111f35..0000000 --- a/example/ruby/IRB/Frame/FrameUnderflow.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::Frame::FrameUnderflow -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [FrameUnderflow] a new instance of FrameUnderflow - diff --git a/example/ruby/IRB/HelperMethod.md b/example/ruby/IRB/HelperMethod.md deleted file mode 100644 index bf500bf..0000000 --- a/example/ruby/IRB/HelperMethod.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: IRB::HelperMethod - - - - -# Class Methods -## all_helper_methods_info() [](#method-c-all_helper_methods_info) -## register(name , helper_class ) [](#method-c-register) -# Attributes -## helper_methods[RW] [](#attribute-c-helper_methods) -Returns the value of attribute helper_methods. - - diff --git a/example/ruby/IRB/HelperMethod/Base.md b/example/ruby/IRB/HelperMethod/Base.md deleted file mode 100644 index 1db83d5..0000000 --- a/example/ruby/IRB/HelperMethod/Base.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: IRB::HelperMethod::Base -**Inherits:** Object - -**Includes:** Singleton - - - - -# Class Methods -## description(description nil) [](#method-c-description) - -#Instance Methods -## _dump(depth-1)) [](#method-i-_dump) -By default, do not retain any state when marshalling. - -## clone() [](#method-i-clone) -Raises a TypeError to prevent cloning. - -**@raise** [TypeError] - -## dup() [](#method-i-dup) -Raises a TypeError to prevent duping. - -**@raise** [TypeError] - diff --git a/example/ruby/IRB/HelperMethod/Conf.md b/example/ruby/IRB/HelperMethod/Conf.md deleted file mode 100644 index f594a4c..0000000 --- a/example/ruby/IRB/HelperMethod/Conf.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: IRB::HelperMethod::Conf -**Inherits:** IRB::HelperMethod::Base - - - - - -#Instance Methods -## execute() [](#method-i-execute) - diff --git a/example/ruby/IRB/HelpersContainer.md b/example/ruby/IRB/HelpersContainer.md deleted file mode 100644 index b008a75..0000000 --- a/example/ruby/IRB/HelpersContainer.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: IRB::HelpersContainer - - - - -# Class Methods -## install_helper_methods() [](#method-c-install_helper_methods) - diff --git a/example/ruby/IRB/History.md b/example/ruby/IRB/History.md deleted file mode 100644 index 904d5da..0000000 --- a/example/ruby/IRB/History.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: IRB::History - - - - -# Class Methods -## history_file() [](#method-c-history_file) -Might be nil when HOME and XDG_CONFIG_HOME are not available. -## infinite?() [](#method-c-infinite?) -**@return** [Boolean] - -## save_history() [](#method-c-save_history) -Integer representation of `IRB.conf[:HISTORY_FILE]`. -## save_history?() [](#method-c-save_history?) -**@return** [Boolean] - - diff --git a/example/ruby/IRB/HistorySavingAbility.md b/example/ruby/IRB/HistorySavingAbility.md deleted file mode 100644 index c5f3140..0000000 --- a/example/ruby/IRB/HistorySavingAbility.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: IRB::HistorySavingAbility - - -:nodoc: - - - -#Instance Methods -## load_history() [](#method-i-load_history) - -## reset_history_counter() [](#method-i-reset_history_counter) - -## save_history() [](#method-i-save_history) - -## support_history_saving?() [](#method-i-support_history_saving?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/IllegalParameter.md b/example/ruby/IRB/IllegalParameter.md deleted file mode 100644 index 69f4359..0000000 --- a/example/ruby/IRB/IllegalParameter.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::IllegalParameter -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -**@return** [IllegalParameter] a new instance of IllegalParameter - diff --git a/example/ruby/IRB/InputCompletor.md b/example/ruby/IRB/InputCompletor.md deleted file mode 100644 index 3cf0678..0000000 --- a/example/ruby/IRB/InputCompletor.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: IRB::InputCompletor - - - - -# Class Methods -## retrieve_completion_data(input , bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false) [](#method-c-retrieve_completion_data) - diff --git a/example/ruby/IRB/InputMethod.md b/example/ruby/IRB/InputMethod.md deleted file mode 100644 index 595dd68..0000000 --- a/example/ruby/IRB/InputMethod.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: IRB::InputMethod -**Inherits:** Object - - - - -# Attributes -## prompt[RW] [](#attribute-i-prompt) -The irb prompt associated with this input method - - -#Instance Methods -## gets() [](#method-i-gets) -Reads the next line from this input method. - -See IO#gets for more information. - -## inspect() [](#method-i-inspect) -For debug message - -## prompting?() [](#method-i-prompting?) - -**@return** [Boolean] - -## readable_after_eof?() [](#method-i-readable_after_eof?) -Whether this input method is still readable when there is no more data to -read. - -See IO#eof for more information. - -**@return** [Boolean] - -## support_history_saving?() [](#method-i-support_history_saving?) - -**@return** [Boolean] - -## winsize() [](#method-i-winsize) - diff --git a/example/ruby/IRB/Inspector.md b/example/ruby/IRB/Inspector.md deleted file mode 100644 index b54abd7..0000000 --- a/example/ruby/IRB/Inspector.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: IRB::Inspector -**Inherits:** Object - - -An irb inspector - -In order to create your own custom inspector there are two things you should -be aware of: - -Inspector uses #inspect_value, or `inspect_proc`, for output of return values. - -This also allows for an optional #init+, or `init_proc`, which is called when -the inspector is activated. - -Knowing this, you can create a rudimentary inspector as follows: - - irb(main):001:0> ins = IRB::Inspector.new(proc{ |v| "omg! #{v}" }) - irb(main):001:0> IRB.CurrentContext.inspect_mode = ins # => omg! # - irb(main):001:0> "what?" #=> omg! what? - - -# Class Methods -## def_inspector(key , arg nil, &block ) [](#method-c-def_inspector) -Example - - Inspector.def_inspector(key, init_p=nil){|v| v.inspect} - Inspector.def_inspector([key1,..], init_p=nil){|v| v.inspect} - Inspector.def_inspector(key, inspector) - Inspector.def_inspector([key1,...], inspector) -## keys_with_inspector(inspector ) [](#method-c-keys_with_inspector) -Determines the inspector to use where `inspector` is one of the keys passed -during inspector definition. - -#Instance Methods -## init() [](#method-i-init) -Proc to call when the inspector is activated, good for requiring dependent -libraries. - -## initialize(inspect_proc, init_procnil) [](#method-i-initialize) -Creates a new inspector object, using the given `inspect_proc` when output -return values in irb. - -**@return** [Inspector] a new instance of Inspector - -## inspect_value(v) [](#method-i-inspect_value) -Proc to call when the input is evaluated and output in irb. - diff --git a/example/ruby/IRB/Irb.md b/example/ruby/IRB/Irb.md deleted file mode 100644 index d66e830..0000000 --- a/example/ruby/IRB/Irb.md +++ /dev/null @@ -1,85 +0,0 @@ -# Class: IRB::Irb -**Inherits:** Object - - - - -# Attributes -## context[RW] [](#attribute-i-context) -Returns the current context of this irb session - -## from_binding[RW] [](#attribute-i-from_binding) -Returns the value of attribute from_binding. - -## scanner[RW] [](#attribute-i-scanner) -The lexer used by this irb session - - -#Instance Methods -## build_statement(code) [](#method-i-build_statement) - -## command?(code) [](#method-i-command?) - -**@return** [Boolean] - -## configure_io() [](#method-i-configure_io) - -## convert_invalid_byte_sequence(str, enc) [](#method-i-convert_invalid_byte_sequence) - -## debug_break() [](#method-i-debug_break) -A hook point for `debug` command's breakpoint after :IRB_EXIT as well as its -clean-up - -## debug_readline(binding) [](#method-i-debug_readline) - -## each_top_level_statement() [](#method-i-each_top_level_statement) - -## encode_with_invalid_byte_sequence(str, enc) [](#method-i-encode_with_invalid_byte_sequence) - -## eval_input() [](#method-i-eval_input) -Evaluates input for this session. - -## handle_exception(exc) [](#method-i-handle_exception) - -## initialize(workspacenil, input_methodnil, from_binding:false) [](#method-i-initialize) -Creates a new irb session - -**@return** [Irb] a new instance of Irb - -## inspect() [](#method-i-inspect) -Outputs the local variables to this current session, including #signal_status -and #context, using IRB::Locale. - -## output_value(omitfalse) [](#method-i-output_value) -:nodoc: - -## read_input(prompt) [](#method-i-read_input) - -## readmultiline() [](#method-i-readmultiline) - -## run(confIRB.conf) [](#method-i-run) - -## signal_handle() [](#method-i-signal_handle) -Handler for the signal SIGINT, see Kernel#trap for more information. - -## signal_status(status) [](#method-i-signal_status) -Evaluates the given block using the given `status`. - -## suspend_input_method(input_method) [](#method-i-suspend_input_method) -Evaluates the given block using the given `input_method` as the Context#io. - -Used by the irb commands `source` and `irb_load`, see IRB@IRB+Sessions for -more information. - -## suspend_name(pathnil, namenil) [](#method-i-suspend_name) -Evaluates the given block using the given `path` as the Context#irb_path and -`name` as the Context#irb_name. - -Used by the irb command `source`, see IRB@IRB+Sessions for more information. - -## suspend_workspace(workspace) [](#method-i-suspend_workspace) -Evaluates the given block using the given `workspace` as the -Context#workspace. - -Used by the irb command `irb_load`, see IRB@IRB+Sessions for more information. - diff --git a/example/ruby/IRB/IrbAlreadyDead.md b/example/ruby/IRB/IrbAlreadyDead.md deleted file mode 100644 index 253c5d2..0000000 --- a/example/ruby/IRB/IrbAlreadyDead.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::IrbAlreadyDead -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [IrbAlreadyDead] a new instance of IrbAlreadyDead - diff --git a/example/ruby/IRB/IrbLoader.md b/example/ruby/IRB/IrbLoader.md deleted file mode 100644 index 3bc1a1e..0000000 --- a/example/ruby/IRB/IrbLoader.md +++ /dev/null @@ -1,31 +0,0 @@ -# Module: IRB::IrbLoader - - -Provides a few commands for loading files within an irb session. - -See ExtendCommandBundle for more information. - - - -#Instance Methods -## irb_load(fn, privnil) [](#method-i-irb_load) -Loads the given file similarly to Kernel#load - -**@raise** [LoadError] - -## load_file(path, privnil) [](#method-i-load_file) -Loads the given file in the current session's context and evaluates it. - -See Irb#suspend_input_method for more information. - -## old() [](#method-i-old) -:nodoc: - -## search_file_from_ruby_path(fn) [](#method-i-search_file_from_ruby_path) -:nodoc: - -## source_file(path) [](#method-i-source_file) -Loads a given file in the current session and displays the source lines - -See Irb#suspend_input_method for more information. - diff --git a/example/ruby/IRB/IrbSwitchedToCurrentThread.md b/example/ruby/IRB/IrbSwitchedToCurrentThread.md deleted file mode 100644 index 1e16969..0000000 --- a/example/ruby/IRB/IrbSwitchedToCurrentThread.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::IrbSwitchedToCurrentThread -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [IrbSwitchedToCurrentThread] a new instance of IrbSwitchedToCurrentThread - diff --git a/example/ruby/IRB/JobManager.md b/example/ruby/IRB/JobManager.md deleted file mode 100644 index 2d5f06a..0000000 --- a/example/ruby/IRB/JobManager.md +++ /dev/null @@ -1,77 +0,0 @@ -# Class: IRB::JobManager -**Inherits:** Object - - -:nodoc: - - -# Attributes -## current_job[RW] [](#attribute-i-current_job) -The active irb session - - -#Instance Methods -## delete(key) [](#method-i-delete) -Deletes the job at the given `key`. - -## initialize() [](#method-i-initialize) -Creates a new JobManager object - -**@return** [JobManager] a new instance of JobManager - -## insert(irb) [](#method-i-insert) -Add the given `irb` session to the jobs Array. - -## inspect() [](#method-i-inspect) -Outputs a list of jobs, see the irb command `irb_jobs`, or `jobs`. - -## irb(key) [](#method-i-irb) -Returns the irb session for the given `key` object, see #search for more -information. - -## kill(*keys) [](#method-i-kill) -Terminates the irb sessions specified by the given `keys`. - -Raises an IrbAlreadyDead exception if one of the given `keys` is already -terminated. - -See Thread#exit for more information. - -## main_irb() [](#method-i-main_irb) -Returns the top level irb session. - -## main_thread() [](#method-i-main_thread) -Returns the top level thread. - -## n_jobs() [](#method-i-n_jobs) -The total number of irb sessions, used to set `irb_name` of the current -Context. - -## search(key) [](#method-i-search) -Returns the associated job for the given `key`. - -If given an Integer, it will return the `key` index for the jobs Array. - -When an instance of Irb is given, it will return the irb session associated -with `key`. - -If given an instance of Thread, it will return the associated thread `key` -using Object#=== on the jobs Array. - -Otherwise returns the irb session with the same top-level binding as the given -`key`. - -Raises a NoSuchJob exception if no job can be found with the given `key`. - -## switch(key) [](#method-i-switch) -Changes the current active irb session to the given `key` in the jobs Array. - -Raises an IrbAlreadyDead exception if the given `key` is no longer alive. - -If the given irb session is already active, an IrbSwitchedToCurrentThread -exception is raised. - -## thread(key) [](#method-i-thread) -Returns the thread for the given `key` object, see #search for more -information. - diff --git a/example/ruby/IRB/LoadAbort.md b/example/ruby/IRB/LoadAbort.md deleted file mode 100644 index 8481076..0000000 --- a/example/ruby/IRB/LoadAbort.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: IRB::LoadAbort -**Inherits:** Exception - - -Raised in the event of an exception in a file loaded from an Irb session - - - diff --git a/example/ruby/IRB/Locale.md b/example/ruby/IRB/Locale.md deleted file mode 100644 index cfa7cb3..0000000 --- a/example/ruby/IRB/Locale.md +++ /dev/null @@ -1,59 +0,0 @@ -# Class: IRB::Locale -**Inherits:** Object - - -:nodoc: - - -# Attributes -## lang[RW] [](#attribute-i-lang) -Returns the value of attribute lang. - -## modifier[RW] [](#attribute-i-modifier) -Returns the value of attribute modifier. - -## territory[RW] [](#attribute-i-territory) -Returns the value of attribute territory. - - -#Instance Methods -## String(mes) [](#method-i-String) - -## each_localized_path(dir, file) [](#method-i-each_localized_path) - -## each_sublocale() [](#method-i-each_sublocale) - -**@yield** [nil] - -## encoding() [](#method-i-encoding) - -## find(file, paths$:) [](#method-i-find) - -## format(*opts) [](#method-i-format) - -## gets(*rs) [](#method-i-gets) - -## initialize(localenil) [](#method-i-initialize) - -**@return** [Locale] a new instance of Locale - -## load(file) [](#method-i-load) - -## print(*opts) [](#method-i-print) - -## printf(*opts) [](#method-i-printf) - -## puts(*opts) [](#method-i-puts) - -## readline(*rs) [](#method-i-readline) - -## search_file(lib_paths, dir, file) [](#method-i-search_file) -typically, for the parameters and a in paths, it searches - /// - -**@param** [] load paths in which IRB find a localized file. - -**@param** [] directory - -**@param** [] basename to be localized - diff --git a/example/ruby/IRB/NestingParser.md b/example/ruby/IRB/NestingParser.md deleted file mode 100644 index 951f770..0000000 --- a/example/ruby/IRB/NestingParser.md +++ /dev/null @@ -1,28 +0,0 @@ -# Module: IRB::NestingParser - - - - -# Class Methods -## open_tokens(tokens ) [](#method-c-open_tokens) -## parse_by_line(tokens ) [](#method-c-parse_by_line) -Calculates token information [line_tokens, prev_opens, next_opens, min_depth] -for each line. Example code - ["hello - world"+( - -First line - line_tokens: [[lbracket, '['], [tstring_beg, '"'], [tstring_content("hello\nworld"), "hello\n"]] - prev_opens: [] - next_tokens: [lbracket, tstring_beg] - min_depth: 0 (minimum at beginning of line) - -Second line - line_tokens: [[tstring_content("hello\nworld"), "world"], [tstring_end, '"'], [op, '+'], [lparen, '(']] - prev_opens: [lbracket, tstring_beg] - next_tokens: [lbracket, lparen] - min_depth: 1 (minimum just after tstring_end) -## scan_opens(tokens ) [](#method-c-scan_opens) -Scan each token and call the given block with array of token and other -information for parsing - diff --git a/example/ruby/IRB/NoSuchJob.md b/example/ruby/IRB/NoSuchJob.md deleted file mode 100644 index b640988..0000000 --- a/example/ruby/IRB/NoSuchJob.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::NoSuchJob -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -**@return** [NoSuchJob] a new instance of NoSuchJob - diff --git a/example/ruby/IRB/Notifier.md b/example/ruby/IRB/Notifier.md deleted file mode 100644 index 02a0c38..0000000 --- a/example/ruby/IRB/Notifier.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: IRB::Notifier - - -An output formatter used internally by the lexer. - - -# Class Methods -## def_notifier(prefix "", output_method StdioOutputMethod.new) [](#method-c-def_notifier) -Define a new Notifier output source, returning a new CompositeNotifier with -the given `prefix` and `output_method`. - -The optional `prefix` will be appended to all objects being inspected during -output, using the given `output_method` as the output source. If no -`output_method` is given, StdioOutputMethod will be used, and all expressions -will be sent directly to STDOUT without any additional formatting. - diff --git a/example/ruby/IRB/Notifier/AbstractNotifier.md b/example/ruby/IRB/Notifier/AbstractNotifier.md deleted file mode 100644 index 06beecb..0000000 --- a/example/ruby/IRB/Notifier/AbstractNotifier.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: IRB::Notifier::AbstractNotifier -**Inherits:** Object - - -An abstract class, or superclass, for CompositeNotifier and LeveledNotifier to -inherit. It provides several wrapper methods for the OutputMethod object used -by the Notifier. - - -# Attributes -## prefix[RW] [](#attribute-i-prefix) -The `prefix` for this Notifier, which is appended to all objects being -inspected during output. - - -#Instance Methods -## exec_if() [](#method-i-exec_if) -Execute the given block if notifications are enabled. - -**@yield** [@base_notifier] - -## initialize(prefix, base_notifier) [](#method-i-initialize) -Creates a new Notifier object - -**@return** [AbstractNotifier] a new instance of AbstractNotifier - -## notify?() [](#method-i-notify?) -A wrapper method used to determine whether notifications are enabled. - -Defaults to `true`. - -**@return** [Boolean] - -## pp(*objs) [](#method-i-pp) -Same as #ppx, except it uses the #prefix given during object initialization. -See OutputMethod#ppx for more detail. - -## ppx(prefix, *objs) [](#method-i-ppx) -Same as #pp, except it concatenates the given `prefix` with the #prefix given -during object initialization. - -See OutputMethod#ppx for more detail. - -## print(*opts) [](#method-i-print) -See OutputMethod#print for more detail. - -## printf(format, *opts) [](#method-i-printf) -See OutputMethod#printf for more detail. - -## printn(*opts) [](#method-i-printn) -See OutputMethod#printn for more detail. - -## puts(*objs) [](#method-i-puts) -See OutputMethod#puts for more detail. - diff --git a/example/ruby/IRB/Notifier/CompositeNotifier.md b/example/ruby/IRB/Notifier/CompositeNotifier.md deleted file mode 100644 index 86fbfd8..0000000 --- a/example/ruby/IRB/Notifier/CompositeNotifier.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: IRB::Notifier::CompositeNotifier -**Inherits:** IRB::Notifier::AbstractNotifier - - -A class that can be used to create a group of notifier objects with the intent -of representing a leveled notification system for irb. - -This class will allow you to generate other notifiers, and assign them the -appropriate level for output. - -The Notifier class provides a class-method Notifier.def_notifier to create a -new composite notifier. Using the first composite notifier object you create, -sibling notifiers can be initialized with #def_notifier. - - -# Attributes -## level_notifier[RW] [](#attribute-i-level_notifier) -Returns the leveled notifier for this object - -## notifiers[RW] [](#attribute-i-notifiers) -List of notifiers in the group - - -#Instance Methods -## def_notifier(level, prefix"") [](#method-i-def_notifier) -Creates a new LeveledNotifier in the composite #notifiers group. - -The given `prefix` will be assigned to the notifier, and `level` will be used -as the index of the #notifiers Array. - -This method returns the newly created instance. - -## initialize(prefix, base_notifier) [](#method-i-initialize) -Create a new composite notifier object with the given `prefix`, and -`base_notifier` to use for output. - -**@return** [CompositeNotifier] a new instance of CompositeNotifier - diff --git a/example/ruby/IRB/Notifier/ErrUndefinedNotifier.md b/example/ruby/IRB/Notifier/ErrUndefinedNotifier.md deleted file mode 100644 index b9c5cef..0000000 --- a/example/ruby/IRB/Notifier/ErrUndefinedNotifier.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::Notifier::ErrUndefinedNotifier -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -**@return** [ErrUndefinedNotifier] a new instance of ErrUndefinedNotifier - diff --git a/example/ruby/IRB/Notifier/ErrUnrecognizedLevel.md b/example/ruby/IRB/Notifier/ErrUnrecognizedLevel.md deleted file mode 100644 index 8a57513..0000000 --- a/example/ruby/IRB/Notifier/ErrUnrecognizedLevel.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::Notifier::ErrUnrecognizedLevel -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -**@return** [ErrUnrecognizedLevel] a new instance of ErrUnrecognizedLevel - diff --git a/example/ruby/IRB/Notifier/LeveledNotifier.md b/example/ruby/IRB/Notifier/LeveledNotifier.md deleted file mode 100644 index fb0d6d2..0000000 --- a/example/ruby/IRB/Notifier/LeveledNotifier.md +++ /dev/null @@ -1,119 +0,0 @@ -# Class: IRB::Notifier::LeveledNotifier -**Inherits:** IRB::Notifier::AbstractNotifier - -**Includes:** Comparable - - -A leveled notifier is comparable to the composite group from -CompositeNotifier#notifiers. - - -# Attributes -## level[RW] [](#attribute-i-level) -The current level of this notifier object - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Compares the level of this notifier object with the given `other` notifier. - -See the Comparable module for more information. - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## initialize(base, level, prefix) [](#method-i-initialize) -Create a new leveled notifier with the given `base`, and `prefix` to send to -AbstractNotifier.new - -The given `level` is used to compare other leveled notifiers in the -CompositeNotifier group to determine whether or not to output notifications. - -**@return** [LeveledNotifier] a new instance of LeveledNotifier - -## notify?() [](#method-i-notify?) -Whether to output messages to the output method, depending on the level of -this notifier object. - -**@return** [Boolean] - diff --git a/example/ruby/IRB/Notifier/NoMsgNotifier.md b/example/ruby/IRB/Notifier/NoMsgNotifier.md deleted file mode 100644 index c3b5295..0000000 --- a/example/ruby/IRB/Notifier/NoMsgNotifier.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: IRB::Notifier::NoMsgNotifier -**Inherits:** IRB::Notifier::LeveledNotifier - - -NoMsgNotifier is a LeveledNotifier that's used as the default notifier when -creating a new CompositeNotifier. - -This notifier is used as the `zero` index, or level `0`, for -CompositeNotifier#notifiers, and will not output messages of any sort. - - - -#Instance Methods -## initialize() [](#method-i-initialize) -Creates a new notifier that should not be used to output messages. - -**@return** [NoMsgNotifier] a new instance of NoMsgNotifier - -## notify?() [](#method-i-notify?) -Ensures notifications are ignored, see AbstractNotifier#notify? for more -information. - -**@return** [Boolean] - diff --git a/example/ruby/IRB/OutputMethod.md b/example/ruby/IRB/OutputMethod.md deleted file mode 100644 index e2fed80..0000000 --- a/example/ruby/IRB/OutputMethod.md +++ /dev/null @@ -1,51 +0,0 @@ -# Class: IRB::OutputMethod -**Inherits:** Object - - -An abstract output class for IO in irb. This is mainly used internally by -IRB::Notifier. You can define your own output method to use with Irb.new, or -Context.new - - - -#Instance Methods -## parse_printf_format(format, opts) [](#method-i-parse_printf_format) -Returns an array of the given `format` and `opts` to be used by -Kernel#sprintf, if there was a successful Regexp match in the given `format` -from #printf - - % - [#0- +] - (\*|\*[1-9][0-9]*\$|[1-9][0-9]*) - .(\*|\*[1-9][0-9]*\$|[1-9][0-9]*|)? - #(hh|h|l|ll|L|q|j|z|t) - [diouxXeEfgGcsb%] - -## pp(*objs) [](#method-i-pp) -Prints the given `objs` calling Object#inspect on each. - -See #puts for more detail. - -## ppx(prefix, *objs) [](#method-i-ppx) -Prints the given `objs` calling Object#inspect on each and appending the given -`prefix`. - -See #puts for more detail. - -## print(*opts) [](#method-i-print) -Open this method to implement your own output method, raises a -NotImplementedError if you don't define #print in your own class. - -**@raise** [NotImplementedError] - -## printf(format, *opts) [](#method-i-printf) -Extends IO#printf to format the given `opts` for Kernel#sprintf using -#parse_printf_format - -## printn(*opts) [](#method-i-printn) -Prints the given `opts`, with a newline delimiter. - -## puts(*objs) [](#method-i-puts) -Calls #print on each element in the given `objs`, followed by a newline -character. - diff --git a/example/ruby/IRB/Pager.md b/example/ruby/IRB/Pager.md deleted file mode 100644 index c35c44b..0000000 --- a/example/ruby/IRB/Pager.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::Pager -**Inherits:** Object - - -The implementation of this class is borrowed from RDoc's -lib/rdoc/ri/driver.rb. Please do NOT use this class directly outside of IRB. - - -# Class Methods -## page(retain_content: false) [](#method-c-page) -## page_content(content , **options ) [](#method-c-page_content) - diff --git a/example/ruby/IRB/ReadlineInputMethod.md b/example/ruby/IRB/ReadlineInputMethod.md deleted file mode 100644 index e78f404..0000000 --- a/example/ruby/IRB/ReadlineInputMethod.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: IRB::ReadlineInputMethod -**Inherits:** IRB::StdioInputMethod - -**Includes:** IRB::HistorySavingAbility - - - - -# Class Methods -## initialize_readline() [](#method-c-initialize_readline) - -#Instance Methods -## completion_info() [](#method-i-completion_info) - -## eof?() [](#method-i-eof?) -Whether the end of this input method has been reached, returns `true` if there -is no more data to read. - -See IO#eof? for more information. - -**@return** [Boolean] - -## gets() [](#method-i-gets) -Reads the next line from this input method. - -See IO#gets for more information. - -## initialize() [](#method-i-initialize) -Creates a new input method object using Readline - -**@return** [ReadlineInputMethod] a new instance of ReadlineInputMethod - -## inspect() [](#method-i-inspect) -For debug message - -## load_history() [](#method-i-load_history) - -## prompting?() [](#method-i-prompting?) - -**@return** [Boolean] - -## reset_history_counter() [](#method-i-reset_history_counter) - -## save_history() [](#method-i-save_history) - -## support_history_saving?() [](#method-i-support_history_saving?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/RegexpCompletor.md b/example/ruby/IRB/RegexpCompletor.md deleted file mode 100644 index 551ebd8..0000000 --- a/example/ruby/IRB/RegexpCompletor.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: IRB::RegexpCompletor -**Inherits:** IRB::BaseCompletor - - -:nodoc: - - - -#Instance Methods -## complete_require_path(target, preposing, postposing) [](#method-i-complete_require_path) - -## completion_candidates(preposing, target, postposing, bind:) [](#method-i-completion_candidates) - -## doc_namespace(_preposing, matched, _postposing, bind:) [](#method-i-doc_namespace) - -## inspect() [](#method-i-inspect) - -## retrieve_completion_data(input, bind:, doc_namespace:) [](#method-i-retrieve_completion_data) - -## select_message(receiver, message, candidates, sep".") [](#method-i-select_message) - diff --git a/example/ruby/IRB/ReidlineInputMethod.md b/example/ruby/IRB/ReidlineInputMethod.md deleted file mode 100644 index 24cc20a..0000000 --- a/example/ruby/IRB/ReidlineInputMethod.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::ReidlineInputMethod -**Inherits:** IRB::RelineInputMethod - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ReidlineInputMethod] a new instance of ReidlineInputMethod - diff --git a/example/ruby/IRB/RelineInputMethod.md b/example/ruby/IRB/RelineInputMethod.md deleted file mode 100644 index 5327b07..0000000 --- a/example/ruby/IRB/RelineInputMethod.md +++ /dev/null @@ -1,61 +0,0 @@ -# Class: IRB::RelineInputMethod -**Inherits:** IRB::StdioInputMethod - -**Includes:** IRB::HistorySavingAbility - - - - - -#Instance Methods -## auto_indent(&block) [](#method-i-auto_indent) - -## check_termination(&block) [](#method-i-check_termination) - -## completion_info() [](#method-i-completion_info) - -## display_document(matched) [](#method-i-display_document) - -## dynamic_prompt(&block) [](#method-i-dynamic_prompt) - -## eof?() [](#method-i-eof?) -Whether the end of this input method has been reached, returns `true` if there -is no more data to read. - -See IO#eof? for more information. - -**@return** [Boolean] - -## gets() [](#method-i-gets) -Reads the next line from this input method. - -See IO#gets for more information. - -## initialize(completor) [](#method-i-initialize) -Creates a new input method object using Reline - -**@return** [RelineInputMethod] a new instance of RelineInputMethod - -## inspect() [](#method-i-inspect) -For debug message - -## load_history() [](#method-i-load_history) - -## prompting?() [](#method-i-prompting?) - -**@return** [Boolean] - -## rdoc_ri_driver() [](#method-i-rdoc_ri_driver) - -## reset_history_counter() [](#method-i-reset_history_counter) - -## retrieve_doc_namespace(matched) [](#method-i-retrieve_doc_namespace) - -## save_history() [](#method-i-save_history) - -## show_doc_dialog_proc() [](#method-i-show_doc_dialog_proc) - -## support_history_saving?() [](#method-i-support_history_saving?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/RenderingTest.md b/example/ruby/IRB/RenderingTest.md deleted file mode 100644 index 298b316..0000000 --- a/example/ruby/IRB/RenderingTest.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: IRB::RenderingTest -**Inherits:** Yamatanooroti::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_assignment_expression_truncate() [](#method-i-test_assignment_expression_truncate) - -## test_autocomplete_with_multiple_doc_namespaces() [](#method-i-test_autocomplete_with_multiple_doc_namespaces) - -## test_autocomplete_with_showdoc_in_gaps_on_narrow_screen_left() [](#method-i-test_autocomplete_with_showdoc_in_gaps_on_narrow_screen_left) - -## test_autocomplete_with_showdoc_in_gaps_on_narrow_screen_right() [](#method-i-test_autocomplete_with_showdoc_in_gaps_on_narrow_screen_right) - -## test_configuration_file_is_skipped_with_dash_f() [](#method-i-test_configuration_file_is_skipped_with_dash_f) - -## test_configuration_file_is_skipped_with_dash_f_for_nested_sessions() [](#method-i-test_configuration_file_is_skipped_with_dash_f_for_nested_sessions) - -## test_ctrl_c_is_handled() [](#method-i-test_ctrl_c_is_handled) - -## test_debug_integration_doesnt_hint_debugger_commands_in_nomultiline_mode() [](#method-i-test_debug_integration_doesnt_hint_debugger_commands_in_nomultiline_mode) - -## test_debug_integration_doesnt_hint_non_debugger_commands() [](#method-i-test_debug_integration_doesnt_hint_non_debugger_commands) - -## test_debug_integration_hints_debugger_commands() [](#method-i-test_debug_integration_hints_debugger_commands) - -## test_evaluate_each_toplevel_statement_by_multiline_paste() [](#method-i-test_evaluate_each_toplevel_statement_by_multiline_paste) - -## test_launch() [](#method-i-test_launch) - -## test_long_evaluation_output_is_paged() [](#method-i-test_long_evaluation_output_is_paged) - -## test_long_evaluation_output_is_preserved_after_paging() [](#method-i-test_long_evaluation_output_is_preserved_after_paging) - -## test_multiline_paste() [](#method-i-test_multiline_paste) - -## test_nomultiline() [](#method-i-test_nomultiline) - -## test_pager_page_content_doesnt_page_output_when_it_fits_in_the_screen() [](#method-i-test_pager_page_content_doesnt_page_output_when_it_fits_in_the_screen) - -## test_pager_page_content_pages_output_when_it_does_not_fit_in_the_screen_because_of_screen_height() [](#method-i-test_pager_page_content_pages_output_when_it_does_not_fit_in_the_screen_because_of_screen_height) - -## test_pager_page_content_pages_output_when_it_does_not_fit_in_the_screen_because_of_total_length() [](#method-i-test_pager_page_content_pages_output_when_it_does_not_fit_in_the_screen_because_of_total_length) - -## test_show_cmds_with_pager_can_quit_with_ctrl_c() [](#method-i-test_show_cmds_with_pager_can_quit_with_ctrl_c) - -## test_symbol_with_backtick() [](#method-i-test_symbol_with_backtick) - diff --git a/example/ruby/IRB/RubyLex.md b/example/ruby/IRB/RubyLex.md deleted file mode 100644 index 3b25d72..0000000 --- a/example/ruby/IRB/RubyLex.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: IRB::RubyLex -**Inherits:** Object - - -:stopdoc: - - -# Class Methods -## compile_with_errors_suppressed(code , line_no: 1) [](#method-c-compile_with_errors_suppressed) -## generate_local_variables_assign_code(local_variables ) [](#method-c-generate_local_variables_assign_code) -## interpolate_ripper_ignored_tokens(code , tokens ) [](#method-c-interpolate_ripper_ignored_tokens) -Some part of the code is not included in Ripper's token. Example: DATA part, -token after heredoc_beg when heredoc has unclosed embexpr. With interpolated -tokens, tokens.map(&:tok).join will be equal to code. -## ripper_lex_without_warning(code , local_variables: []) [](#method-c-ripper_lex_without_warning) - -#Instance Methods -## assignment_expression?(code, local_variables:) [](#method-i-assignment_expression?) - -**@return** [Boolean] - -## calc_indent_level(opens) [](#method-i-calc_indent_level) - -## check_code_state(code, local_variables:) [](#method-i-check_code_state) - -## check_code_syntax(code, local_variables:) [](#method-i-check_code_syntax) - -## check_termination_in_prev_line(code, local_variables:) [](#method-i-check_termination_in_prev_line) - -## code_terminated?(code, tokens, opens, local_variables:) [](#method-i-code_terminated?) - -**@return** [Boolean] - -## free_indent_token?(token) [](#method-i-free_indent_token?) - -**@return** [Boolean] - -## indent_difference(lines, line_results, line_index) [](#method-i-indent_difference) -Calculates the difference of pasted code's indent and indent calculated from -tokens - -## ltype_from_open_tokens(opens) [](#method-i-ltype_from_open_tokens) - -## process_indent_level(tokens, lines, line_index, is_newline) [](#method-i-process_indent_level) - -## should_continue?(tokens) [](#method-i-should_continue?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/RubyLex/TerminateLineInput.md b/example/ruby/IRB/RubyLex/TerminateLineInput.md deleted file mode 100644 index d4b49a4..0000000 --- a/example/ruby/IRB/RubyLex/TerminateLineInput.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::RubyLex::TerminateLineInput -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [TerminateLineInput] a new instance of TerminateLineInput - diff --git a/example/ruby/IRB/RubyModel.md b/example/ruby/IRB/RubyModel.md deleted file mode 100644 index bd5acf7..0000000 --- a/example/ruby/IRB/RubyModel.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: IRB::RubyModel -**Inherits:** Object - - - - - -#Instance Methods -## init_ruby_model() [](#method-i-init_ruby_model) - -## initialize() [](#method-i-initialize) - -**@return** [RubyModel] a new instance of RubyModel - -## render_frame(i) [](#method-i-render_frame) - diff --git a/example/ruby/IRB/SourceFinder.md b/example/ruby/IRB/SourceFinder.md deleted file mode 100644 index 9263942..0000000 --- a/example/ruby/IRB/SourceFinder.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: IRB::SourceFinder -**Inherits:** Object - - - - - -#Instance Methods -## find_source(signature, super_level0) [](#method-i-find_source) - -## initialize(irb_context) [](#method-i-initialize) - -**@return** [SourceFinder] a new instance of SourceFinder - diff --git a/example/ruby/IRB/SourceFinder/EvaluationError.md b/example/ruby/IRB/SourceFinder/EvaluationError.md deleted file mode 100644 index a7090c8..0000000 --- a/example/ruby/IRB/SourceFinder/EvaluationError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IRB::SourceFinder::EvaluationError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/IRB/Statement.md b/example/ruby/IRB/Statement.md deleted file mode 100644 index a15ba40..0000000 --- a/example/ruby/IRB/Statement.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: IRB::Statement -**Inherits:** Object - - - - -# Attributes -## code[RW] [](#attribute-i-code) -Returns the value of attribute code. - - -#Instance Methods -## is_assignment?() [](#method-i-is_assignment?) - -**@raise** [NotImplementedError] - -**@return** [Boolean] - -## should_be_handled_by_debugger?() [](#method-i-should_be_handled_by_debugger?) - -**@raise** [NotImplementedError] - -**@return** [Boolean] - -## suppresses_echo?() [](#method-i-suppresses_echo?) - -**@raise** [NotImplementedError] - -**@return** [Boolean] - diff --git a/example/ruby/IRB/Statement/Command.md b/example/ruby/IRB/Statement/Command.md deleted file mode 100644 index 0b02228..0000000 --- a/example/ruby/IRB/Statement/Command.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: IRB::Statement::Command -**Inherits:** IRB::Statement - - - - -# Attributes -## arg[RW] [](#attribute-i-arg) -Returns the value of attribute arg. - -## command_class[RW] [](#attribute-i-command_class) -Returns the value of attribute command_class. - - -#Instance Methods -## initialize(original_code, command_class, arg) [](#method-i-initialize) - -**@return** [Command] a new instance of Command - -## is_assignment?() [](#method-i-is_assignment?) - -**@return** [Boolean] - -## should_be_handled_by_debugger?() [](#method-i-should_be_handled_by_debugger?) - -**@return** [Boolean] - -## suppresses_echo?() [](#method-i-suppresses_echo?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/Statement/EmptyInput.md b/example/ruby/IRB/Statement/EmptyInput.md deleted file mode 100644 index bb809e9..0000000 --- a/example/ruby/IRB/Statement/EmptyInput.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: IRB::Statement::EmptyInput -**Inherits:** IRB::Statement - - - - - -#Instance Methods -## code() [](#method-i-code) - -## is_assignment?() [](#method-i-is_assignment?) - -**@return** [Boolean] - -## should_be_handled_by_debugger?() [](#method-i-should_be_handled_by_debugger?) -Debugger takes empty input to repeat the last command - -**@return** [Boolean] - -## suppresses_echo?() [](#method-i-suppresses_echo?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/Statement/Expression.md b/example/ruby/IRB/Statement/Expression.md deleted file mode 100644 index 38a7619..0000000 --- a/example/ruby/IRB/Statement/Expression.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: IRB::Statement::Expression -**Inherits:** IRB::Statement - - - - - -#Instance Methods -## initialize(code, is_assignment) [](#method-i-initialize) - -**@return** [Expression] a new instance of Expression - -## is_assignment?() [](#method-i-is_assignment?) - -**@return** [Boolean] - -## should_be_handled_by_debugger?() [](#method-i-should_be_handled_by_debugger?) - -**@return** [Boolean] - -## suppresses_echo?() [](#method-i-suppresses_echo?) - -**@return** [Boolean] - diff --git a/example/ruby/IRB/StdioInputMethod.md b/example/ruby/IRB/StdioInputMethod.md deleted file mode 100644 index a59d6ef..0000000 --- a/example/ruby/IRB/StdioInputMethod.md +++ /dev/null @@ -1,51 +0,0 @@ -# Class: IRB::StdioInputMethod -**Inherits:** IRB::InputMethod - - - - - -#Instance Methods -## encoding() [](#method-i-encoding) -The external encoding for standard input. - -## eof?() [](#method-i-eof?) -Whether the end of this input method has been reached, returns `true` if there -is no more data to read. - -See IO#eof? for more information. - -**@return** [Boolean] - -## gets() [](#method-i-gets) -Reads the next line from this input method. - -See IO#gets for more information. - -## initialize() [](#method-i-initialize) -Creates a new input method object - -**@return** [StdioInputMethod] a new instance of StdioInputMethod - -## inspect() [](#method-i-inspect) -For debug message - -## line(line_no) [](#method-i-line) -Returns the current line number for #io. - -#line counts the number of times #gets is called. - -See IO#lineno for more information. - -## prompting?() [](#method-i-prompting?) - -**@return** [Boolean] - -## readable_after_eof?() [](#method-i-readable_after_eof?) -Whether this input method is still readable when there is no more data to -read. - -See IO#eof for more information. - -**@return** [Boolean] - diff --git a/example/ruby/IRB/StdioOutputMethod.md b/example/ruby/IRB/StdioOutputMethod.md deleted file mode 100644 index 8e02941..0000000 --- a/example/ruby/IRB/StdioOutputMethod.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: IRB::StdioOutputMethod -**Inherits:** IRB::OutputMethod - - -A standard output printer - - - -#Instance Methods -## print(*opts) [](#method-i-print) -Prints the given `opts` to standard output, see IO#print for more information. - diff --git a/example/ruby/IRB/TypeCompletor.md b/example/ruby/IRB/TypeCompletor.md deleted file mode 100644 index 2922972..0000000 --- a/example/ruby/IRB/TypeCompletor.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: IRB::TypeCompletor -**Inherits:** IRB::BaseCompletor - - -:nodoc: - - - -#Instance Methods -## completion_candidates(preposing, target, _postposing, bind:) [](#method-i-completion_candidates) - -## doc_namespace(preposing, matched, _postposing, bind:) [](#method-i-doc_namespace) - -## initialize(context) [](#method-i-initialize) - -**@return** [TypeCompletor] a new instance of TypeCompletor - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/IRB/UndefinedPromptMode.md b/example/ruby/IRB/UndefinedPromptMode.md deleted file mode 100644 index 6d4cd85..0000000 --- a/example/ruby/IRB/UndefinedPromptMode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: IRB::UndefinedPromptMode -**Inherits:** StandardError - - - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -**@return** [UndefinedPromptMode] a new instance of UndefinedPromptMode - diff --git a/example/ruby/IRB/UnrecognizedSwitch.md b/example/ruby/IRB/UnrecognizedSwitch.md deleted file mode 100644 index ba27fca..0000000 --- a/example/ruby/IRB/UnrecognizedSwitch.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: IRB::UnrecognizedSwitch -**Inherits:** StandardError - - -:stopdoc: - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -**@return** [UnrecognizedSwitch] a new instance of UnrecognizedSwitch - diff --git a/example/ruby/IRB/Vec.md b/example/ruby/IRB/Vec.md deleted file mode 100644 index 64e7578..0000000 --- a/example/ruby/IRB/Vec.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: IRB::Vec -**Inherits:** Object - - - - -# Attributes -## x[RW] [](#attribute-i-x) -Returns the value of attribute x. - -## y[RW] [](#attribute-i-y) -Returns the value of attribute y. - -## z[RW] [](#attribute-i-z) -Returns the value of attribute z. - - -#Instance Methods -## cross(other) [](#method-i-cross) - -## dot(other) [](#method-i-dot) - -## initialize(x, y, z) [](#method-i-initialize) - -**@return** [Vec] a new instance of Vec - -## normalize() [](#method-i-normalize) - -## sub(other) [](#method-i-sub) - diff --git a/example/ruby/IRB/WorkSpace.md b/example/ruby/IRB/WorkSpace.md deleted file mode 100644 index faff058..0000000 --- a/example/ruby/IRB/WorkSpace.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: IRB::WorkSpace -**Inherits:** Object - - - - -# Attributes -## binding[RW] [](#attribute-i-binding) -The Binding of this workspace - -## main[RW] [](#attribute-i-main) -The top-level workspace of this context, also available as -`IRB.conf[:__MAIN__]` - - -#Instance Methods -## __evaluate__() [](#method-i-__evaluate__) -Evaluate the given `statements` within the context of this workspace. - -## code_around_binding() [](#method-i-code_around_binding) - -## evaluate(statements, file__FILE__, line__LINE__) [](#method-i-evaluate) -Evaluate the context of this workspace and use the Tracer library to output -the exact lines of code are being executed in chronological order. - -See https://github.com/ruby/tracer for more information. - -## filter_backtrace(bt) [](#method-i-filter_backtrace) -error message manipulator WARN: Rails patches this method to filter its own -backtrace. Be cautious when changing it. See: -https://github.com/rails/rails/blob/main/railties/lib/rails/commands/console/c -onsole_command.rb#L8:~:text=def,filter_backtrace - -## initialize(*main) [](#method-i-initialize) -Creates a new workspace. - -set self to main if specified, otherwise inherit main from TOPLEVEL_BINDING. - -**@return** [WorkSpace] a new instance of WorkSpace - -## load_helper_methods_to_main() [](#method-i-load_helper_methods_to_main) - -## local_variable_get(name) [](#method-i-local_variable_get) - -## local_variable_set(name, value) [](#method-i-local_variable_set) - diff --git a/example/ruby/ITER_TEST1.md b/example/ruby/ITER_TEST1.md deleted file mode 100644 index 67025f3..0000000 --- a/example/ruby/ITER_TEST1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ITER_TEST1 -**Inherits:** Object - - - - - -#Instance Methods -## a() [](#method-i-a) - diff --git a/example/ruby/ITER_TEST2.md b/example/ruby/ITER_TEST2.md deleted file mode 100644 index 63685ea..0000000 --- a/example/ruby/ITER_TEST2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ITER_TEST2 -**Inherits:** ITER_TEST1 - - - - - -#Instance Methods -## a() [](#method-i-a) - diff --git a/example/ruby/ITER_TEST3.md b/example/ruby/ITER_TEST3.md deleted file mode 100644 index a6e2b10..0000000 --- a/example/ruby/ITER_TEST3.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ITER_TEST3 -**Inherits:** Object - - - - - -#Instance Methods -## foo(x) [](#method-i-foo) - diff --git a/example/ruby/ITER_TEST4.md b/example/ruby/ITER_TEST4.md deleted file mode 100644 index d6caf7a..0000000 --- a/example/ruby/ITER_TEST4.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ITER_TEST4 -**Inherits:** ITER_TEST3 - - - - - -#Instance Methods -## foo(x) [](#method-i-foo) - diff --git a/example/ruby/ITER_TEST5.md b/example/ruby/ITER_TEST5.md deleted file mode 100644 index 99ab760..0000000 --- a/example/ruby/ITER_TEST5.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ITER_TEST5 -**Inherits:** Object - - - - - -#Instance Methods -## tt(aa) [](#method-i-tt) - -## uu(a) [](#method-i-uu) - -## xx(*x) [](#method-i-xx) - diff --git a/example/ruby/ITER_TEST6.md b/example/ruby/ITER_TEST6.md deleted file mode 100644 index 00335b1..0000000 --- a/example/ruby/ITER_TEST6.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ITER_TEST6 -**Inherits:** ITER_TEST5 - - - - - -#Instance Methods -## xx(*a) [](#method-i-xx) - diff --git a/example/ruby/IVarModMock.md b/example/ruby/IVarModMock.md deleted file mode 100644 index 7fdebd9..0000000 --- a/example/ruby/IVarModMock.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: IVarModMock -**Inherits:** Object - - - - -# Class Methods -## class_variables() [](#method-c-class_variables) - diff --git a/example/ruby/IXMLDOMAttribute.md b/example/ruby/IXMLDOMAttribute.md deleted file mode 100644 index 02f3b1b..0000000 --- a/example/ruby/IXMLDOMAttribute.md +++ /dev/null @@ -1,145 +0,0 @@ -# Module: IXMLDOMAttribute - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## name() [](#method-i-name) -BSTR name get name of the attribute - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## value() [](#method-i-value) -VARIANT value string value of the attribute - -## value=(arg0) [](#method-i-value=) -VOID value string value of the attribute - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMCDATASection.md b/example/ruby/IXMLDOMCDATASection.md deleted file mode 100644 index 938a163..0000000 --- a/example/ruby/IXMLDOMCDATASection.md +++ /dev/null @@ -1,175 +0,0 @@ -# Module: IXMLDOMCDATASection - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## appendData(arg0) [](#method-i-appendData) -VOID appendData append string to value - BSTR arg0 --- data [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## data() [](#method-i-data) -BSTR data value of the node - -## data=(arg0) [](#method-i-data=) -VOID data value of the node - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## deleteData(arg0, arg1) [](#method-i-deleteData) -VOID deleteData delete string within the value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## insertData(arg0, arg1) [](#method-i-insertData) -VOID insertData insert string into value - I4 arg0 --- offset [IN] - BSTR arg1 --- data [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## length() [](#method-i-length) -I4 length number of characters in value - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## replaceData(arg0, arg1, arg2) [](#method-i-replaceData) -VOID replaceData replace string within the value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - BSTR arg2 --- data [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## splitText(arg0) [](#method-i-splitText) -IXMLDOMText splitText split the text node into two text nodes at the position -specified - I4 arg0 --- offset [IN] - -## substringData(arg0, arg1) [](#method-i-substringData) -BSTR substringData retrieve substring of value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMCharacterData.md b/example/ruby/IXMLDOMCharacterData.md deleted file mode 100644 index 3f5d971..0000000 --- a/example/ruby/IXMLDOMCharacterData.md +++ /dev/null @@ -1,170 +0,0 @@ -# Module: IXMLDOMCharacterData - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## appendData(arg0) [](#method-i-appendData) -VOID appendData append string to value - BSTR arg0 --- data [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## data() [](#method-i-data) -BSTR data value of the node - -## data=(arg0) [](#method-i-data=) -VOID data value of the node - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## deleteData(arg0, arg1) [](#method-i-deleteData) -VOID deleteData delete string within the value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## insertData(arg0, arg1) [](#method-i-insertData) -VOID insertData insert string into value - I4 arg0 --- offset [IN] - BSTR arg1 --- data [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## length() [](#method-i-length) -I4 length number of characters in value - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## replaceData(arg0, arg1, arg2) [](#method-i-replaceData) -VOID replaceData replace string within the value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - BSTR arg2 --- data [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## substringData(arg0, arg1) [](#method-i-substringData) -BSTR substringData retrieve substring of value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMComment.md b/example/ruby/IXMLDOMComment.md deleted file mode 100644 index 26f96ac..0000000 --- a/example/ruby/IXMLDOMComment.md +++ /dev/null @@ -1,170 +0,0 @@ -# Module: IXMLDOMComment - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## appendData(arg0) [](#method-i-appendData) -VOID appendData append string to value - BSTR arg0 --- data [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## data() [](#method-i-data) -BSTR data value of the node - -## data=(arg0) [](#method-i-data=) -VOID data value of the node - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## deleteData(arg0, arg1) [](#method-i-deleteData) -VOID deleteData delete string within the value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## insertData(arg0, arg1) [](#method-i-insertData) -VOID insertData insert string into value - I4 arg0 --- offset [IN] - BSTR arg1 --- data [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## length() [](#method-i-length) -I4 length number of characters in value - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## replaceData(arg0, arg1, arg2) [](#method-i-replaceData) -VOID replaceData replace string within the value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - BSTR arg2 --- data [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## substringData(arg0, arg1) [](#method-i-substringData) -BSTR substringData retrieve substring of value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMDocument.md b/example/ruby/IXMLDOMDocument.md deleted file mode 100644 index 446eb35..0000000 --- a/example/ruby/IXMLDOMDocument.md +++ /dev/null @@ -1,251 +0,0 @@ -# Module: IXMLDOMDocument - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## abort() [](#method-i-abort) -VOID abort abort an asynchronous download - -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## async() [](#method-i-async) -BOOL async flag for asynchronous download - -## async=(arg0) [](#method-i-async=) -VOID async flag for asynchronous download - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## createAttribute(arg0) [](#method-i-createAttribute) -IXMLDOMAttribute createAttribute create an attribute node - BSTR arg0 --- name [IN] - -## createCDATASection(arg0) [](#method-i-createCDATASection) -IXMLDOMCDATASection createCDATASection create a CDATA section node - BSTR arg0 --- data [IN] - -## createComment(arg0) [](#method-i-createComment) -IXMLDOMComment createComment create a comment node - BSTR arg0 --- data [IN] - -## createDocumentFragment() [](#method-i-createDocumentFragment) -IXMLDOMDocumentFragment createDocumentFragment create a DocumentFragment node - -## createElement(arg0) [](#method-i-createElement) -IXMLDOMElement createElement create an Element node - BSTR arg0 --- tagName [IN] - -## createEntityReference(arg0) [](#method-i-createEntityReference) -IXMLDOMEntityReference createEntityReference create an entity reference node - BSTR arg0 --- name [IN] - -## createNode(arg0, arg1, arg2) [](#method-i-createNode) -IXMLDOMNode createNode create a node of the specified node type and name - VARIANT arg0 --- type [IN] - BSTR arg1 --- name [IN] - BSTR arg2 --- namespaceURI [IN] - -## createProcessingInstruction(arg0, arg1) [](#method-i-createProcessingInstruction) -IXMLDOMProcessingInstruction createProcessingInstruction create a processing -instruction node - BSTR arg0 --- target [IN] - BSTR arg1 --- data [IN] - -## createTextNode(arg0) [](#method-i-createTextNode) -IXMLDOMText createTextNode create a text node - BSTR arg0 --- data [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## doctype() [](#method-i-doctype) -IXMLDOMDocumentType doctype node corresponding to the DOCTYPE - -## documentElement() [](#method-i-documentElement) -IXMLDOMElement documentElement the root of the tree - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## getElementsByTagName(arg0) [](#method-i-getElementsByTagName) -IXMLDOMNodeList getElementsByTagName build a list of elements by name - BSTR arg0 --- tagName [IN] - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## implementation() [](#method-i-implementation) -IXMLDOMImplementation implementation info on this DOM implementation - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## load(arg0) [](#method-i-load) -BOOL load load document from the specified XML source - VARIANT arg0 --- xmlSource [IN] - -## loadXML(arg0) [](#method-i-loadXML) -BOOL loadXML load the document from a string - BSTR arg0 --- bstrXML [IN] - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeFromID(arg0) [](#method-i-nodeFromID) -IXMLDOMNode nodeFromID retrieve node from it's ID - BSTR arg0 --- idString [IN] - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ondataavailable=(arg0) [](#method-i-ondataavailable=) -VOID ondataavailable register an ondataavailable event handler - -## onreadystatechange=(arg0) [](#method-i-onreadystatechange=) -VOID onreadystatechange register a readystatechange event handler - -## ontransformnode=(arg0) [](#method-i-ontransformnode=) -VOID ontransformnode register an ontransformnode event handler - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parseError() [](#method-i-parseError) -IXMLDOMParseError parseError get the last parser error - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## preserveWhiteSpace() [](#method-i-preserveWhiteSpace) -BOOL preserveWhiteSpace indicates whether the parser preserves whitespace - -## preserveWhiteSpace=(arg0) [](#method-i-preserveWhiteSpace=) -VOID preserveWhiteSpace indicates whether the parser preserves whitespace - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## readyState() [](#method-i-readyState) -I4 readyState get the state of the XML document - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## resolveExternals() [](#method-i-resolveExternals) -BOOL resolveExternals indicates whether the parser resolves references to -external DTD/Entities/Schema - -## resolveExternals=(arg0) [](#method-i-resolveExternals=) -VOID resolveExternals indicates whether the parser resolves references to -external DTD/Entities/Schema - -## save(arg0) [](#method-i-save) -VOID save save the document to a specified destination - VARIANT arg0 --- destination [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## url() [](#method-i-url) -BSTR url get the URL for the loaded XML document - -## validateOnParse() [](#method-i-validateOnParse) -BOOL validateOnParse indicates whether the parser performs validation - -## validateOnParse=(arg0) [](#method-i-validateOnParse=) -VOID validateOnParse indicates whether the parser performs validation - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMDocumentFragment.md b/example/ruby/IXMLDOMDocumentFragment.md deleted file mode 100644 index 050e146..0000000 --- a/example/ruby/IXMLDOMDocumentFragment.md +++ /dev/null @@ -1,136 +0,0 @@ -# Module: IXMLDOMDocumentFragment - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMDocumentType.md b/example/ruby/IXMLDOMDocumentType.md deleted file mode 100644 index c25b5f6..0000000 --- a/example/ruby/IXMLDOMDocumentType.md +++ /dev/null @@ -1,145 +0,0 @@ -# Module: IXMLDOMDocumentType - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## entities() [](#method-i-entities) -IXMLDOMNamedNodeMap entities a list of entities in the document - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## name() [](#method-i-name) -BSTR name name of the document type (root of the tree) - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## notations() [](#method-i-notations) -IXMLDOMNamedNodeMap notations a list of notations in the document - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMElement.md b/example/ruby/IXMLDOMElement.md deleted file mode 100644 index a5eaf54..0000000 --- a/example/ruby/IXMLDOMElement.md +++ /dev/null @@ -1,171 +0,0 @@ -# Module: IXMLDOMElement - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## getAttribute(arg0) [](#method-i-getAttribute) -VARIANT getAttribute look up the string value of an attribute by name - BSTR arg0 --- name [IN] - -## getAttributeNode(arg0) [](#method-i-getAttributeNode) -IXMLDOMAttribute getAttributeNode look up the attribute node by name - BSTR arg0 --- name [IN] - -## getElementsByTagName(arg0) [](#method-i-getElementsByTagName) -IXMLDOMNodeList getElementsByTagName build a list of elements by name - BSTR arg0 --- tagName [IN] - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## normalize() [](#method-i-normalize) -VOID normalize collapse all adjacent text nodes in sub-tree - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeAttribute(arg0) [](#method-i-removeAttribute) -VOID removeAttribute remove an attribute by name - BSTR arg0 --- name [IN] - -## removeAttributeNode(arg0) [](#method-i-removeAttributeNode) -IXMLDOMAttribute removeAttributeNode remove the specified attribute - IXMLDOMAttribute arg0 --- DOMAttribute [IN] - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## setAttribute(arg0, arg1) [](#method-i-setAttribute) -VOID setAttribute set the string value of an attribute by name - BSTR arg0 --- name [IN] - VARIANT arg1 --- value [IN] - -## setAttributeNode(arg0) [](#method-i-setAttributeNode) -IXMLDOMAttribute setAttributeNode set the specified attribute on the element - IXMLDOMAttribute arg0 --- DOMAttribute [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## tagName() [](#method-i-tagName) -BSTR tagName get the tagName of the element - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMEntity.md b/example/ruby/IXMLDOMEntity.md deleted file mode 100644 index 9e9426a..0000000 --- a/example/ruby/IXMLDOMEntity.md +++ /dev/null @@ -1,145 +0,0 @@ -# Module: IXMLDOMEntity - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## notationName() [](#method-i-notationName) -BSTR notationName the name of the notation - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## publicId() [](#method-i-publicId) -VARIANT publicId the public ID - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## systemId() [](#method-i-systemId) -VARIANT systemId the system ID - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMEntityReference.md b/example/ruby/IXMLDOMEntityReference.md deleted file mode 100644 index de6c7fd..0000000 --- a/example/ruby/IXMLDOMEntityReference.md +++ /dev/null @@ -1,136 +0,0 @@ -# Module: IXMLDOMEntityReference - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMImplementation.md b/example/ruby/IXMLDOMImplementation.md deleted file mode 100644 index d6b87cd..0000000 --- a/example/ruby/IXMLDOMImplementation.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: IXMLDOMImplementation - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## hasFeature(arg0, arg1) [](#method-i-hasFeature) -BOOL hasFeature - BSTR arg0 --- feature [IN] - BSTR arg1 --- version [IN] - diff --git a/example/ruby/IXMLDOMNamedNodeMap.md b/example/ruby/IXMLDOMNamedNodeMap.md deleted file mode 100644 index 76aa8fa..0000000 --- a/example/ruby/IXMLDOMNamedNodeMap.md +++ /dev/null @@ -1,48 +0,0 @@ -# Module: IXMLDOMNamedNodeMap - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## getNamedItem(arg0) [](#method-i-getNamedItem) -IXMLDOMNode getNamedItem lookup item by name - BSTR arg0 --- name [IN] - -## getQualifiedItem(arg0, arg1) [](#method-i-getQualifiedItem) -IXMLDOMNode getQualifiedItem lookup the item by name and namespace - BSTR arg0 --- baseName [IN] - BSTR arg1 --- namespaceURI [IN] - -## item() [](#method-i-item) -PTR item collection of nodes - I4 arg0 --- index [IN] - -## length() [](#method-i-length) -I4 length number of nodes in the collection - -## nextNode() [](#method-i-nextNode) -IXMLDOMNode nextNode get next node from iterator - -## removeNamedItem(arg0) [](#method-i-removeNamedItem) -IXMLDOMNode removeNamedItem remove item by name - BSTR arg0 --- name [IN] - -## removeQualifiedItem(arg0, arg1) [](#method-i-removeQualifiedItem) -IXMLDOMNode removeQualifiedItem remove the item by name and namespace - BSTR arg0 --- baseName [IN] - BSTR arg1 --- namespaceURI [IN] - -## reset() [](#method-i-reset) -VOID reset reset the position of iterator - -## setNamedItem(arg0) [](#method-i-setNamedItem) -IXMLDOMNode setNamedItem set item by name - IXMLDOMNode arg0 --- newItem [IN] - diff --git a/example/ruby/IXMLDOMNode.md b/example/ruby/IXMLDOMNode.md deleted file mode 100644 index 6a14ece..0000000 --- a/example/ruby/IXMLDOMNode.md +++ /dev/null @@ -1,137 +0,0 @@ -# Module: IXMLDOMNode - -**Includes:** WIN32OLE::VARIANT - - -Core DOM node interface - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMNodeList.md b/example/ruby/IXMLDOMNodeList.md deleted file mode 100644 index 6c40a01..0000000 --- a/example/ruby/IXMLDOMNodeList.md +++ /dev/null @@ -1,26 +0,0 @@ -# Module: IXMLDOMNodeList - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## item() [](#method-i-item) -PTR item collection of nodes - I4 arg0 --- index [IN] - -## length() [](#method-i-length) -I4 length number of nodes in the collection - -## nextNode() [](#method-i-nextNode) -IXMLDOMNode nextNode get next node from iterator - -## reset() [](#method-i-reset) -VOID reset reset the position of iterator - diff --git a/example/ruby/IXMLDOMNotation.md b/example/ruby/IXMLDOMNotation.md deleted file mode 100644 index 500ff1d..0000000 --- a/example/ruby/IXMLDOMNotation.md +++ /dev/null @@ -1,142 +0,0 @@ -# Module: IXMLDOMNotation - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## publicId() [](#method-i-publicId) -VARIANT publicId the public ID - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## systemId() [](#method-i-systemId) -VARIANT systemId the system ID - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMParseError.md b/example/ruby/IXMLDOMParseError.md deleted file mode 100644 index 2c2affd..0000000 --- a/example/ruby/IXMLDOMParseError.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: IXMLDOMParseError - -**Includes:** WIN32OLE::VARIANT - - -structure for reporting parser errors - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## errorCode() [](#method-i-errorCode) -I4 errorCode the error code - -## filepos() [](#method-i-filepos) -I4 filepos the absolute file position in the XML document containing the error - -## line() [](#method-i-line) -I4 line the line number in the XML document where the error occurred - -## linepos() [](#method-i-linepos) -I4 linepos the character position in the line containing the error - -## reason() [](#method-i-reason) -BSTR reason the cause of the error - -## srcText() [](#method-i-srcText) -BSTR srcText the data where the error occurred - -## url() [](#method-i-url) -BSTR url the URL of the XML document containing the error - diff --git a/example/ruby/IXMLDOMProcessingInstruction.md b/example/ruby/IXMLDOMProcessingInstruction.md deleted file mode 100644 index 080f550..0000000 --- a/example/ruby/IXMLDOMProcessingInstruction.md +++ /dev/null @@ -1,145 +0,0 @@ -# Module: IXMLDOMProcessingInstruction - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## data() [](#method-i-data) -BSTR data the data - -## data=(arg0) [](#method-i-data=) -VOID data the data - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## target() [](#method-i-target) -BSTR target the target - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLDOMText.md b/example/ruby/IXMLDOMText.md deleted file mode 100644 index e64fb71..0000000 --- a/example/ruby/IXMLDOMText.md +++ /dev/null @@ -1,175 +0,0 @@ -# Module: IXMLDOMText - -**Includes:** WIN32OLE::VARIANT - - - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## appendData(arg0) [](#method-i-appendData) -VOID appendData append string to value - BSTR arg0 --- data [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## data() [](#method-i-data) -BSTR data value of the node - -## data=(arg0) [](#method-i-data=) -VOID data value of the node - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## deleteData(arg0, arg1) [](#method-i-deleteData) -VOID deleteData delete string within the value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## insertData(arg0, arg1) [](#method-i-insertData) -VOID insertData insert string into value - I4 arg0 --- offset [IN] - BSTR arg1 --- data [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## length() [](#method-i-length) -I4 length number of characters in value - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## replaceData(arg0, arg1, arg2) [](#method-i-replaceData) -VOID replaceData replace string within the value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - BSTR arg2 --- data [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## splitText(arg0) [](#method-i-splitText) -IXMLDOMText splitText split the text node into two text nodes at the position -specified - I4 arg0 --- offset [IN] - -## substringData(arg0, arg1) [](#method-i-substringData) -BSTR substringData retrieve substring of value - I4 arg0 --- offset [IN] - I4 arg1 --- count [IN] - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/IXMLHttpRequest.md b/example/ruby/IXMLHttpRequest.md deleted file mode 100644 index 7494551..0000000 --- a/example/ruby/IXMLHttpRequest.md +++ /dev/null @@ -1,65 +0,0 @@ -# Module: IXMLHttpRequest - -**Includes:** WIN32OLE::VARIANT - - -IXMLHttpRequest Interface - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## abort() [](#method-i-abort) -VOID abort Abort HTTP request - -## getAllResponseHeaders() [](#method-i-getAllResponseHeaders) -BSTR getAllResponseHeaders Get all HTTP response headers - -## getResponseHeader(arg0) [](#method-i-getResponseHeader) -BSTR getResponseHeader Get HTTP response header - BSTR arg0 --- bstrHeader [IN] - -## onreadystatechange=(arg0) [](#method-i-onreadystatechange=) -VOID onreadystatechange Register a complete event handler - -## open(arg0, arg1, arg2nil, arg3nil, arg4nil) [](#method-i-open) -VOID open Open HTTP connection - BSTR arg0 --- bstrMethod [IN] - BSTR arg1 --- bstrUrl [IN] - VARIANT arg2 --- varAsync [IN] - VARIANT arg3 --- bstrUser [IN] - VARIANT arg4 --- bstrPassword [IN] - -## readyState() [](#method-i-readyState) -I4 readyState Get ready state - -## responseBody() [](#method-i-responseBody) -VARIANT responseBody Get response body - -## responseStream() [](#method-i-responseStream) -VARIANT responseStream Get response body - -## responseText() [](#method-i-responseText) -BSTR responseText Get response body - -## responseXML() [](#method-i-responseXML) -DISPATCH responseXML Get response body - -## send(arg0nil) [](#method-i-send) -VOID send Send HTTP request - VARIANT arg0 --- varBody [IN] - -## setRequestHeader(arg0, arg1) [](#method-i-setRequestHeader) -VOID setRequestHeader Add HTTP request header - BSTR arg0 --- bstrHeader [IN] - BSTR arg1 --- bstrValue [IN] - -## status() [](#method-i-status) -I4 status Get HTTP status code - -## statusText() [](#method-i-statusText) -BSTR statusText Get HTTP status text - diff --git a/example/ruby/IXTLRuntime.md b/example/ruby/IXTLRuntime.md deleted file mode 100644 index b925f43..0000000 --- a/example/ruby/IXTLRuntime.md +++ /dev/null @@ -1,180 +0,0 @@ -# Module: IXTLRuntime - -**Includes:** WIN32OLE::VARIANT - - -XTL runtime object - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - -#Instance Methods -## absoluteChildNumber(arg0) [](#method-i-absoluteChildNumber) -I4 absoluteChildNumber - IXMLDOMNode arg0 --- pNode [IN] - -## ancestorChildNumber(arg0, arg1) [](#method-i-ancestorChildNumber) -I4 ancestorChildNumber - BSTR arg0 --- bstrNodeName [IN] - IXMLDOMNode arg1 --- pNode [IN] - -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## childNumber(arg0) [](#method-i-childNumber) -I4 childNumber - IXMLDOMNode arg0 --- pNode [IN] - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## depth(arg0) [](#method-i-depth) -I4 depth - IXMLDOMNode arg0 --- pNode [IN] - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## formatDate(arg0, arg1, arg2nil) [](#method-i-formatDate) -BSTR formatDate - VARIANT arg0 --- varDate [IN] - BSTR arg1 --- bstrFormat [IN] - VARIANT arg2 --- varDestLocale [IN] - -## formatIndex(arg0, arg1) [](#method-i-formatIndex) -BSTR formatIndex - I4 arg0 --- lIndex [IN] - BSTR arg1 --- bstrFormat [IN] - -## formatNumber(arg0, arg1) [](#method-i-formatNumber) -BSTR formatNumber - R8 arg0 --- dblNumber [IN] - BSTR arg1 --- bstrFormat [IN] - -## formatTime(arg0, arg1, arg2nil) [](#method-i-formatTime) -BSTR formatTime - VARIANT arg0 --- varTime [IN] - BSTR arg1 --- bstrFormat [IN] - VARIANT arg2 --- varDestLocale [IN] - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## uniqueID(arg0) [](#method-i-uniqueID) -I4 uniqueID - IXMLDOMNode arg0 --- pNode [IN] - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/ImmutableString.md b/example/ruby/ImmutableString.md deleted file mode 100644 index edb3947..0000000 --- a/example/ruby/ImmutableString.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ImmutableString -**Inherits:** String - - - - - -#Instance Methods -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/IncludeAnyOfMatcher.md b/example/ruby/IncludeAnyOfMatcher.md deleted file mode 100644 index 63f10d9..0000000 --- a/example/ruby/IncludeAnyOfMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: IncludeAnyOfMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(*expected) [](#method-i-initialize) - -**@return** [IncludeAnyOfMatcher] a new instance of IncludeAnyOfMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/IncludeMatcher.md b/example/ruby/IncludeMatcher.md deleted file mode 100644 index 7063e5a..0000000 --- a/example/ruby/IncludeMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: IncludeMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(*expected) [](#method-i-initialize) - -**@return** [IncludeMatcher] a new instance of IncludeMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/IncludesMath.md b/example/ruby/IncludesMath.md deleted file mode 100644 index 4d6038e..0000000 --- a/example/ruby/IncludesMath.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: IncludesMath -**Inherits:** Object - -**Includes:** Math - - - - - diff --git a/example/ruby/IndexError.md b/example/ruby/IndexError.md deleted file mode 100644 index 8ceb47c..0000000 --- a/example/ruby/IndexError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: IndexError -**Inherits:** StandardError - - -Raised when the given index is invalid. - - a = [:foo, :bar] - a.fetch(0) #=> :foo - a[4] #=> nil - a.fetch(4) #=> IndexError: index 4 outside of array bounds: -2...2 - - - diff --git a/example/ruby/Indexer.md b/example/ruby/Indexer.md deleted file mode 100644 index a0810bd..0000000 --- a/example/ruby/Indexer.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Indexer - - - - -# Class Methods -## index(filepath ) [](#method-c-index) -Index the classes and modules within a file. If there are any entries, return -them as a serialized string to the parent process. - diff --git a/example/ruby/Indexer/Repository.md b/example/ruby/Indexer/Repository.md deleted file mode 100644 index bbc9fbb..0000000 --- a/example/ruby/Indexer/Repository.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Indexer::Repository -**Inherits:** Object - - -A class that implements the #enter functionality so that it can be passed to -the various save* APIs. This effectively bundles up all of the node_id and -field_name pairs so that they can be written back to the parent process. - - -# Attributes -## entries[RW] [](#attribute-i-entries) -Returns the value of attribute entries. - -## scope[RW] [](#attribute-i-scope) -Returns the value of attribute scope. - - -#Instance Methods -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## enter(node_id, field_name) [](#method-i-enter) - -## initialize() [](#method-i-initialize) - -**@return** [Repository] a new instance of Repository - -## with(next_scope) [](#method-i-with) - diff --git a/example/ruby/Indexer/Visitor.md b/example/ruby/Indexer/Visitor.md deleted file mode 100644 index 93fd465..0000000 --- a/example/ruby/Indexer/Visitor.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Indexer::Visitor -**Inherits:** Prism::Visitor - - -Visit the classes and modules in the AST and save their locations into the -repository. - - -# Attributes -## repository[RW] [](#attribute-i-repository) -Returns the value of attribute repository. - - -#Instance Methods -## initialize(repository) [](#method-i-initialize) - -**@return** [Visitor] a new instance of Visitor - -## visit_class_node(node) [](#method-i-visit_class_node) - -## visit_module_node(node) [](#method-i-visit_module_node) - diff --git a/example/ruby/InfinityMatcher.md b/example/ruby/InfinityMatcher.md deleted file mode 100644 index 08b6527..0000000 --- a/example/ruby/InfinityMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: InfinityMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected_sign) [](#method-i-initialize) - -**@return** [InfinityMatcher] a new instance of InfinityMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/Inspector.md b/example/ruby/Inspector.md deleted file mode 100644 index 7e0f1cf..0000000 --- a/example/ruby/Inspector.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Inspector -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Inspector] a new instance of Inspector - -## list(idx-1)) [](#method-i-list) - -## list_place() [](#method-i-list_place) - -## primary() [](#method-i-primary) - diff --git a/example/ruby/IntWrapper.md b/example/ruby/IntWrapper.md deleted file mode 100644 index b519668..0000000 --- a/example/ruby/IntWrapper.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: IntWrapper -**Inherits:** Object - - -Wrap an integer to pass as argument We use this so we can have some object -arguments - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## initialize(v) [](#method-i-initialize) - -**@return** [IntWrapper] a new instance of IntWrapper - diff --git a/example/ruby/Integer.md b/example/ruby/Integer.md deleted file mode 100644 index a161af4..0000000 --- a/example/ruby/Integer.md +++ /dev/null @@ -1,3055 +0,0 @@ -# Class: Integer -**Inherits:** Numeric - -**Includes:** Enumerable - - --- Add double dispatch to Integer ++ - - -# Class Methods -## sqrt() [](#method-c-sqrt) -## try_convert(num ) [](#method-c-try_convert) -If `object` is an Integer object, returns `object`. - Integer.try_convert(1) # => 1 - -Otherwise if `object` responds to `:to_int`, calls `object.to_int` and returns -the result. - Integer.try_convert(1.25) # => 1 - -Returns `nil` if `object` does not respond to `:to_int` - Integer.try_convert([]) # => nil - -Raises an exception unless `object.to_int` returns an Integer object. -**@overload** [] - - -#Instance Methods -## %(y) [](#method-i-%) -Returns `self` modulo `other` as a real number. - -For integer `n` and real number `r`, these expressions are equivalent: - - n % r - n-r*(n/r).floor - n.divmod(r)[1] - -See Numeric#divmod. - -Examples: - - 10 % 2 # => 0 - 10 % 3 # => 1 - 10 % 4 # => 2 - - 10 % -2 # => 0 - 10 % -3 # => -2 - 10 % -4 # => -2 - - 10 % 3.0 # => 1.0 - 10 % Rational(3, 1) # => (1/1) - -**@overload** [] - -## &(y) [](#method-i-&) -Bitwise AND; each bit in the result is 1 if both corresponding bits in `self` -and `other` are 1, 0 otherwise: - - "%04b" % (0b0101 & 0b0110) # => "0100" - -Raises an exception if `other` is not an Integer. - -Related: Integer#| (bitwise OR), Integer#^ (bitwise EXCLUSIVE OR). - -**@overload** [] - -## *(y) [](#method-i-*) -Performs multiplication: - - 4 * 2 # => 8 - 4 * -2 # => -8 - -4 * 2 # => -8 - 4 * 2.0 # => 8.0 - 4 * Rational(1, 3) # => (4/3) - 4 * Complex(2, 0) # => (8+0i) - -**@overload** [] - -## **(y) [](#method-i-**) -Raises `self` to the power of `numeric`: - - 2 ** 3 # => 8 - 2 ** -3 # => (1/8) - -2 ** 3 # => -8 - -2 ** -3 # => (-1/8) - 2 ** 3.3 # => 9.849155306759329 - 2 ** Rational(3, 1) # => (8/1) - 2 ** Complex(3, 0) # => (8+0i) - -**@overload** [] - -## +(y) [](#method-i-+) -Performs addition: - - 2 + 2 # => 4 - -2 + 2 # => 0 - -2 + -2 # => -4 - 2 + 2.0 # => 4.0 - 2 + Rational(2, 1) # => (4/1) - 2 + Complex(2, 0) # => (4+0i) - -**@overload** [] - -## -(y) [](#method-i--) -Performs subtraction: - - 4 - 2 # => 2 - -4 - 2 # => -6 - -4 - -2 # => -2 - 4 - 2.0 # => 2.0 - 4 - Rational(2, 1) # => (2/1) - 4 - Complex(2, 0) # => (2+0i) - -**@overload** [] - -## -@() [](#method-i--@) -call-seq: - -int -> integer - -Returns `self`, negated. - -## /(y) [](#method-i-/) -Performs division; for integer `numeric`, truncates the result to an integer: - - 4 / 3 # => 1 - 4 / -3 # => -2 - -4 / 3 # => -2 - -4 / -3 # => 1 - - For other +numeric+, returns non-integer result: - - 4 / 3.0 # => 1.3333333333333333 - 4 / Rational(3, 1) # => (4/3) - 4 / Complex(3, 0) # => ((4/3)+0i) - -**@overload** [] - -## <(y) [](#method-i-<) -Returns `true` if the value of `self` is less than that of `other`: - - 1 < 0 # => false - 1 < 1 # => false - 1 < 2 # => true - 1 < 0.5 # => false - 1 < Rational(1, 2) # => false - - Raises an exception if the comparison cannot be made. - -**@overload** [] - -## <<(y) [](#method-i-<<) -Returns `self` with bits shifted `count` positions to the left, or to the -right if `count` is negative: - - n = 0b11110000 - "%08b" % (n << 1) # => "111100000" - "%08b" % (n << 3) # => "11110000000" - "%08b" % (n << -1) # => "01111000" - "%08b" % (n << -3) # => "00011110" - -Related: Integer#>>. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Returns `true` if the value of `self` is less than or equal to - that of +other+: - - 1 <= 0 # => false - 1 <= 1 # => true - 1 <= 2 # => true - 1 <= 0.5 # => false - 1 <= Rational(1, 2) # => false - - Raises an exception if the comparison cannot be made. - -**@overload** [] - -## <=>(y) [](#method-i-<=>) -Returns: - -* -1, if `self` is less than `other`. -* 0, if `self` is equal to `other`. -* 1, if `self` is greater then `other`. -* `nil`, if `self` and `other` are incomparable. - -Examples: - - 1 <=> 2 # => -1 - 1 <=> 1 # => 0 - 1 <=> 0 # => 1 - 1 <=> 'foo' # => nil - - 1 <=> 1.0 # => 0 - 1 <=> Rational(1, 1) # => 0 - 1 <=> Complex(1, 0) # => 0 - -This method is the basis for comparisons in module Comparable. - -**@overload** [] - -## ==(y) [](#method-i-==) -Returns `true` if `self` is numerically equal to `other`; `false` otherwise. - - 1 == 2 #=> false - 1 == 1.0 #=> true - -Related: Integer#eql? (requires `other` to be an Integer). - -**@overload** [] - -## ===(y) [](#method-i-===) -Returns `true` if `self` is numerically equal to `other`; `false` otherwise. - - 1 == 2 #=> false - 1 == 1.0 #=> true - -Related: Integer#eql? (requires `other` to be an Integer). - -**@overload** [] - -## >(y) [](#method-i->) -Returns `true` if the value of `self` is greater than that of `other`: - - 1 > 0 # => true - 1 > 1 # => false - 1 > 2 # => false - 1 > 0.5 # => true - 1 > Rational(1, 2) # => true - -Raises an exception if the comparison cannot be made. - -**@overload** [] - -## >=(y) [](#method-i->=) -Returns `true` if the value of `self` is greater than or equal to that of -`other`: - - 1 >= 0 # => true - 1 >= 1 # => true - 1 >= 2 # => false - 1 >= 0.5 # => true - 1 >= Rational(1, 2) # => true - -Raises an exception if the comparison cannot be made. - -**@overload** [] - -## >>(y) [](#method-i->>) -Returns `self` with bits shifted `count` positions to the right, or to the -left if `count` is negative: - - n = 0b11110000 - "%08b" % (n >> 1) # => "01111000" - "%08b" % (n >> 3) # => "00011110" - "%08b" % (n >> -1) # => "111100000" - "%08b" % (n >> -3) # => "11110000000" - -Related: Integer#<<. - -**@overload** [] - -## [](*, const) [](#method-i-[]) -Returns a slice of bits from `self`. - -With argument `offset`, returns the bit at the given offset, where offset 0 -refers to the least significant bit: - - n = 0b10 # => 2 - n[0] # => 0 - n[1] # => 1 - n[2] # => 0 - n[3] # => 0 - -In principle, `n[i]` is equivalent to `(n >> i) & 1`. Thus, negative index -always returns zero: - - 255[-1] # => 0 - -With arguments `offset` and `size`, returns `size` bits from `self`, beginning -at `offset` and including bits of greater significance: - - n = 0b111000 # => 56 - "%010b" % n[0, 10] # => "0000111000" - "%010b" % n[4, 10] # => "0000000011" - -With argument `range`, returns `range.size` bits from `self`, beginning at -`range.begin` and including bits of greater significance: - - n = 0b111000 # => 56 - "%010b" % n[0..9] # => "0000111000" - "%010b" % n[4..9] # => "0000000011" - -Raises an exception if the slice cannot be constructed. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## ^(y) [](#method-i-^) -Bitwise EXCLUSIVE OR; each bit in the result is 1 if the corresponding bits in -`self` and `other` are different, 0 otherwise: - - "%04b" % (0b0101 ^ 0b0110) # => "0011" - -Raises an exception if `other` is not an Integer. - -Related: Integer#& (bitwise AND), Integer#| (bitwise OR). - -**@overload** [] - -## abs() [](#method-i-abs) -call-seq: - abs -> integer - -Returns the absolute value of `self`. - - (-12345).abs # => 12345 - -12345.abs # => 12345 - 12345.abs # => 12345 - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## allbits?(mask) [](#method-i-allbits?) -Returns `true` if all bits that are set (=1) in `mask` are also set in `self`; -returns `false` otherwise. - -Example values: - - 0b1010101 self - 0b1010100 mask - 0b1010100 self & mask - true self.allbits?(mask) - - 0b1010100 self - 0b1010101 mask - 0b1010100 self & mask - false self.allbits?(mask) - -Related: Integer#anybits?, Integer#nobits?. - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## anybits?(mask) [](#method-i-anybits?) -Returns `true` if any bit that is set (=1) in `mask` is also set in `self`; -returns `false` otherwise. - -Example values: - - 0b10000010 self - 0b11111111 mask - 0b10000010 self & mask - true self.anybits?(mask) - - 0b00000000 self - 0b11111111 mask - 0b00000000 self & mask - false self.anybits?(mask) - -Related: Integer#allbits?, Integer#nobits?. - -**@overload** [] - -## bit_length() [](#method-i-bit_length) -call-seq: - bit_length -> integer - -Returns the number of bits of the value of `self`, which is the bit position -of the highest-order bit that is different from the sign bit (where the least -significant bit has bit position 1). If there is no such bit (zero or minus -one), returns zero. - -This method returns `ceil(log2(self < 0 ? -self : self + 1))`>. - - (-2**1000-1).bit_length # => 1001 - (-2**1000).bit_length # => 1000 - (-2**1000+1).bit_length # => 1000 - (-2**12-1).bit_length # => 13 - (-2**12).bit_length # => 12 - (-2**12+1).bit_length # => 12 - -0x101.bit_length # => 9 - -0x100.bit_length # => 8 - -0xff.bit_length # => 8 - -2.bit_length # => 1 - -1.bit_length # => 0 - 0.bit_length # => 0 - 1.bit_length # => 1 - 0xff.bit_length # => 8 - 0x100.bit_length # => 9 - (2**12-1).bit_length # => 12 - (2**12).bit_length # => 13 - (2**12+1).bit_length # => 13 - (2**1000-1).bit_length # => 1000 - (2**1000).bit_length # => 1001 - (2**1000+1).bit_length # => 1001 - -For Integer *n*, this method can be used to detect overflow in Array#pack: - - if n.bit_length < 32 - [n].pack('l') # No overflow. - else - raise 'Overflow' - end - -## ceil(*args) [](#method-i-ceil) -:markup: markdown - -call-seq: - ceil(ndigits = 0) -> integer - -Returns an integer that is a "ceiling" value for `self`, as specified by the -given `ndigits`, which must be an [integer-convertible -object](implicit_conversion.rdoc@Integer-Convertible+Objects). - -* When `self` is zero, returns zero (regardless of the value of `ndigits`): - - ``` - 0.ceil(2) # => 0 - 0.ceil(-2) # => 0 - ``` - -* When `self` is non-zero and `ndigits` is non-negative, returns `self`: - - ``` - 555.ceil # => 555 - 555.ceil(50) # => 555 - ``` - -* When `self` is non-zero and `ndigits` is negative, returns a value based - on a computed granularity: - - - The granularity is `10 ** ndigits.abs`. - - The returned value is the smallest multiple of the granularity - that is greater than or equal to `self`. - - Examples with positive `self`: - - | ndigits | Granularity | 1234.ceil(ndigits) | - |--------:|------------:|-------------------:| - | -1 | 10 | 1240 | - | -2 | 100 | 1300 | - | -3 | 1000 | 2000 | - | -4 | 10000 | 10000 | - | -5 | 100000 | 100000 | - - Examples with negative `self`: - - | ndigits | Granularity | -1234.ceil(ndigits) | - |--------:|------------:|--------------------:| - | -1 | 10 | -1230 | - | -2 | 100 | -1200 | - | -3 | 1000 | -1000 | - | -4 | 10000 | 0 | - | -5 | 100000 | 0 | - -Related: Integer#floor. - -## ceildiv(other) [](#method-i-ceildiv) -call-seq: - ceildiv(numeric) -> integer - - Returns the result of division +self+ by +numeric+. - rounded up to the nearest integer. - - 3.ceildiv(3) # => 1 - 4.ceildiv(3) # => 2 - - 4.ceildiv(-3) # => -1 - -4.ceildiv(3) # => -1 - -4.ceildiv(-3) # => 2 - - 3.ceildiv(1.2) # => 3 - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chr(*args) [](#method-i-chr) -Returns a 1-character string containing the character represented by the value -of `self`, according to the given `encoding`. - - 65.chr # => "A" - 0.chr # => "\x00" - 255.chr # => "\xFF" - string = 255.chr(Encoding::UTF_8) - string.encoding # => Encoding::UTF_8 - -Raises an exception if `self` is negative. - -Related: Integer#ord. - -**@overload** [] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## coerce(y) [](#method-i-coerce) -Returns an array with both a `numeric` and a `int` represented as Integer -objects or Float objects. - -This is achieved by converting `numeric` to an Integer or a Float. - -A TypeError is raised if the `numeric` is not an Integer or a Float type. - - (0x3FFFFFFFFFFFFFFF+1).coerce(42) #=> [42, 4611686018427387904] - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## denominator() [](#method-i-denominator) -call-seq: - denominator -> 1 - -Returns `1`. - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## digits(*args) [](#method-i-digits) -Returns an array of integers representing the `base`-radix digits of `self`; -the first element of the array represents the least significant digit: - - 12345.digits # => [5, 4, 3, 2, 1] - 12345.digits(7) # => [4, 6, 6, 0, 5] - 12345.digits(100) # => [45, 23, 1] - -Raises an exception if `self` is negative or `base` is less than 2. - -**@overload** [] - -## div(y) [](#method-i-div) -Performs integer division; returns the integer result of dividing `self` by -`numeric`: - - 4.div(3) # => 1 - 4.div(-3) # => -2 - -4.div(3) # => -2 - -4.div(-3) # => 1 - 4.div(3.0) # => 1 - 4.div(Rational(3, 1)) # => 1 - -Raises an exception if `numeric` does not have method `div`. - -**@overload** [] - -## divmod(y) [](#method-i-divmod) -Returns a 2-element array `[q, r]`, where - - q = (self/other).floor # Quotient - r = self % other # Remainder - -Examples: - - 11.divmod(4) # => [2, 3] - 11.divmod(-4) # => [-3, -1] - -11.divmod(4) # => [-3, 1] - -11.divmod(-4) # => [2, -3] - - 12.divmod(4) # => [3, 0] - 12.divmod(-4) # => [-3, 0] - -12.divmod(4) # => [-3, 0] - -12.divmod(-4) # => [3, 0] - - 13.divmod(4.0) # => [3, 1.0] - 13.divmod(Rational(4, 1)) # => [3, (1/1)] - -**@overload** [] - -## downto(to) [](#method-i-downto) -Calls the given block with each integer value from `self` down to `limit`; -returns `self`: - - a = [] - 10.downto(5) {|i| a << i } # => 10 - a # => [10, 9, 8, 7, 6, 5] - a = [] - 0.downto(-5) {|i| a << i } # => 0 - a # => [0, -1, -2, -3, -4, -5] - 4.downto(5) {|i| fail 'Cannot happen' } # => 4 - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## even?() [](#method-i-even?) -call-seq: - even? -> true or false - - Returns +true+ if +self+ is an even number, +false+ otherwise. - -**@return** [Boolean] - -## fdiv(y) [](#method-i-fdiv) -Returns the Float result of dividing `self` by `numeric`: - - 4.fdiv(2) # => 2.0 - 4.fdiv(-2) # => -2.0 - -4.fdiv(2) # => -2.0 - 4.fdiv(2.0) # => 2.0 - 4.fdiv(Rational(3, 4)) # => 5.333333333333333 - -Raises an exception if `numeric` cannot be converted to a Float. - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## floor(*args) [](#method-i-floor) -:markup: markdown - -call-seq: - floor(ndigits = 0) -> integer - -Returns an integer that is a "floor" value for `self`, as specified by the -given `ndigits`, which must be an [integer-convertible -object](implicit_conversion.rdoc@Integer-Convertible+Objects). - -* When `self` is zero, returns zero (regardless of the value of `ndigits`): - - ``` - 0.floor(2) # => 0 - 0.floor(-2) # => 0 - ``` - -* When `self` is non-zero and `ndigits` is non-negative, returns `self`: - - ``` - 555.floor # => 555 - 555.floor(50) # => 555 - ``` - -* When `self` is non-zero and `ndigits` is negative, returns a value based - on a computed granularity: - - - The granularity is `10 ** ndigits.abs`. - - The returned value is the largest multiple of the granularity - that is less than or equal to `self`. - - Examples with positive `self`: - - | ndigits | Granularity | 1234.floor(ndigits) | - |--------:|------------:|--------------------:| - | -1 | 10 | 1230 | - | -2 | 100 | 1200 | - | -3 | 1000 | 1000 | - | -4 | 10000 | 0 | - | -5 | 100000 | 0 | - - Examples with negative `self`: - - | ndigits | Granularity | -1234.floor(ndigits) | - |--------:|------------:|---------------------:| - | -1 | 10 | -1240 | - | -2 | 100 | -1300 | - | -3 | 1000 | -2000 | - | -4 | 10000 | -10000 | - | -5 | 100000 | -100000 | - -Related: Integer#ceil. - -## gcd(other) [](#method-i-gcd) -Returns the greatest common divisor of the two integers. The result is always -positive. 0.gcd(x) and x.gcd(0) return x.abs. - - 36.gcd(60) #=> 12 - 2.gcd(2) #=> 2 - 3.gcd(-7) #=> 1 - ((1<<31)-1).gcd((1<<61)-1) #=> 1 - -**@overload** [] - -## gcdlcm(other) [](#method-i-gcdlcm) -Returns an array with the greatest common divisor and the least common -multiple of the two integers, [gcd, lcm]. - - 36.gcdlcm(60) #=> [12, 180] - 2.gcdlcm(2) #=> [2, 2] - 3.gcdlcm(-7) #=> [1, 21] - ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## integer?() [](#method-i-integer?) -call-seq: - integer? -> true - - Since +self+ is already an \Integer, always returns +true+. - -**@return** [Boolean] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## lcm(other) [](#method-i-lcm) -Returns the least common multiple of the two integers. The result is always -positive. 0.lcm(x) and x.lcm(0) return zero. - - 36.lcm(60) #=> 180 - 2.lcm(2) #=> 2 - 3.lcm(-7) #=> 21 - ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297 - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## modulo(y) [](#method-i-modulo) -Returns `self` modulo `other` as a real number. - -For integer `n` and real number `r`, these expressions are equivalent: - - n % r - n-r*(n/r).floor - n.divmod(r)[1] - -See Numeric#divmod. - -Examples: - - 10 % 2 # => 0 - 10 % 3 # => 1 - 10 % 4 # => 2 - - 10 % -2 # => 0 - 10 % -3 # => -2 - 10 % -4 # => -2 - - 10 % 3.0 # => 1.0 - 10 % Rational(3, 1) # => (1/1) - -**@overload** [] - -## next() [](#method-i-next) - -## nobits?(mask) [](#method-i-nobits?) -Returns `true` if no bit that is set (=1) in `mask` is also set in `self`; -returns `false` otherwise. - -Example values: - - 0b11110000 self - 0b00001111 mask - 0b00000000 self & mask - true self.nobits?(mask) - - 0b00000001 self - 0b11111111 mask - 0b00000001 self & mask - false self.nobits?(mask) - -Related: Integer#allbits?, Integer#anybits?. - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## numerator() [](#method-i-numerator) -call-seq: - numerator -> self - -Returns `self`. - -## odd?() [](#method-i-odd?) -call-seq: - odd? -> true or false - - Returns +true+ if +self+ is an odd number, +false+ otherwise. - -**@return** [Boolean] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## ord() [](#method-i-ord) -call-seq: - ord -> self - - Returns +self+; - intended for compatibility to character literals in Ruby 1.9. - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pow(*, const) [](#method-i-pow) -Returns (modular) exponentiation as: - - a.pow(b) #=> same as a**b - a.pow(b, m) #=> same as (a**b) % m, but avoids huge temporary values - -**@overload** [] - -**@overload** [] - -## pred() [](#method-i-pred) - -## rationalize(*args) [](#method-i-rationalize) -Returns the value as a rational. The optional argument `eps` is always -ignored. - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## remainder(y) [](#method-i-remainder) -Returns the remainder after dividing `self` by `other`. - -Examples: - - 11.remainder(4) # => 3 - 11.remainder(-4) # => 3 - -11.remainder(4) # => -3 - -11.remainder(-4) # => -3 - - 12.remainder(4) # => 0 - 12.remainder(-4) # => 0 - -12.remainder(4) # => 0 - -12.remainder(-4) # => 0 - - 13.remainder(4.0) # => 1.0 - 13.remainder(Rational(4, 1)) # => (1/1) - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## round(*args) [](#method-i-round) -Returns `self` rounded to the nearest value with a precision of `ndigits` -decimal digits. - -When `ndigits` is negative, the returned value has at least `ndigits.abs` -trailing zeros: - - 555.round(-1) # => 560 - 555.round(-2) # => 600 - 555.round(-3) # => 1000 - -555.round(-2) # => -600 - 555.round(-4) # => 0 - -Returns `self` when `ndigits` is zero or positive. - - 555.round # => 555 - 555.round(1) # => 555 - 555.round(50) # => 555 - -If keyword argument `half` is given, and `self` is equidistant from the two -candidate values, the rounding is according to the given `half` value: - -* `:up` or `nil`: round away from zero: - - 25.round(-1, half: :up) # => 30 - (-25).round(-1, half: :up) # => -30 - -* `:down`: round toward zero: - - 25.round(-1, half: :down) # => 20 - (-25).round(-1, half: :down) # => -20 - -* `:even`: round toward the candidate whose last nonzero digit is even: - - 25.round(-1, half: :even) # => 20 - 15.round(-1, half: :even) # => 20 - (-25).round(-1, half: :even) # => -20 - -Raises and exception if the value for `half` is invalid. - -Related: Integer#truncate. - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) -call-seq: - size -> integer - - Returns the number of bytes in the machine representation of +self+; - the value is system-dependent: - - 1.size # => 8 - -1.size # => 8 - 2147483647.size # => 8 - (256**10 - 1).size # => 10 - (256**20 - 1).size # => 20 - (256**40 - 1).size # => 40 - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## succ() [](#method-i-succ) - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## times() [](#method-i-times) -call-seq: - times {|i| ... } -> self - times -> enumerator - -Calls the given block `self` times with each integer in `(0..self-1)`: - - a = [] - 5.times {|i| a.push(i) } # => 5 - a # => [0, 1, 2, 3, 4] - -With no block given, returns an Enumerator. - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_bn() [](#method-i-to_bn) -Casts an Integer as an OpenSSL::BN - -See `man bn` for more info. - -## to_f() [](#method-i-to_f) -Converts `self` to a Float: - - 1.to_f # => 1.0 - -1.to_f # => -1.0 - -If the value of `self` does not fit in a Float, the result is infinity: - - (10**400).to_f # => Infinity - (-10**400).to_f # => -Infinity - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_i() [](#method-i-to_i) -call-seq: - to_i -> self - - Returns +self+ (which is already an \Integer). - -## to_int() [](#method-i-to_int) -call-seq: - to_int -> self - - Returns +self+ (which is already an \Integer). - -## to_r() [](#method-i-to_r) -Returns the value as a rational. - - 1.to_r #=> (1/1) - (1<<64).to_r #=> (18446744073709551616/1) - -**@overload** [] - -## to_s(*args) [](#method-i-to_s) -Returns a string containing the place-value representation of `self` in radix -`base` (in 2..36). - - 12345.to_s # => "12345" - 12345.to_s(2) # => "11000000111001" - 12345.to_s(8) # => "30071" - 12345.to_s(10) # => "12345" - 12345.to_s(16) # => "3039" - 12345.to_s(36) # => "9ix" - 78546939656932.to_s(36) # => "rubyrules" - -Raises an exception if `base` is out of range. - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## truncate(*args) [](#method-i-truncate) -Returns `self` truncated (toward zero) to a precision of `ndigits` decimal -digits. - -When `ndigits` is negative, the returned value has at least `ndigits.abs` -trailing zeros: - - 555.truncate(-1) # => 550 - 555.truncate(-2) # => 500 - -555.truncate(-2) # => -500 - -Returns `self` when `ndigits` is zero or positive. - - 555.truncate # => 555 - 555.truncate(50) # => 555 - -Related: Integer#round. - -**@overload** [] - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## upto(to) [](#method-i-upto) -Calls the given block with each integer value from `self` up to `limit`; -returns `self`: - - a = [] - 5.upto(10) {|i| a << i } # => 5 - a # => [5, 6, 7, 8, 9, 10] - a = [] - -5.upto(0) {|i| a << i } # => -5 - a # => [-5, -4, -3, -2, -1, 0] - 5.upto(4) {|i| fail 'Cannot happen' } # => 5 - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## zero?() [](#method-i-zero?) -call-seq: - zero? -> true or false - -Returns `true` if `self` has a zero value, `false` otherwise. - -**@return** [Boolean] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - -## |(y) [](#method-i-|) -Bitwise OR; each bit in the result is 1 if either corresponding bit in `self` -or `other` is 1, 0 otherwise: - - "%04b" % (0b0101 | 0b0110) # => "0111" - -Raises an exception if `other` is not an Integer. - -Related: Integer#& (bitwise AND), Integer#^ (bitwise EXCLUSIVE OR). - -**@overload** [] - -## ~() [](#method-i-~) -call-seq: - ~int -> integer - -One's complement: returns the value of `self` with each bit inverted. - -Because an integer value is conceptually of infinite length, the result acts -as if it had an infinite number of one bits to the left. In hex -representations, this is displayed as two periods to the left of the digits: - - sprintf("%X", ~0x1122334455) # => "..FEEDDCCBBAA" - diff --git a/example/ruby/IntegerSpecs.md b/example/ruby/IntegerSpecs.md deleted file mode 100644 index 484c3d2..0000000 --- a/example/ruby/IntegerSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: IntegerSpecs - - - - - diff --git a/example/ruby/IntegerSpecs/CoerceError.md b/example/ruby/IntegerSpecs/CoerceError.md deleted file mode 100644 index 5c65466..0000000 --- a/example/ruby/IntegerSpecs/CoerceError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: IntegerSpecs::CoerceError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Interrupt.md b/example/ruby/Interrupt.md deleted file mode 100644 index cec29e0..0000000 --- a/example/ruby/Interrupt.md +++ /dev/null @@ -1,29 +0,0 @@ -# Exception: Interrupt -**Inherits:** SignalException - - -Raised when the interrupt signal is received, typically because the user has -pressed Control-C (on most posix platforms). As such, it is a subclass of -`SignalException`. - - begin - puts "Press ctrl-C when you get bored" - loop {} - rescue Interrupt => e - puts "Note: You will typically use Signal.trap instead." - end - -*produces:* - - Press ctrl-C when you get bored - -*then waits until it is interrupted with Control-C and then prints:* - - Note: You will typically use Signal.trap instead. - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Isect.md b/example/ruby/Isect.md deleted file mode 100644 index f65703b..0000000 --- a/example/ruby/Isect.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Isect -**Inherits:** Object - - - - -# Attributes -## hit[RW] [](#attribute-i-hit) -Returns the value of attribute hit. - -## n[RW] [](#attribute-i-n) -Returns the value of attribute n. - -## pl[RW] [](#attribute-i-pl) -Returns the value of attribute pl. - -## t[RW] [](#attribute-i-t) -Returns the value of attribute t. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Isect] a new instance of Isect - diff --git a/example/ruby/IterTest.md b/example/ruby/IterTest.md deleted file mode 100644 index 9a6c1e8..0000000 --- a/example/ruby/IterTest.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: IterTest -**Inherits:** Object - - - - - -#Instance Methods -## each0(&block) [](#method-i-each0) - -## each1(&block) [](#method-i-each1) - -## each2(&block) [](#method-i-each2) - -## each3(&block) [](#method-i-each3) - -## each4(&block) [](#method-i-each4) - -## each5() [](#method-i-each5) - -## each6() [](#method-i-each6) - -## each7() [](#method-i-each7) - -## each8() [](#method-i-each8) - -## f(a) [](#method-i-f) - -## initialize(e) [](#method-i-initialize) - -**@return** [IterTest] a new instance of IterTest - diff --git a/example/ruby/JISX0208.md b/example/ruby/JISX0208.md deleted file mode 100644 index 7275932..0000000 --- a/example/ruby/JISX0208.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: JISX0208 - - -Library used by tools/enc-emoji-citrus-gen.rb - - - diff --git a/example/ruby/JISX0208/Char.md b/example/ruby/JISX0208/Char.md deleted file mode 100644 index a3559dc..0000000 --- a/example/ruby/JISX0208/Char.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: JISX0208::Char -**Inherits:** Object - - - - -# Class Methods -## from_sjis(sjis ) [](#method-c-from_sjis) - -#Instance Methods -## ==(other) [](#method-i-==) - -## cell() [](#method-i-cell) - -## hi() [](#method-i-hi) - -## initialize(row, cellnil) [](#method-i-initialize) - -**@return** [Char] a new instance of Char - -## inspect() [](#method-i-inspect) - -## lo() [](#method-i-lo) - -## row() [](#method-i-row) - -## succ() [](#method-i-succ) - -## to_int() [](#method-i-to_int) - -## to_sjis() [](#method-i-to_sjis) - diff --git a/example/ruby/JITSupport.md b/example/ruby/JITSupport.md deleted file mode 100644 index 501c23a..0000000 --- a/example/ruby/JITSupport.md +++ /dev/null @@ -1,25 +0,0 @@ -# Module: JITSupport - - - - -# Class Methods -## rjit_enabled?() [](#method-c-rjit_enabled?) -**@return** [Boolean] - -## rjit_force_enabled?() [](#method-c-rjit_force_enabled?) -**@return** [Boolean] - -## rjit_supported?() [](#method-c-rjit_supported?) -**@return** [Boolean] - -## yjit_enabled?() [](#method-c-yjit_enabled?) -**@return** [Boolean] - -## yjit_force_enabled?() [](#method-c-yjit_force_enabled?) -**@return** [Boolean] - -## yjit_supported?() [](#method-c-yjit_supported?) -**@return** [Boolean] - - diff --git a/example/ruby/JSON.md b/example/ruby/JSON.md deleted file mode 100644 index 22b24f6..0000000 --- a/example/ruby/JSON.md +++ /dev/null @@ -1,1090 +0,0 @@ -# Module: JSON - - -# JavaScript Object Notation (JSON) - -JSON is a lightweight data-interchange format. - -A JSON value is one of the following: -* Double-quoted text: `"foo"`. -* Number: `1`, `1.0`, `2.0e2`. -* Boolean: `true`, `false`. -* Null: `null`. -* Array: an ordered list of values, enclosed by square brackets: - ["foo", 1, 1.0, 2.0e2, true, false, null] - -* Object: a collection of name/value pairs, enclosed by curly braces; each - name is double-quoted text; the values may be any JSON values: - {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null} - -A JSON array or object may contain nested arrays, objects, and scalars to any -depth: - {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]} - [{"foo": 0, "bar": 1}, ["baz", 2]] - -## Using Module JSON - -To make module JSON available in your code, begin with: - require 'json' - -All examples here assume that this has been done. - -### Parsing JSON - -You can parse a String containing JSON data using either of two methods: -* `JSON.parse(source, opts)` -* `JSON.parse!(source, opts)` - -where -* `source` is a Ruby object. -* `opts` is a Hash object containing options that control both input allowed - and output formatting. - -The difference between the two methods is that JSON.parse! omits some checks -and may not be safe for some `source` data; use it only for data from trusted -sources. Use the safer method JSON.parse for less trusted sources. - -#### Parsing JSON Arrays - -When `source` is a JSON array, JSON.parse by default returns a Ruby Array: - json = '["foo", 1, 1.0, 2.0e2, true, false, null]' - ruby = JSON.parse(json) - ruby # => ["foo", 1, 1.0, 200.0, true, false, nil] - ruby.class # => Array - -The JSON array may contain nested arrays, objects, and scalars to any depth: - json = '[{"foo": 0, "bar": 1}, ["baz", 2]]' - JSON.parse(json) # => [{"foo"=>0, "bar"=>1}, ["baz", 2]] - -#### Parsing JSON Objects - -When the source is a JSON object, JSON.parse by default returns a Ruby Hash: - json = '{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}' - ruby = JSON.parse(json) - ruby # => {"a"=>"foo", "b"=>1, "c"=>1.0, "d"=>200.0, "e"=>true, "f"=>false, "g"=>nil} - ruby.class # => Hash - -The JSON object may contain nested arrays, objects, and scalars to any depth: - json = '{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}' - JSON.parse(json) # => {"foo"=>{"bar"=>1, "baz"=>2}, "bat"=>[0, 1, 2]} - -#### Parsing JSON Scalars - -When the source is a JSON scalar (not an array or object), JSON.parse returns -a Ruby scalar. - -String: - ruby = JSON.parse('"foo"') - ruby # => 'foo' - ruby.class # => String - -Integer: - ruby = JSON.parse('1') - ruby # => 1 - ruby.class # => Integer - -Float: - ruby = JSON.parse('1.0') - ruby # => 1.0 - ruby.class # => Float - ruby = JSON.parse('2.0e2') - ruby # => 200 - ruby.class # => Float - -Boolean: - ruby = JSON.parse('true') - ruby # => true - ruby.class # => TrueClass - ruby = JSON.parse('false') - ruby # => false - ruby.class # => FalseClass - -Null: - ruby = JSON.parse('null') - ruby # => nil - ruby.class # => NilClass - -#### Parsing Options - -###### Input Options - -Option `max_nesting` (Integer) specifies the maximum nesting depth allowed; -defaults to `100`; specify `false` to disable depth checking. - -With the default, `false`: - source = '[0, [1, [2, [3]]]]' - ruby = JSON.parse(source) - ruby # => [0, [1, [2, [3]]]] - -Too deep: - # Raises JSON::NestingError (nesting of 2 is too deep): - JSON.parse(source, {max_nesting: 1}) - -Bad value: - # Raises TypeError (wrong argument type Symbol (expected Fixnum)): - JSON.parse(source, {max_nesting: :foo}) - ---- - -Option `allow_nan` (boolean) specifies whether to allow NaN, Infinity, and -MinusInfinity in `source`; defaults to `false`. - -With the default, `false`: - # Raises JSON::ParserError (225: unexpected token at '[NaN]'): - JSON.parse('[NaN]') - # Raises JSON::ParserError (232: unexpected token at '[Infinity]'): - JSON.parse('[Infinity]') - # Raises JSON::ParserError (248: unexpected token at '[-Infinity]'): - JSON.parse('[-Infinity]') - -Allow: - source = '[NaN, Infinity, -Infinity]' - ruby = JSON.parse(source, {allow_nan: true}) - ruby # => [NaN, Infinity, -Infinity] - -###### Output Options - -Option `symbolize_names` (boolean) specifies whether returned Hash keys should -be Symbols; defaults to `false` (use Strings). - -With the default, `false`: - source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}' - ruby = JSON.parse(source) - ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil} - -Use Symbols: - ruby = JSON.parse(source, {symbolize_names: true}) - ruby # => {:a=>"foo", :b=>1.0, :c=>true, :d=>false, :e=>nil} - ---- - -Option `object_class` (Class) specifies the Ruby class to be used for each -JSON object; defaults to Hash. - -With the default, Hash: - source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}' - ruby = JSON.parse(source) - ruby.class # => Hash - -Use class OpenStruct: - ruby = JSON.parse(source, {object_class: OpenStruct}) - ruby # => # - ---- - -Option `array_class` (Class) specifies the Ruby class to be used for each JSON -array; defaults to Array. - -With the default, Array: - source = '["foo", 1.0, true, false, null]' - ruby = JSON.parse(source) - ruby.class # => Array - -Use class Set: - ruby = JSON.parse(source, {array_class: Set}) - ruby # => # - ---- - -Option `create_additions` (boolean) specifies whether to use JSON additions in -parsing. See [\JSON Additions](#module-JSON-label-JSON+Additions). - -### Generating JSON - -To generate a Ruby String containing JSON data, use method -`JSON.generate(source, opts)`, where -* `source` is a Ruby object. -* `opts` is a Hash object containing options that control both input allowed - and output formatting. - -#### Generating JSON from Arrays - -When the source is a Ruby Array, JSON.generate returns a String containing a -JSON array: - ruby = [0, 's', :foo] - json = JSON.generate(ruby) - json # => '[0,"s","foo"]' - -The Ruby Array array may contain nested arrays, hashes, and scalars to any -depth: - ruby = [0, [1, 2], {foo: 3, bar: 4}] - json = JSON.generate(ruby) - json # => '[0,[1,2],{"foo":3,"bar":4}]' - -#### Generating JSON from Hashes - -When the source is a Ruby Hash, JSON.generate returns a String containing a -JSON object: - ruby = {foo: 0, bar: 's', baz: :bat} - json = JSON.generate(ruby) - json # => '{"foo":0,"bar":"s","baz":"bat"}' - -The Ruby Hash array may contain nested arrays, hashes, and scalars to any -depth: - ruby = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad} - json = JSON.generate(ruby) - json # => '{"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}' - -#### Generating JSON from Other Objects - -When the source is neither an Array nor a Hash, the generated JSON data -depends on the class of the source. - -When the source is a Ruby Integer or Float, JSON.generate returns a String -containing a JSON number: - JSON.generate(42) # => '42' - JSON.generate(0.42) # => '0.42' - -When the source is a Ruby String, JSON.generate returns a String containing a -JSON string (with double-quotes): - JSON.generate('A string') # => '"A string"' - -When the source is `true`, `false` or `nil`, JSON.generate returns a String -containing the corresponding JSON token: - JSON.generate(true) # => 'true' - JSON.generate(false) # => 'false' - JSON.generate(nil) # => 'null' - -When the source is none of the above, JSON.generate returns a String -containing a JSON string representation of the source: - JSON.generate(:foo) # => '"foo"' - JSON.generate(Complex(0, 0)) # => '"0+0i"' - JSON.generate(Dir.new('.')) # => '"#"' - -#### Generating Options - -###### Input Options - -Option `allow_nan` (boolean) specifies whether `NaN`, `Infinity`, and -`-Infinity` may be generated; defaults to `false`. - -With the default, `false`: - # Raises JSON::GeneratorError (920: NaN not allowed in JSON): - JSON.generate(JSON::NaN) - # Raises JSON::GeneratorError (917: Infinity not allowed in JSON): - JSON.generate(JSON::Infinity) - # Raises JSON::GeneratorError (917: -Infinity not allowed in JSON): - JSON.generate(JSON::MinusInfinity) - -Allow: - ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity] - JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]' - ---- - -Option `max_nesting` (Integer) specifies the maximum nesting depth in `obj`; -defaults to `100`. - -With the default, `100`: - obj = [[[[[[0]]]]]] - JSON.generate(obj) # => '[[[[[[0]]]]]]' - -Too deep: - # Raises JSON::NestingError (nesting of 2 is too deep): - JSON.generate(obj, max_nesting: 2) - -###### Escaping Options - -Options `script_safe` (boolean) specifies wether `'\u2028'`, `'\u2029'` and -`'/'` should be escaped as to make the JSON object safe to interpolate in -script tags. - -Options `ascii_only` (boolean) specifies wether all characters outside the -ASCII range should be escaped. - -###### Output Options - -The default formatting options generate the most compact JSON data, all on one -line and with no whitespace. - -You can use these formatting options to generate JSON data in a more open -format, using whitespace. See also JSON.pretty_generate. - -* Option `array_nl` (String) specifies a string (usually a newline) to be - inserted after each JSON array; defaults to the empty String, `''`. -* Option `object_nl` (String) specifies a string (usually a newline) to be - inserted after each JSON object; defaults to the empty String, `''`. -* Option `indent` (String) specifies the string (usually spaces) to be used - for indentation; defaults to the empty String, `''`; defaults to the empty - String, `''`; has no effect unless options `array_nl` or `object_nl` - specify newlines. -* Option `space` (String) specifies a string (usually a space) to be - inserted after the colon in each JSON object's pair; defaults to the empty - String, `''`. -* Option `space_before` (String) specifies a string (usually a space) to be - inserted before the colon in each JSON object's pair; defaults to the - empty String, `''`. - -In this example, `obj` is used first to generate the shortest JSON data (no -whitespace), then again with all formatting options specified: - - obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}} - json = JSON.generate(obj) - puts 'Compact:', json - opts = { - array_nl: "\n", - object_nl: "\n", - indent: ' ', - space_before: ' ', - space: ' ' - } - puts 'Open:', JSON.generate(obj, opts) - -Output: - Compact: - {"foo":["bar","baz"],"bat":{"bam":0,"bad":1}} - Open: - { - "foo" : [ - "bar", - "baz" - ], - "bat" : { - "bam" : 0, - "bad" : 1 - } - } - -## JSON Additions - -When you "round trip" a non-String object from Ruby to JSON and back, you have -a new String, instead of the object you began with: - ruby0 = Range.new(0, 2) - json = JSON.generate(ruby0) - json # => '0..2"' - ruby1 = JSON.parse(json) - ruby1 # => '0..2' - ruby1.class # => String - -You can use JSON *additions* to preserve the original object. The addition is -an extension of a ruby class, so that: -* JSON.generate stores more information in the JSON string. -* JSON.parse, called with option `create_additions`, uses that information - to create a proper Ruby object. - -This example shows a Range being generated into JSON and parsed back into -Ruby, both without and with the addition for Range: - ruby = Range.new(0, 2) - # This passage does not use the addition for Range. - json0 = JSON.generate(ruby) - ruby0 = JSON.parse(json0) - # This passage uses the addition for Range. - require 'json/add/range' - json1 = JSON.generate(ruby) - ruby1 = JSON.parse(json1, create_additions: true) - # Make a nice display. - display = <<~EOT - Generated JSON: - Without addition: #{json0} (#{json0.class}) - With addition: #{json1} (#{json1.class}) - Parsed JSON: - Without addition: #{ruby0.inspect} (#{ruby0.class}) - With addition: #{ruby1.inspect} (#{ruby1.class}) - EOT - puts display - -This output shows the different results: - Generated JSON: - Without addition: "0..2" (String) - With addition: {"json_class":"Range","a":[0,2,false]} (String) - Parsed JSON: - Without addition: "0..2" (String) - With addition: 0..2 (Range) - -The JSON module includes additions for certain classes. You can also craft -custom additions. See [Custom \JSON -Additions](#module-JSON-label-Custom+JSON+Additions). - -### Built-in Additions - -The JSON module includes additions for certain classes. To use an addition, -`require` its source: -* BigDecimal: `require 'json/add/bigdecimal'` -* Complex: `require 'json/add/complex'` -* Date: `require 'json/add/date'` -* DateTime: `require 'json/add/date_time'` -* Exception: `require 'json/add/exception'` -* OpenStruct: `require 'json/add/ostruct'` -* Range: `require 'json/add/range'` -* Rational: `require 'json/add/rational'` -* Regexp: `require 'json/add/regexp'` -* Set: `require 'json/add/set'` -* Struct: `require 'json/add/struct'` -* Symbol: `require 'json/add/symbol'` -* Time: `require 'json/add/time'` - -To reduce punctuation clutter, the examples below show the generated JSON via -`puts`, rather than the usual `inspect`, - -BigDecimal: - require 'json/add/bigdecimal' - ruby0 = BigDecimal(0) # 0.0 - json = JSON.generate(ruby0) # {"json_class":"BigDecimal","b":"27:0.0"} - ruby1 = JSON.parse(json, create_additions: true) # 0.0 - ruby1.class # => BigDecimal - -Complex: - require 'json/add/complex' - ruby0 = Complex(1+0i) # 1+0i - json = JSON.generate(ruby0) # {"json_class":"Complex","r":1,"i":0} - ruby1 = JSON.parse(json, create_additions: true) # 1+0i - ruby1.class # Complex - -Date: - require 'json/add/date' - ruby0 = Date.today # 2020-05-02 - json = JSON.generate(ruby0) # {"json_class":"Date","y":2020,"m":5,"d":2,"sg":2299161.0} - ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02 - ruby1.class # Date - -DateTime: - require 'json/add/date_time' - ruby0 = DateTime.now # 2020-05-02T10:38:13-05:00 - json = JSON.generate(ruby0) # {"json_class":"DateTime","y":2020,"m":5,"d":2,"H":10,"M":38,"S":13,"of":"-5/24","sg":2299161.0} - ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02T10:38:13-05:00 - ruby1.class # DateTime - -Exception (and its subclasses including RuntimeError): - require 'json/add/exception' - ruby0 = Exception.new('A message') # A message - json = JSON.generate(ruby0) # {"json_class":"Exception","m":"A message","b":null} - ruby1 = JSON.parse(json, create_additions: true) # A message - ruby1.class # Exception - ruby0 = RuntimeError.new('Another message') # Another message - json = JSON.generate(ruby0) # {"json_class":"RuntimeError","m":"Another message","b":null} - ruby1 = JSON.parse(json, create_additions: true) # Another message - ruby1.class # RuntimeError - -OpenStruct: - require 'json/add/ostruct' - ruby0 = OpenStruct.new(name: 'Matz', language: 'Ruby') # # - json = JSON.generate(ruby0) # {"json_class":"OpenStruct","t":{"name":"Matz","language":"Ruby"}} - ruby1 = JSON.parse(json, create_additions: true) # # - ruby1.class # OpenStruct - -Range: - require 'json/add/range' - ruby0 = Range.new(0, 2) # 0..2 - json = JSON.generate(ruby0) # {"json_class":"Range","a":[0,2,false]} - ruby1 = JSON.parse(json, create_additions: true) # 0..2 - ruby1.class # Range - -Rational: - require 'json/add/rational' - ruby0 = Rational(1, 3) # 1/3 - json = JSON.generate(ruby0) # {"json_class":"Rational","n":1,"d":3} - ruby1 = JSON.parse(json, create_additions: true) # 1/3 - ruby1.class # Rational - -Regexp: - require 'json/add/regexp' - ruby0 = Regexp.new('foo') # (?-mix:foo) - json = JSON.generate(ruby0) # {"json_class":"Regexp","o":0,"s":"foo"} - ruby1 = JSON.parse(json, create_additions: true) # (?-mix:foo) - ruby1.class # Regexp - -Set: - require 'json/add/set' - ruby0 = Set.new([0, 1, 2]) # # - json = JSON.generate(ruby0) # {"json_class":"Set","a":[0,1,2]} - ruby1 = JSON.parse(json, create_additions: true) # # - ruby1.class # Set - -Struct: - require 'json/add/struct' - Customer = Struct.new(:name, :address) # Customer - ruby0 = Customer.new("Dave", "123 Main") # # - json = JSON.generate(ruby0) # {"json_class":"Customer","v":["Dave","123 Main"]} - ruby1 = JSON.parse(json, create_additions: true) # # - ruby1.class # Customer - -Symbol: - require 'json/add/symbol' - ruby0 = :foo # foo - json = JSON.generate(ruby0) # {"json_class":"Symbol","s":"foo"} - ruby1 = JSON.parse(json, create_additions: true) # foo - ruby1.class # Symbol - -Time: - require 'json/add/time' - ruby0 = Time.now # 2020-05-02 11:28:26 -0500 - json = JSON.generate(ruby0) # {"json_class":"Time","s":1588436906,"n":840560000} - ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02 11:28:26 -0500 - ruby1.class # Time - -### Custom JSON Additions - -In addition to the JSON additions provided, you can craft JSON additions of -your own, either for Ruby built-in classes or for user-defined classes. - -Here's a user-defined class `Foo`: - class Foo - attr_accessor :bar, :baz - def initialize(bar, baz) - self.bar = bar - self.baz = baz - end - end - -Here's the JSON addition for it: - # Extend class Foo with JSON addition. - class Foo - # Serialize Foo object with its class name and arguments - def to_json(*args) - { - JSON.create_id => self.class.name, - 'a' => [ bar, baz ] - }.to_json(*args) - end - # Deserialize JSON string by constructing new Foo object with arguments. - def self.json_create(object) - new(*object['a']) - end - end - -Demonstration: - require 'json' - # This Foo object has no custom addition. - foo0 = Foo.new(0, 1) - json0 = JSON.generate(foo0) - obj0 = JSON.parse(json0) - # Lood the custom addition. - require_relative 'foo_addition' - # This foo has the custom addition. - foo1 = Foo.new(0, 1) - json1 = JSON.generate(foo1) - obj1 = JSON.parse(json1, create_additions: true) - # Make a nice display. - display = <<~EOT - Generated JSON: - Without custom addition: #{json0} (#{json0.class}) - With custom addition: #{json1} (#{json1.class}) - Parsed JSON: - Without custom addition: #{obj0.inspect} (#{obj0.class}) - With custom addition: #{obj1.inspect} (#{obj1.class}) - EOT - puts display - -Output: - - Generated JSON: - Without custom addition: "#" (String) - With custom addition: {"json_class":"Foo","a":[0,1]} (String) - Parsed JSON: - Without custom addition: "#" (String) - With custom addition: # (Foo) - - -# Class Methods -## [](object , opts {}) [](#method-c-[]) -:call-seq: - JSON[object] -> new_array or new_string - -If `object` is a String, calls JSON.parse with `object` and `opts` (see method -#parse): - json = '[0, 1, null]' - JSON[json]# => [0, 1, nil] - -Otherwise, calls JSON.generate with `object` and `opts` (see method -#generate): - ruby = [0, 1, nil] - JSON[ruby] # => '[0,1,null]' -## create_fast_state() [](#method-c-create_fast_state) -## create_id() [](#method-c-create_id) -Returns the current create identifier. See also JSON.create_id=. -## create_id=(new_value ) [](#method-c-create_id=) -Sets create identifier, which is used to decide if the *json_create* hook of a -class should be called; initial value is `json_class`: - JSON.create_id # => 'json_class' -## create_pretty_state() [](#method-c-create_pretty_state) -## deep_const_get(path ) [](#method-c-deep_const_get) -Return the constant located at *path*. The format of *path* has to be either -::A::B::C or A::B::C. In any case, A has to be located at the top level -(absolute namespace path?). If there doesn't exist a constant at the given -path, an ArgumentError is raised. -## dump(obj , anIO nil, limit nil, kwargs nil) [](#method-c-dump) -:call-seq: - JSON.dump(obj, io = nil, limit = nil) - -Dumps `obj` as a JSON string, i.e. calls generate on the object and returns -the result. - -The default options can be changed via method JSON.dump_default_options. - -* Argument `io`, if given, should respond to method `write`; the JSON String - is written to `io`, and `io` is returned. If `io` is not given, the JSON - String is returned. -* Argument `limit`, if given, is passed to JSON.generate as option - `max_nesting`. - ---- - -When argument `io` is not given, returns the JSON String generated from `obj`: - obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad} - json = JSON.dump(obj) - json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}" - -When argument `io` is given, writes the JSON String to `io` and returns `io`: - path = 't.json' - File.open(path, 'w') do |file| - JSON.dump(obj, file) - end # => # - puts File.read(path) - -Output: - {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"} -## fast_generate(obj , opts nil) [](#method-c-fast_generate) -:call-seq: - JSON.fast_generate(obj, opts) -> new_string - -Arguments `obj` and `opts` here are the same as arguments `obj` and `opts` in -JSON.generate. - -By default, generates JSON data without checking for circular references in -`obj` (option `max_nesting` set to `false`, disabled). - -Raises an exception if `obj` contains circular references: - a = []; b = []; a.push(b); b.push(a) - # Raises SystemStackError (stack level too deep): - JSON.fast_generate(a) -## generate(obj , opts nil) [](#method-c-generate) -:call-seq: - JSON.generate(obj, opts = nil) -> new_string - -Returns a String containing the generated JSON data. - -See also JSON.fast_generate, JSON.pretty_generate. - -Argument `obj` is the Ruby object to be converted to JSON. - -Argument `opts`, if given, contains a Hash of options for the generation. See -[Generating Options](#module-JSON-label-Generating+Options). - ---- - -When `obj` is an Array, returns a String containing a JSON array: - obj = ["foo", 1.0, true, false, nil] - json = JSON.generate(obj) - json # => '["foo",1.0,true,false,null]' - -When `obj` is a Hash, returns a String containing a JSON object: - obj = {foo: 0, bar: 's', baz: :bat} - json = JSON.generate(obj) - json # => '{"foo":0,"bar":"s","baz":"bat"}' - -For examples of generating from other Ruby objects, see [Generating \JSON from -Other Objects](#module-JSON-label-Generating+JSON+from+Other+Objects). - ---- - -Raises an exception if any formatting option is not a String. - -Raises an exception if `obj` contains circular references: - a = []; b = []; a.push(b); b.push(a) - # Raises JSON::NestingError (nesting of 100 is too deep): - JSON.generate(a) -## iconv(to , from , string ) [](#method-c-iconv) -Encodes string using String.encode. -## load(source , proc nil, options nil) [](#method-c-load) -:call-seq: - JSON.load(source, proc = nil, options = {}) -> object - -Returns the Ruby objects created by parsing the given `source`. - -BEWARE: This method is meant to serialise data from trusted user input, like -from your own database server or clients under your control, it could be -dangerous to allow untrusted users to pass JSON sources into it. If you must -use it, use JSON.unsafe_load instead to make it clear. - -Since JSON version 2.8.0, `load` emits a deprecation warning when a non native -type is deserialized, without `create_additions` being explicitly enabled, and -in JSON version 3.0, `load` will have `create_additions` disabled by default. - -* Argument `source` must be, or be convertible to, a String: - * If `source` responds to instance method `to_str`, `source.to_str` - becomes the source. - * If `source` responds to instance method `to_io`, `source.to_io.read` - becomes the source. - * If `source` responds to instance method `read`, `source.read` becomes - the source. - * If both of the following are true, source becomes the String `'null'`: - * Option `allow_blank` specifies a truthy value. - * The source, as defined above, is `nil` or the empty String `''`. - * Otherwise, `source` remains the source. -* Argument `proc`, if given, must be a Proc that accepts one argument. It - will be called recursively with each result (depth-first order). See - details below. -* Argument `opts`, if given, contains a Hash of options for the parsing. See - [Parsing Options](#module-JSON-label-Parsing+Options). The default options - can be changed via method JSON.load_default_options=. - ---- - -When no `proc` is given, modifies `source` as above and returns the result of -`parse(source, opts)`; see #parse. - -Source for following examples: - source = <<~JSON - { - "name": "Dave", - "age" :40, - "hats": [ - "Cattleman's", - "Panama", - "Tophat" - ] - } - JSON - -Load a String: - ruby = JSON.load(source) - ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} - -Load an IO object: - require 'stringio' - object = JSON.load(StringIO.new(source)) - object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} - -Load a File object: - path = 't.json' - File.write(path, source) - File.open(path) do |file| - JSON.load(file) - end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} - ---- - -When `proc` is given: -* Modifies `source` as above. -* Gets the `result` from calling `parse(source, opts)`. -* Recursively calls `proc(result)`. -* Returns the final result. - -Example: - require 'json' - - # Some classes for the example. - class Base - def initialize(attributes) - @attributes = attributes - end - end - class User < Base; end - class Account < Base; end - class Admin < Base; end - # The JSON source. - json = <<-EOF - { - "users": [ - {"type": "User", "username": "jane", "email": "jane@example.com"}, - {"type": "User", "username": "john", "email": "john@example.com"} - ], - "accounts": [ - {"account": {"type": "Account", "paid": true, "account_id": "1234"}}, - {"account": {"type": "Account", "paid": false, "account_id": "1235"}} - ], - "admins": {"type": "Admin", "password": "0wn3d"} - } - EOF - # Deserializer method. - def deserialize_obj(obj, safe_types = %w(User Account Admin)) - type = obj.is_a?(Hash) && obj["type"] - safe_types.include?(type) ? Object.const_get(type).new(obj) : obj - end - # Call to JSON.load - ruby = JSON.load(json, proc {|obj| - case obj - when Hash - obj.each {|k, v| obj[k] = deserialize_obj v } - when Array - obj.map! {|v| deserialize_obj v } - end - }) - pp ruby - -Output: - {"users"=> - [#"User", "username"=>"jane", "email"=>"jane@example.com"}>, - #"User", "username"=>"john", "email"=>"john@example.com"}>], - "accounts"=> - [{"account"=> - #"Account", "paid"=>true, "account_id"=>"1234"}>}, - {"account"=> - #"Account", "paid"=>false, "account_id"=>"1235"}>}], - "admins"=> - #"Admin", "password"=>"0wn3d"}>} -## load_file(filespec , opts nil) [](#method-c-load_file) -:call-seq: - JSON.load_file(path, opts={}) -> object - -Calls: - parse(File.read(path), opts) - -See method #parse. -## load_file!(filespec , opts {}) [](#method-c-load_file!) -:call-seq: - JSON.load_file!(path, opts = {}) - -Calls: - JSON.parse!(File.read(path, opts)) - -See method #parse! -## merge_dump_options(opts , strict: NOT_SET) [](#method-c-merge_dump_options) -## parse(source , opts nil) [](#method-c-parse) -:call-seq: - JSON.parse(source, opts) -> object - -Returns the Ruby objects created by parsing the given `source`. - -Argument `source` contains the String to be parsed. - -Argument `opts`, if given, contains a Hash of options for the parsing. See -[Parsing Options](#module-JSON-label-Parsing+Options). - ---- - -When `source` is a JSON array, returns a Ruby Array: - source = '["foo", 1.0, true, false, null]' - ruby = JSON.parse(source) - ruby # => ["foo", 1.0, true, false, nil] - ruby.class # => Array - -When `source` is a JSON object, returns a Ruby Hash: - source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}' - ruby = JSON.parse(source) - ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil} - ruby.class # => Hash - -For examples of parsing for all JSON data types, see [Parsing -\JSON](#module-JSON-label-Parsing+JSON). - -Parses nested JSON objects: - source = <<~JSON - { - "name": "Dave", - "age" :40, - "hats": [ - "Cattleman's", - "Panama", - "Tophat" - ] - } - JSON - ruby = JSON.parse(source) - ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} - ---- - -Raises an exception if `source` is not valid JSON: - # Raises JSON::ParserError (783: unexpected token at ''): - JSON.parse('') -## parse!(source , opts {}) [](#method-c-parse!) -:call-seq: - JSON.parse!(source, opts) -> object - -Calls - parse(source, opts) - -with `source` and possibly modified `opts`. - -Differences from JSON.parse: -* Option `max_nesting`, if not provided, defaults to `false`, which disables - checking for nesting depth. -* Option `allow_nan`, if not provided, defaults to `true`. -## pretty_generate(obj , opts nil) [](#method-c-pretty_generate) -:call-seq: - JSON.pretty_generate(obj, opts = nil) -> new_string - -Arguments `obj` and `opts` here are the same as arguments `obj` and `opts` in -JSON.generate. - -Default options are: - { - indent: ' ', # Two spaces - space: ' ', # One space - array_nl: "\n", # Newline - object_nl: "\n" # Newline - } - -Example: - obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}} - json = JSON.pretty_generate(obj) - puts json - -Output: - { - "foo": [ - "bar", - "baz" - ], - "bat": { - "bam": 0, - "bad": 1 - } - } -## recurse_proc(result , &proc ) [](#method-c-recurse_proc) -Recursively calls passed *Proc* if the parsed data structure is an *Array* or -*Hash* -## unsafe_load(source , proc nil, options nil) [](#method-c-unsafe_load) -:call-seq: - JSON.unsafe_load(source, proc = nil, options = {}) -> object - -Returns the Ruby objects created by parsing the given `source`. - -BEWARE: This method is meant to serialise data from trusted user input, like -from your own database server or clients under your control, it could be -dangerous to allow untrusted users to pass JSON sources into it. - -* Argument `source` must be, or be convertible to, a String: - * If `source` responds to instance method `to_str`, `source.to_str` - becomes the source. - * If `source` responds to instance method `to_io`, `source.to_io.read` - becomes the source. - * If `source` responds to instance method `read`, `source.read` becomes - the source. - * If both of the following are true, source becomes the String `'null'`: - * Option `allow_blank` specifies a truthy value. - * The source, as defined above, is `nil` or the empty String `''`. - * Otherwise, `source` remains the source. -* Argument `proc`, if given, must be a Proc that accepts one argument. It - will be called recursively with each result (depth-first order). See - details below. -* Argument `opts`, if given, contains a Hash of options for the parsing. See - [Parsing Options](#module-JSON-label-Parsing+Options). The default options - can be changed via method JSON.unsafe_load_default_options=. - ---- - -When no `proc` is given, modifies `source` as above and returns the result of -`parse(source, opts)`; see #parse. - -Source for following examples: - source = <<~JSON - { - "name": "Dave", - "age" :40, - "hats": [ - "Cattleman's", - "Panama", - "Tophat" - ] - } - JSON - -Load a String: - ruby = JSON.unsafe_load(source) - ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} - -Load an IO object: - require 'stringio' - object = JSON.unsafe_load(StringIO.new(source)) - object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} - -Load a File object: - path = 't.json' - File.write(path, source) - File.open(path) do |file| - JSON.unsafe_load(file) - end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} - ---- - -When `proc` is given: -* Modifies `source` as above. -* Gets the `result` from calling `parse(source, opts)`. -* Recursively calls `proc(result)`. -* Returns the final result. - -Example: - require 'json' - - # Some classes for the example. - class Base - def initialize(attributes) - @attributes = attributes - end - end - class User < Base; end - class Account < Base; end - class Admin < Base; end - # The JSON source. - json = <<-EOF - { - "users": [ - {"type": "User", "username": "jane", "email": "jane@example.com"}, - {"type": "User", "username": "john", "email": "john@example.com"} - ], - "accounts": [ - {"account": {"type": "Account", "paid": true, "account_id": "1234"}}, - {"account": {"type": "Account", "paid": false, "account_id": "1235"}} - ], - "admins": {"type": "Admin", "password": "0wn3d"} - } - EOF - # Deserializer method. - def deserialize_obj(obj, safe_types = %w(User Account Admin)) - type = obj.is_a?(Hash) && obj["type"] - safe_types.include?(type) ? Object.const_get(type).new(obj) : obj - end - # Call to JSON.unsafe_load - ruby = JSON.unsafe_load(json, proc {|obj| - case obj - when Hash - obj.each {|k, v| obj[k] = deserialize_obj v } - when Array - obj.map! {|v| deserialize_obj v } - end - }) - pp ruby - -Output: - {"users"=> - [#"User", "username"=>"jane", "email"=>"jane@example.com"}>, - #"User", "username"=>"john", "email"=>"john@example.com"}>], - "accounts"=> - [{"account"=> - #"Account", "paid"=>true, "account_id"=>"1234"}>}, - {"account"=> - #"Account", "paid"=>false, "account_id"=>"1235"}>}], - "admins"=> - #"Admin", "password"=>"0wn3d"}>} -# Attributes -## dump_default_options[RW] [](#attribute-c-dump_default_options) -Sets or returns the default options for the JSON.dump method. Initially: - opts = JSON.dump_default_options - opts # => {:max_nesting=>false, :allow_nan=>true} - -## generator[RW] [](#attribute-c-generator) -Returns the JSON generator module that is used by JSON. - -## load_default_options[RW] [](#attribute-c-load_default_options) -Sets or returns default options for the JSON.load method. Initially: - opts = JSON.load_default_options - opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true} - -## parser[RW] [](#attribute-c-parser) -Returns the JSON parser class that is used by JSON. - -## state[RW] [](#attribute-c-state) -Sets or Returns the JSON generator state class that is used by JSON. - -## unsafe_load_default_options[RW] [](#attribute-c-unsafe_load_default_options) -Sets or returns default options for the JSON.unsafe_load method. Initially: - opts = JSON.load_default_options - opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true} - - diff --git a/example/ruby/JSON/CircularDatastructure.md b/example/ruby/JSON/CircularDatastructure.md deleted file mode 100644 index 84f0c60..0000000 --- a/example/ruby/JSON/CircularDatastructure.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: JSON::CircularDatastructure -**Inherits:** JSON::NestingError - - -:stopdoc: - - - diff --git a/example/ruby/JSON/Ext.md b/example/ruby/JSON/Ext.md deleted file mode 100644 index c89a98c..0000000 --- a/example/ruby/JSON/Ext.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: JSON::Ext - - -This module holds all the modules/classes that implement JSON's functionality -as C extensions. - - - diff --git a/example/ruby/JSON/Ext/Generator.md b/example/ruby/JSON/Ext/Generator.md deleted file mode 100644 index ed86f60..0000000 --- a/example/ruby/JSON/Ext/Generator.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: JSON::Ext::Generator - - -This is the JSON generator implemented as a C extension. It can be configured -to be used by setting - - JSON.generator = JSON::Ext::Generator - -with the method generator= in JSON. - - - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods.md deleted file mode 100644 index 27f2314..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods - - -:nodoc: - - - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Array.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/Array.md deleted file mode 100644 index 09ded0f..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Array.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::Array - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string containing a JSON array, that is generated from this -Array instance. *state* is a JSON::State object, that can also be used to -configure the produced JSON string output further. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Bignum.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/Bignum.md deleted file mode 100644 index f69235b..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Bignum.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::Bignum - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representation for this Integer number. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/FalseClass.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/FalseClass.md deleted file mode 100644 index 602caa7..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/FalseClass.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::FalseClass - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string for false: 'false'. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Fixnum.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/Fixnum.md deleted file mode 100644 index 14e34ce..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Fixnum.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::Fixnum - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representation for this Integer number. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Float.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/Float.md deleted file mode 100644 index 2da121e..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Float.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::Float - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representation for this Float number. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Hash.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/Hash.md deleted file mode 100644 index beee128..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Hash.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::Hash - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string containing a JSON object, that is generated from this -Hash instance. *state* is a JSON::State object, that can also be used to -configure the produced JSON string output further. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Integer.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/Integer.md deleted file mode 100644 index c2fd259..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Integer.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::Integer - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representation for this Integer number. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/NilClass.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/NilClass.md deleted file mode 100644 index 66e119c..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/NilClass.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::NilClass - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string for nil: 'null'. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Object.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/Object.md deleted file mode 100644 index 8052043..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/Object.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::Object - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Converts this object to a string (calling #to_s), converts it to a JSON -string, and returns the result. This is a fallback, if no special method -#to_json was defined for some object. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/String.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/String.md deleted file mode 100644 index 961a873..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/String.md +++ /dev/null @@ -1,33 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::String - - -:nodoc: - - -# Class Methods -## included(modul ) [](#method-c-included) -Extends *modul* with the String::Extend module. -**@overload** [] - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -This string should be encoded with UTF-8 A call to this method returns a JSON -string encoded with UTF16 big endian characters as u????. - -**@overload** [] - -## to_json_raw(*args) [](#method-i-to_json_raw) -This method creates a JSON text from the result of a call to -to_json_raw_object of this String. - -**@overload** [] - -## to_json_raw_object() [](#method-i-to_json_raw_object) -This method creates a raw object hash, that can be nested into other data -structures and will be generated as a raw string. This method should be used, -if you want to convert raw strings to JSON instead of UTF-8 strings, e. g. -binary data. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/String/Extend.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/String/Extend.md deleted file mode 100644 index fcaa2c5..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/String/Extend.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::String::Extend - - -:nodoc: - - - -#Instance Methods -## json_create(o) [](#method-i-json_create) -Raw Strings are JSON Objects (the raw bytes are stored in an array for the key -"raw"). The Ruby String can be created by this module method. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/GeneratorMethods/TrueClass.md b/example/ruby/JSON/Ext/Generator/GeneratorMethods/TrueClass.md deleted file mode 100644 index e565071..0000000 --- a/example/ruby/JSON/Ext/Generator/GeneratorMethods/TrueClass.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: JSON::Ext::Generator::GeneratorMethods::TrueClass - - -:nodoc: - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) -Returns a JSON string for true: 'true'. - -**@overload** [] - diff --git a/example/ruby/JSON/Ext/Generator/State.md b/example/ruby/JSON/Ext/Generator/State.md deleted file mode 100644 index 009d578..0000000 --- a/example/ruby/JSON/Ext/Generator/State.md +++ /dev/null @@ -1,242 +0,0 @@ -# Class: JSON::Ext::Generator::State -**Inherits:** Object - - - - -# Class Methods -## from_state(opts ) [](#method-c-from_state) -Creates a State object from *opts*, which ought to be Hash to create a new -State instance configured by *opts*, something else to create an unconfigured -instance. If *opts* is a State object, it is just returned. -**@overload** [] - -## generate(obj , opts , io ) [](#method-c-generate) - -#Instance Methods -## [](name) [](#method-i-[]) -call-seq: [](name) - -Returns the value returned by method `name`. - -## []=(name, value) [](#method-i-[]=) -call-seq: []=(name, value) - -Sets the attribute name to value. - -## allow_nan=(enable) [](#method-i-allow_nan=) -This sets whether or not to serialize NaN, Infinity, and -Infinity - -**@overload** [] - -## allow_nan?() [](#method-i-allow_nan?) -Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise -returns false. - -**@overload** [] - -**@return** [Boolean] - -## array_nl() [](#method-i-array_nl) -This string is put at the end of a line that holds a JSON array. - -**@overload** [] - -## array_nl=(array_nl) [](#method-i-array_nl=) -This string is put at the end of a line that holds a JSON array. - -**@overload** [] - -## ascii_only=(enable) [](#method-i-ascii_only=) -This sets whether only ASCII characters should be generated. - -**@overload** [] - -## ascii_only?() [](#method-i-ascii_only?) -Returns true, if only ASCII characters should be generated. Otherwise returns -false. - -**@overload** [] - -**@return** [Boolean] - -## buffer_initial_length() [](#method-i-buffer_initial_length) -This integer returns the current initial length of the buffer. - -**@overload** [] - -## buffer_initial_length=(buffer_initial_length) [](#method-i-buffer_initial_length=) -This sets the initial length of the buffer to `length`, if `length` > 0, -otherwise its value isn't changed. - -**@overload** [] - -## check_circular?() [](#method-i-check_circular?) -Returns true, if circular data structures should be checked, otherwise returns -false. - -**@overload** [] - -**@return** [Boolean] - -## configure(opts) [](#method-i-configure) -call-seq: configure(opts) - -Configure this State instance with the Hash *opts*, and return itself. - -## depth() [](#method-i-depth) -This integer returns the current depth of data structure nesting. - -**@overload** [] - -## depth=(depth) [](#method-i-depth=) -This sets the maximum level of data structure nesting in the generated JSON to -the integer depth, max_nesting = 0 if no maximum should be checked. - -**@overload** [] - -## generate(obj, ionil) [](#method-i-generate) -call-seq: - generate(obj) -> String - generate(obj, anIO) -> anIO - -Generates a valid JSON document from object `obj` and returns the result. If -no valid JSON document can be created this method raises a GeneratorError -exception. - -## indent() [](#method-i-indent) -Returns the string that is used to indent levels in the JSON text. - -**@overload** [] - -## indent=(indent) [](#method-i-indent=) -Sets the string that is used to indent levels in the JSON text. - -**@overload** [] - -## initialize(optsnil) [](#method-i-initialize) -call-seq: new(opts = {}) - -Instantiates a new State object, configured by *opts*. - -*opts* can have the following keys: - -* **indent**: a string used to indent levels (default: ''), -* **space**: a string that is put after, a : or , delimiter (default: ''), -* **space_before**: a string that is put before a : pair delimiter (default: - ''), -* **object_nl**: a string that is put at the end of a JSON object (default: - ''), -* **array_nl**: a string that is put at the end of a JSON array (default: - ''), -* **allow_nan**: true if NaN, Infinity, and -Infinity should be generated, - otherwise an exception is thrown, if these values are encountered. This - options defaults to false. -* **ascii_only**: true if only ASCII characters should be generated. This - option defaults to false. -* **buffer_initial_length**: sets the initial length of the generator's - internal buffer. - -**@return** [State] a new instance of State - -## initialize_copy(orig) [](#method-i-initialize_copy) -Initializes this object from orig if it can be duplicated/cloned and returns -it. - -**@overload** [] - -## max_nesting() [](#method-i-max_nesting) -This integer returns the maximum level of data structure nesting in the -generated JSON, max_nesting = 0 if no maximum is checked. - -**@overload** [] - -## max_nesting=(depth) [](#method-i-max_nesting=) -This sets the maximum level of data structure nesting in the generated JSON to -the integer depth, max_nesting = 0 if no maximum should be checked. - -**@overload** [] - -## object_nl() [](#method-i-object_nl) -This string is put at the end of a line that holds a JSON object (or Hash). - -**@overload** [] - -## object_nl=(object_nl) [](#method-i-object_nl=) -This string is put at the end of a line that holds a JSON object (or Hash). - -**@overload** [] - -## script_safe() [](#method-i-script_safe) -If this boolean is true, the forward slashes will be escaped in the json -output. - -**@overload** [] - -## script_safe=(enable) [](#method-i-script_safe=) -This sets whether or not the forward slashes will be escaped in the json -output. - -**@overload** [] - -## script_safe?() [](#method-i-script_safe?) -If this boolean is true, the forward slashes will be escaped in the json -output. - -**@overload** [] - -**@return** [Boolean] - -## space() [](#method-i-space) -Returns the string that is used to insert a space between the tokens in a JSON -string. - -**@overload** [] - -## space=(space) [](#method-i-space=) -Sets *space* to the string that is used to insert a space between the tokens -in a JSON string. - -**@overload** [] - -## space_before() [](#method-i-space_before) -Returns the string that is used to insert a space before the ':' in JSON -objects. - -**@overload** [] - -## space_before=(space_before) [](#method-i-space_before=) -Sets the string that is used to insert a space before the ':' in JSON objects. - -**@overload** [] - -## strict() [](#method-i-strict) -If this boolean is false, types unsupported by the JSON format will be -serialized as strings. If this boolean is true, types unsupported by the JSON -format will raise a JSON::GeneratorError. - -**@overload** [] - -## strict=(enable) [](#method-i-strict=) -This sets whether or not to serialize types unsupported by the JSON format as -strings. If this boolean is false, types unsupported by the JSON format will -be serialized as strings. If this boolean is true, types unsupported by the -JSON format will raise a JSON::GeneratorError. - -**@overload** [] - -## strict?() [](#method-i-strict?) -If this boolean is false, types unsupported by the JSON format will be -serialized as strings. If this boolean is true, types unsupported by the JSON -format will raise a JSON::GeneratorError. - -**@overload** [] - -**@return** [Boolean] - -## to_h() [](#method-i-to_h) -call-seq: to_h - -Returns the configuration instance variables as a hash, that can be passed to -the configure method. - diff --git a/example/ruby/JSON/Ext/Parser.md b/example/ruby/JSON/Ext/Parser.md deleted file mode 100644 index dd9a61e..0000000 --- a/example/ruby/JSON/Ext/Parser.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: JSON::Ext::Parser -**Inherits:** Object - - -This is the JSON parser implemented as a C extension. It can be configured to -be used by setting - - JSON.parser = JSON::Ext::Parser - -with the method parser= in JSON. - - -# Class Methods -## parse(source , opts ) [](#method-c-parse) - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Creates a new JSON::Ext::Parser instance for the string *source*. - -It will be configured by the *opts* hash. *opts* can have the following keys: - -*opts* can have the following keys: -* **max_nesting**: The maximum depth of nesting allowed in the parsed data - structures. Disable depth checking with :max_nesting => false|nil|0, it - defaults to 100. -* **allow_nan**: If set to true, allow NaN, Infinity and -Infinity in - defiance of RFC 4627 to be parsed by the Parser. This option defaults to - false. -* **symbolize_names**: If set to true, returns symbols for the names (keys) - in a JSON object. Otherwise strings are returned, which is also the - default. It's not possible to use this option in conjunction with the - **create_additions** option. -* **create_additions**: If set to false, the Parser doesn't create additions - even if a matching class and create_id was found. This option defaults to - false. -* **object_class**: Defaults to Hash. If another type is provided, it will - be used instead of Hash to represent JSON objects. The type must respond - to `new` without arguments, and return an object that respond to `[]=`. -* **array_class**: Defaults to Array If another type is provided, it will be - used instead of Hash to represent JSON arrays. The type must respond to - `new` without arguments, and return an object that respond to +<<+. -* **decimal_class**: Specifies which class to use instead of the default - (Float) when parsing decimal numbers. This class must accept a single - string argument in its constructor. - -**@overload** [] - -## parse() [](#method-i-parse) -Parses the current JSON text *source* and returns the complete data - structure as a result. - It raises JSON::ParserError if fail to parse. - -**@overload** [] - -## source() [](#method-i-source) -Returns a copy of the current *source* string, that was used to construct this -Parser. - -**@overload** [] - diff --git a/example/ruby/JSON/GeneratorError.md b/example/ruby/JSON/GeneratorError.md deleted file mode 100644 index 0d85b07..0000000 --- a/example/ruby/JSON/GeneratorError.md +++ /dev/null @@ -1,19 +0,0 @@ -# Exception: JSON::GeneratorError -**Inherits:** JSON::JSONError - - -This exception is raised if a generator or unparser error occurs. - - -# Attributes -## invalid_object[RW] [](#attribute-i-invalid_object) -Returns the value of attribute invalid_object. - - -#Instance Methods -## detailed_message() [](#method-i-detailed_message) - -## initialize(message, invalid_objectnil) [](#method-i-initialize) - -**@return** [GeneratorError] a new instance of GeneratorError - diff --git a/example/ruby/JSON/GenericObject.md b/example/ruby/JSON/GenericObject.md deleted file mode 100644 index b5d973a..0000000 --- a/example/ruby/JSON/GenericObject.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: JSON::GenericObject -**Inherits:** OpenStruct - - - - -# Class Methods -## dump(obj , *args ) [](#method-c-dump) -## from_hash(object ) [](#method-c-from_hash) -## json_creatable?() [](#method-c-json_creatable?) -**@return** [Boolean] - -## json_create(data ) [](#method-c-json_create) -## load(source , proc nil, opts {}) [](#method-c-load) -# Attributes -## json_creatable=[R] [](#attribute-c-json_creatable=) -Sets the attribute json_creatable - -**@param** [] the value to set the attribute json_creatable to. - - -#Instance Methods -## [](name) [](#method-i-[]) - -## []=(name, value) [](#method-i-[]=) - -## as_json() [](#method-i-as_json) - -## to_hash() [](#method-i-to_hash) - -## to_json(*a) [](#method-i-to_json) - -## |(other) [](#method-i-|) - diff --git a/example/ruby/JSON/JSONError.md b/example/ruby/JSON/JSONError.md deleted file mode 100644 index 2d6700b..0000000 --- a/example/ruby/JSON/JSONError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: JSON::JSONError -**Inherits:** StandardError - - -The base exception for JSON errors. - - -# Class Methods -## wrap(exception ) [](#method-c-wrap) - diff --git a/example/ruby/JSON/MissingUnicodeSupport.md b/example/ruby/JSON/MissingUnicodeSupport.md deleted file mode 100644 index 514e5ea..0000000 --- a/example/ruby/JSON/MissingUnicodeSupport.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: JSON::MissingUnicodeSupport -**Inherits:** JSON::JSONError - - -This exception is raised if the required unicode support is missing on the -system. Usually this means that the iconv library is not installed. - - - diff --git a/example/ruby/JSON/NestingError.md b/example/ruby/JSON/NestingError.md deleted file mode 100644 index 3a31d09..0000000 --- a/example/ruby/JSON/NestingError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: JSON::NestingError -**Inherits:** JSON::ParserError - - -This exception is raised if the nesting of parsed data structures is too deep. - - - diff --git a/example/ruby/JSON/ParserError.md b/example/ruby/JSON/ParserError.md deleted file mode 100644 index 09d37b6..0000000 --- a/example/ruby/JSON/ParserError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: JSON::ParserError -**Inherits:** JSON::JSONError - - -This exception is raised if a parser error occurs. - - - diff --git a/example/ruby/JSONAdditionTest.md b/example/ruby/JSONAdditionTest.md deleted file mode 100644 index d6e7024..0000000 --- a/example/ruby/JSONAdditionTest.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: JSONAdditionTest -**Inherits:** Test::Unit::TestCase - -**Includes:** JSON - - - - - -#Instance Methods -## test_bigdecimal() [](#method-i-test_bigdecimal) - -## test_core() [](#method-i-test_core) - -## test_deprecated_load_create_additions() [](#method-i-test_deprecated_load_create_additions) - -## test_extended_json() [](#method-i-test_extended_json) - -## test_extended_json_default() [](#method-i-test_extended_json_default) - -## test_extended_json_disabled() [](#method-i-test_extended_json_disabled) - -## test_extended_json_fail1() [](#method-i-test_extended_json_fail1) - -## test_extended_json_fail2() [](#method-i-test_extended_json_fail2) - -## test_ostruct() [](#method-i-test_ostruct) - -## test_rational_complex() [](#method-i-test_rational_complex) - -## test_raw_strings() [](#method-i-test_raw_strings) - -## test_set() [](#method-i-test_set) - -## test_utc_datetime() [](#method-i-test_utc_datetime) - diff --git a/example/ruby/JSONAdditionTest/A.md b/example/ruby/JSONAdditionTest/A.md deleted file mode 100644 index 3eb6cc7..0000000 --- a/example/ruby/JSONAdditionTest/A.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: JSONAdditionTest::A -**Inherits:** Object - - - - -# Class Methods -## json_create(object ) [](#method-c-json_create) -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(a) [](#method-i-initialize) - -**@return** [A] a new instance of A - -## to_json(*args) [](#method-i-to_json) - diff --git a/example/ruby/JSONAdditionTest/A2.md b/example/ruby/JSONAdditionTest/A2.md deleted file mode 100644 index 248f58f..0000000 --- a/example/ruby/JSONAdditionTest/A2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: JSONAdditionTest::A2 -**Inherits:** JSONAdditionTest::A - - - - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) - diff --git a/example/ruby/JSONAdditionTest/B.md b/example/ruby/JSONAdditionTest/B.md deleted file mode 100644 index 6c30c28..0000000 --- a/example/ruby/JSONAdditionTest/B.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: JSONAdditionTest::B -**Inherits:** Object - - - - -# Class Methods -## json_creatable?() [](#method-c-json_creatable?) -**@return** [Boolean] - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) - diff --git a/example/ruby/JSONAdditionTest/C.md b/example/ruby/JSONAdditionTest/C.md deleted file mode 100644 index 5528470..0000000 --- a/example/ruby/JSONAdditionTest/C.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: JSONAdditionTest::C -**Inherits:** Object - - - - -# Class Methods -## json_creatable?() [](#method-c-json_creatable?) -**@return** [Boolean] - - -#Instance Methods -## to_json(*args) [](#method-i-to_json) - diff --git a/example/ruby/JSONAdditionTest/MyJsonStruct.md b/example/ruby/JSONAdditionTest/MyJsonStruct.md deleted file mode 100644 index e53d4bb..0000000 --- a/example/ruby/JSONAdditionTest/MyJsonStruct.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: JSONAdditionTest::MyJsonStruct -**Inherits:** Struct - - - - -# Attributes -## bar[RW] [](#attribute-i-bar) -Returns the value of attribute bar - -**@return** [Object] the current value of bar - -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo - -**@return** [Object] the current value of foo - - diff --git a/example/ruby/JSONCommonInterfaceTest.md b/example/ruby/JSONCommonInterfaceTest.md deleted file mode 100644 index 9a91964..0000000 --- a/example/ruby/JSONCommonInterfaceTest.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: JSONCommonInterfaceTest -**Inherits:** Test::Unit::TestCase - -**Includes:** JSON - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_JSON() [](#method-i-test_JSON) - -## test_create_id() [](#method-i-test_create_id) - -## test_deep_const_get() [](#method-i-test_deep_const_get) - -## test_dump() [](#method-i-test_dump) - -## test_dump_in_io() [](#method-i-test_dump_in_io) - -## test_dump_should_modify_defaults() [](#method-i-test_dump_should_modify_defaults) - -## test_fast_generate() [](#method-i-test_fast_generate) - -## test_generate() [](#method-i-test_generate) - -## test_generator() [](#method-i-test_generator) - -## test_index() [](#method-i-test_index) - -## test_load() [](#method-i-test_load) - -## test_load_file() [](#method-i-test_load_file) - -## test_load_file!() [](#method-i-test_load_file!) - -## test_load_file_with_bad_default_external_encoding() [](#method-i-test_load_file_with_bad_default_external_encoding) - -## test_load_file_with_option() [](#method-i-test_load_file_with_option) - -## test_load_file_with_option!() [](#method-i-test_load_file_with_option!) - -## test_load_null() [](#method-i-test_load_null) - -## test_load_with_options() [](#method-i-test_load_with_options) - -## test_load_with_proc() [](#method-i-test_load_with_proc) - -## test_parse() [](#method-i-test_parse) - -## test_parse_bang() [](#method-i-test_parse_bang) - -## test_parser() [](#method-i-test_parser) - -## test_pretty_generate() [](#method-i-test_pretty_generate) - -## test_state() [](#method-i-test_state) - diff --git a/example/ruby/JSONCommonInterfaceTest/MethodMissing.md b/example/ruby/JSONCommonInterfaceTest/MethodMissing.md deleted file mode 100644 index 023b437..0000000 --- a/example/ruby/JSONCommonInterfaceTest/MethodMissing.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: JSONCommonInterfaceTest::MethodMissing - - - - - -#Instance Methods -## method_missing(name, *args) [](#method-i-method_missing) - -## respond_to_missing?(name, include_private) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - diff --git a/example/ruby/JSONEncodingTest.md b/example/ruby/JSONEncodingTest.md deleted file mode 100644 index 72e5365..0000000 --- a/example/ruby/JSONEncodingTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: JSONEncodingTest -**Inherits:** Test::Unit::TestCase - -**Includes:** JSON - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_chars() [](#method-i-test_chars) - -## test_generate() [](#method-i-test_generate) - -## test_parse() [](#method-i-test_parse) - -## test_unicode() [](#method-i-test_unicode) - diff --git a/example/ruby/JSONExtParserTest.md b/example/ruby/JSONExtParserTest.md deleted file mode 100644 index 3e6d77b..0000000 --- a/example/ruby/JSONExtParserTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: JSONExtParserTest -**Inherits:** Test::Unit::TestCase - -**Includes:** JSON - - - - - -#Instance Methods -## parse(json) [](#method-i-parse) - -## test_allocate() [](#method-i-test_allocate) - -## test_error_messages() [](#method-i-test_error_messages) - -## test_gc_stress() [](#method-i-test_gc_stress) - -## test_gc_stress_parser_new() [](#method-i-test_gc_stress_parser_new) - diff --git a/example/ruby/JSONFixturesTest.md b/example/ruby/JSONFixturesTest.md deleted file mode 100644 index e5d379a..0000000 --- a/example/ruby/JSONFixturesTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: JSONFixturesTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_failing() [](#method-i-test_failing) - -## test_passing() [](#method-i-test_passing) - -## test_sanity() [](#method-i-test_sanity) - diff --git a/example/ruby/JSONGeneratorTest.md b/example/ruby/JSONGeneratorTest.md deleted file mode 100644 index 147074d..0000000 --- a/example/ruby/JSONGeneratorTest.md +++ /dev/null @@ -1,94 +0,0 @@ -# Class: JSONGeneratorTest -**Inherits:** Test::Unit::TestCase - -**Includes:** JSON - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## silence() [](#method-i-silence) - -## test_allow_nan() [](#method-i-test_allow_nan) - -## test_array_subclass_with_to_json() [](#method-i-test_array_subclass_with_to_json) - -## test_array_subclass_with_to_s() [](#method-i-test_array_subclass_with_to_s) - -## test_backslash() [](#method-i-test_backslash) - -## test_broken_bignum() [](#method-i-test_broken_bignum) -ruby-core:38867 -: - -## test_buffer_initial_length() [](#method-i-test_buffer_initial_length) - -## test_configure_hash_conversion() [](#method-i-test_configure_hash_conversion) - -## test_configure_using_configure_and_merge() [](#method-i-test_configure_using_configure_and_merge) - -## test_custom_object_as_keys() [](#method-i-test_custom_object_as_keys) - -## test_depth() [](#method-i-test_depth) - -## test_dump_strict() [](#method-i-test_dump_strict) - -## test_dump_unenclosed_hash() [](#method-i-test_dump_unenclosed_hash) - -## test_falsy_state() [](#method-i-test_falsy_state) - -## test_fast_generate() [](#method-i-test_fast_generate) - -## test_fast_state() [](#method-i-test_fast_state) - -## test_gc() [](#method-i-test_gc) - -## test_generate() [](#method-i-test_generate) - -## test_generate_custom() [](#method-i-test_generate_custom) - -## test_generate_pretty() [](#method-i-test_generate_pretty) - -## test_hash_likeness_set_string() [](#method-i-test_hash_likeness_set_string) - -## test_hash_likeness_set_symbol() [](#method-i-test_hash_likeness_set_symbol) - -## test_hash_subclass_with_to_json() [](#method-i-test_hash_subclass_with_to_json) - -## test_hash_subclass_with_to_s() [](#method-i-test_hash_subclass_with_to_s) - -## test_invalid_encoding_string() [](#method-i-test_invalid_encoding_string) - -## test_json_generate() [](#method-i-test_json_generate) - -## test_json_generate_unsupported_types() [](#method-i-test_json_generate_unsupported_types) - -## test_nesting() [](#method-i-test_nesting) - -## test_nonutf8_encoding() [](#method-i-test_nonutf8_encoding) - -## test_own_state() [](#method-i-test_own_state) - -## test_pretty_state() [](#method-i-test_pretty_state) - -## test_safe_state() [](#method-i-test_safe_state) - -## test_states() [](#method-i-test_states) - -## test_string_ext_included_calls_super() [](#method-i-test_string_ext_included_calls_super) - -## test_string_subclass() [](#method-i-test_string_subclass) - -## test_string_subclass_as_keys() [](#method-i-test_string_subclass_as_keys) - -## test_string_subclass_with_to_json() [](#method-i-test_string_subclass_with_to_json) - -## test_string_subclass_with_to_s() [](#method-i-test_string_subclass_with_to_s) - -## test_to_json_called_with_state_object() [](#method-i-test_to_json_called_with_state_object) - -## test_valid_utf8_in_different_encoding() [](#method-i-test_valid_utf8_in_different_encoding) - diff --git a/example/ruby/JSONGeneratorTest/ArrayWithToJSON.md b/example/ruby/JSONGeneratorTest/ArrayWithToJSON.md deleted file mode 100644 index 7937601..0000000 --- a/example/ruby/JSONGeneratorTest/ArrayWithToJSON.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONGeneratorTest::ArrayWithToJSON -**Inherits:** Array - -**Includes:** JSONGeneratorTest::CustomToJSON - - - - - -#Instance Methods -## to_json() [](#method-i-to_json) - diff --git a/example/ruby/JSONGeneratorTest/ArrayWithToS.md b/example/ruby/JSONGeneratorTest/ArrayWithToS.md deleted file mode 100644 index fdf5149..0000000 --- a/example/ruby/JSONGeneratorTest/ArrayWithToS.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONGeneratorTest::ArrayWithToS -**Inherits:** Array - -**Includes:** JSONGeneratorTest::CustomToS - - - - - -#Instance Methods -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/JSONGeneratorTest/CustomToJSON.md b/example/ruby/JSONGeneratorTest/CustomToJSON.md deleted file mode 100644 index 1d34076..0000000 --- a/example/ruby/JSONGeneratorTest/CustomToJSON.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: JSONGeneratorTest::CustomToJSON - - - - - -#Instance Methods -## to_json() [](#method-i-to_json) - diff --git a/example/ruby/JSONGeneratorTest/CustomToS.md b/example/ruby/JSONGeneratorTest/CustomToS.md deleted file mode 100644 index 494d49a..0000000 --- a/example/ruby/JSONGeneratorTest/CustomToS.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: JSONGeneratorTest::CustomToS - - - - - -#Instance Methods -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/JSONGeneratorTest/FakeString.md b/example/ruby/JSONGeneratorTest/FakeString.md deleted file mode 100644 index 2d9e007..0000000 --- a/example/ruby/JSONGeneratorTest/FakeString.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONGeneratorTest::FakeString -**Inherits:** Object - - - - - -#Instance Methods -## to_json(_statenil) [](#method-i-to_json) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/JSONGeneratorTest/HashWithToJSON.md b/example/ruby/JSONGeneratorTest/HashWithToJSON.md deleted file mode 100644 index 507e9f3..0000000 --- a/example/ruby/JSONGeneratorTest/HashWithToJSON.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONGeneratorTest::HashWithToJSON -**Inherits:** Hash - -**Includes:** JSONGeneratorTest::CustomToJSON - - - - - -#Instance Methods -## to_json() [](#method-i-to_json) - diff --git a/example/ruby/JSONGeneratorTest/HashWithToS.md b/example/ruby/JSONGeneratorTest/HashWithToS.md deleted file mode 100644 index 58659ab..0000000 --- a/example/ruby/JSONGeneratorTest/HashWithToS.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONGeneratorTest::HashWithToS -**Inherits:** Hash - -**Includes:** JSONGeneratorTest::CustomToS - - - - - -#Instance Methods -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/JSONGeneratorTest/MyCustomString.md b/example/ruby/JSONGeneratorTest/MyCustomString.md deleted file mode 100644 index 058130a..0000000 --- a/example/ruby/JSONGeneratorTest/MyCustomString.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONGeneratorTest::MyCustomString -**Inherits:** String - - - - - -#Instance Methods -## to_json(_statenil) [](#method-i-to_json) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/JSONGeneratorTest/StringWithToJSON.md b/example/ruby/JSONGeneratorTest/StringWithToJSON.md deleted file mode 100644 index e294ead..0000000 --- a/example/ruby/JSONGeneratorTest/StringWithToJSON.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONGeneratorTest::StringWithToJSON -**Inherits:** String - -**Includes:** JSONGeneratorTest::CustomToJSON - - - - - -#Instance Methods -## to_json() [](#method-i-to_json) - diff --git a/example/ruby/JSONGeneratorTest/StringWithToS.md b/example/ruby/JSONGeneratorTest/StringWithToS.md deleted file mode 100644 index 4b62b5e..0000000 --- a/example/ruby/JSONGeneratorTest/StringWithToS.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONGeneratorTest::StringWithToS -**Inherits:** String - -**Includes:** JSONGeneratorTest::CustomToS - - - - - -#Instance Methods -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/JSONGenericObjectTest.md b/example/ruby/JSONGenericObjectTest.md deleted file mode 100644 index 0cf1ea3..0000000 --- a/example/ruby/JSONGenericObjectTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: JSONGenericObjectTest -**Inherits:** Test::Unit::TestCase - -**Includes:** JSON - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_attributes() [](#method-i-test_attributes) - -## test_from_hash() [](#method-i-test_from_hash) - -## test_generate_json() [](#method-i-test_generate_json) - -## test_json_generic_object_load() [](#method-i-test_json_generic_object_load) - -## test_parse_json() [](#method-i-test_parse_json) - diff --git a/example/ruby/JSONInRactorTest.md b/example/ruby/JSONInRactorTest.md deleted file mode 100644 index 9b95683..0000000 --- a/example/ruby/JSONInRactorTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: JSONInRactorTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_generate() [](#method-i-test_generate) - diff --git a/example/ruby/JSONParserTest.md b/example/ruby/JSONParserTest.md deleted file mode 100644 index d37d76a..0000000 --- a/example/ruby/JSONParserTest.md +++ /dev/null @@ -1,88 +0,0 @@ -# Class: JSONParserTest -**Inherits:** Test::Unit::TestCase - -**Includes:** JSON - - - - - -#Instance Methods -## test_argument_encoding_for_binary_unmodified() [](#method-i-test_argument_encoding_for_binary_unmodified) - -## test_argument_encoding_unmodified() [](#method-i-test_argument_encoding_unmodified) - -## test_backslash() [](#method-i-test_backslash) - -## test_construction() [](#method-i-test_construction) - -## test_error_message_encoding() [](#method-i-test_error_message_encoding) - -## test_freeze() [](#method-i-test_freeze) - -## test_generate_core_subclasses_with_default_to_json() [](#method-i-test_generate_core_subclasses_with_default_to_json) - -## test_generate_core_subclasses_with_new_to_json() [](#method-i-test_generate_core_subclasses_with_new_to_json) - -## test_generate_of_core_subclasses() [](#method-i-test_generate_of_core_subclasses) - -## test_nesting() [](#method-i-test_nesting) - -## test_parse_array_custom_array_derived_class() [](#method-i-test_parse_array_custom_array_derived_class) - -## test_parse_array_custom_non_array_derived_class() [](#method-i-test_parse_array_custom_non_array_derived_class) - -## test_parse_arrays() [](#method-i-test_parse_arrays) - -## test_parse_arrays_with_allow_trailing_comma() [](#method-i-test_parse_arrays_with_allow_trailing_comma) - -## test_parse_big_integers() [](#method-i-test_parse_big_integers) - -## test_parse_bigdecimals() [](#method-i-test_parse_bigdecimals) - -## test_parse_broken_string() [](#method-i-test_parse_broken_string) - -## test_parse_comments() [](#method-i-test_parse_comments) - -## test_parse_complex_objects() [](#method-i-test_parse_complex_objects) - -## test_parse_error_incomplete_hash() [](#method-i-test_parse_error_incomplete_hash) - -## test_parse_error_message_length() [](#method-i-test_parse_error_message_length) - -## test_parse_generic_object() [](#method-i-test_parse_generic_object) - -## test_parse_json_primitive_values() [](#method-i-test_parse_json_primitive_values) - -## test_parse_more_complex_arrays() [](#method-i-test_parse_more_complex_arrays) - -## test_parse_numbers() [](#method-i-test_parse_numbers) - -## test_parse_object() [](#method-i-test_parse_object) - -## test_parse_object_custom_hash_derived_class() [](#method-i-test_parse_object_custom_hash_derived_class) - -## test_parse_object_custom_non_hash_derived_class() [](#method-i-test_parse_object_custom_non_hash_derived_class) - -## test_parse_object_with_allow_trailing_comma() [](#method-i-test_parse_object_with_allow_trailing_comma) - -## test_parse_simple_arrays() [](#method-i-test_parse_simple_arrays) - -## test_parse_simple_objects() [](#method-i-test_parse_simple_objects) - -## test_parse_some_strings() [](#method-i-test_parse_some_strings) - -## test_parse_string_mixed_unicode() [](#method-i-test_parse_string_mixed_unicode) - -## test_parse_values() [](#method-i-test_parse_values) - -## test_parser_reset() [](#method-i-test_parser_reset) - -## test_parsing() [](#method-i-test_parsing) - -## test_parsing_frozen_ascii8bit_string() [](#method-i-test_parsing_frozen_ascii8bit_string) - -## test_some_wrong_inputs() [](#method-i-test_some_wrong_inputs) - -## test_symbolize_names() [](#method-i-test_symbolize_names) - diff --git a/example/ruby/JSONParserTest/SubArray.md b/example/ruby/JSONParserTest/SubArray.md deleted file mode 100644 index 265c2b8..0000000 --- a/example/ruby/JSONParserTest/SubArray.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: JSONParserTest::SubArray -**Inherits:** Array - - - - - -#Instance Methods -## <<(v) [](#method-i-<<) - -## shifted?() [](#method-i-shifted?) - -**@return** [Boolean] - diff --git a/example/ruby/JSONParserTest/SubArray2.md b/example/ruby/JSONParserTest/SubArray2.md deleted file mode 100644 index 68db4d8..0000000 --- a/example/ruby/JSONParserTest/SubArray2.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONParserTest::SubArray2 -**Inherits:** Array - - - - -# Class Methods -## json_create(o ) [](#method-c-json_create) - -#Instance Methods -## to_json(*a) [](#method-i-to_json) - diff --git a/example/ruby/JSONParserTest/SubArrayWrapper.md b/example/ruby/JSONParserTest/SubArrayWrapper.md deleted file mode 100644 index a509467..0000000 --- a/example/ruby/JSONParserTest/SubArrayWrapper.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: JSONParserTest::SubArrayWrapper -**Inherits:** Object - - - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## <<(value) [](#method-i-<<) - -## [](index) [](#method-i-[]) - -## initialize() [](#method-i-initialize) - -**@return** [SubArrayWrapper] a new instance of SubArrayWrapper - -## shifted?() [](#method-i-shifted?) - -**@return** [Boolean] - diff --git a/example/ruby/JSONParserTest/SubHash.md b/example/ruby/JSONParserTest/SubHash.md deleted file mode 100644 index 555b3bc..0000000 --- a/example/ruby/JSONParserTest/SubHash.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: JSONParserTest::SubHash -**Inherits:** Hash - - - - - -#Instance Methods -## []=(k, v) [](#method-i-[]=) - -## item_set?() [](#method-i-item_set?) - -**@return** [Boolean] - diff --git a/example/ruby/JSONParserTest/SubHash2.md b/example/ruby/JSONParserTest/SubHash2.md deleted file mode 100644 index 7edcb0a..0000000 --- a/example/ruby/JSONParserTest/SubHash2.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONParserTest::SubHash2 -**Inherits:** Hash - - - - -# Class Methods -## json_create(o ) [](#method-c-json_create) - -#Instance Methods -## to_json(*a) [](#method-i-to_json) - diff --git a/example/ruby/JSONParserTest/SubOpenStruct.md b/example/ruby/JSONParserTest/SubOpenStruct.md deleted file mode 100644 index 8e1d3ce..0000000 --- a/example/ruby/JSONParserTest/SubOpenStruct.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: JSONParserTest::SubOpenStruct -**Inherits:** OpenStruct - - - - - -#Instance Methods -## [](k) [](#method-i-[]) - -## []=(k, v) [](#method-i-[]=) - -## item_set?() [](#method-i-item_set?) - -**@return** [Boolean] - diff --git a/example/ruby/JSONSpecs.md b/example/ruby/JSONSpecs.md deleted file mode 100644 index 68680ef..0000000 --- a/example/ruby/JSONSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: JSONSpecs - - - - - diff --git a/example/ruby/JSONSpecs/MyClass.md b/example/ruby/JSONSpecs/MyClass.md deleted file mode 100644 index 8218944..0000000 --- a/example/ruby/JSONSpecs/MyClass.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: JSONSpecs::MyClass -**Inherits:** Object - - - - -# Class Methods -## json_create(hash ) [](#method-c-json_create) - -#Instance Methods -## initialize(foo) [](#method-i-initialize) - -**@return** [MyClass] a new instance of MyClass - -## to_json(*args) [](#method-i-to_json) - diff --git a/example/ruby/JSONStringMatchingTest.md b/example/ruby/JSONStringMatchingTest.md deleted file mode 100644 index 9feaefe..0000000 --- a/example/ruby/JSONStringMatchingTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: JSONStringMatchingTest -**Inherits:** Test::Unit::TestCase - -**Includes:** JSON - - - - - -#Instance Methods -## test_match_date() [](#method-i-test_match_date) - diff --git a/example/ruby/JSONStringMatchingTest/TestTime.md b/example/ruby/JSONStringMatchingTest/TestTime.md deleted file mode 100644 index e873e13..0000000 --- a/example/ruby/JSONStringMatchingTest/TestTime.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: JSONStringMatchingTest::TestTime -**Inherits:** Time - - - - -# Class Methods -## json_create(string ) [](#method-c-json_create) - -#Instance Methods -## ==(other) [](#method-i-==) - -## to_json() [](#method-i-to_json) - diff --git a/example/ruby/JUnitFormatter.md b/example/ruby/JUnitFormatter.md deleted file mode 100644 index 759cb4a..0000000 --- a/example/ruby/JUnitFormatter.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: JUnitFormatter -**Inherits:** YamlFormatter - - - - - -#Instance Methods -## after(statenil) [](#method-i-after) - -## exception(exception) [](#method-i-exception) - -## finish() [](#method-i-finish) - -## initialize(outnil) [](#method-i-initialize) - -**@return** [JUnitFormatter] a new instance of JUnitFormatter - diff --git a/example/ruby/JaroWinklerTest.md b/example/ruby/JaroWinklerTest.md deleted file mode 100644 index fb8331f..0000000 --- a/example/ruby/JaroWinklerTest.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: JaroWinklerTest -**Inherits:** Test::Unit::TestCase - - -These tests were originally written by Jian Weihang (簡煒航) as part of his work -on the jaro_winkler gem. The original code could be found here: - https://github.com/tonytonyjan/jaro_winkler/blob/9bd12421/spec/jaro_winkler_spec.rb - -Copyright (c) 2014 Jian Weihang - - - -#Instance Methods -## test_jaro_winkler_distance() [](#method-i-test_jaro_winkler_distance) - -## test_jarowinkler_distance_with_utf8_strings() [](#method-i-test_jarowinkler_distance_with_utf8_strings) - diff --git a/example/ruby/KSAutoloadB.md b/example/ruby/KSAutoloadB.md deleted file mode 100644 index 53ac315..0000000 --- a/example/ruby/KSAutoloadB.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: KSAutoloadB - - - - -# Class Methods -## loaded() [](#method-c-loaded) - diff --git a/example/ruby/KSAutoloadD.md b/example/ruby/KSAutoloadD.md deleted file mode 100644 index 4942354..0000000 --- a/example/ruby/KSAutoloadD.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: KSAutoloadD - - - - -# Class Methods -## loaded() [](#method-c-loaded) - diff --git a/example/ruby/Kernel.md b/example/ruby/Kernel.md deleted file mode 100644 index a61576a..0000000 --- a/example/ruby/Kernel.md +++ /dev/null @@ -1,2146 +0,0 @@ -# Module: Kernel - - --- Monkey patch kernel to ensure that all `require` calls call the same method -++ - - -# Class Methods -## float or nil - - Returns arg converted to a float. Numeric types are - converted directly, and with exception to String and - nil, the rest are converted using - arg.to_f. Converting a String with invalid - characters will result in an ArgumentError. Converting - nil generates a TypeError. Exceptions can be - suppressed by passing exception: false. - - Float(1) #=> 1.0 - Float("123.456") #=> 123.456 - Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring" - Float(nil) #=> TypeError: can't convert nil into Float - Float("123.0_badstring", exception: false) #=> nil -## Integer(arg , base 0, exception: true) [](#method-c-Integer) -call-seq: - Integer(object, base = 0, exception: true) -> integer or nil - -Returns an integer converted from `object`. - -Tries to convert `object` to an integer using `to_int` first and `to_i` -second; see below for exceptions. - -With a non-zero `base`, `object` must be a string or convertible to a string. - -#### Numeric objects - -With an integer argument `object` given, returns `object`: - - Integer(1) # => 1 - Integer(-1) # => -1 - -With a floating-point argument `object` given, returns `object` truncated to -an integer: - - Integer(1.9) # => 1 # Rounds toward zero. - Integer(-1.9) # => -1 # Rounds toward zero. - -#### String objects - -With a string argument `object` and zero `base` given, returns `object` -converted to an integer in base 10: - - Integer('100') # => 100 - Integer('-100') # => -100 - -With `base` zero, string `object` may contain leading characters to specify -the actual base (radix indicator): - - Integer('0100') # => 64 # Leading '0' specifies base 8. - Integer('0b100') # => 4 # Leading '0b' specifies base 2. - Integer('0x100') # => 256 # Leading '0x' specifies base 16. - -With a positive `base` (in range 2..36) given, returns `object` converted to -an integer in the given base: - - Integer('100', 2) # => 4 - Integer('100', 8) # => 64 - Integer('-100', 16) # => -256 - -With a negative `base` (in range -36..-2) given, returns `object` converted to -the radix indicator if it exists or `base`: - - Integer('0x100', -2) # => 256 - Integer('100', -2) # => 4 - Integer('0b100', -8) # => 4 - Integer('100', -8) # => 64 - Integer('0o100', -10) # => 64 - Integer('100', -10) # => 100 - -`base` -1 is equivalent to the -10 case. - -When converting strings, surrounding whitespace and embedded underscores are -allowed and ignored: - - Integer(' 100 ') # => 100 - Integer('-1_0_0', 16) # => -256 - -#### Other classes - -Examples with `object` of various other classes: - - Integer(Rational(9, 10)) # => 0 # Rounds toward zero. - Integer(Complex(2, 0)) # => 2 # Imaginary part must be zero. - Integer(Time.now) # => 1650974042 - -#### Keywords - -With the optional keyword argument `exception` given as `true` (the default): - -* Raises TypeError if `object` does not respond to `to_int` or `to_i`. -* Raises TypeError if `object` is `nil`. -* Raises ArgumentError if `object` is an invalid string. - -With `exception` given as `false`, an exception of any kind is suppressed and -`nil` is returned. -## URI(uri ) [](#method-c-URI) -Returns a URI object derived from the given `uri`, which may be a URI string -or an existing URI object: - - # Returns a new URI. - uri = URI('http://github.com/ruby/ruby') - # => # - # Returns the given URI. - URI(uri) - # => # -## l!() [](#method-c-l!) -## load(file , wrap false) [](#method-c-load) -## loop() [](#method-c-loop) -call-seq: - loop { block } - loop -> an_enumerator - -Repeatedly executes the block. - -If no block is given, an enumerator is returned instead. - - loop do - print "Input: " - line = gets - break if !line or line =~ /^q/i - # ... - end - -A StopIteration raised in the block breaks the loop. In this case, loop -returns the "result" value stored in the exception. - - enum = Enumerator.new { |y| - y << "one" - y << "two" - :ok - } - - result = loop { - puts enum.next - } #=> :ok -## pp(*objs ) [](#method-c-pp) -prints arguments in pretty form. - -`#pp` returns argument(s). -## require(file ) [](#method-c-require) -## require_relative(file ) [](#method-c-require_relative) -## syntax_suggest_original_load() [](#method-c-syntax_suggest_original_load) -## syntax_suggest_original_require() [](#method-c-syntax_suggest_original_require) -## syntax_suggest_original_require_relative() [](#method-c-syntax_suggest_original_require_relative) -## uplevel() [](#method-c-uplevel) -## warn(*msgs , uplevel: nil, category: nil) [](#method-c-warn) -call-seq: - warn(*msgs, uplevel: nil, category: nil) -> nil - -If warnings have been disabled (for example with the `-W0` flag), does -nothing. Otherwise, converts each of the messages to strings, appends a -newline character to the string if the string does not end in a newline, and -calls Warning.warn with the string. - - warn("warning 1", "warning 2") - -*produces:* - - warning 1 - warning 2 - -If the `uplevel` keyword argument is given, the string will be prepended with -information for the given caller frame in the same format used by the -`rb_warn` C function. - - # In baz.rb - def foo - warn("invalid call to foo", uplevel: 1) - end - - def bar - foo - end - - bar - -*produces:* - - baz.rb:6: warning: invalid call to foo - -If `category` keyword argument is given, passes the category to -`Warning.warn`. The category given must be one of the following categories: - -:deprecated -: Used for warning for deprecated functionality that may be removed in the - future. - -:experimental -: Used for experimental features that may change in future releases. - -:performance -: Used for warning about APIs or pattern that have negative performance - impact - - -#Instance Methods -## Array(arg) [](#method-i-Array) -Returns an array converted from `object`. - -Tries to convert `object` to an array using `to_ary` first and `to_a` second: - - Array([0, 1, 2]) # => [0, 1, 2] - Array({foo: 0, bar: 1}) # => [[:foo, 0], [:bar, 1]] - Array(0..4) # => [0, 1, 2, 3, 4] - -Returns `object` in an array, `[object]`, if `object` cannot be converted: - - Array(:foo) # => [:foo] - -**@overload** [] - -## Complex(*args) [](#method-i-Complex) -Returns a new Complex object if the arguments are valid; otherwise raises an -exception if `exception` is `true`; otherwise returns `nil`. - -With Numeric arguments `real` and `imag`, returns `Complex.rect(real, imag)` -if the arguments are valid. - -With string argument `s`, returns a new Complex object if the argument is -valid; the string may have: - -* One or two numeric substrings, each of which specifies a Complex, Float, - Integer, Numeric, or Rational value, specifying [rectangular - coordinates](rdoc-ref:Complex@Rectangular+Coordinates): - - * Sign-separated real and imaginary numeric substrings (with trailing - character `'i'`): - - Complex('1+2i') # => (1+2i) - Complex('+1+2i') # => (1+2i) - Complex('+1-2i') # => (1-2i) - Complex('-1+2i') # => (-1+2i) - Complex('-1-2i') # => (-1-2i) - - * Real-only numeric string (without trailing character `'i'`): - - Complex('1') # => (1+0i) - Complex('+1') # => (1+0i) - Complex('-1') # => (-1+0i) - - * Imaginary-only numeric string (with trailing character `'i'`): - - Complex('1i') # => (0+1i) - Complex('+1i') # => (0+1i) - Complex('-1i') # => (0-1i) - -* At-sign separated real and imaginary rational substrings, each of which - specifies a Rational value, specifying [polar - coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex('1/2@3/4') # => (0.36584443443691045+0.34081938001166706i) - Complex('+1/2@+3/4') # => (0.36584443443691045+0.34081938001166706i) - Complex('+1/2@-3/4') # => (0.36584443443691045-0.34081938001166706i) - Complex('-1/2@+3/4') # => (-0.36584443443691045-0.34081938001166706i) - Complex('-1/2@-3/4') # => (-0.36584443443691045+0.34081938001166706i) - -**@overload** [] - -**@overload** [] - -## Hash(arg) [](#method-i-Hash) -Returns a hash converted from `object`. - -* If `object` is: - - * A hash, returns `object`. - * An empty array or `nil`, returns an empty hash. - -* Otherwise, if `object.to_hash` returns a hash, returns that hash. -* Otherwise, returns TypeError. - -Examples: - - Hash({foo: 0, bar: 1}) # => {:foo=>0, :bar=>1} - Hash(nil) # => {} - Hash([]) # => {} - -**@overload** [] - -## Pathname(str) [](#method-i-Pathname) -:call-seq: - Pathname(path) -> pathname - -Creates a new Pathname object from the given string, `path`, and returns -pathname object. - -In order to use this constructor, you must first require the Pathname standard -library extension. - -require 'pathname' Pathname("/home/zzak") #=> # - -See also Pathname::new for more information. - -## Rational(*args) [](#method-i-Rational) -Returns `x/y` or `arg` as a Rational. - - Rational(2, 3) #=> (2/3) - Rational(5) #=> (5/1) - Rational(0.5) #=> (1/2) - Rational(0.3) #=> (5404319552844595/18014398509481984) - - Rational("2/3") #=> (2/3) - Rational("0.3") #=> (3/10) - - Rational("10 cents") #=> ArgumentError - Rational(nil) #=> TypeError - Rational(1, nil) #=> TypeError - - Rational("10 cents", exception: false) #=> nil - -Syntax of the string form: - - string form = extra spaces , rational , extra spaces ; - rational = [ sign ] , unsigned rational ; - unsigned rational = numerator | numerator , "/" , denominator ; - numerator = integer part | fractional part | integer part , fractional part ; - denominator = digits ; - integer part = digits ; - fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; - sign = "-" | "+" ; - digits = digit , { digit | "_" , digit } ; - digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; - extra spaces = ? \s* ? ; - -See also String#to_r. - -**@overload** [] - -**@overload** [] - -## String(arg) [](#method-i-String) -Returns a string converted from `object`. - -Tries to convert `object` to a string using `to_str` first and `to_s` second: - - String([0, 1, 2]) # => "[0, 1, 2]" - String(0..5) # => "0..5" - String({foo: 0, bar: 1}) # => "{foo: 0, bar: 1}" - -Raises `TypeError` if `object` cannot be converted to a string. - -**@overload** [] - -## __callee__() [](#method-i-__callee__) -Returns the called name of the current method as a Symbol. If called outside -of a method, it returns `nil`. - -**@overload** [] - -## __dir__() [](#method-i-__dir__) -Returns the canonicalized absolute path of the directory of the file from -which this method is called. It means symlinks in the path is resolved. If -`__FILE__` is `nil`, it returns `nil`. The return value equals to -`File.dirname(File.realpath(__FILE__))`. - -**@overload** [] - -## __method__() [](#method-i-__method__) -Returns the name at the definition of the current method as a Symbol. If -called outside of a method, it returns `nil`. - -**@overload** [] - -## `(str) [](#method-i-`) -Returns the `$stdout` output from running `command` in a subshell; sets global -variable `$?` to the process status. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Examples: - - $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n" - $ `echo oops && exit 99` # => "oops\n" - $ $? # => # - $ $?.status # => 99> - -The built-in syntax `%x{...}` uses this method. - -**@overload** [] - -## abort(*a, _) [](#method-i-abort) -Terminates execution immediately, effectively by calling `Kernel.exit(false)`. - -If string argument `msg` is given, it is written to STDERR prior to -termination; otherwise, if an exception was raised, prints its message and -backtrace. - -**@overload** [] - -**@overload** [] - -## at_exit() [](#method-i-at_exit) -Converts *block* to a `Proc` object (and therefore binds it at the point of -call) and registers it for execution when the program exits. If multiple -handlers are registered, they are executed in reverse order of registration. - - def do_at_exit(str1) - at_exit { print str1 } - end - at_exit { puts "cruel world" } - do_at_exit("goodbye ") - exit - -*produces:* - - goodbye cruel world - -**@overload** [] - -## autoload(sym, file) [](#method-i-autoload) -Registers *filename* to be loaded (using Kernel::require) the first time that -*const* (which may be a String or a symbol) is accessed. - - autoload(:MyModule, "/usr/local/lib/modules/my_module.rb") - -If *const* is defined as autoload, the file name to be loaded is replaced with -*filename*. If *const* is defined but not as autoload, does nothing. - -**@overload** [] - -## autoload?(*args) [](#method-i-autoload?) -Returns *filename* to be loaded if *name* is registered as `autoload` in the -current namespace or one of its ancestors. - - autoload(:B, "b") - autoload?(:B) #=> "b" - - module C - autoload(:D, "d") - autoload?(:D) #=> "d" - autoload?(:B) #=> nil - end - - class E - autoload(:F, "f") - autoload?(:F) #=> "f" - autoload?(:B) #=> "b" - end - -**@overload** [] - -## binding() [](#method-i-binding) -Returns a Binding object, describing the variable and method bindings at the -point of call. This object can be used when calling Binding#eval to execute -the evaluated command in this environment, or extracting its local variables. - - class User - def initialize(name, position) - @name = name - @position = position - end - - def get_binding - binding - end - end - - user = User.new('Joan', 'manager') - template = '{name: @name, position: @position}' - - # evaluate template in context of the object - eval(template, user.get_binding) - #=> {:name=>"Joan", :position=>"manager"} - -Binding#local_variable_get can be used to access the variables whose names are -reserved Ruby keywords: - - # This is valid parameter declaration, but `if` parameter can't - # be accessed by name, because it is a reserved word. - def validate(field, validation, if: nil) - condition = binding.local_variable_get('if') - return unless condition - - # ...Some implementation ... - end - - validate(:name, :empty?, if: false) # skips validation - validate(:name, :empty?, if: true) # performs validation - -**@overload** [] - -## block_given?() [](#method-i-block_given?) -Returns `true` if `yield` would execute a block in the current context. The -`iterator?` form is mildly deprecated. - - def try - if block_given? - yield - else - "no block" - end - end - try #=> "no block" - try { "hello" } #=> "hello" - try do "hello" end #=> "hello" - -**@overload** [] - -## callcc() [](#method-i-callcc) -Generates a Continuation object, which it passes to the associated block. You -need to `require 'continuation'` before using this method. Performing a -*cont*`.call` will cause the #callcc to return (as will falling through the -end of the block). The value returned by the #callcc is the value of the -block, or the value passed to *cont*`.call`. See class Continuation for more -details. Also see Kernel#throw for an alternative mechanism for unwinding a -call stack. - -**@overload** [] - -## caller(*args) [](#method-i-caller) -Returns the current execution stack---an array containing strings in the form -`file:line` or `file:line: in `method'`. - -The optional *start* parameter determines the number of initial stack entries -to omit from the top of the stack. - -A second optional `length` parameter can be used to limit how many entries are -returned from the stack. - -Returns `nil` if *start* is greater than the size of current execution stack. - -Optionally you can pass a range, which will return an array containing the -entries within the specified range. - - def a(skip) - caller(skip) - end - def b(skip) - a(skip) - end - def c(skip) - b(skip) - end - c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `
'"] - c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `
'"] - c(2) #=> ["prog:8:in `c'", "prog:12:in `
'"] - c(3) #=> ["prog:13:in `
'"] - c(4) #=> [] - c(5) #=> nil - -**@overload** [] - -**@overload** [] - -## caller_locations(*args) [](#method-i-caller_locations) -Returns the current execution stack---an array containing backtrace location -objects. - -See Thread::Backtrace::Location for more information. - -The optional *start* parameter determines the number of initial stack entries -to omit from the top of the stack. - -A second optional `length` parameter can be used to limit how many entries are -returned from the stack. - -Returns `nil` if *start* is greater than the size of current execution stack. - -Optionally you can pass a range, which will return an array containing the -entries within the specified range. - -**@overload** [] - -**@overload** [] - -## catch(*args) [](#method-i-catch) -`catch` executes its block. If `throw` is not called, the block executes -normally, and `catch` returns the value of the last expression evaluated. - - catch(1) { 123 } # => 123 - -If `throw(tag2, val)` is called, Ruby searches up its stack for a `catch` -block whose `tag` has the same `object_id` as *tag2*. When found, the block -stops executing and returns *val* (or `nil` if no second argument was given to -`throw`). - - catch(1) { throw(1, 456) } # => 456 - catch(1) { throw(1) } # => nil - -When `tag` is passed as the first argument, `catch` yields it as the parameter -of the block. - - catch(1) {|x| x + 2 } # => 3 - -When no `tag` is given, `catch` yields a new unique object (as from -`Object.new`) as the block parameter. This object can then be used as the -argument to `throw`, and will match the correct `catch` block. - - catch do |obj_A| - catch do |obj_B| - throw(obj_B, 123) - puts "This puts is not reached" - end - - puts "This puts is displayed" - 456 - end - - # => 456 - - catch do |obj_A| - catch do |obj_B| - throw(obj_A, 123) - puts "This puts is still not reached" - end - - puts "Now this puts is also not reached" - 456 - end - - # => 123 - -**@overload** [] - -## chomp(*args) [](#method-i-chomp) -Equivalent to `$_ = $_.chomp(*string*)`. See String#chomp. Available only when --p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## chop() [](#method-i-chop) -Equivalent to `($_.dup).chop!`, except `nil` is never returned. See -String#chop!. Available only when -p/-n command line option specified. - -**@overload** [] - -## class() [](#method-i-class) -call-seq: - obj.class -> class - - Returns the class of obj. This method must always be called - with an explicit receiver, as #class is also a reserved word in - Ruby. - - 1.class #=> Integer - self.class #=> Object - --- Equivalent to c Object#class in Ruby. - -Returns the class of c obj, skipping singleton classes or module inclusions. -++ - -## clone(freeze:nil) [](#method-i-clone) -call-seq: - obj.clone(freeze: nil) -> an_object - - Produces a shallow copy of obj---the instance variables of - obj are copied, but not the objects they reference. - #clone copies the frozen value state of obj, unless the - +:freeze+ keyword argument is given with a false or true value. - See also the discussion under Object#dup. - - class Klass - attr_accessor :str - end - s1 = Klass.new #=> # - s1.str = "Hello" #=> "Hello" - s2 = s1.clone #=> # - s2.str[1,4] = "i" #=> "i" - s1.inspect #=> "#" - s2.inspect #=> "#" - - This method may have class-specific behavior. If so, that - behavior will be documented under the #+initialize_copy+ method of - the class. - -## eval(*args) [](#method-i-eval) -Evaluates the Ruby expression(s) in *string*. If *binding* is given, which -must be a Binding object, the evaluation is performed in its context. If the -optional *filename* and *lineno* parameters are present, they will be used -when reporting syntax errors. - - def get_binding(str) - return binding - end - str = "hello" - eval "str + ' Fred'" #=> "hello Fred" - eval "str + ' Fred'", get_binding("bye") #=> "bye Fred" - -**@overload** [] - -## exec(*a, _) [](#method-i-exec) -Replaces the current process by doing one of the following: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -The new process is created using the [exec system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e -xecve.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - exec('if true; then echo "Foo"; fi') # Shell reserved word. - exec('exit') # Built-in. - exec('date > date.tmp') # Contains meta character. - -The command line may also contain arguments and options for the command: - - exec('echo "Foo"') - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - exec('/usr/bin/date') - -Output: - - Sat Aug 26 09:38:00 AM CDT 2023 - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - - exec('doesnt_exist') # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - exec('echo', 'C*') - exec('echo', 'hello', 'world') - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## exit(*a, _) [](#method-i-exit) -Initiates termination of the Ruby script by raising SystemExit; the exception -may be caught. Returns exit status `status` to the underlying operating -system. - -Values `true` and `false` for argument `status` indicate, respectively, -success and failure; The meanings of integer values are system-dependent. - -Example: - - begin - exit - puts 'Never get here.' - rescue SystemExit - puts 'Rescued a SystemExit exception.' - end - puts 'After begin block.' - -Output: - - Rescued a SystemExit exception. - After begin block. - -Just prior to final termination, Ruby executes any at-exit procedures (see -Kernel::at_exit) and any object finalizers (see -ObjectSpace::define_finalizer). - -Example: - - at_exit { puts 'In at_exit function.' } - ObjectSpace.define_finalizer('string', proc { puts 'In finalizer.' }) - exit - -Output: - - In at_exit function. - In finalizer. - -**@overload** [] - -**@overload** [] - -## exit!(*args) [](#method-i-exit!) -Exits the process immediately; no exit handlers are called. Returns exit -status `status` to the underlying operating system. - - Process.exit!(true) - -Values `true` and `false` for argument `status` indicate, respectively, -success and failure; The meanings of integer values are system-dependent. - -**@overload** [] - -**@overload** [] - -## fail(*v, _) [](#method-i-fail) -Raises an exception; see [Exceptions](rdoc-ref:exceptions.md). - -Argument `exception` sets the class of the new exception; it should be class -Exception or one of its subclasses (most commonly, RuntimeError or -StandardError), or an instance of one of those classes: - - begin - raise(StandardError) - rescue => x - p x.class - end - # => StandardError - -Argument `message` sets the stored message in the new exception, which may be -retrieved by method Exception#message; the message must be a -[string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or -`nil`: - - begin - raise(StandardError, 'Boom') - rescue => x - p x.message - end - # => "Boom" - -If argument `message` is not given, the message is the exception class name. - -See [Messages](rdoc-ref:exceptions.md@Messages). - -Argument `backtrace` might be used to modify the backtrace of the new -exception, as reported by Exception#backtrace and -Exception#backtrace_locations; the backtrace must be an array of -Thread::Backtrace::Location, an array of strings, a single string, or `nil`. - -Using the array of Thread::Backtrace::Location instances is the most -consistent option and should be preferred when possible. The necessary value -might be obtained from #caller_locations, or copied from -Exception#backtrace_locations of another error: - - begin - do_some_work() - rescue ZeroDivisionError => ex - raise(LogicalError, "You have an error in your math", ex.backtrace_locations) - end - -The ways, both Exception#backtrace and Exception#backtrace_locations of the -raised error are set to the same backtrace. - -When the desired stack of locations is not available and should be constructed -from scratch, an array of strings or a singular string can be used. In this -case, only Exception#backtrace is set: - - begin - raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1]) - rescue => ex - p ex.backtrace - # => ["dsl.rb:3", "framework.rb:1"] - p ex.backtrace_locations - # => nil - end - -If argument `backtrace` is not given, the backtrace is set according to an -array of Thread::Backtrace::Location objects, as derived from the call stack. - -See [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -Keyword argument `cause` sets the stored cause in the new exception, which may -be retrieved by method Exception#cause; the cause must be an exception object -(Exception or one of its subclasses), or `nil`: - - begin - raise(StandardError, cause: RuntimeError.new) - rescue => x - p x.cause - end - # => # - -If keyword argument `cause` is not given, the cause is the value of `$!`. - -See [Cause](rdoc-ref:exceptions.md@Cause). - -In the alternate calling sequence, where argument `exception` *not* given, -raises a new exception of the class given by `$!`, or of class RuntimeError if -`$!` is `nil`: - - begin - raise - rescue => x - p x - end - # => RuntimeError - -With argument `exception` not given, argument `message` and keyword argument -`cause` may be given, but argument `backtrace` may not be given. - -**@overload** [] - -**@overload** [] - -## fork() [](#method-i-fork) -Creates a child process. - -With a block given, runs the block in the child process; on block exit, the -child terminates with a status of zero: - - puts "Before the fork: #{Process.pid}" - fork do - puts "In the child process: #{Process.pid}" - end # => 382141 - puts "After the fork: #{Process.pid}" - -Output: - - Before the fork: 420496 - After the fork: 420496 - In the child process: 420520 - -With no block given, the `fork` call returns twice: - -* Once in the parent process, returning the pid of the child process. -* Once in the child process, returning `nil`. - -Example: - - puts "This is the first line before the fork (pid #{Process.pid})" - puts fork - puts "This is the second line after the fork (pid #{Process.pid})" - -Output: - - This is the first line before the fork (pid 420199) - 420223 - This is the second line after the fork (pid 420199) - - This is the second line after the fork (pid 420223) - -In either case, the child process may exit using Kernel.exit! to avoid the -call to Kernel#at_exit. - -To avoid zombie processes, the parent process should call either: - -* Process.wait, to collect the termination statuses of its children. -* Process.detach, to register disinterest in their status. - -The thread calling `fork` is the only thread in the created child process; -`fork` doesn't copy other threads. - -Note that method `fork` is available on some platforms, but not on others: - - Process.respond_to?(:fork) # => true # Would be false on some. - -If not, you may use ::spawn instead of `fork`. - -**@overload** [] - -**@overload** [] - -## format(*v, _) [](#method-i-format) -Returns the string resulting from formatting `objects` into `format_string`. - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -**@overload** [] - -## frozen?() [](#method-i-frozen?) -call-seq: - obj.frozen? -> true or false - - Returns the freeze status of obj. - - a = [ "a", "b", "c" ] - a.freeze #=> ["a", "b", "c"] - a.frozen? #=> true - --- Determines if the object is frozen. Equivalent to `Object#frozen?` in Ruby. -@[param](in) obj the object to be determines ++ - -**@return** [Boolean] - -## gets(*args) [](#method-i-gets) -Returns (and assigns to `$_`) the next line from the list of files in `ARGV` -(or `$*`), or from standard input if no files are present on the command line. -Returns `nil` at end of file. The optional argument specifies the record -separator. The separator is included with the contents of each record. A -separator of `nil` reads the entire contents, and a zero-length separator -reads the input one paragraph at a time, where paragraphs are divided by two -consecutive newlines. If the first argument is an integer, or optional second -argument is given, the returning string would not be longer than the given -value in bytes. If multiple filenames are present in `ARGV`, `gets(nil)` will -read the contents one file at a time. - - ARGV << "testfile" - print while gets - -*produces:* - - This is line one - This is line two - This is line three - And so on... - -The style of programming using `$_` as an implicit parameter is gradually -losing favor in the Ruby community. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## global_variables() [](#method-i-global_variables) -Returns an array of the names of global variables. This includes special -regexp global variables such as `$~` and `$+`, but does not include the -numbered regexp global variables (`$1`, `$2`, etc.). - - global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr] - -**@overload** [] - -## gsub(*args) [](#method-i-gsub) -Equivalent to `$_.gsub...`, except that `$_` will be updated if substitution -occurs. Available only when -p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## iterator?() [](#method-i-iterator?) -Deprecated. Use block_given? instead. - -**@overload** [] - -## lambda() [](#method-i-lambda) -Equivalent to Proc.new, except the resulting Proc objects check the number of -parameters passed when called. - -**@overload** [] - -## local_variables() [](#method-i-local_variables) -Returns the names of the current local variables. - - fred = 1 - for i in 1..10 - # ... - end - local_variables #=> [:fred, :i] - -**@overload** [] - -## module_specs_public_method_on_kernel() [](#method-i-module_specs_public_method_on_kernel) - -## open(*args) [](#method-i-open) -Creates an IO object connected to the given file. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -With no block given, file stream is returned: - - open('t.txt') # => # - -With a block given, calls the block with the open file stream, then closes the -stream: - - open('t.txt') {|f| p f } # => # - -Output: - - # - -See File.open for details. - -**@overload** [] - -**@overload** [] - -## p(*args) [](#method-i-p) -For each object `obj`, executes: - - $stdout.write(obj.inspect, "\n") - -With one object given, returns the object; with multiple objects given, -returns an array containing the objects; with no object given, returns `nil`. - -Examples: - - r = Range.new(0, 4) - p r # => 0..4 - p [r, r, r] # => [0..4, 0..4, 0..4] - p # => nil - -Output: - - 0..4 - [0..4, 0..4, 0..4] - -Kernel#p is designed for debugging purposes. Ruby implementations may define -Kernel#p to be uninterruptible in whole or in part. On CRuby, Kernel#p's -writing of data is uninterruptible. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## pretty_inspect() [](#method-i-pretty_inspect) -Returns a pretty printed object as a string. - -See the PP module for more information. - -## print(*args) [](#method-i-print) -Equivalent to `$stdout.print(*objects)`, this method is the straightforward -way to write to `$stdout`. - -Writes the given objects to `$stdout`; returns `nil`. Appends the output -record separator `$OUTPUT_RECORD_SEPARATOR` `$\`), if it is not `nil`. - -With argument `objects` given, for each object: - -* Converts via its method `to_s` if not a string. -* Writes to `stdout`. -* If not the last object, writes the output field separator - `$OUTPUT_FIELD_SEPARATOR` (`$,` if it is not `nil`. - -With default separators: - - objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero'] - $OUTPUT_RECORD_SEPARATOR - $OUTPUT_FIELD_SEPARATOR - print(*objects) - -Output: - - nil - nil - 00.00/10+0izerozero - -With specified separators: - - $OUTPUT_RECORD_SEPARATOR = "\n" - $OUTPUT_FIELD_SEPARATOR = ',' - print(*objects) - -Output: - - 0,0.0,0/1,0+0i,zero,zero - -With no argument given, writes the content of `$_` (which is usually the most -recent user input): - - gets # Sets $_ to the most recent user input. - print # Prints $_. - -**@overload** [] - -## printf(*args) [](#method-i-printf) -Equivalent to: - - io.write(sprintf(format_string, *objects)) - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -With the single argument `format_string`, formats `objects` into the string, -then writes the formatted string to $stdout: - - printf('%4.4d %10s %2.2f', 24, 24, 24.0) - -Output (on $stdout): - - 0024 24 24.00# - -With arguments `io` and `format_string`, formats `objects` into the string, -then writes the formatted string to `io`: - - printf($stderr, '%4.4d %10s %2.2f', 24, 24, 24.0) - -Output (on $stderr): - - 0024 24 24.00# => nil - -With no arguments, does nothing. - -**@overload** [] - -**@overload** [] - -## proc() [](#method-i-proc) -Equivalent to Proc.new. - -**@overload** [] - -## putc(ch) [](#method-i-putc) -Equivalent to: - - $stdout.putc(int) - -See IO#putc for important information regarding multi-byte characters. - -**@overload** [] - -## puts(*args) [](#method-i-puts) -Equivalent to - - $stdout.puts(objects) - -**@overload** [] - -## raise(*v, _) [](#method-i-raise) -Raises an exception; see [Exceptions](rdoc-ref:exceptions.md). - -Argument `exception` sets the class of the new exception; it should be class -Exception or one of its subclasses (most commonly, RuntimeError or -StandardError), or an instance of one of those classes: - - begin - raise(StandardError) - rescue => x - p x.class - end - # => StandardError - -Argument `message` sets the stored message in the new exception, which may be -retrieved by method Exception#message; the message must be a -[string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or -`nil`: - - begin - raise(StandardError, 'Boom') - rescue => x - p x.message - end - # => "Boom" - -If argument `message` is not given, the message is the exception class name. - -See [Messages](rdoc-ref:exceptions.md@Messages). - -Argument `backtrace` might be used to modify the backtrace of the new -exception, as reported by Exception#backtrace and -Exception#backtrace_locations; the backtrace must be an array of -Thread::Backtrace::Location, an array of strings, a single string, or `nil`. - -Using the array of Thread::Backtrace::Location instances is the most -consistent option and should be preferred when possible. The necessary value -might be obtained from #caller_locations, or copied from -Exception#backtrace_locations of another error: - - begin - do_some_work() - rescue ZeroDivisionError => ex - raise(LogicalError, "You have an error in your math", ex.backtrace_locations) - end - -The ways, both Exception#backtrace and Exception#backtrace_locations of the -raised error are set to the same backtrace. - -When the desired stack of locations is not available and should be constructed -from scratch, an array of strings or a singular string can be used. In this -case, only Exception#backtrace is set: - - begin - raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1]) - rescue => ex - p ex.backtrace - # => ["dsl.rb:3", "framework.rb:1"] - p ex.backtrace_locations - # => nil - end - -If argument `backtrace` is not given, the backtrace is set according to an -array of Thread::Backtrace::Location objects, as derived from the call stack. - -See [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -Keyword argument `cause` sets the stored cause in the new exception, which may -be retrieved by method Exception#cause; the cause must be an exception object -(Exception or one of its subclasses), or `nil`: - - begin - raise(StandardError, cause: RuntimeError.new) - rescue => x - p x.cause - end - # => # - -If keyword argument `cause` is not given, the cause is the value of `$!`. - -See [Cause](rdoc-ref:exceptions.md@Cause). - -In the alternate calling sequence, where argument `exception` *not* given, -raises a new exception of the class given by `$!`, or of class RuntimeError if -`$!` is `nil`: - - begin - raise - rescue => x - p x - end - # => RuntimeError - -With argument `exception` not given, argument `message` and keyword argument -`cause` may be given, but argument `backtrace` may not be given. - -**@overload** [] - -**@overload** [] - -## rand(*args) [](#method-i-rand) -If called without an argument, or if `max.to_i.abs == 0`, rand returns a -pseudo-random floating point number between 0.0 and 1.0, including 0.0 and -excluding 1.0. - - rand #=> 0.2725926052826416 - -When `max.abs` is greater than or equal to 1, `rand` returns a pseudo-random -integer greater than or equal to 0 and less than `max.to_i.abs`. - - rand(100) #=> 12 - -When `max` is a Range, `rand` returns a random number where -`range.member?(number) == true`. - -Negative or floating point values for `max` are allowed, but may give -surprising results. - - rand(-100) # => 87 - rand(-0.5) # => 0.8130921818028143 - rand(1.9) # equivalent to rand(1), which is always 0 - -Kernel.srand may be used to ensure that sequences of random numbers are -reproducible between different runs of a program. - -See also Random.rand. - -**@overload** [] - -## rb_eval_string(str) [](#method-i-rb_eval_string) - -## readline(*args) [](#method-i-readline) -Equivalent to method Kernel#gets, except that it raises an exception if called -at end-of-stream: - - $ cat t.txt | ruby -e "p readlines; readline" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - in `readline': end of file reached (EOFError) - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## readlines(*args) [](#method-i-readlines) -Returns an array containing the lines returned by calling Kernel#gets until -the end-of-stream is reached; (see [Line IO](rdoc-ref:IO@Line+IO)). - -With only string argument `sep` given, returns the remaining lines as -determined by line separator `sep`, or `nil` if none; see [Line -Separator](rdoc-ref:IO@Line+Separator): - - # Default separator. - $ cat t.txt | ruby -e "p readlines" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - - # Specified separator. - $ cat t.txt | ruby -e "p readlines 'li'" - ["First li", "ne\nSecond li", "ne\n\nFourth li", "ne\nFifth li", "ne\n"] - - # Get-all separator. - $ cat t.txt | ruby -e "p readlines nil" - ["First line\nSecond line\n\nFourth line\nFifth line\n"] - - # Get-paragraph separator. - $ cat t.txt | ruby -e "p readlines ''" - ["First line\nSecond line\n\n", "Fourth line\nFifth line\n"] - -With only integer argument `limit` given, limits the number of bytes in the -line; see [Line Limit](rdoc-ref:IO@Line+Limit): - - $cat t.txt | ruby -e "p readlines 10" - ["First line", "\n", "Second lin", "e\n", "\n", "Fourth lin", "e\n", "Fifth line", "\n"] - - $cat t.txt | ruby -e "p readlines 11" - ["First line\n", "Second line", "\n", "\n", "Fourth line", "\n", "Fifth line\n"] - - $cat t.txt | ruby -e "p readlines 12" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted: - - $ cat t.txt | ruby -e "p readlines(chomp: true)" - ["First line", "Second line", "", "Fourth line", "Fifth line"] - -Optional keyword arguments `enc_opts` specify encoding options; see [Encoding -options](rdoc-ref:encodings.rdoc@Encoding+Options). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## register_sample_bug_reporter(obj) [](#method-i-register_sample_bug_reporter) - -## select(*args) [](#method-i-select) -Invokes system call [select(2)](https://linux.die.net/man/2/select), which -monitors multiple file descriptors, waiting until one or more of the file -descriptors becomes ready for some class of I/O operation. - -Not implemented on all platforms. - -Each of the arguments `read_ios`, `write_ios`, and `error_ios` is an array of -IO objects. - -Argument `timeout` is a numeric value (such as integer or float) timeout -interval in seconds. - -The method monitors the IO objects given in all three arrays, waiting for some -to be ready; returns a 3-element array whose elements are: - -* An array of the objects in `read_ios` that are ready for reading. -* An array of the objects in `write_ios` that are ready for writing. -* An array of the objects in `error_ios` have pending exceptions. - -If no object becomes ready within the given `timeout`, `nil` is returned. - -IO.select peeks the buffer of IO objects for testing readability. If the IO -buffer is not empty, IO.select immediately notifies readability. This "peek" -only happens for IO objects. It does not happen for IO-like objects such as -OpenSSL::SSL::SSLSocket. - -The best way to use IO.select is invoking it after non-blocking methods such -as #read_nonblock, #write_nonblock, etc. The methods raise an exception which -is extended by IO::WaitReadable or IO::WaitWritable. The modules notify how -the caller should wait with IO.select. If IO::WaitReadable is raised, the -caller should wait for reading. If IO::WaitWritable is raised, the caller -should wait for writing. - -So, blocking read (#readpartial) can be emulated using #read_nonblock and -IO.select as follows: - - begin - result = io_like.read_nonblock(maxlen) - rescue IO::WaitReadable - IO.select([io_like]) - retry - rescue IO::WaitWritable - IO.select(nil, [io_like]) - retry - end - -Especially, the combination of non-blocking methods and IO.select is preferred -for IO like objects such as OpenSSL::SSL::SSLSocket. It has #to_io method to -return underlying IO object. IO.select calls #to_io to obtain the file -descriptor to wait. - -This means that readability notified by IO.select doesn't mean readability -from OpenSSL::SSL::SSLSocket object. - -The most likely situation is that OpenSSL::SSL::SSLSocket buffers some data. -IO.select doesn't see the buffer. So IO.select can block when -OpenSSL::SSL::SSLSocket#readpartial doesn't block. - -However, several more complicated situations exist. - -SSL is a protocol which is sequence of records. The record consists of -multiple bytes. So, the remote side of SSL sends a partial record, IO.select -notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a byte and -OpenSSL::SSL::SSLSocket#readpartial will block. - -Also, the remote side can request SSL renegotiation which forces the local SSL -engine to write some data. This means OpenSSL::SSL::SSLSocket#readpartial may -invoke #write system call and it can block. In such a situation, -OpenSSL::SSL::SSLSocket#read_nonblock raises IO::WaitWritable instead of -blocking. So, the caller should wait for ready for writability as above -example. - -The combination of non-blocking methods and IO.select is also useful for -streams such as tty, pipe socket socket when multiple processes read from a -stream. - -Finally, Linux kernel developers don't guarantee that readability of select(2) -means readability of following read(2) even for a single process; see -[select(2)](https://linux.die.net/man/2/select) - -Invoking IO.select before IO#readpartial works well as usual. However it is -not the best way to use IO.select. - -The writability notified by select(2) doesn't show how many bytes are -writable. IO#write method blocks until given whole string is written. So, -`IO#write(two or more bytes)` can block after writability is notified by -IO.select. IO#write_nonblock is required to avoid the blocking. - -Blocking write (#write) can be emulated using #write_nonblock and IO.select as -follows: IO::WaitReadable should also be rescued for SSL renegotiation in -OpenSSL::SSL::SSLSocket. - - while 0 < string.bytesize - begin - written = io_like.write_nonblock(string) - rescue IO::WaitReadable - IO.select([io_like]) - retry - rescue IO::WaitWritable - IO.select(nil, [io_like]) - retry - end - string = string.byteslice(written..-1) - end - -Example: - - rp, wp = IO.pipe - mesg = "ping " - 100.times { - # IO.select follows IO#read. Not the best way to use IO.select. - rs, ws, = IO.select([rp], [wp]) - if r = rs[0] - ret = r.read(5) - print ret - case ret - when /ping/ - mesg = "pong\n" - when /pong/ - mesg = "ping " - end - end - if w = ws[0] - w.write(mesg) - end - } - -Output: - - ping pong - ping pong - ping pong - (snipped) - ping - -**@overload** [] - -## set_trace_func(trace) [](#method-i-set_trace_func) -Establishes *proc* as the handler for tracing, or disables tracing if the -parameter is `nil`. - -**Note:** this method is obsolete, please use TracePoint instead. - -*proc* takes up to six parameters: - -* an event name string -* a filename string -* a line number -* a method name symbol, or nil -* a binding, or nil -* the class, module, or nil - -*proc* is invoked whenever an event occurs. - -Events are: - -`"c-call"` -: call a C-language routine - -`"c-return"` -: return from a C-language routine - -`"call"` -: call a Ruby method - -`"class"` -: start a class or module definition - -`"end"` -: finish a class or module definition - -`"line"` -: execute code on a new line - -`"raise"` -: raise an exception - -`"return"` -: return from a Ruby method - - -Tracing is disabled within the context of *proc*. - - class Test - def test - a = 1 - b = 2 - end - end - - set_trace_func proc { |event, file, line, id, binding, class_or_module| - printf "%8s %s:%-2d %16p %14p\n", event, file, line, id, class_or_module - } - t = Test.new - t.test - -Produces: - - c-return prog.rb:8 :set_trace_func Kernel - line prog.rb:11 nil nil - c-call prog.rb:11 :new Class - c-call prog.rb:11 :initialize BasicObject - c-return prog.rb:11 :initialize BasicObject - c-return prog.rb:11 :new Class - line prog.rb:12 nil nil - call prog.rb:2 :test Test - line prog.rb:3 :test Test - line prog.rb:4 :test Test - return prog.rb:5 :test Test - -**@overload** [] - -**@overload** [] - -## sleep(*args) [](#method-i-sleep) -Suspends execution of the current thread for the number of seconds specified -by numeric argument `secs`, or forever if `secs` is `nil`; returns the integer -number of seconds suspended (rounded). - - Time.new # => 2008-03-08 19:56:19 +0900 - sleep 1.2 # => 1 - Time.new # => 2008-03-08 19:56:20 +0900 - sleep 1.9 # => 2 - Time.new # => 2008-03-08 19:56:22 +0900 - -**@overload** [] - -## spawn(*args) [](#method-i-spawn) -Creates a new child process by doing one of the following in that process: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Returns the process ID (pid) of the new process, without waiting for it to -complete. - -To avoid zombie processes, the parent process should call either: - -* Process.wait, to collect the termination statuses of its children. -* Process.detach, to register disinterest in their status. - -The new process is created using the [exec system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e -xecve.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word. - Process.wait # => 798847 - spawn('exit') # => 798848 # Built-in. - Process.wait # => 798848 - spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character. - Process.wait # => 798849 - spawn('date > /nop/date.tmp') # => 798882 # Issues error message. - Process.wait # => 798882 - -The command line may also contain arguments and options for the command: - - spawn('echo "Foo"') # => 799031 - Process.wait # => 799031 - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable to be called, and - the string to be used as the name of the executing process. - - spawn('/usr/bin/date') # Path to date on Unix-style system. - Process.wait - - Output: - - Mon Aug 28 11:43:10 AM CDT 2023 - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - spawn('echo', 'C*') # => 799392 - Process.wait # => 799392 - spawn('echo', 'hello', 'world') # => 799393 - Process.wait # => 799393 - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## sprintf(*v, _) [](#method-i-sprintf) -Returns the string resulting from formatting `objects` into `format_string`. - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -**@overload** [] - -## srand(*args) [](#method-i-srand) -Seeds the system pseudo-random number generator, with `number`. The previous -seed value is returned. - -If `number` is omitted, seeds the generator using a source of entropy provided -by the operating system, if available (/dev/urandom on Unix systems or the RSA -cryptographic provider on Windows), which is then combined with the time, the -process id, and a sequence number. - -srand may be used to ensure repeatable sequences of pseudo-random numbers -between different runs of the program. By setting the seed to a known value, -programs can be made deterministic during testing. - - srand 1234 # => 268519324636777531569100071560086917274 - [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] - [ rand(10), rand(1000) ] # => [4, 664] - srand 1234 # => 1234 - [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] - -**@overload** [] - -## sub(*args) [](#method-i-sub) -Equivalent to `$_.sub(*args*)`, except that `$_` will be updated if -substitution occurs. Available only when -p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## syscall(*args) [](#method-i-syscall) -Invokes Posix system call [syscall(2)](https://linux.die.net/man/2/syscall), -which calls a specified function. - -Calls the operating system function identified by `integer_callno`; returns -the result of the function or raises SystemCallError if it failed. The effect -of the call is platform-dependent. The arguments and returned value are -platform-dependent. - -For each of `arguments`: if it is an integer, it is passed directly; if it is -a string, it is interpreted as a binary sequence of bytes. There may be as -many as nine such arguments. - -Arguments `integer_callno` and `argument`, as well as the returned value, are -platform-dependent. - -Note: Method `syscall` is essentially unsafe and unportable. The DL (Fiddle) -library is preferred for safer and a bit more portable programming. - -Not implemented on all platforms. - -**@overload** [] - -## system(*args) [](#method-i-system) -Creates a new child process by doing one of the following in that process: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Returns: - -* `true` if the command exits with status zero. -* `false` if the exit status is a non-zero integer. -* `nil` if the command could not execute. - -Raises an exception (instead of returning `false` or `nil`) if keyword -argument `exception` is set to `true`. - -Assigns the command's error status to `$?`. - -The new process is created using the [system system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/s -ystem.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - system('if true; then echo "Foo"; fi') # => true # Shell reserved word. - system('exit') # => true # Built-in. - system('date > /tmp/date.tmp') # => true # Contains meta character. - system('date > /nop/date.tmp') # => false - system('date > /nop/date.tmp', exception: true) # Raises RuntimeError. - -Assigns the command's error status to `$?`: - - system('exit') # => true # Built-in. - $? # => # - system('date > /nop/date.tmp') # => false - $? # => # - -The command line may also contain arguments and options for the command: - - system('echo "Foo"') # => true - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - system('/usr/bin/date') # => true # Path to date on Unix-style system. - system('foo') # => nil # Command failed. - -Output: - - Mon Aug 28 11:43:10 AM CDT 2023 - -Assigns the command's error status to `$?`: - - system('/usr/bin/date') # => true - $? # => # - system('foo') # => nil - $? # => # - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - - system('doesnt_exist') # => nil - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - system('echo', 'C*') # => true - system('echo', 'hello', 'world') # => true - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## tap() [](#method-i-tap) -call-seq: - obj.tap {|x| block } -> obj - - Yields self to the block and then returns self. - The primary purpose of this method is to "tap into" a method chain, - in order to perform operations on intermediate results within the chain. - - (1..10) .tap {|x| puts "original: #{x}" } - .to_a .tap {|x| puts "array: #{x}" } - .select {|x| x.even? } .tap {|x| puts "evens: #{x}" } - .map {|x| x*x } .tap {|x| puts "squares: #{x}" } - --- private ++ - -**@yield** [_self] - -**@yieldparam** [Kernel] the object that the method was called on - -## test(*args) [](#method-i-test) -:markup: markdown - -call-seq: - test(char, path0, path1 = nil) -> object - -Performs a test on one or both of the *filesystem entities* at the given paths -`path0` and `path1`: - -* Each path `path0` or `path1` points to a file, directory, device, pipe, - etc. -* Character `char` selects a specific test. - -The tests: - -* Each of these tests operates only on the entity at `path0`, and returns - `true` or `false`; for a non-existent entity, returns `false` (does not - raise exception): - - | Character | Test | - |:------------:|:--------------------------------------------------------------------------| - | 'b' | Whether the entity is a block device. | - | 'c' | Whether the entity is a character device. | - | 'd' | Whether the entity is a directory. | - | 'e' | Whether the entity is an existing entity. | - | 'f' | Whether the entity is an existing regular file. | - | 'g' | Whether the entity's setgid bit is set. | - | 'G' | Whether the entity's group ownership is equal to the caller's. | - | 'k' | Whether the entity's sticky bit is set. | - | 'l' | Whether the entity is a symbolic link. | - | 'o' | Whether the entity is owned by the caller's effective uid. | - | 'O' | Like 'o', but uses the real uid (not the effective uid). | - | 'p' | Whether the entity is a FIFO device (named pipe). | - | 'r' | Whether the entity is readable by the caller's effective uid/gid. | - | 'R' | Like 'r', but uses the real uid/gid (not the effective uid/gid). | - | 'S' | Whether the entity is a socket. | - | 'u' | Whether the entity's setuid bit is set. | - | 'w' | Whether the entity is writable by the caller's effective uid/gid. | - | 'W' | Like 'w', but uses the real uid/gid (not the effective uid/gid). | - | 'x' | Whether the entity is executable by the caller's effective uid/gid. | - | 'X' | Like 'x', but uses the real uid/gid (not the effective uid/git). | - | 'z' | Whether the entity exists and is of length zero. | - -* This test operates only on the entity at `path0`, and returns an integer - size or `nil`: - - | Character | Test | - |:------------:|:---------------------------------------------------------------------------------------------| - | 's' | Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise. | - -* Each of these tests operates only on the entity at `path0`, and returns a - Time object; raises an exception if the entity does not exist: - - | Character | Test | - |:------------:|:---------------------------------------| - | 'A' | Last access time for the entity. | - | 'C' | Last change time for the entity. | - | 'M' | Last modification time for the entity. | - -* Each of these tests operates on the modification time (`mtime`) of each of - the entities at `path0` and `path1`, and returns a `true` or `false`; - returns `false` if either entity does not exist: - - | Character | Test | - |:------------:|:----------------------------------------------------------------| - | '<' | Whether the `mtime` at `path0` is less than that at `path1`. | - | '=' | Whether the `mtime` at `path0` is equal to that at `path1`. | - | '>' | Whether the `mtime` at `path0` is greater than that at `path1`. | - -* This test operates on the content of each of the entities at `path0` and - `path1`, and returns a `true` or `false`; returns `false` if either entity - does not exist: - - | Character | Test | - |:------------:|:----------------------------------------------| - | '-' | Whether the entities exist and are identical. | - -## then() [](#method-i-then) -call-seq: - obj.then {|x| block } -> an_object - - Yields self to the block and returns the result of the block. - - 3.next.then {|x| x**x }.to_s #=> "256" - - A good use of +then+ is value piping in method chains: - - require 'open-uri' - require 'json' - - construct_url(arguments) - .then {|url| URI(url).read } - .then {|response| JSON.parse(response) } - - When called without a block, the method returns an +Enumerator+, - which can be used, for example, for conditional - circuit-breaking: - - # Meets condition, no-op - 1.then.detect(&:odd?) # => 1 - # Does not meet condition, drop value - 2.then.detect(&:odd?) # => nil - -**@yield** [_self] - -**@yieldparam** [Kernel] the object that the method was called on - -## throw(*args) [](#method-i-throw) -Transfers control to the end of the active `catch` block waiting for *tag*. -Raises `UncaughtThrowError` if there is no `catch` block for the *tag*. The -optional second parameter supplies a return value for the `catch` block, which -otherwise defaults to `nil`. For examples, see Kernel::catch. - -**@overload** [] - -## trace_var(*a, _) [](#method-i-trace_var) -Controls tracing of assignments to global variables. The parameter `symbol` -identifies the variable (as either a string name or a symbol identifier). -*cmd* (which may be a string or a `Proc` object) or block is executed whenever -the variable is assigned. The block or `Proc` object receives the variable's -new value as a parameter. Also see #untrace_var. - - trace_var :$_, proc {|v| puts "$_ is now '#{v}'" } - $_ = "hello" - $_ = ' there' - -*produces:* - - $_ is now 'hello' - $_ is now ' there' - -**@overload** [] - -**@overload** [] - -## trap(*args) [](#method-i-trap) -Specifies the handling of signals. The first parameter is a signal name (a -string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The -characters ``SIG'' may be omitted from the signal name. The command or block -specifies code to be run when the signal is raised. If the command is the -string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command -is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If -the command is ``EXIT'', the script will be terminated by the signal. If the -command is ``SYSTEM_DEFAULT'', the operating system's default handler will be -invoked. Otherwise, the given command or block will be run. The special signal -name ``EXIT'' or signal number zero will be invoked just prior to program -termination. trap returns the previous handler for the given signal. - - Signal.trap(0, proc { puts "Terminating: #{$$}" }) - Signal.trap("CLD") { puts "Child died" } - fork && Process.wait - -*produces:* - Terminating: 27461 - Child died - Terminating: 27460 - -**@overload** [] - -**@overload** [] - -## untrace_var(*a, _) [](#method-i-untrace_var) -Removes tracing for the specified command on the given global variable and -returns `nil`. If no command is specified, removes all tracing for that -variable and returns an array containing the commands actually removed. - -**@overload** [] - diff --git a/example/ruby/KernelSpecs.md b/example/ruby/KernelSpecs.md deleted file mode 100644 index 01a6e4f..0000000 --- a/example/ruby/KernelSpecs.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: KernelSpecs - - - - -# Class Methods -## Array_function(arg ) [](#method-c-Array_function) -## Array_method(arg ) [](#method-c-Array_method) -## Complex_method(string ) [](#method-c-Complex_method) -## Hash_function(arg ) [](#method-c-Hash_function) -## Hash_method(arg ) [](#method-c-Hash_method) -## Integer_function(arg ) [](#method-c-Integer_function) -## Integer_method(arg ) [](#method-c-Integer_method) -## chomp(str , method , sep "\n") [](#method-c-chomp) -## chop(str , method ) [](#method-c-chop) -## has_private_method(name ) [](#method-c-has_private_method) -## putc_function(arg ) [](#method-c-putc_function) -## putc_method(arg ) [](#method-c-putc_method) -## run_with_dash_n(file ) [](#method-c-run_with_dash_n) - diff --git a/example/ruby/KernelSpecs/A.md b/example/ruby/KernelSpecs/A.md deleted file mode 100644 index edd3c23..0000000 --- a/example/ruby/KernelSpecs/A.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: KernelSpecs::A -**Inherits:** Object - - - - - -#Instance Methods -## pub_method() [](#method-i-pub_method) -There is Kernel#public_method, so we don't want this one to clash - -## undefed_method() [](#method-i-undefed_method) - diff --git a/example/ruby/KernelSpecs/AncestorClass.md b/example/ruby/KernelSpecs/AncestorClass.md deleted file mode 100644 index e402621..0000000 --- a/example/ruby/KernelSpecs/AncestorClass.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: KernelSpecs::AncestorClass -**Inherits:** String - -**Includes:** KernelSpecs::AncestorModule - - - - - diff --git a/example/ruby/KernelSpecs/AncestorModule.md b/example/ruby/KernelSpecs/AncestorModule.md deleted file mode 100644 index ab6ce84..0000000 --- a/example/ruby/KernelSpecs/AncestorModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: KernelSpecs::AncestorModule - - - - - diff --git a/example/ruby/KernelSpecs/AutoloadMethod.md b/example/ruby/KernelSpecs/AutoloadMethod.md deleted file mode 100644 index 826bdff..0000000 --- a/example/ruby/KernelSpecs/AutoloadMethod.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::AutoloadMethod - - - - - -#Instance Methods -## setup_autoload(file) [](#method-i-setup_autoload) - diff --git a/example/ruby/KernelSpecs/AutoloadMethod/AutoloadFromIncludedModule.md b/example/ruby/KernelSpecs/AutoloadMethod/AutoloadFromIncludedModule.md deleted file mode 100644 index e27e63e..0000000 --- a/example/ruby/KernelSpecs/AutoloadMethod/AutoloadFromIncludedModule.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: KernelSpecs::AutoloadMethod::AutoloadFromIncludedModule - - - - -# Class Methods -## loaded() [](#method-c-loaded) - diff --git a/example/ruby/KernelSpecs/AutoloadMethod2.md b/example/ruby/KernelSpecs/AutoloadMethod2.md deleted file mode 100644 index e35e1e2..0000000 --- a/example/ruby/KernelSpecs/AutoloadMethod2.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::AutoloadMethod2 - - - - - -#Instance Methods -## setup_autoload(file) [](#method-i-setup_autoload) - diff --git a/example/ruby/KernelSpecs/AutoloadMethod2/AutoloadFromIncludedModule2.md b/example/ruby/KernelSpecs/AutoloadMethod2/AutoloadFromIncludedModule2.md deleted file mode 100644 index b82efbe..0000000 --- a/example/ruby/KernelSpecs/AutoloadMethod2/AutoloadFromIncludedModule2.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: KernelSpecs::AutoloadMethod2::AutoloadFromIncludedModule2 - - - - -# Class Methods -## loaded() [](#method-c-loaded) - diff --git a/example/ruby/KernelSpecs/AutoloadMethodIncluder.md b/example/ruby/KernelSpecs/AutoloadMethodIncluder.md deleted file mode 100644 index 796b751..0000000 --- a/example/ruby/KernelSpecs/AutoloadMethodIncluder.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: KernelSpecs::AutoloadMethodIncluder -**Inherits:** Object - -**Includes:** KernelSpecs::AutoloadMethod - - - - - -#Instance Methods -## setup_autoload(file) [](#method-i-setup_autoload) - diff --git a/example/ruby/KernelSpecs/AutoloadMethodIncluder2.md b/example/ruby/KernelSpecs/AutoloadMethodIncluder2.md deleted file mode 100644 index aa6add2..0000000 --- a/example/ruby/KernelSpecs/AutoloadMethodIncluder2.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: KernelSpecs::AutoloadMethodIncluder2 -**Inherits:** Object - -**Includes:** KernelSpecs::AutoloadMethod2 - - - - - -#Instance Methods -## setup_autoload(file) [](#method-i-setup_autoload) - diff --git a/example/ruby/KernelSpecs/B.md b/example/ruby/KernelSpecs/B.md deleted file mode 100644 index d5288cd..0000000 --- a/example/ruby/KernelSpecs/B.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: KernelSpecs::B -**Inherits:** KernelSpecs::A - - - - - diff --git a/example/ruby/KernelSpecs/Binding.md b/example/ruby/KernelSpecs/Binding.md deleted file mode 100644 index 6d7a59d..0000000 --- a/example/ruby/KernelSpecs/Binding.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: KernelSpecs::Binding -**Inherits:** Object - - - - - -#Instance Methods -## get_binding() [](#method-i-get_binding) - -## initialize(n) [](#method-i-initialize) - -**@return** [Binding] a new instance of Binding - -## square(n) [](#method-i-square) - diff --git a/example/ruby/KernelSpecs/BlockGiven.md b/example/ruby/KernelSpecs/BlockGiven.md deleted file mode 100644 index 558bb4e..0000000 --- a/example/ruby/KernelSpecs/BlockGiven.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::BlockGiven - - - - -# Class Methods -## accept_block() [](#method-c-accept_block) -## accept_block_as_argument(&block ) [](#method-c-accept_block_as_argument) - diff --git a/example/ruby/KernelSpecs/CalleeTest.md b/example/ruby/KernelSpecs/CalleeTest.md deleted file mode 100644 index 0254821..0000000 --- a/example/ruby/KernelSpecs/CalleeTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: KernelSpecs::CalleeTest -**Inherits:** Object - - - - - -#Instance Methods -## f() [](#method-i-f) - -## from_class_body() [](#method-i-from_class_body) - -## from_eval() [](#method-i-from_eval) - -## from_send() [](#method-i-from_send) - -## in_block() [](#method-i-in_block) - diff --git a/example/ruby/KernelSpecs/CallerLocationsTest.md b/example/ruby/KernelSpecs/CallerLocationsTest.md deleted file mode 100644 index 7aa8b9b..0000000 --- a/example/ruby/KernelSpecs/CallerLocationsTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: KernelSpecs::CallerLocationsTest -**Inherits:** Object - - - - -# Class Methods -## locations(*args ) [](#method-c-locations) - diff --git a/example/ruby/KernelSpecs/CallerTest.md b/example/ruby/KernelSpecs/CallerTest.md deleted file mode 100644 index 1748bc2..0000000 --- a/example/ruby/KernelSpecs/CallerTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: KernelSpecs::CallerTest -**Inherits:** Object - - - - -# Class Methods -## locations(*args ) [](#method-c-locations) - diff --git a/example/ruby/KernelSpecs/Child.md b/example/ruby/KernelSpecs/Child.md deleted file mode 100644 index c097856..0000000 --- a/example/ruby/KernelSpecs/Child.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: KernelSpecs::Child -**Inherits:** KernelSpecs::Parent - - - - - diff --git a/example/ruby/KernelSpecs/ClassMM.md b/example/ruby/KernelSpecs/ClassMM.md deleted file mode 100644 index 64f43b3..0000000 --- a/example/ruby/KernelSpecs/ClassMM.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: KernelSpecs::ClassMM -**Inherits:** KernelSpecs::ClassNoMM - - - - -# Class Methods -## method_missing(*args ) [](#method-c-method_missing) - -#Instance Methods -## method_missing(*args) [](#method-i-method_missing) - diff --git a/example/ruby/KernelSpecs/ClassNoMM.md b/example/ruby/KernelSpecs/ClassNoMM.md deleted file mode 100644 index 3ab8448..0000000 --- a/example/ruby/KernelSpecs/ClassNoMM.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: KernelSpecs::ClassNoMM -**Inherits:** Object - - - - -# Class Methods -## method_private() [](#method-c-method_private) -## method_protected() [](#method-c-method_protected) -## method_public() [](#method-c-method_public) - -#Instance Methods -## method_public() [](#method-i-method_public) - diff --git a/example/ruby/KernelSpecs/Clone.md b/example/ruby/KernelSpecs/Clone.md deleted file mode 100644 index d5a42cf..0000000 --- a/example/ruby/KernelSpecs/Clone.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: KernelSpecs::Clone -**Inherits:** Object - - - - - -#Instance Methods -## initialize_clone(other) [](#method-i-initialize_clone) - diff --git a/example/ruby/KernelSpecs/CloneFreeze.md b/example/ruby/KernelSpecs/CloneFreeze.md deleted file mode 100644 index 7f171de..0000000 --- a/example/ruby/KernelSpecs/CloneFreeze.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: KernelSpecs::CloneFreeze -**Inherits:** Object - - - - - -#Instance Methods -## initialize_clone(other, **kwargs) [](#method-i-initialize_clone) - diff --git a/example/ruby/KernelSpecs/CustomRangeFloat.md b/example/ruby/KernelSpecs/CustomRangeFloat.md deleted file mode 100644 index 2170f6e..0000000 --- a/example/ruby/KernelSpecs/CustomRangeFloat.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: KernelSpecs::CustomRangeFloat -**Inherits:** Struct - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value - -**@return** [Object] the current value of value - - -#Instance Methods -## +(other) [](#method-i-+) - -## -(other) [](#method-i--) - -## <=>(other) [](#method-i-<=>) - -## to_f() [](#method-i-to_f) - diff --git a/example/ruby/KernelSpecs/CustomRangeInteger.md b/example/ruby/KernelSpecs/CustomRangeInteger.md deleted file mode 100644 index 3736bae..0000000 --- a/example/ruby/KernelSpecs/CustomRangeInteger.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: KernelSpecs::CustomRangeInteger -**Inherits:** Struct - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value - -**@return** [Object] the current value of value - - -#Instance Methods -## +(other) [](#method-i-+) - -## -(other) [](#method-i--) - -## <=>(other) [](#method-i-<=>) - -## to_int() [](#method-i-to_int) - diff --git a/example/ruby/KernelSpecs/Dup.md b/example/ruby/KernelSpecs/Dup.md deleted file mode 100644 index 2b8dea3..0000000 --- a/example/ruby/KernelSpecs/Dup.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: KernelSpecs::Dup -**Inherits:** Object - - - - - -#Instance Methods -## initialize_dup(other) [](#method-i-initialize_dup) - diff --git a/example/ruby/KernelSpecs/Duplicate.md b/example/ruby/KernelSpecs/Duplicate.md deleted file mode 100644 index 9ac6cb4..0000000 --- a/example/ruby/KernelSpecs/Duplicate.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: KernelSpecs::Duplicate -**Inherits:** Object - - - - -# Attributes -## one[RW] [](#attribute-i-one) -Returns the value of attribute one. - -## two[RW] [](#attribute-i-two) -Returns the value of attribute two. - - -#Instance Methods -## initialize(one, two) [](#method-i-initialize) - -**@return** [Duplicate] a new instance of Duplicate - -## initialize_clone(other, **kw) [](#method-i-initialize_clone) -define to support calling #clone with optional :freeze keyword argument - -## initialize_copy(other, **kw) [](#method-i-initialize_copy) - diff --git a/example/ruby/KernelSpecs/DuplicateM.md b/example/ruby/KernelSpecs/DuplicateM.md deleted file mode 100644 index 0488bf8..0000000 --- a/example/ruby/KernelSpecs/DuplicateM.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::DuplicateM - - - - - -#Instance Methods -## repr() [](#method-i-repr) - diff --git a/example/ruby/KernelSpecs/EvalTest.md b/example/ruby/KernelSpecs/EvalTest.md deleted file mode 100644 index 85bfc83..0000000 --- a/example/ruby/KernelSpecs/EvalTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: KernelSpecs::EvalTest -**Inherits:** Object - - - - -# Class Methods -## call_yield() [](#method-c-call_yield) -## eval_yield_with_binding() [](#method-c-eval_yield_with_binding) - diff --git a/example/ruby/KernelSpecs/Grandchild.md b/example/ruby/KernelSpecs/Grandchild.md deleted file mode 100644 index a7a267c..0000000 --- a/example/ruby/KernelSpecs/Grandchild.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: KernelSpecs::Grandchild -**Inherits:** KernelSpecs::Child - - - - - diff --git a/example/ruby/KernelSpecs/InstanceClass.md b/example/ruby/KernelSpecs/InstanceClass.md deleted file mode 100644 index e53c30d..0000000 --- a/example/ruby/KernelSpecs/InstanceClass.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: KernelSpecs::InstanceClass -**Inherits:** KernelSpecs::AncestorClass - -**Includes:** KernelSpecs::MyModule - - - - - diff --git a/example/ruby/KernelSpecs/InstanceVariable.md b/example/ruby/KernelSpecs/InstanceVariable.md deleted file mode 100644 index 16791e3..0000000 --- a/example/ruby/KernelSpecs/InstanceVariable.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: KernelSpecs::InstanceVariable -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [InstanceVariable] a new instance of InstanceVariable - diff --git a/example/ruby/KernelSpecs/KernelBlockGiven.md b/example/ruby/KernelSpecs/KernelBlockGiven.md deleted file mode 100644 index e2e9bcc..0000000 --- a/example/ruby/KernelSpecs/KernelBlockGiven.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::KernelBlockGiven - - - - -# Class Methods -## accept_block() [](#method-c-accept_block) -## accept_block_as_argument(&block ) [](#method-c-accept_block_as_argument) - diff --git a/example/ruby/KernelSpecs/KindaClass.md b/example/ruby/KernelSpecs/KindaClass.md deleted file mode 100644 index 6ab85ce..0000000 --- a/example/ruby/KernelSpecs/KindaClass.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: KernelSpecs::KindaClass -**Inherits:** KernelSpecs::AncestorClass - -**Includes:** KernelSpecs::MyModule, KernelSpecs::MyPrependedModule - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [KindaClass] a new instance of KindaClass - diff --git a/example/ruby/KernelSpecs/Lambda.md b/example/ruby/KernelSpecs/Lambda.md deleted file mode 100644 index ae21ebe..0000000 --- a/example/ruby/KernelSpecs/Lambda.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: KernelSpecs::Lambda -**Inherits:** Object - - -for testing lambda - - - -#Instance Methods -## inner() [](#method-i-inner) - -## mp(&b) [](#method-i-mp) - -## outer() [](#method-i-outer) - diff --git a/example/ruby/KernelSpecs/LambdaSpecs.md b/example/ruby/KernelSpecs/LambdaSpecs.md deleted file mode 100644 index 5c87ef5..0000000 --- a/example/ruby/KernelSpecs/LambdaSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: KernelSpecs::LambdaSpecs - - - - - diff --git a/example/ruby/KernelSpecs/LambdaSpecs/Ampersand.md b/example/ruby/KernelSpecs/LambdaSpecs/Ampersand.md deleted file mode 100644 index 3f03d96..0000000 --- a/example/ruby/KernelSpecs/LambdaSpecs/Ampersand.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::LambdaSpecs::Ampersand - - - - - -#Instance Methods -## lambda(&block) [](#method-i-lambda) - diff --git a/example/ruby/KernelSpecs/LambdaSpecs/ForwardBlockWithZSuper.md b/example/ruby/KernelSpecs/LambdaSpecs/ForwardBlockWithZSuper.md deleted file mode 100644 index 0bfe0e6..0000000 --- a/example/ruby/KernelSpecs/LambdaSpecs/ForwardBlockWithZSuper.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: KernelSpecs::LambdaSpecs::ForwardBlockWithZSuper -**Inherits:** Object - -**Includes:** KernelSpecs::LambdaSpecs::ZSuper - - - - - -#Instance Methods -## lambda() [](#method-i-lambda) - diff --git a/example/ruby/KernelSpecs/LambdaSpecs/SuperAmpersand.md b/example/ruby/KernelSpecs/LambdaSpecs/SuperAmpersand.md deleted file mode 100644 index fbadf01..0000000 --- a/example/ruby/KernelSpecs/LambdaSpecs/SuperAmpersand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: KernelSpecs::LambdaSpecs::SuperAmpersand -**Inherits:** Object - -**Includes:** KernelSpecs::LambdaSpecs::Ampersand - - - - - -#Instance Methods -## lambda(&block) [](#method-i-lambda) - diff --git a/example/ruby/KernelSpecs/LambdaSpecs/ZSuper.md b/example/ruby/KernelSpecs/LambdaSpecs/ZSuper.md deleted file mode 100644 index 28cfa7d..0000000 --- a/example/ruby/KernelSpecs/LambdaSpecs/ZSuper.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::LambdaSpecs::ZSuper - - - - - -#Instance Methods -## lambda() [](#method-i-lambda) - diff --git a/example/ruby/KernelSpecs/M.md b/example/ruby/KernelSpecs/M.md deleted file mode 100644 index 6779ed8..0000000 --- a/example/ruby/KernelSpecs/M.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: KernelSpecs::M - - - - -# Class Methods -## append_features(o ) [](#method-c-append_features) -## extend_object(o ) [](#method-c-extend_object) -## extended(o ) [](#method-c-extended) -**@private** [] - - diff --git a/example/ruby/KernelSpecs/Method.md b/example/ruby/KernelSpecs/Method.md deleted file mode 100644 index c762549..0000000 --- a/example/ruby/KernelSpecs/Method.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: KernelSpecs::Method -**Inherits:** Object - - - - - diff --git a/example/ruby/KernelSpecs/MethodTest.md b/example/ruby/KernelSpecs/MethodTest.md deleted file mode 100644 index c0cd6cf..0000000 --- a/example/ruby/KernelSpecs/MethodTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: KernelSpecs::MethodTest -**Inherits:** Object - - - - - -#Instance Methods -## f() [](#method-i-f) - -## from_class_body() [](#method-i-from_class_body) - -## from_eval() [](#method-i-from_eval) - -## from_send() [](#method-i-from_send) - -## in_block() [](#method-i-in_block) - diff --git a/example/ruby/KernelSpecs/Methods.md b/example/ruby/KernelSpecs/Methods.md deleted file mode 100644 index 7bb84e9..0000000 --- a/example/ruby/KernelSpecs/Methods.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: KernelSpecs::Methods -**Inherits:** Object - - - - -# Class Methods -## ichi() [](#method-c-ichi) -## juu() [](#method-c-juu) -## juu_ni() [](#method-c-juu_ni) -## roku() [](#method-c-roku) -## san() [](#method-c-san) - -#Instance Methods -## juu_san() [](#method-i-juu_san) - -## ni() [](#method-i-ni) - diff --git a/example/ruby/KernelSpecs/Methods/MetaclassMethods.md b/example/ruby/KernelSpecs/Methods/MetaclassMethods.md deleted file mode 100644 index 31c4ebf..0000000 --- a/example/ruby/KernelSpecs/Methods/MetaclassMethods.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::Methods::MetaclassMethods - - - - - -#Instance Methods -## peekaboo() [](#method-i-peekaboo) - diff --git a/example/ruby/KernelSpecs/ModuleMM.md b/example/ruby/KernelSpecs/ModuleMM.md deleted file mode 100644 index 5c975ad..0000000 --- a/example/ruby/KernelSpecs/ModuleMM.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: KernelSpecs::ModuleMM - - - - -# Class Methods -## method_missing(*args ) [](#method-c-method_missing) -## method_private() [](#method-c-method_private) -## method_protected() [](#method-c-method_protected) -## method_public() [](#method-c-method_public) - diff --git a/example/ruby/KernelSpecs/ModuleNoMM.md b/example/ruby/KernelSpecs/ModuleNoMM.md deleted file mode 100644 index afbb3e0..0000000 --- a/example/ruby/KernelSpecs/ModuleNoMM.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: KernelSpecs::ModuleNoMM - - - - -# Class Methods -## method_private() [](#method-c-method_private) -## method_protected() [](#method-c-method_protected) -## method_public() [](#method-c-method_public) - diff --git a/example/ruby/KernelSpecs/MyExtensionModule.md b/example/ruby/KernelSpecs/MyExtensionModule.md deleted file mode 100644 index f50697f..0000000 --- a/example/ruby/KernelSpecs/MyExtensionModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: KernelSpecs::MyExtensionModule - - - - - diff --git a/example/ruby/KernelSpecs/MyModule.md b/example/ruby/KernelSpecs/MyModule.md deleted file mode 100644 index 1e98a12..0000000 --- a/example/ruby/KernelSpecs/MyModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: KernelSpecs::MyModule - - - - - diff --git a/example/ruby/KernelSpecs/MyPrependedModule.md b/example/ruby/KernelSpecs/MyPrependedModule.md deleted file mode 100644 index 050a03b..0000000 --- a/example/ruby/KernelSpecs/MyPrependedModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: KernelSpecs::MyPrependedModule - - - - - diff --git a/example/ruby/KernelSpecs/Parent.md b/example/ruby/KernelSpecs/Parent.md deleted file mode 100644 index 4aca8ac..0000000 --- a/example/ruby/KernelSpecs/Parent.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: KernelSpecs::Parent -**Inherits:** Object - -**Includes:** KernelSpecs::ParentMixin - - - - -# Class Methods -## parent_class_method() [](#method-c-parent_class_method) - -#Instance Methods -## another_parent_method() [](#method-i-another_parent_method) - -## parent_method() [](#method-i-parent_method) - -## parent_mixin_method() [](#method-i-parent_mixin_method) - diff --git a/example/ruby/KernelSpecs/ParentMixin.md b/example/ruby/KernelSpecs/ParentMixin.md deleted file mode 100644 index bae96ba..0000000 --- a/example/ruby/KernelSpecs/ParentMixin.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::ParentMixin - - - - - -#Instance Methods -## parent_mixin_method() [](#method-i-parent_mixin_method) - diff --git a/example/ruby/KernelSpecs/PrivateSup.md b/example/ruby/KernelSpecs/PrivateSup.md deleted file mode 100644 index 4546344..0000000 --- a/example/ruby/KernelSpecs/PrivateSup.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: KernelSpecs::PrivateSup -**Inherits:** Object - - - - - diff --git a/example/ruby/KernelSpecs/PrivateToA.md b/example/ruby/KernelSpecs/PrivateToA.md deleted file mode 100644 index c68e03c..0000000 --- a/example/ruby/KernelSpecs/PrivateToA.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: KernelSpecs::PrivateToA -**Inherits:** Object - - - - - diff --git a/example/ruby/KernelSpecs/PrivateToAry.md b/example/ruby/KernelSpecs/PrivateToAry.md deleted file mode 100644 index 2a7d808..0000000 --- a/example/ruby/KernelSpecs/PrivateToAry.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: KernelSpecs::PrivateToAry -**Inherits:** Object - - - - - diff --git a/example/ruby/KernelSpecs/PublicSub.md b/example/ruby/KernelSpecs/PublicSub.md deleted file mode 100644 index cd0f5a0..0000000 --- a/example/ruby/KernelSpecs/PublicSub.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: KernelSpecs::PublicSub -**Inherits:** KernelSpecs::PrivateSup - - - - - -#Instance Methods -## public_in_sub() [](#method-i-public_in_sub) - diff --git a/example/ruby/KernelSpecs/RespondViaMissing.md b/example/ruby/KernelSpecs/RespondViaMissing.md deleted file mode 100644 index 1d59d3b..0000000 --- a/example/ruby/KernelSpecs/RespondViaMissing.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: KernelSpecs::RespondViaMissing -**Inherits:** Object - - - - - -#Instance Methods -## method_missing(method, *args) [](#method-i-method_missing) - -## respond_to_missing?(method, privfalse) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - diff --git a/example/ruby/KernelSpecs/SelfBlockGiven.md b/example/ruby/KernelSpecs/SelfBlockGiven.md deleted file mode 100644 index 9803718..0000000 --- a/example/ruby/KernelSpecs/SelfBlockGiven.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: KernelSpecs::SelfBlockGiven - - - - -# Class Methods -## accept_block() [](#method-c-accept_block) -## accept_block_as_argument(&block ) [](#method-c-accept_block_as_argument) - diff --git a/example/ruby/KernelSpecs/SomeOtherModule.md b/example/ruby/KernelSpecs/SomeOtherModule.md deleted file mode 100644 index 1c20751..0000000 --- a/example/ruby/KernelSpecs/SomeOtherModule.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: KernelSpecs::SomeOtherModule - - -kind_of?, is_a?, instance_of? - - - diff --git a/example/ruby/KernelSpecs/VisibilityChange.md b/example/ruby/KernelSpecs/VisibilityChange.md deleted file mode 100644 index ad29b39..0000000 --- a/example/ruby/KernelSpecs/VisibilityChange.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: KernelSpecs::VisibilityChange -**Inherits:** Object - - - - - diff --git a/example/ruby/KernelSpecs/WarnInNestedCall.md b/example/ruby/KernelSpecs/WarnInNestedCall.md deleted file mode 100644 index ada5055..0000000 --- a/example/ruby/KernelSpecs/WarnInNestedCall.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: KernelSpecs::WarnInNestedCall -**Inherits:** Object - - - - - -#Instance Methods -## f1(s, n) [](#method-i-f1) - -## f1_call_lineno() [](#method-i-f1_call_lineno) - -## f2(s, n) [](#method-i-f2) - -## f2_call_lineno() [](#method-i-f2_call_lineno) - -## f3(s, n) [](#method-i-f3) - -## f3_call_lineno() [](#method-i-f3_call_lineno) - -## f4(s"", n) [](#method-i-f4) - -## warn_call_lineno() [](#method-i-warn_call_lineno) - diff --git a/example/ruby/KeyError.md b/example/ruby/KeyError.md deleted file mode 100644 index 7c75acf..0000000 --- a/example/ruby/KeyError.md +++ /dev/null @@ -1,28 +0,0 @@ -# Exception: KeyError -**Inherits:** IndexError - - -Raised when the specified key is not found. It is a subclass of IndexError. - - h = {"foo" => :bar} - h.fetch("foo") #=> :bar - h.fetch("baz") #=> KeyError: key not found: "baz" - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Construct a new `KeyError` exception with the given message, receiver and key. - -**@overload** [] - -## key() [](#method-i-key) -Return the key caused this KeyError exception. - -**@overload** [] - -## receiver() [](#method-i-receiver) -Return the receiver associated with this KeyError exception. - -**@overload** [] - diff --git a/example/ruby/KeyNameCheckTest.md b/example/ruby/KeyNameCheckTest.md deleted file mode 100644 index adc352c..0000000 --- a/example/ruby/KeyNameCheckTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: KeyNameCheckTest -**Inherits:** Test::Unit::TestCase - -**Includes:** DidYouMean::TestHelper - - - - - -#Instance Methods -## assert_correction(expected, array) [](#method-i-assert_correction) - -## test_correct_symbolized_hash_keys_with_string_value() [](#method-i-test_correct_symbolized_hash_keys_with_string_value) - -## test_corrects_env_key_name() [](#method-i-test_corrects_env_key_name) - -## test_corrects_hash_key_name_with_fetch() [](#method-i-test_corrects_hash_key_name_with_fetch) - -## test_corrects_hash_key_name_with_fetch_values() [](#method-i-test_corrects_hash_key_name_with_fetch_values) - -## test_corrects_sprintf_key_name() [](#method-i-test_corrects_sprintf_key_name) - diff --git a/example/ruby/LangSendSpecs.md b/example/ruby/LangSendSpecs.md deleted file mode 100644 index eb51ca5..0000000 --- a/example/ruby/LangSendSpecs.md +++ /dev/null @@ -1,52 +0,0 @@ -# Module: LangSendSpecs - - - - -# Class Methods -## destructure2(a,b ) [](#method-c-destructure2) -## destructure2b(a,b ) [](#method-c-destructure2b) -## destructure4o(a 1, b,c , d , &e ) [](#method-c-destructure4o) -## destructure4os(a 1, b,*c ) [](#method-c-destructure4os) -## destructure4r(a,b,*c,d,e ) [](#method-c-destructure4r) -## destructure5o(a 1, f 2, b,c , d , &e ) [](#method-c-destructure5o) -## destructure7b(a 1, f 2, b,c , d,e , &g ) [](#method-c-destructure7b) -## destructure7o(a 1, f 2, b,c , d,e , &g ) [](#method-c-destructure7o) -## double(x ) [](#method-c-double) -## fooM0() [](#method-c-fooM0) -## fooM0O1(a 1) [](#method-c-fooM0O1) -## fooM0O1R(a 1, *r ) [](#method-c-fooM0O1R) -## fooM0O2(a 1, b 2) [](#method-c-fooM0O2) -## fooM0R(*r ) [](#method-c-fooM0R) -## fooM0RQ1(*r , q ) [](#method-c-fooM0RQ1) -## fooM0RQ2(*r , s , q ) [](#method-c-fooM0RQ2) -## fooM1(a ) [](#method-c-fooM1) -## fooM1O1(a , b 1) [](#method-c-fooM1O1) -## fooM1O1Q1(a , b 2, c ) [](#method-c-fooM1O1Q1) -## fooM1O1R(a , b 1, *r ) [](#method-c-fooM1O1R) -## fooM1O1RQ1(a , b 9, *r , q ) [](#method-c-fooM1O1RQ1) -## fooM1O1RQ2(a , b 9, *r , q , t ) [](#method-c-fooM1O1RQ2) -## fooM1R(a , *r ) [](#method-c-fooM1R) -## fooM1RQ1(a , *r , q ) [](#method-c-fooM1RQ1) -## fooM2(a , b ) [](#method-c-fooM2) -## fooM2O1(a , b , c 1) [](#method-c-fooM2O1) -## fooM2O1Q1(a , b , c 3, d ) [](#method-c-fooM2O1Q1) -## fooM2O2Q1(a , b , c 3, d 4, e ) [](#method-c-fooM2O2Q1) -## fooM3(a , b , c ) [](#method-c-fooM3) -## fooM3O1(a , b , c , d 1) [](#method-c-fooM3O1) -## fooM4(a , b , c , d ) [](#method-c-fooM4) -## fooM4O1(a , b , c , d , e 1) [](#method-c-fooM4O1) -## fooM5(a , b , c , d , e ) [](#method-c-fooM5) -## fooO1Q1(a 1, b ) [](#method-c-fooO1Q1) -## fooO4Q1(a 1, b 2, c 3, d 4, e ) [](#method-c-fooO4Q1) -## fooO4Q2(a 1, b 2, c 3, d 4, e , f ) [](#method-c-fooO4Q2) -## fooR(*r ) [](#method-c-fooR) -## makeproc(&b ) [](#method-c-makeproc) -## one(a ) [](#method-c-one) -## oneb(a , &b ) [](#method-c-oneb) -## rest_len(*a ) [](#method-c-rest_len) -## twob(a , b , &c ) [](#method-c-twob) -## twos(a , b , *c ) [](#method-c-twos) -## weird_parens() [](#method-c-weird_parens) -## yield_now() [](#method-c-yield_now) - diff --git a/example/ruby/LangSendSpecs/Attr19Set.md b/example/ruby/LangSendSpecs/Attr19Set.md deleted file mode 100644 index 84521f4..0000000 --- a/example/ruby/LangSendSpecs/Attr19Set.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: LangSendSpecs::Attr19Set -**Inherits:** Object - - - - -# Attributes -## result[RW] [](#attribute-i-result) -Returns the value of attribute result. - - -#Instance Methods -## []=(*args) [](#method-i-[]=) - diff --git a/example/ruby/LangSendSpecs/AttrSet.md b/example/ruby/LangSendSpecs/AttrSet.md deleted file mode 100644 index 1114e62..0000000 --- a/example/ruby/LangSendSpecs/AttrSet.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: LangSendSpecs::AttrSet -**Inherits:** Object - - - - -# Attributes -## result[RW] [](#attribute-i-result) -Returns the value of attribute result. - - -#Instance Methods -## []=(a, b, c, d) [](#method-i-[]=) - diff --git a/example/ruby/LangSendSpecs/MethodMissing.md b/example/ruby/LangSendSpecs/MethodMissing.md deleted file mode 100644 index ed83eef..0000000 --- a/example/ruby/LangSendSpecs/MethodMissing.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: LangSendSpecs::MethodMissing -**Inherits:** Object - - - - -# Attributes -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## message[RW] [](#attribute-i-message) -Returns the value of attribute message. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MethodMissing] a new instance of MethodMissing - -## method_missing(m, *a) [](#method-i-method_missing) - diff --git a/example/ruby/LangSendSpecs/PrivateGetter.md b/example/ruby/LangSendSpecs/PrivateGetter.md deleted file mode 100644 index bb1effd..0000000 --- a/example/ruby/LangSendSpecs/PrivateGetter.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: LangSendSpecs::PrivateGetter -**Inherits:** Object - - - - - -#Instance Methods -## call_self_foo() [](#method-i-call_self_foo) - -## call_self_foo_or_equals(value) [](#method-i-call_self_foo_or_equals) - diff --git a/example/ruby/LangSendSpecs/PrivateSetter.md b/example/ruby/LangSendSpecs/PrivateSetter.md deleted file mode 100644 index 02a79ce..0000000 --- a/example/ruby/LangSendSpecs/PrivateSetter.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: LangSendSpecs::PrivateSetter -**Inherits:** Object - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - -#Instance Methods -## call_self_foo_equals(value) [](#method-i-call_self_foo_equals) - -## call_self_foo_equals_masgn(value) [](#method-i-call_self_foo_equals_masgn) - diff --git a/example/ruby/LangSendSpecs/ToAry.md b/example/ruby/LangSendSpecs/ToAry.md deleted file mode 100644 index 6ea9946..0000000 --- a/example/ruby/LangSendSpecs/ToAry.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: LangSendSpecs::ToAry -**Inherits:** Object - - - - - -#Instance Methods -## initialize(obj) [](#method-i-initialize) - -**@return** [ToAry] a new instance of ToAry - -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/LangSendSpecs/ToProc.md b/example/ruby/LangSendSpecs/ToProc.md deleted file mode 100644 index e9e2e2f..0000000 --- a/example/ruby/LangSendSpecs/ToProc.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: LangSendSpecs::ToProc -**Inherits:** Object - - - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -**@return** [ToProc] a new instance of ToProc - -## to_proc() [](#method-i-to_proc) - diff --git a/example/ruby/LanguageSpecs.md b/example/ruby/LanguageSpecs.md deleted file mode 100644 index bd80180..0000000 --- a/example/ruby/LanguageSpecs.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: LanguageSpecs - - - - -# Class Methods -## blanks() [](#method-c-blanks) -## get_regexp_with_substitution(o ) [](#method-c-get_regexp_with_substitution) -## non_alphanum_non_space() [](#method-c-non_alphanum_non_space) -## non_paired_delimiters() [](#method-c-non_paired_delimiters) -## paired_delimiters() [](#method-c-paired_delimiters) -Regexp support -## punctuations() [](#method-c-punctuations) -## white_spaces() [](#method-c-white_spaces) - diff --git a/example/ruby/Launchable.md b/example/ruby/Launchable.md deleted file mode 100644 index 11f9f3b..0000000 --- a/example/ruby/Launchable.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Launchable - - -Module for writing a test file for uploading test results into Launchable. In -bootstraptest, we aggregate the test results based on file level. - - - -#Instance Methods -## show_progress(message'') [](#method-i-show_progress) - diff --git a/example/ruby/Launchable/JsonStreamWriter.md b/example/ruby/Launchable/JsonStreamWriter.md deleted file mode 100644 index ed2c031..0000000 --- a/example/ruby/Launchable/JsonStreamWriter.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Launchable::JsonStreamWriter -**Inherits:** Object - - -JsonStreamWriter writes a JSON file using a stream. By utilizing a stream, we -can minimize memory usage, especially for large files. - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize(path) [](#method-i-initialize) - -**@return** [JsonStreamWriter] a new instance of JsonStreamWriter - -## write_array(key) [](#method-i-write_array) - -## write_object(obj) [](#method-i-write_object) - diff --git a/example/ruby/LaunchableFormatter.md b/example/ruby/LaunchableFormatter.md deleted file mode 100644 index d0b7be7..0000000 --- a/example/ruby/LaunchableFormatter.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: LaunchableFormatter - - - - -# Class Methods -## extend_object(obj ) [](#method-c-extend_object) -## setDir(dir ) [](#method-c-setDir) - -#Instance Methods -## after(statenil) [](#method-i-after) - -## before(statenil) [](#method-i-before) - -## exception(exception) [](#method-i-exception) - -## finish() [](#method-i-finish) - -## init() [](#method-i-init) - diff --git a/example/ruby/LeakChecker.md b/example/ruby/LeakChecker.md deleted file mode 100644 index 6187d4d..0000000 --- a/example/ruby/LeakChecker.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: LeakChecker -**Inherits:** Object - - - - -# Class Methods -## skip() [](#method-c-skip) -# Attributes -## leaks[RW] [](#attribute-i-leaks) -Returns the value of attribute leaks. - - -#Instance Methods -## check(state) [](#method-i-check) - -## check_verbose(test_name) [](#method-i-check_verbose) - -## check_warning_flags(test_name) [](#method-i-check_warning_flags) - -## find_warning_flags() [](#method-i-find_warning_flags) - -## initialize() [](#method-i-initialize) - -**@return** [LeakChecker] a new instance of LeakChecker - -## puts(*a) [](#method-i-puts) - diff --git a/example/ruby/LeakCheckerAction.md b/example/ruby/LeakCheckerAction.md deleted file mode 100644 index 8f2829f..0000000 --- a/example/ruby/LeakCheckerAction.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: LeakCheckerAction -**Inherits:** Object - - - - - -#Instance Methods -## after(state) [](#method-i-after) - -## register() [](#method-i-register) - -## start() [](#method-i-start) - diff --git a/example/ruby/LeakError.md b/example/ruby/LeakError.md deleted file mode 100644 index 1f43e26..0000000 --- a/example/ruby/LeakError.md +++ /dev/null @@ -1,17 +0,0 @@ -# Exception: LeakError -**Inherits:** StandardError - - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - - - diff --git a/example/ruby/Lo_Exception.md b/example/ruby/Lo_Exception.md deleted file mode 100644 index 3c3aa1b..0000000 --- a/example/ruby/Lo_Exception.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Lo_Exception -**Inherits:** Exception - - - - - -#Instance Methods -## initialize(num) [](#method-i-initialize) - -**@return** [Lo_Exception] a new instance of Lo_Exception - diff --git a/example/ruby/LoadError.md b/example/ruby/LoadError.md deleted file mode 100644 index ca407fa..0000000 --- a/example/ruby/LoadError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: LoadError -**Inherits:** ScriptError - - -for RubyGems without Bundler environment. If loading library is not part of -the default gems and the bundled gems, warn it. - - - -#Instance Methods -## message() [](#method-i-message) -:nodoc: - diff --git a/example/ruby/LoadSpecWrap.md b/example/ruby/LoadSpecWrap.md deleted file mode 100644 index e5562bd..0000000 --- a/example/ruby/LoadSpecWrap.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: LoadSpecWrap -**Inherits:** Object - - - - - diff --git a/example/ruby/LocalBarrier.md b/example/ruby/LocalBarrier.md deleted file mode 100644 index b0a0df3..0000000 --- a/example/ruby/LocalBarrier.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: LocalBarrier -**Inherits:** Object - - - - - -#Instance Methods -## initialize(n) [](#method-i-initialize) - -**@return** [LocalBarrier] a new instance of LocalBarrier - -## join() [](#method-i-join) - -## sync() [](#method-i-sync) - diff --git a/example/ruby/LocalJumpError.md b/example/ruby/LocalJumpError.md deleted file mode 100644 index 8b2b4b3..0000000 --- a/example/ruby/LocalJumpError.md +++ /dev/null @@ -1,42 +0,0 @@ -# Exception: LocalJumpError -**Inherits:** StandardError - - -Raised when Ruby can't yield as requested. - -A typical scenario is attempting to yield when no block is given: - - def call_block - yield 42 - end - call_block - -*raises the exception:* - - LocalJumpError: no block given (yield) - -A more subtle example: - - def get_me_a_return - Proc.new { return 42 } - end - get_me_a_return.call - -*raises the exception:* - - LocalJumpError: unexpected return - - - -#Instance Methods -## exit_value() [](#method-i-exit_value) -Returns the exit value associated with this `LocalJumpError`. - -**@overload** [] - -## reason() [](#method-i-reason) -The reason this block was terminated: :break, :redo, :retry, :next, :return, -or :noreason. - -**@overload** [] - diff --git a/example/ruby/Logger.md b/example/ruby/Logger.md deleted file mode 100644 index babd33a..0000000 --- a/example/ruby/Logger.md +++ /dev/null @@ -1,603 +0,0 @@ -# Class: Logger -**Inherits:** Object - -**Includes:** Logger::Severity - - -Class Logger provides a simple but sophisticated logging utility that you can -use to create one or more [event -logs](https://en.wikipedia.org/wiki/Logging_(software)#Event_logs) for your -program. Each such log contains a chronological sequence of entries that -provides a record of the program's activities. - -## About the Examples - -All examples on this page assume that Logger has been required: - - require 'logger' - -## Synopsis - -Create a log with Logger.new: - - # Single log file. - logger = Logger.new('t.log') - # Size-based rotated logging: 3 10-megabyte files. - logger = Logger.new('t.log', 3, 10485760) - # Period-based rotated logging: daily (also allowed: 'weekly', 'monthly'). - logger = Logger.new('t.log', 'daily') - # Log to an IO stream. - logger = Logger.new($stdout) - -Add entries (level, message) with Logger#add: - - logger.add(Logger::DEBUG, 'Maximal debugging info') - logger.add(Logger::INFO, 'Non-error information') - logger.add(Logger::WARN, 'Non-error warning') - logger.add(Logger::ERROR, 'Non-fatal error') - logger.add(Logger::FATAL, 'Fatal error') - logger.add(Logger::UNKNOWN, 'Most severe') - -Close the log with Logger#close: - - logger.close - -## Entries - -You can add entries with method Logger#add: - - logger.add(Logger::DEBUG, 'Maximal debugging info') - logger.add(Logger::INFO, 'Non-error information') - logger.add(Logger::WARN, 'Non-error warning') - logger.add(Logger::ERROR, 'Non-fatal error') - logger.add(Logger::FATAL, 'Fatal error') - logger.add(Logger::UNKNOWN, 'Most severe') - -These shorthand methods also add entries: - - logger.debug('Maximal debugging info') - logger.info('Non-error information') - logger.warn('Non-error warning') - logger.error('Non-fatal error') - logger.fatal('Fatal error') - logger.unknown('Most severe') - -When you call any of these methods, the entry may or may not be written to the -log, depending on the entry's severity and on the log level; see [Log -Level](rdoc-ref:Logger@Log+Level) - -An entry always has: - -* A severity (the required argument to #add). -* An automatically created timestamp. - -And may also have: - -* A message. -* A program name. - -Example: - - logger = Logger.new($stdout) - logger.add(Logger::INFO, 'My message.', 'mung') - # => I, [2022-05-07T17:21:46.536234 #20536] INFO -- mung: My message. - -The default format for an entry is: - - "%s, [%s #%d] %5s -- %s: %s\n" - -where the values to be formatted are: - -* Severity (one letter). -* Timestamp. -* Process id. -* Severity (word). -* Program name. -* Message. - -You can use a different entry format by: - -* Setting a custom format proc (affects following entries); see - [formatter=](Logger.html#attribute-i-formatter). -* Calling any of the methods above with a block (affects only the one - entry). Doing so can have two benefits: - - * Context: the block can evaluate the entire program context and create - a context-dependent message. - * Performance: the block is not evaluated unless the log level permits - the entry actually to be written: - - logger.error { my_slow_message_generator } - - Contrast this with the string form, where the string is always - evaluated, regardless of the log level: - - logger.error("#{my_slow_message_generator}") - -### Severity - -The severity of a log entry has two effects: - -* Determines whether the entry is selected for inclusion in the log; see - [Log Level](rdoc-ref:Logger@Log+Level). -* Indicates to any log reader (whether a person or a program) the relative - importance of the entry. - -### Timestamp - -The timestamp for a log entry is generated automatically when the entry is -created. - -The logged timestamp is formatted by method -[Time#strftime](rdoc-ref:Time#strftime) using this format string: - - '%Y-%m-%dT%H:%M:%S.%6N' - -Example: - - logger = Logger.new($stdout) - logger.add(Logger::INFO) - # => I, [2022-05-07T17:04:32.318331 #20536] INFO -- : nil - -You can set a different format using method #datetime_format=. - -### Message - -The message is an optional argument to an entry method: - - logger = Logger.new($stdout) - logger.add(Logger::INFO, 'My message') - # => I, [2022-05-07T18:15:37.647581 #20536] INFO -- : My message - -For the default entry formatter, `Logger::Formatter`, the message object may -be: - -* A string: used as-is. -* An Exception: `message.message` is used. -* Anything else: `message.inspect` is used. - -**Note**: Logger::Formatter does not escape or sanitize the message passed to -it. Developers should be aware that malicious data (user input) may be in the -message, and should explicitly escape untrusted data. - -You can use a custom formatter to escape message data; see the example at -[formatter=](Logger.html#attribute-i-formatter). - -### Program Name - -The program name is an optional argument to an entry method: - - logger = Logger.new($stdout) - logger.add(Logger::INFO, 'My message', 'mung') - # => I, [2022-05-07T18:17:38.084716 #20536] INFO -- mung: My message - -The default program name for a new logger may be set in the call to Logger.new -via optional keyword argument `progname`: - - logger = Logger.new('t.log', progname: 'mung') - -The default program name for an existing logger may be set by a call to method -#progname=: - - logger.progname = 'mung' - -The current program name may be retrieved with method -[progname](Logger.html#attribute-i-progname): - - logger.progname # => "mung" - -## Log Level - -The log level setting determines whether an entry is actually written to the -log, based on the entry's severity. - -These are the defined severities (least severe to most severe): - - logger = Logger.new($stdout) - logger.add(Logger::DEBUG, 'Maximal debugging info') - # => D, [2022-05-07T17:57:41.776220 #20536] DEBUG -- : Maximal debugging info - logger.add(Logger::INFO, 'Non-error information') - # => I, [2022-05-07T17:59:14.349167 #20536] INFO -- : Non-error information - logger.add(Logger::WARN, 'Non-error warning') - # => W, [2022-05-07T18:00:45.337538 #20536] WARN -- : Non-error warning - logger.add(Logger::ERROR, 'Non-fatal error') - # => E, [2022-05-07T18:02:41.592912 #20536] ERROR -- : Non-fatal error - logger.add(Logger::FATAL, 'Fatal error') - # => F, [2022-05-07T18:05:24.703931 #20536] FATAL -- : Fatal error - logger.add(Logger::UNKNOWN, 'Most severe') - # => A, [2022-05-07T18:07:54.657491 #20536] ANY -- : Most severe - -The default initial level setting is Logger::DEBUG, the lowest level, which -means that all entries are to be written, regardless of severity: - - logger = Logger.new($stdout) - logger.level # => 0 - logger.add(0, "My message") - # => D, [2022-05-11T15:10:59.773668 #20536] DEBUG -- : My message - -You can specify a different setting in a new logger using keyword argument -`level` with an appropriate value: - - logger = Logger.new($stdout, level: Logger::ERROR) - logger = Logger.new($stdout, level: 'error') - logger = Logger.new($stdout, level: :error) - logger.level # => 3 - -With this level, entries with severity Logger::ERROR and higher are written, -while those with lower severities are not written: - - logger = Logger.new($stdout, level: Logger::ERROR) - logger.add(3) - # => E, [2022-05-11T15:17:20.933362 #20536] ERROR -- : nil - logger.add(2) # Silent. - -You can set the log level for an existing logger with method #level=: - - logger.level = Logger::ERROR - -These shorthand methods also set the level: - - logger.debug! # => 0 - logger.info! # => 1 - logger.warn! # => 2 - logger.error! # => 3 - logger.fatal! # => 4 - -You can retrieve the log level with method #level. - - logger.level = Logger::ERROR - logger.level # => 3 - -These methods return whether a given level is to be written: - - logger.level = Logger::ERROR - logger.debug? # => false - logger.info? # => false - logger.warn? # => false - logger.error? # => true - logger.fatal? # => true - -## Log File Rotation - -By default, a log file is a single file that grows indefinitely (until -explicitly closed); there is no file rotation. - -To keep log files to a manageable size, you can use *log* *file* *rotation*, -which uses multiple log files: - -* Each log file has entries for a non-overlapping time interval. -* Only the most recent log file is open and active; the others are closed - and inactive. - -### Size-Based Rotation - -For size-based log file rotation, call Logger.new with: - -* Argument `logdev` as a file path. -* Argument `shift_age` with a positive integer: the number of log files to - be in the rotation. -* Argument `shift_size` as a positive integer: the maximum size (in bytes) - of each log file; defaults to 1048576 (1 megabyte). - -Examples: - - logger = Logger.new('t.log', 3) # Three 1-megabyte files. - logger = Logger.new('t.log', 5, 10485760) # Five 10-megabyte files. - -For these examples, suppose: - - logger = Logger.new('t.log', 3) - -Logging begins in the new log file, `t.log`; the log file is "full" and ready -for rotation when a new entry would cause its size to exceed `shift_size`. - -The first time `t.log` is full: - -* `t.log` is closed and renamed to `t.log.0`. -* A new file `t.log` is opened. - -The second time `t.log` is full: - -* +t.log.0 is renamed as `t.log.1`. -* `t.log` is closed and renamed to `t.log.0`. -* A new file `t.log` is opened. - -Each subsequent time that `t.log` is full, the log files are rotated: - -* `t.log.1` is removed. -* +t.log.0 is renamed as `t.log.1`. -* `t.log` is closed and renamed to `t.log.0`. -* A new file `t.log` is opened. - -### Periodic Rotation - -For periodic rotation, call Logger.new with: - -* Argument `logdev` as a file path. -* Argument `shift_age` as a string period indicator. - -Examples: - - logger = Logger.new('t.log', 'daily') # Rotate log files daily. - logger = Logger.new('t.log', 'weekly') # Rotate log files weekly. - logger = Logger.new('t.log', 'monthly') # Rotate log files monthly. - -Example: - - logger = Logger.new('t.log', 'daily') - -When the given period expires: - -* The base log file, `t.log` is closed and renamed with a date-based suffix - such as `t.log.20220509`. -* A new log file `t.log` is opened. -* Nothing is removed. - -The default format for the suffix is `'%Y%m%d'`, which produces a suffix -similar to the one above. You can set a different format using create-time -option `shift_period_suffix`; see details and suggestions at -[Time#strftime](rdoc-ref:Time#strftime). - - -# Attributes -## formatter[RW] [](#attribute-i-formatter) -Sets or retrieves the logger entry formatter proc. - -When `formatter` is `nil`, the logger uses Logger::Formatter. - -When `formatter` is a proc, a new entry is formatted by the proc, which is -called with four arguments: - -* `severity`: The severity of the entry. -* `time`: A Time object representing the entry's timestamp. -* `progname`: The program name for the entry. -* `msg`: The message for the entry (string or string-convertible object). - -The proc should return a string containing the formatted entry. - -This custom formatter uses [String#dump](rdoc-ref:String#dump) to escape the -message string: - - logger = Logger.new($stdout, progname: 'mung') - original_formatter = logger.formatter || Logger::Formatter.new - logger.formatter = proc { |severity, time, progname, msg| - original_formatter.call(severity, time, progname, msg.dump) - } - logger.add(Logger::INFO, "hello \n ''") - logger.add(Logger::INFO, "\f\x00\xff\\\"") - -Output: - - I, [2022-05-13T13:16:29.637488 #8492] INFO -- mung: "hello \n ''" - I, [2022-05-13T13:16:29.637610 #8492] INFO -- mung: "\f\x00\xFF\\\"" - -## progname[RW] [](#attribute-i-progname) -Program name to include in log messages. - - -#Instance Methods -## <<(msg) [](#method-i-<<) -Writes the given `msg` to the log with no formatting; returns the number of -characters written, or `nil` if no log device exists: - - logger = Logger.new($stdout) - logger << 'My message.' # => 10 - -Output: - - My message. - -## add(severity, messagenil, prognamenil) [](#method-i-add) -Creates a log entry, which may or may not be written to the log, depending on -the entry's severity and on the log level. See [Log -Level](rdoc-ref:Logger@Log+Level) and [Entries](rdoc-ref:Logger@Entries) for -details. - -Examples: - - logger = Logger.new($stdout, progname: 'mung') - logger.add(Logger::INFO) - logger.add(Logger::ERROR, 'No good') - logger.add(Logger::ERROR, 'No good', 'gnum') - -Output: - - I, [2022-05-12T16:25:31.469726 #36328] INFO -- mung: mung - E, [2022-05-12T16:25:55.349414 #36328] ERROR -- mung: No good - E, [2022-05-12T16:26:35.841134 #36328] ERROR -- gnum: No good - -These convenience methods have implicit severity: - -* #debug. -* #info. -* #warn. -* #error. -* #fatal. -* #unknown. - -## close() [](#method-i-close) -Closes the logger; returns `nil`: - - logger = Logger.new('t.log') - logger.close # => nil - logger.info('foo') # Prints "log writing failed. closed stream" - -Related: Logger#reopen. - -## datetime_format() [](#method-i-datetime_format) -Returns the date-time format; see #datetime_format=. - -## datetime_format=(datetime_format) [](#method-i-datetime_format=) -Sets the date-time format. - -Argument `datetime_format` should be either of these: - -* A string suitable for use as a format for method - [Time#strftime](rdoc-ref:Time#strftime). -* `nil`: the logger uses `'%Y-%m-%dT%H:%M:%S.%6N'`. - -## debug(prognamenil, &block) [](#method-i-debug) -Equivalent to calling #add with severity `Logger::DEBUG`. - -## debug!() [](#method-i-debug!) -Sets the log level to Logger::DEBUG. See [Log -Level](rdoc-ref:Logger@Log+Level). - -## debug?() [](#method-i-debug?) -Returns `true` if the log level allows entries with severity Logger::DEBUG to -be written, `false` otherwise. See [Log Level](rdoc-ref:Logger@Log+Level). - -**@return** [Boolean] - -## error(prognamenil, &block) [](#method-i-error) -Equivalent to calling #add with severity `Logger::ERROR`. - -## error!() [](#method-i-error!) -Sets the log level to Logger::ERROR. See [Log -Level](rdoc-ref:Logger@Log+Level). - -## error?() [](#method-i-error?) -Returns `true` if the log level allows entries with severity Logger::ERROR to -be written, `false` otherwise. See [Log Level](rdoc-ref:Logger@Log+Level). - -**@return** [Boolean] - -## fatal(prognamenil, &block) [](#method-i-fatal) -Equivalent to calling #add with severity `Logger::FATAL`. - -## fatal!() [](#method-i-fatal!) -Sets the log level to Logger::FATAL. See [Log -Level](rdoc-ref:Logger@Log+Level). - -## fatal?() [](#method-i-fatal?) -Returns `true` if the log level allows entries with severity Logger::FATAL to -be written, `false` otherwise. See [Log Level](rdoc-ref:Logger@Log+Level). - -**@return** [Boolean] - -## flush() [](#method-i-flush) - -## info(prognamenil, &block) [](#method-i-info) -Equivalent to calling #add with severity `Logger::INFO`. - -## info!() [](#method-i-info!) -Sets the log level to Logger::INFO. See [Log -Level](rdoc-ref:Logger@Log+Level). - -## info?() [](#method-i-info?) -Returns `true` if the log level allows entries with severity Logger::INFO to -be written, `false` otherwise. See [Log Level](rdoc-ref:Logger@Log+Level). - -**@return** [Boolean] - -## initialize(fname) [](#method-i-initialize) -:call-seq: - Logger.new(logdev, shift_age = 0, shift_size = 1048576, **options) - -With the single argument `logdev`, returns a new logger with all default -options: - - Logger.new('t.log') # => # - -Argument `logdev` must be one of: - -* A string filepath: entries are to be written to the file at that path; if - the file at that path exists, new entries are appended. -* An IO stream (typically +$stdout+, +$stderr+. or an open file): entries - are to be written to the given stream. -* `nil` or `File::NULL`: no entries are to be written. - -Examples: - - Logger.new('t.log') - Logger.new($stdout) - -The keyword options are: - -* `level`: sets the log level; default value is Logger::DEBUG. See [Log - Level](rdoc-ref:Logger@Log+Level): - - Logger.new('t.log', level: Logger::ERROR) - -* `progname`: sets the default program name; default is `nil`. See [Program - Name](rdoc-ref:Logger@Program+Name): - - Logger.new('t.log', progname: 'mung') - -* `formatter`: sets the entry formatter; default is `nil`. See - [formatter=](Logger.html#attribute-i-formatter). -* `datetime_format`: sets the format for entry timestamp; default is `nil`. - See #datetime_format=. -* `binmode`: sets whether the logger writes in binary mode; default is - `false`. -* `shift_period_suffix`: sets the format for the filename suffix for - periodic log file rotation; default is `'%Y%m%d'`. See [Periodic - Rotation](rdoc-ref:Logger@Periodic+Rotation). -* `reraise_write_errors`: An array of exception classes, which will be - reraised if there is an error when writing to the log device. The default - is to swallow all exceptions raised. - -**@return** [Logger] a new instance of Logger - -## level() [](#method-i-level) -Logging severity threshold (e.g. `Logger::INFO`). - -## level=(severity) [](#method-i-level=) -Sets the log level; returns `severity`. See [Log -Level](rdoc-ref:Logger@Log+Level). - -Argument `severity` may be an integer, a string, or a symbol: - - logger.level = Logger::ERROR # => 3 - logger.level = 3 # => 3 - logger.level = 'error' # => "error" - logger.level = :error # => :error - -Logger#sev_threshold= is an alias for Logger#level=. - -## reopen(logdevnil) [](#method-i-reopen) -Sets the logger's output stream: - -* If `logdev` is `nil`, reopens the current output stream. -* If `logdev` is a filepath, opens the indicated file for append. -* If `logdev` is an IO stream (usually `$stdout`, `$stderr`, or an open File - object), opens the stream for append. - -Example: - - logger = Logger.new('t.log') - logger.add(Logger::ERROR, 'one') - logger.close - logger.add(Logger::ERROR, 'two') # Prints 'log writing failed. closed stream' - logger.reopen - logger.add(Logger::ERROR, 'three') - logger.close - File.readlines('t.log') - # => - # ["# Logfile created on 2022-05-12 14:21:19 -0500 by logger.rb/v1.5.0\n", - # "E, [2022-05-12T14:21:27.596726 #22428] ERROR -- : one\n", - # "E, [2022-05-12T14:23:05.847241 #22428] ERROR -- : three\n"] - -## unknown(prognamenil, &block) [](#method-i-unknown) -Equivalent to calling #add with severity `Logger::UNKNOWN`. - -## warn(prognamenil, &block) [](#method-i-warn) -Equivalent to calling #add with severity `Logger::WARN`. - -## warn!() [](#method-i-warn!) -Sets the log level to Logger::WARN. See [Log -Level](rdoc-ref:Logger@Log+Level). - -## warn?() [](#method-i-warn?) -Returns `true` if the log level allows entries with severity Logger::WARN to -be written, `false` otherwise. See [Log Level](rdoc-ref:Logger@Log+Level). - -**@return** [Boolean] - -## with_level(severity) [](#method-i-with_level) -Adjust the log level during the block execution for the current Fiber only - - logger.with_level(:debug) do - logger.debug { "Hello" } - end - diff --git a/example/ruby/Logger/Error.md b/example/ruby/Logger/Error.md deleted file mode 100644 index 9c7cfb0..0000000 --- a/example/ruby/Logger/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Logger::Error -**Inherits:** RuntimeError - - -not used after 1.2.7. just for compat. - - - diff --git a/example/ruby/Logger/Formatter.md b/example/ruby/Logger/Formatter.md deleted file mode 100644 index bf67a42..0000000 --- a/example/ruby/Logger/Formatter.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Logger::Formatter -**Inherits:** Object - - -Default formatter for log messages. - - -# Attributes -## datetime_format[RW] [](#attribute-i-datetime_format) -Returns the value of attribute datetime_format. - - -#Instance Methods -## call(severity, time, progname, msg) [](#method-i-call) - -## initialize() [](#method-i-initialize) - -**@return** [Formatter] a new instance of Formatter - diff --git a/example/ruby/Logger/LogDevice.md b/example/ruby/Logger/LogDevice.md deleted file mode 100644 index ffb850a..0000000 --- a/example/ruby/Logger/LogDevice.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: Logger::LogDevice -**Inherits:** Object - -**Includes:** Logger::Period, MonitorMixin - - -Device used for logging messages. - - -# Attributes -## dev[RW] [](#attribute-i-dev) -Returns the value of attribute dev. - -## filename[RW] [](#attribute-i-filename) -Returns the value of attribute filename. - - -#Instance Methods -## close() [](#method-i-close) - -## initialize(lognil, shift_age:nil, shift_size:nil, shift_period_suffix:nil, binmode:false, reraise_write_errors:[]) [](#method-i-initialize) - -**@return** [LogDevice] a new instance of LogDevice - -## mon_enter() [](#method-i-mon_enter) -Enters exclusive section. - -## mon_exit() [](#method-i-mon_exit) -Leaves exclusive section. - -## mon_locked?() [](#method-i-mon_locked?) -Returns true if this monitor is locked by any thread - -**@return** [Boolean] - -## mon_owned?() [](#method-i-mon_owned?) -Returns true if this monitor is locked by current thread. - -**@return** [Boolean] - -## mon_synchronize(&b) [](#method-i-mon_synchronize) -Enters exclusive section and executes the block. Leaves the exclusive section -automatically when the block exits. See example under `MonitorMixin`. - -## mon_try_enter() [](#method-i-mon_try_enter) -Attempts to enter exclusive section. Returns `false` if lock fails. - -## new_cond() [](#method-i-new_cond) -Creates a new MonitorMixin::ConditionVariable associated with the Monitor -object. - -## reopen(lognil) [](#method-i-reopen) - -## write(message) [](#method-i-write) - diff --git a/example/ruby/Logger/Period.md b/example/ruby/Logger/Period.md deleted file mode 100644 index cf503eb..0000000 --- a/example/ruby/Logger/Period.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Logger::Period - - - - -# Class Methods -## next_rotate_time(now , shift_age ) [](#method-c-next_rotate_time) -## previous_period_end(now , shift_age ) [](#method-c-previous_period_end) - diff --git a/example/ruby/Logger/Severity.md b/example/ruby/Logger/Severity.md deleted file mode 100644 index efc9561..0000000 --- a/example/ruby/Logger/Severity.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Logger::Severity - - -Logging severity. - - -# Class Methods -## coerce(severity ) [](#method-c-coerce) - diff --git a/example/ruby/Logger/ShiftingError.md b/example/ruby/Logger/ShiftingError.md deleted file mode 100644 index d617751..0000000 --- a/example/ruby/Logger/ShiftingError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Logger::ShiftingError -**Inherits:** Logger::Error - - -:nodoc: - - - diff --git a/example/ruby/LoggerSpecs.md b/example/ruby/LoggerSpecs.md deleted file mode 100644 index a67efc1..0000000 --- a/example/ruby/LoggerSpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: LoggerSpecs - - - - -# Class Methods -## strip_date(str ) [](#method-c-strip_date) - diff --git a/example/ruby/Lrama.md b/example/ruby/Lrama.md deleted file mode 100644 index 460abcd..0000000 --- a/example/ruby/Lrama.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Lrama - - -Symbol is both of nterm and term `number` is both for nterm and term -`token_id` is tokentype for term, internal sequence number for nterm - -TODO: Add validation for ASCII code range for Token::Char - - - diff --git a/example/ruby/Lrama/Bitmap.md b/example/ruby/Lrama/Bitmap.md deleted file mode 100644 index 912194e..0000000 --- a/example/ruby/Lrama/Bitmap.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Lrama::Bitmap - - - - -# Class Methods -## from_array(ary ) [](#method-c-from_array) -## to_array(int ) [](#method-c-to_array) - diff --git a/example/ruby/Lrama/Command.md b/example/ruby/Lrama/Command.md deleted file mode 100644 index dd3df34..0000000 --- a/example/ruby/Lrama/Command.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Lrama::Command -**Inherits:** Object - - - - - -#Instance Methods -## run(argv) [](#method-i-run) - diff --git a/example/ruby/Lrama/Context.md b/example/ruby/Lrama/Context.md deleted file mode 100644 index 743e796..0000000 --- a/example/ruby/Lrama/Context.md +++ /dev/null @@ -1,93 +0,0 @@ -# Class: Lrama::Context -**Inherits:** Object - -**Includes:** Lrama::Report::Duration - - -This is passed to a template - - -# Attributes -## states[RW] [](#attribute-i-states) -TODO: It might be better to pass `states` to Output directly? - -## yydefact[RW] [](#attribute-i-yydefact) -TODO: It might be better to pass `states` to Output directly? - -## yydefgoto[RW] [](#attribute-i-yydefgoto) -TODO: It might be better to pass `states` to Output directly? - -## yylast[RW] [](#attribute-i-yylast) -TODO: It might be better to pass `states` to Output directly? - -## yypact_ninf[RW] [](#attribute-i-yypact_ninf) -TODO: It might be better to pass `states` to Output directly? - -## yytable_ninf[RW] [](#attribute-i-yytable_ninf) -TODO: It might be better to pass `states` to Output directly? - - -#Instance Methods -## initialize(states) [](#method-i-initialize) - -**@return** [Context] a new instance of Context - -## report_duration(method_name) [](#method-i-report_duration) - -## yycheck() [](#method-i-yycheck) - -## yyfinal() [](#method-i-yyfinal) -State number of final (accepted) state - -## yymaxutok() [](#method-i-yymaxutok) -Last token number - -## yynnts() [](#method-i-yynnts) -Number of nterms - -## yynrules() [](#method-i-yynrules) -Number of rules - -## yynstates() [](#method-i-yynstates) -Number of states - -## yyntokens() [](#method-i-yyntokens) -Number of terms - -## yypact() [](#method-i-yypact) - -## yypgoto() [](#method-i-yypgoto) - -## yyr1() [](#method-i-yyr1) -Mapping from rule number to symbol number of LHS. Dummy rule is appended as -the first element whose value is 0 because 0 means error in yydefact. - -## yyr2() [](#method-i-yyr2) -Mapping from rule number to length of RHS. Dummy rule is appended as the first -element whose value is 0 because 0 means error in yydefact. - -## yyrline() [](#method-i-yyrline) -Mapping from rule number to line number of the rule is defined. Dummy rule is -appended as the first element whose value is 0 because 0 means error in -yydefact. - -## yystos() [](#method-i-yystos) - -## yysymbol_kind_t() [](#method-i-yysymbol_kind_t) -enum yysymbol_kind_t - -## yytable() [](#method-i-yytable) - -## yytname() [](#method-i-yytname) -Mapping from symbol number to its name - -## yytokentype() [](#method-i-yytokentype) -enum yytokentype - -## yytranslate() [](#method-i-yytranslate) -YYTRANSLATE - -yytranslate is a mapping from token id to symbol number - -## yytranslate_inverted() [](#method-i-yytranslate_inverted) - diff --git a/example/ruby/Lrama/Counterexamples.md b/example/ruby/Lrama/Counterexamples.md deleted file mode 100644 index 51e4644..0000000 --- a/example/ruby/Lrama/Counterexamples.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Lrama::Counterexamples -**Inherits:** Object - - -See: https://www.cs.cornell.edu/andru/papers/cupex/cupex.pdf - 4. Constructing Nonunifying Counterexamples - - -# Attributes -## productions[RW] [](#attribute-i-productions) -Returns the value of attribute productions. - -## transitions[RW] [](#attribute-i-transitions) -Returns the value of attribute transitions. - - -#Instance Methods -## compute(conflict_state) [](#method-i-compute) - -## initialize(states) [](#method-i-initialize) - -**@return** [Counterexamples] a new instance of Counterexamples - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Lrama/Counterexamples/Derivation.md b/example/ruby/Lrama/Counterexamples/Derivation.md deleted file mode 100644 index 6d3fdd3..0000000 --- a/example/ruby/Lrama/Counterexamples/Derivation.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Lrama::Counterexamples::Derivation -**Inherits:** Object - - - - -# Attributes -## item[RW] [](#attribute-i-item) -Returns the value of attribute item. - -## left[RW] [](#attribute-i-left) -Returns the value of attribute left. - -## right[RW] [](#attribute-i-right) -Returns the value of attribute right. - - -#Instance Methods -## initialize(item, left, rightnil) [](#method-i-initialize) - -**@return** [Derivation] a new instance of Derivation - -## render_for_report() [](#method-i-render_for_report) - -## render_strings_for_report() [](#method-i-render_strings_for_report) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Lrama/Counterexamples/Example.md b/example/ruby/Lrama/Counterexamples/Example.md deleted file mode 100644 index da78dec..0000000 --- a/example/ruby/Lrama/Counterexamples/Example.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Lrama::Counterexamples::Example -**Inherits:** Object - - - - -# Attributes -## conflict[RW] [](#attribute-i-conflict) -Returns the value of attribute conflict. - -## conflict_symbol[RW] [](#attribute-i-conflict_symbol) -Returns the value of attribute conflict_symbol. - -## path1[RW] [](#attribute-i-path1) -Returns the value of attribute path1. - -## path2[RW] [](#attribute-i-path2) -Returns the value of attribute path2. - - -#Instance Methods -## derivations1() [](#method-i-derivations1) - -## derivations2() [](#method-i-derivations2) - -## initialize(path1, path2, conflict, conflict_symbol, counterexamples) [](#method-i-initialize) -path1 is shift conflict when S/R conflict path2 is always reduce conflict - -**@return** [Example] a new instance of Example - -## path1_item() [](#method-i-path1_item) - -## path2_item() [](#method-i-path2_item) - -## type() [](#method-i-type) - diff --git a/example/ruby/Lrama/Counterexamples/Path.md b/example/ruby/Lrama/Counterexamples/Path.md deleted file mode 100644 index 177d827..0000000 --- a/example/ruby/Lrama/Counterexamples/Path.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Lrama::Counterexamples::Path -**Inherits:** Object - - - - - -#Instance Methods -## from() [](#method-i-from) - -## initialize(from_state_item, to_state_item) [](#method-i-initialize) - -**@return** [Path] a new instance of Path - -## to() [](#method-i-to) - -## to_s() [](#method-i-to_s) - -## type() [](#method-i-type) - -**@raise** [NotImplementedError] - diff --git a/example/ruby/Lrama/Counterexamples/ProductionPath.md b/example/ruby/Lrama/Counterexamples/ProductionPath.md deleted file mode 100644 index 18bd60f..0000000 --- a/example/ruby/Lrama/Counterexamples/ProductionPath.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Lrama::Counterexamples::ProductionPath -**Inherits:** Lrama::Counterexamples::Path - - - - - -#Instance Methods -## production?() [](#method-i-production?) - -**@return** [Boolean] - -## transition?() [](#method-i-transition?) - -**@return** [Boolean] - -## type() [](#method-i-type) - diff --git a/example/ruby/Lrama/Counterexamples/StartPath.md b/example/ruby/Lrama/Counterexamples/StartPath.md deleted file mode 100644 index 47dbd1f..0000000 --- a/example/ruby/Lrama/Counterexamples/StartPath.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Lrama::Counterexamples::StartPath -**Inherits:** Lrama::Counterexamples::Path - - - - - -#Instance Methods -## initialize(to_state_item) [](#method-i-initialize) - -**@return** [StartPath] a new instance of StartPath - -## production?() [](#method-i-production?) - -**@return** [Boolean] - -## transition?() [](#method-i-transition?) - -**@return** [Boolean] - -## type() [](#method-i-type) - diff --git a/example/ruby/Lrama/Counterexamples/StateItem.md b/example/ruby/Lrama/Counterexamples/StateItem.md deleted file mode 100644 index f5afdaa..0000000 --- a/example/ruby/Lrama/Counterexamples/StateItem.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Lrama::Counterexamples::StateItem -**Inherits:** Struct - - - - -# Attributes -## item[RW] [](#attribute-i-item) -Returns the value of attribute item - -**@return** [Object] the current value of item - -## state[RW] [](#attribute-i-state) -Returns the value of attribute state - -**@return** [Object] the current value of state - - diff --git a/example/ruby/Lrama/Counterexamples/TransitionPath.md b/example/ruby/Lrama/Counterexamples/TransitionPath.md deleted file mode 100644 index d7532fd..0000000 --- a/example/ruby/Lrama/Counterexamples/TransitionPath.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Lrama::Counterexamples::TransitionPath -**Inherits:** Lrama::Counterexamples::Path - - - - - -#Instance Methods -## production?() [](#method-i-production?) - -**@return** [Boolean] - -## transition?() [](#method-i-transition?) - -**@return** [Boolean] - -## type() [](#method-i-type) - diff --git a/example/ruby/Lrama/Counterexamples/Triple.md b/example/ruby/Lrama/Counterexamples/Triple.md deleted file mode 100644 index 64106f4..0000000 --- a/example/ruby/Lrama/Counterexamples/Triple.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Lrama::Counterexamples::Triple -**Inherits:** Struct - - -s: state itm: item within s l: precise lookahead set - - -# Attributes -## itm[RW] [](#attribute-i-itm) -Returns the value of attribute itm - -**@return** [Object] the current value of itm - -## l[RW] [](#attribute-i-l) -Returns the value of attribute l - -**@return** [Object] the current value of l - -## s[RW] [](#attribute-i-s) -Returns the value of attribute s - -**@return** [Object] the current value of s - - -#Instance Methods -## inspect() [](#method-i-inspect) - -## state_item() [](#method-i-state_item) - diff --git a/example/ruby/Lrama/Diagnostics.md b/example/ruby/Lrama/Diagnostics.md deleted file mode 100644 index b1e066b..0000000 --- a/example/ruby/Lrama/Diagnostics.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Lrama::Diagnostics -**Inherits:** Object - - - - - -#Instance Methods -## initialize(grammar, states, logger) [](#method-i-initialize) - -**@return** [Diagnostics] a new instance of Diagnostics - -## run(diagnostic) [](#method-i-run) - diff --git a/example/ruby/Lrama/Digraph.md b/example/ruby/Lrama/Digraph.md deleted file mode 100644 index 16cf46b..0000000 --- a/example/ruby/Lrama/Digraph.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Lrama::Digraph -**Inherits:** Object - - -Algorithm Digraph of https://dl.acm.org/doi/pdf/10.1145/69622.357187 (P. 625) - - - -#Instance Methods -## compute() [](#method-i-compute) - -## initialize(sets, relation, base_function) [](#method-i-initialize) - -**@return** [Digraph] a new instance of Digraph - diff --git a/example/ruby/Lrama/Grammar.md b/example/ruby/Lrama/Grammar.md deleted file mode 100644 index 7423520..0000000 --- a/example/ruby/Lrama/Grammar.md +++ /dev/null @@ -1,188 +0,0 @@ -# Class: Lrama::Grammar -**Inherits:** Object - -**Extended by:** Forwardable - - -Grammar is the result of parsing an input grammar file - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -# Attributes -## accept_symbol[RW] [](#attribute-i-accept_symbol) -Returns the value of attribute accept_symbol. - -## after_pop_stack[RW] [](#attribute-i-after_pop_stack) -Returns the value of attribute after_pop_stack. - -## after_reduce[RW] [](#attribute-i-after_reduce) -Returns the value of attribute after_reduce. - -## after_shift[RW] [](#attribute-i-after_shift) -Returns the value of attribute after_shift. - -## after_shift_error_token[RW] [](#attribute-i-after_shift_error_token) -Returns the value of attribute after_shift_error_token. - -## aux[RW] [](#attribute-i-aux) -Returns the value of attribute aux. - -## before_reduce[RW] [](#attribute-i-before_reduce) -Returns the value of attribute before_reduce. - -## eof_symbol[RW] [](#attribute-i-eof_symbol) -Returns the value of attribute eof_symbol. - -## error_symbol[RW] [](#attribute-i-error_symbol) -Returns the value of attribute error_symbol. - -## error_tokens[RW] [](#attribute-i-error_tokens) -Returns the value of attribute error_tokens. - -## expect[RW] [](#attribute-i-expect) -Returns the value of attribute expect. - -## initial_action[RW] [](#attribute-i-initial_action) -Returns the value of attribute initial_action. - -## lex_param[RW] [](#attribute-i-lex_param) -Returns the value of attribute lex_param. - -## locations[RW] [](#attribute-i-locations) -Returns the value of attribute locations. - -## no_stdlib[RW] [](#attribute-i-no_stdlib) -Returns the value of attribute no_stdlib. - -## parameterizing_rule_resolver[RW] [](#attribute-i-parameterizing_rule_resolver) -Returns the value of attribute parameterizing_rule_resolver. - -## parse_param[RW] [](#attribute-i-parse_param) -Returns the value of attribute parse_param. - -## percent_codes[RW] [](#attribute-i-percent_codes) -Returns the value of attribute percent_codes. - -## printers[RW] [](#attribute-i-printers) -Returns the value of attribute printers. - -## rule_builders[RW] [](#attribute-i-rule_builders) -Returns the value of attribute rule_builders. - -## rules[RW] [](#attribute-i-rules) -Returns the value of attribute rules. - -## sym_to_rules[RW] [](#attribute-i-sym_to_rules) -Returns the value of attribute sym_to_rules. - -## symbols_resolver[RW] [](#attribute-i-symbols_resolver) -Returns the value of attribute symbols_resolver. - -## types[RW] [](#attribute-i-types) -Returns the value of attribute types. - -## undef_symbol[RW] [](#attribute-i-undef_symbol) -Returns the value of attribute undef_symbol. - -## union[RW] [](#attribute-i-union) -Returns the value of attribute union. - - -#Instance Methods -## add_destructor(ident_or_tags:, token_code:, lineno:) [](#method-i-add_destructor) - -## add_error_token(ident_or_tags:, token_code:, lineno:) [](#method-i-add_error_token) - -## add_left(sym, precedence) [](#method-i-add_left) - -## add_nonassoc(sym, precedence) [](#method-i-add_nonassoc) - -## add_parameterizing_rule(rule) [](#method-i-add_parameterizing_rule) - -## add_percent_code(id:, code:) [](#method-i-add_percent_code) - -## add_precedence(sym, precedence) [](#method-i-add_precedence) - -## add_printer(ident_or_tags:, token_code:, lineno:) [](#method-i-add_printer) - -## add_right(sym, precedence) [](#method-i-add_right) - -## add_rule_builder(builder) [](#method-i-add_rule_builder) - -## add_type(id:, tag:) [](#method-i-add_type) - -## create_rule_builder(rule_counter, midrule_action_counter) [](#method-i-create_rule_builder) - -## epilogue=(epilogue) [](#method-i-epilogue=) - -## epilogue_first_lineno=(epilogue_first_lineno) [](#method-i-epilogue_first_lineno=) - -## find_rules_by_symbol(sym) [](#method-i-find_rules_by_symbol) - -## find_rules_by_symbol!(sym) [](#method-i-find_rules_by_symbol!) - -## initialize(rule_counter) [](#method-i-initialize) - -**@return** [Grammar] a new instance of Grammar - -## insert_before_parameterizing_rules(rules) [](#method-i-insert_before_parameterizing_rules) - -## parameterizing_rules() [](#method-i-parameterizing_rules) - -## prepare() [](#method-i-prepare) - -## prologue=(prologue) [](#method-i-prologue=) - -## prologue_first_lineno=(prologue_first_lineno) [](#method-i-prologue_first_lineno=) - -## set_precedence(sym, precedence) [](#method-i-set_precedence) - -## set_union(code, lineno) [](#method-i-set_union) - -## validate!() [](#method-i-validate!) -TODO: More validation methods - -* Validation for no_declared_type_reference - diff --git a/example/ruby/Lrama/Grammar/Auxiliary.md b/example/ruby/Lrama/Grammar/Auxiliary.md deleted file mode 100644 index 476cd46..0000000 --- a/example/ruby/Lrama/Grammar/Auxiliary.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Lrama::Grammar::Auxiliary -**Inherits:** Struct - - -Grammar file information not used by States but by Output - - -# Attributes -## epilogue[RW] [](#attribute-i-epilogue) -Returns the value of attribute epilogue - -**@return** [Object] the current value of epilogue - -## epilogue_first_lineno[RW] [](#attribute-i-epilogue_first_lineno) -Returns the value of attribute epilogue_first_lineno - -**@return** [Object] the current value of epilogue_first_lineno - -## prologue[RW] [](#attribute-i-prologue) -Returns the value of attribute prologue - -**@return** [Object] the current value of prologue - -## prologue_first_lineno[RW] [](#attribute-i-prologue_first_lineno) -Returns the value of attribute prologue_first_lineno - -**@return** [Object] the current value of prologue_first_lineno - - diff --git a/example/ruby/Lrama/Grammar/Binding.md b/example/ruby/Lrama/Grammar/Binding.md deleted file mode 100644 index f433ddc..0000000 --- a/example/ruby/Lrama/Grammar/Binding.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Lrama::Grammar::Binding -**Inherits:** Object - - - - -# Attributes -## actual_args[RW] [](#attribute-i-actual_args) -Returns the value of attribute actual_args. - -## count[RW] [](#attribute-i-count) -Returns the value of attribute count. - - -#Instance Methods -## initialize(parameterizing_rule, actual_args) [](#method-i-initialize) - -**@return** [Binding] a new instance of Binding - -## resolve_symbol(symbol) [](#method-i-resolve_symbol) - diff --git a/example/ruby/Lrama/Grammar/Code.md b/example/ruby/Lrama/Grammar/Code.md deleted file mode 100644 index ba8b61c..0000000 --- a/example/ruby/Lrama/Grammar/Code.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: Lrama::Grammar::Code -**Inherits:** Object - -**Extended by:** Forwardable - - - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -# Attributes -## token_code[RW] [](#attribute-i-token_code) -Returns the value of attribute token_code. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(type:, token_code:) [](#method-i-initialize) - -**@return** [Code] a new instance of Code - -## translated_code() [](#method-i-translated_code) -$$, $n, @$, @n are translated to C code - diff --git a/example/ruby/Lrama/Grammar/Code/DestructorCode.md b/example/ruby/Lrama/Grammar/Code/DestructorCode.md deleted file mode 100644 index 2beccf5..0000000 --- a/example/ruby/Lrama/Grammar/Code/DestructorCode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Lrama::Grammar::Code::DestructorCode -**Inherits:** Lrama::Grammar::Code - - - - - -#Instance Methods -## initialize(type:, token_code:, tag:) [](#method-i-initialize) - -**@return** [DestructorCode] a new instance of DestructorCode - diff --git a/example/ruby/Lrama/Grammar/Code/InitialActionCode.md b/example/ruby/Lrama/Grammar/Code/InitialActionCode.md deleted file mode 100644 index 5a530ef..0000000 --- a/example/ruby/Lrama/Grammar/Code/InitialActionCode.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Lrama::Grammar::Code::InitialActionCode -**Inherits:** Lrama::Grammar::Code - - - - - diff --git a/example/ruby/Lrama/Grammar/Code/NoReferenceCode.md b/example/ruby/Lrama/Grammar/Code/NoReferenceCode.md deleted file mode 100644 index 14cfceb..0000000 --- a/example/ruby/Lrama/Grammar/Code/NoReferenceCode.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Lrama::Grammar::Code::NoReferenceCode -**Inherits:** Lrama::Grammar::Code - - - - - diff --git a/example/ruby/Lrama/Grammar/Code/PrinterCode.md b/example/ruby/Lrama/Grammar/Code/PrinterCode.md deleted file mode 100644 index 0c0248e..0000000 --- a/example/ruby/Lrama/Grammar/Code/PrinterCode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Lrama::Grammar::Code::PrinterCode -**Inherits:** Lrama::Grammar::Code - - - - - -#Instance Methods -## initialize(type:, token_code:, tag:) [](#method-i-initialize) - -**@return** [PrinterCode] a new instance of PrinterCode - diff --git a/example/ruby/Lrama/Grammar/Code/RuleAction.md b/example/ruby/Lrama/Grammar/Code/RuleAction.md deleted file mode 100644 index 93c5792..0000000 --- a/example/ruby/Lrama/Grammar/Code/RuleAction.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Lrama::Grammar::Code::RuleAction -**Inherits:** Lrama::Grammar::Code - - - - - -#Instance Methods -## initialize(type:, token_code:, rule:) [](#method-i-initialize) - -**@return** [RuleAction] a new instance of RuleAction - diff --git a/example/ruby/Lrama/Grammar/Counter.md b/example/ruby/Lrama/Grammar/Counter.md deleted file mode 100644 index 0f15cd1..0000000 --- a/example/ruby/Lrama/Grammar/Counter.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Lrama::Grammar::Counter -**Inherits:** Object - - - - - -#Instance Methods -## increment() [](#method-i-increment) - -## initialize(number) [](#method-i-initialize) - -**@return** [Counter] a new instance of Counter - diff --git a/example/ruby/Lrama/Grammar/Destructor.md b/example/ruby/Lrama/Grammar/Destructor.md deleted file mode 100644 index fe37444..0000000 --- a/example/ruby/Lrama/Grammar/Destructor.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Lrama::Grammar::Destructor -**Inherits:** Struct - - - - -# Attributes -## ident_or_tags[RW] [](#attribute-i-ident_or_tags) -Returns the value of attribute ident_or_tags - -**@return** [Object] the current value of ident_or_tags - -## lineno[RW] [](#attribute-i-lineno) -Returns the value of attribute lineno - -**@return** [Object] the current value of lineno - -## token_code[RW] [](#attribute-i-token_code) -Returns the value of attribute token_code - -**@return** [Object] the current value of token_code - - -#Instance Methods -## translated_code(tag) [](#method-i-translated_code) - diff --git a/example/ruby/Lrama/Grammar/ErrorToken.md b/example/ruby/Lrama/Grammar/ErrorToken.md deleted file mode 100644 index 37ec7fa..0000000 --- a/example/ruby/Lrama/Grammar/ErrorToken.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Lrama::Grammar::ErrorToken -**Inherits:** Struct - - - - -# Attributes -## ident_or_tags[RW] [](#attribute-i-ident_or_tags) -Returns the value of attribute ident_or_tags - -**@return** [Object] the current value of ident_or_tags - -## lineno[RW] [](#attribute-i-lineno) -Returns the value of attribute lineno - -**@return** [Object] the current value of lineno - -## token_code[RW] [](#attribute-i-token_code) -Returns the value of attribute token_code - -**@return** [Object] the current value of token_code - - -#Instance Methods -## translated_code(tag) [](#method-i-translated_code) - diff --git a/example/ruby/Lrama/Grammar/ParameterizingRule.md b/example/ruby/Lrama/Grammar/ParameterizingRule.md deleted file mode 100644 index 144204f..0000000 --- a/example/ruby/Lrama/Grammar/ParameterizingRule.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Lrama::Grammar::ParameterizingRule -**Inherits:** Object - - - - - diff --git a/example/ruby/Lrama/Grammar/ParameterizingRule/Resolver.md b/example/ruby/Lrama/Grammar/ParameterizingRule/Resolver.md deleted file mode 100644 index 0aaf754..0000000 --- a/example/ruby/Lrama/Grammar/ParameterizingRule/Resolver.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Lrama::Grammar::ParameterizingRule::Resolver -**Inherits:** Object - - - - -# Attributes -## created_lhs_list[RW] [](#attribute-i-created_lhs_list) -Returns the value of attribute created_lhs_list. - -## rules[RW] [](#attribute-i-rules) -Returns the value of attribute rules. - - -#Instance Methods -## add_parameterizing_rule(rule) [](#method-i-add_parameterizing_rule) - -## created_lhs(lhs_s_value) [](#method-i-created_lhs) - -## find_inline(token) [](#method-i-find_inline) - -## find_rule(token) [](#method-i-find_rule) - -## initialize() [](#method-i-initialize) - -**@return** [Resolver] a new instance of Resolver - -## redefined_rules() [](#method-i-redefined_rules) - diff --git a/example/ruby/Lrama/Grammar/ParameterizingRule/Rhs.md b/example/ruby/Lrama/Grammar/ParameterizingRule/Rhs.md deleted file mode 100644 index 06180a9..0000000 --- a/example/ruby/Lrama/Grammar/ParameterizingRule/Rhs.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Lrama::Grammar::ParameterizingRule::Rhs -**Inherits:** Object - - - - -# Attributes -## precedence_sym[RW] [](#attribute-i-precedence_sym) -Returns the value of attribute precedence_sym. - -## symbols[RW] [](#attribute-i-symbols) -Returns the value of attribute symbols. - -## user_code[RW] [](#attribute-i-user_code) -Returns the value of attribute user_code. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Rhs] a new instance of Rhs - -## resolve_user_code(bindings) [](#method-i-resolve_user_code) - diff --git a/example/ruby/Lrama/Grammar/ParameterizingRule/Rule.md b/example/ruby/Lrama/Grammar/ParameterizingRule/Rule.md deleted file mode 100644 index c88061e..0000000 --- a/example/ruby/Lrama/Grammar/ParameterizingRule/Rule.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Lrama::Grammar::ParameterizingRule::Rule -**Inherits:** Object - - - - -# Attributes -## is_inline[RW] [](#attribute-i-is_inline) -Returns the value of attribute is_inline. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## parameters[RW] [](#attribute-i-parameters) -Returns the value of attribute parameters. - -## required_parameters_count[RW] [](#attribute-i-required_parameters_count) -Returns the value of attribute required_parameters_count. - -## rhs_list[RW] [](#attribute-i-rhs_list) -Returns the value of attribute rhs_list. - -## tag[RW] [](#attribute-i-tag) -Returns the value of attribute tag. - - -#Instance Methods -## initialize(name, parameters, rhs_list, tag:nil, is_inline:false) [](#method-i-initialize) - -**@return** [Rule] a new instance of Rule - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Lrama/Grammar/PercentCode.md b/example/ruby/Lrama/Grammar/PercentCode.md deleted file mode 100644 index 986872c..0000000 --- a/example/ruby/Lrama/Grammar/PercentCode.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Lrama::Grammar::PercentCode -**Inherits:** Object - - - - -# Attributes -## code[RW] [](#attribute-i-code) -Returns the value of attribute code. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name, code) [](#method-i-initialize) - -**@return** [PercentCode] a new instance of PercentCode - diff --git a/example/ruby/Lrama/Grammar/Precedence.md b/example/ruby/Lrama/Grammar/Precedence.md deleted file mode 100644 index 0d8eadf..0000000 --- a/example/ruby/Lrama/Grammar/Precedence.md +++ /dev/null @@ -1,106 +0,0 @@ -# Class: Lrama::Grammar::Precedence -**Inherits:** Struct - -**Includes:** Comparable - - - - -# Attributes -## precedence[RW] [](#attribute-i-precedence) -Returns the value of attribute precedence - -**@return** [Object] the current value of precedence - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type - -**@return** [Object] the current value of type - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Lrama/Grammar/Printer.md b/example/ruby/Lrama/Grammar/Printer.md deleted file mode 100644 index 592ef86..0000000 --- a/example/ruby/Lrama/Grammar/Printer.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Lrama::Grammar::Printer -**Inherits:** Struct - - - - -# Attributes -## ident_or_tags[RW] [](#attribute-i-ident_or_tags) -Returns the value of attribute ident_or_tags - -**@return** [Object] the current value of ident_or_tags - -## lineno[RW] [](#attribute-i-lineno) -Returns the value of attribute lineno - -**@return** [Object] the current value of lineno - -## token_code[RW] [](#attribute-i-token_code) -Returns the value of attribute token_code - -**@return** [Object] the current value of token_code - - -#Instance Methods -## translated_code(tag) [](#method-i-translated_code) - diff --git a/example/ruby/Lrama/Grammar/Reference.md b/example/ruby/Lrama/Grammar/Reference.md deleted file mode 100644 index a4bce6b..0000000 --- a/example/ruby/Lrama/Grammar/Reference.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Lrama::Grammar::Reference -**Inherits:** Struct - - -type: :dollar or :at name: String (e.g. $$, $foo, $expr.right) number: Integer -(e.g. $1) index: Integer ex_tag: "$1" (Optional) - - -# Attributes -## ex_tag[RW] [](#attribute-i-ex_tag) -Returns the value of attribute ex_tag - -**@return** [Object] the current value of ex_tag - -## first_column[RW] [](#attribute-i-first_column) -Returns the value of attribute first_column - -**@return** [Object] the current value of first_column - -## index[RW] [](#attribute-i-index) -Returns the value of attribute index - -**@return** [Object] the current value of index - -## last_column[RW] [](#attribute-i-last_column) -Returns the value of attribute last_column - -**@return** [Object] the current value of last_column - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name - -**@return** [Object] the current value of name - -## number[RW] [](#attribute-i-number) -Returns the value of attribute number - -**@return** [Object] the current value of number - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type - -**@return** [Object] the current value of type - - -#Instance Methods -## value() [](#method-i-value) - diff --git a/example/ruby/Lrama/Grammar/Rule.md b/example/ruby/Lrama/Grammar/Rule.md deleted file mode 100644 index e11c9ba..0000000 --- a/example/ruby/Lrama/Grammar/Rule.md +++ /dev/null @@ -1,95 +0,0 @@ -# Class: Lrama::Grammar::Rule -**Inherits:** Struct - - -_rhs holds original RHS element. Use rhs to refer to Symbol. - - -# Attributes -## _lhs[RW] [](#attribute-i-_lhs) -Returns the value of attribute _lhs - -**@return** [Object] the current value of _lhs - -## _rhs[RW] [](#attribute-i-_rhs) -Returns the value of attribute _rhs - -**@return** [Object] the current value of _rhs - -## id[RW] [](#attribute-i-id) -Returns the value of attribute id - -**@return** [Object] the current value of id - -## lhs[RW] [](#attribute-i-lhs) -Returns the value of attribute lhs - -**@return** [Object] the current value of lhs - -## lhs_tag[RW] [](#attribute-i-lhs_tag) -Returns the value of attribute lhs_tag - -**@return** [Object] the current value of lhs_tag - -## lineno[RW] [](#attribute-i-lineno) -Returns the value of attribute lineno - -**@return** [Object] the current value of lineno - -## nullable[RW] [](#attribute-i-nullable) -Returns the value of attribute nullable - -**@return** [Object] the current value of nullable - -## original_rule[RW] [](#attribute-i-original_rule) -Returns the value of attribute original_rule. - -## position_in_original_rule_rhs[RW] [](#attribute-i-position_in_original_rule_rhs) -Returns the value of attribute position_in_original_rule_rhs - -**@return** [Object] the current value of position_in_original_rule_rhs - -## precedence_sym[RW] [](#attribute-i-precedence_sym) -Returns the value of attribute precedence_sym - -**@return** [Object] the current value of precedence_sym - -## rhs[RW] [](#attribute-i-rhs) -Returns the value of attribute rhs - -**@return** [Object] the current value of rhs - -## token_code[RW] [](#attribute-i-token_code) -Returns the value of attribute token_code - -**@return** [Object] the current value of token_code - - -#Instance Methods -## ==(other) [](#method-i-==) - -## as_comment() [](#method-i-as_comment) -Used by #user_actions - -## contains_at_reference?() [](#method-i-contains_at_reference?) - -**@return** [Boolean] - -## display_name() [](#method-i-display_name) - -## empty_rule?() [](#method-i-empty_rule?) -opt_nl: ε <-- empty_rule - | '\n' <-- not empty_rule - -**@return** [Boolean] - -## initial_rule?() [](#method-i-initial_rule?) - -**@return** [Boolean] - -## precedence() [](#method-i-precedence) - -## translated_code() [](#method-i-translated_code) - -## with_actions() [](#method-i-with_actions) - diff --git a/example/ruby/Lrama/Grammar/RuleBuilder.md b/example/ruby/Lrama/Grammar/RuleBuilder.md deleted file mode 100644 index 4573f1d..0000000 --- a/example/ruby/Lrama/Grammar/RuleBuilder.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: Lrama::Grammar::RuleBuilder -**Inherits:** Object - - - - -# Attributes -## lhs[RW] [](#attribute-i-lhs) -Returns the value of attribute lhs. - -## lhs_tag[RW] [](#attribute-i-lhs_tag) -Returns the value of attribute lhs_tag. - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line. - -## precedence_sym[RW] [](#attribute-i-precedence_sym) -Returns the value of attribute precedence_sym. - -## rhs[RW] [](#attribute-i-rhs) -Returns the value of attribute rhs. - -## user_code[RW] [](#attribute-i-user_code) -Returns the value of attribute user_code. - - -#Instance Methods -## add_rhs(rhs) [](#method-i-add_rhs) - -## complete_input() [](#method-i-complete_input) - -## has_inline_rules?() [](#method-i-has_inline_rules?) - -**@return** [Boolean] - -## initialize(rule_counter, midrule_action_counter, parameterizing_rule_resolver, position_in_original_rule_rhsnil, lhs_tag:nil, skip_preprocess_references:false) [](#method-i-initialize) - -**@return** [RuleBuilder] a new instance of RuleBuilder - -## resolve_inline_rules() [](#method-i-resolve_inline_rules) - -## rules() [](#method-i-rules) - -## setup_rules() [](#method-i-setup_rules) - diff --git a/example/ruby/Lrama/Grammar/Symbol.md b/example/ruby/Lrama/Grammar/Symbol.md deleted file mode 100644 index 21b457a..0000000 --- a/example/ruby/Lrama/Grammar/Symbol.md +++ /dev/null @@ -1,106 +0,0 @@ -# Class: Lrama::Grammar::Symbol -**Inherits:** Object - - - - -# Attributes -## accept_symbol=[R] [](#attribute-i-accept_symbol=) -Sets the attribute accept_symbol - -**@param** [] the value to set the attribute accept_symbol to. - -## alias_name[RW] [](#attribute-i-alias_name) -Returns the value of attribute alias_name. - -## destructor[RW] [](#attribute-i-destructor) -Returns the value of attribute destructor. - -## eof_symbol=[R] [](#attribute-i-eof_symbol=) -Sets the attribute eof_symbol - -**@param** [] the value to set the attribute eof_symbol to. - -## error_symbol=[R] [](#attribute-i-error_symbol=) -Sets the attribute error_symbol - -**@param** [] the value to set the attribute error_symbol to. - -## error_token[RW] [](#attribute-i-error_token) -Returns the value of attribute error_token. - -## first_set[RW] [](#attribute-i-first_set) -Returns the value of attribute first_set. - -## first_set_bitmap[RW] [](#attribute-i-first_set_bitmap) -Returns the value of attribute first_set_bitmap. - -## id[RW] [](#attribute-i-id) -Returns the value of attribute id. - -## nullable[RW] [](#attribute-i-nullable) -Returns the value of attribute nullable. - -## number[RW] [](#attribute-i-number) -Returns the value of attribute number. - -## precedence[RW] [](#attribute-i-precedence) -Returns the value of attribute precedence. - -## printer[RW] [](#attribute-i-printer) -Returns the value of attribute printer. - -## tag[RW] [](#attribute-i-tag) -Returns the value of attribute tag. - -## term[RW] [](#attribute-i-term) -Returns the value of attribute term. - -## token_id[RW] [](#attribute-i-token_id) -Returns the value of attribute token_id. - -## undef_symbol=[R] [](#attribute-i-undef_symbol=) -Sets the attribute undef_symbol - -**@param** [] the value to set the attribute undef_symbol to. - - -#Instance Methods -## accept_symbol?() [](#method-i-accept_symbol?) - -**@return** [Boolean] - -## comment() [](#method-i-comment) -comment for yysymbol_kind_t - -## display_name() [](#method-i-display_name) - -## enum_name() [](#method-i-enum_name) -name for yysymbol_kind_t - -See: b4_symbol_kind_base - -## eof_symbol?() [](#method-i-eof_symbol?) - -**@return** [Boolean] - -## error_symbol?() [](#method-i-error_symbol?) - -**@return** [Boolean] - -## initialize(id:, term:, alias_name:nil, number:nil, tag:nil, token_id:nil, nullable:nil, precedence:nil, printer:nil, destructor:nil) [](#method-i-initialize) - -**@return** [Symbol] a new instance of Symbol - -## nterm?() [](#method-i-nterm?) - -**@return** [Boolean] - -## term?() [](#method-i-term?) - -**@return** [Boolean] - -## undef_symbol?() [](#method-i-undef_symbol?) - -**@return** [Boolean] - diff --git a/example/ruby/Lrama/Grammar/Symbols.md b/example/ruby/Lrama/Grammar/Symbols.md deleted file mode 100644 index 597335e..0000000 --- a/example/ruby/Lrama/Grammar/Symbols.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Lrama::Grammar::Symbols -**Inherits:** Object - - - - - diff --git a/example/ruby/Lrama/Grammar/Symbols/Resolver.md b/example/ruby/Lrama/Grammar/Symbols/Resolver.md deleted file mode 100644 index 8da46b9..0000000 --- a/example/ruby/Lrama/Grammar/Symbols/Resolver.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: Lrama::Grammar::Symbols::Resolver -**Inherits:** Object - - - - -# Attributes -## nterms[RW] [](#attribute-i-nterms) -Returns the value of attribute nterms. - -## terms[RW] [](#attribute-i-terms) -Returns the value of attribute terms. - - -#Instance Methods -## add_nterm(id:, alias_name:nil, tag:nil) [](#method-i-add_nterm) - -## add_term(id:, alias_name:nil, tag:nil, token_id:nil, replace:false) [](#method-i-add_term) - -## fill_destructor(destructors) [](#method-i-fill_destructor) - -## fill_error_token(error_tokens) [](#method-i-fill_error_token) - -## fill_nterm_type(types) [](#method-i-fill_nterm_type) - -## fill_printer(printers) [](#method-i-fill_printer) - -## fill_symbol_number() [](#method-i-fill_symbol_number) - -## find_symbol_by_id(id) [](#method-i-find_symbol_by_id) - -## find_symbol_by_id!(id) [](#method-i-find_symbol_by_id!) - -## find_symbol_by_number!(number) [](#method-i-find_symbol_by_number!) - -## find_symbol_by_s_value(s_value) [](#method-i-find_symbol_by_s_value) - -## find_symbol_by_s_value!(s_value) [](#method-i-find_symbol_by_s_value!) - -## find_symbol_by_token_id(token_id) [](#method-i-find_symbol_by_token_id) - -## find_term_by_s_value(s_value) [](#method-i-find_term_by_s_value) - -## initialize() [](#method-i-initialize) - -**@return** [Resolver] a new instance of Resolver - -## sort_by_number!() [](#method-i-sort_by_number!) - -## symbols() [](#method-i-symbols) - -## token_to_symbol(token) [](#method-i-token_to_symbol) - -## validate!() [](#method-i-validate!) - diff --git a/example/ruby/Lrama/Grammar/Type.md b/example/ruby/Lrama/Grammar/Type.md deleted file mode 100644 index 4a4eae7..0000000 --- a/example/ruby/Lrama/Grammar/Type.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Lrama::Grammar::Type -**Inherits:** Object - - - - -# Attributes -## id[RW] [](#attribute-i-id) -Returns the value of attribute id. - -## tag[RW] [](#attribute-i-tag) -Returns the value of attribute tag. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(id:, tag:) [](#method-i-initialize) - -**@return** [Type] a new instance of Type - diff --git a/example/ruby/Lrama/Grammar/Union.md b/example/ruby/Lrama/Grammar/Union.md deleted file mode 100644 index dcfb6c4..0000000 --- a/example/ruby/Lrama/Grammar/Union.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Lrama::Grammar::Union -**Inherits:** Struct - - - - -# Attributes -## code[RW] [](#attribute-i-code) -Returns the value of attribute code - -**@return** [Object] the current value of code - -## lineno[RW] [](#attribute-i-lineno) -Returns the value of attribute lineno - -**@return** [Object] the current value of lineno - - -#Instance Methods -## braces_less_code() [](#method-i-braces_less_code) - diff --git a/example/ruby/Lrama/GrammarValidator.md b/example/ruby/Lrama/GrammarValidator.md deleted file mode 100644 index 0107224..0000000 --- a/example/ruby/Lrama/GrammarValidator.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Lrama::GrammarValidator -**Inherits:** Object - - - - - -#Instance Methods -## initialize(grammar, states, logger) [](#method-i-initialize) - -**@return** [GrammarValidator] a new instance of GrammarValidator - -## valid?() [](#method-i-valid?) - -**@return** [Boolean] - diff --git a/example/ruby/Lrama/Lexer.md b/example/ruby/Lrama/Lexer.md deleted file mode 100644 index 7cb5e7b..0000000 --- a/example/ruby/Lrama/Lexer.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Lrama::Lexer -**Inherits:** Object - - - - -# Attributes -## end_symbol[RW] [](#attribute-i-end_symbol) -Returns the value of attribute end_symbol. - -## head_column[RW] [](#attribute-i-head_column) -Returns the value of attribute head_column. - -## head_line[RW] [](#attribute-i-head_line) -Returns the value of attribute head_line. - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line. - -## status[RW] [](#attribute-i-status) -Returns the value of attribute status. - - -#Instance Methods -## column() [](#method-i-column) - -## initialize(grammar_file) [](#method-i-initialize) - -**@return** [Lexer] a new instance of Lexer - -## lex_c_code() [](#method-i-lex_c_code) - -**@raise** [ParseError] - -## lex_token() [](#method-i-lex_token) - -## location() [](#method-i-location) - -## next_token() [](#method-i-next_token) - diff --git a/example/ruby/Lrama/Lexer/GrammarFile.md b/example/ruby/Lrama/Lexer/GrammarFile.md deleted file mode 100644 index 39b9913..0000000 --- a/example/ruby/Lrama/Lexer/GrammarFile.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Lrama::Lexer::GrammarFile -**Inherits:** Object - - - - -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - -## text[RW] [](#attribute-i-text) -Returns the value of attribute text. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(path, text) [](#method-i-initialize) - -**@return** [GrammarFile] a new instance of GrammarFile - -## inspect() [](#method-i-inspect) - -## lines() [](#method-i-lines) - diff --git a/example/ruby/Lrama/Lexer/GrammarFile/Text.md b/example/ruby/Lrama/Lexer/GrammarFile/Text.md deleted file mode 100644 index fd5ee46..0000000 --- a/example/ruby/Lrama/Lexer/GrammarFile/Text.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Lrama::Lexer::GrammarFile::Text -**Inherits:** String - - - - - -#Instance Methods -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/Lrama/Lexer/Location.md b/example/ruby/Lrama/Lexer/Location.md deleted file mode 100644 index 67e0e36..0000000 --- a/example/ruby/Lrama/Lexer/Location.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Lrama::Lexer::Location -**Inherits:** Object - - - - -# Attributes -## first_column[RW] [](#attribute-i-first_column) -Returns the value of attribute first_column. - -## first_line[RW] [](#attribute-i-first_line) -Returns the value of attribute first_line. - -## grammar_file[RW] [](#attribute-i-grammar_file) -Returns the value of attribute grammar_file. - -## last_column[RW] [](#attribute-i-last_column) -Returns the value of attribute last_column. - -## last_line[RW] [](#attribute-i-last_line) -Returns the value of attribute last_line. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## generate_error_message(error_message) [](#method-i-generate_error_message) - -## initialize(grammar_file:, first_line:, first_column:, last_line:, last_column:) [](#method-i-initialize) - -**@return** [Location] a new instance of Location - -## line_with_carets() [](#method-i-line_with_carets) - -## partial_location(left, right) [](#method-i-partial_location) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Lrama/Lexer/Token.md b/example/ruby/Lrama/Lexer/Token.md deleted file mode 100644 index d85432e..0000000 --- a/example/ruby/Lrama/Lexer/Token.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: Lrama::Lexer::Token -**Inherits:** Object - - - - -# Attributes -## alias_name[RW] [](#attribute-i-alias_name) -Returns the value of attribute alias_name. - -## location[RW] [](#attribute-i-location) -Returns the value of attribute location. - -## referred[RW] [](#attribute-i-referred) -Returns the value of attribute referred. - -## s_value[RW] [](#attribute-i-s_value) -Returns the value of attribute s_value. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## first_column() [](#method-i-first_column) - -## first_line() [](#method-i-first_line) - -## initialize(s_value:, alias_name:nil, location:nil) [](#method-i-initialize) - -**@return** [Token] a new instance of Token - -## invalid_ref(ref, message) [](#method-i-invalid_ref) - -## last_column() [](#method-i-last_column) - -## last_line() [](#method-i-last_line) - -## referred_by?(string) [](#method-i-referred_by?) - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Lrama/Lexer/Token/Char.md b/example/ruby/Lrama/Lexer/Token/Char.md deleted file mode 100644 index 1582f82..0000000 --- a/example/ruby/Lrama/Lexer/Token/Char.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Lrama::Lexer::Token::Char -**Inherits:** Lrama::Lexer::Token - - - - - diff --git a/example/ruby/Lrama/Lexer/Token/Ident.md b/example/ruby/Lrama/Lexer/Token/Ident.md deleted file mode 100644 index b488113..0000000 --- a/example/ruby/Lrama/Lexer/Token/Ident.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Lrama::Lexer::Token::Ident -**Inherits:** Lrama::Lexer::Token - - - - - diff --git a/example/ruby/Lrama/Lexer/Token/InstantiateRule.md b/example/ruby/Lrama/Lexer/Token/InstantiateRule.md deleted file mode 100644 index 9f6040e..0000000 --- a/example/ruby/Lrama/Lexer/Token/InstantiateRule.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Lrama::Lexer::Token::InstantiateRule -**Inherits:** Lrama::Lexer::Token - - - - -# Attributes -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## lhs_tag[RW] [](#attribute-i-lhs_tag) -Returns the value of attribute lhs_tag. - - -#Instance Methods -## args_count() [](#method-i-args_count) - -## initialize(s_value:, alias_name:nil, location:nil, args:[], lhs_tag:nil) [](#method-i-initialize) - -**@return** [InstantiateRule] a new instance of InstantiateRule - -## rule_name() [](#method-i-rule_name) - diff --git a/example/ruby/Lrama/Lexer/Token/Tag.md b/example/ruby/Lrama/Lexer/Token/Tag.md deleted file mode 100644 index 299c321..0000000 --- a/example/ruby/Lrama/Lexer/Token/Tag.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Lrama::Lexer::Token::Tag -**Inherits:** Lrama::Lexer::Token - - - - - -#Instance Methods -## member() [](#method-i-member) -Omit "<>" - diff --git a/example/ruby/Lrama/Lexer/Token/UserCode.md b/example/ruby/Lrama/Lexer/Token/UserCode.md deleted file mode 100644 index 5dcf17b..0000000 --- a/example/ruby/Lrama/Lexer/Token/UserCode.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Lrama::Lexer::Token::UserCode -**Inherits:** Lrama::Lexer::Token - - - - -# Attributes -## tag[RW] [](#attribute-i-tag) -Returns the value of attribute tag. - - -#Instance Methods -## references() [](#method-i-references) - diff --git a/example/ruby/Lrama/Logger.md b/example/ruby/Lrama/Logger.md deleted file mode 100644 index 86dcf66..0000000 --- a/example/ruby/Lrama/Logger.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Lrama::Logger -**Inherits:** Object - - - - - -#Instance Methods -## error(message) [](#method-i-error) - -## initialize(outSTDERR) [](#method-i-initialize) - -**@return** [Logger] a new instance of Logger - -## warn(message) [](#method-i-warn) - diff --git a/example/ruby/Lrama/OptionParser.md b/example/ruby/Lrama/OptionParser.md deleted file mode 100644 index 7707f78..0000000 --- a/example/ruby/Lrama/OptionParser.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Lrama::OptionParser -**Inherits:** Object - - -Handle option parsing for the command line interface. - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [OptionParser] a new instance of OptionParser - -## parse(argv) [](#method-i-parse) - diff --git a/example/ruby/Lrama/Options.md b/example/ruby/Lrama/Options.md deleted file mode 100644 index 0f4b53f..0000000 --- a/example/ruby/Lrama/Options.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: Lrama::Options -**Inherits:** Object - - -Command line options. - - -# Attributes -## debug[RW] [](#attribute-i-debug) -Returns the value of attribute debug. - -## diagnostic[RW] [](#attribute-i-diagnostic) -Returns the value of attribute diagnostic. - -## error_recovery[RW] [](#attribute-i-error_recovery) -Returns the value of attribute error_recovery. - -## grammar_file[RW] [](#attribute-i-grammar_file) -Returns the value of attribute grammar_file. - -## header[RW] [](#attribute-i-header) -Returns the value of attribute header. - -## header_file[RW] [](#attribute-i-header_file) -Returns the value of attribute header_file. - -## outfile[RW] [](#attribute-i-outfile) -Returns the value of attribute outfile. - -## report_file[RW] [](#attribute-i-report_file) -Returns the value of attribute report_file. - -## report_opts[RW] [](#attribute-i-report_opts) -Returns the value of attribute report_opts. - -## skeleton[RW] [](#attribute-i-skeleton) -Returns the value of attribute skeleton. - -## trace_opts[RW] [](#attribute-i-trace_opts) -Returns the value of attribute trace_opts. - -## y[RW] [](#attribute-i-y) -Returns the value of attribute y. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Options] a new instance of Options - diff --git a/example/ruby/Lrama/Output.md b/example/ruby/Lrama/Output.md deleted file mode 100644 index 4975226..0000000 --- a/example/ruby/Lrama/Output.md +++ /dev/null @@ -1,165 +0,0 @@ -# Class: Lrama::Output -**Inherits:** Object - -**Extended by:** Forwardable - -**Includes:** Lrama::Report::Duration - - - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## erb(input ) [](#method-c-erb) -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -# Attributes -## context[RW] [](#attribute-i-context) -Returns the value of attribute context. - -## error_recovery[RW] [](#attribute-i-error_recovery) -Returns the value of attribute error_recovery. - -## grammar[RW] [](#attribute-i-grammar) -Returns the value of attribute grammar. - -## grammar_file_path[RW] [](#attribute-i-grammar_file_path) -Returns the value of attribute grammar_file_path. - -## include_header[RW] [](#attribute-i-include_header) -Returns the value of attribute include_header. - - -#Instance Methods -## after_pop_stack_function(len, comment"") [](#method-i-after_pop_stack_function) - -## after_reduce_function(comment"") [](#method-i-after_reduce_function) - -## after_shift_error_token_function(comment"") [](#method-i-after_shift_error_token_function) - -## after_shift_function(comment"") [](#method-i-after_shift_function) - -## aux() [](#method-i-aux) - -## b4_cpp_guard__b4_spec_mapped_header_file() [](#method-i-b4_cpp_guard__b4_spec_mapped_header_file) - -## before_reduce_function(comment"") [](#method-i-before_reduce_function) - -## extract_param_name(param) [](#method-i-extract_param_name) - -## initialize(out:, output_file_path:, template_name:, grammar_file_path:, context:, grammar:, header_out:nil, header_file_path:nil, error_recovery:false) [](#method-i-initialize) - -**@return** [Output] a new instance of Output - -## int_array_to_string(ary) [](#method-i-int_array_to_string) - -## int_type_for(ary) [](#method-i-int_type_for) -b4_int_type_for - -## lex_param() [](#method-i-lex_param) - -## lex_param_name() [](#method-i-lex_param_name) - -## omit_blanks(param) [](#method-i-omit_blanks) - -## parse_param() [](#method-i-parse_param) -b4_parse_param - -## parse_param_name() [](#method-i-parse_param_name) - -## parse_param_use(val, loc) [](#method-i-parse_param_use) -b4_parse_param_use - -## percent_code(name) [](#method-i-percent_code) -b4_percent_code_get - -## render() [](#method-i-render) - -## render_partial(file) [](#method-i-render_partial) - -## report_duration(method_name) [](#method-i-report_duration) - -## spec_mapped_header_file() [](#method-i-spec_mapped_header_file) - -## symbol_actions_for_destructor() [](#method-i-symbol_actions_for_destructor) - -## symbol_actions_for_error_token() [](#method-i-symbol_actions_for_error_token) - -## symbol_actions_for_printer() [](#method-i-symbol_actions_for_printer) - -## symbol_enum() [](#method-i-symbol_enum) -b4_symbol_enum - -## table_value_equals(table, value, literal, symbol) [](#method-i-table_value_equals) -b4_table_value_equals - -## template_basename() [](#method-i-template_basename) - -## token_enums() [](#method-i-token_enums) -A part of b4_token_enums - -## user_actions() [](#method-i-user_actions) -b4_user_actions - -## user_args() [](#method-i-user_args) -b4_user_args - -## user_formals() [](#method-i-user_formals) -b4_user_formals - -## user_initial_action(comment"") [](#method-i-user_initial_action) -b4_user_initial_action - -## yyerror_args() [](#method-i-yyerror_args) -b4_yyerror_args - -## yylex_formals() [](#method-i-yylex_formals) -b4_yylex_formals - -## yyrline() [](#method-i-yyrline) - -## yytname() [](#method-i-yytname) - -## yytranslate() [](#method-i-yytranslate) - -## yytranslate_inverted() [](#method-i-yytranslate_inverted) - diff --git a/example/ruby/Lrama/Parser.md b/example/ruby/Lrama/Parser.md deleted file mode 100644 index a791b12..0000000 --- a/example/ruby/Lrama/Parser.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Lrama::Parser -**Inherits:** Racc::Parser - - - - - -#Instance Methods -## _reduce_none(val, _values, result) [](#method-i-_reduce_none) - diff --git a/example/ruby/Lrama/Report.md b/example/ruby/Lrama/Report.md deleted file mode 100644 index 028f4c6..0000000 --- a/example/ruby/Lrama/Report.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Lrama::Report -**Inherits:** Object - - - - - diff --git a/example/ruby/Lrama/Report/Duration.md b/example/ruby/Lrama/Report/Duration.md deleted file mode 100644 index 166a1a3..0000000 --- a/example/ruby/Lrama/Report/Duration.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: Lrama::Report::Duration - - - - -# Class Methods -## enable() [](#method-c-enable) -## enabled?() [](#method-c-enabled?) -**@return** [Boolean] - - -#Instance Methods -## report_duration(method_name) [](#method-i-report_duration) - diff --git a/example/ruby/Lrama/Report/Profile.md b/example/ruby/Lrama/Report/Profile.md deleted file mode 100644 index 39fde1a..0000000 --- a/example/ruby/Lrama/Report/Profile.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Lrama::Report::Profile - - - - -# Class Methods -## report_profile() [](#method-c-report_profile) -See "Profiling Lrama" in README.md for how to use. - diff --git a/example/ruby/Lrama/State.md b/example/ruby/Lrama/State.md deleted file mode 100644 index 4bdc14d..0000000 --- a/example/ruby/Lrama/State.md +++ /dev/null @@ -1,72 +0,0 @@ -# Class: Lrama::State -**Inherits:** Object - - - - -# Attributes -## accessing_symbol[RW] [](#attribute-i-accessing_symbol) -Returns the value of attribute accessing_symbol. - -## closure[RW] [](#attribute-i-closure) -Returns the value of attribute closure. - -## conflicts[RW] [](#attribute-i-conflicts) -Returns the value of attribute conflicts. - -## default_reduction_rule[RW] [](#attribute-i-default_reduction_rule) -Returns the value of attribute default_reduction_rule. - -## id[RW] [](#attribute-i-id) -Returns the value of attribute id. - -## items[RW] [](#attribute-i-items) -Returns the value of attribute items. - -## kernels[RW] [](#attribute-i-kernels) -Returns the value of attribute kernels. - -## reduces[RW] [](#attribute-i-reduces) -Returns the value of attribute reduces. - -## resolved_conflicts[RW] [](#attribute-i-resolved_conflicts) -Returns the value of attribute resolved_conflicts. - -## shifts[RW] [](#attribute-i-shifts) -Returns the value of attribute shifts. - - -#Instance Methods -## compute_shifts_reduces() [](#method-i-compute_shifts_reduces) - -## find_reduce_by_item!(item) [](#method-i-find_reduce_by_item!) - -## has_conflicts?() [](#method-i-has_conflicts?) - -**@return** [Boolean] - -## initialize(id, accessing_symbol, kernels) [](#method-i-initialize) - -**@return** [State] a new instance of State - -## non_default_reduces() [](#method-i-non_default_reduces) - -## nterm_transitions() [](#method-i-nterm_transitions) - -## rr_conflicts() [](#method-i-rr_conflicts) - -## selected_term_transitions() [](#method-i-selected_term_transitions) - -## set_items_to_state(items, next_state) [](#method-i-set_items_to_state) - -## set_look_ahead(rule, look_ahead) [](#method-i-set_look_ahead) - -## sr_conflicts() [](#method-i-sr_conflicts) - -## term_transitions() [](#method-i-term_transitions) - -## transition(sym) [](#method-i-transition) -Move to next state by sym - -## transitions() [](#method-i-transitions) - diff --git a/example/ruby/Lrama/State/Reduce.md b/example/ruby/Lrama/State/Reduce.md deleted file mode 100644 index 39f3e4f..0000000 --- a/example/ruby/Lrama/State/Reduce.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Lrama::State::Reduce -**Inherits:** Object - - - - -# Attributes -## default_reduction[RW] [](#attribute-i-default_reduction) -Returns the value of attribute default_reduction. - -## item[RW] [](#attribute-i-item) -https://www.gnu.org/software/bison/manual/html_node/Default-Reductions.html - -## look_ahead[RW] [](#attribute-i-look_ahead) -https://www.gnu.org/software/bison/manual/html_node/Default-Reductions.html - -## not_selected_symbols[RW] [](#attribute-i-not_selected_symbols) -https://www.gnu.org/software/bison/manual/html_node/Default-Reductions.html - - -#Instance Methods -## add_not_selected_symbol(sym) [](#method-i-add_not_selected_symbol) - -## initialize(item) [](#method-i-initialize) - -**@return** [Reduce] a new instance of Reduce - -## rule() [](#method-i-rule) - -## selected_look_ahead() [](#method-i-selected_look_ahead) - diff --git a/example/ruby/Lrama/State/ReduceReduceConflict.md b/example/ruby/Lrama/State/ReduceReduceConflict.md deleted file mode 100644 index 6a7ff86..0000000 --- a/example/ruby/Lrama/State/ReduceReduceConflict.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Lrama::State::ReduceReduceConflict -**Inherits:** Struct - - - - -# Attributes -## reduce1[RW] [](#attribute-i-reduce1) -Returns the value of attribute reduce1 - -**@return** [Object] the current value of reduce1 - -## reduce2[RW] [](#attribute-i-reduce2) -Returns the value of attribute reduce2 - -**@return** [Object] the current value of reduce2 - -## symbols[RW] [](#attribute-i-symbols) -Returns the value of attribute symbols - -**@return** [Object] the current value of symbols - - -#Instance Methods -## type() [](#method-i-type) - diff --git a/example/ruby/Lrama/State/ResolvedConflict.md b/example/ruby/Lrama/State/ResolvedConflict.md deleted file mode 100644 index 34209bd..0000000 --- a/example/ruby/Lrama/State/ResolvedConflict.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Lrama::State::ResolvedConflict -**Inherits:** Struct - - -* symbol: A symbol under discussion -* reduce: A reduce under discussion -* which: For which a conflict is resolved. :shift, :reduce or :error (for - nonassociative) - - -# Attributes -## reduce[RW] [](#attribute-i-reduce) -Returns the value of attribute reduce - -**@return** [Object] the current value of reduce - -## same_prec[RW] [](#attribute-i-same_prec) -Returns the value of attribute same_prec - -**@return** [Object] the current value of same_prec - -## symbol[RW] [](#attribute-i-symbol) -Returns the value of attribute symbol - -**@return** [Object] the current value of symbol - -## which[RW] [](#attribute-i-which) -Returns the value of attribute which - -**@return** [Object] the current value of which - - -#Instance Methods -## report_message() [](#method-i-report_message) - diff --git a/example/ruby/Lrama/State/Shift.md b/example/ruby/Lrama/State/Shift.md deleted file mode 100644 index 0d4e019..0000000 --- a/example/ruby/Lrama/State/Shift.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Lrama::State::Shift -**Inherits:** Object - - - - -# Attributes -## next_items[RW] [](#attribute-i-next_items) -Returns the value of attribute next_items. - -## next_sym[RW] [](#attribute-i-next_sym) -Returns the value of attribute next_sym. - -## not_selected[RW] [](#attribute-i-not_selected) -Returns the value of attribute not_selected. - - -#Instance Methods -## initialize(next_sym, next_items) [](#method-i-initialize) - -**@return** [Shift] a new instance of Shift - diff --git a/example/ruby/Lrama/State/ShiftReduceConflict.md b/example/ruby/Lrama/State/ShiftReduceConflict.md deleted file mode 100644 index 69bf670..0000000 --- a/example/ruby/Lrama/State/ShiftReduceConflict.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Lrama::State::ShiftReduceConflict -**Inherits:** Struct - - - - -# Attributes -## reduce[RW] [](#attribute-i-reduce) -Returns the value of attribute reduce - -**@return** [Object] the current value of reduce - -## shift[RW] [](#attribute-i-shift) -Returns the value of attribute shift - -**@return** [Object] the current value of shift - -## symbols[RW] [](#attribute-i-symbols) -Returns the value of attribute symbols - -**@return** [Object] the current value of symbols - - -#Instance Methods -## type() [](#method-i-type) - diff --git a/example/ruby/Lrama/States.md b/example/ruby/Lrama/States.md deleted file mode 100644 index ef4fcd1..0000000 --- a/example/ruby/Lrama/States.md +++ /dev/null @@ -1,96 +0,0 @@ -# Class: Lrama::States -**Inherits:** Object - -**Extended by:** Forwardable - -**Includes:** Lrama::Report::Duration - - -States is passed to a template file - -"Efficient Computation of LALR(1) Look-Ahead Sets" - https://dl.acm.org/doi/pdf/10.1145/69622.357187 - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -# Attributes -## includes_relation[RW] [](#attribute-i-includes_relation) -Returns the value of attribute includes_relation. - -## lookback_relation[RW] [](#attribute-i-lookback_relation) -Returns the value of attribute lookback_relation. - -## reads_relation[RW] [](#attribute-i-reads_relation) -Returns the value of attribute reads_relation. - -## states[RW] [](#attribute-i-states) -Returns the value of attribute states. - - -#Instance Methods -## compute() [](#method-i-compute) - -## direct_read_sets() [](#method-i-direct_read_sets) - -## follow_sets() [](#method-i-follow_sets) - -## initialize(grammar, trace_state:false) [](#method-i-initialize) - -**@return** [States] a new instance of States - -## la() [](#method-i-la) - -## read_sets() [](#method-i-read_sets) - -## report_duration(method_name) [](#method-i-report_duration) - -## reporter() [](#method-i-reporter) - -## rr_conflicts_count() [](#method-i-rr_conflicts_count) - -## sr_conflicts_count() [](#method-i-sr_conflicts_count) - -## states_count() [](#method-i-states_count) - diff --git a/example/ruby/Lrama/States/Item.md b/example/ruby/Lrama/States/Item.md deleted file mode 100644 index fea6722..0000000 --- a/example/ruby/Lrama/States/Item.md +++ /dev/null @@ -1,108 +0,0 @@ -# Class: Lrama::States::Item -**Inherits:** Struct - -**Extended by:** Forwardable - - - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -# Attributes -## position[RW] [](#attribute-i-position) -Returns the value of attribute position - -**@return** [Object] the current value of position - -## rule[RW] [](#attribute-i-rule) -Returns the value of attribute rule - -**@return** [Object] the current value of rule - - -#Instance Methods -## beginning_of_rule?() [](#method-i-beginning_of_rule?) - -**@return** [Boolean] - -## display_name() [](#method-i-display_name) - -## display_rest() [](#method-i-display_rest) -Right after position - -## empty_rule?() [](#method-i-empty_rule?) - -**@return** [Boolean] - -## end_of_rule?() [](#method-i-end_of_rule?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) -Optimization for States#setup_state - -## new_by_next_position() [](#method-i-new_by_next_position) - -## next_next_sym() [](#method-i-next_next_sym) - -## next_sym() [](#method-i-next_sym) - -## number_of_rest_symbols() [](#method-i-number_of_rest_symbols) - -## previous_sym() [](#method-i-previous_sym) - -## rule_id() [](#method-i-rule_id) - -## start_item?() [](#method-i-start_item?) - -**@return** [Boolean] - -## symbols_after_dot() [](#method-i-symbols_after_dot) -steep:ignore - -## symbols_before_dot() [](#method-i-symbols_before_dot) -steep:ignore - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Lrama/StatesReporter.md b/example/ruby/Lrama/StatesReporter.md deleted file mode 100644 index 8b080c4..0000000 --- a/example/ruby/Lrama/StatesReporter.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Lrama::StatesReporter -**Inherits:** Object - -**Includes:** Lrama::Report::Duration - - - - - -#Instance Methods -## initialize(states) [](#method-i-initialize) - -**@return** [StatesReporter] a new instance of StatesReporter - -## report(io, **options) [](#method-i-report) - -## report_duration(method_name) [](#method-i-report_duration) - diff --git a/example/ruby/Lrama/TraceReporter.md b/example/ruby/Lrama/TraceReporter.md deleted file mode 100644 index 682123f..0000000 --- a/example/ruby/Lrama/TraceReporter.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Lrama::TraceReporter -**Inherits:** Object - - - - - -#Instance Methods -## initialize(grammar) [](#method-i-initialize) - -**@return** [TraceReporter] a new instance of TraceReporter - -## report(**options) [](#method-i-report) - diff --git a/example/ruby/M001.md b/example/ruby/M001.md deleted file mode 100644 index 45862fe..0000000 --- a/example/ruby/M001.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: M001 - - - - - diff --git a/example/ruby/M002.md b/example/ruby/M002.md deleted file mode 100644 index b322a3a..0000000 --- a/example/ruby/M002.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: M002 - -**Includes:** M001 - - - - - diff --git a/example/ruby/M003.md b/example/ruby/M003.md deleted file mode 100644 index 0f2b631..0000000 --- a/example/ruby/M003.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: M003 - -**Includes:** M002 - - - - - diff --git a/example/ruby/MD5Constants.md b/example/ruby/MD5Constants.md deleted file mode 100644 index 395352c..0000000 --- a/example/ruby/MD5Constants.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MD5Constants - - - - - diff --git a/example/ruby/MOSConfig.md b/example/ruby/MOSConfig.md deleted file mode 100644 index 15fe36c..0000000 --- a/example/ruby/MOSConfig.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MOSConfig -**Inherits:** Hash - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MOSConfig] a new instance of MOSConfig - diff --git a/example/ruby/MPart.md b/example/ruby/MPart.md deleted file mode 100644 index d972cb4..0000000 --- a/example/ruby/MPart.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: MPart -**Inherits:** File - - -! ./ruby split into multi part usage: mpart.rb [-nnn] file.. - - -# Class Methods -## new(basename , extname , part , parts ) [](#method-c-new) - -#Instance Methods -## begin_mpart(basename, part, parts) [](#method-i-begin_mpart) - -## close() [](#method-i-close) - diff --git a/example/ruby/MSpec.md b/example/ruby/MSpec.md deleted file mode 100644 index a140989..0000000 --- a/example/ruby/MSpec.md +++ /dev/null @@ -1,157 +0,0 @@ -# Module: MSpec - - - - -# Class Methods -## actions(action , *args ) [](#method-c-actions) -## clear_current() [](#method-c-clear_current) -Sets the toplevel ContextState to `nil`. -## clear_expectations() [](#method-c-clear_expectations) -Resets the flag that an expectation has been encountered in an example. -## clear_modes() [](#method-c-clear_modes) -Clears all registered modes. -## current() [](#method-c-current) -Returns the toplevel ContextState. -## delete_tag(tag ) [](#method-c-delete_tag) -Deletes `tag` from the tag file if it exists. Returns `true` if the tag is -deleted, `false` otherwise. Deletes the tag file if it is empty. -## delete_tags() [](#method-c-delete_tags) -Removes the tag file associated with a spec file. -## deprecate(what , replacement ) [](#method-c-deprecate) -## describe(description , options nil, &block ) [](#method-c-describe) -## disable_feature(feature ) [](#method-c-disable_feature) -## each_file(&block ) [](#method-c-each_file) -## enable_feature(feature ) [](#method-c-enable_feature) -## exit_code() [](#method-c-exit_code) -Retrieves the stored exit code. -## expectation() [](#method-c-expectation) -Records that an expectation has been encountered in an example. -## expectation?() [](#method-c-expectation?) -Returns true if an expectation has been encountered -**@return** [Boolean] - -## feature_enabled?(feature ) [](#method-c-feature_enabled?) -**@return** [Boolean] - -## files() [](#method-c-files) -## files_array() [](#method-c-files_array) -## format(obj ) [](#method-c-format) -## guard() [](#method-c-guard) -Guards can be nested, so a stack is necessary to know when we have exited the -toplevel guard. -## guarded?() [](#method-c-guarded?) -**@return** [Boolean] - -## make_tag_dir(path ) [](#method-c-make_tag_dir) -## mode?(mode ) [](#method-c-mode?) -Returns `true` if `mode` is registered. -**@return** [Boolean] - -## process() [](#method-c-process) -## protect(location , &block ) [](#method-c-protect) -## randomize?() [](#method-c-randomize?) -**@return** [Boolean] - -## read_tags(keys ) [](#method-c-read_tags) -Returns a list of tags matching any tag string in `keys` based on the return -value of `keys.include?("tag_name")` -## register(symbol , action ) [](#method-c-register) -This method is used for registering actions that are run at particular points -in the spec cycle: - :start before any specs are run - :load before a spec file is loaded - :enter before a describe block is run - :before before a single spec is run - :add while a describe block is adding examples to run later - :expectation before a 'should', 'should_receive', etc. - :passed after an example block is run and passes, passed the block, run before :example action - :example after an example block is run, passed the block - :exception after an exception is rescued - :after after a single spec is run - :leave after a describe block is run - :unload after a spec file is run - :finish after all specs are run - -Objects registered as actions above should respond to a method of the same -name. For example, if an object is registered as a :start action, it should -respond to a #start method call. - -Additionally, there are two "action" lists for filtering specs: - :include return true if the spec should be run - :exclude return true if the spec should NOT be run -## register_current(state ) [](#method-c-register_current) -Sets the toplevel ContextState to `state`. -## register_exit(code ) [](#method-c-register_exit) -Stores the exit code used by the runner scripts. -## register_files(files ) [](#method-c-register_files) -Stores the list of files to be evaluated. -## register_mode(mode ) [](#method-c-register_mode) -Registers an operating mode. Modes recognized by MSpec: - - :pretend - actions execute but specs are not run - :verify - specs are run despite guards and the result is - verified to match the expectation of the guard - :report - specs that are guarded are reported - :unguarded - all guards are forced off -## register_shared(state ) [](#method-c-register_shared) -Stores the shared ContextState keyed by description. -## register_tags_patterns(patterns ) [](#method-c-register_tags_patterns) -Stores one or more substitution patterns for transforming a spec filename into -a tags filename, where each pattern has the form: - - [Regexp, String] - -See also `tags_file`. -## retrieve(symbol ) [](#method-c-retrieve) -## retrieve_shared(desc ) [](#method-c-retrieve_shared) -Returns the shared ContextState matching description. -## setup_env() [](#method-c-setup_env) -## shuffle(ary ) [](#method-c-shuffle) -## store(symbol , value ) [](#method-c-store) -## tags_file() [](#method-c-tags_file) -Transforms a spec filename into a tags filename by applying each substitution -pattern in :tags_pattern. The default patterns are: - - [%r(/spec/), '/spec/tags/'], [/_spec.rb$/, '_tags.txt'] - -which will perform the following transformation: - - path/to/spec/class/method_spec.rb => path/to/spec/tags/class/method_tags.txt - -See also `register_tags_patterns`. -## unguard() [](#method-c-unguard) -## unregister(symbol , action ) [](#method-c-unregister) -## write_tag(tag ) [](#method-c-write_tag) -Writes `tag` to the tag file if it does not already exist. Returns `true` if -the tag is written, `false` otherwise. -## write_tags(tags ) [](#method-c-write_tags) -Writes each tag in `tags` to the tag file. Overwrites the tag file if it -exists. -# Attributes -## exclude[RW] [](#attribute-c-exclude) -Returns the value of attribute exclude. - -## file[RW] [](#attribute-c-file) -Returns the value of attribute file. - -## formatter[RW] [](#attribute-c-formatter) -Returns the value of attribute formatter. - -## include[RW] [](#attribute-c-include) -Returns the value of attribute include. - -## randomize=[R] [](#attribute-c-randomize=) -Sets the attribute randomize - -**@param** [] the value to set the attribute randomize to. - -## repeat[RW] [](#attribute-c-repeat) - -## skips[RW] [](#attribute-c-skips) -Returns the value of attribute skips. - -## subprocesses[RW] [](#attribute-c-subprocesses) -Returns the value of attribute subprocesses. - - diff --git a/example/ruby/MSpecCI.md b/example/ruby/MSpecCI.md deleted file mode 100644 index f797869..0000000 --- a/example/ruby/MSpecCI.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MSpecCI -**Inherits:** MSpecScript - - - - - -#Instance Methods -## options(argvARGV) [](#method-i-options) - -## run() [](#method-i-run) - diff --git a/example/ruby/MSpecEnv.md b/example/ruby/MSpecEnv.md deleted file mode 100644 index 03aa9a4..0000000 --- a/example/ruby/MSpecEnv.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MSpecEnv -**Inherits:** Object - -**Includes:** MSpec, MSpecMatchers - - - - - diff --git a/example/ruby/MSpecExampleError.md b/example/ruby/MSpecExampleError.md deleted file mode 100644 index 89ad9f1..0000000 --- a/example/ruby/MSpecExampleError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: MSpecExampleError -**Inherits:** Exception - - -Just to have an exception name output not be "Exception" - - - diff --git a/example/ruby/MSpecMain.md b/example/ruby/MSpecMain.md deleted file mode 100644 index c539c8c..0000000 --- a/example/ruby/MSpecMain.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: MSpecMain -**Inherits:** MSpecScript - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MSpecMain] a new instance of MSpecMain - -## multi_exec(argv) [](#method-i-multi_exec) - -## options(argvARGV) [](#method-i-options) - -## register() [](#method-i-register) - -## run() [](#method-i-run) - diff --git a/example/ruby/MSpecMatchers.md b/example/ruby/MSpecMatchers.md deleted file mode 100644 index a8bd796..0000000 --- a/example/ruby/MSpecMatchers.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: MSpecMatchers - - -Cannot override #include at the toplevel in MRI - - - diff --git a/example/ruby/MSpecOption.md b/example/ruby/MSpecOption.md deleted file mode 100644 index e16b7b6..0000000 --- a/example/ruby/MSpecOption.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: MSpecOption -**Inherits:** Object - - - - -# Attributes -## arg[RW] [](#attribute-i-arg) -Returns the value of attribute arg. - -## block[RW] [](#attribute-i-block) -Returns the value of attribute block. - -## description[RW] [](#attribute-i-description) -Returns the value of attribute description. - -## long[RW] [](#attribute-i-long) -Returns the value of attribute long. - -## short[RW] [](#attribute-i-short) -Returns the value of attribute short. - - -#Instance Methods -## arg?() [](#method-i-arg?) - -**@return** [Boolean] - -## initialize(short, long, arg, description, block) [](#method-i-initialize) - -**@return** [MSpecOption] a new instance of MSpecOption - -## match?(opt) [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/MSpecOptions.md b/example/ruby/MSpecOptions.md deleted file mode 100644 index 1e6d588..0000000 --- a/example/ruby/MSpecOptions.md +++ /dev/null @@ -1,126 +0,0 @@ -# Class: MSpecOptions -**Inherits:** Object - - -MSpecOptions provides a parser for command line options. It also provides a -composable set of options from which the runner scripts can select for their -particular functionality. - - -# Attributes -## latest[RW] [](#attribute-c-latest) -Returns the value of attribute latest. - -## banner[RW] [](#attribute-i-banner) -Returns the value of attribute banner. - -## config[RW] [](#attribute-i-config) -Returns the value of attribute config. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## width[RW] [](#attribute-i-width) -Returns the value of attribute width. - - -#Instance Methods -## action_filters() [](#method-i-action_filters) - -## actions() [](#method-i-actions) - -## add(short, long, arg, description, block) [](#method-i-add) -Adds documentation text for an option and adds an `MSpecOption` instance to -the list of registered options. - -## all() [](#method-i-all) - -## chdir() [](#method-i-chdir) - -## configure(&block) [](#method-i-configure) -The methods below provide groups of options that are composed by the -particular runners to provide their functionality - -## debug() [](#method-i-debug) - -## doc(str) [](#method-i-doc) -Adds a string of documentation text inline in the text generated from the -options. See #on and #add. - -## env() [](#method-i-env) - -## filters() [](#method-i-filters) - -## formatters() [](#method-i-formatters) - -## help(&block) [](#method-i-help) -Convenience method for providing -h, --help options. - -## initialize(banner"", width30, confignil) [](#method-i-initialize) - -**@return** [MSpecOptions] a new instance of MSpecOptions - -## interrupt() [](#method-i-interrupt) - -## launchable() [](#method-i-launchable) - -## match?(opt) [](#method-i-match?) -Searches all registered options to find a match for `opt`. Returns `nil` if no -registered options match. - -**@return** [Boolean] - -## on(*args, &block) [](#method-i-on) -Registers an option. Acceptable formats for arguments are: - - on "-a", "description" - on "-a", "--abdc", "description" - on "-a", "ARG", "description" - on "--abdc", "ARG", "description" - on "-a", "--abdc", "ARG", "description" - -If an block is passed, it will be invoked when the option is matched. Not -passing a block is permitted, but nonsensical. - -**@raise** [OptionError] - -## on_extra(&block) [](#method-i-on_extra) -Stores a block that will be called with unrecognized options - -## parse(argvARGV) [](#method-i-parse) -Parses an array of command line entries, calling blocks for registered -options. - -## prefix() [](#method-i-prefix) - -## pretend() [](#method-i-pretend) - -## process(argv, entry, opt, arg) [](#method-i-process) -Processes an option. Calls the #on_extra block (or default) for unrecognized -options. For registered options, possibly fetches an argument and invokes the -option's block if it is not nil. - -## randomize() [](#method-i-randomize) - -## repeat() [](#method-i-repeat) - -## split(str, n) [](#method-i-split) -Splits a string at `n` characters into the `opt` and the `rest`. The `arg` is -set to `nil` if `rest` is an empty string. - -## targets() [](#method-i-targets) - -## timeout() [](#method-i-timeout) - -## to_s() [](#method-i-to_s) -Returns a string representation of the options and doc strings. - -## unguarded() [](#method-i-unguarded) - -## verbose() [](#method-i-verbose) - -## verify() [](#method-i-verify) - -## version(version, &block) [](#method-i-version) -Convenience method for providing -v, --version options. - diff --git a/example/ruby/MSpecOptions/OptionError.md b/example/ruby/MSpecOptions/OptionError.md deleted file mode 100644 index 64676bd..0000000 --- a/example/ruby/MSpecOptions/OptionError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: MSpecOptions::OptionError -**Inherits:** Exception - - -Raised if incorrect or incomplete formats are passed to #on. - - - diff --git a/example/ruby/MSpecOptions/ParseError.md b/example/ruby/MSpecOptions/ParseError.md deleted file mode 100644 index b642083..0000000 --- a/example/ruby/MSpecOptions/ParseError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: MSpecOptions::ParseError -**Inherits:** Exception - - -Raised if an unrecognized option is encountered. - - - diff --git a/example/ruby/MSpecRun.md b/example/ruby/MSpecRun.md deleted file mode 100644 index 7d7c876..0000000 --- a/example/ruby/MSpecRun.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: MSpecRun -**Inherits:** MSpecScript - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MSpecRun] a new instance of MSpecRun - -## options(argvARGV) [](#method-i-options) - -## run() [](#method-i-run) - diff --git a/example/ruby/MSpecScript.md b/example/ruby/MSpecScript.md deleted file mode 100644 index 3dbd170..0000000 --- a/example/ruby/MSpecScript.md +++ /dev/null @@ -1,110 +0,0 @@ -# Class: MSpecScript -**Inherits:** Object - - -MSpecScript provides a skeleton for all the MSpec runner scripts. - - -# Class Methods -## child_process?() [](#method-c-child_process?) -True if the current process is the one going to run the specs with -`MSpec.process`. False for e.g. `mspec` which exec's to `mspec-run`. This is -useful in .mspec config files. -**@return** [Boolean] - -## config() [](#method-c-config) -Returns the config object. Maintained at the class level to easily enable -simple config files. See the class method `set`. -## get(key ) [](#method-c-get) -Gets the value of `key` from the config object. Simplifies getting values in a -config file: - - class MSpecScript - set :a, 1 - set :b, 2 - set :c, get(:a) + get(:b) - end -## main(child_process true) [](#method-c-main) -Instantiates an instance and calls the series of methods to invoke the script. -## set(key , value ) [](#method-c-set) -Associates `value` with `key` in the config object. Enables simple config -files of the form: - - class MSpecScript - set :target, "ruby" - set :files, ["one_spec.rb", "two_spec.rb"] - end -# Attributes -## child_process[RW] [](#attribute-c-child_process) -Returns the value of attribute child_process. - - -#Instance Methods -## config() [](#method-i-config) -Returns the config object maintained by the instance's class. See the class -methods `set` and `config`. - -## config_formatter() [](#method-i-config_formatter) -Makes a formatter specified by :formatter option. - -## cores(max) [](#method-i-cores) - -## custom_options(options) [](#method-i-custom_options) -Callback for enabling custom options. This version is a no-op. Provide an -implementation specific version in a config file. Called by #options after the -MSpec-provided options are added. - -## custom_register() [](#method-i-custom_register) -Callback for enabling custom actions, etc. This version is a no-op. Provide an -implementation specific version in a config file. Called by #register. - -## entries(partial) [](#method-i-entries) -Attempts to resolve `partial` as a file or directory name in the following -order: - - 1. +partial+ - 2. +partial+ + "_spec.rb" - 3. File.join(config[:prefix], partial) - 4. File.join(config[:prefix], partial + "_spec.rb") - -If it is a file name, returns the name as an entry in an array. If it is a -directory, returns all *_spec.rb files in the directory and subdirectories. - -If unable to resolve `partial`, `Kernel.abort` is called. - -## files(patterns) [](#method-i-files) -Resolves each entry in `patterns` to a set of files. - -If the pattern has a leading '^' character, the list of files is subtracted -from the list of files accumulated to that point. - -If the entry has a leading ':' character, the corresponding key is looked up -in the config object and the entries in the value retrieved are processed -through #entries. - -## files_from_patterns(patterns) [](#method-i-files_from_patterns) - -## initialize() [](#method-i-initialize) - -**@return** [MSpecScript] a new instance of MSpecScript - -## load(target) [](#method-i-load) - -## load_default() [](#method-i-load_default) -Attempts to load a default config file. First tries to load 'default.mspec'. -If that fails, attempts to load a config file name constructed from the value -of RUBY_ENGINE and the first two numbers in RUBY_VERSION. For example, on MRI -1.8.6, the file name would be 'ruby.1.8.mspec'. - -## register() [](#method-i-register) -Registers all filters and actions. - -## setup_env() [](#method-i-setup_env) - -## signals() [](#method-i-signals) -Sets up signal handlers. Only a handler for SIGINT is registered currently. - -## try_load(target) [](#method-i-try_load) -Returns `true` if the file was located in `config[:path]`, possibly appending -+[config](:config_ext). Returns `false` otherwise. - diff --git a/example/ruby/MSpecTag.md b/example/ruby/MSpecTag.md deleted file mode 100644 index 1802063..0000000 --- a/example/ruby/MSpecTag.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: MSpecTag -**Inherits:** MSpecScript - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MSpecTag] a new instance of MSpecTag - -## options(argvARGV) [](#method-i-options) - -## register() [](#method-i-register) - -## run() [](#method-i-run) - diff --git a/example/ruby/MainSpecs.md b/example/ruby/MainSpecs.md deleted file mode 100644 index 8382f98..0000000 --- a/example/ruby/MainSpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: MainSpecs - - - - -# Class Methods -## call_foo(x ) [](#method-c-call_foo) - diff --git a/example/ruby/MainSpecs/Module.md b/example/ruby/MainSpecs/Module.md deleted file mode 100644 index bc78a17..0000000 --- a/example/ruby/MainSpecs/Module.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MainSpecs::Module - - - - - diff --git a/example/ruby/MainSpecs/WrapIncludeModule.md b/example/ruby/MainSpecs/WrapIncludeModule.md deleted file mode 100644 index f733b38..0000000 --- a/example/ruby/MainSpecs/WrapIncludeModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MainSpecs::WrapIncludeModule - - - - - diff --git a/example/ruby/MakeMakefile.md b/example/ruby/MakeMakefile.md deleted file mode 100644 index 2a5b8a2..0000000 --- a/example/ruby/MakeMakefile.md +++ /dev/null @@ -1,1296 +0,0 @@ -# Module: MakeMakefile - -**Extended by:** MakeMakefile - - -mkmf.rb is used by Ruby C extensions to generate a Makefile which will -correctly compile and link the C extension to Ruby and a third-party library. - - -# Class Methods -## append_cflags(flags , **opts ) [](#method-c-append_cflags) -Check whether each given C compiler flag is acceptable and append it to -`$CFLAGS` if so. - -`flags` -: a C compiler flag as a `String` or an `Array` of them - -## append_cppflags(flags , **opts ) [](#method-c-append_cppflags) -Check whether each given C preprocessor flag is acceptable and append it to -`$CPPFLAGS` if so. - -`flags` -: a C preprocessor flag as a `String` or an `Array` of them - -## append_ldflags(flags , **opts ) [](#method-c-append_ldflags) -Check whether each given linker flag is acceptable and append it to `$LDFLAGS` -if so. - -`flags` -: a linker flag as a `String` or an `Array` of them - -## append_library(libs , lib ) [](#method-c-append_library) -:no-doc: -## arg_config(config , default nil, &block ) [](#method-c-arg_config) -:stopdoc: -## cc_command(opt "") [](#method-c-cc_command) -## cc_config(opt "") [](#method-c-cc_config) -## check_signedness(type , headers nil, opts nil, &b ) [](#method-c-check_signedness) -Returns the signedness of the given `type`. You may optionally specify -additional `headers` to search in for the `type`. - -If the `type` is found and is a numeric type, a macro is passed as a -preprocessor constant to the compiler using the `type` name, in uppercase, -prepended with `SIGNEDNESS_OF_`, followed by the `type` name, followed by `=X` -where "X" is positive integer if the `type` is unsigned and a negative integer -if the `type` is signed. - -For example, if `size_t` is defined as unsigned, then -`check_signedness('size_t')` would return +1 and the `SIGNEDNESS_OF_SIZE_T=+1` -preprocessor macro would be passed to the compiler. The -`SIGNEDNESS_OF_INT=-1` macro would be set for `check_signedness('int')` -## check_sizeof(type , headers nil, opts "", &b ) [](#method-c-check_sizeof) -Returns the size of the given `type`. You may optionally specify additional -`headers` to search in for the `type`. - -If found, a macro is passed as a preprocessor constant to the compiler using -the type name, in uppercase, prepended with `SIZEOF_`, followed by the type -name, followed by `=X` where "X" is the actual size. - -For example, if `check_sizeof('mystruct')` returned 12, then the -`SIZEOF_MYSTRUCT=12` preprocessor macro would be passed to the compiler. -## checking_for(m , fmt nil) [](#method-c-checking_for) -This emits a string to stdout that allows users to see the results of the -various have* and find* methods as they are tested. - -Internal use only. -## checking_message(target , place nil, opt nil) [](#method-c-checking_message) -Build a message for checking. - -Internal use only. -## config_string(key , config CONFIG) [](#method-c-config_string) -:stopdoc: -## configuration(srcdir ) [](#method-c-configuration) -## conftest_source() [](#method-c-conftest_source) -Returns the language-dependent source file name for configuration checks. -## convertible_int(type , headers nil, opts nil, &b ) [](#method-c-convertible_int) -Returns the convertible integer type of the given `type`. You may optionally -specify additional `headers` to search in for the `type`. *convertible* means -actually the same type, or typedef'd from the same type. - -If the `type` is an integer type and the *convertible* type is found, the -following macros are passed as preprocessor constants to the compiler using -the `type` name, in uppercase. - -* `TYPEOF_`, followed by the `type` name, followed by `=X` where "X" is the - found *convertible* type name. -* `TYP2NUM` and `NUM2TYP`, where `TYP` is the `type` name in uppercase with - replacing an `_t` suffix with "T", followed by `=X` where "X" is the macro - name to convert `type` to an Integer object, and vice versa. - -For example, if `foobar_t` is defined as unsigned long, then -`convertible_int("foobar_t")` would return "unsigned long", and define these -macros: - - #define TYPEOF_FOOBAR_T unsigned long - #define FOOBART2NUM ULONG2NUM - #define NUM2FOOBART NUM2ULONG -## cpp_command(outfile , opt "") [](#method-c-cpp_command) -## cpp_include(header ) [](#method-c-cpp_include) -## create_header(header "extconf.h") [](#method-c-create_header) -Generates a header file consisting of the various macro definitions generated -by other methods such as have_func and have_header. These are then wrapped in -a custom `#ifndef` based on the `header` file name, which defaults to -"extconf.h". - -For example: - - # extconf.rb - require 'mkmf' - have_func('realpath') - have_header('sys/utime.h') - create_header - create_makefile('foo') - -The above script would generate the following extconf.h file: - - #ifndef EXTCONF_H - #define EXTCONF_H - #define HAVE_REALPATH 1 - #define HAVE_SYS_UTIME_H 1 - #endif - -Given that the create_header method generates a file based on definitions set -earlier in your extconf.rb file, you will probably want to make this one of -the last methods you call in your script. -## create_makefile(target , srcprefix nil) [](#method-c-create_makefile) -Generates the Makefile for your extension, passing along any options and -preprocessor constants that you may have generated through other methods. - -The `target` name should correspond the name of the global function name -defined within your C extension, minus the `Init_`. For example, if your C -extension is defined as `Init_foo`, then your target would simply be "foo". - -If any "/" characters are present in the target name, only the last name is -interpreted as the target name, and the rest are considered toplevel directory -names, and the generated Makefile will be altered accordingly to follow that -directory structure. - -For example, if you pass "test/foo" as a target name, your extension will be -installed under the "test" directory. This means that in order to load the -file within a Ruby program later, that directory structure will have to be -followed, e.g. `require 'test/foo'`. - -The `srcprefix` should be used when your source files are not in the same -directory as your build script. This will not only eliminate the need for you -to manually copy the source files into the same directory as your build -script, but it also sets the proper `target_prefix` in the generated Makefile. - -Setting the `target_prefix` will, in turn, install the generated binary in a -directory under your `RbConfig::CONFIG['sitearchdir']` that mimics your local -filesystem when you run `make install`. - -For example, given the following file tree: - - ext/ - extconf.rb - test/ - foo.c - -And given the following code: - - create_makefile('test/foo', 'test') - -That will set the `target_prefix` in the generated Makefile to "test". That, -in turn, will create the following file tree when installed via the `make -install` command: - - /path/to/ruby/sitearchdir/test/foo.so - -It is recommended that you use this approach to generate your makefiles, -instead of copying files around manually, because some third party libraries -may depend on the `target_prefix` being set properly. - -The `srcprefix` argument can be used to override the default source directory, -i.e. the current directory. It is included as part of the `VPATH` and added -to the list of `INCFLAGS`. -## create_tmpsrc(src ) [](#method-c-create_tmpsrc) -Creats temporary source file from `COMMON_HEADERS` and *src*. Yields the -created source string and uses the returned string as the source code, if the -block is given. -## depend_rules(depend ) [](#method-c-depend_rules) -Processes the data contents of the "depend" file. Each line of this file is -expected to be a file name. - -Returns the output of findings, in Makefile format. -## dir_config(target , idefault nil, ldefault nil) [](#method-c-dir_config) -call-seq: - dir_config(target) - dir_config(target, prefix) - dir_config(target, idefault, ldefault) - -Sets a `target` name that the user can then use to configure various "with" -options with on the command line by using that name. For example, if the -target is set to "foo", then the user could use the `--with-foo-dir=prefix`, -`--with-foo-include=dir` and `--with-foo-lib=dir` command line options to tell -where to search for header/library files. - -You may pass along additional parameters to specify default values. If one is -given it is taken as default `prefix`, and if two are given they are taken as -"include" and "lib" defaults in that order. - -In any case, the return value will be an array of determined "include" and -"lib" directories, either of which can be nil if no corresponding command line -option is given when no default value is specified. - -Note that dir_config only adds to the list of places to search for libraries -and include files. It does not link the libraries into your application. -## dir_re(dir ) [](#method-c-dir_re) -## dummy_makefile(srcdir ) [](#method-c-dummy_makefile) -Creates a stub Makefile. -## each_compile_rules() [](#method-c-each_compile_rules) -:nodoc: -## egrep_cpp(pat , src , opt "", &b ) [](#method-c-egrep_cpp) -Returns whether or not the `src` can be preprocessed with the C preprocessor -and matches with `pat`. - -If a block given, it is called with the source before compilation. You can -modify the source in the block. - -`pat` -: a Regexp or a String - -`src` -: a String which contains a C source - -`opt` -: a String which contains preprocessor options - - -NOTE: When pat is a Regexp the matching will be checked in process, otherwise -egrep(1) will be invoked to check it. -## enable_config(config , default nil) [](#method-c-enable_config) -Tests for the presence of an `--enable-`*config* or `--disable-`*config* -option. Returns `true` if the enable option is given, `false` if the disable -option is given, and the default value otherwise. - -This can be useful for adding custom definitions, such as debug information. - -Example: - - if enable_config("debug") - $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG" - end -## env_quote(envs ) [](#method-c-env_quote) -## expand_command(commands , envs libpath_env) [](#method-c-expand_command) -## find_executable(bin , path nil) [](#method-c-find_executable) -Searches for the executable `bin` on `path`. The default path is your `PATH` -environment variable. If that isn't defined, it will resort to searching -/usr/local/bin, /usr/ucb, /usr/bin and /bin. - -If found, it will return the full path, including the executable name, of -where it was found. - -Note that this method does not actually affect the generated Makefile. -## find_executable0(bin , path nil) [](#method-c-find_executable0) -:nodoc: - -This method is used internally by the find_executable method. - -Internal use only. -## find_header(header , *paths ) [](#method-c-find_header) -Instructs mkmf to search for the given `header` in any of the `paths` -provided, and returns whether or not it was found in those paths. - -If the header is found then the path it was found on is added to the list of -included directories that are sent to the compiler (via the `-I` switch). -## find_library(lib , func , *paths , &b ) [](#method-c-find_library) -Returns whether or not the entry point `func` can be found within the library -`lib` in one of the `paths` specified, where `paths` is an array of strings. -If `func` is `nil` , then the `main()` function is used as the entry point. - -If `lib` is found, then the path it was found on is added to the list of -library paths searched and linked against. -## find_type(type , opt , *headers , &b ) [](#method-c-find_type) -Returns where the static type `type` is defined. - -You may also pass additional flags to `opt` which are then passed along to the -compiler. - -See also `have_type`. -## have_const(const , headers nil, opt "", &b ) [](#method-c-have_const) -Returns whether or not the constant `const` is defined. You may optionally -pass the `type` of `const` as `[const, type]`, such as: - - have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h") - -You may also pass additional `headers` to check against in addition to the -common header files, and additional flags to `opt` which are then passed along -to the compiler. - -If found, a macro is passed as a preprocessor constant to the compiler using -the type name, in uppercase, prepended with `HAVE_CONST_`. - -For example, if `have_const('foo')` returned true, then the `HAVE_CONST_FOO` -preprocessor macro would be passed to the compiler. -## have_devel?() [](#method-c-have_devel?) -:stopdoc: -**@return** [Boolean] - -## have_framework(fw , &b ) [](#method-c-have_framework) -Returns whether or not the given `framework` can be found on your system. If -found, a macro is passed as a preprocessor constant to the compiler using the -framework name, in uppercase, prepended with `HAVE_FRAMEWORK_`. - -For example, if `have_framework('Ruby')` returned true, then the -`HAVE_FRAMEWORK_RUBY` preprocessor macro would be passed to the compiler. - -If `fw` is a pair of the framework name and its header file name that header -file is checked, instead of the normally used header file which is named same -as the framework. -## have_func(func , headers nil, opt "", &b ) [](#method-c-have_func) -Returns whether or not the function `func` can be found in the common header -files, or within any `headers` that you provide. If found, a macro is passed -as a preprocessor constant to the compiler using the function name, in -uppercase, prepended with `HAVE_`. - -To check functions in an additional library, you need to check that library -first using `have_library()`. The `func` shall be either mere function name -or function name with arguments. - -For example, if `have_func('foo')` returned `true`, then the `HAVE_FOO` -preprocessor macro would be passed to the compiler. -## have_header(header , preheaders nil, opt "", &b ) [](#method-c-have_header) -Returns whether or not the given `header` file can be found on your system. If -found, a macro is passed as a preprocessor constant to the compiler using the -header file name, in uppercase, prepended with `HAVE_`. - -For example, if `have_header('foo.h')` returned true, then the `HAVE_FOO_H` -preprocessor macro would be passed to the compiler. -## have_library(lib , func nil, headers nil, opt "", &b ) [](#method-c-have_library) -Returns whether or not the given entry point `func` can be found within `lib`. - If `func` is `nil`, the `main()` entry point is used by default. If found, -it adds the library to list of libraries to be used when linking your -extension. - -If `headers` are provided, it will include those header files as the header -files it looks in when searching for `func`. - -The real name of the library to be linked can be altered by `--with-FOOlib` -configuration option. -## have_macro(macro , headers nil, opt "", &b ) [](#method-c-have_macro) -Returns whether or not `macro` is defined either in the common header files or -within any `headers` you provide. - -Any options you pass to `opt` are passed along to the compiler. -## have_struct_member(type , member , headers nil, opt "", &b ) [](#method-c-have_struct_member) -Returns whether or not the struct of type `type` contains `member`. If it -does not, or the struct type can't be found, then false is returned. You may -optionally specify additional `headers` in which to look for the struct (in -addition to the common header files). - -If found, a macro is passed as a preprocessor constant to the compiler using -the type name and the member name, in uppercase, prepended with `HAVE_`. - -For example, if `have_struct_member('struct foo', 'bar')` returned true, then -the `HAVE_STRUCT_FOO_BAR` preprocessor macro would be passed to the compiler. - -`HAVE_ST_BAR` is also defined for backward compatibility. -## have_type(type , headers nil, opt "", &b ) [](#method-c-have_type) -Returns whether or not the static type `type` is defined. You may optionally -pass additional `headers` to check against in addition to the common header -files. - -You may also pass additional flags to `opt` which are then passed along to the -compiler. - -If found, a macro is passed as a preprocessor constant to the compiler using -the type name, in uppercase, prepended with `HAVE_TYPE_`. - -For example, if `have_type('foo')` returned true, then the `HAVE_TYPE_FOO` -preprocessor macro would be passed to the compiler. -## have_typeof?() [](#method-c-have_typeof?) -Used internally by the what_type? method to check if the *typeof* GCC -extension is available. -**@return** [Boolean] - -## have_var(var , headers nil, opt "", &b ) [](#method-c-have_var) -Returns whether or not the variable `var` can be found in the common header -files, or within any `headers` that you provide. If found, a macro is passed -as a preprocessor constant to the compiler using the variable name, in -uppercase, prepended with `HAVE_`. - -To check variables in an additional library, you need to check that library -first using `have_library()`. - -For example, if `have_var('foo')` returned true, then the `HAVE_FOO` -preprocessor macro would be passed to the compiler. -## init_mkmf(config CONFIG, rbconfig RbConfig::CONFIG) [](#method-c-init_mkmf) -:stopdoc: -## install_dirs(target_prefix nil) [](#method-c-install_dirs) -## install_files(mfile , ifiles , map nil, srcprefix nil) [](#method-c-install_files) -## install_rb(mfile , dest , srcdir nil) [](#method-c-install_rb) -## libpath_env() [](#method-c-libpath_env) -## libpathflag(libpath $DEFLIBPATH|$LIBPATH) [](#method-c-libpathflag) -## link_command(ldflags , *opts ) [](#method-c-link_command) -## link_config(ldflags , opt "", libpath $DEFLIBPATH|$LIBPATH) [](#method-c-link_config) -## log_src(src , heading "checked program was") [](#method-c-log_src) -Logs *src* -## macro_defined?(macro , src , opt "", &b ) [](#method-c-macro_defined?) -This is used internally by the have_macro? method. -**@return** [Boolean] - -## map_dir(dir , map nil) [](#method-c-map_dir) -## merge_libs(*libs ) [](#method-c-merge_libs) -## message(*s ) [](#method-c-message) -Prints messages to $stdout, if verbose mode. - -Internal use only. -## mkintpath(path ) [](#method-c-mkintpath) -## mkmf_failed(path ) [](#method-c-mkmf_failed) -Returns whether or not the Makefile was successfully generated. If not, the -script will abort with an error message. - -Internal use only. -## modified?(target , times ) [](#method-c-modified?) -Returns time stamp of the `target` file if it exists and is newer than or -equal to all of `times`. -**@return** [Boolean] - -## pkg_config(pkg , *options ) [](#method-c-pkg_config) -Returns compile/link information about an installed library in a tuple of -`[cflags, ldflags, libs]`, by using the command found first in the following -commands: - -1. If `--with-{pkg}-config={command}` is given via command line option: - `{command} {options}` - -2. `{pkg}-config {options}` - -3. `pkg-config {options} {pkg}` - -Where `options` is the option name without dashes, for instance `"cflags"` for -the `--cflags` flag. - -The values obtained are appended to `$INCFLAGS`, `$CFLAGS`, `$LDFLAGS` and -`$libs`. - -If one or more `options` argument is given, the config command is invoked with -the options and a stripped output string is returned without modifying any of -the global values mentioned above. -## relative_from(path , base ) [](#method-c-relative_from) -## rm_f(*files ) [](#method-c-rm_f) -Removes *files*. -## rm_rf(*files ) [](#method-c-rm_rf) -Removes *files* recursively. -## scalar_ptr_type?(type , member nil, headers nil, &b ) [](#method-c-scalar_ptr_type?) -Used internally by the what_type? method to determine if `type` is a scalar -pointer. -**@return** [Boolean] - -## scalar_type?(type , member nil, headers nil, &b ) [](#method-c-scalar_type?) -Used internally by the what_type? method to determine if `type` is a scalar -pointer. -**@return** [Boolean] - -## split_libs(*strs ) [](#method-c-split_libs) -:stopdoc: -## timestamp_file(name , target_prefix nil) [](#method-c-timestamp_file) -## try_cflags(flags , werror: true, **opts ) [](#method-c-try_cflags) -:nodoc: -## try_compile(src , opt "", werror: nil, **opts , &b ) [](#method-c-try_compile) -Returns whether or not the `src` can be compiled as a C source. `opt` is -passed to the C compiler as options. Note that `$CFLAGS` is also passed to the -compiler. - -If a block given, it is called with the source before compilation. You can -modify the source in the block. - -`src` -: a String which contains a C source - -`opt` -: a String which contains compiler options - -## try_const(const , headers nil, opt "", &b ) [](#method-c-try_const) -:nodoc: Returns whether or not the constant `const` is defined. - -See also `have_const` -## try_constant(const , headers nil, opt "", &b ) [](#method-c-try_constant) -## try_cpp(src , opt "", **opts , &b ) [](#method-c-try_cpp) -Returns whether or not the `src` can be preprocessed with the C preprocessor. -`opt` is passed to the preprocessor as options. Note that `$CFLAGS` is also -passed to the preprocessor. - -If a block given, it is called with the source before preprocessing. You can -modify the source in the block. - -`src` -: a String which contains a C source - -`opt` -: a String which contains preprocessor options - -## try_cppflags(flags , werror: true, **opts ) [](#method-c-try_cppflags) -:nodoc: -## try_do(src , command , **opts , &b ) [](#method-c-try_do) -## try_func(func , libs , headers nil, opt "", &b ) [](#method-c-try_func) -You should use `have_func` rather than `try_func`. - -`func` -: a String which contains a symbol name - -`libs` -: a String which contains library names. - -`headers` -: a String or an Array of strings which contains names of header files. - -## try_ldflags(flags , werror: $mswin, **opts ) [](#method-c-try_ldflags) -:nodoc: -## try_link(src , opt "", **opts , &b ) [](#method-c-try_link) -Returns whether or not the `src` can be compiled as a C source and linked with -its depending libraries successfully. `opt` is passed to the linker as -options. Note that `$CFLAGS` and `$LDFLAGS` are also passed to the linker. - -If a block given, it is called with the source before compilation. You can -modify the source in the block. - -`src` -: a String which contains a C source - -`opt` -: a String which contains linker options - -## try_link0(src , opt "", ldflags: "", **opts , &b ) [](#method-c-try_link0) -:nodoc: -## try_run(src , opt "", &b ) [](#method-c-try_run) -Returns whether or not: -* the `src` can be compiled as a C source, -* the result object can be linked with its depending libraries successfully, -* the linked file can be invoked as an executable -* and the executable exits successfully - -`opt` is passed to the linker as options. Note that `$CFLAGS` and `$LDFLAGS` -are also passed to the linker. - -If a block given, it is called with the source before compilation. You can -modify the source in the block. - -`src` -: a String which contains a C source - -`opt` -: a String which contains linker options - - -Returns true when the executable exits successfully, false when it fails, or -nil when preprocessing, compilation or link fails. -## try_signedness(type , member , headers nil, opts nil) [](#method-c-try_signedness) -**@raise** [ArgumentError] - -## try_static_assert(expr , headers nil, opt "", &b ) [](#method-c-try_static_assert) -:stopdoc: -## try_type(type , headers nil, opt "", &b ) [](#method-c-try_type) -:nodoc: Returns whether or not the static type `type` is defined. - -See also `have_type` -## try_var(var , headers nil, opt "", &b ) [](#method-c-try_var) -You should use `have_var` rather than `try_var`. -## typedef_expr(type , headers ) [](#method-c-typedef_expr) -## werror_flag(opt nil) [](#method-c-werror_flag) -## what_type?(type , member nil, headers nil, &b ) [](#method-c-what_type?) -Returns a string represents the type of *type*, or *member* of *type* if -*member* is not `nil`. -**@return** [Boolean] - -## winsep(s ) [](#method-c-winsep) -Converts forward slashes to backslashes. Aimed at MS Windows. - -Internal use only. -## with_cflags(flags ) [](#method-c-with_cflags) -Sets `$CFLAGS` to *flags* and yields. If the block returns a falsy value, -`$CFLAGS` is reset to its previous value, remains set to *flags* otherwise. -## with_config(config , default nil) [](#method-c-with_config) -Tests for the presence of a `--with-`*config* or `--without-`*config* option. -Returns `true` if the with option is given, `false` if the without option is -given, and the default value otherwise. - -This can be useful for adding custom definitions, such as debug information. - -Example: - - if with_config("debug") - $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG" - end -## with_cppflags(flags ) [](#method-c-with_cppflags) -Sets `$CPPFLAGS` to *flags* and yields. If the block returns a falsy value, -`$CPPFLAGS` is reset to its previous value, remains set to *flags* otherwise. - -`flags` -: a C preprocessor flag as a `String` - -## with_destdir(dir ) [](#method-c-with_destdir) -:stopdoc: -## with_ldflags(flags ) [](#method-c-with_ldflags) -Sets `$LDFLAGS` to *flags* and yields. If the block returns a falsy value, -`$LDFLAGS` is reset to its previous value, remains set to *flags* otherwise. -## with_werror(opt , opts nil) [](#method-c-with_werror) -**@yield** [opt, opts] - -## xpopen(command , *mode , &block ) [](#method-c-xpopen) -Executes *command* similarly to xsystem, but yields opened pipe. -## xsystem(command , werror: false) [](#method-c-xsystem) -call-seq: - xsystem(command, werror: false) -> true or false - -Executes *command* with expanding variables, and returns the exit status like -as Kernel#system. If *werror* is true and the error output is not empty, -returns `false`. The output will logged. - -#Instance Methods -## append_cflags(flags, **opts) [](#method-i-append_cflags) -Check whether each given C compiler flag is acceptable and append it to -`$CFLAGS` if so. - -`flags` -: a C compiler flag as a `String` or an `Array` of them - - -## append_cppflags(flags, **opts) [](#method-i-append_cppflags) -Check whether each given C preprocessor flag is acceptable and append it to -`$CPPFLAGS` if so. - -`flags` -: a C preprocessor flag as a `String` or an `Array` of them - - -## append_ldflags(flags, **opts) [](#method-i-append_ldflags) -Check whether each given linker flag is acceptable and append it to `$LDFLAGS` -if so. - -`flags` -: a linker flag as a `String` or an `Array` of them - - -## append_library(libs, lib) [](#method-i-append_library) -:no-doc: - -## arg_config(config, defaultnil, &block) [](#method-i-arg_config) -:stopdoc: - -## cc_command(opt"") [](#method-i-cc_command) - -## cc_config(opt"") [](#method-i-cc_config) - -## check_signedness(type, headersnil, optsnil, &b) [](#method-i-check_signedness) -Returns the signedness of the given `type`. You may optionally specify -additional `headers` to search in for the `type`. - -If the `type` is found and is a numeric type, a macro is passed as a -preprocessor constant to the compiler using the `type` name, in uppercase, -prepended with `SIGNEDNESS_OF_`, followed by the `type` name, followed by `=X` -where "X" is positive integer if the `type` is unsigned and a negative integer -if the `type` is signed. - -For example, if `size_t` is defined as unsigned, then -`check_signedness('size_t')` would return +1 and the `SIGNEDNESS_OF_SIZE_T=+1` -preprocessor macro would be passed to the compiler. The -`SIGNEDNESS_OF_INT=-1` macro would be set for `check_signedness('int')` - -## check_sizeof(type, headersnil, opts"", &b) [](#method-i-check_sizeof) -Returns the size of the given `type`. You may optionally specify additional -`headers` to search in for the `type`. - -If found, a macro is passed as a preprocessor constant to the compiler using -the type name, in uppercase, prepended with `SIZEOF_`, followed by the type -name, followed by `=X` where "X" is the actual size. - -For example, if `check_sizeof('mystruct')` returned 12, then the -`SIZEOF_MYSTRUCT=12` preprocessor macro would be passed to the compiler. - -## checking_for(m, fmtnil) [](#method-i-checking_for) -This emits a string to stdout that allows users to see the results of the -various have* and find* methods as they are tested. - -Internal use only. - -## checking_message(target, placenil, optnil) [](#method-i-checking_message) -Build a message for checking. - -Internal use only. - -## configuration(srcdir) [](#method-i-configuration) - -## conftest_source() [](#method-i-conftest_source) -Returns the language-dependent source file name for configuration checks. - -## convertible_int(type, headersnil, optsnil, &b) [](#method-i-convertible_int) -Returns the convertible integer type of the given `type`. You may optionally -specify additional `headers` to search in for the `type`. *convertible* means -actually the same type, or typedef'd from the same type. - -If the `type` is an integer type and the *convertible* type is found, the -following macros are passed as preprocessor constants to the compiler using -the `type` name, in uppercase. - -* `TYPEOF_`, followed by the `type` name, followed by `=X` where "X" is the - found *convertible* type name. -* `TYP2NUM` and `NUM2TYP`, where `TYP` is the `type` name in uppercase with - replacing an `_t` suffix with "T", followed by `=X` where "X" is the macro - name to convert `type` to an Integer object, and vice versa. - -For example, if `foobar_t` is defined as unsigned long, then -`convertible_int("foobar_t")` would return "unsigned long", and define these -macros: - - #define TYPEOF_FOOBAR_T unsigned long - #define FOOBART2NUM ULONG2NUM - #define NUM2FOOBART NUM2ULONG - -## cpp_command(outfile, opt"") [](#method-i-cpp_command) - -## cpp_include(header) [](#method-i-cpp_include) - -## create_header(header"extconf.h") [](#method-i-create_header) -Generates a header file consisting of the various macro definitions generated -by other methods such as have_func and have_header. These are then wrapped in -a custom `#ifndef` based on the `header` file name, which defaults to -"extconf.h". - -For example: - - # extconf.rb - require 'mkmf' - have_func('realpath') - have_header('sys/utime.h') - create_header - create_makefile('foo') - -The above script would generate the following extconf.h file: - - #ifndef EXTCONF_H - #define EXTCONF_H - #define HAVE_REALPATH 1 - #define HAVE_SYS_UTIME_H 1 - #endif - -Given that the create_header method generates a file based on definitions set -earlier in your extconf.rb file, you will probably want to make this one of -the last methods you call in your script. - -## create_makefile(target, srcprefixnil) [](#method-i-create_makefile) -Generates the Makefile for your extension, passing along any options and -preprocessor constants that you may have generated through other methods. - -The `target` name should correspond the name of the global function name -defined within your C extension, minus the `Init_`. For example, if your C -extension is defined as `Init_foo`, then your target would simply be "foo". - -If any "/" characters are present in the target name, only the last name is -interpreted as the target name, and the rest are considered toplevel directory -names, and the generated Makefile will be altered accordingly to follow that -directory structure. - -For example, if you pass "test/foo" as a target name, your extension will be -installed under the "test" directory. This means that in order to load the -file within a Ruby program later, that directory structure will have to be -followed, e.g. `require 'test/foo'`. - -The `srcprefix` should be used when your source files are not in the same -directory as your build script. This will not only eliminate the need for you -to manually copy the source files into the same directory as your build -script, but it also sets the proper `target_prefix` in the generated Makefile. - -Setting the `target_prefix` will, in turn, install the generated binary in a -directory under your `RbConfig::CONFIG['sitearchdir']` that mimics your local -filesystem when you run `make install`. - -For example, given the following file tree: - - ext/ - extconf.rb - test/ - foo.c - -And given the following code: - - create_makefile('test/foo', 'test') - -That will set the `target_prefix` in the generated Makefile to "test". That, -in turn, will create the following file tree when installed via the `make -install` command: - - /path/to/ruby/sitearchdir/test/foo.so - -It is recommended that you use this approach to generate your makefiles, -instead of copying files around manually, because some third party libraries -may depend on the `target_prefix` being set properly. - -The `srcprefix` argument can be used to override the default source directory, -i.e. the current directory. It is included as part of the `VPATH` and added -to the list of `INCFLAGS`. - -## create_tmpsrc(src) [](#method-i-create_tmpsrc) -Creats temporary source file from `COMMON_HEADERS` and *src*. Yields the -created source string and uses the returned string as the source code, if the -block is given. - -## depend_rules(depend) [](#method-i-depend_rules) -Processes the data contents of the "depend" file. Each line of this file is -expected to be a file name. - -Returns the output of findings, in Makefile format. - -## dir_config(target, idefaultnil, ldefaultnil) [](#method-i-dir_config) -call-seq: - dir_config(target) - dir_config(target, prefix) - dir_config(target, idefault, ldefault) - -Sets a `target` name that the user can then use to configure various "with" -options with on the command line by using that name. For example, if the -target is set to "foo", then the user could use the `--with-foo-dir=prefix`, -`--with-foo-include=dir` and `--with-foo-lib=dir` command line options to tell -where to search for header/library files. - -You may pass along additional parameters to specify default values. If one is -given it is taken as default `prefix`, and if two are given they are taken as -"include" and "lib" defaults in that order. - -In any case, the return value will be an array of determined "include" and -"lib" directories, either of which can be nil if no corresponding command line -option is given when no default value is specified. - -Note that dir_config only adds to the list of places to search for libraries -and include files. It does not link the libraries into your application. - -## dummy_makefile(srcdir) [](#method-i-dummy_makefile) -Creates a stub Makefile. - -## each_compile_rules() [](#method-i-each_compile_rules) -:nodoc: - -## egrep_cpp(pat, src, opt"", &b) [](#method-i-egrep_cpp) -Returns whether or not the `src` can be preprocessed with the C preprocessor -and matches with `pat`. - -If a block given, it is called with the source before compilation. You can -modify the source in the block. - -`pat` -: a Regexp or a String - -`src` -: a String which contains a C source - -`opt` -: a String which contains preprocessor options - - -NOTE: When pat is a Regexp the matching will be checked in process, otherwise -egrep(1) will be invoked to check it. - -## enable_config(config, defaultnil) [](#method-i-enable_config) -Tests for the presence of an `--enable-`*config* or `--disable-`*config* -option. Returns `true` if the enable option is given, `false` if the disable -option is given, and the default value otherwise. - -This can be useful for adding custom definitions, such as debug information. - -Example: - - if enable_config("debug") - $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG" - end - -## env_quote(envs) [](#method-i-env_quote) - -## expand_command(commands, envslibpath_env) [](#method-i-expand_command) - -## find_executable(bin, pathnil) [](#method-i-find_executable) -Searches for the executable `bin` on `path`. The default path is your `PATH` -environment variable. If that isn't defined, it will resort to searching -/usr/local/bin, /usr/ucb, /usr/bin and /bin. - -If found, it will return the full path, including the executable name, of -where it was found. - -Note that this method does not actually affect the generated Makefile. - -## find_executable0(bin, pathnil) [](#method-i-find_executable0) -:nodoc: - -This method is used internally by the find_executable method. - -Internal use only. - -## find_header(header, *paths) [](#method-i-find_header) -Instructs mkmf to search for the given `header` in any of the `paths` -provided, and returns whether or not it was found in those paths. - -If the header is found then the path it was found on is added to the list of -included directories that are sent to the compiler (via the `-I` switch). - -## find_library(lib, func, *paths, &b) [](#method-i-find_library) -Returns whether or not the entry point `func` can be found within the library -`lib` in one of the `paths` specified, where `paths` is an array of strings. -If `func` is `nil` , then the `main()` function is used as the entry point. - -If `lib` is found, then the path it was found on is added to the list of -library paths searched and linked against. - -## find_type(type, opt, *headers, &b) [](#method-i-find_type) -Returns where the static type `type` is defined. - -You may also pass additional flags to `opt` which are then passed along to the -compiler. - -See also `have_type`. - -## have_const(const, headersnil, opt"", &b) [](#method-i-have_const) -Returns whether or not the constant `const` is defined. You may optionally -pass the `type` of `const` as `[const, type]`, such as: - - have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h") - -You may also pass additional `headers` to check against in addition to the -common header files, and additional flags to `opt` which are then passed along -to the compiler. - -If found, a macro is passed as a preprocessor constant to the compiler using -the type name, in uppercase, prepended with `HAVE_CONST_`. - -For example, if `have_const('foo')` returned true, then the `HAVE_CONST_FOO` -preprocessor macro would be passed to the compiler. - -## have_devel?() [](#method-i-have_devel?) -:stopdoc: - -**@return** [Boolean] - -## have_framework(fw, &b) [](#method-i-have_framework) -Returns whether or not the given `framework` can be found on your system. If -found, a macro is passed as a preprocessor constant to the compiler using the -framework name, in uppercase, prepended with `HAVE_FRAMEWORK_`. - -For example, if `have_framework('Ruby')` returned true, then the -`HAVE_FRAMEWORK_RUBY` preprocessor macro would be passed to the compiler. - -If `fw` is a pair of the framework name and its header file name that header -file is checked, instead of the normally used header file which is named same -as the framework. - -## have_func(func, headersnil, opt"", &b) [](#method-i-have_func) -Returns whether or not the function `func` can be found in the common header -files, or within any `headers` that you provide. If found, a macro is passed -as a preprocessor constant to the compiler using the function name, in -uppercase, prepended with `HAVE_`. - -To check functions in an additional library, you need to check that library -first using `have_library()`. The `func` shall be either mere function name -or function name with arguments. - -For example, if `have_func('foo')` returned `true`, then the `HAVE_FOO` -preprocessor macro would be passed to the compiler. - -## have_header(header, preheadersnil, opt"", &b) [](#method-i-have_header) -Returns whether or not the given `header` file can be found on your system. If -found, a macro is passed as a preprocessor constant to the compiler using the -header file name, in uppercase, prepended with `HAVE_`. - -For example, if `have_header('foo.h')` returned true, then the `HAVE_FOO_H` -preprocessor macro would be passed to the compiler. - -## have_library(lib, funcnil, headersnil, opt"", &b) [](#method-i-have_library) -Returns whether or not the given entry point `func` can be found within `lib`. - If `func` is `nil`, the `main()` entry point is used by default. If found, -it adds the library to list of libraries to be used when linking your -extension. - -If `headers` are provided, it will include those header files as the header -files it looks in when searching for `func`. - -The real name of the library to be linked can be altered by `--with-FOOlib` -configuration option. - -## have_macro(macro, headersnil, opt"", &b) [](#method-i-have_macro) -Returns whether or not `macro` is defined either in the common header files or -within any `headers` you provide. - -Any options you pass to `opt` are passed along to the compiler. - -## have_struct_member(type, member, headersnil, opt"", &b) [](#method-i-have_struct_member) -Returns whether or not the struct of type `type` contains `member`. If it -does not, or the struct type can't be found, then false is returned. You may -optionally specify additional `headers` in which to look for the struct (in -addition to the common header files). - -If found, a macro is passed as a preprocessor constant to the compiler using -the type name and the member name, in uppercase, prepended with `HAVE_`. - -For example, if `have_struct_member('struct foo', 'bar')` returned true, then -the `HAVE_STRUCT_FOO_BAR` preprocessor macro would be passed to the compiler. - -`HAVE_ST_BAR` is also defined for backward compatibility. - -## have_type(type, headersnil, opt"", &b) [](#method-i-have_type) -Returns whether or not the static type `type` is defined. You may optionally -pass additional `headers` to check against in addition to the common header -files. - -You may also pass additional flags to `opt` which are then passed along to the -compiler. - -If found, a macro is passed as a preprocessor constant to the compiler using -the type name, in uppercase, prepended with `HAVE_TYPE_`. - -For example, if `have_type('foo')` returned true, then the `HAVE_TYPE_FOO` -preprocessor macro would be passed to the compiler. - -## have_typeof?() [](#method-i-have_typeof?) -Used internally by the what_type? method to check if the *typeof* GCC -extension is available. - -**@return** [Boolean] - -## have_var(var, headersnil, opt"", &b) [](#method-i-have_var) -Returns whether or not the variable `var` can be found in the common header -files, or within any `headers` that you provide. If found, a macro is passed -as a preprocessor constant to the compiler using the variable name, in -uppercase, prepended with `HAVE_`. - -To check variables in an additional library, you need to check that library -first using `have_library()`. - -For example, if `have_var('foo')` returned true, then the `HAVE_FOO` -preprocessor macro would be passed to the compiler. - -## init_mkmf(configCONFIG, rbconfigRbConfig::CONFIG) [](#method-i-init_mkmf) -:stopdoc: - -## install_dirs(target_prefixnil) [](#method-i-install_dirs) - -## install_files(mfile, ifiles, mapnil, srcprefixnil) [](#method-i-install_files) - -## install_rb(mfile, dest, srcdirnil) [](#method-i-install_rb) - -## libpath_env() [](#method-i-libpath_env) - -## libpathflag(libpath$DEFLIBPATH|$LIBPATH) [](#method-i-libpathflag) - -## link_command(ldflags, *opts) [](#method-i-link_command) - -## link_config(ldflags, opt"", libpath$DEFLIBPATH|$LIBPATH) [](#method-i-link_config) - -## log_src(src, heading"checked program was") [](#method-i-log_src) -Logs *src* - -## macro_defined?(macro, src, opt"", &b) [](#method-i-macro_defined?) -This is used internally by the have_macro? method. - -**@return** [Boolean] - -## map_dir(dir, mapnil) [](#method-i-map_dir) - -## merge_libs(*libs) [](#method-i-merge_libs) - -## message(*s) [](#method-i-message) -Prints messages to $stdout, if verbose mode. - -Internal use only. - -## mkintpath(path) [](#method-i-mkintpath) - -## mkmf_failed(path) [](#method-i-mkmf_failed) -Returns whether or not the Makefile was successfully generated. If not, the -script will abort with an error message. - -Internal use only. - -## modified?(target, times) [](#method-i-modified?) -Returns time stamp of the `target` file if it exists and is newer than or -equal to all of `times`. - -**@return** [Boolean] - -## pkg_config(pkg, *options) [](#method-i-pkg_config) -Returns compile/link information about an installed library in a tuple of -`[cflags, ldflags, libs]`, by using the command found first in the following -commands: - -1. If `--with-{pkg}-config={command}` is given via command line option: - `{command} {options}` - -2. `{pkg}-config {options}` - -3. `pkg-config {options} {pkg}` - -Where `options` is the option name without dashes, for instance `"cflags"` for -the `--cflags` flag. - -The values obtained are appended to `$INCFLAGS`, `$CFLAGS`, `$LDFLAGS` and -`$libs`. - -If one or more `options` argument is given, the config command is invoked with -the options and a stripped output string is returned without modifying any of -the global values mentioned above. - -## relative_from(path, base) [](#method-i-relative_from) - -## scalar_ptr_type?(type, membernil, headersnil, &b) [](#method-i-scalar_ptr_type?) -Used internally by the what_type? method to determine if `type` is a scalar -pointer. - -**@return** [Boolean] - -## scalar_type?(type, membernil, headersnil, &b) [](#method-i-scalar_type?) -Used internally by the what_type? method to determine if `type` is a scalar -pointer. - -**@return** [Boolean] - -## split_libs(*strs) [](#method-i-split_libs) -:stopdoc: - -## timestamp_file(name, target_prefixnil) [](#method-i-timestamp_file) - -## try_cflags(flags, werror:true, **opts) [](#method-i-try_cflags) -:nodoc: - -## try_compile(src, opt"", werror:nil, **opts, &b) [](#method-i-try_compile) -Returns whether or not the `src` can be compiled as a C source. `opt` is -passed to the C compiler as options. Note that `$CFLAGS` is also passed to the -compiler. - -If a block given, it is called with the source before compilation. You can -modify the source in the block. - -`src` -: a String which contains a C source - -`opt` -: a String which contains compiler options - - -## try_const(const, headersnil, opt"", &b) [](#method-i-try_const) -:nodoc: Returns whether or not the constant `const` is defined. - -See also `have_const` - -## try_constant(const, headersnil, opt"", &b) [](#method-i-try_constant) - -## try_cpp(src, opt"", **opts, &b) [](#method-i-try_cpp) -Returns whether or not the `src` can be preprocessed with the C preprocessor. -`opt` is passed to the preprocessor as options. Note that `$CFLAGS` is also -passed to the preprocessor. - -If a block given, it is called with the source before preprocessing. You can -modify the source in the block. - -`src` -: a String which contains a C source - -`opt` -: a String which contains preprocessor options - - -## try_cppflags(flags, werror:true, **opts) [](#method-i-try_cppflags) -:nodoc: - -## try_do(src, command, **opts, &b) [](#method-i-try_do) - -## try_func(func, libs, headersnil, opt"", &b) [](#method-i-try_func) -You should use `have_func` rather than `try_func`. - -`func` -: a String which contains a symbol name - -`libs` -: a String which contains library names. - -`headers` -: a String or an Array of strings which contains names of header files. - - -## try_ldflags(flags, werror:$mswin, **opts) [](#method-i-try_ldflags) -:nodoc: - -## try_link(src, opt"", **opts, &b) [](#method-i-try_link) -Returns whether or not the `src` can be compiled as a C source and linked with -its depending libraries successfully. `opt` is passed to the linker as -options. Note that `$CFLAGS` and `$LDFLAGS` are also passed to the linker. - -If a block given, it is called with the source before compilation. You can -modify the source in the block. - -`src` -: a String which contains a C source - -`opt` -: a String which contains linker options - - -## try_link0(src, opt"", ldflags:"", **opts, &b) [](#method-i-try_link0) -:nodoc: - -## try_run(src, opt"", &b) [](#method-i-try_run) -Returns whether or not: -* the `src` can be compiled as a C source, -* the result object can be linked with its depending libraries successfully, -* the linked file can be invoked as an executable -* and the executable exits successfully - -`opt` is passed to the linker as options. Note that `$CFLAGS` and `$LDFLAGS` -are also passed to the linker. - -If a block given, it is called with the source before compilation. You can -modify the source in the block. - -`src` -: a String which contains a C source - -`opt` -: a String which contains linker options - - -Returns true when the executable exits successfully, false when it fails, or -nil when preprocessing, compilation or link fails. - -## try_signedness(type, member, headersnil, optsnil) [](#method-i-try_signedness) - -**@raise** [ArgumentError] - -## try_static_assert(expr, headersnil, opt"", &b) [](#method-i-try_static_assert) -:stopdoc: - -## try_type(type, headersnil, opt"", &b) [](#method-i-try_type) -:nodoc: Returns whether or not the static type `type` is defined. - -See also `have_type` - -## try_var(var, headersnil, opt"", &b) [](#method-i-try_var) -You should use `have_var` rather than `try_var`. - -## typedef_expr(type, headers) [](#method-i-typedef_expr) - -## werror_flag(optnil) [](#method-i-werror_flag) - -## what_type?(type, membernil, headersnil, &b) [](#method-i-what_type?) -Returns a string represents the type of *type*, or *member* of *type* if -*member* is not `nil`. - -**@return** [Boolean] - -## winsep(s) [](#method-i-winsep) -Converts forward slashes to backslashes. Aimed at MS Windows. - -Internal use only. - -## with_cflags(flags) [](#method-i-with_cflags) -Sets `$CFLAGS` to *flags* and yields. If the block returns a falsy value, -`$CFLAGS` is reset to its previous value, remains set to *flags* otherwise. - -## with_config(config, defaultnil) [](#method-i-with_config) -Tests for the presence of a `--with-`*config* or `--without-`*config* option. -Returns `true` if the with option is given, `false` if the without option is -given, and the default value otherwise. - -This can be useful for adding custom definitions, such as debug information. - -Example: - - if with_config("debug") - $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG" - end - -## with_cppflags(flags) [](#method-i-with_cppflags) -Sets `$CPPFLAGS` to *flags* and yields. If the block returns a falsy value, -`$CPPFLAGS` is reset to its previous value, remains set to *flags* otherwise. - -`flags` -: a C preprocessor flag as a `String` - - -## with_destdir(dir) [](#method-i-with_destdir) -:stopdoc: - -## with_ldflags(flags) [](#method-i-with_ldflags) -Sets `$LDFLAGS` to *flags* and yields. If the block returns a falsy value, -`$LDFLAGS` is reset to its previous value, remains set to *flags* otherwise. - -## with_werror(opt, optsnil) [](#method-i-with_werror) - -**@yield** [opt, opts] - -## xpopen(command, *mode, &block) [](#method-i-xpopen) -Executes *command* similarly to xsystem, but yields opened pipe. - -## xsystem(command, werror:false) [](#method-i-xsystem) -call-seq: - xsystem(command, werror: false) -> true or false - -Executes *command* with expanding variables, and returns the exit status like -as Kernel#system. If *werror* is true and the error output is not empty, -returns `false`. The output will logged. - diff --git a/example/ruby/MakeMakefile/Logging.md b/example/ruby/MakeMakefile/Logging.md deleted file mode 100644 index 6200f56..0000000 --- a/example/ruby/MakeMakefile/Logging.md +++ /dev/null @@ -1,24 +0,0 @@ -# Module: MakeMakefile::Logging - - -This is a custom logging module. It generates an mkmf.log file when you run -your extconf.rb script. This can be useful for debugging unexpected failures. - -This module and its associated methods are meant for internal use only. - - -# Class Methods -## log_close() [](#method-c-log_close) -## log_open() [](#method-c-log_open) -## log_opened?() [](#method-c-log_opened?) -**@return** [Boolean] - -## logfile(file ) [](#method-c-logfile) -## message(*s ) [](#method-c-message) -## open() [](#method-c-open) -## postpone() [](#method-c-postpone) -# Attributes -## quiet[RW] [](#attribute-c-quiet) -Returns the value of attribute quiet. - - diff --git a/example/ruby/MapItem.md b/example/ruby/MapItem.md deleted file mode 100644 index 1caaee1..0000000 --- a/example/ruby/MapItem.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: MapItem -**Inherits:** Object - - - - -# Attributes -## code[RW] [](#attribute-i-code) -Returns the value of attribute code. - -## lower[RW] [](#attribute-i-lower) -Returns the value of attribute lower. - -## title[RW] [](#attribute-i-title) -Returns the value of attribute title. - -## upper[RW] [](#attribute-i-upper) -Returns the value of attribute upper. - - -#Instance Methods -## initialize(code, upper, lower, title) [](#method-i-initialize) - -**@return** [MapItem] a new instance of MapItem - diff --git a/example/ruby/Marshal.md b/example/ruby/Marshal.md deleted file mode 100644 index 14a5a88..0000000 --- a/example/ruby/Marshal.md +++ /dev/null @@ -1,68 +0,0 @@ -# Module: Marshal - - - - -# Class Methods -## dump(*args ) [](#method-c-dump) -Serializes obj and all descendant objects. If anIO is specified, the -serialized data will be written to it, otherwise the data will be returned as -a String. If limit is specified, the traversal of subobjects will be limited -to that depth. If limit is negative, no checking of depth will be performed. - - class Klass - def initialize(str) - @str = str - end - def say_hello - @str - end - end - -(produces no output) - - o = Klass.new("hello\n") - data = Marshal.dump(o) - obj = Marshal.load(data) - obj.say_hello #=> "hello\n" - -Marshal can't dump following objects: -* anonymous Class/Module. -* objects which are related to system (ex: Dir, File::Stat, IO, File, Socket - and so on) -* an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread, - ThreadGroup, Continuation -* objects which define singleton methods -**@overload** [] - -## load(source , proc nil, freeze: false) [](#method-c-load) -call-seq: - load(source, proc = nil, freeze: false) -> obj - restore(source, proc = nil, freeze: false) -> obj - -Returns the result of converting the serialized data in source into a Ruby -object (possibly with associated subordinate objects). source may be either an -instance of IO or an object that responds to to_str. If proc is specified, -each object will be passed to the proc, as the object is being deserialized. - -Never pass untrusted data (including user supplied input) to this method. -Please see the overview for further details. - -If the `freeze: true` argument is passed, deserialized object would be deeply -frozen. Note that it may lead to more efficient memory usage due to frozen -strings deduplication: - - serialized = Marshal.dump(['value1', 'value2', 'value1', 'value2']) - - deserialized = Marshal.load(serialized) - deserialized.map(&:frozen?) - # => [false, false, false, false] - deserialized.map(&:object_id) - # => [1023900, 1023920, 1023940, 1023960] -- 4 different objects - - deserialized = Marshal.load(serialized, freeze: true) - deserialized.map(&:frozen?) - # => [true, true, true, true] - deserialized.map(&:object_id) - # => [1039360, 1039380, 1039360, 1039380] -- only 2 different objects, object_ids repeating - diff --git a/example/ruby/Marshal/InternalIVar.md b/example/ruby/Marshal/InternalIVar.md deleted file mode 100644 index 90e3fe0..0000000 --- a/example/ruby/Marshal/InternalIVar.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Marshal::InternalIVar -**Inherits:** Object - - - - - -#Instance Methods -## encoding_short() [](#method-i-encoding_short) - -## initialize(arg1, arg2, arg3) [](#method-i-initialize) - -## internal() [](#method-i-internal) - -## normal() [](#method-i-normal) - diff --git a/example/ruby/Marshal/InternalIVar/compat.md b/example/ruby/Marshal/InternalIVar/compat.md deleted file mode 100644 index 09146b1..0000000 --- a/example/ruby/Marshal/InternalIVar/compat.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Marshal::InternalIVar::compat -**Inherits:** Object - - - - - -#Instance Methods -## marshal_load(data) [](#method-i-marshal_load) - diff --git a/example/ruby/Marshal/UsrMarshal.md b/example/ruby/Marshal/UsrMarshal.md deleted file mode 100644 index 368a8f9..0000000 --- a/example/ruby/Marshal/UsrMarshal.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Marshal::UsrMarshal -**Inherits:** Object - - - - - -#Instance Methods -## initialize(val) [](#method-i-initialize) - -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(val) [](#method-i-marshal_load) - -## value() [](#method-i-value) - diff --git a/example/ruby/MarshalSpec.md b/example/ruby/MarshalSpec.md deleted file mode 100644 index dcbddaa..0000000 --- a/example/ruby/MarshalSpec.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: MarshalSpec - - - - -# Class Methods -## random_data() [](#method-c-random_data) -## reset_swapped_class() [](#method-c-reset_swapped_class) -## set_swapped_class(cls ) [](#method-c-set_swapped_class) - diff --git a/example/ruby/MarshalSpec/ArrayWithOverriddenName.md b/example/ruby/MarshalSpec/ArrayWithOverriddenName.md deleted file mode 100644 index aaafcc4..0000000 --- a/example/ruby/MarshalSpec/ArrayWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::ArrayWithOverriddenName -**Inherits:** Array - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalSpec/BasicObjectSubWithRespondToFalse.md b/example/ruby/MarshalSpec/BasicObjectSubWithRespondToFalse.md deleted file mode 100644 index 0d45708..0000000 --- a/example/ruby/MarshalSpec/BasicObjectSubWithRespondToFalse.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MarshalSpec::BasicObjectSubWithRespondToFalse -**Inherits:** BasicObject - - - - - -#Instance Methods -## respond_to?(method_name, include_allfalse) [](#method-i-respond_to?) - -**@return** [Boolean] - diff --git a/example/ruby/MarshalSpec/ClassWithOverriddenName.md b/example/ruby/MarshalSpec/ClassWithOverriddenName.md deleted file mode 100644 index cf233a3..0000000 --- a/example/ruby/MarshalSpec/ClassWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::ClassWithOverriddenName -**Inherits:** Object - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalSpec/DataSpec.md b/example/ruby/MarshalSpec/DataSpec.md deleted file mode 100644 index 149dc7f..0000000 --- a/example/ruby/MarshalSpec/DataSpec.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MarshalSpec::DataSpec - - - - - diff --git a/example/ruby/MarshalSpec/DataSpec/MeasureWithOverriddenName.md b/example/ruby/MarshalSpec/DataSpec/MeasureWithOverriddenName.md deleted file mode 100644 index acd068e..0000000 --- a/example/ruby/MarshalSpec/DataSpec/MeasureWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::DataSpec::MeasureWithOverriddenName -**Inherits:** MarshalSpec::DataSpec::Measure - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalSpec/HashWithOverriddenName.md b/example/ruby/MarshalSpec/HashWithOverriddenName.md deleted file mode 100644 index 66f2473..0000000 --- a/example/ruby/MarshalSpec/HashWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::HashWithOverriddenName -**Inherits:** Hash - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalSpec/M1.md b/example/ruby/MarshalSpec/M1.md deleted file mode 100644 index 0429e1b..0000000 --- a/example/ruby/MarshalSpec/M1.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: MarshalSpec::M1 - - -empty modules - - - diff --git a/example/ruby/MarshalSpec/ModuleToExtendBy.md b/example/ruby/MarshalSpec/ModuleToExtendBy.md deleted file mode 100644 index d9de9c6..0000000 --- a/example/ruby/MarshalSpec/ModuleToExtendBy.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MarshalSpec::ModuleToExtendBy - - - - - diff --git a/example/ruby/MarshalSpec/ModuleWithOverriddenName.md b/example/ruby/MarshalSpec/ModuleWithOverriddenName.md deleted file mode 100644 index 5bf0316..0000000 --- a/example/ruby/MarshalSpec/ModuleWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::ModuleWithOverriddenName -**Inherits:** Object - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalSpec/Multibyte_E38181_E38182_E38183_E38184Class.md b/example/ruby/MarshalSpec/Multibyte_E38181_E38182_E38183_E38184Class.md deleted file mode 100644 index 84359b0..0000000 --- a/example/ruby/MarshalSpec/Multibyte_E38181_E38182_E38183_E38184Class.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: MarshalSpec::MultibyteぁあぃいClass -**Inherits:** Object - - - - - diff --git a/example/ruby/MarshalSpec/Multibyte_E38181_E38182_E38183_E38184Time.md b/example/ruby/MarshalSpec/Multibyte_E38181_E38182_E38183_E38184Time.md deleted file mode 100644 index 0dd9e70..0000000 --- a/example/ruby/MarshalSpec/Multibyte_E38181_E38182_E38183_E38184Time.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: MarshalSpec::MultibyteぁあぃいTime -**Inherits:** Time - - - - - diff --git a/example/ruby/MarshalSpec/Multibyte_E38191_E38192_E38193_E38194Module.md b/example/ruby/MarshalSpec/Multibyte_E38191_E38192_E38193_E38194Module.md deleted file mode 100644 index 9426490..0000000 --- a/example/ruby/MarshalSpec/Multibyte_E38191_E38192_E38193_E38194Module.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MarshalSpec::MultibyteけげこごModule - - - - - diff --git a/example/ruby/MarshalSpec/ObjectWithFreezeRaisingException.md b/example/ruby/MarshalSpec/ObjectWithFreezeRaisingException.md deleted file mode 100644 index 7c999c3..0000000 --- a/example/ruby/MarshalSpec/ObjectWithFreezeRaisingException.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: MarshalSpec::ObjectWithFreezeRaisingException -**Inherits:** Object - - - - - -#Instance Methods -## freeze() [](#method-i-freeze) - diff --git a/example/ruby/MarshalSpec/ObjectWithoutFreeze.md b/example/ruby/MarshalSpec/ObjectWithoutFreeze.md deleted file mode 100644 index f8b16dd..0000000 --- a/example/ruby/MarshalSpec/ObjectWithoutFreeze.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: MarshalSpec::ObjectWithoutFreeze -**Inherits:** Object - - - - - diff --git a/example/ruby/MarshalSpec/RegexpWithOverriddenName.md b/example/ruby/MarshalSpec/RegexpWithOverriddenName.md deleted file mode 100644 index b1b5d6c..0000000 --- a/example/ruby/MarshalSpec/RegexpWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::RegexpWithOverriddenName -**Inherits:** Regexp - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalSpec/StringWithOverriddenName.md b/example/ruby/MarshalSpec/StringWithOverriddenName.md deleted file mode 100644 index 85af825..0000000 --- a/example/ruby/MarshalSpec/StringWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::StringWithOverriddenName -**Inherits:** String - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalSpec/StructToDump.md b/example/ruby/MarshalSpec/StructToDump.md deleted file mode 100644 index 506ed24..0000000 --- a/example/ruby/MarshalSpec/StructToDump.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: MarshalSpec::StructToDump -**Inherits:** Struct - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a - -**@return** [Object] the current value of a - -## b[RW] [](#attribute-i-b) -Returns the value of attribute b - -**@return** [Object] the current value of b - - diff --git a/example/ruby/MarshalSpec/StructWithOverriddenName.md b/example/ruby/MarshalSpec/StructWithOverriddenName.md deleted file mode 100644 index 9296219..0000000 --- a/example/ruby/MarshalSpec/StructWithOverriddenName.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: MarshalSpec::StructWithOverriddenName -**Inherits:** Struct - - - - -# Class Methods -## name() [](#method-c-name) -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a - -**@return** [Object] the current value of a - - diff --git a/example/ruby/MarshalSpec/StructWithUserInitialize.md b/example/ruby/MarshalSpec/StructWithUserInitialize.md deleted file mode 100644 index e2490ce..0000000 --- a/example/ruby/MarshalSpec/StructWithUserInitialize.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: MarshalSpec::StructWithUserInitialize -**Inherits:** Struct - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a - -**@return** [Object] the current value of a - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [StructWithUserInitialize] a new instance of StructWithUserInitialize - diff --git a/example/ruby/MarshalSpec/TimeWithOverriddenName.md b/example/ruby/MarshalSpec/TimeWithOverriddenName.md deleted file mode 100644 index 62c863e..0000000 --- a/example/ruby/MarshalSpec/TimeWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::TimeWithOverriddenName -**Inherits:** Time - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalSpec/UserDefinedWithOverriddenName.md b/example/ruby/MarshalSpec/UserDefinedWithOverriddenName.md deleted file mode 100644 index e2c1948..0000000 --- a/example/ruby/MarshalSpec/UserDefinedWithOverriddenName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MarshalSpec::UserDefinedWithOverriddenName -**Inherits:** UserDefined - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/MarshalTestLib.md b/example/ruby/MarshalTestLib.md deleted file mode 100644 index d0f44f7..0000000 --- a/example/ruby/MarshalTestLib.md +++ /dev/null @@ -1,117 +0,0 @@ -# Module: MarshalTestLib - - - - - -#Instance Methods -## marshal_equal(o1, msgnil) [](#method-i-marshal_equal) - -## marshal_equal_with_ancestry(o1, msgnil) [](#method-i-marshal_equal_with_ancestry) - -## marshaltest(o1) [](#method-i-marshaltest) - -## test_anonymous() [](#method-i-test_anonymous) - -## test_array() [](#method-i-test_array) - -## test_array_ivar() [](#method-i-test_array_ivar) - -## test_array_subclass() [](#method-i-test_array_subclass) - -## test_bignum() [](#method-i-test_bignum) - -## test_exception() [](#method-i-test_exception) - -## test_exception_subclass() [](#method-i-test_exception_subclass) - -## test_extend() [](#method-i-test_extend) - -## test_extend_string() [](#method-i-test_extend_string) - -## test_false() [](#method-i-test_false) - -## test_fixnum() [](#method-i-test_fixnum) - -## test_float() [](#method-i-test_float) - -## test_float_inf_nan() [](#method-i-test_float_inf_nan) - -## test_hash() [](#method-i-test_hash) - -## test_hash_default() [](#method-i-test_hash_default) - -## test_hash_default_proc() [](#method-i-test_hash_default_proc) - -## test_hash_extend() [](#method-i-test_hash_extend) - -## test_hash_ivar() [](#method-i-test_hash_ivar) - -## test_hash_subclass() [](#method-i-test_hash_subclass) - -## test_hash_subclass_extend() [](#method-i-test_hash_subclass_extend) - -## test_nil() [](#method-i-test_nil) - -## test_object() [](#method-i-test_object) - -## test_object_extend() [](#method-i-test_object_extend) - -## test_object_prepend() [](#method-i-test_object_prepend) - -## test_object_subclass() [](#method-i-test_object_subclass) - -## test_object_subclass_extend() [](#method-i-test_object_subclass_extend) - -## test_range() [](#method-i-test_range) - -## test_range_cyclic() [](#method-i-test_range_cyclic) - -## test_range_subclass() [](#method-i-test_range_subclass) - -## test_regexp() [](#method-i-test_regexp) - -## test_regexp_subclass() [](#method-i-test_regexp_subclass) - -## test_share() [](#method-i-test_share) - -## test_singleton() [](#method-i-test_singleton) - -## test_string() [](#method-i-test_string) - -## test_string_crlf() [](#method-i-test_string_crlf) - -## test_string_empty() [](#method-i-test_string_empty) - -## test_string_escape() [](#method-i-test_string_escape) - -## test_string_ivar() [](#method-i-test_string_ivar) - -## test_string_subclass() [](#method-i-test_string_subclass) - -## test_string_subclass_cycle() [](#method-i-test_string_subclass_cycle) - -## test_string_subclass_extend() [](#method-i-test_string_subclass_extend) - -## test_struct() [](#method-i-test_struct) - -## test_struct_ivar() [](#method-i-test_struct_ivar) - -## test_struct_subclass() [](#method-i-test_struct_subclass) - -## test_struct_subclass_extend() [](#method-i-test_struct_subclass_extend) - -## test_struct_toplevel() [](#method-i-test_struct_toplevel) - -## test_symbol() [](#method-i-test_symbol) - -## test_time() [](#method-i-test_time) - -## test_time_in_array() [](#method-i-test_time_in_array) - -## test_time_ivar() [](#method-i-test_time_ivar) - -## test_time_subclass() [](#method-i-test_time_subclass) - -## test_true() [](#method-i-test_true) - diff --git a/example/ruby/MarshalTestLib/CyclicRange.md b/example/ruby/MarshalTestLib/CyclicRange.md deleted file mode 100644 index 7b367e0..0000000 --- a/example/ruby/MarshalTestLib/CyclicRange.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: MarshalTestLib::CyclicRange -**Inherits:** Range - - - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - diff --git a/example/ruby/MarshalTestLib/Mod1.md b/example/ruby/MarshalTestLib/Mod1.md deleted file mode 100644 index 19c5b93..0000000 --- a/example/ruby/MarshalTestLib/Mod1.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MarshalTestLib::Mod1 - - - - - diff --git a/example/ruby/MarshalTestLib/Mod2.md b/example/ruby/MarshalTestLib/Mod2.md deleted file mode 100644 index 218f080..0000000 --- a/example/ruby/MarshalTestLib/Mod2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MarshalTestLib::Mod2 - - - - - diff --git a/example/ruby/MarshalTestLib/MyArray.md b/example/ruby/MarshalTestLib/MyArray.md deleted file mode 100644 index cc0ca7b..0000000 --- a/example/ruby/MarshalTestLib/MyArray.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MarshalTestLib::MyArray -**Inherits:** Array - - - - - -#Instance Methods -## initialize(v, *args) [](#method-i-initialize) - -**@return** [MyArray] a new instance of MyArray - diff --git a/example/ruby/MarshalTestLib/MyException.md b/example/ruby/MarshalTestLib/MyException.md deleted file mode 100644 index 557db73..0000000 --- a/example/ruby/MarshalTestLib/MyException.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: MarshalTestLib::MyException -**Inherits:** Exception - - - - -# Attributes -## v[RW] [](#attribute-i-v) -Returns the value of attribute v. - - -#Instance Methods -## initialize(v, *args) [](#method-i-initialize) - -**@return** [MyException] a new instance of MyException - diff --git a/example/ruby/MarshalTestLib/MyHash.md b/example/ruby/MarshalTestLib/MyHash.md deleted file mode 100644 index 813b24b..0000000 --- a/example/ruby/MarshalTestLib/MyHash.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MarshalTestLib::MyHash -**Inherits:** Hash - - - - - -#Instance Methods -## initialize(v, *args) [](#method-i-initialize) - -**@return** [MyHash] a new instance of MyHash - diff --git a/example/ruby/MarshalTestLib/MyObject.md b/example/ruby/MarshalTestLib/MyObject.md deleted file mode 100644 index dbb916d..0000000 --- a/example/ruby/MarshalTestLib/MyObject.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: MarshalTestLib::MyObject -**Inherits:** Object - - - - -# Attributes -## v[RW] [](#attribute-i-v) -Returns the value of attribute v. - - -#Instance Methods -## initialize(v) [](#method-i-initialize) - -**@return** [MyObject] a new instance of MyObject - diff --git a/example/ruby/MarshalTestLib/MyRange.md b/example/ruby/MarshalTestLib/MyRange.md deleted file mode 100644 index 3d510a1..0000000 --- a/example/ruby/MarshalTestLib/MyRange.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MarshalTestLib::MyRange -**Inherits:** Range - - - - - -#Instance Methods -## initialize(v, *args) [](#method-i-initialize) - -**@return** [MyRange] a new instance of MyRange - diff --git a/example/ruby/MarshalTestLib/MyRegexp.md b/example/ruby/MarshalTestLib/MyRegexp.md deleted file mode 100644 index dbd3079..0000000 --- a/example/ruby/MarshalTestLib/MyRegexp.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MarshalTestLib::MyRegexp -**Inherits:** Regexp - - - - - -#Instance Methods -## initialize(v, *args) [](#method-i-initialize) - -**@return** [MyRegexp] a new instance of MyRegexp - diff --git a/example/ruby/MarshalTestLib/MyString.md b/example/ruby/MarshalTestLib/MyString.md deleted file mode 100644 index f3108a3..0000000 --- a/example/ruby/MarshalTestLib/MyString.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MarshalTestLib::MyString -**Inherits:** String - - - - - -#Instance Methods -## initialize(v, *args) [](#method-i-initialize) - -**@return** [MyString] a new instance of MyString - diff --git a/example/ruby/MarshalTestLib/MyStruct.md b/example/ruby/MarshalTestLib/MyStruct.md deleted file mode 100644 index 7d6b7a1..0000000 --- a/example/ruby/MarshalTestLib/MyStruct.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: MarshalTestLib::MyStruct -**Inherits:** Struct - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a - -**@return** [Object] the current value of a - -## b[RW] [](#attribute-i-b) -Returns the value of attribute b - -**@return** [Object] the current value of b - - diff --git a/example/ruby/MarshalTestLib/MyStruct2.md b/example/ruby/MarshalTestLib/MyStruct2.md deleted file mode 100644 index 87cd1de..0000000 --- a/example/ruby/MarshalTestLib/MyStruct2.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: MarshalTestLib::MyStruct2 -**Inherits:** Struct - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a - -**@return** [Object] the current value of a - -## b[RW] [](#attribute-i-b) -Returns the value of attribute b - -**@return** [Object] the current value of b - - diff --git a/example/ruby/MarshalTestLib/MySubStruct.md b/example/ruby/MarshalTestLib/MySubStruct.md deleted file mode 100644 index 5350809..0000000 --- a/example/ruby/MarshalTestLib/MySubStruct.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MarshalTestLib::MySubStruct -**Inherits:** MarshalTestLib::MyStruct - - - - - -#Instance Methods -## initialize(v, *args) [](#method-i-initialize) - -**@return** [MySubStruct] a new instance of MySubStruct - diff --git a/example/ruby/MarshalTestLib/MyTime.md b/example/ruby/MarshalTestLib/MyTime.md deleted file mode 100644 index 764205a..0000000 --- a/example/ruby/MarshalTestLib/MyTime.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MarshalTestLib::MyTime -**Inherits:** Time - - - - - -#Instance Methods -## initialize(v, *args) [](#method-i-initialize) - -**@return** [MyTime] a new instance of MyTime - diff --git a/example/ruby/MatchData.md b/example/ruby/MatchData.md deleted file mode 100644 index 8a33ea8..0000000 --- a/example/ruby/MatchData.md +++ /dev/null @@ -1,375 +0,0 @@ -# Class: MatchData -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## ==(match2) [](#method-i-==) -Returns `true` if `object` is another MatchData object whose target string, -regexp, match, and captures are the same as `self`, `false` otherwise. - -**@overload** [] - -## [](*args) [](#method-i-[]) -When arguments `index`, +start and `length`, or `range` are given, returns -match and captures in the style of Array#[]: - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - # => # - m[0] # => "HX1138" - m[1, 2] # => ["H", "X"] - m[1..3] # => ["H", "X", "113"] - m[-3, 2] # => ["X", "113"] - -When string or symbol argument `name` is given, returns the matched substring -for the given name: - - m = /(?.)(.)(?.+)/.match("hoge") - # => # - m['foo'] # => "h" - m[:bar] # => "ge" - -If multiple captures have the same name, returns the last matched substring. - - m = /(?.)(?.+)/.match("hoge") - # => # - m[:foo] #=> "oge" - - m = /\W(?.+)|\w(?.+)|(?.+)/.match("hoge") - # - m[:foo] #=> "oge" - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## begin(n) [](#method-i-begin) -:include: doc/matchdata/begin.rdoc - -**@overload** [] - -**@overload** [] - -## bytebegin(n) [](#method-i-bytebegin) -:include: doc/matchdata/bytebegin.rdoc - -**@overload** [] - -**@overload** [] - -## byteend(n) [](#method-i-byteend) -:include: doc/matchdata/byteend.rdoc - -**@overload** [] - -**@overload** [] - -## byteoffset(n) [](#method-i-byteoffset) -Returns a two-element array containing the beginning and ending byte-based -offsets of the *n*th match. *n* can be a string or symbol to reference a named -capture. - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - m.byteoffset(0) #=> [1, 7] - m.byteoffset(4) #=> [6, 7] - - m = /(?.)(.)(?.)/.match("hoge") - p m.byteoffset(:foo) #=> [0, 1] - p m.byteoffset(:bar) #=> [2, 3] - -**@overload** [] - -## captures() [](#method-i-captures) -Returns the array of captures, which are all matches except `m[0]`: - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - # => # - m[0] # => "HX1138" - m.captures # => ["H", "X", "113", "8"] - -Related: MatchData.to_a. - -**@overload** [] - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Returns a hash of the named captures for the given names. - - m = /(?\d{2}):(?\d{2}):(?\d{2})/.match("18:37:22") - m.deconstruct_keys([:hours, :minutes]) # => {:hours => "18", :minutes => "37"} - m.deconstruct_keys(nil) # => {:hours => "18", :minutes => "37", :seconds => "22"} - -Returns an empty hash if no named captures were defined: - - m = /(\d{2}):(\d{2}):(\d{2})/.match("18:37:22") - m.deconstruct_keys(nil) # => {} - -**@overload** [] - -## end(n) [](#method-i-end) -:include: doc/matchdata/end.rdoc - -**@overload** [] - -**@overload** [] - -## eql?(match2) [](#method-i-eql?) -Returns `true` if `object` is another MatchData object whose target string, -regexp, match, and captures are the same as `self`, `false` otherwise. - -**@overload** [] - -## hash() [](#method-i-hash) -Returns the integer hash value for `self`, based on the target string, regexp, -match, and captures. - -See also Object#hash. - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - m = /.$/.match("foo") - # => # - m.inspect # => "#" - - m = /(.)(.)(.)/.match("foo") - # => # - m.inspect # => "# # - m.inspect # => "#" - -Related: MatchData#to_s. - -**@overload** [] - -## length() [](#method-i-length) -Returns size of the match array: - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - # => # - m.size # => 5 - -**@overload** [] - -## match(n) [](#method-i-match) -Returns the matched substring corresponding to the given argument. - -When non-negative argument `n` is given, returns the matched substring for the -`n`th match: - - m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.") - # => # - m.match(0) # => "HX1138" - m.match(4) # => "8" - m.match(5) # => nil - -When string or symbol argument `name` is given, returns the matched substring -for the given name: - - m = /(?.)(.)(?.+)/.match("hoge") - # => # - m.match('foo') # => "h" - m.match(:bar) # => "ge" - -**@overload** [] - -**@overload** [] - -## match_length(n) [](#method-i-match_length) -Returns the length (in characters) of the matched substring corresponding to -the given argument. - -When non-negative argument `n` is given, returns the length of the matched -substring for the `n`th match: - - m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.") - # => # - m.match_length(0) # => 6 - m.match_length(4) # => 1 - m.match_length(5) # => nil - -When string or symbol argument `name` is given, returns the length of the -matched substring for the named match: - - m = /(?.)(.)(?.+)/.match("hoge") - # => # - m.match_length('foo') # => 1 - m.match_length(:bar) # => 2 - -**@overload** [] - -**@overload** [] - -## named_captures(*args) [](#method-i-named_captures) -Returns a hash of the named captures; each key is a capture name; each value -is its captured string or `nil`: - - m = /(?.)(.)(?.+)/.match("hoge") - # => # - m.named_captures # => {"foo"=>"h", "bar"=>"ge"} - - m = /(?.)(?.)/.match("01") - # => # - m.named_captures #=> {"a" => "0", "b" => "1"} - - m = /(?.)(?.)?/.match("0") - # => # - m.named_captures #=> {"a" => "0", "b" => nil} - - m = /(?.)(?.)/.match("01") - # => # - m.named_captures #=> {"a" => "1"} - -If keyword argument `symbolize_names` is given a true value, the keys in the -resulting hash are Symbols: - - m = /(?.)(?.)/.match("01") - # => # - m.named_captures(symbolize_names: true) #=> {:a => "1"} - -**@overload** [] - -## names() [](#method-i-names) -Returns an array of the capture names (see [Named -Captures](rdoc-ref:Regexp@Named+Captures)): - - m = /(?.)(?.)(?.)/.match("hoge") - # => # - m.names # => ["foo", "bar", "baz"] - - m = /foo/.match('foo') # => # - m.names # => [] # No named captures. - -Equivalent to: - - m = /(?.)(?.)(?.)/.match("hoge") - m.regexp.names # => ["foo", "bar", "baz"] - -**@overload** [] - -## offset(n) [](#method-i-offset) -:include: doc/matchdata/offset.rdoc - -**@overload** [] - -**@overload** [] - -## post_match() [](#method-i-post_match) -Returns the substring of the target string from the end of the first match in -`self` (that is, `self[0]`) to the end of the string; equivalent to regexp -global variable `$'`: - - m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") - # => # - m[0] # => "HX1138" - m.post_match # => ": The Movie"\ - -Related: MatchData.pre_match. - -**@overload** [] - -## pre_match() [](#method-i-pre_match) -Returns the substring of the target string from its beginning up to the first -match in `self` (that is, `self[0]`); equivalent to regexp global variable -`$``: - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - # => # - m[0] # => "HX1138" - m.pre_match # => "T" - -Related: MatchData#post_match. - -**@overload** [] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## regexp() [](#method-i-regexp) -Returns the regexp that produced the match: - - m = /a.*b/.match("abc") # => # - m.regexp # => /a.*b/ - -**@overload** [] - -## size() [](#method-i-size) -Returns size of the match array: - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - # => # - m.size # => 5 - -**@overload** [] - -## string() [](#method-i-string) -Returns the target string if it was frozen; otherwise, returns a frozen copy -of the target string: - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - # => # - m.string # => "THX1138." - -**@overload** [] - -## to_a() [](#method-i-to_a) -Returns the array of matches: - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - # => # - m.to_a # => ["HX1138", "H", "X", "113", "8"] - -Related: MatchData#captures. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns the matched string: - - m = /(.)(.)(\d+)(\d)/.match("THX1138.") - # => # - m.to_s # => "HX1138" - - m = /(?.)(.)(?.+)/.match("hoge") - # => # - m.to_s # => "hoge" - -Related: MatchData.inspect. - -**@overload** [] - -## values_at(*args) [](#method-i-values_at) -Returns match and captures at the given `indexes`, which may include any -mixture of: - -* Integers. -* Ranges. -* Names (strings and symbols). - -Examples: - - m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") - # => # - m.values_at(0, 2, -2) # => ["HX1138", "X", "113"] - m.values_at(1..2, -1) # => ["H", "X", "8"] - - m = /(?\d+) *(?[+\-*\/]) *(?\d+)/.match("1 + 2") - # => # - m.values_at(0, 1..2, :a, :b, :op) - # => ["1 + 2", "1", "+", "1", "2", "+"] - -**@overload** [] - diff --git a/example/ruby/MatchDataSpecs.md b/example/ruby/MatchDataSpecs.md deleted file mode 100644 index b89db05..0000000 --- a/example/ruby/MatchDataSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MatchDataSpecs - - - - - diff --git a/example/ruby/MatchDataSpecs/MyString.md b/example/ruby/MatchDataSpecs/MyString.md deleted file mode 100644 index dfaa013..0000000 --- a/example/ruby/MatchDataSpecs/MyString.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: MatchDataSpecs::MyString -**Inherits:** String - - - - - diff --git a/example/ruby/MatchFilter.md b/example/ruby/MatchFilter.md deleted file mode 100644 index 0ce0638..0000000 --- a/example/ruby/MatchFilter.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: MatchFilter -**Inherits:** Object - - - - - -#Instance Methods -## ===(string) [](#method-i-===) - -## initialize(what, *strings) [](#method-i-initialize) - -**@return** [MatchFilter] a new instance of MatchFilter - -## register() [](#method-i-register) - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/MatchYAMLMatcher.md b/example/ruby/MatchYAMLMatcher.md deleted file mode 100644 index 294bd9d..0000000 --- a/example/ruby/MatchYAMLMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: MatchYAMLMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected) [](#method-i-initialize) - -**@return** [MatchYAMLMatcher] a new instance of MatchYAMLMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/Math.md b/example/ruby/Math.md deleted file mode 100644 index 2aa634b..0000000 --- a/example/ruby/Math.md +++ /dev/null @@ -1,480 +0,0 @@ -# Module: Math - - - - -# Class Methods -## acos(x ) [](#method-c-acos) -Returns the [arc -cosine](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of `x`. - -* Domain: `[-1, 1]`. -* Range: `[0, PI]`. - -Examples: - - acos(-1.0) # => 3.141592653589793 # PI - acos(0.0) # => 1.5707963267948966 # PI/2 - acos(1.0) # => 0.0 -**@overload** [] - -## acosh(x ) [](#method-c-acosh) -Returns the [inverse hyperbolic -cosine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`. - -* Domain: `[1, INFINITY]`. -* Range: `[0, INFINITY]`. - -Examples: - - acosh(1.0) # => 0.0 - acosh(INFINITY) # => Infinity -**@overload** [] - -## asin(x ) [](#method-c-asin) -Returns the [arc -sine](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of `x`. - -* Domain: `[-1, -1]`. -* Range: `[-PI/2, PI/2]`. - -Examples: - - asin(-1.0) # => -1.5707963267948966 # -PI/2 - asin(0.0) # => 0.0 - asin(1.0) # => 1.5707963267948966 # PI/2 -**@overload** [] - -## asinh(x ) [](#method-c-asinh) -Returns the [inverse hyperbolic -sine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`. - -* Domain: `[-INFINITY, INFINITY]`. -* Range: `[-INFINITY, INFINITY]`. - -Examples: - - asinh(-INFINITY) # => -Infinity - asinh(0.0) # => 0.0 - asinh(INFINITY) # => Infinity -**@overload** [] - -## atan(x ) [](#method-c-atan) -Returns the [arc -tangent](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of -`x`. - -* Domain: `[-INFINITY, INFINITY]`. -* Range: `[-PI/2, PI/2] `. - -Examples: - - atan(-INFINITY) # => -1.5707963267948966 # -PI2 - atan(-PI) # => -1.2626272556789115 - atan(-PI/2) # => -1.0038848218538872 - atan(0.0) # => 0.0 - atan(PI/2) # => 1.0038848218538872 - atan(PI) # => 1.2626272556789115 - atan(INFINITY) # => 1.5707963267948966 # PI/2 -**@overload** [] - -## atan2(y , x ) [](#method-c-atan2) -Returns the [arc tangent](https://en.wikipedia.org/wiki/Atan2) of `y` and `x` -in -[radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus -_degrees). - -* Domain of `y`: `[-INFINITY, INFINITY]`. -* Domain of `x`: `[-INFINITY, INFINITY]`. -* Range: `[-PI, PI]`. - -Examples: - - atan2(-1.0, -1.0) # => -2.356194490192345 # -3*PI/4 - atan2(-1.0, 0.0) # => -1.5707963267948966 # -PI/2 - atan2(-1.0, 1.0) # => -0.7853981633974483 # -PI/4 - atan2(0.0, -1.0) # => 3.141592653589793 # PI -**@overload** [] - -## atanh(x ) [](#method-c-atanh) -Returns the [inverse hyperbolic -tangent](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`. - -* Domain: `[-1, 1]`. -* Range: `[-INFINITY, INFINITY]`. - -Examples: - - atanh(-1.0) # => -Infinity - atanh(0.0) # => 0.0 - atanh(1.0) # => Infinity -**@overload** [] - -## cbrt(x ) [](#method-c-cbrt) -Returns the [cube root](https://en.wikipedia.org/wiki/Cube_root) of `x`. - -* Domain: `[-INFINITY, INFINITY]`. -* Range: `[-INFINITY, INFINITY]`. - -Examples: - - cbrt(-INFINITY) # => -Infinity - cbrt(-27.0) # => -3.0 - cbrt(-8.0) # => -2.0 - cbrt(-2.0) # => -1.2599210498948732 - cbrt(1.0) # => 1.0 - cbrt(0.0) # => 0.0 - cbrt(1.0) # => 1.0 - cbrt(2.0) # => 1.2599210498948732 - cbrt(8.0) # => 2.0 - cbrt(27.0) # => 3.0 - cbrt(INFINITY) # => Infinity -**@overload** [] - -## cos(x ) [](#method-c-cos) -Returns the [cosine](https://en.wikipedia.org/wiki/Sine_and_cosine) of `x` in -[radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus -_degrees). - -* Domain: `(-INFINITY, INFINITY)`. -* Range: `[-1.0, 1.0]`. - -Examples: - - cos(-PI) # => -1.0 - cos(-PI/2) # => 6.123031769111886e-17 # 0.0000000000000001 - cos(0.0) # => 1.0 - cos(PI/2) # => 6.123031769111886e-17 # 0.0000000000000001 - cos(PI) # => -1.0 -**@overload** [] - -## cosh(x ) [](#method-c-cosh) -Returns the [hyperbolic -cosine](https://en.wikipedia.org/wiki/Hyperbolic_functions) of `x` in -[radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus -_degrees). - -* Domain: `[-INFINITY, INFINITY]`. -* Range: `[1, INFINITY]`. - -Examples: - - cosh(-INFINITY) # => Infinity - cosh(0.0) # => 1.0 - cosh(INFINITY) # => Infinity -**@overload** [] - -## erf(x ) [](#method-c-erf) -Returns the value of the [Gauss error -function](https://en.wikipedia.org/wiki/Error_function) for `x`. - - - Domain: [-INFINITY, INFINITY]. - - Range: [-1, 1]. - - Examples: - - erf(-INFINITY) # => -1.0 - erf(0.0) # => 0.0 - erf(INFINITY) # => 1.0 - - Related: Math.erfc. -**@overload** [] - -## erfc(x ) [](#method-c-erfc) -Returns the value of the [complementary error -function](https://en.wikipedia.org/wiki/Error_function#Complementary_error_fun -ction) for `x`. - - - Domain: [-INFINITY, INFINITY]. - - Range: [0, 2]. - - Examples: - - erfc(-INFINITY) # => 2.0 - erfc(0.0) # => 1.0 - erfc(INFINITY) # => 0.0 - - Related: Math.erf. -**@overload** [] - -## exp(x ) [](#method-c-exp) -Returns `e` raised to the `x` power. - -* Domain: `[-INFINITY, INFINITY]`. -* Range: `[0, INFINITY]`. - -Examples: - - exp(-INFINITY) # => 0.0 - exp(-1.0) # => 0.36787944117144233 # 1.0/E - exp(0.0) # => 1.0 - exp(0.5) # => 1.6487212707001282 # sqrt(E) - exp(1.0) # => 2.718281828459045 # E - exp(2.0) # => 7.38905609893065 # E**2 - exp(INFINITY) # => Infinity -**@overload** [] - -## frexp(x ) [](#method-c-frexp) -Returns a 2-element array containing the normalized signed float `fraction` -and integer `exponent` of `x` such that: - - x = fraction * 2**exponent - -See [IEEE 754 double-precision binary floating-point format: -binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format -#IEEE_754_double-precision_binary_floating-point_format:_binary64). - -* Domain: `[-INFINITY, INFINITY]`. -* Range `[-INFINITY, INFINITY]`. - -Examples: - - frexp(-INFINITY) # => [-Infinity, -1] - frexp(-2.0) # => [-0.5, 2] - frexp(-1.0) # => [-0.5, 1] - frexp(0.0) # => [0.0, 0] - frexp(1.0) # => [0.5, 1] - frexp(2.0) # => [0.5, 2] - frexp(INFINITY) # => [Infinity, -1] - -Related: Math.ldexp (inverse of Math.frexp). -**@overload** [] - -## gamma(x ) [](#method-c-gamma) -Returns the value of the [gamma -function](https://en.wikipedia.org/wiki/Gamma_function) for `x`. - - - Domain: (-INFINITY, INFINITY] excluding negative integers. - - Range: [-INFINITY, INFINITY]. - - Examples: - - gamma(-2.5) # => -0.9453087204829431 - gamma(-1.5) # => 2.3632718012073513 - gamma(-0.5) # => -3.5449077018110375 - gamma(0.0) # => Infinity - gamma(1.0) # => 1.0 - gamma(2.0) # => 1.0 - gamma(3.0) # => 2.0 - gamma(4.0) # => 6.0 - gamma(5.0) # => 24.0 - - Related: Math.lgamma. -**@overload** [] - -## hypot(x , y ) [](#method-c-hypot) -Returns `sqrt(a**2 + b**2)`, which is the length of the longest side `c` (the -hypotenuse) of the right triangle whose other sides have lengths `a` and `b`. - -* Domain of `a`: `[-INFINITY, INFINITY]`. -* Domain of +ab: `[-INFINITY, INFINITY]`. -* Range: `[0, INFINITY]`. - -Examples: - - hypot(0.0, 1.0) # => 1.0 - hypot(1.0, 1.0) # => 1.4142135623730951 # sqrt(2.0) - hypot(3.0, 4.0) # => 5.0 - hypot(5.0, 12.0) # => 13.0 - hypot(1.0, sqrt(3.0)) # => 1.9999999999999998 # Near 2.0 - -Note that if either argument is `INFINITY` or `-INFINITY`, the result is -`Infinity`. -**@overload** [] - -## ldexp(x , n ) [](#method-c-ldexp) -Returns the value of `fraction * 2**exponent`. - -* Domain of `fraction`: `[0.0, 1.0)`. -* Domain of `exponent`: `[0, 1024]` (larger values are equivalent to 1024). - -See [IEEE 754 double-precision binary floating-point format: -binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format -#IEEE_754_double-precision_binary_floating-point_format:_binary64). - -Examples: - - ldexp(-INFINITY, -1) # => -Infinity - ldexp(-0.5, 2) # => -2.0 - ldexp(-0.5, 1) # => -1.0 - ldexp(0.0, 0) # => 0.0 - ldexp(-0.5, 1) # => 1.0 - ldexp(-0.5, 2) # => 2.0 - ldexp(INFINITY, -1) # => Infinity - -Related: Math.frexp (inverse of Math.ldexp). -**@overload** [] - -## lgamma(x ) [](#method-c-lgamma) -Returns a 2-element array equivalent to: - - [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] - - See {logarithmic gamma function}[https://en.wikipedia.org/wiki/Gamma_function#The_log-gamma_function]. - - - Domain: (-INFINITY, INFINITY]. - - Range of first element: (-INFINITY, INFINITY]. - - Second element is -1 or 1. - - Examples: - - lgamma(-4.0) # => [Infinity, -1] - lgamma(-3.0) # => [Infinity, -1] - lgamma(-2.0) # => [Infinity, -1] - lgamma(-1.0) # => [Infinity, -1] - lgamma(0.0) # => [Infinity, 1] - - lgamma(1.0) # => [0.0, 1] - lgamma(2.0) # => [0.0, 1] - lgamma(3.0) # => [0.6931471805599436, 1] - lgamma(4.0) # => [1.7917594692280545, 1] - - lgamma(-2.5) # => [-0.05624371649767279, -1] - lgamma(-1.5) # => [0.8600470153764797, 1] - lgamma(-0.5) # => [1.265512123484647, -1] - lgamma(0.5) # => [0.5723649429247004, 1] - lgamma(1.5) # => [-0.12078223763524676, 1] - lgamma(2.5) # => [0.2846828704729205, 1] - - Related: Math.gamma. -**@overload** [] - -## log(*args ) [](#method-c-log) -Returns the base `base` [logarithm](https://en.wikipedia.org/wiki/Logarithm) -of `x`. - -* Domain: `[0, INFINITY]`. -* Range: `[-INFINITY, INFINITY)]`. - -Examples: - - log(0.0) # => -Infinity - log(1.0) # => 0.0 - log(E) # => 1.0 - log(INFINITY) # => Infinity - - log(0.0, 2.0) # => -Infinity - log(1.0, 2.0) # => 0.0 - log(2.0, 2.0) # => 1.0 - - log(0.0, 10.0) # => -Infinity - log(1.0, 10.0) # => 0.0 - log(10.0, 10.0) # => 1.0 -**@overload** [] - -## log10(x ) [](#method-c-log10) -Returns the base 10 [logarithm](https://en.wikipedia.org/wiki/Logarithm) of -`x`. - -* Domain: `[0, INFINITY]`. -* Range: `[-INFINITY, INFINITY]`. - -Examples: - - log10(0.0) # => -Infinity - log10(1.0) # => 0.0 - log10(10.0) # => 1.0 - log10(INFINITY) # => Infinity -**@overload** [] - -## log2(x ) [](#method-c-log2) -Returns the base 2 [logarithm](https://en.wikipedia.org/wiki/Logarithm) of -`x`. - -* Domain: `[0, INFINITY]`. -* Range: `[-INFINITY, INFINITY]`. - -Examples: - - log2(0.0) # => -Infinity - log2(1.0) # => 0.0 - log2(2.0) # => 1.0 - log2(INFINITY) # => Infinity -**@overload** [] - -## sin(x ) [](#method-c-sin) -Returns the [sine](https://en.wikipedia.org/wiki/Sine_and_cosine) of `x` in -[radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus -_degrees). - -* Domain: `(-INFINITY, INFINITY)`. -* Range: `[-1.0, 1.0]`. - -Examples: - - sin(-PI) # => -1.2246063538223773e-16 # -0.0000000000000001 - sin(-PI/2) # => -1.0 - sin(0.0) # => 0.0 - sin(PI/2) # => 1.0 - sin(PI) # => 1.2246063538223773e-16 # 0.0000000000000001 -**@overload** [] - -## sinh(x ) [](#method-c-sinh) -Returns the [hyperbolic -sine](https://en.wikipedia.org/wiki/Hyperbolic_functions) of `x` in -[radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus -_degrees). - -* Domain: `[-INFINITY, INFINITY]`. -* Range: `[-INFINITY, INFINITY]`. - -Examples: - - sinh(-INFINITY) # => -Infinity - sinh(0.0) # => 0.0 - sinh(INFINITY) # => Infinity -**@overload** [] - -## sqrt(x ) [](#method-c-sqrt) -Returns the principal (non-negative) [square -root](https://en.wikipedia.org/wiki/Square_root) of `x`. - -* Domain: `[0, INFINITY]`. -* Range: `[0, INFINITY]`. - -Examples: - - sqrt(0.0) # => 0.0 - sqrt(0.5) # => 0.7071067811865476 - sqrt(1.0) # => 1.0 - sqrt(2.0) # => 1.4142135623730951 - sqrt(4.0) # => 2.0 - sqrt(9.0) # => 3.0 - sqrt(INFINITY) # => Infinity -**@overload** [] - -## tan(x ) [](#method-c-tan) -Returns the [tangent](https://en.wikipedia.org/wiki/Trigonometric_functions) -of `x` in -[radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus -_degrees). - -* Domain: `(-INFINITY, INFINITY)`. -* Range: `(-INFINITY, INFINITY)`. - -Examples: - - tan(-PI) # => 1.2246467991473532e-16 # -0.0000000000000001 - tan(-PI/2) # => -1.633123935319537e+16 # -16331239353195370.0 - tan(0.0) # => 0.0 - tan(PI/2) # => 1.633123935319537e+16 # 16331239353195370.0 - tan(PI) # => -1.2246467991473532e-16 # -0.0000000000000001 -**@overload** [] - -## tanh(x ) [](#method-c-tanh) -Returns the [hyperbolic -tangent](https://en.wikipedia.org/wiki/Hyperbolic_functions) of `x` in -[radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus -_degrees). - -* Domain: `[-INFINITY, INFINITY]`. -* Range: `[-1, 1]`. - -Examples: - - tanh(-INFINITY) # => -1.0 - tanh(0.0) # => 0.0 - tanh(INFINITY) # => 1.0 -**@overload** [] - - diff --git a/example/ruby/Math/DomainError.md b/example/ruby/Math/DomainError.md deleted file mode 100644 index ced15ab..0000000 --- a/example/ruby/Math/DomainError.md +++ /dev/null @@ -1,18 +0,0 @@ -# Exception: Math::DomainError -**Inherits:** StandardError - - -Raised when a mathematical function is evaluated outside of its domain of -definition. - -For example, since `cos` returns values in the range -1..1, its inverse -function `acos` is only defined on that interval: - - Math.acos(42) - -*produces:* - - Math::DomainError: Numerical argument is out of domain - "acos" - - - diff --git a/example/ruby/MathSpecs.md b/example/ruby/MathSpecs.md deleted file mode 100644 index 93e8de0..0000000 --- a/example/ruby/MathSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MathSpecs - - - - - diff --git a/example/ruby/MathSpecs/Float.md b/example/ruby/MathSpecs/Float.md deleted file mode 100644 index 5aa006a..0000000 --- a/example/ruby/MathSpecs/Float.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: MathSpecs::Float -**Inherits:** Numeric - - - - - -#Instance Methods -## initialize(value1.0) [](#method-i-initialize) - -**@return** [Float] a new instance of Float - -## to_f() [](#method-i-to_f) - diff --git a/example/ruby/MathSpecs/Integer.md b/example/ruby/MathSpecs/Integer.md deleted file mode 100644 index 9844fbc..0000000 --- a/example/ruby/MathSpecs/Integer.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: MathSpecs::Integer -**Inherits:** Object - - - - - -#Instance Methods -## to_int() [](#method-i-to_int) - diff --git a/example/ruby/MathSpecs/StringSubClass.md b/example/ruby/MathSpecs/StringSubClass.md deleted file mode 100644 index 0edd2c1..0000000 --- a/example/ruby/MathSpecs/StringSubClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: MathSpecs::StringSubClass -**Inherits:** String - - - - - diff --git a/example/ruby/MathSpecs/UserClass.md b/example/ruby/MathSpecs/UserClass.md deleted file mode 100644 index 5170f68..0000000 --- a/example/ruby/MathSpecs/UserClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: MathSpecs::UserClass -**Inherits:** Object - - - - - diff --git a/example/ruby/MatrixSub.md b/example/ruby/MatrixSub.md deleted file mode 100644 index 65618fb..0000000 --- a/example/ruby/MatrixSub.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MatrixSub -**Inherits:** Matrix - - - - -# Class Methods -## ins() [](#method-c-ins) - diff --git a/example/ruby/Mdoc2Man.md b/example/ruby/Mdoc2Man.md deleted file mode 100644 index 7ca7354..0000000 --- a/example/ruby/Mdoc2Man.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: Mdoc2Man -**Inherits:** Object - - -mdoc2man - mdoc to man converter - -Quick usage: mdoc2man.rb < mdoc_manpage.8 > man_manpage.8 - -Ported from Perl by Akinori MUSHA. - - Copyright (c) 2001 University of Illinois Board of Trustees - Copyright (c) 2001 Mark D. Roth - Copyright (c) 2002, 2003 Akinori MUSHA - 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. All advertising materials mentioning features or use of this software - must display the following acknowledgement: - This product includes software developed by the University of - Illinois at Urbana, and their contributors. - 4. The University nor the names of their - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE TRUSTEES 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 TRUSTEES 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. - -$Id$ - - -# Class Methods -## mdoc2man(i , o ) [](#method-c-mdoc2man) - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Mdoc2Man] a new instance of Mdoc2Man - -## mdoc2man(i, o) [](#method-i-mdoc2man) - -## parse_macro(line) [](#method-i-parse_macro) - -## shift_arg(words) [](#method-i-shift_arg) - diff --git a/example/ruby/Memory.md b/example/ruby/Memory.md deleted file mode 100644 index b4d462a..0000000 --- a/example/ruby/Memory.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Memory - - - - - diff --git a/example/ruby/Memory/Status.md b/example/ruby/Memory/Status.md deleted file mode 100644 index 9dfd688..0000000 --- a/example/ruby/Memory/Status.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Memory::Status -**Inherits:** Struct - - - - -# Class Methods -## parse(str ) [](#method-c-parse) - -#Instance Methods -## _update() [](#method-i-_update) - -## initialize() [](#method-i-initialize) - -**@return** [Status] a new instance of Status - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/MemoryViewTestUtils.md b/example/ruby/MemoryViewTestUtils.md deleted file mode 100644 index 3199469..0000000 --- a/example/ruby/MemoryViewTestUtils.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: MemoryViewTestUtils - - - - -# Class Methods -## available?(obj ) [](#method-c-available?) -**@return** [Boolean] - -## extract_item_members(str , format ) [](#method-c-extract_item_members) -## fill_contiguous_strides(ndim_v , item_size_v , shape_v , row_major_p ) [](#method-c-fill_contiguous_strides) -## get_memory_view_info(obj ) [](#method-c-get_memory_view_info) -## item_size_from_format(format ) [](#method-c-item_size_from_format) -## parse_item_format(format ) [](#method-c-parse_item_format) -## ref_count_while_exporting(obj , n ) [](#method-c-ref_count_while_exporting) -## register(obj ) [](#method-c-register) - diff --git a/example/ruby/MemoryViewTestUtils/ExportableString.md b/example/ruby/MemoryViewTestUtils/ExportableString.md deleted file mode 100644 index a7ae5d6..0000000 --- a/example/ruby/MemoryViewTestUtils/ExportableString.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: MemoryViewTestUtils::ExportableString -**Inherits:** Object - - - - - -#Instance Methods -## initialize(s) [](#method-i-initialize) - diff --git a/example/ruby/MemoryViewTestUtils/MultiDimensionalView.md b/example/ruby/MemoryViewTestUtils/MultiDimensionalView.md deleted file mode 100644 index 90b6f94..0000000 --- a/example/ruby/MemoryViewTestUtils/MultiDimensionalView.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MemoryViewTestUtils::MultiDimensionalView -**Inherits:** Object - - - - - -#Instance Methods -## [](indices_v) [](#method-i-[]) - -## initialize(buf, format, shape, strides) [](#method-i-initialize) - diff --git a/example/ruby/Merger_3DObject.new.md b/example/ruby/Merger_3DObject.new.md deleted file mode 100644 index d0fe085..0000000 --- a/example/ruby/Merger_3DObject.new.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Merger=Object.new -**Inherits:** Object - - - - - diff --git a/example/ruby/MetaClassSpecs.md b/example/ruby/MetaClassSpecs.md deleted file mode 100644 index fe2c9ec..0000000 --- a/example/ruby/MetaClassSpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: MetaClassSpecs - - - - -# Class Methods -## metaclass_of(obj ) [](#method-c-metaclass_of) - diff --git a/example/ruby/MetaClassSpecs/A.md b/example/ruby/MetaClassSpecs/A.md deleted file mode 100644 index 4aad4af..0000000 --- a/example/ruby/MetaClassSpecs/A.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MetaClassSpecs::A -**Inherits:** Object - - - - -# Class Methods -## cheese() [](#method-c-cheese) - diff --git a/example/ruby/MetaClassSpecs/B.md b/example/ruby/MetaClassSpecs/B.md deleted file mode 100644 index 3edd1da..0000000 --- a/example/ruby/MetaClassSpecs/B.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MetaClassSpecs::B -**Inherits:** MetaClassSpecs::A - - - - -# Class Methods -## cheese() [](#method-c-cheese) - diff --git a/example/ruby/MetaClassSpecs/C.md b/example/ruby/MetaClassSpecs/C.md deleted file mode 100644 index 394510b..0000000 --- a/example/ruby/MetaClassSpecs/C.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MetaClassSpecs::C -**Inherits:** Object - - - - -# Class Methods -## ham() [](#method-c-ham) - diff --git a/example/ruby/MetaClassSpecs/D.md b/example/ruby/MetaClassSpecs/D.md deleted file mode 100644 index 5947f6f..0000000 --- a/example/ruby/MetaClassSpecs/D.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: MetaClassSpecs::D -**Inherits:** MetaClassSpecs::C - - - - - diff --git a/example/ruby/MetaMetaMetaTestCase.md b/example/ruby/MetaMetaMetaTestCase.md deleted file mode 100644 index c33b999..0000000 --- a/example/ruby/MetaMetaMetaTestCase.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: MetaMetaMetaTestCase -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_report(expected, flags%w[--seed 42]) [](#method-i-assert_report) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## with_output() [](#method-i-with_output) - diff --git a/example/ruby/Method.md b/example/ruby/Method.md deleted file mode 100644 index 1065e50..0000000 --- a/example/ruby/Method.md +++ /dev/null @@ -1,344 +0,0 @@ -# Class: Method -**Inherits:** Object - - -******************************************************************** - - Method objects are created by Object#method, and are associated - with a particular object (not just with a class). They may be - used to invoke the method within the object, and as a block - associated with an iterator. They may also be unbound from one - object (creating an UnboundMethod) and bound to another. - - class Thing - def square(n) - n*n - end - end - thing = Thing.new - meth = thing.method(:square) - - meth.call(9) #=> 81 - [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9] - - [ 1, 2, 3 ].each(&method(:puts)) #=> prints 1, 2, 3 - - require 'date' - %w[2017-03-01 2017-03-02].collect(&Date.method(:parse)) - #=> [#, #] - - - -#Instance Methods -## <<(g) [](#method-i-<<) -Returns a proc that is the composition of this method and the given *g*. The -returned proc takes a variable number of arguments, calls *g* with them then -calls this method with the result. - - def f(x) - x * x - end - - f = self.method(:f) - g = proc {|x| x + x } - p (f << g).call(2) #=> 16 - -**@overload** [] - -## ==(other) [](#method-i-==) -Two method objects are equal if they are bound to the same object and refer to -the same method definition and the classes defining the methods are the same -class or module. - -**@overload** [] - -**@overload** [] - -## ===(*args) [](#method-i-===) -Invokes the *meth* with the specified arguments, returning the method's return -value. - - m = 12.method("+") - m.call(3) #=> 15 - m.call(20) #=> 32 - -**@overload** [] - -## >>(g) [](#method-i->>) -Returns a proc that is the composition of this method and the given *g*. The -returned proc takes a variable number of arguments, calls this method with -them then calls *g* with the result. - - def f(x) - x * x - end - - f = self.method(:f) - g = proc {|x| x + x } - p (f >> g).call(2) #=> 8 - -**@overload** [] - -## [](*args) [](#method-i-[]) -Invokes the *meth* with the specified arguments, returning the method's return -value. - - m = 12.method("+") - m.call(3) #=> 15 - m.call(20) #=> 32 - -**@overload** [] - -## arity() [](#method-i-arity) -Returns an indication of the number of arguments accepted by a method. Returns -a nonnegative integer for methods that take a fixed number of arguments. For -Ruby methods that take a variable number of arguments, returns -n-1, where n -is the number of required arguments. Keyword arguments will be considered as a -single additional argument, that argument being mandatory if any keyword -argument is mandatory. For methods written in C, returns -1 if the call takes -a variable number of arguments. - - class C - def one; end - def two(a); end - def three(*a); end - def four(a, b); end - def five(a, b, *c); end - def six(a, b, *c, &d); end - def seven(a, b, x:0); end - def eight(x:, y:); end - def nine(x:, y:, **z); end - def ten(*a, x:, y:); end - end - c = C.new - c.method(:one).arity #=> 0 - c.method(:two).arity #=> 1 - c.method(:three).arity #=> -1 - c.method(:four).arity #=> 2 - c.method(:five).arity #=> -3 - c.method(:six).arity #=> -3 - c.method(:seven).arity #=> -3 - c.method(:eight).arity #=> 1 - c.method(:nine).arity #=> 1 - c.method(:ten).arity #=> -2 - - "cat".method(:size).arity #=> 0 - "cat".method(:replace).arity #=> 1 - "cat".method(:squeeze).arity #=> -1 - "cat".method(:count).arity #=> -1 - -**@overload** [] - -## call(*args) [](#method-i-call) -Invokes the *meth* with the specified arguments, returning the method's return -value. - - m = 12.method("+") - m.call(3) #=> 15 - m.call(20) #=> 32 - -**@overload** [] - -## clone() [](#method-i-clone) -Returns a clone of this method. - - class A - def foo - return "bar" - end - end - - m = A.new.method(:foo) - m.call # => "bar" - n = m.clone.call # => "bar" - -**@overload** [] - -## curry(*args) [](#method-i-curry) -Returns a curried proc based on the method. When the proc is called with a -number of arguments that is lower than the method's arity, then another -curried proc is returned. Only when enough arguments have been supplied to -satisfy the method signature, will the method actually be called. - -The optional *arity* argument should be supplied when currying methods with -variable arguments to determine how many arguments are needed before the -method is called. - - def foo(a,b,c) - [a, b, c] - end - - proc = self.method(:foo).curry - proc2 = proc.call(1, 2) #=> # - proc2.call(3) #=> [1,2,3] - - def vararg(*args) - args - end - - proc = self.method(:vararg).curry(4) - proc2 = proc.call(:x) #=> # - proc3 = proc2.call(:y, :z) #=> # - proc3.call(:a) #=> [:x, :y, :z, :a] - -**@overload** [] - -**@overload** [] - -## dup() [](#method-i-dup) -:nodoc: - -## eql?(other) [](#method-i-eql?) -Two method objects are equal if they are bound to the same object and refer to -the same method definition and the classes defining the methods are the same -class or module. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -Returns a hash value corresponding to the method object. - -See also Object#hash. - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a human-readable description of the underlying method. - - "cat".method(:count).inspect #=> "#" - (1..3).method(:map).inspect #=> "#" - -In the latter case, the method description includes the "owner" of the -original method (`Enumerable` module, which is included into `Range`). - -`inspect` also provides, when possible, method argument names (call sequence) -and source location. - - require 'net/http' - Net::HTTP.method(:get).inspect - #=> "#/lib/ruby/2.7.0/net/http.rb:457>" - -`...` in argument definition means argument is optional (has some default -value). - -For methods defined in C (language core and extensions), location and argument -names can't be extracted, and only generic information is provided in form of -`*` (any number of arguments) or `_` (some positional argument). - - "cat".method(:count).inspect #=> "#" - "cat".method(:+).inspect #=> "#"" - -**@overload** [] - -**@overload** [] - -## name() [](#method-i-name) -Returns the name of the method. - -**@overload** [] - -## original_name() [](#method-i-original_name) -Returns the original name of the method. - - class C - def foo; end - alias bar foo - end - C.instance_method(:bar).original_name # => :foo - -**@overload** [] - -## owner() [](#method-i-owner) -Returns the class or module on which this method is defined. In other words, - - meth.owner.instance_methods(false).include?(meth.name) # => true - -holds as long as the method is not removed/undefined/replaced, (with -private_instance_methods instead of instance_methods if the method is -private). - -See also Method#receiver. - - (1..3).method(:map).owner #=> Enumerable - -**@overload** [] - -## parameters() [](#method-i-parameters) -Returns the parameter information of this method. - - def foo(bar); end - method(:foo).parameters #=> [[:req, :bar]] - - def foo(bar, baz, bat, &blk); end - method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:req, :bat], [:block, :blk]] - - def foo(bar, *args); end - method(:foo).parameters #=> [[:req, :bar], [:rest, :args]] - - def foo(bar, baz, *args, &blk); end - method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:rest, :args], [:block, :blk]] - -**@overload** [] - -## receiver() [](#method-i-receiver) -Returns the bound receiver of the method object. - - (1..3).method(:map).receiver # => 1..3 - -**@overload** [] - -## source_location() [](#method-i-source_location) -Returns the Ruby source filename and line number containing this method or nil -if this method was not defined in Ruby (i.e. native). - -**@overload** [] - -## super_method() [](#method-i-super_method) -Returns a Method of superclass which would be called when super is used or nil -if there is no method on superclass. - -**@overload** [] - -## to_proc() [](#method-i-to_proc) -Returns a Proc object corresponding to this method. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns a human-readable description of the underlying method. - - "cat".method(:count).inspect #=> "#" - (1..3).method(:map).inspect #=> "#" - -In the latter case, the method description includes the "owner" of the -original method (`Enumerable` module, which is included into `Range`). - -`inspect` also provides, when possible, method argument names (call sequence) -and source location. - - require 'net/http' - Net::HTTP.method(:get).inspect - #=> "#/lib/ruby/2.7.0/net/http.rb:457>" - -`...` in argument definition means argument is optional (has some default -value). - -For methods defined in C (language core and extensions), location and argument -names can't be extracted, and only generic information is provided in form of -`*` (any number of arguments) or `_` (some positional argument). - - "cat".method(:count).inspect #=> "#" - "cat".method(:+).inspect #=> "#"" - -**@overload** [] - -**@overload** [] - -## unbind() [](#method-i-unbind) -Dissociates *meth* from its current receiver. The resulting UnboundMethod can -subsequently be bound to a new object of the same class (see UnboundMethod). - -**@overload** [] - diff --git a/example/ruby/MethodFormatter.md b/example/ruby/MethodFormatter.md deleted file mode 100644 index 592dffe..0000000 --- a/example/ruby/MethodFormatter.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: MethodFormatter -**Inherits:** BaseFormatter - - - - -# Attributes -## methods[RW] [](#attribute-i-methods) -Returns the value of attribute methods. - - -#Instance Methods -## after(statenil) [](#method-i-after) -Callback for the MSpec :after event. Sets or adds to tallies for the example -block. - -## before(state) [](#method-i-before) -Callback for the MSpec :before event. Parses the describe string into class -and method if possible. Resets the tallies so the counts are only for this -example. - -## finish() [](#method-i-finish) -Callback for the MSpec :finish event. Prints out the summary information in -YAML format for all the methods. - -## initialize(outnil) [](#method-i-initialize) - -**@return** [MethodFormatter] a new instance of MethodFormatter - -## method_type(sep) [](#method-i-method_type) -Returns the type of method as a "class", "instance", or "unknown". - diff --git a/example/ruby/MethodMatcher.md b/example/ruby/MethodMatcher.md deleted file mode 100644 index 4a048b6..0000000 --- a/example/ruby/MethodMatcher.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: MethodMatcher -**Inherits:** Object - - - - - -#Instance Methods -## initialize(method, include_supertrue) [](#method-i-initialize) - -**@return** [MethodMatcher] a new instance of MethodMatcher - -## matches?(mod) [](#method-i-matches?) - -**@raise** [Exception] - -**@return** [Boolean] - diff --git a/example/ruby/MethodNameCheckTest.md b/example/ruby/MethodNameCheckTest.md deleted file mode 100644 index 5646354..0000000 --- a/example/ruby/MethodNameCheckTest.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: MethodNameCheckTest -**Inherits:** Test::Unit::TestCase - -**Includes:** DidYouMean::TestHelper - - - - - -#Instance Methods -## assert_correction(expected, array) [](#method-i-assert_correction) - -## setup() [](#method-i-setup) - -## test_corrections_include_class_method() [](#method-i-test_corrections_include_class_method) - -## test_corrections_include_instance_method() [](#method-i-test_corrections_include_instance_method) - -## test_corrections_include_method_from_module() [](#method-i-test_corrections_include_method_from_module) - -## test_corrections_include_private_method() [](#method-i-test_corrections_include_private_method) - -## test_corrections_when_private_method_is_called_with_args() [](#method-i-test_corrections_when_private_method_is_called_with_args) - -## test_does_not_append_suggestions_three_times() [](#method-i-test_does_not_append_suggestions_three_times) - -## test_does_not_append_suggestions_twice() [](#method-i-test_does_not_append_suggestions_twice) - -## test_does_not_exclude_custom_methods_on_nil() [](#method-i-test_does_not_exclude_custom_methods_on_nil) - -## test_does_not_suggest_reader() [](#method-i-test_does_not_suggest_reader) -Do not suggest `name` for `name=` - -## test_does_not_suggest_writer() [](#method-i-test_does_not_suggest_writer) -Do not suggest `name=` for `name` - -## test_does_not_suggest_yield() [](#method-i-test_does_not_suggest_yield) - -## test_exclude_methods_on_nil() [](#method-i-test_exclude_methods_on_nil) - -## test_private_methods_should_not_be_suggested() [](#method-i-test_private_methods_should_not_be_suggested) - -## test_suggests_corrections_on_nested_error() [](#method-i-test_suggests_corrections_on_nested_error) - -## test_suggests_yield() [](#method-i-test_suggests_yield) - diff --git a/example/ruby/MethodNameCheckTest/User.md b/example/ruby/MethodNameCheckTest/User.md deleted file mode 100644 index 79c4184..0000000 --- a/example/ruby/MethodNameCheckTest/User.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: MethodNameCheckTest::User -**Inherits:** Object - - - - -# Class Methods -## load() [](#method-c-load) -# Attributes -## reader[RW] [](#attribute-i-reader) -Returns the value of attribute reader. - -## writer=[R] [](#attribute-i-writer=) -Sets the attribute writer - -**@param** [] the value to set the attribute writer to. - - -#Instance Methods -## call_incorrect_private_method() [](#method-i-call_incorrect_private_method) - -## descendants() [](#method-i-descendants) - -## first_name() [](#method-i-first_name) - -## friends() [](#method-i-friends) - -## raise_no_method_error() [](#method-i-raise_no_method_error) - diff --git a/example/ruby/MethodNameCheckTest/UserModule.md b/example/ruby/MethodNameCheckTest/UserModule.md deleted file mode 100644 index dd95fa8..0000000 --- a/example/ruby/MethodNameCheckTest/UserModule.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: MethodNameCheckTest::UserModule - - - - - -#Instance Methods -## from_module() [](#method-i-from_module) - diff --git a/example/ruby/MethodSpecs.md b/example/ruby/MethodSpecs.md deleted file mode 100644 index 3e1e4db..0000000 --- a/example/ruby/MethodSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MethodSpecs - - - - - diff --git a/example/ruby/MethodSpecs/A.md b/example/ruby/MethodSpecs/A.md deleted file mode 100644 index 8605282..0000000 --- a/example/ruby/MethodSpecs/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MethodSpecs::A -**Inherits:** Object - - - - - -#Instance Methods -## baz(a, b) [](#method-i-baz) - -## overridden() [](#method-i-overridden) - diff --git a/example/ruby/MethodSpecs/B.md b/example/ruby/MethodSpecs/B.md deleted file mode 100644 index e61a86a..0000000 --- a/example/ruby/MethodSpecs/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: MethodSpecs::B -**Inherits:** MethodSpecs::A - - - - - -#Instance Methods -## overridden() [](#method-i-overridden) - diff --git a/example/ruby/MethodSpecs/BetweenBAndC.md b/example/ruby/MethodSpecs/BetweenBAndC.md deleted file mode 100644 index 4c3058a..0000000 --- a/example/ruby/MethodSpecs/BetweenBAndC.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: MethodSpecs::BetweenBAndC - - - - - -#Instance Methods -## overridden() [](#method-i-overridden) - diff --git a/example/ruby/MethodSpecs/C.md b/example/ruby/MethodSpecs/C.md deleted file mode 100644 index ff37dca..0000000 --- a/example/ruby/MethodSpecs/C.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MethodSpecs::C -**Inherits:** MethodSpecs::B - -**Includes:** MethodSpecs::BetweenBAndC - - - - - -#Instance Methods -## overridden() [](#method-i-overridden) - diff --git a/example/ruby/MethodSpecs/Composition.md b/example/ruby/MethodSpecs/Composition.md deleted file mode 100644 index 273ac0c..0000000 --- a/example/ruby/MethodSpecs/Composition.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: MethodSpecs::Composition -**Inherits:** Object - - - - - -#Instance Methods -## double(n) [](#method-i-double) - -## inc(n) [](#method-i-inc) - -## mul(n, m) [](#method-i-mul) - -## pow_2(n) [](#method-i-pow_2) - -## succ(s) [](#method-i-succ) - -## upcase(s) [](#method-i-upcase) - diff --git a/example/ruby/MethodSpecs/D.md b/example/ruby/MethodSpecs/D.md deleted file mode 100644 index 39cb9dd..0000000 --- a/example/ruby/MethodSpecs/D.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: MethodSpecs::D -**Inherits:** Object - - - - - -#Instance Methods -## bar() [](#method-i-bar) - diff --git a/example/ruby/MethodSpecs/Eql.md b/example/ruby/MethodSpecs/Eql.md deleted file mode 100644 index 658b713..0000000 --- a/example/ruby/MethodSpecs/Eql.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: MethodSpecs::Eql -**Inherits:** Object - - - - - -#Instance Methods -## different_body() [](#method-i-different_body) - -## same_body() [](#method-i-same_body) - -## same_body_two() [](#method-i-same_body_two) - -## same_body_with_args(arg) [](#method-i-same_body_with_args) - diff --git a/example/ruby/MethodSpecs/Eql2.md b/example/ruby/MethodSpecs/Eql2.md deleted file mode 100644 index fc0a34e..0000000 --- a/example/ruby/MethodSpecs/Eql2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: MethodSpecs::Eql2 -**Inherits:** Object - - - - - -#Instance Methods -## same_body() [](#method-i-same_body) - diff --git a/example/ruby/MethodSpecs/InheritedMethods.md b/example/ruby/MethodSpecs/InheritedMethods.md deleted file mode 100644 index e4a620a..0000000 --- a/example/ruby/MethodSpecs/InheritedMethods.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MethodSpecs::InheritedMethods - - - - - diff --git a/example/ruby/MethodSpecs/InheritedMethods/A.md b/example/ruby/MethodSpecs/InheritedMethods/A.md deleted file mode 100644 index 29316a4..0000000 --- a/example/ruby/MethodSpecs/InheritedMethods/A.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MethodSpecs::InheritedMethods::A - - - - - diff --git a/example/ruby/MethodSpecs/InheritedMethods/B.md b/example/ruby/MethodSpecs/InheritedMethods/B.md deleted file mode 100644 index d553855..0000000 --- a/example/ruby/MethodSpecs/InheritedMethods/B.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MethodSpecs::InheritedMethods::B - - - - - diff --git a/example/ruby/MethodSpecs/InheritedMethods/C.md b/example/ruby/MethodSpecs/InheritedMethods/C.md deleted file mode 100644 index 29c28b9..0000000 --- a/example/ruby/MethodSpecs/InheritedMethods/C.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: MethodSpecs::InheritedMethods::C -**Inherits:** Object - -**Includes:** MethodSpecs::InheritedMethods::A, MethodSpecs::InheritedMethods::B - - - - - diff --git a/example/ruby/MethodSpecs/Methods.md b/example/ruby/MethodSpecs/Methods.md deleted file mode 100644 index 127cfd8..0000000 --- a/example/ruby/MethodSpecs/Methods.md +++ /dev/null @@ -1,90 +0,0 @@ -# Class: MethodSpecs::Methods -**Inherits:** Object - - - - -# Attributes -## attr[RW] [](#attribute-i-attr) -Returns the value of attribute attr. - -## reader[RW] [](#attribute-i-reader) -Returns the value of attribute reader. - -## writer=[R] [](#attribute-i-writer=) -Sets the attribute writer - -**@param** [] the value to set the attribute writer to. - - -#Instance Methods -## foo() [](#method-i-foo) - -## method_missing(method, *arguments) [](#method-i-method_missing) - -## my_public_method() [](#method-i-my_public_method) - -## one_opt(anil) [](#method-i-one_opt) - -## one_opt_named(a:nil) [](#method-i-one_opt_named) - -## one_opt_with_block(anil, &blk) [](#method-i-one_opt_with_block) - -## one_req(a) [](#method-i-one_req) - -## one_req_named(a:) [](#method-i-one_req_named) - -## one_req_one_opt(a, bnil) [](#method-i-one_req_one_opt) - -## one_req_one_opt_with_block(a, bnil, &blk) [](#method-i-one_req_one_opt_with_block) - -## one_req_one_opt_with_splat(a, bnil, *c) [](#method-i-one_req_one_opt_with_splat) - -## one_req_one_opt_with_splat_and_block(a, bnil, *c, &blk) [](#method-i-one_req_one_opt_with_splat_and_block) - -## one_req_two_opt(a, bnil, cnil) [](#method-i-one_req_two_opt) - -## one_req_two_opt_with_block(a, bnil, cnil, &blk) [](#method-i-one_req_two_opt_with_block) - -## one_req_two_opt_with_splat(a, bnil, cnil, *d) [](#method-i-one_req_two_opt_with_splat) - -## one_req_two_opt_with_splat_and_block(a, bnil, cnil, *d, &blk) [](#method-i-one_req_two_opt_with_splat_and_block) - -## one_req_with_block(a, &blk) [](#method-i-one_req_with_block) - -## one_req_with_splat(a, *b) [](#method-i-one_req_with_splat) - -## one_req_with_splat_and_block(a, *b, &blk) [](#method-i-one_req_with_splat_and_block) - -## respond_to_missing?(method, bool) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - -## same_as_foo() [](#method-i-same_as_foo) - -## two_req(a, b) [](#method-i-two_req) - -## two_req_one_opt(a, b, cnil) [](#method-i-two_req_one_opt) - -## two_req_one_opt_with_block(a, b, cnil, &blk) [](#method-i-two_req_one_opt_with_block) - -## two_req_one_opt_with_splat(a, b, cnil, *d) [](#method-i-two_req_one_opt_with_splat) - -## two_req_one_opt_with_splat_and_block(a, b, cnil, *d, &blk) [](#method-i-two_req_one_opt_with_splat_and_block) - -## two_req_with_block(a, b, &blk) [](#method-i-two_req_with_block) - -## two_req_with_splat(a, b, *c) [](#method-i-two_req_with_splat) - -## two_req_with_splat_and_block(a, b, *c, &blk) [](#method-i-two_req_with_splat_and_block) - -## zero() [](#method-i-zero) - -## zero_with_block(&blk) [](#method-i-zero_with_block) - -## zero_with_double_splat(**a) [](#method-i-zero_with_double_splat) - -## zero_with_splat(*a) [](#method-i-zero_with_splat) - -## zero_with_splat_and_block(*a, &blk) [](#method-i-zero_with_splat_and_block) - diff --git a/example/ruby/MethodSpecs/MyMod.md b/example/ruby/MethodSpecs/MyMod.md deleted file mode 100644 index 8f55a16..0000000 --- a/example/ruby/MethodSpecs/MyMod.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: MethodSpecs::MyMod - - - - - -#Instance Methods -## bar() [](#method-i-bar) - diff --git a/example/ruby/MethodSpecs/MySub.md b/example/ruby/MethodSpecs/MySub.md deleted file mode 100644 index 8dc5482..0000000 --- a/example/ruby/MethodSpecs/MySub.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: MethodSpecs::MySub -**Inherits:** MethodSpecs::MySuper - - - - - diff --git a/example/ruby/MethodSpecs/MySuper.md b/example/ruby/MethodSpecs/MySuper.md deleted file mode 100644 index b63c7a6..0000000 --- a/example/ruby/MethodSpecs/MySuper.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MethodSpecs::MySuper -**Inherits:** Object - -**Includes:** MethodSpecs::MyMod - - - - - -#Instance Methods -## bar() [](#method-i-bar) - diff --git a/example/ruby/MethodSpecs/OverrideAgain.md b/example/ruby/MethodSpecs/OverrideAgain.md deleted file mode 100644 index 9eef1e9..0000000 --- a/example/ruby/MethodSpecs/OverrideAgain.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: MethodSpecs::OverrideAgain - - - - - -#Instance Methods -## overridden() [](#method-i-overridden) - diff --git a/example/ruby/MethodSpecs/SourceLocation.md b/example/ruby/MethodSpecs/SourceLocation.md deleted file mode 100644 index 89784b0..0000000 --- a/example/ruby/MethodSpecs/SourceLocation.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: MethodSpecs::SourceLocation -**Inherits:** Object - - - - -# Class Methods -## location() [](#method-c-location) -This needs to be on this line -## redefined() [](#method-c-redefined) - -#Instance Methods -## original() [](#method-i-original) - diff --git a/example/ruby/MethodSpecs/ToProc.md b/example/ruby/MethodSpecs/ToProc.md deleted file mode 100644 index 5488356..0000000 --- a/example/ruby/MethodSpecs/ToProc.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MethodSpecs::ToProc -**Inherits:** Object - - - - - -#Instance Methods -## method_called(a, b) [](#method-i-method_called) - -## to_proc() [](#method-i-to_proc) - diff --git a/example/ruby/MethodSpecs/ToProcBeta.md b/example/ruby/MethodSpecs/ToProcBeta.md deleted file mode 100644 index 3ffd832..0000000 --- a/example/ruby/MethodSpecs/ToProcBeta.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MethodSpecs::ToProcBeta -**Inherits:** Object - - - - - -#Instance Methods -## method_called(a) [](#method-i-method_called) - -## to_proc() [](#method-i-to_proc) - diff --git a/example/ruby/Meths.md b/example/ruby/Meths.md deleted file mode 100644 index 67c0842..0000000 --- a/example/ruby/Meths.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Meths - - - - - -#Instance Methods -## meths_method() [](#method-i-meths_method) - diff --git a/example/ruby/MethsMore.md b/example/ruby/MethsMore.md deleted file mode 100644 index c5016f6..0000000 --- a/example/ruby/MethsMore.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: MethsMore - - - - - -#Instance Methods -## meths_more_method() [](#method-i-meths_more_method) - diff --git a/example/ruby/Microsoft_FreeThreadedXMLDOM_1_0.md b/example/ruby/Microsoft_FreeThreadedXMLDOM_1_0.md deleted file mode 100644 index e529307..0000000 --- a/example/ruby/Microsoft_FreeThreadedXMLDOM_1_0.md +++ /dev/null @@ -1,274 +0,0 @@ -# Class: Microsoft_FreeThreadedXMLDOM_1_0 -**Inherits:** Object - -**Includes:** WIN32OLE::VARIANT - - -W3C-DOM XML Document (Apartment) - - -# Attributes -## clsid[RW] [](#attribute-i-clsid) -Returns the value of attribute clsid. - -## dispatch[RW] [](#attribute-i-dispatch) -Returns the value of attribute dispatch. - -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - -## progid[RW] [](#attribute-i-progid) -Returns the value of attribute progid. - - -#Instance Methods -## abort() [](#method-i-abort) -VOID abort abort an asynchronous download - -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## async() [](#method-i-async) -BOOL async flag for asynchronous download - -## async=(arg0) [](#method-i-async=) -VOID async flag for asynchronous download - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## createAttribute(arg0) [](#method-i-createAttribute) -IXMLDOMAttribute createAttribute create an attribute node - BSTR arg0 --- name [IN] - -## createCDATASection(arg0) [](#method-i-createCDATASection) -IXMLDOMCDATASection createCDATASection create a CDATA section node - BSTR arg0 --- data [IN] - -## createComment(arg0) [](#method-i-createComment) -IXMLDOMComment createComment create a comment node - BSTR arg0 --- data [IN] - -## createDocumentFragment() [](#method-i-createDocumentFragment) -IXMLDOMDocumentFragment createDocumentFragment create a DocumentFragment node - -## createElement(arg0) [](#method-i-createElement) -IXMLDOMElement createElement create an Element node - BSTR arg0 --- tagName [IN] - -## createEntityReference(arg0) [](#method-i-createEntityReference) -IXMLDOMEntityReference createEntityReference create an entity reference node - BSTR arg0 --- name [IN] - -## createNode(arg0, arg1, arg2) [](#method-i-createNode) -IXMLDOMNode createNode create a node of the specified node type and name - VARIANT arg0 --- type [IN] - BSTR arg1 --- name [IN] - BSTR arg2 --- namespaceURI [IN] - -## createProcessingInstruction(arg0, arg1) [](#method-i-createProcessingInstruction) -IXMLDOMProcessingInstruction createProcessingInstruction create a processing -instruction node - BSTR arg0 --- target [IN] - BSTR arg1 --- data [IN] - -## createTextNode(arg0) [](#method-i-createTextNode) -IXMLDOMText createTextNode create a text node - BSTR arg0 --- data [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## doctype() [](#method-i-doctype) -IXMLDOMDocumentType doctype node corresponding to the DOCTYPE - -## documentElement() [](#method-i-documentElement) -IXMLDOMElement documentElement the root of the tree - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## getElementsByTagName(arg0) [](#method-i-getElementsByTagName) -IXMLDOMNodeList getElementsByTagName build a list of elements by name - BSTR arg0 --- tagName [IN] - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## implementation() [](#method-i-implementation) -IXMLDOMImplementation implementation info on this DOM implementation - -## initialize(objnil) [](#method-i-initialize) - -**@return** [Microsoft_FreeThreadedXMLDOM_1_0] a new instance of Microsoft_FreeThreadedXMLDOM_1_0 - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## load(arg0) [](#method-i-load) -BOOL load load document from the specified XML source - VARIANT arg0 --- xmlSource [IN] - -## loadXML(arg0) [](#method-i-loadXML) -BOOL loadXML load the document from a string - BSTR arg0 --- bstrXML [IN] - -## method_missing(cmd, *arg) [](#method-i-method_missing) - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeFromID(arg0) [](#method-i-nodeFromID) -IXMLDOMNode nodeFromID retrieve node from it's ID - BSTR arg0 --- idString [IN] - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ondataavailable() [](#method-i-ondataavailable) -HRESULT ondataavailable EVENT in XMLDOMDocumentEvents - -## ondataavailable=(arg0) [](#method-i-ondataavailable=) -VOID ondataavailable register an ondataavailable event handler - -## onreadystatechange() [](#method-i-onreadystatechange) -HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents - -## onreadystatechange=(arg0) [](#method-i-onreadystatechange=) -VOID onreadystatechange register a readystatechange event handler - -## ontransformnode=(arg0) [](#method-i-ontransformnode=) -VOID ontransformnode register an ontransformnode event handler - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parseError() [](#method-i-parseError) -IXMLDOMParseError parseError get the last parser error - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## preserveWhiteSpace() [](#method-i-preserveWhiteSpace) -BOOL preserveWhiteSpace indicates whether the parser preserves whitespace - -## preserveWhiteSpace=(arg0) [](#method-i-preserveWhiteSpace=) -VOID preserveWhiteSpace indicates whether the parser preserves whitespace - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## readyState() [](#method-i-readyState) -I4 readyState get the state of the XML document - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## resolveExternals() [](#method-i-resolveExternals) -BOOL resolveExternals indicates whether the parser resolves references to -external DTD/Entities/Schema - -## resolveExternals=(arg0) [](#method-i-resolveExternals=) -VOID resolveExternals indicates whether the parser resolves references to -external DTD/Entities/Schema - -## save(arg0) [](#method-i-save) -VOID save save the document to a specified destination - VARIANT arg0 --- destination [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## url() [](#method-i-url) -BSTR url get the URL for the loaded XML document - -## validateOnParse() [](#method-i-validateOnParse) -BOOL validateOnParse indicates whether the parser performs validation - -## validateOnParse=(arg0) [](#method-i-validateOnParse=) -VOID validateOnParse indicates whether the parser performs validation - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/Microsoft_XMLDOM_1_0.md b/example/ruby/Microsoft_XMLDOM_1_0.md deleted file mode 100644 index 32b4481..0000000 --- a/example/ruby/Microsoft_XMLDOM_1_0.md +++ /dev/null @@ -1,274 +0,0 @@ -# Class: Microsoft_XMLDOM_1_0 -**Inherits:** Object - -**Includes:** WIN32OLE::VARIANT - - -W3C-DOM XML Document - - -# Attributes -## clsid[RW] [](#attribute-i-clsid) -Returns the value of attribute clsid. - -## dispatch[RW] [](#attribute-i-dispatch) -Returns the value of attribute dispatch. - -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - -## progid[RW] [](#attribute-i-progid) -Returns the value of attribute progid. - - -#Instance Methods -## abort() [](#method-i-abort) -VOID abort abort an asynchronous download - -## appendChild(arg0) [](#method-i-appendChild) -IXMLDOMNode appendChild append a child node - IXMLDOMNode arg0 --- newChild [IN] - -## async() [](#method-i-async) -BOOL async flag for asynchronous download - -## async=(arg0) [](#method-i-async=) -VOID async flag for asynchronous download - -## attributes() [](#method-i-attributes) -IXMLDOMNamedNodeMap attributes the collection of the node's attributes - -## baseName() [](#method-i-baseName) -BSTR baseName the base name of the node (nodename with the prefix stripped -off) - -## childNodes() [](#method-i-childNodes) -IXMLDOMNodeList childNodes the collection of the node's children - -## cloneNode(arg0) [](#method-i-cloneNode) -IXMLDOMNode cloneNode - BOOL arg0 --- deep [IN] - -## createAttribute(arg0) [](#method-i-createAttribute) -IXMLDOMAttribute createAttribute create an attribute node - BSTR arg0 --- name [IN] - -## createCDATASection(arg0) [](#method-i-createCDATASection) -IXMLDOMCDATASection createCDATASection create a CDATA section node - BSTR arg0 --- data [IN] - -## createComment(arg0) [](#method-i-createComment) -IXMLDOMComment createComment create a comment node - BSTR arg0 --- data [IN] - -## createDocumentFragment() [](#method-i-createDocumentFragment) -IXMLDOMDocumentFragment createDocumentFragment create a DocumentFragment node - -## createElement(arg0) [](#method-i-createElement) -IXMLDOMElement createElement create an Element node - BSTR arg0 --- tagName [IN] - -## createEntityReference(arg0) [](#method-i-createEntityReference) -IXMLDOMEntityReference createEntityReference create an entity reference node - BSTR arg0 --- name [IN] - -## createNode(arg0, arg1, arg2) [](#method-i-createNode) -IXMLDOMNode createNode create a node of the specified node type and name - VARIANT arg0 --- type [IN] - BSTR arg1 --- name [IN] - BSTR arg2 --- namespaceURI [IN] - -## createProcessingInstruction(arg0, arg1) [](#method-i-createProcessingInstruction) -IXMLDOMProcessingInstruction createProcessingInstruction create a processing -instruction node - BSTR arg0 --- target [IN] - BSTR arg1 --- data [IN] - -## createTextNode(arg0) [](#method-i-createTextNode) -IXMLDOMText createTextNode create a text node - BSTR arg0 --- data [IN] - -## dataType() [](#method-i-dataType) -VARIANT dataType the data type of the node - -## dataType=(arg0) [](#method-i-dataType=) -VOID dataType the data type of the node - -## definition() [](#method-i-definition) -IXMLDOMNode definition pointer to the definition of the node in the DTD or -schema - -## doctype() [](#method-i-doctype) -IXMLDOMDocumentType doctype node corresponding to the DOCTYPE - -## documentElement() [](#method-i-documentElement) -IXMLDOMElement documentElement the root of the tree - -## firstChild() [](#method-i-firstChild) -IXMLDOMNode firstChild first child of the node - -## getElementsByTagName(arg0) [](#method-i-getElementsByTagName) -IXMLDOMNodeList getElementsByTagName build a list of elements by name - BSTR arg0 --- tagName [IN] - -## hasChildNodes() [](#method-i-hasChildNodes) -BOOL hasChildNodes - -## implementation() [](#method-i-implementation) -IXMLDOMImplementation implementation info on this DOM implementation - -## initialize(objnil) [](#method-i-initialize) - -**@return** [Microsoft_XMLDOM_1_0] a new instance of Microsoft_XMLDOM_1_0 - -## insertBefore(arg0, arg1) [](#method-i-insertBefore) -IXMLDOMNode insertBefore insert a child node - IXMLDOMNode arg0 --- newChild [IN] - VARIANT arg1 --- refChild [IN] - -## lastChild() [](#method-i-lastChild) -IXMLDOMNode lastChild first child of the node - -## load(arg0) [](#method-i-load) -BOOL load load document from the specified XML source - VARIANT arg0 --- xmlSource [IN] - -## loadXML(arg0) [](#method-i-loadXML) -BOOL loadXML load the document from a string - BSTR arg0 --- bstrXML [IN] - -## method_missing(cmd, *arg) [](#method-i-method_missing) - -## namespaceURI() [](#method-i-namespaceURI) -BSTR namespaceURI the URI for the namespace applying to the node - -## nextSibling() [](#method-i-nextSibling) -IXMLDOMNode nextSibling right sibling of the node - -## nodeFromID(arg0) [](#method-i-nodeFromID) -IXMLDOMNode nodeFromID retrieve node from it's ID - BSTR arg0 --- idString [IN] - -## nodeName() [](#method-i-nodeName) -BSTR nodeName name of the node - -## nodeType() [](#method-i-nodeType) -DOMNodeType nodeType the node's type - -## nodeTypeString() [](#method-i-nodeTypeString) -BSTR nodeTypeString the type of node in string form - -## nodeTypedValue() [](#method-i-nodeTypedValue) -VARIANT nodeTypedValue get the strongly typed value of the node - -## nodeTypedValue=(arg0) [](#method-i-nodeTypedValue=) -VOID nodeTypedValue get the strongly typed value of the node - -## nodeValue() [](#method-i-nodeValue) -VARIANT nodeValue value stored in the node - -## nodeValue=(arg0) [](#method-i-nodeValue=) -VOID nodeValue value stored in the node - -## ondataavailable() [](#method-i-ondataavailable) -HRESULT ondataavailable EVENT in XMLDOMDocumentEvents - -## ondataavailable=(arg0) [](#method-i-ondataavailable=) -VOID ondataavailable register an ondataavailable event handler - -## onreadystatechange() [](#method-i-onreadystatechange) -HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents - -## onreadystatechange=(arg0) [](#method-i-onreadystatechange=) -VOID onreadystatechange register a readystatechange event handler - -## ontransformnode=(arg0) [](#method-i-ontransformnode=) -VOID ontransformnode register an ontransformnode event handler - -## ownerDocument() [](#method-i-ownerDocument) -IXMLDOMDocument ownerDocument document that contains the node - -## parentNode() [](#method-i-parentNode) -IXMLDOMNode parentNode parent of the node - -## parseError() [](#method-i-parseError) -IXMLDOMParseError parseError get the last parser error - -## parsed() [](#method-i-parsed) -BOOL parsed has sub-tree been completely parsed - -## prefix() [](#method-i-prefix) -BSTR prefix the prefix for the namespace applying to the node - -## preserveWhiteSpace() [](#method-i-preserveWhiteSpace) -BOOL preserveWhiteSpace indicates whether the parser preserves whitespace - -## preserveWhiteSpace=(arg0) [](#method-i-preserveWhiteSpace=) -VOID preserveWhiteSpace indicates whether the parser preserves whitespace - -## previousSibling() [](#method-i-previousSibling) -IXMLDOMNode previousSibling left sibling of the node - -## readyState() [](#method-i-readyState) -I4 readyState get the state of the XML document - -## removeChild(arg0) [](#method-i-removeChild) -IXMLDOMNode removeChild remove a child node - IXMLDOMNode arg0 --- childNode [IN] - -## replaceChild(arg0, arg1) [](#method-i-replaceChild) -IXMLDOMNode replaceChild replace a child node - IXMLDOMNode arg0 --- newChild [IN] - IXMLDOMNode arg1 --- oldChild [IN] - -## resolveExternals() [](#method-i-resolveExternals) -BOOL resolveExternals indicates whether the parser resolves references to -external DTD/Entities/Schema - -## resolveExternals=(arg0) [](#method-i-resolveExternals=) -VOID resolveExternals indicates whether the parser resolves references to -external DTD/Entities/Schema - -## save(arg0) [](#method-i-save) -VOID save save the document to a specified destination - VARIANT arg0 --- destination [IN] - -## selectNodes(arg0) [](#method-i-selectNodes) -IXMLDOMNodeList selectNodes execute query on the subtree - BSTR arg0 --- queryString [IN] - -## selectSingleNode(arg0) [](#method-i-selectSingleNode) -IXMLDOMNode selectSingleNode execute query on the subtree - BSTR arg0 --- queryString [IN] - -## specified() [](#method-i-specified) -BOOL specified indicates whether node is a default value - -## text() [](#method-i-text) -BSTR text text content of the node and subtree - -## text=(arg0) [](#method-i-text=) -VOID text text content of the node and subtree - -## transformNode(arg0) [](#method-i-transformNode) -BSTR transformNode apply the stylesheet to the subtree - IXMLDOMNode arg0 --- stylesheet [IN] - -## transformNodeToObject(arg0, arg1) [](#method-i-transformNodeToObject) -VOID transformNodeToObject apply the stylesheet to the subtree, returning the -result through a document or a stream - IXMLDOMNode arg0 --- stylesheet [IN] - VARIANT arg1 --- outputObject [IN] - -## url() [](#method-i-url) -BSTR url get the URL for the loaded XML document - -## validateOnParse() [](#method-i-validateOnParse) -BOOL validateOnParse indicates whether the parser performs validation - -## validateOnParse=(arg0) [](#method-i-validateOnParse=) -VOID validateOnParse indicates whether the parser performs validation - -## xml() [](#method-i-xml) -BSTR xml return the XML source for the node and each of its descendants - diff --git a/example/ruby/Microsoft_XMLDSO_1_0.md b/example/ruby/Microsoft_XMLDSO_1_0.md deleted file mode 100644 index d52a67e..0000000 --- a/example/ruby/Microsoft_XMLDSO_1_0.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: Microsoft_XMLDSO_1_0 -**Inherits:** Object - -**Includes:** WIN32OLE::VARIANT - - -XML Data Source Object - - -# Attributes -## clsid[RW] [](#attribute-i-clsid) -Returns the value of attribute clsid. - -## dispatch[RW] [](#attribute-i-dispatch) -Returns the value of attribute dispatch. - -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - -## progid[RW] [](#attribute-i-progid) -Returns the value of attribute progid. - - -#Instance Methods -## JavaDSOCompatible() [](#method-i-JavaDSOCompatible) -I4 JavaDSOCompatible - -## JavaDSOCompatible=(arg0) [](#method-i-JavaDSOCompatible=) -VOID JavaDSOCompatible - -## XMLDocument() [](#method-i-XMLDocument) -IXMLDOMDocument XMLDocument - -## XMLDocument=(arg0) [](#method-i-XMLDocument=) -VOID XMLDocument - -## initialize(objnil) [](#method-i-initialize) - -**@return** [Microsoft_XMLDSO_1_0] a new instance of Microsoft_XMLDSO_1_0 - -## method_missing(cmd, *arg) [](#method-i-method_missing) - -## readyState() [](#method-i-readyState) -I4 readyState - diff --git a/example/ruby/Microsoft_XMLHTTP_1.md b/example/ruby/Microsoft_XMLHTTP_1.md deleted file mode 100644 index 345f29c..0000000 --- a/example/ruby/Microsoft_XMLHTTP_1.md +++ /dev/null @@ -1,81 +0,0 @@ -# Class: Microsoft_XMLHTTP_1 -**Inherits:** Object - -**Includes:** WIN32OLE::VARIANT - - -XML HTTP Request class. - - -# Attributes -## clsid[RW] [](#attribute-i-clsid) -Returns the value of attribute clsid. - -## dispatch[RW] [](#attribute-i-dispatch) -Returns the value of attribute dispatch. - -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - -## progid[RW] [](#attribute-i-progid) -Returns the value of attribute progid. - - -#Instance Methods -## abort() [](#method-i-abort) -VOID abort Abort HTTP request - -## getAllResponseHeaders() [](#method-i-getAllResponseHeaders) -BSTR getAllResponseHeaders Get all HTTP response headers - -## getResponseHeader(arg0) [](#method-i-getResponseHeader) -BSTR getResponseHeader Get HTTP response header - BSTR arg0 --- bstrHeader [IN] - -## initialize(objnil) [](#method-i-initialize) - -**@return** [Microsoft_XMLHTTP_1] a new instance of Microsoft_XMLHTTP_1 - -## method_missing(cmd, *arg) [](#method-i-method_missing) - -## onreadystatechange=(arg0) [](#method-i-onreadystatechange=) -VOID onreadystatechange Register a complete event handler - -## open(arg0, arg1, arg2nil, arg3nil, arg4nil) [](#method-i-open) -VOID open Open HTTP connection - BSTR arg0 --- bstrMethod [IN] - BSTR arg1 --- bstrUrl [IN] - VARIANT arg2 --- varAsync [IN] - VARIANT arg3 --- bstrUser [IN] - VARIANT arg4 --- bstrPassword [IN] - -## readyState() [](#method-i-readyState) -I4 readyState Get ready state - -## responseBody() [](#method-i-responseBody) -VARIANT responseBody Get response body - -## responseStream() [](#method-i-responseStream) -VARIANT responseStream Get response body - -## responseText() [](#method-i-responseText) -BSTR responseText Get response body - -## responseXML() [](#method-i-responseXML) -DISPATCH responseXML Get response body - -## send(arg0nil) [](#method-i-send) -VOID send Send HTTP request - VARIANT arg0 --- varBody [IN] - -## setRequestHeader(arg0, arg1) [](#method-i-setRequestHeader) -VOID setRequestHeader Add HTTP request header - BSTR arg0 --- bstrHeader [IN] - BSTR arg1 --- bstrValue [IN] - -## status() [](#method-i-status) -I4 status Get HTTP status code - -## statusText() [](#method-i-statusText) -BSTR statusText Get HTTP status text - diff --git a/example/ruby/MkSpec.md b/example/ruby/MkSpec.md deleted file mode 100644 index 52bbc2f..0000000 --- a/example/ruby/MkSpec.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: MkSpec -**Inherits:** Object - - - - -# Class Methods -## main() [](#method-c-main) -# Attributes -## config[RW] [](#attribute-i-config) -Returns the value of attribute config. - - -#Instance Methods -## create_directory(mod) [](#method-i-create_directory) - -## create_file(dir, mod, meth, name) [](#method-i-create_file) - -## initialize() [](#method-i-initialize) - -**@return** [MkSpec] a new instance of MkSpec - -## options(argvARGV) [](#method-i-options) - -## run() [](#method-i-run) - -## write_requires(dir, file) [](#method-i-write_requires) - -## write_spec(file, meth, exists) [](#method-i-write_spec) - -## write_version(f) [](#method-i-write_version) - diff --git a/example/ruby/Mock.md b/example/ruby/Mock.md deleted file mode 100644 index 2d668a0..0000000 --- a/example/ruby/Mock.md +++ /dev/null @@ -1,26 +0,0 @@ -# Module: Mock - - - - -# Class Methods -## cleanup() [](#method-c-cleanup) -## clear_replaced(key ) [](#method-c-clear_replaced) -## inspect_args(args ) [](#method-c-inspect_args) -## install_method(obj , sym , type nil) [](#method-c-install_method) -## mock_respond_to?(obj , sym , include_private false) [](#method-c-mock_respond_to?) -**@return** [Boolean] - -## mocks() [](#method-c-mocks) -## name_or_inspect(obj ) [](#method-c-name_or_inspect) -## objects() [](#method-c-objects) -## replaced?(key ) [](#method-c-replaced?) -**@return** [Boolean] - -## replaced_key(obj , sym ) [](#method-c-replaced_key) -## replaced_name(key ) [](#method-c-replaced_name) -## reset() [](#method-c-reset) -## stubs() [](#method-c-stubs) -## verify_call(obj , sym , *args , &block ) [](#method-c-verify_call) -## verify_count() [](#method-c-verify_count) - diff --git a/example/ruby/MockAndRaiseError.md b/example/ruby/MockAndRaiseError.md deleted file mode 100644 index b548563..0000000 --- a/example/ruby/MockAndRaiseError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: MockAndRaiseError -**Inherits:** Exception - - - - - diff --git a/example/ruby/MockIntObject.md b/example/ruby/MockIntObject.md deleted file mode 100644 index 353d982..0000000 --- a/example/ruby/MockIntObject.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: MockIntObject -**Inherits:** Object - - - - -# Attributes -## calls[RW] [](#attribute-i-calls) -Returns the value of attribute calls. - - -#Instance Methods -## count() [](#method-i-count) - -## initialize(val) [](#method-i-initialize) - -**@return** [MockIntObject] a new instance of MockIntObject - -## to_int() [](#method-i-to_int) - diff --git a/example/ruby/MockObject.md b/example/ruby/MockObject.md deleted file mode 100644 index f7f2749..0000000 --- a/example/ruby/MockObject.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: MockObject -**Inherits:** Object - - - - - -#Instance Methods -## initialize(name, options{}) [](#method-i-initialize) - -**@return** [MockObject] a new instance of MockObject - diff --git a/example/ruby/MockProxy.md b/example/ruby/MockProxy.md deleted file mode 100644 index 548452b..0000000 --- a/example/ruby/MockProxy.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: MockProxy -**Inherits:** Object - - - - -# Attributes -## raising[RW] [](#attribute-i-raising) -Returns the value of attribute raising. - -## yielding[RW] [](#attribute-i-yielding) -Returns the value of attribute yielding. - - -#Instance Methods -## and_raise(exception) [](#method-i-and_raise) - -## and_return(*args) [](#method-i-and_return) - -## and_yield(*args) [](#method-i-and_yield) - -## any_number_of_times() [](#method-i-any_number_of_times) - -## arguments() [](#method-i-arguments) - -## at_least(n) [](#method-i-at_least) - -## at_most(n) [](#method-i-at_most) - -## called() [](#method-i-called) - -## calls() [](#method-i-calls) - -## count() [](#method-i-count) - -## exactly(n) [](#method-i-exactly) - -## initialize(typenil) [](#method-i-initialize) - -**@return** [MockProxy] a new instance of MockProxy - -## mock?() [](#method-i-mock?) - -**@return** [Boolean] - -## once() [](#method-i-once) - -## raising?() [](#method-i-raising?) - -**@return** [Boolean] - -## returning() [](#method-i-returning) - -## stub?() [](#method-i-stub?) - -**@return** [Boolean] - -## times() [](#method-i-times) - -## twice() [](#method-i-twice) - -## with(*args) [](#method-i-with) - -**@raise** [ArgumentError] - -## yielding?() [](#method-i-yielding?) - -**@return** [Boolean] - diff --git a/example/ruby/Module.md b/example/ruby/Module.md deleted file mode 100644 index 35aa57f..0000000 --- a/example/ruby/Module.md +++ /dev/null @@ -1,1058 +0,0 @@ -# Class: Module -**Inherits:** Object - -**Includes:** MSpecMatchers, SingletonMethodsSpecs::Prepended - - -Expectations are sometimes used in a module body - - -# Class Methods -## constants(*args ) [](#method-c-constants) -In the first form, returns an array of the names of all constants accessible -from the point of call. This list includes the names of all modules and -classes defined in the global scope. - - Module.constants.first(4) - # => [:ARGF, :ARGV, :ArgumentError, :Array] - - Module.constants.include?(:SEEK_SET) # => false - - class IO - Module.constants.include?(:SEEK_SET) # => true - end - -The second form calls the instance method `constants`. -**@overload** [] - -**@overload** [] - -## nesting() [](#method-c-nesting) -Returns the list of `Modules` nested at the point of call. - - module M1 - module M2 - $a = Module.nesting - end - end - $a #=> [M1::M2, M1] - $a[0].name #=> "M1::M2" -**@overload** [] - -## used_modules() [](#method-c-used_modules) -Returns an array of all modules used in the current scope. The ordering of -modules in the resulting array is not defined. - - module A - refine Object do - end - end - - module B - refine Object do - end - end - - using A - using B - p Module.used_modules - -*produces:* - - [B, A] -**@overload** [] - -## used_refinements() [](#method-c-used_refinements) -Returns an array of all modules used in the current scope. The ordering of -modules in the resulting array is not defined. - - module A - refine Object do - end - end - - module B - refine Object do - end - end - - using A - using B - p Module.used_refinements - -*produces:* - - [#, #] -**@overload** [] - - -#Instance Methods -## <(arg) [](#method-i-<) -Returns true if *mod* is a subclass of *other*. Returns `false` if *mod* is -the same as *other* or *mod* is an ancestor of *other*. Returns `nil` if -there's no relationship between the two. (Think of the relationship in terms -of the class definition: "class A < B" implies "A < B".) - -**@overload** [] - -## <=(arg) [](#method-i-<=) -Returns true if *mod* is a subclass of *other* or is the same as *other*. -Returns `nil` if there's no relationship between the two. (Think of the -relationship in terms of the class definition: "class A < B" implies "A < B".) - -**@overload** [] - -## <=>(arg) [](#method-i-<=>) -Comparison---Returns -1, 0, +1 or nil depending on whether `module` includes -`other_module`, they are the same, or if `module` is included by -`other_module`. - -Returns `nil` if `module` has no relationship with `other_module`, if -`other_module` is not a module, or if the two values are incomparable. - -**@overload** [] - -## ==(obj2) [](#method-i-==) -Equality --- At the Object level, #== returns `true` only if `obj` and `other` -are the same object. Typically, this method is overridden in descendant -classes to provide class-specific meaning. - -Unlike #==, the #equal? method should never be overridden by subclasses as it -is used to determine object identity (that is, `a.equal?(b)` if and only if -`a` is the same object as `b`): - - obj = "a" - other = obj.dup - - obj == other #=> true - obj.equal? other #=> false - obj.equal? obj #=> true - -The #eql? method returns `true` if `obj` and `other` refer to the same hash -key. This is used by Hash to test members for equality. For any pair of -objects where #eql? returns `true`, the #hash value of both objects must be -equal. So any subclass that overrides #eql? should also override #hash -appropriately. - -For objects of class Object, #eql? is synonymous with #==. Subclasses -normally continue this tradition by aliasing #eql? to their overridden #== -method, but there are exceptions. Numeric types, for example, perform type -conversion across #==, but not across #eql?, so: - - 1 == 1.0 #=> true - 1.eql? 1.0 #=> false - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## ===(arg) [](#method-i-===) -Case Equality---Returns `true` if *obj* is an instance of *mod* or an instance -of one of *mod*'s descendants. Of limited use for modules, but can be used in -`case` statements to classify objects by class. - -**@overload** [] - -## >(arg) [](#method-i->) -Returns true if *mod* is an ancestor of *other*. Returns `false` if *mod* is -the same as *other* or *mod* is a descendant of *other*. Returns `nil` if -there's no relationship between the two. (Think of the relationship in terms -of the class definition: "class A < B" implies "B > A".) - -**@overload** [] - -## >=(arg) [](#method-i->=) -Returns true if *mod* is an ancestor of *other*, or the two modules are the -same. Returns `nil` if there's no relationship between the two. (Think of the -relationship in terms of the class definition: "class A < B" implies "B > A".) - -**@overload** [] - -## alias_method(newname, oldname) [](#method-i-alias_method) -Makes *new_name* a new copy of the method *old_name*. This can be used to -retain access to methods that are overridden. - - module Mod - alias_method :orig_exit, :exit #=> :orig_exit - def exit(code=0) - puts "Exiting with code #{code}" - orig_exit(code) - end - end - include Mod - exit(99) - -*produces:* - - Exiting with code 99 - -**@overload** [] - -## ancestors() [](#method-i-ancestors) -Returns a list of modules included/prepended in *mod* (including *mod* -itself). - - module Mod - include Math - include Comparable - prepend Enumerable - end - - Mod.ancestors #=> [Enumerable, Mod, Comparable, Math] - Math.ancestors #=> [Math] - Enumerable.ancestors #=> [Enumerable] - -**@overload** [] - -## attr(*args) [](#method-i-attr) -The first form is equivalent to #attr_reader. The second form is equivalent to -`attr_accessor(name)` but deprecated. The last form is equivalent to -`attr_reader(name)` but deprecated. Returns an array of defined method names -as symbols. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## attr_accessor(*args) [](#method-i-attr_accessor) -Defines a named attribute for this module, where the name is -*symbol.*`id2name`, creating an instance variable (`@name`) and a -corresponding access method to read it. Also creates a method called `name=` -to set the attribute. String arguments are converted to symbols. Returns an -array of defined method names as symbols. - - module Mod - attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=] - end - Mod.instance_methods.sort #=> [:one, :one=, :two, :two=] - -**@overload** [] - -**@overload** [] - -## attr_reader(*args) [](#method-i-attr_reader) -Creates instance variables and corresponding methods that return the value of -each instance variable. Equivalent to calling ```attr`*:name*'' on each name -in turn. String arguments are converted to symbols. Returns an array of -defined method names as symbols. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## attr_writer(*args) [](#method-i-attr_writer) -Creates an accessor method to allow assignment to the attribute -*symbol*`.id2name`. String arguments are converted to symbols. Returns an -array of defined method names as symbols. - -**@overload** [] - -**@overload** [] - -## autoload(sym, file) [](#method-i-autoload) -Registers *filename* to be loaded (using Kernel::require) the first time that -*const* (which may be a String or a symbol) is accessed in the namespace of -*mod*. - - module A - end - A.autoload(:B, "b") - A::B.doit # autoloads "b" - -If *const* in *mod* is defined as autoload, the file name to be loaded is -replaced with *filename*. If *const* is defined but not as autoload, does -nothing. - -**@overload** [] - -## autoload?(*args) [](#method-i-autoload?) -Returns *filename* to be loaded if *name* is registered as `autoload` in the -namespace of *mod* or one of its ancestors. - - module A - end - A.autoload(:B, "b") - A.autoload?(:B) #=> "b" - -If `inherit` is false, the lookup only checks the autoloads in the receiver: - - class A - autoload :CONST, "const.rb" - end - - class B < A - end - - B.autoload?(:CONST) #=> "const.rb", found in A (ancestor) - B.autoload?(:CONST, false) #=> nil, not found in B itself - -**@overload** [] - -## class_eval(*args) [](#method-i-class_eval) -Evaluates the string or block in the context of *mod*, except that when a -block is given, constant/class variable lookup is not affected. This can be -used to add methods to a class. `module_eval` returns the result of evaluating -its argument. The optional *filename* and *lineno* parameters set the text for -error messages. - - class Thing - end - a = %q{def hello() "Hello there!" end} - Thing.module_eval(a) - puts Thing.new.hello() - Thing.module_eval("invalid code", "dummy", 123) - -*produces:* - - Hello there! - dummy:123:in `module_eval': undefined local variable - or method `code' for Thing:Class - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## class_exec(*args) [](#method-i-class_exec) -Evaluates the given block in the context of the class/module. The method -defined in the block will belong to the receiver. Any arguments passed to the -method will be passed to the block. This can be used if the block needs to -access instance variables. - - class Thing - end - Thing.class_exec{ - def hello() "Hello there!" end - } - puts Thing.new.hello() - -*produces:* - - Hello there! - -**@overload** [] - -**@overload** [] - -## class_variable_defined?(iv) [](#method-i-class_variable_defined?) -Returns `true` if the given class variable is defined in *obj*. String -arguments are converted to symbols. - - class Fred - @@foo = 99 - end - Fred.class_variable_defined?(:@@foo) #=> true - Fred.class_variable_defined?(:@@bar) #=> false - -**@overload** [] - -**@overload** [] - -## class_variable_get(iv) [](#method-i-class_variable_get) -Returns the value of the given class variable (or throws a NameError -exception). The `@@` part of the variable name should be included for regular -class variables. String arguments are converted to symbols. - - class Fred - @@foo = 99 - end - Fred.class_variable_get(:@@foo) #=> 99 - -**@overload** [] - -**@overload** [] - -## class_variable_set(iv, val) [](#method-i-class_variable_set) -Sets the class variable named by *symbol* to the given object. If the class -variable name is passed as a string, that string is converted to a symbol. - - class Fred - @@foo = 99 - def foo - @@foo - end - end - Fred.class_variable_set(:@@foo, 101) #=> 101 - Fred.new.foo #=> 101 - -**@overload** [] - -**@overload** [] - -## class_variables() [](#method-i-class_variables) - -## const_defined?(*args) [](#method-i-const_defined?) -Says whether *mod* or its ancestors have a constant with the given name: - - Float.const_defined?(:EPSILON) #=> true, found in Float itself - Float.const_defined?("String") #=> true, found in Object (ancestor) - BasicObject.const_defined?(:Hash) #=> false - -If *mod* is a `Module`, additionally `Object` and its ancestors are checked: - - Math.const_defined?(:String) #=> true, found in Object - -In each of the checked classes or modules, if the constant is not present but -there is an autoload for it, `true` is returned directly without autoloading: - - module Admin - autoload :User, 'admin/user' - end - Admin.const_defined?(:User) #=> true - -If the constant is not found the callback `const_missing` is **not** called -and the method returns `false`. - -If `inherit` is false, the lookup only checks the constants in the receiver: - - IO.const_defined?(:SYNC) #=> true, found in File::Constants (ancestor) - IO.const_defined?(:SYNC, false) #=> false, not found in IO itself - -In this case, the same logic for autoloading applies. - -If the argument is not a valid constant name a `NameError` is raised with the -message "wrong constant name *name*": - - Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar - -**@overload** [] - -**@overload** [] - -## const_get(*args) [](#method-i-const_get) -Checks for a constant with the given name in *mod*. If `inherit` is set, the -lookup will also search the ancestors (and `Object` if *mod* is a `Module`). - -The value of the constant is returned if a definition is found, otherwise a -`NameError` is raised. - - Math.const_get(:PI) #=> 3.14159265358979 - -This method will recursively look up constant names if a namespaced class name -is provided. For example: - - module Foo; class Bar; end end - Object.const_get 'Foo::Bar' - -The `inherit` flag is respected on each lookup. For example: - - module Foo - class Bar - VAL = 10 - end - - class Baz < Bar; end - end - - Object.const_get 'Foo::Baz::VAL' # => 10 - Object.const_get 'Foo::Baz::VAL', false # => NameError - -If the argument is not a valid constant name a `NameError` will be raised with -a warning "wrong constant name". - -Object.const_get 'foobar' #=> NameError: wrong constant name foobar - -**@overload** [] - -**@overload** [] - -## const_missing() [](#method-i-const_missing) - -## const_set(name, value) [](#method-i-const_set) -Sets the named constant to the given object, returning that object. Creates a -new constant if no constant with the given name previously existed. - - Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714 - Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968 - -If `sym` or `str` is not a valid constant name a `NameError` will be raised -with a warning "wrong constant name". - -Object.const_set('foobar', 42) #=> NameError: wrong constant name foobar - -**@overload** [] - -**@overload** [] - -## const_source_location(*args) [](#method-i-const_source_location) -Returns the Ruby source filename and line number containing the definition of -the constant specified. If the named constant is not found, `nil` is returned. -If the constant is found, but its source location can not be extracted -(constant is defined in C code), empty array is returned. - -*inherit* specifies whether to lookup in `mod.ancestors` (`true` by default). - - # test.rb: - class A # line 1 - C1 = 1 - C2 = 2 - end - - module M # line 6 - C3 = 3 - end - - class B < A # line 10 - include M - C4 = 4 - end - - class A # continuation of A definition - C2 = 8 # constant redefinition; warned yet allowed - end - - p B.const_source_location('C4') # => ["test.rb", 12] - p B.const_source_location('C3') # => ["test.rb", 7] - p B.const_source_location('C1') # => ["test.rb", 2] - - p B.const_source_location('C3', false) # => nil -- don't lookup in ancestors - - p A.const_source_location('C2') # => ["test.rb", 16] -- actual (last) definition place - - p Object.const_source_location('B') # => ["test.rb", 10] -- top-level constant could be looked through Object - p Object.const_source_location('A') # => ["test.rb", 1] -- class reopening is NOT considered new definition - - p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors - p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules - - p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported - p Object.const_source_location('String') # => [] -- constant is defined in C code - -**@overload** [] - -**@overload** [] - -## constants() [](#method-i-constants) - -## define_method(*args) [](#method-i-define_method) -Defines an instance method in the receiver. The *method* parameter can be a -`Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, it -is used as the method body. If a block or the *method* parameter has -parameters, they're used as method parameters. This block is evaluated using -#instance_eval. - - class A - def fred - puts "In Fred" - end - def create_method(name, &block) - self.class.define_method(name, &block) - end - define_method(:wilma) { puts "Charge it!" } - define_method(:flint) {|name| puts "I'm #{name}!"} - end - class B < A - define_method(:barney, instance_method(:fred)) - end - a = B.new - a.barney - a.wilma - a.flint('Dino') - a.create_method(:betty) { p self } - a.betty - -*produces:* - - In Fred - Charge it! - I'm Dino! - # - -**@overload** [] - -**@overload** [] - -## deprecate_constant() [](#method-i-deprecate_constant) - -## freeze() [](#method-i-freeze) -Prevents further modifications to *mod*. - -This method returns self. - -**@overload** [] - -## include(*args) [](#method-i-include) -Invokes Module.append_features on each parameter in reverse order. - -**@overload** [] - -## include?(mod2) [](#method-i-include?) -Returns `true` if *module* is included or prepended in *mod* or one of *mod*'s -ancestors. - - module A - end - class B - include A - end - class C < B - end - B.include?(A) #=> true - C.include?(A) #=> true - A.include?(A) #=> false - -**@overload** [] - -## included_modules() [](#method-i-included_modules) -Returns the list of modules included or prepended in *mod* or one of *mod*'s -ancestors. - - module Sub - end - - module Mixin - prepend Sub - end - - module Outer - include Mixin - end - - Mixin.included_modules #=> [Sub] - Outer.included_modules #=> [Sub, Mixin] - -**@overload** [] - -## initialize() [](#method-i-initialize) -Creates a new anonymous module. If a block is given, it is passed the module -object, and the block is evaluated in the context of this module like -#module_eval. - - fred = Module.new do - def meth1 - "hello" - end - def meth2 - "bye" - end - end - a = "my string" - a.extend(fred) #=> "my string" - a.meth1 #=> "hello" - a.meth2 #=> "bye" - -Assign the module to a constant (name starting uppercase) if you want to treat -it like a regular module. - -**@overload** [] - -**@overload** [] - -## initialize_clone(*args) [](#method-i-initialize_clone) -:nodoc: - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## instance_method(vid) [](#method-i-instance_method) -Returns an `UnboundMethod` representing the given instance method in *mod*. - - class Interpreter - def do_a() print "there, "; end - def do_d() print "Hello "; end - def do_e() print "!\n"; end - def do_v() print "Dave"; end - Dispatcher = { - "a" => instance_method(:do_a), - "d" => instance_method(:do_d), - "e" => instance_method(:do_e), - "v" => instance_method(:do_v) - } - def interpret(string) - string.each_char {|b| Dispatcher[b].bind(self).call } - end - end - - interpreter = Interpreter.new - interpreter.interpret('dave') - -*produces:* - - Hello there, Dave! - -**@overload** [] - -## instance_methods(*args) [](#method-i-instance_methods) -Returns an array containing the names of the public and protected instance -methods in the receiver. For a module, these are the public and protected -methods; for a class, they are the instance (not singleton) methods. If the -optional parameter is `false`, the methods of any ancestors are not included. - - module A - def method1() end - end - class B - include A - def method2() end - end - class C < B - def method3() end - end - - A.instance_methods(false) #=> [:method1] - B.instance_methods(false) #=> [:method2] - B.instance_methods(true).include?(:method1) #=> true - C.instance_methods(false) #=> [:method3] - C.instance_methods.include?(:method2) #=> true - -Note that method visibility changes in the current class, as well as aliases, -are considered as methods of the current class by this method: - - class C < B - alias method4 method2 - protected :method2 - end - C.instance_methods(false).sort #=> [:method2, :method3, :method4] - -**@overload** [] - -## method_defined?(*args) [](#method-i-method_defined?) -Returns `true` if the named method is defined by *mod*. If *inherit* is set, -the lookup will also search *mod*'s ancestors. Public and protected methods -are matched. String arguments are converted to symbols. - - module A - def method1() end - def protected_method1() end - protected :protected_method1 - end - class B - def method2() end - def private_method2() end - private :private_method2 - end - class C < B - include A - def method3() end - end - - A.method_defined? :method1 #=> true - C.method_defined? "method1" #=> true - C.method_defined? "method2" #=> true - C.method_defined? "method2", true #=> true - C.method_defined? "method2", false #=> false - C.method_defined? "method3" #=> true - C.method_defined? "protected_method1" #=> true - C.method_defined? "method4" #=> false - C.method_defined? "private_method2" #=> false - -**@overload** [] - -**@overload** [] - -## module_eval(*args) [](#method-i-module_eval) -Evaluates the string or block in the context of *mod*, except that when a -block is given, constant/class variable lookup is not affected. This can be -used to add methods to a class. `module_eval` returns the result of evaluating -its argument. The optional *filename* and *lineno* parameters set the text for -error messages. - - class Thing - end - a = %q{def hello() "Hello there!" end} - Thing.module_eval(a) - puts Thing.new.hello() - Thing.module_eval("invalid code", "dummy", 123) - -*produces:* - - Hello there! - dummy:123:in `module_eval': undefined local variable - or method `code' for Thing:Class - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## module_exec(*args) [](#method-i-module_exec) -Evaluates the given block in the context of the class/module. The method -defined in the block will belong to the receiver. Any arguments passed to the -method will be passed to the block. This can be used if the block needs to -access instance variables. - - class Thing - end - Thing.class_exec{ - def hello() "Hello there!" end - } - puts Thing.new.hello() - -*produces:* - - Hello there! - -**@overload** [] - -**@overload** [] - -## mspec_test_kernel_singleton_methods() [](#method-i-mspec_test_kernel_singleton_methods) - -## name() [](#method-i-name) - -## prepend(*args) [](#method-i-prepend) -Invokes Module.prepend_features on each parameter in reverse order. - -**@overload** [] - -## private_class_method(*args) [](#method-i-private_class_method) -Makes existing class methods private. Often used to hide the default -constructor `new`. - -String arguments are converted to symbols. An Array of Symbols and/or Strings -is also accepted. - - class SimpleSingleton # Not thread safe - private_class_method :new - def SimpleSingleton.create(*args, &block) - @me = new(*args, &block) if ! @me - @me - end - end - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## private_constant() [](#method-i-private_constant) - -## private_instance_methods(*args) [](#method-i-private_instance_methods) -Returns a list of the private instance methods defined in *mod*. If the -optional parameter is `false`, the methods of any ancestors are not included. - - module Mod - def method1() end - private :method1 - def method2() end - end - Mod.instance_methods #=> [:method2] - Mod.private_instance_methods #=> [:method1] - -**@overload** [] - -## private_method_defined?(*args) [](#method-i-private_method_defined?) -Returns `true` if the named private method is defined by *mod*. If *inherit* -is set, the lookup will also search *mod*'s ancestors. String arguments are -converted to symbols. - - module A - def method1() end - end - class B - private - def method2() end - end - class C < B - include A - def method3() end - end - - A.method_defined? :method1 #=> true - C.private_method_defined? "method1" #=> false - C.private_method_defined? "method2" #=> true - C.private_method_defined? "method2", true #=> true - C.private_method_defined? "method2", false #=> false - C.method_defined? "method2" #=> false - -**@overload** [] - -**@overload** [] - -## protected_instance_methods(*args) [](#method-i-protected_instance_methods) -Returns a list of the protected instance methods defined in *mod*. If the -optional parameter is `false`, the methods of any ancestors are not included. - -**@overload** [] - -## protected_method_defined?(*args) [](#method-i-protected_method_defined?) -Returns `true` if the named protected method is defined *mod*. If *inherit* -is set, the lookup will also search *mod*'s ancestors. String arguments are -converted to symbols. - - module A - def method1() end - end - class B - protected - def method2() end - end - class C < B - include A - def method3() end - end - - A.method_defined? :method1 #=> true - C.protected_method_defined? "method1" #=> false - C.protected_method_defined? "method2" #=> true - C.protected_method_defined? "method2", true #=> true - C.protected_method_defined? "method2", false #=> false - C.method_defined? "method2" #=> true - -**@overload** [] - -**@overload** [] - -## public_class_method(*args) [](#method-i-public_class_method) -Makes a list of existing class methods public. - -String arguments are converted to symbols. An Array of Symbols and/or Strings -is also accepted. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## public_constant() [](#method-i-public_constant) - -## public_instance_method(vid) [](#method-i-public_instance_method) -Similar to *instance_method*, searches public method only. - -**@overload** [] - -## public_instance_methods(*args) [](#method-i-public_instance_methods) -Returns a list of the public instance methods defined in *mod*. If the -optional parameter is `false`, the methods of any ancestors are not included. - -**@overload** [] - -## public_method_defined?(*args) [](#method-i-public_method_defined?) -Returns `true` if the named public method is defined by *mod*. If *inherit* -is set, the lookup will also search *mod*'s ancestors. String arguments are -converted to symbols. - - module A - def method1() end - end - class B - protected - def method2() end - end - class C < B - include A - def method3() end - end - - A.method_defined? :method1 #=> true - C.public_method_defined? "method1" #=> true - C.public_method_defined? "method1", true #=> true - C.public_method_defined? "method1", false #=> true - C.public_method_defined? "method2" #=> false - C.method_defined? "method2" #=> true - -**@overload** [] - -**@overload** [] - -## refinements() [](#method-i-refinements) -Returns an array of `Refinement` defined within the receiver. - - module A - refine Integer do - end - - refine String do - end - end - - p A.refinements - -*produces:* - - [#, #] - -**@overload** [] - -## remove_class_variable() [](#method-i-remove_class_variable) - -## remove_method(*args) [](#method-i-remove_method) -Removes the method identified by *symbol* from the current class. For an -example, see Module#undef_method. String arguments are converted to symbols. - -**@overload** [] - -**@overload** [] - -## set_temporary_name() [](#method-i-set_temporary_name) - -## singleton_class?() [](#method-i-singleton_class?) -Returns `true` if *mod* is a singleton class or `false` if it is an ordinary -class or module. - - class C - end - C.singleton_class? #=> false - C.singleton_class.singleton_class? #=> true - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns a string representing this module or class. For basic classes and -modules, this is the name. For singletons, we show information on the thing -we're attached to as well. - -**@overload** [] - -## undef_method(*args) [](#method-i-undef_method) -Prevents the current class from responding to calls to the named method. -Contrast this with `remove_method`, which deletes the method from the -particular class; Ruby will still search superclasses and mixed-in modules for -a possible receiver. String arguments are converted to symbols. - - class Parent - def hello - puts "In parent" - end - end - class Child < Parent - def hello - puts "In child" - end - end - - c = Child.new - c.hello - - class Child - remove_method :hello # remove from child, still in parent - end - c.hello - - class Child - undef_method :hello # prevent any calls to 'hello' - end - c.hello - -*produces:* - - In child - In parent - prog.rb:23: undefined method 'hello' for # (NoMethodError) - -**@overload** [] - -**@overload** [] - -## undefined_instance_methods() [](#method-i-undefined_instance_methods) -Returns a list of the undefined instance methods defined in *mod*. The -undefined methods of any ancestors are not included. - -**@overload** [] - diff --git a/example/ruby/ModuleSpecs.md b/example/ruby/ModuleSpecs.md deleted file mode 100644 index 4ac834b..0000000 --- a/example/ruby/ModuleSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs - - - - -# Class Methods -## build_refined_class(for_super: false) [](#method-c-build_refined_class) -## without_test_modules(modules ) [](#method-c-without_test_modules) - diff --git a/example/ruby/ModuleSpecs/A.md b/example/ruby/ModuleSpecs/A.md deleted file mode 100644 index 7b6194d..0000000 --- a/example/ruby/ModuleSpecs/A.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: ModuleSpecs::A - - - - -# Class Methods -## cma() [](#method-c-cma) - -#Instance Methods -## ma() [](#method-i-ma) - diff --git a/example/ruby/ModuleSpecs/AddConstant.md b/example/ruby/ModuleSpecs/AddConstant.md deleted file mode 100644 index be945d9..0000000 --- a/example/ruby/ModuleSpecs/AddConstant.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::AddConstant - - - - - diff --git a/example/ruby/ModuleSpecs/Alias.md b/example/ruby/ModuleSpecs/Alias.md deleted file mode 100644 index 20631a4..0000000 --- a/example/ruby/ModuleSpecs/Alias.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::Alias - - - - - -#Instance Methods -## report() [](#method-i-report) - diff --git a/example/ruby/ModuleSpecs/Aliasing.md b/example/ruby/ModuleSpecs/Aliasing.md deleted file mode 100644 index ce9644a..0000000 --- a/example/ruby/ModuleSpecs/Aliasing.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ModuleSpecs::Aliasing -**Inherits:** Object - - - - -# Class Methods -## make_alias(*a ) [](#method-c-make_alias) - -#Instance Methods -## public_one() [](#method-i-public_one) - -## public_two(n) [](#method-i-public_two) - diff --git a/example/ruby/ModuleSpecs/AliasingSubclass.md b/example/ruby/ModuleSpecs/AliasingSubclass.md deleted file mode 100644 index 52c648d..0000000 --- a/example/ruby/ModuleSpecs/AliasingSubclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::AliasingSubclass -**Inherits:** ModuleSpecs::Aliasing - - - - - diff --git a/example/ruby/ModuleSpecs/AliasingSuper.md b/example/ruby/ModuleSpecs/AliasingSuper.md deleted file mode 100644 index c1d4ca7..0000000 --- a/example/ruby/ModuleSpecs/AliasingSuper.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::AliasingSuper - - - - - diff --git a/example/ruby/ModuleSpecs/AliasingSuper/Child.md b/example/ruby/ModuleSpecs/AliasingSuper/Child.md deleted file mode 100644 index 428b83c..0000000 --- a/example/ruby/ModuleSpecs/AliasingSuper/Child.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: ModuleSpecs::AliasingSuper::Child - -**Includes:** ModuleSpecs::AliasingSuper::Parent - - - - - -#Instance Methods -## super_call(arg) [](#method-i-super_call) - diff --git a/example/ruby/ModuleSpecs/AliasingSuper/Parent.md b/example/ruby/ModuleSpecs/AliasingSuper/Parent.md deleted file mode 100644 index 596e923..0000000 --- a/example/ruby/ModuleSpecs/AliasingSuper/Parent.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::AliasingSuper::Parent - - - - - -#Instance Methods -## super_call(arg) [](#method-i-super_call) - diff --git a/example/ruby/ModuleSpecs/AliasingSuper/RedefineAfterAlias.md b/example/ruby/ModuleSpecs/AliasingSuper/RedefineAfterAlias.md deleted file mode 100644 index 53010f1..0000000 --- a/example/ruby/ModuleSpecs/AliasingSuper/RedefineAfterAlias.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ModuleSpecs::AliasingSuper::RedefineAfterAlias -**Inherits:** Object - -**Includes:** ModuleSpecs::AliasingSuper::Parent - - - - - -#Instance Methods -## alias_super_call() [](#method-i-alias_super_call) - -## super_call(arg) [](#method-i-super_call) - diff --git a/example/ruby/ModuleSpecs/AliasingSuper/Target.md b/example/ruby/ModuleSpecs/AliasingSuper/Target.md deleted file mode 100644 index 8896a61..0000000 --- a/example/ruby/ModuleSpecs/AliasingSuper/Target.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::AliasingSuper::Target -**Inherits:** Object - -**Includes:** ModuleSpecs::AliasingSuper::Child - - - - - diff --git a/example/ruby/ModuleSpecs/Allonym.md b/example/ruby/ModuleSpecs/Allonym.md deleted file mode 100644 index 45e1d45..0000000 --- a/example/ruby/ModuleSpecs/Allonym.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ModuleSpecs::Allonym -**Inherits:** Object - -**Includes:** ModuleSpecs::Alias - - - - - -#Instance Methods -## report() [](#method-i-report) - diff --git a/example/ruby/ModuleSpecs/Ancestor.md b/example/ruby/ModuleSpecs/Ancestor.md deleted file mode 100644 index 24ec8ea..0000000 --- a/example/ruby/ModuleSpecs/Ancestor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ModuleSpecs::Ancestor -**Inherits:** Object - - - - - -#Instance Methods -## another_method_to_undef() [](#method-i-another_method_to_undef) - -## method_to_undef() [](#method-i-method_to_undef) - diff --git a/example/ruby/ModuleSpecs/Anonymous.md b/example/ruby/ModuleSpecs/Anonymous.md deleted file mode 100644 index 109b416..0000000 --- a/example/ruby/ModuleSpecs/Anonymous.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Anonymous - - - - - diff --git a/example/ruby/ModuleSpecs/Anonymous/Child.md b/example/ruby/ModuleSpecs/Anonymous/Child.md deleted file mode 100644 index 6a3c4ae..0000000 --- a/example/ruby/ModuleSpecs/Anonymous/Child.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Anonymous::Child - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload.md b/example/ruby/ModuleSpecs/Autoload.md deleted file mode 100644 index 6b0116c..0000000 --- a/example/ruby/ModuleSpecs/Autoload.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::Autoload - - - - -# Class Methods -## use_ex1() [](#method-c-use_ex1) - diff --git a/example/ruby/ModuleSpecs/Autoload/AutoloadDuringRequire.md b/example/ruby/ModuleSpecs/Autoload/AutoloadDuringRequire.md deleted file mode 100644 index c3dbc18..0000000 --- a/example/ruby/ModuleSpecs/Autoload/AutoloadDuringRequire.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::AutoloadDuringRequire -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/AutoloadSelfDuringRequire.md b/example/ruby/ModuleSpecs/Autoload/AutoloadSelfDuringRequire.md deleted file mode 100644 index 7541019..0000000 --- a/example/ruby/ModuleSpecs/Autoload/AutoloadSelfDuringRequire.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::AutoloadSelfDuringRequire -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/Child.md b/example/ruby/ModuleSpecs/Autoload/Child.md deleted file mode 100644 index 2eb9320..0000000 --- a/example/ruby/ModuleSpecs/Autoload/Child.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::Child -**Inherits:** ModuleSpecs::Autoload::Parent - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/DuringAutoload.md b/example/ruby/ModuleSpecs/Autoload/DuringAutoload.md deleted file mode 100644 index 09db504..0000000 --- a/example/ruby/ModuleSpecs/Autoload/DuringAutoload.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::DuringAutoload -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/DuringAutoloadAfterDefine.md b/example/ruby/ModuleSpecs/Autoload/DuringAutoloadAfterDefine.md deleted file mode 100644 index 0ee4fba..0000000 --- a/example/ruby/ModuleSpecs/Autoload/DuringAutoloadAfterDefine.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::DuringAutoloadAfterDefine -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/DynClass.md b/example/ruby/ModuleSpecs/Autoload/DynClass.md deleted file mode 100644 index 31c4a32..0000000 --- a/example/ruby/ModuleSpecs/Autoload/DynClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::DynClass -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/DynClass/C.md b/example/ruby/ModuleSpecs/Autoload/DynClass/C.md deleted file mode 100644 index 89b5bb5..0000000 --- a/example/ruby/ModuleSpecs/Autoload/DynClass/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::Autoload::DynClass::C -**Inherits:** Object - - - - - -#Instance Methods -## loaded() [](#method-i-loaded) - diff --git a/example/ruby/ModuleSpecs/Autoload/DynModule.md b/example/ruby/ModuleSpecs/Autoload/DynModule.md deleted file mode 100644 index 9989f35..0000000 --- a/example/ruby/ModuleSpecs/Autoload/DynModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Autoload::DynModule - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/DynModule/D.md b/example/ruby/ModuleSpecs/Autoload/DynModule/D.md deleted file mode 100644 index eb5b9db..0000000 --- a/example/ruby/ModuleSpecs/Autoload/DynModule/D.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::Autoload::DynModule::D -**Inherits:** Object - - - - - -#Instance Methods -## loaded() [](#method-i-loaded) - diff --git a/example/ruby/ModuleSpecs/Autoload/E.md b/example/ruby/ModuleSpecs/Autoload/E.md deleted file mode 100644 index 6da670e..0000000 --- a/example/ruby/ModuleSpecs/Autoload/E.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::Autoload::E -**Inherits:** Object - - - - - -#Instance Methods -## loaded() [](#method-i-loaded) - diff --git a/example/ruby/ModuleSpecs/Autoload/EX1.md b/example/ruby/ModuleSpecs/Autoload/EX1.md deleted file mode 100644 index 4188391..0000000 --- a/example/ruby/ModuleSpecs/Autoload/EX1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: ModuleSpecs::Autoload::EX1 -**Inherits:** Exception - - - - -# Class Methods -## trample1() [](#method-c-trample1) -## trample2() [](#method-c-trample2) - diff --git a/example/ruby/ModuleSpecs/Autoload/F.md b/example/ruby/ModuleSpecs/Autoload/F.md deleted file mode 100644 index e8ac5c9..0000000 --- a/example/ruby/ModuleSpecs/Autoload/F.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::Autoload::F - - - - -# Class Methods -## loaded() [](#method-c-loaded) - diff --git a/example/ruby/ModuleSpecs/Autoload/Foo.md b/example/ruby/ModuleSpecs/Autoload/Foo.md deleted file mode 100644 index f7fb7d2..0000000 --- a/example/ruby/ModuleSpecs/Autoload/Foo.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Autoload::Foo - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/Foo/Bar.md b/example/ruby/ModuleSpecs/Autoload/Foo/Bar.md deleted file mode 100644 index 4b2157c..0000000 --- a/example/ruby/ModuleSpecs/Autoload/Foo/Bar.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::Foo::Bar -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/Foo/Baz.md b/example/ruby/ModuleSpecs/Autoload/Foo/Baz.md deleted file mode 100644 index 16e1b71..0000000 --- a/example/ruby/ModuleSpecs/Autoload/Foo/Baz.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::Foo::Baz -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/FromThread.md b/example/ruby/ModuleSpecs/Autoload/FromThread.md deleted file mode 100644 index de3cfb4..0000000 --- a/example/ruby/ModuleSpecs/Autoload/FromThread.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Autoload::FromThread - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/FromThread/A.md b/example/ruby/ModuleSpecs/Autoload/FromThread/A.md deleted file mode 100644 index 53a152f..0000000 --- a/example/ruby/ModuleSpecs/Autoload/FromThread/A.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Autoload::FromThread::A - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/FromThread/A/B.md b/example/ruby/ModuleSpecs/Autoload/FromThread/A/B.md deleted file mode 100644 index 1f0d6b3..0000000 --- a/example/ruby/ModuleSpecs/Autoload/FromThread/A/B.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::Autoload::FromThread::A::B -**Inherits:** Object - - - - -# Class Methods -## foo() [](#method-c-foo) - diff --git a/example/ruby/ModuleSpecs/Autoload/FromThread/A/B/C.md b/example/ruby/ModuleSpecs/Autoload/FromThread/A/B/C.md deleted file mode 100644 index f7f5696..0000000 --- a/example/ruby/ModuleSpecs/Autoload/FromThread/A/B/C.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::Autoload::FromThread::A::B::C -**Inherits:** Object - - - - -# Class Methods -## foo() [](#method-c-foo) - diff --git a/example/ruby/ModuleSpecs/Autoload/FromThread/D.md b/example/ruby/ModuleSpecs/Autoload/FromThread/D.md deleted file mode 100644 index da9e032..0000000 --- a/example/ruby/ModuleSpecs/Autoload/FromThread/D.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::FromThread::D -**Inherits:** ModuleSpecs::Autoload::FromThread::A::B - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/G.md b/example/ruby/ModuleSpecs/Autoload/G.md deleted file mode 100644 index a27cfc1..0000000 --- a/example/ruby/ModuleSpecs/Autoload/G.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::Autoload::G -**Inherits:** Object - - - - - -#Instance Methods -## loaded() [](#method-i-loaded) - diff --git a/example/ruby/ModuleSpecs/Autoload/GoodParent.md b/example/ruby/ModuleSpecs/Autoload/GoodParent.md deleted file mode 100644 index 429b646..0000000 --- a/example/ruby/ModuleSpecs/Autoload/GoodParent.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Autoload::GoodParent - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/GoodParent/Nested.md b/example/ruby/ModuleSpecs/Autoload/GoodParent/Nested.md deleted file mode 100644 index af81153..0000000 --- a/example/ruby/ModuleSpecs/Autoload/GoodParent/Nested.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::GoodParent::Nested -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/H.md b/example/ruby/ModuleSpecs/Autoload/H.md deleted file mode 100644 index 9f98e34..0000000 --- a/example/ruby/ModuleSpecs/Autoload/H.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::Autoload::H - - - - - -#Instance Methods -## loaded() [](#method-i-loaded) - diff --git a/example/ruby/ModuleSpecs/Autoload/KHash.md b/example/ruby/ModuleSpecs/Autoload/KHash.md deleted file mode 100644 index fa6841d..0000000 --- a/example/ruby/ModuleSpecs/Autoload/KHash.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::KHash -**Inherits:** Hash - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/LoadPath.md b/example/ruby/ModuleSpecs/Autoload/LoadPath.md deleted file mode 100644 index 981f47b..0000000 --- a/example/ruby/ModuleSpecs/Autoload/LoadPath.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::Autoload::LoadPath - - - - -# Class Methods -## loaded() [](#method-c-loaded) - diff --git a/example/ruby/ModuleSpecs/Autoload/Parent.md b/example/ruby/ModuleSpecs/Autoload/Parent.md deleted file mode 100644 index 18659b8..0000000 --- a/example/ruby/ModuleSpecs/Autoload/Parent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::Parent -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/R.md b/example/ruby/ModuleSpecs/Autoload/R.md deleted file mode 100644 index a2adf0f..0000000 --- a/example/ruby/ModuleSpecs/Autoload/R.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::R -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/RequiredDirectly.md b/example/ruby/ModuleSpecs/Autoload/RequiredDirectly.md deleted file mode 100644 index 6e83da1..0000000 --- a/example/ruby/ModuleSpecs/Autoload/RequiredDirectly.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::RequiredDirectly -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/S.md b/example/ruby/ModuleSpecs/Autoload/S.md deleted file mode 100644 index ca93367..0000000 --- a/example/ruby/ModuleSpecs/Autoload/S.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Autoload::S - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/U.md b/example/ruby/ModuleSpecs/Autoload/U.md deleted file mode 100644 index bbc3c6a..0000000 --- a/example/ruby/ModuleSpecs/Autoload/U.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Autoload::U - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/U/V.md b/example/ruby/ModuleSpecs/Autoload/U/V.md deleted file mode 100644 index 700b2f6..0000000 --- a/example/ruby/ModuleSpecs/Autoload/U/V.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::Autoload::U::V -**Inherits:** Object - - - - -# Class Methods -## get_value() [](#method-c-get_value) - diff --git a/example/ruby/ModuleSpecs/Autoload/XX.md b/example/ruby/ModuleSpecs/Autoload/XX.md deleted file mode 100644 index 39c9005..0000000 --- a/example/ruby/ModuleSpecs/Autoload/XX.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Autoload::XX - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/XX/CS_CONST_AUTOLOAD.md b/example/ruby/ModuleSpecs/Autoload/XX/CS_CONST_AUTOLOAD.md deleted file mode 100644 index 8358855..0000000 --- a/example/ruby/ModuleSpecs/Autoload/XX/CS_CONST_AUTOLOAD.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::XX::CS_CONST_AUTOLOAD -**Inherits:** CS_CONST_AUTOLOAD - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/YY.md b/example/ruby/ModuleSpecs/Autoload/YY.md deleted file mode 100644 index ab1e91f..0000000 --- a/example/ruby/ModuleSpecs/Autoload/YY.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::YY -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Autoload/Z.md b/example/ruby/ModuleSpecs/Autoload/Z.md deleted file mode 100644 index 72a8967..0000000 --- a/example/ruby/ModuleSpecs/Autoload/Z.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Autoload::Z -**Inherits:** ModuleSpecs::Autoload::YY - - - - - diff --git a/example/ruby/ModuleSpecs/B.md b/example/ruby/ModuleSpecs/B.md deleted file mode 100644 index 5c10e72..0000000 --- a/example/ruby/ModuleSpecs/B.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: ModuleSpecs::B - -**Includes:** ModuleSpecs::A - - - - -# Class Methods -## cmb() [](#method-c-cmb) - -#Instance Methods -## ma() [](#method-i-ma) - -## mb() [](#method-i-mb) - diff --git a/example/ruby/ModuleSpecs/Basic.md b/example/ruby/ModuleSpecs/Basic.md deleted file mode 100644 index ca36566..0000000 --- a/example/ruby/ModuleSpecs/Basic.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::Basic - - - - - -#Instance Methods -## public_module() [](#method-i-public_module) - diff --git a/example/ruby/ModuleSpecs/C.md b/example/ruby/ModuleSpecs/C.md deleted file mode 100644 index 5d34100..0000000 --- a/example/ruby/ModuleSpecs/C.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ModuleSpecs::C -**Inherits:** Object - -**Includes:** ModuleSpecs::B - - - - - -#Instance Methods -## ma() [](#method-i-ma) - -## mb() [](#method-i-mb) - diff --git a/example/ruby/ModuleSpecs/CVars.md b/example/ruby/ModuleSpecs/CVars.md deleted file mode 100644 index e9f5af6..0000000 --- a/example/ruby/ModuleSpecs/CVars.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: ModuleSpecs::CVars -**Inherits:** Object - - - - -# Class Methods -## cls() [](#method-c-cls) -## meta() [](#method-c-meta) - -#Instance Methods -## meta() [](#method-i-meta) - diff --git a/example/ruby/ModuleSpecs/CaseCompareOnSingleton.md b/example/ruby/ModuleSpecs/CaseCompareOnSingleton.md deleted file mode 100644 index b1366dc..0000000 --- a/example/ruby/ModuleSpecs/CaseCompareOnSingleton.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::CaseCompareOnSingleton - - - - -# Class Methods -## ===() [](#method-c-===) - diff --git a/example/ruby/ModuleSpecs/Child.md b/example/ruby/ModuleSpecs/Child.md deleted file mode 100644 index 3999fe6..0000000 --- a/example/ruby/ModuleSpecs/Child.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: ModuleSpecs::Child -**Inherits:** ModuleSpecs::Parent - -**Extended by:** ModuleSpecs::Internal - -**Includes:** ModuleSpecs::Super - - - - -# Attributes -## accessor_method[RW] [](#attribute-i-accessor_method) -Returns the value of attribute accessor_method. - - -#Instance Methods -## public_child() [](#method-i-public_child) - -## public_module() [](#method-i-public_module) - -## public_super_module() [](#method-i-public_super_module) - diff --git a/example/ruby/ModuleSpecs/Child2.md b/example/ruby/ModuleSpecs/Child2.md deleted file mode 100644 index ce414bb..0000000 --- a/example/ruby/ModuleSpecs/Child2.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: ModuleSpecs::Child2 -**Inherits:** ModuleSpecs::Parent - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - diff --git a/example/ruby/ModuleSpecs/ChildPrivateMethodMadePublic.md b/example/ruby/ModuleSpecs/ChildPrivateMethodMadePublic.md deleted file mode 100644 index ec36233..0000000 --- a/example/ruby/ModuleSpecs/ChildPrivateMethodMadePublic.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::ChildPrivateMethodMadePublic -**Inherits:** ModuleSpecs::ParentPrivateMethodRedef - - - - - diff --git a/example/ruby/ModuleSpecs/ClassEvalTest.md b/example/ruby/ModuleSpecs/ClassEvalTest.md deleted file mode 100644 index 964cf16..0000000 --- a/example/ruby/ModuleSpecs/ClassEvalTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::ClassEvalTest - - - - -# Class Methods -## get_constant_from_scope() [](#method-c-get_constant_from_scope) -## get_constant_from_scope_with_send(method ) [](#method-c-get_constant_from_scope_with_send) - diff --git a/example/ruby/ModuleSpecs/ClassVars.md b/example/ruby/ModuleSpecs/ClassVars.md deleted file mode 100644 index 8913c1c..0000000 --- a/example/ruby/ModuleSpecs/ClassVars.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::ClassVars - - - - - diff --git a/example/ruby/ModuleSpecs/ClassVars/A.md b/example/ruby/ModuleSpecs/ClassVars/A.md deleted file mode 100644 index 9f25242..0000000 --- a/example/ruby/ModuleSpecs/ClassVars/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::ClassVars::A -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/ClassVars/B.md b/example/ruby/ModuleSpecs/ClassVars/B.md deleted file mode 100644 index b336869..0000000 --- a/example/ruby/ModuleSpecs/ClassVars/B.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::ClassVars::B -**Inherits:** ModuleSpecs::ClassVars::A - -**Includes:** ModuleSpecs::ClassVars::M - - - - - diff --git a/example/ruby/ModuleSpecs/ClassVars/M.md b/example/ruby/ModuleSpecs/ClassVars/M.md deleted file mode 100644 index d862af0..0000000 --- a/example/ruby/ModuleSpecs/ClassVars/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::ClassVars::M - - - - - diff --git a/example/ruby/ModuleSpecs/ClassWithFoo.md b/example/ruby/ModuleSpecs/ClassWithFoo.md deleted file mode 100644 index cb9d3cc..0000000 --- a/example/ruby/ModuleSpecs/ClassWithFoo.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::ClassWithFoo -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/ModuleSpecs/ClassWithSuperFoo.md b/example/ruby/ModuleSpecs/ClassWithSuperFoo.md deleted file mode 100644 index 356a436..0000000 --- a/example/ruby/ModuleSpecs/ClassWithSuperFoo.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::ClassWithSuperFoo -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/ModuleSpecs/ConstAddedSpecs.md b/example/ruby/ModuleSpecs/ConstAddedSpecs.md deleted file mode 100644 index 9e1bdd8..0000000 --- a/example/ruby/ModuleSpecs/ConstAddedSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::ConstAddedSpecs - - - - - diff --git a/example/ruby/ModuleSpecs/CountsChild.md b/example/ruby/ModuleSpecs/CountsChild.md deleted file mode 100644 index 421c23b..0000000 --- a/example/ruby/ModuleSpecs/CountsChild.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::CountsChild -**Inherits:** ModuleSpecs::CountsParent - - - - - -#Instance Methods -## public_1() [](#method-i-public_1) - diff --git a/example/ruby/ModuleSpecs/CountsMixin.md b/example/ruby/ModuleSpecs/CountsMixin.md deleted file mode 100644 index 87f0275..0000000 --- a/example/ruby/ModuleSpecs/CountsMixin.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: ModuleSpecs::CountsMixin - - -Be careful touching the Counts* classes as there used for testing -private_instance_methods, public_instance_methods, etc. So adding, removing a -method will break those tests. - - - -#Instance Methods -## public_3() [](#method-i-public_3) - diff --git a/example/ruby/ModuleSpecs/CountsParent.md b/example/ruby/ModuleSpecs/CountsParent.md deleted file mode 100644 index be60a88..0000000 --- a/example/ruby/ModuleSpecs/CountsParent.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ModuleSpecs::CountsParent -**Inherits:** Object - -**Includes:** ModuleSpecs::CountsMixin - - - - - -#Instance Methods -## public_2() [](#method-i-public_2) - -## public_3() [](#method-i-public_3) - diff --git a/example/ruby/ModuleSpecs/CyclicAppendA.md b/example/ruby/ModuleSpecs/CyclicAppendA.md deleted file mode 100644 index 042b303..0000000 --- a/example/ruby/ModuleSpecs/CyclicAppendA.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::CyclicAppendA - - - - - diff --git a/example/ruby/ModuleSpecs/CyclicAppendB.md b/example/ruby/ModuleSpecs/CyclicAppendB.md deleted file mode 100644 index 4d21811..0000000 --- a/example/ruby/ModuleSpecs/CyclicAppendB.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::CyclicAppendB - -**Includes:** ModuleSpecs::CyclicAppendA - - - - - diff --git a/example/ruby/ModuleSpecs/CyclicBarrier.md b/example/ruby/ModuleSpecs/CyclicBarrier.md deleted file mode 100644 index 0a810f9..0000000 --- a/example/ruby/ModuleSpecs/CyclicBarrier.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: ModuleSpecs::CyclicBarrier -**Inherits:** Object - - - - - -#Instance Methods -## await() [](#method-i-await) - -## disable!() [](#method-i-disable!) - -## enabled?() [](#method-i-enabled?) - -**@return** [Boolean] - -## initialize(count1) [](#method-i-initialize) - -**@return** [CyclicBarrier] a new instance of CyclicBarrier - diff --git a/example/ruby/ModuleSpecs/CyclicPrepend.md b/example/ruby/ModuleSpecs/CyclicPrepend.md deleted file mode 100644 index fb0a1e4..0000000 --- a/example/ruby/ModuleSpecs/CyclicPrepend.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::CyclicPrepend - - - - - diff --git a/example/ruby/ModuleSpecs/Detached.md b/example/ruby/ModuleSpecs/Detached.md deleted file mode 100644 index 678f2d4..0000000 --- a/example/ruby/ModuleSpecs/Detached.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::Detached -**Inherits:** Object - - -This class isn't inherited from or included in anywhere. It exists to test the -constant scoping rules. - - - diff --git a/example/ruby/ModuleSpecs/ExtendObject.md b/example/ruby/ModuleSpecs/ExtendObject.md deleted file mode 100644 index 0c8bfdc..0000000 --- a/example/ruby/ModuleSpecs/ExtendObject.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::ExtendObject - - - - - -#Instance Methods -## test_method() [](#method-i-test_method) - diff --git a/example/ruby/ModuleSpecs/ExtendObjectPrivate.md b/example/ruby/ModuleSpecs/ExtendObjectPrivate.md deleted file mode 100644 index cc079dd..0000000 --- a/example/ruby/ModuleSpecs/ExtendObjectPrivate.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::ExtendObjectPrivate - - - - -# Class Methods -## extend_object(obj ) [](#method-c-extend_object) - diff --git a/example/ruby/ModuleSpecs/First.md b/example/ruby/ModuleSpecs/First.md deleted file mode 100644 index 96041da..0000000 --- a/example/ruby/ModuleSpecs/First.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::First -**Inherits:** Object - - - - - -#Instance Methods -## method_to_remove() [](#method-i-method_to_remove) - diff --git a/example/ruby/ModuleSpecs/Grandchild.md b/example/ruby/ModuleSpecs/Grandchild.md deleted file mode 100644 index 5c5d215..0000000 --- a/example/ruby/ModuleSpecs/Grandchild.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Grandchild -**Inherits:** ModuleSpecs::Child - - - - - diff --git a/example/ruby/ModuleSpecs/IncludedInObject.md b/example/ruby/ModuleSpecs/IncludedInObject.md deleted file mode 100644 index f623c36..0000000 --- a/example/ruby/ModuleSpecs/IncludedInObject.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::IncludedInObject - - - - - diff --git a/example/ruby/ModuleSpecs/IncludedInObject/IncludedModuleSpecs.md b/example/ruby/ModuleSpecs/IncludedInObject/IncludedModuleSpecs.md deleted file mode 100644 index 93bdfbd..0000000 --- a/example/ruby/ModuleSpecs/IncludedInObject/IncludedModuleSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::IncludedInObject::IncludedModuleSpecs - - - - - diff --git a/example/ruby/ModuleSpecs/IncludedModule.md b/example/ruby/ModuleSpecs/IncludedModule.md deleted file mode 100644 index 0c1d9dc..0000000 --- a/example/ruby/ModuleSpecs/IncludedModule.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::IncludedModule - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/ModuleSpecs/InstanceMeth.md b/example/ruby/ModuleSpecs/InstanceMeth.md deleted file mode 100644 index 71f4390..0000000 --- a/example/ruby/ModuleSpecs/InstanceMeth.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ModuleSpecs::InstanceMeth -**Inherits:** Object - -**Includes:** ModuleSpecs::InstanceMethMod - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## foo() [](#method-i-foo) - diff --git a/example/ruby/ModuleSpecs/InstanceMethChild.md b/example/ruby/ModuleSpecs/InstanceMethChild.md deleted file mode 100644 index ae75e9a..0000000 --- a/example/ruby/ModuleSpecs/InstanceMethChild.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::InstanceMethChild -**Inherits:** ModuleSpecs::InstanceMeth - - - - - diff --git a/example/ruby/ModuleSpecs/InstanceMethMod.md b/example/ruby/ModuleSpecs/InstanceMethMod.md deleted file mode 100644 index 040e5b2..0000000 --- a/example/ruby/ModuleSpecs/InstanceMethMod.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::InstanceMethMod - - - - - -#Instance Methods -## bar() [](#method-i-bar) - diff --git a/example/ruby/ModuleSpecs/Internal.md b/example/ruby/ModuleSpecs/Internal.md deleted file mode 100644 index 8b47708..0000000 --- a/example/ruby/ModuleSpecs/Internal.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Internal - - - - - diff --git a/example/ruby/ModuleSpecs/Lookup.md b/example/ruby/ModuleSpecs/Lookup.md deleted file mode 100644 index 3299d30..0000000 --- a/example/ruby/ModuleSpecs/Lookup.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::Lookup -**Inherits:** Object - -**Includes:** ModuleSpecs::LookupMod - - - - - diff --git a/example/ruby/ModuleSpecs/LookupChild.md b/example/ruby/ModuleSpecs/LookupChild.md deleted file mode 100644 index aee8893..0000000 --- a/example/ruby/ModuleSpecs/LookupChild.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::LookupChild -**Inherits:** ModuleSpecs::Lookup - - - - - diff --git a/example/ruby/ModuleSpecs/LookupMod.md b/example/ruby/ModuleSpecs/LookupMod.md deleted file mode 100644 index 867e647..0000000 --- a/example/ruby/ModuleSpecs/LookupMod.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::LookupMod - -**Includes:** ModuleSpecs::LookupModInMod - - - - - diff --git a/example/ruby/ModuleSpecs/LookupModInMod.md b/example/ruby/ModuleSpecs/LookupModInMod.md deleted file mode 100644 index dec7d0f..0000000 --- a/example/ruby/ModuleSpecs/LookupModInMod.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::LookupModInMod - - - - - diff --git a/example/ruby/ModuleSpecs/M1.md b/example/ruby/ModuleSpecs/M1.md deleted file mode 100644 index 1819ca6..0000000 --- a/example/ruby/ModuleSpecs/M1.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ModuleSpecs::M1 - - -empty modules - - - diff --git a/example/ruby/ModuleSpecs/M2.md b/example/ruby/ModuleSpecs/M2.md deleted file mode 100644 index 5f81118..0000000 --- a/example/ruby/ModuleSpecs/M2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::M2 - - - - - diff --git a/example/ruby/ModuleSpecs/M3.md b/example/ruby/ModuleSpecs/M3.md deleted file mode 100644 index 96fd2fd..0000000 --- a/example/ruby/ModuleSpecs/M3.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::M3 - - - - - diff --git a/example/ruby/ModuleSpecs/MA.md b/example/ruby/ModuleSpecs/MA.md deleted file mode 100644 index 0fb1d39..0000000 --- a/example/ruby/ModuleSpecs/MA.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::MA - - - - - diff --git a/example/ruby/ModuleSpecs/MB.md b/example/ruby/ModuleSpecs/MB.md deleted file mode 100644 index 120b2b8..0000000 --- a/example/ruby/ModuleSpecs/MB.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::MB - -**Includes:** ModuleSpecs::MA - - - - - diff --git a/example/ruby/ModuleSpecs/MC.md b/example/ruby/ModuleSpecs/MC.md deleted file mode 100644 index 4ca8d64..0000000 --- a/example/ruby/ModuleSpecs/MC.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::MC - - - - - diff --git a/example/ruby/ModuleSpecs/MVars.md b/example/ruby/ModuleSpecs/MVars.md deleted file mode 100644 index 68c0906..0000000 --- a/example/ruby/ModuleSpecs/MVars.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::MVars - - - - - diff --git a/example/ruby/ModuleSpecs/ModuleWithPrepend.md b/example/ruby/ModuleSpecs/ModuleWithPrepend.md deleted file mode 100644 index 8b3d214..0000000 --- a/example/ruby/ModuleSpecs/ModuleWithPrepend.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ModuleSpecs::ModuleWithPrepend - -**Includes:** ModuleSpecs::LookupMod - - - - - diff --git a/example/ruby/ModuleSpecs/Modules.md b/example/ruby/ModuleSpecs/Modules.md deleted file mode 100644 index c80f2f4..0000000 --- a/example/ruby/ModuleSpecs/Modules.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Modules - - - - - diff --git a/example/ruby/ModuleSpecs/Modules/Klass.md b/example/ruby/ModuleSpecs/Modules/Klass.md deleted file mode 100644 index a92223e..0000000 --- a/example/ruby/ModuleSpecs/Modules/Klass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Modules::Klass -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/MultipleIncludes.md b/example/ruby/ModuleSpecs/MultipleIncludes.md deleted file mode 100644 index db4f88a..0000000 --- a/example/ruby/ModuleSpecs/MultipleIncludes.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::MultipleIncludes -**Inherits:** Object - -**Includes:** ModuleSpecs::MB - - - - - diff --git a/example/ruby/ModuleSpecs/NameEncoding.md b/example/ruby/ModuleSpecs/NameEncoding.md deleted file mode 100644 index 0ae60fb..0000000 --- a/example/ruby/ModuleSpecs/NameEncoding.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::NameEncoding -**Inherits:** Object - - - - - -#Instance Methods -## name() [](#method-i-name) - diff --git a/example/ruby/ModuleSpecs/NameEncoding/C_C39F.md b/example/ruby/ModuleSpecs/NameEncoding/C_C39F.md deleted file mode 100644 index 4a68559..0000000 --- a/example/ruby/ModuleSpecs/NameEncoding/C_C39F.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::NameEncoding::Cß -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/NameSpecs.md b/example/ruby/ModuleSpecs/NameSpecs.md deleted file mode 100644 index b4ffc8b..0000000 --- a/example/ruby/ModuleSpecs/NameSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::NameSpecs - - - - - diff --git a/example/ruby/ModuleSpecs/NamedClass.md b/example/ruby/ModuleSpecs/NamedClass.md deleted file mode 100644 index 4c89fac..0000000 --- a/example/ruby/ModuleSpecs/NamedClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::NamedClass -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Nesting.md b/example/ruby/ModuleSpecs/Nesting.md deleted file mode 100644 index 7e7466c..0000000 --- a/example/ruby/ModuleSpecs/Nesting.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: ModuleSpecs::Nesting - - - - -# Class Methods -## [](name ) [](#method-c-[]) -## []=(name , val ) [](#method-c-[]=) -## called_from_module_method() [](#method-c-called_from_module_method) -## meta() [](#method-c-meta) - diff --git a/example/ruby/ModuleSpecs/Nesting/NestedClass.md b/example/ruby/ModuleSpecs/Nesting/NestedClass.md deleted file mode 100644 index 29844b3..0000000 --- a/example/ruby/ModuleSpecs/Nesting/NestedClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ModuleSpecs::Nesting::NestedClass -**Inherits:** Object - - - - -# Class Methods -## called_from_class_method() [](#method-c-called_from_class_method) - -#Instance Methods -## called_from_inst_method() [](#method-i-called_from_inst_method) - diff --git a/example/ruby/ModuleSpecs/Parent.md b/example/ruby/ModuleSpecs/Parent.md deleted file mode 100644 index fee0cda..0000000 --- a/example/ruby/ModuleSpecs/Parent.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: ModuleSpecs::Parent -**Inherits:** Object - - - - -# Class Methods -## public_method() [](#method-c-public_method) - -#Instance Methods -## another_method_to_undef() [](#method-i-another_method_to_undef) - -## another_parent_method() [](#method-i-another_parent_method) - -## method_to_remove() [](#method-i-method_to_remove) - -## method_to_undef() [](#method-i-method_to_undef) - -## parent_method() [](#method-i-parent_method) - -## public_parent() [](#method-i-public_parent) - -## undefed_method() [](#method-i-undefed_method) - diff --git a/example/ruby/ModuleSpecs/ParentPrivateMethodRedef.md b/example/ruby/ModuleSpecs/ParentPrivateMethodRedef.md deleted file mode 100644 index 7c7c165..0000000 --- a/example/ruby/ModuleSpecs/ParentPrivateMethodRedef.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::ParentPrivateMethodRedef -**Inherits:** Object - - - - - -#Instance Methods -## private_method_redefined() [](#method-i-private_method_redefined) - diff --git a/example/ruby/ModuleSpecs/PrependedModule.md b/example/ruby/ModuleSpecs/PrependedModule.md deleted file mode 100644 index b8d1f88..0000000 --- a/example/ruby/ModuleSpecs/PrependedModule.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::PrependedModule - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/ModuleSpecs/PrivConstModule.md b/example/ruby/ModuleSpecs/PrivConstModule.md deleted file mode 100644 index bdf68df..0000000 --- a/example/ruby/ModuleSpecs/PrivConstModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::PrivConstModule - - - - - diff --git a/example/ruby/ModuleSpecs/RecordIncludedModules.md b/example/ruby/ModuleSpecs/RecordIncludedModules.md deleted file mode 100644 index 0cbe4b6..0000000 --- a/example/ruby/ModuleSpecs/RecordIncludedModules.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: ModuleSpecs::RecordIncludedModules -**Inherits:** Object - - - - -# Class Methods -## inherited(base ) [](#method-c-inherited) -**@private** [] - - diff --git a/example/ruby/ModuleSpecs/RemoveClassVariable.md b/example/ruby/ModuleSpecs/RemoveClassVariable.md deleted file mode 100644 index 29b22a3..0000000 --- a/example/ruby/ModuleSpecs/RemoveClassVariable.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::RemoveClassVariable -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/ReopeningModule.md b/example/ruby/ModuleSpecs/ReopeningModule.md deleted file mode 100644 index beeca68..0000000 --- a/example/ruby/ModuleSpecs/ReopeningModule.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: ModuleSpecs::ReopeningModule - - -Yes, we want to re-open the module - - -# Class Methods -## foo() [](#method-c-foo) -## foo2() [](#method-c-foo2) - diff --git a/example/ruby/ModuleSpecs/Second.md b/example/ruby/ModuleSpecs/Second.md deleted file mode 100644 index 7b1a927..0000000 --- a/example/ruby/ModuleSpecs/Second.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ModuleSpecs::Second -**Inherits:** ModuleSpecs::First - - - - - -#Instance Methods -## method_to_remove() [](#method-i-method_to_remove) - diff --git a/example/ruby/ModuleSpecs/ShadowingOuter.md b/example/ruby/ModuleSpecs/ShadowingOuter.md deleted file mode 100644 index 394a3ff..0000000 --- a/example/ruby/ModuleSpecs/ShadowingOuter.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::ShadowingOuter - - - - - diff --git a/example/ruby/ModuleSpecs/ShadowingOuter/M.md b/example/ruby/ModuleSpecs/ShadowingOuter/M.md deleted file mode 100644 index 756c9c1..0000000 --- a/example/ruby/ModuleSpecs/ShadowingOuter/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::ShadowingOuter::M - - - - - diff --git a/example/ruby/ModuleSpecs/ShadowingOuter/N.md b/example/ruby/ModuleSpecs/ShadowingOuter/N.md deleted file mode 100644 index fa98f33..0000000 --- a/example/ruby/ModuleSpecs/ShadowingOuter/N.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::ShadowingOuter::N - - - - - diff --git a/example/ruby/ModuleSpecs/SingletonOnModuleCase.md b/example/ruby/ModuleSpecs/SingletonOnModuleCase.md deleted file mode 100644 index e39b841..0000000 --- a/example/ruby/ModuleSpecs/SingletonOnModuleCase.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::SingletonOnModuleCase - - - - - diff --git a/example/ruby/ModuleSpecs/SingletonOnModuleCase/Bar.md b/example/ruby/ModuleSpecs/SingletonOnModuleCase/Bar.md deleted file mode 100644 index f6ebcdb..0000000 --- a/example/ruby/ModuleSpecs/SingletonOnModuleCase/Bar.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ModuleSpecs::SingletonOnModuleCase::Bar -**Inherits:** Object - - - - -# Class Methods -## included_called() [](#method-c-included_called) -## included_called?() [](#method-c-included_called?) -**@return** [Boolean] - - diff --git a/example/ruby/ModuleSpecs/SingletonOnModuleCase/Foo.md b/example/ruby/ModuleSpecs/SingletonOnModuleCase/Foo.md deleted file mode 100644 index 0cafdb0..0000000 --- a/example/ruby/ModuleSpecs/SingletonOnModuleCase/Foo.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: ModuleSpecs::SingletonOnModuleCase::Foo - - - - -# Class Methods -## included(base ) [](#method-c-included) -**@private** [] - - diff --git a/example/ruby/ModuleSpecs/SubCVars.md b/example/ruby/ModuleSpecs/SubCVars.md deleted file mode 100644 index cbd96b0..0000000 --- a/example/ruby/ModuleSpecs/SubCVars.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::SubCVars -**Inherits:** ModuleSpecs::CVars - - - - - diff --git a/example/ruby/ModuleSpecs/SubModule.md b/example/ruby/ModuleSpecs/SubModule.md deleted file mode 100644 index 41cbb49..0000000 --- a/example/ruby/ModuleSpecs/SubModule.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ModuleSpecs::SubModule -**Inherits:** Module - - - - -# Attributes -## special[RW] [](#attribute-i-special) -Returns the value of attribute special. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [SubModule] a new instance of SubModule - diff --git a/example/ruby/ModuleSpecs/Subclass.md b/example/ruby/ModuleSpecs/Subclass.md deleted file mode 100644 index 69e523b..0000000 --- a/example/ruby/ModuleSpecs/Subclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Subclass -**Inherits:** Module - - - - - diff --git a/example/ruby/ModuleSpecs/SubclassSpec.md b/example/ruby/ModuleSpecs/SubclassSpec.md deleted file mode 100644 index b60cc4d..0000000 --- a/example/ruby/ModuleSpecs/SubclassSpec.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::SubclassSpec -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/Super.md b/example/ruby/ModuleSpecs/Super.md deleted file mode 100644 index ab476ce..0000000 --- a/example/ruby/ModuleSpecs/Super.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: ModuleSpecs::Super - -**Includes:** ModuleSpecs::Basic - - - - - -#Instance Methods -## public_module() [](#method-i-public_module) - -## public_super_module() [](#method-i-public_super_module) - diff --git a/example/ruby/ModuleSpecs/Super/SuperChild.md b/example/ruby/ModuleSpecs/Super/SuperChild.md deleted file mode 100644 index 92bd777..0000000 --- a/example/ruby/ModuleSpecs/Super/SuperChild.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::Super::SuperChild -**Inherits:** Object - - - - - diff --git a/example/ruby/ModuleSpecs/ThreadSafeCounter.md b/example/ruby/ModuleSpecs/ThreadSafeCounter.md deleted file mode 100644 index 8a26b5c..0000000 --- a/example/ruby/ModuleSpecs/ThreadSafeCounter.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ModuleSpecs::ThreadSafeCounter -**Inherits:** Object - - - - - -#Instance Methods -## get() [](#method-i-get) - -## increment_and_get() [](#method-i-increment_and_get) - -## initialize(value0) [](#method-i-initialize) - -**@return** [ThreadSafeCounter] a new instance of ThreadSafeCounter - diff --git a/example/ruby/ModuleSpecs/UnboundMethodTest.md b/example/ruby/ModuleSpecs/UnboundMethodTest.md deleted file mode 100644 index d96aa6c..0000000 --- a/example/ruby/ModuleSpecs/UnboundMethodTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::UnboundMethodTest - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/ModuleSpecs/UndefinedInstanceMethods.md b/example/ruby/ModuleSpecs/UndefinedInstanceMethods.md deleted file mode 100644 index 2ac2b05..0000000 --- a/example/ruby/ModuleSpecs/UndefinedInstanceMethods.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ModuleSpecs::UndefinedInstanceMethods - - -for undefined_instance_methods spec - - - diff --git a/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Child.md b/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Child.md deleted file mode 100644 index 6b199f4..0000000 --- a/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Child.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ModuleSpecs::UndefinedInstanceMethods::Child -**Inherits:** ModuleSpecs::UndefinedInstanceMethods::Parent - -**Includes:** ModuleSpecs::UndefinedInstanceMethods::Super - - - - - -#Instance Methods -## super_included_method() [](#method-i-super_included_method) - diff --git a/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Grandchild.md b/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Grandchild.md deleted file mode 100644 index 356d8f2..0000000 --- a/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Grandchild.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ModuleSpecs::UndefinedInstanceMethods::Grandchild -**Inherits:** ModuleSpecs::UndefinedInstanceMethods::Child - - - - - diff --git a/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Parent.md b/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Parent.md deleted file mode 100644 index 55315f2..0000000 --- a/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Parent.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ModuleSpecs::UndefinedInstanceMethods::Parent -**Inherits:** Object - - - - - -#Instance Methods -## another_parent_method() [](#method-i-another_parent_method) - -## parent_method() [](#method-i-parent_method) - -## undefed_method() [](#method-i-undefed_method) - diff --git a/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Super.md b/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Super.md deleted file mode 100644 index 1ea7ffe..0000000 --- a/example/ruby/ModuleSpecs/UndefinedInstanceMethods/Super.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ModuleSpecs::UndefinedInstanceMethods::Super - - - - - -#Instance Methods -## super_included_method() [](#method-i-super_included_method) - diff --git a/example/ruby/ModuleSpecs/WithPrependedModule.md b/example/ruby/ModuleSpecs/WithPrependedModule.md deleted file mode 100644 index 55ff358..0000000 --- a/example/ruby/ModuleSpecs/WithPrependedModule.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ModuleSpecs::WithPrependedModule -**Inherits:** Object - -**Includes:** ModuleSpecs::ModuleWithPrepend - - - - - diff --git a/example/ruby/ModuleSpecs/Z.md b/example/ruby/ModuleSpecs/Z.md deleted file mode 100644 index 2c66a40..0000000 --- a/example/ruby/ModuleSpecs/Z.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ModuleSpecs::Z - - - - - diff --git a/example/ruby/Monitor.md b/example/ruby/Monitor.md deleted file mode 100644 index e402fb7..0000000 --- a/example/ruby/Monitor.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: Monitor -**Inherits:** Object - - -Use the Monitor class when you want to have a lock object for blocks with -mutual exclusion. - - require 'monitor' - - lock = Monitor.new - lock.synchronize do - # exclusive access - end - - - -#Instance Methods -## enter() [](#method-i-enter) -Enters exclusive section. - -**@overload** [] - -## exit() [](#method-i-exit) -Leaves exclusive section. - -**@overload** [] - -## mon_check_owner() [](#method-i-mon_check_owner) -:nodoc: - -## mon_locked?() [](#method-i-mon_locked?) -:nodoc: - -**@return** [Boolean] - -## mon_owned?() [](#method-i-mon_owned?) -:nodoc: - -**@return** [Boolean] - -## new_cond() [](#method-i-new_cond) -Creates a new MonitorMixin::ConditionVariable associated with the Monitor -object. - -## synchronize() [](#method-i-synchronize) -Enters exclusive section and executes the block. Leaves the exclusive section -automatically when the block exits. See example under `MonitorMixin`. - -**@overload** [] - -## try_enter() [](#method-i-try_enter) -Attempts to enter exclusive section. Returns `false` if lock fails. - -**@overload** [] - -## wait_for_cond(cond, timeout) [](#method-i-wait_for_cond) -:nodoc: - diff --git a/example/ruby/MonitorMixin.md b/example/ruby/MonitorMixin.md deleted file mode 100644 index af59435..0000000 --- a/example/ruby/MonitorMixin.md +++ /dev/null @@ -1,113 +0,0 @@ -# Module: MonitorMixin - - -In concurrent programming, a monitor is an object or module intended to be -used safely by more than one thread. The defining characteristic of a monitor -is that its methods are executed with mutual exclusion. That is, at each point -in time, at most one thread may be executing any of its methods. This mutual -exclusion greatly simplifies reasoning about the implementation of monitors -compared to reasoning about parallel code that updates a data structure. - -You can read more about the general principles on the Wikipedia page for -[Monitors](https://en.wikipedia.org/wiki/Monitor_%28synchronization%29). - -## Examples - -### Simple object.extend - - require 'monitor.rb' - - buf = [] - buf.extend(MonitorMixin) - empty_cond = buf.new_cond - - # consumer - Thread.start do - loop do - buf.synchronize do - empty_cond.wait_while { buf.empty? } - print buf.shift - end - end - end - - # producer - while line = ARGF.gets - buf.synchronize do - buf.push(line) - empty_cond.signal - end - end - -The consumer thread waits for the producer thread to push a line to buf while -`buf.empty?`. The producer thread (main thread) reads a line from ARGF and -pushes it into buf then calls `empty_cond.signal` to notify the consumer -thread of new data. - -### Simple Class include - - require 'monitor' - - class SynchronizedArray < Array - - include MonitorMixin - - def initialize(*args) - super(*args) - end - - alias :old_shift :shift - alias :old_unshift :unshift - - def shift(n=1) - self.synchronize do - self.old_shift(n) - end - end - - def unshift(item) - self.synchronize do - self.old_unshift(item) - end - end - - # other methods ... - end - -`SynchronizedArray` implements an Array with synchronized access to items. -This Class is implemented as subclass of Array which includes the MonitorMixin -module. - - -# Class Methods -## extend_object(obj ) [](#method-c-extend_object) -:nodoc: - -#Instance Methods -## mon_enter() [](#method-i-mon_enter) -Enters exclusive section. - -## mon_exit() [](#method-i-mon_exit) -Leaves exclusive section. - -## mon_locked?() [](#method-i-mon_locked?) -Returns true if this monitor is locked by any thread - -**@return** [Boolean] - -## mon_owned?() [](#method-i-mon_owned?) -Returns true if this monitor is locked by current thread. - -**@return** [Boolean] - -## mon_synchronize(&b) [](#method-i-mon_synchronize) -Enters exclusive section and executes the block. Leaves the exclusive section -automatically when the block exits. See example under `MonitorMixin`. - -## mon_try_enter() [](#method-i-mon_try_enter) -Attempts to enter exclusive section. Returns `false` if lock fails. - -## new_cond() [](#method-i-new_cond) -Creates a new MonitorMixin::ConditionVariable associated with the Monitor -object. - diff --git a/example/ruby/MonitorMixin/ConditionVariable.md b/example/ruby/MonitorMixin/ConditionVariable.md deleted file mode 100644 index 021b917..0000000 --- a/example/ruby/MonitorMixin/ConditionVariable.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: MonitorMixin::ConditionVariable -**Inherits:** Object - - -FIXME: This isn't documented in Nutshell. - -Since MonitorMixin.new_cond returns a ConditionVariable, and the example above -calls while_wait and signal, this class should be documented. - - - -#Instance Methods -## broadcast() [](#method-i-broadcast) -Wakes up all threads waiting for this lock. - -## signal() [](#method-i-signal) -Wakes up the first thread in line waiting for this lock. - -## wait(timeoutnil) [](#method-i-wait) -Releases the lock held in the associated monitor and waits; reacquires the -lock on wakeup. - -If `timeout` is given, this method returns after `timeout` seconds passed, -even if no other thread doesn't signal. - -## wait_until() [](#method-i-wait_until) -Calls wait repeatedly until the given block yields a truthy value. - -## wait_while() [](#method-i-wait_while) -Calls wait repeatedly while the given block yields a truthy value. - diff --git a/example/ruby/Msxml.md b/example/ruby/Msxml.md deleted file mode 100644 index 28576b2..0000000 --- a/example/ruby/Msxml.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Msxml -**Inherits:** Object - -**Includes:** WIN32OLE::VARIANT - - -XMLDocument extends IXML Document. It is obsolete. You should use -DOMDocument. This object should not be confused with the XMLDocument property -on the XML data island. - - -# Attributes -## clsid[RW] [](#attribute-i-clsid) -Returns the value of attribute clsid. - -## dispatch[RW] [](#attribute-i-dispatch) -Returns the value of attribute dispatch. - -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - -## progid[RW] [](#attribute-i-progid) -Returns the value of attribute progid. - - -#Instance Methods -## async() [](#method-i-async) -HRESULT async get asynchronous loading flag. - BOOL arg0 --- pf [OUT] - -## async=(arg0) [](#method-i-async=) -HRESULT async get asynchronous loading flag. - BOOL arg0 --- pf [IN] - -## charset() [](#method-i-charset) -HRESULT charset get encoding. - BSTR arg0 --- p [OUT] - -## charset=(arg0) [](#method-i-charset=) -HRESULT charset get encoding. - BSTR arg0 --- p [IN] - -## createElement(arg0, arg1nil, arg2nil) [](#method-i-createElement) -HRESULT createElement create different types of IXMLElements. - VARIANT arg0 --- vType [IN] - VARIANT arg1 --- var1 [IN] - IXMLElement2,IXMLElement2 arg2 --- ppElem [OUT] - -## doctype() [](#method-i-doctype) -HRESULT doctype get document type. - BSTR arg0 --- p [OUT] - -## initialize(objnil) [](#method-i-initialize) - -**@return** [Msxml] a new instance of Msxml - -## method_missing(cmd, *arg) [](#method-i-method_missing) - -## readyState() [](#method-i-readyState) -HRESULT readyState get ready state. - I4 arg0 --- pl [OUT] - -## root() [](#method-i-root) -HRESULT root get root IXMLElement of the XML document. - IXMLElement2,IXMLElement2 arg0 --- p [OUT] - -## url() [](#method-i-url) -HRESULT url set URL to load an XML document from the URL. - BSTR arg0 --- p [OUT] - -## url=(arg0) [](#method-i-url=) -HRESULT url set URL to load an XML document from the URL. - BSTR arg0 --- p [IN] - -## version() [](#method-i-version) -HRESULT version get XML version number. - BSTR arg0 --- p [OUT] - diff --git a/example/ruby/MultiFormatter.md b/example/ruby/MultiFormatter.md deleted file mode 100644 index 9557fcf..0000000 --- a/example/ruby/MultiFormatter.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: MultiFormatter - - - - -# Class Methods -## extend_object(obj ) [](#method-c-extend_object) - -#Instance Methods -## aggregate_results(files) [](#method-i-aggregate_results) - -## multi_initialize() [](#method-i-multi_initialize) - -## print_exception(exc, count) [](#method-i-print_exception) - -## register() [](#method-i-register) - diff --git a/example/ruby/MultiPart.md b/example/ruby/MultiPart.md deleted file mode 100644 index d173486..0000000 --- a/example/ruby/MultiPart.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: MultiPart -**Inherits:** Object - - -usage: - boundary = 'foobar1234' # or nil - multipart = MultiPart.new(boundary) - multipart.append('name1', 'value1') - multipart.append('file1', File.read('file1.html'), 'file1.html') - str = multipart.close() - str.each_line {|line| p line } - ## output: - # "--foobar1234\r\n" - # "Content-Disposition: form-data: name=\"name1\"\r\n" - # "\r\n" - # "value1\r\n" - # "--foobar1234\r\n" - # "Content-Disposition: form-data: name=\"file1\"; filename=\"file1.html\"\r\n" - # "Content-Type: text/html\r\n" - # "\r\n" - # "\n" - # "

Hello

\n" - # "\n" - # "\r\n" - # "--foobar1234--\r\n" - - -# Attributes -## boundary[RW] [](#attribute-i-boundary) -Returns the value of attribute boundary. - - -#Instance Methods -## append(name, value, filenamenil, content_typenil) [](#method-i-append) - -## close() [](#method-i-close) - -## create_boundary() [](#method-i-create_boundary) -:nodoc: - -## detect_content_type(filename) [](#method-i-detect_content_type) -:nodoc: - -## initialize(boundarynil) [](#method-i-initialize) - -**@return** [MultiPart] a new instance of MultiPart - diff --git a/example/ruby/MyApp.md b/example/ruby/MyApp.md deleted file mode 100644 index bb0bc11..0000000 --- a/example/ruby/MyApp.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: MyApp -**Inherits:** Logger::Application - - - - - -#Instance Methods -## initialize(a, b, c) [](#method-i-initialize) - -**@return** [MyApp] a new instance of MyApp - -## run() [](#method-i-run) - diff --git a/example/ruby/MyDict.md b/example/ruby/MyDict.md deleted file mode 100644 index 2f291c2..0000000 --- a/example/ruby/MyDict.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: MyDict -**Inherits:** WIN32OLE - - -test of subclass of WIN32OLE - - -# Class Methods -## new() [](#method-c-new) - diff --git a/example/ruby/MyElem.md b/example/ruby/MyElem.md deleted file mode 100644 index 8768504..0000000 --- a/example/ruby/MyElem.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: MyElem -**Inherits:** Object - - -Linked list example - - - -#Instance Methods -## data() [](#method-i-data) - -## initialize(item) [](#method-i-initialize) -object initializer called from Class#new - -**@return** [MyElem] a new instance of MyElem - -## succ() [](#method-i-succ) - -## succ=(new) [](#method-i-succ=) -the method invoked by ``obj.data = val'' - diff --git a/example/ruby/MyList.md b/example/ruby/MyList.md deleted file mode 100644 index 0797744..0000000 --- a/example/ruby/MyList.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: MyList -**Inherits:** Object - - - - - -#Instance Methods -## add_to_list(obj) [](#method-i-add_to_list) - -## each() [](#method-i-each) - -## initialize() [](#method-i-initialize) - -**@return** [MyList] a new instance of MyList - -## to_s() [](#method-i-to_s) -the method to convert object into string. redefining this will affect print. - diff --git a/example/ruby/MyModule.md b/example/ruby/MyModule.md deleted file mode 100644 index 9d67599..0000000 --- a/example/ruby/MyModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: MyModule - - - - - diff --git a/example/ruby/MyTimeout.md b/example/ruby/MyTimeout.md deleted file mode 100644 index f002a51..0000000 --- a/example/ruby/MyTimeout.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: MyTimeout -**Inherits:** StandardError - - - - - diff --git a/example/ruby/NameError.md b/example/ruby/NameError.md deleted file mode 100644 index 1e2f427..0000000 --- a/example/ruby/NameError.md +++ /dev/null @@ -1,57 +0,0 @@ -# Exception: NameError -**Inherits:** StandardError - -**Includes:** ErrorHighlight::CoreExt - - -Raised when a given name is invalid or undefined. - - puts foo - -*raises the exception:* - - NameError: undefined local variable or method `foo' for main:Object - -Since constant names must start with a capital: - - Integer.const_set :answer, 42 - -*raises the exception:* - - NameError: wrong constant name answer - - - -#Instance Methods -## detailed_message(highlight:false, error_highlight:true) [](#method-i-detailed_message) - -## initialize(*args) [](#method-i-initialize) -Construct a new NameError exception. If given the *name* parameter may -subsequently be examined using the NameError#name method. *receiver* parameter -allows to pass object in context of which the error happened. Example: - - [1, 2, 3].method(:rject) # NameError with name "rject" and receiver: Array - [1, 2, 3].singleton_method(:rject) # NameError with name "rject" and receiver: [1, 2, 3] - -**@overload** [] - -## local_variables() [](#method-i-local_variables) -Return a list of the local variable names defined where this NameError -exception was raised. - -Internal use only. - -**@overload** [] - -## name() [](#method-i-name) -Return the name associated with this NameError exception. - -**@overload** [] - -## receiver() [](#method-i-receiver) -Return the receiver associated with this NameError exception. - -**@overload** [] - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/NameError/message.md b/example/ruby/NameError/message.md deleted file mode 100644 index a493fd8..0000000 --- a/example/ruby/NameError/message.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: NameError::message -**Inherits:** Object - - -:nodoc: - - -# Class Methods -## _load(str ) [](#method-c-_load) -:nodoc: - -#Instance Methods -## ==(obj2) [](#method-i-==) -:nodoc: - -## _dump(limit) [](#method-i-_dump) -:nodoc: - -## initialize_copy(obj2) [](#method-i-initialize_copy) -:nodoc: - -## to_str() [](#method-i-to_str) -:nodoc: - diff --git a/example/ruby/NameErrorExtensionTest.md b/example/ruby/NameErrorExtensionTest.md deleted file mode 100644 index 38162b1..0000000 --- a/example/ruby/NameErrorExtensionTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: NameErrorExtensionTest -**Inherits:** Test::Unit::TestCase - -**Includes:** DidYouMean::TestHelper - - - - - -#Instance Methods -## assert_correction(expected, array) [](#method-i-assert_correction) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_correctable_error_objects_are_dumpable() [](#method-i-test_correctable_error_objects_are_dumpable) - -## test_message() [](#method-i-test_message) - -## test_to_s_does_not_make_disruptive_changes_to_error_message() [](#method-i-test_to_s_does_not_make_disruptive_changes_to_error_message) - diff --git a/example/ruby/NameErrorExtensionTest/TestSpellChecker.md b/example/ruby/NameErrorExtensionTest/TestSpellChecker.md deleted file mode 100644 index a4f1226..0000000 --- a/example/ruby/NameErrorExtensionTest/TestSpellChecker.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: NameErrorExtensionTest::TestSpellChecker -**Inherits:** Object - - - - - -#Instance Methods -## corrections() [](#method-i-corrections) - -## initialize() [](#method-i-initialize) - -**@return** [TestSpellChecker] a new instance of TestSpellChecker - diff --git a/example/ruby/NameErrorSpecs.md b/example/ruby/NameErrorSpecs.md deleted file mode 100644 index a293ff2..0000000 --- a/example/ruby/NameErrorSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: NameErrorSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/NameErrorSpecs/ReceiverClass.md b/example/ruby/NameErrorSpecs/ReceiverClass.md deleted file mode 100644 index 6b8b77c..0000000 --- a/example/ruby/NameErrorSpecs/ReceiverClass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: NameErrorSpecs::ReceiverClass -**Inherits:** Object - - - - - -#Instance Methods -## call_undefined_class_variable() [](#method-i-call_undefined_class_variable) - diff --git a/example/ruby/NameMap.md b/example/ruby/NameMap.md deleted file mode 100644 index 60fecfa..0000000 --- a/example/ruby/NameMap.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: NameMap -**Inherits:** Object - - - - - -#Instance Methods -## class_or_module(c) [](#method-i-class_or_module) - -## dir_name(c, base) [](#method-i-dir_name) - -## exception?(name) [](#method-i-exception?) - -**@return** [Boolean] - -## file_name(m, c) [](#method-i-file_name) - -## initialize(filterfalse) [](#method-i-initialize) - -**@return** [NameMap] a new instance of NameMap - -## map(hash, constants, modnil) [](#method-i-map) - -## namespace(mod, const) [](#method-i-namespace) - diff --git a/example/ruby/NameMapSpecs.md b/example/ruby/NameMapSpecs.md deleted file mode 100644 index 1d671f2..0000000 --- a/example/ruby/NameMapSpecs.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: NameMapSpecs - - - - -# Class Methods -## n() [](#method-c-n) - -#Instance Methods -## n() [](#method-i-n) - diff --git a/example/ruby/NameMapSpecs/A.md b/example/ruby/NameMapSpecs/A.md deleted file mode 100644 index 241c906..0000000 --- a/example/ruby/NameMapSpecs/A.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: NameMapSpecs::A -**Inherits:** Object - - - - -# Class Methods -## a() [](#method-c-a) - -#Instance Methods -## a() [](#method-i-a) - -## c() [](#method-i-c) - diff --git a/example/ruby/NameMapSpecs/A/B.md b/example/ruby/NameMapSpecs/A/B.md deleted file mode 100644 index 8d32a47..0000000 --- a/example/ruby/NameMapSpecs/A/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: NameMapSpecs::A::B -**Inherits:** Object - - - - - -#Instance Methods -## b() [](#method-i-b) - diff --git a/example/ruby/NameMapSpecs/Error.md b/example/ruby/NameMapSpecs/Error.md deleted file mode 100644 index c97400e..0000000 --- a/example/ruby/NameMapSpecs/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: NameMapSpecs::Error -**Inherits:** Object - - - - - diff --git a/example/ruby/NameMapSpecs/Fixnum.md b/example/ruby/NameMapSpecs/Fixnum.md deleted file mode 100644 index 56713b0..0000000 --- a/example/ruby/NameMapSpecs/Fixnum.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: NameMapSpecs::Fixnum -**Inherits:** Object - - - - - -#Instance Methods -## f() [](#method-i-f) - diff --git a/example/ruby/NamespaceTest.md b/example/ruby/NamespaceTest.md deleted file mode 100644 index 907e50c..0000000 --- a/example/ruby/NamespaceTest.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: NamespaceTest - - - - - diff --git a/example/ruby/Net.md b/example/ruby/Net.md deleted file mode 100644 index 1864b46..0000000 --- a/example/ruby/Net.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Net - - --- https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml - - - diff --git a/example/ruby/Net/BufferedIO.md b/example/ruby/Net/BufferedIO.md deleted file mode 100644 index 6435e02..0000000 --- a/example/ruby/Net/BufferedIO.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: Net::BufferedIO -**Inherits:** Object - - -:nodoc: internal use only - - -# Attributes -## continue_timeout[RW] [](#attribute-i-continue_timeout) -Returns the value of attribute continue_timeout. - -## debug_output[RW] [](#attribute-i-debug_output) -Returns the value of attribute debug_output. - -## io[RW] [](#attribute-i-io) -Returns the value of attribute io. - -## read_timeout[RW] [](#attribute-i-read_timeout) -Returns the value of attribute read_timeout. - -## write_timeout[RW] [](#attribute-i-write_timeout) -Returns the value of attribute write_timeout. - - -#Instance Methods -## close() [](#method-i-close) - -## closed?() [](#method-i-closed?) - -**@return** [Boolean] - -## eof?() [](#method-i-eof?) - -**@return** [Boolean] - -## initialize(io, read_timeout:60, write_timeout:60, continue_timeout:nil, debug_output:nil) [](#method-i-initialize) - -**@return** [BufferedIO] a new instance of BufferedIO - -## inspect() [](#method-i-inspect) - -## read(len, dest''.b, ignore_eoffalse) [](#method-i-read) - -## read_all(dest''.b) [](#method-i-read_all) - -## readline() [](#method-i-readline) - -## readuntil(terminator, ignore_eoffalse) [](#method-i-readuntil) - -## write(*strs) [](#method-i-write) - -## writeline(str) [](#method-i-writeline) - diff --git a/example/ruby/Net/HTTP.md b/example/ruby/Net/HTTP.md deleted file mode 100644 index 571035a..0000000 --- a/example/ruby/Net/HTTP.md +++ /dev/null @@ -1,1638 +0,0 @@ -# Class: Net::HTTP -**Inherits:** Net::Protocol - - -Class Net::HTTP provides a rich library that implements the client in a -client-server model that uses the HTTP request-response protocol. For -information about HTTP, see: - -* [Hypertext Transfer - Protocol](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol). -* [Technical - overview](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Techni - cal_overview). - -## About the Examples - -:include: doc/net-http/examples.rdoc - -## Strategies - -* If you will make only a few GET requests, consider using - [OpenURI](rdoc-ref:OpenURI). -* If you will make only a few requests of all kinds, consider using the - various singleton convenience methods in this class. Each of the following - methods automatically starts and finishes a - [session](rdoc-ref:Net::HTTP@Sessions) that sends a single request: - - # Return string response body. - Net::HTTP.get(hostname, path) - Net::HTTP.get(uri) - - # Write string response body to $stdout. - Net::HTTP.get_print(hostname, path) - Net::HTTP.get_print(uri) - - # Return response as Net::HTTPResponse object. - Net::HTTP.get_response(hostname, path) - Net::HTTP.get_response(uri) - data = '{"title": "foo", "body": "bar", "userId": 1}' - Net::HTTP.post(uri, data) - params = {title: 'foo', body: 'bar', userId: 1} - Net::HTTP.post_form(uri, params) - data = '{"title": "foo", "body": "bar", "userId": 1}' - Net::HTTP.put(uri, data) - -* If performance is important, consider using sessions, which lower request - overhead. This [session](rdoc-ref:Net::HTTP@Sessions) has multiple - requests for [HTTP - methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request - _methods) and [WebDAV - methods](https://en.wikipedia.org/wiki/WebDAV#Implementation): - - Net::HTTP.start(hostname) do |http| - # Session started automatically before block execution. - http.get(path) - http.head(path) - body = 'Some text' - http.post(path, body) # Can also have a block. - http.put(path, body) - http.delete(path) - http.options(path) - http.trace(path) - http.patch(path, body) # Can also have a block. - http.copy(path) - http.lock(path, body) - http.mkcol(path, body) - http.move(path) - http.propfind(path, body) - http.proppatch(path, body) - http.unlock(path, body) - # Session finished automatically at block exit. - end - -The methods cited above are convenience methods that, via their few arguments, -allow minimal control over the requests. For greater control, consider using -[request objects](rdoc-ref:Net::HTTPRequest). - -## URIs - -On the internet, a URI ([Universal Resource -Identifier](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)) is a -string that identifies a particular resource. It consists of some or all of: -scheme, hostname, path, query, and fragment; see [URI -syntax](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax). - -A Ruby [URI::Generic](rdoc-ref:URI::Generic) object represents an internet -URI. It provides, among others, methods `scheme`, `hostname`, `path`, `query`, -and `fragment`. - -### Schemes - -An internet URI has a -[scheme](https://en.wikipedia.org/wiki/List_of_URI_schemes). - -The two schemes supported in Net::HTTP are `'https'` and `'http'`: - - uri.scheme # => "https" - URI('http://example.com').scheme # => "http" - -### Hostnames - -A hostname identifies a server (host) to which requests may be sent: - - hostname = uri.hostname # => "jsonplaceholder.typicode.com" - Net::HTTP.start(hostname) do |http| - # Some HTTP stuff. - end - -### Paths - -A host-specific path identifies a resource on the host: - - _uri = uri.dup - _uri.path = '/todos/1' - hostname = _uri.hostname - path = _uri.path - Net::HTTP.get(hostname, path) - -### Queries - -A host-specific query adds name/value pairs to the URI: - - _uri = uri.dup - params = {userId: 1, completed: false} - _uri.query = URI.encode_www_form(params) - _uri # => # - Net::HTTP.get(_uri) - -### Fragments - -A [URI fragment](https://en.wikipedia.org/wiki/URI_fragment) has no effect in -Net::HTTP; the same data is returned, regardless of whether a fragment is -included. - -## Request Headers - -Request headers may be used to pass additional information to the host, -similar to arguments passed in a method call; each header is a name/value -pair. - -Each of the Net::HTTP methods that sends a request to the host has optional -argument `headers`, where the headers are expressed as a hash of -field-name/value pairs: - - headers = {Accept: 'application/json', Connection: 'Keep-Alive'} - Net::HTTP.get(uri, headers) - -See lists of both standard request fields and common request fields at -[Request -Fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_field -s). A host may also accept other custom fields. - -## HTTP Sessions - -A *session* is a connection between a server (host) and a client that: - -* Is begun by instance method Net::HTTP#start. -* May contain any number of requests. -* Is ended by instance method Net::HTTP#finish. - -See example sessions at [Strategies](rdoc-ref:Net::HTTP@Strategies). - -### Session Using Net::HTTP.start - -If you have many requests to make to a single host (and port), consider using -singleton method Net::HTTP.start with a block; the method handles the session -automatically by: - -* Calling #start before block execution. -* Executing the block. -* Calling #finish after block execution. - -In the block, you can use these instance methods, each of which that sends a -single request: - -* [HTTP - methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request - _methods): - - * #get, #request_get: GET. - * #head, #request_head: HEAD. - * #post, #request_post: POST. - * #delete: DELETE. - * #options: OPTIONS. - * #trace: TRACE. - * #patch: PATCH. - -* [WebDAV methods](https://en.wikipedia.org/wiki/WebDAV#Implementation): - - * #copy: COPY. - * #lock: LOCK. - * #mkcol: MKCOL. - * #move: MOVE. - * #propfind: PROPFIND. - * #proppatch: PROPPATCH. - * #unlock: UNLOCK. - -### Session Using Net::HTTP.start and Net::HTTP.finish - -You can manage a session manually using methods #start and #finish: - - http = Net::HTTP.new(hostname) - http.start - http.get('/todos/1') - http.get('/todos/2') - http.delete('/posts/1') - http.finish # Needed to free resources. - -### Single-Request Session - -Certain convenience methods automatically handle a session by: - -* Creating an HTTP object -* Starting a session. -* Sending a single request. -* Finishing the session. -* Destroying the object. - -Such methods that send GET requests: - -* ::get: Returns the string response body. -* ::get_print: Writes the string response body to $stdout. -* ::get_response: Returns a Net::HTTPResponse object. - -Such methods that send POST requests: - -* ::post: Posts data to the host. -* ::post_form: Posts form data to the host. - -## HTTP Requests and Responses - -Many of the methods above are convenience methods, each of which sends a -request and returns a string without directly using Net::HTTPRequest and -Net::HTTPResponse objects. - -You can, however, directly create a request object, send the request, and -retrieve the response object; see: - -* Net::HTTPRequest. -* Net::HTTPResponse. - -## Following Redirection - -Each returned response is an instance of a subclass of Net::HTTPResponse. See -the [response class -hierarchy](rdoc-ref:Net::HTTPResponse@Response+Subclasses). - -In particular, class Net::HTTPRedirection is the parent of all redirection -classes. This allows you to craft a case statement to handle redirections -properly: - - def fetch(uri, limit = 10) - # You should choose a better exception. - raise ArgumentError, 'Too many HTTP redirects' if limit == 0 - - res = Net::HTTP.get_response(URI(uri)) - case res - when Net::HTTPSuccess # Any success class. - res - when Net::HTTPRedirection # Any redirection class. - location = res['Location'] - warn "Redirected to #{location}" - fetch(location, limit - 1) - else # Any other class. - res.value - end - end - - fetch(uri) - -## Basic Authentication - -Basic authentication is performed according to -[RFC2617](http://www.ietf.org/rfc/rfc2617.txt): - - req = Net::HTTP::Get.new(uri) - req.basic_auth('user', 'pass') - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -## Streaming Response Bodies - -By default Net::HTTP reads an entire response into memory. If you are -handling large files or wish to implement a progress bar you can instead -stream the body directly to an IO. - - Net::HTTP.start(hostname) do |http| - req = Net::HTTP::Get.new(uri) - http.request(req) do |res| - open('t.tmp', 'w') do |f| - res.read_body do |chunk| - f.write chunk - end - end - end - end - -## HTTPS - -HTTPS is enabled for an HTTP connection by Net::HTTP#use_ssl=: - - Net::HTTP.start(hostname, :use_ssl => true) do |http| - req = Net::HTTP::Get.new(uri) - res = http.request(req) - end - -Or if you simply want to make a GET request, you may pass in a URI object that -has an HTTPS URL. Net::HTTP automatically turns on TLS verification if the URI -object has a 'https' URI scheme: - - uri # => # - Net::HTTP.get(uri) - -## Proxy Server - -An HTTP object can have a [proxy -server](https://en.wikipedia.org/wiki/Proxy_server). - -You can create an HTTP object with a proxy server using method Net::HTTP.new -or method Net::HTTP.start. - -The proxy may be defined either by argument `p_addr` or by environment -variable `'http_proxy'`. - -### Proxy Using Argument `p_addr` as a String - -When argument `p_addr` is a string hostname, the returned `http` has the given -host as its proxy: - - http = Net::HTTP.new(hostname, nil, 'proxy.example') - http.proxy? # => true - http.proxy_from_env? # => false - http.proxy_address # => "proxy.example" - # These use default values. - http.proxy_port # => 80 - http.proxy_user # => nil - http.proxy_pass # => nil - -The port, username, and password for the proxy may also be given: - - http = Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass') - # => # - http.proxy? # => true - http.proxy_from_env? # => false - http.proxy_address # => "proxy.example" - http.proxy_port # => 8000 - http.proxy_user # => "pname" - http.proxy_pass # => "ppass" - -### Proxy Using '`ENV['http_proxy']`' - -When environment variable `'http_proxy'` is set to a URI string, the returned -`http` will have the server at that URI as its proxy; note that the URI string -must have a protocol such as `'http'` or `'https'`: - - ENV['http_proxy'] = 'http://example.com' - http = Net::HTTP.new(hostname) - http.proxy? # => true - http.proxy_from_env? # => true - http.proxy_address # => "example.com" - # These use default values. - http.proxy_port # => 80 - http.proxy_user # => nil - http.proxy_pass # => nil - -The URI string may include proxy username, password, and port number: - - ENV['http_proxy'] = 'http://pname:ppass@example.com:8000' - http = Net::HTTP.new(hostname) - http.proxy? # => true - http.proxy_from_env? # => true - http.proxy_address # => "example.com" - http.proxy_port # => 8000 - http.proxy_user # => "pname" - http.proxy_pass # => "ppass" - -### Filtering Proxies - -With method Net::HTTP.new (but not Net::HTTP.start), you can use argument -`p_no_proxy` to filter proxies: - -* Reject a certain address: - - http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example') - http.proxy_address # => nil - -* Reject certain domains or subdomains: - - http = Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example') - http.proxy_address # => nil - -* Reject certain addresses and port combinations: - - http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234') - http.proxy_address # => "proxy.example" - - http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000') - http.proxy_address # => nil - -* Reject a list of the types above delimited using a comma: - - http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') - http.proxy_address # => nil - - http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') - http.proxy_address # => nil - -## Compression and Decompression - -Net::HTTP does not compress the body of a request before sending. - -By default, Net::HTTP adds header `'Accept-Encoding'` to a new [request -object](rdoc-ref:Net::HTTPRequest): - - Net::HTTP::Get.new(uri)['Accept-Encoding'] - # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" - -This requests the server to zip-encode the response body if there is one; the -server is not required to do so. - -Net::HTTP does not automatically decompress a response body if the response -has header `'Content-Range'`. - -Otherwise decompression (or not) depends on the value of header -[Content-Encoding](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#co -ntent-encoding-response-header): - -* `'deflate'`, `'gzip'`, or `'x-gzip'`: decompresses the body and deletes - the header. -* `'none'` or `'identity'`: does not decompress the body, but deletes the - header. -* Any other value: leaves the body and header unchanged. - -## What's Here - -First, what's elsewhere. Class Net::HTTP: - -* Inherits from [class Object](rdoc-ref:Object@What-27s+Here). - -This is a categorized summary of methods and attributes. - -### Net::HTTP Objects - -* [::new](rdoc-ref:Net::HTTP.new): Creates a new instance. -* [#inspect](rdoc-ref:Net::HTTP#inspect): Returns a string representation of - `self`. - -### Sessions - -* [::start](rdoc-ref:Net::HTTP.start): Begins a new session in a new - Net::HTTP object. -* [#started?](rdoc-ref:Net::HTTP#started?): Returns whether in a session. -* [#finish](rdoc-ref:Net::HTTP#finish): Ends an active session. -* [#start](rdoc-ref:Net::HTTP#start): Begins a new session in an existing - Net::HTTP object (`self`). - -### Connections - -* [:continue_timeout](rdoc-ref:Net::HTTP#continue_timeout): Returns the - continue timeout. -* [#continue_timeout=](rdoc-ref:Net::HTTP#continue_timeout=): Sets the - continue timeout seconds. -* [:keep_alive_timeout](rdoc-ref:Net::HTTP#keep_alive_timeout): Returns the - keep-alive timeout. -* [:keep_alive_timeout=](rdoc-ref:Net::HTTP#keep_alive_timeout=): Sets the - keep-alive timeout. -* [:max_retries](rdoc-ref:Net::HTTP#max_retries): Returns the maximum - retries. -* [#max_retries=](rdoc-ref:Net::HTTP#max_retries=): Sets the maximum - retries. -* [:open_timeout](rdoc-ref:Net::HTTP#open_timeout): Returns the open - timeout. -* [:open_timeout=](rdoc-ref:Net::HTTP#open_timeout=): Sets the open timeout. -* [:read_timeout](rdoc-ref:Net::HTTP#read_timeout): Returns the open - timeout. -* [:read_timeout=](rdoc-ref:Net::HTTP#read_timeout=): Sets the read timeout. -* [:ssl_timeout](rdoc-ref:Net::HTTP#ssl_timeout): Returns the ssl timeout. -* [:ssl_timeout=](rdoc-ref:Net::HTTP#ssl_timeout=): Sets the ssl timeout. -* [:write_timeout](rdoc-ref:Net::HTTP#write_timeout): Returns the write - timeout. -* [write_timeout=](rdoc-ref:Net::HTTP#write_timeout=): Sets the write - timeout. - -### Requests - -* [::get](rdoc-ref:Net::HTTP.get): Sends a GET request and returns the - string response body. -* [::get_print](rdoc-ref:Net::HTTP.get_print): Sends a GET request and write - the string response body to $stdout. -* [::get_response](rdoc-ref:Net::HTTP.get_response): Sends a GET request and - returns a response object. -* [::post_form](rdoc-ref:Net::HTTP.post_form): Sends a POST request with - form data and returns a response object. -* [::post](rdoc-ref:Net::HTTP.post): Sends a POST request with data and - returns a response object. -* [::put](rdoc-ref:Net::HTTP.put): Sends a PUT request with data and returns - a response object. -* [#copy](rdoc-ref:Net::HTTP#copy): Sends a COPY request and returns a - response object. -* [#delete](rdoc-ref:Net::HTTP#delete): Sends a DELETE request and returns a - response object. -* [#get](rdoc-ref:Net::HTTP#get): Sends a GET request and returns a response - object. -* [#head](rdoc-ref:Net::HTTP#head): Sends a HEAD request and returns a - response object. -* [#lock](rdoc-ref:Net::HTTP#lock): Sends a LOCK request and returns a - response object. -* [#mkcol](rdoc-ref:Net::HTTP#mkcol): Sends a MKCOL request and returns a - response object. -* [#move](rdoc-ref:Net::HTTP#move): Sends a MOVE request and returns a - response object. -* [#options](rdoc-ref:Net::HTTP#options): Sends a OPTIONS request and - returns a response object. -* [#patch](rdoc-ref:Net::HTTP#patch): Sends a PATCH request and returns a - response object. -* [#post](rdoc-ref:Net::HTTP#post): Sends a POST request and returns a - response object. -* [#propfind](rdoc-ref:Net::HTTP#propfind): Sends a PROPFIND request and - returns a response object. -* [#proppatch](rdoc-ref:Net::HTTP#proppatch): Sends a PROPPATCH request and - returns a response object. -* [#put](rdoc-ref:Net::HTTP#put): Sends a PUT request and returns a response - object. -* [#request](rdoc-ref:Net::HTTP#request): Sends a request and returns a - response object. -* [#request_get](rdoc-ref:Net::HTTP#request_get): Sends a GET request and - forms a response object; if a block given, calls the block with the - object, otherwise returns the object. -* [#request_head](rdoc-ref:Net::HTTP#request_head): Sends a HEAD request and - forms a response object; if a block given, calls the block with the - object, otherwise returns the object. -* [#request_post](rdoc-ref:Net::HTTP#request_post): Sends a POST request and - forms a response object; if a block given, calls the block with the - object, otherwise returns the object. -* [#send_request](rdoc-ref:Net::HTTP#send_request): Sends a request and - returns a response object. -* [#trace](rdoc-ref:Net::HTTP#trace): Sends a TRACE request and returns a - response object. -* [#unlock](rdoc-ref:Net::HTTP#unlock): Sends an UNLOCK request and returns - a response object. - -### Responses - -* [:close_on_empty_response](rdoc-ref:Net::HTTP#close_on_empty_response): - Returns whether to close connection on empty response. -* [:close_on_empty_response=](rdoc-ref:Net::HTTP#close_on_empty_response=): - Sets whether to close connection on empty response. -* [:ignore_eof](rdoc-ref:Net::HTTP#ignore_eof): Returns whether to ignore - end-of-file when reading a response body with `Content-Length` headers. -* [:ignore_eof=](rdoc-ref:Net::HTTP#ignore_eof=): Sets whether to ignore - end-of-file when reading a response body with `Content-Length` headers. -* [:response_body_encoding](rdoc-ref:Net::HTTP#response_body_encoding): - Returns the encoding to use for the response body. -* [#response_body_encoding=](rdoc-ref:Net::HTTP#response_body_encoding=): - Sets the response body encoding. - -### Proxies - -* [:proxy_address](rdoc-ref:Net::HTTP#proxy_address): Returns the proxy - address. -* [:proxy_address=](rdoc-ref:Net::HTTP#proxy_address=): Sets the proxy - address. -* [::proxy_class?](rdoc-ref:Net::HTTP.proxy_class?): Returns whether `self` - is a proxy class. -* [#proxy?](rdoc-ref:Net::HTTP#proxy?): Returns whether `self` has a proxy. -* [#proxy_address](rdoc-ref:Net::HTTP#proxy_address): Returns the proxy - address. -* [#proxy_from_env?](rdoc-ref:Net::HTTP#proxy_from_env?): Returns whether - the proxy is taken from an environment variable. -* [:proxy_from_env=](rdoc-ref:Net::HTTP#proxy_from_env=): Sets whether the - proxy is to be taken from an environment variable. -* [:proxy_pass](rdoc-ref:Net::HTTP#proxy_pass): Returns the proxy password. -* [:proxy_pass=](rdoc-ref:Net::HTTP#proxy_pass=): Sets the proxy password. -* [:proxy_port](rdoc-ref:Net::HTTP#proxy_port): Returns the proxy port. -* [:proxy_port=](rdoc-ref:Net::HTTP#proxy_port=): Sets the proxy port. -* [#proxy_user](rdoc-ref:Net::HTTP#proxy_user): Returns the proxy user name. -* [:proxy_user=](rdoc-ref:Net::HTTP#proxy_user=): Sets the proxy user. - -### Security - -* [:ca_file](rdoc-ref:Net::HTTP#ca_file): Returns the path to a CA - certification file. -* [:ca_file=](rdoc-ref:Net::HTTP#ca_file=): Sets the path to a CA - certification file. -* [:ca_path](rdoc-ref:Net::HTTP#ca_path): Returns the path of to CA - directory containing certification files. -* [:ca_path=](rdoc-ref:Net::HTTP#ca_path=): Sets the path of to CA directory - containing certification files. -* [:cert](rdoc-ref:Net::HTTP#cert): Returns the OpenSSL::X509::Certificate - object to be used for client certification. -* [:cert=](rdoc-ref:Net::HTTP#cert=): Sets the OpenSSL::X509::Certificate - object to be used for client certification. -* [:cert_store](rdoc-ref:Net::HTTP#cert_store): Returns the X509::Store to - be used for verifying peer certificate. -* [:cert_store=](rdoc-ref:Net::HTTP#cert_store=): Sets the X509::Store to be - used for verifying peer certificate. -* [:ciphers](rdoc-ref:Net::HTTP#ciphers): Returns the available SSL ciphers. -* [:ciphers=](rdoc-ref:Net::HTTP#ciphers=): Sets the available SSL ciphers. -* [:extra_chain_cert](rdoc-ref:Net::HTTP#extra_chain_cert): Returns the - extra X509 certificates to be added to the certificate chain. -* [:extra_chain_cert=](rdoc-ref:Net::HTTP#extra_chain_cert=): Sets the extra - X509 certificates to be added to the certificate chain. -* [:key](rdoc-ref:Net::HTTP#key): Returns the OpenSSL::PKey::RSA or - OpenSSL::PKey::DSA object. -* [:key=](rdoc-ref:Net::HTTP#key=): Sets the OpenSSL::PKey::RSA or - OpenSSL::PKey::DSA object. -* [:max_version](rdoc-ref:Net::HTTP#max_version): Returns the maximum SSL - version. -* [:max_version=](rdoc-ref:Net::HTTP#max_version=): Sets the maximum SSL - version. -* [:min_version](rdoc-ref:Net::HTTP#min_version): Returns the minimum SSL - version. -* [:min_version=](rdoc-ref:Net::HTTP#min_version=): Sets the minimum SSL - version. -* [#peer_cert](rdoc-ref:Net::HTTP#peer_cert): Returns the X509 certificate - chain for the session's socket peer. -* [:ssl_version](rdoc-ref:Net::HTTP#ssl_version): Returns the SSL version. -* [:ssl_version=](rdoc-ref:Net::HTTP#ssl_version=): Sets the SSL version. -* [#use_ssl=](rdoc-ref:Net::HTTP#use_ssl=): Sets whether a new session is to - use Transport Layer Security. -* [#use_ssl?](rdoc-ref:Net::HTTP#use_ssl?): Returns whether `self` uses SSL. -* [:verify_callback](rdoc-ref:Net::HTTP#verify_callback): Returns the - callback for the server certification verification. -* [:verify_callback=](rdoc-ref:Net::HTTP#verify_callback=): Sets the - callback for the server certification verification. -* [:verify_depth](rdoc-ref:Net::HTTP#verify_depth): Returns the maximum - depth for the certificate chain verification. -* [:verify_depth=](rdoc-ref:Net::HTTP#verify_depth=): Sets the maximum depth - for the certificate chain verification. -* [:verify_hostname](rdoc-ref:Net::HTTP#verify_hostname): Returns the flags - for server the certification verification at the beginning of the SSL/TLS - session. -* [:verify_hostname=](rdoc-ref:Net::HTTP#verify_hostname=): Sets he flags - for server the certification verification at the beginning of the SSL/TLS - session. -* [:verify_mode](rdoc-ref:Net::HTTP#verify_mode): Returns the flags for - server the certification verification at the beginning of the SSL/TLS - session. -* [:verify_mode=](rdoc-ref:Net::HTTP#verify_mode=): Sets the flags for - server the certification verification at the beginning of the SSL/TLS - session. - -### Addresses and Ports - -* [:address](rdoc-ref:Net::HTTP#address): Returns the string host name or - host IP. -* [::default_port](rdoc-ref:Net::HTTP.default_port): Returns integer 80, the - default port to use for HTTP requests. -* [::http_default_port](rdoc-ref:Net::HTTP.http_default_port): Returns - integer 80, the default port to use for HTTP requests. -* [::https_default_port](rdoc-ref:Net::HTTP.https_default_port): Returns - integer 443, the default port to use for HTTPS requests. -* [#ipaddr](rdoc-ref:Net::HTTP#ipaddr): Returns the IP address for the - connection. -* [#ipaddr=](rdoc-ref:Net::HTTP#ipaddr=): Sets the IP address for the - connection. -* [:local_host](rdoc-ref:Net::HTTP#local_host): Returns the string local - host used to establish the connection. -* [:local_host=](rdoc-ref:Net::HTTP#local_host=): Sets the string local host - used to establish the connection. -* [:local_port](rdoc-ref:Net::HTTP#local_port): Returns the integer local - port used to establish the connection. -* [:local_port=](rdoc-ref:Net::HTTP#local_port=): Sets the integer local - port used to establish the connection. -* [:port](rdoc-ref:Net::HTTP#port): Returns the integer port number. - -### HTTP Version - -* [::version_1_2?](rdoc-ref:Net::HTTP.version_1_2?) (aliased as - [::version_1_2](rdoc-ref:Net::HTTP.version_1_2)): Returns true; retained - for compatibility. - -### Debugging - -* [#set_debug_output](rdoc-ref:Net::HTTP#set_debug_output): Sets the output - stream for debugging. - - -# Class Methods -## Proxy(p_addr :ENV, p_port nil, p_user nil, p_pass nil, p_use_ssl nil) [](#method-c-Proxy) -Creates an HTTP proxy class which behaves like Net::HTTP, but performs all -access via the specified proxy. - -This class is obsolete. You may pass these same parameters directly to -Net::HTTP.new. See Net::HTTP.new for details of the arguments. -## default_port() [](#method-c-default_port) -Returns integer `80`, the default port to use for HTTP requests: - - Net::HTTP.default_port # => 80 -## get(uri_or_host , path_or_headers nil, port nil) [](#method-c-get) -:call-seq: - Net::HTTP.get(hostname, path, port = 80) -> body - Net::HTTP:get(uri, headers = {}, port = uri.port) -> body - -Sends a GET request and returns the HTTP response body as a string. - -With string arguments `hostname` and `path`: - - hostname = 'jsonplaceholder.typicode.com' - path = '/todos/1' - puts Net::HTTP.get(hostname, path) - -Output: - - { - "userId": 1, - "id": 1, - "title": "delectus aut autem", - "completed": false - } - -With URI object `uri` and optional hash argument `headers`: - - uri = URI('https://jsonplaceholder.typicode.com/todos/1') - headers = {'Content-type' => 'application/json; charset=UTF-8'} - Net::HTTP.get(uri, headers) - -Related: - -* Net::HTTP::Get: request class for HTTP method `GET`. -* Net::HTTP#get: convenience method for HTTP method `GET`. -## get_print(uri_or_host , path_or_headers nil, port nil) [](#method-c-get_print) -:call-seq: - Net::HTTP.get_print(hostname, path, port = 80) -> nil - Net::HTTP:get_print(uri, headers = {}, port = uri.port) -> nil - -Like Net::HTTP.get, but writes the returned body to $stdout; returns `nil`. -## get_response(uri_or_host , path_or_headers nil, port nil, &block ) [](#method-c-get_response) -:call-seq: - Net::HTTP.get_response(hostname, path, port = 80) -> http_response - Net::HTTP:get_response(uri, headers = {}, port = uri.port) -> http_response - -Like Net::HTTP.get, but returns a Net::HTTPResponse object instead of the body -string. -## http_default_port() [](#method-c-http_default_port) -Returns integer `80`, the default port to use for HTTP requests: - - Net::HTTP.http_default_port # => 80 -## https_default_port() [](#method-c-https_default_port) -Returns integer `443`, the default port to use for HTTPS requests: - - Net::HTTP.https_default_port # => 443 -## new(address , port nil, p_addr :ENV, p_port nil, p_user nil, p_pass nil, p_no_proxy nil, p_use_ssl nil) [](#method-c-new) -Returns a new Net::HTTP object `http` (but does not open a TCP connection or -HTTP session). - -With only string argument `address` given (and `ENV['http_proxy']` undefined -or `nil`), the returned `http`: - -* Has the given address. -* Has the default port number, Net::HTTP.default_port (80). -* Has no proxy. - -Example: - - http = Net::HTTP.new(hostname) - # => # - http.address # => "jsonplaceholder.typicode.com" - http.port # => 80 - http.proxy? # => false - -With integer argument `port` also given, the returned `http` has the given -port: - - http = Net::HTTP.new(hostname, 8000) - # => # - http.port # => 8000 - -For proxy-defining arguments `p_addr` through `p_no_proxy`, see [Proxy -Server](rdoc-ref:Net::HTTP@Proxy+Server). -## newobj() [](#method-c-newobj) -:nodoc: -## post(url , data , header nil) [](#method-c-post) -Posts data to a host; returns a Net::HTTPResponse object. - -Argument `url` must be a URL; argument `data` must be a string: - - _uri = uri.dup - _uri.path = '/posts' - data = '{"title": "foo", "body": "bar", "userId": 1}' - headers = {'content-type': 'application/json'} - res = Net::HTTP.post(_uri, data, headers) # => # - puts res.body - -Output: - - { - "title": "foo", - "body": "bar", - "userId": 1, - "id": 101 - } - -Related: - -* Net::HTTP::Post: request class for HTTP method `POST`. -* Net::HTTP#post: convenience method for HTTP method `POST`. -## post_form(url , params ) [](#method-c-post_form) -Posts data to a host; returns a Net::HTTPResponse object. - -Argument `url` must be a URI; argument `data` must be a hash: - - _uri = uri.dup - _uri.path = '/posts' - data = {title: 'foo', body: 'bar', userId: 1} - res = Net::HTTP.post_form(_uri, data) # => # - puts res.body - -Output: - - { - "title": "foo", - "body": "bar", - "userId": "1", - "id": 101 - } -## proxy_class?() [](#method-c-proxy_class?) -Returns true if self is a class which was created by HTTP::Proxy. -**@return** [Boolean] - -## put(url , data , header nil) [](#method-c-put) -Sends a PUT request to the server; returns a Net::HTTPResponse object. - -Argument `url` must be a URL; argument `data` must be a string: - - _uri = uri.dup - _uri.path = '/posts' - data = '{"title": "foo", "body": "bar", "userId": 1}' - headers = {'content-type': 'application/json'} - res = Net::HTTP.put(_uri, data, headers) # => # - puts res.body - -Output: - - { - "title": "foo", - "body": "bar", - "userId": 1, - "id": 101 - } - -Related: - -* Net::HTTP::Put: request class for HTTP method `PUT`. -* Net::HTTP#put: convenience method for HTTP method `PUT`. -## socket_type() [](#method-c-socket_type) -:nodoc: obsolete -## start(address , *arg , &block ) [](#method-c-start) -:call-seq: - HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) -> http - HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) {|http| ... } -> object - -Creates a new Net::HTTP object, `http`, via Net::HTTP.new: - -* For arguments `address` and `port`, see Net::HTTP.new. -* For proxy-defining arguments `p_addr` through `p_pass`, see [Proxy - Server](rdoc-ref:Net::HTTP@Proxy+Server). -* For argument `opts`, see below. - -With no block given: - -* Calls `http.start` with no block (see #start), which opens a TCP - connection and HTTP session. -* Returns `http`. -* The caller should call #finish to close the session: - - http = Net::HTTP.start(hostname) - http.started? # => true - http.finish - http.started? # => false - -With a block given: - -* Calls `http.start` with the block (see #start), which: - - * Opens a TCP connection and HTTP session. - * Calls the block, which may make any number of requests to the host. - * Closes the HTTP session and TCP connection on block exit. - * Returns the block's value `object`. - -* Returns `object`. - -Example: - - hostname = 'jsonplaceholder.typicode.com' - Net::HTTP.start(hostname) do |http| - puts http.get('/todos/1').body - puts http.get('/todos/2').body - end - -Output: - - { - "userId": 1, - "id": 1, - "title": "delectus aut autem", - "completed": false - } - { - "userId": 1, - "id": 2, - "title": "quis ut nam facilis et officia qui", - "completed": false - } - -If the last argument given is a hash, it is the `opts` hash, where each key is -a method or accessor to be called, and its value is the value to be set. - -The keys may include: - -* #ca_file -* #ca_path -* #cert -* #cert_store -* #ciphers -* #close_on_empty_response -* `ipaddr` (calls #ipaddr=) -* #keep_alive_timeout -* #key -* #open_timeout -* #read_timeout -* #ssl_timeout -* #ssl_version -* `use_ssl` (calls #use_ssl=) -* #verify_callback -* #verify_depth -* #verify_mode -* #write_timeout - -Note: If `port` is `nil` and `opts[:use_ssl]` is a truthy value, the value -passed to `new` is Net::HTTP.https_default_port, not `port`. -## version_1_1?() [](#method-c-version_1_1?) -Returns `false`; retained for compatibility. -**@return** [Boolean] - -## version_1_2() [](#method-c-version_1_2) -Returns `true`; retained for compatibility. -## version_1_2?() [](#method-c-version_1_2?) -Returns `true`; retained for compatibility. -**@return** [Boolean] - -# Attributes -## default_configuration[RW] [](#attribute-c-default_configuration) -Allows to set the default configuration that will be used when creating a new -connection. - -Example: - - Net::HTTP.default_configuration = { - read_timeout: 1, - write_timeout: 1 - } - http = Net::HTTP.new(hostname) - http.open_timeout # => 60 - http.read_timeout # => 1 - http.write_timeout # => 1 - -## proxy_address[RW] [](#attribute-c-proxy_address) -Returns the address of the proxy host, or `nil` if none; see -Net::HTTP@Proxy+Server. - -## proxy_pass[RW] [](#attribute-c-proxy_pass) -Returns the password for accessing the proxy, or `nil` if none; see -Net::HTTP@Proxy+Server. - -## proxy_port[RW] [](#attribute-c-proxy_port) -Returns the port number of the proxy host, or `nil` if none; see -Net::HTTP@Proxy+Server. - -## proxy_use_ssl[RW] [](#attribute-c-proxy_use_ssl) -Use SSL when talking to the proxy. If Net::HTTP does not use a proxy, nil. - -## proxy_user[RW] [](#attribute-c-proxy_user) -Returns the user name for accessing the proxy, or `nil` if none; see -Net::HTTP@Proxy+Server. - -## address[RW] [](#attribute-i-address) -Returns the string host name or host IP given as argument `address` in ::new. - -## ca_file[RW] [](#attribute-i-ca_file) -Sets or returns the path to a CA certification file in PEM format. - -## ca_path[RW] [](#attribute-i-ca_path) -Sets or returns the path of to CA directory containing certification files in -PEM format. - -## cert[RW] [](#attribute-i-cert) -Sets or returns the OpenSSL::X509::Certificate object to be used for client -certification. - -## cert_store[RW] [](#attribute-i-cert_store) -Sets or returns the X509::Store to be used for verifying peer certificate. - -## ciphers[RW] [](#attribute-i-ciphers) -Sets or returns the available SSL ciphers. See -[:SSL::SSLContext#ciphers=](OpenSSL::SSL::SSL::Context#ciphers=). - -## close_on_empty_response[RW] [](#attribute-i-close_on_empty_response) -Sets or returns whether to close the connection when the response is empty; -initially `false`. - -## continue_timeout[RW] [](#attribute-i-continue_timeout) -Returns the continue timeout value; see continue_timeout=. - -## extra_chain_cert[RW] [](#attribute-i-extra_chain_cert) -Sets or returns the extra X509 certificates to be added to the certificate -chain. See -[:SSL::SSLContext#add_certificate](OpenSSL::SSL::SSL::Context#add_certificate) -. - -## ignore_eof[RW] [](#attribute-i-ignore_eof) -Sets or returns whether to ignore end-of-file when reading a response body -with `Content-Length` headers; initially `true`. - -## keep_alive_timeout[RW] [](#attribute-i-keep_alive_timeout) -Sets or returns the numeric (Integer or Float) number of seconds to keep the -connection open after a request is sent; initially 2. If a new request is made -during the given interval, the still-open connection is used; otherwise the -connection will have been closed and a new connection is opened. - -## key[RW] [](#attribute-i-key) -Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object. - -## local_host[RW] [](#attribute-i-local_host) -Sets or returns the string local host used to establish the connection; -initially `nil`. - -## local_port[RW] [](#attribute-i-local_port) -Sets or returns the integer local port used to establish the connection; -initially `nil`. - -## max_retries[RW] [](#attribute-i-max_retries) -Returns the maximum number of times to retry an idempotent request; see -#max_retries=. - -## max_version[RW] [](#attribute-i-max_version) -Sets or returns the maximum SSL version. See -[:SSL::SSLContext#max_version=](OpenSSL::SSL::SSL::Context#max_version=). - -## min_version[RW] [](#attribute-i-min_version) -Sets or returns the minimum SSL version. See -[:SSL::SSLContext#min_version=](OpenSSL::SSL::SSL::Context#min_version=). - -## open_timeout[RW] [](#attribute-i-open_timeout) -Sets or returns the numeric (Integer or Float) number of seconds to wait for a -connection to open; initially 60. If the connection is not made in the given -interval, an exception is raised. - -## port[RW] [](#attribute-i-port) -Returns the integer port number given as argument `port` in ::new. - -## proxy_address[RW] [](#attribute-i-proxy_address) -Returns the address of the proxy server, if defined, `nil` otherwise; see -[Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server). - -## proxy_from_env=[R] [](#attribute-i-proxy_from_env=) -Sets whether to determine the proxy from environment variable -'`ENV['http_proxy']`'; see [Proxy Using -ENV['http_proxy']](rdoc-ref:Net::HTTP@Proxy+Using+-27ENV-5B-27http_proxy-27-5D --27). - -## proxy_pass[RW] [](#attribute-i-proxy_pass) -Returns the password of the proxy server, if defined, `nil` otherwise; see -[Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server). - -## proxy_port[RW] [](#attribute-i-proxy_port) -Returns the port number of the proxy server, if defined, `nil` otherwise; see -[Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server). - -## proxy_use_ssl=[R] [](#attribute-i-proxy_use_ssl=) -Sets the attribute proxy_use_ssl - -**@param** [] the value to set the attribute proxy_use_ssl to. - -## proxy_user[RW] [](#attribute-i-proxy_user) -Returns the user name of the proxy server, if defined, `nil` otherwise; see -[Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server). - -## read_timeout[RW] [](#attribute-i-read_timeout) -Returns the numeric (Integer or Float) number of seconds to wait for one block -to be read (via one read(2) call); see #read_timeout=. - -## response_body_encoding[RW] [](#attribute-i-response_body_encoding) -Returns the encoding to use for the response body; see -#response_body_encoding=. - -## ssl_timeout[RW] [](#attribute-i-ssl_timeout) -Sets or returns the SSL timeout seconds. - -## ssl_version[RW] [](#attribute-i-ssl_version) -Sets or returns the SSL version. See -[:SSL::SSLContext#ssl_version=](OpenSSL::SSL::SSL::Context#ssl_version=). - -## verify_callback[RW] [](#attribute-i-verify_callback) -Sets or returns the callback for the server certification verification. - -## verify_depth[RW] [](#attribute-i-verify_depth) -Sets or returns the maximum depth for the certificate chain verification. - -## verify_hostname[RW] [](#attribute-i-verify_hostname) -Sets or returns whether to verify that the server certificate is valid for the -hostname. See -[:SSL::SSLContext#verify_hostname=](OpenSSL::SSL::SSL::Context#verify_hostname -=). - -## verify_mode[RW] [](#attribute-i-verify_mode) -Sets or returns the flags for server the certification verification at the -beginning of the SSL/TLS session. OpenSSL::SSL::VERIFY_NONE or -OpenSSL::SSL::VERIFY_PEER are acceptable. - -## write_timeout[RW] [](#attribute-i-write_timeout) -Returns the numeric (Integer or Float) number of seconds to wait for one block -to be written (via one write(2) call); see #write_timeout=. - - -#Instance Methods -## copy(path, initheadernil) [](#method-i-copy) -Sends a COPY request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Copy object created from string `path` -and initial headers hash `initheader`. - - http = Net::HTTP.new(hostname) - http.copy('/todos/1') - -## delete(path, initheader{'Depth' => 'Infinity'}) [](#method-i-delete) -Sends a DELETE request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Delete object created from string -`path` and initial headers hash `initheader`. - - http = Net::HTTP.new(hostname) - http.delete('/todos/1') - -## finish() [](#method-i-finish) -Finishes the HTTP session: - - http = Net::HTTP.new(hostname) - http.start - http.started? # => true - http.finish # => nil - http.started? # => false - -Raises IOError if not in a session. - -**@raise** [IOError] - -## get(path, initheadernil, destnil, &block) [](#method-i-get) -:call-seq: - get(path, initheader = nil) {|res| ... } - -Sends a GET request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Get object created from string `path` -and initial headers hash `initheader`. - -With a block given, calls the block with the response body: - - http = Net::HTTP.new(hostname) - http.get('/todos/1') do |res| - p res - end # => # - -Output: - - "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}" - -With no block given, simply returns the response object: - - http.get('/') # => # - -Related: - -* Net::HTTP::Get: request class for HTTP method GET. -* Net::HTTP.get: sends GET request, returns response body. - -## head(path, initheadernil) [](#method-i-head) -Sends a HEAD request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Head object created from string `path` -and initial headers hash `initheader`: - - res = http.head('/todos/1') # => # - res.body # => nil - res.to_hash.take(3) - # => - [["date", ["Wed, 15 Feb 2023 15:25:42 GMT"]], - ["content-type", ["application/json; charset=utf-8"]], - ["connection", ["close"]]] - -## initialize(address, portnil) [](#method-i-initialize) -Creates a new Net::HTTP object for the specified server address, without -opening the TCP connection or initializing the HTTP session. The `address` -should be a DNS hostname or IP address. - -**@return** [HTTP] a new instance of HTTP - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - Net::HTTP.new(hostname).inspect - # => "#" - -## ipaddr() [](#method-i-ipaddr) -Returns the IP address for the connection. - -If the session has not been started, returns the value set by #ipaddr=, or -`nil` if it has not been set: - - http = Net::HTTP.new(hostname) - http.ipaddr # => nil - http.ipaddr = '172.67.155.76' - http.ipaddr # => "172.67.155.76" - -If the session has been started, returns the IP address from the socket: - - http = Net::HTTP.new(hostname) - http.start - http.ipaddr # => "172.67.155.76" - http.finish - -## ipaddr=(addr) [](#method-i-ipaddr=) -Sets the IP address for the connection: - - http = Net::HTTP.new(hostname) - http.ipaddr # => nil - http.ipaddr = '172.67.155.76' - http.ipaddr # => "172.67.155.76" - -The IP address may not be set if the session has been started. - -**@raise** [IOError] - -## lock(path, body, initheadernil) [](#method-i-lock) -Sends a LOCK request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Lock object created from string `path`, -string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Net::HTTP.new(hostname) - http.lock('/todos/1', data) - -## mkcol(path, bodynil, initheadernil) [](#method-i-mkcol) -Sends a MKCOL request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Mkcol object created from string -`path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http.mkcol('/todos/1', data) - http = Net::HTTP.new(hostname) - -## move(path, initheadernil) [](#method-i-move) -Sends a MOVE request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Move object created from string `path` -and initial headers hash `initheader`. - - http = Net::HTTP.new(hostname) - http.move('/todos/1') - -## options(path, initheadernil) [](#method-i-options) -Sends an Options request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Options object created from string -`path` and initial headers hash `initheader`. - - http = Net::HTTP.new(hostname) - http.options('/') - -## patch(path, data, initheadernil, destnil, &block) [](#method-i-patch) -:call-seq: - patch(path, data, initheader = nil) {|res| ... } - -Sends a PATCH request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Patch object created from string -`path`, string `data`, and initial headers hash `initheader`. - -With a block given, calls the block with the response body: - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Net::HTTP.new(hostname) - http.patch('/todos/1', data) do |res| - p res - end # => # - -Output: - - "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false,\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\"\n}" - -With no block given, simply returns the response object: - - http.patch('/todos/1', data) # => # - -## peer_cert() [](#method-i-peer_cert) -Returns the X509 certificate chain (an array of strings) for the session's -socket peer, or `nil` if none. - -## post(path, data, initheadernil, destnil, &block) [](#method-i-post) -:call-seq: - post(path, data, initheader = nil) {|res| ... } - -Sends a POST request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Post object created from string `path`, -string `data`, and initial headers hash `initheader`. - -With a block given, calls the block with the response body: - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Net::HTTP.new(hostname) - http.post('/todos', data) do |res| - p res - end # => # - -Output: - - "{\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\",\n \"id\": 201\n}" - -With no block given, simply returns the response object: - - http.post('/todos', data) # => # - -Related: - -* Net::HTTP::Post: request class for HTTP method POST. -* Net::HTTP.post: sends POST request, returns response body. - -## propfind(path, bodynil, initheader{'Depth' => '0'}) [](#method-i-propfind) -Sends a PROPFIND request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Propfind object created from string -`path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Net::HTTP.new(hostname) - http.propfind('/todos/1', data) - -## proppatch(path, body, initheadernil) [](#method-i-proppatch) -Sends a PROPPATCH request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Proppatch object created from string -`path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Net::HTTP.new(hostname) - http.proppatch('/todos/1', data) - -## proxy?() [](#method-i-proxy?) -Returns `true` if a proxy server is defined, `false` otherwise; see [Proxy -Server](rdoc-ref:Net::HTTP@Proxy+Server). - -**@return** [Boolean] - -## proxy_from_env?() [](#method-i-proxy_from_env?) -Returns `true` if the proxy server is defined in the environment, `false` -otherwise; see [Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server). - -**@return** [Boolean] - -## proxy_uri() [](#method-i-proxy_uri) -The proxy URI determined from the environment for this connection. - -## put(path, data, initheadernil) [](#method-i-put) -Sends a PUT request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Put object created from string `path`, -string `data`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Net::HTTP.new(hostname) - http.put('/todos/1', data) # => # - -Related: - -* Net::HTTP::Put: request class for HTTP method PUT. -* Net::HTTP.put: sends PUT request, returns response body. - -## request(req, bodynil, &block) [](#method-i-request) -Sends the given request `req` to the server; forms the response into a -Net::HTTPResponse object. - -The given `req` must be an instance of a [subclass of -Net::HTTPRequest](rdoc-ref:Net::HTTPRequest@Request+Subclasses). Argument -`body` should be given only if needed for the request. - -With no block given, returns the response object: - - http = Net::HTTP.new(hostname) - - req = Net::HTTP::Get.new('/todos/1') - http.request(req) - # => # - - req = Net::HTTP::Post.new('/todos') - http.request(req, 'xyzzy') - # => # - -With a block given, calls the block with the response and returns the -response: - - req = Net::HTTP::Get.new('/todos/1') - http.request(req) do |res| - p res - end # => # - -Output: - - # - -## request_get(path, initheadernil, &block) [](#method-i-request_get) -Sends a GET request to the server; forms the response into a Net::HTTPResponse -object. - -The request is based on the Net::HTTP::Get object created from string `path` -and initial headers hash `initheader`. - -With no block given, returns the response object: - - http = Net::HTTP.new(hostname) - http.request_get('/todos') # => # - -With a block given, calls the block with the response object and returns the -response object: - - http.request_get('/todos') do |res| - p res - end # => # - -Output: - - # - -## request_head(path, initheadernil, &block) [](#method-i-request_head) -Sends a HEAD request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Head object created from string `path` -and initial headers hash `initheader`. - - http = Net::HTTP.new(hostname) - http.head('/todos/1') # => # - -## request_post(path, data, initheadernil, &block) [](#method-i-request_post) -Sends a POST request to the server; forms the response into a -Net::HTTPResponse object. - -The request is based on the Net::HTTP::Post object created from string `path`, -string `data`, and initial headers hash `initheader`. - -With no block given, returns the response object: - - http = Net::HTTP.new(hostname) - http.post('/todos', 'xyzzy') - # => # - -With a block given, calls the block with the response body and returns the -response object: - - http.post('/todos', 'xyzzy') do |res| - p res - end # => # - -Output: - - "{\n \"xyzzy\": \"\",\n \"id\": 201\n}" - -## request_put(path, data, initheadernil, &block) [](#method-i-request_put) -Sends a PUT request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Put object created from string `path`, -string `data`, and initial headers hash `initheader`. - - http = Net::HTTP.new(hostname) - http.put('/todos/1', 'xyzzy') - # => # - -## send_request(name, path, datanil, headernil) [](#method-i-send_request) -Sends an HTTP request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTPRequest object created from string -`path`, string `data`, and initial headers hash `header`. That object is an -instance of the [subclass of -Net::HTTPRequest](rdoc-ref:Net::HTTPRequest@Request+Subclasses), that -corresponds to the given uppercase string `name`, which must be an [HTTP -request method](https://en.wikipedia.org/wiki/HTTP#Request_methods) or a -[WebDAV request method](https://en.wikipedia.org/wiki/WebDAV#Implementation). - -Examples: - - http = Net::HTTP.new(hostname) - http.send_request('GET', '/todos/1') - # => # - http.send_request('POST', '/todos', 'xyzzy') - # => # - -## set_debug_output(output) [](#method-i-set_debug_output) -**WARNING** This method opens a serious security hole. Never use this method -in production code. - -Sets the output stream for debugging: - - http = Net::HTTP.new(hostname) - File.open('t.tmp', 'w') do |file| - http.set_debug_output(file) - http.start - http.get('/nosuch/1') - http.finish - end - puts File.read('t.tmp') - -Output: - - opening connection to jsonplaceholder.typicode.com:80... - opened - <- "GET /nosuch/1 HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: jsonplaceholder.typicode.com\r\n\r\n" - -> "HTTP/1.1 404 Not Found\r\n" - -> "Date: Mon, 12 Dec 2022 21:14:11 GMT\r\n" - -> "Content-Type: application/json; charset=utf-8\r\n" - -> "Content-Length: 2\r\n" - -> "Connection: keep-alive\r\n" - -> "X-Powered-By: Express\r\n" - -> "X-Ratelimit-Limit: 1000\r\n" - -> "X-Ratelimit-Remaining: 999\r\n" - -> "X-Ratelimit-Reset: 1670879660\r\n" - -> "Vary: Origin, Accept-Encoding\r\n" - -> "Access-Control-Allow-Credentials: true\r\n" - -> "Cache-Control: max-age=43200\r\n" - -> "Pragma: no-cache\r\n" - -> "Expires: -1\r\n" - -> "X-Content-Type-Options: nosniff\r\n" - -> "Etag: W/\"2-vyGp6PvFo4RvsFtPoIWeCReyIC8\"\r\n" - -> "Via: 1.1 vegur\r\n" - -> "CF-Cache-Status: MISS\r\n" - -> "Server-Timing: cf-q-config;dur=1.3000000762986e-05\r\n" - -> "Report-To: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=yOr40jo%2BwS1KHzhTlVpl54beJ5Wx2FcG4gGV0XVrh3X9OlR5q4drUn2dkt5DGO4GDcE%2BVXT7CNgJvGs%2BZleIyMu8CLieFiDIvOviOY3EhHg94m0ZNZgrEdpKD0S85S507l1vsEwEHkoTm%2Ff19SiO\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\n" - -> "NEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\n" - -> "Server: cloudflare\r\n" - -> "CF-RAY: 778977dc484ce591-DFW\r\n" - -> "alt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r\n" - -> "\r\n" - reading 2 bytes... - -> "{}" - read 2 bytes - Conn keep-alive - -## start() [](#method-i-start) -Starts an HTTP session. - -Without a block, returns `self`: - - http = Net::HTTP.new(hostname) - # => # - http.start - # => # - http.started? # => true - http.finish - -With a block, calls the block with `self`, finishes the session when the block -exits, and returns the block's value: - - http.start do |http| - http - end - # => # - http.started? # => false - -**@raise** [IOError] - -## started?() [](#method-i-started?) -Returns `true` if the HTTP session has been started: - - http = Net::HTTP.new(hostname) - http.started? # => false - http.start - http.started? # => true - http.finish # => nil - http.started? # => false - - Net::HTTP.start(hostname) do |http| - http.started? - end # => true - http.started? # => false - -**@return** [Boolean] - -## trace(path, initheadernil) [](#method-i-trace) -Sends a TRACE request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Trace object created from string `path` -and initial headers hash `initheader`. - - http = Net::HTTP.new(hostname) - http.trace('/todos/1') - -## unlock(path, body, initheadernil) [](#method-i-unlock) -Sends an UNLOCK request to the server; returns an instance of a subclass of -Net::HTTPResponse. - -The request is based on the Net::HTTP::Unlock object created from string -`path`, string `body`, and initial headers hash `initheader`. - - data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' - http = Net::HTTP.new(hostname) - http.unlock('/todos/1', data) - -## use_ssl=(flag) [](#method-i-use_ssl=) -Sets whether a new session is to use [Transport Layer -Security](https://en.wikipedia.org/wiki/Transport_Layer_Security): - -Raises IOError if attempting to change during a session. - -Raises OpenSSL::SSL::SSLError if the port is not an HTTPS port. - -## use_ssl?() [](#method-i-use_ssl?) -Returns `true` if `self` uses SSL, `false` otherwise. See Net::HTTP#use_ssl=. - -**@return** [Boolean] - diff --git a/example/ruby/Net/HTTP/Copy.md b/example/ruby/Net/HTTP/Copy.md deleted file mode 100644 index 62493e3..0000000 --- a/example/ruby/Net/HTTP/Copy.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::HTTP::Copy -**Inherits:** Net::HTTPRequest - - -Class for representing [WebDAV method -COPY](http://www.webdav.org/specs/rfc4918.html#METHOD_COPY): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Copy.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Related: - -* Net::HTTP#copy: sends `COPY` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Delete.md b/example/ruby/Net/HTTP/Delete.md deleted file mode 100644 index 1a07336..0000000 --- a/example/ruby/Net/HTTP/Delete.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Net::HTTP::Delete -**Inherits:** Net::HTTPRequest - - -Class for representing [HTTP method -DELETE](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol -#DELETE_method): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - uri.path = '/posts/1' - req = Net::HTTP::Delete.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: optional. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): no. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Net::HTTP#delete: sends `DELETE` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Get.md b/example/ruby/Net/HTTP/Get.md deleted file mode 100644 index 1bf3521..0000000 --- a/example/ruby/Net/HTTP/Get.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Net::HTTP::Get -**Inherits:** Net::HTTPRequest - - -Class for representing [HTTP method -GET](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#GE -T_method): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Get.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: optional. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): yes. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): yes. - -Related: - -* Net::HTTP.get: sends `GET` request, returns response body. -* Net::HTTP#get: sends `GET` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Head.md b/example/ruby/Net/HTTP/Head.md deleted file mode 100644 index 818bf1c..0000000 --- a/example/ruby/Net/HTTP/Head.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Net::HTTP::Head -**Inherits:** Net::HTTPRequest - - -Class for representing [HTTP method -HEAD](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#H -EAD_method): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Head.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: optional. -* Response body: no. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): yes. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): yes. - -Related: - -* Net::HTTP#head: sends `HEAD` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Lock.md b/example/ruby/Net/HTTP/Lock.md deleted file mode 100644 index f27299b..0000000 --- a/example/ruby/Net/HTTP/Lock.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::HTTP::Lock -**Inherits:** Net::HTTPRequest - - -Class for representing [WebDAV method -LOCK](http://www.webdav.org/specs/rfc4918.html#METHOD_LOCK): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Lock.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Related: - -* Net::HTTP#lock: sends `LOCK` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Mkcol.md b/example/ruby/Net/HTTP/Mkcol.md deleted file mode 100644 index 97a63d8..0000000 --- a/example/ruby/Net/HTTP/Mkcol.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::HTTP::Mkcol -**Inherits:** Net::HTTPRequest - - -Class for representing [WebDAV method -MKCOL](http://www.webdav.org/specs/rfc4918.html#METHOD_MKCOL): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Mkcol.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Related: - -* Net::HTTP#mkcol: sends `MKCOL` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Move.md b/example/ruby/Net/HTTP/Move.md deleted file mode 100644 index 54991e5..0000000 --- a/example/ruby/Net/HTTP/Move.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::HTTP::Move -**Inherits:** Net::HTTPRequest - - -Class for representing [WebDAV method -MOVE](http://www.webdav.org/specs/rfc4918.html#METHOD_MOVE): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Move.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Related: - -* Net::HTTP#move: sends `MOVE` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Options.md b/example/ruby/Net/HTTP/Options.md deleted file mode 100644 index f32913d..0000000 --- a/example/ruby/Net/HTTP/Options.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Net::HTTP::Options -**Inherits:** Net::HTTPRequest - - -Class for representing [HTTP method -OPTIONS](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protoco -l#OPTIONS_method): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Options.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: optional. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): yes. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Net::HTTP#options: sends `OPTIONS` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Patch.md b/example/ruby/Net/HTTP/Patch.md deleted file mode 100644 index 83cb8f2..0000000 --- a/example/ruby/Net/HTTP/Patch.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Net::HTTP::Patch -**Inherits:** Net::HTTPRequest - - -Class for representing [HTTP method -PATCH](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol# -PATCH_method): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - uri.path = '/posts' - req = Net::HTTP::Patch.new(uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: yes. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): no. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): no. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Net::HTTP#patch: sends `PATCH` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Post.md b/example/ruby/Net/HTTP/Post.md deleted file mode 100644 index a02163e..0000000 --- a/example/ruby/Net/HTTP/Post.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Net::HTTP::Post -**Inherits:** Net::HTTPRequest - - -Class for representing [HTTP method -POST](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#P -OST_method): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - uri.path = '/posts' - req = Net::HTTP::Post.new(uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: yes. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): no. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): no. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): yes. - -Related: - -* Net::HTTP.post: sends `POST` request, returns response object. -* Net::HTTP#post: sends `POST` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Propfind.md b/example/ruby/Net/HTTP/Propfind.md deleted file mode 100644 index 619c7de..0000000 --- a/example/ruby/Net/HTTP/Propfind.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::HTTP::Propfind -**Inherits:** Net::HTTPRequest - - -Class for representing [WebDAV method -PROPFIND](http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Propfind.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Related: - -* Net::HTTP#propfind: sends `PROPFIND` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Proppatch.md b/example/ruby/Net/HTTP/Proppatch.md deleted file mode 100644 index eef1274..0000000 --- a/example/ruby/Net/HTTP/Proppatch.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::HTTP::Proppatch -**Inherits:** Net::HTTPRequest - - -Class for representing [WebDAV method -PROPPATCH](http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Proppatch.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Related: - -* Net::HTTP#proppatch: sends `PROPPATCH` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/ProxyDelta.md b/example/ruby/Net/HTTP/ProxyDelta.md deleted file mode 100644 index be59732..0000000 --- a/example/ruby/Net/HTTP/ProxyDelta.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Net::HTTP::ProxyDelta - - -:nodoc: internal use only - - - diff --git a/example/ruby/Net/HTTP/Put.md b/example/ruby/Net/HTTP/Put.md deleted file mode 100644 index f279cd8..0000000 --- a/example/ruby/Net/HTTP/Put.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Net::HTTP::Put -**Inherits:** Net::HTTPRequest - - -Class for representing [HTTP method -PUT](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#PU -T_method): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - uri.path = '/posts' - req = Net::HTTP::Put.new(uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: yes. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): no. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Net::HTTP.put: sends `PUT` request, returns response object. -* Net::HTTP#put: sends `PUT` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Trace.md b/example/ruby/Net/HTTP/Trace.md deleted file mode 100644 index ede69f3..0000000 --- a/example/ruby/Net/HTTP/Trace.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Net::HTTP::Trace -**Inherits:** Net::HTTPRequest - - -Class for representing [HTTP method -TRACE](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol# -TRACE_method): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Trace.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Properties: - -* Request body: no. -* Response body: yes. -* [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth - ods): yes. -* [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide - mpotent_methods): yes. -* [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach - eable_methods): no. - -Related: - -* Net::HTTP#trace: sends `TRACE` request, returns response object. - - - diff --git a/example/ruby/Net/HTTP/Unlock.md b/example/ruby/Net/HTTP/Unlock.md deleted file mode 100644 index 2d5b8cf..0000000 --- a/example/ruby/Net/HTTP/Unlock.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::HTTP::Unlock -**Inherits:** Net::HTTPRequest - - -Class for representing [WebDAV method -UNLOCK](http://www.webdav.org/specs/rfc4918.html#METHOD_UNLOCK): - - require 'net/http' - uri = URI('http://example.com') - hostname = uri.hostname # => "example.com" - req = Net::HTTP::Unlock.new(uri) # => # - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end - -See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers). - -Related: - -* Net::HTTP#unlock: sends `UNLOCK` request, returns response object. - - - diff --git a/example/ruby/Net/HTTPAccepted.md b/example/ruby/Net/HTTPAccepted.md deleted file mode 100644 index ab03626..0000000 --- a/example/ruby/Net/HTTPAccepted.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPAccepted -**Inherits:** Net::HTTPSuccess - - -Response class for `Accepted` responses (status code 202). - -The `Accepted` response indicates that the server has received and is -processing a request, but the processing has not yet been completed. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-202-accepted). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202). - - - diff --git a/example/ruby/Net/HTTPAlreadyReported.md b/example/ruby/Net/HTTPAlreadyReported.md deleted file mode 100644 index 0b4515b..0000000 --- a/example/ruby/Net/HTTPAlreadyReported.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPAlreadyReported -**Inherits:** Net::HTTPSuccess - - -Response class for `Already Reported (WebDAV)` responses (status code 208). - -The `Already Reported (WebDAV)` response indicates that the server has -received the request, and that the members of a DAV binding have already been -enumerated in a preceding part of the (multi-status) response, and are not -being included again. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 5842](https://www.rfc-editor.org/rfc/rfc5842.html#section-7.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208). - - - diff --git a/example/ruby/Net/HTTPBadGateway.md b/example/ruby/Net/HTTPBadGateway.md deleted file mode 100644 index efc9419..0000000 --- a/example/ruby/Net/HTTPBadGateway.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPBadGateway -**Inherits:** Net::HTTPServerError - - -Response class for `Bad Gateway` responses (status code 502). - -The server was acting as a gateway or proxy and received an invalid response -from the upstream server. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-502-bad-gateway). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502). - - - diff --git a/example/ruby/Net/HTTPBadRequest.md b/example/ruby/Net/HTTPBadRequest.md deleted file mode 100644 index d9736b7..0000000 --- a/example/ruby/Net/HTTPBadRequest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPBadRequest -**Inherits:** Net::HTTPClientError - - -Response class for `Bad Request` responses (status code 400). - -The server cannot or will not process the request due to an apparent client -error. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-400-bad-request). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400). - - - diff --git a/example/ruby/Net/HTTPBadResponse.md b/example/ruby/Net/HTTPBadResponse.md deleted file mode 100644 index 2f81405..0000000 --- a/example/ruby/Net/HTTPBadResponse.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Net::HTTPBadResponse -**Inherits:** StandardError - - -:stopdoc: - - - diff --git a/example/ruby/Net/HTTPClientError.md b/example/ruby/Net/HTTPClientError.md deleted file mode 100644 index 5634e8d..0000000 --- a/example/ruby/Net/HTTPClientError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Net::HTTPClientError -**Inherits:** Net::HTTPResponse - - -Parent class for client error (4xx) HTTP response classes. - -A client error response indicates that the client may have caused an error. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.4xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_cl - ient_errors). - - - diff --git a/example/ruby/Net/HTTPClientException.md b/example/ruby/Net/HTTPClientException.md deleted file mode 100644 index c533ef0..0000000 --- a/example/ruby/Net/HTTPClientException.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Net::HTTPClientException -**Inherits:** Net::ProtoServerError - -**Includes:** Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Net/HTTPConflict.md b/example/ruby/Net/HTTPConflict.md deleted file mode 100644 index f2e7075..0000000 --- a/example/ruby/Net/HTTPConflict.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPConflict -**Inherits:** Net::HTTPClientError - - -Response class for `Conflict` responses (status code 409). - -The request could not be processed because of conflict in the current state of -the resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-409-conflict). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409). - - - diff --git a/example/ruby/Net/HTTPContinue.md b/example/ruby/Net/HTTPContinue.md deleted file mode 100644 index 23f9d4a..0000000 --- a/example/ruby/Net/HTTPContinue.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPContinue -**Inherits:** Net::HTTPInformation - - -Response class for `Continue` responses (status code 100). - -A `Continue` response indicates that the server has received the request -headers. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-100-continue). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100). - - - diff --git a/example/ruby/Net/HTTPCreated.md b/example/ruby/Net/HTTPCreated.md deleted file mode 100644 index 5bda8a4..0000000 --- a/example/ruby/Net/HTTPCreated.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPCreated -**Inherits:** Net::HTTPSuccess - - -Response class for `Created` responses (status code 201). - -The `Created` response indicates that the server has received and has -fulfilled a request to create a new resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-201-created). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201). - - - diff --git a/example/ruby/Net/HTTPEarlyHints.md b/example/ruby/Net/HTTPEarlyHints.md deleted file mode 100644 index dedd0ad..0000000 --- a/example/ruby/Net/HTTPEarlyHints.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPEarlyHints -**Inherits:** Net::HTTPInformation - - -Response class for `Early Hints` responses (status code 103). - -The `Early Hints` indicates that the server has received and is processing the -request, and contains certain headers; the final response is not available -yet. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103). -* [RFC 8297](https://www.rfc-editor.org/rfc/rfc8297.html#section-2). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103). - - - diff --git a/example/ruby/Net/HTTPError.md b/example/ruby/Net/HTTPError.md deleted file mode 100644 index 05f347d..0000000 --- a/example/ruby/Net/HTTPError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Net::HTTPError -**Inherits:** Net::ProtocolError - -**Includes:** Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Net/HTTPExceptions.md b/example/ruby/Net/HTTPExceptions.md deleted file mode 100644 index 98611d6..0000000 --- a/example/ruby/Net/HTTPExceptions.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: Net::HTTPExceptions - - -Net::HTTP exception class. You cannot use Net::HTTPExceptions directly; -instead, you must use its subclasses. - - -# Attributes -## response[RW] [](#attribute-i-response) -Returns the value of attribute response. - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Net/HTTPExpectationFailed.md b/example/ruby/Net/HTTPExpectationFailed.md deleted file mode 100644 index 687bf8b..0000000 --- a/example/ruby/Net/HTTPExpectationFailed.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPExpectationFailed -**Inherits:** Net::HTTPClientError - - -Response class for `Expectation Failed` responses (status code 417). - -The server cannot meet the requirements of the Expect request-header field. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-417-expectation-fai - led). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417). - - - diff --git a/example/ruby/Net/HTTPFailedDependency.md b/example/ruby/Net/HTTPFailedDependency.md deleted file mode 100644 index 08f3a6c..0000000 --- a/example/ruby/Net/HTTPFailedDependency.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPFailedDependency -**Inherits:** Net::HTTPClientError - - -Response class for `Failed Dependency (WebDAV)` responses (status code 424). - -The request failed because it depended on another request and that request -failed. See [424 Failed Dependency -(WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424). - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.4). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424). - - - diff --git a/example/ruby/Net/HTTPFatalError.md b/example/ruby/Net/HTTPFatalError.md deleted file mode 100644 index 79049c0..0000000 --- a/example/ruby/Net/HTTPFatalError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Net::HTTPFatalError -**Inherits:** Net::ProtoFatalError - -**Includes:** Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Net/HTTPForbidden.md b/example/ruby/Net/HTTPForbidden.md deleted file mode 100644 index d164305..0000000 --- a/example/ruby/Net/HTTPForbidden.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPForbidden -**Inherits:** Net::HTTPClientError - - -Response class for `Forbidden` responses (status code 403). - -The request contained valid data and was understood by the server, but the -server is refusing action. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-403-forbidden). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403). - - - diff --git a/example/ruby/Net/HTTPFound.md b/example/ruby/Net/HTTPFound.md deleted file mode 100644 index aa27f32..0000000 --- a/example/ruby/Net/HTTPFound.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPFound -**Inherits:** Net::HTTPRedirection - - -Response class for `Found` responses (status code 302). - -The `Found` response indicates that the client should look at (browse to) -another URL. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-302-found). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302). - - - diff --git a/example/ruby/Net/HTTPGatewayTimeout.md b/example/ruby/Net/HTTPGatewayTimeout.md deleted file mode 100644 index 71161ca..0000000 --- a/example/ruby/Net/HTTPGatewayTimeout.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPGatewayTimeout -**Inherits:** Net::HTTPServerError - - -Response class for `Gateway Timeout` responses (status code 504). - -The server was acting as a gateway or proxy and did not receive a timely -response from the upstream server. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-504-gateway-timeout - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504). - - - diff --git a/example/ruby/Net/HTTPGenericRequest.md b/example/ruby/Net/HTTPGenericRequest.md deleted file mode 100644 index af95c9e..0000000 --- a/example/ruby/Net/HTTPGenericRequest.md +++ /dev/null @@ -1,612 +0,0 @@ -# Class: Net::HTTPGenericRequest -**Inherits:** Object - -**Includes:** Net::HTTPHeader - - -HTTPGenericRequest is the parent of the Net::HTTPRequest class. - -Do not use this directly; instead, use a subclass of Net::HTTPRequest. - -## About the Examples - -:include: doc/net-http/examples.rdoc - - -# Attributes -## body[RW] [](#attribute-i-body) -Returns the string body for the request, or `nil` if there is none: - - req = Net::HTTP::Post.new(uri) - req.body # => nil - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}" - -## body_stream[RW] [](#attribute-i-body_stream) -Returns the body stream object for the request, or `nil` if there is none: - - req = Net::HTTP::Post.new(uri) # => # - req.body_stream # => nil - require 'stringio' - req.body_stream = StringIO.new('xyzzy') # => # - req.body_stream # => # - -## decode_content[RW] [](#attribute-i-decode_content) -Returns `false` if the request's header `'Accept-Encoding'` has been set -manually or deleted (indicating that the user intends to handle encoding in -the response), `true` otherwise: - - req = Net::HTTP::Get.new(uri) # => # - req['Accept-Encoding'] # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" - req.decode_content # => true - req['Accept-Encoding'] = 'foo' - req.decode_content # => false - req.delete('Accept-Encoding') - req.decode_content # => false - -## method[RW] [](#attribute-i-method) -Returns the string method name for the request: - - Net::HTTP::Get.new(uri).method # => "GET" - Net::HTTP::Post.new(uri).method # => "POST" - -## path[RW] [](#attribute-i-path) -Returns the string path for the request: - - Net::HTTP::Get.new(uri).path # => "/" - Net::HTTP::Post.new('example.com').path # => "example.com" - -## uri[RW] [](#attribute-i-uri) -Returns the URI object for the request, or `nil` if none: - - Net::HTTP::Get.new(uri).uri - # => # - Net::HTTP::Get.new('example.com').uri # => nil - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Don't automatically decode response content-encoding if the user indicates -they want to handle it. - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## body_exist?() [](#method-i-body_exist?) -:nodoc: - -**@return** [Boolean] - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Net::HTTPHeader#canonical_each is an alias for -Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## exec(sock, ver, path) [](#method-i-exec) -write - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## initialize(m, reqbody, resbody, uri_or_path, initheadernil) [](#method-i-initialize) -:nodoc: - -**@return** [HTTPGenericRequest] a new instance of HTTPGenericRequest - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a string representation of the request: - - Net::HTTP::Post.new(uri).inspect # => "#" - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## request_body_permitted?() [](#method-i-request_body_permitted?) -Returns whether the request may have a body: - - Net::HTTP::Post.new(uri).request_body_permitted? # => true - Net::HTTP::Get.new(uri).request_body_permitted? # => false - -**@return** [Boolean] - -## response_body_permitted?() [](#method-i-response_body_permitted?) -Returns whether the response may have a body: - - Net::HTTP::Post.new(uri).response_body_permitted? # => true - Net::HTTP::Head.new(uri).response_body_permitted? # => false - -**@return** [Boolean] - -## set_body_internal(str) [](#method-i-set_body_internal) -:nodoc: internal use only - -**@raise** [ArgumentError] - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Net::HTTPHeader#content_type= is an alias for -Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) (method -`params.map` will be called), and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[URI.encode_www_form](rdoc-ref:URI.encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - -## update_uri(addr, port, ssl) [](#method-i-update_uri) -:nodoc: internal use only - diff --git a/example/ruby/Net/HTTPGenericRequest/Chunker.md b/example/ruby/Net/HTTPGenericRequest/Chunker.md deleted file mode 100644 index 10a23bd..0000000 --- a/example/ruby/Net/HTTPGenericRequest/Chunker.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Net::HTTPGenericRequest::Chunker -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## finish() [](#method-i-finish) - -## initialize(sock) [](#method-i-initialize) - -**@return** [Chunker] a new instance of Chunker - -## write(buf) [](#method-i-write) - diff --git a/example/ruby/Net/HTTPGone.md b/example/ruby/Net/HTTPGone.md deleted file mode 100644 index 42c3095..0000000 --- a/example/ruby/Net/HTTPGone.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPGone -**Inherits:** Net::HTTPClientError - - -Response class for `Gone` responses (status code 410). - -The resource requested was previously in use but is no longer available and -will not be available again. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-410-gone). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410). - - - diff --git a/example/ruby/Net/HTTPHeader.md b/example/ruby/Net/HTTPHeader.md deleted file mode 100644 index 0d8ec3c..0000000 --- a/example/ruby/Net/HTTPHeader.md +++ /dev/null @@ -1,703 +0,0 @@ -# Module: Net::HTTPHeader - - -The HTTPHeader module provides access to HTTP headers. - -The module is included in: - -* Net::HTTPGenericRequest (and therefore Net::HTTPRequest). -* Net::HTTPResponse. - -The headers are a hash-like collection of key/value pairs called *fields*. - -## Request and Response Fields - -Headers may be included in: - -* A Net::HTTPRequest object: the object's headers will be sent with the - request. Any fields may be defined in the request; see - [Setters](rdoc-ref:Net::HTTPHeader@Setters). -* A Net::HTTPResponse object: the objects headers are usually those returned - from the host. Fields may be retrieved from the object; see - [Getters](rdoc-ref:Net::HTTPHeader@Getters) and - [Iterators](rdoc-ref:Net::HTTPHeader@Iterators). - -Exactly which fields should be sent or expected depends on the host; see: - -* [Request - fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_f - ields). -* [Response - fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_ - fields). - -## About the Examples - -:include: doc/net-http/examples.rdoc - -## Fields - -A header field is a key/value pair. - -### Field Keys - -A field key may be: - -* A string: Key `'Accept'` is treated as if it were `'Accept'.downcase`; - i.e., `'accept'`. -* A symbol: Key `:Accept` is treated as if it were `:Accept.to_s.downcase`; - i.e., `'accept'`. - -Examples: - - req = Net::HTTP::Get.new(uri) - req[:accept] # => "*/*" - req['Accept'] # => "*/*" - req['ACCEPT'] # => "*/*" - - req['accept'] = 'text/html' - req[:accept] = 'text/html' - req['ACCEPT'] = 'text/html' - -### Field Values - -A field value may be returned as an array of strings or as a string: - -* These methods return field values as arrays: - - * #get_fields: Returns the array value for the given key, or `nil` if it - does not exist. - * #to_hash: Returns a hash of all header fields: each key is a field - name; its value is the array value for the field. - -* These methods return field values as string; the string value for a field - is equivalent to `self[key.downcase.to_s].join(', '))`: - - * #[]: Returns the string value for the given key, or `nil` if it does - not exist. - * #fetch: Like #[], but accepts a default value to be returned if the - key does not exist. - -The field value may be set: - -* #[]=: Sets the value for the given key; the given value may be a string, a - symbol, an array, or a hash. -* #add_field: Adds a given value to a value for the given key (not - overwriting the existing value). -* #delete: Deletes the field for the given key. - -Example field values: - -* String: - - req['Accept'] = 'text/html' # => "text/html" - req['Accept'] # => "text/html" - req.get_fields('Accept') # => ["text/html"] - -* Symbol: - - req['Accept'] = :text # => :text - req['Accept'] # => "text" - req.get_fields('Accept') # => ["text"] - -* Simple array: - - req[:foo] = %w[bar baz bat] - req[:foo] # => "bar, baz, bat" - req.get_fields(:foo) # => ["bar", "baz", "bat"] - -* Simple hash: - - req[:foo] = {bar: 0, baz: 1, bat: 2} - req[:foo] # => "bar, 0, baz, 1, bat, 2" - req.get_fields(:foo) # => ["bar", "0", "baz", "1", "bat", "2"] - -* Nested: - - req[:foo] = [%w[bar baz], {bat: 0, bam: 1}] - req[:foo] # => "bar, baz, bat, 0, bam, 1" - req.get_fields(:foo) # => ["bar", "baz", "bat", "0", "bam", "1"] - - req[:foo] = {bar: %w[baz bat], bam: {bah: 0, bad: 1}} - req[:foo] # => "bar, baz, bat, bam, bah, 0, bad, 1" - req.get_fields(:foo) # => ["bar", "baz", "bat", "bam", "bah", "0", "bad", "1"] - -## Convenience Methods - -Various convenience methods retrieve values, set values, query values, set -form values, or iterate over fields. - -### Setters - -Method #[]= can set any field, but does little to validate the new value; some -of the other setter methods provide some validation: - -* #[]=: Sets the string or array value for the given key. -* #add_field: Creates or adds to the array value for the given key. -* #basic_auth: Sets the string authorization header for `'Authorization'`. -* #content_length=: Sets the integer length for field `'Content-Length`. -* #content_type=: Sets the string value for field `'Content-Type'`. -* #proxy_basic_auth: Sets the string authorization header for - `'Proxy-Authorization'`. -* #set_range: Sets the value for field `'Range'`. - -### Form Setters - -* #set_form: Sets an HTML form data set. -* #set_form_data: Sets header fields and a body from HTML form data. - -### Getters - -Method #[] can retrieve the value of any field that exists, but always as a -string; some of the other getter methods return something different from the -simple string value: - -* #[]: Returns the string field value for the given key. -* #content_length: Returns the integer value of field `'Content-Length'`. -* #content_range: Returns the Range value of field `'Content-Range'`. -* #content_type: Returns the string value of field `'Content-Type'`. -* #fetch: Returns the string field value for the given key. -* #get_fields: Returns the array field value for the given `key`. -* #main_type: Returns first part of the string value of field - `'Content-Type'`. -* #sub_type: Returns second part of the string value of field - `'Content-Type'`. -* #range: Returns an array of Range objects of field `'Range'`, or `nil`. -* #range_length: Returns the integer length of the range given in field - `'Content-Range'`. -* #type_params: Returns the string parameters for `'Content-Type'`. - -### Queries - -* #chunked?: Returns whether field `'Transfer-Encoding'` is set to - `'chunked'`. -* #connection_close?: Returns whether field `'Connection'` is set to - `'close'`. -* #connection_keep_alive?: Returns whether field `'Connection'` is set to - `'keep-alive'`. -* #key?: Returns whether a given key exists. - -### Iterators - -* #each_capitalized: Passes each field capitalized-name/value pair to the - block. -* #each_capitalized_name: Passes each capitalized field name to the block. -* #each_header: Passes each field name/value pair to the block. -* #each_name: Passes each field name to the block. -* #each_value: Passes each string field value to the block. - - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Sets the value for the case-insensitive `key` to `val`, overwriting the -previous value if the field exists; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req['Accept'] # => "*/*" - req['Accept'] = 'text/html' - req['Accept'] # => "text/html" - -Note that some field values may be set via convenience methods; see -[Setters](rdoc-ref:Net::HTTPHeader@Setters). - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Net::HTTPHeader#canonical_each is an alias for -Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Net::HTTPHeader#content_type= is an alias for -Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) (method -`params.map` will be called), and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[URI.encode_www_form](rdoc-ref:URI.encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - diff --git a/example/ruby/Net/HTTPHeaderSyntaxError.md b/example/ruby/Net/HTTPHeaderSyntaxError.md deleted file mode 100644 index a8743c7..0000000 --- a/example/ruby/Net/HTTPHeaderSyntaxError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::HTTPHeaderSyntaxError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Net/HTTPIMUsed.md b/example/ruby/Net/HTTPIMUsed.md deleted file mode 100644 index 3cac422..0000000 --- a/example/ruby/Net/HTTPIMUsed.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPIMUsed -**Inherits:** Net::HTTPSuccess - - -Response class for `IM Used` responses (status code 226). - -The `IM Used` response indicates that the server has fulfilled a request for -the resource, and the response is a representation of the result of one or -more instance-manipulations applied to the current instance. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 3229](https://www.rfc-editor.org/rfc/rfc3229.html#section-10.4.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226). - - - diff --git a/example/ruby/Net/HTTPInformation.md b/example/ruby/Net/HTTPInformation.md deleted file mode 100644 index 24a267f..0000000 --- a/example/ruby/Net/HTTPInformation.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Net::HTTPInformation -**Inherits:** Net::HTTPResponse - - -Parent class for informational (1xx) HTTP response classes. - -An informational response indicates that the request was received and -understood. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.1xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_in - formational_response). - - - diff --git a/example/ruby/Net/HTTPInsufficientStorage.md b/example/ruby/Net/HTTPInsufficientStorage.md deleted file mode 100644 index 7f0e856..0000000 --- a/example/ruby/Net/HTTPInsufficientStorage.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPInsufficientStorage -**Inherits:** Net::HTTPServerError - - -Response class for `Insufficient Storage (WebDAV)` responses (status code -507). - -The server is unable to store the representation needed to complete the -request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507). -* [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.5). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507). - - - diff --git a/example/ruby/Net/HTTPInternalServerError.md b/example/ruby/Net/HTTPInternalServerError.md deleted file mode 100644 index 7cfb631..0000000 --- a/example/ruby/Net/HTTPInternalServerError.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPInternalServerError -**Inherits:** Net::HTTPServerError - - -Response class for `Internal Server Error` responses (status code 500). - -An unexpected condition was encountered and no more specific message is -suitable. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-500-internal-server - -error). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500). - - - diff --git a/example/ruby/Net/HTTPLengthRequired.md b/example/ruby/Net/HTTPLengthRequired.md deleted file mode 100644 index 4ff9055..0000000 --- a/example/ruby/Net/HTTPLengthRequired.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPLengthRequired -**Inherits:** Net::HTTPClientError - - -Response class for `Length Required` responses (status code 411). - -The request did not specify the length of its content, which is required by -the requested resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-411-length-required - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411). - - - diff --git a/example/ruby/Net/HTTPLocked.md b/example/ruby/Net/HTTPLocked.md deleted file mode 100644 index 9de468c..0000000 --- a/example/ruby/Net/HTTPLocked.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Net::HTTPLocked -**Inherits:** Net::HTTPClientError - - -Response class for `Locked (WebDAV)` responses (status code 423). - -The requested resource is locked. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.3). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423). - - - diff --git a/example/ruby/Net/HTTPLoopDetected.md b/example/ruby/Net/HTTPLoopDetected.md deleted file mode 100644 index b36d433..0000000 --- a/example/ruby/Net/HTTPLoopDetected.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Net::HTTPLoopDetected -**Inherits:** Net::HTTPServerError - - -Response class for `Loop Detected (WebDAV)` responses (status code 508). - -The server detected an infinite loop while processing the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508). -* [RFC 5942](https://www.rfc-editor.org/rfc/rfc5842.html#section-7.2). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508). - - - diff --git a/example/ruby/Net/HTTPMethodNotAllowed.md b/example/ruby/Net/HTTPMethodNotAllowed.md deleted file mode 100644 index af9660b..0000000 --- a/example/ruby/Net/HTTPMethodNotAllowed.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPMethodNotAllowed -**Inherits:** Net::HTTPClientError - - -Response class for `Method Not Allowed` responses (status code 405). - -The request method is not supported for the requested resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-405-method-not-allo - wed). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405). - - - diff --git a/example/ruby/Net/HTTPMisdirectedRequest.md b/example/ruby/Net/HTTPMisdirectedRequest.md deleted file mode 100644 index 0da6845..0000000 --- a/example/ruby/Net/HTTPMisdirectedRequest.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPMisdirectedRequest -**Inherits:** Net::HTTPClientError - - -Response class for `Misdirected Request` responses (status code 421). - -The request was directed at a server that is not able to produce a response. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-421-misdirected-req - uest). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421). - - - diff --git a/example/ruby/Net/HTTPMovedPermanently.md b/example/ruby/Net/HTTPMovedPermanently.md deleted file mode 100644 index b6c1537..0000000 --- a/example/ruby/Net/HTTPMovedPermanently.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPMovedPermanently -**Inherits:** Net::HTTPRedirection - - -Response class for `Moved Permanently` responses (status code 301). - -The `Moved Permanently` response indicates that links or records returning -this response should be updated to use the given URL. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-301-moved-permanent - ly). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301). - - - diff --git a/example/ruby/Net/HTTPMultiStatus.md b/example/ruby/Net/HTTPMultiStatus.md deleted file mode 100644 index 952e8f3..0000000 --- a/example/ruby/Net/HTTPMultiStatus.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPMultiStatus -**Inherits:** Net::HTTPSuccess - - -Response class for `Multi-Status (WebDAV)` responses (status code 207). - -The `Multi-Status (WebDAV)` response indicates that the server has received -the request, and that the message body can contain a number of separate -response codes. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 4818](https://www.rfc-editor.org/rfc/rfc4918#section-11.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207). - - - diff --git a/example/ruby/Net/HTTPMultipleChoices.md b/example/ruby/Net/HTTPMultipleChoices.md deleted file mode 100644 index 1484130..0000000 --- a/example/ruby/Net/HTTPMultipleChoices.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPMultipleChoices -**Inherits:** Net::HTTPRedirection - - -Response class for `Multiple Choices` responses (status code 300). - -The `Multiple Choices` response indicates that the server offers multiple -options for the resource from which the client may choose. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-300-multiple-choice - s). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300). - - - diff --git a/example/ruby/Net/HTTPNetworkAuthenticationRequired.md b/example/ruby/Net/HTTPNetworkAuthenticationRequired.md deleted file mode 100644 index 61087f6..0000000 --- a/example/ruby/Net/HTTPNetworkAuthenticationRequired.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPNetworkAuthenticationRequired -**Inherits:** Net::HTTPServerError - - -Response class for `Network Authentication Required` responses (status code -511). - -The client needs to authenticate to gain network access. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511). -* [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-6). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511). - - - diff --git a/example/ruby/Net/HTTPNoContent.md b/example/ruby/Net/HTTPNoContent.md deleted file mode 100644 index 0d1ce9e..0000000 --- a/example/ruby/Net/HTTPNoContent.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPNoContent -**Inherits:** Net::HTTPSuccess - - -Response class for `No Content` responses (status code 204). - -The `No Content` response indicates that the server successfully processed the -request, and is not returning any content. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-204-no-content). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204). - - - diff --git a/example/ruby/Net/HTTPNonAuthoritativeInformation.md b/example/ruby/Net/HTTPNonAuthoritativeInformation.md deleted file mode 100644 index 7797ac0..0000000 --- a/example/ruby/Net/HTTPNonAuthoritativeInformation.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::HTTPNonAuthoritativeInformation -**Inherits:** Net::HTTPSuccess - - -Response class for `Non-Authoritative Information` responses (status code -203). - -The `Non-Authoritative Information` response indicates that the server is a -transforming proxy (such as a Web accelerator) that received a 200 OK response -from its origin, and is returning a modified version of the origin's response. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-203-non-authoritati - ve-infor). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203). - - - diff --git a/example/ruby/Net/HTTPNotAcceptable.md b/example/ruby/Net/HTTPNotAcceptable.md deleted file mode 100644 index 0d4c525..0000000 --- a/example/ruby/Net/HTTPNotAcceptable.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPNotAcceptable -**Inherits:** Net::HTTPClientError - - -Response class for `Not Acceptable` responses (status code 406). - -The requested resource is capable of generating only content that not -acceptable according to the Accept headers sent in the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-406-not-acceptable) - . -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406). - - - diff --git a/example/ruby/Net/HTTPNotExtended.md b/example/ruby/Net/HTTPNotExtended.md deleted file mode 100644 index aef39c9..0000000 --- a/example/ruby/Net/HTTPNotExtended.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Net::HTTPNotExtended -**Inherits:** Net::HTTPServerError - - -Response class for `Not Extended` responses (status code 510). - -Further extensions to the request are required for the server to fulfill it. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510). -* [RFC 2774](https://www.rfc-editor.org/rfc/rfc2774.html#section-7). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510). - - - diff --git a/example/ruby/Net/HTTPNotFound.md b/example/ruby/Net/HTTPNotFound.md deleted file mode 100644 index 756748f..0000000 --- a/example/ruby/Net/HTTPNotFound.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPNotFound -**Inherits:** Net::HTTPClientError - - -Response class for `Not Found` responses (status code 404). - -The requested resource could not be found but may be available in the future. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404). - - - diff --git a/example/ruby/Net/HTTPNotImplemented.md b/example/ruby/Net/HTTPNotImplemented.md deleted file mode 100644 index 1e72918..0000000 --- a/example/ruby/Net/HTTPNotImplemented.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPNotImplemented -**Inherits:** Net::HTTPServerError - - -Response class for `Not Implemented` responses (status code 501). - -The server either does not recognize the request method, or it lacks the -ability to fulfil the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-501-not-implemented - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501). - - - diff --git a/example/ruby/Net/HTTPNotModified.md b/example/ruby/Net/HTTPNotModified.md deleted file mode 100644 index 70d3130..0000000 --- a/example/ruby/Net/HTTPNotModified.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPNotModified -**Inherits:** Net::HTTPRedirection - - -Response class for `Not Modified` responses (status code 304). - -Indicates that the resource has not been modified since the version specified -by the request headers. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-304-not-modified). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304). - - - diff --git a/example/ruby/Net/HTTPOK.md b/example/ruby/Net/HTTPOK.md deleted file mode 100644 index 0862d39..0000000 --- a/example/ruby/Net/HTTPOK.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPOK -**Inherits:** Net::HTTPSuccess - - -Response class for `OK` responses (status code 200). - -The `OK` response indicates that the server has received a request and has -responded successfully. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200). -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200). - - - diff --git a/example/ruby/Net/HTTPPartialContent.md b/example/ruby/Net/HTTPPartialContent.md deleted file mode 100644 index 53ec48b..0000000 --- a/example/ruby/Net/HTTPPartialContent.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPPartialContent -**Inherits:** Net::HTTPSuccess - - -Response class for `Partial Content` responses (status code 206). - -The `Partial Content` response indicates that the server is delivering only -part of the resource (byte serving) due to a Range header in the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-206-partial-content - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206). - - - diff --git a/example/ruby/Net/HTTPPayloadTooLarge.md b/example/ruby/Net/HTTPPayloadTooLarge.md deleted file mode 100644 index 4393526..0000000 --- a/example/ruby/Net/HTTPPayloadTooLarge.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPPayloadTooLarge -**Inherits:** Net::HTTPClientError - - -Response class for `Payload Too Large` responses (status code 413). - -The request is larger than the server is willing or able to process. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-413-content-too-lar - ge). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413). - - - diff --git a/example/ruby/Net/HTTPPaymentRequired.md b/example/ruby/Net/HTTPPaymentRequired.md deleted file mode 100644 index dbd3892..0000000 --- a/example/ruby/Net/HTTPPaymentRequired.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPPaymentRequired -**Inherits:** Net::HTTPClientError - - -Response class for `Payment Required` responses (status code 402). - -Reserved for future use. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-402-payment-require - d). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402). - - - diff --git a/example/ruby/Net/HTTPPermanentRedirect.md b/example/ruby/Net/HTTPPermanentRedirect.md deleted file mode 100644 index 98a2851..0000000 --- a/example/ruby/Net/HTTPPermanentRedirect.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPPermanentRedirect -**Inherits:** Net::HTTPRedirection - - -Response class for `Permanent Redirect` responses (status code 308). - -This and all future requests should be directed to the given URI. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-308-permanent-redir - ect). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308). - - - diff --git a/example/ruby/Net/HTTPPreconditionFailed.md b/example/ruby/Net/HTTPPreconditionFailed.md deleted file mode 100644 index a90d17f..0000000 --- a/example/ruby/Net/HTTPPreconditionFailed.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPPreconditionFailed -**Inherits:** Net::HTTPClientError - - -Response class for `Precondition Failed` responses (status code 412). - -The server does not meet one of the preconditions specified in the request -headers. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-412-precondition-fa - iled). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412). - - - diff --git a/example/ruby/Net/HTTPPreconditionRequired.md b/example/ruby/Net/HTTPPreconditionRequired.md deleted file mode 100644 index 96bf9b7..0000000 --- a/example/ruby/Net/HTTPPreconditionRequired.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Net::HTTPPreconditionRequired -**Inherits:** Net::HTTPClientError - - -Response class for `Precondition Required` responses (status code 428). - -The origin server requires the request to be conditional. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428). -* [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-3). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428). - - - diff --git a/example/ruby/Net/HTTPProcessing.md b/example/ruby/Net/HTTPProcessing.md deleted file mode 100644 index be71623..0000000 --- a/example/ruby/Net/HTTPProcessing.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Net::HTTPProcessing -**Inherits:** Net::HTTPInformation - - -Response class for `Processing` responses (status code 102). - -The `Processing` response indicates that the server has received and is -processing the request, but no response is available yet. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC 2518](https://www.rfc-editor.org/rfc/rfc2518#section-10.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102). - - - diff --git a/example/ruby/Net/HTTPProxyAuthenticationRequired.md b/example/ruby/Net/HTTPProxyAuthenticationRequired.md deleted file mode 100644 index 98b5d1b..0000000 --- a/example/ruby/Net/HTTPProxyAuthenticationRequired.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPProxyAuthenticationRequired -**Inherits:** Net::HTTPClientError - - -Response class for `Proxy Authentication Required` responses (status code -407). - -The client must first authenticate itself with the proxy. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-407-proxy-authentic - ation-re). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407). - - - diff --git a/example/ruby/Net/HTTPRangeNotSatisfiable.md b/example/ruby/Net/HTTPRangeNotSatisfiable.md deleted file mode 100644 index 0afca36..0000000 --- a/example/ruby/Net/HTTPRangeNotSatisfiable.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPRangeNotSatisfiable -**Inherits:** Net::HTTPClientError - - -Response class for `Range Not Satisfiable` responses (status code 416). - -The request entity has a media type which the server or resource does not -support. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-416-range-not-satis - fiable). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416). - - - diff --git a/example/ruby/Net/HTTPRedirection.md b/example/ruby/Net/HTTPRedirection.md deleted file mode 100644 index 2b9d17d..0000000 --- a/example/ruby/Net/HTTPRedirection.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Net::HTTPRedirection -**Inherits:** Net::HTTPResponse - - -Parent class for redirection (3xx) HTTP response classes. - -A redirection response indicates the client must take additional action to -complete the request. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.3xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_re - direction). - - - diff --git a/example/ruby/Net/HTTPRequest.md b/example/ruby/Net/HTTPRequest.md deleted file mode 100644 index 5cf5742..0000000 --- a/example/ruby/Net/HTTPRequest.md +++ /dev/null @@ -1,95 +0,0 @@ -# Class: Net::HTTPRequest -**Inherits:** Net::HTTPGenericRequest - - -This class is the base class for Net::HTTP request classes. The class should -not be used directly; instead you should use its subclasses, listed below. - -## Creating a Request - -An request object may be created with either a URI or a string hostname: - - require 'net/http' - uri = URI('https://jsonplaceholder.typicode.com/') - req = Net::HTTP::Get.new(uri) # => # - req = Net::HTTP::Get.new(uri.hostname) # => # - -And with any of the subclasses: - - req = Net::HTTP::Head.new(uri) # => # - req = Net::HTTP::Post.new(uri) # => # - req = Net::HTTP::Put.new(uri) # => # - # ... - -The new instance is suitable for use as the argument to Net::HTTP#request. - -## Request Headers - -A new request object has these header fields by default: - - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -See: - -* [Request header - Accept-Encoding](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields# - Accept-Encoding) and [Compression and - Decompression](rdoc-ref:Net::HTTP@Compression+and+Decompression). -* [Request header - Accept](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#accept-re - quest-header). -* [Request header - User-Agent](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#user- - agent-request-header). -* [Request header - Host](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#host-reques - t-header). - -You can add headers or override default headers: - - # res = Net::HTTP::Get.new(uri, {'foo' => '0', 'bar' => '1'}) - -This class (and therefore its subclasses) also includes (indirectly) module -Net::HTTPHeader, which gives access to its [methods for setting -headers](rdoc-ref:Net::HTTPHeader@Setters). - -## Request Subclasses - -Subclasses for HTTP requests: - -* Net::HTTP::Get -* Net::HTTP::Head -* Net::HTTP::Post -* Net::HTTP::Put -* Net::HTTP::Delete -* Net::HTTP::Options -* Net::HTTP::Trace -* Net::HTTP::Patch - -Subclasses for WebDAV requests: - -* Net::HTTP::Propfind -* Net::HTTP::Proppatch -* Net::HTTP::Mkcol -* Net::HTTP::Copy -* Net::HTTP::Move -* Net::HTTP::Lock -* Net::HTTP::Unlock - - - -#Instance Methods -## initialize(path, initheadernil) [](#method-i-initialize) -Creates an HTTP request object for `path`. - -`initheader` are the default headers to use. Net::HTTP adds Accept-Encoding -to enable compression of the response body unless Accept-Encoding or Range are -supplied in `initheader`. - -**@return** [HTTPRequest] a new instance of HTTPRequest - diff --git a/example/ruby/Net/HTTPRequestHeaderFieldsTooLarge.md b/example/ruby/Net/HTTPRequestHeaderFieldsTooLarge.md deleted file mode 100644 index 721b860..0000000 --- a/example/ruby/Net/HTTPRequestHeaderFieldsTooLarge.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPRequestHeaderFieldsTooLarge -**Inherits:** Net::HTTPClientError - - -Response class for `Request Header Fields Too Large` responses (status code -431). - -An individual header field is too large, or all the header fields -collectively, are too large. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431). -* [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-5). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431). - - - diff --git a/example/ruby/Net/HTTPRequestTimeout.md b/example/ruby/Net/HTTPRequestTimeout.md deleted file mode 100644 index 1b9bcf8..0000000 --- a/example/ruby/Net/HTTPRequestTimeout.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPRequestTimeout -**Inherits:** Net::HTTPClientError - - -Response class for `Request Timeout` responses (status code 408). - -The server timed out waiting for the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-408-request-timeout - ). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408). - - - diff --git a/example/ruby/Net/HTTPResetContent.md b/example/ruby/Net/HTTPResetContent.md deleted file mode 100644 index 28acaae..0000000 --- a/example/ruby/Net/HTTPResetContent.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPResetContent -**Inherits:** Net::HTTPSuccess - - -Response class for `Reset Content` responses (status code 205). - -The `Reset Content` response indicates that the server successfully processed -the request, asks that the client reset its document view, and is not -returning any content. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-205-reset-content). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205). - - - diff --git a/example/ruby/Net/HTTPResponse.md b/example/ruby/Net/HTTPResponse.md deleted file mode 100644 index bbebf4b..0000000 --- a/example/ruby/Net/HTTPResponse.md +++ /dev/null @@ -1,771 +0,0 @@ -# Class: Net::HTTPResponse -**Inherits:** Object - -**Includes:** Net::HTTPHeader - - -This class is the base class for Net::HTTP response classes. - -## About the Examples - -:include: doc/net-http/examples.rdoc - -## Returned Responses - -Method Net::HTTP.get_response returns an instance of one of the subclasses of -Net::HTTPResponse: - - Net::HTTP.get_response(uri) - # => # - Net::HTTP.get_response(hostname, '/nosuch') - # => # - -As does method Net::HTTP#request: - - req = Net::HTTP::Get.new(uri) - Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -Class Net::HTTPResponse includes module Net::HTTPHeader, which provides access -to response header values via (among others): - -* Hash-like method `[]`. -* Specific reader methods, such as `content_type`. - -Examples: - - res = Net::HTTP.get_response(uri) # => # - res['Content-Type'] # => "text/html; charset=UTF-8" - res.content_type # => "text/html" - -## Response Subclasses - -Class Net::HTTPResponse has a subclass for each [HTTP status -code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). You can look -up the response class for a given code: - - Net::HTTPResponse::CODE_TO_OBJ['200'] # => Net::HTTPOK - Net::HTTPResponse::CODE_TO_OBJ['400'] # => Net::HTTPBadRequest - Net::HTTPResponse::CODE_TO_OBJ['404'] # => Net::HTTPNotFound - -And you can retrieve the status code for a response object: - - Net::HTTP.get_response(uri).code # => "200" - Net::HTTP.get_response(hostname, '/nosuch').code # => "404" - -The response subclasses (indentation shows class hierarchy): - -* Net::HTTPUnknownResponse (for unhandled HTTP extensions). - -* Net::HTTPInformation: - - * Net::HTTPContinue (100) - * Net::HTTPSwitchProtocol (101) - * Net::HTTPProcessing (102) - * Net::HTTPEarlyHints (103) - -* Net::HTTPSuccess: - - * Net::HTTPOK (200) - * Net::HTTPCreated (201) - * Net::HTTPAccepted (202) - * Net::HTTPNonAuthoritativeInformation (203) - * Net::HTTPNoContent (204) - * Net::HTTPResetContent (205) - * Net::HTTPPartialContent (206) - * Net::HTTPMultiStatus (207) - * Net::HTTPAlreadyReported (208) - * Net::HTTPIMUsed (226) - -* Net::HTTPRedirection: - - * Net::HTTPMultipleChoices (300) - * Net::HTTPMovedPermanently (301) - * Net::HTTPFound (302) - * Net::HTTPSeeOther (303) - * Net::HTTPNotModified (304) - * Net::HTTPUseProxy (305) - * Net::HTTPTemporaryRedirect (307) - * Net::HTTPPermanentRedirect (308) - -* Net::HTTPClientError: - - * Net::HTTPBadRequest (400) - * Net::HTTPUnauthorized (401) - * Net::HTTPPaymentRequired (402) - * Net::HTTPForbidden (403) - * Net::HTTPNotFound (404) - * Net::HTTPMethodNotAllowed (405) - * Net::HTTPNotAcceptable (406) - * Net::HTTPProxyAuthenticationRequired (407) - * Net::HTTPRequestTimeOut (408) - * Net::HTTPConflict (409) - * Net::HTTPGone (410) - * Net::HTTPLengthRequired (411) - * Net::HTTPPreconditionFailed (412) - * Net::HTTPRequestEntityTooLarge (413) - * Net::HTTPRequestURITooLong (414) - * Net::HTTPUnsupportedMediaType (415) - * Net::HTTPRequestedRangeNotSatisfiable (416) - * Net::HTTPExpectationFailed (417) - * Net::HTTPMisdirectedRequest (421) - * Net::HTTPUnprocessableEntity (422) - * Net::HTTPLocked (423) - * Net::HTTPFailedDependency (424) - * Net::HTTPUpgradeRequired (426) - * Net::HTTPPreconditionRequired (428) - * Net::HTTPTooManyRequests (429) - * Net::HTTPRequestHeaderFieldsTooLarge (431) - * Net::HTTPUnavailableForLegalReasons (451) - -* Net::HTTPServerError: - - * Net::HTTPInternalServerError (500) - * Net::HTTPNotImplemented (501) - * Net::HTTPBadGateway (502) - * Net::HTTPServiceUnavailable (503) - * Net::HTTPGatewayTimeOut (504) - * Net::HTTPVersionNotSupported (505) - * Net::HTTPVariantAlsoNegotiates (506) - * Net::HTTPInsufficientStorage (507) - * Net::HTTPLoopDetected (508) - * Net::HTTPNotExtended (510) - * Net::HTTPNetworkAuthenticationRequired (511) - -There is also the Net::HTTPBadResponse exception which is raised when there is -a protocol error. - - -# Class Methods -## body_permitted?() [](#method-c-body_permitted?) -true if the response has a body. -**@return** [Boolean] - -## exception_type() [](#method-c-exception_type) -:nodoc: internal use only -## read_new(sock ) [](#method-c-read_new) -:nodoc: internal use only -# Attributes -## body_encoding[RW] [](#attribute-i-body_encoding) -Returns the value set by body_encoding=, or `false` if none; see -#body_encoding=. - -## code[RW] [](#attribute-i-code) -The HTTP result code string. For example, '302'. You can also determine the -response type by examining which response subclass the response object is an -instance of. - -## decode_content[RW] [](#attribute-i-decode_content) -Set to true automatically when the request did not contain an Accept-Encoding -header from the user. - -## http_version[RW] [](#attribute-i-http_version) -The HTTP version supported by the server. - -## ignore_eof[RW] [](#attribute-i-ignore_eof) -Whether to ignore EOF when reading bodies with a specified Content-Length -header. - -## message[RW] [](#attribute-i-message) -The HTTP result message sent by the server. For example, 'Not Found'. - -## uri[RW] [](#attribute-i-uri) -The URI used to fetch this response. The response URI is only available if a -URI was used to create the request. - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Sets the value for the case-insensitive `key` to `val`, overwriting the -previous value if the field exists; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req['Accept'] # => "*/*" - req['Accept'] = 'text/html' - req['Accept'] # => "text/html" - -Note that some field values may be set via convenience methods; see -[Setters](rdoc-ref:Net::HTTPHeader@Setters). - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## body() [](#method-i-body) -Returns the string response body; note that repeated calls for the unmodified -body return a cached string: - - path = '/todos/1' - Net::HTTP.start(hostname) do |http| - res = http.get(path) - p res.body - p http.head(path).body # No body. - end - -Output: - - "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}" - nil - -## body=(value) [](#method-i-body=) -Sets the body of the response to the given value. - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## code_type() [](#method-i-code_type) -response <-> exception relationship - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Net::HTTPHeader#canonical_each is an alias for -Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## error!() [](#method-i-error!) -:nodoc: - -**@raise** [error_type()] - -## error_type() [](#method-i-error_type) -:nodoc: - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## header() [](#method-i-header) -:nodoc: - -## initialize(httpv, code, msg) [](#method-i-initialize) -:nodoc: internal use only - -**@return** [HTTPResponse] a new instance of HTTPResponse - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## inspect() [](#method-i-inspect) - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## read_body(destnil, &block) [](#method-i-read_body) -Gets the entity body returned by the remote HTTP server. - -If a block is given, the body is passed to the block, and the body is provided -in fragments, as it is read in from the socket. - -If `dest` argument is given, response is read into that variable, with -`dest#<<` method (it could be String or IO, or any other object responding to -`<<`). - -Calling this method a second or subsequent time for the same HTTPResponse -object will return the value already read. - - http.request_get('/index.html') {|res| - puts res.read_body - } - - http.request_get('/index.html') {|res| - p res.read_body.object_id # 538149362 - p res.read_body.object_id # 538149362 - } - - # using iterator - http.request_get('/index.html') {|res| - res.read_body do |segment| - print segment - end - } - -## read_header() [](#method-i-read_header) -:nodoc: - -## reading_body(sock, reqmethodallowbody) [](#method-i-reading_body) -body - -## response() [](#method-i-response) -header (for backward compatibility only; DO NOT USE) - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Net::HTTPHeader#content_type= is an alias for -Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) (method -`params.map` will be called), and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[URI.encode_www_form](rdoc-ref:URI.encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - -## value() [](#method-i-value) -Raises an HTTP error if the response is not 2xx (success). - diff --git a/example/ruby/Net/HTTPResponse/Inflater.md b/example/ruby/Net/HTTPResponse/Inflater.md deleted file mode 100644 index 82c71c1..0000000 --- a/example/ruby/Net/HTTPResponse/Inflater.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Net::HTTPResponse::Inflater -**Inherits:** Object - - -Inflater is a wrapper around Net::BufferedIO that transparently inflates zlib -and gzip streams. - - - -#Instance Methods -## bytes_inflated() [](#method-i-bytes_inflated) -The number of bytes inflated, used to update the Content-Length of the -response. - -## finish() [](#method-i-finish) -Finishes the inflate stream. - -## inflate_adapter(dest) [](#method-i-inflate_adapter) -Returns a Net::ReadAdapter that inflates each read chunk into `dest`. - -This allows a large response body to be inflated without storing the entire -body in memory. - -## initialize(socket) [](#method-i-initialize) -Creates a new Inflater wrapping `socket` - -**@return** [Inflater] a new instance of Inflater - -## read(clen, dest, ignore_eoffalse) [](#method-i-read) -Reads `clen` bytes from the socket, inflates them, then writes them to `dest`. - `ignore_eof` is passed down to Net::BufferedIO#read - -Unlike Net::BufferedIO#read, this method returns more than `clen` bytes. At -this time there is no way for a user of Net::HTTPResponse to read a specific -number of bytes from the HTTP response body, so this internal API does not -return the same number of bytes as were requested. - -See https://bugs.ruby-lang.org/issues/6492 for further discussion. - -## read_all(dest) [](#method-i-read_all) -Reads the rest of the socket, inflates it, then writes it to `dest`. - diff --git a/example/ruby/Net/HTTPRetriableError.md b/example/ruby/Net/HTTPRetriableError.md deleted file mode 100644 index 62e4e32..0000000 --- a/example/ruby/Net/HTTPRetriableError.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Net::HTTPRetriableError -**Inherits:** Net::ProtoRetriableError - -**Includes:** Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/Net/HTTPSeeOther.md b/example/ruby/Net/HTTPSeeOther.md deleted file mode 100644 index 8d52f44..0000000 --- a/example/ruby/Net/HTTPSeeOther.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPSeeOther -**Inherits:** Net::HTTPRedirection - - -Response class for `See Other` responses (status code 303). - -The response to the request can be found under another URI using the GET -method. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-303-see-other). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303). - - - diff --git a/example/ruby/Net/HTTPServerError.md b/example/ruby/Net/HTTPServerError.md deleted file mode 100644 index f0b0068..0000000 --- a/example/ruby/Net/HTTPServerError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Net::HTTPServerError -**Inherits:** Net::HTTPResponse - - -Parent class for server error (5xx) HTTP response classes. - -A server error response indicates that the server failed to fulfill a request. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.5xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_se - rver_errors). - - - diff --git a/example/ruby/Net/HTTPServiceUnavailable.md b/example/ruby/Net/HTTPServiceUnavailable.md deleted file mode 100644 index f57de1a..0000000 --- a/example/ruby/Net/HTTPServiceUnavailable.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPServiceUnavailable -**Inherits:** Net::HTTPServerError - - -Response class for `Service Unavailable` responses (status code 503). - -The server cannot handle the request (because it is overloaded or down for -maintenance). - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-503-service-unavail - able). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503). - - - diff --git a/example/ruby/Net/HTTPSuccess.md b/example/ruby/Net/HTTPSuccess.md deleted file mode 100644 index 20694e2..0000000 --- a/example/ruby/Net/HTTPSuccess.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Net::HTTPSuccess -**Inherits:** Net::HTTPResponse - - -Parent class for success (2xx) HTTP response classes. - -A success response indicates the action requested by the client was received, -understood, and accepted. - -References: - -* [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.2xx). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_su - ccess). - - - diff --git a/example/ruby/Net/HTTPSwitchProtocol.md b/example/ruby/Net/HTTPSwitchProtocol.md deleted file mode 100644 index af7fee7..0000000 --- a/example/ruby/Net/HTTPSwitchProtocol.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPSwitchProtocol -**Inherits:** Net::HTTPInformation - - -Response class for `Switching Protocol` responses (status code 101). - -The Switching Protocol response indicates that the server has received -a request to switch protocols, and has agreed to do so. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-101-switching-proto - cols). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101). - - - diff --git a/example/ruby/Net/HTTPTemporaryRedirect.md b/example/ruby/Net/HTTPTemporaryRedirect.md deleted file mode 100644 index 61a6c97..0000000 --- a/example/ruby/Net/HTTPTemporaryRedirect.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPTemporaryRedirect -**Inherits:** Net::HTTPRedirection - - -Response class for `Temporary Redirect` responses (status code 307). - -The request should be repeated with another URI; however, future requests -should still use the original URI. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-307-temporary-redir - ect). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307). - - - diff --git a/example/ruby/Net/HTTPTooManyRequests.md b/example/ruby/Net/HTTPTooManyRequests.md deleted file mode 100644 index f5109eb..0000000 --- a/example/ruby/Net/HTTPTooManyRequests.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Net::HTTPTooManyRequests -**Inherits:** Net::HTTPClientError - - -Response class for `Too Many Requests` responses (status code 429). - -The user has sent too many requests in a given amount of time. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429). -* [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-4). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429). - - - diff --git a/example/ruby/Net/HTTPURITooLong.md b/example/ruby/Net/HTTPURITooLong.md deleted file mode 100644 index 8c2f99b..0000000 --- a/example/ruby/Net/HTTPURITooLong.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPURITooLong -**Inherits:** Net::HTTPClientError - - -Response class for `URI Too Long` responses (status code 414). - -The URI provided was too long for the server to process. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-414-uri-too-long). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414). - - - diff --git a/example/ruby/Net/HTTPUnauthorized.md b/example/ruby/Net/HTTPUnauthorized.md deleted file mode 100644 index 8f996d3..0000000 --- a/example/ruby/Net/HTTPUnauthorized.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPUnauthorized -**Inherits:** Net::HTTPClientError - - -Response class for `Unauthorized` responses (status code 401). - -Authentication is required, but either was not provided or failed. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-401-unauthorized). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401). - - - diff --git a/example/ruby/Net/HTTPUnavailableForLegalReasons.md b/example/ruby/Net/HTTPUnavailableForLegalReasons.md deleted file mode 100644 index 290acfd..0000000 --- a/example/ruby/Net/HTTPUnavailableForLegalReasons.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPUnavailableForLegalReasons -**Inherits:** Net::HTTPClientError - - -Response class for `Unavailable For Legal Reasons` responses (status code -451). - -A server operator has received a legal demand to deny access to a resource or -to a set of resources that includes the requested resource. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451). -* [RFC 7725](https://www.rfc-editor.org/rfc/rfc7725.html#section-3). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451). - - - diff --git a/example/ruby/Net/HTTPUnknownResponse.md b/example/ruby/Net/HTTPUnknownResponse.md deleted file mode 100644 index 6f7fdf5..0000000 --- a/example/ruby/Net/HTTPUnknownResponse.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Net::HTTPUnknownResponse -**Inherits:** Net::HTTPResponse - - - - - diff --git a/example/ruby/Net/HTTPUnprocessableEntity.md b/example/ruby/Net/HTTPUnprocessableEntity.md deleted file mode 100644 index 8228cea..0000000 --- a/example/ruby/Net/HTTPUnprocessableEntity.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPUnprocessableEntity -**Inherits:** Net::HTTPClientError - - -Response class for `Unprocessable Entity` responses (status code 422). - -The request was well-formed but had semantic errors. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-422-unprocessable-c - ontent). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422). - - - diff --git a/example/ruby/Net/HTTPUnsupportedMediaType.md b/example/ruby/Net/HTTPUnsupportedMediaType.md deleted file mode 100644 index 8108b04..0000000 --- a/example/ruby/Net/HTTPUnsupportedMediaType.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Net::HTTPUnsupportedMediaType -**Inherits:** Net::HTTPClientError - - -Response class for `Unsupported Media Type` responses (status code 415). - -The request entity has a media type which the server or resource does not -support. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-415-unsupported-med - ia-type). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415). - - - diff --git a/example/ruby/Net/HTTPUpgradeRequired.md b/example/ruby/Net/HTTPUpgradeRequired.md deleted file mode 100644 index 75cd987..0000000 --- a/example/ruby/Net/HTTPUpgradeRequired.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPUpgradeRequired -**Inherits:** Net::HTTPClientError - - -Response class for `Upgrade Required` responses (status code 426). - -The client should switch to the protocol given in the Upgrade header field. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-426-upgrade-require - d). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426). - - - diff --git a/example/ruby/Net/HTTPUseProxy.md b/example/ruby/Net/HTTPUseProxy.md deleted file mode 100644 index 86520b3..0000000 --- a/example/ruby/Net/HTTPUseProxy.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPUseProxy -**Inherits:** Net::HTTPRedirection - - -Response class for `Use Proxy` responses (status code 305). - -The requested resource is available only through a proxy, whose address is -provided in the response. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-305-use-proxy). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305). - - - diff --git a/example/ruby/Net/HTTPVariantAlsoNegotiates.md b/example/ruby/Net/HTTPVariantAlsoNegotiates.md deleted file mode 100644 index 5ebe111..0000000 --- a/example/ruby/Net/HTTPVariantAlsoNegotiates.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Net::HTTPVariantAlsoNegotiates -**Inherits:** Net::HTTPServerError - - -Response class for `Variant Also Negotiates` responses (status code 506). - -Transparent content negotiation for the request results in a circular -reference. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506). -* [RFC 2295](https://www.rfc-editor.org/rfc/rfc2295#section-8.1). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506). - - - diff --git a/example/ruby/Net/HTTPVersionNotSupported.md b/example/ruby/Net/HTTPVersionNotSupported.md deleted file mode 100644 index 7debb1d..0000000 --- a/example/ruby/Net/HTTPVersionNotSupported.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Net::HTTPVersionNotSupported -**Inherits:** Net::HTTPServerError - - -Response class for `HTTP Version Not Supported` responses (status code 505). - -The server does not support the HTTP version used in the request. - -:include: doc/net-http/included_getters.rdoc - -References: - -* [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505). -* [RFC - 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-505-http-version-no - t-suppor). -* [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505). - - - diff --git a/example/ruby/Net/InternetMessageIO.md b/example/ruby/Net/InternetMessageIO.md deleted file mode 100644 index 2f8a621..0000000 --- a/example/ruby/Net/InternetMessageIO.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Net::InternetMessageIO -**Inherits:** Net::BufferedIO - - -:nodoc: internal use only - - - -#Instance Methods -## each_list_item() [](#method-i-each_list_item) -*library private* (cannot handle 'break') - -## each_message_chunk() [](#method-i-each_message_chunk) -Read - -## initialize() [](#method-i-initialize) - -**@return** [InternetMessageIO] a new instance of InternetMessageIO - -## write_message(src) [](#method-i-write_message) -Write - -## write_message_0(src) [](#method-i-write_message_0) - -## write_message_by_block(&block) [](#method-i-write_message_by_block) - diff --git a/example/ruby/Net/NetPrivate.md b/example/ruby/Net/NetPrivate.md deleted file mode 100644 index 3ca4e93..0000000 --- a/example/ruby/Net/NetPrivate.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Net::NetPrivate - - -:nodoc: obsolete - - - diff --git a/example/ruby/Net/OpenTimeout.md b/example/ruby/Net/OpenTimeout.md deleted file mode 100644 index 539d554..0000000 --- a/example/ruby/Net/OpenTimeout.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Net::OpenTimeout -**Inherits:** Timeout::Error - - -OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot be -created within the open_timeout. - - - diff --git a/example/ruby/Net/ProtoAuthError.md b/example/ruby/Net/ProtoAuthError.md deleted file mode 100644 index 62c9be8..0000000 --- a/example/ruby/Net/ProtoAuthError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::ProtoAuthError -**Inherits:** Net::ProtocolError - - - - - diff --git a/example/ruby/Net/ProtoCommandError.md b/example/ruby/Net/ProtoCommandError.md deleted file mode 100644 index d430dad..0000000 --- a/example/ruby/Net/ProtoCommandError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::ProtoCommandError -**Inherits:** Net::ProtocolError - - - - - diff --git a/example/ruby/Net/ProtoFatalError.md b/example/ruby/Net/ProtoFatalError.md deleted file mode 100644 index 3db4e9b..0000000 --- a/example/ruby/Net/ProtoFatalError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::ProtoFatalError -**Inherits:** Net::ProtocolError - - - - - diff --git a/example/ruby/Net/ProtoRetriableError.md b/example/ruby/Net/ProtoRetriableError.md deleted file mode 100644 index d4452e1..0000000 --- a/example/ruby/Net/ProtoRetriableError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::ProtoRetriableError -**Inherits:** Net::ProtocolError - - - - - diff --git a/example/ruby/Net/ProtoServerError.md b/example/ruby/Net/ProtoServerError.md deleted file mode 100644 index 46e5cd4..0000000 --- a/example/ruby/Net/ProtoServerError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::ProtoServerError -**Inherits:** Net::ProtocolError - - - - - diff --git a/example/ruby/Net/ProtoSyntaxError.md b/example/ruby/Net/ProtoSyntaxError.md deleted file mode 100644 index f197278..0000000 --- a/example/ruby/Net/ProtoSyntaxError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::ProtoSyntaxError -**Inherits:** Net::ProtocolError - - - - - diff --git a/example/ruby/Net/ProtoUnknownError.md b/example/ruby/Net/ProtoUnknownError.md deleted file mode 100644 index bda43d5..0000000 --- a/example/ruby/Net/ProtoUnknownError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::ProtoUnknownError -**Inherits:** Net::ProtocolError - - - - - diff --git a/example/ruby/Net/Protocol.md b/example/ruby/Net/Protocol.md deleted file mode 100644 index 9f575cf..0000000 --- a/example/ruby/Net/Protocol.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Net::Protocol -**Inherits:** Object - - -:nodoc: internal use only - - - diff --git a/example/ruby/Net/ProtocolError.md b/example/ruby/Net/ProtocolError.md deleted file mode 100644 index 9160e6d..0000000 --- a/example/ruby/Net/ProtocolError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Net::ProtocolError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Net/ReadAdapter.md b/example/ruby/Net/ReadAdapter.md deleted file mode 100644 index e67d248..0000000 --- a/example/ruby/Net/ReadAdapter.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Net::ReadAdapter -**Inherits:** Object - - -:nodoc: internal use only - - - -#Instance Methods -## <<(str) [](#method-i-<<) - -## initialize(block) [](#method-i-initialize) - -**@return** [ReadAdapter] a new instance of ReadAdapter - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/Net/ReadTimeout.md b/example/ruby/Net/ReadTimeout.md deleted file mode 100644 index 7a5890f..0000000 --- a/example/ruby/Net/ReadTimeout.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: Net::ReadTimeout -**Inherits:** Timeout::Error - - -ReadTimeout, a subclass of Timeout::Error, is raised if a chunk of the -response cannot be read within the read_timeout. - - -# Attributes -## io[RW] [](#attribute-i-io) -Returns the value of attribute io. - - -#Instance Methods -## initialize(ionil) [](#method-i-initialize) - -**@return** [ReadTimeout] a new instance of ReadTimeout - -## message() [](#method-i-message) - diff --git a/example/ruby/Net/TestBufferedIO.md b/example/ruby/Net/TestBufferedIO.md deleted file mode 100644 index ca29275..0000000 --- a/example/ruby/Net/TestBufferedIO.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Net::TestBufferedIO -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_eof?() [](#method-i-test_eof?) - -**@return** [Boolean] - diff --git a/example/ruby/Net/WriteAdapter.md b/example/ruby/Net/WriteAdapter.md deleted file mode 100644 index 7d8cea1..0000000 --- a/example/ruby/Net/WriteAdapter.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Net::WriteAdapter -**Inherits:** Object - - -The writer adapter class - - - -#Instance Methods -## <<(str) [](#method-i-<<) - -## initialize(writer) [](#method-i-initialize) - -**@return** [WriteAdapter] a new instance of WriteAdapter - -## inspect() [](#method-i-inspect) - -## printf(*args) [](#method-i-printf) - -## puts(str'') [](#method-i-puts) - -## write(str) [](#method-i-write) - diff --git a/example/ruby/Net/WriteTimeout.md b/example/ruby/Net/WriteTimeout.md deleted file mode 100644 index b7c85db..0000000 --- a/example/ruby/Net/WriteTimeout.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: Net::WriteTimeout -**Inherits:** Timeout::Error - - -WriteTimeout, a subclass of Timeout::Error, is raised if a chunk of the -response cannot be written within the write_timeout. Not raised on Windows. - - -# Attributes -## io[RW] [](#attribute-i-io) -Returns the value of attribute io. - - -#Instance Methods -## initialize(ionil) [](#method-i-initialize) - -**@return** [WriteTimeout] a new instance of WriteTimeout - -## message() [](#method-i-message) - diff --git a/example/ruby/NetFTPSpecs.md b/example/ruby/NetFTPSpecs.md deleted file mode 100644 index ddf5459..0000000 --- a/example/ruby/NetFTPSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: NetFTPSpecs - - - - - diff --git a/example/ruby/NetFTPSpecs/DummyFTP.md b/example/ruby/NetFTPSpecs/DummyFTP.md deleted file mode 100644 index 6eb4371..0000000 --- a/example/ruby/NetFTPSpecs/DummyFTP.md +++ /dev/null @@ -1,104 +0,0 @@ -# Class: NetFTPSpecs::DummyFTP -**Inherits:** Object - - - - -# Attributes -## connect_message[RW] [](#attribute-i-connect_message) -Returns the value of attribute connect_message. - -## hostname[RW] [](#attribute-i-hostname) -hostname or IP address - -## login_acct[RW] [](#attribute-i-login_acct) -Returns the value of attribute login_acct. - -## login_pass[RW] [](#attribute-i-login_pass) -Returns the value of attribute login_pass. - -## login_user[RW] [](#attribute-i-login_user) -Returns the value of attribute login_user. - -## server_port[RW] [](#attribute-i-server_port) -port number - - -#Instance Methods -## abor() [](#method-i-abor) -FTP methods - -## acct(account) [](#method-i-acct) - -## and_respond(text) [](#method-i-and_respond) - -## appe(file) [](#method-i-appe) - -## cdup() [](#method-i-cdup) - -## cwd(dir) [](#method-i-cwd) - -## dele(file) [](#method-i-dele) - -## eprt(arg) [](#method-i-eprt) - -## error_response(text) [](#method-i-error_response) - -## handle(sym, &block) [](#method-i-handle) - -## handle_request() [](#method-i-handle_request) - -## help(param:default) [](#method-i-help) - -## initialize() [](#method-i-initialize) - -**@return** [DummyFTP] a new instance of DummyFTP - -## list(folder) [](#method-i-list) - -## mdtm(filename) [](#method-i-mdtm) - -## mkd(foldername) [](#method-i-mkd) - -## nlst(foldernil) [](#method-i-nlst) - -## noop() [](#method-i-noop) - -## pass(password) [](#method-i-pass) - -## port(arg) [](#method-i-port) - -## pwd() [](#method-i-pwd) - -## response(text) [](#method-i-response) - -## rest(at_bytes) [](#method-i-rest) - -## retr(file) [](#method-i-retr) - -## rmd(folder) [](#method-i-rmd) - -## rnfr(from) [](#method-i-rnfr) - -## rnto(to) [](#method-i-rnto) - -## serve_once() [](#method-i-serve_once) - -## should_receive(method) [](#method-i-should_receive) - -## site(param) [](#method-i-site) - -## size(filename) [](#method-i-size) - -## stat(param:default) [](#method-i-stat) - -## stop() [](#method-i-stop) - -## stor(file) [](#method-i-stor) - -## syst() [](#method-i-syst) - -## type(type) [](#method-i-type) - -## user(name) [](#method-i-user) - diff --git a/example/ruby/NetHTTPExceptionsSpecs.md b/example/ruby/NetHTTPExceptionsSpecs.md deleted file mode 100644 index dd7d199..0000000 --- a/example/ruby/NetHTTPExceptionsSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: NetHTTPExceptionsSpecs - - - - - diff --git a/example/ruby/NetHTTPExceptionsSpecs/Simple.md b/example/ruby/NetHTTPExceptionsSpecs/Simple.md deleted file mode 100644 index 0001c10..0000000 --- a/example/ruby/NetHTTPExceptionsSpecs/Simple.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: NetHTTPExceptionsSpecs::Simple -**Inherits:** StandardError - -**Includes:** Net::HTTPExceptions - - - - - -#Instance Methods -## initialize(msg, res) [](#method-i-initialize) -:nodoc: - diff --git a/example/ruby/NetHTTPHeaderSpecs.md b/example/ruby/NetHTTPHeaderSpecs.md deleted file mode 100644 index fddf41a..0000000 --- a/example/ruby/NetHTTPHeaderSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: NetHTTPHeaderSpecs - - - - - diff --git a/example/ruby/NetHTTPHeaderSpecs/Example.md b/example/ruby/NetHTTPHeaderSpecs/Example.md deleted file mode 100644 index 21467a6..0000000 --- a/example/ruby/NetHTTPHeaderSpecs/Example.md +++ /dev/null @@ -1,530 +0,0 @@ -# Class: NetHTTPHeaderSpecs::Example -**Inherits:** Object - -**Includes:** Net::HTTPHeader - - - - -# Attributes -## body[RW] [](#attribute-i-body) -Returns the value of attribute body. - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the string field value for the case-insensitive field `key`, or `nil` -if there is no such key; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Connection'] # => "keep-alive" - res['Nosuch'] # => nil - -Note that some field values may be retrieved via convenience methods; see -[Getters](rdoc-ref:Net::HTTPHeader@Getters). - -## []=(key, val) [](#method-i-[]=) -Sets the value for the case-insensitive `key` to `val`, overwriting the -previous value if the field exists; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req['Accept'] # => "*/*" - req['Accept'] = 'text/html' - req['Accept'] # => "text/html" - -Note that some field values may be set via convenience methods; see -[Setters](rdoc-ref:Net::HTTPHeader@Setters). - -## add_field(key, val) [](#method-i-add_field) -Adds value `val` to the value array for field `key` if the field exists; -creates the field with the given `key` and `val` if it does not exist. see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - req = Net::HTTP::Get.new(uri) - req.add_field('Foo', 'bar') - req['Foo'] # => "bar" - req.add_field('Foo', 'baz') - req['Foo'] # => "bar, baz" - req.add_field('Foo', %w[baz bam]) - req['Foo'] # => "bar, baz, baz, bam" - req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"] - -## basic_auth(account, password) [](#method-i-basic_auth) -Sets header `'Authorization'` using the given `account` and `password` -strings: - - req.basic_auth('my_account', 'my_password') - req['Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## chunked?() [](#method-i-chunked?) -Returns `true` if field `'Transfer-Encoding'` exists and has value -`'chunked'`, `false` otherwise; see [Transfer-Encoding response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco -ding-response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Transfer-Encoding'] # => "chunked" - res.chunked? # => true - -**@return** [Boolean] - -## connection_close?() [](#method-i-connection_close?) -Returns whether the HTTP session is to be closed. - -**@return** [Boolean] - -## connection_keep_alive?() [](#method-i-connection_keep_alive?) -Returns whether the HTTP session is to be kept alive. - -**@return** [Boolean] - -## content_length() [](#method-i-content_length) -Returns the value of field `'Content-Length'` as an integer, or `nil` if there -is no such field; see [Content-Length request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-request-header): - - res = Net::HTTP.get_response(hostname, '/nosuch/1') - res.content_length # => 2 - res = Net::HTTP.get_response(hostname, '/todos/1') - res.content_length # => nil - -## content_length=(len) [](#method-i-content_length=) -Sets the value of field `'Content-Length'` to the given numeric; see -[Content-Length response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt -h-response-header): - - _uri = uri.dup - hostname = _uri.hostname # => "jsonplaceholder.typicode.com" - _uri.path = '/posts' # => "/posts" - req = Net::HTTP::Post.new(_uri) # => # - req.body = '{"title": "foo","body": "bar","userId": 1}' - req.content_length = req.body.size # => 42 - req.content_type = 'application/json' - res = Net::HTTP.start(hostname) do |http| - http.request(req) - end # => # - -## content_range() [](#method-i-content_range) -Returns a Range object representing the value of field `'Content-Range'`, or -`nil` if no such field exists; see [Content-Range response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res['Content-Range'] # => "bytes 0-499/1000" - res.content_range # => 0..499 - -## content_type() [](#method-i-content_type) -Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the -value of field `'Content-Type'`, or `nil` if no such field exists; see -[Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.content_type # => "application/json" - -## delete(key) [](#method-i-delete) -Removes the header for the given case-insensitive `key` (see -[Fields](rdoc-ref:Net::HTTPHeader@Fields)); returns the deleted value, or -`nil` if no such field exists: - - req = Net::HTTP::Get.new(uri) - req.delete('Accept') # => ["*/*"] - req.delete('Nosuch') # => nil - -## each_capitalized() [](#method-i-each_capitalized) -Like #each_header, but the keys are returned in capitalized form. - -Net::HTTPHeader#canonical_each is an alias for -Net::HTTPHeader#each_capitalized. - -## each_capitalized_name() [](#method-i-each_capitalized_name) -Calls the block with each capitalized field name: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_capitalized_name do |key| - p key if key.start_with?('C') - end - -Output: - - "Content-Type" - "Connection" - "Cache-Control" - "Cf-Cache-Status" - "Cf-Ray" - -The capitalization is system-dependent; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Returns an enumerator if no block is given. - -## each_header() [](#method-i-each_header) -Calls the block with each key/value pair: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_header do |key, value| - p [key, value] if key.start_with?('c') - end - -Output: - - ["content-type", "application/json; charset=utf-8"] - ["connection", "keep-alive"] - ["cache-control", "max-age=43200"] - ["cf-cache-status", "HIT"] - ["cf-ray", "771d17e9bc542cf5-ORD"] - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header. - -## each_name(&block) [](#method-i-each_name) -Calls the block with each field key: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_key do |key| - p key if key.start_with?('c') - end - -Output: - - "content-type" - "connection" - "cache-control" - "cf-cache-status" - "cf-ray" - -Returns an enumerator if no block is given. - -Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key. - -## each_value() [](#method-i-each_value) -Calls the block with each string field value: - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.each_value do |value| - p value if value.start_with?('c') - end - -Output: - - "chunked" - "cf-q-config;dur=6.0000002122251e-06" - "cloudflare" - -Returns an enumerator if no block is given. - -## fetch(key, *args, &block) [](#method-i-fetch) -call-seq: - fetch(key, default_val = nil) {|key| ... } -> object - fetch(key, default_val = nil) -> value or default_val - -With a block, returns the string value for `key` if it exists; otherwise -returns the value of the block; ignores the `default_val`; see -[Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - - # Field exists; block not called. - res.fetch('Connection') do |value| - fail 'Cannot happen' - end # => "keep-alive" - - # Field does not exist; block called. - res.fetch('Nosuch') do |value| - value.downcase - end # => "nosuch" - -With no block, returns the string value for `key` if it exists; otherwise, -returns `default_val` if it was given; otherwise raises an exception: - - res.fetch('Connection', 'Foo') # => "keep-alive" - res.fetch('Nosuch', 'Foo') # => "Foo" - res.fetch('Nosuch') # Raises KeyError. - -## get_fields(key) [](#method-i-get_fields) -Returns the array field value for the given `key`, or `nil` if there is no -such field; see [Fields](rdoc-ref:Net::HTTPHeader@Fields): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res.get_fields('Connection') # => ["keep-alive"] - res.get_fields('Nosuch') # => nil - -## initialize() [](#method-i-initialize) - -**@return** [Example] a new instance of Example - -## initialize_http_header(initheader) [](#method-i-initialize_http_header) -:nodoc: - -## key?(key) [](#method-i-key?) -Returns `true` if the field for the case-insensitive `key` exists, `false` -otherwise: - - req = Net::HTTP::Get.new(uri) - req.key?('Accept') # => true - req.key?('Nosuch') # => false - -**@return** [Boolean] - -## main_type() [](#method-i-main_type) -Returns the leading ('type') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.main_type # => "application" - -## proxy_basic_auth(account, password) [](#method-i-proxy_basic_auth) -Sets header `'Proxy-Authorization'` using the given `account` and `password` -strings: - - req.proxy_basic_auth('my_account', 'my_password') - req['Proxy-Authorization'] - # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" - -## range() [](#method-i-range) -Returns an array of Range objects that represent the value of field `'Range'`, -or `nil` if there is no such field; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - - req = Net::HTTP::Get.new(uri) - req['Range'] = 'bytes=0-99,200-299,400-499' - req.range # => [0..99, 200..299, 400..499] - req.delete('Range') - req.range # # => nil - -## range_length() [](#method-i-range_length) -Returns the integer representing length of the value of field -`'Content-Range'`, or `nil` if no such field exists; see [Content-Range -response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range --response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['Content-Range'] # => nil - res['Content-Range'] = 'bytes 0-499/1000' - res.range_length # => 500 - -## set_content_type(type, params{}) [](#method-i-set_content_type) -Sets the value of field `'Content-Type'`; returns the new value; see -[Content-Type request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -request-header): - - req = Net::HTTP::Get.new(uri) - req.set_content_type('application/json') # => ["application/json"] - -Net::HTTPHeader#content_type= is an alias for -Net::HTTPHeader#set_content_type. - -## set_form(params, enctype'application/x-www-form-urlencoded', formopt{}) [](#method-i-set_form) -Stores form data to be used in a `POST` or `PUT` request. - -The form data given in `params` consists of zero or more fields; each field -is: - -* A scalar value. -* A name/value pair. -* An IO stream opened for reading. - -Argument `params` should be an -[Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) (method -`params.map` will be called), and is often an array or hash. - -First, we set up a request: - - _uri = uri.dup - _uri.path ='/posts' - req = Net::HTTP::Post.new(_uri) - -**Argument `params` As an Array** - -When `params` is an array, each of its elements is a subarray that defines a -field; the subarray may contain: - -* One string: - - req.set_form([['foo'], ['bar'], ['baz']]) - -* Two strings: - - req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]]) - -* When argument `enctype` (see below) is given as `'multipart/form-data'`: - - * A string name and an IO stream opened for reading: - - require 'stringio' - req.set_form([['file', StringIO.new('Ruby is cool.')]]) - - * A string name, an IO stream opened for reading, and an options hash, - which may contain these entries: - - * `:filename`: The name of the file to use. - * `:content_type`: The content type of the uploaded file. - - Example: - - req.set_form([['file', file, {filename: "other-filename.foo"}]] - -The various forms may be mixed: - - req.set_form(['foo', %w[bar 1], ['file', file]]) - -**Argument `params` As a Hash** - -When `params` is a hash, each of its entries is a name/value pair that defines -a field: - -* The name is a string. -* The value may be: - - * `nil`. - * Another string. - * An IO stream opened for reading (only when argument `enctype` -- see - below -- is given as `'multipart/form-data'`). - -Examples: - - # Nil-valued fields. - req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil}) - - # String-valued fields. - req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2}) - - # IO-valued field. - require 'stringio' - req.set_form({'file' => StringIO.new('Ruby is cool.')}) - - # Mixture of fields. - req.set_form({'foo' => nil, 'bar' => 1, 'file' => file}) - -Optional argument `enctype` specifies the value to be given to field -`'Content-Type'`, and must be one of: - -* `'application/x-www-form-urlencoded'` (the default). -* `'multipart/form-data'`; see [RFC - 7578](https://www.rfc-editor.org/rfc/rfc7578). - -Optional argument `formopt` is a hash of options (applicable only when -argument `enctype` is `'multipart/form-data'`) that may include the following -entries: - -* `:boundary`: The value is the boundary string for the multipart message. - If not given, the boundary is a random string. See - [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1). -* `:charset`: Value is the character set for the form submission. Field - names and values of non-file fields should be encoded with this charset. - -## set_form_data(params, sep'&') [](#method-i-set_form_data) -Sets the request body to a URL-encoded string derived from argument `params`, -and sets request header field `'Content-Type'` to -`'application/x-www-form-urlencoded'`. - -The resulting request is suitable for HTTP request `POST` or `PUT`. - -Argument `params` must be suitable for use as argument `enum` to -[URI.encode_www_form](rdoc-ref:URI.encode_www_form). - -With only argument `params` given, sets the body to a URL-encoded string with -the default separator `'&'`: - - req = Net::HTTP::Post.new('example.com') - - req.set_form_data(q: 'ruby', lang: 'en') - req.body # => "q=ruby&lang=en" - req['Content-Type'] # => "application/x-www-form-urlencoded" - - req.set_form_data([['q', 'ruby'], ['lang', 'en']]) - req.body # => "q=ruby&lang=en" - - req.set_form_data(q: ['ruby', 'perl'], lang: 'en') - req.body # => "q=ruby&q=perl&lang=en" - - req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']]) - req.body # => "q=ruby&q=perl&lang=en" - -With string argument `sep` also given, uses that string as the separator: - - req.set_form_data({q: 'ruby', lang: 'en'}, '|') - req.body # => "q=ruby|lang=en" - -Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data. - -## set_range(r, enil) [](#method-i-set_range) -call-seq: - set_range(length) -> length - set_range(offset, length) -> range - set_range(begin..length) -> range - -Sets the value for field `'Range'`; see [Range request -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request --header): - -With argument `length`: - - req = Net::HTTP::Get.new(uri) - req.set_range(100) # => 100 - req['Range'] # => "bytes=0-99" - -With arguments `offset` and `length`: - - req.set_range(100, 100) # => 100...200 - req['Range'] # => "bytes=100-199" - -With argument `range`: - - req.set_range(100..199) # => 100..199 - req['Range'] # => "bytes=100-199" - -Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range. - -## size() [](#method-i-size) -:nodoc: obsolete - -## sub_type() [](#method-i-sub_type) -Returns the trailing ('subtype') part of the [media -type](https://en.wikipedia.org/wiki/Media_type) from the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.sub_type # => "json" - -## to_hash() [](#method-i-to_hash) -Returns a hash of the key/value pairs: - - req = Net::HTTP::Get.new(uri) - req.to_hash - # => - {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], - "accept"=>["*/*"], - "user-agent"=>["Ruby"], - "host"=>["jsonplaceholder.typicode.com"]} - -## type_params() [](#method-i-type_params) -Returns the trailing ('parameters') part of the value of field -`'Content-Type'`, or `nil` if no such field exists; see [Content-Type response -header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type- -response-header): - - res = Net::HTTP.get_response(hostname, '/todos/1') - res['content-type'] # => "application/json; charset=utf-8" - res.type_params # => {"charset"=>"utf-8"} - diff --git a/example/ruby/NetHTTPRequestSpecs.md b/example/ruby/NetHTTPRequestSpecs.md deleted file mode 100644 index 3b5e7a4..0000000 --- a/example/ruby/NetHTTPRequestSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: NetHTTPRequestSpecs - - - - - diff --git a/example/ruby/NetHTTPRequestSpecs/TestRequest.md b/example/ruby/NetHTTPRequestSpecs/TestRequest.md deleted file mode 100644 index 7fb4ca9..0000000 --- a/example/ruby/NetHTTPRequestSpecs/TestRequest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: NetHTTPRequestSpecs::TestRequest -**Inherits:** Net::HTTPRequest - - - - - diff --git a/example/ruby/NetHTTPSpecs.md b/example/ruby/NetHTTPSpecs.md deleted file mode 100644 index 4b770ef..0000000 --- a/example/ruby/NetHTTPSpecs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: NetHTTPSpecs - - - - -# Class Methods -## port() [](#method-c-port) -## start_server() [](#method-c-start_server) -## stop_server() [](#method-c-stop_server) - diff --git a/example/ruby/NetHTTPSpecs/NullWriter.md b/example/ruby/NetHTTPSpecs/NullWriter.md deleted file mode 100644 index 03f4dc0..0000000 --- a/example/ruby/NetHTTPSpecs/NullWriter.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: NetHTTPSpecs::NullWriter -**Inherits:** Object - - - - - -#Instance Methods -## <<(s) [](#method-i-<<) - -## print(*args) [](#method-i-print) - -## printf(*args) [](#method-i-printf) - -## puts(*args) [](#method-i-puts) - diff --git a/example/ruby/NetHTTPSpecs/SmallHTTPServer.md b/example/ruby/NetHTTPSpecs/SmallHTTPServer.md deleted file mode 100644 index cb6de0b..0000000 --- a/example/ruby/NetHTTPSpecs/SmallHTTPServer.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: NetHTTPSpecs::SmallHTTPServer -**Inherits:** Object - - - - - -#Instance Methods -## close() [](#method-i-close) - -## handle_client(client) [](#method-i-handle_client) - -## handle_request(client, request) [](#method-i-handle_request) - -## initialize(bind_address) [](#method-i-initialize) - -**@return** [SmallHTTPServer] a new instance of SmallHTTPServer - -## ip() [](#method-i-ip) - -## listen() [](#method-i-listen) - -## parse_request(request) [](#method-i-parse_request) - -## port() [](#method-i-port) - -## reply(client, body, request_method) [](#method-i-reply) - diff --git a/example/ruby/NextSpecs.md b/example/ruby/NextSpecs.md deleted file mode 100644 index 72e26eb..0000000 --- a/example/ruby/NextSpecs.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: NextSpecs -**Inherits:** Object - - - - -# Class Methods -## loop_next(arg ) [](#method-c-loop_next) -## loop_within_iter(arg ) [](#method-c-loop_within_iter) -## until_next(arg ) [](#method-c-until_next) -## until_within_iter(arg ) [](#method-c-until_within_iter) -## while_next(arg ) [](#method-c-while_next) -The methods below are defined to spec the behavior of the next statement while -specifically isolating whether the statement is in an Iter block or not. In a -normal spec example, the code is always nested inside a block. Rather than -rely on that implicit context in this case, the context is made explicit -because of the interaction of next in a loop nested inside an Iter block. -## while_within_iter(arg ) [](#method-c-while_within_iter) -## yielding() [](#method-c-yielding) -## yielding_method(expected ) [](#method-c-yielding_method) - diff --git a/example/ruby/NextSpecs/Block.md b/example/ruby/NextSpecs/Block.md deleted file mode 100644 index b6d7886..0000000 --- a/example/ruby/NextSpecs/Block.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: NextSpecs::Block -**Inherits:** Object - - - - - -#Instance Methods -## method(v) [](#method-i-method) - -**@yield** [v] - diff --git a/example/ruby/NilClass.md b/example/ruby/NilClass.md deleted file mode 100644 index faebd91..0000000 --- a/example/ruby/NilClass.md +++ /dev/null @@ -1,142 +0,0 @@ -# Class: NilClass -**Inherits:** Object - - -The class of the singleton object `nil`. - -Several of its methods act as operators: - -* #& -* #| -* #=== -* #=~ -* #^ - -Others act as converters, carrying the concept of *nullity* to other classes: - -* #rationalize -* #to_a -* #to_c -* #to_h -* #to_r -* #to_s - -While `nil` doesn't have an explicitly defined #to_hash method, it can be used -in `**` unpacking, not adding any keyword arguments. - -Another method provides inspection: - -* #inspect - -Finally, there is this query method: - -* #nil? - - - -#Instance Methods -## &(obj2) [](#method-i-&) -Returns `false`: - - false & true # => false - false & Object.new # => false - -Argument `object` is evaluated: - - false & raise # Raises RuntimeError. - -**@overload** [] - -**@overload** [] - -## ===() [](#method-i-===) - -## =~(obj2) [](#method-i-=~) -Returns `nil`. - -This method makes it useful to write: - - while gets =~ /re/ - # ... - end - -**@overload** [] - -## ^() [](#method-i-^) - -## inspect() [](#method-i-inspect) -Returns string `'nil'`: - - nil.inspect # => "nil" - -**@overload** [] - -## nil?() [](#method-i-nil?) -Returns `true`. For all other objects, method `nil?` returns `false`. - -**@overload** [] - -## rationalize(*args) [](#method-i-rationalize) -Returns zero as a Rational: - - nil.rationalize # => (0/1) - -Argument `eps` is ignored. - -**@overload** [] - -## to_a() [](#method-i-to_a) -call-seq: - to_a -> [] - -Returns an empty Array. - - nil.to_a # => [] - -## to_c() [](#method-i-to_c) -Returns zero as a Complex: - - nil.to_c # => (0+0i) - -**@overload** [] - -## to_f() [](#method-i-to_f) -call-seq: - nil.to_f -> 0.0 - - Always returns zero. - - nil.to_f #=> 0.0 - -## to_h() [](#method-i-to_h) -call-seq: - to_h -> {} - -Returns an empty Hash. - - nil.to_h #=> {} - -## to_i() [](#method-i-to_i) -call-seq: - nil.to_i -> 0 - - Always returns zero. - - nil.to_i #=> 0 - -## to_r() [](#method-i-to_r) -Returns zero as a Rational: - - nil.to_r # => (0/1) - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns an empty String: - - nil.to_s # => "" - -**@overload** [] - -## |() [](#method-i-|) - diff --git a/example/ruby/NoMatchingPatternError.md b/example/ruby/NoMatchingPatternError.md deleted file mode 100644 index af05727..0000000 --- a/example/ruby/NoMatchingPatternError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: NoMatchingPatternError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/NoMatchingPatternKeyError.md b/example/ruby/NoMatchingPatternKeyError.md deleted file mode 100644 index 3588e08..0000000 --- a/example/ruby/NoMatchingPatternKeyError.md +++ /dev/null @@ -1,24 +0,0 @@ -# Exception: NoMatchingPatternKeyError -**Inherits:** NoMatchingPatternError - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Construct a new `NoMatchingPatternKeyError` exception with the given message, -matchee and key. - -**@overload** [] - -## key() [](#method-i-key) -Return the key caused this NoMatchingPatternKeyError exception. - -**@overload** [] - -## matchee() [](#method-i-matchee) -Return the matchee associated with this NoMatchingPatternKeyError exception. - -**@overload** [] - diff --git a/example/ruby/NoMemoryError.md b/example/ruby/NoMemoryError.md deleted file mode 100644 index 772a65b..0000000 --- a/example/ruby/NoMemoryError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: NoMemoryError -**Inherits:** Exception - - -Raised when memory allocation fails. - - - diff --git a/example/ruby/NoMethodError.md b/example/ruby/NoMethodError.md deleted file mode 100644 index 01af158..0000000 --- a/example/ruby/NoMethodError.md +++ /dev/null @@ -1,38 +0,0 @@ -# Exception: NoMethodError -**Inherits:** NameError - - -Raised when a method is called on a receiver which doesn't have it defined and -also fails to respond with `method_missing`. - - "hello".to_ary - -*raises the exception:* - - NoMethodError: undefined method `to_ary' for an instance of String - - - -#Instance Methods -## args() [](#method-i-args) -Return the arguments passed in as the third parameter to the constructor. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Construct a NoMethodError exception for a method of the given name called with -the given arguments. The name may be accessed using the `#name` method on the -resulting object, and the arguments using the `#args` method. - -If *private* argument were passed, it designates method was attempted to call -in private context, and can be accessed with `#private_call?` method. - -*receiver* argument stores an object whose method was called. - -**@overload** [] - -## private_call?() [](#method-i-private_call?) -Return true if the caused method was called as private. - -**@overload** [] - diff --git a/example/ruby/NoMethodErrorSpecs.md b/example/ruby/NoMethodErrorSpecs.md deleted file mode 100644 index 1519b5b..0000000 --- a/example/ruby/NoMethodErrorSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: NoMethodErrorSpecs - - - - - diff --git a/example/ruby/NoMethodErrorSpecs/InstanceException.md b/example/ruby/NoMethodErrorSpecs/InstanceException.md deleted file mode 100644 index 3479036..0000000 --- a/example/ruby/NoMethodErrorSpecs/InstanceException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: NoMethodErrorSpecs::InstanceException -**Inherits:** Exception - - - - - diff --git a/example/ruby/NoMethodErrorSpecs/NoMethodErrorA.md b/example/ruby/NoMethodErrorSpecs/NoMethodErrorA.md deleted file mode 100644 index 76e5c95..0000000 --- a/example/ruby/NoMethodErrorSpecs/NoMethodErrorA.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: NoMethodErrorSpecs::NoMethodErrorA -**Inherits:** Object - - - - - diff --git a/example/ruby/NoMethodErrorSpecs/NoMethodErrorB.md b/example/ruby/NoMethodErrorSpecs/NoMethodErrorB.md deleted file mode 100644 index 5d77fb7..0000000 --- a/example/ruby/NoMethodErrorSpecs/NoMethodErrorB.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: NoMethodErrorSpecs::NoMethodErrorB -**Inherits:** Object - - - - - diff --git a/example/ruby/NoMethodErrorSpecs/NoMethodErrorC.md b/example/ruby/NoMethodErrorSpecs/NoMethodErrorC.md deleted file mode 100644 index 4f45cb3..0000000 --- a/example/ruby/NoMethodErrorSpecs/NoMethodErrorC.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: NoMethodErrorSpecs::NoMethodErrorC -**Inherits:** Object - - - - - diff --git a/example/ruby/NoMethodErrorSpecs/NoMethodErrorD.md b/example/ruby/NoMethodErrorSpecs/NoMethodErrorD.md deleted file mode 100644 index 25db3aa..0000000 --- a/example/ruby/NoMethodErrorSpecs/NoMethodErrorD.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: NoMethodErrorSpecs::NoMethodErrorD -**Inherits:** Object - - - - - diff --git a/example/ruby/Node.md b/example/ruby/Node.md deleted file mode 100644 index ea65a61..0000000 --- a/example/ruby/Node.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: Node -**Inherits:** Struct - - - - -# Attributes -## bitwidth[RW] [](#attribute-i-bitwidth) -Returns the value of attribute bitwidth - -**@return** [Object] the current value of bitwidth - -## children[RW] [](#attribute-i-children) -Returns the value of attribute children - -**@return** [Object] the current value of children - -## enum_value[RW] [](#attribute-i-enum_value) -Returns the value of attribute enum_value - -**@return** [Object] the current value of enum_value - -## kind[RW] [](#attribute-i-kind) -Returns the value of attribute kind - -**@return** [Object] the current value of kind - -## offsetof[RW] [](#attribute-i-offsetof) -Returns the value of attribute offsetof - -**@return** [Object] the current value of offsetof - -## sizeof_type[RW] [](#attribute-i-sizeof_type) -Returns the value of attribute sizeof_type - -**@return** [Object] the current value of sizeof_type - -## spelling[RW] [](#attribute-i-spelling) -Returns the value of attribute spelling - -**@return** [Object] the current value of spelling - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type - -**@return** [Object] the current value of type - -## typedef_type[RW] [](#attribute-i-typedef_type) -Returns the value of attribute typedef_type - -**@return** [Object] the current value of typedef_type - - diff --git a/example/ruby/NotImplementedError.md b/example/ruby/NotImplementedError.md deleted file mode 100644 index 1530aba..0000000 --- a/example/ruby/NotImplementedError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: NotImplementedError -**Inherits:** ScriptError - - -Raised when a feature is not implemented on the current platform. For example, -methods depending on the `fsync` or `fork` system calls may raise this -exception if the underlying operating system or Ruby runtime does not support -them. - -Note that if `fork` raises a `NotImplementedError`, then `respond_to?(:fork)` -returns `false`. - - - diff --git a/example/ruby/Notify.md b/example/ruby/Notify.md deleted file mode 100644 index 8e9954f..0000000 --- a/example/ruby/Notify.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Notify -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## done() [](#method-i-done) - -## initialize(biff, command) [](#method-i-initialize) - -**@return** [Notify] a new instance of Notify - -## update(filename, time) [](#method-i-update) - diff --git a/example/ruby/NthToggle.md b/example/ruby/NthToggle.md deleted file mode 100644 index 7a63cd9..0000000 --- a/example/ruby/NthToggle.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: NthToggle -**Inherits:** Toggle - - - - - -#Instance Methods -## activate() [](#method-i-activate) - -## initialize(start_state, max_counter) [](#method-i-initialize) - -**@return** [NthToggle] a new instance of NthToggle - diff --git a/example/ruby/Num2int.md b/example/ruby/Num2int.md deleted file mode 100644 index d665f4c..0000000 --- a/example/ruby/Num2int.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: Num2int - - - - -# Class Methods -## FIX2INT(num ) [](#method-c-FIX2INT) -## FIX2LONG(num ) [](#method-c-FIX2LONG) -## FIX2SHORT(num ) [](#method-c-FIX2SHORT) -## FIX2UINT(num ) [](#method-c-FIX2UINT) -## FIX2ULONG(num ) [](#method-c-FIX2ULONG) -## NUM2INT(num ) [](#method-c-NUM2INT) -## NUM2LL(num ) [](#method-c-NUM2LL) -## NUM2LONG(num ) [](#method-c-NUM2LONG) -## NUM2SHORT(num ) [](#method-c-NUM2SHORT) -## NUM2UINT(num ) [](#method-c-NUM2UINT) -## NUM2ULL(num ) [](#method-c-NUM2ULL) -## NUM2ULONG(num ) [](#method-c-NUM2ULONG) -## NUM2USHORT(num ) [](#method-c-NUM2USHORT) - diff --git a/example/ruby/Numeric.md b/example/ruby/Numeric.md deleted file mode 100644 index 8c8a3dc..0000000 --- a/example/ruby/Numeric.md +++ /dev/null @@ -1,801 +0,0 @@ -# Class: Numeric -**Inherits:** Object - -**Includes:** Comparable - - -Numeric is the class from which all higher-level numeric classes should -inherit. - -Numeric allows instantiation of heap-allocated objects. Other core numeric -classes such as Integer are implemented as immediates, which means that each -Integer is a single immutable object which is always passed by value. - - a = 1 - 1.object_id == a.object_id #=> true - -There can only ever be one instance of the integer `1`, for example. Ruby -ensures this by preventing instantiation. If duplication is attempted, the -same instance is returned. - - Integer.new(1) #=> NoMethodError: undefined method `new' for Integer:Class - 1.dup #=> 1 - 1.object_id == 1.dup.object_id #=> true - -For this reason, Numeric should be used when defining other numeric classes. - -Classes which inherit from Numeric must implement `coerce`, which returns a -two-member Array containing an object that has been coerced into an instance -of the new class and `self` (see #coerce). - -Inheriting classes should also implement arithmetic operator methods (`+`, -`-`, `*` and `/`) and the `<=>` operator (see Comparable). These methods may -rely on `coerce` to ensure interoperability with instances of other numeric -classes. - - class Tally < Numeric - def initialize(string) - @string = string - end - - def to_s - @string - end - - def to_i - @string.size - end - - def coerce(other) - [self.class.new('|' * other.to_i), self] - end - - def <=>(other) - to_i <=> other.to_i - end - - def +(other) - self.class.new('|' * (to_i + other.to_i)) - end - - def -(other) - self.class.new('|' * (to_i - other.to_i)) - end - - def *(other) - self.class.new('|' * (to_i * other.to_i)) - end - - def /(other) - self.class.new('|' * (to_i / other.to_i)) - end - end - - tally = Tally.new('||') - puts tally * 2 #=> "||||" - puts tally > 1 #=> true - -## What's Here - -First, what's elsewhere. Class Numeric: - -* Inherits from [class Object](rdoc-ref:Object@What-27s+Here). -* Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here). - -Here, class Numeric provides methods for: - -* [Querying](rdoc-ref:Numeric@Querying) -* [Comparing](rdoc-ref:Numeric@Comparing) -* [Converting](rdoc-ref:Numeric@Converting) -* [Other](rdoc-ref:Numeric@Other) - -### Querying - -* #finite?: Returns true unless `self` is infinite or not a number. -* #infinite?: Returns -1, `nil` or +1, depending on whether `self` is - `-Infinity, finite, or +Infinity`. -* #integer?: Returns whether `self` is an integer. -* #negative?: Returns whether `self` is negative. -* #nonzero?: Returns whether `self` is not zero. -* #positive?: Returns whether `self` is positive. -* #real?: Returns whether `self` is a real value. -* #zero?: Returns whether `self` is zero. - -### Comparing - -* #<=>: Returns: - - * -1 if `self` is less than the given value. - * 0 if `self` is equal to the given value. - * 1 if `self` is greater than the given value. - * `nil` if `self` and the given value are not comparable. - -* #eql?: Returns whether `self` and the given value have the same value and - type. - -### Converting - -* #% (aliased as #modulo): Returns the remainder of `self` divided by the - given value. -* #-@: Returns the value of `self`, negated. -* #abs (aliased as #magnitude): Returns the absolute value of `self`. -* #abs2: Returns the square of `self`. -* #angle (aliased as #arg and #phase): Returns 0 if `self` is positive, - Math::PI otherwise. -* #ceil: Returns the smallest number greater than or equal to `self`, to a - given precision. -* #coerce: Returns array `[coerced_self, coerced_other]` for the given other - value. -* #conj (aliased as #conjugate): Returns the complex conjugate of `self`. -* #denominator: Returns the denominator (always positive) of the Rational - representation of `self`. -* #div: Returns the value of `self` divided by the given value and converted - to an integer. -* #divmod: Returns array `[quotient, modulus]` resulting from dividing - `self` the given divisor. -* #fdiv: Returns the Float result of dividing `self` by the given divisor. -* #floor: Returns the largest number less than or equal to `self`, to a - given precision. -* #i: Returns the Complex object `Complex(0, self)`. the given value. -* #imaginary (aliased as #imag): Returns the imaginary part of the `self`. -* #numerator: Returns the numerator of the Rational representation of - `self`; has the same sign as `self`. -* #polar: Returns the array `[self.abs, self.arg]`. -* #quo: Returns the value of `self` divided by the given value. -* #real: Returns the real part of `self`. -* #rect (aliased as #rectangular): Returns the array `[self, 0]`. -* #remainder: Returns `self-arg*(self/arg).truncate` for the given `arg`. -* #round: Returns the value of `self` rounded to the nearest value for the - given a precision. -* #to_c: Returns the Complex representation of `self`. -* #to_int: Returns the Integer representation of `self`, truncating if - necessary. -* #truncate: Returns `self` truncated (toward zero) to a given precision. - -### Other - -* #clone: Returns `self`; does not allow freezing. -* #dup (aliased as #+@): Returns `self`. -* #step: Invokes the given block with the sequence of specified numbers. - - - -#Instance Methods -## %(y) [](#method-i-%) -Returns `self` modulo `other` as a real number. - -Of the Core and Standard Library classes, only Rational uses this -implementation. - -For Rational `r` and real number `n`, these expressions are equivalent: - - r % n - r-n*(r/n).floor - r.divmod(n)[1] - -See Numeric#divmod. - -Examples: - - r = Rational(1, 2) # => (1/2) - r2 = Rational(2, 3) # => (2/3) - r % r2 # => (1/2) - r % 2 # => (1/2) - r % 2.0 # => 0.5 - - r = Rational(301,100) # => (301/100) - r2 = Rational(7,5) # => (7/5) - r % r2 # => (21/100) - r % -r2 # => (-119/100) - (-r) % r2 # => (119/100) - (-r) %-r2 # => (-21/100) - -**@overload** [] - -## +@() [](#method-i-+@) -call-seq: - +self -> self - - Returns +self+. - -## -@() [](#method-i--@) -Unary Minus---Returns the receiver, negated. - -**@overload** [] - -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(y) [](#method-i-<=>) -Returns zero if `self` is the same as `other`, `nil` otherwise. - -No subclass in the Ruby Core or Standard Library uses this implementation. - -**@overload** [] - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## abs() [](#method-i-abs) -Returns the absolute value of `self`. - - 12.abs #=> 12 - (-34.56).abs #=> 34.56 - -34.56.abs #=> 34.56 - -**@overload** [] - -## abs2() [](#method-i-abs2) -Returns the square of `self`. - -**@overload** [] - -## angle() [](#method-i-angle) -Returns zero if `self` is positive, Math::PI otherwise. - -**@overload** [] - -## arg() [](#method-i-arg) -Returns zero if `self` is positive, Math::PI otherwise. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## ceil(*args) [](#method-i-ceil) -Returns the smallest float or integer that is greater than or equal to `self`, -as specified by the given `ndigits`, which must be an [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects). - -Equivalent to `self.to_f.ceil(ndigits)`. - -Related: #floor, Float#ceil. - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## clone(*args) [](#method-i-clone) -Returns `self`. - -Raises an exception if the value for `freeze` is neither `true` nor `nil`. - -Related: Numeric#dup. - -**@overload** [] - -## coerce(y) [](#method-i-coerce) -Returns a 2-element array containing two numeric elements, formed from the two -operands `self` and `other`, of a common compatible type. - -Of the Core and Standard Library classes, Integer, Rational, and Complex use -this implementation. - -Examples: - - i = 2 # => 2 - i.coerce(3) # => [3, 2] - i.coerce(3.0) # => [3.0, 2.0] - i.coerce(Rational(1, 2)) # => [0.5, 2.0] - i.coerce(Complex(3, 4)) # Raises RangeError. - - r = Rational(5, 2) # => (5/2) - r.coerce(2) # => [(2/1), (5/2)] - r.coerce(2.0) # => [2.0, 2.5] - r.coerce(Rational(2, 3)) # => [(2/3), (5/2)] - r.coerce(Complex(3, 4)) # => [(3+4i), ((5/2)+0i)] - - c = Complex(2, 3) # => (2+3i) - c.coerce(2) # => [(2+0i), (2+3i)] - c.coerce(2.0) # => [(2.0+0i), (2+3i)] - c.coerce(Rational(1, 2)) # => [((1/2)+0i), (2+3i)] - c.coerce(Complex(3, 4)) # => [(3+4i), (2+3i)] - -Raises an exception if any type conversion fails. - -**@overload** [] - -## conjugate() [](#method-i-conjugate) -call-seq: - conj -> self - -Returns `self`. - -## denominator() [](#method-i-denominator) -Returns the denominator (always positive). - -**@overload** [] - -## div(y) [](#method-i-div) -Returns the quotient `self/other` as an integer (via `floor`), using method -`/` in the derived class of `self`. (Numeric itself does not define method -`/`.) - -Of the Core and Standard Library classes, Only Float and Rational use this -implementation. - -**@overload** [] - -## divmod(y) [](#method-i-divmod) -Returns a 2-element array `[q, r]`, where - - q = (self/other).floor # Quotient - r = self % other # Remainder - -Of the Core and Standard Library classes, only Rational uses this -implementation. - -Examples: - - Rational(11, 1).divmod(4) # => [2, (3/1)] - Rational(11, 1).divmod(-4) # => [-3, (-1/1)] - Rational(-11, 1).divmod(4) # => [-3, (1/1)] - Rational(-11, 1).divmod(-4) # => [2, (-3/1)] - - Rational(12, 1).divmod(4) # => [3, (0/1)] - Rational(12, 1).divmod(-4) # => [-3, (0/1)] - Rational(-12, 1).divmod(4) # => [-3, (0/1)] - Rational(-12, 1).divmod(-4) # => [3, (0/1)] - - Rational(13, 1).divmod(4.0) # => [3, 1.0] - Rational(13, 1).divmod(Rational(4, 11)) # => [35, (3/11)] - -**@overload** [] - -## dup() [](#method-i-dup) -call-seq: - dup -> self - - Returns +self+. - - Related: Numeric#clone. - -## eql?(y) [](#method-i-eql?) -Returns `true` if `self` and `other` are the same type and have equal values. - -Of the Core and Standard Library classes, only Integer, Rational, and Complex -use this implementation. - -Examples: - - 1.eql?(1) # => true - 1.eql?(1.0) # => false - 1.eql?(Rational(1, 1)) # => false - 1.eql?(Complex(1, 0)) # => false - -Method `eql?` is different from `==` in that `eql?` requires matching types, -while `==` does not. - -**@overload** [] - -## fdiv(y) [](#method-i-fdiv) -Returns the quotient `self/other` as a float, using method `/` in the derived -class of `self`. (Numeric itself does not define method `/`.) - -Of the Core and Standard Library classes, only BigDecimal uses this -implementation. - -**@overload** [] - -## finite?() [](#method-i-finite?) -call-seq: - finite? -> true or false - - Returns +true+ if +self+ is a finite number, +false+ otherwise. - -**@return** [Boolean] - -## floor(*args) [](#method-i-floor) -Returns the largest float or integer that is less than or equal to `self`, as -specified by the given `ndigits`, which must be an [integer-convertible -object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects). - -Equivalent to `self.to_f.floor(ndigits)`. - -Related: #ceil, Float#floor. - -**@overload** [] - -## i() [](#method-i-i) -Returns `Complex(0, self)`: - - 2.i # => (0+2i) - -2.i # => (0-2i) - 2.0.i # => (0+2.0i) - Rational(1, 2).i # => (0+(1/2)*i) - Complex(3, 4).i # Raises NoMethodError. - -**@overload** [] - -## imaginary() [](#method-i-imaginary) -call-seq: - imag -> 0 - -Returns zero. - -## infinite?() [](#method-i-infinite?) -call-seq: - infinite? -> -1, 1, or nil - - Returns +nil+, -1, or 1 depending on whether +self+ is - finite, -Infinity, or +Infinity. - -**@return** [Boolean] - -## integer?() [](#method-i-integer?) -call-seq: - integer? -> true or false - - Returns +true+ if +self+ is an Integer. - - 1.0.integer? # => false - 1.integer? # => true - -**@return** [Boolean] - -## magnitude() [](#method-i-magnitude) -Returns the absolute value of `self`. - - 12.abs #=> 12 - (-34.56).abs #=> 34.56 - -34.56.abs #=> 34.56 - -**@overload** [] - -## modulo(y) [](#method-i-modulo) -Returns `self` modulo `other` as a real number. - -Of the Core and Standard Library classes, only Rational uses this -implementation. - -For Rational `r` and real number `n`, these expressions are equivalent: - - r % n - r-n*(r/n).floor - r.divmod(n)[1] - -See Numeric#divmod. - -Examples: - - r = Rational(1, 2) # => (1/2) - r2 = Rational(2, 3) # => (2/3) - r % r2 # => (1/2) - r % 2 # => (1/2) - r % 2.0 # => 0.5 - - r = Rational(301,100) # => (301/100) - r2 = Rational(7,5) # => (7/5) - r % r2 # => (21/100) - r % -r2 # => (-119/100) - (-r) % r2 # => (119/100) - (-r) %-r2 # => (-21/100) - -**@overload** [] - -## negative?() [](#method-i-negative?) -Returns `true` if `self` is less than 0, `false` otherwise. - -**@overload** [] - -## nonzero?() [](#method-i-nonzero?) -Returns `self` if `self` is not a zero value, `nil` otherwise; uses method -`zero?` for the evaluation. - -The returned `self` allows the method to be chained: - - a = %w[z Bb bB bb BB a aA Aa AA A] - a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b } - # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"] - -Of the Core and Standard Library classes, Integer, Float, Rational, and -Complex use this implementation. - -Related: #zero? - -**@overload** [] - -## numerator() [](#method-i-numerator) -Returns the numerator. - -**@overload** [] - -## phase() [](#method-i-phase) -Returns zero if `self` is positive, Math::PI otherwise. - -**@overload** [] - -## polar() [](#method-i-polar) -Returns array `[self.abs, self.arg]`. - -**@overload** [] - -## positive?() [](#method-i-positive?) -Returns `true` if `self` is greater than 0, `false` otherwise. - -**@overload** [] - -## quo(y) [](#method-i-quo) -Returns the most exact division (rational for integers, float for floats). - -**@overload** [] - -**@overload** [] - -## real() [](#method-i-real) -call-seq: - real -> self - -Returns `self`. - -## real?() [](#method-i-real?) -call-seq: - real? -> true or false - - Returns +true+ if +self+ is a real number (i.e. not Complex). - -**@return** [Boolean] - -## rect() [](#method-i-rect) -Returns array `[self, 0]`. - -**@overload** [] - -## rectangular() [](#method-i-rectangular) -Returns array `[self, 0]`. - -**@overload** [] - -## remainder(y) [](#method-i-remainder) -Returns the remainder after dividing `self` by `other`. - -Of the Core and Standard Library classes, only Float and Rational use this -implementation. - -Examples: - - 11.0.remainder(4) # => 3.0 - 11.0.remainder(-4) # => 3.0 - -11.0.remainder(4) # => -3.0 - -11.0.remainder(-4) # => -3.0 - - 12.0.remainder(4) # => 0.0 - 12.0.remainder(-4) # => 0.0 - -12.0.remainder(4) # => -0.0 - -12.0.remainder(-4) # => -0.0 - - 13.0.remainder(4.0) # => 1.0 - 13.0.remainder(Rational(4, 1)) # => 1.0 - - Rational(13, 1).remainder(4) # => (1/1) - Rational(13, 1).remainder(-4) # => (1/1) - Rational(-13, 1).remainder(4) # => (-1/1) - Rational(-13, 1).remainder(-4) # => (-1/1) - -**@overload** [] - -## round(*args) [](#method-i-round) -Returns `self` rounded to the nearest value with a precision of `digits` -decimal digits. - -Numeric implements this by converting `self` to a Float and invoking -Float#round. - -**@overload** [] - -## singleton_method_added(name) [](#method-i-singleton_method_added) -:nodoc: - -Trap attempts to add methods to Numeric objects. Always raises a TypeError. - -Numerics should be values; singleton_methods should not be added to them. - -## step(*args) [](#method-i-step) -Generates a sequence of numbers; with a block given, traverses the sequence. - -Of the Core and Standard Library classes, Integer, Float, and Rational use -this implementation. - -A quick example: - - squares = [] - 1.step(by: 2, to: 10) {|i| squares.push(i*i) } - squares # => [1, 9, 25, 49, 81] - -The generated sequence: - -* Begins with `self`. -* Continues at intervals of `by` (which may not be zero). -* Ends with the last number that is within or equal to `to`; - that is, less than or equal to +to+ if +by+ is positive, - greater than or equal to +to+ if +by+ is negative. - If +to+ is +nil+, the sequence is of infinite length. - -If a block is given, calls the block with each number in the sequence; returns -`self`. If no block is given, returns an Enumerator::ArithmeticSequence. - -**Keyword Arguments** - -With keyword arguments `by` and `to`, their values (or defaults) determine the -step and limit: - - # Both keywords given. - squares = [] - 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4 - squares # => [16, 36, 64, 100] - cubes = [] - 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3 - cubes # => [27.0, 3.375, 0.0, -3.375, -27.0] - squares = [] - 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) } - squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0] - - squares = [] - Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) } - squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0] - - # Only keyword to given. - squares = [] - 4.step(to: 10) {|i| squares.push(i*i) } # => 4 - squares # => [16, 25, 36, 49, 64, 81, 100] - # Only by given. - - # Only keyword by given - squares = [] - 4.step(by:2) {|i| squares.push(i*i); break if i > 10 } - squares # => [16, 36, 64, 100, 144] - - # No block given. - e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3)) - e.class # => Enumerator::ArithmeticSequence - -**Positional Arguments** - -With optional positional arguments `to` and `by`, their values (or defaults) -determine the step and limit: - - squares = [] - 4.step(10, 2) {|i| squares.push(i*i) } # => 4 - squares # => [16, 36, 64, 100] - squares = [] - 4.step(10) {|i| squares.push(i*i) } - squares # => [16, 25, 36, 49, 64, 81, 100] - squares = [] - 4.step {|i| squares.push(i*i); break if i > 10 } # => nil - squares # => [16, 25, 36, 49, 64, 81, 100, 121] - -**Implementation Notes** - -If all the arguments are integers, the loop operates using an integer counter. - -If any of the arguments are floating point numbers, all are converted to -floats, and the loop is executed *floor(n + n*Float::EPSILON) + 1* times, -where *n = (limit - self)/step*. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## to_c() [](#method-i-to_c) -Returns `self` as a Complex object. - -**@overload** [] - -## to_int() [](#method-i-to_int) -Returns `self` as an integer; converts using method `to_i` in the derived -class. - -Of the Core and Standard Library classes, only Rational and Complex use this -implementation. - -Examples: - - Rational(1, 2).to_int # => 0 - Rational(2, 1).to_int # => 2 - Complex(2, 0).to_int # => 2 - Complex(2, 1).to_int # Raises RangeError (non-zero imaginary part) - -**@overload** [] - -## truncate(*args) [](#method-i-truncate) -Returns `self` truncated (toward zero) to a precision of `digits` decimal -digits. - -Numeric implements this by converting `self` to a Float and invoking -Float#truncate. - -**@overload** [] - -## zero?() [](#method-i-zero?) -Returns `true` if `zero` has a zero value, `false` otherwise. - -Of the Core and Standard Library classes, only Rational and Complex use this -implementation. - -**@overload** [] - diff --git a/example/ruby/NumericMockObject.md b/example/ruby/NumericMockObject.md deleted file mode 100644 index 9830df3..0000000 --- a/example/ruby/NumericMockObject.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: NumericMockObject -**Inherits:** Numeric - - - - - -#Instance Methods -## initialize(name, options{}) [](#method-i-initialize) - -**@return** [NumericMockObject] a new instance of NumericMockObject - -## method_missing(sym, *args, &block) [](#method-i-method_missing) - -## singleton_method_added(val) [](#method-i-singleton_method_added) - diff --git a/example/ruby/NumericSpecs.md b/example/ruby/NumericSpecs.md deleted file mode 100644 index a348a52..0000000 --- a/example/ruby/NumericSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: NumericSpecs - - - - - diff --git a/example/ruby/NumericSpecs/Comparison.md b/example/ruby/NumericSpecs/Comparison.md deleted file mode 100644 index f2a97ff..0000000 --- a/example/ruby/NumericSpecs/Comparison.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: NumericSpecs::Comparison -**Inherits:** Numeric - - - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -This method is used because we cannot define singleton methods on subclasses -of Numeric, which is needed for a.should_receive to work. - diff --git a/example/ruby/NumericSpecs/Subclass.md b/example/ruby/NumericSpecs/Subclass.md deleted file mode 100644 index e6d2199..0000000 --- a/example/ruby/NumericSpecs/Subclass.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: NumericSpecs::Subclass -**Inherits:** Numeric - - - - - -#Instance Methods -## singleton_method_added(val) [](#method-i-singleton_method_added) -Allow methods to be mocked - diff --git a/example/ruby/OLEtagDOMNodeType.md b/example/ruby/OLEtagDOMNodeType.md deleted file mode 100644 index 4b1e45d..0000000 --- a/example/ruby/OLEtagDOMNodeType.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: OLEtagDOMNodeType - -**Includes:** WIN32OLE::VARIANT - - -Constants that define a node's type - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - diff --git a/example/ruby/OLEtagXMLEMEM_TYPE.md b/example/ruby/OLEtagXMLEMEM_TYPE.md deleted file mode 100644 index 1ab3599..0000000 --- a/example/ruby/OLEtagXMLEMEM_TYPE.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: OLEtagXMLEMEM_TYPE - -**Includes:** WIN32OLE::VARIANT - - -Constants that define types for IXMLElement. - - -# Attributes -## lastargs[RW] [](#attribute-i-lastargs) -Returns the value of attribute lastargs. - - diff --git a/example/ruby/Object.md b/example/ruby/Object.md deleted file mode 100644 index 82b4794..0000000 --- a/example/ruby/Object.md +++ /dev/null @@ -1,2785 +0,0 @@ -# Class: Object -**Inherits:** BasicObject - -**Includes:** Kernel, ModuleSpecs::IncludedInObject, PP::ObjectMixin - - -https://github.com/seattlerb/minitest/blob/13c48a03d84a2a87855a4de0c959f968001 -00357/lib/minitest/mock.rb#L192 - - -# Class Methods -## const_missing(c ) [](#method-c-const_missing) -**@raise** [NameError] - -## example_class_method_of_object() [](#method-c-example_class_method_of_object) -## yaml_tag(url ) [](#method-c-yaml_tag) - -#Instance Methods -## !~(obj2) [](#method-i-!~) -Returns true if two objects do not match (using the *=~* method), otherwise -false. - -**@overload** [] - -## <=>(obj2) [](#method-i-<=>) -Returns 0 if `obj` and `other` are the same object or `obj == other`, -otherwise nil. - -The #<=> is used by various methods to compare objects, for example -Enumerable#sort, Enumerable#max etc. - -Your implementation of #<=> should return one of the following values: -1, 0, -1 or nil. -1 means self is smaller than other. 0 means self is equal to other. -1 means self is bigger than other. Nil means the two values could not be -compared. - -When you define #<=>, you can include Comparable to gain the methods #<=, #<, -#==, #>=, #> and #between?. - -**@overload** [] - -## ===() [](#method-i-===) - -## Array(arg) [](#method-i-Array) -Returns an array converted from `object`. - -Tries to convert `object` to an array using `to_ary` first and `to_a` second: - - Array([0, 1, 2]) # => [0, 1, 2] - Array({foo: 0, bar: 1}) # => [[:foo, 0], [:bar, 1]] - Array(0..4) # => [0, 1, 2, 3, 4] - -Returns `object` in an array, `[object]`, if `object` cannot be converted: - - Array(:foo) # => [:foo] - -**@overload** [] - -## Complex(*args) [](#method-i-Complex) -Returns a new Complex object if the arguments are valid; otherwise raises an -exception if `exception` is `true`; otherwise returns `nil`. - -With Numeric arguments `real` and `imag`, returns `Complex.rect(real, imag)` -if the arguments are valid. - -With string argument `s`, returns a new Complex object if the argument is -valid; the string may have: - -* One or two numeric substrings, each of which specifies a Complex, Float, - Integer, Numeric, or Rational value, specifying [rectangular - coordinates](rdoc-ref:Complex@Rectangular+Coordinates): - - * Sign-separated real and imaginary numeric substrings (with trailing - character `'i'`): - - Complex('1+2i') # => (1+2i) - Complex('+1+2i') # => (1+2i) - Complex('+1-2i') # => (1-2i) - Complex('-1+2i') # => (-1+2i) - Complex('-1-2i') # => (-1-2i) - - * Real-only numeric string (without trailing character `'i'`): - - Complex('1') # => (1+0i) - Complex('+1') # => (1+0i) - Complex('-1') # => (-1+0i) - - * Imaginary-only numeric string (with trailing character `'i'`): - - Complex('1i') # => (0+1i) - Complex('+1i') # => (0+1i) - Complex('-1i') # => (0-1i) - -* At-sign separated real and imaginary rational substrings, each of which - specifies a Rational value, specifying [polar - coordinates](rdoc-ref:Complex@Polar+Coordinates): - - Complex('1/2@3/4') # => (0.36584443443691045+0.34081938001166706i) - Complex('+1/2@+3/4') # => (0.36584443443691045+0.34081938001166706i) - Complex('+1/2@-3/4') # => (0.36584443443691045-0.34081938001166706i) - Complex('-1/2@+3/4') # => (-0.36584443443691045-0.34081938001166706i) - Complex('-1/2@-3/4') # => (-0.36584443443691045+0.34081938001166706i) - -**@overload** [] - -**@overload** [] - -## Hash(arg) [](#method-i-Hash) -Returns a hash converted from `object`. - -* If `object` is: - - * A hash, returns `object`. - * An empty array or `nil`, returns an empty hash. - -* Otherwise, if `object.to_hash` returns a hash, returns that hash. -* Otherwise, returns TypeError. - -Examples: - - Hash({foo: 0, bar: 1}) # => {:foo=>0, :bar=>1} - Hash(nil) # => {} - Hash([]) # => {} - -**@overload** [] - -## Pathname(str) [](#method-i-Pathname) -:call-seq: - Pathname(path) -> pathname - -Creates a new Pathname object from the given string, `path`, and returns -pathname object. - -In order to use this constructor, you must first require the Pathname standard -library extension. - -require 'pathname' Pathname("/home/zzak") #=> # - -See also Pathname::new for more information. - -## Rational(*args) [](#method-i-Rational) -Returns `x/y` or `arg` as a Rational. - - Rational(2, 3) #=> (2/3) - Rational(5) #=> (5/1) - Rational(0.5) #=> (1/2) - Rational(0.3) #=> (5404319552844595/18014398509481984) - - Rational("2/3") #=> (2/3) - Rational("0.3") #=> (3/10) - - Rational("10 cents") #=> ArgumentError - Rational(nil) #=> TypeError - Rational(1, nil) #=> TypeError - - Rational("10 cents", exception: false) #=> nil - -Syntax of the string form: - - string form = extra spaces , rational , extra spaces ; - rational = [ sign ] , unsigned rational ; - unsigned rational = numerator | numerator , "/" , denominator ; - numerator = integer part | fractional part | integer part , fractional part ; - denominator = digits ; - integer part = digits ; - fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; - sign = "-" | "+" ; - digits = digit , { digit | "_" , digit } ; - digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; - extra spaces = ? \s* ? ; - -See also String#to_r. - -**@overload** [] - -**@overload** [] - -## String(arg) [](#method-i-String) -Returns a string converted from `object`. - -Tries to convert `object` to a string using `to_str` first and `to_s` second: - - String([0, 1, 2]) # => "[0, 1, 2]" - String(0..5) # => "0..5" - String({foo: 0, bar: 1}) # => "{foo: 0, bar: 1}" - -Raises `TypeError` if `object` cannot be converted to a string. - -**@overload** [] - -## __callee__() [](#method-i-__callee__) -Returns the called name of the current method as a Symbol. If called outside -of a method, it returns `nil`. - -**@overload** [] - -## __dir__() [](#method-i-__dir__) -Returns the canonicalized absolute path of the directory of the file from -which this method is called. It means symlinks in the path is resolved. If -`__FILE__` is `nil`, it returns `nil`. The return value equals to -`File.dirname(File.realpath(__FILE__))`. - -**@overload** [] - -## __method__() [](#method-i-__method__) -Returns the name at the definition of the current method as a Symbol. If -called outside of a method, it returns `nil`. - -**@overload** [] - -## `(str) [](#method-i-`) -Returns the `$stdout` output from running `command` in a subshell; sets global -variable `$?` to the process status. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Examples: - - $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n" - $ `echo oops && exit 99` # => "oops\n" - $ $? # => # - $ $?.status # => 99> - -The built-in syntax `%x{...}` uses this method. - -**@overload** [] - -## abort(*a, _) [](#method-i-abort) -Terminates execution immediately, effectively by calling `Kernel.exit(false)`. - -If string argument `msg` is given, it is written to STDERR prior to -termination; otherwise, if an exception was raised, prints its message and -backtrace. - -**@overload** [] - -**@overload** [] - -## arg1(arg1) [](#method-i-arg1) - -## argm1(*args) [](#method-i-argm1) - -## at_exit() [](#method-i-at_exit) -Converts *block* to a `Proc` object (and therefore binds it at the point of -call) and registers it for execution when the program exits. If multiple -handlers are registered, they are executed in reverse order of registration. - - def do_at_exit(str1) - at_exit { print str1 } - end - at_exit { puts "cruel world" } - do_at_exit("goodbye ") - exit - -*produces:* - - goodbye cruel world - -**@overload** [] - -## autoload(sym, file) [](#method-i-autoload) -Registers *filename* to be loaded (using Kernel::require) the first time that -*const* (which may be a String or a symbol) is accessed. - - autoload(:MyModule, "/usr/local/lib/modules/my_module.rb") - -If *const* is defined as autoload, the file name to be loaded is replaced with -*filename*. If *const* is defined but not as autoload, does nothing. - -**@overload** [] - -## autoload?(*args) [](#method-i-autoload?) -Returns *filename* to be loaded if *name* is registered as `autoload` in the -current namespace or one of its ancestors. - - autoload(:B, "b") - autoload?(:B) #=> "b" - - module C - autoload(:D, "d") - autoload?(:D) #=> "d" - autoload?(:B) #=> nil - end - - class E - autoload(:F, "f") - autoload?(:F) #=> "f" - autoload?(:B) #=> "b" - end - -**@overload** [] - -## be_close_to_matrix(expected, toleranceTOLERANCE) [](#method-i-be_close_to_matrix) - -## binding() [](#method-i-binding) -Returns a Binding object, describing the variable and method bindings at the -point of call. This object can be used when calling Binding#eval to execute -the evaluated command in this environment, or extracting its local variables. - - class User - def initialize(name, position) - @name = name - @position = position - end - - def get_binding - binding - end - end - - user = User.new('Joan', 'manager') - template = '{name: @name, position: @position}' - - # evaluate template in context of the object - eval(template, user.get_binding) - #=> {:name=>"Joan", :position=>"manager"} - -Binding#local_variable_get can be used to access the variables whose names are -reserved Ruby keywords: - - # This is valid parameter declaration, but `if` parameter can't - # be accessed by name, because it is a reserved word. - def validate(field, validation, if: nil) - condition = binding.local_variable_get('if') - return unless condition - - # ...Some implementation ... - end - - validate(:name, :empty?, if: false) # skips validation - validate(:name, :empty?, if: true) # performs validation - -**@overload** [] - -## block_given?() [](#method-i-block_given?) -Returns `true` if `yield` would execute a block in the current context. The -`iterator?` form is mildly deprecated. - - def try - if block_given? - yield - else - "no block" - end - end - try #=> "no block" - try { "hello" } #=> "hello" - try do "hello" end #=> "hello" - -**@overload** [] - -## callable_methods() [](#method-i-callable_methods) - -## callcc() [](#method-i-callcc) -Generates a Continuation object, which it passes to the associated block. You -need to `require 'continuation'` before using this method. Performing a -*cont*`.call` will cause the #callcc to return (as will falling through the -end of the block). The value returned by the #callcc is the value of the -block, or the value passed to *cont*`.call`. See class Continuation for more -details. Also see Kernel#throw for an alternative mechanism for unwinding a -call stack. - -**@overload** [] - -## caller(*args) [](#method-i-caller) -Returns the current execution stack---an array containing strings in the form -`file:line` or `file:line: in `method'`. - -The optional *start* parameter determines the number of initial stack entries -to omit from the top of the stack. - -A second optional `length` parameter can be used to limit how many entries are -returned from the stack. - -Returns `nil` if *start* is greater than the size of current execution stack. - -Optionally you can pass a range, which will return an array containing the -entries within the specified range. - - def a(skip) - caller(skip) - end - def b(skip) - a(skip) - end - def c(skip) - b(skip) - end - c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `
'"] - c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `
'"] - c(2) #=> ["prog:8:in `c'", "prog:12:in `
'"] - c(3) #=> ["prog:13:in `
'"] - c(4) #=> [] - c(5) #=> nil - -**@overload** [] - -**@overload** [] - -## caller_locations(*args) [](#method-i-caller_locations) -Returns the current execution stack---an array containing backtrace location -objects. - -See Thread::Backtrace::Location for more information. - -The optional *start* parameter determines the number of initial stack entries -to omit from the top of the stack. - -A second optional `length` parameter can be used to limit how many entries are -returned from the stack. - -Returns `nil` if *start* is greater than the size of current execution stack. - -Optionally you can pass a range, which will return an array containing the -entries within the specified range. - -**@overload** [] - -**@overload** [] - -## catch(*args) [](#method-i-catch) -`catch` executes its block. If `throw` is not called, the block executes -normally, and `catch` returns the value of the last expression evaluated. - - catch(1) { 123 } # => 123 - -If `throw(tag2, val)` is called, Ruby searches up its stack for a `catch` -block whose `tag` has the same `object_id` as *tag2*. When found, the block -stops executing and returns *val* (or `nil` if no second argument was given to -`throw`). - - catch(1) { throw(1, 456) } # => 456 - catch(1) { throw(1) } # => nil - -When `tag` is passed as the first argument, `catch` yields it as the parameter -of the block. - - catch(1) {|x| x + 2 } # => 3 - -When no `tag` is given, `catch` yields a new unique object (as from -`Object.new`) as the block parameter. This object can then be used as the -argument to `throw`, and will match the correct `catch` block. - - catch do |obj_A| - catch do |obj_B| - throw(obj_B, 123) - puts "This puts is not reached" - end - - puts "This puts is displayed" - 456 - end - - # => 456 - - catch do |obj_A| - catch do |obj_B| - throw(obj_A, 123) - puts "This puts is still not reached" - end - - puts "Now this puts is also not reached" - 456 - end - - # => 123 - -**@overload** [] - -## chomp(*args) [](#method-i-chomp) -Equivalent to `$_ = $_.chomp(*string*)`. See String#chomp. Available only when --p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## chop() [](#method-i-chop) -Equivalent to `($_.dup).chop!`, except `nil` is never returned. See -String#chop!. Available only when -p/-n command line option specified. - -**@overload** [] - -## class() [](#method-i-class) -call-seq: - obj.class -> class - - Returns the class of obj. This method must always be called - with an explicit receiver, as #class is also a reserved word in - Ruby. - - 1.class #=> Integer - self.class #=> Object - --- Equivalent to c Object#class in Ruby. - -Returns the class of c obj, skipping singleton classes or module inclusions. -++ - -## clone(freeze:nil) [](#method-i-clone) -call-seq: - obj.clone(freeze: nil) -> an_object - - Produces a shallow copy of obj---the instance variables of - obj are copied, but not the objects they reference. - #clone copies the frozen value state of obj, unless the - +:freeze+ keyword argument is given with a false or true value. - See also the discussion under Object#dup. - - class Klass - attr_accessor :str - end - s1 = Klass.new #=> # - s1.str = "Hello" #=> "Hello" - s2 = s1.clone #=> # - s2.str[1,4] = "i" #=> "i" - s1.inspect #=> "#" - s2.inspect #=> "#" - - This method may have class-specific behavior. If so, that - behavior will be documented under the #+initialize_copy+ method of - the class. - -## define_singleton_method(*args) [](#method-i-define_singleton_method) -Defines a public singleton method in the receiver. The *method* parameter can -be a `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, -it is used as the method body. If a block or a method has parameters, they're -used as method parameters. - - class A - class << self - def class_name - to_s - end - end - end - A.define_singleton_method(:who_am_i) do - "I am: #{class_name}" - end - A.who_am_i # ==> "I am: A" - - guy = "Bob" - guy.define_singleton_method(:hello) { "#{self}: Hello there!" } - guy.hello #=> "Bob: Hello there!" - - chris = "Chris" - chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" } - chris.greet("Hi") #=> "Hi, I'm Chris!" - -**@overload** [] - -**@overload** [] - -## defined_specs_method() [](#method-i-defined_specs_method) - -## defined_specs_receiver() [](#method-i-defined_specs_receiver) - -## display(*args) [](#method-i-display) -Writes `self` on the given port: - - 1.display - "cat".display - [ 4, 5, 6 ].display - puts - -Output: - - 1cat[4, 5, 6] - -**@overload** [] - -## dup() [](#method-i-dup) -Produces a shallow copy of *obj*---the instance variables of *obj* are copied, -but not the objects they reference. - -This method may have class-specific behavior. If so, that behavior will be -documented under the #`initialize_copy` method of the class. - -### on dup vs clone - -In general, #clone and #dup may have different semantics in descendant -classes. While #clone is used to duplicate an object, including its internal -state, #dup typically uses the class of the descendant object to create the -new instance. - -When using #dup, any modules that the object has been extended with will not -be copied. - -class Klass - attr_accessor :str - -end - -module Foo - def foo; 'foo'; end - -end - -s1 = Klass.new #=> # s1.extend(Foo) #=> # -s1.foo #=> "foo" - -s2 = s1.clone #=> # s2.foo #=> "foo" - -s3 = s1.dup #=> # s3.foo #=> NoMethodError: undefined method -`foo' for # - -**@overload** [] - -## enum_for(*args) [](#method-i-enum_for) -Creates a new Enumerator which will enumerate by calling `method` on `obj`, -passing `args` if any. What was *yielded* by method becomes values of -enumerator. - -If a block is given, it will be used to calculate the size of the enumerator -without the need to iterate it (see Enumerator#size). - -### Examples - - str = "xyz" - - enum = str.enum_for(:each_byte) - enum.each { |b| puts b } - # => 120 - # => 121 - # => 122 - - # protect an array from being modified by some_method - a = [1, 2, 3] - some_method(a.to_enum) - - # String#split in block form is more memory-effective: - very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') } - # This could be rewritten more idiomatically with to_enum: - very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first - -It is typical to call to_enum when defining methods for a generic Enumerable, -in case no block is passed. - -Here is such an example, with parameter passing and a sizing block: - - module Enumerable - # a generic method to repeat the values of any enumerable - def repeat(n) - raise ArgumentError, "#{n} is negative!" if n < 0 - unless block_given? - return to_enum(__method__, n) do # __method__ is :repeat here - sz = size # Call size and multiply by n... - sz * n if sz # but return nil if size itself is nil - end - end - each do |*val| - n.times { yield *val } - end - end - end - - %i[hello world].repeat(2) { |w| puts w } - # => Prints 'hello', 'hello', 'world', 'world' - enum = (1..14).repeat(3) - # => returns an Enumerator when called without a block - enum.first(4) # => [1, 1, 1, 2] - enum.size # => 42 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## eql?(obj2) [](#method-i-eql?) -Equality --- At the Object level, #== returns `true` only if `obj` and `other` -are the same object. Typically, this method is overridden in descendant -classes to provide class-specific meaning. - -Unlike #==, the #equal? method should never be overridden by subclasses as it -is used to determine object identity (that is, `a.equal?(b)` if and only if -`a` is the same object as `b`): - - obj = "a" - other = obj.dup - - obj == other #=> true - obj.equal? other #=> false - obj.equal? obj #=> true - -The #eql? method returns `true` if `obj` and `other` refer to the same hash -key. This is used by Hash to test members for equality. For any pair of -objects where #eql? returns `true`, the #hash value of both objects must be -equal. So any subclass that overrides #eql? should also override #hash -appropriately. - -For objects of class Object, #eql? is synonymous with #==. Subclasses -normally continue this tradition by aliasing #eql? to their overridden #== -method, but there are exceptions. Numeric types, for example, perform type -conversion across #==, but not across #eql?, so: - - 1 == 1.0 #=> true - 1.eql? 1.0 #=> false - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## eval(*args) [](#method-i-eval) -Evaluates the Ruby expression(s) in *string*. If *binding* is given, which -must be a Binding object, the evaluation is performed in its context. If the -optional *filename* and *lineno* parameters are present, they will be used -when reporting syntax errors. - - def get_binding(str) - return binding - end - str = "hello" - eval "str + ' Fred'" #=> "hello Fred" - eval "str + ' Fred'", get_binding("bye") #=> "bye Fred" - -**@overload** [] - -## example_instance_method_of_object() [](#method-i-example_instance_method_of_object) - -## exec(*a, _) [](#method-i-exec) -Replaces the current process by doing one of the following: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -The new process is created using the [exec system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e -xecve.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - exec('if true; then echo "Foo"; fi') # Shell reserved word. - exec('exit') # Built-in. - exec('date > date.tmp') # Contains meta character. - -The command line may also contain arguments and options for the command: - - exec('echo "Foo"') - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - exec('/usr/bin/date') - -Output: - - Sat Aug 26 09:38:00 AM CDT 2023 - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - - exec('doesnt_exist') # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - exec('echo', 'C*') - exec('echo', 'hello', 'world') - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## exit(*a, _) [](#method-i-exit) -Initiates termination of the Ruby script by raising SystemExit; the exception -may be caught. Returns exit status `status` to the underlying operating -system. - -Values `true` and `false` for argument `status` indicate, respectively, -success and failure; The meanings of integer values are system-dependent. - -Example: - - begin - exit - puts 'Never get here.' - rescue SystemExit - puts 'Rescued a SystemExit exception.' - end - puts 'After begin block.' - -Output: - - Rescued a SystemExit exception. - After begin block. - -Just prior to final termination, Ruby executes any at-exit procedures (see -Kernel::at_exit) and any object finalizers (see -ObjectSpace::define_finalizer). - -Example: - - at_exit { puts 'In at_exit function.' } - ObjectSpace.define_finalizer('string', proc { puts 'In finalizer.' }) - exit - -Output: - - In at_exit function. - In finalizer. - -**@overload** [] - -**@overload** [] - -## exit!(*args) [](#method-i-exit!) -Exits the process immediately; no exit handlers are called. Returns exit -status `status` to the underlying operating system. - - Process.exit!(true) - -Values `true` and `false` for argument `status` indicate, respectively, -success and failure; The meanings of integer values are system-dependent. - -**@overload** [] - -**@overload** [] - -## extend(*args) [](#method-i-extend) -Adds to *obj* the instance methods from each module given as a parameter. - - module Mod - def hello - "Hello from Mod.\n" - end - end - - class Klass - def hello - "Hello from Klass.\n" - end - end - - k = Klass.new - k.hello #=> "Hello from Klass.\n" - k.extend(Mod) #=> # - k.hello #=> "Hello from Mod.\n" - -**@overload** [] - -## fail(*v, _) [](#method-i-fail) -Raises an exception; see [Exceptions](rdoc-ref:exceptions.md). - -Argument `exception` sets the class of the new exception; it should be class -Exception or one of its subclasses (most commonly, RuntimeError or -StandardError), or an instance of one of those classes: - - begin - raise(StandardError) - rescue => x - p x.class - end - # => StandardError - -Argument `message` sets the stored message in the new exception, which may be -retrieved by method Exception#message; the message must be a -[string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or -`nil`: - - begin - raise(StandardError, 'Boom') - rescue => x - p x.message - end - # => "Boom" - -If argument `message` is not given, the message is the exception class name. - -See [Messages](rdoc-ref:exceptions.md@Messages). - -Argument `backtrace` might be used to modify the backtrace of the new -exception, as reported by Exception#backtrace and -Exception#backtrace_locations; the backtrace must be an array of -Thread::Backtrace::Location, an array of strings, a single string, or `nil`. - -Using the array of Thread::Backtrace::Location instances is the most -consistent option and should be preferred when possible. The necessary value -might be obtained from #caller_locations, or copied from -Exception#backtrace_locations of another error: - - begin - do_some_work() - rescue ZeroDivisionError => ex - raise(LogicalError, "You have an error in your math", ex.backtrace_locations) - end - -The ways, both Exception#backtrace and Exception#backtrace_locations of the -raised error are set to the same backtrace. - -When the desired stack of locations is not available and should be constructed -from scratch, an array of strings or a singular string can be used. In this -case, only Exception#backtrace is set: - - begin - raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1]) - rescue => ex - p ex.backtrace - # => ["dsl.rb:3", "framework.rb:1"] - p ex.backtrace_locations - # => nil - end - -If argument `backtrace` is not given, the backtrace is set according to an -array of Thread::Backtrace::Location objects, as derived from the call stack. - -See [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -Keyword argument `cause` sets the stored cause in the new exception, which may -be retrieved by method Exception#cause; the cause must be an exception object -(Exception or one of its subclasses), or `nil`: - - begin - raise(StandardError, cause: RuntimeError.new) - rescue => x - p x.cause - end - # => # - -If keyword argument `cause` is not given, the cause is the value of `$!`. - -See [Cause](rdoc-ref:exceptions.md@Cause). - -In the alternate calling sequence, where argument `exception` *not* given, -raises a new exception of the class given by `$!`, or of class RuntimeError if -`$!` is `nil`: - - begin - raise - rescue => x - p x - end - # => RuntimeError - -With argument `exception` not given, argument `message` and keyword argument -`cause` may be given, but argument `backtrace` may not be given. - -**@overload** [] - -**@overload** [] - -## fork() [](#method-i-fork) -Creates a child process. - -With a block given, runs the block in the child process; on block exit, the -child terminates with a status of zero: - - puts "Before the fork: #{Process.pid}" - fork do - puts "In the child process: #{Process.pid}" - end # => 382141 - puts "After the fork: #{Process.pid}" - -Output: - - Before the fork: 420496 - After the fork: 420496 - In the child process: 420520 - -With no block given, the `fork` call returns twice: - -* Once in the parent process, returning the pid of the child process. -* Once in the child process, returning `nil`. - -Example: - - puts "This is the first line before the fork (pid #{Process.pid})" - puts fork - puts "This is the second line after the fork (pid #{Process.pid})" - -Output: - - This is the first line before the fork (pid 420199) - 420223 - This is the second line after the fork (pid 420199) - - This is the second line after the fork (pid 420223) - -In either case, the child process may exit using Kernel.exit! to avoid the -call to Kernel#at_exit. - -To avoid zombie processes, the parent process should call either: - -* Process.wait, to collect the termination statuses of its children. -* Process.detach, to register disinterest in their status. - -The thread calling `fork` is the only thread in the created child process; -`fork` doesn't copy other threads. - -Note that method `fork` is available on some platforms, but not on others: - - Process.respond_to?(:fork) # => true # Would be false on some. - -If not, you may use ::spawn instead of `fork`. - -**@overload** [] - -**@overload** [] - -## format(*v, _) [](#method-i-format) -Returns the string resulting from formatting `objects` into `format_string`. - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -**@overload** [] - -## freeze() [](#method-i-freeze) -Prevents further modifications to *obj*. A FrozenError will be raised if -modification is attempted. There is no way to unfreeze a frozen object. See -also Object#frozen?. - -This method returns self. - - a = [ "a", "b", "c" ] - a.freeze - a << "z" - -*produces:* - - prog.rb:3:in `<<': can't modify frozen Array (FrozenError) - from prog.rb:3 - -Objects of the following classes are always frozen: Integer, Float, Symbol. - -**@overload** [] - -## frozen?() [](#method-i-frozen?) -call-seq: - obj.frozen? -> true or false - - Returns the freeze status of obj. - - a = [ "a", "b", "c" ] - a.freeze #=> ["a", "b", "c"] - a.frozen? #=> true - --- Determines if the object is frozen. Equivalent to `Object#frozen?` in Ruby. -@[param](in) obj the object to be determines ++ - -**@return** [Boolean] - -## gets(*args) [](#method-i-gets) -Returns (and assigns to `$_`) the next line from the list of files in `ARGV` -(or `$*`), or from standard input if no files are present on the command line. -Returns `nil` at end of file. The optional argument specifies the record -separator. The separator is included with the contents of each record. A -separator of `nil` reads the entire contents, and a zero-length separator -reads the input one paragraph at a time, where paragraphs are divided by two -consecutive newlines. If the first argument is an integer, or optional second -argument is given, the returning string would not be longer than the given -value in bytes. If multiple filenames are present in `ARGV`, `gets(nil)` will -read the contents one file at a time. - - ARGV << "testfile" - print while gets - -*produces:* - - This is line one - This is line two - This is line three - And so on... - -The style of programming using `$_` as an implicit parameter is gradually -losing favor in the Ruby community. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## global_variables() [](#method-i-global_variables) -Returns an array of the names of global variables. This includes special -regexp global variables such as `$~` and `$+`, but does not include the -numbered regexp global variables (`$1`, `$2`, etc.). - - global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr] - -**@overload** [] - -## gsub(*args) [](#method-i-gsub) -Equivalent to `$_.gsub...`, except that `$_` will be updated if substitution -occurs. Available only when -p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) - -## initialize_clone(*args) [](#method-i-initialize_clone) -:nodoc: - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## initialize_dup(orig) [](#method-i-initialize_dup) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a string containing a human-readable representation of *obj*. The -default #inspect shows the object's class name, an encoding of its memory -address, and a list of the instance variables and their values (by calling -#inspect on each of them). User defined classes should override this method -to provide a better representation of *obj*. When overriding this method, it -should return a string whose encoding is compatible with the default external -encoding. - - [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" - Time.new.inspect #=> "2008-03-08 19:43:39 +0900" - - class Foo - end - Foo.new.inspect #=> "#" - - class Bar - def initialize - @bar = 1 - end - end - Bar.new.inspect #=> "#" - -**@overload** [] - -## instance_of?(c) [](#method-i-instance_of?) -Returns `true` if *obj* is an instance of the given class. See also -Object#kind_of?. - - class A; end - class B < A; end - class C < B; end - - b = B.new - b.instance_of? A #=> false - b.instance_of? B #=> true - b.instance_of? C #=> false - -**@overload** [] - -## instance_variable_defined?(iv) [](#method-i-instance_variable_defined?) -Returns `true` if the given instance variable is defined in *obj*. String -arguments are converted to symbols. - - class Fred - def initialize(p1, p2) - @a, @b = p1, p2 - end - end - fred = Fred.new('cat', 99) - fred.instance_variable_defined?(:@a) #=> true - fred.instance_variable_defined?("@b") #=> true - fred.instance_variable_defined?("@c") #=> false - -**@overload** [] - -**@overload** [] - -## instance_variable_get(iv) [](#method-i-instance_variable_get) -Returns the value of the given instance variable, or nil if the instance -variable is not set. The `@` part of the variable name should be included for -regular instance variables. Throws a NameError exception if the supplied -symbol is not valid as an instance variable name. String arguments are -converted to symbols. - - class Fred - def initialize(p1, p2) - @a, @b = p1, p2 - end - end - fred = Fred.new('cat', 99) - fred.instance_variable_get(:@a) #=> "cat" - fred.instance_variable_get("@b") #=> 99 - -**@overload** [] - -**@overload** [] - -## instance_variable_set(iv, val) [](#method-i-instance_variable_set) -Sets the instance variable named by *symbol* to the given object. This may -circumvent the encapsulation intended by the author of the class, so it should -be used with care. The variable does not have to exist prior to this call. If -the instance variable name is passed as a string, that string is converted to -a symbol. - - class Fred - def initialize(p1, p2) - @a, @b = p1, p2 - end - end - fred = Fred.new('cat', 99) - fred.instance_variable_set(:@a, 'dog') #=> "dog" - fred.instance_variable_set(:@c, 'cat') #=> "cat" - fred.inspect #=> "#" - -**@overload** [] - -**@overload** [] - -## instance_variables() [](#method-i-instance_variables) - -## is_a?(c) [](#method-i-is_a?) -Returns `true` if *class* is the class of *obj*, or if *class* is one of the -superclasses of *obj* or modules included in *obj*. - - module M; end - class A - include M - end - class B < A; end - class C < B; end - - b = B.new - b.is_a? A #=> true - b.is_a? B #=> true - b.is_a? C #=> false - b.is_a? M #=> true - - b.kind_of? A #=> true - b.kind_of? B #=> true - b.kind_of? C #=> false - b.kind_of? M #=> true - -**@overload** [] - -**@overload** [] - -## iterator?() [](#method-i-iterator?) -Deprecated. Use block_given? instead. - -**@overload** [] - -## itself() [](#method-i-itself) -Returns the receiver. - - string = "my string" - string.itself.object_id == string.object_id #=> true - -**@overload** [] - -## kind_of?(c) [](#method-i-kind_of?) -Returns `true` if *class* is the class of *obj*, or if *class* is one of the -superclasses of *obj* or modules included in *obj*. - - module M; end - class A - include M - end - class B < A; end - class C < B; end - - b = B.new - b.is_a? A #=> true - b.is_a? B #=> true - b.is_a? C #=> false - b.is_a? M #=> true - - b.kind_of? A #=> true - b.kind_of? B #=> true - b.kind_of? C #=> false - b.kind_of? M #=> true - -**@overload** [] - -**@overload** [] - -## lambda() [](#method-i-lambda) -Equivalent to Proc.new, except the resulting Proc objects check the number of -parameters passed when called. - -**@overload** [] - -## local_variables() [](#method-i-local_variables) -Returns the names of the current local variables. - - fred = 1 - for i in 1..10 - # ... - end - local_variables #=> [:fred, :i] - -**@overload** [] - -## matching_methods(s'', mcallable_methods) [](#method-i-matching_methods) - -## method(vid) [](#method-i-method) -Looks up the named method as a receiver in *obj*, returning a Method object -(or raising NameError). The Method object acts as a closure in *obj*'s object -instance, so instance variables and the value of `self` remain available. - - class Demo - def initialize(n) - @iv = n - end - def hello() - "Hello, @iv = #{@iv}" - end - end - - k = Demo.new(99) - m = k.method(:hello) - m.call #=> "Hello, @iv = 99" - - l = Demo.new('Fred') - m = l.method("hello") - m.call #=> "Hello, @iv = Fred" - -Note that Method implements `to_proc` method, which means it can be used with -iterators. - - [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout - - out = File.open('test.txt', 'w') - [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file - - require 'date' - %w[2017-03-01 2017-03-02].collect(&Date.method(:parse)) - #=> [#, #] - -**@overload** [] - -## method_missing(m, *a, &b) [](#method-i-method_missing) - -## methods(*args) [](#method-i-methods) -Returns a list of the names of public and protected methods of *obj*. This -will include all the methods accessible in *obj*'s ancestors. If the optional -parameter is `false`, it returns an array of *obj*'s public and protected -singleton methods, the array will not include methods in modules included in -*obj*. - - class Klass - def klass_method() - end - end - k = Klass.new - k.methods[0..9] #=> [:klass_method, :nil?, :===, - # :==~, :!, :eql? - # :hash, :<=>, :class, :singleton_class] - k.methods.length #=> 56 - - k.methods(false) #=> [] - def k.singleton_method; end - k.methods(false) #=> [:singleton_method] - - module M123; def m123; end end - k.extend M123 - k.methods(false) #=> [:singleton_method] - -**@overload** [] - -## module_specs_protected_method_on_object() [](#method-i-module_specs_protected_method_on_object) - -## module_specs_public_method_on_kernel() [](#method-i-module_specs_public_method_on_kernel) - -## module_specs_public_method_on_object() [](#method-i-module_specs_public_method_on_object) - -## module_specs_public_method_on_object_for_kernel_private() [](#method-i-module_specs_public_method_on_object_for_kernel_private) - -## module_specs_public_method_on_object_for_kernel_protected() [](#method-i-module_specs_public_method_on_object_for_kernel_protected) - -## nil?() [](#method-i-nil?) -Only the object *nil* responds `true` to `nil?`. - - Object.new.nil? #=> false - nil.nil? #=> true - -**@overload** [] - -## object_id() [](#method-i-object_id) -call-seq: - obj.__id__ -> integer - obj.object_id -> integer - -Returns an integer identifier for `obj`. - -The same number will be returned on all calls to `object_id` for a given -object, and no two active objects will share an id. - -Note: that some objects of builtin classes are reused for optimization. This -is the case for immediate values and frozen string literals. - -BasicObject implements `__id__`, Kernel implements `object_id`. - -Immediate values are not passed by reference but are passed by value: `nil`, -`true`, `false`, Fixnums, Symbols, and some Floats. - - Object.new.object_id == Object.new.object_id # => false - (21 * 2).object_id == (21 * 2).object_id # => true - "hello".object_id == "hello".object_id # => false - "hi".freeze.object_id == "hi".freeze.object_id # => true - -## open(*args) [](#method-i-open) -Creates an IO object connected to the given file. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -With no block given, file stream is returned: - - open('t.txt') # => # - -With a block given, calls the block with the open file stream, then closes the -stream: - - open('t.txt') {|f| p f } # => # - -Output: - - # - -See File.open for details. - -**@overload** [] - -**@overload** [] - -## p(*args) [](#method-i-p) -For each object `obj`, executes: - - $stdout.write(obj.inspect, "\n") - -With one object given, returns the object; with multiple objects given, -returns an array containing the objects; with no object given, returns `nil`. - -Examples: - - r = Range.new(0, 4) - p r # => 0..4 - p [r, r, r] # => [0..4, 0..4, 0..4] - p # => nil - -Output: - - 0..4 - [0..4, 0..4, 0..4] - -Kernel#p is designed for debugging purposes. Ruby implementations may define -Kernel#p to be uninterruptible in whole or in part. On CRuby, Kernel#p's -writing of data is uninterruptible. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## pack_format(countnil, repeatnil) [](#method-i-pack_format) -This helper is defined here rather than in MSpec because it is only used in -#pack specs. - -## pretty_inspect() [](#method-i-pretty_inspect) -Returns a pretty printed object as a string. - -See the PP module for more information. - -## pretty_print(q) [](#method-i-pretty_print) -A default pretty printing method for general objects. It calls -#pretty_print_instance_variables to list instance variables. - -If `self` has a customized (redefined) #inspect method, the result of -self.inspect is used but it obviously has no line break hints. - -This module provides predefined #pretty_print methods for some of the most -commonly used built-in classes for convenience. - -## pretty_print_cycle(q) [](#method-i-pretty_print_cycle) -A default pretty printing method for general objects that are detected as part -of a cycle. - -## pretty_print_inspect() [](#method-i-pretty_print_inspect) -Is #inspect implementation using #pretty_print. If you implement -#pretty_print, it can be used as follows. - - alias inspect pretty_print_inspect - -However, doing this requires that every class that #inspect is called on -implement #pretty_print, or a RuntimeError will be raised. - -## pretty_print_instance_variables() [](#method-i-pretty_print_instance_variables) -Returns a sorted array of instance variable names. - -This method should return an array of names of instance variables as symbols -or strings as: +[:@a, :@b]+. - -## print(*args) [](#method-i-print) -Equivalent to `$stdout.print(*objects)`, this method is the straightforward -way to write to `$stdout`. - -Writes the given objects to `$stdout`; returns `nil`. Appends the output -record separator `$OUTPUT_RECORD_SEPARATOR` `$\`), if it is not `nil`. - -With argument `objects` given, for each object: - -* Converts via its method `to_s` if not a string. -* Writes to `stdout`. -* If not the last object, writes the output field separator - `$OUTPUT_FIELD_SEPARATOR` (`$,` if it is not `nil`. - -With default separators: - - objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero'] - $OUTPUT_RECORD_SEPARATOR - $OUTPUT_FIELD_SEPARATOR - print(*objects) - -Output: - - nil - nil - 00.00/10+0izerozero - -With specified separators: - - $OUTPUT_RECORD_SEPARATOR = "\n" - $OUTPUT_FIELD_SEPARATOR = ',' - print(*objects) - -Output: - - 0,0.0,0/1,0+0i,zero,zero - -With no argument given, writes the content of `$_` (which is usually the most -recent user input): - - gets # Sets $_ to the most recent user input. - print # Prints $_. - -**@overload** [] - -## printf(*args) [](#method-i-printf) -Equivalent to: - - io.write(sprintf(format_string, *objects)) - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -With the single argument `format_string`, formats `objects` into the string, -then writes the formatted string to $stdout: - - printf('%4.4d %10s %2.2f', 24, 24, 24.0) - -Output (on $stdout): - - 0024 24 24.00# - -With arguments `io` and `format_string`, formats `objects` into the string, -then writes the formatted string to `io`: - - printf($stderr, '%4.4d %10s %2.2f', 24, 24, 24.0) - -Output (on $stderr): - - 0024 24 24.00# => nil - -With no arguments, does nothing. - -**@overload** [] - -**@overload** [] - -## private_methods(*args) [](#method-i-private_methods) -Returns the list of private methods accessible to *obj*. If the *all* -parameter is set to `false`, only those methods in the receiver will be -listed. - -**@overload** [] - -## proc() [](#method-i-proc) -Equivalent to Proc.new. - -**@overload** [] - -## protected_methods(*args) [](#method-i-protected_methods) -Returns the list of protected methods accessible to *obj*. If the *all* -parameter is set to `false`, only those methods in the receiver will be -listed. - -**@overload** [] - -## public_method(vid) [](#method-i-public_method) -Similar to *method*, searches public method only. - -**@overload** [] - -## public_methods(*args) [](#method-i-public_methods) -Returns the list of public methods accessible to *obj*. If the *all* parameter -is set to `false`, only those methods in the receiver will be listed. - -**@overload** [] - -## public_send(*args) [](#method-i-public_send) -Invokes the method identified by *symbol*, passing it any arguments specified. -Unlike send, public_send calls public methods only. When the method is -identified by a string, the string is converted to a symbol. - - 1.public_send(:puts, "hello") # causes NoMethodError - -**@overload** [] - -**@overload** [] - -## putc(ch) [](#method-i-putc) -Equivalent to: - - $stdout.putc(int) - -See IO#putc for important information regarding multi-byte characters. - -**@overload** [] - -## puts(*args) [](#method-i-puts) -Equivalent to - - $stdout.puts(objects) - -**@overload** [] - -## raise(*v, _) [](#method-i-raise) -Raises an exception; see [Exceptions](rdoc-ref:exceptions.md). - -Argument `exception` sets the class of the new exception; it should be class -Exception or one of its subclasses (most commonly, RuntimeError or -StandardError), or an instance of one of those classes: - - begin - raise(StandardError) - rescue => x - p x.class - end - # => StandardError - -Argument `message` sets the stored message in the new exception, which may be -retrieved by method Exception#message; the message must be a -[string-convertible -object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or -`nil`: - - begin - raise(StandardError, 'Boom') - rescue => x - p x.message - end - # => "Boom" - -If argument `message` is not given, the message is the exception class name. - -See [Messages](rdoc-ref:exceptions.md@Messages). - -Argument `backtrace` might be used to modify the backtrace of the new -exception, as reported by Exception#backtrace and -Exception#backtrace_locations; the backtrace must be an array of -Thread::Backtrace::Location, an array of strings, a single string, or `nil`. - -Using the array of Thread::Backtrace::Location instances is the most -consistent option and should be preferred when possible. The necessary value -might be obtained from #caller_locations, or copied from -Exception#backtrace_locations of another error: - - begin - do_some_work() - rescue ZeroDivisionError => ex - raise(LogicalError, "You have an error in your math", ex.backtrace_locations) - end - -The ways, both Exception#backtrace and Exception#backtrace_locations of the -raised error are set to the same backtrace. - -When the desired stack of locations is not available and should be constructed -from scratch, an array of strings or a singular string can be used. In this -case, only Exception#backtrace is set: - - begin - raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1]) - rescue => ex - p ex.backtrace - # => ["dsl.rb:3", "framework.rb:1"] - p ex.backtrace_locations - # => nil - end - -If argument `backtrace` is not given, the backtrace is set according to an -array of Thread::Backtrace::Location objects, as derived from the call stack. - -See [Backtraces](rdoc-ref:exceptions.md@Backtraces). - -Keyword argument `cause` sets the stored cause in the new exception, which may -be retrieved by method Exception#cause; the cause must be an exception object -(Exception or one of its subclasses), or `nil`: - - begin - raise(StandardError, cause: RuntimeError.new) - rescue => x - p x.cause - end - # => # - -If keyword argument `cause` is not given, the cause is the value of `$!`. - -See [Cause](rdoc-ref:exceptions.md@Cause). - -In the alternate calling sequence, where argument `exception` *not* given, -raises a new exception of the class given by `$!`, or of class RuntimeError if -`$!` is `nil`: - - begin - raise - rescue => x - p x - end - # => RuntimeError - -With argument `exception` not given, argument `message` and keyword argument -`cause` may be given, but argument `backtrace` may not be given. - -**@overload** [] - -**@overload** [] - -## rand(*args) [](#method-i-rand) -If called without an argument, or if `max.to_i.abs == 0`, rand returns a -pseudo-random floating point number between 0.0 and 1.0, including 0.0 and -excluding 1.0. - - rand #=> 0.2725926052826416 - -When `max.abs` is greater than or equal to 1, `rand` returns a pseudo-random -integer greater than or equal to 0 and less than `max.to_i.abs`. - - rand(100) #=> 12 - -When `max` is a Range, `rand` returns a random number where -`range.member?(number) == true`. - -Negative or floating point values for `max` are allowed, but may give -surprising results. - - rand(-100) # => 87 - rand(-0.5) # => 0.8130921818028143 - rand(1.9) # equivalent to rand(1), which is always 0 - -Kernel.srand may be used to ensure that sequences of random numbers are -reproducible between different runs of a program. - -See also Random.rand. - -**@overload** [] - -## rb_eval_string(str) [](#method-i-rb_eval_string) - -## readline(*args) [](#method-i-readline) -Equivalent to method Kernel#gets, except that it raises an exception if called -at end-of-stream: - - $ cat t.txt | ruby -e "p readlines; readline" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - in `readline': end of file reached (EOFError) - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## readlines(*args) [](#method-i-readlines) -Returns an array containing the lines returned by calling Kernel#gets until -the end-of-stream is reached; (see [Line IO](rdoc-ref:IO@Line+IO)). - -With only string argument `sep` given, returns the remaining lines as -determined by line separator `sep`, or `nil` if none; see [Line -Separator](rdoc-ref:IO@Line+Separator): - - # Default separator. - $ cat t.txt | ruby -e "p readlines" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - - # Specified separator. - $ cat t.txt | ruby -e "p readlines 'li'" - ["First li", "ne\nSecond li", "ne\n\nFourth li", "ne\nFifth li", "ne\n"] - - # Get-all separator. - $ cat t.txt | ruby -e "p readlines nil" - ["First line\nSecond line\n\nFourth line\nFifth line\n"] - - # Get-paragraph separator. - $ cat t.txt | ruby -e "p readlines ''" - ["First line\nSecond line\n\n", "Fourth line\nFifth line\n"] - -With only integer argument `limit` given, limits the number of bytes in the -line; see [Line Limit](rdoc-ref:IO@Line+Limit): - - $cat t.txt | ruby -e "p readlines 10" - ["First line", "\n", "Second lin", "e\n", "\n", "Fourth lin", "e\n", "Fifth line", "\n"] - - $cat t.txt | ruby -e "p readlines 11" - ["First line\n", "Second line", "\n", "\n", "Fourth line", "\n", "Fifth line\n"] - - $cat t.txt | ruby -e "p readlines 12" - ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] - -With arguments `sep` and `limit` given, combines the two behaviors (see [Line -Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)). - -Optional keyword argument `chomp` specifies whether line separators are to be -omitted: - - $ cat t.txt | ruby -e "p readlines(chomp: true)" - ["First line", "Second line", "", "Fourth line", "Fifth line"] - -Optional keyword arguments `enc_opts` specify encoding options; see [Encoding -options](rdoc-ref:encodings.rdoc@Encoding+Options). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## register_sample_bug_reporter(obj) [](#method-i-register_sample_bug_reporter) - -## remove_instance_variable() [](#method-i-remove_instance_variable) - -## respond_to?(*args) [](#method-i-respond_to?) -Returns `true` if *obj* responds to the given method. Private and protected -methods are included in the search only if the optional second parameter -evaluates to `true`. - -If the method is not implemented, as Process.fork on Windows, File.lchmod on -GNU/Linux, etc., false is returned. - -If the method is not defined, `respond_to_missing?` method is called and the -result is returned. - -When the method name parameter is given as a string, the string is converted -to a symbol. - -**@overload** [] - -**@overload** [] - -## respond_to_missing?(mid, priv) [](#method-i-respond_to_missing?) -DO NOT USE THIS DIRECTLY. - -Hook method to return whether the *obj* can respond to *id* method or not. - -When the method name parameter is given as a string, the string is converted -to a symbol. - -See #respond_to?, and the example of BasicObject. - -**@overload** [] - -**@overload** [] - -## select(*args) [](#method-i-select) -Invokes system call [select(2)](https://linux.die.net/man/2/select), which -monitors multiple file descriptors, waiting until one or more of the file -descriptors becomes ready for some class of I/O operation. - -Not implemented on all platforms. - -Each of the arguments `read_ios`, `write_ios`, and `error_ios` is an array of -IO objects. - -Argument `timeout` is a numeric value (such as integer or float) timeout -interval in seconds. - -The method monitors the IO objects given in all three arrays, waiting for some -to be ready; returns a 3-element array whose elements are: - -* An array of the objects in `read_ios` that are ready for reading. -* An array of the objects in `write_ios` that are ready for writing. -* An array of the objects in `error_ios` have pending exceptions. - -If no object becomes ready within the given `timeout`, `nil` is returned. - -IO.select peeks the buffer of IO objects for testing readability. If the IO -buffer is not empty, IO.select immediately notifies readability. This "peek" -only happens for IO objects. It does not happen for IO-like objects such as -OpenSSL::SSL::SSLSocket. - -The best way to use IO.select is invoking it after non-blocking methods such -as #read_nonblock, #write_nonblock, etc. The methods raise an exception which -is extended by IO::WaitReadable or IO::WaitWritable. The modules notify how -the caller should wait with IO.select. If IO::WaitReadable is raised, the -caller should wait for reading. If IO::WaitWritable is raised, the caller -should wait for writing. - -So, blocking read (#readpartial) can be emulated using #read_nonblock and -IO.select as follows: - - begin - result = io_like.read_nonblock(maxlen) - rescue IO::WaitReadable - IO.select([io_like]) - retry - rescue IO::WaitWritable - IO.select(nil, [io_like]) - retry - end - -Especially, the combination of non-blocking methods and IO.select is preferred -for IO like objects such as OpenSSL::SSL::SSLSocket. It has #to_io method to -return underlying IO object. IO.select calls #to_io to obtain the file -descriptor to wait. - -This means that readability notified by IO.select doesn't mean readability -from OpenSSL::SSL::SSLSocket object. - -The most likely situation is that OpenSSL::SSL::SSLSocket buffers some data. -IO.select doesn't see the buffer. So IO.select can block when -OpenSSL::SSL::SSLSocket#readpartial doesn't block. - -However, several more complicated situations exist. - -SSL is a protocol which is sequence of records. The record consists of -multiple bytes. So, the remote side of SSL sends a partial record, IO.select -notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a byte and -OpenSSL::SSL::SSLSocket#readpartial will block. - -Also, the remote side can request SSL renegotiation which forces the local SSL -engine to write some data. This means OpenSSL::SSL::SSLSocket#readpartial may -invoke #write system call and it can block. In such a situation, -OpenSSL::SSL::SSLSocket#read_nonblock raises IO::WaitWritable instead of -blocking. So, the caller should wait for ready for writability as above -example. - -The combination of non-blocking methods and IO.select is also useful for -streams such as tty, pipe socket socket when multiple processes read from a -stream. - -Finally, Linux kernel developers don't guarantee that readability of select(2) -means readability of following read(2) even for a single process; see -[select(2)](https://linux.die.net/man/2/select) - -Invoking IO.select before IO#readpartial works well as usual. However it is -not the best way to use IO.select. - -The writability notified by select(2) doesn't show how many bytes are -writable. IO#write method blocks until given whole string is written. So, -`IO#write(two or more bytes)` can block after writability is notified by -IO.select. IO#write_nonblock is required to avoid the blocking. - -Blocking write (#write) can be emulated using #write_nonblock and IO.select as -follows: IO::WaitReadable should also be rescued for SSL renegotiation in -OpenSSL::SSL::SSLSocket. - - while 0 < string.bytesize - begin - written = io_like.write_nonblock(string) - rescue IO::WaitReadable - IO.select([io_like]) - retry - rescue IO::WaitWritable - IO.select(nil, [io_like]) - retry - end - string = string.byteslice(written..-1) - end - -Example: - - rp, wp = IO.pipe - mesg = "ping " - 100.times { - # IO.select follows IO#read. Not the best way to use IO.select. - rs, ws, = IO.select([rp], [wp]) - if r = rs[0] - ret = r.read(5) - print ret - case ret - when /ping/ - mesg = "pong\n" - when /pong/ - mesg = "ping " - end - end - if w = ws[0] - w.write(mesg) - end - } - -Output: - - ping pong - ping pong - ping pong - (snipped) - ping - -**@overload** [] - -## send(*args) [](#method-i-send) -Invokes the method identified by *symbol*, passing it any - arguments specified. - When the method is identified by a string, the string is converted - to a symbol. - - BasicObject implements +__send__+, Kernel implements +send+. - __send__ is safer than +send+ - when _obj_ has the same method name like Socket. - See also public_send. - - class Klass - def hello(*args) - "Hello " + args.join(' ') - end - end - k = Klass.new - k.send :hello, "gentle", "readers" #=> "Hello gentle readers" - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## set_trace_func(trace) [](#method-i-set_trace_func) -Establishes *proc* as the handler for tracing, or disables tracing if the -parameter is `nil`. - -**Note:** this method is obsolete, please use TracePoint instead. - -*proc* takes up to six parameters: - -* an event name string -* a filename string -* a line number -* a method name symbol, or nil -* a binding, or nil -* the class, module, or nil - -*proc* is invoked whenever an event occurs. - -Events are: - -`"c-call"` -: call a C-language routine - -`"c-return"` -: return from a C-language routine - -`"call"` -: call a Ruby method - -`"class"` -: start a class or module definition - -`"end"` -: finish a class or module definition - -`"line"` -: execute code on a new line - -`"raise"` -: raise an exception - -`"return"` -: return from a Ruby method - - -Tracing is disabled within the context of *proc*. - - class Test - def test - a = 1 - b = 2 - end - end - - set_trace_func proc { |event, file, line, id, binding, class_or_module| - printf "%8s %s:%-2d %16p %14p\n", event, file, line, id, class_or_module - } - t = Test.new - t.test - -Produces: - - c-return prog.rb:8 :set_trace_func Kernel - line prog.rb:11 nil nil - c-call prog.rb:11 :new Class - c-call prog.rb:11 :initialize BasicObject - c-return prog.rb:11 :initialize BasicObject - c-return prog.rb:11 :new Class - line prog.rb:12 nil nil - call prog.rb:2 :test Test - line prog.rb:3 :test Test - line prog.rb:4 :test Test - return prog.rb:5 :test Test - -**@overload** [] - -**@overload** [] - -## shortest_abbreviation(s'', mcallable_methods) [](#method-i-shortest_abbreviation) - -## should(matcherNO_MATCHER_GIVEN, &block) [](#method-i-should) - -## should_not(matcherNO_MATCHER_GIVEN, &block) [](#method-i-should_not) - -## should_not_receive(sym) [](#method-i-should_not_receive) - -## should_receive(sym) [](#method-i-should_receive) - -## singleton_class() [](#method-i-singleton_class) -Returns the singleton class of *obj*. This method creates a new singleton -class if *obj* does not have one. - -If *obj* is `nil`, `true`, or `false`, it returns NilClass, TrueClass, or -FalseClass, respectively. If *obj* is an Integer, a Float or a Symbol, it -raises a TypeError. - - Object.new.singleton_class #=> #> - String.singleton_class #=> # - nil.singleton_class #=> NilClass - -**@overload** [] - -## singleton_method(vid) [](#method-i-singleton_method) -Similar to *method*, searches singleton method only. - - class Demo - def initialize(n) - @iv = n - end - def hello() - "Hello, @iv = #{@iv}" - end - end - - k = Demo.new(99) - def k.hi - "Hi, @iv = #{@iv}" - end - m = k.singleton_method(:hi) - m.call #=> "Hi, @iv = 99" - m = k.singleton_method(:hello) #=> NameError - -**@overload** [] - -## singleton_methods(*args) [](#method-i-singleton_methods) -Returns an array of the names of singleton methods for *obj*. If the optional -*all* parameter is true, the list will include methods in modules included in -*obj*. Only public and protected singleton methods are returned. - - module Other - def three() end - end - - class Single - def Single.four() end - end - - a = Single.new - - def a.one() - end - - class << a - include Other - def two() - end - end - - Single.singleton_methods #=> [:four] - a.singleton_methods(false) #=> [:two, :one] - a.singleton_methods #=> [:two, :one, :three] - -**@overload** [] - -## sleep(*args) [](#method-i-sleep) -Suspends execution of the current thread for the number of seconds specified -by numeric argument `secs`, or forever if `secs` is `nil`; returns the integer -number of seconds suspended (rounded). - - Time.new # => 2008-03-08 19:56:19 +0900 - sleep 1.2 # => 1 - Time.new # => 2008-03-08 19:56:20 +0900 - sleep 1.9 # => 2 - Time.new # => 2008-03-08 19:56:22 +0900 - -**@overload** [] - -## spawn(*args) [](#method-i-spawn) -Creates a new child process by doing one of the following in that process: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Returns the process ID (pid) of the new process, without waiting for it to -complete. - -To avoid zombie processes, the parent process should call either: - -* Process.wait, to collect the termination statuses of its children. -* Process.detach, to register disinterest in their status. - -The new process is created using the [exec system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e -xecve.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word. - Process.wait # => 798847 - spawn('exit') # => 798848 # Built-in. - Process.wait # => 798848 - spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character. - Process.wait # => 798849 - spawn('date > /nop/date.tmp') # => 798882 # Issues error message. - Process.wait # => 798882 - -The command line may also contain arguments and options for the command: - - spawn('echo "Foo"') # => 799031 - Process.wait # => 799031 - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable to be called, and - the string to be used as the name of the executing process. - - spawn('/usr/bin/date') # Path to date on Unix-style system. - Process.wait - - Output: - - Mon Aug 28 11:43:10 AM CDT 2023 - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - spawn('echo', 'C*') # => 799392 - Process.wait # => 799392 - spawn('echo', 'hello', 'world') # => 799393 - Process.wait # => 799393 - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## sprintf(*v, _) [](#method-i-sprintf) -Returns the string resulting from formatting `objects` into `format_string`. - -For details on `format_string`, see [Format -Specifications](rdoc-ref:format_specifications.rdoc). - -**@overload** [] - -## srand(*args) [](#method-i-srand) -Seeds the system pseudo-random number generator, with `number`. The previous -seed value is returned. - -If `number` is omitted, seeds the generator using a source of entropy provided -by the operating system, if available (/dev/urandom on Unix systems or the RSA -cryptographic provider on Windows), which is then combined with the time, the -process id, and a sequence number. - -srand may be used to ensure repeatable sequences of pseudo-random numbers -between different runs of the program. By setting the seed to a known value, -programs can be made deterministic during testing. - - srand 1234 # => 268519324636777531569100071560086917274 - [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] - [ rand(10), rand(1000) ] # => [4, 664] - srand 1234 # => 1234 - [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] - -**@overload** [] - -## stub(name, val_or_callable, *block_args) [](#method-i-stub) - -## stub!(sym) [](#method-i-stub!) - -## sub(*args) [](#method-i-sub) -Equivalent to `$_.sub(*args*)`, except that `$_` will be updated if -substitution occurs. Available only when -p/-n command line option specified. - -**@overload** [] - -**@overload** [] - -## syscall(*args) [](#method-i-syscall) -Invokes Posix system call [syscall(2)](https://linux.die.net/man/2/syscall), -which calls a specified function. - -Calls the operating system function identified by `integer_callno`; returns -the result of the function or raises SystemCallError if it failed. The effect -of the call is platform-dependent. The arguments and returned value are -platform-dependent. - -For each of `arguments`: if it is an integer, it is passed directly; if it is -a string, it is interpreted as a binary sequence of bytes. There may be as -many as nine such arguments. - -Arguments `integer_callno` and `argument`, as well as the returned value, are -platform-dependent. - -Note: Method `syscall` is essentially unsafe and unportable. The DL (Fiddle) -library is preferred for safer and a bit more portable programming. - -Not implemented on all platforms. - -**@overload** [] - -## system(*args) [](#method-i-system) -Creates a new child process by doing one of the following in that process: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Returns: - -* `true` if the command exits with status zero. -* `false` if the exit status is a non-zero integer. -* `nil` if the command could not execute. - -Raises an exception (instead of returning `false` or `nil`) if keyword -argument `exception` is set to `true`. - -Assigns the command's error status to `$?`. - -The new process is created using the [system system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/s -ystem.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - system('if true; then echo "Foo"; fi') # => true # Shell reserved word. - system('exit') # => true # Built-in. - system('date > /tmp/date.tmp') # => true # Contains meta character. - system('date > /nop/date.tmp') # => false - system('date > /nop/date.tmp', exception: true) # Raises RuntimeError. - -Assigns the command's error status to `$?`: - - system('exit') # => true # Built-in. - $? # => # - system('date > /nop/date.tmp') # => false - $? # => # - -The command line may also contain arguments and options for the command: - - system('echo "Foo"') # => true - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - system('/usr/bin/date') # => true # Path to date on Unix-style system. - system('foo') # => nil # Command failed. - -Output: - - Mon Aug 28 11:43:10 AM CDT 2023 - -Assigns the command's error status to `$?`: - - system('/usr/bin/date') # => true - $? # => # - system('foo') # => nil - $? # => # - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - - system('doesnt_exist') # => nil - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - system('echo', 'C*') # => true - system('echo', 'hello', 'world') # => true - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. - -**@overload** [] - -**@overload** [] - -## tap() [](#method-i-tap) -call-seq: - obj.tap {|x| block } -> obj - - Yields self to the block and then returns self. - The primary purpose of this method is to "tap into" a method chain, - in order to perform operations on intermediate results within the chain. - - (1..10) .tap {|x| puts "original: #{x}" } - .to_a .tap {|x| puts "array: #{x}" } - .select {|x| x.even? } .tap {|x| puts "evens: #{x}" } - .map {|x| x*x } .tap {|x| puts "squares: #{x}" } - --- private ++ - -**@yield** [_self] - -**@yieldparam** [Kernel] the object that the method was called on - -## test(*args) [](#method-i-test) -:markup: markdown - -call-seq: - test(char, path0, path1 = nil) -> object - -Performs a test on one or both of the *filesystem entities* at the given paths -`path0` and `path1`: - -* Each path `path0` or `path1` points to a file, directory, device, pipe, - etc. -* Character `char` selects a specific test. - -The tests: - -* Each of these tests operates only on the entity at `path0`, and returns - `true` or `false`; for a non-existent entity, returns `false` (does not - raise exception): - - | Character | Test | - |:------------:|:--------------------------------------------------------------------------| - | 'b' | Whether the entity is a block device. | - | 'c' | Whether the entity is a character device. | - | 'd' | Whether the entity is a directory. | - | 'e' | Whether the entity is an existing entity. | - | 'f' | Whether the entity is an existing regular file. | - | 'g' | Whether the entity's setgid bit is set. | - | 'G' | Whether the entity's group ownership is equal to the caller's. | - | 'k' | Whether the entity's sticky bit is set. | - | 'l' | Whether the entity is a symbolic link. | - | 'o' | Whether the entity is owned by the caller's effective uid. | - | 'O' | Like 'o', but uses the real uid (not the effective uid). | - | 'p' | Whether the entity is a FIFO device (named pipe). | - | 'r' | Whether the entity is readable by the caller's effective uid/gid. | - | 'R' | Like 'r', but uses the real uid/gid (not the effective uid/gid). | - | 'S' | Whether the entity is a socket. | - | 'u' | Whether the entity's setuid bit is set. | - | 'w' | Whether the entity is writable by the caller's effective uid/gid. | - | 'W' | Like 'w', but uses the real uid/gid (not the effective uid/gid). | - | 'x' | Whether the entity is executable by the caller's effective uid/gid. | - | 'X' | Like 'x', but uses the real uid/gid (not the effective uid/git). | - | 'z' | Whether the entity exists and is of length zero. | - -* This test operates only on the entity at `path0`, and returns an integer - size or `nil`: - - | Character | Test | - |:------------:|:---------------------------------------------------------------------------------------------| - | 's' | Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise. | - -* Each of these tests operates only on the entity at `path0`, and returns a - Time object; raises an exception if the entity does not exist: - - | Character | Test | - |:------------:|:---------------------------------------| - | 'A' | Last access time for the entity. | - | 'C' | Last change time for the entity. | - | 'M' | Last modification time for the entity. | - -* Each of these tests operates on the modification time (`mtime`) of each of - the entities at `path0` and `path1`, and returns a `true` or `false`; - returns `false` if either entity does not exist: - - | Character | Test | - |:------------:|:----------------------------------------------------------------| - | '<' | Whether the `mtime` at `path0` is less than that at `path1`. | - | '=' | Whether the `mtime` at `path0` is equal to that at `path1`. | - | '>' | Whether the `mtime` at `path0` is greater than that at `path1`. | - -* This test operates on the content of each of the entities at `path0` and - `path1`, and returns a `true` or `false`; returns `false` if either entity - does not exist: - - | Character | Test | - |:------------:|:----------------------------------------------| - | '-' | Whether the entities exist and are identical. | - -## then() [](#method-i-then) -call-seq: - obj.then {|x| block } -> an_object - - Yields self to the block and returns the result of the block. - - 3.next.then {|x| x**x }.to_s #=> "256" - - A good use of +then+ is value piping in method chains: - - require 'open-uri' - require 'json' - - construct_url(arguments) - .then {|url| URI(url).read } - .then {|response| JSON.parse(response) } - - When called without a block, the method returns an +Enumerator+, - which can be used, for example, for conditional - circuit-breaking: - - # Meets condition, no-op - 1.then.detect(&:odd?) # => 1 - # Does not meet condition, drop value - 2.then.detect(&:odd?) # => nil - -**@yield** [_self] - -**@yieldparam** [Kernel] the object that the method was called on - -## throw(*args) [](#method-i-throw) -Transfers control to the end of the active `catch` block waiting for *tag*. -Raises `UncaughtThrowError` if there is no `catch` block for the *tag*. The -optional second parameter supplies a return value for the `catch` block, which -otherwise defaults to `nil`. For examples, see Kernel::catch. - -**@overload** [] - -## to_enum(*args) [](#method-i-to_enum) -Creates a new Enumerator which will enumerate by calling `method` on `obj`, -passing `args` if any. What was *yielded* by method becomes values of -enumerator. - -If a block is given, it will be used to calculate the size of the enumerator -without the need to iterate it (see Enumerator#size). - -### Examples - - str = "xyz" - - enum = str.enum_for(:each_byte) - enum.each { |b| puts b } - # => 120 - # => 121 - # => 122 - - # protect an array from being modified by some_method - a = [1, 2, 3] - some_method(a.to_enum) - - # String#split in block form is more memory-effective: - very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') } - # This could be rewritten more idiomatically with to_enum: - very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first - -It is typical to call to_enum when defining methods for a generic Enumerable, -in case no block is passed. - -Here is such an example, with parameter passing and a sizing block: - - module Enumerable - # a generic method to repeat the values of any enumerable - def repeat(n) - raise ArgumentError, "#{n} is negative!" if n < 0 - unless block_given? - return to_enum(__method__, n) do # __method__ is :repeat here - sz = size # Call size and multiply by n... - sz * n if sz # but return nil if size itself is nil - end - end - each do |*val| - n.times { yield *val } - end - end - end - - %i[hello world].repeat(2) { |w| puts w } - # => Prints 'hello', 'hello', 'world', 'world' - enum = (1..14).repeat(3) - # => returns an Enumerator when called without a block - enum.first(4) # => [1, 1, 1, 2] - enum.size # => 42 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns a string representing *obj*. The default #to_s prints the object's -class and an encoding of the object id. As a special case, the top-level -object that is the initial execution context of Ruby programs returns -``main''. - -**@overload** [] - -## to_yaml(options{}) [](#method-i-to_yaml) -call-seq: to_yaml(options = {}) - -Convert an object to YAML. See Psych.dump for more information on the -available `options`. - -## trace_var(*a, _) [](#method-i-trace_var) -Controls tracing of assignments to global variables. The parameter `symbol` -identifies the variable (as either a string name or a symbol identifier). -*cmd* (which may be a string or a `Proc` object) or block is executed whenever -the variable is assigned. The block or `Proc` object receives the variable's -new value as a parameter. Also see #untrace_var. - - trace_var :$_, proc {|v| puts "$_ is now '#{v}'" } - $_ = "hello" - $_ = ' there' - -*produces:* - - $_ is now 'hello' - $_ is now ' there' - -**@overload** [] - -**@overload** [] - -## trap(*args) [](#method-i-trap) -Specifies the handling of signals. The first parameter is a signal name (a -string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The -characters ``SIG'' may be omitted from the signal name. The command or block -specifies code to be run when the signal is raised. If the command is the -string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command -is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If -the command is ``EXIT'', the script will be terminated by the signal. If the -command is ``SYSTEM_DEFAULT'', the operating system's default handler will be -invoked. Otherwise, the given command or block will be run. The special signal -name ``EXIT'' or signal number zero will be invoked just prior to program -termination. trap returns the previous handler for the given signal. - - Signal.trap(0, proc { puts "Terminating: #{$$}" }) - Signal.trap("CLD") { puts "Child died" } - fork && Process.wait - -*produces:* - Terminating: 27461 - Child died - Terminating: 27460 - -**@overload** [] - -**@overload** [] - -## unpack_format(countnil, repeatnil) [](#method-i-unpack_format) -This helper is defined here rather than in MSpec because it is only used in -#unpack specs. - -## untrace_var(*a, _) [](#method-i-untrace_var) -Removes tracing for the specified command on the given global variable and -returns `nil`. If no command is specified, removes all tracing for that -variable and returns an array containing the commands actually removed. - -**@overload** [] - diff --git a/example/ruby/Object/CApiModuleSpecsModuleA.md b/example/ruby/Object/CApiModuleSpecsModuleA.md deleted file mode 100644 index 1dc56f3..0000000 --- a/example/ruby/Object/CApiModuleSpecsModuleA.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Object::CApiModuleSpecsModuleA - - - - - diff --git a/example/ruby/Object/ConstantSpecs.md b/example/ruby/Object/ConstantSpecs.md deleted file mode 100644 index dc21eed..0000000 --- a/example/ruby/Object/ConstantSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Object::ConstantSpecs - - - - - diff --git a/example/ruby/Object/ConstantSpecs/ContainerA.md b/example/ruby/Object/ConstantSpecs/ContainerA.md deleted file mode 100644 index 94895c1..0000000 --- a/example/ruby/Object/ConstantSpecs/ContainerA.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Object::ConstantSpecs::ContainerA -**Inherits:** Object - - - - - diff --git a/example/ruby/Object/ConstantSpecs/ContainerA/ChildA.md b/example/ruby/Object/ConstantSpecs/ContainerA/ChildA.md deleted file mode 100644 index e5695d3..0000000 --- a/example/ruby/Object/ConstantSpecs/ContainerA/ChildA.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Object::ConstantSpecs::ContainerA::ChildA -**Inherits:** Object - - - - -# Class Methods -## const20() [](#method-c-const20) - diff --git a/example/ruby/Object/ConstantSpecs/ContainerB.md b/example/ruby/Object/ConstantSpecs/ContainerB.md deleted file mode 100644 index 0825993..0000000 --- a/example/ruby/Object/ConstantSpecs/ContainerB.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Object::ConstantSpecs::ContainerB -**Inherits:** Object - - - - - diff --git a/example/ruby/Object/ConstantSpecs/ContainerB/ChildB.md b/example/ruby/Object/ConstantSpecs/ContainerB/ChildB.md deleted file mode 100644 index 8f36684..0000000 --- a/example/ruby/Object/ConstantSpecs/ContainerB/ChildB.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Object::ConstantSpecs::ContainerB::ChildB -**Inherits:** Object - - - - -# Class Methods -## const211() [](#method-c-const211) - diff --git a/example/ruby/ObjectSpace.md b/example/ruby/ObjectSpace.md deleted file mode 100644 index 743ad99..0000000 --- a/example/ruby/ObjectSpace.md +++ /dev/null @@ -1,542 +0,0 @@ -# Module: ObjectSpace - - -The objspace library extends the ObjectSpace module and adds several methods -to get internal statistic information about object/memory management. - -You need to `require 'objspace'` to use this extension module. - -Generally, you **SHOULD** **NOT** use this library if you do not know about -the MRI implementation. Mainly, this library is for (memory) profiler -developers and MRI developers who need to know about MRI memory usage. - - -# Class Methods -## _dump(obj , output ) [](#method-c-_dump) -:nodoc: -## _dump_all(output , full , since , shapes ) [](#method-c-_dump_all) -:nodoc: -## _dump_shapes(output , shapes ) [](#method-c-_dump_shapes) -:nodoc: -## _id2ref(objid ) [](#method-c-_id2ref) -:nodoc: -## allocation_class_path(obj ) [](#method-c-allocation_class_path) -Returns the class for the given `object`. - -class A - def foo - ObjectSpace::trace_object_allocations do - obj = Object.new - p "#{ObjectSpace::allocation_class_path(obj)}" - end - end - -end - -A.new.foo #=> "Class" - -See ::trace_object_allocations for more information and examples. -**@overload** [] - -## allocation_generation(obj ) [](#method-c-allocation_generation) -Returns garbage collector generation for the given `object`. - -class B - include ObjectSpace - - def foo - trace_object_allocations do - obj = Object.new - p "Generation is #{allocation_generation(obj)}" - end - end - -end - -B.new.foo #=> "Generation is 3" - -See ::trace_object_allocations for more information and examples. -**@overload** [] - -## allocation_method_id(obj ) [](#method-c-allocation_method_id) -Returns the method identifier for the given `object`. - -class A - include ObjectSpace - - def foo - trace_object_allocations do - obj = Object.new - p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}" - end - end - -end - -A.new.foo #=> "Class#new" - -See ::trace_object_allocations for more information and examples. -**@overload** [] - -## allocation_sourcefile(obj ) [](#method-c-allocation_sourcefile) -Returns the source file origin from the given `object`. - -See ::trace_object_allocations for more information and examples. -**@overload** [] - -## allocation_sourceline(obj ) [](#method-c-allocation_sourceline) -Returns the original line from source for from the given `object`. - -See ::trace_object_allocations for more information and examples. -**@overload** [] - -## class_name_of(klass ) [](#method-c-class_name_of) -## count_imemo_objects(*args ) [](#method-c-count_imemo_objects) -Counts objects for each `T_IMEMO` type. - -This method is only for MRI developers interested in performance and memory -usage of Ruby programs. - -It returns a hash as: - - {:imemo_ifunc=>8, - :imemo_svar=>7, - :imemo_cref=>509, - :imemo_memo=>1, - :imemo_throw_data=>1} - -If the optional argument, result_hash, is given, it is overwritten and -returned. This is intended to avoid probe effect. - -The contents of the returned hash is implementation specific and may change in -the future. - -In this version, keys are symbol objects. - -This method is only expected to work with C Ruby. -**@overload** [] - -## count_nodes(*args ) [](#method-c-count_nodes) -Counts nodes for each node type. - -This method is only for MRI developers interested in performance and memory -usage of Ruby programs. - -It returns a hash as: - -{:NODE_METHOD=>2027, :NODE_FBODY=>1927, :NODE_CFUNC=>1798, ...} - -If the optional argument, result_hash, is given, it is overwritten and -returned. This is intended to avoid probe effect. - -Note: The contents of the returned hash is implementation defined. It may be -changed in future. - -This method is only expected to work with C Ruby. -**@overload** [] - -## count_objects(*args ) [](#method-c-count_objects) -Counts all objects grouped by type. - -It returns a hash, such as: { - :TOTAL=>10000, - :FREE=>3011, - :T_OBJECT=>6, - :T_CLASS=>404, - # ... - -} - -The contents of the returned hash are implementation specific. It may be -changed in future. - -The keys starting with `:T_` means live objects. For example, `:T_ARRAY` is -the number of arrays. `:FREE` means object slots which is not used now. -`:TOTAL` means sum of above. - -If the optional argument `result_hash` is given, it is overwritten and -returned. This is intended to avoid probe effect. - - h = {} - ObjectSpace.count_objects(h) - puts h - # => { :TOTAL=>10000, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249 } - -This method is only expected to work on C Ruby. -**@overload** [] - -## count_objects_size(*args ) [](#method-c-count_objects_size) -Counts objects size (in bytes) for each type. - -Note that this information is incomplete. You need to deal with this -information as only a **HINT**. Especially, total size of T_DATA may be -wrong. - -It returns a hash as: - {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...} - -If the optional argument, result_hash, is given, it is overwritten and -returned. This is intended to avoid probe effect. - -The contents of the returned hash is implementation defined. It may be changed -in future. - -This method is only expected to work with C Ruby. -**@overload** [] - -## count_symbols(*args ) [](#method-c-count_symbols) -Counts symbols for each Symbol type. - -This method is only for MRI developers interested in performance and memory -usage of Ruby programs. - -If the optional argument, result_hash, is given, it is overwritten and -returned. This is intended to avoid probe effect. - -Note: The contents of the returned hash is implementation defined. It may be -changed in future. - -This method is only expected to work with C Ruby. - -On this version of MRI, they have 3 types of Symbols (and 1 total counts). - - * mortal_dynamic_symbol: GC target symbols (collected by GC) - * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC) - * immortal_static_symbol: Immortal symbols (do not collected by GC) - * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol) -**@overload** [] - -## count_tdata_objects(*args ) [](#method-c-count_tdata_objects) -Counts objects for each `T_DATA` type. - -This method is only for MRI developers interested in performance and memory -usage of Ruby programs. - -It returns a hash as: - -{RubyVM::InstructionSequence=>504, :parser=>5, :barrier=>6, :mutex=>6, -Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99, ThreadGroup=>1, -Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1, Random=>1, ARGF.class=>1, -Data=>1, :autoload=>3, Time=>2} # T_DATA objects existing at startup on -r32276. - -If the optional argument, result_hash, is given, it is overwritten and -returned. This is intended to avoid probe effect. - -The contents of the returned hash is implementation specific and may change in -the future. - -In this version, keys are Class object or Symbol object. - -If object is kind of normal (accessible) object, the key is Class object. If -object is not a kind of normal (internal) object, the key is symbol name, -registered by rb_data_type_struct. - -This method is only expected to work with C Ruby. -**@overload** [] - -## define_finalizer(*args ) [](#method-c-define_finalizer) -Adds *aProc* as a finalizer, to be called after *obj* was destroyed. The -object ID of the *obj* will be passed as an argument to *aProc*. If *aProc* is -a lambda or method, make sure it can be called with a single argument. - -The return value is an array `[0, aProc]`. - -The two recommended patterns are to either create the finaliser proc in a -non-instance method where it can safely capture the needed state, or to use a -custom callable object that stores the needed state explicitly as instance -variables. - - class Foo - def initialize(data_needed_for_finalization) - ObjectSpace.define_finalizer(self, self.class.create_finalizer(data_needed_for_finalization)) - end - - def self.create_finalizer(data_needed_for_finalization) - proc { - puts "finalizing #{data_needed_for_finalization}" - } - end - end - - class Bar - class Remover - def initialize(data_needed_for_finalization) - @data_needed_for_finalization = data_needed_for_finalization - end - - def call(id) - puts "finalizing #{@data_needed_for_finalization}" - end - end - - def initialize(data_needed_for_finalization) - ObjectSpace.define_finalizer(self, Remover.new(data_needed_for_finalization)) - end - end - -Note that if your finalizer references the object to be finalized it will -never be run on GC, although it will still be run at exit. You will get a -warning if you capture the object to be finalized as the receiver of the -finalizer. - - class CapturesSelf - def initialize(name) - ObjectSpace.define_finalizer(self, proc { - # this finalizer will only be run on exit - puts "finalizing #{name}" - }) - end - end - -Also note that finalization can be unpredictable and is never guaranteed to be -run except on exit. -**@overload** [] - -## dump(obj , output: :string) [](#method-c-dump) -Dump the contents of a ruby object as JSON. - -*output* can be one of: `:stdout`, `:file`, `:string`, or IO object. - -* `:file` means dumping to a tempfile and returning corresponding File - object; -* `:stdout` means printing the dump and returning `nil`; -* `:string` means returning a string with the dump; -* if an instance of IO object is provided, the output goes there, and the - object is returned. - -This method is only expected to work with C Ruby. This is an experimental -method and is subject to change. In particular, the function signature and -output format are not guaranteed to be compatible in future versions of ruby. -## dump_all(output: :file, full: false, since: nil, shapes: true) [](#method-c-dump_all) -Dump the contents of the ruby heap as JSON. - -*output* argument is the same as for #dump. - -*full* must be a boolean. If true, all heap slots are dumped including the -empty ones (`T_NONE`). - -*since* must be a non-negative integer or `nil`. - -If *since* is a positive integer, only objects of that generation and newer -generations are dumped. The current generation can be accessed using -GC::count. Objects that were allocated without object allocation tracing -enabled are ignored. See ::trace_object_allocations for more information and -examples. - -If *since* is omitted or is `nil`, all objects are dumped. - -*shapes* must be a boolean or a non-negative integer. - -If *shapes* is a positive integer, only shapes newer than the provided shape -id are dumped. The current shape_id can be accessed using -`RubyVM.stat(:next_shape_id)`. - -If *shapes* is `false`, no shapes are dumped. - -To only dump objects allocated past a certain point you can combine *since* -and *shapes*: - ObjectSpace.trace_object_allocations - GC.start - gc_generation = GC.count - shape_generation = RubyVM.stat(:next_shape_id) - call_method_to_instrument - ObjectSpace.dump_all(since: gc_generation, shapes: shape_generation) - -This method is only expected to work with C Ruby. This is an experimental -method and is subject to change. In particular, the function signature and -output format are not guaranteed to be compatible in future versions of ruby. -## dump_shapes(output: :file, since: 0) [](#method-c-dump_shapes) -Dump the contents of the ruby shape tree as JSON. - - _output_ argument is the same as for #dump. - - If _since_ is a positive integer, only shapes newer than the provided - shape id are dumped. The current shape_id can be accessed using RubyVM.stat(:next_shape_id). - - This method is only expected to work with C Ruby. - This is an experimental method and is subject to change. - In particular, the function signature and output format are - not guaranteed to be compatible in future versions of ruby. -## each_object(*args ) [](#method-c-each_object) -Calls the block once for each living, nonimmediate object in this Ruby -process. If *module* is specified, calls the block for only those classes or -modules that match (or are a subclass of) *module*. Returns the number of -objects found. Immediate objects (`Fixnum`s, `Symbol`s `true`, `false`, and -`nil`) are never returned. In the example below, #each_object returns both the -numbers we defined and several constants defined in the Math module. - -If no block is given, an enumerator is returned instead. - - a = 102.7 - b = 95 # Won't be returned - c = 12345678987654321 - count = ObjectSpace.each_object(Numeric) {|x| p x } - puts "Total count: #{count}" - -*produces:* - - 12345678987654321 - 102.7 - 2.71828182845905 - 3.14159265358979 - 2.22044604925031e-16 - 1.7976931348623157e+308 - 2.2250738585072e-308 - Total count: 7 -**@overload** [] - -**@overload** [] - -## garbage_collect(full_mark: true, immediate_mark: true, immediate_sweep: true) [](#method-c-garbage_collect) -Alias of GC.start -## internal_class_of(obj ) [](#method-c-internal_class_of) -MRI specific feature -: Return internal class of obj. - -obj can be an instance of InternalObjectWrapper. - -Note that you should not use this method in your application. -**@overload** [] - -## internal_super_of(obj ) [](#method-c-internal_super_of) -MRI specific feature -: Return internal super class of cls (Class or Module). - -obj can be an instance of InternalObjectWrapper. - -Note that you should not use this method in your application. -**@overload** [] - -## memsize_of(obj ) [](#method-c-memsize_of) -Return consuming memory size of obj in bytes. - -Note that the return size is incomplete. You need to deal with this -information as only a **HINT**. Especially, the size of `T_DATA` may not be -correct. - -This method is only expected to work with C Ruby. - -From Ruby 2.2, memsize_of(obj) returns a memory size includes sizeof(RVALUE). -**@overload** [] - -## memsize_of_all(*args ) [](#method-c-memsize_of_all) -Return consuming memory size of all living objects in bytes. - -If `klass` (should be Class object) is given, return the total memory size of -instances of the given class. - -Note that the returned size is incomplete. You need to deal with this -information as only a **HINT**. Especially, the size of `T_DATA` may not be -correct. - -Note that this method does **NOT** return total malloc'ed memory size. - -This method can be defined by the following Ruby code: - -def memsize_of_all klass = false total = 0 ObjectSpace.each_object{|e| - total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass) - } total end - -This method is only expected to work with C Ruby. -**@overload** [] - -## module_refenreces(klass ) [](#method-c-module_refenreces) -## module_refenreces_dot(klass ) [](#method-c-module_refenreces_dot) -## module_refenreces_image(klass , file ) [](#method-c-module_refenreces_image) -## object_id_of(obj ) [](#method-c-object_id_of) -## reachable_objects_from(obj ) [](#method-c-reachable_objects_from) -MRI specific feature -: Return all reachable objects from `obj'. - - -This method returns all reachable objects from `obj'. - -If `obj' has two or more references to the same object `x', then returned -array only includes one `x' object. - -If `obj' is a non-markable (non-heap management) object such as true, false, -nil, symbols and Fixnums (and Flonum) then it simply returns nil. - -If `obj' has references to an internal object, then it returns instances of -ObjectSpace::InternalObjectWrapper class. This object contains a reference to -an internal object and you can check the type of internal object with `type' -method. - -If `obj' is instance of ObjectSpace::InternalObjectWrapper class, then this -method returns all reachable object from an internal object, which is pointed -by `obj'. - -With this method, you can find memory leaks. - -This method is only expected to work with C Ruby. - -Example: - ObjectSpace.reachable_objects_from(['a', 'b', 'c']) - #=> [Array, 'a', 'b', 'c'] - - ObjectSpace.reachable_objects_from(['a', 'a', 'a']) - #=> [Array, 'a', 'a', 'a'] # all 'a' strings have different object id - - ObjectSpace.reachable_objects_from([v = 'a', v, v]) - #=> [Array, 'a'] - - ObjectSpace.reachable_objects_from(1) - #=> nil # 1 is not markable (heap managed) object -**@overload** [] - -## reachable_objects_from_root() [](#method-c-reachable_objects_from_root) -MRI specific feature -: Return all reachable objects from root. - -**@overload** [] - -## trace_object_allocations() [](#method-c-trace_object_allocations) -Starts tracing object allocations from the ObjectSpace extension module. - -For example: - -require 'objspace' - -class C - include ObjectSpace - - def foo - trace_object_allocations do - obj = Object.new - p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}" - end - end - -end - -C.new.foo #=> "objtrace.rb:8" - -This example has included the ObjectSpace module to make it easier to read, -but you can also use the ::trace_object_allocations notation (recommended). - -Note that this feature introduces a huge performance decrease and huge memory -consumption. -**@overload** [] - -## trace_object_allocations_clear() [](#method-c-trace_object_allocations_clear) -Clear recorded tracing information. -**@overload** [] - -## trace_object_allocations_debug_start() [](#method-c-trace_object_allocations_debug_start) -## trace_object_allocations_start() [](#method-c-trace_object_allocations_start) -Starts tracing object allocations. -**@overload** [] - -## trace_object_allocations_stop() [](#method-c-trace_object_allocations_stop) -Stop tracing object allocations. - -Note that if ::trace_object_allocations_start is called n-times, then tracing -will stop after calling ::trace_object_allocations_stop n-times. -**@overload** [] - -## undefine_finalizer(obj ) [](#method-c-undefine_finalizer) -Removes all finalizers for *obj*. -**@overload** [] - - diff --git a/example/ruby/ObjectSpace/InternalObjectWrapper.md b/example/ruby/ObjectSpace/InternalObjectWrapper.md deleted file mode 100644 index 874d024..0000000 --- a/example/ruby/ObjectSpace/InternalObjectWrapper.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: ObjectSpace::InternalObjectWrapper -**Inherits:** Object - - - - - -#Instance Methods -## inspect() [](#method-i-inspect) -See Object#inspect. - -## internal_object_id() [](#method-i-internal_object_id) -Returns the Object#object_id of the internal object. - -## type() [](#method-i-type) -Returns the type of the internal object. - diff --git a/example/ruby/ObjectSpace/WeakKeyMap.md b/example/ruby/ObjectSpace/WeakKeyMap.md deleted file mode 100644 index 4996042..0000000 --- a/example/ruby/ObjectSpace/WeakKeyMap.md +++ /dev/null @@ -1,147 +0,0 @@ -# Class: ObjectSpace::WeakKeyMap -**Inherits:** Object - - -An ObjectSpace::WeakKeyMap is a key-value map that holds weak references to -its keys, so they can be garbage collected when there is no more references. - -Unlike ObjectSpace::WeakMap: - -* references to values are *strong*, so they aren't garbage collected while - they are in the map; -* keys are compared by value (using Object#eql?), not by identity; -* only garbage-collectable objects can be used as keys. - - map = ObjectSpace::WeakKeyMap.new - val = Time.new(2023, 12, 7) - key = "name" - map[key] = val - - # Value is fetched by equality: the instance of string "name" is - # different here, but it is equal to the key - map["name"] #=> 2023-12-07 00:00:00 +0200 - - val = nil - GC.start - # There are no more references to `val`, yet the pair isn't - # garbage-collected. - map["name"] #=> 2023-12-07 00:00:00 +0200 - - key = nil - GC.start - # There are no more references to `key`, key and value are - # garbage-collected. - map["name"] #=> nil - -(Note that GC.start is used here only for demonstrational purposes and might -not always lead to demonstrated results.) - -The collection is especially useful for implementing caches of lightweight -value objects, so that only one copy of each value representation would be -stored in memory, but the copies that aren't used would be garbage-collected. - - CACHE = ObjectSpace::WeakKeyMap - - def make_value(**) - val = ValueObject.new(**) - if (existing = @cache.getkey(val)) - # if the object with this value exists, we return it - existing - else - # otherwise, put it in the cache - @cache[val] = true - val - end - end - -This will result in `make_value` returning the same object for same set of -attributes always, but the values that aren't needed anymore wouldn't be -sitting in the cache forever. - - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the value associated with the given `key` if found. - -If `key` is not found, returns `nil`. - -**@overload** [] - -## []=(key, val) [](#method-i-[]=) -Associates the given `value` with the given `key` - -The reference to `key` is weak, so when there is no other reference to `key` -it may be garbage collected. - -If the given `key` exists, replaces its value with the given `value`; the -ordering is not affected - -**@overload** [] - -## clear() [](#method-i-clear) -Removes all map entries; returns `self`. - -**@overload** [] - -## delete(key) [](#method-i-delete) -Deletes the entry for the given `key` and returns its associated value. - -If no block is given and `key` is found, deletes the entry and returns the -associated value: - m = ObjectSpace::WeakKeyMap.new - key = "foo" # to hold reference to the key - m[key] = 1 - m.delete("foo") # => 1 - m["foo"] # => nil - -If no block given and `key` is not found, returns `nil`. - -If a block is given and `key` is found, ignores the block, deletes the entry, -and returns the associated value: - m = ObjectSpace::WeakKeyMap.new - key = "foo" # to hold reference to the key - m[key] = 2 - m.delete("foo") { |key| raise 'Will never happen'} # => 2 - -If a block is given and `key` is not found, yields the `key` to the block and -returns the block's return value: - m = ObjectSpace::WeakKeyMap.new - m.delete("nosuch") { |key| "Key #{key} not found" } # => "Key nosuch not found" - -**@overload** [] - -**@overload** [] - -## getkey(key) [](#method-i-getkey) -Returns the existing equal key if it exists, otherwise returns `nil`. - -This might be useful for implementing caches, so that only one copy of some -object would be used everywhere in the program: - - value = {amount: 1, currency: 'USD'} - - # Now if we put this object in a cache: - cache = ObjectSpace::WeakKeyMap.new - cache[value] = true - - # ...we can always extract from there and use the same object: - copy = cache.getkey({amount: 1, currency: 'USD'}) - copy.object_id == value.object_id #=> true - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a new String containing informations about the map: - - m = ObjectSpace::WeakKeyMap.new - m[key] = value - m.inspect # => "#" - -**@overload** [] - -## key?(key) [](#method-i-key?) -Returns `true` if `key` is a key in `self`, otherwise `false`. - -**@overload** [] - diff --git a/example/ruby/ObjectSpace/WeakMap.md b/example/ruby/ObjectSpace/WeakMap.md deleted file mode 100644 index 77d5e27..0000000 --- a/example/ruby/ObjectSpace/WeakMap.md +++ /dev/null @@ -1,2180 +0,0 @@ -# Class: ObjectSpace::WeakMap -**Inherits:** Object - -**Includes:** Enumerable - - -An ObjectSpace::WeakMap is a key-value map that holds weak references to its -keys and values, so they can be garbage-collected when there are no more -references left. - -Keys in the map are compared by identity. - - m = ObjectSpace::WeakMap.new - key1 = "foo" - val1 = Object.new - m[key1] = val1 - - key2 = "bar" - val2 = Object.new - m[key2] = val2 - - m[key1] #=> # - m[key2] #=> # - - val1 = nil # remove the other reference to value - GC.start - - m[key1] #=> nil - m.keys #=> ["bar"] - - key2 = nil # remove the other reference to key - GC.start - - m[key2] #=> nil - m.keys #=> [] - -(Note that GC.start is used here only for demonstrational purposes and might -not always lead to demonstrated results.) - -See also ObjectSpace::WeakKeyMap map class, which compares keys by value, and -holds weak references only to the keys. - - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the value associated with the given `key` if found. - -If `key` is not found, returns `nil`. - -**@overload** [] - -## []=(key, val) [](#method-i-[]=) -Associates the given `value` with the given `key`. - -If the given `key` exists, replaces its value with the given `value`; the -ordering is not affected. - -**@overload** [] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete(key) [](#method-i-delete) -Deletes the entry for the given `key` and returns its associated value. - -If no block is given and `key` is found, deletes the entry and returns the -associated value: - m = ObjectSpace::WeakMap.new - key = "foo" - m[key] = 1 - m.delete(key) # => 1 - m[key] # => nil - -If no block is given and `key` is not found, returns `nil`. - -If a block is given and `key` is found, ignores the block, deletes the entry, -and returns the associated value: - m = ObjectSpace::WeakMap.new - key = "foo" - m[key] = 2 - m.delete(key) { |key| raise 'Will never happen'} # => 2 - -If a block is given and `key` is not found, yields the `key` to the block and -returns the block's return value: - m = ObjectSpace::WeakMap.new - m.delete("nosuch") { |key| "Key #{key} not found" } # => "Key nosuch not found" - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Iterates over keys and values. Note that unlike other collections, `each` -without block isn't supported. - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_key() [](#method-i-each_key) -Iterates over keys. Note that unlike other collections, `each_key` without -block isn't supported. - -**@overload** [] - -## each_pair() [](#method-i-each_pair) -Iterates over keys and values. Note that unlike other collections, `each` -without block isn't supported. - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_value() [](#method-i-each_value) -Iterates over values. Note that unlike other collections, `each_value` without -block isn't supported. - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(key) [](#method-i-include?) -Returns `true` if `key` is a key in `self`, otherwise `false`. - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) - -## key?(key) [](#method-i-key?) -Returns `true` if `key` is a key in `self`, otherwise `false`. - -**@overload** [] - -## keys() [](#method-i-keys) -Returns a new Array containing all keys in the map. - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## length() [](#method-i-length) -Returns the number of referenced objects - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(key) [](#method-i-member?) -Returns `true` if `key` is a key in `self`, otherwise `false`. - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) -Returns the number of referenced objects - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## values() [](#method-i-values) -Returns a new Array containing all values in the map. - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/ObjectSpaceFixtures.md b/example/ruby/ObjectSpaceFixtures.md deleted file mode 100644 index f7e5585..0000000 --- a/example/ruby/ObjectSpaceFixtures.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: ObjectSpaceFixtures - - - - -# Class Methods -## blah() [](#method-c-blah) -## define_finalizer() [](#method-c-define_finalizer) -## garbage() [](#method-c-garbage) -## garbage_objid() [](#method-c-garbage_objid) -## last_objid() [](#method-c-last_objid) -## make_finalizer() [](#method-c-make_finalizer) -## scoped(wr ) [](#method-c-scoped) -## to_be_found_symbols() [](#method-c-to_be_found_symbols) - diff --git a/example/ruby/ObjectSpaceFixtures/ObjectToBeFound.md b/example/ruby/ObjectSpaceFixtures/ObjectToBeFound.md deleted file mode 100644 index d1a95d7..0000000 --- a/example/ruby/ObjectSpaceFixtures/ObjectToBeFound.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ObjectSpaceFixtures::ObjectToBeFound -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [ObjectToBeFound] a new instance of ObjectToBeFound - diff --git a/example/ruby/ObjectSpaceFixtures/ObjectWithInstanceVariable.md b/example/ruby/ObjectSpaceFixtures/ObjectWithInstanceVariable.md deleted file mode 100644 index 3f4dfa2..0000000 --- a/example/ruby/ObjectSpaceFixtures/ObjectWithInstanceVariable.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ObjectSpaceFixtures::ObjectWithInstanceVariable -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ObjectWithInstanceVariable] a new instance of ObjectWithInstanceVariable - diff --git a/example/ruby/ObjectSpecDup.md b/example/ruby/ObjectSpecDup.md deleted file mode 100644 index 9d37bb5..0000000 --- a/example/ruby/ObjectSpecDup.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ObjectSpecDup -**Inherits:** Object - - - - -# Attributes -## obj[RW] [](#attribute-i-obj) -Returns the value of attribute obj. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ObjectSpecDup] a new instance of ObjectSpecDup - diff --git a/example/ruby/ObjectSpecDupInitCopy.md b/example/ruby/ObjectSpecDupInitCopy.md deleted file mode 100644 index d7b057f..0000000 --- a/example/ruby/ObjectSpecDupInitCopy.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: ObjectSpecDupInitCopy -**Inherits:** Object - - - - -# Attributes -## obj[RW] [](#attribute-i-obj) -Returns the value of attribute obj. - -## original[RW] [](#attribute-i-original) -Returns the value of attribute original. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ObjectSpecDupInitCopy] a new instance of ObjectSpecDupInitCopy - diff --git a/example/ruby/ObjectWithInstanceVariables.md b/example/ruby/ObjectWithInstanceVariables.md deleted file mode 100644 index 4409711..0000000 --- a/example/ruby/ObjectWithInstanceVariables.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ObjectWithInstanceVariables -**Inherits:** Object - - - - -# Attributes -## var1[RW] [](#attribute-i-var1) -Returns the value of attribute var1. - -## var2[RW] [](#attribute-i-var2) -Returns the value of attribute var2. - - diff --git a/example/ruby/ObservableSpecs.md b/example/ruby/ObservableSpecs.md deleted file mode 100644 index 8f00c47..0000000 --- a/example/ruby/ObservableSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: ObservableSpecs -**Inherits:** Object - -**Includes:** Observable - - - - - diff --git a/example/ruby/ObserverCallbackSpecs.md b/example/ruby/ObserverCallbackSpecs.md deleted file mode 100644 index 48ad0d4..0000000 --- a/example/ruby/ObserverCallbackSpecs.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ObserverCallbackSpecs -**Inherits:** Object - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ObserverCallbackSpecs] a new instance of ObserverCallbackSpecs - -## update(value) [](#method-i-update) - diff --git a/example/ruby/Olympians.md b/example/ruby/Olympians.md deleted file mode 100644 index 0aaf97c..0000000 --- a/example/ruby/Olympians.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Olympians - - - - - -#Instance Methods -## ruler3() [](#method-i-ruler3) - diff --git a/example/ruby/Open3.md b/example/ruby/Open3.md deleted file mode 100644 index d3e44ab..0000000 --- a/example/ruby/Open3.md +++ /dev/null @@ -1,1036 +0,0 @@ -# Module: Open3 - - -Module Open3 supports creating child processes with access to their $stdin, -$stdout, and $stderr streams. - -## What's Here - -Each of these methods executes a given command in a new process or subshell, -or multiple commands in new processes and/or subshells: - -* Each of these methods executes a single command in a process or subshell, - accepts a string for input to $stdin, and returns string output from - $stdout, $stderr, or both: - - * Open3.capture2: Executes the command; returns the string from $stdout. - * Open3.capture2e: Executes the command; returns the string from merged - $stdout and $stderr. - * Open3.capture3: Executes the command; returns strings from $stdout and - $stderr. - -* Each of these methods executes a single command in a process or subshell, - and returns pipes for $stdin, $stdout, and/or $stderr: - - * Open3.popen2: Executes the command; returns pipes for $stdin and - $stdout. - * Open3.popen2e: Executes the command; returns pipes for $stdin and - merged $stdout and $stderr. - * Open3.popen3: Executes the command; returns pipes for $stdin, $stdout, - and $stderr. - -* Each of these methods executes one or more commands in processes and/or - subshells, returns pipes for the first $stdin, the last $stdout, or both: - - * Open3.pipeline_r: Returns a pipe for the last $stdout. - * Open3.pipeline_rw: Returns pipes for the first $stdin and the last - $stdout. - * Open3.pipeline_w: Returns a pipe for the first $stdin. - * Open3.pipeline_start: Does not wait for processes to complete. - * Open3.pipeline: Waits for processes to complete. - -Each of the methods above accepts: - -* An optional hash of environment variable names and values; see [Execution - Environment](rdoc-ref:Process@Execution+Environment). -* A required string argument that is a `command_line` or `exe_path`; see - [Argument command_line or - exe_path](rdoc-ref:Process@Argument+command_line+or+exe_path). -* An optional hash of execution options; see [Execution - Options](rdoc-ref:Process@Execution+Options). - - -# Class Methods -## capture2(*cmd ) [](#method-c-capture2) -:call-seq: - Open3.capture2([env, ] command_line, options = {}) -> [stdout_s, status] - Open3.capture2([env, ] exe_path, *args, options = {}) -> [stdout_s, status] - -Basically a wrapper for Open3.popen3 that: - -* Creates a child process, by calling Open3.popen3 with the given arguments - (except for certain entries in hash `options`; see below). -* Returns as string `stdout_s` the standard output of the child process. -* Returns as `status` a `Process::Status` object that represents the exit - status of the child process. - -Returns the array `[stdout_s, status]`: - - stdout_s, status = Open3.capture2('echo "Foo"') - # => ["Foo\n", #] - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -Unlike Process.spawn, this method waits for the child process to exit before -returning, so the caller need not do so. - -If the first argument is a hash, it becomes leading argument `env` in the call -to Open3.popen3; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in the -call to Open3.popen3; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The hash `options` is given; two options have local effect in method -Open3.capture2: - -* If entry `options[:stdin_data]` exists, the entry is removed and its - string value is sent to the command's standard input: - - Open3.capture2('tee', stdin_data: 'Foo') - - # => ["Foo", #] - -* If entry `options[:binmode]` exists, the entry is removed and the internal - streams are set to binary mode. - -The single required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more metacharacters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - Open3.capture2('if true; then echo "Foo"; fi') # Shell reserved word. - # => ["Foo\n", #] - Open3.capture2('echo') # Built-in. - # => ["\n", #] - Open3.capture2('date > date.tmp') # Contains meta character. - # => ["", #] - -The command line may also contain arguments and options for the command: - - Open3.capture2('echo "Foo"') - # => ["Foo\n", #] - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - Open3.capture2('/usr/bin/date') - # => ["Fri Sep 29 01:00:39 PM CDT 2023\n", #] - -Ruby invokes the executable directly, with no shell and no shell expansion: - - Open3.capture2('doesnt_exist') # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - Open3.capture2('echo', 'C #') - # => ["C #\n", #] - Open3.capture2('echo', 'hello', 'world') - # => ["hello world\n", #] -## capture2e(*cmd ) [](#method-c-capture2e) -:call-seq: - Open3.capture2e([env, ] command_line, options = {}) -> [stdout_and_stderr_s, status] - Open3.capture2e([env, ] exe_path, *args, options = {}) -> [stdout_and_stderr_s, status] - -Basically a wrapper for Open3.popen3 that: - -* Creates a child process, by calling Open3.popen3 with the given arguments - (except for certain entries in hash `options`; see below). -* Returns as string `stdout_and_stderr_s` the merged standard output and - standard error of the child process. -* Returns as `status` a `Process::Status` object that represents the exit - status of the child process. - -Returns the array `[stdout_and_stderr_s, status]`: - - stdout_and_stderr_s, status = Open3.capture2e('echo "Foo"') - # => ["Foo\n", #] - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -Unlike Process.spawn, this method waits for the child process to exit before -returning, so the caller need not do so. - -If the first argument is a hash, it becomes leading argument `env` in the call -to Open3.popen3; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in the -call to Open3.popen3; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The hash `options` is given; two options have local effect in method -Open3.capture2e: - -* If entry `options[:stdin_data]` exists, the entry is removed and its - string value is sent to the command's standard input: - - Open3.capture2e('tee', stdin_data: 'Foo') - # => ["Foo", #] - -* If entry `options[:binmode]` exists, the entry is removed and the internal - streams are set to binary mode. - -The single required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more metacharacters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - Open3.capture2e('if true; then echo "Foo"; fi') # Shell reserved word. - # => ["Foo\n", #] - Open3.capture2e('echo') # Built-in. - # => ["\n", #] - Open3.capture2e('date > date.tmp') # Contains meta character. - # => ["", #] - -The command line may also contain arguments and options for the command: - - Open3.capture2e('echo "Foo"') - # => ["Foo\n", #] - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - Open3.capture2e('/usr/bin/date') - # => ["Sat Sep 30 09:01:46 AM CDT 2023\n", #] - -Ruby invokes the executable directly, with no shell and no shell expansion: - - Open3.capture2e('doesnt_exist') # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - Open3.capture2e('echo', 'C #') - # => ["C #\n", #] - Open3.capture2e('echo', 'hello', 'world') - # => ["hello world\n", #] -## capture3(*cmd ) [](#method-c-capture3) -:call-seq: - Open3.capture3([env, ] command_line, options = {}) -> [stdout_s, stderr_s, status] - Open3.capture3([env, ] exe_path, *args, options = {}) -> [stdout_s, stderr_s, status] - -Basically a wrapper for Open3.popen3 that: - -* Creates a child process, by calling Open3.popen3 with the given arguments - (except for certain entries in hash `options`; see below). -* Returns as strings `stdout_s` and `stderr_s` the standard output and - standard error of the child process. -* Returns as `status` a `Process::Status` object that represents the exit - status of the child process. - -Returns the array `[stdout_s, stderr_s, status]`: - - stdout_s, stderr_s, status = Open3.capture3('echo "Foo"') - # => ["Foo\n", "", #] - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -Unlike Process.spawn, this method waits for the child process to exit before -returning, so the caller need not do so. - -If the first argument is a hash, it becomes leading argument `env` in the call -to Open3.popen3; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in the -call to Open3.popen3; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The hash `options` is given; two options have local effect in method -Open3.capture3: - -* If entry `options[:stdin_data]` exists, the entry is removed and its - string value is sent to the command's standard input: - - Open3.capture3('tee', stdin_data: 'Foo') - # => ["Foo", "", #] - -* If entry `options[:binmode]` exists, the entry is removed and the internal - streams are set to binary mode. - -The single required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more metacharacters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - Open3.capture3('if true; then echo "Foo"; fi') # Shell reserved word. - # => ["Foo\n", "", #] - Open3.capture3('echo') # Built-in. - # => ["\n", "", #] - Open3.capture3('date > date.tmp') # Contains meta character. - # => ["", "", #] - -The command line may also contain arguments and options for the command: - - Open3.capture3('echo "Foo"') - # => ["Foo\n", "", #] - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - Open3.capture3('/usr/bin/date') - # => ["Thu Sep 28 05:03:51 PM CDT 2023\n", "", #] - -Ruby invokes the executable directly, with no shell and no shell expansion: - - Open3.capture3('doesnt_exist') # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - Open3.capture3('echo', 'C #') - # => ["C #\n", "", #] - Open3.capture3('echo', 'hello', 'world') - # => ["hello world\n", "", #] -## pipeline(*cmds ) [](#method-c-pipeline) -:call-seq: - Open3.pipeline([env, ] *cmds, options = {}) -> array_of_statuses - -Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that: - -* Creates a child process for each of the given `cmds` by calling - Process.spawn. -* Pipes the `stdout` from each child to the `stdin` of the next child, or, - for the last child, to the caller's `stdout`. -* Waits for the child processes to exit. -* Returns an array of Process::Status objects (one for each child). - -Example: - - wait_threads = Open3.pipeline('ls', 'grep R') - # => [#, #] - -Output: - - Rakefile - README.md - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -If the first argument is a hash, it becomes leading argument `env` in each -call to Process.spawn; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in each -call to Process.spawn' see [Execution -Options](rdoc-ref:Process@Execution+Options). - -Each remaining argument in `cmds` is one of: - -* A `command_line`: a string that begins with a shell reserved word or - special built-in, or contains one or more metacharacters. -* An `exe_path`: the string path to an executable to be called. -* An array containing a `command_line` or an `exe_path`, along with zero or - more string arguments for the command. - -See [Argument command_line or -exe_path](rdoc-ref:Process@Argument+command_line+or+exe_path). -## pipeline_r(*cmds , &block ) [](#method-c-pipeline_r) -:call-seq: - Open3.pipeline_r([env, ] *cmds, options = {}) -> [last_stdout, wait_threads] - -Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that: - -* Creates a child process for each of the given `cmds` by calling - Process.spawn. -* Pipes the `stdout` from each child to the `stdin` of the next child, or, - for the last child, to the caller's `stdout`. - -The method does not wait for child processes to exit, so the caller must do -so. - -With no block given, returns a 2-element array containing: - -* The `stdout` stream of the last child process. -* An array of the wait threads for all of the child processes. - -Example: - - last_stdout, wait_threads = Open3.pipeline_r('ls', 'grep R') - # => [#, [#, #]] - puts last_stdout.read - wait_threads.each do |wait_thread| - wait_thread.join - end - -Output: - - Rakefile - README.md - -With a block given, calls the block with the `stdout` stream of the last child -process, and an array of the wait processes: - - Open3.pipeline_r('ls', 'grep R') do |last_stdout, wait_threads| - puts last_stdout.read - wait_threads.each do |wait_thread| - wait_thread.join - end - end - -Output: - - Rakefile - README.md - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -If the first argument is a hash, it becomes leading argument `env` in each -call to Process.spawn; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in each -call to Process.spawn; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -Each remaining argument in `cmds` is one of: - -* A `command_line`: a string that begins with a shell reserved word or - special built-in, or contains one or more metacharacters. -* An `exe_path`: the string path to an executable to be called. -* An array containing a `command_line` or an `exe_path`, along with zero or - more string arguments for the command. - -See [Argument command_line or -exe_path](rdoc-ref:Process@Argument+command_line+or+exe_path). -## pipeline_run(cmds , pipeline_opts , child_io , parent_io ) [](#method-c-pipeline_run) -:nodoc: -## pipeline_rw(*cmds , &block ) [](#method-c-pipeline_rw) -:call-seq: - Open3.pipeline_rw([env, ] *cmds, options = {}) -> [first_stdin, last_stdout, wait_threads] - -Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that: - -* Creates a child process for each of the given `cmds` by calling - Process.spawn. -* Pipes the `stdout` from each child to the `stdin` of the next child, or, - for the first child, from the caller's `stdin`, or, for the last child, to - the caller's `stdout`. - -The method does not wait for child processes to exit, so the caller must do -so. - -With no block given, returns a 3-element array containing: - -* The `stdin` stream of the first child process. -* The `stdout` stream of the last child process. -* An array of the wait threads for all of the child processes. - -Example: - - first_stdin, last_stdout, wait_threads = Open3.pipeline_rw('sort', 'cat -n') - # => [#, #, [#, #]] - first_stdin.puts("foo\nbar\nbaz") - first_stdin.close # Send EOF to sort. - puts last_stdout.read - wait_threads.each do |wait_thread| - wait_thread.join - end - -Output: - - 1 bar - 2 baz - 3 foo - -With a block given, calls the block with the `stdin` stream of the first -child, the `stdout` stream of the last child, and an array of the wait -processes: - - Open3.pipeline_rw('sort', 'cat -n') do |first_stdin, last_stdout, wait_threads| - first_stdin.puts "foo\nbar\nbaz" - first_stdin.close # send EOF to sort. - puts last_stdout.read - wait_threads.each do |wait_thread| - wait_thread.join - end - end - -Output: - - 1 bar - 2 baz - 3 foo - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -If the first argument is a hash, it becomes leading argument `env` in each -call to Process.spawn; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in each -call to Process.spawn; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -Each remaining argument in `cmds` is one of: - -* A `command_line`: a string that begins with a shell reserved word or - special built-in, or contains one or more metacharacters. -* An `exe_path`: the string path to an executable to be called. -* An array containing a `command_line` or an `exe_path`, along with zero or - more string arguments for the command. - -See [Argument command_line or -exe_path](rdoc-ref:Process@Argument+command_line+or+exe_path). -## pipeline_start(*cmds , &block ) [](#method-c-pipeline_start) -:call-seq: - Open3.pipeline_start([env, ] *cmds, options = {}) -> [wait_threads] - -Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that: - -* Creates a child process for each of the given `cmds` by calling - Process.spawn. -* Does not wait for child processes to exit. - -With no block given, returns an array of the wait threads for all of the child -processes. - -Example: - - wait_threads = Open3.pipeline_start('ls', 'grep R') - # => [#, #] - wait_threads.each do |wait_thread| - wait_thread.join - end - -Output: - - Rakefile - README.md - -With a block given, calls the block with an array of the wait processes: - - Open3.pipeline_start('ls', 'grep R') do |wait_threads| - wait_threads.each do |wait_thread| - wait_thread.join - end - end - -Output: - - Rakefile - README.md - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -If the first argument is a hash, it becomes leading argument `env` in each -call to Process.spawn; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in each -call to Process.spawn; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -Each remaining argument in `cmds` is one of: - -* A `command_line`: a string that begins with a shell reserved word or - special built-in, or contains one or more metacharacters. -* An `exe_path`: the string path to an executable to be called. -* An array containing a `command_line` or an `exe_path`, along with zero or - more string arguments for the command. - -See [Argument command_line or -exe_path](rdoc-ref:Process@Argument+command_line+or+exe_path). -## pipeline_w(*cmds , &block ) [](#method-c-pipeline_w) -:call-seq: - Open3.pipeline_w([env, ] *cmds, options = {}) -> [first_stdin, wait_threads] - -Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that: - -* Creates a child process for each of the given `cmds` by calling - Process.spawn. -* Pipes the `stdout` from each child to the `stdin` of the next child, or, - for the first child, pipes the caller's `stdout` to the child's `stdin`. - -The method does not wait for child processes to exit, so the caller must do -so. - -With no block given, returns a 2-element array containing: - -* The `stdin` stream of the first child process. -* An array of the wait threads for all of the child processes. - -Example: - - first_stdin, wait_threads = Open3.pipeline_w('sort', 'cat -n') - # => [#, [#, #]] - first_stdin.puts("foo\nbar\nbaz") - first_stdin.close # Send EOF to sort. - wait_threads.each do |wait_thread| - wait_thread.join - end - -Output: - - 1 bar - 2 baz - 3 foo - -With a block given, calls the block with the `stdin` stream of the first child -process, and an array of the wait processes: - - Open3.pipeline_w('sort', 'cat -n') do |first_stdin, wait_threads| - first_stdin.puts("foo\nbar\nbaz") - first_stdin.close # Send EOF to sort. - wait_threads.each do |wait_thread| - wait_thread.join - end - end - -Output: - - 1 bar - 2 baz - 3 foo - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -If the first argument is a hash, it becomes leading argument `env` in each -call to Process.spawn; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in each -call to Process.spawn; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -Each remaining argument in `cmds` is one of: - -* A `command_line`: a string that begins with a shell reserved word or - special built-in, or contains one or more metacharacters. -* An `exe_path`: the string path to an executable to be called. -* An array containing a `command_line` or an `exe_path`, along with zero or - more string arguments for the command. - -See [Argument command_line or -exe_path](rdoc-ref:Process@Argument+command_line+or+exe_path). -## popen2(*cmd , &block ) [](#method-c-popen2) -:call-seq: - Open3.popen2([env, ] command_line, options = {}) -> [stdin, stdout, wait_thread] - Open3.popen2([env, ] exe_path, *args, options = {}) -> [stdin, stdout, wait_thread] - Open3.popen2([env, ] command_line, options = {}) {|stdin, stdout, wait_thread| ... } -> object - Open3.popen2([env, ] exe_path, *args, options = {}) {|stdin, stdout, wait_thread| ... } -> object - -Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that: - -* Creates a child process, by calling Process.spawn with the given - arguments. -* Creates streams `stdin` and `stdout`, which are the standard input and - standard output streams in the child process. -* Creates thread `wait_thread` that waits for the child process to exit; the - thread has method `pid`, which returns the process ID of the child - process. - -With no block given, returns the array `[stdin, stdout, wait_thread]`. The -caller should close each of the two returned streams. - - stdin, stdout, wait_thread = Open3.popen2('echo') - # => [#, #, #] - stdin.close - stdout.close - wait_thread.pid # => 2263572 - wait_thread.value # => # - -With a block given, calls the block with the three variables (two streams and -the wait thread) and returns the block's return value. The caller need not -close the streams: - - Open3.popen2('echo') do |stdin, stdout, wait_thread| - p stdin - p stdout - p wait_thread - p wait_thread.pid - p wait_thread.value - end - -Output: - - # - # - # - 2263636 - # - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -Unlike Process.spawn, this method waits for the child process to exit before -returning, so the caller need not do so. - -If the first argument is a hash, it becomes leading argument `env` in the call -to Process.spawn; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in the -call to Process.spawn; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The single required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more metacharacters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - Open3.popen2('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word. - Open3.popen2('echo') {|*args| p args } # Built-in. - Open3.popen2('date > date.tmp') {|*args| p args } # Contains meta character. - -Output (similar for each call above): - - # => [#, #, #] - -The command line may also contain arguments and options for the command: - - Open3.popen2('echo "Foo"') { |i, o, t| o.gets } - "Foo\n" - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - Open3.popen2('/usr/bin/date') { |i, o, t| o.gets } - # => "Thu Sep 28 09:41:06 AM CDT 2023\n" - -Ruby invokes the executable directly, with no shell and no shell expansion: - - Open3.popen2('doesnt_exist') { |i, o, t| o.gets } # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - Open3.popen2('echo', 'C #') { |i, o, t| o.gets } - # => "C #\n" - Open3.popen2('echo', 'hello', 'world') { |i, o, t| o.gets } - # => "hello world\n" - -Related: - -* Open3.popen2e: Makes the standard input and the merge of the standard - output and standard error streams of the child process available as - separate streams. -* Open3.popen3: Makes the standard input, standard output, and standard - error streams of the child process available as separate streams. -## popen2e(*cmd , &block ) [](#method-c-popen2e) -:call-seq: - Open3.popen2e([env, ] command_line, options = {}) -> [stdin, stdout_and_stderr, wait_thread] - Open3.popen2e([env, ] exe_path, *args, options = {}) -> [stdin, stdout_and_stderr, wait_thread] - Open3.popen2e([env, ] command_line, options = {}) {|stdin, stdout_and_stderr, wait_thread| ... } -> object - Open3.popen2e([env, ] exe_path, *args, options = {}) {|stdin, stdout_and_stderr, wait_thread| ... } -> object - -Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that: - -* Creates a child process, by calling Process.spawn with the given - arguments. -* Creates streams `stdin`, `stdout_and_stderr`, which are the standard input - and the merge of the standard output and standard error streams in the - child process. -* Creates thread `wait_thread` that waits for the child process to exit; the - thread has method `pid`, which returns the process ID of the child - process. - -With no block given, returns the array `[stdin, stdout_and_stderr, -wait_thread]`. The caller should close each of the two returned streams. - - stdin, stdout_and_stderr, wait_thread = Open3.popen2e('echo') - # => [#, #, #] - stdin.close - stdout_and_stderr.close - wait_thread.pid # => 2274600 - wait_thread.value # => # - -With a block given, calls the block with the three variables (two streams and -the wait thread) and returns the block's return value. The caller need not -close the streams: - - Open3.popen2e('echo') do |stdin, stdout_and_stderr, wait_thread| - p stdin - p stdout_and_stderr - p wait_thread - p wait_thread.pid - p wait_thread.value - end - -Output: - - # - # - # - 2274763 - # - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -Unlike Process.spawn, this method waits for the child process to exit before -returning, so the caller need not do so. - -If the first argument is a hash, it becomes leading argument `env` in the call -to Process.spawn; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in the -call to Process.spawn; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The single required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more metacharacters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - Open3.popen2e('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word. - Open3.popen2e('echo') {|*args| p args } # Built-in. - Open3.popen2e('date > date.tmp') {|*args| p args } # Contains meta character. - -Output (similar for each call above): - - # => [#, #, #] - -The command line may also contain arguments and options for the command: - - Open3.popen2e('echo "Foo"') { |i, o_and_e, t| o_and_e.gets } - "Foo\n" - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - Open3.popen2e('/usr/bin/date') { |i, o_and_e, t| o_and_e.gets } - # => "Thu Sep 28 01:58:45 PM CDT 2023\n" - -Ruby invokes the executable directly, with no shell and no shell expansion: - - Open3.popen2e('doesnt_exist') { |i, o_and_e, t| o_and_e.gets } # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - Open3.popen2e('echo', 'C #') { |i, o_and_e, t| o_and_e.gets } - # => "C #\n" - Open3.popen2e('echo', 'hello', 'world') { |i, o_and_e, t| o_and_e.gets } - # => "hello world\n" - -Related: - -* Open3.popen2: Makes the standard input and standard output streams of the - child process available as separate streams, with no access to the - standard error stream. -* Open3.popen3: Makes the standard input, standard output, and standard - error streams of the child process available as separate streams. -## popen3(*cmd , &block ) [](#method-c-popen3) -:call-seq: - Open3.popen3([env, ] command_line, options = {}) -> [stdin, stdout, stderr, wait_thread] - Open3.popen3([env, ] exe_path, *args, options = {}) -> [stdin, stdout, stderr, wait_thread] - Open3.popen3([env, ] command_line, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object - Open3.popen3([env, ] exe_path, *args, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object - -Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that: - -* Creates a child process, by calling Process.spawn with the given - arguments. -* Creates streams `stdin`, `stdout`, and `stderr`, which are the standard - input, standard output, and standard error streams in the child process. -* Creates thread `wait_thread` that waits for the child process to exit; the - thread has method `pid`, which returns the process ID of the child - process. - -With no block given, returns the array `[stdin, stdout, stderr, wait_thread]`. -The caller should close each of the three returned streams. - - stdin, stdout, stderr, wait_thread = Open3.popen3('echo') - # => [#, #, #, #] - stdin.close - stdout.close - stderr.close - wait_thread.pid # => 2210481 - wait_thread.value # => # - -With a block given, calls the block with the four variables (three streams and -the wait thread) and returns the block's return value. The caller need not -close the streams: - - Open3.popen3('echo') do |stdin, stdout, stderr, wait_thread| - p stdin - p stdout - p stderr - p wait_thread - p wait_thread.pid - p wait_thread.value - end - -Output: - - # - # - # - # - 2211047 - # - -Like Process.spawn, this method has potential security vulnerabilities if -called with untrusted input; see [Command -Injection](rdoc-ref:command_injection.rdoc@Command+Injection). - -Unlike Process.spawn, this method waits for the child process to exit before -returning, so the caller need not do so. - -If the first argument is a hash, it becomes leading argument `env` in the call -to Process.spawn; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -If the last argument is a hash, it becomes trailing argument `options` in the -call to Process.spawn; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The single required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more metacharacters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - Open3.popen3('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word. - Open3.popen3('echo') {|*args| p args } # Built-in. - Open3.popen3('date > date.tmp') {|*args| p args } # Contains meta character. - -Output (similar for each call above): - - [#, #, #, #] - -The command line may also contain arguments and options for the command: - - Open3.popen3('echo "Foo"') { |i, o, e, t| o.gets } - "Foo\n" - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - Open3.popen3('/usr/bin/date') { |i, o, e, t| o.gets } - # => "Wed Sep 27 02:56:44 PM CDT 2023\n" - -Ruby invokes the executable directly, with no shell and no shell expansion: - - Open3.popen3('doesnt_exist') { |i, o, e, t| o.gets } # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - Open3.popen3('echo', 'C #') { |i, o, e, t| o.gets } - # => "C #\n" - Open3.popen3('echo', 'hello', 'world') { |i, o, e, t| o.gets } - # => "hello world\n" - -Take care to avoid deadlocks. Output streams `stdout` and `stderr` have -fixed-size buffers, so reading extensively from one but not the other can -cause a deadlock when the unread buffer fills. To avoid that, `stdout` and -`stderr` should be read simultaneously (using threads or IO.select). - -Related: - -* Open3.popen2: Makes the standard input and standard output streams of the - child process available as separate streams, with no access to the - standard error stream. -* Open3.popen2e: Makes the standard input and the merge of the standard - output and standard error streams of the child process available as - separate streams. -## popen_run(cmd , opts , child_io , parent_io ) [](#method-c-popen_run) -:nodoc: - diff --git a/example/ruby/OpenSSL.md b/example/ruby/OpenSSL.md deleted file mode 100644 index cabca6d..0000000 --- a/example/ruby/OpenSSL.md +++ /dev/null @@ -1,40 +0,0 @@ -# Module: OpenSSL - - --- -# Ruby-space definitions to add DER (de)serialization to classes - -# Info -'OpenSSL for Ruby 2' project Copyright (C) 2002 Michal Rokos - All rights reserved. - -# Licence -This program is licensed under the same licence as Ruby. (See the file -'COPYING'.) ++ - - -# Class Methods -## Digest(name ) [](#method-c-Digest) -Returns a Digest subclass by *name* - - require 'openssl' - - OpenSSL::Digest("MD5") - # => OpenSSL::Digest::MD5 - - Digest("Foo") - # => NameError: wrong constant name Foo -## debug() [](#method-c-debug) -## debug=() [](#method-c-debug=) -## errors() [](#method-c-errors) -## fips_mode() [](#method-c-fips_mode) -## fips_mode=() [](#method-c-fips_mode=) -## fixed_length_secure_compare() [](#method-c-fixed_length_secure_compare) -## secure_compare(a , b ) [](#method-c-secure_compare) -call-seq: - OpenSSL.secure_compare(string, string) -> boolean - -Constant time memory comparison. Inputs are hashed using SHA-256 to mask the -length of the secret. Returns `true` if the strings are identical, `false` -otherwise. - diff --git a/example/ruby/OpenSSL/ASN1.md b/example/ruby/OpenSSL/ASN1.md deleted file mode 100644 index ec5c905..0000000 --- a/example/ruby/OpenSSL/ASN1.md +++ /dev/null @@ -1,165 +0,0 @@ -# Module: OpenSSL::ASN1 - - -Abstract Syntax Notation One (or ASN.1) is a notation syntax to describe data -structures and is defined in ITU-T X.680. ASN.1 itself does not mandate any -encoding or parsing rules, but usually ASN.1 data structures are encoded using -the Distinguished Encoding Rules (DER) or less often the Basic Encoding Rules -(BER) described in ITU-T X.690. DER and BER encodings are binary -Tag-Length-Value (TLV) encodings that are quite concise compared to other -popular data description formats such as XML, JSON etc. ASN.1 data structures -are very common in cryptographic applications, e.g. X.509 public key -certificates or certificate revocation lists (CRLs) are all defined in ASN.1 -and DER-encoded. ASN.1, DER and BER are the building blocks of applied -cryptography. The ASN1 module provides the necessary classes that allow -generation of ASN.1 data structures and the methods to encode them using a DER -encoding. The decode method allows parsing arbitrary BER-/DER-encoded data to -a Ruby object that can then be modified and re-encoded at will. - -## ASN.1 class hierarchy - -The base class representing ASN.1 structures is ASN1Data. ASN1Data offers -attributes to read and set the *tag*, the *tag_class* and finally the *value* -of a particular ASN.1 item. Upon parsing, any tagged values (implicit or -explicit) will be represented by ASN1Data instances because their "real type" -can only be determined using out-of-band information from the ASN.1 type -declaration. Since this information is normally known when encoding a type, -all sub-classes of ASN1Data offer an additional attribute *tagging* that -allows to encode a value implicitly (`:IMPLICIT`) or explicitly (`:EXPLICIT`). - -### Constructive - -Constructive is, as its name implies, the base class for all constructed -encodings, i.e. those that consist of several values, opposed to "primitive" -encodings with just one single value. The value of an Constructive is always -an Array. - -#### ASN1::Set and ASN1::Sequence - -The most common constructive encodings are SETs and SEQUENCEs, which is why -there are two sub-classes of Constructive representing each of them. - -### Primitive - -This is the super class of all primitive values. Primitive itself is not used -when parsing ASN.1 data, all values are either instances of a corresponding -sub-class of Primitive or they are instances of ASN1Data if the value was -tagged implicitly or explicitly. Please cf. Primitive documentation for -details on sub-classes and their respective mappings of ASN.1 data types to -Ruby objects. - -## Possible values for *tagging* - -When constructing an ASN1Data object the ASN.1 type definition may require -certain elements to be either implicitly or explicitly tagged. This can be -achieved by setting the *tagging* attribute manually for sub-classes of -ASN1Data. Use the symbol `:IMPLICIT` for implicit tagging and `:EXPLICIT` if -the element requires explicit tagging. - -## Possible values for *tag_class* - -It is possible to create arbitrary ASN1Data objects that also support a -PRIVATE or APPLICATION tag class. Possible values for the *tag_class* -attribute are: -* `:UNIVERSAL` (the default for untagged values) -* `:CONTEXT_SPECIFIC` (the default for tagged values) -* `:APPLICATION` -* `:PRIVATE` - -## Tag constants - -There is a constant defined for each universal tag: -* OpenSSL::ASN1::EOC (0) -* OpenSSL::ASN1::BOOLEAN (1) -* OpenSSL::ASN1::INTEGER (2) -* OpenSSL::ASN1::BIT_STRING (3) -* OpenSSL::ASN1::OCTET_STRING (4) -* OpenSSL::ASN1::NULL (5) -* OpenSSL::ASN1::OBJECT (6) -* OpenSSL::ASN1::ENUMERATED (10) -* OpenSSL::ASN1::UTF8STRING (12) -* OpenSSL::ASN1::SEQUENCE (16) -* OpenSSL::ASN1::SET (17) -* OpenSSL::ASN1::NUMERICSTRING (18) -* OpenSSL::ASN1::PRINTABLESTRING (19) -* OpenSSL::ASN1::T61STRING (20) -* OpenSSL::ASN1::VIDEOTEXSTRING (21) -* OpenSSL::ASN1::IA5STRING (22) -* OpenSSL::ASN1::UTCTIME (23) -* OpenSSL::ASN1::GENERALIZEDTIME (24) -* OpenSSL::ASN1::GRAPHICSTRING (25) -* OpenSSL::ASN1::ISO64STRING (26) -* OpenSSL::ASN1::GENERALSTRING (27) -* OpenSSL::ASN1::UNIVERSALSTRING (28) -* OpenSSL::ASN1::BMPSTRING (30) - -## UNIVERSAL_TAG_NAME constant - -An Array that stores the name of a given tag number. These names are the same -as the name of the tag constant that is additionally defined, e.g. -`UNIVERSAL_TAG_NAME[2] = "INTEGER"` and `OpenSSL::ASN1::INTEGER = 2`. - -## Example usage - -### Decoding and viewing a DER-encoded file - require 'openssl' - require 'pp' - der = File.binread('data.der') - asn1 = OpenSSL::ASN1.decode(der) - pp der - -### Creating an ASN.1 structure and DER-encoding it - require 'openssl' - version = OpenSSL::ASN1::Integer.new(1) - # Explicitly 0-tagged implies context-specific tag class - serial = OpenSSL::ASN1::Integer.new(12345, 0, :EXPLICIT, :CONTEXT_SPECIFIC) - name = OpenSSL::ASN1::PrintableString.new('Data 1') - sequence = OpenSSL::ASN1::Sequence.new( [ version, serial, name ] ) - der = sequence.to_der - - -# Class Methods -## decode(obj ) [](#method-c-decode) -Decodes a BER- or DER-encoded value and creates an ASN1Data instance. *der* -may be a String or any object that features a `.to_der` method transforming it -into a BER-/DER-encoded String+ - -## Example - der = File.binread('asn1data') - asn1 = OpenSSL::ASN1.decode(der) -**@overload** [] - -## decode_all(obj ) [](#method-c-decode_all) -Similar to #decode with the difference that #decode expects one distinct value -represented in *der*. #decode_all on the contrary decodes a sequence of -sequential BER/DER values lined up in *der* and returns them as an array. - -## Example - ders = File.binread('asn1data_seq') - asn1_ary = OpenSSL::ASN1.decode_all(ders) -**@overload** [] - -## take_default_tag(klass ) [](#method-c-take_default_tag) -:nodoc: -## traverse(obj ) [](#method-c-traverse) -If a block is given, it prints out each of the elements encountered. Block -parameters are (in that order): -* depth: The recursion depth, plus one with each constructed value being - encountered (Integer) -* offset: Current byte offset (Integer) -* header length: Combined length in bytes of the Tag and Length headers. - (Integer) -* length: The overall remaining length of the entire data (Integer) -* constructed: Whether this value is constructed or not (Boolean) -* tag_class: Current tag class (Symbol) -* tag: The current tag number (Integer) - -## Example - der = File.binread('asn1data.der') - OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag| - puts "Depth: #{depth} Offset: #{offset} Length: #{length}" - puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}" - end -**@overload** [] - - diff --git a/example/ruby/OpenSSL/ASN1/ASN1Data.md b/example/ruby/OpenSSL/ASN1/ASN1Data.md deleted file mode 100644 index b12887d..0000000 --- a/example/ruby/OpenSSL/ASN1/ASN1Data.md +++ /dev/null @@ -1,140 +0,0 @@ -# Class: OpenSSL::ASN1::ASN1Data -**Inherits:** Object - - -The top-level class representing any ASN.1 object. When parsed by ASN1.decode, -tagged values are always represented by an instance of ASN1Data. - -## The role of ASN1Data for parsing tagged values - -When encoding an ASN.1 type it is inherently clear what original type (e.g. -INTEGER, OCTET STRING etc.) this value has, regardless of its tagging. But -opposed to the time an ASN.1 type is to be encoded, when parsing them it is -not possible to deduce the "real type" of tagged values. This is why tagged -values are generally parsed into ASN1Data instances, but with a different -outcome for implicit and explicit tagging. - -### Example of a parsed implicitly tagged value - -An implicitly 1-tagged INTEGER value will be parsed as an ASN1Data with -* *tag* equal to 1 -* *tag_class* equal to `:CONTEXT_SPECIFIC` -* *value* equal to a String that carries the raw encoding of the INTEGER. -This implies that a subsequent decoding step is required to completely decode -implicitly tagged values. - -### Example of a parsed explicitly tagged value - -An explicitly 1-tagged INTEGER value will be parsed as an ASN1Data with -* *tag* equal to 1 -* *tag_class* equal to `:CONTEXT_SPECIFIC` -* *value* equal to an Array with one single element, an instance of - OpenSSL::ASN1::Integer, i.e. the inner element is the non-tagged primitive - value, and the tagging is represented in the outer ASN1Data - -## Example - Decoding an implicitly tagged INTEGER - int = OpenSSL::ASN1::Integer.new(1, 0, :IMPLICIT) # implicit 0-tagged - seq = OpenSSL::ASN1::Sequence.new( [int] ) - der = seq.to_der - asn1 = OpenSSL::ASN1.decode(der) - # pp asn1 => #]> - raw_int = asn1.value[0] - # manually rewrite tag and tag class to make it an UNIVERSAL value - raw_int.tag = OpenSSL::ASN1::INTEGER - raw_int.tag_class = :UNIVERSAL - int2 = OpenSSL::ASN1.decode(raw_int) - puts int2.value # => 1 - -## Example - Decoding an explicitly tagged INTEGER - int = OpenSSL::ASN1::Integer.new(1, 0, :EXPLICIT) # explicit 0-tagged - seq = OpenSSL::ASN1::Sequence.new( [int] ) - der = seq.to_der - asn1 = OpenSSL::ASN1.decode(der) - # pp asn1 => #]>]> - int2 = asn1.value[0].value[0] - puts int2.value # => 1 - - -# Attributes -## indefinite_length[RW] [](#attribute-i-indefinite_length) -Never `nil`. A boolean value indicating whether the encoding uses indefinite -length (in the case of parsing) or whether an indefinite length form shall be -used (in the encoding case). In DER, every value uses definite length form. -But in scenarios where large amounts of data need to be transferred it might -be desirable to have some kind of streaming support available. For example, -huge OCTET STRINGs are preferably sent in smaller-sized chunks, each at a -time. This is possible in BER by setting the length bytes of an encoding to -zero and by this indicating that the following value will be sent in chunks. -Indefinite length encodings are always constructed. The end of such a stream -of chunks is indicated by sending a EOC (End of Content) tag. SETs and -SEQUENCEs may use an indefinite length encoding, but also primitive types such -as e.g. OCTET STRINGS or BIT STRINGS may leverage this functionality (cf. -ITU-T X.690). - -## tag[RW] [](#attribute-i-tag) -An Integer representing the tag number of this ASN1Data. Never `nil`. - -## tag_class[RW] [](#attribute-i-tag_class) -A Symbol representing the tag class of this ASN1Data. Never `nil`. See -ASN1Data for possible values. - -## value[RW] [](#attribute-i-value) -Carries the value of a ASN.1 type. Please confer Constructive and Primitive -for the mappings between ASN.1 data types and Ruby classes. - - -#Instance Methods -## initialize(value, tag, tag_class) [](#method-i-initialize) -:call-seq: - OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) => ASN1Data - -*value*: Please have a look at Constructive and Primitive to see how Ruby -types are mapped to ASN.1 types and vice versa. - -*tag*: An Integer indicating the tag number. - -*tag_class*: A Symbol indicating the tag class. Please cf. ASN1 for possible -values. - -## Example - asn1_int = OpenSSL::ASN1Data.new(42, 2, :UNIVERSAL) # => Same as OpenSSL::ASN1::Integer.new(42) - tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER - -**@raise** [ASN1Error] - -**@return** [ASN1Data] a new instance of ASN1Data - -## to_der() [](#method-i-to_der) -Encodes this ASN1Data into a DER-encoded String value. The result is -DER-encoded except for the possibility of indefinite length forms. Indefinite -length forms are not allowed in strict DER, so strictly speaking the result of -such an encoding would be a BER-encoding. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/ASN1/ASN1Error.md b/example/ruby/OpenSSL/ASN1/ASN1Error.md deleted file mode 100644 index 9f8459e..0000000 --- a/example/ruby/OpenSSL/ASN1/ASN1Error.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: OpenSSL::ASN1::ASN1Error -**Inherits:** OpenSSL::OpenSSLError - - -Generic error class for all errors raised in ASN1 and any of the classes -defined in it. - - - diff --git a/example/ruby/OpenSSL/ASN1/BitString.md b/example/ruby/OpenSSL/ASN1/BitString.md deleted file mode 100644 index a6788c7..0000000 --- a/example/ruby/OpenSSL/ASN1/BitString.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: OpenSSL::ASN1::BitString -**Inherits:** OpenSSL::ASN1::Primitive - - - - -# Attributes -## unused_bits[RW] [](#attribute-i-unused_bits) -Returns the value of attribute unused_bits. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [BitString] a new instance of BitString - diff --git a/example/ruby/OpenSSL/ASN1/Boolean.md b/example/ruby/OpenSSL/ASN1/Boolean.md deleted file mode 100644 index 1a78325..0000000 --- a/example/ruby/OpenSSL/ASN1/Boolean.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: OpenSSL::ASN1::Boolean -**Inherits:** OpenSSL::ASN1::Primitive - - - - - diff --git a/example/ruby/OpenSSL/ASN1/Constructive.md b/example/ruby/OpenSSL/ASN1/Constructive.md deleted file mode 100644 index 218c6c9..0000000 --- a/example/ruby/OpenSSL/ASN1/Constructive.md +++ /dev/null @@ -1,2130 +0,0 @@ -# Class: OpenSSL::ASN1::Constructive -**Inherits:** OpenSSL::ASN1::ASN1Data - -**Includes:** Enumerable, OpenSSL::ASN1::TaggedASN1Data - - -The parent class for all constructed encodings. The *value* attribute of a -Constructive is always an Array. Attributes are the same as for ASN1Data, with -the addition of *tagging*. - -## SET and SEQUENCE - -Most constructed encodings come in the form of a SET or a SEQUENCE. These -encodings are represented by one of the two sub-classes of Constructive: -* OpenSSL::ASN1::Set -* OpenSSL::ASN1::Sequence -Please note that tagged sequences and sets are still parsed as instances of -ASN1Data. Find further details on tagged values there. - -### Example - constructing a SEQUENCE - int = OpenSSL::ASN1::Integer.new(1) - str = OpenSSL::ASN1::PrintableString.new('abc') - sequence = OpenSSL::ASN1::Sequence.new( [ int, str ] ) - -### Example - constructing a SET - int = OpenSSL::ASN1::Integer.new(1) - str = OpenSSL::ASN1::PrintableString.new('abc') - set = OpenSSL::ASN1::Set.new( [ int, str ] ) - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&blk) [](#method-i-each) -:call-seq: - asn1_ary.each { |asn1| block } => asn1_ary - -Calls the given block once for each element in self, passing that element as -parameter *asn1*. If no block is given, an enumerator is returned instead. - -## Example - asn1_ary.each do |asn1| - puts asn1 - end - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(value, tagnil, taggingnil, tag_classnil) [](#method-i-initialize) -:call-seq: - OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) => Primitive - -*value*: is mandatory. - -*tag*: optional, may be specified for tagged values. If no *tag* is specified, -the UNIVERSAL tag corresponding to the Primitive sub-class is used by default. - -*tagging*: may be used as an encoding hint to encode a value either explicitly -or implicitly, see ASN1 for possible values. - -*tag_class*: if *tag* and *tagging* are `nil` then this is set to `:UNIVERSAL` -by default. If either *tag* or *tagging* are set then `:CONTEXT_SPECIFIC` is -used as the default. For possible values please cf. ASN1. - -## Example - int = OpenSSL::ASN1::Integer.new(42) - zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT) - private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE) - -**@raise** [ASN1Error] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_der() [](#method-i-to_der) -See ASN1Data#to_der for details. - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/OpenSSL/ASN1/EndOfContent.md b/example/ruby/OpenSSL/ASN1/EndOfContent.md deleted file mode 100644 index 98f8b47..0000000 --- a/example/ruby/OpenSSL/ASN1/EndOfContent.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: OpenSSL::ASN1::EndOfContent -**Inherits:** OpenSSL::ASN1::ASN1Data - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [EndOfContent] a new instance of EndOfContent - diff --git a/example/ruby/OpenSSL/ASN1/Enumerated.md b/example/ruby/OpenSSL/ASN1/Enumerated.md deleted file mode 100644 index 9040daf..0000000 --- a/example/ruby/OpenSSL/ASN1/Enumerated.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: OpenSSL::ASN1::Enumerated -**Inherits:** OpenSSL::ASN1::Primitive - - - - - diff --git a/example/ruby/OpenSSL/ASN1/Integer.md b/example/ruby/OpenSSL/ASN1/Integer.md deleted file mode 100644 index 006f5de..0000000 --- a/example/ruby/OpenSSL/ASN1/Integer.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: OpenSSL::ASN1::Integer -**Inherits:** OpenSSL::ASN1::Primitive - - - - - diff --git a/example/ruby/OpenSSL/ASN1/ObjectId.md b/example/ruby/OpenSSL/ASN1/ObjectId.md deleted file mode 100644 index 98b700c..0000000 --- a/example/ruby/OpenSSL/ASN1/ObjectId.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: OpenSSL::ASN1::ObjectId -**Inherits:** OpenSSL::ASN1::Primitive - - -Represents the primitive object id for OpenSSL::ASN1 - - -# Class Methods -## register(oid , sn , ln ) [](#method-c-register) -This adds a new ObjectId to the internal tables. Where *object_id* is the -numerical form, *short_name* is the short name, and *long_name* is the long -name. - -Returns `true` if successful. Raises an OpenSSL::ASN1::ASN1Error if it fails. -**@overload** [] - - -#Instance Methods -## ==(other) [](#method-i-==) -Returns `true` if *other_oid* is the same as *oid*. - -**@overload** [] - -## ln() [](#method-i-ln) -The long name of the ObjectId, as defined in . - -**@overload** [] - -**@overload** [] - -## oid() [](#method-i-oid) -Returns a String representing the Object Identifier in the dot notation, e.g. -"1.2.3.4.5" - -**@overload** [] - -## sn() [](#method-i-sn) -The short name of the ObjectId, as defined in . - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/OpenSSL/ASN1/Primitive.md b/example/ruby/OpenSSL/ASN1/Primitive.md deleted file mode 100644 index b1669d3..0000000 --- a/example/ruby/OpenSSL/ASN1/Primitive.md +++ /dev/null @@ -1,97 +0,0 @@ -# Class: OpenSSL::ASN1::Primitive -**Inherits:** OpenSSL::ASN1::ASN1Data - -**Includes:** OpenSSL::ASN1::TaggedASN1Data - - -The parent class for all primitive encodings. Attributes are the same as for -ASN1Data, with the addition of *tagging*. Primitive values can never be -encoded with indefinite length form, thus it is not possible to set the -*indefinite_length* attribute for Primitive and its sub-classes. - -## Primitive sub-classes and their mapping to Ruby classes -* OpenSSL::ASN1::EndOfContent <=> *value* is always `nil` -* OpenSSL::ASN1::Boolean <=> *value* is `true` or `false` -* OpenSSL::ASN1::Integer <=> *value* is an OpenSSL::BN -* OpenSSL::ASN1::BitString <=> *value* is a String -* OpenSSL::ASN1::OctetString <=> *value* is a String -* OpenSSL::ASN1::Null <=> *value* is always `nil` -* OpenSSL::ASN1::Object <=> *value* is a String -* OpenSSL::ASN1::Enumerated <=> *value* is an OpenSSL::BN -* OpenSSL::ASN1::UTF8String <=> *value* is a String -* OpenSSL::ASN1::NumericString <=> *value* is a String -* OpenSSL::ASN1::PrintableString <=> *value* is a String -* OpenSSL::ASN1::T61String <=> *value* is a String -* OpenSSL::ASN1::VideotexString <=> *value* is a String -* OpenSSL::ASN1::IA5String <=> *value* is a String -* OpenSSL::ASN1::UTCTime <=> *value* is a Time -* OpenSSL::ASN1::GeneralizedTime <=> *value* is a Time -* OpenSSL::ASN1::GraphicString <=> *value* is a String -* OpenSSL::ASN1::ISO64String <=> *value* is a String -* OpenSSL::ASN1::GeneralString <=> *value* is a String -* OpenSSL::ASN1::UniversalString <=> *value* is a String -* OpenSSL::ASN1::BMPString <=> *value* is a String - -## OpenSSL::ASN1::BitString - -### Additional attributes -*unused_bits*: if the underlying BIT STRING's length is a multiple of 8 then -*unused_bits* is 0. Otherwise *unused_bits* indicates the number of bits that -are to be ignored in the final octet of the BitString's *value*. - -## OpenSSL::ASN1::ObjectId - -NOTE: While OpenSSL::ASN1::ObjectId.new will allocate a new ObjectId, it is -not typically allocated this way, but rather that are received from parsed -ASN1 encodings. - -### Additional attributes -* *sn*: the short name as defined in . -* *ln*: the long name as defined in . -* *oid*: the object identifier as a String, e.g. "1.2.3.4.5" -* *short_name*: alias for *sn*. -* *long_name*: alias for *ln*. - -## Examples -With the Exception of OpenSSL::ASN1::EndOfContent, each Primitive class -constructor takes at least one parameter, the *value*. - -### Creating EndOfContent - eoc = OpenSSL::ASN1::EndOfContent.new - -### Creating any other Primitive - prim = .new(value) # being one of the sub-classes except EndOfContent - prim_zero_tagged_implicit = .new(value, 0, :IMPLICIT) - prim_zero_tagged_explicit = .new(value, 0, :EXPLICIT) - - - -#Instance Methods -## initialize(value, tagnil, taggingnil, tag_classnil) [](#method-i-initialize) -:call-seq: - OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) => Primitive - -*value*: is mandatory. - -*tag*: optional, may be specified for tagged values. If no *tag* is specified, -the UNIVERSAL tag corresponding to the Primitive sub-class is used by default. - -*tagging*: may be used as an encoding hint to encode a value either explicitly -or implicitly, see ASN1 for possible values. - -*tag_class*: if *tag* and *tagging* are `nil` then this is set to `:UNIVERSAL` -by default. If either *tag* or *tagging* are set then `:CONTEXT_SPECIFIC` is -used as the default. For possible values please cf. ASN1. - -## Example - int = OpenSSL::ASN1::Integer.new(42) - zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT) - private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE) - -**@raise** [ASN1Error] - -## to_der() [](#method-i-to_der) -See ASN1Data#to_der for details. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/ASN1/TaggedASN1Data.md b/example/ruby/OpenSSL/ASN1/TaggedASN1Data.md deleted file mode 100644 index fba00a6..0000000 --- a/example/ruby/OpenSSL/ASN1/TaggedASN1Data.md +++ /dev/null @@ -1,36 +0,0 @@ -# Module: OpenSSL::ASN1::TaggedASN1Data - - - - -# Attributes -## tagging[RW] [](#attribute-i-tagging) -May be used as a hint for encoding a value either implicitly or explicitly by -setting it either to `:IMPLICIT` or to `:EXPLICIT`. *tagging* is not set when -a ASN.1 structure is parsed using OpenSSL::ASN1.decode. - - -#Instance Methods -## initialize(value, tagnil, taggingnil, tag_classnil) [](#method-i-initialize) -:call-seq: - OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) => Primitive - -*value*: is mandatory. - -*tag*: optional, may be specified for tagged values. If no *tag* is specified, -the UNIVERSAL tag corresponding to the Primitive sub-class is used by default. - -*tagging*: may be used as an encoding hint to encode a value either explicitly -or implicitly, see ASN1 for possible values. - -*tag_class*: if *tag* and *tagging* are `nil` then this is set to `:UNIVERSAL` -by default. If either *tag* or *tagging* are set then `:CONTEXT_SPECIFIC` is -used as the default. For possible values please cf. ASN1. - -## Example - int = OpenSSL::ASN1::Integer.new(42) - zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT) - private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE) - -**@raise** [ASN1Error] - diff --git a/example/ruby/OpenSSL/BN.md b/example/ruby/OpenSSL/BN.md deleted file mode 100644 index 5419563..0000000 --- a/example/ruby/OpenSSL/BN.md +++ /dev/null @@ -1,363 +0,0 @@ -# Class: OpenSSL::BN -**Inherits:** Object - -**Includes:** Comparable - - - - -# Class Methods -## generate_prime(*args ) [](#method-c-generate_prime) -Generates a random prime number of bit length *bits*. If *safe* is set to -`true`, generates a safe prime. If *add* is specified, generates a prime that -fulfills condition `p % add = rem`. - -### Parameters -* *bits* - integer -* *safe* - boolean -* *add* - BN -* *rem* - BN -**@overload** [] - -## rand() [](#method-c-rand) -zero one value_one - DON'T IMPL. set_word get_word -## rand_range(range ) [](#method-c-rand_range) -Generates a cryptographically strong pseudo-random number in the range -0...`range`. - -See also the man page BN_rand_range(3). -**@overload** [] - - -#Instance Methods -## %() [](#method-i-%) - -**@overload** [] - -## *() [](#method-i-*) - -**@overload** [] - -## **() [](#method-i-**) - -**@overload** [] - -## +() [](#method-i-+) - -**@overload** [] - -## +@() [](#method-i-+@) - -**@overload** [] - -## -() [](#method-i--) - -**@overload** [] - -## -@() [](#method-i--@) - -**@overload** [] - -## /() [](#method-i-/) - -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <<() [](#method-i-<<) - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## ==() [](#method-i-==) - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## >>() [](#method-i->>) - -**@overload** [] - -## abs() [](#method-i-abs) - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## bit_set?() [](#method-i-bit_set?) - -**@return** [Boolean] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## clear_bit!() [](#method-i-clear_bit!) - -**@overload** [] - -## cmp() [](#method-i-cmp) - -**@overload** [] - -## coerce(other) [](#method-i-coerce) - -## copy() [](#method-i-copy) - -## eql?(other) [](#method-i-eql?) -Returns `true` only if *obj* is a `OpenSSL::BN` with the same value as *bn*. -Contrast this with OpenSSL::BN#==, which performs type conversions. - -**@overload** [] - -## gcd() [](#method-i-gcd) - -**@overload** [] - -## get_flags(arg) [](#method-i-get_flags) -Returns the flags on the BN object. The argument is used as a bit mask. - -### Parameters -* *flags* - integer - -**@overload** [] - -## hash() [](#method-i-hash) -Returns a hash code for this object. - -See also Object#hash. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Construct a new OpenSSL BIGNUM object. - -If `bn` is an Integer or OpenSSL::BN, a new instance of OpenSSL::BN -representing the same value is returned. See also Integer#to_bn for the -short-hand. - -If a String is given, the content will be parsed according to `base`. - -`string` -: The string to be parsed. - -`base` -: The format. Must be one of the following: - * `0` - MPI format. See the man page BN_mpi2bn(3) for details. - * `2` - Variable-length and big-endian binary encoding of a positive - number. - * `10` - Decimal number representation, with a leading '-' for a - negative number. - * `16` - Hexadecimal number representation, with a leading '-' for a - negative number. - - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy() [](#method-i-initialize_copy) - -## lshift!() [](#method-i-lshift!) - -**@overload** [] - -## mask_bits!() [](#method-i-mask_bits!) - -## mod_add() [](#method-i-mod_add) - -**@overload** [] - -## mod_exp() [](#method-i-mod_exp) - -**@overload** [] - -## mod_inverse() [](#method-i-mod_inverse) - -**@overload** [] - -## mod_mul() [](#method-i-mod_mul) - -**@overload** [] - -## mod_sqr() [](#method-i-mod_sqr) - -**@overload** [] - -## mod_sqrt() [](#method-i-mod_sqrt) - -**@overload** [] - -## mod_sub() [](#method-i-mod_sub) - -**@overload** [] - -## negative?() [](#method-i-negative?) - -**@return** [Boolean] - -## num_bits() [](#method-i-num_bits) - -**@overload** [] - -## num_bytes() [](#method-i-num_bytes) - -**@overload** [] - -## odd?() [](#method-i-odd?) - -**@overload** [] - -**@return** [Boolean] - -## one?() [](#method-i-one?) - -**@overload** [] - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) - -## prime?(*args) [](#method-i-prime?) -Performs a Miller-Rabin probabilistic primality test for `bn`. - -**`checks` parameter is deprecated in version 3.0.** It has no effect. - -**@overload** [] - -**@overload** [] - -**@return** [Boolean] - -## prime_fasttest?(*args) [](#method-i-prime_fasttest?) -Performs a Miller-Rabin probabilistic primality test for `bn`. - -**Deprecated in version 3.0.** Use #prime? instead. - -`checks` and `trial_div` parameters no longer have any effect. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@return** [Boolean] - -## rshift!() [](#method-i-rshift!) - -**@overload** [] - -## set_bit!() [](#method-i-set_bit!) - -**@overload** [] - -## set_flags(arg) [](#method-i-set_flags) -Enables the flags on the BN object. Currently, the flags argument can contain -zero of OpenSSL::BN::CONSTTIME. - -**@overload** [] - -## sqr() [](#method-i-sqr) - -**@overload** [] - -## to_bn() [](#method-i-to_bn) - -## to_i() [](#method-i-to_i) - -**@overload** [] - -## to_s(*args) [](#method-i-to_s) -Returns the string representation of the bignum. - -BN.new can parse the encoded string to convert back into an OpenSSL::BN. - -`base` -: The format. Must be one of the following: - * `0` - MPI format. See the man page BN_bn2mpi(3) for details. - * `2` - Variable-length and big-endian binary encoding. The sign of the - bignum is ignored. - * `10` - Decimal number representation, with a leading '-' for a - negative bignum. - * `16` - Hexadecimal number representation, with a leading '-' for a - negative bignum. - - -**@overload** [] - -## ucmp() [](#method-i-ucmp) - -**@overload** [] - -## zero?() [](#method-i-zero?) - -**@overload** [] - -**@return** [Boolean] - diff --git a/example/ruby/OpenSSL/BNError.md b/example/ruby/OpenSSL/BNError.md deleted file mode 100644 index 6922ae1..0000000 --- a/example/ruby/OpenSSL/BNError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OpenSSL::BNError -**Inherits:** OpenSSL::OpenSSLError - - -Generic Error for all of OpenSSL::BN (big num) - - - diff --git a/example/ruby/OpenSSL/Buffering.md b/example/ruby/OpenSSL/Buffering.md deleted file mode 100644 index 47272c5..0000000 --- a/example/ruby/OpenSSL/Buffering.md +++ /dev/null @@ -1,2261 +0,0 @@ -# Module: OpenSSL::Buffering - -**Includes:** Enumerable - - -OpenSSL IO buffering mix-in module. - -This module allows an OpenSSL::SSL::SSLSocket to behave like an IO. - -You typically won't use this module directly, you can see it implemented in -OpenSSL::SSL::SSLSocket. - - -# Attributes -## sync[RW] [](#attribute-i-sync) -The "sync mode" of the SSLSocket. - -See IO#sync for full details. - - -#Instance Methods -## <<(s) [](#method-i-<<) -Writes *s* to the stream. *s* will be converted to a String using `.to_s` -method. - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## close() [](#method-i-close) -Closes the SSLSocket and flushes any unwritten data. - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(eol$/) [](#method-i-each) -Executes the block for every line in the stream where lines are separated by -*eol*. - -See also #gets - -## each_byte() [](#method-i-each_byte) -Calls the given block once for each byte in the stream. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eof?() [](#method-i-eof?) -Returns true if the stream is at file which means there is no more data to be -read. - -**@return** [Boolean] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flush() [](#method-i-flush) -Flushes buffered data to the SSLSocket. - -## getbyte() [](#method-i-getbyte) -call-seq: - ssl.getbyte => 81 - -Get the next 8bit byte from `ssl`. Returns `nil` on EOF - -## getc() [](#method-i-getc) -Reads one character from the stream. Returns nil if called at end of file. - -## gets(eol$/, limitnil, chomp:false) [](#method-i-gets) -Reads the next "line" from the stream. Lines are separated by *eol*. If -*limit* is provided the result will not be longer than the given number of -bytes. - -*eol* may be a String or Regexp. - -Unlike IO#gets the line read will not be assigned to +$_+. - -Unlike IO#gets the separator must be provided if a limit is provided. - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) -Creates an instance of OpenSSL's buffering IO module. - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## print(*args) [](#method-i-print) -Writes *args* to the stream. - -See IO#print for full details. - -## printf(s, *args) [](#method-i-printf) -Formats and writes to the stream converting parameters under control of the -format string. - -See Kernel#sprintf for format string details. - -## puts(*args) [](#method-i-puts) -Writes *args* to the stream along with a record separator. - -See IO#puts for full details. - -## read(sizenil, bufnil) [](#method-i-read) -Reads *size* bytes from the stream. If *buf* is provided it must reference a -string which will receive the data. - -See IO#read for full details. - -## read_nonblock(maxlen, bufnil, exception:true) [](#method-i-read_nonblock) -Reads at most *maxlen* bytes in the non-blocking manner. - -When no data can be read without blocking it raises OpenSSL::SSL::SSLError -extended by IO::WaitReadable or IO::WaitWritable. - -IO::WaitReadable means SSL needs to read internally so read_nonblock should be -called again when the underlying IO is readable. - -IO::WaitWritable means SSL needs to write internally so read_nonblock should -be called again after the underlying IO is writable. - -OpenSSL::Buffering#read_nonblock needs two rescue clause as follows: - - # emulates blocking read (readpartial). - begin - result = ssl.read_nonblock(maxlen) - rescue IO::WaitReadable - IO.select([io]) - retry - rescue IO::WaitWritable - IO.select(nil, [io]) - retry - end - -Note that one reason that read_nonblock writes to the underlying IO is when -the peer requests a new TLS/SSL handshake. See openssl the FAQ for more -details. http://www.openssl.org/support/faq.html - -By specifying a keyword argument *exception* to `false`, you can indicate that -read_nonblock should not raise an IO::Wait*able exception, but return the -symbol `:wait_writable` or `:wait_readable` instead. At EOF, it will return -`nil` instead of raising EOFError. - -## readbyte() [](#method-i-readbyte) -Get the next 8bit byte. Raises EOFError on EOF - -**@raise** [EOFError] - -## readchar() [](#method-i-readchar) -Reads a one-character string from the stream. Raises an EOFError at end of -file. - -**@raise** [EOFError] - -## readline(eol$/) [](#method-i-readline) -Reads a line from the stream which is separated by *eol*. - -Raises EOFError if at end of file. - -**@raise** [EOFError] - -## readlines(eol$/) [](#method-i-readlines) -Reads lines from the stream which are separated by *eol*. - -See also #gets - -## readpartial(maxlen, bufnil) [](#method-i-readpartial) -Reads at most *maxlen* bytes from the stream. If *buf* is provided it must -reference a string which will receive the data. - -See IO#readpartial for full details. - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## ungetc(c) [](#method-i-ungetc) -Pushes character *c* back onto the stream such that a subsequent buffered -character read will return it. - -Unlike IO#getc multiple bytes may be pushed back onto the stream. - -Has no effect on unbuffered reads (such as #sysread). - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## write(*s) [](#method-i-write) -Writes *s* to the stream. If the argument is not a String it will be -converted using `.to_s` method. Returns the number of bytes written. - -## write_nonblock(s, exception:true) [](#method-i-write_nonblock) -Writes *s* in the non-blocking manner. - -If there is buffered data, it is flushed first. This may block. - -write_nonblock returns number of bytes written to the SSL connection. - -When no data can be written without blocking it raises OpenSSL::SSL::SSLError -extended by IO::WaitReadable or IO::WaitWritable. - -IO::WaitReadable means SSL needs to read internally so write_nonblock should -be called again after the underlying IO is readable. - -IO::WaitWritable means SSL needs to write internally so write_nonblock should -be called again after underlying IO is writable. - -So OpenSSL::Buffering#write_nonblock needs two rescue clause as follows. - - # emulates blocking write. - begin - result = ssl.write_nonblock(str) - rescue IO::WaitReadable - IO.select([io]) - retry - rescue IO::WaitWritable - IO.select(nil, [io]) - retry - end - -Note that one reason that write_nonblock reads from the underlying IO is when -the peer requests a new TLS/SSL handshake. See the openssl FAQ for more -details. http://www.openssl.org/support/faq.html - -By specifying a keyword argument *exception* to `false`, you can indicate that -write_nonblock should not raise an IO::Wait*able exception, but return the -symbol `:wait_writable` or `:wait_readable` instead. - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/OpenSSL/Buffering/Buffer.md b/example/ruby/OpenSSL/Buffering/Buffer.md deleted file mode 100644 index 231fef4..0000000 --- a/example/ruby/OpenSSL/Buffering/Buffer.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: OpenSSL::Buffering::Buffer -**Inherits:** String - - -A buffer which will retain binary encoding. - - - -#Instance Methods -## <<(string) [](#method-i-<<) - -## initialize() [](#method-i-initialize) - -**@return** [Buffer] a new instance of Buffer - diff --git a/example/ruby/OpenSSL/Certs.md b/example/ruby/OpenSSL/Certs.md deleted file mode 100644 index 1dc26e1..0000000 --- a/example/ruby/OpenSSL/Certs.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: OpenSSL::Certs - -**Includes:** OpenSSL::TestUtils - - - - -# Class Methods -## ca_cert() [](#method-c-ca_cert) -## intermediate_cert(key , ca_cert ) [](#method-c-intermediate_cert) -## ts_cert_direct(key , ca_cert ) [](#method-c-ts_cert_direct) -## ts_cert_ee(key , intermediate , im_key ) [](#method-c-ts_cert_ee) - diff --git a/example/ruby/OpenSSL/Cipher.md b/example/ruby/OpenSSL/Cipher.md deleted file mode 100644 index ca7c6f2..0000000 --- a/example/ruby/OpenSSL/Cipher.md +++ /dev/null @@ -1,433 +0,0 @@ -# Class: OpenSSL::Cipher -**Inherits:** Object - - -Provides symmetric algorithms for encryption and decryption. The algorithms -that are available depend on the particular version of OpenSSL that is -installed. - -### Listing all supported algorithms - -A list of supported algorithms can be obtained by - - puts OpenSSL::Cipher.ciphers - -### Instantiating a Cipher - -There are several ways to create a Cipher instance. Generally, a Cipher -algorithm is categorized by its name, the key length in bits and the cipher -mode to be used. The most generic way to create a Cipher is the following - - cipher = OpenSSL::Cipher.new('--') - -That is, a string consisting of the hyphenated concatenation of the individual -components name, key length and mode. Either all uppercase or all lowercase -strings may be used, for example: - - cipher = OpenSSL::Cipher.new('aes-128-cbc') - -### Choosing either encryption or decryption mode - -Encryption and decryption are often very similar operations for symmetric -algorithms, this is reflected by not having to choose different classes for -either operation, both can be done using the same class. Still, after -obtaining a Cipher instance, we need to tell the instance what it is that we -intend to do with it, so we need to call either - - cipher.encrypt - -or - - cipher.decrypt - -on the Cipher instance. This should be the first call after creating the -instance, otherwise configuration that has already been set could get lost in -the process. - -### Choosing a key - -Symmetric encryption requires a key that is the same for the encrypting and -for the decrypting party and after initial key establishment should be kept as -private information. There are a lot of ways to create insecure keys, the most -notable is to simply take a password as the key without processing the -password further. A simple and secure way to create a key for a particular -Cipher is - - cipher = OpenSSL::Cipher.new('aes-256-cfb') - cipher.encrypt - key = cipher.random_key # also sets the generated key on the Cipher - -If you absolutely need to use passwords as encryption keys, you should use -Password-Based Key Derivation Function 2 (PBKDF2) by generating the key with -the help of the functionality provided by OpenSSL::PKCS5.pbkdf2_hmac_sha1 or -OpenSSL::PKCS5.pbkdf2_hmac. - -Although there is Cipher#pkcs5_keyivgen, its use is deprecated and it should -only be used in legacy applications because it does not use the newer PKCS#5 -v2 algorithms. - -### Choosing an IV - -The cipher modes CBC, CFB, OFB and CTR all need an "initialization vector", or -short, IV. ECB mode is the only mode that does not require an IV, but there is -almost no legitimate use case for this mode because of the fact that it does -not sufficiently hide plaintext patterns. Therefore - -**You should never use ECB mode unless you are absolutely sure that you -absolutely need it** - -Because of this, you will end up with a mode that explicitly requires an IV in -any case. Although the IV can be seen as public information, i.e. it may be -transmitted in public once generated, it should still stay unpredictable to -prevent certain kinds of attacks. Therefore, ideally - -**Always create a secure random IV for every encryption of your Cipher** - -A new, random IV should be created for every encryption of data. Think of the -IV as a nonce (number used once) - it's public but random and unpredictable. A -secure random IV can be created as follows - - cipher = ... - cipher.encrypt - key = cipher.random_key - iv = cipher.random_iv # also sets the generated IV on the Cipher - -Although the key is generally a random value, too, it is a bad choice as an -IV. There are elaborate ways how an attacker can take advantage of such an IV. -As a general rule of thumb, exposing the key directly or indirectly should be -avoided at all cost and exceptions only be made with good reason. - -### Calling Cipher#final - -ECB (which should not be used) and CBC are both block-based modes. This means -that unlike for the other streaming-based modes, they operate on fixed-size -blocks of data, and therefore they require a "finalization" step to produce or -correctly decrypt the last block of data by appropriately handling some form -of padding. Therefore it is essential to add the output of -OpenSSL::Cipher#final to your encryption/decryption buffer or you will end up -with decryption errors or truncated data. - -Although this is not really necessary for streaming-mode ciphers, it is still -recommended to apply the same pattern of adding the output of Cipher#final -there as well - it also enables you to switch between modes more easily in the -future. - -### Encrypting and decrypting some data - - data = "Very, very confidential data" - - cipher = OpenSSL::Cipher.new('aes-128-cbc') - cipher.encrypt - key = cipher.random_key - iv = cipher.random_iv - - encrypted = cipher.update(data) + cipher.final - ... - decipher = OpenSSL::Cipher.new('aes-128-cbc') - decipher.decrypt - decipher.key = key - decipher.iv = iv - - plain = decipher.update(encrypted) + decipher.final - - puts data == plain #=> true - -### Authenticated Encryption and Associated Data (AEAD) - -If the OpenSSL version used supports it, an Authenticated Encryption mode -(such as GCM or CCM) should always be preferred over any unauthenticated mode. -Currently, OpenSSL supports AE only in combination with Associated Data (AEAD) -where additional associated data is included in the encryption process to -compute a tag at the end of the encryption. This tag will also be used in the -decryption process and by verifying its validity, the authenticity of a given -ciphertext is established. - -This is superior to unauthenticated modes in that it allows to detect if -somebody effectively changed the ciphertext after it had been encrypted. This -prevents malicious modifications of the ciphertext that could otherwise be -exploited to modify ciphertexts in ways beneficial to potential attackers. - -An associated data is used where there is additional information, such as -headers or some metadata, that must be also authenticated but not necessarily -need to be encrypted. If no associated data is needed for encryption and later -decryption, the OpenSSL library still requires a value to be set - "" may be -used in case none is available. - -An example using the GCM (Galois/Counter Mode). You have 16 bytes *key*, 12 -bytes (96 bits) *nonce* and the associated data *auth_data*. Be sure not to -reuse the *key* and *nonce* pair. Reusing an nonce ruins the security -guarantees of GCM mode. - - cipher = OpenSSL::Cipher.new('aes-128-gcm').encrypt - cipher.key = key - cipher.iv = nonce - cipher.auth_data = auth_data - - encrypted = cipher.update(data) + cipher.final - tag = cipher.auth_tag # produces 16 bytes tag by default - -Now you are the receiver. You know the *key* and have received *nonce*, -*auth_data*, *encrypted* and *tag* through an untrusted network. Note that GCM -accepts an arbitrary length tag between 1 and 16 bytes. You may additionally -need to check that the received tag has the correct length, or you allow -attackers to forge a valid single byte tag for the tampered ciphertext with a -probability of 1/256. - - raise "tag is truncated!" unless tag.bytesize == 16 - decipher = OpenSSL::Cipher.new('aes-128-gcm').decrypt - decipher.key = key - decipher.iv = nonce - decipher.auth_tag = tag - decipher.auth_data = auth_data - - decrypted = decipher.update(encrypted) + decipher.final - - puts data == decrypted #=> true - - -# Class Methods -## ciphers() [](#method-c-ciphers) -Returns the names of all available ciphers in an array. -**@overload** [] - - -#Instance Methods -## auth_data=(data) [](#method-i-auth_data=) -Sets the cipher's additional authenticated data. This field must be set when -using AEAD cipher modes such as GCM or CCM. If no associated data shall be -used, this method must **still** be called with a value of "". The contents of -this field should be non-sensitive data which will be added to the ciphertext -to generate the authentication tag which validates the contents of the -ciphertext. - -The AAD must be set prior to encryption or decryption. In encryption mode, it -must be set after calling Cipher#encrypt and setting Cipher#key= and -Cipher#iv=. When decrypting, the authenticated data must be set after key, iv -and especially **after** the authentication tag has been set. I.e. set it only -after calling Cipher#decrypt, Cipher#key=, Cipher#iv= and Cipher#auth_tag= -first. - -**@overload** [] - -## auth_tag(*args) [](#method-i-auth_tag) -Gets the authentication tag generated by Authenticated Encryption Cipher modes -(GCM for example). This tag may be stored along with the ciphertext, then set -on the decryption cipher to authenticate the contents of the ciphertext -against changes. If the optional integer parameter *tag_len* is given, the -returned tag will be *tag_len* bytes long. If the parameter is omitted, the -default length of 16 bytes or the length previously set by #auth_tag_len= will -be used. For maximum security, the longest possible should be chosen. - -The tag may only be retrieved after calling Cipher#final. - -**@overload** [] - -## auth_tag=(vtag) [](#method-i-auth_tag=) -Sets the authentication tag to verify the integrity of the ciphertext. This -can be called only when the cipher supports AE. The tag must be set after -calling Cipher#decrypt, Cipher#key= and Cipher#iv=, but before calling -Cipher#final. After all decryption is performed, the tag is verified -automatically in the call to Cipher#final. - -For OCB mode, the tag length must be supplied with #auth_tag_len= beforehand. - -**@overload** [] - -## auth_tag_len=(vlen) [](#method-i-auth_tag_len=) -Sets the length of the authentication tag to be generated or to be given for -AEAD ciphers that requires it as in input parameter. Note that not all AEAD -ciphers support this method. - -In OCB mode, the length must be supplied both when encrypting and when -decrypting, and must be before specifying an IV. - -**@overload** [] - -## authenticated?() [](#method-i-authenticated?) -Indicated whether this Cipher instance uses an Authenticated Encryption mode. - -**@overload** [] - -**@return** [Boolean] - -## block_size() [](#method-i-block_size) -Returns the size in bytes of the blocks on which this Cipher operates on. - -**@overload** [] - -## ccm_data_len=(data_len) [](#method-i-ccm_data_len=) -Sets the length of the plaintext / ciphertext message that will be processed -in CCM mode. Make sure to call this method after #key= and #iv= have been set, -and before #auth_data=. - -Only call this method after calling Cipher#encrypt or Cipher#decrypt. - -**@overload** [] - -## decrypt(*args) [](#method-i-decrypt) -Initializes the Cipher for decryption. - -Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the -following methods: - - #key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen -: -Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0). - -**@overload** [] - -## encrypt(*args) [](#method-i-encrypt) -Initializes the Cipher for encryption. - -Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the -following methods: - - #key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen -: -Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1). - -**@overload** [] - -## final() [](#method-i-final) -Returns the remaining data held in the cipher object. Further calls to -Cipher#update or Cipher#final will return garbage. This call should always be -made as the last call of an encryption or decryption operation, after having -fed the entire plaintext or ciphertext to the Cipher instance. - -If an authenticated cipher was used, a CipherError is raised if the tag could -not be authenticated successfully. Only call this method after setting the -authentication tag and passing the entire contents of the ciphertext into the -cipher. - -**@overload** [] - -## initialize(str) [](#method-i-initialize) -The string must contain a valid cipher name like "aes-256-cbc". - -A list of cipher names is available by calling OpenSSL::Cipher.ciphers. - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## iv=(iv) [](#method-i-iv=) -Sets the cipher IV. Please note that since you should never be using ECB mode, -an IV is always explicitly required and should be set prior to encryption. The -IV itself can be safely transmitted in public, but it should be unpredictable -to prevent certain kinds of attacks. You may use Cipher#random_iv to create a -secure random IV. - -Only call this method after calling Cipher#encrypt or Cipher#decrypt. - -**@overload** [] - -## iv_len() [](#method-i-iv_len) -Returns the expected length in bytes for an IV for this Cipher. - -**@overload** [] - -## iv_len=(iv_length) [](#method-i-iv_len=) -Sets the IV/nonce length of the Cipher. Normally block ciphers don't allow -changing the IV length, but some make use of IV for 'nonce'. You may need this -for interoperability with other applications. - -**@overload** [] - -## key=(key) [](#method-i-key=) -Sets the cipher key. To generate a key, you should either use a secure random -byte string or, if the key is to be derived from a password, you should rely -on PBKDF2 functionality provided by OpenSSL::PKCS5. To generate a secure -random-based key, Cipher#random_key may be used. - -Only call this method after calling Cipher#encrypt or Cipher#decrypt. - -**@overload** [] - -## key_len() [](#method-i-key_len) -Returns the key length in bytes of the Cipher. - -**@overload** [] - -## key_len=(key_length) [](#method-i-key_len=) -Sets the key length of the cipher. If the cipher is a fixed length cipher -then attempting to set the key length to any value other than the fixed value -is an error. - -Under normal circumstances you do not need to call this method (and probably -shouldn't). - -See EVP_CIPHER_CTX_set_key_length for further information. - -**@overload** [] - -## name() [](#method-i-name) -Returns the short name of the cipher which may differ slightly from the -original name provided. - -**@overload** [] - -## padding=(padding) [](#method-i-padding=) -Enables or disables padding. By default encryption operations are padded using -standard block padding and the padding is checked and removed when decrypting. -If the pad parameter is zero then no padding is performed, the total amount of -data encrypted or decrypted must then be a multiple of the block size or an -error will occur. - -See EVP_CIPHER_CTX_set_padding for further information. - -**@overload** [] - -## pkcs5_keyivgen(*args) [](#method-i-pkcs5_keyivgen) -Generates and sets the key/IV based on a password. - -**WARNING**: This method is only PKCS5 v1.5 compliant when using RC2, RC4-40, -or DES with MD5 or SHA1. Using anything else (like AES) will generate the -key/iv using an OpenSSL specific method. This method is deprecated and should -no longer be used. Use a PKCS5 v2 key generation method from OpenSSL::PKCS5 -instead. - -### Parameters -* *salt* must be an 8 byte string if provided. -* *iterations* is an integer with a default of 2048. -* *digest* is a Digest object that defaults to 'MD5' - -A minimum of 1000 iterations is recommended. - -**@overload** [] - -## random_iv() [](#method-i-random_iv) -call-seq: - cipher.random_iv -> iv - -Generate a random IV with OpenSSL::Random.random_bytes and sets it to the -cipher, and returns it. - -You must call #encrypt or #decrypt before calling this method. - -## random_key() [](#method-i-random_key) -call-seq: - cipher.random_key -> key - -Generate a random key with OpenSSL::Random.random_bytes and sets it to the -cipher, and returns it. - -You must call #encrypt or #decrypt before calling this method. - -## reset() [](#method-i-reset) -Fully resets the internal state of the Cipher. By using this, the same Cipher -instance may be used several times for encryption or decryption tasks. - -Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1). - -**@overload** [] - -## update(*args) [](#method-i-update) -Encrypts data in a streaming fashion. Hand consecutive blocks of data to the -#update method in order to encrypt it. Returns the encrypted data chunk. When -done, the output of Cipher#final should be additionally added to the result. - -If *buffer* is given, the encryption/decryption result will be written to it. -*buffer* will be resized automatically. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/Cipher/Cipher.md b/example/ruby/OpenSSL/Cipher/Cipher.md deleted file mode 100644 index c5e4350..0000000 --- a/example/ruby/OpenSSL/Cipher/Cipher.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: OpenSSL::Cipher::Cipher -**Inherits:** OpenSSL::Cipher - - -Deprecated. - -This class is only provided for backwards compatibility. Use OpenSSL::Cipher. - - - diff --git a/example/ruby/OpenSSL/Cipher/CipherError.md b/example/ruby/OpenSSL/Cipher/CipherError.md deleted file mode 100644 index 3c71f0a..0000000 --- a/example/ruby/OpenSSL/Cipher/CipherError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::Cipher::CipherError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/Config.md b/example/ruby/OpenSSL/Config.md deleted file mode 100644 index 79a2a22..0000000 --- a/example/ruby/OpenSSL/Config.md +++ /dev/null @@ -1,2149 +0,0 @@ -# Class: OpenSSL::Config -**Inherits:** Object - -**Includes:** Enumerable - - -Configuration for the openssl library. - -Many system's installation of openssl library will depend on your system -configuration. See the value of OpenSSL::Config::DEFAULT_CONFIG_FILE for the -location of the file for your host. - -See also http://www.openssl.org/docs/apps/config.html - - -# Class Methods -## parse(str ) [](#method-c-parse) -Parses a given *string* as a blob that contains configuration for OpenSSL. -**@overload** [] - -## parse_config(io ) [](#method-c-parse_config) -Parses the configuration data read from *io* and returns the whole content as -a Hash. -**@overload** [] - - -#Instance Methods -## [](section) [](#method-i-[]) -Gets all key-value pairs in a specific *section* from the current -configuration. - -Given the following configurating file being loaded: - - config = OpenSSL::Config.load('foo.cnf') - #=> # - puts config.to_s - #=> [ default ] - # foo=bar - -You can get a hash of the specific section like so: - - config['default'] - #=> {"foo"=>"bar"} - -**@overload** [] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## get_value(section, key) [](#method-i-get_value) -Gets the value of *key* from the given *section*. - -Given the following configurating file being loaded: - - config = OpenSSL::Config.load('foo.cnf') - #=> # - puts config.to_s - #=> [ default ] - # foo=bar - -You can get a specific value from the config if you know the *section* and -*key* like so: - - config.get_value('default','foo') - #=> "bar" - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates an instance of OpenSSL::Config from the content of the file specified -by *filename*. - -This can be used in contexts like OpenSSL::X509::ExtensionFactory.config= - -This can raise IO exceptions based on the access, or availability of the file. -A ConfigError exception may be raised depending on the validity of the data -being configured. - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -String representation of this configuration object, including the class name -and its sections. - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## sections() [](#method-i-sections) - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_s() [](#method-i-to_s) - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/OpenSSL/ConfigError.md b/example/ruby/OpenSSL/ConfigError.md deleted file mode 100644 index 9db2d1e..0000000 --- a/example/ruby/OpenSSL/ConfigError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: OpenSSL::ConfigError -**Inherits:** OpenSSL::OpenSSLError - - -General error for openssl library configuration files. Including formatting, -parsing errors, etc. - - - diff --git a/example/ruby/OpenSSL/Digest.md b/example/ruby/OpenSSL/Digest.md deleted file mode 100644 index 484aaf6..0000000 --- a/example/ruby/OpenSSL/Digest.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: OpenSSL::Digest -**Inherits:** Object - - -OpenSSL::Digest allows you to compute message digests (sometimes -interchangeably called "hashes") of arbitrary data that are cryptographically -secure, i.e. a Digest implements a secure one-way function. - -One-way functions offer some useful properties. E.g. given two distinct inputs -the probability that both yield the same output is highly unlikely. Combined -with the fact that every message digest algorithm has a fixed-length output of -just a few bytes, digests are often used to create unique identifiers for -arbitrary data. A common example is the creation of a unique id for binary -documents that are stored in a database. - -Another useful characteristic of one-way functions (and thus the name) is that -given a digest there is no indication about the original data that produced -it, i.e. the only way to identify the original input is to "brute-force" -through every possible combination of inputs. - -These characteristics make one-way functions also ideal companions for public -key signature algorithms: instead of signing an entire document, first a hash -of the document is produced with a considerably faster message digest -algorithm and only the few bytes of its output need to be signed using the -slower public key algorithm. To validate the integrity of a signed document, -it suffices to re-compute the hash and verify that it is equal to that in the -signature. - -You can get a list of all digest algorithms supported on your system by -running this command in your terminal: - - openssl list -digest-algorithms - -Among the OpenSSL 1.1.1 supported message digest algorithms are: -* SHA224, SHA256, SHA384, SHA512, SHA512-224 and SHA512-256 -* SHA3-224, SHA3-256, SHA3-384 and SHA3-512 -* BLAKE2s256 and BLAKE2b512 - -Each of these algorithms can be instantiated using the name: - - digest = OpenSSL::Digest.new('SHA256') - -"Breaking" a message digest algorithm means defying its one-way function -characteristics, i.e. producing a collision or finding a way to get to the -original data by means that are more efficient than brute-forcing etc. Most of -the supported digest algorithms can be considered broken in this sense, even -the very popular MD5 and SHA1 algorithms. Should security be your highest -concern, then you should probably rely on SHA224, SHA256, SHA384 or SHA512. - -### Hashing a file - - data = File.binread('document') - sha256 = OpenSSL::Digest.new('SHA256') - digest = sha256.digest(data) - -### Hashing several pieces of data at once - - data1 = File.binread('file1') - data2 = File.binread('file2') - data3 = File.binread('file3') - sha256 = OpenSSL::Digest.new('SHA256') - sha256 << data1 - sha256 << data2 - sha256 << data3 - digest = sha256.digest - -### Reuse a Digest instance - - data1 = File.binread('file1') - sha256 = OpenSSL::Digest.new('SHA256') - digest1 = sha256.digest(data1) - - data2 = File.binread('file2') - sha256.reset - digest2 = sha256.digest(data2) - - -# Class Methods -## digest(name , data ) [](#method-c-digest) -Return the hash value computed with *name* Digest. *name* is either the long -name or short name of a supported digest algorithm. - -### Example - - OpenSSL::Digest.digest("SHA256", "abc") - diff --git a/example/ruby/OpenSSL/Digest/Digest.md b/example/ruby/OpenSSL/Digest/Digest.md deleted file mode 100644 index 0d647b2..0000000 --- a/example/ruby/OpenSSL/Digest/Digest.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: OpenSSL::Digest::Digest -**Inherits:** OpenSSL::Digest - - -Deprecated. - -This class is only provided for backwards compatibility. Use OpenSSL::Digest -instead. - - - diff --git a/example/ruby/OpenSSL/Digest/DigestError.md b/example/ruby/OpenSSL/Digest/DigestError.md deleted file mode 100644 index 85810e8..0000000 --- a/example/ruby/OpenSSL/Digest/DigestError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: OpenSSL::Digest::DigestError -**Inherits:** Object - - -Generic Exception class that is raised if an error occurs during a Digest -operation. - - - diff --git a/example/ruby/OpenSSL/Engine.md b/example/ruby/OpenSSL/Engine.md deleted file mode 100644 index c0c821b..0000000 --- a/example/ruby/OpenSSL/Engine.md +++ /dev/null @@ -1,146 +0,0 @@ -# Class: OpenSSL::Engine -**Inherits:** Object - - -This class is the access to openssl's ENGINE cryptographic module -implementation. - -See also, https://www.openssl.org/docs/crypto/engine.html - - -# Class Methods -## by_id(id ) [](#method-c-by_id) -Fetches the engine as specified by the *id* String. - - OpenSSL::Engine.by_id("openssl") - => # - -See OpenSSL::Engine.engines for the currently loaded engines. -**@overload** [] - -## cleanup() [](#method-c-cleanup) -It is only necessary to run cleanup when engines are loaded via -OpenSSL::Engine.load. However, running cleanup before exit is recommended. - -Note that this is needed and works only in OpenSSL < 1.1.0. -**@overload** [] - -## engines() [](#method-c-engines) -Returns an array of currently loaded engines. -**@overload** [] - -## load(*args ) [](#method-c-load) -This method loads engines. If *name* is nil, then all builtin engines are -loaded. Otherwise, the given *name*, as a String, is loaded if available to -your runtime, and returns true. If *name* is not found, then nil is returned. -**@overload** [] - - -#Instance Methods -## cipher(name) [](#method-i-cipher) -Returns a new instance of OpenSSL::Cipher by *name*, if it is available in -this engine. - -An EngineError will be raised if the cipher is unavailable. - - e = OpenSSL::Engine.by_id("openssl") - => # - e.cipher("RC4") - => # - -**@overload** [] - -## cmds() [](#method-i-cmds) -Returns an array of command definitions for the current engine - -**@overload** [] - -## ctrl_cmd(*args) [](#method-i-ctrl_cmd) -Sends the given *command* to this engine. - -Raises an EngineError if the command fails. - -**@overload** [] - -## digest(name) [](#method-i-digest) -Returns a new instance of OpenSSL::Digest by *name*. - -Will raise an EngineError if the digest is unavailable. - - e = OpenSSL::Engine.by_id("openssl") - -#=> # - e.digest("SHA1") - -#=> # - e.digest("zomg") - -#=> OpenSSL::Engine::EngineError: no such digest `zomg' - -**@overload** [] - -## finish() [](#method-i-finish) -Releases all internal structural references for this engine. - -May raise an EngineError if the engine is unavailable - -**@overload** [] - -## id() [](#method-i-id) -Gets the id for this engine. - - OpenSSL::Engine.load - OpenSSL::Engine.engines #=> [#, ...] - OpenSSL::Engine.engines.first.id - -#=> "rsax" - -**@overload** [] - -## inspect() [](#method-i-inspect) -Pretty prints this engine. - -**@overload** [] - -## load_private_key(*args) [](#method-i-load_private_key) -Loads the given private key identified by *id* and *data*. - -An EngineError is raised of the OpenSSL::PKey is unavailable. - -**@overload** [] - -## load_public_key(*args) [](#method-i-load_public_key) -Loads the given public key identified by *id* and *data*. - -An EngineError is raised of the OpenSSL::PKey is unavailable. - -**@overload** [] - -## name() [](#method-i-name) -Get the descriptive name for this engine. - - OpenSSL::Engine.load - OpenSSL::Engine.engines #=> [#, ...] - OpenSSL::Engine.engines.first.name - -#=> "RSAX engine support" - -**@overload** [] - -## set_default(flag) [](#method-i-set_default) -Set the defaults for this engine with the given *flag*. - -These flags are used to control combinations of algorithm methods. - -*flag* can be one of the following, other flags are available depending on -your OS. - -All flags -: 0xFFFF - -[No flags] 0x0000 - -See also - -**@overload** [] - diff --git a/example/ruby/OpenSSL/Engine/EngineError.md b/example/ruby/OpenSSL/Engine/EngineError.md deleted file mode 100644 index 56f77a9..0000000 --- a/example/ruby/OpenSSL/Engine/EngineError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OpenSSL::Engine::EngineError -**Inherits:** OpenSSL::OpenSSLError - - -This is the generic exception for OpenSSL::Engine related errors - - - diff --git a/example/ruby/OpenSSL/HMAC.md b/example/ruby/OpenSSL/HMAC.md deleted file mode 100644 index 7930c2b..0000000 --- a/example/ruby/OpenSSL/HMAC.md +++ /dev/null @@ -1,160 +0,0 @@ -# Class: OpenSSL::HMAC -**Inherits:** Object - - -OpenSSL::HMAC allows computing Hash-based Message Authentication Code (HMAC). -It is a type of message authentication code (MAC) involving a hash function in -combination with a key. HMAC can be used to verify the integrity of a message -as well as the authenticity. - -OpenSSL::HMAC has a similar interface to OpenSSL::Digest. - -### HMAC-SHA256 using one-shot interface - - key = "key" - data = "message-to-be-authenticated" - mac = OpenSSL::HMAC.hexdigest("SHA256", key, data) - #=> "cddb0db23f469c8bf072b21fd837149bd6ace9ab771cceef14c9e517cc93282e" - -### HMAC-SHA256 using incremental interface - - data1 = File.binread("file1") - data2 = File.binread("file2") - key = "key" - hmac = OpenSSL::HMAC.new(key, 'SHA256') - hmac << data1 - hmac << data2 - mac = hmac.digest - - -# Class Methods -## base64digest(digest , key , data ) [](#method-c-base64digest) -:call-seq: - HMAC.base64digest(digest, key, data) -> aString - -Returns the authentication code as a Base64-encoded string. The *digest* -parameter specifies the digest algorithm to use. This may be a String -representing the algorithm name or an instance of OpenSSL::Digest. - -### Example - key = 'key' - data = 'The quick brown fox jumps over the lazy dog' - - hmac = OpenSSL::HMAC.base64digest('SHA1', key, data) - #=> "3nybhbi3iqa8ino29wqQcBydtNk=" -## digest(digest , key , data ) [](#method-c-digest) -:call-seq: - HMAC.digest(digest, key, data) -> aString - -Returns the authentication code as a binary string. The *digest* parameter -specifies the digest algorithm to use. This may be a String representing the -algorithm name or an instance of OpenSSL::Digest. - -### Example - key = 'key' - data = 'The quick brown fox jumps over the lazy dog' - - hmac = OpenSSL::HMAC.digest('SHA1', key, data) - #=> "\xDE|\x9B\x85\xB8\xB7\x8A\xA6\xBC\x8Az6\xF7\n\x90p\x1C\x9D\xB4\xD9" -## hexdigest(digest , key , data ) [](#method-c-hexdigest) -:call-seq: - HMAC.hexdigest(digest, key, data) -> aString - -Returns the authentication code as a hex-encoded string. The *digest* -parameter specifies the digest algorithm to use. This may be a String -representing the algorithm name or an instance of OpenSSL::Digest. - -### Example - key = 'key' - data = 'The quick brown fox jumps over the lazy dog' - - hmac = OpenSSL::HMAC.hexdigest('SHA1', key, data) - #=> "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9" - -#Instance Methods -## ==(other) [](#method-i-==) -Securely compare with another HMAC instance in constant time. - -## base64digest() [](#method-i-base64digest) -:call-seq: - hmac.base64digest -> string - -Returns the authentication code an a Base64-encoded string. - -## digest() [](#method-i-digest) -Returns the authentication code an instance represents as a binary string. - -### Example -instance = OpenSSL::HMAC.new('key', 'SHA1') #=> -f42bb0eeb018ebbd4597ae7213711ec60760843f instance.digest #=> -"xF4+xB0xEExB0x18xEBxBDEx97xAErx13qx1ExC6a`x84?" - -**@overload** [] - -## hexdigest() [](#method-i-hexdigest) -Returns the authentication code an instance represents as a hex-encoded -string. - -**@overload** [] - -## initialize(key, digest) [](#method-i-initialize) -Returns an instance of OpenSSL::HMAC set with the key and digest algorithm to -be used. The instance represents the initial state of the message -authentication code before any data has been processed. To process data with -it, use the instance method #update with your data as an argument. - -### Example - -key = 'key' instance = OpenSSL::HMAC.new(key, 'SHA1') #=> -f42bb0eeb018ebbd4597ae7213711ec60760843f instance.class #=> OpenSSL::HMAC - -### A note about comparisons - -Two instances can be securely compared with #== in constant time: - -other_instance = OpenSSL::HMAC.new('key', 'SHA1') #=> -f42bb0eeb018ebbd4597ae7213711ec60760843f instance == other_instance #=> true - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## inspect() [](#method-i-inspect) -Returns the authentication code an instance represents as a hex-encoded -string. - -**@overload** [] - -## reset() [](#method-i-reset) -Returns *hmac* as it was when it was first initialized, with all processed -data cleared from it. - -### Example - -data = "The quick brown fox jumps over the lazy dog" instance = -OpenSSL::HMAC.new('key', 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f - -instance.update(data) #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 -instance.reset #=> f42bb0eeb018ebbd4597ae7213711ec60760843f - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns the authentication code an instance represents as a hex-encoded -string. - -**@overload** [] - -## update(data) [](#method-i-update) -Returns *hmac* updated with the message to be authenticated. Can be called -repeatedly with chunks of the message. - -### Example - -first_chunk = 'The quick brown fox jumps ' second_chunk = 'over the lazy dog' - -instance.update(first_chunk) #=> 5b9a8038a65d571076d97fe783989e52278a492a -instance.update(second_chunk) #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 - -**@overload** [] - diff --git a/example/ruby/OpenSSL/HMACError.md b/example/ruby/OpenSSL/HMACError.md deleted file mode 100644 index 3d4938b..0000000 --- a/example/ruby/OpenSSL/HMACError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::HMACError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/KDF.md b/example/ruby/OpenSSL/KDF.md deleted file mode 100644 index 55d7e5c..0000000 --- a/example/ruby/OpenSSL/KDF.md +++ /dev/null @@ -1,155 +0,0 @@ -# Module: OpenSSL::KDF - - -Provides functionality of various KDFs (key derivation function). - -KDF is typically used for securely deriving arbitrary length symmetric keys to -be used with an OpenSSL::Cipher from passwords. Another use case is for -storing passwords: Due to the ability to tweak the effort of computation by -increasing the iteration count, computation can be slowed down artificially in -order to render possible attacks infeasible. - -Currently, OpenSSL::KDF provides implementations for the following KDF: - -* PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination - with HMAC -* scrypt -* HKDF - -## Examples -### Generating a 128 bit key for a Cipher (e.g. AES) - pass = "secret" - salt = OpenSSL::Random.random_bytes(16) - iter = 20_000 - key_len = 16 - key = OpenSSL::KDF.pbkdf2_hmac(pass, salt: salt, iterations: iter, - length: key_len, hash: "sha1") - -### Storing Passwords - pass = "secret" - # store this with the generated value - salt = OpenSSL::Random.random_bytes(16) - iter = 20_000 - hash = OpenSSL::Digest.new('SHA256') - len = hash.digest_length - # the final value to be stored - value = OpenSSL::KDF.pbkdf2_hmac(pass, salt: salt, iterations: iter, - length: len, hash: hash) - -## Important Note on Checking Passwords -When comparing passwords provided by the user with previously stored values, a -common mistake made is comparing the two values using "==". Typically, "==" -short-circuits on evaluation, and is therefore vulnerable to timing attacks. -The proper way is to use a method that always takes the same amount of time -when comparing two values, thus not leaking any information to potential -attackers. To do this, use `OpenSSL.fixed_length_secure_compare`. - - -# Class Methods -## hkdf(*args ) [](#method-c-hkdf) -HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as specified in -[RFC 5869](https://www.rfc-editor.org/rfc/rfc5869). - -New in OpenSSL 1.1.0. - -### Parameters -*ikm* -: The input keying material. - -*salt* -: The salt. - -*info* -: The context and application specific information. - -*length* -: The output length in octets. Must be <= `255 * HashLen`, where HashLen is - the length of the hash function output in octets. - -*hash* -: The hash function. - - -### Example - # The values from https://www.rfc-editor.org/rfc/rfc5869#appendix-A.1 - ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*") - salt = ["000102030405060708090a0b0c"].pack("H*") - info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*") - p OpenSSL::KDF.hkdf(ikm, salt: salt, info: info, length: 42, hash: "SHA256").unpack1("H*") - # => "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865" -**@overload** [] - -## pbkdf2_hmac(*args ) [](#method-c-pbkdf2_hmac) -PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination with -HMAC. Takes *pass*, *salt* and *iterations*, and then derives a key of -*length* bytes. - -For more information about PBKDF2, see RFC 2898 Section 5.2 -(https://www.rfc-editor.org/rfc/rfc2898#section-5.2). - -### Parameters -pass -: The password. - -salt -: The salt. Salts prevent attacks based on dictionaries of common passwords - and attacks based on rainbow tables. It is a public value that can be - safely stored along with the password (e.g. if the derived value is used - for password storage). - -iterations -: The iteration count. This provides the ability to tune the algorithm. It - is better to use the highest count possible for the maximum resistance to - brute-force attacks. - -length -: The desired length of the derived key in octets. - -hash -: The hash algorithm used with HMAC for the PRF. May be a String - representing the algorithm name, or an instance of OpenSSL::Digest. - -**@overload** [] - -## scrypt(*args ) [](#method-c-scrypt) -Derives a key from *pass* using given parameters with the scrypt -password-based key derivation function. The result can be used for password -storage. - -scrypt is designed to be memory-hard and more secure against brute-force -attacks using custom hardwares than alternative KDFs such as PBKDF2 or bcrypt. - -The keyword arguments *N*, *r* and *p* can be used to tune scrypt. RFC 7914 -(published on 2016-08, https://www.rfc-editor.org/rfc/rfc7914#section-2) -states that using values r=8 and p=1 appears to yield good results. - -See RFC 7914 (https://www.rfc-editor.org/rfc/rfc7914) for more information. - -### Parameters -pass -: Passphrase. - -salt -: Salt. - -N -: CPU/memory cost parameter. This must be a power of 2. - -r -: Block size parameter. - -p -: Parallelization parameter. - -length -: Length in octets of the derived key. - - -### Example - pass = "password" - salt = SecureRandom.random_bytes(16) - dk = OpenSSL::KDF.scrypt(pass, salt: salt, N: 2**14, r: 8, p: 1, length: 32) - p dk #=> "\xDA\xE4\xE2...\x7F\xA1\x01T" -**@overload** [] - - diff --git a/example/ruby/OpenSSL/KDF/KDFError.md b/example/ruby/OpenSSL/KDF/KDFError.md deleted file mode 100644 index 678c45f..0000000 --- a/example/ruby/OpenSSL/KDF/KDFError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::KDF::KDFError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/Marshal.md b/example/ruby/OpenSSL/Marshal.md deleted file mode 100644 index 877eedc..0000000 --- a/example/ruby/OpenSSL/Marshal.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: OpenSSL::Marshal - - - - -# Class Methods -## included(base ) [](#method-c-included) -**@private** [] - - -#Instance Methods -## _dump(_level) [](#method-i-_dump) - diff --git a/example/ruby/OpenSSL/Marshal/ClassMethods.md b/example/ruby/OpenSSL/Marshal/ClassMethods.md deleted file mode 100644 index 324dc8e..0000000 --- a/example/ruby/OpenSSL/Marshal/ClassMethods.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: OpenSSL::Marshal::ClassMethods - - - - - -#Instance Methods -## _load(string) [](#method-i-_load) - diff --git a/example/ruby/OpenSSL/Netscape.md b/example/ruby/OpenSSL/Netscape.md deleted file mode 100644 index 69a4e61..0000000 --- a/example/ruby/OpenSSL/Netscape.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: OpenSSL::Netscape - - -OpenSSL::Netscape is a namespace for SPKI (Simple Public Key Infrastructure) -which implements Signed Public Key and Challenge. See [RFC -2692](https://www.rfc-editor.org/rfc/rfc2692) and [RFC -2693](https://www.rfc-editor.org/rfc/rfc2692) for details. - - - diff --git a/example/ruby/OpenSSL/Netscape/SPKI.md b/example/ruby/OpenSSL/Netscape/SPKI.md deleted file mode 100644 index 2e49685..0000000 --- a/example/ruby/OpenSSL/Netscape/SPKI.md +++ /dev/null @@ -1,113 +0,0 @@ -# Class: OpenSSL::Netscape::SPKI -**Inherits:** Object - - -A Simple Public Key Infrastructure implementation (pronounced "spooky"). The -structure is defined as - PublicKeyAndChallenge ::= SEQUENCE { - spki SubjectPublicKeyInfo, - challenge IA5STRING - } - - SignedPublicKeyAndChallenge ::= SEQUENCE { - publicKeyAndChallenge PublicKeyAndChallenge, - signatureAlgorithm AlgorithmIdentifier, - signature BIT STRING - } - -where the definitions of SubjectPublicKeyInfo and AlgorithmIdentifier can be -found in RFC5280. SPKI is typically used in browsers for generating a -public/private key pair and a subsequent certificate request, using the HTML - element. - -## Examples - -### Creating an SPKI - key = OpenSSL::PKey::RSA.new 2048 - spki = OpenSSL::Netscape::SPKI.new - spki.challenge = "RandomChallenge" - spki.public_key = key.public_key - spki.sign(key, OpenSSL::Digest.new('SHA256')) - #send a request containing this to a server generating a certificate - -### Verifying an SPKI request - request = #... - spki = OpenSSL::Netscape::SPKI.new request - unless spki.verify(spki.public_key) - # signature is invalid - end - #proceed - - - -#Instance Methods -## challenge() [](#method-i-challenge) -Returns the challenge string associated with this SPKI. - -**@overload** [] - -## challenge=(str) [](#method-i-challenge=) -### Parameters -* *str* - the challenge string to be set for this instance - -Sets the challenge to be associated with the SPKI. May be used by the server, -e.g. to prevent replay. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -### Parameters -* *request* - optional raw request, either in PEM or DER format. - -**@overload** [] - -## public_key() [](#method-i-public_key) -Returns the public key associated with the SPKI, an instance of OpenSSL::PKey. - -**@overload** [] - -## public_key=(key) [](#method-i-public_key=) -### Parameters -* *pub* - the public key to be set for this instance - -Sets the public key to be associated with the SPKI, an instance of -OpenSSL::PKey. This should be the public key corresponding to the private key -used for signing the SPKI. - -**@overload** [] - -## sign(key, digest) [](#method-i-sign) -### Parameters -* *key* - the private key to be used for signing this instance -* *digest* - the digest to be used for signing this instance - -To sign an SPKI, the private key corresponding to the public key set for this -instance should be used, in addition to a digest algorithm in the form of an -OpenSSL::Digest. The private key should be an instance of OpenSSL::PKey. - -**@overload** [] - -## to_der() [](#method-i-to_der) -Returns the DER encoding of this SPKI. - -**@overload** [] - -## to_pem() [](#method-i-to_pem) -Returns the PEM encoding of this SPKI. - -**@overload** [] - -## to_text() [](#method-i-to_text) -Returns a textual representation of this SPKI, useful for debugging purposes. - -**@overload** [] - -## verify(key) [](#method-i-verify) -### Parameters -* *key* - the public key to be used for verifying the SPKI signature - -Returns `true` if the signature is valid, `false` otherwise. To verify an -SPKI, the public key contained within the SPKI should be used. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/Netscape/SPKIError.md b/example/ruby/OpenSSL/Netscape/SPKIError.md deleted file mode 100644 index e8435dd..0000000 --- a/example/ruby/OpenSSL/Netscape/SPKIError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: OpenSSL::Netscape::SPKIError -**Inherits:** OpenSSL::OpenSSLError - - -Generic Exception class that is raised if an error occurs during an operation -on an instance of OpenSSL::Netscape::SPKI. - - - diff --git a/example/ruby/OpenSSL/OCSP.md b/example/ruby/OpenSSL/OCSP.md deleted file mode 100644 index 8b7050a..0000000 --- a/example/ruby/OpenSSL/OCSP.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: OpenSSL::OCSP - - - - - diff --git a/example/ruby/OpenSSL/OCSP/BasicResponse.md b/example/ruby/OpenSSL/OCSP/BasicResponse.md deleted file mode 100644 index 8612f8b..0000000 --- a/example/ruby/OpenSSL/OCSP/BasicResponse.md +++ /dev/null @@ -1,104 +0,0 @@ -# Class: OpenSSL::OCSP::BasicResponse -**Inherits:** Object - - - - - -#Instance Methods -## add_nonce(*args) [](#method-i-add_nonce) -Adds *nonce* to this response. If no nonce was provided a random nonce will -be added. - -**@overload** [] - -## add_status(cid, status, reason, revtime, thisupd, nextupd, ext) [](#method-i-add_status) -Adds a certificate status for *certificate_id*. *status* is the status, and -must be one of these: - -* OpenSSL::OCSP::V_CERTSTATUS_GOOD -* OpenSSL::OCSP::V_CERTSTATUS_REVOKED -* OpenSSL::OCSP::V_CERTSTATUS_UNKNOWN - -*reason* and *revocation_time* can be given only when *status* is -OpenSSL::OCSP::V_CERTSTATUS_REVOKED. *reason* describes the reason for the -revocation, and must be one of OpenSSL::OCSP::REVOKED_STATUS_* constants. -*revocation_time* is the time when the certificate is revoked. - -*this_update* and *next_update* indicate the time at which the status is -verified to be correct and the time at or before which newer information will -be available, respectively. *next_update* is optional. - -*extensions* is an Array of OpenSSL::X509::Extension to be included in the -SingleResponse. This is also optional. - -Note that the times, *revocation_time*, *this_update* and *next_update* can be -specified in either of Integer or Time object. If they are Integer, it is -treated as the relative seconds from the current time. - -**@overload** [] - -## copy_nonce(request) [](#method-i-copy_nonce) -Copies the nonce from *request* into this response. Returns 1 on success and -0 on failure. - -**@overload** [] - -## find_response(target) [](#method-i-find_response) -Returns a SingleResponse whose CertId matches with *certificate_id*, or `nil` -if this BasicResponse does not contain it. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new BasicResponse. If *der_string* is given, decodes *der_string* as -DER. - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## responses() [](#method-i-responses) -Returns an Array of SingleResponse for this BasicResponse. - -**@overload** [] - -## sign(*args) [](#method-i-sign) -Signs this OCSP response using the *cert*, *key* and optional *digest*. This -behaves in the similar way as OpenSSL::OCSP::Request#sign. - -*flags* can include: -OpenSSL::OCSP::NOCERTS -: don't include certificates - -OpenSSL::OCSP::NOTIME -: don't set producedAt - -OpenSSL::OCSP::RESPID_KEY -: use signer's public key hash as responderID - - -**@overload** [] - -## status() [](#method-i-status) -Returns an Array of statuses for this response. Each status contains a -CertificateId, the status (0 for good, 1 for revoked, 2 for unknown), the -reason for the status, the revocation time, the time of this update, the time -for the next update and a list of OpenSSL::X509::Extension. - -This should be superseded by BasicResponse#responses and #find_response that -return SingleResponse. - -**@overload** [] - -## to_der() [](#method-i-to_der) -Encodes this basic response into a DER-encoded string. - -**@overload** [] - -## verify(*args) [](#method-i-verify) -Verifies the signature of the response using the given *certificates* and -*store*. This works in the similar way as OpenSSL::OCSP::Request#verify. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/OCSP/CertificateId.md b/example/ruby/OpenSSL/OCSP/CertificateId.md deleted file mode 100644 index 9818ea0..0000000 --- a/example/ruby/OpenSSL/OCSP/CertificateId.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: OpenSSL::OCSP::CertificateId -**Inherits:** Object - - - - - -#Instance Methods -## cmp(other) [](#method-i-cmp) -Compares this certificate id with *other* and returns `true` if they are the -same. - -**@overload** [] - -## cmp_issuer(other) [](#method-i-cmp_issuer) -Compares this certificate id's issuer with *other* and returns `true` if they -are the same. - -**@overload** [] - -## hash_algorithm() [](#method-i-hash_algorithm) -Returns the ln (long name) of the hash algorithm used to generate the -issuerNameHash and the issuerKeyHash values. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new OpenSSL::OCSP::CertificateId for the given *subject* and -*issuer* X509 certificates. The *digest* is a digest algorithm that is used -to compute the hash values. This defaults to SHA-1. - -If only one argument is given, decodes it as DER representation of a -certificate ID or generates certificate ID from the object that responds to -the to_der method. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## issuer_key_hash() [](#method-i-issuer_key_hash) -Returns the issuerKeyHash of this certificate ID, the hash of the issuer's -public key. - -**@overload** [] - -## issuer_name_hash() [](#method-i-issuer_name_hash) -Returns the issuerNameHash of this certificate ID, the hash of the issuer's -distinguished name calculated with the hashAlgorithm. - -**@overload** [] - -## serial() [](#method-i-serial) -Returns the serial number of the certificate for which status is being -requested. - -**@overload** [] - -## to_der() [](#method-i-to_der) -Encodes this certificate identifier into a DER-encoded string. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/OCSP/OCSPError.md b/example/ruby/OpenSSL/OCSP/OCSPError.md deleted file mode 100644 index f6dff0f..0000000 --- a/example/ruby/OpenSSL/OCSP/OCSPError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::OCSP::OCSPError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/OCSP/Request.md b/example/ruby/OpenSSL/OCSP/Request.md deleted file mode 100644 index 4bd6d9a..0000000 --- a/example/ruby/OpenSSL/OCSP/Request.md +++ /dev/null @@ -1,99 +0,0 @@ -# Class: OpenSSL::OCSP::Request -**Inherits:** Object - - - - - -#Instance Methods -## add_certid(certid) [](#method-i-add_certid) -Adds *certificate_id* to the request. - -**@overload** [] - -## add_nonce(*args) [](#method-i-add_nonce) -Adds a *nonce* to the OCSP request. If no nonce is given a random one will be -generated. - -The nonce is used to prevent replay attacks but some servers do not support -it. - -**@overload** [] - -## certid() [](#method-i-certid) -Returns all certificate IDs in this request. - -**@overload** [] - -## check_nonce(basic_resp) [](#method-i-check_nonce) -Checks the nonce validity for this request and *response*. - -The return value is one of the following: - --1 -: nonce in request only. - -0 -: nonces both present and not equal. - -1 -: nonces present and equal. - -2 -: nonces both absent. - -3 -: nonce present in response only. - - -For most responses, clients can check *result* > 0. If a responder doesn't -handle nonces `result.nonzero?` may be necessary. A result of `0` is always -an error. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new OpenSSL::OCSP::Request. The request may be created empty or -from a *request_der* string. - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## sign(*args) [](#method-i-sign) -Signs this OCSP request using *cert*, *key* and optional *digest*. If *digest* -is not specified, SHA-1 is used. *certs* is an optional Array of additional -certificates which are included in the request in addition to the signer -certificate. Note that if *certs* is `nil` or not given, flag -OpenSSL::OCSP::NOCERTS is enabled. Pass an empty array to include only the -signer certificate. - -*flags* is a bitwise OR of the following constants: - -OpenSSL::OCSP::NOCERTS -: Don't include any certificates in the request. *certs* will be ignored. - - -**@overload** [] - -## signed?() [](#method-i-signed?) -Returns `true` if the request is signed, `false` otherwise. Note that the -validity of the signature is **not** checked. Use #verify to verify that. - -**@overload** [] - -## to_der() [](#method-i-to_der) -Returns this request as a DER-encoded string - -## verify(*args) [](#method-i-verify) -Verifies this request using the given *certificates* and *store*. -*certificates* is an array of OpenSSL::X509::Certificate, *store* is an -OpenSSL::X509::Store. - -Note that `false` is returned if the request does not have a signature. Use -#signed? to check whether the request is signed or not. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/OCSP/Response.md b/example/ruby/OpenSSL/OCSP/Response.md deleted file mode 100644 index 61ed4aa..0000000 --- a/example/ruby/OpenSSL/OCSP/Response.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: OpenSSL::OCSP::Response -**Inherits:** Object - - - - -# Class Methods -## create(status , basic_resp ) [](#method-c-create) -Creates an OpenSSL::OCSP::Response from *status* and *basic_response*. -**@overload** [] - - -#Instance Methods -## basic() [](#method-i-basic) -Returns a BasicResponse for this response - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new OpenSSL::OCSP::Response. The response may be created empty or -from a *response_der* string. - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## status() [](#method-i-status) -Returns the status of the response. - -**@overload** [] - -## status_string() [](#method-i-status_string) -Returns a status string for the response. - -**@overload** [] - -## to_der() [](#method-i-to_der) -Returns this response as a DER-encoded string. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/OCSP/SingleResponse.md b/example/ruby/OpenSSL/OCSP/SingleResponse.md deleted file mode 100644 index ed1caf2..0000000 --- a/example/ruby/OpenSSL/OCSP/SingleResponse.md +++ /dev/null @@ -1,73 +0,0 @@ -# Class: OpenSSL::OCSP::SingleResponse -**Inherits:** Object - - - - - -#Instance Methods -## cert_status() [](#method-i-cert_status) -Returns the status of the certificate identified by the certid. The return -value may be one of these constant: - -* V_CERTSTATUS_GOOD -* V_CERTSTATUS_REVOKED -* V_CERTSTATUS_UNKNOWN - -When the status is V_CERTSTATUS_REVOKED, the time at which the certificate was -revoked can be retrieved by #revocation_time. - -**@overload** [] - -## certid() [](#method-i-certid) -Returns the CertificateId for which this SingleResponse is. - -**@overload** [] - -## check_validity(*args) [](#method-i-check_validity) -Checks the validity of thisUpdate and nextUpdate fields of this -SingleResponse. This checks the current time is within the range thisUpdate to -nextUpdate. - -It is possible that the OCSP request takes a few seconds or the time is not -accurate. To avoid rejecting a valid response, this method allows the times to -be within *nsec* seconds of the current time. - -Some responders don't set the nextUpdate field. This may cause a very old -response to be considered valid. The *maxsec* parameter can be used to limit -the age of responses. - -**@overload** [] - -## extensions() [](#method-i-extensions) - -**@overload** [] - -## initialize(arg) [](#method-i-initialize) -Creates a new SingleResponse from *der_string*. - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## next_update() [](#method-i-next_update) - -**@overload** [] - -## revocation_reason() [](#method-i-revocation_reason) - -**@overload** [] - -## revocation_time() [](#method-i-revocation_time) - -**@overload** [] - -## this_update() [](#method-i-this_update) - -**@overload** [] - -## to_der() [](#method-i-to_der) -Encodes this SingleResponse into a DER-encoded string. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/OSSL.md b/example/ruby/OpenSSL/OSSL.md deleted file mode 100644 index 000fece..0000000 --- a/example/ruby/OpenSSL/OSSL.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: OpenSSL::OSSL -**Inherits:** OpenSSL::SSLTestCase - - - - - -#Instance Methods -## test_error_data() [](#method-i-test_error_data) - -## test_fixed_length_secure_compare() [](#method-i-test_fixed_length_secure_compare) - -## test_memcmp_timing() [](#method-i-test_memcmp_timing) - -## test_secure_compare() [](#method-i-test_secure_compare) - diff --git a/example/ruby/OpenSSL/OpenSSLError.md b/example/ruby/OpenSSL/OpenSSLError.md deleted file mode 100644 index 0aecdfa..0000000 --- a/example/ruby/OpenSSL/OpenSSLError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::OpenSSLError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/OpenSSL/PKCS12.md b/example/ruby/OpenSSL/PKCS12.md deleted file mode 100644 index c7bec15..0000000 --- a/example/ruby/OpenSSL/PKCS12.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: OpenSSL::PKCS12 -**Inherits:** Object - - - - -# Class Methods -## create(*args ) [](#method-c-create) -### Parameters -* *pass* - string -* *name* - A string describing the key. -* *key* - Any PKey. -* *cert* - A X509::Certificate. - * The public_key portion of the certificate must contain a valid public - key. - * The not_before and not_after fields must be filled in. -* *ca* - An optional array of X509::Certificate's. -* *key_pbe* - string -* *cert_pbe* - string -* *key_iter* - integer -* *mac_iter* - integer -* *keytype* - An integer representing an MSIE specific extension. - -Any optional arguments may be supplied as `nil` to preserve the OpenSSL -defaults. - -See the OpenSSL documentation for PKCS12_create(). -**@overload** [] - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -### Parameters -* *str* - Must be a DER encoded PKCS12 string. -* *pass* - string - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## set_mac(*args) [](#method-i-set_mac) -Sets MAC parameters and generates MAC over the PKCS #12 structure. - -This method uses HMAC and the PKCS #12 specific password-based KDF as -specified in the original PKCS #12. - -See also the man page PKCS12_set_mac(3). - -Added in version 3.3.0. - -**@overload** [] - -## to_der() [](#method-i-to_der) - diff --git a/example/ruby/OpenSSL/PKCS12/PKCS12Error.md b/example/ruby/OpenSSL/PKCS12/PKCS12Error.md deleted file mode 100644 index a9832c7..0000000 --- a/example/ruby/OpenSSL/PKCS12/PKCS12Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::PKCS12::PKCS12Error -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/PKCS5.md b/example/ruby/OpenSSL/PKCS5.md deleted file mode 100644 index e0baae3..0000000 --- a/example/ruby/OpenSSL/PKCS5.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: OpenSSL::PKCS5 - - - - -# Class Methods -## pbkdf2_hmac(pass , salt , iter , keylen , digest ) [](#method-c-pbkdf2_hmac) -OpenSSL::PKCS5.pbkdf2_hmac has been renamed to OpenSSL::KDF.pbkdf2_hmac. This -method is provided for backwards compatibility. -## pbkdf2_hmac_sha1(pass , salt , iter , keylen ) [](#method-c-pbkdf2_hmac_sha1) - diff --git a/example/ruby/OpenSSL/PKCS7.md b/example/ruby/OpenSSL/PKCS7.md deleted file mode 100644 index 103d8ae..0000000 --- a/example/ruby/OpenSSL/PKCS7.md +++ /dev/null @@ -1,85 +0,0 @@ -# Class: OpenSSL::PKCS7 -**Inherits:** Object - - - - -# Class Methods -## encrypt(*args ) [](#method-c-encrypt) -Creates a PKCS #7 enveloped-data structure. - -Before version 3.3.0, `cipher` was optional and defaulted to `"RC2-40-CBC"`. - -See also the man page PKCS7_encrypt(3). -**@overload** [] - -## read_smime(arg ) [](#method-c-read_smime) -**@overload** [] - -## sign(*args ) [](#method-c-sign) -**@overload** [] - -## write_smime(*args ) [](#method-c-write_smime) -**@overload** [] - - -#Instance Methods -## add_certificate(cert) [](#method-i-add_certificate) - -## add_crl(crl) [](#method-i-add_crl) - -## add_data(data) [](#method-i-add_data) - -## add_recipient(recip) [](#method-i-add_recipient) - -## add_signer(signer) [](#method-i-add_signer) - -## certificates() [](#method-i-certificates) - -## certificates=(ary) [](#method-i-certificates=) - -## cipher=(cipher) [](#method-i-cipher=) - -## crls() [](#method-i-crls) - -## crls=(ary) [](#method-i-crls=) - -## decrypt(*args) [](#method-i-decrypt) - -## detached() [](#method-i-detached) - -## detached=(flag) [](#method-i-detached=) - -## detached?() [](#method-i-detached?) - -**@return** [Boolean] - -## initialize(*args) [](#method-i-initialize) -Many methods in this class aren't documented. - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## recipients() [](#method-i-recipients) - -## signers() [](#method-i-signers) - -## to_der() [](#method-i-to_der) - -## to_pem() [](#method-i-to_pem) - -## to_text() [](#method-i-to_text) - -## type() [](#method-i-type) - -**@overload** [] - -## type=(type) [](#method-i-type=) - -**@overload** [] - -## verify(*args) [](#method-i-verify) - diff --git a/example/ruby/OpenSSL/PKCS7/PKCS7Error.md b/example/ruby/OpenSSL/PKCS7/PKCS7Error.md deleted file mode 100644 index f048a41..0000000 --- a/example/ruby/OpenSSL/PKCS7/PKCS7Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::PKCS7::PKCS7Error -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/PKCS7/RecipientInfo.md b/example/ruby/OpenSSL/PKCS7/RecipientInfo.md deleted file mode 100644 index b434f3d..0000000 --- a/example/ruby/OpenSSL/PKCS7/RecipientInfo.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: OpenSSL::PKCS7::RecipientInfo -**Inherits:** Object - - - - - -#Instance Methods -## enc_key() [](#method-i-enc_key) - -## initialize(cert) [](#method-i-initialize) - -## issuer() [](#method-i-issuer) - -## serial() [](#method-i-serial) - diff --git a/example/ruby/OpenSSL/PKCS7/SignerInfo.md b/example/ruby/OpenSSL/PKCS7/SignerInfo.md deleted file mode 100644 index 8b4dec5..0000000 --- a/example/ruby/OpenSSL/PKCS7/SignerInfo.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: OpenSSL::PKCS7::SignerInfo -**Inherits:** Object - - - - - -#Instance Methods -## initialize(cert, key, digest) [](#method-i-initialize) - -## issuer() [](#method-i-issuer) - -## serial() [](#method-i-serial) - -## signed_time() [](#method-i-signed_time) - diff --git a/example/ruby/OpenSSL/PKey.md b/example/ruby/OpenSSL/PKey.md deleted file mode 100644 index 929c8db..0000000 --- a/example/ruby/OpenSSL/PKey.md +++ /dev/null @@ -1,50 +0,0 @@ -# Module: OpenSSL::PKey - - -## Asymmetric Public Key Algorithms - -Asymmetric public key algorithms solve the problem of establishing and sharing -secret keys to en-/decrypt messages. The key in such an algorithm consists of -two parts: a public key that may be distributed to others and a private key -that needs to remain secret. - -Messages encrypted with a public key can only be decrypted by recipients that -are in possession of the associated private key. Since public key algorithms -are considerably slower than symmetric key algorithms (cf. OpenSSL::Cipher) -they are often used to establish a symmetric key shared between two parties -that are in possession of each other's public key. - -Asymmetric algorithms offer a lot of nice features that are used in a lot of -different areas. A very common application is the creation and validation of -digital signatures. To sign a document, the signatory generally uses a message -digest algorithm (cf. OpenSSL::Digest) to compute a digest of the document -that is then encrypted (i.e. signed) using the private key. Anyone in -possession of the public key may then verify the signature by computing the -message digest of the original document on their own, decrypting the signature -using the signatory's public key and comparing the result to the message -digest they previously computed. The signature is valid if and only if the -decrypted signature is equal to this message digest. - -The PKey module offers support for three popular public/private key -algorithms: -* RSA (OpenSSL::PKey::RSA) -* DSA (OpenSSL::PKey::DSA) -* Elliptic Curve Cryptography (OpenSSL::PKey::EC) -Each of these implementations is in fact a sub-class of the abstract PKey -class which offers the interface for supporting digital signatures in the form -of PKey#sign and PKey#verify. - -## Diffie-Hellman Key Exchange - -Finally PKey also features OpenSSL::PKey::DH, an implementation of the -Diffie-Hellman key exchange protocol based on discrete logarithms in finite -fields, the same basis that DSA is built on. The Diffie-Hellman protocol can -be used to exchange (symmetric) keys over insecure channels without needing -any prior joint knowledge between the participating parties. As the security -of DH demands relatively long "public keys" (i.e. the part that is overtly -transmitted between participants) DH tends to be quite slow. If security or -speed is your primary concern, OpenSSL::PKey::EC offers another implementation -of the Diffie-Hellman protocol. - - - diff --git a/example/ruby/OpenSSL/PKey/DH.md b/example/ruby/OpenSSL/PKey/DH.md deleted file mode 100644 index 5628c70..0000000 --- a/example/ruby/OpenSSL/PKey/DH.md +++ /dev/null @@ -1,247 +0,0 @@ -# Class: OpenSSL::PKey::DH -**Inherits:** OpenSSL::PKey::PKey - -**Includes:** OpenSSL::Marshal - - -An implementation of the Diffie-Hellman key exchange protocol based on -discrete logarithms in finite fields, the same basis that DSA is built on. - -### Accessor methods for the Diffie-Hellman parameters -DH#p -: The prime (an OpenSSL::BN) of the Diffie-Hellman parameters. - -DH#g -: The generator (an OpenSSL::BN) g of the Diffie-Hellman parameters. - -DH#pub_key -: The per-session public key (an OpenSSL::BN) matching the private key. This - needs to be passed to DH#compute_key. - -DH#priv_key -: The per-session private key, an OpenSSL::BN. - - -### Example of a key exchange - # you may send the parameters (der) and own public key (pub1) publicly - # to the participating party - dh1 = OpenSSL::PKey::DH.new(2048) - der = dh1.to_der - pub1 = dh1.pub_key - - # the other party generates its per-session key pair - dhparams = OpenSSL::PKey::DH.new(der) - dh2 = OpenSSL::PKey.generate_key(dhparams) - pub2 = dh2.pub_key - - symm_key1 = dh1.compute_key(pub2) - symm_key2 = dh2.compute_key(pub1) - puts symm_key1 == symm_key2 # => true - - -# Class Methods -## generate(size , generator 2, &blk ) [](#method-c-generate) -:call-seq: - DH.generate(size, generator = 2) -> dh - -Creates a new DH instance from scratch by generating random parameters and a -key pair. - -See also OpenSSL::PKey.generate_parameters and OpenSSL::PKey.generate_key. - -`size` -: The desired key size in bits. - -`generator` -: The generator. - -## new(*args , &blk ) [](#method-c-new) -Handle DH.new(size, generator) form here; new(str) and new() forms are handled -by #initialize - -#Instance Methods -## _dump(_level) [](#method-i-_dump) - -## compute_key(pub_bn) [](#method-i-compute_key) -:call-seq: - dh.compute_key(pub_bn) -> string - -Returns a String containing a shared secret computed from the other party's -public value. - -This method is provided for backwards compatibility, and calls #derive -internally. - -### Parameters -* *pub_bn* is a OpenSSL::BN, **not** the DH instance returned by - DH#public_key as that contains the DH parameters only. - -## export() [](#method-i-export) -Serializes the DH parameters to a PEM-encoding. - -Note that any existing per-session public/private keys will **not** get -encoded, just the Diffie-Hellman parameters will be encoded. - -PEM-encoded parameters will look like: - - -----BEGIN DH PARAMETERS----- - [...] - -----END DH PARAMETERS----- - -See also #public_to_pem (X.509 SubjectPublicKeyInfo) and #private_to_pem (PKCS -#8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the -private or public key components. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## generate_key!() [](#method-i-generate_key!) -:call-seq: - dh.generate_key! -> self - -Generates a private and public key unless a private key already exists. If -this DH instance was generated from public DH parameters (e.g. by encoding the -result of DH#public_key), then this method needs to be called first in order -to generate the per-session keys before performing the actual key exchange. - -**Deprecated in version 3.0**. This method is incompatible with OpenSSL 3.0.0 -or later. - -See also OpenSSL::PKey.generate_key. - -Example: - # DEPRECATED USAGE: This will not work on OpenSSL 3.0 or later - dh0 = OpenSSL::PKey::DH.new(2048) - dh = dh0.public_key # #public_key only copies the DH parameters (contrary to the name) - dh.generate_key! - puts dh.private? # => true - puts dh0.pub_key == dh.pub_key #=> false - - # With OpenSSL::PKey.generate_key - dh0 = OpenSSL::PKey::DH.new(2048) - dh = OpenSSL::PKey.generate_key(dh0) - puts dh0.pub_key == dh.pub_key #=> false - -## initialize(*args) [](#method-i-initialize) -Creates a new instance of OpenSSL::PKey::DH. - -If called without arguments, an empty instance without any parameter or key -components is created. Use #set_pqg to manually set the parameters afterwards -(and optionally #set_key to set private and public key components). - -If a String is given, tries to parse it as a DER- or PEM- encoded parameters. -See also OpenSSL::PKey.read which can parse keys of any kinds. - -The DH.new(size [, generator]) form is an alias of DH.generate. - -`string` -: A String that contains the DER or PEM encoded key. - -`size` -: See DH.generate. - -`generator` -: See DH.generate. - - -Examples: - # Creating an instance from scratch - # Note that this is deprecated and will not work on OpenSSL 3.0 or later. - dh = OpenSSL::PKey::DH.new - dh.set_pqg(bn_p, nil, bn_g) - - # Generating a parameters and a key pair - dh = OpenSSL::PKey::DH.new(2048) # An alias of OpenSSL::PKey::DH.generate(2048) - - # Reading DH parameters - dh_params = OpenSSL::PKey::DH.new(File.read('parameters.pem')) # loads parameters only - dh = OpenSSL::PKey.generate_key(dh_params) # generates a key pair - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## params() [](#method-i-params) -Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN -LEAK OUT!!! Don't use :-)) (I's up to you) - -**@overload** [] - -## params_ok?() [](#method-i-params_ok?) -Validates the Diffie-Hellman parameters associated with this instance. It -checks whether a safe prime and a suitable generator are used. If this is not -the case, `false` is returned. - -See also the man page EVP_PKEY_param_check(3). - -**@overload** [] - -**@return** [Boolean] - -## private?() [](#method-i-private?) -Indicates whether this DH instance has a private key associated with it or -not. The private key may be retrieved with DH#priv_key. - -**@overload** [] - -**@return** [Boolean] - -## public?() [](#method-i-public?) -Indicates whether this DH instance has a public key associated with it or not. -The public key may be retrieved with DH#pub_key. - -**@overload** [] - -**@return** [Boolean] - -## public_key() [](#method-i-public_key) -:call-seq: - dh.public_key -> dhnew - -Returns a new DH instance that carries just the DH parameters. - -Contrary to the method name, the returned DH object contains only parameters -and not the public key. - -This method is provided for backwards compatibility. In most cases, there is -no need to call this method. - -For the purpose of re-generating the key pair while keeping the parameters, -check OpenSSL::PKey.generate_key. - -Example: - # OpenSSL::PKey::DH.generate by default generates a random key pair - dh1 = OpenSSL::PKey::DH.generate(2048) - p dh1.priv_key #=> # - dhcopy = dh1.public_key - p dhcopy.priv_key #=> nil - -## set_key() [](#method-i-set_key) -Sets *pub_key* and *priv_key* for the DH instance. *priv_key* may be `nil`. - -**@overload** [] - -## set_pqg() [](#method-i-set_pqg) -Sets *p*, *q*, *g* to the DH instance. - -**@overload** [] - -## to_der() [](#method-i-to_der) -Serializes the DH parameters to a DER-encoding - -Note that any existing per-session public/private keys will **not** get -encoded, just the Diffie-Hellman parameters will be encoded. - -See also #public_to_der (X.509 SubjectPublicKeyInfo) and #private_to_der (PKCS -#8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the -private or public key components. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/PKey/DHError.md b/example/ruby/OpenSSL/PKey/DHError.md deleted file mode 100644 index c27933b..0000000 --- a/example/ruby/OpenSSL/PKey/DHError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: OpenSSL::PKey::DHError -**Inherits:** OpenSSL::PKey::PKeyError - - -Generic exception that is raised if an operation on a DH PKey fails -unexpectedly or in case an instantiation of an instance of DH fails due to -non-conformant input data. - - - diff --git a/example/ruby/OpenSSL/PKey/DSA.md b/example/ruby/OpenSSL/PKey/DSA.md deleted file mode 100644 index 1f305f6..0000000 --- a/example/ruby/OpenSSL/PKey/DSA.md +++ /dev/null @@ -1,230 +0,0 @@ -# Class: OpenSSL::PKey::DSA -**Inherits:** OpenSSL::PKey::PKey - -**Includes:** OpenSSL::Marshal - - -DSA, the Digital Signature Algorithm, is specified in NIST's FIPS 186-3. It is -an asymmetric public key algorithm that may be used similar to e.g. RSA. - - -# Class Methods -## generate(size , &blk ) [](#method-c-generate) -:call-seq: - DSA.generate(size) -> dsa - -Creates a new DSA instance by generating a private/public key pair from -scratch. - -See also OpenSSL::PKey.generate_parameters and OpenSSL::PKey.generate_key. - -`size` -: The desired key size in bits. - -## new(*args , &blk ) [](#method-c-new) -Handle DSA.new(size) form here; new(str) and new() forms are handled by -#initialize - -#Instance Methods -## _dump(_level) [](#method-i-_dump) - -## export(*args) [](#method-i-export) -Serializes a private or public key to a PEM-encoding. - -When the key contains public components only -: Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher* - and *password* are ignored. - - A PEM-encoded key will look like: - - -----BEGIN PUBLIC KEY----- - [...] - -----END PUBLIC KEY----- - - Consider using #public_to_pem instead. This serializes the key into an - X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a - private key. - - -When the key contains private components, and no parameters are given -: Serializes it into a traditional OpenSSL DSAPrivateKey. - - A PEM-encoded key will look like: - - -----BEGIN DSA PRIVATE KEY----- - [...] - -----END DSA PRIVATE KEY----- - - -When the key contains private components, and *cipher* and *password* are given -: Serializes it into a traditional OpenSSL DSAPrivateKey and encrypts it in - OpenSSL's traditional PEM encryption format. *cipher* must be a cipher - name understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher. - - An encrypted PEM-encoded key will look like: - - -----BEGIN DSA PRIVATE KEY----- - Proc-Type: 4,ENCRYPTED - DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0 - - [...] - -----END DSA PRIVATE KEY----- - - Note that this format uses MD5 to derive the encryption key, and hence - will not be available on FIPS-compliant systems. - - -**This method is kept for compatibility.** This should only be used when the -traditional, non-standard OpenSSL format is required. - -Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem -(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new DSA instance by reading an existing key from *string*. - -If called without arguments, creates a new instance with no key components -set. They can be set individually by #set_pqg and #set_key. - -If called with a String, tries to parse as DER or PEM encoding of a DSA key. -See also OpenSSL::PKey.read which can parse keys of any kinds. - -If called with a number, generates random parameters and a key pair. This form -works as an alias of DSA.generate. - -`string` -: A String that contains a DER or PEM encoded key. - -`pass` -: A String that contains an optional password. - -`size` -: See DSA.generate. - - -Examples: - p OpenSSL::PKey::DSA.new(1024) - #=> # - - p OpenSSL::PKey::DSA.new(File.read('dsa.pem')) - #=> # - - p OpenSSL::PKey::DSA.new(File.read('dsa.pem'), 'mypassword') - #=> # - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## params() [](#method-i-params) -Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN -LEAK OUT!!! Don't use :-)) (I's up to you) - -**@overload** [] - -## private?() [](#method-i-private?) -Indicates whether this DSA instance has a private key associated with it or -not. The private key may be retrieved with DSA#private_key. - -**@overload** [] - -**@return** [Boolean] - -## public?() [](#method-i-public?) -Indicates whether this DSA instance has a public key associated with it or -not. The public key may be retrieved with DSA#public_key. - -**@overload** [] - -**@return** [Boolean] - -## public_key() [](#method-i-public_key) -:call-seq: - dsa.public_key -> dsanew - -Returns a new DSA instance that carries just the DSA parameters and the public -key. - -This method is provided for backwards compatibility. In most cases, there is -no need to call this method. - -For the purpose of serializing the public key, to PEM or DER encoding of X.509 -SubjectPublicKeyInfo format, check PKey#public_to_pem and PKey#public_to_der. - -## set_key() [](#method-i-set_key) -Sets *pub_key* and *priv_key* for the DSA instance. *priv_key* may be `nil`. - -**@overload** [] - -## set_pqg() [](#method-i-set_pqg) -Sets *p*, *q*, *g* to the DSA instance. - -**@overload** [] - -## syssign(string) [](#method-i-syssign) -:call-seq: - dsa.syssign(string) -> string - -Computes and returns the DSA signature of `string`, where `string` is expected -to be an already-computed message digest of the original input data. The -signature is issued using the private key of this DSA instance. - -**Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and -PKey::PKey#verify_raw instead. - -`string` -: A message digest of the original input data to be signed. - - -Example: - dsa = OpenSSL::PKey::DSA.new(2048) - doc = "Sign me" - digest = OpenSSL::Digest.digest('SHA1', doc) - - # With legacy #syssign and #sysverify: - sig = dsa.syssign(digest) - p dsa.sysverify(digest, sig) #=> true - - # With #sign_raw and #verify_raw: - sig = dsa.sign_raw(nil, digest) - p dsa.verify_raw(nil, sig, digest) #=> true - -## sysverify(digest, sig) [](#method-i-sysverify) -:call-seq: - dsa.sysverify(digest, sig) -> true | false - -Verifies whether the signature is valid given the message digest input. It -does so by validating `sig` using the public key of this DSA instance. - -**Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and -PKey::PKey#verify_raw instead. - -`digest` -: A message digest of the original input data to be signed. - -`sig` -: A DSA signature value. - - -## to_der() [](#method-i-to_der) -Serializes a private or public key to a DER-encoding. - -See #to_pem for details. - -**This method is kept for compatibility.** This should only be used when the -traditional, non-standard OpenSSL format is required. - -Consider using #public_to_der or #private_to_der instead. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/PKey/DSAError.md b/example/ruby/OpenSSL/PKey/DSAError.md deleted file mode 100644 index 11dd387..0000000 --- a/example/ruby/OpenSSL/PKey/DSAError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: OpenSSL::PKey::DSAError -**Inherits:** OpenSSL::PKey::PKeyError - - -Generic exception that is raised if an operation on a DSA PKey fails -unexpectedly or in case an instantiation of an instance of DSA fails due to -non-conformant input data. - - - diff --git a/example/ruby/OpenSSL/PKey/EC.md b/example/ruby/OpenSSL/PKey/EC.md deleted file mode 100644 index 9838812..0000000 --- a/example/ruby/OpenSSL/PKey/EC.md +++ /dev/null @@ -1,210 +0,0 @@ -# Class: OpenSSL::PKey::EC -**Inherits:** OpenSSL::PKey::PKey - -**Includes:** OpenSSL::Marshal - - -OpenSSL::PKey::EC provides access to Elliptic Curve Digital Signature -Algorithm (ECDSA) and Elliptic Curve Diffie-Hellman (ECDH). - -### Key exchange - ec1 = OpenSSL::PKey::EC.generate("prime256v1") - ec2 = OpenSSL::PKey::EC.generate("prime256v1") - # ec1 and ec2 have own private key respectively - shared_key1 = ec1.dh_compute_key(ec2.public_key) - shared_key2 = ec2.dh_compute_key(ec1.public_key) - - p shared_key1 == shared_key2 #=> true - - -# Class Methods -## builtin_curves() [](#method-c-builtin_curves) -Obtains a list of all predefined curves by the OpenSSL. Curve names are -returned as sn. - -See the OpenSSL documentation for EC_get_builtin_curves(). -**@overload** [] - -## generate(arg ) [](#method-c-generate) -Creates a new EC instance with a new random private and public key. -**@overload** [] - -**@overload** [] - - -#Instance Methods -## _dump(_level) [](#method-i-_dump) - -## check_key() [](#method-i-check_key) -Raises an exception if the key is invalid. - -See also the man page EVP_PKEY_public_check(3). - -**@overload** [] - -## dh_compute_key(pubkey) [](#method-i-dh_compute_key) -:call-seq: - ec.dh_compute_key(pubkey) -> string - -Derives a shared secret by ECDH. *pubkey* must be an instance of -OpenSSL::PKey::EC::Point and must belong to the same group. - -This method is provided for backwards compatibility, and calls #derive -internally. - -## dsa_sign_asn1(data) [](#method-i-dsa_sign_asn1) -:call-seq: - key.dsa_sign_asn1(data) -> String - -**Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and -PKey::PKey#verify_raw instead. - -## dsa_verify_asn1(data, sig) [](#method-i-dsa_verify_asn1) -:call-seq: - key.dsa_verify_asn1(data, sig) -> true | false - -**Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and -PKey::PKey#verify_raw instead. - -## export(*args) [](#method-i-export) -Serializes a private or public key to a PEM-encoding. - -When the key contains public components only -: Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher* - and *password* are ignored. - - A PEM-encoded key will look like: - - -----BEGIN PUBLIC KEY----- - [...] - -----END PUBLIC KEY----- - - Consider using #public_to_pem instead. This serializes the key into an - X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a - private key. - - -When the key contains private components, and no parameters are given -: Serializes it into a SEC 1/RFC 5915 ECPrivateKey. - - A PEM-encoded key will look like: - - -----BEGIN EC PRIVATE KEY----- - [...] - -----END EC PRIVATE KEY----- - - -When the key contains private components, and *cipher* and *password* are given -: Serializes it into a SEC 1/RFC 5915 ECPrivateKey and encrypts it in - OpenSSL's traditional PEM encryption format. *cipher* must be a cipher - name understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher. - - An encrypted PEM-encoded key will look like: - - -----BEGIN EC PRIVATE KEY----- - Proc-Type: 4,ENCRYPTED - DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0 - - [...] - -----END EC PRIVATE KEY----- - - Note that this format uses MD5 to derive the encryption key, and hence - will not be available on FIPS-compliant systems. - - -**This method is kept for compatibility.** This should only be used when the -SEC 1/RFC 5915 ECPrivateKey format is required. - -Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem -(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead. - -**@overload** [] - -**@overload** [] - -## generate_key!() [](#method-i-generate_key!) -Generates a new random private and public key. - -See also the OpenSSL documentation for EC_KEY_generate_key() - -### Example - ec = OpenSSL::PKey::EC.new("prime256v1") - p ec.private_key # => nil - ec.generate_key! - p ec.private_key # => # - -**@overload** [] - -## group() [](#method-i-group) -Returns the EC::Group that the key is associated with. Modifying the returned -group does not affect *key*. - -**@overload** [] - -## group=(group_v) [](#method-i-group=) -Sets the EC::Group for the key. The group structure is internally copied so -modification to *group* after assigning to a key has no effect on the key. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new EC object from given arguments. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## private?() [](#method-i-private?) -Returns whether this EC instance has a private key. The private key (BN) can -be retrieved with EC#private_key. - -**@overload** [] - -## private_key() [](#method-i-private_key) -See the OpenSSL documentation for EC_KEY_get0_private_key() - -**@overload** [] - -## private_key=(private_key) [](#method-i-private_key=) -See the OpenSSL documentation for EC_KEY_set_private_key() - -**@overload** [] - -## public?() [](#method-i-public?) -Returns whether this EC instance has a public key. The public key (EC::Point) -can be retrieved with EC#public_key. - -**@overload** [] - -## public_key() [](#method-i-public_key) -See the OpenSSL documentation for EC_KEY_get0_public_key() - -**@overload** [] - -## public_key=(public_key) [](#method-i-public_key=) -See the OpenSSL documentation for EC_KEY_set_public_key() - -**@overload** [] - -## to_der() [](#method-i-to_der) -Serializes a private or public key to a DER-encoding. - -See #to_pem for details. - -**This method is kept for compatibility.** This should only be used when the -SEC 1/RFC 5915 ECPrivateKey format is required. - -Consider using #public_to_der or #private_to_der instead. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/PKey/EC/Group.md b/example/ruby/OpenSSL/PKey/EC/Group.md deleted file mode 100644 index 05fd0b6..0000000 --- a/example/ruby/OpenSSL/PKey/EC/Group.md +++ /dev/null @@ -1,148 +0,0 @@ -# Class: OpenSSL::PKey::EC::Group -**Inherits:** Object - - - - - -#Instance Methods -## asn1_flag() [](#method-i-asn1_flag) -Returns the flags set on the group. - -See also #asn1_flag=. - -**@overload** [] - -## asn1_flag=(flag_v) [](#method-i-asn1_flag=) -Sets flags on the group. The flag value is used to determine how to encode the -group: encode explicit parameters or named curve using an OID. - -The flag value can be either of: - -* EC::NAMED_CURVE -* EC::EXPLICIT_CURVE - -See the OpenSSL documentation for EC_GROUP_set_asn1_flag(). - -**@overload** [] - -## cofactor() [](#method-i-cofactor) -Returns the cofactor of the group. - -See the OpenSSL documentation for EC_GROUP_get_cofactor() - -**@overload** [] - -## curve_name() [](#method-i-curve_name) -Returns the curve name (sn). - -See the OpenSSL documentation for EC_GROUP_get_curve_name() - -**@overload** [] - -## degree() [](#method-i-degree) -See the OpenSSL documentation for EC_GROUP_get_degree() - -**@overload** [] - -## eql?(b) [](#method-i-eql?) -Returns `true` if the two groups use the same curve and have the same -parameters, `false` otherwise. - -**@overload** [] - -**@overload** [] - -**@return** [Boolean] - -## generator() [](#method-i-generator) -Returns the generator of the group. - -See the OpenSSL documentation for EC_GROUP_get0_generator() - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new EC::Group object. - -If the first argument is :GFp or :GF2m, creates a new curve with given -parameters. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## order() [](#method-i-order) -Returns the order of the group. - -See the OpenSSL documentation for EC_GROUP_get_order() - -**@overload** [] - -## point_conversion_form() [](#method-i-point_conversion_form) -Returns the form how EC::Point data is encoded as ASN.1. - -See also #point_conversion_form=. - -**@overload** [] - -## point_conversion_form=(form_v) [](#method-i-point_conversion_form=) -Sets the form how EC::Point data is encoded as ASN.1 as defined in X9.62. - -*format* can be one of these: - -`:compressed` -: Encoded as z||x, where z is an octet indicating which solution of the - equation y is. z will be 0x02 or 0x03. - -`:uncompressed` -: Encoded as z||x||y, where z is an octet 0x04. - -`:hybrid` -: Encodes as z||x||y, where z is an octet indicating which solution of the - equation y is. z will be 0x06 or 0x07. - - -See the OpenSSL documentation for EC_GROUP_set_point_conversion_form() - -**@overload** [] - -## seed() [](#method-i-seed) -See the OpenSSL documentation for EC_GROUP_get0_seed() - -**@overload** [] - -## seed=(seed) [](#method-i-seed=) -See the OpenSSL documentation for EC_GROUP_set_seed() - -**@overload** [] - -## set_generator(generator, order, cofactor) [](#method-i-set_generator) -Sets the curve parameters. *generator* must be an instance of EC::Point that -is on the curve. *order* and *cofactor* are integers. - -See the OpenSSL documentation for EC_GROUP_set_generator() - -**@overload** [] - -## to_der() [](#method-i-to_der) -See the OpenSSL documentation for i2d_ECPKParameters_bio() - -**@overload** [] - -## to_pem() [](#method-i-to_pem) -See the OpenSSL documentation for PEM_write_bio_ECPKParameters() - -**@overload** [] - -## to_text() [](#method-i-to_text) -See the OpenSSL documentation for ECPKParameters_print() - -**@overload** [] - diff --git a/example/ruby/OpenSSL/PKey/EC/Group/Error.md b/example/ruby/OpenSSL/PKey/EC/Group/Error.md deleted file mode 100644 index cd7bd3e..0000000 --- a/example/ruby/OpenSSL/PKey/EC/Group/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::PKey::EC::Group::Error -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/PKey/EC/Point.md b/example/ruby/OpenSSL/PKey/EC/Point.md deleted file mode 100644 index 8c2aeb5..0000000 --- a/example/ruby/OpenSSL/PKey/EC/Point.md +++ /dev/null @@ -1,99 +0,0 @@ -# Class: OpenSSL::PKey::EC::Point -**Inherits:** Object - - - - - -#Instance Methods -## add(other) [](#method-i-add) -Performs elliptic curve point addition. - -**@overload** [] - -## eql?(b) [](#method-i-eql?) - -**@overload** [] - -**@overload** [] - -**@return** [Boolean] - -## infinity?() [](#method-i-infinity?) - -**@overload** [] - -**@return** [Boolean] - -## initialize(*args) [](#method-i-initialize) -Creates a new instance of OpenSSL::PKey::EC::Point. If the only argument is an -instance of EC::Point, a copy is returned. Otherwise, creates a point that -belongs to *group*. - -*encoded_point* is the octet string representation of the point. This must be -either a String or an OpenSSL::BN. - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## invert!() [](#method-i-invert!) - -**@overload** [] - -## make_affine!() [](#method-i-make_affine!) -This method is deprecated and should not be used. This is a no-op. - -**@overload** [] - -## mul(*args) [](#method-i-mul) -Performs elliptic curve point multiplication. - -The first form calculates `bn1 * point + bn2 * G`, where `G` is the generator -of the group of *point*. *bn2* may be omitted, and in that case, the result is -just `bn1 * point`. - -The second form calculates `bns[0] * point + bns[1] * points[0] + ... + -bns[-1] * points[-1] + bn2 * G`. *bn2* may be omitted. *bns* must be an array -of OpenSSL::BN. *points* must be an array of OpenSSL::PKey::EC::Point. Please -note that `points[0]` is not multiplied by `bns[0]`, but `bns[1]`. - -**@overload** [] - -**@overload** [] - -## on_curve?() [](#method-i-on_curve?) - -**@overload** [] - -**@return** [Boolean] - -## set_to_infinity!() [](#method-i-set_to_infinity!) - -**@overload** [] - -## to_bn(conversion_formgroup.point_conversion_form) [](#method-i-to_bn) -:call-seq: - point.to_bn([conversion_form]) -> OpenSSL::BN - -Returns the octet string representation of the EC point as an instance of -OpenSSL::BN. - -If *conversion_form* is not given, the *point_conversion_form* attribute set -to the group is used. - -See #to_octet_string for more information. - -## to_octet_string(conversion_form) [](#method-i-to_octet_string) -Returns the octet string representation of the elliptic curve point. - -*conversion_form* specifies how the point is converted. Possible values are: - -* `:compressed` -* `:uncompressed` -* `:hybrid` - -**@overload** [] - diff --git a/example/ruby/OpenSSL/PKey/EC/Point/Error.md b/example/ruby/OpenSSL/PKey/EC/Point/Error.md deleted file mode 100644 index 9839b42..0000000 --- a/example/ruby/OpenSSL/PKey/EC/Point/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::PKey::EC::Point::Error -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/PKey/ECError.md b/example/ruby/OpenSSL/PKey/ECError.md deleted file mode 100644 index 269494f..0000000 --- a/example/ruby/OpenSSL/PKey/ECError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::PKey::ECError -**Inherits:** OpenSSL::PKey::PKeyError - - - - - diff --git a/example/ruby/OpenSSL/PKey/PKey.md b/example/ruby/OpenSSL/PKey/PKey.md deleted file mode 100644 index bd75c9f..0000000 --- a/example/ruby/OpenSSL/PKey/PKey.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: OpenSSL::PKey::PKey -**Inherits:** Object - - -An abstract class that bundles signature creation (PKey#sign) and validation -(PKey#verify) that is common to all implementations except OpenSSL::PKey::DH -* OpenSSL::PKey::RSA -* OpenSSL::PKey::DSA -* OpenSSL::PKey::EC - - - diff --git a/example/ruby/OpenSSL/PKey/PKeyError.md b/example/ruby/OpenSSL/PKey/PKeyError.md deleted file mode 100644 index 74348f5..0000000 --- a/example/ruby/OpenSSL/PKey/PKeyError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OpenSSL::PKey::PKeyError -**Inherits:** OpenSSL::OpenSSLError - - -Raised when errors occur during PKey#sign or PKey#verify. - - - diff --git a/example/ruby/OpenSSL/PKey/RSA.md b/example/ruby/OpenSSL/PKey/RSA.md deleted file mode 100644 index bf224da..0000000 --- a/example/ruby/OpenSSL/PKey/RSA.md +++ /dev/null @@ -1,297 +0,0 @@ -# Class: OpenSSL::PKey::RSA -**Inherits:** OpenSSL::PKey::PKey - -**Includes:** OpenSSL::Marshal - - -RSA is an asymmetric public key algorithm that has been formalized in RFC -3447. It is in widespread use in public key infrastructures (PKI) where -certificates (cf. OpenSSL::X509::Certificate) often are issued on the basis of -a public/private RSA key pair. RSA is used in a wide field of applications -such as secure (symmetric) key exchange, e.g. when establishing a secure -TLS/SSL connection. It is also used in various digital signature schemes. - - -# Class Methods -## generate(size , exp 0x10001, &blk ) [](#method-c-generate) -:call-seq: - RSA.generate(size, exponent = 65537) -> RSA - -Generates an RSA keypair. - -See also OpenSSL::PKey.generate_key. - -`size` -: The desired key size in bits. - -`exponent` -: An odd Integer, normally 3, 17, or 65537. - -## new(*args , &blk ) [](#method-c-new) -Handle RSA.new(size, exponent) form here; new(str) and new() forms are handled -by #initialize - -#Instance Methods -## _dump(_level) [](#method-i-_dump) - -## export(*args) [](#method-i-export) -Serializes a private or public key to a PEM-encoding. - -When the key contains public components only -: Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher* - and *password* are ignored. - - A PEM-encoded key will look like: - - -----BEGIN PUBLIC KEY----- - [...] - -----END PUBLIC KEY----- - - Consider using #public_to_pem instead. This serializes the key into an - X.509 SubjectPublicKeyInfo regardless of whether the key is a public key - or a private key. - - -When the key contains private components, and no parameters are given -: Serializes it into a PKCS #1 RSAPrivateKey. - - A PEM-encoded key will look like: - - -----BEGIN RSA PRIVATE KEY----- - [...] - -----END RSA PRIVATE KEY----- - - -When the key contains private components, and *cipher* and *password* are given -: Serializes it into a PKCS #1 RSAPrivateKey and encrypts it in OpenSSL's - traditional PEM encryption format. *cipher* must be a cipher name - understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher. - - An encrypted PEM-encoded key will look like: - - -----BEGIN RSA PRIVATE KEY----- - Proc-Type: 4,ENCRYPTED - DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0 - - [...] - -----END RSA PRIVATE KEY----- - - Note that this format uses MD5 to derive the encryption key, and hence - will not be available on FIPS-compliant systems. - - -**This method is kept for compatibility.** This should only be used when the -PKCS #1 RSAPrivateKey format is required. - -Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem -(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Generates or loads an RSA keypair. - -If called without arguments, creates a new instance with no key components -set. They can be set individually by #set_key, #set_factors, and -#set_crt_params. - -If called with a String, tries to parse as DER or PEM encoding of an RSA key. -Note that if *password* is not specified, but the key is encrypted with a -password, OpenSSL will prompt for it. See also OpenSSL::PKey.read which can -parse keys of any kind. - -If called with a number, generates a new key pair. This form works as an alias -of RSA.generate. - -Examples: - OpenSSL::PKey::RSA.new 2048 - OpenSSL::PKey::RSA.new File.read 'rsa.pem' - OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my password' - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## params() [](#method-i-params) -THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!! - -Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd', -'p', 'q', 'dmp1', 'dmq1', 'iqmp'. - -Don't use :-)) (It's up to you) - -**@overload** [] - -## private?() [](#method-i-private?) -Does this keypair contain a private key? - -**@overload** [] - -**@return** [Boolean] - -## private_decrypt(data, paddingPKCS1_PADDING) [](#method-i-private_decrypt) -:call-seq: - rsa.private_decrypt(string) -> String - rsa.private_decrypt(string, padding) -> String - -Decrypt `string`, which has been encrypted with the public key, with the -private key. `padding` defaults to PKCS1_PADDING, which is known to be -insecure but is kept for backwards compatibility. - -**Deprecated in version 3.0**. Consider using PKey::PKey#encrypt and -PKey::PKey#decrypt instead. - -## private_encrypt(string, paddingPKCS1_PADDING) [](#method-i-private_encrypt) -:call-seq: - rsa.private_encrypt(string) -> String - rsa.private_encrypt(string, padding) -> String - -Encrypt `string` with the private key. `padding` defaults to PKCS1_PADDING, -which is known to be insecure but is kept for backwards compatibility. The -encrypted string output can be decrypted using #public_decrypt. - -**Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and -PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead. - -## public?() [](#method-i-public?) -The return value is always `true` since every private key is also a public -key. - -**@overload** [] - -## public_decrypt(string, paddingPKCS1_PADDING) [](#method-i-public_decrypt) -:call-seq: - rsa.public_decrypt(string) -> String - rsa.public_decrypt(string, padding) -> String - -Decrypt `string`, which has been encrypted with the private key, with the -public key. `padding` defaults to PKCS1_PADDING which is known to be insecure -but is kept for backwards compatibility. - -**Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and -PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead. - -## public_encrypt(data, paddingPKCS1_PADDING) [](#method-i-public_encrypt) -:call-seq: - rsa.public_encrypt(string) -> String - rsa.public_encrypt(string, padding) -> String - -Encrypt `string` with the public key. `padding` defaults to PKCS1_PADDING, -which is known to be insecure but is kept for backwards compatibility. The -encrypted string output can be decrypted using #private_decrypt. - -**Deprecated in version 3.0**. Consider using PKey::PKey#encrypt and -PKey::PKey#decrypt instead. - -## public_key() [](#method-i-public_key) -:call-seq: - rsa.public_key -> rsanew - -Returns a new RSA instance that carries just the public key components. - -This method is provided for backwards compatibility. In most cases, there is -no need to call this method. - -For the purpose of serializing the public key, to PEM or DER encoding of X.509 -SubjectPublicKeyInfo format, check PKey#public_to_pem and PKey#public_to_der. - -## set_crt_params() [](#method-i-set_crt_params) -Sets *dmp1*, *dmq1*, *iqmp* for the RSA instance. They are calculated by `d -mod (p - 1)`, `d mod (q - 1)` and `q^(-1) mod p` respectively. - -**@overload** [] - -## set_factors() [](#method-i-set_factors) -Sets *p*, *q* for the RSA instance. - -**@overload** [] - -## set_key() [](#method-i-set_key) -Sets *n*, *e*, *d* for the RSA instance. - -**@overload** [] - -## sign_pss(*args) [](#method-i-sign_pss) -Signs *data* using the Probabilistic Signature Scheme (RSA-PSS) and returns -the calculated signature. - -RSAError will be raised if an error occurs. - -See #verify_pss for the verification operation. - -### Parameters -*digest* -: A String containing the message digest algorithm name. - -*data* -: A String. The data to be signed. - -*salt_length* -: The length in octets of the salt. Two special values are reserved: - `:digest` means the digest length, and `:max` means the maximum possible - length for the combination of the private key and the selected message - digest algorithm. - -*mgf1_hash* -: The hash algorithm used in MGF1 (the currently supported mask generation - function (MGF)). - - -### Example - data = "Sign me!" - pkey = OpenSSL::PKey::RSA.new(2048) - signature = pkey.sign_pss("SHA256", data, salt_length: :max, mgf1_hash: "SHA256") - pub_key = OpenSSL::PKey.read(pkey.public_to_der) - puts pub_key.verify_pss("SHA256", signature, data, - salt_length: :auto, mgf1_hash: "SHA256") # => true - -**@overload** [] - -## to_der() [](#method-i-to_der) -Serializes a private or public key to a DER-encoding. - -See #to_pem for details. - -**This method is kept for compatibility.** This should only be used when the -PKCS #1 RSAPrivateKey format is required. - -Consider using #public_to_der or #private_to_der instead. - -**@overload** [] - -## verify_pss(*args) [](#method-i-verify_pss) -Verifies *data* using the Probabilistic Signature Scheme (RSA-PSS). - -The return value is `true` if the signature is valid, `false` otherwise. -RSAError will be raised if an error occurs. - -See #sign_pss for the signing operation and an example code. - -### Parameters -*digest* -: A String containing the message digest algorithm name. - -*data* -: A String. The data to be signed. - -*salt_length* -: The length in octets of the salt. Two special values are reserved: - `:digest` means the digest length, and `:auto` means automatically - determining the length based on the signature. - -*mgf1_hash* -: The hash algorithm used in MGF1. - - -**@overload** [] - diff --git a/example/ruby/OpenSSL/PKey/RSAError.md b/example/ruby/OpenSSL/PKey/RSAError.md deleted file mode 100644 index c59e8db..0000000 --- a/example/ruby/OpenSSL/PKey/RSAError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: OpenSSL::PKey::RSAError -**Inherits:** OpenSSL::PKey::PKeyError - - -Generic exception that is raised if an operation on an RSA PKey fails -unexpectedly or in case an instantiation of an instance of RSA fails due to -non-conformant input data. - - - diff --git a/example/ruby/OpenSSL/PKeyTestCase.md b/example/ruby/OpenSSL/PKeyTestCase.md deleted file mode 100644 index cd97cf8..0000000 --- a/example/ruby/OpenSSL/PKeyTestCase.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: OpenSSL::PKeyTestCase -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## check_component(base, test, keys) [](#method-i-check_component) - diff --git a/example/ruby/OpenSSL/Provider.md b/example/ruby/OpenSSL/Provider.md deleted file mode 100644 index 17b1e44..0000000 --- a/example/ruby/OpenSSL/Provider.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: OpenSSL::Provider -**Inherits:** Object - - -This class is the access to openssl's Provider See also, -https://www.openssl.org/docs/manmaster/man7/provider.html - - -# Class Methods -## load(name ) [](#method-c-load) -This method loads and initializes a provider -**@overload** [] - -## provider_names() [](#method-c-provider_names) -Returns an array of currently loaded provider names. -**@overload** [] - - -#Instance Methods -## inspect() [](#method-i-inspect) -Pretty prints this provider. - -**@overload** [] - -## name() [](#method-i-name) -Get the name of this provider. - -if this provider is already unloaded, it raises -OpenSSL::Provider::ProviderError - -**@overload** [] - -## unload() [](#method-i-unload) -This method unloads this provider. - -if provider unload fails or already unloaded, it raises -OpenSSL::Provider::ProviderError - -**@overload** [] - diff --git a/example/ruby/OpenSSL/Provider/ProviderError.md b/example/ruby/OpenSSL/Provider/ProviderError.md deleted file mode 100644 index 8d754ff..0000000 --- a/example/ruby/OpenSSL/Provider/ProviderError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OpenSSL::Provider::ProviderError -**Inherits:** OpenSSL::OpenSSLError - - -This is the generic exception for OpenSSL::Provider related errors - - - diff --git a/example/ruby/OpenSSL/Random.md b/example/ruby/OpenSSL/Random.md deleted file mode 100644 index 7da941b..0000000 --- a/example/ruby/OpenSSL/Random.md +++ /dev/null @@ -1,67 +0,0 @@ -# Module: OpenSSL::Random - - - - -# Class Methods -## egd(filename ) [](#method-c-egd) -Same as ::egd_bytes but queries 255 bytes by default. -**@overload** [] - -## egd_bytes(filename , len ) [](#method-c-egd_bytes) -Queries the entropy gathering daemon EGD on socket path given by *filename*. - -Fetches *length* number of bytes and uses ::add to seed the OpenSSL built-in -PRNG. -**@overload** [] - -## load_random_file(filename ) [](#method-c-load_random_file) -Reads bytes from *filename* and adds them to the PRNG. -**@overload** [] - -## random_add(str , entropy ) [](#method-c-random_add) -Mixes the bytes from *str* into the Pseudo Random Number Generator(PRNG) -state. - -Thus, if the data from *str* are unpredictable to an adversary, this increases -the uncertainty about the state and makes the PRNG output less predictable. - -The *entropy* argument is (the lower bound of) an estimate of how much -randomness is contained in *str*, measured in bytes. - -### Example - - pid = $$ - now = Time.now - ary = [now.to_i, now.nsec, 1000, pid] - OpenSSL::Random.add(ary.join, 0.0) - OpenSSL::Random.seed(ary.join) -**@overload** [] - -## random_bytes(len ) [](#method-c-random_bytes) -random_bytes(length) -> string - -Generates a String with *length* number of cryptographically strong -pseudo-random bytes. - -### Example - - OpenSSL::Random.random_bytes(12) - #=> "..." -## seed(str ) [](#method-c-seed) -::seed is equivalent to ::add where *entropy* is length of *str*. -**@overload** [] - -## status?() [](#method-c-status?) -Return `true` if the PRNG has been seeded with enough data, `false` otherwise. -**@overload** [] - -**@return** [Boolean] - -## write_random_file(filename ) [](#method-c-write_random_file) -Writes a number of random generated bytes (currently 1024) to *filename* which -can be used to initialize the PRNG by calling ::load_random_file in a later -session. -**@overload** [] - - diff --git a/example/ruby/OpenSSL/Random/RandomError.md b/example/ruby/OpenSSL/Random/RandomError.md deleted file mode 100644 index f355b88..0000000 --- a/example/ruby/OpenSSL/Random/RandomError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::Random::RandomError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/SSL.md b/example/ruby/OpenSSL/SSL.md deleted file mode 100644 index 7cca709..0000000 --- a/example/ruby/OpenSSL/SSL.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: OpenSSL::SSL - - -Use SSLContext to set up the parameters for a TLS (former SSL) connection. -Both client and server TLS connections are supported, SSLSocket and SSLServer -may be used in conjunction with an instance of SSLContext to set up -connections. - - -# Class Methods -## verify_certificate_identity(cert , hostname ) [](#method-c-verify_certificate_identity) -## verify_hostname(hostname , san ) [](#method-c-verify_hostname) -:nodoc: -## verify_wildcard(domain_component , san_component ) [](#method-c-verify_wildcard) -:nodoc: - diff --git a/example/ruby/OpenSSL/SSL/SSLContext.md b/example/ruby/OpenSSL/SSL/SSLContext.md deleted file mode 100644 index 34ce54c..0000000 --- a/example/ruby/OpenSSL/SSL/SSLContext.md +++ /dev/null @@ -1,344 +0,0 @@ -# Class: OpenSSL::SSL::SSLContext -**Inherits:** Object - - -An SSLContext is used to set various options regarding certificates, -algorithms, verification, session caching, etc. The SSLContext is used to -create an SSLSocket. - -All attributes must be set before creating an SSLSocket as the SSLContext will -be frozen afterward. - - -# Attributes -## servername_cb[RW] [](#attribute-i-servername_cb) -A callback invoked at connect time to distinguish between multiple server -names. - -The callback is invoked with an SSLSocket and a server name. The callback -must return an SSLContext for the server name or nil. - -## tmp_dh_callback[RW] [](#attribute-i-tmp_dh_callback) -A callback invoked when DH parameters are required for ephemeral DH key -exchange. - -The callback is invoked with the SSLSocket, a flag indicating the use of an -export cipher and the keylength required. - -The callback must return an OpenSSL::PKey::DH instance of the correct key -length. - -**Deprecated in version 3.0.** Use #tmp_dh= instead. - - -#Instance Methods -## add_certificate(*args) [](#method-i-add_certificate) -Adds a certificate to the context. *pkey* must be a corresponding private key -with *certificate*. - -Multiple certificates with different public key type can be added by repeated -calls of this method, and OpenSSL will choose the most appropriate certificate -during the handshake. - -#cert=, #key=, and #extra_chain_cert= are old accessor methods for setting -certificate and internally call this method. - -### Parameters -*certificate* -: A certificate. An instance of OpenSSL::X509::Certificate. - -*pkey* -: The private key for *certificate*. An instance of OpenSSL::PKey::PKey. - -*extra_certs* -: Optional. An array of OpenSSL::X509::Certificate. When sending a - certificate chain, the certificates specified by this are sent following - *certificate*, in the order in the array. - - -### Example - rsa_cert = OpenSSL::X509::Certificate.new(...) - rsa_pkey = OpenSSL::PKey.read(...) - ca_intermediate_cert = OpenSSL::X509::Certificate.new(...) - ctx.add_certificate(rsa_cert, rsa_pkey, [ca_intermediate_cert]) - - ecdsa_cert = ... - ecdsa_pkey = ... - another_ca_cert = ... - ctx.add_certificate(ecdsa_cert, ecdsa_pkey, [another_ca_cert]) - -**@overload** [] - -## ciphers() [](#method-i-ciphers) -The list of cipher suites configured for this context. - -**@overload** [] - -## ciphers=(v) [](#method-i-ciphers=) -ctx.ciphers = [name, ...] - ctx.ciphers = [[name, version, bits, alg_bits], ...] - -Sets the list of available cipher suites for this context. Note in a server -context some ciphers require the appropriate certificates. For example, an -RSA cipher suite can only be chosen when an RSA certificate is available. - -## ciphersuites=(v) [](#method-i-ciphersuites=) -ctx.ciphersuites = [name, ...] - ctx.ciphersuites = [[name, version, bits, alg_bits], ...] - -Sets the list of available TLSv1.3 cipher suites for this context. - -## ecdh_curves=(arg) [](#method-i-ecdh_curves=) -Sets the list of "supported elliptic curves" for this context. - -For a TLS client, the list is directly used in the Supported Elliptic Curves -Extension. For a server, the list is used by OpenSSL to determine the set of -shared curves. OpenSSL will pick the most appropriate one from it. - -### Example - ctx1 = OpenSSL::SSL::SSLContext.new - ctx1.ecdh_curves = "X25519:P-256:P-224" - svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx1) - Thread.new { svr.accept } - - ctx2 = OpenSSL::SSL::SSLContext.new - ctx2.ecdh_curves = "P-256" - cli = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx2) - cli.connect - - p cli.tmp_key.group.curve_name - # => "prime256v1" (is an alias for NIST P-256) - -**@overload** [] - -## enable_fallback_scsv() [](#method-i-enable_fallback_scsv) -Activate TLS_FALLBACK_SCSV for this context. See RFC 7507. - -**@overload** [] - -## flush_sessions(*args) [](#method-i-flush_sessions) -Removes sessions in the internal cache that have expired at *time*. - -**@overload** [] - -## initialize(versionnil) [](#method-i-initialize) -call-seq: - SSLContext.new -> ctx - SSLContext.new(:TLSv1) -> ctx - SSLContext.new("SSLv23") -> ctx - -Creates a new SSL context. - -If an argument is given, #ssl_version= is called with the value. Note that -this form is deprecated. New applications should use #min_version= and -#max_version= as necessary. - -**@return** [SSLContext] a new instance of SSLContext - -## max_version=(version) [](#method-i-max_version=) -call-seq: - ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION - ctx.max_version = :TLS1_2 - ctx.max_version = nil - -Sets the upper bound of the supported SSL/TLS protocol version. See -#min_version= for the possible values. - -## min_version=(version) [](#method-i-min_version=) -call-seq: - ctx.min_version = OpenSSL::SSL::TLS1_2_VERSION - ctx.min_version = :TLS1_2 - ctx.min_version = nil - -Sets the lower bound on the supported SSL/TLS protocol version. The version -may be specified by an integer constant named OpenSSL::SSL::*_VERSION, a -Symbol, or `nil` which means "any version". - -Be careful that you don't overwrite OpenSSL::SSL::OP_NO_{SSL,TLS}v* options by -#options= once you have called #min_version= or #max_version=. - -### Example - ctx = OpenSSL::SSL::SSLContext.new - ctx.min_version = OpenSSL::SSL::TLS1_1_VERSION - ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION - - sock = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx) - sock.connect # Initiates a connection using either TLS 1.1 or TLS 1.2 - -## options() [](#method-i-options) -Gets various OpenSSL options. - -**@overload** [] - -## options=(options) [](#method-i-options=) -Sets various OpenSSL options. The options are a bit field and can be combined -with the bitwise OR operator (`|`). Available options are defined as constants -in OpenSSL::SSL that begin with `OP_`. - -For backwards compatibility, passing `nil` has the same effect as passing -OpenSSL::SSL::OP_ALL. - -See also man page SSL_CTX_set_options(3). - -**@overload** [] - -## security_level() [](#method-i-security_level) -Returns the security level for the context. - -See also OpenSSL::SSL::SSLContext#security_level=. - -**@overload** [] - -## security_level=(value) [](#method-i-security_level=) -Sets the security level for the context. OpenSSL limits parameters according -to the level. The "parameters" include: ciphersuites, curves, key sizes, -certificate signature algorithms, protocol version and so on. For example, -level 1 rejects parameters offering below 80 bits of security, such as -ciphersuites using MD5 for the MAC or RSA keys shorter than 1024 bits. - -Note that attempts to set such parameters with insufficient security are also -blocked. You need to lower the level first. - -This feature is not supported in OpenSSL < 1.1.0, and setting the level to -other than 0 will raise NotImplementedError. Level 0 means everything is -permitted, the same behavior as previous versions of OpenSSL. - -See the manpage of SSL_CTX_set_security_level(3) for details. - -**@overload** [] - -## session_add(arg) [](#method-i-session_add) -Adds *session* to the session cache. - -**@overload** [] - -## session_cache_mode() [](#method-i-session_cache_mode) -The current session cache mode. - -**@overload** [] - -## session_cache_mode=(arg) [](#method-i-session_cache_mode=) -Sets the SSL session cache mode. Bitwise-or together the desired -SESSION_CACHE_* constants to set. See SSL_CTX_set_session_cache_mode(3) for -details. - -**@overload** [] - -## session_cache_size() [](#method-i-session_cache_size) -Returns the current session cache size. Zero is used to represent an -unlimited cache size. - -**@overload** [] - -## session_cache_size=(arg) [](#method-i-session_cache_size=) -Sets the session cache size. Returns the previously valid session cache size. - Zero is used to represent an unlimited session cache size. - -**@overload** [] - -## session_cache_stats() [](#method-i-session_cache_stats) -Returns a Hash containing the following keys: - -:accept -: Number of started SSL/TLS handshakes in server mode - -:accept_good -: Number of established SSL/TLS sessions in server mode - -:accept_renegotiate -: Number of start renegotiations in server mode - -:cache_full -: Number of sessions that were removed due to cache overflow - -:cache_hits -: Number of successfully reused connections - -:cache_misses -: Number of sessions proposed by clients that were not found - - in the cache - -:cache_num -: Number of sessions in the internal session cache - -:cb_hits -: Number of sessions retrieved from the external cache in server - - mode - -:connect -: Number of started SSL/TLS handshakes in client mode - -:connect_good -: Number of established SSL/TLS sessions in client mode - -:connect_renegotiate -: Number of start renegotiations in client mode - -:timeouts -: Number of sessions proposed by clients that were found in the - - cache but had expired due to timeouts - -**@overload** [] - -## session_remove(arg) [](#method-i-session_remove) -Removes *session* from the session cache. - -**@overload** [] - -## set_params(params{}) [](#method-i-set_params) -call-seq: - ctx.set_params(params = {}) -> params - -Sets saner defaults optimized for the use with HTTP-like protocols. - -If a Hash *params* is given, the parameters are overridden with it. The keys -in *params* must be assignment methods on SSLContext. - -If the verify_mode is not VERIFY_NONE and ca_file, ca_path and cert_store are -not set then the system default certificate store is used. - -## setup() [](#method-i-setup) -This method is called automatically when a new SSLSocket is created. However, -it is not thread-safe and must be called before creating SSLSocket objects in -a multi-threaded program. - -**@overload** [] - -**@overload** [] - -## ssl_version=(meth) [](#method-i-ssl_version=) -call-seq: - ctx.ssl_version = :TLSv1 - ctx.ssl_version = "SSLv23" - -Sets the SSL/TLS protocol version for the context. This forces connections to -use only the specified protocol version. This is deprecated and only provided -for backwards compatibility. Use #min_version= and #max_version= instead. - -### History -As the name hints, this used to call the SSL_CTX_set_ssl_version() function -which sets the SSL method used for connections created from the context. As of -Ruby/OpenSSL 2.1, this accessor method is implemented to call #min_version= -and #max_version= instead. - -## tmp_dh=(arg) [](#method-i-tmp_dh=) -Sets DH parameters used for ephemeral DH key exchange. This is relevant for -servers only. - -`pkey` is an instance of OpenSSL::PKey::DH. Note that key components contained -in the key object, if any, are ignored. The server will always generate a new -key pair for each handshake. - -Added in version 3.0. See also the man page SSL_set0_tmp_dh_pkey(3). - -Example: - ctx = OpenSSL::SSL::SSLContext.new - ctx.tmp_dh = OpenSSL::DH.generate(2048) - svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx) - Thread.new { svr.accept } - -**@overload** [] - diff --git a/example/ruby/OpenSSL/SSL/SSLError.md b/example/ruby/OpenSSL/SSL/SSLError.md deleted file mode 100644 index df8985a..0000000 --- a/example/ruby/OpenSSL/SSL/SSLError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OpenSSL::SSL::SSLError -**Inherits:** OpenSSL::OpenSSLError - - -Generic error class raised by SSLSocket and SSLContext. - - - diff --git a/example/ruby/OpenSSL/SSL/SSLErrorWaitReadable.md b/example/ruby/OpenSSL/SSL/SSLErrorWaitReadable.md deleted file mode 100644 index 4df2d5a..0000000 --- a/example/ruby/OpenSSL/SSL/SSLErrorWaitReadable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: OpenSSL::SSL::SSLErrorWaitReadable -**Inherits:** OpenSSL::SSL::SSLError - -**Includes:** IO::WaitReadable - - - - - diff --git a/example/ruby/OpenSSL/SSL/SSLErrorWaitWritable.md b/example/ruby/OpenSSL/SSL/SSLErrorWaitWritable.md deleted file mode 100644 index 609449b..0000000 --- a/example/ruby/OpenSSL/SSL/SSLErrorWaitWritable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: OpenSSL::SSL::SSLErrorWaitWritable -**Inherits:** OpenSSL::SSL::SSLError - -**Includes:** IO::WaitWritable - - - - - diff --git a/example/ruby/OpenSSL/SSL/SSLServer.md b/example/ruby/OpenSSL/SSL/SSLServer.md deleted file mode 100644 index 087fa2f..0000000 --- a/example/ruby/OpenSSL/SSL/SSLServer.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: OpenSSL::SSL::SSLServer -**Inherits:** Object - -**Includes:** OpenSSL::SSL::SocketForwarder - - -SSLServer represents a TCP/IP server socket with Secure Sockets Layer. - - -# Attributes -## start_immediately[RW] [](#attribute-i-start_immediately) -When true then #accept works exactly the same as TCPServer#accept - - -#Instance Methods -## accept() [](#method-i-accept) -Works similar to TCPServer#accept. - -## addr() [](#method-i-addr) - -## close() [](#method-i-close) -See IO#close for details. - -## close_on_exec=(value) [](#method-i-close_on_exec=) - -## close_on_exec?() [](#method-i-close_on_exec?) - -**@return** [Boolean] - -## closed?() [](#method-i-closed?) - -**@return** [Boolean] - -## do_not_reverse_lookup=(flag) [](#method-i-do_not_reverse_lookup=) - -## fcntl(*args) [](#method-i-fcntl) - -## fileno() [](#method-i-fileno) -The file descriptor for the socket. - -## getsockopt(level, optname) [](#method-i-getsockopt) - -## initialize(svr, ctx) [](#method-i-initialize) -Creates a new instance of SSLServer. -* *srv* is an instance of TCPServer. -* *ctx* is an instance of OpenSSL::SSL::SSLContext. - -**@return** [SSLServer] a new instance of SSLServer - -## listen(backlogSocket::SOMAXCONN) [](#method-i-listen) -See TCPServer#listen for details. - -## local_address() [](#method-i-local_address) - -## peeraddr() [](#method-i-peeraddr) - -## remote_address() [](#method-i-remote_address) - -## setsockopt(level, optname, optval) [](#method-i-setsockopt) - -## shutdown(howSocket::SHUT_RDWR) [](#method-i-shutdown) -See BasicSocket#shutdown for details. - -## timeout() [](#method-i-timeout) - -## timeout=(value) [](#method-i-timeout=) - -## to_io() [](#method-i-to_io) -Returns the TCPServer passed to the SSLServer when initialized. - -## wait(*args) [](#method-i-wait) - -## wait_readable(*args) [](#method-i-wait_readable) - -## wait_writable(*args) [](#method-i-wait_writable) - diff --git a/example/ruby/OpenSSL/SSL/SSLSocket.md b/example/ruby/OpenSSL/SSL/SSLSocket.md deleted file mode 100644 index 57145a5..0000000 --- a/example/ruby/OpenSSL/SSL/SSLSocket.md +++ /dev/null @@ -1,2543 +0,0 @@ -# Class: OpenSSL::SSL::SSLSocket -**Inherits:** Object - -**Includes:** OpenSSL::Buffering, OpenSSL::SSL::SocketForwarder - - - - -# Class Methods -## open(remote_host , remote_port , local_host nil, local_port nil, context: nil) [](#method-c-open) -call-seq: - open(remote_host, remote_port, local_host=nil, local_port=nil, context: nil) - -Creates a new instance of SSLSocket. *remote*host_ and *remote*port_ are used -to open TCPSocket. If *local*host_ and *local*port_ are specified, then those -parameters are used on the local end to establish the connection. If *context* -is provided, the SSL Sockets initial params will be taken from the context. - -### Examples - - sock = OpenSSL::SSL::SSLSocket.open('localhost', 443) - sock.connect # Initiates a connection to localhost:443 - -with SSLContext: - - ctx = OpenSSL::SSL::SSLContext.new - sock = OpenSSL::SSL::SSLSocket.open('localhost', 443, context: ctx) - sock.connect # Initiates a connection to localhost:443 with SSLContext -# Attributes -## context[RW] [](#attribute-i-context) -The SSLContext object used in this connection. - -## hostname[RW] [](#attribute-i-hostname) -Returns the value of attribute hostname. - -## io[RW] [](#attribute-i-io) -The underlying IO object. - -## sync_close[RW] [](#attribute-i-sync_close) -Whether to close the underlying socket as well, when the SSL/TLS connection is -shut down. This defaults to `false`. - - -#Instance Methods -## <<(s) [](#method-i-<<) -Writes *s* to the stream. *s* will be converted to a String using `.to_s` -method. - -## accept() [](#method-i-accept) -Waits for a SSL/TLS client to initiate a handshake. - -**@overload** [] - -## accept_nonblock(*args) [](#method-i-accept_nonblock) -Initiates the SSL/TLS handshake as a server in non-blocking manner. - - # emulates blocking accept - begin - ssl.accept_nonblock - rescue IO::WaitReadable - IO.select([s2]) - retry - rescue IO::WaitWritable - IO.select(nil, [s2]) - retry - end - -By specifying a keyword argument *exception* to `false`, you can indicate that -accept_nonblock should not raise an IO::WaitReadable or IO::WaitWritable -exception, but return the symbol `:wait_readable` or `:wait_writable` instead. - -**@overload** [] - -## addr() [](#method-i-addr) - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## alpn_protocol() [](#method-i-alpn_protocol) -Returns the ALPN protocol string that was finally selected by the server -during the handshake. - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cert() [](#method-i-cert) -The X509 certificate for this socket endpoint. - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## cipher() [](#method-i-cipher) -Returns the cipher suite actually used in the current session, or nil if no -session has been established. - -**@overload** [] - -## client_ca() [](#method-i-client_ca) -Returns the list of client CAs. Please note that in contrast to -SSLContext#client_ca= no array of X509::Certificate is returned but X509::Name -instances of the CA's subject distinguished name. - -In server mode, returns the list set by SSLContext#client_ca=. In client mode, -returns the list of client CAs sent from the server. - -**@overload** [] - -## close() [](#method-i-close) -Closes the SSLSocket and flushes any unwritten data. - -## close_on_exec=(value) [](#method-i-close_on_exec=) - -## close_on_exec?() [](#method-i-close_on_exec?) - -**@return** [Boolean] - -## close_read() [](#method-i-close_read) -Close the stream for reading. This method is ignored by OpenSSL as there is no -reasonable way to implement it, but exists for compatibility with IO. - -## close_write() [](#method-i-close_write) -Closes the stream for writing. The behavior of this method depends on the -version of OpenSSL and the TLS protocol in use. - -* Sends a 'close_notify' alert to the peer. -* Does not wait for the peer's 'close_notify' alert in response. - -In TLS 1.2 and earlier: -* On receipt of a 'close_notify' alert, responds with a 'close_notify' alert - of its own and close down the connection immediately, discarding any - pending writes. - -Therefore, on TLS 1.2, this method will cause the connection to be completely -shut down. On TLS 1.3, the connection will remain open for reading only. - -## closed?() [](#method-i-closed?) - -**@return** [Boolean] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## connect() [](#method-i-connect) -Initiates an SSL/TLS handshake with a server. - -**@overload** [] - -## connect_nonblock(*args) [](#method-i-connect_nonblock) -Initiates the SSL/TLS handshake as a client in non-blocking manner. - - # emulates blocking connect - begin - ssl.connect_nonblock - rescue IO::WaitReadable - IO.select([s2]) - retry - rescue IO::WaitWritable - IO.select(nil, [s2]) - retry - end - -By specifying a keyword argument *exception* to `false`, you can indicate that -connect_nonblock should not raise an IO::WaitReadable or IO::WaitWritable -exception, but return the symbol `:wait_readable` or `:wait_writable` instead. - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## do_not_reverse_lookup=(flag) [](#method-i-do_not_reverse_lookup=) - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(eol$/) [](#method-i-each) -Executes the block for every line in the stream where lines are separated by -*eol*. - -See also #gets - -## each_byte() [](#method-i-each_byte) -Calls the given block once for each byte in the stream. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eof?() [](#method-i-eof?) -Returns true if the stream is at file which means there is no more data to be -read. - -**@return** [Boolean] - -## export_keying_material(*args) [](#method-i-export_keying_material) -Enables use of shared session key material in accordance with RFC 5705. - -**@overload** [] - -## fcntl(*args) [](#method-i-fcntl) - -## fileno() [](#method-i-fileno) -The file descriptor for the socket. - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## finished_message() [](#method-i-finished_message) -Returns the last **Finished** message sent - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flush() [](#method-i-flush) -Flushes buffered data to the SSLSocket. - -## getbyte() [](#method-i-getbyte) -call-seq: - ssl.getbyte => 81 - -Get the next 8bit byte from `ssl`. Returns `nil` on EOF - -## getc() [](#method-i-getc) -Reads one character from the stream. Returns nil if called at end of file. - -## gets(eol$/, limitnil, chomp:false) [](#method-i-gets) -Reads the next "line" from the stream. Lines are separated by *eol*. If -*limit* is provided the result will not be longer than the given number of -bytes. - -*eol* may be a String or Regexp. - -Unlike IO#gets the line read will not be assigned to +$_+. - -Unlike IO#gets the separator must be provided if a limit is provided. - -## getsockopt(level, optname) [](#method-i-getsockopt) - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new SSL socket from *io* which must be a real IO object (not an -IO-like object that responds to read/write). - -If *ctx* is provided the SSL Sockets initial params will be taken from the -context. - -The OpenSSL::Buffering module provides additional IO methods. - -This method will freeze the SSLContext if one is provided; however, session -management is still allowed in the frozen SSLContext. - -**@overload** [] - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## local_address() [](#method-i-local_address) - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## npn_protocol() [](#method-i-npn_protocol) -Returns the protocol string that was finally selected by the client during the -handshake. - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## peer_cert() [](#method-i-peer_cert) -The X509 certificate for this socket's peer. - -**@overload** [] - -## peer_cert_chain() [](#method-i-peer_cert_chain) -The X509 certificate chain for this socket's peer. - -**@overload** [] - -## peer_finished_message() [](#method-i-peer_finished_message) -Returns the last **Finished** message received - -**@overload** [] - -## peeraddr() [](#method-i-peeraddr) - -## pending() [](#method-i-pending) -The number of bytes that are immediately available for reading. - -**@overload** [] - -## post_connection_check(hostname) [](#method-i-post_connection_check) -call-seq: - ssl.post_connection_check(hostname) -> true - -Perform hostname verification following RFC 6125. - -This method MUST be called after calling #connect to ensure that the hostname -of a remote peer has been verified. - -## print(*args) [](#method-i-print) -Writes *args* to the stream. - -See IO#print for full details. - -## printf(s, *args) [](#method-i-printf) -Formats and writes to the stream converting parameters under control of the -format string. - -See Kernel#sprintf for format string details. - -## puts(*args) [](#method-i-puts) -Writes *args* to the stream along with a record separator. - -See IO#puts for full details. - -## read(sizenil, bufnil) [](#method-i-read) -Reads *size* bytes from the stream. If *buf* is provided it must reference a -string which will receive the data. - -See IO#read for full details. - -## read_nonblock(maxlen, bufnil, exception:true) [](#method-i-read_nonblock) -Reads at most *maxlen* bytes in the non-blocking manner. - -When no data can be read without blocking it raises OpenSSL::SSL::SSLError -extended by IO::WaitReadable or IO::WaitWritable. - -IO::WaitReadable means SSL needs to read internally so read_nonblock should be -called again when the underlying IO is readable. - -IO::WaitWritable means SSL needs to write internally so read_nonblock should -be called again after the underlying IO is writable. - -OpenSSL::Buffering#read_nonblock needs two rescue clause as follows: - - # emulates blocking read (readpartial). - begin - result = ssl.read_nonblock(maxlen) - rescue IO::WaitReadable - IO.select([io]) - retry - rescue IO::WaitWritable - IO.select(nil, [io]) - retry - end - -Note that one reason that read_nonblock writes to the underlying IO is when -the peer requests a new TLS/SSL handshake. See openssl the FAQ for more -details. http://www.openssl.org/support/faq.html - -By specifying a keyword argument *exception* to `false`, you can indicate that -read_nonblock should not raise an IO::Wait*able exception, but return the -symbol `:wait_writable` or `:wait_readable` instead. At EOF, it will return -`nil` instead of raising EOFError. - -## readbyte() [](#method-i-readbyte) -Get the next 8bit byte. Raises EOFError on EOF - -**@raise** [EOFError] - -## readchar() [](#method-i-readchar) -Reads a one-character string from the stream. Raises an EOFError at end of -file. - -**@raise** [EOFError] - -## readline(eol$/) [](#method-i-readline) -Reads a line from the stream which is separated by *eol*. - -Raises EOFError if at end of file. - -**@raise** [EOFError] - -## readlines(eol$/) [](#method-i-readlines) -Reads lines from the stream which are separated by *eol*. - -See also #gets - -## readpartial(maxlen, bufnil) [](#method-i-readpartial) -Reads at most *maxlen* bytes from the stream. If *buf* is provided it must -reference a string which will receive the data. - -See IO#readpartial for full details. - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## remote_address() [](#method-i-remote_address) - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## session() [](#method-i-session) -call-seq: - ssl.session -> aSession - -Returns the SSLSession object currently used, or nil if the session is not -established. - -## session=(arg1) [](#method-i-session=) -Sets the Session to be used when the connection is established. - -**@overload** [] - -## session_reused?() [](#method-i-session_reused?) -Returns `true` if a reused session was negotiated during the handshake. - -**@overload** [] - -**@return** [Boolean] - -## setsockopt(level, optname, optval) [](#method-i-setsockopt) - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## ssl_version() [](#method-i-ssl_version) -Returns a String representing the SSL/TLS version that was negotiated for the -connection, for example "TLSv1.2". - -**@overload** [] - -## state() [](#method-i-state) -A description of the current connection state. This is for diagnostic purposes -only. - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## sysclose() [](#method-i-sysclose) -call-seq: - ssl.sysclose => nil - -Sends "close notify" to the peer and tries to shut down the SSL connection -gracefully. - -If sync_close is set to `true`, the underlying IO is also closed. - -## sysread(*args) [](#method-i-sysread) -Reads *length* bytes from the SSL connection. If a pre-allocated *buffer* is -provided the data will be written into it. - -**@overload** [] - -**@overload** [] - -## syswrite(str) [](#method-i-syswrite) -Writes *string* to the SSL connection. - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## timeout() [](#method-i-timeout) - -## timeout=(value) [](#method-i-timeout=) - -## tmp_key() [](#method-i-tmp_key) -Returns the ephemeral key used in case of forward secrecy cipher. - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## ungetc(c) [](#method-i-ungetc) -Pushes character *c* back onto the stream such that a subsequent buffered -character read will return it. - -Unlike IO#getc multiple bytes may be pushed back onto the stream. - -Has no effect on unbuffered reads (such as #sysread). - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## verify_result() [](#method-i-verify_result) -Returns the result of the peer certificates verification. See verify(1) for -error values and descriptions. - -If no peer certificate was presented X509_V_OK is returned. - -**@overload** [] - -## wait(*args) [](#method-i-wait) - -## wait_readable(*args) [](#method-i-wait_readable) - -## wait_writable(*args) [](#method-i-wait_writable) - -## write(*s) [](#method-i-write) -Writes *s* to the stream. If the argument is not a String it will be -converted using `.to_s` method. Returns the number of bytes written. - -## write_nonblock(s, exception:true) [](#method-i-write_nonblock) -Writes *s* in the non-blocking manner. - -If there is buffered data, it is flushed first. This may block. - -write_nonblock returns number of bytes written to the SSL connection. - -When no data can be written without blocking it raises OpenSSL::SSL::SSLError -extended by IO::WaitReadable or IO::WaitWritable. - -IO::WaitReadable means SSL needs to read internally so write_nonblock should -be called again after the underlying IO is readable. - -IO::WaitWritable means SSL needs to write internally so write_nonblock should -be called again after underlying IO is writable. - -So OpenSSL::Buffering#write_nonblock needs two rescue clause as follows. - - # emulates blocking write. - begin - result = ssl.write_nonblock(str) - rescue IO::WaitReadable - IO.select([io]) - retry - rescue IO::WaitWritable - IO.select(nil, [io]) - retry - end - -Note that one reason that write_nonblock reads from the underlying IO is when -the peer requests a new TLS/SSL handshake. See the openssl FAQ for more -details. http://www.openssl.org/support/faq.html - -By specifying a keyword argument *exception* to `false`, you can indicate that -write_nonblock should not raise an IO::Wait*able exception, but return the -symbol `:wait_writable` or `:wait_readable` instead. - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/OpenSSL/SSL/Session.md b/example/ruby/OpenSSL/SSL/Session.md deleted file mode 100644 index 6c29367..0000000 --- a/example/ruby/OpenSSL/SSL/Session.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: OpenSSL::SSL::Session -**Inherits:** Object - - - - - -#Instance Methods -## ==(val2) [](#method-i-==) -Returns `true` if the two Session is the same, `false` if not. - -**@overload** [] - -## id() [](#method-i-id) -Returns the Session ID. - -**@overload** [] - -## initialize(arg1) [](#method-i-initialize) -Creates a new Session object from an instance of SSLSocket or DER/PEM encoded -String. - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## time() [](#method-i-time) -Returns the time at which the session was established. - -**@overload** [] - -## time=(time_v) [](#method-i-time=) -Sets start time of the session. Time resolution is in seconds. - -**@overload** [] - -**@overload** [] - -## timeout() [](#method-i-timeout) -Returns the timeout value set for the session, in seconds from the established -time. - -**@overload** [] - -## timeout=(time_v) [](#method-i-timeout=) -Sets how long until the session expires in seconds. - -**@overload** [] - -## to_der() [](#method-i-to_der) -Returns an ASN1 encoded String that contains the Session object. - -**@overload** [] - -## to_pem() [](#method-i-to_pem) -Returns a PEM encoded String that contains the Session object. - -**@overload** [] - -## to_text() [](#method-i-to_text) -Shows everything in the Session object. This is for diagnostic purposes. - -**@overload** [] - diff --git a/example/ruby/OpenSSL/SSL/Session/SessionError.md b/example/ruby/OpenSSL/SSL/Session/SessionError.md deleted file mode 100644 index 12226c2..0000000 --- a/example/ruby/OpenSSL/SSL/Session/SessionError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::SSL::Session::SessionError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/SSL/SocketForwarder.md b/example/ruby/OpenSSL/SSL/SocketForwarder.md deleted file mode 100644 index b78b6f3..0000000 --- a/example/ruby/OpenSSL/SSL/SocketForwarder.md +++ /dev/null @@ -1,46 +0,0 @@ -# Module: OpenSSL::SSL::SocketForwarder - - - - - -#Instance Methods -## addr() [](#method-i-addr) - -## close_on_exec=(value) [](#method-i-close_on_exec=) - -## close_on_exec?() [](#method-i-close_on_exec?) - -**@return** [Boolean] - -## closed?() [](#method-i-closed?) - -**@return** [Boolean] - -## do_not_reverse_lookup=(flag) [](#method-i-do_not_reverse_lookup=) - -## fcntl(*args) [](#method-i-fcntl) - -## fileno() [](#method-i-fileno) -The file descriptor for the socket. - -## getsockopt(level, optname) [](#method-i-getsockopt) - -## local_address() [](#method-i-local_address) - -## peeraddr() [](#method-i-peeraddr) - -## remote_address() [](#method-i-remote_address) - -## setsockopt(level, optname, optval) [](#method-i-setsockopt) - -## timeout() [](#method-i-timeout) - -## timeout=(value) [](#method-i-timeout=) - -## wait(*args) [](#method-i-wait) - -## wait_readable(*args) [](#method-i-wait_readable) - -## wait_writable(*args) [](#method-i-wait_writable) - diff --git a/example/ruby/OpenSSL/SSLPair.md b/example/ruby/OpenSSL/SSLPair.md deleted file mode 100644 index 20cb17e..0000000 --- a/example/ruby/OpenSSL/SSLPair.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: OpenSSL::SSLPair - -**Includes:** OpenSSL::SSLPairM - - - - - -#Instance Methods -## create_tcp_client(host, port) [](#method-i-create_tcp_client) - -## create_tcp_server(host, port) [](#method-i-create_tcp_server) - -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - diff --git a/example/ruby/OpenSSL/SSLPairLowlevelSocket.md b/example/ruby/OpenSSL/SSLPairLowlevelSocket.md deleted file mode 100644 index 251cda3..0000000 --- a/example/ruby/OpenSSL/SSLPairLowlevelSocket.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: OpenSSL::SSLPairLowlevelSocket - -**Includes:** OpenSSL::SSLPairM - - - - - -#Instance Methods -## create_tcp_client(host, port) [](#method-i-create_tcp_client) - -## create_tcp_server(host, port) [](#method-i-create_tcp_server) - -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - diff --git a/example/ruby/OpenSSL/SSLPairM.md b/example/ruby/OpenSSL/SSLPairM.md deleted file mode 100644 index 3062b95..0000000 --- a/example/ruby/OpenSSL/SSLPairM.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: OpenSSL::SSLPairM - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - diff --git a/example/ruby/OpenSSL/SSLTestCase.md b/example/ruby/OpenSSL/SSLTestCase.md deleted file mode 100644 index b871ec1..0000000 --- a/example/ruby/OpenSSL/SSLTestCase.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: OpenSSL::SSLTestCase -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## readwrite_loop(ctx, ssl) [](#method-i-readwrite_loop) - -## setup() [](#method-i-setup) - -## start_server(verify_mode:OpenSSL::SSL::VERIFY_NONE, start_immediately:true, ctx_proc:nil, server_proc:method(:readwrite_loop), accept_proc:proc{}, ignore_listener_error:false, &block) [](#method-i-start_server) - -## tls13_supported?() [](#method-i-tls13_supported?) - -**@return** [Boolean] - diff --git a/example/ruby/OpenSSL/TestASN1.md b/example/ruby/OpenSSL/TestASN1.md deleted file mode 100644 index 8228ef5..0000000 --- a/example/ruby/OpenSSL/TestASN1.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: OpenSSL::TestASN1 -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_basic_asn1data() [](#method-i-test_basic_asn1data) - -## test_basic_constructed() [](#method-i-test_basic_constructed) - -## test_basic_primitive() [](#method-i-test_basic_primitive) - -## test_bitstring() [](#method-i-test_bitstring) - -## test_boolean() [](#method-i-test_boolean) - -## test_cons_explicit_tagging() [](#method-i-test_cons_explicit_tagging) - -## test_cons_implicit_tagging() [](#method-i-test_cons_implicit_tagging) - -## test_constructive_each() [](#method-i-test_constructive_each) - -## test_decode_all() [](#method-i-test_decode_all) - -## test_decode_constructed_overread() [](#method-i-test_decode_constructed_overread) - -## test_decode_x509_certificate() [](#method-i-test_decode_x509_certificate) - -## test_end_of_content() [](#method-i-test_end_of_content) - -## test_enumerated() [](#method-i-test_enumerated) - -## test_generalizedtime() [](#method-i-test_generalizedtime) - -## test_integer() [](#method-i-test_integer) - -## test_null() [](#method-i-test_null) - -## test_object_id_register() [](#method-i-test_object_id_register) - -## test_object_identifier() [](#method-i-test_object_identifier) - -## test_object_identifier_equality() [](#method-i-test_object_identifier_equality) - -## test_octet_string_constructed_tagging() [](#method-i-test_octet_string_constructed_tagging) - -## test_prim_explicit_tagging() [](#method-i-test_prim_explicit_tagging) - -## test_prim_implicit_tagging() [](#method-i-test_prim_implicit_tagging) - -## test_recursive_octet_string_indefinite_length() [](#method-i-test_recursive_octet_string_indefinite_length) - -## test_recursive_octet_string_parse() [](#method-i-test_recursive_octet_string_parse) - -## test_sequence() [](#method-i-test_sequence) - -## test_set() [](#method-i-test_set) - -## test_string_basic() [](#method-i-test_string_basic) - -## test_utctime() [](#method-i-test_utctime) - diff --git a/example/ruby/OpenSSL/TestBN.md b/example/ruby/OpenSSL/TestBN.md deleted file mode 100644 index db0ddd9..0000000 --- a/example/ruby/OpenSSL/TestBN.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: OpenSSL::TestBN -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abs() [](#method-i-test_abs) - -## test_argument_error() [](#method-i-test_argument_error) - -## test_bit_operations() [](#method-i-test_bit_operations) - -## test_coerce() [](#method-i-test_coerce) - -## test_comparison() [](#method-i-test_comparison) - -## test_exp() [](#method-i-test_exp) - -## test_four_ops() [](#method-i-test_four_ops) - -## test_gcd() [](#method-i-test_gcd) - -## test_get_flags_and_set_flags() [](#method-i-test_get_flags_and_set_flags) - -## test_mod() [](#method-i-test_mod) - -## test_mod_add() [](#method-i-test_mod_add) - -## test_mod_exp() [](#method-i-test_mod_exp) - -## test_mod_inverse() [](#method-i-test_mod_inverse) - -## test_mod_mul() [](#method-i-test_mod_mul) - -## test_mod_sqr() [](#method-i-test_mod_sqr) - -## test_mod_sqrt() [](#method-i-test_mod_sqrt) - -## test_mod_sub() [](#method-i-test_mod_sub) - -## test_negative_p() [](#method-i-test_negative_p) - -## test_new() [](#method-i-test_new) - -## test_num_bits_bytes() [](#method-i-test_num_bits_bytes) - -## test_odd_p() [](#method-i-test_odd_p) - -## test_one_p() [](#method-i-test_one_p) - -## test_ractor() [](#method-i-test_ractor) - -## test_random() [](#method-i-test_random) - -## test_sqr() [](#method-i-test_sqr) - -## test_to_int() [](#method-i-test_to_int) - -## test_to_str() [](#method-i-test_to_str) - -## test_unary_plus_minus() [](#method-i-test_unary_plus_minus) - -## test_zero_p() [](#method-i-test_zero_p) - diff --git a/example/ruby/OpenSSL/TestBuffering.md b/example/ruby/OpenSSL/TestBuffering.md deleted file mode 100644 index ee7ffb6..0000000 --- a/example/ruby/OpenSSL/TestBuffering.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: OpenSSL::TestBuffering -**Inherits:** OpenSSL::TestCase - - - - -# Class Methods -## syswrite(*a ) [](#method-c-syswrite) -**@raise** [SystemCallError] - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_each_byte() [](#method-i-test_each_byte) - -## test_encoding() [](#method-i-test_encoding) - -## test_flush() [](#method-i-test_flush) - -## test_flush_error() [](#method-i-test_flush_error) - -## test_getc() [](#method-i-test_getc) - diff --git a/example/ruby/OpenSSL/TestBuffering/IO.md b/example/ruby/OpenSSL/TestBuffering/IO.md deleted file mode 100644 index 907a86a..0000000 --- a/example/ruby/OpenSSL/TestBuffering/IO.md +++ /dev/null @@ -1,2265 +0,0 @@ -# Class: OpenSSL::TestBuffering::IO -**Inherits:** Object - -**Includes:** OpenSSL::Buffering - - - - -# Class Methods -## sync() [](#method-c-sync) -# Attributes -## sync[RW] [](#attribute-i-sync) -Returns the value of attribute sync. - - -#Instance Methods -## <<(s) [](#method-i-<<) -Writes *s* to the stream. *s* will be converted to a String using `.to_s` -method. - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## close() [](#method-i-close) -Closes the SSLSocket and flushes any unwritten data. - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(eol$/) [](#method-i-each) -Executes the block for every line in the stream where lines are separated by -*eol*. - -See also #gets - -## each_byte() [](#method-i-each_byte) -Calls the given block once for each byte in the stream. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eof?() [](#method-i-eof?) -Returns true if the stream is at file which means there is no more data to be -read. - -**@return** [Boolean] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flush() [](#method-i-flush) -Flushes buffered data to the SSLSocket. - -## getbyte() [](#method-i-getbyte) -call-seq: - ssl.getbyte => 81 - -Get the next 8bit byte from `ssl`. Returns `nil` on EOF - -## getc() [](#method-i-getc) -Reads one character from the stream. Returns nil if called at end of file. - -## gets(eol$/, limitnil, chomp:false) [](#method-i-gets) -Reads the next "line" from the stream. Lines are separated by *eol*. If -*limit* is provided the result will not be longer than the given number of -bytes. - -*eol* may be a String or Regexp. - -Unlike IO#gets the line read will not be assigned to +$_+. - -Unlike IO#gets the separator must be provided if a limit is provided. - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) - -**@return** [IO] a new instance of IO - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## print(*args) [](#method-i-print) -Writes *args* to the stream. - -See IO#print for full details. - -## printf(s, *args) [](#method-i-printf) -Formats and writes to the stream converting parameters under control of the -format string. - -See Kernel#sprintf for format string details. - -## puts(*args) [](#method-i-puts) -Writes *args* to the stream along with a record separator. - -See IO#puts for full details. - -## read(sizenil, bufnil) [](#method-i-read) -Reads *size* bytes from the stream. If *buf* is provided it must reference a -string which will receive the data. - -See IO#read for full details. - -## read_nonblock(maxlen, bufnil, exception:true) [](#method-i-read_nonblock) -Reads at most *maxlen* bytes in the non-blocking manner. - -When no data can be read without blocking it raises OpenSSL::SSL::SSLError -extended by IO::WaitReadable or IO::WaitWritable. - -IO::WaitReadable means SSL needs to read internally so read_nonblock should be -called again when the underlying IO is readable. - -IO::WaitWritable means SSL needs to write internally so read_nonblock should -be called again after the underlying IO is writable. - -OpenSSL::Buffering#read_nonblock needs two rescue clause as follows: - - # emulates blocking read (readpartial). - begin - result = ssl.read_nonblock(maxlen) - rescue IO::WaitReadable - IO.select([io]) - retry - rescue IO::WaitWritable - IO.select(nil, [io]) - retry - end - -Note that one reason that read_nonblock writes to the underlying IO is when -the peer requests a new TLS/SSL handshake. See openssl the FAQ for more -details. http://www.openssl.org/support/faq.html - -By specifying a keyword argument *exception* to `false`, you can indicate that -read_nonblock should not raise an IO::Wait*able exception, but return the -symbol `:wait_writable` or `:wait_readable` instead. At EOF, it will return -`nil` instead of raising EOFError. - -## readbyte() [](#method-i-readbyte) -Get the next 8bit byte. Raises EOFError on EOF - -**@raise** [EOFError] - -## readchar() [](#method-i-readchar) -Reads a one-character string from the stream. Raises an EOFError at end of -file. - -**@raise** [EOFError] - -## readline(eol$/) [](#method-i-readline) -Reads a line from the stream which is separated by *eol*. - -Raises EOFError if at end of file. - -**@raise** [EOFError] - -## readlines(eol$/) [](#method-i-readlines) -Reads lines from the stream which are separated by *eol*. - -See also #gets - -## readpartial(maxlen, bufnil) [](#method-i-readpartial) -Reads at most *maxlen* bytes from the stream. If *buf* is provided it must -reference a string which will receive the data. - -See IO#readpartial for full details. - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## string() [](#method-i-string) - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## sysread(size) [](#method-i-sysread) - -**@raise** [EOFError] - -## syswrite(str) [](#method-i-syswrite) - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## ungetc(c) [](#method-i-ungetc) -Pushes character *c* back onto the stream such that a subsequent buffered -character read will return it. - -Unlike IO#getc multiple bytes may be pushed back onto the stream. - -Has no effect on unbuffered reads (such as #sysread). - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## write(*s) [](#method-i-write) -Writes *s* to the stream. If the argument is not a String it will be -converted using `.to_s` method. Returns the number of bytes written. - -## write_nonblock(s, exception:true) [](#method-i-write_nonblock) -Writes *s* in the non-blocking manner. - -If there is buffered data, it is flushed first. This may block. - -write_nonblock returns number of bytes written to the SSL connection. - -When no data can be written without blocking it raises OpenSSL::SSL::SSLError -extended by IO::WaitReadable or IO::WaitWritable. - -IO::WaitReadable means SSL needs to read internally so write_nonblock should -be called again after the underlying IO is readable. - -IO::WaitWritable means SSL needs to write internally so write_nonblock should -be called again after underlying IO is writable. - -So OpenSSL::Buffering#write_nonblock needs two rescue clause as follows. - - # emulates blocking write. - begin - result = ssl.write_nonblock(str) - rescue IO::WaitReadable - IO.select([io]) - retry - rescue IO::WaitWritable - IO.select(nil, [io]) - retry - end - -Note that one reason that write_nonblock reads from the underlying IO is when -the peer requests a new TLS/SSL handshake. See the openssl FAQ for more -details. http://www.openssl.org/support/faq.html - -By specifying a keyword argument *exception* to `false`, you can indicate that -write_nonblock should not raise an IO::Wait*able exception, but return the -symbol `:wait_writable` or `:wait_readable` instead. - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/OpenSSL/TestCase.md b/example/ruby/OpenSSL/TestCase.md deleted file mode 100644 index 8ce3465..0000000 --- a/example/ruby/OpenSSL/TestCase.md +++ /dev/null @@ -1,194 +0,0 @@ -# Class: OpenSSL::TestCase -**Inherits:** Test::Unit::TestCase - -**Extended by:** OpenSSL::TestUtils - -**Includes:** OpenSSL::TestUtils, Test::Unit::CoreAssertions - - - - - -#Instance Methods -## assert(test, *msgs) [](#method-i-assert) -:call-seq: - assert(test, [failure_message]) - -Tests if `test` is true. - -`msg` may be a String or a Proc. If `msg` is a String, it will be used as the -failure message. Otherwise, the result of calling `msg` will be used as the -message if the assertion fails. - -If no `msg` is given, a default message will be used. - - assert(false, "This was expected to be true") - -## assert_all?(obj, mnil, &blk) [](#method-i-assert_all?) - -**@return** [Boolean] - -## assert_all_assertions(msgnil) [](#method-i-assert_all_assertions) - -## assert_all_assertions_foreach(msgnil, *keys, &block) [](#method-i-assert_all_assertions_foreach) - -## assert_deprecated_warn(mesg/deprecated/) [](#method-i-assert_deprecated_warn) - -## assert_deprecated_warning(mesg/deprecated/) [](#method-i-assert_deprecated_warning) - -## assert_file() [](#method-i-assert_file) - -## assert_in_out_err(args, test_stdin"", test_stdout[], test_stderr[], messagenil, success:nil, **opt) [](#method-i-assert_in_out_err) - -## assert_join_threads(threads, messagenil) [](#method-i-assert_join_threads) -threads should respond to shift method. Array can be used. - -## assert_linear_performance(seq, rehearsal:nil, pre:->(n) {n}) [](#method-i-assert_linear_performance) -Expect `seq` to respond to `first` and `each` methods, e.g., Array, Range, -Enumerator::ArithmeticSequence and other Enumerable-s, and each elements -should be size factors. - -:yield: each elements of `seq`. - -## assert_no_memory_leak(args, prepare, code, messagenil, limit:2.0, rss:false, **opt) [](#method-i-assert_no_memory_leak) - -## assert_normal_exit(testsrc, message'', child_env:nil, **opt) [](#method-i-assert_normal_exit) - -## assert_not_respond_to(obj, meth, *priv, msgnil) [](#method-i-assert_not_respond_to) -:call-seq: - assert_not_respond_to( object, method, failure_message = nil ) - -Tests if the given Object does not respond to `method`. - -An optional failure message may be provided as the final argument. - - assert_not_respond_to("hello", :reverse) #Fails - assert_not_respond_to("hello", :does_not_exist) #Succeeds - -## assert_nothing_raised(*args) [](#method-i-assert_nothing_raised) -:call-seq: - assert_nothing_raised( *args, &block ) - -If any exceptions are given as arguments, the assertion will fail if one of -those exceptions are raised. Otherwise, the test fails if any exceptions are -raised. - -The final argument may be a failure message. - - assert_nothing_raised RuntimeError do - raise Exception #Assertion passes, Exception is not a RuntimeError - end - - assert_nothing_raised do - raise Exception #Assertion fails - end - -## assert_pattern_list(pattern_list, actual, messagenil) [](#method-i-assert_pattern_list) -pattern_list is an array which contains regexp, string and :*. :* means any -sequence. - -pattern_list is anchored. Use [:*, regexp/string, :*] for non-anchored match. - -## assert_ractor(src, args:[], require:nil, require_relative:nil, file:nil, line:nil, ignore_stderr:nil, **opt) [](#method-i-assert_ractor) -Run Ractor-related test without influencing the main test suite - -## assert_raise(*exp, &b) [](#method-i-assert_raise) -:call-seq: - assert_raise( *args, &block ) - -Tests if the given block raises an exception. Acceptable exception types may -be given as optional arguments. If the last argument is a String, it will be -used as the error message. - - assert_raise do #Fails, no Exceptions are raised - end - - assert_raise NameError do - puts x #Raises NameError, so assertion succeeds - end - -## assert_raise_with_message(exception, expected, msgnil, &block) [](#method-i-assert_raise_with_message) -:call-seq: - assert_raise_with_message(exception, expected, msg = nil, &block) - -Tests if the given block raises an exception with the expected message. - - assert_raise_with_message(RuntimeError, "foo") do - nil #Fails, no Exceptions are raised - end - - assert_raise_with_message(RuntimeError, "foo") do - raise ArgumentError, "foo" #Fails, different Exception is raised - end - - assert_raise_with_message(RuntimeError, "foo") do - raise "bar" #Fails, RuntimeError is raised but the message differs - end - - assert_raise_with_message(RuntimeError, "foo") do - raise "foo" #Raises RuntimeError with the message, so assertion succeeds - end - -## assert_respond_to(obj, meth, *priv, msgnil) [](#method-i-assert_respond_to) -:call-seq: - assert_respond_to( object, method, failure_message = nil ) - -Tests if the given Object responds to `method`. - -An optional failure message may be provided as the final argument. - - assert_respond_to("hello", :reverse) #Succeeds - assert_respond_to("hello", :does_not_exist) #Fails - -## assert_ruby_status(args, test_stdin"", messagenil, **opt) [](#method-i-assert_ruby_status) - -## assert_separately(args, filenil, linenil, src, ignore_stderr:nil, **opt) [](#method-i-assert_separately) - -## assert_throw(tag, msgnil) [](#method-i-assert_throw) -:call-seq: - assert_throw( tag, failure_message = nil, &block ) - -Fails unless the given block throws `tag`, returns the caught value otherwise. - -An optional failure message may be provided as the final argument. - - tag = Object.new - assert_throw(tag, "#{tag} was not thrown!") do - throw tag - end - -## assert_valid_syntax(code, *args, **opt) [](#method-i-assert_valid_syntax) - -## assert_warn(*args) [](#method-i-assert_warn) - -## assert_warning(pat, msgnil) [](#method-i-assert_warning) - -## diff(exp, act) [](#method-i-diff) - -## mu_pp(obj) [](#method-i-mu_pp) -:nodoc: - -## new_test_token() [](#method-i-new_test_token) - -## omit_on_fips() [](#method-i-omit_on_fips) -Omit the tests in FIPS. - -For example, the password based encryption used in the PEM format uses MD5 for -deriving the encryption key from the password, and MD5 is not FIPS-approved. - -See -https://github.com/openssl/openssl/discussions/21830#discussioncomment-6865636 -for details. - -## omit_on_non_fips() [](#method-i-omit_on_non_fips) - -## prepare_syntax_check(code, fnamenil, mesgnil, verbose:nil) [](#method-i-prepare_syntax_check) - -## separated_runner(token, outnil) [](#method-i-separated_runner) - -## setup() [](#method-i-setup) - -## syntax_check(code, fname, line) [](#method-i-syntax_check) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/OpenSSL/TestCipher.md b/example/ruby/OpenSSL/TestCipher.md deleted file mode 100644 index 2f332ed..0000000 --- a/example/ruby/OpenSSL/TestCipher.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: OpenSSL::TestCipher -**Inherits:** OpenSSL::TestCase - -**Extended by:** OpenSSL::TestCipher::Helper - -**Includes:** OpenSSL::TestCipher::Helper - - - - -# Class Methods -## has_cipher?(name ) [](#method-c-has_cipher?) -**@return** [Boolean] - - -#Instance Methods -## has_cipher?(name) [](#method-i-has_cipher?) - -**@return** [Boolean] - -## test_AES() [](#method-i-test_AES) - -## test_aes_ccm() [](#method-i-test_aes_ccm) - -## test_aes_gcm() [](#method-i-test_aes_gcm) - -## test_aes_gcm_key_iv_order_issue() [](#method-i-test_aes_gcm_key_iv_order_issue) - -## test_aes_gcm_variable_iv_len() [](#method-i-test_aes_gcm_variable_iv_len) - -## test_aes_keywrap_pad() [](#method-i-test_aes_keywrap_pad) - -## test_aes_ocb_tag_len() [](#method-i-test_aes_ocb_tag_len) - -## test_authenticated() [](#method-i-test_authenticated) - -## test_ciphers() [](#method-i-test_ciphers) - -## test_crypt_after_key() [](#method-i-test_crypt_after_key) - -## test_ctr_if_exists() [](#method-i-test_ctr_if_exists) - -## test_dup() [](#method-i-test_dup) - -## test_encrypt_decrypt() [](#method-i-test_encrypt_decrypt) - -## test_info() [](#method-i-test_info) - -## test_initialize() [](#method-i-test_initialize) - -## test_key_iv_set() [](#method-i-test_key_iv_set) - -## test_non_aead_cipher_set_auth_data() [](#method-i-test_non_aead_cipher_set_auth_data) - -## test_pkcs5_keyivgen() [](#method-i-test_pkcs5_keyivgen) - -## test_random_key_iv() [](#method-i-test_random_key_iv) - -## test_reset() [](#method-i-test_reset) - -## test_update_raise_if_key_not_set() [](#method-i-test_update_raise_if_key_not_set) - -## test_update_with_buffer() [](#method-i-test_update_with_buffer) - diff --git a/example/ruby/OpenSSL/TestCipher/Helper.md b/example/ruby/OpenSSL/TestCipher/Helper.md deleted file mode 100644 index 9c9d0fc..0000000 --- a/example/ruby/OpenSSL/TestCipher/Helper.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: OpenSSL::TestCipher::Helper - - - - - -#Instance Methods -## has_cipher?(name) [](#method-i-has_cipher?) - -**@return** [Boolean] - diff --git a/example/ruby/OpenSSL/TestConfig.md b/example/ruby/OpenSSL/TestConfig.md deleted file mode 100644 index 1f958e0..0000000 --- a/example/ruby/OpenSSL/TestConfig.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: OpenSSL::TestConfig -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_aref() [](#method-i-test_aref) - -## test_constants() [](#method-i-test_constants) - -## test_dup() [](#method-i-test_dup) - -## test_each() [](#method-i-test_each) - -## test_get_value() [](#method-i-test_get_value) - -## test_get_value_ENV() [](#method-i-test_get_value_ENV) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_with_empty_file() [](#method-i-test_initialize_with_empty_file) - -## test_initialize_with_example_file() [](#method-i-test_initialize_with_example_file) - -## test_inspect() [](#method-i-test_inspect) - -## test_ractor() [](#method-i-test_ractor) - -## test_s_load() [](#method-i-test_s_load) - -## test_s_parse() [](#method-i-test_s_parse) - -## test_s_parse_config() [](#method-i-test_s_parse_config) - -## test_s_parse_format() [](#method-i-test_s_parse_format) - -## test_s_parse_include() [](#method-i-test_s_parse_include) - -## test_sections() [](#method-i-test_sections) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/OpenSSL/TestDigest.md b/example/ruby/OpenSSL/TestDigest.md deleted file mode 100644 index 0dd3279..0000000 --- a/example/ruby/OpenSSL/TestDigest.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: OpenSSL::TestDigest -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## encode16(str) [](#method-i-encode16) - -## setup() [](#method-i-setup) - -## test_digest() [](#method-i-test_digest) - -## test_digest_by_oid_and_name() [](#method-i-test_digest_by_oid_and_name) - -## test_digest_by_oid_and_name_sha2() [](#method-i-test_digest_by_oid_and_name_sha2) - -## test_digest_constants() [](#method-i-test_digest_constants) - -## test_digests() [](#method-i-test_digests) - -## test_dup() [](#method-i-test_dup) - -## test_eql() [](#method-i-test_eql) - -## test_info() [](#method-i-test_info) - -## test_openssl_digest() [](#method-i-test_openssl_digest) - -## test_reset() [](#method-i-test_reset) - -## test_sha2() [](#method-i-test_sha2) - -## test_sha3() [](#method-i-test_sha3) - -## test_sha512_truncate() [](#method-i-test_sha512_truncate) - diff --git a/example/ruby/OpenSSL/TestEC.md b/example/ruby/OpenSSL/TestEC.md deleted file mode 100644 index 663e849..0000000 --- a/example/ruby/OpenSSL/TestEC.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: OpenSSL::TestEC -**Inherits:** OpenSSL::PKeyTestCase - - - - - -#Instance Methods -## test_ECPrivateKey() [](#method-i-test_ECPrivateKey) - -## test_ECPrivateKey_encrypted() [](#method-i-test_ECPrivateKey_encrypted) - -## test_ECPrivateKey_with_parameters() [](#method-i-test_ECPrivateKey_with_parameters) - -## test_PUBKEY() [](#method-i-test_PUBKEY) - -## test_builtin_curves() [](#method-i-test_builtin_curves) - -## test_check_key() [](#method-i-test_check_key) - -## test_derive_key() [](#method-i-test_derive_key) - -## test_dh_compute_key() [](#method-i-test_dh_compute_key) - -## test_dsa_sign_asn1_FIPS186_3() [](#method-i-test_dsa_sign_asn1_FIPS186_3) - -## test_ec_group() [](#method-i-test_ec_group) - -## test_ec_key() [](#method-i-test_ec_key) - -## test_ec_point() [](#method-i-test_ec_point) - -## test_ec_point_add() [](#method-i-test_ec_point_add) - -## test_ec_point_mul() [](#method-i-test_ec_point_mul) - -## test_generate() [](#method-i-test_generate) - -## test_generate_key() [](#method-i-test_generate_key) - -## test_marshal() [](#method-i-test_marshal) - -## test_sign_verify() [](#method-i-test_sign_verify) - -## test_sign_verify_raw() [](#method-i-test_sign_verify_raw) - diff --git a/example/ruby/OpenSSL/TestEOF.md b/example/ruby/OpenSSL/TestEOF.md deleted file mode 100644 index 3a85eb8..0000000 --- a/example/ruby/OpenSSL/TestEOF.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: OpenSSL::TestEOF - - - - - -#Instance Methods -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - -## test_getbyte_eof() [](#method-i-test_getbyte_eof) - -## test_readbyte_eof() [](#method-i-test_readbyte_eof) - diff --git a/example/ruby/OpenSSL/TestEOF/Seek.md b/example/ruby/OpenSSL/TestEOF/Seek.md deleted file mode 100644 index df6c9c0..0000000 --- a/example/ruby/OpenSSL/TestEOF/Seek.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: OpenSSL::TestEOF::Seek - - - - - -#Instance Methods -## open_file_seek(content, pos) [](#method-i-open_file_seek) - -## test_eof_0_seek() [](#method-i-test_eof_0_seek) - -## test_eof_1_seek() [](#method-i-test_eof_1_seek) - diff --git a/example/ruby/OpenSSL/TestEOF1.md b/example/ruby/OpenSSL/TestEOF1.md deleted file mode 100644 index ae5780e..0000000 --- a/example/ruby/OpenSSL/TestEOF1.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: OpenSSL::TestEOF1 -**Inherits:** OpenSSL::TestCase - -**Includes:** OpenSSL::SSLPair, OpenSSL::TestEOF, OpenSSL::TestEOF1M - - - - - -#Instance Methods -## create_tcp_client(host, port) [](#method-i-create_tcp_client) - -## create_tcp_server(host, port) [](#method-i-create_tcp_server) - -## open_file(content) [](#method-i-open_file) - -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - -## test_getbyte_eof() [](#method-i-test_getbyte_eof) - -## test_readbyte_eof() [](#method-i-test_readbyte_eof) - diff --git a/example/ruby/OpenSSL/TestEOF1LowlevelSocket.md b/example/ruby/OpenSSL/TestEOF1LowlevelSocket.md deleted file mode 100644 index 0ef2e1d..0000000 --- a/example/ruby/OpenSSL/TestEOF1LowlevelSocket.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: OpenSSL::TestEOF1LowlevelSocket -**Inherits:** OpenSSL::TestCase - -**Includes:** OpenSSL::SSLPairLowlevelSocket, OpenSSL::TestEOF, OpenSSL::TestEOF1M - - - - - -#Instance Methods -## create_tcp_client(host, port) [](#method-i-create_tcp_client) - -## create_tcp_server(host, port) [](#method-i-create_tcp_server) - -## open_file(content) [](#method-i-open_file) - -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - -## test_getbyte_eof() [](#method-i-test_getbyte_eof) - -## test_readbyte_eof() [](#method-i-test_readbyte_eof) - diff --git a/example/ruby/OpenSSL/TestEOF1M.md b/example/ruby/OpenSSL/TestEOF1M.md deleted file mode 100644 index 1e1b43b..0000000 --- a/example/ruby/OpenSSL/TestEOF1M.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: OpenSSL::TestEOF1M - - - - - -#Instance Methods -## open_file(content) [](#method-i-open_file) - diff --git a/example/ruby/OpenSSL/TestEOF2.md b/example/ruby/OpenSSL/TestEOF2.md deleted file mode 100644 index 38b650d..0000000 --- a/example/ruby/OpenSSL/TestEOF2.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: OpenSSL::TestEOF2 -**Inherits:** OpenSSL::TestCase - -**Includes:** OpenSSL::SSLPair, OpenSSL::TestEOF, OpenSSL::TestEOF2M - - - - - -#Instance Methods -## create_tcp_client(host, port) [](#method-i-create_tcp_client) - -## create_tcp_server(host, port) [](#method-i-create_tcp_server) - -## open_file(content) [](#method-i-open_file) - -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - -## test_getbyte_eof() [](#method-i-test_getbyte_eof) - -## test_readbyte_eof() [](#method-i-test_readbyte_eof) - diff --git a/example/ruby/OpenSSL/TestEOF2LowlevelSocket.md b/example/ruby/OpenSSL/TestEOF2LowlevelSocket.md deleted file mode 100644 index 1304342..0000000 --- a/example/ruby/OpenSSL/TestEOF2LowlevelSocket.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: OpenSSL::TestEOF2LowlevelSocket -**Inherits:** OpenSSL::TestCase - -**Includes:** OpenSSL::SSLPairLowlevelSocket, OpenSSL::TestEOF, OpenSSL::TestEOF2M - - - - - -#Instance Methods -## create_tcp_client(host, port) [](#method-i-create_tcp_client) - -## create_tcp_server(host, port) [](#method-i-create_tcp_server) - -## open_file(content) [](#method-i-open_file) - -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - -## test_getbyte_eof() [](#method-i-test_getbyte_eof) - -## test_readbyte_eof() [](#method-i-test_readbyte_eof) - diff --git a/example/ruby/OpenSSL/TestEOF2M.md b/example/ruby/OpenSSL/TestEOF2M.md deleted file mode 100644 index 27597fc..0000000 --- a/example/ruby/OpenSSL/TestEOF2M.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: OpenSSL::TestEOF2M - - - - - -#Instance Methods -## open_file(content) [](#method-i-open_file) - diff --git a/example/ruby/OpenSSL/TestEngine.md b/example/ruby/OpenSSL/TestEngine.md deleted file mode 100644 index 7fba77a..0000000 --- a/example/ruby/OpenSSL/TestEngine.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: OpenSSL::TestEngine -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_engines_free() [](#method-i-test_engines_free) -ruby-dev:44173 -: - -## test_openssl_engine_builtin() [](#method-i-test_openssl_engine_builtin) - -## test_openssl_engine_by_id_string() [](#method-i-test_openssl_engine_by_id_string) - -## test_openssl_engine_cipher_rc4() [](#method-i-test_openssl_engine_cipher_rc4) - -## test_openssl_engine_digest_sha1() [](#method-i-test_openssl_engine_digest_sha1) - -## test_openssl_engine_id_name_inspect() [](#method-i-test_openssl_engine_id_name_inspect) - diff --git a/example/ruby/OpenSSL/TestFIPS.md b/example/ruby/OpenSSL/TestFIPS.md deleted file mode 100644 index 7ff7f40..0000000 --- a/example/ruby/OpenSSL/TestFIPS.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: OpenSSL::TestFIPS -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_fips_mode_get_is_false_on_fips_mode_disabled() [](#method-i-test_fips_mode_get_is_false_on_fips_mode_disabled) - -## test_fips_mode_get_is_true_on_fips_mode_enabled() [](#method-i-test_fips_mode_get_is_true_on_fips_mode_enabled) - -## test_fips_mode_get_with_fips_mode_set() [](#method-i-test_fips_mode_get_with_fips_mode_set) - -## test_fips_mode_is_reentrant() [](#method-i-test_fips_mode_is_reentrant) - diff --git a/example/ruby/OpenSSL/TestHMAC.md b/example/ruby/OpenSSL/TestHMAC.md deleted file mode 100644 index 63e5bcc..0000000 --- a/example/ruby/OpenSSL/TestHMAC.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: OpenSSL::TestHMAC -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_binary_update() [](#method-i-test_binary_update) - -## test_dup() [](#method-i-test_dup) - -## test_eq() [](#method-i-test_eq) - -## test_hmac() [](#method-i-test_hmac) - -## test_reset_keep_key() [](#method-i-test_reset_keep_key) - -## test_singleton_methods() [](#method-i-test_singleton_methods) - -## test_zero_length_key() [](#method-i-test_zero_length_key) - diff --git a/example/ruby/OpenSSL/TestKDF.md b/example/ruby/OpenSSL/TestKDF.md deleted file mode 100644 index 0a7a060..0000000 --- a/example/ruby/OpenSSL/TestKDF.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: OpenSSL::TestKDF -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_hkdf_rfc5869_test_case_1() [](#method-i-test_hkdf_rfc5869_test_case_1) - -## test_hkdf_rfc5869_test_case_3() [](#method-i-test_hkdf_rfc5869_test_case_3) - -## test_hkdf_rfc5869_test_case_4() [](#method-i-test_hkdf_rfc5869_test_case_4) - -## test_pbkdf2_hmac_sha1_rfc6070_c_1_len_20() [](#method-i-test_pbkdf2_hmac_sha1_rfc6070_c_1_len_20) - -## test_pbkdf2_hmac_sha1_rfc6070_c_2_len_20() [](#method-i-test_pbkdf2_hmac_sha1_rfc6070_c_2_len_20) - -## test_pbkdf2_hmac_sha1_rfc6070_c_4096_len_16() [](#method-i-test_pbkdf2_hmac_sha1_rfc6070_c_4096_len_16) - -## test_pbkdf2_hmac_sha1_rfc6070_c_4096_len_20() [](#method-i-test_pbkdf2_hmac_sha1_rfc6070_c_4096_len_20) - -## test_pbkdf2_hmac_sha1_rfc6070_c_4096_len_25() [](#method-i-test_pbkdf2_hmac_sha1_rfc6070_c_4096_len_25) -takes too long! - def test_pbkdf2_hmac_sha1_rfc6070_c_16777216_len_20 - p ="password" - s = "salt" - c = 16777216 - dk_len = 20 - raw = %w{ ee fe 3d 61 cd 4d a4 e4 - e9 94 5b 3d 6b a2 15 8c - 26 34 e9 84 } - expected = [raw.join('')].pack('H*') - value = OpenSSL::KDF.pbkdf2_hmac(p, salt: s, iterations: c, length: dk_len, hash: "sha1") - assert_equal(expected, value) - end - -## test_pbkdf2_hmac_sha256_c_20000_len_32() [](#method-i-test_pbkdf2_hmac_sha256_c_20000_len_32) - -## test_pkcs5_pbkdf2_hmac_compatibility() [](#method-i-test_pkcs5_pbkdf2_hmac_compatibility) - -## test_scrypt_rfc7914_first() [](#method-i-test_scrypt_rfc7914_first) - -## test_scrypt_rfc7914_second() [](#method-i-test_scrypt_rfc7914_second) - diff --git a/example/ruby/OpenSSL/TestNSSPI.md b/example/ruby/OpenSSL/TestNSSPI.md deleted file mode 100644 index 6bb865d..0000000 --- a/example/ruby/OpenSSL/TestNSSPI.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: OpenSSL::TestNSSPI -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_build_data() [](#method-i-test_build_data) - -## test_decode_data() [](#method-i-test_decode_data) - diff --git a/example/ruby/OpenSSL/TestOCSP.md b/example/ruby/OpenSSL/TestOCSP.md deleted file mode 100644 index 5afc429..0000000 --- a/example/ruby/OpenSSL/TestOCSP.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: OpenSSL::TestOCSP -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_basic_response_der() [](#method-i-test_basic_response_der) - -## test_basic_response_dup() [](#method-i-test_basic_response_dup) - -## test_basic_response_response_operations() [](#method-i-test_basic_response_response_operations) - -## test_basic_response_sign_verify() [](#method-i-test_basic_response_sign_verify) - -## test_certificate_id_der() [](#method-i-test_certificate_id_der) - -## test_certificate_id_dup() [](#method-i-test_certificate_id_dup) - -## test_certificate_id_hash_algorithm() [](#method-i-test_certificate_id_hash_algorithm) - -## test_certificate_id_issuer_key_hash() [](#method-i-test_certificate_id_issuer_key_hash) - -## test_certificate_id_issuer_name_hash() [](#method-i-test_certificate_id_issuer_name_hash) - -## test_new_certificate_id() [](#method-i-test_new_certificate_id) - -## test_request_der() [](#method-i-test_request_der) - -## test_request_dup() [](#method-i-test_request_dup) - -## test_request_is_signed() [](#method-i-test_request_is_signed) - -## test_request_nonce() [](#method-i-test_request_nonce) - -## test_request_sign_verify() [](#method-i-test_request_sign_verify) - -## test_response() [](#method-i-test_response) - -## test_response_der() [](#method-i-test_response_der) - -## test_response_dup() [](#method-i-test_response_dup) - -## test_single_response_check_validity() [](#method-i-test_single_response_check_validity) - -## test_single_response_der() [](#method-i-test_single_response_der) - diff --git a/example/ruby/OpenSSL/TestPKCS12.md b/example/ruby/OpenSSL/TestPKCS12.md deleted file mode 100644 index b1d4d57..0000000 --- a/example/ruby/OpenSSL/TestPKCS12.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: OpenSSL::TestPKCS12 -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_create_no_pass() [](#method-i-test_create_no_pass) - -## test_create_single_key_single_cert() [](#method-i-test_create_single_key_single_cert) - -## test_create_with_bad_nid() [](#method-i-test_create_with_bad_nid) - -## test_create_with_chain() [](#method-i-test_create_with_chain) - -## test_create_with_chain_decode() [](#method-i-test_create_with_chain_decode) - -## test_create_with_itr() [](#method-i-test_create_with_itr) - -## test_create_with_keytype() [](#method-i-test_create_with_keytype) - -## test_create_with_mac_itr() [](#method-i-test_create_with_mac_itr) - -## test_dup() [](#method-i-test_dup) - -## test_new_with_no_certs() [](#method-i-test_new_with_no_certs) - -## test_new_with_no_keys() [](#method-i-test_new_with_no_keys) - -## test_set_mac_pkcs12kdf() [](#method-i-test_set_mac_pkcs12kdf) - diff --git a/example/ruby/OpenSSL/TestPKCS7.md b/example/ruby/OpenSSL/TestPKCS7.md deleted file mode 100644 index 6812dc2..0000000 --- a/example/ruby/OpenSSL/TestPKCS7.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: OpenSSL::TestPKCS7 -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_degenerate_pkcs7() [](#method-i-test_degenerate_pkcs7) - -## test_detached_sign() [](#method-i-test_detached_sign) - -## test_empty_signed_data_ruby_bug_19974() [](#method-i-test_empty_signed_data_ruby_bug_19974) - -## test_enveloped() [](#method-i-test_enveloped) - -## test_graceful_parsing_failure() [](#method-i-test_graceful_parsing_failure) -ruby-core:43250 -: - -## test_set_type_data() [](#method-i-test_set_type_data) - -## test_set_type_encrypted() [](#method-i-test_set_type_encrypted) - -## test_set_type_enveloped() [](#method-i-test_set_type_enveloped) - -## test_set_type_signed() [](#method-i-test_set_type_signed) - -## test_set_type_signed_and_enveloped() [](#method-i-test_set_type_signed_and_enveloped) - -## test_signed() [](#method-i-test_signed) - -## test_signed_add_signer() [](#method-i-test_signed_add_signer) - -## test_smime() [](#method-i-test_smime) - -## test_split_content() [](#method-i-test_split_content) - -## test_to_text() [](#method-i-test_to_text) - diff --git a/example/ruby/OpenSSL/TestPKey.md b/example/ruby/OpenSSL/TestPKey.md deleted file mode 100644 index f8d554b..0000000 --- a/example/ruby/OpenSSL/TestPKey.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: OpenSSL::TestPKey -**Inherits:** OpenSSL::PKeyTestCase - - - - - -#Instance Methods -## raw_initialize() [](#method-i-raw_initialize) - -## test_compare?() [](#method-i-test_compare?) - -**@return** [Boolean] - -## test_ed25519() [](#method-i-test_ed25519) - -## test_generic_oid_inspect() [](#method-i-test_generic_oid_inspect) - -## test_hmac_sign_verify() [](#method-i-test_hmac_sign_verify) - -## test_s_generate_key() [](#method-i-test_s_generate_key) - -## test_s_generate_parameters() [](#method-i-test_s_generate_parameters) - -## test_s_generate_parameters_with_block() [](#method-i-test_s_generate_parameters_with_block) - -## test_to_text() [](#method-i-test_to_text) - -## test_x25519() [](#method-i-test_x25519) - diff --git a/example/ruby/OpenSSL/TestPKeyDH.md b/example/ruby/OpenSSL/TestPKeyDH.md deleted file mode 100644 index 34acd57..0000000 --- a/example/ruby/OpenSSL/TestPKeyDH.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: OpenSSL::TestPKeyDH -**Inherits:** OpenSSL::PKeyTestCase - - - - - -#Instance Methods -## test_DHparams() [](#method-i-test_DHparams) - -## test_derive_key() [](#method-i-test_derive_key) - -## test_dup() [](#method-i-test_dup) - -## test_generate_key() [](#method-i-test_generate_key) - -## test_marshal() [](#method-i-test_marshal) - -## test_new_break_on_fips() [](#method-i-test_new_break_on_fips) - -## test_new_break_on_non_fips() [](#method-i-test_new_break_on_non_fips) - -## test_new_empty() [](#method-i-test_new_empty) - -## test_new_generate() [](#method-i-test_new_generate) - -## test_params_ok?() [](#method-i-test_params_ok?) - -**@return** [Boolean] - -## test_public_key() [](#method-i-test_public_key) - diff --git a/example/ruby/OpenSSL/TestPKeyDSA.md b/example/ruby/OpenSSL/TestPKeyDSA.md deleted file mode 100644 index 9f897b0..0000000 --- a/example/ruby/OpenSSL/TestPKeyDSA.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: OpenSSL::TestPKeyDSA -**Inherits:** OpenSSL::PKeyTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_DSAPrivateKey() [](#method-i-test_DSAPrivateKey) - -## test_DSAPrivateKey_encrypted() [](#method-i-test_DSAPrivateKey_encrypted) - -## test_PUBKEY() [](#method-i-test_PUBKEY) - -## test_dup() [](#method-i-test_dup) - -## test_generate() [](#method-i-test_generate) - -## test_marshal() [](#method-i-test_marshal) - -## test_new() [](#method-i-test_new) - -## test_new_break() [](#method-i-test_new_break) - -## test_private() [](#method-i-test_private) - -## test_read_DSAPublicKey_pem() [](#method-i-test_read_DSAPublicKey_pem) - -## test_sign_verify() [](#method-i-test_sign_verify) - -## test_sign_verify_raw() [](#method-i-test_sign_verify_raw) - diff --git a/example/ruby/OpenSSL/TestPKeyRSA.md b/example/ruby/OpenSSL/TestPKeyRSA.md deleted file mode 100644 index 6b355b1..0000000 --- a/example/ruby/OpenSSL/TestPKeyRSA.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: OpenSSL::TestPKeyRSA -**Inherits:** OpenSSL::PKeyTestCase - - - - - -#Instance Methods -## test_PUBKEY() [](#method-i-test_PUBKEY) - -## test_RSAPrivateKey() [](#method-i-test_RSAPrivateKey) - -## test_RSAPrivateKey_encrypted() [](#method-i-test_RSAPrivateKey_encrypted) - -## test_RSAPublicKey() [](#method-i-test_RSAPublicKey) - -## test_dup() [](#method-i-test_dup) - -## test_encrypt_decrypt() [](#method-i-test_encrypt_decrypt) - -## test_encrypt_decrypt_legacy() [](#method-i-test_encrypt_decrypt_legacy) - -## test_export() [](#method-i-test_export) - -## test_marshal() [](#method-i-test_marshal) - -## test_new() [](#method-i-test_new) - -## test_new_break() [](#method-i-test_new_break) - -## test_new_public_exponent() [](#method-i-test_new_public_exponent) - -## test_no_private_exp() [](#method-i-test_no_private_exp) - -## test_pem_passwd() [](#method-i-test_pem_passwd) - -## test_private() [](#method-i-test_private) - -## test_private_encoding() [](#method-i-test_private_encoding) - -## test_private_encoding_encrypted() [](#method-i-test_private_encoding_encrypted) - -## test_s_generate() [](#method-i-test_s_generate) - -## test_s_generate_public_exponent() [](#method-i-test_s_generate_public_exponent) - -## test_sign_verify() [](#method-i-test_sign_verify) - -## test_sign_verify_options() [](#method-i-test_sign_verify_options) - -## test_sign_verify_pss() [](#method-i-test_sign_verify_pss) - -## test_sign_verify_raw() [](#method-i-test_sign_verify_raw) - -## test_sign_verify_raw_legacy() [](#method-i-test_sign_verify_raw_legacy) - -## test_to_der() [](#method-i-test_to_der) - -## test_verify_empty_rsa() [](#method-i-test_verify_empty_rsa) - diff --git a/example/ruby/OpenSSL/TestPair.md b/example/ruby/OpenSSL/TestPair.md deleted file mode 100644 index 7a6f267..0000000 --- a/example/ruby/OpenSSL/TestPair.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: OpenSSL::TestPair -**Inherits:** OpenSSL::TestCase - -**Includes:** OpenSSL::SSLPair, OpenSSL::TestPairM - - - - - -#Instance Methods -## create_tcp_client(host, port) [](#method-i-create_tcp_client) - -## create_tcp_server(host, port) [](#method-i-create_tcp_server) - -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - -## tcp_pair() [](#method-i-tcp_pair) - -## test_connect_accept_nonblock() [](#method-i-test_connect_accept_nonblock) - -## test_connect_accept_nonblock_no_exception() [](#method-i-test_connect_accept_nonblock_no_exception) - -## test_getbyte() [](#method-i-test_getbyte) - -## test_getc() [](#method-i-test_getc) - -## test_gets() [](#method-i-test_gets) - -## test_gets_chomp() [](#method-i-test_gets_chomp) - -## test_gets_eof_limit() [](#method-i-test_gets_eof_limit) - -## test_multibyte_read_write() [](#method-i-test_multibyte_read_write) - -## test_partial_tls_record_read_nonblock() [](#method-i-test_partial_tls_record_read_nonblock) - -## test_puts_empty() [](#method-i-test_puts_empty) - -## test_read_nonblock() [](#method-i-test_read_nonblock) - -## test_read_nonblock_no_exception() [](#method-i-test_read_nonblock_no_exception) - -## test_read_with_outbuf() [](#method-i-test_read_with_outbuf) - -## test_readall() [](#method-i-test_readall) - -## test_readbyte() [](#method-i-test_readbyte) - -## test_readbyte_eof() [](#method-i-test_readbyte_eof) - -## test_readline() [](#method-i-test_readline) - -## test_readpartial() [](#method-i-test_readpartial) - -## test_write_multiple_arguments() [](#method-i-test_write_multiple_arguments) - -## test_write_nonblock() [](#method-i-test_write_nonblock) - -## test_write_nonblock_no_exceptions() [](#method-i-test_write_nonblock_no_exceptions) - -## test_write_nonblock_retry() [](#method-i-test_write_nonblock_retry) - -## test_write_nonblock_with_buffered_data() [](#method-i-test_write_nonblock_with_buffered_data) - -## test_write_nonblock_with_buffered_data_no_exceptions() [](#method-i-test_write_nonblock_with_buffered_data_no_exceptions) - -## test_write_zero() [](#method-i-test_write_zero) - diff --git a/example/ruby/OpenSSL/TestPairLowlevelSocket.md b/example/ruby/OpenSSL/TestPairLowlevelSocket.md deleted file mode 100644 index 1ef9175..0000000 --- a/example/ruby/OpenSSL/TestPairLowlevelSocket.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: OpenSSL::TestPairLowlevelSocket -**Inherits:** OpenSSL::TestCase - -**Includes:** OpenSSL::SSLPairLowlevelSocket, OpenSSL::TestPairM - - - - - -#Instance Methods -## create_tcp_client(host, port) [](#method-i-create_tcp_client) - -## create_tcp_server(host, port) [](#method-i-create_tcp_server) - -## setup() [](#method-i-setup) - -## ssl_pair() [](#method-i-ssl_pair) - -## tcp_pair() [](#method-i-tcp_pair) - -## test_connect_accept_nonblock() [](#method-i-test_connect_accept_nonblock) - -## test_connect_accept_nonblock_no_exception() [](#method-i-test_connect_accept_nonblock_no_exception) - -## test_getbyte() [](#method-i-test_getbyte) - -## test_getc() [](#method-i-test_getc) - -## test_gets() [](#method-i-test_gets) - -## test_gets_chomp() [](#method-i-test_gets_chomp) - -## test_gets_eof_limit() [](#method-i-test_gets_eof_limit) - -## test_multibyte_read_write() [](#method-i-test_multibyte_read_write) - -## test_partial_tls_record_read_nonblock() [](#method-i-test_partial_tls_record_read_nonblock) - -## test_puts_empty() [](#method-i-test_puts_empty) - -## test_read_nonblock() [](#method-i-test_read_nonblock) - -## test_read_nonblock_no_exception() [](#method-i-test_read_nonblock_no_exception) - -## test_read_with_outbuf() [](#method-i-test_read_with_outbuf) - -## test_readall() [](#method-i-test_readall) - -## test_readbyte() [](#method-i-test_readbyte) - -## test_readbyte_eof() [](#method-i-test_readbyte_eof) - -## test_readline() [](#method-i-test_readline) - -## test_readpartial() [](#method-i-test_readpartial) - -## test_write_multiple_arguments() [](#method-i-test_write_multiple_arguments) - -## test_write_nonblock() [](#method-i-test_write_nonblock) - -## test_write_nonblock_no_exceptions() [](#method-i-test_write_nonblock_no_exceptions) - -## test_write_nonblock_retry() [](#method-i-test_write_nonblock_retry) - -## test_write_nonblock_with_buffered_data() [](#method-i-test_write_nonblock_with_buffered_data) - -## test_write_nonblock_with_buffered_data_no_exceptions() [](#method-i-test_write_nonblock_with_buffered_data_no_exceptions) - -## test_write_zero() [](#method-i-test_write_zero) - diff --git a/example/ruby/OpenSSL/TestPairM.md b/example/ruby/OpenSSL/TestPairM.md deleted file mode 100644 index 0720f79..0000000 --- a/example/ruby/OpenSSL/TestPairM.md +++ /dev/null @@ -1,59 +0,0 @@ -# Module: OpenSSL::TestPairM - - - - - -#Instance Methods -## tcp_pair() [](#method-i-tcp_pair) - -## test_connect_accept_nonblock() [](#method-i-test_connect_accept_nonblock) - -## test_connect_accept_nonblock_no_exception() [](#method-i-test_connect_accept_nonblock_no_exception) - -## test_getbyte() [](#method-i-test_getbyte) - -## test_getc() [](#method-i-test_getc) - -## test_gets() [](#method-i-test_gets) - -## test_gets_chomp() [](#method-i-test_gets_chomp) - -## test_gets_eof_limit() [](#method-i-test_gets_eof_limit) - -## test_multibyte_read_write() [](#method-i-test_multibyte_read_write) - -## test_partial_tls_record_read_nonblock() [](#method-i-test_partial_tls_record_read_nonblock) - -## test_puts_empty() [](#method-i-test_puts_empty) - -## test_read_nonblock() [](#method-i-test_read_nonblock) - -## test_read_nonblock_no_exception() [](#method-i-test_read_nonblock_no_exception) - -## test_read_with_outbuf() [](#method-i-test_read_with_outbuf) - -## test_readall() [](#method-i-test_readall) - -## test_readbyte() [](#method-i-test_readbyte) - -## test_readbyte_eof() [](#method-i-test_readbyte_eof) - -## test_readline() [](#method-i-test_readline) - -## test_readpartial() [](#method-i-test_readpartial) - -## test_write_multiple_arguments() [](#method-i-test_write_multiple_arguments) - -## test_write_nonblock() [](#method-i-test_write_nonblock) - -## test_write_nonblock_no_exceptions() [](#method-i-test_write_nonblock_no_exceptions) - -## test_write_nonblock_retry() [](#method-i-test_write_nonblock_retry) - -## test_write_nonblock_with_buffered_data() [](#method-i-test_write_nonblock_with_buffered_data) - -## test_write_nonblock_with_buffered_data_no_exceptions() [](#method-i-test_write_nonblock_with_buffered_data_no_exceptions) - -## test_write_zero() [](#method-i-test_write_zero) - diff --git a/example/ruby/OpenSSL/TestProvider.md b/example/ruby/OpenSSL/TestProvider.md deleted file mode 100644 index ae4671f..0000000 --- a/example/ruby/OpenSSL/TestProvider.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: OpenSSL::TestProvider -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_openssl_legacy_provider() [](#method-i-test_openssl_legacy_provider) - -## test_openssl_provider_name_inspect() [](#method-i-test_openssl_provider_name_inspect) - -## test_openssl_provider_names() [](#method-i-test_openssl_provider_names) - -## test_unloaded_openssl_provider() [](#method-i-test_unloaded_openssl_provider) - diff --git a/example/ruby/OpenSSL/TestRandom.md b/example/ruby/OpenSSL/TestRandom.md deleted file mode 100644 index e68c6b9..0000000 --- a/example/ruby/OpenSSL/TestRandom.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: OpenSSL::TestRandom -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_pseudo_bytes() [](#method-i-test_pseudo_bytes) - -## test_random_bytes() [](#method-i-test_random_bytes) - diff --git a/example/ruby/OpenSSL/TestSSL.md b/example/ruby/OpenSSL/TestSSL.md deleted file mode 100644 index dbf183e..0000000 --- a/example/ruby/OpenSSL/TestSSL.md +++ /dev/null @@ -1,183 +0,0 @@ -# Class: OpenSSL::TestSSL -**Inherits:** OpenSSL::SSLTestCase - - - - - -#Instance Methods -## check_supported_protocol_versions() [](#method-i-check_supported_protocol_versions) - -## create_cert_with_name(name) [](#method-i-create_cert_with_name) - -## create_cert_with_san(san) [](#method-i-create_cert_with_san) - -## create_null_byte_SAN_certificate(criticalfalse) [](#method-i-create_null_byte_SAN_certificate) -Create NULL byte SAN certificate - -## readwrite_loop_safe(ctx, ssl) [](#method-i-readwrite_loop_safe) - -## socketpair() [](#method-i-socketpair) - -## test_accept_errors_include_peeraddr() [](#method-i-test_accept_errors_include_peeraddr) - -## test_add_certificate() [](#method-i-test_add_certificate) - -## test_add_certificate_multiple_certs() [](#method-i-test_add_certificate_multiple_certs) - -## test_alpn_protocol_selection_ary() [](#method-i-test_alpn_protocol_selection_ary) - -## test_alpn_protocol_selection_cancel() [](#method-i-test_alpn_protocol_selection_cancel) - -## test_bad_socket() [](#method-i-test_bad_socket) - -## test_ca_file() [](#method-i-test_ca_file) - -## test_ca_file_not_found() [](#method-i-test_ca_file_not_found) - -## test_ciphers_method_bogus_csuite() [](#method-i-test_ciphers_method_bogus_csuite) - -## test_ciphers_method_frozen_object() [](#method-i-test_ciphers_method_frozen_object) - -## test_ciphers_method_nil_argument() [](#method-i-test_ciphers_method_nil_argument) - -## test_ciphers_method_tls_connection() [](#method-i-test_ciphers_method_tls_connection) - -## test_ciphersuites_method_bogus_csuite() [](#method-i-test_ciphersuites_method_bogus_csuite) - -## test_ciphersuites_method_frozen_object() [](#method-i-test_ciphersuites_method_frozen_object) - -## test_ciphersuites_method_nil_argument() [](#method-i-test_ciphersuites_method_nil_argument) - -## test_ciphersuites_method_tls_connection() [](#method-i-test_ciphersuites_method_tls_connection) - -## test_client_auth_success() [](#method-i-test_client_auth_success) - -## test_client_ca() [](#method-i-test_client_ca) - -## test_client_cert_cb_ignore_error() [](#method-i-test_client_cert_cb_ignore_error) - -## test_close_after_socket_close() [](#method-i-test_close_after_socket_close) - -## test_connect_certificate_verify_failed_exception_message() [](#method-i-test_connect_certificate_verify_failed_exception_message) - -## test_connect_works_when_setting_dh_callback_to_nil() [](#method-i-test_connect_works_when_setting_dh_callback_to_nil) - -## test_copy_stream() [](#method-i-test_copy_stream) - -## test_ctx_options() [](#method-i-test_ctx_options) - -## test_ctx_options_config() [](#method-i-test_ctx_options_config) - -## test_ctx_setup() [](#method-i-test_ctx_setup) - -## test_dup() [](#method-i-test_dup) - -## test_ecdh_curves_tls12() [](#method-i-test_ecdh_curves_tls12) - -## test_ecdh_curves_tls13() [](#method-i-test_ecdh_curves_tls13) - -## test_exception_in_verify_callback_is_ignored() [](#method-i-test_exception_in_verify_callback_is_ignored) - -## test_export_keying_material() [](#method-i-test_export_keying_material) - -## test_fallback_scsv() [](#method-i-test_fallback_scsv) - -## test_fileno() [](#method-i-test_fileno) - -## test_finished_messages() [](#method-i-test_finished_messages) - -## test_freeze_calls_setup() [](#method-i-test_freeze_calls_setup) - -## test_get_ephemeral_key() [](#method-i-test_get_ephemeral_key) - -## test_getbyte() [](#method-i-test_getbyte) - -## test_keylog_cb() [](#method-i-test_keylog_cb) - -## test_minmax_version() [](#method-i-test_minmax_version) - -## test_npn_advertised_protocol_too_long() [](#method-i-test_npn_advertised_protocol_too_long) - -## test_npn_protocol_selection_ary() [](#method-i-test_npn_protocol_selection_ary) - -## test_npn_protocol_selection_cancel() [](#method-i-test_npn_protocol_selection_cancel) - -## test_npn_protocol_selection_enum() [](#method-i-test_npn_protocol_selection_enum) - -## test_npn_selected_protocol_too_long() [](#method-i-test_npn_selected_protocol_too_long) - -## test_options_disable_versions() [](#method-i-test_options_disable_versions) - -## test_parallel() [](#method-i-test_parallel) - -## test_post_connect_check_with_anon_ciphers() [](#method-i-test_post_connect_check_with_anon_ciphers) - -## test_post_connection_check() [](#method-i-test_post_connection_check) - -## test_post_connection_check_wildcard_cn() [](#method-i-test_post_connection_check_wildcard_cn) - -## test_post_connection_check_wildcard_san() [](#method-i-test_post_connection_check_wildcard_san) -Comments in this test is excerpted from -https://www.rfc-editor.org/rfc/rfc6125#page-27 - -## test_read_with_timeout() [](#method-i-test_read_with_timeout) - -## test_readbyte() [](#method-i-test_readbyte) - -## test_renegotiation_cb() [](#method-i-test_renegotiation_cb) - -## test_security_level() [](#method-i-test_security_level) - -## test_servername_cb_raises_an_exception_on_unknown_objects() [](#method-i-test_servername_cb_raises_an_exception_on_unknown_objects) - -## test_set_params_min_version() [](#method-i-test_set_params_min_version) - -## test_socket_close_write() [](#method-i-test_socket_close_write) - -## test_socket_open() [](#method-i-test_socket_open) - -## test_socket_open_with_context() [](#method-i-test_socket_open_with_context) - -## test_socket_open_with_local_address_port_context() [](#method-i-test_socket_open_with_local_address_port_context) - -## test_ssl_methods_constant() [](#method-i-test_ssl_methods_constant) - -## test_ssl_with_server_cert() [](#method-i-test_ssl_with_server_cert) - -## test_sslctx_set_params() [](#method-i-test_sslctx_set_params) - -## test_sync_close() [](#method-i-test_sync_close) - -## test_sync_close_without_connect() [](#method-i-test_sync_close_without_connect) - -## test_sysread_and_syswrite() [](#method-i-test_sysread_and_syswrite) - -## test_tlsext_hostname() [](#method-i-test_tlsext_hostname) - -## test_tmp_dh() [](#method-i-test_tmp_dh) - -## test_tmp_dh_callback() [](#method-i-test_tmp_dh_callback) - -## test_unset_OP_ALL() [](#method-i-test_unset_OP_ALL) - -## test_unstarted_session() [](#method-i-test_unstarted_session) - -## test_verify_certificate_identity() [](#method-i-test_verify_certificate_identity) - -## test_verify_hostname() [](#method-i-test_verify_hostname) - -## test_verify_hostname_failure_error_code() [](#method-i-test_verify_hostname_failure_error_code) - -## test_verify_hostname_on_connect() [](#method-i-test_verify_hostname_on_connect) - -## test_verify_mode_client_cert_required() [](#method-i-test_verify_mode_client_cert_required) - -## test_verify_mode_default() [](#method-i-test_verify_mode_default) - -## test_verify_mode_server_cert() [](#method-i-test_verify_mode_server_cert) - -## test_verify_result() [](#method-i-test_verify_result) - -## test_verify_wildcard() [](#method-i-test_verify_wildcard) - diff --git a/example/ruby/OpenSSL/TestSSLSession.md b/example/ruby/OpenSSL/TestSSLSession.md deleted file mode 100644 index 7f37f63..0000000 --- a/example/ruby/OpenSSL/TestSSLSession.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: OpenSSL::TestSSLSession -**Inherits:** OpenSSL::SSLTestCase - - - - - -#Instance Methods -## test_ctx_client_session_cb_tls12() [](#method-i-test_ctx_client_session_cb_tls12) - -## test_ctx_client_session_cb_tls13() [](#method-i-test_ctx_client_session_cb_tls13) - -## test_ctx_client_session_cb_tls13_exception() [](#method-i-test_ctx_client_session_cb_tls13_exception) - -## test_ctx_server_session_cb() [](#method-i-test_ctx_server_session_cb) - -## test_dup() [](#method-i-test_dup) - -## test_resumption() [](#method-i-test_resumption) - -## test_server_session_cache() [](#method-i-test_server_session_cache) - -## test_session() [](#method-i-test_session) - -## test_session_exts_read() [](#method-i-test_session_exts_read) - -## test_session_time() [](#method-i-test_session_time) - -## test_session_timeout() [](#method-i-test_session_timeout) - diff --git a/example/ruby/OpenSSL/TestTimestamp.md b/example/ruby/OpenSSL/TestTimestamp.md deleted file mode 100644 index f44104d..0000000 --- a/example/ruby/OpenSSL/TestTimestamp.md +++ /dev/null @@ -1,100 +0,0 @@ -# Class: OpenSSL::TestTimestamp -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## ca_cert() [](#method-i-ca_cert) - -## ca_store() [](#method-i-ca_store) - -## ee_key() [](#method-i-ee_key) - -## intermediate_cert() [](#method-i-intermediate_cert) - -## intermediate_key() [](#method-i-intermediate_key) - -## intermediate_store() [](#method-i-intermediate_store) - -## test_no_cert_requested() [](#method-i-test_no_cert_requested) - -## test_request_assignment() [](#method-i-test_request_assignment) - -## test_request_encode_decode() [](#method-i-test_request_encode_decode) - -## test_request_invalid_asn1() [](#method-i-test_request_invalid_asn1) - -## test_request_mandatory_fields() [](#method-i-test_request_mandatory_fields) - -## test_request_re_assignment() [](#method-i-test_request_re_assignment) - -## test_request_serialization() [](#method-i-test_request_serialization) - -## test_response_allowed_digests() [](#method-i-test_response_allowed_digests) - -## test_response_bad_purpose() [](#method-i-test_response_bad_purpose) - -## test_response_constants() [](#method-i-test_response_constants) - -## test_response_creation() [](#method-i-test_response_creation) - -## test_response_default_policy() [](#method-i-test_response_default_policy) - -## test_response_failure_info() [](#method-i-test_response_failure_info) - -## test_response_invalid_asn1() [](#method-i-test_response_invalid_asn1) - -## test_response_mandatory_fields() [](#method-i-test_response_mandatory_fields) - -## test_response_no_policy_defined() [](#method-i-test_response_no_policy_defined) - -## test_reusable() [](#method-i-test_reusable) - -## test_token_info_creation() [](#method-i-test_token_info_creation) - -## test_token_info_invalid_asn1() [](#method-i-test_token_info_invalid_asn1) - -## test_verify_direct() [](#method-i-test_verify_direct) - -## test_verify_direct_no_cert_no_intermediate() [](#method-i-test_verify_direct_no_cert_no_intermediate) - -## test_verify_direct_redundant_untrusted() [](#method-i-test_verify_direct_redundant_untrusted) - -## test_verify_direct_unrelated_untrusted() [](#method-i-test_verify_direct_unrelated_untrusted) - -## test_verify_direct_wrong_root() [](#method-i-test_verify_direct_wrong_root) - -## test_verify_ee_additional_certs_array() [](#method-i-test_verify_ee_additional_certs_array) - -## test_verify_ee_additional_certs_with_root() [](#method-i-test_verify_ee_additional_certs_with_root) - -## test_verify_ee_cert_inclusion_not_requested() [](#method-i-test_verify_ee_cert_inclusion_not_requested) - -## test_verify_ee_def_policy() [](#method-i-test_verify_ee_def_policy) - -## test_verify_ee_intermediate() [](#method-i-test_verify_ee_intermediate) - -## test_verify_ee_intermediate_missing() [](#method-i-test_verify_ee_intermediate_missing) - -## test_verify_ee_intermediate_type_error() [](#method-i-test_verify_ee_intermediate_type_error) - -## test_verify_ee_no_cert() [](#method-i-test_verify_ee_no_cert) - -## test_verify_ee_no_cert_no_intermediate() [](#method-i-test_verify_ee_no_cert_no_intermediate) - -## test_verify_ee_no_req() [](#method-i-test_verify_ee_no_req) - -## test_verify_ee_no_store() [](#method-i-test_verify_ee_no_store) - -## test_verify_ee_nonce_mismatch() [](#method-i-test_verify_ee_nonce_mismatch) - -## test_verify_ee_wrong_root_no_intermediate() [](#method-i-test_verify_ee_wrong_root_no_intermediate) - -## test_verify_ee_wrong_root_wrong_intermediate() [](#method-i-test_verify_ee_wrong_root_wrong_intermediate) - -## ts_cert_direct() [](#method-i-ts_cert_direct) - -## ts_cert_ee() [](#method-i-ts_cert_ee) - diff --git a/example/ruby/OpenSSL/TestUtils.md b/example/ruby/OpenSSL/TestUtils.md deleted file mode 100644 index d61a3a9..0000000 --- a/example/ruby/OpenSSL/TestUtils.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: OpenSSL::TestUtils - - - - -# Class Methods -## generate_cert(dn , key , serial , issuer , not_before: nil, not_after: nil) [](#method-c-generate_cert) -## get_subject_key_id(cert , hex: true) [](#method-c-get_subject_key_id) -## issue_cert(dn , key , serial , extensions , issuer , issuer_key , not_before: nil, not_after: nil, digest: "sha256") [](#method-c-issue_cert) -## issue_crl(revoke_info , serial , lastup , nextup , extensions , issuer , issuer_key , digest ) [](#method-c-issue_crl) -## libressl?(major nil, minor nil, fix nil) [](#method-c-libressl?) -**@return** [Boolean] - -## openssl?(major nil, minor nil, fix nil, patch 0, status 0) [](#method-c-openssl?) -**@return** [Boolean] - - diff --git a/example/ruby/OpenSSL/TestUtils/Fixtures.md b/example/ruby/OpenSSL/TestUtils/Fixtures.md deleted file mode 100644 index ee36ddf..0000000 --- a/example/ruby/OpenSSL/TestUtils/Fixtures.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: OpenSSL::TestUtils::Fixtures - - - - -# Class Methods -## file_path(category , name ) [](#method-c-file_path) -## pkey(name ) [](#method-c-pkey) -## read_file(category , name ) [](#method-c-read_file) - diff --git a/example/ruby/OpenSSL/TestX509Attribute.md b/example/ruby/OpenSSL/TestX509Attribute.md deleted file mode 100644 index a9bd189..0000000 --- a/example/ruby/OpenSSL/TestX509Attribute.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: OpenSSL::TestX509Attribute -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_dup() [](#method-i-test_dup) - -## test_eq() [](#method-i-test_eq) - -## test_from_der() [](#method-i-test_from_der) - -## test_invalid_value() [](#method-i-test_invalid_value) - -## test_marshal() [](#method-i-test_marshal) - -## test_new() [](#method-i-test_new) - -## test_to_der() [](#method-i-test_to_der) - diff --git a/example/ruby/OpenSSL/TestX509CRL.md b/example/ruby/OpenSSL/TestX509CRL.md deleted file mode 100644 index aa4adb7..0000000 --- a/example/ruby/OpenSSL/TestX509CRL.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: OpenSSL::TestX509CRL -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_basic() [](#method-i-test_basic) - -## test_crlnumber() [](#method-i-test_crlnumber) - -## test_eq() [](#method-i-test_eq) - -## test_extension() [](#method-i-test_extension) - -## test_marshal() [](#method-i-test_marshal) - -## test_revoked() [](#method-i-test_revoked) - -## test_revoked_to_der() [](#method-i-test_revoked_to_der) - -## test_sign_and_verify() [](#method-i-test_sign_and_verify) - -## test_sign_and_verify_ed25519() [](#method-i-test_sign_and_verify_ed25519) - diff --git a/example/ruby/OpenSSL/TestX509Certificate.md b/example/ruby/OpenSSL/TestX509Certificate.md deleted file mode 100644 index e89055a..0000000 --- a/example/ruby/OpenSSL/TestX509Certificate.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: OpenSSL::TestX509Certificate -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_aia() [](#method-i-test_aia) - -## test_aia_missing() [](#method-i-test_aia_missing) - -## test_akiski() [](#method-i-test_akiski) - -## test_akiski_missing() [](#method-i-test_akiski_missing) - -## test_check_private_key() [](#method-i-test_check_private_key) - -## test_crl_uris() [](#method-i-test_crl_uris) - -## test_crl_uris_multiple_general_names() [](#method-i-test_crl_uris_multiple_general_names) - -## test_crl_uris_no_crl_distribution_points() [](#method-i-test_crl_uris_no_crl_distribution_points) - -## test_crl_uris_no_uris() [](#method-i-test_crl_uris_no_uris) - -## test_dsa_with_sha2() [](#method-i-test_dsa_with_sha2) - -## test_eq() [](#method-i-test_eq) - -## test_extension_factory() [](#method-i-test_extension_factory) - -## test_invalid_extension() [](#method-i-test_invalid_extension) - -## test_load_file_certificate_der() [](#method-i-test_load_file_certificate_der) - -## test_load_file_empty_pem() [](#method-i-test_load_file_empty_pem) - -## test_load_file_fullchain_garbage() [](#method-i-test_load_file_fullchain_garbage) - -## test_load_file_fullchain_pem() [](#method-i-test_load_file_fullchain_pem) - -## test_marshal() [](#method-i-test_marshal) - -## test_public_key() [](#method-i-test_public_key) - -## test_read_der_then_pem() [](#method-i-test_read_der_then_pem) - -## test_read_from_file() [](#method-i-test_read_from_file) - -## test_serial() [](#method-i-test_serial) - -## test_sign_and_verify_dsa() [](#method-i-test_sign_and_verify_dsa) - -## test_sign_and_verify_dsa_md5() [](#method-i-test_sign_and_verify_dsa_md5) - -## test_sign_and_verify_ed25519() [](#method-i-test_sign_and_verify_ed25519) - -## test_sign_and_verify_rsa_dss1() [](#method-i-test_sign_and_verify_rsa_dss1) - -## test_sign_and_verify_rsa_md5() [](#method-i-test_sign_and_verify_rsa_md5) - -## test_sign_and_verify_rsa_sha1() [](#method-i-test_sign_and_verify_rsa_sha1) - -## test_tbs_precert_bytes() [](#method-i-test_tbs_precert_bytes) - -## test_validity() [](#method-i-test_validity) - diff --git a/example/ruby/OpenSSL/TestX509Extension.md b/example/ruby/OpenSSL/TestX509Extension.md deleted file mode 100644 index fb5b595..0000000 --- a/example/ruby/OpenSSL/TestX509Extension.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: OpenSSL::TestX509Extension -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_create_by_factory() [](#method-i-test_create_by_factory) - -## test_dup() [](#method-i-test_dup) - -## test_eq() [](#method-i-test_eq) - -## test_factory_create_extension_oid() [](#method-i-test_factory_create_extension_oid) - -## test_factory_create_extension_sn_ln() [](#method-i-test_factory_create_extension_sn_ln) - -## test_marshal() [](#method-i-test_marshal) - -## test_new() [](#method-i-test_new) - -## test_value_der() [](#method-i-test_value_der) - diff --git a/example/ruby/OpenSSL/TestX509Name.md b/example/ruby/OpenSSL/TestX509Name.md deleted file mode 100644 index d0ee83d..0000000 --- a/example/ruby/OpenSSL/TestX509Name.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: OpenSSL::TestX509Name -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## name_hash(name) [](#method-i-name_hash) - -## setup() [](#method-i-setup) - -## test_add_entry() [](#method-i-test_add_entry) - -## test_add_entry_placing() [](#method-i-test_add_entry_placing) - -## test_add_entry_street() [](#method-i-test_add_entry_street) - -## test_dup() [](#method-i-test_dup) - -## test_equality() [](#method-i-test_equality) - -## test_equals2() [](#method-i-test_equals2) - -## test_hash() [](#method-i-test_hash) - -## test_marshal() [](#method-i-test_marshal) - -## test_s_new() [](#method-i-test_s_new) - -## test_s_parse() [](#method-i-test_s_parse) - -## test_s_parse_rfc2253() [](#method-i-test_s_parse_rfc2253) - -## test_spaceship() [](#method-i-test_spaceship) - -## test_to_s() [](#method-i-test_to_s) - -## test_to_utf8() [](#method-i-test_to_utf8) - -## test_unrecognized_oid() [](#method-i-test_unrecognized_oid) - -## test_unrecognized_oid_parse_encode_equality() [](#method-i-test_unrecognized_oid_parse_encode_equality) - diff --git a/example/ruby/OpenSSL/TestX509Request.md b/example/ruby/OpenSSL/TestX509Request.md deleted file mode 100644 index 42414ab..0000000 --- a/example/ruby/OpenSSL/TestX509Request.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: OpenSSL::TestX509Request -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## create_ext_req(exts) [](#method-i-create_ext_req) - -## get_ext_req(ext_req_value) [](#method-i-get_ext_req) - -## issue_csr(ver, dn, key, digest) [](#method-i-issue_csr) - -## setup() [](#method-i-setup) - -## test_attr() [](#method-i-test_attr) - -## test_dup() [](#method-i-test_dup) - -## test_eq() [](#method-i-test_eq) - -## test_marshal() [](#method-i-test_marshal) - -## test_public_key() [](#method-i-test_public_key) - -## test_sign_and_verify_dsa() [](#method-i-test_sign_and_verify_dsa) - -## test_sign_and_verify_dsa_md5() [](#method-i-test_sign_and_verify_dsa_md5) - -## test_sign_and_verify_ed25519() [](#method-i-test_sign_and_verify_ed25519) - -## test_sign_and_verify_rsa_md5() [](#method-i-test_sign_and_verify_rsa_md5) - -## test_sign_and_verify_rsa_sha1() [](#method-i-test_sign_and_verify_rsa_sha1) - -## test_subject() [](#method-i-test_subject) - -## test_version() [](#method-i-test_version) - diff --git a/example/ruby/OpenSSL/TestX509Store.md b/example/ruby/OpenSSL/TestX509Store.md deleted file mode 100644 index 6090d78..0000000 --- a/example/ruby/OpenSSL/TestX509Store.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: OpenSSL::TestX509Store -**Inherits:** OpenSSL::TestCase - - - - - -#Instance Methods -## test_add_cert_duplicate() [](#method-i-test_add_cert_duplicate) - -## test_add_file_path() [](#method-i-test_add_file_path) - -## test_ctx_cleanup() [](#method-i-test_ctx_cleanup) - -## test_dup() [](#method-i-test_dup) - -## test_store_new() [](#method-i-test_store_new) - -## test_verify_callback() [](#method-i-test_verify_callback) - -## test_verify_purpose() [](#method-i-test_verify_purpose) - -## test_verify_simple() [](#method-i-test_verify_simple) - -## test_verify_validity_period() [](#method-i-test_verify_validity_period) - -## test_verify_with_crl() [](#method-i-test_verify_with_crl) - diff --git a/example/ruby/OpenSSL/Timestamp.md b/example/ruby/OpenSSL/Timestamp.md deleted file mode 100644 index 18c3e35..0000000 --- a/example/ruby/OpenSSL/Timestamp.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: OpenSSL::Timestamp -**Inherits:** Object - - -Provides classes and methods to request, create and validate -[RFC3161-compliant](http://www.ietf.org/rfc/rfc3161.txt) timestamps. Request -may be used to either create requests from scratch or to parse existing -requests that again can be used to request timestamps from a timestamp server, -e.g. via the net/http. The resulting timestamp response may be parsed using -Response. - -Please note that Response is read-only and immutable. To create a Response, an -instance of Factory as well as a valid Request are needed. - -### Create a Response: - #Assumes ts.p12 is a PKCS#12-compatible file with a private key - #and a certificate that has an extended key usage of 'timeStamping' - p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd') - md = OpenSSL::Digest.new('SHA1') - hash = md.digest(data) #some binary data to be timestamped - req = OpenSSL::Timestamp::Request.new - req.algorithm = 'SHA1' - req.message_imprint = hash - req.policy_id = "1.2.3.4.5" - req.nonce = 42 - fac = OpenSSL::Timestamp::Factory.new - fac.gen_time = Time.now - fac.serial_number = 1 - timestamp = fac.create_timestamp(p12.key, p12.certificate, req) - -### Verify a timestamp response: - #Assume we have a timestamp token in a file called ts.der - ts = OpenSSL::Timestamp::Response.new(File.binread('ts.der')) - #Assume we have the Request for this token in a file called req.der - req = OpenSSL::Timestamp::Request.new(File.binread('req.der')) - # Assume the associated root CA certificate is contained in a - # DER-encoded file named root.cer - root = OpenSSL::X509::Certificate.new(File.binread('root.cer')) - # get the necessary intermediate certificates, available in - # DER-encoded form in inter1.cer and inter2.cer - inter1 = OpenSSL::X509::Certificate.new(File.binread('inter1.cer')) - inter2 = OpenSSL::X509::Certificate.new(File.binread('inter2.cer')) - ts.verify(req, root, inter1, inter2) -> ts or raises an exception if validation fails - - - diff --git a/example/ruby/OpenSSL/Timestamp/Factory.md b/example/ruby/OpenSSL/Timestamp/Factory.md deleted file mode 100644 index fb13134..0000000 --- a/example/ruby/OpenSSL/Timestamp/Factory.md +++ /dev/null @@ -1,125 +0,0 @@ -# Class: OpenSSL::Timestamp::Factory -**Inherits:** Object - - -Used to generate a Response from scratch. - -Please bear in mind that the implementation will always apply and prefer the -policy object identifier given in the request over the default policy id -specified in the Factory. As a consequence, `default_policy_id` will only be -applied if no Request#policy_id was given. But this also means that one needs -to check the policy identifier in the request manually before creating the -Response, e.g. to check whether it complies to a specific set of acceptable -policies. - -There exists also the possibility to add certificates (instances of -OpenSSL::X509::Certificate) besides the timestamping certificate that will be -included in the resulting timestamp token if Request#cert_requested? is -`true`. Ideally, one would also include any intermediate certificates (the -root certificate can be left out - in order to trust it any verifying party -will have to be in its possession anyway). This simplifies validation of the -timestamp since these intermediate certificates are "already there" and need -not be passed as external parameters to Response#verify anymore, thus -minimizing external resources needed for verification. - -### Example: Inclusion of (untrusted) intermediate certificates - -Assume we received a timestamp request that has set Request#policy_id to `nil` -and Request#cert_requested? to true. The raw request bytes are stored in a -variable called `req_raw`. We'd still like to integrate the necessary -intermediate certificates (in `inter1.cer` and `inter2.cer`) to simplify -validation of the resulting Response. `ts.p12` is a PKCS#12-compatible file -including the private key and the timestamping certificate. - - req = OpenSSL::Timestamp::Request.new(raw_bytes) - p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd') - inter1 = OpenSSL::X509::Certificate.new(File.binread('inter1.cer')) - inter2 = OpenSSL::X509::Certificate.new(File.binread('inter2.cer')) - fac = OpenSSL::Timestamp::Factory.new - fac.gen_time = Time.now - fac.serial_number = 1 - fac.allowed_digests = ["sha256", "sha384", "sha512"] - #needed because the Request contained no policy identifier - fac.default_policy_id = '1.2.3.4.5' - fac.additional_certificates = [ inter1, inter2 ] - timestamp = fac.create_timestamp(p12.key, p12.certificate, req) - -## Attributes - -### default_policy_id - -Request#policy_id will always be preferred over this if present in the -Request, only if Request#policy_id is nil default_policy will be used. If none -of both is present, a TimestampError will be raised when trying to create a -Response. - -call-seq: - factory.default_policy_id = "string" -> string - factory.default_policy_id -> string or nil - -### serial_number - -Sets or retrieves the serial number to be used for timestamp creation. Must be -present for timestamp creation. - -call-seq: - factory.serial_number = number -> number - factory.serial_number -> number or nil - -### gen_time - -Sets or retrieves the Time value to be used in the Response. Must be present -for timestamp creation. - -call-seq: - factory.gen_time = Time -> Time - factory.gen_time -> Time or nil - -### additional_certs - -Sets or retrieves additional certificates apart from the timestamp certificate -(e.g. intermediate certificates) to be added to the Response. Must be an Array -of OpenSSL::X509::Certificate. - -call-seq: - factory.additional_certs = [cert1, cert2] -> [ cert1, cert2 ] - factory.additional_certs -> array or nil - -### allowed_digests - -Sets or retrieves the digest algorithms that the factory is allowed create -timestamps for. Known vulnerable or weak algorithms should not be allowed -where possible. Must be an Array of String or OpenSSL::Digest subclass -instances. - -call-seq: - factory.allowed_digests = ["sha1", OpenSSL::Digest.new('SHA256').new] -> [ "sha1", OpenSSL::Digest) ] - factory.allowed_digests -> array or nil - - - -#Instance Methods -## create_timestamp(key, certificate, request) [](#method-i-create_timestamp) -Creates a Response with the help of an OpenSSL::PKey, an -OpenSSL::X509::Certificate and a Request. - -Mandatory parameters for timestamp creation that need to be set in the -Request: - -* Request#algorithm -* Request#message_imprint - -Mandatory parameters that need to be set in the Factory: -* Factory#serial_number -* Factory#gen_time -* Factory#allowed_digests - -In addition one of either Request#policy_id or Factory#default_policy_id must -be set. - -Raises a TimestampError if creation fails, though successfully created error -responses may be returned. - -call-seq: - factory.create_timestamp(key, certificate, request) -> Response - diff --git a/example/ruby/OpenSSL/Timestamp/Request.md b/example/ruby/OpenSSL/Timestamp/Request.md deleted file mode 100644 index d74d5a9..0000000 --- a/example/ruby/OpenSSL/Timestamp/Request.md +++ /dev/null @@ -1,122 +0,0 @@ -# Class: OpenSSL::Timestamp::Request -**Inherits:** Object - - -Allows to create timestamp requests or parse existing ones. A Request is also -needed for creating timestamps from scratch with Factory. When created from -scratch, some default values are set: -* version is set to `1` -* cert_requested is set to `true` -* algorithm, message_imprint, policy_id, and nonce are set to `false` - - - -#Instance Methods -## algorithm() [](#method-i-algorithm) -Returns the 'short name' of the object identifier that represents the -algorithm that was used to create the message imprint digest. - - call-seq: - request.algorithm -> string - -## algorithm=(algo) [](#method-i-algorithm=) -Allows to set the object identifier or the 'short name' of the algorithm that -was used to create the message imprint digest. - -### Example: - request.algorithm = "SHA1" - - call-seq: - request.algorithm = "string" -> string - -## cert_requested=(requested) [](#method-i-cert_requested=) -Specify whether the response shall contain the timestamp authority's -certificate or not. The default value is `true`. - -call-seq: - request.cert_requested = boolean -> true or false - -## cert_requested?() [](#method-i-cert_requested?) -Indicates whether the response shall contain the timestamp authority's -certificate or not. - -call-seq: - request.cert_requested? -> true or false - -**@return** [Boolean] - -## initialize(*args) [](#method-i-initialize) -When creating a Request with the `File` or `string` parameter, the -corresponding `File` or `string` must be DER-encoded. - -call-seq: - OpenSSL::Timestamp::Request.new(file) -> request - OpenSSL::Timestamp::Request.new(string) -> request - OpenSSL::Timestamp::Request.new -> empty request - -## message_imprint() [](#method-i-message_imprint) -Returns the message imprint (digest) of the data to be timestamped. - -call-seq: - request.message_imprint -> string or nil - -## message_imprint=(hash) [](#method-i-message_imprint=) -Set the message imprint digest. - - call-seq: - request.message_imprint = "string" -> string - -## nonce() [](#method-i-nonce) -Returns the nonce (number used once) that the server shall include in its -response. - -call-seq: - request.nonce -> BN or nil - -## nonce=(num) [](#method-i-nonce=) -Sets the nonce (number used once) that the server shall include in its -response. If the nonce is set, the server must return the same nonce value in -a valid Response. - -call-seq: - request.nonce = number -> BN - -## policy_id() [](#method-i-policy_id) -Returns the 'short name' of the object identifier that represents the -timestamp policy under which the server shall create the timestamp. - -call-seq: - request.policy_id -> string or nil - -## policy_id=(oid) [](#method-i-policy_id=) -Allows to set the object identifier that represents the timestamp policy under -which the server shall create the timestamp. This may be left `nil`, implying -that the timestamp server will issue the timestamp using some default policy. - -### Example: - request.policy_id = "1.2.3.4.5" - -call-seq: - request.policy_id = "string" -> string - -## to_der() [](#method-i-to_der) -DER-encodes this Request. - -call-seq: - request.to_der -> DER-encoded string - -## to_text() [](#method-i-to_text) - -## version() [](#method-i-version) -Returns the version of this request. `1` is the default value. - -call-seq: - request.version -> Integer - -## version=(version) [](#method-i-version=) -Sets the version number for this Request. This should be `1` for compliant -servers. - -call-seq: - request.version = number -> Integer - diff --git a/example/ruby/OpenSSL/Timestamp/Response.md b/example/ruby/OpenSSL/Timestamp/Response.md deleted file mode 100644 index 92bf1f1..0000000 --- a/example/ruby/OpenSSL/Timestamp/Response.md +++ /dev/null @@ -1,111 +0,0 @@ -# Class: OpenSSL::Timestamp::Response -**Inherits:** Object - - -Immutable and read-only representation of a timestamp response returned from a -timestamp server after receiving an associated Request. Allows access to -specific information about the response but also allows to verify the -Response. - - - -#Instance Methods -## failure_info() [](#method-i-failure_info) -In cases no timestamp token has been created, this field contains further info -about the reason why response creation failed. The method returns either nil -(the request was successful and a timestamp token was created) or one of the -following: -* :BAD_ALG - Indicates that the timestamp server rejects the message imprint - algorithm used in the Request -* :BAD_REQUEST - Indicates that the timestamp server was not able to process - the Request properly -* :BAD_DATA_FORMAT - Indicates that the timestamp server was not able to - parse certain data in the Request -* :TIME_NOT_AVAILABLE - Indicates that the server could not access its time - source -* :UNACCEPTED_POLICY - Indicates that the requested policy identifier is not - recognized or supported by the timestamp server -* :UNACCEPTED_EXTENSIION - Indicates that an extension in the Request is not - supported by the timestamp server -* :ADD_INFO_NOT_AVAILABLE -Indicates that additional information requested - is either not understood or currently not available -* :SYSTEM_FAILURE - Timestamp creation failed due to an internal error that - occurred on the timestamp server - -call-seq: - response.failure_info -> nil or symbol - -## initialize(der) [](#method-i-initialize) -Creates a Response from a `File` or `string` parameter, the corresponding -`File` or `string` must be DER-encoded. Please note that Response is an -immutable read-only class. If you'd like to create timestamps please refer to -Factory instead. - -call-seq: - OpenSSL::Timestamp::Response.new(file) -> response - OpenSSL::Timestamp::Response.new(string) -> response - -## status() [](#method-i-status) -Returns one of GRANTED, GRANTED_WITH_MODS, REJECTION, WAITING, -REVOCATION_WARNING or REVOCATION_NOTIFICATION. A timestamp token has been -created only in case `status` is equal to GRANTED or GRANTED_WITH_MODS. - -call-seq: - response.status -> BN (never nil) - -## status_text() [](#method-i-status_text) -In cases of failure this field may contain an array of strings further -describing the origin of the failure. - -call-seq: - response.status_text -> Array of strings or nil - -## to_der() [](#method-i-to_der) -Returns the Response in DER-encoded form. - -call-seq: - response.to_der -> string - -## to_text() [](#method-i-to_text) - -## token() [](#method-i-token) -If a timestamp token is present, this returns it in the form of a -OpenSSL::PKCS7. - -call-seq: - response.token -> nil or OpenSSL::PKCS7 - -## token_info() [](#method-i-token_info) -Get the response's token info if present. - -call-seq: - response.token_info -> nil or OpenSSL::Timestamp::TokenInfo - -## tsa_certificate() [](#method-i-tsa_certificate) -If the Request specified to request the TSA certificate -(Request#cert_requested = true), then this field contains the certificate of -the timestamp authority. - -call-seq: - response.tsa_certificate -> OpenSSL::X509::Certificate or nil - -## verify(*args) [](#method-i-verify) -Verifies a timestamp token by checking the signature, validating the -certificate chain implied by tsa_certificate and by checking conformance to a -given Request. Mandatory parameters are the Request associated to this -Response, and an OpenSSL::X509::Store of trusted roots. - -Intermediate certificates can optionally be supplied for creating the -certificate chain. These intermediate certificates must all be instances of -OpenSSL::X509::Certificate. - -If validation fails, several kinds of exceptions can be raised: -* TypeError if types don't fit -* TimestampError if something is wrong with the timestamp token itself, if - it is not conformant to the Request, or if validation of the timestamp - certificate chain fails. - -call-seq: - response.verify(Request, root_store) -> Response - response.verify(Request, root_store, [intermediate_cert]) -> Response - diff --git a/example/ruby/OpenSSL/Timestamp/TimestampError.md b/example/ruby/OpenSSL/Timestamp/TimestampError.md deleted file mode 100644 index bbb66e0..0000000 --- a/example/ruby/OpenSSL/Timestamp/TimestampError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OpenSSL::Timestamp::TimestampError -**Inherits:** OpenSSL::OpenSSLError - - -Generic exception class of the Timestamp module. - - - diff --git a/example/ruby/OpenSSL/Timestamp/TokenInfo.md b/example/ruby/OpenSSL/Timestamp/TokenInfo.md deleted file mode 100644 index 5842827..0000000 --- a/example/ruby/OpenSSL/Timestamp/TokenInfo.md +++ /dev/null @@ -1,110 +0,0 @@ -# Class: OpenSSL::Timestamp::TokenInfo -**Inherits:** Object - - -Immutable and read-only representation of a timestamp token info from a -Response. - - - -#Instance Methods -## algorithm() [](#method-i-algorithm) -Returns the 'short name' of the object identifier representing the algorithm -that was used to derive the message imprint digest. For valid timestamps, this -is the same value that was already given in the Request. If status is GRANTED -or GRANTED_WITH_MODS, this is never `nil`. - -### Example: - algo = token_info.algorithm - puts algo -> "SHA1" - -call-seq: - token_info.algorithm -> string or nil - -## gen_time() [](#method-i-gen_time) -Returns time when this timestamp token was created. If status is GRANTED or -GRANTED_WITH_MODS, this is never `nil`. - -call-seq: - token_info.gen_time -> Time - -## initialize(der) [](#method-i-initialize) -Creates a TokenInfo from a `File` or `string` parameter, the corresponding -`File` or `string` must be DER-encoded. Please note that TokenInfo is an -immutable read-only class. If you'd like to create timestamps please refer to -Factory instead. - -call-seq: - OpenSSL::Timestamp::TokenInfo.new(file) -> token-info - OpenSSL::Timestamp::TokenInfo.new(string) -> token-info - -## message_imprint() [](#method-i-message_imprint) -Returns the message imprint digest. For valid timestamps, this is the same -value that was already given in the Request. If status is GRANTED or -GRANTED_WITH_MODS, this is never `nil`. - -### Example: - mi = token_info.msg_imprint - puts mi -> "DEADBEEF" - -call-seq: - token_info.msg_imprint -> string. - -## nonce() [](#method-i-nonce) -If the timestamp token is valid then this field contains the same nonce that -was passed to the timestamp server in the initial Request. - -call-seq: - token_info.nonce -> BN or nil - -## ordering() [](#method-i-ordering) -If the ordering field is missing, or if the ordering field is present and set -to false, then the genTime field only indicates the time at which the -time-stamp token has been created by the TSA. In such a case, the ordering of -time-stamp tokens issued by the same TSA or different TSAs is only possible -when the difference between the genTime of the first time-stamp token and the -genTime of the second time-stamp token is greater than the sum of the -accuracies of the genTime for each time-stamp token. - -If the ordering field is present and set to true, every time-stamp token from -the same TSA can always be ordered based on the genTime field, regardless of -the genTime accuracy. - -call-seq: - token_info.ordering -> true, falses or nil - -## policy_id() [](#method-i-policy_id) -Returns the timestamp policy object identifier of the policy this timestamp -was created under. If status is GRANTED or GRANTED_WITH_MODS, this is never -`nil`. - -### Example: - id = token_info.policy_id - puts id -> "1.2.3.4.5" - -call-seq: - token_info.policy_id -> string or nil - -## serial_number() [](#method-i-serial_number) -Returns serial number of the timestamp token. This value shall never be the -same for two timestamp tokens issued by a dedicated timestamp authority. If -status is GRANTED or GRANTED_WITH_MODS, this is never `nil`. - -call-seq: - token_info.serial_number -> BN or nil - -## to_der() [](#method-i-to_der) -Returns the TokenInfo in DER-encoded form. - -call-seq: - token_info.to_der -> string - -## to_text() [](#method-i-to_text) - -## version() [](#method-i-version) -Returns the version number of the token info. With compliant servers, this -value should be `1` if present. If status is GRANTED or GRANTED_WITH_MODS. - -call-seq: - token_info.version -> Integer or nil - diff --git a/example/ruby/OpenSSL/X509.md b/example/ruby/OpenSSL/X509.md deleted file mode 100644 index 6e6a407..0000000 --- a/example/ruby/OpenSSL/X509.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: OpenSSL::X509 - - - - - diff --git a/example/ruby/OpenSSL/X509/Attribute.md b/example/ruby/OpenSSL/X509/Attribute.md deleted file mode 100644 index 854b976..0000000 --- a/example/ruby/OpenSSL/X509/Attribute.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: OpenSSL::X509::Attribute -**Inherits:** Object - -**Includes:** OpenSSL::Marshal - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## _dump(_level) [](#method-i-_dump) - -## initialize(*args) [](#method-i-initialize) - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## oid() [](#method-i-oid) - -**@overload** [] - -## oid=(oid) [](#method-i-oid=) - -**@overload** [] - -## to_der() [](#method-i-to_der) - -**@overload** [] - -## value() [](#method-i-value) - -**@overload** [] - -## value=(value) [](#method-i-value=) - -**@overload** [] - diff --git a/example/ruby/OpenSSL/X509/AttributeError.md b/example/ruby/OpenSSL/X509/AttributeError.md deleted file mode 100644 index 4f6f350..0000000 --- a/example/ruby/OpenSSL/X509/AttributeError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::X509::AttributeError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/X509/CRL.md b/example/ruby/OpenSSL/X509/CRL.md deleted file mode 100644 index f40efcf..0000000 --- a/example/ruby/OpenSSL/X509/CRL.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: OpenSSL::X509::CRL -**Inherits:** Object - -**Includes:** OpenSSL::Marshal, OpenSSL::X509::Extension::AuthorityKeyIdentifier - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## _dump(_level) [](#method-i-_dump) - -## add_extension(extension) [](#method-i-add_extension) - -## add_revoked(revoked) [](#method-i-add_revoked) - -## authority_key_identifier() [](#method-i-authority_key_identifier) -Get the issuing certificate's key identifier from the authorityKeyIdentifier -extension, as described in RFC5280 Section 4.2.1.1 - -Returns the binary String keyIdentifier or nil or raises ASN1::ASN1Error. - -## extensions() [](#method-i-extensions) -Gets X509v3 extensions as array of X509Ext objects - -## extensions=(ary) [](#method-i-extensions=) -Sets X509_EXTENSIONs - -## find_extension(oid) [](#method-i-find_extension) - -## initialize(*args) [](#method-i-initialize) - -## initialize_copy(other) [](#method-i-initialize_copy) - -## issuer() [](#method-i-issuer) - -## issuer=(issuer) [](#method-i-issuer=) -NO DUP - don't free - -## last_update() [](#method-i-last_update) - -## last_update=(time) [](#method-i-last_update=) - -## next_update() [](#method-i-next_update) - -## next_update=(time) [](#method-i-next_update=) - -## revoked() [](#method-i-revoked) - -## revoked=(ary) [](#method-i-revoked=) - -## sign(key, digest) [](#method-i-sign) - -## signature_algorithm() [](#method-i-signature_algorithm) - -## to_der() [](#method-i-to_der) - -## to_pem() [](#method-i-to_pem) - -## to_text() [](#method-i-to_text) - -## verify(key) [](#method-i-verify) - -## version() [](#method-i-version) - -## version=(version) [](#method-i-version=) - diff --git a/example/ruby/OpenSSL/X509/CRLError.md b/example/ruby/OpenSSL/X509/CRLError.md deleted file mode 100644 index 0f40eaa..0000000 --- a/example/ruby/OpenSSL/X509/CRLError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::X509::CRLError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/X509/Certificate.md b/example/ruby/OpenSSL/X509/Certificate.md deleted file mode 100644 index 939cd65..0000000 --- a/example/ruby/OpenSSL/X509/Certificate.md +++ /dev/null @@ -1,269 +0,0 @@ -# Class: OpenSSL::X509::Certificate -**Inherits:** Object - -**Includes:** OpenSSL::Marshal, OpenSSL::X509::Extension::AuthorityInfoAccess, OpenSSL::X509::Extension::AuthorityKeyIdentifier, OpenSSL::X509::Extension::CRLDistributionPoints, OpenSSL::X509::Extension::SubjectKeyIdentifier - - -Implementation of an X.509 certificate as specified in RFC 5280. Provides -access to a certificate's attributes and allows certificates to be read from a -string, but also supports the creation of new certificates from scratch. - -### Reading a certificate from a file - -Certificate is capable of handling DER-encoded certificates and certificates -encoded in OpenSSL's PEM format. - - raw = File.binread "cert.cer" # DER- or PEM-encoded - certificate = OpenSSL::X509::Certificate.new raw - -### Saving a certificate to a file - -A certificate may be encoded in DER format - - cert = ... - File.open("cert.cer", "wb") { |f| f.print cert.to_der } - -or in PEM format - - cert = ... - File.open("cert.pem", "wb") { |f| f.print cert.to_pem } - -X.509 certificates are associated with a private/public key pair, typically a -RSA, DSA or ECC key (see also OpenSSL::PKey::RSA, OpenSSL::PKey::DSA and -OpenSSL::PKey::EC), the public key itself is stored within the certificate and -can be accessed in form of an OpenSSL::PKey. Certificates are typically used -to be able to associate some form of identity with a key pair, for example web -servers serving pages over HTTPs use certificates to authenticate themselves -to the user. - -The public key infrastructure (PKI) model relies on trusted certificate -authorities ("root CAs") that issue these certificates, so that end users need -to base their trust just on a selected few authorities that themselves again -vouch for subordinate CAs issuing their certificates to end users. - -The OpenSSL::X509 module provides the tools to set up an independent PKI, -similar to scenarios where the 'openssl' command line tool is used for issuing -certificates in a private PKI. - -### Creating a root CA certificate and an end-entity certificate - -First, we need to create a "self-signed" root certificate. To do so, we need -to generate a key first. Please note that the choice of "1" as a serial number -is considered a security flaw for real certificates. Secure choices are -integers in the two-digit byte range and ideally not sequential but secure -random numbers, steps omitted here to keep the example concise. - - root_key = OpenSSL::PKey::RSA.new 2048 # the CA's public/private key - root_ca = OpenSSL::X509::Certificate.new - root_ca.version = 2 # cf. RFC 5280 - to make it a "v3" certificate - root_ca.serial = 1 - root_ca.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby CA" - root_ca.issuer = root_ca.subject # root CA's are "self-signed" - root_ca.public_key = root_key.public_key - root_ca.not_before = Time.now - root_ca.not_after = root_ca.not_before + 2 * 365 * 24 * 60 * 60 # 2 years validity - ef = OpenSSL::X509::ExtensionFactory.new - ef.subject_certificate = root_ca - ef.issuer_certificate = root_ca - root_ca.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true)) - root_ca.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true)) - root_ca.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) - root_ca.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false)) - root_ca.sign(root_key, OpenSSL::Digest.new('SHA256')) - -The next step is to create the end-entity certificate using the root CA -certificate. - - key = OpenSSL::PKey::RSA.new 2048 - cert = OpenSSL::X509::Certificate.new - cert.version = 2 - cert.serial = 2 - cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby certificate" - cert.issuer = root_ca.subject # root CA is the issuer - cert.public_key = key.public_key - cert.not_before = Time.now - cert.not_after = cert.not_before + 1 * 365 * 24 * 60 * 60 # 1 years validity - ef = OpenSSL::X509::ExtensionFactory.new - ef.subject_certificate = cert - ef.issuer_certificate = root_ca - cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true)) - cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) - cert.sign(root_key, OpenSSL::Digest.new('SHA256')) - - -# Class Methods -## load(buffer ) [](#method-c-load) -Read the chained certificates from the given input. Supports both PEM and DER -encoded certificates. - -PEM is a text format and supports more than one certificate. - -DER is a binary format and only supports one certificate. - -If the file is empty, or contains only unrelated data, an -`OpenSSL::X509::CertificateError` exception will be raised. -**@overload** [] - -**@overload** [] - -## load_file(path ) [](#method-c-load_file) - -#Instance Methods -## ==(other) [](#method-i-==) -Compares the two certificates. Note that this takes into account all fields, -not just the issuer name and the serial number. - -**@overload** [] - -## _dump(_level) [](#method-i-_dump) - -## add_extension(extension) [](#method-i-add_extension) - -**@overload** [] - -## authority_key_identifier() [](#method-i-authority_key_identifier) -Get the issuing certificate's key identifier from the authorityKeyIdentifier -extension, as described in RFC5280 Section 4.2.1.1 - -Returns the binary String keyIdentifier or nil or raises ASN1::ASN1Error. - -## ca_issuer_uris() [](#method-i-ca_issuer_uris) -Get the information and services for the issuer from the certificate's -authority information access extension exteension, as described in RFC5280 -Section 4.2.2.1. - -Returns an array of strings or nil or raises ASN1::ASN1Error. - -## check_private_key(key) [](#method-i-check_private_key) -Returns `true` if *key* is the corresponding private key to the Subject Public -Key Information, `false` otherwise. - -**@overload** [] - -## crl_uris() [](#method-i-crl_uris) -Get the distributionPoint fullName URI from the certificate's CRL distribution -points extension, as described in RFC 5280 Section 4.2.1.13. - -Returns an array of strings or nil or raises ASN1::ASN1Error. - -## extensions() [](#method-i-extensions) - -**@overload** [] - -## extensions=(ary) [](#method-i-extensions=) - -## find_extension(oid) [](#method-i-find_extension) - -## initialize(*args) [](#method-i-initialize) - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## inspect() [](#method-i-inspect) - -## issuer() [](#method-i-issuer) - -**@overload** [] - -## issuer=(issuer) [](#method-i-issuer=) - -**@overload** [] - -## not_after() [](#method-i-not_after) - -**@overload** [] - -## not_after=(time) [](#method-i-not_after=) - -**@overload** [] - -## not_before() [](#method-i-not_before) - -**@overload** [] - -## not_before=(time) [](#method-i-not_before=) - -**@overload** [] - -## ocsp_uris() [](#method-i-ocsp_uris) -Get the URIs for OCSP from the certificate's authority information access -extension exteension, as described in RFC5280 Section 4.2.2.1. - -Returns an array of strings or nil or raises ASN1::ASN1Error. - -## pretty_print(q) [](#method-i-pretty_print) - -## public_key() [](#method-i-public_key) - -**@overload** [] - -## public_key=(key) [](#method-i-public_key=) - -**@overload** [] - -## serial() [](#method-i-serial) - -**@overload** [] - -## serial=(num) [](#method-i-serial=) - -**@overload** [] - -## sign(key, digest) [](#method-i-sign) - -**@overload** [] - -## signature_algorithm() [](#method-i-signature_algorithm) - -**@overload** [] - -## subject() [](#method-i-subject) - -**@overload** [] - -## subject=(subject) [](#method-i-subject=) - -**@overload** [] - -## subject_key_identifier() [](#method-i-subject_key_identifier) -Get the subject's key identifier from the subjectKeyIdentifier exteension, as -described in RFC5280 Section 4.2.1.2. - -Returns the binary String key identifier or nil or raises ASN1::ASN1Error. - -## tbs_bytes() [](#method-i-tbs_bytes) -Returns the DER-encoded bytes of the certificate's to be signed certificate. -This is mainly useful for validating embedded certificate transparency -signatures. - -**@overload** [] - -## to_der() [](#method-i-to_der) - -**@overload** [] - -## to_pem() [](#method-i-to_pem) - -**@overload** [] - -## to_text() [](#method-i-to_text) - -**@overload** [] - -## verify(key) [](#method-i-verify) -Verifies the signature of the certificate, with the public key *key*. *key* -must be an instance of OpenSSL::PKey. - -**@overload** [] - -## version() [](#method-i-version) - -**@overload** [] - -## version=(version) [](#method-i-version=) - -**@overload** [] - diff --git a/example/ruby/OpenSSL/X509/CertificateError.md b/example/ruby/OpenSSL/X509/CertificateError.md deleted file mode 100644 index ab4fc5e..0000000 --- a/example/ruby/OpenSSL/X509/CertificateError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::X509::CertificateError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/X509/Extension.md b/example/ruby/OpenSSL/X509/Extension.md deleted file mode 100644 index 5f3a908..0000000 --- a/example/ruby/OpenSSL/X509/Extension.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: OpenSSL::X509::Extension -**Inherits:** Object - -**Includes:** OpenSSL::Marshal - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## _dump(_level) [](#method-i-_dump) - -## critical=(flag) [](#method-i-critical=) - -## critical?() [](#method-i-critical?) - -**@return** [Boolean] - -## initialize(*args) [](#method-i-initialize) -Creates an X509 extension. - -The extension may be created from *der* data or from an extension *oid* and -*value*. The *oid* may be either an OID or an extension name. If *critical* -is `true` the extension is marked critical. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## oid() [](#method-i-oid) - -## oid=(oid) [](#method-i-oid=) - -## to_a() [](#method-i-to_a) - -## to_der() [](#method-i-to_der) - -## to_h() [](#method-i-to_h) -{"oid"=>sn|ln, "value"=>value, "critical"=>true|false} - -## to_s() [](#method-i-to_s) -"oid = critical, value" - -## value() [](#method-i-value) - -## value=(data) [](#method-i-value=) - -## value_der() [](#method-i-value_der) - diff --git a/example/ruby/OpenSSL/X509/Extension/AuthorityInfoAccess.md b/example/ruby/OpenSSL/X509/Extension/AuthorityInfoAccess.md deleted file mode 100644 index a2b57f3..0000000 --- a/example/ruby/OpenSSL/X509/Extension/AuthorityInfoAccess.md +++ /dev/null @@ -1,24 +0,0 @@ -# Module: OpenSSL::X509::Extension::AuthorityInfoAccess - -**Includes:** OpenSSL::X509::Extension::Helpers - - - - - -#Instance Methods -## ca_issuer_uris() [](#method-i-ca_issuer_uris) -Get the information and services for the issuer from the certificate's -authority information access extension exteension, as described in RFC5280 -Section 4.2.2.1. - -Returns an array of strings or nil or raises ASN1::ASN1Error. - -## find_extension(oid) [](#method-i-find_extension) - -## ocsp_uris() [](#method-i-ocsp_uris) -Get the URIs for OCSP from the certificate's authority information access -extension exteension, as described in RFC5280 Section 4.2.2.1. - -Returns an array of strings or nil or raises ASN1::ASN1Error. - diff --git a/example/ruby/OpenSSL/X509/Extension/AuthorityKeyIdentifier.md b/example/ruby/OpenSSL/X509/Extension/AuthorityKeyIdentifier.md deleted file mode 100644 index d8ebf5e..0000000 --- a/example/ruby/OpenSSL/X509/Extension/AuthorityKeyIdentifier.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: OpenSSL::X509::Extension::AuthorityKeyIdentifier - -**Includes:** OpenSSL::X509::Extension::Helpers - - - - - -#Instance Methods -## authority_key_identifier() [](#method-i-authority_key_identifier) -Get the issuing certificate's key identifier from the authorityKeyIdentifier -extension, as described in RFC5280 Section 4.2.1.1 - -Returns the binary String keyIdentifier or nil or raises ASN1::ASN1Error. - -## find_extension(oid) [](#method-i-find_extension) - diff --git a/example/ruby/OpenSSL/X509/Extension/CRLDistributionPoints.md b/example/ruby/OpenSSL/X509/Extension/CRLDistributionPoints.md deleted file mode 100644 index f92d520..0000000 --- a/example/ruby/OpenSSL/X509/Extension/CRLDistributionPoints.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: OpenSSL::X509::Extension::CRLDistributionPoints - -**Includes:** OpenSSL::X509::Extension::Helpers - - - - - -#Instance Methods -## crl_uris() [](#method-i-crl_uris) -Get the distributionPoint fullName URI from the certificate's CRL distribution -points extension, as described in RFC 5280 Section 4.2.1.13. - -Returns an array of strings or nil or raises ASN1::ASN1Error. - -## find_extension(oid) [](#method-i-find_extension) - diff --git a/example/ruby/OpenSSL/X509/Extension/Helpers.md b/example/ruby/OpenSSL/X509/Extension/Helpers.md deleted file mode 100644 index 7572be0..0000000 --- a/example/ruby/OpenSSL/X509/Extension/Helpers.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: OpenSSL::X509::Extension::Helpers - - - - - -#Instance Methods -## find_extension(oid) [](#method-i-find_extension) - diff --git a/example/ruby/OpenSSL/X509/Extension/SubjectKeyIdentifier.md b/example/ruby/OpenSSL/X509/Extension/SubjectKeyIdentifier.md deleted file mode 100644 index ead9d67..0000000 --- a/example/ruby/OpenSSL/X509/Extension/SubjectKeyIdentifier.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: OpenSSL::X509::Extension::SubjectKeyIdentifier - -**Includes:** OpenSSL::X509::Extension::Helpers - - - - - -#Instance Methods -## find_extension(oid) [](#method-i-find_extension) - -## subject_key_identifier() [](#method-i-subject_key_identifier) -Get the subject's key identifier from the subjectKeyIdentifier exteension, as -described in RFC5280 Section 4.2.1.2. - -Returns the binary String key identifier or nil or raises ASN1::ASN1Error. - diff --git a/example/ruby/OpenSSL/X509/ExtensionError.md b/example/ruby/OpenSSL/X509/ExtensionError.md deleted file mode 100644 index 8715ccb..0000000 --- a/example/ruby/OpenSSL/X509/ExtensionError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::X509::ExtensionError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/X509/ExtensionFactory.md b/example/ruby/OpenSSL/X509/ExtensionFactory.md deleted file mode 100644 index 4c028a0..0000000 --- a/example/ruby/OpenSSL/X509/ExtensionFactory.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: OpenSSL::X509::ExtensionFactory -**Inherits:** Object - - - - - -#Instance Methods -## create_ext(*args) [](#method-i-create_ext) -Creates a new X509::Extension with passed values. See also x509v3_config(5). - -**@overload** [] - -**@overload** [] - -## create_ext_from_array(ary) [](#method-i-create_ext_from_array) - -**@raise** [ExtensionError] - -## create_ext_from_hash(hash) [](#method-i-create_ext_from_hash) - -## create_ext_from_string(str) [](#method-i-create_ext_from_string) -"oid = critical, value" - -## create_extension(*arg) [](#method-i-create_extension) - -## crl=(crl) [](#method-i-crl=) - -## initialize(*args) [](#method-i-initialize) - -## issuer_certificate=(cert) [](#method-i-issuer_certificate=) - -## subject_certificate=(cert) [](#method-i-subject_certificate=) - -## subject_request=(req) [](#method-i-subject_request=) - diff --git a/example/ruby/OpenSSL/X509/Name.md b/example/ruby/OpenSSL/X509/Name.md deleted file mode 100644 index b6b250c..0000000 --- a/example/ruby/OpenSSL/X509/Name.md +++ /dev/null @@ -1,248 +0,0 @@ -# Class: OpenSSL::X509::Name -**Inherits:** Object - -**Includes:** Comparable, OpenSSL::Marshal - - -An X.509 name represents a hostname, email address or other entity associated -with a public key. - -You can create a Name by parsing a distinguished name String or by supplying -the distinguished name as an Array. - - name = OpenSSL::X509::Name.parse_rfc2253 'DC=example,CN=nobody' - - name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']] - - -# Class Methods -## parse_openssl(str , template OBJECT_TYPE_TEMPLATE) [](#method-c-parse_openssl) -Parses the string representation of a distinguished name. Two different forms -are supported: - -* OpenSSL format (`X509_NAME_oneline()`) used by `#to_s`. For example: - `/DC=com/DC=example/CN=nobody` -* OpenSSL format (`X509_NAME_print()`) used by - `#to_s(OpenSSL::X509::Name::COMPAT)`. For example: `DC=com, DC=example, - CN=nobody` - -Neither of them is standardized and has quirks and inconsistencies in handling -of escaped characters or multi-valued RDNs. - -Use of this method is discouraged in new applications. See Name.parse_rfc2253 -and #to_utf8 for the alternative. -## parse_rfc2253(str , template OBJECT_TYPE_TEMPLATE) [](#method-c-parse_rfc2253) -Parses the UTF-8 string representation of a distinguished name, according to -RFC 2253. - -See also #to_utf8 for the opposite operation. - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## _dump(_level) [](#method-i-_dump) - -## add_entry(*args) [](#method-i-add_entry) -Adds a new entry with the given *oid* and *value* to this name. The *oid* is -an object identifier defined in ASN.1. Some common OIDs are: - -C -: Country Name - -CN -: Common Name - -DC -: Domain Component - -O -: Organization Name - -OU -: Organizational Unit Name - -ST -: State or Province Name - - -The optional keyword parameters *loc* and *set* specify where to insert the -new attribute. Refer to the manpage of X509_NAME_add_entry(3) for details. -*loc* defaults to -1 and *set* defaults to 0. This appends a single-valued RDN -to the end. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## cmp(other) [](#method-i-cmp) -Compares this Name with *other* and returns `0` if they are the same and `-1` -or `+1` if they are greater or less than each other respectively. Returns -`nil` if they are not comparable (i.e. different types). - -**@overload** [] - -**@overload** [] - -## eql?(other) [](#method-i-eql?) -Returns true if *name* and *other* refer to the same hash key. - -**@overload** [] - -**@return** [Boolean] - -## hash() [](#method-i-hash) -The hash value returned is suitable for use as a certificate's filename in a -CA path. - -**@overload** [] - -## hash_old() [](#method-i-hash_old) -Returns an MD5 based hash used in OpenSSL 0.9.X. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new Name. - -A name may be created from a DER encoded string *der*, an Array representing a -*distinguished_name* or a *distinguished_name* along with a *template*. - - name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']] - - name = OpenSSL::X509::Name.new name.to_der - -See add_entry for a description of the *distinguished_name* Array's contents - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## initialize_copy(other) [](#method-i-initialize_copy) - -## inspect() [](#method-i-inspect) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) - -## to_a() [](#method-i-to_a) -Returns an Array representation of the distinguished name suitable for passing -to ::new - -**@overload** [] - -## to_der() [](#method-i-to_der) -Converts the name to DER encoding - -**@overload** [] - -## to_s(*args) [](#method-i-to_s) -Returns a String representation of the Distinguished Name. *format* is one of: - -* OpenSSL::X509::Name::COMPAT -* OpenSSL::X509::Name::RFC2253 -* OpenSSL::X509::Name::ONELINE -* OpenSSL::X509::Name::MULTILINE - -If *format* is omitted, the largely broken and traditional OpenSSL format -(`X509_NAME_oneline()` format) is chosen. - -**Use of this method is discouraged.** None of the formats other than -OpenSSL::X509::Name::RFC2253 is standardized and may show an inconsistent -behavior through OpenSSL versions. - -It is recommended to use #to_utf8 instead, which is equivalent to calling -`name.to_s(OpenSSL::X509::Name::RFC2253).force_encoding("UTF-8")`. - -**@overload** [] - -**@overload** [] - -## to_utf8() [](#method-i-to_utf8) -Returns an UTF-8 representation of the distinguished name, as specified in -[RFC 2253](https://www.ietf.org/rfc/rfc2253.txt). - -**@overload** [] - diff --git a/example/ruby/OpenSSL/X509/Name/RFC2253DN.md b/example/ruby/OpenSSL/X509/Name/RFC2253DN.md deleted file mode 100644 index 6785053..0000000 --- a/example/ruby/OpenSSL/X509/Name/RFC2253DN.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: OpenSSL::X509::Name::RFC2253DN - - - - -# Class Methods -## expand_hexstring(str ) [](#method-c-expand_hexstring) -## expand_pair(str ) [](#method-c-expand_pair) -## expand_value(str1 , str2 , str3 ) [](#method-c-expand_value) -## scan(dn ) [](#method-c-scan) - diff --git a/example/ruby/OpenSSL/X509/NameError.md b/example/ruby/OpenSSL/X509/NameError.md deleted file mode 100644 index 949fe21..0000000 --- a/example/ruby/OpenSSL/X509/NameError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::X509::NameError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/X509/Request.md b/example/ruby/OpenSSL/X509/Request.md deleted file mode 100644 index 11ea2a8..0000000 --- a/example/ruby/OpenSSL/X509/Request.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: OpenSSL::X509::Request -**Inherits:** Object - -**Includes:** OpenSSL::Marshal - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## _dump(_level) [](#method-i-_dump) - -## add_attribute(attr) [](#method-i-add_attribute) - -## attributes() [](#method-i-attributes) - -## attributes=(ary) [](#method-i-attributes=) - -## initialize(*args) [](#method-i-initialize) - -## initialize_copy(other) [](#method-i-initialize_copy) - -## public_key() [](#method-i-public_key) - -## public_key=(key) [](#method-i-public_key=) -NO DUP - OK - -## sign(key, digest) [](#method-i-sign) - -## signature_algorithm() [](#method-i-signature_algorithm) - -## subject() [](#method-i-subject) - -## subject=(subject) [](#method-i-subject=) - -## to_der() [](#method-i-to_der) - -## to_pem() [](#method-i-to_pem) - -## to_text() [](#method-i-to_text) - -## verify(key) [](#method-i-verify) -Checks that cert signature is made with PRIVversion of this PUBLIC 'key' - -## version() [](#method-i-version) - -## version=(version) [](#method-i-version=) - diff --git a/example/ruby/OpenSSL/X509/RequestError.md b/example/ruby/OpenSSL/X509/RequestError.md deleted file mode 100644 index ff5f98f..0000000 --- a/example/ruby/OpenSSL/X509/RequestError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::X509::RequestError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/X509/Revoked.md b/example/ruby/OpenSSL/X509/Revoked.md deleted file mode 100644 index 3c04f98..0000000 --- a/example/ruby/OpenSSL/X509/Revoked.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: OpenSSL::X509::Revoked -**Inherits:** Object - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## add_extension(ext) [](#method-i-add_extension) - -## extensions() [](#method-i-extensions) -Gets X509v3 extensions as array of X509Ext objects - -## extensions=(ary) [](#method-i-extensions=) -Sets X509_EXTENSIONs - -## initialize(*args) [](#method-i-initialize) - -## initialize_copy(other) [](#method-i-initialize_copy) - -## serial() [](#method-i-serial) - -## serial=(num) [](#method-i-serial=) - -## time() [](#method-i-time) - -## time=(time) [](#method-i-time=) - -## to_der() [](#method-i-to_der) - diff --git a/example/ruby/OpenSSL/X509/RevokedError.md b/example/ruby/OpenSSL/X509/RevokedError.md deleted file mode 100644 index b3b1bf3..0000000 --- a/example/ruby/OpenSSL/X509/RevokedError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::X509::RevokedError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenSSL/X509/Store.md b/example/ruby/OpenSSL/X509/Store.md deleted file mode 100644 index 3237bc3..0000000 --- a/example/ruby/OpenSSL/X509/Store.md +++ /dev/null @@ -1,161 +0,0 @@ -# Class: OpenSSL::X509::Store -**Inherits:** Object - - -The X509 certificate store holds trusted CA certificates used to verify peer -certificates. - -The easiest way to create a useful certificate store is: - - cert_store = OpenSSL::X509::Store.new - cert_store.set_default_paths - -This will use your system's built-in certificates. - -If your system does not have a default set of certificates you can obtain a -set extracted from Mozilla CA certificate store by cURL maintainers here: -https://curl.haxx.se/docs/caextract.html (You may wish to use the -firefox-db2pem.sh script to extract the certificates from a local install to -avoid man-in-the-middle attacks.) - -After downloading or generating a cacert.pem from the above link you can -create a certificate store from the pem file like this: - - cert_store = OpenSSL::X509::Store.new - cert_store.add_file 'cacert.pem' - -The certificate store can be used with an SSLSocket like this: - - ssl_context = OpenSSL::SSL::SSLContext.new - ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER - ssl_context.cert_store = cert_store - - tcp_socket = TCPSocket.open 'example.com', 443 - - ssl_socket = OpenSSL::SSL::SSLSocket.new tcp_socket, ssl_context - - - -#Instance Methods -## add_cert(arg) [](#method-i-add_cert) -Adds the OpenSSL::X509::Certificate *cert* to the certificate store. - -See also the man page X509_STORE_add_cert(3). - -**@overload** [] - -## add_crl(arg) [](#method-i-add_crl) -Adds the OpenSSL::X509::CRL *crl* to the store. - -See also the man page X509_STORE_add_crl(3). - -**@overload** [] - -## add_file(file) [](#method-i-add_file) -Adds the certificates in *file* to the certificate store. *file* is the path -to the file, and the file contains one or more certificates in PEM format -concatenated together. - -See also the man page X509_LOOKUP_file(3). - -**@overload** [] - -## add_path(dir) [](#method-i-add_path) -Adds *path* as the hash dir to be looked up by the store. - -See also the man page X509_LOOKUP_hash_dir(3). - -**@overload** [] - -## flags=(flags) [](#method-i-flags=) -Sets the default flags used by certificate chain verification performed with -the Store. - -*flags* consists of zero or more of the constants defined in OpenSSL::X509 -with name V_FLAG_* or'ed together. - -OpenSSL::X509::StoreContext#flags= can be used to change the flags for a -single verification operation. - -See also the man page X509_VERIFY_PARAM_set_flags(3). - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new X509::Store. - -**@overload** [] - -## purpose=(purpose) [](#method-i-purpose=) -Sets the store's default verification purpose. If specified, the verifications -on the store will check every certificate's extensions are consistent with the -purpose. The purpose is specified by constants: - -* X509::PURPOSE_SSL_CLIENT -* X509::PURPOSE_SSL_SERVER -* X509::PURPOSE_NS_SSL_SERVER -* X509::PURPOSE_SMIME_SIGN -* X509::PURPOSE_SMIME_ENCRYPT -* X509::PURPOSE_CRL_SIGN -* X509::PURPOSE_ANY -* X509::PURPOSE_OCSP_HELPER -* X509::PURPOSE_TIMESTAMP_SIGN - -OpenSSL::X509::StoreContext#purpose= can be used to change the value for a -single verification operation. - -See also the man page X509_VERIFY_PARAM_set_purpose(3). - -**@overload** [] - -## set_default_paths() [](#method-i-set_default_paths) -Configures *store* to look up CA certificates from the system default -certificate store as needed basis. The location of the store can usually be -determined by: - -* OpenSSL::X509::DEFAULT_CERT_FILE -* OpenSSL::X509::DEFAULT_CERT_DIR - -See also the man page X509_STORE_set_default_paths(3). - -**@overload** [] - -## time=(time) [](#method-i-time=) -Sets the time to be used in the certificate verifications with the store. By -default, if not specified, the current system time is used. - -OpenSSL::X509::StoreContext#time= can be used to change the value for a single -verification operation. - -See also the man page X509_VERIFY_PARAM_set_time(3). - -**@overload** [] - -## trust=(trust) [](#method-i-trust=) -Sets the default trust settings used by the certificate verification with the -store. - -OpenSSL::X509::StoreContext#trust= can be used to change the value for a -single verification operation. - -See also the man page X509_VERIFY_PARAM_set_trust(3). - -**@overload** [] - -## verify(*args) [](#method-i-verify) -Performs a certificate verification on the OpenSSL::X509::Certificate *cert*. - -*chain* can be an array of OpenSSL::X509::Certificate that is used to -construct the certificate chain. - -If a block is given, it overrides the callback set by #verify_callback=. - -After finishing the verification, the error information can be retrieved by -#error, #error_string, and the resulting complete certificate chain can be -retrieved by #chain. - -**@overload** [] - -## verify_callback=(cb) [](#method-i-verify_callback=) -General callback for OpenSSL verify - diff --git a/example/ruby/OpenSSL/X509/StoreContext.md b/example/ruby/OpenSSL/X509/StoreContext.md deleted file mode 100644 index 4ffb028..0000000 --- a/example/ruby/OpenSSL/X509/StoreContext.md +++ /dev/null @@ -1,108 +0,0 @@ -# Class: OpenSSL::X509::StoreContext -**Inherits:** Object - - -A StoreContext is used while validating a single certificate and holds the -status involved. - - - -#Instance Methods -## chain() [](#method-i-chain) -Returns the verified chain. - -See also the man page X509_STORE_CTX_set0_verified_chain(3). - -**@overload** [] - -## cleanup() [](#method-i-cleanup) - -## current_cert() [](#method-i-current_cert) -Returns the certificate which caused the error. - -See also the man page X509_STORE_CTX_get_current_cert(3). - -**@overload** [] - -## current_crl() [](#method-i-current_crl) -Returns the CRL which caused the error. - -See also the man page X509_STORE_CTX_get_current_crl(3). - -**@overload** [] - -## error() [](#method-i-error) -Returns the error code of *stctx*. This is typically called after #verify is -done, or from the verification callback set to -OpenSSL::X509::Store#verify_callback=. - -See also the man page X509_STORE_CTX_get_error(3). - -**@overload** [] - -## error=(err) [](#method-i-error=) -Sets the error code of *stctx*. This is used by the verification callback set -to OpenSSL::X509::Store#verify_callback=. - -See also the man page X509_STORE_CTX_set_error(3). - -**@overload** [] - -## error_depth() [](#method-i-error_depth) -Returns the depth of the chain. This is used in combination with #error. - -See also the man page X509_STORE_CTX_get_error_depth(3). - -**@overload** [] - -## error_string() [](#method-i-error_string) -Returns the human readable error string corresponding to the error code -retrieved by #error. - -See also the man page X509_verify_cert_error_string(3). - -**@overload** [] - -## flags=(flags) [](#method-i-flags=) -Sets the verification flags to the context. This overrides the default value -set by Store#flags=. - -See also the man page X509_VERIFY_PARAM_set_flags(3). - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Sets up a StoreContext for a verification of the X.509 certificate *cert*. - -**@overload** [] - -## purpose=(purpose) [](#method-i-purpose=) -Sets the purpose of the context. This overrides the default value set by -Store#purpose=. - -See also the man page X509_VERIFY_PARAM_set_purpose(3). - -**@overload** [] - -## time=(time) [](#method-i-time=) -Sets the time used in the verification. If not set, the current time is used. - -See also the man page X509_VERIFY_PARAM_set_time(3). - -**@overload** [] - -## trust=(trust) [](#method-i-trust=) -Sets the trust settings of the context. This overrides the default value set -by Store#trust=. - -See also the man page X509_VERIFY_PARAM_set_trust(3). - -**@overload** [] - -## verify() [](#method-i-verify) -Performs the certificate verification using the parameters set to *stctx*. - -See also the man page X509_verify_cert(3). - -**@overload** [] - diff --git a/example/ruby/OpenSSL/X509/StoreError.md b/example/ruby/OpenSSL/X509/StoreError.md deleted file mode 100644 index a9e4c99..0000000 --- a/example/ruby/OpenSSL/X509/StoreError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenSSL::X509::StoreError -**Inherits:** OpenSSL::OpenSSLError - - - - - diff --git a/example/ruby/OpenStruct.md b/example/ruby/OpenStruct.md deleted file mode 100644 index 1bcab6c..0000000 --- a/example/ruby/OpenStruct.md +++ /dev/null @@ -1,263 +0,0 @@ -# Class: OpenStruct -**Inherits:** Object - - -An OpenStruct is a data structure, similar to a Hash, that allows the -definition of arbitrary attributes with their accompanying values. This is -accomplished by using Ruby's metaprogramming to define methods on the class -itself. - -## Examples - - require "ostruct" - - person = OpenStruct.new - person.name = "John Smith" - person.age = 70 - - person.name # => "John Smith" - person.age # => 70 - person.address # => nil - -An OpenStruct employs a Hash internally to store the attributes and values and -can even be initialized with one: - - australia = OpenStruct.new(:country => "Australia", :capital => "Canberra") - # => # - -Hash keys with spaces or characters that could normally not be used for method -calls (e.g. `()[]*`) will not be immediately available on the OpenStruct -object as a method for retrieval or assignment, but can still be reached -through the Object#send method or using []. - - measurements = OpenStruct.new("length (in inches)" => 24) - measurements[:"length (in inches)"] # => 24 - measurements.send("length (in inches)") # => 24 - - message = OpenStruct.new(:queued? => true) - message.queued? # => true - message.send("queued?=", false) - message.queued? # => false - -Removing the presence of an attribute requires the execution of the -delete_field method as setting the property value to `nil` will not remove the -attribute. - - first_pet = OpenStruct.new(:name => "Rowdy", :owner => "John Smith") - second_pet = OpenStruct.new(:name => "Rowdy") - - first_pet.owner = nil - first_pet # => # - first_pet == second_pet # => false - - first_pet.delete_field(:owner) - first_pet # => # - first_pet == second_pet # => true - -Ractor compatibility: A frozen OpenStruct with shareable values is itself -shareable. - -## Caveats - -An OpenStruct utilizes Ruby's method lookup structure to find and define the -necessary methods for properties. This is accomplished through the methods -method_missing and define_singleton_method. - -This should be a consideration if there is a concern about the performance of -the objects that are created, as there is much more overhead in the setting of -these properties compared to using a Hash or a Struct. Creating an open struct -from a small Hash and accessing a few of the entries can be 200 times slower -than accessing the hash directly. - -This is a potential security issue; building OpenStruct from untrusted user -data (e.g. JSON web request) may be susceptible to a "symbol denial of -service" attack since the keys create methods and names of methods are never -garbage collected. - -This may also be the source of incompatibilities between Ruby versions: - - o = OpenStruct.new - o.then # => nil in Ruby < 2.6, enumerator for Ruby >= 2.6 - -Builtin methods may be overwritten this way, which may be a source of bugs or -security issues: - - o = OpenStruct.new - o.methods # => [:to_h, :marshal_load, :marshal_dump, :each_pair, ... - o.methods = [:foo, :bar] - o.methods # => [:foo, :bar] - -To help remedy clashes, OpenStruct uses only protected/private methods ending -with `!` and defines aliases for builtin public methods by adding a `!`: - - o = OpenStruct.new(make: 'Bentley', class: :luxury) - o.class # => :luxury - o.class! # => OpenStruct - -It is recommended (but not enforced) to not use fields ending in `!`; Note -that a subclass' methods may not be overwritten, nor can OpenStruct's own -methods ending with `!`. - -For all these reasons, consider not using OpenStruct at all. - - -# Class Methods -## json_create(object ) [](#method-c-json_create) -See #as_json. -# Attributes -## table[RW] [](#attribute-i-table) -:nodoc: - - -#Instance Methods -## ==(other) [](#method-i-==) -Compares this object and `other` for equality. An OpenStruct is equal to -`other` when `other` is an OpenStruct and the two objects' Hash tables are -equal. - - require "ostruct" - first_pet = OpenStruct.new("name" => "Rowdy") - second_pet = OpenStruct.new(:name => "Rowdy") - third_pet = OpenStruct.new("name" => "Rowdy", :age => nil) - - first_pet == second_pet # => true - first_pet == third_pet # => false - -## [](name) [](#method-i-[]) -:call-seq: - ostruct[name] -> object - -Returns the value of an attribute, or `nil` if there is no such attribute. - - require "ostruct" - person = OpenStruct.new("name" => "John Smith", "age" => 70) - person[:age] # => 70, same as person.age - -## []=(name, value) [](#method-i-[]=) -:call-seq: - ostruct[name] = obj -> obj - -Sets the value of an attribute. - - require "ostruct" - person = OpenStruct.new("name" => "John Smith", "age" => 70) - person[:age] = 42 # equivalent to person.age = 42 - person.age # => 42 - -## as_json() [](#method-i-as_json) -Methods `OpenStruct#as_json` and `OpenStruct.json_create` may be used to -serialize and deserialize a OpenStruct object; see -[Marshal](rdoc-ref:Marshal). - -Method `OpenStruct#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/ostruct' - x = OpenStruct.new('name' => 'Rowdy', :age => nil).as_json - # => {"json_class"=>"OpenStruct", "t"=>{:name=>'Rowdy', :age=>nil}} - -Method `JSON.create` deserializes such a hash, returning a OpenStruct object: - - OpenStruct.json_create(x) - # => # - -## delete_field(name, &block) [](#method-i-delete_field) -Removes the named field from the object and returns the value the field -contained if it was defined. You may optionally provide a block. If the field -is not defined, the result of the block is returned, or a NameError is raised -if no block was given. - - require "ostruct" - - person = OpenStruct.new(name: "John", age: 70, pension: 300) - - person.delete_field!("age") # => 70 - person # => # - -Setting the value to `nil` will not remove the attribute: - - person.pension = nil - person # => # - - person.delete_field('number') # => NameError - - person.delete_field('number') { 8675_309 } # => 8675309 - -## dig(name, *names) [](#method-i-dig) -:call-seq: - ostruct.dig(name, *identifiers) -> object - -Finds and returns the object in nested objects that is specified by `name` and -`identifiers`. The nested objects may be instances of various classes. See -[Dig Methods](rdoc-ref:dig_methods.rdoc). - -Examples: - require "ostruct" - address = OpenStruct.new("city" => "Anytown NC", "zip" => 12345) - person = OpenStruct.new("name" => "John Smith", "address" => address) - person.dig(:address, "zip") # => 12345 - person.dig(:business_address, "zip") # => nil - -## each_pair() [](#method-i-each_pair) -:call-seq: - ostruct.each_pair {|name, value| block } -> ostruct - ostruct.each_pair -> Enumerator - -Yields all attributes (as symbols) along with the corresponding values or -returns an enumerator if no block is given. - - require "ostruct" - data = OpenStruct.new("country" => "Australia", :capital => "Canberra") - data.each_pair.to_a # => [[:country, "Australia"], [:capital, "Canberra"]] - -## encode_with(coder) [](#method-i-encode_with) -Provides marshalling support for use by the YAML library. - -## eql?(other) [](#method-i-eql?) -Compares this object and `other` for equality. An OpenStruct is eql? to -`other` when `other` is an OpenStruct and the two objects' Hash tables are -eql?. - -**@return** [Boolean] - -## freeze() [](#method-i-freeze) - -## hash() [](#method-i-hash) -Computes a hash code for this OpenStruct. - -## init_with(coder) [](#method-i-init_with) -Provides marshalling support for use by the YAML library. - -## initialize(hashnil) [](#method-i-initialize) -Creates a new OpenStruct object. By default, the resulting OpenStruct object -will have no attributes. - -The optional `hash`, if given, will generate attributes and values (can be a -Hash, an OpenStruct or a Struct). For example: - - require "ostruct" - hash = { "country" => "Australia", :capital => "Canberra" } - data = OpenStruct.new(hash) - - data # => # - -**@return** [OpenStruct] a new instance of OpenStruct - -## inspect() [](#method-i-inspect) -Returns a string containing a detailed summary of the keys and values. - -## marshal_dump() [](#method-i-marshal_dump) -Provides marshalling support for use by the Marshal library. - -## to_h(&block) [](#method-i-to_h) - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/ostruct' - puts OpenStruct.new('name' => 'Rowdy', :age => nil).to_json - -Output: - - {"json_class":"OpenStruct","t":{'name':'Rowdy',"age":null}} - diff --git a/example/ruby/OpenStructSpecs.md b/example/ruby/OpenStructSpecs.md deleted file mode 100644 index c22842d..0000000 --- a/example/ruby/OpenStructSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: OpenStructSpecs - - - - - diff --git a/example/ruby/OpenStructSpecs/OpenStructSub.md b/example/ruby/OpenStructSpecs/OpenStructSub.md deleted file mode 100644 index acb29d1..0000000 --- a/example/ruby/OpenStructSpecs/OpenStructSub.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: OpenStructSpecs::OpenStructSub -**Inherits:** OpenStruct - - - - - diff --git a/example/ruby/OpenURI.md b/example/ruby/OpenURI.md deleted file mode 100644 index c916386..0000000 --- a/example/ruby/OpenURI.md +++ /dev/null @@ -1,79 +0,0 @@ -# Module: OpenURI - - -OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP. - -## Example - -It is possible to open an http, https or ftp URL as though it were a file: - - URI.open("http://www.ruby-lang.org/") {|f| - f.each_line {|line| p line} - } - -The opened file has several getter methods for its meta-information, as -follows, since it is extended by OpenURI::Meta. - - URI.open("http://www.ruby-lang.org/en") {|f| - f.each_line {|line| p line} - p f.base_uri # - p f.content_type # "text/html" - p f.charset # "iso-8859-1" - p f.content_encoding # [] - p f.last_modified # Thu Dec 05 02:45:02 UTC 2002 - } - -Additional header fields can be specified by an optional hash argument. - - URI.open("http://www.ruby-lang.org/en/", - "User-Agent" => "Ruby/#{RUBY_VERSION}", - "From" => "foo@bar.invalid", - "Referer" => "http://www.ruby-lang.org/") {|f| - # ... - } - -The environment variables such as http_proxy, https_proxy and ftp_proxy are in -effect by default. Here we disable proxy: - - URI.open("http://www.ruby-lang.org/en/", :proxy => nil) {|f| - # ... - } - -See OpenURI::OpenRead.open and URI.open for more on available options. - -URI objects can be opened in a similar way. - - uri = URI.parse("http://www.ruby-lang.org/en/") - uri.open {|f| - # ... - } - -URI objects can be read directly. The returned string is also extended by -OpenURI::Meta. - - str = uri.read - p str.base_uri - -Author -: Tanaka Akira - - - -# Class Methods -## check_options(options ) [](#method-c-check_options) -:nodoc: -## open_http(buf , target , proxy , options ) [](#method-c-open_http) -:nodoc: -## open_loop(uri , options ) [](#method-c-open_loop) -:nodoc: -## open_uri(name , *rest ) [](#method-c-open_uri) -:nodoc: -**@raise** [ArgumentError] - -## redirectable?(uri1 , uri2 ) [](#method-c-redirectable?) -:nodoc: -**@return** [Boolean] - -## scan_open_optional_arguments(*rest ) [](#method-c-scan_open_optional_arguments) -:nodoc: - diff --git a/example/ruby/OpenURI/Buffer.md b/example/ruby/OpenURI/Buffer.md deleted file mode 100644 index 0870217..0000000 --- a/example/ruby/OpenURI/Buffer.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: OpenURI::Buffer -**Inherits:** Object - - -:nodoc: all - - -# Attributes -## size[RW] [](#attribute-i-size) -Returns the value of attribute size. - - -#Instance Methods -## <<(str) [](#method-i-<<) - -## initialize() [](#method-i-initialize) - -**@return** [Buffer] a new instance of Buffer - -## io() [](#method-i-io) - diff --git a/example/ruby/OpenURI/HTTPError.md b/example/ruby/OpenURI/HTTPError.md deleted file mode 100644 index ca721fc..0000000 --- a/example/ruby/OpenURI/HTTPError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: OpenURI::HTTPError -**Inherits:** StandardError - - - - -# Attributes -## io[RW] [](#attribute-i-io) -Returns the value of attribute io. - - -#Instance Methods -## initialize(message, io) [](#method-i-initialize) - -**@return** [HTTPError] a new instance of HTTPError - diff --git a/example/ruby/OpenURI/HTTPRedirect.md b/example/ruby/OpenURI/HTTPRedirect.md deleted file mode 100644 index 3693974..0000000 --- a/example/ruby/OpenURI/HTTPRedirect.md +++ /dev/null @@ -1,17 +0,0 @@ -# Exception: OpenURI::HTTPRedirect -**Inherits:** OpenURI::HTTPError - - -Raised on redirection, only occurs when `redirect` option for HTTP is `false`. - - -# Attributes -## uri[RW] [](#attribute-i-uri) -Returns the value of attribute uri. - - -#Instance Methods -## initialize(message, io, uri) [](#method-i-initialize) - -**@return** [HTTPRedirect] a new instance of HTTPRedirect - diff --git a/example/ruby/OpenURI/Meta.md b/example/ruby/OpenURI/Meta.md deleted file mode 100644 index 99542f2..0000000 --- a/example/ruby/OpenURI/Meta.md +++ /dev/null @@ -1,62 +0,0 @@ -# Module: OpenURI::Meta - - -Mixin for holding meta-information. - - -# Class Methods -## init(obj , src nil) [](#method-c-init) -:nodoc: -# Attributes -## base_uri[RW] [](#attribute-i-base_uri) -returns a URI that is the base of relative URIs in the data. It may differ -from the URI supplied by a user due to redirection. - -## meta[RW] [](#attribute-i-meta) -returns a Hash that represents header fields. The Hash keys are downcased for -canonicalization. The Hash values are a field body. If there are multiple -field with same field name, the field values are concatenated with a comma. - -## metas[RW] [](#attribute-i-metas) -returns a Hash that represents header fields. The Hash keys are downcased for -canonicalization. The Hash value are an array of field values. - -## status[RW] [](#attribute-i-status) -returns an Array that consists of status code and message. - - -#Instance Methods -## charset() [](#method-i-charset) -returns a charset parameter in Content-Type field. It is downcased for -canonicalization. - -If charset parameter is not given but a block is given, the block is called -and its result is returned. It can be used to guess charset. - -If charset parameter and block is not given, nil is returned except text type. -In that case, "utf-8" is returned as defined by RFC6838 4.2.1 - -## content_encoding() [](#method-i-content_encoding) -Returns a list of encodings in Content-Encoding field as an array of strings. - -The encodings are downcased for canonicalization. - -## content_type() [](#method-i-content_type) -returns "type/subtype" which is MIME Content-Type. It is downcased for -canonicalization. Content-Type parameters are stripped. - -## content_type_parse() [](#method-i-content_type_parse) -:nodoc: - -## last_modified() [](#method-i-last_modified) -returns a Time that represents the Last-Modified field. - -## meta_add_field(name, value) [](#method-i-meta_add_field) -:nodoc: - -## meta_add_field2(name, values) [](#method-i-meta_add_field2) -:nodoc: - -## meta_setup_encoding() [](#method-i-meta_setup_encoding) -:nodoc: - diff --git a/example/ruby/OpenURI/OpenRead.md b/example/ruby/OpenURI/OpenRead.md deleted file mode 100644 index 8473078..0000000 --- a/example/ruby/OpenURI/OpenRead.md +++ /dev/null @@ -1,236 +0,0 @@ -# Module: OpenURI::OpenRead - - -Mixin for HTTP and FTP URIs. - - - -#Instance Methods -## open(*rest, &block) [](#method-i-open) -OpenURI::OpenRead#open provides `open' for URI::HTTP and URI::FTP. - -OpenURI::OpenRead#open takes optional 3 arguments as: - - OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }] - -OpenURI::OpenRead#open returns an IO-like object if block is not given. -Otherwise it yields the IO object and return the value of the block. The IO -object is extended with OpenURI::Meta. - -`mode` and `perm` are the same as Kernel#open. - -However, `mode` must be read mode because OpenURI::OpenRead#open doesn't -support write mode (yet). Also `perm` is ignored because it is meaningful only -for file creation. - -`options` must be a hash. - -Each option with a string key specifies an extra header field for HTTP. I.e., -it is ignored for FTP without HTTP proxy. - -The hash may include other options, where keys are symbols: - -:proxy -: Synopsis: - :proxy => "http://proxy.foo.com:8000/" - :proxy => URI.parse("http://proxy.foo.com:8000/") - :proxy => true - :proxy => false - :proxy => nil - - If :proxy option is specified, the value should be String, URI, boolean or - nil. - - When String or URI is given, it is treated as proxy URI. - - When true is given or the option itself is not specified, environment - variable `scheme_proxy' is examined. `scheme' is replaced by `http', - `https' or `ftp'. - - When false or nil is given, the environment variables are ignored and - connection will be made to a server directly. - - -:proxy_http_basic_authentication -: Synopsis: - :proxy_http_basic_authentication => - ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"] - :proxy_http_basic_authentication => - [URI.parse("http://proxy.foo.com:8000/"), - "proxy-user", "proxy-password"] - - If :proxy option is specified, the value should be an Array with 3 - elements. It should contain a proxy URI, a proxy user name and a proxy - password. The proxy URI should be a String, an URI or nil. The proxy - user name and password should be a String. - - If nil is given for the proxy URI, this option is just ignored. - - If :proxy and :proxy_http_basic_authentication is specified, ArgumentError - is raised. - - -:http_basic_authentication -: Synopsis: - :http_basic_authentication=>[user, password] - - If :http_basic_authentication is specified, the value should be an array - which contains 2 strings: username and password. It is used for HTTP Basic - authentication defined by RFC 2617. - - -:content_length_proc -: Synopsis: - :content_length_proc => lambda {|content_length| ... } - - If :content_length_proc option is specified, the option value procedure is - called before actual transfer is started. It takes one argument, which is - expected content length in bytes. - - If two or more transfers are performed by HTTP redirection, the procedure - is called only once for the last transfer. - - When expected content length is unknown, the procedure is called with nil. - This happens when the HTTP response has no Content-Length header. - - -:progress_proc -: Synopsis: - :progress_proc => lambda {|size| ...} - - If :progress_proc option is specified, the proc is called with one - argument each time when `open' gets content fragment from network. The - argument `size` is the accumulated transferred size in bytes. - - If two or more transfer is done by HTTP redirection, the procedure is - called only one for a last transfer. - - :progress_proc and :content_length_proc are intended to be used for - progress bar. For example, it can be implemented as follows using - Ruby/ProgressBar. - - pbar = nil - open("http://...", - :content_length_proc => lambda {|t| - if t && 0 < t - pbar = ProgressBar.new("...", t) - pbar.file_transfer_mode - end - }, - :progress_proc => lambda {|s| - pbar.set s if pbar - }) {|f| ... } - - -:read_timeout -: Synopsis: - :read_timeout=>nil (no timeout) - :read_timeout=>10 (10 second) - - :read_timeout option specifies a timeout of read for http connections. - - -:open_timeout -: Synopsis: - :open_timeout=>nil (no timeout) - :open_timeout=>10 (10 second) - - :open_timeout option specifies a timeout of open for http connections. - - -:ssl_ca_cert -: Synopsis: - :ssl_ca_cert=>filename or an Array of filenames - - :ssl_ca_cert is used to specify CA certificate for SSL. If it is given, - default certificates are not used. - - -:ssl_verify_mode -: Synopsis: - :ssl_verify_mode=>mode - - :ssl_verify_mode is used to specify openssl verify mode. - - -:ssl_min_version -: Synopsis: - :ssl_min_version=>:TLS1_2 - - :ssl_min_version option specifies the minimum allowed SSL/TLS protocol - version. See also OpenSSL::SSL::SSLContext#min_version=. - - -:ssl_max_version -: Synopsis: - :ssl_max_version=>:TLS1_2 - - :ssl_max_version option specifies the maximum allowed SSL/TLS protocol - version. See also OpenSSL::SSL::SSLContext#max_version=. - - -:ftp_active_mode -: Synopsis: - :ftp_active_mode=>bool - - `:ftp_active_mode => true` is used to make ftp active mode. Ruby 1.9 uses - passive mode by default. Note that the active mode is default in Ruby 1.8 - or prior. - - -:redirect -: Synopsis: - :redirect=>bool - - `:redirect` is true by default. `:redirect => false` is used to disable - all HTTP redirects. - - OpenURI::HTTPRedirect exception raised on redirection. Using `true` also - means that redirections between http and ftp are permitted. - - -:max_redirects -: Synopsis: - :max_redirects=>int - - Number of HTTP redirects allowed before OpenURI::TooManyRedirects is - raised. The default is 64. - - -:request_specific_fields -: Synopsis: - :request_specific_fields => {} - :request_specific_fields => lambda {|url| ...} - - :request_specific_fields option allows specifying custom header fields - that are sent with the HTTP request. It can be passed as a Hash or a Proc - that gets evaluated on each request and returns a Hash of header fields. - - If a Hash is provided, it specifies the headers only for the initial - request and these headers will not be sent on redirects. - - If a Proc is provided, it will be executed for each request including - redirects, allowing dynamic header customization based on the request URL. - It is important that the Proc returns a Hash. And this Hash specifies the - headers to be sent with the request. - - For Example with Hash - URI.open("http://...", - request_specific_fields: {"Authorization" => "token dummy"}) {|f| ... } - - For Example with Proc: - URI.open("http://...", - request_specific_fields: lambda { |uri| - if uri.host == "example.com" - {"Authorization" => "token dummy"} - else - {} - end - }) {|f| ... } - - -## read(options{}) [](#method-i-read) -OpenURI::OpenRead#read([ options ]) reads a content referenced by self and -returns the content as string. The string is extended with OpenURI::Meta. The -argument `options` is same as OpenURI::OpenRead#open. - diff --git a/example/ruby/OpenURI/TooManyRedirects.md b/example/ruby/OpenURI/TooManyRedirects.md deleted file mode 100644 index 885ea31..0000000 --- a/example/ruby/OpenURI/TooManyRedirects.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OpenURI::TooManyRedirects -**Inherits:** OpenURI::HTTPError - - - - - diff --git a/example/ruby/OperatorImplementor.md b/example/ruby/OperatorImplementor.md deleted file mode 100644 index 6c29d96..0000000 --- a/example/ruby/OperatorImplementor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: OperatorImplementor -**Inherits:** Object - - - - - -#Instance Methods -## !~(val) [](#method-i-!~) - -## =~(val) [](#method-i-=~) - diff --git a/example/ruby/OptionParser.md b/example/ruby/OptionParser.md deleted file mode 100644 index 1e9f03e..0000000 --- a/example/ruby/OptionParser.md +++ /dev/null @@ -1,748 +0,0 @@ -# Class: OptionParser -**Inherits:** Object - - --- -## Developer Documentation (not for RDoc output) - -### Class tree - - OptionParser -: front end - - OptionParser::Switch -: each switches - - OptionParser::List -: options list - - OptionParser::ParseError -: errors on parsing - - * OptionParser::AmbiguousOption - * OptionParser::NeedlessArgument - * OptionParser::MissingArgument - * OptionParser::InvalidOption - * OptionParser::InvalidArgument - * OptionParser::AmbiguousArgument - -### Object relationship diagram - - +--------------+ - | OptionParser |<>-----+ - +--------------+ | +--------+ - | ,-| Switch | - on_head -------->+---------------+ / +--------+ - accept/reject -->| List |<|>- - | |<|>- +----------+ - on ------------->+---------------+ `-| argument | - : : | class | - +---------------+ |==========| - on_tail -------->| | |pattern | - +---------------+ |----------| - OptionParser.accept ->| DefaultList | |converter | - reject |(shared between| +----------+ - | all instances)| - +---------------+ - -++ - -## OptionParser - -### New to `OptionParser`? - -See the [Tutorial](optparse/tutorial.rdoc). - -### Introduction - -OptionParser is a class for command-line option analysis. It is much more -advanced, yet also easier to use, than GetoptLong, and is a more Ruby-oriented -solution. - -### Features - -1. The argument specification and the code to handle it are written in the - same place. -2. It can output an option summary; you don't need to maintain this string - separately. -3. Optional and mandatory arguments are specified very gracefully. -4. Arguments can be automatically converted to a specified class. -5. Arguments can be restricted to a certain set. - -All of these features are demonstrated in the examples below. See -#make_switch for full documentation. - -### Minimal example - - require 'optparse' - - options = {} - OptionParser.new do |parser| - parser.banner = "Usage: example.rb [options]" - - parser.on("-v", "--[no-]verbose", "Run verbosely") do |v| - options[:verbose] = v - end - end.parse! - - p options - p ARGV - -### Generating Help - -OptionParser can be used to automatically generate help for the commands you -write: - - require 'optparse' - - Options = Struct.new(:name) - - class Parser - def self.parse(options) - args = Options.new("world") - - opt_parser = OptionParser.new do |parser| - parser.banner = "Usage: example.rb [options]" - - parser.on("-nNAME", "--name=NAME", "Name to say hello to") do |n| - args.name = n - end - - parser.on("-h", "--help", "Prints this help") do - puts parser - exit - end - end - - opt_parser.parse!(options) - return args - end - end - options = Parser.parse %w[--help] - - #=> - # Usage: example.rb [options] - # -n, --name=NAME Name to say hello to - # -h, --help Prints this help - -### Required Arguments - -For options that require an argument, option specification strings may include -an option name in all caps. If an option is used without the required -argument, an exception will be raised. - - require 'optparse' - - options = {} - OptionParser.new do |parser| - parser.on("-r", "--require LIBRARY", - "Require the LIBRARY before executing your script") do |lib| - puts "You required #{lib}!" - end - end.parse! - -Used: - - $ ruby optparse-test.rb -r - optparse-test.rb:9:in `
': missing argument: -r (OptionParser::MissingArgument) - $ ruby optparse-test.rb -r my-library - You required my-library! - -### Type Coercion - -OptionParser supports the ability to coerce command line arguments into -objects for us. - -OptionParser comes with a few ready-to-use kinds of type coercion. They are: - -* Date -- Anything accepted by `Date.parse` (need to require - `optparse/date`) -* DateTime -- Anything accepted by `DateTime.parse` (need to require - `optparse/date`) -* Time -- Anything accepted by `Time.httpdate` or `Time.parse` (need to - require `optparse/time`) -* URI -- Anything accepted by `URI.parse` (need to require `optparse/uri`) -* Shellwords -- Anything accepted by `Shellwords.shellwords` (need to - require `optparse/shellwords`) -* String -- Any non-empty string -* Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040) -* Float -- Any float. (e.g. 10, 3.14, -100E+13) -* Numeric -- Any integer, float, or rational (1, 3.4, 1/3) -* DecimalInteger -- Like `Integer`, but no octal format. -* OctalInteger -- Like `Integer`, but no decimal format. -* DecimalNumeric -- Decimal integer or float. -* TrueClass -- Accepts '+, yes, true, -, no, false' and defaults as `true` -* FalseClass -- Same as `TrueClass`, but defaults to `false` -* Array -- Strings separated by ',' (e.g. 1,2,3) -* Regexp -- Regular expressions. Also includes options. - -We can also add our own coercions, which we will cover below. - -#### Using Built-in Conversions - -As an example, the built-in `Time` conversion is used. The other built-in -conversions behave in the same way. OptionParser will attempt to parse the -argument as a `Time`. If it succeeds, that time will be passed to the handler -block. Otherwise, an exception will be raised. - - require 'optparse' - require 'optparse/time' - OptionParser.new do |parser| - parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time| - p time - end - end.parse! - -Used: - - $ ruby optparse-test.rb -t nonsense - ... invalid argument: -t nonsense (OptionParser::InvalidArgument) - $ ruby optparse-test.rb -t 10-11-12 - 2010-11-12 00:00:00 -0500 - $ ruby optparse-test.rb -t 9:30 - 2014-08-13 09:30:00 -0400 - -#### Creating Custom Conversions - -The `accept` method on OptionParser may be used to create converters. It -specifies which conversion block to call whenever a class is specified. The -example below uses it to fetch a `User` object before the `on` handler -receives it. - - require 'optparse' - - User = Struct.new(:id, :name) - - def find_user id - not_found = ->{ raise "No User Found for id #{id}" } - [ User.new(1, "Sam"), - User.new(2, "Gandalf") ].find(not_found) do |u| - u.id == id - end - end - - op = OptionParser.new - op.accept(User) do |user_id| - find_user user_id.to_i - end - - op.on("--user ID", User) do |user| - puts user - end - - op.parse! - -Used: - - $ ruby optparse-test.rb --user 1 - # - $ ruby optparse-test.rb --user 2 - # - $ ruby optparse-test.rb --user 3 - optparse-test.rb:15:in `block in find_user': No User Found for id 3 (RuntimeError) - -### Store options to a Hash - -The `into` option of `order`, `parse` and so on methods stores command line -options into a Hash. - - require 'optparse' - - options = {} - OptionParser.new do |parser| - parser.on('-a') - parser.on('-b NUM', Integer) - parser.on('-v', '--verbose') - end.parse!(into: options) - - p options - -Used: - - $ ruby optparse-test.rb -a - {:a=>true} - $ ruby optparse-test.rb -a -v - {:a=>true, :verbose=>true} - $ ruby optparse-test.rb -a -b 100 - {:a=>true, :b=>100} - -### Complete example - -The following example is a complete Ruby program. You can run it and see the -effect of specifying various options. This is probably the best way to learn -the features of `optparse`. - - require 'optparse' - require 'optparse/time' - require 'ostruct' - require 'pp' - - class OptparseExample - Version = '1.0.0' - - CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary] - CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" } - - class ScriptOptions - attr_accessor :library, :inplace, :encoding, :transfer_type, - :verbose, :extension, :delay, :time, :record_separator, - :list - - def initialize - self.library = [] - self.inplace = false - self.encoding = "utf8" - self.transfer_type = :auto - self.verbose = false - end - - def define_options(parser) - parser.banner = "Usage: example.rb [options]" - parser.separator "" - parser.separator "Specific options:" - - # add additional options - perform_inplace_option(parser) - delay_execution_option(parser) - execute_at_time_option(parser) - specify_record_separator_option(parser) - list_example_option(parser) - specify_encoding_option(parser) - optional_option_argument_with_keyword_completion_option(parser) - boolean_verbose_option(parser) - - parser.separator "" - parser.separator "Common options:" - # No argument, shows at tail. This will print an options summary. - # Try it and see! - parser.on_tail("-h", "--help", "Show this message") do - puts parser - exit - end - # Another typical switch to print the version. - parser.on_tail("--version", "Show version") do - puts Version - exit - end - end - - def perform_inplace_option(parser) - # Specifies an optional option argument - parser.on("-i", "--inplace [EXTENSION]", - "Edit ARGV files in place", - "(make backup if EXTENSION supplied)") do |ext| - self.inplace = true - self.extension = ext || '' - self.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot. - end - end - - def delay_execution_option(parser) - # Cast 'delay' argument to a Float. - parser.on("--delay N", Float, "Delay N seconds before executing") do |n| - self.delay = n - end - end - - def execute_at_time_option(parser) - # Cast 'time' argument to a Time object. - parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time| - self.time = time - end - end - - def specify_record_separator_option(parser) - # Cast to octal integer. - parser.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger, - "Specify record separator (default \\0)") do |rs| - self.record_separator = rs - end - end - - def list_example_option(parser) - # List of arguments. - parser.on("--list x,y,z", Array, "Example 'list' of arguments") do |list| - self.list = list - end - end - - def specify_encoding_option(parser) - # Keyword completion. We are specifying a specific set of arguments (CODES - # and CODE_ALIASES - notice the latter is a Hash), and the user may provide - # the shortest unambiguous text. - code_list = (CODE_ALIASES.keys + CODES).join(', ') - parser.on("--code CODE", CODES, CODE_ALIASES, "Select encoding", - "(#{code_list})") do |encoding| - self.encoding = encoding - end - end - - def optional_option_argument_with_keyword_completion_option(parser) - # Optional '--type' option argument with keyword completion. - parser.on("--type [TYPE]", [:text, :binary, :auto], - "Select transfer type (text, binary, auto)") do |t| - self.transfer_type = t - end - end - - def boolean_verbose_option(parser) - # Boolean switch. - parser.on("-v", "--[no-]verbose", "Run verbosely") do |v| - self.verbose = v - end - end - end - - # - # Return a structure describing the options. - # - def parse(args) - # The options specified on the command line will be collected in - # *options*. - - @options = ScriptOptions.new - @args = OptionParser.new do |parser| - @options.define_options(parser) - parser.parse!(args) - end - @options - end - - attr_reader :parser, :options - end # class OptparseExample - - example = OptparseExample.new - options = example.parse(ARGV) - pp options # example.options - pp ARGV - -### Shell Completion - -For modern shells (e.g. bash, zsh, etc.), you can use shell completion for -command line options. - -### Further documentation - -The above examples, along with the accompanying -[Tutorial](optparse/tutorial.rdoc), should be enough to learn how to use this -class. If you have any questions, file a ticket at http://bugs.ruby-lang.org. - - -# Class Methods -## accept(*args , &blk ) [](#method-c-accept) -See #accept. -## each_const(path , base ::Object) [](#method-c-each_const) -:stopdoc: -## getopts(*args , symbolize_names: false) [](#method-c-getopts) -See #getopts. -## inc(arg , default nil) [](#method-c-inc) -Returns an incremented value of `default` according to `arg`. -## reject(*args , &blk ) [](#method-c-reject) -See #reject. -## search_const(klass , name ) [](#method-c-search_const) -## show_version(*pkgs ) [](#method-c-show_version) -Shows version string in packages if Version is defined. - -`pkgs` -: package list - -## terminate(arg nil) [](#method-c-terminate) -See #terminate. -## top() [](#method-c-top) -Returns the global top option list. - -Do not use directly. -## with(*args , &block ) [](#method-c-with) -Initializes a new instance and evaluates the optional block in context of the -instance. Arguments `args` are passed to #new, see there for description of -parameters. - -This method is **deprecated**, its behavior corresponds to the older #new -method. -# Attributes -## banner[RW] [](#attribute-i-banner) -Heading banner preceding summary. - -## default_argv[RW] [](#attribute-i-default_argv) -Strings to be parsed in default. - -## program_name[RW] [](#attribute-i-program_name) -Program name to be emitted in error message and default banner, defaults to -$0. - -## raise_unknown[RW] [](#attribute-i-raise_unknown) -Whether to raise at unknown option. - -## release[RW] [](#attribute-i-release) -Release code - -## require_exact[RW] [](#attribute-i-require_exact) -Whether to require that options match exactly (disallows providing abbreviated -long option as short option). - -## summary_indent[RW] [](#attribute-i-summary_indent) -Indentation for summary. Must be String (or have + String method). - -## summary_width[RW] [](#attribute-i-summary_width) -Width for option list portion of summary. Must be Numeric. - -## version[RW] [](#attribute-i-version) -Version - - -#Instance Methods -## abort(mesg$!) [](#method-i-abort) -Shows message with the program name then aborts. - -`mesg` -: Message, defaulted to +$!+. - - -See Kernel#abort. - -## accept(*args, &blk) [](#method-i-accept) -Directs to accept specified class `t`. The argument string is passed to the -block in which it should be converted to the desired class. - -`t` -: Argument class specifier, any object including Class. - -`pat` -: Pattern for argument, defaults to `t` if it responds to match. - - - accept(t, pat, &block) - -## add_officious() [](#method-i-add_officious) -:nodoc: - -## additional_message(typ, opt) [](#method-i-additional_message) -Returns additional info. - -## base() [](#method-i-base) -Subject of #on_tail. - -## candidate(word) [](#method-i-candidate) -Return candidates for `word`. - -## compsys(to, nameFile.basename($0)) [](#method-i-compsys) -:nodoc: - -## define(*opts, &block) [](#method-i-define) -:call-seq: - define(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -## define_by_keywords(options, method, **params) [](#method-i-define_by_keywords) -:call-seq: - define_by_keywords(options, method, **params) - -:include: ../../doc/optparse/creates_option.rdoc - -Defines options which set in to *options* for keyword parameters of *method*. - -Parameters for each keywords are given as elements of *params*. - -## define_head(*opts, &block) [](#method-i-define_head) -:call-seq: - define_head(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -## define_tail(*opts, &block) [](#method-i-define_tail) -:call-seq: - define_tail(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -## environment(envFile.basename($0, '.*'), **keywords) [](#method-i-environment) -Parses environment variable `env` or its uppercase with splitting like a -shell. - -`env` defaults to the basename of the program. - -## getopts(*args, symbolize_names:false, **keywords) [](#method-i-getopts) -Wrapper method for getopts.rb. - - params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option") - # params["a"] = true # -a - # params["b"] = "1" # -b1 - # params["foo"] = "1" # --foo - # params["bar"] = "x" # --bar x - # params["zot"] = "z" # --zot Z - -Option `symbolize_names` (boolean) specifies whether returned Hash keys should -be Symbols; defaults to `false` (use Strings). - - params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option", symbolize_names: true) - # params[:a] = true # -a - # params[:b] = "1" # -b1 - # params[:foo] = "1" # --foo - # params[:bar] = "x" # --bar x - # params[:zot] = "z" # --zot Z - -## help() [](#method-i-help) -Returns option summary string. - -## help_exit() [](#method-i-help_exit) - -## inc(*args) [](#method-i-inc) -See self.inc - -## initialize(bannernil, width32, indent' ' * 4) [](#method-i-initialize) -Initializes the instance and yields itself if called with a block. - -`banner` -: Banner message. - -`width` -: Summary width. - -`indent` -: Summary indent. - - -**@return** [OptionParser] a new instance of OptionParser - -**@yield** [_self] - -**@yieldparam** [OptionParser] the object that the method was called on - -## inspect() [](#method-i-inspect) -:nodoc: - -## load(filenamenil, **keywords) [](#method-i-load) -Loads options from file names as `filename`. Does nothing when the file is not -present. Returns whether successfully loaded. - -`filename` defaults to basename of the program without suffix in a directory -~/.options, then the basename with '.options' suffix under XDG and Haiku -standard places. - -The optional `into` keyword argument works exactly like that accepted in -method #parse. - -## make_switch(opts, blocknil) [](#method-i-make_switch) -:call-seq: - make_switch(params, block = nil) - -:include: ../doc/optparse/creates_option.rdoc - -## new() [](#method-i-new) -Pushes a new List. - -If a block is given, yields `self` and returns the result of the block, -otherwise returns `self`. - -## on(*opts, &block) [](#method-i-on) -:call-seq: - on(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -## on_head(*opts, &block) [](#method-i-on_head) -:call-seq: - on_head(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -The new option is added at the head of the summary. - -## on_tail(*opts, &block) [](#method-i-on_tail) -:call-seq: - on_tail(*params, &block) - -:include: ../doc/optparse/creates_option.rdoc - -The new option is added at the tail of the summary. - -## order(*argv, **keywords, &nonopt) [](#method-i-order) -Parses command line arguments `argv` in order. When a block is given, each -non-option argument is yielded. When optional `into` keyword argument is -provided, the parsed option values are stored there via `[]=` method (so it -can be Hash, or OpenStruct, or other similar object). - -Returns the rest of `argv` left unparsed. - -## order!(argvdefault_argv, into:nil, **keywords, &nonopt) [](#method-i-order!) -Same as #order, but removes switches destructively. Non-option arguments -remain in `argv`. - -## parse(*argv, **keywords) [](#method-i-parse) -Parses command line arguments `argv` in order when environment variable -POSIXLY_CORRECT is set, and in permutation mode otherwise. When optional -`into` keyword argument is provided, the parsed option values are stored there -via `[]=` method (so it can be Hash, or OpenStruct, or other similar object). - -## parse!(argvdefault_argv, **keywords) [](#method-i-parse!) -Same as #parse, but removes switches destructively. Non-option arguments -remain in `argv`. - -## permute(*argv, **keywords) [](#method-i-permute) -Parses command line arguments `argv` in permutation mode and returns list of -non-option arguments. When optional `into` keyword argument is provided, the -parsed option values are stored there via `[]=` method (so it can be Hash, or -OpenStruct, or other similar object). - -## permute!(argvdefault_argv, **keywords) [](#method-i-permute!) -Same as #permute, but removes switches destructively. Non-option arguments -remain in `argv`. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## reject(*args, &blk) [](#method-i-reject) -Directs to reject specified class argument. - -`type` -: Argument class specifier, any object including Class. - - - reject(type) - -## remove() [](#method-i-remove) -Removes the last List. - -## separator(string) [](#method-i-separator) -Add separator in summary. - -## summarize(to[], width@summary_width, maxwidth - 1, indent@summary_indent, &blk) [](#method-i-summarize) -Puts option summary into `to` and returns `to`. Yields each line if a block is -given. - -`to` -: Output destination, which must have method <<. Defaults to []. - -`width` -: Width of left side, defaults to @summary_width. - -`max` -: Maximum length allowed for left side, defaults to `width` - 1. - -`indent` -: Indentation, defaults to @summary_indent. - - -## terminate(argnil) [](#method-i-terminate) -Terminates option parsing. Optional parameter `arg` is a string pushed back to -be the first non-option argument. - -## to_a() [](#method-i-to_a) -Returns option summary list. - -## top() [](#method-i-top) -Subject of #on / #on_head, #accept / #reject - -## ver() [](#method-i-ver) -Returns version string from program_name, version and release. - -## warn(mesg$!) [](#method-i-warn) -Shows warning message with the program name - -`mesg` -: Message, defaulted to +$!+. - - -See Kernel#warn. - diff --git a/example/ruby/OptionParser/AC.md b/example/ruby/OptionParser/AC.md deleted file mode 100644 index 196cb50..0000000 --- a/example/ruby/OptionParser/AC.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: OptionParser::AC -**Inherits:** OptionParser - - -autoconf-like options. - - - -#Instance Methods -## ac_arg_disable(name, help_string, &block) [](#method-i-ac_arg_disable) -Define `--enable` / `--disable` style option - -Appears as `--disable-*name`* in help message. - -## ac_arg_enable(name, help_string, &block) [](#method-i-ac_arg_enable) -Define `--enable` / `--disable` style option - -Appears as `--enable-*name`* in help message. - -## ac_arg_with(name, help_string, &block) [](#method-i-ac_arg_with) -Define `--with` / `--without` style option - -Appears as `--with-*name`* in help message. - diff --git a/example/ruby/OptionParser/Acceptables.md b/example/ruby/OptionParser/Acceptables.md deleted file mode 100644 index daeca66..0000000 --- a/example/ruby/OptionParser/Acceptables.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: OptionParser::Acceptables - - -Acceptable argument classes. Now contains DecimalInteger, OctalInteger and -DecimalNumeric. See Acceptable argument classes (in source code). - - - diff --git a/example/ruby/OptionParser/AmbiguousArgument.md b/example/ruby/OptionParser/AmbiguousArgument.md deleted file mode 100644 index eec9266..0000000 --- a/example/ruby/OptionParser/AmbiguousArgument.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OptionParser::AmbiguousArgument -**Inherits:** OptionParser::InvalidArgument - - -Raises when the given argument word can't be completed uniquely. - - - diff --git a/example/ruby/OptionParser/AmbiguousOption.md b/example/ruby/OptionParser/AmbiguousOption.md deleted file mode 100644 index 93f6574..0000000 --- a/example/ruby/OptionParser/AmbiguousOption.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OptionParser::AmbiguousOption -**Inherits:** OptionParser::ParseError - - -Raises when ambiguously completable string is encountered. - - - diff --git a/example/ruby/OptionParser/Arguable.md b/example/ruby/OptionParser/Arguable.md deleted file mode 100644 index f1901ff..0000000 --- a/example/ruby/OptionParser/Arguable.md +++ /dev/null @@ -1,49 +0,0 @@ -# Module: OptionParser::Arguable - - -Extends command line arguments array (ARGV) to parse itself. - - -# Class Methods -## extend_object(obj ) [](#method-c-extend_object) -Initializes instance variable. - -#Instance Methods -## getopts(*args, symbolize_names:false, **keywords) [](#method-i-getopts) -Substitution of getopts is possible as follows. Also see OptionParser#getopts. - - def getopts(*args) - ($OPT = ARGV.getopts(*args)).each do |opt, val| - eval "$OPT_#{opt.gsub(/[^A-Za-z0-9_]/, '_')} = val" - end - rescue OptionParser::ParseError - end - -## initialize(*args) [](#method-i-initialize) -:nodoc: - -## options() [](#method-i-options) -Actual OptionParser object, automatically created if nonexistent. - -If called with a block, yields the OptionParser object and returns the result -of the block. If an OptionParser::ParseError exception occurs in the block, it -is rescued, a error message printed to STDERR and `nil` returned. - -## options=(opt) [](#method-i-options=) -Sets OptionParser object, when `opt` is `false` or `nil`, methods -OptionParser::Arguable#options and OptionParser::Arguable#options= are -undefined. Thus, there is no ways to access the OptionParser object via the -receiver object. - -## order!(**keywords, &blk) [](#method-i-order!) -Parses `self` destructively in order and returns `self` containing the rest -arguments left unparsed. - -## parse!(**keywords) [](#method-i-parse!) -Parses `self` destructively and returns `self` containing the rest arguments -left unparsed. - -## permute!(**keywords) [](#method-i-permute!) -Parses `self` destructively in permutation mode and returns `self` containing -the rest arguments left unparsed. - diff --git a/example/ruby/OptionParser/CompletingHash.md b/example/ruby/OptionParser/CompletingHash.md deleted file mode 100644 index 317e322..0000000 --- a/example/ruby/OptionParser/CompletingHash.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: OptionParser::CompletingHash -**Inherits:** Hash - -**Includes:** OptionParser::Completion - - -Hash with completion search feature. See OptionParser::Completion. - - - -#Instance Methods -## candidate(key, icasefalse, patnil, &_) [](#method-i-candidate) - -## complete(key, icasefalse, patnil) [](#method-i-complete) - -## convert(optnil, valnil) [](#method-i-convert) - -## match(key) [](#method-i-match) -Completion for hash key. - diff --git a/example/ruby/OptionParser/Completion.md b/example/ruby/OptionParser/Completion.md deleted file mode 100644 index c76e9cb..0000000 --- a/example/ruby/OptionParser/Completion.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: OptionParser::Completion - - -Keyword completion module. This allows partial arguments to be specified and -resolved against a list of acceptable values. - - -# Class Methods -## candidate(key , icase false, pat nil, &block ) [](#method-c-candidate) -## regexp(key , icase ) [](#method-c-regexp) -:nodoc: - -#Instance Methods -## candidate(key, icasefalse, patnil, &_) [](#method-i-candidate) - -## complete(key, icasefalse, patnil) [](#method-i-complete) - -## convert(optnil, valnil) [](#method-i-convert) - diff --git a/example/ruby/OptionParser/InvalidArgument.md b/example/ruby/OptionParser/InvalidArgument.md deleted file mode 100644 index 1874203..0000000 --- a/example/ruby/OptionParser/InvalidArgument.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OptionParser::InvalidArgument -**Inherits:** OptionParser::ParseError - - -Raises when the given argument does not match required format. - - - diff --git a/example/ruby/OptionParser/InvalidOption.md b/example/ruby/OptionParser/InvalidOption.md deleted file mode 100644 index 104406e..0000000 --- a/example/ruby/OptionParser/InvalidOption.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OptionParser::InvalidOption -**Inherits:** OptionParser::ParseError - - -Raises when switch is undefined. - - - diff --git a/example/ruby/OptionParser/List.md b/example/ruby/OptionParser/List.md deleted file mode 100644 index 3dac876..0000000 --- a/example/ruby/OptionParser/List.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: OptionParser::List -**Inherits:** Object - - -Simple option list providing mapping from short and/or long option string to -OptionParser::Switch and mapping from acceptable argument to matching pattern -and converter pair. Also provides summary feature. - - -# Attributes -## atype[RW] [](#attribute-i-atype) -Map from acceptable argument types to pattern and converter pairs. - -## list[RW] [](#attribute-i-list) -List of all switches and summary string. - -## long[RW] [](#attribute-i-long) -Map from long style option switches to actual switch objects. - -## short[RW] [](#attribute-i-short) -Map from short style option switches to actual switch objects. - - -#Instance Methods -## accept(t, pat/.*/m, &block) [](#method-i-accept) -See OptionParser.accept. - -## add_banner(to) [](#method-i-add_banner) -:nodoc: - -## append(*args) [](#method-i-append) -Appends `switch` at the tail of the list, and associates short, long and -negated long options. Arguments are: - -`switch` -: OptionParser::Switch instance to be inserted. - -`short_opts` -: List of short style options. - -`long_opts` -: List of long style options. - -`nolong_opts` -: List of long style options with "no-" prefix. - - - append(switch, short_opts, long_opts, nolong_opts) - -## complete(id, opt, icasefalse, *pat, &block) [](#method-i-complete) -Searches list `id` for `opt` and the optional patterns for completion `pat`. -If `icase` is true, the search is case insensitive. The result is returned or -yielded if a block is given. If it isn't found, nil is returned. - -## compsys(*args, &block) [](#method-i-compsys) -:nodoc: - -## each_option(&block) [](#method-i-each_option) -Iterates over each option, passing the option to the `block`. - -## get_candidates(id) [](#method-i-get_candidates) - -**@yield** [__send__(id).keys] - -## initialize() [](#method-i-initialize) -Just initializes all instance variables. - -**@return** [List] a new instance of List - -## prepend(*args) [](#method-i-prepend) -Inserts `switch` at the head of the list, and associates short, long and -negated long options. Arguments are: - -`switch` -: OptionParser::Switch instance to be inserted. - -`short_opts` -: List of short style options. - -`long_opts` -: List of long style options. - -`nolong_opts` -: List of long style options with "no-" prefix. - - - prepend(switch, short_opts, long_opts, nolong_opts) - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## reject(t) [](#method-i-reject) -See OptionParser.reject. - -## search(id, key) [](#method-i-search) -Searches `key` in `id` list. The result is returned or yielded if a block is -given. If it isn't found, nil is returned. - -## summarize(*args, &block) [](#method-i-summarize) -Creates the summary table, passing each line to the `block` (without newline). -The arguments `args` are passed along to the summarize method which is called -on every option. - diff --git a/example/ruby/OptionParser/MissingArgument.md b/example/ruby/OptionParser/MissingArgument.md deleted file mode 100644 index c94e889..0000000 --- a/example/ruby/OptionParser/MissingArgument.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OptionParser::MissingArgument -**Inherits:** OptionParser::ParseError - - -Raises when a switch with mandatory argument has no argument. - - - diff --git a/example/ruby/OptionParser/NeedlessArgument.md b/example/ruby/OptionParser/NeedlessArgument.md deleted file mode 100644 index 46a09bd..0000000 --- a/example/ruby/OptionParser/NeedlessArgument.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: OptionParser::NeedlessArgument -**Inherits:** OptionParser::ParseError - - -Raises when there is an argument for a switch which takes no argument. - - - diff --git a/example/ruby/OptionParser/OptionMap.md b/example/ruby/OptionParser/OptionMap.md deleted file mode 100644 index 89b2c43..0000000 --- a/example/ruby/OptionParser/OptionMap.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: OptionParser::OptionMap -**Inherits:** Hash - -**Includes:** OptionParser::Completion - - -Map from option/keyword string to object with completion. - - - -#Instance Methods -## candidate(key, icasefalse, patnil, &_) [](#method-i-candidate) - -## complete(key, icasefalse, patnil) [](#method-i-complete) - -## convert(optnil, valnil) [](#method-i-convert) - diff --git a/example/ruby/OptionParser/ParseError.md b/example/ruby/OptionParser/ParseError.md deleted file mode 100644 index 21d3c6c..0000000 --- a/example/ruby/OptionParser/ParseError.md +++ /dev/null @@ -1,38 +0,0 @@ -# Exception: OptionParser::ParseError -**Inherits:** RuntimeError - - -Base class of exceptions from OptionParser. - - -# Class Methods -## filter_backtrace(array ) [](#method-c-filter_backtrace) -# Attributes -## additional[RW] [](#attribute-i-additional) -Returns the value of attribute additional. - -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## reason[RW] [](#attribute-i-reason) -Returns error reason. Override this for I18N. - - -#Instance Methods -## initialize(*args, additional:nil) [](#method-i-initialize) -:nodoc: - -**@return** [ParseError] a new instance of ParseError - -## inspect() [](#method-i-inspect) - -## message() [](#method-i-message) -Default stringizing method to emit standard error message. - -## recover(argv) [](#method-i-recover) -Pushes back erred argument(s) to `argv`. - -## set_backtrace(array) [](#method-i-set_backtrace) - -## set_option(opt, eq) [](#method-i-set_option) - diff --git a/example/ruby/OptionParser/Switch.md b/example/ruby/OptionParser/Switch.md deleted file mode 100644 index 2f023c1..0000000 --- a/example/ruby/OptionParser/Switch.md +++ /dev/null @@ -1,90 +0,0 @@ -# Class: OptionParser::Switch -**Inherits:** Object - - -Individual switch class. Not important to the user. - -Defined within Switch are several Switch-derived classes: NoArgument, -RequiredArgument, etc. - - -# Class Methods -## guess(arg ) [](#method-c-guess) -Guesses argument style from `arg`. Returns corresponding OptionParser::Switch -class (OptionalArgument, etc.). -## incompatible_argument_styles(arg , t ) [](#method-c-incompatible_argument_styles) -**@raise** [ArgumentError] - -## pattern() [](#method-c-pattern) -# Attributes -## arg[RW] [](#attribute-i-arg) -:nodoc: - -## block[RW] [](#attribute-i-block) -:nodoc: - -## conv[RW] [](#attribute-i-conv) -:nodoc: - -## desc[RW] [](#attribute-i-desc) -:nodoc: - -## long[RW] [](#attribute-i-long) -:nodoc: - -## pattern[RW] [](#attribute-i-pattern) -:nodoc: - -## short[RW] [](#attribute-i-short) -:nodoc: - - -#Instance Methods -## add_banner(to) [](#method-i-add_banner) -:nodoc: - -## compsys(sdone, ldone) [](#method-i-compsys) -:nodoc: - -## initialize(patternnil, convnil, shortnil, longnil, argnil, desc([] if short or long), blocknil, &_block) [](#method-i-initialize) - -**@return** [Switch] a new instance of Switch - -## match_nonswitch?(str) [](#method-i-match_nonswitch?) -:nodoc: - -**@return** [Boolean] - -## omitted_argument(val) [](#method-i-omitted_argument) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## pretty_print_contents(q) [](#method-i-pretty_print_contents) -:nodoc: - -## summarize(sdone{}, ldone{}, width1, maxwidth - 1, indent"") [](#method-i-summarize) -Produces the summary text. Each line of the summary is yielded to the block -(without newline). - -`sdone` -: Already summarized short style options keyed hash. - -`ldone` -: Already summarized long style options keyed hash. - -`width` -: Width of left side (option part). In other words, the right side - (description part) starts after `width` columns. - -`max` -: Maximum width of left side -> the options are filled within `max` columns. - -`indent` -: Prefix string indents all summarized lines. - - -## switch_name() [](#method-i-switch_name) -Main name of the switch. - diff --git a/example/ruby/OptionParser/Switch/NoArgument.md b/example/ruby/OptionParser/Switch/NoArgument.md deleted file mode 100644 index 095825b..0000000 --- a/example/ruby/OptionParser/Switch/NoArgument.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: OptionParser::Switch::NoArgument -**Inherits:** OptionParser::Switch - - -Switch that takes no arguments. - - -# Class Methods -## incompatible_argument_styles() [](#method-c-incompatible_argument_styles) -:nodoc: -## pattern() [](#method-c-pattern) -:nodoc: - -#Instance Methods -## parse(arg, argv) [](#method-i-parse) -Raises an exception if any arguments given. - -**@yield** [NeedlessArgument, arg] - -## pretty_head() [](#method-i-pretty_head) -:nodoc: - diff --git a/example/ruby/OptionParser/Switch/OptionalArgument.md b/example/ruby/OptionParser/Switch/OptionalArgument.md deleted file mode 100644 index f7a5872..0000000 --- a/example/ruby/OptionParser/Switch/OptionalArgument.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: OptionParser::Switch::OptionalArgument -**Inherits:** OptionParser::Switch - - -Switch that can omit argument. - - - -#Instance Methods -## parse(arg, argv, &error) [](#method-i-parse) -Parses argument if given, or uses default value. - -## pretty_head() [](#method-i-pretty_head) -:nodoc: - diff --git a/example/ruby/OptionParser/Switch/PlacedArgument.md b/example/ruby/OptionParser/Switch/PlacedArgument.md deleted file mode 100644 index 4e83e90..0000000 --- a/example/ruby/OptionParser/Switch/PlacedArgument.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: OptionParser::Switch::PlacedArgument -**Inherits:** OptionParser::Switch - - -Switch that takes an argument, which does not begin with '-' or is '-'. - - - -#Instance Methods -## parse(arg, argv, &error) [](#method-i-parse) -Returns nil if argument is not present or begins with '-' and is not '-'. - -## pretty_head() [](#method-i-pretty_head) -:nodoc: - diff --git a/example/ruby/OptionParser/Switch/RequiredArgument.md b/example/ruby/OptionParser/Switch/RequiredArgument.md deleted file mode 100644 index b7f579b..0000000 --- a/example/ruby/OptionParser/Switch/RequiredArgument.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: OptionParser::Switch::RequiredArgument -**Inherits:** OptionParser::Switch - - -Switch that takes an argument. - - - -#Instance Methods -## parse(arg, argv, &_) [](#method-i-parse) -Raises an exception if argument is not present. - -## pretty_head() [](#method-i-pretty_head) -:nodoc: - diff --git a/example/ruby/OtherCustomException.md b/example/ruby/OtherCustomException.md deleted file mode 100644 index 91596a5..0000000 --- a/example/ruby/OtherCustomException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: OtherCustomException -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Output.md b/example/ruby/Output.md deleted file mode 100644 index bf1d4fc..0000000 --- a/example/ruby/Output.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Output -**Inherits:** Object - - - - -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - -## vpath[RW] [](#attribute-i-vpath) -Returns the value of attribute vpath. - - -#Instance Methods -## def_options(opt) [](#method-i-def_options) - -## initialize(path:nil, timestamp:nil, ifchange:nil, color:nil, overwrite:false, create_only:false, vpath:VPath.new) [](#method-i-initialize) - -**@return** [Output] a new instance of Output - -## write(data, overwrite:@overwrite, create_only:@create_only) [](#method-i-write) - diff --git a/example/ruby/OutputMatcher.md b/example/ruby/OutputMatcher.md deleted file mode 100644 index c1d1c35..0000000 --- a/example/ruby/OutputMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: OutputMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(stdout, stderr) [](#method-i-initialize) - -**@return** [OutputMatcher] a new instance of OutputMatcher - -## matches?(proc) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/OutputToFDMatcher.md b/example/ruby/OutputToFDMatcher.md deleted file mode 100644 index 634dba8..0000000 --- a/example/ruby/OutputToFDMatcher.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: OutputToFDMatcher -**Inherits:** Object - - -Lower-level output speccing mechanism for a single output stream. Unlike -OutputMatcher which provides methods to capture the output, we actually -replace the FD itself so that there is no reliance on a certain method being -used. - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected, to) [](#method-i-initialize) - -**@return** [OutputToFDMatcher] a new instance of OutputToFDMatcher - -## matches?(block) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - -## with_tmp() [](#method-i-with_tmp) - diff --git a/example/ruby/PP.md b/example/ruby/PP.md deleted file mode 100644 index 9de3187..0000000 --- a/example/ruby/PP.md +++ /dev/null @@ -1,160 +0,0 @@ -# Class: PP -**Inherits:** PrettyPrint - -**Includes:** PP::PPMethods - - -A pretty-printer for Ruby objects. - -## What PP Does - -Standard output by #p returns this: - #, @group_queue=#], []]>, @buffer=[], @newline="\n", @group_stack=[#], @buffer_width=0, @indent=0, @maxwidth=79, @output_width=2, @output=#> - -Pretty-printed output returns this: - #, - @group_queue= - #], - []]>, - @group_stack= - [#], - @indent=0, - @maxwidth=79, - @newline="\n", - @output=#, - @output_width=2> - -## Usage - - pp(obj) #=> obj - pp obj #=> obj - pp(obj1, obj2, ...) #=> [obj1, obj2, ...] - pp() #=> nil - -Output `obj(s)` to `$>` in pretty printed format. - -It returns `obj(s)`. - -## Output Customization - -To define a customized pretty printing function for your classes, redefine -method `#pretty_print(pp)` in the class. Note that `require 'pp'` is needed -before redefining `#pretty_print(pp)`. - -`#pretty_print` takes the `pp` argument, which is an instance of the PP class. -The method uses #text, #breakable, #nest, #group and #pp to print the object. - -## Pretty-Print JSON - -To pretty-print JSON refer to JSON#pretty_generate. - -## Author -Tanaka Akira - - -# Class Methods -## mcall(obj , mod , meth , *args , &block ) [](#method-c-mcall) -:stopdoc: -## pp(obj , out $>, width width_for(out)) [](#method-c-pp) -Outputs `obj` to `out` in pretty printed format of `width` columns in width. - -If `out` is omitted, `$>` is assumed. If `width` is omitted, the width of -`out` is assumed (see width_for). - -PP.pp returns `out`. -## singleline_pp(obj , out $>) [](#method-c-singleline_pp) -Outputs `obj` to `out` like PP.pp but with no indent and newline. - -PP.singleline_pp returns `out`. -## width_for(out ) [](#method-c-width_for) -Returns the usable width for `out`. As the width of `out`: -1. If `out` is assigned to a tty device, its width is used. -2. Otherwise, or it could not get the value, the `COLUMN` environment - variable is assumed to be set to the width. -3. If `COLUMN` is not set to a non-zero number, 80 is assumed. - -And finally, returns the above width value - 1. -* This -1 is for Windows command prompt, which moves the cursor to the next - line if it reaches the last column. -# Attributes -## sharing_detection[RW] [](#attribute-c-sharing_detection) -Returns the sharing detection flag as a boolean value. It is false by default. - - -#Instance Methods -## check_inspect_key(id) [](#method-i-check_inspect_key) -Check whether the object_id `id` is in the current buffer of objects to be -pretty printed. Used to break cycles in chains of objects to be pretty -printed. - -## comma_breakable() [](#method-i-comma_breakable) -A convenience method which is same as follows: - - text ',' - breakable - -## guard_inspect_key() [](#method-i-guard_inspect_key) -Yields to a block and preserves the previous set of objects being printed. - -## object_address_group(obj, &block) [](#method-i-object_address_group) -A convenience method, like object_group, but also reformats the Object's -object_id. - -## object_group(obj, &block) [](#method-i-object_group) -A convenience method which is same as follows: - - group(1, '#<' + obj.class.name, '>') { ... } - -## pop_inspect_key(id) [](#method-i-pop_inspect_key) -Removes an object from the set of objects being pretty printed. - -## pp(obj) [](#method-i-pp) -Adds `obj` to the pretty printing buffer using Object#pretty_print or -Object#pretty_print_cycle. - -Object#pretty_print_cycle is used when `obj` is already printed, a.k.a the -object reference chain has a cycle. - -## pp_hash(obj) [](#method-i-pp_hash) -A pretty print for a Hash - -## pp_hash_pair(k, v) [](#method-i-pp_hash_pair) -A pretty print for a pair of Hash - -## pp_object(obj) [](#method-i-pp_object) -A present standard failsafe for pretty printing any given Object - -## push_inspect_key(id) [](#method-i-push_inspect_key) -Adds the object_id `id` to the set of objects being pretty printed, so as to -not repeat objects. - -## seplist(list, sepnil, iter_method:each) [](#method-i-seplist) -Adds a separated list. The list is separated by comma with breakable space, by -default. - -#seplist iterates the `list` using `iter_method`. It yields each object to the -block given for #seplist. The procedure `separator_proc` is called between -each yields. - -If the iteration is zero times, `separator_proc` is not called at all. - -If `separator_proc` is nil or not given, +lambda { comma_breakable }+ is used. -If `iter_method` is not given, :each is used. - -For example, following 3 code fragments has similar effect. - - q.seplist([1,2,3]) {|v| xxx v } - - q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v } - - xxx 1 - q.comma_breakable - xxx 2 - q.comma_breakable - xxx 3 - diff --git a/example/ruby/PP/ObjectMixin.md b/example/ruby/PP/ObjectMixin.md deleted file mode 100644 index 71bcfd5..0000000 --- a/example/ruby/PP/ObjectMixin.md +++ /dev/null @@ -1,37 +0,0 @@ -# Module: PP::ObjectMixin - - -:nodoc: - - - -#Instance Methods -## pretty_print(q) [](#method-i-pretty_print) -A default pretty printing method for general objects. It calls -#pretty_print_instance_variables to list instance variables. - -If `self` has a customized (redefined) #inspect method, the result of -self.inspect is used but it obviously has no line break hints. - -This module provides predefined #pretty_print methods for some of the most -commonly used built-in classes for convenience. - -## pretty_print_cycle(q) [](#method-i-pretty_print_cycle) -A default pretty printing method for general objects that are detected as part -of a cycle. - -## pretty_print_inspect() [](#method-i-pretty_print_inspect) -Is #inspect implementation using #pretty_print. If you implement -#pretty_print, it can be used as follows. - - alias inspect pretty_print_inspect - -However, doing this requires that every class that #inspect is called on -implement #pretty_print, or a RuntimeError will be raised. - -## pretty_print_instance_variables() [](#method-i-pretty_print_instance_variables) -Returns a sorted array of instance variable names. - -This method should return an array of names of instance variables as symbols -or strings as: +[:@a, :@b]+. - diff --git a/example/ruby/PP/PPMethods.md b/example/ruby/PP/PPMethods.md deleted file mode 100644 index c557b66..0000000 --- a/example/ruby/PP/PPMethods.md +++ /dev/null @@ -1,79 +0,0 @@ -# Module: PP::PPMethods - - -Module that defines helper methods for pretty_print. - - - -#Instance Methods -## check_inspect_key(id) [](#method-i-check_inspect_key) -Check whether the object_id `id` is in the current buffer of objects to be -pretty printed. Used to break cycles in chains of objects to be pretty -printed. - -## comma_breakable() [](#method-i-comma_breakable) -A convenience method which is same as follows: - - text ',' - breakable - -## guard_inspect_key() [](#method-i-guard_inspect_key) -Yields to a block and preserves the previous set of objects being printed. - -## object_address_group(obj, &block) [](#method-i-object_address_group) -A convenience method, like object_group, but also reformats the Object's -object_id. - -## object_group(obj, &block) [](#method-i-object_group) -A convenience method which is same as follows: - - group(1, '#<' + obj.class.name, '>') { ... } - -## pop_inspect_key(id) [](#method-i-pop_inspect_key) -Removes an object from the set of objects being pretty printed. - -## pp(obj) [](#method-i-pp) -Adds `obj` to the pretty printing buffer using Object#pretty_print or -Object#pretty_print_cycle. - -Object#pretty_print_cycle is used when `obj` is already printed, a.k.a the -object reference chain has a cycle. - -## pp_hash(obj) [](#method-i-pp_hash) -A pretty print for a Hash - -## pp_hash_pair(k, v) [](#method-i-pp_hash_pair) -A pretty print for a pair of Hash - -## pp_object(obj) [](#method-i-pp_object) -A present standard failsafe for pretty printing any given Object - -## push_inspect_key(id) [](#method-i-push_inspect_key) -Adds the object_id `id` to the set of objects being pretty printed, so as to -not repeat objects. - -## seplist(list, sepnil, iter_method:each) [](#method-i-seplist) -Adds a separated list. The list is separated by comma with breakable space, by -default. - -#seplist iterates the `list` using `iter_method`. It yields each object to the -block given for #seplist. The procedure `separator_proc` is called between -each yields. - -If the iteration is zero times, `separator_proc` is not called at all. - -If `separator_proc` is nil or not given, +lambda { comma_breakable }+ is used. -If `iter_method` is not given, :each is used. - -For example, following 3 code fragments has similar effect. - - q.seplist([1,2,3]) {|v| xxx v } - - q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v } - - xxx 1 - q.comma_breakable - xxx 2 - q.comma_breakable - xxx 3 - diff --git a/example/ruby/PP/SingleLine.md b/example/ruby/PP/SingleLine.md deleted file mode 100644 index d30d430..0000000 --- a/example/ruby/PP/SingleLine.md +++ /dev/null @@ -1,82 +0,0 @@ -# Class: PP::SingleLine -**Inherits:** PrettyPrint::SingleLine - -**Includes:** PP::PPMethods - - -:nodoc: - - - -#Instance Methods -## check_inspect_key(id) [](#method-i-check_inspect_key) -Check whether the object_id `id` is in the current buffer of objects to be -pretty printed. Used to break cycles in chains of objects to be pretty -printed. - -## comma_breakable() [](#method-i-comma_breakable) -A convenience method which is same as follows: - - text ',' - breakable - -## guard_inspect_key() [](#method-i-guard_inspect_key) -Yields to a block and preserves the previous set of objects being printed. - -## object_address_group(obj, &block) [](#method-i-object_address_group) -A convenience method, like object_group, but also reformats the Object's -object_id. - -## object_group(obj, &block) [](#method-i-object_group) -A convenience method which is same as follows: - - group(1, '#<' + obj.class.name, '>') { ... } - -## pop_inspect_key(id) [](#method-i-pop_inspect_key) -Removes an object from the set of objects being pretty printed. - -## pp(obj) [](#method-i-pp) -Adds `obj` to the pretty printing buffer using Object#pretty_print or -Object#pretty_print_cycle. - -Object#pretty_print_cycle is used when `obj` is already printed, a.k.a the -object reference chain has a cycle. - -## pp_hash(obj) [](#method-i-pp_hash) -A pretty print for a Hash - -## pp_hash_pair(k, v) [](#method-i-pp_hash_pair) -A pretty print for a pair of Hash - -## pp_object(obj) [](#method-i-pp_object) -A present standard failsafe for pretty printing any given Object - -## push_inspect_key(id) [](#method-i-push_inspect_key) -Adds the object_id `id` to the set of objects being pretty printed, so as to -not repeat objects. - -## seplist(list, sepnil, iter_method:each) [](#method-i-seplist) -Adds a separated list. The list is separated by comma with breakable space, by -default. - -#seplist iterates the `list` using `iter_method`. It yields each object to the -block given for #seplist. The procedure `separator_proc` is called between -each yields. - -If the iteration is zero times, `separator_proc` is not called at all. - -If `separator_proc` is nil or not given, +lambda { comma_breakable }+ is used. -If `iter_method` is not given, :each is used. - -For example, following 3 code fragments has similar effect. - - q.seplist([1,2,3]) {|v| xxx v } - - q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v } - - xxx 1 - q.comma_breakable - xxx 2 - q.comma_breakable - xxx 3 - diff --git a/example/ruby/PPTestModule.md b/example/ruby/PPTestModule.md deleted file mode 100644 index 89eed4c..0000000 --- a/example/ruby/PPTestModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: PPTestModule - - - - - diff --git a/example/ruby/PPTestModule/HasBoth.md b/example/ruby/PPTestModule/HasBoth.md deleted file mode 100644 index 69a725a..0000000 --- a/example/ruby/PPTestModule/HasBoth.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: PPTestModule::HasBoth -**Inherits:** Object - - - - - -#Instance Methods -## initialize(a) [](#method-i-initialize) - -**@return** [HasBoth] a new instance of HasBoth - -## inspect() [](#method-i-inspect) - -## pretty_print(q) [](#method-i-pretty_print) - diff --git a/example/ruby/PPTestModule/HasInspect.md b/example/ruby/PPTestModule/HasInspect.md deleted file mode 100644 index 8e0e48c..0000000 --- a/example/ruby/PPTestModule/HasInspect.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: PPTestModule::HasInspect -**Inherits:** Object - - - - - -#Instance Methods -## initialize(a) [](#method-i-initialize) - -**@return** [HasInspect] a new instance of HasInspect - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/PPTestModule/HasPrettyPrint.md b/example/ruby/PPTestModule/HasPrettyPrint.md deleted file mode 100644 index 18f94c2..0000000 --- a/example/ruby/PPTestModule/HasPrettyPrint.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: PPTestModule::HasPrettyPrint -**Inherits:** Object - - - - - -#Instance Methods -## initialize(a) [](#method-i-initialize) - -**@return** [HasPrettyPrint] a new instance of HasPrettyPrint - -## pretty_print(q) [](#method-i-pretty_print) - diff --git a/example/ruby/PPTestModule/PPAbstractSyntaxTree.md b/example/ruby/PPTestModule/PPAbstractSyntaxTree.md deleted file mode 100644 index d8069c2..0000000 --- a/example/ruby/PPTestModule/PPAbstractSyntaxTree.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: PPTestModule::PPAbstractSyntaxTree -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_lasgn_literal() [](#method-i-test_lasgn_literal) - diff --git a/example/ruby/PPTestModule/PPCycleTest.md b/example/ruby/PPTestModule/PPCycleTest.md deleted file mode 100644 index 9473326..0000000 --- a/example/ruby/PPTestModule/PPCycleTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: PPTestModule::PPCycleTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_anonymous() [](#method-i-test_anonymous) - -## test_array() [](#method-i-test_array) - -## test_data() [](#method-i-test_data) - -## test_data_private_member() [](#method-i-test_data_private_member) - -## test_data_removed_member() [](#method-i-test_data_removed_member) - -## test_hash() [](#method-i-test_hash) - -## test_object() [](#method-i-test_object) - -## test_share_nil() [](#method-i-test_share_nil) - -## test_struct() [](#method-i-test_struct) - -## test_withinspect() [](#method-i-test_withinspect) - diff --git a/example/ruby/PPTestModule/PPCycleTest/S.md b/example/ruby/PPTestModule/PPCycleTest/S.md deleted file mode 100644 index d736a44..0000000 --- a/example/ruby/PPTestModule/PPCycleTest/S.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: PPTestModule::PPCycleTest::S -**Inherits:** Struct - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a - -**@return** [Object] the current value of a - -## b[RW] [](#attribute-i-b) -Returns the value of attribute b - -**@return** [Object] the current value of b - - diff --git a/example/ruby/PPTestModule/PPDelegateTest.md b/example/ruby/PPTestModule/PPDelegateTest.md deleted file mode 100644 index 7fc6f29..0000000 --- a/example/ruby/PPTestModule/PPDelegateTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: PPTestModule::PPDelegateTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_delegate() [](#method-i-test_delegate) - -## test_delegate_cycle() [](#method-i-test_delegate_cycle) - diff --git a/example/ruby/PPTestModule/PPDelegateTest/A.md b/example/ruby/PPTestModule/PPDelegateTest/A.md deleted file mode 100644 index 9eb1535..0000000 --- a/example/ruby/PPTestModule/PPDelegateTest/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: PPTestModule::PPDelegateTest::A -**Inherits:** Array - - - - - diff --git a/example/ruby/PPTestModule/PPFileStatTest.md b/example/ruby/PPTestModule/PPFileStatTest.md deleted file mode 100644 index 6fc39c7..0000000 --- a/example/ruby/PPTestModule/PPFileStatTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: PPTestModule::PPFileStatTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_nothing_raised() [](#method-i-test_nothing_raised) - diff --git a/example/ruby/PPTestModule/PPInheritedTest.md b/example/ruby/PPTestModule/PPInheritedTest.md deleted file mode 100644 index 767dee1..0000000 --- a/example/ruby/PPTestModule/PPInheritedTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: PPTestModule::PPInheritedTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_hash_override() [](#method-i-test_hash_override) - diff --git a/example/ruby/PPTestModule/PPInheritedTest/PPSymbolHash.md b/example/ruby/PPTestModule/PPInheritedTest/PPSymbolHash.md deleted file mode 100644 index 49b1d20..0000000 --- a/example/ruby/PPTestModule/PPInheritedTest/PPSymbolHash.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: PPTestModule::PPInheritedTest::PPSymbolHash -**Inherits:** PP - - - - - -#Instance Methods -## pp_hash_pair(k, v) [](#method-i-pp_hash_pair) - diff --git a/example/ruby/PPTestModule/PPInspectTest.md b/example/ruby/PPTestModule/PPInspectTest.md deleted file mode 100644 index a64565c..0000000 --- a/example/ruby/PPTestModule/PPInspectTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: PPTestModule::PPInspectTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_basic_object() [](#method-i-test_basic_object) - -## test_hasboth() [](#method-i-test_hasboth) - -## test_hasinspect() [](#method-i-test_hasinspect) - -## test_hasprettyprint() [](#method-i-test_hasprettyprint) - -## test_pretty_print_inspect() [](#method-i-test_pretty_print_inspect) - -## test_proc() [](#method-i-test_proc) - -## test_to_s_with_iv() [](#method-i-test_to_s_with_iv) - -## test_to_s_without_iv() [](#method-i-test_to_s_without_iv) - diff --git a/example/ruby/PPTestModule/PPSingleLineTest.md b/example/ruby/PPTestModule/PPSingleLineTest.md deleted file mode 100644 index 74a21c0..0000000 --- a/example/ruby/PPTestModule/PPSingleLineTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: PPTestModule::PPSingleLineTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_hash() [](#method-i-test_hash) - -## test_hash_in_array() [](#method-i-test_hash_in_array) - -## test_hash_symbol_colon_key() [](#method-i-test_hash_symbol_colon_key) - diff --git a/example/ruby/PPTestModule/PPTest.md b/example/ruby/PPTestModule/PPTest.md deleted file mode 100644 index ec2ec47..0000000 --- a/example/ruby/PPTestModule/PPTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: PPTestModule::PPTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_list0123_11() [](#method-i-test_list0123_11) - -## test_list0123_12() [](#method-i-test_list0123_12) - -## test_range() [](#method-i-test_range) - -## test_redefined_method() [](#method-i-test_redefined_method) - -## test_struct_override_members() [](#method-i-test_struct_override_members) -ruby-core:7865 -: - diff --git a/example/ruby/PPTestModule/PPTest/OverriddenStruct.md b/example/ruby/PPTestModule/PPTest/OverriddenStruct.md deleted file mode 100644 index 2a8e536..0000000 --- a/example/ruby/PPTestModule/PPTest/OverriddenStruct.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: PPTestModule::PPTest::OverriddenStruct -**Inherits:** Struct - - - - -# Attributes -## class[RW] [](#attribute-i-class) -Returns the value of attribute class - -**@return** [Object] the current value of class - -## members[RW] [](#attribute-i-members) -Returns the value of attribute members - -**@return** [Object] the current value of members - - diff --git a/example/ruby/PPTestModule/PrettyPrintInspect.md b/example/ruby/PPTestModule/PrettyPrintInspect.md deleted file mode 100644 index 8a60371..0000000 --- a/example/ruby/PPTestModule/PrettyPrintInspect.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: PPTestModule::PrettyPrintInspect -**Inherits:** PPTestModule::HasPrettyPrint - - - - - diff --git a/example/ruby/PPTestModule/PrettyPrintInspectWithoutPrettyPrint.md b/example/ruby/PPTestModule/PrettyPrintInspectWithoutPrettyPrint.md deleted file mode 100644 index 10474c3..0000000 --- a/example/ruby/PPTestModule/PrettyPrintInspectWithoutPrettyPrint.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: PPTestModule::PrettyPrintInspectWithoutPrettyPrint -**Inherits:** Object - - - - - diff --git a/example/ruby/PStore.md b/example/ruby/PStore.md deleted file mode 100644 index afdfa0f..0000000 --- a/example/ruby/PStore.md +++ /dev/null @@ -1,454 +0,0 @@ -# Class: PStore -**Inherits:** Object - - -PStore implements a file based persistence mechanism based on a Hash. User -code can store hierarchies of Ruby objects (values) into the data store by -name (keys). An object hierarchy may be just a single object. User code may -later read values back from the data store or even update data, as needed. - -The transactional behavior ensures that any changes succeed or fail together. -This can be used to ensure that the data store is not left in a transitory -state, where some values were updated but others were not. - -Behind the scenes, Ruby objects are stored to the data store file with -Marshal. That carries the usual limitations. Proc objects cannot be -marshalled, for example. - -There are three important concepts here (details at the links): - -* [Store](rdoc-ref:PStore@The+Store): a store is an instance of PStore. -* [Entries](rdoc-ref:PStore@Entries): the store is hash-like; each entry is - the key for a stored object. -* [Transactions](rdoc-ref:PStore@Transactions): each transaction is a - collection of prospective changes to the store; a transaction is defined - in the block given with a call to PStore#transaction. - -## About the Examples - -Examples on this page need a store that has known properties. They can get a -new (and populated) store by calling thus: - - example_store do |store| - # Example code using store goes here. - end - -All we really need to know about `example_store` is that it yields a fresh -store with a known population of entries; its implementation: - - require 'pstore' - require 'tempfile' - # Yield a pristine store for use in examples. - def example_store - # Create the store in a temporary file. - Tempfile.create do |file| - store = PStore.new(file) - # Populate the store. - store.transaction do - store[:foo] = 0 - store[:bar] = 1 - store[:baz] = 2 - end - yield store - end - end - -## The Store - -The contents of the store are maintained in a file whose path is specified -when the store is created (see PStore.new). The objects are stored and -retrieved using module Marshal, which means that certain objects cannot be -added to the store; see [Marshal::dump](rdoc-ref:Marshal.dump). - -## Entries - -A store may have any number of entries. Each entry has a key and a value, just -as in a hash: - -* Key: as in a hash, the key can be (almost) any object; see [Hash - Keys](rdoc-ref:Hash@Hash+Keys). You may find it convenient to keep it - simple by using only symbols or strings as keys. -* Value: the value may be any object that can be marshalled by Marshal (see - [Marshal::dump](rdoc-ref:Marshal.dump)) and in fact may be a collection - (e.g., an array, a hash, a set, a range, etc). That collection may in turn - contain nested objects, including collections, to any depth; those objects - must also be Marshal-able. See [Hierarchical - Values](rdoc-ref:PStore@Hierarchical+Values). - -## Transactions - -### The Transaction Block - -The block given with a call to method #transaction# contains a *transaction*, -which consists of calls to PStore methods that read from or write to the store -(that is, all PStore methods except #transaction itself, #path, and -Pstore.new): - - example_store do |store| - store.transaction do - store.keys # => [:foo, :bar, :baz] - store[:bat] = 3 - store.keys # => [:foo, :bar, :baz, :bat] - end - end - -Execution of the transaction is deferred until the block exits, and is -executed *atomically* (all-or-nothing): either all transaction calls are -executed, or none are. This maintains the integrity of the store. - -Other code in the block (including even calls to #path and PStore.new) is -executed immediately, not deferred. - -The transaction block: - -* May not contain a nested call to #transaction. -* Is the only context where methods that read from or write to the store are - allowed. - -As seen above, changes in a transaction are made automatically when the block -exits. The block may be exited early by calling method #commit or #abort. - -* Method #commit triggers the update to the store and exits the block: - - example_store do |store| - store.transaction do - store.keys # => [:foo, :bar, :baz] - store[:bat] = 3 - store.commit - fail 'Cannot get here' - end - store.transaction do - # Update was completed. - store.keys # => [:foo, :bar, :baz, :bat] - end - end - -* Method #abort discards the update to the store and exits the block: - - example_store do |store| - store.transaction do - store.keys # => [:foo, :bar, :baz] - store[:bat] = 3 - store.abort - fail 'Cannot get here' - end - store.transaction do - # Update was not completed. - store.keys # => [:foo, :bar, :baz] - end - end - -### Read-Only Transactions - -By default, a transaction allows both reading from and writing to the store: - - store.transaction do - # Read-write transaction. - # Any code except a call to #transaction is allowed here. - end - -If argument `read_only` is passed as `true`, only reading is allowed: - - store.transaction(true) do - # Read-only transaction: - # Calls to #transaction, #[]=, and #delete are not allowed here. - end - -## Hierarchical Values - -The value for an entry may be a simple object (as seen above). It may also be -a hierarchy of objects nested to any depth: - - deep_store = PStore.new('deep.store') - deep_store.transaction do - array_of_hashes = [{}, {}, {}] - deep_store[:array_of_hashes] = array_of_hashes - deep_store[:array_of_hashes] # => [{}, {}, {}] - hash_of_arrays = {foo: [], bar: [], baz: []} - deep_store[:hash_of_arrays] = hash_of_arrays - deep_store[:hash_of_arrays] # => {:foo=>[], :bar=>[], :baz=>[]} - deep_store[:hash_of_arrays][:foo].push(:bat) - deep_store[:hash_of_arrays] # => {:foo=>[:bat], :bar=>[], :baz=>[]} - end - -And recall that you can use [dig methods](rdoc-ref:dig_methods.rdoc) in a -returned hierarchy of objects. - -## Working with the Store - -### Creating a Store - -Use method PStore.new to create a store. The new store creates or opens its -containing file: - - store = PStore.new('t.store') - -### Modifying the Store - -Use method #[]= to update or create an entry: - - example_store do |store| - store.transaction do - store[:foo] = 1 # Update. - store[:bam] = 1 # Create. - end - end - -Use method #delete to remove an entry: - - example_store do |store| - store.transaction do - store.delete(:foo) - store[:foo] # => nil - end - end - -### Retrieving Values - -Use method #fetch (allows default) or #[] (defaults to `nil`) to retrieve an -entry: - - example_store do |store| - store.transaction do - store[:foo] # => 0 - store[:nope] # => nil - store.fetch(:baz) # => 2 - store.fetch(:nope, nil) # => nil - store.fetch(:nope) # Raises exception. - end - end - -### Querying the Store - -Use method #key? to determine whether a given key exists: - - example_store do |store| - store.transaction do - store.key?(:foo) # => true - end - end - -Use method #keys to retrieve keys: - - example_store do |store| - store.transaction do - store.keys # => [:foo, :bar, :baz] - end - end - -Use method #path to retrieve the path to the store's underlying file; this -method may be called from outside a transaction block: - - store = PStore.new('t.store') - store.path # => "t.store" - -## Transaction Safety - -For transaction safety, see: - -* Optional argument `thread_safe` at method PStore.new. -* Attribute #ultra_safe. - -Needless to say, if you're storing valuable data with PStore, then you should -backup the PStore file from time to time. - -## An Example Store - - require "pstore" - - # A mock wiki object. - class WikiPage - - attr_reader :page_name - - def initialize(page_name, author, contents) - @page_name = page_name - @revisions = Array.new - add_revision(author, contents) - end - - def add_revision(author, contents) - @revisions << {created: Time.now, - author: author, - contents: contents} - end - - def wiki_page_references - [@page_name] + @revisions.last[:contents].scan(/\b(?:[A-Z]+[a-z]+){2,}/) - end - - end - - # Create a new wiki page. - home_page = WikiPage.new("HomePage", "James Edward Gray II", - "A page about the JoysOfDocumentation..." ) - - wiki = PStore.new("wiki_pages.pstore") - # Update page data and the index together, or not at all. - wiki.transaction do - # Store page. - wiki[home_page.page_name] = home_page - # Create page index. - wiki[:wiki_index] ||= Array.new - # Update wiki index. - wiki[:wiki_index].push(*home_page.wiki_page_references) - end - - # Read wiki data, setting argument read_only to true. - wiki.transaction(true) do - wiki.keys.each do |key| - puts key - puts wiki[key] - end - end - - -# Attributes -## ultra_safe[RW] [](#attribute-i-ultra_safe) -Whether PStore should do its best to prevent file corruptions, even when an -unlikely error (such as memory-error or filesystem error) occurs: - -* `true`: changes are posted by creating a temporary file, writing the - updated data to it, then renaming the file to the given #path. File - integrity is maintained. Note: has effect only if the filesystem has - atomic file rename (as do POSIX platforms Linux, MacOS, FreeBSD and - others). - -* `false` (the default): changes are posted by rewinding the open file and - writing the updated data. File integrity is maintained if the filesystem - raises no unexpected I/O error; if such an error occurs during a write to - the store, the file may become corrupted. - - -#Instance Methods -## [](key) [](#method-i-[]) -Returns the value for the given `key` if the key exists. `nil` otherwise; if -not `nil`, the returned value is an object or a hierarchy of objects: - - example_store do |store| - store.transaction do - store[:foo] # => 0 - store[:nope] # => nil - end - end - -Returns `nil` if there is no such key. - -See also [Hierarchical Values](rdoc-ref:PStore@Hierarchical+Values). - -Raises an exception if called outside a transaction block. - -## []=(key, value) [](#method-i-[]=) -Creates or replaces the value for the given `key`: - - example_store do |store| - temp.transaction do - temp[:bat] = 3 - end - end - -See also [Hierarchical Values](rdoc-ref:PStore@Hierarchical+Values). - -Raises an exception if called outside a transaction block. - -## abort() [](#method-i-abort) -Exits the current transaction block, discarding any changes specified in the -[transaction block](rdoc-ref:PStore@The+Transaction+Block). - -Raises an exception if called outside a transaction block. - -## commit() [](#method-i-commit) -Exits the current transaction block, committing any changes specified in the -[transaction block](rdoc-ref:PStore@The+Transaction+Block). - -Raises an exception if called outside a transaction block. - -## delete(key) [](#method-i-delete) -Removes and returns the value at `key` if it exists: - - example_store do |store| - store.transaction do - store[:bat] = 3 - store.delete(:bat) - end - end - -Returns `nil` if there is no such key. - -Raises an exception if called outside a transaction block. - -## fetch(key, defaultPStore::Error) [](#method-i-fetch) -Like #[], except that it accepts a default value for the store. If the `key` -does not exist: - -* Raises an exception if `default` is `PStore::Error`. -* Returns the value of `default` otherwise: - - example_store do |store| - store.transaction do - store.fetch(:nope, nil) # => nil - store.fetch(:nope) # Raises an exception. - end - end - -Raises an exception if called outside a transaction block. - -## initialize(file, thread_safefalse) [](#method-i-initialize) -Returns a new PStore object. - -Argument `file` is the path to the file in which objects are to be stored; if -the file exists, it should be one that was written by PStore. - - path = 't.store' - store = PStore.new(path) - -A PStore object is -[reentrant](https://en.wikipedia.org/wiki/Reentrancy_(computing)). If argument -`thread_safe` is given as `true`, the object is also thread-safe (at the cost -of a small performance penalty): - - store = PStore.new(path, true) - -**@return** [PStore] a new instance of PStore - -## key?(key) [](#method-i-key?) -Returns `true` if `key` exists, `false` otherwise: - - example_store do |store| - store.transaction do - store.key?(:foo) # => true - end - end - -Raises an exception if called outside a transaction block. - -**@return** [Boolean] - -## keys() [](#method-i-keys) -Returns an array of the existing keys: - - example_store do |store| - store.transaction do - store.keys # => [:foo, :bar, :baz] - end - end - -Raises an exception if called outside a transaction block. - -## path() [](#method-i-path) -Returns the string file path used to create the store: - - store.path # => "flat.store" - -## transaction(read_onlyfalse) [](#method-i-transaction) -Opens a transaction block for the store. See -[Transactions](rdoc-ref:PStore@Transactions). - -With argument `read_only` as `false`, the block may both read from and write -to the store. - -With argument `read_only` as `true`, the block may not include calls to -#transaction, #[]=, or #delete. - -Raises an exception if called within a transaction block. - diff --git a/example/ruby/PStore/Error.md b/example/ruby/PStore/Error.md deleted file mode 100644 index cca1d20..0000000 --- a/example/ruby/PStore/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: PStore::Error -**Inherits:** StandardError - - -The error type thrown by all PStore methods. - - - diff --git a/example/ruby/PStoreTest.md b/example/ruby/PStoreTest.md deleted file mode 100644 index 888b713..0000000 --- a/example/ruby/PStoreTest.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: PStoreTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## clear_store() [](#method-i-clear_store) - -## second_file() [](#method-i-second_file) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_changes_after_commit_are_discarded() [](#method-i-test_changes_after_commit_are_discarded) - -## test_changes_are_not_written_on_abort() [](#method-i-test_changes_are_not_written_on_abort) - -## test_data_should_be_loaded_correctly_when_in_readonly_mode() [](#method-i-test_data_should_be_loaded_correctly_when_in_readonly_mode) - -## test_data_should_be_loaded_correctly_when_in_readwrite_mode() [](#method-i-test_data_should_be_loaded_correctly_when_in_readwrite_mode) - -## test_key_p() [](#method-i-test_key_p) - -## test_keys() [](#method-i-test_keys) - -## test_nested_transaction_raises_error() [](#method-i-test_nested_transaction_raises_error) - -## test_opening_new_file_in_readonly_mode_should_result_in_empty_values() [](#method-i-test_opening_new_file_in_readonly_mode_should_result_in_empty_values) - -## test_opening_new_file_in_readwrite_mode_should_result_in_empty_values() [](#method-i-test_opening_new_file_in_readwrite_mode_should_result_in_empty_values) - -## test_pstore_files_are_accessed_as_binary_files() [](#method-i-test_pstore_files_are_accessed_as_binary_files) -Test that PStore's file operations do not blow up when default encodings are -set - -## test_thread_safe() [](#method-i-test_thread_safe) - -## test_writing_inside_readonly_transaction_raises_error() [](#method-i-test_writing_inside_readonly_transaction_raises_error) - diff --git a/example/ruby/PTY.md b/example/ruby/PTY.md deleted file mode 100644 index c00639e..0000000 --- a/example/ruby/PTY.md +++ /dev/null @@ -1,125 +0,0 @@ -# Module: PTY - - - - -# Class Methods -## check(*args ) [](#method-c-check) -Checks the status of the child process specified by `pid`. Returns `nil` if -the process is still alive. - -If the process is not alive, and `raise` was true, a PTY::ChildExited -exception will be raised. Otherwise it will return a Process::Status instance. - -`pid` -: The process id of the process to check - -`raise` -: If `true` and the process identified by `pid` is no longer alive a - PTY::ChildExited is raised. - -**@overload** [] - -**@overload** [] - -## open() [](#method-c-open) -Allocates a pty (pseudo-terminal). - -In the block form, yields an array of two elements (`master_io, slave_file`) -and the value of the block is returned from `open`. - -The IO and File are both closed after the block completes if they haven't been -already closed. - - PTY.open {|master, slave| - p master #=> # - p slave #=> # - p slave.path #=> "/dev/pts/1" - } - -In the non-block form, returns a two element array, `[master_io, slave_file]`. - - master, slave = PTY.open - # do something with master for IO, or the slave file - -The arguments in both forms are: - -`master_io` -: the master of the pty, as an IO. - -`slave_file` -: the slave of the pty, as a File. The path to the - - terminal device is available via `slave_file.path` - -IO#raw! is usable to disable newline conversions: - - require 'io/console' - PTY.open {|m, s| - s.raw! - # ... - } -**@overload** [] - -**@overload** [] - -## spawn(*args ) [](#method-c-spawn) -Spawns the specified command on a newly allocated pty. You can also use the -alias ::getpty. - -The command's controlling tty is set to the slave device of the pty and its -standard input/output/error is redirected to the slave device. - -`env` is an optional hash that provides additional environment variables to -the spawned pty. - - # sets FOO to "bar" - PTY.spawn({"FOO"=>"bar"}, "printenv", "FOO") do |r, w, pid| - p r.read #=> "bar\r\n" - ensure - r.close; w.close; Process.wait(pid) - end - # unsets FOO - PTY.spawn({"FOO"=>nil}, "printenv", "FOO") do |r, w, pid| - p r.read #=> "" - ensure - r.close; w.close; Process.wait(pid) - end - -`command` and `command_line` are the full commands to run, given a String. Any -additional `arguments` will be passed to the command. - -### Return values - -In the non-block form this returns an array of size three, `[r, w, pid]`. - -In the block form these same values will be yielded to the block: - -`r` -: A readable IO that contains the command's standard output and standard - error - -`w` -: A writable IO that is the command's standard input - -`pid` -: The process identifier for the command. - - -### Clean up - -This method does not clean up like closing IOs or waiting for child process, -except that the process is detached in the block form to prevent it from -becoming a zombie (see Process.detach). Any other cleanup is the -responsibility of the caller. If waiting for `pid`, be sure to close both `r` -and `w` before doing so; doing it in the reverse order may cause deadlock on -some OSes. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - - diff --git a/example/ruby/PTY/ChildExited.md b/example/ruby/PTY/ChildExited.md deleted file mode 100644 index 05e107a..0000000 --- a/example/ruby/PTY/ChildExited.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: PTY::ChildExited -**Inherits:** RuntimeError - - -Thrown when PTY::check is called for a pid that represents a process that has -exited. - - - -#Instance Methods -## status() [](#method-i-status) -Returns the exit status of the child for which PTY#check raised this exception - diff --git a/example/ruby/ParallelRunner.md b/example/ruby/ParallelRunner.md deleted file mode 100644 index 4c0eefa..0000000 --- a/example/ruby/ParallelRunner.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: ParallelRunner -**Inherits:** Object - - - - - -#Instance Methods -## handle(child, message) [](#method-i-handle) - -## initialize(files, processes, formatter, argv) [](#method-i-initialize) - -**@return** [ParallelRunner] a new instance of ParallelRunner - -## launch_children() [](#method-i-launch_children) - -## quit(child) [](#method-i-quit) - -## run() [](#method-i-run) - -## send_new_file_or_quit(child) [](#method-i-send_new_file_or_quit) - diff --git a/example/ruby/ParamList.md b/example/ruby/ParamList.md deleted file mode 100644 index 46623ae..0000000 --- a/example/ruby/ParamList.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: ParamList -**Inherits:** Object - - -List of parameters/arguments for a method - - - -#Instance Methods -## compute_checksum() [](#method-i-compute_checksum) -Compute the expected checksum of arguments ahead of time - -## gen_call_str() [](#method-i-gen_call_str) -Generate code to call into the method and pass the arguments - -## gen_method_str() [](#method-i-gen_method_str) -Generate code for the method signature and method body - -## initialize() [](#method-i-initialize) - -**@return** [ParamList] a new instance of ParamList - -## sample_args() [](#method-i-sample_args) -Sample/generate a random set of arguments corresponding to the parameters - -## sample_params() [](#method-i-sample_params) -Sample/generate a random set of parameters for a method - diff --git a/example/ruby/Parent.md b/example/ruby/Parent.md deleted file mode 100644 index ead02e7..0000000 --- a/example/ruby/Parent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Parent -**Inherits:** Object - - - - - diff --git a/example/ruby/ParserSupport.md b/example/ruby/ParserSupport.md deleted file mode 100644 index 74c3ca7..0000000 --- a/example/ruby/ParserSupport.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: ParserSupport - - - - -# Class Methods -## prism_enabled?() [](#method-c-prism_enabled?) -Determines whether or not Prism is being used in the current process. This -would have been determined by `--parser=prism` on either the command line or -from within various environment variables. -**@return** [Boolean] - -## prism_enabled_in_subprocess?() [](#method-c-prism_enabled_in_subprocess?) -Determines whether or not Prism would be used by a subprocess. This is -necessary because some tests run in subprocesses, and we need to know if we -expect Prism to be used by those tests. This happens if Prism is configured as -the default parser. -**@return** [Boolean] - - diff --git a/example/ruby/Path.md b/example/ruby/Path.md deleted file mode 100644 index b80e79c..0000000 --- a/example/ruby/Path.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: Path - - - - -# Class Methods -## clean(path ) [](#method-c-clean) -## clean_link(src , dest ) [](#method-c-clean_link) -**@yield** [src, dest] - -## ln_dir_relative(src , dest ) [](#method-c-ln_dir_relative) -## ln_relative(src , dest , executable false) [](#method-c-ln_relative) -## ln_safe(src , dest , real_src ) [](#method-c-ln_safe) -## relative(path , base ) [](#method-c-relative) - diff --git a/example/ruby/Path/HardlinkExcutable.md b/example/ruby/Path/HardlinkExcutable.md deleted file mode 100644 index 846d3ef..0000000 --- a/example/ruby/Path/HardlinkExcutable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Path::HardlinkExcutable - - - - - -#Instance Methods -## ln_exe(relative_src, dest, src) [](#method-i-ln_exe) - diff --git a/example/ruby/Path/Mswin.md b/example/ruby/Path/Mswin.md deleted file mode 100644 index b3761a4..0000000 --- a/example/ruby/Path/Mswin.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Path::Mswin - - -Extensions to FileUtils - - - -#Instance Methods -## ln_dir_safe(src, dest, real_src) [](#method-i-ln_dir_safe) - -## ln_safe(src, dest, real_src, *opt) [](#method-i-ln_safe) - diff --git a/example/ruby/Pathname.md b/example/ruby/Pathname.md deleted file mode 100644 index e900e94..0000000 --- a/example/ruby/Pathname.md +++ /dev/null @@ -1,805 +0,0 @@ -# Class: Pathname -**Inherits:** Object - - -* tmpdir * - - -# Class Methods -## getwd() [](#method-c-getwd) -Returns the current working directory as a Pathname. - -Pathname.getwd - #=> # - -See Dir.getwd. -## glob(*args ) [](#method-c-glob) -Returns or yields Pathname objects. - - Pathname.glob("lib/i*.rb") - -#=> [#, #] - -See Dir.glob. -## mktmpdir() [](#method-c-mktmpdir) -Creates a tmp directory and wraps the returned path in a Pathname object. - -See Dir.mktmpdir -## pwd() [](#method-c-pwd) -Returns the current working directory as a Pathname. - -Pathname.getwd - #=> # - -See Dir.getwd. - -#Instance Methods -## +(other) [](#method-i-+) -Appends a pathname fragment to `self` to produce a new Pathname object. Since -`other` is considered as a path relative to `self`, if `other` is an absolute -path, the new Pathname object is created from just `other`. - - p1 = Pathname.new("/usr") # Pathname:/usr - p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby - p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd - - # / is aliased to +. - p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby - p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd - -This method doesn't access the file system; it is pure string manipulation. - -## <=>(other) [](#method-i-<=>) -Provides a case-sensitive comparison operator for pathnames. - -Pathname.new('/usr') <=> Pathname.new('/usr/bin') - #=> -1 - -Pathname.new('/usr/bin') <=> Pathname.new('/usr/bin') - #=> 0 - -Pathname.new('/usr/bin') <=> Pathname.new('/USR/BIN') - #=> 1 - -It will return `-1`, `0` or `1` depending on the value of the left argument -relative to the right argument. Or it will return `nil` if the arguments are -not comparable. - -## ==(other) [](#method-i-==) -Compare this pathname with `other`. The comparison is string-based. Be aware -that two different paths (`foo.txt` and `./foo.txt`) can refer to the same -file. - -## ===(other) [](#method-i-===) -Compare this pathname with `other`. The comparison is string-based. Be aware -that two different paths (`foo.txt` and `./foo.txt`) can refer to the same -file. - -## absolute?() [](#method-i-absolute?) -Predicate method for testing whether a path is absolute. - -It returns `true` if the pathname begins with a slash. - - p = Pathname.new('/im/sure') - p.absolute? - #=> true - - p = Pathname.new('not/so/sure') - p.absolute? - #=> false - -**@return** [Boolean] - -## ascend() [](#method-i-ascend) -Iterates over and yields a new Pathname object for each element in the given -path in ascending order. - - Pathname.new('/path/to/some/file.rb').ascend {|v| p v} - # - # - # - # - # - - Pathname.new('path/to/some/file.rb').ascend {|v| p v} - # - # - # - # - -Returns an Enumerator if no block was given. - - enum = Pathname.new("/usr/bin/ruby").ascend - # ... do stuff ... - enum.each { |e| ... } - # yields Pathnames /usr/bin/ruby, /usr/bin, /usr, and /. - -It doesn't access the filesystem. - -**@yield** [_self] - -**@yieldparam** [Pathname] the object that the method was called on - -## atime() [](#method-i-atime) -Returns the last access time for the file. - -See File.atime. - -**@overload** [] - -## basename(*args) [](#method-i-basename) -Returns the last component of the path. - -See File.basename. - -## binread(*args) [](#method-i-binread) -Returns all the bytes from the file, or the first `N` if specified. - -See File.binread. - -**@overload** [] - -## binwrite(*args) [](#method-i-binwrite) -Writes `contents` to the file, opening it in binary mode. - -See File.binwrite. - -**@overload** [] - -**@overload** [] - -## birthtime() [](#method-i-birthtime) -Returns the birth time for the file. If the platform doesn't have birthtime, -raises NotImplementedError. - -See File.birthtime. - -**@overload** [] - -## blockdev?() [](#method-i-blockdev?) -See FileTest.blockdev?. - -**@return** [Boolean] - -## chardev?() [](#method-i-chardev?) -See FileTest.chardev?. - -**@return** [Boolean] - -## children(with_directorytrue) [](#method-i-children) -Returns the children of the directory (files and subdirectories, not -recursive) as an array of Pathname objects. - -By default, the returned pathnames will have enough information to access the -files. If you set `with_directory` to `false`, then the returned pathnames -will contain the filename only. - -For example: - pn = Pathname("/usr/lib/ruby/1.8") - pn.children - # -> [ Pathname:/usr/lib/ruby/1.8/English.rb, - Pathname:/usr/lib/ruby/1.8/Env.rb, - Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ] - pn.children(false) - # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ] - -Note that the results never contain the entries `.` and `..` in the directory -because they are not children. - -## chmod(mode) [](#method-i-chmod) -Changes file permissions. - -See File.chmod. - -**@overload** [] - -## chown(owner, group) [](#method-i-chown) -Change owner and group of the file. - -See File.chown. - -**@overload** [] - -## cleanpath(consider_symlinkfalse) [](#method-i-cleanpath) -Returns clean pathname of `self` with consecutive slashes and useless dots -removed. The filesystem is not accessed. - -If `consider_symlink` is `true`, then a more conservative algorithm is used to -avoid breaking symbolic linkages. This may retain more `..` entries than -absolutely necessary, but without accessing the filesystem, this can't be -avoided. - -See Pathname#realpath. - -## ctime() [](#method-i-ctime) -Returns the last change time, using directory information, not the file -itself. - -See File.ctime. - -**@overload** [] - -## delete() [](#method-i-delete) -Removes a file or directory, using File.unlink if `self` is a file, or -Dir.unlink as necessary. - -## descend() [](#method-i-descend) -Iterates over and yields a new Pathname object for each element in the given -path in descending order. - - Pathname.new('/path/to/some/file.rb').descend {|v| p v} - # - # - # - # - # - - Pathname.new('path/to/some/file.rb').descend {|v| p v} - # - # - # - # - -Returns an Enumerator if no block was given. - - enum = Pathname.new("/usr/bin/ruby").descend - # ... do stuff ... - enum.each { |e| ... } - # yields Pathnames /, /usr, /usr/bin, and /usr/bin/ruby. - -It doesn't access the filesystem. - -## directory?() [](#method-i-directory?) -See FileTest.directory?. - -**@return** [Boolean] - -## dirname() [](#method-i-dirname) -Returns all but the last component of the path. - -See File.dirname. - -## each_child(with_directorytrue, &b) [](#method-i-each_child) -Iterates over the children of the directory (files and subdirectories, not -recursive). - -It yields Pathname object for each child. - -By default, the yielded pathnames will have enough information to access the -files. - -If you set `with_directory` to `false`, then the returned pathnames will -contain the filename only. - - Pathname("/usr/local").each_child {|f| p f } - #=> # - # # - # # - # # - # # - # # - # # - # # - - Pathname("/usr/local").each_child(false) {|f| p f } - #=> # - # # - # # - # # - # # - # # - # # - # # - -Note that the results never contain the entries `.` and `..` in the directory -because they are not children. - -See Pathname#children - -## each_entry() [](#method-i-each_entry) -Iterates over the entries (files and subdirectories) in the directory, -yielding a Pathname object for each entry. - -## each_filename() [](#method-i-each_filename) -Iterates over each component of the path. - - Pathname.new("/usr/bin/ruby").each_filename {|filename| ... } - # yields "usr", "bin", and "ruby". - -Returns an Enumerator if no block was given. - - enum = Pathname.new("/usr/bin/ruby").each_filename - # ... do stuff ... - enum.each { |e| ... } - # yields "usr", "bin", and "ruby". - -## each_line(*args) [](#method-i-each_line) -Iterates over each line in the file and yields a String object for each. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Tests the file is empty. - -See Dir#empty? and FileTest.empty?. - -**@return** [Boolean] - -## entries() [](#method-i-entries) -Return the entries (files and subdirectories) in the directory, each as a -Pathname object. - -The results contains just the names in the directory, without any trailing -slashes or recursive look-up. - - pp Pathname.new('/usr/local').entries - #=> [#, - # #, - # #, - # #, - # #, - # #, - # #, - # #, - # #, - # #, - # #] - -The result may contain the current directory `#` and the parent -directory `#`. - -If you don't want `.` and `..` and want directories, consider -Pathname#children. - -## eql?(other) [](#method-i-eql?) -Compare this pathname with `other`. The comparison is string-based. Be aware -that two different paths (`foo.txt` and `./foo.txt`) can refer to the same -file. - -**@return** [Boolean] - -## executable?() [](#method-i-executable?) -See FileTest.executable?. - -**@return** [Boolean] - -## executable_real?() [](#method-i-executable_real?) -See FileTest.executable_real?. - -**@return** [Boolean] - -## exist?() [](#method-i-exist?) -See FileTest.exist?. - -**@return** [Boolean] - -## expand_path(*args) [](#method-i-expand_path) -Returns the absolute path for the file. - -See File.expand_path. - -## extname() [](#method-i-extname) -Returns the file's extension. - -See File.extname. - -## file?() [](#method-i-file?) -See FileTest.file?. - -**@return** [Boolean] - -## find(ignore_error:true) [](#method-i-find) -Iterates over the directory tree in a depth first manner, yielding a Pathname -for each file under "this" directory. - -Returns an Enumerator if no block is given. - -Since it is implemented by the standard library module Find, Find.prune can be -used to control the traversal. - -If `self` is `.`, yielded pathnames begin with a filename in the current -directory, not `./`. - -See Find.find - -## fnmatch(*args) [](#method-i-fnmatch) -Return `true` if the receiver matches the given pattern. - -See File.fnmatch. - -**@overload** [] - -**@overload** [] - -## fnmatch?(*args) [](#method-i-fnmatch?) -Return `true` if the receiver matches the given pattern. - -See File.fnmatch. - -**@overload** [] - -**@overload** [] - -## freeze() [](#method-i-freeze) -Freezes this Pathname. - -See Object.freeze. - -**@overload** [] - -## ftype() [](#method-i-ftype) -Returns "type" of file ("file", "directory", etc). - -See File.ftype. - -**@overload** [] - -## glob(*args) [](#method-i-glob) -Returns or yields Pathname objects. - - Pathname("ruby-2.4.2").glob("R*.md") - #=> [#, #] - -See Dir.glob. This method uses the `base` keyword argument of Dir.glob. - -## grpowned?() [](#method-i-grpowned?) -See FileTest.grpowned?. - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(arg) [](#method-i-initialize) -Create a Pathname object from the given String (or String-like object). If -`path` contains a NULL character (`\0`), an ArgumentError is raised. - -## inspect() [](#method-i-inspect) -:nodoc: - -## join(*args) [](#method-i-join) -Joins the given pathnames onto `self` to create a new Pathname object. This is -effectively the same as using Pathname#+ to append `self` and all arguments -sequentially. - - path0 = Pathname.new("/usr") # Pathname:/usr - path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby - # is the same as - path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby - path0 == path1 - #=> true - -## lchmod(mode) [](#method-i-lchmod) -Same as Pathname.chmod, but does not follow symbolic links. - -See File.lchmod. - -**@overload** [] - -## lchown(owner, group) [](#method-i-lchown) -Same as Pathname.chown, but does not follow symbolic links. - -See File.lchown. - -**@overload** [] - -## lstat() [](#method-i-lstat) -See File.lstat. - -## lutime(atime, mtime) [](#method-i-lutime) -Update the access and modification times of the file. - -Same as Pathname#utime, but does not follow symbolic links. - -See File.lutime. - -## make_link(old) [](#method-i-make_link) -Creates a hard link at *pathname*. - -See File.link. - -**@overload** [] - -## make_symlink(old) [](#method-i-make_symlink) -Creates a symbolic link. - -See File.symlink. - -**@overload** [] - -## mkdir(*args) [](#method-i-mkdir) -Create the referenced directory. - -See Dir.mkdir. - -## mkpath(mode:nil) [](#method-i-mkpath) -Creates a full path, including any intermediate directories that don't yet -exist. - -See FileUtils.mkpath and FileUtils.mkdir_p - -## mountpoint?() [](#method-i-mountpoint?) -Returns `true` if `self` points to a mountpoint. - -**@return** [Boolean] - -## mtime() [](#method-i-mtime) -Returns the last modified time of the file. - -See File.mtime. - -**@overload** [] - -## open(*args) [](#method-i-open) -Opens the file for reading or writing. - -See File.open. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## opendir() [](#method-i-opendir) -Opens the referenced directory. - -See Dir.open. - -## owned?() [](#method-i-owned?) -See FileTest.owned?. - -**@return** [Boolean] - -## parent() [](#method-i-parent) -Returns the parent directory. - -This is same as `self + '..'`. - -## pipe?() [](#method-i-pipe?) -See FileTest.pipe?. - -**@return** [Boolean] - -## read(*args) [](#method-i-read) -Returns all data from the file, or the first `N` bytes if specified. - -See File.read. - -**@overload** [] - -**@overload** [] - -## readable?() [](#method-i-readable?) -See FileTest.readable?. - -**@return** [Boolean] - -## readable_real?() [](#method-i-readable_real?) -See FileTest.readable_real?. - -**@return** [Boolean] - -## readlines(*args) [](#method-i-readlines) -Returns all the lines from the file. - -See File.readlines. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## readlink() [](#method-i-readlink) -Read symbolic link. - -See File.readlink. - -## realdirpath(*args) [](#method-i-realdirpath) -Returns the real (absolute) pathname of `self` in the actual filesystem. - -Does not contain symlinks or useless dots, `..` and `.`. - -The last component of the real pathname can be nonexistent. - -## realpath(*args) [](#method-i-realpath) -Returns the real (absolute) pathname for `self` in the actual filesystem. - -Does not contain symlinks or useless dots, `..` and `.`. - -All components of the pathname must exist when this method is called. - -## relative?() [](#method-i-relative?) -The opposite of Pathname#absolute? - -It returns `false` if the pathname begins with a slash. - - p = Pathname.new('/im/sure') - p.relative? - #=> false - - p = Pathname.new('not/so/sure') - p.relative? - #=> true - -**@return** [Boolean] - -## relative_path_from(base_directory) [](#method-i-relative_path_from) -Returns a relative path from the given `base_directory` to the receiver. - -If `self` is absolute, then `base_directory` must be absolute too. - -If `self` is relative, then `base_directory` must be relative too. - -This method doesn't access the filesystem. It assumes no symlinks. - -ArgumentError is raised when it cannot find a relative path. - -Note that this method does not handle situations where the case sensitivity of -the filesystem in use differs from the operating system default. - -## rename(to) [](#method-i-rename) -Rename the file. - -See File.rename. - -## rmdir() [](#method-i-rmdir) -Remove the referenced directory. - -See Dir.rmdir. - -## rmtree(noop:nil, verbose:nil, secure:nil) [](#method-i-rmtree) -Recursively deletes a directory, including all directories beneath it. - -See FileUtils.rm_rf - -## root?() [](#method-i-root?) -Predicate method for root directories. Returns `true` if the pathname -consists of consecutive slashes. - -It doesn't access the filesystem. So it may return `false` for some pathnames -which points to roots such as `/usr/..`. - -**@return** [Boolean] - -## setgid?() [](#method-i-setgid?) -See FileTest.setgid?. - -**@return** [Boolean] - -## setuid?() [](#method-i-setuid?) -See FileTest.setuid?. - -**@return** [Boolean] - -## size() [](#method-i-size) -See FileTest.size. - -## size?() [](#method-i-size?) -See FileTest.size?. - -**@return** [Boolean] - -## socket?() [](#method-i-socket?) -See FileTest.socket?. - -**@return** [Boolean] - -## split() [](#method-i-split) -Returns the #dirname and the #basename in an Array. - -See File.split. - -## stat() [](#method-i-stat) -Returns a File::Stat object. - -See File.stat. - -## sticky?() [](#method-i-sticky?) -See FileTest.sticky?. - -**@return** [Boolean] - -## sub(*args) [](#method-i-sub) -Return a pathname which is substituted by String#sub. - -path1 = Pathname.new('/usr/bin/perl') path1.sub('perl', 'ruby') - #=> # - -## sub_ext(repl) [](#method-i-sub_ext) -Return a pathname with `repl` added as a suffix to the basename. - -If self has no extension part, `repl` is appended. - -Pathname.new('/usr/bin/shutdown').sub_ext('.rb') - #=> # - -## symlink?() [](#method-i-symlink?) -See FileTest.symlink?. - -**@return** [Boolean] - -## sysopen(*args) [](#method-i-sysopen) -See IO.sysopen. - -**@overload** [] - -## to_path() [](#method-i-to_path) -Return the path as a String. - -to_path is implemented so Pathname objects are usable with File.open, etc. - -**@overload** [] - -**@overload** [] - -## to_s() [](#method-i-to_s) -Return the path as a String. - -to_path is implemented so Pathname objects are usable with File.open, etc. - -**@overload** [] - -**@overload** [] - -## truncate(length) [](#method-i-truncate) -Truncates the file to `length` bytes. - -See File.truncate. - -## unlink() [](#method-i-unlink) -Removes a file or directory, using File.unlink if `self` is a file, or -Dir.unlink as necessary. - -## utime(atime, mtime) [](#method-i-utime) -Update the access and modification times of the file. - -See File.utime. - -## world_readable?() [](#method-i-world_readable?) -See FileTest.world_readable?. - -**@return** [Boolean] - -## world_writable?() [](#method-i-world_writable?) -See FileTest.world_writable?. - -**@return** [Boolean] - -## writable?() [](#method-i-writable?) -See FileTest.writable?. - -**@return** [Boolean] - -## writable_real?() [](#method-i-writable_real?) -See FileTest.writable_real?. - -**@return** [Boolean] - -## write(*args) [](#method-i-write) -Writes `contents` to the file. - -See File.write. - -**@overload** [] - -**@overload** [] - -## zero?() [](#method-i-zero?) -See FileTest.zero?. - -**@return** [Boolean] - diff --git a/example/ruby/PatternKeyNameCheckTest.md b/example/ruby/PatternKeyNameCheckTest.md deleted file mode 100644 index 6d4fa43..0000000 --- a/example/ruby/PatternKeyNameCheckTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: PatternKeyNameCheckTest -**Inherits:** Test::Unit::TestCase - -**Includes:** DidYouMean::TestHelper - - - - - -#Instance Methods -## assert_correction(expected, array) [](#method-i-assert_correction) - -## test_corrects_hash_key_name_with_single_pattern_match() [](#method-i-test_corrects_hash_key_name_with_single_pattern_match) - diff --git a/example/ruby/PiDigitSpigot.md b/example/ruby/PiDigitSpigot.md deleted file mode 100644 index 0db2f78..0000000 --- a/example/ruby/PiDigitSpigot.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: PiDigitSpigot -**Inherits:** Object - - -The Great Computer Language Shootout http://shootout.alioth.debian.org/ - -contributed by Gabriele Renzi - - - -#Instance Methods -## consume(a) [](#method-i-consume) - -## initialize() [](#method-i-initialize) - -**@return** [PiDigitSpigot] a new instance of PiDigitSpigot - -## next!() [](#method-i-next!) - -## produce(i) [](#method-i-produce) - -## safe?(digit) [](#method-i-safe?) - -**@return** [Boolean] - diff --git a/example/ruby/Piece.md b/example/ruby/Piece.md deleted file mode 100644 index 11d888f..0000000 --- a/example/ruby/Piece.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Piece -**Inherits:** Object - - -describes a piece and caches information about its rotations to as to be -efficient for iteration ATTRIBUTES: - rotations -- all the rotations of the piece - type -- a numeic "name" of the piece - masks -- an array by location of all legal rotational masks (a n inner array) for that location - placed -- the mask that this piece was last placed at (not a location, but the actual mask used) - - -# Attributes -## masks[RW] [](#attribute-i-masks) -Returns the value of attribute masks. - -## placed[RW] [](#attribute-i-placed) -Returns the value of attribute placed. - -## rotations[RW] [](#attribute-i-rotations) -Returns the value of attribute rotations. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## fill_string(board_string) [](#method-i-fill_string) -given a board string, adds this piece to the board at whatever -location/rotation important: the outbound board string is 5 wide, the normal -location notation is six wide (padded) - -## generate_rotations(directions) [](#method-i-generate_rotations) -rotates a set of directions through all six angles and adds a Rotation to the -list for each one - -## initialize(directions, type) [](#method-i-initialize) - -**@return** [Piece] a new instance of Piece - diff --git a/example/ruby/Plane.md b/example/ruby/Plane.md deleted file mode 100644 index 2400f28..0000000 --- a/example/ruby/Plane.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Plane -**Inherits:** Object - - - - - -#Instance Methods -## initialize(p, n) [](#method-i-initialize) - -**@return** [Plane] a new instance of Plane - -## intersect(ray, isect) [](#method-i-intersect) - diff --git a/example/ruby/Planet.md b/example/ruby/Planet.md deleted file mode 100644 index dd879ad..0000000 --- a/example/ruby/Planet.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Planet -**Inherits:** Object - - - - -# Attributes -## mass[RW] [](#attribute-i-mass) -Returns the value of attribute mass. - -## vx[RW] [](#attribute-i-vx) -Returns the value of attribute vx. - -## vy[RW] [](#attribute-i-vy) -Returns the value of attribute vy. - -## vz[RW] [](#attribute-i-vz) -Returns the value of attribute vz. - -## x[RW] [](#attribute-i-x) -Returns the value of attribute x. - -## y[RW] [](#attribute-i-y) -Returns the value of attribute y. - -## z[RW] [](#attribute-i-z) -Returns the value of attribute z. - - -#Instance Methods -## initialize(x, y, z, vx, vy, vz, mass) [](#method-i-initialize) - -**@return** [Planet] a new instance of Planet - -## move_from_i(bodies, nbodies, dt, i) [](#method-i-move_from_i) - diff --git a/example/ruby/PlatformGuard.md b/example/ruby/PlatformGuard.md deleted file mode 100644 index 2b9ba8d..0000000 --- a/example/ruby/PlatformGuard.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: PlatformGuard -**Inherits:** SpecGuard - - - - -# Class Methods -## c_long_size?(size ) [](#method-c-c_long_size?) -**@return** [Boolean] - -## implementation?(*args ) [](#method-c-implementation?) -**@return** [Boolean] - -## os?(*oses ) [](#method-c-os?) -**@return** [Boolean] - -## pointer_size?(size ) [](#method-c-pointer_size?) -**@return** [Boolean] - -## standard?() [](#method-c-standard?) -**@return** [Boolean] - -## wasi?() [](#method-c-wasi?) -**@return** [Boolean] - -## windows?() [](#method-c-windows?) -**@return** [Boolean] - -## wordsize?(size ) [](#method-c-wordsize?) -**@return** [Boolean] - -## wsl?() [](#method-c-wsl?) -**@return** [Boolean] - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [PlatformGuard] a new instance of PlatformGuard - -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/Point.md b/example/ruby/Point.md deleted file mode 100644 index 328c188..0000000 --- a/example/ruby/Point.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Point -**Inherits:** Object - - -Linked list example -- short version using inspect - - - -#Instance Methods -## initialize(x, y) [](#method-i-initialize) - -**@return** [Point] a new instance of Point - -## inspect() [](#method-i-inspect) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/PrecedenceSpecs.md b/example/ruby/PrecedenceSpecs.md deleted file mode 100644 index 72cc60b..0000000 --- a/example/ruby/PrecedenceSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: PrecedenceSpecs - - - - - diff --git a/example/ruby/PrecedenceSpecs/NonUnaryOpTest.md b/example/ruby/PrecedenceSpecs/NonUnaryOpTest.md deleted file mode 100644 index e2f04f7..0000000 --- a/example/ruby/PrecedenceSpecs/NonUnaryOpTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: PrecedenceSpecs::NonUnaryOpTest -**Inherits:** Object - - - - - -#Instance Methods -## add_num(arg) [](#method-i-add_num) - -## add_str() [](#method-i-add_str) - -## add_var() [](#method-i-add_var) - -## sub_num(arg) [](#method-i-sub_num) - diff --git a/example/ruby/PrettyPrint.md b/example/ruby/PrettyPrint.md deleted file mode 100644 index ed59a15..0000000 --- a/example/ruby/PrettyPrint.md +++ /dev/null @@ -1,193 +0,0 @@ -# Class: PrettyPrint -**Inherits:** Object - - -This class implements a pretty printing algorithm. It finds line breaks and -nice indentations for grouped structure. - -By default, the class assumes that primitive elements are strings and each -byte in the strings have single column in width. But it can be used for other -situations by giving suitable arguments for some methods: -* newline object and space generation block for PrettyPrint.new -* optional width argument for PrettyPrint#text -* PrettyPrint#breakable - -There are several candidate uses: -* text formatting using proportional fonts -* multibyte characters which has columns different to number of bytes -* non-string formatting - -## Bugs -* Box based formatting? -* Other (better) model/algorithm? - -Report any bugs at http://bugs.ruby-lang.org - -## References -Christian Lindig, Strictly Pretty, March 2000, -https://lindig.github.io/papers/strictly-pretty-2000.pdf - -Philip Wadler, A prettier printer, March 1998, -https://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier - -## Author -Tanaka Akira - - -# Class Methods -## format(output ''.dup, maxwidth 79, newline "\n", genspace lambda {|n| ' ' * n}) [](#method-c-format) -This is a convenience method which is same as follows: - - begin - q = PrettyPrint.new(output, maxwidth, newline, &genspace) - ... - q.flush - output - end -**@yield** [q] - -## singleline_format(output ''.dup, maxwidth nil, newline nil, genspace nil) [](#method-c-singleline_format) -This is similar to PrettyPrint::format but the result has no breaks. - -`maxwidth`, `newline` and `genspace` are ignored. - -The invocation of `breakable` in the block doesn't break a line and is treated -as just an invocation of `text`. -**@yield** [q] - -# Attributes -## genspace[RW] [](#attribute-i-genspace) -A lambda or Proc, that takes one argument, of an Integer, and returns the -corresponding number of spaces. - -By default this is: - lambda {|n| ' ' * n} - -## group_queue[RW] [](#attribute-i-group_queue) -The PrettyPrint::GroupQueue of groups in stack to be pretty printed - -## indent[RW] [](#attribute-i-indent) -The number of spaces to be indented - -## maxwidth[RW] [](#attribute-i-maxwidth) -The maximum width of a line, before it is separated in to a newline - -This defaults to 79, and should be an Integer - -## newline[RW] [](#attribute-i-newline) -The value that is appended to `output` to add a new line. - -This defaults to "n", and should be String - -## output[RW] [](#attribute-i-output) -The output object. - -This defaults to '', and should accept the << method - - -#Instance Methods -## break_outmost_groups() [](#method-i-break_outmost_groups) -Breaks the buffer into lines that are shorter than #maxwidth - -## breakable(sep' ', widthsep.length) [](#method-i-breakable) -This says "you can break a line here if necessary", and a `width`-column text -`sep` is inserted if a line is not broken at the point. - -If `sep` is not specified, " " is used. - -If `width` is not specified, `sep.length` is used. You will have to specify -this when `sep` is a multibyte character, for example. - -## current_group() [](#method-i-current_group) -Returns the group most recently added to the stack. - -Contrived example: - out = "" - => "" - q = PrettyPrint.new(out) - => #, @output_width=0, @buffer_width=0, @buffer=[], @group_stack=[#], @group_queue=#]]>, @indent=0> - q.group { - q.text q.current_group.inspect - q.text q.newline - q.group(q.current_group.depth + 1) { - q.text q.current_group.inspect - q.text q.newline - q.group(q.current_group.depth + 1) { - q.text q.current_group.inspect - q.text q.newline - q.group(q.current_group.depth + 1) { - q.text q.current_group.inspect - q.text q.newline - } - } - } - } - => 284 - puts out - # - # - # - # - -## fill_breakable(sep' ', widthsep.length) [](#method-i-fill_breakable) -This is similar to #breakable except the decision to break or not is -determined individually. - -Two #fill_breakable under a group may cause 4 results: (break,break), -(break,non-break), (non-break,break), (non-break,non-break). This is different -to #breakable because two #breakable under a group may cause 2 results: -(break,break), (non-break,non-break). - -The text `sep` is inserted if a line is not broken at this point. - -If `sep` is not specified, " " is used. - -If `width` is not specified, `sep.length` is used. You will have to specify -this when `sep` is a multibyte character, for example. - -## flush() [](#method-i-flush) -outputs buffered data. - -## group(indent0, open_obj'', close_obj'', open_widthopen_obj.length, close_widthclose_obj.length) [](#method-i-group) -Groups line break hints added in the block. The line break hints are all to be -used or not. - -If `indent` is specified, the method call is regarded as nested by -nest(indent) { ... }. - -If `open_obj` is specified, `text open_obj, open_width` is called before -grouping. If `close_obj` is specified, `text close_obj, close_width` is called -after grouping. - -## group_sub() [](#method-i-group_sub) -Takes a block and queues a new group that is indented 1 level further. - -## initialize(output''.dup, maxwidth79, newline"\n", &genspace) [](#method-i-initialize) -Creates a buffer for pretty printing. - -`output` is an output target. If it is not specified, '' is assumed. It should -have a << method which accepts the first argument `obj` of PrettyPrint#text, -the first argument `sep` of PrettyPrint#breakable, the first argument -`newline` of PrettyPrint.new, and the result of a given block for -PrettyPrint.new. - -`maxwidth` specifies maximum line length. If it is not specified, 79 is -assumed. However actual outputs may overflow `maxwidth` if long non-breakable -texts are provided. - -`newline` is used for line breaks. "n" is used if it is not specified. - -The block is used to generate spaces. {|width| ' ' * width} is used if it is -not given. - -**@return** [PrettyPrint] a new instance of PrettyPrint - -## nest(indent) [](#method-i-nest) -Increases left margin after newline with `indent` for line breaks added in the -block. - -## text(obj, widthobj.length) [](#method-i-text) -This adds `obj` as a text of `width` columns in width. - -If `width` is not specified, obj.length is used. - diff --git a/example/ruby/PrettyPrint/Breakable.md b/example/ruby/PrettyPrint/Breakable.md deleted file mode 100644 index 2245375..0000000 --- a/example/ruby/PrettyPrint/Breakable.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: PrettyPrint::Breakable -**Inherits:** Object - - -The Breakable class is used for breaking up object information - -This class is intended for internal use of the PrettyPrint buffers. - - -# Attributes -## indent[RW] [](#attribute-i-indent) -The number of spaces to indent. - -This is inferred from `q` within PrettyPrint, passed in ::new - -## obj[RW] [](#attribute-i-obj) -Holds the separator String - -The `sep` argument from ::new - -## width[RW] [](#attribute-i-width) -The width of `obj` / `sep` - - -#Instance Methods -## initialize(sep, width, q) [](#method-i-initialize) -Create a new Breakable object. - -Arguments: -* `sep` String of the separator -* `width` Integer width of the `sep` -* `q` parent PrettyPrint object, to base from - -**@return** [Breakable] a new instance of Breakable - -## output(out, output_width) [](#method-i-output) -Render the String text of the objects that have been added to this Breakable -object. - -Output the text to `out`, and increment the width to `output_width` - diff --git a/example/ruby/PrettyPrint/Group.md b/example/ruby/PrettyPrint/Group.md deleted file mode 100644 index da59e92..0000000 --- a/example/ruby/PrettyPrint/Group.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: PrettyPrint::Group -**Inherits:** Object - - -The Group class is used for making indentation easier. - -While this class does neither the breaking into newlines nor indentation, it -is used in a stack (as well as a queue) within PrettyPrint, to group objects. - -For information on using groups, see PrettyPrint#group - -This class is intended for internal use of the PrettyPrint buffers. - - -# Attributes -## breakables[RW] [](#attribute-i-breakables) -Array to hold the Breakable objects for this Group - -## depth[RW] [](#attribute-i-depth) -This group's relation to previous groups - - -#Instance Methods -## break() [](#method-i-break) -Makes a break for this Group, and returns true - -## break?() [](#method-i-break?) -Boolean of whether this Group has made a break - -**@return** [Boolean] - -## first?() [](#method-i-first?) -Boolean of whether this Group has been queried for being first - -This is used as a predicate, and ought to be called first. - -**@return** [Boolean] - -## initialize(depth) [](#method-i-initialize) -Create a Group object - -Arguments: -* `depth` - this group's relation to previous groups - -**@return** [Group] a new instance of Group - diff --git a/example/ruby/PrettyPrint/GroupQueue.md b/example/ruby/PrettyPrint/GroupQueue.md deleted file mode 100644 index 1ef5561..0000000 --- a/example/ruby/PrettyPrint/GroupQueue.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: PrettyPrint::GroupQueue -**Inherits:** Object - - -The GroupQueue class is used for managing the queue of Group to be pretty -printed. - -This queue groups the Group objects, based on their depth. - -This class is intended for internal use of the PrettyPrint buffers. - - - -#Instance Methods -## delete(group) [](#method-i-delete) -Remote `group` from this queue - -## deq() [](#method-i-deq) -Returns the outer group of the queue - -## enq(group) [](#method-i-enq) -Enqueue `group` - -This does not strictly append the group to the end of the queue, but instead -adds it in line, base on the `group.depth` - -## initialize(*groups) [](#method-i-initialize) -Create a GroupQueue object - -Arguments: -* `groups` - one or more PrettyPrint::Group objects - -**@return** [GroupQueue] a new instance of GroupQueue - diff --git a/example/ruby/PrettyPrint/SingleLine.md b/example/ruby/PrettyPrint/SingleLine.md deleted file mode 100644 index 63119e8..0000000 --- a/example/ruby/PrettyPrint/SingleLine.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: PrettyPrint::SingleLine -**Inherits:** Object - - -PrettyPrint::SingleLine is used by PrettyPrint.singleline_format - -It is passed to be similar to a PrettyPrint object itself, by responding to: -* #text -* #breakable -* #nest -* #group -* #flush -* #first? - -but instead, the output has no line breaks - - - -#Instance Methods -## breakable(sep' ', widthnil) [](#method-i-breakable) -Appends `sep` to the text to be output. By default `sep` is ' ' - -`width` argument is here for compatibility. It is a noop argument. - -## first?() [](#method-i-first?) -This is used as a predicate, and ought to be called first. - -**@return** [Boolean] - -## flush() [](#method-i-flush) -Method present for compatibility, but is a noop - -## group(indentnil, open_obj'', close_obj'', open_widthnil, close_widthnil) [](#method-i-group) -Opens a block for grouping objects to be pretty printed. - -Arguments: -* `indent` - noop argument. Present for compatibility. -* `open_obj` - text appended before the &blok. Default is '' -* `close_obj` - text appended after the &blok. Default is '' -* `open_width` - noop argument. Present for compatibility. -* `close_width` - noop argument. Present for compatibility. - -## initialize(output, maxwidthnil, newlinenil) [](#method-i-initialize) -Create a PrettyPrint::SingleLine object - -Arguments: -* `output` - String (or similar) to store rendered text. Needs to respond to - '<<' -* `maxwidth` - Argument position expected to be here for compatibility. - This argument is a noop. - -* `newline` - Argument position expected to be here for compatibility. - This argument is a noop. - -**@return** [SingleLine] a new instance of SingleLine - -## nest(indent) [](#method-i-nest) -Takes `indent` arg, but does nothing with it. - -Yields to a block. - -## text(obj, widthnil) [](#method-i-text) -Add `obj` to the text to be output. - -`width` argument is here for compatibility. It is a noop argument. - diff --git a/example/ruby/PrettyPrint/Text.md b/example/ruby/PrettyPrint/Text.md deleted file mode 100644 index a143606..0000000 --- a/example/ruby/PrettyPrint/Text.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: PrettyPrint::Text -**Inherits:** Object - - -The Text class is the means by which to collect strings from objects. - -This class is intended for internal use of the PrettyPrint buffers. - - -# Attributes -## width[RW] [](#attribute-i-width) -The total width of the objects included in this Text object. - - -#Instance Methods -## add(obj, width) [](#method-i-add) -Include `obj` in the objects to be pretty printed, and increment this Text -object's total width by `width` - -## initialize() [](#method-i-initialize) -Creates a new text object. - -This constructor takes no arguments. - -The workflow is to append a PrettyPrint::Text object to the buffer, and being -able to call the buffer.last() to reference it. - -As there are objects, use PrettyPrint::Text#add to include the objects and the -width to utilized by the String version of this object. - -**@return** [Text] a new instance of Text - -## output(out, output_width) [](#method-i-output) -Render the String text of the objects that have been added to this Text -object. - -Output the text to `out`, and increment the width to `output_width` - diff --git a/example/ruby/PrettyPrintTest.md b/example/ruby/PrettyPrintTest.md deleted file mode 100644 index 317d9d1..0000000 --- a/example/ruby/PrettyPrintTest.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: PrettyPrintTest - - - - - diff --git a/example/ruby/PrettyPrintTest/Fill.md b/example/ruby/PrettyPrintTest/Fill.md deleted file mode 100644 index 10c93e6..0000000 --- a/example/ruby/PrettyPrintTest/Fill.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: PrettyPrintTest::Fill -**Inherits:** Test::Unit::TestCase - - -:nodoc: - - - -#Instance Methods -## format(width) [](#method-i-format) - -## test_00_06() [](#method-i-test_00_06) - -## test_07_10() [](#method-i-test_07_10) - -## test_11_14() [](#method-i-test_11_14) - -## test_15_18() [](#method-i-test_15_18) - -## test_19_22() [](#method-i-test_19_22) - -## test_23_26() [](#method-i-test_23_26) - -## test_27() [](#method-i-test_27) - diff --git a/example/ruby/PrettyPrintTest/NonString.md b/example/ruby/PrettyPrintTest/NonString.md deleted file mode 100644 index 9609b1c..0000000 --- a/example/ruby/PrettyPrintTest/NonString.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: PrettyPrintTest::NonString -**Inherits:** Test::Unit::TestCase - - -:nodoc: - - - -#Instance Methods -## format(width) [](#method-i-format) - -## test_6() [](#method-i-test_6) - -## test_7() [](#method-i-test_7) - diff --git a/example/ruby/PrettyPrintTest/StrictPrettyExample.md b/example/ruby/PrettyPrintTest/StrictPrettyExample.md deleted file mode 100644 index 753c635..0000000 --- a/example/ruby/PrettyPrintTest/StrictPrettyExample.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: PrettyPrintTest::StrictPrettyExample -**Inherits:** Test::Unit::TestCase - - -:nodoc: - - - -#Instance Methods -## prog(width) [](#method-i-prog) - -## test_00_04() [](#method-i-test_00_04) - -## test_05() [](#method-i-test_05) - -## test_06() [](#method-i-test_06) - -## test_07() [](#method-i-test_07) - -## test_08() [](#method-i-test_08) - -## test_09() [](#method-i-test_09) - -## test_10() [](#method-i-test_10) - -## test_11_31() [](#method-i-test_11_31) - -## test_32() [](#method-i-test_32) - diff --git a/example/ruby/PrettyPrintTest/TailGroup.md b/example/ruby/PrettyPrintTest/TailGroup.md deleted file mode 100644 index d8a6f05..0000000 --- a/example/ruby/PrettyPrintTest/TailGroup.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: PrettyPrintTest::TailGroup -**Inherits:** Test::Unit::TestCase - - -:nodoc: - - - -#Instance Methods -## test_1() [](#method-i-test_1) - diff --git a/example/ruby/PrettyPrintTest/WadlerExample.md b/example/ruby/PrettyPrintTest/WadlerExample.md deleted file mode 100644 index 5f22c7b..0000000 --- a/example/ruby/PrettyPrintTest/WadlerExample.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: PrettyPrintTest::WadlerExample -**Inherits:** Test::Unit::TestCase - - -:nodoc: - - - -#Instance Methods -## hello(width) [](#method-i-hello) - -## setup() [](#method-i-setup) - -## test_hello_00_06() [](#method-i-test_hello_00_06) - -## test_hello_07_08() [](#method-i-test_hello_07_08) - -## test_hello_09_10() [](#method-i-test_hello_09_10) - -## test_hello_11_12() [](#method-i-test_hello_11_12) - -## test_hello_13() [](#method-i-test_hello_13) - -## test_tree_00_19() [](#method-i-test_tree_00_19) - -## test_tree_20_22() [](#method-i-test_tree_20_22) - -## test_tree_23_43() [](#method-i-test_tree_23_43) - -## test_tree_44() [](#method-i-test_tree_44) - -## test_tree_alt_00_18() [](#method-i-test_tree_alt_00_18) - -## test_tree_alt_19_20() [](#method-i-test_tree_alt_19_20) - -## test_tree_alt_20_49() [](#method-i-test_tree_alt_20_49) - -## test_tree_alt_50() [](#method-i-test_tree_alt_50) - -## tree(width) [](#method-i-tree) - -## tree_alt(width) [](#method-i-tree_alt) - diff --git a/example/ruby/PrettyPrintTest/WadlerExample/Tree.md b/example/ruby/PrettyPrintTest/WadlerExample/Tree.md deleted file mode 100644 index 7700441..0000000 --- a/example/ruby/PrettyPrintTest/WadlerExample/Tree.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: PrettyPrintTest::WadlerExample::Tree -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## altshow(q) [](#method-i-altshow) - -## initialize(string, *children) [](#method-i-initialize) - -**@return** [Tree] a new instance of Tree - -## show(q) [](#method-i-show) - diff --git a/example/ruby/Prism.md b/example/ruby/Prism.md deleted file mode 100644 index aeadc69..0000000 --- a/example/ruby/Prism.md +++ /dev/null @@ -1,177 +0,0 @@ -# Module: Prism - - -This file is organized to match itemization in -https://github.com/ruby/prism/issues/1335 - - -# Class Methods -## dump(*args ) [](#method-c-dump) -Dump the AST corresponding to the given string to a string. For supported -options, see Prism::parse. -**@overload** [] - -## dump_file(*args ) [](#method-c-dump_file) -Dump the AST corresponding to the given file to a string. For supported -options, see Prism::parse. -**@overload** [] - -## lex(*args ) [](#method-c-lex) -Return a LexResult instance that contains an array of Token instances -corresponding to the given string. For supported options, see Prism::parse. -**@overload** [] - -## lex_compat(source , **options ) [](#method-c-lex_compat) -:call-seq: - Prism::lex_compat(source, **options) -> LexCompat::Result - -Returns a parse result whose value is an array of tokens that closely -resembles the return value of Ripper::lex. The main difference is that the -`:on_sp` token is not emitted. - -For supported options, see Prism::parse. -## lex_file(*args ) [](#method-c-lex_file) -Return a LexResult instance that contains an array of Token instances -corresponding to the given file. For supported options, see Prism::parse. -**@overload** [] - -## lex_ripper(source ) [](#method-c-lex_ripper) -:call-seq: - Prism::lex_ripper(source) -> Array - -This lexes with the Ripper lex. It drops any space events but otherwise -returns the same tokens. Raises SyntaxError if the syntax in source is -invalid. -## load(source , serialized ) [](#method-c-load) -:call-seq: - Prism::load(source, serialized) -> ParseResult - -Load the serialized AST using the source as a reference into a tree. -## parse(*args ) [](#method-c-parse) -Parse the given string and return a ParseResult instance. The options that are -supported are: - -* `command_line` - either nil or a string of the various options that were - set on the command line. Valid values are combinations of "a", "l", - "n", "p", and "x". - -* `encoding` - the encoding of the source being parsed. This should be an - encoding or nil. - -* `filepath` - the filepath of the source being parsed. This should be a - string or nil. - -* `frozen_string_literal` - whether or not the frozen string literal pragma - has been set. This should be a boolean or nil. - -* `line` - the line number that the parse starts on. This should be an - integer or nil. Note that this is 1-indexed. - -* `main_script` - a boolean indicating whether or not the source being - parsed - is the main script being run by the interpreter. This controls whether - or not shebangs are parsed for additional flags and whether or not the - parser will attempt to find a matching shebang if the first one does - not contain the word "ruby". - -* `partial_script` - when the file being parsed is considered a "partial" - script, jumps will not be marked as errors if they are not contained - within loops/blocks. This is used in the case that you're parsing a - script that you know will be embedded inside another script later, but - you do not have that context yet. For example, when parsing an ERB - template that will be evaluated inside another script. - -* `scopes` - the locals that are in scope surrounding the code that is being - parsed. This should be an array of arrays of symbols or nil. Scopes are - ordered from the outermost scope to the innermost one. - -* `version` - the version of Ruby syntax that prism should used to parse - Ruby - code. By default prism assumes you want to parse with the latest version - of Ruby syntax (which you can trigger with `nil` or `"latest"`). You - may also restrict the syntax to a specific version of Ruby, e.g., with `"3.3.0"`. - To parse with the same syntax version that the current Ruby is running - use `version: RUBY_VERSION`. Raises ArgumentError if the version is not - currently supported by Prism. -**@overload** [] - -## parse_comments(*args ) [](#method-c-parse_comments) -Parse the given string and return an array of Comment objects. For supported -options, see Prism::parse. -**@overload** [] - -## parse_failure?(*args ) [](#method-c-parse_failure?) -Parse the given string and return true if it parses with errors. For supported -options, see Prism::parse. -**@overload** [] - -## parse_file(*args ) [](#method-c-parse_file) -Parse the given file and return a ParseResult instance. For supported options, -see Prism::parse. -**@overload** [] - -## parse_file_comments(*args ) [](#method-c-parse_file_comments) -Parse the given file and return an array of Comment objects. For supported -options, see Prism::parse. -**@overload** [] - -## parse_file_failure?(*args ) [](#method-c-parse_file_failure?) -Parse the given file and return true if it parses with errors. For supported -options, see Prism::parse. -**@overload** [] - -## parse_file_success?(*args ) [](#method-c-parse_file_success?) -Parse the given file and return true if it parses without errors. For -supported options, see Prism::parse. -**@overload** [] - -## parse_lex(*args ) [](#method-c-parse_lex) -Parse the given string and return a ParseLexResult instance that contains a -2-element array, where the first element is the AST and the second element is -an array of Token instances. - -This API is only meant to be used in the case where you need both the AST and -the tokens. If you only need one or the other, use either Prism::parse or -Prism::lex. - -For supported options, see Prism::parse. -**@overload** [] - -## parse_lex_file(*args ) [](#method-c-parse_lex_file) -Parse the given file and return a ParseLexResult instance that contains a -2-element array, where the first element is the AST and the second element is -an array of Token instances. - -This API is only meant to be used in the case where you need both the AST and -the tokens. If you only need one or the other, use either Prism::parse_file or -Prism::lex_file. - -For supported options, see Prism::parse. -**@overload** [] - -## parse_statement(source , **options ) [](#method-c-parse_statement) -A convenience method for retrieving the first statement in the source string -parsed by Prism. -## parse_stream(*args ) [](#method-c-parse_stream) -Parse the given object that responds to `gets` and return a ParseResult -instance. The options that are supported are the same as Prism::parse. -**@overload** [] - -## parse_success?(*args ) [](#method-c-parse_success?) -Parse the given string and return true if it parses without errors. For -supported options, see Prism::parse. -**@overload** [] - -## profile(*args ) [](#method-c-profile) -Parse the given string and return nothing. This method is meant to allow -profilers to avoid the overhead of reifying the AST to Ruby. For supported -options, see Prism::parse. -**@overload** [] - -## profile_file(*args ) [](#method-c-profile_file) -Parse the given file and return nothing. This method is meant to allow -profilers to avoid the overhead of reifying the AST to Ruby. For supported -options, see Prism::parse. -**@overload** [] - - diff --git a/example/ruby/Prism/ASCIISource.md b/example/ruby/Prism/ASCIISource.md deleted file mode 100644 index 0f91234..0000000 --- a/example/ruby/Prism/ASCIISource.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Prism::ASCIISource -**Inherits:** Prism::Source - - -Specialized version of Prism::Source for source code that includes ASCII -characters only. This class is used to apply performance optimizations that -cannot be applied to sources that include multibyte characters. - -In the extremely rare case that a source includes multi-byte characters but is -marked as binary because of a magic encoding comment and it cannot be eagerly -converted to UTF-8, this class will be used as well. This is because at that -point we will treat everything as single-byte characters. - - - -#Instance Methods -## character_column(byte_offset) [](#method-i-character_column) -Return the column number in characters for the given byte offset. - -## character_offset(byte_offset) [](#method-i-character_offset) -Return the character offset for the given byte offset. - -## code_units_cache(encoding) [](#method-i-code_units_cache) -Returns a cache that is the identity function in order to maintain the same -interface. We can do this because code units are always equivalent to byte -offsets for ASCII-only sources. - -## code_units_column(byte_offset, encoding) [](#method-i-code_units_column) -Specialized version of `code_units_column` that does not depend on -`code_units_offset`, which is a more expensive operation. This is essentially -the same as `Prism::Source#column`. - -## code_units_offset(byte_offset, encoding) [](#method-i-code_units_offset) -Returns the offset from the start of the file for the given byte offset -counting in code units for the given encoding. - -This method is tested with UTF-8, UTF-16, and UTF-32. If there is the concept -of code units that differs from the number of characters in other encodings, -it is not captured here. - diff --git a/example/ruby/Prism/AttributeWriteTest.md b/example/ruby/Prism/AttributeWriteTest.md deleted file mode 100644 index 60bc9d7..0000000 --- a/example/ruby/Prism/AttributeWriteTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Prism::AttributeWriteTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_comparison_operators() [](#method-i-test_comparison_operators) - -## test_indexed_call_with_operator() [](#method-i-test_indexed_call_with_operator) - -## test_indexed_call_without_operator() [](#method-i-test_indexed_call_without_operator) - -## test_named_call_with_operator() [](#method-i-test_named_call_with_operator) - -## test_named_call_without_operator() [](#method-i-test_named_call_without_operator) - diff --git a/example/ruby/Prism/AttributeWriteTest/Target.md b/example/ruby/Prism/AttributeWriteTest/Target.md deleted file mode 100644 index cc69ae4..0000000 --- a/example/ruby/Prism/AttributeWriteTest/Target.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Prism::AttributeWriteTest::Target - - - - -# Class Methods -## []=(index , value ) [](#method-c-[]=) -## value() [](#method-c-value) -## value=(value ) [](#method-c-value=) - diff --git a/example/ruby/Prism/BOMTest.md b/example/ruby/Prism/BOMTest.md deleted file mode 100644 index 5a74a45..0000000 --- a/example/ruby/Prism/BOMTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Prism::BOMTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_back_reference() [](#method-i-test_back_reference) - -## test_class_variable() [](#method-i-test_class_variable) - -## test_global_variable() [](#method-i-test_global_variable) - -## test_ident() [](#method-i-test_ident) - -## test_instance_variable() [](#method-i-test_instance_variable) - -## test_numbered_reference() [](#method-i-test_numbered_reference) - -## test_percents() [](#method-i-test_percents) - -## test_string() [](#method-i-test_string) - diff --git a/example/ruby/Prism/BeginNode.md b/example/ruby/Prism/BeginNode.md deleted file mode 100644 index 093c17f..0000000 --- a/example/ruby/Prism/BeginNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::BeginNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/BreadthFirstSearchTest.md b/example/ruby/Prism/BreadthFirstSearchTest.md deleted file mode 100644 index bb2cbdb..0000000 --- a/example/ruby/Prism/BreadthFirstSearchTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::BreadthFirstSearchTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_breadth_first_search() [](#method-i-test_breadth_first_search) - diff --git a/example/ruby/Prism/CallNode.md b/example/ruby/Prism/CallNode.md deleted file mode 100644 index 231473e..0000000 --- a/example/ruby/Prism/CallNode.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::CallNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## full_message_loc() [](#method-i-full_message_loc) -When a call node has the attribute_write flag set, it means that the call is -using the attribute write syntax. This is either a method call to []= or a -method call to a method that ends with =. Either way, the = sign is present in -the source. - -Prism returns the message_loc *without* the = sign attached, because there can -be any amount of space between the message and the = sign. However, sometimes -you want the location of the full message including the inner space and the = -sign. This method provides that. - diff --git a/example/ruby/Prism/CallOperatorWriteNode.md b/example/ruby/Prism/CallOperatorWriteNode.md deleted file mode 100644 index 780a9ca..0000000 --- a/example/ruby/Prism/CallOperatorWriteNode.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::CallOperatorWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## operator() [](#method-i-operator) -Returns the binary operator used to modify the receiver. This method is -deprecated in favor of #binary_operator. - -## operator_loc() [](#method-i-operator_loc) -Returns the location of the binary operator used to modify the receiver. This -method is deprecated in favor of #binary_operator_loc. - diff --git a/example/ruby/Prism/CaseMatchNode.md b/example/ruby/Prism/CaseMatchNode.md deleted file mode 100644 index 456792b..0000000 --- a/example/ruby/Prism/CaseMatchNode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::CaseMatchNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## consequent() [](#method-i-consequent) -Returns the else clause of the case match node. This method is deprecated in -favor of #else_clause. - diff --git a/example/ruby/Prism/CaseNode.md b/example/ruby/Prism/CaseNode.md deleted file mode 100644 index 0fd6999..0000000 --- a/example/ruby/Prism/CaseNode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::CaseNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## consequent() [](#method-i-consequent) -Returns the else clause of the case node. This method is deprecated in favor -of #else_clause. - diff --git a/example/ruby/Prism/ClassVariableAndWriteNode.md b/example/ruby/Prism/ClassVariableAndWriteNode.md deleted file mode 100644 index 8e4e307..0000000 --- a/example/ruby/Prism/ClassVariableAndWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::ClassVariableAndWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/ClassVariableOperatorWriteNode.md b/example/ruby/Prism/ClassVariableOperatorWriteNode.md deleted file mode 100644 index cc37fd0..0000000 --- a/example/ruby/Prism/ClassVariableOperatorWriteNode.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::ClassVariableOperatorWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - -## operator() [](#method-i-operator) -Returns the binary operator used to modify the receiver. This method is -deprecated in favor of #binary_operator. - -## operator_loc() [](#method-i-operator_loc) -Returns the location of the binary operator used to modify the receiver. This -method is deprecated in favor of #binary_operator_loc. - diff --git a/example/ruby/Prism/ClassVariableOrWriteNode.md b/example/ruby/Prism/ClassVariableOrWriteNode.md deleted file mode 100644 index f8b5d46..0000000 --- a/example/ruby/Prism/ClassVariableOrWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::ClassVariableOrWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/CodeUnitsCache.md b/example/ruby/Prism/CodeUnitsCache.md deleted file mode 100644 index 7a69280..0000000 --- a/example/ruby/Prism/CodeUnitsCache.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Prism::CodeUnitsCache -**Inherits:** Object - - -A cache that can be used to quickly compute code unit offsets from byte -offsets. It purposefully provides only a single #[] method to access the cache -in order to minimize surface area. - -Note that there are some known issues here that may or may not be addressed in -the future: - -* The first is that there are issues when the cache computes values that are - not on character boundaries. This can result in subsequent computations - being off by one or more code units. -* The second is that this cache is currently unbounded. In theory we could - introduce some kind of LRU cache to limit the number of entries, but this - has not yet been implemented. - - - -#Instance Methods -## [](byte_offset) [](#method-i-[]) -Retrieve the code units offset from the given byte offset. - -## initialize(source, encoding) [](#method-i-initialize) -Initialize a new cache with the given source and encoding. - -**@return** [CodeUnitsCache] a new instance of CodeUnitsCache - diff --git a/example/ruby/Prism/CommandLineTest.md b/example/ruby/Prism/CommandLineTest.md deleted file mode 100644 index 8259b21..0000000 --- a/example/ruby/Prism/CommandLineTest.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::CommandLineTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_command_line_a() [](#method-i-test_command_line_a) - -## test_command_line_e() [](#method-i-test_command_line_e) - -## test_command_line_l() [](#method-i-test_command_line_l) - -## test_command_line_n() [](#method-i-test_command_line_n) - -## test_command_line_p() [](#method-i-test_command_line_p) - -## test_command_line_x_explicit() [](#method-i-test_command_line_x_explicit) - -## test_command_line_x_explicit_fail() [](#method-i-test_command_line_x_explicit_fail) - -## test_command_line_x_implicit() [](#method-i-test_command_line_x_implicit) - -## test_command_line_x_implicit_fail() [](#method-i-test_command_line_x_implicit_fail) - diff --git a/example/ruby/Prism/Comment.md b/example/ruby/Prism/Comment.md deleted file mode 100644 index 82f8000..0000000 --- a/example/ruby/Prism/Comment.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Prism::Comment -**Inherits:** Object - - -This represents a comment that was encountered during parsing. It is the base -class for all comment types. - - -# Attributes -## location[RW] [](#attribute-i-location) -The location of this comment in the source. - - -#Instance Methods -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for Comment. - -## initialize(location) [](#method-i-initialize) -Create a new comment object with the given location. - -**@return** [Comment] a new instance of Comment - -## slice() [](#method-i-slice) -Returns the content of the comment by slicing it from the source code. - diff --git a/example/ruby/Prism/CommentsTest.md b/example/ruby/Prism/CommentsTest.md deleted file mode 100644 index cf42eb6..0000000 --- a/example/ruby/Prism/CommentsTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Prism::CommentsTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test___END__() [](#method-i-test___END__) - -## test___END__crlf() [](#method-i-test___END__crlf) - -## test_attaching_comments() [](#method-i-test_attaching_comments) - -## test_comment_embedded_document() [](#method-i-test_comment_embedded_document) - -## test_comment_embedded_document_with_content_on_same_line() [](#method-i-test_comment_embedded_document_with_content_on_same_line) - -## test_comment_inline() [](#method-i-test_comment_inline) - -## test_comment_inline_def() [](#method-i-test_comment_inline_def) - diff --git a/example/ruby/Prism/CompilerTest.md b/example/ruby/Prism/CompilerTest.md deleted file mode 100644 index 41a8bb8..0000000 --- a/example/ruby/Prism/CompilerTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::CompilerTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_compiler() [](#method-i-test_compiler) - diff --git a/example/ruby/Prism/CompilerTest/SExpressions.md b/example/ruby/Prism/CompilerTest/SExpressions.md deleted file mode 100644 index 5aa4d5b..0000000 --- a/example/ruby/Prism/CompilerTest/SExpressions.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::CompilerTest::SExpressions -**Inherits:** Prism::Compiler - - - - - -#Instance Methods -## visit_arguments_node(node) [](#method-i-visit_arguments_node) - -## visit_call_node(node) [](#method-i-visit_call_node) - -## visit_integer_node(node) [](#method-i-visit_integer_node) - -## visit_program_node(node) [](#method-i-visit_program_node) - diff --git a/example/ruby/Prism/ConstantAndWriteNode.md b/example/ruby/Prism/ConstantAndWriteNode.md deleted file mode 100644 index e1c8ce3..0000000 --- a/example/ruby/Prism/ConstantAndWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::ConstantAndWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/ConstantOperatorWriteNode.md b/example/ruby/Prism/ConstantOperatorWriteNode.md deleted file mode 100644 index a887e49..0000000 --- a/example/ruby/Prism/ConstantOperatorWriteNode.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::ConstantOperatorWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - -## operator() [](#method-i-operator) -Returns the binary operator used to modify the receiver. This method is -deprecated in favor of #binary_operator. - -## operator_loc() [](#method-i-operator_loc) -Returns the location of the binary operator used to modify the receiver. This -method is deprecated in favor of #binary_operator_loc. - diff --git a/example/ruby/Prism/ConstantOrWriteNode.md b/example/ruby/Prism/ConstantOrWriteNode.md deleted file mode 100644 index 0110566..0000000 --- a/example/ruby/Prism/ConstantOrWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::ConstantOrWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/ConstantPathNode.md b/example/ruby/Prism/ConstantPathNode.md deleted file mode 100644 index dad9d61..0000000 --- a/example/ruby/Prism/ConstantPathNode.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Prism::ConstantPathNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## child() [](#method-i-child) -Previously, we had a child node on this class that contained either a constant -read or a missing node. To not cause a breaking change, we continue to supply -that API. - -## full_name() [](#method-i-full_name) -Returns the full name of this constant path. For example: "Foo::Bar" - -## full_name_parts() [](#method-i-full_name_parts) -Returns the list of parts for the full name of this constant path. For -example: [:Foo, :Bar] - diff --git a/example/ruby/Prism/ConstantPathNode/DynamicPartsInConstantPathError.md b/example/ruby/Prism/ConstantPathNode/DynamicPartsInConstantPathError.md deleted file mode 100644 index 8544cc9..0000000 --- a/example/ruby/Prism/ConstantPathNode/DynamicPartsInConstantPathError.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: Prism::ConstantPathNode::DynamicPartsInConstantPathError -**Inherits:** StandardError - - -An error class raised when dynamic parts are found while computing a constant -path's full name. For example: Foo::Bar::Baz -> does not raise because all -parts of the constant path are simple constants var::Bar::Baz -> raises -because the first part of the constant path is a local variable - - - diff --git a/example/ruby/Prism/ConstantPathNode/MissingNodesInConstantPathError.md b/example/ruby/Prism/ConstantPathNode/MissingNodesInConstantPathError.md deleted file mode 100644 index 8f7724a..0000000 --- a/example/ruby/Prism/ConstantPathNode/MissingNodesInConstantPathError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Prism::ConstantPathNode::MissingNodesInConstantPathError -**Inherits:** StandardError - - -An error class raised when missing nodes are found while computing a constant -path's full name. For example: -Foo -: -> raises because the constant path is missing the last part - - - - diff --git a/example/ruby/Prism/ConstantPathNodeTest.md b/example/ruby/Prism/ConstantPathNodeTest.md deleted file mode 100644 index 00e96a7..0000000 --- a/example/ruby/Prism/ConstantPathNodeTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Prism::ConstantPathNodeTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_full_name_for_constant_path() [](#method-i-test_full_name_for_constant_path) - -## test_full_name_for_constant_path_target() [](#method-i-test_full_name_for_constant_path_target) - -## test_full_name_for_constant_path_target_with_non_constant_parent() [](#method-i-test_full_name_for_constant_path_target_with_non_constant_parent) - -## test_full_name_for_constant_path_with_self() [](#method-i-test_full_name_for_constant_path_with_self) - -## test_full_name_for_constant_path_with_stovetop_start() [](#method-i-test_full_name_for_constant_path_with_stovetop_start) - -## test_full_name_for_constant_path_with_variable() [](#method-i-test_full_name_for_constant_path_with_variable) - -## test_full_name_for_constant_read_node() [](#method-i-test_full_name_for_constant_read_node) - diff --git a/example/ruby/Prism/ConstantPathOperatorWriteNode.md b/example/ruby/Prism/ConstantPathOperatorWriteNode.md deleted file mode 100644 index 810b2af..0000000 --- a/example/ruby/Prism/ConstantPathOperatorWriteNode.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::ConstantPathOperatorWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## operator() [](#method-i-operator) -Returns the binary operator used to modify the receiver. This method is -deprecated in favor of #binary_operator. - -## operator_loc() [](#method-i-operator_loc) -Returns the location of the binary operator used to modify the receiver. This -method is deprecated in favor of #binary_operator_loc. - diff --git a/example/ruby/Prism/ConstantPathTargetNode.md b/example/ruby/Prism/ConstantPathTargetNode.md deleted file mode 100644 index 0fb40e1..0000000 --- a/example/ruby/Prism/ConstantPathTargetNode.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Prism::ConstantPathTargetNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## child() [](#method-i-child) -Previously, we had a child node on this class that contained either a constant -read or a missing node. To not cause a breaking change, we continue to supply -that API. - -## full_name() [](#method-i-full_name) -Returns the full name of this constant path. For example: "Foo::Bar" - -## full_name_parts() [](#method-i-full_name_parts) -Returns the list of parts for the full name of this constant path. For -example: [:Foo, :Bar] - diff --git a/example/ruby/Prism/ConstantReadNode.md b/example/ruby/Prism/ConstantReadNode.md deleted file mode 100644 index 0eb651b..0000000 --- a/example/ruby/Prism/ConstantReadNode.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::ConstantReadNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## full_name() [](#method-i-full_name) -Returns the full name of this constant. For example: "Foo" - -## full_name_parts() [](#method-i-full_name_parts) -Returns the list of parts for the full name of this constant. For example: -[:Foo] - diff --git a/example/ruby/Prism/ConstantTargetNode.md b/example/ruby/Prism/ConstantTargetNode.md deleted file mode 100644 index a26e1eb..0000000 --- a/example/ruby/Prism/ConstantTargetNode.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::ConstantTargetNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## full_name() [](#method-i-full_name) -Returns the full name of this constant. For example: "Foo" - -## full_name_parts() [](#method-i-full_name_parts) -Returns the list of parts for the full name of this constant. For example: -[:Foo] - diff --git a/example/ruby/Prism/ConstantWriteNode.md b/example/ruby/Prism/ConstantWriteNode.md deleted file mode 100644 index 3b83a6b..0000000 --- a/example/ruby/Prism/ConstantWriteNode.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::ConstantWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## full_name() [](#method-i-full_name) -Returns the full name of this constant. For example: "Foo" - -## full_name_parts() [](#method-i-full_name_parts) -Returns the list of parts for the full name of this constant. For example: -[:Foo] - diff --git a/example/ruby/Prism/DesugarCompiler.md b/example/ruby/Prism/DesugarCompiler.md deleted file mode 100644 index d42c114..0000000 --- a/example/ruby/Prism/DesugarCompiler.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: Prism::DesugarCompiler -**Inherits:** MutationCompiler - - -DesugarCompiler is a compiler that desugars Ruby code into a more primitive -form. This is useful for consumers that want to deal with fewer node types. - - - -#Instance Methods -## visit_class_variable_and_write_node(node) [](#method-i-visit_class_variable_and_write_node) -@@foo &&= bar - -becomes - -@@foo && @@foo = bar - -## visit_class_variable_operator_write_node(node) [](#method-i-visit_class_variable_operator_write_node) -@@foo += bar - -becomes - -@@foo = @@foo + bar - -## visit_class_variable_or_write_node(node) [](#method-i-visit_class_variable_or_write_node) -@@foo ||= bar - -becomes - -defined?(@@foo) ? @@foo : @@foo = bar - -## visit_constant_and_write_node(node) [](#method-i-visit_constant_and_write_node) -Foo &&= bar - -becomes - -Foo && Foo = bar - -## visit_constant_operator_write_node(node) [](#method-i-visit_constant_operator_write_node) -Foo += bar - -becomes - -Foo = Foo + bar - -## visit_constant_or_write_node(node) [](#method-i-visit_constant_or_write_node) -Foo ||= bar - -becomes - -defined?(Foo) ? Foo : Foo = bar - -## visit_global_variable_and_write_node(node) [](#method-i-visit_global_variable_and_write_node) -$foo &&= bar - -becomes - -$foo && $foo = bar - -## visit_global_variable_operator_write_node(node) [](#method-i-visit_global_variable_operator_write_node) -$foo += bar - -becomes - -$foo = $foo + bar - -## visit_global_variable_or_write_node(node) [](#method-i-visit_global_variable_or_write_node) -$foo ||= bar - -becomes - -defined?($foo) ? $foo : $foo = bar - -## visit_instance_variable_and_write_node(node) [](#method-i-visit_instance_variable_and_write_node) -becomes - -## visit_instance_variable_operator_write_node(node) [](#method-i-visit_instance_variable_operator_write_node) -becomes - -## visit_instance_variable_or_write_node(node) [](#method-i-visit_instance_variable_or_write_node) -becomes - -## visit_local_variable_and_write_node(node) [](#method-i-visit_local_variable_and_write_node) -foo &&= bar - -becomes - -foo && foo = bar - -## visit_local_variable_operator_write_node(node) [](#method-i-visit_local_variable_operator_write_node) -foo += bar - -becomes - -foo = foo + bar - -## visit_local_variable_or_write_node(node) [](#method-i-visit_local_variable_or_write_node) -foo ||= bar - -becomes - -foo || foo = bar - diff --git a/example/ruby/Prism/DesugarCompilerTest.md b/example/ruby/Prism/DesugarCompilerTest.md deleted file mode 100644 index a9b26fe..0000000 --- a/example/ruby/Prism/DesugarCompilerTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Prism::DesugarCompilerTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_and_write() [](#method-i-test_and_write) - -## test_operator_write() [](#method-i-test_operator_write) - -## test_or_write() [](#method-i-test_or_write) - diff --git a/example/ruby/Prism/DispatcherTest.md b/example/ruby/Prism/DispatcherTest.md deleted file mode 100644 index bf73a01..0000000 --- a/example/ruby/Prism/DispatcherTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::DispatcherTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_dispatching_events() [](#method-i-test_dispatching_events) - diff --git a/example/ruby/Prism/DispatcherTest/TestListener.md b/example/ruby/Prism/DispatcherTest/TestListener.md deleted file mode 100644 index ccd6adc..0000000 --- a/example/ruby/Prism/DispatcherTest/TestListener.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Prism::DispatcherTest::TestListener -**Inherits:** Object - - - - -# Attributes -## events_received[RW] [](#attribute-i-events_received) -Returns the value of attribute events_received. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [TestListener] a new instance of TestListener - -## on_call_node_enter(node) [](#method-i-on_call_node_enter) - -## on_call_node_leave(node) [](#method-i-on_call_node_leave) - -## on_integer_node_enter(node) [](#method-i-on_integer_node_enter) - diff --git a/example/ruby/Prism/DumpTest.md b/example/ruby/Prism/DumpTest.md deleted file mode 100644 index b5841af..0000000 --- a/example/ruby/Prism/DumpTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::DumpTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_dump() [](#method-i-test_dump) - -## test_dump_file() [](#method-i-test_dump_file) - diff --git a/example/ruby/Prism/EmbDocComment.md b/example/ruby/Prism/EmbDocComment.md deleted file mode 100644 index 7da4e93..0000000 --- a/example/ruby/Prism/EmbDocComment.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Prism::EmbDocComment -**Inherits:** Prism::Comment - - -EmbDocComment objects correspond to comments that are surrounded by =begin and -=end. - - - -#Instance Methods -## inspect() [](#method-i-inspect) -Returns a string representation of this comment. - -## trailing?() [](#method-i-trailing?) -This can only be true for inline comments. - -**@return** [Boolean] - diff --git a/example/ruby/Prism/EncodingsTest.md b/example/ruby/Prism/EncodingsTest.md deleted file mode 100644 index 9a3729d..0000000 --- a/example/ruby/Prism/EncodingsTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::EncodingsTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/EncodingsTest/ConstantContext.md b/example/ruby/Prism/EncodingsTest/ConstantContext.md deleted file mode 100644 index a661ef3..0000000 --- a/example/ruby/Prism/EncodingsTest/ConstantContext.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Prism::EncodingsTest::ConstantContext -**Inherits:** BasicObject - - - - -# Class Methods -## const_missing(const ) [](#method-c-const_missing) - diff --git a/example/ruby/Prism/EncodingsTest/IdentifierContext.md b/example/ruby/Prism/EncodingsTest/IdentifierContext.md deleted file mode 100644 index 800c82f..0000000 --- a/example/ruby/Prism/EncodingsTest/IdentifierContext.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::EncodingsTest::IdentifierContext -**Inherits:** BasicObject - - - - - -#Instance Methods -## method_missing(name) [](#method-i-method_missing) - diff --git a/example/ruby/Prism/EqualityTest.md b/example/ruby/Prism/EqualityTest.md deleted file mode 100644 index da1c895..0000000 --- a/example/ruby/Prism/EqualityTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::EqualityTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_equality() [](#method-i-test_equality) - diff --git a/example/ruby/Prism/ErrorsTest.md b/example/ruby/Prism/ErrorsTest.md deleted file mode 100644 index 8f69f75..0000000 --- a/example/ruby/Prism/ErrorsTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Prism::ErrorsTest -**Inherits:** TestCase - - - - - -#Instance Methods -## test_circular_parameters() [](#method-i-test_circular_parameters) - -## test_embdoc_ending() [](#method-i-test_embdoc_ending) - -## test_invalid_message_name() [](#method-i-test_invalid_message_name) - -## test_newline_preceding_eof() [](#method-i-test_newline_preceding_eof) - -## test_unterminated_empty_string_closing() [](#method-i-test_unterminated_empty_string_closing) - -## test_unterminated_interpolated_string_closing() [](#method-i-test_unterminated_interpolated_string_closing) - -## test_unterminated_string_closing() [](#method-i-test_unterminated_string_closing) - diff --git a/example/ruby/Prism/FixturesTest.md b/example/ruby/Prism/FixturesTest.md deleted file mode 100644 index 42d0e32..0000000 --- a/example/ruby/Prism/FixturesTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::FixturesTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/FuzzerTest.md b/example/ruby/Prism/FuzzerTest.md deleted file mode 100644 index fb24ae0..0000000 --- a/example/ruby/Prism/FuzzerTest.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::FuzzerTest -**Inherits:** TestCase - - -These tests are simply to exercise snippets found by the fuzzer that caused -invalid memory access. - - -# Class Methods -## snippet(name , source ) [](#method-c-snippet) - diff --git a/example/ruby/Prism/GlobalVariableAndWriteNode.md b/example/ruby/Prism/GlobalVariableAndWriteNode.md deleted file mode 100644 index 72ac117..0000000 --- a/example/ruby/Prism/GlobalVariableAndWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::GlobalVariableAndWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/GlobalVariableOperatorWriteNode.md b/example/ruby/Prism/GlobalVariableOperatorWriteNode.md deleted file mode 100644 index 40dfde4..0000000 --- a/example/ruby/Prism/GlobalVariableOperatorWriteNode.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::GlobalVariableOperatorWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - -## operator() [](#method-i-operator) -Returns the binary operator used to modify the receiver. This method is -deprecated in favor of #binary_operator. - -## operator_loc() [](#method-i-operator_loc) -Returns the location of the binary operator used to modify the receiver. This -method is deprecated in favor of #binary_operator_loc. - diff --git a/example/ruby/Prism/GlobalVariableOrWriteNode.md b/example/ruby/Prism/GlobalVariableOrWriteNode.md deleted file mode 100644 index 79a8b98..0000000 --- a/example/ruby/Prism/GlobalVariableOrWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::GlobalVariableOrWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/HeredocDedentTest.md b/example/ruby/Prism/HeredocDedentTest.md deleted file mode 100644 index 072324f..0000000 --- a/example/ruby/Prism/HeredocDedentTest.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Prism::HeredocDedentTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_blank_lines() [](#method-i-test_blank_lines) - -## test_content() [](#method-i-test_content) - -## test_content_content() [](#method-i-test_content_content) - -## test_content_dedented_content() [](#method-i-test_content_dedented_content) - -## test_content_dedented_interpolation() [](#method-i-test_content_dedented_interpolation) - -## test_content_dedented_interpolation_content() [](#method-i-test_content_dedented_interpolation_content) - -## test_content_indented_content() [](#method-i-test_content_indented_content) - -## test_content_interpolation() [](#method-i-test_content_interpolation) - -## test_content_then_interpolation() [](#method-i-test_content_then_interpolation) - -## test_indent_size() [](#method-i-test_indent_size) - -## test_indented_content_content() [](#method-i-test_indented_content_content) - -## test_interpolation_then_content() [](#method-i-test_interpolation_then_content) - -## test_many_blank_lines() [](#method-i-test_many_blank_lines) - -## test_mixed_indentation() [](#method-i-test_mixed_indentation) - -## test_single_quote() [](#method-i-test_single_quote) - -## test_tabs_dedent_spaces() [](#method-i-test_tabs_dedent_spaces) - diff --git a/example/ruby/Prism/HeredocTest.md b/example/ruby/Prism/HeredocTest.md deleted file mode 100644 index f250259..0000000 --- a/example/ruby/Prism/HeredocTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::HeredocTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_heredoc?() [](#method-i-test_heredoc?) - -**@return** [Boolean] - diff --git a/example/ruby/Prism/IfNode.md b/example/ruby/Prism/IfNode.md deleted file mode 100644 index 7c8145e..0000000 --- a/example/ruby/Prism/IfNode.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::IfNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## consequent() [](#method-i-consequent) -Returns the subsequent if/elsif/else clause of the if node. This method is -deprecated in favor of #subsequent. - -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/ImaginaryNode.md b/example/ruby/Prism/ImaginaryNode.md deleted file mode 100644 index d2975be..0000000 --- a/example/ruby/Prism/ImaginaryNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::ImaginaryNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## value() [](#method-i-value) -Returns the value of the node as a Ruby Complex. - diff --git a/example/ruby/Prism/ImplicitArrayTest.md b/example/ruby/Prism/ImplicitArrayTest.md deleted file mode 100644 index 4b8abc6..0000000 --- a/example/ruby/Prism/ImplicitArrayTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Prism::ImplicitArrayTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_call_node() [](#method-i-test_call_node) - -## test_class_variable_write_node() [](#method-i-test_class_variable_write_node) - -## test_constant_path_write_node() [](#method-i-test_constant_path_write_node) - -## test_constant_write_node() [](#method-i-test_constant_write_node) - -## test_global_variable_write_node() [](#method-i-test_global_variable_write_node) - -## test_instance_variable_write_node() [](#method-i-test_instance_variable_write_node) - -## test_local_variable_write_node() [](#method-i-test_local_variable_write_node) - -## test_multi_write_node() [](#method-i-test_multi_write_node) - diff --git a/example/ruby/Prism/IndexOperatorWriteNode.md b/example/ruby/Prism/IndexOperatorWriteNode.md deleted file mode 100644 index d7845ff..0000000 --- a/example/ruby/Prism/IndexOperatorWriteNode.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::IndexOperatorWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## operator() [](#method-i-operator) -Returns the binary operator used to modify the receiver. This method is -deprecated in favor of #binary_operator. - -## operator_loc() [](#method-i-operator_loc) -Returns the location of the binary operator used to modify the receiver. This -method is deprecated in favor of #binary_operator_loc. - diff --git a/example/ruby/Prism/IndexWriteTest.md b/example/ruby/Prism/IndexWriteTest.md deleted file mode 100644 index 677f8f3..0000000 --- a/example/ruby/Prism/IndexWriteTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::IndexWriteTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_block_3_3() [](#method-i-test_block_3_3) - -## test_block_latest() [](#method-i-test_block_latest) - -## test_keywords_3_3() [](#method-i-test_keywords_3_3) - -## test_keywords_latest() [](#method-i-test_keywords_latest) - diff --git a/example/ruby/Prism/InlineComment.md b/example/ruby/Prism/InlineComment.md deleted file mode 100644 index 0c544c5..0000000 --- a/example/ruby/Prism/InlineComment.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::InlineComment -**Inherits:** Prism::Comment - - -InlineComment objects are the most common. They correspond to comments in the -source file like this one that start with #. - - - -#Instance Methods -## inspect() [](#method-i-inspect) -Returns a string representation of this comment. - -## trailing?() [](#method-i-trailing?) -Returns true if this comment happens on the same line as other code and false -if the comment is by itself. - -**@return** [Boolean] - diff --git a/example/ruby/Prism/InstanceVariableAndWriteNode.md b/example/ruby/Prism/InstanceVariableAndWriteNode.md deleted file mode 100644 index 7a52305..0000000 --- a/example/ruby/Prism/InstanceVariableAndWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::InstanceVariableAndWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/InstanceVariableOperatorWriteNode.md b/example/ruby/Prism/InstanceVariableOperatorWriteNode.md deleted file mode 100644 index 615bf4a..0000000 --- a/example/ruby/Prism/InstanceVariableOperatorWriteNode.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::InstanceVariableOperatorWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - -## operator() [](#method-i-operator) -Returns the binary operator used to modify the receiver. This method is -deprecated in favor of #binary_operator. - -## operator_loc() [](#method-i-operator_loc) -Returns the location of the binary operator used to modify the receiver. This -method is deprecated in favor of #binary_operator_loc. - diff --git a/example/ruby/Prism/InstanceVariableOrWriteNode.md b/example/ruby/Prism/InstanceVariableOrWriteNode.md deleted file mode 100644 index 5590b4e..0000000 --- a/example/ruby/Prism/InstanceVariableOrWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::InstanceVariableOrWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/IntegerBaseFlagsTest.md b/example/ruby/Prism/IntegerBaseFlagsTest.md deleted file mode 100644 index 4ffdce0..0000000 --- a/example/ruby/Prism/IntegerBaseFlagsTest.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Prism::IntegerBaseFlagsTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_flags() [](#method-i-test_flags) -Through some bit hackery, we want to allow consumers to use the integer base -flags as the base itself. It has a nice property that the current alignment -provides them in the correct order. So here we test that our assumption holds -so that it doesn't change out from under us. - -In C, this would look something like: - - ((flags & ~DECIMAL) >> 1) || 10 - -We have to do some other work in Ruby because 0 is truthy and ~ on an integer -doesn't have a fixed width. - diff --git a/example/ruby/Prism/IntegerParseTest.md b/example/ruby/Prism/IntegerParseTest.md deleted file mode 100644 index c0c7e57..0000000 --- a/example/ruby/Prism/IntegerParseTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::IntegerParseTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_integer_parse() [](#method-i-test_integer_parse) - diff --git a/example/ruby/Prism/InterpolatedMatchLastLineNode.md b/example/ruby/Prism/InterpolatedMatchLastLineNode.md deleted file mode 100644 index 7f8d16b..0000000 --- a/example/ruby/Prism/InterpolatedMatchLastLineNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::InterpolatedMatchLastLineNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/InterpolatedRegularExpressionNode.md b/example/ruby/Prism/InterpolatedRegularExpressionNode.md deleted file mode 100644 index c004e7e..0000000 --- a/example/ruby/Prism/InterpolatedRegularExpressionNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::InterpolatedRegularExpressionNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/InterpolatedStringNode.md b/example/ruby/Prism/InterpolatedStringNode.md deleted file mode 100644 index 3075e79..0000000 --- a/example/ruby/Prism/InterpolatedStringNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::InterpolatedStringNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/InterpolatedSymbolNode.md b/example/ruby/Prism/InterpolatedSymbolNode.md deleted file mode 100644 index 64c63f6..0000000 --- a/example/ruby/Prism/InterpolatedSymbolNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::InterpolatedSymbolNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/InterpolatedXStringNode.md b/example/ruby/Prism/InterpolatedXStringNode.md deleted file mode 100644 index 4d4cc97..0000000 --- a/example/ruby/Prism/InterpolatedXStringNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::InterpolatedXStringNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/LexCompat/EndContentToken.md b/example/ruby/Prism/LexCompat/EndContentToken.md deleted file mode 100644 index c1104ed..0000000 --- a/example/ruby/Prism/LexCompat/EndContentToken.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Prism::LexCompat::EndContentToken -**Inherits:** Prism::LexCompat::Token - - -Ripper doesn't include the rest of the token in the event, so we need to trim -it down to just the content on the first line when comparing. - - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - diff --git a/example/ruby/Prism/LexCompat/Heredoc/DashHeredoc.md b/example/ruby/Prism/LexCompat/Heredoc/DashHeredoc.md deleted file mode 100644 index 3fb0f66..0000000 --- a/example/ruby/Prism/LexCompat/Heredoc/DashHeredoc.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::LexCompat::Heredoc::DashHeredoc -**Inherits:** Object - - -Dash heredocs are a little more complicated. They are a list of tokens that -need to be split on "\\n" to mimic Ripper's behavior. We also need to keep -track of the state that the heredoc was opened in. - - -# Attributes -## split[RW] [](#attribute-i-split) -:nodoc: - -## tokens[RW] [](#attribute-i-tokens) -:nodoc: - - -#Instance Methods -## <<(token) [](#method-i-<<) - -## initialize(split) [](#method-i-initialize) - -**@return** [DashHeredoc] a new instance of DashHeredoc - -## to_a() [](#method-i-to_a) - diff --git a/example/ruby/Prism/LexCompat/Heredoc/DedentingHeredoc.md b/example/ruby/Prism/LexCompat/Heredoc/DedentingHeredoc.md deleted file mode 100644 index a644c90..0000000 --- a/example/ruby/Prism/LexCompat/Heredoc/DedentingHeredoc.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Prism::LexCompat::Heredoc::DedentingHeredoc -**Inherits:** Object - - -Heredocs that are dedenting heredocs are a little more complicated. Ripper -outputs on_ignored_sp tokens for the whitespace that is being removed from the -output. prism only modifies the node itself and keeps the token the same. This -simplifies prism, but makes comparing against Ripper much harder because there -is a length mismatch. - -Fortunately, we already have to pull out the heredoc tokens in order to insert -them into the stream in the correct order. As such, we can do some extra -manipulation on the tokens to make them match Ripper's output by mirroring the -dedent logic that Ripper uses. - - -# Attributes -## dedent[RW] [](#attribute-i-dedent) -Returns the value of attribute dedent. - -## dedent_next[RW] [](#attribute-i-dedent_next) -Returns the value of attribute dedent_next. - -## embexpr_balance[RW] [](#attribute-i-embexpr_balance) -Returns the value of attribute embexpr_balance. - -## tokens[RW] [](#attribute-i-tokens) -Returns the value of attribute tokens. - - -#Instance Methods -## <<(token) [](#method-i-<<) -As tokens are coming in, we track the minimum amount of common leading -whitespace on plain string content tokens. This allows us to later remove that -amount of whitespace from the beginning of each line. - -## initialize() [](#method-i-initialize) - -**@return** [DedentingHeredoc] a new instance of DedentingHeredoc - -## to_a() [](#method-i-to_a) - diff --git a/example/ruby/Prism/LexCompat/Heredoc/PlainHeredoc.md b/example/ruby/Prism/LexCompat/Heredoc/PlainHeredoc.md deleted file mode 100644 index 7e2ff98..0000000 --- a/example/ruby/Prism/LexCompat/Heredoc/PlainHeredoc.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Prism::LexCompat::Heredoc::PlainHeredoc -**Inherits:** Object - - -Heredocs that are no dash or tilde heredocs are just a list of tokens. We need -to keep them around so that we can insert them in the correct order back into -the token stream and set the state of the last token to the state that the -heredoc was opened in. - - -# Attributes -## tokens[RW] [](#attribute-i-tokens) -:nodoc: - - -#Instance Methods -## <<(token) [](#method-i-<<) - -## initialize() [](#method-i-initialize) - -**@return** [PlainHeredoc] a new instance of PlainHeredoc - -## to_a() [](#method-i-to_a) - diff --git a/example/ruby/Prism/LexCompat/IdentToken.md b/example/ruby/Prism/LexCompat/IdentToken.md deleted file mode 100644 index 17dfb24..0000000 --- a/example/ruby/Prism/LexCompat/IdentToken.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::LexCompat::IdentToken -**Inherits:** Prism::LexCompat::Token - - -Ident tokens for the most part are exactly the same, except sometimes we know -an ident is a local when ripper doesn't (when they are introduced through -named captures in regular expressions). In that case we don't compare the -state. - - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - diff --git a/example/ruby/Prism/LexCompat/IgnoreStateToken.md b/example/ruby/Prism/LexCompat/IgnoreStateToken.md deleted file mode 100644 index 36d5980..0000000 --- a/example/ruby/Prism/LexCompat/IgnoreStateToken.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Prism::LexCompat::IgnoreStateToken -**Inherits:** Prism::LexCompat::Token - - -Tokens where state should be ignored used for :on_comment, :on_heredoc_end, -:on_embexpr_end - - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - diff --git a/example/ruby/Prism/LexCompat/IgnoredNewlineToken.md b/example/ruby/Prism/LexCompat/IgnoredNewlineToken.md deleted file mode 100644 index 9b796e2..0000000 --- a/example/ruby/Prism/LexCompat/IgnoredNewlineToken.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Prism::LexCompat::IgnoredNewlineToken -**Inherits:** Prism::LexCompat::Token - - -Ignored newlines can occasionally have a LABEL state attached to them, so we -compare the state differently here. - - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - diff --git a/example/ruby/Prism/LexCompat/ParamToken.md b/example/ruby/Prism/LexCompat/ParamToken.md deleted file mode 100644 index 457ac12..0000000 --- a/example/ruby/Prism/LexCompat/ParamToken.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Prism::LexCompat::ParamToken -**Inherits:** Prism::LexCompat::Token - - -If we have an identifier that follows a method name like: - - def foo bar - -then Ripper will mark bar as END|LABEL if there is a local in a parent scope -named bar because it hasn't pushed the local table yet. We do this more -accurately, so we need to allow comparing against both END and END|LABEL. - - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - diff --git a/example/ruby/Prism/LexCompat/Result.md b/example/ruby/Prism/LexCompat/Result.md deleted file mode 100644 index db5f8db..0000000 --- a/example/ruby/Prism/LexCompat/Result.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Prism::LexCompat::Result -**Inherits:** Prism::Result - - -A result class specialized for holding tokens produced by the lexer. - - -# Attributes -## value[RW] [](#attribute-i-value) -The list of tokens that were produced by the lexer. - - -#Instance Methods -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for Result. - -## initialize(value, comments, magic_comments, data_loc, errors, warnings, source) [](#method-i-initialize) -Create a new lex compat result object with the given values. - -**@return** [Result] a new instance of Result - diff --git a/example/ruby/Prism/LexCompat/Token.md b/example/ruby/Prism/LexCompat/Token.md deleted file mode 100644 index 15fc649..0000000 --- a/example/ruby/Prism/LexCompat/Token.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Prism::LexCompat::Token -**Inherits:** SimpleDelegator - - -When we produce tokens, we produce the same arrays that Ripper does. However, -we add a couple of convenience methods onto them to make them a little easier -to work with. We delegate all other methods to the array. - - - -#Instance Methods -## event() [](#method-i-event) -The type of the token. - -## location() [](#method-i-location) -The location of the token in the source. - -## state() [](#method-i-state) -The state of the lexer when this token was produced. - -## value() [](#method-i-value) -The slice of the source that this token represents. - diff --git a/example/ruby/Prism/LexResult.md b/example/ruby/Prism/LexResult.md deleted file mode 100644 index 1351617..0000000 --- a/example/ruby/Prism/LexResult.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Prism::LexResult -**Inherits:** Prism::Result - - -This is a result specific to the `lex` and `lex_file` methods. - - -# Attributes -## value[RW] [](#attribute-i-value) -The list of tokens that were parsed from the source code. - - -#Instance Methods -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for LexResult. - -## initialize(value, comments, magic_comments, data_loc, errors, warnings, source) [](#method-i-initialize) -Create a new lex result object with the given values. - -**@return** [LexResult] a new instance of LexResult - diff --git a/example/ruby/Prism/LexTest.md b/example/ruby/Prism/LexTest.md deleted file mode 100644 index 51f5f6c..0000000 --- a/example/ruby/Prism/LexTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Prism::LexTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_lex_file() [](#method-i-test_lex_file) - -## test_lex_result() [](#method-i-test_lex_result) - -## test_parse_lex() [](#method-i-test_parse_lex) - -## test_parse_lex_file() [](#method-i-test_parse_lex_file) - -## test_parse_lex_result() [](#method-i-test_parse_lex_result) - diff --git a/example/ruby/Prism/LibRubyParser/PrismBuffer.md b/example/ruby/Prism/LibRubyParser/PrismBuffer.md deleted file mode 100644 index ff838f3..0000000 --- a/example/ruby/Prism/LibRubyParser/PrismBuffer.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Prism::LibRubyParser::PrismBuffer -**Inherits:** Object - - -This object represents a pm_buffer_t. We only use it as an opaque pointer, so -it doesn't need to know the fields of pm_buffer_t. - - -# Class Methods -## with() [](#method-c-with) -Initialize a new buffer and yield it to the block. The buffer will be -automatically freed when the block returns. -# Attributes -## pointer[RW] [](#attribute-i-pointer) -Returns the value of attribute pointer. - - -#Instance Methods -## initialize(pointer) [](#method-i-initialize) - -**@return** [PrismBuffer] a new instance of PrismBuffer - -## length() [](#method-i-length) - -## read() [](#method-i-read) - -## value() [](#method-i-value) - diff --git a/example/ruby/Prism/LibRubyParser/PrismString.md b/example/ruby/Prism/LibRubyParser/PrismString.md deleted file mode 100644 index 32c3450..0000000 --- a/example/ruby/Prism/LibRubyParser/PrismString.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Prism::LibRubyParser::PrismString -**Inherits:** Object - - -This object represents a pm_string_t. We only use it as an opaque pointer, so -it doesn't have to be an FFI::Struct. - - -# Class Methods -## with_file(filepath ) [](#method-c-with_file) -Yields a pm_string_t pointer to the given block. -**@raise** [TypeError] - -## with_string(string ) [](#method-c-with_string) -Yields a pm_string_t pointer to the given block. -**@raise** [TypeError] - -# Attributes -## length[RW] [](#attribute-i-length) -Returns the value of attribute length. - -## pointer[RW] [](#attribute-i-pointer) -Returns the value of attribute pointer. - - -#Instance Methods -## initialize(pointer, length, from_string) [](#method-i-initialize) - -**@return** [PrismString] a new instance of PrismString - -## read() [](#method-i-read) - diff --git a/example/ruby/Prism/LibrarySymbolsTest.md b/example/ruby/Prism/LibrarySymbolsTest.md deleted file mode 100644 index f86cb73..0000000 --- a/example/ruby/Prism/LibrarySymbolsTest.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: Prism::LibrarySymbolsTest -**Inherits:** Prism::TestCase - - -examine a prism dll or static archive for expected external symbols. - these tests only work on a linux system right now. - - - -#Instance Methods -## global_nm_symbols(path) [](#method-i-global_nm_symbols) - -## global_objdump_symbols(path) [](#method-i-global_objdump_symbols) - -## hidden_global_objdump_symbols(path) [](#method-i-hidden_global_objdump_symbols) - -## local_nm_symbols(path) [](#method-i-local_nm_symbols) - -## names(symbol_lines) [](#method-i-names) -dig the symbol name out of each line. works for both `objdump` and `nm` -output. - -## nm(path) [](#method-i-nm) -nm runner and helpers - -## objdump(path) [](#method-i-objdump) -objdump runner and helpers - -## setup() [](#method-i-setup) - -## test_libprism_a_contains_hidden_pm_symbols() [](#method-i-test_libprism_a_contains_hidden_pm_symbols) - -## test_libprism_a_contains_nothing_globally_visible() [](#method-i-test_libprism_a_contains_nothing_globally_visible) -static archive - libprism.a - -## test_libprism_so_exports_only_the_necessary_functions() [](#method-i-test_libprism_so_exports_only_the_necessary_functions) -shared object - libprism.so - -## test_prism_so_exports_only_the_C_extension_init_function() [](#method-i-test_prism_so_exports_only_the_C_extension_init_function) -shared object - prism.so - -## visible_global_objdump_symbols(path) [](#method-i-visible_global_objdump_symbols) - diff --git a/example/ruby/Prism/LocalVariableAndWriteNode.md b/example/ruby/Prism/LocalVariableAndWriteNode.md deleted file mode 100644 index a931572..0000000 --- a/example/ruby/Prism/LocalVariableAndWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::LocalVariableAndWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/LocalVariableOperatorWriteNode.md b/example/ruby/Prism/LocalVariableOperatorWriteNode.md deleted file mode 100644 index da77e77..0000000 --- a/example/ruby/Prism/LocalVariableOperatorWriteNode.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::LocalVariableOperatorWriteNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - -## operator() [](#method-i-operator) -Returns the binary operator used to modify the receiver. This method is -deprecated in favor of #binary_operator. - -## operator_loc() [](#method-i-operator_loc) -Returns the location of the binary operator used to modify the receiver. This -method is deprecated in favor of #binary_operator_loc. - diff --git a/example/ruby/Prism/LocalVariableOrWriteNode.md b/example/ruby/Prism/LocalVariableOrWriteNode.md deleted file mode 100644 index 37c50be..0000000 --- a/example/ruby/Prism/LocalVariableOrWriteNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::LocalVariableOrWriteNode -**Inherits:** Object - - - - - -#Instance Methods -## desugar() [](#method-i-desugar) -:nodoc: - diff --git a/example/ruby/Prism/LocalsTest.md b/example/ruby/Prism/LocalsTest.md deleted file mode 100644 index dd8753e..0000000 --- a/example/ruby/Prism/LocalsTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::LocalsTest -**Inherits:** TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/Prism/LocalsTest/ISeq.md b/example/ruby/Prism/LocalsTest/ISeq.md deleted file mode 100644 index 5b3a5bc..0000000 --- a/example/ruby/Prism/LocalsTest/ISeq.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::LocalsTest::ISeq -**Inherits:** Object - - -A wrapper around a RubyVM::InstructionSequence that provides a more convenient -interface for accessing parts of the iseq. - - -# Attributes -## parts[RW] [](#attribute-i-parts) -Returns the value of attribute parts. - - -#Instance Methods -## each_child() [](#method-i-each_child) - -## initialize(parts) [](#method-i-initialize) - -**@return** [ISeq] a new instance of ISeq - -## instructions() [](#method-i-instructions) - -## local_table() [](#method-i-local_table) - -## type() [](#method-i-type) - diff --git a/example/ruby/Prism/Location.md b/example/ruby/Prism/Location.md deleted file mode 100644 index 56674ac..0000000 --- a/example/ruby/Prism/Location.md +++ /dev/null @@ -1,145 +0,0 @@ -# Class: Prism::Location -**Inherits:** Object - - -This represents a location in the source. - - -# Attributes -## length[RW] [](#attribute-i-length) -The length of this location in bytes. - -## start_offset[RW] [](#attribute-i-start_offset) -The byte offset from the beginning of the source where this location starts. - - -#Instance Methods -## ==(other) [](#method-i-==) -Returns true if the given other location is equal to this location. - -## adjoin(string) [](#method-i-adjoin) -Join this location with the first occurrence of the string in the source that -occurs after this location on the same line, and return the new location. This -will raise an error if the string does not exist. - -## cached_end_code_units_column(cache) [](#method-i-cached_end_code_units_column) -The end column in code units using the given cache to fetch or calculate the -value. - -## cached_end_code_units_offset(cache) [](#method-i-cached_end_code_units_offset) -The end offset from the start of the file in code units using the given cache -to fetch or calculate the value. - -## cached_start_code_units_column(cache) [](#method-i-cached_start_code_units_column) -The start column in code units using the given cache to fetch or calculate the -value. - -## cached_start_code_units_offset(cache) [](#method-i-cached_start_code_units_offset) -The start offset from the start of the file in code units using the given -cache to fetch or calculate the value. - -## chop() [](#method-i-chop) -Returns a new location that is the result of chopping off the last byte. - -## comments() [](#method-i-comments) -Returns all comments that are associated with this location (both leading and -trailing comments). - -## copy(source:self.source, start_offset:self.start_offset, length:self.length) [](#method-i-copy) -Create a new location object with the given options. - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for Location. - -## end_character_column() [](#method-i-end_character_column) -The column number in characters where this location ends from the start of the -line. - -## end_character_offset() [](#method-i-end_character_offset) -The character offset from the beginning of the source where this location -ends. - -## end_code_units_column(encodingEncoding::UTF_16LE) [](#method-i-end_code_units_column) -The column number in code units of the given encoding where this location ends -from the start of the line. - -## end_code_units_offset(encodingEncoding::UTF_16LE) [](#method-i-end_code_units_offset) -The offset from the start of the file in code units of the given encoding. - -## end_column() [](#method-i-end_column) -The column number in bytes where this location ends from the start of the -line. - -## end_line() [](#method-i-end_line) -The line number where this location ends. - -## end_offset() [](#method-i-end_offset) -The byte offset from the beginning of the source where this location ends. - -## initialize(source, start_offset, length) [](#method-i-initialize) -Create a new location object with the given source, start byte offset, and -byte length. - -**@return** [Location] a new instance of Location - -## inspect() [](#method-i-inspect) -Returns a string representation of this location. - -## join(other) [](#method-i-join) -Returns a new location that stretches from this location to the given other -location. Raises an error if this location is not before the other location or -if they don't share the same source. - -## leading_comment(comment) [](#method-i-leading_comment) -Attach a comment to the leading comments of this location. - -## leading_comments() [](#method-i-leading_comments) -These are the comments that are associated with this location that exist -before the start of this location. - -## pretty_print(q) [](#method-i-pretty_print) -Implement the pretty print interface for Location. - -## slice() [](#method-i-slice) -The source code that this location represents. - -## slice_lines() [](#method-i-slice_lines) -The source code that this location represents starting from the beginning of -the line that this location starts on to the end of the line that this -location ends on. - -## source_lines() [](#method-i-source_lines) -Returns all of the lines of the source code associated with this location. - -## start_character_column() [](#method-i-start_character_column) -The column number in characters where this location ends from the start of the -line. - -## start_character_offset() [](#method-i-start_character_offset) -The character offset from the beginning of the source where this location -starts. - -## start_code_units_column(encodingEncoding::UTF_16LE) [](#method-i-start_code_units_column) -The column number in code units of the given encoding where this location -starts from the start of the line. - -## start_code_units_offset(encodingEncoding::UTF_16LE) [](#method-i-start_code_units_offset) -The offset from the start of the file in code units of the given encoding. - -## start_column() [](#method-i-start_column) -The column number in bytes where this location starts from the start of the -line. - -## start_line() [](#method-i-start_line) -The line number where this location starts. - -## start_line_slice() [](#method-i-start_line_slice) -The content of the line where this location starts before this location. - -## trailing_comment(comment) [](#method-i-trailing_comment) -Attach a comment to the trailing comments of this location. - -## trailing_comments() [](#method-i-trailing_comments) -These are the comments that are associated with this location that exist after -the end of this location. - diff --git a/example/ruby/Prism/LocationTest.md b/example/ruby/Prism/LocationTest.md deleted file mode 100644 index 7fe22ca..0000000 --- a/example/ruby/Prism/LocationTest.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::LocationTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_adjoin() [](#method-i-test_adjoin) - -## test_cached_code_units() [](#method-i-test_cached_code_units) - -## test_character_offsets() [](#method-i-test_character_offsets) - -## test_chop() [](#method-i-test_chop) - -## test_code_units() [](#method-i-test_code_units) - -## test_code_units_binary_invalid_utf8() [](#method-i-test_code_units_binary_invalid_utf8) - -## test_code_units_binary_valid_utf8() [](#method-i-test_code_units_binary_valid_utf8) - -## test_join() [](#method-i-test_join) - -## test_slice_lines() [](#method-i-test_slice_lines) - diff --git a/example/ruby/Prism/MagicComment.md b/example/ruby/Prism/MagicComment.md deleted file mode 100644 index 48ceec9..0000000 --- a/example/ruby/Prism/MagicComment.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Prism::MagicComment -**Inherits:** Object - - -This represents a magic comment that was encountered during parsing. - - -# Attributes -## key_loc[RW] [](#attribute-i-key_loc) -A Location object representing the location of the key in the source. - -## value_loc[RW] [](#attribute-i-value_loc) -A Location object representing the location of the value in the source. - - -#Instance Methods -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for MagicComment. - -## initialize(key_loc, value_loc) [](#method-i-initialize) -Create a new magic comment object with the given key and value locations. - -**@return** [MagicComment] a new instance of MagicComment - -## inspect() [](#method-i-inspect) -Returns a string representation of this magic comment. - -## key() [](#method-i-key) -Returns the key of the magic comment by slicing it from the source code. - -## value() [](#method-i-value) -Returns the value of the magic comment by slicing it from the source code. - diff --git a/example/ruby/Prism/MagicCommentTest.md b/example/ruby/Prism/MagicCommentTest.md deleted file mode 100644 index 5a942a0..0000000 --- a/example/ruby/Prism/MagicCommentTest.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Prism::MagicCommentTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_CoDiNg() [](#method-i-test_CoDiNg) - -## test_coding() [](#method-i-test_coding) - -## test_coding_whitespace() [](#method-i-test_coding_whitespace) - -## test_eNcOdInG() [](#method-i-test_eNcOdInG) - -## test_emacs_CoDiNg() [](#method-i-test_emacs_CoDiNg) - -## test_emacs_coding() [](#method-i-test_emacs_coding) - -## test_emacs_eNcOdInG() [](#method-i-test_emacs_eNcOdInG) - -## test_emacs_encoding() [](#method-i-test_emacs_encoding) - -## test_emacs_multiple() [](#method-i-test_emacs_multiple) - -## test_emacs_whitespace() [](#method-i-test_emacs_whitespace) - -## test_encoding() [](#method-i-test_encoding) - -## test_encoding_whitespace() [](#method-i-test_encoding_whitespace) - -## test_vim() [](#method-i-test_vim) - diff --git a/example/ruby/Prism/MagicCommentTest/MagicCommentRipper.md b/example/ruby/Prism/MagicCommentTest/MagicCommentRipper.md deleted file mode 100644 index 17b759c..0000000 --- a/example/ruby/Prism/MagicCommentTest/MagicCommentRipper.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Prism::MagicCommentTest::MagicCommentRipper -**Inherits:** Ripper - - - - -# Attributes -## magic_comments[RW] [](#attribute-i-magic_comments) -Returns the value of attribute magic_comments. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MagicCommentRipper] a new instance of MagicCommentRipper - -## on_magic_comment(key, value) [](#method-i-on_magic_comment) - diff --git a/example/ruby/Prism/MatchLastLineNode.md b/example/ruby/Prism/MatchLastLineNode.md deleted file mode 100644 index 8ae3ec7..0000000 --- a/example/ruby/Prism/MatchLastLineNode.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::MatchLastLineNode -**Inherits:** Prism::Node - - - - - diff --git a/example/ruby/Prism/NewlineOffsetsTest.md b/example/ruby/Prism/NewlineOffsetsTest.md deleted file mode 100644 index aded9c1..0000000 --- a/example/ruby/Prism/NewlineOffsetsTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::NewlineOffsetsTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/NewlineTest.md b/example/ruby/Prism/NewlineTest.md deleted file mode 100644 index 85c697e..0000000 --- a/example/ruby/Prism/NewlineTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::NewlineTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/Node.md b/example/ruby/Prism/Node.md deleted file mode 100644 index c2fa0ea..0000000 --- a/example/ruby/Prism/Node.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::Node -**Inherits:** Object - - - - - -#Instance Methods -## deprecated(*replacements) [](#method-i-deprecated) -:nodoc: - -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - -## newline_flag?() [](#method-i-newline_flag?) -:nodoc: - -**@return** [Boolean] - diff --git a/example/ruby/Prism/NodeIdTest.md b/example/ruby/Prism/NodeIdTest.md deleted file mode 100644 index e0ec006..0000000 --- a/example/ruby/Prism/NodeIdTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::NodeIdTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/NumericValueTest.md b/example/ruby/Prism/NumericValueTest.md deleted file mode 100644 index f55267d..0000000 --- a/example/ruby/Prism/NumericValueTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::NumericValueTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_numeric_value() [](#method-i-test_numeric_value) - diff --git a/example/ruby/Prism/OnigmoTest.md b/example/ruby/Prism/OnigmoTest.md deleted file mode 100644 index 81cebe9..0000000 --- a/example/ruby/Prism/OnigmoTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Prism::OnigmoTest -**Inherits:** TestCase - - - - - -#Instance Methods -## test_ONIGERR_EMPTY_CHAR_CLASS() [](#method-i-test_ONIGERR_EMPTY_CHAR_CLASS) - -## test_ONIGERR_EMPTY_GROUP_NAME() [](#method-i-test_ONIGERR_EMPTY_GROUP_NAME) - -## test_ONIGERR_END_PATTERN_IN_GROUP() [](#method-i-test_ONIGERR_END_PATTERN_IN_GROUP) - -## test_ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS() [](#method-i-test_ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS) - -## test_ONIGERR_PARSE_DEPTH_LIMIT_OVER() [](#method-i-test_ONIGERR_PARSE_DEPTH_LIMIT_OVER) - -## test_ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED() [](#method-i-test_ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED) - -## test_ONIGERR_UNDEFINED_GROUP_OPTION() [](#method-i-test_ONIGERR_UNDEFINED_GROUP_OPTION) - -## test_ONIGERR_UNMATCHED_CLOSE_PARENTHESIS() [](#method-i-test_ONIGERR_UNMATCHED_CLOSE_PARENTHESIS) - diff --git a/example/ruby/Prism/OverlapTest.md b/example/ruby/Prism/OverlapTest.md deleted file mode 100644 index a2981e1..0000000 --- a/example/ruby/Prism/OverlapTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::OverlapTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/Pack.md b/example/ruby/Prism/Pack.md deleted file mode 100644 index 347c7c4..0000000 --- a/example/ruby/Prism/Pack.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Prism::Pack - - -A parser for the pack template language. - - -# Class Methods -## parse(version_symbol , variant_symbol , format_string ) [](#method-c-parse) -Parse the given source and return a format object. -**@overload** [] - - diff --git a/example/ruby/Prism/Pack/Directive.md b/example/ruby/Prism/Pack/Directive.md deleted file mode 100644 index a03e1f1..0000000 --- a/example/ruby/Prism/Pack/Directive.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: Prism::Pack::Directive -**Inherits:** Object - - -A directive in the pack template language. - - -# Attributes -## endian[RW] [](#attribute-i-endian) -The type of endianness of the directive. - -## length[RW] [](#attribute-i-length) -The length of this directive (used for integers). - -## length_type[RW] [](#attribute-i-length_type) -The length type of this directive (used for integers). - -## signed[RW] [](#attribute-i-signed) -The type of signedness of the directive. - -## size[RW] [](#attribute-i-size) -The size of the directive. - -## source[RW] [](#attribute-i-source) -A byteslice of the source string that this directive represents. - -## type[RW] [](#attribute-i-type) -The type of the directive. - -## variant[RW] [](#attribute-i-variant) -A symbol representing whether or not we are packing or unpacking. - -## version[RW] [](#attribute-i-version) -A symbol representing the version of Ruby. - - -#Instance Methods -## describe() [](#method-i-describe) -Provide a human-readable description of the directive. - -## initialize(version, variant, source, type, signed, endian, size, length_type, length) [](#method-i-initialize) -Initialize a new directive with the given values. - -**@return** [Directive] a new instance of Directive - diff --git a/example/ruby/Prism/Pack/Format.md b/example/ruby/Prism/Pack/Format.md deleted file mode 100644 index 539b03c..0000000 --- a/example/ruby/Prism/Pack/Format.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Prism::Pack::Format -**Inherits:** Object - - -The result of parsing a pack template. - - -# Attributes -## directives[RW] [](#attribute-i-directives) -A list of the directives in the template. - -## encoding[RW] [](#attribute-i-encoding) -The encoding of the template. - - -#Instance Methods -## describe() [](#method-i-describe) -Provide a human-readable description of the format. - -## initialize(directives, encoding) [](#method-i-initialize) -Create a new Format with the given directives and encoding. - -**@return** [Format] a new instance of Format - diff --git a/example/ruby/Prism/ParametersNode.md b/example/ruby/Prism/ParametersNode.md deleted file mode 100644 index eb14370..0000000 --- a/example/ruby/Prism/ParametersNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::ParametersNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## signature() [](#method-i-signature) -Mirrors the Method#parameters method. - diff --git a/example/ruby/Prism/ParametersSignatureTest.md b/example/ruby/Prism/ParametersSignatureTest.md deleted file mode 100644 index efb8b00..0000000 --- a/example/ruby/Prism/ParametersSignatureTest.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Prism::ParametersSignatureTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_block() [](#method-i-test_block) - -## test_block_anonymous() [](#method-i-test_block_anonymous) - -## test_forwarding() [](#method-i-test_forwarding) - -## test_key() [](#method-i-test_key) - -## test_key_ordering() [](#method-i-test_key_ordering) - -## test_keyreq() [](#method-i-test_keyreq) - -## test_keyrest() [](#method-i-test_keyrest) - -## test_keyrest_anonymous() [](#method-i-test_keyrest_anonymous) - -## test_nokey() [](#method-i-test_nokey) - -## test_opt() [](#method-i-test_opt) - -## test_post() [](#method-i-test_post) - -## test_post_destructure() [](#method-i-test_post_destructure) - -## test_req() [](#method-i-test_req) - -## test_req_destructure() [](#method-i-test_req_destructure) - -## test_rest() [](#method-i-test_rest) - -## test_rest_anonymous() [](#method-i-test_rest_anonymous) - diff --git a/example/ruby/Prism/ParenthesesNode.md b/example/ruby/Prism/ParenthesesNode.md deleted file mode 100644 index 3ee8f21..0000000 --- a/example/ruby/Prism/ParenthesesNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::ParenthesesNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/ParseCommentsTest.md b/example/ruby/Prism/ParseCommentsTest.md deleted file mode 100644 index 5dd7a1a..0000000 --- a/example/ruby/Prism/ParseCommentsTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Prism::ParseCommentsTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_parse_comments() [](#method-i-test_parse_comments) - -## test_parse_file_comments() [](#method-i-test_parse_file_comments) - -## test_parse_file_comments_error() [](#method-i-test_parse_file_comments_error) - diff --git a/example/ruby/Prism/ParseError.md b/example/ruby/Prism/ParseError.md deleted file mode 100644 index 5d1a5af..0000000 --- a/example/ruby/Prism/ParseError.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Prism::ParseError -**Inherits:** Object - - -This represents an error that was encountered during parsing. - - -# Attributes -## level[RW] [](#attribute-i-level) -The level of this error. - -## location[RW] [](#attribute-i-location) -A Location object representing the location of this error in the source. - -## message[RW] [](#attribute-i-message) -The message associated with this error. - -## type[RW] [](#attribute-i-type) -The type of error. This is an *internal* symbol that is used for communicating -with translation layers. It is not meant to be public API. - - -#Instance Methods -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for ParseError. - -## initialize(type, message, location, level) [](#method-i-initialize) -Create a new error object with the given message and location. - -**@return** [ParseError] a new instance of ParseError - -## inspect() [](#method-i-inspect) -Returns a string representation of this error. - diff --git a/example/ruby/Prism/ParseLexResult.md b/example/ruby/Prism/ParseLexResult.md deleted file mode 100644 index 42e0448..0000000 --- a/example/ruby/Prism/ParseLexResult.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Prism::ParseLexResult -**Inherits:** Prism::Result - - -This is a result specific to the `parse_lex` and `parse_lex_file` methods. - - -# Attributes -## value[RW] [](#attribute-i-value) -A tuple of the syntax tree and the list of tokens that were parsed from the -source code. - - -#Instance Methods -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for ParseLexResult. - -## initialize(value, comments, magic_comments, data_loc, errors, warnings, source) [](#method-i-initialize) -Create a new parse lex result object with the given values. - -**@return** [ParseLexResult] a new instance of ParseLexResult - diff --git a/example/ruby/Prism/ParseResult.md b/example/ruby/Prism/ParseResult.md deleted file mode 100644 index 6d581cc..0000000 --- a/example/ruby/Prism/ParseResult.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Prism::ParseResult -**Inherits:** Prism::Result - - -This is a result specific to the `parse` and `parse_file` methods. - - -# Attributes -## value[RW] [](#attribute-i-value) -The syntax tree that was parsed from the source code. - - -#Instance Methods -## attach_comments!() [](#method-i-attach_comments!) -Attach the list of comments to their respective locations in the tree. - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for ParseResult. - -## errors_format() [](#method-i-errors_format) -Returns a string representation of the syntax tree with the errors displayed -inline. - -## initialize(value, comments, magic_comments, data_loc, errors, warnings, source) [](#method-i-initialize) -Create a new parse result object with the given values. - -**@return** [ParseResult] a new instance of ParseResult - -## mark_newlines!() [](#method-i-mark_newlines!) -Walk the tree and mark nodes that are on a new line, loosely emulating the -behavior of CRuby's `:line` tracepoint event. - -## statement() [](#method-i-statement) -Returns the first statement in the body of the parsed source. - diff --git a/example/ruby/Prism/ParseResult/Comments/LocationTarget.md b/example/ruby/Prism/ParseResult/Comments/LocationTarget.md deleted file mode 100644 index 71e96e4..0000000 --- a/example/ruby/Prism/ParseResult/Comments/LocationTarget.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Prism::ParseResult::Comments::LocationTarget -**Inherits:** Object - - -A target for attaching comments that is based on a location field on a node. -For example, the `end` token of a ClassNode. - - -# Attributes -## location[RW] [](#attribute-i-location) -:nodoc: - - -#Instance Methods -## encloses?(comment) [](#method-i-encloses?) - -**@return** [Boolean] - -## end_offset() [](#method-i-end_offset) - -## initialize(location) [](#method-i-initialize) - -**@return** [LocationTarget] a new instance of LocationTarget - -## leading_comment(comment) [](#method-i-leading_comment) - -## start_offset() [](#method-i-start_offset) - -## trailing_comment(comment) [](#method-i-trailing_comment) - diff --git a/example/ruby/Prism/ParseResult/Comments/NodeTarget.md b/example/ruby/Prism/ParseResult/Comments/NodeTarget.md deleted file mode 100644 index 46a5728..0000000 --- a/example/ruby/Prism/ParseResult/Comments/NodeTarget.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Prism::ParseResult::Comments::NodeTarget -**Inherits:** Object - - -A target for attaching comments that is based on a specific node's location. - - -# Attributes -## node[RW] [](#attribute-i-node) -:nodoc: - - -#Instance Methods -## encloses?(comment) [](#method-i-encloses?) - -**@return** [Boolean] - -## end_offset() [](#method-i-end_offset) - -## initialize(node) [](#method-i-initialize) - -**@return** [NodeTarget] a new instance of NodeTarget - -## leading_comment(comment) [](#method-i-leading_comment) - -## start_offset() [](#method-i-start_offset) - -## trailing_comment(comment) [](#method-i-trailing_comment) - diff --git a/example/ruby/Prism/ParseStreamTest.md b/example/ruby/Prism/ParseStreamTest.md deleted file mode 100644 index 29db93d..0000000 --- a/example/ruby/Prism/ParseStreamTest.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::ParseStreamTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test___END__() [](#method-i-test___END__) - -## test_false___END___in_heredoc() [](#method-i-test_false___END___in_heredoc) - -## test_false___END___in_list() [](#method-i-test_false___END___in_list) - -## test_false___END___in_regexp() [](#method-i-test_false___END___in_regexp) - -## test_false___END___in_string() [](#method-i-test_false___END___in_string) - -## test_multi_line() [](#method-i-test_multi_line) - -## test_multi_read() [](#method-i-test_multi_read) - -## test_nul_bytes() [](#method-i-test_nul_bytes) - -## test_single_line() [](#method-i-test_single_line) - diff --git a/example/ruby/Prism/ParseSuccessTest.md b/example/ruby/Prism/ParseSuccessTest.md deleted file mode 100644 index 7aa3196..0000000 --- a/example/ruby/Prism/ParseSuccessTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::ParseSuccessTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_parse_file_success?() [](#method-i-test_parse_file_success?) - -**@return** [Boolean] - -## test_parse_success?() [](#method-i-test_parse_success?) - -**@return** [Boolean] - diff --git a/example/ruby/Prism/ParseTest.md b/example/ruby/Prism/ParseTest.md deleted file mode 100644 index 77adc05..0000000 --- a/example/ruby/Prism/ParseTest.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Prism::ParseTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_parse_directory() [](#method-i-test_parse_directory) - -## test_parse_empty_string() [](#method-i-test_parse_empty_string) - -## test_parse_file() [](#method-i-test_parse_file) - -## test_parse_nonascii() [](#method-i-test_parse_nonascii) - -## test_parse_result() [](#method-i-test_parse_result) - -## test_parse_takes_file_path() [](#method-i-test_parse_takes_file_path) - -## test_parse_takes_line() [](#method-i-test_parse_takes_line) - -## test_parse_takes_negative_lines() [](#method-i-test_parse_takes_negative_lines) - -## test_parse_tempfile() [](#method-i-test_parse_tempfile) - -## test_partial_script() [](#method-i-test_partial_script) - -## test_version() [](#method-i-test_version) - diff --git a/example/ruby/Prism/ParseWarning.md b/example/ruby/Prism/ParseWarning.md deleted file mode 100644 index 3fb3476..0000000 --- a/example/ruby/Prism/ParseWarning.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Prism::ParseWarning -**Inherits:** Object - - -This represents a warning that was encountered during parsing. - - -# Attributes -## level[RW] [](#attribute-i-level) -The level of this warning. - -## location[RW] [](#attribute-i-location) -A Location object representing the location of this warning in the source. - -## message[RW] [](#attribute-i-message) -The message associated with this warning. - -## type[RW] [](#attribute-i-type) -The type of warning. This is an *internal* symbol that is used for -communicating with translation layers. It is not meant to be public API. - - -#Instance Methods -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for ParseWarning. - -## initialize(type, message, location, level) [](#method-i-initialize) -Create a new warning object with the given message and location. - -**@return** [ParseWarning] a new instance of ParseWarning - -## inspect() [](#method-i-inspect) -Returns a string representation of this warning. - diff --git a/example/ruby/Prism/ParserTest.md b/example/ruby/Prism/ParserTest.md deleted file mode 100644 index cc74505..0000000 --- a/example/ruby/Prism/ParserTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::ParserTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/Pattern.md b/example/ruby/Prism/Pattern.md deleted file mode 100644 index d09edd9..0000000 --- a/example/ruby/Prism/Pattern.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: Prism::Pattern -**Inherits:** Object - - -A pattern is an object that wraps a Ruby pattern matching expression. The -expression would normally be passed to an `in` clause within a `case` -expression or a rightward assignment expression. For example, in the following -snippet: - - case node - in ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]] - end - -the pattern is the `ConstantPathNode[...]` expression. - -The pattern gets compiled into an object that responds to #call by running the -#compile method. This method itself will run back through Prism to parse the -expression into a tree, then walk the tree to generate the necessary callable -objects. For example, if you wanted to compile the expression above into a -callable, you would: - - callable = Prism::Pattern.new("ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]").compile - callable.call(node) - -The callable object returned by #compile is guaranteed to respond to #call -with a single argument, which is the node to match against. It also is -guaranteed to respond to #===, which means it itself can be used in a `case` -expression, as in: - - case node - when callable - end - -If the query given to the initializer cannot be compiled into a valid matcher -(either because of a syntax error or because it is using syntax we do not yet -support) then a Prism::Pattern::CompilationError will be raised. - - -# Attributes -## query[RW] [](#attribute-i-query) -The query that this pattern was initialized with. - - -#Instance Methods -## compile() [](#method-i-compile) -Compile the query into a callable object that can be used to match against -nodes. - -**@raise** [CompilationError] - -## initialize(query) [](#method-i-initialize) -Create a new pattern with the given query. The query should be a string -containing a Ruby pattern matching expression. - -**@return** [Pattern] a new instance of Pattern - -## scan(root) [](#method-i-scan) -Scan the given node and all of its children for nodes that match the pattern. -If a block is given, it will be called with each node that matches the -pattern. If no block is given, an enumerator will be returned that will yield -each node that matches the pattern. - diff --git a/example/ruby/Prism/Pattern/CompilationError.md b/example/ruby/Prism/Pattern/CompilationError.md deleted file mode 100644 index 3023f15..0000000 --- a/example/ruby/Prism/Pattern/CompilationError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Prism::Pattern::CompilationError -**Inherits:** StandardError - - -Raised when the query given to a pattern is either invalid Ruby syntax or is -using syntax that we don't yet support. - - - -#Instance Methods -## initialize(repr) [](#method-i-initialize) -Create a new CompilationError with the given representation of the node that -caused the error. - -**@return** [CompilationError] a new instance of CompilationError - diff --git a/example/ruby/Prism/PatternTest.md b/example/ruby/Prism/PatternTest.md deleted file mode 100644 index 0a89f89..0000000 --- a/example/ruby/Prism/PatternTest.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: Prism::PatternTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_alternation_pattern() [](#method-i-test_alternation_pattern) - -## test_array_pattern() [](#method-i-test_array_pattern) - -## test_array_pattern_no_constant() [](#method-i-test_array_pattern_no_constant) - -## test_constant_path() [](#method-i-test_constant_path) - -## test_constant_read_node() [](#method-i-test_constant_read_node) - -## test_hash_pattern_no_constant() [](#method-i-test_hash_pattern_no_constant) - -## test_hash_pattern_regexp() [](#method-i-test_hash_pattern_regexp) - -## test_invalid_constant() [](#method-i-test_invalid_constant) - -## test_invalid_nested_constant() [](#method-i-test_invalid_nested_constant) - -## test_invalid_node() [](#method-i-test_invalid_node) - -## test_invalid_syntax() [](#method-i-test_invalid_syntax) - -## test_nil() [](#method-i-test_nil) - -## test_object_const() [](#method-i-test_object_const) - -## test_regexp_options() [](#method-i-test_regexp_options) - -## test_regexp_with_interpolation() [](#method-i-test_regexp_with_interpolation) - -## test_self() [](#method-i-test_self) - -## test_string_empty() [](#method-i-test_string_empty) - -## test_string_with_interpolation() [](#method-i-test_string_with_interpolation) - -## test_symbol() [](#method-i-test_symbol) - -## test_symbol_empty() [](#method-i-test_symbol_empty) - -## test_symbol_plain() [](#method-i-test_symbol_plain) - -## test_symbol_with_interpolation() [](#method-i-test_symbol_with_interpolation) - diff --git a/example/ruby/Prism/PercentDelimiterRegexpTest.md b/example/ruby/Prism/PercentDelimiterRegexpTest.md deleted file mode 100644 index cdfdd3e..0000000 --- a/example/ruby/Prism/PercentDelimiterRegexpTest.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Prism::PercentDelimiterRegexpTest -**Inherits:** Prism::TestCase - -**Includes:** Prism::PercentDelimiterTests - - - - - -#Instance Methods -## assert_parse(expected, str) [](#method-i-assert_parse) - -## find_node(str) [](#method-i-find_node) - -## l(str) [](#method-i-l) - -## test_cr_crlf() [](#method-i-test_cr_crlf) - -## test_lf_crlf() [](#method-i-test_lf_crlf) - -## test_lf_lf() [](#method-i-test_lf_lf) - -## test_newline_terminator_with_cr_cr() [](#method-i-test_newline_terminator_with_cr_cr) - -## test_newline_terminator_with_crlf_crlf_with_extra_cr() [](#method-i-test_newline_terminator_with_crlf_crlf_with_extra_cr) - -## test_newline_terminator_with_crlf_lf() [](#method-i-test_newline_terminator_with_crlf_lf) - -## test_newline_terminator_with_crlf_pair() [](#method-i-test_newline_terminator_with_crlf_pair) - -## test_newline_terminator_with_lf_crlf() [](#method-i-test_newline_terminator_with_lf_crlf) - -## test_newline_terminator_with_lf_crlf_with_extra_cr() [](#method-i-test_newline_terminator_with_lf_crlf_with_extra_cr) - diff --git a/example/ruby/Prism/PercentDelimiterStringTest.md b/example/ruby/Prism/PercentDelimiterStringTest.md deleted file mode 100644 index 6c8d437..0000000 --- a/example/ruby/Prism/PercentDelimiterStringTest.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Prism::PercentDelimiterStringTest -**Inherits:** Prism::TestCase - -**Includes:** Prism::PercentDelimiterTests - - - - - -#Instance Methods -## assert_parse(expected, str) [](#method-i-assert_parse) - -## find_node(str) [](#method-i-find_node) - -## l(str) [](#method-i-l) - -## test_cr_crlf() [](#method-i-test_cr_crlf) - -## test_lf_crlf() [](#method-i-test_lf_crlf) - -## test_lf_lf() [](#method-i-test_lf_lf) - -## test_newline_terminator_with_cr_cr() [](#method-i-test_newline_terminator_with_cr_cr) - -## test_newline_terminator_with_crlf_crlf_with_extra_cr() [](#method-i-test_newline_terminator_with_crlf_crlf_with_extra_cr) - -## test_newline_terminator_with_crlf_lf() [](#method-i-test_newline_terminator_with_crlf_lf) - -## test_newline_terminator_with_crlf_pair() [](#method-i-test_newline_terminator_with_crlf_pair) - -## test_newline_terminator_with_lf_crlf() [](#method-i-test_newline_terminator_with_lf_crlf) - -## test_newline_terminator_with_lf_crlf_with_extra_cr() [](#method-i-test_newline_terminator_with_lf_crlf_with_extra_cr) - diff --git a/example/ruby/Prism/PercentDelimiterTests.md b/example/ruby/Prism/PercentDelimiterTests.md deleted file mode 100644 index 0228c69..0000000 --- a/example/ruby/Prism/PercentDelimiterTests.md +++ /dev/null @@ -1,27 +0,0 @@ -# Module: Prism::PercentDelimiterTests - - - - - -#Instance Methods -## assert_parse(expected, str) [](#method-i-assert_parse) - -## test_cr_crlf() [](#method-i-test_cr_crlf) - -## test_lf_crlf() [](#method-i-test_lf_crlf) - -## test_lf_lf() [](#method-i-test_lf_lf) - -## test_newline_terminator_with_cr_cr() [](#method-i-test_newline_terminator_with_cr_cr) - -## test_newline_terminator_with_crlf_crlf_with_extra_cr() [](#method-i-test_newline_terminator_with_crlf_crlf_with_extra_cr) - -## test_newline_terminator_with_crlf_lf() [](#method-i-test_newline_terminator_with_crlf_lf) - -## test_newline_terminator_with_crlf_pair() [](#method-i-test_newline_terminator_with_crlf_pair) - -## test_newline_terminator_with_lf_crlf() [](#method-i-test_newline_terminator_with_lf_crlf) - -## test_newline_terminator_with_lf_crlf_with_extra_cr() [](#method-i-test_newline_terminator_with_lf_crlf_with_extra_cr) - diff --git a/example/ruby/Prism/RationalNode.md b/example/ruby/Prism/RationalNode.md deleted file mode 100644 index a5c1278..0000000 --- a/example/ruby/Prism/RationalNode.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::RationalNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## numeric() [](#method-i-numeric) -Returns the value of the node as an IntegerNode or a FloatNode. This method is -deprecated in favor of #value or #numerator/#denominator. - -## value() [](#method-i-value) -Returns the value of the node as a Ruby Rational. - diff --git a/example/ruby/Prism/ReflectionTest.md b/example/ruby/Prism/ReflectionTest.md deleted file mode 100644 index 3c66534..0000000 --- a/example/ruby/Prism/ReflectionTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::ReflectionTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_fields_for() [](#method-i-test_fields_for) - diff --git a/example/ruby/Prism/RegexpTest.md b/example/ruby/Prism/RegexpTest.md deleted file mode 100644 index 3b37b56..0000000 --- a/example/ruby/Prism/RegexpTest.md +++ /dev/null @@ -1,117 +0,0 @@ -# Class: Prism::RegexpTest -**Inherits:** TestCase - - - - - -#Instance Methods -## test_absence_operator() [](#method-i-test_absence_operator) - -## test_allows_duplicate_named_captures() [](#method-i-test_allows_duplicate_named_captures) - -## test_alternation() [](#method-i-test_alternation) -These tests test the rest of the AST. They are not exhaustive, but they should -cover the most common cases. We test these to make sure we don't accidentally -regress and stop being able to extract named captures. - -## test_anchors() [](#method-i-test_anchors) - -## test_any() [](#method-i-test_any) - -## test_atomic_groups() [](#method-i-test_atomic_groups) - -## test_beginless_range_quantifier() [](#method-i-test_beginless_range_quantifier) - -## test_character_ranges() [](#method-i-test_character_ranges) - -## test_character_sets() [](#method-i-test_character_sets) - -## test_comments() [](#method-i-test_comments) - -## test_comments_with_escaped_parentheses() [](#method-i-test_comments_with_escaped_parentheses) - -## test_conditional_expression_with_group() [](#method-i-test_conditional_expression_with_group) - -## test_conditional_expression_with_index() [](#method-i-test_conditional_expression_with_index) - -## test_conditional_expression_with_name() [](#method-i-test_conditional_expression_with_name) - -## test_endless_range_quantifier() [](#method-i-test_endless_range_quantifier) - -## test_fake_named_capture_inside_character_set_with_escaped_ending() [](#method-i-test_fake_named_capture_inside_character_set_with_escaped_ending) - -## test_fake_named_captures_inside_character_sets() [](#method-i-test_fake_named_captures_inside_character_sets) - -## test_fake_range_quantifier_because_of_spaces() [](#method-i-test_fake_range_quantifier_because_of_spaces) - -## test_fake_range_quantifier_because_unclosed() [](#method-i-test_fake_range_quantifier_because_unclosed) - -## test_flag_combined() [](#method-i-test_flag_combined) - -## test_flag_extended() [](#method-i-test_flag_extended) - -## test_flag_fixedencoding() [](#method-i-test_flag_fixedencoding) - -## test_flag_ignorecase() [](#method-i-test_flag_ignorecase) -These test that flag values are correct. - -## test_flag_multiline() [](#method-i-test_flag_multiline) - -## test_flag_noencoding() [](#method-i-test_flag_noencoding) - -## test_flag_once() [](#method-i-test_flag_once) - -## test_invalid_posix_character_classes_should_fall_back_to_regular_classes() [](#method-i-test_invalid_posix_character_classes_should_fall_back_to_regular_classes) - -## test_last_encoding_option_wins() [](#method-i-test_last_encoding_option_wins) - -## test_named_capture_inside_fake_range_quantifier() [](#method-i-test_named_capture_inside_fake_range_quantifier) - -## test_named_capture_inside_nested_character_set() [](#method-i-test_named_capture_inside_nested_character_set) - -## test_named_captures_with_arrows() [](#method-i-test_named_captures_with_arrows) -These tests test the actual use case of extracting named capture groups - -## test_named_captures_with_single_quotes() [](#method-i-test_named_captures_with_single_quotes) - -## test_negated_character_ranges() [](#method-i-test_negated_character_ranges) - -## test_negated_character_sets() [](#method-i-test_negated_character_sets) - -## test_negated_posix_character_classes() [](#method-i-test_negated_posix_character_classes) - -## test_negative_lookaheads() [](#method-i-test_negative_lookaheads) - -## test_negative_lookbehinds() [](#method-i-test_negative_lookbehinds) - -## test_nested_character_sets() [](#method-i-test_nested_character_sets) - -## test_nested_character_sets_with_operators() [](#method-i-test_nested_character_sets_with_operators) - -## test_nested_named_captures_with_arrows() [](#method-i-test_nested_named_captures_with_arrows) - -## test_nested_named_captures_with_single_quotes() [](#method-i-test_nested_named_captures_with_single_quotes) - -## test_non_capturing_groups() [](#method-i-test_non_capturing_groups) - -## test_options_on_groups() [](#method-i-test_options_on_groups) - -## test_options_on_groups_getting_turned_off() [](#method-i-test_options_on_groups_getting_turned_off) - -## test_options_on_groups_some_getting_turned_on_some_getting_turned_off() [](#method-i-test_options_on_groups_some_getting_turned_on_some_getting_turned_off) - -## test_plus_quantifier() [](#method-i-test_plus_quantifier) - -## test_positive_lookaheads() [](#method-i-test_positive_lookaheads) - -## test_positive_lookbehinds() [](#method-i-test_positive_lookbehinds) - -## test_posix_character_classes() [](#method-i-test_posix_character_classes) - -## test_question_mark_quantifier() [](#method-i-test_question_mark_quantifier) - -## test_range_quantifier() [](#method-i-test_range_quantifier) - -## test_star_quantifier() [](#method-i-test_star_quantifier) - diff --git a/example/ruby/Prism/RegularExpressionEncodingTest.md b/example/ruby/Prism/RegularExpressionEncodingTest.md deleted file mode 100644 index 84dde10..0000000 --- a/example/ruby/Prism/RegularExpressionEncodingTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::RegularExpressionEncodingTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/RegularExpressionNode.md b/example/ruby/Prism/RegularExpressionNode.md deleted file mode 100644 index 84871a0..0000000 --- a/example/ruby/Prism/RegularExpressionNode.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::RegularExpressionNode -**Inherits:** Prism::Node - - - - - diff --git a/example/ruby/Prism/RegularExpressionOptionsTest.md b/example/ruby/Prism/RegularExpressionOptionsTest.md deleted file mode 100644 index d18992f..0000000 --- a/example/ruby/Prism/RegularExpressionOptionsTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::RegularExpressionOptionsTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_options() [](#method-i-test_options) - diff --git a/example/ruby/Prism/Relocation.md b/example/ruby/Prism/Relocation.md deleted file mode 100644 index 71b8cc8..0000000 --- a/example/ruby/Prism/Relocation.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: Prism::Relocation - - -Prism parses deterministically for the same input. This provides a nice -property that is exposed through the #node_id API on nodes. Effectively this -means that for the same input, these values will remain consistent every time -the source is parsed. This means we can reparse the source same with a -#node_id value and find the exact same node again. - -The Relocation module provides an API around this property. It allows you to -"save" nodes and locations using a minimal amount of memory (just the node_id -and a field identifier) and then reify them later. - - -# Class Methods -## filepath(value ) [](#method-c-filepath) -Create a new repository for the given filepath. -## string(value ) [](#method-c-string) -Create a new repository for the given string. - diff --git a/example/ruby/Prism/Relocation/CharacterColumnsField.md b/example/ruby/Prism/Relocation/CharacterColumnsField.md deleted file mode 100644 index 8bfa905..0000000 --- a/example/ruby/Prism/Relocation/CharacterColumnsField.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::CharacterColumnsField -**Inherits:** Object - - -A field representing the start and end character columns. - - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the start and end character column of a value. - diff --git a/example/ruby/Prism/Relocation/CharacterOffsetsField.md b/example/ruby/Prism/Relocation/CharacterOffsetsField.md deleted file mode 100644 index 0926f69..0000000 --- a/example/ruby/Prism/Relocation/CharacterOffsetsField.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::CharacterOffsetsField -**Inherits:** Object - - -A field representing the start and end character offsets. - - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the start and end character offset of a value. - diff --git a/example/ruby/Prism/Relocation/CodeUnitColumnsField.md b/example/ruby/Prism/Relocation/CodeUnitColumnsField.md deleted file mode 100644 index 9553a79..0000000 --- a/example/ruby/Prism/Relocation/CodeUnitColumnsField.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::Relocation::CodeUnitColumnsField -**Inherits:** Object - - -A field representing the start and end code unit columns for a specific -encoding. - - -# Attributes -## encoding[RW] [](#attribute-i-encoding) -The associated encoding for the code units. - -## repository[RW] [](#attribute-i-repository) -The repository object that is used for lazily creating a code units cache. - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the start and end code units column of a value for a particular -encoding. - -## initialize(repository, encoding) [](#method-i-initialize) -Initialize a new field with the associated repository and encoding. - -**@return** [CodeUnitColumnsField] a new instance of CodeUnitColumnsField - diff --git a/example/ruby/Prism/Relocation/CodeUnitOffsetsField.md b/example/ruby/Prism/Relocation/CodeUnitOffsetsField.md deleted file mode 100644 index 4a7ed89..0000000 --- a/example/ruby/Prism/Relocation/CodeUnitOffsetsField.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::Relocation::CodeUnitOffsetsField -**Inherits:** Object - - -A field representing the start and end code unit offsets. - - -# Attributes -## encoding[RW] [](#attribute-i-encoding) -The associated encoding for the code units. - -## repository[RW] [](#attribute-i-repository) -A pointer to the repository object that is used for lazily creating a code -units cache. - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the start and end code units offset of a value for a particular -encoding. - -## initialize(repository, encoding) [](#method-i-initialize) -Initialize a new field with the associated repository and encoding. - -**@return** [CodeUnitOffsetsField] a new instance of CodeUnitOffsetsField - diff --git a/example/ruby/Prism/Relocation/ColumnsField.md b/example/ruby/Prism/Relocation/ColumnsField.md deleted file mode 100644 index 244d64d..0000000 --- a/example/ruby/Prism/Relocation/ColumnsField.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::ColumnsField -**Inherits:** Object - - -A field representing the start and end byte columns. - - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the start and end byte column of a value. - diff --git a/example/ruby/Prism/Relocation/CommentsField.md b/example/ruby/Prism/Relocation/CommentsField.md deleted file mode 100644 index 5834475..0000000 --- a/example/ruby/Prism/Relocation/CommentsField.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Prism::Relocation::CommentsField -**Inherits:** Object - - -An abstract field used as the parent class of the two comments fields. - - - diff --git a/example/ruby/Prism/Relocation/CommentsField/Comment.md b/example/ruby/Prism/Relocation/CommentsField/Comment.md deleted file mode 100644 index 5001c48..0000000 --- a/example/ruby/Prism/Relocation/CommentsField/Comment.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Prism::Relocation::CommentsField::Comment -**Inherits:** Object - - -An object that represents a slice of a comment. - - -# Attributes -## slice[RW] [](#attribute-i-slice) -The slice of the comment. - - -#Instance Methods -## initialize(slice) [](#method-i-initialize) -Initialize a new comment with the given slice. - -**@return** [Comment] a new instance of Comment - diff --git a/example/ruby/Prism/Relocation/Entry.md b/example/ruby/Prism/Relocation/Entry.md deleted file mode 100644 index 72bcca0..0000000 --- a/example/ruby/Prism/Relocation/Entry.md +++ /dev/null @@ -1,77 +0,0 @@ -# Class: Prism::Relocation::Entry -**Inherits:** Object - - -An entry in a repository that will lazily reify its values when they are first -accessed. - - - -#Instance Methods -## comments() [](#method-i-comments) -Fetch the leading and trailing comments of the value. - -## end_character_column() [](#method-i-end_character_column) -Fetch the end character column of the value. - -## end_character_offset() [](#method-i-end_character_offset) -Fetch the end character offset of the value. - -## end_code_units_column() [](#method-i-end_code_units_column) -Fetch the end code units column of the value, for the encoding that was -configured on the repository. - -## end_code_units_offset() [](#method-i-end_code_units_offset) -Fetch the end code units offset of the value, for the encoding that was -configured on the repository. - -## end_column() [](#method-i-end_column) -Fetch the end byte column of the value. - -## end_line() [](#method-i-end_line) -Fetch the end line of the value. - -## end_offset() [](#method-i-end_offset) -Fetch the end byte offset of the value. - -## filepath() [](#method-i-filepath) -Fetch the filepath of the value. - -## initialize(repository) [](#method-i-initialize) -Initialize a new entry with the given repository. - -**@return** [Entry] a new instance of Entry - -## leading_comments() [](#method-i-leading_comments) -Fetch the leading comments of the value. - -## reify!(values) [](#method-i-reify!) -Reify the values on this entry with the given values. This is an internal-only -API that is called from the repository when it is time to reify the values. - -## start_character_column() [](#method-i-start_character_column) -Fetch the start character column of the value. - -## start_character_offset() [](#method-i-start_character_offset) -Fetch the start character offset of the value. - -## start_code_units_column() [](#method-i-start_code_units_column) -Fetch the start code units column of the value, for the encoding that was -configured on the repository. - -## start_code_units_offset() [](#method-i-start_code_units_offset) -Fetch the start code units offset of the value, for the encoding that was -configured on the repository. - -## start_column() [](#method-i-start_column) -Fetch the start byte column of the value. - -## start_line() [](#method-i-start_line) -Fetch the start line of the value. - -## start_offset() [](#method-i-start_offset) -Fetch the start byte offset of the value. - -## trailing_comments() [](#method-i-trailing_comments) -Fetch the trailing comments of the value. - diff --git a/example/ruby/Prism/Relocation/Entry/MissingValueError.md b/example/ruby/Prism/Relocation/Entry/MissingValueError.md deleted file mode 100644 index 3a81bec..0000000 --- a/example/ruby/Prism/Relocation/Entry/MissingValueError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Prism::Relocation::Entry::MissingValueError -**Inherits:** StandardError - - -Raised if a value that could potentially be on an entry is missing because it -was either not configured on the repository or it has not yet been fetched. - - - diff --git a/example/ruby/Prism/Relocation/FilepathField.md b/example/ruby/Prism/Relocation/FilepathField.md deleted file mode 100644 index 20437e5..0000000 --- a/example/ruby/Prism/Relocation/FilepathField.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Prism::Relocation::FilepathField -**Inherits:** Object - - -A field that represents the file path. - - -# Attributes -## value[RW] [](#attribute-i-value) -The file path that this field represents. - - -#Instance Methods -## fields(_value) [](#method-i-fields) -Fetch the file path. - -## initialize(value) [](#method-i-initialize) -Initialize a new field with the given file path. - -**@return** [FilepathField] a new instance of FilepathField - diff --git a/example/ruby/Prism/Relocation/LeadingCommentsField.md b/example/ruby/Prism/Relocation/LeadingCommentsField.md deleted file mode 100644 index f4a91ce..0000000 --- a/example/ruby/Prism/Relocation/LeadingCommentsField.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::LeadingCommentsField -**Inherits:** Prism::Relocation::CommentsField - - -A field representing the leading comments. - - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the leading comments of a value. - diff --git a/example/ruby/Prism/Relocation/LinesField.md b/example/ruby/Prism/Relocation/LinesField.md deleted file mode 100644 index c3e4bfa..0000000 --- a/example/ruby/Prism/Relocation/LinesField.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::LinesField -**Inherits:** Object - - -A field representing the start and end lines. - - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the start and end line of a value. - diff --git a/example/ruby/Prism/Relocation/OffsetsField.md b/example/ruby/Prism/Relocation/OffsetsField.md deleted file mode 100644 index 69f366a..0000000 --- a/example/ruby/Prism/Relocation/OffsetsField.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::OffsetsField -**Inherits:** Object - - -A field representing the start and end byte offsets. - - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the start and end byte offset of a value. - diff --git a/example/ruby/Prism/Relocation/Repository.md b/example/ruby/Prism/Relocation/Repository.md deleted file mode 100644 index 14d8ffc..0000000 --- a/example/ruby/Prism/Relocation/Repository.md +++ /dev/null @@ -1,77 +0,0 @@ -# Class: Prism::Relocation::Repository -**Inherits:** Object - - -A repository is a configured collection of fields and a set of entries that -knows how to reparse a source and reify the values. - - -# Attributes -## entries[RW] [](#attribute-i-entries) -The entries that have been saved on this repository. - -## fields[RW] [](#attribute-i-fields) -The fields that have been configured on this repository. - -## source[RW] [](#attribute-i-source) -The source associated with this repository. This will be either a -SourceFilepath (the most common use case) or a SourceString. - - -#Instance Methods -## character_columns() [](#method-i-character_columns) -Configure the character columns field for this repository and return self. - -## character_offsets() [](#method-i-character_offsets) -Configure the character offsets field for this repository and return self. - -## code_unit_columns(encoding) [](#method-i-code_unit_columns) -Configure the code unit columns field for this repository for a specific -encoding and return self. - -## code_unit_offsets(encoding) [](#method-i-code_unit_offsets) -Configure the code unit offsets field for this repository for a specific -encoding and return self. - -## code_units_cache(encoding) [](#method-i-code_units_cache) -Create a code units cache for the given encoding from the source. - -## columns() [](#method-i-columns) -Configure the columns field for this repository and return self. - -## comments() [](#method-i-comments) -Configure both the leading and trailing comment fields for this repository and -return self. - -## enter(node_id, field_name) [](#method-i-enter) -This method is called from nodes and locations when they want to enter -themselves into the repository. It it internal-only and meant to be called -from the #save* APIs. - -## filepath() [](#method-i-filepath) -Configure the filepath field for this repository and return self. - -**@raise** [ConfigurationError] - -## initialize(source) [](#method-i-initialize) -Initialize a new repository with the given source. - -**@return** [Repository] a new instance of Repository - -## leading_comments() [](#method-i-leading_comments) -Configure the leading comments field for this repository and return self. - -## lines() [](#method-i-lines) -Configure the lines field for this repository and return self. - -## offsets() [](#method-i-offsets) -Configure the offsets field for this repository and return self. - -## reify!() [](#method-i-reify!) -This method is called from the entries in the repository when they need to -reify their values. It is internal-only and meant to be called from the -various value APIs. - -## trailing_comments() [](#method-i-trailing_comments) -Configure the trailing comments field for this repository and return self. - diff --git a/example/ruby/Prism/Relocation/Repository/ConfigurationError.md b/example/ruby/Prism/Relocation/Repository/ConfigurationError.md deleted file mode 100644 index e47f7ed..0000000 --- a/example/ruby/Prism/Relocation/Repository/ConfigurationError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Prism::Relocation::Repository::ConfigurationError -**Inherits:** StandardError - - -Raised when multiple fields of the same type are configured on the same -repository. - - - diff --git a/example/ruby/Prism/Relocation/Source.md b/example/ruby/Prism/Relocation/Source.md deleted file mode 100644 index 2233cc5..0000000 --- a/example/ruby/Prism/Relocation/Source.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::Relocation::Source -**Inherits:** Object - - -Represents the source of a repository that will be reparsed. - - -# Attributes -## value[RW] [](#attribute-i-value) -The value that will need to be reparsed. - - -#Instance Methods -## code_units_cache(encoding) [](#method-i-code_units_cache) -Create a code units cache for the given encoding. - -## initialize(value) [](#method-i-initialize) -Initialize the source with the given value. - -**@return** [Source] a new instance of Source - -## result() [](#method-i-result) -Reparse the value and return the parse result. - -**@raise** [NotImplementedError] - diff --git a/example/ruby/Prism/Relocation/SourceFilepath.md b/example/ruby/Prism/Relocation/SourceFilepath.md deleted file mode 100644 index 34b1d2e..0000000 --- a/example/ruby/Prism/Relocation/SourceFilepath.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::SourceFilepath -**Inherits:** Prism::Relocation::Source - - -A source that is represented by a file path. - - - -#Instance Methods -## result() [](#method-i-result) -Reparse the file and return the parse result. - diff --git a/example/ruby/Prism/Relocation/SourceString.md b/example/ruby/Prism/Relocation/SourceString.md deleted file mode 100644 index 04391f5..0000000 --- a/example/ruby/Prism/Relocation/SourceString.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::SourceString -**Inherits:** Prism::Relocation::Source - - -A source that is represented by a string. - - - -#Instance Methods -## result() [](#method-i-result) -Reparse the string and return the parse result. - diff --git a/example/ruby/Prism/Relocation/TrailingCommentsField.md b/example/ruby/Prism/Relocation/TrailingCommentsField.md deleted file mode 100644 index f44be95..0000000 --- a/example/ruby/Prism/Relocation/TrailingCommentsField.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Relocation::TrailingCommentsField -**Inherits:** Prism::Relocation::CommentsField - - -A field representing the trailing comments. - - - -#Instance Methods -## fields(value) [](#method-i-fields) -Fetches the trailing comments of a value. - diff --git a/example/ruby/Prism/RelocationTest.md b/example/ruby/Prism/RelocationTest.md deleted file mode 100644 index 316c626..0000000 --- a/example/ruby/Prism/RelocationTest.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Prism::RelocationTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_character_columns() [](#method-i-test_character_columns) - -## test_character_offsets() [](#method-i-test_character_offsets) - -## test_code_unit_columns() [](#method-i-test_code_unit_columns) - -## test_code_unit_offsets() [](#method-i-test_code_unit_offsets) - -## test_columns() [](#method-i-test_columns) - -## test_comments() [](#method-i-test_comments) - -## test_filepath() [](#method-i-test_filepath) - -## test_leading_comments() [](#method-i-test_leading_comments) - -## test_lines() [](#method-i-test_lines) - -## test_misconfiguration() [](#method-i-test_misconfiguration) - -## test_missing_values() [](#method-i-test_missing_values) - -## test_offsets() [](#method-i-test_offsets) - -## test_repository_filepath() [](#method-i-test_repository_filepath) - -## test_trailing_comments() [](#method-i-test_trailing_comments) - diff --git a/example/ruby/Prism/RescueModifierNode.md b/example/ruby/Prism/RescueModifierNode.md deleted file mode 100644 index 7f0bdad..0000000 --- a/example/ruby/Prism/RescueModifierNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::RescueModifierNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/RescueNode.md b/example/ruby/Prism/RescueNode.md deleted file mode 100644 index c64bb6f..0000000 --- a/example/ruby/Prism/RescueNode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::RescueNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## consequent() [](#method-i-consequent) -Returns the subsequent rescue clause of the rescue node. This method is -deprecated in favor of #subsequent. - diff --git a/example/ruby/Prism/Result.md b/example/ruby/Prism/Result.md deleted file mode 100644 index e0aad7f..0000000 --- a/example/ruby/Prism/Result.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: Prism::Result -**Inherits:** Object - - -This represents the result of a call to ::parse or ::parse_file. It contains -the requested structure, any comments that were encounters, and any errors -that were encountered. - - -# Attributes -## comments[RW] [](#attribute-i-comments) -The list of comments that were encountered during parsing. - -## data_loc[RW] [](#attribute-i-data_loc) -An optional location that represents the location of the __END__ marker and -the rest of the content of the file. This content is loaded into the DATA -constant when the file being parsed is the main file being executed. - -## errors[RW] [](#attribute-i-errors) -The list of errors that were generated during parsing. - -## magic_comments[RW] [](#attribute-i-magic_comments) -The list of magic comments that were encountered during parsing. - -## source[RW] [](#attribute-i-source) -A Source instance that represents the source code that was parsed. - -## warnings[RW] [](#attribute-i-warnings) -The list of warnings that were generated during parsing. - - -#Instance Methods -## code_units_cache(encoding) [](#method-i-code_units_cache) -Create a code units cache for the given encoding. - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for Result. - -## encoding() [](#method-i-encoding) -Returns the encoding of the source code that was parsed. - -## failure?() [](#method-i-failure?) -Returns true if there were errors during parsing and false if there were not. - -**@return** [Boolean] - -## initialize(comments, magic_comments, data_loc, errors, warnings, source) [](#method-i-initialize) -Create a new result object with the given values. - -**@return** [Result] a new instance of Result - -## success?() [](#method-i-success?) -Returns true if there were no errors during parsing and false if there were. - -**@return** [Boolean] - diff --git a/example/ruby/Prism/RipperTest.md b/example/ruby/Prism/RipperTest.md deleted file mode 100644 index 2a1fc8a..0000000 --- a/example/ruby/Prism/RipperTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::RipperTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/RubyParserTest.md b/example/ruby/Prism/RubyParserTest.md deleted file mode 100644 index e5e4943..0000000 --- a/example/ruby/Prism/RubyParserTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::RubyParserTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/SnippetsTest.md b/example/ruby/Prism/SnippetsTest.md deleted file mode 100644 index da6d2c5..0000000 --- a/example/ruby/Prism/SnippetsTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::SnippetsTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/Source.md b/example/ruby/Prism/Source.md deleted file mode 100644 index 99cc9ed..0000000 --- a/example/ruby/Prism/Source.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: Prism::Source -**Inherits:** Object - - -This represents a source of Ruby code that has been parsed. It is used in -conjunction with locations to allow them to resolve line numbers and source -ranges. - - -# Class Methods -## for(source , start_line 1, offsets []) [](#method-c-for) -Create a new source object with the given source code. This method should be -used instead of `new` and it will return either a `Source` or a specialized -and more performant `ASCIISource` if no multibyte characters are present in -the source code. -# Attributes -## offsets[RW] [](#attribute-i-offsets) -The list of newline byte offsets in the source code. - -## source[RW] [](#attribute-i-source) -The source code that this source object represents. - -## start_line[RW] [](#attribute-i-start_line) -The line number where this source starts. - - -#Instance Methods -## character_column(byte_offset) [](#method-i-character_column) -Return the column number in characters for the given byte offset. - -## character_offset(byte_offset) [](#method-i-character_offset) -Return the character offset for the given byte offset. - -## code_units_cache(encoding) [](#method-i-code_units_cache) -Generate a cache that targets a specific encoding for calculating code unit -offsets. - -## code_units_column(byte_offset, encoding) [](#method-i-code_units_column) -Returns the column number in code units for the given encoding for the given -byte offset. - -## code_units_offset(byte_offset, encoding) [](#method-i-code_units_offset) -Returns the offset from the start of the file for the given byte offset -counting in code units for the given encoding. - -This method is tested with UTF-8, UTF-16, and UTF-32. If there is the concept -of code units that differs from the number of characters in other encodings, -it is not captured here. - -We purposefully replace invalid and undefined characters with replacement -characters in this conversion. This happens for two reasons. First, it's -possible that the given byte offset will not occur on a character boundary. -Second, it's possible that the source code will contain a character that has -no equivalent in the given encoding. - -## column(byte_offset) [](#method-i-column) -Return the column number for the given byte offset. - -## encoding() [](#method-i-encoding) -Returns the encoding of the source code, which is set by parameters to the -parser or by the encoding magic comment. - -## initialize(source, start_line1, offsets[]) [](#method-i-initialize) -Create a new source object with the given source code. - -**@return** [Source] a new instance of Source - -## line(byte_offset) [](#method-i-line) -Binary search through the offsets to find the line number for the given byte -offset. - -## line_end(byte_offset) [](#method-i-line_end) -Returns the byte offset of the end of the line corresponding to the given byte -offset. - -## line_start(byte_offset) [](#method-i-line_start) -Return the byte offset of the start of the line corresponding to the given -byte offset. - -## lines() [](#method-i-lines) -Returns the lines of the source code as an array of strings. - -## slice(byte_offset, length) [](#method-i-slice) -Perform a byteslice on the source code using the given byte offset and byte -length. - diff --git a/example/ruby/Prism/SourceLocationTest.md b/example/ruby/Prism/SourceLocationTest.md deleted file mode 100644 index a875e7b..0000000 --- a/example/ruby/Prism/SourceLocationTest.md +++ /dev/null @@ -1,308 +0,0 @@ -# Class: Prism::SourceLocationTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_AliasGlobalVariableNode() [](#method-i-test_AliasGlobalVariableNode) - -## test_AliasMethodNode() [](#method-i-test_AliasMethodNode) - -## test_AlternationPatternNode() [](#method-i-test_AlternationPatternNode) - -## test_AndNode() [](#method-i-test_AndNode) - -## test_ArgumentsNode() [](#method-i-test_ArgumentsNode) - -## test_ArrayNode() [](#method-i-test_ArrayNode) - -## test_ArrayPatternNode() [](#method-i-test_ArrayPatternNode) - -## test_AssocNode() [](#method-i-test_AssocNode) - -## test_AssocSplatNode() [](#method-i-test_AssocSplatNode) - -## test_BackReferenceReadNode() [](#method-i-test_BackReferenceReadNode) - -## test_BeginNode() [](#method-i-test_BeginNode) - -## test_BlockArgumentNode() [](#method-i-test_BlockArgumentNode) - -## test_BlockLocalVariableNode() [](#method-i-test_BlockLocalVariableNode) - -## test_BlockNode() [](#method-i-test_BlockNode) - -## test_BlockParameterNode() [](#method-i-test_BlockParameterNode) - -## test_BlockParametersNode() [](#method-i-test_BlockParametersNode) - -## test_BreakNode() [](#method-i-test_BreakNode) - -## test_CallAndWriteNode() [](#method-i-test_CallAndWriteNode) - -## test_CallNode() [](#method-i-test_CallNode) - -## test_CallOperatorWriteNode() [](#method-i-test_CallOperatorWriteNode) - -## test_CallOrWriteNode() [](#method-i-test_CallOrWriteNode) - -## test_CallTargetNode() [](#method-i-test_CallTargetNode) - -## test_CapturePatternNode() [](#method-i-test_CapturePatternNode) - -## test_CaseMatchNode() [](#method-i-test_CaseMatchNode) - -## test_CaseNode() [](#method-i-test_CaseNode) - -## test_ClassNode() [](#method-i-test_ClassNode) - -## test_ClassVariableAndWriteNode() [](#method-i-test_ClassVariableAndWriteNode) - -## test_ClassVariableOperatorWriteNode() [](#method-i-test_ClassVariableOperatorWriteNode) - -## test_ClassVariableOrWriteNode() [](#method-i-test_ClassVariableOrWriteNode) - -## test_ClassVariableReadNode() [](#method-i-test_ClassVariableReadNode) - -## test_ClassVariableTargetNode() [](#method-i-test_ClassVariableTargetNode) - -## test_ClassVariableWriteNode() [](#method-i-test_ClassVariableWriteNode) - -## test_ConstantAndWriteNode() [](#method-i-test_ConstantAndWriteNode) - -## test_ConstantOperatorWriteNode() [](#method-i-test_ConstantOperatorWriteNode) - -## test_ConstantOrWriteNode() [](#method-i-test_ConstantOrWriteNode) - -## test_ConstantPathAndWriteNode() [](#method-i-test_ConstantPathAndWriteNode) - -## test_ConstantPathNode() [](#method-i-test_ConstantPathNode) - -## test_ConstantPathOperatorWriteNode() [](#method-i-test_ConstantPathOperatorWriteNode) - -## test_ConstantPathOrWriteNode() [](#method-i-test_ConstantPathOrWriteNode) - -## test_ConstantPathTargetNode() [](#method-i-test_ConstantPathTargetNode) - -## test_ConstantPathWriteNode() [](#method-i-test_ConstantPathWriteNode) - -## test_ConstantReadNode() [](#method-i-test_ConstantReadNode) - -## test_ConstantTargetNode() [](#method-i-test_ConstantTargetNode) - -## test_ConstantWriteNode() [](#method-i-test_ConstantWriteNode) - -## test_DefNode() [](#method-i-test_DefNode) - -## test_DefinedNode() [](#method-i-test_DefinedNode) - -## test_ElseNode() [](#method-i-test_ElseNode) - -## test_EmbeddedStatementsNode() [](#method-i-test_EmbeddedStatementsNode) - -## test_EmbeddedVariableNode() [](#method-i-test_EmbeddedVariableNode) - -## test_EnsureNode() [](#method-i-test_EnsureNode) - -## test_FalseNode() [](#method-i-test_FalseNode) - -## test_FindPatternNode() [](#method-i-test_FindPatternNode) - -## test_FlipFlopNode() [](#method-i-test_FlipFlopNode) - -## test_FloatNode() [](#method-i-test_FloatNode) - -## test_ForNode() [](#method-i-test_ForNode) - -## test_ForwardingArgumentsNode() [](#method-i-test_ForwardingArgumentsNode) - -## test_ForwardingParameterNode() [](#method-i-test_ForwardingParameterNode) - -## test_ForwardingSuperNode() [](#method-i-test_ForwardingSuperNode) - -## test_GlobalVariableAndWriteNode() [](#method-i-test_GlobalVariableAndWriteNode) - -## test_GlobalVariableOperatorWriteNode() [](#method-i-test_GlobalVariableOperatorWriteNode) - -## test_GlobalVariableOrWriteNode() [](#method-i-test_GlobalVariableOrWriteNode) - -## test_GlobalVariableReadNode() [](#method-i-test_GlobalVariableReadNode) - -## test_GlobalVariableTargetNode() [](#method-i-test_GlobalVariableTargetNode) - -## test_GlobalVariableWriteNode() [](#method-i-test_GlobalVariableWriteNode) - -## test_HashNode() [](#method-i-test_HashNode) - -## test_HashPatternNode() [](#method-i-test_HashPatternNode) - -## test_IfNode() [](#method-i-test_IfNode) - -## test_ImaginaryNode() [](#method-i-test_ImaginaryNode) - -## test_ImplicitNode() [](#method-i-test_ImplicitNode) - -## test_ImplicitRestNode() [](#method-i-test_ImplicitRestNode) - -## test_InNode() [](#method-i-test_InNode) - -## test_IndexAndWriteNode() [](#method-i-test_IndexAndWriteNode) - -## test_IndexOperatorWriteNode() [](#method-i-test_IndexOperatorWriteNode) - -## test_IndexOrWriteNode() [](#method-i-test_IndexOrWriteNode) - -## test_IndexTargetNode() [](#method-i-test_IndexTargetNode) - -## test_InstanceVariableAndWriteNode() [](#method-i-test_InstanceVariableAndWriteNode) - -## test_InstanceVariableOperatorWriteNode() [](#method-i-test_InstanceVariableOperatorWriteNode) - -## test_InstanceVariableOrWriteNode() [](#method-i-test_InstanceVariableOrWriteNode) - -## test_InstanceVariableReadNode() [](#method-i-test_InstanceVariableReadNode) - -## test_InstanceVariableTargetNode() [](#method-i-test_InstanceVariableTargetNode) - -## test_InstanceVariableWriteNode() [](#method-i-test_InstanceVariableWriteNode) - -## test_IntegerNode() [](#method-i-test_IntegerNode) - -## test_InterpolatedMatchLastLineNode() [](#method-i-test_InterpolatedMatchLastLineNode) - -## test_InterpolatedRegularExpressionNode() [](#method-i-test_InterpolatedRegularExpressionNode) - -## test_InterpolatedStringNode() [](#method-i-test_InterpolatedStringNode) - -## test_InterpolatedSymbolNode() [](#method-i-test_InterpolatedSymbolNode) - -## test_InterpolatedXStringNode() [](#method-i-test_InterpolatedXStringNode) - -## test_ItLocalVariableReadNode() [](#method-i-test_ItLocalVariableReadNode) - -## test_ItParametersNode() [](#method-i-test_ItParametersNode) - -## test_KeywordHashNode() [](#method-i-test_KeywordHashNode) - -## test_KeywordRestParameterNode() [](#method-i-test_KeywordRestParameterNode) - -## test_LambdaNode() [](#method-i-test_LambdaNode) - -## test_LocalVariableAndWriteNode() [](#method-i-test_LocalVariableAndWriteNode) - -## test_LocalVariableOperatorWriteNode() [](#method-i-test_LocalVariableOperatorWriteNode) - -## test_LocalVariableOrWriteNode() [](#method-i-test_LocalVariableOrWriteNode) - -## test_LocalVariableReadNode() [](#method-i-test_LocalVariableReadNode) - -## test_LocalVariableTargetNode() [](#method-i-test_LocalVariableTargetNode) - -## test_LocalVariableWriteNode() [](#method-i-test_LocalVariableWriteNode) - -## test_MatchLastLineNode() [](#method-i-test_MatchLastLineNode) - -## test_MatchPredicateNode() [](#method-i-test_MatchPredicateNode) - -## test_MatchRequiredNode() [](#method-i-test_MatchRequiredNode) - -## test_MatchWriteNode() [](#method-i-test_MatchWriteNode) - -## test_ModuleNode() [](#method-i-test_ModuleNode) - -## test_MultiTargetNode() [](#method-i-test_MultiTargetNode) - -## test_MultiWriteNode() [](#method-i-test_MultiWriteNode) - -## test_NextNode() [](#method-i-test_NextNode) - -## test_NilNode() [](#method-i-test_NilNode) - -## test_NoKeywordsParameterNode() [](#method-i-test_NoKeywordsParameterNode) - -## test_NumberedParametersNode() [](#method-i-test_NumberedParametersNode) - -## test_NumberedReferenceReadNode() [](#method-i-test_NumberedReferenceReadNode) - -## test_OptionalKeywordParameterNode() [](#method-i-test_OptionalKeywordParameterNode) - -## test_OptionalParameterNode() [](#method-i-test_OptionalParameterNode) - -## test_OrNode() [](#method-i-test_OrNode) - -## test_ParametersNode() [](#method-i-test_ParametersNode) - -## test_ParenthesesNode() [](#method-i-test_ParenthesesNode) - -## test_PinnedExpressionNode() [](#method-i-test_PinnedExpressionNode) - -## test_PinnedVariableNode() [](#method-i-test_PinnedVariableNode) - -## test_PostExecutionNode() [](#method-i-test_PostExecutionNode) - -## test_PreExecutionNode() [](#method-i-test_PreExecutionNode) - -## test_RangeNode() [](#method-i-test_RangeNode) - -## test_RationalNode() [](#method-i-test_RationalNode) - -## test_RedoNode() [](#method-i-test_RedoNode) - -## test_RegularExpressionNode() [](#method-i-test_RegularExpressionNode) - -## test_RequiredKeywordParameterNode() [](#method-i-test_RequiredKeywordParameterNode) - -## test_RequiredParameterNode() [](#method-i-test_RequiredParameterNode) - -## test_RescueModifierNode() [](#method-i-test_RescueModifierNode) - -## test_RescueNode() [](#method-i-test_RescueNode) - -## test_RestParameterNode() [](#method-i-test_RestParameterNode) - -## test_RetryNode() [](#method-i-test_RetryNode) - -## test_ReturnNode() [](#method-i-test_ReturnNode) - -## test_SelfNode() [](#method-i-test_SelfNode) - -## test_ShareableConstantNode() [](#method-i-test_ShareableConstantNode) - -## test_SingletonClassNode() [](#method-i-test_SingletonClassNode) - -## test_SourceEncodingNode() [](#method-i-test_SourceEncodingNode) - -## test_SourceFileNode() [](#method-i-test_SourceFileNode) - -## test_SourceLineNode() [](#method-i-test_SourceLineNode) - -## test_SplatNode() [](#method-i-test_SplatNode) - -## test_StatementsNode() [](#method-i-test_StatementsNode) - -## test_StringNode() [](#method-i-test_StringNode) - -## test_SuperNode() [](#method-i-test_SuperNode) - -## test_SymbolNode() [](#method-i-test_SymbolNode) - -## test_TrueNode() [](#method-i-test_TrueNode) - -## test_UndefNode() [](#method-i-test_UndefNode) - -## test_UnlessNode() [](#method-i-test_UnlessNode) - -## test_UntilNode() [](#method-i-test_UntilNode) - -## test_WhenNode() [](#method-i-test_WhenNode) - -## test_WhileNode() [](#method-i-test_WhileNode) - -## test_XStringNode() [](#method-i-test_XStringNode) - -## test_YieldNode() [](#method-i-test_YieldNode) - -## test_all_tested() [](#method-i-test_all_tested) - diff --git a/example/ruby/Prism/StaticInspectTest.md b/example/ruby/Prism/StaticInspectTest.md deleted file mode 100644 index 85a9dd5..0000000 --- a/example/ruby/Prism/StaticInspectTest.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Prism::StaticInspectTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_false() [](#method-i-test_false) - -## test_float() [](#method-i-test_float) - -## test_imaginary() [](#method-i-test_imaginary) - -## test_integer() [](#method-i-test_integer) - -## test_nil() [](#method-i-test_nil) - -## test_rational() [](#method-i-test_rational) - -## test_regular_expression() [](#method-i-test_regular_expression) - -## test_source_encoding() [](#method-i-test_source_encoding) - -## test_source_file() [](#method-i-test_source_file) - -## test_source_line() [](#method-i-test_source_line) - -## test_string() [](#method-i-test_string) - -## test_symbol() [](#method-i-test_symbol) - -## test_true() [](#method-i-test_true) - diff --git a/example/ruby/Prism/StaticLiteralsTest.md b/example/ruby/Prism/StaticLiteralsTest.md deleted file mode 100644 index 520eace..0000000 --- a/example/ruby/Prism/StaticLiteralsTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::StaticLiteralsTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_static_literals() [](#method-i-test_static_literals) - diff --git a/example/ruby/Prism/StaticLiteralsTest/NullWarning.md b/example/ruby/Prism/StaticLiteralsTest/NullWarning.md deleted file mode 100644 index bf72647..0000000 --- a/example/ruby/Prism/StaticLiteralsTest/NullWarning.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::StaticLiteralsTest::NullWarning -**Inherits:** Object - - - - - -#Instance Methods -## message() [](#method-i-message) - diff --git a/example/ruby/Prism/StringEncodingTest.md b/example/ruby/Prism/StringEncodingTest.md deleted file mode 100644 index 284f1e1..0000000 --- a/example/ruby/Prism/StringEncodingTest.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Prism::StringEncodingTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_coding() [](#method-i-test_coding) - -## test_coding_with_whitespace() [](#method-i-test_coding_with_whitespace) - -## test_emacs_style() [](#method-i-test_emacs_style) - -## test_first_lexed_token() [](#method-i-test_first_lexed_token) - -## test_multibyte_escapes() [](#method-i-test_multibyte_escapes) - -## test_slice_encoding() [](#method-i-test_slice_encoding) - -## test_strpbrk_multibyte() [](#method-i-test_strpbrk_multibyte) -This test may be a little confusing. Basically when we use our strpbrk, it -takes into account the encoding of the file. - -## test_utf_8_dos() [](#method-i-test_utf_8_dos) - -## test_utf_8_mac() [](#method-i-test_utf_8_mac) - -## test_utf_8_star() [](#method-i-test_utf_8_star) - -## test_utf_8_unix() [](#method-i-test_utf_8_unix) - diff --git a/example/ruby/Prism/StringNode.md b/example/ruby/Prism/StringNode.md deleted file mode 100644 index 9b5a45a..0000000 --- a/example/ruby/Prism/StringNode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::StringNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## to_interpolated() [](#method-i-to_interpolated) -Occasionally it's helpful to treat a string as if it were interpolated so that -there's a consistent interface for working with strings. - diff --git a/example/ruby/Prism/StringQuery.md b/example/ruby/Prism/StringQuery.md deleted file mode 100644 index c1bd672..0000000 --- a/example/ruby/Prism/StringQuery.md +++ /dev/null @@ -1,51 +0,0 @@ -# Class: Prism::StringQuery -**Inherits:** Object - - -Query methods that allow categorizing strings based on their context for where -they could be valid in a Ruby syntax tree. - - -# Class Methods -## constant?(string ) [](#method-c-constant?) -Returns true if the string constitutes a valid constant name. Note that this -means the names that can be set through Module#const_set, not necessarily the -ones that can be set through a constant assignment. -**@overload** [] - -## local?(string ) [](#method-c-local?) -Returns true if the string constitutes a valid local variable name. Note that -this means the names that can be set through Binding#local_variable_set, not -necessarily the ones that can be set through a local variable assignment. -**@overload** [] - -## method_name?(string ) [](#method-c-method_name?) -Returns true if the string constitutes a valid method name. -**@overload** [] - -# Attributes -## string[RW] [](#attribute-i-string) -The string that this query is wrapping. - - -#Instance Methods -## constant?() [](#method-i-constant?) -Whether or not this string is a valid constant name. - -**@return** [Boolean] - -## initialize(string) [](#method-i-initialize) -Initialize a new query with the given string. - -**@return** [StringQuery] a new instance of StringQuery - -## local?() [](#method-i-local?) -Whether or not this string is a valid local variable name. - -**@return** [Boolean] - -## method_name?() [](#method-i-method_name?) -Whether or not this string is a valid method name. - -**@return** [Boolean] - diff --git a/example/ruby/Prism/StringQueryTest.md b/example/ruby/Prism/StringQueryTest.md deleted file mode 100644 index 6574edf..0000000 --- a/example/ruby/Prism/StringQueryTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Prism::StringQueryTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_constant?() [](#method-i-test_constant?) - -**@return** [Boolean] - -## test_invalid_encoding() [](#method-i-test_invalid_encoding) - -## test_local?() [](#method-i-test_local?) - -**@return** [Boolean] - -## test_method_name?() [](#method-i-test_method_name?) - -**@return** [Boolean] - diff --git a/example/ruby/Prism/SymbolEncodingTest.md b/example/ruby/Prism/SymbolEncodingTest.md deleted file mode 100644 index bdc8706..0000000 --- a/example/ruby/Prism/SymbolEncodingTest.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Prism::SymbolEncodingTest -**Inherits:** Prism::TestCase - - - - - diff --git a/example/ruby/Prism/Template.md b/example/ruby/Prism/Template.md deleted file mode 100644 index fc67b04..0000000 --- a/example/ruby/Prism/Template.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Prism::Template - - - - -# Class Methods -## render(name , write_to: nil) [](#method-c-render) -This templates out a file using ERB with the given locals. The locals are -derived from the config.yml file. - diff --git a/example/ruby/Prism/Template/ConfigComment.md b/example/ruby/Prism/Template/ConfigComment.md deleted file mode 100644 index 504cd8a..0000000 --- a/example/ruby/Prism/Template/ConfigComment.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Prism::Template::ConfigComment -**Inherits:** Object - - -A comment attached to a field or node. - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## each_java_line(&block) [](#method-i-each_java_line) - -## each_line(&block) [](#method-i-each_line) - -## initialize(value) [](#method-i-initialize) - -**@return** [ConfigComment] a new instance of ConfigComment - diff --git a/example/ruby/Prism/Template/ConstantField.md b/example/ruby/Prism/Template/ConstantField.md deleted file mode 100644 index d0835ff..0000000 --- a/example/ruby/Prism/Template/ConstantField.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::ConstantField -**Inherits:** Prism::Template::Field - - -This represents a field on a node that is the ID of a string interned through -the parser's constant pool. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/ConstantListField.md b/example/ruby/Prism/Template/ConstantListField.md deleted file mode 100644 index e9afbc0..0000000 --- a/example/ruby/Prism/Template/ConstantListField.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::ConstantListField -**Inherits:** Prism::Template::Field - - -This represents a field on a node that is a list of IDs that are associated -with strings interned through the parser's constant pool. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/DoubleField.md b/example/ruby/Prism/Template/DoubleField.md deleted file mode 100644 index d9985e3..0000000 --- a/example/ruby/Prism/Template/DoubleField.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::DoubleField -**Inherits:** Prism::Template::Field - - -This represents a double-precision floating point number. When it gets to Ruby -it will be a Float. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/Error.md b/example/ruby/Prism/Template/Error.md deleted file mode 100644 index 52f5855..0000000 --- a/example/ruby/Prism/Template/Error.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::Error -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [Error] a new instance of Error - diff --git a/example/ruby/Prism/Template/Field.md b/example/ruby/Prism/Template/Field.md deleted file mode 100644 index f32caa6..0000000 --- a/example/ruby/Prism/Template/Field.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Prism::Template::Field -**Inherits:** Object - - -This represents a field on a node. It contains all of the necessary -information to template out the code for that field. - - -# Attributes -## comment[RW] [](#attribute-i-comment) -Returns the value of attribute comment. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## each_comment_java_line(&block) [](#method-i-each_comment_java_line) - -## each_comment_line(&block) [](#method-i-each_comment_line) - -## initialize(name:, comment:nil, **options) [](#method-i-initialize) - -**@return** [Field] a new instance of Field - -## semantic_field?() [](#method-i-semantic_field?) - -**@return** [Boolean] - -## should_be_serialized?() [](#method-i-should_be_serialized?) - -**@return** [Boolean] - diff --git a/example/ruby/Prism/Template/Flags.md b/example/ruby/Prism/Template/Flags.md deleted file mode 100644 index 94700c7..0000000 --- a/example/ruby/Prism/Template/Flags.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Prism::Template::Flags -**Inherits:** Object - - -Represents a set of flags that should be internally represented with an enum. - - -# Class Methods -## empty() [](#method-c-empty) -# Attributes -## comment[RW] [](#attribute-i-comment) -Returns the value of attribute comment. - -## human[RW] [](#attribute-i-human) -Returns the value of attribute human. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## values[RW] [](#attribute-i-values) -Returns the value of attribute values. - - -#Instance Methods -## initialize(config) [](#method-i-initialize) - -**@return** [Flags] a new instance of Flags - diff --git a/example/ruby/Prism/Template/Flags/Flag.md b/example/ruby/Prism/Template/Flags/Flag.md deleted file mode 100644 index ad63aa1..0000000 --- a/example/ruby/Prism/Template/Flags/Flag.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Prism::Template::Flags::Flag -**Inherits:** Object - - -Represents an individual flag within a set of flags. - - -# Attributes -## camelcase[RW] [](#attribute-i-camelcase) -Returns the value of attribute camelcase. - -## comment[RW] [](#attribute-i-comment) -Returns the value of attribute comment. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(config) [](#method-i-initialize) - -**@return** [Flag] a new instance of Flag - diff --git a/example/ruby/Prism/Template/IntegerField.md b/example/ruby/Prism/Template/IntegerField.md deleted file mode 100644 index bd34e90..0000000 --- a/example/ruby/Prism/Template/IntegerField.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::IntegerField -**Inherits:** Prism::Template::Field - - -This represents an arbitrarily-sized integer. When it gets to Ruby it will be -an Integer. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/JavaDoc.md b/example/ruby/Prism/Template/JavaDoc.md deleted file mode 100644 index 0692263..0000000 --- a/example/ruby/Prism/Template/JavaDoc.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Prism::Template::JavaDoc - - -This module contains methods for escaping characters in JavaDoc comments. - - -# Class Methods -## escape(value ) [](#method-c-escape) - diff --git a/example/ruby/Prism/Template/LocationField.md b/example/ruby/Prism/Template/LocationField.md deleted file mode 100644 index bd307e5..0000000 --- a/example/ruby/Prism/Template/LocationField.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::Template::LocationField -**Inherits:** Prism::Template::Field - - -This represents a field on a node that is a location. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - -## semantic_field?() [](#method-i-semantic_field?) - -**@return** [Boolean] - diff --git a/example/ruby/Prism/Template/NodeField.md b/example/ruby/Prism/Template/NodeField.md deleted file mode 100644 index ee3629b..0000000 --- a/example/ruby/Prism/Template/NodeField.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::NodeField -**Inherits:** Prism::Template::NodeKindField - - -This represents a field on a node that is itself a node. We pass them as -references and store them as references. - - - -#Instance Methods -## check_field_kind() [](#method-i-check_field_kind) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/NodeKindField.md b/example/ruby/Prism/Template/NodeKindField.md deleted file mode 100644 index e14556c..0000000 --- a/example/ruby/Prism/Template/NodeKindField.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Prism::Template::NodeKindField -**Inherits:** Prism::Template::Field - - -Some node fields can be specialized if they point to a specific kind of node -and not just a generic node. - - - -#Instance Methods -## c_type() [](#method-i-c_type) - -## initialize(kind:, **options) [](#method-i-initialize) - -**@return** [NodeKindField] a new instance of NodeKindField - -## java_cast() [](#method-i-java_cast) - -## java_type() [](#method-i-java_type) - -## ruby_type() [](#method-i-ruby_type) - -## specific_kind() [](#method-i-specific_kind) - -## union_kind() [](#method-i-union_kind) - diff --git a/example/ruby/Prism/Template/NodeListField.md b/example/ruby/Prism/Template/NodeListField.md deleted file mode 100644 index a42df80..0000000 --- a/example/ruby/Prism/Template/NodeListField.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Prism::Template::NodeListField -**Inherits:** Prism::Template::NodeKindField - - -This represents a field on a node that is a list of nodes. We pass them as -references and store them directly on the struct. - - - -#Instance Methods -## check_field_kind() [](#method-i-check_field_kind) - -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/NodeType.md b/example/ruby/Prism/Template/NodeType.md deleted file mode 100644 index f0795d4..0000000 --- a/example/ruby/Prism/Template/NodeType.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Prism::Template::NodeType -**Inherits:** Object - - -This class represents a node in the tree, configured by the config.yml file in -YAML format. It contains information about the name of the node and the -various child nodes it contains. - - -# Attributes -## comment[RW] [](#attribute-i-comment) -Returns the value of attribute comment. - -## fields[RW] [](#attribute-i-fields) -Returns the value of attribute fields. - -## flags[RW] [](#attribute-i-flags) -Returns the value of attribute flags. - -## human[RW] [](#attribute-i-human) -Returns the value of attribute human. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## newline[RW] [](#attribute-i-newline) -Returns the value of attribute newline. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## each_comment_java_line(&block) [](#method-i-each_comment_java_line) - -## each_comment_line(&block) [](#method-i-each_comment_line) - -## initialize(config, flags) [](#method-i-initialize) - -**@return** [NodeType] a new instance of NodeType - -## needs_serialized_length?() [](#method-i-needs_serialized_length?) -Should emit serialized length of node so implementations can skip the node to -enable lazy parsing. - -**@return** [Boolean] - -## semantic_fields() [](#method-i-semantic_fields) - diff --git a/example/ruby/Prism/Template/OptionalConstantField.md b/example/ruby/Prism/Template/OptionalConstantField.md deleted file mode 100644 index 7824789..0000000 --- a/example/ruby/Prism/Template/OptionalConstantField.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::OptionalConstantField -**Inherits:** Prism::Template::Field - - -This represents a field on a node that is the ID of a string interned through -the parser's constant pool and can be optionally null. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/OptionalLocationField.md b/example/ruby/Prism/Template/OptionalLocationField.md deleted file mode 100644 index a2147df..0000000 --- a/example/ruby/Prism/Template/OptionalLocationField.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Prism::Template::OptionalLocationField -**Inherits:** Prism::Template::Field - - -This represents a field on a node that is a location that is optional. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - -## semantic_field?() [](#method-i-semantic_field?) - -**@return** [Boolean] - diff --git a/example/ruby/Prism/Template/OptionalNodeField.md b/example/ruby/Prism/Template/OptionalNodeField.md deleted file mode 100644 index e12fc67..0000000 --- a/example/ruby/Prism/Template/OptionalNodeField.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::OptionalNodeField -**Inherits:** Prism::Template::NodeKindField - - -This represents a field on a node that is itself a node and can be optionally -null. We pass them as references and store them as references. - - - -#Instance Methods -## check_field_kind() [](#method-i-check_field_kind) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/StringField.md b/example/ruby/Prism/Template/StringField.md deleted file mode 100644 index 87f9005..0000000 --- a/example/ruby/Prism/Template/StringField.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::Template::StringField -**Inherits:** Prism::Template::Field - - -This represents a field on a node that is a string. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/Token.md b/example/ruby/Prism/Template/Token.md deleted file mode 100644 index 1d4f7a2..0000000 --- a/example/ruby/Prism/Template/Token.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Prism::Template::Token -**Inherits:** Object - - -This represents a token in the lexer. - - -# Attributes -## comment[RW] [](#attribute-i-comment) -Returns the value of attribute comment. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## initialize(config) [](#method-i-initialize) - -**@return** [Token] a new instance of Token - diff --git a/example/ruby/Prism/Template/UInt32Field.md b/example/ruby/Prism/Template/UInt32Field.md deleted file mode 100644 index 5631e09..0000000 --- a/example/ruby/Prism/Template/UInt32Field.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::Template::UInt32Field -**Inherits:** Prism::Template::Field - - -This represents an integer field. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/UInt8Field.md b/example/ruby/Prism/Template/UInt8Field.md deleted file mode 100644 index bab3f89..0000000 --- a/example/ruby/Prism/Template/UInt8Field.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::Template::UInt8Field -**Inherits:** Prism::Template::Field - - -This represents an integer field. - - - -#Instance Methods -## java_type() [](#method-i-java_type) - -## rbi_class() [](#method-i-rbi_class) - -## rbs_class() [](#method-i-rbs_class) - diff --git a/example/ruby/Prism/Template/Warning.md b/example/ruby/Prism/Template/Warning.md deleted file mode 100644 index fde6879..0000000 --- a/example/ruby/Prism/Template/Warning.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Prism::Template::Warning -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [Warning] a new instance of Warning - diff --git a/example/ruby/Prism/TestCase.md b/example/ruby/Prism/TestCase.md deleted file mode 100644 index 0beb370..0000000 --- a/example/ruby/Prism/TestCase.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Prism::TestCase -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## each_encoding() [](#method-c-each_encoding) -Yield each encoding that we want to test, along with a range of the codepoints -that should be tested. -**@yield** [Encoding::ASCII_8BIT, codepoints_1byte] - - diff --git a/example/ruby/Prism/TestCase/Fixture.md b/example/ruby/Prism/TestCase/Fixture.md deleted file mode 100644 index f4a554d..0000000 --- a/example/ruby/Prism/TestCase/Fixture.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Prism::TestCase::Fixture -**Inherits:** Object - - -We have a set of fixtures that we use to test various aspects of the parser. -They are all represented as .txt files under the test/prism/fixtures -directory. Typically in test files you will find calls to Fixture.each which -yields Fixture objects to the given block. These are used to define test -methods that assert against each fixture in some way. - - -# Class Methods -## each(except: [], &block ) [](#method-c-each) -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - -#Instance Methods -## full_path() [](#method-i-full_path) - -## initialize(path) [](#method-i-initialize) - -**@return** [Fixture] a new instance of Fixture - -## read() [](#method-i-read) - -## snapshot_path() [](#method-i-snapshot_path) - -## test_name() [](#method-i-test_name) - diff --git a/example/ruby/Prism/TestCompilePrism.md b/example/ruby/Prism/TestCompilePrism.md deleted file mode 100644 index ce86d59..0000000 --- a/example/ruby/Prism/TestCompilePrism.md +++ /dev/null @@ -1,384 +0,0 @@ -# Class: Prism::TestCompilePrism -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_AliasGlobalVariableNode() [](#method-i-test_AliasGlobalVariableNode) -Methods / parameters # - -## test_AliasMethodNode() [](#method-i-test_AliasMethodNode) - -## test_AlternationPatternNode() [](#method-i-test_AlternationPatternNode) -Pattern matching # - -## test_AndNode() [](#method-i-test_AndNode) -Jumps # - -## test_ArgumentsNode() [](#method-i-test_ArgumentsNode) -Calls / arguments # - -## test_ArrayNode() [](#method-i-test_ArrayNode) -Structures # - -## test_ArrayPatternNode() [](#method-i-test_ArrayPatternNode) - -## test_AssocNode() [](#method-i-test_AssocNode) - -## test_AssocSplatNode() [](#method-i-test_AssocSplatNode) - -## test_BackReferenceReadNode() [](#method-i-test_BackReferenceReadNode) -Reads # - -## test_BeginNode() [](#method-i-test_BeginNode) -Throws # - -## test_BlockArgumentNode() [](#method-i-test_BlockArgumentNode) - -## test_BlockLocalVariableNode() [](#method-i-test_BlockLocalVariableNode) - -## test_BlockNode() [](#method-i-test_BlockNode) -Scopes/statements # - -## test_BlockParameterNode() [](#method-i-test_BlockParameterNode) - -## test_BlockParametersNode() [](#method-i-test_BlockParametersNode) - -## test_BreakNode() [](#method-i-test_BreakNode) - -## test_CallAndWriteNode() [](#method-i-test_CallAndWriteNode) - -## test_CallNode() [](#method-i-test_CallNode) - -## test_CallOperatorWriteNode() [](#method-i-test_CallOperatorWriteNode) - -## test_CallOrWriteNode() [](#method-i-test_CallOrWriteNode) - -## test_CapturePatternNode() [](#method-i-test_CapturePatternNode) - -## test_CaseMatchNode() [](#method-i-test_CaseMatchNode) - -## test_CaseNode() [](#method-i-test_CaseNode) - -## test_ClassNode() [](#method-i-test_ClassNode) - -## test_ClassVariableAndWriteNode() [](#method-i-test_ClassVariableAndWriteNode) -Writes # - -## test_ClassVariableOperatorWriteNode() [](#method-i-test_ClassVariableOperatorWriteNode) - -## test_ClassVariableOrWriteNode() [](#method-i-test_ClassVariableOrWriteNode) - -## test_ClassVariableReadNode() [](#method-i-test_ClassVariableReadNode) - -## test_ClassVariableTargetNode() [](#method-i-test_ClassVariableTargetNode) -Multi-writes # - -## test_ClassVariableWriteNode() [](#method-i-test_ClassVariableWriteNode) - -## test_ConstantAndWriteNode() [](#method-i-test_ConstantAndWriteNode) - -## test_ConstantOperatorWriteNode() [](#method-i-test_ConstantOperatorWriteNode) - -## test_ConstantOrWriteNode() [](#method-i-test_ConstantOrWriteNode) - -## test_ConstantPathAndWriteNode() [](#method-i-test_ConstantPathAndWriteNode) - -## test_ConstantPathNode() [](#method-i-test_ConstantPathNode) - -## test_ConstantPathOperatorWriteNode() [](#method-i-test_ConstantPathOperatorWriteNode) - -## test_ConstantPathOrWriteNode() [](#method-i-test_ConstantPathOrWriteNode) - -## test_ConstantPathTargetNode() [](#method-i-test_ConstantPathTargetNode) - -## test_ConstantPathWriteNode() [](#method-i-test_ConstantPathWriteNode) - -## test_ConstantReadNode() [](#method-i-test_ConstantReadNode) - -## test_ConstantTargetNode() [](#method-i-test_ConstantTargetNode) - -## test_ConstantWriteNode() [](#method-i-test_ConstantWriteNode) - -## test_DefNode() [](#method-i-test_DefNode) -Many of these tests are versions of tests at bootstraptest/test_method.rb - -## test_DefinedNode() [](#method-i-test_DefinedNode) - -## test_ElseNode() [](#method-i-test_ElseNode) - -## test_EmbeddedStatementsNode() [](#method-i-test_EmbeddedStatementsNode) -String-likes # - -## test_EmbeddedVariableNode() [](#method-i-test_EmbeddedVariableNode) - -## test_EnsureNode() [](#method-i-test_EnsureNode) - -## test_FalseNode() [](#method-i-test_FalseNode) -Literals # - -## test_FindPatternNode() [](#method-i-test_FindPatternNode) - -## test_FlipFlopNode() [](#method-i-test_FlipFlopNode) - -## test_FloatNode() [](#method-i-test_FloatNode) - -## test_ForNode() [](#method-i-test_ForNode) - -## test_ForwardingArgumentsNode() [](#method-i-test_ForwardingArgumentsNode) - -## test_ForwardingSuperNode() [](#method-i-test_ForwardingSuperNode) - -## test_FowardingParameterNode() [](#method-i-test_FowardingParameterNode) - -## test_GlobalVariableAndWriteNode() [](#method-i-test_GlobalVariableAndWriteNode) - -## test_GlobalVariableOperatorWriteNode() [](#method-i-test_GlobalVariableOperatorWriteNode) - -## test_GlobalVariableOrWriteNode() [](#method-i-test_GlobalVariableOrWriteNode) - -## test_GlobalVariableReadNode() [](#method-i-test_GlobalVariableReadNode) - -## test_GlobalVariableTargetNode() [](#method-i-test_GlobalVariableTargetNode) - -## test_GlobalVariableWriteNode() [](#method-i-test_GlobalVariableWriteNode) - -## test_HashNode() [](#method-i-test_HashNode) - -## test_HashPatternNode() [](#method-i-test_HashPatternNode) - -## test_IfNode() [](#method-i-test_IfNode) - -## test_ImaginaryNode() [](#method-i-test_ImaginaryNode) - -## test_ImplicitNode() [](#method-i-test_ImplicitNode) - -## test_InstanceVariableAndWriteNode() [](#method-i-test_InstanceVariableAndWriteNode) - -## test_InstanceVariableOperatorWriteNode() [](#method-i-test_InstanceVariableOperatorWriteNode) - -## test_InstanceVariableOrWriteNode() [](#method-i-test_InstanceVariableOrWriteNode) - -## test_InstanceVariableReadNode() [](#method-i-test_InstanceVariableReadNode) - -## test_InstanceVariableTargetNode() [](#method-i-test_InstanceVariableTargetNode) - -## test_InstanceVariableWriteNode() [](#method-i-test_InstanceVariableWriteNode) - -## test_IntegerNode() [](#method-i-test_IntegerNode) - -## test_InterpolatedMatchLastLineNode() [](#method-i-test_InterpolatedMatchLastLineNode) - -## test_InterpolatedRegularExpressionNode() [](#method-i-test_InterpolatedRegularExpressionNode) - -## test_InterpolatedStringNode() [](#method-i-test_InterpolatedStringNode) - -## test_InterpolatedSymbolNode() [](#method-i-test_InterpolatedSymbolNode) - -## test_InterpolatedXStringNode() [](#method-i-test_InterpolatedXStringNode) - -## test_KeywordHashNode() [](#method-i-test_KeywordHashNode) - -## test_KeywordRestParameterNode() [](#method-i-test_KeywordRestParameterNode) - -## test_LambdaNode() [](#method-i-test_LambdaNode) - -## test_LambdaNode_with_multiline_args() [](#method-i-test_LambdaNode_with_multiline_args) - -## test_LocalVariableAndWriteNode() [](#method-i-test_LocalVariableAndWriteNode) - -## test_LocalVariableOperatorWriteNode() [](#method-i-test_LocalVariableOperatorWriteNode) - -## test_LocalVariableOrWriteNode() [](#method-i-test_LocalVariableOrWriteNode) - -## test_LocalVariableReadNode() [](#method-i-test_LocalVariableReadNode) - -## test_LocalVariableTargetNode() [](#method-i-test_LocalVariableTargetNode) - -## test_LocalVariableWriteNode() [](#method-i-test_LocalVariableWriteNode) - -## test_MatchLastLineNode() [](#method-i-test_MatchLastLineNode) - -## test_MatchPredicateNode() [](#method-i-test_MatchPredicateNode) - -## test_MatchRequiredNode() [](#method-i-test_MatchRequiredNode) - -## test_MatchWriteNode() [](#method-i-test_MatchWriteNode) - -## test_MissingNode() [](#method-i-test_MissingNode) -Errors # - -## test_ModuleNode() [](#method-i-test_ModuleNode) - -## test_MultiTargetNode() [](#method-i-test_MultiTargetNode) - -## test_MultiWriteNode() [](#method-i-test_MultiWriteNode) - -## test_NextNode() [](#method-i-test_NextNode) - -## test_NilNode() [](#method-i-test_NilNode) - -## test_NoKeywordsParameterNode() [](#method-i-test_NoKeywordsParameterNode) - -## test_NumberedReferenceReadNode() [](#method-i-test_NumberedReferenceReadNode) - -## test_OptionalKeywordParameterNode() [](#method-i-test_OptionalKeywordParameterNode) - -## test_OptionalParameterNode() [](#method-i-test_OptionalParameterNode) - -## test_OrNode() [](#method-i-test_OrNode) - -## test_ParametersNode() [](#method-i-test_ParametersNode) - -## test_ParenthesesNode() [](#method-i-test_ParenthesesNode) - -## test_PinnedExpressionNode() [](#method-i-test_PinnedExpressionNode) - -## test_PinnedVariableNode() [](#method-i-test_PinnedVariableNode) - -## test_PostExecutionNode() [](#method-i-test_PostExecutionNode) - -## test_PreExecutionNode() [](#method-i-test_PreExecutionNode) - -## test_ProgramNode() [](#method-i-test_ProgramNode) - -## test_RangeNode() [](#method-i-test_RangeNode) - -## test_RationalNode() [](#method-i-test_RationalNode) - -## test_RedoNode() [](#method-i-test_RedoNode) - -## test_RegularExpressionNode() [](#method-i-test_RegularExpressionNode) - -## test_RequiredKeywordParameterNode() [](#method-i-test_RequiredKeywordParameterNode) - -## test_RequiredParameterNode() [](#method-i-test_RequiredParameterNode) - -## test_RescueModifierNode() [](#method-i-test_RescueModifierNode) - -## test_RescueNode() [](#method-i-test_RescueNode) - -## test_RestParameterNode() [](#method-i-test_RestParameterNode) - -## test_RetryNode() [](#method-i-test_RetryNode) - -## test_ReturnNode() [](#method-i-test_ReturnNode) - -## test_ScopeNode() [](#method-i-test_ScopeNode) - -## test_SelfNode() [](#method-i-test_SelfNode) - -## test_SingletonClassNode() [](#method-i-test_SingletonClassNode) - -## test_SourceEncodingNode() [](#method-i-test_SourceEncodingNode) - -## test_SourceFileNode() [](#method-i-test_SourceFileNode) - -## test_SourceLineNode() [](#method-i-test_SourceLineNode) - -## test_SplatNode() [](#method-i-test_SplatNode) - -## test_StatementsNode() [](#method-i-test_StatementsNode) - -## test_StringNode() [](#method-i-test_StringNode) - -## test_StringNode_frozen_string_literal_default() [](#method-i-test_StringNode_frozen_string_literal_default) - -## test_StringNode_frozen_string_literal_false() [](#method-i-test_StringNode_frozen_string_literal_false) - -## test_StringNode_frozen_string_literal_true() [](#method-i-test_StringNode_frozen_string_literal_true) - -## test_SuperNode() [](#method-i-test_SuperNode) - -## test_SymbolNode() [](#method-i-test_SymbolNode) - -## test_TrueNode() [](#method-i-test_TrueNode) - -## test_UndefNode() [](#method-i-test_UndefNode) - -## test_UnlessNode() [](#method-i-test_UnlessNode) - -## test_UntilNode() [](#method-i-test_UntilNode) - -## test_WhileNode() [](#method-i-test_WhileNode) - -## test_XStringNode() [](#method-i-test_XStringNode) - -## test_YieldNode() [](#method-i-test_YieldNode) - -## test_break_runs_ensure() [](#method-i-test_break_runs_ensure) - -## test_complex_default_params() [](#method-i-test_complex_default_params) - -## test_concatenated_StringNode() [](#method-i-test_concatenated_StringNode) - -## test_encoding() [](#method-i-test_encoding) -Encoding # - -## test_ensure_in_methods() [](#method-i-test_ensure_in_methods) - -## test_eval() [](#method-i-test_eval) -Miscellaneous # - -## test_forward_parameters() [](#method-i-test_forward_parameters) - -## test_forward_parameters_block() [](#method-i-test_forward_parameters_block) - -## test_keyword_method_params_only() [](#method-i-test_keyword_method_params_only) - -## test_keyword_method_params_with_splat() [](#method-i-test_keyword_method_params_with_splat) - -## test_leading_splat_and_keyword_method_params() [](#method-i-test_leading_splat_and_keyword_method_params) - -## test_locals_in_parameters() [](#method-i-test_locals_in_parameters) - -## test_method_parameters() [](#method-i-test_method_parameters) - -## test_numbered_params() [](#method-i-test_numbered_params) - -## test_parse_file() [](#method-i-test_parse_file) - -## test_positional_and_splat_keyword_method_params() [](#method-i-test_positional_and_splat_keyword_method_params) - -## test_positional_and_splat_method_params() [](#method-i-test_positional_and_splat_method_params) - -## test_positional_with_splat_and_keyword_method_params() [](#method-i-test_positional_with_splat_and_keyword_method_params) - -## test_positional_with_splat_and_splat_keyword_method_params() [](#method-i-test_positional_with_splat_and_splat_keyword_method_params) - -## test_pow_parameters() [](#method-i-test_pow_parameters) - -## test_repeated_block_params() [](#method-i-test_repeated_block_params) - -## test_repeated_block_underscore() [](#method-i-test_repeated_block_underscore) - -## test_repeated_kw_rest_underscore() [](#method-i-test_repeated_kw_rest_underscore) - -## test_repeated_method_params() [](#method-i-test_repeated_method_params) - -## test_repeated_optional_underscore() [](#method-i-test_repeated_optional_underscore) - -## test_repeated_proc_params() [](#method-i-test_repeated_proc_params) - -## test_repeated_required_keyword_underscore() [](#method-i-test_repeated_required_keyword_underscore) - -## test_repeated_required_post_underscore() [](#method-i-test_repeated_required_post_underscore) - -## test_repeated_required_underscore() [](#method-i-test_repeated_required_underscore) - -## test_repeated_splat_underscore() [](#method-i-test_repeated_splat_underscore) - -## test_required_kwarg_ordering() [](#method-i-test_required_kwarg_ordering) - -## test_rescue_with_ensure() [](#method-i-test_rescue_with_ensure) - -## test_splat_params_with_no_lefties() [](#method-i-test_splat_params_with_no_lefties) - -## test_star_parameters() [](#method-i-test_star_parameters) - -## test_trailing_comma_on_block() [](#method-i-test_trailing_comma_on_block) - -## test_trailing_keyword_method_params() [](#method-i-test_trailing_keyword_method_params) - diff --git a/example/ruby/Prism/TestCompilePrism/Subclass.md b/example/ruby/Prism/TestCompilePrism/Subclass.md deleted file mode 100644 index 5dc72c9..0000000 --- a/example/ruby/Prism/TestCompilePrism/Subclass.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Prism::TestCompilePrism::Subclass -**Inherits:** Object - - -Subclass is used for tests which need it - - - diff --git a/example/ruby/Prism/Token.md b/example/ruby/Prism/Token.md deleted file mode 100644 index 988df4c..0000000 --- a/example/ruby/Prism/Token.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Prism::Token -**Inherits:** Object - - -This represents a token from the Ruby source. - - -# Attributes -## type[RW] [](#attribute-i-type) -The type of token that this token is. - -## value[RW] [](#attribute-i-value) -A byteslice of the source that this token represents. - - -#Instance Methods -## ==(other) [](#method-i-==) -Returns true if the given other token is equal to this token. - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Implement the hash pattern matching interface for Token. - -## initialize(source, type, value, location) [](#method-i-initialize) -Create a new token object with the given type, value, and location. - -**@return** [Token] a new instance of Token - -## inspect() [](#method-i-inspect) -Returns a string representation of this token. - -## location() [](#method-i-location) -A Location object representing the location of this token in the source. - -## pretty_print(q) [](#method-i-pretty_print) -Implement the pretty print interface for Token. - diff --git a/example/ruby/Prism/Translation.md b/example/ruby/Prism/Translation.md deleted file mode 100644 index 40f1b99..0000000 --- a/example/ruby/Prism/Translation.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: Prism::Translation - - -This module is responsible for converting the prism syntax tree into other -syntax trees. - - - diff --git a/example/ruby/Prism/Translation/Parser.md b/example/ruby/Prism/Translation/Parser.md deleted file mode 100644 index b129b75..0000000 --- a/example/ruby/Prism/Translation/Parser.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Prism::Translation::Parser -**Inherits:** Parser::Base - - -This class is the entry-point for converting a prism syntax tree into the -whitequark/parser gem's syntax tree. It inherits from the base parser for the -parser gem, and overrides the parse* methods to parse with prism and then -translate. - - - -#Instance Methods -## default_encoding() [](#method-i-default_encoding) -The default encoding for Ruby files is UTF-8. - -## parse(source_buffer) [](#method-i-parse) -Parses a source buffer and returns the AST. - -## parse_with_comments(source_buffer) [](#method-i-parse_with_comments) -Parses a source buffer and returns the AST and the source code comments. - -## tokenize(source_buffer, recoverfalse) [](#method-i-tokenize) -Parses a source buffer and returns the AST, the source code comments, and the -tokens emitted by the lexer. - -## try_declare_numparam(node) [](#method-i-try_declare_numparam) -Since prism resolves num params for us, we don't need to support this kind of -logic here. - -## version() [](#method-i-version) -:nodoc: - -## yyerror() [](#method-i-yyerror) -:nodoc: - diff --git a/example/ruby/Prism/Translation/Parser/Compiler.md b/example/ruby/Prism/Translation/Parser/Compiler.md deleted file mode 100644 index 2f46260..0000000 --- a/example/ruby/Prism/Translation/Parser/Compiler.md +++ /dev/null @@ -1,579 +0,0 @@ -# Class: Prism::Translation::Parser::Compiler -**Inherits:** Prism::Compiler - - -A visitor that knows how to convert a prism syntax tree into the -whitequark/parser gem's syntax tree. - - -# Attributes -## builder[RW] [](#attribute-i-builder) -The Parser::Builders::Default instance that is being used to build the AST. - -## forwarding[RW] [](#attribute-i-forwarding) -The types of values that can be forwarded in the current scope. - -## in_destructure[RW] [](#attribute-i-in_destructure) -Whether or not the current node is in a destructure. - -## in_pattern[RW] [](#attribute-i-in_pattern) -Whether or not the current node is in a pattern. - -## offset_cache[RW] [](#attribute-i-offset_cache) -The offset cache that is used to map between byte and character offsets in the -file. - -## parser[RW] [](#attribute-i-parser) -The Parser::Base instance that is being used to build the AST. - -## source_buffer[RW] [](#attribute-i-source_buffer) -The Parser::Source::Buffer instance that is holding a reference to the source -code. - - -#Instance Methods -## initialize(parser, offset_cache, forwarding:[], in_destructure:false, in_pattern:false) [](#method-i-initialize) -Initialize a new compiler with the given parser, offset cache, and options. - -**@return** [Compiler] a new instance of Compiler - -## visit_alias_global_variable_node(node) [](#method-i-visit_alias_global_variable_node) -alias $foo $bar ^^^^^^^^^^^^^^^ - -## visit_alias_method_node(node) [](#method-i-visit_alias_method_node) -alias foo bar ^^^^^^^^^^^^^ - -## visit_alternation_pattern_node(node) [](#method-i-visit_alternation_pattern_node) -foo => bar | baz - ^^^^^^^^^ - -## visit_and_node(node) [](#method-i-visit_and_node) -a and b ^^^^^^^ - -## visit_arguments_node(node) [](#method-i-visit_arguments_node) -foo(bar) - ^^^ - -## visit_array_node(node) [](#method-i-visit_array_node) -: ^^ - - -## visit_array_pattern_node(node) [](#method-i-visit_array_pattern_node) -foo => [bar] - ^^^^^ - -## visit_assoc_node(node) [](#method-i-visit_assoc_node) -{ a: 1 } - ^^^^ - -## visit_assoc_splat_node(node) [](#method-i-visit_assoc_splat_node) -def foo(**); bar(**); end - ^^ - -{ **foo } - ^^^^^ - -## visit_back_reference_read_node(node) [](#method-i-visit_back_reference_read_node) -$+ ^^ - -## visit_begin_node(node) [](#method-i-visit_begin_node) -begin end ^^^^^^^^^ - -## visit_block_argument_node(node) [](#method-i-visit_block_argument_node) -foo(&bar) - ^^^^ - -## visit_block_local_variable_node(node) [](#method-i-visit_block_local_variable_node) -foo { |; bar| } - ^^^ - -## visit_block_node(node) [](#method-i-visit_block_node) -A block on a keyword or method call. - -**@raise** [CompilationError] - -## visit_block_parameter_node(node) [](#method-i-visit_block_parameter_node) -def foo(&bar); end - ^^^^ - -## visit_block_parameters_node(node) [](#method-i-visit_block_parameters_node) -A block's parameters. - -## visit_break_node(node) [](#method-i-visit_break_node) -break ^^^^^ - -break foo ^^^^^^^^^ - -## visit_call_and_write_node(node) [](#method-i-visit_call_and_write_node) -foo.bar &&= baz ^^^^^^^^^^^^^^^ - -## visit_call_node(node) [](#method-i-visit_call_node) -foo ^^^ - -foo.bar ^^^^^^^ - -foo.bar() {} ^^^^^^^^^^^^ - -## visit_call_operator_write_node(node) [](#method-i-visit_call_operator_write_node) -foo.bar += baz ^^^^^^^^^^^^^^^ - -## visit_call_or_write_node(node) [](#method-i-visit_call_or_write_node) -foo.bar ||= baz ^^^^^^^^^^^^^^^ - -## visit_call_target_node(node) [](#method-i-visit_call_target_node) -foo.bar, = 1 ^^^^^^^ - -## visit_capture_pattern_node(node) [](#method-i-visit_capture_pattern_node) -foo => bar => baz - ^^^^^^^^^^ - -## visit_case_match_node(node) [](#method-i-visit_case_match_node) -case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^ - -## visit_case_node(node) [](#method-i-visit_case_node) -case foo; when bar; end ^^^^^^^^^^^^^^^^^^^^^^^ - -## visit_class_node(node) [](#method-i-visit_class_node) -class Foo; end ^^^^^^^^^^^^^^ - -## visit_class_variable_and_write_node(node) [](#method-i-visit_class_variable_and_write_node) -@@foo &&= bar ^^^^^^^^^^^^^ - -## visit_class_variable_operator_write_node(node) [](#method-i-visit_class_variable_operator_write_node) -@@foo += bar ^^^^^^^^^^^^ - -## visit_class_variable_or_write_node(node) [](#method-i-visit_class_variable_or_write_node) -@@foo ||= bar ^^^^^^^^^^^^^ - -## visit_class_variable_read_node(node) [](#method-i-visit_class_variable_read_node) -@@foo ^^^^^ - -## visit_class_variable_target_node(node) [](#method-i-visit_class_variable_target_node) -@@foo, = bar ^^^^^ - -## visit_class_variable_write_node(node) [](#method-i-visit_class_variable_write_node) -@@foo = 1 ^^^^^^^^^ - -## visit_constant_and_write_node(node) [](#method-i-visit_constant_and_write_node) -Foo &&= bar ^^^^^^^^^^^^ - -## visit_constant_operator_write_node(node) [](#method-i-visit_constant_operator_write_node) -Foo += bar ^^^^^^^^^^^ - -## visit_constant_or_write_node(node) [](#method-i-visit_constant_or_write_node) -Foo ||= bar ^^^^^^^^^^^^ - -## visit_constant_path_and_write_node(node) [](#method-i-visit_constant_path_and_write_node) -Foo::Bar &&= baz ^^^^^^^^^^^^^^^^ - -## visit_constant_path_node(node) [](#method-i-visit_constant_path_node) -Foo::Bar ^^^^^^^^ - -## visit_constant_path_operator_write_node(node) [](#method-i-visit_constant_path_operator_write_node) -Foo::Bar += baz ^^^^^^^^^^^^^^^ - -## visit_constant_path_or_write_node(node) [](#method-i-visit_constant_path_or_write_node) -Foo::Bar ||= baz ^^^^^^^^^^^^^^^^ - -## visit_constant_path_target_node(node) [](#method-i-visit_constant_path_target_node) -Foo::Bar, = baz ^^^^^^^^ - -## visit_constant_path_write_node(node) [](#method-i-visit_constant_path_write_node) -Foo::Bar = 1 ^^^^^^^^^^^^ - -Foo::Foo, Bar::Bar = 1 ^^^^^^^^ ^^^^^^^^ - -## visit_constant_read_node(node) [](#method-i-visit_constant_read_node) -Foo ^^^ - -## visit_constant_target_node(node) [](#method-i-visit_constant_target_node) -Foo, = bar ^^^ - -## visit_constant_write_node(node) [](#method-i-visit_constant_write_node) -Foo = 1 ^^^^^^^ - -Foo, Bar = 1 ^^^ ^^^ - -## visit_def_node(node) [](#method-i-visit_def_node) -def foo; end ^^^^^^^^^^^^ - -def self.foo; end ^^^^^^^^^^^^^^^^^ - -## visit_defined_node(node) [](#method-i-visit_defined_node) -defined? a ^^^^^^^^^^ - -defined?(a) ^^^^^^^^^^^ - -## visit_else_node(node) [](#method-i-visit_else_node) -if foo then bar else baz end - ^^^^^^^^^^^^ - -## visit_embedded_statements_node(node) [](#method-i-visit_embedded_statements_node) -"foo #{bar}" - ^^^^^^ - -## visit_embedded_variable_node(node) [](#method-i-visit_embedded_variable_node) -"foo #@bar" - ^^^^^ - -## visit_ensure_node(node) [](#method-i-visit_ensure_node) -begin; foo; ensure; bar; end - ^^^^^^^^^^^^ - -**@raise** [CompilationError] - -## visit_false_node(node) [](#method-i-visit_false_node) -false ^^^^^ - -## visit_find_pattern_node(node) [](#method-i-visit_find_pattern_node) -foo => [*, bar, *] - ^^^^^^^^^^^ - -## visit_float_node(node) [](#method-i-visit_float_node) -1.0 ^^^ - -## visit_for_node(node) [](#method-i-visit_for_node) -for foo in bar do end ^^^^^^^^^^^^^^^^^^^^^ - -## visit_forwarding_arguments_node(node) [](#method-i-visit_forwarding_arguments_node) -def foo(...); bar(...); end - ^^^ - -## visit_forwarding_parameter_node(node) [](#method-i-visit_forwarding_parameter_node) -def foo(...); end - ^^^ - -## visit_forwarding_super_node(node) [](#method-i-visit_forwarding_super_node) -super ^^^^^ - -super {} ^^^^^^^^ - -## visit_global_variable_and_write_node(node) [](#method-i-visit_global_variable_and_write_node) -$foo &&= bar ^^^^^^^^^^^^ - -## visit_global_variable_operator_write_node(node) [](#method-i-visit_global_variable_operator_write_node) -$foo += bar ^^^^^^^^^^^ - -## visit_global_variable_or_write_node(node) [](#method-i-visit_global_variable_or_write_node) -$foo ||= bar ^^^^^^^^^^^^ - -## visit_global_variable_read_node(node) [](#method-i-visit_global_variable_read_node) -$foo ^^^^ - -## visit_global_variable_target_node(node) [](#method-i-visit_global_variable_target_node) -$foo, = bar ^^^^ - -## visit_global_variable_write_node(node) [](#method-i-visit_global_variable_write_node) -$foo = 1 ^^^^^^^^ - -## visit_hash_node(node) [](#method-i-visit_hash_node) -{} ^^ - -## visit_hash_pattern_node(node) [](#method-i-visit_hash_pattern_node) -foo => {} - ^^ - -## visit_if_node(node) [](#method-i-visit_if_node) -if foo then bar end ^^^^^^^^^^^^^^^^^^^ - -bar if foo ^^^^^^^^^^ - -foo ? bar : baz ^^^^^^^^^^^^^^^ - -## visit_imaginary_node(node) [](#method-i-visit_imaginary_node) -1i ^^ - -## visit_implicit_node(node) [](#method-i-visit_implicit_node) -{ foo: } - ^^^^ - -**@raise** [CompilationError] - -## visit_implicit_rest_node(node) [](#method-i-visit_implicit_rest_node) -foo { |bar,| } - ^ - -**@raise** [CompilationError] - -## visit_in_node(node) [](#method-i-visit_in_node) -case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^ - -## visit_index_and_write_node(node) [](#method-i-visit_index_and_write_node) -[foo](bar) &&= baz ^^^^^^^^^^^^^^^^ - -## visit_index_operator_write_node(node) [](#method-i-visit_index_operator_write_node) -[foo](bar) += baz ^^^^^^^^^^^^^^^ - -## visit_index_or_write_node(node) [](#method-i-visit_index_or_write_node) -[foo](bar) ||= baz ^^^^^^^^^^^^^^^^ - -## visit_index_target_node(node) [](#method-i-visit_index_target_node) -[foo](bar), = 1 ^^^^^^^^ - -## visit_instance_variable_and_write_node(node) [](#method-i-visit_instance_variable_and_write_node) -^^^^^^^^^^^^ - -## visit_instance_variable_operator_write_node(node) [](#method-i-visit_instance_variable_operator_write_node) -^^^^^^^^^^^ - -## visit_instance_variable_or_write_node(node) [](#method-i-visit_instance_variable_or_write_node) -^^^^^^^^^^^^ - -## visit_instance_variable_read_node(node) [](#method-i-visit_instance_variable_read_node) -^^^^ - -## visit_instance_variable_target_node(node) [](#method-i-visit_instance_variable_target_node) -@foo, = bar ^^^^ - -## visit_instance_variable_write_node(node) [](#method-i-visit_instance_variable_write_node) -^^^^^^^^ - -## visit_integer_node(node) [](#method-i-visit_integer_node) -1 ^ - -## visit_interpolated_regular_expression_node(node) [](#method-i-visit_interpolated_regular_expression_node) -/foo #{bar}/ ^^^^^^^^^^^^ - -## visit_interpolated_string_node(node) [](#method-i-visit_interpolated_string_node) -"foo #{bar}" ^^^^^^^^^^^^ - -## visit_interpolated_symbol_node(node) [](#method-i-visit_interpolated_symbol_node) -:"foo #{bar}" ^^^^^^^^^^^^^ - -## visit_interpolated_x_string_node(node) [](#method-i-visit_interpolated_x_string_node) -`foo #{bar}` ^^^^^^^^^^^^ - -## visit_it_local_variable_read_node(node) [](#method-i-visit_it_local_variable_read_node) --> { it } - ^^ - -## visit_it_parameters_node(node) [](#method-i-visit_it_parameters_node) --> { it } ^^^^^^^^^ - -## visit_keyword_hash_node(node) [](#method-i-visit_keyword_hash_node) -foo(bar: baz) - ^^^^^^^^ - -## visit_keyword_rest_parameter_node(node) [](#method-i-visit_keyword_rest_parameter_node) -def foo(**bar); end - ^^^^^ - -def foo(**); end - ^^ - -## visit_lambda_node(node) [](#method-i-visit_lambda_node) --> {} ^^^^^ - -## visit_local_variable_and_write_node(node) [](#method-i-visit_local_variable_and_write_node) -foo &&= bar ^^^^^^^^^^^ - -## visit_local_variable_operator_write_node(node) [](#method-i-visit_local_variable_operator_write_node) -foo += bar ^^^^^^^^^^ - -## visit_local_variable_or_write_node(node) [](#method-i-visit_local_variable_or_write_node) -foo ||= bar ^^^^^^^^^^^ - -## visit_local_variable_read_node(node) [](#method-i-visit_local_variable_read_node) -foo ^^^ - -## visit_local_variable_target_node(node) [](#method-i-visit_local_variable_target_node) -foo, = bar ^^^ - -## visit_local_variable_write_node(node) [](#method-i-visit_local_variable_write_node) -foo = 1 ^^^^^^^ - -## visit_match_predicate_node(node) [](#method-i-visit_match_predicate_node) -foo in bar ^^^^^^^^^^ - -## visit_match_required_node(node) [](#method-i-visit_match_required_node) -foo => bar ^^^^^^^^^^ - -## visit_match_write_node(node) [](#method-i-visit_match_write_node) -/(?foo)/ =~ bar ^^^^^^^^^^^^^^^^^^^^ - -## visit_missing_node(node) [](#method-i-visit_missing_node) -A node that is missing from the syntax tree. This is only used in the case of -a syntax error. The parser gem doesn't have such a concept, so we invent our -own here. - -## visit_module_node(node) [](#method-i-visit_module_node) -module Foo; end ^^^^^^^^^^^^^^^ - -## visit_multi_target_node(node) [](#method-i-visit_multi_target_node) -foo, bar = baz ^^^^^^^^ - -## visit_multi_write_node(node) [](#method-i-visit_multi_write_node) -foo, bar = baz ^^^^^^^^^^^^^^ - -## visit_next_node(node) [](#method-i-visit_next_node) -next ^^^^ - -next foo ^^^^^^^^ - -## visit_nil_node(node) [](#method-i-visit_nil_node) -nil ^^^ - -## visit_no_keywords_parameter_node(node) [](#method-i-visit_no_keywords_parameter_node) -def foo(**nil); end - ^^^^^ - -## visit_numbered_parameters_node(node) [](#method-i-visit_numbered_parameters_node) --> { _1 + _2 } ^^^^^^^^^^^^^^ - -## visit_numbered_reference_read_node(node) [](#method-i-visit_numbered_reference_read_node) -$1 ^^ - -## visit_optional_keyword_parameter_node(node) [](#method-i-visit_optional_keyword_parameter_node) -def foo(bar: baz); end - ^^^^^^^^ - -## visit_optional_parameter_node(node) [](#method-i-visit_optional_parameter_node) -def foo(bar = 1); end - ^^^^^^^ - -## visit_or_node(node) [](#method-i-visit_or_node) -a or b ^^^^^^ - -## visit_parameters_node(node) [](#method-i-visit_parameters_node) -def foo(bar, *baz); end - ^^^^^^^^^ - -## visit_parentheses_node(node) [](#method-i-visit_parentheses_node) -() ^^ - -(1) ^^^ - -## visit_pinned_expression_node(node) [](#method-i-visit_pinned_expression_node) -foo => ^(bar) - ^^^^^^ - -## visit_pinned_variable_node(node) [](#method-i-visit_pinned_variable_node) -foo = 1 and bar => ^foo - ^^^^ - -## visit_post_execution_node(node) [](#method-i-visit_post_execution_node) -END {} - -## visit_pre_execution_node(node) [](#method-i-visit_pre_execution_node) -BEGIN {} - -## visit_program_node(node) [](#method-i-visit_program_node) -The top-level program node. - -## visit_range_node(node) [](#method-i-visit_range_node) -0..5 ^^^^ - -## visit_rational_node(node) [](#method-i-visit_rational_node) -1r ^^ - -## visit_redo_node(node) [](#method-i-visit_redo_node) -redo ^^^^ - -## visit_regular_expression_node(node) [](#method-i-visit_regular_expression_node) -/foo/ ^^^^^ - -## visit_required_keyword_parameter_node(node) [](#method-i-visit_required_keyword_parameter_node) -def foo(bar:); end - ^^^^ - -## visit_required_parameter_node(node) [](#method-i-visit_required_parameter_node) -def foo(bar); end - ^^^ - -## visit_rescue_modifier_node(node) [](#method-i-visit_rescue_modifier_node) -foo rescue bar ^^^^^^^^^^^^^^ - -## visit_rescue_node(node) [](#method-i-visit_rescue_node) -begin; rescue; end - ^^^^^^^ - -**@raise** [CompilationError] - -## visit_rest_parameter_node(node) [](#method-i-visit_rest_parameter_node) -def foo(*bar); end - ^^^^ - -def foo(*); end - ^ - -## visit_retry_node(node) [](#method-i-visit_retry_node) -retry ^^^^^ - -## visit_return_node(node) [](#method-i-visit_return_node) -return ^^^^^^ - -return 1 ^^^^^^^^ - -## visit_self_node(node) [](#method-i-visit_self_node) -self ^^^^ - -## visit_shareable_constant_node(node) [](#method-i-visit_shareable_constant_node) -A shareable constant. - -## visit_singleton_class_node(node) [](#method-i-visit_singleton_class_node) -class << self; end ^^^^^^^^^^^^^^^^^^ - -## visit_source_encoding_node(node) [](#method-i-visit_source_encoding_node) -__ENCODING__ ^^^^^^^^^^^^ - -## visit_source_file_node(node) [](#method-i-visit_source_file_node) -__FILE__ ^^^^^^^^ - -## visit_source_line_node(node) [](#method-i-visit_source_line_node) -__LINE__ ^^^^^^^^ - -## visit_splat_node(node) [](#method-i-visit_splat_node) -foo(*bar) - ^^^^ - -def foo((bar, *baz)); end - ^^^^ - -def foo(*); bar(*); end - ^ - -## visit_statements_node(node) [](#method-i-visit_statements_node) -A list of statements. - -## visit_string_node(node) [](#method-i-visit_string_node) -"foo" ^^^^^ - -## visit_super_node(node) [](#method-i-visit_super_node) -super(foo) ^^^^^^^^^^ - -## visit_symbol_node(node) [](#method-i-visit_symbol_node) -:foo ^^^^ - -## visit_true_node(node) [](#method-i-visit_true_node) -true ^^^^ - -## visit_undef_node(node) [](#method-i-visit_undef_node) -undef foo ^^^^^^^^^ - -## visit_unless_node(node) [](#method-i-visit_unless_node) -unless foo; bar end ^^^^^^^^^^^^^^^^^^^ - -bar unless foo ^^^^^^^^^^^^^^ - -## visit_until_node(node) [](#method-i-visit_until_node) -until foo; bar end ^^^^^^^^^^^^^^^^^^ - -bar until foo ^^^^^^^^^^^^^ - -## visit_when_node(node) [](#method-i-visit_when_node) -case foo; when bar; end - ^^^^^^^^^^^^^ - -## visit_while_node(node) [](#method-i-visit_while_node) -while foo; bar end ^^^^^^^^^^^^^^^^^^ - -bar while foo ^^^^^^^^^^^^^ - -## visit_x_string_node(node) [](#method-i-visit_x_string_node) -`foo` ^^^^^ - -## visit_yield_node(node) [](#method-i-visit_yield_node) -yield ^^^^^ - -yield 1 ^^^^^^^ - diff --git a/example/ruby/Prism/Translation/Parser/Compiler/CompilationError.md b/example/ruby/Prism/Translation/Parser/Compiler/CompilationError.md deleted file mode 100644 index bf2b2ea..0000000 --- a/example/ruby/Prism/Translation/Parser/Compiler/CompilationError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Prism::Translation::Parser::Compiler::CompilationError -**Inherits:** StandardError - - -Raised when the tree is malformed or there is a bug in the compiler. - - - diff --git a/example/ruby/Prism/Translation/Parser/PrismDiagnostic.md b/example/ruby/Prism/Translation/Parser/PrismDiagnostic.md deleted file mode 100644 index 1cb1c01..0000000 --- a/example/ruby/Prism/Translation/Parser/PrismDiagnostic.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Prism::Translation::Parser::PrismDiagnostic -**Inherits:** Prism::Translation::Parser::Diagnostic - - -The parser gem has a list of diagnostics with a hard-coded set of error -messages. We create our own diagnostic class in order to set our own error -messages. - - -# Attributes -## message[RW] [](#attribute-i-message) -This is the cached message coming from prism. - - -#Instance Methods -## initialize(message, level, reason, location) [](#method-i-initialize) -Initialize a new diagnostic with the given message and location. - -**@return** [PrismDiagnostic] a new instance of PrismDiagnostic - diff --git a/example/ruby/Prism/Translation/Parser33.md b/example/ruby/Prism/Translation/Parser33.md deleted file mode 100644 index b1467c1..0000000 --- a/example/ruby/Prism/Translation/Parser33.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Translation::Parser33 -**Inherits:** Prism::Translation::Parser - - -This class is the entry-point for Ruby 3.3 of `Prism::Translation::Parser`. - - - -#Instance Methods -## version() [](#method-i-version) -:nodoc: - diff --git a/example/ruby/Prism/Translation/Parser34.md b/example/ruby/Prism/Translation/Parser34.md deleted file mode 100644 index 9c68d54..0000000 --- a/example/ruby/Prism/Translation/Parser34.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Translation::Parser34 -**Inherits:** Prism::Translation::Parser - - -This class is the entry-point for Ruby 3.4 of `Prism::Translation::Parser`. - - - -#Instance Methods -## version() [](#method-i-version) -:nodoc: - diff --git a/example/ruby/Prism/Translation/Parser35.md b/example/ruby/Prism/Translation/Parser35.md deleted file mode 100644 index 4938ca2..0000000 --- a/example/ruby/Prism/Translation/Parser35.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::Translation::Parser35 -**Inherits:** Prism::Translation::Parser - - -This class is the entry-point for Ruby 3.5 of `Prism::Translation::Parser`. - - - -#Instance Methods -## version() [](#method-i-version) -:nodoc: - diff --git a/example/ruby/Prism/Translation/Ripper.md b/example/ruby/Prism/Translation/Ripper.md deleted file mode 100644 index 6d7f0e9..0000000 --- a/example/ruby/Prism/Translation/Ripper.md +++ /dev/null @@ -1,675 +0,0 @@ -# Class: Prism::Translation::Ripper -**Inherits:** Compiler - - -This class provides a compatibility layer between prism and Ripper. It -functions by parsing the entire tree first and then walking it and executing -each of the Ripper callbacks as it goes. To use this class, you treat -`Prism::Translation::Ripper` effectively as you would treat the `Ripper` -class. - -Note that this class will serve the most common use cases, but Ripper's API is -extensive and undocumented. It relies on reporting the state of the parser at -any given time. We do our best to replicate that here, but because it is a -different architecture it is not possible to perfectly replicate the behavior -of Ripper. - -The main known difference is that we may omit dispatching some events in some -cases. This impacts the following events: - -* on_assign_error -* on_comma -* on_ignored_nl -* on_ignored_sp -* on_kw -* on_label_end -* on_lbrace -* on_lbracket -* on_lparen -* on_nl -* on_op -* on_operator_ambiguous -* on_rbrace -* on_rbracket -* on_rparen -* on_semicolon -* on_sp -* on_symbeg -* on_tstring_beg -* on_tstring_end - - -# Class Methods -## lex(src , filename "-", lineno 1, raise_errors: false) [](#method-c-lex) -Tokenizes the Ruby program and returns an array of an array, which is -formatted like `[[lineno, column], type, token, state]`. The `filename` -argument is mostly ignored. By default, this method does not handle syntax -errors in `src`, use the `raise_errors` keyword to raise a SyntaxError for an -error in `src`. - - require "ripper" - require "pp" - - pp Ripper.lex("def m(a) nil end") - #=> [[[1, 0], :on_kw, "def", FNAME ], - [[1, 3], :on_sp, " ", FNAME ], - [[1, 4], :on_ident, "m", ENDFN ], - [[1, 5], :on_lparen, "(", BEG|LABEL], - [[1, 6], :on_ident, "a", ARG ], - [[1, 7], :on_rparen, ")", ENDFN ], - [[1, 8], :on_sp, " ", BEG ], - [[1, 9], :on_kw, "nil", END ], - [[1, 12], :on_sp, " ", END ], - [[1, 13], :on_kw, "end", END ]] -## parse(src , filename "(ripper)", lineno 1) [](#method-c-parse) -Parses the given Ruby program read from `src`. `src` must be a String or an IO -or a object with a #gets method. -## sexp(src , filename "-", lineno 1, raise_errors: false) [](#method-c-sexp) -Parses `src` and create S-exp tree. Returns more readable tree rather than -Ripper.sexp_raw. This method is mainly for developer use. The `filename` -argument is mostly ignored. By default, this method does not handle syntax -errors in `src`, returning `nil` in such cases. Use the `raise_errors` keyword -to raise a SyntaxError for an error in `src`. - - require "ripper" - require "pp" - - pp Ripper.sexp("def m(a) nil end") - #=> [:program, - [[:def, - [:@ident, "m", [1, 4]], - [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil, nil, nil, nil]], - [:bodystmt, [[:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]] -## sexp_raw(src , filename "-", lineno 1, raise_errors: false) [](#method-c-sexp_raw) -Parses `src` and create S-exp tree. This method is mainly for developer use. -The `filename` argument is mostly ignored. By default, this method does not -handle syntax errors in `src`, returning `nil` in such cases. Use the -`raise_errors` keyword to raise a SyntaxError for an error in `src`. - - require "ripper" - require "pp" - - pp Ripper.sexp_raw("def m(a) nil end") - #=> [:program, - [:stmts_add, - [:stmts_new], - [:def, - [:@ident, "m", [1, 4]], - [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil]], - [:bodystmt, - [:stmts_add, [:stmts_new], [:var_ref, [:@kw, "nil", [1, 9]]]], - nil, - nil, - nil]]]] -# Attributes -## column[RW] [](#attribute-i-column) -The current column number of the parser. - -## filename[RW] [](#attribute-i-filename) -The filename of the source being parsed. - -## lineno[RW] [](#attribute-i-lineno) -The current line number of the parser. - -## source[RW] [](#attribute-i-source) -The source that is being parsed. - - -#Instance Methods -## error?() [](#method-i-error?) -True if the parser encountered an error during parsing. - -**@return** [Boolean] - -## initialize(source, filename"(ripper)", lineno1) [](#method-i-initialize) -Create a new Translation::Ripper object with the given source. - -**@return** [Ripper] a new instance of Ripper - -## parse() [](#method-i-parse) -Parse the source and return the result. - -## visit_alias_global_variable_node(node) [](#method-i-visit_alias_global_variable_node) -alias $foo $bar ^^^^^^^^^^^^^^^ - -## visit_alias_method_node(node) [](#method-i-visit_alias_method_node) -alias foo bar ^^^^^^^^^^^^^ - -## visit_alternation_pattern_node(node) [](#method-i-visit_alternation_pattern_node) -foo => bar | baz - ^^^^^^^^^ - -## visit_and_node(node) [](#method-i-visit_and_node) -a and b ^^^^^^^ - -## visit_arguments_node(node) [](#method-i-visit_arguments_node) -foo(bar) - ^^^ - -## visit_array_node(node) [](#method-i-visit_array_node) -: ^^ - - -## visit_array_pattern_node(node) [](#method-i-visit_array_pattern_node) -foo => [bar] - ^^^^^ - -## visit_assoc_node(node) [](#method-i-visit_assoc_node) -{ a: 1 } - ^^^^ - -## visit_assoc_splat_node(node) [](#method-i-visit_assoc_splat_node) -def foo(**); bar(**); end - ^^ - -{ **foo } - ^^^^^ - -## visit_back_reference_read_node(node) [](#method-i-visit_back_reference_read_node) -$+ ^^ - -## visit_begin_node(node) [](#method-i-visit_begin_node) -begin end ^^^^^^^^^ - -## visit_block_argument_node(node) [](#method-i-visit_block_argument_node) -foo(&bar) - ^^^^ - -## visit_block_local_variable_node(node) [](#method-i-visit_block_local_variable_node) -foo { |; bar| } - ^^^ - -## visit_block_node(node) [](#method-i-visit_block_node) -Visit a BlockNode. - -## visit_block_parameter_node(node) [](#method-i-visit_block_parameter_node) -def foo(&bar); end - ^^^^ - -## visit_block_parameters_node(node) [](#method-i-visit_block_parameters_node) -A block's parameters. - -## visit_break_node(node) [](#method-i-visit_break_node) -break ^^^^^ - -break foo ^^^^^^^^^ - -## visit_call_and_write_node(node) [](#method-i-visit_call_and_write_node) -foo.bar &&= baz ^^^^^^^^^^^^^^^ - -## visit_call_node(node) [](#method-i-visit_call_node) -foo ^^^ - -foo.bar ^^^^^^^ - -foo.bar() {} ^^^^^^^^^^^^ - -## visit_call_operator_write_node(node) [](#method-i-visit_call_operator_write_node) -foo.bar += baz ^^^^^^^^^^^^^^^ - -## visit_call_or_write_node(node) [](#method-i-visit_call_or_write_node) -foo.bar ||= baz ^^^^^^^^^^^^^^^ - -## visit_call_target_node(node) [](#method-i-visit_call_target_node) -foo.bar, = 1 ^^^^^^^ - -## visit_capture_pattern_node(node) [](#method-i-visit_capture_pattern_node) -foo => bar => baz - ^^^^^^^^^^ - -## visit_case_match_node(node) [](#method-i-visit_case_match_node) -case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^ - -## visit_case_node(node) [](#method-i-visit_case_node) -case foo; when bar; end ^^^^^^^^^^^^^^^^^^^^^^^ - -## visit_class_node(node) [](#method-i-visit_class_node) -class Foo; end ^^^^^^^^^^^^^^ - -## visit_class_variable_and_write_node(node) [](#method-i-visit_class_variable_and_write_node) -@@foo &&= bar ^^^^^^^^^^^^^ - -## visit_class_variable_operator_write_node(node) [](#method-i-visit_class_variable_operator_write_node) -@@foo += bar ^^^^^^^^^^^^ - -## visit_class_variable_or_write_node(node) [](#method-i-visit_class_variable_or_write_node) -@@foo ||= bar ^^^^^^^^^^^^^ - -## visit_class_variable_read_node(node) [](#method-i-visit_class_variable_read_node) -@@foo ^^^^^ - -## visit_class_variable_target_node(node) [](#method-i-visit_class_variable_target_node) -@@foo, = bar ^^^^^ - -## visit_class_variable_write_node(node) [](#method-i-visit_class_variable_write_node) -@@foo = 1 ^^^^^^^^^ - -@@foo, @@bar = 1 ^^^^^ ^^^^^ - -## visit_constant_and_write_node(node) [](#method-i-visit_constant_and_write_node) -Foo &&= bar ^^^^^^^^^^^^ - -## visit_constant_operator_write_node(node) [](#method-i-visit_constant_operator_write_node) -Foo += bar ^^^^^^^^^^^ - -## visit_constant_or_write_node(node) [](#method-i-visit_constant_or_write_node) -Foo ||= bar ^^^^^^^^^^^^ - -## visit_constant_path_and_write_node(node) [](#method-i-visit_constant_path_and_write_node) -Foo::Bar &&= baz ^^^^^^^^^^^^^^^^ - -## visit_constant_path_node(node) [](#method-i-visit_constant_path_node) -Foo::Bar ^^^^^^^^ - -## visit_constant_path_operator_write_node(node) [](#method-i-visit_constant_path_operator_write_node) -Foo::Bar += baz ^^^^^^^^^^^^^^^ - -## visit_constant_path_or_write_node(node) [](#method-i-visit_constant_path_or_write_node) -Foo::Bar ||= baz ^^^^^^^^^^^^^^^^ - -## visit_constant_path_target_node(node) [](#method-i-visit_constant_path_target_node) -Foo::Bar, = baz ^^^^^^^^ - -## visit_constant_path_write_node(node) [](#method-i-visit_constant_path_write_node) -Foo::Bar = 1 ^^^^^^^^^^^^ - -Foo::Foo, Bar::Bar = 1 ^^^^^^^^ ^^^^^^^^ - -## visit_constant_read_node(node) [](#method-i-visit_constant_read_node) -Foo ^^^ - -## visit_constant_target_node(node) [](#method-i-visit_constant_target_node) -Foo, = bar ^^^ - -## visit_constant_write_node(node) [](#method-i-visit_constant_write_node) -Foo = 1 ^^^^^^^ - -Foo, Bar = 1 ^^^ ^^^ - -## visit_def_node(node) [](#method-i-visit_def_node) -def foo; end ^^^^^^^^^^^^ - -def self.foo; end ^^^^^^^^^^^^^^^^^ - -## visit_defined_node(node) [](#method-i-visit_defined_node) -defined? a ^^^^^^^^^^ - -defined?(a) ^^^^^^^^^^^ - -## visit_else_node(node) [](#method-i-visit_else_node) -if foo then bar else baz end - ^^^^^^^^^^^^ - -## visit_embedded_statements_node(node) [](#method-i-visit_embedded_statements_node) -"foo #{bar}" - ^^^^^^ - -## visit_embedded_variable_node(node) [](#method-i-visit_embedded_variable_node) -"foo #@bar" - ^^^^^ - -## visit_ensure_node(node) [](#method-i-visit_ensure_node) -Visit an EnsureNode node. - -## visit_false_node(node) [](#method-i-visit_false_node) -false ^^^^^ - -## visit_find_pattern_node(node) [](#method-i-visit_find_pattern_node) -foo => [*, bar, *] - ^^^^^^^^^^^ - -## visit_flip_flop_node(node) [](#method-i-visit_flip_flop_node) -if foo .. bar; end - ^^^^^^^^^^ - -## visit_float_node(node) [](#method-i-visit_float_node) -1.0 ^^^ - -## visit_for_node(node) [](#method-i-visit_for_node) -for foo in bar do end ^^^^^^^^^^^^^^^^^^^^^ - -## visit_forwarding_arguments_node(node) [](#method-i-visit_forwarding_arguments_node) -def foo(...); bar(...); end - ^^^ - -## visit_forwarding_parameter_node(node) [](#method-i-visit_forwarding_parameter_node) -def foo(...); end - ^^^ - -## visit_forwarding_super_node(node) [](#method-i-visit_forwarding_super_node) -super ^^^^^ - -super {} ^^^^^^^^ - -## visit_global_variable_and_write_node(node) [](#method-i-visit_global_variable_and_write_node) -$foo &&= bar ^^^^^^^^^^^^ - -## visit_global_variable_operator_write_node(node) [](#method-i-visit_global_variable_operator_write_node) -$foo += bar ^^^^^^^^^^^ - -## visit_global_variable_or_write_node(node) [](#method-i-visit_global_variable_or_write_node) -$foo ||= bar ^^^^^^^^^^^^ - -## visit_global_variable_read_node(node) [](#method-i-visit_global_variable_read_node) -$foo ^^^^ - -## visit_global_variable_target_node(node) [](#method-i-visit_global_variable_target_node) -$foo, = bar ^^^^ - -## visit_global_variable_write_node(node) [](#method-i-visit_global_variable_write_node) -$foo = 1 ^^^^^^^^ - -$foo, $bar = 1 ^^^^ ^^^^ - -## visit_hash_node(node) [](#method-i-visit_hash_node) -{} ^^ - -## visit_hash_pattern_node(node) [](#method-i-visit_hash_pattern_node) -foo => {} - ^^ - -## visit_if_node(node) [](#method-i-visit_if_node) -if foo then bar end ^^^^^^^^^^^^^^^^^^^ - -bar if foo ^^^^^^^^^^ - -foo ? bar : baz ^^^^^^^^^^^^^^^ - -## visit_imaginary_node(node) [](#method-i-visit_imaginary_node) -1i ^^ - -## visit_implicit_node(node) [](#method-i-visit_implicit_node) -{ foo: } - ^^^^ - -## visit_implicit_rest_node(node) [](#method-i-visit_implicit_rest_node) -foo { |bar,| } - ^ - -## visit_in_node(node) [](#method-i-visit_in_node) -case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^ - -## visit_index_and_write_node(node) [](#method-i-visit_index_and_write_node) -[foo](bar) &&= baz ^^^^^^^^^^^^^^^^ - -## visit_index_operator_write_node(node) [](#method-i-visit_index_operator_write_node) -[foo](bar) += baz ^^^^^^^^^^^^^^^ - -## visit_index_or_write_node(node) [](#method-i-visit_index_or_write_node) -[foo](bar) ||= baz ^^^^^^^^^^^^^^^^ - -## visit_index_target_node(node) [](#method-i-visit_index_target_node) -[foo](bar), = 1 ^^^^^^^^ - -## visit_instance_variable_and_write_node(node) [](#method-i-visit_instance_variable_and_write_node) -^^^^^^^^^^^^ - -## visit_instance_variable_operator_write_node(node) [](#method-i-visit_instance_variable_operator_write_node) -^^^^^^^^^^^ - -## visit_instance_variable_or_write_node(node) [](#method-i-visit_instance_variable_or_write_node) -^^^^^^^^^^^^ - -## visit_instance_variable_read_node(node) [](#method-i-visit_instance_variable_read_node) -^^^^ - -## visit_instance_variable_target_node(node) [](#method-i-visit_instance_variable_target_node) -@foo, = bar ^^^^ - -## visit_instance_variable_write_node(node) [](#method-i-visit_instance_variable_write_node) -^^^^^^^^ - -## visit_integer_node(node) [](#method-i-visit_integer_node) -1 ^ - -## visit_interpolated_match_last_line_node(node) [](#method-i-visit_interpolated_match_last_line_node) -if /foo #{bar}/ then end - ^^^^^^^^^^^^ - -## visit_interpolated_regular_expression_node(node) [](#method-i-visit_interpolated_regular_expression_node) -/foo #{bar}/ ^^^^^^^^^^^^ - -## visit_interpolated_string_node(node) [](#method-i-visit_interpolated_string_node) -"foo #{bar}" ^^^^^^^^^^^^ - -## visit_interpolated_symbol_node(node) [](#method-i-visit_interpolated_symbol_node) -:"foo #{bar}" ^^^^^^^^^^^^^ - -## visit_interpolated_x_string_node(node) [](#method-i-visit_interpolated_x_string_node) -`foo #{bar}` ^^^^^^^^^^^^ - -## visit_it_local_variable_read_node(node) [](#method-i-visit_it_local_variable_read_node) --> { it } - ^^ - -## visit_it_parameters_node(node) [](#method-i-visit_it_parameters_node) --> { it } ^^^^^^^^^ - -## visit_keyword_hash_node(node) [](#method-i-visit_keyword_hash_node) -foo(bar: baz) - ^^^^^^^^ - -## visit_keyword_rest_parameter_node(node) [](#method-i-visit_keyword_rest_parameter_node) -def foo(**bar); end - ^^^^^ - -def foo(**); end - ^^ - -## visit_lambda_node(node) [](#method-i-visit_lambda_node) --> {} - -## visit_local_variable_and_write_node(node) [](#method-i-visit_local_variable_and_write_node) -foo &&= bar ^^^^^^^^^^^ - -## visit_local_variable_operator_write_node(node) [](#method-i-visit_local_variable_operator_write_node) -foo += bar ^^^^^^^^^^ - -## visit_local_variable_or_write_node(node) [](#method-i-visit_local_variable_or_write_node) -foo ||= bar ^^^^^^^^^^^ - -## visit_local_variable_read_node(node) [](#method-i-visit_local_variable_read_node) -foo ^^^ - -## visit_local_variable_target_node(node) [](#method-i-visit_local_variable_target_node) -foo, = bar ^^^ - -## visit_local_variable_write_node(node) [](#method-i-visit_local_variable_write_node) -foo = 1 ^^^^^^^ - -## visit_match_last_line_node(node) [](#method-i-visit_match_last_line_node) -if /foo/ then end - ^^^^^ - -## visit_match_predicate_node(node) [](#method-i-visit_match_predicate_node) -foo in bar ^^^^^^^^^^ - -## visit_match_required_node(node) [](#method-i-visit_match_required_node) -foo => bar ^^^^^^^^^^ - -## visit_match_write_node(node) [](#method-i-visit_match_write_node) -/(?foo)/ =~ bar ^^^^^^^^^^^^^^^^^^^^ - -## visit_missing_node(node) [](#method-i-visit_missing_node) -A node that is missing from the syntax tree. This is only used in the case of -a syntax error. - -## visit_module_node(node) [](#method-i-visit_module_node) -module Foo; end ^^^^^^^^^^^^^^^ - -## visit_multi_target_node(node) [](#method-i-visit_multi_target_node) -(foo, bar), bar = qux ^^^^^^^^^^ - -## visit_multi_write_node(node) [](#method-i-visit_multi_write_node) -foo, bar = baz ^^^^^^^^^^^^^^ - -## visit_next_node(node) [](#method-i-visit_next_node) -next ^^^^ - -next foo ^^^^^^^^ - -## visit_nil_node(node) [](#method-i-visit_nil_node) -nil ^^^ - -## visit_no_keywords_parameter_node(node) [](#method-i-visit_no_keywords_parameter_node) -def foo(**nil); end - ^^^^^ - -## visit_numbered_parameters_node(node) [](#method-i-visit_numbered_parameters_node) --> { _1 + _2 } ^^^^^^^^^^^^^^ - -## visit_numbered_reference_read_node(node) [](#method-i-visit_numbered_reference_read_node) -$1 ^^ - -## visit_optional_keyword_parameter_node(node) [](#method-i-visit_optional_keyword_parameter_node) -def foo(bar: baz); end - ^^^^^^^^ - -## visit_optional_parameter_node(node) [](#method-i-visit_optional_parameter_node) -def foo(bar = 1); end - ^^^^^^^ - -## visit_or_node(node) [](#method-i-visit_or_node) -a or b ^^^^^^ - -## visit_parameters_node(node) [](#method-i-visit_parameters_node) -def foo(bar, *baz); end - ^^^^^^^^^ - -## visit_parentheses_node(node) [](#method-i-visit_parentheses_node) -() ^^ - -(1) ^^^ - -## visit_pinned_expression_node(node) [](#method-i-visit_pinned_expression_node) -foo => ^(bar) - ^^^^^^ - -## visit_pinned_variable_node(node) [](#method-i-visit_pinned_variable_node) -foo = 1 and bar => ^foo - ^^^^ - -## visit_post_execution_node(node) [](#method-i-visit_post_execution_node) -END {} ^^^^^^ - -## visit_pre_execution_node(node) [](#method-i-visit_pre_execution_node) -BEGIN {} ^^^^^^^^ - -## visit_program_node(node) [](#method-i-visit_program_node) -The top-level program node. - -## visit_range_node(node) [](#method-i-visit_range_node) -0..5 ^^^^ - -## visit_rational_node(node) [](#method-i-visit_rational_node) -1r ^^ - -## visit_redo_node(node) [](#method-i-visit_redo_node) -redo ^^^^ - -## visit_regular_expression_node(node) [](#method-i-visit_regular_expression_node) -/foo/ ^^^^^ - -## visit_required_keyword_parameter_node(node) [](#method-i-visit_required_keyword_parameter_node) -def foo(bar:); end - ^^^^ - -## visit_required_parameter_node(node) [](#method-i-visit_required_parameter_node) -def foo(bar); end - ^^^ - -## visit_rescue_modifier_node(node) [](#method-i-visit_rescue_modifier_node) -foo rescue bar ^^^^^^^^^^^^^^ - -## visit_rescue_node(node) [](#method-i-visit_rescue_node) -begin; rescue; end - ^^^^^^^ - -## visit_rest_parameter_node(node) [](#method-i-visit_rest_parameter_node) -def foo(*bar); end - ^^^^ - -def foo(*); end - ^ - -## visit_retry_node(node) [](#method-i-visit_retry_node) -retry ^^^^^ - -## visit_return_node(node) [](#method-i-visit_return_node) -return ^^^^^^ - -return 1 ^^^^^^^^ - -## visit_self_node(node) [](#method-i-visit_self_node) -self ^^^^ - -## visit_shareable_constant_node(node) [](#method-i-visit_shareable_constant_node) -A shareable constant. - -## visit_singleton_class_node(node) [](#method-i-visit_singleton_class_node) -class << self; end ^^^^^^^^^^^^^^^^^^ - -## visit_source_encoding_node(node) [](#method-i-visit_source_encoding_node) -__ENCODING__ ^^^^^^^^^^^^ - -## visit_source_file_node(node) [](#method-i-visit_source_file_node) -__FILE__ ^^^^^^^^ - -## visit_source_line_node(node) [](#method-i-visit_source_line_node) -__LINE__ ^^^^^^^^ - -## visit_splat_node(node) [](#method-i-visit_splat_node) -foo(*bar) - ^^^^ - -def foo((bar, *baz)); end - ^^^^ - -def foo(*); bar(*); end - ^ - -## visit_statements_node(node) [](#method-i-visit_statements_node) -A list of statements. - -## visit_string_node(node) [](#method-i-visit_string_node) -"foo" ^^^^^ - -## visit_super_node(node) [](#method-i-visit_super_node) -super(foo) ^^^^^^^^^^ - -## visit_symbol_node(node) [](#method-i-visit_symbol_node) -:foo ^^^^ - -## visit_true_node(node) [](#method-i-visit_true_node) -true ^^^^ - -## visit_undef_node(node) [](#method-i-visit_undef_node) -undef foo ^^^^^^^^^ - -## visit_unless_node(node) [](#method-i-visit_unless_node) -unless foo; bar end ^^^^^^^^^^^^^^^^^^^ - -bar unless foo ^^^^^^^^^^^^^^ - -## visit_until_node(node) [](#method-i-visit_until_node) -until foo; bar end ^^^^^^^^^^^^^^^^^ - -bar until foo ^^^^^^^^^^^^^ - -## visit_when_node(node) [](#method-i-visit_when_node) -case foo; when bar; end - ^^^^^^^^^^^^^ - -## visit_while_node(node) [](#method-i-visit_while_node) -while foo; bar end ^^^^^^^^^^^^^^^^^^ - -bar while foo ^^^^^^^^^^^^^ - -## visit_x_string_node(node) [](#method-i-visit_x_string_node) -`foo` ^^^^^ - -## visit_yield_node(node) [](#method-i-visit_yield_node) -yield ^^^^^ - -yield 1 ^^^^^^^ - diff --git a/example/ruby/Prism/Translation/Ripper/SexpBuilder.md b/example/ruby/Prism/Translation/Ripper/SexpBuilder.md deleted file mode 100644 index d23f9fe..0000000 --- a/example/ruby/Prism/Translation/Ripper/SexpBuilder.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Prism::Translation::Ripper::SexpBuilder -**Inherits:** Prism::Translation::Ripper - - -This class mirrors the ::Ripper::SexpBuilder subclass of ::Ripper that returns -the arrays of [type, *children]. - - -# Attributes -## error[RW] [](#attribute-i-error) -:stopdoc: - - diff --git a/example/ruby/Prism/Translation/Ripper/SexpBuilderPP.md b/example/ruby/Prism/Translation/Ripper/SexpBuilderPP.md deleted file mode 100644 index 4c4e240..0000000 --- a/example/ruby/Prism/Translation/Ripper/SexpBuilderPP.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::Translation::Ripper::SexpBuilderPP -**Inherits:** Prism::Translation::Ripper::SexpBuilder - - -This class mirrors the ::Ripper::SexpBuilderPP subclass of ::Ripper that -returns the same values as ::Ripper::SexpBuilder except with a couple of -niceties that flatten linked lists into arrays. - - - diff --git a/example/ruby/Prism/Translation/RubyParser.md b/example/ruby/Prism/Translation/RubyParser.md deleted file mode 100644 index 628f2ba..0000000 --- a/example/ruby/Prism/Translation/RubyParser.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Prism::Translation::RubyParser -**Inherits:** Object - - -This module is the entry-point for converting a prism syntax tree into the -seattlerb/ruby_parser gem's syntax tree. - - -# Class Methods -## parse(source , filepath "(string)") [](#method-c-parse) -Parse the given source and translate it into the seattlerb/ruby_parser gem's -Sexp format. -## parse_file(filepath ) [](#method-c-parse_file) -Parse the given file and translate it into the seattlerb/ruby_parser gem's -Sexp format. - -#Instance Methods -## parse(source, filepath"(string)") [](#method-i-parse) -Parse the given source and translate it into the seattlerb/ruby_parser gem's -Sexp format. - -## parse_file(filepath) [](#method-i-parse_file) -Parse the given file and translate it into the seattlerb/ruby_parser gem's -Sexp format. - diff --git a/example/ruby/Prism/TunnelTest.md b/example/ruby/Prism/TunnelTest.md deleted file mode 100644 index c21806e..0000000 --- a/example/ruby/Prism/TunnelTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::TunnelTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_tunnel() [](#method-i-test_tunnel) - diff --git a/example/ruby/Prism/UnescapeTest.md b/example/ruby/Prism/UnescapeTest.md deleted file mode 100644 index 54f2d88..0000000 --- a/example/ruby/Prism/UnescapeTest.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: Prism::UnescapeTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_char() [](#method-i-test_char) - -## test_dqte() [](#method-i-test_dqte) - -## test_dstr() [](#method-i-test_dstr) - -## test_h0_1() [](#method-i-test_h0_1) - -## test_h0_2() [](#method-i-test_h0_2) - -## test_h0_3() [](#method-i-test_h0_3) - -## test_h0_4() [](#method-i-test_h0_4) - -## test_hd_1() [](#method-i-test_hd_1) - -## test_hd_2() [](#method-i-test_hd_2) - -## test_hd_3() [](#method-i-test_hd_3) - -## test_hd_4() [](#method-i-test_hd_4) - -## test_ht_1() [](#method-i-test_ht_1) - -## test_ht_2() [](#method-i-test_ht_2) - -## test_ht_3() [](#method-i-test_ht_3) - -## test_ht_4() [](#method-i-test_ht_4) - -## test_lwri() [](#method-i-test_lwri) - -## test_lwrq() [](#method-i-test_lwrq) - -## test_lwrs() [](#method-i-test_lwrs) - -## test_lwrx() [](#method-i-test_lwrx) - -## test_pw_1() [](#method-i-test_pw_1) - -## test_pw_2() [](#method-i-test_pw_2) - -## test_reg1() [](#method-i-test_reg1) - -## test_reg2() [](#method-i-test_reg2) - -## test_reg3() [](#method-i-test_reg3) - -## test_reg4() [](#method-i-test_reg4) - -## test_reg5() [](#method-i-test_reg5) - -## test_reg6() [](#method-i-test_reg6) - -## test_sqte() [](#method-i-test_sqte) - -## test_sym1() [](#method-i-test_sym1) - -## test_sym2() [](#method-i-test_sym2) - -## test_upri() [](#method-i-test_upri) - -## test_uprq() [](#method-i-test_uprq) - -## test_uprw() [](#method-i-test_uprw) - -## test_xstr() [](#method-i-test_xstr) - diff --git a/example/ruby/Prism/UnescapeTest/Context.md b/example/ruby/Prism/UnescapeTest/Context.md deleted file mode 100644 index 91b84a0..0000000 --- a/example/ruby/Prism/UnescapeTest/Context.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Prism::UnescapeTest::Context - - - - - diff --git a/example/ruby/Prism/UnescapeTest/Context/Base.md b/example/ruby/Prism/UnescapeTest/Context/Base.md deleted file mode 100644 index 9367a91..0000000 --- a/example/ruby/Prism/UnescapeTest/Context/Base.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Prism::UnescapeTest::Context::Base -**Inherits:** Object - - - - -# Attributes -## left[RW] [](#attribute-i-left) -Returns the value of attribute left. - -## right[RW] [](#attribute-i-right) -Returns the value of attribute right. - - -#Instance Methods -## initialize(left, right) [](#method-i-initialize) - -**@return** [Base] a new instance of Base - -## name() [](#method-i-name) - diff --git a/example/ruby/Prism/UnescapeTest/Context/Heredoc.md b/example/ruby/Prism/UnescapeTest/Context/Heredoc.md deleted file mode 100644 index f0349c0..0000000 --- a/example/ruby/Prism/UnescapeTest/Context/Heredoc.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::UnescapeTest::Context::Heredoc -**Inherits:** Prism::UnescapeTest::Context::Base - - - - - -#Instance Methods -## prism_result(escape) [](#method-i-prism_result) - -## ruby_result(escape) [](#method-i-ruby_result) - diff --git a/example/ruby/Prism/UnescapeTest/Context/List.md b/example/ruby/Prism/UnescapeTest/Context/List.md deleted file mode 100644 index d3f72f7..0000000 --- a/example/ruby/Prism/UnescapeTest/Context/List.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::UnescapeTest::Context::List -**Inherits:** Prism::UnescapeTest::Context::Base - - - - - -#Instance Methods -## prism_result(escape) [](#method-i-prism_result) - -## ruby_result(escape) [](#method-i-ruby_result) - diff --git a/example/ruby/Prism/UnescapeTest/Context/RegExp.md b/example/ruby/Prism/UnescapeTest/Context/RegExp.md deleted file mode 100644 index 256dcab..0000000 --- a/example/ruby/Prism/UnescapeTest/Context/RegExp.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::UnescapeTest::Context::RegExp -**Inherits:** Prism::UnescapeTest::Context::Base - - - - - -#Instance Methods -## prism_result(escape) [](#method-i-prism_result) - -## ruby_result(escape) [](#method-i-ruby_result) - diff --git a/example/ruby/Prism/UnescapeTest/Context/String.md b/example/ruby/Prism/UnescapeTest/Context/String.md deleted file mode 100644 index 677dcf4..0000000 --- a/example/ruby/Prism/UnescapeTest/Context/String.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::UnescapeTest::Context::String -**Inherits:** Prism::UnescapeTest::Context::Base - - - - - -#Instance Methods -## prism_result(escape) [](#method-i-prism_result) - -## ruby_result(escape) [](#method-i-ruby_result) - diff --git a/example/ruby/Prism/UnescapeTest/Context/Symbol.md b/example/ruby/Prism/UnescapeTest/Context/Symbol.md deleted file mode 100644 index aeb6f78..0000000 --- a/example/ruby/Prism/UnescapeTest/Context/Symbol.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::UnescapeTest::Context::Symbol -**Inherits:** Prism::UnescapeTest::Context::Base - - - - - -#Instance Methods -## prism_result(escape) [](#method-i-prism_result) - -## ruby_result(escape) [](#method-i-ruby_result) - diff --git a/example/ruby/Prism/UnlessNode.md b/example/ruby/Prism/UnlessNode.md deleted file mode 100644 index e79a0a5..0000000 --- a/example/ruby/Prism/UnlessNode.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Prism::UnlessNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## consequent() [](#method-i-consequent) -Returns the else clause of the unless node. This method is deprecated in favor -of #else_clause. - -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/UntilNode.md b/example/ruby/Prism/UntilNode.md deleted file mode 100644 index 86ab8e0..0000000 --- a/example/ruby/Prism/UntilNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::UntilNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/VersionTest.md b/example/ruby/Prism/VersionTest.md deleted file mode 100644 index 202b8d1..0000000 --- a/example/ruby/Prism/VersionTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Prism::VersionTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_prism_version_is_set() [](#method-i-test_prism_version_is_set) - diff --git a/example/ruby/Prism/WarningsTest.md b/example/ruby/Prism/WarningsTest.md deleted file mode 100644 index 4e4735e..0000000 --- a/example/ruby/Prism/WarningsTest.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: Prism::WarningsTest -**Inherits:** Prism::TestCase - - - - - -#Instance Methods -## test_END_in_method() [](#method-i-test_END_in_method) - -## test_ambiguous_ampersand() [](#method-i-test_ambiguous_ampersand) - -## test_ambiguous_regexp() [](#method-i-test_ambiguous_regexp) - -## test_ambiguous_uminus() [](#method-i-test_ambiguous_uminus) - -## test_ambiguous_uplus() [](#method-i-test_ambiguous_uplus) - -## test_ambiguous_ustar() [](#method-i-test_ambiguous_ustar) - -## test_binary_operator() [](#method-i-test_binary_operator) - -## test_dot_dot_dot_eol() [](#method-i-test_dot_dot_dot_eol) - -## test_duplicated_hash_key() [](#method-i-test_duplicated_hash_key) - -## test_duplicated_when_clause() [](#method-i-test_duplicated_when_clause) - -## test_equal_in_conditional() [](#method-i-test_equal_in_conditional) - -## test_float_out_of_range() [](#method-i-test_float_out_of_range) - -## test_indentation_mismatch() [](#method-i-test_indentation_mismatch) - -## test_integer_in_flip_flop() [](#method-i-test_integer_in_flip_flop) - -## test_keyword_eol() [](#method-i-test_keyword_eol) - -## test_literal_in_conditionals() [](#method-i-test_literal_in_conditionals) - -## test_literal_in_predicate() [](#method-i-test_literal_in_predicate) - -## test_numbered_reference() [](#method-i-test_numbered_reference) - -## test_regexp_in_predicate() [](#method-i-test_regexp_in_predicate) - -## test_shareable_constant_value() [](#method-i-test_shareable_constant_value) - -## test_shebang_ending_with_carriage_return() [](#method-i-test_shebang_ending_with_carriage_return) - -## test_string_in_predicate() [](#method-i-test_string_in_predicate) - -## test_symbol_in_predicate() [](#method-i-test_symbol_in_predicate) - -## test_unreachable_statement() [](#method-i-test_unreachable_statement) - -## test_unused_local_variables() [](#method-i-test_unused_local_variables) - -## test_void_statements() [](#method-i-test_void_statements) - -## test_warnings_verbosity() [](#method-i-test_warnings_verbosity) - diff --git a/example/ruby/Prism/WhileNode.md b/example/ruby/Prism/WhileNode.md deleted file mode 100644 index e5487c9..0000000 --- a/example/ruby/Prism/WhileNode.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Prism::WhileNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## newline_flag!(lines) [](#method-i-newline_flag!) -:nodoc: - diff --git a/example/ruby/Prism/XStringNode.md b/example/ruby/Prism/XStringNode.md deleted file mode 100644 index a9f39a1..0000000 --- a/example/ruby/Prism/XStringNode.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Prism::XStringNode -**Inherits:** Prism::Node - - - - - -#Instance Methods -## to_interpolated() [](#method-i-to_interpolated) -Occasionally it's helpful to treat a string as if it were interpolated so that -there's a consistent interface for working with strings. - diff --git a/example/ruby/Private.md b/example/ruby/Private.md deleted file mode 100644 index 361b99a..0000000 --- a/example/ruby/Private.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Private - - - - - diff --git a/example/ruby/Private/A.md b/example/ruby/Private/A.md deleted file mode 100644 index d5ea149..0000000 --- a/example/ruby/Private/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Private::A -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/Private/B.md b/example/ruby/Private/B.md deleted file mode 100644 index e7b74e1..0000000 --- a/example/ruby/Private/B.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Private::B -**Inherits:** Object - - - - -# Class Methods -## public_class_method1() [](#method-c-public_class_method1) - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/Private/B/C.md b/example/ruby/Private/B/C.md deleted file mode 100644 index e67a931..0000000 --- a/example/ruby/Private/B/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Private::B::C -**Inherits:** Object - - - - - -#Instance Methods -## baz() [](#method-i-baz) - diff --git a/example/ruby/Private/D.md b/example/ruby/Private/D.md deleted file mode 100644 index 133a789..0000000 --- a/example/ruby/Private/D.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Private::D - - - - - diff --git a/example/ruby/Private/E.md b/example/ruby/Private/E.md deleted file mode 100644 index 10e778e..0000000 --- a/example/ruby/Private/E.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Private::E -**Inherits:** Object - -**Includes:** Private::D - - - - - diff --git a/example/ruby/Private/G.md b/example/ruby/Private/G.md deleted file mode 100644 index 3290a94..0000000 --- a/example/ruby/Private/G.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Private::G -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/Private/H.md b/example/ruby/Private/H.md deleted file mode 100644 index d8071e2..0000000 --- a/example/ruby/Private/H.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Private::H -**Inherits:** Private::A - - - - - diff --git a/example/ruby/Proc.md b/example/ruby/Proc.md deleted file mode 100644 index 17f816f..0000000 --- a/example/ruby/Proc.md +++ /dev/null @@ -1,847 +0,0 @@ -# Class: Proc -**Inherits:** Object - - -A `Proc` object is an encapsulation of a block of code, which can be stored in -a local variable, passed to a method or another Proc, and can be called. Proc -is an essential concept in Ruby and a core of its functional programming -features. - - square = Proc.new {|x| x**2 } - - square.call(3) #=> 9 - # shorthands: - square.(3) #=> 9 - square[3] #=> 9 - -Proc objects are *closures*, meaning they remember and can use the entire -context in which they were created. - - def gen_times(factor) - Proc.new {|n| n*factor } # remembers the value of factor at the moment of creation - end - - times3 = gen_times(3) - times5 = gen_times(5) - - times3.call(12) #=> 36 - times5.call(5) #=> 25 - times3.call(times5.call(4)) #=> 60 - -## Creation - -There are several methods to create a Proc - -* Use the Proc class constructor: - - proc1 = Proc.new {|x| x**2 } - -* Use the Kernel#proc method as a shorthand of Proc.new: - - proc2 = proc {|x| x**2 } - -* Receiving a block of code into proc argument (note the `&`): - - def make_proc(&block) - block - end - - proc3 = make_proc {|x| x**2 } - -* Construct a proc with lambda semantics using the Kernel#lambda method - (see below for explanations about lambdas): - - lambda1 = lambda {|x| x**2 } - -* Use the [Lambda proc - literal](rdoc-ref:syntax/literals.rdoc@Lambda+Proc+Literals) syntax - (also constructs a proc with lambda semantics): - - lambda2 = ->(x) { x**2 } - -## Lambda and non-lambda semantics - -Procs are coming in two flavors: lambda and non-lambda (regular procs). -Differences are: - -* In lambdas, `return` and `break` means exit from this lambda; -* In non-lambda procs, `return` means exit from embracing method - (and will throw +LocalJumpError+ if invoked outside the method); - -* In non-lambda procs, `break` means exit from the method which the block - given for. - (and will throw +LocalJumpError+ if invoked after the method returns); - -* In lambdas, arguments are treated in the same way as in methods: strict, - with +ArgumentError+ for mismatching argument number, - and no additional argument processing; - -* Regular procs accept arguments more generously: missing arguments - are filled with +nil+, single Array arguments are deconstructed if the - proc has multiple arguments, and there is no error raised on extra - arguments. - -Examples: - - # +return+ in non-lambda proc, +b+, exits +m2+. - # (The block +{ return }+ is given for +m1+ and embraced by +m2+.) - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { return }; $a << :m2 end; m2; p $a - #=> [] - - # +break+ in non-lambda proc, +b+, exits +m1+. - # (The block +{ break }+ is given for +m1+ and embraced by +m2+.) - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { break }; $a << :m2 end; m2; p $a - #=> [:m2] - - # +next+ in non-lambda proc, +b+, exits the block. - # (The block +{ next }+ is given for +m1+ and embraced by +m2+.) - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { next }; $a << :m2 end; m2; p $a - #=> [:m1, :m2] - - # Using +proc+ method changes the behavior as follows because - # The block is given for +proc+ method and embraced by +m2+. - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { return }); $a << :m2 end; m2; p $a - #=> [] - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { break }); $a << :m2 end; m2; p $a - # break from proc-closure (LocalJumpError) - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { next }); $a << :m2 end; m2; p $a - #=> [:m1, :m2] - - # +return+, +break+ and +next+ in the stubby lambda exits the block. - # (+lambda+ method behaves same.) - # (The block is given for stubby lambda syntax and embraced by +m2+.) - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { return }); $a << :m2 end; m2; p $a - #=> [:m1, :m2] - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { break }); $a << :m2 end; m2; p $a - #=> [:m1, :m2] - $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { next }); $a << :m2 end; m2; p $a - #=> [:m1, :m2] - - p = proc {|x, y| "x=#{x}, y=#{y}" } - p.call(1, 2) #=> "x=1, y=2" - p.call([1, 2]) #=> "x=1, y=2", array deconstructed - p.call(1, 2, 8) #=> "x=1, y=2", extra argument discarded - p.call(1) #=> "x=1, y=", nil substituted instead of error - - l = lambda {|x, y| "x=#{x}, y=#{y}" } - l.call(1, 2) #=> "x=1, y=2" - l.call([1, 2]) # ArgumentError: wrong number of arguments (given 1, expected 2) - l.call(1, 2, 8) # ArgumentError: wrong number of arguments (given 3, expected 2) - l.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) - - def test_return - -> { return 3 }.call # just returns from lambda into method body - proc { return 4 }.call # returns from method - return 5 - end - - test_return # => 4, return from proc - -Lambdas are useful as self-sufficient functions, in particular useful as -arguments to higher-order functions, behaving exactly like Ruby methods. - -Procs are useful for implementing iterators: - - def test - [[1, 2], [3, 4], [5, 6]].map {|a, b| return a if a + b > 10 } - # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - end - -Inside `map`, the block of code is treated as a regular (non-lambda) proc, -which means that the internal arrays will be deconstructed to pairs of -arguments, and `return` will exit from the method `test`. That would not be -possible with a stricter lambda. - -You can tell a lambda from a regular proc by using the #lambda? instance -method. - -Lambda semantics is typically preserved during the proc lifetime, including -`&`-deconstruction to a block of code: - - p = proc {|x, y| x } - l = lambda {|x, y| x } - [[1, 2], [3, 4]].map(&p) #=> [1, 3] - [[1, 2], [3, 4]].map(&l) # ArgumentError: wrong number of arguments (given 1, expected 2) - -The only exception is dynamic method definition: even if defined by passing a -non-lambda proc, methods still have normal semantics of argument checking. - - class C - define_method(:e, &proc {}) - end - C.new.e(1,2) #=> ArgumentError - C.new.method(:e).to_proc.lambda? #=> true - -This exception ensures that methods never have unusual argument passing -conventions, and makes it easy to have wrappers defining methods that behave -as usual. - - class C - def self.def2(name, &body) - define_method(name, &body) - end - - def2(:f) {} - end - C.new.f(1,2) #=> ArgumentError - -The wrapper `def2` receives *body* as a non-lambda proc, yet defines a method -which has normal semantics. - -## Conversion of other objects to procs - -Any object that implements the `to_proc` method can be converted into a proc -by the `&` operator, and therefore can be consumed by iterators. - - class Greeter - def initialize(greeting) - @greeting = greeting - end - - def to_proc - proc {|name| "#{@greeting}, #{name}!" } - end - end - - hi = Greeter.new("Hi") - hey = Greeter.new("Hey") - ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"] - ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"] - -Of the Ruby core classes, this method is implemented by Symbol, Method, and -Hash. - - :to_s.to_proc.call(1) #=> "1" - [1, 2].map(&:to_s) #=> ["1", "2"] - - method(:puts).to_proc.call(1) # prints 1 - [1, 2].each(&method(:puts)) # prints 1, 2 - - {test: 1}.to_proc.call(:test) #=> 1 - %i[test many keys].map(&{test: 1}) #=> [1, nil, nil] - -## Orphaned Proc - -`return` and `break` in a block exit a method. If a Proc object is generated -from the block and the Proc object survives until the method is returned, -`return` and `break` cannot work. In such case, `return` and `break` raises -LocalJumpError. A Proc object in such situation is called as orphaned Proc -object. - -Note that the method to exit is different for `return` and `break`. There is a -situation that orphaned for `break` but not orphaned for `return`. - - def m1(&b) b.call end; def m2(); m1 { return } end; m2 # ok - def m1(&b) b.call end; def m2(); m1 { break } end; m2 # ok - - def m1(&b) b end; def m2(); m1 { return }.call end; m2 # ok - def m1(&b) b end; def m2(); m1 { break }.call end; m2 # LocalJumpError - - def m1(&b) b end; def m2(); m1 { return } end; m2.call # LocalJumpError - def m1(&b) b end; def m2(); m1 { break } end; m2.call # LocalJumpError - -Since `return` and `break` exits the block itself in lambdas, lambdas cannot -be orphaned. - -## Anonymous block parameters - -To simplify writing short blocks, Ruby provides two different types of -anonymous parameters: `it` (single parameter) and numbered ones: `_1`, `_2` -and so on. - - # Explicit parameter: - %w[test me please].each { |str| puts str.upcase } # prints TEST, ME, PLEASE - (1..5).map { |i| i**2 } # => [1, 4, 9, 16, 25] - - # it: - %w[test me please].each { puts it.upcase } # prints TEST, ME, PLEASE - (1..5).map { it**2 } # => [1, 4, 9, 16, 25] - - # Numbered parameter: - %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE - (1..5).map { _1**2 } # => [1, 4, 9, 16, 25] - -### `it` - -`it` is a name that is available inside a block when no explicit parameters -defined, as shown above. - - %w[test me please].each { puts it.upcase } # prints TEST, ME, PLEASE - (1..5).map { it**2 } # => [1, 4, 9, 16, 25] - -`it` is a "soft keyword": it is not a reserved name, and can be used as a name -for methods and local variables: - - it = 5 # no warnings - def it(&block) # RSpec-like API, no warnings - # ... - end - -`it` can be used as a local variable even in blocks that use it as an implicit -parameter (though this style is obviously confusing): - - [1, 2, 3].each { - # takes a value of implicit parameter "it" and uses it to - # define a local variable with the same name - it = it**2 - p it - } - -In a block with explicit parameters defined `it` usage raises an exception: - - [1, 2, 3].each { |x| p it } - # syntax error found (SyntaxError) - # [1, 2, 3].each { |x| p it } - # ^~ `it` is not allowed when an ordinary parameter is defined - -But if a local name (variable or method) is available, it would be used: - - it = 5 - [1, 2, 3].each { |x| p it } - # Prints 5, 5, 5 - -Blocks using `it` can be nested: - - %w[test me].each { it.each_char { p it } } - # Prints "t", "e", "s", "t", "m", "e" - -Blocks using `it` are considered to have one parameter: - - p = proc { it**2 } - l = lambda { it**2 } - p.parameters # => [[:opt, nil]] - p.arity # => 1 - l.parameters # => [[:req]] - l.arity # => 1 - -### Numbered parameters - -Numbered parameters are another way to name block parameters implicitly. -Unlike `it`, numbered parameters allow to refer to several parameters in one -block. - - %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE - {a: 100, b: 200}.map { "#{_1} = #{_2}" } # => "a = 100", "b = 200" - -Parameter names from `_1` to `_9` are supported: - - [10, 20, 30].zip([40, 50, 60], [70, 80, 90]).map { _1 + _2 + _3 } - # => [120, 150, 180] - -Though, it is advised to resort to them wisely, probably limiting yourself to -`_1` and `_2`, and to one-line blocks. - -Numbered parameters can't be used together with explicitly named ones: - - [10, 20, 30].map { |x| _1**2 } - # SyntaxError (ordinary parameter is defined) - -Numbered parameters can't be mixed with `it` either: - - [10, 20, 30].map { _1 + it } - # SyntaxError: `it` is not allowed when a numbered parameter is already used - -To avoid conflicts, naming local variables or method arguments `_1`, `_2` and -so on, causes an error. - - _1 = 'test' - # ^~ _1 is reserved for numbered parameters (SyntaxError) - -Using implicit numbered parameters affects block's arity: - - p = proc { _1 + _2 } - l = lambda { _1 + _2 } - p.parameters # => [[:opt, :_1], [:opt, :_2]] - p.arity # => 2 - l.parameters # => [[:req, :_1], [:req, :_2]] - l.arity # => 2 - -Blocks with numbered parameters can't be nested: - - %w[test me].each { _1.each_char { p _1 } } - # numbered parameter is already used in outer block (SyntaxError) - # %w[test me].each { _1.each_char { p _1 } } - # ^~ - - -# Class Methods -## new(*args ) [](#method-c-new) -Creates a new Proc object, bound to the current context. - - proc = Proc.new { "hello" } - proc.call #=> "hello" - -Raises ArgumentError if called without a block. - - Proc.new #=> ArgumentError -**@overload** [] - - -#Instance Methods -## <<(g) [](#method-i-<<) -Returns a proc that is the composition of this proc and the given *g*. The -returned proc takes a variable number of arguments, calls *g* with them then -calls this proc with the result. - - f = proc {|x| x * x } - g = proc {|x| x + x } - p (f << g).call(2) #=> 16 - -See Proc#>> for detailed explanations. - -**@overload** [] - -## ==(other) [](#method-i-==) -Two procs are the same if, and only if, they were created from the same code -block. - - def return_block(&block) - block - end - - def pass_block_twice(&block) - [return_block(&block), return_block(&block)] - end - - block1, block2 = pass_block_twice { puts 'test' } - # Blocks might be instantiated into Proc's lazily, so they may, or may not, - # be the same object. - # But they are produced from the same code block, so they are equal - block1 == block2 - #=> true - - # Another Proc will never be equal, even if the code is the "same" - block1 == proc { puts 'test' } - #=> false - -**@overload** [] - -**@overload** [] - -## ===(*args) [](#method-i-===) -call-seq: - proc === obj -> result_of_proc - -Invokes the block with `obj` as the proc's parameter like Proc#call. This -allows a proc object to be the target of a `when` clause in a case statement. - -## >>(g) [](#method-i->>) -Returns a proc that is the composition of this proc and the given *g*. The -returned proc takes a variable number of arguments, calls this proc with them -then calls *g* with the result. - - f = proc {|x| x * x } - g = proc {|x| x + x } - p (f >> g).call(2) #=> 8 - -*g* could be other Proc, or Method, or any other object responding to `call` -method: - - class Parser - def self.call(text) - # ...some complicated parsing logic... - end - end - - pipeline = File.method(:read) >> Parser >> proc { |data| puts "data size: #{data.count}" } - pipeline.call('data.json') - -See also Method#>> and Method#<<. - -**@overload** [] - -## [](*args) [](#method-i-[]) -call-seq: - prc.call(params,...) -> obj - prc[params,...] -> obj - prc.(params,...) -> obj - prc.yield(params,...) -> obj - -Invokes the block, setting the block's parameters to the values in *params* -using something close to method calling semantics. Returns the value of the -last expression evaluated in the block. - - a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } - a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] - a_proc[9, 1, 2, 3] #=> [9, 18, 27] - a_proc.(9, 1, 2, 3) #=> [9, 18, 27] - a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27] - -Note that `prc.()` invokes `prc.call()` with the parameters given. It's -syntactic sugar to hide "call". - -For procs created using #lambda or `->()` an error is generated if the wrong -number of parameters are passed to the proc. For procs created using Proc.new -or Kernel.proc, extra parameters are silently discarded and missing parameters -are set to `nil`. - - a_proc = proc {|a,b| [a,b] } - a_proc.call(1) #=> [1, nil] - - a_proc = lambda {|a,b| [a,b] } - a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) - -See also Proc#lambda?. - -## arity() [](#method-i-arity) -Returns the number of mandatory arguments. If the block is declared to take no -arguments, returns 0. If the block is known to take exactly n arguments, -returns n. If the block has optional arguments, returns -n-1, where n is the -number of mandatory arguments, with the exception for blocks that are not -lambdas and have only a finite number of optional arguments; in this latter -case, returns n. Keyword arguments will be considered as a single additional -argument, that argument being mandatory if any keyword argument is mandatory. -A #proc with no argument declarations is the same as a block declaring `||` as -its arguments. - - proc {}.arity #=> 0 - proc { || }.arity #=> 0 - proc { |a| }.arity #=> 1 - proc { |a, b| }.arity #=> 2 - proc { |a, b, c| }.arity #=> 3 - proc { |*a| }.arity #=> -1 - proc { |a, *b| }.arity #=> -2 - proc { |a, *b, c| }.arity #=> -3 - proc { |x:, y:, z:0| }.arity #=> 1 - proc { |*a, x:, y:0| }.arity #=> -2 - - proc { |a=0| }.arity #=> 0 - lambda { |a=0| }.arity #=> -1 - proc { |a=0, b| }.arity #=> 1 - lambda { |a=0, b| }.arity #=> -2 - proc { |a=0, b=0| }.arity #=> 0 - lambda { |a=0, b=0| }.arity #=> -1 - proc { |a, b=0| }.arity #=> 1 - lambda { |a, b=0| }.arity #=> -2 - proc { |(a, b), c=0| }.arity #=> 1 - lambda { |(a, b), c=0| }.arity #=> -2 - proc { |a, x:0, y:0| }.arity #=> 1 - lambda { |a, x:0, y:0| }.arity #=> -2 - -**@overload** [] - -## binding() [](#method-i-binding) -Returns the binding associated with *prc*. - - def fred(param) - proc {} - end - - b = fred(99) - eval("param", b.binding) #=> 99 - -**@overload** [] - -## call(*args) [](#method-i-call) -call-seq: - prc.call(params,...) -> obj - prc[params,...] -> obj - prc.(params,...) -> obj - prc.yield(params,...) -> obj - -Invokes the block, setting the block's parameters to the values in *params* -using something close to method calling semantics. Returns the value of the -last expression evaluated in the block. - - a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } - a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] - a_proc[9, 1, 2, 3] #=> [9, 18, 27] - a_proc.(9, 1, 2, 3) #=> [9, 18, 27] - a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27] - -Note that `prc.()` invokes `prc.call()` with the parameters given. It's -syntactic sugar to hide "call". - -For procs created using #lambda or `->()` an error is generated if the wrong -number of parameters are passed to the proc. For procs created using Proc.new -or Kernel.proc, extra parameters are silently discarded and missing parameters -are set to `nil`. - - a_proc = proc {|a,b| [a,b] } - a_proc.call(1) #=> [1, nil] - - a_proc = lambda {|a,b| [a,b] } - a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) - -See also Proc#lambda?. - -## clone() [](#method-i-clone) -:nodoc: - -## curry(*args) [](#method-i-curry) -Returns a curried proc. If the optional *arity* argument is given, it -determines the number of arguments. A curried proc receives some arguments. If -a sufficient number of arguments are supplied, it passes the supplied -arguments to the original proc and returns the result. Otherwise, returns -another curried proc that takes the rest of arguments. - -The optional *arity* argument should be supplied when currying procs with -variable arguments to determine how many arguments are needed before the proc -is called. - - b = proc {|x, y, z| (x||0) + (y||0) + (z||0) } - p b.curry[1][2][3] #=> 6 - p b.curry[1, 2][3, 4] #=> 6 - p b.curry(5)[1][2][3][4][5] #=> 6 - p b.curry(5)[1, 2][3, 4][5] #=> 6 - p b.curry(1)[1] #=> 1 - - b = proc {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) } - p b.curry[1][2][3] #=> 6 - p b.curry[1, 2][3, 4] #=> 10 - p b.curry(5)[1][2][3][4][5] #=> 15 - p b.curry(5)[1, 2][3, 4][5] #=> 15 - p b.curry(1)[1] #=> 1 - - b = lambda {|x, y, z| (x||0) + (y||0) + (z||0) } - p b.curry[1][2][3] #=> 6 - p b.curry[1, 2][3, 4] #=> wrong number of arguments (given 4, expected 3) - p b.curry(5) #=> wrong number of arguments (given 5, expected 3) - p b.curry(1) #=> wrong number of arguments (given 1, expected 3) - - b = lambda {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) } - p b.curry[1][2][3] #=> 6 - p b.curry[1, 2][3, 4] #=> 10 - p b.curry(5)[1][2][3][4][5] #=> 15 - p b.curry(5)[1, 2][3, 4][5] #=> 15 - p b.curry(1) #=> wrong number of arguments (given 1, expected 3) - - b = proc { :foo } - p b.curry[] #=> :foo - -**@overload** [] - -**@overload** [] - -## dup() [](#method-i-dup) -:nodoc: - -## eql?(other) [](#method-i-eql?) -Two procs are the same if, and only if, they were created from the same code -block. - - def return_block(&block) - block - end - - def pass_block_twice(&block) - [return_block(&block), return_block(&block)] - end - - block1, block2 = pass_block_twice { puts 'test' } - # Blocks might be instantiated into Proc's lazily, so they may, or may not, - # be the same object. - # But they are produced from the same code block, so they are equal - block1 == block2 - #=> true - - # Another Proc will never be equal, even if the code is the "same" - block1 == proc { puts 'test' } - #=> false - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -Returns a hash value corresponding to proc body. - -See also Object#hash. - -**@overload** [] - -## lambda?() [](#method-i-lambda?) -Returns `true` if a Proc object is lambda. `false` if non-lambda. - -The lambda-ness affects argument handling and the behavior of `return` and -`break`. - -A Proc object generated by `proc` ignores extra arguments. - - proc {|a,b| [a,b] }.call(1,2,3) #=> [1,2] - -It provides `nil` for missing arguments. - - proc {|a,b| [a,b] }.call(1) #=> [1,nil] - -It expands a single array argument. - - proc {|a,b| [a,b] }.call([1,2]) #=> [1,2] - -A Proc object generated by `lambda` doesn't have such tricks. - - lambda {|a,b| [a,b] }.call(1,2,3) #=> ArgumentError - lambda {|a,b| [a,b] }.call(1) #=> ArgumentError - lambda {|a,b| [a,b] }.call([1,2]) #=> ArgumentError - -Proc#lambda? is a predicate for the tricks. It returns `true` if no tricks -apply. - - lambda {}.lambda? #=> true - proc {}.lambda? #=> false - -Proc.new is the same as `proc`. - - Proc.new {}.lambda? #=> false - -`lambda`, `proc` and Proc.new preserve the tricks of a Proc object given by -`&` argument. - - lambda(&lambda {}).lambda? #=> true - proc(&lambda {}).lambda? #=> true - Proc.new(&lambda {}).lambda? #=> true - - lambda(&proc {}).lambda? #=> false - proc(&proc {}).lambda? #=> false - Proc.new(&proc {}).lambda? #=> false - -A Proc object generated by `&` argument has the tricks - - def n(&b) b.lambda? end - n {} #=> false - -The `&` argument preserves the tricks if a Proc object is given by `&` -argument. - - n(&lambda {}) #=> true - n(&proc {}) #=> false - n(&Proc.new {}) #=> false - -A Proc object converted from a method has no tricks. - - def m() end - method(:m).to_proc.lambda? #=> true - - n(&method(:m)) #=> true - n(&method(:m).to_proc) #=> true - -`define_method` is treated the same as method definition. The defined method -has no tricks. - - class C - define_method(:d) {} - end - C.new.d(1,2) #=> ArgumentError - C.new.method(:d).to_proc.lambda? #=> true - -`define_method` always defines a method without the tricks, even if a -non-lambda Proc object is given. This is the only exception for which the -tricks are not preserved. - - class C - define_method(:e, &proc {}) - end - C.new.e(1,2) #=> ArgumentError - C.new.method(:e).to_proc.lambda? #=> true - -This exception ensures that methods never have tricks and makes it easy to -have wrappers to define methods that behave as usual. - - class C - def self.def2(name, &body) - define_method(name, &body) - end - - def2(:f) {} - end - C.new.f(1,2) #=> ArgumentError - -The wrapper *def2* defines a method which has no tricks. - -**@overload** [] - -## parameters(*args) [](#method-i-parameters) -Returns the parameter information of this proc. If the lambda keyword is -provided and not nil, treats the proc as a lambda if true and as a non-lambda -if false. - - prc = proc{|x, y=42, *other|} - prc.parameters #=> [[:opt, :x], [:opt, :y], [:rest, :other]] - prc = lambda{|x, y=42, *other|} - prc.parameters #=> [[:req, :x], [:opt, :y], [:rest, :other]] - prc = proc{|x, y=42, *other|} - prc.parameters(lambda: true) #=> [[:req, :x], [:opt, :y], [:rest, :other]] - prc = lambda{|x, y=42, *other|} - prc.parameters(lambda: false) #=> [[:opt, :x], [:opt, :y], [:rest, :other]] - -**@overload** [] - -## ruby2_keywords() [](#method-i-ruby2_keywords) -Marks the proc as passing keywords through a normal argument splat. This -should only be called on procs that accept an argument splat (`*args`) but not -explicit keywords or a keyword splat. It marks the proc such that if the proc -is called with keyword arguments, the final hash argument is marked with a -special flag such that if it is the final element of a normal argument splat -to another method call, and that method call does not include explicit -keywords or a keyword splat, the final element is interpreted as keywords. In -other words, keywords will be passed through the proc to other methods. - -This should only be used for procs that delegate keywords to another method, -and only for backwards compatibility with Ruby versions before 2.7. - -This method will probably be removed at some point, as it exists only for -backwards compatibility. As it does not exist in Ruby versions before 2.7, -check that the proc responds to this method before calling it. Also, be aware -that if this method is removed, the behavior of the proc will change so that -it does not pass through keywords. - - module Mod - foo = ->(meth, *args, &block) do - send(:"do_#{meth}", *args, &block) - end - foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords) - end - -**@overload** [] - -## source_location() [](#method-i-source_location) -Returns the Ruby source filename and line number containing this proc or `nil` -if this proc was not defined in Ruby (i.e. native). - -**@overload** [] - -## to_proc() [](#method-i-to_proc) -Part of the protocol for converting objects to Proc objects. Instances of -class Proc simply return themselves. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns the unique identifier for this proc, along with an indication of where -the proc was defined. - -**@overload** [] - -## yield(*args) [](#method-i-yield) -call-seq: - prc.call(params,...) -> obj - prc[params,...] -> obj - prc.(params,...) -> obj - prc.yield(params,...) -> obj - -Invokes the block, setting the block's parameters to the values in *params* -using something close to method calling semantics. Returns the value of the -last expression evaluated in the block. - - a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } - a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] - a_proc[9, 1, 2, 3] #=> [9, 18, 27] - a_proc.(9, 1, 2, 3) #=> [9, 18, 27] - a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27] - -Note that `prc.()` invokes `prc.call()` with the parameters given. It's -syntactic sugar to hide "call". - -For procs created using #lambda or `->()` an error is generated if the wrong -number of parameters are passed to the proc. For procs created using Proc.new -or Kernel.proc, extra parameters are silently discarded and missing parameters -are set to `nil`. - - a_proc = proc {|a,b| [a,b] } - a_proc.call(1) #=> [1, nil] - - a_proc = lambda {|a,b| [a,b] } - a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) - -See also Proc#lambda?. - diff --git a/example/ruby/ProcArefFrozenSpecs.md b/example/ruby/ProcArefFrozenSpecs.md deleted file mode 100644 index b7ead35..0000000 --- a/example/ruby/ProcArefFrozenSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ProcArefFrozenSpecs - - - - -# Class Methods -## aref() [](#method-c-aref) -## aref_freeze() [](#method-c-aref_freeze) - diff --git a/example/ruby/ProcArefSpecs.md b/example/ruby/ProcArefSpecs.md deleted file mode 100644 index d0c2def..0000000 --- a/example/ruby/ProcArefSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ProcArefSpecs - - - - -# Class Methods -## aref() [](#method-c-aref) -## aref_freeze() [](#method-c-aref_freeze) - diff --git a/example/ruby/ProcSpecs.md b/example/ruby/ProcSpecs.md deleted file mode 100644 index 84d879e..0000000 --- a/example/ruby/ProcSpecs.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: ProcSpecs - - - - -# Class Methods -## new_proc_from_amp(&block ) [](#method-c-new_proc_from_amp) -## new_proc_in_method() [](#method-c-new_proc_in_method) -## new_proc_subclass_in_method() [](#method-c-new_proc_subclass_in_method) -## proc_for_1() [](#method-c-proc_for_1) - diff --git a/example/ruby/ProcSpecs/Arity.md b/example/ruby/ProcSpecs/Arity.md deleted file mode 100644 index 5b15644..0000000 --- a/example/ruby/ProcSpecs/Arity.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ProcSpecs::Arity -**Inherits:** Object - - - - - -#Instance Methods -## arity_check(&block) [](#method-i-arity_check) - diff --git a/example/ruby/ProcSpecs/MyProc.md b/example/ruby/ProcSpecs/MyProc.md deleted file mode 100644 index 6f88a15..0000000 --- a/example/ruby/ProcSpecs/MyProc.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ProcSpecs::MyProc -**Inherits:** Proc - - - - - diff --git a/example/ruby/ProcSpecs/MyProc2.md b/example/ruby/ProcSpecs/MyProc2.md deleted file mode 100644 index 4680ea4..0000000 --- a/example/ruby/ProcSpecs/MyProc2.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: ProcSpecs::MyProc2 -**Inherits:** Proc - - - - -# Attributes -## first[RW] [](#attribute-i-first) -Returns the value of attribute first. - -## second[RW] [](#attribute-i-second) -Returns the value of attribute second. - - -#Instance Methods -## initialize(a, b) [](#method-i-initialize) - -**@return** [MyProc2] a new instance of MyProc2 - diff --git a/example/ruby/ProcSpecs/ProcSubclass.md b/example/ruby/ProcSpecs/ProcSubclass.md deleted file mode 100644 index 1039e5a..0000000 --- a/example/ruby/ProcSpecs/ProcSubclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: ProcSpecs::ProcSubclass -**Inherits:** Proc - - - - - diff --git a/example/ruby/ProcSpecs/SourceLocation.md b/example/ruby/ProcSpecs/SourceLocation.md deleted file mode 100644 index 0000e11..0000000 --- a/example/ruby/ProcSpecs/SourceLocation.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ProcSpecs::SourceLocation -**Inherits:** Object - - - - -# Class Methods -## my_detached_lambda() [](#method-c-my_detached_lambda) -## my_detached_proc() [](#method-c-my_detached_proc) -## my_detached_proc_new() [](#method-c-my_detached_proc_new) -## my_lambda() [](#method-c-my_lambda) -## my_method() [](#method-c-my_method) -## my_multiline_lambda() [](#method-c-my_multiline_lambda) -## my_multiline_proc() [](#method-c-my_multiline_proc) -## my_multiline_proc_new() [](#method-c-my_multiline_proc_new) -## my_proc() [](#method-c-my_proc) -## my_proc_new() [](#method-c-my_proc_new) - diff --git a/example/ruby/ProcSpecs/ToAryAsNil.md b/example/ruby/ProcSpecs/ToAryAsNil.md deleted file mode 100644 index 335cf85..0000000 --- a/example/ruby/ProcSpecs/ToAryAsNil.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ProcSpecs::ToAryAsNil -**Inherits:** Object - - - - - -#Instance Methods -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/Process.md b/example/ruby/Process.md deleted file mode 100644 index 29ddfaa..0000000 --- a/example/ruby/Process.md +++ /dev/null @@ -1,1682 +0,0 @@ -# Module: Process - - -Module `Process` represents a process in the underlying operating system. Its -methods support management of the current process and its child processes. - -## Process Creation - -Each of the following methods executes a given command in a new process or -subshell, or multiple commands in new processes and/or subshells. The choice -of process or subshell depends on the form of the command; see [Argument -command_line or exe_path](rdoc-ref:Process@Argument+command_line+or+exe_path). - -* Process.spawn, Kernel#spawn: Executes the command; returns the new pid - without waiting for completion. -* Process.exec: Replaces the current process by executing the command. - -In addition: - -* Method Kernel#system executes a given command-line (string) in a subshell; - returns `true`, `false`, or `nil`. -* Method Kernel#` executes a given command-line (string) in a subshell; - returns its $stdout string. -* Module Open3 supports creating child processes with access to their - $stdin, $stdout, and $stderr streams. - -### Execution Environment - -Optional leading argument `env` is a hash of name/value pairs, where each name -is a string and each value is a string or `nil`; each name/value pair is added -to ENV in the new process. - - Process.spawn( 'ruby -e "p ENV[\"Foo\"]"') - Process.spawn({'Foo' => '0'}, 'ruby -e "p ENV[\"Foo\"]"') - -Output: - - "0" - -The effect is usually similar to that of calling ENV#update with argument -`env`, where each named environment variable is created or updated (if the -value is non-`nil`), or deleted (if the value is `nil`). - -However, some modifications to the calling process may remain if the new -process fails. For example, hard resource limits are not restored. - -### Argument `command_line` or `exe_path` - -The required string argument is one of the following: - -* `command_line` if it begins with a shell reserved word or special - built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -#### Argument `command_line` - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - system('if true; then echo "Foo"; fi') # => true # Shell reserved word. - system('exit') # => true # Built-in. - system('date > /tmp/date.tmp') # => true # Contains meta character. - system('date > /nop/date.tmp') # => false - system('date > /nop/date.tmp', exception: true) # Raises RuntimeError. - -The command line may also contain arguments and options for the command: - - system('echo "Foo"') # => true - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -#### Argument `exe_path` - -Argument `exe_path` is one of the following: - -* The string path to an executable file to be called: - - Example: - - system('/usr/bin/date') # => true # Path to date on Unix-style system. - system('foo') # => nil # Command execlution failed. - - Output: - - Thu Aug 31 10:06:48 AM CDT 2023 - - A path or command name containing spaces without arguments cannot be - distinguished from `command_line` above, so you must quote or escape the - entire command name using a shell in platform dependent manner, or use the - array form below. - - If `exe_path` does not contain any path separator, an executable file is - searched from directories specified with the `PATH` environment variable. - What the word "executable" means here is depending on platforms. - - Even if the file considered "executable", its content may not be in proper - executable format. In that case, Ruby tries to run it by using `/bin/sh` - on a Unix-like system, like system(3) does. - - File.write('shell_command', 'echo $SHELL', perm: 0o755) - system('./shell_command') # prints "/bin/sh" or something. - -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process: - - Example: - - pid = spawn(['sleep', 'Hello!'], '1') # 2-element array. - p `ps -p #{pid} -o command=` - - Output: - - "Hello! 1\n" - -### Arguments `args` - -If `command_line` does not contain shell meta characters except for spaces and -tabs, or `exe_path` is given, Ruby invokes the executable directly. This form -does not use the shell: - - spawn("doesnt_exist") # Raises Errno::ENOENT - spawn("doesnt_exist", "\n") # Raises Errno::ENOENT - - spawn("doesnt_exist\n") # => false - # sh: 1: doesnot_exist: not found - -The error message is from a shell and would vary depending on your system. - -If one or more `args` is given after `exe_path`, each is an argument or option -to be passed to the executable: - -Example: - - system('echo', '<', 'C*', '|', '$SHELL', '>') # => true - -Output: - - < C* | $SHELL > - -However, there are exceptions on Windows. See [Execution Shell on -Windows](rdoc-ref:Process@Execution+Shell+on+Windows). - -If you want to invoke a path containing spaces with no arguments without -shell, you will need to use a 2-element array `exe_path`. - -Example: - - path = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' - spawn(path) # Raises Errno::ENOENT; No such file or directory - /Applications/Google - spawn([path] * 2) - -### Execution Options - -Optional trailing argument `options` is a hash of execution options. - -#### Working Directory (`:chdir`) - -By default, the working directory for the new process is the same as that of -the current process: - - Dir.chdir('/var') - Process.spawn('ruby -e "puts Dir.pwd"') - -Output: - - /var - -Use option `:chdir` to set the working directory for the new process: - - Process.spawn('ruby -e "puts Dir.pwd"', {chdir: '/tmp'}) - -Output: - - /tmp - -The working directory of the current process is not changed: - - Dir.pwd # => "/var" - -#### File Redirection (File Descriptor) - -Use execution options for file redirection in the new process. - -The key for such an option may be an integer file descriptor (fd), specifying -a source, or an array of fds, specifying multiple sources. - -An integer source fd may be specified as: - -* *n*: Specifies file descriptor *n*. - -There are these shorthand symbols for fds: - -* `:in`: Specifies file descriptor 0 (STDIN). -* `:out`: Specifies file descriptor 1 (STDOUT). -* `:err`: Specifies file descriptor 2 (STDERR). - -The value given with a source is one of: - -* *n*: Redirects to fd *n* in the parent process. -* `filepath`: Redirects from or to the file at `filepath` via - `open(filepath, mode, 0644)`, where `mode` is `'r'` for source `:in`, or - `'w'` for source `:out` or `:err`. -* `[filepath]`: Redirects from the file at `filepath` via `open(filepath, - 'r', 0644)`. -* `[filepath, mode]`: Redirects from or to the file at `filepath` via - `open(filepath, mode, 0644)`. -* `[filepath, mode, perm]`: Redirects from or to the file at `filepath` via - `open(filepath, mode, perm)`. -* `[:child, fd]`: Redirects to the redirected `fd`. -* `:close`: Closes the file descriptor in child process. - -See [Access Modes](rdoc-ref:File@Access+Modes) and [File -Permissions](rdoc-ref:File@File+Permissions). - -#### Environment Variables (`:unsetenv_others`) - -By default, the new process inherits environment variables from the parent -process; use execution option key `:unsetenv_others` with value `true` to -clear environment variables in the new process. - -Any changes specified by execution option `env` are made after the new process -inherits or clears its environment variables; see [Execution -Environment](rdoc-ref:Process@Execution+Environment). - -#### File-Creation Access (`:umask`) - -Use execution option `:umask` to set the file-creation access for the new -process; see [Access Modes](rdoc-ref:File@Access+Modes): - - command = 'ruby -e "puts sprintf(\"0%o\", File.umask)"' - options = {:umask => 0644} - Process.spawn(command, options) - -Output: - - 0644 - -#### Process Groups (`:pgroup` and `:new_pgroup`) - -By default, the new process belongs to the same [process -group](https://en.wikipedia.org/wiki/Process_group) as the parent process. - -To specify a different process group. use execution option `:pgroup` with one -of the following values: - -* `true`: Create a new process group for the new process. -* *pgid*: Create the new process in the process group whose id is *pgid*. - -On Windows only, use execution option `:new_pgroup` with value `true` to -create a new process group for the new process. - -#### Resource Limits - -Use execution options to set resource limits. - -The keys for these options are symbols of the form `:rlimit_*resource_name`*, -where *resource_name* is the downcased form of one of the string resource -names described at method Process.setrlimit. For example, key `:rlimit_cpu` -corresponds to resource limit `'CPU'`. - -The value for such as key is one of: - -* An integer, specifying both the current and maximum limits. -* A 2-element array of integers, specifying the current and maximum limits. - -#### File Descriptor Inheritance - -By default, the new process inherits file descriptors from the parent process. - -Use execution option `:close_others => true` to modify that inheritance by -closing non-standard fds (3 and greater) that are not otherwise redirected. - -### Execution Shell - -On a Unix-like system, the shell invoked is `/bin/sh`; the entire string -`command_line` is passed as an argument to [shell option --c](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh. -html). - -The shell performs normal shell expansion on the command line: - -Example: - - system('echo $SHELL: C*') # => true - -Output: - - /bin/bash: CONTRIBUTING.md COPYING COPYING.ja - -#### Execution Shell on Windows - -On Windows, the shell invoked is determined by environment variable -`RUBYSHELL`, if defined, or `COMSPEC` otherwise; the entire string -`command_line` is passed as an argument to `-c` option for `RUBYSHELL`, as -well as `/bin/sh`, and [/c -option](https://learn.microsoft.com/en-us/windows-server/administration/window -s-commands/cmd) for `COMSPEC`. The shell is invoked automatically in the -following cases: - -* The command is a built-in of `cmd.exe`, such as `echo`. -* The executable file is a batch file; its name ends with `.bat` or `.cmd`. - -Note that the command will still be invoked as `command_line` form even when -called in `exe_path` form, because `cmd.exe` does not accept a script name -like `/bin/sh` does but only works with `/c` option. - -The standard shell `cmd.exe` performs environment variable expansion but does -not have globbing functionality: - -Example: - - system("echo %COMSPEC%: C*")' # => true - -Output: - - C:\WINDOWS\system32\cmd.exe: C* - -## What's Here - -### Current-Process Getters - -* ::argv0: Returns the process name as a frozen string. -* ::egid: Returns the effective group ID. -* ::euid: Returns the effective user ID. -* ::getpgrp: Return the process group ID. -* ::getrlimit: Returns the resource limit. -* ::gid: Returns the (real) group ID. -* ::pid: Returns the process ID. -* ::ppid: Returns the process ID of the parent process. -* ::uid: Returns the (real) user ID. - -### Current-Process Setters - -* ::egid=: Sets the effective group ID. -* ::euid=: Sets the effective user ID. -* ::gid=: Sets the (real) group ID. -* ::setproctitle: Sets the process title. -* ::setpgrp: Sets the process group ID of the process to zero. -* ::setrlimit: Sets a resource limit. -* ::setsid: Establishes the process as a new session and process group - leader, with no controlling tty. -* ::uid=: Sets the user ID. - -### Current-Process Execution - -* ::abort: Immediately terminates the process. -* ::daemon: Detaches the process from its controlling terminal and continues - running it in the background as system daemon. -* ::exec: Replaces the process by running a given external command. -* ::exit: Initiates process termination by raising exception SystemExit - (which may be caught). -* ::exit!: Immediately exits the process. -* ::warmup: Notifies the Ruby virtual machine that the boot sequence for the - application is completed, and that the VM may begin optimizing the - application. - -### Child Processes - -* ::detach: Guards against a child process becoming a zombie. -* ::fork: Creates a child process. -* ::kill: Sends a given signal to processes. -* ::spawn: Creates a child process. -* ::wait, ::waitpid: Waits for a child process to exit; returns its process - ID. -* ::wait2, ::waitpid2: Waits for a child process to exit; returns its - process ID and status. -* ::waitall: Waits for all child processes to exit; returns their process - IDs and statuses. - -### Process Groups - -* ::getpgid: Returns the process group ID for a process. -* ::getpriority: Returns the scheduling priority for a process, process - group, or user. -* ::getsid: Returns the session ID for a process. -* ::groups: Returns an array of the group IDs in the supplemental group - access list for this process. -* ::groups=: Sets the supplemental group access list to the given array of - group IDs. -* ::initgroups: Initializes the supplemental group access list. -* ::last_status: Returns the status of the last executed child process in - the current thread. -* ::maxgroups: Returns the maximum number of group IDs allowed in the - supplemental group access list. -* ::maxgroups=: Sets the maximum number of group IDs allowed in the - supplemental group access list. -* ::setpgid: Sets the process group ID of a process. -* ::setpriority: Sets the scheduling priority for a process, process group, - or user. - -### Timing - -* ::clock_getres: Returns the resolution of a system clock. -* ::clock_gettime: Returns the time from a system clock. -* ::times: Returns a Process::Tms object containing times for the current - process and its child processes. - - -# Class Methods -## _fork() [](#method-c-_fork) -An internal API for fork. Do not call this method directly. Currently, this is -called via Kernel#fork, Process.fork, and IO.popen with `"-"`. - -This method is not for casual code but for application monitoring libraries. -You can add custom code before and after fork events by overriding this -method. - -Note: Process.daemon may be implemented using fork(2) BUT does not go through -this method. Thus, depending on your reason to hook into this method, you may -also want to hook into that one. See [this -issue](https://bugs.ruby-lang.org/issues/18911) for a more detailed discussion -of this. -**@overload** [] - -## abort(*a , _ ) [](#method-c-abort) -Terminates execution immediately, effectively by calling `Kernel.exit(false)`. - -If string argument `msg` is given, it is written to STDERR prior to -termination; otherwise, if an exception was raised, prints its message and -backtrace. -**@overload** [] - -**@overload** [] - -## argv0() [](#method-c-argv0) -Returns the name of the script being executed. The value is not affected by -assigning a new value to $0. - -This method first appeared in Ruby 2.1 to serve as a global variable free -means to get the script name. -**@overload** [] - -## clock_getres(*args ) [](#method-c-clock_getres) -Returns a clock resolution as determined by POSIX function -[clock_getres()](https://man7.org/linux/man-pages/man3/clock_getres.3.html): - - Process.clock_getres(:CLOCK_REALTIME) # => 1.0e-09 - -See Process.clock_gettime for the values of `clock_id` and `unit`. - -Examples: - - Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond) # => 0.001 - Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_millisecond) # => 1.0e-06 - Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 1.0e-09 - Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :microsecond) # => 0 - Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :millisecond) # => 0 - Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :nanosecond) # => 1 - Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :second) # => 0 - -In addition to the values for `unit` supported in Process.clock_gettime, this -method supports `:hertz`, the integer number of clock ticks per second (which -is the reciprocal of `:float_second`): - - Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) # => 100.0 - Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 0.01 - -**Accuracy**: Note that the returned resolution may be inaccurate on some -platforms due to underlying bugs. Inaccurate resolutions have been reported -for various clocks including `:CLOCK_MONOTONIC` and `:CLOCK_MONOTONIC_RAW` on -Linux, macOS, BSD or AIX platforms, when using ARM processors, or when using -virtualization. -**@overload** [] - -## clock_gettime(*args ) [](#method-c-clock_gettime) -Returns a clock time as determined by POSIX function -[clock_gettime()](https://man7.org/linux/man-pages/man3/clock_gettime.3.html): - - Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID) # => 198.650379677 - -Argument `clock_id` should be a symbol or a constant that specifies the clock -whose time is to be returned; see below. - -Optional argument `unit` should be a symbol that specifies the unit to be used -in the returned clock time; see below. - -**Argument `clock_id`** - -Argument `clock_id` specifies the clock whose time is to be returned; it may -be a constant such as `Process::CLOCK_REALTIME`, or a symbol shorthand such as -`:CLOCK_REALTIME`. - -The supported clocks depend on the underlying operating system; this method -supports the following clocks on the indicated platforms (raises Errno::EINVAL -if called with an unsupported clock): - -* `:CLOCK_BOOTTIME`: Linux 2.6.39. -* `:CLOCK_BOOTTIME_ALARM`: Linux 3.0. -* `:CLOCK_MONOTONIC`: SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, - OpenBSD 3.4, macOS 10.12, Windows-2000. -* `:CLOCK_MONOTONIC_COARSE`: Linux 2.6.32. -* `:CLOCK_MONOTONIC_FAST`: FreeBSD 8.1. -* `:CLOCK_MONOTONIC_PRECISE`: FreeBSD 8.1. -* `:CLOCK_MONOTONIC_RAW`: Linux 2.6.28, macOS 10.12. -* `:CLOCK_MONOTONIC_RAW_APPROX`: macOS 10.12. -* `:CLOCK_PROCESS_CPUTIME_ID`: SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, - OpenBSD 5.4, macOS 10.12. -* `:CLOCK_PROF`: FreeBSD 3.0, OpenBSD 2.1. -* `:CLOCK_REALTIME`: SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, - OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012. Time.now is recommended - over +:CLOCK_REALTIME:. -* `:CLOCK_REALTIME_ALARM`: Linux 3.0. -* `:CLOCK_REALTIME_COARSE`: Linux 2.6.32. -* `:CLOCK_REALTIME_FAST`: FreeBSD 8.1. -* `:CLOCK_REALTIME_PRECISE`: FreeBSD 8.1. -* `:CLOCK_SECOND`: FreeBSD 8.1. -* `:CLOCK_TAI`: Linux 3.10. -* `:CLOCK_THREAD_CPUTIME_ID`: SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD - 5.4, macOS 10.12. -* `:CLOCK_UPTIME`: FreeBSD 7.0, OpenBSD 5.5. -* `:CLOCK_UPTIME_FAST`: FreeBSD 8.1. -* `:CLOCK_UPTIME_PRECISE`: FreeBSD 8.1. -* `:CLOCK_UPTIME_RAW`: macOS 10.12. -* `:CLOCK_UPTIME_RAW_APPROX`: macOS 10.12. -* `:CLOCK_VIRTUAL`: FreeBSD 3.0, OpenBSD 2.1. - -Note that SUS stands for Single Unix Specification. SUS contains POSIX and -clock_gettime is defined in the POSIX part. SUS defines `:CLOCK_REALTIME` as -mandatory but `:CLOCK_MONOTONIC`, `:CLOCK_PROCESS_CPUTIME_ID`, and -`:CLOCK_THREAD_CPUTIME_ID` are optional. - -Certain emulations are used when the given `clock_id` is not supported -directly: - -* Emulations for `:CLOCK_REALTIME`: - - * `:GETTIMEOFDAY_BASED_CLOCK_REALTIME`: Use gettimeofday() defined by - SUS (deprecated in SUSv4). The resolution is 1 microsecond. - * `:TIME_BASED_CLOCK_REALTIME`: Use time() defined by ISO C. The - resolution is 1 second. - -* Emulations for `:CLOCK_MONOTONIC`: - - * `:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC`: Use mach_absolute_time(), - available on Darwin. The resolution is CPU dependent. - * `:TIMES_BASED_CLOCK_MONOTONIC`: Use the result value of times() - defined by POSIX, thus: -> Upon successful completion, times() shall return the elapsed real - time, in clock ticks, since an arbitrary point in the past (for - example, system start-up time). - -> For example, GNU/Linux returns a value based on jiffies and it is - monotonic. However, 4.4BSD uses gettimeofday() and it is not - monotonic. (FreeBSD uses `:CLOCK_MONOTONIC` instead, though.) - - The resolution is the clock tick. "getconf CLK_TCK" command shows the - clock ticks per second. (The clock ticks-per-second is defined by HZ - macro in older systems.) If it is 100 and clock_t is 32 bits integer - type, the resolution is 10 millisecond and cannot represent over 497 - days. - -* Emulations for `:CLOCK_PROCESS_CPUTIME_ID`: - - * `:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID`: Use getrusage() defined - by SUS. getrusage() is used with RUSAGE_SELF to obtain the time only - for the calling process (excluding the time for child processes). The - result is addition of user time (ru_utime) and system time (ru_stime). - The resolution is 1 microsecond. - * `:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID`: Use times() defined by POSIX. - The result is addition of user time (tms_utime) and system time - (tms_stime). tms_cutime and tms_cstime are ignored to exclude the time - for child processes. The resolution is the clock tick. "getconf - CLK_TCK" command shows the clock ticks per second. (The clock ticks - per second is defined by HZ macro in older systems.) If it is 100, the - resolution is 10 millisecond. - * `:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID`: Use clock() defined by ISO C. - The resolution is `1/CLOCKS_PER_SEC`. `CLOCKS_PER_SEC` is the C-level - macro defined by time.h. SUS defines `CLOCKS_PER_SEC` as 1000000; - other systems may define it differently. If `CLOCKS_PER_SEC` is - 1000000 (as in SUS), the resolution is 1 microsecond. If - `CLOCKS_PER_SEC` is 1000000 and clock_t is a 32-bit integer type, it - cannot represent over 72 minutes. - -**Argument `unit`** - -Optional argument `unit` (default `:float_second`) specifies the unit for the -returned value. - -* `:float_microsecond`: Number of microseconds as a float. -* `:float_millisecond`: Number of milliseconds as a float. -* `:float_second`: Number of seconds as a float. -* `:microsecond`: Number of microseconds as an integer. -* `:millisecond`: Number of milliseconds as an integer. -* `:nanosecond`: Number of nanoseconds as an integer. -* `::second`: Number of seconds as an integer. - -Examples: - - Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond) - # => 203605054.825 - Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_millisecond) - # => 203643.696848 - Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_second) - # => 203.762181929 - Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :microsecond) - # => 204123212 - Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :millisecond) - # => 204298 - Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :nanosecond) - # => 204602286036 - Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :second) - # => 204 - -The underlying function, clock_gettime(), returns a number of nanoseconds. -Float object (IEEE 754 double) is not enough to represent the return value for -`:CLOCK_REALTIME`. If the exact nanoseconds value is required, use -`:nanosecond` as the `unit`. - -The origin (time zero) of the returned value is system-dependent, and may be, -for example, system start up time, process start up time, the Epoch, etc. - -The origin in `:CLOCK_REALTIME` is defined as the Epoch: `1970-01-01 00:00:00 -UTC`; some systems count leap seconds and others don't, so the result may vary -across systems. -**@overload** [] - -## daemon(*args ) [](#method-c-daemon) -Detaches the current process from its controlling terminal and runs it in the -background as system daemon; returns zero. - -By default: - -* Changes the current working directory to the root directory. -* Redirects $stdin, $stdout, and $stderr to the null device. - -If optional argument `nochdir` is `true`, does not change the current working -directory. - -If optional argument `noclose` is `true`, does not redirect $stdin, $stdout, -or $stderr. -**@overload** [] - -## detach(pid ) [](#method-c-detach) -Avoids the potential for a child process to become a [zombie -process](https://en.wikipedia.org/wiki/Zombie_process). Process.detach -prevents this by setting up a separate Ruby thread whose sole job is to reap -the status of the process *pid* when it terminates. - -This method is needed only when the parent process will never wait for the -child process. - -This example does not reap the second child process; that process appears as a -zombie in the process status (`ps`) output: - - pid = Process.spawn('ruby', '-e', 'exit 13') # => 312691 - sleep(1) - # Find zombies. - system("ps -ho pid,state -p #{pid}") - -Output: - - 312716 Z - -This example also does not reap the second child process, but it does detach -the process so that it does not become a zombie: - - pid = Process.spawn('ruby', '-e', 'exit 13') # => 313213 - thread = Process.detach(pid) - sleep(1) - # => # - system("ps -ho pid,state -p #{pid}") # Finds no zombies. - -The waiting thread can return the pid of the detached child process: - - thread.join.pid # => 313262 -**@overload** [] - -## egid() [](#method-c-egid) -Returns the effective group ID for the current process: - - Process.egid # => 500 - -Not available on all platforms. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## egid=() [](#method-c-egid=) -## euid() [](#method-c-euid) -Returns the effective user ID for the current process. - - Process.euid # => 501 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## euid=(euid ) [](#method-c-euid=) -Sets the effective user ID for the current process. - -Not available on all platforms. -**@overload** [] - -## exec(*a , _ ) [](#method-c-exec) -Replaces the current process by doing one of the following: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -The new process is created using the [exec system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e -xecve.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - exec('if true; then echo "Foo"; fi') # Shell reserved word. - exec('exit') # Built-in. - exec('date > date.tmp') # Contains meta character. - -The command line may also contain arguments and options for the command: - - exec('echo "Foo"') - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable and the string to - be used as the name of the executing process. - -Example: - - exec('/usr/bin/date') - -Output: - - Sat Aug 26 09:38:00 AM CDT 2023 - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - - exec('doesnt_exist') # Raises Errno::ENOENT - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - exec('echo', 'C*') - exec('echo', 'hello', 'world') - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. -**@overload** [] - -**@overload** [] - -## exit(*a , _ ) [](#method-c-exit) -Initiates termination of the Ruby script by raising SystemExit; the exception -may be caught. Returns exit status `status` to the underlying operating -system. - -Values `true` and `false` for argument `status` indicate, respectively, -success and failure; The meanings of integer values are system-dependent. - -Example: - - begin - exit - puts 'Never get here.' - rescue SystemExit - puts 'Rescued a SystemExit exception.' - end - puts 'After begin block.' - -Output: - - Rescued a SystemExit exception. - After begin block. - -Just prior to final termination, Ruby executes any at-exit procedures (see -Kernel::at_exit) and any object finalizers (see -ObjectSpace::define_finalizer). - -Example: - - at_exit { puts 'In at_exit function.' } - ObjectSpace.define_finalizer('string', proc { puts 'In finalizer.' }) - exit - -Output: - - In at_exit function. - In finalizer. -**@overload** [] - -**@overload** [] - -## exit!(*args ) [](#method-c-exit!) -Exits the process immediately; no exit handlers are called. Returns exit -status `status` to the underlying operating system. - - Process.exit!(true) - -Values `true` and `false` for argument `status` indicate, respectively, -success and failure; The meanings of integer values are system-dependent. -**@overload** [] - -**@overload** [] - -## fork() [](#method-c-fork) -Creates a child process. - -With a block given, runs the block in the child process; on block exit, the -child terminates with a status of zero: - - puts "Before the fork: #{Process.pid}" - fork do - puts "In the child process: #{Process.pid}" - end # => 382141 - puts "After the fork: #{Process.pid}" - -Output: - - Before the fork: 420496 - After the fork: 420496 - In the child process: 420520 - -With no block given, the `fork` call returns twice: - -* Once in the parent process, returning the pid of the child process. -* Once in the child process, returning `nil`. - -Example: - - puts "This is the first line before the fork (pid #{Process.pid})" - puts fork - puts "This is the second line after the fork (pid #{Process.pid})" - -Output: - - This is the first line before the fork (pid 420199) - 420223 - This is the second line after the fork (pid 420199) - - This is the second line after the fork (pid 420223) - -In either case, the child process may exit using Kernel.exit! to avoid the -call to Kernel#at_exit. - -To avoid zombie processes, the parent process should call either: - -* Process.wait, to collect the termination statuses of its children. -* Process.detach, to register disinterest in their status. - -The thread calling `fork` is the only thread in the created child process; -`fork` doesn't copy other threads. - -Note that method `fork` is available on some platforms, but not on others: - - Process.respond_to?(:fork) # => true # Would be false on some. - -If not, you may use ::spawn instead of `fork`. -**@overload** [] - -**@overload** [] - -## getpgid(pid ) [](#method-c-getpgid) -Returns the process group ID for the given process ID `pid`: - - Process.getpgid(Process.ppid) # => 25527 - -Not available on all platforms. -**@overload** [] - -## getpgrp() [](#method-c-getpgrp) -Returns the process group ID for the current process: - - Process.getpgid(0) # => 25527 - Process.getpgrp # => 25527 -**@overload** [] - -## getpriority(which , who ) [](#method-c-getpriority) -Returns the scheduling priority for specified process, process group, or user. - -Argument `kind` is one of: - -* Process::PRIO_PROCESS: return priority for process. -* Process::PRIO_PGRP: return priority for process group. -* Process::PRIO_USER: return priority for user. - -Argument `id` is the ID for the process, process group, or user; zero -specified the current ID for `kind`. - -Examples: - - Process.getpriority(Process::PRIO_USER, 0) # => 19 - Process.getpriority(Process::PRIO_PROCESS, 0) # => 19 - -Not available on all platforms. -**@overload** [] - -## getrlimit(resource ) [](#method-c-getrlimit) -Returns a 2-element array of the current (soft) limit and maximum (hard) limit -for the given `resource`. - -Argument `resource` specifies the resource whose limits are to be returned; -see Process.setrlimit. - -Each of the returned values `cur_limit` and `max_limit` is an integer; see -Process.setrlimit. - -Example: - - Process.getrlimit(:CORE) # => [0, 18446744073709551615] - -See Process.setrlimit. - -Not available on all platforms. -**@overload** [] - -## getsid(*args ) [](#method-c-getsid) -Returns the session ID of the given process ID `pid`, or of the current -process if not given: - - Process.getsid # => 27422 - Process.getsid(0) # => 27422 - Process.getsid(Process.pid()) # => 27422 - -Not available on all platforms. -**@overload** [] - -## gid() [](#method-c-gid) -Returns the (real) group ID for the current process: - - Process.gid # => 1000 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## gid=(id ) [](#method-c-gid=) -Sets the group ID for the current process to `new_gid`: - - Process.gid = 1000 # => 1000 -**@overload** [] - -## groups() [](#method-c-groups) -Returns an array of the group IDs in the supplemental group access list for -the current process: - - Process.groups # => [4, 24, 27, 30, 46, 122, 135, 136, 1000] - -These properties of the returned array are system-dependent: - -* Whether (and how) the array is sorted. -* Whether the array includes effective group IDs. -* Whether the array includes duplicate group IDs. -* Whether the array size exceeds the value of Process.maxgroups. - -Use this call to get a sorted and unique array: - - Process.groups.uniq.sort -**@overload** [] - -## groups=(ary ) [](#method-c-groups=) -Sets the supplemental group access list to the given array of group IDs. - - Process.groups # => [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] - Process.groups = [27, 6, 10, 11] # => [27, 6, 10, 11] - Process.groups # => [27, 6, 10, 11] -**@overload** [] - -## initgroups(uname , base_grp ) [](#method-c-initgroups) -Sets the supplemental group access list; the new list includes: - -* The group IDs of those groups to which the user given by `username` - belongs. -* The group ID `gid`. - -Example: - - Process.groups # => [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] - Process.initgroups('me', 30) # => [30, 6, 10, 11] - Process.groups # => [30, 6, 10, 11] - -Not available on all platforms. -**@overload** [] - -## kill(*v , _ ) [](#method-c-kill) -Sends a signal to each process specified by `ids` (which must specify at least -one ID); returns the count of signals sent. - -For each given `id`, if `id` is: - -* Positive, sends the signal to the process whose process ID is `id`. -* Zero, send the signal to all processes in the current process group. -* Negative, sends the signal to a system-dependent collection of processes. - -Argument `signal` specifies the signal to be sent; the argument may be: - -* An integer signal number: e.g., `-29`, `0`, `29`. -* A signal name (string), with or without leading `'SIG'`, and with or - without a further prefixed minus sign (`'-'`): e.g.: - - * `'SIGPOLL'`. - * `'POLL'`, - * `'-SIGPOLL'`. - * `'-POLL'`. - -* A signal symbol, with or without leading `'SIG'`, and with or without a - further prefixed minus sign (`'-'`): e.g.: - - * `:SIGPOLL`. - * `:POLL`. - * `:'-SIGPOLL'`. - * `:'-POLL'`. - -If `signal` is: - -* A non-negative integer, or a signal name or symbol without prefixed `'-'`, - each process with process ID `id` is signalled. -* A negative integer, or a signal name or symbol with prefixed `'-'`, each - process group with group ID `id` is signalled. - -Use method Signal.list to see which signals are supported by Ruby on the -underlying platform; the method returns a hash of the string names and -non-negative integer values of the supported signals. The size and content of -the returned hash varies widely among platforms. - -Additionally, signal `0` is useful to determine if the process exists. - -Example: - - pid = fork do - Signal.trap('HUP') { puts 'Ouch!'; exit } - # ... do some work ... - end - # ... - Process.kill('HUP', pid) - Process.wait - -Output: - - Ouch! - -Exceptions: - -* Raises Errno::EINVAL or RangeError if `signal` is an integer but invalid. -* Raises ArgumentError if `signal` is a string or symbol but invalid. -* Raises Errno::ESRCH or RangeError if one of `ids` is invalid. -* Raises Errno::EPERM if needed permissions are not in force. - -In the last two cases, signals may have been sent to some processes. -**@overload** [] - -## last_status() [](#method-c-last_status) -Returns a Process::Status object representing the most recently exited child -process in the current thread, or `nil` if none: - - Process.spawn('ruby', '-e', 'exit 13') - Process.wait - Process.last_status # => # - - Process.spawn('ruby', '-e', 'exit 14') - Process.wait - Process.last_status # => # - - Process.spawn('ruby', '-e', 'exit 15') - # 'exit 15' has not been reaped by #wait. - Process.last_status # => # - Process.wait - Process.last_status # => # -**@overload** [] - -## maxgroups() [](#method-c-maxgroups) -Returns the maximum number of group IDs allowed in the supplemental group -access list: - - Process.maxgroups # => 32 -**@overload** [] - -## maxgroups=(val ) [](#method-c-maxgroups=) -Sets the maximum number of group IDs allowed in the supplemental group access -list. -**@overload** [] - -## pid() [](#method-c-pid) -Returns the process ID of the current process: - - Process.pid # => 15668 -**@overload** [] - -## ppid() [](#method-c-ppid) -Returns the process ID of the parent of the current process: - - puts "Pid is #{Process.pid}." - fork { puts "Parent pid is #{Process.ppid}." } - -Output: - - Pid is 271290. - Parent pid is 271290. - -May not return a trustworthy value on certain platforms. -**@overload** [] - -## setpgid(pid , pgrp ) [](#method-c-setpgid) -Sets the process group ID for the process given by process ID `pid` to `pgid`. - -Not available on all platforms. -**@overload** [] - -## setpgrp() [](#method-c-setpgrp) -Equivalent to `setpgid(0, 0)`. - -Not available on all platforms. -**@overload** [] - -## setpriority(which , who , prio ) [](#method-c-setpriority) -See Process.getpriority. - -Examples: - - Process.setpriority(Process::PRIO_USER, 0, 19) # => 0 - Process.setpriority(Process::PRIO_PROCESS, 0, 19) # => 0 - Process.getpriority(Process::PRIO_USER, 0) # => 19 - Process.getpriority(Process::PRIO_PROCESS, 0) # => 19 - -Not available on all platforms. -**@overload** [] - -## setproctitle(title ) [](#method-c-setproctitle) -Sets the process title that appears on the ps(1) command. Not necessarily -effective on all platforms. No exception will be raised regardless of the -result, nor will NotImplementedError be raised even if the platform does not -support the feature. - -Calling this method does not affect the value of $0. - - Process.setproctitle('myapp: worker #%d' % worker_id) - -This method first appeared in Ruby 2.1 to serve as a global variable free -means to change the process title. -**@overload** [] - -## setrlimit(*args ) [](#method-c-setrlimit) -Sets limits for the current process for the given `resource` to `cur_limit` -(soft limit) and `max_limit` (hard limit); returns `nil`. - -Argument `resource` specifies the resource whose limits are to be set; the -argument may be given as a symbol, as a string, or as a constant beginning -with `Process::RLIMIT_` (e.g., `:CORE`, `'CORE'`, or `Process::RLIMIT_CORE`. - -The resources available and supported are system-dependent, and may include -(here expressed as symbols): - -* `:AS`: Total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD - except 4.4BSD-Lite). -* `:CORE`: Core size (bytes) (SUSv3). -* `:CPU`: CPU time (seconds) (SUSv3). -* `:DATA`: Data segment (bytes) (SUSv3). -* `:FSIZE`: File size (bytes) (SUSv3). -* `:MEMLOCK`: Total size for mlock(2) (bytes) (4.4BSD, GNU/Linux). -* `:MSGQUEUE`: Allocation for POSIX message queues (bytes) (GNU/Linux). -* `:NICE`: Ceiling on process's nice(2) value (number) (GNU/Linux). -* `:NOFILE`: File descriptors (number) (SUSv3). -* `:NPROC`: Number of processes for the user (number) (4.4BSD, GNU/Linux). -* `:NPTS`: Number of pseudo terminals (number) (FreeBSD). -* `:RSS`: Resident memory size (bytes) (4.2BSD, GNU/Linux). -* `:RTPRIO`: Ceiling on the process's real-time priority (number) - (GNU/Linux). -* `:RTTIME`: CPU time for real-time process (us) (GNU/Linux). -* `:SBSIZE`: All socket buffers (bytes) (NetBSD, FreeBSD). -* `:SIGPENDING`: Number of queued signals allowed (signals) (GNU/Linux). -* `:STACK`: Stack size (bytes) (SUSv3). - -Arguments `cur_limit` and `max_limit` may be: - -* Integers (`max_limit` should not be smaller than `cur_limit`). -* Symbol `:SAVED_MAX`, string `'SAVED_MAX'`, or constant - `Process::RLIM_SAVED_MAX`: saved maximum limit. -* Symbol `:SAVED_CUR`, string `'SAVED_CUR'`, or constant - `Process::RLIM_SAVED_CUR`: saved current limit. -* Symbol `:INFINITY`, string `'INFINITY'`, or constant - `Process::RLIM_INFINITY`: no limit on resource. - -This example raises the soft limit of core size to the hard limit to try to -make core dump possible: - - Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1]) - -Not available on all platforms. -**@overload** [] - -## setsid() [](#method-c-setsid) -Establishes the current process as a new session and process group leader, -with no controlling tty; returns the session ID: - - Process.setsid # => 27422 - -Not available on all platforms. -**@overload** [] - -## spawn(*args ) [](#method-c-spawn) -Creates a new child process by doing one of the following in that process: - -* Passing string `command_line` to the shell. -* Invoking the executable at `exe_path`. - -This method has potential security vulnerabilities if called with untrusted -input; see [Command Injection](rdoc-ref:command_injection.rdoc). - -Returns the process ID (pid) of the new process, without waiting for it to -complete. - -To avoid zombie processes, the parent process should call either: - -* Process.wait, to collect the termination statuses of its children. -* Process.detach, to register disinterest in their status. - -The new process is created using the [exec system -call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e -xecve.html); it may inherit some of its environment from the calling program -(possibly including open file descriptors). - -Argument `env`, if given, is a hash that affects `ENV` for the new process; -see [Execution Environment](rdoc-ref:Process@Execution+Environment). - -Argument `options` is a hash of options for the new process; see [Execution -Options](rdoc-ref:Process@Execution+Options). - -The first required argument is one of the following: - -* `command_line` if it is a string, and if it begins with a shell reserved - word or special built-in, or if it contains one or more meta characters. -* `exe_path` otherwise. - -**Argument `command_line`** - -String argument `command_line` is a command line to be passed to a shell; it -must begin with a shell reserved word, begin with a special built-in, or -contain meta characters: - - spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word. - Process.wait # => 798847 - spawn('exit') # => 798848 # Built-in. - Process.wait # => 798848 - spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character. - Process.wait # => 798849 - spawn('date > /nop/date.tmp') # => 798882 # Issues error message. - Process.wait # => 798882 - -The command line may also contain arguments and options for the command: - - spawn('echo "Foo"') # => 799031 - Process.wait # => 799031 - -Output: - - Foo - -See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the -shell. - -Raises an exception if the new process could not execute. - -**Argument `exe_path`** - -Argument `exe_path` is one of the following: - -* The string path to an executable to be called. -* A 2-element array containing the path to an executable to be called, and - the string to be used as the name of the executing process. - - spawn('/usr/bin/date') # Path to date on Unix-style system. - Process.wait - - Output: - - Mon Aug 28 11:43:10 AM CDT 2023 - -Ruby invokes the executable directly. This form does not use the shell; see -[Arguments args](rdoc-ref:Process@Arguments+args) for caveats. - -If one or more `args` is given, each is an argument or option to be passed to -the executable: - - spawn('echo', 'C*') # => 799392 - Process.wait # => 799392 - spawn('echo', 'hello', 'world') # => 799393 - Process.wait # => 799393 - -Output: - - C* - hello world - -Raises an exception if the new process could not execute. -**@overload** [] - -**@overload** [] - -## times() [](#method-c-times) -Returns a Process::Tms structure that contains user and system CPU times for -the current process, and for its children processes: - - Process.times - # => # - -The precision is platform-defined. -**@overload** [] - -## uid() [](#method-c-uid) -Returns the (real) user ID of the current process. - - Process.uid # => 1000 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## uid=(id ) [](#method-c-uid=) -Sets the (user) user ID for the current process to `new_uid`: - - Process.uid = 1000 # => 1000 - -Not available on all platforms. -**@overload** [] - -## wait(*v , _ ) [](#method-c-wait) -Waits for a suitable child process to exit, returns its process ID, and sets -`$?` to a Process::Status object containing information on that process. Which -child it waits for depends on the value of the given `pid`: - -* Positive integer: Waits for the child process whose process ID is `pid`: - - pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 230866 - pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 230891 - Process.wait(pid0) # => 230866 - $? # => # - Process.wait(pid1) # => 230891 - $? # => # - Process.wait(pid0) # Raises Errno::ECHILD - -* `0`: Waits for any child process whose group ID is the same as that of the - current process: - - parent_pgpid = Process.getpgid(Process.pid) - puts "Parent process group ID is #{parent_pgpid}." - child0_pid = fork do - puts "Child 0 pid is #{Process.pid}" - child0_pgid = Process.getpgid(Process.pid) - puts "Child 0 process group ID is #{child0_pgid} (same as parent's)." - end - child1_pid = fork do - puts "Child 1 pid is #{Process.pid}" - Process.setpgid(0, Process.pid) - child1_pgid = Process.getpgid(Process.pid) - puts "Child 1 process group ID is #{child1_pgid} (different from parent's)." - end - retrieved_pid = Process.wait(0) - puts "Process.wait(0) returned pid #{retrieved_pid}, which is child 0 pid." - begin - Process.wait(0) - rescue Errno::ECHILD => x - puts "Raised #{x.class}, because child 1 process group ID differs from parent process group ID." - end - - Output: - - Parent process group ID is 225764. - Child 0 pid is 225788 - Child 0 process group ID is 225764 (same as parent's). - Child 1 pid is 225789 - Child 1 process group ID is 225789 (different from parent's). - Process.wait(0) returned pid 225788, which is child 0 pid. - Raised Errno::ECHILD, because child 1 process group ID differs from parent process group ID. - -* `-1` (default): Waits for any child process: - - parent_pgpid = Process.getpgid(Process.pid) - puts "Parent process group ID is #{parent_pgpid}." - child0_pid = fork do - puts "Child 0 pid is #{Process.pid}" - child0_pgid = Process.getpgid(Process.pid) - puts "Child 0 process group ID is #{child0_pgid} (same as parent's)." - end - child1_pid = fork do - puts "Child 1 pid is #{Process.pid}" - Process.setpgid(0, Process.pid) - child1_pgid = Process.getpgid(Process.pid) - puts "Child 1 process group ID is #{child1_pgid} (different from parent's)." - sleep 3 # To force child 1 to exit later than child 0 exit. - end - child_pids = [child0_pid, child1_pid] - retrieved_pid = Process.wait(-1) - puts child_pids.include?(retrieved_pid) - retrieved_pid = Process.wait(-1) - puts child_pids.include?(retrieved_pid) - - Output: - - Parent process group ID is 228736. - Child 0 pid is 228758 - Child 0 process group ID is 228736 (same as parent's). - Child 1 pid is 228759 - Child 1 process group ID is 228759 (different from parent's). - true - true - -* Less than `-1`: Waits for any child whose process group ID is `-pid`: - - parent_pgpid = Process.getpgid(Process.pid) - puts "Parent process group ID is #{parent_pgpid}." - child0_pid = fork do - puts "Child 0 pid is #{Process.pid}" - child0_pgid = Process.getpgid(Process.pid) - puts "Child 0 process group ID is #{child0_pgid} (same as parent's)." - end - child1_pid = fork do - puts "Child 1 pid is #{Process.pid}" - Process.setpgid(0, Process.pid) - child1_pgid = Process.getpgid(Process.pid) - puts "Child 1 process group ID is #{child1_pgid} (different from parent's)." - end - sleep 1 - retrieved_pid = Process.wait(-child1_pid) - puts "Process.wait(-child1_pid) returned pid #{retrieved_pid}, which is child 1 pid." - begin - Process.wait(-child1_pid) - rescue Errno::ECHILD => x - puts "Raised #{x.class}, because there's no longer a child with process group id #{child1_pid}." - end - - Output: - - Parent process group ID is 230083. - Child 0 pid is 230108 - Child 0 process group ID is 230083 (same as parent's). - Child 1 pid is 230109 - Child 1 process group ID is 230109 (different from parent's). - Process.wait(-child1_pid) returned pid 230109, which is child 1 pid. - Raised Errno::ECHILD, because there's no longer a child with process group id 230109. - -Argument `flags` should be given as one of the following constants, or as the -logical OR of both: - -* Process::WNOHANG: Does not block if no child process is available. -* Process::WUNTRACED: May return a stopped child process, even if not yet - reported. - -Not all flags are available on all platforms. - -Raises Errno::ECHILD if there is no suitable child process. - -Not available on all platforms. - -Process.waitpid is an alias for Process.wait. -**@overload** [] - -## wait2(*args ) [](#method-c-wait2) -Like Process.waitpid, but returns an array containing the child process `pid` -and Process::Status `status`: - - pid = Process.spawn('ruby', '-e', 'exit 13') # => 309581 - Process.wait2(pid) - # => [309581, #] - -Process.waitpid2 is an alias for Process.wait2. -**@overload** [] - -## waitall() [](#method-c-waitall) -Waits for all children, returns an array of 2-element arrays; each subarray -contains the integer pid and Process::Status status for one of the reaped -child processes: - - pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 325470 - pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 325495 - Process.waitall - # => [[325470, #], [325495, #]] -**@overload** [] - -## waitpid(*v , _ ) [](#method-c-waitpid) -Waits for a suitable child process to exit, returns its process ID, and sets -`$?` to a Process::Status object containing information on that process. Which -child it waits for depends on the value of the given `pid`: - -* Positive integer: Waits for the child process whose process ID is `pid`: - - pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 230866 - pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 230891 - Process.wait(pid0) # => 230866 - $? # => # - Process.wait(pid1) # => 230891 - $? # => # - Process.wait(pid0) # Raises Errno::ECHILD - -* `0`: Waits for any child process whose group ID is the same as that of the - current process: - - parent_pgpid = Process.getpgid(Process.pid) - puts "Parent process group ID is #{parent_pgpid}." - child0_pid = fork do - puts "Child 0 pid is #{Process.pid}" - child0_pgid = Process.getpgid(Process.pid) - puts "Child 0 process group ID is #{child0_pgid} (same as parent's)." - end - child1_pid = fork do - puts "Child 1 pid is #{Process.pid}" - Process.setpgid(0, Process.pid) - child1_pgid = Process.getpgid(Process.pid) - puts "Child 1 process group ID is #{child1_pgid} (different from parent's)." - end - retrieved_pid = Process.wait(0) - puts "Process.wait(0) returned pid #{retrieved_pid}, which is child 0 pid." - begin - Process.wait(0) - rescue Errno::ECHILD => x - puts "Raised #{x.class}, because child 1 process group ID differs from parent process group ID." - end - - Output: - - Parent process group ID is 225764. - Child 0 pid is 225788 - Child 0 process group ID is 225764 (same as parent's). - Child 1 pid is 225789 - Child 1 process group ID is 225789 (different from parent's). - Process.wait(0) returned pid 225788, which is child 0 pid. - Raised Errno::ECHILD, because child 1 process group ID differs from parent process group ID. - -* `-1` (default): Waits for any child process: - - parent_pgpid = Process.getpgid(Process.pid) - puts "Parent process group ID is #{parent_pgpid}." - child0_pid = fork do - puts "Child 0 pid is #{Process.pid}" - child0_pgid = Process.getpgid(Process.pid) - puts "Child 0 process group ID is #{child0_pgid} (same as parent's)." - end - child1_pid = fork do - puts "Child 1 pid is #{Process.pid}" - Process.setpgid(0, Process.pid) - child1_pgid = Process.getpgid(Process.pid) - puts "Child 1 process group ID is #{child1_pgid} (different from parent's)." - sleep 3 # To force child 1 to exit later than child 0 exit. - end - child_pids = [child0_pid, child1_pid] - retrieved_pid = Process.wait(-1) - puts child_pids.include?(retrieved_pid) - retrieved_pid = Process.wait(-1) - puts child_pids.include?(retrieved_pid) - - Output: - - Parent process group ID is 228736. - Child 0 pid is 228758 - Child 0 process group ID is 228736 (same as parent's). - Child 1 pid is 228759 - Child 1 process group ID is 228759 (different from parent's). - true - true - -* Less than `-1`: Waits for any child whose process group ID is `-pid`: - - parent_pgpid = Process.getpgid(Process.pid) - puts "Parent process group ID is #{parent_pgpid}." - child0_pid = fork do - puts "Child 0 pid is #{Process.pid}" - child0_pgid = Process.getpgid(Process.pid) - puts "Child 0 process group ID is #{child0_pgid} (same as parent's)." - end - child1_pid = fork do - puts "Child 1 pid is #{Process.pid}" - Process.setpgid(0, Process.pid) - child1_pgid = Process.getpgid(Process.pid) - puts "Child 1 process group ID is #{child1_pgid} (different from parent's)." - end - sleep 1 - retrieved_pid = Process.wait(-child1_pid) - puts "Process.wait(-child1_pid) returned pid #{retrieved_pid}, which is child 1 pid." - begin - Process.wait(-child1_pid) - rescue Errno::ECHILD => x - puts "Raised #{x.class}, because there's no longer a child with process group id #{child1_pid}." - end - - Output: - - Parent process group ID is 230083. - Child 0 pid is 230108 - Child 0 process group ID is 230083 (same as parent's). - Child 1 pid is 230109 - Child 1 process group ID is 230109 (different from parent's). - Process.wait(-child1_pid) returned pid 230109, which is child 1 pid. - Raised Errno::ECHILD, because there's no longer a child with process group id 230109. - -Argument `flags` should be given as one of the following constants, or as the -logical OR of both: - -* Process::WNOHANG: Does not block if no child process is available. -* Process::WUNTRACED: May return a stopped child process, even if not yet - reported. - -Not all flags are available on all platforms. - -Raises Errno::ECHILD if there is no suitable child process. - -Not available on all platforms. - -Process.waitpid is an alias for Process.wait. -**@overload** [] - -## waitpid2(*args ) [](#method-c-waitpid2) -Like Process.waitpid, but returns an array containing the child process `pid` -and Process::Status `status`: - - pid = Process.spawn('ruby', '-e', 'exit 13') # => 309581 - Process.wait2(pid) - # => [309581, #] - -Process.waitpid2 is an alias for Process.wait2. -**@overload** [] - -## warmup() [](#method-c-warmup) -Notify the Ruby virtual machine that the boot sequence is finished, and that -now is a good time to optimize the application. This is useful for long -running applications. - -This method is expected to be called at the end of the application boot. If -the application is deployed using a pre-forking model, `Process.warmup` should -be called in the original process before the first fork. - -The actual optimizations performed are entirely implementation specific and -may change in the future without notice. - -On CRuby, `Process.warmup`: - -* Performs a major GC. -* Compacts the heap. -* Promotes all surviving objects to the old generation. -* Precomputes the coderange of all strings. -* Frees all empty heap pages and increments the allocatable pages counter by - the number of pages freed. -* Invoke `malloc_trim` if available to free empty malloc pages. -**@overload** [] - - diff --git a/example/ruby/Process/GID.md b/example/ruby/Process/GID.md deleted file mode 100644 index 5d2db36..0000000 --- a/example/ruby/Process/GID.md +++ /dev/null @@ -1,77 +0,0 @@ -# Module: Process::GID - - - - -# Class Methods -## change_privilege(id ) [](#method-c-change_privilege) -Change the current process's real and effective group ID to that specified by -*group*. Returns the new group ID. Not available on all platforms. - - [Process.gid, Process.egid] #=> [0, 0] - Process::GID.change_privilege(33) #=> 33 - [Process.gid, Process.egid] #=> [33, 33] -**@overload** [] - -## eid() [](#method-c-eid) -Returns the effective group ID for the current process: - - Process.egid # => 500 - -Not available on all platforms. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## from_name(id ) [](#method-c-from_name) -Get the group ID by the *name*. If the group is not found, `ArgumentError` -will be raised. - - Process::GID.from_name("wheel") #=> 0 - Process::GID.from_name("nosuchgroup") #=> can't find group for nosuchgroup (ArgumentError) -**@overload** [] - -## grant_privilege(id ) [](#method-c-grant_privilege) -Set the effective group ID, and if possible, the saved group ID of the process -to the given *group*. Returns the new effective group ID. Not available on all -platforms. - - [Process.gid, Process.egid] #=> [0, 0] - Process::GID.grant_privilege(31) #=> 33 - [Process.gid, Process.egid] #=> [0, 33] -**@overload** [] - -**@overload** [] - -## re_exchange() [](#method-c-re_exchange) -Exchange real and effective group IDs and return the new effective group ID. -Not available on all platforms. - - [Process.gid, Process.egid] #=> [0, 33] - Process::GID.re_exchange #=> 0 - [Process.gid, Process.egid] #=> [33, 0] -**@overload** [] - -## re_exchangeable?() [](#method-c-re_exchangeable?) -Returns `true` if the real and effective group IDs of a process may be -exchanged on the current platform. -**@overload** [] - -## rid() [](#method-c-rid) -Returns the (real) group ID for the current process: - - Process.gid # => 1000 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## sid_available?() [](#method-c-sid_available?) -Returns `true` if the current platform has saved group ID functionality. -**@overload** [] - -## switch() [](#method-c-switch) - diff --git a/example/ruby/Process/Status.md b/example/ruby/Process/Status.md deleted file mode 100644 index 6ca464d..0000000 --- a/example/ruby/Process/Status.md +++ /dev/null @@ -1,145 +0,0 @@ -# Class: Process::Status -**Inherits:** Object - - -******************************************************************* - - A Process::Status contains information about a system process. - - Thread-local variable $? is initially +nil+. - Some methods assign to it a Process::Status object - that represents a system process (either running or terminated): - - `ruby -e "exit 99"` - stat = $? # => # - stat.class # => Process::Status - stat.to_i # => 25344 - stat.stopped? # => false - stat.exited? # => true - stat.exitstatus # => 99 - - -# Class Methods -## wait(*args ) [](#method-c-wait) -Like Process.wait, but returns a Process::Status object (instead of an integer -pid or nil); see Process.wait for the values of `pid` and `flags`. - -If there are child processes, waits for a child process to exit and returns a -Process::Status object containing information on that process; sets -thread-local variable `$?`: - - Process.spawn('cat /nop') # => 1155880 - Process::Status.wait # => # - $? # => # - -If there is no child process, returns an "empty" Process::Status object that -does not represent an actual process; does not set thread-local variable `$?`: - - Process::Status.wait # => # - $? # => # # Unchanged. - -May invoke the scheduler hook Fiber::Scheduler#process_wait. - -Not available on all platforms. -**@overload** [] - - -#Instance Methods -## ==(st2) [](#method-i-==) -Returns whether the value of #to_i == `other`: - - `cat /nop` - stat = $? # => # - sprintf('%x', stat.to_i) # => "100" - stat == 0x100 # => true - -**@overload** [] - -## coredump?() [](#method-i-coredump?) -Returns `true` if the process generated a coredump when it terminated, `false` -if not. - -Not available on all platforms. - -**@overload** [] - -## exited?() [](#method-i-exited?) -Returns `true` if the process exited normally (for example using an `exit()` -call or finishing the program), `false` if not. - -**@overload** [] - -## exitstatus() [](#method-i-exitstatus) -Returns the least significant eight bits of the return code of the process if -it has exited; `nil` otherwise: - - `exit 99` - $?.exitstatus # => 99 - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - system("false") - $?.inspect # => "#" - -**@overload** [] - -## pid() [](#method-i-pid) -Returns the process ID of the process: - - system("false") - $?.pid # => 1247002 - -**@overload** [] - -## signaled?() [](#method-i-signaled?) -Returns `true` if the process terminated because of an uncaught signal, -`false` otherwise. - -**@overload** [] - -## stopped?() [](#method-i-stopped?) -Returns `true` if this process is stopped, and if the corresponding #wait call -had the Process::WUNTRACED flag set, `false` otherwise. - -**@overload** [] - -## stopsig() [](#method-i-stopsig) -Returns the number of the signal that caused the process to stop, or `nil` if -the process is not stopped. - -**@overload** [] - -## success?() [](#method-i-success?) -Returns: - -* `true` if the process has completed successfully and exited. -* `false` if the process has completed unsuccessfully and exited. -* `nil` if the process has not exited. - -**@overload** [] - -## termsig() [](#method-i-termsig) -Returns the number of the signal that caused the process to terminate or `nil` -if the process was not terminated by an uncaught signal. - -**@overload** [] - -## to_i() [](#method-i-to_i) -Returns the system-dependent integer status of `self`: - - `cat /nop` - $?.to_i # => 256 - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns a string representation of `self`: - - `cat /nop` - $?.to_s # => "pid 1262141 exit 1" - -**@overload** [] - diff --git a/example/ruby/Process/Sys.md b/example/ruby/Process/Sys.md deleted file mode 100644 index 5a78aec..0000000 --- a/example/ruby/Process/Sys.md +++ /dev/null @@ -1,110 +0,0 @@ -# Module: Process::Sys - - - - -# Class Methods -## getegid() [](#method-c-getegid) -Returns the effective group ID for the current process: - - Process.egid # => 500 - -Not available on all platforms. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## geteuid() [](#method-c-geteuid) -Returns the effective user ID for the current process. - - Process.euid # => 501 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## getgid() [](#method-c-getgid) -Returns the (real) group ID for the current process: - - Process.gid # => 1000 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## getuid() [](#method-c-getuid) -Returns the (real) user ID of the current process. - - Process.uid # => 1000 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## issetugid() [](#method-c-issetugid) -Returns `true` if the process was created as a result of an execve(2) system -call which had either of the setuid or setgid bits set (and extra privileges -were given as a result) or if it has changed any of its real, effective or -saved user or group IDs since it began execution. -**@overload** [] - -## setegid(id ) [](#method-c-setegid) -Set the effective group ID of the calling process to *group*. Not available -on all platforms. -**@overload** [] - -## seteuid(id ) [](#method-c-seteuid) -Set the effective user ID of the calling process to *user*. Not available on -all platforms. -**@overload** [] - -## setgid(id ) [](#method-c-setgid) -Set the group ID of the current process to *group*. Not available on all -platforms. -**@overload** [] - -## setregid(rid , eid ) [](#method-c-setregid) -Sets the (group) real and/or effective group IDs of the current process to -*rid* and *eid*, respectively. A value of `-1` for either means to leave that -ID unchanged. Not available on all platforms. -**@overload** [] - -## setresgid(rid , eid , sid ) [](#method-c-setresgid) -Sets the (group) real, effective, and saved user IDs of the current process to -*rid*, *eid*, and *sid* respectively. A value of `-1` for any value means to -leave that ID unchanged. Not available on all platforms. -**@overload** [] - -## setresuid(rid , eid , sid ) [](#method-c-setresuid) -Sets the (user) real, effective, and saved user IDs of the current process to -*rid*, *eid*, and *sid* respectively. A value of `-1` for any value means to -leave that ID unchanged. Not available on all platforms. -**@overload** [] - -## setreuid(rid , eid ) [](#method-c-setreuid) -Sets the (user) real and/or effective user IDs of the current process to *rid* -and *eid*, respectively. A value of `-1` for either means to leave that ID -unchanged. Not available on all platforms. -**@overload** [] - -## setrgid(id ) [](#method-c-setrgid) -Set the real group ID of the calling process to *group*. Not available on all -platforms. -**@overload** [] - -## setruid(id ) [](#method-c-setruid) -Set the real user ID of the calling process to *user*. Not available on all -platforms. -**@overload** [] - -## setuid(id ) [](#method-c-setuid) -Set the user ID of the current process to *user*. Not available on all -platforms. -**@overload** [] - - diff --git a/example/ruby/Process/Tms.md b/example/ruby/Process/Tms.md deleted file mode 100644 index 4f1691d..0000000 --- a/example/ruby/Process/Tms.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Process::Tms -**Inherits:** Object - - -******************************************************************* - - Placeholder for rusage - - - diff --git a/example/ruby/Process/UID.md b/example/ruby/Process/UID.md deleted file mode 100644 index 57115c8..0000000 --- a/example/ruby/Process/UID.md +++ /dev/null @@ -1,75 +0,0 @@ -# Module: Process::UID - - - - -# Class Methods -## change_privilege(id ) [](#method-c-change_privilege) -Change the current process's real and effective user ID to that specified by -*user*. Returns the new user ID. Not available on all platforms. - - [Process.uid, Process.euid] #=> [0, 0] - Process::UID.change_privilege(31) #=> 31 - [Process.uid, Process.euid] #=> [31, 31] -**@overload** [] - -## eid() [](#method-c-eid) -Returns the effective user ID for the current process. - - Process.euid # => 501 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## from_name(id ) [](#method-c-from_name) -Get the user ID by the *name*. If the user is not found, `ArgumentError` will -be raised. - - Process::UID.from_name("root") #=> 0 - Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError) -**@overload** [] - -## grant_privilege(id ) [](#method-c-grant_privilege) -Set the effective user ID, and if possible, the saved user ID of the process -to the given *user*. Returns the new effective user ID. Not available on all -platforms. - - [Process.uid, Process.euid] #=> [0, 0] - Process::UID.grant_privilege(31) #=> 31 - [Process.uid, Process.euid] #=> [0, 31] -**@overload** [] - -**@overload** [] - -## re_exchange() [](#method-c-re_exchange) -Exchange real and effective user IDs and return the new effective user ID. Not -available on all platforms. - - [Process.uid, Process.euid] #=> [0, 31] - Process::UID.re_exchange #=> 0 - [Process.uid, Process.euid] #=> [31, 0] -**@overload** [] - -## re_exchangeable?() [](#method-c-re_exchangeable?) -Returns `true` if the real and effective user IDs of a process may be -exchanged on the current platform. -**@overload** [] - -## rid() [](#method-c-rid) -Returns the (real) user ID of the current process. - - Process.uid # => 1000 -**@overload** [] - -**@overload** [] - -**@overload** [] - -## sid_available?() [](#method-c-sid_available?) -Returns `true` if the current platform has saved user ID functionality. -**@overload** [] - -## switch() [](#method-c-switch) - diff --git a/example/ruby/Process/Waiter.md b/example/ruby/Process/Waiter.md deleted file mode 100644 index b6d32bf..0000000 --- a/example/ruby/Process/Waiter.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Process::Waiter -**Inherits:** Thread - - - - - -#Instance Methods -## pid() [](#method-i-pid) - diff --git a/example/ruby/ProcessSpecs.md b/example/ruby/ProcessSpecs.md deleted file mode 100644 index d55fba2..0000000 --- a/example/ruby/ProcessSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ProcessSpecs - - - - -# Class Methods -## clock_constants() [](#method-c-clock_constants) -## use_system_ruby(context ) [](#method-c-use_system_ruby) - diff --git a/example/ruby/ProcessSpecs/Daemon.md b/example/ruby/ProcessSpecs/Daemon.md deleted file mode 100644 index 4072b6f..0000000 --- a/example/ruby/ProcessSpecs/Daemon.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: ProcessSpecs::Daemon -**Inherits:** Object - - - - - -#Instance Methods -## daemon_at_exit() [](#method-i-daemon_at_exit) - -## daemonizing_at_exit() [](#method-i-daemonizing_at_exit) - -## initialize(argv) [](#method-i-initialize) - -**@return** [Daemon] a new instance of Daemon - -## keep_stdio_open_false_stderr() [](#method-i-keep_stdio_open_false_stderr) - -## keep_stdio_open_false_stdin() [](#method-i-keep_stdio_open_false_stdin) - -## keep_stdio_open_false_stdout() [](#method-i-keep_stdio_open_false_stdout) - -## keep_stdio_open_files() [](#method-i-keep_stdio_open_files) - -## keep_stdio_open_true_stderr() [](#method-i-keep_stdio_open_true_stderr) - -## keep_stdio_open_true_stdin() [](#method-i-keep_stdio_open_true_stdin) - -## keep_stdio_open_true_stdout() [](#method-i-keep_stdio_open_true_stdout) - -## pid() [](#method-i-pid) - -## process_group() [](#method-i-process_group) - -## return_value() [](#method-i-return_value) - -## run() [](#method-i-run) - -## stay_in_dir() [](#method-i-stay_in_dir) - -## write(data) [](#method-i-write) - diff --git a/example/ruby/ProcessSpecs/Daemonizer.md b/example/ruby/ProcessSpecs/Daemonizer.md deleted file mode 100644 index c3be530..0000000 --- a/example/ruby/ProcessSpecs/Daemonizer.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: ProcessSpecs::Daemonizer -**Inherits:** Object - - - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - -## input[RW] [](#attribute-i-input) -Returns the value of attribute input. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@raise** [NotImplementedError] - -**@return** [Daemonizer] a new instance of Daemonizer - -## invoke(behavior, arguments[]) [](#method-i-invoke) - -## wait_for_daemon() [](#method-i-wait_for_daemon) - diff --git a/example/ruby/ProcessSpecs/Signalizer.md b/example/ruby/ProcessSpecs/Signalizer.md deleted file mode 100644 index ffb6953..0000000 --- a/example/ruby/ProcessSpecs/Signalizer.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: ProcessSpecs::Signalizer -**Inherits:** Object - - - - -# Attributes -## pid[RW] [](#attribute-i-pid) -Returns the value of attribute pid. - -## pid_file[RW] [](#attribute-i-pid_file) -Returns the value of attribute pid_file. - - -#Instance Methods -## cleanup() [](#method-i-cleanup) - -## initialize(scenarionil) [](#method-i-initialize) - -**@return** [Signalizer] a new instance of Signalizer - -## result() [](#method-i-result) - -## wait_on_result() [](#method-i-wait_on_result) - diff --git a/example/ruby/ProfileAction.md b/example/ruby/ProfileAction.md deleted file mode 100644 index ed07c9e..0000000 --- a/example/ruby/ProfileAction.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: ProfileAction -**Inherits:** Object - - - - - -#Instance Methods -## after(statenil) [](#method-i-after) - -## before(state) [](#method-i-before) - -## enter(describe) [](#method-i-enter) - -## finish() [](#method-i-finish) - -## initialize() [](#method-i-initialize) - -**@return** [ProfileAction] a new instance of ProfileAction - -## now() [](#method-i-now) - -## register() [](#method-i-register) - diff --git a/example/ruby/ProfileFilter.md b/example/ruby/ProfileFilter.md deleted file mode 100644 index c60d9fd..0000000 --- a/example/ruby/ProfileFilter.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: ProfileFilter -**Inherits:** Object - - - - - -#Instance Methods -## ===(string) [](#method-i-===) - -## find(name) [](#method-i-find) - -## initialize(what, *files) [](#method-i-initialize) - -**@return** [ProfileFilter] a new instance of ProfileFilter - -## load(*files) [](#method-i-load) - -## parse(file) [](#method-i-parse) - -## register() [](#method-i-register) - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/ProfileFormatter.md b/example/ruby/ProfileFormatter.md deleted file mode 100644 index cbfd153..0000000 --- a/example/ruby/ProfileFormatter.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ProfileFormatter -**Inherits:** DottedFormatter - - - - - -#Instance Methods -## initialize(outnil) [](#method-i-initialize) - -**@return** [ProfileFormatter] a new instance of ProfileFormatter - -## register() [](#method-i-register) - diff --git a/example/ruby/Progress.md b/example/ruby/Progress.md deleted file mode 100644 index b49a1ca..0000000 --- a/example/ruby/Progress.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Progress -**Inherits:** Object - - - - - -#Instance Methods -## fail() [](#method-i-fail) - -## failed_string() [](#method-i-failed_string) - -## finish() [](#method-i-finish) - -## finish_string() [](#method-i-finish_string) - -## init() [](#method-i-init) - -## init_string() [](#method-i-init_string) - -## initialize() [](#method-i-initialize) - -**@return** [Progress] a new instance of Progress - -## pass() [](#method-i-pass) - -## passed_string() [](#method-i-passed_string) - diff --git a/example/ruby/Progress/Rotator.md b/example/ruby/Progress/Rotator.md deleted file mode 100644 index 442abc6..0000000 --- a/example/ruby/Progress/Rotator.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: Progress::Rotator - - - - - -#Instance Methods -## failed_string() [](#method-i-failed_string) - -## finish_string() [](#method-i-finish_string) - -## init_string() [](#method-i-init_string) - -## passed_string() [](#method-i-passed_string) - diff --git a/example/ruby/Project.md b/example/ruby/Project.md deleted file mode 100644 index 6fd483d..0000000 --- a/example/ruby/Project.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: Project -**Inherits:** Object - - - - -# Class Methods -## bo0k() [](#method-c-bo0k) - diff --git a/example/ruby/Psych.md b/example/ruby/Psych.md deleted file mode 100644 index b3bc8bc..0000000 --- a/example/ruby/Psych.md +++ /dev/null @@ -1,562 +0,0 @@ -# Module: Psych - - -# Overview - -Psych is a YAML parser and emitter. Psych leverages libyaml [Home page: -https://pyyaml.org/wiki/LibYAML] or [git repo: -https://github.com/yaml/libyaml] for its YAML parsing and emitting -capabilities. In addition to wrapping libyaml, Psych also knows how to -serialize and de-serialize most Ruby objects to and from the YAML format. - -# I NEED TO PARSE OR EMIT YAML RIGHT NOW! - - # Parse some YAML - Psych.load("--- foo") # => "foo" - - # Emit some YAML - Psych.dump("foo") # => "--- foo\n...\n" - { :a => 'b'}.to_yaml # => "---\n:a: b\n" - -Got more time on your hands? Keep on reading! - -## YAML Parsing - -Psych provides a range of interfaces for parsing a YAML document ranging from -low level to high level, depending on your parsing needs. At the lowest -level, is an event based parser. Mid level is access to the raw YAML AST, and -at the highest level is the ability to unmarshal YAML to Ruby objects. - -## YAML Emitting - -Psych provides a range of interfaces ranging from low to high level for -producing YAML documents. Very similar to the YAML parsing interfaces, Psych -provides at the lowest level, an event based system, mid-level is building a -YAML AST, and the highest level is converting a Ruby object straight to a YAML -document. - -## High-level API - -### Parsing - -The high level YAML parser provided by Psych simply takes YAML as input and -returns a Ruby data structure. For information on using the high level parser -see Psych.load - -#### Reading from a string - - Psych.safe_load("--- a") # => 'a' - Psych.safe_load("---\n - a\n - b") # => ['a', 'b'] - # From a trusted string: - Psych.load("--- !ruby/range\nbegin: 0\nend: 42\nexcl: false\n") # => 0..42 - -#### Reading from a file - - Psych.safe_load_file("data.yml", permitted_classes: [Date]) - Psych.load_file("trusted_database.yml") - -#### Exception handling - - begin - # The second argument changes only the exception contents - Psych.parse("--- `", "file.txt") - rescue Psych::SyntaxError => ex - ex.file # => 'file.txt' - ex.message # => "(file.txt): found character that cannot start any token" - end - -### Emitting - -The high level emitter has the easiest interface. Psych simply takes a Ruby -data structure and converts it to a YAML document. See Psych.dump for more -information on dumping a Ruby data structure. - -#### Writing to a string - - # Dump an array, get back a YAML string - Psych.dump(['a', 'b']) # => "---\n- a\n- b\n" - - # Dump an array to an IO object - Psych.dump(['a', 'b'], StringIO.new) # => # - - # Dump an array with indentation set - Psych.dump(['a', ['b']], :indentation => 3) # => "---\n- a\n- - b\n" - - # Dump an array to an IO with indentation set - Psych.dump(['a', ['b']], StringIO.new, :indentation => 3) - -#### Writing to a file - -Currently there is no direct API for dumping Ruby structure to file: - - File.open('database.yml', 'w') do |file| - file.write(Psych.dump(['a', 'b'])) - end - -## Mid-level API - -### Parsing - -Psych provides access to an AST produced from parsing a YAML document. This -tree is built using the Psych::Parser and Psych::TreeBuilder. The AST can be -examined and manipulated freely. Please see Psych::parse_stream, -Psych::Nodes, and Psych::Nodes::Node for more information on dealing with YAML -syntax trees. - -#### Reading from a string - - # Returns Psych::Nodes::Stream - Psych.parse_stream("---\n - a\n - b") - - # Returns Psych::Nodes::Document - Psych.parse("---\n - a\n - b") - -#### Reading from a file - - # Returns Psych::Nodes::Stream - Psych.parse_stream(File.read('database.yml')) - - # Returns Psych::Nodes::Document - Psych.parse_file('database.yml') - -#### Exception handling - - begin - # The second argument changes only the exception contents - Psych.parse("--- `", "file.txt") - rescue Psych::SyntaxError => ex - ex.file # => 'file.txt' - ex.message # => "(file.txt): found character that cannot start any token" - end - -### Emitting - -At the mid level is building an AST. This AST is exactly the same as the AST -used when parsing a YAML document. Users can build an AST by hand and the AST -knows how to emit itself as a YAML document. See Psych::Nodes, -Psych::Nodes::Node, and Psych::TreeBuilder for more information on building a -YAML AST. - -#### Writing to a string - - # We need Psych::Nodes::Stream (not Psych::Nodes::Document) - stream = Psych.parse_stream("---\n - a\n - b") - - stream.to_yaml # => "---\n- a\n- b\n" - -#### Writing to a file - - # We need Psych::Nodes::Stream (not Psych::Nodes::Document) - stream = Psych.parse_stream(File.read('database.yml')) - - File.open('database.yml', 'w') do |file| - file.write(stream.to_yaml) - end - -## Low-level API - -### Parsing - -The lowest level parser should be used when the YAML input is already known, -and the developer does not want to pay the price of building an AST or -automatic detection and conversion to Ruby objects. See Psych::Parser for -more information on using the event based parser. - -#### Reading to Psych::Nodes::Stream structure - - parser = Psych::Parser.new(TreeBuilder.new) # => # - parser = Psych.parser # it's an alias for the above - - parser.parse("---\n - a\n - b") # => # - parser.handler # => # - parser.handler.root # => # - -#### Receiving an events stream - - recorder = Psych::Handlers::Recorder.new - parser = Psych::Parser.new(recorder) - - parser.parse("---\n - a\n - b") - recorder.events # => [list of [event, args] lists] - # event is one of: Psych::Handler::EVENTS - # args are the arguments passed to the event - -### Emitting - -The lowest level emitter is an event based system. Events are sent to a -Psych::Emitter object. That object knows how to convert the events to a YAML -document. This interface should be used when document format is known in -advance or speed is a concern. See Psych::Emitter for more information. - -#### Writing to a Ruby structure - - Psych.parser.parse("--- a") # => # - - parser.handler.first # => # - parser.handler.first.to_ruby # => ["a"] - - parser.handler.root.first # => # - parser.handler.root.first.to_ruby # => "a" - - # You can instantiate an Emitter manually - Psych::Visitors::ToRuby.new.accept(parser.handler.root.first) - # => "a" - - -# Class Methods -## add_builtin_type(type_tag , &block ) [](#method-c-add_builtin_type) -## add_domain_type(domain , type_tag , &block ) [](#method-c-add_domain_type) -:stopdoc: -## add_tag(tag , klass ) [](#method-c-add_tag) -## dump(o , io nil, options {}) [](#method-c-dump) -call-seq: - Psych.dump(o) -> string of yaml - Psych.dump(o, options) -> string of yaml - Psych.dump(o, io) -> io object passed in - Psych.dump(o, io, options) -> io object passed in - -Dump Ruby object `o` to a YAML string. Optional `options` may be passed in to -control the output format. If an IO object is passed in, the YAML will be -dumped to that IO object. - -Currently supported options are: - -`:indentation` -: Number of space characters used to indent. Acceptable value should be in - `0..9` range, otherwise option is ignored. - - Default: `2`. - -`:line_width` -: Max character to wrap line at. For unlimited line width use `-1`. - - Default: `0` (meaning "wrap at 81"). - -`:canonical` -: Write "canonical" YAML form (very verbose, yet strictly formal). - - Default: `false`. - -`:header` -: Write `%YAML [version]` at the beginning of document. - - Default: `false`. - - -`:stringify_names` -: Dump symbol keys in Hash objects as string. - - Default: `false`. - - -Example: - - # Dump an array, get back a YAML string - Psych.dump(['a', 'b']) # => "---\n- a\n- b\n" - - # Dump an array to an IO object - Psych.dump(['a', 'b'], StringIO.new) # => # - - # Dump an array with indentation set - Psych.dump(['a', ['b']], indentation: 3) # => "---\n- a\n- - b\n" - - # Dump an array to an IO with indentation set - Psych.dump(['a', ['b']], StringIO.new, indentation: 3) - - # Dump hash with symbol keys as string - Psych.dump({a: "b"}, stringify_names: true) # => "---\na: b\n" -## dump_stream(*objects ) [](#method-c-dump_stream) -Dump a list of objects as separate documents to a document stream. - -Example: - - Psych.dump_stream("foo\n ", {}) # => "--- ! \"foo\\n \"\n--- {}\n" -## libyaml_version() [](#method-c-libyaml_version) -Returns the version of libyaml being used -**@overload** [] - -## load(yaml , permitted_classes: [Symbol], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false) [](#method-c-load) -Load `yaml` in to a Ruby data structure. If multiple documents are provided, -the object contained in the first document will be returned. `filename` will -be used in the exception message if any exception is raised while parsing. If -`yaml` is empty, it returns the specified `fallback` return value, which -defaults to `nil`. - -Raises a Psych::SyntaxError when a YAML syntax error is detected. - -Example: - - Psych.load("--- a") # => 'a' - Psych.load("---\n - a\n - b") # => ['a', 'b'] - - begin - Psych.load("--- `", filename: "file.txt") - rescue Psych::SyntaxError => ex - ex.file # => 'file.txt' - ex.message # => "(file.txt): found character that cannot start any token" - end - -When the optional `symbolize_names` keyword argument is set to a true value, -returns symbols for keys in Hash objects (default: strings). - - Psych.load("---\n foo: bar") # => {"foo"=>"bar"} - Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"} - -Raises a TypeError when `yaml` parameter is NilClass. This method is similar -to `safe_load` except that `Symbol` objects are allowed by default. -## load_file(filename , **kwargs ) [](#method-c-load_file) -Loads the document contained in `filename`. Returns the yaml contained in -`filename` as a Ruby object, or if the file is empty, it returns the specified -`fallback` return value, which defaults to `nil`. See load for options. -## load_stream(yaml , filename: nil, fallback: [], **kwargs ) [](#method-c-load_stream) -Load multiple documents given in `yaml`. Returns the parsed documents as a -list. If a block is given, each document will be converted to Ruby and passed -to the block during parsing - -Example: - - Psych.load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar'] - - list = [] - Psych.load_stream("--- foo\n...\n--- bar\n...") do |ruby| - list << ruby - end - list # => ['foo', 'bar'] -## parse(yaml , filename: nil) [](#method-c-parse) -Parse a YAML string in `yaml`. Returns the Psych::Nodes::Document. `filename` -is used in the exception message if a Psych::SyntaxError is raised. - -Raises a Psych::SyntaxError when a YAML syntax error is detected. - -Example: - - Psych.parse("---\n - a\n - b") # => # - - begin - Psych.parse("--- `", filename: "file.txt") - rescue Psych::SyntaxError => ex - ex.file # => 'file.txt' - ex.message # => "(file.txt): found character that cannot start any token" - end - -See Psych::Nodes for more information about YAML AST. -## parse_file(filename , fallback: false) [](#method-c-parse_file) -Parse a file at `filename`. Returns the Psych::Nodes::Document. - -Raises a Psych::SyntaxError when a YAML syntax error is detected. -## parse_stream(yaml , filename: nil, &block ) [](#method-c-parse_stream) -Parse a YAML string in `yaml`. Returns the Psych::Nodes::Stream. This method -can handle multiple YAML documents contained in `yaml`. `filename` is used in -the exception message if a Psych::SyntaxError is raised. - -If a block is given, a Psych::Nodes::Document node will be yielded to the -block as it's being parsed. - -Raises a Psych::SyntaxError when a YAML syntax error is detected. - -Example: - - Psych.parse_stream("---\n - a\n - b") # => # - - Psych.parse_stream("--- a\n--- b") do |node| - node # => # - end - - begin - Psych.parse_stream("--- `", filename: "file.txt") - rescue Psych::SyntaxError => ex - ex.file # => 'file.txt' - ex.message # => "(file.txt): found character that cannot start any token" - end - -Raises a TypeError when NilClass is passed. - -See Psych::Nodes for more information about YAML AST. -## parser() [](#method-c-parser) -Returns a default parser -## remove_type(type_tag ) [](#method-c-remove_type) -## safe_dump(o , io nil, options {}) [](#method-c-safe_dump) -call-seq: - Psych.safe_dump(o) -> string of yaml - Psych.safe_dump(o, options) -> string of yaml - Psych.safe_dump(o, io) -> io object passed in - Psych.safe_dump(o, io, options) -> io object passed in - -Safely dump Ruby object `o` to a YAML string. Optional `options` may be passed -in to control the output format. If an IO object is passed in, the YAML will -be dumped to that IO object. By default, only the following classes are -allowed to be serialized: - -* TrueClass -* FalseClass -* NilClass -* Integer -* Float -* String -* Array -* Hash - -Arbitrary classes can be allowed by adding those classes to the -`permitted_classes` keyword argument. They are additive. For example, to -allow Date serialization: - - Psych.safe_dump(yaml, permitted_classes: [Date]) - -Now the Date class can be dumped in addition to the classes listed above. - -A Psych::DisallowedClass exception will be raised if the object contains a -class that isn't in the `permitted_classes` list. - -Currently supported options are: - -`:indentation` -: Number of space characters used to indent. Acceptable value should be in - `0..9` range, otherwise option is ignored. - - Default: `2`. - -`:line_width` -: Max character to wrap line at. For unlimited line width use `-1`. - - Default: `0` (meaning "wrap at 81"). - -`:canonical` -: Write "canonical" YAML form (very verbose, yet strictly formal). - - Default: `false`. - -`:header` -: Write `%YAML [version]` at the beginning of document. - - Default: `false`. - - -`:stringify_names` -: Dump symbol keys in Hash objects as string. - - Default: `false`. - - -Example: - - # Dump an array, get back a YAML string - Psych.safe_dump(['a', 'b']) # => "---\n- a\n- b\n" - - # Dump an array to an IO object - Psych.safe_dump(['a', 'b'], StringIO.new) # => # - - # Dump an array with indentation set - Psych.safe_dump(['a', ['b']], indentation: 3) # => "---\n- a\n- - b\n" - - # Dump an array to an IO with indentation set - Psych.safe_dump(['a', ['b']], StringIO.new, indentation: 3) - - # Dump hash with symbol keys as string - Psych.dump({a: "b"}, stringify_names: true) # => "---\na: b\n" -## safe_load(yaml , permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false) [](#method-c-safe_load) -Safely load the yaml string in `yaml`. By default, only the following classes -are allowed to be deserialized: - -* TrueClass -* FalseClass -* NilClass -* Integer -* Float -* String -* Array -* Hash - -Recursive data structures are not allowed by default. Arbitrary classes can -be allowed by adding those classes to the `permitted_classes` keyword -argument. They are additive. For example, to allow Date deserialization: - - Psych.safe_load(yaml, permitted_classes: [Date]) - -Now the Date class can be loaded in addition to the classes listed above. - -Aliases can be explicitly allowed by changing the `aliases` keyword argument. -For example: - - x = [] - x << x - yaml = Psych.dump x - Psych.safe_load yaml # => raises an exception - Psych.safe_load yaml, aliases: true # => loads the aliases - -A Psych::DisallowedClass exception will be raised if the yaml contains a class -that isn't in the `permitted_classes` list. - -A Psych::AliasesNotEnabled exception will be raised if the yaml contains -aliases but the `aliases` keyword argument is set to false. - -`filename` will be used in the exception message if any exception is raised -while parsing. - -When the optional `symbolize_names` keyword argument is set to a true value, -returns symbols for keys in Hash objects (default: strings). - - Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"} - Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"} -## safe_load_file(filename , **kwargs ) [](#method-c-safe_load_file) -Safely loads the document contained in `filename`. Returns the yaml contained -in `filename` as a Ruby object, or if the file is empty, it returns the -specified `fallback` return value, which defaults to `nil`. See safe_load for -options. -## to_json(object ) [](#method-c-to_json) -Dump Ruby `object` to a JSON string. -## unsafe_load(yaml , filename: nil, fallback: false, symbolize_names: false, freeze: false, strict_integer: false) [](#method-c-unsafe_load) -Load `yaml` in to a Ruby data structure. If multiple documents are provided, -the object contained in the first document will be returned. `filename` will -be used in the exception message if any exception is raised while parsing. If -`yaml` is empty, it returns the specified `fallback` return value, which -defaults to `false`. - -Raises a Psych::SyntaxError when a YAML syntax error is detected. - -Example: - - Psych.unsafe_load("--- a") # => 'a' - Psych.unsafe_load("---\n - a\n - b") # => ['a', 'b'] - - begin - Psych.unsafe_load("--- `", filename: "file.txt") - rescue Psych::SyntaxError => ex - ex.file # => 'file.txt' - ex.message # => "(file.txt): found character that cannot start any token" - end - -When the optional `symbolize_names` keyword argument is set to a true value, -returns symbols for keys in Hash objects (default: strings). - - Psych.unsafe_load("---\n foo: bar") # => {"foo"=>"bar"} - Psych.unsafe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"} - -Raises a TypeError when `yaml` parameter is NilClass - -NOTE: This method *should not* be used to parse untrusted documents, such as -YAML documents that are supplied via user input. Instead, please use the load -method or the safe_load method. -## unsafe_load_file(filename , **kwargs ) [](#method-c-unsafe_load_file) -Load the document contained in `filename`. Returns the yaml contained in -`filename` as a Ruby object, or if the file is empty, it returns the specified -`fallback` return value, which defaults to `false`. - -NOTE: This method *should not* be used to parse untrusted documents, such as -YAML documents that are supplied via user input. Instead, please use the -safe_load_file method. - -#Instance Methods -## config() [](#method-i-config) - -## domain_types() [](#method-i-domain_types) - -## domain_types=(value) [](#method-i-domain_types=) - -## dump_tags() [](#method-i-dump_tags) - -## dump_tags=(value) [](#method-i-dump_tags=) - -## load_tags() [](#method-i-load_tags) - -## load_tags=(value) [](#method-i-load_tags=) - diff --git a/example/ruby/Psych/AliasesNotEnabled.md b/example/ruby/Psych/AliasesNotEnabled.md deleted file mode 100644 index cd61d9b..0000000 --- a/example/ruby/Psych/AliasesNotEnabled.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Psych::AliasesNotEnabled -**Inherits:** Psych::BadAlias - - -Subclasses `BadAlias` for backwards compatibility - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [AliasesNotEnabled] a new instance of AliasesNotEnabled - diff --git a/example/ruby/Psych/AnchorNotDefined.md b/example/ruby/Psych/AnchorNotDefined.md deleted file mode 100644 index 5a8b6b3..0000000 --- a/example/ruby/Psych/AnchorNotDefined.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Psych::AnchorNotDefined -**Inherits:** Psych::BadAlias - - -Subclasses `BadAlias` for backwards compatibility - - - -#Instance Methods -## initialize(anchor_name) [](#method-i-initialize) - -**@return** [AnchorNotDefined] a new instance of AnchorNotDefined - diff --git a/example/ruby/Psych/BadAlias.md b/example/ruby/Psych/BadAlias.md deleted file mode 100644 index 6d98f9a..0000000 --- a/example/ruby/Psych/BadAlias.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Psych::BadAlias -**Inherits:** Psych::Exception - - - - - diff --git a/example/ruby/Psych/ClassLoader.md b/example/ruby/Psych/ClassLoader.md deleted file mode 100644 index 90ab0b9..0000000 --- a/example/ruby/Psych/ClassLoader.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Psych::ClassLoader -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ClassLoader] a new instance of ClassLoader - -## load(klassname) [](#method-i-load) - -## symbolize(sym) [](#method-i-symbolize) - diff --git a/example/ruby/Psych/ClassLoader/Restricted.md b/example/ruby/Psych/ClassLoader/Restricted.md deleted file mode 100644 index 380bd74..0000000 --- a/example/ruby/Psych/ClassLoader/Restricted.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Psych::ClassLoader::Restricted -**Inherits:** Psych::ClassLoader - - - - - -#Instance Methods -## initialize(classes, symbols) [](#method-i-initialize) - -**@return** [Restricted] a new instance of Restricted - -## symbolize(sym) [](#method-i-symbolize) - diff --git a/example/ruby/Psych/Coder.md b/example/ruby/Psych/Coder.md deleted file mode 100644 index 1f4182d..0000000 --- a/example/ruby/Psych/Coder.md +++ /dev/null @@ -1,67 +0,0 @@ -# Class: Psych::Coder -**Inherits:** Object - - -If an object defines `encode_with`, then an instance of Psych::Coder will be -passed to the method when the object is being serialized. The Coder -automatically assumes a Psych::Nodes::Mapping is being emitted. Other objects -like Sequence and Scalar may be emitted if `seq=` or `scalar=` are called, -respectively. - - -# Attributes -## implicit[RW] [](#attribute-i-implicit) -Returns the value of attribute implicit. - -## object[RW] [](#attribute-i-object) -Returns the value of attribute object. - -## seq[RW] [](#attribute-i-seq) -Returns the value of attribute seq. - -## style[RW] [](#attribute-i-style) -Returns the value of attribute style. - -## tag[RW] [](#attribute-i-tag) -Returns the value of attribute tag. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## [](k) [](#method-i-[]) - -## []=(k, v) [](#method-i-[]=) - -## initialize(tag) [](#method-i-initialize) - -**@return** [Coder] a new instance of Coder - -## map(tag@tag, style@style) [](#method-i-map) -Emit a map. The coder will be yielded to the block. - -**@yield** [_self] - -**@yieldparam** [Psych::Coder] the object that the method was called on - -## map=(map) [](#method-i-map=) -Emit a map with `value` - -## represent_map(tag, map) [](#method-i-represent_map) -Emit a sequence with `map` and `tag` - -## represent_object(tag, obj) [](#method-i-represent_object) -Emit an arbitrary object `obj` and `tag` - -## represent_scalar(tag, value) [](#method-i-represent_scalar) -Emit a scalar with `value` and `tag` - -## represent_seq(tag, list) [](#method-i-represent_seq) -Emit a sequence with `list` and `tag` - -## scalar(*args) [](#method-i-scalar) - -## scalar=(value) [](#method-i-scalar=) -Emit a scalar with `value` - diff --git a/example/ruby/Psych/Config.md b/example/ruby/Psych/Config.md deleted file mode 100644 index b6375da..0000000 --- a/example/ruby/Psych/Config.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Psych::Config -**Inherits:** Object - - - - -# Attributes -## domain_types[RW] [](#attribute-i-domain_types) -Returns the value of attribute domain_types. - -## dump_tags[RW] [](#attribute-i-dump_tags) -Returns the value of attribute dump_tags. - -## load_tags[RW] [](#attribute-i-load_tags) -Returns the value of attribute load_tags. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Config] a new instance of Config - diff --git a/example/ruby/Psych/DisallowedClass.md b/example/ruby/Psych/DisallowedClass.md deleted file mode 100644 index 7e3a18c..0000000 --- a/example/ruby/Psych/DisallowedClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Psych::DisallowedClass -**Inherits:** Psych::Exception - - - - - -#Instance Methods -## initialize(action, klass_name) [](#method-i-initialize) - -**@return** [DisallowedClass] a new instance of DisallowedClass - diff --git a/example/ruby/Psych/Emitter.md b/example/ruby/Psych/Emitter.md deleted file mode 100644 index ed0f7c5..0000000 --- a/example/ruby/Psych/Emitter.md +++ /dev/null @@ -1,118 +0,0 @@ -# Class: Psych::Emitter -**Inherits:** Psych::Handler - - - - - -#Instance Methods -## alias(anchor) [](#method-i-alias) -Emit an alias with `anchor`. - -See Psych::Handler#alias - -**@overload** [] - -## canonical() [](#method-i-canonical) -Get the output style, canonical or not. - -**@overload** [] - -## canonical=(style) [](#method-i-canonical=) -Set the output style to canonical, or not. - -**@overload** [] - -## end_document(imp) [](#method-i-end_document) -End a document emission with an `implicit` ending. - -See Psych::Handler#end_document - -**@overload** [] - -## end_mapping() [](#method-i-end_mapping) -Emit the end of a mapping. - -See Psych::Handler#end_mapping - -**@overload** [] - -## end_sequence() [](#method-i-end_sequence) -End sequence emission. - -See Psych::Handler#end_sequence - -**@overload** [] - -## end_stream() [](#method-i-end_stream) -End a stream emission - -See Psych::Handler#end_stream - -**@overload** [] - -## indentation() [](#method-i-indentation) -Get the indentation level. - -**@overload** [] - -## indentation=(level) [](#method-i-indentation=) -Set the indentation level to `level`. The level must be less than 10 and -greater than 1. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Create a new Psych::Emitter that writes to `io`. - -**@overload** [] - -## line_width() [](#method-i-line_width) -Get the preferred line width. - -**@overload** [] - -## line_width=(width) [](#method-i-line_width=) -Set the preferred line with to `width`. - -**@overload** [] - -## scalar(value, anchor, tag, plain, quoted, style) [](#method-i-scalar) -Emit a scalar with `value`, `anchor`, `tag`, and a `plain` or `quoted` string -type with `style`. - -See Psych::Handler#scalar - -**@overload** [] - -## start_document(version, tags, imp) [](#method-i-start_document) -Start a document emission with YAML `version`, `tags`, and an `implicit` -start. - -See Psych::Handler#start_document - -**@overload** [] - -## start_mapping(anchor, tag, implicit, style) [](#method-i-start_mapping) -Start emitting a YAML map with `anchor`, `tag`, an `implicit` start and end, -and `style`. - -See Psych::Handler#start_mapping - -**@overload** [] - -## start_sequence(anchor, tag, implicit, style) [](#method-i-start_sequence) -Start emitting a sequence with `anchor`, a `tag`, `implicit` sequence start -and end, along with `style`. - -See Psych::Handler#start_sequence - -**@overload** [] - -## start_stream(encoding) [](#method-i-start_stream) -Start a stream emission with `encoding` - -See Psych::Handler#start_stream - -**@overload** [] - diff --git a/example/ruby/Psych/Exception.md b/example/ruby/Psych/Exception.md deleted file mode 100644 index 5156adb..0000000 --- a/example/ruby/Psych/Exception.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Psych::Exception -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/Psych/Foo.md b/example/ruby/Psych/Foo.md deleted file mode 100644 index c9a564a..0000000 --- a/example/ruby/Psych/Foo.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::Foo -**Inherits:** Object - - - - -# Attributes -## parent[RW] [](#attribute-i-parent) -Returns the value of attribute parent. - - -#Instance Methods -## initialize(parent) [](#method-i-initialize) - -**@return** [Foo] a new instance of Foo - diff --git a/example/ruby/Psych/Handler.md b/example/ruby/Psych/Handler.md deleted file mode 100644 index bdbb41e..0000000 --- a/example/ruby/Psych/Handler.md +++ /dev/null @@ -1,194 +0,0 @@ -# Class: Psych::Handler -**Inherits:** Object - - -Psych::Handler is an abstract base class that defines the events used when -dealing with Psych::Parser. Clients who want to use Psych::Parser should -implement a class that inherits from Psych::Handler and define events that -they can handle. - -Psych::Handler defines all events that Psych::Parser can possibly send to -event handlers. - -See Psych::Parser for more details - - - -#Instance Methods -## alias(anchor) [](#method-i-alias) -Called when an alias is found to `anchor`. `anchor` will be the name of the -anchor found. - -### Example - -Here we have an example of an array that references itself in YAML: - - --- &ponies - - first element - - *ponies - -&ponies is the anchor, *ponies is the alias. In this case, alias is called -with "ponies". - -## empty() [](#method-i-empty) -Called when an empty event happens. (Which, as far as I can tell, is never). - -## end_document(implicit) [](#method-i-end_document) -Called with the document ends. `implicit` is a boolean value indicating -whether or not the document has an implicit ending. - -### Example - -Given the following YAML: - - --- - hello world - -`implicit` will be true. Given this YAML: - - --- - hello world - ... - -`implicit` will be false. - -## end_mapping() [](#method-i-end_mapping) -Called when a map ends - -## end_sequence() [](#method-i-end_sequence) -Called when a sequence ends. - -## end_stream() [](#method-i-end_stream) -Called when the YAML stream ends - -## event_location(start_line, start_column, end_line, end_column) [](#method-i-event_location) -Called before each event with line/column information. - -## scalar(value, anchor, tag, plain, quoted, style) [](#method-i-scalar) -Called when a scalar `value` is found. The scalar may have an `anchor`, a -`tag`, be implicitly `plain` or implicitly `quoted` - -`value` is the string value of the scalar `anchor` is an associated anchor or -nil `tag` is an associated tag or nil `plain` is a boolean value `quoted` is a -boolean value `style` is an integer indicating the string style - -See the constants in Psych::Nodes::Scalar for the possible values of `style` - -### Example - -Here is a YAML document that exercises most of the possible ways this method -can be called: - - --- - - !str "foo" - - &anchor fun - - many - lines - - | - many - newlines - -The above YAML document contains a list with four strings. Here are the -parameters sent to this method in the same order: - - # value anchor tag plain quoted style - ["foo", nil, "!str", false, false, 3 ] - ["fun", "anchor", nil, true, false, 1 ] - ["many lines", nil, nil, true, false, 1 ] - ["many\nnewlines\n", nil, nil, false, true, 4 ] - -## start_document(version, tag_directives, implicit) [](#method-i-start_document) -Called when the document starts with the declared `version`, `tag_directives`, -if the document is `implicit`. - -`version` will be an array of integers indicating the YAML version being dealt -with, `tag_directives` is a list of tuples indicating the prefix and suffix of -each tag, and `implicit` is a boolean indicating whether the document is -started implicitly. - -### Example - -Given the following YAML: - - %YAML 1.1 - %TAG ! tag:tenderlovemaking.com,2009: - --- !squee - -The parameters for start_document must be this: - - version # => [1, 1] - tag_directives # => [["!", "tag:tenderlovemaking.com,2009:"]] - implicit # => false - -## start_mapping(anchor, tag, implicit, style) [](#method-i-start_mapping) -Called when a map starts. - -`anchor` is the anchor associated with the map or `nil`. `tag` is the tag -associated with the map or `nil`. `implicit` is a boolean indicating whether -or not the map was implicitly started. `style` is an integer indicating the -mapping style. - -See the constants in Psych::Nodes::Mapping for the possible values of `style`. - -### Example - -Here is a YAML document that exercises most of the possible ways this method -can be called: - - --- - k: !!map { hello: world } - v: &pewpew - hello: world - -The above YAML document consists of three maps, an outer map that contains two -inner maps. Below is a matrix of the parameters sent in order to represent -these three maps: - - # anchor tag implicit style - [nil, nil, true, 1 ] - [nil, "tag:yaml.org,2002:map", false, 2 ] - ["pewpew", nil, true, 1 ] - -## start_sequence(anchor, tag, implicit, style) [](#method-i-start_sequence) -Called when a sequence is started. - -`anchor` is the anchor associated with the sequence or nil. `tag` is the tag -associated with the sequence or nil. `implicit` a boolean indicating whether -or not the sequence was implicitly started. `style` is an integer indicating -the list style. - -See the constants in Psych::Nodes::Sequence for the possible values of -`style`. - -### Example - -Here is a YAML document that exercises most of the possible ways this method -can be called: - - --- - - !!seq [ - a - ] - - &pewpew - - b - -The above YAML document consists of three lists, an outer list that contains -two inner lists. Here is a matrix of the parameters sent to represent these -lists: - - # anchor tag implicit style - [nil, nil, true, 1 ] - [nil, "tag:yaml.org,2002:seq", false, 2 ] - ["pewpew", nil, true, 1 ] - -## start_stream(encoding) [](#method-i-start_stream) -Called with `encoding` when the YAML stream starts. This method is called -once per stream. A stream may contain multiple documents. - -See the constants in Psych::Parser for the possible values of `encoding`. - -## streaming?() [](#method-i-streaming?) -Is this handler a streaming handler? - -**@return** [Boolean] - diff --git a/example/ruby/Psych/Handler/DumperOptions.md b/example/ruby/Psych/Handler/DumperOptions.md deleted file mode 100644 index 3f7b5cd..0000000 --- a/example/ruby/Psych/Handler/DumperOptions.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Psych::Handler::DumperOptions -**Inherits:** Object - - -Configuration options for dumping YAML. - - -# Attributes -## canonical[RW] [](#attribute-i-canonical) -Returns the value of attribute canonical. - -## indentation[RW] [](#attribute-i-indentation) -Returns the value of attribute indentation. - -## line_width[RW] [](#attribute-i-line_width) -Returns the value of attribute line_width. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [DumperOptions] a new instance of DumperOptions - diff --git a/example/ruby/Psych/Handlers.md b/example/ruby/Psych/Handlers.md deleted file mode 100644 index d107004..0000000 --- a/example/ruby/Psych/Handlers.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Psych::Handlers - - - - - diff --git a/example/ruby/Psych/Handlers/DocumentStream.md b/example/ruby/Psych/Handlers/DocumentStream.md deleted file mode 100644 index ccc6aa1..0000000 --- a/example/ruby/Psych/Handlers/DocumentStream.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Psych::Handlers::DocumentStream -**Inherits:** Psych::TreeBuilder - - -:nodoc: - - - -#Instance Methods -## end_document(implicit_end!streaming?) [](#method-i-end_document) - -## initialize(&block) [](#method-i-initialize) - -**@return** [DocumentStream] a new instance of DocumentStream - -## start_document(version, tag_directives, implicit) [](#method-i-start_document) - diff --git a/example/ruby/Psych/Handlers/Recorder.md b/example/ruby/Psych/Handlers/Recorder.md deleted file mode 100644 index 60fe411..0000000 --- a/example/ruby/Psych/Handlers/Recorder.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Psych::Handlers::Recorder -**Inherits:** Psych::Handler - - -This handler will capture an event and record the event. Recorder events are -available vial Psych::Handlers::Recorder#events. - -For example: - - recorder = Psych::Handlers::Recorder.new - parser = Psych::Parser.new recorder - parser.parse '--- foo' - - recorder.events # => [list of events] - - # Replay the events - - emitter = Psych::Emitter.new $stdout - recorder.events.each do |m, args| - emitter.send m, *args - end - - -# Attributes -## events[RW] [](#attribute-i-events) -Returns the value of attribute events. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Recorder] a new instance of Recorder - diff --git a/example/ruby/Psych/Handlers/TestRecorder.md b/example/ruby/Psych/Handlers/TestRecorder.md deleted file mode 100644 index fb93204..0000000 --- a/example/ruby/Psych/Handlers/TestRecorder.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Psych::Handlers::TestRecorder -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_replay() [](#method-i-test_replay) - diff --git a/example/ruby/Psych/JSON.md b/example/ruby/Psych/JSON.md deleted file mode 100644 index ea19dd7..0000000 --- a/example/ruby/Psych/JSON.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Psych::JSON - - - - - diff --git a/example/ruby/Psych/JSON/RubyEvents.md b/example/ruby/Psych/JSON/RubyEvents.md deleted file mode 100644 index 10ea23c..0000000 --- a/example/ruby/Psych/JSON/RubyEvents.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: Psych::JSON::RubyEvents - - -:nodoc: - - - -#Instance Methods -## visit_DateTime(o) [](#method-i-visit_DateTime) - -## visit_String(o) [](#method-i-visit_String) - -## visit_Time(o) [](#method-i-visit_Time) - diff --git a/example/ruby/Psych/JSON/Stream.md b/example/ruby/Psych/JSON/Stream.md deleted file mode 100644 index fc7ad81..0000000 --- a/example/ruby/Psych/JSON/Stream.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Psych::JSON::Stream -**Inherits:** Psych::Visitors::JSONTree - -**Extended by:** Psych::Streaming::ClassMethods - -**Includes:** Psych::JSON::RubyEvents, Psych::Streaming - - - - -# Class Methods -## new(io ) [](#method-c-new) -Create a new streaming emitter. Emitter will print to `io`. See -Psych::Stream for an example. - -#Instance Methods -## start(encodingNodes::Stream::UTF8) [](#method-i-start) -Start streaming using `encoding` - -## visit_DateTime(o) [](#method-i-visit_DateTime) - -## visit_String(o) [](#method-i-visit_String) - -## visit_Time(o) [](#method-i-visit_Time) - diff --git a/example/ruby/Psych/JSON/Stream/Emitter.md b/example/ruby/Psych/JSON/Stream/Emitter.md deleted file mode 100644 index 4048c20..0000000 --- a/example/ruby/Psych/JSON/Stream/Emitter.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Psych::JSON::Stream::Emitter -**Inherits:** Psych::Stream::Emitter - -**Includes:** Psych::JSON::YAMLEvents - - -:nodoc: - - - -#Instance Methods -## end_document(implicit_end!streaming?) [](#method-i-end_document) - -## scalar(value, anchor, tag, plain, quoted, style) [](#method-i-scalar) - -## start_document(version, tag_directives, implicit) [](#method-i-start_document) - -## start_mapping(anchor, tag, implicit, style) [](#method-i-start_mapping) - -## start_sequence(anchor, tag, implicit, style) [](#method-i-start_sequence) - diff --git a/example/ruby/Psych/JSON/TestStream.md b/example/ruby/Psych/JSON/TestStream.md deleted file mode 100644 index ae1d450..0000000 --- a/example/ruby/Psych/JSON/TestStream.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Psych::JSON::TestStream -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_datetime() [](#method-i-test_datetime) - -## test_explicit_documents() [](#method-i-test_explicit_documents) - -## test_float() [](#method-i-test_float) - -## test_hash() [](#method-i-test_hash) - -## test_int() [](#method-i-test_int) - -## test_json_dump_exclude_tag() [](#method-i-test_json_dump_exclude_tag) - -## test_json_list_dump_exclude_tag() [](#method-i-test_json_list_dump_exclude_tag) - -## test_list_to_json() [](#method-i-test_list_to_json) - -## test_null() [](#method-i-test_null) - -## test_string() [](#method-i-test_string) - -## test_symbol() [](#method-i-test_symbol) - -## test_time() [](#method-i-test_time) - diff --git a/example/ruby/Psych/JSON/TestStream/Bar.md b/example/ruby/Psych/JSON/TestStream/Bar.md deleted file mode 100644 index 3ac0d58..0000000 --- a/example/ruby/Psych/JSON/TestStream/Bar.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Psych::JSON::TestStream::Bar -**Inherits:** Object - - - - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - diff --git a/example/ruby/Psych/JSON/TestStream/Foo.md b/example/ruby/Psych/JSON/TestStream/Foo.md deleted file mode 100644 index 17efe57..0000000 --- a/example/ruby/Psych/JSON/TestStream/Foo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::JSON::TestStream::Foo -**Inherits:** Object - - - - - diff --git a/example/ruby/Psych/JSON/TreeBuilder.md b/example/ruby/Psych/JSON/TreeBuilder.md deleted file mode 100644 index ae328da..0000000 --- a/example/ruby/Psych/JSON/TreeBuilder.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Psych::JSON::TreeBuilder -**Inherits:** Psych::TreeBuilder - -**Includes:** Psych::JSON::YAMLEvents - - -Psych::JSON::TreeBuilder is an event based AST builder. Events are sent to an -instance of Psych::JSON::TreeBuilder and a JSON AST is constructed. - - - -#Instance Methods -## end_document(implicit_end!streaming?) [](#method-i-end_document) - -## scalar(value, anchor, tag, plain, quoted, style) [](#method-i-scalar) - -## start_document(version, tag_directives, implicit) [](#method-i-start_document) - -## start_mapping(anchor, tag, implicit, style) [](#method-i-start_mapping) - -## start_sequence(anchor, tag, implicit, style) [](#method-i-start_sequence) - diff --git a/example/ruby/Psych/JSON/YAMLEvents.md b/example/ruby/Psych/JSON/YAMLEvents.md deleted file mode 100644 index 287ef03..0000000 --- a/example/ruby/Psych/JSON/YAMLEvents.md +++ /dev/null @@ -1,18 +0,0 @@ -# Module: Psych::JSON::YAMLEvents - - -:nodoc: - - - -#Instance Methods -## end_document(implicit_end!streaming?) [](#method-i-end_document) - -## scalar(value, anchor, tag, plain, quoted, style) [](#method-i-scalar) - -## start_document(version, tag_directives, implicit) [](#method-i-start_document) - -## start_mapping(anchor, tag, implicit, style) [](#method-i-start_mapping) - -## start_sequence(anchor, tag, implicit, style) [](#method-i-start_sequence) - diff --git a/example/ruby/Psych/Nodes.md b/example/ruby/Psych/Nodes.md deleted file mode 100644 index 90da652..0000000 --- a/example/ruby/Psych/Nodes.md +++ /dev/null @@ -1,67 +0,0 @@ -# Module: Psych::Nodes - - -# Overview - -When using Psych.load to deserialize a YAML document, the document is -translated to an intermediary AST. That intermediary AST is then translated -in to a Ruby object graph. - -In the opposite direction, when using Psych.dump, the Ruby object graph is -translated to an intermediary AST which is then converted to a YAML document. - -Psych::Nodes contains all of the classes that make up the nodes of a YAML AST. - You can manually build an AST and use one of the visitors (see -Psych::Visitors) to convert that AST to either a YAML document or to a Ruby -object graph. - -Here is an example of building an AST that represents a list with one scalar: - - # Create our nodes - stream = Psych::Nodes::Stream.new - doc = Psych::Nodes::Document.new - seq = Psych::Nodes::Sequence.new - scalar = Psych::Nodes::Scalar.new('foo') - - # Build up our tree - stream.children << doc - doc.children << seq - seq.children << scalar - -The stream is the root of the tree. We can then convert the tree to YAML: - - stream.to_yaml => "---\n- foo\n" - -Or convert it to Ruby: - - stream.to_ruby => [["foo"]] - -## YAML AST Requirements - -A valid YAML AST **must** have one Psych::Nodes::Stream at the root. A -Psych::Nodes::Stream node must have 1 or more Psych::Nodes::Document nodes as -children. - -Psych::Nodes::Document nodes must have one and **only** one child. That child -may be one of: - -* Psych::Nodes::Sequence -* Psych::Nodes::Mapping -* Psych::Nodes::Scalar - -Psych::Nodes::Sequence and Psych::Nodes::Mapping nodes may have many children, -but Psych::Nodes::Mapping nodes should have an even number of children. - -All of these are valid children for Psych::Nodes::Sequence and -Psych::Nodes::Mapping nodes: - -* Psych::Nodes::Sequence -* Psych::Nodes::Mapping -* Psych::Nodes::Scalar -* Psych::Nodes::Alias - -Psych::Nodes::Scalar and Psych::Nodes::Alias are both terminal nodes and -should not have any children. - - - diff --git a/example/ruby/Psych/Nodes/Alias.md b/example/ruby/Psych/Nodes/Alias.md deleted file mode 100644 index 693d49d..0000000 --- a/example/ruby/Psych/Nodes/Alias.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Psych::Nodes::Alias -**Inherits:** Psych::Nodes::Node - - -This class represents a [YAML Alias](http://yaml.org/spec/1.1/#alias). It -points to an `anchor`. - -A Psych::Nodes::Alias is a terminal node and may have no children. - - -# Attributes -## anchor[RW] [](#attribute-i-anchor) -The anchor this alias links to - - -#Instance Methods -## alias?() [](#method-i-alias?) - -**@return** [Boolean] - -## initialize(anchor) [](#method-i-initialize) -Create a new Alias that points to an `anchor` - -**@return** [Alias] a new instance of Alias - diff --git a/example/ruby/Psych/Nodes/Document.md b/example/ruby/Psych/Nodes/Document.md deleted file mode 100644 index 0fbd863..0000000 --- a/example/ruby/Psych/Nodes/Document.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: Psych::Nodes::Document -**Inherits:** Psych::Nodes::Node - - -This represents a YAML Document. This node must be a child of -Psych::Nodes::Stream. A Psych::Nodes::Document must have one child, and that -child may be one of the following: - -* Psych::Nodes::Sequence -* Psych::Nodes::Mapping -* Psych::Nodes::Scalar - - -# Attributes -## implicit[RW] [](#attribute-i-implicit) -Was this document implicitly created? - -## implicit_end[RW] [](#attribute-i-implicit_end) -Is the end of the document implicit? - -## tag_directives[RW] [](#attribute-i-tag_directives) -A list of tag directives for this document - -## version[RW] [](#attribute-i-version) -The version of the YAML document - - -#Instance Methods -## document?() [](#method-i-document?) - -**@return** [Boolean] - -## initialize(version[], tag_directives[], implicitfalse) [](#method-i-initialize) -Create a new Psych::Nodes::Document object. - -`version` is a list indicating the YAML version. `tags_directives` is a list -of tag directive declarations `implicit` is a flag indicating whether the -document will be implicitly started. - -## Example: -This creates a YAML document object that represents a YAML 1.1 document with -one tag directive, and has an implicit start: - - Psych::Nodes::Document.new( - [1,1], - [["!", "tag:tenderlovemaking.com,2009:"]], - true - ) - -## See Also -See also Psych::Handler#start_document - -**@return** [Document] a new instance of Document - -## root() [](#method-i-root) -Returns the root node. A Document may only have one root node: -http://yaml.org/spec/1.1/#id898031 - diff --git a/example/ruby/Psych/Nodes/Mapping.md b/example/ruby/Psych/Nodes/Mapping.md deleted file mode 100644 index 0e99ea2..0000000 --- a/example/ruby/Psych/Nodes/Mapping.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Psych::Nodes::Mapping -**Inherits:** Psych::Nodes::Node - - -This class represents a [YAML Mapping](http://yaml.org/spec/1.1/#mapping). - -A Psych::Nodes::Mapping node may have 0 or more children, but must have an -even number of children. Here are the valid children a Psych::Nodes::Mapping -node may have: - -* Psych::Nodes::Sequence -* Psych::Nodes::Mapping -* Psych::Nodes::Scalar -* Psych::Nodes::Alias - - -# Attributes -## anchor[RW] [](#attribute-i-anchor) -The optional anchor for this mapping - -## implicit[RW] [](#attribute-i-implicit) -Is this an implicit mapping? - -## style[RW] [](#attribute-i-style) -The style of this mapping - -## tag[RW] [](#attribute-i-tag) -The optional tag for this mapping - - -#Instance Methods -## initialize(anchornil, tagnil, implicittrue, styleBLOCK) [](#method-i-initialize) -Create a new Psych::Nodes::Mapping object. - -`anchor` is the anchor associated with the map or `nil`. `tag` is the tag -associated with the map or `nil`. `implicit` is a boolean indicating whether -or not the map was implicitly started. `style` is an integer indicating the -mapping style. - -## See Also -See also Psych::Handler#start_mapping - -**@return** [Mapping] a new instance of Mapping - -## mapping?() [](#method-i-mapping?) - -**@return** [Boolean] - diff --git a/example/ruby/Psych/Nodes/Node.md b/example/ruby/Psych/Nodes/Node.md deleted file mode 100644 index c76e8a2..0000000 --- a/example/ruby/Psych/Nodes/Node.md +++ /dev/null @@ -1,2131 +0,0 @@ -# Class: Psych::Nodes::Node -**Inherits:** Object - -**Includes:** Enumerable - - -The base class for any Node in a YAML parse tree. This class should never be -instantiated. - - -# Attributes -## children[RW] [](#attribute-i-children) -The children of this node - -## end_column[RW] [](#attribute-i-end_column) -The column number where this node ends - -## end_line[RW] [](#attribute-i-end_line) -The line number where this node ends - -## start_column[RW] [](#attribute-i-start_column) -The column number where this node start - -## start_line[RW] [](#attribute-i-start_line) -The line number where this node start - -## tag[RW] [](#attribute-i-tag) -An associated tag - - -#Instance Methods -## alias?() [](#method-i-alias?) - -**@return** [Boolean] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## document?() [](#method-i-document?) - -**@return** [Boolean] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) -Iterate over each node in the tree. Yields each node to `block` depth first. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) -Create a new Psych::Nodes::Node - -**@return** [Node] a new instance of Node - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## mapping?() [](#method-i-mapping?) - -**@return** [Boolean] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## scalar?() [](#method-i-scalar?) - -**@return** [Boolean] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## sequence?() [](#method-i-sequence?) - -**@return** [Boolean] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## stream?() [](#method-i-stream?) - -**@return** [Boolean] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_ruby(symbolize_names:false, freeze:false, strict_integer:false) [](#method-i-to_ruby) -Convert this node to Ruby. - -See also Psych::Visitors::ToRuby - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## yaml(ionil, options{}) [](#method-i-yaml) -Convert this node to YAML. - -See also Psych::Visitors::Emitter - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Psych/Nodes/Scalar.md b/example/ruby/Psych/Nodes/Scalar.md deleted file mode 100644 index 7ac47c0..0000000 --- a/example/ruby/Psych/Nodes/Scalar.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Psych::Nodes::Scalar -**Inherits:** Psych::Nodes::Node - - -This class represents a [YAML Scalar](http://yaml.org/spec/1.1/#id858081). - -This node type is a terminal node and should not have any children. - - -# Attributes -## anchor[RW] [](#attribute-i-anchor) -The anchor value (if there is one) - -## plain[RW] [](#attribute-i-plain) -Is this a plain scalar? - -## quoted[RW] [](#attribute-i-quoted) -Is this scalar quoted? - -## style[RW] [](#attribute-i-style) -The style of this scalar - -## tag[RW] [](#attribute-i-tag) -The tag value (if there is one) - -## value[RW] [](#attribute-i-value) -The scalar value - - -#Instance Methods -## initialize(value, anchornil, tagnil, plaintrue, quotedfalse, styleANY) [](#method-i-initialize) -Create a new Psych::Nodes::Scalar object. - -`value` is the string value of the scalar `anchor` is an associated anchor or -nil `tag` is an associated tag or nil `plain` is a boolean value `quoted` is a -boolean value `style` is an integer indicating the string style - -## See Also - -See also Psych::Handler#scalar - -**@return** [Scalar] a new instance of Scalar - -## scalar?() [](#method-i-scalar?) - -**@return** [Boolean] - diff --git a/example/ruby/Psych/Nodes/Sequence.md b/example/ruby/Psych/Nodes/Sequence.md deleted file mode 100644 index 720ea68..0000000 --- a/example/ruby/Psych/Nodes/Sequence.md +++ /dev/null @@ -1,72 +0,0 @@ -# Class: Psych::Nodes::Sequence -**Inherits:** Psych::Nodes::Node - - -This class represents a [YAML -sequence](http://yaml.org/spec/1.1/#sequence/syntax). - -A YAML sequence is basically a list, and looks like this: - - %YAML 1.1 - --- - - I am - - a Sequence - -A YAML sequence may have an anchor like this: - - %YAML 1.1 - --- - &A [ - "This sequence", - "has an anchor" - ] - -A YAML sequence may also have a tag like this: - - %YAML 1.1 - --- - !!seq [ - "This sequence", - "has a tag" - ] - -This class represents a sequence in a YAML document. A Psych::Nodes::Sequence -node may have 0 or more children. Valid children for this node are: - -* Psych::Nodes::Sequence -* Psych::Nodes::Mapping -* Psych::Nodes::Scalar -* Psych::Nodes::Alias - - -# Attributes -## anchor[RW] [](#attribute-i-anchor) -The anchor for this sequence (if any) - -## implicit[RW] [](#attribute-i-implicit) -Is this sequence started implicitly? - -## style[RW] [](#attribute-i-style) -The sequence style used - -## tag[RW] [](#attribute-i-tag) -The tag name for this sequence (if any) - - -#Instance Methods -## initialize(anchornil, tagnil, implicittrue, styleBLOCK) [](#method-i-initialize) -Create a new object representing a YAML sequence. - -`anchor` is the anchor associated with the sequence or nil. `tag` is the tag -associated with the sequence or nil. `implicit` a boolean indicating whether -or not the sequence was implicitly started. `style` is an integer indicating -the list style. - -See Psych::Handler#start_sequence - -**@return** [Sequence] a new instance of Sequence - -## sequence?() [](#method-i-sequence?) - -**@return** [Boolean] - diff --git a/example/ruby/Psych/Nodes/Stream.md b/example/ruby/Psych/Nodes/Stream.md deleted file mode 100644 index b84ee63..0000000 --- a/example/ruby/Psych/Nodes/Stream.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Psych::Nodes::Stream -**Inherits:** Psych::Nodes::Node - - -Represents a YAML stream. This is the root node for any YAML parse tree. -This node must have one or more child nodes. The only valid child node for a -Psych::Nodes::Stream node is Psych::Nodes::Document. - - -# Attributes -## encoding[RW] [](#attribute-i-encoding) -The encoding used for this stream - - -#Instance Methods -## initialize(encodingUTF8) [](#method-i-initialize) -Create a new Psych::Nodes::Stream node with an `encoding` that defaults to -Psych::Nodes::Stream::UTF8. - -See also Psych::Handler#start_stream - -**@return** [Stream] a new instance of Stream - -## stream?() [](#method-i-stream?) - -**@return** [Boolean] - diff --git a/example/ruby/Psych/Nodes/TestEnumerable.md b/example/ruby/Psych/Nodes/TestEnumerable.md deleted file mode 100644 index 8b2bb4d..0000000 --- a/example/ruby/Psych/Nodes/TestEnumerable.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Psych::Nodes::TestEnumerable -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_alias() [](#method-i-test_alias) - -## test_includes_enumerable() [](#method-i-test_includes_enumerable) - -## test_mapping() [](#method-i-test_mapping) - -## test_returns_enumerator() [](#method-i-test_returns_enumerator) - -## test_scalar() [](#method-i-test_scalar) - -## test_sequence() [](#method-i-test_sequence) - diff --git a/example/ruby/Psych/Omap.md b/example/ruby/Psych/Omap.md deleted file mode 100644 index 55a7dd8..0000000 --- a/example/ruby/Psych/Omap.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::Omap -**Inherits:** Hash - - - - - diff --git a/example/ruby/Psych/Parser.md b/example/ruby/Psych/Parser.md deleted file mode 100644 index cdceede..0000000 --- a/example/ruby/Psych/Parser.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: Psych::Parser -**Inherits:** Object - - -YAML event parser class. This class parses a YAML document and calls events -on the handler that is passed to the constructor. The events can be used for -things such as constructing a YAML AST or deserializing YAML documents. It -can even be fed back to Psych::Emitter to emit the same document that was -parsed. - -See Psych::Handler for documentation on the events that Psych::Parser emits. - -Here is an example that prints out ever scalar found in a YAML document: - - # Handler for detecting scalar values - class ScalarHandler < Psych::Handler - def scalar value, anchor, tag, plain, quoted, style - puts value - end - end - - parser = Psych::Parser.new(ScalarHandler.new) - parser.parse(yaml_document) - -Here is an example that feeds the parser back in to Psych::Emitter. The YAML -document is read from STDIN and written back out to STDERR: - - parser = Psych::Parser.new(Psych::Emitter.new($stderr)) - parser.parse($stdin) - -Psych uses Psych::Parser in combination with Psych::TreeBuilder to construct -an AST of the parsed YAML document. - - -# Attributes -## external_encoding=[R] [](#attribute-i-external_encoding=) -Set the encoding for this parser to `encoding` - -## handler[RW] [](#attribute-i-handler) -The handler on which events will be called - - -#Instance Methods -## initialize(handlerHandler.new) [](#method-i-initialize) -Creates a new Psych::Parser instance with `handler`. YAML events will be -called on `handler`. See Psych::Parser for more details. - -**@return** [Parser] a new instance of Parser - -## mark() [](#method-i-mark) -Returns a Psych::Parser::Mark object that contains line, column, and index -information. - -## parse(yaml, pathyaml.respond_to?(:path) ? yaml.path : "") [](#method-i-parse) -call-seq: - parser.parse(yaml) - -Parse the YAML document contained in `yaml`. Events will be called on the -handler set on the parser instance. - -See Psych::Parser and Psych::Parser#handler - diff --git a/example/ruby/Psych/Parser/Mark.md b/example/ruby/Psych/Parser/Mark.md deleted file mode 100644 index 67a2647..0000000 --- a/example/ruby/Psych/Parser/Mark.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Psych::Parser::Mark -**Inherits:** Struct - - - - -# Attributes -## column[RW] [](#attribute-i-column) -Returns the value of attribute column - -**@return** [Object] the current value of column - -## index[RW] [](#attribute-i-index) -Returns the value of attribute index - -**@return** [Object] the current value of index - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line - -**@return** [Object] the current value of line - - diff --git a/example/ruby/Psych/ScalarScanner.md b/example/ruby/Psych/ScalarScanner.md deleted file mode 100644 index 4b2f086..0000000 --- a/example/ruby/Psych/ScalarScanner.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Psych::ScalarScanner -**Inherits:** Object - - -Scan scalars for built in types - - -# Attributes -## class_loader[RW] [](#attribute-i-class_loader) -Returns the value of attribute class_loader. - - -#Instance Methods -## initialize(class_loader, strict_integer:false) [](#method-i-initialize) -Create a new scanner - -**@return** [ScalarScanner] a new instance of ScalarScanner - -## parse_int(string) [](#method-i-parse_int) -Parse and return an int from `string` - -## parse_time(string) [](#method-i-parse_time) -Parse and return a Time from `string` - -## tokenize(string) [](#method-i-tokenize) -Tokenize `string` returning the Ruby object - diff --git a/example/ruby/Psych/Set.md b/example/ruby/Psych/Set.md deleted file mode 100644 index e93747a..0000000 --- a/example/ruby/Psych/Set.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::Set -**Inherits:** Hash - - - - - diff --git a/example/ruby/Psych/Stream.md b/example/ruby/Psych/Stream.md deleted file mode 100644 index e157589..0000000 --- a/example/ruby/Psych/Stream.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Psych::Stream -**Inherits:** Psych::Visitors::YAMLTree - -**Extended by:** Psych::Streaming::ClassMethods - -**Includes:** Psych::Streaming - - -Psych::Stream is a streaming YAML emitter. It will not buffer your YAML, but -send it straight to an IO. - -Here is an example use: - - stream = Psych::Stream.new($stdout) - stream.start - stream.push({:foo => 'bar'}) - stream.finish - -YAML will be immediately emitted to $stdout with no buffering. - -Psych::Stream#start will take a block and ensure that Psych::Stream#finish is -called, so you can do this form: - - stream = Psych::Stream.new($stdout) - stream.start do |em| - em.push(:foo => 'bar') - end - - -# Class Methods -## new(io ) [](#method-c-new) -Create a new streaming emitter. Emitter will print to `io`. See -Psych::Stream for an example. - -#Instance Methods -## start(encodingNodes::Stream::UTF8) [](#method-i-start) -Start streaming using `encoding` - diff --git a/example/ruby/Psych/Stream/Emitter.md b/example/ruby/Psych/Stream/Emitter.md deleted file mode 100644 index 37ba656..0000000 --- a/example/ruby/Psych/Stream/Emitter.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Psych::Stream::Emitter -**Inherits:** Psych::Emitter - - -:nodoc: - - - -#Instance Methods -## end_document(implicit_end!streaming?) [](#method-i-end_document) - -## streaming?() [](#method-i-streaming?) - -**@return** [Boolean] - diff --git a/example/ruby/Psych/Streaming.md b/example/ruby/Psych/Streaming.md deleted file mode 100644 index ffb7d74..0000000 --- a/example/ruby/Psych/Streaming.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Psych::Streaming - - - - - -#Instance Methods -## start(encodingNodes::Stream::UTF8) [](#method-i-start) -Start streaming using `encoding` - diff --git a/example/ruby/Psych/Streaming/ClassMethods.md b/example/ruby/Psych/Streaming/ClassMethods.md deleted file mode 100644 index 798c636..0000000 --- a/example/ruby/Psych/Streaming/ClassMethods.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Psych::Streaming::ClassMethods - - - - - -#Instance Methods -## new(io) [](#method-i-new) -Create a new streaming emitter. Emitter will print to `io`. See -Psych::Stream for an example. - diff --git a/example/ruby/Psych/SyntaxError.md b/example/ruby/Psych/SyntaxError.md deleted file mode 100644 index c3c8135..0000000 --- a/example/ruby/Psych/SyntaxError.md +++ /dev/null @@ -1,31 +0,0 @@ -# Exception: Psych::SyntaxError -**Inherits:** Psych::Exception - - - - -# Attributes -## column[RW] [](#attribute-i-column) -Returns the value of attribute column. - -## context[RW] [](#attribute-i-context) -Returns the value of attribute context. - -## file[RW] [](#attribute-i-file) -Returns the value of attribute file. - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line. - -## offset[RW] [](#attribute-i-offset) -Returns the value of attribute offset. - -## problem[RW] [](#attribute-i-problem) -Returns the value of attribute problem. - - -#Instance Methods -## initialize(file, line, col, offset, problem, context) [](#method-i-initialize) - -**@return** [SyntaxError] a new instance of SyntaxError - diff --git a/example/ruby/Psych/Tagged.md b/example/ruby/Psych/Tagged.md deleted file mode 100644 index b8e1a07..0000000 --- a/example/ruby/Psych/Tagged.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::Tagged -**Inherits:** Object - - - - -# Attributes -## baz[RW] [](#attribute-i-baz) -Returns the value of attribute baz. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Tagged] a new instance of Tagged - diff --git a/example/ruby/Psych/TestAliasAndAnchor.md b/example/ruby/Psych/TestAliasAndAnchor.md deleted file mode 100644 index 728e7f2..0000000 --- a/example/ruby/Psych/TestAliasAndAnchor.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Psych::TestAliasAndAnchor -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_anchor_alias_round_trip() [](#method-i-test_anchor_alias_round_trip) - -## test_anchor_alias_round_trip_object_with_ivars() [](#method-i-test_anchor_alias_round_trip_object_with_ivars) - -## test_anchor_alias_round_trip_substring_with_ivars() [](#method-i-test_anchor_alias_round_trip_substring_with_ivars) - -## test_mri_compatibility() [](#method-i-test_mri_compatibility) - -## test_mri_compatibility_object_with_ivars() [](#method-i-test_mri_compatibility_object_with_ivars) - -## test_mri_compatibility_substring_with_ivars() [](#method-i-test_mri_compatibility_substring_with_ivars) - diff --git a/example/ruby/Psych/TestArray.md b/example/ruby/Psych/TestArray.md deleted file mode 100644 index dde47d4..0000000 --- a/example/ruby/Psych/TestArray.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Psych::TestArray -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_another_subclass_with_attributes() [](#method-i-test_another_subclass_with_attributes) - -## test_backwards_with_syck() [](#method-i-test_backwards_with_syck) - -## test_cycle() [](#method-i-test_cycle) - -## test_enumerator() [](#method-i-test_enumerator) - -## test_recursive_array() [](#method-i-test_recursive_array) - -## test_recursive_array_uses_alias() [](#method-i-test_recursive_array_uses_alias) - -## test_self_referential() [](#method-i-test_self_referential) - -## test_subclass() [](#method-i-test_subclass) - -## test_subclass_with_attributes() [](#method-i-test_subclass_with_attributes) - diff --git a/example/ruby/Psych/TestArray/X.md b/example/ruby/Psych/TestArray/X.md deleted file mode 100644 index e660322..0000000 --- a/example/ruby/Psych/TestArray/X.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::TestArray::X -**Inherits:** Array - - - - - diff --git a/example/ruby/Psych/TestArray/Y.md b/example/ruby/Psych/TestArray/Y.md deleted file mode 100644 index 17bbb2f..0000000 --- a/example/ruby/Psych/TestArray/Y.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Psych::TestArray::Y -**Inherits:** Array - - - - -# Attributes -## val[RW] [](#attribute-i-val) -Returns the value of attribute val. - - diff --git a/example/ruby/Psych/TestBoolean.md b/example/ruby/Psych/TestBoolean.md deleted file mode 100644 index 3c2eff0..0000000 --- a/example/ruby/Psych/TestBoolean.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Psych::TestBoolean -**Inherits:** Psych::TestCase - - -Test booleans from YAML spec: http://yaml.org/type/bool.html - - - -#Instance Methods -## test_n() [](#method-i-test_n) -YAML spec says "n" and "N" may be used as false, but Syck treats them as -literal strings - -## test_y() [](#method-i-test_y) -YAML spec says "y" and "Y" may be used as true, but Syck treats them as -literal strings - diff --git a/example/ruby/Psych/TestCase.md b/example/ruby/Psych/TestCase.md deleted file mode 100644 index 8c1c6ad..0000000 --- a/example/ruby/Psych/TestCase.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Psych::TestCase -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## suppress_warning() [](#method-c-suppress_warning) - -#Instance Methods -## assert_cycle(obj) [](#method-i-assert_cycle) - -## assert_parse_only(obj, yaml) [](#method-i-assert_parse_only) -Test parser only - -## assert_to_yaml(obj, yaml, loader:load) [](#method-i-assert_to_yaml) -Convert between Psych and the object to verify correct parsing and emitting - -## mktime(year, mon, day, hour, min, sec, usec, zone"Z") [](#method-i-mktime) -Make a time with the time zone - -## with_default_external(enc) [](#method-i-with_default_external) - -## with_default_internal(enc) [](#method-i-with_default_internal) - diff --git a/example/ruby/Psych/TestClass.md b/example/ruby/Psych/TestClass.md deleted file mode 100644 index ce8f3bf..0000000 --- a/example/ruby/Psych/TestClass.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Psych::TestClass -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_cycle() [](#method-i-test_cycle) - -## test_cycle_anonymous_class() [](#method-i-test_cycle_anonymous_class) - -## test_cycle_anonymous_module() [](#method-i-test_cycle_anonymous_module) - -## test_cycle_module() [](#method-i-test_cycle_module) - -## test_dump() [](#method-i-test_dump) - -## test_dump_module() [](#method-i-test_dump_module) - diff --git a/example/ruby/Psych/TestClass/Foo.md b/example/ruby/Psych/TestClass/Foo.md deleted file mode 100644 index 158d111..0000000 --- a/example/ruby/Psych/TestClass/Foo.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Psych::TestClass::Foo - - - - - diff --git a/example/ruby/Psych/TestCoder.md b/example/ruby/Psych/TestCoder.md deleted file mode 100644 index 4eb51cf..0000000 --- a/example/ruby/Psych/TestCoder.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: Psych::TestCoder -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_coder_style_map_any() [](#method-i-test_coder_style_map_any) - -## test_coder_style_map_block() [](#method-i-test_coder_style_map_block) - -## test_coder_style_map_default() [](#method-i-test_coder_style_map_default) - -## test_coder_style_map_flow() [](#method-i-test_coder_style_map_flow) - -## test_coder_style_scalar_any() [](#method-i-test_coder_style_scalar_any) - -## test_coder_style_scalar_default() [](#method-i-test_coder_style_scalar_default) - -## test_coder_style_scalar_double_quoted() [](#method-i-test_coder_style_scalar_double_quoted) - -## test_coder_style_scalar_folded() [](#method-i-test_coder_style_scalar_folded) - -## test_coder_style_scalar_literal() [](#method-i-test_coder_style_scalar_literal) - -## test_coder_style_scalar_plain() [](#method-i-test_coder_style_scalar_plain) - -## test_coder_style_scalar_single_quoted() [](#method-i-test_coder_style_scalar_single_quoted) - -## test_coder_style_seq_any() [](#method-i-test_coder_style_seq_any) - -## test_coder_style_seq_block() [](#method-i-test_coder_style_seq_block) - -## test_coder_style_seq_default() [](#method-i-test_coder_style_seq_default) - -## test_coder_style_seq_flow() [](#method-i-test_coder_style_seq_flow) - -## test_dump_encode_with() [](#method-i-test_dump_encode_with) - -## test_dump_init_with() [](#method-i-test_dump_init_with) - -## test_dump_with_tag() [](#method-i-test_dump_with_tag) - -## test_json_dump_exclude_tag() [](#method-i-test_json_dump_exclude_tag) - -## test_load_dumped_tagging() [](#method-i-test_load_dumped_tagging) - -## test_map_takes_block() [](#method-i-test_map_takes_block) - -## test_map_with_tag() [](#method-i-test_map_with_tag) - -## test_map_with_tag_and_style() [](#method-i-test_map_with_tag_and_style) - -## test_represent!() [](#method-i-test_represent!) - -## test_represent_map() [](#method-i-test_represent_map) - -## test_represent_sequence() [](#method-i-test_represent_sequence) - -## test_represent_with_init() [](#method-i-test_represent_with_init) - -## test_represent_with_object() [](#method-i-test_represent_with_object) - -## test_scalar_coder() [](#method-i-test_scalar_coder) - -## test_self_referential() [](#method-i-test_self_referential) - diff --git a/example/ruby/Psych/TestCoder/CustomEncode.md b/example/ruby/Psych/TestCoder/CustomEncode.md deleted file mode 100644 index 7ffb1ee..0000000 --- a/example/ruby/Psych/TestCoder/CustomEncode.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Psych::TestCoder::CustomEncode -**Inherits:** Object - - - - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - -## initialize(**opts) [](#method-i-initialize) - -**@return** [CustomEncode] a new instance of CustomEncode - diff --git a/example/ruby/Psych/TestCoder/InitApi.md b/example/ruby/Psych/TestCoder/InitApi.md deleted file mode 100644 index 4699e49..0000000 --- a/example/ruby/Psych/TestCoder/InitApi.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Psych::TestCoder::InitApi -**Inherits:** Object - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a. - -## b[RW] [](#attribute-i-b) -Returns the value of attribute b. - -## c[RW] [](#attribute-i-c) -Returns the value of attribute c. - -## implicit[RW] [](#attribute-i-implicit) -Returns the value of attribute implicit. - -## style[RW] [](#attribute-i-style) -Returns the value of attribute style. - -## tag[RW] [](#attribute-i-tag) -Returns the value of attribute tag. - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - -## init_with(coder) [](#method-i-init_with) - -## initialize() [](#method-i-initialize) - -**@return** [InitApi] a new instance of InitApi - diff --git a/example/ruby/Psych/TestCoder/Referential.md b/example/ruby/Psych/TestCoder/Referential.md deleted file mode 100644 index fe2ae2c..0000000 --- a/example/ruby/Psych/TestCoder/Referential.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Psych::TestCoder::Referential -**Inherits:** Object - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a. - - -#Instance Methods -## encode_with(c) [](#method-i-encode_with) - -## init_with(c) [](#method-i-init_with) - -## initialize() [](#method-i-initialize) - -**@return** [Referential] a new instance of Referential - diff --git a/example/ruby/Psych/TestCoder/Represent.md b/example/ruby/Psych/TestCoder/Represent.md deleted file mode 100644 index e717a19..0000000 --- a/example/ruby/Psych/TestCoder/Represent.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Psych::TestCoder::Represent -**Inherits:** Object - - - - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - diff --git a/example/ruby/Psych/TestCoder/RepresentWithInit.md b/example/ruby/Psych/TestCoder/RepresentWithInit.md deleted file mode 100644 index c165bb4..0000000 --- a/example/ruby/Psych/TestCoder/RepresentWithInit.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::TestCoder::RepresentWithInit -**Inherits:** Object - - - - -# Attributes -## str[RW] [](#attribute-i-str) -Returns the value of attribute str. - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - -## init_with(coder) [](#method-i-init_with) - diff --git a/example/ruby/Psych/TestCoder/RepresentWithMap.md b/example/ruby/Psych/TestCoder/RepresentWithMap.md deleted file mode 100644 index e0cce13..0000000 --- a/example/ruby/Psych/TestCoder/RepresentWithMap.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::TestCoder::RepresentWithMap -**Inherits:** Object - - - - -# Attributes -## map[RW] [](#attribute-i-map) -Returns the value of attribute map. - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - -## init_with(coder) [](#method-i-init_with) - diff --git a/example/ruby/Psych/TestCoder/RepresentWithObject.md b/example/ruby/Psych/TestCoder/RepresentWithObject.md deleted file mode 100644 index 0b99ec1..0000000 --- a/example/ruby/Psych/TestCoder/RepresentWithObject.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Psych::TestCoder::RepresentWithObject -**Inherits:** Object - - - - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - diff --git a/example/ruby/Psych/TestCoder/RepresentWithSeq.md b/example/ruby/Psych/TestCoder/RepresentWithSeq.md deleted file mode 100644 index 4eb3baa..0000000 --- a/example/ruby/Psych/TestCoder/RepresentWithSeq.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::TestCoder::RepresentWithSeq -**Inherits:** Object - - - - -# Attributes -## seq[RW] [](#attribute-i-seq) -Returns the value of attribute seq. - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - -## init_with(coder) [](#method-i-init_with) - diff --git a/example/ruby/Psych/TestCoder/ScalarCoder.md b/example/ruby/Psych/TestCoder/ScalarCoder.md deleted file mode 100644 index c80b211..0000000 --- a/example/ruby/Psych/TestCoder/ScalarCoder.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Psych::TestCoder::ScalarCoder -**Inherits:** Object - - - - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - diff --git a/example/ruby/Psych/TestCoder/TaggingCoder.md b/example/ruby/Psych/TestCoder/TaggingCoder.md deleted file mode 100644 index 1b1d8a0..0000000 --- a/example/ruby/Psych/TestCoder/TaggingCoder.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Psych::TestCoder::TaggingCoder -**Inherits:** Psych::TestCoder::InitApi - - - - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - diff --git a/example/ruby/Psych/TestDateTime.md b/example/ruby/Psych/TestDateTime.md deleted file mode 100644 index 633a95e..0000000 --- a/example/ruby/Psych/TestDateTime.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Psych::TestDateTime -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_alias_with_time() [](#method-i-test_alias_with_time) - -## test_datetime_non_utc() [](#method-i-test_datetime_non_utc) - -## test_datetime_timezone_offset() [](#method-i-test_datetime_timezone_offset) - -## test_invalid_date() [](#method-i-test_invalid_date) - -## test_julian_date() [](#method-i-test_julian_date) - -## test_julian_datetime() [](#method-i-test_julian_datetime) - -## test_negative_year() [](#method-i-test_negative_year) - -## test_new_datetime() [](#method-i-test_new_datetime) - -## test_non_utc() [](#method-i-test_non_utc) - -## test_proleptic_gregorian_date() [](#method-i-test_proleptic_gregorian_date) - -## test_proleptic_gregorian_datetime() [](#method-i-test_proleptic_gregorian_datetime) - -## test_round_trip() [](#method-i-test_round_trip) - -## test_string_tag() [](#method-i-test_string_tag) - -## test_timezone_offset() [](#method-i-test_timezone_offset) - -## test_usec() [](#method-i-test_usec) - diff --git a/example/ruby/Psych/TestDeprecated.md b/example/ruby/Psych/TestDeprecated.md deleted file mode 100644 index 6143931..0000000 --- a/example/ruby/Psych/TestDeprecated.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Psych::TestDeprecated -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_coder_scalar() [](#method-i-test_coder_scalar) - -## test_recursive_quick_emit_encode_with() [](#method-i-test_recursive_quick_emit_encode_with) -An object that defines both to_yaml and encode_with should only call -encode_with. - -## test_yaml_initialize_and_init_with() [](#method-i-test_yaml_initialize_and_init_with) -An object that implements both yaml_initialize and init_with should not -receive the yaml_initialize call. - diff --git a/example/ruby/Psych/TestDeprecated/QuickEmitter.md b/example/ruby/Psych/TestDeprecated/QuickEmitter.md deleted file mode 100644 index 6b6921d..0000000 --- a/example/ruby/Psych/TestDeprecated/QuickEmitter.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::TestDeprecated::QuickEmitter -**Inherits:** Object - - - - - diff --git a/example/ruby/Psych/TestDeprecated/QuickEmitterEncodeWith.md b/example/ruby/Psych/TestDeprecated/QuickEmitterEncodeWith.md deleted file mode 100644 index 41ccaa6..0000000 --- a/example/ruby/Psych/TestDeprecated/QuickEmitterEncodeWith.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Psych::TestDeprecated::QuickEmitterEncodeWith -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - -## initialize() [](#method-i-initialize) - -**@return** [QuickEmitterEncodeWith] a new instance of QuickEmitterEncodeWith - -## to_yaml(opts{}) [](#method-i-to_yaml) - diff --git a/example/ruby/Psych/TestDeprecated/YamlInitAndInitWith.md b/example/ruby/Psych/TestDeprecated/YamlInitAndInitWith.md deleted file mode 100644 index dcd41eb..0000000 --- a/example/ruby/Psych/TestDeprecated/YamlInitAndInitWith.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Psych::TestDeprecated::YamlInitAndInitWith -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## init_with(coder) [](#method-i-init_with) - -## initialize() [](#method-i-initialize) - -**@return** [YamlInitAndInitWith] a new instance of YamlInitAndInitWith - -## yaml_initialize(tag, vals) [](#method-i-yaml_initialize) - diff --git a/example/ruby/Psych/TestDocument.md b/example/ruby/Psych/TestDocument.md deleted file mode 100644 index da39284..0000000 --- a/example/ruby/Psych/TestDocument.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Psych::TestDocument -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_emit_bad_tag() [](#method-i-test_emit_bad_tag) - -## test_emit_multitag() [](#method-i-test_emit_multitag) - -## test_emit_tag() [](#method-i-test_emit_tag) - -## test_emit_version() [](#method-i-test_emit_version) - -## test_parse_tag() [](#method-i-test_parse_tag) - -## test_parse_version() [](#method-i-test_parse_version) - diff --git a/example/ruby/Psych/TestEmitter.md b/example/ruby/Psych/TestEmitter.md deleted file mode 100644 index dde824b..0000000 --- a/example/ruby/Psych/TestEmitter.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Psych::TestEmitter -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_emit_utf_8() [](#method-i-test_emit_utf_8) - -## test_indentation_set() [](#method-i-test_indentation_set) - -## test_line_width() [](#method-i-test_line_width) - -## test_resizing_tags() [](#method-i-test_resizing_tags) - -## test_scalar_arg_error() [](#method-i-test_scalar_arg_error) - -## test_set_canonical() [](#method-i-test_set_canonical) - -## test_start_doc_arg_error() [](#method-i-test_start_doc_arg_error) - -## test_start_sequence_arg_error() [](#method-i-test_start_sequence_arg_error) - -## test_start_stream_arg_error() [](#method-i-test_start_stream_arg_error) - diff --git a/example/ruby/Psych/TestEncoding.md b/example/ruby/Psych/TestEncoding.md deleted file mode 100644 index ff1d4cd..0000000 --- a/example/ruby/Psych/TestEncoding.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: Psych::TestEncoding -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_alias() [](#method-i-test_alias) - -## test_default_internal() [](#method-i-test_default_internal) - -## test_doc_tag() [](#method-i-test_doc_tag) - -## test_doc_tag_encoding() [](#method-i-test_doc_tag_encoding) - -## test_dump_load_encoding_object() [](#method-i-test_dump_load_encoding_object) - -## test_dump_non_ascii_string_to_file() [](#method-i-test_dump_non_ascii_string_to_file) - -## test_emit_alias() [](#method-i-test_emit_alias) - -## test_emitter_encoding() [](#method-i-test_emitter_encoding) - -## test_io_shiftjis() [](#method-i-test_io_shiftjis) - -## test_io_utf16be() [](#method-i-test_io_utf16be) - -## test_io_utf16le() [](#method-i-test_io_utf16le) - -## test_io_utf8() [](#method-i-test_io_utf8) - -## test_io_utf8_read_as_binary() [](#method-i-test_io_utf8_read_as_binary) - -## test_list_anchor() [](#method-i-test_list_anchor) - -## test_map_anchor() [](#method-i-test_map_anchor) - -## test_map_tag() [](#method-i-test_map_tag) - -## test_scalar() [](#method-i-test_scalar) - -## test_start_mapping() [](#method-i-test_start_mapping) - -## test_start_sequence() [](#method-i-test_start_sequence) - -## test_to_yaml_is_valid() [](#method-i-test_to_yaml_is_valid) - -## test_transcode_shiftjis() [](#method-i-test_transcode_shiftjis) - -## test_transcode_utf16be() [](#method-i-test_transcode_utf16be) - -## test_transcode_utf16le() [](#method-i-test_transcode_utf16le) - diff --git a/example/ruby/Psych/TestEncoding/EncodingCatcher.md b/example/ruby/Psych/TestEncoding/EncodingCatcher.md deleted file mode 100644 index a7ae988..0000000 --- a/example/ruby/Psych/TestEncoding/EncodingCatcher.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::TestEncoding::EncodingCatcher -**Inherits:** Psych::Handler - - - - -# Attributes -## strings[RW] [](#attribute-i-strings) -Returns the value of attribute strings. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [EncodingCatcher] a new instance of EncodingCatcher - diff --git a/example/ruby/Psych/TestException.md b/example/ruby/Psych/TestException.md deleted file mode 100644 index 2af3ed3..0000000 --- a/example/ruby/Psych/TestException.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Psych::TestException -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## make_ex(msg'oh no!') [](#method-i-make_ex) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_attributes() [](#method-i-test_attributes) - -## test_backtrace() [](#method-i-test_backtrace) - -## test_convert() [](#method-i-test_convert) - -## test_load_file_exception() [](#method-i-test_load_file_exception) - -## test_load_stream_takes_file() [](#method-i-test_load_stream_takes_file) - -## test_load_takes_file() [](#method-i-test_load_takes_file) - -## test_naming_exception() [](#method-i-test_naming_exception) - -## test_parse_file_exception() [](#method-i-test_parse_file_exception) - -## test_psych_parse_stream_takes_file() [](#method-i-test_psych_parse_stream_takes_file) - -## test_psych_parse_takes_file() [](#method-i-test_psych_parse_takes_file) - -## test_psych_syntax_error() [](#method-i-test_psych_syntax_error) - -## test_safe_load_file_exception() [](#method-i-test_safe_load_file_exception) - diff --git a/example/ruby/Psych/TestException/Wups.md b/example/ruby/Psych/TestException/Wups.md deleted file mode 100644 index bfa1502..0000000 --- a/example/ruby/Psych/TestException/Wups.md +++ /dev/null @@ -1,19 +0,0 @@ -# Exception: Psych::TestException::Wups -**Inherits:** Psych::Exception - - - - -# Attributes -## bar[RW] [](#attribute-i-bar) -Returns the value of attribute bar. - -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [Wups] a new instance of Wups - diff --git a/example/ruby/Psych/TestHash.md b/example/ruby/Psych/TestHash.md deleted file mode 100644 index 69cc5ca..0000000 --- a/example/ruby/Psych/TestHash.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Psych::TestHash -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_anchor_reuse() [](#method-i-test_anchor_reuse) - -## test_custom_initialize_no_ivar() [](#method-i-test_custom_initialize_no_ivar) - -## test_custom_initialized() [](#method-i-test_custom_initialized) - -## test_cycles() [](#method-i-test_cycles) - -## test_empty_subclass() [](#method-i-test_empty_subclass) - -## test_hash_subclass_with_ivars() [](#method-i-test_hash_subclass_with_ivars) - -## test_hash_with_ivar() [](#method-i-test_hash_with_ivar) - -## test_key_deduplication() [](#method-i-test_key_deduplication) - -## test_load_with_class_syck_compatibility() [](#method-i-test_load_with_class_syck_compatibility) - -## test_map() [](#method-i-test_map) - -## test_raises_if_anchor_not_defined() [](#method-i-test_raises_if_anchor_not_defined) - -## test_recursive_hash() [](#method-i-test_recursive_hash) - -## test_recursive_hash_uses_alias() [](#method-i-test_recursive_hash_uses_alias) - -## test_ref_append() [](#method-i-test_ref_append) - -## test_referenced_hash_with_ivar() [](#method-i-test_referenced_hash_with_ivar) - -## test_self_referential() [](#method-i-test_self_referential) - diff --git a/example/ruby/Psych/TestHash/HashWithCustomInit.md b/example/ruby/Psych/TestHash/HashWithCustomInit.md deleted file mode 100644 index d4c385c..0000000 --- a/example/ruby/Psych/TestHash/HashWithCustomInit.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::TestHash::HashWithCustomInit -**Inherits:** Hash - - - - -# Attributes -## obj[RW] [](#attribute-i-obj) -Returns the value of attribute obj. - - -#Instance Methods -## initialize(obj) [](#method-i-initialize) - -**@return** [HashWithCustomInit] a new instance of HashWithCustomInit - diff --git a/example/ruby/Psych/TestHash/HashWithCustomInitNoIvar.md b/example/ruby/Psych/TestHash/HashWithCustomInitNoIvar.md deleted file mode 100644 index 91ea295..0000000 --- a/example/ruby/Psych/TestHash/HashWithCustomInitNoIvar.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Psych::TestHash::HashWithCustomInitNoIvar -**Inherits:** Hash - - - - - -#Instance Methods -## initialize(obj) [](#method-i-initialize) - -**@return** [HashWithCustomInitNoIvar] a new instance of HashWithCustomInitNoIvar - diff --git a/example/ruby/Psych/TestHash/HashWithIvar.md b/example/ruby/Psych/TestHash/HashWithIvar.md deleted file mode 100644 index c5a1b51..0000000 --- a/example/ruby/Psych/TestHash/HashWithIvar.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Psych::TestHash::HashWithIvar -**Inherits:** Hash - - - - - -#Instance Methods -## []=(k, v) [](#method-i-[]=) - -## initialize() [](#method-i-initialize) - -**@return** [HashWithIvar] a new instance of HashWithIvar - diff --git a/example/ruby/Psych/TestHash/X.md b/example/ruby/Psych/TestHash/X.md deleted file mode 100644 index 8752064..0000000 --- a/example/ruby/Psych/TestHash/X.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::TestHash::X -**Inherits:** Hash - - - - - diff --git a/example/ruby/Psych/TestJSONTree.md b/example/ruby/Psych/TestJSONTree.md deleted file mode 100644 index 49ebaca..0000000 --- a/example/ruby/Psych/TestJSONTree.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Psych::TestJSONTree -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_datetime() [](#method-i-test_datetime) - -## test_float() [](#method-i-test_float) - -## test_hash() [](#method-i-test_hash) - -## test_int() [](#method-i-test_int) - -## test_json_list_dump_exclude_tag() [](#method-i-test_json_list_dump_exclude_tag) - -## test_list_to_json() [](#method-i-test_list_to_json) - -## test_nil() [](#method-i-test_nil) - -## test_string() [](#method-i-test_string) - -## test_symbol() [](#method-i-test_symbol) - -## test_time() [](#method-i-test_time) - diff --git a/example/ruby/Psych/TestJSONTree/Bar.md b/example/ruby/Psych/TestJSONTree/Bar.md deleted file mode 100644 index 8679b25..0000000 --- a/example/ruby/Psych/TestJSONTree/Bar.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Psych::TestJSONTree::Bar -**Inherits:** Object - - - - - -#Instance Methods -## encode_with(coder) [](#method-i-encode_with) - diff --git a/example/ruby/Psych/TestMarshalable.md b/example/ruby/Psych/TestMarshalable.md deleted file mode 100644 index 2ed7b28..0000000 --- a/example/ruby/Psych/TestMarshalable.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Psych::TestMarshalable -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_init_symbolize_names() [](#method-i-test_init_symbolize_names) - -## test_init_with_takes_priority_over_marshal_methods() [](#method-i-test_init_with_takes_priority_over_marshal_methods) - -## test_objects_defining_marshal_dump_and_marshal_load_can_be_dumped() [](#method-i-test_objects_defining_marshal_dump_and_marshal_load_can_be_dumped) - diff --git a/example/ruby/Psych/TestMarshalable/PsychCustomMarshalable.md b/example/ruby/Psych/TestMarshalable/PsychCustomMarshalable.md deleted file mode 100644 index 1c85fcd..0000000 --- a/example/ruby/Psych/TestMarshalable/PsychCustomMarshalable.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Psych::TestMarshalable::PsychCustomMarshalable -**Inherits:** BasicObject - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - -#Instance Methods -## class() [](#method-i-class) - -## encode_with(coder) [](#method-i-encode_with) - -## init_with(coder) [](#method-i-init_with) - -## initialize(foo) [](#method-i-initialize) - -**@return** [PsychCustomMarshalable] a new instance of PsychCustomMarshalable - -## marshal_dump() [](#method-i-marshal_dump) - -## mashal_load(data) [](#method-i-mashal_load) - -## respond_to?(method) [](#method-i-respond_to?) - -**@return** [Boolean] - diff --git a/example/ruby/Psych/TestMergeKeys.md b/example/ruby/Psych/TestMergeKeys.md deleted file mode 100644 index d2194d7..0000000 --- a/example/ruby/Psych/TestMergeKeys.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Psych::TestMergeKeys -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_bad_seq_merge() [](#method-i-test_bad_seq_merge) - -## test_explicit_string() [](#method-i-test_explicit_string) - -## test_merge_array() [](#method-i-test_merge_array) - -## test_merge_is_not_partial() [](#method-i-test_merge_is_not_partial) - -## test_merge_key() [](#method-i-test_merge_key) -ruby-core:34679 -: - -## test_merge_key_with_bare_hash() [](#method-i-test_merge_key_with_bare_hash) - -## test_merge_key_with_bare_hash_symbolized_names() [](#method-i-test_merge_key_with_bare_hash_symbolized_names) - -## test_merge_nil() [](#method-i-test_merge_nil) - -## test_merge_seq_nil() [](#method-i-test_merge_seq_nil) - -## test_mergekey_with_object() [](#method-i-test_mergekey_with_object) - -## test_missing_merge_key() [](#method-i-test_missing_merge_key) - -## test_multiple_maps() [](#method-i-test_multiple_maps) - -## test_override() [](#method-i-test_override) - -## test_roundtrip_with_chevron_key() [](#method-i-test_roundtrip_with_chevron_key) - diff --git a/example/ruby/Psych/TestMergeKeys/Product.md b/example/ruby/Psych/TestMergeKeys/Product.md deleted file mode 100644 index 8d658c1..0000000 --- a/example/ruby/Psych/TestMergeKeys/Product.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Psych::TestMergeKeys::Product -**Inherits:** Object - - - - -# Attributes -## bar[RW] [](#attribute-i-bar) -Returns the value of attribute bar. - - diff --git a/example/ruby/Psych/TestNil.md b/example/ruby/Psych/TestNil.md deleted file mode 100644 index 14f8ee3..0000000 --- a/example/ruby/Psych/TestNil.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Psych::TestNil -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_array_nil() [](#method-i-test_array_nil) - -## test_nil() [](#method-i-test_nil) - diff --git a/example/ruby/Psych/TestNull.md b/example/ruby/Psych/TestNull.md deleted file mode 100644 index 141e578..0000000 --- a/example/ruby/Psych/TestNull.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Psych::TestNull -**Inherits:** Psych::TestCase - - -Test null from YAML spec: http://yaml.org/type/null.html - - - -#Instance Methods -## test_null_list() [](#method-i-test_null_list) - diff --git a/example/ruby/Psych/TestNumeric.md b/example/ruby/Psych/TestNumeric.md deleted file mode 100644 index 50cbf9c..0000000 --- a/example/ruby/Psych/TestNumeric.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: Psych::TestNumeric -**Inherits:** Psych::TestCase - - -Test numerics from YAML spec: http://yaml.org/type/float.html -http://yaml.org/type/int.html - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_big_decimal_round_trip() [](#method-i-test_big_decimal_round_trip) - -## test_big_decimal_tag() [](#method-i-test_big_decimal_tag) - -## test_does_not_attempt_numeric() [](#method-i-test_does_not_attempt_numeric) - -## test_load_float_with_dot() [](#method-i-test_load_float_with_dot) - -## test_non_float_with_0() [](#method-i-test_non_float_with_0) - -## test_string_with_commas() [](#method-i-test_string_with_commas) -This behavior is not to YML spec, but is kept for backwards compatibility - -## test_string_with_commas_with_strict_integer() [](#method-i-test_string_with_commas_with_strict_integer) - diff --git a/example/ruby/Psych/TestObject.md b/example/ruby/Psych/TestObject.md deleted file mode 100644 index 2956d35..0000000 --- a/example/ruby/Psych/TestObject.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::TestObject -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_cyclic_reference_uses_alias() [](#method-i-test_cyclic_reference_uses_alias) - -## test_cyclic_references() [](#method-i-test_cyclic_references) - -## test_dump_with_tag() [](#method-i-test_dump_with_tag) - -## test_tag_round_trip() [](#method-i-test_tag_round_trip) - diff --git a/example/ruby/Psych/TestObjectReferences.md b/example/ruby/Psych/TestObjectReferences.md deleted file mode 100644 index c64a3f2..0000000 --- a/example/ruby/Psych/TestObjectReferences.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Psych::TestObjectReferences -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## assert_reference_trip(obj) [](#method-i-assert_reference_trip) - -## test_binary_references() [](#method-i-test_binary_references) - -## test_class_has_references() [](#method-i-test_class_has_references) - -## test_complex_has_references() [](#method-i-test_complex_has_references) - -## test_datetime_has_references() [](#method-i-test_datetime_has_references) - -## test_float_references() [](#method-i-test_float_references) - -## test_module_has_references() [](#method-i-test_module_has_references) - -## test_range_has_references() [](#method-i-test_range_has_references) - -## test_rational_has_references() [](#method-i-test_rational_has_references) - -## test_regexp_references() [](#method-i-test_regexp_references) - -## test_struct_has_references() [](#method-i-test_struct_has_references) - diff --git a/example/ruby/Psych/TestOmap.md b/example/ruby/Psych/TestOmap.md deleted file mode 100644 index c70cdce..0000000 --- a/example/ruby/Psych/TestOmap.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Psych::TestOmap -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_dump() [](#method-i-test_dump) - -## test_keys() [](#method-i-test_keys) - -## test_load() [](#method-i-test_load) - -## test_load_shorthand() [](#method-i-test_load_shorthand) -NOTE: This test will not work with Syck - -## test_order() [](#method-i-test_order) - -## test_parse_as_map() [](#method-i-test_parse_as_map) - -## test_round_trip() [](#method-i-test_round_trip) - -## test_self_referential() [](#method-i-test_self_referential) - -## test_square() [](#method-i-test_square) - diff --git a/example/ruby/Psych/TestParser.md b/example/ruby/Psych/TestParser.md deleted file mode 100644 index a7d0e7e..0000000 --- a/example/ruby/Psych/TestParser.md +++ /dev/null @@ -1,90 +0,0 @@ -# Class: Psych::TestParser -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## assert_called(call, withnil, parser@parser) [](#method-i-assert_called) - -## setup() [](#method-i-setup) - -## test_alias() [](#method-i-test_alias) - -## test_ast_roundtrip() [](#method-i-test_ast_roundtrip) - -## test_bogus_io() [](#method-i-test_bogus_io) - -## test_bom() [](#method-i-test_bom) - -## test_code_point_limit() [](#method-i-test_code_point_limit) - -## test_column_numbers() [](#method-i-test_column_numbers) - -## test_end_document_explicit() [](#method-i-test_end_document_explicit) - -## test_end_document_implicit() [](#method-i-test_end_document_implicit) - -## test_end_stream() [](#method-i-test_end_stream) - -## test_event_location() [](#method-i-test_event_location) - -## test_exception_memory_leak() [](#method-i-test_exception_memory_leak) - -## test_external_encoding() [](#method-i-test_external_encoding) - -## test_filename() [](#method-i-test_filename) - -## test_index_numbers() [](#method-i-test_index_numbers) - -## test_line_numbers() [](#method-i-test_line_numbers) - -## test_literal_scalar() [](#method-i-test_literal_scalar) - -## test_mapping_anchor() [](#method-i-test_mapping_anchor) - -## test_mapping_block() [](#method-i-test_mapping_block) - -## test_mapping_end() [](#method-i-test_mapping_end) - -## test_mapping_start() [](#method-i-test_mapping_start) - -## test_mapping_tag() [](#method-i-test_mapping_tag) - -## test_multiparse() [](#method-i-test_multiparse) - -## test_parse_io() [](#method-i-test_parse_io) - -## test_scalar() [](#method-i-test_scalar) - -## test_scalar_plain_implicit() [](#method-i-test_scalar_plain_implicit) - -## test_scalar_with_anchor() [](#method-i-test_scalar_with_anchor) - -## test_scalar_with_tag() [](#method-i-test_scalar_with_tag) - -## test_sequence_end() [](#method-i-test_sequence_end) - -## test_sequence_start_anchor() [](#method-i-test_sequence_start_anchor) - -## test_sequence_start_block() [](#method-i-test_sequence_start_block) - -## test_sequence_start_flow() [](#method-i-test_sequence_start_flow) - -## test_sequence_start_tag() [](#method-i-test_sequence_start_tag) - -## test_start_document_tag() [](#method-i-test_start_document_tag) - -## test_start_document_version() [](#method-i-test_start_document_version) - -## test_start_stream() [](#method-i-test_start_stream) - -## test_syntax_error() [](#method-i-test_syntax_error) - -## test_syntax_error_has_path_for_io() [](#method-i-test_syntax_error_has_path_for_io) - -## test_syntax_error_has_path_for_string() [](#method-i-test_syntax_error_has_path_for_string) - -## test_syntax_error_twice() [](#method-i-test_syntax_error_twice) - diff --git a/example/ruby/Psych/TestParser/EventCatcher.md b/example/ruby/Psych/TestParser/EventCatcher.md deleted file mode 100644 index b7b38e4..0000000 --- a/example/ruby/Psych/TestParser/EventCatcher.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Psych::TestParser::EventCatcher -**Inherits:** Psych::Handler - - - - -# Attributes -## calls[RW] [](#attribute-i-calls) -Returns the value of attribute calls. - -## marks[RW] [](#attribute-i-marks) -Returns the value of attribute marks. - -## parser[RW] [](#attribute-i-parser) -Returns the value of attribute parser. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [EventCatcher] a new instance of EventCatcher - diff --git a/example/ruby/Psych/TestSafeLoad.md b/example/ruby/Psych/TestSafeLoad.md deleted file mode 100644 index 2c4e676..0000000 --- a/example/ruby/Psych/TestSafeLoad.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Psych::TestSafeLoad -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_aliases_are_parsed_when_alias_parsing_is_enabled() [](#method-i-test_aliases_are_parsed_when_alias_parsing_is_enabled) - -## test_anon_struct() [](#method-i-test_anon_struct) - -## test_foo() [](#method-i-test_foo) - -## test_permitted_symbol() [](#method-i-test_permitted_symbol) - -## test_raises_when_alias_found_if_alias_parsing_not_enabled() [](#method-i-test_raises_when_alias_found_if_alias_parsing_not_enabled) - -## test_safe_load() [](#method-i-test_safe_load) - -## test_safe_load_default_fallback() [](#method-i-test_safe_load_default_fallback) - -## test_safe_load_raises_on_bad_input() [](#method-i-test_safe_load_raises_on_bad_input) - -## test_struct_depends_on_sym() [](#method-i-test_struct_depends_on_sym) - -## test_symbol() [](#method-i-test_symbol) - diff --git a/example/ruby/Psych/TestSafeLoad/Foo.md b/example/ruby/Psych/TestSafeLoad/Foo.md deleted file mode 100644 index 00fc8d7..0000000 --- a/example/ruby/Psych/TestSafeLoad/Foo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::TestSafeLoad::Foo -**Inherits:** Object - - - - - diff --git a/example/ruby/Psych/TestSafeLoad/X.md b/example/ruby/Psych/TestSafeLoad/X.md deleted file mode 100644 index 9503b8f..0000000 --- a/example/ruby/Psych/TestSafeLoad/X.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Psych::TestSafeLoad::X -**Inherits:** Struct - - - - -# Attributes -## x[RW] [](#attribute-i-x) -Returns the value of attribute x - -**@return** [Object] the current value of x - - diff --git a/example/ruby/Psych/TestScalar.md b/example/ruby/Psych/TestScalar.md deleted file mode 100644 index cc05454..0000000 --- a/example/ruby/Psych/TestScalar.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Psych::TestScalar -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_some_bytes() [](#method-i-test_some_bytes) -Ticket #278 - -## test_utf_8() [](#method-i-test_utf_8) - diff --git a/example/ruby/Psych/TestScalarScanner.md b/example/ruby/Psych/TestScalarScanner.md deleted file mode 100644 index f699048..0000000 --- a/example/ruby/Psych/TestScalarScanner.md +++ /dev/null @@ -1,72 +0,0 @@ -# Class: Psych::TestScalarScanner -**Inherits:** Psych::TestCase - - - - -# Attributes -## ss[RW] [](#attribute-i-ss) -Returns the value of attribute ss. - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_scan_ascii_matches_quickly() [](#method-i-test_scan_ascii_matches_quickly) - -## test_scan_bad_dates() [](#method-i-test_scan_bad_dates) - -## test_scan_bad_edge_date() [](#method-i-test_scan_bad_edge_date) - -## test_scan_bad_time() [](#method-i-test_scan_bad_time) - -## test_scan_date() [](#method-i-test_scan_date) - -## test_scan_dot() [](#method-i-test_scan_dot) - -## test_scan_float() [](#method-i-test_scan_float) - -## test_scan_float_with_exponent_but_no_fraction() [](#method-i-test_scan_float_with_exponent_but_no_fraction) - -## test_scan_good_edge_date() [](#method-i-test_scan_good_edge_date) - -## test_scan_inf() [](#method-i-test_scan_inf) - -## test_scan_int_commas_and_underscores() [](#method-i-test_scan_int_commas_and_underscores) - -## test_scan_minus_inf() [](#method-i-test_scan_minus_inf) - -## test_scan_nan() [](#method-i-test_scan_nan) - -## test_scan_not_sexagesimal() [](#method-i-test_scan_not_sexagesimal) - -## test_scan_null() [](#method-i-test_scan_null) - -## test_scan_plus_dot() [](#method-i-test_scan_plus_dot) - -## test_scan_plus_inf() [](#method-i-test_scan_plus_inf) - -## test_scan_sexagesimal_float() [](#method-i-test_scan_sexagesimal_float) - -## test_scan_sexagesimal_int() [](#method-i-test_scan_sexagesimal_int) - -## test_scan_strict_int_commas_and_underscores() [](#method-i-test_scan_strict_int_commas_and_underscores) - -## test_scan_strings_ending_with_underscores() [](#method-i-test_scan_strings_ending_with_underscores) - -## test_scan_strings_starting_with_number() [](#method-i-test_scan_strings_starting_with_number) - -## test_scan_strings_starting_with_underscores() [](#method-i-test_scan_strings_starting_with_underscores) - -## test_scan_strings_with_legacy_int_delimiters() [](#method-i-test_scan_strings_with_legacy_int_delimiters) - -## test_scan_strings_with_strict_int_delimiters() [](#method-i-test_scan_strings_with_strict_int_delimiters) - -## test_scan_symbol() [](#method-i-test_scan_symbol) - -## test_scan_time() [](#method-i-test_scan_time) - -## test_scan_true() [](#method-i-test_scan_true) - -## test_scan_unicode_matches_quickly() [](#method-i-test_scan_unicode_matches_quickly) - diff --git a/example/ruby/Psych/TestScalarScanner/MatchCallCounter.md b/example/ruby/Psych/TestScalarScanner/MatchCallCounter.md deleted file mode 100644 index 671ba5f..0000000 --- a/example/ruby/Psych/TestScalarScanner/MatchCallCounter.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::TestScalarScanner::MatchCallCounter -**Inherits:** String - - - - -# Attributes -## match_call_count[RW] [](#attribute-i-match_call_count) -Returns the value of attribute match_call_count. - - -#Instance Methods -## match?(pat) [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/Psych/TestSerializeSubclasses.md b/example/ruby/Psych/TestSerializeSubclasses.md deleted file mode 100644 index 78a6f9b..0000000 --- a/example/ruby/Psych/TestSerializeSubclasses.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Psych::TestSerializeSubclasses -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_some_object() [](#method-i-test_some_object) - -## test_struct_subclass() [](#method-i-test_struct_subclass) - diff --git a/example/ruby/Psych/TestSerializeSubclasses/SomeObject.md b/example/ruby/Psych/TestSerializeSubclasses/SomeObject.md deleted file mode 100644 index 875d664..0000000 --- a/example/ruby/Psych/TestSerializeSubclasses/SomeObject.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Psych::TestSerializeSubclasses::SomeObject -**Inherits:** Object - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(one, two) [](#method-i-initialize) - -**@return** [SomeObject] a new instance of SomeObject - diff --git a/example/ruby/Psych/TestSerializeSubclasses/StructSubclass.md b/example/ruby/Psych/TestSerializeSubclasses/StructSubclass.md deleted file mode 100644 index d4b492f..0000000 --- a/example/ruby/Psych/TestSerializeSubclasses/StructSubclass.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Psych::TestSerializeSubclasses::StructSubclass -**Inherits:** Struct - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo - -**@return** [Object] the current value of foo - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(foo, bar) [](#method-i-initialize) - -**@return** [StructSubclass] a new instance of StructSubclass - diff --git a/example/ruby/Psych/TestSet.md b/example/ruby/Psych/TestSet.md deleted file mode 100644 index 6b558cd..0000000 --- a/example/ruby/Psych/TestSet.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Psych::TestSet -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_dump() [](#method-i-test_dump) - -## test_load_from_yaml() [](#method-i-test_load_from_yaml) -FIXME: Syck should also support !!set as shorthand - -## test_loaded_class() [](#method-i-test_loaded_class) - -## test_roundtrip() [](#method-i-test_roundtrip) - -## test_set_self_reference() [](#method-i-test_set_self_reference) - -## test_set_shorthand() [](#method-i-test_set_shorthand) - -## test_stringify_names() [](#method-i-test_stringify_names) - diff --git a/example/ruby/Psych/TestStream.md b/example/ruby/Psych/TestStream.md deleted file mode 100644 index 918ab1a..0000000 --- a/example/ruby/Psych/TestStream.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Psych::TestStream -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_explicit_documents() [](#method-i-test_explicit_documents) - -## test_load_partial() [](#method-i-test_load_partial) - -## test_load_stream_break() [](#method-i-test_load_stream_break) - -## test_load_stream_yields_documents() [](#method-i-test_load_stream_yields_documents) - -## test_no_backreferences() [](#method-i-test_no_backreferences) - -## test_parse_partial() [](#method-i-test_parse_partial) - -## test_parse_stream_break() [](#method-i-test_parse_stream_break) - -## test_parse_stream_yields_documents() [](#method-i-test_parse_stream_yields_documents) - -## test_start_takes_block() [](#method-i-test_start_takes_block) - diff --git a/example/ruby/Psych/TestString.md b/example/ruby/Psych/TestString.md deleted file mode 100644 index cdf355b..0000000 --- a/example/ruby/Psych/TestString.md +++ /dev/null @@ -1,79 +0,0 @@ -# Class: Psych::TestString -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## binary_string(percentage0.31, length100) [](#method-i-binary_string) - -## test_all_yaml_1_1_booleans_are_quoted() [](#method-i-test_all_yaml_1_1_booleans_are_quoted) -'y', 'Y', 'n', 'N' are kind of ambiguous. Syck treated those literals in YAML -documents as strings. But this is not what the YAML 1.1 spec says. YAML 1.1 -says they should be treated as booleans. When we're dumping documents, we -know it's a string, so adding quotes will eliminate the "ambiguity" in the -emitted document - -## test_another_subclass_with_attributes() [](#method-i-test_another_subclass_with_attributes) - -## test_ascii_only_8bit_string() [](#method-i-test_ascii_only_8bit_string) - -## test_ascii_only_binary_string() [](#method-i-test_ascii_only_binary_string) - -## test_backwards_with_syck() [](#method-i-test_backwards_with_syck) - -## test_binary() [](#method-i-test_binary) - -## test_binary_string() [](#method-i-test_binary_string) - -## test_binary_string_null() [](#method-i-test_binary_string_null) - -## test_cycle_x() [](#method-i-test_cycle_x) - -## test_dash_dot() [](#method-i-test_dash_dot) - -## test_doublequotes_when_there_is_a_single() [](#method-i-test_doublequotes_when_there_is_a_single) - -## test_empty_character_subclass() [](#method-i-test_empty_character_subclass) - -## test_empty_subclass() [](#method-i-test_empty_subclass) - -## test_float_confusion() [](#method-i-test_float_confusion) - -## test_float_with_no_fractional_before_exponent() [](#method-i-test_float_with_no_fractional_before_exponent) - -## test_folded_strip_when_longer_than_line_width_and_no_newlines() [](#method-i-test_folded_strip_when_longer_than_line_width_and_no_newlines) -http://yaml.org/spec/1.2/2009-07-21/spec.html#id2593651 - -## test_folded_when_longer_than_line_width_and_with_final_line_break() [](#method-i-test_folded_when_longer_than_line_width_and_with_final_line_break) - -## test_literal_strip_when_inner_line_break_and_no_final_line_break() [](#method-i-test_literal_strip_when_inner_line_break_and_no_final_line_break) -http://yaml.org/spec/1.2/2009-07-21/spec.html#id2593651 - -## test_literal_when_inner_and_final_line_break() [](#method-i-test_literal_when_inner_and_final_line_break) - -## test_no_doublequotes_with_special_characters() [](#method-i-test_no_doublequotes_with_special_characters) - -## test_no_quotes_when_start_with_non_ascii_character() [](#method-i-test_no_quotes_when_start_with_non_ascii_character) - -## test_nonascii_string_as_binary() [](#method-i-test_nonascii_string_as_binary) - -## test_plain_when_shorten_than_line_width_and_no_final_line_break() [](#method-i-test_plain_when_shorten_than_line_width_and_no_final_line_break) - -## test_plain_when_shorten_than_line_width_and_with_final_line_break() [](#method-i-test_plain_when_shorten_than_line_width_and_with_final_line_break) - -## test_self_referential_string() [](#method-i-test_self_referential_string) - -## test_single_quote_when_matching_date() [](#method-i-test_single_quote_when_matching_date) - -## test_string_subclass_with_anchor() [](#method-i-test_string_subclass_with_anchor) - -## test_string_with_base_60() [](#method-i-test_string_with_base_60) - -## test_string_with_ivars() [](#method-i-test_string_with_ivars) - -## test_string_with_newline() [](#method-i-test_string_with_newline) - -## test_subclass_with_attributes() [](#method-i-test_subclass_with_attributes) - diff --git a/example/ruby/Psych/TestString/X.md b/example/ruby/Psych/TestString/X.md deleted file mode 100644 index bf6da29..0000000 --- a/example/ruby/Psych/TestString/X.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::TestString::X -**Inherits:** String - - - - - diff --git a/example/ruby/Psych/TestString/Y.md b/example/ruby/Psych/TestString/Y.md deleted file mode 100644 index e007cc5..0000000 --- a/example/ruby/Psych/TestString/Y.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Psych::TestString::Y -**Inherits:** String - - - - -# Attributes -## val[RW] [](#attribute-i-val) -Returns the value of attribute val. - - diff --git a/example/ruby/Psych/TestString/Z.md b/example/ruby/Psych/TestString/Z.md deleted file mode 100644 index f44828d..0000000 --- a/example/ruby/Psych/TestString/Z.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Psych::TestString::Z -**Inherits:** String - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Z] a new instance of Z - diff --git a/example/ruby/Psych/TestStruct.md b/example/ruby/Psych/TestStruct.md deleted file mode 100644 index 43e6c57..0000000 --- a/example/ruby/Psych/TestStruct.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Psych::TestStruct -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_load() [](#method-i-test_load) - -## test_roundtrip() [](#method-i-test_roundtrip) - -## test_self_referential_struct() [](#method-i-test_self_referential_struct) - diff --git a/example/ruby/Psych/TestStruct/StructSubclass.md b/example/ruby/Psych/TestStruct/StructSubclass.md deleted file mode 100644 index e7dcc99..0000000 --- a/example/ruby/Psych/TestStruct/StructSubclass.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Psych::TestStruct::StructSubclass -**Inherits:** Struct - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo - -**@return** [Object] the current value of foo - - -#Instance Methods -## initialize(foo, bar) [](#method-i-initialize) - -**@return** [StructSubclass] a new instance of StructSubclass - diff --git a/example/ruby/Psych/TestSymbol.md b/example/ruby/Psych/TestSymbol.md deleted file mode 100644 index 7fa8c3d..0000000 --- a/example/ruby/Psych/TestSymbol.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Psych::TestSymbol -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_cycle() [](#method-i-test_cycle) - -## test_cycle_colon() [](#method-i-test_cycle_colon) - -## test_cycle_empty() [](#method-i-test_cycle_empty) - -## test_load_quoted() [](#method-i-test_load_quoted) - -## test_stringy() [](#method-i-test_stringy) - diff --git a/example/ruby/Psych/TestTreeBuilder.md b/example/ruby/Psych/TestTreeBuilder.md deleted file mode 100644 index feeab29..0000000 --- a/example/ruby/Psych/TestTreeBuilder.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Psych::TestTreeBuilder -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_alias() [](#method-i-test_alias) - -## test_documents() [](#method-i-test_documents) - -## test_mapping() [](#method-i-test_mapping) - -## test_scalar() [](#method-i-test_scalar) - -## test_sequence() [](#method-i-test_sequence) - -## test_stream() [](#method-i-test_stream) - diff --git a/example/ruby/Psych/TestYamlSpecialCases.md b/example/ruby/Psych/TestYamlSpecialCases.md deleted file mode 100644 index f2b10c9..0000000 --- a/example/ruby/Psych/TestYamlSpecialCases.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Psych::TestYamlSpecialCases -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_0xC() [](#method-i-test_0xC) - -## test_8() [](#method-i-test_8) - -## test_NaN() [](#method-i-test_NaN) - -## test_arrows() [](#method-i-test_arrows) - -## test_arrows_hash() [](#method-i-test_arrows_hash) - -## test_empty_string() [](#method-i-test_empty_string) - -## test_false() [](#method-i-test_false) - -## test_inf() [](#method-i-test_inf) - -## test_n() [](#method-i-test_n) - -## test_null() [](#method-i-test_null) - -## test_off() [](#method-i-test_off) - -## test_thousand() [](#method-i-test_thousand) - diff --git a/example/ruby/Psych/TreeBuilder.md b/example/ruby/Psych/TreeBuilder.md deleted file mode 100644 index 0c4f49c..0000000 --- a/example/ruby/Psych/TreeBuilder.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Psych::TreeBuilder -**Inherits:** Psych::Handler - - -This class works in conjunction with Psych::Parser to build an in-memory parse -tree that represents a YAML document. - -## Example - - parser = Psych::Parser.new Psych::TreeBuilder.new - parser.parse('--- foo') - tree = parser.handler.root - -See Psych::Handler for documentation on the event methods used in this class. - - -# Attributes -## root[RW] [](#attribute-i-root) -Returns the root node for the built tree - - -#Instance Methods -## alias(anchor) [](#method-i-alias) - -## end_document(implicit_end!streaming?) [](#method-i-end_document) -Handles end_document events with `version`, `tag_directives`, and `implicit` -styling. - -See Psych::Handler#start_document - -## end_stream() [](#method-i-end_stream) - -## event_location(start_line, start_column, end_line, end_column) [](#method-i-event_location) - -## initialize() [](#method-i-initialize) -Create a new TreeBuilder instance - -**@return** [TreeBuilder] a new instance of TreeBuilder - -## scalar(value, anchor, tag, plain, quoted, style) [](#method-i-scalar) - -## start_document(version, tag_directives, implicit) [](#method-i-start_document) -Handles start_document events with `version`, `tag_directives`, and `implicit` -styling. - -See Psych::Handler#start_document - -## start_stream(encoding) [](#method-i-start_stream) - diff --git a/example/ruby/Psych/Visitors.md b/example/ruby/Psych/Visitors.md deleted file mode 100644 index 5b8352c..0000000 --- a/example/ruby/Psych/Visitors.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Psych::Visitors - - - - - diff --git a/example/ruby/Psych/Visitors/DepthFirst.md b/example/ruby/Psych/Visitors/DepthFirst.md deleted file mode 100644 index 287c48c..0000000 --- a/example/ruby/Psych/Visitors/DepthFirst.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Psych::Visitors::DepthFirst -**Inherits:** Psych::Visitors::Visitor - - - - - -#Instance Methods -## initialize(block) [](#method-i-initialize) - -**@return** [DepthFirst] a new instance of DepthFirst - diff --git a/example/ruby/Psych/Visitors/Emitter.md b/example/ruby/Psych/Visitors/Emitter.md deleted file mode 100644 index 0a3a5cc..0000000 --- a/example/ruby/Psych/Visitors/Emitter.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Psych::Visitors::Emitter -**Inherits:** Psych::Visitors::Visitor - - - - - -#Instance Methods -## initialize(io, options{}) [](#method-i-initialize) - -**@return** [Emitter] a new instance of Emitter - -## visit_Psych_Nodes_Alias(o) [](#method-i-visit_Psych_Nodes_Alias) - -## visit_Psych_Nodes_Document(o) [](#method-i-visit_Psych_Nodes_Document) - -## visit_Psych_Nodes_Mapping(o) [](#method-i-visit_Psych_Nodes_Mapping) - -## visit_Psych_Nodes_Scalar(o) [](#method-i-visit_Psych_Nodes_Scalar) - -## visit_Psych_Nodes_Sequence(o) [](#method-i-visit_Psych_Nodes_Sequence) - -## visit_Psych_Nodes_Stream(o) [](#method-i-visit_Psych_Nodes_Stream) - diff --git a/example/ruby/Psych/Visitors/JSONTree.md b/example/ruby/Psych/Visitors/JSONTree.md deleted file mode 100644 index b417313..0000000 --- a/example/ruby/Psych/Visitors/JSONTree.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Psych::Visitors::JSONTree -**Inherits:** Psych::Visitors::YAMLTree - -**Includes:** Psych::JSON::RubyEvents - - - - -# Class Methods -## create(options {}) [](#method-c-create) - -#Instance Methods -## accept(target) [](#method-i-accept) - -## visit_DateTime(o) [](#method-i-visit_DateTime) - -## visit_String(o) [](#method-i-visit_String) - -## visit_Time(o) [](#method-i-visit_Time) - diff --git a/example/ruby/Psych/Visitors/NoAliasRuby.md b/example/ruby/Psych/Visitors/NoAliasRuby.md deleted file mode 100644 index ba097a1..0000000 --- a/example/ruby/Psych/Visitors/NoAliasRuby.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Psych::Visitors::NoAliasRuby -**Inherits:** Psych::Visitors::ToRuby - - - - - -#Instance Methods -## visit_Psych_Nodes_Alias(o) [](#method-i-visit_Psych_Nodes_Alias) - -**@raise** [AliasesNotEnabled] - diff --git a/example/ruby/Psych/Visitors/RestrictedYAMLTree.md b/example/ruby/Psych/Visitors/RestrictedYAMLTree.md deleted file mode 100644 index 328e34b..0000000 --- a/example/ruby/Psych/Visitors/RestrictedYAMLTree.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::Visitors::RestrictedYAMLTree -**Inherits:** Psych::Visitors::YAMLTree - - - - - -#Instance Methods -## accept(target) [](#method-i-accept) - -## initialize(emitter, ss, options) [](#method-i-initialize) - -**@return** [RestrictedYAMLTree] a new instance of RestrictedYAMLTree - -## visit_Symbol(sym) [](#method-i-visit_Symbol) - diff --git a/example/ruby/Psych/Visitors/TestDepthFirst.md b/example/ruby/Psych/Visitors/TestDepthFirst.md deleted file mode 100644 index f031194..0000000 --- a/example/ruby/Psych/Visitors/TestDepthFirst.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::Visitors::TestDepthFirst -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## test_alias() [](#method-i-test_alias) - -## test_mapping() [](#method-i-test_mapping) - -## test_scalar() [](#method-i-test_scalar) - -## test_sequence() [](#method-i-test_sequence) - diff --git a/example/ruby/Psych/Visitors/TestDepthFirst/Collector.md b/example/ruby/Psych/Visitors/TestDepthFirst/Collector.md deleted file mode 100644 index fb7bd8a..0000000 --- a/example/ruby/Psych/Visitors/TestDepthFirst/Collector.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Psych::Visitors::TestDepthFirst::Collector -**Inherits:** Struct - - - - -# Attributes -## calls[RW] [](#attribute-i-calls) -Returns the value of attribute calls - -**@return** [Object] the current value of calls - - -#Instance Methods -## call(obj) [](#method-i-call) - -## initialize(calls[]) [](#method-i-initialize) - -**@return** [Collector] a new instance of Collector - diff --git a/example/ruby/Psych/Visitors/TestEmitter.md b/example/ruby/Psych/Visitors/TestEmitter.md deleted file mode 100644 index afd5769..0000000 --- a/example/ruby/Psych/Visitors/TestEmitter.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Psych::Visitors::TestEmitter -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_alias() [](#method-i-test_alias) - -## test_document() [](#method-i-test_document) - -## test_document_implicit_end() [](#method-i-test_document_implicit_end) - -## test_mapping() [](#method-i-test_mapping) - -## test_options() [](#method-i-test_options) - -## test_scalar() [](#method-i-test_scalar) - -## test_scalar_with_tag() [](#method-i-test_scalar_with_tag) - -## test_sequence() [](#method-i-test_sequence) - -## test_stream() [](#method-i-test_stream) - diff --git a/example/ruby/Psych/Visitors/TestToRuby.md b/example/ruby/Psych/Visitors/TestToRuby.md deleted file mode 100644 index 0dcc310..0000000 --- a/example/ruby/Psych/Visitors/TestToRuby.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Psych::Visitors::TestToRuby -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_alias() [](#method-i-test_alias) - -## test_anon_struct() [](#method-i-test_anon_struct) - -## test_anon_struct_legacy() [](#method-i-test_anon_struct_legacy) - -## test_binary() [](#method-i-test_binary) - -## test_boolean_false() [](#method-i-test_boolean_false) -http://yaml.org/type/bool.html - -## test_boolean_true() [](#method-i-test_boolean_true) -http://yaml.org/type/bool.html - -## test_complex() [](#method-i-test_complex) - -## test_complex_string() [](#method-i-test_complex_string) - -## test_date() [](#method-i-test_date) - -## test_document() [](#method-i-test_document) - -## test_exception() [](#method-i-test_exception) - -## test_exp_float() [](#method-i-test_exp_float) - -## test_float() [](#method-i-test_float) - -## test_float_ignore() [](#method-i-test_float_ignore) - -## test_int_ignore() [](#method-i-test_int_ignore) - -## test_integer() [](#method-i-test_integer) - -## test_legacy_struct() [](#method-i-test_legacy_struct) - -## test_mapping() [](#method-i-test_mapping) - -## test_mapping_with_str_tag() [](#method-i-test_mapping_with_str_tag) - -## test_object() [](#method-i-test_object) - -## test_range_string() [](#method-i-test_range_string) - -## test_range_string_triple() [](#method-i-test_range_string_triple) - -## test_rational() [](#method-i-test_rational) - -## test_rational_string() [](#method-i-test_rational_string) - -## test_regexp() [](#method-i-test_regexp) - -## test_scalar() [](#method-i-test_scalar) - -## test_sequence() [](#method-i-test_sequence) - -## test_stream() [](#method-i-test_stream) - -## test_struct() [](#method-i-test_struct) - -## test_time() [](#method-i-test_time) - -## test_time_utc() [](#method-i-test_time_utc) - -## test_time_utc_no_z() [](#method-i-test_time_utc_no_z) - -## test_tz_00_00_loads_without_error() [](#method-i-test_tz_00_00_loads_without_error) - diff --git a/example/ruby/Psych/Visitors/TestToRuby/A.md b/example/ruby/Psych/Visitors/TestToRuby/A.md deleted file mode 100644 index 5f04d72..0000000 --- a/example/ruby/Psych/Visitors/TestToRuby/A.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Psych::Visitors::TestToRuby::A -**Inherits:** Struct - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo - -**@return** [Object] the current value of foo - - diff --git a/example/ruby/Psych/Visitors/TestYAMLTree.md b/example/ruby/Psych/Visitors/TestYAMLTree.md deleted file mode 100644 index 53f05dc..0000000 --- a/example/ruby/Psych/Visitors/TestYAMLTree.md +++ /dev/null @@ -1,67 +0,0 @@ -# Class: Psych::Visitors::TestYAMLTree -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_anon_class() [](#method-i-test_anon_class) - -## test_binary_formatting() [](#method-i-test_binary_formatting) - -## test_boolean() [](#method-i-test_boolean) - -## test_complex() [](#method-i-test_complex) - -## test_date() [](#method-i-test_date) - -## test_delegator() [](#method-i-test_delegator) - -## test_exception() [](#method-i-test_exception) - -## test_float() [](#method-i-test_float) - -## test_hash() [](#method-i-test_hash) - -## test_int() [](#method-i-test_int) - -## test_list() [](#method-i-test_list) - -## test_nil() [](#method-i-test_nil) -http://yaml.org/type/null.html - -## test_object_has_no_class() [](#method-i-test_object_has_no_class) - -## test_override_method() [](#method-i-test_override_method) - -## test_range_exclusive() [](#method-i-test_range_exclusive) - -## test_range_inclusive() [](#method-i-test_range_inclusive) - -## test_rational() [](#method-i-test_rational) - -## test_regexp() [](#method-i-test_regexp) - -## test_scalar() [](#method-i-test_scalar) - -## test_simple_delegator() [](#method-i-test_simple_delegator) - -## test_string() [](#method-i-test_string) - -## test_struct() [](#method-i-test_struct) - -## test_struct_anon() [](#method-i-test_struct_anon) - -## test_struct_const() [](#method-i-test_struct_const) - -## test_symbol() [](#method-i-test_symbol) - -## test_time() [](#method-i-test_time) - -## test_tree_can_be_called_twice() [](#method-i-test_tree_can_be_called_twice) - -## test_yaml_tree_can_take_an_emitter() [](#method-i-test_yaml_tree_can_take_an_emitter) - diff --git a/example/ruby/Psych/Visitors/TestYAMLTree/A.md b/example/ruby/Psych/Visitors/TestYAMLTree/A.md deleted file mode 100644 index e1d470a..0000000 --- a/example/ruby/Psych/Visitors/TestYAMLTree/A.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Psych::Visitors::TestYAMLTree::A -**Inherits:** Struct - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo - -**@return** [Object] the current value of foo - - diff --git a/example/ruby/Psych/Visitors/TestYAMLTree/TestDelegatorClass.md b/example/ruby/Psych/Visitors/TestYAMLTree/TestDelegatorClass.md deleted file mode 100644 index 261ff06..0000000 --- a/example/ruby/Psych/Visitors/TestYAMLTree/TestDelegatorClass.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Psych::Visitors::TestYAMLTree::TestDelegatorClass -**Inherits:** Delegator - - - - - -#Instance Methods -## __getobj__() [](#method-i-__getobj__) - -## __setobj__(obj) [](#method-i-__setobj__) - -## initialize(obj) [](#method-i-initialize) - -**@return** [TestDelegatorClass] a new instance of TestDelegatorClass - diff --git a/example/ruby/Psych/Visitors/TestYAMLTree/TestSimpleDelegatorClass.md b/example/ruby/Psych/Visitors/TestYAMLTree/TestSimpleDelegatorClass.md deleted file mode 100644 index 675086a..0000000 --- a/example/ruby/Psych/Visitors/TestYAMLTree/TestSimpleDelegatorClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Psych::Visitors::TestYAMLTree::TestSimpleDelegatorClass -**Inherits:** SimpleDelegator - - - - - diff --git a/example/ruby/Psych/Visitors/ToRuby.md b/example/ruby/Psych/Visitors/ToRuby.md deleted file mode 100644 index cb0830a..0000000 --- a/example/ruby/Psych/Visitors/ToRuby.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Psych::Visitors::ToRuby -**Inherits:** Psych::Visitors::Visitor - - -This class walks a YAML AST, converting each node to Ruby - - -# Class Methods -## create(symbolize_names: false, freeze: false, strict_integer: false) [](#method-c-create) -# Attributes -## class_loader[RW] [](#attribute-i-class_loader) -Returns the value of attribute class_loader. - - -#Instance Methods -## accept(target) [](#method-i-accept) - -## initialize(ss, class_loader, symbolize_names:false, freeze:false) [](#method-i-initialize) - -**@return** [ToRuby] a new instance of ToRuby - -## visit_Psych_Nodes_Alias(o) [](#method-i-visit_Psych_Nodes_Alias) - -## visit_Psych_Nodes_Document(o) [](#method-i-visit_Psych_Nodes_Document) - -## visit_Psych_Nodes_Mapping(o) [](#method-i-visit_Psych_Nodes_Mapping) - -## visit_Psych_Nodes_Scalar(o) [](#method-i-visit_Psych_Nodes_Scalar) - -## visit_Psych_Nodes_Sequence(o) [](#method-i-visit_Psych_Nodes_Sequence) - -## visit_Psych_Nodes_Stream(o) [](#method-i-visit_Psych_Nodes_Stream) - diff --git a/example/ruby/Psych/Visitors/Visitor.md b/example/ruby/Psych/Visitors/Visitor.md deleted file mode 100644 index fd4e7b1..0000000 --- a/example/ruby/Psych/Visitors/Visitor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Psych::Visitors::Visitor -**Inherits:** Object - - - - - -#Instance Methods -## accept(target) [](#method-i-accept) - diff --git a/example/ruby/Psych/Visitors/YAMLTree.md b/example/ruby/Psych/Visitors/YAMLTree.md deleted file mode 100644 index 218d1ea..0000000 --- a/example/ruby/Psych/Visitors/YAMLTree.md +++ /dev/null @@ -1,92 +0,0 @@ -# Class: Psych::Visitors::YAMLTree -**Inherits:** Psych::Visitors::Visitor - - -YAMLTree builds a YAML ast given a Ruby object. For example: - - builder = Psych::Visitors::YAMLTree.new - builder << { :foo => 'bar' } - builder.tree # => # [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value' ] }, <(other) [](#method-i-<=>) -Order by #singleton then #new_name - -## aref() [](#method-i-aref) -HTML fragment reference for this alias - -## full_old_name() [](#method-i-full_old_name) -Full old name including namespace - -## html_name() [](#method-i-html_name) -HTML id-friendly version of `#new_name`. - -## initialize(text, old_name, new_name, comment, singletonfalse) [](#method-i-initialize) -Creates a new Alias with a token stream of `text` that aliases `old_name` to -`new_name`, has `comment` and is a `singleton` context. - -**@return** [Alias] a new instance of Alias - -## inspect() [](#method-i-inspect) -:nodoc: - -## name_prefix() [](#method-i-name_prefix) -'::' for the alias of a singleton method/attribute, '#' for instance-level. - -## pretty_new_name() [](#method-i-pretty_new_name) -New name with prefix '::' or '#'. - -## pretty_old_name() [](#method-i-pretty_old_name) -Old name with prefix '::' or '#'. - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/RDoc/AnonClass.md b/example/ruby/RDoc/AnonClass.md deleted file mode 100644 index 4ffb3b6..0000000 --- a/example/ruby/RDoc/AnonClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: RDoc::AnonClass -**Inherits:** RDoc::ClassModule - - -An anonymous class like: - - c = Class.new do end - -AnonClass is currently not used. - - - diff --git a/example/ruby/RDoc/AnyMethod.md b/example/ruby/RDoc/AnyMethod.md deleted file mode 100644 index a8d4008..0000000 --- a/example/ruby/RDoc/AnyMethod.md +++ /dev/null @@ -1,114 +0,0 @@ -# Class: RDoc::AnyMethod -**Inherits:** RDoc::MethodAttr - -**Includes:** RDoc::TokenStream - - -AnyMethod is the base class for objects representing methods - - -# Attributes -## c_function[RW] [](#attribute-i-c_function) -The C function that implements this method (if it was defined in a C file) - -## calls_super[RW] [](#attribute-i-calls_super) -If true this method uses `super` to call a superclass version - -## dont_rename_initialize[RW] [](#attribute-i-dont_rename_initialize) -Don't rename #initialize to ::new - -## params[RW] [](#attribute-i-params) -Parameters for this method - -## section_title[RW] [](#attribute-i-section_title) -The section title of the method (if defined in a C file via `:category:`) - - -#Instance Methods -## add_alias(an_alias, contextnil) [](#method-i-add_alias) -Adds `an_alias` as an alias for this method in `context`. - -## add_token(token) [](#method-i-add_token) -Adds one `token` to the collected tokens - -## add_tokens(tokens) [](#method-i-add_tokens) -Adds `tokens` to the collected tokens - -## aref_prefix() [](#method-i-aref_prefix) -Prefix for `aref` is 'method'. - -## arglists() [](#method-i-arglists) -The call_seq or the param_seq with method name, if there is no call_seq. - -Use this for displaying a method's argument lists. - -## call_seq() [](#method-i-call_seq) -Different ways to call this method - -## call_seq=(call_seq) [](#method-i-call_seq=) -Sets the different ways you can call this method. If an empty `call_seq` is -given nil is assumed. - -See also #param_seq - -## collect_tokens() [](#method-i-collect_tokens) -Starts collecting tokens - -## has_call_seq?() [](#method-i-has_call_seq?) -Whether the method has a call-seq. - -**@return** [Boolean] - -## initialize(text, name) [](#method-i-initialize) -Creates a new AnyMethod with a token stream `text` and `name` - -**@return** [AnyMethod] a new instance of AnyMethod - -## is_alias_for() [](#method-i-is_alias_for) -Loads is_alias_for from the internal name. Returns nil if the alias cannot be -found. - -## marshal_dump() [](#method-i-marshal_dump) -Dumps this AnyMethod for use by ri. See also #marshal_load - -## marshal_load(array) [](#method-i-marshal_load) -Loads this AnyMethod from `array`. For a loaded AnyMethod the following -methods will return cached values: - -* #full_name -* #parent_name - -## name() [](#method-i-name) -Method name - -If the method has no assigned name, it extracts it from #call_seq. - -## param_list() [](#method-i-param_list) -A list of this method's method and yield parameters. `call-seq` params are -preferred over parsed method and block params. - -## param_seq() [](#method-i-param_seq) -Pretty parameter list for this method. If the method's parameters were given -by `call-seq` it is preferred over the parsed values. - -## pop_token() [](#method-i-pop_token) -Remove the last token from the collected tokens - -## skip_description?() [](#method-i-skip_description?) -Whether to skip the method description, true for methods that have aliases -with a call-seq that doesn't include the method name. - -**@return** [Boolean] - -## store=(store) [](#method-i-store=) -Sets the store for this method and its referenced code objects. - -## superclass_method() [](#method-i-superclass_method) -For methods that `super`, find the superclass method that would be called. - -## token_stream() [](#method-i-token_stream) -Current token stream - -## tokens_to_s() [](#method-i-tokens_to_s) -Returns a string representation of the token stream - diff --git a/example/ruby/RDoc/Attr.md b/example/ruby/RDoc/Attr.md deleted file mode 100644 index 6ba0a0a..0000000 --- a/example/ruby/RDoc/Attr.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: RDoc::Attr -**Inherits:** RDoc::MethodAttr - - -An attribute created by #attr, #attr_reader, #attr_writer or #attr_accessor - - -# Attributes -## rw[RW] [](#attribute-i-rw) -Is the attribute readable ('R'), writable ('W') or both ('RW')? - - -#Instance Methods -## ==(other) [](#method-i-==) -Attributes are equal when their names, singleton and rw are identical - -## add_alias(an_alias, context) [](#method-i-add_alias) -Add `an_alias` as an attribute in `context`. - -## aref_prefix() [](#method-i-aref_prefix) -The #aref prefix for attributes - -## calls_super() [](#method-i-calls_super) -Attributes never call super. See RDoc::AnyMethod#calls_super - -An RDoc::Attr can show up in the method list in some situations (see -Gem::ConfigFile) - -## definition() [](#method-i-definition) -Returns attr_reader, attr_writer or attr_accessor as appropriate. - -## initialize(text, name, rw, comment, singletonfalse) [](#method-i-initialize) -Creates a new Attr with body `text`, `name`, read/write status `rw` and -`comment`. `singleton` marks this as a class attribute. - -**@return** [Attr] a new instance of Attr - -## inspect() [](#method-i-inspect) -:nodoc: - -## marshal_dump() [](#method-i-marshal_dump) -Dumps this Attr for use by ri. See also #marshal_load - -## marshal_load(array) [](#method-i-marshal_load) -Loads this Attr from `array`. For a loaded Attr the following methods will -return cached values: - -* #full_name -* #parent_name - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - -## token_stream() [](#method-i-token_stream) -Attributes do not have token streams. - -An RDoc::Attr can show up in the method list in some situations (see -Gem::ConfigFile) - diff --git a/example/ruby/RDoc/ClassModule.md b/example/ruby/RDoc/ClassModule.md deleted file mode 100644 index 458a4eb..0000000 --- a/example/ruby/RDoc/ClassModule.md +++ /dev/null @@ -1,224 +0,0 @@ -# Class: RDoc::ClassModule -**Inherits:** RDoc::Context - - -ClassModule is the base class for objects representing either a class or a -module. - - -# Class Methods -## from_module(class_type , mod ) [](#method-c-from_module) -Return a RDoc::ClassModule of class `class_type` that is a copy of module -`module`. Used to promote modules to classes. -- TODO move to -RDoc::NormalClass (I think) -# Attributes -## comment_location[RW] [](#attribute-i-comment_location) -Comment and the location it came from. Use #add_comment to add comments - -## constant_aliases[RW] [](#attribute-i-constant_aliases) -Constants that are aliases for this class or module - -## diagram[RW] [](#attribute-i-diagram) -:nodoc: - -## is_alias_for[RW] [](#attribute-i-is_alias_for) -Class or module this constant is an alias for - - -#Instance Methods -## add_comment(comment, location) [](#method-i-add_comment) -Adds `comment` to this ClassModule's list of comments at `location`. This -method is preferred over #comment= since it allows ri data to be updated -across multiple runs. - -## add_things(my_things, other_things) [](#method-i-add_things) -:nodoc: - -## ancestors() [](#method-i-ancestors) -Ancestors list for this ClassModule: the list of included modules (classes -will add their superclass if any). - -Returns the included classes or modules, not the includes themselves. The -returned values are either String or RDoc::NormalModule instances (see -RDoc::Include#module). - -The values are returned in reverse order of their inclusion, which is the -order suitable for searching methods/attributes in the ancestors. The -superclass, if any, comes last. - -## aref() [](#method-i-aref) -HTML fragment reference for this module or class. See RDoc::NormalClass#aref -and RDoc::NormalModule#aref - -## aref_prefix() [](#method-i-aref_prefix) -:nodoc: - -**@raise** [NotImplementedError] - -## clear_comment() [](#method-i-clear_comment) -Clears the comment. Used by the Ruby parser. - -## comment=(comment) [](#method-i-comment=) -This method is deprecated, use #add_comment instead. - -Appends `comment` to the current comment, but separated by a rule. Works more -like `+=`. - -## complete(min_visibility) [](#method-i-complete) -Prepares this ClassModule for use by a generator. - -See RDoc::Store#complete - -## description() [](#method-i-description) -Handy wrapper for marking up this class or module's comment - -## document_self_or_methods() [](#method-i-document_self_or_methods) -Does this ClassModule or any of its methods have document_self set? - -## documented?() [](#method-i-documented?) -Does this class or module have a comment with content or is #received_nodoc -true? - -**@return** [Boolean] - -## each_ancestor() [](#method-i-each_ancestor) -Iterates the ancestors of this class or module for which an RDoc::ClassModule -exists. - -## embed_mixins() [](#method-i-embed_mixins) - -## find_ancestor_local_symbol(symbol) [](#method-i-find_ancestor_local_symbol) -Looks for a symbol in the #ancestors. See Context#find_local_symbol. - -## find_class_named(name) [](#method-i-find_class_named) -Finds a class or module with `name` in this namespace or its descendants - -## full_name() [](#method-i-full_name) -Return the fully qualified name of this class or module - -## initialize(name, superclassnil) [](#method-i-initialize) -Creates a new ClassModule with `name` with optional `superclass` - -This is a constructor for subclasses, and must never be called directly. - -**@return** [ClassModule] a new instance of ClassModule - -## marshal_dump() [](#method-i-marshal_dump) -TODO: filter included items by #display? - -## marshal_load(array) [](#method-i-marshal_load) -:nodoc: - -## merge(class_module) [](#method-i-merge) -Merges `class_module` into this ClassModule. - -The data in `class_module` is preferred over the receiver. - -## merge_collections(mine, other, other_files, &block) [](#method-i-merge_collections) -Merges collection `mine` with `other` preferring other. `other_files` is used -to help determine which items should be deleted. - -Yields whether the item should be added or removed (true or false) and the -item to be added or removed. - - merge_collections things, other.things, other.in_files do |add, thing| - if add then - # add the thing - else - # remove the thing - end - end - -## merge_sections(cm) [](#method-i-merge_sections) -Merges the comments in this ClassModule with the comments in the other -ClassModule `cm`. - -## module?() [](#method-i-module?) -Does this object represent a module? - -**@return** [Boolean] - -## name=(new_name) [](#method-i-name=) -Allows overriding the initial name. - -Used for modules and classes that are constant aliases. - -## name_for_path() [](#method-i-name_for_path) -Name to use to generate the url: modules and classes that are aliases for -another module or class return the name of the latter. - -## non_aliases() [](#method-i-non_aliases) -Returns the classes and modules that are not constants aliasing another class -or module. For use by formatters only (caches its result). - -## parse(comment_location) [](#method-i-parse) -Parses `comment_location` into an RDoc::Markup::Document composed of multiple -RDoc::Markup::Documents with their file set. - -## path() [](#method-i-path) -Path to this class or module for use with HTML generator output. - -## remove_nodoc_children() [](#method-i-remove_nodoc_children) -Updates the child modules or classes of class/module `parent` by deleting the -ones that have been removed from the documentation. - -`parent_hash` is either `parent.modules_hash` or `parent.classes_hash` and -`all_hash` is ::all_modules_hash or ::all_classes_hash. - -## remove_things(my_things, other_files) [](#method-i-remove_things) -:nodoc: - -## search_record() [](#method-i-search_record) -Search record used by RDoc::Generator::JsonIndex - -## store=(store) [](#method-i-store=) -Sets the store for this class or module and its contained code objects. - -## super_classes() [](#method-i-super_classes) -Get all super classes of this class in an array. The last element might be a -string if the name is unknown. - -## superclass() [](#method-i-superclass) -Get the superclass of this class. Attempts to retrieve the superclass object, -returns the name if it is not known. - -## superclass=(superclass) [](#method-i-superclass=) -Set the superclass of this class to `superclass` - -where `superclass` is one of: - -* `nil` -* a String containing the full name of the superclass -* the RDoc::ClassModule representing the superclass - -**@raise** [NoMethodError] - -## to_s() [](#method-i-to_s) -:nodoc: - -## type() [](#method-i-type) -'module' or 'class' - -## update_aliases() [](#method-i-update_aliases) -Updates the child modules & classes by replacing the ones that are aliases -through a constant. - -The aliased module/class is replaced in the children and in -RDoc::Store#modules_hash or RDoc::Store#classes_hash by a copy that has -`RDoc::ClassModule#is_alias_for` set to the aliased module/class, and this -copy is added to `#aliases` of the aliased module/class. - -Formatters can use the #non_aliases method to retrieve children that are not -aliases, for instance to list the namespace content, since the aliased modules -are included in the constants of the class/module, that are listed separately. - -## update_extends() [](#method-i-update_extends) -Deletes from #extends those whose module has been removed from the -documentation. -- FIXME: like update_includes, extends are not reliably -removed - -## update_includes() [](#method-i-update_includes) -Deletes from #includes those whose module has been removed from the -documentation. -- FIXME: includes are not reliably removed, see _possible_bug -test case - diff --git a/example/ruby/RDoc/CodeObject.md b/example/ruby/RDoc/CodeObject.md deleted file mode 100644 index aa5b89c..0000000 --- a/example/ruby/RDoc/CodeObject.md +++ /dev/null @@ -1,230 +0,0 @@ -# Class: RDoc::CodeObject -**Inherits:** Object - -**Includes:** RDoc::Generator::Markup, RDoc::Text - - -Base class for the RDoc code tree. - -We contain the common stuff for contexts (which are containers) and other -elements (methods, attributes and so on) - -Here's the tree of the CodeObject subclasses: - -* RDoc::Context - * RDoc::TopLevel - * RDoc::ClassModule - * RDoc::AnonClass (never used so far) - * RDoc::NormalClass - * RDoc::NormalModule - * RDoc::SingleClass -* RDoc::MethodAttr - * RDoc::Attr - * RDoc::AnyMethod - * RDoc::GhostMethod - * RDoc::MetaMethod -* RDoc::Alias -* RDoc::Constant -* RDoc::Mixin - * RDoc::Require - * RDoc::Include - - -# Attributes -## comment[RW] [](#attribute-i-comment) -Our comment - -## document_children[RW] [](#attribute-i-document_children) -Do we document our children? - -## document_self[RW] [](#attribute-i-document_self) -Do we document ourselves? - -## done_documenting[RW] [](#attribute-i-done_documenting) -Are we done documenting (ie, did we come across a :enddoc:)? - -## file[RW] [](#attribute-i-file) -Which file this code object was defined in - -## force_documentation[RW] [](#attribute-i-force_documentation) -Force documentation of this CodeObject - -## line[RW] [](#attribute-i-line) -Line in #file where this CodeObject was defined - -## metadata[RW] [](#attribute-i-metadata) -Hash of arbitrary metadata for this CodeObject - -## mixin_from[RW] [](#attribute-i-mixin_from) -When mixed-in to a class, this points to the Context in which it was -originally defined. - -## parent[RW] [](#attribute-i-parent) -Our parent CodeObject. The parent may be missing for classes loaded from -legacy RI data stores. - -## received_nodoc[RW] [](#attribute-i-received_nodoc) -Did we ever receive a `:nodoc:` directive? - -## section[RW] [](#attribute-i-section) -The section this CodeObject is in. Sections allow grouping of constants, -attributes and methods inside a class or module. - -## store[RW] [](#attribute-i-store) -The RDoc::Store for this object. - -## viewer[RW] [](#attribute-i-viewer) -We are the model of the code, but we know that at some point we will be worked -on by viewers. By implementing the Viewable protocol, viewers can associated -themselves with these objects. - - -#Instance Methods -## aref_to(target_path) [](#method-i-aref_to) -Generates a relative URL from this object's path to `target_path` - -## as_href(from_path) [](#method-i-as_href) -Generates a relative URL from `from_path` to this object's path - -## cvs_url(url, full_path) [](#method-i-cvs_url) -Build a webcvs URL starting for the given `url` with `full_path` appended as -the destination path. If `url` contains '%s' `full_path` will be will replace -the %s using sprintf on the `url`. - -## description() [](#method-i-description) -Handy wrapper for marking up this object's comment - -## display?() [](#method-i-display?) -Should this CodeObject be displayed in output? - -A code object should be displayed if: - -* The item didn't have a nodoc or wasn't in a container that had nodoc -* The item wasn't ignored -* The item has documentation and was not suppressed - -**@return** [Boolean] - -## documented?() [](#method-i-documented?) -Does this object have a comment with content or is #received_nodoc true? - -**@return** [Boolean] - -## each_parent() [](#method-i-each_parent) -Yields each parent of this CodeObject. See also -RDoc::ClassModule#each_ancestor - -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## file_name() [](#method-i-file_name) -File name where this CodeObject was found. - -See also RDoc::Context#in_files - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## formatter() [](#method-i-formatter) -Creates an RDoc::Markup::ToHtmlCrossref formatter - -## full_name=(full_name) [](#method-i-full_name=) -Sets the full_name overriding any computed full name. - -Set to `nil` to clear RDoc's cached value - -## ignore() [](#method-i-ignore) -Use this to ignore a CodeObject and all its children until found again -(#record_location is called). An ignored item will not be displayed in -documentation. - -See github issue #55 - -The ignored status is temporary in order to allow implementation details to be -hidden. At the end of processing a file RDoc allows all classes and modules -to add new documentation to previously created classes. - -If a class was ignored (via stopdoc) then reopened later with additional -documentation it should be displayed. If a class was ignored and never -reopened it should not be displayed. The ignore flag allows this to occur. - -## ignored?() [](#method-i-ignored?) -Has this class been ignored? - -See also #ignore - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) -Creates a new CodeObject that will document itself and its children - -**@return** [CodeObject] a new instance of CodeObject - -## initialize_visibility() [](#method-i-initialize_visibility) -Initializes state for visibility of this CodeObject and its children. - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## options() [](#method-i-options) -The options instance from the store this CodeObject is attached to, or a -default options instance if the CodeObject is not attached. - -This is used by Text#snippet - -## parent_file_name() [](#method-i-parent_file_name) -File name of our parent - -## parent_name() [](#method-i-parent_name) -Name of our parent - -## parse(text, format'rdoc') [](#method-i-parse) -Normalizes `text` then builds a RDoc::Markup::Document from it - -## record_location(top_level) [](#method-i-record_location) -Records the RDoc::TopLevel (file) where this code object was defined - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## start_doc() [](#method-i-start_doc) -Enable capture of documentation unless documentation has been turned off by -:enddoc: - -## stop_doc() [](#method-i-stop_doc) -Disable capture of documentation - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## suppress() [](#method-i-suppress) -Use this to suppress a CodeObject and all its children until the next file it -is seen in or documentation is discovered. A suppressed item with -documentation will be displayed while an ignored item with documentation may -not be displayed. - -## suppressed?() [](#method-i-suppressed?) -Has this class been suppressed? - -See also #suppress - -**@return** [Boolean] - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/RDoc/Comment.md b/example/ruby/RDoc/Comment.md deleted file mode 100644 index 498a596..0000000 --- a/example/ruby/RDoc/Comment.md +++ /dev/null @@ -1,128 +0,0 @@ -# Class: RDoc::Comment -**Inherits:** Object - -**Includes:** RDoc::Text - - - - -# Attributes -## document=[R] [](#attribute-i-document=) -Overrides the content returned by #parse. Use when there is no #text source -for this comment - -## format[RW] [](#attribute-i-format) -The format of this comment. Defaults to RDoc::Markup - -## line[RW] [](#attribute-i-line) -Line where this Comment was written - -## location[RW] [](#attribute-i-location) -The RDoc::TopLevel this comment was found in - -## text[RW] [](#attribute-i-text) -The text for this comment - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## empty?() [](#method-i-empty?) -A comment is empty if its text String is empty. - -**@return** [Boolean] - -## encode!(encoding) [](#method-i-encode!) -HACK dubious - -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## extract_call_seq(method) [](#method-i-extract_call_seq) -Look for a 'call-seq' in the comment to override the normal parameter -handling. The :call-seq: is indented from the baseline. All lines of the -same indentation level and prefix are consumed. - -For example, all of the following will be used as the :call-seq: - - # :call-seq: - # ARGF.readlines(sep=$/) -> array - # ARGF.readlines(limit) -> array - # ARGF.readlines(sep, limit) -> array - # - # ARGF.to_a(sep=$/) -> array - # ARGF.to_a(limit) -> array - # ARGF.to_a(sep, limit) -> array - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## initialize(textnil, locationnil, languagenil) [](#method-i-initialize) -Creates a new comment with `text` that is found in the RDoc::TopLevel -`location`. - -**@return** [Comment] a new instance of Comment - -## initialize_copy(copy) [](#method-i-initialize_copy) --- TODO deep copy @document - -## inspect() [](#method-i-inspect) -:nodoc: - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## normalize() [](#method-i-normalize) -Normalizes the text. See RDoc::Text#normalize_comment for details - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## normalized?() [](#method-i-normalized?) -Was this text normalized? - -**@return** [Boolean] - -## parse() [](#method-i-parse) -Parses the comment into an RDoc::Markup::Document. The parsed document is -cached until the text is changed. - -## remove_private() [](#method-i-remove_private) -Removes private sections from this comment. Private sections are flush to the -comment marker and start with `--` and end with `++`. For C-style comments, a -private marker may not start at the opening of the comment. - - /* - *-- - * private - *++ - * public - */ - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## tomdoc?() [](#method-i-tomdoc?) -Returns true if this comment is in TomDoc format. - -**@return** [Boolean] - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/RDoc/Constant.md b/example/ruby/RDoc/Constant.md deleted file mode 100644 index 0c88707..0000000 --- a/example/ruby/RDoc/Constant.md +++ /dev/null @@ -1,67 +0,0 @@ -# Class: RDoc::Constant -**Inherits:** RDoc::CodeObject - - -A constant - - -# Attributes -## is_alias_for[RW] [](#attribute-i-is_alias_for) -The module or class this constant is an alias for - -## name[RW] [](#attribute-i-name) -The constant's name - -## value[RW] [](#attribute-i-value) -The constant's value - -## visibility[RW] [](#attribute-i-visibility) -The constant's visibility - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -Constants are ordered by name - -## ==(other) [](#method-i-==) -Constants are equal when their #parent and #name is the same - -## documented?() [](#method-i-documented?) -A constant is documented if it has a comment, or is an alias for a documented -class or module. - -**@return** [Boolean] - -## full_name() [](#method-i-full_name) -Full constant name including namespace - -## initialize(name, value, comment) [](#method-i-initialize) -Creates a new constant with `name`, `value` and `comment` - -**@return** [Constant] a new instance of Constant - -## inspect() [](#method-i-inspect) -:nodoc: - -## marshal_dump() [](#method-i-marshal_dump) -Dumps this Constant for use by ri. See also #marshal_load - -## marshal_load(array) [](#method-i-marshal_load) -Loads this Constant from `array`. For a loaded Constant the following methods -will return cached values: - -* #full_name -* #parent_name - -## path() [](#method-i-path) -Path to this constant for use with HTML generator output. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## store=(store) [](#method-i-store=) -Sets the store for this class or module and its contained code objects. - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/RDoc/Context.md b/example/ruby/RDoc/Context.md deleted file mode 100644 index 0edcee4..0000000 --- a/example/ruby/RDoc/Context.md +++ /dev/null @@ -1,465 +0,0 @@ -# Class: RDoc::Context -**Inherits:** RDoc::CodeObject - -**Includes:** Comparable - - -A Context is something that can hold modules, classes, methods, attributes, -aliases, requires, and includes. Classes, modules, and files are all Contexts. - - -# Attributes -## aliases[RW] [](#attribute-i-aliases) -Class/module aliases - -## attributes[RW] [](#attribute-i-attributes) -All attr* methods - -## block_params[RW] [](#attribute-i-block_params) -Block params to be used in the next MethodAttr parsed under this context - -## constants[RW] [](#attribute-i-constants) -Constants defined - -## constants_hash[RW] [](#attribute-i-constants_hash) -Hash of registered constants. - -## current_line_visibility=[R] [](#attribute-i-current_line_visibility=) -Current visibility of this line - -## current_section[RW] [](#attribute-i-current_section) -The current documentation section that new items will be added to. If -temporary_section is available it will be used. - -## extends[RW] [](#attribute-i-extends) -Modules this context is extended with - -## external_aliases[RW] [](#attribute-i-external_aliases) -Aliases that could not be resolved. - -## in_files[RW] [](#attribute-i-in_files) -Files this context is found in - -## includes[RW] [](#attribute-i-includes) -Modules this context includes - -## method_list[RW] [](#attribute-i-method_list) -Methods defined in this context - -## methods_hash[RW] [](#attribute-i-methods_hash) -Hash of registered methods. Attributes are also registered here, twice if they -are RW. - -## name[RW] [](#attribute-i-name) -Name of this class excluding namespace. See also full_name - -## params[RW] [](#attribute-i-params) -Params to be used in the next MethodAttr parsed under this context - -## requires[RW] [](#attribute-i-requires) -Files this context requires - -## temporary_section[RW] [](#attribute-i-temporary_section) -Use this section for the next method, attribute or constant added. - -## unmatched_alias_lists[RW] [](#attribute-i-unmatched_alias_lists) -Hash `old_name => [aliases]`, for aliases that haven't (yet) been resolved to -a method/attribute. (Not to be confused with the aliases of the context.) - -## visibility[RW] [](#attribute-i-visibility) -Current visibility of this context - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Contexts are sorted by full_name - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## add(klass, name, comment) [](#method-i-add) -Adds an item of type `klass` with the given `name` and `comment` to the -context. - -Currently only RDoc::Extend and RDoc::Include are supported. - -## add_alias(an_alias) [](#method-i-add_alias) -Adds `an_alias` that is automatically resolved - -## add_attribute(attribute) [](#method-i-add_attribute) -Adds `attribute` if not already there. If it is (as method(s) or attribute), -updates the comment if it was empty. - -The attribute is registered only if it defines a new method. For instance, -`attr_reader :foo` will not be registered if method `foo` exists, but -`attr_accessor :foo` will be registered if method `foo` exists, but `foo=` -does not. - -## add_class(class_type, given_name, superclass'::Object') [](#method-i-add_class) -Adds a class named `given_name` with `superclass`. - -Both `given_name` and `superclass` may contain '::', and are interpreted -relative to the `self` context. This allows handling correctly examples like -these: - class RDoc::Gauntlet < Gauntlet - module Mod - class Object # implies < ::Object - class SubObject < Object # this is _not_ ::Object - -Given `class Container::Item` RDoc assumes `Container` is a module unless it -later sees `class Container`. `add_class` automatically upgrades `given_name` -to a class in this case. - -## add_class_or_module(mod, self_hash, all_hash) [](#method-i-add_class_or_module) -Adds the class or module `mod` to the modules or classes Hash `self_hash`, and -to `all_hash` (either `TopLevel::modules_hash` or `TopLevel::classes_hash`), -unless #done_documenting is `true`. Sets the #parent of `mod` to `self`, and -its #section to #current_section. Returns `mod`. - -## add_constant(constant) [](#method-i-add_constant) -Adds `constant` if not already there. If it is, updates the comment, value -and/or is_alias_for of the known constant if they were empty/nil. - -## add_extend(ext) [](#method-i-add_extend) -Adds extension module `ext` which should be an RDoc::Extend - -## add_include(include) [](#method-i-add_include) -Adds included module `include` which should be an RDoc::Include - -## add_method(method) [](#method-i-add_method) -Adds `method` if not already there. If it is (as method or attribute), updates -the comment if it was empty. - -## add_module(class_type, name) [](#method-i-add_module) -Adds a module named `name`. If RDoc already knows `name` is a class then that -class is returned instead. See also #add_class. - -## add_module_alias(from, from_name, to, file) [](#method-i-add_module_alias) -Adds an alias from `from` (a class or module) to `name` which was defined in -`file`. - -## add_module_by_normal_module(mod) [](#method-i-add_module_by_normal_module) -Adds a module by `RDoc::NormalModule` instance. See also #add_module. - -## add_require(require) [](#method-i-add_require) -Adds `require` to this context's top level - -## add_section(title, commentnil) [](#method-i-add_section) -Returns a section with `title`, creating it if it doesn't already exist. -`comment` will be appended to the section's comment. - -A section with a `title` of `nil` will return the default section. - -See also RDoc::Context::Section - -## add_to(array, thing) [](#method-i-add_to) -Adds `thing` to the collection `array` - -## any_content(includestrue) [](#method-i-any_content) -Is there any content? - -This means any of: comment, aliases, methods, attributes, external aliases, -require, constant. - -Includes and extends are also checked unless `includes == false`. - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## child_name(name) [](#method-i-child_name) -Creates the full name for a child with `name` - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## class_attributes() [](#method-i-class_attributes) -Class attributes - -## class_method_list() [](#method-i-class_method_list) -Class methods - -## classes() [](#method-i-classes) -Array of classes in this context - -## classes_and_modules() [](#method-i-classes_and_modules) -All classes and modules in this namespace - -## classes_hash() [](#method-i-classes_hash) -Hash of classes keyed by class name - -## defined_in?(file) [](#method-i-defined_in?) -Is part of this thing was defined in `file`? - -**@return** [Boolean] - -## display(method_attr) [](#method-i-display) -:nodoc: - -## each_ancestor(&_) [](#method-i-each_ancestor) -Iterator for ancestors for duck-typing. Does nothing. See -RDoc::ClassModule#each_ancestor. - -This method exists to make it easy to work with Context subclasses that aren't -part of RDoc. - -## each_attribute() [](#method-i-each_attribute) -Iterator for attributes - -## each_classmodule(&block) [](#method-i-each_classmodule) -Iterator for classes and modules - -## each_constant() [](#method-i-each_constant) -Iterator for constants - -## each_extend() [](#method-i-each_extend) -Iterator for extension modules - -## each_include() [](#method-i-each_include) -Iterator for included modules - -## each_method() [](#method-i-each_method) -Iterator for methods - -## each_section() [](#method-i-each_section) -Iterator for each section's contents sorted by title. The `section`, the -section's `constants` and the sections `attributes` are yielded. The -`constants` and `attributes` collections are sorted. - -To retrieve methods in a section use #methods_by_type with the optional -`section` parameter. - -NOTE: Do not edit collections yielded by this method - -## find_attribute(name, singleton) [](#method-i-find_attribute) -Finds an attribute `name` with singleton value `singleton`. - -## find_attribute_named(name) [](#method-i-find_attribute_named) -Finds an attribute with `name` in this context - -## find_class_method_named(name) [](#method-i-find_class_method_named) -Finds a class method with `name` in this context - -## find_constant_named(name) [](#method-i-find_constant_named) -Finds a constant with `name` in this context - -## find_enclosing_module_named(name) [](#method-i-find_enclosing_module_named) -Find a module at a higher scope - -## find_external_alias(name, singleton) [](#method-i-find_external_alias) -Finds an external alias `name` with singleton value `singleton`. - -## find_external_alias_named(name) [](#method-i-find_external_alias_named) -Finds an external alias with `name` in this context - -## find_file_named(name) [](#method-i-find_file_named) -Finds a file with `name` in this context - -## find_instance_method_named(name) [](#method-i-find_instance_method_named) -Finds an instance method with `name` in this context - -## find_local_symbol(symbol) [](#method-i-find_local_symbol) -Finds a method, constant, attribute, external alias, module or file named -`symbol` in this context. - -## find_method(name, singleton) [](#method-i-find_method) -Finds a method named `name` with singleton value `singleton`. - -## find_method_named(name) [](#method-i-find_method_named) -Finds a instance or module method with `name` in this context - -## find_module_named(name) [](#method-i-find_module_named) -Find a module with `name` using ruby's scoping rules - -## find_symbol(symbol) [](#method-i-find_symbol) -Look up `symbol`, first as a module, then as a local symbol. - -## find_symbol_module(symbol) [](#method-i-find_symbol_module) -Look up a module named `symbol`. - -## full_name() [](#method-i-full_name) -The full name for this context. This method is overridden by subclasses. - -## fully_documented?() [](#method-i-fully_documented?) -Does this context and its methods and constants all have documentation? - -(Yes, fully documented doesn't mean everything.) - -**@return** [Boolean] - -## http_url(prefix) [](#method-i-http_url) -URL for this with a `prefix` - -## initialize() [](#method-i-initialize) -Creates an unnamed empty context with public current visibility - -**@return** [Context] a new instance of Context - -## initialize_methods_etc() [](#method-i-initialize_methods_etc) -Sets the defaults for methods and so-forth - -## instance_attributes() [](#method-i-instance_attributes) -Instance attributes - -## instance_method_list() [](#method-i-instance_method_list) -Instance methods -- TODO remove this later - -## instance_methods() [](#method-i-instance_methods) -Instance methods - -## methods_by_type(sectionnil) [](#method-i-methods_by_type) -Breaks method_list into a nested hash by type (`'class'` or `'instance'`) and -visibility (`:public`, `:protected`, `:private`). - -If `section` is provided only methods in that RDoc::Context::Section will be -returned. - -## methods_matching(methods, singletonfalse, &block) [](#method-i-methods_matching) -Yields AnyMethod and Attr entries matching the list of names in `methods`. - -## modules() [](#method-i-modules) -Array of modules in this context - -## modules_hash() [](#method-i-modules_hash) -Hash of modules keyed by module name - -## name_for_path() [](#method-i-name_for_path) -Name to use to generate the url. `#full_name` by default. - -## ongoing_visibility=(visibility) [](#method-i-ongoing_visibility=) -Changes the visibility for new methods to `visibility` - -## record_location(top_level) [](#method-i-record_location) -Record `top_level` as a file `self` is in. - -## remove_from_documentation?() [](#method-i-remove_from_documentation?) -Should we remove this context from the documentation? - -The answer is yes if: -* #received_nodoc is `true` -* #any_content is `false` (not counting includes) -* All #includes are modules (not a string), and their module has - `#remove_from_documentation? == true` -* All classes and modules have `#remove_from_documentation? == true` - -**@return** [Boolean] - -## remove_invisible(min_visibility) [](#method-i-remove_invisible) -Removes methods and attributes with a visibility less than `min_visibility`. --- TODO mark the visibility of attributes in the template (if not public?) - -## remove_invisible_in(array, min_visibility) [](#method-i-remove_invisible_in) -Only called when min_visibility == :public or :private - -## resolve_aliases(added) [](#method-i-resolve_aliases) -Tries to resolve unmatched aliases when a method or attribute has just been -added. - -## section_contents() [](#method-i-section_contents) -Returns RDoc::Context::Section objects referenced in this context for use in a -table of contents. - -## sections() [](#method-i-sections) -Sections in this context - -## sections_hash() [](#method-i-sections_hash) -:nodoc: - -## set_constant_visibility_for(names, visibility) [](#method-i-set_constant_visibility_for) -Given an array `names` of constants, set the visibility of each constant to -`visibility` - -## set_current_section(title, comment) [](#method-i-set_current_section) -Sets the current section to a section with `title`. See also #add_section - -## set_visibility_for(methods, visibility, singletonfalse) [](#method-i-set_visibility_for) -Given an array `methods` of method names, set the visibility of each to -`visibility` - -## sort_sections() [](#method-i-sort_sections) -Sorts sections alphabetically (default) or in TomDoc fashion (none, Public, -Internal, Deprecated) - -## to_s() [](#method-i-to_s) -:nodoc: - -## top_level() [](#method-i-top_level) -Return the TopLevel that owns us -- FIXME we can be 'owned' by several -TopLevel (see #record_location & #in_files) - -## upgrade_to_class(mod, class_type, enclosing) [](#method-i-upgrade_to_class) -Upgrades NormalModule `mod` in `enclosing` to a `class_type` - diff --git a/example/ruby/RDoc/Context/Section.md b/example/ruby/RDoc/Context/Section.md deleted file mode 100644 index c9e18c5..0000000 --- a/example/ruby/RDoc/Context/Section.md +++ /dev/null @@ -1,131 +0,0 @@ -# Class: RDoc::Context::Section -**Inherits:** Object - -**Includes:** RDoc::Generator::Markup, RDoc::Text - - -A section of documentation like: - - # :section: The title - # The body - -Sections can be referenced multiple times and will be collapsed into a single -section. - - -# Attributes -## comment[RW] [](#attribute-i-comment) -Section comment - -## comments[RW] [](#attribute-i-comments) -Section comments - -## parent[RW] [](#attribute-i-parent) -Context this Section lives in - -## title[RW] [](#attribute-i-title) -Section title - - -#Instance Methods -## ==(other) [](#method-i-==) -Sections are equal when they have the same #title - -## add_comment(comment) [](#method-i-add_comment) -Adds `comment` to this section - -## aref() [](#method-i-aref) -Anchor reference for linking to this section - -## aref_to(target_path) [](#method-i-aref_to) -Generates a relative URL from this object's path to `target_path` - -## as_href(from_path) [](#method-i-as_href) -Generates a relative URL from `from_path` to this object's path - -## cvs_url(url, full_path) [](#method-i-cvs_url) -Build a webcvs URL starting for the given `url` with `full_path` appended as -the destination path. If `url` contains '%s' `full_path` will be will replace -the %s using sprintf on the `url`. - -## description() [](#method-i-description) -Handy wrapper for marking up this object's comment - -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## extract_comment(comment) [](#method-i-extract_comment) -Extracts the comment for this section from the original comment block. If the -first line contains :section:, strip it and use the rest. Otherwise remove -lines up to the line containing :section:, and look for those lines again at -the end and remove them. This lets us write - - # :section: The title - # The body - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## formatter() [](#method-i-formatter) -Creates an RDoc::Markup::ToHtmlCrossref formatter - -## hash() [](#method-i-hash) -:nodoc: - -## in_files() [](#method-i-in_files) -The files comments in this section come from - -## initialize(parent, title, comment) [](#method-i-initialize) -Creates a new section with `title` and `comment` - -**@return** [Section] a new instance of Section - -## inspect() [](#method-i-inspect) -:nodoc: - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## marshal_dump() [](#method-i-marshal_dump) -Serializes this Section. The title and parsed comment are saved, but not the -section parent which must be restored manually. - -## marshal_load(array) [](#method-i-marshal_load) -De-serializes this Section. The section parent must be restored manually. - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## parse() [](#method-i-parse) -Parses `comment_location` into an RDoc::Markup::Document composed of multiple -RDoc::Markup::Documents with their file set. - -## plain_html() [](#method-i-plain_html) -The section's title, or 'Top Section' if the title is nil. - -This is used by the table of contents template so the name is silly. - -## remove_comment(comment) [](#method-i-remove_comment) -Removes a comment from this section if it is from the same file as `comment` - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/RDoc/CrossReference.md b/example/ruby/RDoc/CrossReference.md deleted file mode 100644 index 16e8cd4..0000000 --- a/example/ruby/RDoc/CrossReference.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: RDoc::CrossReference -**Inherits:** Object - - -RDoc::CrossReference is a reusable way to create cross references for names. - - -# Attributes -## seen[RW] [](#attribute-i-seen) -Hash of references that have been looked-up to their replacements - - -#Instance Methods -## initialize(context) [](#method-i-initialize) -Allows cross-references to be created based on the given `context` -(RDoc::Context). - -**@return** [CrossReference] a new instance of CrossReference - -## resolve(name, text) [](#method-i-resolve) -Returns a reference to `name`. - -If the reference is found and `name` is not documented `text` will be -returned. If `name` is escaped `name` is returned. If `name` is not found -`text` is returned. - -## resolve_method(name) [](#method-i-resolve_method) -Returns a method reference to `name`. - diff --git a/example/ruby/RDoc/ERBIO.md b/example/ruby/RDoc/ERBIO.md deleted file mode 100644 index 11d8448..0000000 --- a/example/ruby/RDoc/ERBIO.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: RDoc::ERBIO -**Inherits:** ERB - - -A subclass of ERB that writes directly to an IO. Credit to Aaron Patterson -and Masatoshi SEKI. - -To use: - - erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil - - File.open 'hello.txt', 'w' do |io| - erbio.result binding - end - -Note that binding must enclose the io you wish to output on. - - - -#Instance Methods -## initialize(str, trim_mode:nil, eoutvar:'io') [](#method-i-initialize) -Defaults `eoutvar` to 'io', otherwise is identical to ERB's initialize - -**@return** [ERBIO] a new instance of ERBIO - -## set_eoutvar(compiler, io_variable) [](#method-i-set_eoutvar) -Instructs `compiler` how to write to `io_variable` - diff --git a/example/ruby/RDoc/ERBPartial.md b/example/ruby/RDoc/ERBPartial.md deleted file mode 100644 index bcb20c8..0000000 --- a/example/ruby/RDoc/ERBPartial.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RDoc::ERBPartial -**Inherits:** ERB - - -Allows an ERB template to be rendered in the context (binding) of an existing -ERB template evaluation. - - - -#Instance Methods -## set_eoutvar(compiler, eoutvar'_erbout') [](#method-i-set_eoutvar) -Overrides `compiler` startup to set the `eoutvar` to an empty string only if -it isn't already set. - diff --git a/example/ruby/RDoc/Encoding.md b/example/ruby/RDoc/Encoding.md deleted file mode 100644 index 6f68055..0000000 --- a/example/ruby/RDoc/Encoding.md +++ /dev/null @@ -1,24 +0,0 @@ -# Module: RDoc::Encoding - - -This class is a wrapper around File IO and Encoding that helps RDoc load files -and convert them to the correct encoding. - - -# Class Methods -## change_encoding(text , encoding ) [](#method-c-change_encoding) -Changes encoding based on `encoding` without converting and returns new string -## detect_encoding(string ) [](#method-c-detect_encoding) -Detects the encoding of `string` based on the magic comment -## read_file(filename , encoding , force_transcode false) [](#method-c-read_file) -Reads the contents of `filename` and handles any encoding directives in the -file. - -The content will be converted to the `encoding`. If the file cannot be -converted a warning will be printed and nil will be returned. - -If `force_transcode` is true the document will be transcoded and any unknown -character in the target encoding will be replaced with '?' -## remove_magic_comment(string ) [](#method-c-remove_magic_comment) -Removes magic comments and shebang - diff --git a/example/ruby/RDoc/Error.md b/example/ruby/RDoc/Error.md deleted file mode 100644 index 58bb38f..0000000 --- a/example/ruby/RDoc/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: RDoc::Error -**Inherits:** RuntimeError - - -Exception thrown by any rdoc error. - - - diff --git a/example/ruby/RDoc/Extend.md b/example/ruby/RDoc/Extend.md deleted file mode 100644 index 1a64278..0000000 --- a/example/ruby/RDoc/Extend.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: RDoc::Extend -**Inherits:** RDoc::Mixin - - -A Module extension to a class with #extend - - RDoc::Extend.new 'Enumerable', 'comment ...' - - - diff --git a/example/ruby/RDoc/Generator.md b/example/ruby/RDoc/Generator.md deleted file mode 100644 index 8425fe0..0000000 --- a/example/ruby/RDoc/Generator.md +++ /dev/null @@ -1,44 +0,0 @@ -# Module: RDoc::Generator - - -RDoc uses generators to turn parsed source code in the form of an -RDoc::CodeObject tree into some form of output. RDoc comes with the HTML -generator RDoc::Generator::Darkfish and an ri data generator -RDoc::Generator::RI. - -## Registering a Generator - -Generators are registered by calling RDoc::RDoc.add_generator with the class -of the generator: - - class My::Awesome::Generator - RDoc::RDoc.add_generator self - end - -## Adding Options to `rdoc` - -Before option processing in `rdoc`, RDoc::Options will call ::setup_options on -the generator class with an RDoc::Options instance. The generator can use -RDoc::Options#option_parser to add command-line options to the `rdoc` tool. -See RDoc::Options@Custom+Options for an example and see OptionParser for -details on how to add options. - -You can extend the RDoc::Options instance with additional accessors for your -generator. - -## Generator Instantiation - -After parsing, RDoc::RDoc will instantiate a generator by calling #initialize -with an RDoc::Store instance and an RDoc::Options instance. - -The RDoc::Store instance holds documentation for parsed source code. In RDoc -3 and earlier the RDoc::TopLevel class held this data. When upgrading a -generator from RDoc 3 and earlier you should only need to replace -RDoc::TopLevel with the store instance. - -RDoc will then call #generate on the generator instance. You can use the -various methods on RDoc::Store and in the RDoc::CodeObject tree to create your -desired output format. - - - diff --git a/example/ruby/RDoc/Generator/Darkfish.md b/example/ruby/RDoc/Generator/Darkfish.md deleted file mode 100644 index dd52688..0000000 --- a/example/ruby/RDoc/Generator/Darkfish.md +++ /dev/null @@ -1,196 +0,0 @@ -# Class: RDoc::Generator::Darkfish -**Inherits:** Object - -**Includes:** ERB::Util - - -Darkfish RDoc HTML Generator - -$Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $ - -## Author/s -* Michael Granger (ged@FaerieMUD.org) - -## Contributors -* Mahlon E. Smith (mahlon@martini.nu) -* Eric Hodel (drbrain@segment7.net) - -## License - -Copyright (c) 2007, 2008, Michael Granger. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -* 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. - -* Neither the name of the author/s, nor the names of the project's - contributors may 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. - -## Attributions - -Darkfish uses the [Silk Icons](http://www.famfamfam.com/lab/icons/silk/) set -by Mark James. - - -# Attributes -## asset_rel_path[RW] [](#attribute-i-asset_rel_path) -The relative path to style sheets and javascript. By default this is set the -same as the rel_prefix. - -## base_dir[RW] [](#attribute-i-base_dir) -The path to generate files into, combined with `--op` from the options for a -full path. - -## classes[RW] [](#attribute-i-classes) -Classes and modules to be used by this generator, not necessarily displayed. -See also #modsort - -## dry_run[RW] [](#attribute-i-dry_run) -No files will be written when dry_run is true. - -## file_output[RW] [](#attribute-i-file_output) -When false the generate methods return a String instead of writing to a file. -The default is true. - -## files[RW] [](#attribute-i-files) -Files to be displayed by this generator - -## json_index[RW] [](#attribute-i-json_index) -The JSON index generator for this Darkfish generator - -## methods[RW] [](#attribute-i-methods) -Methods to be displayed by this generator - -## modsort[RW] [](#attribute-i-modsort) -Sorted list of classes and modules to be displayed by this generator - -## outputdir[RW] [](#attribute-i-outputdir) -The output directory - -## store[RW] [](#attribute-i-store) -The RDoc::Store that is the source of the generated content - -## template_dir[RW] [](#attribute-i-template_dir) -The directory where the template files live - - -#Instance Methods -## assemble_template(body_file) [](#method-i-assemble_template) -Creates a template from its components and the `body_file`. - -For backwards compatibility, if `body_file` contains " - h1 { font-size: 3em } - - -### Definition Lists - -The definition_lists extension allows definition lists using the [PHP Markdown -Extra [syntax]](PHPE), but only one label and definition are supported at this -time. This extension is enabled by default. - -Example: - -``` cat : A small furry mammal that seems to sleep a lot - -ant : A little insect that is known to enjoy picnics - -``` - -Produces: - -cat : A small furry mammal that seems to sleep a lot - -ant : A little insect that is known to enjoy picnics - -### Strike - -Example: - -``` This is ~~striked~~. ``` - -Produces: - -This is ~~striked~~. - -### Github - -The #github extension enables a partial set of [Github Flavored Markdown] -[GFM]. This extension is enabled by default. - -Supported github extensions include: - -#### Fenced code blocks - -Use ` ``` ` around a block of code instead of indenting it four spaces. - -#### Syntax highlighting - -Use ` ``` ruby ` as the start of a code fence to add syntax highlighting. -(Currently only `ruby` syntax is supported). - -### HTML - -Enables raw HTML to be included in the output. This extension is enabled by -default. - -Example: - - - ... -
- -### Notes - -The #notes extension enables footnote support. This extension is enabled by -default. - -Example: - - Here is some text[^1] including an inline footnote ^[for short footnotes] - - ... - - [^1]: With the footnote text down at the bottom - -Produces: - -Here is some [text](^1) including an inline footnote ^[for short footnotes] - -[^1]: With the footnote text down at the bottom - -## Limitations - -* Link titles are not used -* Footnotes are collapsed into a single paragraph - -## Author - -This markdown parser is a port to kpeg from [[peg-markdown]](pegmarkdown) by -John MacFarlane. - -It is used under the MIT license: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -The port to kpeg was performed by Eric Hodel and Evan Phoenix - -[dingus]: http://daringfireball.net/projects/markdown/dingus [GFM]: -https://github.github.com/gfm/ [pegmarkdown]: -https://github.com/jgm/peg-markdown [PHPE]: -https://michelf.ca/projects/php-markdown/extra/#def-list [syntax]: -http://daringfireball.net/projects/markdown/syntax -- Last updated to -jgm/peg-markdown commit 8f8fc22ef0 - - -# Class Methods -## extension(name ) [](#method-c-extension) -Creates extension methods for the `name` extension to enable and disable the -extension and to query if they are active. -## parse(markdown ) [](#method-c-parse) -Parses the `markdown` document into an RDoc::Document using the default -extensions. -## rule_info(name , rendered ) [](#method-c-rule_info) -# Attributes -## failed_rule[RW] [](#attribute-i-failed_rule) -Returns the value of attribute failed_rule. - -## failing_rule_offset[RW] [](#attribute-i-failing_rule_offset) -Returns the value of attribute failing_rule_offset. - -## pos[RW] [](#attribute-i-pos) -Returns the value of attribute pos. - -## result[RW] [](#attribute-i-result) -Returns the value of attribute result. - -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - - -#Instance Methods -## _Alphanumeric() [](#method-i-_Alphanumeric) -Alphanumeric = %literals.Alphanumeric - -## _AlphanumericAscii() [](#method-i-_AlphanumericAscii) -AlphanumericAscii = %literals.AlphanumericAscii - -## _AtxHeading() [](#method-i-_AtxHeading) -AtxHeading = AtxStart:s @Spacechar+ AtxInline+:a (@Sp /#*/ @Sp)? @Newline { -RDoc::Markup::Heading.new(s, a.join) } - -## _AtxInline() [](#method-i-_AtxInline) -AtxInline = !@Newline !(@Sp /#*/ @Sp @Newline) Inline - -## _AtxStart() [](#method-i-_AtxStart) -AtxStart = < /#{1,6}/ > { text.length } - -## _AutoLink() [](#method-i-_AutoLink) -AutoLink = (AutoLinkUrl | AutoLinkEmail) - -## _AutoLinkEmail() [](#method-i-_AutoLinkEmail) -AutoLinkEmail = "<" "mailto:"? < /[w+./!%~$-]+/i "@" (!@Newline !">" .)+ > ">" -{ "mailto:#{text}" } - -## _AutoLinkUrl() [](#method-i-_AutoLinkUrl) -AutoLinkUrl = "<" < /[A-Za-z]+/ "://" (!@Newline !">" .)+ > ">" { text } - -## _BOM() [](#method-i-_BOM) -BOM = %literals.BOM - -## _BlankLine() [](#method-i-_BlankLine) -BlankLine = @Sp @Newline { "n" } - -## _Block() [](#method-i-_Block) -Block = @BlankLine* (BlockQuote | Verbatim | CodeFence | Table | Note | -Reference | HorizontalRule | Heading | OrderedList | BulletList | -DefinitionList | HtmlBlock | StyleBlock | Para | Plain) - -## _BlockQuote() [](#method-i-_BlockQuote) -BlockQuote = BlockQuoteRaw:a { RDoc::Markup::BlockQuote.new(*a) } - -## _BlockQuoteRaw() [](#method-i-_BlockQuoteRaw) -BlockQuoteRaw = @StartList:a (">" " "? Line:l { a << l } (!">" !@BlankLine -Line:c { a << c })* (@BlankLine:n { a << n })*)+ { inner_parse a.join } - -## _Bullet() [](#method-i-_Bullet) -Bullet = !HorizontalRule @NonindentSpace /[+*-]/ @Spacechar+ - -## _BulletList() [](#method-i-_BulletList) -BulletList = &Bullet (ListTight | ListLoose):a { -RDoc::Markup::List.new(:BULLET, *a) } - -## _CharEntity() [](#method-i-_CharEntity) -CharEntity = "&" < /[A-Za-z0-9]+/ > ";" { if entity = [HTML_ENTITIES](text) -then entity.pack 'U*' else -"&#{text};" end } - -## _Code() [](#method-i-_Code) -Code = (Ticks1 @Sp < ((!"`" Nonspacechar)+ | !Ticks1 /`+/ | !(@Sp Ticks1) -(@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks1 | Ticks2 @Sp < ((!"`" -Nonspacechar)+ | !Ticks2 /`+/ | !(@Sp Ticks2) (@Spacechar | @Newline -!@BlankLine))+ > @Sp Ticks2 | Ticks3 @Sp < ((!"`" Nonspacechar)+ | !Ticks3 -/`+/ | !(@Sp Ticks3) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks3 | -Ticks4 @Sp < ((!"`" Nonspacechar)+ | !Ticks4 /`+/ | !(@Sp Ticks4) (@Spacechar -| @Newline !@BlankLine))+ > @Sp Ticks4 | Ticks5 @Sp < ((!"`" Nonspacechar)+ | -!Ticks5 /`+/ | !(@Sp Ticks5) (@Spacechar | @Newline !@BlankLine))+ > @Sp -Ticks5) { "`#{text}`" } - -## _CodeFence() [](#method-i-_CodeFence) -CodeFence = &{ github? } Ticks3 (@Sp StrChunk:format)? Spnl < ((!"`" -Nonspacechar)+ | !Ticks3 /`+/ | Spacechar | @Newline)+ > Ticks3 @Sp @Newline* -{ verbatim = RDoc::Markup::Verbatim.new text verbatim.format = -format.intern if format.instance_of?(String) verbatim - } - -## _DecEntity() [](#method-i-_DecEntity) -DecEntity = "&#" < /[0-9]+/ > ";" { [text.to_i].pack 'U' } - -## _DefinitionList() [](#method-i-_DefinitionList) -DefinitionList = &{ definition_lists? } DefinitionListItem+:list { -RDoc::Markup::List.new :NOTE, *list.flatten } - -## _DefinitionListDefinition() [](#method-i-_DefinitionListDefinition) -DefinitionListDefinition = @NonindentSpace ":" @Space Inlines:a @BlankLine+ { -paragraph a } - -## _DefinitionListItem() [](#method-i-_DefinitionListItem) -DefinitionListItem = DefinitionListLabel+:label -DefinitionListDefinition+:defns { list_items = [] -list_items << RDoc::Markup::ListItem.new(label, -defns.shift) list_items.concat defns.map { |defn| - RDoc::Markup::ListItem.new nil, defn - } unless list_items.empty? list_items - } - -## _DefinitionListLabel() [](#method-i-_DefinitionListLabel) -DefinitionListLabel = Inline:label @Sp @Newline { label } - -## _Digit() [](#method-i-_Digit) -Digit = [0-9] - -## _Doc() [](#method-i-_Doc) -Doc = BOM? Block*:a { RDoc::Markup::Document.new(*a.compact) } - -## _Emph() [](#method-i-_Emph) -Emph = (EmphStar | EmphUl) - -## _EmphStar() [](#method-i-_EmphStar) -EmphStar = "*" !@Whitespace @StartList:a (!"*" Inline:b { a << b } | -StrongStar:b { a << b })+ "*" { emphasis a.join } - -## _EmphUl() [](#method-i-_EmphUl) -EmphUl = "_" !@Whitespace @StartList:a (!"_" Inline:b { a << b } | StrongUl:b -{ a << b })+ "_" { emphasis a.join } - -## _EmptyTitle() [](#method-i-_EmptyTitle) -EmptyTitle = "" - -## _Endline() [](#method-i-_Endline) -Endline = (@LineBreak | @TerminalEndline | @NormalEndline) - -## _Entity() [](#method-i-_Entity) -Entity = (HexEntity | DecEntity | CharEntity):a { a } - -## _Enumerator() [](#method-i-_Enumerator) -Enumerator = @NonindentSpace [0-9]+ "." @Spacechar+ - -## _Eof() [](#method-i-_Eof) -Eof = !. - -## _EscapedChar() [](#method-i-_EscapedChar) -EscapedChar = "\" !@Newline < /[:\`|*_{}[\]()#+.!><-]/ > { text } - -## _ExplicitLink() [](#method-i-_ExplicitLink) -ExplicitLink = Label:l "(" @Sp Source:s Spnl Title @Sp ")" { "{#{l}}[#{s}]" } - -## _ExtendedSpecialChar() [](#method-i-_ExtendedSpecialChar) -ExtendedSpecialChar = &{ notes? } "^" - -## _Heading() [](#method-i-_Heading) -Heading = (SetextHeading | AtxHeading) - -## _HexEntity() [](#method-i-_HexEntity) -HexEntity = /&#x/i < /[0-9a-fA-F]+/ > ";" { [text.to_i(16)].pack 'U' } - -## _HorizontalRule() [](#method-i-_HorizontalRule) -HorizontalRule = @NonindentSpace ("*" @Sp "*" @Sp "*" (@Sp "*")* | "-" @Sp "-" -@Sp "-" (@Sp "-")* | "_" @Sp "_" @Sp "_" (@Sp "_")*) @Sp @Newline @BlankLine+ -{ RDoc::Markup::Rule.new 1 } - -## _HtmlAnchor() [](#method-i-_HtmlAnchor) -HtmlAnchor = HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor - -## _HtmlAttribute() [](#method-i-_HtmlAttribute) -HtmlAttribute = (AlphanumericAscii | "-")+ Spnl ("=" Spnl (Quoted | (!">" -Nonspacechar)+))? Spnl - -## _HtmlBlock() [](#method-i-_HtmlBlock) -HtmlBlock = < (HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | -HtmlUnclosed) > @BlankLine+ { if html? then -RDoc::Markup::Raw.new text end } - -## _HtmlBlockAddress() [](#method-i-_HtmlBlockAddress) -HtmlBlockAddress = HtmlBlockOpenAddress (HtmlBlockAddress | -!HtmlBlockCloseAddress .)* HtmlBlockCloseAddress - -## _HtmlBlockBlockquote() [](#method-i-_HtmlBlockBlockquote) -HtmlBlockBlockquote = HtmlBlockOpenBlockquote (HtmlBlockBlockquote | -!HtmlBlockCloseBlockquote .)* HtmlBlockCloseBlockquote - -## _HtmlBlockCenter() [](#method-i-_HtmlBlockCenter) -HtmlBlockCenter = HtmlBlockOpenCenter (HtmlBlockCenter | !HtmlBlockCloseCenter -.)* HtmlBlockCloseCenter - -## _HtmlBlockCloseAddress() [](#method-i-_HtmlBlockCloseAddress) -HtmlBlockCloseAddress = "<" Spnl "/" ("address" | "ADDRESS") Spnl ">" - -## _HtmlBlockCloseBlockquote() [](#method-i-_HtmlBlockCloseBlockquote) -HtmlBlockCloseBlockquote = "<" Spnl "/" ("blockquote" | "BLOCKQUOTE") Spnl ">" - -## _HtmlBlockCloseCenter() [](#method-i-_HtmlBlockCloseCenter) -HtmlBlockCloseCenter = "<" Spnl "/" ("center" | "CENTER") Spnl ">" - -## _HtmlBlockCloseDd() [](#method-i-_HtmlBlockCloseDd) -HtmlBlockCloseDd = "<" Spnl "/" ("dd" | "DD") Spnl ">" - -## _HtmlBlockCloseDir() [](#method-i-_HtmlBlockCloseDir) -HtmlBlockCloseDir = "<" Spnl "/" ("dir" | "DIR") Spnl ">" - -## _HtmlBlockCloseDiv() [](#method-i-_HtmlBlockCloseDiv) -HtmlBlockCloseDiv = "<" Spnl "/" ("div" | "DIV") Spnl ">" - -## _HtmlBlockCloseDl() [](#method-i-_HtmlBlockCloseDl) -HtmlBlockCloseDl = "<" Spnl "/" ("dl" | "DL") Spnl ">" - -## _HtmlBlockCloseDt() [](#method-i-_HtmlBlockCloseDt) -HtmlBlockCloseDt = "<" Spnl "/" ("dt" | "DT") Spnl ">" - -## _HtmlBlockCloseFieldset() [](#method-i-_HtmlBlockCloseFieldset) -HtmlBlockCloseFieldset = "<" Spnl "/" ("fieldset" | "FIELDSET") Spnl ">" - -## _HtmlBlockCloseForm() [](#method-i-_HtmlBlockCloseForm) -HtmlBlockCloseForm = "<" Spnl "/" ("form" | "FORM") Spnl ">" - -## _HtmlBlockCloseFrameset() [](#method-i-_HtmlBlockCloseFrameset) -HtmlBlockCloseFrameset = "<" Spnl "/" ("frameset" | "FRAMESET") Spnl ">" - -## _HtmlBlockCloseH1() [](#method-i-_HtmlBlockCloseH1) -HtmlBlockCloseH1 = "<" Spnl "/" ("h1" | "H1") Spnl ">" - -## _HtmlBlockCloseH2() [](#method-i-_HtmlBlockCloseH2) -HtmlBlockCloseH2 = "<" Spnl "/" ("h2" | "H2") Spnl ">" - -## _HtmlBlockCloseH3() [](#method-i-_HtmlBlockCloseH3) -HtmlBlockCloseH3 = "<" Spnl "/" ("h3" | "H3") Spnl ">" - -## _HtmlBlockCloseH4() [](#method-i-_HtmlBlockCloseH4) -HtmlBlockCloseH4 = "<" Spnl "/" ("h4" | "H4") Spnl ">" - -## _HtmlBlockCloseH5() [](#method-i-_HtmlBlockCloseH5) -HtmlBlockCloseH5 = "<" Spnl "/" ("h5" | "H5") Spnl ">" - -## _HtmlBlockCloseH6() [](#method-i-_HtmlBlockCloseH6) -HtmlBlockCloseH6 = "<" Spnl "/" ("h6" | "H6") Spnl ">" - -## _HtmlBlockCloseHead() [](#method-i-_HtmlBlockCloseHead) -HtmlBlockCloseHead = "<" Spnl "/" ("head" | "HEAD") Spnl ">" - -## _HtmlBlockCloseLi() [](#method-i-_HtmlBlockCloseLi) -HtmlBlockCloseLi = "<" Spnl "/" ("li" | "LI") Spnl ">" - -## _HtmlBlockCloseMenu() [](#method-i-_HtmlBlockCloseMenu) -HtmlBlockCloseMenu = "<" Spnl "/" ("menu" | "MENU") Spnl ">" - -## _HtmlBlockCloseNoframes() [](#method-i-_HtmlBlockCloseNoframes) -HtmlBlockCloseNoframes = "<" Spnl "/" ("noframes" | "NOFRAMES") Spnl ">" - -## _HtmlBlockCloseNoscript() [](#method-i-_HtmlBlockCloseNoscript) -HtmlBlockCloseNoscript = "<" Spnl "/" ("noscript" | "NOSCRIPT") Spnl ">" - -## _HtmlBlockCloseOl() [](#method-i-_HtmlBlockCloseOl) -HtmlBlockCloseOl = "<" Spnl "/" ("ol" | "OL") Spnl ">" - -## _HtmlBlockCloseP() [](#method-i-_HtmlBlockCloseP) -HtmlBlockCloseP = "<" Spnl "/" ("p" | "P") Spnl ">" - -## _HtmlBlockClosePre() [](#method-i-_HtmlBlockClosePre) -HtmlBlockClosePre = "<" Spnl "/" ("pre" | "PRE") Spnl ">" - -## _HtmlBlockCloseScript() [](#method-i-_HtmlBlockCloseScript) -HtmlBlockCloseScript = "<" Spnl "/" ("script" | "SCRIPT") Spnl ">" - -## _HtmlBlockCloseTable() [](#method-i-_HtmlBlockCloseTable) -HtmlBlockCloseTable = "<" Spnl "/" ("table" | "TABLE") Spnl ">" - -## _HtmlBlockCloseTbody() [](#method-i-_HtmlBlockCloseTbody) -HtmlBlockCloseTbody = "<" Spnl "/" ("tbody" | "TBODY") Spnl ">" - -## _HtmlBlockCloseTd() [](#method-i-_HtmlBlockCloseTd) -HtmlBlockCloseTd = "<" Spnl "/" ("td" | "TD") Spnl ">" - -## _HtmlBlockCloseTfoot() [](#method-i-_HtmlBlockCloseTfoot) -HtmlBlockCloseTfoot = "<" Spnl "/" ("tfoot" | "TFOOT") Spnl ">" - -## _HtmlBlockCloseTh() [](#method-i-_HtmlBlockCloseTh) -HtmlBlockCloseTh = "<" Spnl "/" ("th" | "TH") Spnl ">" - -## _HtmlBlockCloseThead() [](#method-i-_HtmlBlockCloseThead) -HtmlBlockCloseThead = "<" Spnl "/" ("thead" | "THEAD") Spnl ">" - -## _HtmlBlockCloseTr() [](#method-i-_HtmlBlockCloseTr) -HtmlBlockCloseTr = "<" Spnl "/" ("tr" | "TR") Spnl ">" - -## _HtmlBlockCloseUl() [](#method-i-_HtmlBlockCloseUl) -HtmlBlockCloseUl = "<" Spnl "/" ("ul" | "UL") Spnl ">" - -## _HtmlBlockDd() [](#method-i-_HtmlBlockDd) -HtmlBlockDd = HtmlBlockOpenDd (HtmlBlockDd | !HtmlBlockCloseDd .)* -HtmlBlockCloseDd - -## _HtmlBlockDir() [](#method-i-_HtmlBlockDir) -HtmlBlockDir = HtmlBlockOpenDir (HtmlBlockDir | !HtmlBlockCloseDir .)* -HtmlBlockCloseDir - -## _HtmlBlockDiv() [](#method-i-_HtmlBlockDiv) -HtmlBlockDiv = HtmlBlockOpenDiv (HtmlBlockDiv | !HtmlBlockCloseDiv .)* -HtmlBlockCloseDiv - -## _HtmlBlockDl() [](#method-i-_HtmlBlockDl) -HtmlBlockDl = HtmlBlockOpenDl (HtmlBlockDl | !HtmlBlockCloseDl .)* -HtmlBlockCloseDl - -## _HtmlBlockDt() [](#method-i-_HtmlBlockDt) -HtmlBlockDt = HtmlBlockOpenDt (HtmlBlockDt | !HtmlBlockCloseDt .)* -HtmlBlockCloseDt - -## _HtmlBlockFieldset() [](#method-i-_HtmlBlockFieldset) -HtmlBlockFieldset = HtmlBlockOpenFieldset (HtmlBlockFieldset | -!HtmlBlockCloseFieldset .)* HtmlBlockCloseFieldset - -## _HtmlBlockForm() [](#method-i-_HtmlBlockForm) -HtmlBlockForm = HtmlBlockOpenForm (HtmlBlockForm | !HtmlBlockCloseForm .)* -HtmlBlockCloseForm - -## _HtmlBlockFrameset() [](#method-i-_HtmlBlockFrameset) -HtmlBlockFrameset = HtmlBlockOpenFrameset (HtmlBlockFrameset | -!HtmlBlockCloseFrameset .)* HtmlBlockCloseFrameset - -## _HtmlBlockH1() [](#method-i-_HtmlBlockH1) -HtmlBlockH1 = HtmlBlockOpenH1 (HtmlBlockH1 | !HtmlBlockCloseH1 .)* -HtmlBlockCloseH1 - -## _HtmlBlockH2() [](#method-i-_HtmlBlockH2) -HtmlBlockH2 = HtmlBlockOpenH2 (HtmlBlockH2 | !HtmlBlockCloseH2 .)* -HtmlBlockCloseH2 - -## _HtmlBlockH3() [](#method-i-_HtmlBlockH3) -HtmlBlockH3 = HtmlBlockOpenH3 (HtmlBlockH3 | !HtmlBlockCloseH3 .)* -HtmlBlockCloseH3 - -## _HtmlBlockH4() [](#method-i-_HtmlBlockH4) -HtmlBlockH4 = HtmlBlockOpenH4 (HtmlBlockH4 | !HtmlBlockCloseH4 .)* -HtmlBlockCloseH4 - -## _HtmlBlockH5() [](#method-i-_HtmlBlockH5) -HtmlBlockH5 = HtmlBlockOpenH5 (HtmlBlockH5 | !HtmlBlockCloseH5 .)* -HtmlBlockCloseH5 - -## _HtmlBlockH6() [](#method-i-_HtmlBlockH6) -HtmlBlockH6 = HtmlBlockOpenH6 (HtmlBlockH6 | !HtmlBlockCloseH6 .)* -HtmlBlockCloseH6 - -## _HtmlBlockHead() [](#method-i-_HtmlBlockHead) -HtmlBlockHead = HtmlBlockOpenHead (!HtmlBlockCloseHead .)* HtmlBlockCloseHead - -## _HtmlBlockInTags() [](#method-i-_HtmlBlockInTags) -HtmlBlockInTags = (HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | -HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | -HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | -HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | -HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | -HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | -HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | -HtmlBlockTr | HtmlBlockScript | HtmlBlockHead) - -## _HtmlBlockLi() [](#method-i-_HtmlBlockLi) -HtmlBlockLi = HtmlBlockOpenLi (HtmlBlockLi | !HtmlBlockCloseLi .)* -HtmlBlockCloseLi - -## _HtmlBlockMenu() [](#method-i-_HtmlBlockMenu) -HtmlBlockMenu = HtmlBlockOpenMenu (HtmlBlockMenu | !HtmlBlockCloseMenu .)* -HtmlBlockCloseMenu - -## _HtmlBlockNoframes() [](#method-i-_HtmlBlockNoframes) -HtmlBlockNoframes = HtmlBlockOpenNoframes (HtmlBlockNoframes | -!HtmlBlockCloseNoframes .)* HtmlBlockCloseNoframes - -## _HtmlBlockNoscript() [](#method-i-_HtmlBlockNoscript) -HtmlBlockNoscript = HtmlBlockOpenNoscript (HtmlBlockNoscript | -!HtmlBlockCloseNoscript .)* HtmlBlockCloseNoscript - -## _HtmlBlockOl() [](#method-i-_HtmlBlockOl) -HtmlBlockOl = HtmlBlockOpenOl (HtmlBlockOl | !HtmlBlockCloseOl .)* -HtmlBlockCloseOl - -## _HtmlBlockOpenAddress() [](#method-i-_HtmlBlockOpenAddress) -HtmlBlockOpenAddress = "<" Spnl ("address" | "ADDRESS") Spnl HtmlAttribute* -">" - -## _HtmlBlockOpenBlockquote() [](#method-i-_HtmlBlockOpenBlockquote) -HtmlBlockOpenBlockquote = "<" Spnl ("blockquote" | "BLOCKQUOTE") Spnl -HtmlAttribute* ">" - -## _HtmlBlockOpenCenter() [](#method-i-_HtmlBlockOpenCenter) -HtmlBlockOpenCenter = "<" Spnl ("center" | "CENTER") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenDd() [](#method-i-_HtmlBlockOpenDd) -HtmlBlockOpenDd = "<" Spnl ("dd" | "DD") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenDir() [](#method-i-_HtmlBlockOpenDir) -HtmlBlockOpenDir = "<" Spnl ("dir" | "DIR") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenDiv() [](#method-i-_HtmlBlockOpenDiv) -HtmlBlockOpenDiv = "<" Spnl ("div" | "DIV") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenDl() [](#method-i-_HtmlBlockOpenDl) -HtmlBlockOpenDl = "<" Spnl ("dl" | "DL") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenDt() [](#method-i-_HtmlBlockOpenDt) -HtmlBlockOpenDt = "<" Spnl ("dt" | "DT") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenFieldset() [](#method-i-_HtmlBlockOpenFieldset) -HtmlBlockOpenFieldset = "<" Spnl ("fieldset" | "FIELDSET") Spnl HtmlAttribute* -">" - -## _HtmlBlockOpenForm() [](#method-i-_HtmlBlockOpenForm) -HtmlBlockOpenForm = "<" Spnl ("form" | "FORM") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenFrameset() [](#method-i-_HtmlBlockOpenFrameset) -HtmlBlockOpenFrameset = "<" Spnl ("frameset" | "FRAMESET") Spnl HtmlAttribute* -">" - -## _HtmlBlockOpenH1() [](#method-i-_HtmlBlockOpenH1) -HtmlBlockOpenH1 = "<" Spnl ("h1" | "H1") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenH2() [](#method-i-_HtmlBlockOpenH2) -HtmlBlockOpenH2 = "<" Spnl ("h2" | "H2") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenH3() [](#method-i-_HtmlBlockOpenH3) -HtmlBlockOpenH3 = "<" Spnl ("h3" | "H3") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenH4() [](#method-i-_HtmlBlockOpenH4) -HtmlBlockOpenH4 = "<" Spnl ("h4" | "H4") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenH5() [](#method-i-_HtmlBlockOpenH5) -HtmlBlockOpenH5 = "<" Spnl ("h5" | "H5") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenH6() [](#method-i-_HtmlBlockOpenH6) -HtmlBlockOpenH6 = "<" Spnl ("h6" | "H6") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenHead() [](#method-i-_HtmlBlockOpenHead) -HtmlBlockOpenHead = "<" Spnl ("head" | "HEAD") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenLi() [](#method-i-_HtmlBlockOpenLi) -HtmlBlockOpenLi = "<" Spnl ("li" | "LI") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenMenu() [](#method-i-_HtmlBlockOpenMenu) -HtmlBlockOpenMenu = "<" Spnl ("menu" | "MENU") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenNoframes() [](#method-i-_HtmlBlockOpenNoframes) -HtmlBlockOpenNoframes = "<" Spnl ("noframes" | "NOFRAMES") Spnl HtmlAttribute* -">" - -## _HtmlBlockOpenNoscript() [](#method-i-_HtmlBlockOpenNoscript) -HtmlBlockOpenNoscript = "<" Spnl ("noscript" | "NOSCRIPT") Spnl HtmlAttribute* -">" - -## _HtmlBlockOpenOl() [](#method-i-_HtmlBlockOpenOl) -HtmlBlockOpenOl = "<" Spnl ("ol" | "OL") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenP() [](#method-i-_HtmlBlockOpenP) -HtmlBlockOpenP = "<" Spnl ("p" | "P") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenPre() [](#method-i-_HtmlBlockOpenPre) -HtmlBlockOpenPre = "<" Spnl ("pre" | "PRE") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenScript() [](#method-i-_HtmlBlockOpenScript) -HtmlBlockOpenScript = "<" Spnl ("script" | "SCRIPT") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenTable() [](#method-i-_HtmlBlockOpenTable) -HtmlBlockOpenTable = "<" Spnl ("table" | "TABLE") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenTbody() [](#method-i-_HtmlBlockOpenTbody) -HtmlBlockOpenTbody = "<" Spnl ("tbody" | "TBODY") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenTd() [](#method-i-_HtmlBlockOpenTd) -HtmlBlockOpenTd = "<" Spnl ("td" | "TD") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenTfoot() [](#method-i-_HtmlBlockOpenTfoot) -HtmlBlockOpenTfoot = "<" Spnl ("tfoot" | "TFOOT") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenTh() [](#method-i-_HtmlBlockOpenTh) -HtmlBlockOpenTh = "<" Spnl ("th" | "TH") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenThead() [](#method-i-_HtmlBlockOpenThead) -HtmlBlockOpenThead = "<" Spnl ("thead" | "THEAD") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenTr() [](#method-i-_HtmlBlockOpenTr) -HtmlBlockOpenTr = "<" Spnl ("tr" | "TR") Spnl HtmlAttribute* ">" - -## _HtmlBlockOpenUl() [](#method-i-_HtmlBlockOpenUl) -HtmlBlockOpenUl = "<" Spnl ("ul" | "UL") Spnl HtmlAttribute* ">" - -## _HtmlBlockP() [](#method-i-_HtmlBlockP) -HtmlBlockP = HtmlBlockOpenP (HtmlBlockP | !HtmlBlockCloseP .)* HtmlBlockCloseP - -## _HtmlBlockPre() [](#method-i-_HtmlBlockPre) -HtmlBlockPre = HtmlBlockOpenPre (HtmlBlockPre | !HtmlBlockClosePre .)* -HtmlBlockClosePre - -## _HtmlBlockScript() [](#method-i-_HtmlBlockScript) -HtmlBlockScript = HtmlBlockOpenScript (!HtmlBlockCloseScript .)* -HtmlBlockCloseScript - -## _HtmlBlockSelfClosing() [](#method-i-_HtmlBlockSelfClosing) -HtmlBlockSelfClosing = "<" Spnl HtmlBlockType Spnl HtmlAttribute* "/" Spnl ">" - -## _HtmlBlockTable() [](#method-i-_HtmlBlockTable) -HtmlBlockTable = HtmlBlockOpenTable (HtmlBlockTable | !HtmlBlockCloseTable .)* -HtmlBlockCloseTable - -## _HtmlBlockTbody() [](#method-i-_HtmlBlockTbody) -HtmlBlockTbody = HtmlBlockOpenTbody (HtmlBlockTbody | !HtmlBlockCloseTbody .)* -HtmlBlockCloseTbody - -## _HtmlBlockTd() [](#method-i-_HtmlBlockTd) -HtmlBlockTd = HtmlBlockOpenTd (HtmlBlockTd | !HtmlBlockCloseTd .)* -HtmlBlockCloseTd - -## _HtmlBlockTfoot() [](#method-i-_HtmlBlockTfoot) -HtmlBlockTfoot = HtmlBlockOpenTfoot (HtmlBlockTfoot | !HtmlBlockCloseTfoot .)* -HtmlBlockCloseTfoot - -## _HtmlBlockTh() [](#method-i-_HtmlBlockTh) -HtmlBlockTh = HtmlBlockOpenTh (HtmlBlockTh | !HtmlBlockCloseTh .)* -HtmlBlockCloseTh - -## _HtmlBlockThead() [](#method-i-_HtmlBlockThead) -HtmlBlockThead = HtmlBlockOpenThead (HtmlBlockThead | !HtmlBlockCloseThead .)* -HtmlBlockCloseThead - -## _HtmlBlockTr() [](#method-i-_HtmlBlockTr) -HtmlBlockTr = HtmlBlockOpenTr (HtmlBlockTr | !HtmlBlockCloseTr .)* -HtmlBlockCloseTr - -## _HtmlBlockType() [](#method-i-_HtmlBlockType) -HtmlBlockType = ("ADDRESS" | "BLOCKQUOTE" | "CENTER" | "DD" | "DIR" | "DIV" | -"DL" | "DT" | "FIELDSET" | "FORM" | "FRAMESET" | "H1" | "H2" | "H3" | "H4" | -"H5" | "H6" | "HR" | "ISINDEX" | "LI" | "MENU" | "NOFRAMES" | "NOSCRIPT" | -"OL" | "P" | "PRE" | "SCRIPT" | "TABLE" | "TBODY" | "TD" | "TFOOT" | "TH" | -"THEAD" | "TR" | "UL" | "address" | "blockquote" | "center" | "dd" | "dir" | -"div" | "dl" | "dt" | "fieldset" | "form" | "frameset" | "h1" | "h2" | "h3" | -"h4" | "h5" | "h6" | "hr" | "isindex" | "li" | "menu" | "noframes" | -"noscript" | "ol" | "p" | "pre" | "script" | "table" | "tbody" | "td" | -"tfoot" | "th" | "thead" | "tr" | "ul") - -## _HtmlBlockUl() [](#method-i-_HtmlBlockUl) -HtmlBlockUl = HtmlBlockOpenUl (HtmlBlockUl | !HtmlBlockCloseUl .)* -HtmlBlockCloseUl - -## _HtmlCloseAnchor() [](#method-i-_HtmlCloseAnchor) -HtmlCloseAnchor = "<" Spnl "/" ("a" | "A") Spnl ">" - -## _HtmlComment() [](#method-i-_HtmlComment) -HtmlComment = "" .)* "-->" - -## _HtmlOpenAnchor() [](#method-i-_HtmlOpenAnchor) -HtmlOpenAnchor = "<" Spnl ("a" | "A") Spnl HtmlAttribute* ">" - -## _HtmlTag() [](#method-i-_HtmlTag) -HtmlTag = "<" Spnl "/"? AlphanumericAscii+ Spnl HtmlAttribute* "/"? Spnl ">" - -## _HtmlUnclosed() [](#method-i-_HtmlUnclosed) -HtmlUnclosed = "<" Spnl HtmlUnclosedType Spnl HtmlAttribute* Spnl ">" - -## _HtmlUnclosedType() [](#method-i-_HtmlUnclosedType) -HtmlUnclosedType = ("HR" | "hr") - -## _Image() [](#method-i-_Image) -Image = "!" (ExplicitLink | ReferenceLink):a { "![](#{a[/\[(.*)\])/, 1]}" } - -## _InStyleTags() [](#method-i-_InStyleTags) -InStyleTags = StyleOpen (!StyleClose .)* StyleClose - -## _Indent() [](#method-i-_Indent) -Indent = /t| / - -## _IndentedLine() [](#method-i-_IndentedLine) -IndentedLine = Indent Line - -## _Inline() [](#method-i-_Inline) -Inline = (Str | @Endline | UlOrStarLine | @Space | Strong | Emph | Strike | -Image | Link | NoteReference | InlineNote | Code | RawHtml | Entity | -EscapedChar | Symbol) - -## _InlineNote() [](#method-i-_InlineNote) -InlineNote = &{ notes? } "^[" @StartList:a (!"]" Inline:l { a << l })+ "]" { -ref = [:inline, @note_order.length] @[footnotes](ref) = -paragraph a note_for ref } - -## _Inlines() [](#method-i-_Inlines) -Inlines = (!@Endline Inline:i { i } | @Endline:c !(&{ github? } Ticks3 -/[^`n]*$/) &Inline { c })+:chunks @Endline? { chunks } - -## _Label() [](#method-i-_Label) -Label = "[" (!"^" &{ notes? } | &. &{ !notes? }) @StartList:a (!"]" Inline:l { -a << l })* "]" { a.join.gsub(/s+/, ' ') } - -## _Line() [](#method-i-_Line) -Line = @RawLine:a { a } - -## _LineBreak() [](#method-i-_LineBreak) -LineBreak = " " @NormalEndline { RDoc::Markup::HardBreak.new } - -## _Link() [](#method-i-_Link) -Link = (ExplicitLink | ReferenceLink | AutoLink) - -## _ListBlock() [](#method-i-_ListBlock) -ListBlock = !@BlankLine Line:a ListBlockLine*:c { [a, *c] } - -## _ListBlockLine() [](#method-i-_ListBlockLine) -ListBlockLine = !@BlankLine !(Indent? (Bullet | Enumerator)) !HorizontalRule -OptionallyIndentedLine - -## _ListContinuationBlock() [](#method-i-_ListContinuationBlock) -ListContinuationBlock = @StartList:a @BlankLine* { a << "n" } (Indent -ListBlock:b { a.concat b })+ { a } - -## _ListItem() [](#method-i-_ListItem) -ListItem = (Bullet | Enumerator) @StartList:a ListBlock:b { a << b } -(ListContinuationBlock:c { a.push(*c) })* { list_item_from a } - -## _ListItemTight() [](#method-i-_ListItemTight) -ListItemTight = (Bullet | Enumerator) ListBlock:a (!@BlankLine -ListContinuationBlock:b { a.push(*b) })* !ListContinuationBlock { -list_item_from a } - -## _ListLoose() [](#method-i-_ListLoose) -ListLoose = @StartList:a (ListItem:b @BlankLine* { a << b })+ { a } - -## _ListTight() [](#method-i-_ListTight) -ListTight = ListItemTight+:a @BlankLine* !(Bullet | Enumerator) { a } - -## _Newline() [](#method-i-_Newline) -Newline = %literals.Newline - -## _NonblankIndentedLine() [](#method-i-_NonblankIndentedLine) -NonblankIndentedLine = !@BlankLine IndentedLine - -## _NonindentSpace() [](#method-i-_NonindentSpace) -NonindentSpace = / {0,3}/ - -## _Nonspacechar() [](#method-i-_Nonspacechar) -Nonspacechar = !@Spacechar !@Newline . - -## _NormalChar() [](#method-i-_NormalChar) -NormalChar = !(@SpecialChar | @Spacechar | @Newline) . - -## _NormalEndline() [](#method-i-_NormalEndline) -NormalEndline = @Sp @Newline !@BlankLine !">" !AtxStart !(Line /={1,}|-{1,}/ -@Newline) { "n" } - -## _Note() [](#method-i-_Note) -Note = &{ notes? } @NonindentSpace RawNoteReference:ref ":" @Sp @StartList:a -RawNoteBlock:i { a.concat i } (&Indent RawNoteBlock:i { a.concat i })* { -@[footnotes](ref) = paragraph a nil } - -## _NoteReference() [](#method-i-_NoteReference) -NoteReference = &{ notes? } RawNoteReference:ref { note_for ref } - -## _Notes() [](#method-i-_Notes) -Notes = (Note | SkipBlock)* - -## _OptionallyIndentedLine() [](#method-i-_OptionallyIndentedLine) -OptionallyIndentedLine = Indent? Line - -## _OrderedList() [](#method-i-_OrderedList) -OrderedList = &Enumerator (ListTight | ListLoose):a { -RDoc::Markup::List.new(:NUMBER, *a) } - -## _Para() [](#method-i-_Para) -Para = @NonindentSpace Inlines:a @BlankLine+ { paragraph a } - -## _Plain() [](#method-i-_Plain) -Plain = Inlines:a { paragraph a } - -## _Quoted() [](#method-i-_Quoted) -Quoted = (""" (!""" .)* """ | "'" (!"'" .)* "'") - -## _RawHtml() [](#method-i-_RawHtml) -RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) > { if html? then text -else '' end } - -## _RawLine() [](#method-i-_RawLine) -RawLine = (< /[^r\n]*/ @Newline > | < .+ > @Eof) { text } - -## _RawNoteBlock() [](#method-i-_RawNoteBlock) -RawNoteBlock = @StartList:a (!@BlankLine !RawNoteReference -OptionallyIndentedLine:l { a << l })+ < @BlankLine* > { a << text } { a } - -## _RawNoteReference() [](#method-i-_RawNoteReference) -RawNoteReference = "[^" < (!@Newline !"]" .)+ > "]" { text } - -## _RefSrc() [](#method-i-_RefSrc) -RefSrc = < Nonspacechar+ > { text } - -## _RefTitle() [](#method-i-_RefTitle) -RefTitle = (RefTitleSingle | RefTitleDouble | RefTitleParens | EmptyTitle) - -## _RefTitleDouble() [](#method-i-_RefTitleDouble) -RefTitleDouble = Spnl """ < (!(""" @Sp @Newline | @Newline) .)* > """ { text } - -## _RefTitleParens() [](#method-i-_RefTitleParens) -RefTitleParens = Spnl "(" < (!(")" @Sp @Newline | @Newline) .)* > ")" { text } - -## _RefTitleSingle() [](#method-i-_RefTitleSingle) -RefTitleSingle = Spnl "'" < (!("'" @Sp @Newline | @Newline) .)* > "'" { text } - -## _Reference() [](#method-i-_Reference) -Reference = @NonindentSpace !"[]" Label:label ":" Spnl RefSrc:link RefTitle -@BlankLine+ { # TODO use title reference label, link - nil } - -## _ReferenceLink() [](#method-i-_ReferenceLink) -ReferenceLink = (ReferenceLinkDouble | ReferenceLinkSingle) - -## _ReferenceLinkDouble() [](#method-i-_ReferenceLinkDouble) -ReferenceLinkDouble = Label:content < Spnl > !"[]" Label:label { link_to -content, label, text } - -## _ReferenceLinkSingle() [](#method-i-_ReferenceLinkSingle) -ReferenceLinkSingle = Label:content < (Spnl "[]")? > { link_to content, -content, text } - -## _References() [](#method-i-_References) -References = (Reference | SkipBlock)* - -## _SetextBottom1() [](#method-i-_SetextBottom1) -SetextBottom1 = /={1,}/ @Newline - -## _SetextBottom2() [](#method-i-_SetextBottom2) -SetextBottom2 = /-{1,}/ @Newline - -## _SetextHeading() [](#method-i-_SetextHeading) -SetextHeading = (SetextHeading1 | SetextHeading2) - -## _SetextHeading1() [](#method-i-_SetextHeading1) -SetextHeading1 = &(@RawLine SetextBottom1) @StartList:a (!@Endline Inline:b { -a << b })+ @Sp @Newline SetextBottom1 { RDoc::Markup::Heading.new(1, a.join) } - -## _SetextHeading2() [](#method-i-_SetextHeading2) -SetextHeading2 = &(@RawLine SetextBottom2) @StartList:a (!@Endline Inline:b { -a << b })+ @Sp @Newline SetextBottom2 { RDoc::Markup::Heading.new(2, a.join) } - -## _SkipBlock() [](#method-i-_SkipBlock) -SkipBlock = (HtmlBlock | (!"#" !SetextBottom1 !SetextBottom2 !@BlankLine -@RawLine)+ @BlankLine* | @BlankLine+ | @RawLine) - -## _Source() [](#method-i-_Source) -Source = ("<" < SourceContents > ">" | < SourceContents >) { text } - -## _SourceContents() [](#method-i-_SourceContents) -SourceContents = ((!"(" !")" !">" Nonspacechar)+ | "(" SourceContents ")")* - -## _Sp() [](#method-i-_Sp) -Sp = @Spacechar* - -## _Space() [](#method-i-_Space) -Space = @Spacechar+ { " " } - -## _Spacechar() [](#method-i-_Spacechar) -Spacechar = %literals.Spacechar - -## _SpecialChar() [](#method-i-_SpecialChar) -SpecialChar = (/[~*[_`&\](\)() { text } | < @Spacechar /*+/ &@Spacechar > { text }) - -## _StartList() [](#method-i-_StartList) -StartList = &. { [] } - -## _Str() [](#method-i-_Str) -Str = @StartList:a < @NormalChar+ > { a = text } (StrChunk:c { a << c })* { a -} - -## _StrChunk() [](#method-i-_StrChunk) -StrChunk = < (@NormalChar | /_+/ &Alphanumeric)+ > { text } - -## _Strike() [](#method-i-_Strike) -Strike = &{ strike? } "~~" !@Whitespace @StartList:a (!"~~" Inline:b { a << b -})+ "~~" { strike a.join } - -## _Strong() [](#method-i-_Strong) -Strong = (StrongStar | StrongUl) - -## _StrongStar() [](#method-i-_StrongStar) -StrongStar = "**" !@Whitespace @StartList:a (!"**" Inline:b { a << b })+ "**" -{ strong a.join } - -## _StrongUl() [](#method-i-_StrongUl) -StrongUl = "__" !@Whitespace @StartList:a (!"__" Inline:b { a << b })+ "__" { -strong a.join } - -## _StyleBlock() [](#method-i-_StyleBlock) -StyleBlock = < InStyleTags > @BlankLine* { if css? then -RDoc::Markup::Raw.new text end } - -## _StyleClose() [](#method-i-_StyleClose) -StyleClose = "<" Spnl "/" ("style" | "STYLE") Spnl ">" - -## _StyleOpen() [](#method-i-_StyleOpen) -StyleOpen = "<" Spnl ("style" | "STYLE") Spnl HtmlAttribute* ">" - -## _Symbol() [](#method-i-_Symbol) -Symbol = < @SpecialChar > { text } - -## _Table() [](#method-i-_Table) -Table = &{ github? } TableHead:header TableLine:line TableRow+:body { table = -RDoc::Markup::Table.new(header, line, body) } - -## _TableAlign() [](#method-i-_TableAlign) -TableAlign = < /:?-+:?/ > @Sp { text.start_with?(":") ? - (text.end_with?(":") ? :center : :left) : -(text.end_with?(":") ? :right : nil) } - -## _TableAlign2() [](#method-i-_TableAlign2) -TableAlign2 = "|" @Sp TableAlign - -## _TableHead() [](#method-i-_TableHead) -TableHead = TableItem2+:items "|"? @Newline { items } - -## _TableItem() [](#method-i-_TableItem) -TableItem = < /(?:\.|[^|n])+/ > { text.strip.gsub(/\(.)/, '1') } - -## _TableItem2() [](#method-i-_TableItem2) -TableItem2 = "|" TableItem - -## _TableLine() [](#method-i-_TableLine) -TableLine = ((TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] }):line -| TableAlign2+:line) "|"? @Newline { line } - -## _TableRow() [](#method-i-_TableRow) -TableRow = ((TableItem:item1 TableItem2*:items { [item1, *items] }):row | -TableItem2+:row) "|"? @Newline { row } - -## _TerminalEndline() [](#method-i-_TerminalEndline) -TerminalEndline = @Sp @Newline @Eof - -## _Ticks1() [](#method-i-_Ticks1) -Ticks1 = "`" !"`" - -## _Ticks2() [](#method-i-_Ticks2) -Ticks2 = "``" !"`" - -## _Ticks3() [](#method-i-_Ticks3) -Ticks3 = "```" !"`" - -## _Ticks4() [](#method-i-_Ticks4) -Ticks4 = "````" !"`" - -## _Ticks5() [](#method-i-_Ticks5) -Ticks5 = "`````" !"`" - -## _Title() [](#method-i-_Title) -Title = (TitleSingle | TitleDouble | ""):a { a } - -## _TitleDouble() [](#method-i-_TitleDouble) -TitleDouble = """ (!(""" @Sp (")" | @Newline)) .)* """ - -## _TitleSingle() [](#method-i-_TitleSingle) -TitleSingle = "'" (!("'" @Sp (")" | @Newline)) .)* "'" - -## _UlLine() [](#method-i-_UlLine) -UlLine = (< /_{4,}/ > { text } | < @Spacechar /_+/ &@Spacechar > { text }) - -## _UlOrStarLine() [](#method-i-_UlOrStarLine) -UlOrStarLine = (UlLine | StarLine):a { a } - -## _Verbatim() [](#method-i-_Verbatim) -Verbatim = VerbatimChunk+:a { RDoc::Markup::Verbatim.new(*a.flatten) } - -## _VerbatimChunk() [](#method-i-_VerbatimChunk) -VerbatimChunk = @BlankLine*:a NonblankIndentedLine+:b { a.concat b } - -## _Whitespace() [](#method-i-_Whitespace) -Whitespace = (@Spacechar | @Newline) - -## _root() [](#method-i-_root) -root = Doc - -## apply(rule) [](#method-i-apply) - -## apply_with_args(rule, *args) [](#method-i-apply_with_args) - -## break_on_newline() [](#method-i-break_on_newline) -Converts all newlines into hard breaks - -## css() [](#method-i-css) -Allow style blocks - -## current_character(targetpos) [](#method-i-current_character) - -## current_column(targetpos) [](#method-i-current_column) - -## current_line(targetpos) [](#method-i-current_line) - -## current_pos_info(targetpos) [](#method-i-current_pos_info) - -## definition_lists() [](#method-i-definition_lists) -Allow PHP Markdown Extras style definition lists - -## emphasis(text) [](#method-i-emphasis) -Wraps `text` in emphasis for rdoc inline formatting - -## extension(name, enable) [](#method-i-extension) -:category: Extensions - -Enables or disables the extension with `name` - -## extension?(name) [](#method-i-extension?) -:category: Extensions - -Is the extension `name` enabled? - -**@return** [Boolean] - -## external_invoke(other, rule, *args) [](#method-i-external_invoke) - -## failure_caret() [](#method-i-failure_caret) - -## failure_character() [](#method-i-failure_character) - -## failure_info() [](#method-i-failure_info) - -## failure_oneline() [](#method-i-failure_oneline) - -## get_byte() [](#method-i-get_byte) - -## get_line(no) [](#method-i-get_line) - -## get_text(start) [](#method-i-get_text) - -## github() [](#method-i-github) -Allow Github Flavored Markdown - -## grow_lr(rule, args, start_pos, m) [](#method-i-grow_lr) - -## html() [](#method-i-html) -Allow HTML - -## initialize(extensionsDEFAULT_EXTENSIONS, debugfalse) [](#method-i-initialize) -Creates a new markdown parser that enables the given `extensions`. - -**@return** [Markdown] a new instance of Markdown - -## inner_parse(text) [](#method-i-inner_parse) -Parses `text` in a clone of this parser. This is used for handling nested -lists the same way as markdown_parser. - -## lines() [](#method-i-lines) - -## link_to(content, labelcontent, textnil) [](#method-i-link_to) -Finds a link reference for `label` and creates a new link to it with `content` -as the link text. If `label` was not encountered in the reference-gathering -parser pass the label and content are reconstructed with the linking `text` -(usually whitespace). - -**@raise** [ParseError] - -## list_item_from(unparsed) [](#method-i-list_item_from) -Creates an RDoc::Markup::ListItem by parsing the `unparsed` content from the -first parsing pass. - -## match_string(str) [](#method-i-match_string) - -## note(label) [](#method-i-note) -Stores `label` as a note and fills in previously unknown note references. - -## note_for(ref) [](#method-i-note_for) -Creates a new link for the footnote `reference` and adds the reference to the -note order list for proper display at the end of the document. - -## notes() [](#method-i-notes) -Enables the notes extension - -## orig_initialize() [](#method-i-orig_initialize) -This is distinct from setup_parser so that a standalone parser can redefine -#initialize and still have access to the proper parser setup code. TODO remove -when kpeg 0.10 is released - -**@return** [Markdown] a new instance of Markdown - -## paragraph(parts) [](#method-i-paragraph) -Creates an RDoc::Markup::Paragraph from `parts` and including -extension-specific behavior - -## parse(markdown) [](#method-i-parse) -Parses `markdown` into an RDoc::Document - -## peg_parse() [](#method-i-peg_parse) -The internal kpeg parse method - -## position_line_offsets() [](#method-i-position_line_offsets) - -## raise_error() [](#method-i-raise_error) - -**@raise** [ParseError] - -## reference(label, link) [](#method-i-reference) -Stores `label` as a reference to `link` and fills in previously unknown link -references. - -## scan(reg) [](#method-i-scan) - -## set_failed_rule(name) [](#method-i-set_failed_rule) - -## set_string(string, pos) [](#method-i-set_string) -Sets the string and current parsing position for the parser. - -## setup_foreign_grammar() [](#method-i-setup_foreign_grammar) -:stopdoc: - -## setup_parser(str, debugfalse) [](#method-i-setup_parser) -Prepares for parsing `str`. If you define a custom initialize you must call -this method before #parse - -## show_error(ioSTDOUT) [](#method-i-show_error) - -## show_pos() [](#method-i-show_pos) - -## strike(text) [](#method-i-strike) -Wraps `text` in strike markup for rdoc inline formatting - -## strong(text) [](#method-i-strong) -Wraps `text` in strong markup for rdoc inline formatting - diff --git a/example/ruby/RDoc/Markdown/KpegPosInfo.md b/example/ruby/RDoc/Markdown/KpegPosInfo.md deleted file mode 100644 index 49c5a20..0000000 --- a/example/ruby/RDoc/Markdown/KpegPosInfo.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: RDoc::Markdown::KpegPosInfo -**Inherits:** Struct - - - - -# Attributes -## char[RW] [](#attribute-i-char) -Returns the value of attribute char - -**@return** [Object] the current value of char - -## col[RW] [](#attribute-i-col) -Returns the value of attribute col - -**@return** [Object] the current value of col - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line - -**@return** [Object] the current value of line - -## lno[RW] [](#attribute-i-lno) -Returns the value of attribute lno - -**@return** [Object] the current value of lno - -## pos[RW] [](#attribute-i-pos) -Returns the value of attribute pos - -**@return** [Object] the current value of pos - - diff --git a/example/ruby/RDoc/Markdown/Literals.md b/example/ruby/RDoc/Markdown/Literals.md deleted file mode 100644 index 7dde650..0000000 --- a/example/ruby/RDoc/Markdown/Literals.md +++ /dev/null @@ -1,115 +0,0 @@ -# Class: RDoc::Markdown::Literals -**Inherits:** Object - - -This set of literals is for Ruby 1.9 regular expressions and gives full -unicode support. - -Unlike peg-markdown, this set of literals recognizes Unicode alphanumeric -characters, newlines and spaces. - - -# Class Methods -## rule_info(name , rendered ) [](#method-c-rule_info) -# Attributes -## failed_rule[RW] [](#attribute-i-failed_rule) -Returns the value of attribute failed_rule. - -## failing_rule_offset[RW] [](#attribute-i-failing_rule_offset) -Returns the value of attribute failing_rule_offset. - -## pos[RW] [](#attribute-i-pos) -Returns the value of attribute pos. - -## result[RW] [](#attribute-i-result) -Returns the value of attribute result. - -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - - -#Instance Methods -## _Alphanumeric() [](#method-i-_Alphanumeric) -Alphanumeric = /p{Word}/ - -## _AlphanumericAscii() [](#method-i-_AlphanumericAscii) -AlphanumericAscii = /[A-Za-z0-9]/ - -## _BOM() [](#method-i-_BOM) -BOM = "uFEFF" - -## _Newline() [](#method-i-_Newline) -Newline = /n|r\n?|p{Zl}|p{Zp}/ - -## _NonAlphanumeric() [](#method-i-_NonAlphanumeric) -NonAlphanumeric = /p{^Word}/ - -## _Spacechar() [](#method-i-_Spacechar) -Spacechar = /t|p{Zs}/ - -## apply(rule) [](#method-i-apply) - -## apply_with_args(rule, *args) [](#method-i-apply_with_args) - -## current_character(targetpos) [](#method-i-current_character) - -## current_column(targetpos) [](#method-i-current_column) - -## current_line(targetpos) [](#method-i-current_line) - -## current_pos_info(targetpos) [](#method-i-current_pos_info) - -## external_invoke(other, rule, *args) [](#method-i-external_invoke) - -## failure_caret() [](#method-i-failure_caret) - -## failure_character() [](#method-i-failure_character) - -## failure_info() [](#method-i-failure_info) - -## failure_oneline() [](#method-i-failure_oneline) - -## get_byte() [](#method-i-get_byte) - -## get_line(no) [](#method-i-get_line) - -## get_text(start) [](#method-i-get_text) - -## grow_lr(rule, args, start_pos, m) [](#method-i-grow_lr) - -## initialize(str, debugfalse) [](#method-i-initialize) -This is distinct from setup_parser so that a standalone parser can redefine -#initialize and still have access to the proper parser setup code. - -**@return** [Literals] a new instance of Literals - -## lines() [](#method-i-lines) - -## match_string(str) [](#method-i-match_string) - -## parse(rulenil) [](#method-i-parse) - -## position_line_offsets() [](#method-i-position_line_offsets) - -## raise_error() [](#method-i-raise_error) - -**@raise** [ParseError] - -## scan(reg) [](#method-i-scan) - -## set_failed_rule(name) [](#method-i-set_failed_rule) - -## set_string(string, pos) [](#method-i-set_string) -Sets the string and current parsing position for the parser. - -## setup_foreign_grammar() [](#method-i-setup_foreign_grammar) -:startdoc: :stopdoc: - -## setup_parser(str, debugfalse) [](#method-i-setup_parser) -Prepares for parsing `str`. If you define a custom initialize you must call -this method before #parse - -## show_error(ioSTDOUT) [](#method-i-show_error) - -## show_pos() [](#method-i-show_pos) - diff --git a/example/ruby/RDoc/Markdown/Literals/KpegPosInfo.md b/example/ruby/RDoc/Markdown/Literals/KpegPosInfo.md deleted file mode 100644 index 58548f7..0000000 --- a/example/ruby/RDoc/Markdown/Literals/KpegPosInfo.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: RDoc::Markdown::Literals::KpegPosInfo -**Inherits:** Struct - - - - -# Attributes -## char[RW] [](#attribute-i-char) -Returns the value of attribute char - -**@return** [Object] the current value of char - -## col[RW] [](#attribute-i-col) -Returns the value of attribute col - -**@return** [Object] the current value of col - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line - -**@return** [Object] the current value of line - -## lno[RW] [](#attribute-i-lno) -Returns the value of attribute lno - -**@return** [Object] the current value of lno - -## pos[RW] [](#attribute-i-pos) -Returns the value of attribute pos - -**@return** [Object] the current value of pos - - diff --git a/example/ruby/RDoc/Markdown/Literals/MemoEntry.md b/example/ruby/RDoc/Markdown/Literals/MemoEntry.md deleted file mode 100644 index b8d7e59..0000000 --- a/example/ruby/RDoc/Markdown/Literals/MemoEntry.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: RDoc::Markdown::Literals::MemoEntry -**Inherits:** Object - - - - -# Attributes -## ans[RW] [](#attribute-i-ans) -Returns the value of attribute ans. - -## left_rec[RW] [](#attribute-i-left_rec) -Returns the value of attribute left_rec. - -## pos[RW] [](#attribute-i-pos) -Returns the value of attribute pos. - -## result[RW] [](#attribute-i-result) -Returns the value of attribute result. - -## set[RW] [](#attribute-i-set) -Returns the value of attribute set. - - -#Instance Methods -## initialize(ans, pos) [](#method-i-initialize) - -**@return** [MemoEntry] a new instance of MemoEntry - -## move!(ans, pos, result) [](#method-i-move!) - diff --git a/example/ruby/RDoc/Markdown/Literals/ParseError.md b/example/ruby/RDoc/Markdown/Literals/ParseError.md deleted file mode 100644 index d5de34a..0000000 --- a/example/ruby/RDoc/Markdown/Literals/ParseError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: RDoc::Markdown::Literals::ParseError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/RDoc/Markdown/Literals/RuleInfo.md b/example/ruby/RDoc/Markdown/Literals/RuleInfo.md deleted file mode 100644 index 1d201f2..0000000 --- a/example/ruby/RDoc/Markdown/Literals/RuleInfo.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: RDoc::Markdown::Literals::RuleInfo -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## rendered[RW] [](#attribute-i-rendered) -Returns the value of attribute rendered. - - -#Instance Methods -## initialize(name, rendered) [](#method-i-initialize) - -**@return** [RuleInfo] a new instance of RuleInfo - diff --git a/example/ruby/RDoc/Markdown/MemoEntry.md b/example/ruby/RDoc/Markdown/MemoEntry.md deleted file mode 100644 index fe905d1..0000000 --- a/example/ruby/RDoc/Markdown/MemoEntry.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: RDoc::Markdown::MemoEntry -**Inherits:** Object - - - - -# Attributes -## ans[RW] [](#attribute-i-ans) -Returns the value of attribute ans. - -## left_rec[RW] [](#attribute-i-left_rec) -Returns the value of attribute left_rec. - -## pos[RW] [](#attribute-i-pos) -Returns the value of attribute pos. - -## result[RW] [](#attribute-i-result) -Returns the value of attribute result. - -## set[RW] [](#attribute-i-set) -Returns the value of attribute set. - - -#Instance Methods -## initialize(ans, pos) [](#method-i-initialize) - -**@return** [MemoEntry] a new instance of MemoEntry - -## move!(ans, pos, result) [](#method-i-move!) - diff --git a/example/ruby/RDoc/Markdown/ParseError.md b/example/ruby/RDoc/Markdown/ParseError.md deleted file mode 100644 index 585167d..0000000 --- a/example/ruby/RDoc/Markdown/ParseError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: RDoc::Markdown::ParseError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/RDoc/Markdown/RuleInfo.md b/example/ruby/RDoc/Markdown/RuleInfo.md deleted file mode 100644 index 21ee06c..0000000 --- a/example/ruby/RDoc/Markdown/RuleInfo.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: RDoc::Markdown::RuleInfo -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## rendered[RW] [](#attribute-i-rendered) -Returns the value of attribute rendered. - - -#Instance Methods -## initialize(name, rendered) [](#method-i-initialize) - -**@return** [RuleInfo] a new instance of RuleInfo - diff --git a/example/ruby/RDoc/Markup.md b/example/ruby/RDoc/Markup.md deleted file mode 100644 index e3b4e40..0000000 --- a/example/ruby/RDoc/Markup.md +++ /dev/null @@ -1,147 +0,0 @@ -# Class: RDoc::Markup -**Inherits:** Object - - -RDoc::Markup parses plain text documents and attempts to decompose them into -their constituent parts. Some of these parts are high-level: paragraphs, -chunks of verbatim text, list entries and the like. Other parts happen at the -character level: a piece of bold text, a word in code font. This markup is -similar in spirit to that used on WikiWiki webs, where folks create web pages -using a simple set of formatting rules. - -RDoc::Markup and other markup formats do no output formatting, this is handled -by the RDoc::Markup::Formatter subclasses. - -# Markup Formats - -`RDoc` supports these markup formats: - -* `rdoc`: the `RDoc` markup format; see RDoc::MarkupReference. -* `markdown`: The `markdown` markup format as described in the [Markdown - Guide](https://www.markdownguide.org); see RDoc::Markdown. -* `rd`: the `rd` markup format format; see RDoc::RD. -* `tomdoc`: the TomDoc format as described in [TomDoc for - Ruby](http://tomdoc.org); see RDoc::TomDoc. - -You can choose a markup format using the following methods: - -per project -: If you build your documentation with rake use RDoc::Task#markup. - - If you build your documentation by hand run: - - rdoc --markup your_favorite_format --write-options - - and commit `.rdoc_options` and ship it with your packaged gem. - -per file -: At the top of the file use the `:markup:` directive to set the default - format for the rest of the file. - -per comment -: Use the `:markup:` directive at the top of a comment you want to write in - a different format. - - -# RDoc::Markup - -RDoc::Markup is extensible at runtime: you can add new markup elements to be -recognized in the documents that RDoc::Markup parses. - -RDoc::Markup is intended to be the basis for a family of tools which share the -common requirement that simple, plain-text should be rendered in a variety of -different output formats and media. It is envisaged that RDoc::Markup could -be the basis for formatting RDoc style comment blocks, Wiki entries, and -online FAQs. - -## Synopsis - -This code converts `input_string` to HTML. The conversion takes place in the -`convert` method, so you can use the same RDoc::Markup converter to convert -multiple input strings. - - require 'rdoc' - - h = RDoc::Markup::ToHtml.new(RDoc::Options.new) - - puts h.convert(input_string) - -You can extend the RDoc::Markup parser to recognize new markup sequences, and -to add regexp handling. Here we make WikiWords significant to the parser, and -also make the sequences {word} and text... signify strike-through -text. We then subclass the HTML output class to deal with these: - - require 'rdoc' - - class WikiHtml < RDoc::Markup::ToHtml - def handle_regexp_WIKIWORD(target) - "" + target.text + "" - end - end - - markup = RDoc::Markup.new - markup.add_word_pair("{", "}", :STRIKE) - markup.add_html("no", :STRIKE) - - markup.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD) - - wh = WikiHtml.new RDoc::Options.new, markup - wh.add_tag(:STRIKE, "", "") - - puts "#{wh.convert ARGF.read}" - -## Encoding - -Where Encoding support is available, RDoc will automatically convert all -documents to the same output encoding. The output encoding can be set via -RDoc::Options#encoding and defaults to Encoding.default_external. - -# RDoc Markup Reference - -See RDoc::MarkupReference. - --- -Original Author -: Dave Thomas, dave@pragmaticprogrammer.com - -License -: Ruby license - - - -# Class Methods -## parse(str ) [](#method-c-parse) -Parses `str` into an RDoc::Markup::Document. -# Attributes -## attribute_manager[RW] [](#attribute-i-attribute_manager) -An AttributeManager which handles inline markup. - - -#Instance Methods -## add_html(tag, name) [](#method-i-add_html) -Add to the sequences recognized as general markup. - -## add_regexp_handling(pattern, name) [](#method-i-add_regexp_handling) -Add to other inline sequences. For example, we could add WikiWords using -something like: - - parser.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD) - -Each wiki word will be presented to the output formatter. - -## add_word_pair(start, stop, name) [](#method-i-add_word_pair) -Add to the sequences used to add formatting to an individual word (such as -**bold**). Matching entries will generate attributes that the output -formatters can recognize by their `name`. - -## convert(input, formatter) [](#method-i-convert) -We take `input`, parse it if necessary, then invoke the output `formatter` -using a Visitor to render the result. - -## initialize(attribute_managernil) [](#method-i-initialize) -Take a block of text and use various heuristics to determine its structure -(paragraphs, lists, and so on). Invoke an event handler as we identify -significant chunks. - -**@return** [Markup] a new instance of Markup - diff --git a/example/ruby/RDoc/Markup/AttrChanger.md b/example/ruby/RDoc/Markup/AttrChanger.md deleted file mode 100644 index 09a1220..0000000 --- a/example/ruby/RDoc/Markup/AttrChanger.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: RDoc::Markup::AttrChanger -**Inherits:** Struct - - -An AttrChanger records a change in attributes. It contains a bitmap of the -attributes to turn on, and a bitmap of those to turn off. - - -# Attributes -## turn_off[RW] [](#attribute-i-turn_off) -Returns the value of attribute turn_off - -**@return** [Object] the current value of turn_off - -## turn_on[RW] [](#attribute-i-turn_on) -Returns the value of attribute turn_on - -**@return** [Object] the current value of turn_on - - -#Instance Methods -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/RDoc/Markup/AttrSpan.md b/example/ruby/RDoc/Markup/AttrSpan.md deleted file mode 100644 index 600365d..0000000 --- a/example/ruby/RDoc/Markup/AttrSpan.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: RDoc::Markup::AttrSpan -**Inherits:** Object - - -An array of attributes which parallels the characters in a string. - - - -#Instance Methods -## [](n) [](#method-i-[]) -Accesses flags for character `n` - -## initialize(length, exclusive) [](#method-i-initialize) -Creates a new AttrSpan for `length` characters - -**@return** [AttrSpan] a new instance of AttrSpan - -## set_attrs(start, length, bits) [](#method-i-set_attrs) -Toggles `bits` from `start` to `length` - diff --git a/example/ruby/RDoc/Markup/AttributeManager.md b/example/ruby/RDoc/Markup/AttributeManager.md deleted file mode 100644 index 381e110..0000000 --- a/example/ruby/RDoc/Markup/AttributeManager.md +++ /dev/null @@ -1,109 +0,0 @@ -# Class: RDoc::Markup::AttributeManager -**Inherits:** Object - - -Manages changes of attributes in a block of text - - -# Attributes -## attributes[RW] [](#attribute-i-attributes) -The attributes enabled for this markup object. - -## exclusive_bitmap[RW] [](#attribute-i-exclusive_bitmap) -A bits of exclusive maps - -## html_tags[RW] [](#attribute-i-html_tags) -This maps HTML tags to the corresponding attribute char - -## matching_word_pairs[RW] [](#attribute-i-matching_word_pairs) -This maps delimiters that occur around words (such as **bold** or `tt`) where -the start and end delimiters and the same. This lets us optimize the regexp - -## protectable[RW] [](#attribute-i-protectable) -A \ in front of a character that would normally be processed turns off -processing. We do this by turning < into <#{PROTECT} - -## regexp_handlings[RW] [](#attribute-i-regexp_handlings) -And this maps _regexp handling_ sequences to a name. A regexp handling -sequence is something like a WikiWord - -## word_pair_map[RW] [](#attribute-i-word_pair_map) -And this is used when the delimiters aren't the same. In this case the hash -maps a pattern to the attribute character - - -#Instance Methods -## add_html(tag, name, exclusivefalse) [](#method-i-add_html) -Adds a markup class with `name` for words surrounded by HTML tag `tag`. To -process emphasis tags: - - am.add_html 'em', :EM - -## add_regexp_handling(pattern, name, exclusivefalse) [](#method-i-add_regexp_handling) -Adds a regexp handling for `pattern` with `name`. A simple URL handler would -be: - - @am.add_regexp_handling(/((https?:)\S+\w)/, :HYPERLINK) - -## add_word_pair(start, stop, name, exclusivefalse) [](#method-i-add_word_pair) -Adds a markup class with `name` for words wrapped in the `start` and `stop` -character. To make words wrapped with "*" bold: - - am.add_word_pair '*', '*', :BOLD - -**@raise** [ArgumentError] - -## attribute(turn_on, turn_off) [](#method-i-attribute) -Return an attribute object with the given turn_on and turn_off bits set - -## change_attribute(current, new) [](#method-i-change_attribute) -Changes the current attribute from `current` to `new` - -## changed_attribute_by_name(current_set, new_set) [](#method-i-changed_attribute_by_name) -Used by the tests to change attributes by name from `current_set` to `new_set` - -## convert_attrs(str, attrs, exclusivefalse) [](#method-i-convert_attrs) -Map attributes like **text**to the sequence 001002001003, where - is a per-attribute specific character - -## convert_attrs_matching_word_pairs(str, attrs, exclusive) [](#method-i-convert_attrs_matching_word_pairs) -:nodoc: - -## convert_attrs_word_pair_map(str, attrs, exclusive) [](#method-i-convert_attrs_word_pair_map) -:nodoc: - -## convert_html(str, attrs, exclusivefalse) [](#method-i-convert_html) -Converts HTML tags to RDoc attributes - -## convert_regexp_handlings(str, attrs, exclusivefalse) [](#method-i-convert_regexp_handlings) -Converts regexp handling sequences to RDoc attributes - -## copy_string(start_pos, end_pos) [](#method-i-copy_string) -Copies `start_pos` to `end_pos` from the current string - -## display_attributes() [](#method-i-display_attributes) -Debug method that prints a string along with its attributes - -## exclusive?(attr) [](#method-i-exclusive?) -:nodoc: - -**@return** [Boolean] - -## flow(str) [](#method-i-flow) -Processes `str` converting attributes, HTML and regexp handlings - -## initialize() [](#method-i-initialize) -Creates a new attribute manager that understands bold, emphasized and teletype -text. - -**@return** [AttributeManager] a new instance of AttributeManager - -## mask_protected_sequences() [](#method-i-mask_protected_sequences) -Escapes regexp handling sequences of text to prevent conversion to RDoc - -## split_into_flow() [](#method-i-split_into_flow) -Splits the string into chunks by attribute change - -## unmask_protected_sequences() [](#method-i-unmask_protected_sequences) -Unescapes regexp handling sequences of text - diff --git a/example/ruby/RDoc/Markup/Attributes.md b/example/ruby/RDoc/Markup/Attributes.md deleted file mode 100644 index 0186d51..0000000 --- a/example/ruby/RDoc/Markup/Attributes.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: RDoc::Markup::Attributes -**Inherits:** Object - - -We manage a set of attributes. Each attribute has a symbol name and a bit -value. - - -# Attributes -## regexp_handling[RW] [](#attribute-i-regexp_handling) -The regexp handling attribute type. See RDoc::Markup#add_regexp_handling - - -#Instance Methods -## as_string(bitmap) [](#method-i-as_string) -Returns a string representation of `bitmap` - -## bitmap_for(name) [](#method-i-bitmap_for) -Returns a unique bit for `name` - -## each_name_of(bitmap) [](#method-i-each_name_of) -yields each attribute name in `bitmap` - -## initialize() [](#method-i-initialize) -Creates a new attributes set. - -**@return** [Attributes] a new instance of Attributes - diff --git a/example/ruby/RDoc/Markup/BlankLine.md b/example/ruby/RDoc/Markup/BlankLine.md deleted file mode 100644 index c4aeada..0000000 --- a/example/ruby/RDoc/Markup/BlankLine.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: RDoc::Markup::BlankLine -**Inherits:** Object - - -An empty line. This class is a singleton. - - -# Class Methods -## new() [](#method-c-new) -RDoc::Markup::BlankLine is a singleton - -#Instance Methods -## accept(visitor) [](#method-i-accept) -Calls #accept_blank_line on `visitor` - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/RDoc/Markup/BlockQuote.md b/example/ruby/RDoc/Markup/BlockQuote.md deleted file mode 100644 index e4ea0d3..0000000 --- a/example/ruby/RDoc/Markup/BlockQuote.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: RDoc::Markup::BlockQuote -**Inherits:** RDoc::Markup::Raw - - -A quoted section which contains markup items. - - - -#Instance Methods -## accept(visitor) [](#method-i-accept) -Calls #accept_block_quote on `visitor` - diff --git a/example/ruby/RDoc/Markup/Document.md b/example/ruby/RDoc/Markup/Document.md deleted file mode 100644 index 96f0485..0000000 --- a/example/ruby/RDoc/Markup/Document.md +++ /dev/null @@ -1,2130 +0,0 @@ -# Class: RDoc::Markup::Document -**Inherits:** Object - -**Includes:** Enumerable - - -A Document containing lists, headings, paragraphs, etc. - - -# Attributes -## file[RW] [](#attribute-i-file) -The file this document was created from. See also -RDoc::ClassModule#add_comment - -## omit_headings_below[RW] [](#attribute-i-omit_headings_below) -If a heading is below the given level it will be omitted from the -table_of_contents - -## parts[RW] [](#attribute-i-parts) -The parts of the Document - - -#Instance Methods -## <<(part) [](#method-i-<<) -Appends `part` to the document - -## ==(other) [](#method-i-==) -:nodoc: - -## accept(visitor) [](#method-i-accept) -Runs this document and all its #items through `visitor` - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## concat(parts) [](#method-i-concat) -Concatenates the given `parts` onto the document - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) -Enumerator for the parts of this document - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Does this document have no parts? - -**@return** [Boolean] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*parts) [](#method-i-initialize) -Creates a new Document with `parts` - -**@return** [Document] a new instance of Document - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## merge(other) [](#method-i-merge) -When this is a collection of documents (#file is not set and this document -contains only other documents as its direct children) #merge replaces -documents in this class with documents from `other` when the file matches and -adds documents from `other` when the files do not. - -The information in `other` is preferred over the receiver - -## merged?() [](#method-i-merged?) -Does this Document contain other Documents? - -**@return** [Boolean] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## push(*parts) [](#method-i-push) -Appends `parts` to the document - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## table_of_contents() [](#method-i-table_of_contents) -Returns an Array of headings in the document. - -Require 'rdoc/markup/formatter' before calling this method. - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/RDoc/Markup/Formatter.md b/example/ruby/RDoc/Markup/Formatter.md deleted file mode 100644 index d77c5ae..0000000 --- a/example/ruby/RDoc/Markup/Formatter.md +++ /dev/null @@ -1,87 +0,0 @@ -# Class: RDoc::Markup::Formatter -**Inherits:** Object - - -Base class for RDoc markup formatters - -Formatters are a visitor that converts an RDoc::Markup tree (from a comment) -into some kind of output. RDoc ships with formatters for converting back to -rdoc, ANSI text, HTML, a Table of Contents and other formats. - -If you'd like to write your own Formatter use RDoc::Markup::FormatterTestCase. - If you're writing a text-output formatter use -RDoc::Markup::TextFormatterTestCase which provides extra test cases. - - -# Class Methods -## gen_relative_url(path , target ) [](#method-c-gen_relative_url) -Converts a target url to one that is relative to a given path - -#Instance Methods -## accept_document(document) [](#method-i-accept_document) -Adds `document` to the output - -## add_regexp_handling_RDOCLINK() [](#method-i-add_regexp_handling_RDOCLINK) -Adds a regexp handling for links of the form rdoc-...: - -## add_regexp_handling_TIDYLINK() [](#method-i-add_regexp_handling_TIDYLINK) -Adds a regexp handling for links of the form []() and -<[word>]() - -## add_tag(name, start, stop) [](#method-i-add_tag) -Add a new set of tags for an attribute. We allow separate start and end tags -for flexibility - -## annotate(tag) [](#method-i-annotate) -Allows `tag` to be decorated with additional information. - -## convert(content) [](#method-i-convert) -Marks up `content` - -## convert_flow(flow) [](#method-i-convert_flow) -Converts flow items `flow` - -## convert_regexp_handling(target) [](#method-i-convert_regexp_handling) -Converts added regexp handlings. See RDoc::Markup#add_regexp_handling - -## convert_string(string) [](#method-i-convert_string) -Converts a string to be fancier if desired - -## each_attr_tag(attr_mask, reversefalse) [](#method-i-each_attr_tag) - -## ignore(*node) [](#method-i-ignore) -Use ignore in your subclass to ignore the content of a node. - - ## - # We don't support raw nodes in ToNoRaw - - alias accept_raw ignore - -## in_tt?() [](#method-i-in_tt?) -Are we currently inside tt tags? - -**@return** [Boolean] - -## initialize(options, markupnil) [](#method-i-initialize) -Creates a new Formatter - -**@return** [Formatter] a new instance of Formatter - -## off_tags(res, item) [](#method-i-off_tags) -Turns off tags for `item` on `res` - -## on_tags(res, item) [](#method-i-on_tags) -Turns on tags for `item` on `res` - -## parse_url(url) [](#method-i-parse_url) -Extracts and a scheme, url and an anchor id from `url` and returns them. - -## tt?(tag) [](#method-i-tt?) -Is `tag` a tt tag? - -**@return** [Boolean] - -## tt_tag?(attr_mask, reversefalse) [](#method-i-tt_tag?) - -**@return** [Boolean] - diff --git a/example/ruby/RDoc/Markup/Formatter/InlineTag.md b/example/ruby/RDoc/Markup/Formatter/InlineTag.md deleted file mode 100644 index 2988b26..0000000 --- a/example/ruby/RDoc/Markup/Formatter/InlineTag.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: RDoc::Markup::Formatter::InlineTag -**Inherits:** Struct - - -Tag for inline markup containing a `bit` for the bitmask and the `on` and -`off` triggers. - - -# Attributes -## bit[RW] [](#attribute-i-bit) -Returns the value of attribute bit - -**@return** [Object] the current value of bit - -## off[RW] [](#attribute-i-off) -Returns the value of attribute off - -**@return** [Object] the current value of off - -## on[RW] [](#attribute-i-on) -Returns the value of attribute on - -**@return** [Object] the current value of on - - diff --git a/example/ruby/RDoc/Markup/FormatterTestCase.md b/example/ruby/RDoc/Markup/FormatterTestCase.md deleted file mode 100644 index 6dc3dd5..0000000 --- a/example/ruby/RDoc/Markup/FormatterTestCase.md +++ /dev/null @@ -1,73 +0,0 @@ -# Class: RDoc::Markup::FormatterTestCase -**Inherits:** RDoc::TestCase - - -Test case for creating new RDoc::Markup formatters. See -test/test_rdoc_markup_to_*.rb for examples. - -This test case adds a variety of tests to your subclass when -#add_visitor_tests is called. Most tests set up a scenario then call a method -you will provide to perform the assertion on the output. - -Your subclass must instantiate a visitor and assign it to `@to`. - -For example, test_accept_blank_line sets up a RDoc::Markup::BlockLine then -calls accept_blank_line on your visitor. You are responsible for asserting -that the output is correct. - -Example: - - class TestRDocMarkupToNewFormat < RDoc::Markup::FormatterTestCase - - add_visitor_tests - - def setup - super - - @to = RDoc::Markup::ToNewFormat.new - end - - def accept_blank_line - assert_equal :junk, @to.res.join - end - - # ... - - end - - -# Class Methods -## add_visitor_tests() [](#method-c-add_visitor_tests) -Call to add the visitor tests to your test case - -#Instance Methods -## setup() [](#method-i-setup) -Call #setup when inheriting from this test case. - -Provides the following instance variables: - -+@m+ -: RDoc::Markup.new - -+@RM+ -: RDoc::Markup # to reduce typing - -+@bullet_list+ -: @RM::List.new :BULLET, # ... - -+@label_list+ -: @RM::List.new :LABEL, # ... - -+@lalpha_list+ -: @RM::List.new :LALPHA, # ... - -+@note_list+ -: @RM::List.new :NOTE, # ... - -+@number_list+ -: @RM::List.new :NUMBER, # ... - -+@ualpha_list+ -: @RM::List.new :UALPHA, # ... - - diff --git a/example/ruby/RDoc/Markup/HardBreak.md b/example/ruby/RDoc/Markup/HardBreak.md deleted file mode 100644 index 23cb85b..0000000 --- a/example/ruby/RDoc/Markup/HardBreak.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: RDoc::Markup::HardBreak -**Inherits:** Object - - -A hard-break in the middle of a paragraph. - - -# Class Methods -## new() [](#method-c-new) -RDoc::Markup::HardBreak is a singleton - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## accept(visitor) [](#method-i-accept) -Calls #accept_hard_break on `visitor` - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/RDoc/Markup/Include.md b/example/ruby/RDoc/Markup/Include.md deleted file mode 100644 index 232f92f..0000000 --- a/example/ruby/RDoc/Markup/Include.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: RDoc::Markup::Include -**Inherits:** Object - - -A file included at generation time. Objects of this class are created by -RDoc::RD for an extension-less include. - -This implementation in incomplete. - - -# Attributes -## file[RW] [](#attribute-i-file) -The filename to be included, without extension - -## include_path[RW] [](#attribute-i-include_path) -Directories to search for #file - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## initialize(file, include_path) [](#method-i-initialize) -Creates a new include that will import `file` from `include_path` - -**@return** [Include] a new instance of Include - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/RDoc/Markup/IndentedParagraph.md b/example/ruby/RDoc/Markup/IndentedParagraph.md deleted file mode 100644 index 781646d..0000000 --- a/example/ruby/RDoc/Markup/IndentedParagraph.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: RDoc::Markup::IndentedParagraph -**Inherits:** RDoc::Markup::Raw - - -An Indented Paragraph of text - - -# Attributes -## indent[RW] [](#attribute-i-indent) -The indent in number of spaces - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## accept(visitor) [](#method-i-accept) -Calls #accept_indented_paragraph on `visitor` - -## initialize(indent, *parts) [](#method-i-initialize) -Creates a new IndentedParagraph containing `parts` indented with `indent` -spaces - -**@return** [IndentedParagraph] a new instance of IndentedParagraph - -## text(hard_breaknil) [](#method-i-text) -Joins the raw paragraph text and converts inline HardBreaks to the -`hard_break` text followed by the indent. - diff --git a/example/ruby/RDoc/Markup/List.md b/example/ruby/RDoc/Markup/List.md deleted file mode 100644 index aea60a5..0000000 --- a/example/ruby/RDoc/Markup/List.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: RDoc::Markup::List -**Inherits:** Object - - -A List is a homogeneous set of ListItems. - -The supported list types include: - -:BULLET -: An unordered list - -:LABEL -: An unordered definition list, but using an alternate RDoc::Markup syntax - -:LALPHA -: An ordered list using increasing lowercase English letters - -:NOTE -: An unordered definition list - -:NUMBER -: An ordered list using increasing Arabic numerals - -:UALPHA -: An ordered list using increasing uppercase English letters - - -Definition lists behave like HTML definition lists. Each list item can -describe multiple terms. See RDoc::Markup::ListItem for how labels and -definition are stored as list items. - - -# Attributes -## items[RW] [](#attribute-i-items) -Items in the list - -## type[RW] [](#attribute-i-type) -The list's type - - -#Instance Methods -## <<(item) [](#method-i-<<) -Appends `item` to the list - -## ==(other) [](#method-i-==) -:nodoc: - -## accept(visitor) [](#method-i-accept) -Runs this list and all its #items through `visitor` - -## empty?() [](#method-i-empty?) -Is the list empty? - -**@return** [Boolean] - -## initialize(typenil, *items) [](#method-i-initialize) -Creates a new list of `type` with `items`. Valid list types are: `:BULLET`, -`:LABEL`, `:LALPHA`, `:NOTE`, `:NUMBER`, `:UALPHA` - -**@return** [List] a new instance of List - -## last() [](#method-i-last) -Returns the last item in the list - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## push(*items) [](#method-i-push) -Appends `items` to the list - diff --git a/example/ruby/RDoc/Markup/ListItem.md b/example/ruby/RDoc/Markup/ListItem.md deleted file mode 100644 index a9d9cee..0000000 --- a/example/ruby/RDoc/Markup/ListItem.md +++ /dev/null @@ -1,51 +0,0 @@ -# Class: RDoc::Markup::ListItem -**Inherits:** Object - - -An item within a List that contains paragraphs, headings, etc. - -For BULLET, NUMBER, LALPHA and UALPHA lists, the label will always be nil. For -NOTE and LABEL lists, the list label may contain: - -* a single String for a single label -* an Array of Strings for a list item with multiple terms -* nil for an extra description attached to a previously labeled list item - - -# Attributes -## label[RW] [](#attribute-i-label) -The label for the ListItem - -## parts[RW] [](#attribute-i-parts) -Parts of the ListItem - - -#Instance Methods -## <<(part) [](#method-i-<<) -Appends `part` to the ListItem - -## ==(other) [](#method-i-==) -:nodoc: - -## accept(visitor) [](#method-i-accept) -Runs this list item and all its #parts through `visitor` - -## empty?() [](#method-i-empty?) -Is the ListItem empty? - -**@return** [Boolean] - -## initialize(labelnil, *parts) [](#method-i-initialize) -Creates a new ListItem with an optional `label` containing `parts` - -**@return** [ListItem] a new instance of ListItem - -## length() [](#method-i-length) -Length of parts in the ListItem - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## push(*parts) [](#method-i-push) -Adds `parts` to the ListItem - diff --git a/example/ruby/RDoc/Markup/Paragraph.md b/example/ruby/RDoc/Markup/Paragraph.md deleted file mode 100644 index 401dfeb..0000000 --- a/example/ruby/RDoc/Markup/Paragraph.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: RDoc::Markup::Paragraph -**Inherits:** RDoc::Markup::Raw - - -A Paragraph of text - - - -#Instance Methods -## accept(visitor) [](#method-i-accept) -Calls #accept_paragraph on `visitor` - -## text(hard_break'') [](#method-i-text) -Joins the raw paragraph text and converts inline HardBreaks to the -`hard_break` text. - diff --git a/example/ruby/RDoc/Markup/Parser.md b/example/ruby/RDoc/Markup/Parser.md deleted file mode 100644 index 6a1aefb..0000000 --- a/example/ruby/RDoc/Markup/Parser.md +++ /dev/null @@ -1,127 +0,0 @@ -# Class: RDoc::Markup::Parser -**Inherits:** Object - -**Includes:** RDoc::Text - - -A recursive-descent parser for RDoc markup. - -The parser tokenizes an input string then parses the tokens into a Document. -Documents can be converted into output formats by writing a visitor like -RDoc::Markup::ToHTML. - -The parser only handles the block-level constructs Paragraph, List, ListItem, -Heading, Verbatim, BlankLine, Rule and BlockQuote. Inline markup such as -`+blah+` is handled separately by RDoc::Markup::AttributeManager. - -To see what markup the Parser implements read RDoc. To see how to use RDoc -markup to format text in your program read RDoc::Markup. - - -# Class Methods -## parse(str ) [](#method-c-parse) -Parses `str` into a Document. - -Use RDoc::Markup#parse instead of this method. -## tokenize(str ) [](#method-c-tokenize) -Returns a token stream for `str`, for testing -# Attributes -## debug[RW] [](#attribute-i-debug) -Enables display of debugging information - -## tokens[RW] [](#attribute-i-tokens) -Token accessor - - -#Instance Methods -## build_heading(level) [](#method-i-build_heading) -Builds a Heading of `level` - -## build_list(margin) [](#method-i-build_list) -Builds a List flush to `margin` - -## build_paragraph(margin) [](#method-i-build_paragraph) -Builds a Paragraph that is flush to `margin` - -## build_verbatim(margin) [](#method-i-build_verbatim) -Builds a Verbatim that is indented from `margin`. - -The verbatim block is shifted left (the least indented lines start in column -0). Each part of the verbatim is one line of text, always terminated by a -newline. Blank lines always consist of a single newline character, and there -is never a single newline at the end of the verbatim. - -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## get() [](#method-i-get) -Pulls the next token from the stream. - -## initialize() [](#method-i-initialize) -Creates a new Parser. See also ::parse - -**@return** [Parser] a new instance of Parser - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## parse(parent, indent0) [](#method-i-parse) -Parses the tokens into an array of RDoc::Markup::XXX objects, and appends them -to the passed `parent` RDoc::Markup::YYY object. - -Exits at the end of the token stream, or when it encounters a token in a -column less than `indent` (unless it is a NEWLINE). - -Returns `parent`. - -## parse_text(parent, indent) [](#method-i-parse_text) -Small hook that is overridden by RDoc::TomDoc - -## peek_token() [](#method-i-peek_token) -Returns the next token on the stream without modifying the stream - -## setup_scanner(input) [](#method-i-setup_scanner) -Creates the StringScanner - -## skip(token_type, errortrue) [](#method-i-skip) -Skips the next token if its type is `token_type`. - -Optionally raises an error if the next token is not of the expected type. - -**@raise** [ParseError] - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## tokenize(input) [](#method-i-tokenize) -Turns text `input` into a stream of tokens - -## unget() [](#method-i-unget) -Returns the current token to the token stream - -**@raise** [Error] - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/RDoc/Markup/Parser/Error.md b/example/ruby/RDoc/Markup/Parser/Error.md deleted file mode 100644 index dd466e8..0000000 --- a/example/ruby/RDoc/Markup/Parser/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: RDoc::Markup::Parser::Error -**Inherits:** RuntimeError - - -Parser error subclass - - - diff --git a/example/ruby/RDoc/Markup/Parser/MyStringScanner.md b/example/ruby/RDoc/Markup/Parser/MyStringScanner.md deleted file mode 100644 index 624d28f..0000000 --- a/example/ruby/RDoc/Markup/Parser/MyStringScanner.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: RDoc::Markup::Parser::MyStringScanner -**Inherits:** Object - - -A simple wrapper of StringScanner that is aware of the current column and -lineno - - - -#Instance Methods -## [](i) [](#method-i-[]) - -## eos?() [](#method-i-eos?) - -**@return** [Boolean] - -## initialize(input) [](#method-i-initialize) -:stopdoc: - -**@return** [MyStringScanner] a new instance of MyStringScanner - -## matched() [](#method-i-matched) - -## newline!() [](#method-i-newline!) - -## pos() [](#method-i-pos) - -## scan(re) [](#method-i-scan) - -## unscan(s) [](#method-i-unscan) - diff --git a/example/ruby/RDoc/Markup/Parser/ParseError.md b/example/ruby/RDoc/Markup/Parser/ParseError.md deleted file mode 100644 index 0680a11..0000000 --- a/example/ruby/RDoc/Markup/Parser/ParseError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: RDoc::Markup::Parser::ParseError -**Inherits:** RDoc::Markup::Parser::Error - - -Raised when the parser is unable to handle the given markup - - - diff --git a/example/ruby/RDoc/Markup/PreProcess.md b/example/ruby/RDoc/Markup/PreProcess.md deleted file mode 100644 index 0b04ef5..0000000 --- a/example/ruby/RDoc/Markup/PreProcess.md +++ /dev/null @@ -1,92 +0,0 @@ -# Class: RDoc::Markup::PreProcess -**Inherits:** Object - - -Handle common directives that can occur in a block of text: - - \:include: filename - -Directives can be escaped by preceding them with a backslash. - -RDoc plugin authors can register additional directives to be handled by using -RDoc::Markup::PreProcess::register. - -Any directive that is not built-in to RDoc (including those registered via -plugins) will be stored in the metadata hash on the CodeObject the comment is -attached to. See RDoc::Markup@Directives for the list of built-in directives. - - -# Class Methods -## post_process(&block ) [](#method-c-post_process) -Adds a post-process handler for directives. The handler will be called with -the result RDoc::Comment (or text String) and the code object for the comment -(if any). -## post_processors() [](#method-c-post_processors) -Registered post-processors -## register(directive , &block ) [](#method-c-register) -Registers `directive` as one handled by RDoc. If a block is given the -directive will be replaced by the result of the block, otherwise the directive -will be removed from the processed text. - -The block will be called with the directive name and the directive parameter: - - RDoc::Markup::PreProcess.register 'my-directive' do |directive, param| - # replace text, etc. - end -## registered() [](#method-c-registered) -Registered directives -## reset() [](#method-c-reset) -Clears all registered directives and post-processors -# Attributes -## options[RW] [](#attribute-i-options) -An RDoc::Options instance that will be filled in with overrides from -directives - - -#Instance Methods -## find_include_file(name) [](#method-i-find_include_file) -Look for the given file in the directory containing the current file, and then -in each of the directories specified in the RDOC_INCLUDE path - -## handle(text, code_objectnil, &block) [](#method-i-handle) -Look for directives in the given `text`. - -Options that we don't handle are yielded. If the block returns false the -directive is restored to the text. If the block returns nil or no block was -given the directive is handled according to the registered directives. If a -String was returned the directive is replaced with the string. - -If no matching directive was registered the directive is restored to the text. - -If `code_object` is given and the directive is unknown then the directive's -parameter is set as metadata on the `code_object`. See -RDoc::CodeObject#metadata for details. - -## handle_directive(prefix, directive, param, code_objectnil, encodingnil, linenil) [](#method-i-handle_directive) -Performs the actions described by `directive` and its parameter `param`. - -`code_object` is used for directives that operate on a class or module. -`prefix` is used to ensure the replacement for handled directives is correct. -`encoding` is used for the `include` directive. - -For a list of directives in RDoc see RDoc::Markup. -- When 1.8.7 support is -ditched prefix can be defaulted to '' - -## include_file(name, indent, encoding) [](#method-i-include_file) -Handles the `:include: *filename`* directive. - -If the first line of the included file starts with '#', and contains an -encoding information in the form 'coding:' or 'coding=', it is removed. - -If all lines in the included file start with a '#', this leading '#' is -removed before inclusion. The included content is indented like the -`:include:` directive. -- so all content will be verbatim because of the -likely space after '#'? TODO shift left the whole file content in that case -TODO comment stop/start #-- and #++ in included file must be processed here - -## initialize(input_file_name, include_path) [](#method-i-initialize) -Creates a new pre-processor for `input_file_name` that will look for included -files in `include_path` - -**@return** [PreProcess] a new instance of PreProcess - diff --git a/example/ruby/RDoc/Markup/PreProcessTest.md b/example/ruby/RDoc/Markup/PreProcessTest.md deleted file mode 100644 index 46fe6cc..0000000 --- a/example/ruby/RDoc/Markup/PreProcessTest.md +++ /dev/null @@ -1,98 +0,0 @@ -# Class: RDoc::Markup::PreProcessTest -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_class_post_process() [](#method-i-test_class_post_process) - -## test_class_register() [](#method-i-test_class_register) - -## test_handle() [](#method-i-test_handle) - -## test_handle_comment() [](#method-i-test_handle_comment) - -## test_handle_directive_arg() [](#method-i-test_handle_directive_arg) - -## test_handle_directive_arg_no_context() [](#method-i-test_handle_directive_arg_no_context) - -## test_handle_directive_args() [](#method-i-test_handle_directive_args) - -## test_handle_directive_blankline() [](#method-i-test_handle_directive_blankline) - -## test_handle_directive_block() [](#method-i-test_handle_directive_block) - -## test_handle_directive_block_false() [](#method-i-test_handle_directive_block_false) - -## test_handle_directive_block_nil() [](#method-i-test_handle_directive_block_nil) - -## test_handle_directive_category() [](#method-i-test_handle_directive_category) - -## test_handle_directive_doc() [](#method-i-test_handle_directive_doc) - -## test_handle_directive_doc_no_context() [](#method-i-test_handle_directive_doc_no_context) - -## test_handle_directive_downcase() [](#method-i-test_handle_directive_downcase) - -## test_handle_directive_enddoc() [](#method-i-test_handle_directive_enddoc) - -## test_handle_directive_include() [](#method-i-test_handle_directive_include) - -## test_handle_directive_main() [](#method-i-test_handle_directive_main) - -## test_handle_directive_nodoc() [](#method-i-test_handle_directive_nodoc) - -## test_handle_directive_nodoc_all() [](#method-i-test_handle_directive_nodoc_all) - -## test_handle_directive_nodoc_no_context() [](#method-i-test_handle_directive_nodoc_no_context) - -## test_handle_directive_not_dash_new() [](#method-i-test_handle_directive_not_dash_new) - -## test_handle_directive_not_new() [](#method-i-test_handle_directive_not_new) - -## test_handle_directive_notnew() [](#method-i-test_handle_directive_notnew) - -## test_handle_directive_registered() [](#method-i-test_handle_directive_registered) - -## test_handle_directive_registered_block() [](#method-i-test_handle_directive_registered_block) - -## test_handle_directive_registered_code_object() [](#method-i-test_handle_directive_registered_code_object) - -## test_handle_directive_startdoc() [](#method-i-test_handle_directive_startdoc) - -## test_handle_directive_stopdoc() [](#method-i-test_handle_directive_stopdoc) - -## test_handle_directive_title() [](#method-i-test_handle_directive_title) - -## test_handle_directive_unhandled() [](#method-i-test_handle_directive_unhandled) - -## test_handle_directive_unhandled_block() [](#method-i-test_handle_directive_unhandled_block) - -## test_handle_directive_yield() [](#method-i-test_handle_directive_yield) - -## test_handle_directive_yield_block_param() [](#method-i-test_handle_directive_yield_block_param) - -## test_handle_directive_yield_no_context() [](#method-i-test_handle_directive_yield_no_context) - -## test_handle_directive_yields() [](#method-i-test_handle_directive_yields) - -## test_handle_markup() [](#method-i-test_handle_markup) - -## test_handle_markup_empty() [](#method-i-test_handle_markup_empty) - -## test_handle_post_process() [](#method-i-test_handle_post_process) - -## test_handle_unregistered() [](#method-i-test_handle_unregistered) - -## test_include_file() [](#method-i-test_include_file) - -## test_include_file_encoding_incompatible() [](#method-i-test_include_file_encoding_incompatible) - -## test_include_file_in_other_directory() [](#method-i-test_include_file_in_other_directory) - diff --git a/example/ruby/RDoc/Markup/Raw.md b/example/ruby/RDoc/Markup/Raw.md deleted file mode 100644 index 6d42683..0000000 --- a/example/ruby/RDoc/Markup/Raw.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: RDoc::Markup::Raw -**Inherits:** Object - - -A section of text that is added to the output document as-is - - -# Attributes -## parts[RW] [](#attribute-i-parts) -The component parts of the list - - -#Instance Methods -## <<(text) [](#method-i-<<) -Appends `text` - -## ==(other) [](#method-i-==) -:nodoc: - -## accept(visitor) [](#method-i-accept) -Calls #accept_raw+ on `visitor` - -## initialize(*parts) [](#method-i-initialize) -Creates a new Raw containing `parts` - -**@return** [Raw] a new instance of Raw - -## merge(other) [](#method-i-merge) -Appends `other`'s parts - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## push(*texts) [](#method-i-push) -Appends `texts` onto this Paragraph - -## text() [](#method-i-text) -The raw text - diff --git a/example/ruby/RDoc/Markup/RegexpHandling.md b/example/ruby/RDoc/Markup/RegexpHandling.md deleted file mode 100644 index 68a395f..0000000 --- a/example/ruby/RDoc/Markup/RegexpHandling.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: RDoc::Markup::RegexpHandling -**Inherits:** Object - - -Hold details of a regexp handling sequence - - -# Attributes -## text[RW] [](#attribute-i-text) -Regexp handling text - -## type[RW] [](#attribute-i-type) -Regexp handling type - - -#Instance Methods -## ==(o) [](#method-i-==) -Regexp handlings are equal when the have the same text and type - -## initialize(type, text) [](#method-i-initialize) -Creates a new regexp handling sequence of `type` with `text` - -**@return** [RegexpHandling] a new instance of RegexpHandling - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/RDoc/Markup/Rule.md b/example/ruby/RDoc/Markup/Rule.md deleted file mode 100644 index 10345ae..0000000 --- a/example/ruby/RDoc/Markup/Rule.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: RDoc::Markup::Rule -**Inherits:** Struct - - -A horizontal rule with a weight - - -# Attributes -## weight[RW] [](#attribute-i-weight) -Returns the value of attribute weight - -**@return** [Object] the current value of weight - - -#Instance Methods -## accept(visitor) [](#method-i-accept) -Calls #accept_rule on `visitor` - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/RDoc/Markup/Table.md b/example/ruby/RDoc/Markup/Table.md deleted file mode 100644 index 566923a..0000000 --- a/example/ruby/RDoc/Markup/Table.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: RDoc::Markup::Table -**Inherits:** Object - - -A section of table - - -# Attributes -## align[RW] [](#attribute-i-align) -alignments of each column - -## body[RW] [](#attribute-i-body) -body texts of each column - -## header[RW] [](#attribute-i-header) -headers of each column - - -#Instance Methods -## ==(other) [](#method-i-==) -:stopdoc: - -## accept(visitor) [](#method-i-accept) - -## initialize(header, align, body) [](#method-i-initialize) -Creates new instance - -**@return** [Table] a new instance of Table - -## pretty_print(q) [](#method-i-pretty_print) - diff --git a/example/ruby/RDoc/Markup/TextFormatterTestCase.md b/example/ruby/RDoc/Markup/TextFormatterTestCase.md deleted file mode 100644 index 952e01e..0000000 --- a/example/ruby/RDoc/Markup/TextFormatterTestCase.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: RDoc::Markup::TextFormatterTestCase -**Inherits:** RDoc::Markup::FormatterTestCase - - -Test case for creating new plain-text RDoc::Markup formatters. See also -RDoc::Markup::FormatterTestCase - -See test_rdoc_markup_to_rdoc.rb for a complete example. - -Example: - - class TestRDocMarkupToNewTextFormat < RDoc::Markup::TextFormatterTestCase - - add_visitor_tests - add_text_tests - - def setup - super - - @to = RDoc::Markup::ToNewTextFormat.new - end - - def accept_blank_line - assert_equal :junk, @to.res.join - end - - # ... - - end - - -# Class Methods -## add_text_tests() [](#method-c-add_text_tests) -Adds test cases to the calling TestCase. - diff --git a/example/ruby/RDoc/Markup/ToAnsi.md b/example/ruby/RDoc/Markup/ToAnsi.md deleted file mode 100644 index 077454d..0000000 --- a/example/ruby/RDoc/Markup/ToAnsi.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: RDoc::Markup::ToAnsi -**Inherits:** RDoc::Markup::ToRdoc - - -Outputs RDoc markup with vibrant ANSI color! - - - -#Instance Methods -## accept_list_item_end(list_item) [](#method-i-accept_list_item_end) -Overrides indent width to ensure output lines up correctly. - -## accept_list_item_start(list_item) [](#method-i-accept_list_item_start) -Adds coloring to note and label list items - -## init_tags() [](#method-i-init_tags) -Maps attributes to ANSI sequences - -## initialize(markupnil) [](#method-i-initialize) -Creates a new ToAnsi visitor that is ready to output vibrant ANSI color! - -**@return** [ToAnsi] a new instance of ToAnsi - -## start_accepting() [](#method-i-start_accepting) -Starts accepting with a reset screen - diff --git a/example/ruby/RDoc/Markup/ToBs.md b/example/ruby/RDoc/Markup/ToBs.md deleted file mode 100644 index 8237eb5..0000000 --- a/example/ruby/RDoc/Markup/ToBs.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: RDoc::Markup::ToBs -**Inherits:** RDoc::Markup::ToRdoc - - -Outputs RDoc markup with hot backspace action! You will probably need a pager -to use this output format. - -This formatter won't work on 1.8.6 because it lacks String#chars. - - - -#Instance Methods -## accept_heading(heading) [](#method-i-accept_heading) -Makes heading text bold. - -## accept_list_item_start(list_item) [](#method-i-accept_list_item_start) -Prepares the visitor for consuming `list_item` - -## annotate(tag) [](#method-i-annotate) -Turns on or off regexp handling for `convert_string` - -## convert_regexp_handling(target) [](#method-i-convert_regexp_handling) -Calls convert_string on the result of convert_regexp_handling - -## convert_string(string) [](#method-i-convert_string) -Adds bold or underline mixed with backspaces - -## init_tags() [](#method-i-init_tags) -Sets a flag that is picked up by #annotate to do the right thing in -#convert_string - -## initialize(markupnil) [](#method-i-initialize) -Returns a new ToBs that is ready for hot backspace action! - -**@return** [ToBs] a new instance of ToBs - diff --git a/example/ruby/RDoc/Markup/ToHtml.md b/example/ruby/RDoc/Markup/ToHtml.md deleted file mode 100644 index 404d258..0000000 --- a/example/ruby/RDoc/Markup/ToHtml.md +++ /dev/null @@ -1,177 +0,0 @@ -# Class: RDoc::Markup::ToHtml -**Inherits:** RDoc::Markup::Formatter - -**Includes:** RDoc::Text - - -Outputs RDoc markup as HTML. - - -# Attributes -## code_object[RW] [](#attribute-i-code_object) -The RDoc::CodeObject HTML is being generated for. This is used to generate -namespaced URI fragments - -## from_path[RW] [](#attribute-i-from_path) -Path to this document for relative links - -## in_list_entry[RW] [](#attribute-i-in_list_entry) -:nodoc: - -## list[RW] [](#attribute-i-list) -:nodoc: - -## res[RW] [](#attribute-i-res) -:nodoc: - - -#Instance Methods -## accept_blank_line(blank_line) [](#method-i-accept_blank_line) -Adds `blank_line` to the output - -## accept_block_quote(block_quote) [](#method-i-accept_block_quote) -Adds `block_quote` to the output - -## accept_heading(heading) [](#method-i-accept_heading) -Adds `heading` to the output. The headings greater than 6 are trimmed to -level 6. - -## accept_list_end(list) [](#method-i-accept_list_end) -Finishes consumption of `list` - -## accept_list_item_end(list_item) [](#method-i-accept_list_item_end) -Finishes consumption of `list_item` - -## accept_list_item_start(list_item) [](#method-i-accept_list_item_start) -Prepares the visitor for consuming `list_item` - -## accept_list_start(list) [](#method-i-accept_list_start) -Prepares the visitor for consuming `list` - -## accept_paragraph(paragraph) [](#method-i-accept_paragraph) -Adds `paragraph` to the output - -## accept_raw(raw) [](#method-i-accept_raw) -Adds `raw` to the output - -## accept_rule(rule) [](#method-i-accept_rule) -Adds `rule` to the output - -## accept_table(header, body, aligns) [](#method-i-accept_table) -Adds `table` to the output - -## accept_verbatim(verbatim) [](#method-i-accept_verbatim) -Adds `verbatim` to the output - -## convert_string(text) [](#method-i-convert_string) -CGI-escapes `text` - -## end_accepting() [](#method-i-end_accepting) -Returns the generated output - -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## gen_url(url, text) [](#method-i-gen_url) -Generate a link to `url` with content `text`. Handles the special cases for -img: and link: described under handle_regexp_HYPERLINK - -## handle_RDOCLINK(url) [](#method-i-handle_RDOCLINK) -:nodoc: - -## handle_regexp_HARD_BREAK(target) [](#method-i-handle_regexp_HARD_BREAK) -`target` is a `
` - -## handle_regexp_HYPERLINK(target) [](#method-i-handle_regexp_HYPERLINK) -`target` is a potential link. The following schemes are handled: - -`mailto:` -: Inserted as-is. - -`http:` -: Links are checked to see if they reference an image. If so, that image - gets inserted using an `` tag. Otherwise a conventional `
` is - used. - -`link:` -: Reference to a local file relative to the output directory. - - -## handle_regexp_RDOCLINK(target) [](#method-i-handle_regexp_RDOCLINK) -`target` is an rdoc-schemed link that will be converted into a hyperlink. - -For the `rdoc-ref` scheme the named reference will be returned without -creating a link. - -For the `rdoc-label` scheme the footnote and label prefixes are stripped when -creating a link. All other contents will be linked verbatim. - -## handle_regexp_TIDYLINK(target) [](#method-i-handle_regexp_TIDYLINK) -This `target` is a link where the label is different from the URL `label[url]` -or `{long label}[url]` - -## html_list_name(list_type, open_tag) [](#method-i-html_list_name) -Determines the HTML list element for `list_type` and `open_tag` - -**@raise** [RDoc::Error] - -## init_link_notation_regexp_handlings() [](#method-i-init_link_notation_regexp_handlings) -Adds regexp handlings about link notations. - -## init_regexp_handlings() [](#method-i-init_regexp_handlings) -Adds regexp handlings. - -## init_tags() [](#method-i-init_tags) -Maps attributes to HTML tags - -## initialize(options, markupnil) [](#method-i-initialize) -Creates a new formatter that will output HTML - -**@return** [ToHtml] a new instance of ToHtml - -## list_end_for(list_type) [](#method-i-list_end_for) -Returns the HTML end-tag for `list_type` - -## list_item_start(list_item, list_type) [](#method-i-list_item_start) -Returns the HTML tag for `list_type`, possible using a label from `list_item` - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## parse(text, format'rdoc') [](#method-i-parse) -Normalizes `text` then builds a RDoc::Markup::Document from it - -## parseable?(text) [](#method-i-parseable?) -Returns true if text is valid ruby syntax - -**@return** [Boolean] - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## start_accepting() [](#method-i-start_accepting) -Prepares the visitor for HTML generation - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## to_html(item) [](#method-i-to_html) -Converts `item` to HTML using RDoc::Text#to_html - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/RDoc/Markup/ToHtmlCrossref.md b/example/ruby/RDoc/Markup/ToHtmlCrossref.md deleted file mode 100644 index 416f669..0000000 --- a/example/ruby/RDoc/Markup/ToHtmlCrossref.md +++ /dev/null @@ -1,63 +0,0 @@ -# Class: RDoc::Markup::ToHtmlCrossref -**Inherits:** RDoc::Markup::ToHtml - - -Subclass of the RDoc::Markup::ToHtml class that supports looking up method -names, classes, etc to create links. RDoc::CrossReference is used to generate -those links based on the current context. - - -# Attributes -## context[RW] [](#attribute-i-context) -RDoc::CodeObject for generating references - -## show_hash[RW] [](#attribute-i-show_hash) -Should we show '#' characters on method references? - - -#Instance Methods -## convert_flow(flow) [](#method-i-convert_flow) - -## cross_reference(name, textnil, codetrue, rdoc_ref:false) [](#method-i-cross_reference) -Creates a link to the reference `name` if the name exists. If `text` is given -it is used as the link text, otherwise `name` is used. - -## gen_url(url, text) [](#method-i-gen_url) -Generates links for `rdoc-ref:` scheme URLs and allows RDoc::Markup::ToHtml to -handle other schemes. - -## handle_regexp_CROSSREF(target) [](#method-i-handle_regexp_CROSSREF) -We're invoked when any text matches the CROSSREF pattern. If we find the -corresponding reference, generate a link. If the name we're looking for -contains no punctuation, we look for it up the module/class chain. For -example, ToHtml is found, even without the `RDoc::Markup::` prefix, because we -look for it in module Markup first. - -## handle_regexp_HYPERLINK(target) [](#method-i-handle_regexp_HYPERLINK) -Handles `rdoc-ref:` scheme links and allows RDoc::Markup::ToHtml to handle -other schemes. - -## handle_regexp_RDOCLINK(target) [](#method-i-handle_regexp_RDOCLINK) -`target` is an rdoc-schemed link that will be converted into a hyperlink. For -the rdoc-ref scheme the cross-reference will be looked up and the given name -will be used. - -All other contents are handled by [the -superclass](rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK) - -## init_link_notation_regexp_handlings() [](#method-i-init_link_notation_regexp_handlings) -:nodoc: - -## initialize(options, from_path, context, markupnil) [](#method-i-initialize) -Creates a new crossref resolver that generates links relative to `context` -which lives at `from_path` in the generated files. '#' characters on -references are removed unless `show_hash` is true. Only method names preceded -by '#' or '::' are linked, unless `hyperlink_all` is true. - -**@raise** [ArgumentError] - -**@return** [ToHtmlCrossref] a new instance of ToHtmlCrossref - -## link(name, text, codetrue, rdoc_ref:false) [](#method-i-link) -Creates an HTML link to `name` with the given `text`. - diff --git a/example/ruby/RDoc/Markup/ToHtmlSnippet.md b/example/ruby/RDoc/Markup/ToHtmlSnippet.md deleted file mode 100644 index b0740fc..0000000 --- a/example/ruby/RDoc/Markup/ToHtmlSnippet.md +++ /dev/null @@ -1,89 +0,0 @@ -# Class: RDoc::Markup::ToHtmlSnippet -**Inherits:** RDoc::Markup::ToHtml - - -Outputs RDoc markup as paragraphs with inline markup only. - - -# Attributes -## character_limit[RW] [](#attribute-i-character_limit) -After this many characters the input will be cut off. - -## characters[RW] [](#attribute-i-characters) -The number of characters seen so far. - -## mask[RW] [](#attribute-i-mask) -The attribute bitmask - -## paragraph_limit[RW] [](#attribute-i-paragraph_limit) -After this many paragraphs the input will be cut off. - -## paragraphs[RW] [](#attribute-i-paragraphs) -Count of paragraphs found - - -#Instance Methods -## accept_heading(heading) [](#method-i-accept_heading) -Adds `heading` to the output as a paragraph - -## accept_list_item_end(list_item) [](#method-i-accept_list_item_end) -Finishes consumption of `list_item` - -## accept_list_item_start(list_item) [](#method-i-accept_list_item_start) -Prepares the visitor for consuming `list_item` - -## accept_list_start(list) [](#method-i-accept_list_start) -Prepares the visitor for consuming `list` - -## accept_paragraph(paragraph) [](#method-i-accept_paragraph) -Adds `paragraph` to the output - -## accept_verbatim(verbatim) [](#method-i-accept_verbatim) -Adds `verbatim` to the output - -## add_paragraph() [](#method-i-add_paragraph) -Throws `:done` when paragraph_limit paragraphs have been encountered - -## convert(content) [](#method-i-convert) -Marks up `content` - -## convert_flow(flow) [](#method-i-convert_flow) -Converts flow items `flow` - -## gen_url(url, text) [](#method-i-gen_url) -Returns just the text of `link`, `url` is only used to determine the link -type. - -## handle_regexp_CROSSREF(target) [](#method-i-handle_regexp_CROSSREF) -Removes escaping from the cross-references in `target` - -## handle_regexp_HARD_BREAK(target) [](#method-i-handle_regexp_HARD_BREAK) -`target` is a `
` - -## html_list_name(list_type, open_tag) [](#method-i-html_list_name) -In snippets, there are no lists - -## initialize(options, characters100, paragraphs3, markupnil) [](#method-i-initialize) -Creates a new ToHtmlSnippet formatter that will cut off the input on the next -word boundary after the given number of `characters` or `paragraphs` of text -have been encountered. - -**@return** [ToHtmlSnippet] a new instance of ToHtmlSnippet - -## list_item_start(list_item, list_type) [](#method-i-list_item_start) -Lists are paragraphs, but notes and labels have a separator - -## off_tags(res, item) [](#method-i-off_tags) -Maintains a bitmask to allow HTML elements to be closed properly. See -RDoc::Markup::Formatter. - -## on_tags(res, item) [](#method-i-on_tags) -Maintains a bitmask to allow HTML elements to be closed properly. See -RDoc::Markup::Formatter. - -## start_accepting() [](#method-i-start_accepting) -Prepares the visitor for HTML snippet generation - -## truncate(text) [](#method-i-truncate) -Truncates `text` at the end of the first word after the character_limit. - diff --git a/example/ruby/RDoc/Markup/ToJoinedParagraph.md b/example/ruby/RDoc/Markup/ToJoinedParagraph.md deleted file mode 100644 index 633a173..0000000 --- a/example/ruby/RDoc/Markup/ToJoinedParagraph.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: RDoc::Markup::ToJoinedParagraph -**Inherits:** RDoc::Markup::Formatter - - -Joins the parts of an RDoc::Markup::Paragraph into a single String. - -This allows for easier maintenance and testing of Markdown support. - -This formatter only works on Paragraph instances. Attempting to process other -markup syntax items will not work. - - - -#Instance Methods -## accept_paragraph(paragraph) [](#method-i-accept_paragraph) -Converts the parts of `paragraph` to a single entry. - -## end_accepting() [](#method-i-end_accepting) -:nodoc: - -## initialize() [](#method-i-initialize) -:nodoc: - -**@return** [ToJoinedParagraph] a new instance of ToJoinedParagraph - -## start_accepting() [](#method-i-start_accepting) -:nodoc: - diff --git a/example/ruby/RDoc/Markup/ToLabel.md b/example/ruby/RDoc/Markup/ToLabel.md deleted file mode 100644 index 90c3364..0000000 --- a/example/ruby/RDoc/Markup/ToLabel.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: RDoc::Markup::ToLabel -**Inherits:** RDoc::Markup::Formatter - - -Creates HTML-safe labels suitable for use in id attributes. Tidylinks are -converted to their link part and cross-reference links have the suppression -marks removed (\SomeClass is converted to SomeClass). - - -# Attributes -## res[RW] [](#attribute-i-res) -:nodoc: - - -#Instance Methods -## convert(text) [](#method-i-convert) -Converts `text` to an HTML-safe label - -## handle_regexp_CROSSREF(target) [](#method-i-handle_regexp_CROSSREF) -Converts the CROSSREF `target` to plain text, removing the suppression marker, -if any - -## handle_regexp_TIDYLINK(target) [](#method-i-handle_regexp_TIDYLINK) -Converts the TIDYLINK `target` to just the text part - -## initialize(markupnil) [](#method-i-initialize) -Creates a new formatter that will output HTML-safe labels - -**@return** [ToLabel] a new instance of ToLabel - diff --git a/example/ruby/RDoc/Markup/ToMarkdown.md b/example/ruby/RDoc/Markup/ToMarkdown.md deleted file mode 100644 index c3eb048..0000000 --- a/example/ruby/RDoc/Markup/ToMarkdown.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: RDoc::Markup::ToMarkdown -**Inherits:** RDoc::Markup::ToRdoc - - -Outputs parsed markup as Markdown - - - -#Instance Methods -## accept_list_end(list) [](#method-i-accept_list_end) -Finishes consumption of `list` - -## accept_list_item_end(list_item) [](#method-i-accept_list_item_end) -Finishes consumption of `list_item` - -## accept_list_item_start(list_item) [](#method-i-accept_list_item_start) -Prepares the visitor for consuming `list_item` - -## accept_list_start(list) [](#method-i-accept_list_start) -Prepares the visitor for consuming `list` - -## accept_rule(rule) [](#method-i-accept_rule) -Adds `rule` to the output - -## accept_verbatim(verbatim) [](#method-i-accept_verbatim) -Outputs `verbatim` indented 4 columns - -## gen_url(url, text) [](#method-i-gen_url) -Creates a Markdown-style URL from `url` with `text`. - -## handle_rdoc_link(url) [](#method-i-handle_rdoc_link) -Handles `rdoc-` type links for footnotes. - -## handle_regexp_HARD_BREAK(target) [](#method-i-handle_regexp_HARD_BREAK) -Adds a newline to the output - -## handle_regexp_RDOCLINK(target) [](#method-i-handle_regexp_RDOCLINK) -Converts the rdoc-...: links into a Markdown.style links. - -## handle_regexp_TIDYLINK(target) [](#method-i-handle_regexp_TIDYLINK) -Converts the RDoc markup tidylink into a Markdown.style link. - -## init_tags() [](#method-i-init_tags) -Maps attributes to HTML sequences - -## initialize(markupnil) [](#method-i-initialize) -Creates a new formatter that will output Markdown format text - -**@return** [ToMarkdown] a new instance of ToMarkdown - diff --git a/example/ruby/RDoc/Markup/ToRdoc.md b/example/ruby/RDoc/Markup/ToRdoc.md deleted file mode 100644 index ac624da..0000000 --- a/example/ruby/RDoc/Markup/ToRdoc.md +++ /dev/null @@ -1,100 +0,0 @@ -# Class: RDoc::Markup::ToRdoc -**Inherits:** RDoc::Markup::Formatter - - -Outputs RDoc markup as RDoc markup! (mostly) - - -# Attributes -## indent[RW] [](#attribute-i-indent) -Current indent amount for output in characters - -## list_index[RW] [](#attribute-i-list_index) -Stack of current list indexes for alphabetic and numeric lists - -## list_type[RW] [](#attribute-i-list_type) -Stack of list types - -## list_width[RW] [](#attribute-i-list_width) -Stack of list widths for indentation - -## prefix[RW] [](#attribute-i-prefix) -Prefix for the next list item. See #use_prefix - -## res[RW] [](#attribute-i-res) -Output accumulator - -## width[RW] [](#attribute-i-width) -Output width in characters - - -#Instance Methods -## accept_blank_line(blank_line) [](#method-i-accept_blank_line) -Adds `blank_line` to the output - -## accept_block_quote(block_quote) [](#method-i-accept_block_quote) -Adds `paragraph` to the output - -## accept_heading(heading) [](#method-i-accept_heading) -Adds `heading` to the output - -## accept_indented_paragraph(paragraph) [](#method-i-accept_indented_paragraph) -Adds `paragraph` to the output - -## accept_list_end(list) [](#method-i-accept_list_end) -Finishes consumption of `list` - -## accept_list_item_end(list_item) [](#method-i-accept_list_item_end) -Finishes consumption of `list_item` - -## accept_list_item_start(list_item) [](#method-i-accept_list_item_start) -Prepares the visitor for consuming `list_item` - -## accept_list_start(list) [](#method-i-accept_list_start) -Prepares the visitor for consuming `list` - -## accept_paragraph(paragraph) [](#method-i-accept_paragraph) -Adds `paragraph` to the output - -## accept_raw(raw) [](#method-i-accept_raw) -Adds `raw` to the output - -## accept_rule(rule) [](#method-i-accept_rule) -Adds `rule` to the output - -## accept_table(header, body, aligns) [](#method-i-accept_table) -Adds `table` to the output - -## accept_verbatim(verbatim) [](#method-i-accept_verbatim) -Outputs `verbatim` indented 2 columns - -## attributes(text) [](#method-i-attributes) -Applies attribute-specific markup to `text` using RDoc::AttributeManager - -## end_accepting() [](#method-i-end_accepting) -Returns the generated output - -## handle_regexp_HARD_BREAK(target) [](#method-i-handle_regexp_HARD_BREAK) -Adds a newline to the output - -## handle_regexp_SUPPRESSED_CROSSREF(target) [](#method-i-handle_regexp_SUPPRESSED_CROSSREF) -Removes preceding \ from the suppressed crossref `target` - -## init_tags() [](#method-i-init_tags) -Maps attributes to HTML sequences - -## initialize(markupnil) [](#method-i-initialize) -Creates a new formatter that will output (mostly) RDoc markup - -**@return** [ToRdoc] a new instance of ToRdoc - -## start_accepting() [](#method-i-start_accepting) -Prepares the visitor for text generation - -## use_prefix() [](#method-i-use_prefix) -Adds the stored #prefix to the output and clears it. Lists generate a prefix -for later consumption. - -## wrap(text) [](#method-i-wrap) -Wraps `text` to #width - diff --git a/example/ruby/RDoc/Markup/ToTableOfContents.md b/example/ruby/RDoc/Markup/ToTableOfContents.md deleted file mode 100644 index feacc84..0000000 --- a/example/ruby/RDoc/Markup/ToTableOfContents.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: RDoc::Markup::ToTableOfContents -**Inherits:** RDoc::Markup::Formatter - - -Extracts just the RDoc::Markup::Heading elements from a RDoc::Markup::Document -to help build a table of contents - - -# Class Methods -## to_toc() [](#method-c-to_toc) -Singleton for table-of-contents generation -# Attributes -## omit_headings_below[RW] [](#attribute-i-omit_headings_below) -Omits headings with a level less than the given level. - -## res[RW] [](#attribute-i-res) -Output accumulator - - -#Instance Methods -## accept_document(document) [](#method-i-accept_document) -Adds `document` to the output, using its heading cutoff if present - -## accept_heading(heading) [](#method-i-accept_heading) -Adds `heading` to the table of contents - -## end_accepting() [](#method-i-end_accepting) -Returns the table of contents - -## initialize() [](#method-i-initialize) -:nodoc: - -**@return** [ToTableOfContents] a new instance of ToTableOfContents - -## start_accepting() [](#method-i-start_accepting) -Prepares the visitor for text generation - -## suppressed?(heading) [](#method-i-suppressed?) -Returns true if `heading` is below the display threshold - -**@return** [Boolean] - diff --git a/example/ruby/RDoc/Markup/ToTest.md b/example/ruby/RDoc/Markup/ToTest.md deleted file mode 100644 index 22856a7..0000000 --- a/example/ruby/RDoc/Markup/ToTest.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: RDoc::Markup::ToTest -**Inherits:** RDoc::Markup::Formatter - - -This Markup outputter is used for testing purposes. - - - -#Instance Methods -## accept_blank_line(blank_line) [](#method-i-accept_blank_line) - -## accept_heading(heading) [](#method-i-accept_heading) - -## accept_list_end(list) [](#method-i-accept_list_end) - -## accept_list_item_end(list_item) [](#method-i-accept_list_item_end) - -## accept_list_item_start(list_item) [](#method-i-accept_list_item_start) - -## accept_list_start(list) [](#method-i-accept_list_start) - -## accept_paragraph(paragraph) [](#method-i-accept_paragraph) - -## accept_raw(raw) [](#method-i-accept_raw) - -## accept_rule(rule) [](#method-i-accept_rule) - -## accept_verbatim(verbatim) [](#method-i-accept_verbatim) - -## end_accepting() [](#method-i-end_accepting) - -## start_accepting() [](#method-i-start_accepting) -:section: Visitor - diff --git a/example/ruby/RDoc/Markup/ToTtOnly.md b/example/ruby/RDoc/Markup/ToTtOnly.md deleted file mode 100644 index cf8281b..0000000 --- a/example/ruby/RDoc/Markup/ToTtOnly.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: RDoc::Markup::ToTtOnly -**Inherits:** RDoc::Markup::Formatter - - -Extracts sections of text enclosed in plus, tt or code. Used to discover -undocumented parameters. - - -# Attributes -## list_type[RW] [](#attribute-i-list_type) -Stack of list types - -## res[RW] [](#attribute-i-res) -Output accumulator - - -#Instance Methods -## accept_block_quote(block_quote) [](#method-i-accept_block_quote) -Adds tts from `block_quote` to the output - -## accept_list_end(list) [](#method-i-accept_list_end) -Pops the list type for `list` from #list_type - -## accept_list_item_start(list_item) [](#method-i-accept_list_item_start) -Prepares the visitor for consuming `list_item` - -## accept_list_start(list) [](#method-i-accept_list_start) -Pushes the list type for `list` onto #list_type - -## accept_paragraph(paragraph) [](#method-i-accept_paragraph) -Adds `paragraph` to the output - -## do_nothing(markup_item) [](#method-i-do_nothing) -Does nothing to `markup_item` because it doesn't have any user-built content - -## end_accepting() [](#method-i-end_accepting) -Returns an Array of items that were wrapped in plus, tt or code. - -## initialize(markupnil) [](#method-i-initialize) -Creates a new tt-only formatter. - -**@return** [ToTtOnly] a new instance of ToTtOnly - -## start_accepting() [](#method-i-start_accepting) -Prepares the visitor for gathering tt sections - -## tt_sections(text) [](#method-i-tt_sections) -Extracts tt sections from `text` - diff --git a/example/ruby/RDoc/Markup/Verbatim.md b/example/ruby/RDoc/Markup/Verbatim.md deleted file mode 100644 index b58f2c1..0000000 --- a/example/ruby/RDoc/Markup/Verbatim.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: RDoc::Markup::Verbatim -**Inherits:** RDoc::Markup::Raw - - -A section of verbatim text - - -# Attributes -## format[RW] [](#attribute-i-format) -Format of this verbatim section - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## accept(visitor) [](#method-i-accept) -Calls #accept_verbatim on `visitor` - -## initialize(*parts) [](#method-i-initialize) -:nodoc: - -**@return** [Verbatim] a new instance of Verbatim - -## normalize() [](#method-i-normalize) -Collapses 3+ newlines into two newlines - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## ruby?() [](#method-i-ruby?) -Is this verbatim section Ruby code? - -**@return** [Boolean] - -## text() [](#method-i-text) -The text of the section - diff --git a/example/ruby/RDoc/MarkupReference.md b/example/ruby/RDoc/MarkupReference.md deleted file mode 100644 index 947e126..0000000 --- a/example/ruby/RDoc/MarkupReference.md +++ /dev/null @@ -1,1212 +0,0 @@ -# Class: RDoc::MarkupReference -**Inherits:** Object - - -Class RDoc::MarkupReference exists only to provide a suitable home for a -reference document for RDoc markup. - -All objects defined in this class -- classes, modules, methods, aliases, -attributes, and constants -- are solely for illustrating RDoc markup, and have -no other legitimate use. - -## About the Examples - -* Examples in this reference are Ruby code and comments; certain differences - from other sources (such as C code and comments) are noted. -* Almost all examples on this page are all RDoc-like; that is, they have no - explicit comment markers like Ruby `#` or C `/* ... */`. -* An example that shows rendered HTML output displays that output in a - blockquote: - -> Some stuff - -> ## RDoc Sources - -The sources of RDoc documentation vary according to the type of file: - -* `.rb` (Ruby code file): - - * Markup may be found in Ruby comments: A comment that immediately - precedes the definition of a Ruby class, module, method, alias, - constant, or attribute becomes the documentation for that defined - object. - * An RDoc directive may be found in: - - * A trailing comment (on the same line as code); see `:nodoc:`, - `:doc:`, and `:notnew:`. - * A single-line comment; see other - [Directives](rdoc-ref:RDoc::MarkupReference@Directives). - - * Documentation may be derived from the Ruby code itself; see - [Documentation Derived from Ruby - Code](rdoc-ref:RDoc::MarkupReference@Documentation+Derived+from+Ruby+C - ode). - -* `.c` (C code file): markup is parsed from C comments. A comment that - immediately precedes a function that implements a Ruby method, or - otherwise immediately precedes the definition of a Ruby object, becomes - the documentation for that object. -* `.rdoc` (RDoc markup text file) or `.md` (RDoc markdown text file): markup - is parsed from the entire file. The text is not associated with any code - object, but may (depending on how the documentation is built) become a - separate page. - -An *RDoc document*: - -* A (possibly multi-line) comment in a Ruby or C file that generates RDoc - documentation (as above). -* The entire markup (`.rdoc`) file or markdown (`.md`) file (which is - usually multi-line). - -### Blocks - -It's convenient to think of an RDoc document as a sequence of *blocks* of -various types (details at the links): - -* [Paragraph](rdoc-ref:RDoc::MarkupReference@Paragraphs): an ordinary - paragraph. -* [Verbatim text - block](rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks): a block of - text to be rendered literally. -* [Code block](rdoc-ref:RDoc::MarkupReference@Code+Blocks): a verbatim text - block containing Ruby code, to be rendered with code highlighting. -* [Block quote](rdoc-ref:RDoc::MarkupReference@Block+Quotes): a longish - quoted passage, to be rendered with indentation instead of quote marks. -* [List](rdoc-ref:RDoc::MarkupReference@Lists): items for a bullet list, - numbered list, lettered list, or labeled list. -* [Heading](rdoc-ref:RDoc::MarkupReference@Headings): a heading. -* [Horizontal rule](rdoc-ref:RDoc::MarkupReference@Horizontal+Rules): a line - across the rendered page. -* [Directive](rdoc-ref:RDoc::MarkupReference@Directives): various special - directions for the rendering. -* [Text Markup](rdoc-ref:RDoc:MarkupReference@Text+Markup): text to be - rendered in a special way. - -About the blocks: - -* Except for a paragraph, a block is distinguished by its indentation, or by - unusual initial or embedded characters. -* Any block may appear independently (that is, not nested in another block); - some blocks may be nested, as detailed below. -* In a multi-line block, RDoc looks for the block's natural left margin, - which becomes the *base margin* for the block and is the initial *current - margin* for the block. - -#### Paragraphs - -A paragraph consists of one or more non-empty lines of ordinary text, each -beginning at the current margin. - -Note: Here, *ordinary text* means text that is *not identified* by -indentation, or by unusual initial or embedded characters. See below. - -Paragraphs are separated by one or more empty lines. - -Example input: - - \RDoc produces HTML and command-line documentation for Ruby projects. - \RDoc includes the rdoc and ri tools for generating and displaying - documentation from the command-line. - - You'll love it. - -Rendered HTML: -> RDoc produces HTML and command-line documentation for Ruby projects. RDoc - includes the rdoc and ri tools for generating and displaying documentation - from the command-line. - -> You'll love it. - -> A paragraph may contain nested blocks, including: - -* [Verbatim text - blocks](rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks). -* [Code blocks](rdoc-ref:RDoc::MarkupReference@Code+Blocks). -* [Block quotes](rdoc-ref:RDoc::MarkupReference@Block+Quotes). -* [Lists](rdoc-ref:RDoc::MarkupReference@Lists). -* [Headings](rdoc-ref:RDoc::MarkupReference@Headings). -* [Horizontal rules](rdoc-ref:RDoc::MarkupReference@Horizontal+Rules). -* [Text Markup](rdoc-ref:RDoc:MarkupReference@Text+Markup). - -#### Verbatim Text Blocks - -Text indented farther than the current margin becomes a *verbatim text block* -(or a code block, described next). In the rendered HTML, such text: - -* Is indented. -* Has a contrasting background color. - -The verbatim text block ends at the first line beginning at the current -margin. - -Example input: - - This is not verbatim text. - - This is verbatim text. - Whitespace is honored. # See? - Whitespace is honored. # See? - - This is still the same verbatim text block. - - This is not verbatim text. - -Rendered HTML: -> This is not verbatim text. - - This is verbatim text. - Whitespace is honored. # See? - Whitespace is honored. # See? - - This is still the same verbatim text block. - -> This is not verbatim text. - -> A verbatim text block may not contain nested blocks of any kind -- it's -verbatim. - -#### Code Blocks - -A special case of verbatim text is the *code block*, which is merely verbatim -text that RDoc recognizes as Ruby code: - -In the rendered HTML, the code block: - -* Is indented. -* Has a contrasting background color. -* Has syntax highlighting. - -Example input: - - Consider this method: - - def foo(name = '', value = 0) - @name = name # Whitespace is still honored. - @value = value - end - -Rendered HTML: -> Consider this method: - - def foo(name = '', value = 0) - @name = name # Whitespace is still honored. - @value = value - end - -> Pro tip: If your indented Ruby code does not get highlighted, it may contain -a syntax error. - -A code block may not contain nested blocks of any kind -- it's verbatim. - -#### Block Quotes - -You can use the characters `>>>` (unindented), followed by indented text, to -treat the text as a [block -quote](https://en.wikipedia.org/wiki/Block_quotation): - -Example input: - - Here's a block quote: - >>> - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer - commodo quam iaculis massa posuere, dictum fringilla justo pulvinar. - Quisque turpis erat, pharetra eu dui at, sollicitudin accumsan nulla. - - Aenean congue ligula eu ligula molestie, eu pellentesque purus - faucibus. In id leo non ligula condimentum lobortis. Duis vestibulum, - diam in pellentesque aliquet, mi tellus placerat sapien, id euismod - purus magna ut tortor. - -Rendered HTML: - -> Here's a block quote: -> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer commodo - quam iaculis massa posuere, dictum fringilla justo pulvinar. Quisque - turpis erat, pharetra eu dui at, sollicitudin accumsan nulla. - -> Aenean congue ligula eu ligula molestie, eu pellentesque purus faucibus. - In id leo non ligula condimentum lobortis. Duis vestibulum, diam in - pellentesque aliquet, mi tellus placerat sapien, id euismod purus magna ut - tortor. - -> Note that, unlike verbatim text, single newlines are not honored, but that a -double newline begins a new paragraph in the block quote. - -A block quote may contain nested blocks, including: - -* Other block quotes. -* [Paragraphs](rdoc-ref:RDoc::MarkupReference@Paragraphs). -* [Verbatim text - blocks](rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks). -* [Code blocks](rdoc-ref:RDoc::MarkupReference@Code+Blocks). -* [Lists](rdoc-ref:RDoc::MarkupReference@Lists). -* [Headings](rdoc-ref:RDoc::MarkupReference@Headings). -* [Horizontal rules](rdoc-ref:RDoc::MarkupReference@Horizontal+Rules). -* [Text Markup](rdoc-ref:RDoc:MarkupReference@Text+Markup). - -#### Lists - -Each type of list item is marked by a special beginning: - -* Bullet list item: Begins with a hyphen or asterisk. -* Numbered list item: Begins with digits and a period. -* Lettered list item: Begins with an alphabetic character and a period. -* Labeled list item: Begins with one of: - * Square-bracketed text. - * A word followed by two colons. - -A list begins with a list item and continues, even across blank lines, as long -as list items of the same type are found at the same indentation level. - -A new list resets the current margin inward. Additional lines of text aligned -at that margin are part of the continuing list item. - -A list item may be continued on additional lines that are aligned with the -first line. See examples below. - -A list item may contain nested blocks, including: - -* Other lists of any type. -* [Paragraphs](rdoc-ref:RDoc::MarkupReference@Paragraphs). -* [Verbatim text - blocks](rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks). -* [Code blocks](rdoc-ref:RDoc::MarkupReference@Code+Blocks). -* [Block quotes](rdoc-ref:RDoc::MarkupReference@Block+Quotes). -* [Headings](rdoc-ref:RDoc::MarkupReference@Headings). -* [Horizontal rules](rdoc-ref:RDoc::MarkupReference@Horizontal+Rules). -* [Text Markup](rdoc-ref:RDoc:MarkupReference@Text+Markup). - -##### Bullet Lists - -A bullet list item begins with a hyphen or asterisk. - -Example input: - - - An item. - - Another. - - An item spanning - multiple lines. - - * Yet another. - - Last one. - -Rendered HTML: - * An item. - * Another. - * An item spanning multiple lines. - - * Yet another. - * Last one. - -##### Numbered Lists - -A numbered list item begins with digits and a period. - -The items are automatically re-numbered. - -Example input: - - 100. An item. - 10. Another. - 1. An item spanning - multiple lines. - - 1. Yet another. - 1000. Last one. - -Rendered HTML: - 1. An item. - 2. Another. - 3. An item spanning multiple lines. - - 4. Yet another. - 5. Last one. - -##### Lettered Lists - -A lettered list item begins with letters and a period. - -The items are automatically "re-lettered." - -Example input: - - z. An item. - y. Another. - x. An item spanning - multiple lines. - - x. Yet another. - a. Last one. - -Rendered HTML: - 1. An item. - 2. Another. - - 3. Yet another. - 4. Last one. - -##### Labeled Lists - -A labeled list item begins with one of: - -* Square-bracketed text: the label and text are on two lines. -* A word followed by two colons: the label and text are on the same line. - -Example input: - - [foo] An item. - bat:: Another. - [bag] An item spanning - multiple lines. - - [bar baz] Yet another. - bam:: Last one. - -Rendered HTML: - foo -: An item. - - bat -: Another. - - bag -: An item spanning multiple lines. - - - bar baz -: Yet another. - - bam -: Last one. - - -#### Headings - -A heading begins with up to six equal-signs, followed by heading text. -Whitespace between those and the heading text is optional. - -Examples: - - = Section 1 - == Section 1.1 - === Section 1.1.1 - === Section 1.1.2 - == Section 1.2 - = Section 2 - = Foo - == Bar - === Baz - ==== Bam - ===== Bat - ====== Bad - ============Still a Heading (Level 6) - \== Not a Heading - -A heading may contain only one type of nested block: - -* [Text Markup](rdoc-ref:RDoc:MarkupReference@Text+Markup). - -#### Horizontal Rules - -A horizontal rule consists of a line with three or more hyphens and nothing -more. - -Example input: - - --- - --- Not a horizontal rule. - - -- Also not a horizontal rule. - --- - -Rendered HTML: -> --- -> --- Not a horizontal rule. - -> -- Also not a horizontal rule. -> --- - -> #### Directives - -##### Directives for Allowing or Suppressing Documentation - -* `# :stopdoc:`: - - * Appears on a line by itself. - * Specifies that RDoc should ignore markup until next `:startdoc:` - directive or end-of-file. - -* `# :startdoc:`: - - * Appears on a line by itself. - * Specifies that RDoc should resume parsing markup. - -* `# :enddoc:`: - - * Appears on a line by itself. - * Specifies that RDoc should ignore markup to end-of-file regardless of - other directives. - -* `# :nodoc:`: - - * Appended to a line of code that defines a class, module, method, - alias, constant, or attribute. - - * Specifies that the defined object should not be documented. - - * For a method definition in C code, it the directive must be in the - comment line immediately preceding the definition: - - /* :nodoc: */ - static VALUE - some_method(VALUE self) - { - return self; - } - - Note that this directive has *no effect at all* when placed at the - method declaration: - - /* :nodoc: */ - rb_define_method(cMyClass, "do_something", something_func, 0); - - The above comment is just a comment and has nothing to do with RDoc. - Therefore, `do_something` method will be reported as "undocumented" - unless that method or function is documented elsewhere. - - * For a constant definition in C code, this directive *can not work* - because there is no "implementation" place for a constant. - -* `# :nodoc: all`: - - * Appended to a line of code that defines a class or module. - * Specifies that the class or module should not be documented. By - default, however, a nested class or module *will* be documented. - -* `# :doc:`: - - * Appended to a line of code that defines a class, module, method, - alias, constant, or attribute. - * Specifies the defined object should be documented, even if it - otherwise would not be documented. - -* `# :notnew:` (aliased as `:not_new:` and `:not-new:`): - - * Appended to a line of code that defines instance method `initialize`. - * Specifies that singleton method `new` should not be documented. By - default, Ruby fakes a corresponding singleton method `new`, which RDoc - includes in the documentation. Note that instance method `initialize` - is private, and so by default is not documented. - -For Ruby code, but not for other RDoc sources, there is a shorthand for -`:stopdoc:` and `:startdoc:`: - - # Documented. - #-- - # Not documented. - #++ - # Documented. - -For C code, any of directives `:startdoc:`, `:stopdoc:`, and `:enddoc:` may -appear in a stand-alone comment: - - /* :startdoc: */ - /* :stopdoc: */ - /* :enddoc: */ - -##### Directive for Specifying RDoc Source Format - -* `# :markup: *type`*: - - * Appears on a line by itself. - * Specifies the format for the RDoc input; parameter `type` is one of: - `rdoc` (the default), `markdown`, `rd`, `tomdoc`. See [Markup - Formats](rdoc-ref:RDoc::Markup@Markup+Formats). - -##### Directives for Method Documentation - -* `# :call-seq:`: - - * Appears on a line by itself. - * Specifies the calling sequence to be reported in the HTML, overriding - the actual calling sequence in the code. See method - #call_seq_directive. - - Note that RDoc can build the calling sequence for a Ruby-coded method, but - not for other languages. You may want to override that by explicitly - giving a `:call-seq:` directive if you want to include: - - * A return type, which is not automatically inferred. - * Multiple calling sequences. - - For C code, the directive may appear in a stand-alone comment. - -* `# :args: *arg_names`* (aliased as `:arg:`): - - * Appears on a line by itself. - * Specifies the arguments to be reported in the HTML, overriding the - actual arguments in the code. See method #args_directive. - -* `# :yields: *arg_names`* (aliased as `:yield:`): - - * Appears on a line by itself. - * Specifies the yield arguments to be reported in the HTML, overriding - the actual yield in the code. See method #yields_directive. - -##### Directives for Organizing Documentation - -By default, RDoc groups: - -* Singleton methods together in alphabetical order. -* Instance methods and their aliases together in alphabetical order. -* Attributes and their aliases together in alphabetical order. - -You can use directives to modify those behaviors. - -* `# :section: *section_title`*: - - * Appears on a line by itself. - * Specifies that following methods are to be grouped into the section - with the given *section_title*, or into the default section if no - title is given. The directive remains in effect until another such - directive is given, but may be temporarily overridden by directive - `:category:`. See below. - - The comment block containing this directive: - - * Must be separated by a blank line from the documentation for the next - item. - * May have one or more lines preceding the directive. These will be - removed, along with any trailing lines that match them. Such lines may - be visually helpful. - * Lines of text that are not so removed become the descriptive text for - the section. - - Example: - - # ---------------------------------------- - # :section: My Section - # This is the section that I wrote. - # See it glisten in the noon-day sun. - # ---------------------------------------- - - ## - # Comment for some_method - def some_method - # ... - end - - You can use directive `:category:` to temporarily override the current - section. - -* `# :category: *section_title`*: - - * Appears on a line by itself. - * Specifies that just one following method is to be included in the - given section, or in the default section if no title is given. - Subsequent methods are to be grouped into the current section. - -##### Directive for Including a File - -* `# :include: *filepath`*: - - * Appears on a line by itself. - * Specifies that the contents of the given file are to be included at - this point. The file content is shifted to have the same indentation - as the colon at the start of the directive. - - The file is searched for in the directory containing the current file, - and then in each of the directories given with the `--include` - command-line option. - - For C code, the directive may appear in a stand-alone comment - -#### Text Markup - -Text markup is metatext that affects HTML rendering: - -* Typeface: italic, bold, monofont. -* Character conversions: copyright, trademark, certain punctuation. -* Links. -* Escapes: marking text as "not markup." - -##### Typeface Markup - -Typeface markup can specify that text is to be rendered as italic, bold, or -monofont. - -Typeface markup may contain only one type of nested block: - -* More typeface markup: italic, bold, monofont. - -###### Italic - -Text may be marked as italic via HTML tag `` or ``. - -Example input: - - Italicized words in a paragraph. - - >>> - Italicized words in a block quote. - - - Italicized words in a list item. - - ====== Italicized words in a Heading - - Italicized passage containing *bold* and +monofont+. - -Rendered HTML: -> *Italicized words* in a paragraph. - -> *Italicized words in a block quote*. - - * *Italicized words* in a list item. - -> ###### *Italicized words* in a Heading - -> *Italicized passage containing **bold** and `monofont`.* - -> A single word may be italicized via a shorthand: prefixed and suffixed -underscores. - -Example input: - - _Italic_ in a paragraph. - - >>> - _Italic_ in a block quote. - - - _Italic_ in a list item. - - ====== _Italic_ in a Heading - -Rendered HTML: -> *Italic* in a paragraph. - -> *Italic* in a block quote. - - * *Italic* in a list item. - -> ###### *Italic* in a Heading - -> ###### Bold - -Text may be marked as bold via HTML tag ``. - -Example input: - - Bold words in a paragraph. - - >>> - Bold words in a block quote. - - - Bold words in a list item. - - ====== Bold words in a Heading - - Bold passage containing _italics_ and +monofont+. - -Rendered HTML: - -> **Bold words** in a paragraph. - -> **Bold words** in a block quote. - - * **Bold words** in a list item. - -> ###### **Bold words** in a Heading - -> **Bold passage containing *italics* and `monofont`.** - -> A single word may be made bold via a shorthand: prefixed and suffixed -asterisks. - -Example input: - - *Bold* in a paragraph. - - >>> - *Bold* in a block quote. - - - *Bold* in a list item. - - ===== *Bold* in a Heading - -Rendered HTML: - -> **Bold** in a paragraph. - -> **Bold** in a block quote. - - * **Bold** in a list item. - -> ##### **Bold** in a Heading - -> ###### Monofont - -Text may be marked as monofont -- sometimes called 'typewriter font' -- via -HTML tag `` or ``. - -Example input: - - Monofont words in a paragraph. - - >>> - Monofont words in a block quote. - - - Monofont words in a list item. - - ====== Monofont words in heading - - Monofont passage containing _italics_ and *bold*. - -Rendered HTML: - -> `Monofont words` in a paragraph. - -> `Monofont words` in a block quote. - - * `Monofont words` in a list item. - -> ###### `Monofont words` in heading - -> `Monofont passage containing *italics* and **bold**.` - -> A single word may be made monofont by a shorthand: prefixed and suffixed -plus-signs. - -Example input: - - +Monofont+ in a paragraph. - - >>> - +Monofont+ in a block quote. - - - +Monofont+ in a list item. - - ====== +Monofont+ in a Heading - -Rendered HTML: - -> `Monofont` in a paragraph. - -> `Monofont` in a block quote. - - * `Monofont` in a list item. - -> ###### `Monofont` in a Heading - -> #### Character Conversions - -Certain combinations of characters may be converted to special characters; -whether the conversion occurs depends on whether the special character is -available in the current encoding. - -* `(c)` converts to (c) (copyright character); must be lowercase. - -* `(r)` converts to (r) (registered trademark character); must be lowercase. - -* `'foo'` converts to 'foo' (smart single-quotes). - -* `"foo"` converts to "foo" (smart double-quotes). - -* `foo ... bar` converts to foo ... bar (1-character ellipsis). - -* `foo -- bar` converts to foo -- bar (1-character en-dash). - -* `foo --- bar` converts to foo --- bar (1-character em-dash). - -#### Links - -Certain strings in RDoc text are converted to links. Any such link may be -suppressed by prefixing a backslash. This section shows how to link to various -targets. - - * On-page: `DummyClass` links to DummyClass. - * Off-page: `RDoc::Alias` links to RDoc::Alias. - - - * On-page: `DummyModule` links to DummyModule. - * Off-page: `RDoc` links to RDoc. - - - * On-page: `DUMMY_CONSTANT` links to DUMMY_CONSTANT. - * Off-page: `RDoc::Text::MARKUP_FORMAT` links to - RDoc::Text::MARKUP_FORMAT. - - - * On-page: `::dummy_singleton_method` links to ::dummy_singleton_method. - * Off-page`RDoc::TokenStream::to_html` links to - RDoc::TokenStream::to_html. - - Note: Occasionally RDoc is not linked to a method whose name has only - special characters. Check whether the links you were expecting are - actually there. If not, you'll need to put in an explicit link; see - below. - - Pro tip: The link to any method is available in the alphabetical table of - contents at the top left of the page for the class or module. - - - * On-page: `#dummy_instance_method` links to #dummy_instance_method. - * Off-page: `RDoc::Alias#html_name` links to RDoc::Alias#html_name. - - See the Note and Pro Tip immediately above. - - - * On-page: `#dummy_attribute` links to #dummy_attribute. - * Off-page: `RDoc::Alias#name` links to RDoc::Alias#name. - - - * On-page: `#dummy_instance_alias` links to #dummy_instance_alias. - * Off-page: `RDoc::Alias#new_name` links to RDoc::Alias#new_name. - - - * Linked: `http://yahoo.com` links to http://yahoo.com. - - - * Linked: `https://github.com` links to https://github.com. - - - * Linked: `ftp://nosuch.site` links to ftp://nosuch.site. - - - * Linked: `mailto:/foo@bar.com` links to mailto://foo@bar.com. - - - * link: `irc://irc.freenode.net/ruby` links to - irc://irc.freenode.net/ruby. - - - * Link: `https://www.ruby-lang.org/images/header-ruby-logo@2x.png` is - converted to an in-line HTML `img` tag, which displays the image in - the HTML: - - https://www.ruby-lang.org/images/header-ruby-logo@2x.png - - Also works for `bmp`, `gif`, `jpeg`, and `jpg` files. - - Note: Works only for a fully qualified URL. - - - * Link: `RDoc::RD@LICENSE` links to RDoc::RDoc::RD@LICENSE. - - Note that spaces in the actual heading are represented by `+` characters - in the linkable text. - - * Link: `RDoc::Options@Saved+Options` links to - RDoc::Options@Saved+Options. - - Punctuation and other special characters must be escaped like CGI.escape. - - Pro tip: The link to any heading is available in the alphabetical table of - contents at the top left of the page for the class or module. - - -Section -: See [Directives for Organizing - Documentation](#class-RDoc::MarkupReference-label-Directives+for+Organizin - g+Documentation). - - * Link: `RDoc::Markup::ToHtml@Visitor` links to - RDoc::Markup::ToHtml@Visitor. - - If a section and a heading share the same name, the link target is the - section. - - -Single-Word Text Link -: Use square brackets to create single-word text link: - - * `GitHub[https://github.com]` links to [GitHub](https://github.com). - - -Multi-Word Text Link -: Use square brackets and curly braces to create a multi-word text link. - - * `{GitHub home page}[https://github.com]` links to [GitHub home - page](https://github.com). - - -`rdoc-ref` Scheme -: A link with the `rdoc-ref:` scheme links to the referenced item, if that - item exists. The referenced item may be a class, module, method, file, - etc. - - * Class: `Alias[rdoc-ref:RDoc::Alias]` generates - [Alias](rdoc-ref:RDoc::Alias). - * Module: `RDoc[rdoc-ref:RDoc]` generates [RDoc](rdoc-ref:RDoc). - * Method: `foo[rdoc-ref:RDoc::MarkupReference#dummy_instance_method]` - generates [foo](rdoc-ref:RDoc::MarkupReference#dummy_instance_method). - * Constant: `bar[rdoc-ref:RDoc::MarkupReference::DUMMY_CONSTANT]` - generates [bar](rdoc-ref:RDoc::MarkupReference::DUMMY_CONSTANT). - * Attribute: `baz[rdoc-ref:RDoc::MarkupReference#dummy_attribute]` - generates [baz](rdoc-ref:RDoc::MarkupReference#dummy_attribute). - * Alias: `bad[rdoc-ref:RDoc::MarkupReference#dummy_instance_alias]` - generates [bad](rdoc-ref:RDoc::MarkupReference#dummy_instance_alias). - - If the referenced item does not exist, no link is generated and entire - `rdoc-ref:` square-bracketed clause is removed from the resulting text. - - * `Nosuch[rdoc-ref:RDoc::Nosuch]` generates - [Nosuch](rdoc-ref:RDoc::Nosuch). - - - Simple -: You can specify a link target using this form, where the second part - cites the id of an HTML element. - - This link refers to the constant `DUMMY_CONSTANT` on this page: - - * `{DUMMY_CONSTANT}[rdoc-label:DUMMY_CONSTANT]` - - Thus: - - [DUMMY_CONSTANT](#DUMMY_CONSTANT) - - - With Return -: You can specify both a link target and a local label that can be used - as the target for a return link. These two links refer to each other: - - * `{go to addressee}[rdoc-label:addressee:sender]` - * `{return to sender}[rdoc-label:sender:addressee]` - - Thus: - - [go to addressee](#addressee) - - Some text. - - [return to sender](#sender) - - - - * `link:README_rdoc.html` links to link:README_rdoc.html. - - -`rdoc-image` Scheme -: Use the `rdoc-image` scheme to display an image that is also a link: - - # {rdoc-image:path/to/image}[link_target] - - * Link: - `{rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png} - [https://www.ruby-lang.org]` displays image - `https://www.ruby-lang.org/images/header-ruby-logo@2x.png` as a link - to `https://www.ruby-lang.org`. - - [rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png]( - https://www.ruby-lang.org) - - A relative path as the target also works: - - * Link: - `{rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png} - [./Alias.html]` links to `./Alias.html` - - [rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png]( - ./Alias.html) - - -### Escaping Text - -Text that would otherwise be interpreted as markup can be "escaped," so that -it is not interpreted as markup; the escape character is the backslash -(`'\\'`). - -In a verbatim text block or a code block, the escape character is always -preserved: - -Example input: - - This is not verbatim text. - - This is verbatim text, with an escape character \. - - This is not a code block. - - def foo - 'String with an escape character.' - end - -Rendered HTML: - -> This is not verbatim text. - - This is verbatim text, with an escape character \. - -> This is not a code block. - - def foo - 'This is a code block with an escape character \.' - end - -> In typeface markup (italic, bold, or monofont), an escape character is -preserved unless it is immediately followed by nested typeface markup. - -Example input: - - This list is about escapes; it contains: - - - Monofont text with unescaped nested _italic_. - - Monofont text with escaped nested \_italic_. - - Monofont text with an escape character \. - -Rendered HTML: - -> This list is about escapes; it contains: - - * `Monofont text with unescaped nested *italic`*. - * `Monofont text with escaped nested _italic_`. - * `Monofont text with an escape character \ `. - -In other text-bearing blocks (paragraphs, block quotes, list items, headings): - -* A single escape character immediately followed by markup escapes the - markup. -* A single escape character followed by whitespace is preserved. -* A single escape character anywhere else is ignored. -* A double escape character is rendered as a single backslash. - - Example input: - - This list is about escapes; it contains: - - - An unescaped class name, RDoc, that will become a link. - - An escaped class name, \RDoc, that will not become a link. - - An escape character followed by whitespace \ . - - An escape character \that is ignored. - - A double escape character \\ that is rendered - as a single backslash. - - Rendered HTML: - -> This list is about escapes; it contains: - - * An unescaped class name, RDoc, that will become a link. - * An escaped class name, RDoc, that will not become a link. - * An escape character followed by whitespace \ . - * An escape character that is ignored. - * A double escape character \ that is rendered as a single backslash. - -## Documentation Derived from Ruby Code - -Class -: By default, RDoc documents: - - * Class name. - * Parent class. - * Singleton methods. - * Instance methods. - * Aliases. - * Constants. - * Attributes. - - -Module -: By default, RDoc documents: - - * Module name. - * Singleton methods. - * Instance methods. - * Aliases. - * Constants. - * Attributes. - - -Method -: By default, RDoc documents: - - * Method name. - * Arguments. - * Yielded values. - - See #method. - - -Alias -: By default, RDoc documents: - - * Alias name. - * Aliased name. - - See #dummy_instance_alias and #dummy_instance_method. - - -Constant -: By default, RDoc documents: - - * Constant name. - - See DUMMY_CONSTANT. - - -Attribute -: By default, RDoc documents: - - * Attribute name. - * Attribute type (`[R]`, `[W]`, or `[RW]`) - - See #dummy_attribute. - - - -# Class Methods -## dummy_singleton_method(foo , bar ) [](#method-c-dummy_singleton_method) -Example singleton method. -# Attributes -## dummy_attribute[RW] [](#attribute-i-dummy_attribute) -Example attribute. - - -#Instance Methods -## args_directive(foo, bar) [](#method-i-args_directive) -The `:args:` directive overrides the actual arguments found in the Ruby code. - -Click on the calling sequence to see the code. - -## call_seq_directive() [](#method-i-call_seq_directive) -:call-seq: - call_seq_directive(foo, bar) - Can be anything -> bar - Also anything more -> baz or bat - -The `:call-seq:` directive overrides the actual calling sequence found in the -Ruby code. - -* It can specify anything at all. -* It can have multiple calling sequences. - -This one includes `Can be anything -> foo`, which is nonsense. - -Note that the "arrow" is two characters, hyphen and right angle-bracket, which -is made into a single character in the HTML. - -Click on the calling sequence to see the code. - -Here is the `:call-seq:` directive given for the method: - - :call-seq: - call_seq_directive(foo, bar) - Can be anything -> bar - Also anything more -> baz or bat - -## dummy_instance_method(foo, bar) [](#method-i-dummy_instance_method) -Example instance method. - -## method(foo, bar) [](#method-i-method) -This method is documented only by RDoc, except for these comments. - -Click on the calling sequence to see the code. - -**@yield** ['baz'] - -## yields_directive(foo, bar) [](#method-i-yields_directive) -The `:yields:` directive overrides the actual yield found in the Ruby code. - -Click on the calling sequence to see the code. - -**@yield** ['baz'] - diff --git a/example/ruby/RDoc/MarkupReference/DummyClass.md b/example/ruby/RDoc/MarkupReference/DummyClass.md deleted file mode 100644 index ed752d3..0000000 --- a/example/ruby/RDoc/MarkupReference/DummyClass.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: RDoc::MarkupReference::DummyClass -**Inherits:** Object - - -Example class. - - - diff --git a/example/ruby/RDoc/MarkupReference/DummyModule.md b/example/ruby/RDoc/MarkupReference/DummyModule.md deleted file mode 100644 index 0f44c6d..0000000 --- a/example/ruby/RDoc/MarkupReference/DummyModule.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: RDoc::MarkupReference::DummyModule - - -Example module. - - - diff --git a/example/ruby/RDoc/MetaMethod.md b/example/ruby/RDoc/MetaMethod.md deleted file mode 100644 index 2b25085..0000000 --- a/example/ruby/RDoc/MetaMethod.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: RDoc::MetaMethod -**Inherits:** RDoc::AnyMethod - - -MetaMethod represents a meta-programmed method - - - diff --git a/example/ruby/RDoc/MethodAttr.md b/example/ruby/RDoc/MethodAttr.md deleted file mode 100644 index d13edaa..0000000 --- a/example/ruby/RDoc/MethodAttr.md +++ /dev/null @@ -1,251 +0,0 @@ -# Class: RDoc::MethodAttr -**Inherits:** RDoc::CodeObject - -**Includes:** Comparable - - -Abstract class representing either a method or an attribute. - - -# Attributes -## aliases[RW] [](#attribute-i-aliases) -Array of other names for this method/attribute - -## arglists[RW] [](#attribute-i-arglists) -The call_seq or the param_seq with method name, if there is no call_seq. - -## block_params[RW] [](#attribute-i-block_params) -Parameters yielded by the called block - -## call_seq[RW] [](#attribute-i-call_seq) -Different ways to call this method - -## is_alias_for[RW] [](#attribute-i-is_alias_for) -The method/attribute we're aliasing - -## name[RW] [](#attribute-i-name) -Name of this method/attribute. - -## param_seq[RW] [](#attribute-i-param_seq) -Pretty parameter list for this method - -## params[RW] [](#attribute-i-params) -Parameters for this method - -## singleton[RW] [](#attribute-i-singleton) -Is this a singleton method/attribute? - -## text[RW] [](#attribute-i-text) -Source file token stream - -## visibility[RW] [](#attribute-i-visibility) -public, protected, private - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Order by #singleton then #name - -## ==(other) [](#method-i-==) -:nodoc: - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## add_alias(an_alias, context) [](#method-i-add_alias) -Abstract method. Contexts in their building phase call this to register a new -alias for this known method/attribute. - -* creates a new AnyMethod/Attribute named `an_alias.new_name`; -* adds `self` as an alias for the new method or attribute -* adds the method or attribute to #aliases -* adds the method or attribute to `context`. - -**@raise** [NotImplementedError] - -## add_line_numbers(src) [](#method-i-add_line_numbers) -Prepend `src` with line numbers. Relies on the first line of a source code -listing having: - - # File xxxxx, line dddd - -If it has this comment then line numbers are added to `src` and the `, line -dddd` portion of the comment is removed. - -## aref() [](#method-i-aref) -HTML fragment reference for this method - -## aref_prefix() [](#method-i-aref_prefix) -Prefix for `aref`, defined by subclasses. - -**@raise** [NotImplementedError] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## documented?() [](#method-i-documented?) -A method/attribute is documented if any of the following is true: -* it was marked with :nodoc:; -* it has a comment; -* it is an alias for a documented method; -* it has a `#see` method that is documented. - -**@return** [Boolean] - -## find_method_or_attribute(name) [](#method-i-find_method_or_attribute) -:nodoc: - -## find_see() [](#method-i-find_see) -:nodoc: - -## full_name() [](#method-i-full_name) -Full method/attribute name including namespace - -## html_name() [](#method-i-html_name) -HTML id-friendly method/attribute name - -## initialize(text, name) [](#method-i-initialize) -Creates a new MethodAttr from token stream `text` and method or attribute name -`name`. - -Usually this is called by super from a subclass. - -**@return** [MethodAttr] a new instance of MethodAttr - -## initialize_copy(other) [](#method-i-initialize_copy) -Resets cached data for the object so it can be rebuilt by accessor methods - -## initialize_visibility() [](#method-i-initialize_visibility) -:nodoc: - -## inspect() [](#method-i-inspect) -:nodoc: - -## markup_code() [](#method-i-markup_code) -Turns the method's token stream into HTML. - -Prepends line numbers if `options.line_numbers` is true. - -## name_ord_range() [](#method-i-name_ord_range) -:nodoc: - -## name_prefix() [](#method-i-name_prefix) -'::' for a class method/attribute, '#' for an instance method. - -## output_name(context) [](#method-i-output_name) -Name for output to HTML. For class methods the full name with a "." is used -like `SomeClass.method_name`. For instance methods the class name is used if -`context` does not match the parent. - -This is to help prevent people from using -: to call class methods. - - -## parent_name() [](#method-i-parent_name) -Name of our parent with special handling for un-marshaled methods - -## path() [](#method-i-path) -Path to this method for use with HTML generator output. - -## pretty_name() [](#method-i-pretty_name) -Method/attribute name with class/instance indicator - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## search_record() [](#method-i-search_record) -Used by RDoc::Generator::JsonIndex to create a record for the search engine. - -## see() [](#method-i-see) -A method/attribute to look at, in particular if this method/attribute has no -documentation. - -It can be a method/attribute of the superclass or of an included module, -including the Kernel module, which is always appended to the included modules. - -Returns `nil` if there is no such method/attribute. The `#is_alias_for` -method/attribute, if any, is not included. - -Templates may generate a "see also ..." if this method/attribute has -documentation, and "see ..." if it does not. - -## store=(store) [](#method-i-store=) -Sets the store for this class or module and its contained code objects. - -## to_s() [](#method-i-to_s) -:nodoc: - -## type() [](#method-i-type) -Type of method/attribute (class or instance) - diff --git a/example/ruby/RDoc/Mixin.md b/example/ruby/RDoc/Mixin.md deleted file mode 100644 index 964561f..0000000 --- a/example/ruby/RDoc/Mixin.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: RDoc::Mixin -**Inherits:** RDoc::CodeObject - - -A Mixin adds features from a module into another context. RDoc::Include and -RDoc::Extend are both mixins. - - -# Attributes -## name[RW] [](#attribute-i-name) -Name of included module - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -Mixins are sorted by name - -## ==(other) [](#method-i-==) -:nodoc: - -## full_name() [](#method-i-full_name) -Full name based on #module - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(name, comment) [](#method-i-initialize) -Creates a new Mixin for `name` with `comment` - -**@return** [Mixin] a new instance of Mixin - -## inspect() [](#method-i-inspect) -:nodoc: - -## module() [](#method-i-module) -Attempts to locate the included module object. Returns the name if not known. - -The scoping rules of Ruby to resolve the name of an included module are: -* first look into the children of the current context; -* if not found, look into the children of included modules, in reverse - inclusion order; -* if still not found, go up the hierarchy of names. - -This method has `O(n!)` behavior when the module calling include is -referencing nonexistent modules. Avoid calling #module until after all the -files are parsed. This behavior is due to ruby's constant lookup behavior. - -As of the beginning of October, 2011, no gem includes nonexistent modules. - -## store=(store) [](#method-i-store=) -Sets the store for this class or module and its contained code objects. - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/RDoc/NormalClass.md b/example/ruby/RDoc/NormalClass.md deleted file mode 100644 index da5fb11..0000000 --- a/example/ruby/RDoc/NormalClass.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: RDoc::NormalClass -**Inherits:** RDoc::ClassModule - - -A normal class, neither singleton nor anonymous - - - -#Instance Methods -## ancestors() [](#method-i-ancestors) -The ancestors of this class including modules. Unlike Module#ancestors, this -class is not included in the result. The result will contain both -RDoc::ClassModules and Strings. - -## aref_prefix() [](#method-i-aref_prefix) -:nodoc: - -## definition() [](#method-i-definition) -The definition of this class, `class MyClassName` - -## direct_ancestors() [](#method-i-direct_ancestors) - -## inspect() [](#method-i-inspect) -:nodoc: - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/RDoc/NormalModule.md b/example/ruby/RDoc/NormalModule.md deleted file mode 100644 index 0fea601..0000000 --- a/example/ruby/RDoc/NormalModule.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: RDoc::NormalModule -**Inherits:** RDoc::ClassModule - - -A normal module, like NormalClass - - - -#Instance Methods -## aref_prefix() [](#method-i-aref_prefix) -:nodoc: - -## definition() [](#method-i-definition) -The definition of this module, `module MyModuleName` - -## inspect() [](#method-i-inspect) -:nodoc: - -## module?() [](#method-i-module?) -This is a module, returns true - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## superclass() [](#method-i-superclass) -Modules don't have one, raises NoMethodError - -**@raise** [NoMethodError] - diff --git a/example/ruby/RDoc/Options.md b/example/ruby/RDoc/Options.md deleted file mode 100644 index 6ccb540..0000000 --- a/example/ruby/RDoc/Options.md +++ /dev/null @@ -1,292 +0,0 @@ -# Class: RDoc::Options -**Inherits:** Object - - -RDoc::Options handles the parsing and storage of options - -## Saved Options - -You can save some options like the markup format in the `.rdoc_options` file -in your gem. The easiest way to do this is: - - rdoc --markup tomdoc --write-options - -Which will automatically create the file and fill it with the options you -specified. - -The following options will not be saved since they interfere with the user's -preferences or with the normal operation of RDoc: - -* `--coverage-report` -* `--dry-run` -* `--encoding` -* `--force-update` -* `--format` -* `--pipe` -* `--quiet` -* `--template` -* `--verbose` - -## Custom Options - -Generators can hook into RDoc::Options to add generator-specific command line -options. - -When `--format` is encountered in ARGV, RDoc calls ::setup_options on the -generator class to add extra options to the option parser. Options for custom -generators must occur after `--format`. `rdoc --help` will list options for -all installed generators. - -Example: - - class RDoc::Generator::Spellcheck - RDoc::RDoc.add_generator self - - def self.setup_options rdoc_options - op = rdoc_options.option_parser - - op.on('--spell-dictionary DICTIONARY', - RDoc::Options::Path) do |dictionary| - rdoc_options.spell_dictionary = dictionary - end - end - end - -Of course, RDoc::Options does not respond to `spell_dictionary` by default so -you will need to add it: - - class RDoc::Options - - ## - # The spell dictionary used by the spell-checking plugin. - - attr_accessor :spell_dictionary - - end - -## Option Validators - -OptionParser validators will validate and cast user input values. In addition -to the validators that ship with OptionParser (String, Integer, Float, -TrueClass, FalseClass, Array, Regexp, Date, Time, URI, etc.), RDoc::Options -adds Path, PathArray and Template. - - -# Class Methods -## load_options() [](#method-c-load_options) -Loads options from .rdoc_options if the file exists, otherwise creates a new -RDoc::Options instance. -**@raise** [RDoc::Error] - -# Attributes -## apply_default_exclude[RW] [](#attribute-i-apply_default_exclude) -Exclude the default patterns as well if true. - -## charset[RW] [](#attribute-i-charset) -Character-set for HTML output. #encoding is preferred over #charset - -## coverage_report[RW] [](#attribute-i-coverage_report) -If true, only report on undocumented files - -## dry_run[RW] [](#attribute-i-dry_run) -If true, RDoc will not write any files. - -## embed_mixins[RW] [](#attribute-i-embed_mixins) -Embed mixin methods, attributes, and constants into class documentation. Set -via `--[no-]embed-mixins` (Default is `false`.) - -## encoding[RW] [](#attribute-i-encoding) -The output encoding. All input files will be transcoded to this encoding. - -The default encoding is UTF-8. This is set via --encoding. - -## exclude[RW] [](#attribute-i-exclude) -Create a regexp for #exclude - -## files[RW] [](#attribute-i-files) -The list of files to be processed - -## force_output[RW] [](#attribute-i-force_output) -Create the output even if the output directory does not look like an rdoc -output directory - -## force_update[RW] [](#attribute-i-force_update) -Scan newer sources than the flag file if true. - -## formatter[RW] [](#attribute-i-formatter) -Formatter to mark up text with - -## generator[RW] [](#attribute-i-generator) -Description of the output generator (set with the `--format` option) - -## generator_name[RW] [](#attribute-i-generator_name) -For #== - -## generator_options[RW] [](#attribute-i-generator_options) -Loaded generator options. Used to prevent --help from loading the same -options multiple times. - -## hyperlink_all[RW] [](#attribute-i-hyperlink_all) -Old rdoc behavior: hyperlink all words that match a method name, even if not -preceded by '#' or '::' - -## line_numbers[RW] [](#attribute-i-line_numbers) -Include line numbers in the source code - -## locale[RW] [](#attribute-i-locale) -The output locale. - -## locale_dir[RW] [](#attribute-i-locale_dir) -The directory where locale data live. - -## main_page[RW] [](#attribute-i-main_page) -Name of the file, class or module to display in the initial index page (if not -specified the first file we encounter is used) - -## markup[RW] [](#attribute-i-markup) -The markup format. One of: `rdoc` (the default), `markdown`, `rd`, `tomdoc`. -See [Markup Formats](rdoc-ref:RDoc::Markup@Markup+Formats). - -## op_dir[RW] [](#attribute-i-op_dir) -The name of the output directory - -## option_parser[RW] [](#attribute-i-option_parser) -The OptionParser for this instance - -## output_decoration[RW] [](#attribute-i-output_decoration) -Output heading decorations? - -## page_dir[RW] [](#attribute-i-page_dir) -Directory where guides, FAQ, and other pages not associated with a class live. - You may leave this unset if these are at the root of your project. - -## pipe[RW] [](#attribute-i-pipe) -Is RDoc in pipe mode? - -## rdoc_include[RW] [](#attribute-i-rdoc_include) -Array of directories to search for files to satisfy an :include: - -## root[RW] [](#attribute-i-root) -Root of the source documentation will be generated for. Set this when -building documentation outside the source directory. Defaults to the current -directory. - -## show_hash[RW] [](#attribute-i-show_hash) -Include the '#' at the front of hyperlinked instance method names - -## skip_tests[RW] [](#attribute-i-skip_tests) -Indicates if files of test suites should be skipped - -## static_path[RW] [](#attribute-i-static_path) -Directory to copy static files from - -## tab_width[RW] [](#attribute-i-tab_width) -The number of columns in a tab - -## template[RW] [](#attribute-i-template) -Template to be used when generating output - -## template_dir[RW] [](#attribute-i-template_dir) -Directory the template lives in - -## template_stylesheets[RW] [](#attribute-i-template_stylesheets) -Additional template stylesheets - -## title[RW] [](#attribute-i-title) -Documentation title - -## update_output_dir[RW] [](#attribute-i-update_output_dir) -Should RDoc update the timestamps in the output dir? - -## verbosity[RW] [](#attribute-i-verbosity) -Verbosity, zero means quiet - -## visibility[RW] [](#attribute-i-visibility) -Minimum visibility of a documented method. One of `:public`, `:protected`, -`:private` or `:nodoc`. - -The `:nodoc` visibility ignores all directives related to visibility. The -other visibilities may be overridden on a per-method basis with the :doc: -directive. - -## warn_missing_rdoc_ref[RW] [](#attribute-i-warn_missing_rdoc_ref) -Warn if rdoc-ref links can't be resolved Default is `false` - -## webcvs[RW] [](#attribute-i-webcvs) -URL of web cvs frontend - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## check_files() [](#method-i-check_files) -Check that the files on the command line exist - -## check_generator() [](#method-i-check_generator) -Ensure only one generator is loaded - -## default_title=(string) [](#method-i-default_title=) -Set the title, but only if not already set. Used to set the title from a -source file, so that a title set from the command line will have the priority. - -## finish() [](#method-i-finish) -Completes any unfinished option setup business such as filtering for existent -files, creating a regexp for #exclude and setting a default #template. - -## finish_page_dir() [](#method-i-finish_page_dir) -Fixes the page_dir to be relative to the root_dir and adds the page_dir to the -files list. - -## generator_descriptions() [](#method-i-generator_descriptions) -Returns a properly-space list of generators and their descriptions. - -## init_ivars() [](#method-i-init_ivars) -:nodoc: - -## init_with(map) [](#method-i-init_with) -:nodoc: - -## initialize(loaded_optionsnil) [](#method-i-initialize) -:nodoc: - -**@return** [Options] a new instance of Options - -## override(map) [](#method-i-override) -:nodoc: - -## parse(argv) [](#method-i-parse) -Parses command line options. - -## quiet() [](#method-i-quiet) -Don't display progress as we process the files - -## quiet=(bool) [](#method-i-quiet=) -Set quietness to `bool` - -## sanitize_path(path) [](#method-i-sanitize_path) -Removes directories from `path` that are outside the current directory - -## setup_generator(generator_name@generator_name) [](#method-i-setup_generator) -Set up an output generator for the named `generator_name`. - -If the found generator responds to :setup_options it will be called with the -options instance. This allows generators to add custom options or set default -options. - -## template_dir_for(template) [](#method-i-template_dir_for) -Finds the template dir for `template` - -## to_yaml(*options) [](#method-i-to_yaml) -For dumping YAML - -## warn(message) [](#method-i-warn) -Displays a warning using Kernel#warn if we're being verbose - -## write_options() [](#method-i-write_options) -Writes the YAML file .rdoc_options to the current directory containing the -parsed options. - -## yaml_initialize(tag, map) [](#method-i-yaml_initialize) -:nodoc: - diff --git a/example/ruby/RDoc/Parser.md b/example/ruby/RDoc/Parser.md deleted file mode 100644 index d160f1d..0000000 --- a/example/ruby/RDoc/Parser.md +++ /dev/null @@ -1,102 +0,0 @@ -# Class: RDoc::Parser -**Inherits:** Object - - -A parser is simple a class that subclasses RDoc::Parser and implements #scan -to fill in an RDoc::TopLevel with parsed data. - -The initialize method takes an RDoc::TopLevel to fill with parsed content, the -name of the file to be parsed, the content of the file, an RDoc::Options -object and an RDoc::Stats object to inform the user of parsed items. The scan -method is then called to parse the file and must return the RDoc::TopLevel -object. By calling super these items will be set for you. - -In order to be used by RDoc the parser needs to register the file extensions -it can parse. Use ::parse_files_matching to register extensions. - - require 'rdoc' - - class RDoc::Parser::Xyz < RDoc::Parser - parse_files_matching /\.xyz$/ - - def initialize top_level, file_name, content, options, stats - super - - # extra initialization if needed - end - - def scan - # parse file and fill in @top_level - end - end - - -# Class Methods -## alias_extension(old_ext , new_ext ) [](#method-c-alias_extension) -Alias an extension to another extension. After this call, files ending -"new_ext" will be parsed using the same parser as "old_ext" -## binary?(file ) [](#method-c-binary?) -Determines if the file is a "binary" file which basically means it has content -that an RDoc parser shouldn't try to consume. -**@return** [Boolean] - -## can_parse(file_name ) [](#method-c-can_parse) -Return a parser that can handle a particular extension -## can_parse_by_name(file_name ) [](#method-c-can_parse_by_name) -Returns a parser that can handle the extension for `file_name`. This does not -depend upon the file being readable. -## check_modeline(file_name ) [](#method-c-check_modeline) -Returns the file type from the modeline in `file_name` -## for(top_level , content , options , stats ) [](#method-c-for) -Finds and instantiates the correct parser for the given `file_name` and -`content`. -## parse_files_matching(regexp ) [](#method-c-parse_files_matching) -Record which file types this parser can understand. - -It is ok to call this multiple times. -## remove_modeline(content ) [](#method-c-remove_modeline) -Removes an emacs-style modeline from the first line of the document -## use_markup(content ) [](#method-c-use_markup) -If there is a `markup: parser_name` comment at the front of the file, use it -to determine the parser. For example: - - # markup: rdoc - # Class comment can go here - - class C - end - -The comment should appear as the first line of the `content`. - -If the content contains a shebang or editor modeline the comment may appear on -the second or third line. - -Any comment style may be used to hide the markup comment. -## zip?(file ) [](#method-c-zip?) -Checks if `file` is a zip file in disguise. Signatures from -http://www.garykessler.net/library/file_sigs.html -**@return** [Boolean] - -# Attributes -## parsers[RW] [](#attribute-c-parsers) -An Array of arrays that maps file extension (or name) regular expressions to -parser classes that will parse matching filenames. - -Use parse_files_matching to register a parser's file extensions. - -## file_name[RW] [](#attribute-i-file_name) -The name of the file being parsed - - -#Instance Methods -## handle_tab_width(body) [](#method-i-handle_tab_width) -Normalizes tabs in `body` - -## initialize(top_level, file_name, content, options, stats) [](#method-i-initialize) -Creates a new Parser storing `top_level`, `file_name`, `content`, `options` -and `stats` in instance variables. In +@preprocess+ an -RDoc::Markup::PreProcess object is created which allows processing of -directives. - -**@return** [Parser] a new instance of Parser - diff --git a/example/ruby/RDoc/Parser/C.md b/example/ruby/RDoc/Parser/C.md deleted file mode 100644 index fa8925e..0000000 --- a/example/ruby/RDoc/Parser/C.md +++ /dev/null @@ -1,351 +0,0 @@ -# Class: RDoc::Parser::C -**Inherits:** RDoc::Parser - -**Includes:** RDoc::Text - - -RDoc::Parser::C attempts to parse C extension files. It looks for the -standard patterns that you find in extensions: `rb_define_class`, -`rb_define_method` and so on. It tries to find the corresponding C source for -the methods and extract comments, but if we fail we don't worry too much. - -The comments associated with a Ruby method are extracted from the C comment -block associated with the routine that *implements* that method, that is to -say the method whose name is given in the `rb_define_method` call. For -example, you might write: - - /* - * Returns a new array that is a one-dimensional flattening of this - * array (recursively). That is, for every element that is an array, - * extract its elements into the new array. - * - * s = [ 1, 2, 3 ] #=> [1, 2, 3] - * t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]] - * a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10] - * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - */ - static VALUE - rb_ary_flatten(VALUE ary) - { - ary = rb_obj_dup(ary); - rb_ary_flatten_bang(ary); - return ary; - } - - ... - - void - Init_Array(void) - { - ... - rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0); - -Here RDoc will determine from the `rb_define_method` line that there's a -method called "flatten" in class Array, and will look for the implementation -in the method `rb_ary_flatten`. It will then use the comment from that method -in the HTML output. This method must be in the same source file as the -`rb_define_method`. - -The comment blocks may include special directives: - -Document-class: `name` -: Documentation for the named class. - - -Document-module: `name` -: Documentation for the named module. - - -Document-const: `name` -: Documentation for the named `rb_define_const`. - - Constant values can be supplied on the first line of the comment like so: - - /* 300: The highest possible score in bowling */ - rb_define_const(cFoo, "PERFECT", INT2FIX(300)); - - The value can contain internal colons so long as they are escaped with a \ - - -Document-global: `name` -: Documentation for the named `rb_define_global_const` - - -Document-variable: `name` -: Documentation for the named `rb_define_variable` - - -Document-method: `method_name` -: Documentation for the named method. Use this when the method name is - unambiguous. - - -Document-method: `ClassName::method_name` -: Documentation for a singleton method in the given class. Use this when - the method name alone is ambiguous. - - -Document-method: `ClassName#method_name` -: Documentation for a instance method in the given class. Use this when the - method name alone is ambiguous. - - -Document-attr: `name` -: Documentation for the named attribute. - - -call-seq: *text up to an empty line* -: Because C source doesn't give descriptive names to Ruby-level parameters, - you need to document the calling sequence explicitly - - -In addition, RDoc assumes by default that the C method implementing a Ruby -function is in the same source file as the rb_define_method call. If this -isn't the case, add the comment: - - rb_define_method(....); // in filename - -As an example, we might have an extension that defines multiple classes in its -Init_xxx method. We could document them using - - /* - * Document-class: MyClass - * - * Encapsulate the writing and reading of the configuration - * file. ... - */ - - /* - * Document-method: read_value - * - * call-seq: - * cfg.read_value(key) -> value - * cfg.read_value(key} { |key| } -> value - * - * Return the value corresponding to +key+ from the configuration. - * In the second form, if the key isn't found, invoke the - * block and return its value. - */ - - -# Class Methods -## tsort_each_child(node , &block ) [](#method-c-tsort_each_child) -## tsort_each_node(&block ) [](#method-c-tsort_each_node) -# Attributes -## classes[RW] [](#attribute-i-classes) -Maps C variable names to names of Ruby classes or modules - -## content[RW] [](#attribute-i-content) -C file the parser is parsing - -## enclosure_dependencies[RW] [](#attribute-i-enclosure_dependencies) -Dependencies from a missing enclosing class to the classes in -missing_dependencies that depend upon it. - -## known_classes[RW] [](#attribute-i-known_classes) -Maps C variable names to names of Ruby classes (and singleton classes) - -## missing_dependencies[RW] [](#attribute-i-missing_dependencies) -Classes found while parsing the C file that were not yet registered due to a -missing enclosing class. These are processed by do_missing - -## singleton_classes[RW] [](#attribute-i-singleton_classes) -Maps C variable names to names of Ruby singleton classes - -## top_level[RW] [](#attribute-i-top_level) -The TopLevel items in the parsed file belong to - - -#Instance Methods -## add_alias(var_name, class_obj, old_name, new_name, comment) [](#method-i-add_alias) -Add alias, either from a direct alias definition, or from two method that -reference the same function. - -## do_aliases() [](#method-i-do_aliases) -Scans #content for rb_define_alias - -## do_attrs() [](#method-i-do_attrs) -Scans #content for rb_attr and rb_define_attr - -## do_boot_defclass() [](#method-i-do_boot_defclass) -Scans #content for boot_defclass - -## do_classes_and_modules() [](#method-i-do_classes_and_modules) -Scans #content for rb_define_class, boot_defclass, rb_define_class_under and -rb_singleton_class - -## do_constants() [](#method-i-do_constants) -Scans #content for rb_define_variable, rb_define_readonly_variable, -rb_define_const and rb_define_global_const - -## do_includes() [](#method-i-do_includes) -Scans #content for rb_include_module - -## do_methods() [](#method-i-do_methods) -Scans #content for rb_define_method, rb_define_singleton_method, -rb_define_module_function, rb_define_private_method, rb_define_global_function -and define_filetest_function - -## do_missing() [](#method-i-do_missing) -Creates classes and module that were missing were defined due to the file -order being different than the declaration order. - -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## find_alias_comment(class_name, new_name, old_name) [](#method-i-find_alias_comment) -Finds the comment for an alias on `class_name` from `new_name` to `old_name` - -## find_attr_comment(var_name, attr_name, readnil, writenil) [](#method-i-find_attr_comment) -Finds a comment for rb_define_attr, rb_attr or Document-attr. - -`var_name` is the C class variable the attribute is defined on. `attr_name` is -the attribute's name. - -`read` and `write` are the read/write flags ('1' or '0'). Either both or -neither must be provided. - -## find_body(class_name, meth_name, meth_obj, file_content, quietfalse) [](#method-i-find_body) -Find the C code corresponding to a Ruby method - -## find_class(raw_name, name, base_namenil) [](#method-i-find_class) -Finds a RDoc::NormalClass or RDoc::NormalModule for `raw_name` - -## find_class_comment(class_name, class_mod) [](#method-i-find_class_comment) -Look for class or module documentation above Init_`class_name`(void), in a -Document-class `class_name` (or module) comment or above an rb_define_class -(or module). If a comment is supplied above a matching Init_ and a -rb_define_class the Init_ comment is used. - - /* - * This is a comment for Foo - */ - Init_Foo(void) { - VALUE cFoo = rb_define_class("Foo", rb_cObject); - } - - /* - * Document-class: Foo - * This is a comment for Foo - */ - Init_foo(void) { - VALUE cFoo = rb_define_class("Foo", rb_cObject); - } - - /* - * This is a comment for Foo - */ - VALUE cFoo = rb_define_class("Foo", rb_cObject); - -## find_const_comment(type, const_name, class_namenil) [](#method-i-find_const_comment) -Finds a comment matching `type` and `const_name` either above the comment or -in the matching Document- section. - -## find_modifiers(comment, meth_obj) [](#method-i-find_modifiers) -Handles modifiers in `comment` and updates `meth_obj` as appropriate. - -## find_override_comment(class_name, meth_obj) [](#method-i-find_override_comment) -Finds a `Document-method` override for `meth_obj` on `class_name` - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## gen_body_table(file_content) [](#method-i-gen_body_table) -Generate a Ruby-method table - -## gen_const_table(file_content) [](#method-i-gen_const_table) -Generate a const table - -## handle_attr(var_name, attr_name, read, write) [](#method-i-handle_attr) -Creates a new RDoc::Attr `attr_name` on class `var_name` that is either -`read`, `write` or both - -## handle_class_module(var_name, type, class_name, parent, in_module) [](#method-i-handle_class_module) -Creates a new RDoc::NormalClass or RDoc::NormalModule based on `type` named -`class_name` in `parent` which was assigned to the C `var_name`. - -## handle_constants(type, var_name, const_name, definition) [](#method-i-handle_constants) -Adds constants. By providing some_value: at the start of the comment you can -override the C value of the comment to give a friendly definition. - - /* 300: The perfect score in bowling */ - rb_define_const(cFoo, "PERFECT", INT2FIX(300)); - -Will override `INT2FIX(300)` with the value `300` in the output RDoc. Values -may include quotes and escaped colons (:). - -## handle_ifdefs_in(body) [](#method-i-handle_ifdefs_in) -Removes #ifdefs that would otherwise confuse us - -## handle_method(type, var_name, meth_name, function, param_count, source_filenil) [](#method-i-handle_method) -Adds an RDoc::AnyMethod `meth_name` defined on a class or module assigned to -`var_name`. `type` is the type of method definition function used. -`singleton_method` and `module_function` create a singleton method. - -## handle_singleton(sclass_var, class_var) [](#method-i-handle_singleton) -Registers a singleton class `sclass_var` as a singleton of `class_var` - -## initialize(top_level, file_name, content, options, stats) [](#method-i-initialize) -Prepares for parsing a C file. See RDoc::Parser#initialize for details on the -arguments. - -**@return** [C] a new instance of C - -## load_variable_map(map_name) [](#method-i-load_variable_map) -Loads the variable map with the given `name` from the RDoc::Store, if present. - -## look_for_directives_in(context, comment) [](#method-i-look_for_directives_in) -Look for directives in a normal comment block: - - /* - * :title: My Awesome Project - */ - -This method modifies the `comment` Both :main: and :title: directives are -deprecated and will be removed in RDoc 7. - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## new_comment(textnil, locationnil, languagenil) [](#method-i-new_comment) -Creates a RDoc::Comment instance. - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## parse(text, format'rdoc') [](#method-i-parse) -Normalizes `text` then builds a RDoc::Markup::Document from it - -## rb_scan_args(method_body) [](#method-i-rb_scan_args) -Extracts parameters from the `method_body` and returns a method parameter -string. Follows 1.9.3dev's scan-arg-spec, see README.EXT - -## remove_commented_out_lines() [](#method-i-remove_commented_out_lines) -Removes lines that are commented out that might otherwise get picked up when -scanning for classes and methods - -## scan() [](#method-i-scan) -Extracts the classes, modules, methods, attributes, constants and aliases from -a C file and returns an RDoc::TopLevel for this file - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/RDoc/Parser/ChangeLog.md b/example/ruby/RDoc/Parser/ChangeLog.md deleted file mode 100644 index a2665e9..0000000 --- a/example/ruby/RDoc/Parser/ChangeLog.md +++ /dev/null @@ -1,59 +0,0 @@ -# Class: RDoc::Parser::ChangeLog -**Inherits:** RDoc::Parser - -**Includes:** RDoc::Parser::Text - - -A ChangeLog file parser. - -This parser converts a ChangeLog into an RDoc::Markup::Document. When viewed -as HTML a ChangeLog page will have an entry for each day's entries in the -sidebar table of contents. - -This parser is meant to parse the MRI ChangeLog, but can be used to parse any -[GNU style Change -Log](http://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html). - - - -#Instance Methods -## continue_entry_body(entry_body, continuation) [](#method-i-continue_entry_body) -Attaches the `continuation` of the previous line to the `entry_body`. - -Continued function listings are joined together as a single entry. Continued -descriptions are joined to make a single paragraph. - -## create_document(groups) [](#method-i-create_document) -Creates an RDoc::Markup::Document given the `groups` of ChangeLog entries. - -## create_entries(entries) [](#method-i-create_entries) -Returns a list of ChangeLog entries an RDoc::Markup nodes for the given -`entries`. - -## create_items(items) [](#method-i-create_items) -Returns an RDoc::Markup::List containing the given `items` in the ChangeLog - -## group_entries(entries) [](#method-i-group_entries) -Groups `entries` by date. - -## parse_date(date) [](#method-i-parse_date) -Parse date in ISO-8601, RFC-2822, or default of Git - -## parse_entries() [](#method-i-parse_entries) -Parses the entries in the ChangeLog. - -Returns an Array of each ChangeLog entry in order of parsing. - -A ChangeLog entry is an Array containing the ChangeLog title (date and -committer) and an Array of ChangeLog items (file and function changed with -description). - -An example result would be: - - [ 'Tue Dec 4 08:33:46 2012 Eric Hodel ', - [ 'README.EXT: Converted to RDoc format', - 'README.EXT.ja: ditto']] - -## scan() [](#method-i-scan) -Converts the ChangeLog into an RDoc::Markup::Document - diff --git a/example/ruby/RDoc/Parser/ChangeLog/Git.md b/example/ruby/RDoc/Parser/ChangeLog/Git.md deleted file mode 100644 index 8d0c845..0000000 --- a/example/ruby/RDoc/Parser/ChangeLog/Git.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: RDoc::Parser::ChangeLog::Git - - -The extension for Git commit log - - - -#Instance Methods -## create_entries(entries) [](#method-i-create_entries) -Returns a list of ChangeLog entries as RDoc::Parser::ChangeLog::Git::LogEntry -list for the given `entries`. - -## parse_entries() [](#method-i-parse_entries) -Parses the entries in the Git commit logs - -## parse_info(info) [](#method-i-parse_info) -Parses auxiliary info. Currently `base-url` to expand references is -effective. - diff --git a/example/ruby/RDoc/Parser/ChangeLog/Git/LogEntry.md b/example/ruby/RDoc/Parser/ChangeLog/Git/LogEntry.md deleted file mode 100644 index faaed08..0000000 --- a/example/ruby/RDoc/Parser/ChangeLog/Git/LogEntry.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: RDoc::Parser::ChangeLog::Git::LogEntry -**Inherits:** Struct - - - - -# Attributes -## author[RW] [](#attribute-i-author) -Returns the value of attribute author - -**@return** [Object] the current value of author - -## base[RW] [](#attribute-i-base) -Returns the value of attribute base - -**@return** [Object] the current value of base - -## commit[RW] [](#attribute-i-commit) -Returns the value of attribute commit - -**@return** [Object] the current value of commit - -## contents[RW] [](#attribute-i-contents) -Returns the value of attribute contents - -**@return** [Object] the current value of contents - -## date[RW] [](#attribute-i-date) -Returns the value of attribute date - -**@return** [Object] the current value of date - -## email[RW] [](#attribute-i-email) -Returns the value of attribute email - -**@return** [Object] the current value of email - - -#Instance Methods -## accept(visitor) [](#method-i-accept) - -## aref() [](#method-i-aref) - -## initialize(base, commit, author, email, date, contents) [](#method-i-initialize) - -**@return** [LogEntry] a new instance of LogEntry - -## label(contextnil) [](#method-i-label) - -## level() [](#method-i-level) - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## text() [](#method-i-text) - diff --git a/example/ruby/RDoc/Parser/Markdown.md b/example/ruby/RDoc/Parser/Markdown.md deleted file mode 100644 index cd3ed55..0000000 --- a/example/ruby/RDoc/Parser/Markdown.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: RDoc::Parser::Markdown -**Inherits:** RDoc::Parser - -**Includes:** RDoc::Parser::Text - - -Parse a Markdown format file. The parsed RDoc::Markup::Document is attached -as a file comment. - - - -#Instance Methods -## scan() [](#method-i-scan) -Creates an Markdown-format TopLevel for the given file. - diff --git a/example/ruby/RDoc/Parser/PrismRuby.md b/example/ruby/RDoc/Parser/PrismRuby.md deleted file mode 100644 index d5d553e..0000000 --- a/example/ruby/RDoc/Parser/PrismRuby.md +++ /dev/null @@ -1,148 +0,0 @@ -# Class: RDoc::Parser::PrismRuby -**Inherits:** RDoc::Parser - - -Parse and collect document from Ruby source code. RDoc::Parser::PrismRuby is -compatible with RDoc::Parser::Ruby and aims to replace it. - - -# Attributes -## container[RW] [](#attribute-i-container) -Returns the value of attribute container. - -## singleton[RW] [](#attribute-i-singleton) -Returns the value of attribute singleton. - -## visibility[RW] [](#attribute-i-visibility) -Returns the value of attribute visibility. - - -#Instance Methods -## add_alias_method(old_name, new_name, line_no) [](#method-i-add_alias_method) -Handles `alias foo bar` and `alias_method :foo, :bar` - -## add_attributes(names, rw, line_no) [](#method-i-add_attributes) -Handles `attr :a, :b`, `attr_reader :a, :b`, `attr_writer :a, :b` and -`attr_accessor :a, :b` - -## add_constant(constant_name, rhs_name, start_line, end_line) [](#method-i-add_constant) -Adds a constant - -## add_extends(names, line_no) [](#method-i-add_extends) -Handle `extend Foo, Bar` - -## add_includes(names, line_no) [](#method-i-add_includes) -Handle `include Foo, Bar` - -## add_includes_extends(names, rdoc_class, line_no) [](#method-i-add_includes_extends) -:nodoc: - -## add_method(name, receiver_name:, receiver_fallback_type:, visibility:, singleton:, params:, calls_super:, block_params:, tokens:, start_line:, end_line:) [](#method-i-add_method) -Adds a method defined by `def` syntax - -## add_module_or_class(module_name, start_line, end_line, is_class:false, superclass_name:nil) [](#method-i-add_module_or_class) -Adds module or class - -## call_node_name_arguments(call_node) [](#method-i-call_node_name_arguments) -:nodoc: - -## change_method_to_module_function(names) [](#method-i-change_method_to_module_function) -Handles `module_function :foo, :bar` - -## change_method_visibility(names, visibility, singleton:@singleton) [](#method-i-change_method_visibility) -Handles `public :foo, :bar` `private :foo, :bar` and `protected :foo, :bar` - -## consecutive_comment(line_no) [](#method-i-consecutive_comment) -Returns consecutive comment linked to the given line number - -## file_line_comment_token(line_no) [](#method-i-file_line_comment_token) -:nodoc: - -## find_or_create_constant_owner_name(constant_path) [](#method-i-find_or_create_constant_owner_name) -Returns a pair of owner module and constant name from a given constant path. -Creates owner module if it does not exist. - -## find_or_create_module_path(module_name, create_mode) [](#method-i-find_or_create_module_path) -Find or create module or class from a given module name. If module or class -does not exist, creates a module or a class according to `create_mode` -argument. - -## handle_consecutive_comment_directive(code_object, comment) [](#method-i-handle_consecutive_comment_directive) -:nodoc: - -## handle_meta_method_comment(comment, node) [](#method-i-handle_meta_method_comment) -Handles meta method comments - -## handle_modifier_directive(code_object, line_no) [](#method-i-handle_modifier_directive) -:nodoc: - -## handle_standalone_consecutive_comment_directive(comment, line_no, start_line) [](#method-i-handle_standalone_consecutive_comment_directive) -:nodoc: - -## initialize(top_level, file_name, content, options, stats) [](#method-i-initialize) - -**@return** [PrismRuby] a new instance of PrismRuby - -## normal_comment_treat_as_ghost_method_for_now?(comment_text, line_no) [](#method-i-normal_comment_treat_as_ghost_method_for_now?) -:nodoc: - -**@return** [Boolean] - -## parse_comment_tomdoc(container, comment, line_no, start_line) [](#method-i-parse_comment_tomdoc) -Creates an RDoc::Method on `container` from `comment` if there is a Signature -section in the comment - -## prepare_comments(comments) [](#method-i-prepare_comments) -Prepares comments for processing. Comments are grouped into consecutive. -Consecutive comment is linked to the next non-blank line. - -Example: - 01| class A # modifier comment 1 - 02| def foo; end # modifier comment 2 - 03| - 04| # consecutive comment 1 start_line: 4 - 05| # consecutive comment 1 linked to line: 7 - 06| - 07| # consecutive comment 2 start_line: 7 - 08| # consecutive comment 2 linked to line: 10 - 09| - 10| def bar; end # consecutive comment 2 linked to this line - 11| end - -## prepare_line_nodes(node) [](#method-i-prepare_line_nodes) -Assign AST node to a line. This is used to show meta-method source code in the -documentation. - -## process_comments_until(line_no_until) [](#method-i-process_comments_until) -Processes consecutive comments that were not linked to any documentable code -until the given line number - -## record_location(container) [](#method-i-record_location) -Records the location of this `container` in the file for this parser and adds -it to the list of classes and modules in the file. - -## resolve_constant_path(constant_path) [](#method-i-resolve_constant_path) -Resolves constant path to a full path by searching module nesting - -## scan() [](#method-i-scan) -Scans this Ruby file for Ruby constructs - -## should_document?(code_object) [](#method-i-should_document?) -:nodoc: - -**@return** [Boolean] - -## skip_comments_until(line_no_until) [](#method-i-skip_comments_until) -Skips all undocumentable consecutive comments until the given line number. -Undocumentable comments are comments written inside `def` or inside -undocumentable class/module - -## slice_tokens(start_pos, end_pos) [](#method-i-slice_tokens) -:nodoc: - -## visible_tokens_from_location(location) [](#method-i-visible_tokens_from_location) -Returns tokens from the given location - -## with_container(container, singleton:false) [](#method-i-with_container) -Dive into another container - diff --git a/example/ruby/RDoc/Parser/PrismRuby/RDocVisitor.md b/example/ruby/RDoc/Parser/PrismRuby/RDocVisitor.md deleted file mode 100644 index 4e9c7b6..0000000 --- a/example/ruby/RDoc/Parser/PrismRuby/RDocVisitor.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: RDoc::Parser::PrismRuby::RDocVisitor -**Inherits:** Prism::Visitor - - -:nodoc: - - - -#Instance Methods -## initialize(scanner, top_level, store) [](#method-i-initialize) - -**@return** [RDocVisitor] a new instance of RDocVisitor - -## visit_alias_method_node(node) [](#method-i-visit_alias_method_node) - -## visit_call_node(node) [](#method-i-visit_call_node) - -## visit_class_node(node) [](#method-i-visit_class_node) - -## visit_constant_path_write_node(node) [](#method-i-visit_constant_path_write_node) - -## visit_constant_write_node(node) [](#method-i-visit_constant_write_node) - -## visit_def_node(node) [](#method-i-visit_def_node) - -## visit_module_node(node) [](#method-i-visit_module_node) - -## visit_singleton_class_node(node) [](#method-i-visit_singleton_class_node) - diff --git a/example/ruby/RDoc/Parser/PrismRuby/RDocVisitor/MethodSignatureVisitor.md b/example/ruby/RDoc/Parser/PrismRuby/RDocVisitor/MethodSignatureVisitor.md deleted file mode 100644 index 1dbd2b1..0000000 --- a/example/ruby/RDoc/Parser/PrismRuby/RDocVisitor/MethodSignatureVisitor.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: RDoc::Parser::PrismRuby::RDocVisitor::MethodSignatureVisitor -**Inherits:** Prism::Visitor - - -:nodoc: - - -# Class Methods -## scan_signature(def_node ) [](#method-c-scan_signature) -# Attributes -## calls_super[RW] [](#attribute-i-calls_super) -Returns the value of attribute calls_super. - -## params[RW] [](#attribute-i-params) -Returns the value of attribute params. - -## yields[RW] [](#attribute-i-yields) -Returns the value of attribute yields. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MethodSignatureVisitor] a new instance of MethodSignatureVisitor - -## visit_def_node(node) [](#method-i-visit_def_node) - -## visit_forwarding_super_node(node) [](#method-i-visit_forwarding_super_node) - -## visit_super_node(node) [](#method-i-visit_super_node) - -## visit_yield_node(node) [](#method-i-visit_yield_node) - diff --git a/example/ruby/RDoc/Parser/RD.md b/example/ruby/RDoc/Parser/RD.md deleted file mode 100644 index ea7b826..0000000 --- a/example/ruby/RDoc/Parser/RD.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: RDoc::Parser::RD -**Inherits:** RDoc::Parser - -**Includes:** RDoc::Parser::Text - - -Parse a RD format file. The parsed RDoc::Markup::Document is attached as a -file comment. - - - -#Instance Methods -## scan() [](#method-i-scan) -Creates an rd-format TopLevel for the given file. - diff --git a/example/ruby/RDoc/Parser/RipperStateLex.md b/example/ruby/RDoc/Parser/RipperStateLex.md deleted file mode 100644 index 2b37f6c..0000000 --- a/example/ruby/RDoc/Parser/RipperStateLex.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: RDoc::Parser::RipperStateLex -**Inherits:** Object - - -Wrapper for Ripper lex states - - -# Class Methods -## end?(token ) [](#method-c-end?) -Returns `true` if lex state will be `END` after `token`. -**@return** [Boolean] - -## parse(code ) [](#method-c-parse) -Returns tokens parsed from `code`. - -#Instance Methods -## get_squashed_tk() [](#method-i-get_squashed_tk) - -## initialize(code) [](#method-i-initialize) -New lexer for `code`. - -**@return** [RipperStateLex] a new instance of RipperStateLex - diff --git a/example/ruby/RDoc/Parser/RipperStateLex/InnerStateLex.md b/example/ruby/RDoc/Parser/RipperStateLex/InnerStateLex.md deleted file mode 100644 index dc1cb0d..0000000 --- a/example/ruby/RDoc/Parser/RipperStateLex/InnerStateLex.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RDoc::Parser::RipperStateLex::InnerStateLex -**Inherits:** Ripper::Filter - - - - - -#Instance Methods -## initialize(code) [](#method-i-initialize) - -**@return** [InnerStateLex] a new instance of InnerStateLex - -## on_default(event, tok, data) [](#method-i-on_default) - diff --git a/example/ruby/RDoc/Parser/RipperStateLex/Token.md b/example/ruby/RDoc/Parser/RipperStateLex/Token.md deleted file mode 100644 index 3c9f7e9..0000000 --- a/example/ruby/RDoc/Parser/RipperStateLex/Token.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: RDoc::Parser::RipperStateLex::Token -**Inherits:** Struct - - -:stopdoc: - - -# Attributes -## char_no[RW] [](#attribute-i-char_no) -Returns the value of attribute char_no - -**@return** [Object] the current value of char_no - -## kind[RW] [](#attribute-i-kind) -Returns the value of attribute kind - -**@return** [Object] the current value of kind - -## line_no[RW] [](#attribute-i-line_no) -Returns the value of attribute line_no - -**@return** [Object] the current value of line_no - -## state[RW] [](#attribute-i-state) -Returns the value of attribute state - -**@return** [Object] the current value of state - -## text[RW] [](#attribute-i-text) -Returns the value of attribute text - -**@return** [Object] the current value of text - - diff --git a/example/ruby/RDoc/Parser/Ruby.md b/example/ruby/RDoc/Parser/Ruby.md deleted file mode 100644 index cdc332f..0000000 --- a/example/ruby/RDoc/Parser/Ruby.md +++ /dev/null @@ -1,501 +0,0 @@ -# Class: RDoc::Parser::Ruby -**Inherits:** RDoc::Parser - -**Includes:** RDoc::Parser::RubyTools, RDoc::TokenStream - - -Extracts code elements from a source file returning a TopLevel object -containing the constituent file elements. - -This file is based on rtags - -RubyParser understands how to document: -* classes -* modules -* methods -* constants -* aliases -* private, public, protected -* private_class_function, public_class_function -* private_constant, public_constant -* module_function -* attr, attr_reader, attr_writer, attr_accessor -* extra accessors given on the command line -* metaprogrammed methods -* require -* include - -## Method Arguments - --- NOTE: I don't think this works, needs tests, remove the paragraph following -this block when known to work - -The parser extracts the arguments from the method definition. You can -override this with a custom argument definition using the :args: directive: - - ## - # This method tries over and over until it is tired - - def go_go_go(thing_to_try, tries = 10) # :args: thing_to_try - puts thing_to_try - go_go_go thing_to_try, tries - 1 - end - -If you have a more-complex set of overrides you can use the :call-seq: -directive: ++ - -The parser extracts the arguments from the method definition. You can -override this with a custom argument definition using the :call-seq: -directive: - - ## - # This method can be called with a range or an offset and length - # - # :call-seq: - # my_method(Range) - # my_method(offset, length) - - def my_method(*args) - end - -The parser extracts `yield` expressions from method bodies to gather the -yielded argument names. If your method manually calls a block instead of -yielding or you want to override the discovered argument names use the -:yields: directive: - - ## - # My method is awesome - - def my_method(&block) # :yields: happy, times - block.call 1, 2 - end - -## Metaprogrammed Methods - -To pick up a metaprogrammed method, the parser looks for a comment starting -with '##' before an identifier: - - ## - # This is a meta-programmed method! - - add_my_method :meta_method, :arg1, :arg2 - -The parser looks at the token after the identifier to determine the name, in -this example, :meta_method. If a name cannot be found, a warning is printed -and 'unknown is used. - -You can force the name of a method using the :method: directive: - - ## - # :method: some_method! - -By default, meta-methods are instance methods. To indicate that a method is a -singleton method instead use the :singleton-method: directive: - - ## - # :singleton-method: - -You can also use the :singleton-method: directive with a name: - - ## - # :singleton-method: some_method! - -You can define arguments for metaprogrammed methods via either the :call-seq:, -:arg: or :args: directives. - -Additionally you can mark a method as an attribute by using :attr:, -:attr_reader:, :attr_writer: or :attr_accessor:. Just like for :method:, the -name is optional. - - ## - # :attr_reader: my_attr_name - -## Hidden methods and attributes - -You can provide documentation for methods that don't appear using the -:method:, :singleton-method: and :attr: directives: - - ## - # :attr_writer: ghost_writer - # There is an attribute here, but you can't see it! - - ## - # :method: ghost_method - # There is a method here, but you can't see it! - - ## - # this is a comment for a regular method - - def regular_method() end - -Note that by default, the :method: directive will be ignored if there is a -standard rdocable item following it. - - - -#Instance Methods -## add_token(token) [](#method-i-add_token) -Adds one `token` to the collected tokens - -## add_token_listener(obj) [](#method-i-add_token_listener) -Adds a token listener `obj`, but you should probably use token_listener - -## add_tokens(tokens) [](#method-i-add_tokens) -Adds `tokens` to the collected tokens - -## collect_first_comment() [](#method-i-collect_first_comment) -Look for the first comment in a file that isn't a shebang line. - -## collect_tokens() [](#method-i-collect_tokens) -Starts collecting tokens - -## consume_trailing_spaces() [](#method-i-consume_trailing_spaces) -Consumes trailing whitespace from the token stream - -## create_attr(container, single, name, rw, comment) [](#method-i-create_attr) -Creates a new attribute in `container` with `name`. - -## create_module_alias(container, constant, rhs_name) [](#method-i-create_module_alias) -Creates a module alias in `container` at `rhs_name` (or at the top-level for -"::") with the name from `constant`. - -## error(msg) [](#method-i-error) -Aborts with `msg` - -## get_bool() [](#method-i-get_bool) -Looks for a true or false token. - -## get_class_or_module(container, ignore_constantsfalse) [](#method-i-get_class_or_module) -Look for the name of a class of module (optionally with a leading -: or - -with -: separated named) and return the ultimate name, the associated - -container, and the given name (with the ::). - -## get_class_specification() [](#method-i-get_class_specification) -Return a superclass, which can be either a constant of an expression - -## get_constant() [](#method-i-get_constant) -Parse a constant, which might be qualified by one or more class or module -names - -## get_end_token(tk) [](#method-i-get_end_token) -Little hack going on here. In the statement: - - f = 2*(1+yield) - -We see the RPAREN as the next token, so we need to exit early. This still -won't catch all cases (such as "a = yield + 1" - -## get_included_module_with_optional_parens() [](#method-i-get_included_module_with_optional_parens) -Get an included module that may be surrounded by parens - -## get_method_container(container, name_t) [](#method-i-get_method_container) -Retrieves the method container for a singleton method. - -## get_symbol_or_name() [](#method-i-get_symbol_or_name) -Extracts a name or symbol from the token stream. - -## get_tk() [](#method-i-get_tk) -Fetches the next token from the scanner - -## get_tk_until(*tokens) [](#method-i-get_tk_until) -Reads and returns all tokens up to one of `tokens`. Leaves the matched token -in the token list. - -## get_tkread() [](#method-i-get_tkread) -Retrieves a String representation of the read tokens - -## get_tkread_clean(pattern, replacement) [](#method-i-get_tkread_clean) -Retrieves the read token stream and replaces `pattern` with `replacement` -using gsub. If the result is only a ";" returns an empty string. - -## get_visibility_information(tk, single) [](#method-i-get_visibility_information) -Extracts the visibility information for the visibility token `tk` and `single` -class type identifier. - -Returns the visibility type (a string), the visibility (a symbol) and -`singleton` if the methods following should be converted to singleton methods. - -## initialize(top_level, file_name, content, options, stats) [](#method-i-initialize) -Creates a new Ruby parser. - -**@return** [Ruby] a new instance of Ruby - -## look_for_directives_in(container, comment) [](#method-i-look_for_directives_in) -Look for directives in a normal comment block: - - # :stopdoc: - # Don't display comment from this point forward - -This routine modifies its `comment` parameter. - -## make_message(message) [](#method-i-make_message) -Adds useful info about the parser to `message` - -## new_comment(comment, line_nonil) [](#method-i-new_comment) -Creates a comment with the correct format - -## parse_alias(context, single, tk, comment) [](#method-i-parse_alias) -Parses an `alias` in `context` with `comment` - -## parse_attr(context, single, tk, comment) [](#method-i-parse_attr) -Creates an RDoc::Attr for the name following `tk`, setting the comment to -`comment`. - -## parse_attr_accessor(context, single, tk, comment) [](#method-i-parse_attr_accessor) -Creates an RDoc::Attr for each attribute listed after `tk`, setting the -comment for each to `comment`. - -## parse_call_parameters(tk) [](#method-i-parse_call_parameters) -Extracts call parameters from the token stream. - -## parse_class(container, single, tk, comment) [](#method-i-parse_class) -Parses a class in `context` with `comment` - -## parse_class_regular(container, declaration_context, single, name_t, given_name, comment) [](#method-i-parse_class_regular) -Parses and creates a regular class - -## parse_class_singleton(container, name, comment) [](#method-i-parse_class_singleton) -Parses a singleton class in `container` with the given `name` and `comment`. - -## parse_comment(container, tk, comment) [](#method-i-parse_comment) -Generates an RDoc::Method or RDoc::Attr from `comment` by looking for :method: -or :attr: directives in `comment`. - -## parse_comment_attr(container, type, name, comment) [](#method-i-parse_comment_attr) -Parse a comment that is describing an attribute in `container` with the given -`name` and `comment`. - -## parse_comment_ghost(container, text, name, column, line_no, comment) [](#method-i-parse_comment_ghost) -:nodoc: - -## parse_comment_tomdoc(container, tk, comment) [](#method-i-parse_comment_tomdoc) -Creates an RDoc::Method on `container` from `comment` if there is a Signature -section in the comment - -## parse_constant(container, tk, comment, ignore_constantsfalse) [](#method-i-parse_constant) -Parses a constant in `context` with `comment`. If `ignore_constants` is true, -no found constants will be added to RDoc. - -## parse_constant_body(container, constant, is_array_or_hash) [](#method-i-parse_constant_body) -:nodoc: - -## parse_constant_visibility(container, single, tk) [](#method-i-parse_constant_visibility) -Parses a Module#private_constant or Module#public_constant call from `tk`. - -## parse_extend_or_include(klass, container, comment) [](#method-i-parse_extend_or_include) -Parses an `include` or `extend`, indicated by the `klass` and adds it to -`container` # with `comment` - -## parse_identifier(container, single, tk, comment) [](#method-i-parse_identifier) -Parses identifiers that can create new methods or change visibility. - -Returns true if the comment was not consumed. - -## parse_included_with_activesupport_concern(container, comment) [](#method-i-parse_included_with_activesupport_concern) -Parses an `included` with a block feature of ActiveSupport::Concern. - -## parse_meta_attr(context, single, tk, comment) [](#method-i-parse_meta_attr) -Parses a meta-programmed attribute and creates an RDoc::Attr. - -To create foo and bar attributes on class C with comment "My attributes": - - class C - - ## - # :attr: - # - # My attributes - - my_attr :foo, :bar - - end - -To create a foo attribute on class C with comment "My attribute": - - class C - - ## - # :attr: foo - # - # My attribute - - my_attr :foo, :bar - - end - -## parse_meta_method(container, single, tk, comment) [](#method-i-parse_meta_method) -Parses a meta-programmed method - -## parse_meta_method_name(comment, tk) [](#method-i-parse_meta_method_name) -Parses the name of a metaprogrammed method. `comment` is used to determine -the name while `tk` is used in an error message if the name cannot be -determined. - -## parse_meta_method_params(container, single, meth, tk, comment) [](#method-i-parse_meta_method_params) -Parses the parameters and block for a meta-programmed method. - -## parse_method(container, single, tk, comment) [](#method-i-parse_method) -Parses a normal method defined by `def` - -## parse_method_dummy(container) [](#method-i-parse_method_dummy) -Parses a method that needs to be ignored. - -## parse_method_name(container) [](#method-i-parse_method_name) -Parses the name of a method in `container`. - -Returns the method name, the container it is in (for def Foo.name) and if it -is a singleton or regular method. - -## parse_method_name_regular(container, name_t) [](#method-i-parse_method_name_regular) -For the given `container` and initial name token `name_t` the method name is -parsed from the token stream for a regular method. - -## parse_method_name_singleton(container, name_t) [](#method-i-parse_method_name_singleton) -For the given `container` and initial name token `name_t` the method name and -the new `container` (if necessary) are parsed from the token stream for a -singleton method. - -## parse_method_or_yield_parameters(methodnil, modifiersRDoc::METHOD_MODIFIERS) [](#method-i-parse_method_or_yield_parameters) -Extracts `yield` parameters from `method` - -## parse_method_parameters(method) [](#method-i-parse_method_parameters) -Capture the method's parameters. Along the way, look for a comment containing: - - # yields: .... - -and add this as the block_params for the method - -## parse_method_params_and_body(container, single, meth, added_container) [](#method-i-parse_method_params_and_body) -Parses the parameters and body of `meth` - -## parse_module(container, single, tk, comment) [](#method-i-parse_module) -Parses an RDoc::NormalModule in `container` with `comment` - -## parse_require(context, comment) [](#method-i-parse_require) -Parses an RDoc::Require in `context` containing `comment` - -## parse_rescue() [](#method-i-parse_rescue) -Parses a rescue - -## parse_statements(container, singleNORMAL, current_methodnil, commentnew_comment('')) [](#method-i-parse_statements) -The core of the Ruby parser. - -## parse_symbol_arg(nonil) [](#method-i-parse_symbol_arg) -Parse up to `no` symbol arguments - -## parse_symbol_arg_paren(no) [](#method-i-parse_symbol_arg_paren) -Parses up to `no` symbol arguments surrounded by () and places them in `args`. - -## parse_symbol_arg_space(no, tk) [](#method-i-parse_symbol_arg_space) -Parses up to `no` symbol arguments separated by spaces and places them in -`args`. - -## parse_symbol_in_arg() [](#method-i-parse_symbol_in_arg) -Returns symbol text from the next token - -## parse_top_level_statements(container) [](#method-i-parse_top_level_statements) -Parses statements in the top-level `container` - -## parse_visibility(container, single, tk) [](#method-i-parse_visibility) -Determines the visibility in `container` from `tk` - -## parse_yield(context, single, tk, method) [](#method-i-parse_yield) -Determines the block parameter for `context` - -## peek_read() [](#method-i-peek_read) -Peek equivalent for get_tkread - -## peek_tk() [](#method-i-peek_tk) -Peek at the next token, but don't remove it from the stream - -## pop_token() [](#method-i-pop_token) -Remove the last token from the collected tokens - -## read_directive(allowed) [](#method-i-read_directive) -Directives are modifier comments that can appear after class, module, or -method names. For example: - - def fred # :yields: a, b - -or: - - class MyClass # :nodoc: - -We return the directive name and any parameters as a two element array if the -name is in `allowed`. A directive can be found anywhere up to the end of the -current line. - -## read_documentation_modifiers(context, allowed) [](#method-i-read_documentation_modifiers) -Handles directives following the definition for `context` (any -RDoc::CodeObject) if the directives are `allowed` at this point. - -See also RDoc::Markup::PreProcess#handle_directive - -## record_location(container) [](#method-i-record_location) -Records the location of this `container` in the file for this parser and adds -it to the list of classes and modules in the file. - -## remove_token_listener(obj) [](#method-i-remove_token_listener) -Removes the token listener `obj` - -## reset() [](#method-i-reset) -Resets the tools - -## retrieve_comment_body(tk) [](#method-i-retrieve_comment_body) -Retrieve comment body without =begin/=end - -## scan() [](#method-i-scan) -Scans this Ruby file for Ruby constructs - -## skip_for_variable() [](#method-i-skip_for_variable) -skip the var [in] part of a 'for' statement - -## skip_method(container) [](#method-i-skip_method) -Skips the next method in `container` - -## skip_optional_do_after_expression() [](#method-i-skip_optional_do_after_expression) -while, until, and for have an optional do - -## skip_parentheses(&block) [](#method-i-skip_parentheses) -Skip opening parentheses and yield the block. Skip closing parentheses too -when exists. - -## skip_tkspace() [](#method-i-skip_tkspace) -Skips whitespace tokens including newlines - -## skip_tkspace_comment(skip_nltrue) [](#method-i-skip_tkspace_comment) -Skip spaces until a comment is found - -## skip_tkspace_without_nl() [](#method-i-skip_tkspace_without_nl) -Skips whitespace tokens excluding newlines - -## suppress_parents(container, ancestor) [](#method-i-suppress_parents) -Marks containers between `container` and `ancestor` as ignored - -## tk_nl?(tk) [](#method-i-tk_nl?) -Return `true` if `tk` is a newline. - -**@return** [Boolean] - -## token_listener(obj) [](#method-i-token_listener) -Has `obj` listen to tokens - -## token_stream() [](#method-i-token_stream) -Current token stream - -## tokens_to_s() [](#method-i-tokens_to_s) -Returns a string representation of the token stream - -## unget_tk(tk) [](#method-i-unget_tk) -Returns `tk` to the scanner - -## update_visibility(container, vis_type, vis, singleton) [](#method-i-update_visibility) -Updates visibility in `container` from `vis_type` and `vis`. - -## warn(message) [](#method-i-warn) -Prints `message` to +$stderr+ unless we're being quiet - diff --git a/example/ruby/RDoc/Parser/RubyTools.md b/example/ruby/RDoc/Parser/RubyTools.md deleted file mode 100644 index 79e0a44..0000000 --- a/example/ruby/RDoc/Parser/RubyTools.md +++ /dev/null @@ -1,45 +0,0 @@ -# Module: RDoc::Parser::RubyTools - - -Collection of methods for writing parsers - - - -#Instance Methods -## add_token_listener(obj) [](#method-i-add_token_listener) -Adds a token listener `obj`, but you should probably use token_listener - -## get_tk() [](#method-i-get_tk) -Fetches the next token from the scanner - -## get_tk_until(*tokens) [](#method-i-get_tk_until) -Reads and returns all tokens up to one of `tokens`. Leaves the matched token -in the token list. - -## get_tkread() [](#method-i-get_tkread) -Retrieves a String representation of the read tokens - -## peek_read() [](#method-i-peek_read) -Peek equivalent for get_tkread - -## peek_tk() [](#method-i-peek_tk) -Peek at the next token, but don't remove it from the stream - -## remove_token_listener(obj) [](#method-i-remove_token_listener) -Removes the token listener `obj` - -## reset() [](#method-i-reset) -Resets the tools - -## skip_tkspace() [](#method-i-skip_tkspace) -Skips whitespace tokens including newlines - -## skip_tkspace_without_nl() [](#method-i-skip_tkspace_without_nl) -Skips whitespace tokens excluding newlines - -## token_listener(obj) [](#method-i-token_listener) -Has `obj` listen to tokens - -## unget_tk(tk) [](#method-i-unget_tk) -Returns `tk` to the scanner - diff --git a/example/ruby/RDoc/Parser/Simple.md b/example/ruby/RDoc/Parser/Simple.md deleted file mode 100644 index f55c6fc..0000000 --- a/example/ruby/RDoc/Parser/Simple.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: RDoc::Parser::Simple -**Inherits:** RDoc::Parser - -**Includes:** RDoc::Parser::Text - - -Parse a non-source file. We basically take the whole thing as one big comment. - - -# Attributes -## content[RW] [](#attribute-i-content) -:nodoc: - - -#Instance Methods -## initialize(top_level, file_name, content, options, stats) [](#method-i-initialize) -Prepare to parse a plain file - -**@return** [Simple] a new instance of Simple - -## remove_coding_comment(text) [](#method-i-remove_coding_comment) -Removes the encoding magic comment from `text` - -## remove_private_comment(comment) [](#method-i-remove_private_comment) -Removes private comments. - -Unlike RDoc::Comment#remove_private this implementation only looks for two -dashes at the beginning of the line. Three or more dashes are considered to -be a rule and ignored. - -## scan() [](#method-i-scan) -Extract the file contents and attach them to the TopLevel as a comment - diff --git a/example/ruby/RDoc/Parser/Text.md b/example/ruby/RDoc/Parser/Text.md deleted file mode 100644 index 964e1a9..0000000 --- a/example/ruby/RDoc/Parser/Text.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: RDoc::Parser::Text - - -Indicates this parser is text and doesn't contain code constructs. - -Include this module in a RDoc::Parser subclass to make it show up as a file, -not as part of a class or module. -- This is not named File to avoid -overriding ::File - - - diff --git a/example/ruby/RDoc/RD.md b/example/ruby/RDoc/RD.md deleted file mode 100644 index 8195ef4..0000000 --- a/example/ruby/RDoc/RD.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: RDoc::RD -**Inherits:** Object - - -racc/parser.rb end - - -# Class Methods -## parse(rd ) [](#method-c-parse) -Parses `rd` source and returns an RDoc::Markup::Document. If the `=begin` or -`=end` lines are missing they will be added. - diff --git a/example/ruby/RDoc/RD/BlockParser.md b/example/ruby/RDoc/RD/BlockParser.md deleted file mode 100644 index 4b15eee..0000000 --- a/example/ruby/RDoc/RD/BlockParser.md +++ /dev/null @@ -1,183 +0,0 @@ -# Class: RDoc::RD::BlockParser -**Inherits:** Racc::Parser - - -RD format parser for headings, paragraphs, lists, verbatim sections that exist -as blocks. - - -# Attributes -## footnotes[RW] [](#attribute-i-footnotes) -Footnotes for this document - -## include_path[RW] [](#attribute-i-include_path) -Path to find included files in - -## labels[RW] [](#attribute-i-labels) -Labels for items in this document - - -#Instance Methods -## _reduce_1(val, _values, result) [](#method-i-_reduce_1) -reduce 0 omitted - -## _reduce_10(val, _values, result) [](#method-i-_reduce_10) - -## _reduce_11(val, _values, result) [](#method-i-_reduce_11) - -## _reduce_12(val, _values, result) [](#method-i-_reduce_12) - -## _reduce_13(val, _values, result) [](#method-i-_reduce_13) - -## _reduce_14(val, _values, result) [](#method-i-_reduce_14) - -## _reduce_15(val, _values, result) [](#method-i-_reduce_15) - -## _reduce_16(val, _values, result) [](#method-i-_reduce_16) - -## _reduce_17(val, _values, result) [](#method-i-_reduce_17) - -## _reduce_18(val, _values, result) [](#method-i-_reduce_18) - -## _reduce_19(val, _values, result) [](#method-i-_reduce_19) - -## _reduce_2(val, _values, result) [](#method-i-_reduce_2) - -**@raise** [ParseError] - -## _reduce_20(val, _values, result) [](#method-i-_reduce_20) - -## _reduce_21(val, _values, result) [](#method-i-_reduce_21) - -## _reduce_22(val, _values, result) [](#method-i-_reduce_22) - -## _reduce_27(val, _values, result) [](#method-i-_reduce_27) -reduce 26 omitted - -## _reduce_28(val, _values, result) [](#method-i-_reduce_28) - -## _reduce_29(val, _values, result) [](#method-i-_reduce_29) - -## _reduce_3(val, _values, result) [](#method-i-_reduce_3) - -## _reduce_30(val, _values, result) [](#method-i-_reduce_30) - -## _reduce_31(val, _values, result) [](#method-i-_reduce_31) - -## _reduce_32(val, _values, result) [](#method-i-_reduce_32) - -## _reduce_33(val, _values, result) [](#method-i-_reduce_33) - -## _reduce_34(val, _values, result) [](#method-i-_reduce_34) - -## _reduce_35(val, _values, result) [](#method-i-_reduce_35) - -## _reduce_36(val, _values, result) [](#method-i-_reduce_36) - -## _reduce_37(val, _values, result) [](#method-i-_reduce_37) - -## _reduce_38(val, _values, result) [](#method-i-_reduce_38) - -## _reduce_39(val, _values, result) [](#method-i-_reduce_39) - -## _reduce_4(val, _values, result) [](#method-i-_reduce_4) - -## _reduce_40(val, _values, result) [](#method-i-_reduce_40) - -## _reduce_41(val, _values, result) [](#method-i-_reduce_41) - -## _reduce_42(val, _values, result) [](#method-i-_reduce_42) - -## _reduce_43(val, _values, result) [](#method-i-_reduce_43) - -## _reduce_44(val, _values, result) [](#method-i-_reduce_44) - -## _reduce_45(val, _values, result) [](#method-i-_reduce_45) - -## _reduce_46(val, _values, result) [](#method-i-_reduce_46) - -## _reduce_47(val, _values, result) [](#method-i-_reduce_47) - -## _reduce_48(val, _values, result) [](#method-i-_reduce_48) - -## _reduce_49(val, _values, result) [](#method-i-_reduce_49) - -## _reduce_5(val, _values, result) [](#method-i-_reduce_5) - -## _reduce_50(val, _values, result) [](#method-i-_reduce_50) - -## _reduce_51(val, _values, result) [](#method-i-_reduce_51) - -## _reduce_52(val, _values, result) [](#method-i-_reduce_52) - -## _reduce_54(val, _values, result) [](#method-i-_reduce_54) -reduce 53 omitted - -## _reduce_55(val, _values, result) [](#method-i-_reduce_55) - -## _reduce_57(val, _values, result) [](#method-i-_reduce_57) -reduce 56 omitted - -## _reduce_6(val, _values, result) [](#method-i-_reduce_6) - -## _reduce_62(val, _values, result) [](#method-i-_reduce_62) -reduce 61 omitted - -## _reduce_63(val, _values, result) [](#method-i-_reduce_63) - -## _reduce_64(val, _values, result) [](#method-i-_reduce_64) - -## _reduce_65(val, _values, result) [](#method-i-_reduce_65) - -## _reduce_66(val, _values, result) [](#method-i-_reduce_66) - -## _reduce_67(val, _values, result) [](#method-i-_reduce_67) - -## _reduce_68(val, _values, result) [](#method-i-_reduce_68) - -## _reduce_69(val, _values, result) [](#method-i-_reduce_69) - -## _reduce_71(val, _values, result) [](#method-i-_reduce_71) -reduce 70 omitted - -## _reduce_72(val, _values, result) [](#method-i-_reduce_72) - -## _reduce_8(val, _values, result) [](#method-i-_reduce_8) -reduce 7 omitted - -## _reduce_9(val, _values, result) [](#method-i-_reduce_9) - -## _reduce_none(val, _values, result) [](#method-i-_reduce_none) - -## add_footnote(content) [](#method-i-add_footnote) -Adds footnote `content` to the document - -## add_label(label) [](#method-i-add_label) -Adds label `label` to the document - -## content(values) [](#method-i-content) -Retrieves the content of `values` as a single String - -## initialize() [](#method-i-initialize) -Creates a new RDoc::RD::BlockParser. Use #parse to parse an rd-format -document. - -**@return** [BlockParser] a new instance of BlockParser - -## line_index() [](#method-i-line_index) -Current line number - -## next_token() [](#method-i-next_token) -Returns the next token from the document - -## on_error(et, ev, _values) [](#method-i-on_error) -Raises a ParseError when invalid formatting is found - -**@raise** [ParseError] - -## paragraph(value) [](#method-i-paragraph) -Creates a paragraph for `value` - -## parse(src) [](#method-i-parse) -Parses `src` and returns an RDoc::Markup::Document. - diff --git a/example/ruby/RDoc/RD/Inline.md b/example/ruby/RDoc/RD/Inline.md deleted file mode 100644 index 58d15f1..0000000 --- a/example/ruby/RDoc/RD/Inline.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: RDoc::RD::Inline -**Inherits:** Object - - -Inline keeps track of markup and labels to create proper links. - - -# Class Methods -## new(rdoc , reference rdoc) [](#method-c-new) -Creates a new Inline for `rdoc` and `reference`. - -`rdoc` may be another Inline or a String. If `reference` is not given it will -use the text from `rdoc`. -# Attributes -## rdoc[RW] [](#attribute-i-rdoc) -The markup of this reference in RDoc format - -## reference[RW] [](#attribute-i-reference) -The text of the reference - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## append(more) [](#method-i-append) -Appends `more` to this inline. `more` may be a String or another Inline. - -## initialize(rdoc, reference) [](#method-i-initialize) -Initializes the Inline with `rdoc` and `inline` - -**@return** [Inline] a new instance of Inline - -## inspect() [](#method-i-inspect) -:nodoc: - diff --git a/example/ruby/RDoc/RD/InlineParser.md b/example/ruby/RDoc/RD/InlineParser.md deleted file mode 100644 index 8dd54df..0000000 --- a/example/ruby/RDoc/RD/InlineParser.md +++ /dev/null @@ -1,148 +0,0 @@ -# Class: RDoc::RD::InlineParser -**Inherits:** Racc::Parser - - -RD format parser for inline markup such as emphasis, links, footnotes, etc. - - - -#Instance Methods -## _reduce_101(val, _values, result) [](#method-i-_reduce_101) -reduce 100 omitted - -## _reduce_102(val, _values, result) [](#method-i-_reduce_102) - -## _reduce_109(val, _values, result) [](#method-i-_reduce_109) -reduce 108 omitted - -## _reduce_111(val, _values, result) [](#method-i-_reduce_111) -reduce 110 omitted - -## _reduce_113(val, _values, result) [](#method-i-_reduce_113) -reduce 112 omitted - -## _reduce_114(val, _values, result) [](#method-i-_reduce_114) - -## _reduce_115(val, _values, result) [](#method-i-_reduce_115) - -## _reduce_13(val, _values, result) [](#method-i-_reduce_13) -reduce 12 omitted - -## _reduce_136(val, _values, result) [](#method-i-_reduce_136) -reduce 135 omitted - -## _reduce_14(val, _values, result) [](#method-i-_reduce_14) - -## _reduce_15(val, _values, result) [](#method-i-_reduce_15) - -## _reduce_16(val, _values, result) [](#method-i-_reduce_16) - -## _reduce_17(val, _values, result) [](#method-i-_reduce_17) - -## _reduce_18(val, _values, result) [](#method-i-_reduce_18) - -## _reduce_19(val, _values, result) [](#method-i-_reduce_19) - -## _reduce_2(val, _values, result) [](#method-i-_reduce_2) -reduce 1 omitted - -## _reduce_20(val, _values, result) [](#method-i-_reduce_20) - -## _reduce_21(val, _values, result) [](#method-i-_reduce_21) - -## _reduce_22(val, _values, result) [](#method-i-_reduce_22) - -## _reduce_23(val, _values, result) [](#method-i-_reduce_23) - -## _reduce_24(val, _values, result) [](#method-i-_reduce_24) - -## _reduce_25(val, _values, result) [](#method-i-_reduce_25) - -## _reduce_26(val, _values, result) [](#method-i-_reduce_26) - -## _reduce_27(val, _values, result) [](#method-i-_reduce_27) - -## _reduce_29(val, _values, result) [](#method-i-_reduce_29) -reduce 28 omitted - -## _reduce_3(val, _values, result) [](#method-i-_reduce_3) - -## _reduce_30(val, _values, result) [](#method-i-_reduce_30) - -## _reduce_31(val, _values, result) [](#method-i-_reduce_31) - -## _reduce_32(val, _values, result) [](#method-i-_reduce_32) - -## _reduce_33(val, _values, result) [](#method-i-_reduce_33) - -## _reduce_34(val, _values, result) [](#method-i-_reduce_34) - -## _reduce_36(val, _values, result) [](#method-i-_reduce_36) -reduce 35 omitted - -## _reduce_37(val, _values, result) [](#method-i-_reduce_37) - -## _reduce_38(val, _values, result) [](#method-i-_reduce_38) - -## _reduce_39(val, _values, result) [](#method-i-_reduce_39) - -## _reduce_40(val, _values, result) [](#method-i-_reduce_40) - -## _reduce_41(val, _values, result) [](#method-i-_reduce_41) - -## _reduce_43(val, _values, result) [](#method-i-_reduce_43) -reduce 42 omitted - -## _reduce_44(val, _values, result) [](#method-i-_reduce_44) - -## _reduce_45(val, _values, result) [](#method-i-_reduce_45) - -## _reduce_46(val, _values, result) [](#method-i-_reduce_46) - -## _reduce_57(val, _values, result) [](#method-i-_reduce_57) -reduce 56 omitted - -## _reduce_58(val, _values, result) [](#method-i-_reduce_58) - -## _reduce_59(val, _values, result) [](#method-i-_reduce_59) - -## _reduce_60(val, _values, result) [](#method-i-_reduce_60) - -## _reduce_62(val, _values, result) [](#method-i-_reduce_62) -reduce 61 omitted - -## _reduce_64(val, _values, result) [](#method-i-_reduce_64) -reduce 63 omitted - -## _reduce_78(val, _values, result) [](#method-i-_reduce_78) -reduce 77 omitted - -## _reduce_none(val, _values, result) [](#method-i-_reduce_none) -reduce 137 omitted - -## initialize(block_parser) [](#method-i-initialize) -Creates a new parser for inline markup in the rd format. The `block_parser` -is used to for footnotes and labels in the inline text. - -**@return** [InlineParser] a new instance of InlineParser - -## inline(rdoc, referencerdoc) [](#method-i-inline) -Creates a new RDoc::RD::Inline for the `rdoc` markup and the raw `reference` - -## next_token() [](#method-i-next_token) -Returns the next token from the inline text - -## next_words_on_error() [](#method-i-next_words_on_error) -Returns words following an error - -## on_error(et, ev, values) [](#method-i-on_error) -Raises a ParseError when invalid formatting is found - -**@raise** [ParseError] - -## parse(inline) [](#method-i-parse) -Parses the `inline` text from RD format into RDoc format. - -## prev_words_on_error(ev) [](#method-i-prev_words_on_error) -Returns words before the error - diff --git a/example/ruby/RDoc/RDoc.md b/example/ruby/RDoc/RDoc.md deleted file mode 100644 index 801b56a..0000000 --- a/example/ruby/RDoc/RDoc.md +++ /dev/null @@ -1,133 +0,0 @@ -# Class: RDoc::RDoc -**Inherits:** Object - - -This is the driver for generating RDoc output. It handles file parsing and -generation of output. - -To use this class to generate RDoc output via the API, the recommended way is: - - rdoc = RDoc::RDoc.new - options = RDoc::Options.load_options # returns an RDoc::Options instance - # set extra options - rdoc.document options - -You can also generate output like the `rdoc` executable: - - rdoc = RDoc::RDoc.new - rdoc.document argv - -Where `argv` is an array of strings, each corresponding to an argument you'd -give rdoc on the command line. See `rdoc --help` for details. - - -# Class Methods -## add_generator(klass ) [](#method-c-add_generator) -Add `klass` that can generate output after parsing -## current() [](#method-c-current) -Active RDoc::RDoc instance -## current=(rdoc ) [](#method-c-current=) -Sets the active RDoc::RDoc instance -# Attributes -## generator[RW] [](#attribute-i-generator) -Generator instance used for creating output - -## last_modified[RW] [](#attribute-i-last_modified) -Hash of files and their last modified times. - -## options[RW] [](#attribute-i-options) -RDoc options - -## stats[RW] [](#attribute-i-stats) -Accessor for statistics. Available after each call to parse_files - -## store[RW] [](#attribute-i-store) -The current documentation store - - -#Instance Methods -## document(options) [](#method-i-document) -Generates documentation or a coverage report depending upon the settings in -`options`. - -`options` can be either an RDoc::Options instance or an array of strings -equivalent to the strings that would be passed on the command line like `%w[-q --o doc -t My\ Doc\ Title]`. #document will automatically call -RDoc::Options#finish if an options instance was given. - -For a list of options, see either RDoc::Options or `rdoc --help`. - -By default, output will be stored in a directory called "doc" below the -current directory, so make sure you're somewhere writable before invoking. - -## error(msg) [](#method-i-error) -Report an error message and exit - -**@raise** [RDoc::Error] - -## gather_files(files) [](#method-i-gather_files) -Gathers a set of parseable files from the files and directories listed in -`files`. - -## generate() [](#method-i-generate) -Generates documentation for `file_info` (from #parse_files) into the output -dir using the generator selected by the RDoc options - -## handle_pipe() [](#method-i-handle_pipe) -Turns RDoc from stdin into HTML - -## initialize() [](#method-i-initialize) -Creates a new RDoc::RDoc instance. Call #document to parse files and generate -documentation. - -**@return** [RDoc] a new instance of RDoc - -## install_siginfo_handler() [](#method-i-install_siginfo_handler) -Installs a siginfo handler that prints the current filename. - -## list_files_in_directory(dir) [](#method-i-list_files_in_directory) -Return a list of the files to be processed in a directory. We know that this -directory doesn't have a .document file, so we're looking for real files. -However we may well contain subdirectories which must be tested for .document -files. - -## normalized_file_list(relative_files, force_docfalse, exclude_patternnil) [](#method-i-normalized_file_list) -Given a list of files and directories, create a list of all the Ruby files -they contain. - -If `force_doc` is true we always add the given files, if false, only add files -that we guarantee we can parse. It is true when looking at files given on the -command line, false when recursing through subdirectories. - -The effect of this is that if you want a file with a non-standard extension -parsed, you must name it explicitly. - -## output_flag_file(op_dir) [](#method-i-output_flag_file) -Return the path name of the flag file in an output directory. - -## parse_dot_doc_file(in_dir, filename) [](#method-i-parse_dot_doc_file) -The .document file contains a list of file and directory name patterns, -representing candidates for documentation. It may also contain comments -(starting with '#') - -## parse_file(filename) [](#method-i-parse_file) -Parses `filename` and returns an RDoc::TopLevel - -## parse_files(files) [](#method-i-parse_files) -Parse each file on the command line, recursively entering directories. - -## remove_siginfo_handler() [](#method-i-remove_siginfo_handler) -Removes a siginfo handler and replaces the previous - -## remove_unparseable(files) [](#method-i-remove_unparseable) -Removes file extensions known to be unparseable from `files` and TAGS files -for emacs and vim. - -## setup_output_dir(dir, force) [](#method-i-setup_output_dir) -Create an output dir if it doesn't exist. If it does exist, but doesn't -contain the flag file `created.rid` then we refuse to use it, as we may -clobber some manually generated documentation - -## update_output_dir(op_dir, time, last{}) [](#method-i-update_output_dir) -Update the flag file in an output directory. - diff --git a/example/ruby/RDoc/RI.md b/example/ruby/RDoc/RI.md deleted file mode 100644 index 4a4eb74..0000000 --- a/example/ruby/RDoc/RI.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: RDoc::RI - - -Namespace for the ri command line tool's implementation. - -See `ri --help` for details. - - - diff --git a/example/ruby/RDoc/RI/Driver.md b/example/ruby/RDoc/RI/Driver.md deleted file mode 100644 index 652071d..0000000 --- a/example/ruby/RDoc/RI/Driver.md +++ /dev/null @@ -1,238 +0,0 @@ -# Class: RDoc::RI::Driver -**Inherits:** Object - - -The RI driver implements the command-line ri tool. - -The driver supports: -* loading RI data from: - * Ruby's standard library - * RubyGems - * ~/.rdoc - * A user-supplied directory -* Paging output (uses RI_PAGER environment variable, PAGER environment - variable or the less, more and pager programs) -* Interactive mode with tab-completion -* Abbreviated names (ri Zl shows Zlib documentation) -* Colorized output -* Merging output from multiple RI data sources - - -# Class Methods -## default_options() [](#method-c-default_options) -Default options for ri -## dump(data_path ) [](#method-c-dump) -Dump `data_path` using pp -## process_args(argv ) [](#method-c-process_args) -Parses `argv` and returns a Hash of options -## run(argv ARGV) [](#method-c-run) -Runs the ri command line executable using `argv` -# Attributes -## show_all[RW] [](#attribute-i-show_all) -Show all method documentation following a class or module - -## stores[RW] [](#attribute-i-stores) -An RDoc::RI::Store for each entry in the RI path - -## use_stdout[RW] [](#attribute-i-use_stdout) -Controls the user of the pager vs $stdout - - -#Instance Methods -## add_also_in(out, also_in) [](#method-i-add_also_in) -Adds paths for undocumented classes `also_in` to `out` - -## add_class(out, name, classes) [](#method-i-add_class) -Adds a class header to `out` for class `name` which is described in `classes`. - -## add_extends(out, extends) [](#method-i-add_extends) -Adds `extends` to `out` - -## add_extension_modules(out, type, extensions) [](#method-i-add_extension_modules) -Adds a list of `extensions` to this module of the given `type` to `out`. -add_includes and add_extends call this, so you should use those directly. - -## add_extension_modules_multiple(out, store, modules) [](#method-i-add_extension_modules_multiple) -Renders multiple included `modules` from `store` to `out`. - -## add_extension_modules_single(out, store, include) [](#method-i-add_extension_modules_single) -Adds a single extension module `include` from `store` to `out` - -## add_from(out, store) [](#method-i-add_from) -Adds "(from ...)" to `out` for `store` - -## add_includes(out, includes) [](#method-i-add_includes) -Adds `includes` to `out` - -## add_method(out, name) [](#method-i-add_method) -Looks up the method `name` and adds it to `out` - -## add_method_documentation(out, klass) [](#method-i-add_method_documentation) -Adds documentation for all methods in `klass` to `out` - -## add_method_list(out, methods, name) [](#method-i-add_method_list) -Adds a list of `methods` to `out` with a heading of `name` - -## ancestors_of(klass) [](#method-i-ancestors_of) -Returns ancestor classes of `klass` - -## check_did_you_mean() [](#method-i-check_did_you_mean) -:nodoc: - -## class_cache() [](#method-i-class_cache) -For RubyGems backwards compatibility - -## class_document(name, found, klasses, includes, extends) [](#method-i-class_document) -Builds a RDoc::Markup::Document from `found`, `klasess` and `includes` - -## class_document_comment(out, comment) [](#method-i-class_document_comment) -Adds the class `comment` to `out`. - -## class_document_constants(out, klass) [](#method-i-class_document_constants) -Adds the constants from `klass` to the Document `out`. - -## classes() [](#method-i-classes) -Hash mapping a known class or module to the stores it can be loaded from - -## classes_and_includes_and_extends_for(name) [](#method-i-classes_and_includes_and_extends_for) -Returns the stores wherein `name` is found along with the classes, extends and -includes that match it - -## complete(name) [](#method-i-complete) -Completes `name` based on the caches. For Readline - -## complete_klass(name, klass, selector, method, completions) [](#method-i-complete_klass) -:nodoc: - -## complete_method(name, klass, selector, completions) [](#method-i-complete_method) -:nodoc: - -## display(document) [](#method-i-display) -Converts `document` to text and writes it to the pager - -## display_class(name) [](#method-i-display_class) -Outputs formatted RI data for class `name`. Groups undocumented classes - -## display_method(name) [](#method-i-display_method) -Outputs formatted RI data for method `name` - -## display_name(name) [](#method-i-display_name) -Outputs formatted RI data for the class or method `name`. - -Returns true if `name` was found, false if it was not an alternative could be -guessed, raises an error if `name` couldn't be guessed. - -## display_names(names) [](#method-i-display_names) -Displays each name in `name` - -## display_page(name) [](#method-i-display_page) -Outputs formatted RI data for page `name`. - -## display_page_list(store, pages, searchnil) [](#method-i-display_page_list) -Outputs a formatted RI page list for the pages in `store`. - -## expand_class(klass) [](#method-i-expand_class) -Expands abbreviated klass `klass` into a fully-qualified class. "Zl::Da" will -be expanded to Zlib::DataError. - -## expand_name(name) [](#method-i-expand_name) -Expands the class portion of `name` into a fully-qualified class. See -#expand_class. - -## expand_rdoc_refs_at_the_bottom(out) [](#method-i-expand_rdoc_refs_at_the_bottom) - -## filter_methods(found, name) [](#method-i-filter_methods) -Filters the methods in `found` trying to find a match for `name`. - -## find_methods(name) [](#method-i-find_methods) -Yields items matching `name` including the store they were found in, the class -being searched for, the class they were found in (an ancestor) the types of -methods to look up (from #method_type), and the method name being searched for - -## find_store(name) [](#method-i-find_store) -Finds a store that matches `name` which can be the name of a gem, "ruby", -"home" or "site". - -See also RDoc::Store#source - -**@raise** [RDoc::RI::Driver::NotFoundError] - -## formatter(io) [](#method-i-formatter) -Creates a new RDoc::Markup::Formatter. If a formatter is given with -f, use -it. If we're outputting to a pager, use bs, otherwise ansi. - -## initialize(initial_options{}) [](#method-i-initialize) -Creates a new driver using `initial_options` from ::process_args - -**@return** [Driver] a new instance of Driver - -## interactive() [](#method-i-interactive) -Runs ri interactively using Readline if it is available. - -## list_known_classes(names[]) [](#method-i-list_known_classes) -Lists classes known to ri starting with `names`. If `names` is empty all -known classes are shown. - -## list_methods_matching(name) [](#method-i-list_methods_matching) -Returns an Array of methods matching `name` - -## load_method(store, cache, klass, type, name) [](#method-i-load_method) -Loads RI data for method `name` on `klass` from `store`. `type` and `cache` -indicate if it is a class or instance method. - -## load_methods_matching(name) [](#method-i-load_methods_matching) -Returns an Array of RI data for methods matching `name` - -## lookup_method(name) [](#method-i-lookup_method) -Returns a filtered list of methods matching `name` - -## method_document(out, name, filtered) [](#method-i-method_document) -Builds a RDoc::Markup::Document from `found`, `klasses` and `includes` - -## method_type(selector) [](#method-i-method_type) -Returns the type of method (:both, :instance, :class) for `selector` - -## name_regexp(name) [](#method-i-name_regexp) -Returns a regular expression for `name` that will match an RDoc::AnyMethod's -name. - -## page() [](#method-i-page) -Paginates output through a pager program. - -## paging?() [](#method-i-paging?) -Are we using a pager? - -**@return** [Boolean] - -## parse_name(name) [](#method-i-parse_name) -Extracts the class, selector and method name parts from `name` like -Foo::Bar#baz. - -NOTE: Given Foo::Bar, Bar is considered a class even though it may be a method - -## render_class(out, store, klass, also_in) [](#method-i-render_class) -Renders the `klass` from `store` to `out`. If the klass has no documentable -items the class is added to `also_in` instead. - -## render_method(out, store, method, name) [](#method-i-render_method) -:nodoc: - -## render_method_arguments(out, arglists) [](#method-i-render_method_arguments) -:nodoc: - -## render_method_comment(out, method, alias_fornil) [](#method-i-render_method_comment) -:nodoc: - -## render_method_superclass(out, method) [](#method-i-render_method_superclass) -:nodoc: - -## run() [](#method-i-run) -Looks up and displays ri data according to the options given. - -## setup_pager() [](#method-i-setup_pager) -Sets up a pager program to pass output through. Tries the RI_PAGER and PAGER -environment variables followed by pager, less then more. - -## start_server() [](#method-i-start_server) -Starts a WEBrick server for ri. - diff --git a/example/ruby/RDoc/RI/Driver/Error.md b/example/ruby/RDoc/RI/Driver/Error.md deleted file mode 100644 index 88a67a8..0000000 --- a/example/ruby/RDoc/RI/Driver/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: RDoc::RI::Driver::Error -**Inherits:** RDoc::RI::Error - - -Base Driver error class - - - diff --git a/example/ruby/RDoc/RI/Driver/NotFoundError.md b/example/ruby/RDoc/RI/Driver/NotFoundError.md deleted file mode 100644 index 786fd26..0000000 --- a/example/ruby/RDoc/RI/Driver/NotFoundError.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: RDoc::RI::Driver::NotFoundError -**Inherits:** RDoc::RI::Driver::Error - - -Raised when a name isn't found in the ri data stores - - - -#Instance Methods -## initialize(klass, suggestion_procnil) [](#method-i-initialize) -:nodoc: - -**@return** [NotFoundError] a new instance of NotFoundError - -## message() [](#method-i-message) -:nodoc: - -## name() [](#method-i-name) -Name that wasn't found - diff --git a/example/ruby/RDoc/RI/Error.md b/example/ruby/RDoc/RI/Error.md deleted file mode 100644 index 55ed944..0000000 --- a/example/ruby/RDoc/RI/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: RDoc::RI::Error -**Inherits:** RDoc::Error - - -Base RI error class - - - diff --git a/example/ruby/RDoc/RI/Formatter.md b/example/ruby/RDoc/RI/Formatter.md deleted file mode 100644 index 5770f99..0000000 --- a/example/ruby/RDoc/RI/Formatter.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: RDoc::RI::Formatter - - -For RubyGems backwards compatibility - - - diff --git a/example/ruby/RDoc/RI/Paths.md b/example/ruby/RDoc/RI/Paths.md deleted file mode 100644 index 3c84ef6..0000000 --- a/example/ruby/RDoc/RI/Paths.md +++ /dev/null @@ -1,68 +0,0 @@ -# Module: RDoc::RI::Paths - - -The directories where ri data lives. Paths can be enumerated via ::each, or -queried individually via ::system_dir, ::site_dir, ::home_dir and ::gem_dir. - - -# Class Methods -## each(system true, site true, home true, gems :latest, *extra_dirs ) [](#method-c-each) -Iterates over each selected path yielding the directory and type. - -Yielded types: -:system -: Where Ruby's ri data is stored. Yielded when `system` is true - -:site -: Where ri for installed libraries are stored. Yielded when `site` is true. - Normally no ri data is stored here. - -:home -: ~/.rdoc. Yielded when `home` is true. - -:gem -: ri data for an installed gem. Yielded when `gems` is true. - -:extra -: ri data directory from the command line. Yielded for each entry in - `extra_dirs` - -**@yield** [system_dir, :system] - -## gem_dir(name , version ) [](#method-c-gem_dir) -The ri directory for the gem with `gem_name`. -## gemdirs(filter :latest) [](#method-c-gemdirs) -The latest installed gems' ri directories. `filter` can be :all or :latest. - -A `filter` :all includes all versions of gems and includes gems without ri -documentation. -## home_dir() [](#method-c-home_dir) -The location of the rdoc data in the user's home directory. - -Like ::system, ri data in the user's home directory is rare and predates -libraries distributed via RubyGems. ri data is rarely generated into this -directory. -## path(system true, site true, home true, gems :latest, *extra_dirs ) [](#method-c-path) -Returns existing directories from the selected documentation directories as an -Array. - -See also ::each -## raw_path(system , site , home , gems , *extra_dirs ) [](#method-c-raw_path) -Returns selected documentation directories including nonexistent directories. - -See also ::each -## site_dir() [](#method-c-site_dir) -The location of ri data installed into the site dir. - -Historically this was available for documentation installed by Ruby libraries -predating RubyGems. It is unlikely to contain any content for modern Ruby -installations. -## system_dir() [](#method-c-system_dir) -The location of the built-in ri data. - -This data is built automatically when `make` is run when Ruby is installed. -If you did not install Ruby by hand you may need to install the documentation -yourself. Please consult the documentation for your package manager or Ruby -installer for details. You can also use the rdoc-data gem to install system -ri data for common versions of Ruby. - diff --git a/example/ruby/RDoc/RI/Task.md b/example/ruby/RDoc/RI/Task.md deleted file mode 100644 index 19c35bc..0000000 --- a/example/ruby/RDoc/RI/Task.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: RDoc::RI::Task -**Inherits:** RDoc::Task - - -RDoc::RI::Task creates ri data in `./.rdoc` for your project. - -It contains the following tasks: - -ri -: Build ri data - - -clobber_ri -: Delete ri data files. This target is automatically added to the main - clobber target. - - -reri -: Rebuild the ri data from scratch even if they are not out of date. - - -Simple example: - - require 'rdoc/ri/task' - - RDoc::RI::Task.new do |ri| - ri.main = 'README.rdoc' - ri.rdoc_files.include 'README.rdoc', 'lib/**/*.rb' - end - -For further configuration details see RDoc::Task. - - - -#Instance Methods -## clobber_task_description() [](#method-i-clobber_task_description) -:nodoc: - -## defaults() [](#method-i-defaults) -Sets default task values - -## initialize(nameDEFAULT_NAMES) [](#method-i-initialize) -Create an ri task with the given name. See RDoc::Task for documentation on -setting names. - -**@return** [Task] a new instance of Task - -## rdoc_task_description() [](#method-i-rdoc_task_description) -:nodoc: - -## rerdoc_task_description() [](#method-i-rerdoc_task_description) -:nodoc: - diff --git a/example/ruby/RDoc/Require.md b/example/ruby/RDoc/Require.md deleted file mode 100644 index d9dc230..0000000 --- a/example/ruby/RDoc/Require.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: RDoc::Require -**Inherits:** RDoc::CodeObject - - -A file loaded by #require - - -# Attributes -## name[RW] [](#attribute-i-name) -Name of the required file - - -#Instance Methods -## initialize(name, comment) [](#method-i-initialize) -Creates a new Require that loads `name` with `comment` - -**@return** [Require] a new instance of Require - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - -## top_level() [](#method-i-top_level) -The RDoc::TopLevel corresponding to this require, or `nil` if not found. - diff --git a/example/ruby/RDoc/RubyGemsHook.md b/example/ruby/RDoc/RubyGemsHook.md deleted file mode 100644 index d92057a..0000000 --- a/example/ruby/RDoc/RubyGemsHook.md +++ /dev/null @@ -1,193 +0,0 @@ -# Class: RDoc::RubyGemsHook -**Inherits:** Object - -**Extended by:** Gem::UserInteraction - -**Includes:** Gem::UserInteraction - - -We define the following two similar name classes in this file: - -* RDoc::RubyGemsHook -* RDoc::RubygemsHook - -RDoc::RubyGemsHook is the main class that has real logic. - -RDoc::RubygemsHook is a class that is only for compatibility. -RDoc::RubygemsHook is used by RubyGems directly. We can remove this when all -maintained RubyGems remove `rubygems/rdoc.rb`. - - -# Class Methods -## alert(statement , question nil) [](#method-c-alert) -Displays an alert `statement`. Asks a `question` if given. -## alert_error(statement , question nil) [](#method-c-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. -## alert_warning(statement , question nil) [](#method-c-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. -## ask(question ) [](#method-c-ask) -Asks a `question` and returns the answer. -## ask_for_password(prompt ) [](#method-c-ask_for_password) -Asks for a password with a `prompt` -## ask_yes_no(question , default nil) [](#method-c-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. -## choose_from_list(question , list ) [](#method-c-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. -## clean_text(text ) [](#method-c-clean_text) -Remove any non-printable characters and make the text suitable for printing. -## format_text(text , wrap , indent 0) [](#method-c-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters -## generate(installer , specs ) [](#method-c-generate) -Post installs hook that generates documentation for each specification in -`specs` -## levenshtein_distance(str1 , str2 ) [](#method-c-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 -## load_rdoc() [](#method-c-load_rdoc) -Loads the RDoc generator -## min3(a , b , c ) [](#method-c-min3) -:nodoc: -## remove(uninstaller ) [](#method-c-remove) -## say(statement "") [](#method-c-say) -Displays the given `statement` on the standard output (or equivalent). -## terminate_interaction(exit_code 0) [](#method-c-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` -## truncate_text(text , description , max_length 100_000) [](#method-c-truncate_text) -**@raise** [ArgumentError] - -## ui() [](#method-c-ui) -See DefaultUserInteraction::ui -## ui=(new_ui ) [](#method-c-ui=) -See DefaultUserInteraction::ui= -## use_ui(new_ui , &block ) [](#method-c-use_ui) -See DefaultUserInteraction::use_ui -## verbose(msg nil) [](#method-c-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. -# Attributes -## rdoc_version[RW] [](#attribute-c-rdoc_version) -Loaded version of RDoc. Set by ::load_rdoc - -## force[RW] [](#attribute-i-force) -Force installation of documentation? - -## generate_rdoc[RW] [](#attribute-i-generate_rdoc) -Generate rdoc? - -## generate_ri[RW] [](#attribute-i-generate_ri) -Generate ri data? - - -#Instance Methods -## alert(statement, questionnil) [](#method-i-alert) -Displays an alert `statement`. Asks a `question` if given. - -## alert_error(statement, questionnil) [](#method-i-alert_error) -Displays an error `statement` to the error output location. Asks a `question` -if given. - -## alert_warning(statement, questionnil) [](#method-i-alert_warning) -Displays a warning `statement` to the warning output location. Asks a -`question` if given. - -## ask(question) [](#method-i-ask) -Asks a `question` and returns the answer. - -## ask_for_password(prompt) [](#method-i-ask_for_password) -Asks for a password with a `prompt` - -## ask_yes_no(question, defaultnil) [](#method-i-ask_yes_no) -Asks a yes or no `question`. Returns true for yes, false for no. - -## choose_from_list(question, list) [](#method-i-choose_from_list) -Asks the user to answer `question` with an answer from the given `list`. - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## delete_legacy_args(args) [](#method-i-delete_legacy_args) -Removes legacy rdoc arguments from `args` -- TODO move to RDoc::Options - -## document(generator, options, destination) [](#method-i-document) -Generates documentation using the named `generator` ("darkfish" or "ri") and -following the given `options`. - -Documentation will be generated into `destination` - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## generate() [](#method-i-generate) -Generates RDoc and ri data - -## initialize(spec, generate_rdocfalse, generate_ritrue) [](#method-i-initialize) -Creates a new documentation generator for `spec`. RDoc and ri data generation -can be enabled or disabled through `generate_rdoc` and `generate_ri` -respectively. - -Only `generate_ri` is enabled by default. - -**@return** [RubyGemsHook] a new instance of RubyGemsHook - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## new_rdoc() [](#method-i-new_rdoc) -#new_rdoc creates a new RDoc instance. This method is provided only to make -testing easier. - -## rdoc_installed?() [](#method-i-rdoc_installed?) -Is rdoc documentation installed? - -**@return** [Boolean] - -## remove() [](#method-i-remove) -Removes generated RDoc and ri data - -**@raise** [Gem::FilePermissionError] - -## ri_installed?() [](#method-i-ri_installed?) -Is ri data installed? - -**@return** [Boolean] - -## say(statement"") [](#method-i-say) -Displays the given `statement` on the standard output (or equivalent). - -## setup() [](#method-i-setup) -Prepares the spec for documentation generation - -**@raise** [Gem::FilePermissionError] - -## terminate_interaction(exit_code0) [](#method-i-terminate_interaction) -Terminates the RubyGems process with the given `exit_code` - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## verbose(msgnil) [](#method-i-verbose) -Calls `say` with `msg` or the results of the block if really_verbose is true. - diff --git a/example/ruby/RDoc/RubygemsHook.md b/example/ruby/RDoc/RubygemsHook.md deleted file mode 100644 index 8d5a528..0000000 --- a/example/ruby/RDoc/RubygemsHook.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: RDoc::RubygemsHook -**Inherits:** Object - - - - -# Class Methods -## default_gem?() [](#method-c-default_gem?) -**@return** [Boolean] - -## generation_hook(installer , specs ) [](#method-c-generation_hook) -# Attributes -## force[RW] [](#attribute-i-force) -Returns the value of attribute force. - -## generate_rdoc[RW] [](#attribute-i-generate_rdoc) -Returns the value of attribute generate_rdoc. - -## generate_ri[RW] [](#attribute-i-generate_ri) -Returns the value of attribute generate_ri. - - -#Instance Methods -## generate() [](#method-i-generate) - -## initialize(spec, generate_rdocfalse, generate_ritrue) [](#method-i-initialize) - -**@return** [RubygemsHook] a new instance of RubygemsHook - -## remove() [](#method-i-remove) - diff --git a/example/ruby/RDoc/Servlet.md b/example/ruby/RDoc/Servlet.md deleted file mode 100644 index 6bfe114..0000000 --- a/example/ruby/RDoc/Servlet.md +++ /dev/null @@ -1,107 +0,0 @@ -# Class: RDoc::Servlet -**Inherits:** WEBrick::HTTPServlet::AbstractServlet - - -This is a WEBrick servlet that allows you to browse ri documentation. - -You can show documentation through either `ri --server` or, with RubyGems 2.0 -or newer, `gem server`. For ri, the server runs on port 8214 by default. For -RubyGems the server runs on port 8808 by default. - -You can use this servlet in your own project by mounting it on a WEBrick -server: - - require 'webrick' - - server = WEBrick::HTTPServer.new Port: 8000 - - server.mount '/', RDoc::Servlet - -If you want to mount the servlet some other place than the root, provide the -base path when mounting: - - server.mount '/rdoc', RDoc::Servlet, '/rdoc' - - -# Class Methods -## get_instance(server , *options ) [](#method-c-get_instance) -Creates an instance of this servlet that shares cached data between requests. -# Attributes -## asset_dirs[RW] [](#attribute-i-asset_dirs) -Maps an asset type to its path on the filesystem - -## options[RW] [](#attribute-i-options) -An RDoc::Options instance used for rendering options - - -#Instance Methods -## asset(generator_name, req, res) [](#method-i-asset) -Serves the asset at the path in `req` for `generator_name` via `res`. - -## do_GET(req, res) [](#method-i-do_GET) -GET request entry point. Fills in `res` for the path, etc. in `req`. - -## documentation_page(store, generator, path, req, res) [](#method-i-documentation_page) -Fills in `res` with the class, module or page for `req` from `store`. - -`path` is relative to the mount_path and is used to determine the class, -module or page name (/RDoc/Servlet.html becomes RDoc::Servlet). `generator` is -used to create the page. - -## documentation_search(store, generator, req, res) [](#method-i-documentation_search) -Creates the JSON search index on `res` for the given `store`. `generator` -must respond to #json_index to build. `req` is ignored. - -## documentation_source(path) [](#method-i-documentation_source) -Returns the RDoc::Store and path relative to `mount_path` for documentation at -`path`. - -## error(exception, req, res) [](#method-i-error) -Generates an error page for the `exception` while handling `req` on `res`. - -## generator_for(store) [](#method-i-generator_for) -Instantiates a Darkfish generator for `store` - -## if_modified_since(req, res, pathnil) [](#method-i-if_modified_since) -Handles the If-Modified-Since HTTP header on `req` for `path`. If the file -has not been modified a Not Modified response is returned. If the file has -been modified a Last-Modified header is added to `res`. - -## initialize(server, stores, cache, mount_pathnil, extra_doc_dirs[]) [](#method-i-initialize) -Creates a new WEBrick servlet. - -Use `mount_path` when mounting the servlet somewhere other than /. - -Use `extra_doc_dirs` for additional documentation directories. - -`server` is provided automatically by WEBrick when mounting. `stores` and -`cache` are provided automatically by the servlet. - -**@return** [Servlet] a new instance of Servlet - -## installed_docs() [](#method-i-installed_docs) -Returns an Array of installed documentation. - -Each entry contains the documentation name (gem name, 'Ruby Documentation', -etc.), the path relative to the mount point, whether the documentation exists, -the type of documentation (See RDoc::RI::Paths#each) and the filesystem to the -RDoc::Store for the documentation. - -## not_found(generator, req, res, messagenil) [](#method-i-not_found) -Returns a 404 page built by `generator` for `req` on `res`. - -## ri_paths(&block) [](#method-i-ri_paths) -Enumerates the ri paths. See RDoc::RI::Paths#each - -## root(req, res) [](#method-i-root) -Generates the root page on `res`. `req` is ignored. - -## root_search(req, res) [](#method-i-root_search) -Generates a search index for the root page on `res`. `req` is ignored. - -## show_documentation(req, res) [](#method-i-show_documentation) -Displays documentation for `req` on `res`, whether that be HTML or some asset. - -## store_for(source_name) [](#method-i-store_for) -Returns an RDoc::Store for the given `source_name` ('ruby' or a gem name). - diff --git a/example/ruby/RDoc/SingleClass.md b/example/ruby/RDoc/SingleClass.md deleted file mode 100644 index 247387e..0000000 --- a/example/ruby/RDoc/SingleClass.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: RDoc::SingleClass -**Inherits:** RDoc::ClassModule - - -A singleton class - - - -#Instance Methods -## ancestors() [](#method-i-ancestors) -Adds the superclass to the included modules. - -## aref_prefix() [](#method-i-aref_prefix) -:nodoc: - -## definition() [](#method-i-definition) -The definition of this singleton class, `class << MyClassName` - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - diff --git a/example/ruby/RDoc/Stats.md b/example/ruby/RDoc/Stats.md deleted file mode 100644 index ae33a29..0000000 --- a/example/ruby/RDoc/Stats.md +++ /dev/null @@ -1,134 +0,0 @@ -# Class: RDoc::Stats -**Inherits:** Object - -**Includes:** RDoc::Text - - -RDoc statistics collector which prints a summary and report of a project's -documentation totals. - - -# Attributes -## coverage_level[RW] [](#attribute-i-coverage_level) -Output level for the coverage report - -## files_so_far[RW] [](#attribute-i-files_so_far) -Count of files parsed during parsing - -## num_files[RW] [](#attribute-i-num_files) -Total number of files found - - -#Instance Methods -## add_alias(as) [](#method-i-add_alias) -Records the parsing of an alias `as`. - -## add_attribute(attribute) [](#method-i-add_attribute) -Records the parsing of an attribute `attribute` - -## add_class(klass) [](#method-i-add_class) -Records the parsing of a class `klass` - -## add_constant(constant) [](#method-i-add_constant) -Records the parsing of `constant` - -## add_file(file) [](#method-i-add_file) -Records the parsing of `file` - -## add_method(method) [](#method-i-add_method) -Records the parsing of `method` - -## add_module(mod) [](#method-i-add_module) -Records the parsing of a module `mod` - -## begin_adding() [](#method-i-begin_adding) -Call this to mark the beginning of parsing for display purposes - -## calculate() [](#method-i-calculate) -Calculates documentation totals and percentages for classes, modules, -constants, attributes and methods. - -## doc_stats(collection) [](#method-i-doc_stats) -Returns the length and number of undocumented items in `collection`. - -## done_adding() [](#method-i-done_adding) -Call this to mark the end of parsing for display purposes - -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## fully_documented?() [](#method-i-fully_documented?) -The documentation status of this project. `true` when 100%, `false` when less -than 100% and `nil` when unknown. - -Set by calling #calculate - -**@return** [Boolean] - -## great_job() [](#method-i-great_job) -A report that says you did a great job! - -## initialize(store, num_files, verbosity1) [](#method-i-initialize) -Creates a new Stats that will have `num_files`. `verbosity` defaults to 1 -which will create an RDoc::Stats::Normal outputter. - -**@return** [Stats] a new instance of Stats - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## parse(text, format'rdoc') [](#method-i-parse) -Normalizes `text` then builds a RDoc::Markup::Document from it - -## percent_doc() [](#method-i-percent_doc) -Calculates the percentage of items documented. - -## report() [](#method-i-report) -Returns a report on which items are not documented - -## report_attributes(cm) [](#method-i-report_attributes) -Returns a report on undocumented attributes in ClassModule `cm` - -## report_class_module(cm) [](#method-i-report_class_module) -Returns a report on undocumented items in ClassModule `cm` - -## report_constants(cm) [](#method-i-report_constants) -Returns a report on undocumented constants in ClassModule `cm` - -## report_methods(cm) [](#method-i-report_methods) -Returns a report on undocumented methods in ClassModule `cm` - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## summary() [](#method-i-summary) -Returns a summary of the collected statistics. - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## undoc_params(method) [](#method-i-undoc_params) -Determines which parameters in `method` were not documented. Returns a total -parameter count and an Array of undocumented methods. - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/RDoc/Stats/Normal.md b/example/ruby/RDoc/Stats/Normal.md deleted file mode 100644 index 6972f76..0000000 --- a/example/ruby/RDoc/Stats/Normal.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: RDoc::Stats::Normal -**Inherits:** RDoc::Stats::Quiet - - -Stats printer that prints just the files being documented with a progress bar - - - -#Instance Methods -## begin_adding() [](#method-i-begin_adding) -:nodoc: - -## done_adding() [](#method-i-done_adding) -:nodoc: - -## print_file(files_so_far, filename) [](#method-i-print_file) -Prints a file with a progress bar - diff --git a/example/ruby/RDoc/Stats/Quiet.md b/example/ruby/RDoc/Stats/Quiet.md deleted file mode 100644 index fb99063..0000000 --- a/example/ruby/RDoc/Stats/Quiet.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: RDoc::Stats::Quiet -**Inherits:** Object - - -Stats printer that prints nothing - - - -#Instance Methods -## begin_adding() [](#method-i-begin_adding) -Prints a message at the beginning of parsing - -## done_adding() [](#method-i-done_adding) -Prints when RDoc is done - -## initialize(num_files) [](#method-i-initialize) -Creates a new Quiet that will print nothing - -**@return** [Quiet] a new instance of Quiet - -## print_alias() [](#method-i-print_alias) -Prints when an alias is added - -## print_attribute() [](#method-i-print_attribute) -Prints when an attribute is added - -## print_class() [](#method-i-print_class) -Prints when a class is added - -## print_constant() [](#method-i-print_constant) -Prints when a constant is added - -## print_file() [](#method-i-print_file) -Prints when a file is added - -## print_method() [](#method-i-print_method) -Prints when a method is added - -## print_module() [](#method-i-print_module) -Prints when a module is added - diff --git a/example/ruby/RDoc/Stats/Verbose.md b/example/ruby/RDoc/Stats/Verbose.md deleted file mode 100644 index 0ffaf2c..0000000 --- a/example/ruby/RDoc/Stats/Verbose.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: RDoc::Stats::Verbose -**Inherits:** RDoc::Stats::Normal - - -Stats printer that prints everything documented, including the documented -status - - - -#Instance Methods -## nodoc(co) [](#method-i-nodoc) -Returns a marker for RDoc::CodeObject `co` being undocumented - -## print_alias(as) [](#method-i-print_alias) -:nodoc: - -## print_attribute(attribute) [](#method-i-print_attribute) -:nodoc: - -## print_class(klass) [](#method-i-print_class) -:nodoc: - -## print_constant(constant) [](#method-i-print_constant) -:nodoc: - -## print_file(files_so_far, file) [](#method-i-print_file) -:nodoc: - -## print_method(method) [](#method-i-print_method) -:nodoc: - -## print_module(mod) [](#method-i-print_module) -:nodoc: - diff --git a/example/ruby/RDoc/Store.md b/example/ruby/RDoc/Store.md deleted file mode 100644 index f972269..0000000 --- a/example/ruby/RDoc/Store.md +++ /dev/null @@ -1,282 +0,0 @@ -# Class: RDoc::Store -**Inherits:** Object - - -A set of rdoc data for a single project (gem, path, etc.). - -The store manages reading and writing ri data for a project and maintains a -cache of methods, classes and ancestors in the store. - -The store maintains a #cache of its contents for faster lookup. After adding -items to the store it must be flushed using #save_cache. The cache contains -the following structures: - - @cache = { - :ancestors => {}, # class name => ancestor names - :attributes => {}, # class name => attributes - :class_methods => {}, # class name => class methods - :instance_methods => {}, # class name => instance methods - :modules => [], # classes and modules in this store - :pages => [], # page names - } - --- TODO need to prune classes - - -# Attributes -## c_class_variables[RW] [](#attribute-i-c_class_variables) -Maps C variables to class or module names for each parsed C file. - -## c_enclosure_classes[RW] [](#attribute-i-c_enclosure_classes) -Stores the name of the C variable a class belongs to. This helps wire up -classes defined from C across files. - -## c_enclosure_names[RW] [](#attribute-i-c_enclosure_names) -:nodoc: - -## c_singleton_class_variables[RW] [](#attribute-i-c_singleton_class_variables) -Maps C variables to singleton class names for each parsed C file. - -## cache[RW] [](#attribute-i-cache) -The contents of the Store - -## dry_run[RW] [](#attribute-i-dry_run) -If true this Store will not write any files - -## encoding[RW] [](#attribute-i-encoding) -The encoding of the contents in the Store - -## path[RW] [](#attribute-i-path) -Path this store reads or writes - -## rdoc[RW] [](#attribute-i-rdoc) -The RDoc::RDoc driver for this parse tree. This allows classes consulting the -documentation tree to access user-set options, for example. - -## type[RW] [](#attribute-i-type) -Type of ri datastore this was loaded from. See RDoc::RI::Driver, -RDoc::RI::Paths. - -## unmatched_constant_alias[RW] [](#attribute-i-unmatched_constant_alias) -The lazy constants alias will be discovered in passing - - -#Instance Methods -## add_c_enclosure(variable, namespace) [](#method-i-add_c_enclosure) -Adds `module` as an enclosure (namespace) for the given `variable` for C -files. - -## add_c_variables(c_parser) [](#method-i-add_c_variables) -Adds C variables from an RDoc::Parser::C - -## add_file(absolute_name, relative_name:absolute_name, parser:nil) [](#method-i-add_file) -Adds the file with `name` as an RDoc::TopLevel to the store. Returns the -created RDoc::TopLevel. - -## all_classes() [](#method-i-all_classes) -Returns all classes discovered by RDoc - -## all_classes_and_modules() [](#method-i-all_classes_and_modules) -Returns all classes and modules discovered by RDoc - -## all_files() [](#method-i-all_files) -All TopLevels known to RDoc - -## all_modules() [](#method-i-all_modules) -Returns all modules discovered by RDoc - -## ancestors() [](#method-i-ancestors) -Ancestors cache accessor. Maps a klass name to an Array of its ancestors in -this store. If Foo in this store inherits from Object, Kernel won't be listed -(it will be included from ruby's ri store). - -## attributes() [](#method-i-attributes) -Attributes cache accessor. Maps a class to an Array of its attributes. - -## cache_path() [](#method-i-cache_path) -Path to the cache file - -## class_file(klass_name) [](#method-i-class_file) -Path to the ri data for `klass_name` - -## class_methods() [](#method-i-class_methods) -Class methods cache accessor. Maps a class to an Array of its class methods -(not full name). - -## class_path(klass_name) [](#method-i-class_path) -Path where data for `klass_name` will be stored (methods or class data) - -## classes_hash() [](#method-i-classes_hash) -Hash of all classes known to RDoc - -## clean_cache_collection(collection) [](#method-i-clean_cache_collection) -Removes empty items and ensures item in each collection are unique and sorted - -## complete(min_visibility) [](#method-i-complete) -Prepares the RDoc code object tree for use by a generator. - -It finds unique classes/modules defined, and replaces classes/modules that are -aliases for another one by a copy with RDoc::ClassModule#is_alias_for set. - -It updates the RDoc::ClassModule#constant_aliases attribute of "real" classes -or modules. - -It also completely removes the classes and modules that should be removed from -the documentation and the methods that have a visibility below -`min_visibility`, which is the `--visibility` option. - -See also RDoc::Context#remove_from_documentation? - -## files_hash() [](#method-i-files_hash) -Hash of all files known to RDoc - -## find_c_enclosure(variable) [](#method-i-find_c_enclosure) -Finds the enclosure (namespace) for the given C `variable`. - -## find_class_named(name) [](#method-i-find_class_named) -Finds the class with `name` in all discovered classes - -## find_class_named_from(name, from) [](#method-i-find_class_named_from) -Finds the class with `name` starting in namespace `from` - -## find_class_or_module(name) [](#method-i-find_class_or_module) -Finds the class or module with `name` - -## find_file_named(name) [](#method-i-find_file_named) -Finds the file with `name` in all discovered files - -## find_module_named(name) [](#method-i-find_module_named) -Finds the module with `name` in all discovered modules - -## find_text_page(file_name) [](#method-i-find_text_page) -Returns the RDoc::TopLevel that is a text file and has the given `file_name` - -## find_unique(all_hash) [](#method-i-find_unique) -Finds unique classes/modules defined in `all_hash`, and returns them as an -array. Performs the alias updates in `all_hash`: see ::complete. -- TODO -aliases should be registered by Context#add_module_alias - -## fix_basic_object_inheritance() [](#method-i-fix_basic_object_inheritance) -Fixes the erroneous `BasicObject < Object` in 1.9. - -Because we assumed all classes without a stated superclass inherit from -Object, we have the above wrong inheritance. - -We fix BasicObject right away if we are running in a Ruby version >= 1.9. - -## friendly_path() [](#method-i-friendly_path) -Friendly rendition of #path - -## initialize(pathnil, typenil) [](#method-i-initialize) -Creates a new Store of `type` that will load or save to `path` - -**@return** [Store] a new instance of Store - -## inspect() [](#method-i-inspect) -:nodoc: - -## instance_methods() [](#method-i-instance_methods) -Instance methods cache accessor. Maps a class to an Array of its instance -methods (not full name). - -## load_all() [](#method-i-load_all) -Loads all items from this store into memory. This recreates a documentation -tree for use by a generator - -## load_cache() [](#method-i-load_cache) -Loads cache file for this store - -## load_class(klass_name) [](#method-i-load_class) -Loads ri data for `klass_name` and hooks it up to this store. - -## load_class_data(klass_name) [](#method-i-load_class_data) -Loads ri data for `klass_name` - -## load_method(klass_name, method_name) [](#method-i-load_method) -Loads ri data for `method_name` in `klass_name` - -## load_page(page_name) [](#method-i-load_page) -Loads ri data for `page_name` - -## main() [](#method-i-main) -Gets the main page for this RDoc store. This page is used as the root of the -RDoc server. - -## main=(page) [](#method-i-main=) -Sets the main page for this RDoc store. - -## make_variable_map(variables) [](#method-i-make_variable_map) -Converts the variable => ClassModule map `variables` from a C parser into a -variable => class name map. - -## method_file(klass_name, method_name) [](#method-i-method_file) -Path to the ri data for `method_name` in `klass_name` - -## module_names() [](#method-i-module_names) -Modules cache accessor. An Array of all the module (and class) names in the -store. - -## modules_hash() [](#method-i-modules_hash) -Hash of all modules known to RDoc - -## page(name) [](#method-i-page) -Returns the RDoc::TopLevel that is a text file and has the given `name` - -## page_file(page_name) [](#method-i-page_file) -Path to the ri data for `page_name` - -## remove_nodoc(all_hash) [](#method-i-remove_nodoc) -Removes from `all_hash` the contexts that are nodoc or have no content. - -See RDoc::Context#remove_from_documentation? - -## resolve_c_superclasses() [](#method-i-resolve_c_superclasses) -Make sure any references to C variable names are resolved to the corresponding -class. - -## save() [](#method-i-save) -Saves all entries in the store - -## save_cache() [](#method-i-save_cache) -Writes the cache file for this store - -## save_class(klass) [](#method-i-save_class) -Writes the ri data for `klass` (or module) - -## save_method(klass, method) [](#method-i-save_method) -Writes the ri data for `method` on `klass` - -## save_page(page) [](#method-i-save_page) -Writes the ri data for `page` - -## source() [](#method-i-source) -Source of the contents of this store. - -For a store from a gem the source is the gem name. For a store from the home -directory the source is "home". For system ri store (the standard library -documentation) the source is"ruby". For a store from the site ri directory -the store is "site". For other stores the source is the #path. - -## title() [](#method-i-title) -Gets the title for this RDoc store. This is used as the title in each page on -the RDoc server - -## title=(title) [](#method-i-title=) -Sets the title page for this RDoc store. - -## unique_classes() [](#method-i-unique_classes) -Returns the unique classes discovered by RDoc. - -::complete must have been called prior to using this method. - -## unique_classes_and_modules() [](#method-i-unique_classes_and_modules) -Returns the unique classes and modules discovered by RDoc. ::complete must -have been called prior to using this method. - -## unique_modules() [](#method-i-unique_modules) -Returns the unique modules discovered by RDoc. ::complete must have been -called prior to using this method. - -## update_parser_of_file(absolute_name, parser) [](#method-i-update_parser_of_file) -Sets the parser of `absolute_name`, unless it from a source code file. - diff --git a/example/ruby/RDoc/Store/Error.md b/example/ruby/RDoc/Store/Error.md deleted file mode 100644 index 980c4ee..0000000 --- a/example/ruby/RDoc/Store/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: RDoc::Store::Error -**Inherits:** RDoc::Error - - -Errors raised from loading or saving the store - - - diff --git a/example/ruby/RDoc/Store/MissingFileError.md b/example/ruby/RDoc/Store/MissingFileError.md deleted file mode 100644 index 1a6194a..0000000 --- a/example/ruby/RDoc/Store/MissingFileError.md +++ /dev/null @@ -1,28 +0,0 @@ -# Exception: RDoc::Store::MissingFileError -**Inherits:** RDoc::Store::Error - - -Raised when a stored file for a class, module, page or method is missing. - - -# Attributes -## file[RW] [](#attribute-i-file) -The file the #name should be saved as - -## name[RW] [](#attribute-i-name) -The name of the object the #file would be loaded from - -## store[RW] [](#attribute-i-store) -The store the file should exist in - - -#Instance Methods -## initialize(store, file, name) [](#method-i-initialize) -Creates a new MissingFileError for the missing `file` for the given `name` -that should have been in the `store`. - -**@return** [MissingFileError] a new instance of MissingFileError - -## message() [](#method-i-message) -:nodoc: - diff --git a/example/ruby/RDoc/Task.md b/example/ruby/RDoc/Task.md deleted file mode 100644 index d372db0..0000000 --- a/example/ruby/RDoc/Task.md +++ /dev/null @@ -1,149 +0,0 @@ -# Class: RDoc::Task -**Inherits:** Rake::TaskLib - - -RDoc::Task creates the following rake tasks to generate and clean up RDoc -output: - -rdoc -: Main task for this RDoc task. - - -clobber_rdoc -: Delete all the rdoc files. This target is automatically added to the main - clobber target. - - -rerdoc -: Rebuild the rdoc files from scratch, even if they are not out of date. - - -rdoc:coverage -: Print RDoc coverage report for all rdoc files. - - -Simple Example: - - require 'rdoc/task' - - RDoc::Task.new do |rdoc| - rdoc.main = "README.rdoc" - rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb") - end - -The `rdoc` object passed to the block is an RDoc::Task object. See the -attributes list for the RDoc::Task class for available customization options. - -## Specifying different task names - -You may wish to give the task a different name, such as if you are generating -two sets of documentation. For instance, if you want to have a development -set of documentation including private methods: - - require 'rdoc/task' - - RDoc::Task.new :rdoc_dev do |rdoc| - rdoc.main = "README.rdoc" - rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb") - rdoc.options << "--all" - end - -The tasks would then be named :*rdoc_dev*, :clobber_*rdoc_dev*, and -:re*rdoc_dev*. - -If you wish to have completely different task names, then pass a Hash as first -argument. With the `:rdoc`, `:clobber_rdoc` and `:rerdoc` options, you can -customize the task names to your liking. - -For example: - - require 'rdoc/task' - - RDoc::Task.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", - :rerdoc => "rdoc:force") - -This will create the tasks `:rdoc`, `:rdoc:clean`, `:rdoc:force`, and -`:rdoc:coverage`. - - -# Attributes -## external[RW] [](#attribute-i-external) -Whether to run the rdoc process as an external shell (default is false) - -## generator[RW] [](#attribute-i-generator) -Name of format generator (`--format`) used by rdoc. (defaults to rdoc's -default) - -## main[RW] [](#attribute-i-main) -Name of file to be used as the main, top level file of the RDoc. (default is -none) - -## markup[RW] [](#attribute-i-markup) -The markup format; one of: `rdoc` (the default), `markdown`, `rd`, `tomdoc`. -See [Markup Formats](rdoc-ref:RDoc::Markup@Markup+Formats). - -## name[RW] [](#attribute-i-name) -Name of the main, top level task. (default is :rdoc) - -## options[RW] [](#attribute-i-options) -Additional list of options to be passed rdoc. (default is []) - -## rdoc_dir[RW] [](#attribute-i-rdoc_dir) -Name of directory to receive the html output files. (default is "html") - -## rdoc_files[RW] [](#attribute-i-rdoc_files) -List of files to be included in the rdoc generation. (default is []) - -## template[RW] [](#attribute-i-template) -Name of template to be used by rdoc. (defaults to rdoc's default) - -## title[RW] [](#attribute-i-title) -Title of RDoc documentation. (defaults to rdoc's default) - - -#Instance Methods -## before_running_rdoc(&block) [](#method-i-before_running_rdoc) -The block passed to this method will be called just before running the RDoc -generator. It is allowed to modify RDoc::Task attributes inside the block. - -## check_names(names) [](#method-i-check_names) -Ensures that `names` only includes names for the :rdoc, :clobber_rdoc and -:rerdoc. If other names are given an ArgumentError is raised. - -## clobber_task_description() [](#method-i-clobber_task_description) -Task description for the clobber rdoc task or its renamed equivalent - -## coverage_task_description() [](#method-i-coverage_task_description) -Task description for the coverage task or its renamed description - -## defaults() [](#method-i-defaults) -Sets default task values - -## define() [](#method-i-define) -Create the tasks defined by this task lib. - -## initialize(name:rdoc) [](#method-i-initialize) -Create an RDoc task with the given name. See the RDoc::Task class overview for -documentation. - -**@return** [Task] a new instance of Task - -**@yield** [_self] - -**@yieldparam** [RDoc::Task] the object that the method was called on - -## inline_source() [](#method-i-inline_source) -All source is inline now. This method is deprecated - -## inline_source=(value) [](#method-i-inline_source=) -All source is inline now. This method is deprecated - -## option_list() [](#method-i-option_list) -List of options that will be supplied to RDoc - -## rdoc_task_description() [](#method-i-rdoc_task_description) -Task description for the rdoc task or its renamed equivalent - -## rerdoc_task_description() [](#method-i-rerdoc_task_description) -Task description for the rerdoc task or its renamed description - diff --git a/example/ruby/RDoc/TestCase.md b/example/ruby/RDoc/TestCase.md deleted file mode 100644 index 717ad2b..0000000 --- a/example/ruby/RDoc/TestCase.md +++ /dev/null @@ -1,83 +0,0 @@ -# Class: RDoc::TestCase -**Inherits:** Test::Unit::TestCase - - -RDoc::TestCase is an abstract TestCase to provide common setup and teardown -across all RDoc tests. The test case uses test-unit, so all the assertions of -test-unit may be used. - -The testcase provides the following: - -* A reset code-object tree -* A reset markup preprocessor (RDoc::Markup::PreProcess) -* The `@RM` alias of RDoc::Markup (for less typing) -* `@pwd` containing the current working directory -* FileUtils, pp, Tempfile, Dir.tmpdir and StringIO - - - -#Instance Methods -## assert_directory(path) [](#method-i-assert_directory) -Asserts `path` is a directory - -## assert_file(path) [](#method-i-assert_file) -Asserts `path` is a file - -## blank_line() [](#method-i-blank_line) -Shortcut for RDoc::Markup::BlankLine.new - -## block(*contents) [](#method-i-block) -Shortcut for RDoc::Markup::BlockQuote.new with `contents` - -## comment(text, top_level@top_level, languagenil) [](#method-i-comment) -Creates an RDoc::Comment with `text` which was defined on `top_level`. By -default the comment has the 'rdoc' format. - -## doc(*contents) [](#method-i-doc) -Shortcut for RDoc::Markup::Document.new with `contents` - -## hard_break() [](#method-i-hard_break) -Shortcut for RDoc::Markup::HardBreak.new - -## head(level, text) [](#method-i-head) -Shortcut for RDoc::Markup::Heading.new with `level` and `text` - -## item(labelnil, *parts) [](#method-i-item) -Shortcut for RDoc::Markup::ListItem.new with `label` and `parts` - -## list(typenil, *items) [](#method-i-list) -Shortcut for RDoc::Markup::List.new with `type` and `items` - -## mu_pp(obj) [](#method-i-mu_pp) -Enables pretty-print output - -## para(*a) [](#method-i-para) -Shortcut for RDoc::Markup::Paragraph.new with `contents` - -## raw(*contents) [](#method-i-raw) -Shortcut for RDoc::Markup::Raw.new with `contents` - -## refute_file(path) [](#method-i-refute_file) -Refutes `path` exists - -## rule(weight) [](#method-i-rule) -Shortcut for RDoc::Markup::Rule.new with `weight` - -## setup() [](#method-i-setup) -Abstract test-case setup - -## teardown() [](#method-i-teardown) -Abstract test-case teardown - -## temp_dir() [](#method-i-temp_dir) -Creates a temporary directory changes the current directory to it for the -duration of the block. - -Depends upon Dir.mktmpdir - -## verb(*parts) [](#method-i-verb) -Shortcut for RDoc::Markup::Verbatim.new with `parts` - -## verbose_capture_output() [](#method-i-verbose_capture_output) -run capture_io with setting $VERBOSE = true - diff --git a/example/ruby/RDoc/Text.md b/example/ruby/RDoc/Text.md deleted file mode 100644 index a712bb9..0000000 --- a/example/ruby/RDoc/Text.md +++ /dev/null @@ -1,51 +0,0 @@ -# Module: RDoc::Text - - -Methods for manipulating comment text - - -# Class Methods -## encode_fallback(character , encoding , fallback ) [](#method-c-encode_fallback) -Transcodes `character` to `encoding` with a `fallback` character. -# Attributes -## language[RW] [](#attribute-i-language) -The language for this text. This affects stripping comments markers. - - -#Instance Methods -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## parse(text, format'rdoc') [](#method-i-parse) -Normalizes `text` then builds a RDoc::Markup::Document from it - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/RDoc/TokenStream.md b/example/ruby/RDoc/TokenStream.md deleted file mode 100644 index 5a64a02..0000000 --- a/example/ruby/RDoc/TokenStream.md +++ /dev/null @@ -1,35 +0,0 @@ -# Module: RDoc::TokenStream - - -A TokenStream is a list of tokens, gathered during the parse of some entity -(say a method). Entities populate these streams by being registered with the -lexer. Any class can collect tokens by including TokenStream. From the -outside, you use such an object by calling the start_collecting_tokens method, -followed by calls to add_token and pop_token. - - -# Class Methods -## to_html(token_stream ) [](#method-c-to_html) -Converts `token_stream` to HTML wrapping various tokens with `` -elements. Some tokens types are wrapped in spans with the given class names. -Other token types are not wrapped in spans. - -#Instance Methods -## add_token(token) [](#method-i-add_token) -Adds one `token` to the collected tokens - -## add_tokens(tokens) [](#method-i-add_tokens) -Adds `tokens` to the collected tokens - -## collect_tokens() [](#method-i-collect_tokens) -Starts collecting tokens - -## pop_token() [](#method-i-pop_token) -Remove the last token from the collected tokens - -## token_stream() [](#method-i-token_stream) -Current token stream - -## tokens_to_s() [](#method-i-tokens_to_s) -Returns a string representation of the token stream - diff --git a/example/ruby/RDoc/TomDoc.md b/example/ruby/RDoc/TomDoc.md deleted file mode 100644 index db54ec3..0000000 --- a/example/ruby/RDoc/TomDoc.md +++ /dev/null @@ -1,108 +0,0 @@ -# Class: RDoc::TomDoc -**Inherits:** RDoc::Markup::Parser - - -A parser for TomDoc based on TomDoc 1.0.0-rc1 (02adef9b5a) - -The TomDoc specification can be found at http://tomdoc.org. - -To choose TomDoc as your only default format see RDoc::Options@Saved+Options -for instructions on setting up a `.rdoc_options` file to store your project -default. - -There are a few differences between this parser and the specification. A -best-effort was made to follow the specification as closely as possible but -some choices to deviate were made. - -A future version of RDoc will warn when a MUST or MUST NOT is violated and may -warn when a SHOULD or SHOULD NOT is violated. RDoc will always try to emit -documentation even if given invalid TomDoc. - -Here are some implementation choices this parser currently makes: - -This parser allows rdoc-style inline markup but you should not depended on it. - -This parser allows a space between the comment and the method body. - -This parser does not require the default value to be described for an optional -argument. - -This parser does not examine the order of sections. An Examples section may -precede the Arguments section. - -This class is documented in TomDoc format. Since this is a subclass of the -RDoc markup parser there isn't much to see here, unfortunately. - - -# Class Methods -## add_post_processor() [](#method-c-add_post_processor) -Internal: Adds a post-processor which sets the RDoc section based on the -comment's status. - -Returns nothing. -## parse(text ) [](#method-c-parse) -Public: Parses TomDoc from text - -text - A String containing TomDoc-format text. - -Examples - - RDoc::TomDoc.parse <<-TOMDOC - This method does some things - - Returns nothing. - TOMDOC - # => # - -Returns an RDoc::Markup::Document representing the TomDoc format. -## signature(comment ) [](#method-c-signature) -Internal: Extracts the Signature section's method signature - -comment - An RDoc::Comment that will be parsed and have the signature - extracted - -Returns a String containing the signature and nil if not -# Attributes -## tokens[RW] [](#attribute-i-tokens) -Internal: Token accessor - - -#Instance Methods -## build_heading(level) [](#method-i-build_heading) -Internal: Builds a heading from the token stream - -level - The level of heading to create - -Returns an RDoc::Markup::Heading - -## build_paragraph(margin) [](#method-i-build_paragraph) -Internal: Builds a paragraph from the token stream - -margin - Unused - -Returns an RDoc::Markup::Paragraph. - -## build_verbatim(margin) [](#method-i-build_verbatim) -Internal: Builds a verbatim from the token stream. A verbatim in the Examples -section will be marked as in Ruby format. - -margin - The indentation from the margin for lines that belong to this - verbatim section. - -Returns an RDoc::Markup::Verbatim - -## initialize() [](#method-i-initialize) -Public: Creates a new TomDoc parser. See also RDoc::Markup::parse - -**@return** [TomDoc] a new instance of TomDoc - -## parse_text(parent, indent) [](#method-i-parse_text) -Detects a section change to "Returns" and adds a heading - -## tokenize(text) [](#method-i-tokenize) -Internal: Turns text into an Array of tokens - -text - A String containing TomDoc-format text. - -Returns self. - diff --git a/example/ruby/RDoc/TopLevel.md b/example/ruby/RDoc/TopLevel.md deleted file mode 100644 index ed4e100..0000000 --- a/example/ruby/RDoc/TopLevel.md +++ /dev/null @@ -1,125 +0,0 @@ -# Class: RDoc::TopLevel -**Inherits:** RDoc::Context - - -A TopLevel context is a representation of the contents of a single file - - -# Attributes -## absolute_name[RW] [](#attribute-i-absolute_name) -Absolute name of this file - -## classes_or_modules[RW] [](#attribute-i-classes_or_modules) -All the classes or modules that were declared in this file. These are assigned -to either `#classes_hash` or `#modules_hash` once we know what they really -are. - -## diagram[RW] [](#attribute-i-diagram) -:nodoc: - -## file_stat[RW] [](#attribute-i-file_stat) -This TopLevel's File::Stat struct - -## parser[RW] [](#attribute-i-parser) -The parser class that processed this file - -## relative_name[RW] [](#attribute-i-relative_name) -Relative name of this file - - -#Instance Methods -## ==(other) [](#method-i-==) -An RDoc::TopLevel is equal to another with the same relative_name - -## add_alias(an_alias) [](#method-i-add_alias) -Adds `an_alias` to `Object` instead of `self`. - -## add_constant(constant) [](#method-i-add_constant) -Adds `constant` to `Object` instead of `self`. - -## add_include(include) [](#method-i-add_include) -Adds `include` to `Object` instead of `self`. - -## add_method(method) [](#method-i-add_method) -Adds `method` to `Object` instead of `self`. - -## add_to_classes_or_modules(mod) [](#method-i-add_to_classes_or_modules) -Adds class or module `mod`. Used in the building phase by the Ruby parser. - -## base_name() [](#method-i-base_name) -Base name of this file - -## cvs_url() [](#method-i-cvs_url) -Returns a URL for this source file on some web repository. Use the -W command -line option to set. - -## display?() [](#method-i-display?) -Only a TopLevel that contains text file) will be displayed. See also -RDoc::CodeObject#display? - -**@return** [Boolean] - -## find_class_or_module(name) [](#method-i-find_class_or_module) -See RDoc::TopLevel::find_class_or_module -- TODO Why do we search through all -classes/modules found, not just the - ones of this instance? - -## find_local_symbol(symbol) [](#method-i-find_local_symbol) -Finds a class or module named `symbol` - -## find_module_named(name) [](#method-i-find_module_named) -Finds a module or class with `name` - -## full_name() [](#method-i-full_name) -Returns the relative name of this file - -## hash() [](#method-i-hash) -An RDoc::TopLevel has the same hash as another with the same relative_name - -## http_url(prefix) [](#method-i-http_url) -URL for this with a `prefix` - -## initialize(absolute_name, relative_nameabsolute_name) [](#method-i-initialize) -Creates a new TopLevel for the file at `absolute_name`. If documentation is -being generated outside the source dir `relative_name` is relative to the -source directory. - -**@return** [TopLevel] a new instance of TopLevel - -## inspect() [](#method-i-inspect) -:nodoc: - -## last_modified() [](#method-i-last_modified) -Time this file was last modified, if known - -## marshal_dump() [](#method-i-marshal_dump) -Dumps this TopLevel for use by ri. See also #marshal_load - -## marshal_load(array) [](#method-i-marshal_load) -Loads this TopLevel from `array`. - -## object_class() [](#method-i-object_class) -Returns the NormalClass "Object", creating it if not found. - -Records `self` as a location in "Object". - -## page_name() [](#method-i-page_name) -Base name of this file without the extension - -## path() [](#method-i-path) -Path to this file for use with HTML generator output. - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## search_record() [](#method-i-search_record) -Search record used by RDoc::Generator::JsonIndex - -## text?() [](#method-i-text?) -Is this TopLevel from a text file instead of a source code file? - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/RDocGeneratorDarkfishTest.md b/example/ruby/RDocGeneratorDarkfishTest.md deleted file mode 100644 index 98fe9a3..0000000 --- a/example/ruby/RDocGeneratorDarkfishTest.md +++ /dev/null @@ -1,61 +0,0 @@ -# Class: RDocGeneratorDarkfishTest -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## assert_hard_link(filename) [](#method-i-assert_hard_link) -Asserts that `filename` has a link count greater than 1 if hard links to - -## assert_main_title(content, title) [](#method-i-assert_main_title) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_generate() [](#method-i-test_generate) - -## test_generate_dry_run() [](#method-i-test_generate_dry_run) - -## test_generate_page() [](#method-i-test_generate_page) - -## test_generate_static() [](#method-i-test_generate_static) - -## test_generate_static_dry_run() [](#method-i-test_generate_static_dry_run) - -## test_generated_filename_with_html_tag() [](#method-i-test_generated_filename_with_html_tag) - -## test_generated_method_with_html_tag_yield() [](#method-i-test_generated_method_with_html_tag_yield) - -## test_install_rdoc_static_file() [](#method-i-test_install_rdoc_static_file) - -## test_install_rdoc_static_file_missing() [](#method-i-test_install_rdoc_static_file_missing) - -## test_meta_tags_for_classes() [](#method-i-test_meta_tags_for_classes) - -## test_meta_tags_for_empty_document() [](#method-i-test_meta_tags_for_empty_document) - -## test_meta_tags_for_index() [](#method-i-test_meta_tags_for_index) - -## test_meta_tags_for_markdown_files() [](#method-i-test_meta_tags_for_markdown_files) - -## test_meta_tags_for_raw_pages() [](#method-i-test_meta_tags_for_raw_pages) - -## test_meta_tags_for_rdoc_files() [](#method-i-test_meta_tags_for_rdoc_files) - -## test_setup() [](#method-i-test_setup) - -## test_template_for() [](#method-i-test_template_for) - -## test_template_for_dry_run() [](#method-i-test_template_for_dry_run) - -## test_template_for_partial() [](#method-i-test_template_for_partial) - -## test_template_stylesheets() [](#method-i-test_template_stylesheets) - -## test_title() [](#method-i-test_title) - -## test_title_escape() [](#method-i-test_title_escape) - diff --git a/example/ruby/RDocMarkupToAnsiTest.md b/example/ruby/RDocMarkupToAnsiTest.md deleted file mode 100644 index 05ac760..0000000 --- a/example/ruby/RDocMarkupToAnsiTest.md +++ /dev/null @@ -1,131 +0,0 @@ -# Class: RDocMarkupToAnsiTest -**Inherits:** RDoc::Markup::TextFormatterTestCase - - - - - -#Instance Methods -## accept_blank_line() [](#method-i-accept_blank_line) - -## accept_block_quote() [](#method-i-accept_block_quote) - -## accept_document() [](#method-i-accept_document) - -## accept_heading() [](#method-i-accept_heading) - -## accept_heading_1() [](#method-i-accept_heading_1) - -## accept_heading_2() [](#method-i-accept_heading_2) - -## accept_heading_3() [](#method-i-accept_heading_3) - -## accept_heading_4() [](#method-i-accept_heading_4) - -## accept_heading_b() [](#method-i-accept_heading_b) - -## accept_heading_indent() [](#method-i-accept_heading_indent) - -## accept_heading_suppressed_crossref() [](#method-i-accept_heading_suppressed_crossref) - -## accept_list_end_bullet() [](#method-i-accept_list_end_bullet) - -## accept_list_end_label() [](#method-i-accept_list_end_label) - -## accept_list_end_lalpha() [](#method-i-accept_list_end_lalpha) - -## accept_list_end_note() [](#method-i-accept_list_end_note) - -## accept_list_end_number() [](#method-i-accept_list_end_number) - -## accept_list_end_ualpha() [](#method-i-accept_list_end_ualpha) - -## accept_list_item_end_bullet() [](#method-i-accept_list_item_end_bullet) - -## accept_list_item_end_label() [](#method-i-accept_list_item_end_label) - -## accept_list_item_end_lalpha() [](#method-i-accept_list_item_end_lalpha) - -## accept_list_item_end_note() [](#method-i-accept_list_item_end_note) - -## accept_list_item_end_number() [](#method-i-accept_list_item_end_number) - -## accept_list_item_end_ualpha() [](#method-i-accept_list_item_end_ualpha) - -## accept_list_item_start_bullet() [](#method-i-accept_list_item_start_bullet) - -## accept_list_item_start_label() [](#method-i-accept_list_item_start_label) - -## accept_list_item_start_lalpha() [](#method-i-accept_list_item_start_lalpha) - -## accept_list_item_start_note() [](#method-i-accept_list_item_start_note) - -## accept_list_item_start_note_2() [](#method-i-accept_list_item_start_note_2) - -## accept_list_item_start_note_multi_description() [](#method-i-accept_list_item_start_note_multi_description) - -## accept_list_item_start_note_multi_label() [](#method-i-accept_list_item_start_note_multi_label) - -## accept_list_item_start_number() [](#method-i-accept_list_item_start_number) - -## accept_list_item_start_ualpha() [](#method-i-accept_list_item_start_ualpha) - -## accept_list_start_bullet() [](#method-i-accept_list_start_bullet) - -## accept_list_start_label() [](#method-i-accept_list_start_label) - -## accept_list_start_lalpha() [](#method-i-accept_list_start_lalpha) - -## accept_list_start_note() [](#method-i-accept_list_start_note) - -## accept_list_start_number() [](#method-i-accept_list_start_number) - -## accept_list_start_ualpha() [](#method-i-accept_list_start_ualpha) - -## accept_paragraph() [](#method-i-accept_paragraph) - -## accept_paragraph_b() [](#method-i-accept_paragraph_b) - -## accept_paragraph_br() [](#method-i-accept_paragraph_br) - -## accept_paragraph_break() [](#method-i-accept_paragraph_break) - -## accept_paragraph_i() [](#method-i-accept_paragraph_i) - -## accept_paragraph_indent() [](#method-i-accept_paragraph_indent) - -## accept_paragraph_plus() [](#method-i-accept_paragraph_plus) - -## accept_paragraph_star() [](#method-i-accept_paragraph_star) - -## accept_paragraph_underscore() [](#method-i-accept_paragraph_underscore) - -## accept_paragraph_wrap() [](#method-i-accept_paragraph_wrap) - -## accept_raw() [](#method-i-accept_raw) - -## accept_rule() [](#method-i-accept_rule) - -## accept_rule_indent() [](#method-i-accept_rule_indent) - -## accept_table_align() [](#method-i-accept_table_align) - -## accept_verbatim() [](#method-i-accept_verbatim) - -## accept_verbatim_big_indent() [](#method-i-accept_verbatim_big_indent) - -## accept_verbatim_indent() [](#method-i-accept_verbatim_indent) - -## end_accepting() [](#method-i-end_accepting) - -## list_nested() [](#method-i-list_nested) - -## list_verbatim() [](#method-i-list_verbatim) - -## setup() [](#method-i-setup) - -## start_accepting() [](#method-i-start_accepting) - -## test_convert_list_note() [](#method-i-test_convert_list_note) -functional test - diff --git a/example/ruby/RDocMarkupToBsTest.md b/example/ruby/RDocMarkupToBsTest.md deleted file mode 100644 index 29a292e..0000000 --- a/example/ruby/RDocMarkupToBsTest.md +++ /dev/null @@ -1,128 +0,0 @@ -# Class: RDocMarkupToBsTest -**Inherits:** RDoc::Markup::TextFormatterTestCase - - - - - -#Instance Methods -## accept_blank_line() [](#method-i-accept_blank_line) - -## accept_block_quote() [](#method-i-accept_block_quote) - -## accept_document() [](#method-i-accept_document) - -## accept_heading() [](#method-i-accept_heading) - -## accept_heading_1() [](#method-i-accept_heading_1) - -## accept_heading_2() [](#method-i-accept_heading_2) - -## accept_heading_3() [](#method-i-accept_heading_3) - -## accept_heading_4() [](#method-i-accept_heading_4) - -## accept_heading_b() [](#method-i-accept_heading_b) - -## accept_heading_indent() [](#method-i-accept_heading_indent) - -## accept_heading_suppressed_crossref() [](#method-i-accept_heading_suppressed_crossref) - -## accept_list_end_bullet() [](#method-i-accept_list_end_bullet) - -## accept_list_end_label() [](#method-i-accept_list_end_label) - -## accept_list_end_lalpha() [](#method-i-accept_list_end_lalpha) - -## accept_list_end_note() [](#method-i-accept_list_end_note) - -## accept_list_end_number() [](#method-i-accept_list_end_number) - -## accept_list_end_ualpha() [](#method-i-accept_list_end_ualpha) - -## accept_list_item_end_bullet() [](#method-i-accept_list_item_end_bullet) - -## accept_list_item_end_label() [](#method-i-accept_list_item_end_label) - -## accept_list_item_end_lalpha() [](#method-i-accept_list_item_end_lalpha) - -## accept_list_item_end_note() [](#method-i-accept_list_item_end_note) - -## accept_list_item_end_number() [](#method-i-accept_list_item_end_number) - -## accept_list_item_end_ualpha() [](#method-i-accept_list_item_end_ualpha) - -## accept_list_item_start_bullet() [](#method-i-accept_list_item_start_bullet) - -## accept_list_item_start_label() [](#method-i-accept_list_item_start_label) - -## accept_list_item_start_lalpha() [](#method-i-accept_list_item_start_lalpha) - -## accept_list_item_start_note() [](#method-i-accept_list_item_start_note) - -## accept_list_item_start_note_2() [](#method-i-accept_list_item_start_note_2) - -## accept_list_item_start_note_multi_description() [](#method-i-accept_list_item_start_note_multi_description) - -## accept_list_item_start_note_multi_label() [](#method-i-accept_list_item_start_note_multi_label) - -## accept_list_item_start_number() [](#method-i-accept_list_item_start_number) - -## accept_list_item_start_ualpha() [](#method-i-accept_list_item_start_ualpha) - -## accept_list_start_bullet() [](#method-i-accept_list_start_bullet) - -## accept_list_start_label() [](#method-i-accept_list_start_label) - -## accept_list_start_lalpha() [](#method-i-accept_list_start_lalpha) - -## accept_list_start_note() [](#method-i-accept_list_start_note) - -## accept_list_start_number() [](#method-i-accept_list_start_number) - -## accept_list_start_ualpha() [](#method-i-accept_list_start_ualpha) - -## accept_paragraph() [](#method-i-accept_paragraph) - -## accept_paragraph_b() [](#method-i-accept_paragraph_b) - -## accept_paragraph_br() [](#method-i-accept_paragraph_br) - -## accept_paragraph_break() [](#method-i-accept_paragraph_break) - -## accept_paragraph_i() [](#method-i-accept_paragraph_i) - -## accept_paragraph_indent() [](#method-i-accept_paragraph_indent) - -## accept_paragraph_plus() [](#method-i-accept_paragraph_plus) - -## accept_paragraph_star() [](#method-i-accept_paragraph_star) - -## accept_paragraph_underscore() [](#method-i-accept_paragraph_underscore) - -## accept_paragraph_wrap() [](#method-i-accept_paragraph_wrap) - -## accept_raw() [](#method-i-accept_raw) - -## accept_rule() [](#method-i-accept_rule) - -## accept_rule_indent() [](#method-i-accept_rule_indent) - -## accept_table_align() [](#method-i-accept_table_align) - -## accept_verbatim() [](#method-i-accept_verbatim) - -## accept_verbatim_big_indent() [](#method-i-accept_verbatim_big_indent) - -## accept_verbatim_indent() [](#method-i-accept_verbatim_indent) - -## end_accepting() [](#method-i-end_accepting) - -## list_nested() [](#method-i-list_nested) - -## list_verbatim() [](#method-i-list_verbatim) - -## setup() [](#method-i-setup) - -## start_accepting() [](#method-i-start_accepting) - diff --git a/example/ruby/RDocMarkupToHtmlCrossrefTest.md b/example/ruby/RDocMarkupToHtmlCrossrefTest.md deleted file mode 100644 index 0d33348..0000000 --- a/example/ruby/RDocMarkupToHtmlCrossrefTest.md +++ /dev/null @@ -1,82 +0,0 @@ -# Class: RDocMarkupToHtmlCrossrefTest -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## REGEXP_HANDLING(text) [](#method-i-REGEXP_HANDLING) - -## hyper(reference) [](#method-i-hyper) - -## para(text) [](#method-i-para) - -## regexp_handling(text) [](#method-i-regexp_handling) - -## setup() [](#method-i-setup) - -## test_convert_CROSSREF() [](#method-i-test_convert_CROSSREF) - -## test_convert_CROSSREF_constant() [](#method-i-test_convert_CROSSREF_constant) - -## test_convert_CROSSREF_label() [](#method-i-test_convert_CROSSREF_label) - -## test_convert_CROSSREF_label_for_md() [](#method-i-test_convert_CROSSREF_label_for_md) - -## test_convert_CROSSREF_label_period() [](#method-i-test_convert_CROSSREF_label_period) - -## test_convert_CROSSREF_label_space() [](#method-i-test_convert_CROSSREF_label_space) - -## test_convert_CROSSREF_method() [](#method-i-test_convert_CROSSREF_method) - -## test_convert_CROSSREF_section() [](#method-i-test_convert_CROSSREF_section) - -## test_convert_RDOCLINK_rdoc_ref() [](#method-i-test_convert_RDOCLINK_rdoc_ref) - -## test_convert_RDOCLINK_rdoc_ref_label() [](#method-i-test_convert_RDOCLINK_rdoc_ref_label) - -## test_convert_RDOCLINK_rdoc_ref_label_in_current_file() [](#method-i-test_convert_RDOCLINK_rdoc_ref_label_in_current_file) - -## test_convert_RDOCLINK_rdoc_ref_method() [](#method-i-test_convert_RDOCLINK_rdoc_ref_method) - -## test_convert_RDOCLINK_rdoc_ref_method_escape_html() [](#method-i-test_convert_RDOCLINK_rdoc_ref_method_escape_html) - -## test_convert_RDOCLINK_rdoc_ref_method_label() [](#method-i-test_convert_RDOCLINK_rdoc_ref_method_label) - -## test_convert_RDOCLINK_rdoc_ref_method_percent() [](#method-i-test_convert_RDOCLINK_rdoc_ref_method_percent) - -## test_convert_RDOCLINK_rdoc_ref_method_percent_label() [](#method-i-test_convert_RDOCLINK_rdoc_ref_method_percent_label) - -## test_convert_RDOCLINK_rdoc_ref_not_found() [](#method-i-test_convert_RDOCLINK_rdoc_ref_not_found) - -## test_gen_url() [](#method-i-test_gen_url) - -## test_gen_url_rdoc_ref_not_found() [](#method-i-test_gen_url_rdoc_ref_not_found) - -## test_handle_regexp_CROSSREF() [](#method-i-test_handle_regexp_CROSSREF) - -## test_handle_regexp_CROSSREF_label() [](#method-i-test_handle_regexp_CROSSREF_label) - -## test_handle_regexp_CROSSREF_show_hash_false() [](#method-i-test_handle_regexp_CROSSREF_show_hash_false) - -## test_handle_regexp_CROSSREF_with_arg_looks_like_TIDYLINK() [](#method-i-test_handle_regexp_CROSSREF_with_arg_looks_like_TIDYLINK) - -## test_handle_regexp_HYPERLINK_rdoc() [](#method-i-test_handle_regexp_HYPERLINK_rdoc) - -## test_handle_regexp_TIDYLINK_label() [](#method-i-test_handle_regexp_TIDYLINK_label) - -## test_handle_regexp_TIDYLINK_rdoc() [](#method-i-test_handle_regexp_TIDYLINK_rdoc) - -## test_link() [](#method-i-test_link) - -## test_link_class_method_full() [](#method-i-test_link_class_method_full) - -## test_link_for_method_traverse() [](#method-i-test_link_for_method_traverse) - -## test_to_html_CROSSREF_email() [](#method-i-test_to_html_CROSSREF_email) - -## test_to_html_CROSSREF_email_hyperlink_all() [](#method-i-test_to_html_CROSSREF_email_hyperlink_all) - -## tidy(reference) [](#method-i-tidy) - diff --git a/example/ruby/RDocMarkupToHtmlTest.md b/example/ruby/RDocMarkupToHtmlTest.md deleted file mode 100644 index 28c9bb1..0000000 --- a/example/ruby/RDocMarkupToHtmlTest.md +++ /dev/null @@ -1,224 +0,0 @@ -# Class: RDocMarkupToHtmlTest -**Inherits:** RDoc::Markup::FormatterTestCase - - - - - -#Instance Methods -## accept_blank_line() [](#method-i-accept_blank_line) - -## accept_block_quote() [](#method-i-accept_block_quote) - -## accept_document() [](#method-i-accept_document) - -## accept_heading() [](#method-i-accept_heading) - -## accept_heading_1() [](#method-i-accept_heading_1) - -## accept_heading_2() [](#method-i-accept_heading_2) - -## accept_heading_3() [](#method-i-accept_heading_3) - -## accept_heading_4() [](#method-i-accept_heading_4) - -## accept_heading_b() [](#method-i-accept_heading_b) - -## accept_heading_suppressed_crossref() [](#method-i-accept_heading_suppressed_crossref) - -## accept_list_end_bullet() [](#method-i-accept_list_end_bullet) - -## accept_list_end_label() [](#method-i-accept_list_end_label) - -## accept_list_end_lalpha() [](#method-i-accept_list_end_lalpha) - -## accept_list_end_note() [](#method-i-accept_list_end_note) - -## accept_list_end_number() [](#method-i-accept_list_end_number) - -## accept_list_end_ualpha() [](#method-i-accept_list_end_ualpha) - -## accept_list_item_end_bullet() [](#method-i-accept_list_item_end_bullet) - -## accept_list_item_end_label() [](#method-i-accept_list_item_end_label) - -## accept_list_item_end_lalpha() [](#method-i-accept_list_item_end_lalpha) - -## accept_list_item_end_note() [](#method-i-accept_list_item_end_note) - -## accept_list_item_end_number() [](#method-i-accept_list_item_end_number) - -## accept_list_item_end_ualpha() [](#method-i-accept_list_item_end_ualpha) - -## accept_list_item_start_bullet() [](#method-i-accept_list_item_start_bullet) - -## accept_list_item_start_label() [](#method-i-accept_list_item_start_label) - -## accept_list_item_start_lalpha() [](#method-i-accept_list_item_start_lalpha) - -## accept_list_item_start_note() [](#method-i-accept_list_item_start_note) - -## accept_list_item_start_note_2() [](#method-i-accept_list_item_start_note_2) - -## accept_list_item_start_note_multi_description() [](#method-i-accept_list_item_start_note_multi_description) - -## accept_list_item_start_note_multi_label() [](#method-i-accept_list_item_start_note_multi_label) - -## accept_list_item_start_number() [](#method-i-accept_list_item_start_number) - -## accept_list_item_start_ualpha() [](#method-i-accept_list_item_start_ualpha) - -## accept_list_start_bullet() [](#method-i-accept_list_start_bullet) - -## accept_list_start_label() [](#method-i-accept_list_start_label) - -## accept_list_start_lalpha() [](#method-i-accept_list_start_lalpha) - -## accept_list_start_note() [](#method-i-accept_list_start_note) - -## accept_list_start_number() [](#method-i-accept_list_start_number) - -## accept_list_start_ualpha() [](#method-i-accept_list_start_ualpha) - -## accept_paragraph() [](#method-i-accept_paragraph) - -## accept_paragraph_b() [](#method-i-accept_paragraph_b) - -## accept_paragraph_br() [](#method-i-accept_paragraph_br) - -## accept_paragraph_break() [](#method-i-accept_paragraph_break) - -## accept_paragraph_i() [](#method-i-accept_paragraph_i) - -## accept_paragraph_plus() [](#method-i-accept_paragraph_plus) - -## accept_paragraph_star() [](#method-i-accept_paragraph_star) - -## accept_paragraph_underscore() [](#method-i-accept_paragraph_underscore) - -## accept_raw() [](#method-i-accept_raw) - -## accept_rule() [](#method-i-accept_rule) - -## accept_verbatim() [](#method-i-accept_verbatim) - -## assert_escaped(unexpected, code) [](#method-i-assert_escaped) - -## end_accepting() [](#method-i-end_accepting) - -## list_nested() [](#method-i-list_nested) - -## list_verbatim() [](#method-i-list_verbatim) - -## setup() [](#method-i-setup) - -## start_accepting() [](#method-i-start_accepting) - -## test_accept_heading_7() [](#method-i-test_accept_heading_7) - -## test_accept_heading_aref_class() [](#method-i-test_accept_heading_aref_class) - -## test_accept_heading_aref_method() [](#method-i-test_accept_heading_aref_method) - -## test_accept_heading_output_decoration() [](#method-i-test_accept_heading_output_decoration) - -## test_accept_heading_output_decoration_with_pipe() [](#method-i-test_accept_heading_output_decoration_with_pipe) - -## test_accept_heading_pipe() [](#method-i-test_accept_heading_pipe) - -## test_accept_paragraph_newline() [](#method-i-test_accept_paragraph_newline) - -## test_accept_table() [](#method-i-test_accept_table) - -## test_accept_verbatim_escape_in_backtick() [](#method-i-test_accept_verbatim_escape_in_backtick) - -## test_accept_verbatim_escape_in_string() [](#method-i-test_accept_verbatim_escape_in_string) - -## test_accept_verbatim_nl_after_backslash() [](#method-i-test_accept_verbatim_nl_after_backslash) - -## test_accept_verbatim_parseable() [](#method-i-test_accept_verbatim_parseable) - -## test_accept_verbatim_parseable_error() [](#method-i-test_accept_verbatim_parseable_error) - -## test_accept_verbatim_pipe() [](#method-i-test_accept_verbatim_pipe) - -## test_accept_verbatim_redefinable_operators() [](#method-i-test_accept_verbatim_redefinable_operators) - -## test_accept_verbatim_ruby() [](#method-i-test_accept_verbatim_ruby) - -## test_block_quote_in_verbatim() [](#method-i-test_block_quote_in_verbatim) - -## test_convert_HYPERLINK_irc() [](#method-i-test_convert_HYPERLINK_irc) - -## test_convert_RDOCLINK_escape_image() [](#method-i-test_convert_RDOCLINK_escape_image) - -## test_convert_RDOCLINK_escape_label_id() [](#method-i-test_convert_RDOCLINK_escape_label_id) - -## test_convert_RDOCLINK_escape_label_path() [](#method-i-test_convert_RDOCLINK_escape_label_path) - -## test_convert_RDOCLINK_escape_ref() [](#method-i-test_convert_RDOCLINK_escape_ref) - -## test_convert_RDOCLINK_escape_xxx() [](#method-i-test_convert_RDOCLINK_escape_xxx) - -## test_convert_RDOCLINK_label_footmark() [](#method-i-test_convert_RDOCLINK_label_footmark) - -## test_convert_RDOCLINK_label_foottext() [](#method-i-test_convert_RDOCLINK_label_foottext) - -## test_convert_RDOCLINK_label_label() [](#method-i-test_convert_RDOCLINK_label_label) - -## test_convert_RDOCLINK_ref() [](#method-i-test_convert_RDOCLINK_ref) - -## test_convert_TIDYLINK_escape_javascript() [](#method-i-test_convert_TIDYLINK_escape_javascript) - -## test_convert_TIDYLINK_escape_onerror() [](#method-i-test_convert_TIDYLINK_escape_onerror) - -## test_convert_TIDYLINK_escape_onmouseover() [](#method-i-test_convert_TIDYLINK_escape_onmouseover) - -## test_convert_TIDYLINK_escape_text() [](#method-i-test_convert_TIDYLINK_escape_text) - -## test_convert_TIDYLINK_footnote() [](#method-i-test_convert_TIDYLINK_footnote) - -## test_convert_TIDYLINK_image() [](#method-i-test_convert_TIDYLINK_image) - -## test_convert_TIDYLINK_irc() [](#method-i-test_convert_TIDYLINK_irc) - -## test_convert_TIDYLINK_multiple() [](#method-i-test_convert_TIDYLINK_multiple) - -## test_convert_TIDYLINK_rdoc_label() [](#method-i-test_convert_TIDYLINK_rdoc_label) - -## test_convert_string() [](#method-i-test_convert_string) - -## test_convert_underscore_adjacent_to_code() [](#method-i-test_convert_underscore_adjacent_to_code) - -## test_convert_with_exclude_tag() [](#method-i-test_convert_with_exclude_tag) - -## test_gen_url() [](#method-i-test_gen_url) - -## test_gen_url_image_url() [](#method-i-test_gen_url_image_url) - -## test_gen_url_md_file() [](#method-i-test_gen_url_md_file) - -## test_gen_url_rb_file() [](#method-i-test_gen_url_rb_file) - -## test_gen_url_rdoc_file() [](#method-i-test_gen_url_rdoc_file) - -## test_gen_url_rdoc_label() [](#method-i-test_gen_url_rdoc_label) - -## test_gen_url_rdoc_label_id() [](#method-i-test_gen_url_rdoc_label_id) - -## test_gen_url_ssl_image_url() [](#method-i-test_gen_url_ssl_image_url) - -## test_handle_regexp_HYPERLINK_escape() [](#method-i-test_handle_regexp_HYPERLINK_escape) - -## test_handle_regexp_HYPERLINK_irc() [](#method-i-test_handle_regexp_HYPERLINK_irc) - -## test_handle_regexp_HYPERLINK_link() [](#method-i-test_handle_regexp_HYPERLINK_link) - -## test_list_verbatim_2() [](#method-i-test_list_verbatim_2) - -## test_parseable_eh() [](#method-i-test_parseable_eh) - -## test_to_html() [](#method-i-test_to_html) - -## util_format(text) [](#method-i-util_format) - diff --git a/example/ruby/RDocMarkupToMarkdownTest.md b/example/ruby/RDocMarkupToMarkdownTest.md deleted file mode 100644 index bc34e6a..0000000 --- a/example/ruby/RDocMarkupToMarkdownTest.md +++ /dev/null @@ -1,142 +0,0 @@ -# Class: RDocMarkupToMarkdownTest -**Inherits:** RDoc::Markup::TextFormatterTestCase - - - - - -#Instance Methods -## accept_blank_line() [](#method-i-accept_blank_line) - -## accept_block_quote() [](#method-i-accept_block_quote) - -## accept_document() [](#method-i-accept_document) - -## accept_heading() [](#method-i-accept_heading) - -## accept_heading_1() [](#method-i-accept_heading_1) - -## accept_heading_2() [](#method-i-accept_heading_2) - -## accept_heading_3() [](#method-i-accept_heading_3) - -## accept_heading_4() [](#method-i-accept_heading_4) - -## accept_heading_b() [](#method-i-accept_heading_b) - -## accept_heading_indent() [](#method-i-accept_heading_indent) - -## accept_heading_suppressed_crossref() [](#method-i-accept_heading_suppressed_crossref) - -## accept_list_end_bullet() [](#method-i-accept_list_end_bullet) - -## accept_list_end_label() [](#method-i-accept_list_end_label) - -## accept_list_end_lalpha() [](#method-i-accept_list_end_lalpha) - -## accept_list_end_note() [](#method-i-accept_list_end_note) - -## accept_list_end_number() [](#method-i-accept_list_end_number) - -## accept_list_end_ualpha() [](#method-i-accept_list_end_ualpha) - -## accept_list_item_end_bullet() [](#method-i-accept_list_item_end_bullet) - -## accept_list_item_end_label() [](#method-i-accept_list_item_end_label) - -## accept_list_item_end_lalpha() [](#method-i-accept_list_item_end_lalpha) - -## accept_list_item_end_note() [](#method-i-accept_list_item_end_note) - -## accept_list_item_end_number() [](#method-i-accept_list_item_end_number) - -## accept_list_item_end_ualpha() [](#method-i-accept_list_item_end_ualpha) - -## accept_list_item_start_bullet() [](#method-i-accept_list_item_start_bullet) - -## accept_list_item_start_label() [](#method-i-accept_list_item_start_label) - -## accept_list_item_start_lalpha() [](#method-i-accept_list_item_start_lalpha) - -## accept_list_item_start_note() [](#method-i-accept_list_item_start_note) - -## accept_list_item_start_note_2() [](#method-i-accept_list_item_start_note_2) - -## accept_list_item_start_note_multi_description() [](#method-i-accept_list_item_start_note_multi_description) - -## accept_list_item_start_note_multi_label() [](#method-i-accept_list_item_start_note_multi_label) - -## accept_list_item_start_number() [](#method-i-accept_list_item_start_number) - -## accept_list_item_start_ualpha() [](#method-i-accept_list_item_start_ualpha) - -## accept_list_start_bullet() [](#method-i-accept_list_start_bullet) - -## accept_list_start_label() [](#method-i-accept_list_start_label) - -## accept_list_start_lalpha() [](#method-i-accept_list_start_lalpha) - -## accept_list_start_note() [](#method-i-accept_list_start_note) - -## accept_list_start_number() [](#method-i-accept_list_start_number) - -## accept_list_start_ualpha() [](#method-i-accept_list_start_ualpha) - -## accept_paragraph() [](#method-i-accept_paragraph) - -## accept_paragraph_b() [](#method-i-accept_paragraph_b) - -## accept_paragraph_br() [](#method-i-accept_paragraph_br) - -## accept_paragraph_break() [](#method-i-accept_paragraph_break) - -## accept_paragraph_i() [](#method-i-accept_paragraph_i) - -## accept_paragraph_indent() [](#method-i-accept_paragraph_indent) - -## accept_paragraph_plus() [](#method-i-accept_paragraph_plus) - -## accept_paragraph_star() [](#method-i-accept_paragraph_star) - -## accept_paragraph_underscore() [](#method-i-accept_paragraph_underscore) - -## accept_paragraph_wrap() [](#method-i-accept_paragraph_wrap) - -## accept_raw() [](#method-i-accept_raw) - -## accept_rule() [](#method-i-accept_rule) - -## accept_rule_indent() [](#method-i-accept_rule_indent) - -## accept_table_align() [](#method-i-accept_table_align) - -## accept_verbatim() [](#method-i-accept_verbatim) - -## accept_verbatim_big_indent() [](#method-i-accept_verbatim_big_indent) - -## accept_verbatim_indent() [](#method-i-accept_verbatim_indent) - -## end_accepting() [](#method-i-end_accepting) - -## list_nested() [](#method-i-list_nested) - -## list_verbatim() [](#method-i-list_verbatim) - -## setup() [](#method-i-setup) - -## start_accepting() [](#method-i-start_accepting) - -## test_convert_RDOCLINK() [](#method-i-test_convert_RDOCLINK) - -## test_convert_RDOCLINK_image() [](#method-i-test_convert_RDOCLINK_image) - -## test_convert_TIDYLINK() [](#method-i-test_convert_TIDYLINK) - -## test_handle_rdoc_link_label_footmark() [](#method-i-test_handle_rdoc_link_label_footmark) - -## test_handle_rdoc_link_label_foottext() [](#method-i-test_handle_rdoc_link_label_foottext) - -## test_handle_rdoc_link_label_label() [](#method-i-test_handle_rdoc_link_label_label) - -## test_handle_rdoc_link_ref() [](#method-i-test_handle_rdoc_link_ref) - diff --git a/example/ruby/RDocMarkupToRDocTest.md b/example/ruby/RDocMarkupToRDocTest.md deleted file mode 100644 index c017120..0000000 --- a/example/ruby/RDocMarkupToRDocTest.md +++ /dev/null @@ -1,133 +0,0 @@ -# Class: RDocMarkupToRDocTest -**Inherits:** RDoc::Markup::TextFormatterTestCase - - - - - -#Instance Methods -## accept_blank_line() [](#method-i-accept_blank_line) - -## accept_block_quote() [](#method-i-accept_block_quote) - -## accept_document() [](#method-i-accept_document) - -## accept_heading() [](#method-i-accept_heading) - -## accept_heading_1() [](#method-i-accept_heading_1) - -## accept_heading_2() [](#method-i-accept_heading_2) - -## accept_heading_3() [](#method-i-accept_heading_3) - -## accept_heading_4() [](#method-i-accept_heading_4) - -## accept_heading_b() [](#method-i-accept_heading_b) - -## accept_heading_indent() [](#method-i-accept_heading_indent) - -## accept_heading_suppressed_crossref() [](#method-i-accept_heading_suppressed_crossref) - -## accept_list_end_bullet() [](#method-i-accept_list_end_bullet) - -## accept_list_end_label() [](#method-i-accept_list_end_label) - -## accept_list_end_lalpha() [](#method-i-accept_list_end_lalpha) - -## accept_list_end_note() [](#method-i-accept_list_end_note) - -## accept_list_end_number() [](#method-i-accept_list_end_number) - -## accept_list_end_ualpha() [](#method-i-accept_list_end_ualpha) - -## accept_list_item_end_bullet() [](#method-i-accept_list_item_end_bullet) - -## accept_list_item_end_label() [](#method-i-accept_list_item_end_label) - -## accept_list_item_end_lalpha() [](#method-i-accept_list_item_end_lalpha) - -## accept_list_item_end_note() [](#method-i-accept_list_item_end_note) - -## accept_list_item_end_number() [](#method-i-accept_list_item_end_number) - -## accept_list_item_end_ualpha() [](#method-i-accept_list_item_end_ualpha) - -## accept_list_item_start_bullet() [](#method-i-accept_list_item_start_bullet) - -## accept_list_item_start_label() [](#method-i-accept_list_item_start_label) - -## accept_list_item_start_lalpha() [](#method-i-accept_list_item_start_lalpha) - -## accept_list_item_start_note() [](#method-i-accept_list_item_start_note) - -## accept_list_item_start_note_2() [](#method-i-accept_list_item_start_note_2) - -## accept_list_item_start_note_multi_description() [](#method-i-accept_list_item_start_note_multi_description) - -## accept_list_item_start_note_multi_label() [](#method-i-accept_list_item_start_note_multi_label) - -## accept_list_item_start_number() [](#method-i-accept_list_item_start_number) - -## accept_list_item_start_ualpha() [](#method-i-accept_list_item_start_ualpha) - -## accept_list_start_bullet() [](#method-i-accept_list_start_bullet) - -## accept_list_start_label() [](#method-i-accept_list_start_label) - -## accept_list_start_lalpha() [](#method-i-accept_list_start_lalpha) - -## accept_list_start_note() [](#method-i-accept_list_start_note) - -## accept_list_start_number() [](#method-i-accept_list_start_number) - -## accept_list_start_ualpha() [](#method-i-accept_list_start_ualpha) - -## accept_paragraph() [](#method-i-accept_paragraph) - -## accept_paragraph_b() [](#method-i-accept_paragraph_b) - -## accept_paragraph_br() [](#method-i-accept_paragraph_br) - -## accept_paragraph_break() [](#method-i-accept_paragraph_break) - -## accept_paragraph_i() [](#method-i-accept_paragraph_i) - -## accept_paragraph_indent() [](#method-i-accept_paragraph_indent) - -## accept_paragraph_plus() [](#method-i-accept_paragraph_plus) - -## accept_paragraph_star() [](#method-i-accept_paragraph_star) - -## accept_paragraph_underscore() [](#method-i-accept_paragraph_underscore) - -## accept_paragraph_wrap() [](#method-i-accept_paragraph_wrap) - -## accept_raw() [](#method-i-accept_raw) - -## accept_rule() [](#method-i-accept_rule) - -## accept_rule_indent() [](#method-i-accept_rule_indent) - -## accept_table_align() [](#method-i-accept_table_align) - -## accept_verbatim() [](#method-i-accept_verbatim) - -## accept_verbatim_big_indent() [](#method-i-accept_verbatim_big_indent) - -## accept_verbatim_indent() [](#method-i-accept_verbatim_indent) - -## end_accepting() [](#method-i-end_accepting) - -## list_nested() [](#method-i-list_nested) - -## list_verbatim() [](#method-i-list_verbatim) - -## setup() [](#method-i-setup) - -## start_accepting() [](#method-i-start_accepting) - -## test_accept_indented_paragraph() [](#method-i-test_accept_indented_paragraph) - -## test_convert_list_note() [](#method-i-test_convert_list_note) -functional test - diff --git a/example/ruby/RDocParserPrismTestCases.md b/example/ruby/RDocParserPrismTestCases.md deleted file mode 100644 index 3ad23ad..0000000 --- a/example/ruby/RDocParserPrismTestCases.md +++ /dev/null @@ -1,179 +0,0 @@ -# Module: RDocParserPrismTestCases - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_alias() [](#method-i-test_alias) - -## test_alias_method() [](#method-i-test_alias_method) - -## test_alias_method_stopdoc_nodoc() [](#method-i-test_alias_method_stopdoc_nodoc) - -## test_alias_singleton() [](#method-i-test_alias_singleton) - -## test_attributes() [](#method-i-test_attributes) - -## test_attributes_nodoc() [](#method-i-test_attributes_nodoc) - -## test_attributes_nodoc_track() [](#method-i-test_attributes_nodoc_track) - -## test_attributes_visibility() [](#method-i-test_attributes_visibility) - -## test_block_comment() [](#method-i-test_block_comment) - -## test_calls_super() [](#method-i-test_calls_super) - -## test_category() [](#method-i-test_category) - -## test_class() [](#method-i-test_class) - -## test_class_definition_encountered_after_class_reference() [](#method-i-test_class_definition_encountered_after_class_reference) - -## test_class_method_visibility() [](#method-i-test_class_method_visibility) - -## test_class_mistaken_for_module() [](#method-i-test_class_mistaken_for_module) - -## test_class_module_nodoc() [](#method-i-test_class_module_nodoc) - -## test_class_module_stopdoc() [](#method-i-test_class_module_stopdoc) - -## test_class_new_notnew() [](#method-i-test_class_new_notnew) - -## test_class_repeatedly() [](#method-i-test_class_repeatedly) - -## test_class_superclass() [](#method-i-test_class_superclass) - -## test_confusing_superclass() [](#method-i-test_confusing_superclass) - -## test_constant() [](#method-i-test_constant) - -## test_constant_alias() [](#method-i-test_constant_alias) - -## test_constant_assignment_to_undefined_module_path() [](#method-i-test_constant_assignment_to_undefined_module_path) - -## test_constant_method() [](#method-i-test_constant_method) - -## test_constant_visibility() [](#method-i-test_constant_visibility) - -## test_define_method_visibility() [](#method-i-test_define_method_visibility) - -## test_enddoc() [](#method-i-test_enddoc) - -## test_first_comment_is_not_a_meta_method() [](#method-i-test_first_comment_is_not_a_meta_method) - -## test_ghost_method() [](#method-i-test_ghost_method) - -## test_ignore_constant_assign_rhs() [](#method-i-test_ignore_constant_assign_rhs) - -## test_include_extend() [](#method-i-test_include_extend) - -## test_include_extend_to_singleton_class() [](#method-i-test_include_extend_to_singleton_class) - -## test_include_with_module_nesting() [](#method-i-test_include_with_module_nesting) - -## test_invalid_alias_method() [](#method-i-test_invalid_alias_method) - -## test_invalid_meta_method() [](#method-i-test_invalid_meta_method) - -## test_look_for_directives_in_commented() [](#method-i-test_look_for_directives_in_commented) - -## test_look_for_directives_in_section() [](#method-i-test_look_for_directives_in_section) - -## test_look_for_directives_in_unhandled() [](#method-i-test_look_for_directives_in_unhandled) - -## test_markup_first_comment() [](#method-i-test_markup_first_comment) - -## test_markup_override() [](#method-i-test_markup_override) - -## test_meta_attributes() [](#method-i-test_meta_attributes) - -## test_meta_attributes_named() [](#method-i-test_meta_attributes_named) - -## test_meta_define_method() [](#method-i-test_meta_define_method) - -## test_meta_method() [](#method-i-test_meta_method) - -## test_meta_method_unknown() [](#method-i-test_meta_method_unknown) - -## test_method() [](#method-i-test_method) - -## test_method_args_directive() [](#method-i-test_method_args_directive) - -## test_method_change_visibility() [](#method-i-test_method_change_visibility) - -## test_method_definition_nested_inside_block() [](#method-i-test_method_definition_nested_inside_block) - -## test_method_nested_visibility() [](#method-i-test_method_nested_visibility) - -## test_method_nodoc_stopdoc() [](#method-i-test_method_nodoc_stopdoc) - -## test_method_nodoc_track() [](#method-i-test_method_nodoc_track) - -## test_method_singleton_class_visibility() [](#method-i-test_method_singleton_class_visibility) - -## test_method_toplevel() [](#method-i-test_method_toplevel) - -## test_method_visibility_change_in_subclass() [](#method-i-test_method_visibility_change_in_subclass) - -## test_method_yields_directive() [](#method-i-test_method_yields_directive) - -## test_module() [](#method-i-test_module) - -## test_module_function() [](#method-i-test_module_function) - -## test_multibyte_method_name() [](#method-i-test_multibyte_method_name) - -## test_nested_class_with_colon() [](#method-i-test_nested_class_with_colon) - -## test_nested_module_with_colon() [](#method-i-test_nested_module_with_colon) - -## test_nodoc_constant_assigned_without_nodoc_comment() [](#method-i-test_nodoc_constant_assigned_without_nodoc_comment) - -## test_open_class_with_superclass() [](#method-i-test_open_class_with_superclass) - -## test_options_encoding() [](#method-i-test_options_encoding) - -## test_parenthesized_cdecl() [](#method-i-test_parenthesized_cdecl) - -## test_private_def_public_def() [](#method-i-test_private_def_public_def) - -## test_read_directive_linear_performance() [](#method-i-test_read_directive_linear_performance) - -## test_require() [](#method-i-test_require) - -## test_scan_duplicate_module() [](#method-i-test_scan_duplicate_module) - -## test_section() [](#method-i-test_section) - -## test_singleton_class() [](#method-i-test_singleton_class) - -## test_singleton_class_attributes() [](#method-i-test_singleton_class_attributes) - -## test_singleton_class_meta_method() [](#method-i-test_singleton_class_meta_method) - -## test_singleton_method_visibility_change_in_subclass() [](#method-i-test_singleton_method_visibility_change_in_subclass) - -## test_statements_identifier_alias_method_before_original_method() [](#method-i-test_statements_identifier_alias_method_before_original_method) - -## test_tomdoc_meta() [](#method-i-test_tomdoc_meta) - -## test_top_level_enddoc() [](#method-i-test_top_level_enddoc) - -## test_true_false_nil_method() [](#method-i-test_true_false_nil_method) - -## test_undefined_singleton_class_defines_module() [](#method-i-test_undefined_singleton_class_defines_module) - -## test_undocumentable_attributes() [](#method-i-test_undocumentable_attributes) - -## test_undocumentable_change_visibility() [](#method-i-test_undocumentable_change_visibility) - -## test_unknown_meta_method() [](#method-i-test_unknown_meta_method) - -## test_various_argument_include() [](#method-i-test_various_argument_include) - diff --git a/example/ruby/RDocParserTest.md b/example/ruby/RDocParserTest.md deleted file mode 100644 index efb97c6..0000000 --- a/example/ruby/RDocParserTest.md +++ /dev/null @@ -1,65 +0,0 @@ -# Class: RDocParserTest -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_can_parse_modeline() [](#method-i-test_can_parse_modeline) - -## test_can_parse_modeline_c() [](#method-i-test_can_parse_modeline_c) - -## test_check_modeline() [](#method-i-test_check_modeline) - -## test_check_modeline_coding() [](#method-i-test_check_modeline_coding) - -## test_check_modeline_no_modeline() [](#method-i-test_check_modeline_no_modeline) - -## test_check_modeline_with_other() [](#method-i-test_check_modeline_with_other) - -## test_class_binary_eh_ISO_2022_JP() [](#method-i-test_class_binary_eh_ISO_2022_JP) - -## test_class_binary_eh_marshal() [](#method-i-test_class_binary_eh_marshal) - -## test_class_binary_japanese_rdoc() [](#method-i-test_class_binary_japanese_rdoc) - -## test_class_binary_japanese_text() [](#method-i-test_class_binary_japanese_text) - -## test_class_binary_large_japanese_rdoc() [](#method-i-test_class_binary_large_japanese_rdoc) - -## test_class_can_parse() [](#method-i-test_class_can_parse) - -## test_class_can_parse_zip() [](#method-i-test_class_can_parse_zip) -Selenium hides a .jar file using a .txt extension. - -## test_class_for_binary() [](#method-i-test_class_for_binary) - -## test_class_for_executable() [](#method-i-test_class_for_executable) - -## test_class_for_forbidden() [](#method-i-test_class_for_forbidden) - -## test_class_for_markup() [](#method-i-test_class_for_markup) - -## test_class_for_modeline() [](#method-i-test_class_for_modeline) - -## test_class_use_markup() [](#method-i-test_class_use_markup) - -## test_class_use_markup_markdown() [](#method-i-test_class_use_markup_markdown) - -## test_class_use_markup_modeline() [](#method-i-test_class_use_markup_modeline) - -## test_class_use_markup_modeline_shebang() [](#method-i-test_class_use_markup_modeline_shebang) - -## test_class_use_markup_none() [](#method-i-test_class_use_markup_none) - -## test_class_use_markup_shebang() [](#method-i-test_class_use_markup_shebang) - -## test_class_use_markup_tomdoc() [](#method-i-test_class_use_markup_tomdoc) - -## test_class_use_markup_unknown() [](#method-i-test_class_use_markup_unknown) - -## test_initialize() [](#method-i-test_initialize) - diff --git a/example/ruby/RDocRIDriverTest.md b/example/ruby/RDocRIDriverTest.md deleted file mode 100644 index 566d0ca..0000000 --- a/example/ruby/RDocRIDriverTest.md +++ /dev/null @@ -1,197 +0,0 @@ -# Class: RDocRIDriverTest -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_add_also_in() [](#method-i-test_add_also_in) - -## test_add_also_in_empty() [](#method-i-test_add_also_in_empty) - -## test_add_class() [](#method-i-test_add_class) - -## test_add_extends() [](#method-i-test_add_extends) - -## test_add_extension_modules_empty() [](#method-i-test_add_extension_modules_empty) - -## test_add_extension_modules_many() [](#method-i-test_add_extension_modules_many) - -## test_add_extension_modules_many_no_doc() [](#method-i-test_add_extension_modules_many_no_doc) - -## test_add_extension_modules_one() [](#method-i-test_add_extension_modules_one) - -## test_add_from() [](#method-i-test_add_from) - -## test_add_includes() [](#method-i-test_add_includes) - -## test_add_method() [](#method-i-test_add_method) - -## test_add_method_attribute() [](#method-i-test_add_method_attribute) - -## test_add_method_documentation() [](#method-i-test_add_method_documentation) - -## test_add_method_inherited() [](#method-i-test_add_method_inherited) - -## test_add_method_list() [](#method-i-test_add_method_list) - -## test_add_method_list_interative() [](#method-i-test_add_method_list_interative) - -## test_add_method_list_none() [](#method-i-test_add_method_list_none) - -## test_add_method_overridden() [](#method-i-test_add_method_overridden) - -## test_add_method_that_is_alias_for_original() [](#method-i-test_add_method_that_is_alias_for_original) - -## test_add_method_with_rdoc_ref_link() [](#method-i-test_add_method_with_rdoc_ref_link) - -## test_ancestors_of() [](#method-i-test_ancestors_of) - -## test_ancestors_of_chained_inclusion() [](#method-i-test_ancestors_of_chained_inclusion) - -## test_class_document() [](#method-i-test_class_document) - -## test_classes() [](#method-i-test_classes) - -## test_complete() [](#method-i-test_complete) - -## test_complete_ancestor() [](#method-i-test_complete_ancestor) - -## test_complete_classes() [](#method-i-test_complete_classes) - -## test_complete_multistore() [](#method-i-test_complete_multistore) - -## test_did_you_mean() [](#method-i-test_did_you_mean) - -## test_display() [](#method-i-test_display) - -## test_display_class() [](#method-i-test_display_class) - -## test_display_class_all() [](#method-i-test_display_class_all) - -## test_display_class_ambiguous() [](#method-i-test_display_class_ambiguous) - -## test_display_class_module() [](#method-i-test_display_class_module) - -## test_display_class_multi_no_doc() [](#method-i-test_display_class_multi_no_doc) - -## test_display_class_page() [](#method-i-test_display_class_page) - -## test_display_class_superclass() [](#method-i-test_display_class_superclass) - -## test_display_method() [](#method-i-test_display_method) - -## test_display_method_attribute() [](#method-i-test_display_method_attribute) - -## test_display_method_inherited() [](#method-i-test_display_method_inherited) - -## test_display_method_overridden() [](#method-i-test_display_method_overridden) - -## test_display_method_params() [](#method-i-test_display_method_params) - -## test_display_name() [](#method-i-test_display_name) - -## test_display_name_not_found_class() [](#method-i-test_display_name_not_found_class) - -## test_display_name_not_found_method() [](#method-i-test_display_name_not_found_method) - -## test_display_name_not_found_special() [](#method-i-test_display_name_not_found_special) - -## test_display_page() [](#method-i-test_display_page) - -## test_display_page_add_extension() [](#method-i-test_display_page_add_extension) - -## test_display_page_ambiguous() [](#method-i-test_display_page_ambiguous) - -## test_display_page_extension() [](#method-i-test_display_page_extension) - -## test_display_page_ignore_directory() [](#method-i-test_display_page_ignore_directory) - -## test_display_page_list() [](#method-i-test_display_page_list) - -## test_display_page_missing() [](#method-i-test_display_page_missing) - -## test_expand_class() [](#method-i-test_expand_class) - -## test_expand_class_2() [](#method-i-test_expand_class_2) - -## test_expand_class_3() [](#method-i-test_expand_class_3) - -## test_expand_name() [](#method-i-test_expand_name) - -## test_filter_methods() [](#method-i-test_filter_methods) - -## test_filter_methods_not_found() [](#method-i-test_filter_methods_not_found) - -## test_find_methods() [](#method-i-test_find_methods) - -## test_find_methods_method() [](#method-i-test_find_methods_method) - -## test_find_store() [](#method-i-test_find_store) - -## test_formatter() [](#method-i-test_formatter) - -## test_list_known_classes() [](#method-i-test_list_known_classes) - -## test_list_known_classes_name() [](#method-i-test_list_known_classes_name) - -## test_list_methods_matching() [](#method-i-test_list_methods_matching) - -## test_list_methods_matching_inherit() [](#method-i-test_list_methods_matching_inherit) - -## test_list_methods_matching_regexp() [](#method-i-test_list_methods_matching_regexp) - -## test_load_method() [](#method-i-test_load_method) - -## test_load_method_inherited() [](#method-i-test_load_method_inherited) - -## test_load_method_missing() [](#method-i-test_load_method_missing) - -## test_load_methods_matching() [](#method-i-test_load_methods_matching) - -## test_load_methods_matching_inherited() [](#method-i-test_load_methods_matching_inherited) - -## test_method_type() [](#method-i-test_method_type) - -## test_name_regexp() [](#method-i-test_name_regexp) - -## test_output_width() [](#method-i-test_output_width) - -## test_page() [](#method-i-test_page) - -## test_page_in_presence_of_child_status() [](#method-i-test_page_in_presence_of_child_status) - -## test_page_stdout() [](#method-i-test_page_stdout) - -## test_parse_name_method() [](#method-i-test_parse_name_method) - -## test_parse_name_namespace() [](#method-i-test_parse_name_namespace) - -## test_parse_name_page() [](#method-i-test_parse_name_page) - -## test_parse_name_page_extenson() [](#method-i-test_parse_name_page_extenson) - -## test_parse_name_single_class() [](#method-i-test_parse_name_single_class) - -## test_parse_name_special() [](#method-i-test_parse_name_special) - -## test_rdoc_refs_expansion_can_be_disabled() [](#method-i-test_rdoc_refs_expansion_can_be_disabled) - -## test_self_dump() [](#method-i-test_self_dump) - -## test_setup_pager() [](#method-i-test_setup_pager) -this test doesn't do anything anymore :( - -## util_ancestors_store() [](#method-i-util_ancestors_store) - -## util_multi_store() [](#method-i-util_multi_store) - -## util_store() [](#method-i-util_store) - -## with_dummy_pager() [](#method-i-with_dummy_pager) - diff --git a/example/ruby/RSpecExt.md b/example/ruby/RSpecExt.md deleted file mode 100644 index 0f1f3a5..0000000 --- a/example/ruby/RSpecExt.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: RSpecExt - - - - - -#Instance Methods -## handle_interrupt() [](#method-i-handle_interrupt) - diff --git a/example/ruby/Racc.md b/example/ruby/Racc.md deleted file mode 100644 index f19964e..0000000 --- a/example/ruby/Racc.md +++ /dev/null @@ -1,171 +0,0 @@ -# Module: Racc - - -Racc is an LALR(1) parser generator. It is written in Ruby itself, and -generates Ruby programs. - -## Command-line Reference - - racc [-ofilename] [--output-file=filename] - [-erubypath] [--executable=rubypath] - [-v] [--verbose] - [-Ofilename] [--log-file=filename] - [-g] [--debug] - [-E] [--embedded] - [-l] [--no-line-convert] - [-c] [--line-convert-all] - [-a] [--no-omit-actions] - [-C] [--check-only] - [-S] [--output-status] - [--version] [--copyright] [--help] grammarfile - -`grammarfile` -: Racc grammar file. Any extension is permitted. - --o+outfile+, --output-file=`outfile` -: A filename for output. default is <`filename`>.tab.rb - --O+filename+, --log-file=`filename` -: Place logging output in file `filename`. Default log file name is - <`filename`>.output. - --e+rubypath+, --executable=`rubypath` -: output executable file(mode 755). where `path` is the Ruby interpreter. - --v, --verbose -: verbose mode. create `filename`.output file, like yacc's y.output file. - --g, --debug -: add debug code to parser class. To display debugging information, use this - '-g' option and set @yydebug true in parser class. - --E, --embedded -: Output parser which doesn't need runtime files (racc/parser.rb). - --F, --frozen -: Output parser which declares frozen_string_literals: true - --C, --check-only -: Check syntax of racc grammar file and quit. - --S, --output-status -: Print messages time to time while compiling. - --l, --no-line-convert -: turns off line number converting. - --c, --line-convert-all -: Convert line number of actions, inner, header and footer. - --a, --no-omit-actions -: Call all actions, even if an action is empty. - ---version -: print Racc version and quit. - ---copyright -: Print copyright and quit. - ---help -: Print usage and quit. - - -## Generating Parser Using Racc - -To compile Racc grammar file, simply type: - - $ racc parse.y - -This creates Ruby script file "parse.tab.y". The -o option can change the -output filename. - -## Writing A Racc Grammar File - -If you want your own parser, you have to write a grammar file. A grammar file -contains the name of your parser class, grammar for the parser, user code, and -anything else. When writing a grammar file, yacc's knowledge is helpful. If -you have not used yacc before, Racc is not too difficult. - -Here's an example Racc grammar file. - - class Calcparser - rule - target: exp { print val[0] } - - exp: exp '+' exp - | exp '*' exp - | '(' exp ')' - | NUMBER - end - -Racc grammar files resemble yacc files. But (of course), this is Ruby code. -yacc's $$ is the 'result', $0, $1... is an array called 'val', and $-1, $-2... -is an array called '_values'. - -See the [Grammar File Reference](rdoc-ref:lib/racc/rdoc/grammar.en.rdoc) for -more information on grammar files. - -## Parser - -Then you must prepare the parse entry method. There are two types of parse -methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse - -Racc::Parser#do_parse is simple. - -It's yyparse() of yacc, and Racc::Parser#next_token is yylex(). This method -must returns an array like [TOKENSYMBOL, ITS_VALUE]. EOF is [false, false]. -(TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default. If you -want to change this, see the grammar reference. - -Racc::Parser#yyparse is little complicated, but useful. It does not use -Racc::Parser#next_token, instead it gets tokens from any iterator. - -For example, `yyparse(obj, :scan)` causes calling +obj#scan+, and you can -return tokens by yielding them from +obj#scan+. - -## Debugging - -When debugging, "-v" or/and the "-g" option is helpful. - -"-v" creates verbose log file (.output). "-g" creates a "Verbose Parser". -Verbose Parser prints the internal status when parsing. But it's *not* -automatic. You must use -g option and set +@yydebug+ to `true` in order to get -output. -g option only creates the verbose parser. - -### Racc reported syntax error. - -Isn't there too many "end"? grammar of racc file is changed in v0.10. - -Racc does not use '%' mark, while yacc uses huge number of '%' marks.. - -### Racc reported "XXXX conflicts". - -Try "racc -v xxxx.y". It causes producing racc's internal log file, -xxxx.output. - -### Generated parsers does not work correctly - -Try "racc -g xxxx.y". This command let racc generate "debugging parser". Then -set @yydebug=true in your parser. It produces a working log of your parser. - -## Re-distributing Racc runtime - -A parser, which is created by Racc, requires the Racc runtime module; -racc/parser.rb. - -Ruby 1.8.x comes with Racc runtime module, you need NOT distribute Racc -runtime files. - -If you want to include the Racc runtime module with your parser. This can be -done by using '-E' option: - - $ racc -E -omyparser.rb myparser.y - -This command creates myparser.rb which `includes' Racc runtime. Only you must -do is to distribute your parser file (myparser.rb). - -Note: parser.rb is ruby license, but your parser is not. Your own parser is -completely yours. - - - diff --git a/example/ruby/Racc/ParseError.md b/example/ruby/Racc/ParseError.md deleted file mode 100644 index 4fda229..0000000 --- a/example/ruby/Racc/ParseError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Racc::ParseError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Racc/Parser.md b/example/ruby/Racc/Parser.md deleted file mode 100644 index 4978b01..0000000 --- a/example/ruby/Racc/Parser.md +++ /dev/null @@ -1,83 +0,0 @@ -# Class: Racc::Parser -**Inherits:** Object - - - - -# Class Methods -## racc_runtime_type() [](#method-c-racc_runtime_type) -:nodoc: - -#Instance Methods -## _racc_do_parse_rb(arg, in_debug) [](#method-i-_racc_do_parse_rb) - -## _racc_do_reduce(arg, act) [](#method-i-_racc_do_reduce) - -## _racc_evalact(act, arg) [](#method-i-_racc_evalact) -common - -## _racc_init_sysvars() [](#method-i-_racc_init_sysvars) - -## _racc_setup() [](#method-i-_racc_setup) - -## _racc_yyparse_rb(recv, mid, arg, c_debug) [](#method-i-_racc_yyparse_rb) - -## next_token() [](#method-i-next_token) -The method to fetch next token. If you use #do_parse method, you must -implement #next_token. - -The format of return value is [TOKEN_SYMBOL, VALUE]. `token-symbol` is -represented by Ruby's symbol by default, e.g. :IDENT for 'IDENT'. ";" -(String) for ';'. - -The final symbol (End of file) must be false. - -**@raise** [NotImplementedError] - -## on_error(t, val, vstack) [](#method-i-on_error) -This method is called when a parse error is found. - -ERROR_TOKEN_ID is an internal ID of token which caused error. You can get -string representation of this ID by calling #token_to_str. - -ERROR_VALUE is a value of error token. - -value_stack is a stack of symbol values. DO NOT MODIFY this object. - -This method raises ParseError by default. - -If this method returns, parsers enter "error recovering mode". - -**@raise** [ParseError] - -## racc_accept() [](#method-i-racc_accept) - -## racc_e_pop(state, tstack, vstack) [](#method-i-racc_e_pop) - -## racc_next_state(curstate, state) [](#method-i-racc_next_state) - -## racc_print_stacks(t, v) [](#method-i-racc_print_stacks) - -## racc_print_states(s) [](#method-i-racc_print_states) - -## racc_read_token(t, tok, val) [](#method-i-racc_read_token) -For debugging output - -## racc_reduce(toks, sim, tstack, vstack) [](#method-i-racc_reduce) - -## racc_shift(tok, tstack, vstack) [](#method-i-racc_shift) - -## racc_token2str(tok) [](#method-i-racc_token2str) - -## token_to_str(t) [](#method-i-token_to_str) -Convert internal ID of token symbol to the string. - -## yyaccept() [](#method-i-yyaccept) -Exit parser. Return value is `Symbol_Value_Stack[0]`. - -## yyerrok() [](#method-i-yyerrok) -Leave error recovering mode. - -## yyerror() [](#method-i-yyerror) -Enter error recovering mode. This method does not call #on_error. - diff --git a/example/ruby/Ractor.md b/example/ruby/Ractor.md deleted file mode 100644 index 59ba71a..0000000 --- a/example/ruby/Ractor.md +++ /dev/null @@ -1,836 +0,0 @@ -# Class: Ractor -**Inherits:** Object - - -Ractor is an Actor-model abstraction for Ruby that provides thread-safe -parallel execution. - -Ractor.new makes a new Ractor, which can run in parallel. - - # The simplest ractor - r = Ractor.new {puts "I am in Ractor!"} - r.take # wait for it to finish - # Here, "I am in Ractor!" is printed - -Ractors do not share all objects with each other. There are two main benefits -to this: across ractors, thread-safety concerns such as data-races and -race-conditions are not possible. The other benefit is parallelism. - -To achieve this, object sharing is limited across ractors. For example, unlike -in threads, ractors can't access all the objects available in other ractors. -Even objects normally available through variables in the outer scope are -prohibited from being used across ractors. - - a = 1 - r = Ractor.new {puts "I am in Ractor! a=#{a}"} - # fails immediately with - # ArgumentError (can not isolate a Proc because it accesses outer variables (a).) - -The object must be explicitly shared: - a = 1 - r = Ractor.new(a) { |a1| puts "I am in Ractor! a=#{a1}"} - -On CRuby (the default implementation), Global Virtual Machine Lock (GVL) is -held per ractor, so ractors can perform in parallel without locking each -other. This is unlike the situation with threads on CRuby. - -Instead of accessing shared state, objects should be passed to and from -ractors by sending and receiving them as messages. - - a = 1 - r = Ractor.new do - a_in_ractor = receive # receive blocks until somebody passes a message - puts "I am in Ractor! a=#{a_in_ractor}" - end - r.send(a) # pass it - r.take - # Here, "I am in Ractor! a=1" is printed - -There are two pairs of methods for sending/receiving messages: - -* Ractor#send and Ractor.receive for when the *sender* knows the receiver - (push); -* Ractor.yield and Ractor#take for when the *receiver* knows the sender - (pull); - -In addition to that, any arguments passed to Ractor.new are passed to the -block and available there as if received by Ractor.receive, and the last block -value is sent outside of the ractor as if sent by Ractor.yield. - -A little demonstration of a classic ping-pong: - - server = Ractor.new(name: "server") do - puts "Server starts: #{self.inspect}" - puts "Server sends: ping" - Ractor.yield 'ping' # The server doesn't know the receiver and sends to whoever interested - received = Ractor.receive # The server doesn't know the sender and receives from whoever sent - puts "Server received: #{received}" - end - - client = Ractor.new(server) do |srv| # The server is sent to the client, and available as srv - puts "Client starts: #{self.inspect}" - received = srv.take # The client takes a message from the server - puts "Client received from " \ - "#{srv.inspect}: #{received}" - puts "Client sends to " \ - "#{srv.inspect}: pong" - srv.send 'pong' # The client sends a message to the server - end - - [client, server].each(&:take) # Wait until they both finish - -This will output something like: - - Server starts: # - Server sends: ping - Client starts: # - Client received from #: ping - Client sends to #: pong - Server received: pong - -Ractors receive their messages via the *incoming port*, and send them to the -*outgoing port*. Either one can be disabled with Ractor#close_incoming and -Ractor#close_outgoing, respectively. When a ractor terminates, its ports are -closed automatically. - -## Shareable and unshareable objects - -When an object is sent to and from a ractor, it's important to understand -whether the object is shareable or unshareable. Most Ruby objects are -unshareable objects. Even frozen objects can be unshareable if they contain -(through their instance variables) unfrozen objects. - -Shareable objects are those which can be used by several threads without -compromising thread-safety, for example numbers, `true` and `false`. -Ractor.shareable? allows you to check this, and Ractor.make_shareable tries to -make the object shareable if it's not already, and gives an error if it can't -do it. - - Ractor.shareable?(1) #=> true -- numbers and other immutable basic values are shareable - Ractor.shareable?('foo') #=> false, unless the string is frozen due to # frozen_string_literal: true - Ractor.shareable?('foo'.freeze) #=> true - Ractor.shareable?([Object.new].freeze) #=> false, inner object is unfrozen - - ary = ['hello', 'world'] - ary.frozen? #=> false - ary[0].frozen? #=> false - Ractor.make_shareable(ary) - ary.frozen? #=> true - ary[0].frozen? #=> true - ary[1].frozen? #=> true - -When a shareable object is sent (via #send or Ractor.yield), no additional -processing occurs on it. It just becomes usable by both ractors. When an -unshareable object is sent, it can be either *copied* or *moved*. The first is -the default, and it copies the object fully by deep cloning (Object#clone) the -non-shareable parts of its structure. - - data = ['foo', 'bar'.freeze] - r = Ractor.new do - data2 = Ractor.receive - puts "In ractor: #{data2.object_id}, #{data2[0].object_id}, #{data2[1].object_id}" - end - r.send(data) - r.take - puts "Outside : #{data.object_id}, #{data[0].object_id}, #{data[1].object_id}" - -This will output something like: - - In ractor: 340, 360, 320 - Outside : 380, 400, 320 - -Note that the object ids of the array and the non-frozen string inside the -array have changed in the ractor because they are different objects. The -second array's element, which is a shareable frozen string, is the same -object. - -Deep cloning of objects may be slow, and sometimes impossible. Alternatively, -`move: true` may be used during sending. This will *move* the unshareable -object to the receiving ractor, making it inaccessible to the sending ractor. - - data = ['foo', 'bar'] - r = Ractor.new do - data_in_ractor = Ractor.receive - puts "In ractor: #{data_in_ractor.object_id}, #{data_in_ractor[0].object_id}" - end - r.send(data, move: true) - r.take - puts "Outside: moved? #{Ractor::MovedObject === data}" - puts "Outside: #{data.inspect}" - -This will output: - - In ractor: 100, 120 - Outside: moved? true - test.rb:9:in `method_missing': can not send any methods to a moved object (Ractor::MovedError) - -Notice that even `inspect` (and more basic methods like `__id__`) is -inaccessible on a moved object. - -Class and Module objects are shareable so the class/module definitions are -shared between ractors. Ractor objects are also shareable. All operations on -shareable objects are thread-safe, so the thread-safety property will be kept. -We can not define mutable shareable objects in Ruby, but C extensions can -introduce them. - -It is prohibited to access (get) instance variables of shareable objects in -other ractors if the values of the variables aren't shareable. This can occur -because modules/classes are shareable, but they can have instance variables -whose values are not. In non-main ractors, it's also prohibited to set -instance variables on classes/modules (even if the value is shareable). - - class C - class << self - attr_accessor :tricky - end - end - - C.tricky = "unshareable".dup - - r = Ractor.new(C) do |cls| - puts "I see #{cls}" - puts "I can't see #{cls.tricky}" - cls.tricky = true # doesn't get here, but this would also raise an error - end - r.take - # I see C - # can not access instance variables of classes/modules from non-main Ractors (RuntimeError) - -Ractors can access constants if they are shareable. The main Ractor is the -only one that can access non-shareable constants. - - GOOD = 'good'.freeze - BAD = 'bad'.dup - - r = Ractor.new do - puts "GOOD=#{GOOD}" - puts "BAD=#{BAD}" - end - r.take - # GOOD=good - # can not access non-shareable objects in constant Object::BAD by non-main Ractor. (NameError) - - # Consider the same C class from above - - r = Ractor.new do - puts "I see #{C}" - puts "I can't see #{C.tricky}" - end - r.take - # I see C - # can not access instance variables of classes/modules from non-main Ractors (RuntimeError) - -See also the description of `# shareable_constant_value` pragma in [Comments -syntax](rdoc-ref:syntax/comments.rdoc) explanation. - -## Ractors vs threads - -Each ractor has its own main Thread. New threads can be created from inside -ractors (and, on CRuby, they share the GVL with other threads of this ractor). - - r = Ractor.new do - a = 1 - Thread.new {puts "Thread in ractor: a=#{a}"}.join - end - r.take - # Here "Thread in ractor: a=1" will be printed - -## Note on code examples - -In the examples below, sometimes we use the following method to wait for -ractors that are not currently blocked to finish (or to make progress). - - def wait - sleep(0.1) - end - -It is **only for demonstration purposes** and shouldn't be used in a real -code. Most of the time, #take is used to wait for ractors to finish. - -## Reference - -See [Ractor design doc](rdoc-ref:ractor.md) for more details. - - -# Class Methods -## [](sym ) [](#method-c-[]) -get a value from ractor-local storage of current Ractor -## []=(sym , val ) [](#method-c-[]=) -set a value in ractor-local storage of current Ractor -## _require(feature ) [](#method-c-_require) -internal method -## count() [](#method-c-count) -Returns the number of Ractors currently running or blocking (waiting). - - Ractor.count #=> 1 - r = Ractor.new(name: 'example') { Ractor.yield(1) } - Ractor.count #=> 2 (main + example ractor) - r.take # wait for Ractor.yield(1) - r.take # wait until r will finish - Ractor.count #=> 1 -## current() [](#method-c-current) -Returns the currently executing Ractor. - - Ractor.current #=> # -## main() [](#method-c-main) -returns main ractor -## main?() [](#method-c-main?) -return true if the current ractor is main ractor -**@return** [Boolean] - -## make_shareable(obj , copy: false) [](#method-c-make_shareable) -call-seq: - Ractor.make_shareable(obj, copy: false) -> shareable_obj - -Make `obj` shareable between ractors. - -`obj` and all the objects it refers to will be frozen, unless they are already -shareable. - -If `copy` keyword is `true`, it will copy objects before freezing them, and -will not modify `obj` or its internal objects. - -Note that the specification and implementation of this method are not mature -and may be changed in the future. - - obj = ['test'] - Ractor.shareable?(obj) #=> false - Ractor.make_shareable(obj) #=> ["test"] - Ractor.shareable?(obj) #=> true - obj.frozen? #=> true - obj[0].frozen? #=> true - - # Copy vs non-copy versions: - obj1 = ['test'] - obj1s = Ractor.make_shareable(obj1) - obj1.frozen? #=> true - obj1s.object_id == obj1.object_id #=> true - obj2 = ['test'] - obj2s = Ractor.make_shareable(obj2, copy: true) - obj2.frozen? #=> false - obj2s.frozen? #=> true - obj2s.object_id == obj2.object_id #=> false - obj2s[0].object_id == obj2[0].object_id #=> false - -See also the "Shareable and unshareable objects" section in the Ractor class -docs. -## new(*args , name: nil, &block ) [](#method-c-new) -call-seq: - Ractor.new(*args, name: nil) {|*args| block } -> ractor - -Create a new Ractor with args and a block. - -The given block (Proc) will be isolated (can't access any outer variables). -`self` inside the block will refer to the current Ractor. - - r = Ractor.new { puts "Hi, I am #{self.inspect}" } - r.take - # Prints "Hi, I am #" - -Any `args` passed are propagated to the block arguments by the same rules as -objects sent via #send/Ractor.receive. If an argument in `args` is not -shareable, it will be copied (via deep cloning, which might be inefficient). - - arg = [1, 2, 3] - puts "Passing: #{arg} (##{arg.object_id})" - r = Ractor.new(arg) {|received_arg| - puts "Received: #{received_arg} (##{received_arg.object_id})" - } - r.take - # Prints: - # Passing: [1, 2, 3] (#280) - # Received: [1, 2, 3] (#300) - -Ractor's `name` can be set for debugging purposes: - - r = Ractor.new(name: 'my ractor') {}; r.take - p r - #=> # -**@raise** [ArgumentError] - -## receive() [](#method-c-receive) -call-seq: - Ractor.receive -> msg - -Receive a message from the incoming port of the current ractor (which was sent -there by #send from another ractor). - - r = Ractor.new do - v1 = Ractor.receive - puts "Received: #{v1}" - end - r.send('message1') - r.take - # Here will be printed: "Received: message1" - -Alternatively, the private instance method `receive` may be used: - - r = Ractor.new do - v1 = receive - puts "Received: #{v1}" - end - r.send('message1') - r.take - # This prints: "Received: message1" - -The method blocks if the queue is empty. - - r = Ractor.new do - puts "Before first receive" - v1 = Ractor.receive - puts "Received: #{v1}" - v2 = Ractor.receive - puts "Received: #{v2}" - end - wait - puts "Still not received" - r.send('message1') - wait - puts "Still received only one" - r.send('message2') - r.take - -Output: - - Before first receive - Still not received - Received: message1 - Still received only one - Received: message2 - -If close_incoming was called on the ractor, the method raises -Ractor::ClosedError if there are no more messages in the incoming queue: - - Ractor.new do - close_incoming - receive - end - wait - # in `receive': The incoming port is already closed => # (Ractor::ClosedError) -## receive_if(&b ) [](#method-c-receive_if) -call-seq: - Ractor.receive_if {|msg| block } -> msg - -Receive only a specific message. - -Instead of Ractor.receive, Ractor.receive_if can be given a pattern (or any -filter) in a block and you can choose the messages to accept that are -available in your ractor's incoming queue. - - r = Ractor.new do - p Ractor.receive_if{|msg| msg.match?(/foo/)} #=> "foo3" - p Ractor.receive_if{|msg| msg.match?(/bar/)} #=> "bar1" - p Ractor.receive_if{|msg| msg.match?(/baz/)} #=> "baz2" - end - r << "bar1" - r << "baz2" - r << "foo3" - r.take - -This will output: - - foo3 - bar1 - baz2 - -If the block returns a truthy value, the message is removed from the incoming -queue and returned. Otherwise, the message remains in the incoming queue and -the next messages are checked by the given block. - -If there are no messages left in the incoming queue, the method will block -until new messages arrive. - -If the block is escaped by break/return/exception/throw, the message is -removed from the incoming queue as if a truthy value had been returned. - - r = Ractor.new do - val = Ractor.receive_if{|msg| msg.is_a?(Array)} - puts "Received successfully: #{val}" - end - - r.send(1) - r.send('test') - wait - puts "2 non-matching sent, nothing received" - r.send([1, 2, 3]) - wait - -Prints: - - 2 non-matching sent, nothing received - Received successfully: [1, 2, 3] - -Note that you can not call receive/receive_if in the given block recursively. -You should not do any tasks in the block other than message filtration. - - Ractor.current << true - Ractor.receive_if{|msg| Ractor.receive} - #=> `receive': can not call receive/receive_if recursively (Ractor::Error) -## recv() [](#method-c-recv) -call-seq: - Ractor.receive -> msg - -Receive a message from the incoming port of the current ractor (which was sent -there by #send from another ractor). - - r = Ractor.new do - v1 = Ractor.receive - puts "Received: #{v1}" - end - r.send('message1') - r.take - # Here will be printed: "Received: message1" - -Alternatively, the private instance method `receive` may be used: - - r = Ractor.new do - v1 = receive - puts "Received: #{v1}" - end - r.send('message1') - r.take - # This prints: "Received: message1" - -The method blocks if the queue is empty. - - r = Ractor.new do - puts "Before first receive" - v1 = Ractor.receive - puts "Received: #{v1}" - v2 = Ractor.receive - puts "Received: #{v2}" - end - wait - puts "Still not received" - r.send('message1') - wait - puts "Still received only one" - r.send('message2') - r.take - -Output: - - Before first receive - Still not received - Received: message1 - Still received only one - Received: message2 - -If close_incoming was called on the ractor, the method raises -Ractor::ClosedError if there are no more messages in the incoming queue: - - Ractor.new do - close_incoming - receive - end - wait - # in `receive': The incoming port is already closed => # (Ractor::ClosedError) -## select(*ractors , yield_value: yield_unspecified = true, move: false) [](#method-c-select) -call-seq: - Ractor.select(*ractors, [yield_value:, move: false]) -> [ractor or symbol, obj] - -Wait for any ractor to have something in its outgoing port, read from this -ractor, and then return that ractor and the object received. - - r1 = Ractor.new {Ractor.yield 'from 1'} - r2 = Ractor.new {Ractor.yield 'from 2'} - - r, obj = Ractor.select(r1, r2) - - puts "received #{obj.inspect} from #{r.inspect}" - # Prints: received "from 1" from # - # But could just as well print "from r2" here, either prints could be first. - -If one of the given ractors is the current ractor, and it is selected, `r` -will contain the `:receive` symbol instead of the ractor object. - - r1 = Ractor.new(Ractor.current) do |main| - main.send 'to main' - Ractor.yield 'from 1' - end - r2 = Ractor.new do - Ractor.yield 'from 2' - end - - r, obj = Ractor.select(r1, r2, Ractor.current) - puts "received #{obj.inspect} from #{r.inspect}" - # Could print: received "to main" from :receive - -If `yield_value` is provided, that value may be yielded if another ractor is -calling #take. In this case, the pair `[:yield, nil]` is returned: - - r1 = Ractor.new(Ractor.current) do |main| - puts "Received from main: #{main.take}" - end - - puts "Trying to select" - r, obj = Ractor.select(r1, Ractor.current, yield_value: 123) - wait - puts "Received #{obj.inspect} from #{r.inspect}" - -This will print: - - Trying to select - Received from main: 123 - Received nil from :yield - -`move` boolean flag defines whether yielded value will be copied (default) or -moved. -**@raise** [ArgumentError] - -## shareable?(obj ) [](#method-c-shareable?) -call-seq: - Ractor.shareable?(obj) -> true | false - -Checks if the object is shareable by ractors. - - Ractor.shareable?(1) #=> true -- numbers and other immutable basic values are frozen - Ractor.shareable?('foo') #=> false, unless the string is frozen due to # frozen_string_literal: true - Ractor.shareable?('foo'.freeze) #=> true - -See also the "Shareable and unshareable objects" section in the Ractor class -docs. -**@return** [Boolean] - -## store_if_absent(sym ) [](#method-c-store_if_absent) -call-seq: - Ractor.store_if_absent(key){ init_block } - -If the correponding value is not set, yield a value with init_block and store -the value in thread-safe manner. This method returns corresponding stored -value. - - (1..10).map{ - Thread.new(it){|i| - Ractor.store_if_absent(:s){ f(); i } - #=> return stored value of key :s - } - }.map(&:value).uniq.size #=> 1 and f() is called only once -## yield(obj , move: false) [](#method-c-yield) -call-seq: - Ractor.yield(msg, move: false) -> nil - -Send a message to the current ractor's outgoing port to be accepted by #take. - - r = Ractor.new {Ractor.yield 'Hello from ractor'} - puts r.take - # Prints: "Hello from ractor" - -This method is blocking, and will return only when somebody consumes the sent -message. - - r = Ractor.new do - Ractor.yield 'Hello from ractor' - puts "Ractor: after yield" - end - wait - puts "Still not taken" - puts r.take - -This will print: - - Still not taken - Hello from ractor - Ractor: after yield - -If the outgoing port was closed with #close_outgoing, the method will raise: - - r = Ractor.new do - close_outgoing - Ractor.yield 'Hello from ractor' - end - wait - # `yield': The outgoing-port is already closed (Ractor::ClosedError) - -The meaning of the `move` argument is the same as for #send. - -#Instance Methods -## [](sym) [](#method-i-[]) -get a value from ractor-local storage of current Ractor Obsolete and use -Ractor.[] instead. - -## []=(sym, val) [](#method-i-[]=) -set a value in ractor-local storage of current Ractor Obsolete and use -Ractor.[]= instead. - -## close_incoming() [](#method-i-close_incoming) -call-seq: - ractor.close_incoming -> true | false - -Closes the incoming port and returns whether it was already closed. All -further attempts to Ractor.receive in the ractor, and #send to the ractor will -fail with Ractor::ClosedError. - - r = Ractor.new {sleep(500)} - r.close_incoming #=> false - r.close_incoming #=> true - r.send('test') - # Ractor::ClosedError (The incoming-port is already closed) - -## close_outgoing() [](#method-i-close_outgoing) -call-seq: - ractor.close_outgoing -> true | false - -Closes the outgoing port and returns whether it was already closed. All -further attempts to Ractor.yield in the ractor, and #take from the ractor will -fail with Ractor::ClosedError. - - r = Ractor.new {sleep(500)} - r.close_outgoing #=> false - r.close_outgoing #=> true - r.take - # Ractor::ClosedError (The outgoing-port is already closed) - -## inspect() [](#method-i-inspect) - -## name() [](#method-i-name) -The name set in Ractor.new, or `nil`. - -## send(obj, move:false) [](#method-i-send) -call-seq: - ractor.send(msg, move: false) -> self - -Send a message to a Ractor's incoming queue to be accepted by Ractor.receive. - - r = Ractor.new do - value = Ractor.receive - puts "Received #{value}" - end - r.send 'message' - # Prints: "Received: message" - -The method is non-blocking (will return immediately even if the ractor is not -ready to receive anything): - - r = Ractor.new {sleep(5)} - r.send('test') - puts "Sent successfully" - # Prints: "Sent successfully" immediately - -An attempt to send to a ractor which already finished its execution will raise -Ractor::ClosedError. - - r = Ractor.new {} - r.take - p r - # "#" - r.send('test') - # Ractor::ClosedError (The incoming-port is already closed) - -If close_incoming was called on the ractor, the method also raises -Ractor::ClosedError. - - r = Ractor.new do - sleep(500) - receive - end - r.close_incoming - r.send('test') - # Ractor::ClosedError (The incoming-port is already closed) - # The error is raised immediately, not when the ractor tries to receive - -If the `obj` is unshareable, by default it will be copied into the receiving -ractor by deep cloning. If `move: true` is passed, the object is *moved* into -the receiving ractor and becomes inaccessible to the sender. - - r = Ractor.new {puts "Received: #{receive}"} - msg = 'message' - r.send(msg, move: true) - r.take - p msg - -This prints: - - Received: message - in `p': undefined method `inspect' for # - -All references to the object and its parts will become invalid to the sender. - - r = Ractor.new {puts "Received: #{receive}"} - s = 'message' - ary = [s] - copy = ary.dup - r.send(ary, move: true) - - s.inspect - # Ractor::MovedError (can not send any methods to a moved object) - ary.class - # Ractor::MovedError (can not send any methods to a moved object) - copy.class - # => Array, it is different object - copy[0].inspect - # Ractor::MovedError (can not send any methods to a moved object) - # ...but its item was still a reference to `s`, which was moved - -If the object is shareable, `move: true` has no effect on it: - - r = Ractor.new {puts "Received: #{receive}"} - s = 'message'.freeze - r.send(s, move: true) - s.inspect #=> "message", still available - -## take() [](#method-i-take) -call-seq: - ractor.take -> msg - -Get a message from the ractor's outgoing port, which was put there by -Ractor.yield or at ractor's termination. - - r = Ractor.new do - Ractor.yield 'explicit yield' - 'last value' - end - puts r.take #=> 'explicit yield' - puts r.take #=> 'last value' - puts r.take # Ractor::ClosedError (The outgoing-port is already closed) - -The fact that the last value is also sent to the outgoing port means that -`take` can be used as an analog of Thread#join ("just wait until ractor -finishes"). However, it will raise if somebody has already consumed that -message. - -If the outgoing port was closed with #close_outgoing, the method will raise -Ractor::ClosedError. - - r = Ractor.new do - sleep(500) - Ractor.yield 'Hello from ractor' - end - r.close_outgoing - r.take - # Ractor::ClosedError (The outgoing-port is already closed) - # The error would be raised immediately, not when ractor will try to receive - -If an uncaught exception is raised in the Ractor, it is propagated by take as -a Ractor::RemoteError. - - r = Ractor.new {raise "Something weird happened"} - - begin - r.take - rescue => e - p e # => # - p e.ractor == r # => true - p e.cause # => # - end - -Ractor::ClosedError is a descendant of StopIteration, so the termination of -the ractor will break out of any loops that receive this message without -propagating the error: - - r = Ractor.new do - 3.times {|i| Ractor.yield "message #{i}"} - "finishing" - end - - loop {puts "Received: " + r.take} - puts "Continue successfully" - -This will print: - - Received: message 0 - Received: message 1 - Received: message 2 - Received: finishing - Continue successfully - diff --git a/example/ruby/Ractor/ClosedError.md b/example/ruby/Ractor/ClosedError.md deleted file mode 100644 index 8ae393f..0000000 --- a/example/ruby/Ractor/ClosedError.md +++ /dev/null @@ -1,39 +0,0 @@ -# Exception: Ractor::ClosedError -**Inherits:** StopIteration - - -Raised when an attempt is made to send a message to a closed port, or to -retrieve a message from a closed and empty port. Ports may be closed -explicitly with Ractor#close_outgoing/close_incoming and are closed implicitly -when a Ractor terminates. - - r = Ractor.new { sleep(500) } - r.close_outgoing - r.take # Ractor::ClosedError - -ClosedError is a descendant of StopIteration, so the closing of the ractor -will break the loops without propagating the error: - - r = Ractor.new do - loop do - msg = receive # raises ClosedError and loop traps it - puts "Received: #{msg}" - end - puts "loop exited" - end - - 3.times{|i| r << i} - r.close_incoming - r.take - puts "Continue successfully" - -This will print: - - Received: 0 - Received: 1 - Received: 2 - loop exited - Continue successfully - - - diff --git a/example/ruby/Ractor/Error.md b/example/ruby/Ractor/Error.md deleted file mode 100644 index c409f2e..0000000 --- a/example/ruby/Ractor/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Ractor::Error -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/Ractor/IsolationError.md b/example/ruby/Ractor/IsolationError.md deleted file mode 100644 index f410f66..0000000 --- a/example/ruby/Ractor/IsolationError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Ractor::IsolationError -**Inherits:** Ractor::Error - - - - - diff --git a/example/ruby/Ractor/MovedError.md b/example/ruby/Ractor/MovedError.md deleted file mode 100644 index 887773d..0000000 --- a/example/ruby/Ractor/MovedError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Ractor::MovedError -**Inherits:** Ractor::Error - - -Raised on an attempt to access an object which was moved in Ractor#send or -Ractor.yield. - - r = Ractor.new { sleep } - - ary = [1, 2, 3] - r.send(ary, move: true) - ary.inspect - # Ractor::MovedError (can not send any methods to a moved object) - - - diff --git a/example/ruby/Ractor/MovedObject.md b/example/ruby/Ractor/MovedObject.md deleted file mode 100644 index 4cefe35..0000000 --- a/example/ruby/Ractor/MovedObject.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: Ractor::MovedObject -**Inherits:** BasicObject - - -A special object which replaces any value that was moved to another ractor in -Ractor#send or Ractor.yield. Any attempt to access the object results in -Ractor::MovedError. - - r = Ractor.new { receive } - - ary = [1, 2, 3] - r.send(ary, move: true) - p Ractor::MovedObject === ary - # => true - ary.inspect - # Ractor::MovedError (can not send any methods to a moved object) - - - -#Instance Methods -## !() [](#method-i-!) - -## !=() [](#method-i-!=) - -## ==() [](#method-i-==) - -## __id__() [](#method-i-__id__) - -## __send__() [](#method-i-__send__) -override methods defined in BasicObject - -## equal?() [](#method-i-equal?) - -**@return** [Boolean] - -## instance_eval() [](#method-i-instance_eval) - -## instance_exec() [](#method-i-instance_exec) - -## method_missing() [](#method-i-method_missing) - diff --git a/example/ruby/Ractor/RemoteError.md b/example/ruby/Ractor/RemoteError.md deleted file mode 100644 index caafcc0..0000000 --- a/example/ruby/Ractor/RemoteError.md +++ /dev/null @@ -1,24 +0,0 @@ -# Exception: Ractor::RemoteError -**Inherits:** Ractor::Error - - -Raised on attempt to Ractor#take if there was an uncaught exception in the -Ractor. Its `cause` will contain the original exception, and `ractor` is the -original ractor it was raised in. - - r = Ractor.new { raise "Something weird happened" } - - begin - r.take - rescue => e - p e # => # - p e.ractor == r # => true - p e.cause # => # - end - - -# Attributes -## ractor[RW] [](#attribute-i-ractor) -The Ractor an uncaught exception is raised in. - - diff --git a/example/ruby/Ractor/Selector.md b/example/ruby/Ractor/Selector.md deleted file mode 100644 index fd2337e..0000000 --- a/example/ruby/Ractor/Selector.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Ractor::Selector -**Inherits:** Object - - -:nodoc: currently - -Selects multiple Ractors to be activated. - - -# Class Methods -## new() [](#method-c-new) - -#Instance Methods -## _wait() [](#method-i-_wait) - -## add() [](#method-i-add) - -## clear() [](#method-i-clear) - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## remove() [](#method-i-remove) - -## wait() [](#method-i-wait) - diff --git a/example/ruby/Ractor/UnsafeError.md b/example/ruby/Ractor/UnsafeError.md deleted file mode 100644 index 12933e5..0000000 --- a/example/ruby/Ractor/UnsafeError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Ractor::UnsafeError -**Inherits:** Ractor::Error - - - - - diff --git a/example/ruby/RactorCompatibilityTest.md b/example/ruby/RactorCompatibilityTest.md deleted file mode 100644 index 1fb7e76..0000000 --- a/example/ruby/RactorCompatibilityTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: RactorCompatibilityTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_can_raise_other_name_error_in_ractor() [](#method-i-test_can_raise_other_name_error_in_ractor) - -## test_class_name_suggestion_works_in_ractor() [](#method-i-test_class_name_suggestion_works_in_ractor) - -## test_key_name_suggestion_works_in_ractor() [](#method-i-test_key_name_suggestion_works_in_ractor) - -## test_method_name_suggestion_works_in_ractor() [](#method-i-test_method_name_suggestion_works_in_ractor) - -## test_pattern_key_name_suggestion_works_in_ractor() [](#method-i-test_pattern_key_name_suggestion_works_in_ractor) - -## test_variable_name_suggestion_works_in_ractor() [](#method-i-test_variable_name_suggestion_works_in_ractor) - diff --git a/example/ruby/RactorLocalSingleton.md b/example/ruby/RactorLocalSingleton.md deleted file mode 100644 index e023bbe..0000000 --- a/example/ruby/RactorLocalSingleton.md +++ /dev/null @@ -1,28 +0,0 @@ -# Module: RactorLocalSingleton - -**Extended by:** Singleton::SingletonClassProperties - -**Includes:** Singleton::SingletonInstanceMethods - - - - -# Class Methods -## __init__(klass ) [](#method-c-__init__) -:nodoc: -## module_with_class_methods() [](#method-c-module_with_class_methods) - -#Instance Methods -## _dump(depth-1)) [](#method-i-_dump) -By default, do not retain any state when marshalling. - -## clone() [](#method-i-clone) -Raises a TypeError to prevent cloning. - -**@raise** [TypeError] - -## dup() [](#method-i-dup) -Raises a TypeError to prevent duping. - -**@raise** [TypeError] - diff --git a/example/ruby/RactorLocalSingleton/RactorLocalSingletonClassMethods.md b/example/ruby/RactorLocalSingleton/RactorLocalSingletonClassMethods.md deleted file mode 100644 index ab4ede6..0000000 --- a/example/ruby/RactorLocalSingleton/RactorLocalSingletonClassMethods.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: RactorLocalSingleton::RactorLocalSingletonClassMethods - -**Includes:** Singleton::SingletonClassMethods - - - - - -#Instance Methods -## _load(str) [](#method-i-_load) -By default calls instance(). Override to retain singleton state. - -## clone() [](#method-i-clone) -:nodoc: - -## instance() [](#method-i-instance) - diff --git a/example/ruby/RaiseErrorMatcher.md b/example/ruby/RaiseErrorMatcher.md deleted file mode 100644 index e9fe7e5..0000000 --- a/example/ruby/RaiseErrorMatcher.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: RaiseErrorMatcher -**Inherits:** Object - - - - -# Attributes -## block=[R] [](#attribute-i-block=) -Sets the attribute block - -**@param** [] the value to set the attribute block to. - - -#Instance Methods -## exception_class_and_message(exception_class, message) [](#method-i-exception_class_and_message) - -## failure_message() [](#method-i-failure_message) - -## format_exception(exception) [](#method-i-format_exception) - -## format_expected_exception() [](#method-i-format_expected_exception) - -## initialize(exception, message, &block) [](#method-i-initialize) - -**@return** [RaiseErrorMatcher] a new instance of RaiseErrorMatcher - -## matches?(proc) [](#method-i-matches?) -This #matches? method is unusual because it doesn't always return a boolean -but instead re-raises the original exception if proc.call raises an exception -and #matching_exception? is false. The reasoning is the original exception -class matters and we don't want to change it by raising another exception, so -instead we attach the #failure_message and extract it in -ExceptionState#message. - -**@return** [Boolean] - -## matching_class?(exc) [](#method-i-matching_class?) - -**@return** [Boolean] - -## matching_exception?(exc) [](#method-i-matching_exception?) - -**@return** [Boolean] - -## matching_message?(exc) [](#method-i-matching_message?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/Rake.md b/example/ruby/Rake.md deleted file mode 100644 index 4169b35..0000000 --- a/example/ruby/Rake.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Rake - - -:stopdoc: - - - diff --git a/example/ruby/Rake/ExtensionTask.md b/example/ruby/Rake/ExtensionTask.md deleted file mode 100644 index f07c176..0000000 --- a/example/ruby/Rake/ExtensionTask.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Rake::ExtensionTask -**Inherits:** TaskLib - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ExtensionTask] a new instance of ExtensionTask - diff --git a/example/ruby/Random.md b/example/ruby/Random.md deleted file mode 100644 index c76f2b8..0000000 --- a/example/ruby/Random.md +++ /dev/null @@ -1,185 +0,0 @@ -# Class: Random - - -Random provides an interface to Ruby's pseudo-random number generator, or -PRNG. The PRNG produces a deterministic sequence of bits which approximate -true randomness. The sequence may be represented by integers, floats, or -binary strings. - -The generator may be initialized with either a system-generated or -user-supplied seed value by using Random.srand. - -The class method Random.rand provides the base functionality of Kernel.rand -along with better handling of floating point values. These are both interfaces -to the Ruby system PRNG. - -Random.new will create a new PRNG with a state independent of the Ruby system -PRNG, allowing multiple generators with different seed values or sequence -positions to exist simultaneously. Random objects can be marshaled, allowing -sequences to be saved and resumed. - -PRNGs are currently implemented as a modified Mersenne Twister with a period -of 2**19937-1. As this algorithm is *not* for cryptographical use, you must -use SecureRandom for security purpose, instead of this PRNG. - -See also Random::Formatter module that adds convenience methods to generate -various forms of random data. - - -# Class Methods -## bytes(len ) [](#method-c-bytes) -Returns a random binary string. The argument `size` specifies the length of -the returned string. -**@overload** [] - -## new_seed() [](#method-c-new_seed) -Returns an arbitrary seed value. This is used by Random.new when no seed value -is specified as an argument. - - Random.new_seed #=> 115032730400174366788466674494640623225 -**@overload** [] - -## rand(*args ) [](#method-c-rand) -Returns a random number using the Ruby system PRNG. - -See also Random#rand. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## seed() [](#method-c-seed) -Returns the seed value used to initialize the Ruby system PRNG. This may be -used to initialize another generator with the same state at a later time, -causing it to produce the same sequence of numbers. - - Random.seed #=> 1234 - prng1 = Random.new(Random.seed) - prng1.seed #=> 1234 - prng1.rand(100) #=> 47 - Random.seed #=> 1234 - Random.rand(100) #=> 47 -**@overload** [] - -## srand(*args ) [](#method-c-srand) -Seeds the system pseudo-random number generator, with `number`. The previous -seed value is returned. - -If `number` is omitted, seeds the generator using a source of entropy provided -by the operating system, if available (/dev/urandom on Unix systems or the RSA -cryptographic provider on Windows), which is then combined with the time, the -process id, and a sequence number. - -srand may be used to ensure repeatable sequences of pseudo-random numbers -between different runs of the program. By setting the seed to a known value, -programs can be made deterministic during testing. - - srand 1234 # => 268519324636777531569100071560086917274 - [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] - [ rand(10), rand(1000) ] # => [4, 664] - srand 1234 # => 1234 - [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] -**@overload** [] - -## urandom(size ) [](#method-c-urandom) -Returns a string, using platform providing features. Returned value is -expected to be a cryptographically secure pseudo-random number in binary form. -This method raises a RuntimeError if the feature provided by platform failed -to prepare the result. - -In 2017, Linux manpage random(7) writes that "no cryptographic primitive -available today can hope to promise more than 256 bits of security". So it -might be questionable to pass size > 32 to this method. - - Random.urandom(8) #=> "\x78\x41\xBA\xAF\x7D\xEA\xD8\xEA" -**@overload** [] - - -#Instance Methods -## ==(other) [](#method-i-==) -Returns true if the two generators have the same internal state, otherwise -false. Equivalent generators will return the same sequence of pseudo-random -numbers. Two generators will generally have the same state only if they were -initialized with the same seed - - Random.new == Random.new # => false - Random.new(1234) == Random.new(1234) # => true - -and have the same invocation history. - - prng1 = Random.new(1234) - prng2 = Random.new(1234) - prng1 == prng2 # => true - - prng1.rand # => 0.1915194503788923 - prng1 == prng2 # => false - - prng2.rand # => 0.1915194503788923 - prng1 == prng2 # => true - -**@overload** [] - -## bytes(len) [](#method-i-bytes) -Returns a random binary string containing `size` bytes. - - random_string = Random.new.bytes(10) # => "\xD7:R\xAB?\x83\xCE\xFAkO" - random_string.size # => 10 - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new PRNG using `seed` to set the initial state. If `seed` is -omitted, the generator is initialized with Random.new_seed. - -See Random.srand for more information on the use of seed values. - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## rand(*args) [](#method-i-rand) -When `max` is an Integer, `rand` returns a random integer greater than or -equal to zero and less than `max`. Unlike Kernel.rand, when `max` is a -negative integer or zero, `rand` raises an ArgumentError. - - prng = Random.new - prng.rand(100) # => 42 - -When `max` is a Float, `rand` returns a random floating point number between -0.0 and `max`, including 0.0 and excluding `max`. - - prng.rand(1.5) # => 1.4600282860034115 - -When `range` is a Range, `rand` returns a random number where -`range.member?(number) == true`. - - prng.rand(5..9) # => one of [5, 6, 7, 8, 9] - prng.rand(5...9) # => one of [5, 6, 7, 8] - prng.rand(5.0..9.0) # => between 5.0 and 9.0, including 9.0 - prng.rand(5.0...9.0) # => between 5.0 and 9.0, excluding 9.0 - -Both the beginning and ending values of the range must respond to subtract -(`-`) and add (`+`)methods, or rand will raise an ArgumentError. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## seed() [](#method-i-seed) -Returns the seed value used to initialize the generator. This may be used to -initialize another generator with the same state at a later time, causing it -to produce the same sequence of numbers. - - prng1 = Random.new(1234) - prng1.seed #=> 1234 - prng1.rand(100) #=> 47 - - prng2 = Random.new(prng1.seed) - prng2.rand(100) #=> 47 - -**@overload** [] - diff --git a/example/ruby/Random/Formatter.md b/example/ruby/Random/Formatter.md deleted file mode 100644 index 428190f..0000000 --- a/example/ruby/Random/Formatter.md +++ /dev/null @@ -1,280 +0,0 @@ -# Module: Random::Formatter - - -## Random number formatter. - -Formats generated random numbers in many manners. When `'random/formatter'` is -required, several methods are added to empty core module `Random::Formatter`, -making them available as Random's instance and module methods. - -Standard library SecureRandom is also extended with the module, and the -methods described below are available as a module methods in it. - -### Examples - -Generate random hexadecimal strings: - - require 'random/formatter' - - prng = Random.new - prng.hex(10) #=> "52750b30ffbc7de3b362" - prng.hex(10) #=> "92b15d6c8dc4beb5f559" - prng.hex(13) #=> "39b290146bea6ce975c37cfc23" - # or just - Random.hex #=> "1aed0c631e41be7f77365415541052ee" - -Generate random base64 strings: - - prng.base64(10) #=> "EcmTPZwWRAozdA==" - prng.base64(10) #=> "KO1nIU+p9DKxGg==" - prng.base64(12) #=> "7kJSM/MzBJI+75j8" - Random.base64(4) #=> "bsQ3fQ==" - -Generate random binary strings: - - prng.random_bytes(10) #=> "\016\t{\370g\310pbr\301" - prng.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337" - Random.random_bytes(6) #=> "\xA1\xE6Lr\xC43" - -Generate alphanumeric strings: - - prng.alphanumeric(10) #=> "S8baxMJnPl" - prng.alphanumeric(10) #=> "aOxAg8BAJe" - Random.alphanumeric #=> "TmP9OsJHJLtaZYhP" - -Generate UUIDs: - - prng.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594" - prng.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab" - Random.uuid #=> "f14e0271-de96-45cc-8911-8910292a42cd" - -All methods are available in the standard library SecureRandom, too: - - SecureRandom.hex #=> "05b45376a30c67238eb93b16499e50cf" - - - -#Instance Methods -## alphanumeric(nnil, chars:ALPHANUMERIC) [](#method-i-alphanumeric) -Generate a random alphanumeric string. - -The argument *n* specifies the length, in characters, of the alphanumeric -string to be generated. The argument *chars* specifies the character list -which the result is consist of. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain A-Z, a-z and 0-9, unless *chars* is specified. - - require 'random/formatter' - - Random.alphanumeric #=> "2BuBuLf3WfSKyQbR" - # or - prng = Random.new - prng.alphanumeric(10) #=> "i6K93NdqiH" - - Random.alphanumeric(4, chars: [*"0".."9"]) #=> "2952" - # or - prng = Random.new - prng.alphanumeric(10, chars: [*"!".."/"]) #=> ",.,++%/''." - -## base64(nnil) [](#method-i-base64) -Generate a random base64 string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the result string is about 4/3 of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain A-Z, a-z, 0-9, "+", "/" and "=". - - require 'random/formatter' - - Random.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A==" - # or - prng = Random.new - prng.base64 #=> "6BbW0pxO0YENxn38HMUbcQ==" - -See RFC 3548 for the definition of base64. - -## hex(nnil) [](#method-i-hex) -Generate a random hexadecimal string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the resulting hexadecimal string is twice of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain 0-9 and a-f. - - require 'random/formatter' - - Random.hex #=> "eb693ec8252cd630102fd0d0fb7c3485" - # or - prng = Random.new - prng.hex #=> "91dc3bfb4de5b11d029d376634589b61" - -## rand(*args) [](#method-i-rand) -Generates formatted random number from raw random bytes. See Random#rand. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## random_bytes(nnil) [](#method-i-random_bytes) -Generate a random binary string. - -The argument *n* specifies the length of the result string. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in future. - -The result may contain any byte: "x00" - "xff". - - require 'random/formatter' - - Random.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6" - # or - prng = Random.new - prng.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97" - -## random_number(*args) [](#method-i-random_number) -Generates formatted random number from raw random bytes. See Random#rand. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## urlsafe_base64(nnil, paddingfalse) [](#method-i-urlsafe_base64) -Generate a random URL-safe base64 string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the result string is about 4/3 of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The boolean argument *padding* specifies the padding. If it is false or nil, -padding is not generated. Otherwise padding is generated. By default, padding -is not generated because "=" may be used as a URL delimiter. - -The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if -*padding* is true. - - require 'random/formatter' - - Random.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg" - # or - prng = Random.new - prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg" - - prng.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ==" - prng.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg==" - -See RFC 3548 for the definition of URL-safe base64. - -## uuid() [](#method-i-uuid) -Generate a random v4 UUID (Universally Unique IDentifier). - - require 'random/formatter' - - Random.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594" - Random.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab" - # or - prng = Random.new - prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b" - -The version 4 UUID is purely random (except the version). It doesn't contain -meaningful information such as MAC addresses, timestamps, etc. - -The result contains 122 random bits (15.25 random bytes). - -See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv4. - -## uuid_v7(extra_timestamp_bits:0) [](#method-i-uuid_v7) -Generate a random v7 UUID (Universally Unique IDentifier). - - require 'random/formatter' - - Random.uuid_v7 # => "0188d4c3-1311-7f96-85c7-242a7aa58f1e" - Random.uuid_v7 # => "0188d4c3-16fe-744f-86af-38fa04c62bb5" - Random.uuid_v7 # => "0188d4c3-1af8-764f-b049-c204ce0afa23" - Random.uuid_v7 # => "0188d4c3-1e74-7085-b14f-ef6415dc6f31" - # |<--sorted-->| |<----- random ---->| - - # or - prng = Random.new - prng.uuid_v7 # => "0188ca51-5e72-7950-a11d-def7ff977c98" - -The version 7 UUID starts with the least significant 48 bits of a 64 bit Unix -timestamp (milliseconds since the epoch) and fills the remaining bits with -random data, excluding the version and variant bits. - -This allows version 7 UUIDs to be sorted by creation time. Time ordered UUIDs -can be used for better database index locality of newly inserted records, -which may have a significant performance benefit compared to random data -inserts. - -The result contains 74 random bits (9.25 random bytes). - -Note that this method cannot be made reproducible because its output includes -not only random bits but also timestamp. - -See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv7. - -#### Monotonicity - -UUIDv7 has millisecond precision by default, so multiple UUIDs created within -the same millisecond are not issued in monotonically increasing order. To -create UUIDs that are time-ordered with sub-millisecond precision, up to 12 -bits of additional timestamp may added with `extra_timestamp_bits`. The extra -timestamp precision comes at the expense of random bits. Setting -`extra_timestamp_bits: 12` provides ~244ns of precision, but only 62 random -bits (7.75 random bytes). - - prng = Random.new - Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 12) } - # => - ["0188d4c7-13da-74f9-8b53-22a786ffdd5a", - "0188d4c7-13da-753b-83a5-7fb9b2afaeea", - "0188d4c7-13da-754a-88ea-ac0baeedd8db", - "0188d4c7-13da-7557-83e1-7cad9cda0d8d"] - # |<--- sorted --->| |<-- random --->| - - Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 8) } - # => - ["0188d4c7-3333-7a95-850a-de6edb858f7e", - "0188d4c7-3333-7ae8-842e-bc3a8b7d0cf9", # <- out of order - "0188d4c7-3333-7ae2-995a-9f135dc44ead", # <- out of order - "0188d4c7-3333-7af9-87c3-8f612edac82e"] - # |<--- sorted -->||<---- random --->| - -Any rollbacks of the system clock will break monotonicity. UUIDv7 is based on -UTC, which excludes leap seconds and can rollback the clock. To avoid this, -the system clock can synchronize with an NTP server configured to use a "leap -smear" approach. NTP or PTP will also be needed to synchronize across -distributed nodes. - -Counters and other mechanisms for stronger guarantees of monotonicity are not -implemented. Applications with stricter requirements should follow [Section -6.2](https://www.rfc-editor.org/rfc/rfc9562.html#name-monotonicity-and-counter -s) of the specification. - diff --git a/example/ruby/Random/Formatter/FormatterTest.md b/example/ruby/Random/Formatter/FormatterTest.md deleted file mode 100644 index c18fd67..0000000 --- a/example/ruby/Random/Formatter/FormatterTest.md +++ /dev/null @@ -1,41 +0,0 @@ -# Module: Random::Formatter::FormatterTest - - - - - -#Instance Methods -## assert_in_range(range, result, mesgnil) [](#method-i-assert_in_range) - -## assert_uuid_v7(**opts) [](#method-i-assert_uuid_v7) - -## current_uuid7_time(extra_timestamp_bits:0) [](#method-i-current_uuid7_time) -It would be nice to simply use Time#floor here. But that is problematic due -to the difference between decimal vs binary fractions. - -## get_uuid7_time(uuid, extra_timestamp_bits:0) [](#method-i-get_uuid7_time) - -## test_alphanumeric() [](#method-i-test_alphanumeric) - -## test_alphanumeric_chars() [](#method-i-test_alphanumeric_chars) - -## test_base64() [](#method-i-test_base64) - -## test_hex() [](#method-i-test_hex) - -## test_hex_encoding() [](#method-i-test_hex_encoding) - -## test_random_bytes() [](#method-i-test_random_bytes) - -## test_random_number_float() [](#method-i-test_random_number_float) - -## test_random_number_float_by_zero() [](#method-i-test_random_number_float_by_zero) - -## test_random_number_int() [](#method-i-test_random_number_int) - -## test_urlsafe_base64() [](#method-i-test_urlsafe_base64) - -## test_uuid() [](#method-i-test_uuid) - -## test_uuid_v7() [](#method-i-test_uuid_v7) - diff --git a/example/ruby/Random/Formatter/NotDefaultTest.md b/example/ruby/Random/Formatter/NotDefaultTest.md deleted file mode 100644 index f67cf6a..0000000 --- a/example/ruby/Random/Formatter/NotDefaultTest.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Random::Formatter::NotDefaultTest - - - - - -#Instance Methods -## test_random_number_not_default() [](#method-i-test_random_number_not_default) - diff --git a/example/ruby/Random/Formatter/TestClassMethods.md b/example/ruby/Random/Formatter/TestClassMethods.md deleted file mode 100644 index cc9da22..0000000 --- a/example/ruby/Random/Formatter/TestClassMethods.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Random::Formatter::TestClassMethods -**Inherits:** Test::Unit::TestCase - -**Includes:** Random::Formatter::FormatterTest - - - - - -#Instance Methods -## assert_in_range(range, result, mesgnil) [](#method-i-assert_in_range) - -## assert_uuid_v7(**opts) [](#method-i-assert_uuid_v7) - -## current_uuid7_time(extra_timestamp_bits:0) [](#method-i-current_uuid7_time) -It would be nice to simply use Time#floor here. But that is problematic due -to the difference between decimal vs binary fractions. - -## get_uuid7_time(uuid, extra_timestamp_bits:0) [](#method-i-get_uuid7_time) - -## setup() [](#method-i-setup) - -## test_alphanumeric() [](#method-i-test_alphanumeric) - -## test_alphanumeric_chars() [](#method-i-test_alphanumeric_chars) - -## test_alphanumeric_frozen() [](#method-i-test_alphanumeric_frozen) - -## test_base64() [](#method-i-test_base64) - -## test_hex() [](#method-i-test_hex) - -## test_hex_encoding() [](#method-i-test_hex_encoding) - -## test_random_bytes() [](#method-i-test_random_bytes) - -## test_random_number_float() [](#method-i-test_random_number_float) - -## test_random_number_float_by_zero() [](#method-i-test_random_number_float_by_zero) - -## test_random_number_int() [](#method-i-test_random_number_int) - -## test_urlsafe_base64() [](#method-i-test_urlsafe_base64) - -## test_uuid() [](#method-i-test_uuid) - -## test_uuid_v7() [](#method-i-test_uuid_v7) - diff --git a/example/ruby/Random/Formatter/TestInstanceMethods.md b/example/ruby/Random/Formatter/TestInstanceMethods.md deleted file mode 100644 index 42208f7..0000000 --- a/example/ruby/Random/Formatter/TestInstanceMethods.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Random::Formatter::TestInstanceMethods -**Inherits:** Test::Unit::TestCase - -**Includes:** Random::Formatter::FormatterTest, Random::Formatter::NotDefaultTest - - - - - -#Instance Methods -## assert_in_range(range, result, mesgnil) [](#method-i-assert_in_range) - -## assert_uuid_v7(**opts) [](#method-i-assert_uuid_v7) - -## current_uuid7_time(extra_timestamp_bits:0) [](#method-i-current_uuid7_time) -It would be nice to simply use Time#floor here. But that is problematic due -to the difference between decimal vs binary fractions. - -## get_uuid7_time(uuid, extra_timestamp_bits:0) [](#method-i-get_uuid7_time) - -## setup() [](#method-i-setup) - -## test_alphanumeric() [](#method-i-test_alphanumeric) - -## test_alphanumeric_chars() [](#method-i-test_alphanumeric_chars) - -## test_base64() [](#method-i-test_base64) - -## test_hex() [](#method-i-test_hex) - -## test_hex_encoding() [](#method-i-test_hex_encoding) - -## test_random_bytes() [](#method-i-test_random_bytes) - -## test_random_number_float() [](#method-i-test_random_number_float) - -## test_random_number_float_by_zero() [](#method-i-test_random_number_float_by_zero) - -## test_random_number_int() [](#method-i-test_random_number_int) - -## test_random_number_not_default() [](#method-i-test_random_number_not_default) - -## test_urlsafe_base64() [](#method-i-test_urlsafe_base64) - -## test_uuid() [](#method-i-test_uuid) - -## test_uuid_v7() [](#method-i-test_uuid_v7) - diff --git a/example/ruby/RandomSpecs.md b/example/ruby/RandomSpecs.md deleted file mode 100644 index 05aa924..0000000 --- a/example/ruby/RandomSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: RandomSpecs - - - - - diff --git a/example/ruby/RandomSpecs/CustomRangeFloat.md b/example/ruby/RandomSpecs/CustomRangeFloat.md deleted file mode 100644 index b545e0a..0000000 --- a/example/ruby/RandomSpecs/CustomRangeFloat.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: RandomSpecs::CustomRangeFloat -**Inherits:** Struct - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value - -**@return** [Object] the current value of value - - -#Instance Methods -## +(other) [](#method-i-+) - -## -(other) [](#method-i--) - -## <=>(other) [](#method-i-<=>) - -## to_f() [](#method-i-to_f) - diff --git a/example/ruby/RandomSpecs/CustomRangeInteger.md b/example/ruby/RandomSpecs/CustomRangeInteger.md deleted file mode 100644 index 665b414..0000000 --- a/example/ruby/RandomSpecs/CustomRangeInteger.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: RandomSpecs::CustomRangeInteger -**Inherits:** Struct - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value - -**@return** [Object] the current value of value - - -#Instance Methods -## +(other) [](#method-i-+) - -## -(other) [](#method-i--) - -## <=>(other) [](#method-i-<=>) - -## to_int() [](#method-i-to_int) - diff --git a/example/ruby/Range.md b/example/ruby/Range.md deleted file mode 100644 index 539a649..0000000 --- a/example/ruby/Range.md +++ /dev/null @@ -1,2744 +0,0 @@ -# Class: Range -**Inherits:** Object - -**Includes:** Enumerable - - -:nodoc: - - -# Class Methods -## json_create(object ) [](#method-c-json_create) -See #as_json. - -#Instance Methods -## %(step) [](#method-i-%) -Same as #step (but doesn't provide default value for `n`). The method is -convenient for experssive producing of Enumerator::ArithmeticSequence. - - array = [0, 1, 2, 3, 4, 5, 6] - - # slice each second element: - seq = (0..) % 2 #=> ((0..).%(2)) - array[seq] #=> [0, 2, 4, 6] - # or just - array[(0..) % 2] #=> [0, 2, 4, 6] - -Note that due to operator precedence in Ruby, parentheses are mandatory around -range in this case: - - (0..7) % 2 #=> ((0..7).%(2)) -- as expected - 0..7 % 2 #=> 0..1 -- parsed as 0..(7 % 2) - -**@overload** [] - -**@overload** [] - -## ==(obj) [](#method-i-==) -Returns `true` if and only if: - -* `other` is a range. -* `other.begin == self.begin`. -* `other.end == self.end`. -* `other.exclude_end? == self.exclude_end?`. - -Otherwise returns `false`. - - r = (1..5) - r == (1..5) # => true - r = Range.new(1, 5) - r == 'foo' # => false - r == (2..5) # => false - r == (1..4) # => false - r == (1...5) # => false - r == Range.new(1, 5, true) # => false - -Note that even with the same argument, the return values of #== and #eql? can -differ: - - (1..2) == (1..2.0) # => true - (1..2).eql? (1..2.0) # => false - -Related: Range#eql?. - -**@overload** [] - -## ===(val) [](#method-i-===) -Returns `true` if `object` is between `self.begin` and `self.end`. `false` -otherwise: - - (1..4) === 2 # => true - (1..4) === 5 # => false - (1..4) === 'a' # => false - (1..4) === 4 # => true - (1...4) === 4 # => false - ('a'..'d') === 'c' # => true - ('a'..'d') === 'e' # => false - -A case statement uses method `===`, and so: - - case 79 - when (1..50) - "low" - when (51..75) - "medium" - when (76..100) - "high" - end # => "high" - - case "2.6.5" - when ..."2.4" - "EOL" - when "2.4"..."2.5" - "maintenance" - when "2.5"..."3.0" - "stable" - when "3.1".. - "upcoming" - end # => "stable" - -**@overload** [] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Range#as_json` and `Range.json_create` may be used to serialize and -deserialize a Range object; see [Marshal](rdoc-ref:Marshal). - -Method `Range#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/range' - x = (1..4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, false]} - y = (1...4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, true]} - z = ('a'..'d').as_json # => {"json_class"=>"Range", "a"=>["a", "d", false]} - -Method `JSON.create` deserializes such a hash, returning a Range object: - - Range.json_create(x) # => 1..4 - Range.json_create(y) # => 1...4 - Range.json_create(z) # => "a".."d" - -## begin() [](#method-i-begin) -Returns the object that defines the beginning of `self`. - - (1..4).begin # => 1 - (..2).begin # => nil - -Related: Range#first, Range#end. - -**@overload** [] - -## bsearch() [](#method-i-bsearch) -Returns an element from `self` selected by a binary search. - -See [Binary Searching](rdoc-ref:bsearch.rdoc). - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - (1..4).count # => 4 - (1...4).count # => 3 - ('a'..'d').count # => 4 - ('a'...'d').count # => 3 - (1..).count # => Infinity - (..4).count # => Infinity - -With argument `object`, returns the number of `object` found in `self`, which -will usually be zero or one: - - (1..4).count(2) # => 1 - (1..4).count(5) # => 0 - (1..4).count('a') # => 0 - -With a block given, calls the block with each element; returns the number of -elements for which the block returns a truthy value: - - (1..4).count {|element| element < 3 } # => 2 - -Related: Range#size. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cover?(val) [](#method-i-cover?) -Returns `true` if the given argument is within `self`, `false` otherwise. - -With non-range argument `object`, evaluates with `<=` and `<`. - -For range `self` with included end value (`#exclude_end? == false`), evaluates -thus: - - self.begin <= object <= self.end - -Examples: - - r = (1..4) - r.cover?(1) # => true - r.cover?(4) # => true - r.cover?(0) # => false - r.cover?(5) # => false - r.cover?('foo') # => false - - r = ('a'..'d') - r.cover?('a') # => true - r.cover?('d') # => true - r.cover?(' ') # => false - r.cover?('e') # => false - r.cover?(0) # => false - -For range `r` with excluded end value (`#exclude_end? == true`), evaluates -thus: - - r.begin <= object < r.end - -Examples: - - r = (1...4) - r.cover?(1) # => true - r.cover?(3) # => true - r.cover?(0) # => false - r.cover?(4) # => false - r.cover?('foo') # => false - - r = ('a'...'d') - r.cover?('a') # => true - r.cover?('c') # => true - r.cover?(' ') # => false - r.cover?('d') # => false - r.cover?(0) # => false - -With range argument `range`, compares the first and last elements of `self` -and `range`: - - r = (1..4) - r.cover?(1..4) # => true - r.cover?(0..4) # => false - r.cover?(1..5) # => false - r.cover?('a'..'d') # => false - - r = (1...4) - r.cover?(1..3) # => true - r.cover?(1..4) # => false - -If begin and end are numeric, #cover? behaves like #include? - - (1..3).cover?(1.5) # => true - (1..3).include?(1.5) # => true - -But when not numeric, the two methods may differ: - - ('a'..'d').cover?('cc') # => true - ('a'..'d').include?('cc') # => false - -Returns `false` if either: - -* The begin value of `self` is larger than its end value. -* An internal call to `#<=>` returns `nil`; that is, the operands are not - comparable. - -Beginless ranges cover all values of the same type before the end, excluding -the end for exclusive ranges. Beginless ranges cover ranges that end before -the end of the beginless range, or at the end of the beginless range for -inclusive ranges. - - (..2).cover?(1) # => true - (..2).cover?(2) # => true - (..2).cover?(3) # => false - (...2).cover?(2) # => false - (..2).cover?("2") # => false - (..2).cover?(..2) # => true - (..2).cover?(...2) # => true - (..2).cover?(.."2") # => false - (...2).cover?(..2) # => false - -Endless ranges cover all values of the same type after the beginning. Endless -exclusive ranges do not cover endless inclusive ranges. - - (2..).cover?(1) # => false - (2..).cover?(3) # => true - (2...).cover?(3) # => true - (2..).cover?(2) # => true - (2..).cover?("2") # => false - (2..).cover?(2..) # => true - (2..).cover?(2...) # => true - (2..).cover?("2"..) # => false - (2...).cover?(2..) # => false - (2...).cover?(3...) # => true - (2...).cover?(3..) # => false - (3..).cover?(2..) # => false - -Ranges that are both beginless and endless cover all values and ranges, and -return true for all arguments, with the exception that beginless and endless -exclusive ranges do not cover endless inclusive ranges. - - (nil...).cover?(Object.new) # => true - (nil...).cover?(nil...) # => true - (nil..).cover?(nil...) # => true - (nil...).cover?(nil..) # => false - (nil...).cover?(1..) # => false - -Related: Range#include?. - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -With a block given, passes each element of `self` to the block: - - a = [] - (1..4).each {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - -Raises an exception unless `self.first.respond_to?(:succ)`. - -With no block given, returns an enumerator. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## end() [](#method-i-end) -Returns the object that defines the end of `self`. - - (1..4).end # => 4 - (1...4).end # => 4 - (1..).end # => nil - -Related: Range#begin, Range#last. - -**@overload** [] - -## entries() [](#method-i-entries) -Returns an array containing the elements in `self`, if a finite collection; -raises an exception otherwise. - - (1..4).to_a # => [1, 2, 3, 4] - (1...4).to_a # => [1, 2, 3] - ('a'..'d').to_a # => ["a", "b", "c", "d"] - -**@overload** [] - -## eql?(obj) [](#method-i-eql?) -Returns `true` if and only if: - -* `other` is a range. -* `other.begin.eql?(self.begin)`. -* `other.end.eql?(self.end)`. -* `other.exclude_end? == self.exclude_end?`. - -Otherwise returns `false`. - - r = (1..5) - r.eql?(1..5) # => true - r = Range.new(1, 5) - r.eql?('foo') # => false - r.eql?(2..5) # => false - r.eql?(1..4) # => false - r.eql?(1...5) # => false - r.eql?(Range.new(1, 5, true)) # => false - -Note that even with the same argument, the return values of #== and #eql? can -differ: - - (1..2) == (1..2.0) # => true - (1..2).eql? (1..2.0) # => false - -Related: Range#==. - -**@overload** [] - -## exclude_end?() [](#method-i-exclude_end?) -Returns `true` if `self` excludes its end value; `false` otherwise: - - Range.new(2, 5).exclude_end? # => false - Range.new(2, 5, true).exclude_end? # => true - (2..5).exclude_end? # => false - (2...5).exclude_end? # => true - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -With no argument, returns the first element of `self`, if it exists: - - (1..4).first # => 1 - ('a'..'d').first # => "a" - -With non-negative integer argument `n` given, returns the first `n` elements -in an array: - - (1..10).first(3) # => [1, 2, 3] - (1..10).first(0) # => [] - (1..4).first(50) # => [1, 2, 3, 4] - -Raises an exception if there is no first element: - - (..4).first # Raises RangeError - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -Returns the integer hash value for `self`. Two range objects `r0` and `r1` -have the same hash value if and only if `r0.eql?(r1)`. - -Related: Range#eql?, Object#hash. - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns `true` if `object` is an element of `self`, `false` otherwise: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?(4) # => true - (1...4).include?(4) # => false - ('a'..'d').include?('b') # => true - ('a'..'d').include?('e') # => false - ('a'..'d').include?('B') # => false - ('a'..'d').include?('d') # => true - ('a'...'d').include?('d') # => false - -If begin and end are numeric, #include? behaves like #cover? - - (1..3).include?(1.5) # => true - (1..3).cover?(1.5) # => true - -But when not numeric, the two methods may differ: - - ('a'..'d').include?('cc') # => false - ('a'..'d').cover?('cc') # => true - -Related: Range#cover?. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Returns a new range based on the given objects `begin` and `end`. Optional -argument `exclude_end` determines whether object `end` is included as the last -object in the range: - - Range.new(2, 5).to_a # => [2, 3, 4, 5] - Range.new(2, 5, true).to_a # => [2, 3, 4] - Range.new('a', 'd').to_a # => ["a", "b", "c", "d"] - Range.new('a', 'd', true).to_a # => ["a", "b", "c"] - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`, including `begin.inspect` and -`end.inspect`: - - (1..4).inspect # => "1..4" - (1...4).inspect # => "1...4" - (1..).inspect # => "1.." - (..4).inspect # => "..4" - -Note that returns from #to_s and #inspect may differ: - - ('a'..'d').to_s # => "a..d" - ('a'..'d').inspect # => "\"a\"..\"d\"" - -Related: Range#to_s. - -**@overload** [] - -## last(*args) [](#method-i-last) -With no argument, returns the last element of `self`, if it exists: - - (1..4).last # => 4 - ('a'..'d').last # => "d" - -Note that `last` with no argument returns the end element of `self` even if -#exclude_end? is `true`: - - (1...4).last # => 4 - ('a'...'d').last # => "d" - -With non-negative integer argument `n` given, returns the last `n` elements in -an array: - - (1..10).last(3) # => [8, 9, 10] - (1..10).last(0) # => [] - (1..4).last(50) # => [1, 2, 3, 4] - -Note that `last` with argument does not return the end element of `self` if -#exclude_end? it `true`: - - (1...4).last(3) # => [1, 2, 3] - ('a'...'d').last(3) # => ["a", "b", "c"] - -Raises an exception if there is no last element: - - (1..).last # Raises RangeError - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the maximum value in `self`, using method `#<=>` or a given block for -comparison. - -With no argument and no block given, returns the maximum-valued element of -`self`. - - (1..4).max # => 4 - ('a'..'d').max # => "d" - (-4..-1).max # => -1 - -With non-negative integer argument `n` given, and no block given, returns the -`n` maximum-valued elements of `self` in an array: - - (1..4).max(2) # => [4, 3] - ('a'..'d').max(2) # => ["d", "c"] - (-4..-1).max(2) # => [-1, -2] - (1..4).max(50) # => [4, 3, 2, 1] - -If a block is given, it is called: - -* First, with the first two element of `self`. -* Then, sequentially, with the so-far maximum value and the next element of - `self`. - -To illustrate: - - (1..4).max {|a, b| p [a, b]; a <=> b } # => 4 - -Output: - - [2, 1] - [3, 2] - [4, 3] - -With no argument and a block given, returns the return value of the last call -to the block: - - (1..4).max {|a, b| -(a <=> b) } # => 1 - -With non-negative integer argument `n` given, and a block given, returns the -return values of the last `n` calls to the block in an array: - - (1..4).max(2) {|a, b| -(a <=> b) } # => [1, 2] - (1..4).max(50) {|a, b| -(a <=> b) } # => [1, 2, 3, 4] - -Returns an empty array if `n` is zero: - - (1..4).max(0) # => [] - (1..4).max(0) {|a, b| -(a <=> b) } # => [] - -Returns `nil` or an empty array if: - -* The begin value of the range is larger than the end value: - - (4..1).max # => nil - (4..1).max(2) # => [] - (4..1).max {|a, b| -(a <=> b) } # => nil - (4..1).max(2) {|a, b| -(a <=> b) } # => [] - -* The begin value of an exclusive range is equal to the end value: - - (1...1).max # => nil - (1...1).max(2) # => [] - (1...1).max {|a, b| -(a <=> b) } # => nil - (1...1).max(2) {|a, b| -(a <=> b) } # => [] - -Raises an exception if either: - -* `self` is a endless range: `(1..)`. -* A block is given and `self` is a beginless range. - -Related: Range#min, Range#minmax. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns `true` if `object` is an element of `self`, `false` otherwise: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?(4) # => true - (1...4).include?(4) # => false - ('a'..'d').include?('b') # => true - ('a'..'d').include?('e') # => false - ('a'..'d').include?('B') # => false - ('a'..'d').include?('d') # => true - ('a'...'d').include?('d') # => false - -If begin and end are numeric, #include? behaves like #cover? - - (1..3).include?(1.5) # => true - (1..3).cover?(1.5) # => true - -But when not numeric, the two methods may differ: - - ('a'..'d').include?('cc') # => false - ('a'..'d').cover?('cc') # => true - -Related: Range#cover?. - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the minimum value in `self`, using method `#<=>` or a given block for -comparison. - -With no argument and no block given, returns the minimum-valued element of -`self`. - - (1..4).min # => 1 - ('a'..'d').min # => "a" - (-4..-1).min # => -4 - -With non-negative integer argument `n` given, and no block given, returns the -`n` minimum-valued elements of `self` in an array: - - (1..4).min(2) # => [1, 2] - ('a'..'d').min(2) # => ["a", "b"] - (-4..-1).min(2) # => [-4, -3] - (1..4).min(50) # => [1, 2, 3, 4] - -If a block is given, it is called: - -* First, with the first two element of `self`. -* Then, sequentially, with the so-far minimum value and the next element of - `self`. - -To illustrate: - - (1..4).min {|a, b| p [a, b]; a <=> b } # => 1 - -Output: - - [2, 1] - [3, 1] - [4, 1] - -With no argument and a block given, returns the return value of the last call -to the block: - - (1..4).min {|a, b| -(a <=> b) } # => 4 - -With non-negative integer argument `n` given, and a block given, returns the -return values of the last `n` calls to the block in an array: - - (1..4).min(2) {|a, b| -(a <=> b) } # => [4, 3] - (1..4).min(50) {|a, b| -(a <=> b) } # => [4, 3, 2, 1] - -Returns an empty array if `n` is zero: - - (1..4).min(0) # => [] - (1..4).min(0) {|a, b| -(a <=> b) } # => [] - -Returns `nil` or an empty array if: - -* The begin value of the range is larger than the end value: - - (4..1).min # => nil - (4..1).min(2) # => [] - (4..1).min {|a, b| -(a <=> b) } # => nil - (4..1).min(2) {|a, b| -(a <=> b) } # => [] - -* The begin value of an exclusive range is equal to the end value: - - (1...1).min # => nil - (1...1).min(2) # => [] - (1...1).min {|a, b| -(a <=> b) } # => nil - (1...1).min(2) {|a, b| -(a <=> b) } # => [] - -Raises an exception if either: - -* `self` is a beginless range: `(..4)`. -* A block is given and `self` is an endless range. - -Related: Range#max, Range#minmax. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum value in `self`, -either according to comparison method `#<=>` or a given block. - -With no block given, returns the minimum and maximum values, using `#<=>` for -comparison: - - (1..4).minmax # => [1, 4] - (1...4).minmax # => [1, 3] - ('a'..'d').minmax # => ["a", "d"] - (-4..-1).minmax # => [-4, -1] - -With a block given, the block must return an integer: - -* Negative if `a` is smaller than `b`. -* Zero if `a` and `b` are equal. -* Positive if `a` is larger than `b`. - -The block is called `self.size` times to compare elements; returns a 2-element -Array containing the minimum and maximum values from `self`, per the block: - - (1..4).minmax {|a, b| -(a <=> b) } # => [4, 1] - -Returns `[nil, nil]` if: - -* The begin value of the range is larger than the end value: - - (4..1).minmax # => [nil, nil] - (4..1).minmax {|a, b| -(a <=> b) } # => [nil, nil] - -* The begin value of an exclusive range is equal to the end value: - - (1...1).minmax # => [nil, nil] - (1...1).minmax {|a, b| -(a <=> b) } # => [nil, nil] - -Raises an exception if `self` is a beginless or an endless range. - -Related: Range#min, Range#max. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## overlap?(other) [](#method-i-overlap?) -Returns `true` if `range` overlaps with `self`, `false` otherwise: - - (0..2).overlap?(1..3) #=> true - (0..2).overlap?(3..4) #=> false - (0..).overlap?(..0) #=> true - -With non-range argument, raises TypeError. - - (1..3).overlap?(1) # TypeError - -Returns `false` if an internal call to `#<=>` returns `nil`; that is, the -operands are not comparable. - - (1..3).overlap?('a'..'d') # => false - -Returns `false` if `self` or `range` is empty. "Empty range" means that its -begin value is larger than, or equal for an exclusive range, its end value. - - (4..1).overlap?(2..3) # => false - (4..1).overlap?(..3) # => false - (4..1).overlap?(2..) # => false - (2...2).overlap?(1..2) # => false - - (1..4).overlap?(3..2) # => false - (..4).overlap?(3..2) # => false - (1..).overlap?(3..2) # => false - (1..2).overlap?(2...2) # => false - -Returns `false` if the begin value one of `self` and `range` is larger than, -or equal if the other is an exclusive range, the end value of the other: - - (4..5).overlap?(2..3) # => false - (4..5).overlap?(2...4) # => false - - (1..2).overlap?(3..4) # => false - (1...3).overlap?(3..4) # => false - -Returns `false` if the end value one of `self` and `range` is larger than, or -equal for an exclusive range, the end value of the other: - - (4..5).overlap?(2..3) # => false - (4..5).overlap?(2...4) # => false - - (1..2).overlap?(3..4) # => false - (1...3).overlap?(3..4) # => false - -Note that the method wouldn't make any assumptions about the beginless range -being actually empty, even if its upper bound is the minimum possible value of -its type, so all this would return `true`: - - (...-Float::INFINITY).overlap?(...-Float::INFINITY) # => true - (..."").overlap?(..."") # => true - (...[]).overlap?(...[]) # => true - -Even if those ranges are effectively empty (no number can be smaller than -`-Float::INFINITY`), they are still considered overlapping with themselves. - -Related: Range#cover?. - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each() [](#method-i-reverse_each) -With a block given, passes each element of `self` to the block in reverse -order: - - a = [] - (1..4).reverse_each {|element| a.push(element) } # => 1..4 - a # => [4, 3, 2, 1] - - a = [] - (1...4).reverse_each {|element| a.push(element) } # => 1...4 - a # => [3, 2, 1] - -With no block given, returns an enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) -Returns the count of elements in `self` if both begin and end values are -numeric; otherwise, returns `nil`: - - (1..4).size # => 4 - (1...4).size # => 3 - (1..).size # => Infinity - ('a'..'z').size # => nil - -If `self` is not iterable, raises an exception: - - (0.5..2.5).size # TypeError - (..1).size # TypeError - -Related: Range#count. - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## step(*args) [](#method-i-step) -Iterates over the elements of range in steps of `s`. The iteration is -performed by `+` operator: - - (0..6).step(2) { puts _1 } #=> 1..5 - # Prints: 0, 2, 4, 6 - - # Iterate between two dates in step of 1 day (24 hours) - (Time.utc(2022, 2, 24)..Time.utc(2022, 3, 1)).step(24*60*60) { puts _1 } - # Prints: - # 2022-02-24 00:00:00 UTC - # 2022-02-25 00:00:00 UTC - # 2022-02-26 00:00:00 UTC - # 2022-02-27 00:00:00 UTC - # 2022-02-28 00:00:00 UTC - # 2022-03-01 00:00:00 UTC - -If ` + step` decreases the value, iteration is still performed when step -`begin` is higher than the `end`: - - (0..6).step(-2) { puts _1 } - # Prints nothing - - (6..0).step(-2) { puts _1 } - # Prints: 6, 4, 2, 0 - - (Time.utc(2022, 3, 1)..Time.utc(2022, 2, 24)).step(-24*60*60) { puts _1 } - # Prints: - # 2022-03-01 00:00:00 UTC - # 2022-02-28 00:00:00 UTC - # 2022-02-27 00:00:00 UTC - # 2022-02-26 00:00:00 UTC - # 2022-02-25 00:00:00 UTC - # 2022-02-24 00:00:00 UTC - -When the block is not provided, and range boundaries and step are Numeric, the -method returns Enumerator::ArithmeticSequence. - - (1..5).step(2) # => ((1..5).step(2)) - (1.0..).step(1.5) #=> ((1.0..).step(1.5)) - (..3r).step(1/3r) #=> ((..3/1).step((1/3))) - -Enumerator::ArithmeticSequence can be further used as a value object for -iteration or slicing of collections (see Array#[]). There is a convenience -method #% with behavior similar to `step` to produce arithmetic sequences more -expressively: - - # Same as (1..5).step(2) - (1..5) % 2 # => ((1..5).%(2)) - -In a generic case, when the block is not provided, Enumerator is returned: - - ('a'..).step('b') #=> # - ('a'..).step('b').take(3) #=> ["a", "ab", "abb"] - -If `s` is not provided, it is considered `1` for ranges with numeric `begin`: - - (1..5).step { p _1 } - # Prints: 1, 2, 3, 4, 5 - -For non-Numeric ranges, step absence is an error: - - (Time.utc(2022, 3, 1)..Time.utc(2022, 2, 24)).step { p _1 } - # raises: step is required for non-numeric ranges (ArgumentError) - -For backward compatibility reasons, String ranges support the iteration both -with string step and with integer step. In the latter case, the iteration is -performed by calculating the next values with String#succ: - - ('a'..'e').step(2) { p _1 } - # Prints: a, c, e - ('a'..'e').step { p _1 } - # Default step 1; prints: a, b, c, d, e - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) -Returns an array containing the elements in `self`, if a finite collection; -raises an exception otherwise. - - (1..4).to_a # => [1, 2, 3, 4] - (1...4).to_a # => [1, 2, 3] - ('a'..'d').to_a # => ["a", "b", "c", "d"] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/range' - puts (1..4).to_json - puts (1...4).to_json - puts ('a'..'d').to_json - -Output: - - {"json_class":"Range","a":[1,4,false]} - {"json_class":"Range","a":[1,4,true]} - {"json_class":"Range","a":["a","d",false]} - -## to_s() [](#method-i-to_s) -Returns a string representation of `self`, including `begin.to_s` and -`end.to_s`: - - (1..4).to_s # => "1..4" - (1...4).to_s # => "1...4" - (1..).to_s # => "1.." - (..4).to_s # => "..4" - -Note that returns from #to_s and #inspect may differ: - - ('a'..'d').to_s # => "a..d" - ('a'..'d').inspect # => "\"a\"..\"d\"" - -Related: Range#inspect. - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/RangeError.md b/example/ruby/RangeError.md deleted file mode 100644 index 8dc3f08..0000000 --- a/example/ruby/RangeError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: RangeError -**Inherits:** StandardError - - -Raised when a given numerical value is out of range. - - [1, 2, 3].drop(1 << 100) - -*raises the exception:* - - RangeError: bignum too big to convert into `long' - - - diff --git a/example/ruby/RangeSpecs.md b/example/ruby/RangeSpecs.md deleted file mode 100644 index 7d9cf14..0000000 --- a/example/ruby/RangeSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: RangeSpecs - - - - - diff --git a/example/ruby/RangeSpecs/ComparisonError.md b/example/ruby/RangeSpecs/ComparisonError.md deleted file mode 100644 index 302fab1..0000000 --- a/example/ruby/RangeSpecs/ComparisonError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: RangeSpecs::ComparisonError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/RangeSpecs/Custom.md b/example/ruby/RangeSpecs/Custom.md deleted file mode 100644 index 948e3e9..0000000 --- a/example/ruby/RangeSpecs/Custom.md +++ /dev/null @@ -1,104 +0,0 @@ -# Class: RangeSpecs::Custom -**Inherits:** Object - -**Includes:** Comparable - - -Custom Range classes Xs and Ys - - -# Attributes -## length[RW] [](#attribute-i-length) -Returns the value of attribute length. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## initialize(n) [](#method-i-initialize) - -**@return** [Custom] a new instance of Custom - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/RangeSpecs/MyRange.md b/example/ruby/RangeSpecs/MyRange.md deleted file mode 100644 index 196b1c6..0000000 --- a/example/ruby/RangeSpecs/MyRange.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: RangeSpecs::MyRange -**Inherits:** Range - - - - - diff --git a/example/ruby/RangeSpecs/TenfoldSucc.md b/example/ruby/RangeSpecs/TenfoldSucc.md deleted file mode 100644 index b35ded0..0000000 --- a/example/ruby/RangeSpecs/TenfoldSucc.md +++ /dev/null @@ -1,105 +0,0 @@ -# Class: RangeSpecs::TenfoldSucc -**Inherits:** Object - -**Includes:** Comparable - - - - -# Attributes -## n[RW] [](#attribute-i-n) -Returns the value of attribute n. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## initialize(n) [](#method-i-initialize) - -**@return** [TenfoldSucc] a new instance of TenfoldSucc - -## succ() [](#method-i-succ) - diff --git a/example/ruby/RangeSpecs/WithoutSucc.md b/example/ruby/RangeSpecs/WithoutSucc.md deleted file mode 100644 index 864cb60..0000000 --- a/example/ruby/RangeSpecs/WithoutSucc.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: RangeSpecs::WithoutSucc -**Inherits:** Object - -**Includes:** Comparable - - - - -# Attributes -## n[RW] [](#attribute-i-n) -Returns the value of attribute n. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## initialize(n) [](#method-i-initialize) - -**@return** [WithoutSucc] a new instance of WithoutSucc - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/RangeSpecs/Xs.md b/example/ruby/RangeSpecs/Xs.md deleted file mode 100644 index 09601a6..0000000 --- a/example/ruby/RangeSpecs/Xs.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: RangeSpecs::Xs -**Inherits:** RangeSpecs::Custom - - -represent a string of 'x's - - - -#Instance Methods -## inspect() [](#method-i-inspect) - -## succ() [](#method-i-succ) - diff --git a/example/ruby/RangeSpecs/Ys.md b/example/ruby/RangeSpecs/Ys.md deleted file mode 100644 index 6fe7984..0000000 --- a/example/ruby/RangeSpecs/Ys.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: RangeSpecs::Ys -**Inherits:** RangeSpecs::Custom - - -represent a string of 'y's - - - -#Instance Methods -## inspect() [](#method-i-inspect) - -## succ() [](#method-i-succ) - diff --git a/example/ruby/Rational.md b/example/ruby/Rational.md deleted file mode 100644 index bb60913..0000000 --- a/example/ruby/Rational.md +++ /dev/null @@ -1,401 +0,0 @@ -# Class: Rational -**Inherits:** Numeric - - -A rational number can be represented as a pair of integer numbers: a/b (b>0), -where a is the numerator and b is the denominator. Integer a equals rational -a/1 mathematically. - -You can create a Rational object explicitly with: - -* A [rational literal](rdoc-ref:syntax/literals.rdoc@Rational+Literals). - -You can convert certain objects to Rationals with: - -* Method #Rational. - -Examples - - Rational(1) #=> (1/1) - Rational(2, 3) #=> (2/3) - Rational(4, -6) #=> (-2/3) # Reduced. - 3.to_r #=> (3/1) - 2/3r #=> (2/3) - -You can also create rational objects from floating-point numbers or strings. - - Rational(0.3) #=> (5404319552844595/18014398509481984) - Rational('0.3') #=> (3/10) - Rational('2/3') #=> (2/3) - - 0.3.to_r #=> (5404319552844595/18014398509481984) - '0.3'.to_r #=> (3/10) - '2/3'.to_r #=> (2/3) - 0.3.rationalize #=> (3/10) - -A rational object is an exact number, which helps you to write programs -without any rounding errors. - - 10.times.inject(0) {|t| t + 0.1 } #=> 0.9999999999999999 - 10.times.inject(0) {|t| t + Rational('0.1') } #=> (1/1) - -However, when an expression includes an inexact component (numerical value or -operation), it will produce an inexact result. - - Rational(10) / 3 #=> (10/3) - Rational(10) / 3.0 #=> 3.3333333333333335 - - Rational(-8) ** Rational(1, 3) - #=> (1.0000000000000002+1.7320508075688772i) - - -# Class Methods -## json_create(object ) [](#method-c-json_create) -See #as_json. - -#Instance Methods -## *(other) [](#method-i-*) -Performs multiplication. - - Rational(2, 3) * Rational(2, 3) #=> (4/9) - Rational(900) * Rational(1) #=> (900/1) - Rational(-2, 9) * Rational(-9, 2) #=> (1/1) - Rational(9, 8) * 4 #=> (9/2) - Rational(20, 9) * 9.8 #=> 21.77777777777778 - -**@overload** [] - -## **() [](#method-i-**) - -## +(other) [](#method-i-+) -Performs addition. - - Rational(2, 3) + Rational(2, 3) #=> (4/3) - Rational(900) + Rational(1) #=> (901/1) - Rational(-2, 9) + Rational(-9, 2) #=> (-85/18) - Rational(9, 8) + 4 #=> (41/8) - Rational(20, 9) + 9.8 #=> 12.022222222222222 - -**@overload** [] - -## -(other) [](#method-i--) -Performs subtraction. - - Rational(2, 3) - Rational(2, 3) #=> (0/1) - Rational(900) - Rational(1) #=> (899/1) - Rational(-2, 9) - Rational(-9, 2) #=> (77/18) - Rational(9, 8) - 4 #=> (-23/8) - Rational(20, 9) - 9.8 #=> -7.577777777777778 - -**@overload** [] - -## -@() [](#method-i--@) -Negates `rat`. - -**@overload** [] - -## /(other) [](#method-i-/) -Performs division. - - Rational(2, 3) / Rational(2, 3) #=> (1/1) - Rational(900) / Rational(1) #=> (900/1) - Rational(-2, 9) / Rational(-9, 2) #=> (4/81) - Rational(9, 8) / 4 #=> (9/32) - Rational(20, 9) / 9.8 #=> 0.22675736961451246 - -**@overload** [] - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -Returns -1, 0, or +1 depending on whether `rational` is less than, equal to, -or greater than `numeric`. - -`nil` is returned if the two values are incomparable. - - Rational(2, 3) <=> Rational(2, 3) #=> 0 - Rational(5) <=> 5 #=> 0 - Rational(2, 3) <=> Rational(1, 3) #=> 1 - Rational(1, 3) <=> 1 #=> -1 - Rational(1, 3) <=> 0.3 #=> 1 - - Rational(1, 3) <=> "0.3" #=> nil - -**@overload** [] - -## ==(other) [](#method-i-==) -Returns `true` if `rat` equals `object` numerically. - - Rational(2, 3) == Rational(2, 3) #=> true - Rational(5) == 5 #=> true - Rational(0) == 0.0 #=> true - Rational('1/3') == 0.33 #=> false - Rational('1/2') == '1/2' #=> false - -**@overload** [] - -## abs() [](#method-i-abs) -Returns the absolute value of `rat`. - - (1/2r).abs #=> (1/2) - (-1/2r).abs #=> (1/2) - -**@overload** [] - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Rational#as_json` and `Rational.json_create` may be used to serialize -and deserialize a Rational object; see [Marshal](rdoc-ref:Marshal). - -Method `Rational#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/rational' - x = Rational(2, 3).as_json - # => {"json_class"=>"Rational", "n"=>2, "d"=>3} - -Method `JSON.create` deserializes such a hash, returning a Rational object: - - Rational.json_create(x) - # => (2/3) - -## ceil(*args) [](#method-i-ceil) -Returns the smallest number greater than or equal to `rat` with a precision of -`ndigits` decimal digits (default: 0). - -When the precision is negative, the returned value is an integer with at least -`ndigits.abs` trailing zeros. - -Returns a rational when `ndigits` is positive, otherwise returns an integer. - - Rational(3).ceil #=> 3 - Rational(2, 3).ceil #=> 1 - Rational(-3, 2).ceil #=> -1 - - # decimal - 1 2 3 . 4 5 6 - # ^ ^ ^ ^ ^ ^ - # precision -3 -2 -1 0 +1 +2 - - Rational('-123.456').ceil(+1).to_f #=> -123.4 - Rational('-123.456').ceil(-1) #=> -120 - -**@overload** [] - -## coerce(other) [](#method-i-coerce) -:nodoc: - -## denominator() [](#method-i-denominator) -Returns the denominator (always positive). - - Rational(7).denominator #=> 1 - Rational(7, 1).denominator #=> 1 - Rational(9, -4).denominator #=> 4 - Rational(-2, -10).denominator #=> 5 - -**@overload** [] - -## fdiv(other) [](#method-i-fdiv) -Performs division and returns the value as a Float. - - Rational(2, 3).fdiv(1) #=> 0.6666666666666666 - Rational(2, 3).fdiv(0.5) #=> 1.3333333333333333 - Rational(2).fdiv(3) #=> 0.6666666666666666 - -**@overload** [] - -## floor(*args) [](#method-i-floor) -Returns the largest number less than or equal to `rat` with a precision of -`ndigits` decimal digits (default: 0). - -When the precision is negative, the returned value is an integer with at least -`ndigits.abs` trailing zeros. - -Returns a rational when `ndigits` is positive, otherwise returns an integer. - - Rational(3).floor #=> 3 - Rational(2, 3).floor #=> 0 - Rational(-3, 2).floor #=> -2 - - # decimal - 1 2 3 . 4 5 6 - # ^ ^ ^ ^ ^ ^ - # precision -3 -2 -1 0 +1 +2 - - Rational('-123.456').floor(+1).to_f #=> -123.5 - Rational('-123.456').floor(-1) #=> -130 - -**@overload** [] - -## hash() [](#method-i-hash) - -## inspect() [](#method-i-inspect) -Returns the value as a string for inspection. - - Rational(2).inspect #=> "(2/1)" - Rational(-8, 6).inspect #=> "(-4/3)" - Rational('1/2').inspect #=> "(1/2)" - -**@overload** [] - -## magnitude() [](#method-i-magnitude) -Returns the absolute value of `rat`. - - (1/2r).abs #=> (1/2) - (-1/2r).abs #=> (1/2) - -**@overload** [] - -**@overload** [] - -## negative?() [](#method-i-negative?) -Returns `true` if `rat` is less than 0. - -**@overload** [] - -## numerator() [](#method-i-numerator) -Returns the numerator. - - Rational(7).numerator #=> 7 - Rational(7, 1).numerator #=> 7 - Rational(9, -4).numerator #=> -9 - Rational(-2, -10).numerator #=> 1 - -**@overload** [] - -## positive?() [](#method-i-positive?) -Returns `true` if `rat` is greater than 0. - -**@overload** [] - -## quo(other) [](#method-i-quo) -Performs division. - - Rational(2, 3) / Rational(2, 3) #=> (1/1) - Rational(900) / Rational(1) #=> (900/1) - Rational(-2, 9) / Rational(-9, 2) #=> (4/81) - Rational(9, 8) / 4 #=> (9/32) - Rational(20, 9) / 9.8 #=> 0.22675736961451246 - -**@overload** [] - -**@overload** [] - -## rationalize(*args) [](#method-i-rationalize) -Returns a simpler approximation of the value if the optional argument `eps` is -given (rat-|eps| <= result <= rat+|eps|), self otherwise. - - r = Rational(5033165, 16777216) - r.rationalize #=> (5033165/16777216) - r.rationalize(Rational('0.01')) #=> (3/10) - r.rationalize(Rational('0.1')) #=> (1/3) - -**@overload** [] - -**@overload** [] - -## round(*args) [](#method-i-round) -Returns `rat` rounded to the nearest value with a precision of `ndigits` -decimal digits (default: 0). - -When the precision is negative, the returned value is an integer with at least -`ndigits.abs` trailing zeros. - -Returns a rational when `ndigits` is positive, otherwise returns an integer. - - Rational(3).round #=> 3 - Rational(2, 3).round #=> 1 - Rational(-3, 2).round #=> -2 - - # decimal - 1 2 3 . 4 5 6 - # ^ ^ ^ ^ ^ ^ - # precision -3 -2 -1 0 +1 +2 - - Rational('-123.456').round(+1).to_f #=> -123.5 - Rational('-123.456').round(-1) #=> -120 - -The optional `half` keyword argument is available similar to Float#round. - - Rational(25, 100).round(1, half: :up) #=> (3/10) - Rational(25, 100).round(1, half: :down) #=> (1/5) - Rational(25, 100).round(1, half: :even) #=> (1/5) - Rational(35, 100).round(1, half: :up) #=> (2/5) - Rational(35, 100).round(1, half: :down) #=> (3/10) - Rational(35, 100).round(1, half: :even) #=> (2/5) - Rational(-25, 100).round(1, half: :up) #=> (-3/10) - Rational(-25, 100).round(1, half: :down) #=> (-1/5) - Rational(-25, 100).round(1, half: :even) #=> (-1/5) - -**@overload** [] - -## to_f() [](#method-i-to_f) -Returns the value as a Float. - - Rational(2).to_f #=> 2.0 - Rational(9, 4).to_f #=> 2.25 - Rational(-3, 4).to_f #=> -0.75 - Rational(20, 3).to_f #=> 6.666666666666667 - -**@overload** [] - -## to_i() [](#method-i-to_i) -Returns the truncated value as an integer. - -Equivalent to Rational#truncate. - - Rational(2, 3).to_i #=> 0 - Rational(3).to_i #=> 3 - Rational(300.6).to_i #=> 300 - Rational(98, 71).to_i #=> 1 - Rational(-31, 2).to_i #=> -15 - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/rational' - puts Rational(2, 3).to_json - -Output: - - {"json_class":"Rational","n":2,"d":3} - -## to_r() [](#method-i-to_r) -Returns self. - - Rational(2).to_r #=> (2/1) - Rational(-8, 6).to_r #=> (-4/3) - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns the value as a string. - - Rational(2).to_s #=> "2/1" - Rational(-8, 6).to_s #=> "-4/3" - Rational('1/2').to_s #=> "1/2" - -**@overload** [] - -## truncate(*args) [](#method-i-truncate) -Returns `rat` truncated (toward zero) to a precision of `ndigits` decimal -digits (default: 0). - -When the precision is negative, the returned value is an integer with at least -`ndigits.abs` trailing zeros. - -Returns a rational when `ndigits` is positive, otherwise returns an integer. - - Rational(3).truncate #=> 3 - Rational(2, 3).truncate #=> 0 - Rational(-3, 2).truncate #=> -1 - - # decimal - 1 2 3 . 4 5 6 - # ^ ^ ^ ^ ^ ^ - # precision -3 -2 -1 0 +1 +2 - - Rational('-123.456').truncate(+1).to_f #=> -123.4 - Rational('-123.456').truncate(-1) #=> -120 - -**@overload** [] - diff --git a/example/ruby/Rational/compatible.md b/example/ruby/Rational/compatible.md deleted file mode 100644 index 0a7066c..0000000 --- a/example/ruby/Rational/compatible.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Rational::compatible -**Inherits:** Object - - - - - diff --git a/example/ruby/RationalSpecs.md b/example/ruby/RationalSpecs.md deleted file mode 100644 index 29a1d05..0000000 --- a/example/ruby/RationalSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: RationalSpecs - - - - - diff --git a/example/ruby/RationalSpecs/CoerceError.md b/example/ruby/RationalSpecs/CoerceError.md deleted file mode 100644 index fd7fc1b..0000000 --- a/example/ruby/RationalSpecs/CoerceError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: RationalSpecs::CoerceError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/RationalSpecs/SubNumeric.md b/example/ruby/RationalSpecs/SubNumeric.md deleted file mode 100644 index bf2c80d..0000000 --- a/example/ruby/RationalSpecs/SubNumeric.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RationalSpecs::SubNumeric -**Inherits:** Numeric - - - - - -#Instance Methods -## initialize(value) [](#method-i-initialize) - -**@return** [SubNumeric] a new instance of SubNumeric - -## to_r() [](#method-i-to_r) - diff --git a/example/ruby/RationalSub.md b/example/ruby/RationalSub.md deleted file mode 100644 index 75eed87..0000000 --- a/example/ruby/RationalSub.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: RationalSub -**Inherits:** Rational - - - - - diff --git a/example/ruby/Rational_Test.md b/example/ruby/Rational_Test.md deleted file mode 100644 index 96e09a6..0000000 --- a/example/ruby/Rational_Test.md +++ /dev/null @@ -1,118 +0,0 @@ -# Class: Rational_Test -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_eql(exp, act, *args) [](#method-i-assert_eql) - -## assert_invalid_rational(n, d, r) [](#method-i-assert_invalid_rational) - -## assert_valid_rational(n, d, r) [](#method-i-assert_valid_rational) - -## test_Rational_with_invalid_exception() [](#method-i-test_Rational_with_invalid_exception) - -## test_Rational_without_exception() [](#method-i-test_Rational_without_exception) - -## test_add() [](#method-i-test_add) - -## test_attr() [](#method-i-test_attr) - -## test_attr2() [](#method-i-test_attr2) - -## test_cmp() [](#method-i-test_cmp) - -## test_coerce() [](#method-i-test_coerce) - -## test_coerce2() [](#method-i-test_coerce2) - -## test_conv() [](#method-i-test_conv) - -## test_div() [](#method-i-test_div) - -## test_divmod() [](#method-i-test_divmod) - -## test_eqeq() [](#method-i-test_eqeq) - -## test_eql_p() [](#method-i-test_eql_p) - -## test_expt() [](#method-i-test_expt) - -## test_fdiv() [](#method-i-test_fdiv) - -## test_finite_p() [](#method-i-test_finite_p) - -## test_fixed_bug() [](#method-i-test_fixed_bug) - -## test_freeze() [](#method-i-test_freeze) - -## test_gcd_no_memory_leak() [](#method-i-test_gcd_no_memory_leak) - -## test_gcdlcm() [](#method-i-test_gcdlcm) - -## test_hash() [](#method-i-test_hash) - -## test_idiv() [](#method-i-test_idiv) - -## test_infinite_p() [](#method-i-test_infinite_p) - -## test_inspect() [](#method-i-test_inspect) - -## test_known_bug() [](#method-i-test_known_bug) - -## test_marshal() [](#method-i-test_marshal) - -## test_marshal_compatibility() [](#method-i-test_marshal_compatibility) - -## test_math() [](#method-i-test_math) - -## test_modulo() [](#method-i-test_modulo) - -## test_mul() [](#method-i-test_mul) - -## test_negate() [](#method-i-test_negate) - -## test_negative_p() [](#method-i-test_negative_p) - -## test_parse() [](#method-i-test_parse) - -## test_parse_zero_denominator() [](#method-i-test_parse_zero_denominator) - -## test_positive_p() [](#method-i-test_positive_p) - -## test_power_of_0() [](#method-i-test_power_of_0) - -## test_power_of_1_and_minus_1() [](#method-i-test_power_of_1_and_minus_1) - -## test_power_overflow() [](#method-i-test_power_overflow) - -## test_quo() [](#method-i-test_quo) - -## test_rationalize() [](#method-i-test_rationalize) - -## test_ratsub() [](#method-i-test_ratsub) - -## test_remainder() [](#method-i-test_remainder) - -## test_ruby19() [](#method-i-test_ruby19) - -## test_sub() [](#method-i-test_sub) - -## test_supp() [](#method-i-test_supp) - -## test_to_c() [](#method-i-test_to_c) - -## test_to_f() [](#method-i-test_to_f) - -## test_to_i() [](#method-i-test_to_i) - -## test_to_r() [](#method-i-test_to_r) - -## test_to_s() [](#method-i-test_to_s) - -## test_trunc() [](#method-i-test_trunc) - -## test_uplus() [](#method-i-test_uplus) - diff --git a/example/ruby/Rational_Test/ObjectX.md b/example/ruby/Rational_Test/ObjectX.md deleted file mode 100644 index 2d51f31..0000000 --- a/example/ruby/Rational_Test/ObjectX.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Rational_Test::ObjectX -**Inherits:** Object - - - - - -#Instance Methods -## +(x) [](#method-i-+) - -## coerce(x) [](#method-i-coerce) - diff --git a/example/ruby/Rational_Test2.md b/example/ruby/Rational_Test2.md deleted file mode 100644 index 966d9a8..0000000 --- a/example/ruby/Rational_Test2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Rational_Test2 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_kumi() [](#method-i-test_kumi) - diff --git a/example/ruby/Ray.md b/example/ruby/Ray.md deleted file mode 100644 index fa417a0..0000000 --- a/example/ruby/Ray.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Ray -**Inherits:** Object - - - - -# Attributes -## dir[RW] [](#attribute-i-dir) -Returns the value of attribute dir. - -## org[RW] [](#attribute-i-org) -Returns the value of attribute org. - - -#Instance Methods -## initialize(org, dir) [](#method-i-initialize) - -**@return** [Ray] a new instance of Ray - diff --git a/example/ruby/RbConfig.md b/example/ruby/RbConfig.md deleted file mode 100644 index 9581ed4..0000000 --- a/example/ruby/RbConfig.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: RbConfig - - - - -# Attributes -## ruby[RW] [](#attribute-c-ruby) -Returns the value of attribute ruby. - - diff --git a/example/ruby/RbInstall.md b/example/ruby/RbInstall.md deleted file mode 100644 index 8777284..0000000 --- a/example/ruby/RbInstall.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: RbInstall - - - - -# Class Methods -## no_write(options nil) [](#method-c-no_write) - diff --git a/example/ruby/RbInstall/DirPackage.md b/example/ruby/RbInstall/DirPackage.md deleted file mode 100644 index 512c70e..0000000 --- a/example/ruby/RbInstall/DirPackage.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: RbInstall::DirPackage -**Inherits:** Object - - - - -# Attributes -## data_mode[RW] [](#attribute-i-data_mode) -Returns the value of attribute data_mode. - -## dir_mode[RW] [](#attribute-i-dir_mode) -Returns the value of attribute dir_mode. - -## prog_mode[RW] [](#attribute-i-prog_mode) -Returns the value of attribute prog_mode. - -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - -#Instance Methods -## extract_files(destination_dir, pattern"*") [](#method-i-extract_files) - -## initialize(spec, dir_mapnil) [](#method-i-initialize) - -**@return** [DirPackage] a new instance of DirPackage - diff --git a/example/ruby/RbInstall/Specs.md b/example/ruby/RbInstall/Specs.md deleted file mode 100644 index 631e74c..0000000 --- a/example/ruby/RbInstall/Specs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: RbInstall::Specs - - - - - diff --git a/example/ruby/RbInstall/Specs/FileCollector.md b/example/ruby/RbInstall/Specs/FileCollector.md deleted file mode 100644 index 4a5d25a..0000000 --- a/example/ruby/RbInstall/Specs/FileCollector.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: RbInstall::Specs::FileCollector -**Inherits:** Object - - - - -# Class Methods -## for(srcdir , type , gemspec ) [](#method-c-for) -# Attributes -## gemspec[RW] [](#attribute-i-gemspec) -Returns the value of attribute gemspec. - -## relative_base[RW] [](#attribute-i-relative_base) -Returns the value of attribute relative_base. - -## srcdir[RW] [](#attribute-i-srcdir) -Returns the value of attribute srcdir. - - -#Instance Methods -## collect() [](#method-i-collect) - -## initialize(gemspec, srcdir, relative_base) [](#method-i-initialize) - -**@return** [FileCollector] a new instance of FileCollector - diff --git a/example/ruby/RbInstall/Specs/FileCollector/Ext.md b/example/ruby/RbInstall/Specs/FileCollector/Ext.md deleted file mode 100644 index bc8f88f..0000000 --- a/example/ruby/RbInstall/Specs/FileCollector/Ext.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: RbInstall::Specs::FileCollector::Ext -**Inherits:** RbInstall::Specs::FileCollector - - - - - -#Instance Methods -## requirable_features() [](#method-i-requirable_features) - diff --git a/example/ruby/RbInstall/Specs/FileCollector/Lib.md b/example/ruby/RbInstall/Specs/FileCollector/Lib.md deleted file mode 100644 index ea4695d..0000000 --- a/example/ruby/RbInstall/Specs/FileCollector/Lib.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: RbInstall::Specs::FileCollector::Lib -**Inherits:** RbInstall::Specs::FileCollector - - - - - -#Instance Methods -## requirable_features() [](#method-i-requirable_features) - diff --git a/example/ruby/RbInstall/UnpackedInstaller.md b/example/ruby/RbInstall/UnpackedInstaller.md deleted file mode 100644 index 6b3c6b5..0000000 --- a/example/ruby/RbInstall/UnpackedInstaller.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: RbInstall::UnpackedInstaller -**Inherits:** Gem::Installer - - - - - -#Instance Methods -## app_script_text(bin_file_name) [](#method-i-app_script_text) - -## build_extensions() [](#method-i-build_extensions) -Now build-ext builds all extensions including bundled gems. - -## check_executable_overwrite(filename) [](#method-i-check_executable_overwrite) - -## ensure_writable_dir(dir) [](#method-i-ensure_writable_dir) - -## generate_bin_script(filename, bindir) [](#method-i-generate_bin_script) - -## install() [](#method-i-install) - -## same_bin_script?(filename, bindir) [](#method-i-same_bin_script?) - -**@return** [Boolean] - -## shebang(bin_file_name) [](#method-i-shebang) - -## verify_gem_home() [](#method-i-verify_gem_home) -:nodoc: - -## write_cache_file() [](#method-i-write_cache_file) - -## write_default_spec() [](#method-i-write_default_spec) - -## write_spec() [](#method-i-write_spec) - diff --git a/example/ruby/RealSuperUserGuard.md b/example/ruby/RealSuperUserGuard.md deleted file mode 100644 index 5c16a49..0000000 --- a/example/ruby/RealSuperUserGuard.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: RealSuperUserGuard -**Inherits:** SpecGuard - - - - - -#Instance Methods -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/RedBlackTree.md b/example/ruby/RedBlackTree.md deleted file mode 100644 index 093b63b..0000000 --- a/example/ruby/RedBlackTree.md +++ /dev/null @@ -1,2082 +0,0 @@ -# Class: RedBlackTree -**Inherits:** Object - -**Includes:** Enumerable - - -Algorithm based on "Introduction to Algorithms" by Cormen and others - - -# Attributes -## root[RW] [](#attribute-i-root) -Returns the value of attribute root. - -## size[RW] [](#attribute-i-size) -Returns the value of attribute size. - - -#Instance Methods -## add(key) [](#method-i-add) - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## black_height(xroot) [](#method-i-black_height) - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete(z) [](#method-i-delete) - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) - -**@return** [RedBlackTree] a new instance of RedBlackTree - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inorder_walk(xroot) [](#method-i-inorder_walk) - -## insert(x) [](#method-i-insert) - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## maximum(xroot) [](#method-i-maximum) - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minimum(xroot) [](#method-i-minimum) - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## predecessor(x) [](#method-i-predecessor) - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_inorder_walk(xroot) [](#method-i-reverse_inorder_walk) - -## search(key, xroot) [](#method-i-search) - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## successor(x) [](#method-i-successor) - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/RedBlackTree/NilNode.md b/example/ruby/RedBlackTree/NilNode.md deleted file mode 100644 index 175d33c..0000000 --- a/example/ruby/RedBlackTree/NilNode.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: RedBlackTree::NilNode -**Inherits:** RedBlackTree::Node - - - - -# Class Methods -## instance() [](#method-c-instance) -it's not thread safe - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [NilNode] a new instance of NilNode - -## nil?() [](#method-i-nil?) - -**@return** [Boolean] - diff --git a/example/ruby/RedBlackTree/Node.md b/example/ruby/RedBlackTree/Node.md deleted file mode 100644 index 8bcc918..0000000 --- a/example/ruby/RedBlackTree/Node.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: RedBlackTree::Node -**Inherits:** Object - - - - -# Attributes -## color[RW] [](#attribute-i-color) -Returns the value of attribute color. - -## key[RW] [](#attribute-i-key) -Returns the value of attribute key. - -## left[RW] [](#attribute-i-left) -Returns the value of attribute left. - -## parent[RW] [](#attribute-i-parent) -Returns the value of attribute parent. - -## right[RW] [](#attribute-i-right) -Returns the value of attribute right. - - -#Instance Methods -## black?() [](#method-i-black?) - -**@return** [Boolean] - -## initialize(key, colorRED) [](#method-i-initialize) - -**@raise** [ArgumentError] - -**@return** [Node] a new instance of Node - -## red?() [](#method-i-red?) - -**@return** [Boolean] - diff --git a/example/ruby/Refinement.md b/example/ruby/Refinement.md deleted file mode 100644 index 99f62b5..0000000 --- a/example/ruby/Refinement.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Refinement -**Inherits:** Module - - -********************************************************************* - - Refinement is a class of the +self+ (current context) inside +refine+ - statement. It allows to import methods from other modules, see #import_methods. - - - -#Instance Methods -## target() [](#method-i-target) -Return the class or module refined by the receiver. - - module M - refine String do - end - end - - M.refinements[0].target # => String - -**@overload** [] - diff --git a/example/ruby/RefinementSpec.md b/example/ruby/RefinementSpec.md deleted file mode 100644 index 2ed565f..0000000 --- a/example/ruby/RefinementSpec.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: RefinementSpec - - - - - diff --git a/example/ruby/RefinementSpec/ModuleWithAncestors.md b/example/ruby/RefinementSpec/ModuleWithAncestors.md deleted file mode 100644 index 9655e4e..0000000 --- a/example/ruby/RefinementSpec/ModuleWithAncestors.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: RefinementSpec::ModuleWithAncestors - - - - - diff --git a/example/ruby/ReflectSpecs.md b/example/ruby/ReflectSpecs.md deleted file mode 100644 index 6b39941..0000000 --- a/example/ruby/ReflectSpecs.md +++ /dev/null @@ -1,51 +0,0 @@ -# Module: ReflectSpecs - - -These modules and classes are fixtures used by the Ruby reflection specs. -These include specs for methods: - -Module: - instance_methods - public_instance_methods - protected_instance_methods - private_instance_methods - -Kernel: - methods - public_methods - protected_methods - private_methods - singleton_methods - -The following naming scheme is used to keep the method names short and still -communicate the relevant facts about the methods: - - X[s]_VIS - -where - - X is the name of the module or class in lower case - s is the literal character 's' for singleton methods - VIS is the first three letters of the corresponding visibility - pub(lic), pro(tected), pri(vate) - -For example: - - l_pub is a public method on module L - ls_pri is a private singleton method on module L - - -# Class Methods -## o() [](#method-c-o) -An object with no singleton methods. -## oe() [](#method-c-oe) -An object extended with a module. -## oed() [](#method-c-oed) -An object with duplicate methods extended with a module. -## oee() [](#method-c-oee) -An object extended with two modules. -## oei() [](#method-c-oei) -An object extended with a module including a module. -## os() [](#method-c-os) -An object with singleton methods. - diff --git a/example/ruby/ReflectSpecs/A.md b/example/ruby/ReflectSpecs/A.md deleted file mode 100644 index 8b48ea8..0000000 --- a/example/ruby/ReflectSpecs/A.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ReflectSpecs::A -**Inherits:** Object - - -A simple class. - - -# Class Methods -## as_pri() [](#method-c-as_pri) -## as_pro() [](#method-c-as_pro) -## as_pub() [](#method-c-as_pub) -## pri() [](#method-c-pri) -## pro() [](#method-c-pro) -## pub() [](#method-c-pub) - -#Instance Methods -## a_pub() [](#method-i-a_pub) - diff --git a/example/ruby/ReflectSpecs/B.md b/example/ruby/ReflectSpecs/B.md deleted file mode 100644 index 2fac2e1..0000000 --- a/example/ruby/ReflectSpecs/B.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: ReflectSpecs::B -**Inherits:** ReflectSpecs::A - - -A simple subclass. - - -# Class Methods -## bs_pri() [](#method-c-bs_pri) -## bs_pro() [](#method-c-bs_pro) -## bs_pub() [](#method-c-bs_pub) -## pri() [](#method-c-pri) -## pro() [](#method-c-pro) -## pub() [](#method-c-pub) - -#Instance Methods -## b_pub() [](#method-i-b_pub) - diff --git a/example/ruby/ReflectSpecs/C.md b/example/ruby/ReflectSpecs/C.md deleted file mode 100644 index f15d6a7..0000000 --- a/example/ruby/ReflectSpecs/C.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: ReflectSpecs::C -**Inherits:** ReflectSpecs::A - -**Includes:** ReflectSpecs::M - - -A subclass including a module. - - -# Class Methods -## cs_pri() [](#method-c-cs_pri) -## cs_pro() [](#method-c-cs_pro) -## cs_pub() [](#method-c-cs_pub) -## pri() [](#method-c-pri) -## pro() [](#method-c-pro) -## pub() [](#method-c-pub) - -#Instance Methods -## c_pub() [](#method-i-c_pub) - -## m_pub() [](#method-i-m_pub) - -## pub() [](#method-i-pub) - diff --git a/example/ruby/ReflectSpecs/D.md b/example/ruby/ReflectSpecs/D.md deleted file mode 100644 index 16d86d3..0000000 --- a/example/ruby/ReflectSpecs/D.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: ReflectSpecs::D -**Inherits:** Object - -**Includes:** ReflectSpecs::M - - -A simple class including a module - - -# Class Methods -## ds_pri() [](#method-c-ds_pri) -## ds_pro() [](#method-c-ds_pro) -## ds_pub() [](#method-c-ds_pub) - -#Instance Methods -## d_pub() [](#method-i-d_pub) - -## m_pub() [](#method-i-m_pub) - -## pub() [](#method-i-pub) - diff --git a/example/ruby/ReflectSpecs/E.md b/example/ruby/ReflectSpecs/E.md deleted file mode 100644 index e586cd9..0000000 --- a/example/ruby/ReflectSpecs/E.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: ReflectSpecs::E -**Inherits:** ReflectSpecs::D - - -A subclass of a class including a module. - - -# Class Methods -## es_pri() [](#method-c-es_pri) -## es_pro() [](#method-c-es_pro) -## es_pub() [](#method-c-es_pub) - -#Instance Methods -## e_pub() [](#method-i-e_pub) - -## pub() [](#method-i-pub) - diff --git a/example/ruby/ReflectSpecs/F.md b/example/ruby/ReflectSpecs/F.md deleted file mode 100644 index c8adc24..0000000 --- a/example/ruby/ReflectSpecs/F.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: ReflectSpecs::F -**Inherits:** ReflectSpecs::D - -**Includes:** ReflectSpecs::L - - -A subclass that includes a module of a class including a module. - - -# Class Methods -## fs_pri() [](#method-c-fs_pri) -## fs_pro() [](#method-c-fs_pro) -## fs_pub() [](#method-c-fs_pub) - -#Instance Methods -## f_pub() [](#method-i-f_pub) - -## l_pub() [](#method-i-l_pub) - diff --git a/example/ruby/ReflectSpecs/K.md b/example/ruby/ReflectSpecs/K.md deleted file mode 100644 index 9f11552..0000000 --- a/example/ruby/ReflectSpecs/K.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: ReflectSpecs::K - - -A module with no singleton methods. - - - diff --git a/example/ruby/ReflectSpecs/L.md b/example/ruby/ReflectSpecs/L.md deleted file mode 100644 index b4a44a1..0000000 --- a/example/ruby/ReflectSpecs/L.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: ReflectSpecs::L - - -A simple module. - - -# Class Methods -## ls_pri() [](#method-c-ls_pri) -## ls_pro() [](#method-c-ls_pro) -## ls_pub() [](#method-c-ls_pub) - -#Instance Methods -## l_pub() [](#method-i-l_pub) - diff --git a/example/ruby/ReflectSpecs/M.md b/example/ruby/ReflectSpecs/M.md deleted file mode 100644 index e4c2411..0000000 --- a/example/ruby/ReflectSpecs/M.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: ReflectSpecs::M - - -A simple module. - - -# Class Methods -## ms_pri() [](#method-c-ms_pri) -## ms_pro() [](#method-c-ms_pro) -## ms_pub() [](#method-c-ms_pub) - -#Instance Methods -## m_pub() [](#method-i-m_pub) - -## pub() [](#method-i-pub) - diff --git a/example/ruby/ReflectSpecs/N.md b/example/ruby/ReflectSpecs/N.md deleted file mode 100644 index ff18119..0000000 --- a/example/ruby/ReflectSpecs/N.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: ReflectSpecs::N - -**Includes:** ReflectSpecs::M - - -A module including a module - - -# Class Methods -## ns_pri() [](#method-c-ns_pri) -## ns_pro() [](#method-c-ns_pro) -## ns_pub() [](#method-c-ns_pub) - -#Instance Methods -## m_pub() [](#method-i-m_pub) - -## n_pub() [](#method-i-n_pub) - -## pub() [](#method-i-pub) - diff --git a/example/ruby/ReflectSpecs/O.md b/example/ruby/ReflectSpecs/O.md deleted file mode 100644 index df73d60..0000000 --- a/example/ruby/ReflectSpecs/O.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: ReflectSpecs::O -**Inherits:** Object - - -Class with no singleton methods. - - - diff --git a/example/ruby/ReflectSpecs/P.md b/example/ruby/ReflectSpecs/P.md deleted file mode 100644 index c5f59bf..0000000 --- a/example/ruby/ReflectSpecs/P.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: ReflectSpecs::P -**Inherits:** Object - -**Extended by:** ReflectSpecs::M - - -Class extended with a module. - - -# Class Methods -## m_pub() [](#method-c-m_pub) -## pub() [](#method-c-pub) - diff --git a/example/ruby/Regexp.md b/example/ruby/Regexp.md deleted file mode 100644 index f9f1c4e..0000000 --- a/example/ruby/Regexp.md +++ /dev/null @@ -1,546 +0,0 @@ -# Class: Regexp -**Inherits:** Object - - -:include: doc/_regexp.rdoc - - -# Class Methods -## compile() [](#method-c-compile) -Alias for Regexp.new -## escape(str ) [](#method-c-escape) -Returns a new string that escapes any characters that have special meaning in -a regular expression: - - s = Regexp.escape('\*?{}.') # => "\\\\\\*\\?\\{\\}\\." - -For any string `s`, this call returns a MatchData object: - - r = Regexp.new(Regexp.escape(s)) # => /\\\\\\\*\\\?\\\{\\\}\\\./ - r.match(s) # => # -**@overload** [] - -## json_create(object ) [](#method-c-json_create) -See #as_json. -## last_match(*args ) [](#method-c-last_match) -With no argument, returns the value of `$~`, which is the result of the most -recent pattern match (see [Regexp global -variables](rdoc-ref:Regexp@Global+Variables)): - - /c(.)t/ =~ 'cat' # => 0 - Regexp.last_match # => # - /a/ =~ 'foo' # => nil - Regexp.last_match # => nil - -With non-negative integer argument `n`, returns the _n_th field in the -matchdata, if any, or nil if none: - - /c(.)t/ =~ 'cat' # => 0 - Regexp.last_match(0) # => "cat" - Regexp.last_match(1) # => "a" - Regexp.last_match(2) # => nil - -With negative integer argument `n`, counts backwards from the last field: - - Regexp.last_match(-1) # => "a" - -With string or symbol argument `name`, returns the string value for the named -capture, if any: - - /(?\w+)\s*=\s*(?\w+)/ =~ 'var = val' - Regexp.last_match # => # - Regexp.last_match(:lhs) # => "var" - Regexp.last_match('rhs') # => "val" - Regexp.last_match('foo') # Raises IndexError. -**@overload** [] - -**@overload** [] - -**@overload** [] - -## linear_time?(*args ) [](#method-c-linear_time?) -Returns `true` if matching against `re` can be done in linear time to the -input string. - - Regexp.linear_time?(/re/) # => true - -Note that this is a property of the ruby interpreter, not of the argument -regular expression. Identical regexp can or cannot run in linear time -depending on your ruby binary. Neither forward nor backward compatibility is -guaranteed about the return value of this method. Our current algorithm is -(*1) but this is subject to change in the future. Alternative implementations -can also behave differently. They might always return false for everything. - -(*1): https://doi.org/10.1109/SP40001.2021.00032 -**@overload** [] - -**@overload** [] - -**@return** [Boolean] - -## quote(str ) [](#method-c-quote) -Returns a new string that escapes any characters that have special meaning in -a regular expression: - - s = Regexp.escape('\*?{}.') # => "\\\\\\*\\?\\{\\}\\." - -For any string `s`, this call returns a MatchData object: - - r = Regexp.new(Regexp.escape(s)) # => /\\\\\\\*\\\?\\\{\\\}\\\./ - r.match(s) # => # -**@overload** [] - -## timeout() [](#method-c-timeout) -It returns the current default timeout interval for Regexp matching in second. -`nil` means no default timeout configuration. -**@overload** [] - -## timeout=(timeout ) [](#method-c-timeout=) -It sets the default timeout interval for Regexp matching in second. `nil` -means no default timeout configuration. This configuration is process-global. -If you want to set timeout for each Regexp, use `timeout` keyword for -`Regexp.new`. - - Regexp.timeout = 1 - /^a*b?a*$/ =~ "a" * 100000 + "x" #=> regexp match timeout (RuntimeError) -**@overload** [] - -## try_convert(re ) [](#method-c-try_convert) -Returns `object` if it is a regexp: - - Regexp.try_convert(/re/) # => /re/ - -Otherwise if `object` responds to `:to_regexp`, calls `object.to_regexp` and -returns the result. - -Returns `nil` if `object` does not respond to `:to_regexp`. - - Regexp.try_convert('re') # => nil - -Raises an exception unless `object.to_regexp` returns a regexp. -**@overload** [] - -## union(args ) [](#method-c-union) -Returns a new regexp that is the union of the given patterns: - - r = Regexp.union(%w[cat dog]) # => /cat|dog/ - r.match('cat') # => # - r.match('dog') # => # - r.match('cog') # => nil - -For each pattern that is a string, `Regexp.new(pattern)` is used: - - Regexp.union('penzance') # => /penzance/ - Regexp.union('a+b*c') # => /a\+b\*c/ - Regexp.union('skiing', 'sledding') # => /skiing|sledding/ - Regexp.union(['skiing', 'sledding']) # => /skiing|sledding/ - -For each pattern that is a regexp, it is used as is, including its flags: - - Regexp.union(/foo/i, /bar/m, /baz/x) - # => /(?i-mx:foo)|(?m-ix:bar)|(?x-mi:baz)/ - Regexp.union([/foo/i, /bar/m, /baz/x]) - # => /(?i-mx:foo)|(?m-ix:bar)|(?x-mi:baz)/ - -With no arguments, returns `/(?!)/`: - - Regexp.union # => /(?!)/ - -If any regexp pattern contains captures, the behavior is unspecified. -**@overload** [] - -**@overload** [] - - -#Instance Methods -## ==(re2) [](#method-i-==) -Returns `true` if `object` is another Regexp whose pattern, flags, and -encoding are the same as `self`, `false` otherwise: - - /foo/ == Regexp.new('foo') # => true - /foo/ == /foo/i # => false - /foo/ == Regexp.new('food') # => false - /foo/ == Regexp.new("abc".force_encoding("euc-jp")) # => false - -**@overload** [] - -## ===(str) [](#method-i-===) -Returns `true` if `self` finds a match in `string`: - - /^[a-z]*$/ === 'HELLO' # => false - /^[A-Z]*$/ === 'HELLO' # => true - -This method is called in case statements: - - s = 'HELLO' - case s - when /\A[a-z]*\z/; print "Lower case\n" - when /\A[A-Z]*\z/; print "Upper case\n" - else print "Mixed case\n" - end # => "Upper case" - -**@overload** [] - -## =~(str) [](#method-i-=~) -Returns the integer index (in characters) of the first match for `self` and -`string`, or `nil` if none; also sets the [rdoc-ref:Regexp global -variables](rdoc-ref:Regexp@Global+Variables): - - /at/ =~ 'input data' # => 7 - $~ # => # - /ax/ =~ 'input data' # => nil - $~ # => nil - -Assigns named captures to local variables of the same names if and only if -`self`: - -* Is a regexp literal; see [Regexp - Literals](rdoc-ref:syntax/literals.rdoc@Regexp+Literals). -* Does not contain interpolations; see [Regexp - interpolation](rdoc-ref:Regexp@Interpolation+Mode). -* Is at the left of the expression. - -Example: - - /(?\w+)\s*=\s*(?\w+)/ =~ ' x = y ' - p lhs # => "x" - p rhs # => "y" - -Assigns `nil` if not matched: - - /(?\w+)\s*=\s*(?\w+)/ =~ ' x = ' - p lhs # => nil - p rhs # => nil - -Does not make local variable assignments if `self` is not a regexp literal: - - r = /(?\w+)\s*=\s*(?\w+)/ - r =~ ' x = y ' - p foo # Undefined local variable - p bar # Undefined local variable - -The assignment does not occur if the regexp is not at the left: - - ' x = y ' =~ /(?\w+)\s*=\s*(?\w+)/ - p foo, foo # Undefined local variables - -A regexp interpolation, `#{}`, also disables the assignment: - - r = /(?\w+)/ - /(?\w+)\s*=\s*#{r}/ =~ 'x = y' - p foo # Undefined local variable - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Regexp#as_json` and `Regexp.json_create` may be used to serialize and -deserialize a Regexp object; see [Marshal](rdoc-ref:Marshal). - -Method `Regexp#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/regexp' - x = /foo/.as_json - # => {"json_class"=>"Regexp", "o"=>0, "s"=>"foo"} - -Method `JSON.create` deserializes such a hash, returning a Regexp object: - - Regexp.json_create(x) # => /foo/ - -## casefold?() [](#method-i-casefold?) -Returns `true` if the case-insensitivity flag in `self` is set, `false` -otherwise: - - /a/.casefold? # => false - /a/i.casefold? # => true - /(?i:a)/.casefold? # => false - -**@overload** [] - -**@return** [Boolean] - -## encoding() [](#method-i-encoding) - -## eql?(re2) [](#method-i-eql?) -Returns `true` if `object` is another Regexp whose pattern, flags, and -encoding are the same as `self`, `false` otherwise: - - /foo/ == Regexp.new('foo') # => true - /foo/ == /foo/i # => false - /foo/ == Regexp.new('food') # => false - /foo/ == Regexp.new("abc".force_encoding("euc-jp")) # => false - -**@overload** [] - -## fixed_encoding?() [](#method-i-fixed_encoding?) -Returns `false` if `self` is applicable to a string with any ASCII-compatible -encoding; otherwise returns `true`: - - r = /a/ # => /a/ - r.fixed_encoding? # => false - r.match?("\u{6666} a") # => true - r.match?("\xa1\xa2 a".force_encoding("euc-jp")) # => true - r.match?("abc".force_encoding("euc-jp")) # => true - - r = /a/u # => /a/ - r.fixed_encoding? # => true - r.match?("\u{6666} a") # => true - r.match?("\xa1\xa2".force_encoding("euc-jp")) # Raises exception. - r.match?("abc".force_encoding("euc-jp")) # => true - - r = /\u{6666}/ # => /\u{6666}/ - r.fixed_encoding? # => true - r.encoding # => # - r.match?("\u{6666} a") # => true - r.match?("\xa1\xa2".force_encoding("euc-jp")) # Raises exception. - r.match?("abc".force_encoding("euc-jp")) # => false - -**@overload** [] - -## hash() [](#method-i-hash) -Returns the integer hash value for `self`. - -Related: Object#hash. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -With argument `string` given, returns a new regexp with the given string and -options: - - r = Regexp.new('foo') # => /foo/ - r.source # => "foo" - r.options # => 0 - -Optional argument `options` is one of the following: - -* A String of options: - - Regexp.new('foo', 'i') # => /foo/i - Regexp.new('foo', 'im') # => /foo/im - -* The bit-wise OR of one or more of the constants Regexp::EXTENDED, - Regexp::IGNORECASE, Regexp::MULTILINE, and Regexp::NOENCODING: - - Regexp.new('foo', Regexp::IGNORECASE) # => /foo/i - Regexp.new('foo', Regexp::EXTENDED) # => /foo/x - Regexp.new('foo', Regexp::MULTILINE) # => /foo/m - Regexp.new('foo', Regexp::NOENCODING) # => /foo/n - flags = Regexp::IGNORECASE | Regexp::EXTENDED | Regexp::MULTILINE - Regexp.new('foo', flags) # => /foo/mix - -* `nil` or `false`, which is ignored. -* Any other truthy value, in which case the regexp will be case-insensitive. - -If optional keyword argument `timeout` is given, its float value overrides the -timeout interval for the class, Regexp.timeout. If `nil` is passed as -+timeout, it uses the timeout interval for the class, Regexp.timeout. - -With argument `regexp` given, returns a new regexp. The source, options, -timeout are the same as `regexp`. `options` and `n_flag` arguments are -ineffective. The timeout can be overridden by `timeout` keyword. - - options = Regexp::MULTILINE - r = Regexp.new('foo', options, timeout: 1.1) # => /foo/m - r2 = Regexp.new(r) # => /foo/m - r2.timeout # => 1.1 - r3 = Regexp.new(r, timeout: 3.14) # => /foo/m - r3.timeout # => 3.14 - -**@overload** [] - -**@overload** [] - -## initialize_copy(re) [](#method-i-initialize_copy) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a nicely-formatted string representation of `self`: - - /ab+c/ix.inspect # => "/ab+c/ix" - -Related: Regexp#to_s. - -**@overload** [] - -## match(*args) [](#method-i-match) -With no block given, returns the MatchData object that describes the match, if -any, or `nil` if none; the search begins at the given character `offset` in -`string`: - - /abra/.match('abracadabra') # => # - /abra/.match('abracadabra', 4) # => # - /abra/.match('abracadabra', 8) # => nil - /abra/.match('abracadabra', 800) # => nil - - string = "\u{5d0 5d1 5e8 5d0}cadabra" - /abra/.match(string, 7) #=> # - /abra/.match(string, 8) #=> nil - /abra/.match(string.b, 8) #=> # - -With a block given, calls the block if and only if a match is found; returns -the block's value: - - /abra/.match('abracadabra') {|matchdata| p matchdata } - # => # - /abra/.match('abracadabra', 4) {|matchdata| p matchdata } - # => # - /abra/.match('abracadabra', 8) {|matchdata| p matchdata } - # => nil - /abra/.match('abracadabra', 8) {|marchdata| fail 'Cannot happen' } - # => nil - -Output (from the first two blocks above): - - # - # - - /(.)(.)(.)/.match("abc")[2] # => "b" - /(.)(.)/.match("abc", 1)[2] # => "c" - -**@overload** [] - -**@overload** [] - -## match?(*args) [](#method-i-match?) -Returns `true` or `false` to indicate whether the regexp is matched or not -without updating $~ and other related variables. If the second parameter is -present, it specifies the position in the string to begin the search. - - /R.../.match?("Ruby") # => true - /R.../.match?("Ruby", 1) # => false - /P.../.match?("Ruby") # => false - $& # => nil - -**@overload** [] - -**@overload** [] - -## named_captures() [](#method-i-named_captures) -Returns a hash representing named captures of `self` (see [Named -Captures](rdoc-ref:Regexp@Named+Captures)): - -* Each key is the name of a named capture. -* Each value is an array of integer indexes for that named capture. - -Examples: - - /(?.)(?.)/.named_captures # => {"foo"=>[1], "bar"=>[2]} - /(?.)(?.)/.named_captures # => {"foo"=>[1, 2]} - /(.)(.)/.named_captures # => {} - -**@overload** [] - -## names() [](#method-i-names) -Returns an array of names of captures (see [Named -Captures](rdoc-ref:Regexp@Named+Captures)): - - /(?.)(?.)(?.)/.names # => ["foo", "bar", "baz"] - /(?.)(?.)/.names # => ["foo"] - /(.)(.)/.names # => [] - -**@overload** [] - -## options() [](#method-i-options) -Returns an integer whose bits show the options set in `self`. - -The option bits are: - - Regexp::IGNORECASE # => 1 - Regexp::EXTENDED # => 2 - Regexp::MULTILINE # => 4 - -Examples: - - /foo/.options # => 0 - /foo/i.options # => 1 - /foo/x.options # => 2 - /foo/m.options # => 4 - /foo/mix.options # => 7 - -Note that additional bits may be set in the returned integer; these are -maintained internally in `self`, are ignored if passed to Regexp.new, and may -be ignored by the caller: - -Returns the set of bits corresponding to the options used when creating this -regexp (see Regexp::new for details). Note that additional bits may be set in -the returned options: these are used internally by the regular expression -code. These extra bits are ignored if the options are passed to Regexp::new: - - r = /\xa1\xa2/e # => /\xa1\xa2/ - r.source # => "\\xa1\\xa2" - r.options # => 16 - Regexp.new(r.source, r.options) # => /\xa1\xa2/ - -**@overload** [] - -## source() [](#method-i-source) -Returns the original string of `self`: - - /ab+c/ix.source # => "ab+c" - -Regexp escape sequences are retained: - - /\x20\+/.source # => "\\x20\\+" - -Lexer escape characters are not retained: - - /\//.source # => "/" - -**@overload** [] - -## timeout() [](#method-i-timeout) -It returns the timeout interval for Regexp matching in second. `nil` means no -default timeout configuration. - -This configuration is per-object. The global configuration set by -Regexp.timeout= is ignored if per-object configuration is set. - - re = Regexp.new("^a*b?a*$", timeout: 1) - re.timeout #=> 1.0 - re =~ "a" * 100000 + "x" #=> regexp match timeout (RuntimeError) - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/regexp' - puts /foo/.to_json - -Output: - - {"json_class":"Regexp","o":0,"s":"foo"} - -## to_s() [](#method-i-to_s) -Returns a string showing the options and string of `self`: - - r0 = /ab+c/ix - s0 = r0.to_s # => "(?ix-m:ab+c)" - -The returned string may be used as an argument to Regexp.new, or as -interpolated text for a [Regexp -interpolation](rdoc-ref:Regexp@Interpolation+Mode): - - r1 = Regexp.new(s0) # => /(?ix-m:ab+c)/ - r2 = /#{s0}/ # => /(?ix-m:ab+c)/ - -Note that `r1` and `r2` are not equal to `r0` because their original strings -are different: - - r0 == r1 # => false - r0.source # => "ab+c" - r1.source # => "(?ix-m:ab+c)" - -Related: Regexp#inspect. - -**@overload** [] - -## ~() [](#method-i-~) -Equivalent to *`rxp* =~ $_`: - - $_ = "input data" - ~ /at/ # => 7 - -**@overload** [] - diff --git a/example/ruby/Regexp/TimeoutError.md b/example/ruby/Regexp/TimeoutError.md deleted file mode 100644 index 92b3c9b..0000000 --- a/example/ruby/Regexp/TimeoutError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Regexp::TimeoutError -**Inherits:** RegexpError - - - - - diff --git a/example/ruby/RegexpError.md b/example/ruby/RegexpError.md deleted file mode 100644 index f1c8237..0000000 --- a/example/ruby/RegexpError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: RegexpError -**Inherits:** StandardError - - -Raised when given an invalid regexp expression. - - Regexp.new("?") - -*raises the exception:* - - RegexpError: target of repeat operator is not specified: /?/ - - - diff --git a/example/ruby/RegexpFilter.md b/example/ruby/RegexpFilter.md deleted file mode 100644 index 7565069..0000000 --- a/example/ruby/RegexpFilter.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: RegexpFilter -**Inherits:** Object - - - - - -#Instance Methods -## ===(string) [](#method-i-===) - -## initialize(what, *regexps) [](#method-i-initialize) - -**@return** [RegexpFilter] a new instance of RegexpFilter - -## register() [](#method-i-register) - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/Reline.md b/example/ruby/Reline.md deleted file mode 100644 index 0d7a7ee..0000000 --- a/example/ruby/Reline.md +++ /dev/null @@ -1,86 +0,0 @@ -# Module: Reline - -**Extended by:** Forwardable, SingleForwardable - - - - -# Class Methods -## core() [](#method-c-core) -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## def_single_delegator(accessor , method , ali method) [](#method-c-def_single_delegator) -:call-seq: - def_single_delegator(accessor, method, new_name=method) - -Defines a method *method* which delegates to *accessor* (i.e. it calls the -method of the same name in *accessor*). If *new_name* is provided, it is used -as the name for the delegate method. Returns the name of the method defined. -## def_single_delegators(accessor , *methods ) [](#method-c-def_single_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## encoding_system_needs() [](#method-c-encoding_system_needs) -## get_screen_size() [](#method-c-get_screen_size) -## insert_text(text ) [](#method-c-insert_text) -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -## line_editor() [](#method-c-line_editor) -## single_delegate(hash ) [](#method-c-single_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names. The value is the accessor to which -the methods will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -## test_mode(ansi: false) [](#method-c-test_mode) -## test_reset() [](#method-c-test_reset) -## test_rubybin() [](#method-c-test_rubybin) -Return a executable name to spawn Ruby process. In certain build -configuration, "ruby" may not be available. -## ungetc(c ) [](#method-c-ungetc) - diff --git a/example/ruby/Reline/ANSI.md b/example/ruby/Reline/ANSI.md deleted file mode 100644 index 3b44731..0000000 --- a/example/ruby/Reline/ANSI.md +++ /dev/null @@ -1,93 +0,0 @@ -# Class: Reline::ANSI -**Inherits:** Reline::IO - - - - -# Attributes -## input=[R] [](#attribute-i-input=) -Sets the attribute input - -**@param** [] the value to set the attribute input to. - -## output=[R] [](#attribute-i-output=) -Sets the attribute output - -**@param** [] the value to set the attribute output to. - - -#Instance Methods -## both_tty?() [](#method-i-both_tty?) - -**@return** [Boolean] - -## buffered_output() [](#method-i-buffered_output) - -## clear_screen() [](#method-i-clear_screen) - -## cursor_pos() [](#method-i-cursor_pos) - -## deprep(otio) [](#method-i-deprep) - -## empty_buffer?() [](#method-i-empty_buffer?) - -**@return** [Boolean] - -## encoding() [](#method-i-encoding) - -## erase_after_cursor() [](#method-i-erase_after_cursor) - -## get_screen_size() [](#method-i-get_screen_size) - -## getc(timeout_second) [](#method-i-getc) -if the usage expects to wait indefinitely, use Float::INFINITY for -timeout_second - -## hide_cursor() [](#method-i-hide_cursor) - -## in_pasting?() [](#method-i-in_pasting?) - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [ANSI] a new instance of ANSI - -## inner_getc(timeout_second) [](#method-i-inner_getc) - -## move_cursor_column(x) [](#method-i-move_cursor_column) - -## move_cursor_down(x) [](#method-i-move_cursor_down) - -## move_cursor_up(x) [](#method-i-move_cursor_up) - -## prep() [](#method-i-prep) - -## read_bracketed_paste() [](#method-i-read_bracketed_paste) - -## retrieve_keybuffer() [](#method-i-retrieve_keybuffer) - -## scroll_down(x) [](#method-i-scroll_down) -This only works when the cursor is at the bottom of the scroll range For more -details, see https://github.com/ruby/reline/pull/577#issuecomment-1646679623 - -## set_bracketed_paste_key_bindings(config) [](#method-i-set_bracketed_paste_key_bindings) - -## set_default_key_bindings(config) [](#method-i-set_default_key_bindings) - -## set_default_key_bindings_ansi_cursor(config) [](#method-i-set_default_key_bindings_ansi_cursor) - -## set_default_key_bindings_comprehensive_list(config) [](#method-i-set_default_key_bindings_comprehensive_list) - -## set_screen_size(rows, columns) [](#method-i-set_screen_size) - -## set_winch_handler(&handler) [](#method-i-set_winch_handler) - -## show_cursor() [](#method-i-show_cursor) - -## ungetc(c) [](#method-i-ungetc) - -## with_raw_input() [](#method-i-with_raw_input) - -## write(string) [](#method-i-write) - diff --git a/example/ruby/Reline/ANSITest.md b/example/ruby/Reline/ANSITest.md deleted file mode 100644 index 82c5c6f..0000000 --- a/example/ruby/Reline/ANSITest.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Reline::ANSITest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_delete() [](#method-i-test_delete) - -## test_down_arrow() [](#method-i-test_down_arrow) - -## test_end() [](#method-i-test_end) - -## test_extended() [](#method-i-test_extended) -Ctrl+arrow and Meta+arrow - -## test_home() [](#method-i-test_home) - -## test_left_arrow() [](#method-i-test_left_arrow) - -## test_more_emacs() [](#method-i-test_more_emacs) -A few emacs bindings that are always mapped - -## test_right_arrow() [](#method-i-test_right_arrow) - -## test_shift_tab() [](#method-i-test_shift_tab) - -## test_up_arrow() [](#method-i-test_up_arrow) - diff --git a/example/ruby/Reline/Config.md b/example/ruby/Reline/Config.md deleted file mode 100644 index f236083..0000000 --- a/example/ruby/Reline/Config.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: Reline::Config -**Inherits:** Object - - - - -# Attributes -## autocompletion[RW] [](#attribute-i-autocompletion) -Returns the value of attribute autocompletion. - -## test_mode[RW] [](#attribute-i-test_mode) -Returns the value of attribute test_mode. - - -#Instance Methods -## add_default_key_binding(keystroke, target) [](#method-i-add_default_key_binding) - -## add_default_key_binding_by_keymap(keymap, keystroke, target) [](#method-i-add_default_key_binding_by_keymap) - -## add_oneshot_key_binding(keystroke, target) [](#method-i-add_oneshot_key_binding) - -## bind_key(key, value) [](#method-i-bind_key) - -## bind_variable(name, value, raw_value) [](#method-i-bind_variable) - -## editing_mode() [](#method-i-editing_mode) - -## editing_mode=(val) [](#method-i-editing_mode=) - -## editing_mode_is?(*val) [](#method-i-editing_mode_is?) - -**@return** [Boolean] - -## handle_directive(directive, file, no, if_stack) [](#method-i-handle_directive) - -## initialize() [](#method-i-initialize) - -**@return** [Config] a new instance of Config - -## inputrc_path() [](#method-i-inputrc_path) - -## key_bindings() [](#method-i-key_bindings) - -## key_notation_to_code(notation) [](#method-i-key_notation_to_code) - -## keymap() [](#method-i-keymap) - -## loaded?() [](#method-i-loaded?) - -**@return** [Boolean] - -## parse_key_binding(key, func_name) [](#method-i-parse_key_binding) - -## parse_keyseq(str) [](#method-i-parse_keyseq) - -## read(filenil) [](#method-i-read) - -## read_lines(lines, filenil) [](#method-i-read_lines) - -## reload() [](#method-i-reload) - -## reset() [](#method-i-reset) - -## reset_oneshot_key_bindings() [](#method-i-reset_oneshot_key_bindings) - -## reset_variables() [](#method-i-reset_variables) - -## retrieve_string(str) [](#method-i-retrieve_string) - diff --git a/example/ruby/Reline/Config/InvalidInputrc.md b/example/ruby/Reline/Config/InvalidInputrc.md deleted file mode 100644 index 1219a94..0000000 --- a/example/ruby/Reline/Config/InvalidInputrc.md +++ /dev/null @@ -1,14 +0,0 @@ -# Exception: Reline::Config::InvalidInputrc -**Inherits:** RuntimeError - - - - -# Attributes -## file[RW] [](#attribute-i-file) -Returns the value of attribute file. - -## lineno[RW] [](#attribute-i-lineno) -Returns the value of attribute lineno. - - diff --git a/example/ruby/Reline/Config/Test.md b/example/ruby/Reline/Config/Test.md deleted file mode 100644 index ddd15c7..0000000 --- a/example/ruby/Reline/Config/Test.md +++ /dev/null @@ -1,118 +0,0 @@ -# Class: Reline::Config::Test -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## additional_key_bindings(keymap_label) [](#method-i-additional_key_bindings) - -## get_config_variable(variable) [](#method-i-get_config_variable) - -## registered_key_bindings(keys) [](#method-i-registered_key_bindings) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_additional_key_bindings() [](#method-i-test_additional_key_bindings) - -## test_additional_key_bindings_for_auxiliary_emacs_keymaps() [](#method-i-test_additional_key_bindings_for_auxiliary_emacs_keymaps) - -## test_additional_key_bindings_for_other_keymap() [](#method-i-test_additional_key_bindings_for_other_keymap) - -## test_additional_key_bindings_with_nesting_and_comment_out() [](#method-i-test_additional_key_bindings_with_nesting_and_comment_out) - -## test_bind_key() [](#method-i-test_bind_key) - -## test_bind_key_with_ctrl_chars() [](#method-i-test_bind_key_with_ctrl_chars) - -## test_bind_key_with_ctrl_meta_chars() [](#method-i-test_bind_key_with_ctrl_meta_chars) - -## test_bind_key_with_escaped_chars() [](#method-i-test_bind_key_with_escaped_chars) - -## test_bind_key_with_hexadecimal_number() [](#method-i-test_bind_key_with_hexadecimal_number) - -## test_bind_key_with_macro() [](#method-i-test_bind_key_with_macro) - -## test_bind_key_with_meta_chars() [](#method-i-test_bind_key_with_meta_chars) - -## test_bind_key_with_octal_number() [](#method-i-test_bind_key_with_octal_number) - -## test_default_key_bindings() [](#method-i-test_default_key_bindings) - -## test_else() [](#method-i-test_else) - -## test_empty_inputrc() [](#method-i-test_empty_inputrc) - -## test_empty_inputrc_env() [](#method-i-test_empty_inputrc_env) - -## test_empty_xdg_config_home() [](#method-i-test_empty_xdg_config_home) - -## test_encoding_is_ascii() [](#method-i-test_encoding_is_ascii) - -## test_encoding_is_not_ascii() [](#method-i-test_encoding_is_not_ascii) - -## test_history_size() [](#method-i-test_history_size) - -## test_if() [](#method-i-test_if) - -## test_if_with_false() [](#method-i-test_if_with_false) - -## test_if_with_indent() [](#method-i-test_if_with_indent) - -## test_if_with_invalid_mode() [](#method-i-test_if_with_invalid_mode) - -## test_if_with_mode() [](#method-i-test_if_with_mode) - -## test_if_without_else_condition() [](#method-i-test_if_without_else_condition) - -## test_include() [](#method-i-test_include) - -## test_include_expand_path() [](#method-i-test_include_expand_path) - -## test_inputrc() [](#method-i-test_inputrc) - -## test_inputrc_raw_value() [](#method-i-test_inputrc_raw_value) - -## test_inputrc_with_eucjp() [](#method-i-test_inputrc_with_eucjp) - -## test_inputrc_with_utf8() [](#method-i-test_inputrc_with_utf8) - -## test_invalid_keystroke() [](#method-i-test_invalid_keystroke) - -## test_key_bindings_with_reset() [](#method-i-test_key_bindings_with_reset) - -## test_mode_label_differs_from_keymap_label() [](#method-i-test_mode_label_differs_from_keymap_label) - -## test_nested_if_else() [](#method-i-test_nested_if_else) - -## test_read_lines() [](#method-i-test_read_lines) - -## test_read_lines_with_variable() [](#method-i-test_read_lines_with_variable) - -## test_relative_xdg_config_home() [](#method-i-test_relative_xdg_config_home) - -## test_reload() [](#method-i-test_reload) - -## test_string_value() [](#method-i-test_string_value) - -## test_string_value_with_brackets() [](#method-i-test_string_value_with_brackets) - -## test_string_value_with_brackets_and_quotes() [](#method-i-test_string_value_with_brackets_and_quotes) - -## test_string_value_with_parens() [](#method-i-test_string_value_with_parens) - -## test_string_value_with_parens_and_quotes() [](#method-i-test_string_value_with_parens_and_quotes) - -## test_unclosed_if() [](#method-i-test_unclosed_if) - -## test_unmatched_else() [](#method-i-test_unmatched_else) - -## test_unmatched_endif() [](#method-i-test_unmatched_endif) - -## test_unquoted_additional_key_bindings() [](#method-i-test_unquoted_additional_key_bindings) - -## test_xdg_config_home() [](#method-i-test_xdg_config_home) - diff --git a/example/ruby/Reline/ConfigEncodingConversionError.md b/example/ruby/Reline/ConfigEncodingConversionError.md deleted file mode 100644 index 3ba257c..0000000 --- a/example/ruby/Reline/ConfigEncodingConversionError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Reline::ConfigEncodingConversionError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Reline/Core.md b/example/ruby/Reline/Core.md deleted file mode 100644 index 11d3417..0000000 --- a/example/ruby/Reline/Core.md +++ /dev/null @@ -1,153 +0,0 @@ -# Class: Reline::Core -**Inherits:** Object - -**Extended by:** Forwardable - - - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -# Attributes -## config[RW] [](#attribute-i-config) -Returns the value of attribute config. - -## key_stroke[RW] [](#attribute-i-key_stroke) -Returns the value of attribute key_stroke. - -## last_incremental_search[RW] [](#attribute-i-last_incremental_search) -Returns the value of attribute last_incremental_search. - -## line_editor[RW] [](#attribute-i-line_editor) -Returns the value of attribute line_editor. - -## output[RW] [](#attribute-i-output) -Returns the value of attribute output. - - -#Instance Methods -## add_dialog_proc(name_sym, p, contextnil) [](#method-i-add_dialog_proc) - -**@raise** [ArgumentError] - -## ambiguous_width() [](#method-i-ambiguous_width) - -## auto_indent_proc=(p) [](#method-i-auto_indent_proc=) - -**@raise** [ArgumentError] - -## basic_quote_characters=(v) [](#method-i-basic_quote_characters=) - -## basic_word_break_characters=(v) [](#method-i-basic_word_break_characters=) - -## completer_quote_characters=(v) [](#method-i-completer_quote_characters=) - -## completer_word_break_characters=(v) [](#method-i-completer_word_break_characters=) - -## completion_append_character=(val) [](#method-i-completion_append_character=) - -## completion_case_fold() [](#method-i-completion_case_fold) - -## completion_case_fold=(v) [](#method-i-completion_case_fold=) - -## completion_proc=(p) [](#method-i-completion_proc=) - -**@raise** [ArgumentError] - -## completion_quote_character() [](#method-i-completion_quote_character) - -## dialog_proc(name_sym) [](#method-i-dialog_proc) - -## dig_perfect_match_proc=(p) [](#method-i-dig_perfect_match_proc=) - -**@raise** [ArgumentError] - -## emacs_editing_mode() [](#method-i-emacs_editing_mode) - -## emacs_editing_mode?() [](#method-i-emacs_editing_mode?) - -**@return** [Boolean] - -## encoding() [](#method-i-encoding) - -## filename_quote_characters=(v) [](#method-i-filename_quote_characters=) - -## get_screen_size() [](#method-i-get_screen_size) - -## initialize() [](#method-i-initialize) - -**@return** [Core] a new instance of Core - -**@yield** [_self] - -**@yieldparam** [Reline::Core] the object that the method was called on - -## input=(val) [](#method-i-input=) - -**@raise** [TypeError] - -## io_gate() [](#method-i-io_gate) - -## output_modifier_proc=(p) [](#method-i-output_modifier_proc=) - -**@raise** [ArgumentError] - -## pre_input_hook=(p) [](#method-i-pre_input_hook=) - -## prompt_proc=(p) [](#method-i-prompt_proc=) - -**@raise** [ArgumentError] - -## readline(prompt'', add_histfalse) [](#method-i-readline) - -## readmultiline(prompt'', add_histfalse, &confirm_multiline_termination) [](#method-i-readmultiline) - -## special_prefixes=(v) [](#method-i-special_prefixes=) - -## vi_editing_mode() [](#method-i-vi_editing_mode) - -## vi_editing_mode?() [](#method-i-vi_editing_mode?) - -**@return** [Boolean] - diff --git a/example/ruby/Reline/Core/DialogProc.md b/example/ruby/Reline/Core/DialogProc.md deleted file mode 100644 index 79ef098..0000000 --- a/example/ruby/Reline/Core/DialogProc.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Reline::Core::DialogProc -**Inherits:** Struct - - - - -# Attributes -## context[RW] [](#attribute-i-context) -Returns the value of attribute context - -**@return** [Object] the current value of context - -## dialog_proc[RW] [](#attribute-i-dialog_proc) -Returns the value of attribute dialog_proc - -**@return** [Object] the current value of dialog_proc - - diff --git a/example/ruby/Reline/CursorPos.md b/example/ruby/Reline/CursorPos.md deleted file mode 100644 index 5e4d5fc..0000000 --- a/example/ruby/Reline/CursorPos.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Reline::CursorPos -**Inherits:** Struct - - - - -# Attributes -## x[RW] [](#attribute-i-x) -Returns the value of attribute x - -**@return** [Object] the current value of x - -## y[RW] [](#attribute-i-y) -Returns the value of attribute y - -**@return** [Object] the current value of y - - diff --git a/example/ruby/Reline/DialogRenderInfo.md b/example/ruby/Reline/DialogRenderInfo.md deleted file mode 100644 index 5a8827b..0000000 --- a/example/ruby/Reline/DialogRenderInfo.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: Reline::DialogRenderInfo -**Inherits:** Struct - - - - -# Attributes -## bg_color[RW] [](#attribute-i-bg_color) -Returns the value of attribute bg_color - -**@return** [Object] the current value of bg_color - -## contents[RW] [](#attribute-i-contents) -Returns the value of attribute contents - -**@return** [Object] the current value of contents - -## face[RW] [](#attribute-i-face) -Returns the value of attribute face - -**@return** [Object] the current value of face - -## height[RW] [](#attribute-i-height) -Returns the value of attribute height - -**@return** [Object] the current value of height - -## pos[RW] [](#attribute-i-pos) -Returns the value of attribute pos - -**@return** [Object] the current value of pos - -## scrollbar[RW] [](#attribute-i-scrollbar) -Returns the value of attribute scrollbar - -**@return** [Object] the current value of scrollbar - -## width[RW] [](#attribute-i-width) -Returns the value of attribute width - -**@return** [Object] the current value of width - - diff --git a/example/ruby/Reline/Dumb.md b/example/ruby/Reline/Dumb.md deleted file mode 100644 index 77af6dc..0000000 --- a/example/ruby/Reline/Dumb.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: Reline::Dumb -**Inherits:** Reline::IO - - - - -# Attributes -## output=[R] [](#attribute-i-output=) -Sets the attribute output - -**@param** [] the value to set the attribute output to. - - -#Instance Methods -## buffered_output() [](#method-i-buffered_output) - -## clear_screen() [](#method-i-clear_screen) - -## cursor_pos() [](#method-i-cursor_pos) - -## deprep(otio) [](#method-i-deprep) - -## dumb?() [](#method-i-dumb?) - -**@return** [Boolean] - -## encoding() [](#method-i-encoding) - -## erase_after_cursor() [](#method-i-erase_after_cursor) - -## get_screen_size() [](#method-i-get_screen_size) - -## getc(_timeout_second) [](#method-i-getc) - -## hide_cursor() [](#method-i-hide_cursor) - -## in_pasting?() [](#method-i-in_pasting?) - -**@return** [Boolean] - -## initialize(encoding:nil) [](#method-i-initialize) - -**@return** [Dumb] a new instance of Dumb - -## input=(val) [](#method-i-input=) - -## move_cursor_column(val) [](#method-i-move_cursor_column) - -## move_cursor_down(val) [](#method-i-move_cursor_down) - -## move_cursor_up(val) [](#method-i-move_cursor_up) - -## prep() [](#method-i-prep) - -## scroll_down(val) [](#method-i-scroll_down) - -## set_default_key_bindings(_) [](#method-i-set_default_key_bindings) - -## set_screen_size(rows, columns) [](#method-i-set_screen_size) - -## set_winch_handler(&handler) [](#method-i-set_winch_handler) - -## show_cursor() [](#method-i-show_cursor) - -## ungetc(c) [](#method-i-ungetc) - -## with_raw_input() [](#method-i-with_raw_input) - -## write(string) [](#method-i-write) - diff --git a/example/ruby/Reline/Face.md b/example/ruby/Reline/Face.md deleted file mode 100644 index dcc6834..0000000 --- a/example/ruby/Reline/Face.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Reline::Face -**Inherits:** Object - - - - -# Class Methods -## [](name ) [](#method-c-[]) -## config(name , &block ) [](#method-c-config) -## configs() [](#method-c-configs) -## force_truecolor() [](#method-c-force_truecolor) -## load_initial_configs() [](#method-c-load_initial_configs) -## reset_to_initial_configs() [](#method-c-reset_to_initial_configs) -## truecolor?() [](#method-c-truecolor?) -**@return** [Boolean] - - diff --git a/example/ruby/Reline/Face/Test.md b/example/ruby/Reline/Face/Test.md deleted file mode 100644 index 3cc497f..0000000 --- a/example/ruby/Reline/Face/Test.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Reline::Face::Test -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/Reline/Face/Test/ConfigTest.md b/example/ruby/Reline/Face/Test/ConfigTest.md deleted file mode 100644 index 2e22c96..0000000 --- a/example/ruby/Reline/Face/Test/ConfigTest.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Reline::Face::Test::ConfigTest -**Inherits:** Reline::Face::Test - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_force_truecolor_reconfigure() [](#method-i-test_force_truecolor_reconfigure) - -## test_format_to_sgr_preserves_order() [](#method-i-test_format_to_sgr_preserves_order) - -## test_format_to_sgr_with_reset() [](#method-i-test_format_to_sgr_with_reset) - -## test_format_to_sgr_with_single_style() [](#method-i-test_format_to_sgr_with_single_style) - -## test_invalid_rgb?() [](#method-i-test_invalid_rgb?) - -**@return** [Boolean] - -## test_rgb?() [](#method-i-test_rgb?) - -**@return** [Boolean] - -## test_sgr_rgb_256color() [](#method-i-test_sgr_rgb_256color) - -## test_sgr_rgb_truecolor() [](#method-i-test_sgr_rgb_truecolor) - -## test_truecolor() [](#method-i-test_truecolor) - diff --git a/example/ruby/Reline/Face/Test/WithInsufficientSetupTest.md b/example/ruby/Reline/Face/Test/WithInsufficientSetupTest.md deleted file mode 100644 index ff45f9b..0000000 --- a/example/ruby/Reline/Face/Test/WithInsufficientSetupTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Reline::Face::Test::WithInsufficientSetupTest -**Inherits:** Reline::Face::Test - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_my_insufficient_config_line() [](#method-i-test_my_insufficient_config_line) - -## test_my_insufficient_configs() [](#method-i-test_my_insufficient_configs) - diff --git a/example/ruby/Reline/Face/Test/WithSetupTest.md b/example/ruby/Reline/Face/Test/WithSetupTest.md deleted file mode 100644 index 1e4e47b..0000000 --- a/example/ruby/Reline/Face/Test/WithSetupTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Reline::Face::Test::WithSetupTest -**Inherits:** Reline::Face::Test - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_my_config_enhanced() [](#method-i-test_my_config_enhanced) - -## test_my_config_line() [](#method-i-test_my_config_line) - -## test_my_configs() [](#method-i-test_my_configs) - -## test_not_respond_to_another_label() [](#method-i-test_not_respond_to_another_label) - -## test_now_there_are_four_configs() [](#method-i-test_now_there_are_four_configs) - -## test_resetting_config_discards_user_defined_configs() [](#method-i-test_resetting_config_discards_user_defined_configs) - diff --git a/example/ruby/Reline/Face/Test/WithoutSetupTest.md b/example/ruby/Reline/Face/Test/WithoutSetupTest.md deleted file mode 100644 index b04d0b5..0000000 --- a/example/ruby/Reline/Face/Test/WithoutSetupTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Reline::Face::Test::WithoutSetupTest -**Inherits:** Reline::Face::Test - - - - - -#Instance Methods -## test_invalid_background_name() [](#method-i-test_invalid_background_name) - -## test_invalid_foreground_name() [](#method-i-test_invalid_foreground_name) - -## test_invalid_keyword() [](#method-i-test_invalid_keyword) - -## test_invalid_style_name() [](#method-i-test_invalid_style_name) - -## test_my_config_default() [](#method-i-test_my_config_default) - -## test_private_constants() [](#method-i-test_private_constants) - -## test_style_does_not_exist() [](#method-i-test_style_does_not_exist) - diff --git a/example/ruby/Reline/History.md b/example/ruby/Reline/History.md deleted file mode 100644 index ca427a1..0000000 --- a/example/ruby/Reline/History.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Reline::History -**Inherits:** Array - - - - - -#Instance Methods -## <<(val) [](#method-i-<<) - -## [](index) [](#method-i-[]) - -## []=(index, val) [](#method-i-[]=) - -## concat(*val) [](#method-i-concat) - -## delete_at(index) [](#method-i-delete_at) - -## initialize(config) [](#method-i-initialize) - -**@return** [History] a new instance of History - -## push(*val) [](#method-i-push) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Reline/History/Test.md b/example/ruby/Reline/History/Test.md deleted file mode 100644 index 2deb043..0000000 --- a/example/ruby/Reline/History/Test.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: Reline::History::Test -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_ancestors() [](#method-i-test_ancestors) - -## test_delete_at() [](#method-i-test_delete_at) - -## test_delete_at__out_of_range() [](#method-i-test_delete_at__out_of_range) - -## test_each() [](#method-i-test_each) - -## test_each__enumerator() [](#method-i-test_each__enumerator) - -## test_empty_p() [](#method-i-test_empty_p) - -## test_get() [](#method-i-test_get) - -## test_get__negative() [](#method-i-test_get__negative) - -## test_get__out_of_range() [](#method-i-test_get__out_of_range) - -## test_history_encoding_conversion() [](#method-i-test_history_encoding_conversion) - -## test_history_size_negative_unlimited() [](#method-i-test_history_size_negative_unlimited) - -## test_history_size_zero() [](#method-i-test_history_size_zero) - -## test_length() [](#method-i-test_length) - -## test_pop() [](#method-i-test_pop) - -## test_push() [](#method-i-test_push) - -## test_push__operator() [](#method-i-test_push__operator) - -## test_push__plural() [](#method-i-test_push__plural) - -## test_set() [](#method-i-test_set) - -## test_set__out_of_range() [](#method-i-test_set__out_of_range) - -## test_shift() [](#method-i-test_shift) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/Reline/IO.md b/example/ruby/Reline/IO.md deleted file mode 100644 index 080b313..0000000 --- a/example/ruby/Reline/IO.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Reline::IO -**Inherits:** Object - - - - -# Class Methods -## decide_io_gate() [](#method-c-decide_io_gate) - -#Instance Methods -## dumb?() [](#method-i-dumb?) - -**@return** [Boolean] - -## read_single_char(keyseq_timeout) [](#method-i-read_single_char) -Read a single encoding valid character from the input. - -## reset_color_sequence() [](#method-i-reset_color_sequence) - -## win?() [](#method-i-win?) - -**@return** [Boolean] - diff --git a/example/ruby/Reline/Key.md b/example/ruby/Reline/Key.md deleted file mode 100644 index e9c2603..0000000 --- a/example/ruby/Reline/Key.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Reline::Key -**Inherits:** Struct - - -EOF key: { char: nil, method_symbol: nil } Other key: { char: String, -method_symbol: Symbol } - - -# Attributes -## char[RW] [](#attribute-i-char) -Returns the value of attribute char - -**@return** [Object] the current value of char - -## method_symbol[RW] [](#attribute-i-method_symbol) -Returns the value of attribute method_symbol - -**@return** [Object] the current value of method_symbol - -## unused_boolean[RW] [](#attribute-i-unused_boolean) -Returns the value of attribute unused_boolean - -**@return** [Object] the current value of unused_boolean - - -#Instance Methods -## match?(sym) [](#method-i-match?) -For dialog_proc `key.match?(dialog.name)` - -**@return** [Boolean] - diff --git a/example/ruby/Reline/KeyActor.md b/example/ruby/Reline/KeyActor.md deleted file mode 100644 index e5196fa..0000000 --- a/example/ruby/Reline/KeyActor.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Reline::KeyActor - - - - - diff --git a/example/ruby/Reline/KeyActor/Base.md b/example/ruby/Reline/KeyActor/Base.md deleted file mode 100644 index 14165d7..0000000 --- a/example/ruby/Reline/KeyActor/Base.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Reline::KeyActor::Base -**Inherits:** Object - - - - - -#Instance Methods -## add(key, func) [](#method-i-add) - -## add_mappings(mappings) [](#method-i-add_mappings) - -## clear() [](#method-i-clear) - -## get(key) [](#method-i-get) - -## initialize(mappingsnil) [](#method-i-initialize) - -**@return** [Base] a new instance of Base - -## matching?(key) [](#method-i-matching?) - -**@return** [Boolean] - diff --git a/example/ruby/Reline/KeyActor/Composite.md b/example/ruby/Reline/KeyActor/Composite.md deleted file mode 100644 index 415a9f8..0000000 --- a/example/ruby/Reline/KeyActor/Composite.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Reline::KeyActor::Composite -**Inherits:** Object - - - - - -#Instance Methods -## get(key) [](#method-i-get) - -## initialize(key_actors) [](#method-i-initialize) - -**@return** [Composite] a new instance of Composite - -## matching?(key) [](#method-i-matching?) - -**@return** [Boolean] - diff --git a/example/ruby/Reline/KeyActor/EmacsTest.md b/example/ruby/Reline/KeyActor/EmacsTest.md deleted file mode 100644 index 07c2762..0000000 --- a/example/ruby/Reline/KeyActor/EmacsTest.md +++ /dev/null @@ -1,245 +0,0 @@ -# Class: Reline::KeyActor::EmacsTest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_autocompletion() [](#method-i-test_autocompletion) - -## test_bracketed_paste_insert() [](#method-i-test_bracketed_paste_insert) - -## test_completion() [](#method-i-test_completion) - -## test_completion_append_character() [](#method-i-test_completion_append_character) - -## test_completion_duplicated_list() [](#method-i-test_completion_duplicated_list) - -## test_completion_in_middle_of_line() [](#method-i-test_completion_in_middle_of_line) - -## test_completion_with_completion_ignore_case() [](#method-i-test_completion_with_completion_ignore_case) - -## test_completion_with_indent() [](#method-i-test_completion_with_indent) - -## test_completion_with_nil_value() [](#method-i-test_completion_with_nil_value) - -## test_completion_with_perfect_match() [](#method-i-test_completion_with_perfect_match) - -## test_completion_with_quote_append() [](#method-i-test_completion_with_quote_append) - -## test_continuous_completion_disabled_with_perfect_match() [](#method-i-test_continuous_completion_disabled_with_perfect_match) - -## test_continuous_completion_with_perfect_match() [](#method-i-test_continuous_completion_with_perfect_match) - -## test_ed_argument_digit_by_meta_num() [](#method-i-test_ed_argument_digit_by_meta_num) - -## test_ed_clear_screen() [](#method-i-test_ed_clear_screen) - -## test_ed_clear_screen_with_inputted() [](#method-i-test_ed_clear_screen_with_inputted) - -## test_ed_delete_prev_word() [](#method-i-test_ed_delete_prev_word) - -## test_ed_delete_prev_word_for_mbchar() [](#method-i-test_ed_delete_prev_word_for_mbchar) - -## test_ed_delete_prev_word_for_mbchar_by_plural_code_points() [](#method-i-test_ed_delete_prev_word_for_mbchar_by_plural_code_points) - -## test_ed_digit() [](#method-i-test_ed_digit) - -## test_ed_insert_for_include_valiation_selector() [](#method-i-test_ed_insert_for_include_valiation_selector) - -## test_ed_insert_for_include_zwj_emoji() [](#method-i-test_ed_insert_for_include_zwj_emoji) -Unicode emoji test - -## test_ed_insert_for_mbchar_by_plural_code_points() [](#method-i-test_ed_insert_for_mbchar_by_plural_code_points) - -## test_ed_insert_for_plural_mbchar_by_plural_code_points() [](#method-i-test_ed_insert_for_plural_mbchar_by_plural_code_points) - -## test_ed_insert_mbchar_one() [](#method-i-test_ed_insert_mbchar_one) - -## test_ed_insert_mbchar_two() [](#method-i-test_ed_insert_mbchar_two) - -## test_ed_insert_one() [](#method-i-test_ed_insert_one) - -## test_ed_insert_two() [](#method-i-test_ed_insert_two) - -## test_ed_kill_line() [](#method-i-test_ed_kill_line) - -## test_ed_move_to_beg() [](#method-i-test_ed_move_to_beg) - -## test_ed_move_to_beg_with_blank() [](#method-i-test_ed_move_to_beg_with_blank) - -## test_ed_move_to_end() [](#method-i-test_ed_move_to_end) - -## test_ed_newline_with_cr() [](#method-i-test_ed_newline_with_cr) - -## test_ed_newline_with_lf() [](#method-i-test_ed_newline_with_lf) - -## test_ed_next_and_prev_char() [](#method-i-test_ed_next_and_prev_char) - -## test_ed_next_and_prev_char_for_mbchar() [](#method-i-test_ed_next_and_prev_char_for_mbchar) - -## test_ed_next_and_prev_char_for_mbchar_by_plural_code_points() [](#method-i-test_ed_next_and_prev_char_for_mbchar_by_plural_code_points) - -## test_ed_quoted_insert() [](#method-i-test_ed_quoted_insert) - -## test_ed_quoted_insert_with_vi_arg() [](#method-i-test_ed_quoted_insert_with_vi_arg) - -## test_ed_search_next_history() [](#method-i-test_ed_search_next_history) - -## test_ed_search_next_history_with_empty() [](#method-i-test_ed_search_next_history_with_empty) - -## test_ed_search_prev_history() [](#method-i-test_ed_search_prev_history) - -## test_ed_search_prev_history_with_empty() [](#method-i-test_ed_search_prev_history_with_empty) - -## test_ed_search_prev_history_without_match() [](#method-i-test_ed_search_prev_history_without_match) - -## test_ed_search_prev_next_history_in_multibyte() [](#method-i-test_ed_search_prev_next_history_in_multibyte) - -## test_ed_transpose_chars() [](#method-i-test_ed_transpose_chars) - -## test_ed_transpose_chars_for_mbchar() [](#method-i-test_ed_transpose_chars_for_mbchar) - -## test_ed_transpose_chars_for_mbchar_by_plural_code_points() [](#method-i-test_ed_transpose_chars_for_mbchar_by_plural_code_points) - -## test_ed_transpose_words() [](#method-i-test_ed_transpose_words) - -## test_ed_transpose_words_for_mbchar() [](#method-i-test_ed_transpose_words_for_mbchar) - -## test_ed_transpose_words_with_one_word() [](#method-i-test_ed_transpose_words_with_one_word) - -## test_ed_transpose_words_with_one_word_for_mbchar() [](#method-i-test_ed_transpose_words_with_one_word_for_mbchar) - -## test_em_capitol_case() [](#method-i-test_em_capitol_case) - -## test_em_capitol_case_with_complex_example() [](#method-i-test_em_capitol_case_with_complex_example) - -## test_em_delete() [](#method-i-test_em_delete) - -## test_em_delete_ends_editing() [](#method-i-test_em_delete_ends_editing) - -## test_em_delete_for_mbchar() [](#method-i-test_em_delete_for_mbchar) - -## test_em_delete_for_mbchar_by_plural_code_points() [](#method-i-test_em_delete_for_mbchar_by_plural_code_points) - -## test_em_delete_next_word() [](#method-i-test_em_delete_next_word) - -## test_em_delete_next_word_for_mbchar() [](#method-i-test_em_delete_next_word_for_mbchar) - -## test_em_delete_next_word_for_mbchar_by_plural_code_points() [](#method-i-test_em_delete_next_word_for_mbchar_by_plural_code_points) - -## test_em_delete_or_list() [](#method-i-test_em_delete_or_list) - -## test_em_delete_prev_char() [](#method-i-test_em_delete_prev_char) - -## test_em_delete_prev_char_for_mbchar() [](#method-i-test_em_delete_prev_char_for_mbchar) - -## test_em_delete_prev_char_for_mbchar_by_plural_code_points() [](#method-i-test_em_delete_prev_char_for_mbchar_by_plural_code_points) - -## test_em_exchange_mark_without_mark() [](#method-i-test_em_exchange_mark_without_mark) - -## test_em_kill_line() [](#method-i-test_em_kill_line) - -## test_em_kill_region() [](#method-i-test_em_kill_region) - -## test_em_kill_region_mbchar() [](#method-i-test_em_kill_region_mbchar) - -## test_em_kill_region_with_kill_ring() [](#method-i-test_em_kill_region_with_kill_ring) - -## test_em_lower_case() [](#method-i-test_em_lower_case) - -## test_em_lower_case_with_complex_example() [](#method-i-test_em_lower_case_with_complex_example) - -## test_em_next_word() [](#method-i-test_em_next_word) - -## test_em_next_word_for_mbchar() [](#method-i-test_em_next_word_for_mbchar) - -## test_em_next_word_for_mbchar_by_plural_code_points() [](#method-i-test_em_next_word_for_mbchar_by_plural_code_points) - -## test_em_prev_word() [](#method-i-test_em_prev_word) - -## test_em_prev_word_for_mbchar() [](#method-i-test_em_prev_word_for_mbchar) - -## test_em_prev_word_for_mbchar_by_plural_code_points() [](#method-i-test_em_prev_word_for_mbchar_by_plural_code_points) - -## test_em_set_mark_and_em_exchange_mark() [](#method-i-test_em_set_mark_and_em_exchange_mark) - -## test_em_upper_case() [](#method-i-test_em_upper_case) - -## test_em_upper_case_with_complex_example() [](#method-i-test_em_upper_case_with_complex_example) - -## test_em_yank_pop() [](#method-i-test_em_yank_pop) - -## test_halfwidth_kana_width_dakuten() [](#method-i-test_halfwidth_kana_width_dakuten) - -## test_ignore_NUL_by_ed_quoted_insert() [](#method-i-test_ignore_NUL_by_ed_quoted_insert) - -## test_incremental_search_history_cancel_by_symbol_key() [](#method-i-test_incremental_search_history_cancel_by_symbol_key) - -## test_incremental_search_history_saves_and_restores_last_input() [](#method-i-test_incremental_search_history_saves_and_restores_last_input) - -## test_input_unknown_char() [](#method-i-test_input_unknown_char) - -## test_key_delete() [](#method-i-test_key_delete) - -## test_key_delete_does_not_end_editing() [](#method-i-test_key_delete_does_not_end_editing) - -## test_key_delete_preserves_cursor() [](#method-i-test_key_delete_preserves_cursor) - -## test_larger_histories_than_history_size() [](#method-i-test_larger_histories_than_history_size) - -## test_modify_lines_with_wrong_rs() [](#method-i-test_modify_lines_with_wrong_rs) - -## test_move_next_and_prev() [](#method-i-test_move_next_and_prev) - -## test_move_next_and_prev_for_mbchar() [](#method-i-test_move_next_and_prev_for_mbchar) - -## test_move_next_and_prev_for_mbchar_by_plural_code_points() [](#method-i-test_move_next_and_prev_for_mbchar_by_plural_code_points) - -## test_move_to_beg_end() [](#method-i-test_move_to_beg_end) - -## test_redo() [](#method-i-test_redo) - -## test_redo_with_cursor_position() [](#method-i-test_redo_with_cursor_position) - -## test_redo_with_many_times() [](#method-i-test_redo_with_many_times) - -## test_redo_with_multiline() [](#method-i-test_redo_with_multiline) - -## test_search_history_back_and_front() [](#method-i-test_search_history_back_and_front) - -## test_search_history_by_last_determined() [](#method-i-test_search_history_by_last_determined) - -## test_search_history_front_and_back() [](#method-i-test_search_history_front_and_back) - -## test_search_history_to_back() [](#method-i-test_search_history_to_back) - -## test_search_history_to_back_in_the_middle_of_histories() [](#method-i-test_search_history_to_back_in_the_middle_of_histories) - -## test_search_history_to_front() [](#method-i-test_search_history_to_front) - -## test_search_history_twice() [](#method-i-test_search_history_twice) - -## test_search_history_with_isearch_terminator() [](#method-i-test_search_history_with_isearch_terminator) - -## test_undo() [](#method-i-test_undo) - -## test_undo_redo_restores_indentation() [](#method-i-test_undo_redo_restores_indentation) - -## test_undo_with_cursor_position() [](#method-i-test_undo_with_cursor_position) - -## test_undo_with_many_times() [](#method-i-test_undo_with_many_times) - -## test_undo_with_multiline() [](#method-i-test_undo_with_multiline) - -## test_unix_line_discard() [](#method-i-test_unix_line_discard) - -## test_vi_editing_mode() [](#method-i-test_vi_editing_mode) - -## test_vi_search_prev() [](#method-i-test_vi_search_prev) - diff --git a/example/ruby/Reline/KeyStroke.md b/example/ruby/Reline/KeyStroke.md deleted file mode 100644 index a023dee..0000000 --- a/example/ruby/Reline/KeyStroke.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Reline::KeyStroke -**Inherits:** Object - - - - -# Attributes -## encoding[RW] [](#attribute-i-encoding) -Returns the value of attribute encoding. - - -#Instance Methods -## expand(input) [](#method-i-expand) - -## initialize(config, encoding) [](#method-i-initialize) - -**@return** [KeyStroke] a new instance of KeyStroke - -## match_status(input) [](#method-i-match_status) - diff --git a/example/ruby/Reline/KeyStroke/Test.md b/example/ruby/Reline/KeyStroke/Test.md deleted file mode 100644 index dea3bd4..0000000 --- a/example/ruby/Reline/KeyStroke/Test.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Reline::KeyStroke::Test -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## encoding() [](#method-i-encoding) - -## test_expand() [](#method-i-test_expand) - -## test_match_status() [](#method-i-test_match_status) - -## test_match_unknown() [](#method-i-test_match_unknown) - -## test_multibyte_matching() [](#method-i-test_multibyte_matching) - -## test_oneshot_key_bindings() [](#method-i-test_oneshot_key_bindings) - diff --git a/example/ruby/Reline/KillRing.md b/example/ruby/Reline/KillRing.md deleted file mode 100644 index 200c02c..0000000 --- a/example/ruby/Reline/KillRing.md +++ /dev/null @@ -1,2082 +0,0 @@ -# Class: Reline::KillRing -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## append(string, before_pfalse) [](#method-i-append) - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(max1024) [](#method-i-initialize) - -**@return** [KillRing] a new instance of KillRing - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## process() [](#method-i-process) - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## yank() [](#method-i-yank) - -## yank_pop() [](#method-i-yank_pop) - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Reline/KillRing/RingBuffer.md b/example/ruby/Reline/KillRing/RingBuffer.md deleted file mode 100644 index d00f5ab..0000000 --- a/example/ruby/Reline/KillRing/RingBuffer.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Reline::KillRing::RingBuffer -**Inherits:** Object - - - - -# Attributes -## head[RW] [](#attribute-i-head) -Returns the value of attribute head. - -## size[RW] [](#attribute-i-size) -Returns the value of attribute size. - - -#Instance Methods -## <<(point) [](#method-i-<<) - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## initialize(max1024) [](#method-i-initialize) - -**@return** [RingBuffer] a new instance of RingBuffer - diff --git a/example/ruby/Reline/KillRing/RingPoint.md b/example/ruby/Reline/KillRing/RingPoint.md deleted file mode 100644 index 991def5..0000000 --- a/example/ruby/Reline/KillRing/RingPoint.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Reline::KillRing::RingPoint -**Inherits:** Struct - - - - -# Attributes -## backward[RW] [](#attribute-i-backward) -Returns the value of attribute backward - -**@return** [Object] the current value of backward - -## forward[RW] [](#attribute-i-forward) -Returns the value of attribute forward - -**@return** [Object] the current value of forward - -## str[RW] [](#attribute-i-str) -Returns the value of attribute str - -**@return** [Object] the current value of str - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(str) [](#method-i-initialize) - -**@return** [RingPoint] a new instance of RingPoint - diff --git a/example/ruby/Reline/KillRing/State.md b/example/ruby/Reline/KillRing/State.md deleted file mode 100644 index 52b5eb8..0000000 --- a/example/ruby/Reline/KillRing/State.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Reline::KillRing::State - - - - - diff --git a/example/ruby/Reline/KillRing/Test.md b/example/ruby/Reline/KillRing/Test.md deleted file mode 100644 index c1bc238..0000000 --- a/example/ruby/Reline/KillRing/Test.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Reline::KillRing::Test -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_append_after() [](#method-i-test_append_after) - -## test_append_before() [](#method-i-test_append_before) - -## test_append_chain_two() [](#method-i-test_append_chain_two) - -## test_append_complex_chain() [](#method-i-test_append_complex_chain) - -## test_append_four_with_max_two() [](#method-i-test_append_four_with_max_two) - -## test_append_one() [](#method-i-test_append_one) - -## test_append_three() [](#method-i-test_append_three) - -## test_append_three_with_max_two() [](#method-i-test_append_three_with_max_two) - -## test_append_two() [](#method-i-test_append_two) - -## test_enumerable() [](#method-i-test_enumerable) - diff --git a/example/ruby/Reline/LineEditor.md b/example/ruby/Reline/LineEditor.md deleted file mode 100644 index 15dafac..0000000 --- a/example/ruby/Reline/LineEditor.md +++ /dev/null @@ -1,154 +0,0 @@ -# Class: Reline::LineEditor -**Inherits:** Object - - - - -# Attributes -## auto_indent_proc[RW] [](#attribute-i-auto_indent_proc) -Returns the value of attribute auto_indent_proc. - -## byte_pointer[RW] [](#attribute-i-byte_pointer) -TODO: Use "private alias_method" idiom after drop Ruby 2.5. - -## completion_append_character[RW] [](#attribute-i-completion_append_character) -Returns the value of attribute completion_append_character. - -## completion_proc[RW] [](#attribute-i-completion_proc) -Returns the value of attribute completion_proc. - -## confirm_multiline_termination_proc[RW] [](#attribute-i-confirm_multiline_termination_proc) -Returns the value of attribute confirm_multiline_termination_proc. - -## dig_perfect_match_proc[RW] [](#attribute-i-dig_perfect_match_proc) -Returns the value of attribute dig_perfect_match_proc. - -## output_modifier_proc[RW] [](#attribute-i-output_modifier_proc) -Returns the value of attribute output_modifier_proc. - -## prompt_proc[RW] [](#attribute-i-prompt_proc) -Returns the value of attribute prompt_proc. - - -#Instance Methods -## add_dialog_proc(name, p, contextnil) [](#method-i-add_dialog_proc) - -## calculate_overlay_levels(overlay_levels) [](#method-i-calculate_overlay_levels) - -## call_completion_proc(pre, target, post, quote) [](#method-i-call_completion_proc) - -## call_completion_proc_with_checking_args(pre, target, post) [](#method-i-call_completion_proc_with_checking_args) - -## clear_dialogs() [](#method-i-clear_dialogs) - -## confirm_multiline_termination() [](#method-i-confirm_multiline_termination) - -## current_byte_pointer_cursor() [](#method-i-current_byte_pointer_cursor) - -## current_line() [](#method-i-current_line) - -## delete_text(startnil, lengthnil) [](#method-i-delete_text) - -## dialog_proc_scope_completion_journey_data() [](#method-i-dialog_proc_scope_completion_journey_data) - -## editing_mode() [](#method-i-editing_mode) - -## encoding() [](#method-i-encoding) - -## eof?() [](#method-i-eof?) - -**@return** [Boolean] - -## finalize() [](#method-i-finalize) - -## finish() [](#method-i-finish) - -## finished?() [](#method-i-finished?) - -**@return** [Boolean] - -## handle_signal() [](#method-i-handle_signal) - -## initialize(config) [](#method-i-initialize) - -**@return** [LineEditor] a new instance of LineEditor - -## input_key(key) [](#method-i-input_key) - -## insert_multiline_text(text) [](#method-i-insert_multiline_text) - -## insert_text(text) [](#method-i-insert_text) - -## io_gate() [](#method-i-io_gate) - -## line() [](#method-i-line) - -## modified_lines() [](#method-i-modified_lines) - -## multiline_off() [](#method-i-multiline_off) - -## multiline_on() [](#method-i-multiline_on) - -## print_nomultiline_prompt() [](#method-i-print_nomultiline_prompt) - -## prompt_list() [](#method-i-prompt_list) - -## push_input_lines() [](#method-i-push_input_lines) - -## render() [](#method-i-render) - -## render_finished() [](#method-i-render_finished) - -## render_line_differential(old_items, new_items) [](#method-i-render_line_differential) - -## rerender() [](#method-i-rerender) - -## reset(prompt'') [](#method-i-reset) - -## reset_line() [](#method-i-reset_line) - -## reset_variables(prompt'') [](#method-i-reset_variables) - -## rest_height(wrapped_cursor_y) [](#method-i-rest_height) - -## retrieve_completion_block() [](#method-i-retrieve_completion_block) - -## save_old_buffer() [](#method-i-save_old_buffer) - -## screen_height() [](#method-i-screen_height) - -## screen_scroll_top() [](#method-i-screen_scroll_top) - -## screen_width() [](#method-i-screen_width) - -## scroll_into_view() [](#method-i-scroll_into_view) - -## set_current_line(line, byte_pointernil) [](#method-i-set_current_line) - -## set_pasting_state(in_pasting) [](#method-i-set_pasting_state) - -## set_signal_handlers() [](#method-i-set_signal_handlers) - -## test_menu_info_format() [](#method-i-test_menu_info_format) - -## trim_input_lines() [](#method-i-trim_input_lines) - -## update(key) [](#method-i-update) - -## update_dialogs(keynil) [](#method-i-update_dialogs) - -## upper_space_height(wrapped_cursor_y) [](#method-i-upper_space_height) - -## whole_buffer() [](#method-i-whole_buffer) - -## whole_lines() [](#method-i-whole_lines) - -## with_cache(key, *deps) [](#method-i-with_cache) - -## wrap_method_call(method_symbol, method_obj, key, with_operatorfalse) [](#method-i-wrap_method_call) - -## wrapped_cursor_position() [](#method-i-wrapped_cursor_position) -Calculate cursor position in word wrapped content. - -## wrapped_prompt_and_input_lines() [](#method-i-wrapped_prompt_and_input_lines) - diff --git a/example/ruby/Reline/LineEditor/CompletionBlockTest.md b/example/ruby/Reline/LineEditor/CompletionBlockTest.md deleted file mode 100644 index 38a7899..0000000 --- a/example/ruby/Reline/LineEditor/CompletionBlockTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Reline::LineEditor::CompletionBlockTest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## retrieve_completion_block(lines, line_index, byte_pointer) [](#method-i-retrieve_completion_block) - -## retrieve_completion_quote(line) [](#method-i-retrieve_completion_quote) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_retrieve_completion_block() [](#method-i-test_retrieve_completion_block) - -## test_retrieve_completion_block_with_quote_characters() [](#method-i-test_retrieve_completion_block_with_quote_characters) - -## test_retrieve_completion_quote() [](#method-i-test_retrieve_completion_quote) - diff --git a/example/ruby/Reline/LineEditor/CompletionJourneyState.md b/example/ruby/Reline/LineEditor/CompletionJourneyState.md deleted file mode 100644 index 7829af7..0000000 --- a/example/ruby/Reline/LineEditor/CompletionJourneyState.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Reline::LineEditor::CompletionJourneyState -**Inherits:** Struct - - - - -# Attributes -## line_index[RW] [](#attribute-i-line_index) -Returns the value of attribute line_index - -**@return** [Object] the current value of line_index - -## list[RW] [](#attribute-i-list) -Returns the value of attribute list - -**@return** [Object] the current value of list - -## pointer[RW] [](#attribute-i-pointer) -Returns the value of attribute pointer - -**@return** [Object] the current value of pointer - -## post[RW] [](#attribute-i-post) -Returns the value of attribute post - -**@return** [Object] the current value of post - -## pre[RW] [](#attribute-i-pre) -Returns the value of attribute pre - -**@return** [Object] the current value of pre - -## target[RW] [](#attribute-i-target) -Returns the value of attribute target - -**@return** [Object] the current value of target - - diff --git a/example/ruby/Reline/LineEditor/CompletionState.md b/example/ruby/Reline/LineEditor/CompletionState.md deleted file mode 100644 index f455dc1..0000000 --- a/example/ruby/Reline/LineEditor/CompletionState.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Reline::LineEditor::CompletionState - - - - - diff --git a/example/ruby/Reline/LineEditor/CursorPositionTest.md b/example/ruby/Reline/LineEditor/CursorPositionTest.md deleted file mode 100644 index 7a7ccf0..0000000 --- a/example/ruby/Reline/LineEditor/CursorPositionTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Reline::LineEditor::CursorPositionTest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_cursor_position_with_escaped_input() [](#method-i-test_cursor_position_with_escaped_input) - diff --git a/example/ruby/Reline/LineEditor/Dialog.md b/example/ruby/Reline/LineEditor/Dialog.md deleted file mode 100644 index 034d44e..0000000 --- a/example/ruby/Reline/LineEditor/Dialog.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: Reline::LineEditor::Dialog -**Inherits:** Object - - - - -# Attributes -## column[RW] [](#attribute-i-column) -Returns the value of attribute column. - -## contents[RW] [](#attribute-i-contents) -Returns the value of attribute contents. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## pointer[RW] [](#attribute-i-pointer) -Returns the value of attribute pointer. - -## scroll_top[RW] [](#attribute-i-scroll_top) -Returns the value of attribute scroll_top. - -## trap_key[RW] [](#attribute-i-trap_key) -Returns the value of attribute trap_key. - -## vertical_offset[RW] [](#attribute-i-vertical_offset) -Returns the value of attribute vertical_offset. - -## width[RW] [](#attribute-i-width) -Returns the value of attribute width. - - -#Instance Methods -## call(key) [](#method-i-call) - -## initialize(name, config, proc_scope) [](#method-i-initialize) - -**@return** [Dialog] a new instance of Dialog - -## set_cursor_pos(col, row) [](#method-i-set_cursor_pos) - diff --git a/example/ruby/Reline/LineEditor/DialogProcScope.md b/example/ruby/Reline/LineEditor/DialogProcScope.md deleted file mode 100644 index 31dec06..0000000 --- a/example/ruby/Reline/LineEditor/DialogProcScope.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Reline::LineEditor::DialogProcScope -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - -## call_completion_proc_with_checking_args(pre, target, post) [](#method-i-call_completion_proc_with_checking_args) - -## completion_journey_data() [](#method-i-completion_journey_data) - -## config() [](#method-i-config) - -## context() [](#method-i-context) - -## cursor_pos() [](#method-i-cursor_pos) - -## dialog() [](#method-i-dialog) - -## initialize(line_editor, config, proc_to_exec, context) [](#method-i-initialize) - -**@return** [DialogProcScope] a new instance of DialogProcScope - -## just_cursor_moving() [](#method-i-just_cursor_moving) - -## key() [](#method-i-key) - -## preferred_dialog_height() [](#method-i-preferred_dialog_height) - -## retrieve_completion_block(_unusedfalse) [](#method-i-retrieve_completion_block) - -## screen_height() [](#method-i-screen_height) - -## screen_width() [](#method-i-screen_width) - -## set_cursor_pos(col, row) [](#method-i-set_cursor_pos) - -## set_dialog(dialog) [](#method-i-set_dialog) - -## set_key(key) [](#method-i-set_key) - diff --git a/example/ruby/Reline/LineEditor/DialogProcScope/CompletionJourneyData.md b/example/ruby/Reline/LineEditor/DialogProcScope/CompletionJourneyData.md deleted file mode 100644 index fe8e98f..0000000 --- a/example/ruby/Reline/LineEditor/DialogProcScope/CompletionJourneyData.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Reline::LineEditor::DialogProcScope::CompletionJourneyData -**Inherits:** Struct - - - - -# Attributes -## list[RW] [](#attribute-i-list) -Returns the value of attribute list - -**@return** [Object] the current value of list - -## pointer[RW] [](#attribute-i-pointer) -Returns the value of attribute pointer - -**@return** [Object] the current value of pointer - -## postposing[RW] [](#attribute-i-postposing) -Returns the value of attribute postposing - -**@return** [Object] the current value of postposing - -## preposing[RW] [](#attribute-i-preposing) -Returns the value of attribute preposing - -**@return** [Object] the current value of preposing - - diff --git a/example/ruby/Reline/LineEditor/MenuInfo.md b/example/ruby/Reline/LineEditor/MenuInfo.md deleted file mode 100644 index 234ae92..0000000 --- a/example/ruby/Reline/LineEditor/MenuInfo.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Reline::LineEditor::MenuInfo -**Inherits:** Object - - - - -# Attributes -## list[RW] [](#attribute-i-list) -Returns the value of attribute list. - - -#Instance Methods -## initialize(list) [](#method-i-initialize) - -**@return** [MenuInfo] a new instance of MenuInfo - -## lines(screen_width) [](#method-i-lines) - diff --git a/example/ruby/Reline/LineEditor/RenderLineDifferentialTest.md b/example/ruby/Reline/LineEditor/RenderLineDifferentialTest.md deleted file mode 100644 index 8fcda4d..0000000 --- a/example/ruby/Reline/LineEditor/RenderLineDifferentialTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: Reline::LineEditor::RenderLineDifferentialTest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## assert_output(expected) [](#method-i-assert_output) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_complicated() [](#method-i-test_complicated) - -## test_dialog_appear_disappear() [](#method-i-test_dialog_appear_disappear) - -## test_dialog_change() [](#method-i-test_dialog_change) - -## test_dialog_move() [](#method-i-test_dialog_move) - -## test_line_increase_decrease() [](#method-i-test_line_increase_decrease) - -## test_multibyte() [](#method-i-test_multibyte) - -## test_update_under_dialog() [](#method-i-test_update_under_dialog) - diff --git a/example/ruby/Reline/LineEditor/RenderLineDifferentialTest/TestIO.md b/example/ruby/Reline/LineEditor/RenderLineDifferentialTest/TestIO.md deleted file mode 100644 index bd1847b..0000000 --- a/example/ruby/Reline/LineEditor/RenderLineDifferentialTest/TestIO.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Reline::LineEditor::RenderLineDifferentialTest::TestIO -**Inherits:** Reline::IO - - - - - -#Instance Methods -## erase_after_cursor() [](#method-i-erase_after_cursor) - -## move_cursor_column(col) [](#method-i-move_cursor_column) - -## write(string) [](#method-i-write) - diff --git a/example/ruby/Reline/LineEditor/RenderedScreen.md b/example/ruby/Reline/LineEditor/RenderedScreen.md deleted file mode 100644 index cd4a8a3..0000000 --- a/example/ruby/Reline/LineEditor/RenderedScreen.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: Reline::LineEditor::RenderedScreen -**Inherits:** Struct - - - - -# Attributes -## base_y[RW] [](#attribute-i-base_y) -Returns the value of attribute base_y - -**@return** [Object] the current value of base_y - -## cursor_y[RW] [](#attribute-i-cursor_y) -Returns the value of attribute cursor_y - -**@return** [Object] the current value of cursor_y - -## lines[RW] [](#attribute-i-lines) -Returns the value of attribute lines - -**@return** [Object] the current value of lines - - diff --git a/example/ruby/Reline/LineEditor/StringProcessingTest.md b/example/ruby/Reline/LineEditor/StringProcessingTest.md deleted file mode 100644 index 5c443f2..0000000 --- a/example/ruby/Reline/LineEditor/StringProcessingTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Reline::LineEditor::StringProcessingTest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_calculate_width() [](#method-i-test_calculate_width) - -## test_calculate_width_with_escape_sequence() [](#method-i-test_calculate_width_with_escape_sequence) - -## test_completion_proc_with_preposing_and_postposing() [](#method-i-test_completion_proc_with_preposing_and_postposing) - diff --git a/example/ruby/Reline/MacroTest.md b/example/ruby/Reline/MacroTest.md deleted file mode 100644 index c8b2e04..0000000 --- a/example/ruby/Reline/MacroTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Reline::MacroTest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## input(str) [](#method-i-input) - -## input_key(char, method_symbol:ed_insert) [](#method-i-input_key) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_alias() [](#method-i-test_alias) - -## test_simple_input() [](#method-i-test_simple_input) - diff --git a/example/ruby/Reline/Test.md b/example/ruby/Reline/Test.md deleted file mode 100644 index deb0818..0000000 --- a/example/ruby/Reline/Test.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Reline::Test -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## get_reline_encoding() [](#method-i-get_reline_encoding) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_add_dialog_proc() [](#method-i-test_add_dialog_proc) - -## test_add_dialog_proc_with_context() [](#method-i-test_add_dialog_proc_with_context) - -## test_auto_indent_proc() [](#method-i-test_auto_indent_proc) - -## test_basic_quote_characters() [](#method-i-test_basic_quote_characters) - -## test_basic_word_break_characters() [](#method-i-test_basic_word_break_characters) - -## test_completer_quote_characters() [](#method-i-test_completer_quote_characters) - -## test_completer_word_break_characters() [](#method-i-test_completer_word_break_characters) - -## test_completion_append_character() [](#method-i-test_completion_append_character) - -## test_completion_case_fold() [](#method-i-test_completion_case_fold) - -## test_completion_proc() [](#method-i-test_completion_proc) - -## test_delete_text() [](#method-i-test_delete_text) - -## test_dig_perfect_match_proc() [](#method-i-test_dig_perfect_match_proc) - -## test_dumb_terminal() [](#method-i-test_dumb_terminal) - -## test_emacs_editing_mode() [](#method-i-test_emacs_editing_mode) - -## test_filename_quote_characters() [](#method-i-test_filename_quote_characters) - -## test_insert_text() [](#method-i-test_insert_text) - -## test_output_modifier_proc() [](#method-i-test_output_modifier_proc) - -## test_pre_input_hook() [](#method-i-test_pre_input_hook) - -## test_print_prompt_before_everything_else() [](#method-i-test_print_prompt_before_everything_else) - -## test_prompt_proc() [](#method-i-test_prompt_proc) - -## test_read_eof_returns_input() [](#method-i-test_read_eof_returns_input) - -## test_read_eof_returns_nil_if_empty() [](#method-i-test_read_eof_returns_nil_if_empty) - -## test_read_io() [](#method-i-test_read_io) - -## test_readline() [](#method-i-test_readline) - -## test_readmultiline() [](#method-i-test_readmultiline) - -## test_require_reline_should_not_trigger_winsize() [](#method-i-test_require_reline_should_not_trigger_winsize) - -## test_set_input_and_output() [](#method-i-test_set_input_and_output) - -## test_special_prefixes() [](#method-i-test_special_prefixes) - -## test_tty_amibuous_width() [](#method-i-test_tty_amibuous_width) - -## test_vi_editing_mode() [](#method-i-test_vi_editing_mode) - -## win?() [](#method-i-win?) - -**@return** [Boolean] - diff --git a/example/ruby/Reline/Test/DummyCallbackObject.md b/example/ruby/Reline/Test/DummyCallbackObject.md deleted file mode 100644 index a4659ca..0000000 --- a/example/ruby/Reline/Test/DummyCallbackObject.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Reline::Test::DummyCallbackObject -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - diff --git a/example/ruby/Reline/TestCase.md b/example/ruby/Reline/TestCase.md deleted file mode 100644 index a838ebf..0000000 --- a/example/ruby/Reline/TestCase.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Reline::TestCase -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_byte_pointer_size(expected) [](#method-i-assert_byte_pointer_size) - -## assert_key_binding(input, method_symbol, editing_modes[:emacs, :vi_insert, :vi_command]) [](#method-i-assert_key_binding) - -## assert_line_around_cursor(before, after) [](#method-i-assert_line_around_cursor) - -## assert_line_index(expected) [](#method-i-assert_line_index) - -## assert_whole_lines(expected) [](#method-i-assert_whole_lines) - -## input_key_by_symbol(method_symbol, char:nil, csi:false) [](#method-i-input_key_by_symbol) - -## input_keys(input, converttrue) [](#method-i-input_keys) - -## input_raw_keys(input, converttrue) [](#method-i-input_raw_keys) - -## set_line_around_cursor(before, after) [](#method-i-set_line_around_cursor) - diff --git a/example/ruby/Reline/TestKey.md b/example/ruby/Reline/TestKey.md deleted file mode 100644 index 70616ca..0000000 --- a/example/ruby/Reline/TestKey.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Reline::TestKey -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## test_match_symbol() [](#method-i-test_match_symbol) - diff --git a/example/ruby/Reline/Unicode.md b/example/ruby/Reline/Unicode.md deleted file mode 100644 index 15b6ec5..0000000 --- a/example/ruby/Reline/Unicode.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Reline::Unicode -**Inherits:** Object - - - - -# Class Methods -## calculate_width(str , allow_escape_code false) [](#method-c-calculate_width) -## common_prefix(list , ignore_case: false) [](#method-c-common_prefix) -## ed_transpose_words(line , byte_pointer ) [](#method-c-ed_transpose_words) -## em_backward_word(line , byte_pointer ) [](#method-c-em_backward_word) -## em_big_backward_word(line , byte_pointer ) [](#method-c-em_big_backward_word) -## em_forward_word(line , byte_pointer ) [](#method-c-em_forward_word) -## em_forward_word_with_capitalization(line , byte_pointer ) [](#method-c-em_forward_word_with_capitalization) -## escape_for_print(str ) [](#method-c-escape_for_print) -## get_mbchar_width(mbchar ) [](#method-c-get_mbchar_width) -## get_next_mbchar_size(line , byte_pointer ) [](#method-c-get_next_mbchar_size) -## get_prev_mbchar_size(line , byte_pointer ) [](#method-c-get_prev_mbchar_size) -## safe_encode(str , encoding ) [](#method-c-safe_encode) -## space_character?(s ) [](#method-c-space_character?) -**@return** [Boolean] - -## split_by_width(str , max_width ) [](#method-c-split_by_width) -This method is used by IRB -## split_line_by_width(str , max_width , encoding str.encoding, offset: 0) [](#method-c-split_line_by_width) -## strip_non_printing_start_end(prompt ) [](#method-c-strip_non_printing_start_end) -## take_mbchar_range(str , start_col , width , cover_begin: false, cover_end: false, padding: false) [](#method-c-take_mbchar_range) -## take_range(str , start_col , max_width ) [](#method-c-take_range) -Take a chunk of a String cut by width with escape sequences. -## vi_backward_word(line , byte_pointer ) [](#method-c-vi_backward_word) -## vi_big_backward_word(line , byte_pointer ) [](#method-c-vi_big_backward_word) -## vi_big_forward_end_word(line , byte_pointer ) [](#method-c-vi_big_forward_end_word) -## vi_big_forward_word(line , byte_pointer ) [](#method-c-vi_big_forward_word) -## vi_first_print(line ) [](#method-c-vi_first_print) -## vi_forward_end_word(line , byte_pointer ) [](#method-c-vi_forward_end_word) -## vi_forward_word(line , byte_pointer , drop_terminate_spaces false) [](#method-c-vi_forward_word) -## word_character?(s ) [](#method-c-word_character?) -**@return** [Boolean] - - diff --git a/example/ruby/Reline/Unicode/EastAsianWidth.md b/example/ruby/Reline/Unicode/EastAsianWidth.md deleted file mode 100644 index afee590..0000000 --- a/example/ruby/Reline/Unicode/EastAsianWidth.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Reline::Unicode::EastAsianWidth -**Inherits:** Object - - - - - diff --git a/example/ruby/Reline/Unicode/Test.md b/example/ruby/Reline/Unicode/Test.md deleted file mode 100644 index 3ec184c..0000000 --- a/example/ruby/Reline/Unicode/Test.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: Reline::Unicode::Test -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_ambiguous_width() [](#method-i-test_ambiguous_width) - -## test_calculate_width() [](#method-i-test_calculate_width) - -## test_character_type() [](#method-i-test_character_type) - -## test_common_prefix() [](#method-i-test_common_prefix) - -## test_csi_regexp() [](#method-i-test_csi_regexp) - -## test_ed_transpose_words() [](#method-i-test_ed_transpose_words) - -## test_em_backward_word() [](#method-i-test_em_backward_word) - -## test_em_big_backward_word() [](#method-i-test_em_big_backward_word) - -## test_em_forward_word() [](#method-i-test_em_forward_word) - -## test_em_forward_word_with_capitalization() [](#method-i-test_em_forward_word_with_capitalization) - -## test_encoding_conversion() [](#method-i-test_encoding_conversion) - -## test_get_mbchar_width() [](#method-i-test_get_mbchar_width) - -## test_nonprinting_start_end() [](#method-i-test_nonprinting_start_end) - -## test_osc_regexp() [](#method-i-test_osc_regexp) - -## test_split_by_width() [](#method-i-test_split_by_width) - -## test_split_line_by_width() [](#method-i-test_split_line_by_width) - -## test_split_line_by_width_csi_reset_sgr_optimization() [](#method-i-test_split_line_by_width_csi_reset_sgr_optimization) - -## test_strip_non_printing_start_end() [](#method-i-test_strip_non_printing_start_end) - -## test_take_mbchar_range() [](#method-i-test_take_mbchar_range) - -## test_take_range() [](#method-i-test_take_range) - -## test_vi_backward_word() [](#method-i-test_vi_backward_word) - -## test_vi_big_backward_word() [](#method-i-test_vi_big_backward_word) - -## test_vi_big_forward_end_word() [](#method-i-test_vi_big_forward_end_word) - -## test_vi_big_forward_word() [](#method-i-test_vi_big_forward_word) - -## test_vi_first_print() [](#method-i-test_vi_first_print) - -## test_vi_forward_end_word() [](#method-i-test_vi_forward_end_word) - -## test_vi_forward_word() [](#method-i-test_vi_forward_word) - diff --git a/example/ruby/Reline/ViInsertTest.md b/example/ruby/Reline/ViInsertTest.md deleted file mode 100644 index 6ab3bbe..0000000 --- a/example/ruby/Reline/ViInsertTest.md +++ /dev/null @@ -1,174 +0,0 @@ -# Class: Reline::ViInsertTest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## editing_mode_label() [](#method-i-editing_mode_label) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_autocompletion_with_upward_navigation() [](#method-i-test_autocompletion_with_upward_navigation) - -## test_autocompletion_with_upward_navigation_and_menu_complete_backward() [](#method-i-test_autocompletion_with_upward_navigation_and_menu_complete_backward) - -## test_cancel_waiting_with_symbol_key() [](#method-i-test_cancel_waiting_with_symbol_key) - -## test_completion() [](#method-i-test_completion) - -## test_completion_journey() [](#method-i-test_completion_journey) - -## test_completion_journey_in_middle_of_line() [](#method-i-test_completion_journey_in_middle_of_line) - -## test_completion_journey_reverse() [](#method-i-test_completion_journey_reverse) - -## test_completion_with_disable_completion() [](#method-i-test_completion_with_disable_completion) - -## test_ed_delete_next_char_at_eol() [](#method-i-test_ed_delete_next_char_at_eol) - -## test_ed_delete_prev_char() [](#method-i-test_ed_delete_prev_char) - -## test_ed_delete_prev_word() [](#method-i-test_ed_delete_prev_word) - -## test_ed_delete_prev_word_for_mbchar() [](#method-i-test_ed_delete_prev_word_for_mbchar) - -## test_ed_delete_prev_word_for_mbchar_by_plural_code_points() [](#method-i-test_ed_delete_prev_word_for_mbchar_by_plural_code_points) - -## test_ed_insert_for_mbchar_by_plural_code_points() [](#method-i-test_ed_insert_for_mbchar_by_plural_code_points) - -## test_ed_insert_for_plural_mbchar_by_plural_code_points() [](#method-i-test_ed_insert_for_plural_mbchar_by_plural_code_points) - -## test_ed_insert_ignore_in_vi_command() [](#method-i-test_ed_insert_ignore_in_vi_command) - -## test_ed_insert_mbchar_one() [](#method-i-test_ed_insert_mbchar_one) - -## test_ed_insert_mbchar_two() [](#method-i-test_ed_insert_mbchar_two) - -## test_ed_insert_one() [](#method-i-test_ed_insert_one) - -## test_ed_insert_two() [](#method-i-test_ed_insert_two) - -## test_ed_move_to_beg() [](#method-i-test_ed_move_to_beg) - -## test_ed_newline_with_cr() [](#method-i-test_ed_newline_with_cr) - -## test_ed_newline_with_lf() [](#method-i-test_ed_newline_with_lf) - -## test_ed_next_char() [](#method-i-test_ed_next_char) - -## test_ed_prev_char() [](#method-i-test_ed_prev_char) - -## test_ed_quoted_insert() [](#method-i-test_ed_quoted_insert) - -## test_ed_quoted_insert_with_vi_arg() [](#method-i-test_ed_quoted_insert_with_vi_arg) - -## test_emacs_editing_mode() [](#method-i-test_emacs_editing_mode) - -## test_history() [](#method-i-test_history) - -## test_unimplemented_vi_command_should_be_no_op() [](#method-i-test_unimplemented_vi_command_should_be_no_op) - -## test_vi_add() [](#method-i-test_vi_add) - -## test_vi_add_at_eol() [](#method-i-test_vi_add_at_eol) - -## test_vi_change_meta() [](#method-i-test_vi_change_meta) - -## test_vi_change_meta_with_vi_next_word() [](#method-i-test_vi_change_meta_with_vi_next_word) - -## test_vi_change_to_eol() [](#method-i-test_vi_change_to_eol) - -## test_vi_command_mode() [](#method-i-test_vi_command_mode) - -## test_vi_command_mode_with_input() [](#method-i-test_vi_command_mode_with_input) - -## test_vi_delete_meta() [](#method-i-test_vi_delete_meta) - -## test_vi_delete_meta_nothing() [](#method-i-test_vi_delete_meta_nothing) - -## test_vi_delete_meta_with_arg() [](#method-i-test_vi_delete_meta_with_arg) - -## test_vi_delete_meta_with_vi_next_char() [](#method-i-test_vi_delete_meta_with_vi_next_char) - -## test_vi_delete_meta_with_vi_next_word_at_eol() [](#method-i-test_vi_delete_meta_with_vi_next_word_at_eol) - -## test_vi_delete_next_char() [](#method-i-test_vi_delete_next_char) - -## test_vi_delete_next_char_for_mbchar() [](#method-i-test_vi_delete_next_char_for_mbchar) - -## test_vi_delete_next_char_for_mbchar_by_plural_code_points() [](#method-i-test_vi_delete_next_char_for_mbchar_by_plural_code_points) - -## test_vi_delete_prev_char() [](#method-i-test_vi_delete_prev_char) - -## test_vi_delete_prev_char_for_mbchar() [](#method-i-test_vi_delete_prev_char_for_mbchar) - -## test_vi_delete_prev_char_for_mbchar_by_plural_code_points() [](#method-i-test_vi_delete_prev_char_for_mbchar_by_plural_code_points) - -## test_vi_end_big_word() [](#method-i-test_vi_end_big_word) - -## test_vi_end_big_word_with_operator() [](#method-i-test_vi_end_big_word_with_operator) - -## test_vi_end_word() [](#method-i-test_vi_end_word) - -## test_vi_end_word_with_operator() [](#method-i-test_vi_end_word_with_operator) - -## test_vi_first_print() [](#method-i-test_vi_first_print) - -## test_vi_insert() [](#method-i-test_vi_insert) - -## test_vi_insert_at_bol() [](#method-i-test_vi_insert_at_bol) - -## test_vi_kill_line_prev() [](#method-i-test_vi_kill_line_prev) - -## test_vi_list_or_eof() [](#method-i-test_vi_list_or_eof) - -## test_vi_list_or_eof_with_non_empty_line() [](#method-i-test_vi_list_or_eof_with_non_empty_line) - -## test_vi_motion_operators() [](#method-i-test_vi_motion_operators) - -## test_vi_next_char() [](#method-i-test_vi_next_char) - -## test_vi_next_char_with_operator() [](#method-i-test_vi_next_char_with_operator) - -## test_vi_paste_next() [](#method-i-test_vi_paste_next) - -## test_vi_paste_next_for_mbchar() [](#method-i-test_vi_paste_next_for_mbchar) - -## test_vi_paste_next_for_mbchar_by_plural_code_points() [](#method-i-test_vi_paste_next_for_mbchar_by_plural_code_points) - -## test_vi_paste_prev() [](#method-i-test_vi_paste_prev) - -## test_vi_paste_prev_for_mbchar() [](#method-i-test_vi_paste_prev_for_mbchar) - -## test_vi_paste_prev_for_mbchar_by_plural_code_points() [](#method-i-test_vi_paste_prev_for_mbchar_by_plural_code_points) - -## test_vi_prev_char() [](#method-i-test_vi_prev_char) - -## test_vi_prev_next_big_word() [](#method-i-test_vi_prev_next_big_word) - -## test_vi_prev_next_word() [](#method-i-test_vi_prev_next_word) - -## test_vi_replace_char() [](#method-i-test_vi_replace_char) - -## test_vi_replace_char_with_mbchar() [](#method-i-test_vi_replace_char_with_mbchar) - -## test_vi_to_column() [](#method-i-test_vi_to_column) - -## test_vi_to_next_char() [](#method-i-test_vi_to_next_char) - -## test_vi_to_prev_char() [](#method-i-test_vi_to_prev_char) - -## test_vi_waiting_operator_cancel() [](#method-i-test_vi_waiting_operator_cancel) - -## test_vi_waiting_operator_with_waiting_proc() [](#method-i-test_vi_waiting_operator_with_waiting_proc) - -## test_vi_yank() [](#method-i-test_vi_yank) - -## test_vi_yank_nothing() [](#method-i-test_vi_yank_nothing) - -## test_waiting_operator_arg_including_zero() [](#method-i-test_waiting_operator_arg_including_zero) - diff --git a/example/ruby/Reline/Windows.md b/example/ruby/Reline/Windows.md deleted file mode 100644 index 8fc7670..0000000 --- a/example/ruby/Reline/Windows.md +++ /dev/null @@ -1,97 +0,0 @@ -# Class: Reline::Windows -**Inherits:** Reline::IO - - - - -# Attributes -## output=[R] [](#attribute-i-output=) -Sets the attribute output - -**@param** [] the value to set the attribute output to. - - -#Instance Methods -## buffered_output() [](#method-i-buffered_output) - -## check_input_event() [](#method-i-check_input_event) - -## clear_screen() [](#method-i-clear_screen) - -## cursor_pos() [](#method-i-cursor_pos) - -## deprep(otio) [](#method-i-deprep) - -## disable_auto_linewrap(settingtrue, &block) [](#method-i-disable_auto_linewrap) - -## empty_buffer?() [](#method-i-empty_buffer?) - -**@return** [Boolean] - -## encoding() [](#method-i-encoding) - -## erase_after_cursor() [](#method-i-erase_after_cursor) - -## get_console_screen_buffer_info() [](#method-i-get_console_screen_buffer_info) - -## get_screen_size() [](#method-i-get_screen_size) - -## getc(_timeout_second) [](#method-i-getc) - -## hide_cursor() [](#method-i-hide_cursor) - -## in_pasting?() [](#method-i-in_pasting?) - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [Windows] a new instance of Windows - -## move_cursor_column(val) [](#method-i-move_cursor_column) - -## move_cursor_down(val) [](#method-i-move_cursor_down) - -## move_cursor_up(val) [](#method-i-move_cursor_up) - -## msys_tty?(io@hConsoleInputHandle) [](#method-i-msys_tty?) -if @legacy_console - setconsolemode(getconsolemode() | ENABLE_VIRTUAL_TERMINAL_PROCESSING) - @legacy_console = (getconsolemode() & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0) - -end - -**@return** [Boolean] - -## prep() [](#method-i-prep) - -## process_key_event(repeat_count, virtual_key_code, virtual_scan_code, char_code, control_key_state) [](#method-i-process_key_event) - -## scroll_down(x) [](#method-i-scroll_down) -This only works when the cursor is at the bottom of the scroll range For more -details, see https://github.com/ruby/reline/pull/577#issuecomment-1646679623 - -## set_default_key_bindings(config) [](#method-i-set_default_key_bindings) - -## set_screen_size(rows, columns) [](#method-i-set_screen_size) - -**@raise** [NotImplementedError] - -## set_winch_handler(&handler) [](#method-i-set_winch_handler) - -## show_cursor() [](#method-i-show_cursor) - -## ungetc(c) [](#method-i-ungetc) - -## win?() [](#method-i-win?) - -**@return** [Boolean] - -## win_legacy_console?() [](#method-i-win_legacy_console?) - -**@return** [Boolean] - -## with_raw_input() [](#method-i-with_raw_input) - -## write(string) [](#method-i-write) - diff --git a/example/ruby/Reline/Windows/KeyEventRecord.md b/example/ruby/Reline/Windows/KeyEventRecord.md deleted file mode 100644 index 237a366..0000000 --- a/example/ruby/Reline/Windows/KeyEventRecord.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Reline::Windows::KeyEventRecord -**Inherits:** Object - - - - -# Attributes -## char_code[RW] [](#attribute-i-char_code) -Returns the value of attribute char_code. - -## control_key_state[RW] [](#attribute-i-control_key_state) -Returns the value of attribute control_key_state. - -## control_keys[RW] [](#attribute-i-control_keys) -Returns the value of attribute control_keys. - -## virtual_key_code[RW] [](#attribute-i-virtual_key_code) -Returns the value of attribute virtual_key_code. - - -#Instance Methods -## char() [](#method-i-char) - -## enhanced?() [](#method-i-enhanced?) - -**@return** [Boolean] - -## initialize(virtual_key_code, char_code, control_key_state) [](#method-i-initialize) - -**@return** [KeyEventRecord] a new instance of KeyEventRecord - -## match?(control_keys:nil, virtual_key_code:nil, char_code:nil) [](#method-i-match?) -Verifies if the arguments match with this key event. Nil arguments are -ignored, but at least one must be passed as non-nil. To verify that no control -keys were pressed, pass an empty array: `control_keys: []`. - -**@raise** [ArgumentError] - -**@return** [Boolean] - diff --git a/example/ruby/Reline/Windows/KeyEventRecord/Test.md b/example/ruby/Reline/Windows/KeyEventRecord/Test.md deleted file mode 100644 index be520cf..0000000 --- a/example/ruby/Reline/Windows/KeyEventRecord/Test.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Reline::Windows::KeyEventRecord::Test -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_doesnt_match_alt() [](#method-i-test_doesnt_match_alt) - -## test_doesnt_match_empty_control_key() [](#method-i-test_doesnt_match_empty_control_key) - -## test_matches__with_no_arguments_raises_error() [](#method-i-test_matches__with_no_arguments_raises_error) - -## test_matches_char_code() [](#method-i-test_matches_char_code) - -## test_matches_control_keys() [](#method-i-test_matches_control_keys) - -## test_matches_control_keys_and_virtual_key_code() [](#method-i-test_matches_control_keys_and_virtual_key_code) - -## test_matches_virtual_key_code() [](#method-i-test_matches_virtual_key_code) - diff --git a/example/ruby/Reline/Windows/Win32API.md b/example/ruby/Reline/Windows/Win32API.md deleted file mode 100644 index a861ed4..0000000 --- a/example/ruby/Reline/Windows/Win32API.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Reline::Windows::Win32API -**Inherits:** Object - - - - - -#Instance Methods -## call(*args) [](#method-i-call) - -## initialize(dllname, func, import, export"0", calltype:stdcall) [](#method-i-initialize) - -**@return** [Win32API] a new instance of Win32API - diff --git a/example/ruby/Reline/WithinPipeTest.md b/example/ruby/Reline/WithinPipeTest.md deleted file mode 100644 index d2caf6e..0000000 --- a/example/ruby/Reline/WithinPipeTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Reline::WithinPipeTest -**Inherits:** Reline::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_delete_text_in_multiline() [](#method-i-test_delete_text_in_multiline) - -## test_macro_commands_for_editing() [](#method-i-test_macro_commands_for_editing) - -## test_macro_commands_for_moving() [](#method-i-test_macro_commands_for_moving) - -## test_simple_input() [](#method-i-test_simple_input) - -## test_unknown_macro() [](#method-i-test_unknown_macro) - diff --git a/example/ruby/RelocationVisitor.md b/example/ruby/RelocationVisitor.md deleted file mode 100644 index 080a3cb..0000000 --- a/example/ruby/RelocationVisitor.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: RelocationVisitor -**Inherits:** Prism::Visitor - - - - -# Attributes -## index[RW] [](#attribute-i-index) -Returns the value of attribute index. - -## repository[RW] [](#attribute-i-repository) -Returns the value of attribute repository. - -## scope[RW] [](#attribute-i-scope) -Returns the value of attribute scope. - - -#Instance Methods -## initialize(index, repository, scope[]) [](#method-i-initialize) - -**@return** [RelocationVisitor] a new instance of RelocationVisitor - -## visit_class_node(node) [](#method-i-visit_class_node) - -## visit_module_node(node) [](#method-i-visit_module_node) - diff --git a/example/ruby/Removal.md b/example/ruby/Removal.md deleted file mode 100644 index e0fa895..0000000 --- a/example/ruby/Removal.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Removal -**Inherits:** Object - - - - -# Attributes -## base[RW] [](#attribute-i-base) -Returns the value of attribute base. - - -#Instance Methods -## directory?(name) [](#method-i-directory?) - -**@return** [Boolean] - -## each_directory() [](#method-i-each_directory) - -## each_file() [](#method-i-each_file) - -## exist?(name) [](#method-i-exist?) - -**@return** [Boolean] - -## glob(pattern, *rest) [](#method-i-glob) - -## initialize(basenil) [](#method-i-initialize) - -**@return** [Removal] a new instance of Removal - -## prefixed(name) [](#method-i-prefixed) - -## rmdir(name) [](#method-i-rmdir) - -## slash(name) [](#method-i-slash) - -## sorted() [](#method-i-sorted) - -## stripped(name) [](#method-i-stripped) - -## unlink(name) [](#method-i-unlink) - diff --git a/example/ruby/RequirePathCheckTest.md b/example/ruby/RequirePathCheckTest.md deleted file mode 100644 index 02819d3..0000000 --- a/example/ruby/RequirePathCheckTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: RequirePathCheckTest -**Inherits:** Test::Unit::TestCase - -**Includes:** DidYouMean::TestHelper - - - - - -#Instance Methods -## assert_correction(expected, array) [](#method-i-assert_correction) - -## test_load_error_from_require_for_nested_files_has_suggestions() [](#method-i-test_load_error_from_require_for_nested_files_has_suggestions) - -## test_load_error_from_require_has_suggestions() [](#method-i-test_load_error_from_require_has_suggestions) - diff --git a/example/ruby/RequirementChecker.md b/example/ruby/RequirementChecker.md deleted file mode 100644 index bc616a5..0000000 --- a/example/ruby/RequirementChecker.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: RequirementChecker -**Inherits:** Proc - - - - -# Class Methods -## against(present ) [](#method-c-against) -# Attributes -## provided[RW] [](#attribute-i-provided) -Returns the value of attribute provided. - - -#Instance Methods -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/RescueSpecs.md b/example/ruby/RescueSpecs.md deleted file mode 100644 index 54a161f..0000000 --- a/example/ruby/RescueSpecs.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: RescueSpecs - - - - -# Class Methods -## begin_else(raise_exception ) [](#method-c-begin_else) -## begin_else_ensure(raise_exception ) [](#method-c-begin_else_ensure) -## begin_else_return(raise_exception ) [](#method-c-begin_else_return) -## begin_else_return_ensure(raise_exception ) [](#method-c-begin_else_return_ensure) -## raise_standard_error() [](#method-c-raise_standard_error) -**@raise** [StandardError] - - diff --git a/example/ruby/RescueSpecs/Captor.md b/example/ruby/RescueSpecs/Captor.md deleted file mode 100644 index ea3a4a2..0000000 --- a/example/ruby/RescueSpecs/Captor.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: RescueSpecs::Captor -**Inherits:** Object - - - - -# Class Methods -## should_capture_exception() [](#method-c-should_capture_exception) -# Attributes -## captured_error[RW] [](#attribute-i-captured_error) -Returns the value of attribute captured_error. - - diff --git a/example/ruby/RescueSpecs/ClassVariableCaptor.md b/example/ruby/RescueSpecs/ClassVariableCaptor.md deleted file mode 100644 index b7b0637..0000000 --- a/example/ruby/RescueSpecs/ClassVariableCaptor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: RescueSpecs::ClassVariableCaptor -**Inherits:** RescueSpecs::Captor - - - - - -#Instance Methods -## capture(msg) [](#method-i-capture) - -## captured_error() [](#method-i-captured_error) - diff --git a/example/ruby/RescueSpecs/ConstantCaptor.md b/example/ruby/RescueSpecs/ConstantCaptor.md deleted file mode 100644 index 47a825e..0000000 --- a/example/ruby/RescueSpecs/ConstantCaptor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: RescueSpecs::ConstantCaptor -**Inherits:** RescueSpecs::Captor - - - - - -#Instance Methods -## capture(msg) [](#method-i-capture) - -## captured_error() [](#method-i-captured_error) - diff --git a/example/ruby/RescueSpecs/GlobalVariableCaptor.md b/example/ruby/RescueSpecs/GlobalVariableCaptor.md deleted file mode 100644 index c28961a..0000000 --- a/example/ruby/RescueSpecs/GlobalVariableCaptor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: RescueSpecs::GlobalVariableCaptor -**Inherits:** RescueSpecs::Captor - - - - - -#Instance Methods -## capture(msg) [](#method-i-capture) - -## captured_error() [](#method-i-captured_error) - diff --git a/example/ruby/RescueSpecs/InstanceVariableCaptor.md b/example/ruby/RescueSpecs/InstanceVariableCaptor.md deleted file mode 100644 index 2f7a65f..0000000 --- a/example/ruby/RescueSpecs/InstanceVariableCaptor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: RescueSpecs::InstanceVariableCaptor -**Inherits:** RescueSpecs::Captor - - - - - -#Instance Methods -## capture(msg) [](#method-i-capture) - diff --git a/example/ruby/RescueSpecs/LocalVariableCaptor.md b/example/ruby/RescueSpecs/LocalVariableCaptor.md deleted file mode 100644 index 5411a48..0000000 --- a/example/ruby/RescueSpecs/LocalVariableCaptor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: RescueSpecs::LocalVariableCaptor -**Inherits:** RescueSpecs::Captor - - - - - -#Instance Methods -## capture(msg) [](#method-i-capture) - diff --git a/example/ruby/RescueSpecs/SafeNavigationSetterCaptor.md b/example/ruby/RescueSpecs/SafeNavigationSetterCaptor.md deleted file mode 100644 index 8ea246f..0000000 --- a/example/ruby/RescueSpecs/SafeNavigationSetterCaptor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: RescueSpecs::SafeNavigationSetterCaptor -**Inherits:** RescueSpecs::Captor - - - - - -#Instance Methods -## capture(msg) [](#method-i-capture) - diff --git a/example/ruby/RescueSpecs/SetterCaptor.md b/example/ruby/RescueSpecs/SetterCaptor.md deleted file mode 100644 index d9a2682..0000000 --- a/example/ruby/RescueSpecs/SetterCaptor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: RescueSpecs::SetterCaptor -**Inherits:** RescueSpecs::Captor - - - - - -#Instance Methods -## capture(msg) [](#method-i-capture) - diff --git a/example/ruby/RescueSpecs/SquareBracketsCaptor.md b/example/ruby/RescueSpecs/SquareBracketsCaptor.md deleted file mode 100644 index f25997a..0000000 --- a/example/ruby/RescueSpecs/SquareBracketsCaptor.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RescueSpecs::SquareBracketsCaptor -**Inherits:** RescueSpecs::Captor - - - - - -#Instance Methods -## []=(key, value) [](#method-i-[]=) - -## capture(msg) [](#method-i-capture) - -## captured_error() [](#method-i-captured_error) - diff --git a/example/ruby/Resolv.md b/example/ruby/Resolv.md deleted file mode 100644 index e1b8726..0000000 --- a/example/ruby/Resolv.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: Resolv -**Inherits:** Object - - -Resolv is a thread-aware DNS resolver library written in Ruby. Resolv can -handle multiple DNS requests concurrently without blocking the entire Ruby -interpreter. - -See also resolv-replace.rb to replace the libc resolver with Resolv. - -Resolv can look up various DNS resources using the DNS module directly. - -Examples: - - p Resolv.getaddress "www.ruby-lang.org" - p Resolv.getname "210.251.121.214" - - Resolv::DNS.open do |dns| - ress = dns.getresources "www.ruby-lang.org", Resolv::DNS::Resource::IN::A - p ress.map(&:address) - ress = dns.getresources "ruby-lang.org", Resolv::DNS::Resource::IN::MX - p ress.map { |r| [r.exchange.to_s, r.preference] } - end - -## Bugs - -* NIS is not supported. -* /etc/nsswitch.conf is not supported. - - -# Class Methods -## each_address(name , &block ) [](#method-c-each_address) -Iterates over all IP addresses for `name`. -## each_name(address , &proc ) [](#method-c-each_name) -Iterates over all hostnames for `address`. -## getaddress(name ) [](#method-c-getaddress) -Looks up the first IP address for `name`. -## getaddresses(name ) [](#method-c-getaddresses) -Looks up all IP address for `name`. -## getname(address ) [](#method-c-getname) -Looks up the hostname of `address`. -## getnames(address ) [](#method-c-getnames) -Looks up all hostnames for `address`. - -#Instance Methods -## each_address(name) [](#method-i-each_address) -Iterates over all IP addresses for `name`. - -## each_name(address) [](#method-i-each_name) -Iterates over all hostnames for `address`. - -## getaddress(name) [](#method-i-getaddress) -Looks up the first IP address for `name`. - -**@raise** [ResolvError] - -## getaddresses(name) [](#method-i-getaddresses) -Looks up all IP address for `name`. - -## getname(address) [](#method-i-getname) -Looks up the hostname of `address`. - -**@raise** [ResolvError] - -## getnames(address) [](#method-i-getnames) -Looks up all hostnames for `address`. - -## initialize(resolvers(arg_not_set = true; nil), use_ipv6:(keyword_not_set = true; nil)) [](#method-i-initialize) -Creates a new Resolv using `resolvers`. - -If `resolvers` is not given, a hash, or `nil`, uses a Hosts resolver and and a -DNS resolver. If `resolvers` is a hash, uses the hash as configuration for -the DNS resolver. - -**@return** [Resolv] a new instance of Resolv - diff --git a/example/ruby/Resolv/DNS.md b/example/ruby/Resolv/DNS.md deleted file mode 100644 index 8257554..0000000 --- a/example/ruby/Resolv/DNS.md +++ /dev/null @@ -1,166 +0,0 @@ -# Class: Resolv::DNS -**Inherits:** Object - - -Resolv::DNS is a DNS stub resolver. - -Information taken from the following places: - -* STD0013 -* RFC 1035 -* ftp://ftp.isi.edu/in-notes/iana/assignments/dns-parameters -* etc. - - -# Class Methods -## allocate_request_id(host , port ) [](#method-c-allocate_request_id) -:nodoc: -## bind_random_port(udpsock , bind_host "0.0.0.0") [](#method-c-bind_random_port) -:nodoc: -## free_request_id(host , port , id ) [](#method-c-free_request_id) -:nodoc: -## open(*args ) [](#method-c-open) -Creates a new DNS resolver. See Resolv::DNS.new for argument details. - -Yields the created DNS resolver to the block, if given, otherwise returns it. -## random(arg ) [](#method-c-random) -:nodoc: - -#Instance Methods -## close() [](#method-i-close) -Closes the DNS resolver. - -## each_address(name) [](#method-i-each_address) -Iterates over all IP addresses for `name` retrieved from the DNS resolver. - -`name` can be a Resolv::DNS::Name or a String. Retrieved addresses will be a -Resolv::IPv4 or Resolv::IPv6 - -## each_name(address) [](#method-i-each_name) -Iterates over all hostnames for `address` retrieved from the DNS resolver. - -`address` must be a Resolv::IPv4, Resolv::IPv6 or a String. Retrieved names -will be Resolv::DNS::Name instances. - -## each_resource(name, typeclass, &proc) [](#method-i-each_resource) -Iterates over all `typeclass` DNS resources for `name`. See #getresource for -argument details. - -## extract_resources(msg, name, typeclass) [](#method-i-extract_resources) -:nodoc: - -## fetch_resource(name, typeclass) [](#method-i-fetch_resource) - -## getaddress(name) [](#method-i-getaddress) -Gets the IP address of `name` from the DNS resolver. - -`name` can be a Resolv::DNS::Name or a String. Retrieved address will be a -Resolv::IPv4 or Resolv::IPv6 - -**@raise** [ResolvError] - -## getaddresses(name) [](#method-i-getaddresses) -Gets all IP addresses for `name` from the DNS resolver. - -`name` can be a Resolv::DNS::Name or a String. Retrieved addresses will be a -Resolv::IPv4 or Resolv::IPv6 - -## getname(address) [](#method-i-getname) -Gets the hostname for `address` from the DNS resolver. - -`address` must be a Resolv::IPv4, Resolv::IPv6 or a String. Retrieved name -will be a Resolv::DNS::Name. - -**@raise** [ResolvError] - -## getnames(address) [](#method-i-getnames) -Gets all hostnames for `address` from the DNS resolver. - -`address` must be a Resolv::IPv4, Resolv::IPv6 or a String. Retrieved names -will be Resolv::DNS::Name instances. - -## getresource(name, typeclass) [](#method-i-getresource) -Look up the `typeclass` DNS resource of `name`. - -`name` must be a Resolv::DNS::Name or a String. - -`typeclass` should be one of the following: - -* Resolv::DNS::Resource::IN::A -* Resolv::DNS::Resource::IN::AAAA -* Resolv::DNS::Resource::IN::ANY -* Resolv::DNS::Resource::IN::CNAME -* Resolv::DNS::Resource::IN::HINFO -* Resolv::DNS::Resource::IN::MINFO -* Resolv::DNS::Resource::IN::MX -* Resolv::DNS::Resource::IN::NS -* Resolv::DNS::Resource::IN::PTR -* Resolv::DNS::Resource::IN::SOA -* Resolv::DNS::Resource::IN::TXT -* Resolv::DNS::Resource::IN::WKS - -Returned resource is represented as a Resolv::DNS::Resource instance, i.e. -Resolv::DNS::Resource::IN::A. - -**@raise** [ResolvError] - -## getresources(name, typeclass) [](#method-i-getresources) -Looks up all `typeclass` DNS resources for `name`. See #getresource for -argument details. - -## initialize(config_infonil) [](#method-i-initialize) -Creates a new DNS resolver. - -`config_info` can be: - -nil -: Uses /etc/resolv.conf. - -String -: Path to a file using /etc/resolv.conf's format. - -Hash -: Must contain :nameserver, :search and :ndots keys. - -:nameserver_port can be used to specify port number of nameserver address. -:raise_timeout_errors can be used to raise timeout errors as exceptions -instead of treating the same as an NXDOMAIN response. - -The value of :nameserver should be an address string or an array of address -strings. -* :nameserver => '8.8.8.8' -* :nameserver => ['8.8.8.8', '8.8.4.4'] - -The value of :nameserver_port should be an array of pair of nameserver address -and port number. -* :nameserver_port => [['8.8.8.8', 53], ['8.8.4.4', 53]] - -Example: - - Resolv::DNS.new(:nameserver => ['210.251.121.21'], - :search => ['ruby-lang.org'], - :ndots => 1) - -**@return** [DNS] a new instance of DNS - -## lazy_initialize() [](#method-i-lazy_initialize) -:nodoc: - -## make_tcp_requester(host, port) [](#method-i-make_tcp_requester) -:nodoc: - -## make_udp_requester() [](#method-i-make_udp_requester) -:nodoc: - -## timeouts=(values) [](#method-i-timeouts=) -Sets the resolver timeouts. This may be a single positive number or an array -of positive numbers representing timeouts in seconds. If an array is -specified, a DNS request will retry and wait for each successive interval in -the array until a successful response is received. Specifying `nil` reverts -to the default timeouts: -5, second = 5 * 2 / nameserver_count, 2 * second, 4 * second -: Example: - - dns.timeouts = 3 - - diff --git a/example/ruby/Resolv/DNS/Config.md b/example/ruby/Resolv/DNS/Config.md deleted file mode 100644 index f93cd1b..0000000 --- a/example/ruby/Resolv/DNS/Config.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Resolv::DNS::Config -**Inherits:** Object - - -:nodoc: - - -# Class Methods -## default_config_hash(filename "/etc/resolv.conf") [](#method-c-default_config_hash) -## parse_resolv_conf(filename ) [](#method-c-parse_resolv_conf) - -#Instance Methods -## generate_candidates(name) [](#method-i-generate_candidates) - -## generate_timeouts() [](#method-i-generate_timeouts) - -## initialize(config_infonil) [](#method-i-initialize) - -**@return** [Config] a new instance of Config - -## lazy_initialize() [](#method-i-lazy_initialize) - -## nameserver_port() [](#method-i-nameserver_port) - -## resolv(name) [](#method-i-resolv) - -## single?() [](#method-i-single?) - -**@return** [Boolean] - -## timeouts=(values) [](#method-i-timeouts=) - -## use_ipv6?() [](#method-i-use_ipv6?) - -**@return** [Boolean] - diff --git a/example/ruby/Resolv/DNS/Config/NXDomain.md b/example/ruby/Resolv/DNS/Config/NXDomain.md deleted file mode 100644 index 487b951..0000000 --- a/example/ruby/Resolv/DNS/Config/NXDomain.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Resolv::DNS::Config::NXDomain -**Inherits:** Resolv::ResolvError - - -Indicates no such domain was found. - - - diff --git a/example/ruby/Resolv/DNS/Config/OtherResolvError.md b/example/ruby/Resolv/DNS/Config/OtherResolvError.md deleted file mode 100644 index 9b058cd..0000000 --- a/example/ruby/Resolv/DNS/Config/OtherResolvError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Resolv::DNS::Config::OtherResolvError -**Inherits:** Resolv::ResolvError - - -Indicates some other unhandled resolver error was encountered. - - - diff --git a/example/ruby/Resolv/DNS/DecodeError.md b/example/ruby/Resolv/DNS/DecodeError.md deleted file mode 100644 index c3e1788..0000000 --- a/example/ruby/Resolv/DNS/DecodeError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Resolv::DNS::DecodeError -**Inherits:** StandardError - - -Indicates that the DNS response was unable to be decoded. - - - diff --git a/example/ruby/Resolv/DNS/EncodeError.md b/example/ruby/Resolv/DNS/EncodeError.md deleted file mode 100644 index 454c8b5..0000000 --- a/example/ruby/Resolv/DNS/EncodeError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Resolv::DNS::EncodeError -**Inherits:** StandardError - - -Indicates that the DNS request was unable to be encoded. - - - diff --git a/example/ruby/Resolv/DNS/Label.md b/example/ruby/Resolv/DNS/Label.md deleted file mode 100644 index 2ab3abd..0000000 --- a/example/ruby/Resolv/DNS/Label.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Resolv::DNS::Label - - -:nodoc: - - -# Class Methods -## split(arg ) [](#method-c-split) - diff --git a/example/ruby/Resolv/DNS/Label/Str.md b/example/ruby/Resolv/DNS/Label/Str.md deleted file mode 100644 index a3402dd..0000000 --- a/example/ruby/Resolv/DNS/Label/Str.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Resolv::DNS::Label::Str -**Inherits:** Object - - -:nodoc: - - -# Attributes -## downcase[RW] [](#attribute-i-downcase) -Returns the value of attribute downcase. - -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) - -## initialize(string) [](#method-i-initialize) - -**@return** [Str] a new instance of Str - -## inspect() [](#method-i-inspect) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Resolv/DNS/Message.md b/example/ruby/Resolv/DNS/Message.md deleted file mode 100644 index 394f7fa..0000000 --- a/example/ruby/Resolv/DNS/Message.md +++ /dev/null @@ -1,74 +0,0 @@ -# Class: Resolv::DNS::Message -**Inherits:** Object - - -:nodoc: - - -# Class Methods -## decode(m ) [](#method-c-decode) -# Attributes -## aa[RW] [](#attribute-i-aa) -Returns the value of attribute aa. - -## additional[RW] [](#attribute-i-additional) -Returns the value of attribute additional. - -## answer[RW] [](#attribute-i-answer) -Returns the value of attribute answer. - -## authority[RW] [](#attribute-i-authority) -Returns the value of attribute authority. - -## id[RW] [](#attribute-i-id) -Returns the value of attribute id. - -## opcode[RW] [](#attribute-i-opcode) -Returns the value of attribute opcode. - -## qr[RW] [](#attribute-i-qr) -Returns the value of attribute qr. - -## question[RW] [](#attribute-i-question) -Returns the value of attribute question. - -## ra[RW] [](#attribute-i-ra) -Returns the value of attribute ra. - -## rcode[RW] [](#attribute-i-rcode) -Returns the value of attribute rcode. - -## rd[RW] [](#attribute-i-rd) -Returns the value of attribute rd. - -## tc[RW] [](#attribute-i-tc) -Returns the value of attribute tc. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## add_additional(name, ttl, data) [](#method-i-add_additional) - -## add_answer(name, ttl, data) [](#method-i-add_answer) - -## add_authority(name, ttl, data) [](#method-i-add_authority) - -## add_question(name, typeclass) [](#method-i-add_question) - -## each_additional() [](#method-i-each_additional) - -## each_answer() [](#method-i-each_answer) - -## each_authority() [](#method-i-each_authority) - -## each_question() [](#method-i-each_question) - -## each_resource() [](#method-i-each_resource) - -## encode() [](#method-i-encode) - -## initialize(id(@@identifier += 1) & 0xffff) [](#method-i-initialize) - -**@return** [Message] a new instance of Message - diff --git a/example/ruby/Resolv/DNS/Message/MessageDecoder.md b/example/ruby/Resolv/DNS/Message/MessageDecoder.md deleted file mode 100644 index 9eabcb1..0000000 --- a/example/ruby/Resolv/DNS/Message/MessageDecoder.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Resolv::DNS::Message::MessageDecoder -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## get_bytes(len@limit - @index) [](#method-i-get_bytes) - -**@raise** [DecodeError] - -## get_label() [](#method-i-get_label) - -## get_labels() [](#method-i-get_labels) - -## get_length16() [](#method-i-get_length16) - -## get_list() [](#method-i-get_list) - -## get_name() [](#method-i-get_name) - -## get_question() [](#method-i-get_question) - -## get_rr() [](#method-i-get_rr) - -## get_string() [](#method-i-get_string) - -**@raise** [DecodeError] - -## get_string_list() [](#method-i-get_string_list) - -## get_unpack(template) [](#method-i-get_unpack) - -**@raise** [DecodeError] - -## initialize(data) [](#method-i-initialize) - -**@return** [MessageDecoder] a new instance of MessageDecoder - -**@yield** [_self] - -**@yieldparam** [Resolv::DNS::Message::MessageDecoder] the object that the method was called on - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/Resolv/DNS/Message/MessageEncoder.md b/example/ruby/Resolv/DNS/Message/MessageEncoder.md deleted file mode 100644 index bad52a0..0000000 --- a/example/ruby/Resolv/DNS/Message/MessageEncoder.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: Resolv::DNS::Message::MessageEncoder -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [MessageEncoder] a new instance of MessageEncoder - -**@yield** [_self] - -**@yieldparam** [Resolv::DNS::Message::MessageEncoder] the object that the method was called on - -## put_bytes(d) [](#method-i-put_bytes) - -## put_label(d) [](#method-i-put_label) - -## put_labels(d, compress:true) [](#method-i-put_labels) - -## put_length16() [](#method-i-put_length16) - -## put_name(d, compress:true) [](#method-i-put_name) - -## put_pack(template, *d) [](#method-i-put_pack) - -## put_string(d) [](#method-i-put_string) - -## put_string_list(ds) [](#method-i-put_string_list) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Resolv/DNS/Name.md b/example/ruby/Resolv/DNS/Name.md deleted file mode 100644 index 1778783..0000000 --- a/example/ruby/Resolv/DNS/Name.md +++ /dev/null @@ -1,75 +0,0 @@ -# Class: Resolv::DNS::Name -**Inherits:** Object - - -A representation of a DNS name. - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new DNS name from `arg`. `arg` can be: - -Name -: returns `arg`. - -String -: Creates a new Name. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## [](i) [](#method-i-[]) -:nodoc: - -## absolute?() [](#method-i-absolute?) -True if this name is absolute. - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(labels, absolutetrue) [](#method-i-initialize) -:nodoc: - -**@return** [Name] a new instance of Name - -## inspect() [](#method-i-inspect) -:nodoc: - -## length() [](#method-i-length) -:nodoc: - -## subdomain_of?(other) [](#method-i-subdomain_of?) -Returns true if `other` is a subdomain. - -Example: - - domain = Resolv::DNS::Name.create("y.z") - p Resolv::DNS::Name.create("w.x.y.z").subdomain_of?(domain) #=> true - p Resolv::DNS::Name.create("x.y.z").subdomain_of?(domain) #=> true - p Resolv::DNS::Name.create("y.z").subdomain_of?(domain) #=> false - p Resolv::DNS::Name.create("z").subdomain_of?(domain) #=> false - p Resolv::DNS::Name.create("x.y.z.").subdomain_of?(domain) #=> false - p Resolv::DNS::Name.create("w.z").subdomain_of?(domain) #=> false - -**@raise** [ArgumentError] - -**@return** [Boolean] - -## to_a() [](#method-i-to_a) -:nodoc: - -## to_s() [](#method-i-to_s) -returns the domain name as a string. - -The domain name doesn't have a trailing dot even if the name object is -absolute. - -Example: - - p Resolv::DNS::Name.create("x.y.z.").to_s #=> "x.y.z" - p Resolv::DNS::Name.create("x.y.z").to_s #=> "x.y.z" - diff --git a/example/ruby/Resolv/DNS/OpCode.md b/example/ruby/Resolv/DNS/OpCode.md deleted file mode 100644 index eaee1f9..0000000 --- a/example/ruby/Resolv/DNS/OpCode.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Resolv::DNS::OpCode - - -:nodoc: - - - diff --git a/example/ruby/Resolv/DNS/Query.md b/example/ruby/Resolv/DNS/Query.md deleted file mode 100644 index 5660279..0000000 --- a/example/ruby/Resolv/DNS/Query.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Resolv::DNS::Query -**Inherits:** Object - - -A DNS query abstract class. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -**@raise** [DecodeError] - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -**@raise** [EncodeError] - diff --git a/example/ruby/Resolv/DNS/RCode.md b/example/ruby/Resolv/DNS/RCode.md deleted file mode 100644 index b0f2bb9..0000000 --- a/example/ruby/Resolv/DNS/RCode.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Resolv::DNS::RCode - - -:nodoc: - - - diff --git a/example/ruby/Resolv/DNS/Requester.md b/example/ruby/Resolv/DNS/Requester.md deleted file mode 100644 index 848834c..0000000 --- a/example/ruby/Resolv/DNS/Requester.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Resolv::DNS::Requester -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize() [](#method-i-initialize) - -**@return** [Requester] a new instance of Requester - -## request(sender, tout) [](#method-i-request) - -## sender_for(addr, msg) [](#method-i-sender_for) - diff --git a/example/ruby/Resolv/DNS/Requester/ConnectedUDP.md b/example/ruby/Resolv/DNS/Requester/ConnectedUDP.md deleted file mode 100644 index c0fb772..0000000 --- a/example/ruby/Resolv/DNS/Requester/ConnectedUDP.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Resolv::DNS::Requester::ConnectedUDP -**Inherits:** Resolv::DNS::Requester - - -:nodoc: - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize(host, portPort) [](#method-i-initialize) - -**@return** [ConnectedUDP] a new instance of ConnectedUDP - -## lazy_initialize() [](#method-i-lazy_initialize) - -## recv_reply(readable_socks) [](#method-i-recv_reply) - -## sender(msg, data, host@host, port@port) [](#method-i-sender) - diff --git a/example/ruby/Resolv/DNS/Requester/ConnectedUDP/Sender.md b/example/ruby/Resolv/DNS/Requester/ConnectedUDP/Sender.md deleted file mode 100644 index 4ad8d04..0000000 --- a/example/ruby/Resolv/DNS/Requester/ConnectedUDP/Sender.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Resolv::DNS::Requester::ConnectedUDP::Sender -**Inherits:** Resolv::DNS::Requester::Sender - - -:nodoc: - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## send() [](#method-i-send) - diff --git a/example/ruby/Resolv/DNS/Requester/MDNSOneShot.md b/example/ruby/Resolv/DNS/Requester/MDNSOneShot.md deleted file mode 100644 index e677895..0000000 --- a/example/ruby/Resolv/DNS/Requester/MDNSOneShot.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Resolv::DNS::Requester::MDNSOneShot -**Inherits:** Resolv::DNS::Requester::UnconnectedUDP - - -:nodoc: - - - -#Instance Methods -## sender(msg, data, host, portPort) [](#method-i-sender) - -## sender_for(addr, msg) [](#method-i-sender_for) - diff --git a/example/ruby/Resolv/DNS/Requester/RequestError.md b/example/ruby/Resolv/DNS/Requester/RequestError.md deleted file mode 100644 index 6a74c97..0000000 --- a/example/ruby/Resolv/DNS/Requester/RequestError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Resolv::DNS::Requester::RequestError -**Inherits:** StandardError - - -Indicates a problem with the DNS request. - - - diff --git a/example/ruby/Resolv/DNS/Requester/Sender.md b/example/ruby/Resolv/DNS/Requester/Sender.md deleted file mode 100644 index 9ed5534..0000000 --- a/example/ruby/Resolv/DNS/Requester/Sender.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Resolv::DNS::Requester::Sender -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## initialize(msg, data, sock) [](#method-i-initialize) - -**@return** [Sender] a new instance of Sender - diff --git a/example/ruby/Resolv/DNS/Requester/TCP.md b/example/ruby/Resolv/DNS/Requester/TCP.md deleted file mode 100644 index 3950674..0000000 --- a/example/ruby/Resolv/DNS/Requester/TCP.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Resolv::DNS::Requester::TCP -**Inherits:** Resolv::DNS::Requester - - -:nodoc: - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize(host, portPort) [](#method-i-initialize) - -**@return** [TCP] a new instance of TCP - -## recv_reply(readable_socks) [](#method-i-recv_reply) - -## sender(msg, data, host@host, port@port) [](#method-i-sender) - diff --git a/example/ruby/Resolv/DNS/Requester/TCP/Sender.md b/example/ruby/Resolv/DNS/Requester/TCP/Sender.md deleted file mode 100644 index d59bda5..0000000 --- a/example/ruby/Resolv/DNS/Requester/TCP/Sender.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Resolv::DNS::Requester::TCP::Sender -**Inherits:** Resolv::DNS::Requester::Sender - - -:nodoc: - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## send() [](#method-i-send) - diff --git a/example/ruby/Resolv/DNS/Requester/UnconnectedUDP.md b/example/ruby/Resolv/DNS/Requester/UnconnectedUDP.md deleted file mode 100644 index 67a81a7..0000000 --- a/example/ruby/Resolv/DNS/Requester/UnconnectedUDP.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Resolv::DNS::Requester::UnconnectedUDP -**Inherits:** Resolv::DNS::Requester - - -:nodoc: - - - -#Instance Methods -## close() [](#method-i-close) - -## initialize(*nameserver_port) [](#method-i-initialize) - -**@return** [UnconnectedUDP] a new instance of UnconnectedUDP - -## lazy_initialize() [](#method-i-lazy_initialize) - -## recv_reply(readable_socks) [](#method-i-recv_reply) - -## sender(msg, data, host, portPort) [](#method-i-sender) - diff --git a/example/ruby/Resolv/DNS/Requester/UnconnectedUDP/Sender.md b/example/ruby/Resolv/DNS/Requester/UnconnectedUDP/Sender.md deleted file mode 100644 index e77863b..0000000 --- a/example/ruby/Resolv/DNS/Requester/UnconnectedUDP/Sender.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Resolv::DNS::Requester::UnconnectedUDP::Sender -**Inherits:** Resolv::DNS::Requester::Sender - - -:nodoc: - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## initialize(msg, data, sock, host, port) [](#method-i-initialize) - -**@return** [Sender] a new instance of Sender - -## send() [](#method-i-send) - diff --git a/example/ruby/Resolv/DNS/Resource.md b/example/ruby/Resolv/DNS/Resource.md deleted file mode 100644 index 17b0b9c..0000000 --- a/example/ruby/Resolv/DNS/Resource.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Resolv::DNS::Resource -**Inherits:** Resolv::DNS::Query - - -A DNS resource abstract class. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -**@raise** [NotImplementedError] - -## get_class(type_value , class_value ) [](#method-c-get_class) -:nodoc: -# Attributes -## ttl[RW] [](#attribute-i-ttl) -Remaining Time To Live for this Resource. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -**@raise** [NotImplementedError] - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - diff --git a/example/ruby/Resolv/DNS/Resource/ANY.md b/example/ruby/Resolv/DNS/Resource/ANY.md deleted file mode 100644 index 89ed56d..0000000 --- a/example/ruby/Resolv/DNS/Resource/ANY.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Resolv::DNS::Resource::ANY -**Inherits:** Resolv::DNS::Query - - -A Query type requesting any RR. - - - diff --git a/example/ruby/Resolv/DNS/Resource/CAA.md b/example/ruby/Resolv/DNS/Resource/CAA.md deleted file mode 100644 index 4fbbdaa..0000000 --- a/example/ruby/Resolv/DNS/Resource/CAA.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Resolv::DNS::Resource::CAA -**Inherits:** Resolv::DNS::Resource - - -CAA resource record defined in RFC 8659 - -These records identify certificate authority allowed to issue certificates for -the given domain. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## flags[RW] [](#attribute-i-flags) -Flags for this proprty: -* Bit 0 : 0 = not critical, 1 = critical - -## tag[RW] [](#attribute-i-tag) -Property tag ("issue", "issuewild", "iodef"...). - -## value[RW] [](#attribute-i-value) -Property value. - - -#Instance Methods -## critical?() [](#method-i-critical?) -Whether the critical flag is set on this property. - -**@return** [Boolean] - -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(flags, tag, value) [](#method-i-initialize) -Creates a new CAA for `flags`, `tag` and `value`. - -**@return** [CAA] a new instance of CAA - diff --git a/example/ruby/Resolv/DNS/Resource/CNAME.md b/example/ruby/Resolv/DNS/Resource/CNAME.md deleted file mode 100644 index 7be2ee8..0000000 --- a/example/ruby/Resolv/DNS/Resource/CNAME.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Resolv::DNS::Resource::CNAME -**Inherits:** Resolv::DNS::Resource::DomainName - - -The canonical name for an alias. - - - diff --git a/example/ruby/Resolv/DNS/Resource/DomainName.md b/example/ruby/Resolv/DNS/Resource/DomainName.md deleted file mode 100644 index 5fb600a..0000000 --- a/example/ruby/Resolv/DNS/Resource/DomainName.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::Resource::DomainName -**Inherits:** Resolv::DNS::Resource - - -Domain Name resource abstract class. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## name[RW] [](#attribute-i-name) -The name of this DomainName. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(name) [](#method-i-initialize) -Creates a new DomainName from `name`. - -**@return** [DomainName] a new instance of DomainName - diff --git a/example/ruby/Resolv/DNS/Resource/Generic.md b/example/ruby/Resolv/DNS/Resource/Generic.md deleted file mode 100644 index 7854bd1..0000000 --- a/example/ruby/Resolv/DNS/Resource/Generic.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Resolv::DNS::Resource::Generic -**Inherits:** Resolv::DNS::Resource - - -A generic resource abstract class. - - -# Class Methods -## create(type_value , class_value ) [](#method-c-create) -:nodoc: -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## data[RW] [](#attribute-i-data) -Data for this generic resource. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(data) [](#method-i-initialize) -Creates a new generic resource. - -**@return** [Generic] a new instance of Generic - diff --git a/example/ruby/Resolv/DNS/Resource/HINFO.md b/example/ruby/Resolv/DNS/Resource/HINFO.md deleted file mode 100644 index 73e4c4f..0000000 --- a/example/ruby/Resolv/DNS/Resource/HINFO.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Resolv::DNS::Resource::HINFO -**Inherits:** Resolv::DNS::Resource - - -Host Information resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## cpu[RW] [](#attribute-i-cpu) -CPU architecture for this resource. - -## os[RW] [](#attribute-i-os) -Operating system for this resource. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(cpu, os) [](#method-i-initialize) -Creates a new HINFO running `os` on `cpu`. - -**@return** [HINFO] a new instance of HINFO - diff --git a/example/ruby/Resolv/DNS/Resource/IN.md b/example/ruby/Resolv/DNS/Resource/IN.md deleted file mode 100644 index baaced0..0000000 --- a/example/ruby/Resolv/DNS/Resource/IN.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: Resolv::DNS::Resource::IN - - -module IN contains ARPA Internet specific RRs. - - - diff --git a/example/ruby/Resolv/DNS/Resource/IN/A.md b/example/ruby/Resolv/DNS/Resource/IN/A.md deleted file mode 100644 index 0ce4e00..0000000 --- a/example/ruby/Resolv/DNS/Resource/IN/A.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::Resource::IN::A -**Inherits:** Resolv::DNS::Resource - - -IPv4 Address resource - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## address[RW] [](#attribute-i-address) -The Resolv::IPv4 address for this A. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(address) [](#method-i-initialize) -Creates a new A for `address`. - -**@return** [A] a new instance of A - diff --git a/example/ruby/Resolv/DNS/Resource/IN/AAAA.md b/example/ruby/Resolv/DNS/Resource/IN/AAAA.md deleted file mode 100644 index 1f1478a..0000000 --- a/example/ruby/Resolv/DNS/Resource/IN/AAAA.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::Resource::IN::AAAA -**Inherits:** Resolv::DNS::Resource - - -An IPv6 address record. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## address[RW] [](#attribute-i-address) -The Resolv::IPv6 address for this AAAA. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(address) [](#method-i-initialize) -Creates a new AAAA for `address`. - -**@return** [AAAA] a new instance of AAAA - diff --git a/example/ruby/Resolv/DNS/Resource/IN/HTTPS.md b/example/ruby/Resolv/DNS/Resource/IN/HTTPS.md deleted file mode 100644 index 6bceb92..0000000 --- a/example/ruby/Resolv/DNS/Resource/IN/HTTPS.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Resolv::DNS::Resource::IN::HTTPS -**Inherits:** Resolv::DNS::Resource::IN::ServiceBinding - - -HTTPS resource record [RFC9460] - - - diff --git a/example/ruby/Resolv/DNS/Resource/IN/SRV.md b/example/ruby/Resolv/DNS/Resource/IN/SRV.md deleted file mode 100644 index e3ed791..0000000 --- a/example/ruby/Resolv/DNS/Resource/IN/SRV.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: Resolv::DNS::Resource::IN::SRV -**Inherits:** Resolv::DNS::Resource - - -SRV resource record defined in RFC 2782 - -These records identify the hostname and port that a service is available at. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## port[RW] [](#attribute-i-port) -The port on this target host of this service. - -The range is 0-65535. - -## priority[RW] [](#attribute-i-priority) -The priority of this target host. - -A client MUST attempt to contact the target host with the lowest-numbered -priority it can reach; target hosts with the same priority SHOULD be tried in -an order defined by the weight field. The range is 0-65535. Note that it is -not widely implemented and should be set to zero. - -## target[RW] [](#attribute-i-target) -The domain name of the target host. - -A target of "." means that the service is decidedly not available at this -domain. - -## weight[RW] [](#attribute-i-weight) -A server selection mechanism. - -The weight field specifies a relative weight for entries with the same -priority. Larger weights SHOULD be given a proportionately higher probability -of being selected. The range of this number is 0-65535. Domain administrators -SHOULD use Weight 0 when there isn't any server selection to do, to make the -RR easier to read for humans (less noisy). Note that it is not widely -implemented and should be set to zero. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(priority, weight, port, target) [](#method-i-initialize) -Create a SRV resource record. - -See the documentation for #priority, #weight, #port and #target for -`priority`, `weight`, +port and `target` respectively. - -**@return** [SRV] a new instance of SRV - diff --git a/example/ruby/Resolv/DNS/Resource/IN/SVCB.md b/example/ruby/Resolv/DNS/Resource/IN/SVCB.md deleted file mode 100644 index f83077e..0000000 --- a/example/ruby/Resolv/DNS/Resource/IN/SVCB.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Resolv::DNS::Resource::IN::SVCB -**Inherits:** Resolv::DNS::Resource::IN::ServiceBinding - - -SVCB resource record [RFC9460] - - - diff --git a/example/ruby/Resolv/DNS/Resource/IN/ServiceBinding.md b/example/ruby/Resolv/DNS/Resource/IN/ServiceBinding.md deleted file mode 100644 index d13005f..0000000 --- a/example/ruby/Resolv/DNS/Resource/IN/ServiceBinding.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: Resolv::DNS::Resource::IN::ServiceBinding -**Inherits:** Object - - -Common implementation for SVCB-compatible resource records. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## params[RW] [](#attribute-i-params) -The service parameters for the target host. - -## priority[RW] [](#attribute-i-priority) -The priority of this target host. - -The range is 0-65535. If set to 0, this RR is in AliasMode. Otherwise, it is -in ServiceMode. - -## target[RW] [](#attribute-i-target) -The domain name of the target host. - - -#Instance Methods -## alias_mode?() [](#method-i-alias_mode?) -Whether this RR is in AliasMode. - -**@return** [Boolean] - -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(priority, target, params[]) [](#method-i-initialize) -Create a service binding resource record. - -**@return** [ServiceBinding] a new instance of ServiceBinding - -## service_mode?() [](#method-i-service_mode?) -Whether this RR is in ServiceMode. - -**@return** [Boolean] - diff --git a/example/ruby/Resolv/DNS/Resource/IN/WKS.md b/example/ruby/Resolv/DNS/Resource/IN/WKS.md deleted file mode 100644 index b0b5e98..0000000 --- a/example/ruby/Resolv/DNS/Resource/IN/WKS.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Resolv::DNS::Resource::IN::WKS -**Inherits:** Resolv::DNS::Resource - - -Well Known Service resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## address[RW] [](#attribute-i-address) -The host these services run on. - -## bitmap[RW] [](#attribute-i-bitmap) -A bit map of enabled services on this host. - -If protocol is 6 (TCP) then the 26th bit corresponds to the SMTP service (port -25). If this bit is set, then an SMTP server should be listening on TCP port -25; if zero, SMTP service is not supported. - -## protocol[RW] [](#attribute-i-protocol) -IP protocol number for these services. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(address, protocol, bitmap) [](#method-i-initialize) - -**@return** [WKS] a new instance of WKS - diff --git a/example/ruby/Resolv/DNS/Resource/LOC.md b/example/ruby/Resolv/DNS/Resource/LOC.md deleted file mode 100644 index 35f3674..0000000 --- a/example/ruby/Resolv/DNS/Resource/LOC.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Resolv::DNS::Resource::LOC -**Inherits:** Resolv::DNS::Resource - - -Location resource - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## altitude[RW] [](#attribute-i-altitude) -The altitude of the LOC above a reference sphere whose surface sits 100km -below the WGS84 spheroid in centimeters as an unsigned 32bit integer - -## hprecision[RW] [](#attribute-i-hprecision) -The horizontal precision using ssize type values in meters using scientific -notation as 2 integers of XeY for precision use value/2 e.g. 2m = +/-1m - -## latitude[RW] [](#attribute-i-latitude) -The latitude for this LOC where 2**31 is the equator in thousandths of an arc -second as an unsigned 32bit integer - -## longitude[RW] [](#attribute-i-longitude) -The longitude for this LOC where 2**31 is the prime meridian in thousandths of -an arc second as an unsigned 32bit integer - -## ssize[RW] [](#attribute-i-ssize) -The spherical size of this LOC in meters using scientific notation as 2 -integers of XeY - -## version[RW] [](#attribute-i-version) -Returns the version value for this LOC record which should always be 00 - -## vprecision[RW] [](#attribute-i-vprecision) -The vertical precision using ssize type values in meters using scientific -notation as 2 integers of XeY for precision use value/2 e.g. 2m = +/-1m - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(version, ssize, hprecision, vprecision, latitude, longitude, altitude) [](#method-i-initialize) - -**@return** [LOC] a new instance of LOC - diff --git a/example/ruby/Resolv/DNS/Resource/MINFO.md b/example/ruby/Resolv/DNS/Resource/MINFO.md deleted file mode 100644 index 2b50949..0000000 --- a/example/ruby/Resolv/DNS/Resource/MINFO.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Resolv::DNS::Resource::MINFO -**Inherits:** Resolv::DNS::Resource - - -Mailing list or mailbox information. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## emailbx[RW] [](#attribute-i-emailbx) -Mailbox to use for error messages related to the mail list or mailbox. - -## rmailbx[RW] [](#attribute-i-rmailbx) -Domain name responsible for this mail list or mailbox. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(rmailbx, emailbx) [](#method-i-initialize) - -**@return** [MINFO] a new instance of MINFO - diff --git a/example/ruby/Resolv/DNS/Resource/MX.md b/example/ruby/Resolv/DNS/Resource/MX.md deleted file mode 100644 index bd6bd9a..0000000 --- a/example/ruby/Resolv/DNS/Resource/MX.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Resolv::DNS::Resource::MX -**Inherits:** Resolv::DNS::Resource - - -Mail Exchanger resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## exchange[RW] [](#attribute-i-exchange) -The host of this MX. - -## preference[RW] [](#attribute-i-preference) -The preference for this MX. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(preference, exchange) [](#method-i-initialize) -Creates a new MX record with `preference`, accepting mail at `exchange`. - -**@return** [MX] a new instance of MX - diff --git a/example/ruby/Resolv/DNS/Resource/NS.md b/example/ruby/Resolv/DNS/Resource/NS.md deleted file mode 100644 index ffb1d2f..0000000 --- a/example/ruby/Resolv/DNS/Resource/NS.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Resolv::DNS::Resource::NS -**Inherits:** Resolv::DNS::Resource::DomainName - - -An authoritative name server. - - - diff --git a/example/ruby/Resolv/DNS/Resource/PTR.md b/example/ruby/Resolv/DNS/Resource/PTR.md deleted file mode 100644 index 119bf72..0000000 --- a/example/ruby/Resolv/DNS/Resource/PTR.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Resolv::DNS::Resource::PTR -**Inherits:** Resolv::DNS::Resource::DomainName - - -A Pointer to another DNS name. - - - diff --git a/example/ruby/Resolv/DNS/Resource/SOA.md b/example/ruby/Resolv/DNS/Resource/SOA.md deleted file mode 100644 index 7d33f74..0000000 --- a/example/ruby/Resolv/DNS/Resource/SOA.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: Resolv::DNS::Resource::SOA -**Inherits:** Resolv::DNS::Resource - - -Start Of Authority resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## expire[RW] [](#attribute-i-expire) -Time in seconds that a secondary name server is to use the data before -refreshing from the primary name server. - -## minimum[RW] [](#attribute-i-minimum) -The minimum number of seconds to be used for TTL values in RRs. - -## mname[RW] [](#attribute-i-mname) -Name of the host where the master zone file for this zone resides. - -## refresh[RW] [](#attribute-i-refresh) -How often, in seconds, a secondary name server is to check for updates from -the primary name server. - -## retry[RW] [](#attribute-i-retry) -How often, in seconds, a secondary name server is to retry after a failure to -check for a refresh. - -## rname[RW] [](#attribute-i-rname) -The person responsible for this domain name. - -## serial[RW] [](#attribute-i-serial) -The version number of the zone file. - - -#Instance Methods -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(mname, rname, serial, refresh, retry_, expire, minimum) [](#method-i-initialize) -Creates a new SOA record. See the attr documentation for the details of each -argument. - -**@return** [SOA] a new instance of SOA - diff --git a/example/ruby/Resolv/DNS/Resource/TXT.md b/example/ruby/Resolv/DNS/Resource/TXT.md deleted file mode 100644 index ef269bc..0000000 --- a/example/ruby/Resolv/DNS/Resource/TXT.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Resolv::DNS::Resource::TXT -**Inherits:** Resolv::DNS::Resource - - -Unstructured text resource. - - -# Class Methods -## decode_rdata(msg ) [](#method-c-decode_rdata) -:nodoc: -# Attributes -## strings[RW] [](#attribute-i-strings) -Returns an Array of Strings for this TXT record. - - -#Instance Methods -## data() [](#method-i-data) -Returns the concatenated string from `strings`. - -## encode_rdata(msg) [](#method-i-encode_rdata) -:nodoc: - -## initialize(first_string, *rest_strings) [](#method-i-initialize) - -**@return** [TXT] a new instance of TXT - diff --git a/example/ruby/Resolv/DNS/SvcParam.md b/example/ruby/Resolv/DNS/SvcParam.md deleted file mode 100644 index bccbdce..0000000 --- a/example/ruby/Resolv/DNS/SvcParam.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: Resolv::DNS::SvcParam -**Inherits:** Object - - -Base class for SvcParam. [RFC9460] - - -# Class Methods -## key_name() [](#method-c-key_name) -Get the presentation name of the SvcParamKey. -## key_number() [](#method-c-key_number) -Get the registered number of the SvcParamKey. - diff --git a/example/ruby/Resolv/DNS/SvcParam/ALPN.md b/example/ruby/Resolv/DNS/SvcParam/ALPN.md deleted file mode 100644 index 2929064..0000000 --- a/example/ruby/Resolv/DNS/SvcParam/ALPN.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::SvcParam::ALPN -**Inherits:** Resolv::DNS::SvcParam - - -"alpn" SvcParam -- Additional supported protocols - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## protocol_ids[RW] [](#attribute-i-protocol_ids) -Supported protocol IDs. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(protocol_ids) [](#method-i-initialize) -Initialize "alpn" ScvParam. - -**@return** [ALPN] a new instance of ALPN - diff --git a/example/ruby/Resolv/DNS/SvcParam/DoHPath.md b/example/ruby/Resolv/DNS/SvcParam/DoHPath.md deleted file mode 100644 index d262782..0000000 --- a/example/ruby/Resolv/DNS/SvcParam/DoHPath.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::SvcParam::DoHPath -**Inherits:** Resolv::DNS::SvcParam - - -"dohpath" SvcParam -- DNS over HTTPS path template [RFC9461] - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## template[RW] [](#attribute-i-template) -URI template for DoH queries. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(template) [](#method-i-initialize) -Initialize "dohpath" ScvParam. - -**@return** [DoHPath] a new instance of DoHPath - diff --git a/example/ruby/Resolv/DNS/SvcParam/Generic.md b/example/ruby/Resolv/DNS/SvcParam/Generic.md deleted file mode 100644 index 6eefff8..0000000 --- a/example/ruby/Resolv/DNS/SvcParam/Generic.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: Resolv::DNS::SvcParam::Generic -**Inherits:** Resolv::DNS::SvcParam - - -Generic SvcParam abstract class. - - -# Class Methods -## create(key_number ) [](#method-c-create) -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## value[RW] [](#attribute-i-value) -SvcParamValue in wire-format byte string. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(value) [](#method-i-initialize) -Create generic SvcParam - -**@return** [Generic] a new instance of Generic - diff --git a/example/ruby/Resolv/DNS/SvcParam/IPv4Hint.md b/example/ruby/Resolv/DNS/SvcParam/IPv4Hint.md deleted file mode 100644 index e968237..0000000 --- a/example/ruby/Resolv/DNS/SvcParam/IPv4Hint.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::SvcParam::IPv4Hint -**Inherits:** Resolv::DNS::SvcParam - - -"ipv4hint" SvcParam -- IPv4 address hints - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## addresses[RW] [](#attribute-i-addresses) -Set of IPv4 addresses. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(addresses) [](#method-i-initialize) -Initialize "ipv4hint" ScvParam. - -**@return** [IPv4Hint] a new instance of IPv4Hint - diff --git a/example/ruby/Resolv/DNS/SvcParam/IPv6Hint.md b/example/ruby/Resolv/DNS/SvcParam/IPv6Hint.md deleted file mode 100644 index 559f3f1..0000000 --- a/example/ruby/Resolv/DNS/SvcParam/IPv6Hint.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::SvcParam::IPv6Hint -**Inherits:** Resolv::DNS::SvcParam - - -"ipv6hint" SvcParam -- IPv6 address hints - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## addresses[RW] [](#attribute-i-addresses) -Set of IPv6 addresses. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(addresses) [](#method-i-initialize) -Initialize "ipv6hint" ScvParam. - -**@return** [IPv6Hint] a new instance of IPv6Hint - diff --git a/example/ruby/Resolv/DNS/SvcParam/Mandatory.md b/example/ruby/Resolv/DNS/SvcParam/Mandatory.md deleted file mode 100644 index 8a2c70e..0000000 --- a/example/ruby/Resolv/DNS/SvcParam/Mandatory.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::SvcParam::Mandatory -**Inherits:** Resolv::DNS::SvcParam - - -"mandatory" SvcParam -- Mandatory keys in service binding RR - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## keys[RW] [](#attribute-i-keys) -Mandatory keys. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(keys) [](#method-i-initialize) -Initialize "mandatory" ScvParam. - -**@return** [Mandatory] a new instance of Mandatory - diff --git a/example/ruby/Resolv/DNS/SvcParam/NoDefaultALPN.md b/example/ruby/Resolv/DNS/SvcParam/NoDefaultALPN.md deleted file mode 100644 index 37e04ed..0000000 --- a/example/ruby/Resolv/DNS/SvcParam/NoDefaultALPN.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Resolv::DNS::SvcParam::NoDefaultALPN -**Inherits:** Resolv::DNS::SvcParam - - -"no-default-alpn" SvcParam -- No support for default protocol - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - diff --git a/example/ruby/Resolv/DNS/SvcParam/Port.md b/example/ruby/Resolv/DNS/SvcParam/Port.md deleted file mode 100644 index c7ce3f9..0000000 --- a/example/ruby/Resolv/DNS/SvcParam/Port.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Resolv::DNS::SvcParam::Port -**Inherits:** Resolv::DNS::SvcParam - - -"port" SvcParam -- Port for alternative endpoint - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: -# Attributes -## port[RW] [](#attribute-i-port) -Port number. - - -#Instance Methods -## encode(msg) [](#method-i-encode) -:nodoc: - -## initialize(port) [](#method-i-initialize) -Initialize "port" ScvParam. - -**@return** [Port] a new instance of Port - diff --git a/example/ruby/Resolv/DNS/SvcParams.md b/example/ruby/Resolv/DNS/SvcParams.md deleted file mode 100644 index abbdc8a..0000000 --- a/example/ruby/Resolv/DNS/SvcParams.md +++ /dev/null @@ -1,2078 +0,0 @@ -# Class: Resolv::DNS::SvcParams -**Inherits:** Object - -**Includes:** Enumerable - - -SvcParams for service binding RRs. [RFC9460] - - -# Class Methods -## decode(msg ) [](#method-c-decode) -:nodoc: - -#Instance Methods -## [](key) [](#method-i-[]) -Get SvcParam for the given `key` in this list. - -## add(param) [](#method-i-add) -Add the SvcParam `param` to this list, overwriting the existing one with the -same key. - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count() [](#method-i-count) -Get the number of SvcParams in this list. - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete(key) [](#method-i-delete) -Remove the `SvcParam` with the given `key` and return it. - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) -Enumerate the +SvcParam+s in this list. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Get whether this list is empty. - -**@return** [Boolean] - -## encode(msg) [](#method-i-encode) -:nodoc: - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(params[]) [](#method-i-initialize) -Create a list of SvcParams with the given initial content. - -`params` has to be an enumerable of +SvcParam+s. If its content has -+SvcParam+s with the duplicate key, the one appears last takes precedence. - -**@return** [SvcParams] a new instance of SvcParams - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Resolv/Hosts.md b/example/ruby/Resolv/Hosts.md deleted file mode 100644 index 1c5bc3b..0000000 --- a/example/ruby/Resolv/Hosts.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: Resolv::Hosts -**Inherits:** Object - - -Resolv::Hosts is a hostname resolver that uses the system hosts file. - - - -#Instance Methods -## each_address(name, &proc) [](#method-i-each_address) -Iterates over all IP addresses for `name` retrieved from the hosts file. - -## each_name(address, &proc) [](#method-i-each_name) -Iterates over all hostnames for `address` retrieved from the hosts file. - -## getaddress(name) [](#method-i-getaddress) -Gets the IP address of `name` from the hosts file. - -**@raise** [ResolvError] - -## getaddresses(name) [](#method-i-getaddresses) -Gets all IP addresses for `name` from the hosts file. - -## getname(address) [](#method-i-getname) -Gets the hostname of `address` from the hosts file. - -**@raise** [ResolvError] - -## getnames(address) [](#method-i-getnames) -Gets all hostnames for `address` from the hosts file. - -## initialize(filenameDefaultFileName) [](#method-i-initialize) -Creates a new Resolv::Hosts, using `filename` for its data source. - -**@return** [Hosts] a new instance of Hosts - -## lazy_initialize() [](#method-i-lazy_initialize) -:nodoc: - diff --git a/example/ruby/Resolv/IPv4.md b/example/ruby/Resolv/IPv4.md deleted file mode 100644 index a177b6b..0000000 --- a/example/ruby/Resolv/IPv4.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: Resolv::IPv4 -**Inherits:** Object - - -A Resolv::DNS IPv4 address. - - -# Class Methods -## create(arg ) [](#method-c-create) -# Attributes -## address[RW] [](#attribute-i-address) -The raw IPv4 address as a String. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(address) [](#method-i-initialize) -:nodoc: - -**@return** [IPv4] a new instance of IPv4 - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_name() [](#method-i-to_name) -Turns this IPv4 address into a Resolv::DNS::Name. - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Resolv/IPv6.md b/example/ruby/Resolv/IPv6.md deleted file mode 100644 index 37d91c0..0000000 --- a/example/ruby/Resolv/IPv6.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: Resolv::IPv6 -**Inherits:** Object - - -A Resolv::DNS IPv6 address. - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new IPv6 address from `arg` which may be: - -IPv6 -: returns `arg`. - -String -: `arg` must match one of the IPv6::Regex* constants - -# Attributes -## address[RW] [](#attribute-i-address) -The raw IPv6 address as a String. - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(address) [](#method-i-initialize) -:nodoc: - -**@return** [IPv6] a new instance of IPv6 - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_name() [](#method-i-to_name) -Turns this IPv6 address into a Resolv::DNS::Name. -- ip6.arpa should be -searched too. [RFC3152] - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Resolv/LOC.md b/example/ruby/Resolv/LOC.md deleted file mode 100644 index e25c5cf..0000000 --- a/example/ruby/Resolv/LOC.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Resolv::LOC - - - - - diff --git a/example/ruby/Resolv/LOC/Alt.md b/example/ruby/Resolv/LOC/Alt.md deleted file mode 100644 index 532caea..0000000 --- a/example/ruby/Resolv/LOC/Alt.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Resolv::LOC::Alt -**Inherits:** Object - - -A Resolv::LOC::Alt - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new LOC::Alt from `arg` which may be: - -LOC::Alt -: returns `arg`. - -String -: `arg` must match the LOC::Alt::Regex constant - -# Attributes -## altitude[RW] [](#attribute-i-altitude) -The raw altitude - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(altitude) [](#method-i-initialize) - -**@return** [Alt] a new instance of Alt - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Resolv/LOC/Coord.md b/example/ruby/Resolv/LOC/Coord.md deleted file mode 100644 index 009699c..0000000 --- a/example/ruby/Resolv/LOC/Coord.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: Resolv::LOC::Coord -**Inherits:** Object - - -A Resolv::LOC::Coord - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new LOC::Coord from `arg` which may be: - -LOC::Coord -: returns `arg`. - -String -: `arg` must match the LOC::Coord::Regex constant - -# Attributes -## coordinates[RW] [](#attribute-i-coordinates) -The raw coordinates - -## orientation[RW] [](#attribute-i-orientation) -The orientation of the hemisphere as 'lat' or 'lon' - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(coordinates, orientation) [](#method-i-initialize) - -**@return** [Coord] a new instance of Coord - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Resolv/LOC/Size.md b/example/ruby/Resolv/LOC/Size.md deleted file mode 100644 index 1b12d53..0000000 --- a/example/ruby/Resolv/LOC/Size.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: Resolv::LOC::Size -**Inherits:** Object - - -A Resolv::LOC::Size - - -# Class Methods -## create(arg ) [](#method-c-create) -Creates a new LOC::Size from `arg` which may be: - -LOC::Size -: returns `arg`. - -String -: `arg` must match the LOC::Size::Regex constant - -# Attributes -## scalar[RW] [](#attribute-i-scalar) -The raw size - - -#Instance Methods -## ==(other) [](#method-i-==) -:nodoc: - -## eql?(other) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## hash() [](#method-i-hash) -:nodoc: - -## initialize(scalar) [](#method-i-initialize) - -**@return** [Size] a new instance of Size - -## inspect() [](#method-i-inspect) -:nodoc: - -## to_s() [](#method-i-to_s) -:nodoc: - diff --git a/example/ruby/Resolv/MDNS.md b/example/ruby/Resolv/MDNS.md deleted file mode 100644 index 184cb38..0000000 --- a/example/ruby/Resolv/MDNS.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: Resolv::MDNS -**Inherits:** Resolv::DNS - - -Resolv::MDNS is a one-shot Multicast DNS (mDNS) resolver. It blindly makes -queries to the mDNS addresses without understanding anything about multicast -ports. - -Information taken form the following places: - -* RFC 6762 - - - -#Instance Methods -## each_address(name) [](#method-i-each_address) -Iterates over all IP addresses for `name` retrieved from the mDNS resolver, -provided name ends with "local". If the name does not end in "local" no -records will be returned. - -`name` can be a Resolv::DNS::Name or a String. Retrieved addresses will be a -Resolv::IPv4 or Resolv::IPv6 - -## initialize(config_infonil) [](#method-i-initialize) -Creates a new one-shot Multicast DNS (mDNS) resolver. - -`config_info` can be: - -nil -: Uses the default mDNS addresses - - -Hash -: Must contain :nameserver or :nameserver_port like Resolv::DNS#initialize. - - -**@return** [MDNS] a new instance of MDNS - -## make_udp_requester() [](#method-i-make_udp_requester) -:nodoc: - diff --git a/example/ruby/Resolv/ResolvError.md b/example/ruby/Resolv/ResolvError.md deleted file mode 100644 index 4c8aa9a..0000000 --- a/example/ruby/Resolv/ResolvError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Resolv::ResolvError -**Inherits:** StandardError - - -Indicates a failure to resolve a name or address. - - - diff --git a/example/ruby/Resolv/ResolvTimeout.md b/example/ruby/Resolv/ResolvTimeout.md deleted file mode 100644 index 73e615c..0000000 --- a/example/ruby/Resolv/ResolvTimeout.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Resolv::ResolvTimeout -**Inherits:** Timeout::Error - - -Indicates a timeout resolving a name or address. - - - diff --git a/example/ruby/ResolveSymbolResolver.md b/example/ruby/ResolveSymbolResolver.md deleted file mode 100644 index ad71116..0000000 --- a/example/ruby/ResolveSymbolResolver.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: ResolveSymbolResolver - - - - -# Class Methods -## any_method() [](#method-c-any_method) -## try_resolve_fname() [](#method-c-try_resolve_fname) -## try_resolve_sname() [](#method-c-try_resolve_sname) - diff --git a/example/ruby/ResolveSymbolTarget.md b/example/ruby/ResolveSymbolTarget.md deleted file mode 100644 index 25cd9d3..0000000 --- a/example/ruby/ResolveSymbolTarget.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: ResolveSymbolTarget - - - - -# Class Methods -## any_method() [](#method-c-any_method) - diff --git a/example/ruby/RespondToMatcher.md b/example/ruby/RespondToMatcher.md deleted file mode 100644 index ea4e118..0000000 --- a/example/ruby/RespondToMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: RespondToMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected) [](#method-i-initialize) - -**@return** [RespondToMatcher] a new instance of RespondToMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/ReturnSpecs.md b/example/ruby/ReturnSpecs.md deleted file mode 100644 index 80981f4..0000000 --- a/example/ruby/ReturnSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ReturnSpecs - - - - - diff --git a/example/ruby/ReturnSpecs/Blocks.md b/example/ruby/ReturnSpecs/Blocks.md deleted file mode 100644 index 0976c35..0000000 --- a/example/ruby/ReturnSpecs/Blocks.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ReturnSpecs::Blocks -**Inherits:** Object - - - - - -#Instance Methods -## enclosing_method() [](#method-i-enclosing_method) - -## yielding_method() [](#method-i-yielding_method) - diff --git a/example/ruby/ReturnSpecs/DefineMethod.md b/example/ruby/ReturnSpecs/DefineMethod.md deleted file mode 100644 index 34afa4f..0000000 --- a/example/ruby/ReturnSpecs/DefineMethod.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ReturnSpecs::DefineMethod -**Inherits:** Object - - - - - -#Instance Methods -## outer() [](#method-i-outer) - diff --git a/example/ruby/ReturnSpecs/MethodWithBlock.md b/example/ruby/ReturnSpecs/MethodWithBlock.md deleted file mode 100644 index e646430..0000000 --- a/example/ruby/ReturnSpecs/MethodWithBlock.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ReturnSpecs::MethodWithBlock -**Inherits:** Object - - - - - -#Instance Methods -## get_ary(count, &blk) [](#method-i-get_ary) - -## method1() [](#method-i-method1) - -## method2() [](#method-i-method2) - diff --git a/example/ruby/ReturnSpecs/NestedBlocks.md b/example/ruby/ReturnSpecs/NestedBlocks.md deleted file mode 100644 index 01ba5e7..0000000 --- a/example/ruby/ReturnSpecs/NestedBlocks.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: ReturnSpecs::NestedBlocks -**Inherits:** ReturnSpecs::Blocks - - - - - -#Instance Methods -## enclosing_method() [](#method-i-enclosing_method) - diff --git a/example/ruby/ReturnSpecs/NestedCalls.md b/example/ruby/ReturnSpecs/NestedCalls.md deleted file mode 100644 index d3894ed..0000000 --- a/example/ruby/ReturnSpecs/NestedCalls.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ReturnSpecs::NestedCalls -**Inherits:** ReturnSpecs::Blocks - - - - - -#Instance Methods -## enclosing_method() [](#method-i-enclosing_method) - -## invoking_method(&b) [](#method-i-invoking_method) - diff --git a/example/ruby/ReturnSpecs/SavedInnerBlock.md b/example/ruby/ReturnSpecs/SavedInnerBlock.md deleted file mode 100644 index 09f196e..0000000 --- a/example/ruby/ReturnSpecs/SavedInnerBlock.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ReturnSpecs::SavedInnerBlock -**Inherits:** Object - - - - - -#Instance Methods -## add(&b) [](#method-i-add) - -## inner() [](#method-i-inner) - -## outer() [](#method-i-outer) - -## start() [](#method-i-start) - diff --git a/example/ruby/ReturnSpecs/ThroughDefineMethod.md b/example/ruby/ReturnSpecs/ThroughDefineMethod.md deleted file mode 100644 index 625ac7e..0000000 --- a/example/ruby/ReturnSpecs/ThroughDefineMethod.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ReturnSpecs::ThroughDefineMethod -**Inherits:** Object - - - - - -#Instance Methods -## mp(&b) [](#method-i-mp) - -## outer() [](#method-i-outer) - diff --git a/example/ruby/Ring.md b/example/ruby/Ring.md deleted file mode 100644 index 3e6e901..0000000 --- a/example/ruby/Ring.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Ring -**Inherits:** Object - - - - -# Attributes -## next_ring[RW] [](#attribute-i-next_ring) -Returns the value of attribute next_ring. - - -#Instance Methods -## initialize(nnil) [](#method-i-initialize) - -**@return** [Ring] a new instance of Ring - -## size() [](#method-i-size) - diff --git a/example/ruby/RingEcho.md b/example/ruby/RingEcho.md deleted file mode 100644 index 530418a..0000000 --- a/example/ruby/RingEcho.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: RingEcho -**Inherits:** Object - -**Includes:** DRbUndumped - - - - - -#Instance Methods -## echo(str) [](#method-i-echo) - -## initialize(name) [](#method-i-initialize) - -**@return** [RingEcho] a new instance of RingEcho - diff --git a/example/ruby/Ripper.md b/example/ruby/Ripper.md deleted file mode 100644 index b25a509..0000000 --- a/example/ruby/Ripper.md +++ /dev/null @@ -1,165 +0,0 @@ -# Class: Ripper -**Inherits:** Object - - -Ripper is a Ruby script parser. - -You can get information from the parser with event-based style. Information -such as abstract syntax trees or simple lexical analysis of the Ruby program. - -## Usage - -Ripper provides an easy interface for parsing your program into a symbolic -expression tree (or S-expression). - -Understanding the output of the parser may come as a challenge, it's -recommended you use PP to format the output for legibility. - - require 'ripper' - require 'pp' - - pp Ripper.sexp('def hello(world) "Hello, #{world}!"; end') - #=> [:program, - [[:def, - [:@ident, "hello", [1, 4]], - [:paren, - [:params, [[:@ident, "world", [1, 10]]], nil, nil, nil, nil, nil, nil]], - [:bodystmt, - [[:string_literal, - [:string_content, - [:@tstring_content, "Hello, ", [1, 18]], - [:string_embexpr, [[:var_ref, [:@ident, "world", [1, 27]]]]], - [:@tstring_content, "!", [1, 33]]]]], - nil, - nil, - nil]]]] - -You can see in the example above, the expression starts with `:program`. - -From here, a method definition at `:def`, followed by the method's identifier -`:@ident`. After the method's identifier comes the parentheses `:paren` and -the method parameters under `:params`. - -Next is the method body, starting at `:bodystmt` (`stmt` meaning statement), -which contains the full definition of the method. - -In our case, we're simply returning a String, so next we have the -`:string_literal` expression. - -Within our `:string_literal` you'll notice two `@tstring_content`, this is the -literal part for `Hello, ` and `!`. Between the two `@tstring_content` -statements is a `:string_embexpr`, where *embexpr* is an embedded expression. -Our expression consists of a local variable, or `var_ref`, with the identifier -(`@ident`) of `world`. - -## Resources - -* [Ruby - Inside](http://www.rubyinside.com/using-ripper-to-see-how-ruby-is-parsing- - your-code-5270.html) - -## Requirements - -* ruby 1.9 (support CVS HEAD only) -* bison 1.28 or later (Other yaccs do not work) - -## License - -Ruby License. - -* Minero Aoki -* aamine@loveruby.net -* http://i.loveruby.net - - -# Class Methods -## lex(src , filename '-', lineno 1, **kw ) [](#method-c-lex) -Tokenizes the Ruby program and returns an array of an array, which is -formatted like `[[lineno, column], type, token, state]`. The `filename` -argument is mostly ignored. By default, this method does not handle syntax -errors in `src`, use the `raise_errors` keyword to raise a SyntaxError for an -error in `src`. - - require 'ripper' - require 'pp' - - pp Ripper.lex("def m(a) nil end") - #=> [[[1, 0], :on_kw, "def", FNAME ], - [[1, 3], :on_sp, " ", FNAME ], - [[1, 4], :on_ident, "m", ENDFN ], - [[1, 5], :on_lparen, "(", BEG|LABEL], - [[1, 6], :on_ident, "a", ARG ], - [[1, 7], :on_rparen, ")", ENDFN ], - [[1, 8], :on_sp, " ", BEG ], - [[1, 9], :on_kw, "nil", END ], - [[1, 12], :on_sp, " ", END ], - [[1, 13], :on_kw, "end", END ]] -## parse(src , filename '(ripper)', lineno 1) [](#method-c-parse) -Parses the given Ruby program read from `src`. `src` must be a String or an IO -or a object with a #gets method. -## sexp(src , filename '-', lineno 1, raise_errors: false) [](#method-c-sexp) -EXPERIMENTAL -: Parses `src` and create S-exp tree. Returns more readable tree rather than - Ripper.sexp_raw. This method is mainly for developer use. The `filename` - argument is mostly ignored. By default, this method does not handle syntax - errors in `src`, returning `nil` in such cases. Use the `raise_errors` - keyword to raise a SyntaxError for an error in `src`. - - require 'ripper' - require 'pp' - - pp Ripper.sexp("def m(a) nil end") - #=> [:program, - [[:def, - [:@ident, "m", [1, 4]], - [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil, nil, nil, nil]], - [:bodystmt, [[:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]] - -## sexp_raw(src , filename '-', lineno 1, raise_errors: false) [](#method-c-sexp_raw) -EXPERIMENTAL -: Parses `src` and create S-exp tree. This method is mainly for developer - use. The `filename` argument is mostly ignored. By default, this method - does not handle syntax errors in `src`, returning `nil` in such cases. Use - the `raise_errors` keyword to raise a SyntaxError for an error in `src`. - - require 'ripper' - require 'pp' - - pp Ripper.sexp_raw("def m(a) nil end") - #=> [:program, - [:stmts_add, - [:stmts_new], - [:def, - [:@ident, "m", [1, 4]], - [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil]], - [:bodystmt, - [:stmts_add, [:stmts_new], [:var_ref, [:@kw, "nil", [1, 9]]]], - nil, - nil, - nil]]]] - -## slice(src , pattern , n 0) [](#method-c-slice) -EXPERIMENTAL -: Parses `src` and return a string which was matched to `pattern`. `pattern` - should be described as Regexp. - - require 'ripper' - - p Ripper.slice('def m(a) nil end', 'ident') #=> "m" - p Ripper.slice('def m(a) nil end', '[ident lparen rparen]+') #=> "m(a)" - p Ripper.slice("< "string\n" - -## token_match(src , pattern ) [](#method-c-token_match) -:nodoc: -## tokenize(src , filename '-', lineno 1, **kw ) [](#method-c-tokenize) -Tokenizes the Ruby program and returns an array of strings. The `filename` and -`lineno` arguments are mostly ignored, since the return value is just the -tokenized input. By default, this method does not handle syntax errors in -`src`, use the `raise_errors` keyword to raise a SyntaxError for an error in -`src`. - - p Ripper.tokenize("def m(a) nil end") - # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"] - diff --git a/example/ruby/Ripper/Filter.md b/example/ruby/Ripper/Filter.md deleted file mode 100644 index 8ed33f1..0000000 --- a/example/ruby/Ripper/Filter.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: Ripper::Filter -**Inherits:** Object - - -This class handles only scanner events, which are dispatched in the 'right' -order (same with input). - - - -#Instance Methods -## column() [](#method-i-column) -The column number of the current token. This value starts from 0. This method -is valid only in event handlers. - -## filename() [](#method-i-filename) -The file name of the input. - -## initialize(src, filename'-', lineno1) [](#method-i-initialize) -Creates a new Ripper::Filter instance, passes parameters `src`, `filename`, -and `lineno` to Ripper::Lexer.new - -The lexer is for internal use only. - -**@return** [Filter] a new instance of Filter - -## lineno() [](#method-i-lineno) -The line number of the current token. This value starts from 1. This method is -valid only in event handlers. - -## parse(initnil) [](#method-i-parse) -Starts the parser. `init` is a data accumulator and is passed to the next -event handler (as of Enumerable#inject). - -## state() [](#method-i-state) -The scanner's state of the current token. This value is the bitwise OR of zero -or more of the `Ripper::EXPR_*` constants. - diff --git a/example/ruby/Ripper/Lexer.md b/example/ruby/Ripper/Lexer.md deleted file mode 100644 index 13def99..0000000 --- a/example/ruby/Ripper/Lexer.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Ripper::Lexer -**Inherits:** Ripper - - -:nodoc: internal use only - - -# Attributes -## errors[RW] [](#attribute-i-errors) -Returns the value of attribute errors. - - -#Instance Methods -## lex(**kw) [](#method-i-lex) - -## parse(raise_errors:false) [](#method-i-parse) - -## scan(**kw) [](#method-i-scan) -parse the code and returns elements including errors. - -## tokenize(**kw) [](#method-i-tokenize) - diff --git a/example/ruby/Ripper/Lexer/Elem.md b/example/ruby/Ripper/Lexer/Elem.md deleted file mode 100644 index cbbcac3..0000000 --- a/example/ruby/Ripper/Lexer/Elem.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: Ripper::Lexer::Elem -**Inherits:** Object - - - - -# Attributes -## event[RW] [](#attribute-i-event) -Returns the value of attribute event. - -## message[RW] [](#attribute-i-message) -Returns the value of attribute message. - -## pos[RW] [](#attribute-i-pos) -Returns the value of attribute pos. - -## state[RW] [](#attribute-i-state) -Returns the value of attribute state. - -## tok[RW] [](#attribute-i-tok) -Returns the value of attribute tok. - - -#Instance Methods -## [](index) [](#method-i-[]) - -## initialize(pos, event, tok, state, messagenil) [](#method-i-initialize) - -**@return** [Elem] a new instance of Elem - -## inspect() [](#method-i-inspect) - -## pretty_print(q) [](#method-i-pretty_print) - -## to_a() [](#method-i-to_a) - diff --git a/example/ruby/Ripper/Lexer/State.md b/example/ruby/Ripper/Lexer/State.md deleted file mode 100644 index 13d2bdb..0000000 --- a/example/ruby/Ripper/Lexer/State.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: Ripper::Lexer::State -**Inherits:** Object - - -:stopdoc: - - -# Attributes -## to_int[RW] [](#attribute-i-to_int) -Returns the value of attribute to_int. - -## to_s[RW] [](#attribute-i-to_s) -Returns the value of attribute to_s. - - -#Instance Methods -## &(i) [](#method-i-&) - -## ==(i) [](#method-i-==) - -## [](index) [](#method-i-[]) - -## allbits?(i) [](#method-i-allbits?) - -**@return** [Boolean] - -## anybits?(i) [](#method-i-anybits?) - -**@return** [Boolean] - -## initialize(i) [](#method-i-initialize) - -**@return** [State] a new instance of State - -## nobits?(i) [](#method-i-nobits?) - -**@return** [Boolean] - -## pretty_print(q) [](#method-i-pretty_print) - -## |(i) [](#method-i-|) - diff --git a/example/ruby/Ripper/SexpBuilder.md b/example/ruby/Ripper/SexpBuilder.md deleted file mode 100644 index 0e70c9c..0000000 --- a/example/ruby/Ripper/SexpBuilder.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Ripper::SexpBuilder -**Inherits:** Ripper - - -:nodoc: - - -# Attributes -## error[RW] [](#attribute-i-error) -Returns the value of attribute error. - - diff --git a/example/ruby/Ripper/SexpBuilderPP.md b/example/ruby/Ripper/SexpBuilderPP.md deleted file mode 100644 index 3a03ad9..0000000 --- a/example/ruby/Ripper/SexpBuilderPP.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Ripper::SexpBuilderPP -**Inherits:** Ripper::SexpBuilder - - -:nodoc: - - - diff --git a/example/ruby/Ripper/TokenPattern.md b/example/ruby/Ripper/TokenPattern.md deleted file mode 100644 index e067f44..0000000 --- a/example/ruby/Ripper/TokenPattern.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Ripper::TokenPattern -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## initialize(pattern) [](#method-i-initialize) - -**@return** [TokenPattern] a new instance of TokenPattern - -## match(str) [](#method-i-match) - -## match_list(tokens) [](#method-i-match_list) - diff --git a/example/ruby/Ripper/TokenPattern/CompileError.md b/example/ruby/Ripper/TokenPattern/CompileError.md deleted file mode 100644 index af978ef..0000000 --- a/example/ruby/Ripper/TokenPattern/CompileError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Ripper::TokenPattern::CompileError -**Inherits:** Ripper::TokenPattern::Error - - -:nodoc: - - - diff --git a/example/ruby/Ripper/TokenPattern/Error.md b/example/ruby/Ripper/TokenPattern/Error.md deleted file mode 100644 index b6b44ea..0000000 --- a/example/ruby/Ripper/TokenPattern/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Ripper::TokenPattern::Error -**Inherits:** StandardError - - -:nodoc: - - - diff --git a/example/ruby/Ripper/TokenPattern/MatchData.md b/example/ruby/Ripper/TokenPattern/MatchData.md deleted file mode 100644 index a323748..0000000 --- a/example/ruby/Ripper/TokenPattern/MatchData.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: Ripper::TokenPattern::MatchData -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## initialize(tokens, match) [](#method-i-initialize) - -**@return** [MatchData] a new instance of MatchData - -## string(n0) [](#method-i-string) - diff --git a/example/ruby/Ripper/TokenPattern/MatchError.md b/example/ruby/Ripper/TokenPattern/MatchError.md deleted file mode 100644 index 3b36aa0..0000000 --- a/example/ruby/Ripper/TokenPattern/MatchError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Ripper::TokenPattern::MatchError -**Inherits:** Ripper::TokenPattern::Error - - -:nodoc: - - - diff --git a/example/ruby/Rotation.md b/example/ruby/Rotation.md deleted file mode 100644 index e11b069..0000000 --- a/example/ruby/Rotation.md +++ /dev/null @@ -1,71 +0,0 @@ -# Class: Rotation -**Inherits:** Object - - -class to represent all information about a particular rotation of a particular -piece - - -# Attributes -## start_masks[RW] [](#attribute-i-start_masks) -an array (by location) containing a bit mask for how the piece maps at the -given location. if the rotation is invalid at that location the mask will -contain false - - -#Instance Methods -## compute_required(mask, offset) [](#method-i-compute_required) - -## flood_fill(board, location) [](#method-i-flood_fill) - -## get_values(directions) [](#method-i-get_values) -given a set of directions places the piece (as defined by a set of directions) -on the board at a location that will not take it off the edge - -## initialize(directions) [](#method-i-initialize) - -**@return** [Rotation] a new instance of Rotation - -## mask_for_offsets(offsets) [](#method-i-mask_for_offsets) -produce a bitmask representation of an array of offset locations - -## normalize_offsets(values) [](#method-i-normalize_offsets) -returns a set of offsets relative to the top-left most piece of the rotation -(by even or odd rows) this is hard to explain. imagine we have this partial -board: - 0 0 0 0 0 x [positions 0-5] - 0 0 1 1 0 x [positions 6-11] - 0 0 1 0 0 x [positions 12-17] - 0 1 0 0 0 x [positions 18-23] - 0 1 0 0 0 x [positions 24-29] - 0 0 0 0 0 x [positions 30-35] - ... - -The top-left of the piece is at position 8, the board would be passed as a set -of positions (values array) containing [8,9,14,19,25] not necessarily in that -sorted order. Since that array starts on an odd row, the offsets for an odd -row are: [0,1,6,11,17] obtained by subtracting 8 from everything. Now imagine -the piece shifted up and to the right so it's on an even row: - 0 0 0 1 1 x [positions 0-5] - 0 0 1 0 0 x [positions 6-11] - 0 0 1 0 0 x [positions 12-17] - 0 1 0 0 0 x [positions 18-23] - 0 0 0 0 0 x [positions 24-29] - 0 0 0 0 0 x [positions 30-35] - ... - -Now the positions are [3,4,8,14,19] which after subtracting the lowest value -(3) gives [0,1,5,11,16] thus, the offsets for this particular piece are (in -even, odd order) [[0,1,5,11,16],](0,1,6,11,17) which is what this function -would return - -## offsets(location) [](#method-i-offsets) -given a location, produces a list of relative locations covered by the piece -at this rotation - -## start_adjust(directions) [](#method-i-start_adjust) -finds a "safe" position that a position as described by a list of directions -can be placed without falling off any edge of the board. the values returned -a location to place the first piece at so it will fit after making the -described moves - diff --git a/example/ruby/Ruby.md b/example/ruby/Ruby.md deleted file mode 100644 index a169ffa..0000000 --- a/example/ruby/Ruby.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Ruby - - - - - diff --git a/example/ruby/Ruby2HTML.md b/example/ruby/Ruby2HTML.md deleted file mode 100644 index 03e8f0d..0000000 --- a/example/ruby/Ruby2HTML.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Ruby2HTML -**Inherits:** Ripper::Filter - - - - -# Class Methods -## compile(f ) [](#method-c-compile) - -#Instance Methods -## on_comment(tok, f) [](#method-i-on_comment) - -## on_default(event, tok, f) [](#method-i-on_default) - -## on_kw(tok, f) [](#method-i-on_kw) - -## on_tstring_beg(tok, f) [](#method-i-on_tstring_beg) - -## on_tstring_end(tok, f) [](#method-i-on_tstring_end) - diff --git a/example/ruby/RubyExeSpecs.md b/example/ruby/RubyExeSpecs.md deleted file mode 100644 index 4fa7d4c..0000000 --- a/example/ruby/RubyExeSpecs.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: RubyExeSpecs -**Inherits:** Object - - - - - diff --git a/example/ruby/RubyImplementation.md b/example/ruby/RubyImplementation.md deleted file mode 100644 index ecdfac2..0000000 --- a/example/ruby/RubyImplementation.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: RubyImplementation -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## from_commit() [](#method-i-from_commit) - -## git_url() [](#method-i-git_url) - -## initialize(name, data) [](#method-i-initialize) - -**@return** [RubyImplementation] a new instance of RubyImplementation - -## last_merge_message() [](#method-i-last_merge_message) - -## prefix() [](#method-i-prefix) - -## rebased_branch() [](#method-i-rebased_branch) - -## repo_name() [](#method-i-repo_name) - -## repo_org() [](#method-i-repo_org) - -## repo_path() [](#method-i-repo_path) - diff --git a/example/ruby/RubyVM.md b/example/ruby/RubyVM.md deleted file mode 100644 index b14cadc..0000000 --- a/example/ruby/RubyVM.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: RubyVM -**Inherits:** Object - - -The RubyVM module only exists on MRI. `RubyVM` is not defined in other Ruby -implementations such as JRuby and TruffleRuby. - -The RubyVM module provides some access to MRI internals. This module is for -very limited purposes, such as debugging, prototyping, and research. Normal -users must not use it. This module is not portable between Ruby -implementations. - - -# Class Methods -## NSDR() [](#method-c-NSDR) -:nodoc: -## SDR() [](#method-c-SDR) -:nodoc: -## USAGE_ANALYSIS_INSN_CLEAR() [](#method-c-USAGE_ANALYSIS_INSN_CLEAR) -## USAGE_ANALYSIS_INSN_RUNNING() [](#method-c-USAGE_ANALYSIS_INSN_RUNNING) -## USAGE_ANALYSIS_INSN_START() [](#method-c-USAGE_ANALYSIS_INSN_START) -## USAGE_ANALYSIS_INSN_STOP() [](#method-c-USAGE_ANALYSIS_INSN_STOP) -## USAGE_ANALYSIS_OPERAND_CLEAR() [](#method-c-USAGE_ANALYSIS_OPERAND_CLEAR) -## USAGE_ANALYSIS_OPERAND_RUNNING() [](#method-c-USAGE_ANALYSIS_OPERAND_RUNNING) -## USAGE_ANALYSIS_OPERAND_START() [](#method-c-USAGE_ANALYSIS_OPERAND_START) -## USAGE_ANALYSIS_OPERAND_STOP() [](#method-c-USAGE_ANALYSIS_OPERAND_STOP) -## USAGE_ANALYSIS_REGISTER_CLEAR() [](#method-c-USAGE_ANALYSIS_REGISTER_CLEAR) -## USAGE_ANALYSIS_REGISTER_RUNNING() [](#method-c-USAGE_ANALYSIS_REGISTER_RUNNING) -## USAGE_ANALYSIS_REGISTER_START() [](#method-c-USAGE_ANALYSIS_REGISTER_START) -## USAGE_ANALYSIS_REGISTER_STOP() [](#method-c-USAGE_ANALYSIS_REGISTER_STOP) -## each_builtin() [](#method-c-each_builtin) -:nodoc: -## keep_script_lines() [](#method-c-keep_script_lines) -Return current `keep_script_lines` status. Now it only returns `true` of -`false`, but it can return other objects in future. - -Note that this is an API for ruby internal use, debugging, and research. Do -not use this for any other purpose. The compatibility is not guaranteed. -**@overload** [] - -## keep_script_lines=(flags ) [](#method-c-keep_script_lines=) -It set `keep_script_lines` flag. If the flag is set, all loaded scripts are -recorded in a interpreter process. - -Note that this is an API for ruby internal use, debugging, and research. Do -not use this for any other purpose. The compatibility is not guaranteed. -**@overload** [] - -## mtbl(obj , sym ) [](#method-c-mtbl) -:nodoc: -## mtbl2(obj , sym ) [](#method-c-mtbl2) -:nodoc: -## reset_debug_counters() [](#method-c-reset_debug_counters) -## show_debug_counters() [](#method-c-show_debug_counters) -## stat(*args ) [](#method-c-stat) -Returns a Hash containing implementation-dependent counters inside the VM. - -This hash includes information about method/constant caches: - - { - :constant_cache_invalidations=>2, - :constant_cache_misses=>14, - :global_cvar_state=>27 - } - -If `USE_DEBUG_COUNTER` is enabled, debug counters will be included. - -The contents of the hash are implementation specific and may be changed in the -future. - -This method is only expected to work on C Ruby. -**@overload** [] - -**@overload** [] - -**@overload** [] - - diff --git a/example/ruby/RubyVM/AbstractSyntaxTree.md b/example/ruby/RubyVM/AbstractSyntaxTree.md deleted file mode 100644 index c6d5410..0000000 --- a/example/ruby/RubyVM/AbstractSyntaxTree.md +++ /dev/null @@ -1,102 +0,0 @@ -# Module: RubyVM::AbstractSyntaxTree - - -AbstractSyntaxTree provides methods to parse Ruby code into abstract syntax -trees. The nodes in the tree are instances of -RubyVM::AbstractSyntaxTree::Node. - -This module is MRI specific as it exposes implementation details of the MRI -abstract syntax tree. - -This module is experimental and its API is not stable, therefore it might -change without notice. As examples, the order of children nodes is not -guaranteed, the number of children nodes might change, there is no way to -access children nodes by name, etc. - -If you are looking for a stable API or an API working under multiple Ruby -implementations, consider using the *prism* gem, which is the official Ruby -API to parse Ruby code. - - -# Class Methods -## node_id_for_backtrace_location(backtrace_location ) [](#method-c-node_id_for_backtrace_location) -call-seq: - RubyVM::AbstractSyntaxTree.node_id_for_backtrace_location(backtrace_location) -> integer - - Returns the node id for the given backtrace location. - - begin - raise - rescue => e - loc = e.backtrace_locations.first - RubyVM::AbstractSyntaxTree.node_id_for_backtrace_location(loc) - end # => 0 -## of(body , keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) [](#method-c-of) -call-seq: - RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node - RubyVM::AbstractSyntaxTree.of(method, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node - - Returns AST nodes of the given _proc_ or _method_. - - RubyVM::AbstractSyntaxTree.of(proc {1 + 2}) - # => # - - def hello - puts "hello, world" - end - - RubyVM::AbstractSyntaxTree.of(method(:hello)) - # => # - - See ::parse for explanation of keyword argument meaning and usage. -## parse(string , keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) [](#method-c-parse) -call-seq: - RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node - - Parses the given _string_ into an abstract syntax tree, - returning the root node of that tree. - - RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") - # => # - - If keep_script_lines: true option is provided, the text of the parsed - source is associated with nodes and is available via Node#script_lines. - - If keep_tokens: true option is provided, Node#tokens are populated. - - SyntaxError is raised if the given _string_ is invalid syntax. To overwrite this - behavior, error_tolerant: true can be provided. In this case, the parser - will produce a tree where expressions with syntax errors would be represented by - Node with type=:ERROR. - - root = RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2") - # :33:in `parse': syntax error, unexpected ';', expecting ')' (SyntaxError) - # x = 1; p(x; y=2 - # ^ - - root = RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2", error_tolerant: true) - # (SCOPE@1:0-1:15 - # tbl: [:x, :y] - # args: nil - # body: (BLOCK@1:0-1:15 (LASGN@1:0-1:5 :x (LIT@1:4-1:5 1)) (ERROR@1:7-1:11) (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2)))) - root.children.last.children - # [(LASGN@1:0-1:5 :x (LIT@1:4-1:5 1)), - # (ERROR@1:7-1:11), - # (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2))] - - Note that parsing continues even after the errored expression. -## parse_file(pathname , keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) [](#method-c-parse_file) -call-seq: - RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node - - Reads the file from _pathname_, then parses it like ::parse, - returning the root node of the abstract syntax tree. - - SyntaxError is raised if _pathname_'s contents are not - valid Ruby syntax. - - RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb") - # => # - - See ::parse for explanation of keyword argument meaning and usage. - diff --git a/example/ruby/RubyVM/AbstractSyntaxTree/Location.md b/example/ruby/RubyVM/AbstractSyntaxTree/Location.md deleted file mode 100644 index 0e4c3b2..0000000 --- a/example/ruby/RubyVM/AbstractSyntaxTree/Location.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: RubyVM::AbstractSyntaxTree::Location -**Inherits:** Object - - -RubyVM::AbstractSyntaxTree::Location instances are created by -RubyVM::AbstractSyntaxTree::Node#locations. - -This class is MRI specific. - - - -#Instance Methods -## first_column() [](#method-i-first_column) -call-seq: - location.first_column -> integer - - The column number in the source code where this AST's text began. - -## first_lineno() [](#method-i-first_lineno) -call-seq: - location.first_lineno -> integer - - The line number in the source code where this AST's text began. - -## inspect() [](#method-i-inspect) -call-seq: - location.inspect -> string - - Returns debugging information about this location as a string. - -## last_column() [](#method-i-last_column) -call-seq: - location.last_column -> integer - - The column number in the source code where this AST's text ended. - -## last_lineno() [](#method-i-last_lineno) -call-seq: - location.last_lineno -> integer - - The line number in the source code where this AST's text ended. - diff --git a/example/ruby/RubyVM/AbstractSyntaxTree/Node.md b/example/ruby/RubyVM/AbstractSyntaxTree/Node.md deleted file mode 100644 index bb0ac3d..0000000 --- a/example/ruby/RubyVM/AbstractSyntaxTree/Node.md +++ /dev/null @@ -1,138 +0,0 @@ -# Class: RubyVM::AbstractSyntaxTree::Node -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## all_tokens() [](#method-i-all_tokens) -call-seq: - node.all_tokens -> array - - Returns all tokens for the input script regardless the receiver node. - Returns +nil+ if +keep_tokens+ is not enabled when #parse method is called. - - root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2", keep_tokens: true) - root.all_tokens # => [[0, :tIDENTIFIER, "x", [1, 0, 1, 1]], [1, :tSP, " ", [1, 1, 1, 2]], ...] - root.children[-1].all_tokens # => [[0, :tIDENTIFIER, "x", [1, 0, 1, 1]], [1, :tSP, " ", [1, 1, 1, 2]], ...] - -## beg_pos() [](#method-i-beg_pos) - -## children() [](#method-i-children) -call-seq: - node.children -> array - - Returns AST nodes under this one. Each kind of node - has different children, depending on what kind of node it is. - - The returned array may contain other nodes or nil. - -## end_pos() [](#method-i-end_pos) - -## first_column() [](#method-i-first_column) -call-seq: - node.first_column -> integer - - The column number in the source code where this AST's text began. - -## first_lineno() [](#method-i-first_lineno) -call-seq: - node.first_lineno -> integer - - The line number in the source code where this AST's text began. - -## inspect() [](#method-i-inspect) -call-seq: - node.inspect -> string - - Returns debugging information about this node as a string. - -## last_column() [](#method-i-last_column) -call-seq: - node.last_column -> integer - - The column number in the source code where this AST's text ended. - -## last_lineno() [](#method-i-last_lineno) -call-seq: - node.last_lineno -> integer - - The line number in the source code where this AST's text ended. - -## locations() [](#method-i-locations) -call-seq: - node.locations -> array - - Returns location objects associated with the AST node. - The returned array contains RubyVM::AbstractSyntaxTree::Location. - -## node_id() [](#method-i-node_id) -call-seq: - node.node_id -> integer - - Returns an internal node_id number. - Note that this is an API for ruby internal use, debugging, - and research. Do not use this for any other purpose. - The compatibility is not guaranteed. - -## pretty_print(q) [](#method-i-pretty_print) - -## pretty_print_children(q, names[]) [](#method-i-pretty_print_children) - -## script_lines() [](#method-i-script_lines) -call-seq: - node.script_lines -> array - - Returns the original source code as an array of lines. - - Note that this is an API for ruby internal use, debugging, - and research. Do not use this for any other purpose. - The compatibility is not guaranteed. - -## source() [](#method-i-source) -call-seq: - node.source -> string - - Returns the code fragment that corresponds to this AST. - - Note that this is an API for ruby internal use, debugging, - and research. Do not use this for any other purpose. - The compatibility is not guaranteed. - - Also note that this API may return an incomplete code fragment - that does not parse; for example, a here document following - an expression may be dropped. - -## tokens() [](#method-i-tokens) -call-seq: - node.tokens -> array - - Returns tokens corresponding to the location of the node. - Returns +nil+ if +keep_tokens+ is not enabled when #parse method is called. - - root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2", keep_tokens: true) - root.tokens # => [[0, :tIDENTIFIER, "x", [1, 0, 1, 1]], [1, :tSP, " ", [1, 1, 1, 2]], ...] - root.tokens.map{_1[2]}.join # => "x = 1 + 2" - - Token is an array of: - - - id - - token type - - source code text - - location [ first_lineno, first_column, last_lineno, last_column ] - -## type() [](#method-i-type) -call-seq: - node.type -> symbol - - Returns the type of this node as a symbol. - - root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") - root.type # => :SCOPE - lasgn = root.children[2] - lasgn.type # => :LASGN - call = lasgn.children[1] - call.type # => :OPCALL - diff --git a/example/ruby/RubyVM/AbstractSyntaxTree/Node/CodePosition.md b/example/ruby/RubyVM/AbstractSyntaxTree/Node/CodePosition.md deleted file mode 100644 index dce6f17..0000000 --- a/example/ruby/RubyVM/AbstractSyntaxTree/Node/CodePosition.md +++ /dev/null @@ -1,106 +0,0 @@ -# Class: RubyVM::AbstractSyntaxTree::Node::CodePosition -**Inherits:** Object - -**Includes:** Comparable - - - - -# Attributes -## column[RW] [](#attribute-i-column) -Returns the value of attribute column. - -## lineno[RW] [](#attribute-i-lineno) -Returns the value of attribute lineno. - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## initialize(lineno, column) [](#method-i-initialize) - -**@return** [CodePosition] a new instance of CodePosition - diff --git a/example/ruby/RubyVM/Attribute.md b/example/ruby/RubyVM/Attribute.md deleted file mode 100644 index 22bdad4..0000000 --- a/example/ruby/RubyVM/Attribute.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: RubyVM::Attribute -**Inherits:** Object - -**Includes:** RubyVM::CEscape - - - - -# Attributes -## expr[RW] [](#attribute-i-expr) -Returns the value of attribute expr. - -## insn[RW] [](#attribute-i-insn) -Returns the value of attribute insn. - -## key[RW] [](#attribute-i-key) -Returns the value of attribute key. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## declaration() [](#method-i-declaration) - -## definition() [](#method-i-definition) - -## initialize(opts{}) [](#method-i-initialize) - -**@return** [Attribute] a new instance of Attribute - -## name() [](#method-i-name) - -## pretty_name() [](#method-i-pretty_name) - diff --git a/example/ruby/RubyVM/BareInstructions.md b/example/ruby/RubyVM/BareInstructions.md deleted file mode 100644 index bc1f2df..0000000 --- a/example/ruby/RubyVM/BareInstructions.md +++ /dev/null @@ -1,90 +0,0 @@ -# Class: RubyVM::BareInstructions -**Inherits:** Object - - - - -# Attributes -## decls[RW] [](#attribute-i-decls) -Returns the value of attribute decls. - -## expr[RW] [](#attribute-i-expr) -Returns the value of attribute expr. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - -## operands[RW] [](#attribute-i-operands) -Returns the value of attribute operands. - -## pops[RW] [](#attribute-i-pops) -Returns the value of attribute pops. - -## rets[RW] [](#attribute-i-rets) -Returns the value of attribute rets. - -## template[RW] [](#attribute-i-template) -Returns the value of attribute template. - - -#Instance Methods -## always_leaf?() [](#method-i-always_leaf?) - -**@return** [Boolean] - -## attributes() [](#method-i-attributes) - -## bin() [](#method-i-bin) - -## call_attribute(name) [](#method-i-call_attribute) - -## cast_from_VALUE(var, expr) [](#method-i-cast_from_VALUE) - -## cast_to_VALUE(var, expr) [](#method-i-cast_to_VALUE) - -## declarations() [](#method-i-declarations) - -## handle_canary(stmt) [](#method-i-handle_canary) - -## handles_sp?() [](#method-i-handles_sp?) - -**@return** [Boolean] - -## has_attribute?(k) [](#method-i-has_attribute?) - -**@return** [Boolean] - -## has_ope?(var) [](#method-i-has_ope?) - -**@return** [Boolean] - -## has_pop?(var) [](#method-i-has_pop?) - -**@return** [Boolean] - -## initialize(opts{}) [](#method-i-initialize) - -**@return** [BareInstructions] a new instance of BareInstructions - -## inspect() [](#method-i-inspect) - -## leaf_without_check_ints?() [](#method-i-leaf_without_check_ints?) - -**@return** [Boolean] - -## operands_info() [](#method-i-operands_info) - -## preamble() [](#method-i-preamble) - -## pretty_name() [](#method-i-pretty_name) - -## sc?() [](#method-i-sc?) - -**@return** [Boolean] - -## use_call_data?() [](#method-i-use_call_data?) - -**@return** [Boolean] - -## width() [](#method-i-width) - diff --git a/example/ruby/RubyVM/CEscape.md b/example/ruby/RubyVM/CEscape.md deleted file mode 100644 index 6c29b8d..0000000 --- a/example/ruby/RubyVM/CEscape.md +++ /dev/null @@ -1,23 +0,0 @@ -# Module: RubyVM::CEscape - - - - -# Class Methods -## as_tr_cpp(name ) [](#method-c-as_tr_cpp) -Mimic AS_TR_CPP() of autoconf. -## commentify(str ) [](#method-c-commentify) -generate comment, with escaps. -## gensym(prefix 'gensym_') [](#method-c-gensym) -Mimic gensym of CL. -## rstring2cstr(str ) [](#method-c-rstring2cstr) -Section 6.10.4 of ISO/IEC 9899:1999 specifies that the file name used for -#line directive shall be a "character string literal". So this is needed. - -I'm not sure how many chars are allowed here, though. The standard -specifies 4095 chars at most, after string concatenation (section 5.2.4.1). -But it is easy to have a path that is longer than that. - -Here we ignore the standard. Just create single string literal of any -needed length. - diff --git a/example/ruby/RubyVM/CExpr.md b/example/ruby/RubyVM/CExpr.md deleted file mode 100644 index 607a7b9..0000000 --- a/example/ruby/RubyVM/CExpr.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: RubyVM::CExpr -**Inherits:** Object - -**Includes:** RubyVM::CEscape - - - - -# Attributes -## __FILE__[RW] [](#attribute-i-__FILE__) -Returns the value of attribute __FILE__. - -## __LINE__[RW] [](#attribute-i-__LINE__) -Returns the value of attribute __LINE__. - -## expr[RW] [](#attribute-i-expr) -Returns the value of attribute expr. - - -#Instance Methods -## blank?() [](#method-i-blank?) - -**@return** [Boolean] - -## initialize(opts{}) [](#method-i-initialize) - -**@return** [CExpr] a new instance of CExpr - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/RubyVM/Dumper.md b/example/ruby/RubyVM/Dumper.md deleted file mode 100644 index d50c2d3..0000000 --- a/example/ruby/RubyVM/Dumper.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: RubyVM::Dumper -**Inherits:** Object - -**Includes:** RubyVM::CEscape - - - - - -#Instance Methods -## do_render(source, locals) [](#method-i-do_render) - -## generate(template) [](#method-i-generate) - -## initialize(dst, base) [](#method-i-initialize) - -**@return** [Dumper] a new instance of Dumper - -## render(partial, opts{ :locals => {} }) [](#method-i-render) - -## replace_pragma(str) [](#method-i-replace_pragma) - diff --git a/example/ruby/RubyVM/Insns2VM.md b/example/ruby/RubyVM/Insns2VM.md deleted file mode 100644 index aa62024..0000000 --- a/example/ruby/RubyVM/Insns2VM.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: RubyVM::Insns2VM - - - - -# Class Methods -## router(argv ) [](#method-c-router) - diff --git a/example/ruby/RubyVM/InstructionSequence.md b/example/ruby/RubyVM/InstructionSequence.md deleted file mode 100644 index 1c4fcd4..0000000 --- a/example/ruby/RubyVM/InstructionSequence.md +++ /dev/null @@ -1,655 +0,0 @@ -# Class: RubyVM::InstructionSequence -**Inherits:** Object - - -iseq_loader.rb - sample of compiler/loader for binary compiled file - -Usage as a compiler: ruby iseq_loader.rb [file or directory] ... - - It compiles and stores specified files. - If directories are specified, then compiles and stores all *.rb files. - (using Dir.glob) - -TODO: add remove option TODO: add verify option - -Usage as a loader: simply require this file with the following setting. - -Setting with environment variables. - - * RUBY_ISEQ_LOADER_STORAGE to select storage type - * dbm: use dbm - * fs: [default] use file system. locate a compiled binary files in same - directory of scripts like Rubinius. foo.rb.yarb will be created for foo.rb. - * fs2: use file system. locate compiled file in specified directory. - * nothing: do nothing. - - * RUBY_ISEQ_LOADER_STORAGE_DIR to select directory - * default: ~/.ruby_binaries/ - - * RUBY_ISEQ_LOADER_STORAGE_COMPILE_IF_NOT_COMPILED - * true: store compiled file if compiled data is not available. - * false: [default] do nothing if there is no compiled iseq data. - - -# Class Methods -## compare_dump_and_load(i1 , dumper , loader ) [](#method-c-compare_dump_and_load) -## compile(*args ) [](#method-c-compile) -Takes `source`, which can be a string of Ruby code, or an open `File` object. -that contains Ruby source code. - -Optionally takes `file`, `path`, and `line` which describe the file path, real -path and first line number of the ruby code in `source` which are metadata -attached to the returned `iseq`. - -`file` is used for `__FILE__` and exception backtrace. `path` is used for -`require_relative` base. It is recommended these should be the same full path. - -`options`, which can be `true`, `false` or a `Hash`, is used to modify the -default behavior of the Ruby iseq compiler. - -For details regarding valid compile options see ::compile_option=. - - RubyVM::InstructionSequence.compile("a = 1 + 2") - #=> @> - - path = "test.rb" - RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path)) - #=> @test.rb:1> - - file = File.open("test.rb") - RubyVM::InstructionSequence.compile(file) - #=> @:1> - - path = File.expand_path("test.rb") - RubyVM::InstructionSequence.compile(File.read(path), path, path) - #=> @/absolute/path/to/test.rb:1> -**@overload** [] - -**@overload** [] - -## compile_and_save_iseq(fname ) [](#method-c-compile_and_save_iseq) -## compile_file(*args ) [](#method-c-compile_file) -Takes `file`, a String with the location of a Ruby source file, reads, parses -and compiles the file, and returns `iseq`, the compiled InstructionSequence -with source location metadata set. - -Optionally takes `options`, which can be `true`, `false` or a `Hash`, to -modify the default behavior of the Ruby iseq compiler. - -For details regarding valid compile options see ::compile_option=. - - # /tmp/hello.rb - puts "Hello, world!" - - # elsewhere - RubyVM::InstructionSequence.compile_file("/tmp/hello.rb") - #=> @/tmp/hello.rb> -**@overload** [] - -## compile_file_prism(*args ) [](#method-c-compile_file_prism) -Takes `file`, a String with the location of a Ruby source file, reads, parses -and compiles the file, and returns `iseq`, the compiled InstructionSequence -with source location metadata set. It parses and compiles using prism. - -Optionally takes `options`, which can be `true`, `false` or a `Hash`, to -modify the default behavior of the Ruby iseq compiler. - -For details regarding valid compile options see ::compile_option=. - - # /tmp/hello.rb - puts "Hello, world!" - - # elsewhere - RubyVM::InstructionSequence.compile_file_prism("/tmp/hello.rb") - #=> @/tmp/hello.rb> -**@overload** [] - -## compile_option() [](#method-c-compile_option) -Returns a hash of default options used by the Ruby iseq compiler. - -For details, see InstructionSequence.compile_option=. -**@overload** [] - -## compile_option=(opt ) [](#method-c-compile_option=) -Sets the default values for various optimizations in the Ruby iseq compiler. - -Possible values for `options` include `true`, which enables all options, -`false` which disables all options, and `nil` which leaves all options -unchanged. - -You can also pass a `Hash` of `options` that you want to change, any options -not present in the hash will be left unchanged. - -Possible option names (which are keys in `options`) which can be set to `true` -or `false` include: - -* `:inline_const_cache` -* `:instructions_unification` -* `:operands_unification` -* `:peephole_optimization` -* `:specialized_instruction` -* `:tailcall_optimization` - -Additionally, `:debug_level` can be set to an integer. - -These default options can be overwritten for a single run of the iseq compiler -by passing any of the above values as the `options` parameter to ::new, -::compile and ::compile_file. -**@overload** [] - -## compile_parsey(*args ) [](#method-c-compile_parsey) -Takes `source`, which can be a string of Ruby code, or an open `File` object. -that contains Ruby source code. It parses and compiles using parse.y. - -Optionally takes `file`, `path`, and `line` which describe the file path, real -path and first line number of the ruby code in `source` which are metadata -attached to the returned `iseq`. - -`file` is used for `__FILE__` and exception backtrace. `path` is used for -`require_relative` base. It is recommended these should be the same full path. - -`options`, which can be `true`, `false` or a `Hash`, is used to modify the -default behavior of the Ruby iseq compiler. - -For details regarding valid compile options see ::compile_option=. - - RubyVM::InstructionSequence.compile_parsey("a = 1 + 2") - #=> @> - - path = "test.rb" - RubyVM::InstructionSequence.compile_parsey(File.read(path), path, File.expand_path(path)) - #=> @test.rb:1> - - file = File.open("test.rb") - RubyVM::InstructionSequence.compile_parsey(file) - #=> @:1> - - path = File.expand_path("test.rb") - RubyVM::InstructionSequence.compile_parsey(File.read(path), path, path) - #=> @/absolute/path/to/test.rb:1> -**@overload** [] - -## compile_prism(*args ) [](#method-c-compile_prism) -Takes `source`, which can be a string of Ruby code, or an open `File` object. -that contains Ruby source code. It parses and compiles using prism. - -Optionally takes `file`, `path`, and `line` which describe the file path, real -path and first line number of the ruby code in `source` which are metadata -attached to the returned `iseq`. - -`file` is used for `__FILE__` and exception backtrace. `path` is used for -`require_relative` base. It is recommended these should be the same full path. - -`options`, which can be `true`, `false` or a `Hash`, is used to modify the -default behavior of the Ruby iseq compiler. - -For details regarding valid compile options see ::compile_option=. - - RubyVM::InstructionSequence.compile_prism("a = 1 + 2") - #=> @> - - path = "test.rb" - RubyVM::InstructionSequence.compile_prism(File.read(path), path, File.expand_path(path)) - #=> @test.rb:1> - - file = File.open("test.rb") - RubyVM::InstructionSequence.compile_prism(file) - #=> @:1> - - path = File.expand_path("test.rb") - RubyVM::InstructionSequence.compile_prism(File.read(path), path, path) - #=> @/absolute/path/to/test.rb:1> -**@overload** [] - -## disasm(body ) [](#method-c-disasm) -Takes `body`, a Method or Proc object, and returns a String with the human -readable instructions for `body`. - -For a Method object: - - # /tmp/method.rb - def hello - puts "hello, world" - end - - puts RubyVM::InstructionSequence.disasm(method(:hello)) - -Produces: - - == disasm: ============ - 0000 trace 8 ( 1) - 0002 trace 1 ( 2) - 0004 putself - 0005 putstring "hello, world" - 0007 send :puts, 1, nil, 8, - 0013 trace 16 ( 3) - 0015 leave ( 2) - -For a Proc: - - # /tmp/proc.rb - p = proc { num = 1 + 2 } - puts RubyVM::InstructionSequence.disasm(p) - -Produces: - - == disasm: @/tmp/proc.rb>=== - == catch table - | catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000 - | catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012 - |------------------------------------------------------------------------ - local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1) - [ 2] num - 0000 trace 1 ( 1) - 0002 putobject 1 - 0004 putobject 2 - 0006 opt_plus - 0008 dup - 0009 setlocal num, 0 - 0012 leave -**@overload** [] - -**@overload** [] - -## disassemble(body ) [](#method-c-disassemble) -Takes `body`, a Method or Proc object, and returns a String with the human -readable instructions for `body`. - -For a Method object: - - # /tmp/method.rb - def hello - puts "hello, world" - end - - puts RubyVM::InstructionSequence.disasm(method(:hello)) - -Produces: - - == disasm: ============ - 0000 trace 8 ( 1) - 0002 trace 1 ( 2) - 0004 putself - 0005 putstring "hello, world" - 0007 send :puts, 1, nil, 8, - 0013 trace 16 ( 3) - 0015 leave ( 2) - -For a Proc: - - # /tmp/proc.rb - p = proc { num = 1 + 2 } - puts RubyVM::InstructionSequence.disasm(p) - -Produces: - - == disasm: @/tmp/proc.rb>=== - == catch table - | catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000 - | catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012 - |------------------------------------------------------------------------ - local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1) - [ 2] num - 0000 trace 1 ( 1) - 0002 putobject 1 - 0004 putobject 2 - 0006 opt_plus - 0008 dup - 0009 setlocal num, 0 - 0012 leave -**@overload** [] - -**@overload** [] - -## iseq_load(*args ) [](#method-c-iseq_load) -## load(*args ) [](#method-c-load) -:nodoc: -## load_from_binary(str ) [](#method-c-load_from_binary) -Load an iseq object from binary format String object created by -RubyVM::InstructionSequence.to_binary. - -This loader does not have a verifier, so that loading broken/modified binary -causes critical problem. - -You should not load binary data provided by others. You should use binary data -translated by yourself. -**@overload** [] - -## load_from_binary_extra_data(str ) [](#method-c-load_from_binary_extra_data) -Load extra data embed into binary format String object. -**@overload** [] - -## load_iseq(filepath ) [](#method-c-load_iseq) -If RUBY_ISEQ_DUMP_DEBUG is "prism", we'll set up InstructionSequence.load_iseq -to intercept loading filepaths to compile using prism. -## new(*args ) [](#method-c-new) -Takes `source`, which can be a string of Ruby code, or an open `File` object. -that contains Ruby source code. - -Optionally takes `file`, `path`, and `line` which describe the file path, real -path and first line number of the ruby code in `source` which are metadata -attached to the returned `iseq`. - -`file` is used for `__FILE__` and exception backtrace. `path` is used for -`require_relative` base. It is recommended these should be the same full path. - -`options`, which can be `true`, `false` or a `Hash`, is used to modify the -default behavior of the Ruby iseq compiler. - -For details regarding valid compile options see ::compile_option=. - - RubyVM::InstructionSequence.compile("a = 1 + 2") - #=> @> - - path = "test.rb" - RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path)) - #=> @test.rb:1> - - file = File.open("test.rb") - RubyVM::InstructionSequence.compile(file) - #=> @:1> - - path = File.expand_path("test.rb") - RubyVM::InstructionSequence.compile(File.read(path), path, path) - #=> @/absolute/path/to/test.rb:1> -**@overload** [] - -**@overload** [] - -## of(body ) [](#method-c-of) -Returns the instruction sequence containing the given proc or method. - -For example, using irb: - -# a proc > p = proc { num = 1 + 2 } > RubyVM::InstructionSequence.of(p) > #=> - - -# for a method > def foo(bar); puts bar; end > -RubyVM::InstructionSequence.of(method(:foo)) > #=> - - -Using ::compile_file: - -# /tmp/iseq_of.rb def hello - puts "hello, world" - -end - -$a_global_proc = proc { str = 'a' + 'b' } - -# in irb > require '/tmp/iseq_of.rb' - -# first the method hello > RubyVM::InstructionSequence.of(method(:hello)) > -#=> # - -# then the global proc > RubyVM::InstructionSequence.of($a_global_proc) > #=> -# -## translate(i1 ) [](#method-c-translate) -## unlink_compiled_iseq(fname ) [](#method-c-unlink_compiled_iseq) - -#Instance Methods -## absolute_path() [](#method-i-absolute_path) -Returns the absolute path of this instruction sequence. - -`nil` if the iseq was evaluated from a string. - -For example, using ::compile_file: - -# /tmp/method.rb def hello - puts "hello, world" - -end - -# in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > -iseq.absolute_path #=> /tmp/method.rb - -## base_label() [](#method-i-base_label) -Returns the base label of this instruction sequence. - -For example, using irb: - -iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> -@> iseq.base_label #=> -"" - -Using ::compile_file: - -# /tmp/method.rb def hello - puts "hello, world" - -end - -# in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > -iseq.base_label #=>
- -## disasm() [](#method-i-disasm) -Returns the instruction sequence as a `String` in human readable form. - - puts RubyVM::InstructionSequence.compile('1 + 2').disasm - -Produces: - - == disasm: @>========== - 0000 trace 1 ( 1) - 0002 putobject 1 - 0004 putobject 2 - 0006 opt_plus - 0008 leave - -**@overload** [] - -**@overload** [] - -## disasm_if_possible() [](#method-i-disasm_if_possible) - -## disassemble() [](#method-i-disassemble) -Returns the instruction sequence as a `String` in human readable form. - - puts RubyVM::InstructionSequence.compile('1 + 2').disasm - -Produces: - - == disasm: @>========== - 0000 trace 1 ( 1) - 0002 putobject 1 - 0004 putobject 2 - 0006 opt_plus - 0008 leave - -**@overload** [] - -**@overload** [] - -## each_child() [](#method-i-each_child) -Iterate all direct child instruction sequences. Iteration order is -implementation/version defined so that people should not rely on the order. - -**@overload** [] - -## eval() [](#method-i-eval) -Evaluates the instruction sequence and returns the result. - - RubyVM::InstructionSequence.compile("1 + 2").eval #=> 3 - -**@overload** [] - -## first_lineno() [](#method-i-first_lineno) -Returns the number of the first source line where the instruction sequence was -loaded from. - -For example, using irb: - -iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> -@> iseq.first_lineno #=> 1 - -## inspect() [](#method-i-inspect) -Returns a human-readable string representation of this instruction sequence, -including the #label and #path. - -## label() [](#method-i-label) -Returns the label of this instruction sequence. - -`
` if it's at the top level, `` if it was evaluated from a -string. - -For example, using irb: - -iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> -@> iseq.label #=> -"" - -Using ::compile_file: - -# /tmp/method.rb def hello - puts "hello, world" - -end - -# in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > -iseq.label #=>
- -## path() [](#method-i-path) -Returns the path of this instruction sequence. - -`` if the iseq was evaluated from a string. - -For example, using irb: - -iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> -@> iseq.path #=> "" - -Using ::compile_file: - -# /tmp/method.rb def hello - puts "hello, world" - -end - -# in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > -iseq.path #=> /tmp/method.rb - -## script_lines() [](#method-i-script_lines) -It returns recorded script lines if it is available. The script lines are not -limited to the iseq range, but are entire lines of the source file. - -Note that this is an API for ruby internal use, debugging, and research. Do -not use this for any other purpose. The compatibility is not guaranteed. - -**@overload** [] - -## to_a() [](#method-i-to_a) -Returns an Array with 14 elements representing the instruction sequence with -the following data: - -magic -: A string identifying the data format. **Always - `YARVInstructionSequence/SimpleDataFormat`.** - - -major_version -: The major version of the instruction sequence. - - -minor_version -: The minor version of the instruction sequence. - - -format_type -: A number identifying the data format. **Always 1**. - - -misc -: A hash containing: - - - `:arg_size` -: - -the total number of arguments taken by the method or the block (0 if *iseq* -doesn't represent a method or block) - [+:local_size+] - -the number of local variables + 1 - [+:stack_max+] - -used in calculating the stack depth at which a SystemStackError is thrown. - -#label -: The name of the context (block, method, class, module, etc.) that this - instruction sequence belongs to. - - `
` if it's at the top level, `` if it was evaluated from a - string. - - -#path -: The relative path to the Ruby file where the instruction sequence was - loaded from. - - `` if the iseq was evaluated from a string. - - -#absolute_path -: The absolute path to the Ruby file where the instruction sequence was - loaded from. - - `nil` if the iseq was evaluated from a string. - - -#first_lineno -: The number of the first source line where the instruction sequence was - loaded from. - - -type -: The type of the instruction sequence. - - Valid values are `:top`, `:method`, `:block`, `:class`, `:rescue`, - `:ensure`, `:eval`, `:main`, and `plain`. - - -locals -: An array containing the names of all arguments and local variables as - symbols. - - -params -: An Hash object containing parameter information. - - More info about these values can be found in `vm_core.h`. - - -catch_table -: A list of exceptions and control flow operators (rescue, next, redo, - break, etc.). - - -bytecode -: An array of arrays containing the instruction names and operands that make - up the body of the instruction sequence. - - -Note that this format is MRI specific and version dependent. - -**@overload** [] - -## to_binary(*args) [](#method-i-to_binary) -Returns serialized iseq binary format data as a String object. A corresponding -iseq object is created by RubyVM::InstructionSequence.load_from_binary() -method. - -String extra_data will be saved with binary data. You can access this data -with RubyVM::InstructionSequence.load_from_binary_extra_data(binary). - -Note that the translated binary data is not portable. You can not move this -binary data to another machine. You can not use the binary data which is -created by another version/another architecture of Ruby. - -**@overload** [] - -## trace_points() [](#method-i-trace_points) -Return trace points in the instruction sequence. Return an array of [line, -event_symbol] pair. - -**@overload** [] - diff --git a/example/ruby/RubyVM/InstructionSequence/BasicStorage.md b/example/ruby/RubyVM/InstructionSequence/BasicStorage.md deleted file mode 100644 index c6e6ba5..0000000 --- a/example/ruby/RubyVM/InstructionSequence/BasicStorage.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: RubyVM::InstructionSequence::BasicStorage -**Inherits:** Object - - - - - -#Instance Methods -## compile_and_save_iseq(fname, iseq_keyiseq_key_name(fname)) [](#method-i-compile_and_save_iseq) - -## extra_data(fname) [](#method-i-extra_data) - -## initialize() [](#method-i-initialize) - -**@return** [BasicStorage] a new instance of BasicStorage - -## load_iseq(fname) [](#method-i-load_iseq) - diff --git a/example/ruby/RubyVM/InstructionSequence/DBMStorage.md b/example/ruby/RubyVM/InstructionSequence/DBMStorage.md deleted file mode 100644 index c3ba6f2..0000000 --- a/example/ruby/RubyVM/InstructionSequence/DBMStorage.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RubyVM::InstructionSequence::DBMStorage -**Inherits:** RubyVM::InstructionSequence::BasicStorage - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [DBMStorage] a new instance of DBMStorage - -## unlink_compiled_iseq() [](#method-i-unlink_compiled_iseq) - diff --git a/example/ruby/RubyVM/InstructionSequence/FS2Storage.md b/example/ruby/RubyVM/InstructionSequence/FS2Storage.md deleted file mode 100644 index 08da161..0000000 --- a/example/ruby/RubyVM/InstructionSequence/FS2Storage.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: RubyVM::InstructionSequence::FS2Storage -**Inherits:** RubyVM::InstructionSequence::FSStorage - - - - - -#Instance Methods -## iseq_key_name(fname) [](#method-i-iseq_key_name) - diff --git a/example/ruby/RubyVM/InstructionSequence/FSStorage.md b/example/ruby/RubyVM/InstructionSequence/FSStorage.md deleted file mode 100644 index 9d3c829..0000000 --- a/example/ruby/RubyVM/InstructionSequence/FSStorage.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RubyVM::InstructionSequence::FSStorage -**Inherits:** RubyVM::InstructionSequence::BasicStorage - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [FSStorage] a new instance of FSStorage - -## unlink_compiled_iseq() [](#method-i-unlink_compiled_iseq) - diff --git a/example/ruby/RubyVM/InstructionSequence/NullStorage.md b/example/ruby/RubyVM/InstructionSequence/NullStorage.md deleted file mode 100644 index 1721e7d..0000000 --- a/example/ruby/RubyVM/InstructionSequence/NullStorage.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RubyVM::InstructionSequence::NullStorage -**Inherits:** Object - - - - - -#Instance Methods -## compile_and_save_isq(fname) [](#method-i-compile_and_save_isq) - -## load_iseq(fname) [](#method-i-load_iseq) - -## unlink_compiled_iseq() [](#method-i-unlink_compiled_iseq) - diff --git a/example/ruby/RubyVM/InstructionsUnifications.md b/example/ruby/RubyVM/InstructionsUnifications.md deleted file mode 100644 index f17e0d1..0000000 --- a/example/ruby/RubyVM/InstructionsUnifications.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: RubyVM::InstructionsUnifications -**Inherits:** Object - -**Includes:** RubyVM::CEscape - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(opts{}) [](#method-i-initialize) - -**@return** [InstructionsUnifications] a new instance of InstructionsUnifications - diff --git a/example/ruby/RubyVM/OperandsUnifications.md b/example/ruby/RubyVM/OperandsUnifications.md deleted file mode 100644 index 1fe4d04..0000000 --- a/example/ruby/RubyVM/OperandsUnifications.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: RubyVM::OperandsUnifications -**Inherits:** RubyVM::BareInstructions - -**Includes:** RubyVM::CEscape - - - - -# Attributes -## original[RW] [](#attribute-i-original) -Returns the value of attribute original. - -## preamble[RW] [](#attribute-i-preamble) -Returns the value of attribute preamble. - -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - -#Instance Methods -## condition(ptr) [](#method-i-condition) - -## has_ope?(var) [](#method-i-has_ope?) - -**@return** [Boolean] - -## initialize(opts{}) [](#method-i-initialize) - -**@return** [OperandsUnifications] a new instance of OperandsUnifications - -## operand_shift_of(var) [](#method-i-operand_shift_of) - diff --git a/example/ruby/RubyVM/RJIT.md b/example/ruby/RubyVM/RJIT.md deleted file mode 100644 index 39c8a31..0000000 --- a/example/ruby/RubyVM/RJIT.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: RubyVM::RJIT - - -Part of this file is generated by tool/rjit/bindgen.rb. Run `make -rjit-bindgen` to update code between "RJIT bindgen begin" and "RJIT bindgen -end". - - -# Class Methods -## enable() [](#method-c-enable) -Start JIT compilation after --rjit-disable. -## enabled?() [](#method-c-enabled?) -Return true if RJIT is enabled. -**@return** [Boolean] - -## runtime_stats() [](#method-c-runtime_stats) -Return a Hash for RJIT statistics. --rjit-stats makes more information -available. - diff --git a/example/ruby/RubyVM/RJIT/Assembler.md b/example/ruby/RubyVM/RJIT/Assembler.md deleted file mode 100644 index b8f1eb5..0000000 --- a/example/ruby/RubyVM/RJIT/Assembler.md +++ /dev/null @@ -1,151 +0,0 @@ -# Class: RubyVM::RJIT::Assembler -**Inherits:** Object - -**Extended by:** RubyVM::RJIT::OperandMatcher - -**Includes:** RubyVM::RJIT::OperandMatcher - - -https://cdrdv2.intel.com/v1/dl/getContent/671110 Mostly an x86_64 assembler, -but this also has some stuff that is useful for any architecture. - - -# Class Methods -## extended_reg?(reg ) [](#method-c-extended_reg?) -**@return** [Boolean] - -## imm32?(imm ) [](#method-c-imm32?) -**@return** [Boolean] - -## imm64?(imm ) [](#method-c-imm64?) -**@return** [Boolean] - -## imm8?(imm ) [](#method-c-imm8?) -**@return** [Boolean] - -## r32?(reg ) [](#method-c-r32?) -**@return** [Boolean] - -## r64?(reg ) [](#method-c-r64?) -**@return** [Boolean] - -## reg_code_extended(reg ) [](#method-c-reg_code_extended) -# Attributes -## comments[RW] [](#attribute-i-comments) -Utilities - - -#Instance Methods -## add(dst, src) [](#method-i-add) -Instructions - -## and(dst, src) [](#method-i-and) - -## assemble(addr) [](#method-i-assemble) - -## block(block) [](#method-i-block) -Mark the starting address of a block - -## call(dst) [](#method-i-call) - -## cmove(dst, src) [](#method-i-cmove) - -## cmovg(dst, src) [](#method-i-cmovg) - -## cmovge(dst, src) [](#method-i-cmovge) - -## cmovl(dst, src) [](#method-i-cmovl) - -## cmovle(dst, src) [](#method-i-cmovle) - -## cmovne(dst, src) [](#method-i-cmovne) - -## cmovnz(dst, src) [](#method-i-cmovnz) - -## cmovz(dst, src) [](#method-i-cmovz) - -## cmp(left, right) [](#method-i-cmp) - -## comment(message) [](#method-i-comment) - -## extended_reg?(reg) [](#method-i-extended_reg?) - -**@return** [Boolean] - -## imm32?(imm) [](#method-i-imm32?) - -**@return** [Boolean] - -## imm64?(imm) [](#method-i-imm64?) - -**@return** [Boolean] - -## imm8?(imm) [](#method-i-imm8?) - -**@return** [Boolean] - -## incr_counter(name) [](#method-i-incr_counter) - -## initialize() [](#method-i-initialize) - -**@return** [Assembler] a new instance of Assembler - -## jbe(dst) [](#method-i-jbe) - -## je(dst) [](#method-i-je) - -## jl(dst) [](#method-i-jl) - -## jmp(dst) [](#method-i-jmp) - -## jne(dst) [](#method-i-jne) - -## jnz(dst) [](#method-i-jnz) - -## jo(dst) [](#method-i-jo) - -## jz(dst) [](#method-i-jz) - -## lea(dst, src) [](#method-i-lea) - -## mov(dst, src) [](#method-i-mov) - -## new_label(name) [](#method-i-new_label) - -## or(dst, src) [](#method-i-or) - -## pop(dst) [](#method-i-pop) - -## pos_marker(&block) [](#method-i-pos_marker) - -## push(src) [](#method-i-push) - -## r32?(reg) [](#method-i-r32?) - -**@return** [Boolean] - -## r64?(reg) [](#method-i-r64?) - -**@return** [Boolean] - -## reg_code_extended(reg) [](#method-i-reg_code_extended) - -## ret() [](#method-i-ret) - -## sar(dst, src) [](#method-i-sar) - -## size() [](#method-i-size) - -## stub(stub) [](#method-i-stub) -Mark the starting/ending addresses of a stub - -## sub(dst, src) [](#method-i-sub) - -## test(left, right) [](#method-i-test) - -## write_label(label) [](#method-i-write_label) - -**@param** [RubyVM::RJIT::Assembler::Label] - -## xor(dst, src) [](#method-i-xor) - diff --git a/example/ruby/RubyVM/RJIT/Assembler/Label.md b/example/ruby/RubyVM/RJIT/Assembler/Label.md deleted file mode 100644 index 3a5c528..0000000 --- a/example/ruby/RubyVM/RJIT/Assembler/Label.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: RubyVM::RJIT::Assembler::Label -**Inherits:** Object - - -rel8 jumps are made with labels - - - diff --git a/example/ruby/RubyVM/RJIT/Assembler/ModRM.md b/example/ruby/RubyVM/RJIT/Assembler/ModRM.md deleted file mode 100644 index 3531eae..0000000 --- a/example/ruby/RubyVM/RJIT/Assembler/ModRM.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: RubyVM::RJIT::Assembler::ModRM -**Inherits:** Object - - -A set of ModR/M values encoded on #insn - - - diff --git a/example/ruby/RubyVM/RJIT/Assembler/Rel32.md b/example/ruby/RubyVM/RJIT/Assembler/Rel32.md deleted file mode 100644 index 99bb03e..0000000 --- a/example/ruby/RubyVM/RJIT/Assembler/Rel32.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: RubyVM::RJIT::Assembler::Rel32 -**Inherits:** Object - - -rel32 is inserted as [Rel32, Rel32Pad..] and converted on #resolve_rel32 - - - diff --git a/example/ruby/RubyVM/RJIT/Block.md b/example/ruby/RubyVM/RJIT/Block.md deleted file mode 100644 index 005946e..0000000 --- a/example/ruby/RubyVM/RJIT/Block.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: RubyVM::RJIT::Block -**Inherits:** Struct - - - - -# Attributes -## ctx[RW] [](#attribute-i-ctx) -Returns the value of attribute ctx - -**@return** [Object] the current value of ctx - -## entry_exit[RW] [](#attribute-i-entry_exit) -Returns the value of attribute entry_exit - -**@return** [Object] the current value of entry_exit - -## incoming[RW] [](#attribute-i-incoming) -Returns the value of attribute incoming - -**@return** [Object] the current value of incoming - -## invalidated[RW] [](#attribute-i-invalidated) -Returns the value of attribute invalidated - -**@return** [Object] the current value of invalidated - -## iseq[RW] [](#attribute-i-iseq) -Returns the value of attribute iseq - -**@return** [Object] the current value of iseq - -## pc[RW] [](#attribute-i-pc) -Returns the value of attribute pc - -**@return** [Object] the current value of pc - -## start_addr[RW] [](#attribute-i-start_addr) -Returns the value of attribute start_addr - -**@return** [Object] the current value of start_addr - - -#Instance Methods -## initialize(incoming:[], invalidated:false) [](#method-i-initialize) - -**@return** [Block] a new instance of Block - diff --git a/example/ruby/RubyVM/RJIT/BranchStub.md b/example/ruby/RubyVM/RJIT/BranchStub.md deleted file mode 100644 index 9bd9892..0000000 --- a/example/ruby/RubyVM/RJIT/BranchStub.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: RubyVM::RJIT::BranchStub -**Inherits:** Struct - - -neither targets is a fallthrough - - -# Attributes -## compile[RW] [](#attribute-i-compile) -Returns the value of attribute compile - -**@return** [Object] the current value of compile - -## end_addr[RW] [](#attribute-i-end_addr) -Returns the value of attribute end_addr - -**@return** [Object] the current value of end_addr - -## iseq[RW] [](#attribute-i-iseq) -Returns the value of attribute iseq - -**@return** [Object] the current value of iseq - -## shape[RW] [](#attribute-i-shape) -Returns the value of attribute shape - -**@return** [Object] the current value of shape - -## start_addr[RW] [](#attribute-i-start_addr) -Returns the value of attribute start_addr - -**@return** [Object] the current value of start_addr - -## target0[RW] [](#attribute-i-target0) -Returns the value of attribute target0 - -**@return** [Object] the current value of target0 - -## target1[RW] [](#attribute-i-target1) -Returns the value of attribute target1 - -**@return** [Object] the current value of target1 - - diff --git a/example/ruby/RubyVM/RJIT/BranchTarget.md b/example/ruby/RubyVM/RJIT/BranchTarget.md deleted file mode 100644 index 384c005..0000000 --- a/example/ruby/RubyVM/RJIT/BranchTarget.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: RubyVM::RJIT::BranchTarget -**Inherits:** Struct - - - - -# Attributes -## address[RW] [](#attribute-i-address) -Returns the value of attribute address - -**@return** [Object] the current value of address - -## ctx[RW] [](#attribute-i-ctx) -Returns the value of attribute ctx - -**@return** [Object] the current value of ctx - -## pc[RW] [](#attribute-i-pc) -Returns the value of attribute pc - -**@return** [Object] the current value of pc - - diff --git a/example/ruby/RubyVM/RJIT/BytePtr.md b/example/ruby/RubyVM/RJIT/BytePtr.md deleted file mode 100644 index 98fb28e..0000000 --- a/example/ruby/RubyVM/RJIT/BytePtr.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: RubyVM::RJIT::BytePtr -**Inherits:** Object - - -8-bit memory access - - - diff --git a/example/ruby/RubyVM/RJIT/CPointer.md b/example/ruby/RubyVM/RJIT/CPointer.md deleted file mode 100644 index 5828018..0000000 --- a/example/ruby/RubyVM/RJIT/CPointer.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: RubyVM::RJIT::CPointer - - -Every class under this namespace is a pointer. Even if the type is immediate, -it shouldn't be dereferenced until `*` is called. - - -# Class Methods -## with_class_name(prefix , name , cache: false, &block ) [](#method-c-with_class_name) -Give a name to a dynamic CPointer class to see it on inspect - diff --git a/example/ruby/RubyVM/RJIT/CPointer/Array.md b/example/ruby/RubyVM/RJIT/CPointer/Array.md deleted file mode 100644 index 5a7cc2f..0000000 --- a/example/ruby/RubyVM/RJIT/CPointer/Array.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: RubyVM::RJIT::CPointer::Array -**Inherits:** Object - - -Basically Immediate but without #* to skip auto-dereference of structs. - - -# Attributes -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## [](index) [](#method-i-[]) -Array access - -## []=(index, value) [](#method-i-[]=) -Array set - -**@param** [Integer] - -**@param** [Integer, RubyVM::RJIT::CPointer::Struct] an address itself or an object that return an address with to_i - -## initialize(addr, type) [](#method-i-initialize) - -**@param** [Integer] - -**@param** [Class] RubyVM::RJIT::CType::* - -**@return** [Array] a new instance of Array - diff --git a/example/ruby/RubyVM/RJIT/CPointer/BitField.md b/example/ruby/RubyVM/RJIT/CPointer/BitField.md deleted file mode 100644 index 3a9f45a..0000000 --- a/example/ruby/RubyVM/RJIT/CPointer/BitField.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: RubyVM::RJIT::CPointer::BitField -**Inherits:** Object - - - - -# Class Methods -## define(width , offset ) [](#method-c-define) -**@param** [Integer] - -**@param** [Integer] - - -#Instance Methods -## *() [](#method-i-*) -Dereference - -## initialize(addr, width, offset) [](#method-i-initialize) - -**@param** [Integer] - -**@param** [Integer] - -**@param** [Integer] - -**@return** [BitField] a new instance of BitField - diff --git a/example/ruby/RubyVM/RJIT/CPointer/Bool.md b/example/ruby/RubyVM/RJIT/CPointer/Bool.md deleted file mode 100644 index 7708981..0000000 --- a/example/ruby/RubyVM/RJIT/CPointer/Bool.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RubyVM::RJIT::CPointer::Bool -**Inherits:** Object - - --Fiddle::TYPE_CHAR Immediate with special handling of true/false - - -# Class Methods -## []=(addr , value ) [](#method-c-[]=) - -#Instance Methods -## *() [](#method-i-*) -Dereference - diff --git a/example/ruby/RubyVM/RJIT/CPointer/Immediate.md b/example/ruby/RubyVM/RJIT/CPointer/Immediate.md deleted file mode 100644 index b9a10f9..0000000 --- a/example/ruby/RubyVM/RJIT/CPointer/Immediate.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: RubyVM::RJIT::CPointer::Immediate -**Inherits:** Object - - - - -# Class Methods -## define(fiddle_type ) [](#method-c-define) -**@param** [Integer] Fiddle::TYPE_* - - -#Instance Methods -## *() [](#method-i-*) -Dereference - -## +(index) [](#method-i-+) -Move addr to addess this pointer like an array - -## [](index) [](#method-i-[]) -Array access - -## []=(index, value) [](#method-i-[]=) -Array set - -## initialize(addr, size, pack) [](#method-i-initialize) - -**@param** [Integer] - -**@param** [Integer] - -**@param** [String] - -**@return** [Immediate] a new instance of Immediate - -## to_i() [](#method-i-to_i) -Get a raw address - -## to_s() [](#method-i-to_s) -Serialized address for generated code. Used for embedding things like -body->iseq_encoded. - diff --git a/example/ruby/RubyVM/RJIT/CPointer/Pointer.md b/example/ruby/RubyVM/RJIT/CPointer/Pointer.md deleted file mode 100644 index 9b779b0..0000000 --- a/example/ruby/RubyVM/RJIT/CPointer/Pointer.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: RubyVM::RJIT::CPointer::Pointer -**Inherits:** Object - - - - -# Attributes -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## *() [](#method-i-*) -Dereference - -## +(index) [](#method-i-+) -Move addr to addess this pointer like an array - -**@raise** [ArgumentError] - -## [](index) [](#method-i-[]) -Array access - -## []=(index, value) [](#method-i-[]=) -Array set - -**@param** [Integer] - -**@param** [Integer, RubyVM::RJIT::CPointer::Struct] an address itself or an object that return an address with to_i - -## initialize(addr, type) [](#method-i-initialize) - -**@param** [Integer] - -**@param** [Class] RubyVM::RJIT::CType::* - -**@return** [Pointer] a new instance of Pointer - -## to_i() [](#method-i-to_i) -Get a raw address - diff --git a/example/ruby/RubyVM/RJIT/CPointer/Struct.md b/example/ruby/RubyVM/RJIT/CPointer/Struct.md deleted file mode 100644 index 10ae8e5..0000000 --- a/example/ruby/RubyVM/RJIT/CPointer/Struct.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: RubyVM::RJIT::CPointer::Struct -**Inherits:** Object - - -Note: We'd like to avoid alphabetic method names to avoid a conflict with -member methods. to_i and to_s are considered an exception. - - - -#Instance Methods -## -(struct) [](#method-i--) -Pointer diff - -**@raise** [ArgumentError] - -## [](member) [](#method-i-[]) -Primitive API that does no automatic dereference TODO: remove this? - -**@param** [Symbol] - -## initialize(addr, sizeof, members) [](#method-i-initialize) - -**@param** [String] - -**@param** [Integer] - -**@param** [Hash{ Symbol => [RubyVM::RJIT::CType::*, Integer, TrueClass] }] - -**@return** [Struct] a new instance of Struct - -## to_i() [](#method-i-to_i) -Get a raw address - -## to_s() [](#method-i-to_s) -Serialized address for generated code - diff --git a/example/ruby/RubyVM/RJIT/CPointer/Union.md b/example/ruby/RubyVM/RJIT/CPointer/Union.md deleted file mode 100644 index a328a57..0000000 --- a/example/ruby/RubyVM/RJIT/CPointer/Union.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: RubyVM::RJIT::CPointer::Union -**Inherits:** Object - - -Note: We'd like to avoid alphabetic method names to avoid a conflict with -member methods. to_i is considered an exception. - - -# Class Methods -## define(sizeof , members ) [](#method-c-define) -**@param** [Integer] - -**@param** [Hash{ Symbol => RubyVM::RJIT::CType::* }] - - -#Instance Methods -## +(index) [](#method-i-+) -Move addr to access this pointer like an array - -**@raise** [ArgumentError] - -## -(union) [](#method-i--) -Pointer diff - -**@raise** [ArgumentError] - -## initialize(addr, sizeof, members) [](#method-i-initialize) - -**@param** [String] To be used when it starts defining a union pointer class - -**@param** [Integer] - -**@param** [Hash{ Symbol => RubyVM::RJIT::CType::* }] - -**@return** [Union] a new instance of Union - -## to_i() [](#method-i-to_i) -Get a raw address - diff --git a/example/ruby/RubyVM/RJIT/CType.md b/example/ruby/RubyVM/RJIT/CType.md deleted file mode 100644 index e0f59cd..0000000 --- a/example/ruby/RubyVM/RJIT/CType.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: RubyVM::RJIT::CType - - - - - diff --git a/example/ruby/RubyVM/RJIT/CType/Array.md b/example/ruby/RubyVM/RJIT/CType/Array.md deleted file mode 100644 index 9cef3b4..0000000 --- a/example/ruby/RubyVM/RJIT/CType/Array.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: RubyVM::RJIT::CType::Array -**Inherits:** Object - - - - -# Class Methods -## new(&block ) [](#method-c-new) - diff --git a/example/ruby/RubyVM/RJIT/CType/BitField.md b/example/ruby/RubyVM/RJIT/CType/BitField.md deleted file mode 100644 index b6fe102..0000000 --- a/example/ruby/RubyVM/RJIT/CType/BitField.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: RubyVM::RJIT::CType::BitField - - - - -# Class Methods -## new(width , offset ) [](#method-c-new) -**@param** [Integer] - -**@param** [Integer] - - diff --git a/example/ruby/RubyVM/RJIT/CType/Bool.md b/example/ruby/RubyVM/RJIT/CType/Bool.md deleted file mode 100644 index 6d6925d..0000000 --- a/example/ruby/RubyVM/RJIT/CType/Bool.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: RubyVM::RJIT::CType::Bool - - - - -# Class Methods -## new() [](#method-c-new) - diff --git a/example/ruby/RubyVM/RJIT/CType/Immediate.md b/example/ruby/RubyVM/RJIT/CType/Immediate.md deleted file mode 100644 index b4d45ef..0000000 --- a/example/ruby/RubyVM/RJIT/CType/Immediate.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: RubyVM::RJIT::CType::Immediate - - - - -# Class Methods -## find(size , signed ) [](#method-c-find) -## new(fiddle_type ) [](#method-c-new) -**@param** [Integer] - -## parse(ctype ) [](#method-c-parse) -**@param** [String] - - diff --git a/example/ruby/RubyVM/RJIT/CType/Pointer.md b/example/ruby/RubyVM/RJIT/CType/Pointer.md deleted file mode 100644 index 62874f0..0000000 --- a/example/ruby/RubyVM/RJIT/CType/Pointer.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: RubyVM::RJIT::CType::Pointer -**Inherits:** Object - - - - -# Class Methods -## new(&block ) [](#method-c-new) -This takes a block to avoid "stack level too deep" on a cyclic reference -**@param** [Proc] - - diff --git a/example/ruby/RubyVM/RJIT/CType/Struct.md b/example/ruby/RubyVM/RJIT/CType/Struct.md deleted file mode 100644 index f7a1373..0000000 --- a/example/ruby/RubyVM/RJIT/CType/Struct.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: RubyVM::RJIT::CType::Struct - - - - -# Class Methods -## new(name , sizeof , **members ) [](#method-c-new) -**@param** [String] - -**@param** [Hash{ Symbol => [Integer, RubyVM::RJIT::CType::*] }] - - diff --git a/example/ruby/RubyVM/RJIT/CType/Stub.md b/example/ruby/RubyVM/RJIT/CType/Stub.md deleted file mode 100644 index 2d6f823..0000000 --- a/example/ruby/RubyVM/RJIT/CType/Stub.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: RubyVM::RJIT::CType::Stub -**Inherits:** Struct - - -Types that are referenced but not part of code generation targets - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name - -**@return** [Object] the current value of name - - diff --git a/example/ruby/RubyVM/RJIT/CType/Union.md b/example/ruby/RubyVM/RJIT/CType/Union.md deleted file mode 100644 index 07eddd7..0000000 --- a/example/ruby/RubyVM/RJIT/CType/Union.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: RubyVM::RJIT::CType::Union - - - - -# Class Methods -## new(name , sizeof , **members ) [](#method-c-new) -**@param** [String] - -**@param** [Hash{ Symbol => RubyVM::RJIT::CType::* }] - - diff --git a/example/ruby/RubyVM/RJIT/C_3DModule.new.md b/example/ruby/RubyVM/RJIT/C_3DModule.new.md deleted file mode 100644 index 77bb05f..0000000 --- a/example/ruby/RubyVM/RJIT/C_3DModule.new.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: RubyVM::RJIT::C=Module.new -**Inherits:** Object - - -Main: Used by RJIT - -This `class << C` section is for calling C functions with Primitive. For -importing variables or macros, use tool/rjit/bindgen.rb instead. - - - diff --git a/example/ruby/RubyVM/RJIT/CodeBlock.md b/example/ruby/RubyVM/RJIT/CodeBlock.md deleted file mode 100644 index 0f4149f..0000000 --- a/example/ruby/RubyVM/RJIT/CodeBlock.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: RubyVM::RJIT::CodeBlock -**Inherits:** Object - - - - - -#Instance Methods -## dump_disasm(from, to, io:STDOUT, color:true, test:false) [](#method-i-dump_disasm) - -## include?(addr) [](#method-i-include?) - -**@return** [Boolean] - -## initialize(mem_block:, mem_size:, outlined:false) [](#method-i-initialize) - -**@param** [Integer] JIT buffer address - -**@param** [Integer] JIT buffer size - -**@param** [TrueClass, FalseClass] true for outlined CodeBlock - -**@return** [CodeBlock] a new instance of CodeBlock - -## set_write_addr(addr) [](#method-i-set_write_addr) - -## with_write_addr(addr) [](#method-i-with_write_addr) - -## write(asm) [](#method-i-write) - -**@param** [RubyVM::RJIT::Assembler] - -## write_addr() [](#method-i-write_addr) - diff --git a/example/ruby/RubyVM/RJIT/Compiler.md b/example/ruby/RubyVM/RJIT/Compiler.md deleted file mode 100644 index 39b2456..0000000 --- a/example/ruby/RubyVM/RJIT/Compiler.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: RubyVM::RJIT::Compiler -**Inherits:** Object - - - - -# Class Methods -## decode_insn(encoded ) [](#method-c-decode_insn) -# Attributes -## write_pos[RW] [](#attribute-i-write_pos) -Returns the value of attribute write_pos. - - -#Instance Methods -## branch_stub_hit(branch_stub, cfp, target0_p) [](#method-i-branch_stub_hit) -Compile a branch stub. - -**@param** [RubyVM::RJIT::BranchStub] - -**@param** [] `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t` - -**@param** [TrueClass, FalseClass] - -**@return** [Integer] The starting address of the compiled branch stub - -## compile(iseq, cfp) [](#method-i-compile) -Compile an ISEQ from its entry point. - -**@param** [] `RubyVM::RJIT::CPointer::Struct_rb_iseq_t` - -**@param** [] `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t` - -## entry_stub_hit(entry_stub, cfp) [](#method-i-entry_stub_hit) -Compile an entry. - -**@param** [RubyVM::RJIT::EntryStub] - -## initialize() [](#method-i-initialize) - -**@return** [Compiler] a new instance of Compiler - -## invalidate_block(block) [](#method-i-invalidate_block) - -## invalidate_blocks(iseq, pc) [](#method-i-invalidate_blocks) - -**@param** [] `RubyVM::RJIT::CPointer::Struct_rb_iseq_t` - -**@param** [Integer] - diff --git a/example/ruby/RubyVM/RJIT/Context.md b/example/ruby/RubyVM/RJIT/Context.md deleted file mode 100644 index 3eb5402..0000000 --- a/example/ruby/RubyVM/RJIT/Context.md +++ /dev/null @@ -1,109 +0,0 @@ -# Class: RubyVM::RJIT::Context -**Inherits:** Struct - - - - -# Attributes -## chain_depth[RW] [](#attribute-i-chain_depth) -Returns the value of attribute chain_depth - -**@return** [Object] the current value of chain_depth - -## local_types[RW] [](#attribute-i-local_types) -Returns the value of attribute local_types - -**@return** [Object] the current value of local_types - -## self_type[RW] [](#attribute-i-self_type) -Returns the value of attribute self_type - -**@return** [Object] the current value of self_type - -## sp_offset[RW] [](#attribute-i-sp_offset) -Returns the value of attribute sp_offset - -**@return** [Object] the current value of sp_offset - -## stack_size[RW] [](#attribute-i-stack_size) -Returns the value of attribute stack_size - -**@return** [Object] the current value of stack_size - -## temp_mapping[RW] [](#attribute-i-temp_mapping) -Returns the value of attribute temp_mapping - -**@return** [Object] the current value of temp_mapping - -## temp_types[RW] [](#attribute-i-temp_types) -Returns the value of attribute temp_types - -**@return** [Object] the current value of temp_types - - -#Instance Methods -## clear_local_types() [](#method-i-clear_local_types) -Erase local variable type information eg: because of a call we can't track - -## diff(dst) [](#method-i-diff) -Compute a difference score for two context objects - -## dup() [](#method-i-dup) -Deep dup by default for safety - -## get_local_type(idx) [](#method-i-get_local_type) -Get the currently tracked type for a local variable - -## get_opnd_mapping(opnd) [](#method-i-get_opnd_mapping) -Get both the type and mapping (where the value originates) of an operand. This -is can be used with stack_push_mapping or set_opnd_mapping to copy a stack -value's type while maintaining the mapping. - -## get_opnd_type(opnd) [](#method-i-get_opnd_type) -Get the type of an instruction operand - -## initialize(stack_size:0, sp_offset:0, chain_depth:0, local_types:[Type::Unknown] * MAX_LOCAL_TYPES, temp_types:[Type::Unknown] * MAX_TEMP_TYPES, self_type:Type::Unknown, temp_mapping:[MapToStack] * MAX_TEMP_TYPES) [](#method-i-initialize) - -**@return** [Context] a new instance of Context - -## set_local_type(local_idx, local_type) [](#method-i-set_local_type) -Set the type of a local variable - -## set_opnd_mapping(opnd, mapping_opnd_type) [](#method-i-set_opnd_mapping) -Overwrite both the type and mapping of a stack operand. - -## shift_stack(argc) [](#method-i-shift_stack) - -## sp_opnd(offset_bytes0) [](#method-i-sp_opnd) - -## stack_opnd(depth_from_top) [](#method-i-stack_opnd) - -## stack_pop(n1) [](#method-i-stack_pop) -Pop N values off the stack Return a pointer to the stack top before the pop -operation - -## stack_push(val_type) [](#method-i-stack_push) -Push one new value on the temp stack Return a pointer to the new stack top - -## stack_push_local(local_idx) [](#method-i-stack_push_local) -Push a local variable on the stack - -## stack_push_mapping(mapping_temp_type) [](#method-i-stack_push_mapping) -Push one new value on the temp stack with an explicit mapping Return a pointer -to the new stack top - -## stack_push_self() [](#method-i-stack_push_self) -Push the self value on the stack - -## upgrade_opnd_type(opnd, opnd_type) [](#method-i-upgrade_opnd_type) -Upgrade (or "learn") the type of an instruction operand This value must be -compatible and at least as specific as the previously known type. If this -value originated from self, or an lvar, the learned type will be propagated -back to its source. - -## with_stack_size(stack_size) [](#method-i-with_stack_size) -Create a new Context instance with a given stack_size and sp_offset adjusted -accordingly. This is useful when you want to virtually rewind a stack_size for -generating a side exit while considering past sp_offset changes on -gen_save_sp. - diff --git a/example/ruby/RubyVM/RJIT/DwordPtr.md b/example/ruby/RubyVM/RJIT/DwordPtr.md deleted file mode 100644 index 7f56b76..0000000 --- a/example/ruby/RubyVM/RJIT/DwordPtr.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: RubyVM::RJIT::DwordPtr -**Inherits:** Object - - -32-bit memory access - - - diff --git a/example/ruby/RubyVM/RJIT/EntryStub.md b/example/ruby/RubyVM/RJIT/EntryStub.md deleted file mode 100644 index a9878f0..0000000 --- a/example/ruby/RubyVM/RJIT/EntryStub.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: RubyVM::RJIT::EntryStub -**Inherits:** Struct - - - - -# Attributes -## end_addr[RW] [](#attribute-i-end_addr) -Returns the value of attribute end_addr - -**@return** [Object] the current value of end_addr - -## start_addr[RW] [](#attribute-i-start_addr) -Returns the value of attribute start_addr - -**@return** [Object] the current value of start_addr - - diff --git a/example/ruby/RubyVM/RJIT/ExitCompiler.md b/example/ruby/RubyVM/RJIT/ExitCompiler.md deleted file mode 100644 index 81b507a..0000000 --- a/example/ruby/RubyVM/RJIT/ExitCompiler.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: RubyVM::RJIT::ExitCompiler -**Inherits:** Object - - - - - -#Instance Methods -## compile_branch_stub(ctx, asm, branch_stub, target0_p) [](#method-i-compile_branch_stub) - -**@param** [RubyVM::RJIT::Context] - -**@param** [RubyVM::RJIT::Assembler] - -**@param** [RubyVM::RJIT::BranchStub] - -**@param** [TrueClass, FalseClass] - -## compile_entry_exit(pc, ctx, asm, cause:) [](#method-i-compile_entry_exit) -Used for invalidating a block on entry. - -**@param** [Integer] - -**@param** [RubyVM::RJIT::Assembler] - -## compile_entry_stub(asm, entry_stub) [](#method-i-compile_entry_stub) - -**@param** [RubyVM::RJIT::Assembler] - -**@param** [RubyVM::RJIT::EntryStub] - -## compile_full_cfunc_return(asm) [](#method-i-compile_full_cfunc_return) -Fire cfunc events on invalidation by TracePoint - -**@param** [RubyVM::RJIT::Assembler] - -## compile_leave_exit(asm) [](#method-i-compile_leave_exit) -Set to cfp->jit_return by default for leave insn - -**@param** [RubyVM::RJIT::Assembler] - -## compile_side_exit(pc, ctx, asm) [](#method-i-compile_side_exit) - -**@param** [RubyVM::RJIT::JITState] - -**@param** [RubyVM::RJIT::Context] - -**@param** [RubyVM::RJIT::Assembler] - -## initialize() [](#method-i-initialize) - -**@return** [ExitCompiler] a new instance of ExitCompiler - diff --git a/example/ruby/RubyVM/RJIT/Hooks.md b/example/ruby/RubyVM/RJIT/Hooks.md deleted file mode 100644 index e69a031..0000000 --- a/example/ruby/RubyVM/RJIT/Hooks.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: RubyVM::RJIT::Hooks - - -:nodoc: all - - -# Class Methods -## on_bop_redefined(_redefined_flag , _bop ) [](#method-c-on_bop_redefined) -## on_cme_invalidate(cme ) [](#method-c-on_cme_invalidate) -## on_constant_ic_update(iseq , ic , insn_idx ) [](#method-c-on_constant_ic_update) -ISEQ-specific constant invalidation -## on_constant_state_changed(id ) [](#method-c-on_constant_state_changed) -Global constant changes like const_set -## on_ractor_spawn() [](#method-c-on_ractor_spawn) -## on_tracing_invalidate_all(_new_iseq_events ) [](#method-c-on_tracing_invalidate_all) -## on_update_references() [](#method-c-on_update_references) - diff --git a/example/ruby/RubyVM/RJIT/Invariants.md b/example/ruby/RubyVM/RJIT/Invariants.md deleted file mode 100644 index aa18cf6..0000000 --- a/example/ruby/RubyVM/RJIT/Invariants.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: RubyVM::RJIT::Invariants -**Inherits:** Object - - - - -# Class Methods -## assume_bop_not_redefined(jit , klass , op ) [](#method-c-assume_bop_not_redefined) -**@param** [RubyVM::RJIT::JITState] - -**@param** [Integer] - -**@param** [Integer] - -## assume_method_basic_definition(jit , klass , mid ) [](#method-c-assume_method_basic_definition) -**@param** [RubyVM::RJIT::JITState] - -## assume_method_lookup_stable(jit , cme ) [](#method-c-assume_method_lookup_stable) -**@param** [RubyVM::RJIT::JITState] - -## assume_stable_constant_names(jit , idlist ) [](#method-c-assume_stable_constant_names) -## ensure_block_entry_exit(jit , cause: ) [](#method-c-ensure_block_entry_exit) -**@param** [RubyVM::RJIT::JITState] - -**@param** [RubyVM::RJIT::Block] - -## initialize(cb , ocb , compiler , exit_compiler ) [](#method-c-initialize) -Called by RubyVM::RJIT::Compiler to lazily initialize this -**@param** [CodeBlock] - -**@param** [CodeBlock] - -**@param** [RubyVM::RJIT::Compiler] - -**@param** [RubyVM::RJIT::ExitCompiler] - -## on_cme_invalidate(cme ) [](#method-c-on_cme_invalidate) -## on_constant_ic_update(iseq , ic , insn_idx ) [](#method-c-on_constant_ic_update) -## on_constant_state_changed(id ) [](#method-c-on_constant_state_changed) -## on_tracing_invalidate_all() [](#method-c-on_tracing_invalidate_all) -## on_update_references() [](#method-c-on_update_references) -## record_global_inval_patch(asm , target ) [](#method-c-record_global_inval_patch) -**@param** [RubyVM::RJIT::Assembler] - - diff --git a/example/ruby/RubyVM/RJIT/JITState.md b/example/ruby/RubyVM/RJIT/JITState.md deleted file mode 100644 index 5d049cc..0000000 --- a/example/ruby/RubyVM/RJIT/JITState.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: RubyVM::RJIT::JITState -**Inherits:** Struct - - - - -# Attributes -## block[RW] [](#attribute-i-block) -Returns the value of attribute block - -**@return** [Object] the current value of block - -## cfp[RW] [](#attribute-i-cfp) -Returns the value of attribute cfp - -**@return** [Object] the current value of cfp - -## iseq[RW] [](#attribute-i-iseq) -Returns the value of attribute iseq - -**@return** [Object] the current value of iseq - -## pc[RW] [](#attribute-i-pc) -Returns the value of attribute pc - -**@return** [Object] the current value of pc - -## record_boundary_patch_point[RW] [](#attribute-i-record_boundary_patch_point) -Returns the value of attribute record_boundary_patch_point - -**@return** [Object] the current value of record_boundary_patch_point - -## side_exit_for_pc[RW] [](#attribute-i-side_exit_for_pc) -Returns the value of attribute side_exit_for_pc - -**@return** [Object] the current value of side_exit_for_pc - -## stack_size_for_pc[RW] [](#attribute-i-stack_size_for_pc) -Returns the value of attribute stack_size_for_pc - -**@return** [Object] the current value of stack_size_for_pc - - -#Instance Methods -## at_current_insn?() [](#method-i-at_current_insn?) - -**@return** [Boolean] - -## initialize(side_exit_for_pc:{}, record_boundary_patch_point:false) [](#method-i-initialize) - -**@return** [JITState] a new instance of JITState - -## insn() [](#method-i-insn) - -## operand(index, signed:false, ruby:false) [](#method-i-operand) - -## peek_at_block_handler(level) [](#method-i-peek_at_block_handler) - -## peek_at_local(n) [](#method-i-peek_at_local) - -## peek_at_self() [](#method-i-peek_at_self) - -## peek_at_stack(depth_from_top) [](#method-i-peek_at_stack) - diff --git a/example/ruby/RubyVM/RJIT/OperandMatcher.md b/example/ruby/RubyVM/RJIT/OperandMatcher.md deleted file mode 100644 index e12c267..0000000 --- a/example/ruby/RubyVM/RJIT/OperandMatcher.md +++ /dev/null @@ -1,33 +0,0 @@ -# Module: RubyVM::RJIT::OperandMatcher - - - - - -#Instance Methods -## extended_reg?(reg) [](#method-i-extended_reg?) - -**@return** [Boolean] - -## imm32?(imm) [](#method-i-imm32?) - -**@return** [Boolean] - -## imm64?(imm) [](#method-i-imm64?) - -**@return** [Boolean] - -## imm8?(imm) [](#method-i-imm8?) - -**@return** [Boolean] - -## r32?(reg) [](#method-i-r32?) - -**@return** [Boolean] - -## r64?(reg) [](#method-i-r64?) - -**@return** [Boolean] - -## reg_code_extended(reg) [](#method-i-reg_code_extended) - diff --git a/example/ruby/RubyVM/RJIT/TestAssembler.md b/example/ruby/RubyVM/RJIT/TestAssembler.md deleted file mode 100644 index 9502838..0000000 --- a/example/ruby/RubyVM/RJIT/TestAssembler.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: RubyVM::RJIT::TestAssembler -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add() [](#method-i-test_add) - -## test_and() [](#method-i-test_and) - -## test_call() [](#method-i-test_call) - -## test_cmove() [](#method-i-test_cmove) - -## test_cmovg() [](#method-i-test_cmovg) - -## test_cmovge() [](#method-i-test_cmovge) - -## test_cmovl() [](#method-i-test_cmovl) - -## test_cmovle() [](#method-i-test_cmovle) - -## test_cmovne() [](#method-i-test_cmovne) - -## test_cmovnz() [](#method-i-test_cmovnz) - -## test_cmovz() [](#method-i-test_cmovz) - -## test_cmp() [](#method-i-test_cmp) - -## test_jbe() [](#method-i-test_jbe) - -## test_je() [](#method-i-test_je) - -## test_jl() [](#method-i-test_jl) - -## test_jmp() [](#method-i-test_jmp) - -## test_jne() [](#method-i-test_jne) - -## test_jnz() [](#method-i-test_jnz) - -## test_jo() [](#method-i-test_jo) - -## test_jz() [](#method-i-test_jz) - -## test_lea() [](#method-i-test_lea) - -## test_mov() [](#method-i-test_mov) - -## test_or() [](#method-i-test_or) - -## test_pop() [](#method-i-test_pop) - -## test_push() [](#method-i-test_push) - -## test_ret() [](#method-i-test_ret) - -## test_sar() [](#method-i-test_sar) - -## test_sub() [](#method-i-test_sub) - -## test_test() [](#method-i-test_test) - -## test_xor() [](#method-i-test_xor) - diff --git a/example/ruby/RubyVM/RJIT/TypeDiff.md b/example/ruby/RubyVM/RJIT/TypeDiff.md deleted file mode 100644 index 8e7bf17..0000000 --- a/example/ruby/RubyVM/RJIT/TypeDiff.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: RubyVM::RJIT::TypeDiff - - - - - diff --git a/example/ruby/RubyVM/Scanner.md b/example/ruby/RubyVM/Scanner.md deleted file mode 100644 index 5c1b51e..0000000 --- a/example/ruby/RubyVM/Scanner.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: RubyVM::Scanner -**Inherits:** Object - - -Poor man's StringScanner. Sadly https://bugs.ruby-lang.org/issues/8343 is -not backported to 2.0. We have to do it by hand. - - -# Attributes -## __FILE__[RW] [](#attribute-i-__FILE__) -Returns the value of attribute __FILE__. - -## __LINE__[RW] [](#attribute-i-__LINE__) -Returns the value of attribute __LINE__. - - -#Instance Methods -## [](key) [](#method-i-[]) - -## eos?() [](#method-i-eos?) - -**@return** [Boolean] - -## initialize(path) [](#method-i-initialize) - -**@return** [Scanner] a new instance of Scanner - -## scan(re) [](#method-i-scan) - -## scan!(re) [](#method-i-scan!) - diff --git a/example/ruby/RubyVM/Shape.md b/example/ruby/RubyVM/Shape.md deleted file mode 100644 index 8c02da4..0000000 --- a/example/ruby/RubyVM/Shape.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: RubyVM::Shape -**Inherits:** Object - - -:nodoc: - - - diff --git a/example/ruby/RubyVM/TraceInstructions.md b/example/ruby/RubyVM/TraceInstructions.md deleted file mode 100644 index 7a6bbcf..0000000 --- a/example/ruby/RubyVM/TraceInstructions.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: RubyVM::TraceInstructions -**Inherits:** Object - -**Includes:** RubyVM::CEscape - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## attributes() [](#method-i-attributes) - -## bin() [](#method-i-bin) - -## has_attribute?() [](#method-i-has_attribute?) - -**@return** [Boolean] - -## initialize(orig) [](#method-i-initialize) - -**@return** [TraceInstructions] a new instance of TraceInstructions - -## jump_destination() [](#method-i-jump_destination) - -## operands_info() [](#method-i-operands_info) - -## pops() [](#method-i-pops) - -## pretty_name() [](#method-i-pretty_name) - -## rets() [](#method-i-rets) - -## width() [](#method-i-width) - diff --git a/example/ruby/RubyVM/YJIT.md b/example/ruby/RubyVM/YJIT.md deleted file mode 100644 index 81b9f9a..0000000 --- a/example/ruby/RubyVM/YJIT.md +++ /dev/null @@ -1,97 +0,0 @@ -# Module: RubyVM::YJIT - - -This module allows for introspection of YJIT, CRuby's just-in-time compiler. -Everything in the module is highly implementation specific and the API might -be less stable compared to the standard library. - -This module may not exist if YJIT does not support the particular platform for -which CRuby is built. - - -# Class Methods -## code_gc() [](#method-c-code_gc) -Discard existing compiled code to reclaim memory and allow for recompilations -in the future. -## disasm(iseq ) [](#method-c-disasm) -Produce disassembly for an iseq. This requires a `--enable-yjit=dev` build. -## dump_exit_locations(filename ) [](#method-c-dump_exit_locations) -Marshal dumps exit locations to the given filename. - -Usage: - -If `--yjit-exit-locations` is passed, a file named "yjit_exit_locations.dump" -will automatically be generated. - -If you want to collect traces manually, call `dump_exit_locations` directly. - -Note that calling this in a script will generate stats after the dump is -created, so the stats data may include exits from the dump itself. - -In a script call: - - at_exit do - RubyVM::YJIT.dump_exit_locations("my_file.dump") - end - -Then run the file with the following options: - - ruby --yjit --yjit-trace-exits test.rb - -Once the code is done running, use Stackprof to read the dump file. See -Stackprof documentation for options. -## enable(stats: false, log: false) [](#method-c-enable) -Enable YJIT compilation. `stats` option decides whether to enable YJIT stats -or not. `compilation_log` decides whether to enable YJIT compilation logging -or not. - -* `stats`: - * `false`: Don't enable stats. - * `true`: Enable stats. Print stats at exit. - * `:quiet`: Enable stats. Do not print stats at exit. - -* `log`: - * `false`: Don't enable the log. - * `true`: Enable the log. Print log at exit. - * `:quiet`: Enable the log. Do not print log at exit. -## enabled?() [](#method-c-enabled?) -Check if YJIT is enabled. -**@return** [Boolean] - -## exit_locations() [](#method-c-exit_locations) -If --yjit-trace-exits is enabled parse the hashes from -Primitive.rb_yjit_get_exit_locations into a format readable by Stackprof. This -will allow us to find the exact location of a side exit in YJIT based on the -instruction that is exiting. -## insns_compiled(iseq ) [](#method-c-insns_compiled) -Produce a list of instructions compiled by YJIT for an iseq -## log() [](#method-c-log) -Return an array of log entries. Return `nil` when option is not passed or -unavailable. -## log_enabled?() [](#method-c-log_enabled?) -Check if `--yjit-log` is used. -**@return** [Boolean] - -## reset_stats!() [](#method-c-reset_stats!) -Discard statistics collected for `--yjit-stats`. -## runtime_stats(key nil) [](#method-c-runtime_stats) -Return a hash for statistics generated for the `--yjit-stats` command line -option. Return `nil` when option is not passed or unavailable. If a symbol -argument is provided, return only the value for the named stat. If any other -type is provided, raises TypeError. -**@raise** [TypeError] - -## simulate_oom!() [](#method-c-simulate_oom!) -:nodoc: -## stats_enabled?() [](#method-c-stats_enabled?) -Check if `--yjit-stats` is used. -**@return** [Boolean] - -## stats_string() [](#method-c-stats_string) -Format and print out counters as a String. This returns a non-empty content -only when `--yjit-stats` is enabled. -## trace_exit_locations_enabled?() [](#method-c-trace_exit_locations_enabled?) -Check if rb_yjit_trace_exit_locations_enabled_p is enabled. -**@return** [Boolean] - - diff --git a/example/ruby/RubygemsVersionManager.md b/example/ruby/RubygemsVersionManager.md deleted file mode 100644 index 20c9dd6..0000000 --- a/example/ruby/RubygemsVersionManager.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: RubygemsVersionManager -**Inherits:** Object - -**Includes:** Spec::Env, Spec::Options, Spec::Subprocess - - - - - -#Instance Methods -## all_commands_output() [](#method-i-all_commands_output) - -## assert_system_features_not_loaded!() [](#method-i-assert_system_features_not_loaded!) - -## command_executions() [](#method-i-command_executions) - -## err() [](#method-i-err) - -## exitstatus() [](#method-i-exitstatus) - -## git(cmd, pathDir.pwd, options{}) [](#method-i-git) - -## initialize(source) [](#method-i-initialize) - -**@return** [RubygemsVersionManager] a new instance of RubygemsVersionManager - -## last_command() [](#method-i-last_command) - -## opt_add(option, options) [](#method-i-opt_add) - -## opt_remove(option, options) [](#method-i-opt_remove) - -## out() [](#method-i-out) - -## read_stream(stream, handler, timeout:) [](#method-i-read_stream) -Mostly copied from -https://github.com/piotrmurach/tty-command/blob/49c37a895ccea107e8b78d20e4cb29 -de6a1a53c8/lib/tty/command/process_runner.rb#L165-L193 - -## ruby_core?() [](#method-i-ruby_core?) - -**@return** [Boolean] - -## sh(cmd, options{}) [](#method-i-sh) - -## switch() [](#method-i-switch) - diff --git a/example/ruby/RuntimeError.md b/example/ruby/RuntimeError.md deleted file mode 100644 index ec7ea7b..0000000 --- a/example/ruby/RuntimeError.md +++ /dev/null @@ -1,15 +0,0 @@ -# Exception: RuntimeError -**Inherits:** StandardError - - -A generic error class raised when an invalid operation is attempted. -Kernel#raise will raise a RuntimeError if no Exception class is specified. - - raise "ouch" - -*raises the exception:* - - RuntimeError: ouch - - - diff --git a/example/ruby/S.md b/example/ruby/S.md deleted file mode 100644 index 5392358..0000000 --- a/example/ruby/S.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: S -**Inherits:** Object - - - - - -#Instance Methods -## initialize(a) [](#method-i-initialize) - -**@return** [S] a new instance of S - diff --git a/example/ruby/SHA1Constants.md b/example/ruby/SHA1Constants.md deleted file mode 100644 index b59222f..0000000 --- a/example/ruby/SHA1Constants.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SHA1Constants - - - - - diff --git a/example/ruby/SHA256Constants.md b/example/ruby/SHA256Constants.md deleted file mode 100644 index ca11f96..0000000 --- a/example/ruby/SHA256Constants.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SHA256Constants - - - - - diff --git a/example/ruby/SHA384Constants.md b/example/ruby/SHA384Constants.md deleted file mode 100644 index 90d3604..0000000 --- a/example/ruby/SHA384Constants.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SHA384Constants - - - - - diff --git a/example/ruby/SHA512Constants.md b/example/ruby/SHA512Constants.md deleted file mode 100644 index ee16811..0000000 --- a/example/ruby/SHA512Constants.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SHA512Constants - - - - - diff --git a/example/ruby/SOCKSSocket.md b/example/ruby/SOCKSSocket.md deleted file mode 100644 index 5f5f726..0000000 --- a/example/ruby/SOCKSSocket.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: SOCKSSocket -**Inherits:** TCPSocket - - -SOCKS is an Internet protocol that routes packets between a client and a -server through a proxy server. SOCKS5, if supported, additionally provides -authentication so only authorized users may access a server. - - - -#Instance Methods -## close() [](#method-i-close) -Closes the SOCKS connection. - -## initialize(host, port) [](#method-i-initialize) -Opens a SOCKS connection to `host` via the SOCKS server. - -The SOCKS server configuration varies by implementation - -When using the Dante libsocks/libsocksd implementation it is configured as -SOCKS_SERVER env var. - -See: https://manpages.debian.org/testing/dante-client/socksify.1.en.html for -full env variable support. - -**@overload** [] - diff --git a/example/ruby/SameName.md b/example/ruby/SameName.md deleted file mode 100644 index 6bd8849..0000000 --- a/example/ruby/SameName.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SameName -**Inherits:** Object - - - - - diff --git a/example/ruby/SampleClassForTestProfileFrames.md b/example/ruby/SampleClassForTestProfileFrames.md deleted file mode 100644 index 93ce956..0000000 --- a/example/ruby/SampleClassForTestProfileFrames.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: SampleClassForTestProfileFrames -**Inherits:** Object - - - - -# Class Methods -## bar(block ) [](#method-c-bar) -# Attributes -## sample4[RW] [](#attribute-c-sample4) -Returns the value of attribute sample4. - - -#Instance Methods -## foo(block) [](#method-i-foo) - diff --git a/example/ruby/SampleClassForTestProfileFrames/Sample2.md b/example/ruby/SampleClassForTestProfileFrames/Sample2.md deleted file mode 100644 index 11fdcf9..0000000 --- a/example/ruby/SampleClassForTestProfileFrames/Sample2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SampleClassForTestProfileFrames::Sample2 -**Inherits:** Object - - - - - -#Instance Methods -## baz(block) [](#method-i-baz) - diff --git a/example/ruby/SampleClassForTestProfileFrames/Sample3.md b/example/ruby/SampleClassForTestProfileFrames/Sample3.md deleted file mode 100644 index 7e22c5f..0000000 --- a/example/ruby/SampleClassForTestProfileFrames/Sample3.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: SampleClassForTestProfileFrames::Sample3 - - - - -# Class Methods -## qux(block ) [](#method-c-qux) - diff --git a/example/ruby/SampleClassForTestProfileThreadFrames.md b/example/ruby/SampleClassForTestProfileThreadFrames.md deleted file mode 100644 index bee7fa9..0000000 --- a/example/ruby/SampleClassForTestProfileThreadFrames.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: SampleClassForTestProfileThreadFrames -**Inherits:** Object - - - - - -#Instance Methods -## bar(block) [](#method-i-bar) - -## foo(block) [](#method-i-foo) - -## initialize(mutex) [](#method-i-initialize) - -**@return** [SampleClassForTestProfileThreadFrames] a new instance of SampleClassForTestProfileThreadFrames - diff --git a/example/ruby/Scene.md b/example/ruby/Scene.md deleted file mode 100644 index 156723a..0000000 --- a/example/ruby/Scene.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Scene -**Inherits:** Object - - - - - -#Instance Methods -## ambient_occlusion(isect) [](#method-i-ambient_occlusion) - -## initialize() [](#method-i-initialize) - -**@return** [Scene] a new instance of Scene - -## render(w, h, nsubsamples) [](#method-i-render) - diff --git a/example/ruby/Scheduler.md b/example/ruby/Scheduler.md deleted file mode 100644 index ca9a08e..0000000 --- a/example/ruby/Scheduler.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: Scheduler -**Inherits:** Object - - - - -# Attributes -## readable[RW] [](#attribute-i-readable) -Returns the value of attribute readable. - -## waiting[RW] [](#attribute-i-waiting) -Returns the value of attribute waiting. - -## writable[RW] [](#attribute-i-writable) -Returns the value of attribute writable. - - -#Instance Methods -## address_resolve(hostname) [](#method-i-address_resolve) -This hook is invoked by `Addrinfo.getaddrinfo`. Using a thread ensures that -the operation does not block the fiber scheduler, since `getaddrinfo` is -usually provided by `libc` and is blocking. - -## block(blocker, timeoutnil) [](#method-i-block) -This hook is invoked by blocking options such as `Thread::Mutex#lock`, -`Thread::Queue#pop` and `Thread::SizedQueue#push`, which are unblocked by -other threads/fibers. To unblock a blocked fiber, you should call `unblock` -with the same `blocker` and `fiber` arguments. - -## blocking_operation_wait(work) [](#method-i-blocking_operation_wait) - -## close(internalfalse) [](#method-i-close) -If the `scheduler_close` hook does not exist, this method `close` will be -invoked instead when the fiber scheduler goes out of scope. This is legacy -behaviour, you should almost certainly use `scheduler_close`. The reason for -this, is `scheduler_close` is called when the scheduler goes out of scope, -while `close` may be called by the user. - -## closed?() [](#method-i-closed?) - -**@return** [Boolean] - -## current_time() [](#method-i-current_time) - -## fiber(&block) [](#method-i-fiber) -This hook is invoked by `Fiber.schedule`. Strictly speaking, you should use it -to create scheduled fibers, but it is not required in practice; `Fiber.new` is -usually sufficient. - -## initialize(fiberFiber.current) [](#method-i-initialize) - -**@return** [Scheduler] a new instance of Scheduler - -## io_select() [](#method-i-io_select) -This hook is invoked by `IO.select`. Using a thread ensures that the operation -does not block the fiber scheduler. - -## io_wait(io, events, duration) [](#method-i-io_wait) -This hook is invoked by `IO#read` and `IO#write` in the case that `io_read` -and `io_write` hooks are not available. This implementation is not completely -general, in the sense that calling `io_wait` multiple times with the same `io` -and `events` will not work, which is okay for tests but not for real code. -Correct fiber schedulers should not have this limitation. - -## kernel_sleep(durationnil) [](#method-i-kernel_sleep) -This hook is invoked by `Kernel#sleep` and `Thread::Mutex#sleep`. - -## next_timeout() [](#method-i-next_timeout) - -## process_wait(pid, flags) [](#method-i-process_wait) -This hook is invoked by `Process.wait`, `system`, and backticks. - -## run() [](#method-i-run) - -## scheduler_close() [](#method-i-scheduler_close) -A fiber scheduler hook, invoked when the scheduler goes out of scope. - -## timeout_after(duration, klass, message, &block) [](#method-i-timeout_after) -This hook is invoked by `Timeout.timeout` and related code. - -## transfer() [](#method-i-transfer) - -## unblock(blocker, fiber) [](#method-i-unblock) -This method is invoked from a thread or fiber to unblock a fiber that is -blocked by `block`. It is expected to be thread safe. - diff --git a/example/ruby/ScratchPad.md b/example/ruby/ScratchPad.md deleted file mode 100644 index 539696d..0000000 --- a/example/ruby/ScratchPad.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: ScratchPad - - - - -# Class Methods -## <<(arg ) [](#method-c-<<) -## clear() [](#method-c-clear) -## inspect() [](#method-c-inspect) -## record(arg ) [](#method-c-record) -## recorded() [](#method-c-recorded) - diff --git a/example/ruby/ScriptError.md b/example/ruby/ScriptError.md deleted file mode 100644 index 430daf1..0000000 --- a/example/ruby/ScriptError.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: ScriptError -**Inherits:** Exception - - -ScriptError is the superclass for errors raised when a script can not be -executed because of a `LoadError`, `NotImplementedError` or a `SyntaxError`. -Note these type of `ScriptErrors` are not `StandardError` and will not be -rescued unless it is specified explicitly (or its ancestor `Exception`). - - - diff --git a/example/ruby/SecondClass.md b/example/ruby/SecondClass.md deleted file mode 100644 index d655042..0000000 --- a/example/ruby/SecondClass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SecondClass -**Inherits:** Object - - - - - -#Instance Methods -## some_method() [](#method-i-some_method) - diff --git a/example/ruby/SecureRandom.md b/example/ruby/SecureRandom.md deleted file mode 100644 index eb96e13..0000000 --- a/example/ruby/SecureRandom.md +++ /dev/null @@ -1,266 +0,0 @@ -# Module: SecureRandom - -**Extended by:** Random::Formatter - - -## Secure random number generator interface. - -This library is an interface to secure random number generators which are -suitable for generating session keys in HTTP cookies, etc. - -You can use this library in your application by requiring it: - - require 'securerandom' - -It supports the following secure random number generators: - -* openssl -* /dev/urandom -* Win32 - -SecureRandom is extended by the Random::Formatter module which defines the -following methods: - -* alphanumeric -* base64 -* choose -* gen_random -* hex -* rand -* random_bytes -* random_number -* urlsafe_base64 -* uuid - -These methods are usable as class methods of SecureRandom such as -`SecureRandom.hex`. - -If a secure random number generator is not available, `NotImplementedError` is -raised. - - -# Class Methods -## alphanumeric(n nil, chars: ALPHANUMERIC) [](#method-c-alphanumeric) -Generate a random alphanumeric string. - -The argument *n* specifies the length, in characters, of the alphanumeric -string to be generated. The argument *chars* specifies the character list -which the result is consist of. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain A-Z, a-z and 0-9, unless *chars* is specified. - - require 'random/formatter' - - Random.alphanumeric #=> "2BuBuLf3WfSKyQbR" - # or - prng = Random.new - prng.alphanumeric(10) #=> "i6K93NdqiH" - - Random.alphanumeric(4, chars: [*"0".."9"]) #=> "2952" - # or - prng = Random.new - prng.alphanumeric(10, chars: [*"!".."/"]) #=> ",.,++%/''." -## base64(n nil) [](#method-c-base64) -Generate a random base64 string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the result string is about 4/3 of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain A-Z, a-z, 0-9, "+", "/" and "=". - - require 'random/formatter' - - Random.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A==" - # or - prng = Random.new - prng.base64 #=> "6BbW0pxO0YENxn38HMUbcQ==" - -See RFC 3548 for the definition of base64. -## bytes(n ) [](#method-c-bytes) -Returns a random binary string containing `size` bytes. - -See Random.bytes -## hex(n nil) [](#method-c-hex) -Generate a random hexadecimal string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the resulting hexadecimal string is twice of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The result may contain 0-9 and a-f. - - require 'random/formatter' - - Random.hex #=> "eb693ec8252cd630102fd0d0fb7c3485" - # or - prng = Random.new - prng.hex #=> "91dc3bfb4de5b11d029d376634589b61" -## rand(*args ) [](#method-c-rand) -Generates formatted random number from raw random bytes. See Random#rand. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## random_bytes(n nil) [](#method-c-random_bytes) -Generate a random binary string. - -The argument *n* specifies the length of the result string. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in future. - -The result may contain any byte: "x00" - "xff". - - require 'random/formatter' - - Random.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6" - # or - prng = Random.new - prng.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97" -## random_number(*args ) [](#method-c-random_number) -Generates formatted random number from raw random bytes. See Random#rand. -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## urlsafe_base64(n nil, padding false) [](#method-c-urlsafe_base64) -Generate a random URL-safe base64 string. - -The argument *n* specifies the length, in bytes, of the random number to be -generated. The length of the result string is about 4/3 of *n*. - -If *n* is not specified or is nil, 16 is assumed. It may be larger in the -future. - -The boolean argument *padding* specifies the padding. If it is false or nil, -padding is not generated. Otherwise padding is generated. By default, padding -is not generated because "=" may be used as a URL delimiter. - -The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if -*padding* is true. - - require 'random/formatter' - - Random.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg" - # or - prng = Random.new - prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg" - - prng.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ==" - prng.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg==" - -See RFC 3548 for the definition of URL-safe base64. -## uuid() [](#method-c-uuid) -Generate a random v4 UUID (Universally Unique IDentifier). - - require 'random/formatter' - - Random.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594" - Random.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab" - # or - prng = Random.new - prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b" - -The version 4 UUID is purely random (except the version). It doesn't contain -meaningful information such as MAC addresses, timestamps, etc. - -The result contains 122 random bits (15.25 random bytes). - -See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv4. -## uuid_v7(extra_timestamp_bits: 0) [](#method-c-uuid_v7) -Generate a random v7 UUID (Universally Unique IDentifier). - - require 'random/formatter' - - Random.uuid_v7 # => "0188d4c3-1311-7f96-85c7-242a7aa58f1e" - Random.uuid_v7 # => "0188d4c3-16fe-744f-86af-38fa04c62bb5" - Random.uuid_v7 # => "0188d4c3-1af8-764f-b049-c204ce0afa23" - Random.uuid_v7 # => "0188d4c3-1e74-7085-b14f-ef6415dc6f31" - # |<--sorted-->| |<----- random ---->| - - # or - prng = Random.new - prng.uuid_v7 # => "0188ca51-5e72-7950-a11d-def7ff977c98" - -The version 7 UUID starts with the least significant 48 bits of a 64 bit Unix -timestamp (milliseconds since the epoch) and fills the remaining bits with -random data, excluding the version and variant bits. - -This allows version 7 UUIDs to be sorted by creation time. Time ordered UUIDs -can be used for better database index locality of newly inserted records, -which may have a significant performance benefit compared to random data -inserts. - -The result contains 74 random bits (9.25 random bytes). - -Note that this method cannot be made reproducible because its output includes -not only random bits but also timestamp. - -See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv7. - -#### Monotonicity - -UUIDv7 has millisecond precision by default, so multiple UUIDs created within -the same millisecond are not issued in monotonically increasing order. To -create UUIDs that are time-ordered with sub-millisecond precision, up to 12 -bits of additional timestamp may added with `extra_timestamp_bits`. The extra -timestamp precision comes at the expense of random bits. Setting -`extra_timestamp_bits: 12` provides ~244ns of precision, but only 62 random -bits (7.75 random bytes). - - prng = Random.new - Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 12) } - # => - ["0188d4c7-13da-74f9-8b53-22a786ffdd5a", - "0188d4c7-13da-753b-83a5-7fb9b2afaeea", - "0188d4c7-13da-754a-88ea-ac0baeedd8db", - "0188d4c7-13da-7557-83e1-7cad9cda0d8d"] - # |<--- sorted --->| |<-- random --->| - - Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 8) } - # => - ["0188d4c7-3333-7a95-850a-de6edb858f7e", - "0188d4c7-3333-7ae8-842e-bc3a8b7d0cf9", # <- out of order - "0188d4c7-3333-7ae2-995a-9f135dc44ead", # <- out of order - "0188d4c7-3333-7af9-87c3-8f612edac82e"] - # |<--- sorted -->||<---- random --->| - -Any rollbacks of the system clock will break monotonicity. UUIDv7 is based on -UTC, which excludes leap seconds and can rollback the clock. To avoid this, -the system clock can synchronize with an NTP server configured to use a "leap -smear" approach. NTP or PTP will also be needed to synchronize across -distributed nodes. - -Counters and other mechanisms for stronger guarantees of monotonicity are not -implemented. Applications with stricter requirements should follow [Section -6.2](https://www.rfc-editor.org/rfc/rfc9562.html#name-monotonicity-and-counter -s) of the specification. - -#Instance Methods -## alphanumeric(nnil, chars:ALPHANUMERIC) [](#method-i-alphanumeric) -Compatibility methods for Ruby 3.2, we can remove this after dropping to -support Ruby 3.2 - diff --git a/example/ruby/SecurityError.md b/example/ruby/SecurityError.md deleted file mode 100644 index 875e0d3..0000000 --- a/example/ruby/SecurityError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: SecurityError -**Inherits:** Exception - - -No longer used by internal code. - - - diff --git a/example/ruby/Segfault.md b/example/ruby/Segfault.md deleted file mode 100644 index a0f0739..0000000 --- a/example/ruby/Segfault.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Segfault -**Inherits:** Object - - - - - diff --git a/example/ruby/SendSpecs.md b/example/ruby/SendSpecs.md deleted file mode 100644 index 6623454..0000000 --- a/example/ruby/SendSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SendSpecs - - - - - diff --git a/example/ruby/Sentence.md b/example/ruby/Sentence.md deleted file mode 100644 index 2f8169e..0000000 --- a/example/ruby/Sentence.md +++ /dev/null @@ -1,2285 +0,0 @@ -# Class: Sentence -**Inherits:** Object - -**Includes:** Enumerable - - -Sentence class represents a tree with string leaves. - - -# Class Methods -## each(syntax , sym , limit ) [](#method-c-each) -Sentence.each generates sentences by deriving the start symbol *sym* using -*syntax*. The derivation is restricted by an positive integer *limit* to avoid -infinite generation. - -Sentence.each yields the block with a generated sentence. - - Sentence.each({ - :exp => [["n"], - [:exp, "+", :exp], - [:exp, "*", :exp]] - }, :exp, 1) {|sent| p sent } - #=> - # - # - # - - Sentence.each({ - :exp => [["n"], - [:exp, "+", :exp], - [:exp, "*", :exp]] - }, :exp, 2) {|sent| p sent } - #=> - # - # - # - # - # - # - # - # - # - # - # -## expand_syntax(syntax ) [](#method-c-expand_syntax) -Sentence.expand_syntax returns an expanded syntax: -* No rule derives to empty sequence -* Underivable rule simplified -* No channel rule -* Symbols which has zero or one choices are not appeared in rhs. - -Note that the rules which can derive empty and non-empty sequences are -modified to derive only non-empty sequences. - - Sentence.expand_syntax({ - :underivable1 => [], - :underivable2 => [[:underivable1]], - :underivable3 => [[:underivable3]], - :empty_only1 => [[]], - :empty_only2 => [[:just_empty1, :just_empty1]], - :empty_or_not => [[], ["foo"]], - :empty_or_not_2 => [[:empty_or_not, :empty_or_not]], - :empty_or_not_3 => [[:empty_or_not, :empty_or_not, :empty_or_not]], - :empty_or_not_4 => [[:empty_or_not_2, :empty_or_not_2]], - :channel1 => [[:channeled_data]], - :channeled_data => [["a", "b"], ["c", "d"]], - :single_choice => [["single", "choice"]], - :single_choice_2 => [[:single_choice, :single_choice]], - }) - #=> - { - :underivable1=>[], # underivable rules are simplified to []. - :underivable2=>[], - :underivable3=>[], - :empty_only1=>[], # derivation to empty sequence are removed. - :empty_only2=>[], - :empty_or_not=>[["foo"]], # empty sequences are removed too. - :empty_or_not_2=>[["foo"], ["foo", "foo"]], - :empty_or_not_3=>[["foo"], ["foo", "foo"], ["foo", "foo", "foo"]], - :empty_or_not_4=> [["foo"], ["foo", "foo"], [:empty_or_not_2, :empty_or_not_2]], - :channel1=>[["a", "b"], ["c", "d"]], # channel rules are removed. - :channeled_data=>[["a", "b"], ["c", "d"]], - :single_choice=>[["single", "choice"]], # single choice rules are expanded. - :single_choice_2=>[["single", "choice", "single", "choice"]], - } - - Sentence.expand_syntax({ - :factor => [["n"], - ["(", :exp, ")"]], - :term => [[:factor], - [:term, "*", :factor], - [:term, "/", :factor]], - :exp => [[:term], - [:exp, "+", :term], - [:exp, "-", :term]] - }) - #=> - {:exp=> [["n"], - ["(", :exp, ")"], - [:exp, "+", :term], - [:exp, "-", :term], - [:term, "*", :factor], - [:term, "/", :factor]], - :factor=> [["n"], - ["(", :exp, ")"]], - :term=> [["n"], - ["(", :exp, ")"], - [:term, "*", :factor], - [:term, "/", :factor]] - } - -#Instance Methods -## [](i) [](#method-i-[]) -returns *i*th element as a sentence or string. - - s = Sentence(["foo", "bar"], "baz") - s #=> # - s[0] #=> # - s[1] #=> "baz" - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -iterates over children. - - Sentence(%w[2 * 7], "+", %w[3 * 5]).each {|v| p v } - #=> - # - "+" - # - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## expand(&b) [](#method-i-expand) -returns a new sentence object which expands according to the condition given -by the block. - -The block is invoked for each subsentence. The subsentences which the block -returns true are expanded into parent. - - s = Sentence(%w[2 * 7], "+", %w[3 * 5]) - #=> # - - s.expand { true } - #=> # - - s.expand {|s| s[0] == "3" } - #=> # - -## expand_rec(obj, r[], &b) [](#method-i-expand_rec) -:stopdoc: - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## find_subtree(&b) [](#method-i-find_subtree) -find a subsentence and return it. The block is invoked for each subsentence in -preorder manner. The first subsentence which the block returns true is -returned. - - Sentence(%w[2 * 7], "+", %w[3 * 5]).find_subtree {|s| s[1] == "*" } - #=> # - -## find_subtree_rec(obj, &b) [](#method-i-find_subtree_rec) -:stopdoc: - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(ary) [](#method-i-initialize) -*ary* represents a tree. It should be a possibly nested array which contains -strings. - -Note that *ary* is not copied. Don't modify *ary* after the sentence object is -instantiated. - - Sentence.new(["a", "pen"]) - # - - Sentence.new(["I", "have", ["a", "pen"]]) - # - -**@return** [Sentence] a new instance of Sentence - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inner_inspect(ary, r) [](#method-i-inner_inspect) -:stopdoc: - -## inspect() [](#method-i-inspect) - -## join(sep' ') [](#method-i-join) -returns a string which is concatenation of all strings separated by *sep*. If -*sep* is not given, single space is used. - - Sentence("I", "have", ["a", "pen"]).join - "I have a pen" - - Sentence("I", "have", ["a", "pen"]).join("/") - "I/have/a/pen" - - Sentence("a", [], "b").join("/") - "a/b" - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## length() [](#method-i-length) -returns the number of top level elements. - - Sentence.new(%w[foo bar]).length - #=> 2 - - Sentence(%w[2 * 7], "+", %w[3 * 5]).length - #=> 3 - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## subst(target, &b) [](#method-i-subst) -returns new sentence object which *target* is substituted by the block. - -Sentence#subst invokes *`target* === *string`* for each string in the -sentence. The strings which === returns true are substituted by the block. The -block is invoked with the substituting string. - - Sentence.new(%w[2 + 3]).subst("+") { "*" } - # - - Sentence.new(%w[2 + 3]).subst(/\A\d+\z/) {|s| ((s.to_i)*2).to_s } - #=> # - -## subst_rec(obj, target, &b) [](#method-i-subst_rec) -:stopdoc: - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) -returns a tree as a nested array. - -Note that the result is not copied. Don't modify the result. - - Sentence(["foo", "bar"], "baz").to_a - #=> [["foo", "bar"], "baz"] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_s() [](#method-i-to_s) -returns a string which is concatenation of all strings. No separator is used. - - Sentence("2", "+", "3").to_s - "2+3" - - Sentence("2", "+", ["3", "*", "5"]).to_s - "2+3*5" - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Sentence/Gen.md b/example/ruby/Sentence/Gen.md deleted file mode 100644 index 1ed5e08..0000000 --- a/example/ruby/Sentence/Gen.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Sentence::Gen -**Inherits:** Object - - -:stopdoc: - - -# Class Methods -## each_string(syntax , sym , limit , &b ) [](#method-c-each_string) -## each_tree(syntax , sym , limit , &b ) [](#method-c-each_tree) -## expand_channel_rules(syntax ) [](#method-c-expand_channel_rules) -## expand_emptyable_syms(rhs , emptyable_syms ) [](#method-c-expand_emptyable_syms) -## expand_noalt_rules(syntax ) [](#method-c-expand_noalt_rules) -## expand_syntax(syntax ) [](#method-c-expand_syntax) -## make_rules_no_empseq(syntax ) [](#method-c-make_rules_no_empseq) -## reorder_rules(syntax ) [](#method-c-reorder_rules) -## simplify_emptyonly_rules(syntax ) [](#method-c-simplify_emptyonly_rules) -## simplify_underivable_rules(syntax ) [](#method-c-simplify_underivable_rules) - -#Instance Methods -## each_string(sym, limit) [](#method-i-each_string) - -## each_tree(sym, limit) [](#method-i-each_tree) - -## generate_from_rhs(rhs, limit) [](#method-i-generate_from_rhs) - -## generate_from_sym(sym, limit, &b) [](#method-i-generate_from_sym) - -## initialize(syntax) [](#method-i-initialize) - -**@return** [Gen] a new instance of Gen - diff --git a/example/ruby/Seq.md b/example/ruby/Seq.md deleted file mode 100644 index 025bc51..0000000 --- a/example/ruby/Seq.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Seq -**Inherits:** Object - -**Includes:** DRbNamedObject, DRbUndumped - - - - - -#Instance Methods -## initialize(v, name) [](#method-i-initialize) - -**@return** [Seq] a new instance of Seq - -## next_value() [](#method-i-next_value) - diff --git a/example/ruby/Set.md b/example/ruby/Set.md deleted file mode 100644 index 43fc88f..0000000 --- a/example/ruby/Set.md +++ /dev/null @@ -1,2517 +0,0 @@ -# Class: Set -**Inherits:** Object - -**Includes:** Enumerable - - -This library provides the Set class, which implements a collection of -unordered values with no duplicates. It is a hybrid of Array's intuitive -inter-operation facilities and Hash's fast lookup. - -The method `to_set` is added to Enumerable for convenience. - -Set is easy to use with Enumerable objects (implementing `each`). Most of the -initializer methods and binary operators accept generic Enumerable objects -besides sets and arrays. An Enumerable object can be converted to Set using -the `to_set` method. - -Set uses Hash as storage, so you must note the following points: - -* Equality of elements is determined according to Object#eql? and - Object#hash. Use Set#compare_by_identity to make a set compare its - elements by their identity. -* Set assumes that the identity of each element does not change while it is - stored. Modifying an element of a set will render the set to an - unreliable state. -* When a string is to be stored, a frozen copy of the string is stored - instead unless the original string is already frozen. - -## Comparison - -The comparison operators `<`, `>`, `<=`, and `>=` are implemented as shorthand -for the {proper_,}{subset?,superset?} methods. The `<=>` operator reflects -this order, or return `nil` for sets that both have distinct elements (`{x, -y}` vs. `{x, z}` for example). - -## Example - -```ruby require 'set' s1 = Set[1, 2] #=> # -s2 = [1, 2].to_set #=> # s1 == s2 - #=> true s1.add("foo") #=> # s1.merge([2, 6]) #=> # -s1.subset?(s2) #=> false s2.subset?(s1) - #=> true ``` - -## Contact - -* Akinori MUSHA <> (current maintainer) - -## What's Here - - First, what's elsewhere. \Class \Set: - -* Inherits from [class Object](rdoc-ref:Object@What-27s+Here). -* Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which - provides dozens of additional methods. - -In particular, class Set does not have many methods of its own for fetching or -for iterating. Instead, it relies on those in Enumerable. - -Here, class Set provides methods that are useful for: - -* [Creating a Set](#class-Set-label-Methods+for+Creating+a+Set) -* [Set Operations](#class-Set-label-Methods+for+Set+Operations) -* [Comparing](#class-Set-label-Methods+for+Comparing) -* [Querying](#class-Set-label-Methods+for+Querying) -* [Assigning](#class-Set-label-Methods+for+Assigning) -* [Deleting](#class-Set-label-Methods+for+Deleting) -* [Converting](#class-Set-label-Methods+for+Converting) -* [Iterating](#class-Set-label-Methods+for+Iterating) -* [And more....](#class-Set-label-Other+Methods) - -### Methods for Creating a Set - -* ::[]: Returns a new set containing the given objects. -* ::new: Returns a new set containing either the given objects (if no block - given) or the return values from the called block (if a block given). - -### Methods for Set Operations - -* [|](#method-i-7C) (aliased as #union and #+): Returns a new set containing - all elements from `self` and all elements from a given enumerable (no - duplicates). -* [&](#method-i-26) (aliased as #intersection): Returns a new set containing - all elements common to `self` and a given enumerable. -* [-](#method-i-2D) (aliased as #difference): Returns a copy of `self` with - all elements in a given enumerable removed. -* [^](#method-i-5E): Returns a new set containing all elements from `self` - and a given enumerable except those common to both. - -### Methods for Comparing - -* [<=>](#method-i-3C-3D-3E): Returns -1, 0, or 1 as `self` is less than, - equal to, or greater than a given object. -* [==](#method-i-3D-3D): Returns whether `self` and a given enumerable are - equal, as determined by Object#eql?. -* #compare_by_identity?: Returns whether the set considers only identity - when comparing elements. - -### Methods for Querying - -* #length (aliased as #size): Returns the count of elements. -* #empty?: Returns whether the set has no elements. -* #include? (aliased as #member? and #===): Returns whether a given object - is an element in the set. -* #subset? (aliased as [<=](#method-i-3C-3D)): Returns whether a given - object is a subset of the set. -* #proper_subset? (aliased as [<](#method-i-3C)): Returns whether a given - enumerable is a proper subset of the set. -* #superset? (aliased as [>=](#method-i-3E-3D])): Returns whether a given - enumerable is a superset of the set. -* #proper_superset? (aliased as [>](#method-i-3E)): Returns whether a given - enumerable is a proper superset of the set. -* #disjoint?: Returns `true` if the set and a given enumerable have no - common elements, `false` otherwise. -* #intersect?: Returns `true` if the set and a given enumerable: have any - common elements, `false` otherwise. -* #compare_by_identity?: Returns whether the set considers only identity - when comparing elements. - -### Methods for Assigning - -* #add (aliased as #<<): Adds a given object to the set; returns `self`. -* #add?: If the given object is not an element in the set, adds it and - returns `self`; otherwise, returns `nil`. -* #merge: Merges the elements of each given enumerable object to the set; - returns `self`. -* #replace: Replaces the contents of the set with the contents of a given - enumerable. - -### Methods for Deleting - -* #clear: Removes all elements in the set; returns `self`. -* #delete: Removes a given object from the set; returns `self`. -* #delete?: If the given object is an element in the set, removes it and - returns `self`; otherwise, returns `nil`. -* #subtract: Removes each given object from the set; returns `self`. -* #delete_if - Removes elements specified by a given block. -* #select! (aliased as #filter!): Removes elements not specified by a given - block. -* #keep_if: Removes elements not specified by a given block. -* #reject! Removes elements specified by a given block. - -### Methods for Converting - -* #classify: Returns a hash that classifies the elements, as determined by - the given block. -* #collect! (aliased as #map!): Replaces each element with a block - return-value. -* #divide: Returns a hash that classifies the elements, as determined by the - given block; differs from #classify in that the block may accept either - one or two arguments. -* #flatten: Returns a new set that is a recursive flattening of `self`. - \#flatten!: - Replaces each nested set in +self+ with the elements from that set. - -* #inspect (aliased as #to_s): Returns a string displaying the elements. -* #join: Returns a string containing all elements, converted to strings as - needed, and joined by the given record separator. -* #to_a: Returns an array containing all set elements. -* #to_set: Returns `self` if given no arguments and no block; with a block - given, returns a new set consisting of block return values. - -### Methods for Iterating - -* #each: Calls the block with each successive element; returns `self`. - -### Other Methods - -* #reset: Resets the internal state; useful if an object has been modified - while an element in the set. - - -# Class Methods -## [](*ary ) [](#method-c-[]) -Creates a new set containing the given objects. - - Set[1, 2] # => # - Set[1, 2, 1] # => # - Set[1, 'c', :s] # => # -## json_create(object ) [](#method-c-json_create) -See #as_json. - -#Instance Methods -## &(enum) [](#method-i-&) -Returns a new set containing elements common to the set and the given -enumerable object. - - Set[1, 3, 5] & Set[3, 2, 1] #=> # - Set['a', 'b', 'z'] & ['a', 'b', 'c'] #=> # - -## -(enum) [](#method-i--) -Returns a new set built by duplicating the set, removing every element that -appears in the given enumerable object. - - Set[1, 3, 5] - Set[1, 5] #=> # - Set['a', 'b', 'z'] - ['a', 'c'] #=> # - -## <=>(set) [](#method-i-<=>) -Returns 0 if the set are equal, -1 / +1 if the set is a proper subset / -superset of the given set, or nil if they both have unique elements. - -## ==(other) [](#method-i-==) -Returns true if two sets are equal. The equality of each couple of elements -is defined according to Object#eql?. - - Set[1, 2] == Set[2, 1] #=> true - Set[1, 3, 5] == Set[1, 5] #=> false - Set['a', 'b', 'c'] == Set['a', 'c', 'b'] #=> true - Set['a', 'b', 'c'] == ['a', 'c', 'b'] #=> false - -## ^(enum) [](#method-i-^) -Returns a new set containing elements exclusive between the set and the given -enumerable object. `(set ^ enum)` is equivalent to `((set | enum) - (set & -enum))`. - - Set[1, 2] ^ Set[2, 3] #=> # - Set[1, 'b', 'c'] ^ ['b', 'd'] #=> # - -## add(o) [](#method-i-add) -Adds the given object to the set and returns self. Use `merge` to add many -elements at once. - - Set[1, 2].add(3) #=> # - Set[1, 2].add([3, 4]) #=> # - Set[1, 2].add(2) #=> # - -## add?(o) [](#method-i-add?) -Adds the given object to the set and returns self. If the object is already -in the set, returns nil. - - Set[1, 2].add?(3) #=> # - Set[1, 2].add?([3, 4]) #=> # - Set[1, 2].add?(2) #=> nil - -**@return** [Boolean] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Set#as_json` and `Set.json_create` may be used to serialize and -deserialize a Set object; see [Marshal](rdoc-ref:Marshal). - -Method `Set#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/set' - x = Set.new(%w/foo bar baz/).as_json - # => {"json_class"=>"Set", "a"=>["foo", "bar", "baz"]} - -Method `JSON.create` deserializes such a hash, returning a Set object: - - Set.json_create(x) # => # - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## classify() [](#method-i-classify) -Classifies the set by the return value of the given block and returns a hash -of {value => set of elements} pairs. The block is called once for each -element of the set, passing the element as parameter. - - require 'set' - files = Set.new(Dir.glob("*.rb")) - hash = files.classify { |f| File.mtime(f).year } - hash #=> {2000=>#, - # 2001=>#, - # 2002=>#} - -Returns an enumerator if no block is given. - -## clear() [](#method-i-clear) -Removes all elements and returns self. - - set = Set[1, 'c', :s] #=> # - set.clear #=> # - set #=> # - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect!() [](#method-i-collect!) -Replaces the elements with ones returned by `collect()`. Returns an enumerator -if no block is given. - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## compare_by_identity() [](#method-i-compare_by_identity) -Makes the set compare its elements by their identity and returns self. This -method may not be supported by all subclasses of Set. - -## compare_by_identity?() [](#method-i-compare_by_identity?) -Returns true if the set will compare its elements by their identity. Also see -Set#compare_by_identity. - -**@return** [Boolean] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete(o) [](#method-i-delete) -Deletes the given object from the set and returns self. Use `subtract` to -delete many items at once. - -## delete?(o) [](#method-i-delete?) -Deletes the given object from the set and returns self. If the object is not -in the set, returns nil. - -**@return** [Boolean] - -## delete_if(&block) [](#method-i-delete_if) -Deletes every element of the set for which block evaluates to true, and -returns self. Returns an enumerator if no block is given. - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## disjoint?(set) [](#method-i-disjoint?) -Returns true if the set and the given enumerable have no element in common. -This method is the opposite of `intersect?`. - - Set[1, 2, 3].disjoint? Set[3, 4] #=> false - Set[1, 2, 3].disjoint? Set[4, 5] #=> true - Set[1, 2, 3].disjoint? [3, 4] #=> false - Set[1, 2, 3].disjoint? 4..5 #=> true - -**@return** [Boolean] - -## divide(&func) [](#method-i-divide) -Divides the set into a set of subsets according to the commonality defined by -the given block. - -If the arity of the block is 2, elements o1 and o2 are in common if -block.call(o1, o2) is true. Otherwise, elements o1 and o2 are in common if -block.call(o1) == block.call(o2). - - require 'set' - numbers = Set[1, 3, 4, 6, 9, 10, 11] - set = numbers.divide { |i,j| (i - j).abs == 1 } - set #=> #, - # #, - # #, - # #}> - -Returns an enumerator if no block is given. - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) -Calls the given block once for each element in the set, passing the element as -parameter. Returns an enumerator if no block is given. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Returns true if the set contains no elements. - -**@return** [Boolean] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eql?(o) [](#method-i-eql?) -:nodoc: - -**@return** [Boolean] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flatten() [](#method-i-flatten) -Returns a new set that is a copy of the set, flattening each containing set -recursively. - -## flatten!() [](#method-i-flatten!) -Equivalent to Set#flatten, but replaces the receiver with the result in place. - Returns nil if no modifications were made. - -## freeze() [](#method-i-freeze) -:nodoc: - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -:nodoc: - -## include?(o) [](#method-i-include?) -Returns true if the set contains the given object. - -Note that `include?` and `member?` do not test member equality using `==` as -do other Enumerables. - -See also Enumerable#include? - -**@return** [Boolean] - -## initialize(enumnil, &block) [](#method-i-initialize) -Creates a new set containing the elements of the given enumerable object. - -If a block is given, the elements of enum are preprocessed by the given block. - - Set.new([1, 2]) #=> # - Set.new([1, 2, 1]) #=> # - Set.new([1, 'c', :s]) #=> # - Set.new(1..5) #=> # - Set.new([1, 2, 3]) { |x| x * x } #=> # - -**@return** [Set] a new instance of Set - -## initialize_clone(orig, **options) [](#method-i-initialize_clone) -Clone internal hash. - -## initialize_dup(orig) [](#method-i-initialize_dup) -Dup internal hash. - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string containing a human-readable representation of the set -("#"). - -## intersect?(set) [](#method-i-intersect?) -Returns true if the set and the given enumerable have at least one element in -common. - - Set[1, 2, 3].intersect? Set[4, 5] #=> false - Set[1, 2, 3].intersect? Set[3, 4] #=> true - Set[1, 2, 3].intersect? 4..5 #=> false - Set[1, 2, 3].intersect? [3, 4] #=> true - -**@return** [Boolean] - -## join(separatornil) [](#method-i-join) -Returns a string created by converting each element of the set to a string See -also: Array#join - -## keep_if(&block) [](#method-i-keep_if) -Deletes every element of the set for which block evaluates to false, and -returns self. Returns an enumerator if no block is given. - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## merge(*enums) [](#method-i-merge) -Merges the elements of the given enumerable objects to the set and returns -self. - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pretty_print(pp) [](#method-i-pretty_print) -:nodoc: - -## pretty_print_cycle(pp) [](#method-i-pretty_print_cycle) -:nodoc: - -## proper_subset?(set) [](#method-i-proper_subset?) -Returns true if the set is a proper subset of the given set. - -**@return** [Boolean] - -## proper_superset?(set) [](#method-i-proper_superset?) -Returns true if the set is a proper superset of the given set. - -**@return** [Boolean] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reject!(&block) [](#method-i-reject!) -Equivalent to Set#delete_if, but returns nil if no changes were made. Returns -an enumerator if no block is given. - -## replace(enum) [](#method-i-replace) -Replaces the contents of the set with the contents of the given enumerable -object and returns self. - - set = Set[1, 'c', :s] #=> # - set.replace([1, 2]) #=> # - set #=> # - -## reset() [](#method-i-reset) -Resets the internal state after modification to existing elements and returns -self. - -Elements will be reindexed and deduplicated. - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## select!(&block) [](#method-i-select!) -Equivalent to Set#keep_if, but returns nil if no changes were made. Returns an -enumerator if no block is given. - -## size() [](#method-i-size) -Returns the number of elements. - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## subset?(set) [](#method-i-subset?) -Returns true if the set is a subset of the given set. - -**@return** [Boolean] - -## subtract(enum) [](#method-i-subtract) -Deletes every element that appears in the given enumerable object and returns -self. - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## superset?(set) [](#method-i-superset?) -Returns true if the set is a superset of the given set. - -**@return** [Boolean] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) -Returns an array containing all elements in the set. - - Set[1, 2].to_a #=> [1, 2] - Set[1, 'c', :s].to_a #=> [1, "c", :s] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/set' - puts Set.new(%w/foo bar baz/).to_json - -Output: - - {"json_class":"Set","a":["foo","bar","baz"]} - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Returns self if no arguments are given. Otherwise, converts the set to -another with `klass.new(self, *args, &block)`. - -In subclasses, returns `klass.new(self, *args, &block)` unless overridden. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - -## |(enum) [](#method-i-|) -Returns a new set built by merging the set and the elements of the given -enumerable object. - - Set[1, 2, 3] | Set[2, 4, 5] #=> # - Set[1, 5, 'z'] | (1..6) #=> # - diff --git a/example/ruby/SetSpecs.md b/example/ruby/SetSpecs.md deleted file mode 100644 index 95d659a..0000000 --- a/example/ruby/SetSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SetSpecs - - - - - diff --git a/example/ruby/SetSpecs/SetLike.md b/example/ruby/SetSpecs/SetLike.md deleted file mode 100644 index 5573fcf..0000000 --- a/example/ruby/SetSpecs/SetLike.md +++ /dev/null @@ -1,2088 +0,0 @@ -# Class: SetSpecs::SetLike -**Inherits:** Object - -**Includes:** Enumerable - - -This class is used to test the interaction of "Set-like" objects with real -Sets - -These "Set-like" objects reply to is_a?(Set) with true and thus real Set -objects are able to transparently interoperate with them in a duck-typing -manner. - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(entries) [](#method-i-initialize) - -**@return** [SetLike] a new instance of SetLike - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) - -## is_a?(klass) [](#method-i-is_a?) - -**@return** [Boolean] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Shellwords.md b/example/ruby/Shellwords.md deleted file mode 100644 index 9489684..0000000 --- a/example/ruby/Shellwords.md +++ /dev/null @@ -1,164 +0,0 @@ -# Module: Shellwords - - -## Manipulates strings like the UNIX Bourne shell - -This module manipulates strings according to the word parsing rules of the -UNIX Bourne shell. - -The `shellwords()` function was originally a port of shellwords.pl, but -modified to conform to [the Shell & Utilities volume of the IEEE Std -1003.1-2008, 2016 -Edition](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.ht -ml) - -### Usage - -You can use Shellwords to parse a string into a Bourne shell friendly Array. - - require 'shellwords' - - argv = Shellwords.split('three blind "mice"') - argv #=> ["three", "blind", "mice"] - -Once you've required Shellwords, you can use the #split alias -String#shellsplit. - - argv = "see how they run".shellsplit - argv #=> ["see", "how", "they", "run"] - -They treat quotes as special characters, so an unmatched quote will cause an -ArgumentError. - - argv = "they all ran after the farmer's wife".shellsplit - #=> ArgumentError: Unmatched quote: ... - -Shellwords also provides methods that do the opposite. Shellwords.escape, or -its alias, String#shellescape, escapes shell metacharacters in a string for -use in a command line. - - filename = "special's.txt" - - system("cat -- #{filename.shellescape}") - # runs "cat -- special\\'s.txt" - -Note the '--'. Without it, cat(1) will treat the following argument as a -command line option if it starts with '-'. It is guaranteed that -Shellwords.escape converts a string to a form that a Bourne shell will parse -back to the original string, but it is the programmer's responsibility to make -sure that passing an arbitrary argument to a command does no harm. - -Shellwords also comes with a core extension for Array, Array#shelljoin. - - dir = "Funny GIFs" - argv = %W[ls -lta -- #{dir}] - system(argv.shelljoin + " | less") - # runs "ls -lta -- Funny\\ GIFs | less" - -You can use this method to build a complete command line out of an array of -arguments. - -### Authors -* Wakou Aoyama -* Akinori MUSHA - -### Contact -* Akinori MUSHA (current maintainer) - - -# Class Methods -## shellescape(str ) [](#method-c-shellescape) -Escapes a string so that it can be safely used in a Bourne shell command line. - `str` can be a non-string object that responds to `to_s`. - -`str` must not contain NUL characters because of nature of `exec` system call. - -Note that a resulted string should be used unquoted and is not intended for -use in double quotes nor in single quotes. - - argv = Shellwords.escape("It's better to give than to receive") - argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive" - -String#shellescape is a shorthand for this function. - - argv = "It's better to give than to receive".shellescape - argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive" - - # Search files in lib for method definitions - pattern = "^[ \t]*def " - open("| grep -Ern -e #{pattern.shellescape} lib") { |grep| - grep.each_line { |line| - file, lineno, matched_line = line.split(':', 3) - # ... - } - } - -It is the caller's responsibility to encode the string in the right encoding -for the shell environment where this string is used. - -Multibyte characters are treated as multibyte characters, not as bytes. - -Returns an empty quoted String if `str` has a length of zero. -**@raise** [ArgumentError] - -## shelljoin(array ) [](#method-c-shelljoin) -Builds a command line string from an argument list, `array`. - -All elements are joined into a single string with fields separated by a space, -where each element is escaped for the Bourne shell and stringified using -`to_s`. See also Shellwords.shellescape. - - ary = ["There's", "a", "time", "and", "place", "for", "everything"] - argv = Shellwords.join(ary) - argv #=> "There\\'s a time and place for everything" - -Array#shelljoin is a shortcut for this function. - - ary = ["Don't", "rock", "the", "boat"] - argv = ary.shelljoin - argv #=> "Don\\'t rock the boat" - -You can also mix non-string objects in the elements as allowed in Array#join. - - output = `#{['ps', '-p', $$].shelljoin}` -## shellsplit(line ) [](#method-c-shellsplit) -Splits a string into an array of tokens in the same way the UNIX Bourne shell -does. - - argv = Shellwords.split('here are "two words"') - argv #=> ["here", "are", "two words"] - -`line` must not contain NUL characters because of nature of `exec` system -call. - -Note, however, that this is not a command line parser. Shell metacharacters -except for the single and double quotes and backslash are not treated as such. - - argv = Shellwords.split('ruby my_prog.rb | less') - argv #=> ["ruby", "my_prog.rb", "|", "less"] - -String#shellsplit is a shortcut for this function. - - argv = 'here are "two words"'.shellsplit - argv #=> ["here", "are", "two words"] -## shellwords() [](#method-c-shellwords) -Splits a string into an array of tokens in the same way the UNIX Bourne shell -does. - - argv = Shellwords.split('here are "two words"') - argv #=> ["here", "are", "two words"] - -`line` must not contain NUL characters because of nature of `exec` system -call. - -Note, however, that this is not a command line parser. Shell metacharacters -except for the single and double quotes and backslash are not treated as such. - - argv = Shellwords.split('ruby my_prog.rb | less') - argv #=> ["ruby", "my_prog.rb", "|", "less"] - -String#shellsplit is a shortcut for this function. - - argv = 'here are "two words"'.shellsplit - argv #=> ["here", "are", "two words"] - diff --git a/example/ruby/ShouldSpecsMonitor.md b/example/ruby/ShouldSpecsMonitor.md deleted file mode 100644 index d0fc04c..0000000 --- a/example/ruby/ShouldSpecsMonitor.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: ShouldSpecsMonitor -**Inherits:** Object - - - - - -#Instance Methods -## expectation(state) [](#method-i-expectation) - -## finish() [](#method-i-finish) - -## initialize() [](#method-i-initialize) - -**@return** [ShouldSpecsMonitor] a new instance of ShouldSpecsMonitor - diff --git a/example/ruby/Signal.md b/example/ruby/Signal.md deleted file mode 100644 index f202f12..0000000 --- a/example/ruby/Signal.md +++ /dev/null @@ -1,51 +0,0 @@ -# Module: Signal - - - - -# Class Methods -## list() [](#method-c-list) -Returns a list of signal names mapped to the corresponding underlying signal -numbers. - - Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29} -**@overload** [] - -## signame(signo ) [](#method-c-signame) -Convert signal number to signal name. - Returns +nil+ if the signo is an invalid signal number. - - Signal.trap("INT") { |signo| puts Signal.signame(signo) } - Process.kill("INT", 0) - - produces: - - INT -**@overload** [] - -## trap(*args ) [](#method-c-trap) -Specifies the handling of signals. The first parameter is a signal name (a -string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The -characters ``SIG'' may be omitted from the signal name. The command or block -specifies code to be run when the signal is raised. If the command is the -string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command -is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If -the command is ``EXIT'', the script will be terminated by the signal. If the -command is ``SYSTEM_DEFAULT'', the operating system's default handler will be -invoked. Otherwise, the given command or block will be run. The special signal -name ``EXIT'' or signal number zero will be invoked just prior to program -termination. trap returns the previous handler for the given signal. - - Signal.trap(0, proc { puts "Terminating: #{$$}" }) - Signal.trap("CLD") { puts "Child died" } - fork && Process.wait - -*produces:* - Terminating: 27461 - Child died - Terminating: 27460 -**@overload** [] - -**@overload** [] - - diff --git a/example/ruby/SignalException.md b/example/ruby/SignalException.md deleted file mode 100644 index 9e627a2..0000000 --- a/example/ruby/SignalException.md +++ /dev/null @@ -1,33 +0,0 @@ -# Exception: SignalException -**Inherits:** Exception - - -Raised when a signal is received. - - begin - Process.kill('HUP',Process.pid) - sleep # wait for receiver to handle signal sent by Process.kill - rescue SignalException => e - puts "received Exception #{e}" - end - -*produces:* - - received Exception SIGHUP - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Construct a new SignalException object. `sig_name` should be a known - signal name. - -**@overload** [] - -**@overload** [] - -## signo() [](#method-i-signo) -Returns a signal number. - -**@overload** [] - diff --git a/example/ruby/SignedZeroMatcher.md b/example/ruby/SignedZeroMatcher.md deleted file mode 100644 index d7e4155..0000000 --- a/example/ruby/SignedZeroMatcher.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: SignedZeroMatcher -**Inherits:** Object - - - - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(expected_sign) [](#method-i-initialize) - -**@return** [SignedZeroMatcher] a new instance of SignedZeroMatcher - -## matches?(actual) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/SimpleDelegator.md b/example/ruby/SimpleDelegator.md deleted file mode 100644 index 4927011..0000000 --- a/example/ruby/SimpleDelegator.md +++ /dev/null @@ -1,91 +0,0 @@ -# Class: SimpleDelegator -**Inherits:** Delegator - - -A concrete implementation of Delegator, this class provides the means to -delegate all supported method calls to the object passed into the constructor -and even to change the object being delegated to at a later time with -#__setobj__. - - class User - def born_on - Date.new(1989, 9, 10) - end - end - - require 'delegate' - - class UserDecorator < SimpleDelegator - def birth_year - born_on.year - end - end - - decorated_user = UserDecorator.new(User.new) - decorated_user.birth_year #=> 1989 - decorated_user.__getobj__ #=> # - -A SimpleDelegator instance can take advantage of the fact that SimpleDelegator -is a subclass of `Delegator` to call `super` to have methods called on the -object being delegated to. - - class SuperArray < SimpleDelegator - def [](*args) - super + 1 - end - end - - SuperArray.new([1])[0] #=> 2 - -Here's a simple example that takes advantage of the fact that -SimpleDelegator's delegation object can be changed at any time. - - class Stats - def initialize - @source = SimpleDelegator.new([]) - end - - def stats(records) - @source.__setobj__(records) - - "Elements: #{@source.size}\n" + - " Non-Nil: #{@source.compact.size}\n" + - " Unique: #{@source.uniq.size}\n" - end - end - - s = Stats.new - puts s.stats(%w{James Edward Gray II}) - puts - puts s.stats([1, 2, 3, nil, 4, 5, 1, 2]) - -Prints: - - Elements: 4 - Non-Nil: 4 - Unique: 4 - - Elements: 8 - Non-Nil: 7 - Unique: 6 - - - -#Instance Methods -## __getobj__() [](#method-i-__getobj__) -Returns the current object method calls are being delegated to. - -## __setobj__(obj) [](#method-i-__setobj__) -Changes the delegate object to *obj*. - -It's important to note that this does **not** cause SimpleDelegator's methods -to change. Because of this, you probably only want to change delegation to -objects of the same type as the original delegate. - -Here's an example of changing the delegation object. - - names = SimpleDelegator.new(%w{James Edward Gray II}) - puts names[1] # => Edward - names.__setobj__(%w{Gavin Sinclair}) - puts names[1] # => Sinclair - diff --git a/example/ruby/SimpleHTTPProxyServer.md b/example/ruby/SimpleHTTPProxyServer.md deleted file mode 100644 index 6af3792..0000000 --- a/example/ruby/SimpleHTTPProxyServer.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: SimpleHTTPProxyServer -**Inherits:** Object - - - - - -#Instance Methods -## initialize(host, port, auth_procnil, log, access_log) [](#method-i-initialize) - -**@return** [SimpleHTTPProxyServer] a new instance of SimpleHTTPProxyServer - -## shutdown() [](#method-i-shutdown) - -## start() [](#method-i-start) - diff --git a/example/ruby/SimpleHTTPProxyServer/Request.md b/example/ruby/SimpleHTTPProxyServer/Request.md deleted file mode 100644 index 68fbee9..0000000 --- a/example/ruby/SimpleHTTPProxyServer/Request.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: SimpleHTTPProxyServer::Request -**Inherits:** Object - - - - -# Attributes -## headers[RW] [](#attribute-i-headers) -Returns the value of attribute headers. - -## method[RW] [](#attribute-i-method) -Returns the value of attribute method. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - -## request_line[RW] [](#attribute-i-request_line) -Returns the value of attribute request_line. - - -#Instance Methods -## [](key) [](#method-i-[]) - -## initialize(method, path, request_line, headers) [](#method-i-initialize) - -**@return** [Request] a new instance of Request - diff --git a/example/ruby/SimpleHTTPSServer.md b/example/ruby/SimpleHTTPSServer.md deleted file mode 100644 index 1425304..0000000 --- a/example/ruby/SimpleHTTPSServer.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: SimpleHTTPSServer -**Inherits:** Object - - - - - -#Instance Methods -## handle_request(socket) [](#method-i-handle_request) - -## initialize(cert, key, dh, bind_addr, port, log) [](#method-i-initialize) - -**@return** [SimpleHTTPSServer] a new instance of SimpleHTTPSServer - -## shutdown() [](#method-i-shutdown) - -## start() [](#method-i-start) - diff --git a/example/ruby/SimpleHTTPServer.md b/example/ruby/SimpleHTTPServer.md deleted file mode 100644 index 4cfe554..0000000 --- a/example/ruby/SimpleHTTPServer.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: SimpleHTTPServer -**Inherits:** Object - - - - - -#Instance Methods -## initialize(bind_addr, port, log) [](#method-i-initialize) - -**@return** [SimpleHTTPServer] a new instance of SimpleHTTPServer - -## mount_proc(path, proc) [](#method-i-mount_proc) - -## shutdown() [](#method-i-shutdown) - -## start() [](#method-i-start) - diff --git a/example/ruby/SimpleHTTPServer/Request.md b/example/ruby/SimpleHTTPServer/Request.md deleted file mode 100644 index 427db45..0000000 --- a/example/ruby/SimpleHTTPServer/Request.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: SimpleHTTPServer::Request -**Inherits:** Object - - - - -# Attributes -## headers[RW] [](#attribute-i-headers) -Returns the value of attribute headers. - -## method[RW] [](#attribute-i-method) -Returns the value of attribute method. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - -#Instance Methods -## [](key) [](#method-i-[]) - -## []=(key, value) [](#method-i-[]=) - -## initialize(method, path, headers) [](#method-i-initialize) - -**@return** [Request] a new instance of Request - diff --git a/example/ruby/SimpleHTTPServer/Response.md b/example/ruby/SimpleHTTPServer/Response.md deleted file mode 100644 index e7ef924..0000000 --- a/example/ruby/SimpleHTTPServer/Response.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: SimpleHTTPServer::Response -**Inherits:** Object - - - - -# Attributes -## body[RW] [](#attribute-i-body) -Returns the value of attribute body. - -## chunked[RW] [](#attribute-i-chunked) -Returns the value of attribute chunked. - -## cookies[RW] [](#attribute-i-cookies) -Returns the value of attribute cookies. - -## headers[RW] [](#attribute-i-headers) -Returns the value of attribute headers. - -## status[RW] [](#attribute-i-status) -Returns the value of attribute status. - - -#Instance Methods -## [](key) [](#method-i-[]) - -## []=(key, value) [](#method-i-[]=) - -## finish() [](#method-i-finish) - -## initialize(client) [](#method-i-initialize) - -**@return** [Response] a new instance of Response - -## write_chunk(chunk) [](#method-i-write_chunk) - diff --git a/example/ruby/SimpleRat.md b/example/ruby/SimpleRat.md deleted file mode 100644 index fbe3583..0000000 --- a/example/ruby/SimpleRat.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: SimpleRat -**Inherits:** Numeric - - - - - -#Instance Methods -## *(o) [](#method-i-*) - -## **(o) [](#method-i-**) - -## +(o) [](#method-i-+) - -## +@() [](#method-i-+@) - -## -(o) [](#method-i--) - -## -@() [](#method-i--@) - -## <=>(o) [](#method-i-<=>) - -## ==(o) [](#method-i-==) - -## ceil() [](#method-i-ceil) - -## coerce(o) [](#method-i-coerce) - -## denominator() [](#method-i-denominator) - -## div(o) [](#method-i-div) - -## divmod(o) [](#method-i-divmod) - -## floor() [](#method-i-floor) - -## hash() [](#method-i-hash) - -## initialize(num, den1) [](#method-i-initialize) - -**@return** [SimpleRat] a new instance of SimpleRat - -## inspect() [](#method-i-inspect) - -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(a) [](#method-i-marshal_load) - -## modulo(o) [](#method-i-modulo) - -## numerator() [](#method-i-numerator) - -## quo(o) [](#method-i-quo) - -## quot(o) [](#method-i-quot) - -## quotrem(o) [](#method-i-quotrem) - -## remainder(o) [](#method-i-remainder) - -## round() [](#method-i-round) - -## to_f() [](#method-i-to_f) - -## to_r() [](#method-i-to_r) - -## to_s() [](#method-i-to_s) - -## truncate() [](#method-i-truncate) - diff --git a/example/ruby/SimpleTupleSpace.md b/example/ruby/SimpleTupleSpace.md deleted file mode 100644 index 83da3d3..0000000 --- a/example/ruby/SimpleTupleSpace.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: SimpleTupleSpace -**Inherits:** Object - - -SimpleTupleSpace Copyright (c) 1999-2000 Masatoshi SEKI You can redistribute -it and/or modify it under the same terms as Ruby. - - - -#Instance Methods -## in(key) [](#method-i-in) - -## initialize() [](#method-i-initialize) - -**@return** [SimpleTupleSpace] a new instance of SimpleTupleSpace - -## out(key, obj) [](#method-i-out) - diff --git a/example/ruby/SingleForwardable.md b/example/ruby/SingleForwardable.md deleted file mode 100644 index ad8b70f..0000000 --- a/example/ruby/SingleForwardable.md +++ /dev/null @@ -1,59 +0,0 @@ -# Module: SingleForwardable - - -SingleForwardable can be used to setup delegation at the object level as well. - - printer = String.new - printer.extend SingleForwardable # prepare object for delegation - printer.def_delegator "STDOUT", "puts" # add delegation for STDOUT.puts() - printer.puts "Howdy!" - -Also, SingleForwardable can be used to set up delegation for a Class or -Module. - - class Implementation - def self.service - puts "serviced!" - end - end - - module Facade - extend SingleForwardable - def_delegator :Implementation, :service - end - - Facade.service #=> serviced! - -If you want to use both Forwardable and SingleForwardable, you can use methods -def_instance_delegator and def_single_delegator, etc. - - - -#Instance Methods -## def_single_delegator(accessor, method, alimethod) [](#method-i-def_single_delegator) -:call-seq: - def_single_delegator(accessor, method, new_name=method) - -Defines a method *method* which delegates to *accessor* (i.e. it calls the -method of the same name in *accessor*). If *new_name* is provided, it is used -as the name for the delegate method. Returns the name of the method defined. - -## def_single_delegators(accessor, *methods) [](#method-i-def_single_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map - -## single_delegate(hash) [](#method-i-single_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names. The value is the accessor to which -the methods will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor - diff --git a/example/ruby/Singleton.md b/example/ruby/Singleton.md deleted file mode 100644 index 9ffd78f..0000000 --- a/example/ruby/Singleton.md +++ /dev/null @@ -1,117 +0,0 @@ -# Module: Singleton - -**Extended by:** Singleton::SingletonClassProperties - -**Includes:** Singleton::SingletonInstanceMethods - - -The Singleton module implements the Singleton pattern. - -## Usage - -To use Singleton, include the module in your class. - - class Klass - include Singleton - # ... - end - -This ensures that only one instance of Klass can be created. - - a,b = Klass.instance, Klass.instance - - a == b - # => true - - Klass.new - # => NoMethodError - new is private ... - -The instance is created at upon the first call of Klass.instance(). - - class OtherKlass - include Singleton - # ... - end - - ObjectSpace.each_object(OtherKlass){} - # => 0 - - OtherKlass.instance - ObjectSpace.each_object(OtherKlass){} - # => 1 - -This behavior is preserved under inheritance and cloning. - -## Implementation - -This above is achieved by: - -* Making Klass.new and Klass.allocate private. - -* Overriding Klass.inherited(sub_klass) and Klass.clone() to ensure that the - Singleton properties are kept when inherited and cloned. - -* Providing the Klass.instance() method that returns the same object each - time it is called. - -* Overriding Klass._load(str) to call Klass.instance(). - -* Overriding Klass#clone and Klass#dup to raise TypeErrors to prevent - cloning or duping. - -## Singleton and Marshal - -By default Singleton's #_dump(depth) returns the empty string. Marshalling by -default will strip state information, e.g. instance variables from the -instance. Classes using Singleton can provide custom _load(str) and -_dump(depth) methods to retain some of the previous state of the instance. - - require 'singleton' - - class Example - include Singleton - attr_accessor :keep, :strip - def _dump(depth) - # this strips the @strip information from the instance - Marshal.dump(@keep, depth) - end - - def self._load(str) - instance.keep = Marshal.load(str) - instance - end - end - - a = Example.instance - a.keep = "keep this" - a.strip = "get rid of this" - - stored_state = Marshal.dump(a) - - a.keep = nil - a.strip = nil - b = Marshal.load(stored_state) - p a == b # => true - p a.keep # => "keep this" - p a.strip # => nil - - -# Class Methods -## __init__(klass ) [](#method-c-__init__) -:nodoc: -## module_with_class_methods() [](#method-c-module_with_class_methods) - -#Instance Methods -## _dump(depth-1)) [](#method-i-_dump) -By default, do not retain any state when marshalling. - -## clone() [](#method-i-clone) -Raises a TypeError to prevent cloning. - -**@raise** [TypeError] - -## dup() [](#method-i-dup) -Raises a TypeError to prevent duping. - -**@raise** [TypeError] - diff --git a/example/ruby/Singleton/SingletonClassMethods.md b/example/ruby/Singleton/SingletonClassMethods.md deleted file mode 100644 index c16a9d9..0000000 --- a/example/ruby/Singleton/SingletonClassMethods.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: Singleton::SingletonClassMethods - - -:nodoc: - - - -#Instance Methods -## _load(str) [](#method-i-_load) -By default calls instance(). Override to retain singleton state. - -## clone() [](#method-i-clone) -:nodoc: - -## instance() [](#method-i-instance) -:nodoc: - diff --git a/example/ruby/Singleton/SingletonClassProperties.md b/example/ruby/Singleton/SingletonClassProperties.md deleted file mode 100644 index 2f9b978..0000000 --- a/example/ruby/Singleton/SingletonClassProperties.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: Singleton::SingletonClassProperties - - - - -# Class Methods -## extended(c ) [](#method-c-extended) -**@private** [] - -## included(c ) [](#method-c-included) -**@private** [] - - -#Instance Methods -## __init__(klass) [](#method-i-__init__) -:nodoc: - diff --git a/example/ruby/Singleton/SingletonInstanceMethods.md b/example/ruby/Singleton/SingletonInstanceMethods.md deleted file mode 100644 index 541ca7d..0000000 --- a/example/ruby/Singleton/SingletonInstanceMethods.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: Singleton::SingletonInstanceMethods - - - - - -#Instance Methods -## _dump(depth-1)) [](#method-i-_dump) -By default, do not retain any state when marshalling. - -## clone() [](#method-i-clone) -Raises a TypeError to prevent cloning. - -**@raise** [TypeError] - -## dup() [](#method-i-dup) -Raises a TypeError to prevent duping. - -**@raise** [TypeError] - diff --git a/example/ruby/SingletonMethodsSpecs.md b/example/ruby/SingletonMethodsSpecs.md deleted file mode 100644 index d23f643..0000000 --- a/example/ruby/SingletonMethodsSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SingletonMethodsSpecs - - - - - diff --git a/example/ruby/SingletonMethodsSpecs/Prepended.md b/example/ruby/SingletonMethodsSpecs/Prepended.md deleted file mode 100644 index 435b15e..0000000 --- a/example/ruby/SingletonMethodsSpecs/Prepended.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: SingletonMethodsSpecs::Prepended - - - - - -#Instance Methods -## mspec_test_kernel_singleton_methods() [](#method-i-mspec_test_kernel_singleton_methods) - diff --git a/example/ruby/SingletonMethodsSpecs/SelfExtending.md b/example/ruby/SingletonMethodsSpecs/SelfExtending.md deleted file mode 100644 index 5cbe83c..0000000 --- a/example/ruby/SingletonMethodsSpecs/SelfExtending.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: SingletonMethodsSpecs::SelfExtending - -**Extended by:** SingletonMethodsSpecs::SelfExtending - - - - - diff --git a/example/ruby/SingletonSpecs.md b/example/ruby/SingletonSpecs.md deleted file mode 100644 index 57d6208..0000000 --- a/example/ruby/SingletonSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SingletonSpecs - - - - - diff --git a/example/ruby/SingletonSpecs/MyClass.md b/example/ruby/SingletonSpecs/MyClass.md deleted file mode 100644 index bfc56ef..0000000 --- a/example/ruby/SingletonSpecs/MyClass.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: SingletonSpecs::MyClass -**Inherits:** Object - -**Includes:** Singleton - - - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## _dump(depth-1)) [](#method-i-_dump) -By default, do not retain any state when marshalling. - -## clone() [](#method-i-clone) -Raises a TypeError to prevent cloning. - -**@raise** [TypeError] - -## dup() [](#method-i-dup) -Raises a TypeError to prevent duping. - -**@raise** [TypeError] - diff --git a/example/ruby/SingletonSpecs/MyClassChild.md b/example/ruby/SingletonSpecs/MyClassChild.md deleted file mode 100644 index 60a4679..0000000 --- a/example/ruby/SingletonSpecs/MyClassChild.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SingletonSpecs::MyClassChild -**Inherits:** SingletonSpecs::MyClass - - - - - diff --git a/example/ruby/SingletonSpecs/NewSpec.md b/example/ruby/SingletonSpecs/NewSpec.md deleted file mode 100644 index 9c00a10..0000000 --- a/example/ruby/SingletonSpecs/NewSpec.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: SingletonSpecs::NewSpec -**Inherits:** Object - -**Includes:** Singleton - - - - - -#Instance Methods -## _dump(depth-1)) [](#method-i-_dump) -By default, do not retain any state when marshalling. - -## clone() [](#method-i-clone) -Raises a TypeError to prevent cloning. - -**@raise** [TypeError] - -## dup() [](#method-i-dup) -Raises a TypeError to prevent duping. - -**@raise** [TypeError] - diff --git a/example/ruby/SingletonSpecs/NotInstantiated.md b/example/ruby/SingletonSpecs/NotInstantiated.md deleted file mode 100644 index 641f3e6..0000000 --- a/example/ruby/SingletonSpecs/NotInstantiated.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SingletonSpecs::NotInstantiated -**Inherits:** SingletonSpecs::MyClass - - - - - diff --git a/example/ruby/SkippedSpecError.md b/example/ruby/SkippedSpecError.md deleted file mode 100644 index 2be95a7..0000000 --- a/example/ruby/SkippedSpecError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: SkippedSpecError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/SleepingBlockingScheduler.md b/example/ruby/SleepingBlockingScheduler.md deleted file mode 100644 index 3ddcfb7..0000000 --- a/example/ruby/SleepingBlockingScheduler.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SleepingBlockingScheduler -**Inherits:** Scheduler - - -This scheduler has a broken implementation of `kernel_sleep` in the sense that -it invokes a blocking sleep which can cause a deadlock in some cases. - - - -#Instance Methods -## kernel_sleep(durationnil) [](#method-i-kernel_sleep) - diff --git a/example/ruby/SleepingUnblockScheduler.md b/example/ruby/SleepingUnblockScheduler.md deleted file mode 100644 index 1e48751..0000000 --- a/example/ruby/SleepingUnblockScheduler.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SleepingUnblockScheduler -**Inherits:** Scheduler - - -This scheduler has a broken implementation of `unblock` in the sense that it -sleeps. This is used to test the behavior of the scheduler when unblock messes -with the internal thread state in an unexpected way. - - - -#Instance Methods -## unblock(blocker, fiber) [](#method-i-unblock) -This method is invoked when the thread is exiting. - diff --git a/example/ruby/Socket.md b/example/ruby/Socket.md deleted file mode 100644 index 8a7696a..0000000 --- a/example/ruby/Socket.md +++ /dev/null @@ -1,1326 +0,0 @@ -# Class: Socket -**Inherits:** BasicSocket - - -Class `Socket` provides access to the underlying operating system socket -implementations. It can be used to provide more operating system specific -functionality than the protocol-specific socket classes. - -The constants defined under Socket::Constants are also defined under Socket. -For example, Socket::AF_INET is usable as well as Socket::Constants::AF_INET. -See Socket::Constants for the list of constants. - -### What's a socket? - -Sockets are endpoints of a bidirectional communication channel. Sockets can -communicate within a process, between processes on the same machine or between -different machines. There are many types of socket: TCPSocket, UDPSocket or -UNIXSocket for example. - -Sockets have their own vocabulary: - -**domain:** The family of protocols: -* Socket::PF_INET -* Socket::PF_INET6 -* Socket::PF_UNIX -* etc. - -**type:** The type of communications between the two endpoints, typically -* Socket::SOCK_STREAM -* Socket::SOCK_DGRAM. - -**protocol:** Typically *zero*. This may be used to identify a variant of a -protocol. - -**hostname:** The identifier of a network interface: -* a string (hostname, IPv4 or IPv6 address or `broadcast` - which specifies a broadcast address) - -* a zero-length string which specifies INADDR_ANY -* an integer (interpreted as binary address in host byte order). - -### Quick start - -Many of the classes, such as TCPSocket, UDPSocket or UNIXSocket, ease the use -of sockets comparatively to the equivalent C programming interface. - -Let's create an internet socket using the IPv4 protocol in a C-like manner: - - require 'socket' - - s = Socket.new Socket::AF_INET, Socket::SOCK_STREAM - s.connect Socket.pack_sockaddr_in(80, 'example.com') - -You could also use the TCPSocket class: - - s = TCPSocket.new 'example.com', 80 - -A simple server might look like this: - - require 'socket' - - server = TCPServer.new 2000 # Server bound to port 2000 - - loop do - client = server.accept # Wait for a client to connect - client.puts "Hello !" - client.puts "Time is #{Time.now}" - client.close - end - -A simple client may look like this: - - require 'socket' - - s = TCPSocket.new 'localhost', 2000 - - while line = s.gets # Read lines from socket - puts line # and print them - end - - s.close # close socket when done - -### Exception Handling - -Ruby's Socket implementation raises exceptions based on the error generated by -the system dependent implementation. This is why the methods are documented -in a way that isolate Unix-based system exceptions from Windows based -exceptions. If more information on a particular exception is needed, please -refer to the Unix manual pages or the Windows WinSock reference. - -### Convenience methods - -Although the general way to create socket is Socket.new, there are several -methods of socket creation for most cases. - -TCP client socket -: Socket.tcp, TCPSocket.open - -TCP server socket -: Socket.tcp_server_loop, TCPServer.open - -UNIX client socket -: Socket.unix, UNIXSocket.open - -UNIX server socket -: Socket.unix_server_loop, UNIXServer.open - - -### Documentation by - -* Zach Dennis -* Sam Roberts -* *Programming Ruby* from The Pragmatic Bookshelf. - -Much material in this documentation is taken with permission from *Programming -Ruby* from The Pragmatic Bookshelf. - - -# Class Methods -## accept_loop(*sockets ) [](#method-c-accept_loop) -yield socket and client address for each a connection accepted via given -sockets. - -The arguments are a list of sockets. The individual argument should be a -socket or an array of sockets. - -This method yields the block sequentially. It means that the next connection -is not accepted until the block returns. So concurrent mechanism, thread for -example, should be used to service multiple clients at a time. -## getaddrinfo(*args ) [](#method-c-getaddrinfo) -Obtains address information for *nodename*:*servname*. - -Note that Addrinfo.getaddrinfo provides the same functionality in an object -oriented style. - -*family* should be an address family such as: :INET, :INET6, etc. - -*socktype* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. - -*protocol* should be a protocol defined in the family, and defaults to 0 for -the family. - -*flags* should be bitwise OR of Socket::AI_* constants. - - Socket.getaddrinfo("www.ruby-lang.org", "http", nil, :STREAM) - #=> [["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68", 2, 1, 6]] # PF_INET/SOCK_STREAM/IPPROTO_TCP - - Socket.getaddrinfo("localhost", nil) - #=> [["AF_INET", 0, "localhost", "127.0.0.1", 2, 1, 6], # PF_INET/SOCK_STREAM/IPPROTO_TCP - # ["AF_INET", 0, "localhost", "127.0.0.1", 2, 2, 17], # PF_INET/SOCK_DGRAM/IPPROTO_UDP - # ["AF_INET", 0, "localhost", "127.0.0.1", 2, 3, 0]] # PF_INET/SOCK_RAW/IPPROTO_IP - -*reverse_lookup* directs the form of the third element, and has to be one of -below. If *reverse_lookup* is omitted, the default value is `nil`. - - +true+, +:hostname+: hostname is obtained from numeric address using reverse lookup, which may take a time. - +false+, +:numeric+: hostname is the same as numeric address. - +nil+: obey to the current +do_not_reverse_lookup+ flag. - -If Addrinfo object is preferred, use Addrinfo.getaddrinfo. -**@overload** [] - -## gethostbyaddr(*args ) [](#method-c-gethostbyaddr) -Use Addrinfo#getnameinfo instead. This method is deprecated for the following -reasons: - -* Uncommon address representation: 4/16-bytes binary string to represent - IPv4/IPv6 address. -* gethostbyaddr() may take a long time and it may block other threads. (GVL - cannot be released since gethostbyname() is not thread safe.) -* This method uses gethostbyname() function already removed from POSIX. - -This method obtains the host information for *address*. - - p Socket.gethostbyaddr([221,186,184,68].pack("CCCC")) - #=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"] - - p Socket.gethostbyaddr([127,0,0,1].pack("CCCC")) - ["localhost", [], 2, "\x7F\x00\x00\x01"] - p Socket.gethostbyaddr(([0]*15+[1]).pack("C"*16)) - #=> ["localhost", ["ip6-localhost", "ip6-loopback"], 10, - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"] -**@overload** [] - -## gethostbyname(host ) [](#method-c-gethostbyname) -Use Addrinfo.getaddrinfo instead. This method is deprecated for the following -reasons: - -* The 3rd element of the result is the address family of the first address. - The address families of the rest of the addresses are not returned. -* Uncommon address representation: 4/16-bytes binary string to represent - IPv4/IPv6 address. -* gethostbyname() may take a long time and it may block other threads. (GVL - cannot be released since gethostbyname() is not thread safe.) -* This method uses gethostbyname() function already removed from POSIX. - -This method obtains the host information for *hostname*. - - p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"] -**@overload** [] - -## gethostname() [](#method-c-gethostname) -## getifaddrs() [](#method-c-getifaddrs) -Returns an array of interface addresses. An element of the array is an -instance of Socket::Ifaddr. - -This method can be used to find multicast-enabled interfaces: - - pp Socket.getifaddrs.reject {|ifaddr| - !ifaddr.addr.ip? || (ifaddr.flags & Socket::IFF_MULTICAST == 0) - }.map {|ifaddr| [ifaddr.name, ifaddr.ifindex, ifaddr.addr] } - #=> [["eth0", 2, #], - # ["eth0", 2, #]] - -Example result on GNU/Linux: - pp Socket.getifaddrs - #=> [#, - # #, - # #, - # #, - # #, - # #, - # #] - -Example result on FreeBSD: - pp Socket.getifaddrs - #=> [#, - # #, - # #, - # #, - # #, - # #, - # #, - # #, - # #, - # #] -**@overload** [] - -## getnameinfo(*args ) [](#method-c-getnameinfo) -Obtains name information for *sockaddr*. - -*sockaddr* should be one of follows. -* packed sockaddr string such as Socket.sockaddr_in(80, "127.0.0.1") -* 3-elements array such as ["AF_INET", 80, "127.0.0.1"] -* 4-elements array such as ["AF_INET", 80, ignored, "127.0.0.1"] - -*flags* should be bitwise OR of Socket::NI_* constants. - -Note: The last form is compatible with IPSocket#addr and IPSocket#peeraddr. - - Socket.getnameinfo(Socket.sockaddr_in(80, "127.0.0.1")) #=> ["localhost", "www"] - Socket.getnameinfo(["AF_INET", 80, "127.0.0.1"]) #=> ["localhost", "www"] - Socket.getnameinfo(["AF_INET", 80, "localhost", "127.0.0.1"]) #=> ["localhost", "www"] - -If Addrinfo object is preferred, use Addrinfo#getnameinfo. -**@overload** [] - -## getservbyname(*args ) [](#method-c-getservbyname) -Obtains the port number for *service_name*. - -If *protocol_name* is not given, "tcp" is assumed. - - Socket.getservbyname("smtp") #=> 25 - Socket.getservbyname("shell") #=> 514 - Socket.getservbyname("syslog", "udp") #=> 514 -**@overload** [] - -**@overload** [] - -## getservbyport(*args ) [](#method-c-getservbyport) -Obtains the port number for *port*. - -If *protocol_name* is not given, "tcp" is assumed. - - Socket.getservbyport(80) #=> "www" - Socket.getservbyport(514, "tcp") #=> "shell" - Socket.getservbyport(514, "udp") #=> "syslog" -**@overload** [] - -## ip_address_list() [](#method-c-ip_address_list) -Returns local IP addresses as an array. - -The array contains Addrinfo objects. - - pp Socket.ip_address_list - #=> [#, - #, - #, - ...] -**@overload** [] - -## ip_sockets_port0(ai_list , reuseaddr ) [](#method-c-ip_sockets_port0) -:stopdoc: -## pack_sockaddr_in(port , host ) [](#method-c-pack_sockaddr_in) -Packs *port* and *host* as an AF_INET/AF_INET6 sockaddr string. - - Socket.sockaddr_in(80, "127.0.0.1") - #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" - - Socket.sockaddr_in(80, "::1") - #=> "\n\x00\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00" -**@overload** [] - -**@overload** [] - -## pack_sockaddr_un(path ) [](#method-c-pack_sockaddr_un) -Packs *path* as an AF_UNIX sockaddr string. - - Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..." -**@overload** [] - -**@overload** [] - -## pair(*args ) [](#method-c-pair) -Creates a pair of sockets connected each other. - -*domain* should be a communications domain such as: :INET, :INET6, :UNIX, etc. - -*socktype* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. - -*protocol* should be a protocol defined in the domain, defaults to 0 for the -domain. - - s1, s2 = Socket.pair(:UNIX, :STREAM, 0) - s1.send "a", 0 - s1.send "b", 0 - s1.close - p s2.recv(10) #=> "ab" - p s2.recv(10) #=> "" - p s2.recv(10) #=> "" - - s1, s2 = Socket.pair(:UNIX, :DGRAM, 0) - s1.send "a", 0 - s1.send "b", 0 - p s2.recv(10) #=> "a" - p s2.recv(10) #=> "b" -**@overload** [] - -**@overload** [] - -## sockaddr_in(port , host ) [](#method-c-sockaddr_in) -Packs *port* and *host* as an AF_INET/AF_INET6 sockaddr string. - - Socket.sockaddr_in(80, "127.0.0.1") - #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" - - Socket.sockaddr_in(80, "::1") - #=> "\n\x00\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00" -**@overload** [] - -**@overload** [] - -## sockaddr_un(path ) [](#method-c-sockaddr_un) -Packs *path* as an AF_UNIX sockaddr string. - - Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..." -**@overload** [] - -**@overload** [] - -## socketpair(*args ) [](#method-c-socketpair) -Creates a pair of sockets connected each other. - -*domain* should be a communications domain such as: :INET, :INET6, :UNIX, etc. - -*socktype* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. - -*protocol* should be a protocol defined in the domain, defaults to 0 for the -domain. - - s1, s2 = Socket.pair(:UNIX, :STREAM, 0) - s1.send "a", 0 - s1.send "b", 0 - s1.close - p s2.recv(10) #=> "ab" - p s2.recv(10) #=> "" - p s2.recv(10) #=> "" - - s1, s2 = Socket.pair(:UNIX, :DGRAM, 0) - s1.send "a", 0 - s1.send "b", 0 - p s2.recv(10) #=> "a" - p s2.recv(10) #=> "b" -**@overload** [] - -**@overload** [] - -## tcp(host , port , local_host nil, local_port nil, connect_timeout: nil, resolv_timeout: nil, fast_fallback: tcp_fast_fallback) [](#method-c-tcp) -:call-seq: - Socket.tcp(host, port, local_host=nil, local_port=nil, [opts]) {|socket| ... } - Socket.tcp(host, port, local_host=nil, local_port=nil, [opts]) - -creates a new socket object connected to host:port using TCP/IP. - -Starting from Ruby 3.4, this method operates according to the Happy Eyeballs -Version 2 ([RFC 8305](https://datatracker.ietf.org/doc/html/rfc8305)) -algorithm by default. - -For details on Happy Eyeballs Version 2, see -[Socket.tcp_fast_fallback=](rdoc-ref:Socket.tcp_fast_fallback=). - -To make it behave the same as in Ruby 3.3 and earlier, explicitly specify the -option fast_fallback:false. Or, setting Socket.tcp_fast_fallback=false will -disable Happy Eyeballs Version 2 not only for this method but for all Socket -globally. - -If local_host:local_port is given, the socket is bound to it. - -The optional last argument *opts* is options represented by a hash. *opts* may -have following options: - -:resolv_timeout -: Specifies the timeout in seconds from when the hostname resolution starts. - -:connect_timeout -: This method sequentially attempts connecting to all candidate destination - addresses. - The `connect_timeout` specifies the timeout in seconds from the start of - the connection attempt to the last candidate. - By default, all connection attempts continue until the timeout occurs. - When `fast_fallback:false` is explicitly specified, - a timeout is set for each connection attempt and any connection attempt - that exceeds its timeout will be canceled. - -:fast_fallback -: Enables the Happy Eyeballs Version 2 algorithm (enabled by default). - - -If a block is given, the block is called with the socket. The value of the -block is returned. The socket is closed when this method returns. - -If no block is given, the socket is returned. - - Socket.tcp("www.ruby-lang.org", 80) {|sock| - sock.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n" - sock.close_write - puts sock.read - } -## tcp_fast_fallback() [](#method-c-tcp_fast_fallback) -Returns whether Happy Eyeballs Version 2 ([RFC -8305](https://datatracker.ietf.org/doc/html/rfc8305)), which is provided -starting from Ruby 3.4 when using TCPSocket.new and Socket.tcp, is enabled or -disabled. - -If true, it is enabled for TCPSocket.new and Socket.tcp. (Note: Happy Eyeballs -Version 2 is not provided when using TCPSocket.new on Windows.) - -If false, Happy Eyeballs Version 2 is disabled. - -For details on Happy Eyeballs Version 2, see -[Socket.tcp_fast_fallback=](rdoc-ref:Socket.tcp_fast_fallback=). -**@overload** [] - -## tcp_fast_fallback=(value ) [](#method-c-tcp_fast_fallback=) -Enable or disable Happy Eyeballs Version 2 ([RFC -8305](https://datatracker.ietf.org/doc/html/rfc8305)) globally, which is -provided starting from Ruby 3.4 when using TCPSocket.new and Socket.tcp. - -When set to true, the feature is enabled for both `TCPSocket.new` and -`Socket.tcp`. (Note: This feature is not available when using TCPSocket.new on -Windows.) - -When set to false, the behavior reverts to that of Ruby 3.3 or earlier. - -The default value is true if no value is explicitly set by calling this -method. However, when the environment variable RUBY_TCP_NO_FAST_FALLBACK=1 is -set, the default is false. - -To control the setting on a per-method basis, use the fast_fallback keyword -argument for each method. - -### Happy Eyeballs Version 2 -Happy Eyeballs Version 2 ([RFC -8305](https://datatracker.ietf.org/doc/html/rfc8305)) is an algorithm designed -to improve client socket connectivity. - It aims for more reliable and efficient connections by performing hostname -resolution and connection attempts in parallel, instead of serially. - -Starting from Ruby 3.4, this method operates as follows with this algorithm: - -1. Start resolving both IPv6 and IPv4 addresses concurrently. -2. Start connecting to the one of the addresses that are obtained first. - If IPv4 addresses are obtained first, the method waits 50 ms for IPv6 name - resolution to prioritize IPv6 connections. -3. After starting a connection attempt, wait 250 ms for the connection to be - established. - If no connection is established within this time, a new connection is - started every 250 ms - until a connection is established or there are no more candidate - addresses. - (Although RFC 8305 strictly specifies sorting addresses, - this method only alternates between IPv6 / IPv4 addresses due to the - performance concerns) -4. Once a connection is established, all remaining connection attempts are - canceled. -**@overload** [] - -## tcp_server_loop(host nil, port , &b ) [](#method-c-tcp_server_loop) -creates a TCP/IP server on *port* and calls the block for each connection -accepted. The block is called with a socket and a client_address as an -Addrinfo object. - -If *host* is specified, it is used with *port* to determine the server -addresses. - -The socket is **not** closed when the block returns. So application should -close it explicitly. - -This method calls the block sequentially. It means that the next connection is -not accepted until the block returns. So concurrent mechanism, thread for -example, should be used to service multiple clients at a time. - -Note that Addrinfo.getaddrinfo is used to determine the server socket -addresses. When Addrinfo.getaddrinfo returns two or more addresses, IPv4 and -IPv6 address for example, all of them are used. Socket.tcp_server_loop -succeeds if one socket can be used at least. - - # Sequential echo server. - # It services only one client at a time. - Socket.tcp_server_loop(16807) {|sock, client_addrinfo| - begin - IO.copy_stream(sock, sock) - ensure - sock.close - end - } - - # Threaded echo server - # It services multiple clients at a time. - # Note that it may accept connections too much. - Socket.tcp_server_loop(16807) {|sock, client_addrinfo| - Thread.new { - begin - IO.copy_stream(sock, sock) - ensure - sock.close - end - } - } -## tcp_server_sockets(host nil, port ) [](#method-c-tcp_server_sockets) -creates TCP/IP server sockets for *host* and *port*. *host* is optional. - -If no block given, it returns an array of listening sockets. - -If a block is given, the block is called with the sockets. The value of the -block is returned. The socket is closed when this method returns. - -If *port* is 0, actual port number is chosen dynamically. However all sockets -in the result has same port number. - - # tcp_server_sockets returns two sockets. - sockets = Socket.tcp_server_sockets(1296) - p sockets #=> [#, #] - - # The sockets contains IPv6 and IPv4 sockets. - sockets.each {|s| p s.local_address } - #=> # - # # - - # IPv6 and IPv4 socket has same port number, 53114, even if it is chosen dynamically. - sockets = Socket.tcp_server_sockets(0) - sockets.each {|s| p s.local_address } - #=> # - # # - - # The block is called with the sockets. - Socket.tcp_server_sockets(0) {|sockets| - p sockets #=> [#, #] - } -## tcp_server_sockets_port0(host ) [](#method-c-tcp_server_sockets_port0) -## tcp_with_fast_fallback(host , port , local_host nil, local_port nil, connect_timeout: nil, resolv_timeout: nil) [](#method-c-tcp_with_fast_fallback) -## udp_server_loop(host nil, port , &b ) [](#method-c-udp_server_loop) -:call-seq: - Socket.udp_server_loop(port) {|msg, msg_src| ... } - Socket.udp_server_loop(host, port) {|msg, msg_src| ... } - -creates a UDP/IP server on *port* and calls the block for each message -arrived. The block is called with the message and its source information. - -This method allocates sockets internally using *port*. If *host* is specified, -it is used conjunction with *port* to determine the server addresses. - -The *msg* is a string. - -The *msg_src* is a Socket::UDPSource object. It is used for reply. - - # UDP/IP echo server. - Socket.udp_server_loop(9261) {|msg, msg_src| - msg_src.reply msg - } -## udp_server_loop_on(sockets , &b ) [](#method-c-udp_server_loop_on) -:call-seq: - Socket.udp_server_loop_on(sockets) {|msg, msg_src| ... } - -Run UDP/IP server loop on the given sockets. - -The return value of Socket.udp_server_sockets is appropriate for the argument. - -It calls the block for each message received. -## udp_server_recv(sockets ) [](#method-c-udp_server_recv) -:call-seq: - Socket.udp_server_recv(sockets) {|msg, msg_src| ... } - -Receive UDP/IP packets from the given *sockets*. For each packet received, the -block is called. - -The block receives *msg* and *msg_src*. *msg* is a string which is the payload -of the received packet. *msg_src* is a Socket::UDPSource object which is used -for reply. - -Socket.udp_server_loop can be implemented using this method as follows. - - udp_server_sockets(host, port) {|sockets| - loop { - readable, _, _ = IO.select(sockets) - udp_server_recv(readable) {|msg, msg_src| ... } - } - } -## udp_server_sockets(host nil, port ) [](#method-c-udp_server_sockets) -:call-seq: - Socket.udp_server_sockets([host, ] port) - -Creates UDP/IP sockets for a UDP server. - -If no block given, it returns an array of sockets. - -If a block is given, the block is called with the sockets. The value of the -block is returned. The sockets are closed when this method returns. - -If *port* is zero, some port is chosen. But the chosen port is used for the -all sockets. - - # UDP/IP echo server - Socket.udp_server_sockets(0) {|sockets| - p sockets.first.local_address.ip_port #=> 32963 - Socket.udp_server_loop_on(sockets) {|msg, msg_src| - msg_src.reply msg - } - } -## unix(path ) [](#method-c-unix) -creates a new socket connected to path using UNIX socket socket. - -If a block is given, the block is called with the socket. The value of the -block is returned. The socket is closed when this method returns. - -If no block is given, the socket is returned. - - # talk to /tmp/sock socket. - Socket.unix("/tmp/sock") {|sock| - t = Thread.new { IO.copy_stream(sock, STDOUT) } - IO.copy_stream(STDIN, sock) - t.join - } -## unix_server_loop(path , &b ) [](#method-c-unix_server_loop) -creates a UNIX socket server on *path*. It calls the block for each socket -accepted. - -If *host* is specified, it is used with *port* to determine the server ports. - -The socket is **not** closed when the block returns. So application should -close it. - -This method deletes the socket file pointed by *path* at first if the file is -a socket file and it is owned by the user of the application. This is safe -only if the directory of *path* is not changed by a malicious user. So don't -use /tmp/malicious-users-directory/socket. Note that /tmp/socket and -/tmp/your-private-directory/socket is safe assuming that /tmp has sticky bit. - - # Sequential echo server. - # It services only one client at a time. - Socket.unix_server_loop("/tmp/sock") {|sock, client_addrinfo| - begin - IO.copy_stream(sock, sock) - ensure - sock.close - end - } -## unix_server_socket(path ) [](#method-c-unix_server_socket) -creates a UNIX server socket on *path* - -If no block given, it returns a listening socket. - -If a block is given, it is called with the socket and the block value is -returned. When the block exits, the socket is closed and the socket file is -removed. - - socket = Socket.unix_server_socket("/tmp/s") - p socket #=> # - p socket.local_address #=> # - - Socket.unix_server_socket("/tmp/sock") {|s| - p s #=> # - p s.local_address #=> # # - } -## unpack_sockaddr_in(addr ) [](#method-c-unpack_sockaddr_in) -Unpacks *sockaddr* into port and ip_address. - -*sockaddr* should be a string or an addrinfo for AF_INET/AF_INET6. - - sockaddr = Socket.sockaddr_in(80, "127.0.0.1") - p sockaddr #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" - p Socket.unpack_sockaddr_in(sockaddr) #=> [80, "127.0.0.1"] -**@overload** [] - -## unpack_sockaddr_un(addr ) [](#method-c-unpack_sockaddr_un) -Unpacks *sockaddr* into path. - -*sockaddr* should be a string or an addrinfo for AF_UNIX. - - sockaddr = Socket.sockaddr_un("/tmp/sock") - p Socket.unpack_sockaddr_un(sockaddr) #=> "/tmp/sock" -**@overload** [] - - -#Instance Methods -## accept() [](#method-i-accept) -Accepts a next connection. Returns a new Socket object and Addrinfo object. - - serv = Socket.new(:INET, :STREAM, 0) - serv.listen(5) - c = Socket.new(:INET, :STREAM, 0) - c.connect(serv.connect_address) - p serv.accept #=> [#, #] - -**@overload** [] - -## accept_nonblock(exception:true) [](#method-i-accept_nonblock) -call-seq: - socket.accept_nonblock([options]) => [client_socket, client_addrinfo] - -Accepts an incoming connection using accept(2) after O_NONBLOCK is set for the -underlying file descriptor. It returns an array containing the accepted socket -for the incoming connection, *client_socket*, and an Addrinfo, -*client_addrinfo*. - -### Example - # In one script, start this first - require 'socket' - include Socket::Constants - socket = Socket.new(AF_INET, SOCK_STREAM, 0) - sockaddr = Socket.sockaddr_in(2200, 'localhost') - socket.bind(sockaddr) - socket.listen(5) - begin # emulate blocking accept - client_socket, client_addrinfo = socket.accept_nonblock - rescue IO::WaitReadable, Errno::EINTR - IO.select([socket]) - retry - end - puts "The client said, '#{client_socket.readline.chomp}'" - client_socket.puts "Hello from script one!" - socket.close - - # In another script, start this second - require 'socket' - include Socket::Constants - socket = Socket.new(AF_INET, SOCK_STREAM, 0) - sockaddr = Socket.sockaddr_in(2200, 'localhost') - socket.connect(sockaddr) - socket.puts "Hello from script 2." - puts "The server said, '#{socket.readline.chomp}'" - socket.close - -Refer to Socket#accept for the exceptions that may be thrown if the call to -*accept_nonblock* fails. - -Socket#accept_nonblock may raise any error corresponding to accept(2) failure, -including Errno::EWOULDBLOCK. - -If the exception is Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::ECONNABORTED or -Errno::EPROTO, it is extended by IO::WaitReadable. So IO::WaitReadable can be -used to rescue the exceptions for retrying accept_nonblock. - -By specifying a keyword argument *exception* to `false`, you can indicate that -accept_nonblock should not raise an IO::WaitReadable exception, but return the -symbol `:wait_readable` instead. - -### See -* Socket#accept - -## bind(addr) [](#method-i-bind) -Binds to the given local address. - -### Parameter -* `local_sockaddr` - the `struct` sockaddr contained in a string or an - Addrinfo object - -### Example - require 'socket' - - # use Addrinfo - socket = Socket.new(:INET, :STREAM, 0) - socket.bind(Addrinfo.tcp("127.0.0.1", 2222)) - p socket.local_address #=> # - - # use struct sockaddr - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) - socket.bind( sockaddr ) - -### Unix-based Exceptions -On unix-based based systems the following system exceptions may be raised if -the call to *bind* fails: -* Errno::EACCES - the specified *sockaddr* is protected and the current user - does not have permission to bind to it -* Errno::EADDRINUSE - the specified *sockaddr* is already in use -* Errno::EADDRNOTAVAIL - the specified *sockaddr* is not available from the - local machine -* Errno::EAFNOSUPPORT - the specified *sockaddr* is not a valid address for - the family of the calling `socket` -* Errno::EBADF - the *sockaddr* specified is not a valid file descriptor -* Errno::EFAULT - the *sockaddr* argument cannot be accessed -* Errno::EINVAL - the `socket` is already bound to an address, and the - protocol does not support binding to the new *sockaddr* or the `socket` - has been shut down. -* Errno::EINVAL - the address length is not a valid length for the address - family -* Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded - PATH_MAX -* Errno::ENOBUFS - no buffer space is available -* Errno::ENOSR - there were insufficient STREAMS resources available to - complete the operation -* Errno::ENOTSOCK - the `socket` does not refer to a socket -* Errno::EOPNOTSUPP - the socket type of the `socket` does not support - binding to an address - -On unix-based based systems if the address family of the calling `socket` is -Socket::AF_UNIX the follow exceptions may be raised if the call to *bind* -fails: -* Errno::EACCES - search permission is denied for a component of the prefix - path or write access to the `socket` is denied -* Errno::EDESTADDRREQ - the *sockaddr* argument is a null pointer -* Errno::EISDIR - same as Errno::EDESTADDRREQ -* Errno::EIO - an i/o error occurred -* Errno::ELOOP - too many symbolic links were encountered in translating the - pathname in *sockaddr* -* Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX - characters, or an entire pathname exceeded PATH_MAX characters -* Errno::ENOENT - a component of the pathname does not name an existing file - or the pathname is an empty string -* Errno::ENOTDIR - a component of the path prefix of the pathname in - *sockaddr* is not a directory -* Errno::EROFS - the name would reside on a read only filesystem - -### Windows Exceptions -On Windows systems the following system exceptions may be raised if the call -to *bind* fails: -* Errno::ENETDOWN-- the network is down -* Errno::EACCES - the attempt to connect the datagram socket to the - broadcast address failed -* Errno::EADDRINUSE - the socket's local address is already in use -* Errno::EADDRNOTAVAIL - the specified address is not a valid address for - this computer -* Errno::EFAULT - the socket's internal address or address length parameter - is too small or is not a valid part of the user space addressed -* Errno::EINVAL - the `socket` is already bound to an address -* Errno::ENOBUFS - no buffer space is available -* Errno::ENOTSOCK - the `socket` argument does not refer to a socket - -### See -* bind manual pages on unix-based systems -* bind function in Microsoft's Winsock functions reference - -**@overload** [] - -## connect(addr) [](#method-i-connect) -Requests a connection to be made on the given `remote_sockaddr`. Returns 0 if -successful, otherwise an exception is raised. - -### Parameter -* `remote_sockaddr` - the `struct` sockaddr contained in a string or - Addrinfo object - -### Example: - # Pull down Google's web page - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 80, 'www.google.com' ) - socket.connect( sockaddr ) - socket.write( "GET / HTTP/1.0\r\n\r\n" ) - results = socket.read - -### Unix-based Exceptions -On unix-based systems the following system exceptions may be raised if the -call to *connect* fails: -* Errno::EACCES - search permission is denied for a component of the prefix - path or write access to the `socket` is denied -* Errno::EADDRINUSE - the *sockaddr* is already in use -* Errno::EADDRNOTAVAIL - the specified *sockaddr* is not available from the - local machine -* Errno::EAFNOSUPPORT - the specified *sockaddr* is not a valid address for - the address family of the specified `socket` -* Errno::EALREADY - a connection is already in progress for the specified - socket -* Errno::EBADF - the `socket` is not a valid file descriptor -* Errno::ECONNREFUSED - the target *sockaddr* was not listening for - connections refused the connection request -* Errno::ECONNRESET - the remote host reset the connection request -* Errno::EFAULT - the *sockaddr* cannot be accessed -* Errno::EHOSTUNREACH - the destination host cannot be reached (probably - because the host is down or a remote router cannot reach it) -* Errno::EINPROGRESS - the O_NONBLOCK is set for the `socket` and the - connection cannot be immediately established; the connection will be - established asynchronously -* Errno::EINTR - the attempt to establish the connection was interrupted by - delivery of a signal that was caught; the connection will be established - asynchronously -* Errno::EISCONN - the specified `socket` is already connected -* Errno::EINVAL - the address length used for the *sockaddr* is not a valid - length for the address family or there is an invalid family in *sockaddr* -* Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded - PATH_MAX -* Errno::ENETDOWN - the local interface used to reach the destination is - down -* Errno::ENETUNREACH - no route to the network is present -* Errno::ENOBUFS - no buffer space is available -* Errno::ENOSR - there were insufficient STREAMS resources available to - complete the operation -* Errno::ENOTSOCK - the `socket` argument does not refer to a socket -* Errno::EOPNOTSUPP - the calling `socket` is listening and cannot be - connected -* Errno::EPROTOTYPE - the *sockaddr* has a different type than the socket - bound to the specified peer address -* Errno::ETIMEDOUT - the attempt to connect timed out before a connection - was made. - -On unix-based systems if the address family of the calling `socket` is AF_UNIX -the follow exceptions may be raised if the call to *connect* fails: -* Errno::EIO - an i/o error occurred while reading from or writing to the - file system -* Errno::ELOOP - too many symbolic links were encountered in translating the - pathname in *sockaddr* -* Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX - characters, or an entire pathname exceeded PATH_MAX characters -* Errno::ENOENT - a component of the pathname does not name an existing file - or the pathname is an empty string -* Errno::ENOTDIR - a component of the path prefix of the pathname in - *sockaddr* is not a directory - -### Windows Exceptions -On Windows systems the following system exceptions may be raised if the call -to *connect* fails: -* Errno::ENETDOWN - the network is down -* Errno::EADDRINUSE - the socket's local address is already in use -* Errno::EINTR - the socket was cancelled -* Errno::EINPROGRESS - a blocking socket is in progress or the service - provider is still processing a callback function. Or a nonblocking connect - call is in progress on the `socket`. -* Errno::EALREADY - see Errno::EINVAL -* Errno::EADDRNOTAVAIL - the remote address is not a valid address, such as - ADDR_ANY TODO check ADDRANY TO INADDR_ANY -* Errno::EAFNOSUPPORT - addresses in the specified family cannot be used - with with this `socket` -* Errno::ECONNREFUSED - the target *sockaddr* was not listening for - connections refused the connection request -* Errno::EFAULT - the socket's internal address or address length parameter - is too small or is not a valid part of the user space address -* Errno::EINVAL - the `socket` is a listening socket -* Errno::EISCONN - the `socket` is already connected -* Errno::ENETUNREACH - the network cannot be reached from this host at this - time -* Errno::EHOSTUNREACH - no route to the network is present -* Errno::ENOBUFS - no buffer space is available -* Errno::ENOTSOCK - the `socket` argument does not refer to a socket -* Errno::ETIMEDOUT - the attempt to connect timed out before a connection - was made. -* Errno::EWOULDBLOCK - the socket is marked as nonblocking and the - connection cannot be completed immediately -* Errno::EACCES - the attempt to connect the datagram socket to the - broadcast address failed - -### See -* connect manual pages on unix-based systems -* connect function in Microsoft's Winsock functions reference - -**@overload** [] - -## connect_nonblock(addr, exception:true) [](#method-i-connect_nonblock) -call-seq: - socket.connect_nonblock(remote_sockaddr, [options]) => 0 - -Requests a connection to be made on the given `remote_sockaddr` after -O_NONBLOCK is set for the underlying file descriptor. Returns 0 if successful, -otherwise an exception is raised. - -### Parameter -* `remote_sockaddr` - the `struct` sockaddr contained in a string or - Addrinfo object - -### Example: - # Pull down Google's web page - require 'socket' - include Socket::Constants - socket = Socket.new(AF_INET, SOCK_STREAM, 0) - sockaddr = Socket.sockaddr_in(80, 'www.google.com') - begin # emulate blocking connect - socket.connect_nonblock(sockaddr) - rescue IO::WaitWritable - IO.select(nil, [socket]) # wait 3-way handshake completion - begin - socket.connect_nonblock(sockaddr) # check connection failure - rescue Errno::EISCONN - end - end - socket.write("GET / HTTP/1.0\r\n\r\n") - results = socket.read - -Refer to Socket#connect for the exceptions that may be thrown if the call to -*connect_nonblock* fails. - -Socket#connect_nonblock may raise any error corresponding to connect(2) -failure, including Errno::EINPROGRESS. - -If the exception is Errno::EINPROGRESS, it is extended by IO::WaitWritable. So -IO::WaitWritable can be used to rescue the exceptions for retrying -connect_nonblock. - -By specifying a keyword argument *exception* to `false`, you can indicate that -connect_nonblock should not raise an IO::WaitWritable exception, but return -the symbol `:wait_writable` instead. - -### See -* Socket#connect - -## initialize(*args) [](#method-i-initialize) -Creates a new socket object. - -*domain* should be a communications domain such as: :INET, :INET6, :UNIX, etc. - -*socktype* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. - -*protocol* is optional and should be a protocol defined in the domain. If -protocol is not given, 0 is used internally. - - Socket.new(:INET, :STREAM) # TCP socket - Socket.new(:INET, :DGRAM) # UDP socket - Socket.new(:UNIX, :STREAM) # UNIX stream socket - Socket.new(:UNIX, :DGRAM) # UNIX datagram socket - -**@overload** [] - -## ipv6only!() [](#method-i-ipv6only!) -enable the socket option IPV6_V6ONLY if IPV6_V6ONLY is available. - -## listen(log) [](#method-i-listen) -Listens for connections, using the specified `int` as the backlog. A call to -*listen* only applies if the `socket` is of type SOCK_STREAM or -SOCK_SEQPACKET. - -### Parameter -* `backlog` - the maximum length of the queue for pending connections. - -### Example 1 - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) - socket.bind( sockaddr ) - socket.listen( 5 ) - -### Example 2 (listening on an arbitrary port, unix-based systems only): - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - socket.listen( 1 ) - -### Unix-based Exceptions -On unix based systems the above will work because a new `sockaddr` struct is -created on the address ADDR_ANY, for an arbitrary port number as handed off by -the kernel. It will not work on Windows, because Windows requires that the -`socket` is bound by calling *bind* before it can *listen*. - -If the *backlog* amount exceeds the implementation-dependent maximum queue -length, the implementation's maximum queue length will be used. - -On unix-based based systems the following system exceptions may be raised if -the call to *listen* fails: -* Errno::EBADF - the *socket* argument is not a valid file descriptor -* Errno::EDESTADDRREQ - the *socket* is not bound to a local address, and - the protocol does not support listening on an unbound socket -* Errno::EINVAL - the *socket* is already connected -* Errno::ENOTSOCK - the *socket* argument does not refer to a socket -* Errno::EOPNOTSUPP - the *socket* protocol does not support listen -* Errno::EACCES - the calling process does not have appropriate privileges -* Errno::EINVAL - the *socket* has been shut down -* Errno::ENOBUFS - insufficient resources are available in the system to - complete the call - -### Windows Exceptions -On Windows systems the following system exceptions may be raised if the call -to *listen* fails: -* Errno::ENETDOWN - the network is down -* Errno::EADDRINUSE - the socket's local address is already in use. This - usually occurs during the execution of *bind* but could be delayed if the - call to *bind* was to a partially wildcard address (involving ADDR_ANY) - and if a specific address needs to be committed at the time of the call to - *listen* -* Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the - service provider is still processing a callback function -* Errno::EINVAL - the `socket` has not been bound with a call to *bind*. -* Errno::EISCONN - the `socket` is already connected -* Errno::EMFILE - no more socket descriptors are available -* Errno::ENOBUFS - no buffer space is available -* Errno::ENOTSOC - `socket` is not a socket -* Errno::EOPNOTSUPP - the referenced `socket` is not a type that supports - the *listen* method - -### See -* listen manual pages on unix-based systems -* listen function in Microsoft's Winsock functions reference - -**@overload** [] - -## recvfrom(*args) [](#method-i-recvfrom) -Receives up to *maxlen* bytes from `socket`. *flags* is zero or more of the -`MSG_` options. The first element of the results, *mesg*, is the data -received. The second element, *sender_addrinfo*, contains protocol-specific -address information of the sender. - -### Parameters -* `maxlen` - the maximum number of bytes to receive from the socket -* `flags` - zero or more of the `MSG_` options - -### Example - # In one file, start this first - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) - socket.bind( sockaddr ) - socket.listen( 5 ) - client, client_addrinfo = socket.accept - data = client.recvfrom( 20 )[0].chomp - puts "I only received 20 bytes '#{data}'" - sleep 1 - socket.close - - # In another file, start this second - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) - socket.connect( sockaddr ) - socket.puts "Watch this get cut short!" - socket.close - -### Unix-based Exceptions -On unix-based based systems the following system exceptions may be raised if -the call to *recvfrom* fails: -* Errno::EAGAIN - the `socket` file descriptor is marked as O_NONBLOCK and - no data is waiting to be received; or MSG_OOB is set and no out-of-band - data is available and either the `socket` file descriptor is marked as - O_NONBLOCK or the `socket` does not support blocking to wait for - out-of-band-data -* Errno::EWOULDBLOCK - see Errno::EAGAIN -* Errno::EBADF - the `socket` is not a valid file descriptor -* Errno::ECONNRESET - a connection was forcibly closed by a peer -* Errno::EFAULT - the socket's internal buffer, address or address length - cannot be accessed or written -* Errno::EINTR - a signal interrupted *recvfrom* before any data was - available -* Errno::EINVAL - the MSG_OOB flag is set and no out-of-band data is - available -* Errno::EIO - an i/o error occurred while reading from or writing to the - filesystem -* Errno::ENOBUFS - insufficient resources were available in the system to - perform the operation -* Errno::ENOMEM - insufficient memory was available to fulfill the request -* Errno::ENOSR - there were insufficient STREAMS resources available to - complete the operation -* Errno::ENOTCONN - a receive is attempted on a connection-mode socket that - is not connected -* Errno::ENOTSOCK - the `socket` does not refer to a socket -* Errno::EOPNOTSUPP - the specified flags are not supported for this socket - type -* Errno::ETIMEDOUT - the connection timed out during connection - establishment or due to a transmission timeout on an active connection - -### Windows Exceptions -On Windows systems the following system exceptions may be raised if the call -to *recvfrom* fails: -* Errno::ENETDOWN - the network is down -* Errno::EFAULT - the internal buffer and from parameters on `socket` are - not part of the user address space, or the internal fromlen parameter is - too small to accommodate the peer address -* Errno::EINTR - the (blocking) call was cancelled by an internal call to - the WinSock function WSACancelBlockingCall -* Errno::EINPROGRESS - a blocking Windows Sockets 1.1 call is in progress or - the service provider is still processing a callback function -* Errno::EINVAL - `socket` has not been bound with a call to *bind*, or an - unknown flag was specified, or MSG_OOB was specified for a socket with - SO_OOBINLINE enabled, or (for byte stream-style sockets only) the internal - len parameter on `socket` was zero or negative -* Errno::EISCONN - `socket` is already connected. The call to *recvfrom* is - not permitted with a connected socket on a socket that is connection - oriented or connectionless. -* Errno::ENETRESET - the connection has been broken due to the keep-alive - activity detecting a failure while the operation was in progress. -* Errno::EOPNOTSUPP - MSG_OOB was specified, but `socket` is not - stream-style such as type SOCK_STREAM. OOB data is not supported in the - communication domain associated with `socket`, or `socket` is - unidirectional and supports only send operations -* Errno::ESHUTDOWN - `socket` has been shutdown. It is not possible to call - *recvfrom* on a socket after *shutdown* has been invoked. -* Errno::EWOULDBLOCK - `socket` is marked as nonblocking and a call to - *recvfrom* would block. -* Errno::EMSGSIZE - the message was too large to fit into the specified - buffer and was truncated. -* Errno::ETIMEDOUT - the connection has been dropped, because of a network - failure or because the system on the other end went down without notice -* Errno::ECONNRESET - the virtual circuit was reset by the remote side - executing a hard or abortive close. The application should close the - socket; it is no longer usable. On a UDP-datagram socket this error - indicates a previous send operation resulted in an ICMP Port Unreachable - message. - -**@overload** [] - -**@overload** [] - -## recvfrom_nonblock(len, flag0, strnil, exception:true) [](#method-i-recvfrom_nonblock) -call-seq: - socket.recvfrom_nonblock(maxlen[, flags[, outbuf[, opts]]]) => [mesg, sender_addrinfo] - -Receives up to *maxlen* bytes from `socket` using recvfrom(2) after O_NONBLOCK -is set for the underlying file descriptor. *flags* is zero or more of the -`MSG_` options. The first element of the results, *mesg*, is the data -received. The second element, *sender_addrinfo*, contains protocol-specific -address information of the sender. - -When recvfrom(2) returns 0, Socket#recv_nonblock returns nil. In most cases it -means the connection was closed, but for UDP connections it may mean an empty -packet was received, as the underlying API makes it impossible to distinguish -these two cases. - -### Parameters -* `maxlen` - the maximum number of bytes to receive from the socket -* `flags` - zero or more of the `MSG_` options -* `outbuf` - destination String buffer -* `opts` - keyword hash, supporting `exception: false` - -### Example - # In one file, start this first - require 'socket' - include Socket::Constants - socket = Socket.new(AF_INET, SOCK_STREAM, 0) - sockaddr = Socket.sockaddr_in(2200, 'localhost') - socket.bind(sockaddr) - socket.listen(5) - client, client_addrinfo = socket.accept - begin # emulate blocking recvfrom - pair = client.recvfrom_nonblock(20) - rescue IO::WaitReadable - IO.select([client]) - retry - end - data = pair[0].chomp - puts "I only received 20 bytes '#{data}'" - sleep 1 - socket.close - - # In another file, start this second - require 'socket' - include Socket::Constants - socket = Socket.new(AF_INET, SOCK_STREAM, 0) - sockaddr = Socket.sockaddr_in(2200, 'localhost') - socket.connect(sockaddr) - socket.puts "Watch this get cut short!" - socket.close - -Refer to Socket#recvfrom for the exceptions that may be thrown if the call to -*recvfrom_nonblock* fails. - -Socket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) -failure, including Errno::EWOULDBLOCK. - -If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, it is extended by -IO::WaitReadable. So IO::WaitReadable can be used to rescue the exceptions for -retrying recvfrom_nonblock. - -By specifying a keyword argument *exception* to `false`, you can indicate that -recvfrom_nonblock should not raise an IO::WaitReadable exception, but return -the symbol `:wait_readable` instead. - -### See -* Socket#recvfrom - -## sysaccept() [](#method-i-sysaccept) -Accepts an incoming connection returning an array containing the (integer) -file descriptor for the incoming connection, *client_socket_fd*, and an -Addrinfo, *client_addrinfo*. - -### Example - # In one script, start this first - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) - socket.bind( sockaddr ) - socket.listen( 5 ) - client_fd, client_addrinfo = socket.sysaccept - client_socket = Socket.for_fd( client_fd ) - puts "The client said, '#{client_socket.readline.chomp}'" - client_socket.puts "Hello from script one!" - socket.close - - # In another script, start this second - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) - socket.connect( sockaddr ) - socket.puts "Hello from script 2." - puts "The server said, '#{socket.readline.chomp}'" - socket.close - -Refer to Socket#accept for the exceptions that may be thrown if the call to -*sysaccept* fails. - -### See -* Socket#accept - -**@overload** [] - diff --git a/example/ruby/Socket/AncillaryData.md b/example/ruby/Socket/AncillaryData.md deleted file mode 100644 index e33b233..0000000 --- a/example/ruby/Socket/AncillaryData.md +++ /dev/null @@ -1,258 +0,0 @@ -# Class: Socket::AncillaryData -**Inherits:** Object - - -Socket::AncillaryData represents the ancillary data (control information) used -by sendmsg and recvmsg system call. It contains socket #family, control -message (cmsg) #level, cmsg #type and cmsg #data. - - -# Class Methods -## int(vfamily , vlevel , vtype , integer ) [](#method-c-int) -Creates a new Socket::AncillaryData object which contains a int as data. - -The size and endian is dependent on the host. - - require 'socket' - - p Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) - #=> # -**@overload** [] - -## ip_pktinfo(*args ) [](#method-c-ip_pktinfo) -Returns new ancillary data for IP_PKTINFO. - -If spec_dst is not given, addr is used. - -IP_PKTINFO is not standard. - -Supported platform: GNU/Linux - - addr = Addrinfo.ip("127.0.0.1") - ifindex = 0 - spec_dst = Addrinfo.ip("127.0.0.1") - p Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst) - #=> # -**@overload** [] - -**@overload** [] - -## ipv6_pktinfo(v_addr , v_ifindex ) [](#method-c-ipv6_pktinfo) -Returns new ancillary data for IPV6_PKTINFO. - -IPV6_PKTINFO is defined by RFC 3542. - - addr = Addrinfo.ip("::1") - ifindex = 0 - p Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) - #=> # -**@overload** [] - -## unix_rights(*args ) [](#method-c-unix_rights) -Creates a new Socket::AncillaryData object which contains file descriptors as -data. - - p Socket::AncillaryData.unix_rights(STDERR) - #=> # -**@overload** [] - - -#Instance Methods -## cmsg_is?(vlevel, vtype) [](#method-i-cmsg_is?) -tests the level and type of *ancillarydata*. - - ancdata = Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") - ancdata.cmsg_is?(Socket::IPPROTO_IPV6, Socket::IPV6_PKTINFO) #=> true - ancdata.cmsg_is?(:IPV6, :PKTINFO) #=> true - ancdata.cmsg_is?(:IP, :PKTINFO) #=> false - ancdata.cmsg_is?(:SOCKET, :RIGHTS) #=> false - -**@overload** [] - -## data() [](#method-i-data) -returns the cmsg data as a string. - - p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").data - #=> "" - -**@overload** [] - -## family() [](#method-i-family) -returns the socket family as an integer. - - p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").family - #=> 10 - -**@overload** [] - -## initialize(vfamily, vlevel, vtype, data) [](#method-i-initialize) -*family* should be an integer, a string or a symbol. -* Socket::AF_INET, "AF_INET", "INET", :AF_INET, :INET -* Socket::AF_UNIX, "AF_UNIX", "UNIX", :AF_UNIX, :UNIX -* etc. - -*cmsg_level* should be an integer, a string or a symbol. -* Socket::SOL_SOCKET, "SOL_SOCKET", "SOCKET", :SOL_SOCKET and :SOCKET -* Socket::IPPROTO_IP, "IP" and :IP -* Socket::IPPROTO_IPV6, "IPV6" and :IPV6 -* Socket::IPPROTO_TCP, "TCP" and :TCP -* etc. - -*cmsg_type* should be an integer, a string or a symbol. If a string/symbol is -specified, it is interpreted depend on *cmsg_level*. -* Socket::SCM_RIGHTS, "SCM_RIGHTS", "RIGHTS", :SCM_RIGHTS, :RIGHTS for - SOL_SOCKET -* Socket::IP_RECVTTL, "RECVTTL" and :RECVTTL for IPPROTO_IP -* Socket::IPV6_PKTINFO, "PKTINFO" and :PKTINFO for IPPROTO_IPV6 -* etc. - -*cmsg_data* should be a string. - - p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "") - #=> # - - p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") - #=> # - -**@overload** [] - -## inspect() [](#method-i-inspect) -returns a string which shows ancillarydata in human-readable form. - - p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").inspect - #=> "#" - -**@overload** [] - -## int() [](#method-i-int) -Returns the data in *ancillarydata* as an int. - -The size and endian is dependent on the host. - - ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) - p ancdata.int #=> 2 - -**@overload** [] - -## ip_pktinfo() [](#method-i-ip_pktinfo) -Extracts addr, ifindex and spec_dst from IP_PKTINFO ancillary data. - -IP_PKTINFO is not standard. - -Supported platform: GNU/Linux - - addr = Addrinfo.ip("127.0.0.1") - ifindex = 0 - spec_dest = Addrinfo.ip("127.0.0.1") - ancdata = Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dest) - p ancdata.ip_pktinfo - #=> [#, 0, #] - -**@overload** [] - -## ipv6_pktinfo() [](#method-i-ipv6_pktinfo) -Extracts addr and ifindex from IPV6_PKTINFO ancillary data. - -IPV6_PKTINFO is defined by RFC 3542. - - addr = Addrinfo.ip("::1") - ifindex = 0 - ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) - p ancdata.ipv6_pktinfo #=> [#, 0] - -**@overload** [] - -## ipv6_pktinfo_addr() [](#method-i-ipv6_pktinfo_addr) -Extracts addr from IPV6_PKTINFO ancillary data. - -IPV6_PKTINFO is defined by RFC 3542. - - addr = Addrinfo.ip("::1") - ifindex = 0 - ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) - p ancdata.ipv6_pktinfo_addr #=> # - -**@overload** [] - -## ipv6_pktinfo_ifindex() [](#method-i-ipv6_pktinfo_ifindex) -Extracts ifindex from IPV6_PKTINFO ancillary data. - -IPV6_PKTINFO is defined by RFC 3542. - - addr = Addrinfo.ip("::1") - ifindex = 0 - ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) - p ancdata.ipv6_pktinfo_ifindex #=> 0 - -**@overload** [] - -## level() [](#method-i-level) -returns the cmsg level as an integer. - - p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").level - #=> 41 - -**@overload** [] - -## timestamp() [](#method-i-timestamp) -returns the timestamp as a time object. - -*ancillarydata* should be one of following type: -* SOL_SOCKET/SCM_TIMESTAMP (microsecond) GNU/Linux, FreeBSD, NetBSD, - OpenBSD, Solaris, MacOS X -* SOL_SOCKET/SCM_TIMESTAMPNS (nanosecond) GNU/Linux -* SOL_SOCKET/SCM_BINTIME (2**(-64) second) FreeBSD - - Addrinfo.udp("127.0.0.1", 0).bind {|s1| - Addrinfo.udp("127.0.0.1", 0).bind {|s2| - s1.setsockopt(:SOCKET, :TIMESTAMP, true) - s2.send "a", 0, s1.local_address - ctl = s1.recvmsg.last - p ctl #=> # - t = ctl.timestamp - p t #=> 2009-02-24 17:35:46 +0900 - p t.usec #=> 775581 - p t.nsec #=> 775581000 - } - - } - -**@overload** [] - -## type() [](#method-i-type) -returns the cmsg type as an integer. - - p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").type - #=> 2 - -**@overload** [] - -## unix_rights() [](#method-i-unix_rights) -returns the array of IO objects for SCM_RIGHTS control message in UNIX domain -socket. - -The class of the IO objects in the array is IO or Socket. - -The array is attached to *ancillarydata* when it is instantiated. For example, -BasicSocket#recvmsg attach the array when receives a SCM_RIGHTS control -message and :scm_rights=>true option is given. - - # recvmsg needs :scm_rights=>true for unix_rights - s1, s2 = UNIXSocket.pair - p s1 #=> # - s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1) - _, _, _, ctl = s2.recvmsg(:scm_rights=>true) - p ctl #=> # - p ctl.unix_rights #=> [#, #] - p File.identical?(STDIN, ctl.unix_rights[0]) #=> true - p File.identical?(s1, ctl.unix_rights[1]) #=> true - - # If :scm_rights=>true is not given, unix_rights returns nil - s1, s2 = UNIXSocket.pair - s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1) - _, _, _, ctl = s2.recvmsg - p ctl #=> # - p ctl.unix_rights #=> nil - -**@overload** [] - diff --git a/example/ruby/Socket/Ifaddr.md b/example/ruby/Socket/Ifaddr.md deleted file mode 100644 index f8670c8..0000000 --- a/example/ruby/Socket/Ifaddr.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: Socket::Ifaddr -**Inherits:** Object - - -Socket::Ifaddr represents a result of getifaddrs() function. - - - -#Instance Methods -## addr() [](#method-i-addr) -Returns the address of *ifaddr*. nil is returned if address is not available -in *ifaddr*. - -**@overload** [] - -## broadaddr() [](#method-i-broadaddr) -Returns the broadcast address of *ifaddr*. nil is returned if the flags -doesn't have IFF_BROADCAST. - -**@overload** [] - -## dstaddr() [](#method-i-dstaddr) -Returns the destination address of *ifaddr*. nil is returned if the flags -doesn't have IFF_POINTOPOINT. - -**@overload** [] - -## flags() [](#method-i-flags) -Returns the flags of *ifaddr*. - -**@overload** [] - -## ifindex() [](#method-i-ifindex) -Returns the interface index of *ifaddr*. - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string to show contents of *ifaddr*. - -**@overload** [] - -## name() [](#method-i-name) -Returns the interface name of *ifaddr*. - -**@overload** [] - -## netmask() [](#method-i-netmask) -Returns the netmask address of *ifaddr*. nil is returned if netmask is not -available in *ifaddr*. - -**@overload** [] - -## vhid() [](#method-i-vhid) -Returns the vhid address of *ifaddr*. nil is returned if there is no vhid. - -**@overload** [] - diff --git a/example/ruby/Socket/Option.md b/example/ruby/Socket/Option.md deleted file mode 100644 index af568ac..0000000 --- a/example/ruby/Socket/Option.md +++ /dev/null @@ -1,192 +0,0 @@ -# Class: Socket::Option -**Inherits:** Object - - -Socket::Option represents a socket option used by BasicSocket#getsockopt and -BasicSocket#setsockopt. A socket option contains the socket #family, protocol -#level, option name #optname and option value #data. - - -# Class Methods -## bool(vfamily , vlevel , voptname , vbool ) [](#method-c-bool) -Creates a new Socket::Option object which contains boolean as data. Actually 0 -or 1 as int is used. - - require 'socket' - - p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true) - #=> # - - p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false) - #=> # -**@overload** [] - -## byte(vfamily , vlevel , voptname , vint ) [](#method-c-byte) -Creates a new Socket::Option object which contains a byte as data. - - p Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1) - #=> # -**@overload** [] - -## int(vfamily , vlevel , voptname , vint ) [](#method-c-int) -Creates a new Socket::Option object which contains an int as data. - -The size and endian is dependent on the platform. - - p Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) - #=> # -**@overload** [] - -## ipv4_multicast_loop(value ) [](#method-c-ipv4_multicast_loop) -Creates a new Socket::Option object for IP_MULTICAST_LOOP. - -The size is dependent on the platform. - - sockopt = Socket::Option.int(:INET, :IPPROTO_IP, :IP_MULTICAST_LOOP, 1) - p sockopt.int => 1 - - p Socket::Option.ipv4_multicast_loop(10) - #=> # -**@overload** [] - -## ipv4_multicast_ttl(value ) [](#method-c-ipv4_multicast_ttl) -Creates a new Socket::Option object for IP_MULTICAST_TTL. - -The size is dependent on the platform. - - p Socket::Option.ipv4_multicast_ttl(10) - #=> # -**@overload** [] - -## linger(vonoff , vsecs ) [](#method-c-linger) -Creates a new Socket::Option object for SOL_SOCKET/SO_LINGER. - -*onoff* should be an integer or a boolean. - -*secs* should be the number of seconds. - - p Socket::Option.linger(true, 10) - #=> # -**@overload** [] - - -#Instance Methods -## bool() [](#method-i-bool) -Returns the data in *sockopt* as an boolean value. - - sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) - p sockopt.bool => true - -**@overload** [] - -## byte() [](#method-i-byte) -Returns the data in *sockopt* as an byte. - - sockopt = Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1) - p sockopt.byte => 1 - -**@overload** [] - -## data() [](#method-i-data) -returns the socket option data as a string. - - p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).data - #=> "\x01\x00\x00\x00" - -**@overload** [] - -**@overload** [] - -## family() [](#method-i-family) -returns the socket family as an integer. - - p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).family - #=> 10 - -**@overload** [] - -## initialize(vfamily, vlevel, voptname, data) [](#method-i-initialize) -Returns a new Socket::Option object. - - sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")) - p sockopt #=> # - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string which shows sockopt in human-readable form. - - p Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")).inspect - #=> "#" - -**@overload** [] - -## int() [](#method-i-int) -Returns the data in *sockopt* as an int. - -The size and endian is dependent on the platform. - - sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) - p sockopt.int => 1 - -**@overload** [] - -## ipv4_multicast_loop() [](#method-i-ipv4_multicast_loop) -Returns the ipv4_multicast_loop data in *sockopt* as an integer. - - sockopt = Socket::Option.ipv4_multicast_loop(10) - p sockopt.ipv4_multicast_loop => 10 - -**@overload** [] - -## ipv4_multicast_ttl() [](#method-i-ipv4_multicast_ttl) -Returns the ipv4_multicast_ttl data in *sockopt* as an integer. - - sockopt = Socket::Option.ipv4_multicast_ttl(10) - p sockopt.ipv4_multicast_ttl => 10 - -**@overload** [] - -## level() [](#method-i-level) -returns the socket level as an integer. - - p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).level - #=> 41 - -**@overload** [] - -## linger() [](#method-i-linger) -Returns the linger data in *sockopt* as a pair of boolean and integer. - - sockopt = Socket::Option.linger(true, 10) - p sockopt.linger => [true, 10] - -**@overload** [] - -## optname() [](#method-i-optname) -returns the socket option name as an integer. - - p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).optname - #=> 2 - -**@overload** [] - -## to_s() [](#method-i-to_s) -returns the socket option data as a string. - - p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).data - #=> "\x01\x00\x00\x00" - -**@overload** [] - -**@overload** [] - -## unpack(template) [](#method-i-unpack) -Calls String#unpack on sockopt.data. - - sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")) - p sockopt.unpack("i") #=> [1] - p sockopt.data.unpack("i") #=> [1] - -**@overload** [] - diff --git a/example/ruby/Socket/ResolutionError.md b/example/ruby/Socket/ResolutionError.md deleted file mode 100644 index 0538474..0000000 --- a/example/ruby/Socket/ResolutionError.md +++ /dev/null @@ -1,24 +0,0 @@ -# Exception: Socket::ResolutionError -**Inherits:** SocketError - - - - - -#Instance Methods -## error_code() [](#method-i-error_code) -Returns the raw error code indicating the cause of the hostname resolution -failure. - - begin - Addrinfo.getaddrinfo("ruby-lang.org", nil) - rescue Socket::ResolutionError => e - if e.error_code == Socket::EAI_AGAIN - puts "Temporary failure in name resolution." - end - end - -Note that error codes depend on the operating system. - -**@overload** [] - diff --git a/example/ruby/Socket/UDPSource.md b/example/ruby/Socket/UDPSource.md deleted file mode 100644 index 8b4e2f0..0000000 --- a/example/ruby/Socket/UDPSource.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: Socket::UDPSource -**Inherits:** Object - - -UDP/IP address information used by Socket.udp_server_loop. - - -# Attributes -## local_address[RW] [](#attribute-i-local_address) -Local address - -## remote_address[RW] [](#attribute-i-remote_address) -Address of the source - - -#Instance Methods -## initialize(remote_address, local_address, &reply_proc) [](#method-i-initialize) -`remote_address` is an Addrinfo object. - -`local_address` is an Addrinfo object. - -`reply_proc` is a Proc used to send reply back to the source. - -**@return** [UDPSource] a new instance of UDPSource - -## inspect() [](#method-i-inspect) -:nodoc: - -## reply(msg) [](#method-i-reply) -Sends the String `msg` to the source - diff --git a/example/ruby/SocketError.md b/example/ruby/SocketError.md deleted file mode 100644 index ec786b5..0000000 --- a/example/ruby/SocketError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: SocketError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/SocketSpecs.md b/example/ruby/SocketSpecs.md deleted file mode 100644 index 05c220c..0000000 --- a/example/ruby/SocketSpecs.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: SocketSpecs - - - - -# Class Methods -## addr(which :ipv4) [](#method-c-addr) -## dest_addr_req_error() [](#method-c-dest_addr_req_error) -## each_ip_protocol() [](#method-c-each_ip_protocol) -## hostname(ip "127.0.0.1") [](#method-c-hostname) -helper to get the hostname associated to 127.0.0.1 or the given ip -## hostname_reverse_lookup(ip "127.0.0.1") [](#method-c-hostname_reverse_lookup) -## ipv6_available?() [](#method-c-ipv6_available?) -**@return** [Boolean] - -## loop_with_timeout(timeout TIME_TOLERANCE) [](#method-c-loop_with_timeout) -## reserved_unused_port() [](#method-c-reserved_unused_port) -## rm_socket(path ) [](#method-c-rm_socket) -## sockaddr_in(port , host ) [](#method-c-sockaddr_in) -## socket_path() [](#method-c-socket_path) - diff --git a/example/ruby/SocketSpecs/ServerLoopPortFinder.md b/example/ruby/SocketSpecs/ServerLoopPortFinder.md deleted file mode 100644 index be55483..0000000 --- a/example/ruby/SocketSpecs/ServerLoopPortFinder.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: SocketSpecs::ServerLoopPortFinder -**Inherits:** Socket - - -We need to find a free port for Socket.tcp_server_loop and -Socket.udp_server_loop, and the only reliable way to do that is to pass 0 as -the port, but then we need to find out which one was chosen and the API -doesn't let us find what it is. So we intercept one of the public API methods -called by these methods. - - -# Class Methods -## cleanup() [](#method-c-cleanup) -## port() [](#method-c-port) -## tcp_server_sockets(*args ) [](#method-c-tcp_server_sockets) -## udp_server_sockets(*args , &block ) [](#method-c-udp_server_sockets) - diff --git a/example/ruby/SocketSpecs/SpecTCPServer.md b/example/ruby/SocketSpecs/SpecTCPServer.md deleted file mode 100644 index 8c4d284..0000000 --- a/example/ruby/SocketSpecs/SpecTCPServer.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: SocketSpecs::SpecTCPServer -**Inherits:** Object - - -TCPServer echo server accepting one connection - - -# Attributes -## hostname[RW] [](#attribute-i-hostname) -Returns the value of attribute hostname. - -## port[RW] [](#attribute-i-port) -Returns the value of attribute port. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [SpecTCPServer] a new instance of SpecTCPServer - -## log(message) [](#method-i-log) - -## service(socket) [](#method-i-service) - -## shutdown() [](#method-i-shutdown) - diff --git a/example/ruby/SomeClass.md b/example/ruby/SomeClass.md deleted file mode 100644 index 1b46598..0000000 --- a/example/ruby/SomeClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SomeClass -**Inherits:** Object - - -Class comment - - - -#Instance Methods -## some_method() [](#method-i-some_method) -Method comment - diff --git a/example/ruby/SortedSet.md b/example/ruby/SortedSet.md deleted file mode 100644 index 87f97c3..0000000 --- a/example/ruby/SortedSet.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SortedSet -**Inherits:** Set - - - - - diff --git a/example/ruby/Spec.md b/example/ruby/Spec.md deleted file mode 100644 index 8d4c5a2..0000000 --- a/example/ruby/Spec.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Spec - - - - - diff --git a/example/ruby/Spec/BuildMetadata.md b/example/ruby/Spec/BuildMetadata.md deleted file mode 100644 index d76643e..0000000 --- a/example/ruby/Spec/BuildMetadata.md +++ /dev/null @@ -1,418 +0,0 @@ -# Module: Spec::BuildMetadata - -**Extended by:** Spec::BuildMetadata - -**Includes:** Spec::Helpers, Spec::Path - - - - -# Class Methods -## all_commands_output() [](#method-c-all_commands_output) -## base_system_gem_path() [](#method-c-base_system_gem_path) -## base_system_gems() [](#method-c-base_system_gems) -## bindir() [](#method-c-bindir) -## break_git!() [](#method-c-break_git!) -## build_ruby_cmd(options {}) [](#method-c-build_ruby_cmd) -## bundle(cmd , options {}, &block ) [](#method-c-bundle) -## bundled_app(*path ) [](#method-c-bundled_app) -## bundled_app2(*path ) [](#method-c-bundled_app2) -## bundled_app_gemfile() [](#method-c-bundled_app_gemfile) -## bundled_app_lock() [](#method-c-bundled_app_lock) -## bundler(cmd , options {}) [](#method-c-bundler) -## cache_gems(*gems , gem_repo: gem_repo1) [](#method-c-cache_gems) -## cached_gem(path ) [](#method-c-cached_gem) -## command_executions() [](#method-c-command_executions) -## config(config nil, path bundled_app(".bundle/config")) [](#method-c-config) -## create_file(path , contents "") [](#method-c-create_file) -## current_ruby_minor() [](#method-c-current_ruby_minor) -## default_bundle_path(*path ) [](#method-c-default_bundle_path) -## default_cache_path(*path ) [](#method-c-default_cache_path) -## deprecations() [](#method-c-deprecations) -## dev_gemfile() [](#method-c-dev_gemfile) -## err() [](#method-c-err) -## err_without_deprecations() [](#method-c-err_without_deprecations) -## exit_status_for_signal(signal_number ) [](#method-c-exit_status_for_signal) -## exitstatus() [](#method-c-exitstatus) -## file_uri_for(path ) [](#method-c-file_uri_for) -## find_unused_port() [](#method-c-find_unused_port) -## gem_bin() [](#method-c-gem_bin) -## gem_cmd() [](#method-c-gem_cmd) -## gem_command(command , options {}) [](#method-c-gem_command) -## gem_repo1(*args ) [](#method-c-gem_repo1) -## gem_repo2(*args ) [](#method-c-gem_repo2) -## gem_repo3(*args ) [](#method-c-gem_repo3) -## gem_repo4(*args ) [](#method-c-gem_repo4) -## gem_repo_missing(*args ) [](#method-c-gem_repo_missing) -## gembin(cmd , options {}) [](#method-c-gembin) -## gemfile(*args ) [](#method-c-gemfile) -## gemspec() [](#method-c-gemspec) -## gemspec_dir() [](#method-c-gemspec_dir) -## git(cmd , path Dir.pwd, options {}) [](#method-c-git) -## git_root() [](#method-c-git_root) -## global_config(config nil) [](#method-c-global_config) -## global_plugin_gem(*args ) [](#method-c-global_plugin_gem) -## home(*path ) [](#method-c-home) -## install_gem(path , install_dir , default false) [](#method-c-install_gem) -## install_gemfile(*args ) [](#method-c-install_gemfile) -## installed_bindir() [](#method-c-installed_bindir) -## last_command() [](#method-c-last_command) -## lib_dir() [](#method-c-lib_dir) -## lib_path(*args ) [](#method-c-lib_path) -## lib_tracked_files() [](#method-c-lib_tracked_files) -## load_error_ruby(ruby , name , opts {}) [](#method-c-load_error_ruby) -## load_error_run(ruby , name , *args ) [](#method-c-load_error_run) -## loaded_gemspec() [](#method-c-loaded_gemspec) -## local_gem_path(*path , base: bundled_app) [](#method-c-local_gem_path) -## local_plugin_gem(*args ) [](#method-c-local_plugin_gem) -## lock_gemfile(*args ) [](#method-c-lock_gemfile) -## lockfile(*args ) [](#method-c-lockfile) -## main_source(dir ) [](#method-c-main_source) -## man_dir() [](#method-c-man_dir) -## man_tracked_files() [](#method-c-man_tracked_files) -## next_ruby_minor() [](#method-c-next_ruby_minor) -## opt_add(option , options ) [](#method-c-opt_add) -## opt_remove(option , options ) [](#method-c-opt_remove) -## out() [](#method-c-out) -## path() [](#method-c-path) -## prepare_gemspec(pathname ) [](#method-c-prepare_gemspec) -Simulate replacing TODOs with real values -## previous_ruby_minor() [](#method-c-previous_ruby_minor) -## pristine_system_gem_path() [](#method-c-pristine_system_gem_path) -## pristine_system_gems(*gems ) [](#method-c-pristine_system_gems) -## process_file(pathname ) [](#method-c-process_file) -## rake() [](#method-c-rake) -## rake_path() [](#method-c-rake_path) -## read_bundled_app_file(file ) [](#method-c-read_bundled_app_file) -## read_gemfile(file "Gemfile") [](#method-c-read_gemfile) -## read_lockfile(file "Gemfile.lock") [](#method-c-read_lockfile) -## read_stream(stream , handler , timeout: ) [](#method-c-read_stream) -Mostly copied from -https://github.com/piotrmurach/tty-command/blob/49c37a895ccea107e8b78d20e4cb29 -de6a1a53c8/lib/tty/command/process_runner.rb#L165-L193 -## realworld_system_gems(*gems ) [](#method-c-realworld_system_gems) -## relative_gemspec() [](#method-c-relative_gemspec) -## replace_required_ruby_version(version , dir: ) [](#method-c-replace_required_ruby_version) -## replace_version_file(version , dir: source_root) [](#method-c-replace_version_file) -## require_rack() [](#method-c-require_rack) -## reset!() [](#method-c-reset!) -## reset_build_metadata(dir: source_root) [](#method-c-reset_build_metadata) -## reset_paths!() [](#method-c-reset_paths!) -## revision_for(path ) [](#method-c-revision_for) -## root() [](#method-c-root) -## rubocop_gemfile() [](#method-c-rubocop_gemfile) -## rubocop_gems() [](#method-c-rubocop_gems) -## ruby(ruby , options {}) [](#method-c-ruby) -## ruby_core?() [](#method-c-ruby_core?) -**@return** [Boolean] - -## ruby_major_minor() [](#method-c-ruby_major_minor) -## run(cmd , *args ) [](#method-c-run) -## scope() [](#method-c-scope) -## scoped_gem_path(base ) [](#method-c-scoped_gem_path) -## security_repo(*args ) [](#method-c-security_repo) -## sh(cmd , options {}) [](#method-c-sh) -## shipped_files() [](#method-c-shipped_files) -## simulate_new_machine() [](#method-c-simulate_new_machine) -## simulate_platform(platform ) [](#method-c-simulate_platform) -## simulate_ruby_platform(ruby_platform ) [](#method-c-simulate_ruby_platform) -## simulate_windows(platform x86_mswin32) [](#method-c-simulate_windows) -## source_lib_dir() [](#method-c-source_lib_dir) -## source_root() [](#method-c-source_root) -## spec_dir() [](#method-c-spec_dir) -## standard_gemfile() [](#method-c-standard_gemfile) -## standard_gems() [](#method-c-standard_gems) -## strip_whitespace(str ) [](#method-c-strip_whitespace) -## sys_exec(cmd , options {}, &block ) [](#method-c-sys_exec) -## system_gem_path(*path ) [](#method-c-system_gem_path) -## system_gems(*gems ) [](#method-c-system_gems) -## test_env_version() [](#method-c-test_env_version) -Bump this version whenever you make a breaking change to the spec setup that -requires regenerating tmp/. -## test_gemfile() [](#method-c-test_gemfile) -## the_bundle(*args ) [](#method-c-the_bundle) -## tmp(*path ) [](#method-c-tmp) -## tmp_root(scope ) [](#method-c-tmp_root) -## tmpdir(*args ) [](#method-c-tmpdir) -## tracked_files() [](#method-c-tracked_files) -## vendored_gems(path nil) [](#method-c-vendored_gems) -## wait_for_server(host , port , seconds 15) [](#method-c-wait_for_server) -## with_built_bundler(version nil, &block ) [](#method-c-with_built_bundler) -## with_env_vars(env_hash , &block ) [](#method-c-with_env_vars) -## with_fake_man() [](#method-c-with_fake_man) -## with_gem_path_as(path ) [](#method-c-with_gem_path_as) -## with_path_added(path ) [](#method-c-with_path_added) -## with_path_as(path ) [](#method-c-with_path_as) -## with_read_only(pattern ) [](#method-c-with_read_only) -## without_env_side_effects() [](#method-c-without_env_side_effects) -## write_build_metadata(dir: source_root) [](#method-c-write_build_metadata) - -#Instance Methods -## all_commands_output() [](#method-i-all_commands_output) - -## base_system_gem_path() [](#method-i-base_system_gem_path) - -## base_system_gems() [](#method-i-base_system_gems) - -## bindir() [](#method-i-bindir) - -## break_git!() [](#method-i-break_git!) - -## build_ruby_cmd(options{}) [](#method-i-build_ruby_cmd) - -## bundle(cmd, options{}, &block) [](#method-i-bundle) - -## bundled_app(*path) [](#method-i-bundled_app) - -## bundled_app2(*path) [](#method-i-bundled_app2) - -## bundled_app_gemfile() [](#method-i-bundled_app_gemfile) - -## bundled_app_lock() [](#method-i-bundled_app_lock) - -## bundler(cmd, options{}) [](#method-i-bundler) - -## cache_gems(*gems, gem_repo:gem_repo1) [](#method-i-cache_gems) - -## cached_gem(path) [](#method-i-cached_gem) - -## command_executions() [](#method-i-command_executions) - -## config(confignil, pathbundled_app(".bundle/config")) [](#method-i-config) - -## create_file(path, contents"") [](#method-i-create_file) - -## current_ruby_minor() [](#method-i-current_ruby_minor) - -## default_bundle_path(*path) [](#method-i-default_bundle_path) - -## default_cache_path(*path) [](#method-i-default_cache_path) - -## deprecations() [](#method-i-deprecations) - -## dev_gemfile() [](#method-i-dev_gemfile) - -## err() [](#method-i-err) - -## err_without_deprecations() [](#method-i-err_without_deprecations) - -## exit_status_for_signal(signal_number) [](#method-i-exit_status_for_signal) - -## exitstatus() [](#method-i-exitstatus) - -## file_uri_for(path) [](#method-i-file_uri_for) - -## find_unused_port() [](#method-i-find_unused_port) - -## gem_bin() [](#method-i-gem_bin) - -## gem_cmd() [](#method-i-gem_cmd) - -## gem_command(command, options{}) [](#method-i-gem_command) - -## gem_repo1(*args) [](#method-i-gem_repo1) - -## gem_repo2(*args) [](#method-i-gem_repo2) - -## gem_repo3(*args) [](#method-i-gem_repo3) - -## gem_repo4(*args) [](#method-i-gem_repo4) - -## gem_repo_missing(*args) [](#method-i-gem_repo_missing) - -## gembin(cmd, options{}) [](#method-i-gembin) - -## gemfile(*args) [](#method-i-gemfile) - -## gemspec() [](#method-i-gemspec) - -## gemspec_dir() [](#method-i-gemspec_dir) - -## git(cmd, pathDir.pwd, options{}) [](#method-i-git) - -## git_root() [](#method-i-git_root) - -## global_config(confignil) [](#method-i-global_config) - -## global_plugin_gem(*args) [](#method-i-global_plugin_gem) - -## home(*path) [](#method-i-home) - -## install_gem(path, install_dir, defaultfalse) [](#method-i-install_gem) - -## install_gemfile(*args) [](#method-i-install_gemfile) - -## installed_bindir() [](#method-i-installed_bindir) - -## last_command() [](#method-i-last_command) - -## lib_dir() [](#method-i-lib_dir) - -## lib_path(*args) [](#method-i-lib_path) - -## lib_tracked_files() [](#method-i-lib_tracked_files) - -## load_error_ruby(ruby, name, opts{}) [](#method-i-load_error_ruby) - -## load_error_run(ruby, name, *args) [](#method-i-load_error_run) - -## loaded_gemspec() [](#method-i-loaded_gemspec) - -## local_gem_path(*path, base:bundled_app) [](#method-i-local_gem_path) - -## local_plugin_gem(*args) [](#method-i-local_plugin_gem) - -## lock_gemfile(*args) [](#method-i-lock_gemfile) - -## lockfile(*args) [](#method-i-lockfile) - -## main_source(dir) [](#method-i-main_source) - -## man_dir() [](#method-i-man_dir) - -## man_tracked_files() [](#method-i-man_tracked_files) - -## next_ruby_minor() [](#method-i-next_ruby_minor) - -## opt_add(option, options) [](#method-i-opt_add) - -## opt_remove(option, options) [](#method-i-opt_remove) - -## out() [](#method-i-out) - -## path() [](#method-i-path) - -## prepare_gemspec(pathname) [](#method-i-prepare_gemspec) -Simulate replacing TODOs with real values - -## previous_ruby_minor() [](#method-i-previous_ruby_minor) - -## pristine_system_gem_path() [](#method-i-pristine_system_gem_path) - -## pristine_system_gems(*gems) [](#method-i-pristine_system_gems) - -## process_file(pathname) [](#method-i-process_file) - -## rake() [](#method-i-rake) - -## rake_path() [](#method-i-rake_path) - -## read_bundled_app_file(file) [](#method-i-read_bundled_app_file) - -## read_gemfile(file"Gemfile") [](#method-i-read_gemfile) - -## read_lockfile(file"Gemfile.lock") [](#method-i-read_lockfile) - -## read_stream(stream, handler, timeout:) [](#method-i-read_stream) -Mostly copied from -https://github.com/piotrmurach/tty-command/blob/49c37a895ccea107e8b78d20e4cb29 -de6a1a53c8/lib/tty/command/process_runner.rb#L165-L193 - -## realworld_system_gems(*gems) [](#method-i-realworld_system_gems) - -## relative_gemspec() [](#method-i-relative_gemspec) - -## replace_required_ruby_version(version, dir:) [](#method-i-replace_required_ruby_version) - -## replace_version_file(version, dir:source_root) [](#method-i-replace_version_file) - -## require_rack() [](#method-i-require_rack) - -## reset!() [](#method-i-reset!) - -## reset_build_metadata(dir:source_root) [](#method-i-reset_build_metadata) - -## reset_paths!() [](#method-i-reset_paths!) - -## revision_for(path) [](#method-i-revision_for) - -## root() [](#method-i-root) - -## rubocop_gemfile() [](#method-i-rubocop_gemfile) - -## rubocop_gems() [](#method-i-rubocop_gems) - -## ruby(ruby, options{}) [](#method-i-ruby) - -## ruby_core?() [](#method-i-ruby_core?) - -**@return** [Boolean] - -## ruby_major_minor() [](#method-i-ruby_major_minor) - -## run(cmd, *args) [](#method-i-run) - -## scope() [](#method-i-scope) - -## scoped_gem_path(base) [](#method-i-scoped_gem_path) - -## security_repo(*args) [](#method-i-security_repo) - -## sh(cmd, options{}) [](#method-i-sh) - -## shipped_files() [](#method-i-shipped_files) - -## simulate_new_machine() [](#method-i-simulate_new_machine) - -## simulate_platform(platform) [](#method-i-simulate_platform) - -## simulate_ruby_platform(ruby_platform) [](#method-i-simulate_ruby_platform) - -## simulate_windows(platformx86_mswin32) [](#method-i-simulate_windows) - -## source_lib_dir() [](#method-i-source_lib_dir) - -## source_root() [](#method-i-source_root) - -## spec_dir() [](#method-i-spec_dir) - -## standard_gemfile() [](#method-i-standard_gemfile) - -## standard_gems() [](#method-i-standard_gems) - -## strip_whitespace(str) [](#method-i-strip_whitespace) - -## sys_exec(cmd, options{}, &block) [](#method-i-sys_exec) - -## system_gem_path(*path) [](#method-i-system_gem_path) - -## system_gems(*gems) [](#method-i-system_gems) - -## test_env_version() [](#method-i-test_env_version) -Bump this version whenever you make a breaking change to the spec setup that -requires regenerating tmp/. - -## test_gemfile() [](#method-i-test_gemfile) - -## the_bundle(*args) [](#method-i-the_bundle) - -## tmp(*path) [](#method-i-tmp) - -## tmp_root(scope) [](#method-i-tmp_root) - -## tmpdir(*args) [](#method-i-tmpdir) - -## tracked_files() [](#method-i-tracked_files) - -## vendored_gems(pathnil) [](#method-i-vendored_gems) - -## wait_for_server(host, port, seconds15) [](#method-i-wait_for_server) - -## with_built_bundler(versionnil, &block) [](#method-i-with_built_bundler) - -## with_env_vars(env_hash, &block) [](#method-i-with_env_vars) - -## with_fake_man() [](#method-i-with_fake_man) - -## with_gem_path_as(path) [](#method-i-with_gem_path_as) - -## with_path_added(path) [](#method-i-with_path_added) - -## with_path_as(path) [](#method-i-with_path_as) - -## with_read_only(pattern) [](#method-i-with_read_only) - -## without_env_side_effects() [](#method-i-without_env_side_effects) - -## write_build_metadata(dir:source_root) [](#method-i-write_build_metadata) - diff --git a/example/ruby/Spec/Builders.md b/example/ruby/Spec/Builders.md deleted file mode 100644 index 729c7e0..0000000 --- a/example/ruby/Spec/Builders.md +++ /dev/null @@ -1,59 +0,0 @@ -# Module: Spec::Builders - - - - -# Class Methods -## constantize(name ) [](#method-c-constantize) -## extended(mod ) [](#method-c-extended) -**@private** [] - - -#Instance Methods -## build_bundler(*args, &blk) [](#method-i-build_bundler) - -## build_gem(name, *args, &blk) [](#method-i-build_gem) - -## build_git(name, *args, &block) [](#method-i-build_git) - -## build_index(&block) [](#method-i-build_index) - -## build_lib(name, *args, &blk) [](#method-i-build_lib) - -## build_plugin(name, *args, &blk) [](#method-i-build_plugin) - -## build_repo(path, **kwargs, &blk) [](#method-i-build_repo) - -## build_repo1() [](#method-i-build_repo1) - -## build_repo2(**kwargs, &blk) [](#method-i-build_repo2) - -## build_repo3(**kwargs, &blk) [](#method-i-build_repo3) -A repo that has no pre-installed gems included. (The caller completely -determines the contents with the block.) - -## build_repo4(**kwargs, &blk) [](#method-i-build_repo4) -Like build_repo3, this is a repo that has no pre-installed gems included. We -have two different methods for situations where two different empty sources -are needed. - -## build_security_repo() [](#method-i-build_security_repo) - -## build_spec(name, version"0.0.1", platformnil, &block) [](#method-i-build_spec) - -## check_test_gems!() [](#method-i-check_test_gems!) - -## pl(platform) [](#method-i-pl) - -## rake_version() [](#method-i-rake_version) - -## update_git(name, *args, &block) [](#method-i-update_git) - -## update_repo(path, build_compact_index:true) [](#method-i-update_repo) - -## update_repo2(**kwargs, &blk) [](#method-i-update_repo2) - -## update_repo4(&blk) [](#method-i-update_repo4) - -## v(version) [](#method-i-v) - diff --git a/example/ruby/Spec/Builders/BundlerBuilder.md b/example/ruby/Spec/Builders/BundlerBuilder.md deleted file mode 100644 index 35fb69a..0000000 --- a/example/ruby/Spec/Builders/BundlerBuilder.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Spec::Builders::BundlerBuilder -**Inherits:** Object - - - - -# Attributes -## required_ruby_version=[R] [](#attribute-i-required_ruby_version=) -Sets the attribute required_ruby_version - -**@param** [] the value to set the attribute required_ruby_version to. - - -#Instance Methods -## _build(options{}) [](#method-i-_build) - -## initialize(context, name, version) [](#method-i-initialize) - -**@return** [BundlerBuilder] a new instance of BundlerBuilder - diff --git a/example/ruby/Spec/Builders/DepBuilder.md b/example/ruby/Spec/Builders/DepBuilder.md deleted file mode 100644 index 19c1830..0000000 --- a/example/ruby/Spec/Builders/DepBuilder.md +++ /dev/null @@ -1,71 +0,0 @@ -# Class: Spec::Builders::DepBuilder -**Inherits:** Object - -**Includes:** Spec::Builders - - - - -# Class Methods -## run(spec , &block ) [](#method-c-run) - -#Instance Methods -## build_bundler(*args, &blk) [](#method-i-build_bundler) - -## build_gem(name, *args, &blk) [](#method-i-build_gem) - -## build_git(name, *args, &block) [](#method-i-build_git) - -## build_index(&block) [](#method-i-build_index) - -## build_lib(name, *args, &blk) [](#method-i-build_lib) - -## build_plugin(name, *args, &blk) [](#method-i-build_plugin) - -## build_repo(path, **kwargs, &blk) [](#method-i-build_repo) - -## build_repo1() [](#method-i-build_repo1) - -## build_repo2(**kwargs, &blk) [](#method-i-build_repo2) - -## build_repo3(**kwargs, &blk) [](#method-i-build_repo3) -A repo that has no pre-installed gems included. (The caller completely -determines the contents with the block.) - -## build_repo4(**kwargs, &blk) [](#method-i-build_repo4) -Like build_repo3, this is a repo that has no pre-installed gems included. We -have two different methods for situations where two different empty sources -are needed. - -## build_security_repo() [](#method-i-build_security_repo) - -## build_spec(name, version"0.0.1", platformnil, &block) [](#method-i-build_spec) - -## check_test_gems!() [](#method-i-check_test_gems!) - -## development(name, requirements) [](#method-i-development) - -## initialize(spec) [](#method-i-initialize) - -**@return** [DepBuilder] a new instance of DepBuilder - -## pl(platform) [](#method-i-pl) - -## rake_version() [](#method-i-rake_version) - -## required_ruby_version=(*reqs) [](#method-i-required_ruby_version=) - -## run(&block) [](#method-i-run) - -## runtime(name, requirements) [](#method-i-runtime) - -## update_git(name, *args, &block) [](#method-i-update_git) - -## update_repo(path, build_compact_index:true) [](#method-i-update_repo) - -## update_repo2(**kwargs, &blk) [](#method-i-update_repo2) - -## update_repo4(&blk) [](#method-i-update_repo4) - -## v(version) [](#method-i-v) - diff --git a/example/ruby/Spec/Builders/GemBuilder.md b/example/ruby/Spec/Builders/GemBuilder.md deleted file mode 100644 index 763241e..0000000 --- a/example/ruby/Spec/Builders/GemBuilder.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Spec::Builders::GemBuilder -**Inherits:** Spec::Builders::LibBuilder - - - - - -#Instance Methods -## _build(opts) [](#method-i-_build) - -## _default_path() [](#method-i-_default_path) - diff --git a/example/ruby/Spec/Builders/GitBareBuilder.md b/example/ruby/Spec/Builders/GitBareBuilder.md deleted file mode 100644 index b23c53d..0000000 --- a/example/ruby/Spec/Builders/GitBareBuilder.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Spec::Builders::GitBareBuilder -**Inherits:** Spec::Builders::LibBuilder - - - - - -#Instance Methods -## _build(options) [](#method-i-_build) - diff --git a/example/ruby/Spec/Builders/GitBuilder.md b/example/ruby/Spec/Builders/GitBuilder.md deleted file mode 100644 index a368806..0000000 --- a/example/ruby/Spec/Builders/GitBuilder.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Spec::Builders::GitBuilder -**Inherits:** Spec::Builders::LibBuilder - - - - - -#Instance Methods -## _build(options) [](#method-i-_build) - diff --git a/example/ruby/Spec/Builders/GitReader.md b/example/ruby/Spec/Builders/GitReader.md deleted file mode 100644 index c3d663d..0000000 --- a/example/ruby/Spec/Builders/GitReader.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Spec::Builders::GitReader -**Inherits:** Object - - - - -# Attributes -## context[RW] [](#attribute-i-context) -Returns the value of attribute context. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - -#Instance Methods -## initialize(context, path) [](#method-i-initialize) - -**@return** [GitReader] a new instance of GitReader - -## ref_for(ref, lennil) [](#method-i-ref_for) - diff --git a/example/ruby/Spec/Builders/GitUpdater.md b/example/ruby/Spec/Builders/GitUpdater.md deleted file mode 100644 index 0e17411..0000000 --- a/example/ruby/Spec/Builders/GitUpdater.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Spec::Builders::GitUpdater -**Inherits:** Spec::Builders::LibBuilder - - - - - -#Instance Methods -## _build(options) [](#method-i-_build) - diff --git a/example/ruby/Spec/Builders/IndexBuilder.md b/example/ruby/Spec/Builders/IndexBuilder.md deleted file mode 100644 index a592602..0000000 --- a/example/ruby/Spec/Builders/IndexBuilder.md +++ /dev/null @@ -1,71 +0,0 @@ -# Class: Spec::Builders::IndexBuilder -**Inherits:** Object - -**Includes:** Spec::Builders - - - - -# Class Methods -## run(index , &block ) [](#method-c-run) - -#Instance Methods -## build_bundler(*args, &blk) [](#method-i-build_bundler) - -## build_gem(name, *args, &blk) [](#method-i-build_gem) - -## build_git(name, *args, &block) [](#method-i-build_git) - -## build_index(&block) [](#method-i-build_index) - -## build_lib(name, *args, &blk) [](#method-i-build_lib) - -## build_plugin(name, *args, &blk) [](#method-i-build_plugin) - -## build_repo(path, **kwargs, &blk) [](#method-i-build_repo) - -## build_repo1() [](#method-i-build_repo1) - -## build_repo2(**kwargs, &blk) [](#method-i-build_repo2) - -## build_repo3(**kwargs, &blk) [](#method-i-build_repo3) -A repo that has no pre-installed gems included. (The caller completely -determines the contents with the block.) - -## build_repo4(**kwargs, &blk) [](#method-i-build_repo4) -Like build_repo3, this is a repo that has no pre-installed gems included. We -have two different methods for situations where two different empty sources -are needed. - -## build_security_repo() [](#method-i-build_security_repo) - -## build_spec(name, version"0.0.1", platformnil, &block) [](#method-i-build_spec) - -## check_test_gems!() [](#method-i-check_test_gems!) - -## gem(*args, &block) [](#method-i-gem) - -## initialize(index) [](#method-i-initialize) - -**@return** [IndexBuilder] a new instance of IndexBuilder - -## pl(platform) [](#method-i-pl) - -## platforms(platforms) [](#method-i-platforms) - -## rake_version() [](#method-i-rake_version) - -## run(&block) [](#method-i-run) - -## update_git(name, *args, &block) [](#method-i-update_git) - -## update_repo(path, build_compact_index:true) [](#method-i-update_repo) - -## update_repo2(**kwargs, &blk) [](#method-i-update_repo2) - -## update_repo4(&blk) [](#method-i-update_repo4) - -## v(version) [](#method-i-v) - -## versions(versions) [](#method-i-versions) - diff --git a/example/ruby/Spec/Builders/LibBuilder.md b/example/ruby/Spec/Builders/LibBuilder.md deleted file mode 100644 index 8f28f3a..0000000 --- a/example/ruby/Spec/Builders/LibBuilder.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Spec::Builders::LibBuilder -**Inherits:** Object - - - - - -#Instance Methods -## _build(options) [](#method-i-_build) - -## _default_files() [](#method-i-_default_files) - -## _default_path() [](#method-i-_default_path) - -## add_c_extension() [](#method-i-add_c_extension) - -## entrypoint() [](#method-i-entrypoint) - -## executables=(val) [](#method-i-executables=) - -## initialize(context, name, version) [](#method-i-initialize) - -**@return** [LibBuilder] a new instance of LibBuilder - -## method_missing(*args, &blk) [](#method-i-method_missing) - -## platform_string() [](#method-i-platform_string) - -## write(file, source"") [](#method-i-write) - diff --git a/example/ruby/Spec/Builders/PluginBuilder.md b/example/ruby/Spec/Builders/PluginBuilder.md deleted file mode 100644 index a00ed22..0000000 --- a/example/ruby/Spec/Builders/PluginBuilder.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Spec::Builders::PluginBuilder -**Inherits:** Spec::Builders::GemBuilder - - - - - -#Instance Methods -## _default_files() [](#method-i-_default_files) - diff --git a/example/ruby/Spec/Checksums.md b/example/ruby/Spec/Checksums.md deleted file mode 100644 index dd0fc5f..0000000 --- a/example/ruby/Spec/Checksums.md +++ /dev/null @@ -1,24 +0,0 @@ -# Module: Spec::Checksums - - - - - -#Instance Methods -## checksum_digest(*args) [](#method-i-checksum_digest) - -## checksum_from_package(gem_file, name, version) [](#method-i-checksum_from_package) - -## checksum_to_lock(*args) [](#method-i-checksum_to_lock) - -## checksums_section(enabledtrue, &block) [](#method-i-checksums_section) - -## checksums_section_when_enabled(target_lockfilenil, &block) [](#method-i-checksums_section_when_enabled) - -## remove_checksums_from_lockfile(lockfile, *prefixes) [](#method-i-remove_checksums_from_lockfile) -if prefixes is given, removes all checksums where the line has any of the -prefixes on the line before the checksum otherwise, removes all checksums from -the lockfile - -## remove_checksums_section_from_lockfile(lockfile) [](#method-i-remove_checksums_section_from_lockfile) - diff --git a/example/ruby/Spec/Checksums/ChecksumsBuilder.md b/example/ruby/Spec/Checksums/ChecksumsBuilder.md deleted file mode 100644 index 69986ea..0000000 --- a/example/ruby/Spec/Checksums/ChecksumsBuilder.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Spec::Checksums::ChecksumsBuilder -**Inherits:** Object - - - - - -#Instance Methods -## checksum(repo, name, version, platformGem::Platform::RUBY) [](#method-i-checksum) - -## delete(name, platformnil) [](#method-i-delete) - -## initialize(enabledtrue, &block) [](#method-i-initialize) - -**@return** [ChecksumsBuilder] a new instance of ChecksumsBuilder - -**@yield** [_self] - -**@yieldparam** [Spec::Checksums::ChecksumsBuilder] the object that the method was called on - -## initialize_copy(original) [](#method-i-initialize_copy) - -## no_checksum(name, version, platformGem::Platform::RUBY) [](#method-i-no_checksum) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Spec/CommandExecution.md b/example/ruby/Spec/CommandExecution.md deleted file mode 100644 index 0218ff9..0000000 --- a/example/ruby/Spec/CommandExecution.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: Spec::CommandExecution -**Inherits:** Object - - - - -# Attributes -## command[RW] [](#attribute-i-command) -Returns the value of attribute command. - -## exitstatus[RW] [](#attribute-i-exitstatus) -Returns the value of attribute exitstatus. - -## failure_reason=[R] [](#attribute-i-failure_reason=) -Sets the attribute failure_reason - -**@param** [] the value to set the attribute failure_reason to. - -## original_stderr[RW] [](#attribute-i-original_stderr) -Returns the value of attribute original_stderr. - -## original_stdout[RW] [](#attribute-i-original_stdout) -Returns the value of attribute original_stdout. - -## timeout[RW] [](#attribute-i-timeout) -Returns the value of attribute timeout. - - -#Instance Methods -## failure?() [](#method-i-failure?) - -**@return** [Boolean] - -## initialize(command, working_directory:, timeout:) [](#method-i-initialize) - -**@return** [CommandExecution] a new instance of CommandExecution - -## raise_error!() [](#method-i-raise_error!) - -## stdboth() [](#method-i-stdboth) - -## stderr() [](#method-i-stderr) - -## stdout() [](#method-i-stdout) - -## success?() [](#method-i-success?) - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) - -## to_s_verbose() [](#method-i-to_s_verbose) - diff --git a/example/ruby/Spec/Env.md b/example/ruby/Spec/Env.md deleted file mode 100644 index dd7d04d..0000000 --- a/example/ruby/Spec/Env.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Spec::Env - - - - - -#Instance Methods -## ruby_core?() [](#method-i-ruby_core?) - -**@return** [Boolean] - diff --git a/example/ruby/Spec/Helpers.md b/example/ruby/Spec/Helpers.md deleted file mode 100644 index 856d0e9..0000000 --- a/example/ruby/Spec/Helpers.md +++ /dev/null @@ -1,278 +0,0 @@ -# Module: Spec::Helpers - -**Includes:** Spec::Options, Spec::Path, Spec::Subprocess - - - - -# Class Methods -## extended(mod ) [](#method-c-extended) -**@private** [] - -## install_dev_bundler() [](#method-c-install_dev_bundler) - -#Instance Methods -## all_commands_output() [](#method-i-all_commands_output) - -## base_system_gem_path() [](#method-i-base_system_gem_path) - -## base_system_gems() [](#method-i-base_system_gems) - -## bindir() [](#method-i-bindir) - -## break_git!() [](#method-i-break_git!) - -## build_ruby_cmd(options{}) [](#method-i-build_ruby_cmd) - -## bundle(cmd, options{}, &block) [](#method-i-bundle) - -## bundled_app(*path) [](#method-i-bundled_app) - -## bundled_app2(*path) [](#method-i-bundled_app2) - -## bundled_app_gemfile() [](#method-i-bundled_app_gemfile) - -## bundled_app_lock() [](#method-i-bundled_app_lock) - -## bundler(cmd, options{}) [](#method-i-bundler) - -## cache_gems(*gems, gem_repo:gem_repo1) [](#method-i-cache_gems) - -## cached_gem(path) [](#method-i-cached_gem) - -## command_executions() [](#method-i-command_executions) - -## config(confignil, pathbundled_app(".bundle/config")) [](#method-i-config) - -## create_file(path, contents"") [](#method-i-create_file) - -## current_ruby_minor() [](#method-i-current_ruby_minor) - -## default_bundle_path(*path) [](#method-i-default_bundle_path) - -## default_cache_path(*path) [](#method-i-default_cache_path) - -## deprecations() [](#method-i-deprecations) - -## dev_gemfile() [](#method-i-dev_gemfile) - -## err() [](#method-i-err) - -## err_without_deprecations() [](#method-i-err_without_deprecations) - -## exit_status_for_signal(signal_number) [](#method-i-exit_status_for_signal) - -## exitstatus() [](#method-i-exitstatus) - -## file_uri_for(path) [](#method-i-file_uri_for) - -## find_unused_port() [](#method-i-find_unused_port) - -## gem_bin() [](#method-i-gem_bin) - -## gem_cmd() [](#method-i-gem_cmd) - -## gem_command(command, options{}) [](#method-i-gem_command) - -## gem_repo1(*args) [](#method-i-gem_repo1) - -## gem_repo2(*args) [](#method-i-gem_repo2) - -## gem_repo3(*args) [](#method-i-gem_repo3) - -## gem_repo4(*args) [](#method-i-gem_repo4) - -## gem_repo_missing(*args) [](#method-i-gem_repo_missing) - -## gembin(cmd, options{}) [](#method-i-gembin) - -## gemfile(*args) [](#method-i-gemfile) - -## gemspec() [](#method-i-gemspec) - -## gemspec_dir() [](#method-i-gemspec_dir) - -## git(cmd, pathDir.pwd, options{}) [](#method-i-git) - -## git_root() [](#method-i-git_root) - -## global_config(confignil) [](#method-i-global_config) - -## global_plugin_gem(*args) [](#method-i-global_plugin_gem) - -## home(*path) [](#method-i-home) - -## install_gem(path, install_dir, defaultfalse) [](#method-i-install_gem) - -## install_gemfile(*args) [](#method-i-install_gemfile) - -## installed_bindir() [](#method-i-installed_bindir) - -## last_command() [](#method-i-last_command) - -## lib_dir() [](#method-i-lib_dir) - -## lib_path(*args) [](#method-i-lib_path) - -## lib_tracked_files() [](#method-i-lib_tracked_files) - -## load_error_ruby(ruby, name, opts{}) [](#method-i-load_error_ruby) - -## load_error_run(ruby, name, *args) [](#method-i-load_error_run) - -## loaded_gemspec() [](#method-i-loaded_gemspec) - -## local_gem_path(*path, base:bundled_app) [](#method-i-local_gem_path) - -## local_plugin_gem(*args) [](#method-i-local_plugin_gem) - -## lock_gemfile(*args) [](#method-i-lock_gemfile) - -## lockfile(*args) [](#method-i-lockfile) - -## main_source(dir) [](#method-i-main_source) - -## man_dir() [](#method-i-man_dir) - -## man_tracked_files() [](#method-i-man_tracked_files) - -## next_ruby_minor() [](#method-i-next_ruby_minor) - -## opt_add(option, options) [](#method-i-opt_add) - -## opt_remove(option, options) [](#method-i-opt_remove) - -## out() [](#method-i-out) - -## path() [](#method-i-path) - -## prepare_gemspec(pathname) [](#method-i-prepare_gemspec) -Simulate replacing TODOs with real values - -## previous_ruby_minor() [](#method-i-previous_ruby_minor) - -## pristine_system_gem_path() [](#method-i-pristine_system_gem_path) - -## pristine_system_gems(*gems) [](#method-i-pristine_system_gems) - -## process_file(pathname) [](#method-i-process_file) - -## rake() [](#method-i-rake) - -## rake_path() [](#method-i-rake_path) - -## read_bundled_app_file(file) [](#method-i-read_bundled_app_file) - -## read_gemfile(file"Gemfile") [](#method-i-read_gemfile) - -## read_lockfile(file"Gemfile.lock") [](#method-i-read_lockfile) - -## read_stream(stream, handler, timeout:) [](#method-i-read_stream) -Mostly copied from -https://github.com/piotrmurach/tty-command/blob/49c37a895ccea107e8b78d20e4cb29 -de6a1a53c8/lib/tty/command/process_runner.rb#L165-L193 - -## realworld_system_gems(*gems) [](#method-i-realworld_system_gems) - -## relative_gemspec() [](#method-i-relative_gemspec) - -## replace_required_ruby_version(version, dir:) [](#method-i-replace_required_ruby_version) - -## replace_version_file(version, dir:source_root) [](#method-i-replace_version_file) - -## require_rack() [](#method-i-require_rack) - -## reset!() [](#method-i-reset!) - -## reset_paths!() [](#method-i-reset_paths!) - -## revision_for(path) [](#method-i-revision_for) - -## root() [](#method-i-root) - -## rubocop_gemfile() [](#method-i-rubocop_gemfile) - -## rubocop_gems() [](#method-i-rubocop_gems) - -## ruby(ruby, options{}) [](#method-i-ruby) - -## ruby_core?() [](#method-i-ruby_core?) - -**@return** [Boolean] - -## ruby_major_minor() [](#method-i-ruby_major_minor) - -## run(cmd, *args) [](#method-i-run) - -## scope() [](#method-i-scope) - -## scoped_gem_path(base) [](#method-i-scoped_gem_path) - -## security_repo(*args) [](#method-i-security_repo) - -## sh(cmd, options{}) [](#method-i-sh) - -## shipped_files() [](#method-i-shipped_files) - -## simulate_new_machine() [](#method-i-simulate_new_machine) - -## simulate_platform(platform) [](#method-i-simulate_platform) - -## simulate_ruby_platform(ruby_platform) [](#method-i-simulate_ruby_platform) - -## simulate_windows(platformx86_mswin32) [](#method-i-simulate_windows) - -## source_lib_dir() [](#method-i-source_lib_dir) - -## source_root() [](#method-i-source_root) - -## spec_dir() [](#method-i-spec_dir) - -## standard_gemfile() [](#method-i-standard_gemfile) - -## standard_gems() [](#method-i-standard_gems) - -## strip_whitespace(str) [](#method-i-strip_whitespace) - -## sys_exec(cmd, options{}, &block) [](#method-i-sys_exec) - -## system_gem_path(*path) [](#method-i-system_gem_path) - -## system_gems(*gems) [](#method-i-system_gems) - -## test_env_version() [](#method-i-test_env_version) -Bump this version whenever you make a breaking change to the spec setup that -requires regenerating tmp/. - -## test_gemfile() [](#method-i-test_gemfile) - -## the_bundle(*args) [](#method-i-the_bundle) - -## tmp(*path) [](#method-i-tmp) - -## tmp_root(scope) [](#method-i-tmp_root) - -## tmpdir(*args) [](#method-i-tmpdir) - -## tracked_files() [](#method-i-tracked_files) - -## vendored_gems(pathnil) [](#method-i-vendored_gems) - -## wait_for_server(host, port, seconds15) [](#method-i-wait_for_server) - -## with_built_bundler(versionnil, &block) [](#method-i-with_built_bundler) - -## with_env_vars(env_hash, &block) [](#method-i-with_env_vars) - -## with_fake_man() [](#method-i-with_fake_man) - -## with_gem_path_as(path) [](#method-i-with_gem_path_as) - -## with_path_added(path) [](#method-i-with_path_added) - -## with_path_as(path) [](#method-i-with_path_as) - -## with_read_only(pattern) [](#method-i-with_read_only) - -## without_env_side_effects() [](#method-i-without_env_side_effects) - diff --git a/example/ruby/Spec/Indexes.md b/example/ruby/Spec/Indexes.md deleted file mode 100644 index a46c15e..0000000 --- a/example/ruby/Spec/Indexes.md +++ /dev/null @@ -1,50 +0,0 @@ -# Module: Spec::Indexes - - - - - -#Instance Methods -## a_circular_index() [](#method-i-a_circular_index) - -## a_complex_conflict_index() [](#method-i-a_complex_conflict_index) - -## a_complicated_index() [](#method-i-a_complicated_index) -Issue #3459 - -## a_conflict_index() [](#method-i-a_conflict_index) -Builder 3.1.4 will activate first, but if all goes well, it should resolve to -3.0.4 - -## a_index_with_root_conflict_on_child() [](#method-i-a_index_with_root_conflict_on_child) - -## a_unresolvable_child_index() [](#method-i-a_unresolvable_child_index) - -## an_ambiguous_index() [](#method-i-an_ambiguous_index) - -## an_awesome_index() [](#method-i-an_awesome_index) - -## dep(name, reqsnil) [](#method-i-dep) - -## gem(*args, &blk) [](#method-i-gem) - -## index_with_conflict_on_child() [](#method-i-index_with_conflict_on_child) - -## locked(*args) [](#method-i-locked) - -## optional_prereleases_index() [](#method-i-optional_prereleases_index) - -## platform(*args) [](#method-i-platform) - -## resolve(args[], dependency_api_available:true) [](#method-i-resolve) - -## should_conservative_resolve_and_include(opts, unlock, specs) [](#method-i-should_conservative_resolve_and_include) - -## should_not_resolve() [](#method-i-should_not_resolve) - -## should_resolve_and_include(specs, args[]) [](#method-i-should_resolve_and_include) - -## should_resolve_as(specs) [](#method-i-should_resolve_as) - -## should_resolve_without_dependency_api(specs) [](#method-i-should_resolve_without_dependency_api) - diff --git a/example/ruby/Spec/Matchers.md b/example/ruby/Spec/Matchers.md deleted file mode 100644 index 342bf31..0000000 --- a/example/ruby/Spec/Matchers.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: Spec::Matchers - -**Extended by:** RSpec::Matchers - - - - -# Class Methods -## define_compound_matcher(matcher , preconditions , &declarations ) [](#method-c-define_compound_matcher) - -#Instance Methods -## indent(string, padding4, indent_character" ") [](#method-i-indent) - -## plugin_should_be_installed(*names) [](#method-i-plugin_should_be_installed) - -## plugin_should_not_be_installed(*names) [](#method-i-plugin_should_not_be_installed) - diff --git a/example/ruby/Spec/Matchers/Precondition.md b/example/ruby/Spec/Matchers/Precondition.md deleted file mode 100644 index 50c0257..0000000 --- a/example/ruby/Spec/Matchers/Precondition.md +++ /dev/null @@ -1,77 +0,0 @@ -# Class: Spec::Matchers::Precondition -**Inherits:** Object - -**Extended by:** Forwardable - -**Includes:** RSpec::Matchers::Composable - - - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor - -#Instance Methods -## does_not_match?(target, &blk) [](#method-i-does_not_match?) - -**@return** [Boolean] - -## expects_call_stack_jump?() [](#method-i-expects_call_stack_jump?) - -**@return** [Boolean] - -## failing_matcher() [](#method-i-failing_matcher) - -## initialize(matcher, preconditions) [](#method-i-initialize) - -**@return** [Precondition] a new instance of Precondition - -## matches?(target, &blk) [](#method-i-matches?) - -**@return** [Boolean] - -## supports_block_expectations?() [](#method-i-supports_block_expectations?) - -**@return** [Boolean] - diff --git a/example/ruby/Spec/Options.md b/example/ruby/Spec/Options.md deleted file mode 100644 index 8d7563f..0000000 --- a/example/ruby/Spec/Options.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Spec::Options - - - - - -#Instance Methods -## opt_add(option, options) [](#method-i-opt_add) - -## opt_remove(option, options) [](#method-i-opt_remove) - diff --git a/example/ruby/Spec/Path.md b/example/ruby/Spec/Path.md deleted file mode 100644 index 6053c76..0000000 --- a/example/ruby/Spec/Path.md +++ /dev/null @@ -1,200 +0,0 @@ -# Module: Spec::Path - -**Extended by:** Spec::Path - -**Includes:** Spec::Env - - - - -# Class Methods -## base_system_gem_path() [](#method-c-base_system_gem_path) -## base_system_gems() [](#method-c-base_system_gems) -## bindir() [](#method-c-bindir) -## bundled_app(*path ) [](#method-c-bundled_app) -## bundled_app2(*path ) [](#method-c-bundled_app2) -## bundled_app_gemfile() [](#method-c-bundled_app_gemfile) -## bundled_app_lock() [](#method-c-bundled_app_lock) -## cached_gem(path ) [](#method-c-cached_gem) -## default_bundle_path(*path ) [](#method-c-default_bundle_path) -## default_cache_path(*path ) [](#method-c-default_cache_path) -## dev_gemfile() [](#method-c-dev_gemfile) -## file_uri_for(path ) [](#method-c-file_uri_for) -## gem_bin() [](#method-c-gem_bin) -## gem_cmd() [](#method-c-gem_cmd) -## gem_repo1(*args ) [](#method-c-gem_repo1) -## gem_repo2(*args ) [](#method-c-gem_repo2) -## gem_repo3(*args ) [](#method-c-gem_repo3) -## gem_repo4(*args ) [](#method-c-gem_repo4) -## gem_repo_missing(*args ) [](#method-c-gem_repo_missing) -## gemspec() [](#method-c-gemspec) -## gemspec_dir() [](#method-c-gemspec_dir) -## git_root() [](#method-c-git_root) -## global_plugin_gem(*args ) [](#method-c-global_plugin_gem) -## home(*path ) [](#method-c-home) -## installed_bindir() [](#method-c-installed_bindir) -## lib_dir() [](#method-c-lib_dir) -## lib_path(*args ) [](#method-c-lib_path) -## lib_tracked_files() [](#method-c-lib_tracked_files) -## loaded_gemspec() [](#method-c-loaded_gemspec) -## local_gem_path(*path , base: bundled_app) [](#method-c-local_gem_path) -## local_plugin_gem(*args ) [](#method-c-local_plugin_gem) -## man_dir() [](#method-c-man_dir) -## man_tracked_files() [](#method-c-man_tracked_files) -## path() [](#method-c-path) -## pristine_system_gem_path() [](#method-c-pristine_system_gem_path) -## rake_path() [](#method-c-rake_path) -## relative_gemspec() [](#method-c-relative_gemspec) -## replace_required_ruby_version(version , dir: ) [](#method-c-replace_required_ruby_version) -## replace_version_file(version , dir: source_root) [](#method-c-replace_version_file) -## root() [](#method-c-root) -## rubocop_gemfile() [](#method-c-rubocop_gemfile) -## rubocop_gems() [](#method-c-rubocop_gems) -## ruby_core?() [](#method-c-ruby_core?) -**@return** [Boolean] - -## scope() [](#method-c-scope) -## scoped_gem_path(base ) [](#method-c-scoped_gem_path) -## security_repo(*args ) [](#method-c-security_repo) -## shipped_files() [](#method-c-shipped_files) -## source_lib_dir() [](#method-c-source_lib_dir) -## source_root() [](#method-c-source_root) -## spec_dir() [](#method-c-spec_dir) -## standard_gemfile() [](#method-c-standard_gemfile) -## standard_gems() [](#method-c-standard_gems) -## system_gem_path(*path ) [](#method-c-system_gem_path) -## test_env_version() [](#method-c-test_env_version) -Bump this version whenever you make a breaking change to the spec setup that -requires regenerating tmp/. -## test_gemfile() [](#method-c-test_gemfile) -## tmp(*path ) [](#method-c-tmp) -## tmp_root(scope ) [](#method-c-tmp_root) -## tmpdir(*args ) [](#method-c-tmpdir) -## tracked_files() [](#method-c-tracked_files) -## vendored_gems(path nil) [](#method-c-vendored_gems) - -#Instance Methods -## base_system_gem_path() [](#method-i-base_system_gem_path) - -## base_system_gems() [](#method-i-base_system_gems) - -## bindir() [](#method-i-bindir) - -## bundled_app(*path) [](#method-i-bundled_app) - -## bundled_app2(*path) [](#method-i-bundled_app2) - -## bundled_app_gemfile() [](#method-i-bundled_app_gemfile) - -## bundled_app_lock() [](#method-i-bundled_app_lock) - -## cached_gem(path) [](#method-i-cached_gem) - -## default_bundle_path(*path) [](#method-i-default_bundle_path) - -## default_cache_path(*path) [](#method-i-default_cache_path) - -## dev_gemfile() [](#method-i-dev_gemfile) - -## file_uri_for(path) [](#method-i-file_uri_for) - -## gem_bin() [](#method-i-gem_bin) - -## gem_cmd() [](#method-i-gem_cmd) - -## gem_repo1(*args) [](#method-i-gem_repo1) - -## gem_repo2(*args) [](#method-i-gem_repo2) - -## gem_repo3(*args) [](#method-i-gem_repo3) - -## gem_repo4(*args) [](#method-i-gem_repo4) - -## gem_repo_missing(*args) [](#method-i-gem_repo_missing) - -## gemspec() [](#method-i-gemspec) - -## gemspec_dir() [](#method-i-gemspec_dir) - -## git_root() [](#method-i-git_root) - -## global_plugin_gem(*args) [](#method-i-global_plugin_gem) - -## home(*path) [](#method-i-home) - -## installed_bindir() [](#method-i-installed_bindir) - -## lib_dir() [](#method-i-lib_dir) - -## lib_path(*args) [](#method-i-lib_path) - -## lib_tracked_files() [](#method-i-lib_tracked_files) - -## loaded_gemspec() [](#method-i-loaded_gemspec) - -## local_gem_path(*path, base:bundled_app) [](#method-i-local_gem_path) - -## local_plugin_gem(*args) [](#method-i-local_plugin_gem) - -## man_dir() [](#method-i-man_dir) - -## man_tracked_files() [](#method-i-man_tracked_files) - -## path() [](#method-i-path) - -## pristine_system_gem_path() [](#method-i-pristine_system_gem_path) - -## rake_path() [](#method-i-rake_path) - -## relative_gemspec() [](#method-i-relative_gemspec) - -## replace_required_ruby_version(version, dir:) [](#method-i-replace_required_ruby_version) - -## replace_version_file(version, dir:source_root) [](#method-i-replace_version_file) - -## root() [](#method-i-root) - -## rubocop_gemfile() [](#method-i-rubocop_gemfile) - -## rubocop_gems() [](#method-i-rubocop_gems) - -## ruby_core?() [](#method-i-ruby_core?) - -**@return** [Boolean] - -## scope() [](#method-i-scope) - -## scoped_gem_path(base) [](#method-i-scoped_gem_path) - -## security_repo(*args) [](#method-i-security_repo) - -## shipped_files() [](#method-i-shipped_files) - -## source_lib_dir() [](#method-i-source_lib_dir) - -## source_root() [](#method-i-source_root) - -## spec_dir() [](#method-i-spec_dir) - -## standard_gemfile() [](#method-i-standard_gemfile) - -## standard_gems() [](#method-i-standard_gems) - -## system_gem_path(*path) [](#method-i-system_gem_path) - -## test_env_version() [](#method-i-test_env_version) -Bump this version whenever you make a breaking change to the spec setup that -requires regenerating tmp/. - -## test_gemfile() [](#method-i-test_gemfile) - -## tmp(*path) [](#method-i-tmp) - -## tmp_root(scope) [](#method-i-tmp_root) - -## tmpdir(*args) [](#method-i-tmpdir) - -## tracked_files() [](#method-i-tracked_files) - -## vendored_gems(pathnil) [](#method-i-vendored_gems) - diff --git a/example/ruby/Spec/Permissions.md b/example/ruby/Spec/Permissions.md deleted file mode 100644 index 2b24ce2..0000000 --- a/example/ruby/Spec/Permissions.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: Spec::Permissions - - - - - -#Instance Methods -## with_umask(new_umask) [](#method-i-with_umask) - diff --git a/example/ruby/Spec/Platforms.md b/example/ruby/Spec/Platforms.md deleted file mode 100644 index 0012f07..0000000 --- a/example/ruby/Spec/Platforms.md +++ /dev/null @@ -1,55 +0,0 @@ -# Module: Spec::Platforms - -**Includes:** Bundler::GemHelpers - - - - - -#Instance Methods -## all_platforms() [](#method-i-all_platforms) - -## default_locked_platforms() [](#method-i-default_locked_platforms) - -## default_platform_list(*extra, defaults:default_locked_platforms) [](#method-i-default_platform_list) - -## java() [](#method-i-java) - -## linux() [](#method-i-linux) - -## local_engine_version() [](#method-i-local_engine_version) - -## local_ruby_engine() [](#method-i-local_ruby_engine) - -## local_tag() [](#method-i-local_tag) - -## lockfile_platforms(*extra, defaults:default_locked_platforms) [](#method-i-lockfile_platforms) - -## mac() [](#method-i-mac) - -## not_local() [](#method-i-not_local) - -## not_local_engine_version() [](#method-i-not_local_engine_version) - -## not_local_patchlevel() [](#method-i-not_local_patchlevel) - -## not_local_ruby_version() [](#method-i-not_local_ruby_version) - -## not_local_tag() [](#method-i-not_local_tag) - -## rb() [](#method-i-rb) - -## windows_platforms() [](#method-i-windows_platforms) - -## x64_mac() [](#method-i-x64_mac) - -## x64_mingw32() [](#method-i-x64_mingw32) - -## x64_mingw_ucrt() [](#method-i-x64_mingw_ucrt) - -## x64_mswin64() [](#method-i-x64_mswin64) - -## x86_mingw32() [](#method-i-x86_mingw32) - -## x86_mswin32() [](#method-i-x86_mswin32) - diff --git a/example/ruby/Spec/Rubygems.md b/example/ruby/Spec/Rubygems.md deleted file mode 100644 index f4a9d12..0000000 --- a/example/ruby/Spec/Rubygems.md +++ /dev/null @@ -1,37 +0,0 @@ -# Module: Spec::Rubygems - -**Extended by:** Spec::Rubygems - - - - -# Class Methods -## check_source_control_changes(success_message: , error_message: ) [](#method-c-check_source_control_changes) -## dev_setup() [](#method-c-dev_setup) -## gem_load(gem_name , bin_container ) [](#method-c-gem_load) -## gem_load_and_possibly_install(gem_name , bin_container ) [](#method-c-gem_load_and_possibly_install) -## gem_require(gem_name , entrypoint ) [](#method-c-gem_require) -## install_parallel_test_deps() [](#method-c-install_parallel_test_deps) -## install_test_deps() [](#method-c-install_test_deps) -## setup_test_paths() [](#method-c-setup_test_paths) -## test_setup() [](#method-c-test_setup) - -#Instance Methods -## check_source_control_changes(success_message:, error_message:) [](#method-i-check_source_control_changes) - -## dev_setup() [](#method-i-dev_setup) - -## gem_load(gem_name, bin_container) [](#method-i-gem_load) - -## gem_load_and_possibly_install(gem_name, bin_container) [](#method-i-gem_load_and_possibly_install) - -## gem_require(gem_name, entrypoint) [](#method-i-gem_require) - -## install_parallel_test_deps() [](#method-i-install_parallel_test_deps) - -## install_test_deps() [](#method-i-install_test_deps) - -## setup_test_paths() [](#method-i-setup_test_paths) - -## test_setup() [](#method-i-test_setup) - diff --git a/example/ruby/Spec/SilentLogger.md b/example/ruby/Spec/SilentLogger.md deleted file mode 100644 index 0bdca3b..0000000 --- a/example/ruby/Spec/SilentLogger.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Spec::SilentLogger -**Inherits:** Object - - - - - diff --git a/example/ruby/Spec/Subprocess.md b/example/ruby/Spec/Subprocess.md deleted file mode 100644 index 93b978b..0000000 --- a/example/ruby/Spec/Subprocess.md +++ /dev/null @@ -1,28 +0,0 @@ -# Module: Spec::Subprocess - - - - - -#Instance Methods -## all_commands_output() [](#method-i-all_commands_output) - -## command_executions() [](#method-i-command_executions) - -## err() [](#method-i-err) - -## exitstatus() [](#method-i-exitstatus) - -## git(cmd, pathDir.pwd, options{}) [](#method-i-git) - -## last_command() [](#method-i-last_command) - -## out() [](#method-i-out) - -## read_stream(stream, handler, timeout:) [](#method-i-read_stream) -Mostly copied from -https://github.com/piotrmurach/tty-command/blob/49c37a895ccea107e8b78d20e4cb29 -de6a1a53c8/lib/tty/command/process_runner.rb#L165-L193 - -## sh(cmd, options{}) [](#method-i-sh) - diff --git a/example/ruby/Spec/Subprocess/TimeoutExceeded.md b/example/ruby/Spec/Subprocess/TimeoutExceeded.md deleted file mode 100644 index 27a1472..0000000 --- a/example/ruby/Spec/Subprocess/TimeoutExceeded.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: Spec::Subprocess::TimeoutExceeded -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Spec/TheBundle.md b/example/ruby/Spec/TheBundle.md deleted file mode 100644 index 492815a..0000000 --- a/example/ruby/Spec/TheBundle.md +++ /dev/null @@ -1,152 +0,0 @@ -# Class: Spec::TheBundle -**Inherits:** Object - -**Includes:** Spec::Path - - - - -# Attributes -## bundle_dir[RW] [](#attribute-i-bundle_dir) -Returns the value of attribute bundle_dir. - - -#Instance Methods -## base_system_gem_path() [](#method-i-base_system_gem_path) - -## base_system_gems() [](#method-i-base_system_gems) - -## bindir() [](#method-i-bindir) - -## bundled_app(*path) [](#method-i-bundled_app) - -## bundled_app2(*path) [](#method-i-bundled_app2) - -## bundled_app_gemfile() [](#method-i-bundled_app_gemfile) - -## bundled_app_lock() [](#method-i-bundled_app_lock) - -## cached_gem(path) [](#method-i-cached_gem) - -## default_bundle_path(*path) [](#method-i-default_bundle_path) - -## default_cache_path(*path) [](#method-i-default_cache_path) - -## dev_gemfile() [](#method-i-dev_gemfile) - -## file_uri_for(path) [](#method-i-file_uri_for) - -## gem_bin() [](#method-i-gem_bin) - -## gem_cmd() [](#method-i-gem_cmd) - -## gem_repo1(*args) [](#method-i-gem_repo1) - -## gem_repo2(*args) [](#method-i-gem_repo2) - -## gem_repo3(*args) [](#method-i-gem_repo3) - -## gem_repo4(*args) [](#method-i-gem_repo4) - -## gem_repo_missing(*args) [](#method-i-gem_repo_missing) - -## gemspec() [](#method-i-gemspec) - -## gemspec_dir() [](#method-i-gemspec_dir) - -## git_root() [](#method-i-git_root) - -## global_plugin_gem(*args) [](#method-i-global_plugin_gem) - -## home(*path) [](#method-i-home) - -## initialize(opts{}) [](#method-i-initialize) - -**@return** [TheBundle] a new instance of TheBundle - -## installed_bindir() [](#method-i-installed_bindir) - -## lib_dir() [](#method-i-lib_dir) - -## lib_path(*args) [](#method-i-lib_path) - -## lib_tracked_files() [](#method-i-lib_tracked_files) - -## loaded_gemspec() [](#method-i-loaded_gemspec) - -## local_gem_path(*path, base:bundled_app) [](#method-i-local_gem_path) - -## local_plugin_gem(*args) [](#method-i-local_plugin_gem) - -## locked?() [](#method-i-locked?) - -**@return** [Boolean] - -## locked_gems() [](#method-i-locked_gems) - -## lockfile() [](#method-i-lockfile) - -## man_dir() [](#method-i-man_dir) - -## man_tracked_files() [](#method-i-man_tracked_files) - -## path() [](#method-i-path) - -## pristine_system_gem_path() [](#method-i-pristine_system_gem_path) - -## rake_path() [](#method-i-rake_path) - -## relative_gemspec() [](#method-i-relative_gemspec) - -## replace_required_ruby_version(version, dir:) [](#method-i-replace_required_ruby_version) - -## replace_version_file(version, dir:source_root) [](#method-i-replace_version_file) - -## root() [](#method-i-root) - -## rubocop_gemfile() [](#method-i-rubocop_gemfile) - -## rubocop_gems() [](#method-i-rubocop_gems) - -## ruby_core?() [](#method-i-ruby_core?) - -**@return** [Boolean] - -## scope() [](#method-i-scope) - -## scoped_gem_path(base) [](#method-i-scoped_gem_path) - -## security_repo(*args) [](#method-i-security_repo) - -## shipped_files() [](#method-i-shipped_files) - -## source_lib_dir() [](#method-i-source_lib_dir) - -## source_root() [](#method-i-source_root) - -## spec_dir() [](#method-i-spec_dir) - -## standard_gemfile() [](#method-i-standard_gemfile) - -## standard_gems() [](#method-i-standard_gems) - -## system_gem_path(*path) [](#method-i-system_gem_path) - -## test_env_version() [](#method-i-test_env_version) -Bump this version whenever you make a breaking change to the spec setup that -requires regenerating tmp/. - -## test_gemfile() [](#method-i-test_gemfile) - -## tmp(*path) [](#method-i-tmp) - -## tmp_root(scope) [](#method-i-tmp_root) - -## tmpdir(*args) [](#method-i-tmpdir) - -## to_s() [](#method-i-to_s) - -## tracked_files() [](#method-i-tracked_files) - -## vendored_gems(pathnil) [](#method-i-vendored_gems) - diff --git a/example/ruby/SpecEvaluate.md b/example/ruby/SpecEvaluate.md deleted file mode 100644 index 72fc8fa..0000000 --- a/example/ruby/SpecEvaluate.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: SpecEvaluate -**Inherits:** Object - -**Includes:** MSpecMatchers - - - - -# Class Methods -## desc() [](#method-c-desc) -## desc=(desc ) [](#method-c-desc=) - -#Instance Methods -## define(&block) [](#method-i-define) - -## format(ruby, newlinetrue) [](#method-i-format) -Formats the Ruby source code for reabable output in the -fs formatter option. -If the source contains no newline characters, wraps the source in single -quotes to set if off from the rest of the description string. If the source -does contain newline characters, sets the indent level to four characters. - -## initialize(ruby, desc) [](#method-i-initialize) - -**@return** [SpecEvaluate] a new instance of SpecEvaluate - diff --git a/example/ruby/SpecExpectation.md b/example/ruby/SpecExpectation.md deleted file mode 100644 index 0baa3b0..0000000 --- a/example/ruby/SpecExpectation.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: SpecExpectation -**Inherits:** Object - - - - -# Class Methods -## fail_predicate(receiver , predicate , args , block , result , expectation ) [](#method-c-fail_predicate) -**@raise** [SpecExpectationNotMetError] - -## fail_single_arg_predicate(receiver , predicate , arg , result , expectation ) [](#method-c-fail_single_arg_predicate) -## fail_with(expected , actual ) [](#method-c-fail_with) -**@raise** [SpecExpectationNotMetError] - - diff --git a/example/ruby/SpecExpectationNotFoundError.md b/example/ruby/SpecExpectationNotFoundError.md deleted file mode 100644 index 0524435..0000000 --- a/example/ruby/SpecExpectationNotFoundError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: SpecExpectationNotFoundError -**Inherits:** StandardError - - - - - -#Instance Methods -## message() [](#method-i-message) - diff --git a/example/ruby/SpecExpectationNotMetError.md b/example/ruby/SpecExpectationNotMetError.md deleted file mode 100644 index c18f8db..0000000 --- a/example/ruby/SpecExpectationNotMetError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: SpecExpectationNotMetError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/SpecGuard.md b/example/ruby/SpecGuard.md deleted file mode 100644 index 9c7166f..0000000 --- a/example/ruby/SpecGuard.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: SpecGuard -**Inherits:** Object - - - - -# Class Methods -## clear() [](#method-c-clear) -## clear_guards() [](#method-c-clear_guards) -## finish() [](#method-c-finish) -## guards() [](#method-c-guards) -## report() [](#method-c-report) -## ruby_version(which :minor) [](#method-c-ruby_version) -Returns a partial Ruby version string based on `which`. For example, if -RUBY_VERSION = 8.2.3: - - :major => "8" - :minor => "8.2" - :tiny => "8.2.3" - :teeny => "8.2.3" - :full => "8.2.3" -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## add(example) [](#method-i-add) - -## initialize(*args) [](#method-i-initialize) - -**@return** [SpecGuard] a new instance of SpecGuard - -## match?() [](#method-i-match?) - -**@return** [Boolean] - -## record(description) [](#method-i-record) - -## report_key() [](#method-i-report_key) - -## reporting?() [](#method-i-reporting?) - -**@return** [Boolean] - -## run_if(name, &block) [](#method-i-run_if) - -## run_unless(name, &block) [](#method-i-run_unless) - -## unregister() [](#method-i-unregister) - -## yield?(invertfalse) [](#method-i-yield?) - -**@return** [Boolean] - diff --git a/example/ruby/SpecNegativeOperatorMatcher.md b/example/ruby/SpecNegativeOperatorMatcher.md deleted file mode 100644 index 0566fc8..0000000 --- a/example/ruby/SpecNegativeOperatorMatcher.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: SpecNegativeOperatorMatcher -**Inherits:** BasicObject - - - - - -#Instance Methods -## !=(expected) [](#method-i-!=) - -## ==(expected) [](#method-i-==) - -## equal?(expected) [](#method-i-equal?) - -**@return** [Boolean] - -## initialize(actual) [](#method-i-initialize) - -**@return** [SpecNegativeOperatorMatcher] a new instance of SpecNegativeOperatorMatcher - -## method_missing(name, *args, &block) [](#method-i-method_missing) - diff --git a/example/ruby/SpecPositiveOperatorMatcher.md b/example/ruby/SpecPositiveOperatorMatcher.md deleted file mode 100644 index c1188fa..0000000 --- a/example/ruby/SpecPositiveOperatorMatcher.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: SpecPositiveOperatorMatcher -**Inherits:** BasicObject - - - - - -#Instance Methods -## !=(expected) [](#method-i-!=) - -## ==(expected) [](#method-i-==) - -## equal?(expected) [](#method-i-equal?) - -**@return** [Boolean] - -## initialize(actual) [](#method-i-initialize) - -**@return** [SpecPositiveOperatorMatcher] a new instance of SpecPositiveOperatorMatcher - -## method_missing(name, *args, &block) [](#method-i-method_missing) - diff --git a/example/ruby/SpecTag.md b/example/ruby/SpecTag.md deleted file mode 100644 index 0fa892c..0000000 --- a/example/ruby/SpecTag.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: SpecTag -**Inherits:** Object - - - - -# Attributes -## comment[RW] [](#attribute-i-comment) -Returns the value of attribute comment. - -## description[RW] [](#attribute-i-description) -Returns the value of attribute description. - -## tag[RW] [](#attribute-i-tag) -Returns the value of attribute tag. - - -#Instance Methods -## ==(o) [](#method-i-==) - -## escape(str) [](#method-i-escape) - -## initialize(stringnil) [](#method-i-initialize) - -**@return** [SpecTag] a new instance of SpecTag - -## parse(string) [](#method-i-parse) - -## to_s() [](#method-i-to_s) - -## unescape(str) [](#method-i-unescape) - diff --git a/example/ruby/SpecVersion.md b/example/ruby/SpecVersion.md deleted file mode 100644 index 0df041a..0000000 --- a/example/ruby/SpecVersion.md +++ /dev/null @@ -1,114 +0,0 @@ -# Class: SpecVersion -**Inherits:** Object - -**Includes:** Comparable - - - - - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## initialize(version, ceilfalse) [](#method-i-initialize) -SpecVersion handles comparison correctly for the context by filling in missing -version parts according to the value of `ceil`. If `ceil` is `false`, 0 digits -fill in missing version parts. If `ceil` is `true`, 9 digits fill in missing -parts. (See e.g. VersionGuard and BugGuard.) - -**@return** [SpecVersion] a new instance of SpecVersion - -## to_i() [](#method-i-to_i) -Converts a string representation of a version major.minor.tiny to an integer -representation so that comparisons can be made. For example, "2.2.10" < -"2.2.2" would be false if compared as strings. - -## to_int() [](#method-i-to_int) - -## to_s() [](#method-i-to_s) - -## to_str() [](#method-i-to_str) - diff --git a/example/ruby/SpecdocFormatter.md b/example/ruby/SpecdocFormatter.md deleted file mode 100644 index 04260f9..0000000 --- a/example/ruby/SpecdocFormatter.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: SpecdocFormatter -**Inherits:** BaseFormatter - - - - - -#Instance Methods -## after(statenil) [](#method-i-after) -Callback for the MSpec :after event. Prints a newline to finish the -description string output. - -## before(state) [](#method-i-before) -Callback for the MSpec :before event. Prints the `it` block string. - -## enter(describe) [](#method-i-enter) -Callback for the MSpec :enter event. Prints the `describe` block string. - -## exception(exception) [](#method-i-exception) -Callback for the MSpec :exception event. Prints either 'ERROR - X' or 'FAILED -- X' where *X* is the sequential number of the exception raised. If there has -already been an exception raised while evaluating this example, it prints -another `it` block description string so that each description string has an -associated 'ERROR' or 'FAILED' - -## register() [](#method-i-register) - diff --git a/example/ruby/SpecificExampleException.md b/example/ruby/SpecificExampleException.md deleted file mode 100644 index c5ac678..0000000 --- a/example/ruby/SpecificExampleException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: SpecificExampleException -**Inherits:** StandardError - - - - - diff --git a/example/ruby/Specs.md b/example/ruby/Specs.md deleted file mode 100644 index 87fff69..0000000 --- a/example/ruby/Specs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Specs - - - - - diff --git a/example/ruby/Specs/Kernel.md b/example/ruby/Specs/Kernel.md deleted file mode 100644 index 69677e6..0000000 --- a/example/ruby/Specs/Kernel.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Specs::Kernel - - - - - diff --git a/example/ruby/Specs/Kernel/HasEqual.md b/example/ruby/Specs/Kernel/HasEqual.md deleted file mode 100644 index c8d38c1..0000000 --- a/example/ruby/Specs/Kernel/HasEqual.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Specs::Kernel::HasEqual -**Inherits:** Object - - - - - -#Instance Methods -## equal?(other) [](#method-i-equal?) - -**@return** [Boolean] - diff --git a/example/ruby/Specs/Kernel/HasNone.md b/example/ruby/Specs/Kernel/HasNone.md deleted file mode 100644 index c59edcc..0000000 --- a/example/ruby/Specs/Kernel/HasNone.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Specs::Kernel::HasNone -**Inherits:** Object - - - - - diff --git a/example/ruby/Specs/Kernel/HasOpEqual.md b/example/ruby/Specs/Kernel/HasOpEqual.md deleted file mode 100644 index 3d18df6..0000000 --- a/example/ruby/Specs/Kernel/HasOpEqual.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Specs::Kernel::HasOpEqual -**Inherits:** Object - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - diff --git a/example/ruby/Specs/Kernel/HasOppoOpEqual.md b/example/ruby/Specs/Kernel/HasOppoOpEqual.md deleted file mode 100644 index 570fd44..0000000 --- a/example/ruby/Specs/Kernel/HasOppoOpEqual.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Specs::Kernel::HasOppoOpEqual -**Inherits:** Object - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## equal?(other) [](#method-i-equal?) - -**@return** [Boolean] - diff --git a/example/ruby/SpellCheckerTest.md b/example/ruby/SpellCheckerTest.md deleted file mode 100644 index fdaaad6..0000000 --- a/example/ruby/SpellCheckerTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: SpellCheckerTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_spell_checker_corrects_misspells() [](#method-i-test_spell_checker_corrects_misspells) - -## test_spell_checker_corrects_mistypes() [](#method-i-test_spell_checker_corrects_mistypes) - -## test_spell_checker_excludes_input_from_dictionary() [](#method-i-test_spell_checker_excludes_input_from_dictionary) - -## test_spell_checker_sorts_results_by_simiarity() [](#method-i-test_spell_checker_sorts_results_by_simiarity) - diff --git a/example/ruby/Sphere.md b/example/ruby/Sphere.md deleted file mode 100644 index 6c1a808..0000000 --- a/example/ruby/Sphere.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Sphere -**Inherits:** Object - - - - -# Attributes -## center[RW] [](#attribute-i-center) -Returns the value of attribute center. - -## radius[RW] [](#attribute-i-radius) -Returns the value of attribute radius. - - -#Instance Methods -## initialize(center, radius) [](#method-i-initialize) - -**@return** [Sphere] a new instance of Sphere - -## intersect(ray, isect) [](#method-i-intersect) - diff --git a/example/ruby/SpinnerFormatter.md b/example/ruby/SpinnerFormatter.md deleted file mode 100644 index d13e729..0000000 --- a/example/ruby/SpinnerFormatter.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: SpinnerFormatter -**Inherits:** BaseFormatter - - - - -# Attributes -## length[RW] [](#attribute-i-length) -Returns the value of attribute length. - - -#Instance Methods -## after(statenil) [](#method-i-after) -Callback for the MSpec :after event. Updates the spinner. - -## clear_progress_line() [](#method-i-clear_progress_line) - -## compute_etr() [](#method-i-compute_etr) - -## compute_percentage() [](#method-i-compute_percentage) - -## compute_progress() [](#method-i-compute_progress) - -## exception(exception) [](#method-i-exception) -Callback for the MSpec :exception event. Changes the color used to display the -tally of errors and failures - -## initialize(outnil) [](#method-i-initialize) - -**@return** [SpinnerFormatter] a new instance of SpinnerFormatter - -## progress_line() [](#method-i-progress_line) - -## register() [](#method-i-register) - -## start() [](#method-i-start) -Callback for the MSpec :start event. Stores the total number of files that -will be processed. - -## unload() [](#method-i-unload) -Callback for the MSpec :unload event. Increments the number of files that have -been run. - diff --git a/example/ruby/SquigglyHeredocSpecs.md b/example/ruby/SquigglyHeredocSpecs.md deleted file mode 100644 index 15d386b..0000000 --- a/example/ruby/SquigglyHeredocSpecs.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: SquigglyHeredocSpecs - - - - -# Class Methods -## backslash() [](#method-c-backslash) -## blank() [](#method-c-blank) -## doublequoted() [](#method-c-doublequoted) -## least_indented_on_the_first_line() [](#method-c-least_indented_on_the_first_line) -## least_indented_on_the_first_line_single() [](#method-c-least_indented_on_the_first_line_single) -## least_indented_on_the_last_line() [](#method-c-least_indented_on_the_last_line) -## least_indented_on_the_last_line_single() [](#method-c-least_indented_on_the_last_line_single) -## message() [](#method-c-message) -## singlequoted() [](#method-c-singlequoted) -## unquoted() [](#method-c-unquoted) - diff --git a/example/ruby/StandardError.md b/example/ruby/StandardError.md deleted file mode 100644 index 325cbe3..0000000 --- a/example/ruby/StandardError.md +++ /dev/null @@ -1,23 +0,0 @@ -# Exception: StandardError -**Inherits:** Exception - - -The most standard error types are subclasses of StandardError. A rescue clause -without an explicit Exception class will rescue all StandardErrors (and only -those). - - def foo - raise "Oups" - end - foo rescue "Hello" #=> "Hello" - -On the other hand: - - require 'does/not/exist' rescue "Hi" - -*raises the exception:* - - LoadError: no such file to load -- does/not/exist - - - diff --git a/example/ruby/StatsPerFileFormatter.md b/example/ruby/StatsPerFileFormatter.md deleted file mode 100644 index 21d48f6..0000000 --- a/example/ruby/StatsPerFileFormatter.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: StatsPerFileFormatter -**Inherits:** BaseFormatter - - - - - -#Instance Methods -## finish() [](#method-i-finish) - -## initialize(outnil) [](#method-i-initialize) - -**@return** [StatsPerFileFormatter] a new instance of StatsPerFileFormatter - -## load() [](#method-i-load) -Resets the tallies so the counts are only for this file. - -## register() [](#method-i-register) - -## unload() [](#method-i-unload) - diff --git a/example/ruby/StopIteration.md b/example/ruby/StopIteration.md deleted file mode 100644 index d15c9fa..0000000 --- a/example/ruby/StopIteration.md +++ /dev/null @@ -1,47 +0,0 @@ -# Exception: StopIteration -**Inherits:** IndexError - - -Raised to stop the iteration, in particular by Enumerator#next. It is rescued -by Kernel#loop. - - loop do - puts "Hello" - raise StopIteration - puts "World" - end - puts "Done!" - -*produces:* - - Hello - Done! - - - -#Instance Methods -## result() [](#method-i-result) -Returns the return value of the iterator. - - o = Object.new - def o.each - yield 1 - yield 2 - yield 3 - 100 - end - - e = o.to_enum - - puts e.next #=> 1 - puts e.next #=> 2 - puts e.next #=> 3 - - begin - e.next - rescue StopIteration => ex - puts ex.result #=> 100 - end - -**@overload** [] - diff --git a/example/ruby/String.md b/example/ruby/String.md deleted file mode 100644 index 75442aa..0000000 --- a/example/ruby/String.md +++ /dev/null @@ -1,2024 +0,0 @@ -# Class: String -**Inherits:** Object - -**Includes:** Comparable - - -Allows us to write cleaner tests since <<~EOM block quotes strip off all -leading indentation and we need it to be preserved sometimes. - - -# Class Methods -## new(*args ) [](#method-c-new) -:nodoc: -## try_convert(str ) [](#method-c-try_convert) -If `object` is a `String` object, returns `object`. - -Otherwise if `object` responds to `:to_str`, calls `object.to_str` and returns -the result. - -Returns `nil` if `object` does not respond to `:to_str`. - -Raises an exception unless `object.to_str` returns a `String` object. -**@overload** [] - - -#Instance Methods -## %(arg) [](#method-i-%) -Returns the result of formatting `object` into the format specification `self` -(see Kernel#sprintf for formatting details): - - "%05d" % 123 # => "00123" - -If `self` contains multiple substitutions, `object` must be an Array or Hash -containing the values to be substituted: - - "%-5s: %016x" % [ "ID", self.object_id ] # => "ID : 00002b054ec93168" - "foo = %{foo}" % {foo: 'bar'} # => "foo = bar" - "foo = %{foo}, baz = %{baz}" % {foo: 'bar', baz: 'bat'} # => "foo = bar, baz = bat" - -**@overload** [] - -## *(times) [](#method-i-*) -Returns a new `String` containing `integer` copies of `self`: - - "Ho! " * 3 # => "Ho! Ho! Ho! " - "Ho! " * 0 # => "" - -**@overload** [] - -## +(str2) [](#method-i-+) -Returns a new `String` containing `other_string` concatenated to `self`: - - "Hello from " + self.to_s # => "Hello from main" - -**@overload** [] - -## +@() [](#method-i-+@) -Returns `self` if `self` is not frozen and can be mutated without warning -issuance. - -Otherwise returns `self.dup`, which is not frozen. - -**@overload** [] - -## -(a) [](#method-i--) - -## -@() [](#method-i--@) -Returns a frozen, possibly pre-existing copy of the string. - -The returned `String` will be deduplicated as long as it does not have any -instance variables set on it and is not a String subclass. - -Note that `-string` variant is more convenient for defining constants: - - FILENAME = -'config/database.yml' - -while `dedup` is better suitable for using the method in chains of -calculations: - - @url_list.concat(urls.map(&:dedup)) - -**@overload** [] - -**@overload** [] - -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <<(str2) [](#method-i-<<) -Concatenates `object` to `self` and returns `self`: - - s = 'foo' - s << 'bar' # => "foobar" - s # => "foobar" - -If `object` is an Integer, the value is considered a codepoint and converted -to a character before concatenation: - - s = 'foo' - s << 33 # => "foo!" - -If that codepoint is not representable in the encoding of *string*, RangeError -is raised. - - s = 'foo' - s.encoding # => - s << 0x00110000 # 1114112 out of char range (RangeError) - s = 'foo'.encode('EUC-JP') - s << 0x00800080 # invalid codepoint 0x800080 in EUC-JP (RangeError) - -If the encoding is US-ASCII and the codepoint is 0..0xff, *string* is -automatically promoted to ASCII-8BIT. - - s = 'foo'.encode('US-ASCII') - s << 0xff - s.encoding # => # - -Related: String#concat, which takes multiple arguments. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(str2) [](#method-i-<=>) -Compares `self` and `other_string`, returning: - -* -1 if `other_string` is larger. -* 0 if the two are equal. -* 1 if `other_string` is smaller. -* `nil` if the two are incomparable. - -Examples: - - 'foo' <=> 'foo' # => 0 - 'foo' <=> 'food' # => -1 - 'food' <=> 'foo' # => 1 - 'FOO' <=> 'foo' # => -1 - 'foo' <=> 'FOO' # => 1 - 'foo' <=> 1 # => nil - -**@overload** [] - -## ==(str2) [](#method-i-==) -Returns `true` if `object` has the same length and content; as `self`; `false` -otherwise: - - s = 'foo' - s == 'foo' # => true - s == 'food' # => false - s == 'FOO' # => false - -Returns `false` if the two strings' encodings are not compatible: - "\u{e4 f6 fc}".encode("ISO-8859-1") == ("\u{c4 d6 dc}") # => false - -If `object` is not an instance of `String` but responds to `to_str`, then the -two strings are compared using `object.==`. - -**@overload** [] - -**@overload** [] - -## ===(str2) [](#method-i-===) -Returns `true` if `object` has the same length and content; as `self`; `false` -otherwise: - - s = 'foo' - s == 'foo' # => true - s == 'food' # => false - s == 'FOO' # => false - -Returns `false` if the two strings' encodings are not compatible: - "\u{e4 f6 fc}".encode("ISO-8859-1") == ("\u{c4 d6 dc}") # => false - -If `object` is not an instance of `String` but responds to `to_str`, then the -two strings are compared using `object.==`. - -**@overload** [] - -**@overload** [] - -## =~(y) [](#method-i-=~) -Returns the Integer index of the first substring that matches the given -`regexp`, or `nil` if no match found: - - 'foo' =~ /f/ # => 0 - 'foo' =~ /o/ # => 1 - 'foo' =~ /x/ # => nil - -Note: also updates Regexp@Global+Variables. - -If the given `object` is not a Regexp, returns the value returned by `object -=~ self`. - -Note that `string =~ regexp` is different from `regexp =~ string` (see -Regexp#=~): - - number= nil - "no. 9" =~ /(?\d+)/ - number # => nil (not assigned) - /(?\d+)/ =~ "no. 9" - number #=> "9" - -**@overload** [] - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## [](*a) [](#method-i-[]) -Returns the substring of `self` specified by the arguments. See examples at -[String Slices](rdoc-ref:String@String+Slices). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## []=(*args) [](#method-i-[]=) -Replaces all, some, or none of the contents of `self`; returns `new_string`. -See [String Slices](rdoc-ref:String@String+Slices). - -A few examples: - - s = 'foo' - s[2] = 'rtune' # => "rtune" - s # => "fortune" - s[1, 5] = 'init' # => "init" - s # => "finite" - s[3..4] = 'al' # => "al" - s # => "finale" - s[/e$/] = 'ly' # => "ly" - s # => "finally" - s['lly'] = 'ncial' # => "ncial" - s # => "financial" - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## append_as_bytes(*args) [](#method-i-append_as_bytes) -Concatenates each object in `objects` into `self` without any encoding -validation or conversion and returns `self`: - - s = 'foo' - s.append_as_bytes(" \xE2\x82") # => "foo \xE2\x82" - s.valid_encoding? # => false - s.append_as_bytes("\xAC 12") - s.valid_encoding? # => true - -For each given object `object` that is an Integer, the value is considered a -Byte. If the Integer is bigger than one byte, only the lower byte is -considered, similar to String#setbyte: - - s = "" - s.append_as_bytes(0, 257) # => "\u0000\u0001" - -Related: String#<<, String#concat, which do an encoding aware concatenation. - -**@overload** [] - -## ascii_only?() [](#method-i-ascii_only?) -Returns `true` if `self` contains only ASCII characters, `false` otherwise: - - 'abc'.ascii_only? # => true - "abc\u{6666}".ascii_only? # => false - -**@overload** [] - -## b() [](#method-i-b) -:include: doc/string/b.rdoc - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## byteindex(*args) [](#method-i-byteindex) -Returns the Integer byte-based index of the first occurrence of the given -`substring`, or `nil` if none found: - - 'foo'.byteindex('f') # => 0 - 'foo'.byteindex('o') # => 1 - 'foo'.byteindex('oo') # => 1 - 'foo'.byteindex('ooo') # => nil - -Returns the Integer byte-based index of the first match for the given Regexp -`regexp`, or `nil` if none found: - - 'foo'.byteindex(/f/) # => 0 - 'foo'.byteindex(/o/) # => 1 - 'foo'.byteindex(/oo/) # => 1 - 'foo'.byteindex(/ooo/) # => nil - -Integer argument `offset`, if given, specifies the byte-based position in the -string to begin the search: - - 'foo'.byteindex('o', 1) # => 1 - 'foo'.byteindex('o', 2) # => 2 - 'foo'.byteindex('o', 3) # => nil - -If `offset` is negative, counts backward from the end of `self`: - - 'foo'.byteindex('o', -1) # => 2 - 'foo'.byteindex('o', -2) # => 1 - 'foo'.byteindex('o', -3) # => 1 - 'foo'.byteindex('o', -4) # => nil - -If `offset` does not land on character (codepoint) boundary, `IndexError` is -raised. - -Related: String#index, String#byterindex. - -**@overload** [] - -**@overload** [] - -## byterindex(*args) [](#method-i-byterindex) -Returns the Integer byte-based index of the *last* occurrence of the given -`substring`, or `nil` if none found: - - 'foo'.byterindex('f') # => 0 - 'foo'.byterindex('o') # => 2 - 'foo'.byterindex('oo') # => 1 - 'foo'.byterindex('ooo') # => nil - -Returns the Integer byte-based index of the *last* match for the given Regexp -`regexp`, or `nil` if none found: - - 'foo'.byterindex(/f/) # => 0 - 'foo'.byterindex(/o/) # => 2 - 'foo'.byterindex(/oo/) # => 1 - 'foo'.byterindex(/ooo/) # => nil - -The *last* match means starting at the possible last position, not the last of -longest matches. - - 'foo'.byterindex(/o+/) # => 2 - $~ #=> # - -To get the last longest match, needs to combine with negative lookbehind. - - 'foo'.byterindex(/(? 1 - $~ #=> # - -Or String#byteindex with negative lookforward. - - 'foo'.byteindex(/o+(?!.*o)/) # => 1 - $~ #=> # - -Integer argument `offset`, if given and non-negative, specifies the maximum -starting byte-based position in the string to *end* the search: - - 'foo'.byterindex('o', 0) # => nil - 'foo'.byterindex('o', 1) # => 1 - 'foo'.byterindex('o', 2) # => 2 - 'foo'.byterindex('o', 3) # => 2 - -If `offset` is a negative Integer, the maximum starting position in the string -to *end* the search is the sum of the string's length and `offset`: - - 'foo'.byterindex('o', -1) # => 2 - 'foo'.byterindex('o', -2) # => 1 - 'foo'.byterindex('o', -3) # => nil - 'foo'.byterindex('o', -4) # => nil - -If `offset` does not land on character (codepoint) boundary, `IndexError` is -raised. - -Related: String#byteindex. - -**@overload** [] - -**@overload** [] - -## bytes() [](#method-i-bytes) -:include: doc/string/bytes.rdoc - -**@overload** [] - -## bytesize() [](#method-i-bytesize) -:include: doc/string/bytesize.rdoc - -**@overload** [] - -## byteslice(*args) [](#method-i-byteslice) -Returns a substring of `self`, or `nil` if the substring cannot be -constructed. - -With integer arguments `index` and `length` given, returns the substring -beginning at the given `index` of the given `length` (if possible), or `nil` -if `length` is negative or `index` falls outside of `self`: - - s = '0123456789' # => "0123456789" - s.byteslice(2) # => "2" - s.byteslice(200) # => nil - s.byteslice(4, 3) # => "456" - s.byteslice(4, 30) # => "456789" - s.byteslice(4, -1) # => nil - s.byteslice(40, 2) # => nil - -In either case above, counts backwards from the end of `self` if `index` is -negative: - - s = '0123456789' # => "0123456789" - s.byteslice(-4) # => "6" - s.byteslice(-4, 3) # => "678" - -With Range argument `range` given, returns `byteslice(range.begin, -range.size)`: - - s = '0123456789' # => "0123456789" - s.byteslice(4..6) # => "456" - s.byteslice(-6..-4) # => "456" - s.byteslice(5..2) # => "" # range.size is zero. - s.byteslice(40..42) # => nil - -In all cases, a returned string has the same encoding as `self`: - - s.encoding # => # - s.byteslice(4).encoding # => # - -**@overload** [] - -**@overload** [] - -## bytesplice(*args) [](#method-i-bytesplice) -Replaces some or all of the content of `self` with `str`, and returns `self`. -The portion of the string affected is determined using the same criteria as -String#byteslice, except that `length` cannot be omitted. If the replacement -string is not the same length as the text it is replacing, the string will be -adjusted accordingly. - -If `str_index` and `str_length`, or `str_range` are given, the content of -`self` is replaced by str.byteslice(str_index, str_length) or -str.byteslice(str_range); however the substring of `str` is not allocated as a -new string. - -The form that take an Integer will raise an IndexError if the value is out of -range; the Range form will raise a RangeError. If the beginning or ending -offset does not land on character (codepoint) boundary, an IndexError will be -raised. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## capitalize(*args) [](#method-i-capitalize) -Returns a string containing the characters in `self`; the first character is -upcased; the remaining characters are downcased: - - s = 'hello World!' # => "hello World!" - s.capitalize # => "Hello world!" - -The casing may be affected by the given `options`; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#capitalize!. - -**@overload** [] - -## capitalize!(*args) [](#method-i-capitalize!) -Upcases the first character in `self`; downcases the remaining characters; -returns `self` if any changes were made, `nil` otherwise: - - s = 'hello World!' # => "hello World!" - s.capitalize! # => "Hello world!" - s # => "Hello world!" - s.capitalize! # => nil - -The casing may be affected by the given `options`; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#capitalize. - -**@overload** [] - -## casecmp(str2) [](#method-i-casecmp) -Compares `self.downcase` and `other_string.downcase`; returns: - -* -1 if `other_string.downcase` is larger. -* 0 if the two are equal. -* 1 if `other_string.downcase` is smaller. -* `nil` if the two are incomparable. - -Examples: - - 'foo'.casecmp('foo') # => 0 - 'foo'.casecmp('food') # => -1 - 'food'.casecmp('foo') # => 1 - 'FOO'.casecmp('foo') # => 0 - 'foo'.casecmp('FOO') # => 0 - 'foo'.casecmp(1) # => nil - -See [Case Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#casecmp?. - -**@overload** [] - -## casecmp?(str2) [](#method-i-casecmp?) -Returns `true` if `self` and `other_string` are equal after Unicode case -folding, otherwise `false`: - - 'foo'.casecmp?('foo') # => true - 'foo'.casecmp?('food') # => false - 'food'.casecmp?('foo') # => false - 'FOO'.casecmp?('foo') # => true - 'foo'.casecmp?('FOO') # => true - -Returns `nil` if the two values are incomparable: - - 'foo'.casecmp?(1) # => nil - -See [Case Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#casecmp. - -**@overload** [] - -## center(*args) [](#method-i-center) -:include: doc/string/center.rdoc - -Related: String#ljust, String#rjust. - -**@overload** [] - -## chars() [](#method-i-chars) -:include: doc/string/chars.rdoc - -**@overload** [] - -## chomp(*args) [](#method-i-chomp) -:include: doc/string/chomp.rdoc - -**@overload** [] - -## chomp!(*args) [](#method-i-chomp!) -Like String#chomp, but modifies `self` in place; returns `nil` if no -modification made, `self` otherwise. - -**@overload** [] - -## chop() [](#method-i-chop) -:include: doc/string/chop.rdoc - -**@overload** [] - -## chop!() [](#method-i-chop!) -Like String#chop, but modifies `self` in place; returns `nil` if `self` is -empty, `self` otherwise. - -Related: String#chomp!. - -**@overload** [] - -## chr() [](#method-i-chr) -Returns a string containing the first character of `self`: - - s = 'foo' # => "foo" - s.chr # => "f" - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## clear() [](#method-i-clear) -Removes the contents of `self`: - - s = 'foo' # => "foo" - s.clear # => "" - -**@overload** [] - -## codepoints() [](#method-i-codepoints) -:include: doc/string/codepoints.rdoc - -**@overload** [] - -## color(forenil, backnil, opts{}, bold:false, underscore:false) [](#method-i-color) - -## concat(*args) [](#method-i-concat) -Concatenates each object in `objects` to `self` and returns `self`: - - s = 'foo' - s.concat('bar', 'baz') # => "foobarbaz" - s # => "foobarbaz" - -For each given object `object` that is an Integer, the value is considered a -codepoint and converted to a character before concatenation: - - s = 'foo' - s.concat(32, 'bar', 32, 'baz') # => "foo bar baz" - -Related: String#<<, which takes a single argument. - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the total number of characters in `self` that are specified by the -given `selectors` (see [Multiple Character -Selectors](rdoc-ref:character_selectors.rdoc@Multiple+Character+Selectors)): - - a = "hello world" - a.count "lo" #=> 5 - a.count "lo", "o" #=> 2 - a.count "hello", "^l" #=> 4 - a.count "ej-m" #=> 4 - - "hello^world".count "\\^aeiou" #=> 4 - "hello-world".count "a\\-eo" #=> 4 - - c = "hello world\\r\\n" - c.count "\\" #=> 2 - c.count "\\A" #=> 0 - c.count "X-\\w" #=> 3 - -**@overload** [] - -## crypt(salt) [](#method-i-crypt) -Returns the string generated by calling `crypt(3)` standard library function -with `str` and `salt_str`, in this order, as its arguments. Please do not use -this method any longer. It is legacy; provided only for backward -compatibility with ruby scripts in earlier days. It is bad to use in -contemporary programs for several reasons: - -* Behaviour of C's `crypt(3)` depends on the OS it is run. The generated - string lacks data portability. - -* On some OSes such as Mac OS, `crypt(3)` never fails (i.e. silently ends up - in unexpected results). - -* On some OSes such as Mac OS, `crypt(3)` is not thread safe. - -* So-called "traditional" usage of `crypt(3)` is very very very weak. - According to its manpage, Linux's traditional `crypt(3)` output has only - 2**56 variations; too easy to brute force today. And this is the default - behaviour. - -* In order to make things robust some OSes implement so-called "modular" - usage. To go through, you have to do a complex build-up of the `salt_str` - parameter, by hand. Failure in generation of a proper salt string tends - not to yield any errors; typos in parameters are normally not detectable. - - * For instance, in the following example, the second invocation of - String#crypt is wrong; it has a typo in "round=" (lacks "s"). However - the call does not fail and something unexpected is generated. - - "foo".crypt("$5$rounds=1000$salt$") # OK, proper usage - "foo".crypt("$5$round=1000$salt$") # Typo not detected - -* Even in the "modular" mode, some hash functions are considered archaic and - no longer recommended at all; for instance module `$1$` is officially - abandoned by its author: see http://phk.freebsd.dk/sagas/md5crypt_eol/ . - For another instance module `$3$` is considered completely broken: see the - manpage of FreeBSD. - -* On some OS such as Mac OS, there is no modular mode. Yet, as written - above, `crypt(3)` on Mac OS never fails. This means even if you build up a - proper salt string it generates a traditional DES hash anyways, and there - is no way for you to be aware of. - - "foo".crypt("$5$rounds=1000$salt$") # => "$5fNPQMxC5j6." - -If for some reason you cannot migrate to other secure contemporary password -hashing algorithms, install the string-crypt gem and `require 'string/crypt'` -to continue using it. - -**@overload** [] - -## dedup() [](#method-i-dedup) -Returns a frozen, possibly pre-existing copy of the string. - -The returned `String` will be deduplicated as long as it does not have any -instance variables set on it and is not a String subclass. - -Note that `-string` variant is more convenient for defining constants: - - FILENAME = -'config/database.yml' - -while `dedup` is better suitable for using the method in chains of -calculations: - - @url_list.concat(urls.map(&:dedup)) - -**@overload** [] - -**@overload** [] - -## delete(*args) [](#method-i-delete) -Returns a copy of `self` with characters specified by `selectors` removed (see -[Multiple Character -Selectors](rdoc-ref:character_selectors.rdoc@Multiple+Character+Selectors)): - - "hello".delete "l","lo" #=> "heo" - "hello".delete "lo" #=> "he" - "hello".delete "aeiou", "^e" #=> "hell" - "hello".delete "ej-m" #=> "ho" - -**@overload** [] - -## delete!(*args) [](#method-i-delete!) -Like String#delete, but modifies `self` in place. Returns `self` if any -changes were made, `nil` otherwise. - -**@overload** [] - -## delete_prefix(prefix) [](#method-i-delete_prefix) -:include: doc/string/delete_prefix.rdoc - -**@overload** [] - -## delete_prefix!(prefix) [](#method-i-delete_prefix!) -Like String#delete_prefix, except that `self` is modified in place. Returns -`self` if the prefix is removed, `nil` otherwise. - -**@overload** [] - -## delete_suffix(suffix) [](#method-i-delete_suffix) -:include: doc/string/delete_suffix.rdoc - -**@overload** [] - -## delete_suffix!(suffix) [](#method-i-delete_suffix!) -Like String#delete_suffix, except that `self` is modified in place. Returns -`self` if the suffix is removed, `nil` otherwise. - -**@overload** [] - -## downcase(*args) [](#method-i-downcase) -Returns a string containing the downcased characters in `self`: - - s = 'Hello World!' # => "Hello World!" - s.downcase # => "hello world!" - -The casing may be affected by the given `options`; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#downcase!, String#upcase, String#upcase!. - -**@overload** [] - -## downcase!(*args) [](#method-i-downcase!) -Downcases the characters in `self`; returns `self` if any changes were made, -`nil` otherwise: - - s = 'Hello World!' # => "Hello World!" - s.downcase! # => "hello world!" - s # => "hello world!" - s.downcase! # => nil - -The casing may be affected by the given `options`; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#downcase, String#upcase, String#upcase!. - -**@overload** [] - -## dump() [](#method-i-dump) -Returns a printable version of `self`, enclosed in double-quotes, with special -characters escaped, and with non-printing characters replaced by hexadecimal -notation: - - "hello \n ''".dump # => "\"hello \\n ''\"" - "\f\x00\xff\\\"".dump # => "\"\\f\\x00\\xFF\\\\\\\"\"" - -Related: String#undump (inverse of String#dump). - -**@overload** [] - -## dup() [](#method-i-dup) -:nodoc: - -## each_byte() [](#method-i-each_byte) -:include: doc/string/each_byte.rdoc - -**@overload** [] - -**@overload** [] - -## each_char() [](#method-i-each_char) -:include: doc/string/each_char.rdoc - -**@overload** [] - -**@overload** [] - -## each_codepoint() [](#method-i-each_codepoint) -:include: doc/string/each_codepoint.rdoc - -**@overload** [] - -**@overload** [] - -## each_grapheme_cluster() [](#method-i-each_grapheme_cluster) -:include: doc/string/each_grapheme_cluster.rdoc - -**@overload** [] - -**@overload** [] - -## each_line(*args) [](#method-i-each_line) -:include: doc/string/each_line.rdoc - -**@overload** [] - -**@overload** [] - -## empty?() [](#method-i-empty?) -Returns `true` if the length of `self` is zero, `false` otherwise: - - "hello".empty? # => false - " ".empty? # => false - "".empty? # => true - -**@overload** [] - -## encode(*args) [](#method-i-encode) -:include: doc/string/encode.rdoc - -**@overload** [] - -**@overload** [] - -## encode!(*args) [](#method-i-encode!) -Like #encode, but applies encoding changes to `self`; returns `self`. - -**@overload** [] - -**@overload** [] - -## encoding() [](#method-i-encoding) - -## end_with?(*args) [](#method-i-end_with?) -:include: doc/string/end_with_p.rdoc - -**@overload** [] - -## eql?(str2) [](#method-i-eql?) -Returns `true` if `object` has the same length and content; - as +self+; +false+ otherwise: - - s = 'foo' - s.eql?('foo') # => true - s.eql?('food') # => false - s.eql?('FOO') # => false - - Returns +false+ if the two strings' encodings are not compatible: - - "\u{e4 f6 fc}".encode("ISO-8859-1").eql?("\u{c4 d6 dc}") # => false - -**@overload** [] - -## force_encoding(enc) [](#method-i-force_encoding) -:include: doc/string/force_encoding.rdoc - -**@overload** [] - -## freeze() [](#method-i-freeze) -:nodoc: - -## funcall_style() [](#method-i-funcall_style) - -## getbyte(index) [](#method-i-getbyte) -Returns the byte at zero-based `index` as an integer, or `nil` if `index` is -out of range: - - s = 'abcde' # => "abcde" - s.getbyte(0) # => 97 - s.getbyte(-1) # => 101 - s.getbyte(5) # => nil - -Related: String#setbyte. - -**@overload** [] - -## grapheme_clusters() [](#method-i-grapheme_clusters) -:include: doc/string/grapheme_clusters.rdoc - -**@overload** [] - -## gsub(*args) [](#method-i-gsub) -Returns a copy of `self` with all occurrences of the given `pattern` replaced. - -See [Substitution Methods](rdoc-ref:String@Substitution+Methods). - -Returns an Enumerator if no `replacement` and no block given. - -Related: String#sub, String#sub!, String#gsub!. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## gsub!(*args) [](#method-i-gsub!) -Performs the specified substring replacement(s) on `self`; returns `self` if -any replacement occurred, `nil` otherwise. - -See [Substitution Methods](rdoc-ref:String@Substitution+Methods). - -Returns an Enumerator if no `replacement` and no block given. - -Related: String#sub, String#gsub, String#sub!. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -Returns the integer hash value for `self`. The value is based on the length, -content and encoding of `self`. - -Related: Object#hash. - -**@overload** [] - -## hex() [](#method-i-hex) -Interprets the leading substring of `self` as a string of hexadecimal digits -(with an optional sign and an optional `0x`) and returns the corresponding -number; returns zero if there is no such leading substring: - - '0x0a'.hex # => 10 - '-1234'.hex # => -4660 - '0'.hex # => 0 - 'non-numeric'.hex # => 0 - -Related: String#oct. - -**@overload** [] - -## include?(arg) [](#method-i-include?) -Returns `true` if `self` contains `other_string`, `false` otherwise: - - s = 'foo' - s.include?('f') # => true - s.include?('fo') # => true - s.include?('food') # => false - -**@overload** [] - -## indent(number) [](#method-i-indent) - -## index(*args) [](#method-i-index) -:include: doc/string/index.rdoc - -**@overload** [] - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -:include: doc/string/new.rdoc - -**@overload** [] - -## initialize_copy(str2) [](#method-i-initialize_copy) -Replaces the contents of `self` with the contents of `other_string`: - - s = 'foo' # => "foo" - s.replace('bar') # => "bar" - -**@overload** [] - -## insert(idx, str2) [](#method-i-insert) -Inserts the given `other_string` into `self`; returns `self`. - -If the Integer `index` is positive, inserts `other_string` at offset `index`: - - 'foo'.insert(1, 'bar') # => "fbaroo" - -If the Integer `index` is negative, counts backward from the end of `self` and -inserts `other_string` at offset `index+1` (that is, *after* `self[index]`): - - 'foo'.insert(-2, 'bar') # => "fobaro" - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a printable version of `self`, enclosed in double-quotes, and with -special characters escaped: - - s = "foo\tbar\tbaz\n" - s.inspect - # => "\"foo\\tbar\\tbaz\\n\"" - -**@overload** [] - -## intern() [](#method-i-intern) - -## kjust(len) [](#method-i-kjust) - -## length() [](#method-i-length) -:include: doc/string/length.rdoc - -**@overload** [] - -## lines(*args) [](#method-i-lines) -Forms substrings ("lines") of `self` according to the given arguments (see -String#each_line for details); returns the lines in an array. - -**@overload** [] - -## ljust(*args) [](#method-i-ljust) -:include: doc/string/ljust.rdoc - -Related: String#rjust, String#center. - -**@overload** [] - -## lstrip() [](#method-i-lstrip) -Returns a copy of `self` with leading whitespace removed; see [Whitespace in -Strings](rdoc-ref:String@Whitespace+in+Strings): - - whitespace = "\x00\t\n\v\f\r " - s = whitespace + 'abc' + whitespace - s # => "\u0000\t\n\v\f\r abc\u0000\t\n\v\f\r " - s.lstrip # => "abc\u0000\t\n\v\f\r " - -Related: String#rstrip, String#strip. - -**@overload** [] - -## lstrip!() [](#method-i-lstrip!) -Like String#lstrip, except that any modifications are made in `self`; returns -`self` if any modification are made, `nil` otherwise. - -Related: String#rstrip!, String#strip!. - -**@overload** [] - -## match(*args) [](#method-i-match) -Returns a MatchData object (or `nil`) based on `self` and the given `pattern`. - -Note: also updates Regexp@Global+Variables. - -* Computes `regexp` by converting `pattern` (if not already a Regexp). - regexp = Regexp.new(pattern) - -* Computes `matchdata`, which will be either a MatchData object or `nil` - (see Regexp#match): - matchdata = regexp.match(self) - -With no block given, returns the computed `matchdata`: - - 'foo'.match('f') # => # - 'foo'.match('o') # => # - 'foo'.match('x') # => nil - -If Integer argument `offset` is given, the search begins at index `offset`: - - 'foo'.match('f', 1) # => nil - 'foo'.match('o', 1) # => # - -With a block given, calls the block with the computed `matchdata` and returns -the block's return value: - - 'foo'.match(/o/) {|matchdata| matchdata } # => # - 'foo'.match(/x/) {|matchdata| matchdata } # => nil - 'foo'.match(/f/, 1) {|matchdata| matchdata } # => nil - -**@overload** [] - -**@overload** [] - -## match?(*args) [](#method-i-match?) -Returns `true` or `false` based on whether a match is found for `self` and -`pattern`. - -Note: does not update Regexp@Global+Variables. - -Computes `regexp` by converting `pattern` (if not already a Regexp). - regexp = Regexp.new(pattern) - -Returns `true` if `self+.match(regexp)` returns a MatchData object, `false` -otherwise: - - 'foo'.match?(/o/) # => true - 'foo'.match?('o') # => true - 'foo'.match?(/x/) # => false - -If Integer argument `offset` is given, the search begins at index `offset`: - 'foo'.match?('f', 1) # => false - 'foo'.match?('o', 1) # => true - -**@overload** [] - -## next() [](#method-i-next) -Returns the successor to `self`. The successor is calculated by incrementing -characters. - -The first character to be incremented is the rightmost alphanumeric: or, if no -alphanumerics, the rightmost character: - - 'THX1138'.succ # => "THX1139" - '<>'.succ # => "<>" - '***'.succ # => '**+' - -The successor to a digit is another digit, "carrying" to the next-left -character for a "rollover" from 9 to 0, and prepending another digit if -necessary: - - '00'.succ # => "01" - '09'.succ # => "10" - '99'.succ # => "100" - -The successor to a letter is another letter of the same case, carrying to the -next-left character for a rollover, and prepending another same-case letter if -necessary: - - 'aa'.succ # => "ab" - 'az'.succ # => "ba" - 'zz'.succ # => "aaa" - 'AA'.succ # => "AB" - 'AZ'.succ # => "BA" - 'ZZ'.succ # => "AAA" - -The successor to a non-alphanumeric character is the next character in the -underlying character set's collating sequence, carrying to the next-left -character for a rollover, and prepending another character if necessary: - - s = 0.chr * 3 - s # => "\x00\x00\x00" - s.succ # => "\x00\x00\x01" - s = 255.chr * 3 - s # => "\xFF\xFF\xFF" - s.succ # => "\x01\x00\x00\x00" - -Carrying can occur between and among mixtures of alphanumeric characters: - - s = 'zz99zz99' - s.succ # => "aaa00aa00" - s = '99zz99zz' - s.succ # => "100aa00aa" - -The successor to an empty `String` is a new empty `String`: - - ''.succ # => "" - -**@overload** [] - -## next!() [](#method-i-next!) -Equivalent to String#succ, but modifies `self` in place; returns `self`. - -**@overload** [] - -## oct() [](#method-i-oct) -Interprets the leading substring of `self` as a string of octal digits (with -an optional sign) and returns the corresponding number; returns zero if there -is no such leading substring: - - '123'.oct # => 83 - '-377'.oct # => -255 - '0377non-numeric'.oct # => 255 - 'non-numeric'.oct # => 0 - -If `self` starts with `0`, radix indicators are honored; see Kernel#Integer. - -Related: String#hex. - -**@overload** [] - -## ord() [](#method-i-ord) -:include: doc/string/ord.rdoc - -**@overload** [] - -## partition(sep) [](#method-i-partition) -:include: doc/string/partition.rdoc - -**@overload** [] - -## prepend(*args) [](#method-i-prepend) -Prepends each string in `other_strings` to `self` and returns `self`: - - s = 'foo' - s.prepend('bar', 'baz') # => "barbazfoo" - s # => "barbazfoo" - -Related: String#concat. - -**@overload** [] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## quote() [](#method-i-quote) -Wraps a string in escaped quotes if it contains whitespace. - -## replace(str2) [](#method-i-replace) -Replaces the contents of `self` with the contents of `other_string`: - - s = 'foo' # => "foo" - s.replace('bar') # => "bar" - -**@overload** [] - -## reverse() [](#method-i-reverse) -Returns a new string with the characters from `self` in reverse order. - - 'stressed'.reverse # => "desserts" - -**@overload** [] - -## reverse!() [](#method-i-reverse!) -Returns `self` with its characters reversed: - - s = 'stressed' - s.reverse! # => "desserts" - s # => "desserts" - -**@overload** [] - -## rindex(*args) [](#method-i-rindex) -Returns the Integer index of the *last* occurrence of the given `substring`, -or `nil` if none found: - - 'foo'.rindex('f') # => 0 - 'foo'.rindex('o') # => 2 - 'foo'.rindex('oo') # => 1 - 'foo'.rindex('ooo') # => nil - -Returns the Integer index of the *last* match for the given Regexp `regexp`, -or `nil` if none found: - - 'foo'.rindex(/f/) # => 0 - 'foo'.rindex(/o/) # => 2 - 'foo'.rindex(/oo/) # => 1 - 'foo'.rindex(/ooo/) # => nil - -The *last* match means starting at the possible last position, not the last of -longest matches. - - 'foo'.rindex(/o+/) # => 2 - $~ #=> # - -To get the last longest match, needs to combine with negative lookbehind. - - 'foo'.rindex(/(? 1 - $~ #=> # - -Or String#index with negative lookforward. - - 'foo'.index(/o+(?!.*o)/) # => 1 - $~ #=> # - -Integer argument `offset`, if given and non-negative, specifies the maximum -starting position in the string to *end* the search: - - 'foo'.rindex('o', 0) # => nil - 'foo'.rindex('o', 1) # => 1 - 'foo'.rindex('o', 2) # => 2 - 'foo'.rindex('o', 3) # => 2 - -If `offset` is a negative Integer, the maximum starting position in the string -to *end* the search is the sum of the string's length and `offset`: - - 'foo'.rindex('o', -1) # => 2 - 'foo'.rindex('o', -2) # => 1 - 'foo'.rindex('o', -3) # => nil - 'foo'.rindex('o', -4) # => nil - -Related: String#index. - -**@overload** [] - -**@overload** [] - -## rjust(*args) [](#method-i-rjust) -:include: doc/string/rjust.rdoc - -Related: String#ljust, String#center. - -**@overload** [] - -## rpartition(sep) [](#method-i-rpartition) -:include: doc/string/rpartition.rdoc - -**@overload** [] - -## rstrip() [](#method-i-rstrip) -Returns a copy of the receiver with trailing whitespace removed; see -[Whitespace in Strings](rdoc-ref:String@Whitespace+in+Strings): - - whitespace = "\x00\t\n\v\f\r " - s = whitespace + 'abc' + whitespace - s # => "\u0000\t\n\v\f\r abc\u0000\t\n\v\f\r " - s.rstrip # => "\u0000\t\n\v\f\r abc" - -Related: String#lstrip, String#strip. - -**@overload** [] - -## rstrip!() [](#method-i-rstrip!) -Like String#rstrip, except that any modifications are made in `self`; returns -`self` if any modification are made, `nil` otherwise. - -Related: String#lstrip!, String#strip!. - -**@overload** [] - -## sans_arguments() [](#method-i-sans_arguments) - -## scan(pat) [](#method-i-scan) -Matches a pattern against `self`; the pattern is: - -* `string_or_regexp` itself, if it is a Regexp. -* `Regexp.quote(string_or_regexp)`, if `string_or_regexp` is a string. - -Iterates through `self`, generating a collection of matching results: - -* If the pattern contains no groups, each result is the matched string, - `$&`. -* If the pattern contains groups, each result is an array containing one - entry per group. - -With no block given, returns an array of the results: - - s = 'cruel world' - s.scan(/\w+/) # => ["cruel", "world"] - s.scan(/.../) # => ["cru", "el ", "wor"] - s.scan(/(...)/) # => [["cru"], ["el "], ["wor"]] - s.scan(/(..)(..)/) # => [["cr", "ue"], ["l ", "wo"]] - -With a block given, calls the block with each result; returns `self`: - - s.scan(/\w+/) {|w| print "<<#{w}>> " } - print "\n" - s.scan(/(.)(.)/) {|x,y| print y, x } - print "\n" - -Output: - - <> <> - rceu lowlr - -**@overload** [] - -**@overload** [] - -## scrub(*args) [](#method-i-scrub) -:include: doc/string/scrub.rdoc - -**@overload** [] - -**@overload** [] - -## scrub!(*args) [](#method-i-scrub!) -Like String#scrub, except that any replacements are made in `self`. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## setbyte(index, value) [](#method-i-setbyte) -Sets the byte at zero-based `index` to `integer`; returns `integer`: - - s = 'abcde' # => "abcde" - s.setbyte(0, 98) # => 98 - s # => "bbcde" - -Related: String#getbyte. - -**@overload** [] - -## shellescape() [](#method-i-shellescape) -call-seq: - str.shellescape => string - -Escapes `str` so that it can be safely used in a Bourne shell command line. - -See Shellwords.shellescape for details. - -## shellsplit() [](#method-i-shellsplit) -call-seq: - str.shellsplit => array - -Splits `str` into an array of tokens in the same way the UNIX Bourne shell -does. - -See Shellwords.shellsplit for details. - -## size() [](#method-i-size) -:include: doc/string/length.rdoc - -**@overload** [] - -## slice(*args) [](#method-i-slice) -Returns the substring of `self` specified by the arguments. See examples at -[String Slices](rdoc-ref:String@String+Slices). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## slice!(*args) [](#method-i-slice!) -Removes and returns the substring of `self` specified by the arguments. See -[String Slices](rdoc-ref:String@String+Slices). - -A few examples: - - string = "This is a string" - string.slice!(2) #=> "i" - string.slice!(3..6) #=> " is " - string.slice!(/s.*t/) #=> "sa st" - string.slice!("r") #=> "r" - string #=> "Thing" - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## split(*args) [](#method-i-split) -:include: doc/string/split.rdoc - -**@overload** [] - -**@overload** [] - -## squeeze(*args) [](#method-i-squeeze) -Returns a copy of `self` with characters specified by `selectors` "squeezed" -(see [Multiple Character -Selectors](rdoc-ref:character_selectors.rdoc@Multiple+Character+Selectors)): - -"Squeezed" means that each multiple-character run of a selected character is -squeezed down to a single character; with no arguments given, squeezes all -characters: - - "yellow moon".squeeze #=> "yelow mon" - " now is the".squeeze(" ") #=> " now is the" - "putters shoot balls".squeeze("m-z") #=> "puters shot balls" - -**@overload** [] - -## squeeze!(*args) [](#method-i-squeeze!) -Like String#squeeze, but modifies `self` in place. Returns `self` if any -changes were made, `nil` otherwise. - -**@overload** [] - -## start_with?(*prefixes) [](#method-i-start_with?) -:include: doc/string/start_with_p.rdoc - -**@overload** [] - -## strip() [](#method-i-strip) -Returns a copy of the receiver with leading and trailing whitespace removed; -see [Whitespace in Strings](rdoc-ref:String@Whitespace+in+Strings): - - whitespace = "\x00\t\n\v\f\r " - s = whitespace + 'abc' + whitespace - s # => "\u0000\t\n\v\f\r abc\u0000\t\n\v\f\r " - s.strip # => "abc" - -Related: String#lstrip, String#rstrip. - -**@overload** [] - -## strip!() [](#method-i-strip!) -Like String#strip, except that any modifications are made in `self`; returns -`self` if any modification are made, `nil` otherwise. - -Related: String#lstrip!, String#strip!. - -**@overload** [] - -## sub(*args) [](#method-i-sub) -Returns a copy of `self` with only the first occurrence (not all occurrences) -of the given `pattern` replaced. - -See [Substitution Methods](rdoc-ref:String@Substitution+Methods). - -Related: String#sub!, String#gsub, String#gsub!. - -**@overload** [] - -**@overload** [] - -## sub!(*args) [](#method-i-sub!) -Replaces the first occurrence (not all occurrences) of the given `pattern` on -`self`; returns `self` if a replacement occurred, `nil` otherwise. - -See [Substitution Methods](rdoc-ref:String@Substitution+Methods). - -Related: String#sub, String#gsub, String#gsub!. - -**@overload** [] - -**@overload** [] - -## succ() [](#method-i-succ) -Returns the successor to `self`. The successor is calculated by incrementing -characters. - -The first character to be incremented is the rightmost alphanumeric: or, if no -alphanumerics, the rightmost character: - - 'THX1138'.succ # => "THX1139" - '<>'.succ # => "<>" - '***'.succ # => '**+' - -The successor to a digit is another digit, "carrying" to the next-left -character for a "rollover" from 9 to 0, and prepending another digit if -necessary: - - '00'.succ # => "01" - '09'.succ # => "10" - '99'.succ # => "100" - -The successor to a letter is another letter of the same case, carrying to the -next-left character for a rollover, and prepending another same-case letter if -necessary: - - 'aa'.succ # => "ab" - 'az'.succ # => "ba" - 'zz'.succ # => "aaa" - 'AA'.succ # => "AB" - 'AZ'.succ # => "BA" - 'ZZ'.succ # => "AAA" - -The successor to a non-alphanumeric character is the next character in the -underlying character set's collating sequence, carrying to the next-left -character for a rollover, and prepending another character if necessary: - - s = 0.chr * 3 - s # => "\x00\x00\x00" - s.succ # => "\x00\x00\x01" - s = 255.chr * 3 - s # => "\xFF\xFF\xFF" - s.succ # => "\x01\x00\x00\x00" - -Carrying can occur between and among mixtures of alphanumeric characters: - - s = 'zz99zz99' - s.succ # => "aaa00aa00" - s = '99zz99zz' - s.succ # => "100aa00aa" - -The successor to an empty `String` is a new empty `String`: - - ''.succ # => "" - -**@overload** [] - -## succ!() [](#method-i-succ!) -Equivalent to String#succ, but modifies `self` in place; returns `self`. - -**@overload** [] - -## sum(*args) [](#method-i-sum) -:include: doc/string/sum.rdoc - -**@overload** [] - -## swapcase(*args) [](#method-i-swapcase) -Returns a string containing the characters in `self`, with cases reversed; -each uppercase character is downcased; each lowercase character is upcased: - - s = 'Hello World!' # => "Hello World!" - s.swapcase # => "hELLO wORLD!" - -The casing may be affected by the given `options`; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#swapcase!. - -**@overload** [] - -## swapcase!(*args) [](#method-i-swapcase!) -Upcases each lowercase character in `self`; downcases uppercase character; -returns `self` if any changes were made, `nil` otherwise: - - s = 'Hello World!' # => "Hello World!" - s.swapcase! # => "hELLO wORLD!" - s # => "hELLO wORLD!" - ''.swapcase! # => nil - -The casing may be affected by the given `options`; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#swapcase. - -**@overload** [] - -## to_a() [](#method-i-to_a) - -## to_c() [](#method-i-to_c) -Returns `self` interpreted as a Complex object; leading whitespace and -trailing garbage are ignored: - - '9'.to_c # => (9+0i) - '2.5'.to_c # => (2.5+0i) - '2.5/1'.to_c # => ((5/2)+0i) - '-3/2'.to_c # => ((-3/2)+0i) - '-i'.to_c # => (0-1i) - '45i'.to_c # => (0+45i) - '3-4i'.to_c # => (3-4i) - '-4e2-4e-2i'.to_c # => (-400.0-0.04i) - '-0.0-0.0i'.to_c # => (-0.0-0.0i) - '1/2+3/4i'.to_c # => ((1/2)+(3/4)*i) - '1.0@0'.to_c # => (1+0.0i) - "1.0@#{Math::PI/2}".to_c # => (0.0+1i) - "1.0@#{Math::PI}".to_c # => (-1+0.0i) - -Returns Complex zero if the string cannot be converted: - - 'ruby'.to_c # => (0+0i) - -See Kernel#Complex. - -**@overload** [] - -## to_f() [](#method-i-to_f) -Returns the result of interpreting leading characters in `self` as a Float: - - '3.14159'.to_f # => 3.14159 - '1.234e-2'.to_f # => 0.01234 - -Characters past a leading valid number (in the given `base`) are ignored: - - '3.14 (pi to two places)'.to_f # => 3.14 - -Returns zero if there is no leading valid number: - - 'abcdef'.to_f # => 0.0 - -**@overload** [] - -## to_i(*args) [](#method-i-to_i) -Returns the result of interpreting leading characters in `self` as an integer -in the given `base` (which must be in (0, 2..36)): - - '123456'.to_i # => 123456 - '123def'.to_i(16) # => 1195503 - -With `base` zero, string `object` may contain leading characters to specify -the actual base: - - '123def'.to_i(0) # => 123 - '0123def'.to_i(0) # => 83 - '0b123def'.to_i(0) # => 1 - '0o123def'.to_i(0) # => 83 - '0d123def'.to_i(0) # => 123 - '0x123def'.to_i(0) # => 1195503 - -Characters past a leading valid number (in the given `base`) are ignored: - - '12.345'.to_i # => 12 - '12345'.to_i(2) # => 1 - -Returns zero if there is no leading valid number: - - 'abcdef'.to_i # => 0 - '2'.to_i(2) # => 0 - -**@overload** [] - -## to_r() [](#method-i-to_r) -Returns the result of interpreting leading characters in `str` as a rational. -Leading whitespace and extraneous characters past the end of a valid number -are ignored. Digit sequences can be separated by an underscore. If there is -not a valid number at the start of `str`, zero is returned. This method never -raises an exception. - - ' 2 '.to_r #=> (2/1) - '300/2'.to_r #=> (150/1) - '-9.2'.to_r #=> (-46/5) - '-9.2e2'.to_r #=> (-920/1) - '1_234_567'.to_r #=> (1234567/1) - '21 June 09'.to_r #=> (21/1) - '21/06/09'.to_r #=> (7/2) - 'BWV 1079'.to_r #=> (0/1) - -NOTE: "0.3".to_r isn't the same as 0.3.to_r. The former is equivalent to -"3/10".to_r, but the latter isn't so. - - "0.3".to_r == 3/10r #=> true - 0.3.to_r == 3/10r #=> false - -See also Kernel#Rational. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns `self` if `self` is a `String`, or `self` converted to a `String` if -`self` is a subclass of `String`. - -**@overload** [] - -## to_str() [](#method-i-to_str) -Returns `self` if `self` is a `String`, or `self` converted to a `String` if -`self` is a subclass of `String`. - -**@overload** [] - -## to_sym() [](#method-i-to_sym) - -## tr(src, repl) [](#method-i-tr) -Returns a copy of `self` with each character specified by string `selector` -translated to the corresponding character in string `replacements`. The -correspondence is *positional*: - -* Each occurrence of the first character specified by `selector` is - translated to the first character in `replacements`. -* Each occurrence of the second character specified by `selector` is - translated to the second character in `replacements`. -* And so on. - -Example: - - 'hello'.tr('el', 'ip') #=> "hippo" - -If `replacements` is shorter than `selector`, it is implicitly padded with its -own last character: - - 'hello'.tr('aeiou', '-') # => "h-ll-" - 'hello'.tr('aeiou', 'AA-') # => "hAll-" - -Arguments `selector` and `replacements` must be valid character selectors (see -[Character Selectors](rdoc-ref:character_selectors.rdoc)), and may use any of -its valid forms, including negation, ranges, and escaping: - - # Negation. - 'hello'.tr('^aeiou', '-') # => "-e--o" - # Ranges. - 'ibm'.tr('b-z', 'a-z') # => "hal" - # Escapes. - 'hel^lo'.tr('\^aeiou', '-') # => "h-l-l-" # Escaped leading caret. - 'i-b-m'.tr('b\-z', 'a-z') # => "ibabm" # Escaped embedded hyphen. - 'foo\\bar'.tr('ab\\', 'XYZ') # => "fooZYXr" # Escaped backslash. - -**@overload** [] - -## tr!(src, repl) [](#method-i-tr!) -Like String#tr, but modifies `self` in place. Returns `self` if any changes -were made, `nil` otherwise. - -**@overload** [] - -## tr_cpp() [](#method-i-tr_cpp) -Generates a string used as cpp macro name. - -## tr_s(src, repl) [](#method-i-tr_s) -Like String#tr, but also squeezes the modified portions of the translated -string; returns a new string (translated and squeezed). - - 'hello'.tr_s('l', 'r') #=> "hero" - 'hello'.tr_s('el', '-') #=> "h-o" - 'hello'.tr_s('el', 'hx') #=> "hhxo" - -Related: String#squeeze. - -**@overload** [] - -## tr_s!(src, repl) [](#method-i-tr_s!) -Like String#tr_s, but modifies `self` in place. Returns `self` if any changes -were made, `nil` otherwise. - -Related: String#squeeze!. - -**@overload** [] - -## undump() [](#method-i-undump) -Returns an unescaped version of `self`: - - s_orig = "\f\x00\xff\\\"" # => "\f\u0000\xFF\\\"" - s_dumped = s_orig.dump # => "\"\\f\\x00\\xFF\\\\\\\"\"" - s_undumped = s_dumped.undump # => "\f\u0000\xFF\\\"" - s_undumped == s_orig # => true - -Related: String#dump (inverse of String#undump). - -**@overload** [] - -## unicode_normalize(*args) [](#method-i-unicode_normalize) -Returns a copy of `self` with [Unicode -normalization](https://unicode.org/reports/tr15) applied. - -Argument `form` must be one of the following symbols (see [Unicode -normalization forms](https://unicode.org/reports/tr15/#Norm_Forms)): - -* `:nfc`: Canonical decomposition, followed by canonical composition. -* `:nfd`: Canonical decomposition. -* `:nfkc`: Compatibility decomposition, followed by canonical composition. -* `:nfkd`: Compatibility decomposition. - -The encoding of `self` must be one of: - -* Encoding::UTF_8 -* Encoding::UTF_16BE -* Encoding::UTF_16LE -* Encoding::UTF_32BE -* Encoding::UTF_32LE -* Encoding::GB18030 -* Encoding::UCS_2BE -* Encoding::UCS_4BE - -Examples: - - "a\u0300".unicode_normalize # => "a" - "\u00E0".unicode_normalize(:nfd) # => "a " - -Related: String#unicode_normalize!, String#unicode_normalized?. - -**@overload** [] - -## unicode_normalize!(*args) [](#method-i-unicode_normalize!) -Like String#unicode_normalize, except that the normalization is performed on -`self`. - -Related String#unicode_normalized?. - -**@overload** [] - -## unicode_normalized?(*args) [](#method-i-unicode_normalized?) -Returns `true` if `self` is in the given `form` of Unicode normalization, -`false` otherwise. The `form` must be one of `:nfc`, `:nfd`, `:nfkc`, or -`:nfkd`. - -Examples: - - "a\u0300".unicode_normalized? # => false - "a\u0300".unicode_normalized?(:nfd) # => true - "\u00E0".unicode_normalized? # => true - "\u00E0".unicode_normalized?(:nfd) # => false - -Raises an exception if `self` is not in a Unicode encoding: - - s = "\xE0".force_encoding('ISO-8859-1') - s.unicode_normalized? # Raises Encoding::CompatibilityError. - -Related: String#unicode_normalize, String#unicode_normalize!. - -**@overload** [] - -## unpack(fmt, offset:0) [](#method-i-unpack) -call-seq: - unpack(template, offset: 0, &block) -> array - - Extracts data from +self+. - - If +block+ is not given, forming objects that become the elements - of a new array, and returns that array. Otherwise, yields each - object. - - See {Packed Data}[rdoc-ref:packed_data.rdoc]. - -## unpack1(fmt, offset:0) [](#method-i-unpack1) -call-seq: - unpack1(template, offset: 0) -> object - - Like String#unpack, but unpacks and returns only the first extracted object. - See {Packed Data}[rdoc-ref:packed_data.rdoc]. - -## unspace() [](#method-i-unspace) -Escape whitespaces for Makefile. - -## upcase(*args) [](#method-i-upcase) -Returns a string containing the upcased characters in `self`: - - s = 'Hello World!' # => "Hello World!" - s.upcase # => "HELLO WORLD!" - -The casing may be affected by the given `options`; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#upcase!, String#downcase, String#downcase!. - -**@overload** [] - -## upcase!(*args) [](#method-i-upcase!) -Upcases the characters in `self`; returns `self` if any changes were made, -`nil` otherwise: - - s = 'Hello World!' # => "Hello World!" - s.upcase! # => "HELLO WORLD!" - s # => "HELLO WORLD!" - s.upcase! # => nil - -The casing may be affected by the given `options`; see [Case -Mapping](rdoc-ref:case_mapping.rdoc). - -Related: String#upcase, String#downcase, String#downcase!. - -**@overload** [] - -## upto(*args) [](#method-i-upto) -With a block given, calls the block with each `String` value returned by -successive calls to String#succ; the first value is `self`, the next is -`self.succ`, and so on; the sequence terminates when value `other_string` is -reached; returns `self`: - - 'a8'.upto('b6') {|s| print s, ' ' } # => "a8" - -Output: - - a8 a9 b0 b1 b2 b3 b4 b5 b6 - -If argument `exclusive` is given as a truthy object, the last value is -omitted: - - 'a8'.upto('b6', true) {|s| print s, ' ' } # => "a8" - -Output: - - a8 a9 b0 b1 b2 b3 b4 b5 - -If `other_string` would not be reached, does not call the block: - - '25'.upto('5') {|s| fail s } - 'aa'.upto('a') {|s| fail s } - -With no block given, returns a new Enumerator: - - 'a8'.upto('b6') # => # - -**@overload** [] - -**@overload** [] - -## valid_encoding?() [](#method-i-valid_encoding?) -Returns `true` if `self` is encoded correctly, `false` otherwise: - - "\xc2\xa1".force_encoding("UTF-8").valid_encoding? # => true - "\xc2".force_encoding("UTF-8").valid_encoding? # => false - "\x80".force_encoding("UTF-8").valid_encoding? # => false - -**@overload** [] - diff --git a/example/ruby/StringIO.md b/example/ruby/StringIO.md deleted file mode 100644 index 4408de2..0000000 --- a/example/ruby/StringIO.md +++ /dev/null @@ -1,2533 +0,0 @@ -# Class: StringIO -**Inherits:** Object - -**Includes:** Enumerable, IO::generic_readable, IO::generic_writable - - - - -# Class Methods -## new(*args ) [](#method-c-new) -:nodoc: -## open(*args ) [](#method-c-open) -Note that `mode` defaults to `'r'` if `string` is frozen. - -Creates a new StringIO instance formed from `string` and `mode`; see [Access -Modes](rdoc-ref:File@Access+Modes). - -With no block, returns the new instance: - - strio = StringIO.open # => # - -With a block, calls the block with the new instance and returns the block's -value; closes the instance on block exit. - - StringIO.open {|strio| p strio } - # => # - -Related: StringIO.new. -**@overload** [] - - -#Instance Methods -## <<() [](#method-i-<<) - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## binmode() [](#method-i-binmode) -Sets the data mode in `self` to binary mode; see [Data -Mode](rdoc-ref:File@Data+Mode). - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## close() [](#method-i-close) -Closes `self` for both reading and writing. - -Raises IOError if reading or writing is attempted. - -Related: StringIO#close_read, StringIO#close_write. - -**@overload** [] - -## close_read() [](#method-i-close_read) -Closes `self` for reading; closed-write setting remains unchanged. - -Raises IOError if reading is attempted. - -Related: StringIO#close, StringIO#close_write. - -**@overload** [] - -## close_write() [](#method-i-close_write) -Closes `self` for writing; closed-read setting remains unchanged. - -Raises IOError if writing is attempted. - -Related: StringIO#close, StringIO#close_read. - -**@overload** [] - -## closed?() [](#method-i-closed?) -Returns `true` if `self` is closed for both reading and writing, `false` -otherwise. - -**@overload** [] - -## closed_read?() [](#method-i-closed_read?) -Returns `true` if `self` is closed for reading, `false` otherwise. - -**@overload** [] - -## closed_write?() [](#method-i-closed_write?) -Returns `true` if `self` is closed for writing, `false` otherwise. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(*args) [](#method-i-each) -Calls the block with each remaining line read from the stream; does nothing if -already at end-of-file; returns `self`. See [Line IO](rdoc-ref:IO@Line+IO). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## each_byte() [](#method-i-each_byte) -With a block given, calls the block with each remaining byte in the stream; -see [Byte IO](rdoc-ref:IO@Byte+IO). - -With no block given, returns an enumerator. - -**@overload** [] - -## each_char() [](#method-i-each_char) -With a block given, calls the block with each remaining character in the -stream; see [Character IO](rdoc-ref:IO@Character+IO). - -With no block given, returns an enumerator. - -**@overload** [] - -## each_codepoint() [](#method-i-each_codepoint) -With a block given, calls the block with each remaining codepoint in the -stream; see [Codepoint IO](rdoc-ref:IO@Codepoint+IO). - -With no block given, returns an enumerator. - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_line(*args) [](#method-i-each_line) -Calls the block with each remaining line read from the stream; does nothing if -already at end-of-file; returns `self`. See [Line IO](rdoc-ref:IO@Line+IO). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eof() [](#method-i-eof) -Returns `true` if positioned at end-of-stream, `false` otherwise; see -[Position](rdoc-ref:IO@Position). - -Raises IOError if the stream is not opened for reading. - -**@overload** [] - -## eof?() [](#method-i-eof?) -Returns `true` if positioned at end-of-stream, `false` otherwise; see -[Position](rdoc-ref:IO@Position). - -Raises IOError if the stream is not opened for reading. - -**@overload** [] - -## external_encoding() [](#method-i-external_encoding) -Returns the Encoding object that represents the encoding of the file. If the -stream is write mode and no encoding is specified, returns `nil`. - -**@overload** [] - -## fcntl() [](#method-i-fcntl) - -**@overload** [] - -## fileno() [](#method-i-fileno) - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flush() [](#method-i-flush) - -**@overload** [] - -## fsync() [](#method-i-fsync) - -**@overload** [] - -## getbyte() [](#method-i-getbyte) -Reads and returns the next 8-bit byte from the stream; see [Byte -IO](rdoc-ref:IO@Byte+IO). - -**@overload** [] - -## getc() [](#method-i-getc) -Reads and returns the next character from the stream; see [Character -IO](rdoc-ref:IO@Character+IO). - -**@overload** [] - -## getch(*args) [](#method-i-getch) -See IO#getch. - -**@overload** [] - -## getpass(*args) [](#method-i-getpass) -See IO#getpass. - -**@overload** [] - -## gets(*args) [](#method-i-gets) -Reads and returns a line from the stream; assigns the return value to `$_`; -see [Line IO](rdoc-ref:IO@Line+IO). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Note that `mode` defaults to `'r'` if `string` is frozen. - -Returns a new StringIO instance formed from `string` and `mode`; see [Access -Modes](rdoc-ref:File@Access+Modes): - - strio = StringIO.new # => # - strio.close - -The instance should be closed when no longer needed. - -Related: StringIO.open (accepts block; closes automatically). - -**@overload** [] - -## initialize_copy(orig) [](#method-i-initialize_copy) -:nodoc: - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## internal_encoding() [](#method-i-internal_encoding) -Returns the Encoding of the internal string if conversion is specified. -Otherwise returns `nil`. - -**@overload** [] - -## isatty() [](#method-i-isatty) - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## length() [](#method-i-length) -Returns the size of the buffer string. - -**@overload** [] - -**@overload** [] - -## lineno() [](#method-i-lineno) -Returns the current line number in `self`; see [Line -Number](rdoc-ref:IO@Line+Number). - -**@overload** [] - -## lineno=(lineno) [](#method-i-lineno=) -Sets the current line number in `self` to the given `new_line_number`; see -[Line Number](rdoc-ref:IO@Line+Number). - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pid() [](#method-i-pid) - -**@overload** [] - -## pos() [](#method-i-pos) -Returns the current position (in bytes); see [Position](rdoc-ref:IO@Position). - -**@overload** [] - -## pos=(pos) [](#method-i-pos=) -Sets the current position (in bytes); see [Position](rdoc-ref:IO@Position). - -**@overload** [] - -## pread(*args) [](#method-i-pread) -See IO#pread. - -**@overload** [] - -**@overload** [] - -## print() [](#method-i-print) - -## printf() [](#method-i-printf) - -## putc(ch) [](#method-i-putc) -See IO#putc. - -**@overload** [] - -## puts() [](#method-i-puts) - -## read(*args) [](#method-i-read) -See IO#read. - -**@overload** [] - -## read_nonblock(*args) [](#method-i-read_nonblock) -Similar to #read, but raises `EOFError` at end of string unless the -+exception: false+ option is passed in. - -**@overload** [] - -## readbyte() [](#method-i-readbyte) -Like `getbyte`, but raises an exception if already at end-of-stream; see [Byte -IO](rdoc-ref:IO@Byte+IO). - -**@overload** [] - -## readchar() [](#method-i-readchar) -Like `getc`, but raises an exception if already at end-of-stream; see -[Character IO](rdoc-ref:IO@Character+IO). - -**@overload** [] - -## readline(*args) [](#method-i-readline) -Reads a line as with IO#gets, but raises EOFError if already at end-of-file; -see [Line IO](rdoc-ref:IO@Line+IO). - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## readlines(*args) [](#method-i-readlines) -See IO#readlines. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## readpartial(*args) [](#method-i-readpartial) -Similar to #read, but raises `EOFError` at end of string instead of returning -`nil`, as well as IO#sysread does. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reopen(*args) [](#method-i-reopen) -Reinitializes the stream with the given `other` (string or StringIO) and -`mode`; see IO.new: - - StringIO.open('foo') do |strio| - p strio.string - strio.reopen('bar') - p strio.string - other_strio = StringIO.new('baz') - strio.reopen(other_strio) - p strio.string - other_strio.close - end - -Output: - - "foo" - "bar" - "baz" - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## rewind() [](#method-i-rewind) -Sets the current position and line number to zero; see -[Position](rdoc-ref:IO@Position) and [Line Number](rdoc-ref:IO@Line+Number). - -**@overload** [] - -## seek(*args) [](#method-i-seek) -Sets the current position to the given integer `offset` (in bytes), with -respect to a given constant `whence`; see [Position](rdoc-ref:IO@Position). - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## set_encoding(*args) [](#method-i-set_encoding) -Specify the encoding of the StringIO as *ext_enc*. Use the default external -encoding if *ext_enc* is nil. 2nd argument *int_enc* and optional hash *opt* -argument are ignored; they are for API compatibility to IO. - -**@overload** [] - -## set_encoding_by_bom() [](#method-i-set_encoding_by_bom) -Sets the encoding according to the BOM (Byte Order Mark) in the string. - -Returns `self` if the BOM is found, otherwise +nil. - -**@overload** [] - -## size() [](#method-i-size) -Returns the size of the buffer string. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## string() [](#method-i-string) -Returns underlying string: - - StringIO.open('foo') do |strio| - p strio.string - strio.string = 'bar' - p strio.string - end - -Output: - - "foo" - "bar" - -Related: StringIO#string= (assigns the underlying string). - -**@overload** [] - -## string=(string) [](#method-i-string=) -Assigns the underlying string as `other_string`, and sets position to zero; -returns `other_string`: - - StringIO.open('foo') do |strio| - p strio.string - strio.string = 'bar' - p strio.string - end - -Output: - - "foo" - "bar" - -Related: StringIO#string (returns the underlying string). - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## sync() [](#method-i-sync) -Returns `true`; implemented only for compatibility with other stream classes. - -**@overload** [] - -## sync=() [](#method-i-sync=) - -**@overload** [] - -## sysread(*args) [](#method-i-sysread) -Similar to #read, but raises `EOFError` at end of string instead of returning -`nil`, as well as IO#sysread does. - -**@overload** [] - -**@overload** [] - -## syswrite() [](#method-i-syswrite) - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## tell() [](#method-i-tell) - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## truncate(len) [](#method-i-truncate) -Truncates the buffer string to at most *integer* bytes. The stream must be -opened for writing. - -**@overload** [] - -## tty?() [](#method-i-tty?) - -**@return** [Boolean] - -## ungetbyte(c) [](#method-i-ungetbyte) -Pushes back ("unshifts") an 8-bit byte onto the stream; see [Byte -IO](rdoc-ref:IO@Byte+IO). - -**@overload** [] - -## ungetc(c) [](#method-i-ungetc) -Pushes back ("unshifts") a character or integer onto the stream; see -[Character IO](rdoc-ref:IO@Character+IO). - -**@overload** [] - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## write(*args) [](#method-i-write) -Appends the given string to the underlying buffer string. The stream must be -opened for writing. If the argument is not a string, it will be converted to -a string using `to_s`. Returns the number of bytes written. See IO#write. - -**@overload** [] - -**@overload** [] - -## write_nonblock(*args) [](#method-i-write_nonblock) -See IO#write_nonblock - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/StringIOSpecs.md b/example/ruby/StringIOSpecs.md deleted file mode 100644 index a1f98e9..0000000 --- a/example/ruby/StringIOSpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: StringIOSpecs - - - - -# Class Methods -## build() [](#method-c-build) - diff --git a/example/ruby/StringRefinement.md b/example/ruby/StringRefinement.md deleted file mode 100644 index 2d8fbe2..0000000 --- a/example/ruby/StringRefinement.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: StringRefinement - - - - - diff --git a/example/ruby/StringScanner.md b/example/ruby/StringScanner.md deleted file mode 100644 index 789fb9e..0000000 --- a/example/ruby/StringScanner.md +++ /dev/null @@ -1,682 +0,0 @@ -# Class: StringScanner -**Inherits:** Object - - -:markup: markdown - -:include: strscan/link_refs.txt :include: strscan/strscan.md - - -# Class Methods -## must_C_version() [](#method-c-must_C_version) -:nodoc: - -#Instance Methods -## <<(str) [](#method-i-<<) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - concat(more_string) -> self - -* Appends the given `more_string` to the [stored [string]](1). -* Returns `self`. -* Does not affect the [[positions]](11) or [match [values]](9). - -```rb scanner = StringScanner.new('foo') scanner.string # => "foo" -scanner.terminate scanner.concat('barbaz') # => # scanner.string # => "foobarbaz" put_situation(scanner) # -Situation: # pos: 3 # charpos: 3 # rest: "barbaz" # -rest_size: 6 ``` - -## [](idx) [](#method-i-[]) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - [](specifier) -> substring or nil - -Returns a captured substring or `nil`; see [Captured Match [Values]](13). - -When there are captures: - -```rb scanner = StringScanner.new('Fri Dec 12 1975 14:39') -scanner.scan(/(?w+) (?w+) (?d+) /) ``` - -* `specifier` zero: returns the entire matched substring: - - ```rb - scanner[0] # => "Fri Dec 12 " - scanner.pre_match # => "" - scanner.post_match # => "1975 14:39" - ``` - -* `specifier` positive integer. returns the `n`th capture, or `nil` if out - of range: - - ```rb - scanner[1] # => "Fri" - scanner[2] # => "Dec" - scanner[3] # => "12" - scanner[4] # => nil - ``` - -* `specifier` negative integer. counts backward from the last subgroup: - - ```rb - scanner[-1] # => "12" - scanner[-4] # => "Fri Dec 12 " - scanner[-5] # => nil - ``` - -* `specifier` symbol or string. returns the named subgroup, or `nil` if no - such: - - ```rb - scanner[:wday] # => "Fri" - scanner['wday'] # => "Fri" - scanner[:month] # => "Dec" - scanner[:day] # => "12" - scanner[:nope] # => nil - ``` - -When there are no captures, only `[0]` returns non-`nil`: - -```rb scanner = StringScanner.new('foobarbaz') scanner.exist?(/bar/) -[scanner](0) # => "bar" [scanner](1) # => nil ``` - -For a failed match, even `[0]` returns `nil`: - -```rb scanner.scan(/nope/) # => nil [scanner](0) # => nil -[scanner](1) # => nil ``` - -## beginning_of_line?() [](#method-i-beginning_of_line?) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - beginning_of_line? -> true or false - -Returns whether the [[position]](2) is at the beginning of a line; that is, at -the beginning of the [stored [string]](1) or immediately after a newline: - - scanner = StringScanner.new(MULTILINE_TEXT) - scanner.string - # => "Go placidly amid the noise and haste,\nand remember what peace there may be in silence.\n" - scanner.pos # => 0 - scanner.beginning_of_line? # => true - - scanner.scan_until(/,/) # => "Go placidly amid the noise and haste," - scanner.beginning_of_line? # => false - - scanner.scan(/\n/) # => "\n" - scanner.beginning_of_line? # => true - - scanner.terminate - scanner.beginning_of_line? # => true - - scanner.concat('x') - scanner.terminate - scanner.beginning_of_line? # => false - -StringScanner#bol? is an alias for StringScanner#beginning_of_line?. - -**@return** [Boolean] - -## captures() [](#method-i-captures) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - captures -> substring_array or nil - -Returns the array of [captured match [values]](13) at indexes `(1..)` if the -most recent match attempt succeeded, or `nil` otherwise: - -```rb scanner = StringScanner.new('Fri Dec 12 1975 14:39') scanner.captures - # => nil - -scanner.exist?(/(?w+) (?w+) (?d+) /) scanner.captures - # => ["Fri", "Dec", "12"] scanner.values_at(*0..4) # => ["Fri Dec 12 ", -"Fri", "Dec", "12", nil] - -scanner.exist?(/Fri/) scanner.captures # => [] - -scanner.scan(/nope/) scanner.captures # => nil ``` - -## charpos() [](#method-i-charpos) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/get_charpos.md - -## check(re) [](#method-i-check) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - check(pattern) -> matched_substring or nil - -Attempts to [[match]](17) the given `pattern` at the beginning of the [target -[substring]](3); does not modify the [[positions]](11). - -If the match succeeds: - -* Returns the matched substring. -* Sets all [match [values]](9). - -```rb scanner = StringScanner.new('foobarbaz') scanner.pos = 3 -scanner.check('bar') # => "bar" put_match_values(scanner) # Basic match -values: # matched?: true # matched_size: 3 # pre_match: -"foo" # matched : "bar" # post_match: "baz" # Captured match -values: # size: 1 # captures: [] # named_captures: {} # - values_at: ["bar", nil] # []: # [0]: "bar" # [1]: - nil # => 0..1 put_situation(scanner) # Situation: # pos: 3 # -charpos: 3 # rest: "barbaz" # rest_size: 6 ``` - -If the match fails: - -* Returns `nil`. -* Clears all [match [values]](9). - -```rb scanner.check(/nope/) # => nil match_values_cleared?(scanner) # -=> true ``` - -## check_until(re) [](#method-i-check_until) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - check_until(pattern) -> substring or nil - -Attempts to [[match]](17) the given `pattern` anywhere (at any -[[position]](2)) in the [target [substring]](3); does not modify the -[[positions]](11). - -If the match succeeds: - -* Sets all [match [values]](9). -* Returns the matched substring, which extends from the current - [[position]](2) to the end of the matched substring. - -```rb scanner = StringScanner.new('foobarbazbatbam') scanner.pos = 6 -scanner.check_until(/bat/) # => "bazbat" put_match_values(scanner) # Basic -match values: # matched?: true # matched_size: 3 # pre_match: - "foobarbaz" # matched : "bat" # post_match: "bam" # Captured -match values: # size: 1 # captures: [] # named_captures: -{} # values_at: ["bat", nil] # []: # [0]: "bat" # -[1]: nil put_situation(scanner) # Situation: # pos: 6 # -charpos: 6 # rest: "bazbatbam" # rest_size: 9 ``` - -If the match fails: - -* Clears all [match [values]](9). -* Returns `nil`. - -```rb scanner.check_until(/nope/) # => nil match_values_cleared?(scanner) # -=> true ``` - -## clear() [](#method-i-clear) -:nodoc: - -## concat(str) [](#method-i-concat) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - concat(more_string) -> self - -* Appends the given `more_string` to the [stored [string]](1). -* Returns `self`. -* Does not affect the [[positions]](11) or [match [values]](9). - -```rb scanner = StringScanner.new('foo') scanner.string # => "foo" -scanner.terminate scanner.concat('barbaz') # => # scanner.string # => "foobarbaz" put_situation(scanner) # -Situation: # pos: 3 # charpos: 3 # rest: "barbaz" # -rest_size: 6 ``` - -## empty?() [](#method-i-empty?) -:nodoc: - -**@return** [Boolean] - -## eos?() [](#method-i-eos?) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - eos? -> true or false - -Returns whether the [[position]](2) is at the end of the [stored [string]](1): - -```rb scanner = StringScanner.new('foobarbaz') scanner.eos? # => false pos = 3 -scanner.eos? # => false scanner.terminate scanner.eos? # => true ``` - -**@return** [Boolean] - -## exist?(re) [](#method-i-exist?) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - exist?(pattern) -> byte_offset or nil - -Attempts to [[match]](17) the given `pattern` anywhere (at any -[[position]](2)) n the [target [substring]](3); does not modify the -[[positions]](11). - -If the match succeeds: - -* Returns a byte offset: the distance in bytes between the current - [[position]](2) and the end of the matched substring. -* Sets all [match [values]](9). - -```rb scanner = StringScanner.new('foobarbazbatbam') scanner.pos = 6 -scanner.exist?(/bat/) # => 6 put_match_values(scanner) # Basic match values: # - matched?: true # matched_size: 3 # pre_match: "foobarbaz" # - matched : "bat" # post_match: "bam" # Captured match values: # -size: 1 # captures: [] # named_captures: {} # values_at: - ["bat", nil] # []: # [0]: "bat" # [1]: nil -put_situation(scanner) # Situation: # pos: 6 # charpos: 6 # -rest: "bazbatbam" # rest_size: 9 ``` - -If the match fails: - -* Returns `nil`. -* Clears all [match [values]](9). - -```rb scanner.exist?(/nope/) # => nil match_values_cleared?(scanner) # -=> true ``` - -**@return** [Boolean] - -## fixed_anchor?() [](#method-i-fixed_anchor?) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - fixed_anchor? -> true or false - -Returns whether the [fixed-anchor [property]](10) is set. - -**@return** [Boolean] - -## get_byte() [](#method-i-get_byte) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/get_byte.md - -## getbyte() [](#method-i-getbyte) -:nodoc: - -## getch() [](#method-i-getch) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/getch.md - -## getrows(lx, ly) [](#method-i-getrows) -lx: limit of x (columns of screen) ly: limit of y (rows of screen) - -## inspect() [](#method-i-inspect) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - inspect -> string - -Returns a string representation of `self` that may show: - -1. The current [[position]](2). -2. The size (in bytes) of the [stored [string]](1). -3. The substring preceding the current position. -4. The substring following the current position (which is also the [target - [substring]](3)). - -```rb scanner = StringScanner.new("Fri Dec 12 1975 14:39") scanner.pos = 11 -scanner.inspect # => "#" ``` - -If at beginning-of-string, item 4 above (following substring) is omitted: - -```rb scanner.reset scanner.inspect # => "#" -``` - -If at end-of-string, all items above are omitted: - -```rb scanner.terminate scanner.inspect # => "#" ``` - -## match?(re) [](#method-i-match?) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - match?(pattern) -> updated_position or nil - -Attempts to [[match]](17) the given `pattern` at the beginning of the [target -[substring]](3); does not modify the [[positions]](11). - -If the match succeeds: - -* Sets [match [values]](9). -* Returns the size in bytes of the matched substring. - -```rb scanner = StringScanner.new('foobarbaz') scanner.pos = 3 -scanner.match?(/bar/) => 3 put_match_values(scanner) # Basic match values: # -matched?: true # matched_size: 3 # pre_match: "foo" # -matched : "bar" # post_match: "baz" # Captured match values: # -size: 1 # captures: [] # named_captures: {} # values_at: - ["bar", nil] # []: # [0]: "bar" # [1]: nil -put_situation(scanner) # Situation: # pos: 3 # charpos: 3 # -rest: "barbaz" # rest_size: 6 ``` - -If the match fails: - -* Clears match values. -* Returns `nil`. -* Does not increment positions. - -```rb scanner.match?(/nope/) # => nil match_values_cleared?(scanner) # -=> true ``` - -**@return** [Boolean] - -## matched() [](#method-i-matched) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - matched -> matched_substring or nil - -Returns the matched substring from the most recent [[match]](17) attempt if it -was successful, or `nil` otherwise; see [Basic Matched [Values]](18): - -```rb scanner = StringScanner.new('foobarbaz') scanner.matched # => nil -scanner.pos = 3 scanner.match?(/bar/) # => 3 scanner.matched # => -"bar" scanner.match?(/nope/) # => nil scanner.matched # => nil ``` - -## matched?() [](#method-i-matched?) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - matched? -> true or false - -Returns `true` of the most recent [match [attempt]](17) was successful, -`false` otherwise; see [Basic Matched [Values]](18): - -```rb scanner = StringScanner.new('foobarbaz') scanner.matched? # => -false scanner.pos = 3 scanner.exist?(/baz/) # => 6 scanner.matched? # -=> true scanner.exist?(/nope/) # => nil scanner.matched? # => false ``` - -**@return** [Boolean] - -## matched_size() [](#method-i-matched_size) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - matched_size -> substring_size or nil - -Returns the size (in bytes) of the matched substring from the most recent -match [match [attempt]](17) if it was successful, or `nil` otherwise; see -[Basic Matched [Values]](18): - -```rb scanner = StringScanner.new('foobarbaz') scanner.matched_size # => nil - -pos = 3 scanner.exist?(/baz/) # => 9 scanner.matched_size # => 3 - -scanner.exist?(/nope/) # => nil scanner.matched_size # => nil ``` - -## named_captures() [](#method-i-named_captures) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - named_captures -> hash - -Returns the array of captured match values at indexes (1..) if the most recent -match attempt succeeded, or nil otherwise; see [Captured Match [Values]](13): - -```rb scanner = StringScanner.new('Fri Dec 12 1975 14:39') -scanner.named_captures # => {} - -pattern = /(?w+) (?w+) (?d+) / scanner.match?(pattern) -scanner.named_captures # => {"wday"=>"Fri", "month"=>"Dec", "day"=>"12"} - -scanner.string = 'nope' scanner.match?(pattern) scanner.named_captures # => -{"wday"=>nil, "month"=>nil, "day"=>nil} - -scanner.match?(/nosuch/) scanner.named_captures # => {} ``` - -## peek(vlen) [](#method-i-peek) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - peek(length) -> substring - -Returns the substring `string[pos, length]`; does not update [match -[values]](9) or [[positions]](11): - -```rb scanner = StringScanner.new('foobarbaz') scanner.pos = 3 scanner.peek(3) - # => "bar" scanner.terminate scanner.peek(3) # => "" ``` - -## peek_byte() [](#method-i-peek_byte) -Peeks at the current byte and returns it as an integer. - - s = StringScanner.new('ab') - s.peek_byte # => 97 - -## peep(vlen) [](#method-i-peep) -:nodoc: - -## pointer() [](#method-i-pointer) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/get_pos.md - -## pointer=(v) [](#method-i-pointer=) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/set_pos.md - -## pos() [](#method-i-pos) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/get_pos.md - -## pos=(v) [](#method-i-pos=) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/set_pos.md - -## post_match() [](#method-i-post_match) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - post_match -> substring - -Returns the substring that follows the matched substring from the most recent -match attempt if it was successful, or `nil` otherwise; see [Basic Match -[Values]](18): - -```rb scanner = StringScanner.new('foobarbaz') scanner.post_match # => nil - -scanner.pos = 3 scanner.match?(/bar/) # => 3 scanner.post_match # => -"baz" - -scanner.match?(/nope/) # => nil scanner.post_match # => nil ``` - -## pre_match() [](#method-i-pre_match) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - pre_match -> substring - -Returns the substring that precedes the matched substring from the most recent -match attempt if it was successful, or `nil` otherwise; see [Basic Match -[Values]](18): - -```rb scanner = StringScanner.new('foobarbaz') scanner.pre_match # => nil - -scanner.pos = 3 scanner.exist?(/baz/) # => 6 scanner.pre_match # => -"foobar" # Substring of entire string, not just target string. - -scanner.exist?(/nope/) # => nil scanner.pre_match # => nil ``` - -## reset() [](#method-i-reset) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - reset -> self - -Sets both [byte [position]](2) and [character [position]](7) to zero, and -clears [match [values]](9); returns `self`: - -```rb scanner = StringScanner.new('foobarbaz') scanner.exist?(/bar/) -# => 6 scanner.reset # => # -put_situation(scanner) # Situation: # pos: 0 # charpos: 0 # -rest: "foobarbaz" # rest_size: 9 # => nil -match_values_cleared?(scanner) # => true ``` - -## rest() [](#method-i-rest) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - rest -> target_substring - -Returns the 'rest' of the [stored [string]](1) (all after the current -[[position]](2)), which is the [target [substring]](3): - -```rb scanner = StringScanner.new('foobarbaz') scanner.rest # => "foobarbaz" -scanner.pos = 3 scanner.rest # => "barbaz" scanner.terminate scanner.rest # => -"" ``` - -## rest?() [](#method-i-rest?) -:nodoc: - -**@return** [Boolean] - -## rest_size() [](#method-i-rest_size) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - rest_size -> integer - -Returns the size (in bytes) of the #rest of the [stored [string]](1): - -```rb scanner = StringScanner.new('foobarbaz') scanner.rest # => -"foobarbaz" scanner.rest_size # => 9 scanner.pos = 3 scanner.rest # => -"barbaz" scanner.rest_size # => 6 scanner.terminate scanner.rest # => "" -scanner.rest_size # => 0 ``` - -## restsize() [](#method-i-restsize) -:nodoc: - -## scan(re) [](#method-i-scan) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/scan.md - -## scan_byte() [](#method-i-scan_byte) -Scans one byte and returns it as an integer. This method is not multibyte -character sensitive. See also: #getch. - -**@overload** [] - -## scan_full(re, s, f) [](#method-i-scan_full) -:nodoc: - -## scan_integer(base:10) [](#method-i-scan_integer) -call-seq: - scan_integer(base: 10) - -If `base` isn't provided or is `10`, then it is equivalent to calling `#scan` -with a `[+-]?d+` pattern, and returns an Integer or nil. - -If `base` is `16`, then it is equivalent to calling `#scan` with a -`[+-]?([0x)?](0-9a-fA-F)+` pattern, and returns an Integer or nil. - -The scanned string must be encoded with an ASCII compatible encoding, -otherwise Encoding::CompatibilityError will be raised. - -## scan_until(re) [](#method-i-scan_until) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/scan_until.md - -## search_full(re, s, f) [](#method-i-search_full) -:nodoc: - -## size() [](#method-i-size) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - size -> captures_count - -Returns the count of captures if the most recent match attempt succeeded, -`nil` otherwise; see [Captures Match [Values]](13): - -```rb scanner = StringScanner.new('Fri Dec 12 1975 14:39') scanner.size - # => nil - -pattern = /(?w+) (?w+) (?d+) / scanner.match?(pattern) -scanner.values_at(*0..scanner.size) # => ["Fri Dec 12 ", "Fri", "Dec", "12", -nil] scanner.size # => 4 - -scanner.match?(/nope/) # => nil scanner.size - # => nil ``` - -## skip(re) [](#method-i-skip) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/skip.md - -## skip_until(re) [](#method-i-skip_until) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/skip_until.md - -## string() [](#method-i-string) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - string -> stored_string - -Returns the [stored [string]](1): - -```rb scanner = StringScanner.new('foobar') scanner.string # => "foobar" -scanner.concat('baz') scanner.string # => "foobarbaz" ``` - -## string=(str) [](#method-i-string=) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - string = other_string -> other_string - -Replaces the [stored [string]](1) with the given `other_string`: - -* Sets both [[positions]](11) to zero. -* Clears [match [values]](9). -* Returns `other_string`. - -```rb scanner = StringScanner.new('foobar') scanner.scan(/foo/) -put_situation(scanner) # Situation: # pos: 3 # charpos: 3 # -rest: "bar" # rest_size: 3 match_values_cleared?(scanner) # => false - -scanner.string = 'baz' # => "baz" put_situation(scanner) # Situation: -# pos: 0 # charpos: 0 # rest: "baz" # rest_size: 3 -match_values_cleared?(scanner) # => true ``` - -## terminate() [](#method-i-terminate) -:markup: markdown :include: strscan/link_refs.txt :include: -strscan/methods/terminate.md - -## unscan() [](#method-i-unscan) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - unscan -> self - -Sets the [[position]](2) to its value previous to the recent successful -match][17 -: attempt: - - -```rb scanner = StringScanner.new('foobarbaz') scanner.scan(/foo/) -put_situation(scanner) # Situation: # pos: 3 # charpos: 3 # -rest: "barbaz" # rest_size: 6 scanner.unscan # => # put_situation(scanner) # Situation: # pos: 0 # charpos: - 0 # rest: "foobarbaz" # rest_size: 9 ``` - -Raises an exception if match values are clear: - -```rb scanner.scan(/nope/) # => nil match_values_cleared?(scanner) # -=> true scanner.unscan # Raises StringScanner::Error. ``` - -## values_at(*args) [](#method-i-values_at) -:markup: markdown :include: strscan/link_refs.txt - -call-seq: - values_at(*specifiers) -> array_of_captures or nil - -Returns an array of captured substrings, or `nil` of none. - -For each `specifier`, the returned substring is `[specifier]`; see #[]. - -```rb scanner = StringScanner.new('Fri Dec 12 1975 14:39') pattern = -/(?w+) (?w+) (?d+) / scanner.match?(pattern) -scanner.values_at(*0..3) # => ["Fri Dec 12 ", "Fri", "Dec", -"12"] scanner.values_at(*%i[wday month day]) # => ["Fri", "Dec", "12"] ``` - diff --git a/example/ruby/StringScanner/Error.md b/example/ruby/StringScanner/Error.md deleted file mode 100644 index 7e7ec84..0000000 --- a/example/ruby/StringScanner/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: StringScanner::Error -**Inherits:** StandardError - - - - - diff --git a/example/ruby/StringScannerTests.md b/example/ruby/StringScannerTests.md deleted file mode 100644 index 32f8f56..0000000 --- a/example/ruby/StringScannerTests.md +++ /dev/null @@ -1,147 +0,0 @@ -# Module: StringScannerTests - - - - - -#Instance Methods -## test_AREF() [](#method-i-test_AREF) - -## test_aref_without_regex() [](#method-i-test_aref_without_regex) - -## test_bol?() [](#method-i-test_bol?) - -**@return** [Boolean] - -## test_captures() [](#method-i-test_captures) - -## test_charpos_not_use_string_methods() [](#method-i-test_charpos_not_use_string_methods) - -## test_check() [](#method-i-test_check) - -## test_check_until() [](#method-i-test_check_until) - -## test_check_until_string() [](#method-i-test_check_until_string) - -## test_concat() [](#method-i-test_concat) - -## test_const_Id() [](#method-i-test_const_Id) - -## test_const_Version() [](#method-i-test_const_Version) - -## test_dup() [](#method-i-test_dup) - -## test_empty_encoding_ascii_8bit() [](#method-i-test_empty_encoding_ascii_8bit) - -## test_empty_encoding_utf8() [](#method-i-test_empty_encoding_utf8) - -## test_encoding() [](#method-i-test_encoding) - -## test_encoding_string() [](#method-i-test_encoding_string) - -## test_eos?() [](#method-i-test_eos?) - -**@return** [Boolean] - -## test_exist_p() [](#method-i-test_exist_p) - -## test_exist_p_invalid_argument() [](#method-i-test_exist_p_invalid_argument) - -## test_exist_p_string() [](#method-i-test_exist_p_string) - -## test_generic_regexp() [](#method-i-test_generic_regexp) - -## test_get_byte() [](#method-i-test_get_byte) - -## test_getch() [](#method-i-test_getch) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect2() [](#method-i-test_inspect2) - -## test_invalid_encoding_string() [](#method-i-test_invalid_encoding_string) - -## test_match_p() [](#method-i-test_match_p) - -## test_matched() [](#method-i-test_matched) - -## test_matched_size() [](#method-i-test_matched_size) - -## test_named_captures() [](#method-i-test_named_captures) - -## test_peek() [](#method-i-test_peek) - -## test_peek_byte() [](#method-i-test_peek_byte) - -## test_pos() [](#method-i-test_pos) - -## test_pos_unicode() [](#method-i-test_pos_unicode) - -## test_post_match() [](#method-i-test_post_match) - -## test_pre_match() [](#method-i-test_pre_match) - -## test_reset() [](#method-i-test_reset) - -## test_rest() [](#method-i-test_rest) - -## test_rest_size() [](#method-i-test_rest_size) - -## test_s_allocate() [](#method-i-test_s_allocate) - -## test_s_mustc() [](#method-i-test_s_mustc) - -## test_s_new() [](#method-i-test_s_new) - -## test_scan() [](#method-i-test_scan) - -## test_scan_aref_repeatedly() [](#method-i-test_scan_aref_repeatedly) - -## test_scan_byte() [](#method-i-test_scan_byte) - -## test_scan_full() [](#method-i-test_scan_full) - -## test_scan_integer() [](#method-i-test_scan_integer) - -## test_scan_integer_base_16() [](#method-i-test_scan_integer_base_16) - -## test_scan_integer_encoding() [](#method-i-test_scan_integer_encoding) - -## test_scan_integer_unmatch() [](#method-i-test_scan_integer_unmatch) - -## test_scan_string() [](#method-i-test_scan_string) - -## test_scan_until() [](#method-i-test_scan_until) - -## test_scan_until_string() [](#method-i-test_scan_until_string) - -## test_search_full() [](#method-i-test_search_full) - -## test_search_full_string() [](#method-i-test_search_full_string) - -## test_set_pos() [](#method-i-test_set_pos) - -## test_size() [](#method-i-test_size) - -## test_skip() [](#method-i-test_skip) - -## test_skip_until() [](#method-i-test_skip_until) - -## test_skip_until_string() [](#method-i-test_skip_until_string) - -## test_skip_with_begenning_of_line_anchor_match() [](#method-i-test_skip_with_begenning_of_line_anchor_match) - -## test_skip_with_begenning_of_string_anchor_match() [](#method-i-test_skip_with_begenning_of_string_anchor_match) - -## test_string() [](#method-i-test_string) - -## test_string_append() [](#method-i-test_string_append) - -## test_string_set_is_equal() [](#method-i-test_string_set_is_equal) - -## test_terminate() [](#method-i-test_terminate) - -## test_unscan() [](#method-i-test_unscan) - -## test_values_at() [](#method-i-test_values_at) - diff --git a/example/ruby/StringSpecs.md b/example/ruby/StringSpecs.md deleted file mode 100644 index 709490c..0000000 --- a/example/ruby/StringSpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: StringSpecs - - - - -# Class Methods -## to_c_method(string ) [](#method-c-to_c_method) - diff --git a/example/ruby/StringSpecs/ISO88599Encoding.md b/example/ruby/StringSpecs/ISO88599Encoding.md deleted file mode 100644 index 54c16c7..0000000 --- a/example/ruby/StringSpecs/ISO88599Encoding.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: StringSpecs::ISO88599Encoding -**Inherits:** Object - - - - - -#Instance Methods -## ascii_only() [](#method-i-ascii_only) - -## cedilla() [](#method-i-cedilla) -S-cedilla - -## source_encoding() [](#method-i-source_encoding) - -## x_escape() [](#method-i-x_escape) - diff --git a/example/ruby/StringSpecs/InitializeString.md b/example/ruby/StringSpecs/InitializeString.md deleted file mode 100644 index cdb7236..0000000 --- a/example/ruby/StringSpecs/InitializeString.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: StringSpecs::InitializeString -**Inherits:** String - - - - -# Attributes -## ivar[RW] [](#attribute-i-ivar) -Returns the value of attribute ivar. - - -#Instance Methods -## initialize(other) [](#method-i-initialize) - -**@return** [InitializeString] a new instance of InitializeString - -## initialize_copy(other) [](#method-i-initialize_copy) - diff --git a/example/ruby/StringSpecs/MyArray.md b/example/ruby/StringSpecs/MyArray.md deleted file mode 100644 index 2f530e9..0000000 --- a/example/ruby/StringSpecs/MyArray.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: StringSpecs::MyArray -**Inherits:** Array - - - - - diff --git a/example/ruby/StringSpecs/MyRange.md b/example/ruby/StringSpecs/MyRange.md deleted file mode 100644 index 998a85f..0000000 --- a/example/ruby/StringSpecs/MyRange.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: StringSpecs::MyRange -**Inherits:** Range - - - - - diff --git a/example/ruby/StringSpecs/MyString.md b/example/ruby/StringSpecs/MyString.md deleted file mode 100644 index 79d2cee..0000000 --- a/example/ruby/StringSpecs/MyString.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: StringSpecs::MyString -**Inherits:** String - - - - - diff --git a/example/ruby/StringSpecs/SpecialVarProcessor.md b/example/ruby/StringSpecs/SpecialVarProcessor.md deleted file mode 100644 index 9d93484..0000000 --- a/example/ruby/StringSpecs/SpecialVarProcessor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: StringSpecs::SpecialVarProcessor -**Inherits:** Object - - - - - -#Instance Methods -## process(match) [](#method-i-process) - diff --git a/example/ruby/StringSpecs/StringModule.md b/example/ruby/StringSpecs/StringModule.md deleted file mode 100644 index 6df0ac2..0000000 --- a/example/ruby/StringSpecs/StringModule.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: StringSpecs::StringModule - - - - - -#Instance Methods -## repr() [](#method-i-repr) - diff --git a/example/ruby/StringSpecs/StringWithRaisingConstructor.md b/example/ruby/StringSpecs/StringWithRaisingConstructor.md deleted file mode 100644 index 31907b8..0000000 --- a/example/ruby/StringSpecs/StringWithRaisingConstructor.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: StringSpecs::StringWithRaisingConstructor -**Inherits:** String - - - - - -#Instance Methods -## initialize(str) [](#method-i-initialize) - -**@raise** [ArgumentError] - -**@return** [StringWithRaisingConstructor] a new instance of StringWithRaisingConstructor - diff --git a/example/ruby/StringSpecs/SubString.md b/example/ruby/StringSpecs/SubString.md deleted file mode 100644 index 93fb5ff..0000000 --- a/example/ruby/StringSpecs/SubString.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: StringSpecs::SubString -**Inherits:** String - - - - -# Attributes -## special[RW] [](#attribute-i-special) -Returns the value of attribute special. - - -#Instance Methods -## initialize(strnil) [](#method-i-initialize) - -**@return** [SubString] a new instance of SubString - diff --git a/example/ruby/StringSubclass.md b/example/ruby/StringSubclass.md deleted file mode 100644 index f95b15f..0000000 --- a/example/ruby/StringSubclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: StringSubclass -**Inherits:** String - - - - - diff --git a/example/ruby/StringifySymbols.md b/example/ruby/StringifySymbols.md deleted file mode 100644 index e5e8a13..0000000 --- a/example/ruby/StringifySymbols.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: StringifySymbols - - - - -# Class Methods -## stringify_symbol(fname , sname ) [](#method-c-stringify_symbol) - diff --git a/example/ruby/StringifyTarget.md b/example/ruby/StringifyTarget.md deleted file mode 100644 index 32cebd5..0000000 --- a/example/ruby/StringifyTarget.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: StringifyTarget - - - - -# Class Methods -## any_method() [](#method-c-any_method) - diff --git a/example/ruby/Struct.md b/example/ruby/Struct.md deleted file mode 100644 index fe65641..0000000 --- a/example/ruby/Struct.md +++ /dev/null @@ -1,2541 +0,0 @@ -# Class: Struct -**Inherits:** Object - -**Includes:** Enumerable - - -:nodoc: - - -# Class Methods -## json_create(object ) [](#method-c-json_create) -See #as_json. -## keyword_init?() [](#method-c-keyword_init?) -Returns `true` if the class was initialized with `keyword_init: true`. -Otherwise returns `nil` or `false`. - -Examples: - Foo = Struct.new(:a) - Foo.keyword_init? # => nil - Bar = Struct.new(:a, keyword_init: true) - Bar.keyword_init? # => true - Baz = Struct.new(:a, keyword_init: false) - Baz.keyword_init? # => false -**@overload** [] - -## members() [](#method-c-members) -Returns the member names of the Struct descendant as an array: - - Customer = Struct.new(:name, :address, :zip) - Customer.members # => [:name, :address, :zip] -**@overload** [] - -## new(*args ) [](#method-c-new) -`Struct.new` returns a new subclass of `Struct`. The new subclass: - -* May be anonymous, or may have the name given by `class_name`. -* May have members as given by `member_names`. -* May have initialization via ordinary arguments, or via keyword arguments - -The new subclass has its own method `::new`; thus: - - Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo - f = Foo.new(0, 1) # => # - -**\Class Name** - -With string argument `class_name`, returns a new subclass of `Struct` named -`Struct::*class_name`*: - - Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo - Foo.name # => "Struct::Foo" - Foo.superclass # => Struct - -Without string argument `class_name`, returns a new anonymous subclass of -`Struct`: - - Struct.new(:foo, :bar).name # => nil - -**Block** - -With a block given, the created subclass is yielded to the block: - - Customer = Struct.new('Customer', :name, :address) do |new_class| - p "The new subclass is #{new_class}" - def greeting - "Hello #{name} at #{address}" - end - end # => Struct::Customer - dave = Customer.new('Dave', '123 Main') - dave # => # - dave.greeting # => "Hello Dave at 123 Main" - -Output, from `Struct.new`: - - "The new subclass is Struct::Customer" - -**Member Names** - -Symbol arguments `member_names` determines the members of the new subclass: - - Struct.new(:foo, :bar).members # => [:foo, :bar] - Struct.new('Foo', :foo, :bar).members # => [:foo, :bar] - -The new subclass has instance methods corresponding to `member_names`: - - Foo = Struct.new('Foo', :foo, :bar) - Foo.instance_methods(false) # => [:foo, :bar, :foo=, :bar=] - f = Foo.new # => # - f.foo # => nil - f.foo = 0 # => 0 - f.bar # => nil - f.bar = 1 # => 1 - f # => # - -**Singleton Methods** - -A subclass returned by Struct.new has these singleton methods: - -* Method `::new ` creates an instance of the subclass: - - Foo.new # => # - Foo.new(0) # => # - Foo.new(0, 1) # => # - Foo.new(0, 1, 2) # Raises ArgumentError: struct size differs - - # Initialization with keyword arguments: - Foo.new(foo: 0) # => # - Foo.new(foo: 0, bar: 1) # => # - Foo.new(foo: 0, bar: 1, baz: 2) - # Raises ArgumentError: unknown keywords: baz - -* Method `:inspect` returns a string representation of the subclass: - - Foo.inspect - # => "Struct::Foo" - -* Method `::members` returns an array of the member names: - - Foo.members # => [:foo, :bar] - -**Keyword Argument** - -By default, the arguments for initializing an instance of the new subclass can -be both positional and keyword arguments. - -Optional keyword argument `keyword_init:` allows to force only one type of -arguments to be accepted: - - KeywordsOnly = Struct.new(:foo, :bar, keyword_init: true) - KeywordsOnly.new(bar: 1, foo: 0) - # => # - KeywordsOnly.new(0, 1) - # Raises ArgumentError: wrong number of arguments - - PositionalOnly = Struct.new(:foo, :bar, keyword_init: false) - PositionalOnly.new(0, 1) - # => # - PositionalOnly.new(bar: 1, foo: 0) - # => #1, :bar=>2}, bar=nil> - # Note that no error is raised, but arguments treated as one hash value - - # Same as not providing keyword_init: - Any = Struct.new(:foo, :bar, keyword_init: nil) - Any.new(foo: 1, bar: 2) - # => # - Any.new(1, 2) - # => # -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - - -#Instance Methods -## ==(s2) [](#method-i-==) -Returns `true` if and only if the following are true; otherwise returns -`false`: - -* `other.class == self.class`. -* For each member name `name`, `other.name == self.name`. - -Examples: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe_jr == joe # => true - joe_jr[:name] = 'Joe Smith, Jr.' - # => "Joe Smith, Jr." - joe_jr == joe # => false - -**@overload** [] - -## [](idx) [](#method-i-[]) -Returns a value from `self`. - -With symbol or string argument `name` given, returns the value for the named -member: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe[:zip] # => 12345 - -Raises NameError if `name` is not the name of a member. - -With integer argument `n` given, returns `self.values[n]` if `n` is in range; -see Array@Array+Indexes: - - joe[2] # => 12345 - joe[-2] # => "123 Maple, Anytown NC" - -Raises IndexError if `n` is out of range. - -**@overload** [] - -**@overload** [] - -## []=(idx, val) [](#method-i-[]=) -Assigns a value to a member. - -With symbol or string argument `name` given, assigns the given `value` to the -named member; returns `value`: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe[:zip] = 54321 # => 54321 - joe # => # - -Raises NameError if `name` is not the name of a member. - -With integer argument `n` given, assigns the given `value` to the `n`-th -member if `n` is in range; see Array@Array+Indexes: - - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe[2] = 54321 # => 54321 - joe[-3] = 'Joseph Smith' # => "Joseph Smith" - joe # => # - -Raises IndexError if `n` is out of range. - -**@overload** [] - -**@overload** [] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Struct#as_json` and `Struct.json_create` may be used to serialize and -deserialize a Struct object; see [Marshal](rdoc-ref:Marshal). - -Method `Struct#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/struct' - Customer = Struct.new('Customer', :name, :address, :zip) - x = Struct::Customer.new.as_json - # => {"json_class"=>"Struct::Customer", "v"=>[nil, nil, nil]} - -Method `JSON.create` deserializes such a hash, returning a Struct object: - - Struct::Customer.json_create(x) - # => # - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## deconstruct() [](#method-i-deconstruct) -Returns the values in `self` as an array: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345] - -Related: #members. - -**@overload** [] - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Returns a hash of the name/value pairs for the given member names. - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - h = joe.deconstruct_keys([:zip, :address]) - h # => {:zip=>12345, :address=>"123 Maple, Anytown NC"} - -Returns all names and values if `array_of_names` is `nil`: - - h = joe.deconstruct_keys(nil) - h # => {:name=>"Joseph Smith, Jr.", :address=>"123 Maple, Anytown NC", :zip=>12345} - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## dig(*args) [](#method-i-dig) -Finds and returns an object among nested objects. - The nested objects may be instances of various classes. - See {Dig Methods}[rdoc-ref:dig_methods.rdoc]. - - Given symbol or string argument +name+, - returns the object that is specified by +name+ and +identifiers+: - - Foo = Struct.new(:a) - f = Foo.new(Foo.new({b: [1, 2, 3]})) - f.dig(:a) # => #[1, 2, 3]}> - f.dig(:a, :a) # => {:b=>[1, 2, 3]} - f.dig(:a, :a, :b) # => [1, 2, 3] - f.dig(:a, :a, :b, 0) # => 1 - f.dig(:b, 0) # => nil - - Given integer argument +n+, - returns the object that is specified by +n+ and +identifiers+: - - f.dig(0) # => #[1, 2, 3]}> - f.dig(0, 0) # => {:b=>[1, 2, 3]} - f.dig(0, 0, :b) # => [1, 2, 3] - f.dig(0, 0, :b, 0) # => 1 - f.dig(:b, 0) # => nil - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) -Calls the given block with the value of each member; returns `self`: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.each {|value| p value } - -Output: - - "Joe Smith" - "123 Maple, Anytown NC" - 12345 - -Returns an Enumerator if no block is given. - -Related: #each_pair. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_pair() [](#method-i-each_pair) -Calls the given block with each member name/value pair; returns `self`: - - Customer = Struct.new(:name, :address, :zip) # => Customer - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.each_pair {|(name, value)| p "#{name} => #{value}" } - -Output: - - "name => Joe Smith" - "address => 123 Maple, Anytown NC" - "zip => 12345" - -Returns an Enumerator if no block is given. - -Related: #each. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eql?(s2) [](#method-i-eql?) -Returns `true` if and only if the following are true; otherwise returns -`false`: - - - other.class == self.class. - - For each member name +name+, other.name.eql?(self.name). - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe_jr.eql?(joe) # => true - joe_jr[:name] = 'Joe Smith, Jr.' - joe_jr.eql?(joe) # => false - - Related: Object#==. - -**@overload** [] - -## filter(*args) [](#method-i-filter) -With a block given, returns an array of values from `self` for which the block -returns a truthy value: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - a = joe.select {|value| value.is_a?(String) } - a # => ["Joe Smith", "123 Maple, Anytown NC"] - a = joe.select {|value| value.is_a?(Integer) } - a # => [12345] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## hash() [](#method-i-hash) -Returns the integer hash value for `self`. - -Two structs of the same class and with the same content will have the same -hash code (and will compare using Struct#eql?): - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.hash == joe_jr.hash # => true - joe_jr[:name] = 'Joe Smith, Jr.' - joe.hash == joe_jr.hash # => false - -Related: Object#hash. - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) - -## initialize_copy(s) [](#method-i-initialize_copy) -:nodoc: - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a string representation of `self`: - - Customer = Struct.new(:name, :address, :zip) # => Customer - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.inspect # => "#" - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## length() [](#method-i-length) -Returns the number of members. - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.size #=> 3 - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## members() [](#method-i-members) -Returns the member names from `self` as an array: - - Customer = Struct.new(:name, :address, :zip) - Customer.new.members # => [:name, :address, :zip] - -Related: #to_a. - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pretty_print(q) [](#method-i-pretty_print) -:nodoc: - -## pretty_print_cycle(q) [](#method-i-pretty_print_cycle) -:nodoc: - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select(*args) [](#method-i-select) -With a block given, returns an array of values from `self` for which the block -returns a truthy value: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - a = joe.select {|value| value.is_a?(String) } - a # => ["Joe Smith", "123 Maple, Anytown NC"] - a = joe.select {|value| value.is_a?(Integer) } - a # => [12345] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## size() [](#method-i-size) -Returns the number of members. - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.size #=> 3 - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) -Returns the values in `self` as an array: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345] - -Related: #members. - -**@overload** [] - -## to_h() [](#method-i-to_h) -Returns a hash containing the name and value for each member: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - h = joe.to_h - h # => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345} - -If a block is given, it is called with each name/value pair; the block should -return a 2-element array whose elements will become a key/value pair in the -returned hash: - - h = joe.to_h{|name, value| [name.upcase, value.to_s.upcase]} - h # => {:NAME=>"JOE SMITH", :ADDRESS=>"123 MAPLE, ANYTOWN NC", :ZIP=>"12345"} - -Raises ArgumentError if the block returns an inappropriate value. - -**@overload** [] - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/struct' - Customer = Struct.new('Customer', :name, :address, :zip) - puts Struct::Customer.new.to_json - -Output: - - {"json_class":"Struct","t":{'name':'Rowdy',"age":null}} - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## values() [](#method-i-values) -Returns the values in `self` as an array: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345] - -Related: #members. - -**@overload** [] - -## values_at(*args) [](#method-i-values_at) -Returns an array of values from `self`. - -With integer arguments `integers` given, returns an array containing each -value given by one of `integers`: - - Customer = Struct.new(:name, :address, :zip) - joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - joe.values_at(0, 2) # => ["Joe Smith", 12345] - joe.values_at(2, 0) # => [12345, "Joe Smith"] - joe.values_at(2, 1, 0) # => [12345, "123 Maple, Anytown NC", "Joe Smith"] - joe.values_at(0, -3) # => ["Joe Smith", "Joe Smith"] - -Raises IndexError if any of `integers` is out of range; see -Array@Array+Indexes. - -With integer range argument `integer_range` given, returns an array containing -each value given by the elements of the range; fills with `nil` values for -range elements larger than the structure: - - joe.values_at(0..2) - # => ["Joe Smith", "123 Maple, Anytown NC", 12345] - joe.values_at(-3..-1) - # => ["Joe Smith", "123 Maple, Anytown NC", 12345] - joe.values_at(1..4) # => ["123 Maple, Anytown NC", 12345, nil, nil] - -Raises RangeError if any element of the range is negative and out of range; -see Array@Array+Indexes. - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/StructClasses.md b/example/ruby/StructClasses.md deleted file mode 100644 index 106630f..0000000 --- a/example/ruby/StructClasses.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: StructClasses - - - - - diff --git a/example/ruby/StructClasses/Apple.md b/example/ruby/StructClasses/Apple.md deleted file mode 100644 index 1fa802e..0000000 --- a/example/ruby/StructClasses/Apple.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: StructClasses::Apple -**Inherits:** Struct - - - - - diff --git a/example/ruby/StructClasses/Car.md b/example/ruby/StructClasses/Car.md deleted file mode 100644 index e1d842f..0000000 --- a/example/ruby/StructClasses/Car.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: StructClasses::Car -**Inherits:** Struct - - - - -# Attributes -## make[RW] [](#attribute-i-make) -Returns the value of attribute make - -**@return** [Object] the current value of make - -## model[RW] [](#attribute-i-model) -Returns the value of attribute model - -**@return** [Object] the current value of model - -## year[RW] [](#attribute-i-year) -Returns the value of attribute year - -**@return** [Object] the current value of year - - diff --git a/example/ruby/StructClasses/Honda.md b/example/ruby/StructClasses/Honda.md deleted file mode 100644 index f368cc7..0000000 --- a/example/ruby/StructClasses/Honda.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: StructClasses::Honda -**Inherits:** StructClasses::Car - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [Honda] a new instance of Honda - diff --git a/example/ruby/StructClasses/Ruby.md b/example/ruby/StructClasses/Ruby.md deleted file mode 100644 index 61af42e..0000000 --- a/example/ruby/StructClasses/Ruby.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: StructClasses::Ruby -**Inherits:** Struct - - - - -# Attributes -## platform[RW] [](#attribute-i-platform) -Returns the value of attribute platform - -**@return** [Object] the current value of platform - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version - -**@return** [Object] the current value of version - - diff --git a/example/ruby/StructClasses/StructWithOverriddenName.md b/example/ruby/StructClasses/StructWithOverriddenName.md deleted file mode 100644 index da1582f..0000000 --- a/example/ruby/StructClasses/StructWithOverriddenName.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: StructClasses::StructWithOverriddenName -**Inherits:** Struct - - - - -# Class Methods -## name() [](#method-c-name) -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a - -**@return** [Object] the current value of a - - diff --git a/example/ruby/StructClasses/SubclassX.md b/example/ruby/StructClasses/SubclassX.md deleted file mode 100644 index 63c8923..0000000 --- a/example/ruby/StructClasses/SubclassX.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: StructClasses::SubclassX -**Inherits:** Struct - - - - -# Attributes -## key[RW] [](#attribute-i-key) -Returns the value of attribute key. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [SubclassX] a new instance of SubclassX - diff --git a/example/ruby/SubStringWithInstanceVariables.md b/example/ruby/SubStringWithInstanceVariables.md deleted file mode 100644 index 4732c71..0000000 --- a/example/ruby/SubStringWithInstanceVariables.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: SubStringWithInstanceVariables -**Inherits:** String - - - - -# Attributes -## var1[RW] [](#attribute-i-var1) -Returns the value of attribute var1. - - diff --git a/example/ruby/SummaryFormatter.md b/example/ruby/SummaryFormatter.md deleted file mode 100644 index 7546a48..0000000 --- a/example/ruby/SummaryFormatter.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SummaryFormatter -**Inherits:** BaseFormatter - - - - - diff --git a/example/ruby/SuperSpecs.md b/example/ruby/SuperSpecs.md deleted file mode 100644 index 12b2088..0000000 --- a/example/ruby/SuperSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs - - - - - diff --git a/example/ruby/SuperSpecs/Alias1.md b/example/ruby/SuperSpecs/Alias1.md deleted file mode 100644 index 73c97f5..0000000 --- a/example/ruby/SuperSpecs/Alias1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::Alias1 -**Inherits:** Object - - - - - -#Instance Methods -## name() [](#method-i-name) - diff --git a/example/ruby/SuperSpecs/Alias2.md b/example/ruby/SuperSpecs/Alias2.md deleted file mode 100644 index 7ec1749..0000000 --- a/example/ruby/SuperSpecs/Alias2.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SuperSpecs::Alias2 -**Inherits:** SuperSpecs::Alias1 - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Alias2] a new instance of Alias2 - -## name() [](#method-i-name) - diff --git a/example/ruby/SuperSpecs/Alias3.md b/example/ruby/SuperSpecs/Alias3.md deleted file mode 100644 index 5950495..0000000 --- a/example/ruby/SuperSpecs/Alias3.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SuperSpecs::Alias3 -**Inherits:** SuperSpecs::Alias2 - - - - - diff --git a/example/ruby/SuperSpecs/AliasWithSuper.md b/example/ruby/SuperSpecs/AliasWithSuper.md deleted file mode 100644 index 3bff9f1..0000000 --- a/example/ruby/SuperSpecs/AliasWithSuper.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::AliasWithSuper - - - - - diff --git a/example/ruby/SuperSpecs/AliasWithSuper/AS1.md b/example/ruby/SuperSpecs/AliasWithSuper/AS1.md deleted file mode 100644 index 95dc44a..0000000 --- a/example/ruby/SuperSpecs/AliasWithSuper/AS1.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: SuperSpecs::AliasWithSuper::AS1 - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/AliasWithSuper/BS1.md b/example/ruby/SuperSpecs/AliasWithSuper/BS1.md deleted file mode 100644 index fe1f13d..0000000 --- a/example/ruby/SuperSpecs/AliasWithSuper/BS1.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: SuperSpecs::AliasWithSuper::BS1 - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/AliasWithSuper/Base.md b/example/ruby/SuperSpecs/AliasWithSuper/Base.md deleted file mode 100644 index f7e81a1..0000000 --- a/example/ruby/SuperSpecs/AliasWithSuper/Base.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: SuperSpecs::AliasWithSuper::Base -**Inherits:** Object - -**Extended by:** SuperSpecs::AliasWithSuper::AS1, SuperSpecs::AliasWithSuper::BS1 - - - - -# Class Methods -## foo() [](#method-c-foo) - diff --git a/example/ruby/SuperSpecs/AliasWithSuper/Trigger.md b/example/ruby/SuperSpecs/AliasWithSuper/Trigger.md deleted file mode 100644 index c8f7b47..0000000 --- a/example/ruby/SuperSpecs/AliasWithSuper/Trigger.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: SuperSpecs::AliasWithSuper::Trigger -**Inherits:** SuperSpecs::AliasWithSuper::Base - - - - -# Class Methods -## foo_quux() [](#method-c-foo_quux) - diff --git a/example/ruby/SuperSpecs/AnonymousModuleIncludedTwice.md b/example/ruby/SuperSpecs/AnonymousModuleIncludedTwice.md deleted file mode 100644 index e1d06a2..0000000 --- a/example/ruby/SuperSpecs/AnonymousModuleIncludedTwice.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SuperSpecs::AnonymousModuleIncludedTwice -**Inherits:** SuperSpecs::AnonymousModuleIncludedTwiceBase - - - - - diff --git a/example/ruby/SuperSpecs/AnonymousModuleIncludedTwiceBase.md b/example/ruby/SuperSpecs/AnonymousModuleIncludedTwiceBase.md deleted file mode 100644 index 6b1d521..0000000 --- a/example/ruby/SuperSpecs/AnonymousModuleIncludedTwiceBase.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::AnonymousModuleIncludedTwiceBase -**Inherits:** Object - - - - -# Class Methods -## whatever() [](#method-c-whatever) - -#Instance Methods -## a(array) [](#method-i-a) - diff --git a/example/ruby/SuperSpecs/FromBasicObject.md b/example/ruby/SuperSpecs/FromBasicObject.md deleted file mode 100644 index 3fce640..0000000 --- a/example/ruby/SuperSpecs/FromBasicObject.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: SuperSpecs::FromBasicObject - - - - - -#Instance Methods -## __send__(name, *args, &block) [](#method-i-__send__) - diff --git a/example/ruby/SuperSpecs/IncludesFromBasic.md b/example/ruby/SuperSpecs/IncludesFromBasic.md deleted file mode 100644 index 832e7e2..0000000 --- a/example/ruby/SuperSpecs/IncludesFromBasic.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SuperSpecs::IncludesFromBasic -**Inherits:** Object - -**Includes:** SuperSpecs::FromBasicObject - - - - - -#Instance Methods -## __send__(name, *args, &block) [](#method-i-__send__) - -## foobar() [](#method-i-foobar) - diff --git a/example/ruby/SuperSpecs/IncludesIntermediate.md b/example/ruby/SuperSpecs/IncludesIntermediate.md deleted file mode 100644 index 6d11a06..0000000 --- a/example/ruby/SuperSpecs/IncludesIntermediate.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SuperSpecs::IncludesIntermediate -**Inherits:** Object - -**Includes:** SuperSpecs::IntermediateBasic - - - - - -#Instance Methods -## __send__(name, *args, &block) [](#method-i-__send__) - -## foobar() [](#method-i-foobar) - diff --git a/example/ruby/SuperSpecs/IntermediateBasic.md b/example/ruby/SuperSpecs/IntermediateBasic.md deleted file mode 100644 index d9bad79..0000000 --- a/example/ruby/SuperSpecs/IntermediateBasic.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: SuperSpecs::IntermediateBasic - -**Includes:** SuperSpecs::FromBasicObject - - - - - -#Instance Methods -## __send__(name, *args, &block) [](#method-i-__send__) - diff --git a/example/ruby/SuperSpecs/Keywords.md b/example/ruby/SuperSpecs/Keywords.md deleted file mode 100644 index 1a03be3..0000000 --- a/example/ruby/SuperSpecs/Keywords.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::Keywords - - - - - diff --git a/example/ruby/SuperSpecs/Keywords/Arguments.md b/example/ruby/SuperSpecs/Keywords/Arguments.md deleted file mode 100644 index db4359e..0000000 --- a/example/ruby/SuperSpecs/Keywords/Arguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::Keywords::Arguments -**Inherits:** Object - - - - - -#Instance Methods -## foo(**args) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/Keywords/OptionalAndPlaceholderArguments.md b/example/ruby/SuperSpecs/Keywords/OptionalAndPlaceholderArguments.md deleted file mode 100644 index 76348ce..0000000 --- a/example/ruby/SuperSpecs/Keywords/OptionalAndPlaceholderArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::Keywords::OptionalAndPlaceholderArguments -**Inherits:** SuperSpecs::Keywords::Arguments - - - - - -#Instance Methods -## foo(b:'b', **args) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/Keywords/OptionalArguments.md b/example/ruby/SuperSpecs/Keywords/OptionalArguments.md deleted file mode 100644 index 9f717d4..0000000 --- a/example/ruby/SuperSpecs/Keywords/OptionalArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::Keywords::OptionalArguments -**Inherits:** SuperSpecs::Keywords::Arguments - - - - - -#Instance Methods -## foo(b:'b') [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/Keywords/PlaceholderArguments.md b/example/ruby/SuperSpecs/Keywords/PlaceholderArguments.md deleted file mode 100644 index e6e266d..0000000 --- a/example/ruby/SuperSpecs/Keywords/PlaceholderArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::Keywords::PlaceholderArguments -**Inherits:** SuperSpecs::Keywords::Arguments - - - - - -#Instance Methods -## foo(**args) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/Keywords/RequiredAndOptionalAndPlaceholderArguments.md b/example/ruby/SuperSpecs/Keywords/RequiredAndOptionalAndPlaceholderArguments.md deleted file mode 100644 index 1f21775..0000000 --- a/example/ruby/SuperSpecs/Keywords/RequiredAndOptionalAndPlaceholderArguments.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: SuperSpecs::Keywords::RequiredAndOptionalAndPlaceholderArguments -**Inherits:** SuperSpecs::Keywords::Arguments - - ---- - - - -#Instance Methods -## foo(a:, b:'b', **args) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/Keywords/RequiredAndOptionalArguments.md b/example/ruby/SuperSpecs/Keywords/RequiredAndOptionalArguments.md deleted file mode 100644 index 21bb9ca..0000000 --- a/example/ruby/SuperSpecs/Keywords/RequiredAndOptionalArguments.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: SuperSpecs::Keywords::RequiredAndOptionalArguments -**Inherits:** SuperSpecs::Keywords::Arguments - - ---- - - - -#Instance Methods -## foo(a:, b:'b') [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/Keywords/RequiredAndPlaceholderArguments.md b/example/ruby/SuperSpecs/Keywords/RequiredAndPlaceholderArguments.md deleted file mode 100644 index 5587cde..0000000 --- a/example/ruby/SuperSpecs/Keywords/RequiredAndPlaceholderArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::Keywords::RequiredAndPlaceholderArguments -**Inherits:** SuperSpecs::Keywords::Arguments - - - - - -#Instance Methods -## foo(a:, **args) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/Keywords/RequiredArguments.md b/example/ruby/SuperSpecs/Keywords/RequiredArguments.md deleted file mode 100644 index 4106300..0000000 --- a/example/ruby/SuperSpecs/Keywords/RequiredArguments.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: SuperSpecs::Keywords::RequiredArguments -**Inherits:** SuperSpecs::Keywords::Arguments - - ---- - - - -#Instance Methods -## foo(a:) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MM_A.md b/example/ruby/SuperSpecs/MM_A.md deleted file mode 100644 index 8e19f62..0000000 --- a/example/ruby/SuperSpecs/MM_A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SuperSpecs::MM_A -**Inherits:** Object - - - - - diff --git a/example/ruby/SuperSpecs/MM_B.md b/example/ruby/SuperSpecs/MM_B.md deleted file mode 100644 index 9de5353..0000000 --- a/example/ruby/SuperSpecs/MM_B.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SuperSpecs::MM_B -**Inherits:** SuperSpecs::MM_A - - - - - -#Instance Methods -## is_a?(blah) [](#method-i-is_a?) - -**@return** [Boolean] - -## method_missing() [](#method-i-method_missing) - diff --git a/example/ruby/SuperSpecs/MS1.md b/example/ruby/SuperSpecs/MS1.md deleted file mode 100644 index 14b42f8..0000000 --- a/example/ruby/SuperSpecs/MS1.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::MS1 - - - - - diff --git a/example/ruby/SuperSpecs/MS1/A.md b/example/ruby/SuperSpecs/MS1/A.md deleted file mode 100644 index dfdaf82..0000000 --- a/example/ruby/SuperSpecs/MS1/A.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SuperSpecs::MS1::A -**Inherits:** Object - -**Includes:** SuperSpecs::MS1::ModA - - - - - -#Instance Methods -## bar(a) [](#method-i-bar) - -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MS1/B.md b/example/ruby/SuperSpecs/MS1/B.md deleted file mode 100644 index 3a14ed1..0000000 --- a/example/ruby/SuperSpecs/MS1/B.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SuperSpecs::MS1::B -**Inherits:** SuperSpecs::MS1::A - -**Includes:** SuperSpecs::MS1::ModB - - - - - -#Instance Methods -## bar(a) [](#method-i-bar) - -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MS1/ModA.md b/example/ruby/SuperSpecs/MS1/ModA.md deleted file mode 100644 index 4bdc79d..0000000 --- a/example/ruby/SuperSpecs/MS1/ModA.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: SuperSpecs::MS1::ModA - - - - - -#Instance Methods -## bar(a) [](#method-i-bar) - -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MS1/ModB.md b/example/ruby/SuperSpecs/MS1/ModB.md deleted file mode 100644 index 2922d5b..0000000 --- a/example/ruby/SuperSpecs/MS1/ModB.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: SuperSpecs::MS1::ModB - - - - - -#Instance Methods -## bar(a) [](#method-i-bar) - diff --git a/example/ruby/SuperSpecs/MS2.md b/example/ruby/SuperSpecs/MS2.md deleted file mode 100644 index 88de3f1..0000000 --- a/example/ruby/SuperSpecs/MS2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::MS2 - - - - - diff --git a/example/ruby/SuperSpecs/MS2/A.md b/example/ruby/SuperSpecs/MS2/A.md deleted file mode 100644 index 74b42bc..0000000 --- a/example/ruby/SuperSpecs/MS2/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::MS2::A -**Inherits:** Object - - - - - -#Instance Methods -## baz(a) [](#method-i-baz) - diff --git a/example/ruby/SuperSpecs/MS2/B.md b/example/ruby/SuperSpecs/MS2/B.md deleted file mode 100644 index 891693b..0000000 --- a/example/ruby/SuperSpecs/MS2/B.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::MS2::B -**Inherits:** SuperSpecs::MS2::A - -**Includes:** SuperSpecs::MS2::ModB - - - - - -#Instance Methods -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MS2/C.md b/example/ruby/SuperSpecs/MS2/C.md deleted file mode 100644 index 120e17e..0000000 --- a/example/ruby/SuperSpecs/MS2/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::MS2::C -**Inherits:** SuperSpecs::MS2::B - - - - - -#Instance Methods -## baz(a) [](#method-i-baz) - diff --git a/example/ruby/SuperSpecs/MS2/ModB.md b/example/ruby/SuperSpecs/MS2/ModB.md deleted file mode 100644 index 57b316a..0000000 --- a/example/ruby/SuperSpecs/MS2/ModB.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: SuperSpecs::MS2::ModB - - - - - -#Instance Methods -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MS3.md b/example/ruby/SuperSpecs/MS3.md deleted file mode 100644 index 7e25a24..0000000 --- a/example/ruby/SuperSpecs/MS3.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::MS3 - - - - - diff --git a/example/ruby/SuperSpecs/MS3/A.md b/example/ruby/SuperSpecs/MS3/A.md deleted file mode 100644 index ae7263d..0000000 --- a/example/ruby/SuperSpecs/MS3/A.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: SuperSpecs::MS3::A -**Inherits:** Object - -**Extended by:** SuperSpecs::MS3::ModA - - - - -# Class Methods -## bar(a ) [](#method-c-bar) -## foo(a ) [](#method-c-foo) - -#Instance Methods -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MS3/B.md b/example/ruby/SuperSpecs/MS3/B.md deleted file mode 100644 index 35212df..0000000 --- a/example/ruby/SuperSpecs/MS3/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::MS3::B -**Inherits:** SuperSpecs::MS3::A - - - - -# Class Methods -## bar(a ) [](#method-c-bar) -## foo(a ) [](#method-c-foo) - diff --git a/example/ruby/SuperSpecs/MS3/ModA.md b/example/ruby/SuperSpecs/MS3/ModA.md deleted file mode 100644 index 259f099..0000000 --- a/example/ruby/SuperSpecs/MS3/ModA.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: SuperSpecs::MS3::ModA - - - - - -#Instance Methods -## bar(a) [](#method-i-bar) - -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MS4.md b/example/ruby/SuperSpecs/MS4.md deleted file mode 100644 index 4da3dcc..0000000 --- a/example/ruby/SuperSpecs/MS4.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::MS4 - - - - - diff --git a/example/ruby/SuperSpecs/MS4/A.md b/example/ruby/SuperSpecs/MS4/A.md deleted file mode 100644 index 00388ff..0000000 --- a/example/ruby/SuperSpecs/MS4/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::MS4::A -**Inherits:** Object - -**Includes:** SuperSpecs::MS4::Layer2 - - - - - -#Instance Methods -## example() [](#method-i-example) - diff --git a/example/ruby/SuperSpecs/MS4/Layer1.md b/example/ruby/SuperSpecs/MS4/Layer1.md deleted file mode 100644 index cdc4d40..0000000 --- a/example/ruby/SuperSpecs/MS4/Layer1.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: SuperSpecs::MS4::Layer1 - - - - - -#Instance Methods -## example() [](#method-i-example) - diff --git a/example/ruby/SuperSpecs/MS4/Layer2.md b/example/ruby/SuperSpecs/MS4/Layer2.md deleted file mode 100644 index bea8b29..0000000 --- a/example/ruby/SuperSpecs/MS4/Layer2.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: SuperSpecs::MS4::Layer2 - -**Includes:** SuperSpecs::MS4::Layer1 - - - - - -#Instance Methods -## example() [](#method-i-example) - diff --git a/example/ruby/SuperSpecs/MultiSuperTargets.md b/example/ruby/SuperSpecs/MultiSuperTargets.md deleted file mode 100644 index e566e1e..0000000 --- a/example/ruby/SuperSpecs/MultiSuperTargets.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::MultiSuperTargets - - - - - diff --git a/example/ruby/SuperSpecs/MultiSuperTargets/A.md b/example/ruby/SuperSpecs/MultiSuperTargets/A.md deleted file mode 100644 index 62b1827..0000000 --- a/example/ruby/SuperSpecs/MultiSuperTargets/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::MultiSuperTargets::A -**Inherits:** SuperSpecs::MultiSuperTargets::BaseA - -**Includes:** SuperSpecs::MultiSuperTargets::M - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MultiSuperTargets/B.md b/example/ruby/SuperSpecs/MultiSuperTargets/B.md deleted file mode 100644 index 1f64b34..0000000 --- a/example/ruby/SuperSpecs/MultiSuperTargets/B.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::MultiSuperTargets::B -**Inherits:** SuperSpecs::MultiSuperTargets::BaseB - -**Includes:** SuperSpecs::MultiSuperTargets::M - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MultiSuperTargets/BaseA.md b/example/ruby/SuperSpecs/MultiSuperTargets/BaseA.md deleted file mode 100644 index 82bed8f..0000000 --- a/example/ruby/SuperSpecs/MultiSuperTargets/BaseA.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::MultiSuperTargets::BaseA -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MultiSuperTargets/BaseB.md b/example/ruby/SuperSpecs/MultiSuperTargets/BaseB.md deleted file mode 100644 index 25daa7d..0000000 --- a/example/ruby/SuperSpecs/MultiSuperTargets/BaseB.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::MultiSuperTargets::BaseB -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/MultiSuperTargets/M.md b/example/ruby/SuperSpecs/MultiSuperTargets/M.md deleted file mode 100644 index 7e1d6e7..0000000 --- a/example/ruby/SuperSpecs/MultiSuperTargets/M.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: SuperSpecs::MultiSuperTargets::M - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords.md b/example/ruby/SuperSpecs/RegularAndKeywords.md deleted file mode 100644 index c3c7589..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::RegularAndKeywords - - - - - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords/Arguments.md b/example/ruby/SuperSpecs/RegularAndKeywords/Arguments.md deleted file mode 100644 index 8018edb..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords/Arguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::RegularAndKeywords::Arguments -**Inherits:** Object - - - - - -#Instance Methods -## foo(a, **options) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords/OptionalAndPlaceholderArguments.md b/example/ruby/SuperSpecs/RegularAndKeywords/OptionalAndPlaceholderArguments.md deleted file mode 100644 index 77dbaf7..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords/OptionalAndPlaceholderArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::RegularAndKeywords::OptionalAndPlaceholderArguments -**Inherits:** SuperSpecs::RegularAndKeywords::Arguments - - - - - -#Instance Methods -## foo(a, c:'c', **options) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords/OptionalArguments.md b/example/ruby/SuperSpecs/RegularAndKeywords/OptionalArguments.md deleted file mode 100644 index d52edab..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords/OptionalArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::RegularAndKeywords::OptionalArguments -**Inherits:** SuperSpecs::RegularAndKeywords::Arguments - - - - - -#Instance Methods -## foo(a, c:'c') [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords/PlaceholderArguments.md b/example/ruby/SuperSpecs/RegularAndKeywords/PlaceholderArguments.md deleted file mode 100644 index 15a4805..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords/PlaceholderArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::RegularAndKeywords::PlaceholderArguments -**Inherits:** SuperSpecs::RegularAndKeywords::Arguments - - - - - -#Instance Methods -## foo(a, **options) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndOptionalAndPlaceholderArguments.md b/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndOptionalAndPlaceholderArguments.md deleted file mode 100644 index 146deac..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndOptionalAndPlaceholderArguments.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: SuperSpecs::RegularAndKeywords::RequiredAndOptionalAndPlaceholderArguments -**Inherits:** SuperSpecs::RegularAndKeywords::Arguments - - ---- - - - -#Instance Methods -## foo(a, b:, c:'c', **options) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndOptionalArguments.md b/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndOptionalArguments.md deleted file mode 100644 index 0e5b7ee..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndOptionalArguments.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: SuperSpecs::RegularAndKeywords::RequiredAndOptionalArguments -**Inherits:** SuperSpecs::RegularAndKeywords::Arguments - - ---- - - - -#Instance Methods -## foo(a, b:, c:'c') [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndPlaceholderArguments.md b/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndPlaceholderArguments.md deleted file mode 100644 index 166029a..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords/RequiredAndPlaceholderArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::RegularAndKeywords::RequiredAndPlaceholderArguments -**Inherits:** SuperSpecs::RegularAndKeywords::Arguments - - - - - -#Instance Methods -## foo(a, b:, **options) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RegularAndKeywords/RequiredArguments.md b/example/ruby/SuperSpecs/RegularAndKeywords/RequiredArguments.md deleted file mode 100644 index e565924..0000000 --- a/example/ruby/SuperSpecs/RegularAndKeywords/RequiredArguments.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: SuperSpecs::RegularAndKeywords::RequiredArguments -**Inherits:** SuperSpecs::RegularAndKeywords::Arguments - - ---- - - - -#Instance Methods -## foo(a, b:) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/RestArgsWithSuper.md b/example/ruby/SuperSpecs/RestArgsWithSuper.md deleted file mode 100644 index 73447ea..0000000 --- a/example/ruby/SuperSpecs/RestArgsWithSuper.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::RestArgsWithSuper - - - - - diff --git a/example/ruby/SuperSpecs/RestArgsWithSuper/A.md b/example/ruby/SuperSpecs/RestArgsWithSuper/A.md deleted file mode 100644 index d5e269b..0000000 --- a/example/ruby/SuperSpecs/RestArgsWithSuper/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::RestArgsWithSuper::A -**Inherits:** Object - - - - - -#Instance Methods -## a(*args) [](#method-i-a) - diff --git a/example/ruby/SuperSpecs/RestArgsWithSuper/B.md b/example/ruby/SuperSpecs/RestArgsWithSuper/B.md deleted file mode 100644 index 193e47b..0000000 --- a/example/ruby/SuperSpecs/RestArgsWithSuper/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::RestArgsWithSuper::B -**Inherits:** SuperSpecs::RestArgsWithSuper::A - - - - - -#Instance Methods -## a(*args) [](#method-i-a) - diff --git a/example/ruby/SuperSpecs/S1.md b/example/ruby/SuperSpecs/S1.md deleted file mode 100644 index e9a738b..0000000 --- a/example/ruby/SuperSpecs/S1.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::S1 - - - - - diff --git a/example/ruby/SuperSpecs/S1/A.md b/example/ruby/SuperSpecs/S1/A.md deleted file mode 100644 index b47a9bb..0000000 --- a/example/ruby/SuperSpecs/S1/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::S1::A -**Inherits:** Object - - - - - -#Instance Methods -## bar(a) [](#method-i-bar) - -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/S1/B.md b/example/ruby/SuperSpecs/S1/B.md deleted file mode 100644 index 8444ee5..0000000 --- a/example/ruby/SuperSpecs/S1/B.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::S1::B -**Inherits:** SuperSpecs::S1::A - - - - - -#Instance Methods -## bar(a) [](#method-i-bar) - -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/S2.md b/example/ruby/SuperSpecs/S2.md deleted file mode 100644 index b7bbb7a..0000000 --- a/example/ruby/SuperSpecs/S2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::S2 - - - - - diff --git a/example/ruby/SuperSpecs/S2/A.md b/example/ruby/SuperSpecs/S2/A.md deleted file mode 100644 index 50b1cb5..0000000 --- a/example/ruby/SuperSpecs/S2/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::S2::A -**Inherits:** Object - - - - - -#Instance Methods -## baz(a) [](#method-i-baz) - diff --git a/example/ruby/SuperSpecs/S2/B.md b/example/ruby/SuperSpecs/S2/B.md deleted file mode 100644 index a54634b..0000000 --- a/example/ruby/SuperSpecs/S2/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::S2::B -**Inherits:** SuperSpecs::S2::A - - - - - -#Instance Methods -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/S2/C.md b/example/ruby/SuperSpecs/S2/C.md deleted file mode 100644 index 3d172ce..0000000 --- a/example/ruby/SuperSpecs/S2/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::S2::C -**Inherits:** SuperSpecs::S2::B - - - - - -#Instance Methods -## baz(a) [](#method-i-baz) - diff --git a/example/ruby/SuperSpecs/S3.md b/example/ruby/SuperSpecs/S3.md deleted file mode 100644 index 6f2d73d..0000000 --- a/example/ruby/SuperSpecs/S3.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::S3 - - - - - diff --git a/example/ruby/SuperSpecs/S3/A.md b/example/ruby/SuperSpecs/S3/A.md deleted file mode 100644 index 0e33de7..0000000 --- a/example/ruby/SuperSpecs/S3/A.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: SuperSpecs::S3::A -**Inherits:** Object - - - - -# Class Methods -## bar(a ) [](#method-c-bar) -## foo(a ) [](#method-c-foo) - -#Instance Methods -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/S3/B.md b/example/ruby/SuperSpecs/S3/B.md deleted file mode 100644 index e0036fb..0000000 --- a/example/ruby/SuperSpecs/S3/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::S3::B -**Inherits:** SuperSpecs::S3::A - - - - -# Class Methods -## bar(a ) [](#method-c-bar) -## foo(a ) [](#method-c-foo) - diff --git a/example/ruby/SuperSpecs/S4.md b/example/ruby/SuperSpecs/S4.md deleted file mode 100644 index 12b3e4c..0000000 --- a/example/ruby/SuperSpecs/S4.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::S4 - - - - - diff --git a/example/ruby/SuperSpecs/S4/A.md b/example/ruby/SuperSpecs/S4/A.md deleted file mode 100644 index aaea88f..0000000 --- a/example/ruby/SuperSpecs/S4/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::S4::A -**Inherits:** Object - - - - - -#Instance Methods -## foo(a) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/S4/B.md b/example/ruby/SuperSpecs/S4/B.md deleted file mode 100644 index 983d4e6..0000000 --- a/example/ruby/SuperSpecs/S4/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::S4::B -**Inherits:** SuperSpecs::S4::A - - - - - -#Instance Methods -## foo(a, b) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/S5.md b/example/ruby/SuperSpecs/S5.md deleted file mode 100644 index 2b7c61a..0000000 --- a/example/ruby/SuperSpecs/S5.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::S5 -**Inherits:** Object - - - - - -#Instance Methods -## here() [](#method-i-here) - diff --git a/example/ruby/SuperSpecs/S6.md b/example/ruby/SuperSpecs/S6.md deleted file mode 100644 index 93e9d8f..0000000 --- a/example/ruby/SuperSpecs/S6.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::S6 -**Inherits:** SuperSpecs::S5 - - - - - -#Instance Methods -## here() [](#method-i-here) - -## under() [](#method-i-under) - diff --git a/example/ruby/SuperSpecs/S7.md b/example/ruby/SuperSpecs/S7.md deleted file mode 100644 index 3610964..0000000 --- a/example/ruby/SuperSpecs/S7.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SuperSpecs::S7 -**Inherits:** SuperSpecs::S5 - - - - - diff --git a/example/ruby/SuperSpecs/SingletonAliasCase.md b/example/ruby/SuperSpecs/SingletonAliasCase.md deleted file mode 100644 index 8cc0e08..0000000 --- a/example/ruby/SuperSpecs/SingletonAliasCase.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::SingletonAliasCase - - - - - diff --git a/example/ruby/SuperSpecs/SingletonAliasCase/Base.md b/example/ruby/SuperSpecs/SingletonAliasCase/Base.md deleted file mode 100644 index a50b382..0000000 --- a/example/ruby/SuperSpecs/SingletonAliasCase/Base.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::SingletonAliasCase::Base -**Inherits:** Object - - - - - -#Instance Methods -## alias_on_singleton() [](#method-i-alias_on_singleton) - -## foobar(array) [](#method-i-foobar) - diff --git a/example/ruby/SuperSpecs/SingletonAliasCase/Foo.md b/example/ruby/SuperSpecs/SingletonAliasCase/Foo.md deleted file mode 100644 index cd37086..0000000 --- a/example/ruby/SuperSpecs/SingletonAliasCase/Foo.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::SingletonAliasCase::Foo -**Inherits:** SuperSpecs::SingletonAliasCase::Base - - - - - -#Instance Methods -## foobar(array) [](#method-i-foobar) - diff --git a/example/ruby/SuperSpecs/SingletonCase.md b/example/ruby/SuperSpecs/SingletonCase.md deleted file mode 100644 index 5aa8742..0000000 --- a/example/ruby/SuperSpecs/SingletonCase.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::SingletonCase - - - - - diff --git a/example/ruby/SuperSpecs/SingletonCase/Base.md b/example/ruby/SuperSpecs/SingletonCase/Base.md deleted file mode 100644 index 9290132..0000000 --- a/example/ruby/SuperSpecs/SingletonCase/Base.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::SingletonCase::Base -**Inherits:** Object - - - - - -#Instance Methods -## foobar(array) [](#method-i-foobar) - diff --git a/example/ruby/SuperSpecs/SingletonCase/Foo.md b/example/ruby/SuperSpecs/SingletonCase/Foo.md deleted file mode 100644 index 91554ee..0000000 --- a/example/ruby/SuperSpecs/SingletonCase/Foo.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::SingletonCase::Foo -**Inherits:** SuperSpecs::SingletonCase::Base - - - - - -#Instance Methods -## foobar(array) [](#method-i-foobar) - diff --git a/example/ruby/SuperSpecs/SplatAndKeywords.md b/example/ruby/SuperSpecs/SplatAndKeywords.md deleted file mode 100644 index aaded33..0000000 --- a/example/ruby/SuperSpecs/SplatAndKeywords.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::SplatAndKeywords - - - - - diff --git a/example/ruby/SuperSpecs/SplatAndKeywords/AllArguments.md b/example/ruby/SuperSpecs/SplatAndKeywords/AllArguments.md deleted file mode 100644 index d073e6b..0000000 --- a/example/ruby/SuperSpecs/SplatAndKeywords/AllArguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::SplatAndKeywords::AllArguments -**Inherits:** SuperSpecs::SplatAndKeywords::Arguments - - - - - -#Instance Methods -## foo(*args, **options) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/SplatAndKeywords/Arguments.md b/example/ruby/SuperSpecs/SplatAndKeywords/Arguments.md deleted file mode 100644 index efbd317..0000000 --- a/example/ruby/SuperSpecs/SplatAndKeywords/Arguments.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::SplatAndKeywords::Arguments -**Inherits:** Object - - - - - -#Instance Methods -## foo(*args, **options) [](#method-i-foo) - diff --git a/example/ruby/SuperSpecs/ZSuperInBlock.md b/example/ruby/SuperSpecs/ZSuperInBlock.md deleted file mode 100644 index 7836640..0000000 --- a/example/ruby/SuperSpecs/ZSuperInBlock.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperInBlock - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperInBlock/A.md b/example/ruby/SuperSpecs/ZSuperInBlock/A.md deleted file mode 100644 index 407a808..0000000 --- a/example/ruby/SuperSpecs/ZSuperInBlock/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperInBlock::A -**Inherits:** Object - - - - - -#Instance Methods -## m(arg:) [](#method-i-m) - diff --git a/example/ruby/SuperSpecs/ZSuperInBlock/B.md b/example/ruby/SuperSpecs/ZSuperInBlock/B.md deleted file mode 100644 index 41ff015..0000000 --- a/example/ruby/SuperSpecs/ZSuperInBlock/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperInBlock::B -**Inherits:** SuperSpecs::ZSuperInBlock::A - - - - - -#Instance Methods -## m(arg:) [](#method-i-m) - diff --git a/example/ruby/SuperSpecs/ZSuperWithBlock.md b/example/ruby/SuperSpecs/ZSuperWithBlock.md deleted file mode 100644 index 4efc35f..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithBlock.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithBlock - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithBlock/A.md b/example/ruby/SuperSpecs/ZSuperWithBlock/A.md deleted file mode 100644 index 95527f8..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithBlock/A.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SuperSpecs::ZSuperWithBlock::A -**Inherits:** Object - - - - - -#Instance Methods -## a() [](#method-i-a) - -## b(&block) [](#method-i-b) - -## c() [](#method-i-c) - diff --git a/example/ruby/SuperSpecs/ZSuperWithBlock/B.md b/example/ruby/SuperSpecs/ZSuperWithBlock/B.md deleted file mode 100644 index 2131882..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithBlock/B.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: SuperSpecs::ZSuperWithBlock::B -**Inherits:** SuperSpecs::ZSuperWithBlock::A - - - - - -#Instance Methods -## a() [](#method-i-a) - -## b() [](#method-i-b) - -## c() [](#method-i-c) - diff --git a/example/ruby/SuperSpecs/ZSuperWithOptional.md b/example/ruby/SuperSpecs/ZSuperWithOptional.md deleted file mode 100644 index 4375f0d..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithOptional.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithOptional - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithOptional/A.md b/example/ruby/SuperSpecs/ZSuperWithOptional/A.md deleted file mode 100644 index 889dbf3..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithOptional/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperWithOptional::A -**Inherits:** Object - - - - - -#Instance Methods -## m(x, y, z) [](#method-i-m) - diff --git a/example/ruby/SuperSpecs/ZSuperWithOptional/B.md b/example/ruby/SuperSpecs/ZSuperWithOptional/B.md deleted file mode 100644 index ebb7aec..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithOptional/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperWithOptional::B -**Inherits:** SuperSpecs::ZSuperWithOptional::A - - - - - -#Instance Methods -## m(x, y, z14) [](#method-i-m) - diff --git a/example/ruby/SuperSpecs/ZSuperWithOptional/C.md b/example/ruby/SuperSpecs/ZSuperWithOptional/C.md deleted file mode 100644 index 34f2e54..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithOptional/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperWithOptional::C -**Inherits:** SuperSpecs::ZSuperWithOptional::A - - - - - -#Instance Methods -## m(x, y, z14) [](#method-i-m) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRest.md b/example/ruby/SuperSpecs/ZSuperWithRest.md deleted file mode 100644 index 3b74039..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRest.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithRest - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithRest/A.md b/example/ruby/SuperSpecs/ZSuperWithRest/A.md deleted file mode 100644 index 184ffb1..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRest/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRest::A -**Inherits:** Object - - - - - -#Instance Methods -## m(*args) [](#method-i-m) - -## m_modified(*args) [](#method-i-m_modified) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRest/B.md b/example/ruby/SuperSpecs/ZSuperWithRest/B.md deleted file mode 100644 index c7b7ac9..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRest/B.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRest::B -**Inherits:** SuperSpecs::ZSuperWithRest::A - - - - - -#Instance Methods -## m(*args) [](#method-i-m) - -## m_modified(*args) [](#method-i-m_modified) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestAndOthers.md b/example/ruby/SuperSpecs/ZSuperWithRestAndOthers.md deleted file mode 100644 index 266ab12..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestAndOthers.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithRestAndOthers - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestAndOthers/A.md b/example/ruby/SuperSpecs/ZSuperWithRestAndOthers/A.md deleted file mode 100644 index e5060d5..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestAndOthers/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestAndOthers::A -**Inherits:** Object - - - - - -#Instance Methods -## m(a, b, *args) [](#method-i-m) - -## m_modified(a, b, *args) [](#method-i-m_modified) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestAndOthers/B.md b/example/ruby/SuperSpecs/ZSuperWithRestAndOthers/B.md deleted file mode 100644 index 460114d..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestAndOthers/B.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestAndOthers::B -**Inherits:** SuperSpecs::ZSuperWithRestAndOthers::A - - - - - -#Instance Methods -## m(a, b, *args) [](#method-i-m) - -## m_modified(a, b, *args) [](#method-i-m_modified) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestAndPost.md b/example/ruby/SuperSpecs/ZSuperWithRestAndPost.md deleted file mode 100644 index 8371a9f..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestAndPost.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithRestAndPost - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestAndPost/A.md b/example/ruby/SuperSpecs/ZSuperWithRestAndPost/A.md deleted file mode 100644 index 51ca870..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestAndPost/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestAndPost::A -**Inherits:** Object - - - - - -#Instance Methods -## m(*args, a, b) [](#method-i-m) - -## m_modified(*args, a, b) [](#method-i-m_modified) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestAndPost/B.md b/example/ruby/SuperSpecs/ZSuperWithRestAndPost/B.md deleted file mode 100644 index 1e4aee1..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestAndPost/B.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestAndPost::B -**Inherits:** SuperSpecs::ZSuperWithRestAndPost::A - - - - - -#Instance Methods -## m(*args, a, b) [](#method-i-m) - -## m_modified(*args, a, b) [](#method-i-m_modified) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost.md b/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost.md deleted file mode 100644 index a5f40b8..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithRestOthersAndPost - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost/A.md b/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost/A.md deleted file mode 100644 index eacc077..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestOthersAndPost::A -**Inherits:** Object - - - - - -#Instance Methods -## m(a, *args, b) [](#method-i-m) - -## m_modified(a, *args, b) [](#method-i-m_modified) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost/B.md b/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost/B.md deleted file mode 100644 index dd88f2f..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestOthersAndPost/B.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestOthersAndPost::B -**Inherits:** SuperSpecs::ZSuperWithRestOthersAndPost::A - - - - - -#Instance Methods -## m(a, *args, b) [](#method-i-m) - -## m_modified(a, *args, b) [](#method-i-m_modified) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestReassigned.md b/example/ruby/SuperSpecs/ZSuperWithRestReassigned.md deleted file mode 100644 index 9989f44..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestReassigned.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithRestReassigned - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestReassigned/A.md b/example/ruby/SuperSpecs/ZSuperWithRestReassigned/A.md deleted file mode 100644 index 7c437f9..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestReassigned/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestReassigned::A -**Inherits:** Object - - - - - -#Instance Methods -## a(*args) [](#method-i-a) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestReassigned/B.md b/example/ruby/SuperSpecs/ZSuperWithRestReassigned/B.md deleted file mode 100644 index d218465..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestReassigned/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestReassigned::B -**Inherits:** SuperSpecs::ZSuperWithRestReassigned::A - - - - - -#Instance Methods -## a(*args) [](#method-i-a) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar.md b/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar.md deleted file mode 100644 index 9540992..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithRestReassignedWithScalar - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar/A.md b/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar/A.md deleted file mode 100644 index 647b706..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestReassignedWithScalar::A -**Inherits:** Object - - - - - -#Instance Methods -## a(*args) [](#method-i-a) - diff --git a/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar/B.md b/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar/B.md deleted file mode 100644 index df36db3..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithRestReassignedWithScalar/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: SuperSpecs::ZSuperWithRestReassignedWithScalar::B -**Inherits:** SuperSpecs::ZSuperWithRestReassignedWithScalar::A - - - - - -#Instance Methods -## a(*args) [](#method-i-a) - diff --git a/example/ruby/SuperSpecs/ZSuperWithUnderscores.md b/example/ruby/SuperSpecs/ZSuperWithUnderscores.md deleted file mode 100644 index b82e73a..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithUnderscores.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SuperSpecs::ZSuperWithUnderscores - - - - - diff --git a/example/ruby/SuperSpecs/ZSuperWithUnderscores/A.md b/example/ruby/SuperSpecs/ZSuperWithUnderscores/A.md deleted file mode 100644 index f3ea9bf..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithUnderscores/A.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: SuperSpecs::ZSuperWithUnderscores::A -**Inherits:** Object - - - - - -#Instance Methods -## m(*args) [](#method-i-m) - -## m3(*args) [](#method-i-m3) - -## m4(*args) [](#method-i-m4) - -## m_default(*args) [](#method-i-m_default) - -## m_kwrest(**kw) [](#method-i-m_kwrest) - -## m_modified(*args) [](#method-i-m_modified) - -## m_pre_default_rest_post(*args) [](#method-i-m_pre_default_rest_post) - -## m_rest(*args) [](#method-i-m_rest) - diff --git a/example/ruby/SuperSpecs/ZSuperWithUnderscores/B.md b/example/ruby/SuperSpecs/ZSuperWithUnderscores/B.md deleted file mode 100644 index 82f65f5..0000000 --- a/example/ruby/SuperSpecs/ZSuperWithUnderscores/B.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: SuperSpecs::ZSuperWithUnderscores::B -**Inherits:** SuperSpecs::ZSuperWithUnderscores::A - - - - - -#Instance Methods -## m(_, _) [](#method-i-m) - -## m3(_, _, _) [](#method-i-m3) - -## m4(_, _, _, _) [](#method-i-m4) - -## m_default(_0) [](#method-i-m_default) - -## m_kwrest(**_) [](#method-i-m_kwrest) - -## m_modified(_, _) [](#method-i-m_modified) - -## m_pre_default_rest_post(_, _, _:a, _:b, *_, _, _) [](#method-i-m_pre_default_rest_post) - -## m_rest(*_) [](#method-i-m_rest) - diff --git a/example/ruby/SuperUserGuard.md b/example/ruby/SuperUserGuard.md deleted file mode 100644 index 361e261..0000000 --- a/example/ruby/SuperUserGuard.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SuperUserGuard -**Inherits:** SpecGuard - - - - - -#Instance Methods -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/SupportedGuard.md b/example/ruby/SupportedGuard.md deleted file mode 100644 index 35ca424..0000000 --- a/example/ruby/SupportedGuard.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: SupportedGuard -**Inherits:** SpecGuard - - - - - -#Instance Methods -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/Symbol.md b/example/ruby/Symbol.md deleted file mode 100644 index 75be8e4..0000000 --- a/example/ruby/Symbol.md +++ /dev/null @@ -1,446 +0,0 @@ -# Class: Symbol -**Inherits:** Object - -**Includes:** Comparable - - -******************************************************************** - - A +Symbol+ object represents a named identifier inside the Ruby interpreter. - - You can create a +Symbol+ object explicitly with: - - - A {symbol literal}[rdoc-ref:syntax/literals.rdoc@Symbol+Literals]. - - The same +Symbol+ object will be - created for a given name or string for the duration of a program's - execution, regardless of the context or meaning of that name. Thus - if Fred is a constant in one context, a method in - another, and a class in a third, the +Symbol+ :Fred - will be the same object in all three contexts. - - module One - class Fred - end - $f1 = :Fred - end - module Two - Fred = 1 - $f2 = :Fred - end - def Fred() - end - $f3 = :Fred - $f1.object_id #=> 2514190 - $f2.object_id #=> 2514190 - $f3.object_id #=> 2514190 - - Constant, method, and variable names are returned as symbols: - - module One - Two = 2 - def three; 3 end - @four = 4 - @@five = 5 - $six = 6 - end - seven = 7 - - One.constants - # => [:Two] - One.instance_methods(true) - # => [:three] - One.instance_variables - # => [:@four] - One.class_variables - # => [:@@five] - global_variables.grep(/six/) - # => [:$six] - local_variables - # => [:seven] - - A +Symbol+ object differs from a String object in that - a +Symbol+ object represents an identifier, while a String object - represents text or data. - - == What's Here - - First, what's elsewhere. \Class +Symbol+: - - - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here]. - - Includes {module Comparable}[rdoc-ref:Comparable@What-27s+Here]. - - Here, class +Symbol+ provides methods that are useful for: - - - {Querying}[rdoc-ref:Symbol@Methods+for+Querying] - - {Comparing}[rdoc-ref:Symbol@Methods+for+Comparing] - - {Converting}[rdoc-ref:Symbol@Methods+for+Converting] - - === Methods for Querying - - - ::all_symbols: Returns an array of the symbols currently in Ruby's symbol table. - - #=~: Returns the index of the first substring in symbol that matches a - given Regexp or other object; returns +nil+ if no match is found. - - #[], #slice : Returns a substring of symbol - determined by a given index, start/length, or range, or string. - - #empty?: Returns +true+ if +self.length+ is zero; +false+ otherwise. - - #encoding: Returns the Encoding object that represents the encoding - of symbol. - - #end_with?: Returns +true+ if symbol ends with - any of the given strings. - - #match: Returns a MatchData object if symbol - matches a given Regexp; +nil+ otherwise. - - #match?: Returns +true+ if symbol - matches a given Regexp; +false+ otherwise. - - #length, #size: Returns the number of characters in symbol. - - #start_with?: Returns +true+ if symbol starts with - any of the given strings. - - === Methods for Comparing - - - #<=>: Returns -1, 0, or 1 as a given symbol is smaller than, equal to, - or larger than symbol. - - #==, #===: Returns +true+ if a given symbol has the same content and - encoding. - - #casecmp: Ignoring case, returns -1, 0, or 1 as a given - symbol is smaller than, equal to, or larger than symbol. - - #casecmp?: Returns +true+ if symbol is equal to a given symbol - after Unicode case folding; +false+ otherwise. - - === Methods for Converting - - - #capitalize: Returns symbol with the first character upcased - and all other characters downcased. - - #downcase: Returns symbol with all characters downcased. - - #inspect: Returns the string representation of +self+ as a symbol literal. - - #name: Returns the frozen string corresponding to symbol. - - #succ, #next: Returns the symbol that is the successor to symbol. - - #swapcase: Returns symbol with all upcase characters downcased - and all downcase characters upcased. - - #to_proc: Returns a Proc object which responds to the method named by symbol. - - #to_s, #id2name: Returns the string corresponding to +self+. - - #to_sym, #intern: Returns +self+. - - #upcase: Returns symbol with all characters upcased. - - -# Class Methods -## all_symbols() [](#method-c-all_symbols) -Returns an array of all symbols currently in Ruby's symbol table: - - Symbol.all_symbols.size # => 9334 - Symbol.all_symbols.take(3) # => [:!, :"\"", :"#"] -**@overload** [] - -## json_create(o ) [](#method-c-json_create) -See #as_json. - -#Instance Methods -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(other) [](#method-i-<=>) -If `object` is a symbol, returns the equivalent of `symbol.to_s <=> -object.to_s`: - - :bar <=> :foo # => -1 - :foo <=> :foo # => 0 - :foo <=> :bar # => 1 - -Otherwise, returns `nil`: - - :foo <=> 'bar' # => nil - -Related: String#<=>. - -**@overload** [] - -## ==() [](#method-i-==) - -## ===() [](#method-i-===) - -## =~(other) [](#method-i-=~) -Equivalent to `symbol.to_s =~ object`, including possible updates to global -variables; see String#=~. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## [](*args) [](#method-i-[]) -Equivalent to `symbol.to_s[]`; see String#[]. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Symbol#as_json` and `Symbol.json_create` may be used to serialize and -deserialize a Symbol object; see [Marshal](rdoc-ref:Marshal). - -Method `Symbol#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/symbol' - x = :foo.as_json - # => {"json_class"=>"Symbol", "s"=>"foo"} - -Method `JSON.create` deserializes such a hash, returning a Symbol object: - - Symbol.json_create(x) # => :foo - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## call(*args, &block) [](#method-i-call) - -## capitalize(*args) [](#method-i-capitalize) -Equivalent to `sym.to_s.capitalize.to_sym`. - -See String#capitalize. - -**@overload** [] - -## casecmp(other) [](#method-i-casecmp) -:include: doc/symbol/casecmp.rdoc - -**@overload** [] - -## casecmp?(other) [](#method-i-casecmp?) -:include: doc/symbol/casecmp_p.rdoc - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## downcase(*args) [](#method-i-downcase) -Equivalent to `sym.to_s.downcase.to_sym`. - -See String#downcase. - -Related: Symbol#upcase. - -**@overload** [] - -## empty?() [](#method-i-empty?) -Returns `true` if `self` is `:''`, `false` otherwise. - -**@overload** [] - -## encoding() [](#method-i-encoding) -Equivalent to `self.to_s.encoding`; see String#encoding. - -**@overload** [] - -## end_with?(*args) [](#method-i-end_with?) -Equivalent to `self.to_s.end_with?`; see String#end_with?. - -**@overload** [] - -## hash() [](#method-i-hash) - -## inspect() [](#method-i-inspect) -Returns a string representation of `self` (including the leading colon): - - :foo.inspect # => ":foo" - -Related: Symbol#to_s, Symbol#name. - -**@overload** [] - -## length() [](#method-i-length) -Equivalent to `self.to_s.length`; see String#length. - -**@overload** [] - -## match(*args) [](#method-i-match) -Equivalent to `self.to_s.match`, including possible updates to global -variables; see String#match. - -**@overload** [] - -**@overload** [] - -## match?(*args) [](#method-i-match?) -Equivalent to `sym.to_s.match?`; see String#match. - -**@overload** [] - -## name() [](#method-i-name) -call-seq: - name -> string - -Returns a frozen string representation of `self` (not including the leading -colon): - - :foo.name # => "foo" - :foo.name.frozen? # => true - -Related: Symbol#to_s, Symbol#inspect. - -## next() [](#method-i-next) -Equivalent to `self.to_s.succ.to_sym`: - - :foo.succ # => :fop - -Related: String#succ. - -**@overload** [] - -## size() [](#method-i-size) -Equivalent to `self.to_s.length`; see String#length. - -**@overload** [] - -## slice(*args) [](#method-i-slice) -Equivalent to `symbol.to_s[]`; see String#[]. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## start_with?(*args) [](#method-i-start_with?) -Equivalent to `self.to_s.start_with?`; see String#start_with?. - -**@overload** [] - -## succ() [](#method-i-succ) -Equivalent to `self.to_s.succ.to_sym`: - - :foo.succ # => :fop - -Related: String#succ. - -**@overload** [] - -## swapcase(*args) [](#method-i-swapcase) -Equivalent to `sym.to_s.swapcase.to_sym`. - -See String#swapcase. - -**@overload** [] - -## to_json(*a) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/symbol' - puts :foo.to_json - -Output: - - # {"json_class":"Symbol","s":"foo"} - -## to_proc() [](#method-i-to_proc) -Returns a Proc object which calls the method with name of `self` on the first -parameter and passes the remaining parameters to the method. - - proc = :to_s.to_proc # => # - proc.call(1000) # => "1000" - proc.call(1000, 16) # => "3e8" - (1..3).collect(&:to_s) # => ["1", "2", "3"] - -**@overload** [] - -## to_s() [](#method-i-to_s) -call-seq: - to_s -> string - -Returns a string representation of `self` (not including the leading colon): - - :foo.to_s # => "foo" - -Related: Symbol#inspect, Symbol#name. - -## to_sym() [](#method-i-to_sym) -call-seq: - to_sym -> self - -Returns `self`. - -Related: String#to_sym. - -## upcase(*args) [](#method-i-upcase) -Equivalent to `sym.to_s.upcase.to_sym`. - -See String#upcase. - -**@overload** [] - diff --git a/example/ruby/SymbolSpecs.md b/example/ruby/SymbolSpecs.md deleted file mode 100644 index fa3d878..0000000 --- a/example/ruby/SymbolSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SymbolSpecs - - - - - diff --git a/example/ruby/SymbolSpecs/MyRange.md b/example/ruby/SymbolSpecs/MyRange.md deleted file mode 100644 index 1093e2d..0000000 --- a/example/ruby/SymbolSpecs/MyRange.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: SymbolSpecs::MyRange -**Inherits:** Range - - - - - diff --git a/example/ruby/SyncDefaultGems.md b/example/ruby/SyncDefaultGems.md deleted file mode 100644 index ecae0bb..0000000 --- a/example/ruby/SyncDefaultGems.md +++ /dev/null @@ -1,106 +0,0 @@ -# Module: SyncDefaultGems - -**Extended by:** FileUtils - -**Includes:** FileUtils - - - - -# Class Methods -## apply_mask(mode , user_mask , op , mode_mask ) [](#method-c-apply_mask) -:nodoc: -## check_prerelease_version(gem ) [](#method-c-check_prerelease_version) -## commits_in_ranges(gem , repo , default_branch , ranges ) [](#method-c-commits_in_ranges) -Returns commit list as array of [commit_hash, subject]. -## filter_pickup_files(changed , ignore_file_pattern , base ) [](#method-c-filter_pickup_files) -## fu_get_gid(group ) [](#method-c-fu_get_gid) -:nodoc: -## fu_get_uid(user ) [](#method-c-fu_get_uid) -:nodoc: -## fu_have_symlink?() [](#method-c-fu_have_symlink?) -:nodoc: -**@return** [Boolean] - -## fu_mkdir(path , mode ) [](#method-c-fu_mkdir) -:nodoc: -## fu_mode(mode , path ) [](#method-c-fu_mode) -:nodoc: -## fu_stat_identical_entry?(a , b ) [](#method-c-fu_stat_identical_entry?) -:nodoc: -**@return** [Boolean] - -## ignore_file_pattern_for(gem ) [](#method-c-ignore_file_pattern_for) -## message_filter(repo , sha , input: ARGF) [](#method-c-message_filter) -## mode_to_s(mode ) [](#method-c-mode_to_s) -:nodoc: -## pickup_commit(gem , sha , edit ) [](#method-c-pickup_commit) -## pickup_files(gem , changed , picked ) [](#method-c-pickup_files) -## pipe_readlines(args , rs: "\0", chomp: true) [](#method-c-pipe_readlines) -## preexisting?(base , file ) [](#method-c-preexisting?) -**@return** [Boolean] - -## remove_trailing_slash(dir ) [](#method-c-remove_trailing_slash) -:nodoc: -## replace_rdoc_ref(file ) [](#method-c-replace_rdoc_ref) -## replace_rdoc_ref_all() [](#method-c-replace_rdoc_ref_all) -## resolve_conflicts(gem , sha , edit ) [](#method-c-resolve_conflicts) --- Following methods used by sync_default_gems_with_commits return true: -success false: skipped nil: failed ++ -## symbolic_modes_to_i(mode_sym , path ) [](#method-c-symbolic_modes_to_i) -:nodoc: -## sync_default_gems(gem ) [](#method-c-sync_default_gems) -We usually don't use this. Please consider using -#sync_default_gems_with_commits instead. -## sync_default_gems_with_commits(gem , ranges , edit: nil) [](#method-c-sync_default_gems_with_commits) -NOTE: This method is also used by GitHub ruby/git.ruby-lang.org's -bin/update-default-gem.sh -**@param** [String] A gem name, also used as a git remote name. REPOSITORIES converts it to the appropriate GitHub repository. - -**@param** [Array] "before..after". Note that it will NOT sync "before" (but commits after that). - -**@param** [TrueClass] Set true if you want to resolve conflicts. Obviously, update-default-gem.sh doesn't use this. - -## sync_lib(repo , upstream nil) [](#method-c-sync_lib) -## update_default_gems(gem , release: false) [](#method-c-update_default_gems) -## user_mask(target ) [](#method-c-user_mask) -:nodoc: - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/SyntaxError.md b/example/ruby/SyntaxError.md deleted file mode 100644 index d02390a..0000000 --- a/example/ruby/SyntaxError.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: SyntaxError -**Inherits:** ScriptError - - -Raised when encountering Ruby code with an invalid syntax. - - eval("1+1=2") - -*raises the exception:* - - SyntaxError: (eval):1: syntax error, unexpected '=', expecting $end - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Construct a SyntaxError exception. - -**@overload** [] - diff --git a/example/ruby/SyntaxSuggest.md b/example/ruby/SyntaxSuggest.md deleted file mode 100644 index d79e6b1..0000000 --- a/example/ruby/SyntaxSuggest.md +++ /dev/null @@ -1,107 +0,0 @@ -# Module: SyntaxSuggest - - - - -# Class Methods -## call(source: , filename: DEFAULT_VALUE, terminal: DEFAULT_VALUE, record_dir: DEFAULT_VALUE, timeout: TIMEOUT_DEFAULT, io: $stderr) [](#method-c-call) -SyntaxSuggest.call [Private] - -Main private interface -## handle_error(e , re_raise: true, io: $stderr) [](#method-c-handle_error) -SyntaxSuggest.handle_error [Public] - -Takes a `SyntaxError` exception, uses the error message to locate the file. -Then the file will be analyzed to find the location of the syntax error and -emit that location to stderr. - -Example: - - begin - require 'bad_file' - rescue => e - SyntaxSuggest.handle_error(e) - end - -By default it will re-raise the exception unless `re_raise: false`. The -message output location can be configured using the `io: $stderr` input. - -If a valid filename cannot be determined, the original exception will be -re-raised (even with `re_raise: false`). -## invalid?(source ) [](#method-c-invalid?) -**@return** [Boolean] - -## module_for_detailed_message() [](#method-c-module_for_detailed_message) -SyntaxSuggest.module_for_detailed_message [Private] - -Used to monkeypatch SyntaxError via Module.prepend -## record_dir(dir ) [](#method-c-record_dir) -SyntaxSuggest.record_dir [Private] - -Used to generate a unique directory to record search steps for debugging -## use_prism_parser?() [](#method-c-use_prism_parser?) -SyntaxSuggest.use_prism_parser? [Private] - -Tells us if the prism parser is available for use or if we should fallback to -`Ripper` -**@return** [Boolean] - -## valid?(source ) [](#method-c-valid?) -SyntaxSuggest.valid? [Private] - -Returns truthy if a given input source is valid syntax - - SyntaxSuggest.valid?(<<~EOM) # => true - def foo - end - EOM - - SyntaxSuggest.valid?(<<~EOM) # => false - def foo - def bar # Syntax error here - end - EOM - -You can also pass in an array of lines and they'll be joined before evaluating - - SyntaxSuggest.valid?( - [ - "def foo\n", - "end\n" - ] - ) # => true - - SyntaxSuggest.valid?( - [ - "def foo\n", - " def bar\n", # Syntax error here - "end\n" - ] - ) # => false - -As an FYI the CodeLine class instances respond to `to_s` so passing a CodeLine -in as an object or as an array will convert it to it's code representation. -**@return** [Boolean] - -## valid_without?(without_lines: , code_lines: ) [](#method-c-valid_without?) -SyntaxSuggest.valid_without? [Private] - -This will tell you if the `code_lines` would be valid if you removed the -`without_lines`. In short it's a way to detect if we've found the lines with -syntax errors in our document yet. - - code_lines = [ - CodeLine.new(line: "def foo\n", index: 0) - CodeLine.new(line: " def bar\n", index: 1) - CodeLine.new(line: "end\n", index: 2) - ] - - SyntaxSuggest.valid_without?( - without_lines: code_lines[1], - code_lines: code_lines - ) # => true - - SyntaxSuggest.valid?(code_lines) # => false -**@return** [Boolean] - - diff --git a/example/ruby/SyntaxSuggest/AroundBlockScan.md b/example/ruby/SyntaxSuggest/AroundBlockScan.md deleted file mode 100644 index d0ec13d..0000000 --- a/example/ruby/SyntaxSuggest/AroundBlockScan.md +++ /dev/null @@ -1,111 +0,0 @@ -# Class: SyntaxSuggest::AroundBlockScan -**Inherits:** Object - - -This class is useful for exploring contents before and after a block - -It searches above and below the passed in block to match for whatever criteria -you give it: - -Example: - - def dog # 1 - puts "bark" # 2 - puts "bark" # 3 - end # 4 - - scan = AroundBlockScan.new( - code_lines: code_lines - block: CodeBlock.new(lines: code_lines[1]) - ) - - scan.scan_while { true } - - puts scan.before_index # => 0 - puts scan.after_index # => 3 - - - -#Instance Methods -## code_block() [](#method-i-code_block) -Return the currently matched lines as a `CodeBlock` - -When a `CodeBlock` is created it will gather metadata about itself, so this is -not a free conversion. Avoid allocating more CodeBlock's than needed - -## force_add_empty() [](#method-i-force_add_empty) -When using this flag, `scan_while` will bypass the block it's given and always -add a line that responds truthy to `CodeLine#empty?` - -Empty lines contain no code, only whitespace such as leading spaces a newline. - -## force_add_hidden() [](#method-i-force_add_hidden) -When using this flag, `scan_while` will bypass the block it's given and always -add a line that responds truthy to `CodeLine#hidden?` - -Lines are hidden when they've been evaluated by the parser as part of a block -and found to contain valid code. - -## initialize(code_lines:, block:) [](#method-i-initialize) - -**@return** [AroundBlockScan] a new instance of AroundBlockScan - -## inspect() [](#method-i-inspect) -Manageable rspec errors - -## lines() [](#method-i-lines) -Returns the lines matched by the current scan as an array of CodeLines - -## lookahead_balance_one_line() [](#method-i-lookahead_balance_one_line) -Scanning is intentionally conservative because we have no way of rolling back -an aggressive block (at this time) - -If a block was stopped for some trivial reason, (like an empty line) but the -next line would have caused it to be balanced then we can check that condition -and grab just one more line either up or down. - -For example, below if we're scanning up, line 2 might cause the scanning to -stop. This is because empty lines might denote logical breaks where the user -intended to chunk code which is a good place to stop and check validity. -Unfortunately it also means we might have a "dangling" keyword or end. - - 1 def bark - 2 - 3 end - -If lines 2 and 3 are in the block, then when this method is run it would see -it is unbalanced, but that acquiring line 1 would make it balanced, so that's -what it does. - -## scan_adjacent_indent() [](#method-i-scan_adjacent_indent) -Scan blocks based on indentation of next line above/below block - -Determines indentaion of the next line above/below the current block. - -Normally this is called when a block has expanded to capture all "neighbors" -at the same (or greater) indentation and needs to expand out. For example the -`def/end` lines surrounding a method. - -## scan_neighbors_not_empty() [](#method-i-scan_neighbors_not_empty) -Finds code lines at the same or greater indentation and adds them to the block - -## scan_while() [](#method-i-scan_while) -Main work method - -The scan_while method takes a block that yields lines above and below the -block. If the yield returns true, the @before_index or @after_index are -modified to include the matched line. - -In addition to yielding individual lines, the internals of this object give a -mini DSL to handle common situations such as stopping if we've found a -keyword/end mis-match in one direction or the other. - -## stop_after_kw() [](#method-i-stop_after_kw) -Tells `scan_while` to look for mismatched keyword/end-s - -When scanning up, if we see more keywords then end-s it will stop. This might -happen when scanning outside of a method body. the first scan line up would be -a keyword and this setting would trigger a stop. - -When scanning down, stop if there are more end-s than keywords. - diff --git a/example/ruby/SyntaxSuggest/BlockExpand.md b/example/ruby/SyntaxSuggest/BlockExpand.md deleted file mode 100644 index 5a20eda..0000000 --- a/example/ruby/SyntaxSuggest/BlockExpand.md +++ /dev/null @@ -1,121 +0,0 @@ -# Class: SyntaxSuggest::BlockExpand -**Inherits:** Object - - -This class is responsible for taking a code block that exists at a far -indentaion and then iteratively increasing the block so that it captures -everything within the same indentation block. - - def dog - puts "bow" - puts "wow" - end - -block = BlockExpand.new(code_lines: code_lines) - .call(CodeBlock.new(lines: code_lines[1])) - -puts block.to_s # => puts "bow" - puts "wow" - -Once a code block has captured everything at a given indentation level then it -will expand to capture surrounding indentation. - -block = BlockExpand.new(code_lines: code_lines) - .call(block) - -block.to_s # => def dog - puts "bow" - puts "wow" - end - - - -#Instance Methods -## call(block) [](#method-i-call) -Main interface. Expand current indentation, before expanding to a lower -indentation - -## expand_indent(block) [](#method-i-expand_indent) -Expands code to the next lowest indentation - -For example: - - 1 def dog - 2 print "dog" - 3 end - -If a block starts on line 2 then it has captured all it's "neighbors" (code at -the same indentation or higher). To continue expanding, this block must -capture lines one and three which are at a different indentation level. - -This method allows fully expanded blocks to decrease their indentation level -(so they can expand to capture more code up and down). It does this -conservatively as there's no undo (currently). - -## expand_neighbors(block) [](#method-i-expand_neighbors) -A neighbor is code that is at or above the current indent line. - -First we build a block with all neighbors. If we can't go further then we -decrease the indentation threshold and expand via indentation i.e. -`expand_indent` - -Handles two general cases. - -## Case #1: Check code inside of methods/classes/etc. - -It's important to note, that not everything in a given indentation level can -be parsed as valid code even if it's part of valid code. For example: - - 1 hash = { - 2 name: "richard", - 3 dog: "cinco", - 4 } - -In this case lines 2 and 3 will be neighbors, but they're invalid until -`expand_indent` is called on them. - -When we are adding code within a method or class (at the same indentation -level), use the empty lines to denote the programmer intended logical chunks. -Stop and check each one. For example: - - 1 def dog - 2 print "dog" - 3 - 4 hash = { - 5 end - -If we did not stop parsing at empty newlines then the block might mistakenly -grab all the contents (lines 2, 3, and 4) and report them as being problems, -instead of only line 4. - -## Case #2: Expand/grab other logical blocks - -Once the search algorithm has converted all lines into blocks at a given -indentation it will then `expand_indent`. Once the blocks that generates are -expanded as neighbors we then begin seeing neighbors being other logical -blocks i.e. a block's neighbors may be another method or class (something with -keywords/ends). - -For example: - - 1 def bark - 2 - 3 end - 4 - 5 def sit - 6 end - -In this case if lines 4, 5, and 6 are in a block when it tries to expand -neighbors it will expand up. If it stops after line 2 or 3 it may cause -problems since there's a valid kw/end pair, but the block will be checked -without it. - -We try to resolve this edge case with `lookahead_balance_one_line` below. - -## initialize(code_lines:) [](#method-i-initialize) - -**@return** [BlockExpand] a new instance of BlockExpand - -## inspect() [](#method-i-inspect) -Manageable rspec errors - diff --git a/example/ruby/SyntaxSuggest/Capture.md b/example/ruby/SyntaxSuggest/Capture.md deleted file mode 100644 index 288347f..0000000 --- a/example/ruby/SyntaxSuggest/Capture.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: SyntaxSuggest::Capture - - - - - diff --git a/example/ruby/SyntaxSuggest/Capture/BeforeAfterKeywordEnds.md b/example/ruby/SyntaxSuggest/Capture/BeforeAfterKeywordEnds.md deleted file mode 100644 index 071d161..0000000 --- a/example/ruby/SyntaxSuggest/Capture/BeforeAfterKeywordEnds.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: SyntaxSuggest::Capture::BeforeAfterKeywordEnds -**Inherits:** Object - - -Shows surrounding kw/end pairs - -The purpose of showing these extra pairs is due to cases of ambiguity when -only one visible line is matched. - -For example: - - 1 class Dog - 2 def bark - 4 def eat - 5 end - 6 end - -In this case either line 2 could be missing an `end` or line 4 was an extra -line added by mistake (it happens). - -When we detect the above problem it shows the issue as only being on line 2 - - 2 def bark - -Showing "neighbor" keyword pairs gives extra context: - - 2 def bark - 4 def eat - 5 end - -Example: - - lines = BeforeAfterKeywordEnds.new( - block: block, - code_lines: code_lines - ).call() - - - -#Instance Methods -## call() [](#method-i-call) - -## initialize(code_lines:, block:) [](#method-i-initialize) - -**@return** [BeforeAfterKeywordEnds] a new instance of BeforeAfterKeywordEnds - diff --git a/example/ruby/SyntaxSuggest/Capture/FallingIndentLines.md b/example/ruby/SyntaxSuggest/Capture/FallingIndentLines.md deleted file mode 100644 index 8e06e63..0000000 --- a/example/ruby/SyntaxSuggest/Capture/FallingIndentLines.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: SyntaxSuggest::Capture::FallingIndentLines -**Inherits:** Object - - -Shows the context around code provided by "falling" indentation - -If this is the original code lines: - - class OH - def hello - it "foo" do - end - end - -And this is the line that is captured - - it "foo" do - -It will yield its surrounding context: - - class OH - def hello - end - end - -Example: - - FallingIndentLines.new( - block: block, - code_lines: @code_lines - ).call do |line| - @lines_to_output << line - end - - - -#Instance Methods -## call(&yieldable) [](#method-i-call) - -## initialize(code_lines:, block:) [](#method-i-initialize) - -**@return** [FallingIndentLines] a new instance of FallingIndentLines - diff --git a/example/ruby/SyntaxSuggest/CaptureCodeContext.md b/example/ruby/SyntaxSuggest/CaptureCodeContext.md deleted file mode 100644 index 7aca20e..0000000 --- a/example/ruby/SyntaxSuggest/CaptureCodeContext.md +++ /dev/null @@ -1,138 +0,0 @@ -# Class: SyntaxSuggest::CaptureCodeContext -**Inherits:** Object - - -Turns a "invalid block(s)" into useful context - -There are three main phases in the algorithm: - -1. Sanitize/format input source -2. Search for invalid blocks -3. Format invalid blocks into something meaningful - -This class handles the third part. - -The algorithm is very good at capturing all of a syntax error in a single -block in number 2, however the results can contain ambiguities. Humans are -good at pattern matching and filtering and can mentally remove extraneous -data, but they can't add extra data that's not present. - -In the case of known ambiguious cases, this class adds context back to the -ambiguity so the programmer has full information. - -Beyond handling these ambiguities, it also captures surrounding code context -information: - - puts block.to_s # => "def bark" - - context = CaptureCodeContext.new( - blocks: block, - code_lines: code_lines - ) - - lines = context.call.map(&:original) - puts lines.join - # => - class Dog - def bark - end - - -# Attributes -## code_lines[RW] [](#attribute-i-code_lines) -Returns the value of attribute code_lines. - - -#Instance Methods -## call() [](#method-i-call) - -## capture_before_after_kws(block) [](#method-i-capture_before_after_kws) -Shows surrounding kw/end pairs - -The purpose of showing these extra pairs is due to cases of ambiguity when -only one visible line is matched. - -For example: - - 1 class Dog - 2 def bark - 4 def eat - 5 end - 6 end - -In this case either line 2 could be missing an `end` or line 4 was an extra -line added by mistake (it happens). - -When we detect the above problem it shows the issue as only being on line 2 - - 2 def bark - -Showing "neighbor" keyword pairs gives extra context: - - 2 def bark - 4 def eat - 5 end - -## capture_falling_indent(block) [](#method-i-capture_falling_indent) -Shows the context around code provided by "falling" indentation - -Converts: - - it "foo" do - -into: - - class OH - def hello - it "foo" do - end - end - -## capture_first_kw_end_same_indent(block) [](#method-i-capture_first_kw_end_same_indent) -The logical inverse of `capture_last_end_same_indent` - -When there is an invalid block with an `end` missing a keyword right after -another `end`, it is unclear where which end is missing the keyword. - -Take this example: - - class Dog # 1 - puts "woof" # 2 - end # 3 - end # 4 - -the problem line will be identified as: - - > end # 4 - -This happens because lines 1, 2, and 3 are technically valid code and are -expanded first, deemed valid, and hidden. We need to un-hide the matching -keyword on line 1. Also work backwards and if there's a mis-matched end, show -it too - -## capture_last_end_same_indent(block) [](#method-i-capture_last_end_same_indent) -When there is an invalid block with a keyword missing an end right before -another end, it is unclear where which keyword is missing the end - -Take this example: - - class Dog # 1 - def bark # 2 - puts "woof" # 3 - end # 4 - -However due to https://github.com/ruby/syntax_suggest/issues/32 the problem -line will be identified as: - - > class Dog # 1 - -Because lines 2, 3, and 4 are technically valid code and are expanded first, -deemed valid, and hidden. We need to un-hide the matching end line 4. Also -work backwards and if there's a mis-matched keyword, show it too - -## initialize(blocks:, code_lines:) [](#method-i-initialize) - -**@return** [CaptureCodeContext] a new instance of CaptureCodeContext - -## sorted_lines() [](#method-i-sorted_lines) - diff --git a/example/ruby/SyntaxSuggest/CleanDocument.md b/example/ruby/SyntaxSuggest/CleanDocument.md deleted file mode 100644 index 7a8c750..0000000 --- a/example/ruby/SyntaxSuggest/CleanDocument.md +++ /dev/null @@ -1,213 +0,0 @@ -# Class: SyntaxSuggest::CleanDocument -**Inherits:** Object - - -Parses and sanitizes source into a lexically aware document - -Internally the document is represented by an array with each index containing -a CodeLine correlating to a line from the source code. - -There are three main phases in the algorithm: - -1. Sanitize/format input source -2. Search for invalid blocks -3. Format invalid blocks into something meaningful - -This class handles the first part. - -The reason this class exists is to format input source for -better/easier/cleaner exploration. - -The CodeSearch class operates at the line level so we must be careful to not -introduce lines that look valid by themselves, but when removed will trigger -syntax errors or strange behavior. - -## Join Trailing slashes - -Code with a trailing slash is logically treated as a single line: - - 1 it "code can be split" \ - 2 "across multiple lines" do - -In this case removing line 2 would add a syntax error. We get around this by -internally joining the two lines into a single "line" object - -## Logically Consecutive lines - -Code that can be broken over multiple lines such as method calls are on -different lines: - - 1 User. - 2 where(name: "schneems"). - 3 first - -Removing line 2 can introduce a syntax error. To fix this, all lines are -joined into one. - -## Heredocs - -A heredoc is an way of defining a multi-line string. They can cause many -problems. If left as a single line, the parser would try to parse the contents -as ruby code rather than as a string. Even without this problem, we still hit -an issue with indentation: - - 1 foo = <<~HEREDOC - 2 "Be yourself; everyone else is already taken."" - 3 ― Oscar Wilde - 4 puts "I look like ruby code" # but i'm still a heredoc - 5 HEREDOC - -If we didn't join these lines then our algorithm would think that line 4 is -separate from the rest, has a higher indentation, then look at it first and -remove it. - -If the code evaluates line 5 by itself it will think line 5 is a constant, -remove it, and introduce a syntax errror. - -All of these problems are fixed by joining the whole heredoc into a single -line. - -## Comments and whitespace - -Comments can throw off the way the lexer tells us that the line logically -belongs with the next line. This is valid ruby but results in a different lex -output than before: - - 1 User. - 2 where(name: "schneems"). - 3 # Comment here - 4 first - -To handle this we can replace comment lines with empty lines and then re-lex -the source. This removal and re-lexing preserves line index and document size, -but generates an easier to work with document. - - - -#Instance Methods -## call() [](#method-i-call) -Call all of the document "cleaners" and return self - -## clean_sweep(source:) [](#method-i-clean_sweep) -Remove comments - -replace with empty newlines - - source = <<~'EOM' - # Comment 1 - puts "hello" - # Comment 2 - puts "world" - EOM - - lines = CleanDocument.new(source: source).lines - expect(lines[0].to_s).to eq("\n") - expect(lines[1].to_s).to eq("puts "hello") - expect(lines[2].to_s).to eq("\n") - expect(lines[3].to_s).to eq("puts "world") - -Important: This must be done before lexing. - -After this change is made, we lex the document because removing comments can -change how the doc is parsed. - -For example: - - values = LexAll.new(source: <<~EOM)) - User. - # comment - where(name: 'schneems') - EOM - expect( - values.count {|v| v.type == :on_ignored_nl} - ).to eq(1) - -After the comment is removed: - - values = LexAll.new(source: <<~EOM)) - User. - - where(name: 'schneems') - EOM - expect( - values.count {|v| v.type == :on_ignored_nl} - ).to eq(2) - -## initialize(source:) [](#method-i-initialize) - -**@return** [CleanDocument] a new instance of CleanDocument - -## join_consecutive!() [](#method-i-join_consecutive!) -Smushes logically "consecutive" lines - - source = <<~'EOM' - User. - where(name: 'schneems'). - first - EOM - - lines = CleanDocument.new(source: source).join_consecutive!.lines - expect(lines[0].to_s).to eq(source) - expect(lines[1].to_s).to eq("") - -The one known case this doesn't handle is: - - Ripper.lex <<~EOM - a && - b || - c - EOM - -For some reason this introduces `on_ignore_newline` but with BEG type - -## join_groups(groups) [](#method-i-join_groups) -Helper method for joining "groups" of lines - -Input is expected to be type Array> - -The outer array holds the various "groups" while the inner array holds code -lines. - -All code lines are "joined" into the first line in their group. - -To preserve document size, empty lines are placed in the place of the lines -that were "joined" - -## join_heredoc!() [](#method-i-join_heredoc!) -Smushes all heredoc lines into one line - - source = <<~'EOM' - foo = <<~HEREDOC - lol - hehehe - HEREDOC - EOM - - lines = CleanDocument.new(source: source).join_heredoc!.lines - expect(lines[0].to_s).to eq(source) - expect(lines[1].to_s).to eq("") - -## join_trailing_slash!() [](#method-i-join_trailing_slash!) -Join lines with a trailing slash - - source = <<~'EOM' - it "code can be split" \ - "across multiple lines" do - EOM - - lines = CleanDocument.new(source: source).join_consecutive!.lines - expect(lines[0].to_s).to eq(source) - expect(lines[1].to_s).to eq("") - -## lines() [](#method-i-lines) -Return an array of CodeLines in the document - -## take_while_including(range0) [](#method-i-take_while_including) -Helper method for grabbing elements from document - -Like `take_while` except when it stops iterating, it also returns the line -that caused it to stop - -## to_s() [](#method-i-to_s) -Renders the document back to a string - diff --git a/example/ruby/SyntaxSuggest/Cli.md b/example/ruby/SyntaxSuggest/Cli.md deleted file mode 100644 index a3ab7fb..0000000 --- a/example/ruby/SyntaxSuggest/Cli.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: SyntaxSuggest::Cli -**Inherits:** Object - - -All the logic of the exe/syntax_suggest CLI in one handy spot - - Cli.new(argv: ["--help"]).call - Cli.new(argv: [".rb"]).call - Cli.new(argv: [".rb", "--record=tmp"]).call - Cli.new(argv: [".rb", "--terminal"]).call - - -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - - -#Instance Methods -## call() [](#method-i-call) - -## initialize(argv:, exit_obj:Kernel, io:$stdout, env:ENV) [](#method-i-initialize) -ARGV is Everything passed to the executable, does not include executable name - -All other intputs are dependency injection for testing - -**@return** [Cli] a new instance of Cli - -## parse() [](#method-i-parse) - -## parser() [](#method-i-parser) - diff --git a/example/ruby/SyntaxSuggest/CodeBlock.md b/example/ruby/SyntaxSuggest/CodeBlock.md deleted file mode 100644 index 523f21a..0000000 --- a/example/ruby/SyntaxSuggest/CodeBlock.md +++ /dev/null @@ -1,71 +0,0 @@ -# Class: SyntaxSuggest::CodeBlock -**Inherits:** Object - - -Multiple lines form a singular CodeBlock - -Source code is made of multiple CodeBlocks. - -Example: - - code_block.to_s # => - # def foo - # puts "foo" - # end - - code_block.valid? # => true - code_block.in_valid? # => false - - -# Attributes -## ends_at[RW] [](#attribute-i-ends_at) -Returns the value of attribute ends_at. - -## lines[RW] [](#attribute-i-lines) -Returns the value of attribute lines. - -## starts_at[RW] [](#attribute-i-starts_at) -Returns the value of attribute starts_at. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -This is used for frontier ordering, we are searching from the largest -indentation to the smallest. This allows us to populate an array with multiple -code blocks then call `sort!` on it without having to specify the sorting -criteria - -## current_indent() [](#method-i-current_indent) - -## delete() [](#method-i-delete) - -## deleted?() [](#method-i-deleted?) - -**@return** [Boolean] - -## hidden?() [](#method-i-hidden?) - -**@return** [Boolean] - -## initialize(lines:[]) [](#method-i-initialize) - -**@return** [CodeBlock] a new instance of CodeBlock - -## invalid?() [](#method-i-invalid?) - -**@return** [Boolean] - -## is_end?() [](#method-i-is_end?) - -**@return** [Boolean] - -## mark_invisible() [](#method-i-mark_invisible) - -## to_s() [](#method-i-to_s) - -## valid?() [](#method-i-valid?) - -**@return** [Boolean] - -## visible_lines() [](#method-i-visible_lines) - diff --git a/example/ruby/SyntaxSuggest/CodeFrontier.md b/example/ruby/SyntaxSuggest/CodeFrontier.md deleted file mode 100644 index a632f87..0000000 --- a/example/ruby/SyntaxSuggest/CodeFrontier.md +++ /dev/null @@ -1,102 +0,0 @@ -# Class: SyntaxSuggest::CodeFrontier -**Inherits:** Object - - -There are three main phases in the algorithm: - -1. Sanitize/format input source -2. Search for invalid blocks -3. Format invalid blocks into something meaningful - -The Code frontier is a critical part of the second step - -## Knowing where we've been - -Once a code block is generated it is added onto the frontier. Then it will be -sorted by indentation and frontier can be filtered. Large blocks that fully -enclose a smaller block will cause the smaller block to be evicted. - - CodeFrontier#<<(block) # Adds block to frontier - CodeFrontier#pop # Removes block from frontier - -## Knowing where we can go - -Internally the frontier keeps track of "unvisited" lines which are exposed via -`next_indent_line` when called, this method returns, a line of code with the -highest indentation. - -The returned line of code can be used to build a CodeBlock and then that code -block is added back to the frontier. Then, the lines are removed from the -"unvisited" so we don't double-create the same block. - - CodeFrontier#next_indent_line # Shows next line - CodeFrontier#register_indent_block(block) # Removes lines from unvisited - -## Knowing when to stop - -The frontier knows how to check the entire document for a syntax error. When -blocks are added onto the frontier, they're removed from the document. When -all code containing syntax errors has been added to the frontier, the document -will be parsable without a syntax error and the search can stop. - - CodeFrontier#holds_all_syntax_errors? # Returns true when frontier holds all syntax errors - -## Filtering false positives - -Once the search is completed, the frontier may have multiple blocks that do -not contain the syntax error. To limit the result to the smallest subset of -"invalid blocks" call: - - CodeFrontier#detect_invalid_blocks - - -# Class Methods -## combination(array ) [](#method-c-combination) -Example: - - combination([:a, :b, :c, :d]) - # => [[:a], [:b], [:c], [:d], [:a, :b], [:a, :c], [:a, :d], [:b, :c], [:b, :d], [:c, :d], [:a, :b, :c], [:a, :b, :d], [:a, :c, :d], [:b, :c, :d], [:a, :b, :c, :d]] - -#Instance Methods -## <<(block) [](#method-i-<<) -Add a block to the frontier - -This method ensures the frontier always remains sorted (in indentation order) -and that each code block's lines are removed from the indentation hash so we -don't re-evaluate the same line multiple times. - -## count() [](#method-i-count) - -## detect_invalid_blocks() [](#method-i-detect_invalid_blocks) -Given that we know our syntax error exists somewhere in our frontier, we want -to find the smallest possible set of blocks that contain all the syntax errors - -## expand?() [](#method-i-expand?) - -**@return** [Boolean] - -## holds_all_syntax_errors?(block_array@queue, can_cache:true) [](#method-i-holds_all_syntax_errors?) -Returns true if the document is valid with all lines removed. By default it -checks all blocks in present in the frontier array, but can be used for -arbitrary arrays of codeblocks as well - -**@return** [Boolean] - -## initialize(code_lines:, unvisited:UnvisitedLines.new(code_lines: code_lines)) [](#method-i-initialize) - -**@return** [CodeFrontier] a new instance of CodeFrontier - -## next_indent_line() [](#method-i-next_indent_line) - -## pop() [](#method-i-pop) -Returns a code block with the largest indentation possible - -## register_engulf_block(block) [](#method-i-register_engulf_block) -When one element fully encapsulates another we remove the smaller block from -the frontier. This prevents double expansions and all-around weird behavior. -However this guarantee is quite expensive to maintain - -## register_indent_block(block) [](#method-i-register_indent_block) -Keeps track of what lines have been added to blocks and which are not yet -visited. - diff --git a/example/ruby/SyntaxSuggest/CodeLine.md b/example/ruby/SyntaxSuggest/CodeLine.md deleted file mode 100644 index 09c5892..0000000 --- a/example/ruby/SyntaxSuggest/CodeLine.md +++ /dev/null @@ -1,145 +0,0 @@ -# Class: SyntaxSuggest::CodeLine -**Inherits:** Object - - -Represents a single line of code of a given source file - -This object contains metadata about the line such as amount of indentation, if -it is empty or not, and lexical data, such as if it has an `end` or a keyword -in it. - -Visibility of lines can be toggled off. Marking a line as invisible indicates -that it should not be used for syntax checks. It's functionally the same as -commenting it out. - -Example: - - line = CodeLine.from_source("def foo\n").first - line.number => 1 - line.empty? # => false - line.visible? # => true - line.mark_invisible - line.visible? # => false - - -# Class Methods -## from_source(source , lines: nil) [](#method-c-from_source) -Returns an array of CodeLine objects from the source string -# Attributes -## indent[RW] [](#attribute-i-indent) -Returns the value of attribute indent. - -## index[RW] [](#attribute-i-index) -Returns the value of attribute index. - -## lex[RW] [](#attribute-i-lex) -Returns the value of attribute lex. - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line. - -## line_number[RW] [](#attribute-i-line_number) -Returns the value of attribute line_number. - -## original[RW] [](#attribute-i-original) -When the code line is marked invisible we retain the original value of it's -line this is useful for debugging and for showing extra context - -DisplayCodeWithLineNumbers will render all lines given to it, not just visible -lines, it uses the original method to obtain them. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) -Comparison operator, needed for equality and sorting - -## empty?() [](#method-i-empty?) -An `empty?` line is one that was originally left empty in the source code, -while a "hidden" line is one that we've since marked as "invisible" - -**@return** [Boolean] - -## hidden?() [](#method-i-hidden?) -Opposite or `visible?` (note: different than `empty?`) - -**@return** [Boolean] - -## ignore_newline_not_beg?() [](#method-i-ignore_newline_not_beg?) -Not stable API -: Lines that have a `on_ignored_nl` type token and NOT a `BEG` type seem to - be a good proxy for the ability to join multiple lines into one. - - This predicate method is used to determine when those two criteria have - been met. - - The one known case this doesn't handle is: - - Ripper.lex <<~EOM - a && - b || - c - EOM - - For some reason this introduces `on_ignore_newline` but with BEG type - - -**@return** [Boolean] - -## indent_index() [](#method-i-indent_index) -Used for stable sort via indentation level - -Ruby's sort is not "stable" meaning that when multiple elements have the same -value, they are not guaranteed to return in the same order they were put in. - -So when multiple code lines have the same indentation level, they're sorted by -their index value which is unique and consistent. - -This is mostly needed for consistency of the test suite - -## initialize(line:, index:, lex:) [](#method-i-initialize) - -**@return** [CodeLine] a new instance of CodeLine - -## is_end?() [](#method-i-is_end?) -Returns true if the code line is determined to contain an `end` keyword - -**@return** [Boolean] - -## is_kw?() [](#method-i-is_kw?) -Returns true if the code line is determined to contain a keyword that matches -with an `end` - -For example: `def`, `do`, `begin`, `ensure`, etc. - -**@return** [Boolean] - -## mark_invisible() [](#method-i-mark_invisible) -Used to hide lines - -The search alorithm will group lines into blocks then if those blocks are -determined to represent valid code they will be hidden - -## not_empty?() [](#method-i-not_empty?) -Opposite of `empty?` (note: different than `visible?`) - -**@return** [Boolean] - -## to_s() [](#method-i-to_s) -Renders the given line - -Also allows us to represent source code as an array of code lines. - -When we have an array of code line elements calling `join` on the array will -call `to_s` on each element, which essentially converts it back into it's -original source string. - -## trailing_slash?() [](#method-i-trailing_slash?) - -**@return** [Boolean] - -## visible?() [](#method-i-visible?) -Means the line was marked as "invisible" Confusingly, "empty" lines are -visible...they just don't contain any source code other than a newline ("n"). - -**@return** [Boolean] - diff --git a/example/ruby/SyntaxSuggest/CodeSearch.md b/example/ruby/SyntaxSuggest/CodeSearch.md deleted file mode 100644 index 0ebebeb..0000000 --- a/example/ruby/SyntaxSuggest/CodeSearch.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: SyntaxSuggest::CodeSearch -**Inherits:** Object - - -Searches code for a syntax error - -There are three main phases in the algorithm: - -1. Sanitize/format input source -2. Search for invalid blocks -3. Format invalid blocks into something meaninful - -This class handles the part. - -The bulk of the heavy lifting is done in: - - - CodeFrontier (Holds information for generating blocks and determining if we can stop searching) - - ParseBlocksFromLine (Creates blocks into the frontier) - - BlockExpand (Expands existing blocks to search more code) - -## Syntax error detection - -When the frontier holds the syntax error, we can stop searching - - search = CodeSearch.new(<<~EOM) - def dog - def lol - end - EOM - - search.call - - search.invalid_blocks.map(&:to_s) # => - # => ["def lol\n"] - - -# Attributes -## code_lines[RW] [](#attribute-i-code_lines) -Returns the value of attribute code_lines. - -## invalid_blocks[RW] [](#attribute-i-invalid_blocks) -Returns the value of attribute invalid_blocks. - -## record_dir[RW] [](#attribute-i-record_dir) -Returns the value of attribute record_dir. - - -#Instance Methods -## call() [](#method-i-call) -Main search loop - -## create_blocks_from_untracked_lines() [](#method-i-create_blocks_from_untracked_lines) -Parses the most indented lines into blocks that are marked and added to the -frontier - -## expand_existing() [](#method-i-expand_existing) -Given an already existing block in the frontier, expand it to see if it -contains our invalid syntax - -## initialize(source, record_dir:DEFAULT_VALUE) [](#method-i-initialize) - -**@return** [CodeSearch] a new instance of CodeSearch - -## push(block, name:) [](#method-i-push) - -## record(block:, name:"record") [](#method-i-record) -Used for debugging - diff --git a/example/ruby/SyntaxSuggest/CurrentIndex.md b/example/ruby/SyntaxSuggest/CurrentIndex.md deleted file mode 100644 index 1db0ade..0000000 --- a/example/ruby/SyntaxSuggest/CurrentIndex.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: SyntaxSuggest::CurrentIndex -**Inherits:** Object - - - - -# Attributes -## current_indent[RW] [](#attribute-i-current_indent) -Returns the value of attribute current_indent. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - -## initialize(value) [](#method-i-initialize) - -**@return** [CurrentIndex] a new instance of CurrentIndex - -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/SyntaxSuggest/DisplayCodeWithLineNumbers.md b/example/ruby/SyntaxSuggest/DisplayCodeWithLineNumbers.md deleted file mode 100644 index ff45f86..0000000 --- a/example/ruby/SyntaxSuggest/DisplayCodeWithLineNumbers.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: SyntaxSuggest::DisplayCodeWithLineNumbers -**Inherits:** Object - - -Outputs code with highlighted lines - -Whatever is passed to this class will be rendered even if it is "marked -invisible" any filtering of output should be done before calling this class. - - DisplayCodeWithLineNumbers.new( - lines: lines, - highlight_lines: [lines[2], lines[3]] - ).call - # => - 1 - 2 def cat - > 3 Dir.chdir - > 4 end - 5 end - 6 - - - -#Instance Methods -## call() [](#method-i-call) - -## initialize(lines:, highlight_lines:[], terminal:false) [](#method-i-initialize) - -**@return** [DisplayCodeWithLineNumbers] a new instance of DisplayCodeWithLineNumbers - diff --git a/example/ruby/SyntaxSuggest/DisplayInvalidBlocks.md b/example/ruby/SyntaxSuggest/DisplayInvalidBlocks.md deleted file mode 100644 index 4624fba..0000000 --- a/example/ruby/SyntaxSuggest/DisplayInvalidBlocks.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: SyntaxSuggest::DisplayInvalidBlocks -**Inherits:** Object - - -Used for formatting invalid blocks - - -# Attributes -## filename[RW] [](#attribute-i-filename) -Returns the value of attribute filename. - - -#Instance Methods -## call() [](#method-i-call) - -## document_ok?() [](#method-i-document_ok?) - -**@return** [Boolean] - -## initialize(code_lines:, blocks:, io:$stderr, filename:nil, terminal:DEFAULT_VALUE) [](#method-i-initialize) - -**@return** [DisplayInvalidBlocks] a new instance of DisplayInvalidBlocks - diff --git a/example/ruby/SyntaxSuggest/Error.md b/example/ruby/SyntaxSuggest/Error.md deleted file mode 100644 index e62ec31..0000000 --- a/example/ruby/SyntaxSuggest/Error.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: SyntaxSuggest::Error -**Inherits:** StandardError - - - - - diff --git a/example/ruby/SyntaxSuggest/ExplainSyntax.md b/example/ruby/SyntaxSuggest/ExplainSyntax.md deleted file mode 100644 index adef0f3..0000000 --- a/example/ruby/SyntaxSuggest/ExplainSyntax.md +++ /dev/null @@ -1,59 +0,0 @@ -# Class: SyntaxSuggest::ExplainSyntax -**Inherits:** Object - - -Explains syntax errors based on their source - -example: - - source = "def foo; puts 'lol'" # Note missing end - explain ExplainSyntax.new( - code_lines: CodeLine.from_source(source) - ).call - explain.errors.first - # => "Unmatched keyword, missing `end' ?" - -When the error cannot be determined by lexical counting then the parser is run -against the input and the raw errors are returned. - -Example: - - source = "1 * " # Note missing a second number - explain ExplainSyntax.new( - code_lines: CodeLine.from_source(source) - ).call - explain.errors.first - # => "syntax error, unexpected end-of-input" - - - -#Instance Methods -## call() [](#method-i-call) - -## errors() [](#method-i-errors) -Returns an array of syntax error messages - -If no missing pairs are found it falls back on the original error messages - -## initialize(code_lines:) [](#method-i-initialize) - -**@return** [ExplainSyntax] a new instance of ExplainSyntax - -## missing() [](#method-i-missing) -Returns an array of missing elements - -For example this: - - ExplainSyntax.new(code_lines: lines).missing - # => ["}"] - -Would indicate that the source is missing a `}` character in the source code - -## why(miss) [](#method-i-why) -Converts a missing string to an human understandable explanation. - -Example: - - explain.why("}") - # => "Unmatched `{', missing `}' ?" - diff --git a/example/ruby/SyntaxSuggest/FakeExit.md b/example/ruby/SyntaxSuggest/FakeExit.md deleted file mode 100644 index fa32b83..0000000 --- a/example/ruby/SyntaxSuggest/FakeExit.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: SyntaxSuggest::FakeExit -**Inherits:** Object - - - - -# Attributes -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## called?() [](#method-i-called?) - -**@return** [Boolean] - -## exit(valuenil) [](#method-i-exit) - -## initialize() [](#method-i-initialize) - -**@return** [FakeExit] a new instance of FakeExit - diff --git a/example/ruby/SyntaxSuggest/GetParseErrors.md b/example/ruby/SyntaxSuggest/GetParseErrors.md deleted file mode 100644 index 69c1b1f..0000000 --- a/example/ruby/SyntaxSuggest/GetParseErrors.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: SyntaxSuggest::GetParseErrors -**Inherits:** Object - - - - -# Class Methods -## errors(source ) [](#method-c-errors) - diff --git a/example/ruby/SyntaxSuggest/LeftRightLexCount.md b/example/ruby/SyntaxSuggest/LeftRightLexCount.md deleted file mode 100644 index 12e1f55..0000000 --- a/example/ruby/SyntaxSuggest/LeftRightLexCount.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: SyntaxSuggest::LeftRightLexCount -**Inherits:** Object - - -Find mis-matched syntax based on lexical count - -Used for detecting missing pairs of elements each keyword needs an end, each -'{' needs a '}' etc. - -Example: - - left_right = LeftRightLexCount.new - left_right.count_kw - left_right.missing.first - # => "end" - - left_right = LeftRightLexCount.new - source = "{ a: b, c: d" # Note missing '}' - LexAll.new(source: source).each do |lex| - left_right.count_lex(lex) - end - left_right.missing.first - # => "}" - - - -#Instance Methods -## count_end() [](#method-i-count_end) - -## count_for_char(char) [](#method-i-count_for_char) - -## count_kw() [](#method-i-count_kw) - -## count_lex(lex) [](#method-i-count_lex) -Count source code characters - -Example: - - left_right = LeftRightLexCount.new - left_right.count_lex(LexValue.new(1, :on_lbrace, "{", Ripper::EXPR_BEG)) - left_right.count_for_char("{") - # => 1 - left_right.count_for_char("}") - # => 0 - -## initialize() [](#method-i-initialize) - -**@return** [LeftRightLexCount] a new instance of LeftRightLexCount - -## missing() [](#method-i-missing) -Returns an array of missing syntax characters or `"end"` or `"keyword"` - - left_right.missing - # => ["}"] - diff --git a/example/ruby/SyntaxSuggest/LexAll.md b/example/ruby/SyntaxSuggest/LexAll.md deleted file mode 100644 index b66fb27..0000000 --- a/example/ruby/SyntaxSuggest/LexAll.md +++ /dev/null @@ -1,2089 +0,0 @@ -# Class: SyntaxSuggest::LexAll -**Inherits:** Object - -**Includes:** Enumerable - - -Ripper.lex is not guaranteed to lex the entire source document - -This class guarantees the whole document is lex-ed by iteratively lexing the -document where ripper stopped. - -Prism likely doesn't have the same problem. Once ripper support is removed we -can likely reduce the complexity here if not remove the whole concept. - -Example usage: - - lex = LexAll.new(source: source) - lex.each do |value| - puts value.line - end - - -# Class Methods -## lex(source , line_number ) [](#method-c-lex) - -#Instance Methods -## [](index) [](#method-i-[]) - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(source:, source_lines:nil) [](#method-i-initialize) - -**@return** [LexAll] a new instance of LexAll - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## last() [](#method-i-last) - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a() [](#method-i-to_a) - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/SyntaxSuggest/LexValue.md b/example/ruby/SyntaxSuggest/LexValue.md deleted file mode 100644 index e6d9257..0000000 --- a/example/ruby/SyntaxSuggest/LexValue.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: SyntaxSuggest::LexValue -**Inherits:** Object - - -Value object for accessing lex values - -This lex: - - [1, 0], :on_ident, "describe", CMDARG - -Would translate into: - - lex.line # => 1 - lex.type # => :on_indent - lex.token # => "describe" - - -# Attributes -## line[RW] [](#attribute-i-line) -Returns the value of attribute line. - -## state[RW] [](#attribute-i-state) -Returns the value of attribute state. - -## token[RW] [](#attribute-i-token) -Returns the value of attribute token. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## expr_beg?() [](#method-i-expr_beg?) - -**@return** [Boolean] - -## expr_label?() [](#method-i-expr_label?) - -**@return** [Boolean] - -## fname?() [](#method-i-fname?) - -**@return** [Boolean] - -## ignore_newline?() [](#method-i-ignore_newline?) - -**@return** [Boolean] - -## initialize(line, type, token, state, last_lexnil) [](#method-i-initialize) - -**@return** [LexValue] a new instance of LexValue - -## is_end?() [](#method-i-is_end?) - -**@return** [Boolean] - -## is_kw?() [](#method-i-is_kw?) - -**@return** [Boolean] - diff --git a/example/ruby/SyntaxSuggest/MiniStringIO.md b/example/ruby/SyntaxSuggest/MiniStringIO.md deleted file mode 100644 index f942f63..0000000 --- a/example/ruby/SyntaxSuggest/MiniStringIO.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: SyntaxSuggest::MiniStringIO -**Inherits:** Object - - -Mini String IO [Private] - -Acts like a StringIO with reduced API, but without having to require that -class. - -The original codebase emitted directly to $stderr, but now -SyntaxError#detailed_message needs a string output. To accomplish that we kept -the original print infrastructure in place and added this class to accumulate -the print output into a string. - - -# Attributes -## isatty[RW] [](#attribute-i-isatty) -Returns the value of attribute isatty. - -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - - -#Instance Methods -## initialize(isatty:$stderr.isatty) [](#method-i-initialize) - -**@return** [MiniStringIO] a new instance of MiniStringIO - -## puts(valueEMPTY_ARG) [](#method-i-puts) - diff --git a/example/ruby/SyntaxSuggest/ParseBlocksFromIndentLine.md b/example/ruby/SyntaxSuggest/ParseBlocksFromIndentLine.md deleted file mode 100644 index b95b83a..0000000 --- a/example/ruby/SyntaxSuggest/ParseBlocksFromIndentLine.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: SyntaxSuggest::ParseBlocksFromIndentLine -**Inherits:** Object - - -This class is responsible for generating initial code blocks that will then -later be expanded. - -The biggest concern when guessing code blocks, is accidentally grabbing one -that contains only an "end". In this example: - - def dog - begonn # misspelled `begin` - puts "bark" - end - end - -The following lines would be matched (from bottom to top): - - 1) end - - 2) puts "bark" - end - - 3) begonn - puts "bark" - end - -At this point it has no where else to expand, and it will yield this inner -code as a block - - -# Attributes -## code_lines[RW] [](#attribute-i-code_lines) -Returns the value of attribute code_lines. - - -#Instance Methods -## each_neighbor_block(target_line) [](#method-i-each_neighbor_block) -Builds blocks from bottom up - -## initialize(code_lines:) [](#method-i-initialize) - -**@return** [ParseBlocksFromIndentLine] a new instance of ParseBlocksFromIndentLine - diff --git a/example/ruby/SyntaxSuggest/PathnameFromMessage.md b/example/ruby/SyntaxSuggest/PathnameFromMessage.md deleted file mode 100644 index 59dc6db..0000000 --- a/example/ruby/SyntaxSuggest/PathnameFromMessage.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: SyntaxSuggest::PathnameFromMessage -**Inherits:** Object - - -Converts a SyntaxError message to a path - -Handles the case where the filename has a colon in it such as on a windows -file system: https://github.com/ruby/syntax_suggest/issues/111 - -Example: - - message = "/tmp/scratch:2:in `require_relative': /private/tmp/bad.rb:1: syntax error, unexpected `end' (SyntaxError)" - puts PathnameFromMessage.new(message).call.name - # => "/tmp/scratch.rb" - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## call() [](#method-i-call) - -## initialize(message, io:$stderr) [](#method-i-initialize) - -**@return** [PathnameFromMessage] a new instance of PathnameFromMessage - -## skip_missing_file_name?() [](#method-i-skip_missing_file_name?) - -**@return** [Boolean] - -## stop?() [](#method-i-stop?) - -**@return** [Boolean] - diff --git a/example/ruby/SyntaxSuggest/PriorityEngulfQueue.md b/example/ruby/SyntaxSuggest/PriorityEngulfQueue.md deleted file mode 100644 index fd047c6..0000000 --- a/example/ruby/SyntaxSuggest/PriorityEngulfQueue.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: SyntaxSuggest::PriorityEngulfQueue -**Inherits:** Object - - -Keeps track of what elements are in the queue in priority and also ensures -that when one element engulfs/covers/eats another that the larger element -evicts the smaller element - - - -#Instance Methods -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## initialize() [](#method-i-initialize) - -**@return** [PriorityEngulfQueue] a new instance of PriorityEngulfQueue - -## length() [](#method-i-length) - -## peek() [](#method-i-peek) - -## pop() [](#method-i-pop) - -## push(block) [](#method-i-push) - -## to_a() [](#method-i-to_a) - diff --git a/example/ruby/SyntaxSuggest/PriorityQueue.md b/example/ruby/SyntaxSuggest/PriorityQueue.md deleted file mode 100644 index dee73b3..0000000 --- a/example/ruby/SyntaxSuggest/PriorityQueue.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: SyntaxSuggest::PriorityQueue -**Inherits:** Object - - -Holds elements in a priority heap on insert - -Instead of constantly calling `sort!`, put the element where it belongs the -first time around - -Example: - - queue = PriorityQueue.new - queue << 33 - queue << 44 - queue << 1 - - puts queue.peek # => 44 - - -# Attributes -## elements[RW] [](#attribute-i-elements) -Returns the value of attribute elements. - - -#Instance Methods -## <<(element) [](#method-i-<<) - -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## exchange(source, target) [](#method-i-exchange) - -## initialize() [](#method-i-initialize) - -**@return** [PriorityQueue] a new instance of PriorityQueue - -## length() [](#method-i-length) - -## peek() [](#method-i-peek) - -## pop() [](#method-i-pop) - -## sorted() [](#method-i-sorted) -Used for testing, extremely not performant - -## to_a() [](#method-i-to_a) - diff --git a/example/ruby/SyntaxSuggest/RipperErrors.md b/example/ruby/SyntaxSuggest/RipperErrors.md deleted file mode 100644 index 07f1eb3..0000000 --- a/example/ruby/SyntaxSuggest/RipperErrors.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: SyntaxSuggest::RipperErrors -**Inherits:** Ripper - - -Capture parse errors from Ripper - -Prism returns the errors with their messages, but Ripper does not. To get them -we must make a custom subclass. - -Example: - - puts RipperErrors.new(" def foo").call.errors - # => ["syntax error, unexpected end-of-input, expecting ';' or '\\n'"] - - -# Attributes -## errors[RW] [](#attribute-i-errors) -Returns the value of attribute errors. - - -#Instance Methods -## call() [](#method-i-call) - -## on_parse_error(msg) [](#method-i-on_parse_error) -Comes from ripper, called on every parse error, msg is a string - diff --git a/example/ruby/SyntaxSuggest/ScanHistory.md b/example/ruby/SyntaxSuggest/ScanHistory.md deleted file mode 100644 index b7f965a..0000000 --- a/example/ruby/SyntaxSuggest/ScanHistory.md +++ /dev/null @@ -1,61 +0,0 @@ -# Class: SyntaxSuggest::ScanHistory -**Inherits:** Object - - -Scans up/down from the given block - -You can try out a change, stash it, or commit it to save for later - -Example: - - scanner = ScanHistory.new(code_lines: code_lines, block: block) - scanner.scan( - up: ->(_, _, _) { true }, - down: ->(_, _, _) { true } - ) - scanner.changed? # => true - expect(scanner.lines).to eq(code_lines) - - scanner.stash_changes - - expect(scanner.lines).to_not eq(code_lines) - - -# Attributes -## after_index[RW] [](#attribute-i-after_index) -Returns the value of attribute after_index. - -## before_index[RW] [](#attribute-i-before_index) -Returns the value of attribute before_index. - - -#Instance Methods -## changed?() [](#method-i-changed?) - -**@return** [Boolean] - -## commit_if_changed() [](#method-i-commit_if_changed) - -## initialize(code_lines:, block:) [](#method-i-initialize) - -**@return** [ScanHistory] a new instance of ScanHistory - -## lines() [](#method-i-lines) - -## next_down() [](#method-i-next_down) - -## next_up() [](#method-i-next_up) - -## revert_last_commit() [](#method-i-revert_last_commit) -Discard changes that have not been committed and revert the last commit - -Cannot revert the first commit - -## scan(up:, down:) [](#method-i-scan) -Iterates up and down - -Returns line, kw_count, end_count for each iteration - -## stash_changes() [](#method-i-stash_changes) -Discards any changes that have not been committed - diff --git a/example/ruby/SyntaxSuggest/UnvisitedLines.md b/example/ruby/SyntaxSuggest/UnvisitedLines.md deleted file mode 100644 index 626b96d..0000000 --- a/example/ruby/SyntaxSuggest/UnvisitedLines.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: SyntaxSuggest::UnvisitedLines -**Inherits:** Object - - -Tracks which lines various code blocks have expanded to and which are still -unexplored - - - -#Instance Methods -## empty?() [](#method-i-empty?) - -**@return** [Boolean] - -## initialize(code_lines:) [](#method-i-initialize) - -**@return** [UnvisitedLines] a new instance of UnvisitedLines - -## peek() [](#method-i-peek) - -## pop() [](#method-i-pop) - -## visit_block(block) [](#method-i-visit_block) - diff --git a/example/ruby/SystemCallError.md b/example/ruby/SystemCallError.md deleted file mode 100644 index b83bf7c..0000000 --- a/example/ruby/SystemCallError.md +++ /dev/null @@ -1,37 +0,0 @@ -# Exception: SystemCallError -**Inherits:** StandardError - - -SystemCallError is the base class for all low-level platform-dependent errors. - -The errors available on the current platform are subclasses of SystemCallError -and are defined in the Errno module. - - File.open("does/not/exist") - -*raises the exception:* - - Errno::ENOENT: No such file or directory - does/not/exist - - -# Class Methods -## ===(exc ) [](#method-c-===) -Return `true` if the receiver is a generic `SystemCallError`, or if the error -numbers `self` and *other* are the same. -**@overload** [] - - -#Instance Methods -## errno() [](#method-i-errno) -Return this SystemCallError's error number. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -If *errno* corresponds to a known system error code, constructs the -appropriate Errno class for that error, otherwise constructs a generic -SystemCallError object. The error number is subsequently available via the -#errno method. - -**@overload** [] - diff --git a/example/ruby/SystemExit.md b/example/ruby/SystemExit.md deleted file mode 100644 index 71a7389..0000000 --- a/example/ruby/SystemExit.md +++ /dev/null @@ -1,31 +0,0 @@ -# Exception: SystemExit -**Inherits:** Exception - - -Raised by `exit` to initiate the termination of the script. - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Create a new `SystemExit` exception with the given status and message. Status -is true, false, or an integer. If status is not given, true is used. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## status() [](#method-i-status) -Return the status value associated with this system exit. - -**@overload** [] - -## success?() [](#method-i-success?) -Returns `true` if exiting successful, `false` if not. - -**@overload** [] - diff --git a/example/ruby/SystemStackError.md b/example/ruby/SystemStackError.md deleted file mode 100644 index a5b4ab2..0000000 --- a/example/ruby/SystemStackError.md +++ /dev/null @@ -1,17 +0,0 @@ -# Exception: SystemStackError -**Inherits:** Exception - - -Raised in case of a stack overflow. - - def me_myself_and_i - me_myself_and_i - end - me_myself_and_i - -*raises the exception:* - - SystemStackError: stack level too deep - - - diff --git a/example/ruby/TCPServer.md b/example/ruby/TCPServer.md deleted file mode 100644 index b5aca4e..0000000 --- a/example/ruby/TCPServer.md +++ /dev/null @@ -1,173 +0,0 @@ -# Class: TCPServer -**Inherits:** TCPSocket - - -TCPServer represents a TCP/IP server socket. - -A simple TCP server may look like: - - require 'socket' - - server = TCPServer.new 2000 # Server bind to port 2000 - loop do - client = server.accept # Wait for a client to connect - client.puts "Hello !" - client.puts "Time is #{Time.now}" - client.close - end - -A more usable server (serving multiple clients): - - require 'socket' - - server = TCPServer.new 2000 - loop do - Thread.start(server.accept) do |client| - client.puts "Hello !" - client.puts "Time is #{Time.now}" - client.close - end - end - - - -#Instance Methods -## accept() [](#method-i-accept) -Accepts an incoming connection. It returns a new TCPSocket object. - - TCPServer.open("127.0.0.1", 14641) {|serv| - s = serv.accept - s.puts Time.now - s.close - } - -**@overload** [] - -## accept_nonblock(exception:true) [](#method-i-accept_nonblock) -call-seq: - tcpserver.accept_nonblock([options]) => tcpsocket - -Accepts an incoming connection using accept(2) after O_NONBLOCK is set for the -underlying file descriptor. It returns an accepted TCPSocket for the incoming -connection. - -### Example - require 'socket' serv = TCPServer.new(2202) begin # emulate blocking accept - sock = serv.accept_nonblock rescue IO::WaitReadable, Errno::EINTR -[IO.select(](serv)) retry end # sock is an accepted socket. - -Refer to Socket#accept for the exceptions that may be thrown if the call to -TCPServer#accept_nonblock fails. - -TCPServer#accept_nonblock may raise any error corresponding to accept(2) -failure, including Errno::EWOULDBLOCK. - -If the exception is Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::ECONNABORTED, -Errno::EPROTO, it is extended by IO::WaitReadable. So IO::WaitReadable can be -used to rescue the exceptions for retrying accept_nonblock. - -By specifying a keyword argument *exception* to `false`, you can indicate that -accept_nonblock should not raise an IO::WaitReadable exception, but return the -symbol `:wait_readable` instead. - -### See -* TCPServer#accept -* Socket#accept - -## initialize(*args) [](#method-i-initialize) -Creates a new server socket bound to *port*. - -If *hostname* is given, the socket is bound to it. - - serv = TCPServer.new("127.0.0.1", 28561) - s = serv.accept - s.puts Time.now - s.close - -Internally, TCPServer.new calls getaddrinfo() function to obtain addresses. If -getaddrinfo() returns multiple addresses, TCPServer.new tries to create a -server socket for each address and returns first one that is successful. - -**@overload** [] - -## listen(log) [](#method-i-listen) -Listens for connections, using the specified `int` as the backlog. A call to -*listen* only applies if the `socket` is of type SOCK_STREAM or -SOCK_SEQPACKET. - -### Parameter -* `backlog` - the maximum length of the queue for pending connections. - -### Example 1 - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) - socket.bind( sockaddr ) - socket.listen( 5 ) - -### Example 2 (listening on an arbitrary port, unix-based systems only): - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - socket.listen( 1 ) - -### Unix-based Exceptions -On unix based systems the above will work because a new `sockaddr` struct is -created on the address ADDR_ANY, for an arbitrary port number as handed off by -the kernel. It will not work on Windows, because Windows requires that the -`socket` is bound by calling *bind* before it can *listen*. - -If the *backlog* amount exceeds the implementation-dependent maximum queue -length, the implementation's maximum queue length will be used. - -On unix-based based systems the following system exceptions may be raised if -the call to *listen* fails: -* Errno::EBADF - the *socket* argument is not a valid file descriptor -* Errno::EDESTADDRREQ - the *socket* is not bound to a local address, and - the protocol does not support listening on an unbound socket -* Errno::EINVAL - the *socket* is already connected -* Errno::ENOTSOCK - the *socket* argument does not refer to a socket -* Errno::EOPNOTSUPP - the *socket* protocol does not support listen -* Errno::EACCES - the calling process does not have appropriate privileges -* Errno::EINVAL - the *socket* has been shut down -* Errno::ENOBUFS - insufficient resources are available in the system to - complete the call - -### Windows Exceptions -On Windows systems the following system exceptions may be raised if the call -to *listen* fails: -* Errno::ENETDOWN - the network is down -* Errno::EADDRINUSE - the socket's local address is already in use. This - usually occurs during the execution of *bind* but could be delayed if the - call to *bind* was to a partially wildcard address (involving ADDR_ANY) - and if a specific address needs to be committed at the time of the call to - *listen* -* Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the - service provider is still processing a callback function -* Errno::EINVAL - the `socket` has not been bound with a call to *bind*. -* Errno::EISCONN - the `socket` is already connected -* Errno::EMFILE - no more socket descriptors are available -* Errno::ENOBUFS - no buffer space is available -* Errno::ENOTSOC - `socket` is not a socket -* Errno::EOPNOTSUPP - the referenced `socket` is not a type that supports - the *listen* method - -### See -* listen manual pages on unix-based systems -* listen function in Microsoft's Winsock functions reference - -**@overload** [] - -## sysaccept() [](#method-i-sysaccept) -Returns a file descriptor of a accepted connection. - - TCPServer.open("127.0.0.1", 28561) {|serv| - fd = serv.sysaccept - s = IO.for_fd(fd) - s.puts Time.now - s.close - } - -**@overload** [] - diff --git a/example/ruby/TCPSocket.md b/example/ruby/TCPSocket.md deleted file mode 100644 index 4e7b3c1..0000000 --- a/example/ruby/TCPSocket.md +++ /dev/null @@ -1,79 +0,0 @@ -# Class: TCPSocket -**Inherits:** IPSocket - -**Includes:** CoreExtensions::TCPSocketExt - - -TCPSocket represents a TCP/IP client socket. - -A simple client may look like: - - require 'socket' - - s = TCPSocket.new 'localhost', 2000 - - while line = s.gets # Read lines from socket - puts line # and print them - end - - s.close # close socket when done - - -# Class Methods -## gethostbyname(host ) [](#method-c-gethostbyname) -Use Addrinfo.getaddrinfo instead. This method is deprecated for the following -reasons: - -* The 3rd element of the result is the address family of the first address. - The address families of the rest of the addresses are not returned. -* gethostbyname() may take a long time and it may block other threads. (GVL - cannot be released since gethostbyname() is not thread safe.) -* This method uses gethostbyname() function already removed from POSIX. - -This method lookups host information by *hostname*. - - TCPSocket.gethostbyname("localhost") - #=> ["localhost", ["hal"], 2, "127.0.0.1"] -**@overload** [] - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Opens a TCP connection to `remote_host` on `remote_port`. If `local_host` and -`local_port` are specified, then those parameters are used on the local end to -establish the connection. - -Starting from Ruby 3.4, this method operates according to the Happy Eyeballs -Version 2 ([RFC 8305](https://datatracker.ietf.org/doc/html/rfc8305)) -algorithm by default, except on Windows. - -For details on Happy Eyeballs Version 2, see -[Socket.tcp_fast_fallback=](rdoc-ref:Socket.tcp_fast_fallback=). - -To make it behave the same as in Ruby 3.3 and earlier, explicitly specify the -option fast_fallback:false. Or, setting Socket.tcp_fast_fallback=false will -disable Happy Eyeballs Version 2 not only for this method but for all Socket -globally. - -When using TCPSocket.new on Windows, Happy Eyeballs Version 2 is not provided, -and it behaves the same as in Ruby 3.3 and earlier. - -:resolv_timeout -: Specifies the timeout in seconds from when the hostname resolution starts. - -:connect_timeout -: This method sequentially attempts connecting to all candidate destination - addresses. - The `connect_timeout` specifies the timeout in seconds from the start of - the connection attempt to the last candidate. - By default, all connection attempts continue until the timeout occurs. - When `fast_fallback:false` is explicitly specified, - a timeout is set for each connection attempt and any connection attempt - that exceeds its timeout will be canceled. - -:fast_fallback -: Enables the Happy Eyeballs Version 2 algorithm (enabled by default). - - -**@overload** [] - diff --git a/example/ruby/TC_Enumerable.md b/example/ruby/TC_Enumerable.md deleted file mode 100644 index 11c5bb5..0000000 --- a/example/ruby/TC_Enumerable.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TC_Enumerable -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_to_set() [](#method-i-test_to_set) - diff --git a/example/ruby/TC_IPAddr.md b/example/ruby/TC_IPAddr.md deleted file mode 100644 index 93cdea1..0000000 --- a/example/ruby/TC_IPAddr.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TC_IPAddr -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_as_json() [](#method-i-test_as_json) - -## test_ip6_arpa() [](#method-i-test_ip6_arpa) - -## test_ip6_int() [](#method-i-test_ip6_int) - -## test_ipv4_compat() [](#method-i-test_ipv4_compat) - -## test_ipv4_mapped() [](#method-i-test_ipv4_mapped) - -## test_netmask() [](#method-i-test_netmask) - -## test_ntop() [](#method-i-test_ntop) - -## test_prefix_writer() [](#method-i-test_prefix_writer) - -## test_reverse() [](#method-i-test_reverse) - -## test_s_new() [](#method-i-test_s_new) - -## test_s_new_ntoh() [](#method-i-test_s_new_ntoh) - -## test_to_json() [](#method-i-test_to_json) - -## test_to_range() [](#method-i-test_to_range) - -## test_to_s() [](#method-i-test_to_s) - -## test_wildcard_mask() [](#method-i-test_wildcard_mask) - -## test_zone_id() [](#method-i-test_zone_id) - diff --git a/example/ruby/TC_OpenStruct.md b/example/ruby/TC_OpenStruct.md deleted file mode 100644 index 0612351..0000000 --- a/example/ruby/TC_OpenStruct.md +++ /dev/null @@ -1,82 +0,0 @@ -# Class: TC_OpenStruct -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_access_methods_from_different_ractor() [](#method-i-test_access_methods_from_different_ractor) - -## test_access_original_methods() [](#method-i-test_access_original_methods) - -## test_access_undefined() [](#method-i-test_access_undefined) - -## test_accessor_defines_method() [](#method-i-test_accessor_defines_method) - -## test_allocate_subclass() [](#method-i-test_allocate_subclass) - -## test_class() [](#method-i-test_class) - -## test_delete_field() [](#method-i-test_delete_field) - -## test_dig() [](#method-i-test_dig) - -## test_does_not_redefine() [](#method-i-test_does_not_redefine) - -## test_each_pair() [](#method-i-test_each_pair) - -## test_eql_and_hash() [](#method-i-test_eql_and_hash) - -## test_equality() [](#method-i-test_equality) - -## test_frozen() [](#method-i-test_frozen) - -## test_getter() [](#method-i-test_getter) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_subclass() [](#method-i-test_initialize_subclass) - -## test_inspect() [](#method-i-test_inspect) - -## test_legacy_yaml() [](#method-i-test_legacy_yaml) - -## test_marshal() [](#method-i-test_marshal) - -## test_method_missing() [](#method-i-test_method_missing) - -## test_mistaken_subclass() [](#method-i-test_mistaken_subclass) - -## test_overridden_private_methods() [](#method-i-test_overridden_private_methods) - -## test_overridden_public_methods() [](#method-i-test_overridden_public_methods) - -## test_override_subclass() [](#method-i-test_override_subclass) - -## test_override_submodule() [](#method-i-test_override_submodule) - -## test_performance_warning() [](#method-i-test_performance_warning) - -## test_private_method() [](#method-i-test_private_method) - -## test_protected_method() [](#method-i-test_protected_method) - -## test_ractor() [](#method-i-test_ractor) - -## test_respond_to() [](#method-i-test_respond_to) - -## test_respond_to_allocated() [](#method-i-test_respond_to_allocated) - -## test_respond_to_with_lazy_getter() [](#method-i-test_respond_to_with_lazy_getter) - -## test_setter() [](#method-i-test_setter) - -## test_super() [](#method-i-test_super) - -## test_to_h() [](#method-i-test_to_h) - -## test_to_h_with_block() [](#method-i-test_to_h_with_block) - -## test_yaml() [](#method-i-test_yaml) - diff --git a/example/ruby/TC_Operator.md b/example/ruby/TC_Operator.md deleted file mode 100644 index c15d9bf..0000000 --- a/example/ruby/TC_Operator.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TC_Operator -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_and() [](#method-i-test_and) - -## test_carrot() [](#method-i-test_carrot) - -## test_compare() [](#method-i-test_compare) - -## test_equal() [](#method-i-test_equal) - -## test_hash() [](#method-i-test_hash) - -## test_include?() [](#method-i-test_include?) - -**@return** [Boolean] - -## test_link_local?() [](#method-i-test_link_local?) - -**@return** [Boolean] - -## test_loopback?() [](#method-i-test_loopback?) - -**@return** [Boolean] - -## test_mask() [](#method-i-test_mask) - -## test_native_coerce_mask_addr() [](#method-i-test_native_coerce_mask_addr) - -## test_or() [](#method-i-test_or) - -## test_private?() [](#method-i-test_private?) - -**@return** [Boolean] - -## test_shift_left() [](#method-i-test_shift_left) - -## test_shift_right() [](#method-i-test_shift_right) - diff --git a/example/ruby/TC_Set.md b/example/ruby/TC_Set.md deleted file mode 100644 index 517111e..0000000 --- a/example/ruby/TC_Set.md +++ /dev/null @@ -1,114 +0,0 @@ -# Class: TC_Set -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_intersect(expected, set, other) [](#method-i-assert_intersect) - -## test_add() [](#method-i-test_add) - -## test_and() [](#method-i-test_and) - -## test_aref() [](#method-i-test_aref) - -## test_classify() [](#method-i-test_classify) - -## test_clear() [](#method-i-test_clear) - -## test_clone() [](#method-i-test_clone) - -## test_collect!() [](#method-i-test_collect!) - -## test_compare_by_identity() [](#method-i-test_compare_by_identity) - -## test_delete() [](#method-i-test_delete) - -## test_delete_if() [](#method-i-test_delete_if) - -## test_divide() [](#method-i-test_divide) - -## test_dup() [](#method-i-test_dup) - -## test_each() [](#method-i-test_each) - -## test_empty?() [](#method-i-test_empty?) - -**@return** [Boolean] - -## test_eq() [](#method-i-test_eq) - -## test_eqq() [](#method-i-test_eqq) - -## test_filter!() [](#method-i-test_filter!) - -## test_flatten() [](#method-i-test_flatten) - -## test_freeze() [](#method-i-test_freeze) - -## test_freeze_clone() [](#method-i-test_freeze_clone) - -## test_freeze_clone_false() [](#method-i-test_freeze_clone_false) - -## test_freeze_dup() [](#method-i-test_freeze_dup) - -## test_include?() [](#method-i-test_include?) - -**@return** [Boolean] - -## test_inspect() [](#method-i-test_inspect) - -## test_intersect?() [](#method-i-test_intersect?) - -**@return** [Boolean] - -## test_join() [](#method-i-test_join) - -## test_keep_if() [](#method-i-test_keep_if) - -## test_merge() [](#method-i-test_merge) - -## test_minus() [](#method-i-test_minus) - -## test_plus() [](#method-i-test_plus) - -## test_proper_subset?() [](#method-i-test_proper_subset?) - -**@return** [Boolean] - -## test_proper_superset?() [](#method-i-test_proper_superset?) - -**@return** [Boolean] - -## test_reject!() [](#method-i-test_reject!) - -## test_replace() [](#method-i-test_replace) - -## test_reset() [](#method-i-test_reset) - -## test_s_new() [](#method-i-test_s_new) - -## test_select!() [](#method-i-test_select!) - -## test_size() [](#method-i-test_size) - -## test_spacecraft_operator() [](#method-i-test_spacecraft_operator) - -## test_subset?() [](#method-i-test_subset?) - -**@return** [Boolean] - -## test_subtract() [](#method-i-test_subtract) - -## test_superset?() [](#method-i-test_superset?) - -**@return** [Boolean] - -## test_to_a() [](#method-i-test_to_a) - -## test_to_s() [](#method-i-test_to_s) - -## test_xor() [](#method-i-test_xor) - diff --git a/example/ruby/TC_Set/Set2.md b/example/ruby/TC_Set/Set2.md deleted file mode 100644 index 32c4c96..0000000 --- a/example/ruby/TC_Set/Set2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TC_Set::Set2 -**Inherits:** Set - - - - - diff --git a/example/ruby/TC_Set_Builtin.md b/example/ruby/TC_Set_Builtin.md deleted file mode 100644 index 4f3948f..0000000 --- a/example/ruby/TC_Set_Builtin.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TC_Set_Builtin -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_Set() [](#method-i-test_Set) - -## test_to_set() [](#method-i-test_to_set) - diff --git a/example/ruby/TC_SortedSet.md b/example/ruby/TC_SortedSet.md deleted file mode 100644 index 12edfef..0000000 --- a/example/ruby/TC_SortedSet.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TC_SortedSet -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_runs(ruby, options:nil) [](#method-i-assert_runs) - -## base_dir() [](#method-i-base_dir) - -## test_error() [](#method-i-test_error) - -## test_ok_require() [](#method-i-test_ok_require) - -## test_ok_with_gem() [](#method-i-test_ok_with_gem) - diff --git a/example/ruby/TSort.md b/example/ruby/TSort.md deleted file mode 100644 index 214216d..0000000 --- a/example/ruby/TSort.md +++ /dev/null @@ -1,359 +0,0 @@ -# Module: TSort - - -TSort implements topological sorting using Tarjan's algorithm for strongly -connected components. - -TSort is designed to be able to be used with any object which can be -interpreted as a directed graph. - -TSort requires two methods to interpret an object as a graph, tsort_each_node -and tsort_each_child. - -* tsort_each_node is used to iterate for all nodes over a graph. -* tsort_each_child is used to iterate for child nodes of a given node. - -The equality of nodes are defined by eql? and hash since TSort uses Hash -internally. - -## A Simple Example - -The following example demonstrates how to mix the TSort module into an -existing class (in this case, Hash). Here, we're treating each key in the hash -as a node in the graph, and so we simply alias the required #tsort_each_node -method to Hash's #each_key method. For each key in the hash, the associated -value is an array of the node's child nodes. This choice in turn leads to our -implementation of the required #tsort_each_child method, which fetches the -array of child nodes and then iterates over that array using the user-supplied -block. - - require 'tsort' - - class Hash - include TSort - alias tsort_each_node each_key - def tsort_each_child(node, &block) - fetch(node).each(&block) - end - end - - {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort - #=> [3, 2, 1, 4] - - {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components - #=> [[4], [2, 3], [1]] - -## A More Realistic Example - -A very simple `make' like tool can be implemented as follows: - - require 'tsort' - - class Make - def initialize - @dep = {} - @dep.default = [] - end - - def rule(outputs, inputs=[], &block) - triple = [outputs, inputs, block] - outputs.each {|f| @dep[f] = [triple]} - @dep[triple] = inputs - end - - def build(target) - each_strongly_connected_component_from(target) {|ns| - if ns.length != 1 - fs = ns.delete_if {|n| Array === n} - raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}") - end - n = ns.first - if Array === n - outputs, inputs, block = n - inputs_time = inputs.map {|f| File.mtime f}.max - begin - outputs_time = outputs.map {|f| File.mtime f}.min - rescue Errno::ENOENT - outputs_time = nil - end - if outputs_time == nil || - inputs_time != nil && outputs_time <= inputs_time - sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i - block.call - end - end - } - end - - def tsort_each_child(node, &block) - @dep[node].each(&block) - end - include TSort - end - - def command(arg) - print arg, "\n" - system arg - end - - m = Make.new - m.rule(%w[t1]) { command 'date > t1' } - m.rule(%w[t2]) { command 'date > t2' } - m.rule(%w[t3]) { command 'date > t3' } - m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' } - m.rule(%w[t5], %w[t4 t2]) { command 'cat t4 t2 > t5' } - m.build('t5') - -## Bugs - -* 'tsort.rb' is wrong name because this library uses Tarjan's algorithm for - strongly connected components. Although 'strongly_connected_components.rb' - is correct but too long. - -## References - - 1. Tarjan, "Depth First Search and Linear Graph Algorithms", -*SIAM Journal on Computing*, Vol. 1, No. 2, pp. 146-160, June 1972. - - -# Class Methods -## each_strongly_connected_component(each_node , each_child ) [](#method-c-each_strongly_connected_component) -The iterator version of the TSort.strongly_connected_components method. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc } - #=> [4] - # [2, 3] - # [1] -## each_strongly_connected_component_from(node , each_child , id_map {}, stack []) [](#method-c-each_strongly_connected_component_from) -Iterates over strongly connected components in a graph. The graph is -represented by *node* and *each_child*. - -*node* is the first node. *each_child* should have `call` method which takes a -node argument and yields for each child node. - -Return value is unspecified. - -#TSort.each_strongly_connected_component_from is a class method and it doesn't -need a class to represent a graph which includes TSort. - - graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_child = lambda {|n, &b| graph[n].each(&b) } - TSort.each_strongly_connected_component_from(1, each_child) {|scc| - p scc - } - #=> [4] - # [2, 3] - # [1] -## strongly_connected_components(each_node , each_child ) [](#method-c-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p TSort.strongly_connected_components(each_node, each_child) - #=> [[4], [2], [3], [1]] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p TSort.strongly_connected_components(each_node, each_child) - #=> [[4], [2, 3], [1]] -## tsort(each_node , each_child ) [](#method-c-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - -If there is a cycle, TSort::Cyclic is raised. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1] - - g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - p TSort.tsort(each_node, each_child) # raises TSort::Cyclic -## tsort_each(each_node , each_child ) [](#method-c-tsort_each) -The iterator version of the TSort.tsort method. - -The graph is represented by *each_node* and *each_child*. *each_node* should -have `call` method which yields for each node in the graph. *each_child* -should have `call` method which takes a node argument and yields for each -child node. - - g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} - each_node = lambda {|&b| g.each_key(&b) } - each_child = lambda {|n, &b| g[n].each(&b) } - TSort.tsort_each(each_node, each_child) {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -#Instance Methods -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, TSort::Cyclic is raised. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, TSort::Cyclic is raised. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## tsort_each_child(node) [](#method-i-tsort_each_child) -Should be implemented by a extended class. - -#tsort_each_child is used to iterate for child nodes of *node*. - -**@raise** [NotImplementedError] - -## tsort_each_node() [](#method-i-tsort_each_node) -Should be implemented by a extended class. - -#tsort_each_node is used to iterate for all nodes over a graph. - -**@raise** [NotImplementedError] - diff --git a/example/ruby/TSort/Cyclic.md b/example/ruby/TSort/Cyclic.md deleted file mode 100644 index a8b9cc7..0000000 --- a/example/ruby/TSort/Cyclic.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TSort::Cyclic -**Inherits:** StandardError - - - - - diff --git a/example/ruby/TSortArray.md b/example/ruby/TSortArray.md deleted file mode 100644 index 2516c82..0000000 --- a/example/ruby/TSortArray.md +++ /dev/null @@ -1,135 +0,0 @@ -# Class: TSortArray -**Inherits:** Array - -**Includes:** TSort - - -:nodoc: - - - -#Instance Methods -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, TSort::Cyclic is raised. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, TSort::Cyclic is raised. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## tsort_each_child(node, &block) [](#method-i-tsort_each_child) - diff --git a/example/ruby/TSortHash.md b/example/ruby/TSortHash.md deleted file mode 100644 index c767e84..0000000 --- a/example/ruby/TSortHash.md +++ /dev/null @@ -1,135 +0,0 @@ -# Class: TSortHash -**Inherits:** Hash - -**Includes:** TSort - - -:nodoc: - - - -#Instance Methods -## each_strongly_connected_component(&block) [](#method-i-each_strongly_connected_component) -The iterator version of the #strongly_connected_components method. -*`obj*.each_strongly_connected_component` is similar to -*`obj*.strongly_connected_components.each`, but modification of *obj* during -the iteration may lead to unexpected results. - -#each_strongly_connected_component returns `nil`. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2] - # [3] - # [1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component {|scc| p scc } - #=> [4] - # [2, 3] - # [1] - -## each_strongly_connected_component_from(node, id_map{}, stack[], &block) [](#method-i-each_strongly_connected_component_from) -Iterates over strongly connected component in the subgraph reachable from -*node*. - -Return value is unspecified. - -#each_strongly_connected_component_from doesn't call #tsort_each_node. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - graph.each_strongly_connected_component_from(2) {|scc| p scc } - #=> [4] - # [2, 3] - -## strongly_connected_components() [](#method-i-strongly_connected_components) -Returns strongly connected components as an array of arrays of nodes. The -array is sorted from children to parents. Each elements of the array -represents a strongly connected component. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2], [3], [1]] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.strongly_connected_components #=> [[4], [2, 3], [1]] - -## tsort() [](#method-i-tsort) -Returns a topologically sorted array of nodes. The array is sorted from -children to parents, i.e. the first element has no child and the last node has -no parent. - -If there is a cycle, TSort::Cyclic is raised. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - p graph.tsort #=> [4, 2, 3, 1] - - graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) - p graph.tsort # raises TSort::Cyclic - -## tsort_each(&block) [](#method-i-tsort_each) -The iterator version of the #tsort method. *`obj*.tsort_each` is similar to -*`obj*.tsort.each`, but modification of *obj* during the iteration may lead to -unexpected results. - -#tsort_each returns `nil`. If there is a cycle, TSort::Cyclic is raised. - - class G - include TSort - def initialize(g) - @g = g - end - def tsort_each_child(n, &b) @g[n].each(&b) end - def tsort_each_node(&b) @g.each_key(&b) end - end - - graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) - graph.tsort_each {|n| p n } - #=> 4 - # 2 - # 3 - # 1 - -## tsort_each_child(node, &block) [](#method-i-tsort_each_child) - diff --git a/example/ruby/TSortTest.md b/example/ruby/TSortTest.md deleted file mode 100644 index ca880b4..0000000 --- a/example/ruby/TSortTest.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TSortTest -**Inherits:** Test::Unit::TestCase - - -:nodoc: - - - -#Instance Methods -## test_array() [](#method-i-test_array) - -## test_cycle() [](#method-i-test_cycle) - -## test_dag() [](#method-i-test_dag) - -## test_s_each_strongly_connected_component() [](#method-i-test_s_each_strongly_connected_component) - -## test_s_each_strongly_connected_component_from() [](#method-i-test_s_each_strongly_connected_component_from) - -## test_s_strongly_connected_components() [](#method-i-test_s_strongly_connected_components) - -## test_s_tsort() [](#method-i-test_s_tsort) - -## test_s_tsort_each() [](#method-i-test_s_tsort_each) - diff --git a/example/ruby/TagAction.md b/example/ruby/TagAction.md deleted file mode 100644 index 54972e9..0000000 --- a/example/ruby/TagAction.md +++ /dev/null @@ -1,67 +0,0 @@ -# Class: TagAction -**Inherits:** ActionFilter - - -TagAction - Write tagged spec description string to a tag file associated with -each spec file. - -The action is triggered by specs whose descriptions match the filter created -with 'tags' and/or 'desc' - -The action fires in the :after event, after the spec had been run. The action -fires if the outcome of running the spec matches 'outcome'. - -The arguments are: - - action: :add, :del - outcome: :pass, :fail, :all - tag: the tag to create/delete - comment: the comment to create - tags: zero or more tags to get matching - spec description strings from - desc: zero or more strings to match the - spec description strings - - - -#Instance Methods -## ===(string) [](#method-i-===) -Returns true if there are no *tag* or *description* filters. This means that a -TagAction matches any example by default. Otherwise, returns true if either -the *tag* or the *description* filter matches `string`. - -## after(state) [](#method-i-after) -Callback for the MSpec :after event. Performs the tag action depending on the -type of action and the outcome of evaluating the example. See `TagAction` for -a description of the actions. - -## before(state) [](#method-i-before) -Callback for the MSpec :before event. Resets the `#exception?` flag to false. - -## exception(exception) [](#method-i-exception) -Callback for the MSpec :exception event. Sets the `#exception?` flag to true. - -## exception?() [](#method-i-exception?) -Returns true if an exception was raised while evaluating the current example. - -**@return** [Boolean] - -## finish() [](#method-i-finish) -Callback for the MSpec :finish event. Prints the actions performed while -evaluating the examples. - -## initialize(action, outcome, tag, comment, tagsnil, descsnil) [](#method-i-initialize) - -**@return** [TagAction] a new instance of TagAction - -## outcome?() [](#method-i-outcome?) -Returns true if the result of evaluating the example matches the *outcome* -registered for this tag action. See `TagAction` for a description of the -*outcome* types. - -**@return** [Boolean] - -## register() [](#method-i-register) - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/TagFilter.md b/example/ruby/TagFilter.md deleted file mode 100644 index 84171c8..0000000 --- a/example/ruby/TagFilter.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TagFilter -**Inherits:** Object - - - - - -#Instance Methods -## ===(string) [](#method-i-===) - -## initialize(what, *tags) [](#method-i-initialize) - -**@return** [TagFilter] a new instance of TagFilter - -## load() [](#method-i-load) - -## register() [](#method-i-register) - -## unload() [](#method-i-unload) - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/TagListAction.md b/example/ruby/TagListAction.md deleted file mode 100644 index dd77259..0000000 --- a/example/ruby/TagListAction.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: TagListAction -**Inherits:** Object - - -TagListAction - prints out the descriptions for any specs tagged with `tags`. -If `tags` is an empty list, prints out descriptions for any specs that are -tagged. - - - -#Instance Methods -## ===(string) [](#method-i-===) -Returns true if any tagged descriptions matches `string`. - -## after(state) [](#method-i-after) -Prints the spec description if it matches the filter. - -## include?(arg) [](#method-i-include?) -Returns true. This enables us to match any tag when loading tags from the -file. - -**@return** [Boolean] - -## initialize(tagsnil) [](#method-i-initialize) - -**@return** [TagListAction] a new instance of TagListAction - -## load() [](#method-i-load) -Creates a MatchFilter for specific tags or for all tags. - -## register() [](#method-i-register) - -## start() [](#method-i-start) -Prints a banner about matching tagged specs. - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/TagPurgeAction.md b/example/ruby/TagPurgeAction.md deleted file mode 100644 index a182e4e..0000000 --- a/example/ruby/TagPurgeAction.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TagPurgeAction -**Inherits:** TagListAction - - -TagPurgeAction - removes all tags not matching any spec descriptions. - - -# Attributes -## matching[RW] [](#attribute-i-matching) -Returns the value of attribute matching. - - -#Instance Methods -## after(state) [](#method-i-after) -Saves any matching tags - -## initialize() [](#method-i-initialize) - -**@return** [TagPurgeAction] a new instance of TagPurgeAction - -## load() [](#method-i-load) -Creates a MatchFilter for all tags. - -## register() [](#method-i-register) - -## start() [](#method-i-start) -Prints a banner about purging tags. - -## unload() [](#method-i-unload) -Rewrites any matching tags. Prints non-matching tags. Deletes the tag file if -there were no tags (this cleans up empty or malformed tag files). - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/TagsVisitor.md b/example/ruby/TagsVisitor.md deleted file mode 100644 index df918eb..0000000 --- a/example/ruby/TagsVisitor.md +++ /dev/null @@ -1,79 +0,0 @@ -# Class: TagsVisitor -**Inherits:** Prism::Visitor - - -This visitor is responsible for visiting the nodes in the AST and generating -the appropriate tags. The tags are stored in the entries array as strings. - - -# Attributes -## entries[RW] [](#attribute-i-entries) -Returns the value of attribute entries. - -## filepath[RW] [](#attribute-i-filepath) -Returns the value of attribute filepath. - -## lines[RW] [](#attribute-i-lines) -Returns the value of attribute lines. - -## nesting[RW] [](#attribute-i-nesting) -Returns the value of attribute nesting. - -## singleton[RW] [](#attribute-i-singleton) -Returns the value of attribute singleton. - - -#Instance Methods -## initialize(entries, filepath, lines, nesting[], singletonfalse) [](#method-i-initialize) -Initialize the visitor with the given parameters. The first three parameters -are constant throughout the visit, while the last two are controlled by the -visitor as it traverses the AST. These are treated as immutable by virtue of -the visit methods constructing new visitors when they need to change. - -**@return** [TagsVisitor] a new instance of TagsVisitor - -## visit_alias_method_node(node) [](#method-i-visit_alias_method_node) -Visit a method alias node and generate the appropriate tags. - - alias m2 m1 - -## visit_call_node(node) [](#method-i-visit_call_node) -Visit a method call to attr_reader, attr_writer, or attr_accessor without a -receiver and generate the appropriate tags. Note that this ignores the fact -that these methods could be overridden, which is a limitation of this script. - - attr_accessor :m1 - -## visit_class_node(node) [](#method-i-visit_class_node) -Visit a class node and generate the appropriate tags. - - class C1 - end - -## visit_constant_path_write_node(node) [](#method-i-visit_constant_path_write_node) -Visit a constant path write node and generate the appropriate tags. - - C1::C2 = 1 - -## visit_constant_write_node(node) [](#method-i-visit_constant_write_node) -Visit a constant write node and generate the appropriate tags. - - C1 = 1 - -## visit_def_node(node) [](#method-i-visit_def_node) -Visit a method definition node and generate the appropriate tags. - - def m1; end - -## visit_module_node(node) [](#method-i-visit_module_node) -Visit a module node and generate the appropriate tags. - - module M1 - end - -## visit_singleton_class_node(node) [](#method-i-visit_singleton_class_node) -Visit a singleton class node and generate the appropriate tags. - - class << self - end - diff --git a/example/ruby/Tally.md b/example/ruby/Tally.md deleted file mode 100644 index e4c031c..0000000 --- a/example/ruby/Tally.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: Tally -**Inherits:** Object - - - - -# Attributes -## errors[RW] [](#attribute-i-errors) -Returns the value of attribute errors. - -## examples[RW] [](#attribute-i-examples) -Returns the value of attribute examples. - -## expectations[RW] [](#attribute-i-expectations) -Returns the value of attribute expectations. - -## failures[RW] [](#attribute-i-failures) -Returns the value of attribute failures. - -## files[RW] [](#attribute-i-files) -Returns the value of attribute files. - -## guards[RW] [](#attribute-i-guards) -Returns the value of attribute guards. - -## tagged[RW] [](#attribute-i-tagged) -Returns the value of attribute tagged. - - -#Instance Methods -## error() [](#method-i-error) - -## errors!(add1) [](#method-i-errors!) - -## example() [](#method-i-example) - -## examples!(add1) [](#method-i-examples!) - -## expectation() [](#method-i-expectation) - -## expectations!(add1) [](#method-i-expectations!) - -## failure() [](#method-i-failure) - -## failures!(add1) [](#method-i-failures!) - -## file() [](#method-i-file) - -## files!(add1) [](#method-i-files!) - -## format() [](#method-i-format) - -## guard() [](#method-i-guard) - -## guards!(add1) [](#method-i-guards!) - -## initialize() [](#method-i-initialize) - -**@return** [Tally] a new instance of Tally - -## tag() [](#method-i-tag) - -## tagged!(add1) [](#method-i-tagged!) - diff --git a/example/ruby/TallyAction.md b/example/ruby/TallyAction.md deleted file mode 100644 index 5d5f092..0000000 --- a/example/ruby/TallyAction.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: TallyAction -**Inherits:** Object - - - - -# Attributes -## counter[RW] [](#attribute-i-counter) -Returns the value of attribute counter. - - -#Instance Methods -## example(state, block) [](#method-i-example) -Callback for the MSpec :example event. Increments the tally of examples. - -## exception(exception) [](#method-i-exception) -Callback for the MSpec :exception event. Increments the tally of errors and -failures. - -## expectation(state) [](#method-i-expectation) -Callback for the MSpec :expectation event. Increments the tally of -expectations (e.g. #should, #should_receive, etc.). - -## format() [](#method-i-format) - -## initialize() [](#method-i-initialize) - -**@return** [TallyAction] a new instance of TallyAction - -## load() [](#method-i-load) - -## register() [](#method-i-register) - -## tagged(state) [](#method-i-tagged) - -## unregister() [](#method-i-unregister) - diff --git a/example/ruby/Tarball.md b/example/ruby/Tarball.md deleted file mode 100644 index b8c7a96..0000000 --- a/example/ruby/Tarball.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: Tarball -**Inherits:** Object - - - - -# Class Methods -## parse(wwwdir , version ) [](#method-c-parse) -* /home/naruse/obj/ruby-trunk/tmp/ruby-2.6.0-preview3.tar.gz SIZE: - 17116009 bytes SHA1: 21f62c369661a2ab1b521fd2fa8191a4273e12a1 SHA256: - 97cea8aa63dfa250ba6902b658a7aa066daf817b22f82b7ee28f44aec7c2e394 SHA512: - 1e2042324821bb4e110af7067f52891606dcfc71e640c194ab1c117f0b941550e0b3ac36ad - 3511214ac80c536b9e5cfaf8789eec74cf56971a832ea8fc4e6d94 -## update_branches_yml(ver , xy , wwwdir ) [](#method-c-update_branches_yml) -## update_downloads_yml(ver , xy , wwwdir ) [](#method-c-update_downloads_yml) -## update_releases_yml(ver , xy , ary , wwwdir , files_changed , insertions , deletions ) [](#method-c-update_releases_yml) -# Attributes -## sha1[RW] [](#attribute-i-sha1) -Returns the value of attribute sha1. - -## sha256[RW] [](#attribute-i-sha256) -Returns the value of attribute sha256. - -## sha512[RW] [](#attribute-i-sha512) -Returns the value of attribute sha512. - -## size[RW] [](#attribute-i-size) -Returns the value of attribute size. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## ext() [](#method-i-ext) - -## gz?() [](#method-i-gz?) - -**@return** [Boolean] - -## initialize(version, url, size, sha1, sha256, sha512) [](#method-i-initialize) - -**@return** [Tarball] a new instance of Tarball - -## to_md() [](#method-i-to_md) - -## xz?() [](#method-i-xz?) - -**@return** [Boolean] - -## zip?() [](#method-i-zip?) - -**@return** [Boolean] - diff --git a/example/ruby/Tempfile.md b/example/ruby/Tempfile.md deleted file mode 100644 index e538856..0000000 --- a/example/ruby/Tempfile.md +++ /dev/null @@ -1,422 +0,0 @@ -# Class: Tempfile -**Inherits:** File - - -A utility class for managing temporary files. - -There are two kind of methods of creating a temporary file: - -* Tempfile.create (recommended) -* Tempfile.new and Tempfile.open (mostly for backward compatibility, not - recommended) - -Tempfile.create creates a usual File object. The timing of file deletion is -predictable. Also, it supports open-and-unlink technique which removes the -temporary file immediately after creation. - -Tempfile.new and Tempfile.open creates a Tempfile object. The created file is -removed by the GC (finalizer). The timing of file deletion is not predictable. - -## Synopsis - - require 'tempfile' - - # Tempfile.create with a block - # The filename are choosen automatically. - # (You can specify the prefix and suffix of the filename by an optional argument.) - Tempfile.create {|f| - f.puts "foo" - f.rewind - f.read # => "foo\n" - } # The file is removed at block exit. - - # Tempfile.create without a block - # You need to unlink the file in non-block form. - f = Tempfile.create - f.puts "foo" - f.close - File.unlink(f.path) # You need to unlink the file. - - # Tempfile.create(anonymous: true) without a block - f = Tempfile.create(anonymous: true) - # The file is already removed because anonymous. - f.path # => "/tmp/" (no filename since no file) - f.puts "foo" - f.rewind - f.read # => "foo\n" - f.close - - # Tempfile.create(anonymous: true) with a block - Tempfile.create(anonymous: true) {|f| - # The file is already removed because anonymous. - f.path # => "/tmp/" (no filename since no file) - f.puts "foo" - f.rewind - f.read # => "foo\n" - } - - # Not recommended: Tempfile.new without a block - file = Tempfile.new('foo') - file.path # => A unique filename in the OS's temp directory, - # e.g.: "/tmp/foo.24722.0" - # This filename contains 'foo' in its basename. - file.write("hello world") - file.rewind - file.read # => "hello world" - file.close - file.unlink # deletes the temp file - -## About Tempfile.new and Tempfile.open - -This section does not apply to Tempfile.create because it returns a File -object (not a Tempfile object). - -When you create a Tempfile object, it will create a temporary file with a -unique filename. A Tempfile objects behaves just like a File object, and you -can perform all the usual file operations on it: reading data, writing data, -changing its permissions, etc. So although this class does not explicitly -document all instance methods supported by File, you can in fact call any File -instance method on a Tempfile object. - -A Tempfile object has a finalizer to remove the temporary file. This means -that the temporary file is removed via GC. This can cause several problems: - -* Long GC intervals and conservative GC can accumulate temporary files that - are not removed. -* Temporary files are not removed if Ruby exits abnormally (such as SIGKILL, - SEGV). - -There are legacy good practices for Tempfile.new and Tempfile.open as follows. - -### Explicit close - -When a Tempfile object is garbage collected, or when the Ruby interpreter -exits, its associated temporary file is automatically deleted. This means that -it's unnecessary to explicitly delete a Tempfile after use, though it's a good -practice to do so: not explicitly deleting unused Tempfiles can potentially -leave behind a large number of temp files on the filesystem until they're -garbage collected. The existence of these temp files can make it harder to -determine a new Tempfile filename. - -Therefore, one should always call #unlink or close in an ensure block, like -this: - - file = Tempfile.new('foo') - begin - # ...do something with file... - ensure - file.close - file.unlink # deletes the temp file - end - -Tempfile.create { ... } exists for this purpose and is more convenient to use. -Note that Tempfile.create returns a File instance instead of a Tempfile, which -also avoids the overhead and complications of delegation. - - Tempfile.create('foo') do |file| - # ...do something with file... - end - -### Unlink after creation - -On POSIX systems, it's possible to unlink a file right after creating it, and -before closing it. This removes the filesystem entry without closing the file -handle, so it ensures that only the processes that already had the file handle -open can access the file's contents. It's strongly recommended that you do -this if you do not want any other processes to be able to read from or write -to the Tempfile, and you do not need to know the Tempfile's filename either. - -Also, this guarantees the temporary file is removed even if Ruby exits -abnormally. The OS reclaims the storage for the temporary file when the file -is closed or the Ruby process exits (normally or abnormally). - -For example, a practical use case for unlink-after-creation would be this: you -need a large byte buffer that's too large to comfortably fit in RAM, e.g. when -you're writing a web server and you want to buffer the client's file upload -data. - -`Tempfile.create(anonymous: true)` supports this behavior. It also works on -Windows. - -## Minor notes - -Tempfile's filename picking method is both thread-safe and inter-process-safe: -it guarantees that no other threads or processes will pick the same filename. - -Tempfile itself however may not be entirely thread-safe. If you access the -same Tempfile object from multiple threads then you should protect it with a -mutex. - - -# Class Methods -## create(basename , *rest ) [](#method-c-create) -Creates a file in the underlying file system; returns a new File object based -on that file. - -With no block given and no arguments, creates and returns file whose: - -* Class is [File](rdoc-ref:File) (not Tempfile). -* Directory is the system temporary directory (system-dependent). -* Generated filename is unique in that directory. -* Permissions are `0600`; see [File - Permissions](rdoc-ref:File@File+Permissions). -* Mode is `'w+'` (read/write mode, positioned at the end). - -The temporary file removal depends on the keyword argument `anonymous` and -whether a block is given or not. See the description about the `anonymous` -keyword argument later. - -Example: - - f = Tempfile.create # => # - f.class # => File - f.path # => "/tmp/20220505-9795-17ky6f6" - f.stat.mode.to_s(8) # => "100600" - f.close - File.exist?(f.path) # => true - File.unlink(f.path) - File.exist?(f.path) # => false - - Tempfile.create {|f| - f.puts "foo" - f.rewind - f.read # => "foo\n" - f.path # => "/tmp/20240524-380207-oma0ny" - File.exist?(f.path) # => true - } # The file is removed at block exit. - - f = Tempfile.create(anonymous: true) - # The file is already removed because anonymous - f.path # => "/tmp/" (no filename since no file) - f.puts "foo" - f.rewind - f.read # => "foo\n" - f.close - - Tempfile.create(anonymous: true) {|f| - # The file is already removed because anonymous - f.path # => "/tmp/" (no filename since no file) - f.puts "foo" - f.rewind - f.read # => "foo\n" - } - -The argument `basename`, if given, may be one of the following: - -* A string: the generated filename begins with `basename`: - - Tempfile.create('foo') # => # - -* An array of two strings `[prefix, suffix]`: the generated filename begins - with `prefix` and ends with `suffix`: - - Tempfile.create(%w/foo .jpg/) # => # - -With arguments `basename` and `tmpdir`, the file is created in the directory -`tmpdir`: - - Tempfile.create('foo', '.') # => # - -Keyword arguments `mode` and `options` are passed directly to the method -[File.open](rdoc-ref:File.open): - -* The value given for `mode` must be an integer and may be expressed as the - logical OR of constants defined in - [File::Constants](rdoc-ref:File::Constants). -* For `options`, see [Open Options](rdoc-ref:IO@Open+Options). - -The keyword argument `anonymous` specifies when the file is removed. - -* `anonymous=false` (default) without a block: the file is not removed. -* `anonymous=false` (default) with a block: the file is removed after the - block exits. -* `anonymous=true` without a block: the file is removed before returning. -* `anonymous=true` with a block: the file is removed before the block is - called. - -In the first case (`anonymous=false` without a block), the file is not removed -automatically. It should be explicitly closed. It can be used to rename to the -desired filename. If the file is not needed, it should be explicitly removed. - -The File#path method of the created file object returns the temporary -directory with a trailing slash when `anonymous` is true. - -When a block is given, it creates the file as described above, passes it to -the block, and returns the block's value. Before the returning, the file -object is closed and the underlying file is removed: - - Tempfile.create {|file| file.path } # => "/tmp/20220505-9795-rkists" - -Implementation note: - -The keyword argument +anonymous=true+ is implemented using FILE_SHARE_DELETE -on Windows. O_TMPFILE is used on Linux. - -Related: Tempfile.new. -## open(*args , **kw ) [](#method-c-open) -Creates a new Tempfile. - -This method is not recommended and exists mostly for backward compatibility. -Please use Tempfile.create instead, which avoids the cost of delegation, does -not rely on a finalizer, and also unlinks the file when given a block. - -Tempfile.open is still appropriate if you need the Tempfile to be unlinked by -a finalizer and you cannot explicitly know where in the program the Tempfile -can be unlinked safely. - -If no block is given, this is a synonym for Tempfile.new. - -If a block is given, then a Tempfile object will be constructed, and the block -is run with the Tempfile object as argument. The Tempfile object will be -automatically closed after the block terminates. However, the file will -**not** be unlinked and needs to be manually unlinked with Tempfile#close! or -Tempfile#unlink. The finalizer will try to unlink but should not be relied -upon as it can keep the file on the disk much longer than intended. For -instance, on CRuby, finalizers can be delayed due to conservative stack -scanning and references left in unused memory. - -The call returns the value of the block. - -In any case, all arguments (`*args`) will be passed to Tempfile.new. - - Tempfile.open('foo', '/home/temp') do |f| - # ... do something with f ... - end - - # Equivalent: - f = Tempfile.open('foo', '/home/temp') - begin - # ... do something with f ... - ensure - f.close - end - -#Instance Methods -## close(unlink_nowfalse) [](#method-i-close) -Closes the file. If `unlink_now` is true, then the file will be unlinked -(deleted) after closing. Of course, you can choose to later call #unlink if -you do not unlink it now. - -If you don't explicitly unlink the temporary file, the removal will be delayed -until the object is finalized. - -## close!() [](#method-i-close!) -Closes and unlinks (deletes) the file. Has the same effect as called -`close(true)`. - -## initialize(basename"", tmpdirnil, mode:0, **options) [](#method-i-initialize) -Creates a file in the underlying file system; returns a new Tempfile object -based on that file. - -If possible, consider instead using Tempfile.create, which: - -* Avoids the performance cost of delegation, incurred when Tempfile.new - calls its superclass `DelegateClass(File)`. -* Does not rely on a finalizer to close and unlink the file, which can be - unreliable. - -Creates and returns file whose: - -* Class is Tempfile (not File, as in Tempfile.create). -* Directory is the system temporary directory (system-dependent). -* Generated filename is unique in that directory. -* Permissions are `0600`; see [File - Permissions](rdoc-ref:File@File+Permissions). -* Mode is `'w+'` (read/write mode, positioned at the end). - -The underlying file is removed when the Tempfile object dies and is reclaimed -by the garbage collector. - -Example: - - f = Tempfile.new # => # - f.class # => Tempfile - f.path # => "/tmp/20220505-17839-1s0kt30" - f.stat.mode.to_s(8) # => "100600" - File.exist?(f.path) # => true - File.unlink(f.path) # - File.exist?(f.path) # => false - -Argument `basename`, if given, may be one of: - -* A string: the generated filename begins with `basename`: - - Tempfile.new('foo') # => # - -* An array of two strings `[prefix, suffix]`: the generated filename begins - with `prefix` and ends with `suffix`: - - Tempfile.new(%w/foo .jpg/) # => # - -With arguments `basename` and `tmpdir`, the file is created in directory -`tmpdir`: - - Tempfile.new('foo', '.') # => # - -Keyword arguments `mode` and `options` are passed directly to method -[File.open](rdoc-ref:File.open): - -* The value given with `mode` must be an integer, and may be expressed as - the logical OR of constants defined in - [File::Constants](rdoc-ref:File::Constants). -* For `options`, see [Open Options](rdoc-ref:IO@Open+Options). - -Related: Tempfile.create. - -**@return** [Tempfile] a new instance of Tempfile - -## initialize_clone(other) [](#method-i-initialize_clone) -:nodoc: - -## initialize_dup(other) [](#method-i-initialize_dup) -:nodoc: - -## inspect() [](#method-i-inspect) -:stopdoc: - -## open() [](#method-i-open) -Opens or reopens the file with mode "r+". - -## path() [](#method-i-path) -Returns the full path name of the temporary file. This will be nil if #unlink -has been called. - -## size() [](#method-i-size) -Returns the size of the temporary file. As a side effect, the IO buffer is -flushed before determining the size. - -## unlink() [](#method-i-unlink) -Unlinks (deletes) the file from the filesystem. One should always unlink the -file after using it, as is explained in the "Explicit close" good practice -section in the Tempfile overview: - - file = Tempfile.new('foo') - begin - # ...do something with file... - ensure - file.close - file.unlink # deletes the temp file - end - -### Unlink-before-close - -On POSIX systems it's possible to unlink a file before closing it. This -practice is explained in detail in the Tempfile overview (section "Unlink -after creation"); please refer there for more information. - -However, unlink-before-close may not be supported on non-POSIX operating -systems. Microsoft Windows is the most notable case: unlinking a non-closed -file will result in an error, which this method will silently ignore. If you -want to practice unlink-before-close whenever possible, then you should write -code like this: - - file = Tempfile.new('foo') - file.unlink # On Windows this silently fails. - begin - # ... do something with file ... - ensure - file.close! # Closes the file handle. If the file wasn't unlinked - # because #unlink failed, then this method will attempt - # to do so again. - end - diff --git a/example/ruby/Tempfile/FinalizerManager.md b/example/ruby/Tempfile/FinalizerManager.md deleted file mode 100644 index 36f6109..0000000 --- a/example/ruby/Tempfile/FinalizerManager.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Tempfile::FinalizerManager -**Inherits:** Object - - -:nodoc: - - -# Attributes -## unlinked[RW] [](#attribute-i-unlinked) -Returns the value of attribute unlinked. - - -#Instance Methods -## call(object_id) [](#method-i-call) - -## initialize(path) [](#method-i-initialize) - -**@return** [FinalizerManager] a new instance of FinalizerManager - -## register(obj, file) [](#method-i-register) - diff --git a/example/ruby/Tempfile/PathAttr.md b/example/ruby/Tempfile/PathAttr.md deleted file mode 100644 index 4646cc4..0000000 --- a/example/ruby/Tempfile/PathAttr.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: Tempfile::PathAttr - - -:nodoc: - - -# Class Methods -## set_path(file , path ) [](#method-c-set_path) -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - - diff --git a/example/ruby/TerminationChecker.md b/example/ruby/TerminationChecker.md deleted file mode 100644 index ceddbce..0000000 --- a/example/ruby/TerminationChecker.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: TerminationChecker - - - - -# Class Methods -## terminated?(code ) [](#method-c-terminated?) -**@return** [Boolean] - - diff --git a/example/ruby/Test.md b/example/ruby/Test.md deleted file mode 100644 index 52cdc0a..0000000 --- a/example/ruby/Test.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: Test - - -$Id$ - - -# Class Methods -## filter_backtrace(bt ) [](#method-c-filter_backtrace) -:nodoc: -# Attributes -## backtrace_filter[RW] [](#attribute-c-backtrace_filter) -Filter object for backtraces. - - diff --git a/example/ruby/Test/ASAN.md b/example/ruby/Test/ASAN.md deleted file mode 100644 index 85bff20..0000000 --- a/example/ruby/Test/ASAN.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Test::ASAN -**Inherits:** Object - - - - -# Class Methods -## enabled?() [](#method-c-enabled?) -**@return** [Boolean] - - diff --git a/example/ruby/Test/BacktraceFilter.md b/example/ruby/Test/BacktraceFilter.md deleted file mode 100644 index fcc4085..0000000 --- a/example/ruby/Test/BacktraceFilter.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Test::BacktraceFilter -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## filter(bt) [](#method-i-filter) - diff --git a/example/ruby/Test/Unit.md b/example/ruby/Test/Unit.md deleted file mode 100644 index ab578fe..0000000 --- a/example/ruby/Test/Unit.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Test::Unit - - -Test::Unit is an implementation of the xUnit testing framework for Ruby. - - -# Class Methods -## location(e ) [](#method-c-location) -Extract the location where the last assertion method was called. Returns -"" if *e* does not have backtrace, or an empty string if no assertion -method location was found. - diff --git a/example/ruby/Test/Unit/AssertionFailedError.md b/example/ruby/Test/Unit/AssertionFailedError.md deleted file mode 100644 index 25a6053..0000000 --- a/example/ruby/Test/Unit/AssertionFailedError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Test::Unit::AssertionFailedError -**Inherits:** Exception - - -Assertion base class - - - diff --git a/example/ruby/Test/Unit/Assertions.md b/example/ruby/Test/Unit/Assertions.md deleted file mode 100644 index 0de7e77..0000000 --- a/example/ruby/Test/Unit/Assertions.md +++ /dev/null @@ -1,327 +0,0 @@ -# Module: Test::Unit::Assertions - - - - -# Class Methods -## diff() [](#method-c-diff) -Returns the diff command to use in #diff. Tries to intelligently figure out -what diff to use. -## diff=(o ) [](#method-c-diff=) -Set the diff command to use in #diff. - -#Instance Methods -## _assertions() [](#method-i-_assertions) -:nodoc: - -## _assertions=(n) [](#method-i-_assertions=) -:nodoc: - -## assert(test, msgnil) [](#method-i-assert) -Fails unless `test` is a true value. - -## assert_bignum(v, msgnil) [](#method-i-assert_bignum) - -## assert_block(*msgs) [](#method-i-assert_block) -:call-seq: - assert_block( failure_message = nil ) - -Tests the result of the given block. If the block does not return true, the -assertion will fail. The optional `failure_message` argument is the same as in -Assertions#assert. - - assert_block do - [1, 2, 3].any? { |num| num < 1 } - end - -## assert_cpu_usage_low(msgnil, pct:0.05, wait:1.0, stop:nil) [](#method-i-assert_cpu_usage_low) - -## assert_empty(obj, msgnil) [](#method-i-assert_empty) -Fails unless `obj` is empty. - -## assert_equal(exp, act, msgnil) [](#method-i-assert_equal) -:call-seq: - assert_equal( expected, actual, failure_message = nil ) - -Tests if `expected` is equal to `actual`. - -An optional failure message may be provided as the final argument. - -## assert_false(obj, msgnil) [](#method-i-assert_false) -Fails unless `obj` is false - -## assert_fixnum(v, msgnil) [](#method-i-assert_fixnum) - -## assert_in_delta(exp, act, delta0.001, msgnil) [](#method-i-assert_in_delta) -For comparing Floats. Fails unless `exp` and `act` are within `delta` of each -other. - - assert_in_delta Math::PI, (22.0 / 7.0), 0.01 - -## assert_in_epsilon(a, b, epsilon0.001, msgnil) [](#method-i-assert_in_epsilon) -For comparing Floats. Fails unless `exp` and `act` have a relative error less -than `epsilon`. - -## assert_includes(collection, obj, msgnil) [](#method-i-assert_includes) -Fails unless `collection` includes `obj`. - -## assert_instance_of(cls, obj, msgnil) [](#method-i-assert_instance_of) -Fails unless `obj` is an instance of `cls`. - -## assert_is_minus_zero(f) [](#method-i-assert_is_minus_zero) - -## assert_kind_of(cls, obj, msgnil) [](#method-i-assert_kind_of) -Fails unless `obj` is a kind of `cls`. - -## assert_match(matcher, obj, msgnil) [](#method-i-assert_match) -Fails unless `matcher` `=~` `obj`. - -## assert_nil(obj, msgnil) [](#method-i-assert_nil) -Fails unless `obj` is nil - -## assert_no_match(regexp, string, msgnil) [](#method-i-assert_no_match) -:call-seq: - assert_no_match( regexp, string, failure_message = nil ) - -Tests if the given Regexp does not match a given String. - -An optional failure message may be provided as the final argument. - -## assert_no_warning(pat, msgnil) [](#method-i-assert_no_warning) - -## assert_not_all?(obj, mnil, &blk) [](#method-i-assert_not_all?) - -**@return** [Boolean] - -## assert_not_equal(exp, act, msgnil) [](#method-i-assert_not_equal) -:call-seq: - assert_not_equal( expected, actual, failure_message = nil ) - -Tests if `expected` is not equal to `actual`. - -An optional failure message may be provided as the final argument. - -## assert_not_nil(exp, msgnil) [](#method-i-assert_not_nil) -:call-seq: - assert_not_nil( expression, failure_message = nil ) - -Tests if `expression` is not nil. - -An optional failure message may be provided as the final argument. - -## assert_not_same(expected, actual, message"") [](#method-i-assert_not_same) -:call-seq: - assert_not_same( expected, actual, failure_message = nil ) - -Tests if `expected` is not the same object as `actual`. This test uses -Object#equal? to test equality. - -An optional failure message may be provided as the final argument. - - assert_not_same("x", "x") #Succeeds - -## assert_not_send(send_ary, mnil) [](#method-i-assert_not_send) -:call-seq: - assert_not_send( +send_array+, failure_message = nil ) - -Passes if the method send doesn't return a true value. - -`send_array` is composed of: -* A receiver -* A method -* Arguments to the method - -Example: - assert_not_send([[1, 2], :member?, 1]) # -> fail - assert_not_send([[1, 2], :member?, 4]) # -> pass - -## assert_nothing_thrown(msgnil) [](#method-i-assert_nothing_thrown) -:call-seq: - assert_nothing_thrown( failure_message = nil, &block ) - -Fails if the given block uses a call to Kernel#throw, and returns the result -of the block otherwise. - -An optional failure message may be provided as the final argument. - - assert_nothing_thrown "Something was thrown!" do - throw :problem? - end - -## assert_operator(o1, op, o2(predicate = true; nil), msgnil) [](#method-i-assert_operator) -For testing with binary operators. - - assert_operator 5, :<=, 4 - -## assert_output(stdoutnil, stderrnil) [](#method-i-assert_output) -Fails if stdout or stderr do not output the expected results. Pass in nil if -you don't care about that streams output. Pass in "" if you require it to be -silent. Pass in a regexp if you want to pattern match. - -NOTE: this uses #capture_io, not #capture_subprocess_io. - -See also: #assert_silent - -## assert_path_exists(path, msgnil) [](#method-i-assert_path_exists) - -## assert_predicate(o1, op, msgnil) [](#method-i-assert_predicate) -For testing with predicates. - - assert_predicate str, :empty? - -This is really meant for specs and is front-ended by assert_operator: - - str.must_be :empty? - -## assert_raises(*exp, &b) [](#method-i-assert_raises) - -**@raise** [NoMethodError] - -## assert_respond_to(obj, meth, msgnil) [](#method-i-assert_respond_to) -Fails unless `obj` responds to `meth`. - -## assert_same(exp, act, msgnil) [](#method-i-assert_same) -Fails unless `exp` and `act` are #equal? - -## assert_send(send_ary, mnil) [](#method-i-assert_send) -:call-seq: - assert_send( +send_array+, failure_message = nil ) - -Passes if the method send returns a true value. - -`send_array` is composed of: -* A receiver -* A method -* Arguments to the method - -Example: - assert_send(["Hello world", :include?, "Hello"]) # -> pass - assert_send(["Hello world", :include?, "Goodbye"]) # -> fail - -## assert_silent() [](#method-i-assert_silent) -Fails if the block outputs anything to stderr or stdout. - -See also: #assert_output - -## assert_syntax_error(code, error, *args, **opt) [](#method-i-assert_syntax_error) - -## assert_throws(sym, msgnil) [](#method-i-assert_throws) -Fails unless the block throws `sym` - -## assert_true(obj, msgnil) [](#method-i-assert_true) -Fails unless `obj` is true - -## build_message(head, templatenil, *arguments) [](#method-i-build_message) -:nodoc: - -## capture_io() [](#method-i-capture_io) - -**@raise** [NoMethodError] - -## capture_output() [](#method-i-capture_output) -Captures $stdout and $stderr into strings: - - out, err = capture_output do - puts "Some info" - warn "You did a bad thing" - end - - assert_match %r%info%, out - assert_match %r%bad%, err - -## diff(exp, act) [](#method-i-diff) -Returns a diff between `exp` and `act`. If there is no known diff command or -if it doesn't make sense to diff the output (single line, short output), then -it simply returns a basic comparison between the two. - -## flunk(msgnil) [](#method-i-flunk) -Fails with `msg` - -## message(msgnil, endingnil, &default) [](#method-i-message) -Returns a proc that will output `msg` along with the default message. - -## mu_pp_for_diff(obj) [](#method-i-mu_pp_for_diff) -This returns a diff-able human-readable version of `obj`. This differs from -the regular mu_pp because it expands escaped newlines and makes hex-values -generic (like object_ids). This uses mu_pp to do the first pass and then -cleans it up. - -## pass(msgnil) [](#method-i-pass) -used for counting assertions - -## pend(msgnil, btcaller, &_) [](#method-i-pend) -Skips the current test. Gets listed at the end of the run but doesn't cause a -failure exit code. - -**@raise** [Test::Unit::PendedError] - -## refute(test, msgnil) [](#method-i-refute) -Fails if `test` is a true value - -## refute_empty(obj, msgnil) [](#method-i-refute_empty) -Fails if `obj` is empty. - -## refute_equal(exp, act, msgnil) [](#method-i-refute_equal) -Fails if `exp == act`. - -For floats use refute_in_delta. - -## refute_in_delta(exp, act, delta0.001, msgnil) [](#method-i-refute_in_delta) -For comparing Floats. Fails if `exp` is within `delta` of `act`. - - refute_in_delta Math::PI, (22.0 / 7.0) - -## refute_in_epsilon(a, b, epsilon0.001, msgnil) [](#method-i-refute_in_epsilon) -For comparing Floats. Fails if `exp` and `act` have a relative error less -than `epsilon`. - -## refute_includes(collection, obj, msgnil) [](#method-i-refute_includes) -Fails if `collection` includes `obj`. - -## refute_instance_of(cls, obj, msgnil) [](#method-i-refute_instance_of) -Fails if `obj` is an instance of `cls`. - -## refute_kind_of(cls, obj, msgnil) [](#method-i-refute_kind_of) -Fails if `obj` is a kind of `cls`. - -## refute_match(matcher, obj, msgnil) [](#method-i-refute_match) -Fails if `matcher` `=~` `obj`. - -## refute_nil(obj, msgnil) [](#method-i-refute_nil) -Fails if `obj` is nil. - -## refute_operator(o1, op, o2(predicate = true; nil), msgnil) [](#method-i-refute_operator) -Fails if `o1` is not `op` `o2`. Eg: - - refute_operator 1, :>, 2 #=> pass - refute_operator 1, :<, 2 #=> fail - -## refute_path_exists(path, msgnil) [](#method-i-refute_path_exists) - -## refute_predicate(o1, op, msgnil) [](#method-i-refute_predicate) -For testing with predicates. - - refute_predicate str, :empty? - -This is really meant for specs and is front-ended by refute_operator: - - str.wont_be :empty? - -## refute_respond_to(obj, meth, msgnil) [](#method-i-refute_respond_to) -Fails if `obj` responds to the message `meth`. - -## refute_same(exp, act, msgnil) [](#method-i-refute_same) -Fails if `exp` is the same (by object identity) as `act`. - -## skip(msgnil, btcaller) [](#method-i-skip) - -**@raise** [NoMethodError] - -## skipped?() [](#method-i-skipped?) -Was this testcase skipped? Meant for #teardown. - -**@return** [Boolean] - -## synchronize() [](#method-i-synchronize) -Takes a block and wraps it with the runner's shared mutex. - diff --git a/example/ruby/Test/Unit/AutoRunner.md b/example/ruby/Test/Unit/AutoRunner.md deleted file mode 100644 index e08fb4c..0000000 --- a/example/ruby/Test/Unit/AutoRunner.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Test::Unit::AutoRunner -**Inherits:** Object - - -:nodoc: all - - -# Class Methods -## run(*args ) [](#method-c-run) -# Attributes -## options[RW] [](#attribute-i-options) -Returns the value of attribute options. - -## to_run[RW] [](#attribute-i-to_run) -Returns the value of attribute to_run. - - -#Instance Methods -## initialize(force_standalonefalse, default_dirnil, argvARGV) [](#method-i-initialize) - -**@return** [AutoRunner] a new instance of AutoRunner - -## process_args(*args) [](#method-i-process_args) - -## run() [](#method-i-run) - diff --git a/example/ruby/Test/Unit/AutoRunner/Runner.md b/example/ruby/Test/Unit/AutoRunner/Runner.md deleted file mode 100644 index c248cda..0000000 --- a/example/ruby/Test/Unit/AutoRunner/Runner.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Test::Unit::AutoRunner::Runner -**Inherits:** Test::Unit::Runner - -**Includes:** Test::Unit::LaunchableOption, Test::Unit::RequireFiles - - - - - -#Instance Methods -## encode_test_path_component(component) [](#method-i-encode_test_path_component) - -## non_options(files, options) [](#method-i-non_options) - -## record(suite, method, assertions, time, error, source_locationnil) [](#method-i-record) - -## run() [](#method-i-run) - diff --git a/example/ruby/Test/Unit/CoreAssertions.md b/example/ruby/Test/Unit/CoreAssertions.md deleted file mode 100644 index 4c30401..0000000 --- a/example/ruby/Test/Unit/CoreAssertions.md +++ /dev/null @@ -1,197 +0,0 @@ -# Module: Test::Unit::CoreAssertions - - - - -# Class Methods -## glibc?(*ver ) [](#method-c-glibc?) -**@return** [Boolean] - -## linux?(*ver ) [](#method-c-linux?) -**@return** [Boolean] - -## macos?(*ver ) [](#method-c-macos?) -**@return** [Boolean] - -## mingw?() [](#method-c-mingw?) -**@return** [Boolean] - -## mswin?() [](#method-c-mswin?) -Platform predicates -**@return** [Boolean] - -## version_compare(expected , actual ) [](#method-c-version_compare) -## version_match?(expected , actual ) [](#method-c-version_match?) -**@return** [Boolean] - -## windows?() [](#method-c-windows?) -**@return** [Boolean] - - -#Instance Methods -## assert(test, *msgs) [](#method-i-assert) -:call-seq: - assert(test, [failure_message]) - -Tests if `test` is true. - -`msg` may be a String or a Proc. If `msg` is a String, it will be used as the -failure message. Otherwise, the result of calling `msg` will be used as the -message if the assertion fails. - -If no `msg` is given, a default message will be used. - - assert(false, "This was expected to be true") - -## assert_all?(obj, mnil, &blk) [](#method-i-assert_all?) - -**@return** [Boolean] - -## assert_all_assertions(msgnil) [](#method-i-assert_all_assertions) - -## assert_all_assertions_foreach(msgnil, *keys, &block) [](#method-i-assert_all_assertions_foreach) - -## assert_deprecated_warn(mesg/deprecated/) [](#method-i-assert_deprecated_warn) - -## assert_deprecated_warning(mesg/deprecated/) [](#method-i-assert_deprecated_warning) - -## assert_file() [](#method-i-assert_file) - -## assert_in_out_err(args, test_stdin"", test_stdout[], test_stderr[], messagenil, success:nil, **opt) [](#method-i-assert_in_out_err) - -## assert_join_threads(threads, messagenil) [](#method-i-assert_join_threads) -threads should respond to shift method. Array can be used. - -## assert_linear_performance(seq, rehearsal:nil, pre:->(n) {n}) [](#method-i-assert_linear_performance) -Expect `seq` to respond to `first` and `each` methods, e.g., Array, Range, -Enumerator::ArithmeticSequence and other Enumerable-s, and each elements -should be size factors. - -:yield: each elements of `seq`. - -## assert_no_memory_leak(args, prepare, code, messagenil, limit:2.0, rss:false, **opt) [](#method-i-assert_no_memory_leak) - -## assert_normal_exit(testsrc, message'', child_env:nil, **opt) [](#method-i-assert_normal_exit) - -## assert_not_respond_to(obj, meth, *priv, msgnil) [](#method-i-assert_not_respond_to) -:call-seq: - assert_not_respond_to( object, method, failure_message = nil ) - -Tests if the given Object does not respond to `method`. - -An optional failure message may be provided as the final argument. - - assert_not_respond_to("hello", :reverse) #Fails - assert_not_respond_to("hello", :does_not_exist) #Succeeds - -## assert_nothing_raised(*args) [](#method-i-assert_nothing_raised) -:call-seq: - assert_nothing_raised( *args, &block ) - -If any exceptions are given as arguments, the assertion will fail if one of -those exceptions are raised. Otherwise, the test fails if any exceptions are -raised. - -The final argument may be a failure message. - - assert_nothing_raised RuntimeError do - raise Exception #Assertion passes, Exception is not a RuntimeError - end - - assert_nothing_raised do - raise Exception #Assertion fails - end - -## assert_pattern_list(pattern_list, actual, messagenil) [](#method-i-assert_pattern_list) -pattern_list is an array which contains regexp, string and :*. :* means any -sequence. - -pattern_list is anchored. Use [:*, regexp/string, :*] for non-anchored match. - -## assert_ractor(src, args:[], require:nil, require_relative:nil, file:nil, line:nil, ignore_stderr:nil, **opt) [](#method-i-assert_ractor) -Run Ractor-related test without influencing the main test suite - -## assert_raise(*exp, &b) [](#method-i-assert_raise) -:call-seq: - assert_raise( *args, &block ) - -Tests if the given block raises an exception. Acceptable exception types may -be given as optional arguments. If the last argument is a String, it will be -used as the error message. - - assert_raise do #Fails, no Exceptions are raised - end - - assert_raise NameError do - puts x #Raises NameError, so assertion succeeds - end - -## assert_raise_with_message(exception, expected, msgnil, &block) [](#method-i-assert_raise_with_message) -:call-seq: - assert_raise_with_message(exception, expected, msg = nil, &block) - -Tests if the given block raises an exception with the expected message. - - assert_raise_with_message(RuntimeError, "foo") do - nil #Fails, no Exceptions are raised - end - - assert_raise_with_message(RuntimeError, "foo") do - raise ArgumentError, "foo" #Fails, different Exception is raised - end - - assert_raise_with_message(RuntimeError, "foo") do - raise "bar" #Fails, RuntimeError is raised but the message differs - end - - assert_raise_with_message(RuntimeError, "foo") do - raise "foo" #Raises RuntimeError with the message, so assertion succeeds - end - -## assert_respond_to(obj, meth, *priv, msgnil) [](#method-i-assert_respond_to) -:call-seq: - assert_respond_to( object, method, failure_message = nil ) - -Tests if the given Object responds to `method`. - -An optional failure message may be provided as the final argument. - - assert_respond_to("hello", :reverse) #Succeeds - assert_respond_to("hello", :does_not_exist) #Fails - -## assert_ruby_status(args, test_stdin"", messagenil, **opt) [](#method-i-assert_ruby_status) - -## assert_separately(args, filenil, linenil, src, ignore_stderr:nil, **opt) [](#method-i-assert_separately) - -## assert_throw(tag, msgnil) [](#method-i-assert_throw) -:call-seq: - assert_throw( tag, failure_message = nil, &block ) - -Fails unless the given block throws `tag`, returns the caught value otherwise. - -An optional failure message may be provided as the final argument. - - tag = Object.new - assert_throw(tag, "#{tag} was not thrown!") do - throw tag - end - -## assert_valid_syntax(code, *args, **opt) [](#method-i-assert_valid_syntax) - -## assert_warn(*args) [](#method-i-assert_warn) - -## assert_warning(pat, msgnil) [](#method-i-assert_warning) - -## diff(exp, act) [](#method-i-diff) - -## mu_pp(obj) [](#method-i-mu_pp) -:nodoc: - -## new_test_token() [](#method-i-new_test_token) - -## prepare_syntax_check(code, fnamenil, mesgnil, verbose:nil) [](#method-i-prepare_syntax_check) - -## separated_runner(token, outnil) [](#method-i-separated_runner) - -## syntax_check(code, fname, line) [](#method-i-syntax_check) - diff --git a/example/ruby/Test/Unit/CoreAssertions/AllFailures.md b/example/ruby/Test/Unit/CoreAssertions/AllFailures.md deleted file mode 100644 index 2ac29e8..0000000 --- a/example/ruby/Test/Unit/CoreAssertions/AllFailures.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: Test::Unit::CoreAssertions::AllFailures -**Inherits:** Object - - - - -# Attributes -## failures[RW] [](#attribute-i-failures) -Returns the value of attribute failures. - - -#Instance Methods -## for(key) [](#method-i-for) - -## foreach(*keys) [](#method-i-foreach) - -## initialize() [](#method-i-initialize) - -**@return** [AllFailures] a new instance of AllFailures - -## message() [](#method-i-message) - -## pass?() [](#method-i-pass?) - -**@return** [Boolean] - diff --git a/example/ruby/Test/Unit/ExcludesOption.md b/example/ruby/Test/Unit/ExcludesOption.md deleted file mode 100644 index 8d045ac..0000000 --- a/example/ruby/Test/Unit/ExcludesOption.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Test::Unit::ExcludesOption - - -:nodoc: all - - - -#Instance Methods -## _run_suite(suite, type) [](#method-i-_run_suite) - -## setup_options(parser, options) [](#method-i-setup_options) - diff --git a/example/ruby/Test/Unit/ExcludesOption/ExcludedMethods.md b/example/ruby/Test/Unit/ExcludesOption/ExcludedMethods.md deleted file mode 100644 index ce6b8cc..0000000 --- a/example/ruby/Test/Unit/ExcludesOption/ExcludedMethods.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Test::Unit::ExcludesOption::ExcludedMethods -**Inherits:** Struct - - - - -# Class Methods -## load(dirs , name ) [](#method-c-load) -# Attributes -## excludes[RW] [](#attribute-i-excludes) -Returns the value of attribute excludes - -**@return** [Object] the current value of excludes - - -#Instance Methods -## exclude(name, reason) [](#method-i-exclude) - -## exclude_from(klass) [](#method-i-exclude_from) - diff --git a/example/ruby/Test/Unit/FileAssertions.md b/example/ruby/Test/Unit/FileAssertions.md deleted file mode 100644 index 27acb84..0000000 --- a/example/ruby/Test/Unit/FileAssertions.md +++ /dev/null @@ -1,33 +0,0 @@ -# Module: Test::Unit::FileAssertions - - - - - -#Instance Methods -## assert_directory(path, messagenil) [](#method-i-assert_directory) - -## assert_equal_filemode(file1, file2, messagenil, mask:07777) [](#method-i-assert_equal_filemode) - -## assert_equal_time(expected, actual, messagenil) [](#method-i-assert_equal_time) - -## assert_equal_timestamp(expected, actual, messagenil) [](#method-i-assert_equal_timestamp) - -## assert_file_exist(path, messagenil) [](#method-i-assert_file_exist) - -## assert_file_not_exist(path, messagenil) [](#method-i-assert_file_not_exist) - -## assert_filemode(expected, file, messagenil, mask:07777) [](#method-i-assert_filemode) - -## assert_not_symlink(path, messagenil) [](#method-i-assert_not_symlink) - -## assert_ownership_group(expected, file) [](#method-i-assert_ownership_group) - -## assert_ownership_user(expected, file) [](#method-i-assert_ownership_user) - -## assert_same_entry(from, to, messagenil) [](#method-i-assert_same_entry) - -## assert_same_file(from, to, messagenil) [](#method-i-assert_same_file) - -## assert_symlink(path, messagenil) [](#method-i-assert_symlink) - diff --git a/example/ruby/Test/Unit/GCOption.md b/example/ruby/Test/Unit/GCOption.md deleted file mode 100644 index 9b7874f..0000000 --- a/example/ruby/Test/Unit/GCOption.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Test::Unit::GCOption - - -:nodoc: all - - - -#Instance Methods -## non_options(files, options) [](#method-i-non_options) - -## setup_options(parser, options) [](#method-i-setup_options) - diff --git a/example/ruby/Test/Unit/GlobOption.md b/example/ruby/Test/Unit/GlobOption.md deleted file mode 100644 index ab9247e..0000000 --- a/example/ruby/Test/Unit/GlobOption.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: Test::Unit::GlobOption - - -:nodoc: all - - - -#Instance Methods -## complement_test_name(f, orig_f) [](#method-i-complement_test_name) - -**@raise** [ArgumentError] - -## non_options(files, options) [](#method-i-non_options) - -## setup_options(parser, options) [](#method-i-setup_options) - diff --git a/example/ruby/Test/Unit/Guard.md b/example/ruby/Test/Unit/Guard.md deleted file mode 100644 index 346498a..0000000 --- a/example/ruby/Test/Unit/Guard.md +++ /dev/null @@ -1,40 +0,0 @@ -# Module: Test::Unit::Guard - - -Provides a simple set of guards that you can use in your tests to skip -execution if it is not applicable. These methods are mixed into TestCase as -both instance and class methods so you can use them inside or outside of the -test methods. - - def test_something_for_mri - skip "bug 1234" if jruby? - # ... - end - - if windows? then - # ... lots of test methods ... - end - - - -#Instance Methods -## jruby?(platformRUBY_PLATFORM) [](#method-i-jruby?) -Is this running on jruby? - -**@return** [Boolean] - -## mingw?(platformRUBY_PLATFORM) [](#method-i-mingw?) -Is this running on mingw? - -**@return** [Boolean] - -## mri?(platformRUBY_DESCRIPTION) [](#method-i-mri?) -Is this running on mri? - -**@return** [Boolean] - -## windows?(platformRUBY_PLATFORM) [](#method-i-windows?) -Is this running on windows? - -**@return** [Boolean] - diff --git a/example/ruby/Test/Unit/LaunchableOption.md b/example/ruby/Test/Unit/LaunchableOption.md deleted file mode 100644 index 851e243..0000000 --- a/example/ruby/Test/Unit/LaunchableOption.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Test::Unit::LaunchableOption - - - - - -#Instance Methods -## encode_test_path_component(component) [](#method-i-encode_test_path_component) - -## record(suite, method, assertions, time, error, source_locationnil) [](#method-i-record) - diff --git a/example/ruby/Test/Unit/LaunchableOption/Nothing.md b/example/ruby/Test/Unit/LaunchableOption/Nothing.md deleted file mode 100644 index 01f0ef7..0000000 --- a/example/ruby/Test/Unit/LaunchableOption/Nothing.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Test::Unit::LaunchableOption::Nothing - - - - - diff --git a/example/ruby/Test/Unit/LifecycleHooks.md b/example/ruby/Test/Unit/LifecycleHooks.md deleted file mode 100644 index cbc26e0..0000000 --- a/example/ruby/Test/Unit/LifecycleHooks.md +++ /dev/null @@ -1,60 +0,0 @@ -# Module: Test::Unit::LifecycleHooks - - -Provides before/after hooks for setup and teardown. These are meant for -library writers, NOT for regular test authors. See #before_setup for an -example. - - - -#Instance Methods -## after_setup() [](#method-i-after_setup) -Runs before every test, after setup. This hook is meant for libraries to -extend Test::Unit. It is not meant to be used by test developers. - -See #before_setup for an example. - -## after_teardown() [](#method-i-after_teardown) -Runs after every test, after teardown. This hook is meant for libraries to -extend Test::Unit. It is not meant to be used by test developers. - -See #before_setup for an example. - -## before_setup() [](#method-i-before_setup) -Runs before every test, before setup. This hook is meant for libraries to -extend Test::Unit. It is not meant to be used by test developers. - -As a simplistic example: - - module MyTestUnitPlugin - def before_setup - super - # ... stuff to do before setup is run - end - - def after_setup - # ... stuff to do after setup is run - super - end - - def before_teardown - super - # ... stuff to do before teardown is run - end - - def after_teardown - # ... stuff to do after teardown is run - super - end - end - - class Test::Unit::Runner::TestCase - include MyTestUnitPlugin - end - -## before_teardown() [](#method-i-before_teardown) -Runs after every test, before teardown. This hook is meant for libraries to -extend Test::Unit. It is not meant to be used by test developers. - -See #before_setup for an example. - diff --git a/example/ruby/Test/Unit/LoadPathOption.md b/example/ruby/Test/Unit/LoadPathOption.md deleted file mode 100644 index c09291b..0000000 --- a/example/ruby/Test/Unit/LoadPathOption.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Test::Unit::LoadPathOption - - -:nodoc: all - - - -#Instance Methods -## non_options(files, options) [](#method-i-non_options) - -## setup_options(parser, options) [](#method-i-setup_options) - diff --git a/example/ruby/Test/Unit/Options.md b/example/ruby/Test/Unit/Options.md deleted file mode 100644 index c2f1239..0000000 --- a/example/ruby/Test/Unit/Options.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: Test::Unit::Options - - -:nodoc: all - - - -#Instance Methods -## initialize(&block) [](#method-i-initialize) - -## option_parser() [](#method-i-option_parser) - -## process_args(args[]) [](#method-i-process_args) - diff --git a/example/ruby/Test/Unit/Order.md b/example/ruby/Test/Unit/Order.md deleted file mode 100644 index a16d7b8..0000000 --- a/example/ruby/Test/Unit/Order.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Test::Unit::Order - - - - - diff --git a/example/ruby/Test/Unit/Order/Alpha.md b/example/ruby/Test/Unit/Order/Alpha.md deleted file mode 100644 index 491e4df..0000000 --- a/example/ruby/Test/Unit/Order/Alpha.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test::Unit::Order::Alpha -**Inherits:** Test::Unit::Order::NoSort - - - - - -#Instance Methods -## sort_by_name(list) [](#method-i-sort_by_name) - -## sort_by_string(list) [](#method-i-sort_by_string) - diff --git a/example/ruby/Test/Unit/Order/NoSort.md b/example/ruby/Test/Unit/Order/NoSort.md deleted file mode 100644 index 423f716..0000000 --- a/example/ruby/Test/Unit/Order/NoSort.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Test::Unit::Order::NoSort -**Inherits:** Object - - - - - -#Instance Methods -## group(list) [](#method-i-group) - -## initialize(seed) [](#method-i-initialize) - -**@return** [NoSort] a new instance of NoSort - -## sort_by_name(list) [](#method-i-sort_by_name) - diff --git a/example/ruby/Test/Unit/Order/Shuffle.md b/example/ruby/Test/Unit/Order/Shuffle.md deleted file mode 100644 index 48319f5..0000000 --- a/example/ruby/Test/Unit/Order/Shuffle.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: Test::Unit::Order::Shuffle -**Inherits:** Struct - - -shuffle test suites based on CRC32 of their names - - -# Attributes -## salt[RW] [](#attribute-i-salt) -Returns the value of attribute salt - -**@return** [Object] the current value of salt - -## seed[RW] [](#attribute-i-seed) -Returns the value of attribute seed - -**@return** [Object] the current value of seed - - -#Instance Methods -## group(list) [](#method-i-group) - -## initialize(seed) [](#method-i-initialize) - -**@return** [Shuffle] a new instance of Shuffle - -## sort_by_name(list) [](#method-i-sort_by_name) - -## sort_by_string(list) [](#method-i-sort_by_string) - diff --git a/example/ruby/Test/Unit/OutputOption.md b/example/ruby/Test/Unit/OutputOption.md deleted file mode 100644 index 10ea9da..0000000 --- a/example/ruby/Test/Unit/OutputOption.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Test::Unit::OutputOption - - -:nodoc: all - - - -#Instance Methods -## process_args(args[]) [](#method-i-process_args) - -## setup_options(parser, options) [](#method-i-setup_options) - diff --git a/example/ruby/Test/Unit/Parallel.md b/example/ruby/Test/Unit/Parallel.md deleted file mode 100644 index 35dd018..0000000 --- a/example/ruby/Test/Unit/Parallel.md +++ /dev/null @@ -1,16 +0,0 @@ -# Module: Test::Unit::Parallel - - -:nodoc: all - - - -#Instance Methods -## non_options(files, options) [](#method-i-non_options) - -## process_args(args[]) [](#method-i-process_args) - -## status(*args) [](#method-i-status) - -**@raise** [@interrupt] - diff --git a/example/ruby/Test/Unit/Parallel/FakeClass.md b/example/ruby/Test/Unit/Parallel/FakeClass.md deleted file mode 100644 index 402c86b..0000000 --- a/example/ruby/Test/Unit/Parallel/FakeClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test::Unit::Parallel::FakeClass -**Inherits:** Struct - - - - - diff --git a/example/ruby/Test/Unit/Parallel/Worker.md b/example/ruby/Test/Unit/Parallel/Worker.md deleted file mode 100644 index 65a6a88..0000000 --- a/example/ruby/Test/Unit/Parallel/Worker.md +++ /dev/null @@ -1,65 +0,0 @@ -# Class: Test::Unit::Parallel::Worker -**Inherits:** Object - - - - -# Class Methods -## launch(ruby , args []) [](#method-c-launch) -# Attributes -## current[RW] [](#attribute-i-current) -Returns the value of attribute current. - -## file[RW] [](#attribute-i-file) -Returns the value of attribute file. - -## io[RW] [](#attribute-i-io) -Returns the value of attribute io. - -## loadpath[RW] [](#attribute-i-loadpath) -Returns the value of attribute loadpath. - -## pid[RW] [](#attribute-i-pid) -Returns the value of attribute pid. - -## quit_called[RW] [](#attribute-i-quit_called) -Returns the value of attribute quit_called. - -## real_file[RW] [](#attribute-i-real_file) -Returns the value of attribute real_file. - -## response_at[RW] [](#attribute-i-response_at) -Returns the value of attribute response_at. - -## start_time[RW] [](#attribute-i-start_time) -Returns the value of attribute start_time. - -## status[RW] [](#attribute-i-status) -Returns the value of attribute status. - - -#Instance Methods -## close() [](#method-i-close) - -## died(*additional) [](#method-i-died) - -## hook(id, &block) [](#method-i-hook) - -## initialize(io, pid, status) [](#method-i-initialize) - -**@return** [Worker] a new instance of Worker - -## kill() [](#method-i-kill) - -## name() [](#method-i-name) - -## puts(*args) [](#method-i-puts) - -## quit(reason:normal) [](#method-i-quit) - -## read() [](#method-i-read) - -## run(task, type) [](#method-i-run) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Test/Unit/PendedError.md b/example/ruby/Test/Unit/PendedError.md deleted file mode 100644 index 436f5a3..0000000 --- a/example/ruby/Test/Unit/PendedError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Test::Unit::PendedError -**Inherits:** Test::Unit::AssertionFailedError - - -Assertion raised when skipping a test - - - diff --git a/example/ruby/Test/Unit/ProxyError.md b/example/ruby/Test/Unit/ProxyError.md deleted file mode 100644 index 7762f61..0000000 --- a/example/ruby/Test/Unit/ProxyError.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: Test::Unit::ProxyError -**Inherits:** StandardError - - -:nodoc: all - - -# Attributes -## backtrace[RW] [](#attribute-i-backtrace) -Returns the value of attribute backtrace. - -## message[RW] [](#attribute-i-message) -Returns the value of attribute message. - - -#Instance Methods -## initialize(ex) [](#method-i-initialize) - -**@return** [ProxyError] a new instance of ProxyError - diff --git a/example/ruby/Test/Unit/RepeatOption.md b/example/ruby/Test/Unit/RepeatOption.md deleted file mode 100644 index e50aa21..0000000 --- a/example/ruby/Test/Unit/RepeatOption.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Test::Unit::RepeatOption - - -:nodoc: all - - - -#Instance Methods -## _run_anything(type) [](#method-i-_run_anything) - -## setup_options(parser, options) [](#method-i-setup_options) - diff --git a/example/ruby/Test/Unit/RequireFiles.md b/example/ruby/Test/Unit/RequireFiles.md deleted file mode 100644 index 5ba24f1..0000000 --- a/example/ruby/Test/Unit/RequireFiles.md +++ /dev/null @@ -1,12 +0,0 @@ -# Module: Test::Unit::RequireFiles - - -:nodoc: all - - - -#Instance Methods -## non_options(files, options) [](#method-i-non_options) - -## run() [](#method-i-run) - diff --git a/example/ruby/Test/Unit/RunCount.md b/example/ruby/Test/Unit/RunCount.md deleted file mode 100644 index ba52d6c..0000000 --- a/example/ruby/Test/Unit/RunCount.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: Test::Unit::RunCount - - -:nodoc: all - - -# Class Methods -## have_run?() [](#method-c-have_run?) -**@return** [Boolean] - -## run_once() [](#method-c-run_once) - -#Instance Methods -## run() [](#method-i-run) - diff --git a/example/ruby/Test/Unit/Runner.md b/example/ruby/Test/Unit/Runner.md deleted file mode 100644 index df95793..0000000 --- a/example/ruby/Test/Unit/Runner.md +++ /dev/null @@ -1,171 +0,0 @@ -# Class: Test::Unit::Runner -**Inherits:** Object - -**Includes:** Test::Unit::ExcludesOption, Test::Unit::GCOption, Test::Unit::GlobOption, Test::Unit::LaunchableOption::Nothing, Test::Unit::LoadPathOption, Test::Unit::Options, Test::Unit::OutputOption, Test::Unit::Parallel, Test::Unit::RepeatOption, Test::Unit::RunCount, Test::Unit::Skipping, Test::Unit::Statistics, Test::Unit::StatusLine, Test::Unit::TimeoutOption - - -:nodoc: all - - -# Class Methods -## after_tests(&block ) [](#method-c-after_tests) -A simple hook allowing you to run a block of code after *all* of the tests are -done. Eg: - - Test::Unit::Runner.after_tests { p $debugging_info } -## autorun() [](#method-c-autorun) -## current_repeat_count() [](#method-c-current_repeat_count) -Runner for a given `type` (eg, test vs bench). -## output() [](#method-c-output) -Returns the stream to use for output. -## output=(stream ) [](#method-c-output=) -Sets Test::Unit::Runner to write output to `stream`. $stdout is the default -output -## plugins() [](#method-c-plugins) -Return all plugins' run methods (methods that start with "run_"). -## runner() [](#method-c-runner) -Returns the Test::Unit::Runner subclass instance that will be used to run the -tests. A Test::Unit::Runner instance is the default runner. -## runner=(runner ) [](#method-c-runner=) -Tells Test::Unit::Runner to delegate to `runner`, an instance of a -Test::Unit::Runner subclass, when Test::Unit::Runner#run is called. -# Attributes -## assertion_count[RW] [](#attribute-i-assertion_count) -:nodoc: - -## errors[RW] [](#attribute-i-errors) -:nodoc: - -## failures[RW] [](#attribute-i-failures) -:nodoc: - -## help[RW] [](#attribute-i-help) -:nodoc: - -## info_signal[RW] [](#attribute-i-info_signal) -:attr: - -if true, installs an "INFO" signal handler (only available to BSD and OS X -users) which prints diagnostic information about the test run. - -This is auto-detected by default but may be overridden by custom runners. - -## options[RW] [](#attribute-i-options) -Lazy accessor for options. - -## report[RW] [](#attribute-i-report) -:nodoc: - -## skips[RW] [](#attribute-i-skips) -:nodoc: - -## start_time[RW] [](#attribute-i-start_time) -:nodoc: - -## test_count[RW] [](#attribute-i-test_count) -:nodoc: - -## verbose[RW] [](#attribute-i-verbose) -:nodoc: - - -#Instance Methods -## _end_method(inst) [](#method-i-_end_method) - -## _prepare_run(suites, type) [](#method-i-_prepare_run) - -## _print(s) [](#method-i-_print) - -## _run(args[]) [](#method-i-_run) -Top level driver, controls all output and filtering. - -## _run_anything(type) [](#method-i-_run_anything) - -## _run_suite(suite, type) [](#method-i-_run_suite) -Run a single `suite` for a given `type`. - -## _start_method(inst) [](#method-i-_start_method) - -## add_status(line) [](#method-i-add_status) - -## complement_test_name(f, orig_f) [](#method-i-complement_test_name) - -**@raise** [ArgumentError] - -## del_jobs_status() [](#method-i-del_jobs_status) - -## del_status_line(flushtrue) [](#method-i-del_status_line) - -## failed(s) [](#method-i-failed) - -## initialize() [](#method-i-initialize) -Writes status for failed test `meth` in `klass` which finished with exception -`e` - -**@return** [Runner] a new instance of Runner - -## inspect() [](#method-i-inspect) - -## jobs_status(worker) [](#method-i-jobs_status) - -## location(e) [](#method-i-location) -:nodoc: - -## new_test(s) [](#method-i-new_test) - -## non_options(files, options) [](#method-i-non_options) - -## option_parser() [](#method-i-option_parser) - -## output() [](#method-i-output) -Return the IO for output. - -## print(*a) [](#method-i-print) -:nodoc: - -## process_args(args[]) [](#method-i-process_args) - -## puke(klass, meth, e) [](#method-i-puke) -Overriding of Test::Unit::Runner#puke - -## puts(*a) [](#method-i-puts) -:nodoc: - -## record(suite, method, assertions, time, error, source_locationnil) [](#method-i-record) -Record the result of a single test. Makes it very easy to gather information. -Eg: - - class StatisticsRecorder < Test::Unit::Runner - def record suite, method, assertions, time, error - # ... record the results somewhere ... - end - end - - Test::Unit::Runner.runner = StatisticsRecorder.new - -NOTE: record might be sent more than once per test. It will be sent once with -the results from the test itself. If there is a failure or error in teardown, -it will be sent again with the error or failure. - -## run(argv[]) [](#method-i-run) -Begins the full test run. Delegates to `runner`'s #_run method. - -## run_tests() [](#method-i-run_tests) -Runs test suites matching `filter`. - -## setup_options(parser, options) [](#method-i-setup_options) - -## status(ioself.output) [](#method-i-status) -Writes status to `io` - -## succeed() [](#method-i-succeed) - -## synchronize() [](#method-i-synchronize) -:nodoc: - -## terminal_width() [](#method-i-terminal_width) - -## update_list(list, rec, max) [](#method-i-update_list) - -## update_status(s) [](#method-i-update_status) - diff --git a/example/ruby/Test/Unit/Skipping.md b/example/ruby/Test/Unit/Skipping.md deleted file mode 100644 index bde5198..0000000 --- a/example/ruby/Test/Unit/Skipping.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Test::Unit::Skipping - - -:nodoc: all - - - -#Instance Methods -## failed(s) [](#method-i-failed) - diff --git a/example/ruby/Test/Unit/Statistics.md b/example/ruby/Test/Unit/Statistics.md deleted file mode 100644 index c94ef6f..0000000 --- a/example/ruby/Test/Unit/Statistics.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: Test::Unit::Statistics - - - - - -#Instance Methods -## record(suite, method, assertions, time, error, source_locationnil) [](#method-i-record) - -## run(*args) [](#method-i-run) - -## update_list(list, rec, max) [](#method-i-update_list) - diff --git a/example/ruby/Test/Unit/StatusLine.md b/example/ruby/Test/Unit/StatusLine.md deleted file mode 100644 index e9b81c3..0000000 --- a/example/ruby/Test/Unit/StatusLine.md +++ /dev/null @@ -1,36 +0,0 @@ -# Module: Test::Unit::StatusLine - - -:nodoc: all - - - -#Instance Methods -## _prepare_run(suites, type) [](#method-i-_prepare_run) - -## _print(s) [](#method-i-_print) - -## add_status(line) [](#method-i-add_status) - -## del_jobs_status() [](#method-i-del_jobs_status) - -## del_status_line(flushtrue) [](#method-i-del_status_line) - -## failed(s) [](#method-i-failed) - -## initialize() [](#method-i-initialize) - -## jobs_status(worker) [](#method-i-jobs_status) - -## new_test(s) [](#method-i-new_test) - -## output() [](#method-i-output) - -## run(*args) [](#method-i-run) - -## succeed() [](#method-i-succeed) - -## terminal_width() [](#method-i-terminal_width) - -## update_status(s) [](#method-i-update_status) - diff --git a/example/ruby/Test/Unit/StatusLine/Output.md b/example/ruby/Test/Unit/StatusLine/Output.md deleted file mode 100644 index 4a92d7f..0000000 --- a/example/ruby/Test/Unit/StatusLine/Output.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: Test::Unit::StatusLine::Output -**Inherits:** Struct - - -:nodoc: all - - - -#Instance Methods -## method_missing(*a, &b) [](#method-i-method_missing) - -## print(s) [](#method-i-print) - -## puts(*a) [](#method-i-puts) - -## respond_to_missing?(*a) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - diff --git a/example/ruby/Test/Unit/TestCase.md b/example/ruby/Test/Unit/TestCase.md deleted file mode 100644 index 4f08c17..0000000 --- a/example/ruby/Test/Unit/TestCase.md +++ /dev/null @@ -1,603 +0,0 @@ -# Class: Test::Unit::TestCase -**Inherits:** Object - -**Extended by:** Test::Unit::Guard - -**Includes:** GCCompactChecker, GCDisabledChecker, Test::Unit::Assertions, Test::Unit::CoreAssertions, Test::Unit::Guard, Test::Unit::LifecycleHooks, TracePointChecker::ZombieTraceHunter, ZombieHunter - - -Subclass TestCase to create your own tests. Typically you'll want a TestCase -subclass per implementation class. - -See `Test::Unit::AssertionFailedError`s - - -# Class Methods -## add(*name , &b ) [](#method-c-add) -## add_proc_meminfo(file , fields ) [](#method-c-add_proc_meminfo) -## current() [](#method-c-current) -:nodoc: -## inherited(klass ) [](#method-c-inherited) -:nodoc: -## jruby?(platform RUBY_PLATFORM) [](#method-c-jruby?) -Is this running on jruby? -**@return** [Boolean] - -## method_added(name ) [](#method-c-method_added) -**@private** [] - -## mingw?(platform RUBY_PLATFORM) [](#method-c-mingw?) -Is this running on mingw? -**@return** [Boolean] - -## mri?(platform RUBY_DESCRIPTION) [](#method-c-mri?) -Is this running on mri? -**@return** [Boolean] - -## on_parallel_worker?() [](#method-c-on_parallel_worker?) -**@return** [Boolean] - -## reset() [](#method-c-reset) -:nodoc: -## test_methods() [](#method-c-test_methods) -:nodoc: -## test_suites() [](#method-c-test_suites) -:nodoc: -## windows?(platform RUBY_PLATFORM) [](#method-c-windows?) -Is this running on windows? -**@return** [Boolean] - -# Attributes -## test_order[RW] [](#attribute-c-test_order) - -## __name__[RW] [](#attribute-i-__name__) -:nodoc: - - -#Instance Methods -## _assertions() [](#method-i-_assertions) -:nodoc: - -## _assertions=(n) [](#method-i-_assertions=) -:nodoc: - -## after_setup() [](#method-i-after_setup) -Runs before every test, after setup. This hook is meant for libraries to -extend Test::Unit. It is not meant to be used by test developers. - -See #before_setup for an example. - -## after_teardown() [](#method-i-after_teardown) - -## assert(test, *msgs) [](#method-i-assert) -:call-seq: - assert(test, [failure_message]) - -Tests if `test` is true. - -`msg` may be a String or a Proc. If `msg` is a String, it will be used as the -failure message. Otherwise, the result of calling `msg` will be used as the -message if the assertion fails. - -If no `msg` is given, a default message will be used. - - assert(false, "This was expected to be true") - -## assert_all?(obj, mnil, &blk) [](#method-i-assert_all?) - -**@return** [Boolean] - -## assert_all_assertions(msgnil) [](#method-i-assert_all_assertions) - -## assert_all_assertions_foreach(msgnil, *keys, &block) [](#method-i-assert_all_assertions_foreach) - -## assert_bignum(v, msgnil) [](#method-i-assert_bignum) - -## assert_block(*msgs) [](#method-i-assert_block) -:call-seq: - assert_block( failure_message = nil ) - -Tests the result of the given block. If the block does not return true, the -assertion will fail. The optional `failure_message` argument is the same as in -Assertions#assert. - - assert_block do - [1, 2, 3].any? { |num| num < 1 } - end - -## assert_cpu_usage_low(msgnil, pct:0.05, wait:1.0, stop:nil) [](#method-i-assert_cpu_usage_low) - -## assert_deprecated_warn(mesg/deprecated/) [](#method-i-assert_deprecated_warn) - -## assert_deprecated_warning(mesg/deprecated/) [](#method-i-assert_deprecated_warning) - -## assert_empty(obj, msgnil) [](#method-i-assert_empty) -Fails unless `obj` is empty. - -## assert_equal(exp, act, msgnil) [](#method-i-assert_equal) -:call-seq: - assert_equal( expected, actual, failure_message = nil ) - -Tests if `expected` is equal to `actual`. - -An optional failure message may be provided as the final argument. - -## assert_false(obj, msgnil) [](#method-i-assert_false) -Fails unless `obj` is false - -## assert_file() [](#method-i-assert_file) - -## assert_fixnum(v, msgnil) [](#method-i-assert_fixnum) - -## assert_in_delta(exp, act, delta0.001, msgnil) [](#method-i-assert_in_delta) -For comparing Floats. Fails unless `exp` and `act` are within `delta` of each -other. - - assert_in_delta Math::PI, (22.0 / 7.0), 0.01 - -## assert_in_epsilon(a, b, epsilon0.001, msgnil) [](#method-i-assert_in_epsilon) -For comparing Floats. Fails unless `exp` and `act` have a relative error less -than `epsilon`. - -## assert_in_out_err(args, test_stdin"", test_stdout[], test_stderr[], messagenil, success:nil, **opt) [](#method-i-assert_in_out_err) - -## assert_includes(collection, obj, msgnil) [](#method-i-assert_includes) -Fails unless `collection` includes `obj`. - -## assert_instance_of(cls, obj, msgnil) [](#method-i-assert_instance_of) -Fails unless `obj` is an instance of `cls`. - -## assert_is_minus_zero(f) [](#method-i-assert_is_minus_zero) - -## assert_join_threads(threads, messagenil) [](#method-i-assert_join_threads) -threads should respond to shift method. Array can be used. - -## assert_kind_of(cls, obj, msgnil) [](#method-i-assert_kind_of) -Fails unless `obj` is a kind of `cls`. - -## assert_linear_performance(seq, rehearsal:nil, pre:->(n) {n}) [](#method-i-assert_linear_performance) -Expect `seq` to respond to `first` and `each` methods, e.g., Array, Range, -Enumerator::ArithmeticSequence and other Enumerable-s, and each elements -should be size factors. - -:yield: each elements of `seq`. - -## assert_match(matcher, obj, msgnil) [](#method-i-assert_match) -Fails unless `matcher` `=~` `obj`. - -## assert_nil(obj, msgnil) [](#method-i-assert_nil) -Fails unless `obj` is nil - -## assert_no_match(regexp, string, msgnil) [](#method-i-assert_no_match) -:call-seq: - assert_no_match( regexp, string, failure_message = nil ) - -Tests if the given Regexp does not match a given String. - -An optional failure message may be provided as the final argument. - -## assert_no_memory_leak(args, prepare, code, messagenil, limit:2.0, rss:false, **opt) [](#method-i-assert_no_memory_leak) - -## assert_no_warning(pat, msgnil) [](#method-i-assert_no_warning) - -## assert_normal_exit(testsrc, message'', child_env:nil, **opt) [](#method-i-assert_normal_exit) - -## assert_not_all?(obj, mnil, &blk) [](#method-i-assert_not_all?) - -**@return** [Boolean] - -## assert_not_equal(exp, act, msgnil) [](#method-i-assert_not_equal) -:call-seq: - assert_not_equal( expected, actual, failure_message = nil ) - -Tests if `expected` is not equal to `actual`. - -An optional failure message may be provided as the final argument. - -## assert_not_nil(exp, msgnil) [](#method-i-assert_not_nil) -:call-seq: - assert_not_nil( expression, failure_message = nil ) - -Tests if `expression` is not nil. - -An optional failure message may be provided as the final argument. - -## assert_not_respond_to(obj, meth, *priv, msgnil) [](#method-i-assert_not_respond_to) -:call-seq: - assert_not_respond_to( object, method, failure_message = nil ) - -Tests if the given Object does not respond to `method`. - -An optional failure message may be provided as the final argument. - - assert_not_respond_to("hello", :reverse) #Fails - assert_not_respond_to("hello", :does_not_exist) #Succeeds - -## assert_not_same(expected, actual, message"") [](#method-i-assert_not_same) -:call-seq: - assert_not_same( expected, actual, failure_message = nil ) - -Tests if `expected` is not the same object as `actual`. This test uses -Object#equal? to test equality. - -An optional failure message may be provided as the final argument. - - assert_not_same("x", "x") #Succeeds - -## assert_not_send(send_ary, mnil) [](#method-i-assert_not_send) -:call-seq: - assert_not_send( +send_array+, failure_message = nil ) - -Passes if the method send doesn't return a true value. - -`send_array` is composed of: -* A receiver -* A method -* Arguments to the method - -Example: - assert_not_send([[1, 2], :member?, 1]) # -> fail - assert_not_send([[1, 2], :member?, 4]) # -> pass - -## assert_nothing_raised(*args) [](#method-i-assert_nothing_raised) -:call-seq: - assert_nothing_raised( *args, &block ) - -If any exceptions are given as arguments, the assertion will fail if one of -those exceptions are raised. Otherwise, the test fails if any exceptions are -raised. - -The final argument may be a failure message. - - assert_nothing_raised RuntimeError do - raise Exception #Assertion passes, Exception is not a RuntimeError - end - - assert_nothing_raised do - raise Exception #Assertion fails - end - -## assert_nothing_thrown(msgnil) [](#method-i-assert_nothing_thrown) -:call-seq: - assert_nothing_thrown( failure_message = nil, &block ) - -Fails if the given block uses a call to Kernel#throw, and returns the result -of the block otherwise. - -An optional failure message may be provided as the final argument. - - assert_nothing_thrown "Something was thrown!" do - throw :problem? - end - -## assert_operator(o1, op, o2(predicate = true; nil), msgnil) [](#method-i-assert_operator) -For testing with binary operators. - - assert_operator 5, :<=, 4 - -## assert_output(stdoutnil, stderrnil) [](#method-i-assert_output) -Fails if stdout or stderr do not output the expected results. Pass in nil if -you don't care about that streams output. Pass in "" if you require it to be -silent. Pass in a regexp if you want to pattern match. - -NOTE: this uses #capture_io, not #capture_subprocess_io. - -See also: #assert_silent - -## assert_path_exists(path, msgnil) [](#method-i-assert_path_exists) - -## assert_pattern_list(pattern_list, actual, messagenil) [](#method-i-assert_pattern_list) -pattern_list is an array which contains regexp, string and :*. :* means any -sequence. - -pattern_list is anchored. Use [:*, regexp/string, :*] for non-anchored match. - -## assert_predicate(o1, op, msgnil) [](#method-i-assert_predicate) -For testing with predicates. - - assert_predicate str, :empty? - -This is really meant for specs and is front-ended by assert_operator: - - str.must_be :empty? - -## assert_ractor(src, args:[], require:nil, require_relative:nil, file:nil, line:nil, ignore_stderr:nil, **opt) [](#method-i-assert_ractor) -Run Ractor-related test without influencing the main test suite - -## assert_raise(*exp, &b) [](#method-i-assert_raise) -:call-seq: - assert_raise( *args, &block ) - -Tests if the given block raises an exception. Acceptable exception types may -be given as optional arguments. If the last argument is a String, it will be -used as the error message. - - assert_raise do #Fails, no Exceptions are raised - end - - assert_raise NameError do - puts x #Raises NameError, so assertion succeeds - end - -## assert_raise_with_message(exception, expected, msgnil, &block) [](#method-i-assert_raise_with_message) -:call-seq: - assert_raise_with_message(exception, expected, msg = nil, &block) - -Tests if the given block raises an exception with the expected message. - - assert_raise_with_message(RuntimeError, "foo") do - nil #Fails, no Exceptions are raised - end - - assert_raise_with_message(RuntimeError, "foo") do - raise ArgumentError, "foo" #Fails, different Exception is raised - end - - assert_raise_with_message(RuntimeError, "foo") do - raise "bar" #Fails, RuntimeError is raised but the message differs - end - - assert_raise_with_message(RuntimeError, "foo") do - raise "foo" #Raises RuntimeError with the message, so assertion succeeds - end - -## assert_raises(*exp, &b) [](#method-i-assert_raises) - -**@raise** [NoMethodError] - -## assert_respond_to(obj, meth, *priv, msgnil) [](#method-i-assert_respond_to) -:call-seq: - assert_respond_to( object, method, failure_message = nil ) - -Tests if the given Object responds to `method`. - -An optional failure message may be provided as the final argument. - - assert_respond_to("hello", :reverse) #Succeeds - assert_respond_to("hello", :does_not_exist) #Fails - -## assert_ruby_status(args, test_stdin"", messagenil, **opt) [](#method-i-assert_ruby_status) - -## assert_same(exp, act, msgnil) [](#method-i-assert_same) -Fails unless `exp` and `act` are #equal? - -## assert_send(send_ary, mnil) [](#method-i-assert_send) -:call-seq: - assert_send( +send_array+, failure_message = nil ) - -Passes if the method send returns a true value. - -`send_array` is composed of: -* A receiver -* A method -* Arguments to the method - -Example: - assert_send(["Hello world", :include?, "Hello"]) # -> pass - assert_send(["Hello world", :include?, "Goodbye"]) # -> fail - -## assert_separately(args, filenil, linenil, src, ignore_stderr:nil, **opt) [](#method-i-assert_separately) - -## assert_silent() [](#method-i-assert_silent) -Fails if the block outputs anything to stderr or stdout. - -See also: #assert_output - -## assert_syntax_error(code, error, *args, **opt) [](#method-i-assert_syntax_error) - -## assert_throw(tag, msgnil) [](#method-i-assert_throw) -:call-seq: - assert_throw( tag, failure_message = nil, &block ) - -Fails unless the given block throws `tag`, returns the caught value otherwise. - -An optional failure message may be provided as the final argument. - - tag = Object.new - assert_throw(tag, "#{tag} was not thrown!") do - throw tag - end - -## assert_throws(sym, msgnil) [](#method-i-assert_throws) -Fails unless the block throws `sym` - -## assert_true(obj, msgnil) [](#method-i-assert_true) -Fails unless `obj` is true - -## assert_valid_syntax(code, *args, **opt) [](#method-i-assert_valid_syntax) - -## assert_warn(*args) [](#method-i-assert_warn) - -## assert_warning(pat, msgnil) [](#method-i-assert_warning) - -## before_setup() [](#method-i-before_setup) - -## before_teardown() [](#method-i-before_teardown) -Runs after every test, before teardown. This hook is meant for libraries to -extend Test::Unit. It is not meant to be used by test developers. - -See #before_setup for an example. - -## build_message(head, templatenil, *arguments) [](#method-i-build_message) -:nodoc: - -## capture_io() [](#method-i-capture_io) - -**@raise** [NoMethodError] - -## capture_output() [](#method-i-capture_output) -Captures $stdout and $stderr into strings: - - out, err = capture_output do - puts "Some info" - warn "You did a bad thing" - end - - assert_match %r%info%, out - assert_match %r%bad%, err - -## clean(s) [](#method-i-clean) - -## diff(exp, act) [](#method-i-diff) - -## flunk(msgnil) [](#method-i-flunk) -Fails with `msg` - -## initialize(name) [](#method-i-initialize) -:nodoc: - -**@return** [TestCase] a new instance of TestCase - -## io() [](#method-i-io) -Return the output IO object - -## io?() [](#method-i-io?) -Have we hooked up the IO yet? - -**@return** [Boolean] - -## jruby?(platformRUBY_PLATFORM) [](#method-i-jruby?) -Is this running on jruby? - -**@return** [Boolean] - -## memprofile_test_all_result_result() [](#method-i-memprofile_test_all_result_result) - -## message(msgnil, endingnil, &default) [](#method-i-message) -Returns a proc that will output `msg` along with the default message. - -## mingw?(platformRUBY_PLATFORM) [](#method-i-mingw?) -Is this running on mingw? - -**@return** [Boolean] - -## mri?(platformRUBY_DESCRIPTION) [](#method-i-mri?) -Is this running on mri? - -**@return** [Boolean] - -## mu_pp(obj) [](#method-i-mu_pp) -:nodoc: - -## mu_pp_for_diff(obj) [](#method-i-mu_pp_for_diff) -This returns a diff-able human-readable version of `obj`. This differs from -the regular mu_pp because it expands escaped newlines and makes hex-values -generic (like object_ids). This uses mu_pp to do the first pass and then -cleans it up. - -## new_test_token() [](#method-i-new_test_token) - -## on_parallel_worker?() [](#method-i-on_parallel_worker?) - -**@return** [Boolean] - -## orig_run() [](#method-i-orig_run) - -## pass(msgnil) [](#method-i-pass) -used for counting assertions - -## passed?() [](#method-i-passed?) -Returns true if the test passed. - -**@return** [Boolean] - -## pend(msgnil, btcaller, &_) [](#method-i-pend) -Skips the current test. Gets listed at the end of the run but doesn't cause a -failure exit code. - -**@raise** [Test::Unit::PendedError] - -## prepare_syntax_check(code, fnamenil, mesgnil, verbose:nil) [](#method-i-prepare_syntax_check) - -## refute(test, msgnil) [](#method-i-refute) -Fails if `test` is a true value - -## refute_empty(obj, msgnil) [](#method-i-refute_empty) -Fails if `obj` is empty. - -## refute_equal(exp, act, msgnil) [](#method-i-refute_equal) -Fails if `exp == act`. - -For floats use refute_in_delta. - -## refute_in_delta(exp, act, delta0.001, msgnil) [](#method-i-refute_in_delta) -For comparing Floats. Fails if `exp` is within `delta` of `act`. - - refute_in_delta Math::PI, (22.0 / 7.0) - -## refute_in_epsilon(a, b, epsilon0.001, msgnil) [](#method-i-refute_in_epsilon) -For comparing Floats. Fails if `exp` and `act` have a relative error less -than `epsilon`. - -## refute_includes(collection, obj, msgnil) [](#method-i-refute_includes) -Fails if `collection` includes `obj`. - -## refute_instance_of(cls, obj, msgnil) [](#method-i-refute_instance_of) -Fails if `obj` is an instance of `cls`. - -## refute_kind_of(cls, obj, msgnil) [](#method-i-refute_kind_of) -Fails if `obj` is a kind of `cls`. - -## refute_match(matcher, obj, msgnil) [](#method-i-refute_match) -Fails if `matcher` `=~` `obj`. - -## refute_nil(obj, msgnil) [](#method-i-refute_nil) -Fails if `obj` is nil. - -## refute_operator(o1, op, o2(predicate = true; nil), msgnil) [](#method-i-refute_operator) -Fails if `o1` is not `op` `o2`. Eg: - - refute_operator 1, :>, 2 #=> pass - refute_operator 1, :<, 2 #=> fail - -## refute_path_exists(path, msgnil) [](#method-i-refute_path_exists) - -## refute_predicate(o1, op, msgnil) [](#method-i-refute_predicate) -For testing with predicates. - - refute_predicate str, :empty? - -This is really meant for specs and is front-ended by refute_operator: - - str.wont_be :empty? - -## refute_respond_to(obj, meth, msgnil) [](#method-i-refute_respond_to) -Fails if `obj` responds to the message `meth`. - -## refute_same(exp, act, msgnil) [](#method-i-refute_same) -Fails if `exp` is the same (by object identity) as `act`. - -## run(runner) [](#method-i-run) -Runs the tests reporting the status to `runner` - -## run_test(name) [](#method-i-run_test) - -## separated_runner(token, outnil) [](#method-i-separated_runner) - -## setup() [](#method-i-setup) -Runs before every test. Use this to set up before each test run. - -## skip(msgnil, btcaller) [](#method-i-skip) - -**@raise** [NoMethodError] - -## skipped?() [](#method-i-skipped?) -Was this testcase skipped? Meant for #teardown. - -**@return** [Boolean] - -## synchronize() [](#method-i-synchronize) -Takes a block and wraps it with the runner's shared mutex. - -## syntax_check(code, fname, line) [](#method-i-syntax_check) - -## teardown() [](#method-i-teardown) -Runs after every test. Use this to clean up after each test run. - -## tracepoint_capture_stat_get() [](#method-i-tracepoint_capture_stat_get) - -## windows?(platformRUBY_PLATFORM) [](#method-i-windows?) -Is this running on windows? - -**@return** [Boolean] - diff --git a/example/ruby/Test/Unit/TimeoutOption.md b/example/ruby/Test/Unit/TimeoutOption.md deleted file mode 100644 index a0555f1..0000000 --- a/example/ruby/Test/Unit/TimeoutOption.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: Test::Unit::TimeoutOption - - - - - -#Instance Methods -## non_options(files, options) [](#method-i-non_options) - -## setup_options(parser, options) [](#method-i-setup_options) - diff --git a/example/ruby/Test/Unit/Worker.md b/example/ruby/Test/Unit/Worker.md deleted file mode 100644 index 2f88dc3..0000000 --- a/example/ruby/Test/Unit/Worker.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Test::Unit::Worker -**Inherits:** Test::Unit::Runner - - -:nodoc: - - - -#Instance Methods -## _report(res, *args) [](#method-i-_report) -:nodoc: - -## _run_suite(suite, type) [](#method-i-_run_suite) -:nodoc: - -## _run_suites(suites, type) [](#method-i-_run_suites) -:nodoc: - -## _start_method(inst) [](#method-i-_start_method) - -## increment_io(orig) [](#method-i-increment_io) -:nodoc: - -## puke(klass, meth, e) [](#method-i-puke) -:nodoc: - -## record(suite, method, assertions, time, error) [](#method-i-record) -:nodoc: - -## run(args[]) [](#method-i-run) -:nodoc: - diff --git a/example/ruby/TestA.md b/example/ruby/TestA.md deleted file mode 100644 index 11ae76c..0000000 --- a/example/ruby/TestA.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestA -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_nothing_test() [](#method-i-test_nothing_test) - diff --git a/example/ruby/TestABI.md b/example/ruby/TestABI.md deleted file mode 100644 index 35c24f6..0000000 --- a/example/ruby/TestABI.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestABI -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_disable_abi_check_using_environment_variable() [](#method-i-test_disable_abi_check_using_environment_variable) - -## test_enable_abi_check_using_environment_variable() [](#method-i-test_enable_abi_check_using_environment_variable) - -## test_require_lib_with_incorrect_abi_on_dev_ruby() [](#method-i-test_require_lib_with_incorrect_abi_on_dev_ruby) - -## test_require_lib_with_incorrect_abi_on_release_ruby() [](#method-i-test_require_lib_with_incorrect_abi_on_release_ruby) - diff --git a/example/ruby/TestAddressResolve.md b/example/ruby/TestAddressResolve.md deleted file mode 100644 index 50ede8f..0000000 --- a/example/ruby/TestAddressResolve.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: TestAddressResolve -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_addrinfo_getaddrinfo_any_non_blocking() [](#method-i-test_addrinfo_getaddrinfo_any_non_blocking) - -## test_addrinfo_getaddrinfo_full_domain_blocking() [](#method-i-test_addrinfo_getaddrinfo_full_domain_blocking) - -## test_addrinfo_getaddrinfo_ipv4_domain_blocking() [](#method-i-test_addrinfo_getaddrinfo_ipv4_domain_blocking) - -## test_addrinfo_getaddrinfo_ipv6_domain_blocking() [](#method-i-test_addrinfo_getaddrinfo_ipv6_domain_blocking) - -## test_addrinfo_getaddrinfo_localhost() [](#method-i-test_addrinfo_getaddrinfo_localhost) - -## test_addrinfo_getaddrinfo_no_host_non_blocking() [](#method-i-test_addrinfo_getaddrinfo_no_host_non_blocking) - -## test_addrinfo_getaddrinfo_non_existing_domain_blocking() [](#method-i-test_addrinfo_getaddrinfo_non_existing_domain_blocking) - -## test_addrinfo_getaddrinfo_numeric_non_blocking() [](#method-i-test_addrinfo_getaddrinfo_numeric_non_blocking) - -## test_addrinfo_getaddrinfo_pf_unspec_domain_blocking() [](#method-i-test_addrinfo_getaddrinfo_pf_unspec_domain_blocking) - -## test_addrinfo_ip_domain_blocking() [](#method-i-test_addrinfo_ip_domain_blocking) - -## test_addrinfo_tcp_domain_blocking() [](#method-i-test_addrinfo_tcp_domain_blocking) - -## test_addrinfo_udp_domain_blocking() [](#method-i-test_addrinfo_udp_domain_blocking) - -## test_ip_socket_getaddress_domain_blocking() [](#method-i-test_ip_socket_getaddress_domain_blocking) - -## test_socket_getnameinfo_domain_blocking() [](#method-i-test_socket_getnameinfo_domain_blocking) -This test "hits deep" into C function call chain. - diff --git a/example/ruby/TestAddressResolve/NullScheduler.md b/example/ruby/TestAddressResolve/NullScheduler.md deleted file mode 100644 index 7dc0d4b..0000000 --- a/example/ruby/TestAddressResolve/NullScheduler.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestAddressResolve::NullScheduler -**Inherits:** Scheduler - - - - - -#Instance Methods -## address_resolve() [](#method-i-address_resolve) - diff --git a/example/ruby/TestAddressResolve/StubScheduler.md b/example/ruby/TestAddressResolve/StubScheduler.md deleted file mode 100644 index b373efb..0000000 --- a/example/ruby/TestAddressResolve/StubScheduler.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestAddressResolve::StubScheduler -**Inherits:** Scheduler - - - - - -#Instance Methods -## address_resolve(hostname) [](#method-i-address_resolve) - diff --git a/example/ruby/TestAlias.md b/example/ruby/TestAlias.md deleted file mode 100644 index 32016cb..0000000 --- a/example/ruby/TestAlias.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: TestAlias -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_alias() [](#method-i-test_alias) - -## test_alias_class_method_added() [](#method-i-test_alias_class_method_added) - -## test_alias_complemented_method() [](#method-i-test_alias_complemented_method) - -## test_alias_in_module() [](#method-i-test_alias_in_module) - -## test_alias_inspect() [](#method-i-test_alias_inspect) - -## test_alias_memory_leak() [](#method-i-test_alias_memory_leak) - -## test_alias_method_equation() [](#method-i-test_alias_method_equation) - -## test_alias_module_method_added() [](#method-i-test_alias_module_method_added) - -## test_alias_suppressing_redefinition() [](#method-i-test_alias_suppressing_redefinition) - -## test_alias_wb_miss() [](#method-i-test_alias_wb_miss) - -## test_alias_with_zsuper_method() [](#method-i-test_alias_with_zsuper_method) - -## test_cyclic_zsuper() [](#method-i-test_cyclic_zsuper) - -## test_nonexistmethod() [](#method-i-test_nonexistmethod) - -## test_send_alias() [](#method-i-test_send_alias) - -## test_special_const_alias() [](#method-i-test_special_const_alias) - -## test_super_in_aliased_module_method() [](#method-i-test_super_in_aliased_module_method) -ruby-dev:46028 -: - -## test_zsuper_alias_visibility() [](#method-i-test_zsuper_alias_visibility) - diff --git a/example/ruby/TestAlias/Alias0.md b/example/ruby/TestAlias/Alias0.md deleted file mode 100644 index 1b1be98..0000000 --- a/example/ruby/TestAlias/Alias0.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestAlias::Alias0 -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestAlias/Alias1.md b/example/ruby/TestAlias/Alias1.md deleted file mode 100644 index 10c9b1b..0000000 --- a/example/ruby/TestAlias/Alias1.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestAlias::Alias1 -**Inherits:** TestAlias::Alias0 - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestAlias/Alias2.md b/example/ruby/TestAlias/Alias2.md deleted file mode 100644 index 8c5fc10..0000000 --- a/example/ruby/TestAlias/Alias2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestAlias::Alias2 -**Inherits:** TestAlias::Alias1 - - - - - diff --git a/example/ruby/TestAlias/Alias3.md b/example/ruby/TestAlias/Alias3.md deleted file mode 100644 index 67c868f..0000000 --- a/example/ruby/TestAlias/Alias3.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestAlias::Alias3 -**Inherits:** TestAlias::Alias2 - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## foo() [](#method-i-foo) - -## quux() [](#method-i-quux) - diff --git a/example/ruby/TestAlias/Alias4.md b/example/ruby/TestAlias/Alias4.md deleted file mode 100644 index 5fb8470..0000000 --- a/example/ruby/TestAlias/Alias4.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestAlias::Alias4 -**Inherits:** TestAlias::Alias0 - - - - - diff --git a/example/ruby/TestAlias/Alias5.md b/example/ruby/TestAlias/Alias5.md deleted file mode 100644 index 9080669..0000000 --- a/example/ruby/TestAlias/Alias5.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestAlias::Alias5 -**Inherits:** TestAlias::Alias4 - - - - - diff --git a/example/ruby/TestAlias/C0.md b/example/ruby/TestAlias/C0.md deleted file mode 100644 index 8829cba..0000000 --- a/example/ruby/TestAlias/C0.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestAlias::C0 -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestAlias/C1.md b/example/ruby/TestAlias/C1.md deleted file mode 100644 index 8c200ed..0000000 --- a/example/ruby/TestAlias/C1.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestAlias::C1 -**Inherits:** TestAlias::C0 - - - - - diff --git a/example/ruby/TestAlias/C2.md b/example/ruby/TestAlias/C2.md deleted file mode 100644 index cdbc560..0000000 --- a/example/ruby/TestAlias/C2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestAlias::C2 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestAlias/SuperInAliasedModuleMethod.md b/example/ruby/TestAlias/SuperInAliasedModuleMethod.md deleted file mode 100644 index 70138c9..0000000 --- a/example/ruby/TestAlias/SuperInAliasedModuleMethod.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestAlias::SuperInAliasedModuleMethod - - - - - diff --git a/example/ruby/TestAlias/SuperInAliasedModuleMethod/Base.md b/example/ruby/TestAlias/SuperInAliasedModuleMethod/Base.md deleted file mode 100644 index 0e11a11..0000000 --- a/example/ruby/TestAlias/SuperInAliasedModuleMethod/Base.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestAlias::SuperInAliasedModuleMethod::Base -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestAlias/SuperInAliasedModuleMethod/Derived.md b/example/ruby/TestAlias/SuperInAliasedModuleMethod/Derived.md deleted file mode 100644 index 62a97b3..0000000 --- a/example/ruby/TestAlias/SuperInAliasedModuleMethod/Derived.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestAlias::SuperInAliasedModuleMethod::Derived -**Inherits:** TestAlias::SuperInAliasedModuleMethod::Base - -**Includes:** TestAlias::SuperInAliasedModuleMethod::M - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestAlias/SuperInAliasedModuleMethod/M.md b/example/ruby/TestAlias/SuperInAliasedModuleMethod/M.md deleted file mode 100644 index 879480c..0000000 --- a/example/ruby/TestAlias/SuperInAliasedModuleMethod/M.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestAlias::SuperInAliasedModuleMethod::M - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestAllRubyQuine.md b/example/ruby/TestAllRubyQuine.md deleted file mode 100644 index e66b6be..0000000 --- a/example/ruby/TestAllRubyQuine.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: TestAllRubyQuine -**Inherits:** Test::Unit::TestCase - - -https://github.com/mame/all-ruby-quine - - - -#Instance Methods -## test_all_ruby_quine() [](#method-i-test_all_ruby_quine) - diff --git a/example/ruby/TestAllocation.md b/example/ruby/TestAllocation.md deleted file mode 100644 index bd8e958..0000000 --- a/example/ruby/TestAllocation.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestAllocation -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## check_allocations(checks) [](#method-i-check_allocations) - -## munge_checks(checks) [](#method-i-munge_checks) - diff --git a/example/ruby/TestAllocation/Literal.md b/example/ruby/TestAllocation/Literal.md deleted file mode 100644 index 0b97a2d..0000000 --- a/example/ruby/TestAllocation/Literal.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestAllocation::Literal -**Inherits:** TestAllocation - - - - - -#Instance Methods -## test_array_literal() [](#method-i-test_array_literal) - -## test_hash_literal() [](#method-i-test_hash_literal) - diff --git a/example/ruby/TestAllocation/MethodCall.md b/example/ruby/TestAllocation/MethodCall.md deleted file mode 100644 index d977ada..0000000 --- a/example/ruby/TestAllocation/MethodCall.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: TestAllocation::MethodCall -**Inherits:** TestAllocation - - - - - -#Instance Methods -## block() [](#method-i-block) - -## test_anonymous_splat_and_anonymous_keyword_splat_parameters() [](#method-i-test_anonymous_splat_and_anonymous_keyword_splat_parameters) - -## test_argument_forwarding() [](#method-i-test_argument_forwarding) - -## test_keyword_and_keyword_splat_parameter() [](#method-i-test_keyword_and_keyword_splat_parameter) - -## test_keyword_parameter() [](#method-i-test_keyword_parameter) - -## test_keyword_splat_parameter() [](#method-i-test_keyword_splat_parameter) - -## test_nested_anonymous_splat_and_anonymous_keyword_splat_parameters() [](#method-i-test_nested_anonymous_splat_and_anonymous_keyword_splat_parameters) - -## test_nested_argument_forwarding() [](#method-i-test_nested_argument_forwarding) - -## test_no_array_allocation_with_splat_and_nonstatic_keywords() [](#method-i-test_no_array_allocation_with_splat_and_nonstatic_keywords) - -## test_no_parameters() [](#method-i-test_no_parameters) - -## test_optional_parameter() [](#method-i-test_optional_parameter) - -## test_positional_splat_and_keyword_parameter() [](#method-i-test_positional_splat_and_keyword_parameter) - -## test_positional_splat_and_keyword_splat_parameter() [](#method-i-test_positional_splat_and_keyword_splat_parameter) - -## test_positional_splat_and_post_parameters() [](#method-i-test_positional_splat_and_post_parameters) - -## test_positional_splat_parameter() [](#method-i-test_positional_splat_parameter) - -## test_required_and_keyword_splat_parameter() [](#method-i-test_required_and_keyword_splat_parameter) - -## test_required_and_positional_splat_parameters() [](#method-i-test_required_and_positional_splat_parameters) - -## test_required_parameter() [](#method-i-test_required_parameter) - -## test_required_positional_and_keyword_parameter() [](#method-i-test_required_positional_and_keyword_parameter) - -## test_ruby2_keywords() [](#method-i-test_ruby2_keywords) - diff --git a/example/ruby/TestAllocation/MethodCall/WithBlock.md b/example/ruby/TestAllocation/MethodCall/WithBlock.md deleted file mode 100644 index 5a29dec..0000000 --- a/example/ruby/TestAllocation/MethodCall/WithBlock.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestAllocation::MethodCall::WithBlock -**Inherits:** TestAllocation::MethodCall - - - - - -#Instance Methods -## block() [](#method-i-block) - diff --git a/example/ruby/TestAllocation/ProcCall.md b/example/ruby/TestAllocation/ProcCall.md deleted file mode 100644 index 8b81286..0000000 --- a/example/ruby/TestAllocation/ProcCall.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestAllocation::ProcCall -**Inherits:** TestAllocation::MethodCall - - - - - -#Instance Methods -## munge_checks(checks) [](#method-i-munge_checks) - -## test_no_array_allocation_with_splat_and_nonstatic_keywords() [](#method-i-test_no_array_allocation_with_splat_and_nonstatic_keywords) - diff --git a/example/ruby/TestAllocation/ProcCall/WithBlock.md b/example/ruby/TestAllocation/ProcCall/WithBlock.md deleted file mode 100644 index 2464df6..0000000 --- a/example/ruby/TestAllocation/ProcCall/WithBlock.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestAllocation::ProcCall::WithBlock -**Inherits:** TestAllocation::ProcCall - - - - - -#Instance Methods -## block() [](#method-i-block) - diff --git a/example/ruby/TestArgf.md b/example/ruby/TestArgf.md deleted file mode 100644 index 43e4567..0000000 --- a/example/ruby/TestArgf.md +++ /dev/null @@ -1,168 +0,0 @@ -# Class: TestArgf -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_src_expected(src, argsnil, line:caller_locations(1, 1)[0].lineno+1) [](#method-i-assert_src_expected) - -## make_tempfile(basename"argf-qux", data%w[foo bar baz],, binmode:false) [](#method-i-make_tempfile) - -## no_safe_rename() [](#method-i-no_safe_rename) - -## ruby(*args, external_encoding:Encoding::UTF_8) [](#method-i-ruby) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_argf() [](#method-i-test_argf) - -## test_argv() [](#method-i-test_argv) - -## test_binmode() [](#method-i-test_binmode) - -## test_close() [](#method-i-test_close) - -## test_close_replace() [](#method-i-test_close_replace) - -## test_closed() [](#method-i-test_closed) - -## test_each_byte() [](#method-i-test_each_byte) - -## test_each_char() [](#method-i-test_each_char) - -## test_each_codepoint() [](#method-i-test_each_codepoint) - -## test_each_line() [](#method-i-test_each_line) - -## test_each_line_chomp() [](#method-i-test_each_line_chomp) - -## test_each_line_limit_0() [](#method-i-test_each_line_limit_0) - -## test_each_line_paragraph() [](#method-i-test_each_line_paragraph) - -## test_encoding() [](#method-i-test_encoding) - -## test_eof() [](#method-i-test_eof) - -## test_file() [](#method-i-test_file) - -## test_filename() [](#method-i-test_filename) - -## test_filename2() [](#method-i-test_filename2) - -## test_fileno() [](#method-i-test_fileno) - -## test_getbyte() [](#method-i-test_getbyte) - -## test_getc() [](#method-i-test_getc) - -## test_gets_chomp() [](#method-i-test_gets_chomp) - -## test_inplace() [](#method-i-test_inplace) - -## test_inplace2() [](#method-i-test_inplace2) - -## test_inplace3() [](#method-i-test_inplace3) - -## test_inplace_ascii_incompatible_path() [](#method-i-test_inplace_ascii_incompatible_path) - -## test_inplace_bug_17117() [](#method-i-test_inplace_bug_17117) - -## test_inplace_dup() [](#method-i-test_inplace_dup) - -## test_inplace_invalid_backup() [](#method-i-test_inplace_invalid_backup) - -## test_inplace_no_backup() [](#method-i-test_inplace_no_backup) - -## test_inplace_nonascii() [](#method-i-test_inplace_nonascii) - -## test_inplace_rename_impossible() [](#method-i-test_inplace_rename_impossible) - -## test_inplace_stdin() [](#method-i-test_inplace_stdin) - -## test_inplace_stdin2() [](#method-i-test_inplace_stdin2) - -## test_inplace_suffix_encoding() [](#method-i-test_inplace_suffix_encoding) - -## test_inplace_to_path() [](#method-i-test_inplace_to_path) - -## test_lineno() [](#method-i-test_lineno) - -## test_lineno2() [](#method-i-test_lineno2) - -## test_lineno3() [](#method-i-test_lineno3) - -## test_lineno_after_shebang() [](#method-i-test_lineno_after_shebang) - -## test_new_lineno_each() [](#method-i-test_new_lineno_each) - -## test_new_lineno_each_char() [](#method-i-test_new_lineno_each_char) - -## test_print() [](#method-i-test_print) - -## test_printf() [](#method-i-test_printf) - -## test_putc() [](#method-i-test_putc) - -## test_puts() [](#method-i-test_puts) - -## test_read() [](#method-i-test_read) - -## test_read2() [](#method-i-test_read2) - -## test_read2_with_not_empty_buffer() [](#method-i-test_read2_with_not_empty_buffer) - -## test_read3() [](#method-i-test_read3) - -## test_read_nonblock() [](#method-i-test_read_nonblock) - -## test_readbyte() [](#method-i-test_readbyte) - -## test_readchar() [](#method-i-test_readchar) - -## test_readline_chomp() [](#method-i-test_readline_chomp) - -## test_readlines_chomp() [](#method-i-test_readlines_chomp) - -## test_readlines_limit_0() [](#method-i-test_readlines_limit_0) - -## test_readlines_twice() [](#method-i-test_readlines_twice) - -## test_readpartial() [](#method-i-test_readpartial) - -## test_readpartial2() [](#method-i-test_readpartial2) - -## test_readpartial_eof_twice() [](#method-i-test_readpartial_eof_twice) - -## test_rewind() [](#method-i-test_rewind) - -## test_seek() [](#method-i-test_seek) - -## test_set_pos() [](#method-i-test_set_pos) - -## test_sized_read() [](#method-i-test_sized_read) - -## test_skip() [](#method-i-test_skip) - -## test_skip_in_each_byte() [](#method-i-test_skip_in_each_byte) - -## test_skip_in_each_char() [](#method-i-test_skip_in_each_char) - -## test_skip_in_each_codepoint() [](#method-i-test_skip_in_each_codepoint) - -## test_skip_in_each_line() [](#method-i-test_skip_in_each_line) - -## test_tell() [](#method-i-test_tell) - -## test_textmode() [](#method-i-test_textmode) - -## test_to_io() [](#method-i-test_to_io) - -## test_unreadable() [](#method-i-test_unreadable) - -## test_wrong_type() [](#method-i-test_wrong_type) - diff --git a/example/ruby/TestArithmeticSequence.md b/example/ruby/TestArithmeticSequence.md deleted file mode 100644 index 8a5f944..0000000 --- a/example/ruby/TestArithmeticSequence.md +++ /dev/null @@ -1,84 +0,0 @@ -# Class: TestArithmeticSequence -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_num_equal_type(ary1, ary2, messagenil) [](#method-i-assert_num_equal_type) - -## test_allocate() [](#method-i-test_allocate) - -## test_begin() [](#method-i-test_begin) - -## test_complex() [](#method-i-test_complex) - -## test_cons() [](#method-i-test_cons) - -## test_end() [](#method-i-test_end) - -## test_eq() [](#method-i-test_eq) - -## test_eql_p() [](#method-i-test_eql_p) - -## test_eqq() [](#method-i-test_eqq) - -## test_exclude_end_p() [](#method-i-test_exclude_end_p) - -## test_first() [](#method-i-test_first) - -## test_first_bug15518() [](#method-i-test_first_bug15518) - -## test_hash() [](#method-i-test_hash) - -## test_last() [](#method-i-test_last) - -## test_last_bug17218() [](#method-i-test_last_bug17218) - -## test_last_with_float() [](#method-i-test_last_with_float) - -## test_last_with_rational() [](#method-i-test_last_with_rational) - -## test_new() [](#method-i-test_new) - -## test_next() [](#method-i-test_next) - -## test_next_after_stopiteration() [](#method-i-test_next_after_stopiteration) - -## test_next_bug15444() [](#method-i-test_next_bug15444) - -## test_next_rewind() [](#method-i-test_next_rewind) - -## test_next_values() [](#method-i-test_next_values) - -## test_num_step_inspect() [](#method-i-test_num_step_inspect) - -## test_num_step_size() [](#method-i-test_num_step_size) - -## test_peek() [](#method-i-test_peek) - -## test_peek_values() [](#method-i-test_peek_values) - -## test_range_step_inspect() [](#method-i-test_range_step_inspect) - -## test_range_step_size() [](#method-i-test_range_step_size) - -## test_slice() [](#method-i-test_slice) - -## test_step() [](#method-i-test_step) - -## test_stop_result() [](#method-i-test_stop_result) - -## test_sum() [](#method-i-test_sum) - -## test_to_a() [](#method-i-test_to_a) - -## test_to_a_bug15444() [](#method-i-test_to_a_bug15444) - -## test_to_a_bug17218() [](#method-i-test_to_a_bug17218) - -## test_with_index() [](#method-i-test_with_index) - -## test_with_object() [](#method-i-test_with_object) - diff --git a/example/ruby/TestArity.md b/example/ruby/TestArity.md deleted file mode 100644 index 1950f1a..0000000 --- a/example/ruby/TestArity.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestArity -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## a() [](#method-i-a) - -## assert_arity(expected, method_procnil, argc0) [](#method-i-assert_arity) - -## b(a, b, c, d1, e2, f, g, h, i, &block) [](#method-i-b) - -## c(a, b, c, d1, e2, *rest) [](#method-i-c) - -## d(a, b:42) [](#method-i-d) - -## e(a, b:42, **c) [](#method-i-e) - -## f(a, b, c1, *rest, d:3) [](#method-i-f) - -## test_message_change_issue_6085() [](#method-i-test_message_change_issue_6085) - -## test_method_err_mess() [](#method-i-test_method_err_mess) - -## test_proc_err_mess() [](#method-i-test_proc_err_mess) - diff --git a/example/ruby/TestArray.md b/example/ruby/TestArray.md deleted file mode 100644 index 0914e24..0000000 --- a/example/ruby/TestArray.md +++ /dev/null @@ -1,514 +0,0 @@ -# Class: TestArray -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## to_ary() [](#method-c-to_ary) - -#Instance Methods -## assert_complex_equal(e, v, msgnil) [](#method-i-assert_complex_equal) - -## assert_equal_instance(x, y, *msg) [](#method-i-assert_equal_instance) - -## assert_float_equal(e, v, msgnil) [](#method-i-assert_float_equal) - -## assert_int_equal(e, v, msgnil) [](#method-i-assert_int_equal) - -## assert_rational_equal(e, v, msgnil) [](#method-i-assert_rational_equal) - -## assert_typed_equal(e, v, cls, msgnil) [](#method-i-assert_typed_equal) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_00_new() [](#method-i-test_00_new) -From rubicon - -## test_01_square_brackets() [](#method-i-test_01_square_brackets) - -## test_0_literal() [](#method-i-test_0_literal) - -## test_AND() [](#method-i-test_AND) -'&' - -## test_AND_big_array() [](#method-i-test_AND_big_array) -'&' - -## test_AREF() [](#method-i-test_AREF) -'[]' - -## test_ASET() [](#method-i-test_ASET) -'[]=' - -## test_CMP() [](#method-i-test_CMP) -'<=>' - -## test_EQUAL() [](#method-i-test_EQUAL) -'==' - -## test_LSHIFT() [](#method-i-test_LSHIFT) -'<<' - -## test_MINUS() [](#method-i-test_MINUS) -'-' - -## test_MINUS_big_array() [](#method-i-test_MINUS_big_array) -'-' - -## test_MUL() [](#method-i-test_MUL) -'*' - -## test_OR() [](#method-i-test_OR) -'|' - -## test_OR_big_array() [](#method-i-test_OR_big_array) -'|' - -## test_OR_big_in_order() [](#method-i-test_OR_big_in_order) - -## test_OR_in_order() [](#method-i-test_OR_in_order) - -## test_PLUS() [](#method-i-test_PLUS) -'+' - -## test_VERY_EQUAL() [](#method-i-test_VERY_EQUAL) -'===' - -## test_append() [](#method-i-test_append) - -## test_aref() [](#method-i-test_aref) - -## test_array_andor_0() [](#method-i-test_array_andor_0) - -## test_array_safely_modified_by_sort_block() [](#method-i-test_array_safely_modified_by_sort_block) - -## test_ary_new() [](#method-i-test_ary_new) - -## test_ary_to_ary() [](#method-i-test_ary_to_ary) - -## test_aset_error() [](#method-i-test_aset_error) - -## test_assoc() [](#method-i-test_assoc) - -## test_at() [](#method-i-test_at) - -## test_beg_end_0() [](#method-i-test_beg_end_0) - -## test_big_array_literal_with_kwsplat() [](#method-i-test_big_array_literal_with_kwsplat) - -## test_bsearch_in_find_any_mode() [](#method-i-test_bsearch_in_find_any_mode) - -## test_bsearch_in_find_minimum_mode() [](#method-i-test_bsearch_in_find_minimum_mode) - -## test_bsearch_index_in_find_any_mode() [](#method-i-test_bsearch_index_in_find_any_mode) - -## test_bsearch_index_in_find_minimum_mode() [](#method-i-test_bsearch_index_in_find_minimum_mode) - -## test_bsearch_index_typechecks_return_values() [](#method-i-test_bsearch_index_typechecks_return_values) - -## test_bsearch_index_with_no_block() [](#method-i-test_bsearch_index_with_no_block) - -## test_bsearch_typechecks_return_values() [](#method-i-test_bsearch_typechecks_return_values) - -## test_bsearch_with_no_block() [](#method-i-test_bsearch_with_no_block) - -## test_clear() [](#method-i-test_clear) - -## test_clear2() [](#method-i-test_clear2) - -## test_clone() [](#method-i-test_clone) - -## test_collect() [](#method-i-test_collect) - -## test_collect!() [](#method-i-test_collect!) -also update map! - -## test_combination() [](#method-i-test_combination) - -## test_combination2() [](#method-i-test_combination2) - -## test_combination_clear() [](#method-i-test_combination_clear) - -## test_combination_with_callcc() [](#method-i-test_combination_with_callcc) - -## test_compact() [](#method-i-test_compact) - -## test_compact!() [](#method-i-test_compact!) - -## test_compact_0() [](#method-i-test_compact_0) - -## test_concat() [](#method-i-test_concat) - -## test_count() [](#method-i-test_count) - -## test_cycle() [](#method-i-test_cycle) - -## test_delete() [](#method-i-test_delete) - -## test_delete2() [](#method-i-test_delete2) - -## test_delete_at() [](#method-i-test_delete_at) - -## test_delete_if() [](#method-i-test_delete_if) -also reject! - -## test_difference() [](#method-i-test_difference) - -## test_difference_big_array() [](#method-i-test_difference_big_array) - -## test_dig() [](#method-i-test_dig) - -## test_drop() [](#method-i-test_drop) - -## test_drop_while() [](#method-i-test_drop_while) - -## test_dup() [](#method-i-test_dup) - -## test_each() [](#method-i-test_each) - -## test_each_index() [](#method-i-test_each_index) - -## test_empty?() [](#method-i-test_empty?) - -**@return** [Boolean] - -## test_empty_0() [](#method-i-test_empty_0) - -## test_eql?() [](#method-i-test_eql?) - -**@return** [Boolean] - -## test_equal() [](#method-i-test_equal) - -## test_equal_resize() [](#method-i-test_equal_resize) - -## test_fetch() [](#method-i-test_fetch) - -## test_fill() [](#method-i-test_fill) - -## test_fill2() [](#method-i-test_fill2) - -## test_fill_0() [](#method-i-test_fill_0) - -## test_fill_negative_length() [](#method-i-test_fill_negative_length) - -## test_filter() [](#method-i-test_filter) - -## test_filter!() [](#method-i-test_filter!) -alias for select! - -## test_find_all_0() [](#method-i-test_find_all_0) - -## test_first() [](#method-i-test_first) - -## test_first2() [](#method-i-test_first2) - -## test_flatten() [](#method-i-test_flatten) - -## test_flatten!() [](#method-i-test_flatten!) - -## test_flatten_empty!() [](#method-i-test_flatten_empty!) - -## test_flatten_error() [](#method-i-test_flatten_error) - -## test_flatten_level0() [](#method-i-test_flatten_level0) - -## test_flatten_level0!() [](#method-i-test_flatten_level0!) - -## test_flatten_recursive() [](#method-i-test_flatten_recursive) - -## test_flatten_respond_to_missing() [](#method-i-test_flatten_respond_to_missing) - -## test_flatten_splat() [](#method-i-test_flatten_splat) - -## test_flatten_splat!() [](#method-i-test_flatten_splat!) - -## test_flatten_with_callcc() [](#method-i-test_flatten_with_callcc) - -## test_flatten_wrong_argument() [](#method-i-test_flatten_wrong_argument) - -## test_flattern_singleton_class() [](#method-i-test_flattern_singleton_class) - -## test_flattern_singleton_class!() [](#method-i-test_flattern_singleton_class!) - -## test_freeze_inside_sort!() [](#method-i-test_freeze_inside_sort!) - -## test_hash() [](#method-i-test_hash) - -## test_include?() [](#method-i-test_include?) - -**@return** [Boolean] - -## test_index() [](#method-i-test_index) - -## test_index2() [](#method-i-test_index2) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize2() [](#method-i-test_initialize2) - -## test_insert() [](#method-i-test_insert) - -## test_intersect?() [](#method-i-test_intersect?) - -**@return** [Boolean] - -## test_intersect_big_array() [](#method-i-test_intersect_big_array) - -## test_intersection() [](#method-i-test_intersection) - -## test_intersection_big_array() [](#method-i-test_intersection_big_array) - -## test_iseq_shared_array_reject!() [](#method-i-test_iseq_shared_array_reject!) - -## test_join() [](#method-i-test_join) - -## test_join2() [](#method-i-test_join2) - -## test_join_recheck_array_length() [](#method-i-test_join_recheck_array_length) - -## test_join_recheck_elements_type() [](#method-i-test_join_recheck_elements_type) - -## test_keep_if() [](#method-i-test_keep_if) -also select! - -## test_last() [](#method-i-test_last) - -## test_last2() [](#method-i-test_last2) - -## test_length() [](#method-i-test_length) - -## test_map!() [](#method-i-test_map!) -also update collect! - -## test_max() [](#method-i-test_max) - -## test_max_uncomparable() [](#method-i-test_max_uncomparable) - -## test_min() [](#method-i-test_min) - -## test_min_uncomparable() [](#method-i-test_min_uncomparable) - -## test_minmax() [](#method-i-test_minmax) - -## test_misc_0() [](#method-i-test_misc_0) - -## test_monkey_patch_include?() [](#method-i-test_monkey_patch_include?) - -**@return** [Boolean] - -## test_pack() [](#method-i-test_pack) - -## test_pack_format_mutation() [](#method-i-test_pack_format_mutation) - -## test_pack_with_buffer() [](#method-i-test_pack_with_buffer) - -## test_percent_I() [](#method-i-test_percent_I) - -## test_percent_i() [](#method-i-test_percent_i) - -## test_permutation() [](#method-i-test_permutation) - -## test_permutation_stack_error() [](#method-i-test_permutation_stack_error) - -## test_permutation_with_callcc() [](#method-i-test_permutation_with_callcc) - -## test_pop() [](#method-i-test_pop) - -## test_prepend() [](#method-i-test_prepend) - -## test_product() [](#method-i-test_product) - -## test_product2() [](#method-i-test_product2) - -## test_product_with_callcc() [](#method-i-test_product_with_callcc) - -## test_push() [](#method-i-test_push) - -## test_push_over_ary_max() [](#method-i-test_push_over_ary_max) - -## test_rassoc() [](#method-i-test_rassoc) - -## test_reject() [](#method-i-test_reject) - -## test_reject!() [](#method-i-test_reject!) -also delete_if - -## test_reject_with_callcc() [](#method-i-test_reject_with_callcc) - -## test_repeated_combination() [](#method-i-test_repeated_combination) - -## test_repeated_combination_stack_error() [](#method-i-test_repeated_combination_stack_error) - -## test_repeated_combination_with_callcc() [](#method-i-test_repeated_combination_with_callcc) - -## test_repeated_permutation() [](#method-i-test_repeated_permutation) - -## test_repeated_permutation_stack_error() [](#method-i-test_repeated_permutation_stack_error) - -## test_repeated_permutation_with_callcc() [](#method-i-test_repeated_permutation_with_callcc) - -## test_replace() [](#method-i-test_replace) - -## test_replace_shared_ary() [](#method-i-test_replace_shared_ary) - -## test_replace_wb_variable_width_alloc() [](#method-i-test_replace_wb_variable_width_alloc) - -## test_reverse() [](#method-i-test_reverse) - -## test_reverse!() [](#method-i-test_reverse!) - -## test_reverse_each() [](#method-i-test_reverse_each) - -## test_reverse_each2() [](#method-i-test_reverse_each2) - -## test_rindex() [](#method-i-test_rindex) - -## test_rindex2() [](#method-i-test_rindex2) - -## test_rotate() [](#method-i-test_rotate) - -## test_rotate!() [](#method-i-test_rotate!) - -## test_sample() [](#method-i-test_sample) - -## test_sample_invalid_argument() [](#method-i-test_sample_invalid_argument) - -## test_sample_random_generator() [](#method-i-test_sample_random_generator) - -## test_sample_random_generator_half() [](#method-i-test_sample_random_generator_half) - -## test_sample_random_invalid_generator() [](#method-i-test_sample_random_invalid_generator) - -## test_sample_random_srand0() [](#method-i-test_sample_random_srand0) - -## test_sample_statistics() [](#method-i-test_sample_statistics) - -## test_sample_unknown_keyword() [](#method-i-test_sample_unknown_keyword) - -## test_select() [](#method-i-test_select) - -## test_select!() [](#method-i-test_select!) -also keep_if - -## test_shared_array_reject!() [](#method-i-test_shared_array_reject!) - -## test_shared_marking() [](#method-i-test_shared_marking) - -## test_shift() [](#method-i-test_shift) - -## test_shift2() [](#method-i-test_shift2) - -## test_shift_shared_ary() [](#method-i-test_shift_shared_ary) - -## test_short_heap_array_sort_bang_memory_leak() [](#method-i-test_short_heap_array_sort_bang_memory_leak) - -## test_shrink_shared_array() [](#method-i-test_shrink_shared_array) - -## test_shuffle() [](#method-i-test_shuffle) - -## test_shuffle_random() [](#method-i-test_shuffle_random) - -## test_shuffle_random_clobbering() [](#method-i-test_shuffle_random_clobbering) - -## test_shuffle_random_invalid_generator() [](#method-i-test_shuffle_random_invalid_generator) - -## test_shuffle_random_zero() [](#method-i-test_shuffle_random_zero) - -## test_size() [](#method-i-test_size) - -## test_slice() [](#method-i-test_slice) - -## test_slice!() [](#method-i-test_slice!) - -## test_slice_frozen_array() [](#method-i-test_slice_frozen_array) - -## test_slice_gc_compact_stress() [](#method-i-test_slice_gc_compact_stress) - -## test_slice_out_of_range() [](#method-i-test_slice_out_of_range) - -## test_slice_out_of_range!() [](#method-i-test_slice_out_of_range!) - -## test_sort() [](#method-i-test_sort) - -## test_sort!() [](#method-i-test_sort!) - -## test_sort_0() [](#method-i-test_sort_0) - -## test_sort_bang_with_freeze() [](#method-i-test_sort_bang_with_freeze) - -## test_sort_by!() [](#method-i-test_sort_by!) - -## test_sort_uncomparable() [](#method-i-test_sort_uncomparable) - -## test_sort_with_callcc() [](#method-i-test_sort_with_callcc) - -## test_sort_with_replace() [](#method-i-test_sort_with_replace) - -## test_splice() [](#method-i-test_splice) - -## test_splice_over_ary_max() [](#method-i-test_splice_over_ary_max) - -## test_split_0() [](#method-i-test_split_0) - -## test_sum() [](#method-i-test_sum) - -## test_take() [](#method-i-test_take) - -## test_take_while() [](#method-i-test_take_while) - -## test_times() [](#method-i-test_times) - -## test_to_a() [](#method-i-test_to_a) - -## test_to_a2() [](#method-i-test_to_a2) - -## test_to_ary() [](#method-i-test_to_ary) - -## test_to_h() [](#method-i-test_to_h) - -## test_to_h_block() [](#method-i-test_to_h_block) - -## test_to_s() [](#method-i-test_to_s) - -## test_transpose() [](#method-i-test_transpose) - -## test_try_convert() [](#method-i-test_try_convert) - -## test_union() [](#method-i-test_union) - -## test_union_big_array() [](#method-i-test_union_big_array) - -## test_uniq() [](#method-i-test_uniq) - -## test_uniq!() [](#method-i-test_uniq!) - -## test_uniq_0() [](#method-i-test_uniq_0) - -## test_uniq_bang_with_block() [](#method-i-test_uniq_bang_with_block) - -## test_uniq_bang_with_freeze() [](#method-i-test_uniq_bang_with_freeze) - -## test_uniq_with_block() [](#method-i-test_uniq_with_block) - -## test_unshift() [](#method-i-test_unshift) - -## test_unshift_error() [](#method-i-test_unshift_error) - -## test_unshift_frozen() [](#method-i-test_unshift_frozen) - -## test_unshift_over_ary_max() [](#method-i-test_unshift_over_ary_max) - -## test_values_at() [](#method-i-test_values_at) - -## test_values_at2() [](#method-i-test_values_at2) - -## test_zip() [](#method-i-test_zip) - -## test_zip_bug() [](#method-i-test_zip_bug) - -## test_zip_with_enumerator() [](#method-i-test_zip_with_enumerator) - diff --git a/example/ruby/TestArraySubclass.md b/example/ruby/TestArraySubclass.md deleted file mode 100644 index c8a527c..0000000 --- a/example/ruby/TestArraySubclass.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestArraySubclass -**Inherits:** TestArray - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_array_subclass() [](#method-i-test_array_subclass) - -## test_to_a() [](#method-i-test_to_a) - diff --git a/example/ruby/TestAssertion.md b/example/ruby/TestAssertion.md deleted file mode 100644 index a6bf5a3..0000000 --- a/example/ruby/TestAssertion.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: TestAssertion -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_fail_for_backtrace_location() [](#method-i-assert_fail_for_backtrace_location) - -## assert_not_pattern_list(pattern_list, actual, messagenil) [](#method-i-assert_not_pattern_list) - -## return_in_assert_raise() [](#method-i-return_in_assert_raise) - -## test_assert_pattern_list() [](#method-i-test_assert_pattern_list) - -## test_assert_raise() [](#method-i-test_assert_raise) - -## test_caller_bactrace_location() [](#method-i-test_caller_bactrace_location) - -## test_timeout_separately() [](#method-i-test_timeout_separately) - -## test_version_match_array_beginless_range() [](#method-i-test_version_match_array_beginless_range) - -## test_version_match_array_beginless_range_exclude_end() [](#method-i-test_version_match_array_beginless_range_exclude_end) - -## test_version_match_array_endless_range() [](#method-i-test_version_match_array_endless_range) - -## test_version_match_array_endless_range_exclude_end() [](#method-i-test_version_match_array_endless_range_exclude_end) - -## test_version_match_array_range() [](#method-i-test_version_match_array_range) - -## test_version_match_integer() [](#method-i-test_version_match_integer) - -## test_version_match_integer_beginless_range() [](#method-i-test_version_match_integer_beginless_range) - -## test_version_match_integer_endless_range() [](#method-i-test_version_match_integer_endless_range) - -## test_version_match_integer_endless_range_exclusive() [](#method-i-test_version_match_integer_endless_range_exclusive) - -## test_version_match_integer_range() [](#method-i-test_version_match_integer_range) - -## test_wrong_assertion() [](#method-i-test_wrong_assertion) - diff --git a/example/ruby/TestAssertion/VersionClass.md b/example/ruby/TestAssertion/VersionClass.md deleted file mode 100644 index b2fbaf8..0000000 --- a/example/ruby/TestAssertion/VersionClass.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestAssertion::VersionClass -**Inherits:** Struct - - - - -# Attributes -## version[RW] [](#attribute-i-version) -Returns the value of attribute version - -**@return** [Object] the current value of version - - -#Instance Methods -## version?(*ver) [](#method-i-version?) - -**@return** [Boolean] - diff --git a/example/ruby/TestAssignment.md b/example/ruby/TestAssignment.md deleted file mode 100644 index aab8a80..0000000 --- a/example/ruby/TestAssignment.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: TestAssignment -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## f() [](#method-i-f) - -**@yield** [nil] - -## r(val) [](#method-i-r) - -## test_assign() [](#method-i-test_assign) - -## test_assign_abbreviated() [](#method-i-test_assign_abbreviated) - -## test_assign_ary() [](#method-i-test_assign_ary) - -## test_assign_ary_splat() [](#method-i-test_assign_ary_splat) - -## test_assign_private_self() [](#method-i-test_assign_private_self) - -## test_assign_rescue() [](#method-i-test_assign_rescue) - -## test_assign_simple() [](#method-i-test_assign_simple) - -## test_assign_splat() [](#method-i-test_assign_splat) - -## test_break() [](#method-i-test_break) - -## test_const_assign_order() [](#method-i-test_const_assign_order) - -## test_const_massign() [](#method-i-test_const_massign) - -## test_lambda() [](#method-i-test_lambda) - -## test_massign() [](#method-i-test_massign) - -## test_massign_const_order() [](#method-i-test_massign_const_order) - -## test_massign_in_cond() [](#method-i-test_massign_in_cond) - -## test_massign_order() [](#method-i-test_massign_order) - -## test_massign_simple() [](#method-i-test_massign_simple) - -## test_massign_splat() [](#method-i-test_massign_splat) - -## test_multi() [](#method-i-test_multi) - -## test_nested_massign() [](#method-i-test_nested_massign) - -## test_next() [](#method-i-test_next) - -## test_return() [](#method-i-test_return) - -## test_to_ary_splat() [](#method-i-test_to_ary_splat) - -## test_yield() [](#method-i-test_yield) - diff --git a/example/ruby/TestAssignment/Base.md b/example/ruby/TestAssignment/Base.md deleted file mode 100644 index a923c1e..0000000 --- a/example/ruby/TestAssignment/Base.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestAssignment::Base -**Inherits:** Object - - - - - diff --git a/example/ruby/TestAssignment/MyObj.md b/example/ruby/TestAssignment/MyObj.md deleted file mode 100644 index 82f71b5..0000000 --- a/example/ruby/TestAssignment/MyObj.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestAssignment::MyObj -**Inherits:** Object - - - - - -#Instance Methods -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/TestAssignmentGen.md b/example/ruby/TestAssignmentGen.md deleted file mode 100644 index 42bf8cd..0000000 --- a/example/ruby/TestAssignmentGen.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestAssignmentGen -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## check(assign) [](#method-i-check) - -## do_assign(assign, vars) [](#method-i-do_assign) - -## emu_assign(assign) [](#method-i-emu_assign) - -## emu_assign_ary(lhs, rv, h) [](#method-i-emu_assign_ary) - -## emu_assign_single(lhs, rv, h{}) [](#method-i-emu_assign_single) - -## expand_except_paren(obj) [](#method-i-expand_except_paren) - -## extract_single_element(ary) [](#method-i-extract_single_element) - -## rename_var(obj) [](#method-i-rename_var) - -## test_assignment() [](#method-i-test_assignment) - -## test_chainged_assign_command() [](#method-i-test_chainged_assign_command) - -## test_massign_aref_lhs_splat() [](#method-i-test_massign_aref_lhs_splat) - -## test_optimized_aset() [](#method-i-test_optimized_aset) - diff --git a/example/ruby/TestAst.md b/example/ruby/TestAst.md deleted file mode 100644 index c1c8268..0000000 --- a/example/ruby/TestAst.md +++ /dev/null @@ -1,150 +0,0 @@ -# Class: TestAst -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_invalid_parse(msg, code) [](#method-i-assert_invalid_parse) - -## assert_parse(code, warning:'') [](#method-i-assert_parse) - -## sample_backtrace_location() [](#method-i-sample_backtrace_location) - -## test_allocate() [](#method-i-test_allocate) - -## test_args() [](#method-i-test_args) - -## test_argument_forwarding() [](#method-i-test_argument_forwarding) - -## test_block_arg() [](#method-i-test_block_arg) - -## test_call() [](#method-i-test_call) - -## test_column_of_heredoc() [](#method-i-test_column_of_heredoc) - -## test_column_with_long_heredoc_identifier() [](#method-i-test_column_with_long_heredoc_identifier) - -## test_defn() [](#method-i-test_defn) - -## test_defn_endless() [](#method-i-test_defn_endless) - -## test_defs() [](#method-i-test_defs) - -## test_defs_endless() [](#method-i-test_defs_endless) - -## test_dstr() [](#method-i-test_dstr) - -## test_e_option() [](#method-i-test_e_option) - -## test_encoding_with_keep_script_lines() [](#method-i-test_encoding_with_keep_script_lines) - -## test_error_tolerant() [](#method-i-test_error_tolerant) - -## test_error_tolerant_end_is_short_for_begin() [](#method-i-test_error_tolerant_end_is_short_for_begin) - -## test_error_tolerant_end_is_short_for_case() [](#method-i-test_error_tolerant_end_is_short_for_case) - -## test_error_tolerant_end_is_short_for_class() [](#method-i-test_error_tolerant_end_is_short_for_class) - -## test_error_tolerant_end_is_short_for_do() [](#method-i-test_error_tolerant_end_is_short_for_do) - -## test_error_tolerant_end_is_short_for_do_LAMBDA() [](#method-i-test_error_tolerant_end_is_short_for_do_LAMBDA) - -## test_error_tolerant_end_is_short_for_do_block() [](#method-i-test_error_tolerant_end_is_short_for_do_block) - -## test_error_tolerant_end_is_short_for_for() [](#method-i-test_error_tolerant_end_is_short_for_for) - -## test_error_tolerant_end_is_short_for_if() [](#method-i-test_error_tolerant_end_is_short_for_if) - -## test_error_tolerant_end_is_short_for_method_define() [](#method-i-test_error_tolerant_end_is_short_for_method_define) - -## test_error_tolerant_end_is_short_for_module() [](#method-i-test_error_tolerant_end_is_short_for_module) - -## test_error_tolerant_end_is_short_for_singleton_method_define() [](#method-i-test_error_tolerant_end_is_short_for_singleton_method_define) - -## test_error_tolerant_end_is_short_for_unless() [](#method-i-test_error_tolerant_end_is_short_for_unless) - -## test_error_tolerant_end_is_short_for_until() [](#method-i-test_error_tolerant_end_is_short_for_until) - -## test_error_tolerant_end_is_short_for_while() [](#method-i-test_error_tolerant_end_is_short_for_while) - -## test_error_tolerant_expr_value_can_be_error() [](#method-i-test_error_tolerant_expr_value_can_be_error) - -## test_error_tolerant_treat_end_as_keyword_based_on_indent() [](#method-i-test_error_tolerant_treat_end_as_keyword_based_on_indent) - -## test_error_tolerant_unexpected_backslash() [](#method-i-test_error_tolerant_unexpected_backslash) - -## test_fcall() [](#method-i-test_fcall) - -## test_invalid_exit() [](#method-i-test_invalid_exit) - -## test_invalid_retry() [](#method-i-test_invalid_retry) - -## test_invalid_yield() [](#method-i-test_invalid_yield) - -## test_keep_script_lines_for_of() [](#method-i-test_keep_script_lines_for_of) - -## test_keep_script_lines_for_of_with_existing_SCRIPT_LINES__that_has__FILE__as_a_key() [](#method-i-test_keep_script_lines_for_of_with_existing_SCRIPT_LINES__that_has__FILE__as_a_key) - -## test_keep_script_lines_for_parse() [](#method-i-test_keep_script_lines_for_parse) - -## test_keep_tokens_for_parse() [](#method-i-test_keep_tokens_for_parse) - -## test_keep_tokens_unexpected_backslash() [](#method-i-test_keep_tokens_unexpected_backslash) - -## test_keyword_rest() [](#method-i-test_keyword_rest) - -## test_locations() [](#method-i-test_locations) - -## test_memory_leak() [](#method-i-test_memory_leak) - -## test_node_id_for_backtrace_location_raises_argument_error() [](#method-i-test_node_id_for_backtrace_location_raises_argument_error) - -## test_node_id_for_location() [](#method-i-test_node_id_for_location) - -## test_of_backtrace_location() [](#method-i-test_of_backtrace_location) - -## test_of_backtrace_location_under_eval() [](#method-i-test_of_backtrace_location_under_eval) - -## test_of_backtrace_location_under_eval_with_keep_script_lines() [](#method-i-test_of_backtrace_location_under_eval_with_keep_script_lines) - -## test_of_c_method() [](#method-i-test_of_c_method) - -## test_of_error() [](#method-i-test_of_error) - -## test_of_proc_and_method() [](#method-i-test_of_proc_and_method) - -## test_of_proc_and_method_under_eval() [](#method-i-test_of_proc_and_method_under_eval) - -## test_of_proc_and_method_under_eval_with_keep_script_lines() [](#method-i-test_of_proc_and_method_under_eval_with_keep_script_lines) - -## test_op_asgn2() [](#method-i-test_op_asgn2) - -## test_parse_argument_error() [](#method-i-test_parse_argument_error) - -## test_parse_file_raises_syntax_error() [](#method-i-test_parse_file_raises_syntax_error) - -## test_parse_raises_syntax_error() [](#method-i-test_parse_raises_syntax_error) - -## test_ranges_numbered_parameter() [](#method-i-test_ranges_numbered_parameter) - -## test_rest_arg() [](#method-i-test_rest_arg) - -## test_return() [](#method-i-test_return) - -## test_scope_local_variables() [](#method-i-test_scope_local_variables) - -## test_source_with_multibyte_characters() [](#method-i-test_source_with_multibyte_characters) - -## test_until() [](#method-i-test_until) - -## test_unused_block_local_variable() [](#method-i-test_unused_block_local_variable) - -## test_vcall() [](#method-i-test_vcall) - -## test_while() [](#method-i-test_while) - -## test_with_bom() [](#method-i-test_with_bom) - diff --git a/example/ruby/TestAst/Helper.md b/example/ruby/TestAst/Helper.md deleted file mode 100644 index 361e631..0000000 --- a/example/ruby/TestAst/Helper.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestAst::Helper -**Inherits:** Object - - - - -# Attributes -## errors[RW] [](#attribute-i-errors) -Returns the value of attribute errors. - - -#Instance Methods -## ast() [](#method-i-ast) - -## initialize(path, src:nil) [](#method-i-initialize) - -**@return** [Helper] a new instance of Helper - -## validate_not_cared() [](#method-i-validate_not_cared) - -## validate_range() [](#method-i-validate_range) - diff --git a/example/ruby/TestAst/TestLocation.md b/example/ruby/TestAst/TestLocation.md deleted file mode 100644 index 22baf49..0000000 --- a/example/ruby/TestAst/TestLocation.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: TestAst::TestLocation -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_alias_locations() [](#method-i-test_alias_locations) - -## test_and_locations() [](#method-i-test_and_locations) - -## test_block_pass_locations() [](#method-i-test_block_pass_locations) - -## test_break_locations() [](#method-i-test_break_locations) - -## test_case2_locations() [](#method-i-test_case2_locations) - -## test_case3_locations() [](#method-i-test_case3_locations) - -## test_case_locations() [](#method-i-test_case_locations) - -## test_lineno_and_column() [](#method-i-test_lineno_and_column) - -## test_next_locations() [](#method-i-test_next_locations) - -## test_op_asgn1_locations() [](#method-i-test_op_asgn1_locations) - -## test_op_asgn2_locations() [](#method-i-test_op_asgn2_locations) - -## test_or_locations() [](#method-i-test_or_locations) - -## test_redo_locations() [](#method-i-test_redo_locations) - -## test_return_locations() [](#method-i-test_return_locations) - -## test_splat_locations() [](#method-i-test_splat_locations) - -## test_undef_locations() [](#method-i-test_undef_locations) - -## test_unless_locations() [](#method-i-test_unless_locations) - -## test_until_locations() [](#method-i-test_until_locations) - -## test_valias_locations() [](#method-i-test_valias_locations) - -## test_when_locations() [](#method-i-test_when_locations) - -## test_while_locations() [](#method-i-test_while_locations) - diff --git a/example/ruby/TestAutoload.md b/example/ruby/TestAutoload.md deleted file mode 100644 index 7f864f5..0000000 --- a/example/ruby/TestAutoload.md +++ /dev/null @@ -1,72 +0,0 @@ -# Class: TestAutoload -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## add_autoload(path) [](#method-i-add_autoload) - -## remove_autoload_constant() [](#method-i-remove_autoload_constant) - -## ruby_impl_require() [](#method-i-ruby_impl_require) - -## test_autoload_after_failed_and_removed_from_loaded_features() [](#method-i-test_autoload_after_failed_and_removed_from_loaded_features) - -## test_autoload_deprecate_constant() [](#method-i-test_autoload_deprecate_constant) - -## test_autoload_deprecate_constant_before_autoload() [](#method-i-test_autoload_deprecate_constant_before_autoload) - -## test_autoload_fork() [](#method-i-test_autoload_fork) - -## test_autoload_module_gc() [](#method-i-test_autoload_module_gc) - -## test_autoload_p() [](#method-i-test_autoload_p) - -## test_autoload_p_with_static_extensions() [](#method-i-test_autoload_p_with_static_extensions) - -## test_autoload_parallel_race() [](#method-i-test_autoload_parallel_race) - -## test_autoload_parent_namespace() [](#method-i-test_autoload_parent_namespace) - -## test_autoload_private_constant() [](#method-i-test_autoload_private_constant) - -## test_autoload_private_constant_before_autoload() [](#method-i-test_autoload_private_constant_before_autoload) - -## test_autoload_same_file() [](#method-i-test_autoload_same_file) - -## test_autoload_same_file_with_raise() [](#method-i-test_autoload_same_file_with_raise) - -## test_autoload_so() [](#method-i-test_autoload_so) - -## test_autoload_while_autoloading() [](#method-i-test_autoload_while_autoloading) - -## test_autoload_with_unqualified_file_name() [](#method-i-test_autoload_with_unqualified_file_name) -ruby-core:69206 -: - -## test_bug_13526() [](#method-i-test_bug_13526) - -## test_nameerror_when_autoload_did_not_define_the_constant() [](#method-i-test_nameerror_when_autoload_did_not_define_the_constant) - -## test_no_memory_leak() [](#method-i-test_no_memory_leak) - -## test_non_realpath_in_loadpath() [](#method-i-test_non_realpath_in_loadpath) - -## test_override_autoload() [](#method-i-test_override_autoload) - -## test_override_while_autoloading() [](#method-i-test_override_while_autoloading) - -## test_require_explicit() [](#method-i-test_require_explicit) - -## test_require_implemented_in_ruby_is_called() [](#method-i-test_require_implemented_in_ruby_is_called) - -## test_source_location() [](#method-i-test_source_location) - -## test_source_location_after_require() [](#method-i-test_source_location_after_require) - -## test_threaded_accessing_constant() [](#method-i-test_threaded_accessing_constant) - -## test_threaded_accessing_inner_constant() [](#method-i-test_threaded_accessing_inner_constant) - diff --git a/example/ruby/TestB.md b/example/ruby/TestB.md deleted file mode 100644 index eb0af22..0000000 --- a/example/ruby/TestB.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestB -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_nothing() [](#method-i-test_nothing) - diff --git a/example/ruby/TestBacktrace.md b/example/ruby/TestBacktrace.md deleted file mode 100644 index 8dbdd39..0000000 --- a/example/ruby/TestBacktrace.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: TestBacktrace -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## a() [](#method-c-a) -## b() [](#method-c-b) -## foo() [](#method-c-foo) -## label() [](#method-c-label) -## label_caller() [](#method-c-label_caller) - -#Instance Methods -## call_helper_test_exception_backtrace_locations() [](#method-i-call_helper_test_exception_backtrace_locations) - -## helper_test_exception_backtrace_locations() [](#method-i-helper_test_exception_backtrace_locations) - -## test_argument_error_backtrace_locations() [](#method-i-test_argument_error_backtrace_locations) - -## test_caller_lev() [](#method-i-test_caller_lev) - -## test_caller_lev_and_n() [](#method-i-test_caller_lev_and_n) - -## test_caller_limit_cfunc_iseq_no_pc() [](#method-i-test_caller_limit_cfunc_iseq_no_pc) - -## test_caller_location_inspect_cfunc_iseq_no_pc() [](#method-i-test_caller_location_inspect_cfunc_iseq_no_pc) - -## test_caller_location_path_cfunc_iseq_no_pc() [](#method-i-test_caller_location_path_cfunc_iseq_no_pc) - -## test_caller_locations() [](#method-i-test_caller_locations) - -## test_caller_locations_absolute_path() [](#method-i-test_caller_locations_absolute_path) - -## test_caller_locations_base_label() [](#method-i-test_caller_locations_base_label) - -## test_caller_locations_first_label() [](#method-i-test_caller_locations_first_label) - -## test_caller_locations_label() [](#method-i-test_caller_locations_label) - -## test_caller_locations_lineno() [](#method-i-test_caller_locations_lineno) - -## test_caller_locations_path() [](#method-i-test_caller_locations_path) - -## test_caller_locations_to_s_inspect() [](#method-i-test_caller_locations_to_s_inspect) - -## test_caller_locations_with_range() [](#method-i-test_caller_locations_with_range) - -## test_caller_to_enum() [](#method-i-test_caller_to_enum) - -## test_caller_with_limit() [](#method-i-test_caller_with_limit) - -## test_caller_with_nil_length() [](#method-i-test_caller_with_nil_length) - -## test_core_backtrace_alias() [](#method-i-test_core_backtrace_alias) - -## test_core_backtrace_hash_merge() [](#method-i-test_core_backtrace_hash_merge) - -## test_core_backtrace_undef() [](#method-i-test_core_backtrace_undef) - -## test_each_backtrace_location() [](#method-i-test_each_backtrace_location) - -## test_exception() [](#method-i-test_exception) - -## test_exception_backtrace_locations() [](#method-i-test_exception_backtrace_locations) - -## test_no_receiver_for_anonymous_class() [](#method-i-test_no_receiver_for_anonymous_class) - -## test_notty_backtrace() [](#method-i-test_notty_backtrace) - -## test_thread_backtrace() [](#method-i-test_thread_backtrace) - -## test_thread_backtrace_locations_with_range() [](#method-i-test_thread_backtrace_locations_with_range) - -## th_rec(q, n10) [](#method-i-th_rec) - diff --git a/example/ruby/TestBasicInstructions.md b/example/ruby/TestBasicInstructions.md deleted file mode 100644 index 6ef6f5c..0000000 --- a/example/ruby/TestBasicInstructions.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: TestBasicInstructions -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## do_test_const_cref() [](#method-i-do_test_const_cref) - -## do_test_const_inherit() [](#method-i-do_test_const_inherit) - -## do_test_const_path() [](#method-i-do_test_const_path) - -## set_gvar_in_another_method() [](#method-i-set_gvar_in_another_method) - -## set_lvar_in_another_method() [](#method-i-set_lvar_in_another_method) - -## test_array() [](#method-i-test_array) - -## test_array_splat() [](#method-i-test_array_splat) - -## test_backref() [](#method-i-test_backref) - -## test_class_variable() [](#method-i-test_class_variable) - -## test_const_cref() [](#method-i-test_const_cref) - -## test_const_inherit() [](#method-i-test_const_inherit) - -## test_const_path() [](#method-i-test_const_path) - -## test_dstring() [](#method-i-test_dstring) - -## test_dsym() [](#method-i-test_dsym) - -## test_global_variable() [](#method-i-test_global_variable) - -## test_hash() [](#method-i-test_hash) - -## test_immediates() [](#method-i-test_immediates) - -## test_local_variable() [](#method-i-test_local_variable) - -## test_not() [](#method-i-test_not) - -## test_opassign1_1() [](#method-i-test_opassign1_1) - -## test_opassign1_2() [](#method-i-test_opassign1_2) - -## test_opassign2_1() [](#method-i-test_opassign2_1) - -## test_opassign2_2() [](#method-i-test_opassign2_2) - -## test_opassign2_3() [](#method-i-test_opassign2_3) - -## test_range() [](#method-i-test_range) - -## test_regexp() [](#method-i-test_regexp) - -## test_self() [](#method-i-test_self) - -## test_send_opassign() [](#method-i-test_send_opassign) - -## test_special_const_instance_variables() [](#method-i-test_special_const_instance_variables) - -## test_string() [](#method-i-test_string) - -## test_xstr() [](#method-i-test_xstr) - diff --git a/example/ruby/TestBasicInstructions/CVarA.md b/example/ruby/TestBasicInstructions/CVarA.md deleted file mode 100644 index a99a0de..0000000 --- a/example/ruby/TestBasicInstructions/CVarA.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: TestBasicInstructions::CVarA -**Inherits:** Object - - - - -# Class Methods -## cv() [](#method-c-cv) -## cv2() [](#method-c-cv2) -## cv=(v ) [](#method-c-cv=) -## setup() [](#method-c-setup) - -#Instance Methods -## cv() [](#method-i-cv) - -## cv=(v) [](#method-i-cv=) - diff --git a/example/ruby/TestBasicInstructions/CVarB.md b/example/ruby/TestBasicInstructions/CVarB.md deleted file mode 100644 index 3c11662..0000000 --- a/example/ruby/TestBasicInstructions/CVarB.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestBasicInstructions::CVarB -**Inherits:** TestBasicInstructions::CVarA - - - - -# Class Methods -## cvB() [](#method-c-cvB) -## cvB2() [](#method-c-cvB2) -## cvB=(v ) [](#method-c-cvB=) - -#Instance Methods -## cvB() [](#method-i-cvB) - -## cvB=(v) [](#method-i-cvB=) - diff --git a/example/ruby/TestBasicInstructions/Const.md b/example/ruby/TestBasicInstructions/Const.md deleted file mode 100644 index 5eadb1a..0000000 --- a/example/ruby/TestBasicInstructions/Const.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestBasicInstructions::Const -**Inherits:** Object - - - - -# Class Methods -## c() [](#method-c-c) - -#Instance Methods -## c() [](#method-i-c) - diff --git a/example/ruby/TestBasicInstructions/Const/A.md b/example/ruby/TestBasicInstructions/Const/A.md deleted file mode 100644 index 30e3df1..0000000 --- a/example/ruby/TestBasicInstructions/Const/A.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: TestBasicInstructions::Const::A -**Inherits:** Object - - - - -# Class Methods -## c() [](#method-c-c) -## cc() [](#method-c-cc) - -#Instance Methods -## c() [](#method-i-c) - -## cc() [](#method-i-cc) - diff --git a/example/ruby/TestBasicInstructions/Const/A/B.md b/example/ruby/TestBasicInstructions/Const/A/B.md deleted file mode 100644 index 4334036..0000000 --- a/example/ruby/TestBasicInstructions/Const/A/B.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: TestBasicInstructions::Const::A::B -**Inherits:** Object - - - - -# Class Methods -## c() [](#method-c-c) -## cc() [](#method-c-cc) - -#Instance Methods -## c() [](#method-i-c) - -## cc() [](#method-i-cc) - diff --git a/example/ruby/TestBasicInstructions/Const/AA.md b/example/ruby/TestBasicInstructions/Const/AA.md deleted file mode 100644 index 00c0da8..0000000 --- a/example/ruby/TestBasicInstructions/Const/AA.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestBasicInstructions::Const::AA -**Inherits:** TestBasicInstructions::Const::A - - - - -# Class Methods -## cc() [](#method-c-cc) - -#Instance Methods -## cc() [](#method-i-cc) - diff --git a/example/ruby/TestBasicInstructions/Const/AAA.md b/example/ruby/TestBasicInstructions/Const/AAA.md deleted file mode 100644 index 816ae2f..0000000 --- a/example/ruby/TestBasicInstructions/Const/AAA.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestBasicInstructions::Const::AAA -**Inherits:** TestBasicInstructions::Const::AA - - - - -# Class Methods -## cc() [](#method-c-cc) - -#Instance Methods -## cc() [](#method-i-cc) - diff --git a/example/ruby/TestBasicInstructions/OP.md b/example/ruby/TestBasicInstructions/OP.md deleted file mode 100644 index 1fdc287..0000000 --- a/example/ruby/TestBasicInstructions/OP.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: TestBasicInstructions::OP -**Inherits:** Object - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - -## x[RW] [](#attribute-i-x) -Returns the value of attribute x. - - -#Instance Methods -## [](i) [](#method-i-[]) - -## []=(i, x) [](#method-i-[]=) - diff --git a/example/ruby/TestBeginEndBlock.md b/example/ruby/TestBeginEndBlock.md deleted file mode 100644 index 083ce01..0000000 --- a/example/ruby/TestBeginEndBlock.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestBeginEndBlock -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_beginendblock() [](#method-i-test_beginendblock) - -## test_begininclass() [](#method-i-test_begininclass) - -## test_begininmethod() [](#method-i-test_begininmethod) - -## test_callcc_at_exit() [](#method-i-test_callcc_at_exit) - -## test_endblock_raise() [](#method-i-test_endblock_raise) - -## test_endblock_variable() [](#method-i-test_endblock_variable) - -## test_endblockwarn() [](#method-i-test_endblockwarn) - -## test_endblockwarn_in_eval() [](#method-i-test_endblockwarn_in_eval) - -## test_errinfo_at_exit() [](#method-i-test_errinfo_at_exit) - -## test_exitcode_in_at_exit() [](#method-i-test_exitcode_in_at_exit) - -## test_internal_errinfo_at_exit() [](#method-i-test_internal_errinfo_at_exit) - -## test_nested_at_exit() [](#method-i-test_nested_at_exit) - -## test_propagate_exit_code() [](#method-i-test_propagate_exit_code) - -## test_propagate_signaled() [](#method-i-test_propagate_signaled) - -## test_raise_in_at_exit() [](#method-i-test_raise_in_at_exit) - -## test_rescue_at_exit() [](#method-i-test_rescue_at_exit) - diff --git a/example/ruby/TestBenchmark.md b/example/ruby/TestBenchmark.md deleted file mode 100644 index ce3b102..0000000 --- a/example/ruby/TestBenchmark.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: TestBenchmark -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## bench(type:bm, *args, &block) [](#method-i-bench) - -## capture_bench_output(type, *args, &block) [](#method-i-capture_bench_output) - -## labels() [](#method-i-labels) - -## test_benchmark_does_not_print_any_space_if_the_given_caption_is_empty() [](#method-i-test_benchmark_does_not_print_any_space_if_the_given_caption_is_empty) - -## test_benchmark_makes_extra_calculations_with_an_Array_at_the_end_of_the_benchmark_and_show_the_result() [](#method-i-test_benchmark_makes_extra_calculations_with_an_Array_at_the_end_of_the_benchmark_and_show_the_result) - -## test_bm_can_make_extra_calcultations_with_an_array_at_the_end_of_the_benchmark() [](#method-i-test_bm_can_make_extra_calcultations_with_an_array_at_the_end_of_the_benchmark) - -## test_bm_correctly_output_when_no_label_is_given() [](#method-i-test_bm_correctly_output_when_no_label_is_given) - -## test_bm_correctly_output_when_the_label_width_is_given() [](#method-i-test_bm_correctly_output_when_the_label_width_is_given) - -## test_bm_returns_an_Array_of_the_times_with_the_labels() [](#method-i-test_bm_returns_an_Array_of_the_times_with_the_labels) - -## test_bmbm_correctly_guess_the_label_width_even_when_not_given() [](#method-i-test_bmbm_correctly_guess_the_label_width_even_when_not_given) - -## test_bmbm_correctly_output_when_the_label_width_is_given__bmbm_ignore_it__but_it_is_a_frequent_mistake() [](#method-i-test_bmbm_correctly_output_when_the_label_width_is_given__bmbm_ignore_it__but_it_is_a_frequent_mistake) - -## test_bugs_ruby_dev_40906_can_add_in_place_the_time_of_execution_of_the_block_given() [](#method-i-test_bugs_ruby_dev_40906_can_add_in_place_the_time_of_execution_of_the_block_given) - -## test_realtime_output() [](#method-i-test_realtime_output) - -## test_report_item_shows_the_title__even_if_not_a_string() [](#method-i-test_report_item_shows_the_title__even_if_not_a_string) - -## test_tms_outputs_nicely() [](#method-i-test_tms_outputs_nicely) - -## test_tms_to_h() [](#method-i-test_tms_to_h) -Test that `to_h` returns a hash with the expected data. - -## test_tms_wont_modify_the_format_String_given() [](#method-i-test_tms_wont_modify_the_format_String_given) - diff --git a/example/ruby/TestBig5.md b/example/ruby/TestBig5.md deleted file mode 100644 index 4d7dae2..0000000 --- a/example/ruby/TestBig5.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestBig5 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## s(s) [](#method-i-s) - -## test_code_to_mbc() [](#method-i-test_code_to_mbc) - -## test_left_adjust_char_head() [](#method-i-test_left_adjust_char_head) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_mbc_enc_len() [](#method-i-test_mbc_enc_len) - -## test_mbc_to_code() [](#method-i-test_mbc_to_code) - diff --git a/example/ruby/TestBignum_Big2str.md b/example/ruby/TestBignum_Big2str.md deleted file mode 100644 index a2aefeb..0000000 --- a/example/ruby/TestBignum_Big2str.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestBignum_Big2str -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_big2str_generic() [](#method-i-test_big2str_generic) - -## test_big2str_gmp() [](#method-i-test_big2str_gmp) - -## test_big2str_poweroftwo() [](#method-i-test_big2str_poweroftwo) - diff --git a/example/ruby/TestBignum_BigZero.md b/example/ruby/TestBignum_BigZero.md deleted file mode 100644 index c50dd63..0000000 --- a/example/ruby/TestBignum_BigZero.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestBignum_BigZero -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_equal_0() [](#method-i-test_equal_0) - -## test_zero?() [](#method-i-test_zero?) - -**@return** [Boolean] - diff --git a/example/ruby/TestBignum_Div.md b/example/ruby/TestBignum_Div.md deleted file mode 100644 index 8ce3650..0000000 --- a/example/ruby/TestBignum_Div.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestBignum_Div -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_divrem_gmp() [](#method-i-test_divrem_gmp) - -## test_divrem_normal() [](#method-i-test_divrem_normal) - diff --git a/example/ruby/TestBignum_Mul.md b/example/ruby/TestBignum_Mul.md deleted file mode 100644 index 9f0bff9..0000000 --- a/example/ruby/TestBignum_Mul.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: TestBignum_Mul -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_mul_balance() [](#method-i-test_mul_balance) - -## test_mul_balance_2x16() [](#method-i-test_mul_balance_2x16) - -## test_mul_balance_2x17() [](#method-i-test_mul_balance_2x17) - -## test_mul_gmp() [](#method-i-test_mul_gmp) - -## test_mul_karatsuba() [](#method-i-test_mul_karatsuba) - -## test_mul_karatsuba_borrow() [](#method-i-test_mul_karatsuba_borrow) - -## test_mul_karatsuba_carry2() [](#method-i-test_mul_karatsuba_carry2) - -## test_mul_karatsuba_odd_xy() [](#method-i-test_mul_karatsuba_odd_xy) - -## test_mul_karatsuba_odd_y() [](#method-i-test_mul_karatsuba_odd_y) - -## test_mul_karatsuba_x1_gt_x0() [](#method-i-test_mul_karatsuba_x1_gt_x0) - -## test_mul_karatsuba_x1_gt_x0_and_y1_gt_y0() [](#method-i-test_mul_karatsuba_x1_gt_x0_and_y1_gt_y0) - -## test_mul_karatsuba_y1_gt_y0() [](#method-i-test_mul_karatsuba_y1_gt_y0) - -## test_mul_normal() [](#method-i-test_mul_normal) - -## test_mul_normal_max_max() [](#method-i-test_mul_normal_max_max) - -## test_mul_normal_zero_in_x() [](#method-i-test_mul_normal_zero_in_x) - -## test_mul_normal_zero_in_y() [](#method-i-test_mul_normal_zero_in_y) - -## test_mul_toom3() [](#method-i-test_mul_toom3) - -## test_sq_fast() [](#method-i-test_sq_fast) - -## test_sq_fast_max2() [](#method-i-test_sq_fast_max2) - -## test_sq_fast_zero_in_middle() [](#method-i-test_sq_fast_zero_in_middle) - diff --git a/example/ruby/TestBignum_Pack.md b/example/ruby/TestBignum_Pack.md deleted file mode 100644 index 4414eba..0000000 --- a/example/ruby/TestBignum_Pack.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: TestBignum_Pack -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_numbits_2comp() [](#method-i-test_numbits_2comp) - -## test_numbytes_2comp() [](#method-i-test_numbytes_2comp) - -## test_pack2comp_emptybuf() [](#method-i-test_pack2comp_emptybuf) - -## test_pack2comp_nearly_zero() [](#method-i-test_pack2comp_nearly_zero) - -## test_pack2comp_overflow() [](#method-i-test_pack2comp_overflow) - -## test_pack2comp_zero() [](#method-i-test_pack2comp_zero) - -## test_pack_argument_check() [](#method-i-test_pack_argument_check) - -## test_pack_fixed_buffer() [](#method-i-test_pack_fixed_buffer) - -## test_pack_nail() [](#method-i-test_pack_nail) - -## test_pack_native_endian() [](#method-i-test_pack_native_endian) - -## test_pack_orders() [](#method-i-test_pack_orders) - -## test_pack_overflow() [](#method-i-test_pack_overflow) - -## test_pack_sign() [](#method-i-test_pack_sign) - -## test_pack_wordorder_and_endian() [](#method-i-test_pack_wordorder_and_endian) - -## test_pack_wordsize() [](#method-i-test_pack_wordsize) - -## test_pack_zero() [](#method-i-test_pack_zero) - -## test_unpack2comp_negative_single_byte() [](#method-i-test_unpack2comp_negative_single_byte) - -## test_unpack2comp_negative_zero() [](#method-i-test_unpack2comp_negative_zero) - -## test_unpack2comp_sequence_of_ff() [](#method-i-test_unpack2comp_sequence_of_ff) - -## test_unpack2comp_single_byte() [](#method-i-test_unpack2comp_single_byte) - -## test_unpack_argument_check() [](#method-i-test_unpack_argument_check) - -## test_unpack_nail() [](#method-i-test_unpack_nail) - -## test_unpack_native_endian() [](#method-i-test_unpack_native_endian) - -## test_unpack_orders() [](#method-i-test_unpack_orders) - -## test_unpack_sign() [](#method-i-test_unpack_sign) - -## test_unpack_wordorder_and_endian() [](#method-i-test_unpack_wordorder_and_endian) - -## test_unpack_wordsize() [](#method-i-test_unpack_wordsize) - -## test_unpack_zero() [](#method-i-test_unpack_zero) - diff --git a/example/ruby/TestBignum_Str2big.md b/example/ruby/TestBignum_Str2big.md deleted file mode 100644 index ca13e56..0000000 --- a/example/ruby/TestBignum_Str2big.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestBignum_Str2big -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_str2big_gmp() [](#method-i-test_str2big_gmp) - -## test_str2big_karatsuba() [](#method-i-test_str2big_karatsuba) - -## test_str2big_normal() [](#method-i-test_str2big_normal) - -## test_str2big_poweroftwo() [](#method-i-test_str2big_poweroftwo) - diff --git a/example/ruby/TestBugReporter.md b/example/ruby/TestBugReporter.md deleted file mode 100644 index 80b669b..0000000 --- a/example/ruby/TestBugReporter.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestBugReporter -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_bug_reporter_add() [](#method-i-test_bug_reporter_add) - diff --git a/example/ruby/TestBundlerGem.md b/example/ruby/TestBundlerGem.md deleted file mode 100644 index a9f616f..0000000 --- a/example/ruby/TestBundlerGem.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: TestBundlerGem -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_auto_activation_of_specific_gemdeps_file() [](#method-i-test_auto_activation_of_specific_gemdeps_file) - -## test_auto_activation_of_used_gemdeps_file() [](#method-i-test_auto_activation_of_used_gemdeps_file) - -## test_looks_for_gemdeps_files_automatically_from_binstubs() [](#method-i-test_looks_for_gemdeps_files_automatically_from_binstubs) - -## test_looks_for_gemdeps_files_automatically_from_binstubs_in_parent_dir() [](#method-i-test_looks_for_gemdeps_files_automatically_from_binstubs_in_parent_dir) - -## test_no_warning_warning() [](#method-i-test_no_warning_warning) - -## test_self_find_files_with_gemfile() [](#method-i-test_self_find_files_with_gemfile) - -## test_self_use_gemdeps() [](#method-i-test_self_use_gemdeps) - -## test_use_gemdeps() [](#method-i-test_use_gemdeps) - -## test_use_gemdeps_ENV() [](#method-i-test_use_gemdeps_ENV) - -## test_use_gemdeps_argument_missing() [](#method-i-test_use_gemdeps_argument_missing) - -## test_use_gemdeps_argument_missing_match_ENV() [](#method-i-test_use_gemdeps_argument_missing_match_ENV) - -## test_use_gemdeps_automatic() [](#method-i-test_use_gemdeps_automatic) - -## test_use_gemdeps_automatic_missing() [](#method-i-test_use_gemdeps_automatic_missing) - -## test_use_gemdeps_disabled() [](#method-i-test_use_gemdeps_disabled) - -## test_use_gemdeps_missing_gem() [](#method-i-test_use_gemdeps_missing_gem) - -## test_use_gemdeps_specific() [](#method-i-test_use_gemdeps_specific) - -## test_warning() [](#method-i-test_warning) - -## test_warning_archdir() [](#method-i-test_warning_archdir) - -## test_warning_libdir() [](#method-i-test_warning_libdir) - diff --git a/example/ruby/TestC.md b/example/ruby/TestC.md deleted file mode 100644 index 714e506..0000000 --- a/example/ruby/TestC.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestC -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_nothing() [](#method-i-test_nothing) - diff --git a/example/ruby/TestCESU8.md b/example/ruby/TestCESU8.md deleted file mode 100644 index d8adab6..0000000 --- a/example/ruby/TestCESU8.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: TestCESU8 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_str_equal(expected, actual, messagenil) [](#method-i-assert_str_equal) - -## enccall(recv, meth, *args) [](#method-i-enccall) - -## encdump(obj) [](#method-i-encdump) - -## test_cesu8_left_adjust_char_head() [](#method-i-test_cesu8_left_adjust_char_head) - -## test_cesu8_ord() [](#method-i-test_cesu8_ord) - -## test_cesu8_valid_encoding() [](#method-i-test_cesu8_valid_encoding) -tests start - diff --git a/example/ruby/TestCP949.md b/example/ruby/TestCP949.md deleted file mode 100644 index cd1b06b..0000000 --- a/example/ruby/TestCP949.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestCP949 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## s(s) [](#method-i-s) - -## test_code_to_mbc() [](#method-i-test_code_to_mbc) - -## test_left_adjust_char_head() [](#method-i-test_left_adjust_char_head) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_mbc_enc_len() [](#method-i-test_mbc_enc_len) - -## test_mbc_to_code() [](#method-i-test_mbc_to_code) - diff --git a/example/ruby/TestCall.md b/example/ruby/TestCall.md deleted file mode 100644 index f4e94a9..0000000 --- a/example/ruby/TestCall.md +++ /dev/null @@ -1,187 +0,0 @@ -# Class: TestCall -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## a(*a ) [](#method-c-a) -**@yield** [OVER_STACK_ARGV] - -## b(_ , *a ) [](#method-c-b) -## c(_ , *a , _ ) [](#method-c-c) -## d(b 1, *a ) [](#method-c-d) -## e(b 1, *a , _ ) [](#method-c-e) -## f(b , *a ) [](#method-c-f) -## g(*a , k: 1) [](#method-c-g) -## h(*a , **kw ) [](#method-c-h) -## i(*a , k: 1, **kw ) [](#method-c-i) -## j(b 1, *a , k: 1) [](#method-c-j) -## k(b 1, *a , **kw ) [](#method-c-k) -## l(b 1, *a , k: 1, **kw ) [](#method-c-l) -## m(b 1, *a , _ , k: 1) [](#method-c-m) -## method_missing(m , *a ) [](#method-c-method_missing) -## n(b 1, *a , _ , **kw ) [](#method-c-n) -## o(b 1, *a , _ , k: 1, **kw ) [](#method-c-o) -## t(splat ) [](#method-c-t) - -#Instance Methods -## a() [](#method-i-a) -These dummy method definitions prevent warnings "the block passed to 'a'..." - -## aaa(a, b100, *rest) [](#method-i-aaa) - -## b() [](#method-i-b) - -## c() [](#method-i-c) - -## d() [](#method-i-d) - -## e() [](#method-i-e) - -## f() [](#method-i-f) - -## g() [](#method-i-g) - -## h() [](#method-i-h) - -## i() [](#method-i-i) - -## j() [](#method-i-j) - -## k() [](#method-i-k) - -## l() [](#method-i-l) - -## m() [](#method-i-m) - -## n() [](#method-i-n) - -## o() [](#method-i-o) - -## test_call() [](#method-i-test_call) - -## test_call_alias_large_array_splat() [](#method-i-test_call_alias_large_array_splat) - -## test_call_args_splat_with_nonhash_keyword_splat() [](#method-i-test_call_args_splat_with_nonhash_keyword_splat) - -## test_call_args_splat_with_pos_arg_kw_splat_is_not_mutable() [](#method-i-test_call_args_splat_with_pos_arg_kw_splat_is_not_mutable) - -## test_call_attr_reader_large_array_splat_fail() [](#method-i-test_call_attr_reader_large_array_splat_fail) - -## test_call_attr_writer_large_array_splat_fail() [](#method-i-test_call_attr_writer_large_array_splat_fail) - -## test_call_bmethod_large_array_splat_fail() [](#method-i-test_call_bmethod_large_array_splat_fail) - -## test_call_bmethod_large_array_splat_pass() [](#method-i-test_call_bmethod_large_array_splat_pass) - -## test_call_bmethod_proc() [](#method-i-test_call_bmethod_proc) - -## test_call_bmethod_proc_restarg() [](#method-i-test_call_bmethod_proc_restarg) - -## test_call_cfunc_splat_large_array_bug_4040() [](#method-i-test_call_cfunc_splat_large_array_bug_4040) - -## test_call_ifunc_iseq_large_array_splat_fail() [](#method-i-test_call_ifunc_iseq_large_array_splat_fail) - -## test_call_ifunc_iseq_large_array_splat_pass() [](#method-i-test_call_ifunc_iseq_large_array_splat_pass) - -## test_call_iseq_large_array_splat_fail() [](#method-i-test_call_iseq_large_array_splat_fail) - -## test_call_iseq_large_array_splat_pass() [](#method-i-test_call_iseq_large_array_splat_pass) - -## test_call_iseq_large_array_splat_with_large_number_of_parameters() [](#method-i-test_call_iseq_large_array_splat_with_large_number_of_parameters) - -## test_call_lambda_large_array_splat_fail() [](#method-i-test_call_lambda_large_array_splat_fail) - -## test_call_lambda_large_array_splat_pass() [](#method-i-test_call_lambda_large_array_splat_pass) - -## test_call_method_missing_bmethod_large_array_splat_fail() [](#method-i-test_call_method_missing_bmethod_large_array_splat_fail) - -## test_call_method_missing_bmethod_large_array_splat_pass() [](#method-i-test_call_method_missing_bmethod_large_array_splat_pass) - -## test_call_method_missing_iseq_large_array_splat_fail() [](#method-i-test_call_method_missing_iseq_large_array_splat_fail) - -## test_call_method_missing_iseq_large_array_splat_pass() [](#method-i-test_call_method_missing_iseq_large_array_splat_pass) - -## test_call_op_asgn_keywords() [](#method-i-test_call_op_asgn_keywords) - -## test_call_op_asgn_keywords_mutable() [](#method-i-test_call_op_asgn_keywords_mutable) - -## test_call_proc_large_array_splat_pass() [](#method-i-test_call_proc_large_array_splat_pass) - -## test_call_proc_large_array_splat_with_large_number_of_parameters() [](#method-i-test_call_proc_large_array_splat_with_large_number_of_parameters) - -## test_call_rb_call_bmethod_large_array_splat_fail() [](#method-i-test_call_rb_call_bmethod_large_array_splat_fail) - -## test_call_rb_call_bmethod_large_array_splat_pass() [](#method-i-test_call_rb_call_bmethod_large_array_splat_pass) - -## test_call_rb_call_iseq_large_array_splat_fail() [](#method-i-test_call_rb_call_iseq_large_array_splat_fail) - -## test_call_rb_call_iseq_large_array_splat_pass() [](#method-i-test_call_rb_call_iseq_large_array_splat_pass) - -## test_call_refined_large_array_splat_fail() [](#method-i-test_call_refined_large_array_splat_fail) - -## test_call_refined_large_array_splat_pass() [](#method-i-test_call_refined_large_array_splat_pass) - -## test_call_send_cfunc_large_array_splat_fail() [](#method-i-test_call_send_cfunc_large_array_splat_fail) - -## test_call_send_cfunc_large_array_splat_pass() [](#method-i-test_call_send_cfunc_large_array_splat_pass) - -## test_call_send_iseq_large_array_splat_fail() [](#method-i-test_call_send_iseq_large_array_splat_fail) - -## test_call_send_iseq_large_array_splat_pass() [](#method-i-test_call_send_iseq_large_array_splat_pass) - -## test_call_send_iseq_large_array_splat_with_large_number_of_parameters() [](#method-i-test_call_send_iseq_large_array_splat_with_large_number_of_parameters) - -## test_call_splat_block_order() [](#method-i-test_call_splat_block_order) - -## test_call_splat_kw_order() [](#method-i-test_call_splat_kw_order) - -## test_call_splat_kw_splat_order() [](#method-i-test_call_splat_kw_splat_order) - -## test_call_splat_post_order() [](#method-i-test_call_splat_post_order) - -## test_call_struct_aref_large_array_splat_fail() [](#method-i-test_call_struct_aref_large_array_splat_fail) - -## test_call_struct_aset_large_array_splat_fail() [](#method-i-test_call_struct_aset_large_array_splat_fail) - -## test_call_symproc_large_array_splat_fail() [](#method-i-test_call_symproc_large_array_splat_fail) - -## test_call_symproc_large_array_splat_pass() [](#method-i-test_call_symproc_large_array_splat_pass) - -## test_call_yield_block_large_array_splat_pass() [](#method-i-test_call_yield_block_large_array_splat_pass) - -## test_call_yield_lambda_large_array_splat_fail() [](#method-i-test_call_yield_lambda_large_array_splat_fail) - -## test_call_yield_lambda_large_array_splat_pass() [](#method-i-test_call_yield_lambda_large_array_splat_pass) - -## test_call_yield_large_array_splat_with_large_number_of_parameters() [](#method-i-test_call_yield_large_array_splat_with_large_number_of_parameters) - -## test_call_zsuper_large_array_splat() [](#method-i-test_call_zsuper_large_array_splat) - -## test_callinfo() [](#method-i-test_callinfo) - -## test_frozen_splat_and_keywords() [](#method-i-test_frozen_splat_and_keywords) - -## test_invalid_safe_call() [](#method-i-test_invalid_safe_call) - -## test_kwsplat_block_eval_order() [](#method-i-test_kwsplat_block_eval_order) - -## test_kwsplat_block_order() [](#method-i-test_kwsplat_block_order) - -## test_kwsplat_block_order_op_asgn() [](#method-i-test_kwsplat_block_order_op_asgn) - -## test_kwsplat_block_order_super() [](#method-i-test_kwsplat_block_order_super) - -## test_safe_call() [](#method-i-test_safe_call) - -## test_safe_call_block_call() [](#method-i-test_safe_call_block_call) - -## test_safe_call_block_call_brace() [](#method-i-test_safe_call_block_call_brace) - -## test_safe_call_block_call_command() [](#method-i-test_safe_call_block_call_command) - -## test_safe_call_block_command() [](#method-i-test_safe_call_block_command) - -## test_safe_call_evaluate_arguments_only_method_call_is_made() [](#method-i-test_safe_call_evaluate_arguments_only_method_call_is_made) - diff --git a/example/ruby/TestCall/RefinedModuleLargeArrayTest.md b/example/ruby/TestCall/RefinedModuleLargeArrayTest.md deleted file mode 100644 index 65d5781..0000000 --- a/example/ruby/TestCall/RefinedModuleLargeArrayTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestCall::RefinedModuleLargeArrayTest -**Inherits:** Object - - - - - -#Instance Methods -## b() [](#method-i-b) - -## d() [](#method-i-d) - -## f() [](#method-i-f) - diff --git a/example/ruby/TestCase.md b/example/ruby/TestCase.md deleted file mode 100644 index 8e46ff0..0000000 --- a/example/ruby/TestCase.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestCase -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_case() [](#method-i-test_case) - -## test_deoptimization() [](#method-i-test_deoptimization) - -## test_deoptimize_nil() [](#method-i-test_deoptimize_nil) - -## test_method_missing() [](#method-i-test_method_missing) - -## test_nomethoderror() [](#method-i-test_nomethoderror) - -## test_optimization() [](#method-i-test_optimization) - diff --git a/example/ruby/TestCase/NilEqq.md b/example/ruby/TestCase/NilEqq.md deleted file mode 100644 index 3a045c3..0000000 --- a/example/ruby/TestCase/NilEqq.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestCase::NilEqq - - - - - diff --git a/example/ruby/TestCase/NilEqqClass.md b/example/ruby/TestCase/NilEqqClass.md deleted file mode 100644 index c6ab091..0000000 --- a/example/ruby/TestCase/NilEqqClass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestCase::NilEqqClass -**Inherits:** Object - - - - - -#Instance Methods -## eqq(a) [](#method-i-eqq) - diff --git a/example/ruby/TestCaseFold.md b/example/ruby/TestCaseFold.md deleted file mode 100644 index 4d0f334..0000000 --- a/example/ruby/TestCaseFold.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestCaseFold -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## generate_test_casefold(encoding ) [](#method-c-generate_test_casefold) - -#Instance Methods -## check_downcase_properties(expected, start, *flags) [](#method-i-check_downcase_properties) - -## read_tests() [](#method-i-read_tests) - -## setup() [](#method-i-setup) - -## test_downcase_fold() [](#method-i-test_downcase_fold) - -## to_codepoints(string) [](#method-i-to_codepoints) - diff --git a/example/ruby/TestCaseFold/CaseTest.md b/example/ruby/TestCaseFold/CaseTest.md deleted file mode 100644 index a8f7799..0000000 --- a/example/ruby/TestCaseFold/CaseTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestCaseFold::CaseTest -**Inherits:** Struct - - - - -# Attributes -## kind[RW] [](#attribute-i-kind) -Returns the value of attribute kind - -**@return** [Object] the current value of kind - -## line[RW] [](#attribute-i-line) -Returns the value of attribute line - -**@return** [Object] the current value of line - -## source[RW] [](#attribute-i-source) -Returns the value of attribute source - -**@return** [Object] the current value of source - -## target[RW] [](#attribute-i-target) -Returns the value of attribute target - -**@return** [Object] the current value of target - - diff --git a/example/ruby/TestCaseForDict.md b/example/ruby/TestCaseForDict.md deleted file mode 100644 index 1a4d37c..0000000 --- a/example/ruby/TestCaseForDict.md +++ /dev/null @@ -1,43 +0,0 @@ -# Module: TestCaseForDict - - - - - -#Instance Methods -## test_add() [](#method-i-test_add) - -## test_bracket() [](#method-i-test_bracket) - -## test_bracket_equal() [](#method-i-test_bracket_equal) - -## test_bracket_with_numkey() [](#method-i-test_bracket_with_numkey) - -## test_convert_bignum() [](#method-i-test_convert_bignum) - -## test_each() [](#method-i-test_each) - -## test_invoke_with_array() [](#method-i-test_invoke_with_array) - -## test_methods() [](#method-i-test_methods) - -## test_no_method_error() [](#method-i-test_no_method_error) - -## test_non_exist_property() [](#method-i-test_non_exist_property) - -## test_ole_func_methods() [](#method-i-test_ole_func_methods) - -## test_ole_get_methods() [](#method-i-test_ole_get_methods) - -## test_ole_method_help() [](#method-i-test_ole_method_help) - -## test_ole_methods() [](#method-i-test_ole_methods) - -## test_ole_put_methods() [](#method-i-test_ole_put_methods) - -## test_ole_typelib() [](#method-i-test_ole_typelib) - -## test_raise_message() [](#method-i-test_raise_message) - -## test_setproperty_equal_ended() [](#method-i-test_setproperty_equal_ended) - diff --git a/example/ruby/TestCaseMappingPreliminary.md b/example/ruby/TestCaseMappingPreliminary.md deleted file mode 100644 index c8e360f..0000000 --- a/example/ruby/TestCaseMappingPreliminary.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: TestCaseMappingPreliminary -**Inherits:** Test::Unit::TestCase - - -preliminary tests, using as a guard to test new implementation strategy - - - -#Instance Methods -## check_capitalize_properties(expected, start, *flags) [](#method-i-check_capitalize_properties) - -## check_capitalize_suffixes(lower, upper) [](#method-i-check_capitalize_suffixes) - -## check_downcase_properties(expected, start, *flags) [](#method-i-check_downcase_properties) - -## check_swapcase_properties(expected, start, *flags) [](#method-i-check_swapcase_properties) -different properties; careful: roundtrip isn't always guaranteed - -## check_upcase_properties(expected, start, *flags) [](#method-i-check_upcase_properties) -checks, including idempotence and non-modification; not always guaranteed - -## no_longer_a_test_buffer_allocations() [](#method-i-no_longer_a_test_buffer_allocations) - -## test_ascii() [](#method-i-test_ascii) - -## test_ascii_option() [](#method-i-test_ascii_option) - -## test_cherokee() [](#method-i-test_cherokee) - -## test_fold_option() [](#method-i-test_fold_option) - -## test_general() [](#method-i-test_general) - -## test_georgian_canary() [](#method-i-test_georgian_canary) - -## test_georgian_capitalize() [](#method-i-test_georgian_capitalize) - -## test_georgian_unassigned() [](#method-i-test_georgian_unassigned) - -## test_greek() [](#method-i-test_greek) - -## test_invalid() [](#method-i-test_invalid) - -## test_one_way_upcase() [](#method-i-test_one_way_upcase) - -## test_reorder_unfold() [](#method-i-test_reorder_unfold) -This test checks against problems when changing the order of mapping results -in some of the entries of the unfolding table (related to -https://bugs.ruby-lang.org/issues/12990). - -## test_shift_jis_downcase_ascii() [](#method-i-test_shift_jis_downcase_ascii) - -## test_shift_jis_upcase_ascii() [](#method-i-test_shift_jis_upcase_ascii) - -## test_swapcase() [](#method-i-test_swapcase) - -## test_titlecase() [](#method-i-test_titlecase) - -## test_turcic() [](#method-i-test_turcic) - -## test_various() [](#method-i-test_various) - diff --git a/example/ruby/TestCaseOptions.md b/example/ruby/TestCaseOptions.md deleted file mode 100644 index 1c382fb..0000000 --- a/example/ruby/TestCaseOptions.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: TestCaseOptions -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_okay_bang_operations(arg, *options) [](#method-i-assert_okay_bang_operations) - -## assert_okay_both_types(*options) [](#method-i-assert_okay_both_types) - -## assert_okay_functional_operations(arg, *options) [](#method-i-assert_okay_functional_operations) - -## assert_raise_bang_operations(arg, *options) [](#method-i-assert_raise_bang_operations) - -## assert_raise_both_types(*options) [](#method-i-assert_raise_both_types) - -## assert_raise_functional_operations(arg, *options) [](#method-i-assert_raise_functional_operations) - -## test_operation_specific() [](#method-i-test_operation_specific) -:fold option only allowed on downcase - -## test_option_errors() [](#method-i-test_option_errors) - -## test_options_okay() [](#method-i-test_options_okay) - diff --git a/example/ruby/TestCiDetector.md b/example/ruby/TestCiDetector.md deleted file mode 100644 index e08a2eb..0000000 --- a/example/ruby/TestCiDetector.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestCiDetector -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_ci?() [](#method-i-test_ci?) - -**@return** [Boolean] - -## test_ci_strings() [](#method-i-test_ci_strings) - diff --git a/example/ruby/TestClass.md b/example/ruby/TestClass.md deleted file mode 100644 index 0671d42..0000000 --- a/example/ruby/TestClass.md +++ /dev/null @@ -1,121 +0,0 @@ -# Class: TestClass -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_00_new_basic() [](#method-i-test_00_new_basic) - -## test_01_new_inherited() [](#method-i-test_01_new_inherited) - -## test_append_features() [](#method-i-test_append_features) - -## test_assign_frozen_class_to_const() [](#method-i-test_assign_frozen_class_to_const) - -## test_attached_object() [](#method-i-test_attached_object) - -## test_cannot_reinitialize_class_with_initialize_copy() [](#method-i-test_cannot_reinitialize_class_with_initialize_copy) -ruby-core:50869 -: - -## test_check_inheritable() [](#method-i-test_check_inheritable) - -## test_class_cmp() [](#method-i-test_class_cmp) - -## test_class_initialize() [](#method-i-test_class_initialize) - -## test_classext_memory_leak() [](#method-i-test_classext_memory_leak) - -## test_clone() [](#method-i-test_clone) - -## test_clone_singleton_class_exists() [](#method-i-test_clone_singleton_class_exists) - -## test_clone_when_method_exists_on_singleton_class_of_singleton_class() [](#method-i-test_clone_when_method_exists_on_singleton_class_of_singleton_class) - -## test_clone_when_singleton_class_of_singleton_class_exists() [](#method-i-test_clone_when_singleton_class_of_singleton_class_exists) - -## test_cloned_class() [](#method-i-test_cloned_class) - -## test_cloned_singleton_method_added() [](#method-i-test_cloned_singleton_method_added) - -## test_constant_access_from_method_in_cloned_class() [](#method-i-test_constant_access_from_method_in_cloned_class) - -## test_extend_object() [](#method-i-test_extend_object) - -## test_freeze_to_s() [](#method-i-test_freeze_to_s) - -## test_initialize_copy() [](#method-i-test_initialize_copy) - -## test_instance_freeze_dont_freeze_the_class_bug_19164() [](#method-i-test_instance_freeze_dont_freeze_the_class_bug_19164) - -## test_instantiate_singleton_class() [](#method-i-test_instantiate_singleton_class) - -## test_invalid_break_from_class_definition() [](#method-i-test_invalid_break_from_class_definition) - -## test_invalid_next_from_class_definition() [](#method-i-test_invalid_next_from_class_definition) - -## test_invalid_redo_from_class_definition() [](#method-i-test_invalid_redo_from_class_definition) - -## test_invalid_retry_from_class_definition() [](#method-i-test_invalid_retry_from_class_definition) - -## test_invalid_return_from_class_definition() [](#method-i-test_invalid_return_from_class_definition) - -## test_invalid_superclass() [](#method-i-test_invalid_superclass) - -## test_invalid_yield_from_class_definition() [](#method-i-test_invalid_yield_from_class_definition) - -## test_method_redefinition() [](#method-i-test_method_redefinition) - -## test_module_function() [](#method-i-test_module_function) - -## test_module_specific_methods() [](#method-i-test_module_specific_methods) - -## test_namescope_error_message() [](#method-i-test_namescope_error_message) - -## test_nested_class_removal() [](#method-i-test_nested_class_removal) - -## test_nonascii_name() [](#method-i-test_nonascii_name) - -## test_prepend_features() [](#method-i-test_prepend_features) - -## test_private_const_access() [](#method-i-test_private_const_access) - -## test_redefine_private_class() [](#method-i-test_redefine_private_class) - -## test_redefinition_mismatch() [](#method-i-test_redefinition_mismatch) - -## test_s_inherited() [](#method-i-test_s_inherited) ---- -Start of tests ---- - -## test_s_new() [](#method-i-test_s_new) - -## test_should_not_expose_singleton_class_without_metaclass() [](#method-i-test_should_not_expose_singleton_class_without_metaclass) - -## test_singleton_class() [](#method-i-test_singleton_class) - -## test_singleton_class_message() [](#method-i-test_singleton_class_message) - -## test_singleton_class_of_frozen_object() [](#method-i-test_singleton_class_of_frozen_object) - -## test_singleton_class_p() [](#method-i-test_singleton_class_p) - -## test_singleton_class_should_has_own_namespace() [](#method-i-test_singleton_class_should_has_own_namespace) - -## test_subclass_gc() [](#method-i-test_subclass_gc) - -## test_subclass_gc_stress() [](#method-i-test_subclass_gc_stress) - -## test_subclasses() [](#method-i-test_subclasses) - -## test_superclass() [](#method-i-test_superclass) - -## test_superclass_of_basicobject() [](#method-i-test_superclass_of_basicobject) - -## test_uninitialized() [](#method-i-test_uninitialized) - -## test_visibility_inside_method() [](#method-i-test_visibility_inside_method) - diff --git a/example/ruby/TestClass/ClassFour.md b/example/ruby/TestClass/ClassFour.md deleted file mode 100644 index c4c141a..0000000 --- a/example/ruby/TestClass/ClassFour.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestClass::ClassFour -**Inherits:** TestClass::ClassThree - - - - - diff --git a/example/ruby/TestClass/ClassOne.md b/example/ruby/TestClass/ClassOne.md deleted file mode 100644 index bfb95b7..0000000 --- a/example/ruby/TestClass/ClassOne.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: TestClass::ClassOne -**Inherits:** Object - - ---- -Various test classes ---- - - -# Class Methods -## inherited(klass ) [](#method-c-inherited) -**@private** [] - -# Attributes -## num_args[RW] [](#attribute-i-num_args) -Returns the value of attribute num_args. - - -#Instance Methods -## [](n) [](#method-i-[]) - -## initialize(*args) [](#method-i-initialize) - -**@return** [ClassOne] a new instance of ClassOne - -## subs() [](#method-i-subs) - diff --git a/example/ruby/TestClass/ClassThree.md b/example/ruby/TestClass/ClassThree.md deleted file mode 100644 index d932d57..0000000 --- a/example/ruby/TestClass/ClassThree.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestClass::ClassThree -**Inherits:** TestClass::ClassOne - - - - - diff --git a/example/ruby/TestClass/ClassTwo.md b/example/ruby/TestClass/ClassTwo.md deleted file mode 100644 index e0d7354..0000000 --- a/example/ruby/TestClass/ClassTwo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestClass::ClassTwo -**Inherits:** TestClass::ClassOne - - - - - diff --git a/example/ruby/TestClass/CloneTest.md b/example/ruby/TestClass/CloneTest.md deleted file mode 100644 index 6edfeab..0000000 --- a/example/ruby/TestClass/CloneTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestClass::CloneTest -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestClass/CloneTest1.md b/example/ruby/TestClass/CloneTest1.md deleted file mode 100644 index e48172c..0000000 --- a/example/ruby/TestClass/CloneTest1.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestClass::CloneTest1 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestClass/CloneTest2.md b/example/ruby/TestClass/CloneTest2.md deleted file mode 100644 index 8db2cd3..0000000 --- a/example/ruby/TestClass/CloneTest2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestClass::CloneTest2 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestClone.md b/example/ruby/TestClone.md deleted file mode 100644 index 6638ead..0000000 --- a/example/ruby/TestClone.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestClone -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_clone() [](#method-i-test_clone) - -## test_frozen_properties_and_ivars_retained_on_clone_with_ivar() [](#method-i-test_frozen_properties_and_ivars_retained_on_clone_with_ivar) - -## test_frozen_properties_retained_on_clone() [](#method-i-test_frozen_properties_retained_on_clone) - -## test_ivar_retained_on_clone() [](#method-i-test_ivar_retained_on_clone) - -## test_ivars_retained_on_extended_obj_clone() [](#method-i-test_ivars_retained_on_extended_obj_clone) - -## test_proc_obj_id_flag_reset() [](#method-i-test_proc_obj_id_flag_reset) - -## test_user_flags() [](#method-i-test_user_flags) - diff --git a/example/ruby/TestClone/M001.md b/example/ruby/TestClone/M001.md deleted file mode 100644 index 4967f23..0000000 --- a/example/ruby/TestClone/M001.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestClone::M001 - - - - - diff --git a/example/ruby/TestClone/M002.md b/example/ruby/TestClone/M002.md deleted file mode 100644 index 3c216a9..0000000 --- a/example/ruby/TestClone/M002.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestClone::M002 - -**Includes:** TestClone::M001 - - - - - diff --git a/example/ruby/TestClone/M003.md b/example/ruby/TestClone/M003.md deleted file mode 100644 index e3fcfa3..0000000 --- a/example/ruby/TestClone/M003.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestClone::M003 - -**Includes:** TestClone::M002 - - - - - diff --git a/example/ruby/TestCompactIndexClient.md b/example/ruby/TestCompactIndexClient.md deleted file mode 100644 index 676e807..0000000 --- a/example/ruby/TestCompactIndexClient.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestCompactIndexClient -**Inherits:** Struct - - - - -# Attributes -## info_data[RW] [](#attribute-i-info_data) -Returns the value of attribute info_data - -**@return** [Object] the current value of info_data - -## names[RW] [](#attribute-i-names) -Returns the value of attribute names - -**@return** [Object] the current value of names - -## versions[RW] [](#attribute-i-versions) -Returns the value of attribute versions - -**@return** [Object] the current value of versions - - -#Instance Methods -## info(name, checksum) [](#method-i-info) -Requiring the checksum to match the input data helps ensure that we are -parsing the correct checksum from the versions file - -## set_info_data(name, value) [](#method-i-set_info_data) - diff --git a/example/ruby/TestComparable.md b/example/ruby/TestComparable.md deleted file mode 100644 index cd068e1..0000000 --- a/example/ruby/TestComparable.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestComparable -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## cmp(b) [](#method-i-cmp) - -## setup() [](#method-i-setup) - -## test_between() [](#method-i-test_between) - -## test_clamp() [](#method-i-test_clamp) - -## test_clamp_with_range() [](#method-i-test_clamp_with_range) - -## test_equal() [](#method-i-test_equal) - -## test_err() [](#method-i-test_err) - -## test_ge() [](#method-i-test_ge) - -## test_gt() [](#method-i-test_gt) - -## test_inversed_compare() [](#method-i-test_inversed_compare) - -## test_le() [](#method-i-test_le) - -## test_lt() [](#method-i-test_lt) - -## test_no_cmp() [](#method-i-test_no_cmp) - diff --git a/example/ruby/TestComprehensiveCaseMapping.md b/example/ruby/TestComprehensiveCaseMapping.md deleted file mode 100644 index efd0acb..0000000 --- a/example/ruby/TestComprehensiveCaseMapping.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestComprehensiveCaseMapping -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## data_files_available?() [](#method-c-data_files_available?) -**@return** [Boolean] - -## expand_filename(basename ) [](#method-c-expand_filename) -## hex2utf8(s ) [](#method-c-hex2utf8) - -#Instance Methods -## test_data_files_available() [](#method-i-test_data_files_available) - diff --git a/example/ruby/TestConcatStress.md b/example/ruby/TestConcatStress.md deleted file mode 100644 index bbc1823..0000000 --- a/example/ruby/TestConcatStress.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestConcatStress -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_concat() [](#method-i-test_concat) - diff --git a/example/ruby/TestCondition.md b/example/ruby/TestCondition.md deleted file mode 100644 index 9b75ef2..0000000 --- a/example/ruby/TestCondition.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: TestCondition -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_condition() [](#method-i-test_condition) -should -: first test to see if we can run the tests. - - diff --git a/example/ruby/TestConst.md b/example/ruby/TestConst.md deleted file mode 100644 index 8134127..0000000 --- a/example/ruby/TestConst.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestConst -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_const() [](#method-i-test_const) - -## test_const_access_from_nil() [](#method-i-test_const_access_from_nil) - -## test_redefinition() [](#method-i-test_redefinition) - -## test_redefinition_memory_leak() [](#method-i-test_redefinition_memory_leak) - -## test_toplevel_lookup() [](#method-i-test_toplevel_lookup) - diff --git a/example/ruby/TestContinuation.md b/example/ruby/TestContinuation.md deleted file mode 100644 index 3935f63..0000000 --- a/example/ruby/TestContinuation.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestContinuation -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## _test_tracing_with_set_trace_func() [](#method-i-_test_tracing_with_set_trace_func) - -## setup() [](#method-i-setup) - -## test_ary_flatten() [](#method-i-test_ary_flatten) - -## test_call() [](#method-i-test_call) - -## test_check_localvars() [](#method-i-test_check_localvars) - -## test_create() [](#method-i-test_create) - -## test_error() [](#method-i-test_error) - -## test_marshal_dump() [](#method-i-test_marshal_dump) - -## test_tracing_with_thread_set_trace_func() [](#method-i-test_tracing_with_thread_set_trace_func) - -## tracing_with_set_trace_func() [](#method-i-tracing_with_set_trace_func) - -## tracing_with_thread_set_trace_func() [](#method-i-tracing_with_thread_set_trace_func) - diff --git a/example/ruby/TestCoverage.md b/example/ruby/TestCoverage.md deleted file mode 100644 index 63a9d2f..0000000 --- a/example/ruby/TestCoverage.md +++ /dev/null @@ -1,96 +0,0 @@ -# Class: TestCoverage -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_coverage(code, opt, stdout) [](#method-i-assert_coverage) - -## test_big_code() [](#method-i-test_big_code) - -## test_branch_coverage_for_case_statement() [](#method-i-test_branch_coverage_for_case_statement) - -## test_branch_coverage_for_if_statement() [](#method-i-test_branch_coverage_for_if_statement) - -## test_branch_coverage_for_pattern_matching() [](#method-i-test_branch_coverage_for_pattern_matching) - -## test_branch_coverage_for_safe_method_invocation() [](#method-i-test_branch_coverage_for_safe_method_invocation) - -## test_branch_coverage_for_while_statement() [](#method-i-test_branch_coverage_for_while_statement) - -## test_branch_coverage_in_ensure_clause() [](#method-i-test_branch_coverage_in_ensure_clause) - -## test_clear_with_branches() [](#method-i-test_clear_with_branches) - -## test_clear_with_lines() [](#method-i-test_clear_with_lines) - -## test_clear_with_methods() [](#method-i-test_clear_with_methods) - -## test_clear_with_oneshot_lines() [](#method-i-test_clear_with_oneshot_lines) - -## test_coverage_ensure_if_return() [](#method-i-test_coverage_ensure_if_return) - -## test_coverage_in_main_script() [](#method-i-test_coverage_in_main_script) - -## test_coverage_optimized_branch() [](#method-i-test_coverage_optimized_branch) - -## test_coverage_running?() [](#method-i-test_coverage_running?) - -**@return** [Boolean] - -## test_coverage_snapshot() [](#method-i-test_coverage_snapshot) - -## test_coverage_state() [](#method-i-test_coverage_state) - -## test_coverage_supported() [](#method-i-test_coverage_supported) - -## test_coverage_suspendable() [](#method-i-test_coverage_suspendable) - -## test_coverage_with_asan() [](#method-i-test_coverage_with_asan) - -## test_double_resume() [](#method-i-test_double_resume) - -## test_double_suspend() [](#method-i-test_double_suspend) - -## test_eval() [](#method-i-test_eval) - -## test_eval_coverage() [](#method-i-test_eval_coverage) - -## test_line_coverage_for_multiple_lines() [](#method-i-test_line_coverage_for_multiple_lines) - -## test_line_stub() [](#method-i-test_line_stub) - -## test_method_coverage() [](#method-i-test_method_coverage) - -## test_method_coverage_for_alias() [](#method-i-test_method_coverage_for_alias) - -## test_method_coverage_for_define_method() [](#method-i-test_method_coverage_for_define_method) - -## test_method_coverage_for_singleton_class() [](#method-i-test_method_coverage_for_singleton_class) - -## test_nocoverage_optimized_line() [](#method-i-test_nocoverage_optimized_line) - -## test_oneshot_line_coverage() [](#method-i-test_oneshot_line_coverage) - -## test_peek_result_without_start() [](#method-i-test_peek_result_without_start) - -## test_restarting_coverage() [](#method-i-test_restarting_coverage) - -## test_result_after_suspend() [](#method-i-test_result_after_suspend) - -## test_result_with_nothing() [](#method-i-test_result_with_nothing) - -## test_result_without_resume() [](#method-i-test_result_without_resume) - -## test_result_without_start() [](#method-i-test_result_without_start) - -## test_resume_without_setup() [](#method-i-test_resume_without_setup) - -## test_stop_wrong_peephole_optimization() [](#method-i-test_stop_wrong_peephole_optimization) - -## test_suspend_without_setup() [](#method-i-test_suspend_without_setup) - -## test_tag_break_with_branch_coverage() [](#method-i-test_tag_break_with_branch_coverage) - diff --git a/example/ruby/TestCoverage/DummyConstant.md b/example/ruby/TestCoverage/DummyConstant.md deleted file mode 100644 index 7e79298..0000000 --- a/example/ruby/TestCoverage/DummyConstant.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestCoverage::DummyConstant -**Inherits:** String - - - - - -#Instance Methods -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/TestD.md b/example/ruby/TestD.md deleted file mode 100644 index 73183a0..0000000 --- a/example/ruby/TestD.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestD -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_fail_at_worker() [](#method-i-test_fail_at_worker) - diff --git a/example/ruby/TestData.md b/example/ruby/TestData.md deleted file mode 100644 index 221fb51..0000000 --- a/example/ruby/TestData.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestData -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_define() [](#method-i-test_define) - -## test_define_edge_cases() [](#method-i-test_define_edge_cases) - -## test_define_with_block() [](#method-i-test_define_with_block) - -## test_dup() [](#method-i-test_dup) - -## test_eql() [](#method-i-test_eql) - -## test_equal() [](#method-i-test_equal) - -## test_hash() [](#method-i-test_hash) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_redefine() [](#method-i-test_initialize_redefine) - -## test_inspect() [](#method-i-test_inspect) - -## test_instance_behavior() [](#method-i-test_instance_behavior) - -## test_marshal() [](#method-i-test_marshal) - -## test_memberless() [](#method-i-test_memberless) - -## test_with() [](#method-i-test_with) - -## test_with_initialize() [](#method-i-test_with_initialize) - diff --git a/example/ruby/TestDate.md b/example/ruby/TestDate.md deleted file mode 100644 index 9e63b61..0000000 --- a/example/ruby/TestDate.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestDate -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test__const() [](#method-i-test__const) - -## test_deconstruct_keys() [](#method-i-test_deconstruct_keys) - -## test_eql_p() [](#method-i-test_eql_p) - -## test_freeze() [](#method-i-test_freeze) - -## test_hash() [](#method-i-test_hash) - -## test_infinity_comparison() [](#method-i-test_infinity_comparison) - -## test_range_infinite_float() [](#method-i-test_range_infinite_float) - -## test_sub() [](#method-i-test_sub) - -## test_submillisecond_comparison() [](#method-i-test_submillisecond_comparison) - diff --git a/example/ruby/TestDateArith.md b/example/ruby/TestDateArith.md deleted file mode 100644 index 164f0e3..0000000 --- a/example/ruby/TestDateArith.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: TestDateArith -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test__compare() [](#method-i-test__compare) - -## test__minus() [](#method-i-test__minus) - -## test__minus__ex() [](#method-i-test__minus__ex) - -## test__plus() [](#method-i-test__plus) - -## test__plus__ex() [](#method-i-test__plus__ex) - -## test_downto() [](#method-i-test_downto) - -## test_downto__noblock() [](#method-i-test_downto__noblock) - -## test_new_offset() [](#method-i-test_new_offset) - -## test_next() [](#method-i-test_next) - -## test_next_day() [](#method-i-test_next_day) - -## test_next_month() [](#method-i-test_next_month) - -## test_next_month__2() [](#method-i-test_next_month__2) - -## test_next_year() [](#method-i-test_next_year) - -## test_prev() [](#method-i-test_prev) - -## test_prev_day() [](#method-i-test_prev_day) - -## test_prev_month() [](#method-i-test_prev_month) - -## test_prev_month__2() [](#method-i-test_prev_month__2) - -## test_prev_year() [](#method-i-test_prev_year) - -## test_step() [](#method-i-test_step) - -## test_step__compare() [](#method-i-test_step__compare) - -## test_step__noblock() [](#method-i-test_step__noblock) - -## test_upto() [](#method-i-test_upto) - -## test_upto__noblock() [](#method-i-test_upto__noblock) - diff --git a/example/ruby/TestDateArith/Rat.md b/example/ruby/TestDateArith/Rat.md deleted file mode 100644 index 5c9e746..0000000 --- a/example/ruby/TestDateArith/Rat.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestDateArith::Rat -**Inherits:** Numeric - - - - - -#Instance Methods -## to_r() [](#method-i-to_r) - diff --git a/example/ruby/TestDateAttr.md b/example/ruby/TestDateAttr.md deleted file mode 100644 index 0e56127..0000000 --- a/example/ruby/TestDateAttr.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestDateAttr -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test__attr() [](#method-i-test__attr) - -## test__wday_predicate() [](#method-i-test__wday_predicate) - -## test_nth_kday() [](#method-i-test_nth_kday) - diff --git a/example/ruby/TestDateCompat.md b/example/ruby/TestDateCompat.md deleted file mode 100644 index b3aef60..0000000 --- a/example/ruby/TestDateCompat.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestDateCompat -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_compat() [](#method-i-test_compat) - diff --git a/example/ruby/TestDateConv.md b/example/ruby/TestDateConv.md deleted file mode 100644 index a89d52d..0000000 --- a/example/ruby/TestDateConv.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestDateConv -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_to_class() [](#method-i-test_to_class) - -## test_to_date__from_date() [](#method-i-test_to_date__from_date) - -## test_to_date__from_datetime() [](#method-i-test_to_date__from_datetime) - -## test_to_date__from_time() [](#method-i-test_to_date__from_time) - -## test_to_datetime__from_date() [](#method-i-test_to_datetime__from_date) - -## test_to_datetime__from_datetime() [](#method-i-test_to_datetime__from_datetime) - -## test_to_datetime__from_time() [](#method-i-test_to_datetime__from_time) - -## test_to_time__from_date() [](#method-i-test_to_time__from_date) - -## test_to_time__from_datetime() [](#method-i-test_to_time__from_datetime) - -## test_to_time__from_time() [](#method-i-test_to_time__from_time) - -## test_to_time_to_date_roundtrip__from_gregorian_date() [](#method-i-test_to_time_to_date_roundtrip__from_gregorian_date) - -## test_to_time_to_date_roundtrip__from_julian_date() [](#method-i-test_to_time_to_date_roundtrip__from_julian_date) - -## with_tz(tz) [](#method-i-with_tz) - diff --git a/example/ruby/TestDateMarshal.md b/example/ruby/TestDateMarshal.md deleted file mode 100644 index 22e3395..0000000 --- a/example/ruby/TestDateMarshal.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDateMarshal -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_marshal() [](#method-i-test_marshal) - -## test_memsize() [](#method-i-test_memsize) - diff --git a/example/ruby/TestDateNew.md b/example/ruby/TestDateNew.md deleted file mode 100644 index 4d56853..0000000 --- a/example/ruby/TestDateNew.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestDateNew -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_civil() [](#method-i-test_civil) - -## test_civil__ex() [](#method-i-test_civil__ex) - -## test_civil__neg() [](#method-i-test_civil__neg) - -## test_civil__reform() [](#method-i-test_civil__reform) - -## test_commercial() [](#method-i-test_commercial) - -## test_commercial__ex() [](#method-i-test_commercial__ex) - -## test_commercial__neg() [](#method-i-test_commercial__neg) - -## test_invalid_types() [](#method-i-test_invalid_types) - -## test_jd() [](#method-i-test_jd) - -## test_jd__ex() [](#method-i-test_jd__ex) - -## test_memsize() [](#method-i-test_memsize) - -## test_now() [](#method-i-test_now) - -## test_nth_kday() [](#method-i-test_nth_kday) - -## test_ordinal() [](#method-i-test_ordinal) - -## test_ordinal__ex() [](#method-i-test_ordinal__ex) - -## test_ordinal__neg() [](#method-i-test_ordinal__neg) - -## test_today() [](#method-i-test_today) - -## test_valid_with_invalid_types() [](#method-i-test_valid_with_invalid_types) - -## test_weeknum() [](#method-i-test_weeknum) - diff --git a/example/ruby/TestDateParse.md b/example/ruby/TestDateParse.md deleted file mode 100644 index 993390d..0000000 --- a/example/ruby/TestDateParse.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: TestDateParse -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test__httpdate() [](#method-i-test__httpdate) - -## test__iso8601() [](#method-i-test__iso8601) - -## test__jisx0301() [](#method-i-test__jisx0301) - -## test__parse() [](#method-i-test__parse) - -## test__parse__2() [](#method-i-test__parse__2) - -## test__parse_odd_offset() [](#method-i-test__parse_odd_offset) - -## test__parse_slash_exp() [](#method-i-test__parse_slash_exp) - -## test__parse_too_long_year() [](#method-i-test__parse_too_long_year) - -## test__rfc2822() [](#method-i-test__rfc2822) - -## test__rfc3339() [](#method-i-test__rfc3339) - -## test__xmlschema() [](#method-i-test__xmlschema) - -## test_given_string() [](#method-i-test_given_string) - -## test_httpdate() [](#method-i-test_httpdate) - -## test_iso8601() [](#method-i-test_iso8601) - -## test_jisx0301() [](#method-i-test_jisx0301) - -## test_length_limit() [](#method-i-test_length_limit) - -## test_parse() [](#method-i-test_parse) - -## test_parse__2() [](#method-i-test_parse__2) - -## test_parse__comp() [](#method-i-test_parse__comp) - -## test_parse__d_to_s() [](#method-i-test_parse__d_to_s) - -## test_parse__ex() [](#method-i-test_parse__ex) - -## test_parse__time() [](#method-i-test_parse__time) - -## test_parse_utf8() [](#method-i-test_parse_utf8) - -## test_rfc2822() [](#method-i-test_rfc2822) - -## test_rfc3339() [](#method-i-test_rfc3339) - -## test_xmlschema() [](#method-i-test_xmlschema) - diff --git a/example/ruby/TestDateParseRactor.md b/example/ruby/TestDateParseRactor.md deleted file mode 100644 index 55e6beb..0000000 --- a/example/ruby/TestDateParseRactor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDateParseRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## code(klassDate, share:false) [](#method-i-code) - -## test_date_ractor() [](#method-i-test_date_ractor) - diff --git a/example/ruby/TestDateStrftime.md b/example/ruby/TestDateStrftime.md deleted file mode 100644 index e3cb138..0000000 --- a/example/ruby/TestDateStrftime.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: TestDateStrftime -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test__different_format() [](#method-i-test__different_format) - -## test_overflow() [](#method-i-test_overflow) - -## test_strftime() [](#method-i-test_strftime) - -## test_strftime__2() [](#method-i-test_strftime__2) - -## test_strftime__3_1() [](#method-i-test_strftime__3_1) - -## test_strftime__3_2() [](#method-i-test_strftime__3_2) - -## test_strftime__4() [](#method-i-test_strftime__4) - -## test_strftime__gnuext() [](#method-i-test_strftime__gnuext) -coreutils - -## test_strftime__gnuext_LN() [](#method-i-test_strftime__gnuext_LN) -coreutils - -## test_strftime__gnuext_complex() [](#method-i-test_strftime__gnuext_complex) - -## test_strftime__gnuext_z() [](#method-i-test_strftime__gnuext_z) -coreutils - -## test_strftime__minus() [](#method-i-test_strftime__minus) - -## test_strftime__offset() [](#method-i-test_strftime__offset) - -## test_strftime_milli() [](#method-i-test_strftime_milli) - diff --git a/example/ruby/TestDateStrptime.md b/example/ruby/TestDateStrptime.md deleted file mode 100644 index 0f79039..0000000 --- a/example/ruby/TestDateStrptime.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestDateStrptime -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test__strptime() [](#method-i-test__strptime) - -## test__strptime__2() [](#method-i-test__strptime__2) - -## test__strptime__3() [](#method-i-test__strptime__3) - -## test__strptime__fail() [](#method-i-test__strptime__fail) - -## test__strptime__width() [](#method-i-test__strptime__width) - -## test_given_string() [](#method-i-test_given_string) - -## test_strptime() [](#method-i-test_strptime) - -## test_strptime__2() [](#method-i-test_strptime__2) - -## test_strptime__comp() [](#method-i-test_strptime__comp) - -## test_strptime__d_to_s() [](#method-i-test_strptime__d_to_s) - -## test_strptime__ex() [](#method-i-test_strptime__ex) - -## test_strptime__minus() [](#method-i-test_strptime__minus) - -## test_sz() [](#method-i-test_sz) - diff --git a/example/ruby/TestDebug.md b/example/ruby/TestDebug.md deleted file mode 100644 index f994194..0000000 --- a/example/ruby/TestDebug.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestDebug -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## binds_check(binds, msgnil) [](#method-i-binds_check) - -## inspector_in_eval() [](#method-i-inspector_in_eval) - -## test_inspector_open() [](#method-i-test_inspector_open) - -## test_inspector_open_in_eval() [](#method-i-test_inspector_open_in_eval) - -## test_lazy_block() [](#method-i-test_lazy_block) - diff --git a/example/ruby/TestDebug/MyRelation.md b/example/ruby/TestDebug/MyRelation.md deleted file mode 100644 index f573043..0000000 --- a/example/ruby/TestDebug/MyRelation.md +++ /dev/null @@ -1,2072 +0,0 @@ -# Class: TestDebug::MyRelation -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -**@yield** [:each_entry] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/TestDefaultGems.md b/example/ruby/TestDefaultGems.md deleted file mode 100644 index 70eb896..0000000 --- a/example/ruby/TestDefaultGems.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDefaultGems -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## load(file ) [](#method-c-load) - -#Instance Methods -## test_validate_gemspec() [](#method-i-test_validate_gemspec) - diff --git a/example/ruby/TestDefined.md b/example/ruby/TestDefined.md deleted file mode 100644 index 699c24b..0000000 --- a/example/ruby/TestDefined.md +++ /dev/null @@ -1,84 +0,0 @@ -# Class: TestDefined -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## defined_test() [](#method-i-defined_test) - -## test_autoloaded_noload() [](#method-i-test_autoloaded_noload) - -## test_autoloaded_subclass() [](#method-i-test_autoloaded_subclass) - -## test_define_method() [](#method-i-test_define_method) - -## test_defined_assignment() [](#method-i-test_defined_assignment) - -## test_defined_attrasgn() [](#method-i-test_defined_attrasgn) - -## test_defined_constant() [](#method-i-test_defined_constant) - -## test_defined_empty_paren_arg() [](#method-i-test_defined_empty_paren_arg) - -## test_defined_empty_paren_expr() [](#method-i-test_defined_empty_paren_expr) - -## test_defined_global_variable() [](#method-i-test_defined_global_variable) - -## test_defined_hash() [](#method-i-test_defined_hash) - -## test_defined_impl_specific() [](#method-i-test_defined_impl_specific) - -## test_defined_literal() [](#method-i-test_defined_literal) - -## test_defined_local_variable() [](#method-i-test_defined_local_variable) - -## test_defined_matchdata() [](#method-i-test_defined_matchdata) - -## test_defined_method() [](#method-i-test_defined_method) - -## test_defined_method_single_call() [](#method-i-test_defined_method_single_call) - -## test_defined_operator() [](#method-i-test_defined_operator) - -## test_defined_private_method() [](#method-i-test_defined_private_method) - -## test_defined_protected_method() [](#method-i-test_defined_protected_method) - -## test_defined_public_method() [](#method-i-test_defined_public_method) - -## test_defined_refined_call_with_using() [](#method-i-test_defined_refined_call_with_using) - -## test_defined_refined_call_without_using() [](#method-i-test_defined_refined_call_without_using) - -## test_defined_refined_vcall_with_using() [](#method-i-test_defined_refined_vcall_with_using) - -## test_defined_refined_vcall_without_using() [](#method-i-test_defined_refined_vcall_without_using) - -## test_defined_splat() [](#method-i-test_defined_splat) - -## test_defined_undef() [](#method-i-test_defined_undef) - -## test_defined_undefined_argument() [](#method-i-test_defined_undefined_argument) - -## test_defined_undefined_method() [](#method-i-test_defined_undefined_method) - -## test_defined_yield() [](#method-i-test_defined_yield) - -## test_exception() [](#method-i-test_exception) - -## test_method_by_respond_to_missing() [](#method-i-test_method_by_respond_to_missing) - -## test_respond_to() [](#method-i-test_respond_to) - -## test_super_in_basic_object() [](#method-i-test_super_in_basic_object) - -## test_super_in_block() [](#method-i-test_super_in_block) - -## test_super_in_included_method() [](#method-i-test_super_in_included_method) - -## test_super_toplevel() [](#method-i-test_super_toplevel) - -## test_top_level_constant_not_defined() [](#method-i-test_top_level_constant_not_defined) - diff --git a/example/ruby/TestDefined/ExampleRespondToMissing.md b/example/ruby/TestDefined/ExampleRespondToMissing.md deleted file mode 100644 index e0e7a9f..0000000 --- a/example/ruby/TestDefined/ExampleRespondToMissing.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestDefined::ExampleRespondToMissing -**Inherits:** Object - - - - -# Attributes -## called[RW] [](#attribute-i-called) -Returns the value of attribute called. - - -#Instance Methods -## existing_method() [](#method-i-existing_method) - -## func_defined_existing_func() [](#method-i-func_defined_existing_func) - -## func_defined_non_existing_func() [](#method-i-func_defined_non_existing_func) - -## initialize() [](#method-i-initialize) - -**@return** [ExampleRespondToMissing] a new instance of ExampleRespondToMissing - -## respond_to_missing?(*args) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - diff --git a/example/ruby/TestDefined/Foo.md b/example/ruby/TestDefined/Foo.md deleted file mode 100644 index e2ae24f..0000000 --- a/example/ruby/TestDefined/Foo.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestDefined::Foo -**Inherits:** Object - - - - -# Attributes -## attr[RW] [](#attribute-i-attr) -Returns the value of attribute attr. - - -#Instance Methods -## attrasgn_test() [](#method-i-attrasgn_test) - -**@yield** [defined?(self.attr = 1)] - -## bar(f) [](#method-i-bar) - -**@yield** [defined?(self.foo)] - -## baz(f) [](#method-i-baz) - diff --git a/example/ruby/TestDefined/RefinedClass.md b/example/ruby/TestDefined/RefinedClass.md deleted file mode 100644 index 35250d1..0000000 --- a/example/ruby/TestDefined/RefinedClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestDefined::RefinedClass -**Inherits:** Object - - - - - diff --git a/example/ruby/TestDefined/RefiningModule.md b/example/ruby/TestDefined/RefiningModule.md deleted file mode 100644 index 441f071..0000000 --- a/example/ruby/TestDefined/RefiningModule.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: TestDefined::RefiningModule - - - - -# Class Methods -## call_with_using(x RefinedClass.new) [](#method-c-call_with_using) -## call_without_using(x RefinedClass.new) [](#method-c-call_without_using) -## vcall_with_using(x RefinedClass.new) [](#method-c-vcall_with_using) -## vcall_without_using(x RefinedClass.new) [](#method-c-vcall_without_using) - diff --git a/example/ruby/TestDefined/TestAutoloadedNoload.md b/example/ruby/TestDefined/TestAutoloadedNoload.md deleted file mode 100644 index 2c23d60..0000000 --- a/example/ruby/TestDefined/TestAutoloadedNoload.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestDefined::TestAutoloadedNoload -**Inherits:** Object - - - - - -#Instance Methods -## a?() [](#method-i-a?) - -**@return** [Boolean] - -## b?() [](#method-i-b?) - -**@return** [Boolean] - diff --git a/example/ruby/TestDefined/TestAutoloadedSubclass.md b/example/ruby/TestDefined/TestAutoloadedSubclass.md deleted file mode 100644 index 5069cbc..0000000 --- a/example/ruby/TestDefined/TestAutoloadedSubclass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDefined::TestAutoloadedSubclass -**Inherits:** TestDefined::TestAutoloadedSuperclass - - - - - -#Instance Methods -## a?() [](#method-i-a?) - -**@return** [Boolean] - diff --git a/example/ruby/TestDefined/TestAutoloadedSuperclass.md b/example/ruby/TestDefined/TestAutoloadedSuperclass.md deleted file mode 100644 index 1dfe128..0000000 --- a/example/ruby/TestDefined/TestAutoloadedSuperclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestDefined::TestAutoloadedSuperclass -**Inherits:** Object - - - - - diff --git a/example/ruby/TestDelegateClass.md b/example/ruby/TestDelegateClass.md deleted file mode 100644 index 13ae7e5..0000000 --- a/example/ruby/TestDelegateClass.md +++ /dev/null @@ -1,80 +0,0 @@ -# Class: TestDelegateClass -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_DelegateClass_instance_method() [](#method-i-test_DelegateClass_instance_method) - -## test_DelegateClass_public_instance_method() [](#method-i-test_DelegateClass_public_instance_method) - -## test_basicobject() [](#method-i-test_basicobject) - -## test_basicobject_respond_to() [](#method-i-test_basicobject_respond_to) - -## test_callee_in_delegator_class() [](#method-i-test_callee_in_delegator_class) - -## test_callee_in_simple_delegator() [](#method-i-test_callee_in_simple_delegator) - -## test_copy_frozen() [](#method-i-test_copy_frozen) - -## test_delegate_class_block() [](#method-i-test_delegate_class_block) - -## test_delegateclass_class() [](#method-i-test_delegateclass_class) - -## test_dir_in_delegator_class() [](#method-i-test_dir_in_delegator_class) - -## test_dir_in_simple_delegator() [](#method-i-test_dir_in_simple_delegator) - -## test_eql?() [](#method-i-test_eql?) - -**@return** [Boolean] - -## test_extend() [](#method-i-test_extend) - -## test_frozen() [](#method-i-test_frozen) - -## test_global_function() [](#method-i-test_global_function) - -## test_global_method_if_no_target() [](#method-i-test_global_method_if_no_target) - -## test_instance_method() [](#method-i-test_instance_method) - -## test_instance_methods() [](#method-i-test_instance_methods) - -## test_keyword_and_hash() [](#method-i-test_keyword_and_hash) - -## test_keyword_argument() [](#method-i-test_keyword_argument) - -## test_marshal() [](#method-i-test_marshal) - -## test_method_in_delegator_class() [](#method-i-test_method_in_delegator_class) - -## test_method_in_simple_delegator() [](#method-i-test_method_in_simple_delegator) - -## test_methods() [](#method-i-test_methods) - -## test_module_methods_vs_kernel_methods() [](#method-i-test_module_methods_vs_kernel_methods) - -## test_override() [](#method-i-test_override) - -## test_private_method() [](#method-i-test_private_method) - -## test_protected_instance_methods() [](#method-i-test_protected_instance_methods) - -## test_public_instance_methods() [](#method-i-test_public_instance_methods) - -## test_send_method_in_delegator() [](#method-i-test_send_method_in_delegator) - -## test_simpledelegator_class() [](#method-i-test_simpledelegator_class) - -## test_simpledelegator_clone() [](#method-i-test_simpledelegator_clone) - -## test_systemcallerror_eq() [](#method-i-test_systemcallerror_eq) - -## test_unset_delegate_class() [](#method-i-test_unset_delegate_class) - -## test_unset_simple_delegator() [](#method-i-test_unset_simple_delegator) - diff --git a/example/ruby/TestDelegateClass/Bar.md b/example/ruby/TestDelegateClass/Bar.md deleted file mode 100644 index eb77f54..0000000 --- a/example/ruby/TestDelegateClass/Bar.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestDelegateClass::Bar -**Inherits:** TestDelegateClass::Foo - - - - - diff --git a/example/ruby/TestDelegateClass/Bug9155.md b/example/ruby/TestDelegateClass/Bug9155.md deleted file mode 100644 index b174395..0000000 --- a/example/ruby/TestDelegateClass/Bug9155.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDelegateClass::Bug9155 -**Inherits:** Integer - - - - - -#Instance Methods -## initialize(value) [](#method-i-initialize) - -**@return** [Bug9155] a new instance of Bug9155 - diff --git a/example/ruby/TestDelegateClass/Bug9403.md b/example/ruby/TestDelegateClass/Bug9403.md deleted file mode 100644 index 2d14316..0000000 --- a/example/ruby/TestDelegateClass/Bug9403.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestDelegateClass::Bug9403 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestDelegateClass/Child.md b/example/ruby/TestDelegateClass/Child.md deleted file mode 100644 index dde214e..0000000 --- a/example/ruby/TestDelegateClass/Child.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestDelegateClass::Child -**Inherits:** TestDelegateClass::Parent - - - - - diff --git a/example/ruby/TestDelegateClass/Foo.md b/example/ruby/TestDelegateClass/Foo.md deleted file mode 100644 index 873c2fa..0000000 --- a/example/ruby/TestDelegateClass/Foo.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDelegateClass::Foo -**Inherits:** Object - - - - - -#Instance Methods -## delegate_test_m() [](#method-i-delegate_test_m) - -## m() [](#method-i-m) - diff --git a/example/ruby/TestDelegateClass/IV.md b/example/ruby/TestDelegateClass/IV.md deleted file mode 100644 index b22a480..0000000 --- a/example/ruby/TestDelegateClass/IV.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestDelegateClass::IV -**Inherits:** Integer - - - - -# Attributes -## var[RW] [](#attribute-i-var) -Returns the value of attribute var. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [IV] a new instance of IV - diff --git a/example/ruby/TestDelegateClass/M.md b/example/ruby/TestDelegateClass/M.md deleted file mode 100644 index ca4e0d6..0000000 --- a/example/ruby/TestDelegateClass/M.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: TestDelegateClass::M - - - - -# Attributes -## m[RW] [](#attribute-i-m) -Returns the value of attribute m. - - diff --git a/example/ruby/TestDelegateClass/Myclass.md b/example/ruby/TestDelegateClass/Myclass.md deleted file mode 100644 index 4da6b5d..0000000 --- a/example/ruby/TestDelegateClass/Myclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestDelegateClass::Myclass -**Inherits:** Array - - - - - diff --git a/example/ruby/TestDelegateClass/Object.md b/example/ruby/TestDelegateClass/Object.md deleted file mode 100644 index 916bb62..0000000 --- a/example/ruby/TestDelegateClass/Object.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestDelegateClass::Object -**Inherits:** Object - - - - - -#Instance Methods -## m() [](#method-i-m) - diff --git a/example/ruby/TestDelegateClass/Parent.md b/example/ruby/TestDelegateClass/Parent.md deleted file mode 100644 index 8402553..0000000 --- a/example/ruby/TestDelegateClass/Parent.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDelegateClass::Parent -**Inherits:** Object - - - - - -#Instance Methods -## parent_public() [](#method-i-parent_public) - -## parent_public_added() [](#method-i-parent_public_added) - diff --git a/example/ruby/TestDigest.md b/example/ruby/TestDigest.md deleted file mode 100644 index baa3e59..0000000 --- a/example/ruby/TestDigest.md +++ /dev/null @@ -1,31 +0,0 @@ -# Module: TestDigest - - - - - -#Instance Methods -## test_alignment() [](#method-i-test_alignment) - -## test_bubblebabble() [](#method-i-test_bubblebabble) - -## test_bubblebabble_class() [](#method-i-test_bubblebabble_class) - -## test_bubblebabble_instance() [](#method-i-test_bubblebabble_instance) - -## test_eq() [](#method-i-test_eq) - -## test_instance_eval() [](#method-i-test_instance_eval) - -## test_s_base64digest() [](#method-i-test_s_base64digest) - -## test_s_digest() [](#method-i-test_s_digest) - -## test_s_file() [](#method-i-test_s_file) - -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - -## test_s_new() [](#method-i-test_s_new) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/TestDigest/TestBase.md b/example/ruby/TestDigest/TestBase.md deleted file mode 100644 index e620a1f..0000000 --- a/example/ruby/TestDigest/TestBase.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestDigest::TestBase -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_base() [](#method-i-test_base) - diff --git a/example/ruby/TestDigest/TestDigestParen.md b/example/ruby/TestDigest/TestDigestParen.md deleted file mode 100644 index 5ee1bbf..0000000 --- a/example/ruby/TestDigest/TestDigestParen.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestDigest::TestDigestParen -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_no_lib() [](#method-i-test_no_lib) - -## test_no_lib_no_def() [](#method-i-test_no_lib_no_def) - -## test_race() [](#method-i-test_race) - -## test_race_mixed() [](#method-i-test_race_mixed) - -## test_sha2() [](#method-i-test_sha2) - diff --git a/example/ruby/TestDigest/TestInitCopy.md b/example/ruby/TestDigest/TestInitCopy.md deleted file mode 100644 index dd172a4..0000000 --- a/example/ruby/TestDigest/TestInitCopy.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestDigest::TestInitCopy -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_initialize_copy_md5_rmd160() [](#method-i-test_initialize_copy_md5_rmd160) - diff --git a/example/ruby/TestDigest/TestMD5.md b/example/ruby/TestDigest/TestMD5.md deleted file mode 100644 index 28b9b21..0000000 --- a/example/ruby/TestDigest/TestMD5.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestDigest::TestMD5 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigest - - - - - -#Instance Methods -## test_alignment() [](#method-i-test_alignment) - -## test_bubblebabble() [](#method-i-test_bubblebabble) - -## test_bubblebabble_class() [](#method-i-test_bubblebabble_class) - -## test_bubblebabble_instance() [](#method-i-test_bubblebabble_instance) - -## test_eq() [](#method-i-test_eq) - -## test_instance_eval() [](#method-i-test_instance_eval) - -## test_s_base64digest() [](#method-i-test_s_base64digest) - -## test_s_digest() [](#method-i-test_s_digest) - -## test_s_file() [](#method-i-test_s_file) - -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - -## test_s_new() [](#method-i-test_s_new) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/TestDigest/TestRMD160.md b/example/ruby/TestDigest/TestRMD160.md deleted file mode 100644 index b4d2f7e..0000000 --- a/example/ruby/TestDigest/TestRMD160.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestDigest::TestRMD160 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigest - - - - - -#Instance Methods -## test_alignment() [](#method-i-test_alignment) - -## test_bubblebabble() [](#method-i-test_bubblebabble) - -## test_bubblebabble_class() [](#method-i-test_bubblebabble_class) - -## test_bubblebabble_instance() [](#method-i-test_bubblebabble_instance) - -## test_eq() [](#method-i-test_eq) - -## test_instance_eval() [](#method-i-test_instance_eval) - -## test_s_base64digest() [](#method-i-test_s_base64digest) - -## test_s_digest() [](#method-i-test_s_digest) - -## test_s_file() [](#method-i-test_s_file) - -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - -## test_s_new() [](#method-i-test_s_new) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/TestDigest/TestSHA1.md b/example/ruby/TestDigest/TestSHA1.md deleted file mode 100644 index 9d3682c..0000000 --- a/example/ruby/TestDigest/TestSHA1.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestDigest::TestSHA1 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigest - - - - - -#Instance Methods -## test_alignment() [](#method-i-test_alignment) - -## test_bubblebabble() [](#method-i-test_bubblebabble) - -## test_bubblebabble_class() [](#method-i-test_bubblebabble_class) - -## test_bubblebabble_instance() [](#method-i-test_bubblebabble_instance) - -## test_eq() [](#method-i-test_eq) - -## test_instance_eval() [](#method-i-test_instance_eval) - -## test_s_base64digest() [](#method-i-test_s_base64digest) - -## test_s_digest() [](#method-i-test_s_digest) - -## test_s_file() [](#method-i-test_s_file) - -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - -## test_s_new() [](#method-i-test_s_new) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/TestDigest/TestSHA2.md b/example/ruby/TestDigest/TestSHA2.md deleted file mode 100644 index 57da1df..0000000 --- a/example/ruby/TestDigest/TestSHA2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestDigest::TestSHA2 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_s_file() [](#method-i-test_s_file) - diff --git a/example/ruby/TestDigest/TestSHA256.md b/example/ruby/TestDigest/TestSHA256.md deleted file mode 100644 index 8bfc88f..0000000 --- a/example/ruby/TestDigest/TestSHA256.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestDigest::TestSHA256 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigest - - - - - -#Instance Methods -## test_alignment() [](#method-i-test_alignment) - -## test_bubblebabble() [](#method-i-test_bubblebabble) - -## test_bubblebabble_class() [](#method-i-test_bubblebabble_class) - -## test_bubblebabble_instance() [](#method-i-test_bubblebabble_instance) - -## test_eq() [](#method-i-test_eq) - -## test_instance_eval() [](#method-i-test_instance_eval) - -## test_s_base64digest() [](#method-i-test_s_base64digest) - -## test_s_digest() [](#method-i-test_s_digest) - -## test_s_file() [](#method-i-test_s_file) - -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - -## test_s_new() [](#method-i-test_s_new) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/TestDigest/TestSHA384.md b/example/ruby/TestDigest/TestSHA384.md deleted file mode 100644 index a0db844..0000000 --- a/example/ruby/TestDigest/TestSHA384.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestDigest::TestSHA384 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigest - - - - - -#Instance Methods -## test_alignment() [](#method-i-test_alignment) - -## test_bubblebabble() [](#method-i-test_bubblebabble) - -## test_bubblebabble_class() [](#method-i-test_bubblebabble_class) - -## test_bubblebabble_instance() [](#method-i-test_bubblebabble_instance) - -## test_eq() [](#method-i-test_eq) - -## test_instance_eval() [](#method-i-test_instance_eval) - -## test_s_base64digest() [](#method-i-test_s_base64digest) - -## test_s_digest() [](#method-i-test_s_digest) - -## test_s_file() [](#method-i-test_s_file) - -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - -## test_s_new() [](#method-i-test_s_new) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/TestDigest/TestSHA512.md b/example/ruby/TestDigest/TestSHA512.md deleted file mode 100644 index 873b060..0000000 --- a/example/ruby/TestDigest/TestSHA512.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestDigest::TestSHA512 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigest - - - - - -#Instance Methods -## test_alignment() [](#method-i-test_alignment) - -## test_bubblebabble() [](#method-i-test_bubblebabble) - -## test_bubblebabble_class() [](#method-i-test_bubblebabble_class) - -## test_bubblebabble_instance() [](#method-i-test_bubblebabble_instance) - -## test_eq() [](#method-i-test_eq) - -## test_instance_eval() [](#method-i-test_instance_eval) - -## test_s_base64digest() [](#method-i-test_s_base64digest) - -## test_s_digest() [](#method-i-test_s_digest) - -## test_s_file() [](#method-i-test_s_file) - -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - -## test_s_new() [](#method-i-test_s_new) - -## test_update() [](#method-i-test_update) - diff --git a/example/ruby/TestDigestExtend.md b/example/ruby/TestDigestExtend.md deleted file mode 100644 index 8c3316f..0000000 --- a/example/ruby/TestDigestExtend.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: TestDigestExtend -**Inherits:** Test::Unit::TestCase - -**Extended by:** DifferentOFS - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_block_length() [](#method-i-test_block_length) - -## test_class_reset() [](#method-i-test_class_reset) - -## test_context() [](#method-i-test_context) - -## test_digest() [](#method-i-test_digest) - -## test_digest_hexdigest() [](#method-i-test_digest_hexdigest) - -## test_digest_hexdigest_bang() [](#method-i-test_digest_hexdigest_bang) - -## test_digest_length() [](#method-i-test_digest_length) -breaks @MyDigest#digest_length - -## test_digest_s_hexencode() [](#method-i-test_digest_s_hexencode) - -## test_hexdigest() [](#method-i-test_hexdigest) - -## test_length() [](#method-i-test_length) - -## test_new() [](#method-i-test_new) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestDigestExtend/MyDigest.md b/example/ruby/TestDigestExtend/MyDigest.md deleted file mode 100644 index 00eed24..0000000 --- a/example/ruby/TestDigestExtend/MyDigest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestDigestExtend::MyDigest -**Inherits:** Digest::Class - - - - - -#Instance Methods -## finish() [](#method-i-finish) - -## initialize(*arg) [](#method-i-initialize) - -**@return** [MyDigest] a new instance of MyDigest - -## initialize_copy(org) [](#method-i-initialize_copy) - -## reset() [](#method-i-reset) - -## update(arg) [](#method-i-update) - diff --git a/example/ruby/TestDigestRactor.md b/example/ruby/TestDigestRactor.md deleted file mode 100644 index dc8e7ec..0000000 --- a/example/ruby/TestDigestRactor.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestDigestRactor - - - - - -#Instance Methods -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - diff --git a/example/ruby/TestDigestRactor/TestMD5Ractor.md b/example/ruby/TestDigestRactor/TestMD5Ractor.md deleted file mode 100644 index 15168fb..0000000 --- a/example/ruby/TestDigestRactor/TestMD5Ractor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDigestRactor::TestMD5Ractor -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigestRactor - - - - - -#Instance Methods -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - diff --git a/example/ruby/TestDigestRactor/TestRMD160Ractor.md b/example/ruby/TestDigestRactor/TestRMD160Ractor.md deleted file mode 100644 index 8484f99..0000000 --- a/example/ruby/TestDigestRactor/TestRMD160Ractor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDigestRactor::TestRMD160Ractor -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigestRactor - - - - - -#Instance Methods -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - diff --git a/example/ruby/TestDigestRactor/TestSHA1Ractor.md b/example/ruby/TestDigestRactor/TestSHA1Ractor.md deleted file mode 100644 index 3bb50fc..0000000 --- a/example/ruby/TestDigestRactor/TestSHA1Ractor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDigestRactor::TestSHA1Ractor -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigestRactor - - - - - -#Instance Methods -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - diff --git a/example/ruby/TestDigestRactor/TestSHA256Ractor.md b/example/ruby/TestDigestRactor/TestSHA256Ractor.md deleted file mode 100644 index 555c78f..0000000 --- a/example/ruby/TestDigestRactor/TestSHA256Ractor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDigestRactor::TestSHA256Ractor -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigestRactor - - - - - -#Instance Methods -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - diff --git a/example/ruby/TestDigestRactor/TestSHA384Ractor.md b/example/ruby/TestDigestRactor/TestSHA384Ractor.md deleted file mode 100644 index 7f0de63..0000000 --- a/example/ruby/TestDigestRactor/TestSHA384Ractor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDigestRactor::TestSHA384Ractor -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigestRactor - - - - - -#Instance Methods -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - diff --git a/example/ruby/TestDigestRactor/TestSHA512Ractor.md b/example/ruby/TestDigestRactor/TestSHA512Ractor.md deleted file mode 100644 index 9dd7aa1..0000000 --- a/example/ruby/TestDigestRactor/TestSHA512Ractor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestDigestRactor::TestSHA512Ractor -**Inherits:** Test::Unit::TestCase - -**Includes:** TestDigestRactor - - - - - -#Instance Methods -## test_s_hexdigest() [](#method-i-test_s_hexdigest) - diff --git a/example/ruby/TestDir.md b/example/ruby/TestDir.md deleted file mode 100644 index eddb3d2..0000000 --- a/example/ruby/TestDir.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: TestDir -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_entries(entries, children_onlyfalse) [](#method-i-assert_entries) - -## setup() [](#method-i-setup) - -## setup_envs(envs%w"HOME LOGDIR")) [](#method-i-setup_envs) - -## teardown() [](#method-i-teardown) - -## test_chdir_conflict() [](#method-i-test_chdir_conflict) - -## test_children() [](#method-i-test_children) - -## test_chroot_nodir() [](#method-i-test_chroot_nodir) - -## test_class_chdir() [](#method-i-test_class_chdir) - -## test_close() [](#method-i-test_close) - -## test_dir_enc() [](#method-i-test_dir_enc) - -## test_each_child() [](#method-i-test_each_child) - -## test_empty?() [](#method-i-test_empty?) - -**@return** [Boolean] - -## test_entries() [](#method-i-test_entries) - -## test_fileno() [](#method-i-test_fileno) - -## test_for_fd() [](#method-i-test_for_fd) - -## test_foreach() [](#method-i-test_foreach) - -## test_glob() [](#method-i-test_glob) - -## test_glob_array_with_destructive_element() [](#method-i-test_glob_array_with_destructive_element) - -## test_glob_base() [](#method-i-test_glob_base) - -## test_glob_base_dir() [](#method-i-test_glob_base_dir) - -## test_glob_cases() [](#method-i-test_glob_cases) - -## test_glob_gc_for_fd() [](#method-i-test_glob_gc_for_fd) - -## test_glob_ignore_casefold_invalid_encoding() [](#method-i-test_glob_ignore_casefold_invalid_encoding) - -## test_glob_legacy_short_name() [](#method-i-test_glob_legacy_short_name) - -## test_glob_metachar() [](#method-i-test_glob_metachar) - -## test_glob_order() [](#method-i-test_glob_order) - -## test_glob_recursive() [](#method-i-test_glob_recursive) - -## test_glob_recursive_directory() [](#method-i-test_glob_recursive_directory) - -## test_glob_recursive_with_brace() [](#method-i-test_glob_recursive_with_brace) - -## test_glob_starts_with_brace() [](#method-i-test_glob_starts_with_brace) - -## test_glob_super_root() [](#method-i-test_glob_super_root) - -## test_glob_too_may_open_files() [](#method-i-test_glob_too_may_open_files) - -## test_home() [](#method-i-test_home) - -## test_home_at_startup_windows() [](#method-i-test_home_at_startup_windows) - -## test_home_utf8() [](#method-i-test_home_utf8) -On Windows and macOS, file system encoding is always UTF-8. - -## test_home_windows() [](#method-i-test_home_windows) - -## test_inspect() [](#method-i-test_inspect) - -## test_instance_chdir() [](#method-i-test_instance_chdir) - -## test_nodir() [](#method-i-test_nodir) - -## test_path() [](#method-i-test_path) - -## test_rewind() [](#method-i-test_rewind) - -## test_seek() [](#method-i-test_seek) - -## test_set_pos() [](#method-i-test_set_pos) - -## test_symlink() [](#method-i-test_symlink) - -## test_symlinks_not_resolved() [](#method-i-test_symlinks_not_resolved) - -## test_unknown_keywords() [](#method-i-test_unknown_keywords) - diff --git a/example/ruby/TestDir_M17N.md b/example/ruby/TestDir_M17N.md deleted file mode 100644 index 420e3ce..0000000 --- a/example/ruby/TestDir_M17N.md +++ /dev/null @@ -1,61 +0,0 @@ -# Class: TestDir_M17N -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_raw_file_name(code, encoding) [](#method-i-assert_raw_file_name) - -## test_entries_compose() [](#method-i-test_entries_compose) - -## test_error_nonascii() [](#method-i-test_error_nonascii) - -## test_filename_as_bytes_extutf8() [](#method-i-test_filename_as_bytes_extutf8) - -## test_filename_bytes_euc_jp() [](#method-i-test_filename_bytes_euc_jp) -others - -## test_filename_euc_jp() [](#method-i-test_filename_euc_jp) - -## test_filename_ext_euc_jp_and_int_utf_8() [](#method-i-test_filename_ext_euc_jp_and_int_utf_8) - -## test_filename_extutf8() [](#method-i-test_filename_extutf8) -UTF-8 default_external, no default_internal - -## test_filename_extutf8_inteucjp_representable() [](#method-i-test_filename_extutf8_inteucjp_representable) -UTF-8 default_external, EUC-JP default_internal - -## test_filename_extutf8_inteucjp_unrepresentable() [](#method-i-test_filename_extutf8_inteucjp_unrepresentable) - -## test_filename_extutf8_invalid() [](#method-i-test_filename_extutf8_invalid) - -## test_filename_utf8_raw_jp_name() [](#method-i-test_filename_utf8_raw_jp_name) - -## test_filename_utf8_raw_windows_1251_name() [](#method-i-test_filename_utf8_raw_windows_1251_name) - -## test_filename_utf8_raw_windows_1252_name() [](#method-i-test_filename_utf8_raw_windows_1252_name) - -## test_glob_compose() [](#method-i-test_glob_compose) - -## test_glob_encoding() [](#method-i-test_glob_encoding) - -## test_glob_escape_multibyte() [](#method-i-test_glob_escape_multibyte) - -## test_glob_incompatible() [](#method-i-test_glob_incompatible) - -## test_glob_warning_match_all() [](#method-i-test_glob_warning_match_all) - -## test_glob_warning_match_dir() [](#method-i-test_glob_warning_match_dir) - -## test_glob_warning_opendir() [](#method-i-test_glob_warning_opendir) - -## test_inspect_nonascii() [](#method-i-test_inspect_nonascii) - -## test_pwd() [](#method-i-test_pwd) - -## with_enc_path() [](#method-i-with_enc_path) - -## with_tmpdir() [](#method-i-with_tmpdir) - diff --git a/example/ruby/TestDup.md b/example/ruby/TestDup.md deleted file mode 100644 index ffae85e..0000000 --- a/example/ruby/TestDup.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestDup -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_dup() [](#method-i-test_dup) - -## test_frozen_properties_not_retained_on_dup() [](#method-i-test_frozen_properties_not_retained_on_dup) - -## test_frozen_properties_not_retained_on_dup_with_ivar() [](#method-i-test_frozen_properties_not_retained_on_dup_with_ivar) - -## test_ivar_retained_on_dup() [](#method-i-test_ivar_retained_on_dup) - -## test_ivars_retained_on_extended_obj_dup() [](#method-i-test_ivars_retained_on_extended_obj_dup) - -## test_user_flags() [](#method-i-test_user_flags) - diff --git a/example/ruby/TestDup/M001.md b/example/ruby/TestDup/M001.md deleted file mode 100644 index 7d4144b..0000000 --- a/example/ruby/TestDup/M001.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestDup::M001 - - - - - diff --git a/example/ruby/TestDup/M002.md b/example/ruby/TestDup/M002.md deleted file mode 100644 index c7dfcf4..0000000 --- a/example/ruby/TestDup/M002.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestDup::M002 - -**Includes:** TestDup::M001 - - - - - diff --git a/example/ruby/TestDup/M003.md b/example/ruby/TestDup/M003.md deleted file mode 100644 index 1aaf0dd..0000000 --- a/example/ruby/TestDup/M003.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestDup::M003 - -**Includes:** TestDup::M002 - - - - - diff --git a/example/ruby/TestE.md b/example/ruby/TestE.md deleted file mode 100644 index 89e73ec..0000000 --- a/example/ruby/TestE.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestE -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_always_fail() [](#method-i-test_always_fail) - -## test_always_skip() [](#method-i-test_always_skip) - -## test_not_fail() [](#method-i-test_not_fail) - -## test_skip_after_unknown_error() [](#method-i-test_skip_after_unknown_error) - -## test_unknown_error() [](#method-i-test_unknown_error) - -**@raise** [UnknownError] - diff --git a/example/ruby/TestE/UnknownError.md b/example/ruby/TestE/UnknownError.md deleted file mode 100644 index 9b1263e..0000000 --- a/example/ruby/TestE/UnknownError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestE::UnknownError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/TestEOF.md b/example/ruby/TestEOF.md deleted file mode 100644 index 649b031..0000000 --- a/example/ruby/TestEOF.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: TestEOF - - - - - -#Instance Methods -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - diff --git a/example/ruby/TestEOF/Seek.md b/example/ruby/TestEOF/Seek.md deleted file mode 100644 index d64688a..0000000 --- a/example/ruby/TestEOF/Seek.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: TestEOF::Seek - - - - - -#Instance Methods -## open_file_seek(content, pos) [](#method-i-open_file_seek) - -## test_eof_0_seek() [](#method-i-test_eof_0_seek) - -## test_eof_1_seek() [](#method-i-test_eof_1_seek) - diff --git a/example/ruby/TestERB.md b/example/ruby/TestERB.md deleted file mode 100644 index 10ea8ed..0000000 --- a/example/ruby/TestERB.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestERB -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_concurrent_default_binding() [](#method-i-test_concurrent_default_binding) - -## test_html_escape() [](#method-i-test_html_escape) - -## test_html_escape_extension() [](#method-i-test_html_escape_extension) - -## test_html_escape_to_s() [](#method-i-test_html_escape_to_s) - -## test_with_filename() [](#method-i-test_with_filename) - -## test_with_filename_and_safe_level() [](#method-i-test_with_filename_and_safe_level) -deprecated -: This will be removed later - - -## test_with_filename_lineno() [](#method-i-test_with_filename_lineno) - -## test_with_location() [](#method-i-test_with_location) - -## test_without_filename() [](#method-i-test_without_filename) - -## test_without_filename_with_safe_level() [](#method-i-test_without_filename_with_safe_level) -deprecated -: This will be removed later - - diff --git a/example/ruby/TestERB/MyError.md b/example/ruby/TestERB/MyError.md deleted file mode 100644 index 5e13478..0000000 --- a/example/ruby/TestERB/MyError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestERB::MyError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/TestERBCore.md b/example/ruby/TestERBCore.md deleted file mode 100644 index bd6d5f1..0000000 --- a/example/ruby/TestERBCore.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: TestERBCore -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## _test_core(safe) [](#method-i-_test_core) - -## setup() [](#method-i-setup) - -## test_core() [](#method-i-test_core) - -## test_def_class() [](#method-i-test_def_class) - -## test_def_erb_method() [](#method-i-test_def_erb_method) - -## test_def_method_with_fname() [](#method-i-test_def_method_with_fname) - -## test_def_method_without_filename() [](#method-i-test_def_method_without_filename) - -## test_def_module() [](#method-i-test_def_module) - -## test_deprecated_interface_warnings() [](#method-i-test_deprecated_interface_warnings) -deprecated -: These interfaces will be removed later - - -## test_escape() [](#method-i-test_escape) - -## test_explicit() [](#method-i-test_explicit) - -## test_explicit_trim_line_with_carriage_return() [](#method-i-test_explicit_trim_line_with_carriage_return) - -## test_frozen_string_literal() [](#method-i-test_frozen_string_literal) - -## test_half_working_comment_backward_compatibility() [](#method-i-test_half_working_comment_backward_compatibility) -Bug#14243 - -## test_invalid_trim_mode() [](#method-i-test_invalid_trim_mode) - -## test_keep_lineno() [](#method-i-test_keep_lineno) - -## test_multi_line_comment_lineno() [](#method-i-test_multi_line_comment_lineno) - -## test_percent() [](#method-i-test_percent) - -## test_percent_after_etag() [](#method-i-test_percent_after_etag) - -## test_prohibited_marshal_dump() [](#method-i-test_prohibited_marshal_dump) - -## test_prohibited_marshal_load() [](#method-i-test_prohibited_marshal_load) - -## test_result_with_hash() [](#method-i-test_result_with_hash) - -## test_result_with_hash_does_not_modify_caller_binding() [](#method-i-test_result_with_hash_does_not_modify_caller_binding) - -## test_result_with_hash_does_not_modify_toplevel_binding() [](#method-i-test_result_with_hash_does_not_modify_toplevel_binding) - -## test_result_with_hash_does_not_use_caller_local_variables() [](#method-i-test_result_with_hash_does_not_use_caller_local_variables) - -## test_result_with_hash_with_invalid_keys_raises_type_error() [](#method-i-test_result_with_hash_with_invalid_keys_raises_type_error) -This depends on the behavior that #local_variable_set raises TypeError by -invalid key. - -## test_run() [](#method-i-test_run) - -## test_token_extension() [](#method-i-test_token_extension) - -## test_trim_line1_with_carriage_return() [](#method-i-test_trim_line1_with_carriage_return) - -## test_trim_line2_with_carriage_return() [](#method-i-test_trim_line2_with_carriage_return) - -## test_url_encode() [](#method-i-test_url_encode) - -## test_version() [](#method-i-test_version) - diff --git a/example/ruby/TestERBCore/Foo.md b/example/ruby/TestERBCore/Foo.md deleted file mode 100644 index f455a41..0000000 --- a/example/ruby/TestERBCore/Foo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestERBCore::Foo -**Inherits:** Object - - - - - diff --git a/example/ruby/TestERBCoreWOStrScan.md b/example/ruby/TestERBCoreWOStrScan.md deleted file mode 100644 index 7a2fdd9..0000000 --- a/example/ruby/TestERBCoreWOStrScan.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestERBCoreWOStrScan -**Inherits:** TestERBCore - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/TestERBEncoding.md b/example/ruby/TestERBEncoding.md deleted file mode 100644 index 684e38c..0000000 --- a/example/ruby/TestERBEncoding.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestERBEncoding -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test___ENCODING__() [](#method-i-test___ENCODING__) - -## test_generate_magic_comment() [](#method-i-test_generate_magic_comment) - -## test_literal_encoding() [](#method-i-test_literal_encoding) - -## test_method_with_encoding() [](#method-i-test_method_with_encoding) - -## test_recognize_magic_comment() [](#method-i-test_recognize_magic_comment) - -## test_result_encoding() [](#method-i-test_result_encoding) - diff --git a/example/ruby/TestERBEncoding/M.md b/example/ruby/TestERBEncoding/M.md deleted file mode 100644 index 0f690fa..0000000 --- a/example/ruby/TestERBEncoding/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestERBEncoding::M - - - - - diff --git a/example/ruby/TestEUC_JP.md b/example/ruby/TestEUC_JP.md deleted file mode 100644 index 0164f4f..0000000 --- a/example/ruby/TestEUC_JP.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestEUC_JP -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_charboundary() [](#method-i-test_charboundary) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_property() [](#method-i-test_property) - diff --git a/example/ruby/TestEmojiBreaks.md b/example/ruby/TestEmojiBreaks.md deleted file mode 100644 index 8d92363..0000000 --- a/example/ruby/TestEmojiBreaks.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TestEmojiBreaks -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## data_files_available?() [](#method-c-data_files_available?) -**@return** [Boolean] - - -#Instance Methods -## all_tests() [](#method-i-all_tests) - -## read_data() [](#method-i-read_data) - -## test_data_files_available() [](#method-i-test_data_files_available) - -## test_embedded_emoji() [](#method-i-test_embedded_emoji) - -## test_mixed_emoji() [](#method-i-test_mixed_emoji) -test some pseodorandom combinations of emoji - -## test_single_emoji() [](#method-i-test_single_emoji) - diff --git a/example/ruby/TestEmojiBreaks/BreakFile.md b/example/ruby/TestEmojiBreaks/BreakFile.md deleted file mode 100644 index e3219fc..0000000 --- a/example/ruby/TestEmojiBreaks/BreakFile.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestEmojiBreaks::BreakFile -**Inherits:** Object - - - - -# Class Methods -## files() [](#method-c-files) -# Attributes -## basename[RW] [](#attribute-i-basename) -Returns the value of attribute basename. - -## fullname[RW] [](#attribute-i-fullname) -Returns the value of attribute fullname. - -## version[RW] [](#attribute-i-version) -Returns the value of attribute version. - - -#Instance Methods -## initialize(basename, path, version) [](#method-i-initialize) - -**@return** [BreakFile] a new instance of BreakFile - diff --git a/example/ruby/TestEmojiBreaks/BreakTest.md b/example/ruby/TestEmojiBreaks/BreakTest.md deleted file mode 100644 index 3302092..0000000 --- a/example/ruby/TestEmojiBreaks/BreakTest.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: TestEmojiBreaks::BreakTest -**Inherits:** Object - - - - -# Attributes -## comment[RW] [](#attribute-i-comment) -Returns the value of attribute comment. - -## filename[RW] [](#attribute-i-filename) -Returns the value of attribute filename. - -## line_number[RW] [](#attribute-i-line_number) -Returns the value of attribute line_number. - -## shortname[RW] [](#attribute-i-shortname) -Returns the value of attribute shortname. - -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - -## type[RW] [](#attribute-i-type) -Returns the value of attribute type. - - -#Instance Methods -## initialize(filename, line_number, data, comment'') [](#method-i-initialize) - -**@return** [BreakTest] a new instance of BreakTest - diff --git a/example/ruby/TestEncoding.md b/example/ruby/TestEncoding.md deleted file mode 100644 index 4e8e82d..0000000 --- a/example/ruby/TestEncoding.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: TestEncoding -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_aliases() [](#method-i-test_aliases) - -## test_ascii_compatible_p() [](#method-i-test_ascii_compatible_p) - -## test_compatible_p() [](#method-i-test_compatible_p) - -## test_dummy_p() [](#method-i-test_dummy_p) - -## test_enc_names() [](#method-i-test_enc_names) - -## test_encoding() [](#method-i-test_encoding) -Test basic encoding methods: list, find, name - -## test_errinfo_after_autoload() [](#method-i-test_errinfo_after_autoload) - -## test_find() [](#method-i-test_find) - -## test_marshal() [](#method-i-test_marshal) - -## test_name_list() [](#method-i-test_name_list) - -## test_nonascii_library_path() [](#method-i-test_nonascii_library_path) - -## test_ractor_load_encoding() [](#method-i-test_ractor_load_encoding) - -## test_singleton() [](#method-i-test_singleton) -Test that Encoding objects can't be copied And that they can be compared by -object_id - diff --git a/example/ruby/TestEncodingConverter.md b/example/ruby/TestEncodingConverter.md deleted file mode 100644 index c543756..0000000 --- a/example/ruby/TestEncodingConverter.md +++ /dev/null @@ -1,180 +0,0 @@ -# Class: TestEncodingConverter -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_econv(converted, eres, obuf_bytesize, ec, consumed, rest, optsnil) [](#method-i-assert_econv) - -## assert_errinfo(e_res, e_enc1, e_enc2, e_error_bytes, e_readagain_bytes, ec) [](#method-i-assert_errinfo) - -## check_ec(edst, esrc, eres, dst, src, ec, off, len, optsnil) [](#method-i-check_ec) - -## test_88591() [](#method-i-test_88591) - -## test_accumulate_dst1() [](#method-i-test_accumulate_dst1) - -## test_accumulate_dst2() [](#method-i-test_accumulate_dst2) - -## test_after_output() [](#method-i-test_after_output) - -## test_asciicompat_encoding_iso2022jp() [](#method-i-test_asciicompat_encoding_iso2022jp) - -## test_convert() [](#method-i-test_convert) - -## test_convpath() [](#method-i-test_convpath) - -## test_cr_newline() [](#method-i-test_cr_newline) - -## test_cr_newline2() [](#method-i-test_cr_newline2) - -## test_crlf_newline() [](#method-i-test_crlf_newline) - -## test_crlf_newline2() [](#method-i-test_crlf_newline2) - -## test_default_external() [](#method-i-test_default_external) - -## test_econv_new_hash() [](#method-i-test_econv_new_hash) - -## test_errinfo_invalid_euc_jp() [](#method-i-test_errinfo_invalid_euc_jp) - -## test_errinfo_invalid_euc_jp2() [](#method-i-test_errinfo_invalid_euc_jp2) - -## test_errinfo_invalid_partial_character() [](#method-i-test_errinfo_invalid_partial_character) - -## test_errinfo_invalid_utf16be() [](#method-i-test_errinfo_invalid_utf16be) - -## test_errinfo_invalid_utf16le() [](#method-i-test_errinfo_invalid_utf16le) - -## test_errinfo_undefined_hiragana() [](#method-i-test_errinfo_undefined_hiragana) - -## test_errinfo_valid_partial_character() [](#method-i-test_errinfo_valid_partial_character) - -## test_errors() [](#method-i-test_errors) - -## test_errors2() [](#method-i-test_errors2) - -## test_eucjp_to_utf8() [](#method-i-test_eucjp_to_utf8) - -## test_exc_incomplete() [](#method-i-test_exc_incomplete) - -## test_exc_invalid() [](#method-i-test_exc_invalid) - -## test_exc_undef() [](#method-i-test_exc_undef) - -## test_finish_incomplete_error() [](#method-i-test_finish_incomplete_error) - -## test_finish_iso2022jp() [](#method-i-test_finish_iso2022jp) - -## test_get_encoding() [](#method-i-test_get_encoding) - -## test_get_replacement() [](#method-i-test_get_replacement) - -## test_hex_charref() [](#method-i-test_hex_charref) - -## test_invalid() [](#method-i-test_invalid) - -## test_invalid2() [](#method-i-test_invalid2) - -## test_invalid3() [](#method-i-test_invalid3) - -## test_invalid4() [](#method-i-test_invalid4) - -## test_invalid_ignore() [](#method-i-test_invalid_ignore) - -## test_invalid_replace() [](#method-i-test_invalid_replace) - -## test_invalid_replace2() [](#method-i-test_invalid_replace2) - -## test_invalid_utf16be() [](#method-i-test_invalid_utf16be) - -## test_invalid_utf16le() [](#method-i-test_invalid_utf16le) - -## test_invalid_utf32be() [](#method-i-test_invalid_utf32be) - -## test_invalid_utf32le() [](#method-i-test_invalid_utf32le) - -## test_iso2022jp() [](#method-i-test_iso2022jp) - -## test_iso2022jp_decode() [](#method-i-test_iso2022jp_decode) - -## test_iso2022jp_encode() [](#method-i-test_iso2022jp_encode) - -## test_iso2022jp_invalid_replace() [](#method-i-test_iso2022jp_invalid_replace) - -## test_last_error1() [](#method-i-test_last_error1) - -## test_last_error2() [](#method-i-test_last_error2) - -## test_newline_converter_with_ascii_incompatible() [](#method-i-test_newline_converter_with_ascii_incompatible) - -## test_newline_option() [](#method-i-test_newline_option) - -## test_nil_destination_bytesize() [](#method-i-test_nil_destination_bytesize) - -## test_nil_destination_bytesize2() [](#method-i-test_nil_destination_bytesize2) - -## test_nil_destination_bytesize_with_nonnil_byteoffset() [](#method-i-test_nil_destination_bytesize_with_nonnil_byteoffset) - -## test_nil_source_buffer() [](#method-i-test_nil_source_buffer) - -## test_no_universal_newline1() [](#method-i-test_no_universal_newline1) - -## test_no_universal_newline2() [](#method-i-test_no_universal_newline2) - -## test_noconv() [](#method-i-test_noconv) - -## test_noconv_after_output() [](#method-i-test_noconv_after_output) - -## test_noconv_insert_output() [](#method-i-test_noconv_insert_output) - -## test_noconv_partial() [](#method-i-test_noconv_partial) - -## test_output_iso2022jp() [](#method-i-test_output_iso2022jp) - -## test_output_region() [](#method-i-test_output_region) - -## test_partial_input() [](#method-i-test_partial_input) - -## test_putback() [](#method-i-test_putback) - -## test_putback2() [](#method-i-test_putback2) - -## test_result_encoding() [](#method-i-test_result_encoding) - -## test_s_asciicompat_encoding() [](#method-i-test_s_asciicompat_encoding) - -## test_s_new() [](#method-i-test_s_new) - -## test_s_new_convpath() [](#method-i-test_s_new_convpath) - -## test_s_new_fail() [](#method-i-test_s_new_fail) - -## test_search_convpath() [](#method-i-test_search_convpath) - -## test_set_replacement() [](#method-i-test_set_replacement) - -## test_undef_ignore() [](#method-i-test_undef_ignore) - -## test_undef_replace() [](#method-i-test_undef_replace) - -## test_universal_newline() [](#method-i-test_universal_newline) - -## test_universal_newline2() [](#method-i-test_universal_newline2) - -## test_universal_newline3() [](#method-i-test_universal_newline3) - -## test_us_ascii() [](#method-i-test_us_ascii) - -## test_xml_escape_attr_content() [](#method-i-test_xml_escape_attr_content) - -## test_xml_escape_attr_quote() [](#method-i-test_xml_escape_attr_quote) - -## test_xml_escape_text() [](#method-i-test_xml_escape_text) - -## test_xml_escape_with_charref() [](#method-i-test_xml_escape_with_charref) - -## test_xml_hasharg() [](#method-i-test_xml_hasharg) - diff --git a/example/ruby/TestEnsureAndCallcc.md b/example/ruby/TestEnsureAndCallcc.md deleted file mode 100644 index 4c1b5a5..0000000 --- a/example/ruby/TestEnsureAndCallcc.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestEnsureAndCallcc -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_bug20655_dir_chdir_using_rb_ensure() [](#method-i-test_bug20655_dir_chdir_using_rb_ensure) - -## test_bug20655_extension_using_rb_ensure() [](#method-i-test_bug20655_extension_using_rb_ensure) - diff --git a/example/ruby/TestEnumerable.md b/example/ruby/TestEnumerable.md deleted file mode 100644 index 08b3796..0000000 --- a/example/ruby/TestEnumerable.md +++ /dev/null @@ -1,194 +0,0 @@ -# Class: TestEnumerable -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## each(foo: ) [](#method-c-each) -**@yield** [foo] - - -#Instance Methods -## assert_complex_equal(e, v, msgnil) [](#method-i-assert_complex_equal) - -## assert_float_equal(e, v, msgnil) [](#method-i-assert_float_equal) - -## assert_int_equal(e, v, msgnil) [](#method-i-assert_int_equal) - -## assert_rational_equal(e, v, msgnil) [](#method-i-assert_rational_equal) - -## assert_typed_equal(e, v, cls, msgnil) [](#method-i-assert_typed_equal) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_all() [](#method-i-test_all) - -## test_all_fast() [](#method-i-test_all_fast) - -## test_all_with_unused_block() [](#method-i-test_all_with_unused_block) - -## test_any() [](#method-i-test_any) - -## test_any_with_unused_block() [](#method-i-test_any_with_unused_block) - -## test_callcc() [](#method-i-test_callcc) - -## test_chunk() [](#method-i-test_chunk) - -## test_chunk_while_contiguously_increasing_integers() [](#method-i-test_chunk_while_contiguously_increasing_integers) - -## test_compact() [](#method-i-test_compact) - -## test_count() [](#method-i-test_count) - -## test_cycle() [](#method-i-test_cycle) - -## test_detect() [](#method-i-test_detect) - -## test_drop() [](#method-i-test_drop) - -## test_drop_while() [](#method-i-test_drop_while) - -## test_each_cons() [](#method-i-test_each_cons) - -## test_each_entry() [](#method-i-test_each_entry) - -## test_each_slice() [](#method-i-test_each_slice) - -## test_each_with_index() [](#method-i-test_each_with_index) - -## test_each_with_object() [](#method-i-test_each_with_object) - -## test_filter_map() [](#method-i-test_filter_map) - -## test_find() [](#method-i-test_find) - -## test_find_all() [](#method-i-test_find_all) - -## test_find_index() [](#method-i-test_find_index) - -## test_first() [](#method-i-test_first) - -## test_flat_map() [](#method-i-test_flat_map) - -## test_grep() [](#method-i-test_grep) - -## test_grep_optimization() [](#method-i-test_grep_optimization) - -## test_grep_v() [](#method-i-test_grep_v) - -## test_group_by() [](#method-i-test_group_by) - -## test_hash_sum() [](#method-i-test_hash_sum) - -## test_inject() [](#method-i-test_inject) - -## test_inject_array_mul() [](#method-i-test_inject_array_mul) - -## test_inject_array_op_private() [](#method-i-test_inject_array_op_private) - -## test_inject_array_op_redefined() [](#method-i-test_inject_array_op_redefined) - -## test_inject_array_plus() [](#method-i-test_inject_array_plus) - -## test_inject_op_private() [](#method-i-test_inject_op_private) - -## test_inject_op_redefined() [](#method-i-test_inject_op_redefined) - -## test_map() [](#method-i-test_map) - -## test_max() [](#method-i-test_max) - -## test_max_by() [](#method-i-test_max_by) - -## test_member() [](#method-i-test_member) - -## test_min() [](#method-i-test_min) - -## test_min_by() [](#method-i-test_min_by) - -## test_minmax() [](#method-i-test_minmax) - -## test_minmax_by() [](#method-i-test_minmax_by) - -## test_none() [](#method-i-test_none) - -## test_none_with_unused_block() [](#method-i-test_none_with_unused_block) - -## test_one() [](#method-i-test_one) - -## test_one_with_unused_block() [](#method-i-test_one_with_unused_block) - -## test_partition() [](#method-i-test_partition) - -## test_range_sum() [](#method-i-test_range_sum) - -## test_refine_Enumerable_then_include() [](#method-i-test_refine_Enumerable_then_include) - -## test_reject() [](#method-i-test_reject) - -## test_reverse_each() [](#method-i-test_reverse_each) - -## test_reverse_each_memory_corruption() [](#method-i-test_reverse_each_memory_corruption) - -## test_ruby_svar() [](#method-i-test_ruby_svar) - -## test_select() [](#method-i-test_select) - -## test_slice_after0() [](#method-i-test_slice_after0) - -## test_slice_after1() [](#method-i-test_slice_after1) - -## test_slice_after_both_pattern_and_block() [](#method-i-test_slice_after_both_pattern_and_block) - -## test_slice_after_continuation_lines() [](#method-i-test_slice_after_continuation_lines) - -## test_slice_before() [](#method-i-test_slice_before) - -## test_slice_before_empty_line() [](#method-i-test_slice_before_empty_line) - -## test_slice_when_0() [](#method-i-test_slice_when_0) - -## test_slice_when_1() [](#method-i-test_slice_when_1) - -## test_slice_when_2() [](#method-i-test_slice_when_2) - -## test_slice_when_3() [](#method-i-test_slice_when_3) - -## test_slice_when_contiguously_increasing_integers() [](#method-i-test_slice_when_contiguously_increasing_integers) - -## test_slice_when_noblock() [](#method-i-test_slice_when_noblock) - -## test_sort() [](#method-i-test_sort) - -## test_sort_by() [](#method-i-test_sort_by) - -## test_sum() [](#method-i-test_sum) - -## test_take() [](#method-i-test_take) - -## test_take_while() [](#method-i-test_take_while) - -## test_tally() [](#method-i-test_tally) - -## test_to_a() [](#method-i-test_to_a) - -## test_to_a_keywords() [](#method-i-test_to_a_keywords) - -## test_to_a_size_infinity() [](#method-i-test_to_a_size_infinity) - -## test_to_a_size_symbol() [](#method-i-test_to_a_size_symbol) - -## test_to_h() [](#method-i-test_to_h) - -## test_to_h_block() [](#method-i-test_to_h_block) - -## test_transient_heap_sort_by() [](#method-i-test_transient_heap_sort_by) - -## test_uniq() [](#method-i-test_uniq) - -## test_zip() [](#method-i-test_zip) - diff --git a/example/ruby/TestEnumerable/Foo.md b/example/ruby/TestEnumerable/Foo.md deleted file mode 100644 index d39b00b..0000000 --- a/example/ruby/TestEnumerable/Foo.md +++ /dev/null @@ -1,2072 +0,0 @@ -# Class: TestEnumerable::Foo -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each() [](#method-i-each) - -**@yield** [1] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/TestEnumerator.md b/example/ruby/TestEnumerator.md deleted file mode 100644 index a7ad4a4..0000000 --- a/example/ruby/TestEnumerator.md +++ /dev/null @@ -1,158 +0,0 @@ -# Class: TestEnumerator -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## each() [](#method-c-each) -**@yield** [:ok1] - -## size() [](#method-c-size) - -#Instance Methods -## check_consistency_for_combinatorics(method) [](#method-i-check_consistency_for_combinatorics) - -## enum_test(obj) [](#method-i-enum_test) - -## setup() [](#method-i-setup) - -## test_chain_each_lambda() [](#method-i-test_chain_each_lambda) - -## test_chain_undef_methods() [](#method-i-test_chain_undef_methods) - -## test_chain_with_index() [](#method-i-test_chain_with_index) - -## test_chained_enums() [](#method-i-test_chained_enums) - -## test_compact() [](#method-i-test_compact) - -## test_cons() [](#method-i-test_cons) - -## test_each_arg() [](#method-i-test_each_arg) - -## test_each_slice_size() [](#method-i-test_each_slice_size) - -## test_enum_chain_and_plus() [](#method-i-test_enum_chain_and_plus) - -## test_feed() [](#method-i-test_feed) - -## test_feed_before_first_next() [](#method-i-test_feed_before_first_next) - -## test_feed_mixed() [](#method-i-test_feed_mixed) - -## test_feed_twice() [](#method-i-test_feed_twice) - -## test_feed_yielder() [](#method-i-test_feed_yielder) - -## test_freeze() [](#method-i-test_freeze) - -## test_gc() [](#method-i-test_gc) - -## test_generator() [](#method-i-test_generator) - -## test_generator_args() [](#method-i-test_generator_args) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_copy() [](#method-i-test_initialize_copy) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect_encoding() [](#method-i-test_inspect_encoding) - -## test_inspect_verbose() [](#method-i-test_inspect_verbose) - -## test_iterators() [](#method-i-test_iterators) - -## test_lazy_chain() [](#method-i-test_lazy_chain) - -## test_lazy_chain_under_gc_compact_stress() [](#method-i-test_lazy_chain_under_gc_compact_stress) - -## test_loop() [](#method-i-test_loop) - -## test_loop_return_value() [](#method-i-test_loop_return_value) - -## test_nested_iteration() [](#method-i-test_nested_iteration) - -## test_next() [](#method-i-test_next) -Enumerator as Iterator - -## test_next_after_stopiteration() [](#method-i-test_next_after_stopiteration) - -## test_next_rewind() [](#method-i-test_next_rewind) - -## test_next_values() [](#method-i-test_next_values) - -## test_peek() [](#method-i-test_peek) - -## test_peek_for_enumerator_objects() [](#method-i-test_peek_for_enumerator_objects) - -## test_peek_modify() [](#method-i-test_peek_modify) - -## test_peek_values() [](#method-i-test_peek_values) - -## test_peek_values_modify() [](#method-i-test_peek_values_modify) - -## test_produce() [](#method-i-test_produce) - -## test_product_new() [](#method-i-test_product_new) - -## test_rewind_clear_feed() [](#method-i-test_rewind_clear_feed) - -## test_s_product() [](#method-i-test_s_product) - -## test_size() [](#method-i-test_size) - -## test_size_for_array_combinatorics() [](#method-i-test_size_for_array_combinatorics) - -## test_size_for_cycle() [](#method-i-test_size_for_cycle) - -## test_size_for_downup_to() [](#method-i-test_size_for_downup_to) - -## test_size_for_each_cons() [](#method-i-test_size_for_each_cons) - -## test_size_for_each_slice() [](#method-i-test_size_for_each_slice) - -## test_size_for_enum_created_by_enumerators() [](#method-i-test_size_for_enum_created_by_enumerators) - -## test_size_for_enum_created_from_array() [](#method-i-test_size_for_enum_created_from_array) - -## test_size_for_enum_created_from_enumerable() [](#method-i-test_size_for_enum_created_from_enumerable) - -## test_size_for_enum_created_from_env() [](#method-i-test_size_for_enum_created_from_env) - -## test_size_for_enum_created_from_hash() [](#method-i-test_size_for_enum_created_from_hash) - -## test_size_for_enum_created_from_struct() [](#method-i-test_size_for_enum_created_from_struct) - -## test_size_for_loops() [](#method-i-test_size_for_loops) - -## test_size_for_step() [](#method-i-test_size_for_step) - -## test_size_for_string() [](#method-i-test_size_for_string) - -## test_slice() [](#method-i-test_slice) - -## test_stop_result() [](#method-i-test_stop_result) - -## test_stopiteration_rescue() [](#method-i-test_stopiteration_rescue) - -## test_uniq() [](#method-i-test_uniq) - -## test_with_index() [](#method-i-test_with_index) - -## test_with_index_dangling_memo() [](#method-i-test_with_index_dangling_memo) - -## test_with_index_large_offset() [](#method-i-test_with_index_large_offset) - -## test_with_index_nonnum_offset() [](#method-i-test_with_index_nonnum_offset) - -## test_with_index_string_offset() [](#method-i-test_with_index_string_offset) - -## test_with_index_under_gc_compact_stress() [](#method-i-test_with_index_under_gc_compact_stress) - -## test_with_object() [](#method-i-test_with_object) - -## test_yielder() [](#method-i-test_yielder) - diff --git a/example/ruby/TestEnumeratorKw.md b/example/ruby/TestEnumeratorKw.md deleted file mode 100644 index 61ac636..0000000 --- a/example/ruby/TestEnumeratorKw.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestEnumeratorKw -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_enumerator_kw() [](#method-i-test_enumerator_kw) - diff --git a/example/ruby/TestEnv.md b/example/ruby/TestEnv.md deleted file mode 100644 index f52d503..0000000 --- a/example/ruby/TestEnv.md +++ /dev/null @@ -1,228 +0,0 @@ -# Class: TestEnv -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_equal_env(as, bs) [](#method-i-assert_equal_env) - -## assert_invalid_env(msgnil) [](#method-i-assert_invalid_env) - -## ignore_case_str() [](#method-i-ignore_case_str) - -## setup() [](#method-i-setup) - -## str_for_assert_raise_on_yielded_exception_class(expected_error_class, ractor_var) [](#method-i-str_for_assert_raise_on_yielded_exception_class) - -## str_for_yielding_exception_class(code_str, exception_var:"raised_exception") [](#method-i-str_for_yielding_exception_class) - -## str_to_receive_invalid_envvar_errors(ractor_var) [](#method-i-str_to_receive_invalid_envvar_errors) - -## str_to_yield_invalid_envvar_errors(var_name, code_str) [](#method-i-str_to_yield_invalid_envvar_errors) - -## teardown() [](#method-i-teardown) - -## test_aset() [](#method-i-test_aset) - -## test_aset_in_ractor() [](#method-i-test_aset_in_ractor) - -## test_assoc() [](#method-i-test_assoc) - -## test_assoc_in_ractor() [](#method-i-test_assoc_in_ractor) - -## test_bracket() [](#method-i-test_bracket) - -## test_bracket_in_ractor() [](#method-i-test_bracket_in_ractor) - -## test_clear() [](#method-i-test_clear) - -## test_clear_in_ractor() [](#method-i-test_clear_in_ractor) - -## test_clone() [](#method-i-test_clone) - -## test_delete() [](#method-i-test_delete) - -## test_delete_if() [](#method-i-test_delete_if) - -## test_delete_if_in_ractor() [](#method-i-test_delete_if_in_ractor) - -## test_delete_in_ractor() [](#method-i-test_delete_in_ractor) - -## test_dup() [](#method-i-test_dup) - -## test_dup_in_ractor() [](#method-i-test_dup_in_ractor) - -## test_each_key() [](#method-i-test_each_key) - -## test_each_key_in_ractor() [](#method-i-test_each_key_in_ractor) - -## test_each_pair() [](#method-i-test_each_pair) - -## test_each_pair_in_ractor() [](#method-i-test_each_pair_in_ractor) - -## test_each_value() [](#method-i-test_each_value) - -## test_each_value_in_ractor() [](#method-i-test_each_value_in_ractor) - -## test_empty_p() [](#method-i-test_empty_p) - -## test_empty_p_in_ractor() [](#method-i-test_empty_p_in_ractor) - -## test_except() [](#method-i-test_except) - -## test_except_in_ractor() [](#method-i-test_except_in_ractor) - -## test_fetch() [](#method-i-test_fetch) - -## test_fetch_in_ractor() [](#method-i-test_fetch_in_ractor) - -## test_filter() [](#method-i-test_filter) - -## test_filter_bang() [](#method-i-test_filter_bang) - -## test_filter_bang_in_ractor() [](#method-i-test_filter_bang_in_ractor) - -## test_filter_in_ractor() [](#method-i-test_filter_in_ractor) - -## test_frozen() [](#method-i-test_frozen) - -## test_frozen_env() [](#method-i-test_frozen_env) - -## test_frozen_env_in_ractor() [](#method-i-test_frozen_env_in_ractor) - -## test_frozen_in_ractor() [](#method-i-test_frozen_in_ractor) - -## test_getenv() [](#method-i-test_getenv) - -## test_getenv_in_ractor() [](#method-i-test_getenv_in_ractor) - -## test_has_key() [](#method-i-test_has_key) - -## test_has_key_in_ractor() [](#method-i-test_has_key_in_ractor) - -## test_has_value() [](#method-i-test_has_value) - -## test_has_value2() [](#method-i-test_has_value2) - -## test_has_value2_in_ractor() [](#method-i-test_has_value2_in_ractor) - -## test_has_value_in_ractor() [](#method-i-test_has_value_in_ractor) - -## test_huge_value() [](#method-i-test_huge_value) - -## test_huge_value_in_ractor() [](#method-i-test_huge_value_in_ractor) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect_encoding() [](#method-i-test_inspect_encoding) - -## test_inspect_in_ractor() [](#method-i-test_inspect_in_ractor) - -## test_invert() [](#method-i-test_invert) - -## test_invert_in_ractor() [](#method-i-test_invert_in_ractor) - -## test_ivar_in_env_should_not_be_access_from_non_main_ractors() [](#method-i-test_ivar_in_env_should_not_be_access_from_non_main_ractors) - -## test_keep_if() [](#method-i-test_keep_if) - -## test_keep_if_in_ractor() [](#method-i-test_keep_if_in_ractor) - -## test_key() [](#method-i-test_key) - -## test_key_in_ractor() [](#method-i-test_key_in_ractor) - -## test_keys() [](#method-i-test_keys) - -## test_keys_in_ractor() [](#method-i-test_keys_in_ractor) - -## test_memory_crash_select() [](#method-i-test_memory_crash_select) - -## test_memory_leak_aset() [](#method-i-test_memory_leak_aset) - -## test_memory_leak_select() [](#method-i-test_memory_leak_select) - -## test_memory_leak_shift() [](#method-i-test_memory_leak_shift) - -## test_rassoc() [](#method-i-test_rassoc) - -## test_rassoc_in_ractor() [](#method-i-test_rassoc_in_ractor) - -## test_rehash() [](#method-i-test_rehash) - -## test_rehash_in_ractor() [](#method-i-test_rehash_in_ractor) - -## test_reject() [](#method-i-test_reject) - -## test_reject_bang() [](#method-i-test_reject_bang) - -## test_reject_bang_in_ractor() [](#method-i-test_reject_bang_in_ractor) - -## test_reject_in_ractor() [](#method-i-test_reject_in_ractor) - -## test_replace() [](#method-i-test_replace) - -## test_replace_in_ractor() [](#method-i-test_replace_in_ractor) - -## test_select() [](#method-i-test_select) - -## test_select_bang() [](#method-i-test_select_bang) - -## test_select_bang_in_ractor() [](#method-i-test_select_bang_in_ractor) - -## test_select_in_ractor() [](#method-i-test_select_in_ractor) - -## test_shared_substring() [](#method-i-test_shared_substring) - -## test_shared_substring_in_ractor() [](#method-i-test_shared_substring_in_ractor) - -## test_shift() [](#method-i-test_shift) - -## test_shift_in_ractor() [](#method-i-test_shift_in_ractor) - -## test_size() [](#method-i-test_size) - -## test_size_in_ractor() [](#method-i-test_size_in_ractor) - -## test_slice() [](#method-i-test_slice) - -## test_slice_in_ractor() [](#method-i-test_slice_in_ractor) - -## test_to_a() [](#method-i-test_to_a) - -## test_to_a_in_ractor() [](#method-i-test_to_a_in_ractor) - -## test_to_h() [](#method-i-test_to_h) - -## test_to_h_in_ractor() [](#method-i-test_to_h_in_ractor) - -## test_to_hash() [](#method-i-test_to_hash) - -## test_to_hash_in_ractor() [](#method-i-test_to_hash_in_ractor) - -## test_to_s() [](#method-i-test_to_s) - -## test_to_s_in_ractor() [](#method-i-test_to_s_in_ractor) - -## test_update() [](#method-i-test_update) - -## test_update_in_ractor() [](#method-i-test_update_in_ractor) - -## test_utf8() [](#method-i-test_utf8) - -## test_utf8_empty() [](#method-i-test_utf8_empty) - -## test_values() [](#method-i-test_values) - -## test_values_at() [](#method-i-test_values_at) - -## test_values_at_in_ractor() [](#method-i-test_values_at_in_ractor) - -## test_values_in_ractor() [](#method-i-test_values_in_ractor) - -## test_win32_blocksize() [](#method-i-test_win32_blocksize) - -## windows_version() [](#method-i-windows_version) - diff --git a/example/ruby/TestErbCommand.md b/example/ruby/TestErbCommand.md deleted file mode 100644 index 980a6bb..0000000 --- a/example/ruby/TestErbCommand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestErbCommand -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_template_file_encoding() [](#method-i-test_template_file_encoding) - -## test_var() [](#method-i-test_var) - diff --git a/example/ruby/TestErrInCallBack.md b/example/ruby/TestErrInCallBack.md deleted file mode 100644 index ed15ebf..0000000 --- a/example/ruby/TestErrInCallBack.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestErrInCallBack -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## available_adodb?() [](#method-i-available_adodb?) - -**@return** [Boolean] - -## setup() [](#method-i-setup) - -## test_err_in_callback() [](#method-i-test_err_in_callback) - diff --git a/example/ruby/TestEtc.md b/example/ruby/TestEtc.md deleted file mode 100644 index 28d3c2e..0000000 --- a/example/ruby/TestEtc.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestEtc -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_confstr() [](#method-i-test_confstr) - -## test_getgrgid() [](#method-i-test_getgrgid) - -## test_getgrnam() [](#method-i-test_getgrnam) - -## test_getlogin() [](#method-i-test_getlogin) - -## test_getpwnam() [](#method-i-test_getpwnam) - -## test_getpwuid() [](#method-i-test_getpwuid) - -## test_group() [](#method-i-test_group) - -## test_group_with_low_level_api() [](#method-i-test_group_with_low_level_api) - -## test_nprocessors() [](#method-i-test_nprocessors) - -## test_passwd() [](#method-i-test_passwd) - -## test_passwd_with_low_level_api() [](#method-i-test_passwd_with_low_level_api) - -## test_pathconf() [](#method-i-test_pathconf) - -## test_ractor() [](#method-i-test_ractor) - -## test_sysconf() [](#method-i-test_sysconf) - -## test_sysconfdir() [](#method-i-test_sysconfdir) - -## test_uname() [](#method-i-test_uname) - diff --git a/example/ruby/TestEucKr.md b/example/ruby/TestEucKr.md deleted file mode 100644 index ec7f59d..0000000 --- a/example/ruby/TestEucKr.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestEucKr -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## s(s) [](#method-i-s) - -## test_code_to_mbc() [](#method-i-test_code_to_mbc) - -## test_euro_sign() [](#method-i-test_euro_sign) - -## test_left_adjust_char_head() [](#method-i-test_left_adjust_char_head) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_mbc_enc_len() [](#method-i-test_mbc_enc_len) - -## test_mbc_to_code() [](#method-i-test_mbc_to_code) - -## test_registered_mark() [](#method-i-test_registered_mark) - diff --git a/example/ruby/TestEucTw.md b/example/ruby/TestEucTw.md deleted file mode 100644 index 34c211e..0000000 --- a/example/ruby/TestEucTw.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestEucTw -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## s(s) [](#method-i-s) - -## test_code_to_mbc() [](#method-i-test_code_to_mbc) - -## test_left_adjust_char_head() [](#method-i-test_left_adjust_char_head) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_mbc_enc_len() [](#method-i-test_mbc_enc_len) - -## test_mbc_to_code() [](#method-i-test_mbc_to_code) - diff --git a/example/ruby/TestEval.md b/example/ruby/TestEval.md deleted file mode 100644 index 8fb01db..0000000 --- a/example/ruby/TestEval.md +++ /dev/null @@ -1,103 +0,0 @@ -# Class: TestEval -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## test_binding() [](#method-c-test_binding) - -#Instance Methods -## forall_TYPE() [](#method-i-forall_TYPE) - -## make_test_binding() [](#method-i-make_test_binding) -From ruby/test/ruby/test_eval.rb - -## orphan_lambda() [](#method-i-orphan_lambda) - -## orphan_proc() [](#method-i-orphan_proc) - -## ruby(*args) [](#method-i-ruby) - -## test_cvar_scope_with_instance_eval() [](#method-i-test_cvar_scope_with_instance_eval) - -## test_define_method_block() [](#method-i-test_define_method_block) - -## test_define_method_toplevel() [](#method-i-test_define_method_toplevel) - -## test_eval_and_define_method() [](#method-i-test_eval_and_define_method) - -## test_eval_ascii_incompatible() [](#method-i-test_eval_ascii_incompatible) - -## test_eval_basic() [](#method-i-test_eval_basic) - -## test_eval_binding_basic() [](#method-i-test_eval_binding_basic) - -## test_eval_invalid_block_exit_bug_20597() [](#method-i-test_eval_invalid_block_exit_bug_20597) - -## test_eval_location_binding() [](#method-i-test_eval_location_binding) - -## test_eval_location_fstring() [](#method-i-test_eval_location_fstring) - -## test_eval_orig() [](#method-i-test_eval_orig) - -## test_eval_raise() [](#method-i-test_eval_raise) - -## test_eval_using_integer_as_binding() [](#method-i-test_eval_using_integer_as_binding) - -## test_eval_with_toplevel_binding() [](#method-i-test_eval_with_toplevel_binding) -ruby-dev:37142 -: - -## test_file_encoding() [](#method-i-test_file_encoding) - -## test_fixnum_instance_eval_cvar() [](#method-i-test_fixnum_instance_eval_cvar) - -## test_fstring_instance_eval() [](#method-i-test_fstring_instance_eval) - -## test_gced_binding_block() [](#method-i-test_gced_binding_block) - -## test_gced_eval_location() [](#method-i-test_gced_eval_location) - -## test_instance_eval_block_basic() [](#method-i-test_instance_eval_block_basic) - -## test_instance_eval_block_self() [](#method-i-test_instance_eval_block_self) - -## test_instance_eval_block_symbol() [](#method-i-test_instance_eval_block_symbol) - -## test_instance_eval_const() [](#method-i-test_instance_eval_const) - -## test_instance_eval_cvar() [](#method-i-test_instance_eval_cvar) - -## test_instance_eval_method() [](#method-i-test_instance_eval_method) - -## test_instance_eval_method_proc() [](#method-i-test_instance_eval_method_proc) - -## test_instance_eval_on_argf_singleton_class() [](#method-i-test_instance_eval_on_argf_singleton_class) - -## test_instance_eval_string_basic() [](#method-i-test_instance_eval_string_basic) - -## test_instance_exec_block_basic() [](#method-i-test_instance_exec_block_basic) - -## test_instance_exec_cvar() [](#method-i-test_instance_exec_cvar) - -## test_instance_exec_eval_method_definition() [](#method-i-test_instance_exec_eval_method_definition) - -## test_instance_exec_method_definition() [](#method-i-test_instance_exec_method_definition) - -## test_module_eval_block_basic() [](#method-i-test_module_eval_block_basic) - -## test_module_eval_block_symbol() [](#method-i-test_module_eval_block_symbol) - -## test_module_eval_string_basic() [](#method-i-test_module_eval_string_basic) - -## test_nil_instance_eval_cvar() [](#method-i-test_nil_instance_eval_cvar) - -## test_outer_local_variable_under_gc_compact_stress() [](#method-i-test_outer_local_variable_under_gc_compact_stress) - -## test_return_in_eval_lambda() [](#method-i-test_return_in_eval_lambda) - -## test_return_in_eval_proc() [](#method-i-test_return_in_eval_proc) - -## test_syntax_error_no_memory_leak() [](#method-i-test_syntax_error_no_memory_leak) - diff --git a/example/ruby/TestEval/Foo.md b/example/ruby/TestEval/Foo.md deleted file mode 100644 index e22b098..0000000 --- a/example/ruby/TestEval/Foo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestEval::Foo -**Inherits:** Object - - - - - diff --git a/example/ruby/TestException.md b/example/ruby/TestException.md deleted file mode 100644 index 274eee6..0000000 --- a/example/ruby/TestException.md +++ /dev/null @@ -1,209 +0,0 @@ -# Class: TestException -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## meow() [](#method-c-meow) -## to_s() [](#method-c-to_s) -## w(n ) [](#method-c-w) - -#Instance Methods -## assert_null_char(src, *args, **opts) [](#method-i-assert_null_char) - -## capture_warning_warn(category:false) [](#method-i-capture_warning_warn) - -## m() [](#method-i-m) - -## test_anonymous_message() [](#method-i-test_anonymous_message) - -## test_backtrace_by_exception() [](#method-i-test_backtrace_by_exception) - -## test_backtrace_in_eval() [](#method-i-test_backtrace_in_eval) - -## test_blocking_backtrace() [](#method-i-test_blocking_backtrace) - -## test_break_ensure() [](#method-i-test_break_ensure) - -## test_catch_no_throw() [](#method-i-test_catch_no_throw) - -## test_catch_throw() [](#method-i-test_catch_throw) - -## test_catch_throw_in_require() [](#method-i-test_catch_throw_in_require) - -## test_catch_throw_in_require_cant_be_rescued() [](#method-i-test_catch_throw_in_require_cant_be_rescued) - -## test_catch_throw_noarg() [](#method-i-test_catch_throw_noarg) - -## test_cause() [](#method-i-test_cause) - -## test_cause_at_end() [](#method-i-test_cause_at_end) - -## test_cause_at_raised() [](#method-i-test_cause_at_raised) - -## test_cause_exception_in_cause_message() [](#method-i-test_cause_exception_in_cause_message) - -## test_cause_raised_in_rescue() [](#method-i-test_cause_raised_in_rescue) - -## test_cause_reraised() [](#method-i-test_cause_reraised) - -## test_cause_thread_no_cause() [](#method-i-test_cause_thread_no_cause) - -## test_cause_thread_with_cause() [](#method-i-test_cause_thread_with_cause) - -## test_cause_with_frozen_exception() [](#method-i-test_cause_with_frozen_exception) - -## test_cause_with_no_arguments() [](#method-i-test_cause_with_no_arguments) - -## test_circular_cause() [](#method-i-test_circular_cause) - -## test_circular_cause_handle() [](#method-i-test_circular_cause_handle) - -## test_control_in_message() [](#method-i-test_control_in_message) - -## test_detailed_message() [](#method-i-test_detailed_message) - -## test_detailed_message_under_gc_compact_stress() [](#method-i-test_detailed_message_under_gc_compact_stress) - -## test_else_nested_no_exception() [](#method-i-test_else_nested_no_exception) - -## test_else_nested_rescued() [](#method-i-test_else_nested_rescued) - -## test_else_nested_rescued_reraise() [](#method-i-test_else_nested_rescued_reraise) - -## test_else_nested_unrescued() [](#method-i-test_else_nested_unrescued) - -## test_else_no_exception() [](#method-i-test_else_no_exception) - -## test_else_raised() [](#method-i-test_else_raised) - -## test_encoding_in_message() [](#method-i-test_encoding_in_message) - -## test_ensure_after_nomemoryerror() [](#method-i-test_ensure_after_nomemoryerror) - -## test_equal() [](#method-i-test_equal) - -## test_errat() [](#method-i-test_errat) - -## test_errinfo() [](#method-i-test_errinfo) - -## test_errinfo_encoding_in_debug() [](#method-i-test_errinfo_encoding_in_debug) - -## test_errinfo_in_debug() [](#method-i-test_errinfo_in_debug) - -## test_errno() [](#method-i-test_errno) - -## test_errno_constants() [](#method-i-test_errno_constants) - -## test_exception_ensure() [](#method-i-test_exception_ensure) - -## test_exception_ensure_2() [](#method-i-test_exception_ensure_2) -just duplication? - -## test_exception_in_ensure() [](#method-i-test_exception_in_ensure) - -## test_exception_in_ensure_with_next() [](#method-i-test_exception_in_ensure_with_next) - -## test_exception_in_ensure_with_redo() [](#method-i-test_exception_in_ensure_with_redo) - -## test_exception_in_ensure_with_return() [](#method-i-test_exception_in_ensure_with_return) - -## test_exception_in_exception_equal() [](#method-i-test_exception_in_exception_equal) - -## test_exception_in_message() [](#method-i-test_exception_in_message) - -## test_exception_in_name_error_to_str() [](#method-i-test_exception_in_name_error_to_str) - -## test_exception_in_rescue() [](#method-i-test_exception_in_rescue) - -## test_exception_rescued() [](#method-i-test_exception_rescued) - -## test_exception_retry() [](#method-i-test_exception_retry) - -## test_exit_success_p() [](#method-i-test_exit_success_p) - -## test_full_message() [](#method-i-test_full_message) - -## test_full_message_with_custom_detailed_message() [](#method-i-test_full_message_with_custom_detailed_message) - -## test_full_message_with_encoding() [](#method-i-test_full_message_with_encoding) - -## test_inspect() [](#method-i-test_inspect) - -## test_kernel_warn_uplevel() [](#method-i-test_kernel_warn_uplevel) - -## test_machine_stackoverflow() [](#method-i-test_machine_stackoverflow) - -## test_machine_stackoverflow_by_define_method() [](#method-i-test_machine_stackoverflow_by_define_method) - -## test_machine_stackoverflow_by_trace() [](#method-i-test_machine_stackoverflow_by_trace) - -## test_marshal_circular_cause() [](#method-i-test_marshal_circular_cause) - -## test_message_of_name_error() [](#method-i-test_message_of_name_error) - -## test_method_missing_reason_clear() [](#method-i-test_method_missing_reason_clear) - -## test_multibyte_and_newline() [](#method-i-test_multibyte_and_newline) - -## test_non_exception_cause() [](#method-i-test_non_exception_cause) - -## test_output_string_encoding() [](#method-i-test_output_string_encoding) - -## test_raise_with_cause() [](#method-i-test_raise_with_cause) - -## test_raise_with_cause_in_rescue() [](#method-i-test_raise_with_cause_in_rescue) - -## test_raise_with_wrong_number_of_arguments() [](#method-i-test_raise_with_wrong_number_of_arguments) - -## test_redefined_backtrace() [](#method-i-test_redefined_backtrace) - -## test_rescue_single_argument() [](#method-i-test_rescue_single_argument) - -## test_rescue_splat_argument() [](#method-i-test_rescue_splat_argument) - -## test_set_backtrace() [](#method-i-test_set_backtrace) - -## test_stackoverflow() [](#method-i-test_stackoverflow) - -## test_super_in_method_missing() [](#method-i-test_super_in_method_missing) - -## test_syntax_error_detailed_message() [](#method-i-test_syntax_error_detailed_message) - -## test_syntax_error_path() [](#method-i-test_syntax_error_path) - -## test_systemexit_new() [](#method-i-test_systemexit_new) - -## test_thread_signal_location() [](#method-i-test_thread_signal_location) - -## test_throw_false() [](#method-i-test_throw_false) - -## test_to_s() [](#method-i-test_to_s) - -## test_too_many_args_in_eval() [](#method-i-test_too_many_args_in_eval) - -## test_type_error_message_encoding() [](#method-i-test_type_error_message_encoding) - -## test_uncaught_throw() [](#method-i-test_uncaught_throw) - -## test_undef_Warning_warn() [](#method-i-test_undef_Warning_warn) - -## test_undefined_backtrace() [](#method-i-test_undefined_backtrace) - -## test_unknown_option() [](#method-i-test_unknown_option) - -## test_warn_deprecated_backwards_compatibility_category() [](#method-i-test_warn_deprecated_backwards_compatibility_category) - -## test_warning_category() [](#method-i-test_warning_category) - -## test_warning_warn() [](#method-i-test_warning_warn) - -## test_warning_warn_circular_require_backtrace() [](#method-i-test_warning_warn_circular_require_backtrace) - -## test_warning_warn_invalid_argument() [](#method-i-test_warning_warn_invalid_argument) - -## test_warning_warn_super() [](#method-i-test_warning_warn_super) - -## test_wrong_backtrace() [](#method-i-test_wrong_backtrace) - diff --git a/example/ruby/TestExtLibs.md b/example/ruby/TestExtLibs.md deleted file mode 100644 index 84beed3..0000000 --- a/example/ruby/TestExtLibs.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestExtLibs -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## check_existence(ext , add_msg nil) [](#method-c-check_existence) - -#Instance Methods -## windows?() [](#method-i-windows?) - -**@return** [Boolean] - diff --git a/example/ruby/TestFiber.md b/example/ruby/TestFiber.md deleted file mode 100644 index c4a5ec4..0000000 --- a/example/ruby/TestFiber.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: TestFiber -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_alive() [](#method-i-test_alive) - -## test_argument() [](#method-i-test_argument) - -## test_create_fiber_in_new_thread() [](#method-i-test_create_fiber_in_new_thread) - -## test_error() [](#method-i-test_error) - -## test_exit_in_fiber() [](#method-i-test_exit_in_fiber) - -## test_fatal_in_fiber() [](#method-i-test_fatal_in_fiber) - -## test_fiber_transfer_segv() [](#method-i-test_fiber_transfer_segv) - -## test_fiber_variables() [](#method-i-test_fiber_variables) - -## test_fork_from_fiber() [](#method-i-test_fork_from_fiber) - -## test_gc_root_fiber() [](#method-i-test_gc_root_fiber) - -## test_machine_stack_gc() [](#method-i-test_machine_stack_gc) - -## test_many_fibers() [](#method-i-test_many_fibers) - -## test_many_fibers_with_threads() [](#method-i-test_many_fibers_with_threads) - -## test_mark_fiber() [](#method-i-test_mark_fiber) - -## test_new_symbol_proc() [](#method-i-test_new_symbol_proc) - -## test_no_valid_cfp() [](#method-i-test_no_valid_cfp) - -## test_normal() [](#method-i-test_normal) - -## test_prohibit_resume_to_transferring_fiber() [](#method-i-test_prohibit_resume_to_transferring_fiber) - -## test_prohibit_transfer_to_resuming_fiber() [](#method-i-test_prohibit_transfer_to_resuming_fiber) - -## test_prohibit_transfer_to_yielding_fiber() [](#method-i-test_prohibit_transfer_to_yielding_fiber) - -## test_raise() [](#method-i-test_raise) - -## test_raise_transferring_fiber() [](#method-i-test_raise_transferring_fiber) - -## test_resume_root_fiber() [](#method-i-test_resume_root_fiber) - -## test_resume_self() [](#method-i-test_resume_self) - -## test_return() [](#method-i-test_return) - -## test_separate_lastline() [](#method-i-test_separate_lastline) - -## test_separate_lastmatch() [](#method-i-test_separate_lastmatch) - -## test_term() [](#method-i-test_term) - -## test_terminate_transferred_fiber() [](#method-i-test_terminate_transferred_fiber) - -## test_throw() [](#method-i-test_throw) - -## test_tls() [](#method-i-test_tls) - -## test_to_s() [](#method-i-test_to_s) - -## test_transfer() [](#method-i-test_transfer) - -## tvar(var, val) [](#method-i-tvar) - diff --git a/example/ruby/TestFiberBacktrace.md b/example/ruby/TestFiberBacktrace.md deleted file mode 100644 index 5e95e3f..0000000 --- a/example/ruby/TestFiberBacktrace.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestFiberBacktrace -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_backtrace() [](#method-i-test_backtrace) - -## test_backtrace_locations() [](#method-i-test_backtrace_locations) - -## test_local_backtrace() [](#method-i-test_local_backtrace) - diff --git a/example/ruby/TestFiberCurrentRactor.md b/example/ruby/TestFiberCurrentRactor.md deleted file mode 100644 index 28fac10..0000000 --- a/example/ruby/TestFiberCurrentRactor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestFiberCurrentRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ractor_shareable() [](#method-i-test_ractor_shareable) - diff --git a/example/ruby/TestFiberEnumerator.md b/example/ruby/TestFiberEnumerator.md deleted file mode 100644 index 23146be..0000000 --- a/example/ruby/TestFiberEnumerator.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestFiberEnumerator -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## enumerator_fiber_is_nonblocking() [](#method-i-enumerator_fiber_is_nonblocking) - -## test_read_characters() [](#method-i-test_read_characters) - diff --git a/example/ruby/TestFiberIO.md b/example/ruby/TestFiberIO.md deleted file mode 100644 index 8316932..0000000 --- a/example/ruby/TestFiberIO.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestFiberIO -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_backquote() [](#method-i-test_backquote) - -## test_close_while_reading_on_thread() [](#method-i-test_close_while_reading_on_thread) -Tests for https://bugs.ruby-lang.org/issues/20723 which would otherwise -deadlock this test. - -## test_epipe_on_read() [](#method-i-test_epipe_on_read) - -## test_heavy_read() [](#method-i-test_heavy_read) - -## test_io_select() [](#method-i-test_io_select) - -## test_puts_empty() [](#method-i-test_puts_empty) - -## test_read() [](#method-i-test_read) - -## test_read_write_blocking() [](#method-i-test_read_write_blocking) - -## test_tcp_accept() [](#method-i-test_tcp_accept) - -## test_tcp_connect() [](#method-i-test_tcp_connect) - diff --git a/example/ruby/TestFiberIOBuffer.md b/example/ruby/TestFiberIOBuffer.md deleted file mode 100644 index 72c39a6..0000000 --- a/example/ruby/TestFiberIOBuffer.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestFiberIOBuffer -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## nonblockable?(io) [](#method-i-nonblockable?) - -**@return** [Boolean] - -## test_io_buffer_pread_pwrite() [](#method-i-test_io_buffer_pread_pwrite) - -## test_io_buffer_read_write() [](#method-i-test_io_buffer_read_write) - -## test_read_nonblock() [](#method-i-test_read_nonblock) - -## test_read_write_blocking() [](#method-i-test_read_write_blocking) - -## test_timeout_after() [](#method-i-test_timeout_after) - -## test_write_nonblock() [](#method-i-test_write_nonblock) - diff --git a/example/ruby/TestFiberMutex.md b/example/ruby/TestFiberMutex.md deleted file mode 100644 index fc21b5d..0000000 --- a/example/ruby/TestFiberMutex.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestFiberMutex -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_condition_variable() [](#method-i-test_condition_variable) - -## test_mutex_deadlock() [](#method-i-test_mutex_deadlock) - -## test_mutex_fiber_deadlock_no_scheduler() [](#method-i-test_mutex_fiber_deadlock_no_scheduler) - -## test_mutex_fiber_raise() [](#method-i-test_mutex_fiber_raise) - -## test_mutex_interleaved_locking() [](#method-i-test_mutex_interleaved_locking) - -## test_mutex_synchronize() [](#method-i-test_mutex_synchronize) - -## test_mutex_thread() [](#method-i-test_mutex_thread) - -## test_queue() [](#method-i-test_queue) - -## test_queue_pop_waits() [](#method-i-test_queue_pop_waits) - diff --git a/example/ruby/TestFiberProcess.md b/example/ruby/TestFiberProcess.md deleted file mode 100644 index e7e3c67..0000000 --- a/example/ruby/TestFiberProcess.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestFiberProcess -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_fork() [](#method-i-test_fork) - -## test_process_wait() [](#method-i-test_process_wait) - -## test_system() [](#method-i-test_system) - -## test_system_faulty_process_wait() [](#method-i-test_system_faulty_process_wait) - diff --git a/example/ruby/TestFiberQueue.md b/example/ruby/TestFiberQueue.md deleted file mode 100644 index fa3cafd..0000000 --- a/example/ruby/TestFiberQueue.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestFiberQueue -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_pop_with_timeout() [](#method-i-test_pop_with_timeout) - -## test_pop_with_timeout_and_value() [](#method-i-test_pop_with_timeout_and_value) - diff --git a/example/ruby/TestFiberScheduler.md b/example/ruby/TestFiberScheduler.md deleted file mode 100644 index 2aae3a0..0000000 --- a/example/ruby/TestFiberScheduler.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestFiberScheduler -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_autoload() [](#method-i-test_autoload) - -## test_close_at_exit() [](#method-i-test_close_at_exit) - -## test_closed_at_thread_exit() [](#method-i-test_closed_at_thread_exit) - -## test_closed_when_set_to_nil() [](#method-i-test_closed_when_set_to_nil) - -## test_condition_variable() [](#method-i-test_condition_variable) - -## test_current_scheduler() [](#method-i-test_current_scheduler) - -## test_deadlock() [](#method-i-test_deadlock) - -## test_fiber_blocking() [](#method-i-test_fiber_blocking) - -## test_fiber_new() [](#method-i-test_fiber_new) - -## test_fiber_new_with_options() [](#method-i-test_fiber_new_with_options) - -## test_fiber_without_scheduler() [](#method-i-test_fiber_without_scheduler) - -## test_minimal_interface() [](#method-i-test_minimal_interface) - diff --git a/example/ruby/TestFiberSchedulerAutoload.md b/example/ruby/TestFiberSchedulerAutoload.md deleted file mode 100644 index b3fc87e..0000000 --- a/example/ruby/TestFiberSchedulerAutoload.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestFiberSchedulerAutoload - - - - - diff --git a/example/ruby/TestFiberSleep.md b/example/ruby/TestFiberSleep.md deleted file mode 100644 index cdb3f57..0000000 --- a/example/ruby/TestFiberSleep.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestFiberSleep -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_broken_sleep() [](#method-i-test_broken_sleep) - -## test_sleep() [](#method-i-test_sleep) - -## test_sleep_returns_seconds_slept() [](#method-i-test_sleep_returns_seconds_slept) - diff --git a/example/ruby/TestFiberStorage.md b/example/ruby/TestFiberStorage.md deleted file mode 100644 index 9bfb599..0000000 --- a/example/ruby/TestFiberStorage.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestFiberStorage -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_enumerator_count() [](#method-i-test_enumerator_count) - -## test_enumerator_inherited_storage() [](#method-i-test_enumerator_inherited_storage) - -## test_inherited_storage() [](#method-i-test_inherited_storage) - -## test_storage() [](#method-i-test_storage) - -## test_storage_assignment() [](#method-i-test_storage_assignment) - -## test_storage_assignment_type_error() [](#method-i-test_storage_assignment_type_error) - -## test_storage_inherited() [](#method-i-test_storage_inherited) - -## test_storage_only_allow_access_from_same_fiber() [](#method-i-test_storage_only_allow_access_from_same_fiber) - -## test_thread_inherited_storage() [](#method-i-test_thread_inherited_storage) - -## test_variable_assignment() [](#method-i-test_variable_assignment) - diff --git a/example/ruby/TestFiberThread.md b/example/ruby/TestFiberThread.md deleted file mode 100644 index 5dc823f..0000000 --- a/example/ruby/TestFiberThread.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestFiberThread -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_broken_unblock() [](#method-i-test_broken_unblock) - -## test_thread_join() [](#method-i-test_thread_join) - -## test_thread_join_blocking() [](#method-i-test_thread_join_blocking) - -## test_thread_join_hang() [](#method-i-test_thread_join_hang) - -## test_thread_join_implicit() [](#method-i-test_thread_join_implicit) - -## test_thread_join_timeout() [](#method-i-test_thread_join_timeout) - diff --git a/example/ruby/TestFiberTimeout.md b/example/ruby/TestFiberTimeout.md deleted file mode 100644 index 4fe6379..0000000 --- a/example/ruby/TestFiberTimeout.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestFiberTimeout -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_timeout_after() [](#method-i-test_timeout_after) - -## test_timeout_on_main_fiber() [](#method-i-test_timeout_on_main_fiber) - diff --git a/example/ruby/TestFiddle.md b/example/ruby/TestFiddle.md deleted file mode 100644 index e6fc7be..0000000 --- a/example/ruby/TestFiddle.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestFiddle -**Inherits:** Fiddle::TestCase - - - - - -#Instance Methods -## test_dlopen_linker_script_group_linux() [](#method-i-test_dlopen_linker_script_group_linux) - -## test_dlopen_linker_script_input_linux() [](#method-i-test_dlopen_linker_script_input_linux) - -## test_nil_true_etc() [](#method-i-test_nil_true_etc) - -## test_windows_constant() [](#method-i-test_windows_constant) - diff --git a/example/ruby/TestFile.md b/example/ruby/TestFile.md deleted file mode 100644 index 0cb15ef..0000000 --- a/example/ruby/TestFile.md +++ /dev/null @@ -1,118 +0,0 @@ -# Class: TestFile -**Inherits:** Test::Unit::TestCase - -**Includes:** TestEOF, TestEOF::Seek - - - - - -#Instance Methods -## assert_bom(bytes, name) [](#method-i-assert_bom) - -## measure_time() [](#method-i-measure_time) - -## open_file(content) [](#method-i-open_file) - -## open_file_seek(content, pos) [](#method-i-open_file_seek) - -## test_absolute_path?() [](#method-i-test_absolute_path?) - -**@return** [Boolean] - -## test_bom_16be() [](#method-i-test_bom_16be) - -## test_bom_16le() [](#method-i-test_bom_16le) - -## test_bom_32be() [](#method-i-test_bom_32be) - -## test_bom_32le() [](#method-i-test_bom_32le) - -## test_bom_8() [](#method-i-test_bom_8) - -## test_chmod_m17n() [](#method-i-test_chmod_m17n) - -## test_chown() [](#method-i-test_chown) - -## test_conflicting_encodings() [](#method-i-test_conflicting_encodings) - -## test_each_byte_extended_file() [](#method-i-test_each_byte_extended_file) - -## test_each_char_extended_file() [](#method-i-test_each_char_extended_file) - -## test_empty_file_bom() [](#method-i-test_empty_file_bom) - -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_0_seek() [](#method-i-test_eof_0_seek) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_1_seek() [](#method-i-test_eof_1_seek) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - -## test_file_open_double_mode() [](#method-i-test_file_open_double_mode) - -## test_file_open_newline_option() [](#method-i-test_file_open_newline_option) - -## test_file_open_permissions() [](#method-i-test_file_open_permissions) - -## test_file_share_delete() [](#method-i-test_file_share_delete) - -## test_getbyte_extended_file() [](#method-i-test_getbyte_extended_file) - -## test_getc_extended_file() [](#method-i-test_getc_extended_file) - -## test_gets_extended_file() [](#method-i-test_gets_extended_file) - -## test_gets_para_extended_file() [](#method-i-test_gets_para_extended_file) - -## test_initialize() [](#method-i-test_initialize) - -## test_long_unc() [](#method-i-test_long_unc) - -## test_open_nul() [](#method-i-test_open_nul) - -## test_open_tempfile_path() [](#method-i-test_open_tempfile_path) - -## test_read_all_extended_file() [](#method-i-test_read_all_extended_file) - -## test_realdirpath() [](#method-i-test_realdirpath) - -## test_realdirpath_junction() [](#method-i-test_realdirpath_junction) - -## test_realpath() [](#method-i-test_realpath) - -## test_realpath_encoding() [](#method-i-test_realpath_encoding) - -## test_realpath_special_symlink() [](#method-i-test_realpath_special_symlink) - -## test_s_chown() [](#method-i-test_s_chown) - -## test_stat() [](#method-i-test_stat) - -## test_stat_inode() [](#method-i-test_stat_inode) - -## test_truncate_beyond_eof() [](#method-i-test_truncate_beyond_eof) - -## test_truncate_rbuf() [](#method-i-test_truncate_rbuf) - -## test_truncate_size() [](#method-i-test_truncate_size) - -## test_truncate_wbuf() [](#method-i-test_truncate_wbuf) - -## test_uninitialized() [](#method-i-test_uninitialized) - -## test_unlink_before_close() [](#method-i-test_unlink_before_close) -I don't know Ruby's spec about "unlink-before-close" exactly. This test -asserts current behaviour. - -## test_utime() [](#method-i-test_utime) - -## test_utime_with_minus_time_segv() [](#method-i-test_utime_with_minus_time_segv) - diff --git a/example/ruby/TestFile/NewlineConvTests.md b/example/ruby/TestFile/NewlineConvTests.md deleted file mode 100644 index 6da2322..0000000 --- a/example/ruby/TestFile/NewlineConvTests.md +++ /dev/null @@ -1,92 +0,0 @@ -# Class: TestFile::NewlineConvTests -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_file_contents_has_crlf(f) [](#method-i-assert_file_contents_has_crlf) - -## assert_file_contents_has_crlf_on_windows(f) [](#method-i-assert_file_contents_has_crlf_on_windows) - -## assert_file_contents_has_lf(f) [](#method-i-assert_file_contents_has_lf) - -## assert_file_contents_has_lf_on_windows(f) [](#method-i-assert_file_contents_has_lf_on_windows) - -## open_file_with(method, filename, mode) [](#method-i-open_file_with) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_c_rb_file_open_bin_mode_read_crlf() [](#method-i-test_c_rb_file_open_bin_mode_read_crlf) - -## test_c_rb_file_open_bin_mode_read_crlf_with_utf8_encoding() [](#method-i-test_c_rb_file_open_bin_mode_read_crlf_with_utf8_encoding) - -## test_c_rb_file_open_bin_mode_read_lf() [](#method-i-test_c_rb_file_open_bin_mode_read_lf) - -## test_c_rb_file_open_bin_mode_read_lf_with_utf8_encoding() [](#method-i-test_c_rb_file_open_bin_mode_read_lf_with_utf8_encoding) - -## test_c_rb_file_open_bin_mode_write_crlf() [](#method-i-test_c_rb_file_open_bin_mode_write_crlf) - -## test_c_rb_file_open_bin_mode_write_lf() [](#method-i-test_c_rb_file_open_bin_mode_write_lf) - -## test_c_rb_file_open_text_mode_read_crlf() [](#method-i-test_c_rb_file_open_text_mode_read_crlf) - -## test_c_rb_file_open_text_mode_read_crlf_with_utf8_encoding() [](#method-i-test_c_rb_file_open_text_mode_read_crlf_with_utf8_encoding) - -## test_c_rb_file_open_text_mode_read_lf() [](#method-i-test_c_rb_file_open_text_mode_read_lf) - -## test_c_rb_file_open_text_mode_read_lf_with_utf8_encoding() [](#method-i-test_c_rb_file_open_text_mode_read_lf_with_utf8_encoding) - -## test_c_rb_file_open_text_mode_write_lf() [](#method-i-test_c_rb_file_open_text_mode_write_lf) - -## test_c_rb_io_fdopen_bin_mode_read_crlf() [](#method-i-test_c_rb_io_fdopen_bin_mode_read_crlf) - -## test_c_rb_io_fdopen_bin_mode_read_crlf_with_utf8_encoding() [](#method-i-test_c_rb_io_fdopen_bin_mode_read_crlf_with_utf8_encoding) - -## test_c_rb_io_fdopen_bin_mode_read_lf() [](#method-i-test_c_rb_io_fdopen_bin_mode_read_lf) - -## test_c_rb_io_fdopen_bin_mode_read_lf_with_utf8_encoding() [](#method-i-test_c_rb_io_fdopen_bin_mode_read_lf_with_utf8_encoding) - -## test_c_rb_io_fdopen_bin_mode_write_crlf() [](#method-i-test_c_rb_io_fdopen_bin_mode_write_crlf) - -## test_c_rb_io_fdopen_bin_mode_write_lf() [](#method-i-test_c_rb_io_fdopen_bin_mode_write_lf) - -## test_c_rb_io_fdopen_text_mode_read_crlf() [](#method-i-test_c_rb_io_fdopen_text_mode_read_crlf) - -## test_c_rb_io_fdopen_text_mode_read_crlf_with_utf8_encoding() [](#method-i-test_c_rb_io_fdopen_text_mode_read_crlf_with_utf8_encoding) - -## test_c_rb_io_fdopen_text_mode_read_lf() [](#method-i-test_c_rb_io_fdopen_text_mode_read_lf) - -## test_c_rb_io_fdopen_text_mode_read_lf_with_utf8_encoding() [](#method-i-test_c_rb_io_fdopen_text_mode_read_lf_with_utf8_encoding) - -## test_c_rb_io_fdopen_text_mode_write_lf() [](#method-i-test_c_rb_io_fdopen_text_mode_write_lf) - -## test_ruby_file_open_bin_mode_read_crlf() [](#method-i-test_ruby_file_open_bin_mode_read_crlf) - -## test_ruby_file_open_bin_mode_read_crlf_with_utf8_encoding() [](#method-i-test_ruby_file_open_bin_mode_read_crlf_with_utf8_encoding) - -## test_ruby_file_open_bin_mode_read_lf() [](#method-i-test_ruby_file_open_bin_mode_read_lf) - -## test_ruby_file_open_bin_mode_read_lf_with_utf8_encoding() [](#method-i-test_ruby_file_open_bin_mode_read_lf_with_utf8_encoding) - -## test_ruby_file_open_bin_mode_write_crlf() [](#method-i-test_ruby_file_open_bin_mode_write_crlf) - -## test_ruby_file_open_bin_mode_write_lf() [](#method-i-test_ruby_file_open_bin_mode_write_lf) - -## test_ruby_file_open_text_mode_read_crlf() [](#method-i-test_ruby_file_open_text_mode_read_crlf) - -## test_ruby_file_open_text_mode_read_crlf_with_utf8_encoding() [](#method-i-test_ruby_file_open_text_mode_read_crlf_with_utf8_encoding) - -## test_ruby_file_open_text_mode_read_lf() [](#method-i-test_ruby_file_open_text_mode_read_lf) - -## test_ruby_file_open_text_mode_read_lf_with_utf8_encoding() [](#method-i-test_ruby_file_open_text_mode_read_lf_with_utf8_encoding) - -## test_ruby_file_open_text_mode_write_lf() [](#method-i-test_ruby_file_open_text_mode_write_lf) - -## windows?() [](#method-i-windows?) - -**@return** [Boolean] - diff --git a/example/ruby/TestFileExhaustive.md b/example/ruby/TestFileExhaustive.md deleted file mode 100644 index e9897fb..0000000 --- a/example/ruby/TestFileExhaustive.md +++ /dev/null @@ -1,354 +0,0 @@ -# Class: TestFileExhaustive -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_bool_equal(expected, result, *messages) [](#method-i-assert_bool_equal) - -## assert_incompatible_encoding() [](#method-i-assert_incompatible_encoding) - -## assert_integer(n) [](#method-i-assert_integer) - -## assert_integer_or_nil(n) [](#method-i-assert_integer_or_nil) - -## assert_no_memory_leak_at_expand_path_home(arg, message) [](#method-i-assert_no_memory_leak_at_expand_path_home) - -## blockdev() [](#method-i-blockdev) - -## chardev() [](#method-i-chardev) - -## fifo() [](#method-i-fifo) - -## grpownedfile() [](#method-i-grpownedfile) - -## hardlinkfile() [](#method-i-hardlinkfile) - -## io_open(file_name) [](#method-i-io_open) - -## make_file(content, file) [](#method-i-make_file) - -## make_tmp_filename(prefix) [](#method-i-make_tmp_filename) - -## nofile() [](#method-i-nofile) - -## notownedfile() [](#method-i-notownedfile) - -## path_identical_p(file) [](#method-i-path_identical_p) - -## regular_file() [](#method-i-regular_file) - -## root_without_capabilities?() [](#method-i-root_without_capabilities?) - -**@return** [Boolean] - -## rootdir() [](#method-i-rootdir) - -## setup() [](#method-i-setup) - -## sgidfile() [](#method-i-sgidfile) - -## socket() [](#method-i-socket) - -## stickyfile() [](#method-i-stickyfile) - -## suidfile() [](#method-i-suidfile) - -## symlinkfile() [](#method-i-symlinkfile) - -## teardown() [](#method-i-teardown) - -## test_absolute_path() [](#method-i-test_absolute_path) - -## test_atime() [](#method-i-test_atime) - -## test_basename() [](#method-i-test_basename) - -## test_basename_backslash() [](#method-i-test_basename_backslash) - -## test_basename_encoding() [](#method-i-test_basename_encoding) - -## test_basename_strip() [](#method-i-test_basename_strip) - -## test_birthtime() [](#method-i-test_birthtime) - -## test_blockdev_p() [](#method-i-test_blockdev_p) - -## test_chardev_p() [](#method-i-test_chardev_p) - -## test_chmod() [](#method-i-test_chmod) - -## test_chown() [](#method-i-test_chown) -xxx - -## test_closed_io_identical_p() [](#method-i-test_closed_io_identical_p) - -## test_ctime() [](#method-i-test_ctime) - -## test_directory_p() [](#method-i-test_directory_p) - -## test_dirname() [](#method-i-test_dirname) - -## test_dirname_backslash() [](#method-i-test_dirname_backslash) - -## test_dirname_encoding() [](#method-i-test_dirname_encoding) - -## test_empty_p() [](#method-i-test_empty_p) - -## test_executable_p() [](#method-i-test_executable_p) - -## test_executable_real_p() [](#method-i-test_executable_real_p) - -## test_exist_p() [](#method-i-test_exist_p) - -## test_expand_path() [](#method-i-test_expand_path) - -## test_expand_path_absolute() [](#method-i-test_expand_path_absolute) - -## test_expand_path_accepts_objects_that_have_a_to_path_method() [](#method-i-test_expand_path_accepts_objects_that_have_a_to_path_method) - -## test_expand_path_cleanup_dots_file_name() [](#method-i-test_expand_path_cleanup_dots_file_name) - -## test_expand_path_compose() [](#method-i-test_expand_path_compose) - -## test_expand_path_converts_a_dot_with_unc_dir() [](#method-i-test_expand_path_converts_a_dot_with_unc_dir) - -## test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_a_complete_path() [](#method-i-test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_a_complete_path) - -## test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_home_as_base() [](#method-i-test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_home_as_base) - -## test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_unc_home() [](#method-i-test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_unc_home) - -## test_expand_path_converts_a_pathname_which_starts_with_a_slash_and_unc_pathname() [](#method-i-test_expand_path_converts_a_pathname_which_starts_with_a_slash_and_unc_pathname) - -## test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_a_current_drive() [](#method-i-test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_a_current_drive) - -## test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_dir_s_drive() [](#method-i-test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_dir_s_drive) - -## test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_host_share() [](#method-i-test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_host_share) - -## test_expand_path_does_not_expand_wildcards() [](#method-i-test_expand_path_does_not_expand_wildcards) - -## test_expand_path_does_not_modify_a_home_string_argument() [](#method-i-test_expand_path_does_not_modify_a_home_string_argument) - -## test_expand_path_does_not_modify_the_string_argument() [](#method-i-test_expand_path_does_not_modify_the_string_argument) - -## test_expand_path_encoding() [](#method-i-test_expand_path_encoding) - -## test_expand_path_encoding_filesystem() [](#method-i-test_expand_path_encoding_filesystem) - -## test_expand_path_error_for_non_absolute_home() [](#method-i-test_expand_path_error_for_non_absolute_home) - -## test_expand_path_error_for_nonexistent_username() [](#method-i-test_expand_path_error_for_nonexistent_username) - -## test_expand_path_expands_dot_dir() [](#method-i-test_expand_path_expands_dot_dir) - -## test_expand_path_for_existent_username() [](#method-i-test_expand_path_for_existent_username) - -## test_expand_path_home() [](#method-i-test_expand_path_home) - -## test_expand_path_home_dir_string() [](#method-i-test_expand_path_home_dir_string) - -## test_expand_path_home_memory_leak_in_base() [](#method-i-test_expand_path_home_memory_leak_in_base) - -## test_expand_path_home_memory_leak_in_path() [](#method-i-test_expand_path_home_memory_leak_in_path) - -## test_expand_path_ignores_supplied_dir_if_path_contains_a_drive_letter() [](#method-i-test_expand_path_ignores_supplied_dir_if_path_contains_a_drive_letter) - -## test_expand_path_memsize() [](#method-i-test_expand_path_memsize) - -## test_expand_path_ntfs() [](#method-i-test_expand_path_ntfs) - -## test_expand_path_preserves_unc_path_root() [](#method-i-test_expand_path_preserves_unc_path_root) - -## test_expand_path_raises_a_type_error_if_not_passed_a_string_type() [](#method-i-test_expand_path_raises_a_type_error_if_not_passed_a_string_type) - -## test_expand_path_raises_argument_error_for_any_supplied_username() [](#method-i-test_expand_path_raises_argument_error_for_any_supplied_username) - -## test_expand_path_remove_trailing_alternative_data() [](#method-i-test_expand_path_remove_trailing_alternative_data) - -## test_expand_path_removes_trailing_slashes_from_absolute_path() [](#method-i-test_expand_path_removes_trailing_slashes_from_absolute_path) - -## test_expand_path_removes_trailing_spaces_from_absolute_path() [](#method-i-test_expand_path_removes_trailing_spaces_from_absolute_path) - -## test_expand_path_resolve_dot_current_directory() [](#method-i-test_expand_path_resolve_dot_current_directory) - -## test_expand_path_resolve_empty_string_current_directory() [](#method-i-test_expand_path_resolve_empty_string_current_directory) - -## test_expand_path_resolve_file_name_and_dir_string_relative() [](#method-i-test_expand_path_resolve_file_name_and_dir_string_relative) - -## test_expand_path_resolve_file_name_relative_current_directory() [](#method-i-test_expand_path_resolve_file_name_relative_current_directory) - -## test_expand_path_returns_a_string_when_passed_a_string_subclass() [](#method-i-test_expand_path_returns_a_string_when_passed_a_string_subclass) - -## test_expand_path_with_drive_letter() [](#method-i-test_expand_path_with_drive_letter) - -## test_extname() [](#method-i-test_extname) - -## test_file_p() [](#method-i-test_file_p) - -## test_flock_exclusive() [](#method-i-test_flock_exclusive) - -## test_flock_shared() [](#method-i-test_flock_shared) - -## test_ftype() [](#method-i-test_ftype) - -## test_grpowned_p() [](#method-i-test_grpowned_p) -xxx - -## test_hardlink() [](#method-i-test_hardlink) - -## test_ignore_nil_dir_string() [](#method-i-test_ignore_nil_dir_string) - -## test_io_identical_p() [](#method-i-test_io_identical_p) - -## test_join() [](#method-i-test_join) - -## test_join_alt_separator() [](#method-i-test_join_alt_separator) - -## test_join_ascii_incompatible() [](#method-i-test_join_ascii_incompatible) - -## test_join_with_changed_separator() [](#method-i-test_join_with_changed_separator) - -## test_lchmod() [](#method-i-test_lchmod) - -## test_lchown() [](#method-i-test_lchown) -xxx - -## test_lstat() [](#method-i-test_lstat) - -## test_lutime() [](#method-i-test_lutime) - -## test_mtime() [](#method-i-test_mtime) - -## test_owned_p() [](#method-i-test_owned_p) - -## test_path() [](#method-i-test_path) - -## test_path_check() [](#method-i-test_path_check) - -## test_path_identical_p() [](#method-i-test_path_identical_p) - -## test_pipe_p() [](#method-i-test_pipe_p) - -## test_readable_p() [](#method-i-test_readable_p) - -## test_readable_real_p() [](#method-i-test_readable_real_p) - -## test_readlink() [](#method-i-test_readlink) - -## test_readlink_junction() [](#method-i-test_readlink_junction) - -## test_readlink_long_path() [](#method-i-test_readlink_long_path) - -## test_realpath_mount_point() [](#method-i-test_realpath_mount_point) - -## test_rename() [](#method-i-test_rename) - -## test_s_size() [](#method-i-test_s_size) - -## test_sgid() [](#method-i-test_sgid) - -## test_size() [](#method-i-test_size) - -## test_size_p() [](#method-i-test_size_p) - -## test_socket_p() [](#method-i-test_socket_p) - -## test_split() [](#method-i-test_split) - -## test_stat() [](#method-i-test_stat) - -## test_stat_blockdev_p() [](#method-i-test_stat_blockdev_p) - -## test_stat_chardev_p() [](#method-i-test_stat_chardev_p) - -## test_stat_directory_p() [](#method-i-test_stat_directory_p) - -## test_stat_drive_root() [](#method-i-test_stat_drive_root) - -## test_stat_executable_p() [](#method-i-test_stat_executable_p) - -## test_stat_executable_real_p() [](#method-i-test_stat_executable_real_p) - -## test_stat_file_p() [](#method-i-test_stat_file_p) - -## test_stat_ftype() [](#method-i-test_stat_ftype) - -## test_stat_grpowned_p() [](#method-i-test_stat_grpowned_p) -xxx - -## test_stat_init() [](#method-i-test_stat_init) - -## test_stat_new_utf8() [](#method-i-test_stat_new_utf8) - -## test_stat_owned_p() [](#method-i-test_stat_owned_p) - -## test_stat_pipe_p() [](#method-i-test_stat_pipe_p) - -## test_stat_readable_p() [](#method-i-test_stat_readable_p) - -## test_stat_readable_real_p() [](#method-i-test_stat_readable_real_p) - -## test_stat_sgid() [](#method-i-test_stat_sgid) - -## test_stat_size() [](#method-i-test_stat_size) - -## test_stat_size_p() [](#method-i-test_stat_size_p) - -## test_stat_socket_p() [](#method-i-test_stat_socket_p) - -## test_stat_special_file() [](#method-i-test_stat_special_file) - -## test_stat_sticky() [](#method-i-test_stat_sticky) - -## test_stat_suid() [](#method-i-test_stat_suid) - -## test_stat_symlink_p() [](#method-i-test_stat_symlink_p) - -## test_stat_world_readable_p() [](#method-i-test_stat_world_readable_p) - -## test_stat_world_writable_p() [](#method-i-test_stat_world_writable_p) - -## test_stat_writable_p() [](#method-i-test_stat_writable_p) - -## test_stat_writable_real_p() [](#method-i-test_stat_writable_real_p) - -## test_stat_zero_p() [](#method-i-test_stat_zero_p) - -## test_sticky() [](#method-i-test_sticky) - -## test_suid() [](#method-i-test_suid) - -## test_symlink() [](#method-i-test_symlink) - -## test_symlink_p() [](#method-i-test_symlink_p) - -## test_test() [](#method-i-test_test) - -## test_truncate() [](#method-i-test_truncate) - -## test_umask() [](#method-i-test_umask) - -## test_unlink() [](#method-i-test_unlink) - -## test_utime() [](#method-i-test_utime) - -## test_utime_symlinkfile() [](#method-i-test_utime_symlinkfile) - -## test_world_readable_p() [](#method-i-test_world_readable_p) - -## test_world_writable_p() [](#method-i-test_world_writable_p) - -## test_writable_p() [](#method-i-test_writable_p) - -## test_writable_real_p() [](#method-i-test_writable_real_p) - -## test_zero_p() [](#method-i-test_zero_p) - -## utf8_file() [](#method-i-utf8_file) - -## zerofile() [](#method-i-zerofile) - diff --git a/example/ruby/TestFileUtils.md b/example/ruby/TestFileUtils.md deleted file mode 100644 index 2fa2be0..0000000 --- a/example/ruby/TestFileUtils.md +++ /dev/null @@ -1,338 +0,0 @@ -# Class: TestFileUtils -**Inherits:** Test::Unit::TestCase - -**Includes:** FileUtils, Test::Unit::FileAssertions - - - - - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## assert_directory(path, messagenil) [](#method-i-assert_directory) - -## assert_equal_filemode(file1, file2, messagenil, mask:07777) [](#method-i-assert_equal_filemode) - -## assert_equal_time(expected, actual, messagenil) [](#method-i-assert_equal_time) - -## assert_equal_timestamp(expected, actual, messagenil) [](#method-i-assert_equal_timestamp) - -## assert_file_exist(path, messagenil) [](#method-i-assert_file_exist) - -## assert_file_not_exist(path, messagenil) [](#method-i-assert_file_not_exist) - -## assert_filemode(expected, file, messagenil, mask:07777) [](#method-i-assert_filemode) - -## assert_not_symlink(path, messagenil) [](#method-i-assert_not_symlink) - -## assert_output_lines(expected, fuself, messagenil) [](#method-i-assert_output_lines) - -## assert_ownership_group(expected, file) [](#method-i-assert_ownership_group) - -## assert_ownership_user(expected, file) [](#method-i-assert_ownership_user) - -## assert_same_entry(from, to, messagenil) [](#method-i-assert_same_entry) - -## assert_same_file(from, to, messagenil) [](#method-i-assert_same_file) - -## assert_symlink(path, messagenil) [](#method-i-assert_symlink) - -## check_singleton(name) [](#method-i-check_singleton) - -## each_srcdest() [](#method-i-each_srcdest) - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## my_rm_rf(path) [](#method-i-my_rm_rf) - -## mymkdir(path) [](#method-i-mymkdir) - -## prepare_big_file() [](#method-i-prepare_big_file) - -## prepare_data_file() [](#method-i-prepare_data_file) - -## prepare_time_data() [](#method-i-prepare_time_data) - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## setup() [](#method-i-setup) - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## teardown() [](#method-i-teardown) - -## test_assert_output_lines() [](#method-i-test_assert_output_lines) -Test Cases - -## test_cd() [](#method-i-test_cd) - -## test_cd_result() [](#method-i-test_cd_result) - -## test_chdir() [](#method-i-test_chdir) - -## test_chdir_verbose() [](#method-i-test_chdir_verbose) - -## test_chdir_verbose_frozen() [](#method-i-test_chdir_verbose_frozen) - -## test_chmod() [](#method-i-test_chmod) - -## test_chmod_R() [](#method-i-test_chmod_R) - -## test_chmod_symbol_mode() [](#method-i-test_chmod_symbol_mode) - -## test_chmod_symbol_mode_R() [](#method-i-test_chmod_symbol_mode_R) - -## test_chmod_verbose() [](#method-i-test_chmod_verbose) - -## test_chown() [](#method-i-test_chown) - -## test_chown_R() [](#method-i-test_chown_R) - -## test_chown_R_force() [](#method-i-test_chown_R_force) - -## test_chown_R_noop() [](#method-i-test_chown_R_noop) - -## test_chown_R_verbose() [](#method-i-test_chown_R_verbose) - -## test_chown_R_with_root() [](#method-i-test_chown_R_with_root) - -## test_chown_R_without_permission() [](#method-i-test_chown_R_without_permission) - -## test_chown_dir_group_ownership_not_recursive() [](#method-i-test_chown_dir_group_ownership_not_recursive) - -## test_chown_dir_user_ownership_not_recursive_with_root() [](#method-i-test_chown_dir_user_ownership_not_recursive_with_root) - -## test_chown_error() [](#method-i-test_chown_error) - -## test_chown_noop() [](#method-i-test_chown_noop) - -## test_chown_verbose() [](#method-i-test_chown_verbose) - -## test_chown_with_root() [](#method-i-test_chown_with_root) - -## test_chown_without_permission() [](#method-i-test_chown_without_permission) - -## test_cmp() [](#method-i-test_cmp) - -## test_collect_methods() [](#method-i-test_collect_methods) - -## test_commands() [](#method-i-test_commands) - -## test_compare_file() [](#method-i-test_compare_file) - -## test_compare_stream() [](#method-i-test_compare_stream) - -## test_copy_entry() [](#method-i-test_copy_entry) - -## test_copy_entry_symlink() [](#method-i-test_copy_entry_symlink) - -## test_copy_entry_symlink_remove_destination() [](#method-i-test_copy_entry_symlink_remove_destination) - -## test_copy_file() [](#method-i-test_copy_file) - -## test_copy_stream() [](#method-i-test_copy_stream) - -## test_copy_stream_duck() [](#method-i-test_copy_stream_duck) - -## test_cp() [](#method-i-test_cp) - -## test_cp_lr() [](#method-i-test_cp_lr) - -## test_cp_pathname() [](#method-i-test_cp_pathname) - -## test_cp_preserve_permissions() [](#method-i-test_cp_preserve_permissions) - -## test_cp_preserve_permissions_dir() [](#method-i-test_cp_preserve_permissions_dir) - -## test_cp_r() [](#method-i-test_cp_r) - -## test_cp_r_dev() [](#method-i-test_cp_r_dev) - -## test_cp_r_fifo() [](#method-i-test_cp_r_fifo) - -## test_cp_r_pathname() [](#method-i-test_cp_r_pathname) - -## test_cp_r_symlink() [](#method-i-test_cp_r_symlink) - -## test_cp_r_symlink_preserve() [](#method-i-test_cp_r_symlink_preserve) - -## test_cp_r_symlink_remove_destination() [](#method-i-test_cp_r_symlink_remove_destination) - -## test_cp_symlink() [](#method-i-test_cp_symlink) - -## test_getwd() [](#method-i-test_getwd) - -## test_have_option?() [](#method-i-test_have_option?) - -**@return** [Boolean] - -## test_identical?() [](#method-i-test_identical?) - -**@return** [Boolean] - -## test_install() [](#method-i-test_install) - -## test_install_broken_symlink() [](#method-i-test_install_broken_symlink) - -## test_install_group_option() [](#method-i-test_install_group_option) - -## test_install_mode_option() [](#method-i-test_install_mode_option) - -## test_install_owner_option() [](#method-i-test_install_owner_option) - -## test_install_pathname() [](#method-i-test_install_pathname) - -## test_install_symlink() [](#method-i-test_install_symlink) - -## test_link() [](#method-i-test_link) - -## test_ln() [](#method-i-test_ln) - -## test_ln_broken_symlink() [](#method-i-test_ln_broken_symlink) - -## test_ln_pathname() [](#method-i-test_ln_pathname) - -## test_ln_s() [](#method-i-test_ln_s) - -## test_ln_s_broken_symlink() [](#method-i-test_ln_s_broken_symlink) - -## test_ln_s_pathname() [](#method-i-test_ln_s_pathname) - -## test_ln_sf() [](#method-i-test_ln_sf) - -## test_ln_sf_broken_symlink() [](#method-i-test_ln_sf_broken_symlink) - -## test_ln_sf_pathname() [](#method-i-test_ln_sf_pathname) - -## test_ln_sr() [](#method-i-test_ln_sr) - -## test_ln_sr_broken_symlink() [](#method-i-test_ln_sr_broken_symlink) - -## test_ln_sr_pathname() [](#method-i-test_ln_sr_pathname) - -## test_ln_symlink() [](#method-i-test_ln_symlink) - -## test_makedirs() [](#method-i-test_makedirs) - -## test_mkdir() [](#method-i-test_mkdir) - -## test_mkdir_file_perm() [](#method-i-test_mkdir_file_perm) - -## test_mkdir_lf_in_path() [](#method-i-test_mkdir_lf_in_path) - -## test_mkdir_p() [](#method-i-test_mkdir_p) - -## test_mkdir_p_file_perm() [](#method-i-test_mkdir_p_file_perm) - -## test_mkdir_p_offline_drive() [](#method-i-test_mkdir_p_offline_drive) - -## test_mkdir_p_pathname() [](#method-i-test_mkdir_p_pathname) - -## test_mkdir_p_root() [](#method-i-test_mkdir_p_root) - -## test_mkdir_pathname() [](#method-i-test_mkdir_pathname) - -## test_mkpath() [](#method-i-test_mkpath) - -## test_move() [](#method-i-test_move) - -## test_mv() [](#method-i-test_mv) - -## test_mv_broken_symlink() [](#method-i-test_mv_broken_symlink) - -## test_mv_pathname() [](#method-i-test_mv_pathname) - -## test_mv_symlink() [](#method-i-test_mv_symlink) - -## test_options() [](#method-i-test_options) - -## test_options_of() [](#method-i-test_options_of) - -## test_pwd() [](#method-i-test_pwd) - -## test_remove_dir() [](#method-i-test_remove_dir) - -## test_remove_dir_file_perm() [](#method-i-test_remove_dir_file_perm) - -## test_remove_entry_cjk_path() [](#method-i-test_remove_entry_cjk_path) - -## test_remove_entry_multibyte_path() [](#method-i-test_remove_entry_multibyte_path) - -## test_remove_entry_secure() [](#method-i-test_remove_entry_secure) - -## test_remove_entry_secure_pathname() [](#method-i-test_remove_entry_secure_pathname) - -## test_remove_entry_secure_symlink() [](#method-i-test_remove_entry_secure_symlink) - -## test_remove_file() [](#method-i-test_remove_file) - -## test_remove_file_file_perm() [](#method-i-test_remove_file_file_perm) - -## test_rm() [](#method-i-test_rm) - -## test_rm_f() [](#method-i-test_rm_f) - -## test_rm_f_2() [](#method-i-test_rm_f_2) - -## test_rm_pathname() [](#method-i-test_rm_pathname) - -## test_rm_r() [](#method-i-test_rm_r) - -## test_rm_r_no_permissions() [](#method-i-test_rm_r_no_permissions) - -## test_rm_r_pathname() [](#method-i-test_rm_r_pathname) - -## test_rm_r_symlink() [](#method-i-test_rm_r_symlink) - -## test_rm_rf() [](#method-i-test_rm_rf) - -## test_rm_symlink() [](#method-i-test_rm_symlink) - -## test_rmdir() [](#method-i-test_rmdir) - -## test_rmtree() [](#method-i-test_rmtree) - -## test_s_chmod_verbose() [](#method-i-test_s_chmod_verbose) - -## test_safe_unlink() [](#method-i-test_safe_unlink) - -## test_symlink() [](#method-i-test_symlink) - -## test_touch() [](#method-i-test_touch) - -## test_uptodate?() [](#method-i-test_uptodate?) - -**@return** [Boolean] - -## test_with_big_file() [](#method-i-test_with_big_file) - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/TestFileUtils/Stream.md b/example/ruby/TestFileUtils/Stream.md deleted file mode 100644 index ac1c5cb..0000000 --- a/example/ruby/TestFileUtils/Stream.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestFileUtils::Stream -**Inherits:** Object - - - - - -#Instance Methods -## initialize(f) [](#method-i-initialize) - -**@return** [Stream] a new instance of Stream - -## read(*args) [](#method-i-read) - -## write(str) [](#method-i-write) - diff --git a/example/ruby/TestFileUtilsClobber.md b/example/ruby/TestFileUtilsClobber.md deleted file mode 100644 index 2d14d8b..0000000 --- a/example/ruby/TestFileUtilsClobber.md +++ /dev/null @@ -1,59 +0,0 @@ -# Module: TestFileUtilsClobber - -**Includes:** Test::Unit::FileAssertions - - - - - -#Instance Methods -## assert_directory(path, messagenil) [](#method-i-assert_directory) - -## assert_equal_filemode(file1, file2, messagenil, mask:07777) [](#method-i-assert_equal_filemode) - -## assert_equal_time(expected, actual, messagenil) [](#method-i-assert_equal_time) - -## assert_equal_timestamp(expected, actual, messagenil) [](#method-i-assert_equal_timestamp) - -## assert_file_exist(path, messagenil) [](#method-i-assert_file_exist) - -## assert_file_not_exist(path, messagenil) [](#method-i-assert_file_not_exist) - -## assert_filemode(expected, file, messagenil, mask:07777) [](#method-i-assert_filemode) - -## assert_not_symlink(path, messagenil) [](#method-i-assert_not_symlink) - -## assert_ownership_group(expected, file) [](#method-i-assert_ownership_group) - -## assert_ownership_user(expected, file) [](#method-i-assert_ownership_user) - -## assert_same_entry(from, to, messagenil) [](#method-i-assert_same_entry) - -## assert_same_file(from, to, messagenil) [](#method-i-assert_same_file) - -## assert_symlink(path, messagenil) [](#method-i-assert_symlink) - -## check(dest, messagenil) [](#method-i-check) - -## my_rm_rf(path) [](#method-i-my_rm_rf) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_copy_entry() [](#method-i-test_copy_entry) - -## test_cp() [](#method-i-test_cp) - -## test_mkdir() [](#method-i-test_mkdir) - -## test_mkdir_p() [](#method-i-test_mkdir_p) - -## test_mv() [](#method-i-test_mv) - -## test_rm() [](#method-i-test_rm) - -## test_rm_f() [](#method-i-test_rm_f) - -## test_rm_rf() [](#method-i-test_rm_rf) - diff --git a/example/ruby/TestFileUtilsDryRun.md b/example/ruby/TestFileUtilsDryRun.md deleted file mode 100644 index c2b0a2e..0000000 --- a/example/ruby/TestFileUtilsDryRun.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: TestFileUtilsDryRun -**Inherits:** Test::Unit::TestCase - -**Includes:** FileUtils::DryRun, TestFileUtilsIncVisibility - - - - - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## setup() [](#method-i-setup) - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/TestFileUtilsIncVisibility.md b/example/ruby/TestFileUtilsIncVisibility.md deleted file mode 100644 index 7e103c7..0000000 --- a/example/ruby/TestFileUtilsIncVisibility.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestFileUtilsIncVisibility - - -These tests are reused in the FileUtils::Verbose, FileUtils::NoWrite and -FileUtils::DryRun tests - - - diff --git a/example/ruby/TestFileUtilsNoWrite.md b/example/ruby/TestFileUtilsNoWrite.md deleted file mode 100644 index e0fd0d2..0000000 --- a/example/ruby/TestFileUtilsNoWrite.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: TestFileUtilsNoWrite -**Inherits:** Test::Unit::TestCase - -**Includes:** FileUtils::NoWrite, TestFileUtilsIncVisibility - - - - - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## setup() [](#method-i-setup) - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/TestFileUtilsVerbose.md b/example/ruby/TestFileUtilsVerbose.md deleted file mode 100644 index efc7f21..0000000 --- a/example/ruby/TestFileUtilsVerbose.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: TestFileUtilsVerbose -**Inherits:** Test::Unit::TestCase - -**Includes:** FileUtils::Verbose, TestFileUtilsIncVisibility - - - - - -#Instance Methods -## apply_mask(mode, user_mask, op, mode_mask) [](#method-i-apply_mask) -:nodoc: - -## fu_get_gid(group) [](#method-i-fu_get_gid) -:nodoc: - -## fu_get_uid(user) [](#method-i-fu_get_uid) -:nodoc: - -## fu_have_symlink?() [](#method-i-fu_have_symlink?) -:nodoc: - -**@return** [Boolean] - -## fu_mkdir(path, mode) [](#method-i-fu_mkdir) -:nodoc: - -## fu_mode(mode, path) [](#method-i-fu_mode) -:nodoc: - -## fu_stat_identical_entry?(a, b) [](#method-i-fu_stat_identical_entry?) -:nodoc: - -**@return** [Boolean] - -## mode_to_s(mode) [](#method-i-mode_to_s) -:nodoc: - -## remove_trailing_slash(dir) [](#method-i-remove_trailing_slash) -:nodoc: - -## setup() [](#method-i-setup) - -## symbolic_modes_to_i(mode_sym, path) [](#method-i-symbolic_modes_to_i) -:nodoc: - -## user_mask(target) [](#method-i-user_mask) -:nodoc: - diff --git a/example/ruby/TestFind.md b/example/ruby/TestFind.md deleted file mode 100644 index 68562bf..0000000 --- a/example/ruby/TestFind.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: TestFind -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_change_dir_to_file() [](#method-i-test_change_dir_to_file) - -## test_change_dir_to_symlink_loop() [](#method-i-test_change_dir_to_symlink_loop) - -## test_countdown3() [](#method-i-test_countdown3) - -## test_countup3() [](#method-i-test_countup3) - -## test_dangling_symlink() [](#method-i-test_dangling_symlink) - -## test_dangling_symlink_stat_error() [](#method-i-test_dangling_symlink_stat_error) - -## test_dont_follow_symlink() [](#method-i-test_dont_follow_symlink) - -## test_empty() [](#method-i-test_empty) - -## test_encoding_ascii() [](#method-i-test_encoding_ascii) - -## test_encoding_non_ascii() [](#method-i-test_encoding_non_ascii) - -## test_enumerator() [](#method-i-test_enumerator) - -## test_nonexistence() [](#method-i-test_nonexistence) - -## test_prune() [](#method-i-test_prune) - -## test_rec() [](#method-i-test_rec) - -## test_relative() [](#method-i-test_relative) - -## test_to_path() [](#method-i-test_to_path) - -## test_unreadable_dir() [](#method-i-test_unreadable_dir) - -## test_unsearchable_dir() [](#method-i-test_unsearchable_dir) - diff --git a/example/ruby/TestFind/TestInclude.md b/example/ruby/TestFind/TestInclude.md deleted file mode 100644 index 0987139..0000000 --- a/example/ruby/TestFind/TestInclude.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestFind::TestInclude -**Inherits:** Test::Unit::TestCase - -**Includes:** Find - - - - - -#Instance Methods -## test_functional_call() [](#method-i-test_functional_call) - diff --git a/example/ruby/TestFixnum.md b/example/ruby/TestFixnum.md deleted file mode 100644 index 47596e6..0000000 --- a/example/ruby/TestFixnum.md +++ /dev/null @@ -1,92 +0,0 @@ -# Class: TestFixnum -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_eql(a, b, mess) [](#method-i-assert_eql) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_abs() [](#method-i-test_abs) - -## test_and_with_float() [](#method-i-test_and_with_float) - -## test_and_with_nonintegral_numeric() [](#method-i-test_and_with_nonintegral_numeric) - -## test_and_with_rational() [](#method-i-test_and_with_rational) - -## test_cmp() [](#method-i-test_cmp) - -## test_div() [](#method-i-test_div) - -## test_divide() [](#method-i-test_divide) - -## test_divmod() [](#method-i-test_divmod) - -## test_finite_p() [](#method-i-test_finite_p) - -## test_frozen() [](#method-i-test_frozen) - -## test_infinite_p() [](#method-i-test_infinite_p) - -## test_lshift() [](#method-i-test_lshift) - -## test_minus() [](#method-i-test_minus) - -## test_mod() [](#method-i-test_mod) - -## test_mul() [](#method-i-test_mul) - -## test_mult() [](#method-i-test_mult) - -## test_negative_p() [](#method-i-test_negative_p) - -## test_not() [](#method-i-test_not) - -## test_or_with_float() [](#method-i-test_or_with_float) - -## test_or_with_nonintegral_numeric() [](#method-i-test_or_with_nonintegral_numeric) - -## test_or_with_rational() [](#method-i-test_or_with_rational) - -## test_plus() [](#method-i-test_plus) - -## test_plus2() [](#method-i-test_plus2) - -## test_positive_p() [](#method-i-test_positive_p) - -## test_pow() [](#method-i-test_pow) - -## test_pow2() [](#method-i-test_pow2) - -## test_power_of_0() [](#method-i-test_power_of_0) - -## test_power_of_1_and_minus_1() [](#method-i-test_power_of_1_and_minus_1) - -## test_pred() [](#method-i-test_pred) - -## test_remainder() [](#method-i-test_remainder) - -## test_rshift() [](#method-i-test_rshift) - -## test_singleton_method() [](#method-i-test_singleton_method) - -## test_sub() [](#method-i-test_sub) - -## test_succ() [](#method-i-test_succ) - -## test_to_s() [](#method-i-test_to_s) - -## test_xor_with_float() [](#method-i-test_xor_with_float) - -## test_xor_with_nonintegral_numeric() [](#method-i-test_xor_with_nonintegral_numeric) - -## test_xor_with_rational() [](#method-i-test_xor_with_rational) - -## test_zero_p() [](#method-i-test_zero_p) - diff --git a/example/ruby/TestFixnum/DummyNumeric.md b/example/ruby/TestFixnum/DummyNumeric.md deleted file mode 100644 index 189dab8..0000000 --- a/example/ruby/TestFixnum/DummyNumeric.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestFixnum::DummyNumeric -**Inherits:** Numeric - - - - - -#Instance Methods -## to_int() [](#method-i-to_int) - diff --git a/example/ruby/TestFlip.md b/example/ruby/TestFlip.md deleted file mode 100644 index 8d9cdb2..0000000 --- a/example/ruby/TestFlip.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestFlip -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_flip_flop() [](#method-i-test_flip_flop) - -## test_hidden_key() [](#method-i-test_hidden_key) - -## test_input_line_number_range() [](#method-i-test_input_line_number_range) - -## test_shared_eval() [](#method-i-test_shared_eval) - -## test_shared_thread() [](#method-i-test_shared_thread) - diff --git a/example/ruby/TestFloat.md b/example/ruby/TestFloat.md deleted file mode 100644 index a7acd9e..0000000 --- a/example/ruby/TestFloat.md +++ /dev/null @@ -1,137 +0,0 @@ -# Class: TestFloat -**Inherits:** Test::Unit::TestCase - -**Includes:** EnvUtil - - - - -# Class Methods -## infinite?() [](#method-c-infinite?) -**@return** [Boolean] - -## to_int() [](#method-c-to_int) - -#Instance Methods -## nan_test(x, y) [](#method-i-nan_test) - -## test_Float() [](#method-i-test_Float) - -## test_Float_with_exception_keyword() [](#method-i-test_Float_with_exception_keyword) - -## test_Float_with_invalid_exception() [](#method-i-test_Float_with_invalid_exception) - -## test_aliased_quo_recursion() [](#method-i-test_aliased_quo_recursion) - -## test_ceil() [](#method-i-test_ceil) - -## test_ceil_with_precision() [](#method-i-test_ceil_with_precision) - -## test_cmp() [](#method-i-test_cmp) - -## test_cmp_int() [](#method-i-test_cmp_int) - -## test_coerce() [](#method-i-test_coerce) - -## test_div() [](#method-i-test_div) - -## test_div2() [](#method-i-test_div2) - -## test_divmod() [](#method-i-test_divmod) - -## test_divmod2() [](#method-i-test_divmod2) - -## test_eql() [](#method-i-test_eql) - -## test_finite_p() [](#method-i-test_finite_p) - -## test_float() [](#method-i-test_float) - -## test_floor() [](#method-i-test_floor) - -## test_floor_ceil_round_truncate() [](#method-i-test_floor_ceil_round_truncate) - -## test_floor_with_precision() [](#method-i-test_floor_with_precision) - -## test_hash_0() [](#method-i-test_hash_0) - -## test_infinite_p() [](#method-i-test_infinite_p) - -## test_invalid_str() [](#method-i-test_invalid_str) - -## test_long_string() [](#method-i-test_long_string) - -## test_minus() [](#method-i-test_minus) - -## test_modulo() [](#method-i-test_modulo) - -## test_modulo2() [](#method-i-test_modulo2) - -## test_modulo3() [](#method-i-test_modulo3) - -## test_modulo4() [](#method-i-test_modulo4) - -## test_mul() [](#method-i-test_mul) - -## test_nan() [](#method-i-test_nan) - -## test_negative_p() [](#method-i-test_negative_p) - -## test_next_float() [](#method-i-test_next_float) - -## test_next_prev_float_zero() [](#method-i-test_next_prev_float_zero) - -## test_num2dbl() [](#method-i-test_num2dbl) - -## test_plus() [](#method-i-test_plus) - -## test_positive_p() [](#method-i-test_positive_p) - -## test_pow() [](#method-i-test_pow) - -## test_precision() [](#method-i-test_precision) - -## test_prev_float() [](#method-i-test_prev_float) - -## test_remainder() [](#method-i-test_remainder) - -## test_round() [](#method-i-test_round) - -## test_round_half_down() [](#method-i-test_round_half_down) - -## test_round_half_even() [](#method-i-test_round_half_even) - -## test_round_half_even_with_precision() [](#method-i-test_round_half_even_with_precision) - -## test_round_half_invalid() [](#method-i-test_round_half_invalid) - -## test_round_half_nil() [](#method-i-test_round_half_nil) - -## test_round_half_up() [](#method-i-test_round_half_up) - -## test_round_with_precision() [](#method-i-test_round_with_precision) - -## test_singleton_method() [](#method-i-test_singleton_method) - -## test_sleep_with_Float() [](#method-i-test_sleep_with_Float) - -## test_step() [](#method-i-test_step) - -## test_step2() [](#method-i-test_step2) - -## test_step_excl() [](#method-i-test_step_excl) - -## test_strtod() [](#method-i-test_strtod) - -## test_symmetry_bignum() [](#method-i-test_symmetry_bignum) -ruby-bugs-ja:118 -: - -## test_to_s() [](#method-i-test_to_s) - -## test_truncate() [](#method-i-test_truncate) - -## test_truncate_with_precision() [](#method-i-test_truncate_with_precision) - -## test_zero_p() [](#method-i-test_zero_p) - diff --git a/example/ruby/TestFloatExt.md b/example/ruby/TestFloatExt.md deleted file mode 100644 index ddd8ea8..0000000 --- a/example/ruby/TestFloatExt.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestFloatExt -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/TestFnmatch.md b/example/ruby/TestFnmatch.md deleted file mode 100644 index cb16ee0..0000000 --- a/example/ruby/TestFnmatch.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: TestFnmatch -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## bracket_test(s, t) [](#method-i-bracket_test) -`s' should start with neither '!' nor '^' - -## test_any_chars() [](#method-i-test_any_chars) - -## test_any_one() [](#method-i-test_any_one) - -## test_char_class() [](#method-i-test_char_class) - -## test_escape() [](#method-i-test_escape) - -## test_extglob() [](#method-i-test_extglob) - -## test_fnm_casefold() [](#method-i-test_fnm_casefold) - -## test_fnm_dotmatch() [](#method-i-test_fnm_dotmatch) - -## test_fnm_escape() [](#method-i-test_fnm_escape) - -## test_fnm_pathname() [](#method-i-test_fnm_pathname) - -## test_fnmatch() [](#method-i-test_fnmatch) - -## test_nullchar() [](#method-i-test_nullchar) - -## test_recursive() [](#method-i-test_recursive) - -## test_text() [](#method-i-test_text) - -## test_unicode() [](#method-i-test_unicode) - -## test_unmatched_encoding() [](#method-i-test_unmatched_encoding) - diff --git a/example/ruby/TestForTestHideSkip.md b/example/ruby/TestForTestHideSkip.md deleted file mode 100644 index 1c4e146..0000000 --- a/example/ruby/TestForTestHideSkip.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestForTestHideSkip -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_a() [](#method-i-test_a) - -## test_b() [](#method-i-test_b) - -## test_c() [](#method-i-test_c) - -## test_omit() [](#method-i-test_omit) - -## test_pend() [](#method-i-test_pend) - diff --git a/example/ruby/TestForTestRedefinition.md b/example/ruby/TestForTestRedefinition.md deleted file mode 100644 index db173d1..0000000 --- a/example/ruby/TestForTestRedefinition.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestForTestRedefinition -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_redefinition() [](#method-i-test_redefinition) - diff --git a/example/ruby/TestForTestTimeout.md b/example/ruby/TestForTestTimeout.md deleted file mode 100644 index 7cc2e27..0000000 --- a/example/ruby/TestForTestTimeout.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestForTestTimeout -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/TestFormatter.md b/example/ruby/TestFormatter.md deleted file mode 100644 index eb0d19c..0000000 --- a/example/ruby/TestFormatter.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestFormatter -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_call() [](#method-i-test_call) - -## test_format_datetime() [](#method-i-test_format_datetime) - diff --git a/example/ruby/TestFormatter/CustomFormatter.md b/example/ruby/TestFormatter/CustomFormatter.md deleted file mode 100644 index 0651b78..0000000 --- a/example/ruby/TestFormatter/CustomFormatter.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestFormatter::CustomFormatter -**Inherits:** Logger::Formatter - - - - - -#Instance Methods -## call(time) [](#method-i-call) - diff --git a/example/ruby/TestForwardable.md b/example/ruby/TestForwardable.md deleted file mode 100644 index 9038f7a..0000000 --- a/example/ruby/TestForwardable.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: TestForwardable -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## baz() [](#method-c-baz) - -#Instance Methods -## test_aref() [](#method-i-test_aref) - -## test_aset() [](#method-i-test_aset) - -## test_backtrace_adjustment() [](#method-i-test_backtrace_adjustment) - -## test_basicobject_subclass() [](#method-i-test_basicobject_subclass) - -## test_binop() [](#method-i-test_binop) - -## test_class_single_delegate() [](#method-i-test_class_single_delegate) - -## test_class_single_delegator() [](#method-i-test_class_single_delegator) - -## test_class_single_delegators() [](#method-i-test_class_single_delegators) - -## test_def_instance_delegate_using_args_method_as_receiver() [](#method-i-test_def_instance_delegate_using_args_method_as_receiver) - -## test_def_instance_delegate_using_block_method_as_receiver() [](#method-i-test_def_instance_delegate_using_block_method_as_receiver) - -## test_def_instance_delegator() [](#method-i-test_def_instance_delegator) - -## test_def_instance_delegator_constant() [](#method-i-test_def_instance_delegator_constant) - -## test_def_instance_delegator_kw() [](#method-i-test_def_instance_delegator_kw) - -## test_def_instance_delegator_using_args_method_as_receiver() [](#method-i-test_def_instance_delegator_using_args_method_as_receiver) - -## test_def_instance_delegator_using_block_method_as_receiver() [](#method-i-test_def_instance_delegator_using_block_method_as_receiver) - -## test_def_instance_delegators() [](#method-i-test_def_instance_delegators) - -## test_def_instance_delegators_send_id() [](#method-i-test_def_instance_delegators_send_id) - -## test_def_instance_delegators_using_args_method_as_receiver() [](#method-i-test_def_instance_delegators_using_args_method_as_receiver) - -## test_def_instance_delegators_using_block_method_as_receiver() [](#method-i-test_def_instance_delegators_using_block_method_as_receiver) - -## test_instance_delegate() [](#method-i-test_instance_delegate) - -## test_non_module() [](#method-i-test_non_module) - -## test_obj_single_delegate() [](#method-i-test_obj_single_delegate) - -## test_obj_single_delegator() [](#method-i-test_obj_single_delegator) - -## test_obj_single_delegators() [](#method-i-test_obj_single_delegators) - -## test_obj_single_delegators_send_id() [](#method-i-test_obj_single_delegators_send_id) - -## test_on_private_method() [](#method-i-test_on_private_method) - -## test_uniop() [](#method-i-test_uniop) - diff --git a/example/ruby/TestForwardable/Foo.md b/example/ruby/TestForwardable/Foo.md deleted file mode 100644 index 5a138ce..0000000 --- a/example/ruby/TestForwardable/Foo.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: TestForwardable::Foo -**Inherits:** Object - -**Extended by:** Forwardable - - - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor -# Attributes -## bar[RW] [](#attribute-i-bar) -Returns the value of attribute bar. - - diff --git a/example/ruby/TestForwardable/Foo2.md b/example/ruby/TestForwardable/Foo2.md deleted file mode 100644 index 1cefe50..0000000 --- a/example/ruby/TestForwardable/Foo2.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: TestForwardable::Foo2 -**Inherits:** BasicObject - -**Extended by:** Forwardable - - - - -# Class Methods -## def_instance_delegator(accessor , method , ali method) [](#method-c-def_instance_delegator) -Define `method` as delegator instance method with an optional alias name -`ali`. Method calls to `ali` will be delegated to `accessor.method`. -`accessor` should be a method name, instance variable name, or constant name. -Use the full path to the constant if providing the constant name. Returns the -name of the method defined. - - class MyQueue - CONST = 1 - extend Forwardable - attr_reader :queue - def initialize - @queue = [] - end - - def_delegator :@queue, :push, :mypush - def_delegator 'MyQueue::CONST', :to_i - end - - q = MyQueue.new - q.mypush 42 - q.queue #=> [42] - q.push 23 #=> NoMethodError - q.to_i #=> 1 -## def_instance_delegators(accessor , *methods ) [](#method-c-def_instance_delegators) -Shortcut for defining multiple delegator methods, but with no provision for -using a different name. The following two code samples have the same effect: - - def_delegators :@records, :size, :<<, :map - - def_delegator :@records, :size - def_delegator :@records, :<< - def_delegator :@records, :map -## instance_delegate(hash ) [](#method-c-instance_delegate) -Takes a hash as its argument. The key is a symbol or an array of symbols. -These symbols correspond to method names, instance variable names, or constant -names (see def_delegator). The value is the accessor to which the methods -will be delegated. - -:call-seq: - delegate method => accessor - delegate [method, method, ...] => accessor - diff --git a/example/ruby/TestFrozen.md b/example/ruby/TestFrozen.md deleted file mode 100644 index e298b75..0000000 --- a/example/ruby/TestFrozen.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestFrozen -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_setting_ivar_on_frozen_obj() [](#method-i-test_setting_ivar_on_frozen_obj) - -## test_setting_ivar_on_frozen_obj_with_ivars() [](#method-i-test_setting_ivar_on_frozen_obj_with_ivars) - -## test_setting_ivar_on_frozen_string() [](#method-i-test_setting_ivar_on_frozen_string) - -## test_setting_ivar_on_frozen_string_with_ivars() [](#method-i-test_setting_ivar_on_frozen_string_with_ivars) - diff --git a/example/ruby/TestFrozenError.md b/example/ruby/TestFrozenError.md deleted file mode 100644 index 13939b8..0000000 --- a/example/ruby/TestFrozenError.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestFrozenError -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_message() [](#method-i-test_message) - -## test_new_default() [](#method-i-test_new_default) - -## test_new_message() [](#method-i-test_new_message) - -## test_new_receiver() [](#method-i-test_new_receiver) - -## test_receiver() [](#method-i-test_receiver) - diff --git a/example/ruby/TestFuncall.md b/example/ruby/TestFuncall.md deleted file mode 100644 index 3622be4..0000000 --- a/example/ruby/TestFuncall.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestFuncall -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## extra_args_name() [](#method-c-extra_args_name) - -#Instance Methods -## test_funcall_extra_args() [](#method-i-test_funcall_extra_args) - -## test_with_funcall2() [](#method-i-test_with_funcall2) - -## test_with_funcall_passing_block() [](#method-i-test_with_funcall_passing_block) - -## test_with_funcall_passing_block_kw() [](#method-i-test_with_funcall_passing_block_kw) - -## test_with_funcallv_public_kw() [](#method-i-test_with_funcallv_public_kw) - -## test_with_yield_splat_kw() [](#method-i-test_with_yield_splat_kw) - diff --git a/example/ruby/TestFuncall/Relay.md b/example/ruby/TestFuncall/Relay.md deleted file mode 100644 index 5435171..0000000 --- a/example/ruby/TestFuncall/Relay.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: TestFuncall::Relay - - - - -# Class Methods -## target(*args , **kw , &block ) [](#method-c-target) -**@yield** [args, kw] - -## with_funcall2(*args ) [](#method-c-with_funcall2) -## with_funcall_passing_block(*args ) [](#method-c-with_funcall_passing_block) -## with_funcall_passing_block_kw(*args ) [](#method-c-with_funcall_passing_block_kw) -## with_funcallv_public_kw(*args ) [](#method-c-with_funcallv_public_kw) -## with_yield_splat_kw(*args ) [](#method-c-with_yield_splat_kw) - diff --git a/example/ruby/TestGB18030.md b/example/ruby/TestGB18030.md deleted file mode 100644 index b7013dc..0000000 --- a/example/ruby/TestGB18030.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestGB18030 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## fcheck(c) [](#method-i-fcheck) - -## s(s) [](#method-i-s) - -## scheck(c, i) [](#method-i-scheck) - -## test_code_to_mbc() [](#method-i-test_code_to_mbc) - -## test_left_adjust_char_head() [](#method-i-test_left_adjust_char_head) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_mbc_enc_len() [](#method-i-test_mbc_enc_len) - -## test_mbc_to_code() [](#method-i-test_mbc_to_code) - diff --git a/example/ruby/TestGBK.md b/example/ruby/TestGBK.md deleted file mode 100644 index a090247..0000000 --- a/example/ruby/TestGBK.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGBK -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## s(s) [](#method-i-s) - -## test_code_to_mbc() [](#method-i-test_code_to_mbc) - -## test_left_adjust_char_head() [](#method-i-test_left_adjust_char_head) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_mbc_enc_len() [](#method-i-test_mbc_enc_len) - -## test_mbc_to_code() [](#method-i-test_mbc_to_code) - diff --git a/example/ruby/TestGCCompact.md b/example/ruby/TestGCCompact.md deleted file mode 100644 index 2a07716..0000000 --- a/example/ruby/TestGCCompact.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: TestGCCompact -**Inherits:** Test::Unit::TestCase - -**Includes:** TestGCCompact::OmitUnlessCompactSupported - - - - - -#Instance Methods -## big_list(level10) [](#method-i-big_list) - -## setup() [](#method-i-setup) - -## supports_compact?() [](#method-i-supports_compact?) - -**@return** [Boolean] - -## test_ast_compacts() [](#method-i-test_ast_compacts) - -## test_compact_count() [](#method-i-test_compact_count) - -## test_compacting_from_trace_point() [](#method-i-test_compacting_from_trace_point) - -## test_complex_hash_keys() [](#method-i-test_complex_hash_keys) - -## test_gc_compact_stats() [](#method-i-test_gc_compact_stats) - -## test_moving_arrays_down_heaps() [](#method-i-test_moving_arrays_down_heaps) - -## test_moving_arrays_up_heaps() [](#method-i-test_moving_arrays_up_heaps) - -## test_moving_hashes_down_heaps() [](#method-i-test_moving_hashes_down_heaps) - -## test_moving_objects_between_heaps() [](#method-i-test_moving_objects_between_heaps) - -## test_moving_objects_between_heaps_keeps_shape_frozen_status() [](#method-i-test_moving_objects_between_heaps_keeps_shape_frozen_status) - -## test_moving_strings_down_heaps() [](#method-i-test_moving_strings_down_heaps) - -## test_moving_strings_up_heaps() [](#method-i-test_moving_strings_up_heaps) - -## test_updating_references_for_embed_frozen_shared_arrays() [](#method-i-test_updating_references_for_embed_frozen_shared_arrays) - -## test_updating_references_for_embed_shared_arrays() [](#method-i-test_updating_references_for_embed_shared_arrays) - -## test_updating_references_for_heap_allocated_frozen_shared_arrays() [](#method-i-test_updating_references_for_heap_allocated_frozen_shared_arrays) - -## test_updating_references_for_heap_allocated_shared_arrays() [](#method-i-test_updating_references_for_heap_allocated_shared_arrays) - diff --git a/example/ruby/TestGCCompact/AutoCompact.md b/example/ruby/TestGCCompact/AutoCompact.md deleted file mode 100644 index 94557ec..0000000 --- a/example/ruby/TestGCCompact/AutoCompact.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestGCCompact::AutoCompact -**Inherits:** Test::Unit::TestCase - -**Includes:** TestGCCompact::OmitUnlessCompactSupported - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## supports_compact?() [](#method-i-supports_compact?) - -**@return** [Boolean] - -## test_disable_autocompact() [](#method-i-test_disable_autocompact) - -## test_enable_autocompact() [](#method-i-test_enable_autocompact) - -## test_implicit_compaction_does_something() [](#method-i-test_implicit_compaction_does_something) - -## test_major_compacts() [](#method-i-test_major_compacts) - diff --git a/example/ruby/TestGCCompact/CompactMethodsNotImplemented.md b/example/ruby/TestGCCompact/CompactMethodsNotImplemented.md deleted file mode 100644 index 191d30d..0000000 --- a/example/ruby/TestGCCompact/CompactMethodsNotImplemented.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestGCCompact::CompactMethodsNotImplemented -**Inherits:** Test::Unit::TestCase - -**Includes:** TestGCCompact::CompactionSupportInspector - - - - - -#Instance Methods -## assert_not_implemented(method, *args) [](#method-i-assert_not_implemented) - -## supports_compact?() [](#method-i-supports_compact?) - -**@return** [Boolean] - -## test_gc_auto_compact_get_not_implemented() [](#method-i-test_gc_auto_compact_get_not_implemented) - -## test_gc_auto_compact_set_not_implemented() [](#method-i-test_gc_auto_compact_set_not_implemented) - -## test_gc_compact_not_implemented() [](#method-i-test_gc_compact_not_implemented) - -## test_gc_latest_compact_info_not_implemented() [](#method-i-test_gc_latest_compact_info_not_implemented) - -## test_gc_verify_compaction_references_not_implemented() [](#method-i-test_gc_verify_compaction_references_not_implemented) - diff --git a/example/ruby/TestGCCompact/CompactionSupportInspector.md b/example/ruby/TestGCCompact/CompactionSupportInspector.md deleted file mode 100644 index 6ca7b32..0000000 --- a/example/ruby/TestGCCompact/CompactionSupportInspector.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: TestGCCompact::CompactionSupportInspector - - - - - -#Instance Methods -## supports_compact?() [](#method-i-supports_compact?) - -**@return** [Boolean] - diff --git a/example/ruby/TestGCCompact/OmitUnlessCompactSupported.md b/example/ruby/TestGCCompact/OmitUnlessCompactSupported.md deleted file mode 100644 index f421bba..0000000 --- a/example/ruby/TestGCCompact/OmitUnlessCompactSupported.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: TestGCCompact::OmitUnlessCompactSupported - -**Includes:** TestGCCompact::CompactionSupportInspector - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## supports_compact?() [](#method-i-supports_compact?) - -**@return** [Boolean] - diff --git a/example/ruby/TestGc.md b/example/ruby/TestGc.md deleted file mode 100644 index bbe652f..0000000 --- a/example/ruby/TestGc.md +++ /dev/null @@ -1,116 +0,0 @@ -# Class: TestGc -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_ast_node_buffer() [](#method-i-test_ast_node_buffer) - -## test_count() [](#method-i-test_count) - -## test_enable_disable() [](#method-i-test_enable_disable) - -## test_exception_in_finalizer() [](#method-i-test_exception_in_finalizer) - -## test_exception_in_finalizer_method() [](#method-i-test_exception_in_finalizer_method) - -## test_exception_in_finalizer_procs() [](#method-i-test_exception_in_finalizer_procs) - -## test_expand_heap() [](#method-i-test_expand_heap) - -## test_finalizer_passed_object_id() [](#method-i-test_finalizer_passed_object_id) - -## test_finalizing_main_thread() [](#method-i-test_finalizing_main_thread) - -## test_gc() [](#method-i-test_gc) - -## test_gc_config_disable_major() [](#method-i-test_gc_config_disable_major) - -## test_gc_config_disable_major_gc_start_always_works() [](#method-i-test_gc_config_disable_major_gc_start_always_works) - -## test_gc_config_full_mark_by_default() [](#method-i-test_gc_config_full_mark_by_default) - -## test_gc_config_implementation() [](#method-i-test_gc_config_implementation) - -## test_gc_config_implementation_is_readonly() [](#method-i-test_gc_config_implementation_is_readonly) - -## test_gc_config_invalid_args() [](#method-i-test_gc_config_invalid_args) - -## test_gc_config_setting_returns_nil_for_missing_keys() [](#method-i-test_gc_config_setting_returns_nil_for_missing_keys) - -## test_gc_config_setting_returns_updated_config_hash() [](#method-i-test_gc_config_setting_returns_updated_config_hash) - -## test_gc_disabled_start() [](#method-i-test_gc_disabled_start) - -## test_gc_internals() [](#method-i-test_gc_internals) - -## test_gc_parameter() [](#method-i-test_gc_parameter) - -## test_gc_parameter_init_slots() [](#method-i-test_gc_parameter_init_slots) - -## test_gc_stress_at_startup() [](#method-i-test_gc_stress_at_startup) - -## test_gc_stress_on_realloc() [](#method-i-test_gc_stress_on_realloc) - -## test_interrupt_in_finalizer() [](#method-i-test_interrupt_in_finalizer) - -## test_latest_gc_info() [](#method-i-test_latest_gc_info) - -## test_latest_gc_info_argument() [](#method-i-test_latest_gc_info_argument) - -## test_latest_gc_info_need_major_by() [](#method-i-test_latest_gc_info_need_major_by) - -## test_latest_gc_info_weak_references_count() [](#method-i-test_latest_gc_info_weak_references_count) - -## test_measure_total_time() [](#method-i-test_measure_total_time) - -## test_object_ids_never_repeat() [](#method-i-test_object_ids_never_repeat) - -## test_old_to_young_reference() [](#method-i-test_old_to_young_reference) - -## test_profiler_clear() [](#method-i-test_profiler_clear) - -## test_profiler_enabled() [](#method-i-test_profiler_enabled) - -## test_profiler_raw_data() [](#method-i-test_profiler_raw_data) - -## test_profiler_total_time() [](#method-i-test_profiler_total_time) - -## test_singleton_method() [](#method-i-test_singleton_method) - -## test_singleton_method_added() [](#method-i-test_singleton_method_added) - -## test_start_full_mark() [](#method-i-test_start_full_mark) - -## test_start_immediate_sweep() [](#method-i-test_start_immediate_sweep) - -## test_stat() [](#method-i-test_stat) - -## test_stat_argument() [](#method-i-test_stat_argument) - -## test_stat_constraints() [](#method-i-test_stat_constraints) - -## test_stat_heap() [](#method-i-test_stat_heap) - -## test_stat_heap_all() [](#method-i-test_stat_heap_all) - -## test_stat_heap_constraints() [](#method-i-test_stat_heap_constraints) - -## test_stat_single() [](#method-i-test_stat_single) - -## test_stress_compile_send() [](#method-i-test_stress_compile_send) - -## test_sweep_in_finalizer() [](#method-i-test_sweep_in_finalizer) - -## test_thrashing_for_young_objects() [](#method-i-test_thrashing_for_young_objects) - -## test_verify_internal_consistency() [](#method-i-test_verify_internal_consistency) - -## test_vm_object() [](#method-i-test_vm_object) - -## use_rgengc?() [](#method-i-use_rgengc?) - -**@return** [Boolean] - diff --git a/example/ruby/TestGc/S.md b/example/ruby/TestGc/S.md deleted file mode 100644 index 7b9142a..0000000 --- a/example/ruby/TestGc/S.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGc::S -**Inherits:** Object - - - - - -#Instance Methods -## initialize(a) [](#method-i-initialize) - -**@return** [S] a new instance of S - diff --git a/example/ruby/TestGem.md b/example/ruby/TestGem.md deleted file mode 100644 index 5f09448..0000000 --- a/example/ruby/TestGem.md +++ /dev/null @@ -1,272 +0,0 @@ -# Class: TestGem -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## assert_self_install_permissions(format_executable:false, data_mode:0o640) [](#method-i-assert_self_install_permissions) - -## setup() [](#method-i-setup) - -## test_activate_bin_path_does_not_error_if_a_gem_thats_not_finally_activated_has_orphaned_dependencies() [](#method-i-test_activate_bin_path_does_not_error_if_a_gem_thats_not_finally_activated_has_orphaned_dependencies) - -## test_activate_bin_path_gives_proper_error_for_bundler_when_underscore_selection_given() [](#method-i-test_activate_bin_path_gives_proper_error_for_bundler_when_underscore_selection_given) - -## test_activate_bin_path_in_debug_mode() [](#method-i-test_activate_bin_path_in_debug_mode) - -## test_activate_bin_path_raises_a_meaningful_error_if_a_gem_thats_finally_activated_has_orphaned_dependencies() [](#method-i-test_activate_bin_path_raises_a_meaningful_error_if_a_gem_thats_finally_activated_has_orphaned_dependencies) - -## test_activate_bin_path_resolves_eagerly() [](#method-i-test_activate_bin_path_resolves_eagerly) - -## test_activate_bin_path_respects_underscore_selection_if_given() [](#method-i-test_activate_bin_path_respects_underscore_selection_if_given) - -## test_activate_bin_path_selects_exact_bundler_version_if_present() [](#method-i-test_activate_bin_path_selects_exact_bundler_version_if_present) - -## test_activated_specs_does_not_cause_duplicates_when_looping_through_specs() [](#method-i-test_activated_specs_does_not_cause_duplicates_when_looping_through_specs) - -## test_data_home_default() [](#method-i-test_data_home_default) - -## test_data_home_from_env() [](#method-i-test_data_home_from_env) - -## test_default_path() [](#method-i-test_default_path) - -## test_default_path_missing_vendor() [](#method-i-test_default_path_missing_vendor) - -## test_default_path_user_home() [](#method-i-test_default_path_user_home) - -## test_default_path_vendor_dir() [](#method-i-test_default_path_vendor_dir) - -## test_default_source_date_epoch_doesnt_change() [](#method-i-test_default_source_date_epoch_doesnt_change) -Ensure that `Gem.source_date_epoch` is consistent even if $SOURCE_DATE_EPOCH -has not been set. - -## test_deprecated_paths=() [](#method-i-test_deprecated_paths=) - -## test_gem_path_ordering() [](#method-i-test_gem_path_ordering) - -## test_gem_path_ordering_short() [](#method-i-test_gem_path_ordering_short) - -## test_load_env_plugins() [](#method-i-test_load_env_plugins) - -## test_load_plugins() [](#method-i-test_load_plugins) - -## test_load_user_installed_plugins() [](#method-i-test_load_user_installed_plugins) - -## test_operating_system_defaults() [](#method-i-test_operating_system_defaults) - -## test_platform_defaults() [](#method-i-test_platform_defaults) - -## test_register_default_spec() [](#method-i-test_register_default_spec) - -## test_register_default_spec_old_style_with_folder_starting_with_lib() [](#method-i-test_register_default_spec_old_style_with_folder_starting_with_lib) - -## test_require_does_not_glob() [](#method-i-test_require_does_not_glob) - -## test_require_missing() [](#method-i-test_require_missing) - -## test_self_activate_bin_path_no_exec_name() [](#method-i-test_self_activate_bin_path_no_exec_name) - -## test_self_bin_path_active() [](#method-i-test_self_bin_path_active) - -## test_self_bin_path_bin_file_gone_in_latest() [](#method-i-test_self_bin_path_bin_file_gone_in_latest) - -## test_self_bin_path_bin_name() [](#method-i-test_self_bin_path_bin_name) - -## test_self_bin_path_bin_name_version() [](#method-i-test_self_bin_path_bin_name_version) - -## test_self_bin_path_no_bin_file() [](#method-i-test_self_bin_path_no_bin_file) - -## test_self_bin_path_no_exec_name() [](#method-i-test_self_bin_path_no_exec_name) - -## test_self_bin_path_nonexistent_binfile() [](#method-i-test_self_bin_path_nonexistent_binfile) - -## test_self_bin_path_not_found() [](#method-i-test_self_bin_path_not_found) - -## test_self_bin_path_picking_newest() [](#method-i-test_self_bin_path_picking_newest) - -## test_self_bindir() [](#method-i-test_self_bindir) - -## test_self_bindir_default_dir() [](#method-i-test_self_bindir_default_dir) - -## test_self_clear_paths() [](#method-i-test_self_clear_paths) - -## test_self_configuration() [](#method-i-test_self_configuration) - -## test_self_datadir() [](#method-i-test_self_datadir) - -## test_self_datadir_nonexistent_package() [](#method-i-test_self_datadir_nonexistent_package) - -## test_self_default_exec_format() [](#method-i-test_self_default_exec_format) - -## test_self_default_exec_format_18() [](#method-i-test_self_default_exec_format_18) - -## test_self_default_exec_format_jruby() [](#method-i-test_self_default_exec_format_jruby) - -## test_self_default_sources() [](#method-i-test_self_default_sources) - -## test_self_dir() [](#method-i-test_self_dir) - -## test_self_done_installing() [](#method-i-test_self_done_installing) - -## test_self_ensure_gem_directories() [](#method-i-test_self_ensure_gem_directories) - -## test_self_ensure_gem_directories_missing_parents() [](#method-i-test_self_ensure_gem_directories_missing_parents) - -## test_self_ensure_gem_directories_non_existent_paths() [](#method-i-test_self_ensure_gem_directories_non_existent_paths) - -## test_self_ensure_gem_directories_permissions() [](#method-i-test_self_ensure_gem_directories_permissions) - -## test_self_ensure_gem_directories_safe_permissions() [](#method-i-test_self_ensure_gem_directories_safe_permissions) - -## test_self_ensure_gem_directories_write_protected() [](#method-i-test_self_ensure_gem_directories_write_protected) - -## test_self_ensure_gem_directories_write_protected_parents() [](#method-i-test_self_ensure_gem_directories_write_protected_parents) - -## test_self_env_requirement() [](#method-i-test_self_env_requirement) - -## test_self_extension_dir_shared() [](#method-i-test_self_extension_dir_shared) - -## test_self_extension_dir_static() [](#method-i-test_self_extension_dir_static) - -## test_self_find_files() [](#method-i-test_self_find_files) - -## test_self_find_latest_files() [](#method-i-test_self_find_latest_files) - -## test_self_finish_resolve() [](#method-i-test_self_finish_resolve) - -## test_self_finish_resolve_respects_loaded_specs() [](#method-i-test_self_finish_resolve_respects_loaded_specs) - -## test_self_finish_resolve_wtf() [](#method-i-test_self_finish_resolve_wtf) - -## test_self_gunzip() [](#method-i-test_self_gunzip) - -## test_self_gzip() [](#method-i-test_self_gzip) - -## test_self_install() [](#method-i-test_self_install) - -## test_self_install_in_rescue() [](#method-i-test_self_install_in_rescue) - -## test_self_install_permissions() [](#method-i-test_self_install_permissions) - -## test_self_install_permissions_umask_0() [](#method-i-test_self_install_permissions_umask_0) - -## test_self_install_permissions_umask_077() [](#method-i-test_self_install_permissions_umask_077) - -## test_self_install_permissions_with_format_executable() [](#method-i-test_self_install_permissions_with_format_executable) - -## test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name() [](#method-i-test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name) - -## test_self_latest_rubygems_version() [](#method-i-test_self_latest_rubygems_version) - -## test_self_latest_spec_for() [](#method-i-test_self_latest_spec_for) - -## test_self_latest_spec_for_multiple_sources() [](#method-i-test_self_latest_spec_for_multiple_sources) - -## test_self_latest_version_for() [](#method-i-test_self_latest_version_for) - -## test_self_latest_version_for_multiple_sources() [](#method-i-test_self_latest_version_for_multiple_sources) - -## test_self_loaded_specs() [](#method-i-test_self_loaded_specs) - -## test_self_needs() [](#method-i-test_self_needs) - -## test_self_needs_picks_up_unresolved_deps() [](#method-i-test_self_needs_picks_up_unresolved_deps) - -## test_self_path() [](#method-i-test_self_path) - -## test_self_path_ENV_PATH() [](#method-i-test_self_path_ENV_PATH) - -## test_self_path_default() [](#method-i-test_self_path_default) - -## test_self_path_duplicate() [](#method-i-test_self_path_duplicate) - -## test_self_path_overlap() [](#method-i-test_self_path_overlap) - -## test_self_paths_eq() [](#method-i-test_self_paths_eq) - -## test_self_paths_eq_nonexistent_home() [](#method-i-test_self_paths_eq_nonexistent_home) - -## test_self_platforms() [](#method-i-test_self_platforms) - -## test_self_post_build() [](#method-i-test_self_post_build) - -## test_self_post_install() [](#method-i-test_self_post_install) - -## test_self_post_reset() [](#method-i-test_self_post_reset) - -## test_self_post_uninstall() [](#method-i-test_self_post_uninstall) - -## test_self_pre_install() [](#method-i-test_self_pre_install) - -## test_self_pre_reset() [](#method-i-test_self_pre_reset) - -## test_self_pre_uninstall() [](#method-i-test_self_pre_uninstall) - -## test_self_prefix() [](#method-i-test_self_prefix) - -## test_self_prefix_libdir() [](#method-i-test_self_prefix_libdir) - -## test_self_prefix_sitelibdir() [](#method-i-test_self_prefix_sitelibdir) - -## test_self_read_binary() [](#method-i-test_self_read_binary) - -## test_self_refresh() [](#method-i-test_self_refresh) - -## test_self_refresh_keeps_loaded_specs_activated() [](#method-i-test_self_refresh_keeps_loaded_specs_activated) - -## test_self_ruby_api_version() [](#method-i-test_self_ruby_api_version) - -## test_self_ruby_escaping_spaces_in_path() [](#method-i-test_self_ruby_escaping_spaces_in_path) - -## test_self_ruby_path_without_spaces() [](#method-i-test_self_ruby_path_without_spaces) - -## test_self_ruby_version_with_git_master() [](#method-i-test_self_ruby_version_with_git_master) - -## test_self_ruby_version_with_git_prerelease() [](#method-i-test_self_ruby_version_with_git_prerelease) - -## test_self_ruby_version_with_non_mri_implementations() [](#method-i-test_self_ruby_version_with_non_mri_implementations) - -## test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility() [](#method-i-test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility) - -## test_self_ruby_version_with_svn_prerelease() [](#method-i-test_self_ruby_version_with_svn_prerelease) - -## test_self_ruby_version_with_svn_trunk() [](#method-i-test_self_ruby_version_with_svn_trunk) - -## test_self_rubygems_version() [](#method-i-test_self_rubygems_version) - -## test_self_sources() [](#method-i-test_self_sources) - -## test_self_try_activate_missing_dep() [](#method-i-test_self_try_activate_missing_dep) - -## test_self_try_activate_missing_extensions() [](#method-i-test_self_try_activate_missing_extensions) - -## test_self_try_activate_missing_prerelease() [](#method-i-test_self_try_activate_missing_prerelease) - -## test_self_use_paths() [](#method-i-test_self_use_paths) - -## test_self_use_paths_with_nils() [](#method-i-test_self_use_paths_with_nils) - -## test_self_user_dir() [](#method-i-test_self_user_dir) - -## test_self_user_home() [](#method-i-test_self_user_home) - -## test_self_vendor_dir() [](#method-i-test_self_vendor_dir) - -## test_self_vendor_dir_ENV_GEM_VENDOR() [](#method-i-test_self_vendor_dir_ENV_GEM_VENDOR) - -## test_self_vendor_dir_missing() [](#method-i-test_self_vendor_dir_missing) - -## test_setting_paths_does_not_mutate_parameter_object() [](#method-i-test_setting_paths_does_not_mutate_parameter_object) - -## test_setting_paths_does_not_warn_about_unknown_keys() [](#method-i-test_setting_paths_does_not_warn_about_unknown_keys) - -## test_spec_order_is_consistent() [](#method-i-test_spec_order_is_consistent) - -## test_state_home_default() [](#method-i-test_state_home_default) - -## test_state_home_from_env() [](#method-i-test_state_home_from_env) - -## test_try_activate_returns_true_for_activated_specs() [](#method-i-test_try_activate_returns_true_for_activated_specs) - diff --git a/example/ruby/TestGemAvailableSet.md b/example/ruby/TestGemAvailableSet.md deleted file mode 100644 index 4e3a048..0000000 --- a/example/ruby/TestGemAvailableSet.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestGemAvailableSet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_and_empty() [](#method-i-test_add_and_empty) - -## test_best() [](#method-i-test_best) - -## test_find_all() [](#method-i-test_find_all) - -## test_match_platform() [](#method-i-test_match_platform) - -## test_remove_installed_bang() [](#method-i-test_remove_installed_bang) - -## test_sorted_normal_versions() [](#method-i-test_sorted_normal_versions) - -## test_sorted_respect_pre() [](#method-i-test_sorted_respect_pre) - diff --git a/example/ruby/TestGemBundledCA.md b/example/ruby/TestGemBundledCA.md deleted file mode 100644 index 856efdf..0000000 --- a/example/ruby/TestGemBundledCA.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TestGemBundledCA -**Inherits:** Gem::TestCase - - -# Testing Bundled CA - -The tested hosts are explained in detail here: -https://github.com/rubygems/rubygems/commit/5e16a5428f973667cabfa07e94ff939e7a -83ebd9 - - - -#Instance Methods -## assert_https(host) [](#method-i-assert_https) - -## bundled_certificate_store() [](#method-i-bundled_certificate_store) - -## test_accessing_new_index() [](#method-i-test_accessing_new_index) - -## test_accessing_rubygems() [](#method-i-test_accessing_rubygems) - -## test_accessing_staging() [](#method-i-test_accessing_staging) - -## test_accessing_www_rubygems() [](#method-i-test_accessing_www_rubygems) - diff --git a/example/ruby/TestGemBundlerVersionFinder.md b/example/ruby/TestGemBundlerVersionFinder.md deleted file mode 100644 index 6b4769a..0000000 --- a/example/ruby/TestGemBundlerVersionFinder.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestGemBundlerVersionFinder -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## bvf() [](#method-i-bvf) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_bundler_version() [](#method-i-test_bundler_version) - -## test_bundler_version_defaults_to_nil() [](#method-i-test_bundler_version_defaults_to_nil) - -## test_bundler_version_with_bundle_update_bundler() [](#method-i-test_bundler_version_with_bundle_update_bundler) - -## test_bundler_version_with_env_var() [](#method-i-test_bundler_version_with_env_var) - -## test_bundler_version_with_lockfile() [](#method-i-test_bundler_version_with_lockfile) - -## test_deleted_directory() [](#method-i-test_deleted_directory) - -## test_prioritize() [](#method-i-test_prioritize) - -## util_prioritize_specs(specs) [](#method-i-util_prioritize_specs) - diff --git a/example/ruby/TestGemCommand.md b/example/ruby/TestGemCommand.md deleted file mode 100644 index 81d2ddb..0000000 --- a/example/ruby/TestGemCommand.md +++ /dev/null @@ -1,57 +0,0 @@ -# Class: TestGemCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_add_option() [](#method-i-test_add_option) - -## test_add_option_with_empty() [](#method-i-test_add_option_with_empty) - -## test_basic_accessors() [](#method-i-test_basic_accessors) - -## test_common_option_in_class() [](#method-i-test_common_option_in_class) - -## test_defaults() [](#method-i-test_defaults) - -## test_deprecate_option() [](#method-i-test_deprecate_option) - -## test_deprecate_option_extra_message() [](#method-i-test_deprecate_option_extra_message) - -## test_deprecate_option_extra_message_and_no_version() [](#method-i-test_deprecate_option_extra_message_and_no_version) - -## test_deprecate_option_no_version() [](#method-i-test_deprecate_option_no_version) - -## test_invoke() [](#method-i-test_invoke) - -## test_invoke_with_bad_options() [](#method-i-test_invoke_with_bad_options) - -## test_invoke_with_build_args() [](#method-i-test_invoke_with_build_args) - -## test_invoke_with_common_options() [](#method-i-test_invoke_with_common_options) - -## test_invoke_with_help() [](#method-i-test_invoke_with_help) -Returning false from the command handler invokes the usage output. - -## test_invoke_with_options() [](#method-i-test_invoke_with_options) - -## test_option_recognition() [](#method-i-test_option_recognition) - -## test_self_add_specific_extra_args() [](#method-i-test_self_add_specific_extra_args) - -## test_self_add_specific_extra_args_unknown() [](#method-i-test_self_add_specific_extra_args_unknown) - -## test_self_extra_args() [](#method-i-test_self_extra_args) - -## test_show_lookup_failure_suggestions_local() [](#method-i-test_show_lookup_failure_suggestions_local) - -## test_show_lookup_failure_suggestions_none() [](#method-i-test_show_lookup_failure_suggestions_none) - -## test_show_lookup_failure_suggestions_remote() [](#method-i-test_show_lookup_failure_suggestions_remote) - diff --git a/example/ruby/TestGemCommandManager.md b/example/ruby/TestGemCommandManager.md deleted file mode 100644 index b0393d4..0000000 --- a/example/ruby/TestGemCommandManager.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: TestGemCommandManager -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_deprecated_command() [](#method-i-test_deprecated_command) - -## test_deprecated_command_with_version() [](#method-i-test_deprecated_command_with_version) - -## test_find_alias_command() [](#method-i-test_find_alias_command) - -## test_find_command() [](#method-i-test_find_command) - -## test_find_command_ambiguous() [](#method-i-test_find_command_ambiguous) - -## test_find_command_ambiguous_exact() [](#method-i-test_find_command_ambiguous_exact) - -## test_find_command_unknown() [](#method-i-test_find_command_unknown) - -## test_find_command_unknown_suggestions() [](#method-i-test_find_command_unknown_suggestions) - -## test_find_login_alias_command() [](#method-i-test_find_login_alias_command) - -## test_find_logout_alias_comamnd() [](#method-i-test_find_logout_alias_comamnd) - -## test_process_args_bad_arg() [](#method-i-test_process_args_bad_arg) - -## test_process_args_build() [](#method-i-test_process_args_build) -HACK: move to build command test - -## test_process_args_check() [](#method-i-test_process_args_check) -HACK: move to check command test - -## test_process_args_install() [](#method-i-test_process_args_install) -HACK: move to install command test - -## test_process_args_query() [](#method-i-test_process_args_query) -HACK: move to query command test - -## test_process_args_uninstall() [](#method-i-test_process_args_uninstall) -HACK: move to uninstall command test - -## test_process_args_update() [](#method-i-test_process_args_update) -HACK: move to update command test - -## test_process_args_with_c_flag() [](#method-i-test_process_args_with_c_flag) - -## test_process_args_with_c_flag_path_not_found() [](#method-i-test_process_args_with_c_flag_path_not_found) - -## test_process_args_with_c_flag_without_path() [](#method-i-test_process_args_with_c_flag_without_path) - -## test_run_crash_command() [](#method-i-test_run_crash_command) - -## test_run_interrupt() [](#method-i-test_run_interrupt) - diff --git a/example/ruby/TestGemCommandsBuildCommand.md b/example/ruby/TestGemCommandsBuildCommand.md deleted file mode 100644 index e419063..0000000 --- a/example/ruby/TestGemCommandsBuildCommand.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: TestGemCommandsBuildCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_build_auto_resign_cert() [](#method-i-test_build_auto_resign_cert) - -## test_build_is_reproducible() [](#method-i-test_build_is_reproducible) - -## test_build_signed_gem() [](#method-i-test_build_signed_gem) - -## test_build_signed_gem_with_cert_expiration_length_days() [](#method-i-test_build_signed_gem_with_cert_expiration_length_days) - -## test_can_find_gemspecs_without_dot_gemspec() [](#method-i-test_can_find_gemspecs_without_dot_gemspec) - -## test_execute() [](#method-i-test_execute) - -## test_execute_bad_name() [](#method-i-test_execute_bad_name) - -## test_execute_bad_spec() [](#method-i-test_execute_bad_spec) - -## test_execute_force() [](#method-i-test_execute_force) - -## test_execute_missing_file() [](#method-i-test_execute_missing_file) - -## test_execute_multiple_gemspec_without_gem_name() [](#method-i-test_execute_multiple_gemspec_without_gem_name) - -## test_execute_outside_dir() [](#method-i-test_execute_outside_dir) - -## test_execute_outside_dir_no_gemspec_present() [](#method-i-test_execute_outside_dir_no_gemspec_present) - -## test_execute_outside_dir_with_external_gemspec() [](#method-i-test_execute_outside_dir_with_external_gemspec) - -## test_execute_outside_dir_with_external_relative_gemspec() [](#method-i-test_execute_outside_dir_with_external_relative_gemspec) - -## test_execute_outside_dir_with_glob_argument() [](#method-i-test_execute_outside_dir_with_glob_argument) - -## test_execute_outside_dir_without_gem_name() [](#method-i-test_execute_outside_dir_without_gem_name) - -## test_execute_platform() [](#method-i-test_execute_platform) - -## test_execute_rubyforge_project_warning() [](#method-i-test_execute_rubyforge_project_warning) - -## test_execute_strict_with_warnings() [](#method-i-test_execute_strict_with_warnings) - -## test_execute_strict_without_warnings() [](#method-i-test_execute_strict_without_warnings) - -## test_execute_without_gem_name() [](#method-i-test_execute_without_gem_name) - -## test_handle_deprecated_options() [](#method-i-test_handle_deprecated_options) - -## test_handle_options() [](#method-i-test_handle_options) - -## test_handle_options_defaults() [](#method-i-test_handle_options_defaults) - -## test_options_filename() [](#method-i-test_options_filename) - -## util_test_build_gem(gem, suffix:nil) [](#method-i-util_test_build_gem) - diff --git a/example/ruby/TestGemCommandsCertCommand.md b/example/ruby/TestGemCommandsCertCommand.md deleted file mode 100644 index 8129491..0000000 --- a/example/ruby/TestGemCommandsCertCommand.md +++ /dev/null @@ -1,82 +0,0 @@ -# Class: TestGemCommandsCertCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_certificates_matching() [](#method-i-test_certificates_matching) - -## test_certificates_matching_filter() [](#method-i-test_certificates_matching_filter) - -## test_execute_add() [](#method-i-test_execute_add) - -## test_execute_add_twice() [](#method-i-test_execute_add_twice) - -## test_execute_build() [](#method-i-test_execute_build) - -## test_execute_build_bad_email_address() [](#method-i-test_execute_build_bad_email_address) - -## test_execute_build_bad_passphrase_confirmation() [](#method-i-test_execute_build_bad_passphrase_confirmation) - -## test_execute_build_ec_key() [](#method-i-test_execute_build_ec_key) - -## test_execute_build_encrypted_key() [](#method-i-test_execute_build_encrypted_key) - -## test_execute_build_expiration_days() [](#method-i-test_execute_build_expiration_days) - -## test_execute_build_key() [](#method-i-test_execute_build_key) - -## test_execute_build_key_algorithm_ec_key() [](#method-i-test_execute_build_key_algorithm_ec_key) - -## test_execute_certificate() [](#method-i-test_execute_certificate) - -## test_execute_encrypted_private_key() [](#method-i-test_execute_encrypted_private_key) - -## test_execute_list() [](#method-i-test_execute_list) - -## test_execute_list_filter() [](#method-i-test_execute_list_filter) - -## test_execute_private_key() [](#method-i-test_execute_private_key) - -## test_execute_re_sign() [](#method-i-test_execute_re_sign) - -## test_execute_re_sign_with_cert_expiration_length_days() [](#method-i-test_execute_re_sign_with_cert_expiration_length_days) - -## test_execute_remove() [](#method-i-test_execute_remove) - -## test_execute_remove_multiple() [](#method-i-test_execute_remove_multiple) - -## test_execute_remove_twice() [](#method-i-test_execute_remove_twice) - -## test_execute_sign() [](#method-i-test_execute_sign) - -## test_execute_sign_default() [](#method-i-test_execute_sign_default) - -## test_execute_sign_default_encrypted_key() [](#method-i-test_execute_sign_default_encrypted_key) - -## test_execute_sign_encrypted_key() [](#method-i-test_execute_sign_encrypted_key) - -## test_execute_sign_no_cert() [](#method-i-test_execute_sign_no_cert) - -## test_execute_sign_no_key() [](#method-i-test_execute_sign_no_key) - -## test_handle_options() [](#method-i-test_handle_options) - -## test_handle_options_add_bad() [](#method-i-test_handle_options_add_bad) - -## test_handle_options_certificate() [](#method-i-test_handle_options_certificate) - -## test_handle_options_key_bad() [](#method-i-test_handle_options_key_bad) - -## test_handle_options_sign() [](#method-i-test_handle_options_sign) - -## test_handle_options_sign_encrypted_key() [](#method-i-test_handle_options_sign_encrypted_key) - -## test_handle_options_sign_nonexistent() [](#method-i-test_handle_options_sign_nonexistent) - diff --git a/example/ruby/TestGemCommandsCheckCommand.md b/example/ruby/TestGemCommandsCheckCommand.md deleted file mode 100644 index c73f9d7..0000000 --- a/example/ruby/TestGemCommandsCheckCommand.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGemCommandsCheckCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## gem(name) [](#method-i-gem) - -## setup() [](#method-i-setup) - -## test_doctor() [](#method-i-test_doctor) - -## test_handle_options() [](#method-i-test_handle_options) - -## test_handle_options_defaults() [](#method-i-test_handle_options_defaults) - -## test_initialize() [](#method-i-test_initialize) - diff --git a/example/ruby/TestGemCommandsCleanupCommand.md b/example/ruby/TestGemCommandsCleanupCommand.md deleted file mode 100644 index 6a01458..0000000 --- a/example/ruby/TestGemCommandsCleanupCommand.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: TestGemCommandsCleanupCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_all() [](#method-i-test_execute_all) - -## test_execute_all_dependencies() [](#method-i-test_execute_all_dependencies) - -## test_execute_all_user() [](#method-i-test_execute_all_user) - -## test_execute_all_user_no_sudo() [](#method-i-test_execute_all_user_no_sudo) - -## test_execute_dev_dependencies() [](#method-i-test_execute_dev_dependencies) - -## test_execute_dry_run() [](#method-i-test_execute_dry_run) - -## test_execute_ignore_default_gem_verbose() [](#method-i-test_execute_ignore_default_gem_verbose) - -## test_execute_keeps_older_versions_with_deps() [](#method-i-test_execute_keeps_older_versions_with_deps) - -## test_execute_remove_gem_home_only() [](#method-i-test_execute_remove_gem_home_only) - -## test_execute_user_install() [](#method-i-test_execute_user_install) - -## test_execute_without_dev_dependencies() [](#method-i-test_execute_without_dev_dependencies) - -## test_handle_options_check_development() [](#method-i-test_handle_options_check_development) - -## test_handle_options_d() [](#method-i-test_handle_options_d) - -## test_handle_options_deprecated_dry_run() [](#method-i-test_handle_options_deprecated_dry_run) - -## test_handle_options_dry_run() [](#method-i-test_handle_options_dry_run) - -## test_handle_options_n() [](#method-i-test_handle_options_n) - diff --git a/example/ruby/TestGemCommandsContentsCommand.md b/example/ruby/TestGemCommandsContentsCommand.md deleted file mode 100644 index edadcc2..0000000 --- a/example/ruby/TestGemCommandsContentsCommand.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: TestGemCommandsContentsCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## gem(name, version2) [](#method-i-gem) - -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_all() [](#method-i-test_execute_all) - -## test_execute_bad_gem() [](#method-i-test_execute_bad_gem) - -## test_execute_default_gem() [](#method-i-test_execute_default_gem) - -## test_execute_exact_match() [](#method-i-test_execute_exact_match) - -## test_execute_lib_only() [](#method-i-test_execute_lib_only) - -## test_execute_missing_multiple() [](#method-i-test_execute_missing_multiple) - -## test_execute_missing_single() [](#method-i-test_execute_missing_single) - -## test_execute_missing_version() [](#method-i-test_execute_missing_version) - -## test_execute_multiple() [](#method-i-test_execute_multiple) - -## test_execute_no_prefix() [](#method-i-test_execute_no_prefix) - -## test_execute_show_install_dir() [](#method-i-test_execute_show_install_dir) - -## test_execute_show_install_dir_latest_version() [](#method-i-test_execute_show_install_dir_latest_version) - -## test_execute_show_install_dir_version() [](#method-i-test_execute_show_install_dir_version) - -## test_handle_options() [](#method-i-test_handle_options) - diff --git a/example/ruby/TestGemCommandsDependencyCommand.md b/example/ruby/TestGemCommandsDependencyCommand.md deleted file mode 100644 index 7a7537b..0000000 --- a/example/ruby/TestGemCommandsDependencyCommand.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestGemCommandsDependencyCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_no_args() [](#method-i-test_execute_no_args) - -## test_execute_no_match() [](#method-i-test_execute_no_match) - -## test_execute_pipe_format() [](#method-i-test_execute_pipe_format) - -## test_execute_prerelease() [](#method-i-test_execute_prerelease) - -## test_execute_regexp() [](#method-i-test_execute_regexp) - -## test_execute_remote() [](#method-i-test_execute_remote) - -## test_execute_remote_version() [](#method-i-test_execute_remote_version) - -## test_execute_reverse() [](#method-i-test_execute_reverse) - -## test_execute_reverse_remote() [](#method-i-test_execute_reverse_remote) - diff --git a/example/ruby/TestGemCommandsEnvironmentCommand.md b/example/ruby/TestGemCommandsEnvironmentCommand.md deleted file mode 100644 index 8d8aba3..0000000 --- a/example/ruby/TestGemCommandsEnvironmentCommand.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestGemCommandsEnvironmentCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_gemdir() [](#method-i-test_execute_gemdir) - -## test_execute_gempath() [](#method-i-test_execute_gempath) - -## test_execute_gempath_multiple() [](#method-i-test_execute_gempath_multiple) - -## test_execute_platform() [](#method-i-test_execute_platform) - -## test_execute_remotesources() [](#method-i-test_execute_remotesources) - -## test_execute_unknown() [](#method-i-test_execute_unknown) - -## test_execute_user_gemdir() [](#method-i-test_execute_user_gemdir) - -## test_execute_user_gemhome() [](#method-i-test_execute_user_gemhome) - -## test_execute_version() [](#method-i-test_execute_version) - diff --git a/example/ruby/TestGemCommandsExecCommand.md b/example/ruby/TestGemCommandsExecCommand.md deleted file mode 100644 index 6f9a856..0000000 --- a/example/ruby/TestGemCommandsExecCommand.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: TestGemCommandsExecCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## invoke(*args) [](#method-i-invoke) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_conservative() [](#method-i-test_conservative) - -## test_conservative_missing_gem() [](#method-i-test_conservative_missing_gem) - -## test_error_with_no_arguments() [](#method-i-test_error_with_no_arguments) - -## test_error_with_no_executable() [](#method-i-test_error_with_no_executable) - -## test_full_option_parsing() [](#method-i-test_full_option_parsing) - -## test_gem_dependency_contains_executable() [](#method-i-test_gem_dependency_contains_executable) - -## test_gem_dependency_contains_other_executable() [](#method-i-test_gem_dependency_contains_other_executable) - -## test_gem_exec_gem_uninstall() [](#method-i-test_gem_exec_gem_uninstall) - -## test_gem_with_executable() [](#method-i-test_gem_with_executable) - -## test_gem_with_executable_error() [](#method-i-test_gem_with_executable_error) - -## test_gem_with_multiple_executables_no_match() [](#method-i-test_gem_with_multiple_executables_no_match) - -## test_gem_with_multiple_executables_one_match() [](#method-i-test_gem_with_multiple_executables_one_match) - -## test_gem_with_other_executable_name() [](#method-i-test_gem_with_other_executable_name) - -## test_gem_with_platform_and_platform_dependencies() [](#method-i-test_gem_with_platform_and_platform_dependencies) - -## test_gem_with_platform_dependencies() [](#method-i-test_gem_with_platform_dependencies) - -## test_gem_with_platforms() [](#method-i-test_gem_with_platforms) - -## test_gem_without_executable() [](#method-i-test_gem_without_executable) - -## test_missing_gem() [](#method-i-test_missing_gem) - -## test_newer_prerelease_available() [](#method-i-test_newer_prerelease_available) - -## test_only_prerelease_available() [](#method-i-test_only_prerelease_available) - -## test_other_gem_contains_executable() [](#method-i-test_other_gem_contains_executable) - -## test_pre_argument() [](#method-i-test_pre_argument) - -## test_pre_version_option() [](#method-i-test_pre_version_option) - -## test_single_arg_parsing() [](#method-i-test_single_arg_parsing) - -## test_single_arg_parsing_with_version() [](#method-i-test_single_arg_parsing_with_version) - -## test_uses_newest_version() [](#method-i-test_uses_newest_version) - -## test_uses_newest_version_of_dependency() [](#method-i-test_uses_newest_version_of_dependency) - -## test_version_mismatch() [](#method-i-test_version_mismatch) - diff --git a/example/ruby/TestGemCommandsFetchCommand.md b/example/ruby/TestGemCommandsFetchCommand.md deleted file mode 100644 index 6d33b86..0000000 --- a/example/ruby/TestGemCommandsFetchCommand.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestGemCommandsFetchCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_latest() [](#method-i-test_execute_latest) - -## test_execute_nonexistent_hint_disabled() [](#method-i-test_execute_nonexistent_hint_disabled) - -## test_execute_platform() [](#method-i-test_execute_platform) - -## test_execute_prerelease() [](#method-i-test_execute_prerelease) - -## test_execute_specific_prerelease() [](#method-i-test_execute_specific_prerelease) - -## test_execute_two_version() [](#method-i-test_execute_two_version) - -## test_execute_two_version_specified_by_colon() [](#method-i-test_execute_two_version_specified_by_colon) - -## test_execute_version() [](#method-i-test_execute_version) - -## test_execute_version_nonexistent() [](#method-i-test_execute_version_nonexistent) - -## test_execute_version_specified_by_colon() [](#method-i-test_execute_version_specified_by_colon) - diff --git a/example/ruby/TestGemCommandsHelpCommand.md b/example/ruby/TestGemCommandsHelpCommand.md deleted file mode 100644 index 8c1f956..0000000 --- a/example/ruby/TestGemCommandsHelpCommand.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestGemCommandsHelpCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_gem_help_bad() [](#method-i-test_gem_help_bad) - -## test_gem_help_build() [](#method-i-test_gem_help_build) - -## test_gem_help_commands() [](#method-i-test_gem_help_commands) - -## test_gem_help_commands_omits_deprecated_commands() [](#method-i-test_gem_help_commands_omits_deprecated_commands) - -## test_gem_help_gem_dependencies() [](#method-i-test_gem_help_gem_dependencies) - -## test_gem_help_platforms() [](#method-i-test_gem_help_platforms) - -## test_gem_no_args_shows_help() [](#method-i-test_gem_no_args_shows_help) - -## util_gem(*args) [](#method-i-util_gem) - -**@yield** [@ui.output, @ui.error] - diff --git a/example/ruby/TestGemCommandsInfoCommand.md b/example/ruby/TestGemCommandsInfoCommand.md deleted file mode 100644 index 4a0c7e0..0000000 --- a/example/ruby/TestGemCommandsInfoCommand.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGemCommandsInfoCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## gem(name, version"1.0") [](#method-i-gem) - -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_with_default_gem() [](#method-i-test_execute_with_default_gem) - -## test_execute_with_default_gem_and_regular_gem() [](#method-i-test_execute_with_default_gem_and_regular_gem) - -## test_execute_with_version_flag() [](#method-i-test_execute_with_version_flag) - diff --git a/example/ruby/TestGemCommandsInstallCommand.md b/example/ruby/TestGemCommandsInstallCommand.md deleted file mode 100644 index 18bdf52..0000000 --- a/example/ruby/TestGemCommandsInstallCommand.md +++ /dev/null @@ -1,140 +0,0 @@ -# Class: TestGemCommandsInstallCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_execute_bad_source() [](#method-i-test_execute_bad_source) - -## test_execute_conservative() [](#method-i-test_execute_conservative) - -## test_execute_dependency_nonexistent() [](#method-i-test_execute_dependency_nonexistent) - -## test_execute_exclude_prerelease() [](#method-i-test_execute_exclude_prerelease) - -## test_execute_explicit_version_includes_prerelease() [](#method-i-test_execute_explicit_version_includes_prerelease) - -## test_execute_http_proxy() [](#method-i-test_execute_http_proxy) - -## test_execute_installs_deps_a_gemdeps() [](#method-i-test_execute_installs_deps_a_gemdeps) - -## test_execute_installs_deps_a_gemdeps_into_a_path() [](#method-i-test_execute_installs_deps_a_gemdeps_into_a_path) - -## test_execute_installs_from_a_gemdeps() [](#method-i-test_execute_installs_from_a_gemdeps) - -## test_execute_installs_from_a_gemdeps_with_conservative() [](#method-i-test_execute_installs_from_a_gemdeps_with_conservative) - -## test_execute_local() [](#method-i-test_execute_local) - -## test_execute_local_dependency_nonexistent() [](#method-i-test_execute_local_dependency_nonexistent) - -## test_execute_local_dependency_nonexistent_ignore_dependencies() [](#method-i-test_execute_local_dependency_nonexistent_ignore_dependencies) - -## test_execute_local_missing() [](#method-i-test_execute_local_missing) - -## test_execute_local_missing_ignore_dependencies() [](#method-i-test_execute_local_missing_ignore_dependencies) - -## test_execute_local_transitive_prerelease() [](#method-i-test_execute_local_transitive_prerelease) - -## test_execute_no_gem() [](#method-i-test_execute_no_gem) - -## test_execute_no_user_install() [](#method-i-test_execute_no_user_install) - -## test_execute_nonexistent() [](#method-i-test_execute_nonexistent) - -## test_execute_nonexistent_force() [](#method-i-test_execute_nonexistent_force) - -## test_execute_nonexistent_hint_disabled() [](#method-i-test_execute_nonexistent_hint_disabled) - -## test_execute_nonexistent_with_dashes() [](#method-i-test_execute_nonexistent_with_dashes) - -## test_execute_nonexistent_with_hint() [](#method-i-test_execute_nonexistent_with_hint) - -## test_execute_prerelease_skipped_when_no_flag_set() [](#method-i-test_execute_prerelease_skipped_when_no_flag_set) - -## test_execute_prerelease_skipped_when_non_pre_available() [](#method-i-test_execute_prerelease_skipped_when_non_pre_available) - -## test_execute_prerelease_wins_over_previous_ver() [](#method-i-test_execute_prerelease_wins_over_previous_ver) - -## test_execute_rdoc() [](#method-i-test_execute_rdoc) - -## test_execute_rdoc_with_path() [](#method-i-test_execute_rdoc_with_path) - -## test_execute_remote() [](#method-i-test_execute_remote) - -## test_execute_remote_ignores_files() [](#method-i-test_execute_remote_ignores_files) - -## test_execute_remote_truncates_existing_gemspecs() [](#method-i-test_execute_remote_truncates_existing_gemspecs) - -## test_execute_required_ruby_version() [](#method-i-test_execute_required_ruby_version) - -## test_execute_required_ruby_version_specific_not_met() [](#method-i-test_execute_required_ruby_version_specific_not_met) - -## test_execute_required_ruby_version_specific_prerelease_met() [](#method-i-test_execute_required_ruby_version_specific_prerelease_met) - -## test_execute_required_ruby_version_specific_prerelease_not_met() [](#method-i-test_execute_required_ruby_version_specific_prerelease_not_met) - -## test_execute_required_ruby_version_upper_bound() [](#method-i-test_execute_required_ruby_version_upper_bound) - -## test_execute_required_rubygems_version_wrong() [](#method-i-test_execute_required_rubygems_version_wrong) - -## test_execute_saves_build_args() [](#method-i-test_execute_saves_build_args) - -## test_execute_two() [](#method-i-test_execute_two) - -## test_execute_two_version() [](#method-i-test_execute_two_version) - -## test_execute_two_version_specified_by_colon() [](#method-i-test_execute_two_version_specified_by_colon) - -## test_execute_uses_deps_a_gemdeps() [](#method-i-test_execute_uses_deps_a_gemdeps) - -## test_execute_uses_deps_a_gemdeps_with_a_path() [](#method-i-test_execute_uses_deps_a_gemdeps_with_a_path) - -## test_execute_uses_from_a_gemdeps() [](#method-i-test_execute_uses_from_a_gemdeps) - -## test_execute_uses_from_a_gemdeps_with_no_lock() [](#method-i-test_execute_uses_from_a_gemdeps_with_no_lock) - -## test_execute_with_gemdeps_path_ignores_system() [](#method-i-test_execute_with_gemdeps_path_ignores_system) - -## test_execute_with_invalid_gem_file() [](#method-i-test_execute_with_invalid_gem_file) - -## test_execute_with_version_specified_by_colon() [](#method-i-test_execute_with_version_specified_by_colon) - -## test_explain_platform_local() [](#method-i-test_explain_platform_local) - -## test_explain_platform_local_ignore_dependencies() [](#method-i-test_explain_platform_local_ignore_dependencies) - -## test_explain_platform_ruby() [](#method-i-test_explain_platform_ruby) - -## test_explain_platform_ruby_ignore_dependencies() [](#method-i-test_explain_platform_ruby_ignore_dependencies) - -## test_handle_options_file() [](#method-i-test_handle_options_file) - -## test_handle_options_suggest() [](#method-i-test_handle_options_suggest) - -## test_handle_options_without() [](#method-i-test_handle_options_without) - -## test_install_gem_ignore_dependencies_both() [](#method-i-test_install_gem_ignore_dependencies_both) - -## test_install_gem_ignore_dependencies_remote() [](#method-i-test_install_gem_ignore_dependencies_remote) - -## test_install_gem_ignore_dependencies_remote_platform_local() [](#method-i-test_install_gem_ignore_dependencies_remote_platform_local) - -## test_install_gem_ignore_dependencies_specific_file() [](#method-i-test_install_gem_ignore_dependencies_specific_file) - -## test_parses_requirement_from_gemname() [](#method-i-test_parses_requirement_from_gemname) - -## test_redact_credentials_from_uri_on_warning() [](#method-i-test_redact_credentials_from_uri_on_warning) - -## test_show_errors_on_failure() [](#method-i-test_show_errors_on_failure) - -## test_show_source_problems_even_on_success() [](#method-i-test_show_source_problems_even_on_success) - -## test_suggest_update_if_enabled() [](#method-i-test_suggest_update_if_enabled) - diff --git a/example/ruby/TestGemCommandsListCommand.md b/example/ruby/TestGemCommandsListCommand.md deleted file mode 100644 index 4d520c2..0000000 --- a/example/ruby/TestGemCommandsListCommand.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemCommandsListCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute_installed() [](#method-i-test_execute_installed) - -## test_execute_normal_gem_shadowing_default_gem() [](#method-i-test_execute_normal_gem_shadowing_default_gem) - diff --git a/example/ruby/TestGemCommandsLockCommand.md b/example/ruby/TestGemCommandsLockCommand.md deleted file mode 100644 index f1c5c65..0000000 --- a/example/ruby/TestGemCommandsLockCommand.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemCommandsLockCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_missing_dependency() [](#method-i-test_execute_missing_dependency) - -## test_execute_strict() [](#method-i-test_execute_strict) - diff --git a/example/ruby/TestGemCommandsMirrorCommand.md b/example/ruby/TestGemCommandsMirrorCommand.md deleted file mode 100644 index 0cca3e9..0000000 --- a/example/ruby/TestGemCommandsMirrorCommand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemCommandsMirrorCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - diff --git a/example/ruby/TestGemCommandsOpenCommand.md b/example/ruby/TestGemCommandsOpenCommand.md deleted file mode 100644 index 4702354..0000000 --- a/example/ruby/TestGemCommandsOpenCommand.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGemCommandsOpenCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## gem(name, version"1.0") [](#method-i-gem) - -## setup() [](#method-i-setup) - -## test_default_gem() [](#method-i-test_default_gem) - -## test_execute() [](#method-i-test_execute) - -## test_execute_bad_gem() [](#method-i-test_execute_bad_gem) - -## test_wrong_version() [](#method-i-test_wrong_version) - diff --git a/example/ruby/TestGemCommandsOutdatedCommand.md b/example/ruby/TestGemCommandsOutdatedCommand.md deleted file mode 100644 index cf2bdd5..0000000 --- a/example/ruby/TestGemCommandsOutdatedCommand.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemCommandsOutdatedCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_with_up_to_date_platform_specific_gem() [](#method-i-test_execute_with_up_to_date_platform_specific_gem) - -## test_initialize() [](#method-i-test_initialize) - diff --git a/example/ruby/TestGemCommandsOwnerCommand.md b/example/ruby/TestGemCommandsOwnerCommand.md deleted file mode 100644 index 84a8864..0000000 --- a/example/ruby/TestGemCommandsOwnerCommand.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: TestGemCommandsOwnerCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_add_owner_with_host_option_through_execute() [](#method-i-test_add_owner_with_host_option_through_execute) - -## test_add_owners() [](#method-i-test_add_owners) - -## test_add_owners_denied() [](#method-i-test_add_owners_denied) - -## test_add_owners_key() [](#method-i-test_add_owners_key) - -## test_add_owners_no_api_key_webauthn_enabled_does_not_reuse_otp_codes() [](#method-i-test_add_owners_no_api_key_webauthn_enabled_does_not_reuse_otp_codes) - -## test_add_owners_permanent_redirect() [](#method-i-test_add_owners_permanent_redirect) - -## test_add_owners_unathorized_api_key() [](#method-i-test_add_owners_unathorized_api_key) - -## test_otp_verified_failure() [](#method-i-test_otp_verified_failure) - -## test_otp_verified_success() [](#method-i-test_otp_verified_success) - -## test_remove_owners() [](#method-i-test_remove_owners) - -## test_remove_owners_denied() [](#method-i-test_remove_owners_denied) - -## test_remove_owners_key() [](#method-i-test_remove_owners_key) - -## test_remove_owners_missing() [](#method-i-test_remove_owners_missing) - -## test_remove_owners_permanent_redirect() [](#method-i-test_remove_owners_permanent_redirect) - -## test_remove_owners_unathorized_api_key() [](#method-i-test_remove_owners_unathorized_api_key) - -## test_show_owners() [](#method-i-test_show_owners) - -## test_show_owners_denied() [](#method-i-test_show_owners_denied) - -## test_show_owners_dont_load_objects() [](#method-i-test_show_owners_dont_load_objects) - -## test_show_owners_key() [](#method-i-test_show_owners_key) - -## test_show_owners_permanent_redirect() [](#method-i-test_show_owners_permanent_redirect) - -## test_show_owners_setting_up_host() [](#method-i-test_show_owners_setting_up_host) - -## test_show_owners_setting_up_host_through_env_var() [](#method-i-test_show_owners_setting_up_host_through_env_var) - -## test_with_webauthn_enabled_failure() [](#method-i-test_with_webauthn_enabled_failure) - -## test_with_webauthn_enabled_failure_with_polling() [](#method-i-test_with_webauthn_enabled_failure_with_polling) - -## test_with_webauthn_enabled_success() [](#method-i-test_with_webauthn_enabled_success) - -## test_with_webauthn_enabled_success_with_polling() [](#method-i-test_with_webauthn_enabled_success_with_polling) - diff --git a/example/ruby/TestGemCommandsPristineCommand.md b/example/ruby/TestGemCommandsPristineCommand.md deleted file mode 100644 index fe897ec..0000000 --- a/example/ruby/TestGemCommandsPristineCommand.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: TestGemCommandsPristineCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_all() [](#method-i-test_execute_all) - -## test_execute_bindir() [](#method-i-test_execute_bindir) - -## test_execute_default_gem() [](#method-i-test_execute_default_gem) - -## test_execute_env_shebang() [](#method-i-test_execute_env_shebang) - -## test_execute_extensions_explicit() [](#method-i-test_execute_extensions_explicit) - -## test_execute_extensions_only_missing_extensions() [](#method-i-test_execute_extensions_only_missing_extensions) - -## test_execute_many() [](#method-i-test_execute_many) - -## test_execute_many_multi_repo() [](#method-i-test_execute_many_multi_repo) - -## test_execute_missing_cache_gem() [](#method-i-test_execute_missing_cache_gem) - -## test_execute_missing_cache_gem_when_multi_repo() [](#method-i-test_execute_missing_cache_gem_when_multi_repo) - -## test_execute_multi_platform() [](#method-i-test_execute_multi_platform) - -## test_execute_no_extension() [](#method-i-test_execute_no_extension) - -## test_execute_no_gem() [](#method-i-test_execute_no_gem) - -## test_execute_only_executables() [](#method-i-test_execute_only_executables) - -## test_execute_only_plugins() [](#method-i-test_execute_only_plugins) - -## test_execute_unknown_gem_at_remote_source() [](#method-i-test_execute_unknown_gem_at_remote_source) - -## test_execute_user_install() [](#method-i-test_execute_user_install) - -## test_execute_with_extension_with_build_args() [](#method-i-test_execute_with_extension_with_build_args) - -## test_handle_options() [](#method-i-test_handle_options) - -## test_handle_options_extensions() [](#method-i-test_handle_options_extensions) - -## test_skip() [](#method-i-test_skip) - -## test_skip_many_gems() [](#method-i-test_skip_many_gems) - diff --git a/example/ruby/TestGemCommandsPushCommand.md b/example/ruby/TestGemCommandsPushCommand.md deleted file mode 100644 index 9bd1a7f..0000000 --- a/example/ruby/TestGemCommandsPushCommand.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: TestGemCommandsPushCommand -**Inherits:** Gem::TestCase - - - - -# Class Methods -## sign_in() [](#method-c-sign_in) - -#Instance Methods -## send_battery() [](#method-i-send_battery) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_execute() [](#method-i-test_execute) - -## test_execute_allowed_push_host() [](#method-i-test_execute_allowed_push_host) - -## test_execute_attestation() [](#method-i-test_execute_attestation) - -## test_execute_host() [](#method-i-test_execute_host) - -## test_otp_verified_failure() [](#method-i-test_otp_verified_failure) - -## test_otp_verified_success() [](#method-i-test_otp_verified_success) - -## test_raises_error_with_no_arguments() [](#method-i-test_raises_error_with_no_arguments) - -## test_sending_gem() [](#method-i-test_sending_gem) - -## test_sending_gem_defaulting_to_allowed_push_host() [](#method-i-test_sending_gem_defaulting_to_allowed_push_host) - -## test_sending_gem_denied() [](#method-i-test_sending_gem_denied) - -## test_sending_gem_key() [](#method-i-test_sending_gem_key) - -## test_sending_gem_to_allowed_push_host() [](#method-i-test_sending_gem_to_allowed_push_host) - -## test_sending_gem_to_allowed_push_host_with_basic_credentials() [](#method-i-test_sending_gem_to_allowed_push_host_with_basic_credentials) - -## test_sending_gem_to_disallowed_default_host() [](#method-i-test_sending_gem_to_disallowed_default_host) - -## test_sending_gem_to_disallowed_push_host() [](#method-i-test_sending_gem_to_disallowed_push_host) - -## test_sending_gem_to_host_permanent_redirect() [](#method-i-test_sending_gem_to_host_permanent_redirect) - -## test_sending_gem_to_metadata_host() [](#method-i-test_sending_gem_to_metadata_host) - -## test_sending_gem_unathorized_api_key_with_mfa_enabled() [](#method-i-test_sending_gem_unathorized_api_key_with_mfa_enabled) - -## test_sending_gem_with_env_var_api_key() [](#method-i-test_sending_gem_with_env_var_api_key) - -## test_sending_gem_with_no_local_creds() [](#method-i-test_sending_gem_with_no_local_creds) - -## test_sending_when_default_host_disabled() [](#method-i-test_sending_when_default_host_disabled) - -## test_sending_when_default_host_disabled_with_override() [](#method-i-test_sending_when_default_host_disabled_with_override) - -## test_with_webauthn_enabled_failure() [](#method-i-test_with_webauthn_enabled_failure) - -## test_with_webauthn_enabled_failure_with_polling() [](#method-i-test_with_webauthn_enabled_failure_with_polling) - -## test_with_webauthn_enabled_success() [](#method-i-test_with_webauthn_enabled_success) - -## test_with_webauthn_enabled_success_with_polling() [](#method-i-test_with_webauthn_enabled_success_with_polling) - diff --git a/example/ruby/TestGemCommandsQueryCommandSetup.md b/example/ruby/TestGemCommandsQueryCommandSetup.md deleted file mode 100644 index 40a6f10..0000000 --- a/example/ruby/TestGemCommandsQueryCommandSetup.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestGemCommandsQueryCommandSetup - - - - - -#Instance Methods -## setup() [](#method-i-setup) - diff --git a/example/ruby/TestGemCommandsQueryCommandWithInstalledGems.md b/example/ruby/TestGemCommandsQueryCommandWithInstalledGems.md deleted file mode 100644 index cc4c839..0000000 --- a/example/ruby/TestGemCommandsQueryCommandWithInstalledGems.md +++ /dev/null @@ -1,67 +0,0 @@ -# Class: TestGemCommandsQueryCommandWithInstalledGems -**Inherits:** Gem::TestCase - -**Includes:** TestGemCommandsQueryCommandSetup - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_all() [](#method-i-test_execute_all) - -## test_execute_all_prerelease() [](#method-i-test_execute_all_prerelease) - -## test_execute_details() [](#method-i-test_execute_details) - -## test_execute_details_cleans_text() [](#method-i-test_execute_details_cleans_text) - -## test_execute_details_truncates_summary() [](#method-i-test_execute_details_truncates_summary) - -## test_execute_installed() [](#method-i-test_execute_installed) - -## test_execute_installed_inverse() [](#method-i-test_execute_installed_inverse) - -## test_execute_installed_inverse_not_installed() [](#method-i-test_execute_installed_inverse_not_installed) - -## test_execute_installed_no_name() [](#method-i-test_execute_installed_no_name) - -## test_execute_installed_not_installed() [](#method-i-test_execute_installed_not_installed) - -## test_execute_installed_version() [](#method-i-test_execute_installed_version) - -## test_execute_installed_version_not_installed() [](#method-i-test_execute_installed_version_not_installed) - -## test_execute_local() [](#method-i-test_execute_local) - -## test_execute_local_notty() [](#method-i-test_execute_local_notty) - -## test_execute_local_quiet() [](#method-i-test_execute_local_quiet) - -## test_execute_multiple_args() [](#method-i-test_execute_multiple_args) -Test for multiple args handling! - -## test_execute_no_prerelease_local() [](#method-i-test_execute_no_prerelease_local) - -## test_execute_no_versions() [](#method-i-test_execute_no_versions) - -## test_execute_notty() [](#method-i-test_execute_notty) - -## test_execute_prerelease() [](#method-i-test_execute_prerelease) - -## test_execute_prerelease_local() [](#method-i-test_execute_prerelease_local) - -## test_execute_remote() [](#method-i-test_execute_remote) - -## test_execute_remote_notty() [](#method-i-test_execute_remote_notty) - -## test_execute_remote_quiet() [](#method-i-test_execute_remote_quiet) - -## test_make_entry() [](#method-i-test_make_entry) - -## test_show_gems() [](#method-i-test_show_gems) - diff --git a/example/ruby/TestGemCommandsQueryCommandWithoutInstalledGems.md b/example/ruby/TestGemCommandsQueryCommandWithoutInstalledGems.md deleted file mode 100644 index a518655..0000000 --- a/example/ruby/TestGemCommandsQueryCommandWithoutInstalledGems.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestGemCommandsQueryCommandWithoutInstalledGems -**Inherits:** Gem::TestCase - -**Includes:** TestGemCommandsQueryCommandSetup - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_depprecated() [](#method-i-test_depprecated) - -## test_execute_default_details() [](#method-i-test_execute_default_details) - -## test_execute_exact_local() [](#method-i-test_execute_exact_local) - -## test_execute_exact_multiple() [](#method-i-test_execute_exact_multiple) - -## test_execute_exact_remote() [](#method-i-test_execute_exact_remote) - -## test_execute_local_details() [](#method-i-test_execute_local_details) - -## test_execute_platform() [](#method-i-test_execute_platform) - -## test_execute_show_default_gems() [](#method-i-test_execute_show_default_gems) - -## test_execute_show_default_gems_with_platform() [](#method-i-test_execute_show_default_gems_with_platform) - diff --git a/example/ruby/TestGemCommandsRebuildCommand.md b/example/ruby/TestGemCommandsRebuildCommand.md deleted file mode 100644 index fb0942f..0000000 --- a/example/ruby/TestGemCommandsRebuildCommand.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemCommandsRebuildCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_build_is_reproducible() [](#method-i-test_build_is_reproducible) - -## util_test_build_gem(gem, args) [](#method-i-util_test_build_gem) - -## util_test_rebuild_gem(gem, args, original_gem_file, gemspec_file, timestamp) [](#method-i-util_test_rebuild_gem) - diff --git a/example/ruby/TestGemCommandsSearchCommand.md b/example/ruby/TestGemCommandsSearchCommand.md deleted file mode 100644 index 4daaa00..0000000 --- a/example/ruby/TestGemCommandsSearchCommand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemCommandsSearchCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_initialize() [](#method-i-test_initialize) - diff --git a/example/ruby/TestGemCommandsServerCommand.md b/example/ruby/TestGemCommandsServerCommand.md deleted file mode 100644 index b5d49a1..0000000 --- a/example/ruby/TestGemCommandsServerCommand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemCommandsServerCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - diff --git a/example/ruby/TestGemCommandsSetupCommand.md b/example/ruby/TestGemCommandsSetupCommand.md deleted file mode 100644 index 56146a4..0000000 --- a/example/ruby/TestGemCommandsSetupCommand.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: TestGemCommandsSetupCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_destdir_flag_does_not_try_to_write_to_the_default_gem_home() [](#method-i-test_destdir_flag_does_not_try_to_write_to_the_default_gem_home) - -## test_destdir_flag_regenerates_binstubs() [](#method-i-test_destdir_flag_regenerates_binstubs) - -## test_env_shebang_flag() [](#method-i-test_env_shebang_flag) - -## test_execute_informs_about_installed_executables() [](#method-i-test_execute_informs_about_installed_executables) - -## test_execute_no_regenerate_binstubs() [](#method-i-test_execute_no_regenerate_binstubs) - -## test_execute_no_regenerate_plugins() [](#method-i-test_execute_no_regenerate_plugins) - -## test_execute_regenerate_binstubs() [](#method-i-test_execute_regenerate_binstubs) - -## test_execute_regenerate_plugins() [](#method-i-test_execute_regenerate_plugins) - -## test_execute_regenerate_plugins_creates_plugins_dir_if_not_there() [](#method-i-test_execute_regenerate_plugins_creates_plugins_dir_if_not_there) - -## test_files_in() [](#method-i-test_files_in) - -## test_install_default_bundler_gem() [](#method-i-test_install_default_bundler_gem) - -## test_install_default_bundler_gem_with_default_gems_not_installed_at_default_dir() [](#method-i-test_install_default_bundler_gem_with_default_gems_not_installed_at_default_dir) - -## test_install_default_bundler_gem_with_destdir_and_prefix_flags() [](#method-i-test_install_default_bundler_gem_with_destdir_and_prefix_flags) - -## test_install_default_bundler_gem_with_destdir_flag() [](#method-i-test_install_default_bundler_gem_with_destdir_flag) - -## test_install_default_bundler_gem_with_force_flag() [](#method-i-test_install_default_bundler_gem_with_force_flag) - -## test_install_lib() [](#method-i-test_install_lib) - -## test_remove_old_lib_files() [](#method-i-test_remove_old_lib_files) - -## test_remove_old_man_files() [](#method-i-test_remove_old_man_files) - -## test_show_release_notes() [](#method-i-test_show_release_notes) - diff --git a/example/ruby/TestGemCommandsSigninCommand.md b/example/ruby/TestGemCommandsSigninCommand.md deleted file mode 100644 index 72d5806..0000000 --- a/example/ruby/TestGemCommandsSigninCommand.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: TestGemCommandsSigninCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_execute_on_gemserver_without_profile_me_endpoint() [](#method-i-test_execute_on_gemserver_without_profile_me_endpoint) - -## test_execute_when_already_signed_in_with_different_host() [](#method-i-test_execute_when_already_signed_in_with_different_host) - -## test_execute_when_already_signed_in_with_same_host() [](#method-i-test_execute_when_already_signed_in_with_same_host) - -## test_execute_when_not_already_signed_in() [](#method-i-test_execute_when_not_already_signed_in) - -## test_execute_when_not_already_signed_in_and_not_preexisting_credentials_folder() [](#method-i-test_execute_when_not_already_signed_in_and_not_preexisting_credentials_folder) - -## test_execute_with_host_permanent_redirect() [](#method-i-test_execute_with_host_permanent_redirect) - -## test_execute_with_host_supplied() [](#method-i-test_execute_with_host_supplied) - -## test_execute_with_key_name_and_custom_scope() [](#method-i-test_execute_with_key_name_and_custom_scope) - -## test_execute_with_key_name_and_exclusive_scope() [](#method-i-test_execute_with_key_name_and_exclusive_scope) - -## test_execute_with_key_name_custom_scope_and_mfa_level_of_gem_signin() [](#method-i-test_execute_with_key_name_custom_scope_and_mfa_level_of_gem_signin) - -## test_execute_with_key_name_custom_scope_and_mfa_level_of_ui_only() [](#method-i-test_execute_with_key_name_custom_scope_and_mfa_level_of_ui_only) - -## test_execute_with_key_name_default_scope() [](#method-i-test_execute_with_key_name_default_scope) - -## test_execute_with_valid_creds_set_for_default_host() [](#method-i-test_execute_with_valid_creds_set_for_default_host) - -## test_execute_with_warnings() [](#method-i-test_execute_with_warnings) - -## util_capture(ui_stubnil, hostnil, api_keynil, fetcherGem::FakeFetcher.new, mfa_level"disabled", warningnil) [](#method-i-util_capture) -Utility method to capture IO/UI within the block passed - diff --git a/example/ruby/TestGemCommandsSignoutCommand.md b/example/ruby/TestGemCommandsSignoutCommand.md deleted file mode 100644 index aec70fa..0000000 --- a/example/ruby/TestGemCommandsSignoutCommand.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: TestGemCommandsSignoutCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute_when_not_signed_in() [](#method-i-test_execute_when_not_signed_in) -i.e. no credential file created - -## test_execute_when_user_is_signed_in() [](#method-i-test_execute_when_user_is_signed_in) - diff --git a/example/ruby/TestGemCommandsSourcesCommand.md b/example/ruby/TestGemCommandsSourcesCommand.md deleted file mode 100644 index 5bccf3a..0000000 --- a/example/ruby/TestGemCommandsSourcesCommand.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: TestGemCommandsSourcesCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_execute() [](#method-i-test_execute) - -## test_execute_add() [](#method-i-test_execute_add) - -## test_execute_add_allow_typo_squatting_source() [](#method-i-test_execute_add_allow_typo_squatting_source) - -## test_execute_add_allow_typo_squatting_source_forced() [](#method-i-test_execute_add_allow_typo_squatting_source_forced) - -## test_execute_add_bad_uri() [](#method-i-test_execute_add_bad_uri) - -## test_execute_add_deny_typo_squatting_source() [](#method-i-test_execute_add_deny_typo_squatting_source) - -## test_execute_add_existent_source_invalid_uri() [](#method-i-test_execute_add_existent_source_invalid_uri) - -## test_execute_add_existent_source_invalid_uri_with_error_by_chance_including_the_uri_password() [](#method-i-test_execute_add_existent_source_invalid_uri_with_error_by_chance_including_the_uri_password) - -## test_execute_add_http_rubygems_org() [](#method-i-test_execute_add_http_rubygems_org) - -## test_execute_add_http_rubygems_org_forced() [](#method-i-test_execute_add_http_rubygems_org_forced) - -## test_execute_add_https_rubygems_org() [](#method-i-test_execute_add_https_rubygems_org) - -## test_execute_add_nonexistent_source() [](#method-i-test_execute_add_nonexistent_source) - -## test_execute_add_redundant_source() [](#method-i-test_execute_add_redundant_source) - -## test_execute_add_redundant_source_trailing_slash() [](#method-i-test_execute_add_redundant_source_trailing_slash) - -## test_execute_clear_all() [](#method-i-test_execute_clear_all) - -## test_execute_list() [](#method-i-test_execute_list) - -## test_execute_remove() [](#method-i-test_execute_remove) - -## test_execute_remove_no_network() [](#method-i-test_execute_remove_no_network) - -## test_execute_update() [](#method-i-test_execute_update) - -## test_initialize_proxy() [](#method-i-test_initialize_proxy) - diff --git a/example/ruby/TestGemCommandsSpecificationCommand.md b/example/ruby/TestGemCommandsSpecificationCommand.md deleted file mode 100644 index b4e7e2a..0000000 --- a/example/ruby/TestGemCommandsSpecificationCommand.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestGemCommandsSpecificationCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_all() [](#method-i-test_execute_all) - -## test_execute_all_conflicts_with_version() [](#method-i-test_execute_all_conflicts_with_version) - -## test_execute_bad_name() [](#method-i-test_execute_bad_name) - -## test_execute_bad_name_with_version() [](#method-i-test_execute_bad_name_with_version) - -## test_execute_exact_match() [](#method-i-test_execute_exact_match) - -## test_execute_field() [](#method-i-test_execute_field) - -## test_execute_file() [](#method-i-test_execute_file) - -## test_execute_marshal() [](#method-i-test_execute_marshal) - -## test_execute_remote() [](#method-i-test_execute_remote) - -## test_execute_remote_with_prerelease() [](#method-i-test_execute_remote_with_prerelease) - -## test_execute_remote_with_version() [](#method-i-test_execute_remote_with_version) - -## test_execute_remote_with_version_and_platform() [](#method-i-test_execute_remote_with_version_and_platform) - -## test_execute_remote_without_prerelease() [](#method-i-test_execute_remote_without_prerelease) - -## test_execute_ruby() [](#method-i-test_execute_ruby) - diff --git a/example/ruby/TestGemCommandsStaleCommand.md b/example/ruby/TestGemCommandsStaleCommand.md deleted file mode 100644 index 8dc1d76..0000000 --- a/example/ruby/TestGemCommandsStaleCommand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemCommandsStaleCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute_sorts() [](#method-i-test_execute_sorts) - diff --git a/example/ruby/TestGemCommandsUninstallCommand.md b/example/ruby/TestGemCommandsUninstallCommand.md deleted file mode 100644 index a36e37a..0000000 --- a/example/ruby/TestGemCommandsUninstallCommand.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: TestGemCommandsUninstallCommand -**Inherits:** Gem::InstallerTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute_all() [](#method-i-test_execute_all) - -## test_execute_all_named() [](#method-i-test_execute_all_named) - -## test_execute_all_named_default_multiple() [](#method-i-test_execute_all_named_default_multiple) - -## test_execute_all_named_default_single() [](#method-i-test_execute_all_named_default_single) - -## test_execute_dependency_order() [](#method-i-test_execute_dependency_order) - -## test_execute_does_not_error_on_shadowed_default_gems() [](#method-i-test_execute_does_not_error_on_shadowed_default_gems) - -## test_execute_does_not_remove_default_gem_executables() [](#method-i-test_execute_does_not_remove_default_gem_executables) - -## test_execute_outside_gem_home() [](#method-i-test_execute_outside_gem_home) - -## test_execute_outside_gem_home_when_install_dir_given() [](#method-i-test_execute_outside_gem_home_when_install_dir_given) - -## test_execute_prerelease() [](#method-i-test_execute_prerelease) - -## test_execute_removes_executable() [](#method-i-test_execute_removes_executable) - -## test_execute_removes_formatted_executable() [](#method-i-test_execute_removes_formatted_executable) - -## test_execute_two_version() [](#method-i-test_execute_two_version) - -## test_execute_with_force_and_without_version_uninstalls_everything() [](#method-i-test_execute_with_force_and_without_version_uninstalls_everything) - -## test_execute_with_force_ignores_dependencies() [](#method-i-test_execute_with_force_ignores_dependencies) - -## test_execute_with_gem_not_installed() [](#method-i-test_execute_with_gem_not_installed) - -## test_execute_with_gem_uninstall_error() [](#method-i-test_execute_with_gem_uninstall_error) - -## test_execute_with_multiple_version_specified_as_colon() [](#method-i-test_execute_with_multiple_version_specified_as_colon) - -## test_execute_with_version_leaves_non_matching_versions() [](#method-i-test_execute_with_version_leaves_non_matching_versions) - -## test_execute_with_version_specified_as_colon() [](#method-i-test_execute_with_version_specified_as_colon) - -## test_handle_options() [](#method-i-test_handle_options) - -## test_handle_options_vendor() [](#method-i-test_handle_options_vendor) - -## test_handle_options_vendor_missing() [](#method-i-test_handle_options_vendor_missing) - -## test_uninstall_selection() [](#method-i-test_uninstall_selection) - -## test_uninstall_selection_multiple_gems() [](#method-i-test_uninstall_selection_multiple_gems) - diff --git a/example/ruby/TestGemCommandsUnpackCommand.md b/example/ruby/TestGemCommandsUnpackCommand.md deleted file mode 100644 index c450236..0000000 --- a/example/ruby/TestGemCommandsUnpackCommand.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestGemCommandsUnpackCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_exact_match() [](#method-i-test_execute_exact_match) - -## test_execute_gem_path() [](#method-i-test_execute_gem_path) - -## test_execute_gem_path_missing() [](#method-i-test_execute_gem_path_missing) - -## test_execute_remote() [](#method-i-test_execute_remote) - -## test_execute_spec() [](#method-i-test_execute_spec) - -## test_execute_spec_target() [](#method-i-test_execute_spec_target) - -## test_execute_sudo() [](#method-i-test_execute_sudo) - -## test_execute_with_target_option() [](#method-i-test_execute_with_target_option) - -## test_find_in_cache() [](#method-i-test_find_in_cache) - -## test_get_path() [](#method-i-test_get_path) - -## test_handle_options_metadata() [](#method-i-test_handle_options_metadata) - diff --git a/example/ruby/TestGemCommandsUpdateCommand.md b/example/ruby/TestGemCommandsUpdateCommand.md deleted file mode 100644 index cd4e5ac..0000000 --- a/example/ruby/TestGemCommandsUpdateCommand.md +++ /dev/null @@ -1,98 +0,0 @@ -# Class: TestGemCommandsUpdateCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_dependencies() [](#method-i-test_execute_dependencies) -before: - a1 -> c1.2 - -after: - a2 -> b2 # new dependency - a2 -> c2 - -## test_execute_multiple() [](#method-i-test_execute_multiple) - -## test_execute_named() [](#method-i-test_execute_named) - -## test_execute_named_not_installed_and_no_update() [](#method-i-test_execute_named_not_installed_and_no_update) - -## test_execute_named_some_up_to_date() [](#method-i-test_execute_named_some_up_to_date) - -## test_execute_named_up_to_date() [](#method-i-test_execute_named_up_to_date) - -## test_execute_named_up_to_date_prerelease() [](#method-i-test_execute_named_up_to_date_prerelease) - -## test_execute_rdoc() [](#method-i-test_execute_rdoc) - -## test_execute_system() [](#method-i-test_execute_system) - -## test_execute_system_at_latest() [](#method-i-test_execute_system_at_latest) - -## test_execute_system_multiple() [](#method-i-test_execute_system_multiple) - -## test_execute_system_silent() [](#method-i-test_execute_system_silent) - -## test_execute_system_silent_passed_to_setuprb() [](#method-i-test_execute_system_silent_passed_to_setuprb) -The other style of `gem update --system` tests don't actually run setup.rb, so -we just check that setup.rb gets the `--silent` flag. - -## test_execute_system_specific() [](#method-i-test_execute_system_specific) - -## test_execute_system_specific_newer_than_or_equal_to_3_2_leaves_plugins_dir_alone() [](#method-i-test_execute_system_specific_newer_than_or_equal_to_3_2_leaves_plugins_dir_alone) - -## test_execute_system_specific_older_than_3_2_removes_plugins_dir() [](#method-i-test_execute_system_specific_older_than_3_2_removes_plugins_dir) - -## test_execute_system_specific_older_than_minimum_supported_rubygems() [](#method-i-test_execute_system_specific_older_than_minimum_supported_rubygems) - -## test_execute_system_specifically_to_latest_version() [](#method-i-test_execute_system_specifically_to_latest_version) - -## test_execute_system_update_installed() [](#method-i-test_execute_system_update_installed) - -## test_execute_system_update_installed_in_non_default_gem_path() [](#method-i-test_execute_system_update_installed_in_non_default_gem_path) - -## test_execute_system_when_latest_does_not_support_your_ruby() [](#method-i-test_execute_system_when_latest_does_not_support_your_ruby) - -## test_execute_system_when_latest_does_not_support_your_ruby_but_previous_one_does() [](#method-i-test_execute_system_when_latest_does_not_support_your_ruby_but_previous_one_does) - -## test_execute_system_with_disabled_update() [](#method-i-test_execute_system_with_disabled_update) - -## test_execute_system_with_gems() [](#method-i-test_execute_system_with_gems) - -## test_execute_up_to_date() [](#method-i-test_execute_up_to_date) - -## test_execute_user_install() [](#method-i-test_execute_user_install) - -## test_explain() [](#method-i-test_explain) - -## test_explain_platform_local() [](#method-i-test_explain_platform_local) - -## test_explain_platform_ruby() [](#method-i-test_explain_platform_ruby) - -## test_fetch_remote_gems() [](#method-i-test_fetch_remote_gems) - -## test_fetch_remote_gems_error() [](#method-i-test_fetch_remote_gems_error) - -## test_fetch_remote_gems_mismatch() [](#method-i-test_fetch_remote_gems_mismatch) - -## test_fetch_remote_gems_prerelease() [](#method-i-test_fetch_remote_gems_prerelease) - -## test_handle_options_system() [](#method-i-test_handle_options_system) - -## test_handle_options_system_non_version() [](#method-i-test_handle_options_system_non_version) - -## test_handle_options_system_specific() [](#method-i-test_handle_options_system_specific) - -## test_update_gem_prerelease() [](#method-i-test_update_gem_prerelease) - -## test_update_gem_unresolved_dependency() [](#method-i-test_update_gem_unresolved_dependency) - -## test_update_rubygems_arguments() [](#method-i-test_update_rubygems_arguments) - diff --git a/example/ruby/TestGemCommandsWhichCommand.md b/example/ruby/TestGemCommandsWhichCommand.md deleted file mode 100644 index a01fd6e..0000000 --- a/example/ruby/TestGemCommandsWhichCommand.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGemCommandsWhichCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_execute() [](#method-i-test_execute) - -## test_execute_directory() [](#method-i-test_execute_directory) - -## test_execute_missing() [](#method-i-test_execute_missing) - -## test_execute_one_missing() [](#method-i-test_execute_one_missing) - -## util_foo_bar() [](#method-i-util_foo_bar) - diff --git a/example/ruby/TestGemCommandsYankCommand.md b/example/ruby/TestGemCommandsYankCommand.md deleted file mode 100644 index 241d8f5..0000000 --- a/example/ruby/TestGemCommandsYankCommand.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestGemCommandsYankCommand -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_execute() [](#method-i-test_execute) - -## test_execute_host() [](#method-i-test_execute_host) - -## test_execute_key() [](#method-i-test_execute_key) - -## test_execute_with_otp_failure() [](#method-i-test_execute_with_otp_failure) - -## test_execute_with_otp_success() [](#method-i-test_execute_with_otp_success) - -## test_handle_options() [](#method-i-test_handle_options) - -## test_handle_options_missing_argument() [](#method-i-test_handle_options_missing_argument) - -## test_with_webauthn_enabled_failure() [](#method-i-test_with_webauthn_enabled_failure) - -## test_with_webauthn_enabled_failure_with_polling() [](#method-i-test_with_webauthn_enabled_failure_with_polling) - -## test_with_webauthn_enabled_success() [](#method-i-test_with_webauthn_enabled_success) - -## test_with_webauthn_enabled_success_with_polling() [](#method-i-test_with_webauthn_enabled_success_with_polling) - -## test_yank_gem_unathorized_api_key() [](#method-i-test_yank_gem_unathorized_api_key) - diff --git a/example/ruby/TestGemConfig.md b/example/ruby/TestGemConfig.md deleted file mode 100644 index ae90955..0000000 --- a/example/ruby/TestGemConfig.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemConfig -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_bad_rake_path_is_escaped() [](#method-i-test_bad_rake_path_is_escaped) - -## test_datadir() [](#method-i-test_datadir) - -## test_good_rake_path_is_escaped() [](#method-i-test_good_rake_path_is_escaped) - diff --git a/example/ruby/TestGemConfigFile.md b/example/ruby/TestGemConfigFile.md deleted file mode 100644 index 8f78d4d..0000000 --- a/example/ruby/TestGemConfigFile.md +++ /dev/null @@ -1,88 +0,0 @@ -# Class: TestGemConfigFile -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_accept_string_key() [](#method-i-test_accept_string_key) - -## test_api_keys() [](#method-i-test_api_keys) - -## test_check_credentials_permissions() [](#method-i-test_check_credentials_permissions) - -## test_disable_default_gem_server() [](#method-i-test_disable_default_gem_server) - -## test_dump_with_rubygems_yaml() [](#method-i-test_dump_with_rubygems_yaml) - -## test_handle_arguments() [](#method-i-test_handle_arguments) - -## test_handle_arguments_backtrace() [](#method-i-test_handle_arguments_backtrace) - -## test_handle_arguments_debug() [](#method-i-test_handle_arguments_debug) - -## test_handle_arguments_norc() [](#method-i-test_handle_arguments_norc) - -## test_handle_arguments_override() [](#method-i-test_handle_arguments_override) - -## test_handle_arguments_traceback() [](#method-i-test_handle_arguments_traceback) - -## test_handle_comment() [](#method-i-test_handle_comment) - -## test_ignore_invalid_config_file() [](#method-i-test_ignore_invalid_config_file) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_environment_variable_override() [](#method-i-test_initialize_environment_variable_override) - -## test_initialize_handle_arguments_config_file() [](#method-i-test_initialize_handle_arguments_config_file) - -## test_initialize_handle_arguments_config_file_equals() [](#method-i-test_initialize_handle_arguments_config_file_equals) - -## test_initialize_handle_arguments_config_file_with_other_params() [](#method-i-test_initialize_handle_arguments_config_file_with_other_params) - -## test_initialize_ipv4_fallback_enabled_env() [](#method-i-test_initialize_ipv4_fallback_enabled_env) - -## test_initialize_operating_system_override() [](#method-i-test_initialize_operating_system_override) - -## test_initialize_platform_override() [](#method-i-test_initialize_platform_override) - -## test_initialize_system_wide_override() [](#method-i-test_initialize_system_wide_override) - -## test_load_api_keys() [](#method-i-test_load_api_keys) - -## test_load_api_keys_bad_permission() [](#method-i-test_load_api_keys_bad_permission) - -## test_load_install_extension_in_lib_from_config() [](#method-i-test_load_install_extension_in_lib_from_config) - -## test_load_ssl_ca_cert_from_config() [](#method-i-test_load_ssl_ca_cert_from_config) - -## test_load_ssl_client_cert_from_config() [](#method-i-test_load_ssl_client_cert_from_config) - -## test_load_ssl_verify_mode_from_config() [](#method-i-test_load_ssl_verify_mode_from_config) - -## test_load_with_rubygems_config_hash() [](#method-i-test_load_with_rubygems_config_hash) - -## test_really_verbose() [](#method-i-test_really_verbose) - -## test_rubygems_api_key_equals() [](#method-i-test_rubygems_api_key_equals) - -## test_rubygems_api_key_equals_bad_permission() [](#method-i-test_rubygems_api_key_equals_bad_permission) - -## test_s3_source() [](#method-i-test_s3_source) - -## test_s3_source_with_config_without_lookahead() [](#method-i-test_s3_source_with_config_without_lookahead) - -## test_set_config_file_name_from_environment_variable() [](#method-i-test_set_config_file_name_from_environment_variable) - -## test_write() [](#method-i-test_write) - -## test_write_from_hash() [](#method-i-test_write_from_hash) - -## util_config_file(args@cfg_args) [](#method-i-util_config_file) - diff --git a/example/ruby/TestGemConsoleUI.md b/example/ruby/TestGemConsoleUI.md deleted file mode 100644 index 926a770..0000000 --- a/example/ruby/TestGemConsoleUI.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestGemConsoleUI -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_output_can_be_captured_by_test_unit() [](#method-i-test_output_can_be_captured_by_test_unit) - diff --git a/example/ruby/TestGemDependency.md b/example/ruby/TestGemDependency.md deleted file mode 100644 index d388da3..0000000 --- a/example/ruby/TestGemDependency.md +++ /dev/null @@ -1,74 +0,0 @@ -# Class: TestGemDependency -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_equals2() [](#method-i-test_equals2) - -## test_equals2_type() [](#method-i-test_equals2_type) - -## test_equals_tilde() [](#method-i-test_equals_tilde) - -## test_equals_tilde_escape() [](#method-i-test_equals_tilde_escape) - -## test_equals_tilde_object() [](#method-i-test_equals_tilde_object) - -## test_equals_tilde_spec() [](#method-i-test_equals_tilde_spec) - -## test_hash() [](#method-i-test_hash) - -## test_identity() [](#method-i-test_identity) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_double() [](#method-i-test_initialize_double) - -## test_initialize_empty() [](#method-i-test_initialize_empty) - -## test_initialize_prerelease() [](#method-i-test_initialize_prerelease) - -## test_initialize_type() [](#method-i-test_initialize_type) - -## test_initialize_type_bad() [](#method-i-test_initialize_type_bad) - -## test_initialize_version() [](#method-i-test_initialize_version) - -## test_match_eh_allow_prerelease() [](#method-i-test_match_eh_allow_prerelease) - -## test_match_eh_name_tuple() [](#method-i-test_match_eh_name_tuple) - -## test_match_eh_specification() [](#method-i-test_match_eh_specification) - -## test_matches_spec_eh() [](#method-i-test_matches_spec_eh) - -## test_matches_spec_eh_prerelease() [](#method-i-test_matches_spec_eh_prerelease) - -## test_merge() [](#method-i-test_merge) - -## test_merge_default() [](#method-i-test_merge_default) - -## test_merge_name_mismatch() [](#method-i-test_merge_name_mismatch) - -## test_merge_other_default() [](#method-i-test_merge_other_default) - -## test_prerelease_eh() [](#method-i-test_prerelease_eh) - -## test_specific() [](#method-i-test_specific) - -## test_to_spec() [](#method-i-test_to_spec) - -## test_to_spec_prerelease() [](#method-i-test_to_spec_prerelease) - -## test_to_spec_with_only_prereleases() [](#method-i-test_to_spec_with_only_prereleases) - -## test_to_specs_indicates_total_gem_set_size() [](#method-i-test_to_specs_indicates_total_gem_set_size) - -## test_to_specs_respects_bundler_version() [](#method-i-test_to_specs_respects_bundler_version) - -## test_to_specs_suggests_other_versions() [](#method-i-test_to_specs_suggests_other_versions) - diff --git a/example/ruby/TestGemDependencyInstaller.md b/example/ruby/TestGemDependencyInstaller.md deleted file mode 100644 index 5d76ff6..0000000 --- a/example/ruby/TestGemDependencyInstaller.md +++ /dev/null @@ -1,128 +0,0 @@ -# Class: TestGemDependencyInstaller -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_find_gems_gems_with_sources() [](#method-i-test_find_gems_gems_with_sources) - -## test_find_gems_with_sources_local() [](#method-i-test_find_gems_with_sources_local) - -## test_find_gems_with_sources_prerelease() [](#method-i-test_find_gems_with_sources_prerelease) - -## test_find_gems_with_sources_with_bad_source() [](#method-i-test_find_gems_with_sources_with_bad_source) - -## test_find_gems_with_sources_with_best_only_and_platform() [](#method-i-test_find_gems_with_sources_with_best_only_and_platform) - -## test_install() [](#method-i-test_install) - -## test_install_all_dependencies() [](#method-i-test_install_all_dependencies) - -## test_install_build_args() [](#method-i-test_install_build_args) - -## test_install_cache_dir() [](#method-i-test_install_cache_dir) - -## test_install_dependencies_satisfied() [](#method-i-test_install_dependencies_satisfied) - -## test_install_dependency() [](#method-i-test_install_dependency) - -## test_install_dependency_development() [](#method-i-test_install_dependency_development) - -## test_install_dependency_development_deep() [](#method-i-test_install_dependency_development_deep) - -## test_install_dependency_development_shallow() [](#method-i-test_install_dependency_development_shallow) - -## test_install_dependency_existing() [](#method-i-test_install_dependency_existing) - -## test_install_dependency_existing_extension() [](#method-i-test_install_dependency_existing_extension) - -## test_install_dependency_old() [](#method-i-test_install_dependency_old) - -## test_install_doesnt_upgrade_installed_dependencies() [](#method-i-test_install_doesnt_upgrade_installed_dependencies) -This asserts that if a gem's dependency is satisfied by an already installed -gem, RubyGems doesn't installed a newer version - -## test_install_domain_both() [](#method-i-test_install_domain_both) - -## test_install_domain_both_no_network() [](#method-i-test_install_domain_both_no_network) - -## test_install_domain_local() [](#method-i-test_install_domain_local) - -## test_install_domain_remote() [](#method-i-test_install_domain_remote) - -## test_install_dual_repository() [](#method-i-test_install_dual_repository) - -## test_install_dual_repository_and_done_installing_hooks() [](#method-i-test_install_dual_repository_and_done_installing_hooks) - -## test_install_env_shebang() [](#method-i-test_install_env_shebang) - -## test_install_force() [](#method-i-test_install_force) - -## test_install_ignore_dependencies() [](#method-i-test_install_ignore_dependencies) - -## test_install_install_dir() [](#method-i-test_install_install_dir) - -## test_install_legacy_spec_with_nil_required_ruby_version() [](#method-i-test_install_legacy_spec_with_nil_required_ruby_version) - -## test_install_legacy_spec_with_nil_required_rubygems_version() [](#method-i-test_install_legacy_spec_with_nil_required_rubygems_version) - -## test_install_local() [](#method-i-test_install_local) - -## test_install_local_dependency() [](#method-i-test_install_local_dependency) - -## test_install_local_dependency_installed() [](#method-i-test_install_local_dependency_installed) - -## test_install_local_dependency_no_network_for_target_gem() [](#method-i-test_install_local_dependency_no_network_for_target_gem) - -## test_install_local_prerelease() [](#method-i-test_install_local_prerelease) - -## test_install_local_subdir() [](#method-i-test_install_local_subdir) - -## test_install_minimal_deps() [](#method-i-test_install_minimal_deps) - -## test_install_no_document() [](#method-i-test_install_no_document) - -## test_install_no_minimal_deps() [](#method-i-test_install_no_minimal_deps) - -## test_install_no_wrappers() [](#method-i-test_install_no_wrappers) - -## test_install_platform_is_ignored_when_a_file_is_specified() [](#method-i-test_install_platform_is_ignored_when_a_file_is_specified) - -## test_install_prerelease() [](#method-i-test_install_prerelease) - -## test_install_prerelease_bug_990() [](#method-i-test_install_prerelease_bug_990) - -## test_install_prerelease_skipped_when_normal_ver() [](#method-i-test_install_prerelease_skipped_when_normal_ver) - -## test_install_reinstall() [](#method-i-test_install_reinstall) - -## test_install_remote() [](#method-i-test_install_remote) - -## test_install_remote_dep() [](#method-i-test_install_remote_dep) - -## test_install_remote_platform_newer() [](#method-i-test_install_remote_platform_newer) - -## test_install_security_policy() [](#method-i-test_install_security_policy) - -## test_install_version() [](#method-i-test_install_version) - -## test_install_version_default() [](#method-i-test_install_version_default) - -## test_install_when_only_prerelease() [](#method-i-test_install_when_only_prerelease) - -## test_resolve_dependencies() [](#method-i-test_resolve_dependencies) - -## test_resolve_dependencies_ignore_dependencies() [](#method-i-test_resolve_dependencies_ignore_dependencies) - -## test_resolve_dependencies_local() [](#method-i-test_resolve_dependencies_local) - -## util_setup_d() [](#method-i-util_setup_d) - -## util_setup_gems() [](#method-i-util_setup_gems) - diff --git a/example/ruby/TestGemDependencyList.md b/example/ruby/TestGemDependencyList.md deleted file mode 100644 index e990b79..0000000 --- a/example/ruby/TestGemDependencyList.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: TestGemDependencyList -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_active_count() [](#method-i-test_active_count) - -## test_add() [](#method-i-test_add) - -## test_dependency_order() [](#method-i-test_dependency_order) - -## test_dependency_order_circle() [](#method-i-test_dependency_order_circle) - -## test_dependency_order_development() [](#method-i-test_dependency_order_development) - -## test_dependency_order_diamond() [](#method-i-test_dependency_order_diamond) - -## test_dependency_order_no_dependencies() [](#method-i-test_dependency_order_no_dependencies) - -## test_find_name() [](#method-i-test_find_name) - -## test_ok_eh() [](#method-i-test_ok_eh) - -## test_ok_eh_mismatch() [](#method-i-test_ok_eh_mismatch) - -## test_ok_eh_redundant() [](#method-i-test_ok_eh_redundant) - -## test_ok_to_remove_eh() [](#method-i-test_ok_to_remove_eh) - -## test_ok_to_remove_eh_after_sibling_removed() [](#method-i-test_ok_to_remove_eh_after_sibling_removed) - -## test_remove_by_name() [](#method-i-test_remove_by_name) - -## test_tsort_each_child() [](#method-i-test_tsort_each_child) - -## test_tsort_each_node() [](#method-i-test_tsort_each_node) - -## test_why_not_ok_eh() [](#method-i-test_why_not_ok_eh) - -## test_why_not_ok_eh_old_dependency() [](#method-i-test_why_not_ok_eh_old_dependency) - -## util_diamond() [](#method-i-util_diamond) -d1 -> b1 -> a1 d1 -> c2 -> a2 - diff --git a/example/ruby/TestGemDependencyResolutionError.md b/example/ruby/TestGemDependencyResolutionError.md deleted file mode 100644 index 71a1713..0000000 --- a/example/ruby/TestGemDependencyResolutionError.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemDependencyResolutionError -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_message() [](#method-i-test_message) - diff --git a/example/ruby/TestGemDeprecate.md b/example/ruby/TestGemDeprecate.md deleted file mode 100644 index 3515b55..0000000 --- a/example/ruby/TestGemDeprecate.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestGemDeprecate -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_assignment() [](#method-i-test_assignment) - -## test_defaults() [](#method-i-test_defaults) - -## test_deprecated_method_calls_the_old_method() [](#method-i-test_deprecated_method_calls_the_old_method) - -## test_deprecated_method_outputs_a_warning() [](#method-i-test_deprecated_method_outputs_a_warning) - -## test_deprecated_method_outputs_a_warning_old_way() [](#method-i-test_deprecated_method_outputs_a_warning_old_way) - -## test_rubygems_deprecate_command() [](#method-i-test_rubygems_deprecate_command) - -## test_skip() [](#method-i-test_skip) - diff --git a/example/ruby/TestGemDeprecate/OtherThing.md b/example/ruby/TestGemDeprecate/OtherThing.md deleted file mode 100644 index d0e02b7..0000000 --- a/example/ruby/TestGemDeprecate/OtherThing.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: TestGemDeprecate::OtherThing -**Inherits:** Object - -**Extended by:** Gem::Deprecate - - - - -# Class Methods -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -# Attributes -## message[RW] [](#attribute-i-message) -Returns the value of attribute message. - - -#Instance Methods -## bar() [](#method-i-bar) - -## bar_arg(msg) [](#method-i-bar_arg) - -## bar_kwarg(message:) [](#method-i-bar_kwarg) - -## foo() [](#method-i-foo) - -## foo_arg(msg) [](#method-i-foo_arg) - -## foo_kwarg(message:) [](#method-i-foo_kwarg) - diff --git a/example/ruby/TestGemDeprecate/Thing.md b/example/ruby/TestGemDeprecate/Thing.md deleted file mode 100644 index 09a047d..0000000 --- a/example/ruby/TestGemDeprecate/Thing.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: TestGemDeprecate::Thing -**Inherits:** Object - -**Extended by:** Gem::Deprecate - - - - -# Class Methods -## deprecate(name , repl , year , month ) [](#method-c-deprecate) -Simple deprecation method that deprecates `name` by wrapping it up in a dummy -method. It warns on each call to the dummy method telling the user of `repl` -(unless `repl` is :none) and the year/month that it is planned to go away. -# Attributes -## message[RW] [](#attribute-i-message) -Returns the value of attribute message. - - -#Instance Methods -## bar() [](#method-i-bar) - -## bar_arg(msg) [](#method-i-bar_arg) - -## bar_kwarg(message:) [](#method-i-bar_kwarg) - -## foo() [](#method-i-foo) - -## foo_arg(msg) [](#method-i-foo_arg) - -## foo_kwarg(message:) [](#method-i-foo_kwarg) - diff --git a/example/ruby/TestGemDoctor.md b/example/ruby/TestGemDoctor.md deleted file mode 100644 index a3e327b..0000000 --- a/example/ruby/TestGemDoctor.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestGemDoctor -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## gem(name) [](#method-i-gem) - -## test_doctor() [](#method-i-test_doctor) - -## test_doctor_badly_named_plugins() [](#method-i-test_doctor_badly_named_plugins) - -## test_doctor_child_missing() [](#method-i-test_doctor_child_missing) - -## test_doctor_dry_run() [](#method-i-test_doctor_dry_run) - -## test_doctor_non_gem_home() [](#method-i-test_doctor_non_gem_home) - -## test_gem_repository_eh() [](#method-i-test_gem_repository_eh) - diff --git a/example/ruby/TestGemExit.md b/example/ruby/TestGemExit.md deleted file mode 100644 index 216eebe..0000000 --- a/example/ruby/TestGemExit.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemExit -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_exit() [](#method-i-test_exit) - -## test_status() [](#method-i-test_status) - diff --git a/example/ruby/TestGemExtBuilder.md b/example/ruby/TestGemExtBuilder.md deleted file mode 100644 index 380e41f..0000000 --- a/example/ruby/TestGemExtBuilder.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestGemExtBuilder -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_build_extensions() [](#method-i-test_build_extensions) - -## test_build_extensions_extconf_bad() [](#method-i-test_build_extensions_extconf_bad) - -## test_build_extensions_install_ext_only() [](#method-i-test_build_extensions_install_ext_only) - -## test_build_extensions_none() [](#method-i-test_build_extensions_none) - -## test_build_extensions_rebuild_failure() [](#method-i-test_build_extensions_rebuild_failure) - -## test_build_extensions_unsupported() [](#method-i-test_build_extensions_unsupported) - -## test_build_extensions_with_build_args() [](#method-i-test_build_extensions_with_build_args) - -## test_build_extensions_with_gemhome_with_space() [](#method-i-test_build_extensions_with_gemhome_with_space) - -## test_build_extensions_with_target_rbconfig() [](#method-i-test_build_extensions_with_target_rbconfig) - -## test_class_make() [](#method-i-test_class_make) - -## test_class_make_no_clean() [](#method-i-test_class_make_no_clean) - -## test_custom_make_with_options() [](#method-i-test_custom_make_with_options) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_build_args() [](#method-i-test_initialize_build_args) - diff --git a/example/ruby/TestGemExtCargoBuilder.md b/example/ruby/TestGemExtCargoBuilder.md deleted file mode 100644 index 412156d..0000000 --- a/example/ruby/TestGemExtCargoBuilder.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestGemExtCargoBuilder -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## setup_rust_gem(name) [](#method-i-setup_rust_gem) - -## test_build_cdylib() [](#method-i-test_build_cdylib) - -## test_build_fail() [](#method-i-test_build_fail) - -## test_custom_name() [](#method-i-test_custom_name) - -## test_full_integration() [](#method-i-test_full_integration) - -## test_rubygems_cfg_passed_to_rustc() [](#method-i-test_rubygems_cfg_passed_to_rustc) - diff --git a/example/ruby/TestGemExtCargoBuilderLinkFlagConverter.md b/example/ruby/TestGemExtCargoBuilderLinkFlagConverter.md deleted file mode 100644 index 449f6ab..0000000 --- a/example/ruby/TestGemExtCargoBuilderLinkFlagConverter.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestGemExtCargoBuilderLinkFlagConverter -**Inherits:** Gem::TestCase - - - - - diff --git a/example/ruby/TestGemExtCargoBuilderUnit.md b/example/ruby/TestGemExtCargoBuilderUnit.md deleted file mode 100644 index 077315f..0000000 --- a/example/ruby/TestGemExtCargoBuilderUnit.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGemExtCargoBuilderUnit -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## skip_unsupported_platforms!() [](#method-i-skip_unsupported_platforms!) - -## test_build_env_includes_rbconfig() [](#method-i-test_build_env_includes_rbconfig) - -## test_cargo_command_locks_in_release_profile() [](#method-i-test_cargo_command_locks_in_release_profile) - -## test_cargo_command_passes_args() [](#method-i-test_cargo_command_passes_args) - -## test_cargo_command_passes_respects_cargo_build_target() [](#method-i-test_cargo_command_passes_respects_cargo_build_target) - -## test_cargo_command_passes_respects_cargo_env_var() [](#method-i-test_cargo_command_passes_respects_cargo_env_var) - diff --git a/example/ruby/TestGemExtCmakeBuilder.md b/example/ruby/TestGemExtCmakeBuilder.md deleted file mode 100644 index a453ebf..0000000 --- a/example/ruby/TestGemExtCmakeBuilder.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemExtCmakeBuilder -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_self_build() [](#method-i-test_self_build) - -## test_self_build_fail() [](#method-i-test_self_build_fail) - -## test_self_build_has_makefile() [](#method-i-test_self_build_has_makefile) - diff --git a/example/ruby/TestGemExtConfigureBuilder.md b/example/ruby/TestGemExtConfigureBuilder.md deleted file mode 100644 index ba11373..0000000 --- a/example/ruby/TestGemExtConfigureBuilder.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemExtConfigureBuilder -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_self_build() [](#method-i-test_self_build) - -## test_self_build_fail() [](#method-i-test_self_build_fail) - -## test_self_build_has_makefile() [](#method-i-test_self_build_has_makefile) - diff --git a/example/ruby/TestGemExtExtConfBuilder.md b/example/ruby/TestGemExtExtConfBuilder.md deleted file mode 100644 index b6e4c2d..0000000 --- a/example/ruby/TestGemExtExtConfBuilder.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestGemExtExtConfBuilder -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## configure_args(argsnil) [](#method-i-configure_args) - -## setup() [](#method-i-setup) - -## test_class_build() [](#method-i-test_class_build) - -## test_class_build_env_make() [](#method-i-test_class_build_env_make) - -## test_class_build_extconf_fail() [](#method-i-test_class_build_extconf_fail) - -## test_class_build_extconf_success_without_warning() [](#method-i-test_class_build_extconf_success_without_warning) - -## test_class_build_rbconfig_make_prog() [](#method-i-test_class_build_rbconfig_make_prog) - -## test_class_build_unconventional() [](#method-i-test_class_build_unconventional) - -## test_class_make() [](#method-i-test_class_make) - -## test_class_make_no_Makefile() [](#method-i-test_class_make_no_Makefile) - diff --git a/example/ruby/TestGemExtRakeBuilder.md b/example/ruby/TestGemExtRakeBuilder.md deleted file mode 100644 index 8474cb2..0000000 --- a/example/ruby/TestGemExtRakeBuilder.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TestGemExtRakeBuilder -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## create_temp_mkrf_file(rakefile_content) [](#method-i-create_temp_mkrf_file) - -## setup() [](#method-i-setup) - -## test_class_build() [](#method-i-test_class_build) - -## test_class_build_fail() [](#method-i-test_class_build_fail) - -## test_class_build_no_mkrf_passes_args() [](#method-i-test_class_build_no_mkrf_passes_args) - -## test_class_build_with_args() [](#method-i-test_class_build_with_args) -https://github.com/rubygems/rubygems/pull/1819 - -It should not fail with a non-empty args list either - -## test_class_no_openssl_override() [](#method-i-test_class_no_openssl_override) - diff --git a/example/ruby/TestGemGemRunner.md b/example/ruby/TestGemGemRunner.md deleted file mode 100644 index d8064e6..0000000 --- a/example/ruby/TestGemGemRunner.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestGemGemRunner -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_do_configuration() [](#method-i-test_do_configuration) - -## test_extract_build_args() [](#method-i-test_extract_build_args) - -## test_info_succeeds() [](#method-i-test_info_succeeds) - -## test_list_succeeds() [](#method-i-test_list_succeeds) - -## test_query_is_deprecated() [](#method-i-test_query_is_deprecated) - -## test_search_succeeds() [](#method-i-test_search_succeeds) - -## test_validate_encoding() [](#method-i-test_validate_encoding) - diff --git a/example/ruby/TestGemGemcutterUtilities.md b/example/ruby/TestGemGemcutterUtilities.md deleted file mode 100644 index 1270b22..0000000 --- a/example/ruby/TestGemGemcutterUtilities.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: TestGemGemcutterUtilities -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_alternate_key_alternate_host() [](#method-i-test_alternate_key_alternate_host) - -## test_api_key() [](#method-i-test_api_key) - -## test_api_key_override() [](#method-i-test_api_key_override) - -## test_host() [](#method-i-test_host) - -## test_host_RUBYGEMS_HOST() [](#method-i-test_host_RUBYGEMS_HOST) - -## test_host_RUBYGEMS_HOST_empty() [](#method-i-test_host_RUBYGEMS_HOST_empty) - -## test_sign_in() [](#method-i-test_sign_in) - -## test_sign_in_skips_with_existing_credentials() [](#method-i-test_sign_in_skips_with_existing_credentials) - -## test_sign_in_skips_with_key_override() [](#method-i-test_sign_in_skips_with_key_override) - -## test_sign_in_with_bad_credentials() [](#method-i-test_sign_in_with_bad_credentials) - -## test_sign_in_with_correct_otp_code() [](#method-i-test_sign_in_with_correct_otp_code) - -## test_sign_in_with_host() [](#method-i-test_sign_in_with_host) - -## test_sign_in_with_host_ENV() [](#method-i-test_sign_in_with_host_ENV) - -## test_sign_in_with_host_nil() [](#method-i-test_sign_in_with_host_nil) - -## test_sign_in_with_incorrect_otp_code() [](#method-i-test_sign_in_with_incorrect_otp_code) - -## test_sign_in_with_other_credentials_doesnt_overwrite_other_keys() [](#method-i-test_sign_in_with_other_credentials_doesnt_overwrite_other_keys) - -## test_sign_in_with_webauthn_enabled() [](#method-i-test_sign_in_with_webauthn_enabled) - -## test_sign_in_with_webauthn_enabled_with_error() [](#method-i-test_sign_in_with_webauthn_enabled_with_error) - -## test_sign_in_with_webauthn_enabled_with_polling() [](#method-i-test_sign_in_with_webauthn_enabled_with_polling) - -## test_sign_in_with_webauthn_enabled_with_polling_failure() [](#method-i-test_sign_in_with_webauthn_enabled_with_polling_failure) - -## test_signin_with_env_otp_code() [](#method-i-test_signin_with_env_otp_code) - -## test_verify_api_key() [](#method-i-test_verify_api_key) - -## test_verify_missing_api_key() [](#method-i-test_verify_missing_api_key) - -## util_sign_in(args:[], extra_input:"") [](#method-i-util_sign_in) - diff --git a/example/ruby/TestGemGemcutterUtilities/SignInFetcher.md b/example/ruby/TestGemGemcutterUtilities/SignInFetcher.md deleted file mode 100644 index 4cd026c..0000000 --- a/example/ruby/TestGemGemcutterUtilities/SignInFetcher.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestGemGemcutterUtilities::SignInFetcher -**Inherits:** Gem::MultifactorAuthFetcher - - - - -# Attributes -## api_key[RW] [](#attribute-i-api_key) -Returns the value of attribute api_key. - - -#Instance Methods -## initialize(host:nil) [](#method-i-initialize) - -**@return** [SignInFetcher] a new instance of SignInFetcher - -## respond_with_forbidden_api_key_response() [](#method-i-respond_with_forbidden_api_key_response) - -## respond_with_require_otp() [](#method-i-respond_with_require_otp) - -## respond_with_unauthorized_api_key_response() [](#method-i-respond_with_unauthorized_api_key_response) - diff --git a/example/ruby/TestGemImpossibleDependenciesError.md b/example/ruby/TestGemImpossibleDependenciesError.md deleted file mode 100644 index 6ab364b..0000000 --- a/example/ruby/TestGemImpossibleDependenciesError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestGemImpossibleDependenciesError -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_message_conflict() [](#method-i-test_message_conflict) - diff --git a/example/ruby/TestGemInstallUpdateOptions.md b/example/ruby/TestGemInstallUpdateOptions.md deleted file mode 100644 index 086088f..0000000 --- a/example/ruby/TestGemInstallUpdateOptions.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: TestGemInstallUpdateOptions -**Inherits:** Gem::InstallerTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_install_update_options() [](#method-i-test_add_install_update_options) - -## test_build_root() [](#method-i-test_build_root) - -## test_doc() [](#method-i-test_doc) - -## test_doc_no() [](#method-i-test_doc_no) - -## test_doc_rdoc() [](#method-i-test_doc_rdoc) - -## test_doc_rdoc_ri() [](#method-i-test_doc_rdoc_ri) - -## test_document() [](#method-i-test_document) - -## test_document_no() [](#method-i-test_document_no) - -## test_document_rdoc() [](#method-i-test_document_rdoc) - -## test_minimal_deps() [](#method-i-test_minimal_deps) - -## test_minimal_deps_no() [](#method-i-test_minimal_deps_no) - -## test_post_install_message() [](#method-i-test_post_install_message) - -## test_post_install_message_no() [](#method-i-test_post_install_message_no) - -## test_security_policy() [](#method-i-test_security_policy) - -## test_security_policy_unknown() [](#method-i-test_security_policy_unknown) - -## test_user_install_disabled_read_only() [](#method-i-test_user_install_disabled_read_only) - -## test_user_install_enabled() [](#method-i-test_user_install_enabled) - -## test_vendor() [](#method-i-test_vendor) - -## test_vendor_missing() [](#method-i-test_vendor_missing) - diff --git a/example/ruby/TestGemInstaller.md b/example/ruby/TestGemInstaller.md deleted file mode 100644 index 1728b13..0000000 --- a/example/ruby/TestGemInstaller.md +++ /dev/null @@ -1,263 +0,0 @@ -# Class: TestGemInstaller -**Inherits:** Gem::InstallerTestCase - - - - -# Attributes -## plugin_loaded[RW] [](#attribute-c-plugin_loaded) -Returns the value of attribute plugin_loaded. - -## post_install_is_called[RW] [](#attribute-c-post_install_is_called) -Returns the value of attribute post_install_is_called. - - -#Instance Methods -## get_bin_env() [](#method-i-get_bin_env) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_app_script_text() [](#method-i-test_app_script_text) - -## test_check_executable_overwrite() [](#method-i-test_check_executable_overwrite) - -## test_check_executable_overwrite_default_bin_dir() [](#method-i-test_check_executable_overwrite_default_bin_dir) - -## test_check_executable_overwrite_format_executable() [](#method-i-test_check_executable_overwrite_format_executable) - -## test_check_executable_overwrite_other_gem() [](#method-i-test_check_executable_overwrite_other_gem) - -## test_check_executable_overwrite_other_gem_force() [](#method-i-test_check_executable_overwrite_other_gem_force) - -## test_check_executable_overwrite_other_non_gem() [](#method-i-test_check_executable_overwrite_other_non_gem) - -## test_check_that_user_bin_dir_is_in_path() [](#method-i-test_check_that_user_bin_dir_is_in_path) - -## test_check_that_user_bin_dir_is_in_path_not_in_path() [](#method-i-test_check_that_user_bin_dir_is_in_path_not_in_path) - -## test_check_that_user_bin_dir_is_in_path_tilde() [](#method-i-test_check_that_user_bin_dir_is_in_path_tilde) - -## test_conflicting_binstubs() [](#method-i-test_conflicting_binstubs) - -## test_default_gem_loaded_from() [](#method-i-test_default_gem_loaded_from) - -## test_default_gem_to_specific_install_dir() [](#method-i-test_default_gem_to_specific_install_dir) - -## test_default_gem_with_exe_as_bindir() [](#method-i-test_default_gem_with_exe_as_bindir) - -## test_default_gem_with_wrappers() [](#method-i-test_default_gem_with_wrappers) - -## test_default_gem_without_wrappers() [](#method-i-test_default_gem_without_wrappers) - -## test_dir() [](#method-i-test_dir) - -## test_ensure_dependency() [](#method-i-test_ensure_dependency) - -## test_ensure_loadable_spec() [](#method-i-test_ensure_loadable_spec) - -## test_ensure_loadable_spec_security_policy() [](#method-i-test_ensure_loadable_spec_security_policy) - -## test_extract_files() [](#method-i-test_extract_files) - -## test_find_lib_file_after_install() [](#method-i-test_find_lib_file_after_install) - -## test_gem_attribute() [](#method-i-test_gem_attribute) - -## test_generate_bin_bindir() [](#method-i-test_generate_bin_bindir) - -## test_generate_bin_bindir_with_user_install_warning() [](#method-i-test_generate_bin_bindir_with_user_install_warning) - -## test_generate_bin_script() [](#method-i-test_generate_bin_script) - -## test_generate_bin_script_format() [](#method-i-test_generate_bin_script_format) - -## test_generate_bin_script_format_disabled() [](#method-i-test_generate_bin_script_format_disabled) - -## test_generate_bin_script_install_dir() [](#method-i-test_generate_bin_script_install_dir) - -## test_generate_bin_script_no_execs() [](#method-i-test_generate_bin_script_no_execs) - -## test_generate_bin_script_no_perms() [](#method-i-test_generate_bin_script_no_perms) - -## test_generate_bin_script_no_shebang() [](#method-i-test_generate_bin_script_no_shebang) - -## test_generate_bin_script_wrappers() [](#method-i-test_generate_bin_script_wrappers) - -## test_generate_bin_symlink() [](#method-i-test_generate_bin_symlink) - -## test_generate_bin_symlink_no_execs() [](#method-i-test_generate_bin_symlink_no_execs) - -## test_generate_bin_symlink_no_perms() [](#method-i-test_generate_bin_symlink_no_perms) - -## test_generate_bin_symlink_update_newer() [](#method-i-test_generate_bin_symlink_update_newer) - -## test_generate_bin_symlink_update_older() [](#method-i-test_generate_bin_symlink_update_older) - -## test_generate_bin_symlink_update_remove_wrapper() [](#method-i-test_generate_bin_symlink_update_remove_wrapper) - -## test_generate_bin_symlink_win32() [](#method-i-test_generate_bin_symlink_win32) - -## test_generate_bin_uses_default_shebang() [](#method-i-test_generate_bin_uses_default_shebang) - -## test_generate_bin_with_dangling_symlink() [](#method-i-test_generate_bin_with_dangling_symlink) - -## test_generate_plugins() [](#method-i-test_generate_plugins) - -## test_generate_plugins_with_build_root() [](#method-i-test_generate_plugins_with_build_root) - -## test_generate_plugins_with_install_dir() [](#method-i-test_generate_plugins_with_install_dir) - -## test_generate_plugins_with_user_install() [](#method-i-test_generate_plugins_with_user_install) - -## test_generates_plugins_dir_under_install_dir_if_not_there() [](#method-i-test_generates_plugins_dir_under_install_dir_if_not_there) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_user_install() [](#method-i-test_initialize_user_install) - -## test_initialize_user_install_bin_dir() [](#method-i-test_initialize_user_install_bin_dir) - -## test_install() [](#method-i-test_install) - -## test_install_build_root() [](#method-i-test_install_build_root) - -## test_install_build_root_when_gem_home_not_writable_does_not_fallback_to_user_install_inside_build_root() [](#method-i-test_install_build_root_when_gem_home_not_writable_does_not_fallback_to_user_install_inside_build_root) - -## test_install_creates_binstub_that_dont_trust_encoding() [](#method-i-test_install_creates_binstub_that_dont_trust_encoding) - -## test_install_creates_binstub_that_prefers_user_installed_gem_to_default() [](#method-i-test_install_creates_binstub_that_prefers_user_installed_gem_to_default) - -## test_install_creates_binstub_that_understand_version() [](#method-i-test_install_creates_binstub_that_understand_version) - -## test_install_creates_working_binstub() [](#method-i-test_install_creates_working_binstub) - -## test_install_dir_takes_precedence_to_user_install() [](#method-i-test_install_dir_takes_precedence_to_user_install) - -## test_install_does_not_leave_lockfile_for_binstub() [](#method-i-test_install_does_not_leave_lockfile_for_binstub) - -## test_install_extension_and_script() [](#method-i-test_install_extension_and_script) - -## test_install_extension_clean_intermediate_files() [](#method-i-test_install_extension_clean_intermediate_files) - -## test_install_extension_dir() [](#method-i-test_install_extension_dir) - -## test_install_extension_dir_is_removed_on_reinstall() [](#method-i-test_install_extension_dir_is_removed_on_reinstall) - -## test_install_extension_flat() [](#method-i-test_install_extension_flat) - -## test_install_force() [](#method-i-test_install_force) - -## test_install_missing_dirs() [](#method-i-test_install_missing_dirs) - -## test_install_post_build_false() [](#method-i-test_install_post_build_false) - -## test_install_post_build_nil() [](#method-i-test_install_post_build_nil) - -## test_install_pre_install_false() [](#method-i-test_install_pre_install_false) - -## test_install_pre_install_nil() [](#method-i-test_install_pre_install_nil) - -## test_install_user_extension_dir() [](#method-i-test_install_user_extension_dir) - -## test_install_with_message() [](#method-i-test_install_with_message) - -## test_install_with_no_prior_files() [](#method-i-test_install_with_no_prior_files) - -## test_install_with_skipped_message() [](#method-i-test_install_with_skipped_message) - -## test_installation_satisfies_dependency_eh() [](#method-i-test_installation_satisfies_dependency_eh) - -## test_installation_satisfies_dependency_eh_development() [](#method-i-test_installation_satisfies_dependency_eh_development) - -## test_keeps_plugins_up_to_date() [](#method-i-test_keeps_plugins_up_to_date) - -## test_leaves_no_empty_cached_spec_when_no_more_disk_space() [](#method-i-test_leaves_no_empty_cached_spec_when_no_more_disk_space) - -## test_package_attribute() [](#method-i-test_package_attribute) - -## test_pre_install_checks_dependencies() [](#method-i-test_pre_install_checks_dependencies) - -## test_pre_install_checks_dependencies_ignore() [](#method-i-test_pre_install_checks_dependencies_ignore) - -## test_pre_install_checks_dependencies_install_dir() [](#method-i-test_pre_install_checks_dependencies_install_dir) - -## test_pre_install_checks_malicious_dependencies_before_eval() [](#method-i-test_pre_install_checks_malicious_dependencies_before_eval) - -## test_pre_install_checks_malicious_extensions_before_eval() [](#method-i-test_pre_install_checks_malicious_extensions_before_eval) - -## test_pre_install_checks_malicious_name() [](#method-i-test_pre_install_checks_malicious_name) - -## test_pre_install_checks_malicious_name_before_eval() [](#method-i-test_pre_install_checks_malicious_name_before_eval) - -## test_pre_install_checks_malicious_platform_before_eval() [](#method-i-test_pre_install_checks_malicious_platform_before_eval) - -## test_pre_install_checks_malicious_require_paths_before_eval() [](#method-i-test_pre_install_checks_malicious_require_paths_before_eval) - -## test_pre_install_checks_malicious_specification_version_before_eval() [](#method-i-test_pre_install_checks_malicious_specification_version_before_eval) - -## test_process_options() [](#method-i-test_process_options) - -## test_process_options_build_root() [](#method-i-test_process_options_build_root) - -## test_process_options_does_not_fallback_to_user_install_when_gem_home_not_writable_and_no_user_install() [](#method-i-test_process_options_does_not_fallback_to_user_install_when_gem_home_not_writable_and_no_user_install) - -## test_process_options_fallback_to_user_install_when_gem_home_not_writable() [](#method-i-test_process_options_fallback_to_user_install_when_gem_home_not_writable) - -## test_shebang() [](#method-i-test_shebang) - -## test_shebang_arguments() [](#method-i-test_shebang_arguments) - -## test_shebang_arguments_with_load_relative() [](#method-i-test_shebang_arguments_with_load_relative) - -## test_shebang_custom() [](#method-i-test_shebang_custom) - -## test_shebang_custom_with_expands() [](#method-i-test_shebang_custom_with_expands) - -## test_shebang_custom_with_expands_and_arguments() [](#method-i-test_shebang_custom_with_expands_and_arguments) - -## test_shebang_empty() [](#method-i-test_shebang_empty) - -## test_shebang_env() [](#method-i-test_shebang_env) - -## test_shebang_env_arguments() [](#method-i-test_shebang_env_arguments) - -## test_shebang_env_arguments_with_load_relative() [](#method-i-test_shebang_env_arguments_with_load_relative) - -## test_shebang_env_shebang() [](#method-i-test_shebang_env_shebang) - -## test_shebang_nested() [](#method-i-test_shebang_nested) - -## test_shebang_nested_arguments() [](#method-i-test_shebang_nested_arguments) - -## test_shebang_nested_arguments_with_load_relative() [](#method-i-test_shebang_nested_arguments_with_load_relative) - -## test_shebang_version() [](#method-i-test_shebang_version) - -## test_shebang_version_arguments() [](#method-i-test_shebang_version_arguments) - -## test_shebang_version_arguments_with_load_relative() [](#method-i-test_shebang_version_arguments_with_load_relative) - -## test_shebang_version_env() [](#method-i-test_shebang_version_env) - -## test_shebang_version_env_arguments() [](#method-i-test_shebang_version_env_arguments) - -## test_shebang_version_env_arguments_with_load_relative() [](#method-i-test_shebang_version_env_arguments_with_load_relative) - -## test_unpack() [](#method-i-test_unpack) - -## test_use_plugin_immediately() [](#method-i-test_use_plugin_immediately) - -## test_write_build_info_file() [](#method-i-test_write_build_info_file) - -## test_write_build_info_file_empty() [](#method-i-test_write_build_info_file_empty) - -## test_write_build_info_file_install_dir() [](#method-i-test_write_build_info_file_install_dir) - -## test_write_cache_file() [](#method-i-test_write_cache_file) - -## test_write_spec() [](#method-i-test_write_spec) - -## test_write_spec_writes_cached_spec() [](#method-i-test_write_spec_writes_cached_spec) - diff --git a/example/ruby/TestGemKernel.md b/example/ruby/TestGemKernel.md deleted file mode 100644 index cd5f7cc..0000000 --- a/example/ruby/TestGemKernel.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestGemKernel -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_gem() [](#method-i-test_gem) - -## test_gem_bundler() [](#method-i-test_gem_bundler) - -## test_gem_bundler_inferred_bundler_version() [](#method-i-test_gem_bundler_inferred_bundler_version) - -## test_gem_conflicting() [](#method-i-test_gem_conflicting) - -## test_gem_default() [](#method-i-test_gem_default) - -## test_gem_default_re_gem() [](#method-i-test_gem_default_re_gem) - -## test_gem_env_req() [](#method-i-test_gem_env_req) - -## test_gem_failing_inside_require_doesnt_cause_double_exceptions() [](#method-i-test_gem_failing_inside_require_doesnt_cause_double_exceptions) - -## test_gem_not_adding_bin() [](#method-i-test_gem_not_adding_bin) - -## test_gem_overlapping() [](#method-i-test_gem_overlapping) - -## test_gem_prerelease_is_the_only_available() [](#method-i-test_gem_prerelease_is_the_only_available) - -## test_gem_re_gem_mismatch() [](#method-i-test_gem_re_gem_mismatch) - -## test_gem_redundant() [](#method-i-test_gem_redundant) - -## test_release_favored_over_prerelease() [](#method-i-test_release_favored_over_prerelease) - diff --git a/example/ruby/TestGemLocalRemoteOptions.md b/example/ruby/TestGemLocalRemoteOptions.md deleted file mode 100644 index f492388..0000000 --- a/example/ruby/TestGemLocalRemoteOptions.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestGemLocalRemoteOptions -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_local_remote_options() [](#method-i-test_add_local_remote_options) - -## test_both_eh() [](#method-i-test_both_eh) - -## test_clear_sources_option() [](#method-i-test_clear_sources_option) - -## test_clear_sources_option_idiot_proof() [](#method-i-test_clear_sources_option_idiot_proof) - -## test_local_eh() [](#method-i-test_local_eh) - -## test_remote_eh() [](#method-i-test_remote_eh) - -## test_short_source_option() [](#method-i-test_short_source_option) - -## test_source_option() [](#method-i-test_source_option) - -## test_source_option_bad() [](#method-i-test_source_option_bad) - -## test_update_sources_option() [](#method-i-test_update_sources_option) - diff --git a/example/ruby/TestGemNameTuple.md b/example/ruby/TestGemNameTuple.md deleted file mode 100644 index f831d6c..0000000 --- a/example/ruby/TestGemNameTuple.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemNameTuple -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_full_name() [](#method-i-test_full_name) - -## test_platform_normalization() [](#method-i-test_platform_normalization) - -## test_spaceship() [](#method-i-test_spaceship) - -## test_spec_name() [](#method-i-test_spec_name) - diff --git a/example/ruby/TestGemPackage.md b/example/ruby/TestGemPackage.md deleted file mode 100644 index 6abe810..0000000 --- a/example/ruby/TestGemPackage.md +++ /dev/null @@ -1,125 +0,0 @@ -# Class: TestGemPackage -**Inherits:** Gem::Package::TarTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_checksums() [](#method-i-test_add_checksums) - -## test_add_files() [](#method-i-test_add_files) - -## test_add_files_symlink() [](#method-i-test_add_files_symlink) - -## test_build() [](#method-i-test_build) - -## test_build_auto_signed() [](#method-i-test_build_auto_signed) - -## test_build_auto_signed_encrypted_key() [](#method-i-test_build_auto_signed_encrypted_key) - -## test_build_invalid() [](#method-i-test_build_invalid) - -## test_build_invalid_arguments() [](#method-i-test_build_invalid_arguments) - -## test_build_modified_platform() [](#method-i-test_build_modified_platform) - -## test_build_signed() [](#method-i-test_build_signed) - -## test_build_signed_encrypted_key() [](#method-i-test_build_signed_encrypted_key) - -## test_build_time_uses_source_date_epoch() [](#method-i-test_build_time_uses_source_date_epoch) - -## test_build_time_without_source_date_epoch() [](#method-i-test_build_time_without_source_date_epoch) - -## test_class_new_old_format() [](#method-i-test_class_new_old_format) - -## test_contents() [](#method-i-test_contents) - -## test_contents_from_io() [](#method-i-test_contents_from_io) - -## test_corrupt_data_tar_gz() [](#method-i-test_corrupt_data_tar_gz) - -## test_extract_file_permissions() [](#method-i-test_extract_file_permissions) - -## test_extract_files() [](#method-i-test_extract_files) - -## test_extract_files_empty() [](#method-i-test_extract_files_empty) - -## test_extract_symlink_into_symlink_dir() [](#method-i-test_extract_symlink_into_symlink_dir) - -## test_extract_symlink_parent() [](#method-i-test_extract_symlink_parent) - -## test_extract_symlink_parent_doesnt_delete_user_dir() [](#method-i-test_extract_symlink_parent_doesnt_delete_user_dir) - -## test_extract_tar_gz_absolute() [](#method-i-test_extract_tar_gz_absolute) - -## test_extract_tar_gz_case_insensitive() [](#method-i-test_extract_tar_gz_case_insensitive) - -## test_extract_tar_gz_directory() [](#method-i-test_extract_tar_gz_directory) - -## test_extract_tar_gz_dot_file() [](#method-i-test_extract_tar_gz_dot_file) - -## test_extract_tar_gz_dot_slash() [](#method-i-test_extract_tar_gz_dot_slash) - -## test_extract_tar_gz_symlink_broken_relative_path() [](#method-i-test_extract_tar_gz_symlink_broken_relative_path) - -## test_extract_tar_gz_symlink_relative_path() [](#method-i-test_extract_tar_gz_symlink_relative_path) - -## test_gem_attr() [](#method-i-test_gem_attr) - -## test_install_location() [](#method-i-test_install_location) - -## test_install_location_absolute() [](#method-i-test_install_location_absolute) - -## test_install_location_dots() [](#method-i-test_install_location_dots) - -## test_install_location_extra_slash() [](#method-i-test_install_location_extra_slash) - -## test_install_location_relative() [](#method-i-test_install_location_relative) - -## test_install_location_suffix() [](#method-i-test_install_location_suffix) - -## test_load_spec() [](#method-i-test_load_spec) - -## test_raw_spec() [](#method-i-test_raw_spec) - -## test_spec() [](#method-i-test_spec) - -## test_spec_from_io() [](#method-i-test_spec_from_io) - -## test_spec_from_io_raises_gem_error_for_io_not_at_start() [](#method-i-test_spec_from_io_raises_gem_error_for_io_not_at_start) - -## test_verify() [](#method-i-test_verify) - -## test_verify_checksum_bad() [](#method-i-test_verify_checksum_bad) - -## test_verify_checksum_missing() [](#method-i-test_verify_checksum_missing) - -## test_verify_corrupt() [](#method-i-test_verify_corrupt) - -## test_verify_corrupt_tar_checksums_entry() [](#method-i-test_verify_corrupt_tar_checksums_entry) - -## test_verify_corrupt_tar_data_entry() [](#method-i-test_verify_corrupt_tar_data_entry) - -## test_verify_corrupt_tar_metadata_entry() [](#method-i-test_verify_corrupt_tar_metadata_entry) - -## test_verify_duplicate_file() [](#method-i-test_verify_duplicate_file) - -## test_verify_empty() [](#method-i-test_verify_empty) - -## test_verify_entry() [](#method-i-test_verify_entry) -end #verify tests - -## test_verify_nonexistent() [](#method-i-test_verify_nonexistent) - -## test_verify_security_policy() [](#method-i-test_verify_security_policy) - -## test_verify_security_policy_checksum_missing() [](#method-i-test_verify_security_policy_checksum_missing) - -## test_verify_security_policy_low_security() [](#method-i-test_verify_security_policy_low_security) - -## test_verify_truncate() [](#method-i-test_verify_truncate) - diff --git a/example/ruby/TestGemPackageOld.md b/example/ruby/TestGemPackageOld.md deleted file mode 100644 index baee1f1..0000000 --- a/example/ruby/TestGemPackageOld.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestGemPackageOld -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_contents() [](#method-i-test_contents) - -## test_contents_security_policy() [](#method-i-test_contents_security_policy) - -## test_extract_files() [](#method-i-test_extract_files) - -## test_extract_files_security_policy() [](#method-i-test_extract_files_security_policy) - -## test_spec() [](#method-i-test_spec) - -## test_spec_security_policy() [](#method-i-test_spec_security_policy) - -## test_verify() [](#method-i-test_verify) - diff --git a/example/ruby/TestGemPackageTarHeader.md b/example/ruby/TestGemPackageTarHeader.md deleted file mode 100644 index 8fb8ac6..0000000 --- a/example/ruby/TestGemPackageTarHeader.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestGemPackageTarHeader -**Inherits:** Gem::Package::TarTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_big_uid_gid() [](#method-i-test_big_uid_gid) - -## test_empty() [](#method-i-test_empty) - -## test_empty_eh() [](#method-i-test_empty_eh) - -## test_equals2() [](#method-i-test_equals2) - -## test_from_bad_octal() [](#method-i-test_from_bad_octal) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_bad() [](#method-i-test_initialize_bad) - -## test_initialize_typeflag() [](#method-i-test_initialize_typeflag) - -## test_self_from() [](#method-i-test_self_from) - -## test_spaces_in_headers() [](#method-i-test_spaces_in_headers) - -## test_to_s() [](#method-i-test_to_s) - -## test_update_checksum() [](#method-i-test_update_checksum) - diff --git a/example/ruby/TestGemPackageTarReader.md b/example/ruby/TestGemPackageTarReader.md deleted file mode 100644 index 81b4b58..0000000 --- a/example/ruby/TestGemPackageTarReader.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestGemPackageTarReader -**Inherits:** Gem::Package::TarTestCase - - - - - -#Instance Methods -## test_each_entry() [](#method-i-test_each_entry) - -## test_each_with_not_a_tar() [](#method-i-test_each_with_not_a_tar) - -## test_read_in_gem_data() [](#method-i-test_read_in_gem_data) - -## test_rewind() [](#method-i-test_rewind) - -## test_seek() [](#method-i-test_seek) - -## test_seek_in_gem_data() [](#method-i-test_seek_in_gem_data) - -## test_seek_missing() [](#method-i-test_seek_missing) - diff --git a/example/ruby/TestGemPackageTarReaderEntry.md b/example/ruby/TestGemPackageTarReaderEntry.md deleted file mode 100644 index b7d0c6b..0000000 --- a/example/ruby/TestGemPackageTarReaderEntry.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: TestGemPackageTarReaderEntry -**Inherits:** Gem::Package::TarTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_bytes_read() [](#method-i-test_bytes_read) - -## test_close() [](#method-i-test_close) - -## test_closed_eh() [](#method-i-test_closed_eh) - -## test_consecutive_read() [](#method-i-test_consecutive_read) - -## test_consecutive_read_bytes_past_eof() [](#method-i-test_consecutive_read_bytes_past_eof) - -## test_directory_eh() [](#method-i-test_directory_eh) - -## test_eof_eh() [](#method-i-test_eof_eh) - -## test_file_eh() [](#method-i-test_file_eh) - -## test_full_name() [](#method-i-test_full_name) - -## test_full_name_null() [](#method-i-test_full_name_null) - -## test_getc() [](#method-i-test_getc) - -## test_open() [](#method-i-test_open) - -## test_open_closes_entry() [](#method-i-test_open_closes_entry) - -## test_open_returns_entry() [](#method-i-test_open_returns_entry) - -## test_pos() [](#method-i-test_pos) - -## test_read() [](#method-i-test_read) - -## test_read_big() [](#method-i-test_read_big) - -## test_read_corrupted_tar() [](#method-i-test_read_corrupted_tar) - -## test_read_from_gzip_io() [](#method-i-test_read_from_gzip_io) - -## test_read_from_gzip_io_with_non_zero_offset() [](#method-i-test_read_from_gzip_io_with_non_zero_offset) - -## test_read_partial_buffer() [](#method-i-test_read_partial_buffer) - -## test_read_remaining() [](#method-i-test_read_remaining) - -## test_read_small() [](#method-i-test_read_small) - -## test_read_zero() [](#method-i-test_read_zero) - -## test_readpartial() [](#method-i-test_readpartial) - -## test_readpartial_corrupted_tar() [](#method-i-test_readpartial_corrupted_tar) - -## test_readpartial_past_eof() [](#method-i-test_readpartial_past_eof) - -## test_readpartial_to_eof() [](#method-i-test_readpartial_to_eof) - -## test_readpartial_zero() [](#method-i-test_readpartial_zero) - -## test_rewind() [](#method-i-test_rewind) - -## test_seek() [](#method-i-test_seek) - -## test_seek_in_gzip_io_corrupted() [](#method-i-test_seek_in_gzip_io_corrupted) - -## test_seek_in_gzip_io_with_non_zero_offset() [](#method-i-test_seek_in_gzip_io_with_non_zero_offset) - -## test_size() [](#method-i-test_size) - -## test_symlink_eh() [](#method-i-test_symlink_eh) - -## test_zero_byte_file_read() [](#method-i-test_zero_byte_file_read) - -## test_zero_byte_file_readpartial() [](#method-i-test_zero_byte_file_readpartial) - diff --git a/example/ruby/TestGemPackageTarWriter.md b/example/ruby/TestGemPackageTarWriter.md deleted file mode 100644 index 43af8dd..0000000 --- a/example/ruby/TestGemPackageTarWriter.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: TestGemPackageTarWriter -**Inherits:** Gem::Package::TarTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_add_file() [](#method-i-test_add_file) - -## test_add_file_digest() [](#method-i-test_add_file_digest) - -## test_add_file_digest_multiple() [](#method-i-test_add_file_digest_multiple) - -## test_add_file_signer() [](#method-i-test_add_file_signer) - -## test_add_file_signer_empty() [](#method-i-test_add_file_signer_empty) - -## test_add_file_simple() [](#method-i-test_add_file_simple) - -## test_add_file_simple_data() [](#method-i-test_add_file_simple_data) - -## test_add_file_simple_padding() [](#method-i-test_add_file_simple_padding) - -## test_add_file_simple_size() [](#method-i-test_add_file_simple_size) - -## test_add_file_simple_source_date_epoch() [](#method-i-test_add_file_simple_source_date_epoch) - -## test_add_file_source_date_epoch() [](#method-i-test_add_file_source_date_epoch) - -## test_add_symlink() [](#method-i-test_add_symlink) - -## test_add_symlink_source_date_epoch() [](#method-i-test_add_symlink_source_date_epoch) - -## test_close() [](#method-i-test_close) - -## test_mkdir() [](#method-i-test_mkdir) - -## test_mkdir_source_date_epoch() [](#method-i-test_mkdir_source_date_epoch) - -## test_split_name() [](#method-i-test_split_name) - -## test_split_name_too_long_name() [](#method-i-test_split_name_too_long_name) - -## test_split_name_too_long_prefix() [](#method-i-test_split_name_too_long_prefix) - -## test_split_name_too_long_total() [](#method-i-test_split_name_too_long_total) - diff --git a/example/ruby/TestGemPackageTask.md b/example/ruby/TestGemPackageTask.md deleted file mode 100644 index 9b91199..0000000 --- a/example/ruby/TestGemPackageTask.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestGemPackageTask -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_gem_package() [](#method-i-test_gem_package) - -## test_gem_package_prints_to_stdout_by_default() [](#method-i-test_gem_package_prints_to_stdout_by_default) - -## test_gem_package_with_current_platform() [](#method-i-test_gem_package_with_current_platform) - -## test_gem_package_with_ruby_platform() [](#method-i-test_gem_package_with_ruby_platform) - -## test_package_dir_path() [](#method-i-test_package_dir_path) - diff --git a/example/ruby/TestGemPathSupport.md b/example/ruby/TestGemPathSupport.md deleted file mode 100644 index 087768a..0000000 --- a/example/ruby/TestGemPathSupport.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestGemPathSupport -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_gem_paths_do_not_contain_symlinks() [](#method-i-test_gem_paths_do_not_contain_symlinks) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_home() [](#method-i-test_initialize_home) - -## test_initialize_home_normalize() [](#method-i-test_initialize_home_normalize) - -## test_initialize_home_path() [](#method-i-test_initialize_home_path) - -## test_initialize_path() [](#method-i-test_initialize_path) - -## test_initialize_path_with_defaults() [](#method-i-test_initialize_path_with_defaults) - -## test_initialize_regexp_path_separator() [](#method-i-test_initialize_regexp_path_separator) - -## test_initialize_spec() [](#method-i-test_initialize_spec) - diff --git a/example/ruby/TestGemPlatform.md b/example/ruby/TestGemPlatform.md deleted file mode 100644 index d3b7566..0000000 --- a/example/ruby/TestGemPlatform.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: TestGemPlatform -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## assert_local_match(name) [](#method-i-assert_local_match) - -## refute_local_match(name) [](#method-i-refute_local_match) - -## test_eabi_and_nil_version_combination_strictness() [](#method-i-test_eabi_and_nil_version_combination_strictness) - -## test_eabi_version_is_stricter_for_linux_os() [](#method-i-test_eabi_version_is_stricter_for_linux_os) - -## test_equals2() [](#method-i-test_equals2) - -## test_equals3() [](#method-i-test_equals3) - -## test_equals3_cpu() [](#method-i-test_equals3_cpu) - -## test_equals3_cpu_arm() [](#method-i-test_equals3_cpu_arm) - -## test_equals3_universal_mingw() [](#method-i-test_equals3_universal_mingw) - -## test_equals3_version() [](#method-i-test_equals3_version) - -## test_equals_tilde() [](#method-i-test_equals_tilde) - -## test_gem_platform_match_with_string_argument() [](#method-i-test_gem_platform_match_with_string_argument) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_command_line() [](#method-i-test_initialize_command_line) - -## test_initialize_mswin32_vc6() [](#method-i-test_initialize_mswin32_vc6) - -## test_initialize_platform() [](#method-i-test_initialize_platform) - -## test_initialize_test() [](#method-i-test_initialize_test) - -## test_inspect() [](#method-i-test_inspect) - -## test_nil_cpu_arch_is_treated_as_universal() [](#method-i-test_nil_cpu_arch_is_treated_as_universal) - -## test_nil_version_is_stricter_for_linux_os() [](#method-i-test_nil_version_is_stricter_for_linux_os) - -## test_nil_version_is_treated_as_any_version() [](#method-i-test_nil_version_is_treated_as_any_version) - -## test_self_local() [](#method-i-test_self_local) - -## test_self_match() [](#method-i-test_self_match) - -## test_self_match_gem?() [](#method-i-test_self_match_gem?) - -**@return** [Boolean] - -## test_self_match_spec?() [](#method-i-test_self_match_spec?) - -**@return** [Boolean] - -## test_self_match_spec_with_match_gem_override() [](#method-i-test_self_match_spec_with_match_gem_override) - -## test_self_new() [](#method-i-test_self_new) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestGemProjectSanity.md b/example/ruby/TestGemProjectSanity.md deleted file mode 100644 index 1f5cefe..0000000 --- a/example/ruby/TestGemProjectSanity.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemProjectSanity -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_manifest_is_up_to_date() [](#method-i-test_manifest_is_up_to_date) - -## test_require_rubygems_package() [](#method-i-test_require_rubygems_package) - diff --git a/example/ruby/TestGemRDoc.md b/example/ruby/TestGemRDoc.md deleted file mode 100644 index 0e58fdd..0000000 --- a/example/ruby/TestGemRDoc.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestGemRDoc -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_delete_legacy_args() [](#method-i-test_delete_legacy_args) - -## test_generate_disabled() [](#method-i-test_generate_disabled) - -## test_initialize() [](#method-i-test_initialize) - -## test_new_rdoc() [](#method-i-test_new_rdoc) - -## test_rdoc_installed?() [](#method-i-test_rdoc_installed?) - -**@return** [Boolean] - -## test_remove() [](#method-i-test_remove) - -## test_remove_unwritable() [](#method-i-test_remove_unwritable) - -## test_ri_installed?() [](#method-i-test_ri_installed?) - -**@return** [Boolean] - -## test_setup() [](#method-i-test_setup) - -## test_setup_unwritable() [](#method-i-test_setup_unwritable) - diff --git a/example/ruby/TestGemRemoteFetchError.md b/example/ruby/TestGemRemoteFetchError.md deleted file mode 100644 index da4d887..0000000 --- a/example/ruby/TestGemRemoteFetchError.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemRemoteFetchError -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_invalid_url() [](#method-i-test_invalid_url) - -## test_password_redacted() [](#method-i-test_password_redacted) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestGemRemoteFetcher.md b/example/ruby/TestGemRemoteFetcher.md deleted file mode 100644 index 68d2911..0000000 --- a/example/ruby/TestGemRemoteFetcher.md +++ /dev/null @@ -1,118 +0,0 @@ -# Class: TestGemRemoteFetcher -**Inherits:** Gem::TestCase - -**Includes:** Gem::DefaultUserInteraction - - - - -# Class Methods -## fetch_path(uri , mtime nil, head false) [](#method-c-fetch_path) - -#Instance Methods -## assert_error(exception_classException) [](#method-i-assert_error) - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## setup() [](#method-i-setup) - -## test_cache_update_path() [](#method-i-test_cache_update_path) - -## test_cache_update_path_no_update() [](#method-i-test_cache_update_path_no_update) - -## test_cache_update_path_with_utf8_internal_encoding() [](#method-i-test_cache_update_path_with_utf8_internal_encoding) - -## test_download() [](#method-i-test_download) - -## test_download_cached() [](#method-i-test_download_cached) - -## test_download_install_dir() [](#method-i-test_download_install_dir) - -## test_download_local() [](#method-i-test_download_local) - -## test_download_local_read_only() [](#method-i-test_download_local_read_only) - -## test_download_local_space() [](#method-i-test_download_local_space) - -## test_download_platform_legacy() [](#method-i-test_download_platform_legacy) - -## test_download_read_only() [](#method-i-test_download_read_only) - -## test_download_same_file() [](#method-i-test_download_same_file) - -## test_download_to_cache() [](#method-i-test_download_to_cache) - -## test_download_unsupported() [](#method-i-test_download_unsupported) - -## test_download_with_auth() [](#method-i-test_download_with_auth) - -## test_download_with_encoded_auth() [](#method-i-test_download_with_encoded_auth) - -## test_download_with_token() [](#method-i-test_download_with_token) - -## test_download_with_x_oauth_basic() [](#method-i-test_download_with_x_oauth_basic) - -## test_fetch_http() [](#method-i-test_fetch_http) - -## test_fetch_http_redirects() [](#method-i-test_fetch_http_redirects) - -## test_fetch_http_redirects_without_location() [](#method-i-test_fetch_http_redirects_without_location) - -## test_fetch_path_bad_uri() [](#method-i-test_fetch_path_bad_uri) - -## test_fetch_path_getaddrinfo_error() [](#method-i-test_fetch_path_getaddrinfo_error) - -## test_fetch_path_gzip() [](#method-i-test_fetch_path_gzip) - -## test_fetch_path_gzip_unmodified() [](#method-i-test_fetch_path_gzip_unmodified) - -## test_fetch_path_io_error() [](#method-i-test_fetch_path_io_error) - -## test_fetch_path_openssl_ssl_sslerror() [](#method-i-test_fetch_path_openssl_ssl_sslerror) - -## test_fetch_path_socket_error() [](#method-i-test_fetch_path_socket_error) - -## test_fetch_path_system_call_error() [](#method-i-test_fetch_path_system_call_error) - -## test_fetch_path_timeout_error() [](#method-i-test_fetch_path_timeout_error) - -## test_fetch_path_unmodified() [](#method-i-test_fetch_path_unmodified) - -## test_request_block() [](#method-i-test_request_block) - -## test_self_fetcher() [](#method-i-test_self_fetcher) - -## test_self_fetcher_with_proxy() [](#method-i-test_self_fetcher_with_proxy) - -## test_yaml_error_on_size() [](#method-i-test_yaml_error_on_size) - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - -## util_fuck_with_fetcher(data, blowfalse) [](#method-i-util_fuck_with_fetcher) - diff --git a/example/ruby/TestGemRemoteFetcherLocalSSLServer.md b/example/ruby/TestGemRemoteFetcherLocalSSLServer.md deleted file mode 100644 index 7b6899a..0000000 --- a/example/ruby/TestGemRemoteFetcherLocalSSLServer.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: TestGemRemoteFetcherLocalSSLServer -**Inherits:** Gem::TestCase - -**Includes:** Gem::DefaultUserInteraction - - - - - -#Instance Methods -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_do_not_allow_insecure_ssl_connection_by_default() [](#method-i-test_do_not_allow_insecure_ssl_connection_by_default) - -## test_do_not_allow_invalid_client_cert_auth_connection() [](#method-i-test_do_not_allow_invalid_client_cert_auth_connection) - -## test_do_not_follow_insecure_redirect() [](#method-i-test_do_not_follow_insecure_redirect) - -## test_nil_ca_cert() [](#method-i-test_nil_ca_cert) - -## test_ssl_client_cert_auth_connection() [](#method-i-test_ssl_client_cert_auth_connection) - -## test_ssl_connection() [](#method-i-test_ssl_connection) - -## test_ssl_connection_allow_verify_none() [](#method-i-test_ssl_connection_allow_verify_none) - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - diff --git a/example/ruby/TestGemRemoteFetcherLocalServer.md b/example/ruby/TestGemRemoteFetcherLocalServer.md deleted file mode 100644 index 0c155da..0000000 --- a/example/ruby/TestGemRemoteFetcherLocalServer.md +++ /dev/null @@ -1,72 +0,0 @@ -# Class: TestGemRemoteFetcherLocalServer -**Inherits:** Gem::TestCase - -**Includes:** Gem::DefaultUserInteraction - - -# Testing Proxy Settings - -These tests check the proper proxy server settings by running two web servers. - The web server at http://localhost:#{SERVER_PORT} represents the normal gem -server and returns a gemspec with a rake version of 0.4.11. The web server at -http://localhost:#{PROXY_PORT} represents the proxy server and returns a -different dataset where rake has version 0.4.2. This allows us to detect -which server is returning the data. - -Note that the proxy server is not a **real** proxy server. But our software -doesn't really care, as long as we hit the proxy URL when a proxy is -configured. - - - -#Instance Methods -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_fetch_http_with_additional_headers() [](#method-i-test_fetch_http_with_additional_headers) - -## test_implicit_no_proxy() [](#method-i-test_implicit_no_proxy) - -## test_implicit_proxy() [](#method-i-test_implicit_proxy) - -## test_implicit_proxy_no_env() [](#method-i-test_implicit_proxy_no_env) - -## test_implicit_upper_case_proxy() [](#method-i-test_implicit_upper_case_proxy) - -## test_no_proxy() [](#method-i-test_no_proxy) - -## test_observe_no_proxy_env_list() [](#method-i-test_observe_no_proxy_env_list) - -## test_observe_no_proxy_env_single_host() [](#method-i-test_observe_no_proxy_env_single_host) - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - diff --git a/example/ruby/TestGemRemoteFetcherS3.md b/example/ruby/TestGemRemoteFetcherS3.md deleted file mode 100644 index f43bd79..0000000 --- a/example/ruby/TestGemRemoteFetcherS3.md +++ /dev/null @@ -1,74 +0,0 @@ -# Class: TestGemRemoteFetcherS3 -**Inherits:** Gem::TestCase - -**Includes:** Gem::DefaultUserInteraction - - - - - -#Instance Methods -## assert_fetch_s3(url, signature, tokennil, region"us-east-1", instance_profile_jsonnil) [](#method-i-assert_fetch_s3) - -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## refute_fetch_s3(url, expected_message) [](#method-i-refute_fetch_s3) - -## setup() [](#method-i-setup) - -## test_fetch_s3_config_creds() [](#method-i-test_fetch_s3_config_creds) - -## test_fetch_s3_config_creds_with_region() [](#method-i-test_fetch_s3_config_creds_with_region) - -## test_fetch_s3_config_creds_with_token() [](#method-i-test_fetch_s3_config_creds_with_token) - -## test_fetch_s3_env_creds() [](#method-i-test_fetch_s3_env_creds) - -## test_fetch_s3_env_creds_with_region() [](#method-i-test_fetch_s3_env_creds_with_region) - -## test_fetch_s3_env_creds_with_token() [](#method-i-test_fetch_s3_env_creds_with_token) - -## test_fetch_s3_instance_profile_creds() [](#method-i-test_fetch_s3_instance_profile_creds) - -## test_fetch_s3_instance_profile_creds_with_region() [](#method-i-test_fetch_s3_instance_profile_creds_with_region) - -## test_fetch_s3_instance_profile_creds_with_token() [](#method-i-test_fetch_s3_instance_profile_creds_with_token) - -## test_fetch_s3_no_host() [](#method-i-test_fetch_s3_no_host) - -## test_fetch_s3_no_id() [](#method-i-test_fetch_s3_no_id) - -## test_fetch_s3_no_secret() [](#method-i-test_fetch_s3_no_secret) - -## test_fetch_s3_no_source_key() [](#method-i-test_fetch_s3_no_source_key) - -## test_fetch_s3_url_creds() [](#method-i-test_fetch_s3_url_creds) - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - -## ui() [](#method-i-ui) -See DefaultUserInteraction::ui - -## ui=(new_ui) [](#method-i-ui=) -See DefaultUserInteraction::ui= - -## use_ui(new_ui, &block) [](#method-i-use_ui) -See DefaultUserInteraction::use_ui - diff --git a/example/ruby/TestGemRequest.md b/example/ruby/TestGemRequest.md deleted file mode 100644 index 711b4a5..0000000 --- a/example/ruby/TestGemRequest.md +++ /dev/null @@ -1,96 +0,0 @@ -# Class: TestGemRequest -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## base64_encode64(bin) [](#method-i-base64_encode64) -This method is same code as Base64.encode64 We should not use Base64.encode64 -because we need to avoid gem activation. - -## make_request(uri, request_class, last_modified, proxy) [](#method-i-make_request) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_configure_connection_for_https() [](#method-i-test_configure_connection_for_https) - -## test_configure_connection_for_https_ssl_ca_cert() [](#method-i-test_configure_connection_for_https_ssl_ca_cert) - -## test_fetch() [](#method-i-test_fetch) - -## test_fetch_basic_auth() [](#method-i-test_fetch_basic_auth) - -## test_fetch_basic_auth_encoded() [](#method-i-test_fetch_basic_auth_encoded) - -## test_fetch_basic_oauth_encoded() [](#method-i-test_fetch_basic_oauth_encoded) - -## test_fetch_head() [](#method-i-test_fetch_head) - -## test_fetch_unmodified() [](#method-i-test_fetch_unmodified) - -## test_get_proxy_from_env_domain() [](#method-i-test_get_proxy_from_env_domain) - -## test_get_proxy_from_env_empty() [](#method-i-test_get_proxy_from_env_empty) - -## test_get_proxy_from_env_escape() [](#method-i-test_get_proxy_from_env_escape) - -## test_get_proxy_from_env_fallback() [](#method-i-test_get_proxy_from_env_fallback) - -## test_get_proxy_from_env_https() [](#method-i-test_get_proxy_from_env_https) - -## test_get_proxy_from_env_normalize() [](#method-i-test_get_proxy_from_env_normalize) - -## test_initialize_proxy() [](#method-i-test_initialize_proxy) - -## test_initialize_proxy_ENV() [](#method-i-test_initialize_proxy_ENV) - -## test_initialize_proxy_ENV_https() [](#method-i-test_initialize_proxy_ENV_https) - -## test_initialize_proxy_URI() [](#method-i-test_initialize_proxy_URI) - -## test_proxy_ENV() [](#method-i-test_proxy_ENV) - -## test_user_agent() [](#method-i-test_user_agent) - -## test_user_agent_engine() [](#method-i-test_user_agent_engine) - -## test_user_agent_engine_ruby() [](#method-i-test_user_agent_engine_ruby) - -## test_user_agent_patchlevel() [](#method-i-test_user_agent_patchlevel) - -## test_user_agent_revision() [](#method-i-test_user_agent_revision) - -## test_verify_certificate() [](#method-i-test_verify_certificate) - -## test_verify_certificate_extra_message() [](#method-i-test_verify_certificate_extra_message) - -## test_verify_certificate_message_CERT_HAS_EXPIRED() [](#method-i-test_verify_certificate_message_CERT_HAS_EXPIRED) - -## test_verify_certificate_message_CERT_NOT_YET_VALID() [](#method-i-test_verify_certificate_message_CERT_NOT_YET_VALID) - -## test_verify_certificate_message_CERT_REJECTED() [](#method-i-test_verify_certificate_message_CERT_REJECTED) - -## test_verify_certificate_message_CERT_UNTRUSTED() [](#method-i-test_verify_certificate_message_CERT_UNTRUSTED) - -## test_verify_certificate_message_DEPTH_ZERO_SELF_SIGNED_CERT() [](#method-i-test_verify_certificate_message_DEPTH_ZERO_SELF_SIGNED_CERT) - -## test_verify_certificate_message_INVALID_CA() [](#method-i-test_verify_certificate_message_INVALID_CA) - -## test_verify_certificate_message_INVALID_PURPOSE() [](#method-i-test_verify_certificate_message_INVALID_PURPOSE) - -## test_verify_certificate_message_SELF_SIGNED_CERT_IN_CHAIN() [](#method-i-test_verify_certificate_message_SELF_SIGNED_CERT_IN_CHAIN) - -## test_verify_certificate_message_UNABLE_TO_GET_ISSUER_CERT_LOCALLY() [](#method-i-test_verify_certificate_message_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) - -## test_verify_certificate_message_UNABLE_TO_VERIFY_LEAF_SIGNATURE() [](#method-i-test_verify_certificate_message_UNABLE_TO_VERIFY_LEAF_SIGNATURE) - -## util_restore_version() [](#method-i-util_restore_version) - -## util_save_version() [](#method-i-util_save_version) - -## util_stub_net_http(hash) [](#method-i-util_stub_net_http) - diff --git a/example/ruby/TestGemRequest/Conn.md b/example/ruby/TestGemRequest/Conn.md deleted file mode 100644 index ec353e7..0000000 --- a/example/ruby/TestGemRequest/Conn.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestGemRequest::Conn -**Inherits:** Object - - - - -# Attributes -## payload[RW] [](#attribute-i-payload) -Returns the value of attribute payload. - - -#Instance Methods -## cert_store=(setting) [](#method-i-cert_store=) - -## initialize(response) [](#method-i-initialize) - -**@return** [Conn] a new instance of Conn - -## new(*args) [](#method-i-new) - -## request(req) [](#method-i-request) - -## start() [](#method-i-start) - -## use_ssl=(bool) [](#method-i-use_ssl=) - -## verify_callback=(setting) [](#method-i-verify_callback=) - -## verify_mode=(setting) [](#method-i-verify_mode=) - diff --git a/example/ruby/TestGemRequestConnectionPool.md b/example/ruby/TestGemRequestConnectionPool.md deleted file mode 100644 index cc901fe..0000000 --- a/example/ruby/TestGemRequestConnectionPool.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestGemRequestConnectionPool -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_checkout_same_connection() [](#method-i-test_checkout_same_connection) - -## test_net_http_args() [](#method-i-test_net_http_args) - -## test_net_http_args_ipv6() [](#method-i-test_net_http_args_ipv6) - -## test_net_http_args_no_proxy() [](#method-i-test_net_http_args_no_proxy) - -## test_net_http_args_proxy() [](#method-i-test_net_http_args_proxy) - -## test_thread_waits_for_connection() [](#method-i-test_thread_waits_for_connection) - -## test_to_proxy_eh() [](#method-i-test_to_proxy_eh) - -## test_to_proxy_eh_wildcard() [](#method-i-test_to_proxy_eh_wildcard) - -## test_to_proxy_empty_string() [](#method-i-test_to_proxy_empty_string) - -## test_to_proxy_substring() [](#method-i-test_to_proxy_substring) - diff --git a/example/ruby/TestGemRequestConnectionPool/FakeHttp.md b/example/ruby/TestGemRequestConnectionPool/FakeHttp.md deleted file mode 100644 index 3fc920a..0000000 --- a/example/ruby/TestGemRequestConnectionPool/FakeHttp.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemRequestConnectionPool::FakeHttp -**Inherits:** Object - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [FakeHttp] a new instance of FakeHttp - -## start() [](#method-i-start) - diff --git a/example/ruby/TestGemRequestSet.md b/example/ruby/TestGemRequestSet.md deleted file mode 100644 index d477a45..0000000 --- a/example/ruby/TestGemRequestSet.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: TestGemRequestSet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_bug_bug_990() [](#method-i-test_bug_bug_990) - -## test_gem() [](#method-i-test_gem) - -## test_gem_duplicate() [](#method-i-test_gem_duplicate) - -## test_import() [](#method-i-test_import) - -## test_install() [](#method-i-test_install) - -## test_install_from_gemdeps() [](#method-i-test_install_from_gemdeps) - -## test_install_from_gemdeps_complex_dependencies() [](#method-i-test_install_from_gemdeps_complex_dependencies) - -## test_install_from_gemdeps_explain() [](#method-i-test_install_from_gemdeps_explain) - -## test_install_from_gemdeps_install_dir() [](#method-i-test_install_from_gemdeps_install_dir) - -## test_install_from_gemdeps_local() [](#method-i-test_install_from_gemdeps_local) - -## test_install_from_gemdeps_lockfile() [](#method-i-test_install_from_gemdeps_lockfile) - -## test_install_from_gemdeps_version_mismatch() [](#method-i-test_install_from_gemdeps_version_mismatch) - -## test_install_into() [](#method-i-test_install_into) - -## test_install_into_development_shallow() [](#method-i-test_install_into_development_shallow) - -## test_load_gemdeps() [](#method-i-test_load_gemdeps) - -## test_load_gemdeps_installing() [](#method-i-test_load_gemdeps_installing) - -## test_load_gemdeps_without_groups() [](#method-i-test_load_gemdeps_without_groups) - -## test_resolve() [](#method-i-test_resolve) - -## test_resolve_development() [](#method-i-test_resolve_development) - -## test_resolve_development_shallow() [](#method-i-test_resolve_development_shallow) - -## test_resolve_git() [](#method-i-test_resolve_git) - -## test_resolve_ignore_dependencies() [](#method-i-test_resolve_ignore_dependencies) - -## test_resolve_incompatible() [](#method-i-test_resolve_incompatible) - -## test_resolve_vendor() [](#method-i-test_resolve_vendor) - -## test_sorted_requests() [](#method-i-test_sorted_requests) - -## test_sorted_requests_development_shallow() [](#method-i-test_sorted_requests_development_shallow) - -## test_tsort_each_child_development() [](#method-i-test_tsort_each_child_development) - -## test_tsort_each_child_development_shallow() [](#method-i-test_tsort_each_child_development_shallow) - diff --git a/example/ruby/TestGemRequestSetGemDependencyAPI.md b/example/ruby/TestGemRequestSetGemDependencyAPI.md deleted file mode 100644 index a0ae7fb..0000000 --- a/example/ruby/TestGemRequestSetGemDependencyAPI.md +++ /dev/null @@ -1,136 +0,0 @@ -# Class: TestGemRequestSetGemDependencyAPI -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_gem() [](#method-i-test_gem) - -## test_gem_bitbucket() [](#method-i-test_gem_bitbucket) - -## test_gem_bitbucket_expand_path() [](#method-i-test_gem_bitbucket_expand_path) - -## test_gem_deps_file() [](#method-i-test_gem_deps_file) - -## test_gem_duplicate() [](#method-i-test_gem_duplicate) - -## test_gem_git() [](#method-i-test_gem_git) - -## test_gem_git_branch() [](#method-i-test_gem_git_branch) - -## test_gem_git_gist() [](#method-i-test_gem_git_gist) - -## test_gem_git_ref() [](#method-i-test_gem_git_ref) - -## test_gem_git_submodules() [](#method-i-test_gem_git_submodules) - -## test_gem_git_tag() [](#method-i-test_gem_git_tag) - -## test_gem_github() [](#method-i-test_gem_github) - -## test_gem_github_expand_path() [](#method-i-test_gem_github_expand_path) - -## test_gem_group() [](#method-i-test_gem_group) - -## test_gem_group_method() [](#method-i-test_gem_group_method) - -## test_gem_group_without() [](#method-i-test_gem_group_without) - -## test_gem_groups() [](#method-i-test_gem_groups) - -## test_gem_path() [](#method-i-test_gem_path) - -## test_gem_platforms() [](#method-i-test_gem_platforms) - -## test_gem_platforms_bundler_ruby() [](#method-i-test_gem_platforms_bundler_ruby) - -## test_gem_platforms_engine() [](#method-i-test_gem_platforms_engine) - -## test_gem_platforms_maglev() [](#method-i-test_gem_platforms_maglev) - -## test_gem_platforms_multiple() [](#method-i-test_gem_platforms_multiple) - -## test_gem_platforms_platform() [](#method-i-test_gem_platforms_platform) - -## test_gem_platforms_truffleruby() [](#method-i-test_gem_platforms_truffleruby) - -## test_gem_platforms_unknown() [](#method-i-test_gem_platforms_unknown) - -## test_gem_platforms_version() [](#method-i-test_gem_platforms_version) - -## test_gem_requirement() [](#method-i-test_gem_requirement) - -## test_gem_requirements() [](#method-i-test_gem_requirements) - -## test_gem_requirements_options() [](#method-i-test_gem_requirements_options) - -## test_gem_requires() [](#method-i-test_gem_requires) - -## test_gem_requires_false() [](#method-i-test_gem_requires_false) - -## test_gem_requires_without_group() [](#method-i-test_gem_requires_without_group) - -## test_gem_source_mismatch() [](#method-i-test_gem_source_mismatch) - -## test_gempspec_with_multiple_runtime_deps() [](#method-i-test_gempspec_with_multiple_runtime_deps) - -## test_gemspec() [](#method-i-test_gemspec) - -## test_gemspec_bad() [](#method-i-test_gemspec_bad) - -## test_gemspec_development_group() [](#method-i-test_gemspec_development_group) - -## test_gemspec_multiple() [](#method-i-test_gemspec_multiple) - -## test_gemspec_name() [](#method-i-test_gemspec_name) - -## test_gemspec_named() [](#method-i-test_gemspec_named) - -## test_gemspec_none() [](#method-i-test_gemspec_none) - -## test_gemspec_path() [](#method-i-test_gemspec_path) - -## test_gemspec_without_group() [](#method-i-test_gemspec_without_group) - -## test_git() [](#method-i-test_git) - -## test_git_source() [](#method-i-test_git_source) - -## test_group() [](#method-i-test_group) - -## test_load() [](#method-i-test_load) - -## test_pin_gem_source() [](#method-i-test_pin_gem_source) - -## test_platform_mswin() [](#method-i-test_platform_mswin) - -## test_platform_multiple() [](#method-i-test_platform_multiple) - -## test_platform_ruby() [](#method-i-test_platform_ruby) - -## test_platforms() [](#method-i-test_platforms) - -## test_ruby() [](#method-i-test_ruby) - -## test_ruby_engine() [](#method-i-test_ruby_engine) - -## test_ruby_engine_mismatch_engine() [](#method-i-test_ruby_engine_mismatch_engine) - -## test_ruby_engine_mismatch_version() [](#method-i-test_ruby_engine_mismatch_version) - -## test_ruby_engine_no_engine_version() [](#method-i-test_ruby_engine_no_engine_version) - -## test_ruby_mismatch() [](#method-i-test_ruby_mismatch) - -## test_ruby_mismatch_installing() [](#method-i-test_ruby_mismatch_installing) - -## test_source() [](#method-i-test_source) - -## test_with_engine_version() [](#method-i-test_with_engine_version) - -## with_engine_version(name, version) [](#method-i-with_engine_version) - diff --git a/example/ruby/TestGemRequestSetLockfile.md b/example/ruby/TestGemRequestSetLockfile.md deleted file mode 100644 index 83f0aa5..0000000 --- a/example/ruby/TestGemRequestSetLockfile.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestGemRequestSetLockfile -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## lockfile() [](#method-i-lockfile) - -## setup() [](#method-i-setup) - -## test_add_DEPENDENCIES() [](#method-i-test_add_DEPENDENCIES) - -## test_add_DEPENDENCIES_from_gem_deps() [](#method-i-test_add_DEPENDENCIES_from_gem_deps) - -## test_add_GEM() [](#method-i-test_add_GEM) - -## test_add_PLATFORMS() [](#method-i-test_add_PLATFORMS) - -## test_relative_path_from() [](#method-i-test_relative_path_from) - -## test_to_s_gem() [](#method-i-test_to_s_gem) - -## test_to_s_gem_dependency() [](#method-i-test_to_s_gem_dependency) - -## test_to_s_gem_dependency_non_default() [](#method-i-test_to_s_gem_dependency_non_default) - -## test_to_s_gem_dependency_requirement() [](#method-i-test_to_s_gem_dependency_requirement) - -## test_to_s_gem_path() [](#method-i-test_to_s_gem_path) - -## test_to_s_gem_path_absolute() [](#method-i-test_to_s_gem_path_absolute) - -## test_to_s_gem_platform() [](#method-i-test_to_s_gem_platform) - -## test_to_s_gem_source() [](#method-i-test_to_s_gem_source) - -## test_to_s_git() [](#method-i-test_to_s_git) - -## test_write() [](#method-i-test_write) - -## test_write_error() [](#method-i-test_write_error) - -## write_lockfile(lockfile) [](#method-i-write_lockfile) - diff --git a/example/ruby/TestGemRequestSetLockfileParser.md b/example/ruby/TestGemRequestSetLockfileParser.md deleted file mode 100644 index fd5180e..0000000 --- a/example/ruby/TestGemRequestSetLockfileParser.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: TestGemRequestSetLockfileParser -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## parse_lockfile(set, platforms) [](#method-i-parse_lockfile) - -## setup() [](#method-i-setup) - -## test_get() [](#method-i-test_get) - -## test_get_type_mismatch() [](#method-i-test_get_type_mismatch) - -## test_get_type_multiple() [](#method-i-test_get_type_multiple) - -## test_get_type_value_mismatch() [](#method-i-test_get_type_value_mismatch) - -## test_parse() [](#method-i-test_parse) - -## test_parse_DEPENDENCIES_git() [](#method-i-test_parse_DEPENDENCIES_git) - -## test_parse_DEPENDENCIES_git_version() [](#method-i-test_parse_DEPENDENCIES_git_version) - -## test_parse_GEM() [](#method-i-test_parse_GEM) - -## test_parse_GEM_remote_multiple() [](#method-i-test_parse_GEM_remote_multiple) - -## test_parse_GIT() [](#method-i-test_parse_GIT) - -## test_parse_GIT_branch() [](#method-i-test_parse_GIT_branch) - -## test_parse_GIT_ref() [](#method-i-test_parse_GIT_ref) - -## test_parse_GIT_tag() [](#method-i-test_parse_GIT_tag) - -## test_parse_PATH() [](#method-i-test_parse_PATH) - -## test_parse_dependencies() [](#method-i-test_parse_dependencies) - -## test_parse_dependency() [](#method-i-test_parse_dependency) - -## test_parse_gem_specs_dependency() [](#method-i-test_parse_gem_specs_dependency) - -## test_parse_missing() [](#method-i-test_parse_missing) - -## write_lockfile(lockfile) [](#method-i-write_lockfile) - diff --git a/example/ruby/TestGemRequestSetLockfileTokenizer.md b/example/ruby/TestGemRequestSetLockfileTokenizer.md deleted file mode 100644 index 0639a00..0000000 --- a/example/ruby/TestGemRequestSetLockfileTokenizer.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestGemRequestSetLockfileTokenizer -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_peek() [](#method-i-test_peek) - -## test_skip() [](#method-i-test_skip) - -## test_token_pos() [](#method-i-test_token_pos) - -## test_tokenize() [](#method-i-test_tokenize) - -## test_tokenize_capitals() [](#method-i-test_tokenize_capitals) - -## test_tokenize_conflict_markers() [](#method-i-test_tokenize_conflict_markers) - -## test_tokenize_git() [](#method-i-test_tokenize_git) - -## test_tokenize_multiple() [](#method-i-test_tokenize_multiple) - -## test_unget() [](#method-i-test_unget) - -## tokenize_lockfile() [](#method-i-tokenize_lockfile) - -## write_lockfile(lockfile) [](#method-i-write_lockfile) - diff --git a/example/ruby/TestGemRequire.md b/example/ruby/TestGemRequire.md deleted file mode 100644 index 6926b41..0000000 --- a/example/ruby/TestGemRequire.md +++ /dev/null @@ -1,92 +0,0 @@ -# Class: TestGemRequire -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## assert_require(path) [](#method-i-assert_require) - -## create_sync_thread() [](#method-i-create_sync_thread) - -## loaded_spec_names() [](#method-i-loaded_spec_names) - -## refute_require(path) [](#method-i-refute_require) - -## test_activate_via_require_respects_loaded_default_from_default_gems() [](#method-i-test_activate_via_require_respects_loaded_default_from_default_gems) - -## test_activate_via_require_respects_loaded_files() [](#method-i-test_activate_via_require_respects_loaded_files) - -## test_already_activated_direct_conflict() [](#method-i-test_already_activated_direct_conflict) - -## test_concurrent_require() [](#method-i-test_concurrent_require) - -## test_dash_i_beats_default_gems() [](#method-i-test_dash_i_beats_default_gems) -Providing -I on the commandline should always beat gems - -## test_dash_i_beats_gems() [](#method-i-test_dash_i_beats_gems) -Providing -I on the commandline should always beat gems - -## test_dash_i_respects_default_library_extension_priority() [](#method-i-test_dash_i_respects_default_library_extension_priority) - -## test_default_gem_and_normal_gem() [](#method-i-test_default_gem_and_normal_gem) - -## test_default_gem_and_normal_gem_same_version() [](#method-i-test_default_gem_and_normal_gem_same_version) - -## test_default_gem_only() [](#method-i-test_default_gem_only) - -## test_default_gem_prerelease() [](#method-i-test_default_gem_prerelease) - -## test_default_gem_require_activates_just_once() [](#method-i-test_default_gem_require_activates_just_once) - -## test_default_gem_required_circulary_with_unresolved_gems_depending_on_it() [](#method-i-test_default_gem_required_circulary_with_unresolved_gems_depending_on_it) - -## test_default_gem_with_unresolved_gems_depending_on_it() [](#method-i-test_default_gem_with_unresolved_gems_depending_on_it) - -## test_expected_backtrace_location_when_inheriting_from_basic_object_and_including_kernel() [](#method-i-test_expected_backtrace_location_when_inheriting_from_basic_object_and_including_kernel) - -## test_multiple_gems_with_the_same_path() [](#method-i-test_multiple_gems_with_the_same_path) - -## test_no_crash_when_overriding_warn_with_warning_module() [](#method-i-test_no_crash_when_overriding_warn_with_warning_module) - -## test_normal_gem_does_not_shadow_default_gem() [](#method-i-test_normal_gem_does_not_shadow_default_gem) - -## test_normal_gems_with_overridden_load_error_message() [](#method-i-test_normal_gems_with_overridden_load_error_message) - -## test_realworld_default_gem() [](#method-i-test_realworld_default_gem) - -## test_realworld_upgraded_default_gem() [](#method-i-test_realworld_upgraded_default_gem) - -## test_require_bundler() [](#method-i-test_require_bundler) - -## test_require_can_use_a_pathname_object() [](#method-i-test_require_can_use_a_pathname_object) - -## test_require_default_when_gem_defined() [](#method-i-test_require_default_when_gem_defined) - -## test_require_does_not_crash_when_utilizing_bundler_version_finder() [](#method-i-test_require_does_not_crash_when_utilizing_bundler_version_finder) - -## test_require_doesnt_traverse_development_dependencies() [](#method-i-test_require_doesnt_traverse_development_dependencies) - -## test_require_is_lazy_with_inexact_req() [](#method-i-test_require_is_lazy_with_inexact_req) - -## test_require_is_not_lazy_with_exact_req() [](#method-i-test_require_is_not_lazy_with_exact_req) - -## test_require_is_not_lazy_with_one_possible() [](#method-i-test_require_is_not_lazy_with_one_possible) - -## test_require_is_not_lazy_with_shadowed_default_gem() [](#method-i-test_require_is_not_lazy_with_shadowed_default_gem) - -## test_require_when_gem_defined() [](#method-i-test_require_when_gem_defined) - -## test_require_works_after_cleanup() [](#method-i-test_require_works_after_cleanup) - -## test_respect_loaded_features_caching_like_standard_require() [](#method-i-test_respect_loaded_features_caching_like_standard_require) - -## test_second_gem_require_does_not_resolve_path_manually_before_going_through_standard_require() [](#method-i-test_second_gem_require_does_not_resolve_path_manually_before_going_through_standard_require) - -## test_try_activate_error_unlocks_require_monitor() [](#method-i-test_try_activate_error_unlocks_require_monitor) - -## test_unable_to_find_good_unresolved_version() [](#method-i-test_unable_to_find_good_unresolved_version) - -## unresolved_names() [](#method-i-unresolved_names) - diff --git a/example/ruby/TestGemRequire/Latch.md b/example/ruby/TestGemRequire/Latch.md deleted file mode 100644 index f6f52a5..0000000 --- a/example/ruby/TestGemRequire/Latch.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemRequire::Latch -**Inherits:** Object - - - - - -#Instance Methods -## await() [](#method-i-await) - -## initialize(count1) [](#method-i-initialize) - -**@return** [Latch] a new instance of Latch - -## release() [](#method-i-release) - diff --git a/example/ruby/TestGemRequirement.md b/example/ruby/TestGemRequirement.md deleted file mode 100644 index 073be23..0000000 --- a/example/ruby/TestGemRequirement.md +++ /dev/null @@ -1,102 +0,0 @@ -# Class: TestGemRequirement -**Inherits:** Gem::TestCase - - - - -# Class Methods -## exploit(arg ) [](#method-c-exploit) -**@raise** [Exploit] - - -#Instance Methods -## assert_requirement_equal(expected, actual) [](#method-i-assert_requirement_equal) -Assert that two requirements are equal. Handles Gem::Requirements, strings, -arrays, numbers, and versions. - -## assert_requirement_hash_equal(expected, actual) [](#method-i-assert_requirement_hash_equal) -Assert that two requirement hashes are equal. Handles Gem::Requirements, -strings, arrays, numbers, and versions. - -## assert_satisfied_by(version, requirement) [](#method-i-assert_satisfied_by) -Assert that `version` satisfies `requirement`. - -## refute_requirement_equal(unexpected, actual) [](#method-i-refute_requirement_equal) -Refute the assumption that two requirements are equal. - -## refute_requirement_hash_equal(unexpected, actual) [](#method-i-refute_requirement_hash_equal) -Refute the assumption that two requirements hashes are equal. - -## refute_satisfied_by(version, requirement) [](#method-i-refute_satisfied_by) -Refute the assumption that `version` satisfies `requirement`. - -## test_bad() [](#method-i-test_bad) - -## test_basic_non_none() [](#method-i-test_basic_non_none) - -## test_concat() [](#method-i-test_concat) - -## test_create() [](#method-i-test_create) - -## test_empty_requirements_is_none() [](#method-i-test_empty_requirements_is_none) - -## test_equals2() [](#method-i-test_equals2) - -## test_explicit_default_is_none() [](#method-i-test_explicit_default_is_none) - -## test_for_lockfile() [](#method-i-test_for_lockfile) - -## test_hash_returns_equal_hashes_for_equivalent_requirements() [](#method-i-test_hash_returns_equal_hashes_for_equivalent_requirements) - -## test_hash_with_multiple_versions() [](#method-i-test_hash_with_multiple_versions) - -## test_illformed_requirements() [](#method-i-test_illformed_requirements) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_copy() [](#method-i-test_initialize_copy) - -## test_marshal_load_attack() [](#method-i-test_marshal_load_attack) - -## test_parse() [](#method-i-test_parse) - -## test_parse_bad() [](#method-i-test_parse_bad) - -## test_parse_deduplication() [](#method-i-test_parse_deduplication) - -## test_prerelease_eh() [](#method-i-test_prerelease_eh) - -## test_satisfied_by_boxed() [](#method-i-test_satisfied_by_boxed) - -## test_satisfied_by_eh_bang_equal() [](#method-i-test_satisfied_by_eh_bang_equal) - -## test_satisfied_by_eh_blank() [](#method-i-test_satisfied_by_eh_blank) - -## test_satisfied_by_eh_boxed() [](#method-i-test_satisfied_by_eh_boxed) - -## test_satisfied_by_eh_equal() [](#method-i-test_satisfied_by_eh_equal) - -## test_satisfied_by_eh_good() [](#method-i-test_satisfied_by_eh_good) - -## test_satisfied_by_eh_gt() [](#method-i-test_satisfied_by_eh_gt) - -## test_satisfied_by_eh_gte() [](#method-i-test_satisfied_by_eh_gte) - -## test_satisfied_by_eh_list() [](#method-i-test_satisfied_by_eh_list) - -## test_satisfied_by_eh_lt() [](#method-i-test_satisfied_by_eh_lt) - -## test_satisfied_by_eh_lte() [](#method-i-test_satisfied_by_eh_lte) - -## test_satisfied_by_eh_multiple() [](#method-i-test_satisfied_by_eh_multiple) - -## test_satisfied_by_eh_non_versions() [](#method-i-test_satisfied_by_eh_non_versions) - -## test_satisfied_by_eh_tilde_gt() [](#method-i-test_satisfied_by_eh_tilde_gt) - -## test_satisfied_by_eh_tilde_gt_v0() [](#method-i-test_satisfied_by_eh_tilde_gt_v0) - -## test_satisfied_by_explicitly_bounded() [](#method-i-test_satisfied_by_explicitly_bounded) - -## test_specific() [](#method-i-test_specific) - diff --git a/example/ruby/TestGemRequirement/Exploit.md b/example/ruby/TestGemRequirement/Exploit.md deleted file mode 100644 index 7cd1749..0000000 --- a/example/ruby/TestGemRequirement/Exploit.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestGemRequirement::Exploit -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/TestGemResolver.md b/example/ruby/TestGemResolver.md deleted file mode 100644 index b531d6c..0000000 --- a/example/ruby/TestGemResolver.md +++ /dev/null @@ -1,99 +0,0 @@ -# Class: TestGemResolver -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## assert_resolves_to(expected, resolver) [](#method-i-assert_resolves_to) - -## make_dep(name, *req) [](#method-i-make_dep) - -## set(*specs) [](#method-i-set) - -## test_backoff_higher_version_to_satisfy_dep() [](#method-i-test_backoff_higher_version_to_satisfy_dep) - -## test_backtracks_to_the_first_conflict() [](#method-i-test_backtracks_to_the_first_conflict) - -## test_common_rack_activation_scenario() [](#method-i-test_common_rack_activation_scenario) - -## test_conflict_resolution_only_effects_correct_spec() [](#method-i-test_conflict_resolution_only_effects_correct_spec) - -## test_does_not_pick_musl_variants_on_non_musl_linux() [](#method-i-test_does_not_pick_musl_variants_on_non_musl_linux) - -## test_keeps_resolving_after_seeing_satisfied_dep() [](#method-i-test_keeps_resolving_after_seeing_satisfied_dep) - -## test_no_overlap_specifically() [](#method-i-test_no_overlap_specifically) - -## test_only_returns_spec_once() [](#method-i-test_only_returns_spec_once) - -## test_pick_generic_linux_variants_on_musl_linux() [](#method-i-test_pick_generic_linux_variants_on_musl_linux) - -## test_picks_best_platform() [](#method-i-test_picks_best_platform) - -## test_picks_highest_version() [](#method-i-test_picks_highest_version) - -## test_picks_lower_version_when_needed() [](#method-i-test_picks_lower_version_when_needed) - -## test_pulls_in_dependencies() [](#method-i-test_pulls_in_dependencies) - -## test_raises_and_explains_when_platform_prevents_install() [](#method-i-test_raises_and_explains_when_platform_prevents_install) - -## test_raises_and_reports_a_toplevel_request_properly() [](#method-i-test_raises_and_reports_a_toplevel_request_properly) - -## test_raises_and_reports_an_implicit_request_properly() [](#method-i-test_raises_and_reports_an_implicit_request_properly) - -## test_raises_dependency_error() [](#method-i-test_raises_dependency_error) - -## test_raises_when_a_gem_is_missing() [](#method-i-test_raises_when_a_gem_is_missing) - -## test_raises_when_a_gem_version_is_missing() [](#method-i-test_raises_when_a_gem_version_is_missing) - -## test_raises_when_possibles_are_exhausted() [](#method-i-test_raises_when_possibles_are_exhausted) - -## test_requests() [](#method-i-test_requests) - -## test_requests_development() [](#method-i-test_requests_development) - -## test_requests_ignore_dependencies() [](#method-i-test_requests_ignore_dependencies) - -## test_resolve_bug_699() [](#method-i-test_resolve_bug_699) - -## test_resolve_conflict() [](#method-i-test_resolve_conflict) - -## test_resolve_conservative() [](#method-i-test_resolve_conservative) - -## test_resolve_development() [](#method-i-test_resolve_development) - -## test_resolve_development_shallow() [](#method-i-test_resolve_development_shallow) - -## test_resolve_remote_missing_dependency() [](#method-i-test_resolve_remote_missing_dependency) - -## test_resolve_rollback() [](#method-i-test_resolve_rollback) - -## test_search_for_local_platform_partial_string_match() [](#method-i-test_search_for_local_platform_partial_string_match) - -## test_second_level_backout() [](#method-i-test_second_level_backout) - -## test_select_local_platforms() [](#method-i-test_select_local_platforms) - -## test_self_compose_sets_best_set() [](#method-i-test_self_compose_sets_best_set) - -## test_self_compose_sets_multiple() [](#method-i-test_self_compose_sets_multiple) - -## test_self_compose_sets_nest() [](#method-i-test_self_compose_sets_nest) - -## test_self_compose_sets_nil() [](#method-i-test_self_compose_sets_nil) - -## test_self_compose_sets_single() [](#method-i-test_self_compose_sets_single) - -## test_simple_activesupport_problem() [](#method-i-test_simple_activesupport_problem) -actionmailer 2.3.4 activemerchant 1.5.0 activesupport 2.3.5, 2.3.4 -Activemerchant needs activesupport >= 2.3.2. When you require activemerchant, -it will activate the latest version that meets that requirement which is -2.3.5. Actionmailer on the other hand needs activesupport = 2.3.4. When -rubygems tries to activate activesupport 2.3.4, it will raise an error. - -## test_sorts_by_source_then_version() [](#method-i-test_sorts_by_source_then_version) - diff --git a/example/ruby/TestGemResolverAPISet.md b/example/ruby/TestGemResolverAPISet.md deleted file mode 100644 index e814ab6..0000000 --- a/example/ruby/TestGemResolverAPISet.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestGemResolverAPISet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_find_all() [](#method-i-test_find_all) - -## test_find_all_cache() [](#method-i-test_find_all_cache) - -## test_find_all_local() [](#method-i-test_find_all_local) - -## test_find_all_missing() [](#method-i-test_find_all_missing) - -## test_find_all_not_found() [](#method-i-test_find_all_not_found) - -## test_find_all_prereleases() [](#method-i-test_find_all_prereleases) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_deeper_uri() [](#method-i-test_initialize_deeper_uri) - -## test_initialize_uri() [](#method-i-test_initialize_uri) - -## test_prefetch() [](#method-i-test_prefetch) - -## test_prefetch_cache() [](#method-i-test_prefetch_cache) - -## test_prefetch_cache_missing() [](#method-i-test_prefetch_cache_missing) - -## test_prefetch_local() [](#method-i-test_prefetch_local) - diff --git a/example/ruby/TestGemResolverAPISpecification.md b/example/ruby/TestGemResolverAPISpecification.md deleted file mode 100644 index 21d6ae2..0000000 --- a/example/ruby/TestGemResolverAPISpecification.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGemResolverAPISpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_fetch_development_dependencies() [](#method-i-test_fetch_development_dependencies) - -## test_initialize() [](#method-i-test_initialize) - -## test_installable_platform_eh() [](#method-i-test_installable_platform_eh) - -## test_source() [](#method-i-test_source) - -## test_spec() [](#method-i-test_spec) - -## test_spec_jruby_platform() [](#method-i-test_spec_jruby_platform) - diff --git a/example/ruby/TestGemResolverActivationRequest.md b/example/ruby/TestGemResolverActivationRequest.md deleted file mode 100644 index fbae10a..0000000 --- a/example/ruby/TestGemResolverActivationRequest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemResolverActivationRequest -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_development_eh() [](#method-i-test_development_eh) - -## test_inspect() [](#method-i-test_inspect) - -## test_installed_eh() [](#method-i-test_installed_eh) - diff --git a/example/ruby/TestGemResolverBestSet.md b/example/ruby/TestGemResolverBestSet.md deleted file mode 100644 index c9dcaf2..0000000 --- a/example/ruby/TestGemResolverBestSet.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestGemResolverBestSet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_find_all() [](#method-i-test_find_all) - -## test_find_all_local() [](#method-i-test_find_all_local) - -## test_initialize() [](#method-i-test_initialize) - -## test_prefetch() [](#method-i-test_prefetch) - -## test_prefetch_local() [](#method-i-test_prefetch_local) - diff --git a/example/ruby/TestGemResolverComposedSet.md b/example/ruby/TestGemResolverComposedSet.md deleted file mode 100644 index f9b0e8e..0000000 --- a/example/ruby/TestGemResolverComposedSet.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemResolverComposedSet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_errors() [](#method-i-test_errors) - -## test_prerelease_equals() [](#method-i-test_prerelease_equals) - -## test_remote_equals() [](#method-i-test_remote_equals) - diff --git a/example/ruby/TestGemResolverConflict.md b/example/ruby/TestGemResolverConflict.md deleted file mode 100644 index 4c9d9b6..0000000 --- a/example/ruby/TestGemResolverConflict.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemResolverConflict -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_explanation() [](#method-i-test_explanation) - -## test_explanation_user_request() [](#method-i-test_explanation_user_request) - -## test_request_path() [](#method-i-test_request_path) - diff --git a/example/ruby/TestGemResolverDependencyRequest.md b/example/ruby/TestGemResolverDependencyRequest.md deleted file mode 100644 index b9d874f..0000000 --- a/example/ruby/TestGemResolverDependencyRequest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestGemResolverDependencyRequest -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_development_eh() [](#method-i-test_development_eh) - -## test_match_eh() [](#method-i-test_match_eh) - -## test_match_eh_prerelease() [](#method-i-test_match_eh_prerelease) - -## test_match_eh_prerelease_allow_prerelease() [](#method-i-test_match_eh_prerelease_allow_prerelease) - -## test_matches_spec_eh() [](#method-i-test_matches_spec_eh) - -## test_matches_spec_eh_prerelease() [](#method-i-test_matches_spec_eh_prerelease) - -## test_requirement() [](#method-i-test_requirement) - diff --git a/example/ruby/TestGemResolverGitSet.md b/example/ruby/TestGemResolverGitSet.md deleted file mode 100644 index 778d385..0000000 --- a/example/ruby/TestGemResolverGitSet.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestGemResolverGitSet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_git_gem() [](#method-i-test_add_git_gem) - -## test_add_git_gem_submodules() [](#method-i-test_add_git_gem_submodules) - -## test_add_git_spec() [](#method-i-test_add_git_spec) - -## test_find_all() [](#method-i-test_find_all) - -## test_find_all_local() [](#method-i-test_find_all_local) - -## test_find_all_prerelease() [](#method-i-test_find_all_prerelease) - -## test_prefetch() [](#method-i-test_prefetch) - -## test_prefetch_cache() [](#method-i-test_prefetch_cache) - -## test_prefetch_filter() [](#method-i-test_prefetch_filter) - -## test_prefetch_root_dir() [](#method-i-test_prefetch_root_dir) - -## test_root_dir() [](#method-i-test_root_dir) - diff --git a/example/ruby/TestGemResolverGitSpecification.md b/example/ruby/TestGemResolverGitSpecification.md deleted file mode 100644 index 1fbb7d2..0000000 --- a/example/ruby/TestGemResolverGitSpecification.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: TestGemResolverGitSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_dependency() [](#method-i-test_add_dependency) - -## test_equals2() [](#method-i-test_equals2) - -## test_install() [](#method-i-test_install) - -## test_install_extension() [](#method-i-test_install_extension) -functional test for Gem::Ext::Builder - -## test_install_installed() [](#method-i-test_install_installed) - diff --git a/example/ruby/TestGemResolverIndexSet.md b/example/ruby/TestGemResolverIndexSet.md deleted file mode 100644 index 9f319b4..0000000 --- a/example/ruby/TestGemResolverIndexSet.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestGemResolverIndexSet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_find_all() [](#method-i-test_find_all) - -## test_find_all_local() [](#method-i-test_find_all_local) - -## test_find_all_prerelease() [](#method-i-test_find_all_prerelease) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_source() [](#method-i-test_initialize_source) - diff --git a/example/ruby/TestGemResolverIndexSpecification.md b/example/ruby/TestGemResolverIndexSpecification.md deleted file mode 100644 index 1178532..0000000 --- a/example/ruby/TestGemResolverIndexSpecification.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestGemResolverIndexSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_platform() [](#method-i-test_initialize_platform) - -## test_install() [](#method-i-test_install) - -## test_spec() [](#method-i-test_spec) - -## test_spec_local() [](#method-i-test_spec_local) - diff --git a/example/ruby/TestGemResolverInstalledSpecification.md b/example/ruby/TestGemResolverInstalledSpecification.md deleted file mode 100644 index af8e7e8..0000000 --- a/example/ruby/TestGemResolverInstalledSpecification.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemResolverInstalledSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_initialize() [](#method-i-test_initialize) - -## test_install() [](#method-i-test_install) - -## test_installable_platform_eh() [](#method-i-test_installable_platform_eh) - diff --git a/example/ruby/TestGemResolverInstallerSet.md b/example/ruby/TestGemResolverInstallerSet.md deleted file mode 100644 index 619fdf6..0000000 --- a/example/ruby/TestGemResolverInstallerSet.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: TestGemResolverInstallerSet -**Inherits:** Gem::TestCase - - - - -# Class Methods -## prefetch(_ ) [](#method-c-prefetch) - -#Instance Methods -## test_add_always_install() [](#method-i-test_add_always_install) - -## test_add_always_install_errors() [](#method-i-test_add_always_install_errors) - -## test_add_always_install_index_spec_platform() [](#method-i-test_add_always_install_index_spec_platform) - -## test_add_always_install_platform() [](#method-i-test_add_always_install_platform) - -## test_add_always_install_platform_if_gem_platforms_modified_by_platform_flag() [](#method-i-test_add_always_install_platform_if_gem_platforms_modified_by_platform_flag) - -## test_add_always_install_prerelease() [](#method-i-test_add_always_install_prerelease) - -## test_add_always_install_prerelease_github_problem() [](#method-i-test_add_always_install_prerelease_github_problem) - -## test_add_always_install_prerelease_only() [](#method-i-test_add_always_install_prerelease_only) - -## test_add_local() [](#method-i-test_add_local) - -## test_consider_local_eh() [](#method-i-test_consider_local_eh) - -## test_consider_remote_eh() [](#method-i-test_consider_remote_eh) - -## test_errors() [](#method-i-test_errors) - -## test_find_all_always_install() [](#method-i-test_find_all_always_install) - -## test_find_all_prerelease() [](#method-i-test_find_all_prerelease) - -## test_find_all_prerelease_dependencies_with_add_local() [](#method-i-test_find_all_prerelease_dependencies_with_add_local) - -## test_load_spec() [](#method-i-test_load_spec) - -## test_prefetch() [](#method-i-test_prefetch) - -## test_prerelease_equals() [](#method-i-test_prerelease_equals) - -## test_remote_equals_both() [](#method-i-test_remote_equals_both) - -## test_remote_equals_local() [](#method-i-test_remote_equals_local) - -## test_remote_equals_remote() [](#method-i-test_remote_equals_remote) - diff --git a/example/ruby/TestGemResolverLocalSpecification.md b/example/ruby/TestGemResolverLocalSpecification.md deleted file mode 100644 index fbff375..0000000 --- a/example/ruby/TestGemResolverLocalSpecification.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemResolverLocalSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_install() [](#method-i-test_install) - -## test_installable_platform_eh() [](#method-i-test_installable_platform_eh) - diff --git a/example/ruby/TestGemResolverLockSet.md b/example/ruby/TestGemResolverLockSet.md deleted file mode 100644 index c07e910..0000000 --- a/example/ruby/TestGemResolverLockSet.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestGemResolverLockSet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add() [](#method-i-test_add) - -## test_find_all() [](#method-i-test_find_all) - -## test_load_spec() [](#method-i-test_load_spec) - -## test_prefetch() [](#method-i-test_prefetch) - diff --git a/example/ruby/TestGemResolverLockSpecification.md b/example/ruby/TestGemResolverLockSpecification.md deleted file mode 100644 index fe59a35..0000000 --- a/example/ruby/TestGemResolverLockSpecification.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestGemResolverLockSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_dependency() [](#method-i-test_add_dependency) - -## test_initialize() [](#method-i-test_initialize) - -## test_install() [](#method-i-test_install) - -## test_install_installed() [](#method-i-test_install_installed) - -## test_spec() [](#method-i-test_spec) - -## test_spec_loaded() [](#method-i-test_spec_loaded) - diff --git a/example/ruby/TestGemResolverRequirementList.md b/example/ruby/TestGemResolverRequirementList.md deleted file mode 100644 index 5b90092..0000000 --- a/example/ruby/TestGemResolverRequirementList.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemResolverRequirementList -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_each() [](#method-i-test_each) - diff --git a/example/ruby/TestGemResolverSpecification.md b/example/ruby/TestGemResolverSpecification.md deleted file mode 100644 index c997711..0000000 --- a/example/ruby/TestGemResolverSpecification.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemResolverSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_install() [](#method-i-test_install) - -## test_installable_platform_eh() [](#method-i-test_installable_platform_eh) - -## test_source() [](#method-i-test_source) - diff --git a/example/ruby/TestGemResolverSpecification/TestSpec.md b/example/ruby/TestGemResolverSpecification/TestSpec.md deleted file mode 100644 index 8df7b97..0000000 --- a/example/ruby/TestGemResolverSpecification/TestSpec.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: TestGemResolverSpecification::TestSpec -**Inherits:** Gem::Resolver::Specification - - - - -# Attributes -## source=[R] [](#attribute-i-source=) -Sets the attribute source - -**@param** [] the value to set the attribute source to. - -## spec[RW] [](#attribute-i-spec) -Returns the value of attribute spec. - - -#Instance Methods -## initialize(spec) [](#method-i-initialize) - -**@return** [TestSpec] a new instance of TestSpec - diff --git a/example/ruby/TestGemResolverVendorSet.md b/example/ruby/TestGemResolverVendorSet.md deleted file mode 100644 index b11beca..0000000 --- a/example/ruby/TestGemResolverVendorSet.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGemResolverVendorSet -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_vendor_gem() [](#method-i-test_add_vendor_gem) - -## test_add_vendor_gem_missing() [](#method-i-test_add_vendor_gem_missing) - -## test_find_all() [](#method-i-test_find_all) - -## test_find_all_prerelease() [](#method-i-test_find_all_prerelease) - -## test_load_spec() [](#method-i-test_load_spec) - diff --git a/example/ruby/TestGemResolverVendorSpecification.md b/example/ruby/TestGemResolverVendorSpecification.md deleted file mode 100644 index ab146a3..0000000 --- a/example/ruby/TestGemResolverVendorSpecification.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestGemResolverVendorSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_dependencies() [](#method-i-test_dependencies) - -## test_equals2() [](#method-i-test_equals2) - -## test_full_name() [](#method-i-test_full_name) - -## test_install() [](#method-i-test_install) - -## test_name() [](#method-i-test_name) - -## test_platform() [](#method-i-test_platform) - -## test_version() [](#method-i-test_version) - diff --git a/example/ruby/TestGemSafeMarshal.md b/example/ruby/TestGemSafeMarshal.md deleted file mode 100644 index d2ecb98..0000000 --- a/example/ruby/TestGemSafeMarshal.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: TestGemSafeMarshal -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## assert_safe_load_as(x, **kwargs) [](#method-i-assert_safe_load_as) - -## assert_safe_load_marshal(dumped, additional_methods:[], permitted_ivars:nil, equality:true, marshal_dump_equality:true, inspect:true, to_s:true) [](#method-i-assert_safe_load_marshal) - -## test_array_subclass() [](#method-i-test_array_subclass) - -## test_date() [](#method-i-test_date) - -## test_floats() [](#method-i-test_floats) - -## test_frozen_object() [](#method-i-test_frozen_object) - -## test_gem_spec_disallowed_ivar() [](#method-i-test_gem_spec_disallowed_ivar) - -## test_gem_spec_disallowed_symbol() [](#method-i-test_gem_spec_disallowed_symbol) - -## test_gem_spec_unmarshall_license() [](#method-i-test_gem_spec_unmarshall_license) - -## test_gem_spec_unmarshall_required_ruby_rubygems_version() [](#method-i-test_gem_spec_unmarshall_required_ruby_rubygems_version) - -## test_hash_with_compare_by_identity() [](#method-i-test_hash_with_compare_by_identity) - -## test_hash_with_default_value() [](#method-i-test_hash_with_default_value) - -## test_hash_with_ivar() [](#method-i-test_hash_with_ivar) - -## test_length_one_symbols() [](#method-i-test_length_one_symbols) - -## test_link_after_float() [](#method-i-test_link_after_float) - -## test_negative_length() [](#method-i-test_negative_length) - -## test_rational() [](#method-i-test_rational) - -## test_recursive_array() [](#method-i-test_recursive_array) - -## test_recursive_string() [](#method-i-test_recursive_string) - -## test_repeated_string() [](#method-i-test_repeated_string) - -## test_repeated_symbol() [](#method-i-test_repeated_symbol) - -## test_string_subclass() [](#method-i-test_string_subclass) - -## test_string_with_encoding() [](#method-i-test_string_with_encoding) - -## test_string_with_ivar() [](#method-i-test_string_with_ivar) - -## test_time_loads() [](#method-i-test_time_loads) - -## test_time_user_marshal() [](#method-i-test_time_user_marshal) - -## test_time_with_ivar() [](#method-i-test_time_with_ivar) - -## test_unexpected_eof() [](#method-i-test_unexpected_eof) - -## with_const(mod, name, new_value, &block) [](#method-i-with_const) - diff --git a/example/ruby/TestGemSafeMarshal/ArraySubclass.md b/example/ruby/TestGemSafeMarshal/ArraySubclass.md deleted file mode 100644 index f30392e..0000000 --- a/example/ruby/TestGemSafeMarshal/ArraySubclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestGemSafeMarshal::ArraySubclass -**Inherits:** Array - - - - - diff --git a/example/ruby/TestGemSafeMarshal/StringSubclass.md b/example/ruby/TestGemSafeMarshal/StringSubclass.md deleted file mode 100644 index f7c4251..0000000 --- a/example/ruby/TestGemSafeMarshal/StringSubclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestGemSafeMarshal::StringSubclass -**Inherits:** String - - - - - diff --git a/example/ruby/TestGemSafeMarshal/UserMarshal.md b/example/ruby/TestGemSafeMarshal/UserMarshal.md deleted file mode 100644 index 36b79c2..0000000 --- a/example/ruby/TestGemSafeMarshal/UserMarshal.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemSafeMarshal::UserMarshal -**Inherits:** Object - - - - - -#Instance Methods -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load() [](#method-i-marshal_load) - diff --git a/example/ruby/TestGemSafeYAML.md b/example/ruby/TestGemSafeYAML.md deleted file mode 100644 index afc6ebf..0000000 --- a/example/ruby/TestGemSafeYAML.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemSafeYAML -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_aliases_disabled() [](#method-i-test_aliases_disabled) - -## test_aliases_enabled_by_default() [](#method-i-test_aliases_enabled_by_default) - diff --git a/example/ruby/TestGemSecurity.md b/example/ruby/TestGemSecurity.md deleted file mode 100644 index 61636a6..0000000 --- a/example/ruby/TestGemSecurity.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestGemSecurity -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_class_create_cert() [](#method-i-test_class_create_cert) - -## test_class_create_cert_email() [](#method-i-test_class_create_cert_email) - -## test_class_create_cert_self_signed() [](#method-i-test_class_create_cert_self_signed) - -## test_class_create_key() [](#method-i-test_class_create_key) - -## test_class_create_key_downcases() [](#method-i-test_class_create_key_downcases) - -## test_class_create_key_raises_unknown_algorithm() [](#method-i-test_class_create_key_raises_unknown_algorithm) - -## test_class_email_to_name() [](#method-i-test_class_email_to_name) - -## test_class_get_public_key_ec() [](#method-i-test_class_get_public_key_ec) - -## test_class_get_public_key_rsa() [](#method-i-test_class_get_public_key_rsa) - -## test_class_re_sign() [](#method-i-test_class_re_sign) - -## test_class_re_sign_not_self_signed() [](#method-i-test_class_re_sign_not_self_signed) - -## test_class_re_sign_wrong_key() [](#method-i-test_class_re_sign_wrong_key) - -## test_class_reset() [](#method-i-test_class_reset) - -## test_class_sign() [](#method-i-test_class_sign) - -## test_class_sign_AltName() [](#method-i-test_class_sign_AltName) - -## test_class_trust_dir() [](#method-i-test_class_trust_dir) - -## test_class_write() [](#method-i-test_class_write) - -## test_class_write_encrypted() [](#method-i-test_class_write_encrypted) - -## test_class_write_encrypted_cipher() [](#method-i-test_class_write_encrypted_cipher) - diff --git a/example/ruby/TestGemSecurityPolicy.md b/example/ruby/TestGemSecurityPolicy.md deleted file mode 100644 index 2419f67..0000000 --- a/example/ruby/TestGemSecurityPolicy.md +++ /dev/null @@ -1,108 +0,0 @@ -# Class: TestGemSecurityPolicy -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## digest(data) [](#method-i-digest) - -## dummy_signatures(keyPRIVATE_KEY) [](#method-i-dummy_signatures) - -## setup() [](#method-i-setup) - -## sign(data, keyPRIVATE_KEY) [](#method-i-sign) - -## test_check_cert() [](#method-i-test_check_cert) - -## test_check_cert_expired() [](#method-i-test_check_cert_expired) - -## test_check_cert_future() [](#method-i-test_check_cert_future) - -## test_check_cert_invalid_issuer() [](#method-i-test_check_cert_invalid_issuer) - -## test_check_cert_issuer() [](#method-i-test_check_cert_issuer) - -## test_check_cert_no_signer() [](#method-i-test_check_cert_no_signer) - -## test_check_chain() [](#method-i-test_check_chain) - -## test_check_chain_empty_chain() [](#method-i-test_check_chain_empty_chain) - -## test_check_chain_invalid() [](#method-i-test_check_chain_invalid) - -## test_check_chain_no_chain() [](#method-i-test_check_chain_no_chain) - -## test_check_data() [](#method-i-test_check_data) - -## test_check_data_invalid() [](#method-i-test_check_data_invalid) - -## test_check_key() [](#method-i-test_check_key) - -## test_check_key_no_signer() [](#method-i-test_check_key_no_signer) - -## test_check_key_wrong_key() [](#method-i-test_check_key_wrong_key) - -## test_check_root() [](#method-i-test_check_root) - -## test_check_root_empty_chain() [](#method-i-test_check_root_empty_chain) - -## test_check_root_invalid_signer() [](#method-i-test_check_root_invalid_signer) - -## test_check_root_no_chain() [](#method-i-test_check_root_no_chain) - -## test_check_root_not_self_signed() [](#method-i-test_check_root_not_self_signed) - -## test_check_trust() [](#method-i-test_check_trust) - -## test_check_trust_child() [](#method-i-test_check_trust_child) - -## test_check_trust_empty_chain() [](#method-i-test_check_trust_empty_chain) - -## test_check_trust_mismatch() [](#method-i-test_check_trust_mismatch) - -## test_check_trust_no_chain() [](#method-i-test_check_trust_no_chain) - -## test_check_trust_no_trust() [](#method-i-test_check_trust_no_trust) - -## test_check_trust_no_trust_child() [](#method-i-test_check_trust_no_trust_child) - -## test_subject() [](#method-i-test_subject) - -## test_verify() [](#method-i-test_verify) - -## test_verify_chain_key() [](#method-i-test_verify_chain_key) - -## test_verify_chain_signatures() [](#method-i-test_verify_chain_signatures) - -## test_verify_no_digests() [](#method-i-test_verify_no_digests) - -## test_verify_no_digests_no_security() [](#method-i-test_verify_no_digests_no_security) - -## test_verify_no_signatures() [](#method-i-test_verify_no_signatures) - -## test_verify_no_signatures_no_digests() [](#method-i-test_verify_no_signatures_no_digests) - -## test_verify_no_trust() [](#method-i-test_verify_no_trust) - -## test_verify_not_enough_signatures() [](#method-i-test_verify_not_enough_signatures) - -## test_verify_signatures() [](#method-i-test_verify_signatures) - -## test_verify_signatures_chain() [](#method-i-test_verify_signatures_chain) - -## test_verify_signatures_data() [](#method-i-test_verify_signatures_data) - -## test_verify_signatures_missing() [](#method-i-test_verify_signatures_missing) - -## test_verify_signatures_none() [](#method-i-test_verify_signatures_none) - -## test_verify_signatures_root() [](#method-i-test_verify_signatures_root) - -## test_verify_signatures_signer() [](#method-i-test_verify_signatures_signer) - -## test_verify_signatures_trust() [](#method-i-test_verify_signatures_trust) - -## test_verify_wrong_digest_type() [](#method-i-test_verify_wrong_digest_type) - diff --git a/example/ruby/TestGemSecuritySigner.md b/example/ruby/TestGemSecuritySigner.md deleted file mode 100644 index e80abcd..0000000 --- a/example/ruby/TestGemSecuritySigner.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestGemSecuritySigner -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_extract_name() [](#method-i-test_extract_name) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_cert_chain_empty() [](#method-i-test_initialize_cert_chain_empty) - -## test_initialize_cert_chain_invalid() [](#method-i-test_initialize_cert_chain_invalid) - -## test_initialize_cert_chain_mixed() [](#method-i-test_initialize_cert_chain_mixed) - -## test_initialize_cert_chain_path() [](#method-i-test_initialize_cert_chain_path) - -## test_initialize_default() [](#method-i-test_initialize_default) - -## test_initialize_encrypted_key_path() [](#method-i-test_initialize_encrypted_key_path) - -## test_initialize_key_path() [](#method-i-test_initialize_key_path) - -## test_load_cert_chain() [](#method-i-test_load_cert_chain) - -## test_load_cert_chain_broken() [](#method-i-test_load_cert_chain_broken) - -## test_sign() [](#method-i-test_sign) - -## test_sign_expired() [](#method-i-test_sign_expired) - -## test_sign_expired_auto_update() [](#method-i-test_sign_expired_auto_update) - -## test_sign_expired_auto_update_exists() [](#method-i-test_sign_expired_auto_update_exists) - -## test_sign_no_certs() [](#method-i-test_sign_no_certs) - -## test_sign_no_key() [](#method-i-test_sign_no_key) - -## test_sign_wrong_key() [](#method-i-test_sign_wrong_key) - diff --git a/example/ruby/TestGemSecurityTrustDir.md b/example/ruby/TestGemSecurityTrustDir.md deleted file mode 100644 index ace68c6..0000000 --- a/example/ruby/TestGemSecurityTrustDir.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestGemSecurityTrustDir -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_cert_path() [](#method-i-test_cert_path) - -## test_issuer_of() [](#method-i-test_issuer_of) - -## test_load_certificate() [](#method-i-test_load_certificate) - -## test_name_path() [](#method-i-test_name_path) - -## test_trust_cert() [](#method-i-test_trust_cert) - -## test_verify() [](#method-i-test_verify) - -## test_verify_file() [](#method-i-test_verify_file) - -## test_verify_wrong_permissions() [](#method-i-test_verify_wrong_permissions) - diff --git a/example/ruby/TestGemSilentUI.md b/example/ruby/TestGemSilentUI.md deleted file mode 100644 index 468320b..0000000 --- a/example/ruby/TestGemSilentUI.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestGemSilentUI -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_ask() [](#method-i-test_ask) - -## test_ask_for_password() [](#method-i-test_ask_for_password) - -## test_ask_yes_no() [](#method-i-test_ask_yes_no) - -## test_choose_from_list() [](#method-i-test_choose_from_list) - -## test_download_reporter() [](#method-i-test_download_reporter) - -## test_new_without_dev_null() [](#method-i-test_new_without_dev_null) - -## test_progress_reporter() [](#method-i-test_progress_reporter) - diff --git a/example/ruby/TestGemSource.md b/example/ruby/TestGemSource.md deleted file mode 100644 index b56cce3..0000000 --- a/example/ruby/TestGemSource.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: TestGemSource -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_cache_dir_escapes_windows_paths() [](#method-i-test_cache_dir_escapes_windows_paths) - -## test_dependency_resolver_set_bundler_api() [](#method-i-test_dependency_resolver_set_bundler_api) - -## test_dependency_resolver_set_file_uri() [](#method-i-test_dependency_resolver_set_file_uri) - -## test_dependency_resolver_set_marshal_api() [](#method-i-test_dependency_resolver_set_marshal_api) - -## test_fetch_spec() [](#method-i-test_fetch_spec) - -## test_fetch_spec_cached() [](#method-i-test_fetch_spec_cached) - -## test_fetch_spec_platform() [](#method-i-test_fetch_spec_platform) - -## test_fetch_spec_platform_ruby() [](#method-i-test_fetch_spec_platform_ruby) - -## test_initialize_git() [](#method-i-test_initialize_git) - -## test_initialize_invalid_uri() [](#method-i-test_initialize_invalid_uri) - -## test_load_specs() [](#method-i-test_load_specs) - -## test_load_specs_cached() [](#method-i-test_load_specs_cached) - -## test_load_specs_cached_empty() [](#method-i-test_load_specs_cached_empty) - -## test_load_specs_from_unavailable_uri() [](#method-i-test_load_specs_from_unavailable_uri) - -## test_spaceship() [](#method-i-test_spaceship) - -## test_spaceship_order_is_preserved_when_uri_differs() [](#method-i-test_spaceship_order_is_preserved_when_uri_differs) - -## test_typo_squatting() [](#method-i-test_typo_squatting) - -## test_typo_squatting_custom_distance_threshold() [](#method-i-test_typo_squatting_custom_distance_threshold) - -## test_typo_squatting_false_positive() [](#method-i-test_typo_squatting_false_positive) - -## test_update_cache_eh() [](#method-i-test_update_cache_eh) - -## test_update_cache_eh_home_nonexistent() [](#method-i-test_update_cache_eh_home_nonexistent) - -## tuple(*args) [](#method-i-tuple) - diff --git a/example/ruby/TestGemSourceFetchProblem.md b/example/ruby/TestGemSourceFetchProblem.md deleted file mode 100644 index fa8ee83..0000000 --- a/example/ruby/TestGemSourceFetchProblem.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemSourceFetchProblem -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_exception() [](#method-i-test_exception) - -## test_password_redacted() [](#method-i-test_password_redacted) - -## test_source_password_no_redacted() [](#method-i-test_source_password_no_redacted) - diff --git a/example/ruby/TestGemSourceGit.md b/example/ruby/TestGemSourceGit.md deleted file mode 100644 index 8228fec..0000000 --- a/example/ruby/TestGemSourceGit.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: TestGemSourceGit -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_base_dir() [](#method-i-test_base_dir) - -## test_cache() [](#method-i-test_cache) - -## test_cache_local() [](#method-i-test_cache_local) - -## test_checkout() [](#method-i-test_checkout) - -## test_checkout_default() [](#method-i-test_checkout_default) - -## test_checkout_local() [](#method-i-test_checkout_local) - -## test_checkout_local_cached() [](#method-i-test_checkout_local_cached) - -## test_checkout_submodules() [](#method-i-test_checkout_submodules) - -## test_dir_shortref() [](#method-i-test_dir_shortref) - -## test_download() [](#method-i-test_download) - -## test_equals2() [](#method-i-test_equals2) - -## test_install_dir() [](#method-i-test_install_dir) - -## test_install_dir_local() [](#method-i-test_install_dir_local) - -## test_pretty_print() [](#method-i-test_pretty_print) - -## test_repo_cache_dir() [](#method-i-test_repo_cache_dir) - -## test_rev_parse() [](#method-i-test_rev_parse) - -## test_root_dir() [](#method-i-test_root_dir) - -## test_spaceship() [](#method-i-test_spaceship) - -## test_specs() [](#method-i-test_specs) - -## test_specs_local() [](#method-i-test_specs_local) - -## test_uri() [](#method-i-test_uri) - -## test_uri_hash() [](#method-i-test_uri_hash) - diff --git a/example/ruby/TestGemSourceInstalled.md b/example/ruby/TestGemSourceInstalled.md deleted file mode 100644 index 5662a1e..0000000 --- a/example/ruby/TestGemSourceInstalled.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemSourceInstalled -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_pretty_print() [](#method-i-test_pretty_print) - -## test_spaceship() [](#method-i-test_spaceship) - diff --git a/example/ruby/TestGemSourceList.md b/example/ruby/TestGemSourceList.md deleted file mode 100644 index 3956bf9..0000000 --- a/example/ruby/TestGemSourceList.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: TestGemSourceList -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_Enumerable() [](#method-i-test_Enumerable) - -## test_append() [](#method-i-test_append) - -## test_clear() [](#method-i-test_clear) - -## test_delete() [](#method-i-test_delete) - -## test_delete_a_source() [](#method-i-test_delete_a_source) - -## test_each() [](#method-i-test_each) - -## test_each_source() [](#method-i-test_each_source) - -## test_empty?() [](#method-i-test_empty?) - -**@return** [Boolean] - -## test_equal_to_another_list() [](#method-i-test_equal_to_another_list) - -## test_equal_to_array() [](#method-i-test_equal_to_array) - -## test_include_eh() [](#method-i-test_include_eh) - -## test_include_matches_a_source() [](#method-i-test_include_matches_a_source) - -## test_replace() [](#method-i-test_replace) - -## test_self_from() [](#method-i-test_self_from) - -## test_to_a() [](#method-i-test_to_a) - diff --git a/example/ruby/TestGemSourceLocal.md b/example/ruby/TestGemSourceLocal.md deleted file mode 100644 index adf4519..0000000 --- a/example/ruby/TestGemSourceLocal.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestGemSourceLocal -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_download() [](#method-i-test_download) - -## test_fetch_spec() [](#method-i-test_fetch_spec) - -## test_find_gem() [](#method-i-test_find_gem) - -## test_find_gem_highest_version() [](#method-i-test_find_gem_highest_version) - -## test_find_gem_prerelease() [](#method-i-test_find_gem_prerelease) - -## test_find_gem_specific_version() [](#method-i-test_find_gem_specific_version) - -## test_inspect() [](#method-i-test_inspect) - -## test_load_specs_latest() [](#method-i-test_load_specs_latest) - -## test_load_specs_prerelease() [](#method-i-test_load_specs_prerelease) - -## test_load_specs_released() [](#method-i-test_load_specs_released) - -## test_pretty_print() [](#method-i-test_pretty_print) - -## test_spaceship() [](#method-i-test_spaceship) - diff --git a/example/ruby/TestGemSourceLock.md b/example/ruby/TestGemSourceLock.md deleted file mode 100644 index f07359a..0000000 --- a/example/ruby/TestGemSourceLock.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestGemSourceLock -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_equals2() [](#method-i-test_equals2) - -## test_fetch_spec() [](#method-i-test_fetch_spec) - -## test_spaceship() [](#method-i-test_spaceship) - -## test_spaceship_git() [](#method-i-test_spaceship_git) - -## test_spaceship_installed() [](#method-i-test_spaceship_installed) - -## test_spaceship_local() [](#method-i-test_spaceship_local) - -## test_spaceship_remote() [](#method-i-test_spaceship_remote) - -## test_spaceship_specific_file() [](#method-i-test_spaceship_specific_file) - -## test_spaceship_vendor() [](#method-i-test_spaceship_vendor) - -## test_uri() [](#method-i-test_uri) - diff --git a/example/ruby/TestGemSourceSpecificFile.md b/example/ruby/TestGemSourceSpecificFile.md deleted file mode 100644 index d5d2fd4..0000000 --- a/example/ruby/TestGemSourceSpecificFile.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestGemSourceSpecificFile -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_download() [](#method-i-test_download) - -## test_fetch_spec() [](#method-i-test_fetch_spec) - -## test_fetch_spec_fails_on_unknown_name() [](#method-i-test_fetch_spec_fails_on_unknown_name) - -## test_load_specs() [](#method-i-test_load_specs) - -## test_path() [](#method-i-test_path) - -## test_pretty_print() [](#method-i-test_pretty_print) - -## test_spaceship() [](#method-i-test_spaceship) - -## test_spec() [](#method-i-test_spec) - diff --git a/example/ruby/TestGemSourceSubpathProblem.md b/example/ruby/TestGemSourceSubpathProblem.md deleted file mode 100644 index 0f3eaef..0000000 --- a/example/ruby/TestGemSourceSubpathProblem.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestGemSourceSubpathProblem -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_dependency_resolver_set() [](#method-i-test_dependency_resolver_set) - -## test_fetch_spec() [](#method-i-test_fetch_spec) - -## test_load_specs() [](#method-i-test_load_specs) - -## tuple(*args) [](#method-i-tuple) - diff --git a/example/ruby/TestGemSourceVendor.md b/example/ruby/TestGemSourceVendor.md deleted file mode 100644 index 70e0c6b..0000000 --- a/example/ruby/TestGemSourceVendor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestGemSourceVendor -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_initialize() [](#method-i-test_initialize) - -## test_spaceship() [](#method-i-test_spaceship) - diff --git a/example/ruby/TestGemSpecFetcher.md b/example/ruby/TestGemSpecFetcher.md deleted file mode 100644 index 50b0f38..0000000 --- a/example/ruby/TestGemSpecFetcher.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: TestGemSpecFetcher -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_available_specs_cache() [](#method-i-test_available_specs_cache) - -## test_available_specs_cache_released() [](#method-i-test_available_specs_cache_released) - -## test_available_specs_complete() [](#method-i-test_available_specs_complete) - -## test_available_specs_complete_handles_no_prerelease() [](#method-i-test_available_specs_complete_handles_no_prerelease) - -## test_available_specs_latest() [](#method-i-test_available_specs_latest) - -## test_available_specs_prerelease() [](#method-i-test_available_specs_prerelease) - -## test_available_specs_released() [](#method-i-test_available_specs_released) - -## test_available_specs_with_bad_source() [](#method-i-test_available_specs_with_bad_source) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_nonexistent_home_dir() [](#method-i-test_initialize_nonexistent_home_dir) - -## test_initialize_source() [](#method-i-test_initialize_source) - -## test_initialize_unwritable_home_dir() [](#method-i-test_initialize_unwritable_home_dir) - -## test_spec_for_dependency_all() [](#method-i-test_spec_for_dependency_all) - -## test_spec_for_dependency_bad_fetch_spec() [](#method-i-test_spec_for_dependency_bad_fetch_spec) - -## test_spec_for_dependency_latest() [](#method-i-test_spec_for_dependency_latest) - -## test_spec_for_dependency_mismatched_platform() [](#method-i-test_spec_for_dependency_mismatched_platform) - -## test_spec_for_dependency_platform() [](#method-i-test_spec_for_dependency_platform) - -## test_spec_for_dependency_prerelease() [](#method-i-test_spec_for_dependency_prerelease) - -## test_suggest_gems_from_name_latest() [](#method-i-test_suggest_gems_from_name_latest) - -## test_suggest_gems_from_name_prefix_or_suffix() [](#method-i-test_suggest_gems_from_name_prefix_or_suffix) - -## test_suggest_gems_from_name_prerelease() [](#method-i-test_suggest_gems_from_name_prerelease) - -## tuple(*args) [](#method-i-tuple) - diff --git a/example/ruby/TestGemSpecification.md b/example/ruby/TestGemSpecification.md deleted file mode 100644 index c11d71c..0000000 --- a/example/ruby/TestGemSpecification.md +++ /dev/null @@ -1,680 +0,0 @@ -# Class: TestGemSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## assert_date(date) [](#method-i-assert_date) - -## ext_spec(platform:Gem::Platform::RUBY) [](#method-i-ext_spec) - -## f() [](#method-i-f) - -## make_spec_c1() [](#method-i-make_spec_c1) - -## set_orig(cls) [](#method-i-set_orig) - -## setup() [](#method-i-setup) - -## t() [](#method-i-t) - -## test__dump() [](#method-i-test__dump) - -## test__load_fixes_Date_objects() [](#method-i-test__load_fixes_Date_objects) - -## test_activate() [](#method-i-test_activate) - -## test_add_dependency_from_existing_dependency() [](#method-i-test_add_dependency_from_existing_dependency) - -## test_add_dependency_with_type() [](#method-i-test_add_dependency_with_type) - -## test_add_dependency_with_type_explicit() [](#method-i-test_add_dependency_with_type_explicit) - -## test_allowed_push_host() [](#method-i-test_allowed_push_host) - -## test_author() [](#method-i-test_author) - -## test_authors() [](#method-i-test_authors) - -## test_base_dir() [](#method-i-test_base_dir) - -## test_base_dir_default() [](#method-i-test_base_dir_default) - -## test_base_dir_not_loaded() [](#method-i-test_base_dir_not_loaded) - -## test_bindir_equals() [](#method-i-test_bindir_equals) - -## test_bindir_equals_nil() [](#method-i-test_bindir_equals_nil) - -## test_build_args() [](#method-i-test_build_args) - -## test_build_extensions() [](#method-i-test_build_extensions) - -## test_build_extensions_built() [](#method-i-test_build_extensions_built) - -## test_build_extensions_default_gem() [](#method-i-test_build_extensions_default_gem) - -## test_build_extensions_error() [](#method-i-test_build_extensions_error) - -## test_build_extensions_extensions_dir_unwritable() [](#method-i-test_build_extensions_extensions_dir_unwritable) - -## test_build_extensions_no_extensions_dir_unwritable() [](#method-i-test_build_extensions_no_extensions_dir_unwritable) - -## test_build_extensions_none() [](#method-i-test_build_extensions_none) - -## test_build_extensions_preview() [](#method-i-test_build_extensions_preview) - -## test_contains_requirable_file_eh() [](#method-i-test_contains_requirable_file_eh) - -## test_contains_requirable_file_eh_extension() [](#method-i-test_contains_requirable_file_eh_extension) - -## test_contains_requirable_file_eh_extension_java_platform() [](#method-i-test_contains_requirable_file_eh_extension_java_platform) - -## test_contains_requirable_file_extension_soext() [](#method-i-test_contains_requirable_file_extension_soext) - -## test_date() [](#method-i-test_date) - -## test_date_equals_date() [](#method-i-test_date_equals_date) - -## test_date_equals_string() [](#method-i-test_date_equals_string) - -## test_date_equals_string_bad() [](#method-i-test_date_equals_string_bad) - -## test_date_equals_time() [](#method-i-test_date_equals_time) - -## test_date_equals_time_local() [](#method-i-test_date_equals_time_local) - -## test_date_equals_time_utc() [](#method-i-test_date_equals_time_utc) - -## test_date_tolerates_hour_sec_and_timezone() [](#method-i-test_date_tolerates_hour_sec_and_timezone) - -## test_date_tolerates_hour_sec_zulu() [](#method-i-test_date_tolerates_hour_sec_zulu) - -## test_date_use_env_source_date_epoch() [](#method-i-test_date_use_env_source_date_epoch) - -## test_default_spec_stub_is_marked_default() [](#method-i-test_default_spec_stub_is_marked_default) - -## test_dependencies() [](#method-i-test_dependencies) - -## test_dependent_gems() [](#method-i-test_dependent_gems) - -## test_description() [](#method-i-test_description) - -## test_development_dependencies() [](#method-i-test_development_dependencies) - -## test_doc_dir() [](#method-i-test_doc_dir) - -## test_doc_dir_type() [](#method-i-test_doc_dir_type) - -## test_duplicate_runtime_dependency() [](#method-i-test_duplicate_runtime_dependency) - -## test_eql_eh() [](#method-i-test_eql_eh) - -## test_eql_eh_extensions() [](#method-i-test_eql_eh_extensions) - -## test_executable_equals() [](#method-i-test_executable_equals) - -## test_executables() [](#method-i-test_executables) - -## test_executables_equals_nil() [](#method-i-test_executables_equals_nil) - -## test_extension_dir() [](#method-i-test_extension_dir) - -## test_extension_dir_override() [](#method-i-test_extension_dir_override) - -## test_extensions() [](#method-i-test_extensions) - -## test_extensions_equals_nil() [](#method-i-test_extensions_equals_nil) - -## test_extra_rdoc_files_equals_nil() [](#method-i-test_extra_rdoc_files_equals_nil) - -## test_files() [](#method-i-test_files) - -## test_files_append() [](#method-i-test_files_append) - -## test_files_duplicate() [](#method-i-test_files_duplicate) - -## test_files_extra_rdoc_files() [](#method-i-test_files_extra_rdoc_files) - -## test_files_non_array() [](#method-i-test_files_non_array) - -## test_files_non_array_pathological() [](#method-i-test_files_non_array_pathological) - -## test_find_all_by_full_name() [](#method-i-test_find_all_by_full_name) - -## test_find_by_full_name() [](#method-i-test_find_by_full_name) - -## test_find_by_name() [](#method-i-test_find_by_name) - -## test_find_by_name_prerelease() [](#method-i-test_find_by_name_prerelease) - -## test_find_by_name_with_only_prereleases() [](#method-i-test_find_by_name_with_only_prereleases) - -## test_find_by_name_with_only_prereleases_with_requirements() [](#method-i-test_find_by_name_with_only_prereleases_with_requirements) - -## test_find_by_path() [](#method-i-test_find_by_path) - -## test_find_in_unresolved_tree_is_not_exponentiental() [](#method-i-test_find_in_unresolved_tree_is_not_exponentiental) - -## test_find_inactive_by_path() [](#method-i-test_find_inactive_by_path) - -## test_for_cache() [](#method-i-test_for_cache) - -## test_full_gem_path() [](#method-i-test_full_gem_path) - -## test_full_gem_path_double_slash() [](#method-i-test_full_gem_path_double_slash) - -## test_full_name() [](#method-i-test_full_name) - -## test_full_name_windows() [](#method-i-test_full_name_windows) - -## test_full_require_paths() [](#method-i-test_full_require_paths) - -## test_fullpath_return_rb_extension_file_when_exist_the_same_name_file() [](#method-i-test_fullpath_return_rb_extension_file_when_exist_the_same_name_file) - -## test_gem_build_complete_path() [](#method-i-test_gem_build_complete_path) - -## test_handles_dependencies_with_other_syck_requirements_argument_error() [](#method-i-test_handles_dependencies_with_other_syck_requirements_argument_error) - -## test_handles_dependencies_with_syck_requirements_bug() [](#method-i-test_handles_dependencies_with_syck_requirements_bug) - -## test_handles_private_null_type() [](#method-i-test_handles_private_null_type) - -## test_hash() [](#method-i-test_hash) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_copy() [](#method-i-test_initialize_copy) - -## test_initialize_copy_broken() [](#method-i-test_initialize_copy_broken) - -## test_initialize_future() [](#method-i-test_initialize_future) - -## test_initialize_nil_version() [](#method-i-test_initialize_nil_version) - -## test_initialize_prerelease_version_before_name() [](#method-i-test_initialize_prerelease_version_before_name) - -## test_inner_clonflict_in_indirect_gems() [](#method-i-test_inner_clonflict_in_indirect_gems) - -## test_inner_clonflict_in_indirect_gems_reversed() [](#method-i-test_inner_clonflict_in_indirect_gems_reversed) - -## test_installed_by_version() [](#method-i-test_installed_by_version) - -## test_latest_specs() [](#method-i-test_latest_specs) - -## test_lib_files() [](#method-i-test_lib_files) - -## test_license() [](#method-i-test_license) - -## test_licenses() [](#method-i-test_licenses) - -## test_load_default_gem() [](#method-i-test_load_default_gem) - -## test_load_errors_contain_filename() [](#method-i-test_load_errors_contain_filename) - -## test_metadata_key_size_validation_fails() [](#method-i-test_metadata_key_size_validation_fails) - -## test_metadata_key_type_validation_fails() [](#method-i-test_metadata_key_type_validation_fails) - -## test_metadata_link_validation_fails() [](#method-i-test_metadata_link_validation_fails) - -## test_metadata_link_validation_warns_for_duplicates() [](#method-i-test_metadata_link_validation_warns_for_duplicates) - -## test_metadata_specs() [](#method-i-test_metadata_specs) - -## test_metadata_validates_ok() [](#method-i-test_metadata_validates_ok) - -## test_metadata_value_size_validation_fails() [](#method-i-test_metadata_value_size_validation_fails) - -## test_metadata_value_type_validation_fails() [](#method-i-test_metadata_value_type_validation_fails) - -## test_missing_extensions_eh() [](#method-i-test_missing_extensions_eh) - -## test_missing_extensions_eh_default_gem() [](#method-i-test_missing_extensions_eh_default_gem) - -## test_missing_extensions_eh_none() [](#method-i-test_missing_extensions_eh_none) - -## test_name() [](#method-i-test_name) - -## test_original_name() [](#method-i-test_original_name) - -## test_platform() [](#method-i-test_platform) - -## test_platform_change_reset_cache_file() [](#method-i-test_platform_change_reset_cache_file) - -## test_platform_change_reset_full_name() [](#method-i-test_platform_change_reset_full_name) - -## test_platform_equals() [](#method-i-test_platform_equals) - -## test_platform_equals_current() [](#method-i-test_platform_equals_current) - -## test_platform_equals_legacy() [](#method-i-test_platform_equals_legacy) - -## test_removed_methods() [](#method-i-test_removed_methods) - -## test_require_already_activated() [](#method-i-test_require_already_activated) - -## test_require_already_activated_indirect_conflict() [](#method-i-test_require_already_activated_indirect_conflict) - -## test_require_finds_in_2nd_level_indirect() [](#method-i-test_require_finds_in_2nd_level_indirect) - -## test_require_paths() [](#method-i-test_require_paths) - -## test_require_paths_default_ext_dir_for() [](#method-i-test_require_paths_default_ext_dir_for) - -## test_require_should_not_conflict() [](#method-i-test_require_should_not_conflict) - -## test_require_should_prefer_latest_gem_level1() [](#method-i-test_require_should_prefer_latest_gem_level1) - -## test_require_should_prefer_latest_gem_level2() [](#method-i-test_require_should_prefer_latest_gem_level2) - -## test_require_should_prefer_reachable_gems() [](#method-i-test_require_should_prefer_reachable_gems) - -## test_requirements() [](#method-i-test_requirements) - -## test_runtime_dependencies() [](#method-i-test_runtime_dependencies) - -## test_runtime_dependencies_legacy() [](#method-i-test_runtime_dependencies_legacy) - -## test_runtime_predicate_false() [](#method-i-test_runtime_predicate_false) - -## test_runtime_predicate_true() [](#method-i-test_runtime_predicate_true) - -## test_self__load_future() [](#method-i-test_self__load_future) - -## test_self_activate() [](#method-i-test_self_activate) - -## test_self_activate_ambiguous_direct() [](#method-i-test_self_activate_ambiguous_direct) - -## test_self_activate_ambiguous_indirect() [](#method-i-test_self_activate_ambiguous_indirect) - -## test_self_activate_ambiguous_indirect_conflict() [](#method-i-test_self_activate_ambiguous_indirect_conflict) - -## test_self_activate_ambiguous_unrelated() [](#method-i-test_self_activate_ambiguous_unrelated) - -## test_self_activate_checks_dependencies() [](#method-i-test_self_activate_checks_dependencies) -A -: depends on - C -: # 1.0 depends on - - B -: # 2.0 - - B -: ~> 1.0 (satisfied by 1.0) - - - -## test_self_activate_conflict() [](#method-i-test_self_activate_conflict) - -## test_self_activate_deep_unambiguous() [](#method-i-test_self_activate_deep_unambiguous) - -## test_self_activate_divergent() [](#method-i-test_self_activate_divergent) -A -: depends on - B -: ~> 1.0 (satisfied by 1.0) - - C -: # 1.0 depends on - - B -: # 2.0 - - - -## test_self_activate_dropped() [](#method-i-test_self_activate_dropped) -A1 -: depends on - -B -: > 0 (satisfied by 2.0) - -B1 -: depends on - -C -: > 0 (satisfied by 1.0) - -B2 -: depends on nothing! - -C1 -: depends on nothing - - -## test_self_activate_loaded() [](#method-i-test_self_activate_loaded) - -## test_self_activate_old_required() [](#method-i-test_self_activate_old_required) -DOC - -## test_self_activate_over() [](#method-i-test_self_activate_over) -A -: depends on - B -: >= 1.0 (satisfied by 2.0) - - C -: # 1.0 depends on - - B -: ~> 1.0 - - - -and should resolve using b-1.0 TODO: move these to specification - -## test_self_activate_platform_alternate() [](#method-i-test_self_activate_platform_alternate) -DOC - -## test_self_activate_platform_bump() [](#method-i-test_self_activate_platform_bump) -DOC - -## test_self_activate_prerelease() [](#method-i-test_self_activate_prerelease) -C -: depends on - A -: # 1.a - - B -: # 1.0 depends on - A -: >= 0 (satisfied by 1.a) - - - - -## test_self_activate_raggi_the_edgecase_generator() [](#method-i-test_self_activate_raggi_the_edgecase_generator) -A -: depends on - B -: >= 1.0 (satisfied by 1.1) depends on - - Z -: - - C -: >= 1.0 depends on - B -: # 1.0 - - - - -and should backtrack to resolve using b-1.0, pruning Z from the resolve. - -## test_self_activate_under() [](#method-i-test_self_activate_under) -A -: depends on - B -: ~> 1.0 (satisfied by 1.1) - - C -: # 1.0 depends on - - B -: # 1.0 - - - -and should resolve using b-1.0 - -TODO: this is not under, but over... under would require depth first resolve -through a dependency that is later pruned. - -## test_self_activate_unrelated() [](#method-i-test_self_activate_unrelated) -A -: depends on - B -: >= 1.0 (satisfied by 2.0) - - -C -: depends on nothing - - -## test_self_activate_via_require() [](#method-i-test_self_activate_via_require) - -## test_self_activate_via_require_wtf() [](#method-i-test_self_activate_via_require_wtf) - -## test_self_all_equals() [](#method-i-test_self_all_equals) - -## test_self_attribute_names() [](#method-i-test_self_attribute_names) - -## test_self_find_active_stub_by_path() [](#method-i-test_self_find_active_stub_by_path) - -## test_self_from_yaml() [](#method-i-test_self_from_yaml) - -## test_self_from_yaml_cleans_up_Date_objects() [](#method-i-test_self_from_yaml_cleans_up_Date_objects) - -## test_self_load() [](#method-i-test_self_load) - -## test_self_load_escape_curly() [](#method-i-test_self_load_escape_curly) - -## test_self_load_escape_interpolation() [](#method-i-test_self_load_escape_interpolation) - -## test_self_load_escape_quote() [](#method-i-test_self_load_escape_quote) - -## test_self_load_legacy_ruby() [](#method-i-test_self_load_legacy_ruby) - -## test_self_load_relative() [](#method-i-test_self_load_relative) - -## test_self_load_utf8_with_ascii_encoding() [](#method-i-test_self_load_utf8_with_ascii_encoding) - -## test_self_normalize_yaml_input_with_183_io() [](#method-i-test_self_normalize_yaml_input_with_183_io) - -## test_self_normalize_yaml_input_with_183_yaml() [](#method-i-test_self_normalize_yaml_input_with_183_yaml) - -## test_self_normalize_yaml_input_with_192_yaml() [](#method-i-test_self_normalize_yaml_input_with_192_yaml) - -## test_self_normalize_yaml_input_with_non_183_io() [](#method-i-test_self_normalize_yaml_input_with_non_183_io) - -## test_self_normalize_yaml_input_with_non_183_yaml() [](#method-i-test_self_normalize_yaml_input_with_non_183_yaml) - -## test_self_outdated() [](#method-i-test_self_outdated) - -## test_self_outdated_and_latest_remotes() [](#method-i-test_self_outdated_and_latest_remotes) - -## test_self_remove_spec() [](#method-i-test_self_remove_spec) - -## test_self_remove_spec_removed() [](#method-i-test_self_remove_spec_removed) - -## test_self_stubs_for_lazy_loading() [](#method-i-test_self_stubs_for_lazy_loading) - -## test_self_stubs_for_mult_platforms() [](#method-i-test_self_stubs_for_mult_platforms) - -## test_self_stubs_for_no_lazy_loading_after_all_specs_setup() [](#method-i-test_self_stubs_for_no_lazy_loading_after_all_specs_setup) - -## test_self_stubs_returns_only_specified_named_specs() [](#method-i-test_self_stubs_returns_only_specified_named_specs) - -## test_source() [](#method-i-test_source) - -## test_source_paths() [](#method-i-test_source_paths) - -## test_spaceship_name() [](#method-i-test_spaceship_name) - -## test_spaceship_platform() [](#method-i-test_spaceship_platform) - -## test_spaceship_version() [](#method-i-test_spaceship_version) - -## test_spec_file() [](#method-i-test_spec_file) - -## test_spec_name() [](#method-i-test_spec_name) - -## test_summary() [](#method-i-test_summary) - -## test_test_files() [](#method-i-test_test_files) - -## test_test_files_equals_nil() [](#method-i-test_test_files_equals_nil) - -## test_to_fullpath() [](#method-i-test_to_fullpath) - -## test_to_ruby() [](#method-i-test_to_ruby) - -## test_to_ruby_fancy() [](#method-i-test_to_ruby_fancy) - -## test_to_ruby_for_cache() [](#method-i-test_to_ruby_for_cache) - -## test_to_ruby_keeps_requirements_as_originally_specified() [](#method-i-test_to_ruby_keeps_requirements_as_originally_specified) - -## test_to_ruby_legacy() [](#method-i-test_to_ruby_legacy) - -## test_to_ruby_nested_hash() [](#method-i-test_to_ruby_nested_hash) - -## test_to_ruby_platform() [](#method-i-test_to_ruby_platform) - -## test_to_ruby_with_rsa_key() [](#method-i-test_to_ruby_with_rsa_key) - -## test_to_yaml() [](#method-i-test_to_yaml) - -## test_to_yaml_fancy() [](#method-i-test_to_yaml_fancy) - -## test_to_yaml_no_autorequire() [](#method-i-test_to_yaml_no_autorequire) - -## test_to_yaml_no_post_install_message() [](#method-i-test_to_yaml_no_post_install_message) - -## test_to_yaml_no_signing_key() [](#method-i-test_to_yaml_no_signing_key) - -## test_to_yaml_platform() [](#method-i-test_to_yaml_platform) - -## test_to_yaml_platform_legacy() [](#method-i-test_to_yaml_platform_legacy) - -## test_to_yaml_platform_no_specific_platform() [](#method-i-test_to_yaml_platform_no_specific_platform) - -## test_to_yaml_platform_original_platform_empty_string() [](#method-i-test_to_yaml_platform_original_platform_empty_string) - -## test_to_yaml_platform_original_platform_nil() [](#method-i-test_to_yaml_platform_original_platform_nil) - -## test_unresolved_specs() [](#method-i-test_unresolved_specs) - -## test_unresolved_specs_with_duplicated_versions() [](#method-i-test_unresolved_specs_with_duplicated_versions) - -## test_unresolved_specs_with_unrestricted_deps_on_default_gems() [](#method-i-test_unresolved_specs_with_unrestricted_deps_on_default_gems) - -## test_unresolved_specs_with_versions() [](#method-i-test_unresolved_specs_with_versions) - -## test_validate() [](#method-i-test_validate) - -## test_validate_authors() [](#method-i-test_validate_authors) - -## test_validate_autorequire() [](#method-i-test_validate_autorequire) - -## test_validate_dependencies() [](#method-i-test_validate_dependencies) - -## test_validate_dependencies_allowed_duplicates() [](#method-i-test_validate_dependencies_allowed_duplicates) - -## test_validate_dependencies_duplicates() [](#method-i-test_validate_dependencies_duplicates) - -## test_validate_deprecated_license_values_plus() [](#method-i-test_validate_deprecated_license_values_plus) - -## test_validate_description() [](#method-i-test_validate_description) - -## test_validate_email() [](#method-i-test_validate_email) - -## test_validate_empty() [](#method-i-test_validate_empty) - -## test_validate_empty_files() [](#method-i-test_validate_empty_files) - -## test_validate_empty_homepage() [](#method-i-test_validate_empty_homepage) - -## test_validate_empty_require_paths() [](#method-i-test_validate_empty_require_paths) - -## test_validate_empty_summary() [](#method-i-test_validate_empty_summary) - -## test_validate_error() [](#method-i-test_validate_error) - -## test_validate_executables() [](#method-i-test_validate_executables) - -## test_validate_files() [](#method-i-test_validate_files) - -## test_validate_files_recursive() [](#method-i-test_validate_files_recursive) - -## test_validate_for_resolution_ignores_metadata() [](#method-i-test_validate_for_resolution_ignores_metadata) - -## test_validate_for_resolution_validates_duplicate_dependencies() [](#method-i-test_validate_for_resolution_validates_duplicate_dependencies) - -## test_validate_for_resolution_validates_name() [](#method-i-test_validate_for_resolution_validates_name) - -## test_validate_for_resolution_validates_required_attributes() [](#method-i-test_validate_for_resolution_validates_required_attributes) - -## test_validate_homepage() [](#method-i-test_validate_homepage) - -## test_validate_license() [](#method-i-test_validate_license) - -## test_validate_license_gives_suggestions() [](#method-i-test_validate_license_gives_suggestions) - -## test_validate_license_in_a_non_packaging_context() [](#method-i-test_validate_license_in_a_non_packaging_context) - -## test_validate_license_ref() [](#method-i-test_validate_license_ref) - -## test_validate_license_values() [](#method-i-test_validate_license_values) - -## test_validate_license_values_or_later() [](#method-i-test_validate_license_values_or_later) - -## test_validate_license_values_with() [](#method-i-test_validate_license_values_with) - -## test_validate_license_with_deprecated_exception() [](#method-i-test_validate_license_with_deprecated_exception) - -## test_validate_license_with_invalid_exception() [](#method-i-test_validate_license_with_invalid_exception) - -## test_validate_license_with_nonsense_suffix() [](#method-i-test_validate_license_with_nonsense_suffix) - -## test_validate_name() [](#method-i-test_validate_name) - -## test_validate_nil_license() [](#method-i-test_validate_nil_license) - -## test_validate_no_required_ruby_versions() [](#method-i-test_validate_no_required_ruby_versions) - -## test_validate_non_nil() [](#method-i-test_validate_non_nil) - -## test_validate_open_required_ruby_versions() [](#method-i-test_validate_open_required_ruby_versions) - -## test_validate_permissions() [](#method-i-test_validate_permissions) - -## test_validate_permissions_of_missing_file_non_packaging() [](#method-i-test_validate_permissions_of_missing_file_non_packaging) - -## test_validate_platform_legacy() [](#method-i-test_validate_platform_legacy) - -## test_validate_prerelease_dependencies_with_prerelease_version() [](#method-i-test_validate_prerelease_dependencies_with_prerelease_version) - -## test_validate_rake_extension_have_rake_dependency_no_warning() [](#method-i-test_validate_rake_extension_have_rake_dependency_no_warning) - -## test_validate_rake_extension_have_rake_dependency_warning() [](#method-i-test_validate_rake_extension_have_rake_dependency_warning) - -## test_validate_removed_rubyforge_project() [](#method-i-test_validate_removed_rubyforge_project) - -## test_validate_require_paths_with_invalid_types() [](#method-i-test_validate_require_paths_with_invalid_types) - -## test_validate_rubygems_version() [](#method-i-test_validate_rubygems_version) - -## test_validate_rust_extension_have_missing_cargo_toml_error() [](#method-i-test_validate_rust_extension_have_missing_cargo_toml_error) - -## test_validate_rust_extension_have_no_missing_cargo_toml_error() [](#method-i-test_validate_rust_extension_have_no_missing_cargo_toml_error) - -## test_validate_self_referencing_dependencies() [](#method-i-test_validate_self_referencing_dependencies) - -## test_validate_specification_version() [](#method-i-test_validate_specification_version) - -## test_validate_summary() [](#method-i-test_validate_summary) - -## test_validate_valid_required_ruby_versions() [](#method-i-test_validate_valid_required_ruby_versions) - -## test_validate_warning() [](#method-i-test_validate_warning) - -## test_version() [](#method-i-test_version) - -## test_version_change_reset_cache_file() [](#method-i-test_version_change_reset_cache_file) - -## test_version_change_reset_full_name() [](#method-i-test_version_change_reset_full_name) - -## util_setup_deps() [](#method-i-util_setup_deps) - -## util_setup_validate() [](#method-i-util_setup_validate) - -## w() [](#method-i-w) - -## x(s) [](#method-i-x) - diff --git a/example/ruby/TestGemStreamUI.md b/example/ruby/TestGemStreamUI.md deleted file mode 100644 index e3310df..0000000 --- a/example/ruby/TestGemStreamUI.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: TestGemStreamUI -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ask() [](#method-i-test_ask) - -## test_ask_for_password() [](#method-i-test_ask_for_password) - -## test_ask_for_password_no_tty() [](#method-i-test_ask_for_password_no_tty) - -## test_ask_no_tty() [](#method-i-test_ask_no_tty) - -## test_ask_yes_no_no_tty_with_default() [](#method-i-test_ask_yes_no_no_tty_with_default) - -## test_ask_yes_no_no_tty_without_default() [](#method-i-test_ask_yes_no_no_tty_without_default) - -## test_choose_from_list() [](#method-i-test_choose_from_list) - -## test_choose_from_list_0() [](#method-i-test_choose_from_list_0) - -## test_choose_from_list_EOF() [](#method-i-test_choose_from_list_EOF) - -## test_choose_from_list_negative() [](#method-i-test_choose_from_list_negative) - -## test_choose_from_list_over() [](#method-i-test_choose_from_list_over) - -## test_download_reporter_anything() [](#method-i-test_download_reporter_anything) - -## test_download_reporter_silent_false() [](#method-i-test_download_reporter_silent_false) - -## test_download_reporter_silent_nil() [](#method-i-test_download_reporter_silent_nil) - -## test_progress_reporter_silent_false() [](#method-i-test_progress_reporter_silent_false) - -## test_progress_reporter_silent_nil() [](#method-i-test_progress_reporter_silent_nil) - -## test_progress_reporter_simple() [](#method-i-test_progress_reporter_simple) - -## test_progress_reporter_verbose() [](#method-i-test_progress_reporter_verbose) - -## test_threaded_download_reporter() [](#method-i-test_threaded_download_reporter) - -## test_verbose_download_reporter_no_tty() [](#method-i-test_verbose_download_reporter_no_tty) - -## test_verbose_download_reporter_progress() [](#method-i-test_verbose_download_reporter_progress) - -## test_verbose_download_reporter_progress_complete() [](#method-i-test_verbose_download_reporter_progress_complete) - -## test_verbose_download_reporter_progress_nil_length() [](#method-i-test_verbose_download_reporter_progress_nil_length) - -## test_verbose_download_reporter_progress_once() [](#method-i-test_verbose_download_reporter_progress_once) - -## test_verbose_download_reporter_progress_zero_length() [](#method-i-test_verbose_download_reporter_progress_zero_length) - diff --git a/example/ruby/TestGemStreamUI/IsTty.md b/example/ruby/TestGemStreamUI/IsTty.md deleted file mode 100644 index 3c67481..0000000 --- a/example/ruby/TestGemStreamUI/IsTty.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: TestGemStreamUI::IsTty - - - - -# Attributes -## tty[RW] [](#attribute-i-tty) -Returns the value of attribute tty. - - -#Instance Methods -## noecho() [](#method-i-noecho) - -**@yield** [_self] - -**@yieldparam** [TestGemStreamUI::IsTty] the object that the method was called on - -## tty?() [](#method-i-tty?) - -**@return** [Boolean] - diff --git a/example/ruby/TestGemText.md b/example/ruby/TestGemText.md deleted file mode 100644 index 5752ab2..0000000 --- a/example/ruby/TestGemText.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: TestGemText -**Inherits:** Gem::TestCase - -**Includes:** Gem::Text - - - - - -#Instance Methods -## clean_text(text) [](#method-i-clean_text) -Remove any non-printable characters and make the text suitable for printing. - -## format_text(text, wrap, indent0) [](#method-i-format_text) -Wraps `text` to `wrap` characters and optionally indents by `indent` -characters - -## levenshtein_distance(str1, str2) [](#method-i-levenshtein_distance) -Returns a value representing the "cost" of transforming str1 into str2 -Vendored version of DidYouMean::Levenshtein.distance from the -ruby/did_you_mean gem @ 1.4.0 -https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651 -807c/lib/did_you_mean/levenshtein.rb#L7-L37 - -## min3(a, b, c) [](#method-i-min3) -:nodoc: - -## test_clean_text() [](#method-i-test_clean_text) - -## test_format_removes_nonprintable_characters() [](#method-i-test_format_removes_nonprintable_characters) - -## test_format_text() [](#method-i-test_format_text) - -## test_format_text_indent() [](#method-i-test_format_text_indent) - -## test_format_text_no_space() [](#method-i-test_format_text_no_space) - -## test_format_text_none() [](#method-i-test_format_text_none) - -## test_format_text_none_indent() [](#method-i-test_format_text_none_indent) - -## test_format_text_trailing() [](#method-i-test_format_text_trailing) -for two spaces after . - -## test_levenshtein_distance_add() [](#method-i-test_levenshtein_distance_add) - -## test_levenshtein_distance_all() [](#method-i-test_levenshtein_distance_all) - -## test_levenshtein_distance_empty() [](#method-i-test_levenshtein_distance_empty) - -## test_levenshtein_distance_remove() [](#method-i-test_levenshtein_distance_remove) - -## test_levenshtein_distance_replace() [](#method-i-test_levenshtein_distance_replace) - -## test_min3() [](#method-i-test_min3) - -## test_truncate_text() [](#method-i-test_truncate_text) - -## truncate_text(text, description, max_length100_000) [](#method-i-truncate_text) - -**@raise** [ArgumentError] - diff --git a/example/ruby/TestGemUninstaller.md b/example/ruby/TestGemUninstaller.md deleted file mode 100644 index a26bcf0..0000000 --- a/example/ruby/TestGemUninstaller.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: TestGemUninstaller -**Inherits:** Gem::InstallerTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ask_if_ok() [](#method-i-test_ask_if_ok) - -## test_initialize_expand_path() [](#method-i-test_initialize_expand_path) - -## test_path_ok_eh() [](#method-i-test_path_ok_eh) - -## test_path_ok_eh_legacy() [](#method-i-test_path_ok_eh_legacy) - -## test_path_ok_eh_user() [](#method-i-test_path_ok_eh_user) - -## test_regenerate_plugins_for() [](#method-i-test_regenerate_plugins_for) - -## test_remove_all() [](#method-i-test_remove_all) - -## test_remove_executables_force_keep() [](#method-i-test_remove_executables_force_keep) - -## test_remove_executables_force_remove() [](#method-i-test_remove_executables_force_remove) - -## test_remove_executables_user() [](#method-i-test_remove_executables_user) - -## test_remove_executables_user_format() [](#method-i-test_remove_executables_user_format) - -## test_remove_executables_user_format_disabled() [](#method-i-test_remove_executables_user_format_disabled) - -## test_remove_not_in_home() [](#method-i-test_remove_not_in_home) - -## test_remove_plugins() [](#method-i-test_remove_plugins) - -## test_remove_plugins_user_installed() [](#method-i-test_remove_plugins_user_installed) - -## test_remove_symlinked_gem_home() [](#method-i-test_remove_symlinked_gem_home) - -## test_uninstall() [](#method-i-test_uninstall) - -## test_uninstall_default_gem() [](#method-i-test_uninstall_default_gem) - -## test_uninstall_default_gem_with_same_version() [](#method-i-test_uninstall_default_gem_with_same_version) - -## test_uninstall_doesnt_prompt_and_raises_when_abort_on_dependent_set() [](#method-i-test_uninstall_doesnt_prompt_and_raises_when_abort_on_dependent_set) - -## test_uninstall_doesnt_prompt_when_other_gem_satisfies_requirement() [](#method-i-test_uninstall_doesnt_prompt_when_other_gem_satisfies_requirement) - -## test_uninstall_doesnt_prompt_when_removing_a_dev_dep() [](#method-i-test_uninstall_doesnt_prompt_when_removing_a_dev_dep) - -## test_uninstall_extension() [](#method-i-test_uninstall_extension) - -## test_uninstall_keeps_plugins_up_to_date() [](#method-i-test_uninstall_keeps_plugins_up_to_date) - -## test_uninstall_no_permission() [](#method-i-test_uninstall_no_permission) - -## test_uninstall_nonexistent() [](#method-i-test_uninstall_nonexistent) - -## test_uninstall_not_ok() [](#method-i-test_uninstall_not_ok) - -## test_uninstall_only_lists_unsatisfied_deps() [](#method-i-test_uninstall_only_lists_unsatisfied_deps) - -## test_uninstall_prompt_includes_dep_type() [](#method-i-test_uninstall_prompt_includes_dep_type) - -## test_uninstall_prompt_only_lists_the_dependents_that_prevented_uninstallation() [](#method-i-test_uninstall_prompt_only_lists_the_dependents_that_prevented_uninstallation) - -## test_uninstall_prompts_about_broken_deps() [](#method-i-test_uninstall_prompts_about_broken_deps) - -## test_uninstall_selection() [](#method-i-test_uninstall_selection) - -## test_uninstall_selection_greater_than_one() [](#method-i-test_uninstall_selection_greater_than_one) - -## test_uninstall_user_install() [](#method-i-test_uninstall_user_install) - -## test_uninstall_user_install_with_symlinked_home() [](#method-i-test_uninstall_user_install_with_symlinked_home) - -## test_uninstall_with_install_dir_regenerates_plugins() [](#method-i-test_uninstall_with_install_dir_regenerates_plugins) - -## test_uninstall_with_install_dir_removes_plugins() [](#method-i-test_uninstall_with_install_dir_removes_plugins) - -## test_uninstall_wrong_repo() [](#method-i-test_uninstall_wrong_repo) - diff --git a/example/ruby/TestGemUnsatisfiableDependencyError.md b/example/ruby/TestGemUnsatisfiableDependencyError.md deleted file mode 100644 index a11b127..0000000 --- a/example/ruby/TestGemUnsatisfiableDependencyError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestGemUnsatisfiableDependencyError -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_errors() [](#method-i-test_errors) - -## test_name() [](#method-i-test_name) - -## test_version() [](#method-i-test_version) - diff --git a/example/ruby/TestGemUriFormatter.md b/example/ruby/TestGemUriFormatter.md deleted file mode 100644 index 9ddd0e3..0000000 --- a/example/ruby/TestGemUriFormatter.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemUriFormatter -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_escape() [](#method-i-test_escape) - -## test_normalize_uri() [](#method-i-test_normalize_uri) - -## test_unescape() [](#method-i-test_unescape) - diff --git a/example/ruby/TestGemUtil.md b/example/ruby/TestGemUtil.md deleted file mode 100644 index 24195ed..0000000 --- a/example/ruby/TestGemUtil.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestGemUtil -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_class_popen() [](#method-i-test_class_popen) - -## test_correct_for_windows_path() [](#method-i-test_correct_for_windows_path) - -## test_glob_files_in_dir() [](#method-i-test_glob_files_in_dir) - -## test_silent_system() [](#method-i-test_silent_system) - -## test_traverse_parents() [](#method-i-test_traverse_parents) - -## test_traverse_parents_does_not_crash_on_permissions_error() [](#method-i-test_traverse_parents_does_not_crash_on_permissions_error) - diff --git a/example/ruby/TestGemValidator.md b/example/ruby/TestGemValidator.md deleted file mode 100644 index 9a157c6..0000000 --- a/example/ruby/TestGemValidator.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestGemValidator -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_alien() [](#method-i-test_alien) - -## test_alien_default() [](#method-i-test_alien_default) - diff --git a/example/ruby/TestGemVersion.md b/example/ruby/TestGemVersion.md deleted file mode 100644 index 3cdc006..0000000 --- a/example/ruby/TestGemVersion.md +++ /dev/null @@ -1,92 +0,0 @@ -# Class: TestGemVersion -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## assert_approximate_equal(expected, version) [](#method-i-assert_approximate_equal) -Assert that `expected` is the "approximate" recommendation for `version`. - -## assert_approximate_satisfies_itself(version) [](#method-i-assert_approximate_satisfies_itself) -Assert that the "approximate" recommendation for `version` satisfies -`version`. - -## assert_bumped_version_equal(expected, unbumped) [](#method-i-assert_bumped_version_equal) -Assert that bumping the `unbumped` version yields the `expected`. - -## assert_less_than(left, right) [](#method-i-assert_less_than) - -## assert_prerelease(version) [](#method-i-assert_prerelease) -Asserts that `version` is a prerelease. - -## assert_release_equal(release, version) [](#method-i-assert_release_equal) -Assert that `release` is the correct non-prerelease `version`. - -## assert_version_eql(first, second) [](#method-i-assert_version_eql) -Assert that two versions are eql?. Checks both directions. - -## assert_version_equal(expected, actual) [](#method-i-assert_version_equal) -Assert that two versions are equal. Handles strings or Gem::Version instances. - -## refute_prerelease(version) [](#method-i-refute_prerelease) -Refute the assumption that `version` is a prerelease. - -## refute_version_eql(first, second) [](#method-i-refute_version_eql) -Refute the assumption that two versions are eql?. Checks both directions. - -## refute_version_equal(unexpected, actual) [](#method-i-refute_version_equal) -Refute the assumption that the two versions are equal?. - -## test_approximate_recommendation() [](#method-i-test_approximate_recommendation) - -## test_bump() [](#method-i-test_bump) - -## test_bump_alpha() [](#method-i-test_bump_alpha) - -## test_bump_alphanumeric() [](#method-i-test_bump_alphanumeric) - -## test_bump_one_level() [](#method-i-test_bump_one_level) - -## test_bump_trailing_zeros() [](#method-i-test_bump_trailing_zeros) - -## test_canonical_segments() [](#method-i-test_canonical_segments) - -## test_class_correct() [](#method-i-test_class_correct) - -## test_class_create() [](#method-i-test_class_create) -A Gem::Version is already a Gem::Version and therefore not transformed by -Gem::Version.create - -## test_class_new_subclass() [](#method-i-test_class_new_subclass) - -## test_empty_version() [](#method-i-test_empty_version) - -## test_eql_eh() [](#method-i-test_eql_eh) - -## test_equals2() [](#method-i-test_equals2) - -## test_frozen_version() [](#method-i-test_frozen_version) - -## test_hash() [](#method-i-test_hash) -REVISIT: consider removing as too impl-bound - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_invalid() [](#method-i-test_initialize_invalid) - -## test_prerelease() [](#method-i-test_prerelease) - -## test_release() [](#method-i-test_release) - -## test_segments() [](#method-i-test_segments) -modifying the segments of a version should not affect the segments of the -cached version object - -## test_semver() [](#method-i-test_semver) - -## test_spaceship() [](#method-i-test_spaceship) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestGemVersion/V.md b/example/ruby/TestGemVersion/V.md deleted file mode 100644 index ee63acf..0000000 --- a/example/ruby/TestGemVersion/V.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestGemVersion::V -**Inherits:** Gem::Version - - - - - diff --git a/example/ruby/TestGemVersionOption.md b/example/ruby/TestGemVersionOption.md deleted file mode 100644 index 2181c11..0000000 --- a/example/ruby/TestGemVersionOption.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestGemVersionOption -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_platform_option() [](#method-i-test_add_platform_option) - -## test_add_version_option() [](#method-i-test_add_version_option) - -## test_enables_prerelease() [](#method-i-test_enables_prerelease) - -## test_multiple_version_operator_option_compound() [](#method-i-test_multiple_version_operator_option_compound) - -## test_platform_option() [](#method-i-test_platform_option) - -## test_platform_option_ruby() [](#method-i-test_platform_option_ruby) - -## test_platform_option_twice() [](#method-i-test_platform_option_twice) - -## test_version_option() [](#method-i-test_version_option) - -## test_version_option_compound() [](#method-i-test_version_option_compound) - -## test_version_option_explicit_prerelease() [](#method-i-test_version_option_explicit_prerelease) - -## test_version_option_twice() [](#method-i-test_version_option_twice) - diff --git a/example/ruby/TestGraphemeBreaksFromFile.md b/example/ruby/TestGraphemeBreaksFromFile.md deleted file mode 100644 index a4b998a..0000000 --- a/example/ruby/TestGraphemeBreaksFromFile.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestGraphemeBreaksFromFile -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## file_available?() [](#method-c-file_available?) -**@return** [Boolean] - - -#Instance Methods -## all_tests() [](#method-i-all_tests) - -## read_data() [](#method-i-read_data) - -## test_backslash_X() [](#method-i-test_backslash_X) - -## test_data_files_available() [](#method-i-test_data_files_available) - -## test_each_grapheme_cluster() [](#method-i-test_each_grapheme_cluster) - diff --git a/example/ruby/TestGraphemeBreaksFromFile/BreakTest.md b/example/ruby/TestGraphemeBreaksFromFile/BreakTest.md deleted file mode 100644 index 6e79e16..0000000 --- a/example/ruby/TestGraphemeBreaksFromFile/BreakTest.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TestGraphemeBreaksFromFile::BreakTest -**Inherits:** Object - - - - -# Attributes -## clusters[RW] [](#attribute-i-clusters) -Returns the value of attribute clusters. - -## comment[RW] [](#attribute-i-comment) -Returns the value of attribute comment. - -## line_number[RW] [](#attribute-i-line_number) -Returns the value of attribute line_number. - -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - - -#Instance Methods -## initialize(line_number, data, comment) [](#method-i-initialize) - -**@return** [BreakTest] a new instance of BreakTest - diff --git a/example/ruby/TestHash.md b/example/ruby/TestHash.md deleted file mode 100644 index 5e963b7..0000000 --- a/example/ruby/TestHash.md +++ /dev/null @@ -1,298 +0,0 @@ -# Class: TestHash -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## hash_hint(hv) [](#method-i-hash_hint) - -## hrec(h, n, &b) [](#method-i-hrec) - -## setup() [](#method-i-setup) -From rubicon - -## teardown() [](#method-i-teardown) - -## test_AREF() [](#method-i-test_AREF) -'[]' - -## test_ASET() [](#method-i-test_ASET) -'[]=' - -## test_EQUAL() [](#method-i-test_EQUAL) -'==' - -## test_assoc() [](#method-i-test_assoc) - -## test_assoc_compare_by_identity() [](#method-i-test_assoc_compare_by_identity) - -## test_callcc() [](#method-i-test_callcc) - -## test_callcc_escape() [](#method-i-test_callcc_escape) - -## test_callcc_iter_level() [](#method-i-test_callcc_iter_level) - -## test_callcc_reenter() [](#method-i-test_callcc_reenter) - -## test_clear() [](#method-i-test_clear) - -## test_clear2() [](#method-i-test_clear2) - -## test_clear_initialize_copy() [](#method-i-test_clear_initialize_copy) - -## test_clone() [](#method-i-test_clone) - -## test_cmp() [](#method-i-test_cmp) - -## test_cmp_samekeys() [](#method-i-test_cmp_samekeys) - -## test_compact() [](#method-i-test_compact) - -## test_compare_by_identity() [](#method-i-test_compare_by_identity) - -## test_compare_by_identy_memory_leak() [](#method-i-test_compare_by_identy_memory_leak) - -## test_create() [](#method-i-test_create) - -## test_default() [](#method-i-test_default) - -## test_default=() [](#method-i-test_default=) - -## test_default_proc() [](#method-i-test_default_proc) - -## test_delete() [](#method-i-test_delete) - -## test_delete_if() [](#method-i-test_delete_if) - -## test_dig() [](#method-i-test_dig) - -## test_dig_with_respond_to() [](#method-i-test_dig_with_respond_to) - -## test_dup() [](#method-i-test_dup) - -## test_dup_equality() [](#method-i-test_dup_equality) - -## test_each() [](#method-i-test_each) - -## test_each_key() [](#method-i-test_each_key) - -## test_each_pair() [](#method-i-test_each_pair) - -## test_each_value() [](#method-i-test_each_value) - -## test_empty?() [](#method-i-test_empty?) - -**@return** [Boolean] - -## test_eql() [](#method-i-test_eql) - -## test_equal2() [](#method-i-test_equal2) - -## test_except() [](#method-i-test_except) - -## test_except_on_identhash() [](#method-i-test_except_on_identhash) - -## test_fetch() [](#method-i-test_fetch) - -## test_fetch2() [](#method-i-test_fetch2) - -## test_fetch_error() [](#method-i-test_fetch_error) - -## test_fetch_values() [](#method-i-test_fetch_values) - -## test_filter() [](#method-i-test_filter) - -## test_filter!() [](#method-i-test_filter!) - -## test_flatten() [](#method-i-test_flatten) - -## test_flatten_arity() [](#method-i-test_flatten_arity) - -## test_hash() [](#method-i-test_hash) - -## test_hash2() [](#method-i-test_hash2) - -## test_hash_bignum_hash() [](#method-i-test_hash_bignum_hash) - -## test_hash_hash() [](#method-i-test_hash_hash) - -## test_hash_popped() [](#method-i-test_hash_popped) - -## test_hash_recursion_independent_of_mid() [](#method-i-test_hash_recursion_independent_of_mid) -Previously this test would fail because rb_hash inside opt_aref would look at -the current method name - -## test_huge_iter_level() [](#method-i-test_huge_iter_level) - -## test_include?() [](#method-i-test_include?) - -**@return** [Boolean] - -## test_inspect() [](#method-i-test_inspect) - -## test_inverse_hash() [](#method-i-test_inverse_hash) - -## test_invert() [](#method-i-test_invert) - -## test_keep_if() [](#method-i-test_keep_if) - -## test_key() [](#method-i-test_key) - -## test_key2?() [](#method-i-test_key2?) - -**@return** [Boolean] - -## test_key?() [](#method-i-test_key?) - -**@return** [Boolean] - -## test_keys() [](#method-i-test_keys) - -## test_length() [](#method-i-test_length) - -## test_member?() [](#method-i-test_member?) - -**@return** [Boolean] - -## test_merge() [](#method-i-test_merge) - -## test_merge!() [](#method-i-test_merge!) - -## test_merge_on_identhash() [](#method-i-test_merge_on_identhash) - -## test_rassoc() [](#method-i-test_rassoc) - -## test_recursive_hash_value_array() [](#method-i-test_recursive_hash_value_array) - -## test_recursive_hash_value_array_hash() [](#method-i-test_recursive_hash_value_array_hash) - -## test_recursive_hash_value_hash_array() [](#method-i-test_recursive_hash_value_hash_array) - -## test_recursive_hash_value_struct() [](#method-i-test_recursive_hash_value_struct) - -## test_recursive_key() [](#method-i-test_recursive_key) - -## test_rehash() [](#method-i-test_rehash) - -## test_rehash2() [](#method-i-test_rehash2) - -## test_reject() [](#method-i-test_reject) - -## test_reject!() [](#method-i-test_reject!) - -## test_reject_bang2() [](#method-i-test_reject_bang2) - -## test_reject_on_identhash() [](#method-i-test_reject_on_identhash) - -## test_replace() [](#method-i-test_replace) - -## test_replace2() [](#method-i-test_replace2) - -## test_replace_bug9230() [](#method-i-test_replace_bug9230) - -## test_s_AREF_duplicated_key() [](#method-i-test_s_AREF_duplicated_key) - -## test_s_AREF_from_hash() [](#method-i-test_s_AREF_from_hash) - -## test_s_AREF_from_list() [](#method-i-test_s_AREF_from_list) - -## test_s_AREF_from_pairs() [](#method-i-test_s_AREF_from_pairs) - -## test_s_AREF_frozen_key_id() [](#method-i-test_s_AREF_frozen_key_id) - -## test_s_AREF_key_tampering() [](#method-i-test_s_AREF_key_tampering) - -## test_s_new() [](#method-i-test_s_new) - -## test_same_key() [](#method-i-test_same_key) - -## test_select() [](#method-i-test_select) - -## test_select!() [](#method-i-test_select!) - -## test_select_on_identhash() [](#method-i-test_select_on_identhash) - -## test_self_initialize_copy() [](#method-i-test_self_initialize_copy) - -## test_shift() [](#method-i-test_shift) - -## test_shift2() [](#method-i-test_shift2) - -## test_shift_for_empty_hash() [](#method-i-test_shift_for_empty_hash) - -## test_shift_none() [](#method-i-test_shift_none) - -## test_size() [](#method-i-test_size) - -## test_size2() [](#method-i-test_size2) - -## test_slice() [](#method-i-test_slice) - -## test_slice_on_identhash() [](#method-i-test_slice_on_identhash) - -## test_sort() [](#method-i-test_sort) - -## test_st_literal_memory_leak() [](#method-i-test_st_literal_memory_leak) - -## test_store() [](#method-i-test_store) - -## test_threaded_iter_level() [](#method-i-test_threaded_iter_level) - -## test_to_a() [](#method-i-test_to_a) - -## test_to_h() [](#method-i-test_to_h) - -## test_to_h_block() [](#method-i-test_to_h_block) - -## test_to_h_default_proc() [](#method-i-test_to_h_default_proc) - -## test_to_h_default_value() [](#method-i-test_to_h_default_value) - -## test_to_h_instance_variable() [](#method-i-test_to_h_instance_variable) - -## test_to_hash() [](#method-i-test_to_hash) - -## test_to_proc() [](#method-i-test_to_proc) - -## test_to_s() [](#method-i-test_to_s) - -## test_transform_keys() [](#method-i-test_transform_keys) - -## test_transform_keys_bang() [](#method-i-test_transform_keys_bang) - -## test_transform_keys_on_identhash() [](#method-i-test_transform_keys_on_identhash) - -## test_transform_values() [](#method-i-test_transform_values) - -## test_transform_values_bang() [](#method-i-test_transform_values_bang) - -## test_transform_values_on_identhash() [](#method-i-test_transform_values_on_identhash) - -## test_try_convert() [](#method-i-test_try_convert) - -## test_update() [](#method-i-test_update) - -## test_update2() [](#method-i-test_update2) - -## test_update3() [](#method-i-test_update3) - -## test_update4() [](#method-i-test_update4) - -## test_update5() [](#method-i-test_update5) - -## test_update_on_identhash() [](#method-i-test_update_on_identhash) - -## test_value2?() [](#method-i-test_value2?) - -**@return** [Boolean] - -## test_value?() [](#method-i-test_value?) - -**@return** [Boolean] - -## test_values() [](#method-i-test_values) - -## test_values_at() [](#method-i-test_values_at) - diff --git a/example/ruby/TestHash/ObjWithHash.md b/example/ruby/TestHash/ObjWithHash.md deleted file mode 100644 index aeeb4bd..0000000 --- a/example/ruby/TestHash/ObjWithHash.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: TestHash::ObjWithHash -**Inherits:** Object - - - - -# Attributes -## hash[RW] [](#attribute-i-hash) -Returns the value of attribute hash. - -## value[RW] [](#attribute-i-value) -Returns the value of attribute value. - - -#Instance Methods -## eql?(other) [](#method-i-eql?) - -**@return** [Boolean] - -## initialize(value, hash) [](#method-i-initialize) - -**@return** [ObjWithHash] a new instance of ObjWithHash - diff --git a/example/ruby/TestHash/TestSubHash.md b/example/ruby/TestHash/TestSubHash.md deleted file mode 100644 index 7712496..0000000 --- a/example/ruby/TestHash/TestSubHash.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestHash::TestSubHash -**Inherits:** TestHash - - - - - -#Instance Methods -## setup() [](#method-i-setup) - diff --git a/example/ruby/TestHash/TestSubHash/SubHash.md b/example/ruby/TestHash/TestSubHash/SubHash.md deleted file mode 100644 index f55612e..0000000 --- a/example/ruby/TestHash/TestSubHash/SubHash.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestHash::TestSubHash::SubHash -**Inherits:** Hash - - - - - diff --git a/example/ruby/TestHashOnly.md b/example/ruby/TestHashOnly.md deleted file mode 100644 index 668293d..0000000 --- a/example/ruby/TestHashOnly.md +++ /dev/null @@ -1,100 +0,0 @@ -# Class: TestHashOnly -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## ar2st_object() [](#method-i-ar2st_object) - -## assert_hash_does_not_rehash() [](#method-i-assert_hash_does_not_rehash) - -**@yield** [hash] - -## assert_hash_random(obj, dumpobj.inspect) [](#method-i-assert_hash_random) - -## check_flagged_hash(k::NG) [](#method-i-check_flagged_hash) - -## hash_iter_recursion(h, level) [](#method-i-hash_iter_recursion) - -## test_AREF_fstring_key() [](#method-i-test_AREF_fstring_key) - -## test_AREF_fstring_key_default_proc() [](#method-i-test_AREF_fstring_key_default_proc) - -## test_ASET_fstring_key() [](#method-i-test_ASET_fstring_key) - -## test_ASET_fstring_non_literal_key() [](#method-i-test_ASET_fstring_non_literal_key) - -## test_NEWHASH_fstring_key() [](#method-i-test_NEWHASH_fstring_key) - -## test_any_hash_fixable() [](#method-i-test_any_hash_fixable) - -## test_ar2st_delete() [](#method-i-test_ar2st_delete) - -## test_ar2st_insert() [](#method-i-test_ar2st_insert) - -## test_ar2st_lookup() [](#method-i-test_ar2st_lookup) - -## test_ar_hash_to_st_hash() [](#method-i-test_ar_hash_to_st_hash) - -## test_bad_initialize_copy() [](#method-i-test_bad_initialize_copy) - -## test_broken_hash_value() [](#method-i-test_broken_hash_value) - -## test_bug_12706() [](#method-i-test_bug_12706) - -## test_compare_by_id_memory_leak() [](#method-i-test_compare_by_id_memory_leak) - -## test_compare_by_identity_during_iteration() [](#method-i-test_compare_by_identity_during_iteration) - -## test_dup_will_not_rehash() [](#method-i-test_dup_will_not_rehash) - -## test_exception_in_rehash_memory_leak() [](#method-i-test_exception_in_rehash_memory_leak) - -## test_float_hash_random() [](#method-i-test_float_hash_random) - -## test_hash_aref_fstring_identity() [](#method-i-test_hash_aref_fstring_identity) - -## test_hash_aset_fstring_identity() [](#method-i-test_hash_aset_fstring_identity) - -## test_initialize_wrong_arguments() [](#method-i-test_initialize_wrong_arguments) - -## test_integer_hash_random() [](#method-i-test_integer_hash_random) - -## test_iterlevel_in_ivar_bug19589() [](#method-i-test_iterlevel_in_ivar_bug19589) - -## test_label_syntax() [](#method-i-test_label_syntax) - -## test_memory_size_after_delete() [](#method-i-test_memory_size_after_delete) - -## test_nil_to_h() [](#method-i-test_nil_to_h) - -## test_rehash_memory_leak() [](#method-i-test_rehash_memory_leak) - -## test_replace_bug15358() [](#method-i-test_replace_bug15358) - -## test_replace_memory_leak() [](#method-i-test_replace_memory_leak) - -## test_replace_st_with_ar() [](#method-i-test_replace_st_with_ar) - -## test_reserved_hash_val() [](#method-i-test_reserved_hash_val) - -## test_ruby2_keywords_hash() [](#method-i-test_ruby2_keywords_hash) - -## test_ruby2_keywords_hash?() [](#method-i-test_ruby2_keywords_hash?) - -**@return** [Boolean] - -## test_select_reject_will_not_rehash() [](#method-i-test_select_reject_will_not_rehash) - -## test_st_literal_memory_leak() [](#method-i-test_st_literal_memory_leak) - -## test_string_hash_random() [](#method-i-test_string_hash_random) - -## test_symbol_hash_random() [](#method-i-test_symbol_hash_random) - -## test_try_convert() [](#method-i-test_try_convert) - -## test_wrapper() [](#method-i-test_wrapper) - diff --git a/example/ruby/TestHideSkip.md b/example/ruby/TestHideSkip.md deleted file mode 100644 index 7ddd4ee..0000000 --- a/example/ruby/TestHideSkip.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestHideSkip -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_hideskip() [](#method-i-test_hideskip) - diff --git a/example/ruby/TestHung.md b/example/ruby/TestHung.md deleted file mode 100644 index 4e2d529..0000000 --- a/example/ruby/TestHung.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestHung -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_hungup_at_worker() [](#method-i-test_hungup_at_worker) - -## test_success_at_worker() [](#method-i-test_success_at_worker) - diff --git a/example/ruby/TestIO.md b/example/ruby/TestIO.md deleted file mode 100644 index 1d0c510..0000000 --- a/example/ruby/TestIO.md +++ /dev/null @@ -1,574 +0,0 @@ -# Class: TestIO -**Inherits:** Test::Unit::TestCase - -**Extended by:** TestIO::Feature - -**Includes:** TestIO::Feature - - - - -# Class Methods -## have_close_on_exec?() [](#method-c-have_close_on_exec?) -**@return** [Boolean] - -## have_nonblock?() [](#method-c-have_nonblock?) -**@return** [Boolean] - - -#Instance Methods -## assert_buffer_not_raise_shared_string_error() [](#method-i-assert_buffer_not_raise_shared_string_error) - -## can_seek_data(f) [](#method-i-can_seek_data) - -## have_close_on_exec?() [](#method-i-have_close_on_exec?) - -**@return** [Boolean] - -## have_nonblock?() [](#method-i-have_nonblock?) - -**@return** [Boolean] - -## make_tempfile() [](#method-i-make_tempfile) - -## make_tempfile_for_encoding() [](#method-i-make_tempfile_for_encoding) - -## mkcdtmpdir() [](#method-i-mkcdtmpdir) - -## os_and_fs(path) [](#method-i-os_and_fs) - -## pipe(wp, rp) [](#method-i-pipe) - -## ruby(*args) [](#method-i-ruby) - -## test_DATA_binmode() [](#method-i-test_DATA_binmode) - -## test_advise() [](#method-i-test_advise) - -## test_advise_pipe() [](#method-i-test_advise_pipe) - -## test_autoclose() [](#method-i-test_autoclose) - -## test_autoclose_false_closed_by_finalizer() [](#method-i-test_autoclose_false_closed_by_finalizer) - -## test_autoclose_true_closed_by_finalizer() [](#method-i-test_autoclose_true_closed_by_finalizer) - -## test_binmode_after_closed() [](#method-i-test_binmode_after_closed) - -## test_binmode_pipe() [](#method-i-test_binmode_pipe) - -## test_cloexec() [](#method-i-test_cloexec) - -## test_close_on_exec() [](#method-i-test_close_on_exec) - -## test_close_read() [](#method-i-test_close_read) - -## test_close_read_non_readable() [](#method-i-test_close_read_non_readable) - -## test_close_read_pipe() [](#method-i-test_close_read_pipe) - -## test_close_read_write_separately() [](#method-i-test_close_read_write_separately) - -## test_close_twice() [](#method-i-test_close_twice) - -## test_close_uninitialized() [](#method-i-test_close_uninitialized) - -## test_close_write() [](#method-i-test_close_write) - -## test_close_write_non_readable() [](#method-i-test_close_write_non_readable) - -## test_closed_stream_in_rescue() [](#method-i-test_closed_stream_in_rescue) - -## test_copy_stream_append() [](#method-i-test_copy_stream_append) - -## test_copy_stream_append_to_nonempty() [](#method-i-test_copy_stream_append_to_nonempty) - -## test_copy_stream_bigcontent() [](#method-i-test_copy_stream_bigcontent) - -## test_copy_stream_bigcontent_chop() [](#method-i-test_copy_stream_bigcontent_chop) - -## test_copy_stream_bigcontent_fpos() [](#method-i-test_copy_stream_bigcontent_fpos) - -## test_copy_stream_bigcontent_mid() [](#method-i-test_copy_stream_bigcontent_mid) - -## test_copy_stream_broken_src_read_eof() [](#method-i-test_copy_stream_broken_src_read_eof) - -## test_copy_stream_closed_pipe() [](#method-i-test_copy_stream_closed_pipe) - -## test_copy_stream_dst_rbuf() [](#method-i-test_copy_stream_dst_rbuf) - -## test_copy_stream_file_to_pipe() [](#method-i-test_copy_stream_file_to_pipe) - -## test_copy_stream_fname_to_strio() [](#method-i-test_copy_stream_fname_to_strio) - -## test_copy_stream_io_to_rot13() [](#method-i-test_copy_stream_io_to_rot13) - -## test_copy_stream_io_to_strio() [](#method-i-test_copy_stream_io_to_strio) - -## test_copy_stream_megacontent_file_to_pipe() [](#method-i-test_copy_stream_megacontent_file_to_pipe) - -## test_copy_stream_megacontent_nonblock() [](#method-i-test_copy_stream_megacontent_nonblock) - -## test_copy_stream_megacontent_pipe_to_file() [](#method-i-test_copy_stream_megacontent_pipe_to_file) - -## test_copy_stream_no_busy_wait() [](#method-i-test_copy_stream_no_busy_wait) - -## test_copy_stream_noent() [](#method-i-test_copy_stream_noent) - -## test_copy_stream_pathname_to_pathname() [](#method-i-test_copy_stream_pathname_to_pathname) - -## test_copy_stream_pipe() [](#method-i-test_copy_stream_pipe) - -## test_copy_stream_pipe_nonblock() [](#method-i-test_copy_stream_pipe_nonblock) - -## test_copy_stream_pipe_to_file() [](#method-i-test_copy_stream_pipe_to_file) - -## test_copy_stream_rbuf() [](#method-i-test_copy_stream_rbuf) - -## test_copy_stream_read_in_binmode() [](#method-i-test_copy_stream_read_in_binmode) - -## test_copy_stream_read_pipe() [](#method-i-test_copy_stream_read_pipe) - -## test_copy_stream_rot13_to_io() [](#method-i-test_copy_stream_rot13_to_io) - -## test_copy_stream_rot13_to_rot13() [](#method-i-test_copy_stream_rot13_to_rot13) - -## test_copy_stream_small() [](#method-i-test_copy_stream_small) - -## test_copy_stream_smaller() [](#method-i-test_copy_stream_smaller) - -## test_copy_stream_socket1() [](#method-i-test_copy_stream_socket1) - -## test_copy_stream_socket2() [](#method-i-test_copy_stream_socket2) - -## test_copy_stream_socket3() [](#method-i-test_copy_stream_socket3) - -## test_copy_stream_socket4() [](#method-i-test_copy_stream_socket4) - -## test_copy_stream_socket5() [](#method-i-test_copy_stream_socket5) - -## test_copy_stream_socket6() [](#method-i-test_copy_stream_socket6) - -## test_copy_stream_socket7() [](#method-i-test_copy_stream_socket7) - -## test_copy_stream_src_wbuf() [](#method-i-test_copy_stream_src_wbuf) - -## test_copy_stream_strio() [](#method-i-test_copy_stream_strio) - -## test_copy_stream_strio_flush() [](#method-i-test_copy_stream_strio_flush) - -## test_copy_stream_strio_len() [](#method-i-test_copy_stream_strio_len) - -## test_copy_stream_strio_off() [](#method-i-test_copy_stream_strio_off) - -## test_copy_stream_strio_rbuf() [](#method-i-test_copy_stream_strio_rbuf) - -## test_copy_stream_strio_to_fname() [](#method-i-test_copy_stream_strio_to_fname) - -## test_copy_stream_strio_to_io() [](#method-i-test_copy_stream_strio_to_io) - -## test_copy_stream_strio_to_tempfile() [](#method-i-test_copy_stream_strio_to_tempfile) - -## test_copy_stream_to_duplex_io() [](#method-i-test_copy_stream_to_duplex_io) - -## test_copy_stream_write_in_binmode() [](#method-i-test_copy_stream_write_in_binmode) - -## test_copy_stream_write_pipe() [](#method-i-test_copy_stream_write_pipe) - -## test_cross_thread_close_fd() [](#method-i-test_cross_thread_close_fd) - -## test_cross_thread_close_stdio() [](#method-i-test_cross_thread_close_stdio) - -## test_display() [](#method-i-test_display) - -## test_dup() [](#method-i-test_dup) - -## test_dup_many() [](#method-i-test_dup_many) - -## test_dup_timeout() [](#method-i-test_dup_timeout) - -## test_each_byte() [](#method-i-test_each_byte) - -## test_each_byte2() [](#method-i-test_each_byte2) - -## test_each_byte_closed() [](#method-i-test_each_byte_closed) - -## test_each_byte_with_seek() [](#method-i-test_each_byte_with_seek) - -## test_each_char() [](#method-i-test_each_char) - -## test_each_char2() [](#method-i-test_each_char2) - -## test_each_codepoint() [](#method-i-test_each_codepoint) - -## test_each_codepoint_closed() [](#method-i-test_each_codepoint_closed) - -## test_each_line() [](#method-i-test_each_line) - -## test_each_line_limit_0() [](#method-i-test_each_line_limit_0) - -## test_exception_at_close() [](#method-i-test_exception_at_close) - -## test_exclusive_mode() [](#method-i-test_exclusive_mode) - -## test_explicit_path() [](#method-i-test_explicit_path) - -## test_external_encoding_index() [](#method-i-test_external_encoding_index) - -## test_fcntl_dupfd() [](#method-i-test_fcntl_dupfd) - -## test_fcntl_lock_freebsd() [](#method-i-test_fcntl_lock_freebsd) - -## test_fcntl_lock_linux() [](#method-i-test_fcntl_lock_linux) - -## test_flag() [](#method-i-test_flag) - -## test_flush_in_finalizer1() [](#method-i-test_flush_in_finalizer1) - -## test_flush_in_finalizer2() [](#method-i-test_flush_in_finalizer2) - -## test_foreach() [](#method-i-test_foreach) - -## test_foreach_limit_conversion() [](#method-i-test_foreach_limit_conversion) - -## test_foreach_limit_invalid() [](#method-i-test_foreach_limit_invalid) - -## test_foreach_rs_conversion() [](#method-i-test_foreach_rs_conversion) - -## test_foreach_rs_invalid() [](#method-i-test_foreach_rs_invalid) - -## test_frozen_autoclose() [](#method-i-test_frozen_autoclose) - -## test_frozen_fileno() [](#method-i-test_frozen_fileno) - -## test_gets() [](#method-i-test_gets) - -## test_gets_chomp_default_rs() [](#method-i-test_gets_chomp_default_rs) - -## test_gets_chomp_paragraph() [](#method-i-test_gets_chomp_paragraph) - -## test_gets_chomp_rs() [](#method-i-test_gets_chomp_rs) - -## test_gets_chomp_rs_nil() [](#method-i-test_gets_chomp_rs_nil) - -## test_gets_default_rs() [](#method-i-test_gets_default_rs) - -## test_gets_limit_extra_arg() [](#method-i-test_gets_limit_extra_arg) - -## test_gets_paragraph() [](#method-i-test_gets_paragraph) - -## test_gets_rs() [](#method-i-test_gets_rs) - -## test_gets_rs_377() [](#method-i-test_gets_rs_377) - -## test_gets_rs_nil() [](#method-i-test_gets_rs_nil) - -## test_initialize() [](#method-i-test_initialize) - -## test_inspect() [](#method-i-test_inspect) - -## test_invalid_advise() [](#method-i-test_invalid_advise) - -## test_io_select_with_many_files() [](#method-i-test_io_select_with_many_files) - -## test_ioctl_linux() [](#method-i-test_ioctl_linux) - -## test_ioctl_linux2() [](#method-i-test_ioctl_linux2) - -## test_marshal_closed_io() [](#method-i-test_marshal_closed_io) - -## test_new_with_block() [](#method-i-test_new_with_block) - -## test_nofollow() [](#method-i-test_nofollow) - -## test_open_fifo_does_not_block_other_threads() [](#method-i-test_open_fifo_does_not_block_other_threads) - -## test_open_fifo_restart_at_signal_intterupt() [](#method-i-test_open_fifo_restart_at_signal_intterupt) - -## test_open_flag() [](#method-i-test_open_flag) - -## test_open_flag_binary() [](#method-i-test_open_flag_binary) - -## test_open_mode() [](#method-i-test_open_mode) - -## test_open_pipe() [](#method-i-test_open_pipe) - -## test_open_redirect() [](#method-i-test_open_redirect) - -## test_open_redirect_keyword() [](#method-i-test_open_redirect_keyword) - -## test_pid() [](#method-i-test_pid) - -## test_pid_after_close_read() [](#method-i-test_pid_after_close_read) - -## test_pipe() [](#method-i-test_pipe) - -## test_pipe_block() [](#method-i-test_pipe_block) - -## test_pipe_block_close() [](#method-i-test_pipe_block_close) - -## test_pos() [](#method-i-test_pos) - -## test_pos_with_getc() [](#method-i-test_pos_with_getc) - -## test_pread() [](#method-i-test_pread) - -## test_print() [](#method-i-test_print) - -## test_print_separators() [](#method-i-test_print_separators) - -## test_printf() [](#method-i-test_printf) - -## test_putc() [](#method-i-test_putc) - -## test_puts_old_write() [](#method-i-test_puts_old_write) - -## test_puts_parallel() [](#method-i-test_puts_parallel) - -## test_puts_recursive_array() [](#method-i-test_puts_recursive_array) - -## test_puts_recursive_ary() [](#method-i-test_puts_recursive_ary) - -## test_pwrite() [](#method-i-test_pwrite) - -## test_race_between_read() [](#method-i-test_race_between_read) - -## test_race_closed_stream() [](#method-i-test_race_closed_stream) - -## test_race_gets_and_close() [](#method-i-test_race_gets_and_close) - -## test_read() [](#method-i-test_read) - -## test_read_32bit_boundary() [](#method-i-test_read_32bit_boundary) - -## test_read_buffer_error() [](#method-i-test_read_buffer_error) - -## test_read_buffer_not_raise_shared_string_error() [](#method-i-test_read_buffer_not_raise_shared_string_error) - -## test_read_command() [](#method-i-test_read_command) - -## test_read_lock() [](#method-i-test_read_lock) - -## test_read_nonblock_error() [](#method-i-test_read_nonblock_error) - -## test_read_nonblock_file() [](#method-i-test_read_nonblock_file) - -## test_read_nonblock_invalid_exception() [](#method-i-test_read_nonblock_invalid_exception) - -## test_read_nonblock_no_exceptions() [](#method-i-test_read_nonblock_no_exceptions) - -## test_read_nonblock_with_buffer_no_exceptions() [](#method-i-test_read_nonblock_with_buffer_no_exceptions) - -## test_read_nonblock_with_not_empty_buffer() [](#method-i-test_read_nonblock_with_not_empty_buffer) - -## test_read_nonblock_zero_size() [](#method-i-test_read_nonblock_zero_size) - -## test_read_unlocktmp_ensure() [](#method-i-test_read_unlocktmp_ensure) - -## test_read_with_not_empty_buffer() [](#method-i-test_read_with_not_empty_buffer) - -## test_read_zero_size() [](#method-i-test_read_zero_size) - -## test_readbyte() [](#method-i-test_readbyte) - -## test_readchar() [](#method-i-test_readchar) - -## test_readline2() [](#method-i-test_readline2) - -## test_readline_bad_param_raises() [](#method-i-test_readline_bad_param_raises) - -## test_readline_chomp_true() [](#method-i-test_readline_chomp_true) - -## test_readline_incompatible_rs() [](#method-i-test_readline_incompatible_rs) - -## test_readline_limit_nonascii() [](#method-i-test_readline_limit_nonascii) - -## test_readline_limit_without_separator() [](#method-i-test_readline_limit_without_separator) - -## test_readline_raises() [](#method-i-test_readline_raises) - -## test_readline_separators() [](#method-i-test_readline_separators) - -## test_readline_separators_limits() [](#method-i-test_readline_separators_limits) - -## test_readlines() [](#method-i-test_readlines) - -## test_readlines_limit_0() [](#method-i-test_readlines_limit_0) - -## test_readlines_limit_invalid() [](#method-i-test_readlines_limit_invalid) - -## test_readlines_rs_invalid() [](#method-i-test_readlines_rs_invalid) - -## test_readpartial() [](#method-i-test_readpartial) - -## test_readpartial_bad_args() [](#method-i-test_readpartial_bad_args) - -## test_readpartial_buffer_error() [](#method-i-test_readpartial_buffer_error) - -## test_readpartial_buffer_not_raise_shared_string_error() [](#method-i-test_readpartial_buffer_not_raise_shared_string_error) - -## test_readpartial_lock() [](#method-i-test_readpartial_lock) - -## test_readpartial_locktmp() [](#method-i-test_readpartial_locktmp) - -## test_readpartial_pos() [](#method-i-test_readpartial_pos) - -## test_readpartial_unlocktmp_ensure() [](#method-i-test_readpartial_unlocktmp_ensure) - -## test_readpartial_with_not_empty_buffer() [](#method-i-test_readpartial_with_not_empty_buffer) - -## test_readpartial_zero_size() [](#method-i-test_readpartial_zero_size) - -## test_recycled_fd_close() [](#method-i-test_recycled_fd_close) - -## test_reinitialize() [](#method-i-test_reinitialize) - -## test_reopen() [](#method-i-test_reopen) - -## test_reopen_binmode() [](#method-i-test_reopen_binmode) - -## test_reopen_encoding() [](#method-i-test_reopen_encoding) - -## test_reopen_encoding_from_io() [](#method-i-test_reopen_encoding_from_io) - -## test_reopen_inherit() [](#method-i-test_reopen_inherit) - -## test_reopen_ivar() [](#method-i-test_reopen_ivar) - -## test_reopen_mode() [](#method-i-test_reopen_mode) - -## test_reopen_opt() [](#method-i-test_reopen_opt) - -## test_reopen_opt_encoding() [](#method-i-test_reopen_opt_encoding) - -## test_reopen_stdio() [](#method-i-test_reopen_stdio) - -## test_rubydev33072() [](#method-i-test_rubydev33072) - -## test_s_binread_does_not_leak_with_invalid_offset() [](#method-i-test_s_binread_does_not_leak_with_invalid_offset) - -## test_s_binwrite() [](#method-i-test_s_binwrite) - -## test_s_read() [](#method-i-test_s_read) - -## test_s_readlines() [](#method-i-test_s_readlines) - -## test_s_write() [](#method-i-test_s_write) - -## test_seek() [](#method-i-test_seek) - -## test_seek_symwhence() [](#method-i-test_seek_symwhence) - -## test_select_exceptfds() [](#method-i-test_select_exceptfds) - -## test_select_memory_leak() [](#method-i-test_select_memory_leak) - -## test_set_lineno() [](#method-i-test_set_lineno) - -## test_set_lineno_gets() [](#method-i-test_set_lineno_gets) - -## test_set_lineno_readline() [](#method-i-test_set_lineno_readline) - -## test_set_stdout() [](#method-i-test_set_stdout) - -## test_setpos() [](#method-i-test_setpos) - -## test_single_exception_on_close() [](#method-i-test_single_exception_on_close) - -## test_std_fileno() [](#method-i-test_std_fileno) - -## test_stdout_to_closed_pipe() [](#method-i-test_stdout_to_closed_pipe) - -## test_sysopen() [](#method-i-test_sysopen) - -## test_sysread() [](#method-i-test_sysread) - -## test_sysread_buffer_not_raise_shared_string_error() [](#method-i-test_sysread_buffer_not_raise_shared_string_error) - -## test_sysread_locktmp() [](#method-i-test_sysread_locktmp) - -## test_sysread_unlocktmp_ensure() [](#method-i-test_sysread_unlocktmp_ensure) - -## test_sysread_with_negative_length() [](#method-i-test_sysread_with_negative_length) - -## test_sysread_with_not_empty_buffer() [](#method-i-test_sysread_with_not_empty_buffer) - -## test_sysseek() [](#method-i-test_sysseek) - -## test_syswrite() [](#method-i-test_syswrite) - -## test_threaded_flush() [](#method-i-test_threaded_flush) - -## test_try_convert() [](#method-i-test_try_convert) - -## test_ungetbyte() [](#method-i-test_ungetbyte) - -## test_ungetbyte_with_seek() [](#method-i-test_ungetbyte_with_seek) - -## test_ungetc() [](#method-i-test_ungetc) -This test cause SEGV. - -## test_ungetc2() [](#method-i-test_ungetc2) - -## test_ungetc_with_seek() [](#method-i-test_ungetc_with_seek) - -## test_uninitialized() [](#method-i-test_uninitialized) - -## test_warn() [](#method-i-test_warn) - -## test_write_32bit_boundary() [](#method-i-test_write_32bit_boundary) - -## test_write_buffered_with_multiple_arguments() [](#method-i-test_write_buffered_with_multiple_arguments) - -## test_write_epipe_nosync() [](#method-i-test_write_epipe_nosync) - -## test_write_no_args() [](#method-i-test_write_no_args) - -## test_write_non_writable() [](#method-i-test_write_non_writable) - -## test_write_nonblock() [](#method-i-test_write_nonblock) - -## test_write_nonblock_error() [](#method-i-test_write_nonblock_error) - -## test_write_nonblock_file() [](#method-i-test_write_nonblock_file) - -## test_write_nonblock_invalid_exception() [](#method-i-test_write_nonblock_invalid_exception) - -## test_write_nonblock_no_exceptions() [](#method-i-test_write_nonblock_no_exceptions) - -## test_write_nonblock_simple_no_exceptions() [](#method-i-test_write_nonblock_simple_no_exceptions) - -## test_write_with_many_arguments() [](#method-i-test_write_with_many_arguments) - -## test_write_with_multiple_arguments() [](#method-i-test_write_with_multiple_arguments) - -## test_write_with_multiple_arguments_and_buffer() [](#method-i-test_write_with_multiple_arguments_and_buffer) - -## test_write_with_multiple_nonstring_arguments() [](#method-i-test_write_with_multiple_nonstring_arguments) - -## trapping_usr2() [](#method-i-trapping_usr2) - -## try_fdopen(fd, autoclosetrue, level50) [](#method-i-try_fdopen) - -## with_bigcontent() [](#method-i-with_bigcontent) - -**@yield** ["abc" * 123456] - -## with_bigsrc() [](#method-i-with_bigsrc) - -## with_megacontent() [](#method-i-with_megacontent) - -**@yield** ["abc" * 1234567] - -## with_megasrc() [](#method-i-with_megasrc) - -## with_pipe() [](#method-i-with_pipe) - -## with_pipecontent() [](#method-i-with_pipecontent) - -## with_read_pipe(content) [](#method-i-with_read_pipe) - -## with_socketpair() [](#method-i-with_socketpair) - -## with_srccontent(content"baz") [](#method-i-with_srccontent) - diff --git a/example/ruby/TestIO/Bug5237.md b/example/ruby/TestIO/Bug5237.md deleted file mode 100644 index 9f7a28a..0000000 --- a/example/ruby/TestIO/Bug5237.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIO::Bug5237 -**Inherits:** Object - - - - -# Attributes -## count[RW] [](#attribute-i-count) -Returns the value of attribute count. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Bug5237] a new instance of Bug5237 - -## read(bytes, buffer) [](#method-i-read) - diff --git a/example/ruby/TestIO/Feature.md b/example/ruby/TestIO/Feature.md deleted file mode 100644 index 96f0a15..0000000 --- a/example/ruby/TestIO/Feature.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: TestIO::Feature - - - - - -#Instance Methods -## have_close_on_exec?() [](#method-i-have_close_on_exec?) - -**@return** [Boolean] - -## have_nonblock?() [](#method-i-have_nonblock?) - -**@return** [Boolean] - diff --git a/example/ruby/TestIO/Rot13IO.md b/example/ruby/TestIO/Rot13IO.md deleted file mode 100644 index 39db4d7..0000000 --- a/example/ruby/TestIO/Rot13IO.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIO::Rot13IO -**Inherits:** Object - - - - - -#Instance Methods -## initialize(io) [](#method-i-initialize) - -**@return** [Rot13IO] a new instance of Rot13IO - -## readpartial(*args) [](#method-i-readpartial) - -## to_io() [](#method-i-to_io) - -## write(str) [](#method-i-write) - diff --git a/example/ruby/TestIOBuffer.md b/example/ruby/TestIOBuffer.md deleted file mode 100644 index 7e27d97..0000000 --- a/example/ruby/TestIOBuffer.md +++ /dev/null @@ -1,138 +0,0 @@ -# Class: TestIOBuffer -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_negative(value) [](#method-i-assert_negative) - -## assert_positive(value) [](#method-i-assert_positive) - -## hello_world_tempfile(repeats1) [](#method-i-hello_world_tempfile) - -## test_clear() [](#method-i-test_clear) - -## test_compare_different_size() [](#method-i-test_compare_different_size) - -## test_compare_same_size() [](#method-i-test_compare_same_size) - -## test_compare_zero_length() [](#method-i-test_compare_zero_length) - -## test_copy_null_destination() [](#method-i-test_copy_null_destination) - -## test_copy_null_source() [](#method-i-test_copy_null_source) - -## test_copy_overlapped_bwd() [](#method-i-test_copy_overlapped_bwd) - -## test_copy_overlapped_fwd() [](#method-i-test_copy_overlapped_fwd) - -## test_default_size() [](#method-i-test_default_size) - -## test_each() [](#method-i-test_each) - -## test_each_byte() [](#method-i-test_each_byte) - -## test_endian() [](#method-i-test_endian) - -## test_file_mapped() [](#method-i-test_file_mapped) - -## test_file_mapped_invalid() [](#method-i-test_file_mapped_invalid) - -## test_flags() [](#method-i-test_flags) - -## test_get_set_value() [](#method-i-test_get_set_value) - -## test_get_set_values() [](#method-i-test_get_set_values) - -## test_get_string() [](#method-i-test_get_string) - -## test_inplace_operators() [](#method-i-test_inplace_operators) - -## test_invalidation() [](#method-i-test_invalidation) - -## test_locked() [](#method-i-test_locked) - -## test_new_internal() [](#method-i-test_new_internal) - -## test_new_mapped() [](#method-i-test_new_mapped) - -## test_new_readonly() [](#method-i-test_new_readonly) - -## test_non_string() [](#method-i-test_non_string) - -## test_operators() [](#method-i-test_operators) - -## test_pread() [](#method-i-test_pread) - -## test_pread_offset() [](#method-i-test_pread_offset) - -## test_private() [](#method-i-test_private) - -## test_pwrite() [](#method-i-test_pwrite) - -## test_pwrite_offset() [](#method-i-test_pwrite_offset) - -## test_read() [](#method-i-test_read) - -## test_read_with_length_and_offset() [](#method-i-test_read_with_length_and_offset) - -## test_read_with_with_length() [](#method-i-test_read_with_with_length) - -## test_read_with_with_offset() [](#method-i-test_read_with_with_offset) - -## test_resize_mapped() [](#method-i-test_resize_mapped) - -## test_resize_preserve() [](#method-i-test_resize_preserve) - -## test_resize_zero_external() [](#method-i-test_resize_zero_external) - -## test_resize_zero_internal() [](#method-i-test_resize_zero_internal) - -## test_set_string_null_destination() [](#method-i-test_set_string_null_destination) - -## test_set_string_overlapped_bwd() [](#method-i-test_set_string_overlapped_bwd) - -## test_set_string_overlapped_fwd() [](#method-i-test_set_string_overlapped_fwd) - -## test_shared() [](#method-i-test_shared) - -## test_slice() [](#method-i-test_slice) - -## test_slice_arguments() [](#method-i-test_slice_arguments) - -## test_slice_bounds_error() [](#method-i-test_slice_bounds_error) - -## test_slice_readonly() [](#method-i-test_slice_readonly) - -## test_string() [](#method-i-test_string) - -## test_string_mapped() [](#method-i-test_string_mapped) - -## test_string_mapped_buffer_locked() [](#method-i-test_string_mapped_buffer_locked) - -## test_string_mapped_frozen() [](#method-i-test_string_mapped_frozen) - -## test_string_mapped_mutable() [](#method-i-test_string_mapped_mutable) - -## test_string_negative() [](#method-i-test_string_negative) - -## test_transfer() [](#method-i-test_transfer) - -## test_transfer_in_block() [](#method-i-test_transfer_in_block) - -## test_values() [](#method-i-test_values) - -## test_write() [](#method-i-test_write) - -## test_write_with_length_and_offset() [](#method-i-test_write_with_length_and_offset) - -## test_zero_length_each() [](#method-i-test_zero_length_each) - -## test_zero_length_each_byte() [](#method-i-test_zero_length_each_byte) - -## test_zero_length_get_set_values() [](#method-i-test_zero_length_get_set_values) - -## test_zero_length_get_string() [](#method-i-test_zero_length_get_string) - diff --git a/example/ruby/TestIOConsoleInRactor.md b/example/ruby/TestIOConsoleInRactor.md deleted file mode 100644 index 3915288..0000000 --- a/example/ruby/TestIOConsoleInRactor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIOConsoleInRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_ractor() [](#method-i-test_ractor) - diff --git a/example/ruby/TestIONonblock.md b/example/ruby/TestIONonblock.md deleted file mode 100644 index eed325e..0000000 --- a/example/ruby/TestIONonblock.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestIONonblock -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## flush_test(r, w) [](#method-i-flush_test) - -## test_flush() [](#method-i-test_flush) - -## test_nonblock() [](#method-i-test_nonblock) - diff --git a/example/ruby/TestIOTimeout.md b/example/ruby/TestIOTimeout.md deleted file mode 100644 index 02138de..0000000 --- a/example/ruby/TestIOTimeout.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIOTimeout -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_timeout_attribute() [](#method-i-test_timeout_attribute) - -## test_timeout_gets_exception() [](#method-i-test_timeout_gets_exception) - -## test_timeout_puts() [](#method-i-test_timeout_puts) - -## test_timeout_read_exception() [](#method-i-test_timeout_read_exception) - -## with_pipe() [](#method-i-with_pipe) - diff --git a/example/ruby/TestIOWait.md b/example/ruby/TestIOWait.md deleted file mode 100644 index 95c16d4..0000000 --- a/example/ruby/TestIOWait.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: TestIOWait -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_buffered_ready?() [](#method-i-test_buffered_ready?) - -**@return** [Boolean] - -## test_nread() [](#method-i-test_nread) - -## test_nread_buffered() [](#method-i-test_nread_buffered) - -## test_ready?() [](#method-i-test_ready?) - -**@return** [Boolean] - -## test_wait() [](#method-i-test_wait) - -## test_wait_buffered() [](#method-i-test_wait_buffered) - -## test_wait_eof() [](#method-i-test_wait_eof) - -## test_wait_forever() [](#method-i-test_wait_forever) - -## test_wait_mask_negative() [](#method-i-test_wait_mask_negative) - -## test_wait_mask_readable() [](#method-i-test_wait_mask_readable) - -## test_wait_mask_writable() [](#method-i-test_wait_mask_writable) - -## test_wait_mask_zero() [](#method-i-test_wait_mask_zero) - -## test_wait_readable() [](#method-i-test_wait_readable) - -## test_wait_readable_buffered() [](#method-i-test_wait_readable_buffered) - -## test_wait_readable_eof() [](#method-i-test_wait_readable_eof) - -## test_wait_readable_forever() [](#method-i-test_wait_readable_forever) - -## test_wait_readwrite() [](#method-i-test_wait_readwrite) - -## test_wait_readwrite_timeout() [](#method-i-test_wait_readwrite_timeout) - -## test_wait_writable() [](#method-i-test_wait_writable) - -## test_wait_writable_EPIPE() [](#method-i-test_wait_writable_EPIPE) - -## test_wait_writable_closed() [](#method-i-test_wait_writable_closed) - -## test_wait_writable_timeout() [](#method-i-test_wait_writable_timeout) - diff --git a/example/ruby/TestIOWaitInRactor.md b/example/ruby/TestIOWaitInRactor.md deleted file mode 100644 index 87d8179..0000000 --- a/example/ruby/TestIOWaitInRactor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIOWaitInRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_ractor() [](#method-i-test_ractor) - diff --git a/example/ruby/TestIOWaitUncommon.md b/example/ruby/TestIOWaitUncommon.md deleted file mode 100644 index 135ca39..0000000 --- a/example/ruby/TestIOWaitUncommon.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestIOWaitUncommon -**Inherits:** Test::Unit::TestCase - - -test uncommon device types to check portability problems We may optimize -IO#wait_*able for non-Linux kernels in the future - - - -#Instance Methods -## check_dev(dev, m:wait_readable, mode:m == :wait_readable ? 'r' : 'w', &block) [](#method-i-check_dev) -used to find portability problems because some ppoll implementations are -incomplete and do not work for certain "file" types - -## test_fifo_wait() [](#method-i-test_fifo_wait) - -## test_tty_wait() [](#method-i-test_tty_wait) - -## test_wait_readable_random() [](#method-i-test_wait_readable_random) - -## test_wait_readable_urandom() [](#method-i-test_wait_readable_urandom) - -## test_wait_readable_zero() [](#method-i-test_wait_readable_zero) - -## test_wait_writable_null() [](#method-i-test_wait_writable_null) - diff --git a/example/ruby/TestIO_Console.md b/example/ruby/TestIO_Console.md deleted file mode 100644 index ce54190..0000000 --- a/example/ruby/TestIO_Console.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TestIO_Console -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## set_winsize_setup() [](#method-i-set_winsize_setup) -FreeBSD seems to hang on TTOU when running parallel tests tested on FreeBSD -11.x. - -Solaris gets stuck too, even in non-parallel mode. It occurs only in chkbuild. - It does not occur when running `make test-all` in SSH terminal. - -I suspect that it occurs only when having no TTY. (Parallel mode runs tests in -child processes, so I guess they has no TTY.) But it does not occur in `make -test-all > /dev/null`, so there should be an additional factor, I guess. - -## set_winsize_teardown() [](#method-i-set_winsize_teardown) - -## test_bad_keyword() [](#method-i-test_bad_keyword) - -## test_failed_path() [](#method-i-test_failed_path) - diff --git a/example/ruby/TestIO_M17N.md b/example/ruby/TestIO_M17N.md deleted file mode 100644 index 9e50c48..0000000 --- a/example/ruby/TestIO_M17N.md +++ /dev/null @@ -1,364 +0,0 @@ -# Class: TestIO_M17N -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_str_equal(expected, actual, messagenil) [](#method-i-assert_str_equal) - -## assert_write(expected, mode, *args) [](#method-i-assert_write) - -## encdump(str) [](#method-i-encdump) - -## generate_file(path, content) [](#method-i-generate_file) - -## pipe(*args, wp, rp) [](#method-i-pipe) - -## system_newline() [](#method-i-system_newline) - -## t_write_mode_enc(enc"") [](#method-i-t_write_mode_enc) - -## test_binary() [](#method-i-test_binary) - -## test_binary_mode() [](#method-i-test_binary_mode) - -## test_binmode() [](#method-i-test_binmode) - -## test_binmode2() [](#method-i-test_binmode2) - -## test_binmode3() [](#method-i-test_binmode3) - -## test_binmode_decode_universal_newline() [](#method-i-test_binmode_decode_universal_newline) - -## test_binmode_paragraph_nonasciicompat() [](#method-i-test_binmode_paragraph_nonasciicompat) - -## test_binmode_with_pipe() [](#method-i-test_binmode_with_pipe) - -## test_binmode_write_ascii_incompat_internal() [](#method-i-test_binmode_write_ascii_incompat_internal) - -## test_bom_non_reading() [](#method-i-test_bom_non_reading) - -## test_bom_non_utf() [](#method-i-test_bom_non_utf) - -## test_bom_too_long_utfname() [](#method-i-test_bom_too_long_utfname) - -## test_both_textmode_binmode() [](#method-i-test_both_textmode_binmode) - -## test_cbuf() [](#method-i-test_cbuf) - -## test_cbuf_select() [](#method-i-test_cbuf_select) - -## test_cr_decorator_on_stdout() [](#method-i-test_cr_decorator_on_stdout) - -## test_crlf_decorator_on_stdout() [](#method-i-test_crlf_decorator_on_stdout) - -## test_default_mode_decode_universal_newline_gets() [](#method-i-test_default_mode_decode_universal_newline_gets) - -## test_default_mode_on_dosish() [](#method-i-test_default_mode_on_dosish) - -## test_default_mode_on_unix() [](#method-i-test_default_mode_on_unix) - -## test_default_stdout_stderr_mode() [](#method-i-test_default_stdout_stderr_mode) - -## test_dup() [](#method-i-test_dup) - -## test_dup_undef() [](#method-i-test_dup_undef) - -## test_each_codepoint_need_more() [](#method-i-test_each_codepoint_need_more) - -## test_error_nonascii() [](#method-i-test_error_nonascii) - -## test_file_foreach() [](#method-i-test_file_foreach) - -## test_getc_and_read_with_binmode() [](#method-i-test_getc_and_read_with_binmode) - -## test_getc_ascii_only() [](#method-i-test_getc_ascii_only) - -## test_getc_conversion() [](#method-i-test_getc_conversion) - -## test_getc_invalid() [](#method-i-test_getc_invalid) - -## test_getc_invalid2() [](#method-i-test_getc_invalid2) - -## test_getc_invalid3() [](#method-i-test_getc_invalid3) - -## test_getc_newlineconv() [](#method-i-test_getc_newlineconv) - -## test_getc_newlineconv_invalid() [](#method-i-test_getc_newlineconv_invalid) - -## test_getc_stateful_conversion() [](#method-i-test_getc_stateful_conversion) - -## test_gets_and_read_with_binmode() [](#method-i-test_gets_and_read_with_binmode) - -## test_gets_invalid() [](#method-i-test_gets_invalid) - -## test_gets_limit() [](#method-i-test_gets_limit) - -## test_gets_nil() [](#method-i-test_gets_nil) - -## test_ignored_encoding_option() [](#method-i-test_ignored_encoding_option) - -## test_inspect_nonascii() [](#method-i-test_inspect_nonascii) - -## test_invalid_r() [](#method-i-test_invalid_r) - -## test_invalid_w() [](#method-i-test_invalid_w) - -## test_io_new_enc() [](#method-i-test_io_new_enc) - -## test_lf_decorator_on_stdout() [](#method-i-test_lf_decorator_on_stdout) - -## test_marshal() [](#method-i-test_marshal) - -## test_nonascii_terminator() [](#method-i-test_nonascii_terminator) - -## test_open_ascii() [](#method-i-test_open_ascii) - -## test_open_nonascii() [](#method-i-test_open_nonascii) - -## test_open_pipe_r_enc() [](#method-i-test_open_pipe_r_enc) - -## test_open_pipe_r_enc2() [](#method-i-test_open_pipe_r_enc2) - -## test_open_r() [](#method-i-test_open_r) - -## test_open_r_ascii8bit() [](#method-i-test_open_r_ascii8bit) - -## test_open_r_enc() [](#method-i-test_open_r_enc) - -## test_open_r_enc_enc() [](#method-i-test_open_r_enc_enc) - -## test_open_r_enc_enc_in_opt() [](#method-i-test_open_r_enc_enc_in_opt) - -## test_open_r_enc_in_opt() [](#method-i-test_open_r_enc_in_opt) - -## test_open_r_encname_encname() [](#method-i-test_open_r_encname_encname) - -## test_open_r_encname_encname_in_opt() [](#method-i-test_open_r_encname_encname_in_opt) - -## test_open_r_encname_in_opt() [](#method-i-test_open_r_encname_in_opt) - -## test_open_r_ext_enc_in_opt() [](#method-i-test_open_r_ext_enc_in_opt) - -## test_open_r_ext_encname_in_opt() [](#method-i-test_open_r_ext_encname_in_opt) - -## test_open_r_externalencname_internalencname_in_opt() [](#method-i-test_open_r_externalencname_internalencname_in_opt) - -## test_open_rb() [](#method-i-test_open_rb) - -## test_open_w() [](#method-i-test_open_w) - -## test_open_w_enc() [](#method-i-test_open_w_enc) - -## test_open_w_enc_enc() [](#method-i-test_open_w_enc_enc) - -## test_open_w_enc_enc_in_opt() [](#method-i-test_open_w_enc_enc_in_opt) - -## test_open_w_enc_enc_in_opt2() [](#method-i-test_open_w_enc_enc_in_opt2) - -## test_open_w_enc_enc_perm() [](#method-i-test_open_w_enc_enc_perm) - -## test_open_w_enc_in_opt() [](#method-i-test_open_w_enc_in_opt) - -## test_open_w_enc_in_opt2() [](#method-i-test_open_w_enc_in_opt2) - -## test_open_wb() [](#method-i-test_open_wb) - -## test_pipe() [](#method-i-test_pipe) - -## test_pipe_conversion() [](#method-i-test_pipe_conversion) - -## test_pipe_convert_partial_read() [](#method-i-test_pipe_convert_partial_read) - -## test_pipe_terminator_conversion() [](#method-i-test_pipe_terminator_conversion) - -## test_popen_r_enc() [](#method-i-test_popen_r_enc) - -## test_popen_r_enc_enc() [](#method-i-test_popen_r_enc_enc) - -## test_popen_r_enc_enc_in_opt() [](#method-i-test_popen_r_enc_enc_in_opt) - -## test_popen_r_enc_enc_in_opt2() [](#method-i-test_popen_r_enc_enc_in_opt2) - -## test_popen_r_enc_in_opt() [](#method-i-test_popen_r_enc_in_opt) - -## test_popen_r_enc_in_opt2() [](#method-i-test_popen_r_enc_in_opt2) - -## test_popenv_r_enc_enc_in_opt2() [](#method-i-test_popenv_r_enc_enc_in_opt2) - -## test_pos_dont_move_cursor_position() [](#method-i-test_pos_dont_move_cursor_position) - -## test_pos_with_buffer_end_cr() [](#method-i-test_pos_with_buffer_end_cr) - -## test_puts_widechar() [](#method-i-test_puts_widechar) - -## test_read_all() [](#method-i-test_read_all) - -## test_read_all_invalid() [](#method-i-test_read_all_invalid) - -## test_read_crlf_and_eof() [](#method-i-test_read_crlf_and_eof) - -## test_read_encoding() [](#method-i-test_read_encoding) - -## test_read_mode() [](#method-i-test_read_mode) - -## test_read_newline_conversion_error() [](#method-i-test_read_newline_conversion_error) - -## test_read_newline_conversion_with_encoding_conversion() [](#method-i-test_read_newline_conversion_with_encoding_conversion) - -## test_read_newline_conversion_without_encoding_conversion() [](#method-i-test_read_newline_conversion_without_encoding_conversion) - -## test_read_stateful() [](#method-i-test_read_stateful) - -## test_read_with_binmode_and_getc() [](#method-i-test_read_with_binmode_and_getc) - -## test_read_with_binmode_and_gets() [](#method-i-test_read_with_binmode_and_gets) - -## test_read_with_buf_broken_ascii_only() [](#method-i-test_read_with_buf_broken_ascii_only) - -## test_read_with_length() [](#method-i-test_read_with_length) - -## test_read_with_length_binmode() [](#method-i-test_read_with_length_binmode) - -## test_read_write_with_binmode() [](#method-i-test_read_write_with_binmode) - -## test_s_foreach_enc() [](#method-i-test_s_foreach_enc) - -## test_s_foreach_enc_enc() [](#method-i-test_s_foreach_enc_enc) - -## test_s_foreach_enc_enc_in_opt() [](#method-i-test_s_foreach_enc_enc_in_opt) - -## test_s_foreach_enc_enc_in_opt2() [](#method-i-test_s_foreach_enc_enc_in_opt2) - -## test_s_foreach_enc_in_opt() [](#method-i-test_s_foreach_enc_in_opt) - -## test_s_foreach_enc_in_opt2() [](#method-i-test_s_foreach_enc_in_opt2) - -## test_s_foreach_open_args_enc() [](#method-i-test_s_foreach_open_args_enc) - -## test_s_foreach_open_args_enc_enc() [](#method-i-test_s_foreach_open_args_enc_enc) - -## test_s_foreach_open_args_enc_enc_in_opt() [](#method-i-test_s_foreach_open_args_enc_enc_in_opt) - -## test_s_foreach_open_args_enc_enc_in_opt2() [](#method-i-test_s_foreach_open_args_enc_enc_in_opt2) - -## test_s_foreach_open_args_enc_in_opt() [](#method-i-test_s_foreach_open_args_enc_in_opt) - -## test_s_foreach_open_args_enc_in_opt2() [](#method-i-test_s_foreach_open_args_enc_in_opt2) - -## test_s_pipe_invalid() [](#method-i-test_s_pipe_invalid) - -## test_s_pipe_undef() [](#method-i-test_s_pipe_undef) - -## test_s_pipe_undef_replace_string() [](#method-i-test_s_pipe_undef_replace_string) - -## test_seek_with_setting_binmode() [](#method-i-test_seek_with_setting_binmode) - -## test_set_encoding() [](#method-i-test_set_encoding) - -## test_set_encoding2() [](#method-i-test_set_encoding2) - -## test_set_encoding_argument_parsing() [](#method-i-test_set_encoding_argument_parsing) - -## test_set_encoding_binmode() [](#method-i-test_set_encoding_binmode) - -## test_set_encoding_enc() [](#method-i-test_set_encoding_enc) - -## test_set_encoding_identical() [](#method-i-test_set_encoding_identical) - -## test_set_encoding_invalid() [](#method-i-test_set_encoding_invalid) - -## test_set_encoding_nil() [](#method-i-test_set_encoding_nil) - -## test_set_encoding_undef() [](#method-i-test_set_encoding_undef) - -## test_set_encoding_undef_replace() [](#method-i-test_set_encoding_undef_replace) - -## test_set_encoding_unsupported() [](#method-i-test_set_encoding_unsupported) - -## test_stderr() [](#method-i-test_stderr) - -## test_stdin() [](#method-i-test_stdin) - -## test_stdin_binmode() [](#method-i-test_stdin_binmode) - -## test_stdin_external_encoding_with_reopen() [](#method-i-test_stdin_external_encoding_with_reopen) - -## test_stdout() [](#method-i-test_stdout) - -## test_strip_bom_invalid() [](#method-i-test_strip_bom_invalid) - -## test_strip_bom_no_bom() [](#method-i-test_strip_bom_no_bom) - -## test_strip_bom_no_conv() [](#method-i-test_strip_bom_no_conv) - -## test_terminator_conversion() [](#method-i-test_terminator_conversion) - -## test_terminator_conversion2() [](#method-i-test_terminator_conversion2) - -## test_terminator_stateful_conversion() [](#method-i-test_terminator_stateful_conversion) - -## test_text_mode() [](#method-i-test_text_mode) - -## test_text_mode_ungetc_eof() [](#method-i-test_text_mode_ungetc_eof) - -## test_textmode_decode_universal_newline_getc() [](#method-i-test_textmode_decode_universal_newline_getc) - -## test_textmode_decode_universal_newline_gets() [](#method-i-test_textmode_decode_universal_newline_gets) - -## test_textmode_decode_universal_newline_read() [](#method-i-test_textmode_decode_universal_newline_read) - -## test_textmode_decode_universal_newline_utf16() [](#method-i-test_textmode_decode_universal_newline_utf16) - -## test_textmode_encode_newline() [](#method-i-test_textmode_encode_newline) - -## test_textmode_encode_newline_enc() [](#method-i-test_textmode_encode_newline_enc) - -## test_textmode_paragraph_binaryread() [](#method-i-test_textmode_paragraph_binaryread) - -## test_textmode_paragraph_nonasciicompat() [](#method-i-test_textmode_paragraph_nonasciicompat) - -## test_textmode_paragraphmode() [](#method-i-test_textmode_paragraphmode) - -## test_textmode_twice() [](#method-i-test_textmode_twice) - -## test_undef_r() [](#method-i-test_undef_r) - -## test_undef_w_stateful() [](#method-i-test_undef_w_stateful) - -## test_undef_w_stateless() [](#method-i-test_undef_w_stateless) - -## test_ungetc_int() [](#method-i-test_ungetc_int) - -## test_ungetc_stateful_conversion() [](#method-i-test_ungetc_stateful_conversion) - -## test_ungetc_stateful_conversion2() [](#method-i-test_ungetc_stateful_conversion2) - -## test_ungetc_str() [](#method-i-test_ungetc_str) - -## test_w_xml_attr() [](#method-i-test_w_xml_attr) - -## test_write_ascii_incompat() [](#method-i-test_write_ascii_incompat) - -## test_write_conversion() [](#method-i-test_write_conversion) - -## test_write_conversion_anyenc_stateful() [](#method-i-test_write_conversion_anyenc_stateful) - -## test_write_conversion_anyenc_stateful_nosync() [](#method-i-test_write_conversion_anyenc_stateful_nosync) - -## test_write_conversion_anyenc_stateless() [](#method-i-test_write_conversion_anyenc_stateless) - -## test_write_conversion_fixenc() [](#method-i-test_write_conversion_fixenc) - -## test_write_mode() [](#method-i-test_write_mode) - -## test_write_mode_fail() [](#method-i-test_write_mode_fail) - -## test_write_noenc() [](#method-i-test_write_noenc) - -## with_pipe(*args) [](#method-i-with_pipe) - -## with_tmpdir() [](#method-i-with_tmpdir) - diff --git a/example/ruby/TestIRB.md b/example/ruby/TestIRB.md deleted file mode 100644 index 19e5441..0000000 --- a/example/ruby/TestIRB.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestIRB - - - - - diff --git a/example/ruby/TestIRB/BacktraceFilteringTest.md b/example/ruby/TestIRB/BacktraceFilteringTest.md deleted file mode 100644 index 45b58cc..0000000 --- a/example/ruby/TestIRB/BacktraceFilteringTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestIRB::BacktraceFilteringTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_backtrace_filtering() [](#method-i-test_backtrace_filtering) - -## test_backtrace_filtering_with_backtrace_filter() [](#method-i-test_backtrace_filtering_with_backtrace_filter) - diff --git a/example/ruby/TestIRB/CDTest.md b/example/ruby/TestIRB/CDTest.md deleted file mode 100644 index c74d3c0..0000000 --- a/example/ruby/TestIRB/CDTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIRB::CDTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_cd() [](#method-i-test_cd) - -## test_cd_basic_object_or_frozen() [](#method-i-test_cd_basic_object_or_frozen) - -## test_cd_moves_top_level_with_no_args() [](#method-i-test_cd_moves_top_level_with_no_args) - -## test_cd_with_error() [](#method-i-test_cd_with_error) - diff --git a/example/ruby/TestIRB/ChwsTest.md b/example/ruby/TestIRB/ChwsTest.md deleted file mode 100644 index fef009d..0000000 --- a/example/ruby/TestIRB/ChwsTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::ChwsTest -**Inherits:** TestIRB::WorkspaceCommandTestCase - - - - - -#Instance Methods -## test_chws_does_nothing_when_receiving_no_argument() [](#method-i-test_chws_does_nothing_when_receiving_no_argument) - -## test_chws_replaces_the_current_workspace() [](#method-i-test_chws_replaces_the_current_workspace) - diff --git a/example/ruby/TestIRB/ColorPrinterTest.md b/example/ruby/TestIRB/ColorPrinterTest.md deleted file mode 100644 index 4ed19f2..0000000 --- a/example/ruby/TestIRB/ColorPrinterTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestIRB::ColorPrinterTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_color_printer() [](#method-i-test_color_printer) - diff --git a/example/ruby/TestIRB/ColorPrinterTest/IRBTestColorPrinter.md b/example/ruby/TestIRB/ColorPrinterTest/IRBTestColorPrinter.md deleted file mode 100644 index 43a033d..0000000 --- a/example/ruby/TestIRB/ColorPrinterTest/IRBTestColorPrinter.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: TestIRB::ColorPrinterTest::IRBTestColorPrinter -**Inherits:** Struct - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a - -**@return** [Object] the current value of a - - diff --git a/example/ruby/TestIRB/ColorTest.md b/example/ruby/TestIRB/ColorTest.md deleted file mode 100644 index 20b572a..0000000 --- a/example/ruby/TestIRB/ColorTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestIRB::ColorTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_colorize() [](#method-i-test_colorize) - -## test_colorize_code() [](#method-i-test_colorize_code) - -## test_colorize_code_complete_false() [](#method-i-test_colorize_code_complete_false) - -## test_colorize_code_complete_true() [](#method-i-test_colorize_code_complete_true) - -## test_colorize_code_with_local_variables() [](#method-i-test_colorize_code_with_local_variables) - -## test_inspect_colorable() [](#method-i-test_inspect_colorable) - diff --git a/example/ruby/TestIRB/CommandTestCase.md b/example/ruby/TestIRB/CommandTestCase.md deleted file mode 100644 index e73d80a..0000000 --- a/example/ruby/TestIRB/CommandTestCase.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestIRB::CommandTestCase -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## execute_lines(*lines, conf:{}, main:self, irb_path:nil) [](#method-i-execute_lines) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/TestIRB/CompletionTest.md b/example/ruby/TestIRB/CompletionTest.md deleted file mode 100644 index 9c3155f..0000000 --- a/example/ruby/TestIRB/CompletionTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestIRB::CompletionTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## completion_candidates(target, bind) [](#method-i-completion_candidates) - -## doc_namespace(target, bind) [](#method-i-doc_namespace) - -## test_complete_absolute_constants_with_special_characters() [](#method-i-test_complete_absolute_constants_with_special_characters) - -## test_complete_invalid_three_colons() [](#method-i-test_complete_invalid_three_colons) - -## test_complete_methods() [](#method-i-test_complete_methods) - -## test_complete_reserved_words() [](#method-i-test_complete_reserved_words) - -## test_complete_symbol() [](#method-i-test_complete_symbol) - -## test_not_completing_empty_string() [](#method-i-test_not_completing_empty_string) - diff --git a/example/ruby/TestIRB/CompletionTest/CommandCompletionTest.md b/example/ruby/TestIRB/CompletionTest/CommandCompletionTest.md deleted file mode 100644 index 18e5e91..0000000 --- a/example/ruby/TestIRB/CompletionTest/CommandCompletionTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::CompletionTest::CommandCompletionTest -**Inherits:** TestIRB::CompletionTest - - - - - -#Instance Methods -## test_command_completion() [](#method-i-test_command_completion) - diff --git a/example/ruby/TestIRB/CompletionTest/ConstantCompletionTest.md b/example/ruby/TestIRB/CompletionTest/ConstantCompletionTest.md deleted file mode 100644 index e47adc8..0000000 --- a/example/ruby/TestIRB/CompletionTest/ConstantCompletionTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::CompletionTest::ConstantCompletionTest -**Inherits:** TestIRB::CompletionTest - - - - - -#Instance Methods -## test_complete_constants() [](#method-i-test_complete_constants) - diff --git a/example/ruby/TestIRB/CompletionTest/ConstantCompletionTest/Foo.md b/example/ruby/TestIRB/CompletionTest/ConstantCompletionTest/Foo.md deleted file mode 100644 index b6c0f95..0000000 --- a/example/ruby/TestIRB/CompletionTest/ConstantCompletionTest/Foo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestIRB::CompletionTest::ConstantCompletionTest::Foo -**Inherits:** Object - - - - - diff --git a/example/ruby/TestIRB/CompletionTest/MethodCompletionTest.md b/example/ruby/TestIRB/CompletionTest/MethodCompletionTest.md deleted file mode 100644 index 4a1a1d0..0000000 --- a/example/ruby/TestIRB/CompletionTest/MethodCompletionTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestIRB::CompletionTest::MethodCompletionTest -**Inherits:** TestIRB::CompletionTest - - - - - -#Instance Methods -## test_complete_array() [](#method-i-test_complete_array) - -## test_complete_class() [](#method-i-test_complete_class) - -## test_complete_hash_and_proc() [](#method-i-test_complete_hash_and_proc) - -## test_complete_numeric() [](#method-i-test_complete_numeric) - -## test_complete_regexp() [](#method-i-test_complete_regexp) - -## test_complete_string() [](#method-i-test_complete_string) - -## test_complete_symbol() [](#method-i-test_complete_symbol) - diff --git a/example/ruby/TestIRB/CompletionTest/RequireComepletionTest.md b/example/ruby/TestIRB/CompletionTest/RequireComepletionTest.md deleted file mode 100644 index e3c0777..0000000 --- a/example/ruby/TestIRB/CompletionTest/RequireComepletionTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestIRB::CompletionTest::RequireComepletionTest -**Inherits:** TestIRB::CompletionTest - - - - - -#Instance Methods -## test_complete_require() [](#method-i-test_complete_require) - -## test_complete_require_library_name_first() [](#method-i-test_complete_require_library_name_first) - -## test_complete_require_relative() [](#method-i-test_complete_require_relative) - -## test_complete_require_with_malformed_object_in_load_path() [](#method-i-test_complete_require_with_malformed_object_in_load_path) - -## test_complete_require_with_pathname_in_load_path() [](#method-i-test_complete_require_with_pathname_in_load_path) - -## test_complete_require_with_string_convertable_in_load_path() [](#method-i-test_complete_require_with_string_convertable_in_load_path) - diff --git a/example/ruby/TestIRB/CompletionTest/VariableCompletionTest.md b/example/ruby/TestIRB/CompletionTest/VariableCompletionTest.md deleted file mode 100644 index 699fa34..0000000 --- a/example/ruby/TestIRB/CompletionTest/VariableCompletionTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::CompletionTest::VariableCompletionTest -**Inherits:** TestIRB::CompletionTest - - - - - -#Instance Methods -## test_complete_sort_variables() [](#method-i-test_complete_sort_variables) - -## test_complete_variable() [](#method-i-test_complete_variable) - diff --git a/example/ruby/TestIRB/ConfigValidationTest.md b/example/ruby/TestIRB/ConfigValidationTest.md deleted file mode 100644 index a4acf50..0000000 --- a/example/ruby/TestIRB/ConfigValidationTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestIRB::ConfigValidationTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_back_trace_limit_only_accepts_integers() [](#method-i-test_back_trace_limit_only_accepts_integers) - -## test_eval_history_only_accepts_integers() [](#method-i-test_eval_history_only_accepts_integers) - -## test_irb_name_converts_non_string_values_to_string() [](#method-i-test_irb_name_converts_non_string_values_to_string) - -## test_irb_rc_name_only_takes_callable_objects() [](#method-i-test_irb_rc_name_only_takes_callable_objects) - -## test_prompt_only_accepts_hash() [](#method-i-test_prompt_only_accepts_hash) - diff --git a/example/ruby/TestIRB/ContextTest.md b/example/ruby/TestIRB/ContextTest.md deleted file mode 100644 index 6318a14..0000000 --- a/example/ruby/TestIRB/ContextTest.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: TestIRB::ContextTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_build_completor() [](#method-i-test_build_completor) - -## test_default_config() [](#method-i-test_default_config) - -## test_default_return_format() [](#method-i-test_default_return_format) - -## test_echo_on_assignment() [](#method-i-test_echo_on_assignment) - -## test_echo_on_assignment_conf() [](#method-i-test_echo_on_assignment_conf) - -## test_eval_input() [](#method-i-test_eval_input) - -## test_eval_input_raise2x() [](#method-i-test_eval_input_raise2x) - -## test_eval_input_with_exception() [](#method-i-test_eval_input_with_exception) - -## test_eval_input_with_invalid_byte_sequence_exception() [](#method-i-test_eval_input_with_invalid_byte_sequence_exception) - -## test_eval_input_with_long_exception() [](#method-i-test_eval_input_with_long_exception) - -## test_irb_path_setter() [](#method-i-test_irb_path_setter) - -## test_lineno() [](#method-i-test_lineno) - -## test_multiline_output_on_default_inspector() [](#method-i-test_multiline_output_on_default_inspector) - -## test_object_inspection_falls_back_to_kernel_inspect_when_errored() [](#method-i-test_object_inspection_falls_back_to_kernel_inspect_when_errored) - -## test_object_inspection_handles_basic_object() [](#method-i-test_object_inspection_handles_basic_object) - -## test_object_inspection_prints_useful_info_when_kernel_inspect_also_errored() [](#method-i-test_object_inspection_prints_useful_info_when_kernel_inspect_also_errored) - -## test_omit_multiline_on_assignment() [](#method-i-test_omit_multiline_on_assignment) - -## test_omit_on_assignment() [](#method-i-test_omit_on_assignment) - -## test_output_to_pipe() [](#method-i-test_output_to_pipe) - -## test_prompt_format() [](#method-i-test_prompt_format) - -## test_prompt_main_basic_object() [](#method-i-test_prompt_main_basic_object) - -## test_prompt_main_escape() [](#method-i-test_prompt_main_escape) - -## test_prompt_main_inspect_escape() [](#method-i-test_prompt_main_inspect_escape) - -## test_prompt_main_raise() [](#method-i-test_prompt_main_raise) - -## test_prompt_main_truncate() [](#method-i-test_prompt_main_truncate) - -## test_prompt_n_deprecation() [](#method-i-test_prompt_n_deprecation) - diff --git a/example/ruby/TestIRB/ContextWithTracerIntegrationTest.md b/example/ruby/TestIRB/ContextWithTracerIntegrationTest.md deleted file mode 100644 index 043c216..0000000 --- a/example/ruby/TestIRB/ContextWithTracerIntegrationTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIRB::ContextWithTracerIntegrationTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## example_ruby_file() [](#method-i-example_ruby_file) - -## setup() [](#method-i-setup) - -## test_use_tracer_enabled_when_gem_is_available() [](#method-i-test_use_tracer_enabled_when_gem_is_available) - -## test_use_tracer_enabled_when_gem_is_unavailable() [](#method-i-test_use_tracer_enabled_when_gem_is_unavailable) - -## test_use_tracer_is_disabled_by_default() [](#method-i-test_use_tracer_is_disabled_by_default) - diff --git a/example/ruby/TestIRB/CustomCommandIntegrationTest.md b/example/ruby/TestIRB/CustomCommandIntegrationTest.md deleted file mode 100644 index e50ae56..0000000 --- a/example/ruby/TestIRB/CustomCommandIntegrationTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestIRB::CustomCommandIntegrationTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_arguments_propagation() [](#method-i-test_arguments_propagation) - -## test_command_name_local_variable() [](#method-i-test_command_name_local_variable) - -## test_command_registration_accepts_string_too() [](#method-i-test_command_registration_accepts_string_too) - -## test_command_registration_can_happen_after_irb_require() [](#method-i-test_command_registration_can_happen_after_irb_require) - -## test_def_extend_command_still_works() [](#method-i-test_def_extend_command_still_works) - -## test_no_meta_command_also_works() [](#method-i-test_no_meta_command_also_works) - diff --git a/example/ruby/TestIRB/CwwsTest.md b/example/ruby/TestIRB/CwwsTest.md deleted file mode 100644 index 3417f75..0000000 --- a/example/ruby/TestIRB/CwwsTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::CwwsTest -**Inherits:** TestIRB::WorkspaceCommandTestCase - - - - - -#Instance Methods -## test_cwws_returns_the_current_workspace_object() [](#method-i-test_cwws_returns_the_current_workspace_object) - diff --git a/example/ruby/TestIRB/DebuggerIntegrationTest.md b/example/ruby/TestIRB/DebuggerIntegrationTest.md deleted file mode 100644 index f43a72e..0000000 --- a/example/ruby/TestIRB/DebuggerIntegrationTest.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: TestIRB::DebuggerIntegrationTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_backtrace() [](#method-i-test_backtrace) - -## test_break() [](#method-i-test_break) - -## test_catch() [](#method-i-test_catch) - -## test_continue() [](#method-i-test_continue) - -## test_debug() [](#method-i-test_debug) - -## test_debug_command_can_only_be_called_from_binding_irb() [](#method-i-test_debug_command_can_only_be_called_from_binding_irb) - -## test_debug_command_only_runs_once() [](#method-i-test_debug_command_only_runs_once) - -## test_debugger_cant_be_activated_while_multi_irb_is_active() [](#method-i-test_debugger_cant_be_activated_while_multi_irb_is_active) - -## test_delete() [](#method-i-test_delete) - -## test_exit() [](#method-i-test_exit) - -## test_finish() [](#method-i-test_finish) - -## test_force_exit() [](#method-i-test_force_exit) - -## test_help_command_is_delegated_to_the_debugger() [](#method-i-test_help_command_is_delegated_to_the_debugger) - -## test_help_display_different_content_when_debugger_is_enabled() [](#method-i-test_help_display_different_content_when_debugger_is_enabled) - -## test_info() [](#method-i-test_info) - -## test_input_is_evaluated_in_the_context_of_the_current_thread() [](#method-i-test_input_is_evaluated_in_the_context_of_the_current_thread) - -## test_irb_command_can_check_local_variables() [](#method-i-test_irb_command_can_check_local_variables) - -## test_irb_commands_are_available_after_moving_around_with_the_debugger() [](#method-i-test_irb_commands_are_available_after_moving_around_with_the_debugger) - -## test_irb_passes_empty_input_to_debugger_to_repeat_the_last_command() [](#method-i-test_irb_passes_empty_input_to_debugger_to_repeat_the_last_command) - -## test_irb_switches_debugger_interface_if_debug_was_already_activated() [](#method-i-test_irb_switches_debugger_interface_if_debug_was_already_activated) - -## test_long_stepping() [](#method-i-test_long_stepping) - -## test_multi_irb_commands_are_not_available_after_activating_the_debugger() [](#method-i-test_multi_irb_commands_are_not_available_after_activating_the_debugger) - -## test_next() [](#method-i-test_next) - -## test_prompt_irb_name_is_kept() [](#method-i-test_prompt_irb_name_is_kept) - -## test_prompt_line_number_continues() [](#method-i-test_prompt_line_number_continues) - -## test_quit() [](#method-i-test_quit) - -## test_step() [](#method-i-test_step) - diff --git a/example/ruby/TestIRB/DeprecatedInputCompletorTest.md b/example/ruby/TestIRB/DeprecatedInputCompletorTest.md deleted file mode 100644 index a5c94ef..0000000 --- a/example/ruby/TestIRB/DeprecatedInputCompletorTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestIRB::DeprecatedInputCompletorTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_completion_proc() [](#method-i-test_completion_proc) - -## test_retrieve_completion_data() [](#method-i-test_retrieve_completion_data) - diff --git a/example/ruby/TestIRB/DisableIRBTest.md b/example/ruby/TestIRB/DisableIRBTest.md deleted file mode 100644 index 20b06ab..0000000 --- a/example/ruby/TestIRB/DisableIRBTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::DisableIRBTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_disable_irb_disable_further_irb_breakpoints() [](#method-i-test_disable_irb_disable_further_irb_breakpoints) - diff --git a/example/ruby/TestIRB/DisplayDocumentTest.md b/example/ruby/TestIRB/DisplayDocumentTest.md deleted file mode 100644 index 848076a..0000000 --- a/example/ruby/TestIRB/DisplayDocumentTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestIRB::DisplayDocumentTest -**Inherits:** TestIRB::InputMethodTest - - - - - -#Instance Methods -## display_document(target, bind, drivernil) [](#method-i-display_document) - -## setup() [](#method-i-setup) - -## test_not_matched_namespace_triggers_nothing() [](#method-i-test_not_matched_namespace_triggers_nothing) - -## test_perfect_matching_handles_nil_namespace() [](#method-i-test_perfect_matching_handles_nil_namespace) - -## test_perfect_matching_stops_without_rdoc() [](#method-i-test_perfect_matching_stops_without_rdoc) - -## test_perfectly_matched_multiple_namespaces_triggers_document_display() [](#method-i-test_perfectly_matched_multiple_namespaces_triggers_document_display) - -## test_perfectly_matched_namespace_triggers_document_display() [](#method-i-test_perfectly_matched_namespace_triggers_document_display) - diff --git a/example/ruby/TestIRB/EchoingTest.md b/example/ruby/TestIRB/EchoingTest.md deleted file mode 100644 index 136e3fa..0000000 --- a/example/ruby/TestIRB/EchoingTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::EchoingTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_irb_doesnt_echo_line_with_semicolon() [](#method-i-test_irb_doesnt_echo_line_with_semicolon) - -## test_irb_echos_by_default() [](#method-i-test_irb_echos_by_default) - diff --git a/example/ruby/TestIRB/EditTest.md b/example/ruby/TestIRB/EditTest.md deleted file mode 100644 index fbf8d31..0000000 --- a/example/ruby/TestIRB/EditTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestIRB::EditTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_edit_with_class_method() [](#method-i-test_edit_with_class_method) - -## test_edit_with_constant() [](#method-i-test_edit_with_constant) - -## test_edit_with_editor_env_var() [](#method-i-test_edit_with_editor_env_var) - -## test_edit_with_instance_method() [](#method-i-test_edit_with_instance_method) - -## test_edit_with_non_existing_path() [](#method-i-test_edit_with_non_existing_path) - -## test_edit_with_path() [](#method-i-test_edit_with_path) - -## test_edit_without_arg() [](#method-i-test_edit_without_arg) - -## test_edit_without_arg_and_non_existing_irb_path() [](#method-i-test_edit_without_arg_and_non_existing_irb_path) - diff --git a/example/ruby/TestIRB/EvalHistoryTest.md b/example/ruby/TestIRB/EvalHistoryTest.md deleted file mode 100644 index e9fe5b0..0000000 --- a/example/ruby/TestIRB/EvalHistoryTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestIRB::EvalHistoryTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## execute_lines(*lines, conf:{}, main:self, irb_path:nil) [](#method-i-execute_lines) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_eval_history_can_be_retrieved_with_double_underscore() [](#method-i-test_eval_history_can_be_retrieved_with_double_underscore) - -## test_eval_history_is_disabled_by_default() [](#method-i-test_eval_history_is_disabled_by_default) - -## test_eval_history_respects_given_limit() [](#method-i-test_eval_history_respects_given_limit) - diff --git a/example/ruby/TestIRB/ForceExitTest.md b/example/ruby/TestIRB/ForceExitTest.md deleted file mode 100644 index 102e2d5..0000000 --- a/example/ruby/TestIRB/ForceExitTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::ForceExitTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_forced_exit_finishes_process_immediately() [](#method-i-test_forced_exit_finishes_process_immediately) - -## test_forced_exit_in_nested_sessions() [](#method-i-test_forced_exit_in_nested_sessions) - diff --git a/example/ruby/TestIRB/FrozenObjectTest.md b/example/ruby/TestIRB/FrozenObjectTest.md deleted file mode 100644 index 3b55817..0000000 --- a/example/ruby/TestIRB/FrozenObjectTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::FrozenObjectTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## test_calling_command_on_a_frozen_main() [](#method-i-test_calling_command_on_a_frozen_main) - diff --git a/example/ruby/TestIRB/HelpTest.md b/example/ruby/TestIRB/HelpTest.md deleted file mode 100644 index 3e6eabf..0000000 --- a/example/ruby/TestIRB/HelpTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestIRB::HelpTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_command_help() [](#method-i-test_command_help) - -## test_command_help_not_found() [](#method-i-test_command_help_not_found) - -## test_help() [](#method-i-test_help) - -## test_help_lists_helper_methods() [](#method-i-test_help_lists_helper_methods) - -## test_help_lists_user_aliases() [](#method-i-test_help_lists_user_aliases) - -## test_show_cmds() [](#method-i-test_show_cmds) - diff --git a/example/ruby/TestIRB/HelperMethodInsallTest.md b/example/ruby/TestIRB/HelperMethodInsallTest.md deleted file mode 100644 index 22e5906..0000000 --- a/example/ruby/TestIRB/HelperMethodInsallTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::HelperMethodInsallTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## test_helper_method_install() [](#method-i-test_helper_method_install) - diff --git a/example/ruby/TestIRB/HelperMethodIntegrationTest.md b/example/ruby/TestIRB/HelperMethodIntegrationTest.md deleted file mode 100644 index bf2089f..0000000 --- a/example/ruby/TestIRB/HelperMethodIntegrationTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestIRB::HelperMethodIntegrationTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_arguments_propogation() [](#method-i-test_arguments_propogation) - -## test_helper_method_injection_can_happen_after_irb_require() [](#method-i-test_helper_method_injection_can_happen_after_irb_require) - -## test_helper_method_instances_are_memoized() [](#method-i-test_helper_method_instances_are_memoized) - diff --git a/example/ruby/TestIRB/HelperMethodTestCase.md b/example/ruby/TestIRB/HelperMethodTestCase.md deleted file mode 100644 index 50f9123..0000000 --- a/example/ruby/TestIRB/HelperMethodTestCase.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestIRB::HelperMethodTestCase -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## execute_lines(*lines, conf:{}, main:self, irb_path:nil) [](#method-i-execute_lines) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/TestIRB/HistoryCmdTest.md b/example/ruby/TestIRB/HistoryCmdTest.md deleted file mode 100644 index 983540c..0000000 --- a/example/ruby/TestIRB/HistoryCmdTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestIRB::HistoryCmdTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## teardown() [](#method-i-teardown) - -## test_history() [](#method-i-test_history) - -## test_history_grep() [](#method-i-test_history_grep) - -## test_multiline_history_with_truncation() [](#method-i-test_multiline_history_with_truncation) - diff --git a/example/ruby/TestIRB/HistoryTest.md b/example/ruby/TestIRB/HistoryTest.md deleted file mode 100644 index 7fcbb62..0000000 --- a/example/ruby/TestIRB/HistoryTest.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestIRB::HistoryTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_history_concurrent_use_not_present() [](#method-i-test_history_concurrent_use_not_present) - -## test_history_concurrent_use_readline() [](#method-i-test_history_concurrent_use_readline) - -## test_history_concurrent_use_reline() [](#method-i-test_history_concurrent_use_reline) - -## test_history_different_encodings() [](#method-i-test_history_different_encodings) - -## test_history_does_not_raise_when_history_file_directory_does_not_exist() [](#method-i-test_history_does_not_raise_when_history_file_directory_does_not_exist) - -## test_history_dont_save() [](#method-i-test_history_dont_save) - -## test_history_save_1() [](#method-i-test_history_save_1) - -## test_history_save_100() [](#method-i-test_history_save_100) - -## test_history_save_bignum() [](#method-i-test_history_save_bignum) - -## test_history_save_minus_as_infinity() [](#method-i-test_history_save_minus_as_infinity) - -## test_no_home_no_history_file_does_not_raise_history_save() [](#method-i-test_no_home_no_history_file_does_not_raise_history_save) - diff --git a/example/ruby/TestIRB/HistoryTest/TestInputMethodWithReadlineHistory.md b/example/ruby/TestIRB/HistoryTest/TestInputMethodWithReadlineHistory.md deleted file mode 100644 index acd4c51..0000000 --- a/example/ruby/TestIRB/HistoryTest/TestInputMethodWithReadlineHistory.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestIRB::HistoryTest::TestInputMethodWithReadlineHistory -**Inherits:** TestInputMethod - -**Includes:** IRB::HistorySavingAbility - - - - - -#Instance Methods -## load_history() [](#method-i-load_history) - -## reset_history_counter() [](#method-i-reset_history_counter) - -## save_history() [](#method-i-save_history) - -## support_history_saving?() [](#method-i-support_history_saving?) - -**@return** [Boolean] - diff --git a/example/ruby/TestIRB/HistoryTest/TestInputMethodWithRelineHistory.md b/example/ruby/TestIRB/HistoryTest/TestInputMethodWithRelineHistory.md deleted file mode 100644 index 85382fc..0000000 --- a/example/ruby/TestIRB/HistoryTest/TestInputMethodWithRelineHistory.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestIRB::HistoryTest::TestInputMethodWithRelineHistory -**Inherits:** TestInputMethod - -**Includes:** IRB::HistorySavingAbility - - - - - -#Instance Methods -## load_history() [](#method-i-load_history) - -## reset_history_counter() [](#method-i-reset_history_counter) - -## save_history() [](#method-i-save_history) - -## support_history_saving?() [](#method-i-support_history_saving?) - -**@return** [Boolean] - diff --git a/example/ruby/TestIRB/IRBHistoryIntegrationTest.md b/example/ruby/TestIRB/IRBHistoryIntegrationTest.md deleted file mode 100644 index 0e9f954..0000000 --- a/example/ruby/TestIRB/IRBHistoryIntegrationTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestIRB::IRBHistoryIntegrationTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_direct_debug_session_loads_history() [](#method-i-test_direct_debug_session_loads_history) - -## test_history_saving_with_debug() [](#method-i-test_history_saving_with_debug) - -## test_history_saving_with_debug_without_prior_history() [](#method-i-test_history_saving_with_debug_without_prior_history) - -## test_history_saving_with_nested_sessions() [](#method-i-test_history_saving_with_nested_sessions) - -## test_history_saving_with_nested_sessions_and_prior_history() [](#method-i-test_history_saving_with_nested_sessions_and_prior_history) - -## test_nested_history_saving_from_inner_session_with_exit!() [](#method-i-test_nested_history_saving_from_inner_session_with_exit!) - -## test_nested_history_saving_from_outer_session_with_exit!() [](#method-i-test_nested_history_saving_from_outer_session_with_exit!) - diff --git a/example/ruby/TestIRB/InfoTest.md b/example/ruby/TestIRB/InfoTest.md deleted file mode 100644 index 7405e19..0000000 --- a/example/ruby/TestIRB/InfoTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestIRB::InfoTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_irb_info_lang() [](#method-i-test_irb_info_lang) - -## test_irb_info_multiline() [](#method-i-test_irb_info_multiline) - -## test_irb_info_multiline_without_rc_files() [](#method-i-test_irb_info_multiline_without_rc_files) - -## test_irb_info_singleline() [](#method-i-test_irb_info_singleline) - -## test_irb_info_singleline_without_rc_files() [](#method-i-test_irb_info_singleline_without_rc_files) - diff --git a/example/ruby/TestIRB/InitIntegrationTest.md b/example/ruby/TestIRB/InitIntegrationTest.md deleted file mode 100644 index 88259c1..0000000 --- a/example/ruby/TestIRB/InitIntegrationTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestIRB::InitIntegrationTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_load_error_in_rc_file_is_warned() [](#method-i-test_load_error_in_rc_file_is_warned) - -## test_normal_errors_in_rc_file_is_warned() [](#method-i-test_normal_errors_in_rc_file_is_warned) - diff --git a/example/ruby/TestIRB/InitTest.md b/example/ruby/TestIRB/InitTest.md deleted file mode 100644 index 6bf4dde..0000000 --- a/example/ruby/TestIRB/InitTest.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestIRB::InitTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## reset_rc_name_generators() [](#method-i-reset_rc_name_generators) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_completor_environment_variable() [](#method-i-test_completor_environment_variable) - -## test_completor_setup_with_argv() [](#method-i-test_completor_setup_with_argv) - -## test_dash() [](#method-i-test_dash) - -## test_duplicated_rc_files() [](#method-i-test_duplicated_rc_files) - -## test_no_color_environment_variable() [](#method-i-test_no_color_environment_variable) - -## test_noscript() [](#method-i-test_noscript) - -## test_option_tracer() [](#method-i-test_option_tracer) - -## test_rc_files() [](#method-i-test_rc_files) - -## test_setup_with_argv_preserves_global_argv() [](#method-i-test_setup_with_argv_preserves_global_argv) - -## test_setup_with_minimum_argv_does_not_change_dollar0() [](#method-i-test_setup_with_minimum_argv_does_not_change_dollar0) - -## test_sigint_restore_block() [](#method-i-test_sigint_restore_block) - -## test_sigint_restore_default() [](#method-i-test_sigint_restore_default) - -## test_use_autocomplete_environment_variable() [](#method-i-test_use_autocomplete_environment_variable) - diff --git a/example/ruby/TestIRB/InputMethodTest.md b/example/ruby/TestIRB/InputMethodTest.md deleted file mode 100644 index 9180e3c..0000000 --- a/example/ruby/TestIRB/InputMethodTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::InputMethodTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/TestIRB/InputTest.md b/example/ruby/TestIRB/InputTest.md deleted file mode 100644 index 9427b2a..0000000 --- a/example/ruby/TestIRB/InputTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestIRB::InputTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_commands_dont_override_stored_last_result() [](#method-i-test_commands_dont_override_stored_last_result) - -## test_empty_input_echoing_behaviour() [](#method-i-test_empty_input_echoing_behaviour) - -## test_evaluate_still_emits_warning() [](#method-i-test_evaluate_still_emits_warning) - -## test_evaluate_with_encoding_error_without_lineno() [](#method-i-test_evaluate_with_encoding_error_without_lineno) - -## test_symbol_aliases_are_handled_correctly() [](#method-i-test_symbol_aliases_are_handled_correctly) - -## test_symbol_aliases_are_handled_correctly_with_singleline_mode() [](#method-i-test_symbol_aliases_are_handled_correctly_with_singleline_mode) - -## test_symbol_aliases_dont_affect_ruby_syntax() [](#method-i-test_symbol_aliases_dont_affect_ruby_syntax) - -## test_underscore_stores_last_result() [](#method-i-test_underscore_stores_last_result) - diff --git a/example/ruby/TestIRB/IntegrationTestCase.md b/example/ruby/TestIRB/IntegrationTestCase.md deleted file mode 100644 index 56f7911..0000000 --- a/example/ruby/TestIRB/IntegrationTestCase.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestIRB::IntegrationTestCase -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## kill_safely(pid) [](#method-i-kill_safely) - -## run_ruby_file(&block) [](#method-i-run_ruby_file) - -## safe_gets(read) [](#method-i-safe_gets) -read.gets could raise exceptions on some platforms -https://github.com/ruby/ruby/blob/master/ext/pty/pty.c#L721-L728 - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## type(command) [](#method-i-type) - -## wait_pid(pid, sec) [](#method-i-wait_pid) - -## write_rc(content) [](#method-i-write_rc) - -## write_ruby(program) [](#method-i-write_ruby) - diff --git a/example/ruby/TestIRB/IrbIOConfigurationTest.md b/example/ruby/TestIRB/IrbIOConfigurationTest.md deleted file mode 100644 index 7d82f12..0000000 --- a/example/ruby/TestIRB/IrbIOConfigurationTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::IrbIOConfigurationTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/TestIRB/IrbIOConfigurationTest/AutoIndentationTest.md b/example/ruby/TestIRB/IrbIOConfigurationTest/AutoIndentationTest.md deleted file mode 100644 index daeac30..0000000 --- a/example/ruby/TestIRB/IrbIOConfigurationTest/AutoIndentationTest.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: TestIRB::IrbIOConfigurationTest::AutoIndentationTest -**Inherits:** TestIRB::IrbIOConfigurationTest - - - - - -#Instance Methods -## test_a_closed_brace_and_not_closed_brace_in_a_line() [](#method-i-test_a_closed_brace_and_not_closed_brace_in_a_line) - -## test_auto_indent() [](#method-i-test_auto_indent) - -## test_braces_on_their_own_line() [](#method-i-test_braces_on_their_own_line) - -## test_bracket_corresponding_to_loop() [](#method-i-test_bracket_corresponding_to_loop) - -## test_bracket_corresponding_to_times() [](#method-i-test_bracket_corresponding_to_times) - -## test_broken_heredoc() [](#method-i-test_broken_heredoc) - -## test_corresponding_syntax_to_keyword_do() [](#method-i-test_corresponding_syntax_to_keyword_do) - -## test_corresponding_syntax_to_keyword_do_in_class() [](#method-i-test_corresponding_syntax_to_keyword_do_in_class) - -## test_corresponding_syntax_to_keyword_for() [](#method-i-test_corresponding_syntax_to_keyword_for) - -## test_corresponding_syntax_to_keyword_for_with_do() [](#method-i-test_corresponding_syntax_to_keyword_for_with_do) - -## test_do_corresponding_to_loop() [](#method-i-test_do_corresponding_to_loop) - -## test_do_corresponding_to_times() [](#method-i-test_do_corresponding_to_times) - -## test_embdoc_indent() [](#method-i-test_embdoc_indent) - -## test_heredoc_keep_indent_spaces() [](#method-i-test_heredoc_keep_indent_spaces) - -## test_heredoc_with_indent() [](#method-i-test_heredoc_with_indent) - -## test_incomplete_coding_magic_comment() [](#method-i-test_incomplete_coding_magic_comment) - -## test_incomplete_emacs_coding_magic_comment() [](#method-i-test_incomplete_emacs_coding_magic_comment) - -## test_incomplete_encoding_magic_comment() [](#method-i-test_incomplete_encoding_magic_comment) - -## test_incomplete_vim_coding_magic_comment() [](#method-i-test_incomplete_vim_coding_magic_comment) - -## test_mixed_rescue() [](#method-i-test_mixed_rescue) - -## test_multiple_braces_in_a_line() [](#method-i-test_multiple_braces_in_a_line) - -## test_oneliner_def_in_multiple_lines() [](#method-i-test_oneliner_def_in_multiple_lines) - -## test_oneliner_method_definition() [](#method-i-test_oneliner_method_definition) - -## test_pasted_code_keep_base_indent_spaces() [](#method-i-test_pasted_code_keep_base_indent_spaces) - -## test_pasted_code_keep_base_indent_spaces_with_heredoc() [](#method-i-test_pasted_code_keep_base_indent_spaces_with_heredoc) - -## test_symbols() [](#method-i-test_symbols) - -## test_tlambda() [](#method-i-test_tlambda) - -## test_typing_incomplete_include_interpreted_as_keyword_in() [](#method-i-test_typing_incomplete_include_interpreted_as_keyword_in) - diff --git a/example/ruby/TestIRB/IrbIOConfigurationTest/DynamicPromptTest.md b/example/ruby/TestIRB/IrbIOConfigurationTest/DynamicPromptTest.md deleted file mode 100644 index cd2de11..0000000 --- a/example/ruby/TestIRB/IrbIOConfigurationTest/DynamicPromptTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestIRB::IrbIOConfigurationTest::DynamicPromptTest -**Inherits:** TestIRB::IrbIOConfigurationTest - - - - -# Class Methods -## generate_prompt(opens , continue , line_offset ) [](#method-c-generate_prompt) - -#Instance Methods -## assert_dynamic_prompt(input_with_prompt) [](#method-i-assert_dynamic_prompt) - -## test_backtick_method() [](#method-i-test_backtick_method) - -## test_dynamic_prompt() [](#method-i-test_dynamic_prompt) - -## test_dynamic_prompt_with_blank_line() [](#method-i-test_dynamic_prompt_with_blank_line) - -## test_dynamic_prompt_with_double_newline_breaking_code() [](#method-i-test_dynamic_prompt_with_double_newline_breaking_code) - -## test_dynamic_prompt_with_multiline_literal() [](#method-i-test_dynamic_prompt_with_multiline_literal) - -## test_endless_range_at_end_of_line() [](#method-i-test_endless_range_at_end_of_line) - -## test_heredoc_prompt_with_quotes() [](#method-i-test_heredoc_prompt_with_quotes) - -## test_heredoc_with_embexpr() [](#method-i-test_heredoc_with_embexpr) - diff --git a/example/ruby/TestIRB/IrbIOConfigurationTest/MockIO_AutoIndent.md b/example/ruby/TestIRB/IrbIOConfigurationTest/MockIO_AutoIndent.md deleted file mode 100644 index 1fbaabf..0000000 --- a/example/ruby/TestIRB/IrbIOConfigurationTest/MockIO_AutoIndent.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIRB::IrbIOConfigurationTest::MockIO_AutoIndent -**Inherits:** Object - - - - -# Attributes -## calculated_indent[RW] [](#attribute-i-calculated_indent) -Returns the value of attribute calculated_indent. - - -#Instance Methods -## auto_indent(&block) [](#method-i-auto_indent) - -## initialize(*params) [](#method-i-initialize) - -**@return** [MockIO_AutoIndent] a new instance of MockIO_AutoIndent - diff --git a/example/ruby/TestIRB/IrbIOConfigurationTest/MockIO_DynamicPrompt.md b/example/ruby/TestIRB/IrbIOConfigurationTest/MockIO_DynamicPrompt.md deleted file mode 100644 index ca6b935..0000000 --- a/example/ruby/TestIRB/IrbIOConfigurationTest/MockIO_DynamicPrompt.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIRB::IrbIOConfigurationTest::MockIO_DynamicPrompt -**Inherits:** Object - - - - -# Attributes -## prompt_list[RW] [](#attribute-i-prompt_list) -Returns the value of attribute prompt_list. - - -#Instance Methods -## dynamic_prompt(&block) [](#method-i-dynamic_prompt) - -## initialize(params, &assertion) [](#method-i-initialize) - -**@return** [MockIO_DynamicPrompt] a new instance of MockIO_DynamicPrompt - diff --git a/example/ruby/TestIRB/IrbIOConfigurationTest/Row.md b/example/ruby/TestIRB/IrbIOConfigurationTest/Row.md deleted file mode 100644 index b7f56ac..0000000 --- a/example/ruby/TestIRB/IrbIOConfigurationTest/Row.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestIRB::IrbIOConfigurationTest::Row -**Inherits:** Struct - - - - -# Attributes -## content[RW] [](#attribute-i-content) -Returns the value of attribute content - -**@return** [Object] the current value of content - -## current_line_spaces[RW] [](#attribute-i-current_line_spaces) -Returns the value of attribute current_line_spaces - -**@return** [Object] the current value of current_line_spaces - -## indent_level[RW] [](#attribute-i-indent_level) -Returns the value of attribute indent_level - -**@return** [Object] the current value of indent_level - -## new_line_spaces[RW] [](#attribute-i-new_line_spaces) -Returns the value of attribute new_line_spaces - -**@return** [Object] the current value of new_line_spaces - - diff --git a/example/ruby/TestIRB/IrbLoadTest.md b/example/ruby/TestIRB/IrbLoadTest.md deleted file mode 100644 index 8887369..0000000 --- a/example/ruby/TestIRB/IrbLoadTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::IrbLoadTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## test_irb_load() [](#method-i-test_irb_load) - -## test_irb_load_without_argument() [](#method-i-test_irb_load_without_argument) - diff --git a/example/ruby/TestIRB/IrbSourceTest.md b/example/ruby/TestIRB/IrbSourceTest.md deleted file mode 100644 index e121ec5..0000000 --- a/example/ruby/TestIRB/IrbSourceTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::IrbSourceTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## test_irb_source() [](#method-i-test_irb_source) - -## test_irb_source_without_argument() [](#method-i-test_irb_source_without_argument) - diff --git a/example/ruby/TestIRB/LocaleTestCase.md b/example/ruby/TestIRB/LocaleTestCase.md deleted file mode 100644 index e713707..0000000 --- a/example/ruby/TestIRB/LocaleTestCase.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestIRB::LocaleTestCase -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## test_find() [](#method-i-test_find) - -## test_initialize_with_en() [](#method-i-test_initialize_with_en) - -## test_initialize_with_ja() [](#method-i-test_initialize_with_ja) - -## test_initialize_with_legacy_ja_encoding_euc() [](#method-i-test_initialize_with_legacy_ja_encoding_euc) - -## test_initialize_with_legacy_ja_encoding_ujis() [](#method-i-test_initialize_with_legacy_ja_encoding_ujis) - -## test_load() [](#method-i-test_load) - diff --git a/example/ruby/TestIRB/LsTest.md b/example/ruby/TestIRB/LsTest.md deleted file mode 100644 index 79334e8..0000000 --- a/example/ruby/TestIRB/LsTest.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestIRB::LsTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## test_ls() [](#method-i-test_ls) - -## test_ls_class() [](#method-i-test_ls_class) - -## test_ls_grep() [](#method-i-test_ls_grep) - -## test_ls_grep_empty() [](#method-i-test_ls_grep_empty) - -## test_ls_instance() [](#method-i-test_ls_instance) - -## test_ls_module() [](#method-i-test_ls_module) - -## test_ls_with_eval_error() [](#method-i-test_ls_with_eval_error) - -## test_ls_with_no_singleton_class() [](#method-i-test_ls_with_no_singleton_class) - diff --git a/example/ruby/TestIRB/MeasureTest.md b/example/ruby/TestIRB/MeasureTest.md deleted file mode 100644 index 213ae98..0000000 --- a/example/ruby/TestIRB/MeasureTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestIRB::MeasureTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## test_measure() [](#method-i-test_measure) - -## test_measure_enabled_by_rc() [](#method-i-test_measure_enabled_by_rc) - -## test_measure_enabled_by_rc_with_custom() [](#method-i-test_measure_enabled_by_rc_with_custom) - -## test_measure_keeps_previous_value() [](#method-i-test_measure_keeps_previous_value) - -## test_measure_toggle() [](#method-i-test_measure_toggle) - -## test_measure_with_custom() [](#method-i-test_measure_with_custom) - -## test_measure_with_proc_warning() [](#method-i-test_measure_with_proc_warning) - diff --git a/example/ruby/TestIRB/MultiIRBTest.md b/example/ruby/TestIRB/MultiIRBTest.md deleted file mode 100644 index 62ad6df..0000000 --- a/example/ruby/TestIRB/MultiIRBTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestIRB::MultiIRBTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_irb_fg_jobs_and_kill_commands() [](#method-i-test_irb_fg_jobs_and_kill_commands) - -## test_irb_jobs_and_kill_commands() [](#method-i-test_irb_jobs_and_kill_commands) - -## test_jobs_command_with_print_deprecated_warning() [](#method-i-test_jobs_command_with_print_deprecated_warning) - diff --git a/example/ruby/TestIRB/NestedBindingIrbTest.md b/example/ruby/TestIRB/NestedBindingIrbTest.md deleted file mode 100644 index cbafe7b..0000000 --- a/example/ruby/TestIRB/NestedBindingIrbTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::NestedBindingIrbTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_current_context_restore() [](#method-i-test_current_context_restore) - diff --git a/example/ruby/TestIRB/NestingParserTest.md b/example/ruby/TestIRB/NestingParserTest.md deleted file mode 100644 index db658ef..0000000 --- a/example/ruby/TestIRB/NestingParserTest.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestIRB::NestingParserTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## parse_by_line(code) [](#method-i-parse_by_line) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_backslash_continued_nested_symbol() [](#method-i-test_backslash_continued_nested_symbol) - -## test_case_in() [](#method-i-test_case_in) - -## test_for_in() [](#method-i-test_for_in) - -## test_heredoc_embexpr() [](#method-i-test_heredoc_embexpr) - -## test_multiline_string() [](#method-i-test_multiline_string) - -## test_oneliner_def() [](#method-i-test_oneliner_def) - -## test_open_tokens() [](#method-i-test_open_tokens) - -## test_parse_by_line() [](#method-i-test_parse_by_line) - -## test_ruby_syntax() [](#method-i-test_ruby_syntax) - -## test_undef_alias() [](#method-i-test_undef_alias) - -## test_while_until() [](#method-i-test_while_until) - diff --git a/example/ruby/TestIRB/OptionTest.md b/example/ruby/TestIRB/OptionTest.md deleted file mode 100644 index b2ca30f..0000000 --- a/example/ruby/TestIRB/OptionTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::OptionTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## test_end_of_option() [](#method-i-test_end_of_option) - diff --git a/example/ruby/TestIRB/PopwsTest.md b/example/ruby/TestIRB/PopwsTest.md deleted file mode 100644 index 56f85c6..0000000 --- a/example/ruby/TestIRB/PopwsTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::PopwsTest -**Inherits:** TestIRB::WorkspaceCommandTestCase - - - - - -#Instance Methods -## test_popws_prints_help_message_if_the_workspace_is_empty() [](#method-i-test_popws_prints_help_message_if_the_workspace_is_empty) - -## test_popws_replaces_the_current_workspace_with_the_previous_one() [](#method-i-test_popws_replaces_the_current_workspace_with_the_previous_one) - diff --git a/example/ruby/TestIRB/PushwsTest.md b/example/ruby/TestIRB/PushwsTest.md deleted file mode 100644 index 69d4732..0000000 --- a/example/ruby/TestIRB/PushwsTest.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestIRB::PushwsTest -**Inherits:** TestIRB::WorkspaceCommandTestCase - - - - - -#Instance Methods -## test_pushws_extends_the_new_workspace_with_command_bundle() [](#method-i-test_pushws_extends_the_new_workspace_with_command_bundle) - -## test_pushws_prints_workspace_stack_when_no_arg_is_given() [](#method-i-test_pushws_prints_workspace_stack_when_no_arg_is_given) - -## test_pushws_switches_to_new_workspace_and_pushes_the_current_one_to_the_stack() [](#method-i-test_pushws_switches_to_new_workspace_and_pushes_the_current_one_to_the_stack) - -## test_pushws_without_argument_swaps_the_top_two_workspaces() [](#method-i-test_pushws_without_argument_swaps_the_top_two_workspaces) - diff --git a/example/ruby/TestIRB/RaiseExceptionTest.md b/example/ruby/TestIRB/RaiseExceptionTest.md deleted file mode 100644 index 634999b..0000000 --- a/example/ruby/TestIRB/RaiseExceptionTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIRB::RaiseExceptionTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## test_raise_exception_with_different_encoding_containing_invalid_byte_sequence() [](#method-i-test_raise_exception_with_different_encoding_containing_invalid_byte_sequence) - -## test_raise_exception_with_invalid_byte_sequence() [](#method-i-test_raise_exception_with_invalid_byte_sequence) - -## test_raise_exception_with_message_exception() [](#method-i-test_raise_exception_with_message_exception) - -## test_raise_exception_with_message_inspect_exception() [](#method-i-test_raise_exception_with_message_inspect_exception) - -## test_raise_exception_with_nil_backtrace() [](#method-i-test_raise_exception_with_nil_backtrace) - diff --git a/example/ruby/TestIRB/RelineInputMethodTest.md b/example/ruby/TestIRB/RelineInputMethodTest.md deleted file mode 100644 index a95ebbc..0000000 --- a/example/ruby/TestIRB/RelineInputMethodTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIRB::RelineInputMethodTest -**Inherits:** TestIRB::InputMethodTest - - - - - -#Instance Methods -## test_colorize() [](#method-i-test_colorize) - -## test_initialization() [](#method-i-test_initialization) - -## test_initialization_with_use_autocomplete() [](#method-i-test_initialization_with_use_autocomplete) - -## test_initialization_with_use_autocomplete_but_without_rdoc() [](#method-i-test_initialization_with_use_autocomplete_but_without_rdoc) - -## test_initialization_without_use_autocomplete() [](#method-i-test_initialization_without_use_autocomplete) - diff --git a/example/ruby/TestIRB/RubyLexTest.md b/example/ruby/TestIRB/RubyLexTest.md deleted file mode 100644 index d4940cd..0000000 --- a/example/ruby/TestIRB/RubyLexTest.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestIRB::RubyLexTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_assignment_expression() [](#method-i-test_assignment_expression) - -## test_assignment_expression_with_local_variable() [](#method-i-test_assignment_expression_with_local_variable) - -## test_broken_percent_literal() [](#method-i-test_broken_percent_literal) - -## test_broken_percent_literal_in_method() [](#method-i-test_broken_percent_literal_in_method) - -## test_code_block_open_with_should_continue() [](#method-i-test_code_block_open_with_should_continue) - -## test_indent_level_with_heredoc_and_embdoc() [](#method-i-test_indent_level_with_heredoc_and_embdoc) - -## test_initialising_the_old_top_level_ruby_lex() [](#method-i-test_initialising_the_old_top_level_ruby_lex) - -## test_interpolate_token_with_heredoc_and_unclosed_embexpr() [](#method-i-test_interpolate_token_with_heredoc_and_unclosed_embexpr) - -## test_literal_ends_with_newline() [](#method-i-test_literal_ends_with_newline) - -## test_literal_ends_with_space() [](#method-i-test_literal_ends_with_space) - -## test_local_variables_dependent_code() [](#method-i-test_local_variables_dependent_code) - -## test_should_continue() [](#method-i-test_should_continue) - -## test_unterminated_code() [](#method-i-test_unterminated_code) - -## test_unterminated_heredoc_string_literal() [](#method-i-test_unterminated_heredoc_string_literal) - diff --git a/example/ruby/TestIRB/ShowDocTest.md b/example/ruby/TestIRB/ShowDocTest.md deleted file mode 100644 index 3bf5e5c..0000000 --- a/example/ruby/TestIRB/ShowDocTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::ShowDocTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## test_show_doc() [](#method-i-test_show_doc) - -## test_show_doc_without_rdoc() [](#method-i-test_show_doc_without_rdoc) - diff --git a/example/ruby/TestIRB/ShowSourceTest.md b/example/ruby/TestIRB/ShowSourceTest.md deleted file mode 100644 index 382320d..0000000 --- a/example/ruby/TestIRB/ShowSourceTest.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: TestIRB::ShowSourceTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_show_source() [](#method-i-test_show_source) - -## test_show_source_alias() [](#method-i-test_show_source_alias) - -## test_show_source_keep_script_lines() [](#method-i-test_show_source_keep_script_lines) - -## test_show_source_method_accidental_characters() [](#method-i-test_show_source_method_accidental_characters) - -## test_show_source_method_exceeds_super_chain() [](#method-i-test_show_source_method_exceeds_super_chain) - -## test_show_source_method_multiple_s() [](#method-i-test_show_source_method_multiple_s) - -## test_show_source_method_no_instance_method() [](#method-i-test_show_source_method_no_instance_method) - -## test_show_source_method_s() [](#method-i-test_show_source_method_s) - -## test_show_source_method_s_with_incorrect_signature() [](#method-i-test_show_source_method_s_with_incorrect_signature) - -## test_show_source_private_method() [](#method-i-test_show_source_private_method) - -## test_show_source_private_singleton_method() [](#method-i-test_show_source_private_singleton_method) - -## test_show_source_receiver_super() [](#method-i-test_show_source_receiver_super) - -## test_show_source_shows_binary_source() [](#method-i-test_show_source_shows_binary_source) - -## test_show_source_string() [](#method-i-test_show_source_string) - -## test_show_source_unavailable_source() [](#method-i-test_show_source_unavailable_source) - -## test_show_source_with_constant_lookup() [](#method-i-test_show_source_with_constant_lookup) - -## test_show_source_with_double_colons() [](#method-i-test_show_source_with_double_colons) - -## test_show_source_with_eval_error() [](#method-i-test_show_source_with_eval_error) - -## test_show_source_with_missing_constant() [](#method-i-test_show_source_with_missing_constant) - -## test_show_source_with_missing_signature() [](#method-i-test_show_source_with_missing_signature) - diff --git a/example/ruby/TestIRB/TestCase.md b/example/ruby/TestIRB/TestCase.md deleted file mode 100644 index c8624f7..0000000 --- a/example/ruby/TestIRB/TestCase.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestIRB::TestCase -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## restore_encodings() [](#method-i-restore_encodings) - -## ruby_core?() [](#method-i-ruby_core?) - -**@return** [Boolean] - -## save_encodings() [](#method-i-save_encodings) - -## setup_envs(home:) [](#method-i-setup_envs) - -## teardown_envs() [](#method-i-teardown_envs) - -## without_rdoc(&block) [](#method-i-without_rdoc) - diff --git a/example/ruby/TestIRB/TestCase/TestInputMethod.md b/example/ruby/TestIRB/TestCase/TestInputMethod.md deleted file mode 100644 index a6cae44..0000000 --- a/example/ruby/TestIRB/TestCase/TestInputMethod.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: TestIRB::TestCase::TestInputMethod -**Inherits:** IRB::InputMethod - - - - -# Attributes -## line_no[RW] [](#attribute-i-line_no) -Returns the value of attribute line_no. - -## list[RW] [](#attribute-i-list) -Returns the value of attribute list. - - -#Instance Methods -## encoding() [](#method-i-encoding) - -## eof?() [](#method-i-eof?) - -**@return** [Boolean] - -## gets() [](#method-i-gets) - -## initialize(list[]) [](#method-i-initialize) - -**@return** [TestInputMethod] a new instance of TestInputMethod - -## reset() [](#method-i-reset) - diff --git a/example/ruby/TestIRB/TestHelperMethod.md b/example/ruby/TestIRB/TestHelperMethod.md deleted file mode 100644 index a99d44f..0000000 --- a/example/ruby/TestIRB/TestHelperMethod.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestIRB::TestHelperMethod - - - - - diff --git a/example/ruby/TestIRB/TestHelperMethod/ConfTest.md b/example/ruby/TestIRB/TestHelperMethod/ConfTest.md deleted file mode 100644 index 8ba01ef..0000000 --- a/example/ruby/TestIRB/TestHelperMethod/ConfTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::TestHelperMethod::ConfTest -**Inherits:** TestIRB::HelperMethodTestCase - - - - - -#Instance Methods -## test_conf_returns_the_context_object() [](#method-i-test_conf_returns_the_context_object) - diff --git a/example/ruby/TestIRB/TypeCompletorIntegrationTest.md b/example/ruby/TestIRB/TypeCompletorIntegrationTest.md deleted file mode 100644 index 4004cbf..0000000 --- a/example/ruby/TestIRB/TypeCompletorIntegrationTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::TypeCompletorIntegrationTest -**Inherits:** TestIRB::IntegrationTestCase - - - - - -#Instance Methods -## test_type_completor() [](#method-i-test_type_completor) - diff --git a/example/ruby/TestIRB/TypeCompletorTest.md b/example/ruby/TestIRB/TypeCompletorTest.md deleted file mode 100644 index df9e833..0000000 --- a/example/ruby/TestIRB/TypeCompletorTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestIRB::TypeCompletorTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## assert_completion(preposing, target, binding:empty_binding, include:nil, exclude:nil) [](#method-i-assert_completion) - -**@raise** [ArgumentError] - -## assert_doc_namespace(preposing, target, namespace, binding:empty_binding) [](#method-i-assert_doc_namespace) - -## empty_binding() [](#method-i-empty_binding) - -## setup() [](#method-i-setup) - -## test_build_completor() [](#method-i-test_build_completor) - -## test_command_completion() [](#method-i-test_command_completion) - -## test_empty_completion() [](#method-i-test_empty_completion) - -## test_inspect() [](#method-i-test_inspect) - -## test_type_completion() [](#method-i-test_type_completion) - diff --git a/example/ruby/TestIRB/TypeCompletorTest/DummyContext.md b/example/ruby/TestIRB/TypeCompletorTest/DummyContext.md deleted file mode 100644 index 9a573ac..0000000 --- a/example/ruby/TestIRB/TypeCompletorTest/DummyContext.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: TestIRB::TypeCompletorTest::DummyContext -**Inherits:** Struct - - - - -# Attributes -## irb_path[RW] [](#attribute-i-irb_path) -Returns the value of attribute irb_path - -**@return** [Object] the current value of irb_path - - diff --git a/example/ruby/TestIRB/WhereamiTest.md b/example/ruby/TestIRB/WhereamiTest.md deleted file mode 100644 index 09ff0aa..0000000 --- a/example/ruby/TestIRB/WhereamiTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIRB::WhereamiTest -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## test_whereami() [](#method-i-test_whereami) - -## test_whereami_alias() [](#method-i-test_whereami_alias) - diff --git a/example/ruby/TestIRB/WorkSpaceTest.md b/example/ruby/TestIRB/WorkSpaceTest.md deleted file mode 100644 index b4bb9e2..0000000 --- a/example/ruby/TestIRB/WorkSpaceTest.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestIRB::WorkSpaceTest -**Inherits:** TestIRB::TestCase - - - - - -#Instance Methods -## test_code_around_binding() [](#method-i-test_code_around_binding) - -## test_code_around_binding_on_irb() [](#method-i-test_code_around_binding_on_irb) - -## test_code_around_binding_with_existing_unreadable_file() [](#method-i-test_code_around_binding_with_existing_unreadable_file) - -## test_code_around_binding_with_script_lines__() [](#method-i-test_code_around_binding_with_script_lines__) - -## test_toplevel_binding_local_variables() [](#method-i-test_toplevel_binding_local_variables) - diff --git a/example/ruby/TestIRB/WorkspaceCommandTestCase.md b/example/ruby/TestIRB/WorkspaceCommandTestCase.md deleted file mode 100644 index 481e5e7..0000000 --- a/example/ruby/TestIRB/WorkspaceCommandTestCase.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::WorkspaceCommandTestCase -**Inherits:** TestIRB::CommandTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - diff --git a/example/ruby/TestIRB/WorkspacesTest.md b/example/ruby/TestIRB/WorkspacesTest.md deleted file mode 100644 index cde30e9..0000000 --- a/example/ruby/TestIRB/WorkspacesTest.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIRB::WorkspacesTest -**Inherits:** TestIRB::WorkspaceCommandTestCase - - - - - -#Instance Methods -## test_workspaces_returns_the_stack_of_workspaces() [](#method-i-test_workspaces_returns_the_stack_of_workspaces) - diff --git a/example/ruby/TestISO8859.md b/example/ruby/TestISO8859.md deleted file mode 100644 index 84544e0..0000000 --- a/example/ruby/TestISO8859.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestISO8859 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_iso_8859_1() [](#method-i-test_iso_8859_1) - -## test_iso_8859_10() [](#method-i-test_iso_8859_10) - -## test_iso_8859_11() [](#method-i-test_iso_8859_11) - -## test_iso_8859_13() [](#method-i-test_iso_8859_13) - -## test_iso_8859_14() [](#method-i-test_iso_8859_14) - -## test_iso_8859_15() [](#method-i-test_iso_8859_15) - -## test_iso_8859_16() [](#method-i-test_iso_8859_16) - -## test_iso_8859_2() [](#method-i-test_iso_8859_2) - -## test_iso_8859_3() [](#method-i-test_iso_8859_3) - -## test_iso_8859_4() [](#method-i-test_iso_8859_4) - -## test_iso_8859_5() [](#method-i-test_iso_8859_5) - -## test_iso_8859_6() [](#method-i-test_iso_8859_6) - -## test_iso_8859_7() [](#method-i-test_iso_8859_7) - -## test_iso_8859_8() [](#method-i-test_iso_8859_8) - -## test_iso_8859_9() [](#method-i-test_iso_8859_9) - diff --git a/example/ruby/TestISeq.md b/example/ruby/TestISeq.md deleted file mode 100644 index 3c28937..0000000 --- a/example/ruby/TestISeq.md +++ /dev/null @@ -1,168 +0,0 @@ -# Class: TestISeq -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## anon_block() [](#method-i-anon_block) - -## anon_keyrest() [](#method-i-anon_keyrest) - -## anon_star() [](#method-i-anon_star) - -## assert_iseq_to_binary(code, mesgnil) [](#method-i-assert_iseq_to_binary) - -## block_unused_method() [](#method-i-block_unused_method) - -## block_using_method() [](#method-i-block_using_method) - -## collect_from_binary_tracepoint_lines(tracepoint_type, filename) [](#method-i-collect_from_binary_tracepoint_lines) - -## compile(src, linenil, optnil) [](#method-i-compile) - -## hexdump(bin) [](#method-i-hexdump) - -## lines(src, linesnil) [](#method-i-lines) - -## method_test_line_trace() [](#method-i-method_test_line_trace) - -## sample_iseq() [](#method-i-sample_iseq) - -## strip_lineno(source) [](#method-i-strip_lineno) - -## test_allocate() [](#method-i-test_allocate) - -## test_anon_block_param_in_disasm() [](#method-i-test_anon_block_param_in_disasm) - -## test_anon_keyrest_param_in_disasm() [](#method-i-test_anon_keyrest_param_in_disasm) - -## test_anon_rest_param_in_disasm() [](#method-i-test_anon_rest_param_in_disasm) - -## test_cdhash_after_roundtrip() [](#method-i-test_cdhash_after_roundtrip) - -## test_compile_error() [](#method-i-test_compile_error) -Bug #19173 -: - -## test_compile_file_encoding() [](#method-i-test_compile_file_encoding) - -## test_compile_file_error() [](#method-i-test_compile_file_error) - -## test_compile_prism_with_file() [](#method-i-test_compile_prism_with_file) - -## test_compile_prism_with_invalid_object_type() [](#method-i-test_compile_prism_with_invalid_object_type) - -## test_disable_opt() [](#method-i-test_disable_opt) - -## test_disasm_encoding() [](#method-i-test_disasm_encoding) - -## test_each_child() [](#method-i-test_each_child) - -## test_empty_iseq_lineno() [](#method-i-test_empty_iseq_lineno) - -## test_ever_condition_loop() [](#method-i-test_ever_condition_loop) - -## test_forwardable() [](#method-i-test_forwardable) - -## test_frozen_string_literal_compile_option() [](#method-i-test_frozen_string_literal_compile_option) - -## test_ibf_bignum() [](#method-i-test_ibf_bignum) - -## test_inspect() [](#method-i-test_inspect) - -## test_invalid_source() [](#method-i-test_invalid_source) - -## test_iseq_builtin_load() [](#method-i-test_iseq_builtin_load) - -## test_iseq_builtin_to_a() [](#method-i-test_iseq_builtin_to_a) - -## test_iseq_of() [](#method-i-test_iseq_of) - -## test_iseq_of_twice_for_same_code() [](#method-i-test_iseq_of_twice_for_same_code) - -## test_iseq_option_debug_level() [](#method-i-test_iseq_option_debug_level) - -## test_label_fstring() [](#method-i-test_label_fstring) - -## test_lambda_with_ractor_roundtrip() [](#method-i-test_lambda_with_ractor_roundtrip) - -## test_line_trace() [](#method-i-test_line_trace) - -## test_load_from_binary_only_accepts_string_param() [](#method-i-test_load_from_binary_only_accepts_string_param) - -## test_loaded_cdhash_mark() [](#method-i-test_loaded_cdhash_mark) - -## test_loading_kwargs_memory_leak() [](#method-i-test_loading_kwargs_memory_leak) - -## test_location() [](#method-i-test_location) - -## test_mandatory_only() [](#method-i-test_mandatory_only) - -## test_mandatory_only_redef() [](#method-i-test_mandatory_only_redef) - -## test_no_linenum() [](#method-i-test_no_linenum) - -## test_parent_iseq_mark() [](#method-i-test_parent_iseq_mark) - -## test_ractor_shareable_value_frozen_core() [](#method-i-test_ractor_shareable_value_frozen_core) - -## test_ractor_unshareable_outer_variable() [](#method-i-test_ractor_unshareable_outer_variable) - -## test_safe_call_chain() [](#method-i-test_safe_call_chain) -Safe call chain is not optimized when Coverage is running. So we can test it -only when Coverage is not running. - -## test_super_with_anonymous_block() [](#method-i-test_super_with_anonymous_block) - -## test_super_with_block() [](#method-i-test_super_with_block) - -## test_super_with_block_and_kwrest() [](#method-i-test_super_with_block_and_kwrest) - -## test_super_with_block_hash_0() [](#method-i-test_super_with_block_hash_0) - -## test_syntax_error_message() [](#method-i-test_syntax_error_message) - -## test_to_a_lines() [](#method-i-test_to_a_lines) - -## test_to_binary_b_call_tracepoint() [](#method-i-test_to_binary_b_call_tracepoint) - -## test_to_binary_b_return_tracepoint() [](#method-i-test_to_binary_b_return_tracepoint) - -## test_to_binary_class_tracepoint() [](#method-i-test_to_binary_class_tracepoint) - -## test_to_binary_dumps_nokey() [](#method-i-test_to_binary_dumps_nokey) - -## test_to_binary_end_tracepoint() [](#method-i-test_to_binary_end_tracepoint) - -## test_to_binary_line_info() [](#method-i-test_to_binary_line_info) - -## test_to_binary_line_tracepoint() [](#method-i-test_to_binary_line_tracepoint) - -## test_to_binary_pattern_matching() [](#method-i-test_to_binary_pattern_matching) - -## test_to_binary_return_tracepoint() [](#method-i-test_to_binary_return_tracepoint) - -## test_to_binary_with_hidden_local_variables() [](#method-i-test_to_binary_with_hidden_local_variables) - -## test_to_binary_with_objects() [](#method-i-test_to_binary_with_objects) - -## test_trace_points() [](#method-i-test_trace_points) - -## test_translate_by_object() [](#method-i-test_translate_by_object) - -## test_unreachable_next_in_block() [](#method-i-test_unreachable_next_in_block) - -## test_unreachable_pattern_matching() [](#method-i-test_unreachable_pattern_matching) - -## test_unreachable_pattern_matching_in_if_condition() [](#method-i-test_unreachable_pattern_matching_in_if_condition) - -## test_unreachable_syntax_error() [](#method-i-test_unreachable_syntax_error) - -## test_unsupported_type() [](#method-i-test_unsupported_type) - -## test_unused_param() [](#method-i-test_unused_param) - -## test_while_in_until_condition() [](#method-i-test_while_in_until_condition) - diff --git a/example/ruby/TestIfUnless.md b/example/ruby/TestIfUnless.md deleted file mode 100644 index 3027cc8..0000000 --- a/example/ruby/TestIfUnless.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIfUnless -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_if_unless() [](#method-i-test_if_unless) - diff --git a/example/ruby/TestInsnsLeaf.md b/example/ruby/TestInsnsLeaf.md deleted file mode 100644 index 2ecf9d5..0000000 --- a/example/ruby/TestInsnsLeaf.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestInsnsLeaf -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_insns_leaf() [](#method-i-test_insns_leaf) - diff --git a/example/ruby/TestInsnsLeaf/Id.md b/example/ruby/TestInsnsLeaf/Id.md deleted file mode 100644 index 69ff3e3..0000000 --- a/example/ruby/TestInsnsLeaf/Id.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestInsnsLeaf::Id -**Inherits:** Object - - - - -# Attributes -## db_id[RW] [](#attribute-i-db_id) -Returns the value of attribute db_id. - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - -## ==(other) [](#method-i-==) - -## hash() [](#method-i-hash) - -## initialize(db_id) [](#method-i-initialize) - -**@return** [Id] a new instance of Id - diff --git a/example/ruby/TestInsnsLeaf/Namespace.md b/example/ruby/TestInsnsLeaf/Namespace.md deleted file mode 100644 index 5372618..0000000 --- a/example/ruby/TestInsnsLeaf/Namespace.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: TestInsnsLeaf::Namespace -**Inherits:** Object - - - - -# Class Methods -## test?(id ) [](#method-c-test?) -**@return** [Boolean] - - diff --git a/example/ruby/TestInteger.md b/example/ruby/TestInteger.md deleted file mode 100644 index 0894de2..0000000 --- a/example/ruby/TestInteger.md +++ /dev/null @@ -1,89 +0,0 @@ -# Class: TestInteger -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## to_int() [](#method-c-to_int) -## to_str() [](#method-c-to_str) - -#Instance Methods -## assert_float_equal(expected, result, mesgnil) [](#method-i-assert_float_equal) - -## assert_int_equal(expected, result, mesgnil) [](#method-i-assert_int_equal) - -## test_Integer() [](#method-i-test_Integer) - -## test_Integer_when_to_str() [](#method-i-test_Integer_when_to_str) - -## test_Integer_with_base() [](#method-i-test_Integer_with_base) - -## test_Integer_with_exception_keyword() [](#method-i-test_Integer_with_exception_keyword) - -## test_Integer_with_invalid_exception() [](#method-i-test_Integer_with_invalid_exception) - -## test_aref() [](#method-i-test_aref) - -## test_bit_length() [](#method-i-test_bit_length) - -## test_bitwise_and_with_integer_coercion() [](#method-i-test_bitwise_and_with_integer_coercion) - -## test_bitwise_and_with_integer_mimic_object() [](#method-i-test_bitwise_and_with_integer_mimic_object) - -## test_bitwise_or_with_integer_coercion() [](#method-i-test_bitwise_or_with_integer_coercion) - -## test_bitwise_or_with_integer_mimic_object() [](#method-i-test_bitwise_or_with_integer_mimic_object) - -## test_bitwise_xor_with_integer_coercion() [](#method-i-test_bitwise_xor_with_integer_coercion) - -## test_bitwise_xor_with_integer_mimic_object() [](#method-i-test_bitwise_xor_with_integer_mimic_object) - -## test_ceil() [](#method-i-test_ceil) - -## test_ceildiv() [](#method-i-test_ceildiv) - -## test_chr() [](#method-i-test_chr) - -## test_digits() [](#method-i-test_digits) - -## test_digits_for_invalid_base_numbers() [](#method-i-test_digits_for_invalid_base_numbers) - -## test_digits_for_negative_numbers() [](#method-i-test_digits_for_negative_numbers) - -## test_digits_for_non_integral_base_numbers() [](#method-i-test_digits_for_non_integral_base_numbers) - -## test_digits_for_non_numeric_base_argument() [](#method-i-test_digits_for_non_numeric_base_argument) - -## test_downto() [](#method-i-test_downto) - -## test_fdiv() [](#method-i-test_fdiv) - -## test_floor() [](#method-i-test_floor) - -## test_int_p() [](#method-i-test_int_p) - -## test_lshift() [](#method-i-test_lshift) - -## test_obj_fdiv() [](#method-i-test_obj_fdiv) - -## test_pow() [](#method-i-test_pow) - -## test_round() [](#method-i-test_round) - -## test_rshift() [](#method-i-test_rshift) - -## test_square_root() [](#method-i-test_square_root) - -## test_succ() [](#method-i-test_succ) - -## test_times() [](#method-i-test_times) - -## test_times_bignum_redefine_plus_lt() [](#method-i-test_times_bignum_redefine_plus_lt) - -## test_truncate() [](#method-i-test_truncate) - -## test_try_convert() [](#method-i-test_try_convert) - -## test_upto() [](#method-i-test_upto) - diff --git a/example/ruby/TestInteger/CoercionToInt.md b/example/ruby/TestInteger/CoercionToInt.md deleted file mode 100644 index 03adc01..0000000 --- a/example/ruby/TestInteger/CoercionToInt.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestInteger::CoercionToInt - - - - - -#Instance Methods -## coerce(other) [](#method-i-coerce) - diff --git a/example/ruby/TestInteger/CoercionToSelf.md b/example/ruby/TestInteger/CoercionToSelf.md deleted file mode 100644 index 25d8a24..0000000 --- a/example/ruby/TestInteger/CoercionToSelf.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestInteger::CoercionToSelf - - - - - -#Instance Methods -## coerce(other) [](#method-i-coerce) - diff --git a/example/ruby/TestInteger/MimicInteger.md b/example/ruby/TestInteger/MimicInteger.md deleted file mode 100644 index 1a0e35f..0000000 --- a/example/ruby/TestInteger/MimicInteger.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: TestInteger::MimicInteger -**Inherits:** Struct - - - - -# Attributes -## to_int[RW] [](#attribute-i-to_int) -Returns the value of attribute to_int - -**@return** [Object] the current value of to_int - - diff --git a/example/ruby/TestIntegerComb.md b/example/ruby/TestIntegerComb.md deleted file mode 100644 index 6b24bde..0000000 --- a/example/ruby/TestIntegerComb.md +++ /dev/null @@ -1,93 +0,0 @@ -# Class: TestIntegerComb -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_abs() [](#method-i-test_abs) - -## test_allbits_p() [](#method-i-test_allbits_p) - -## test_and() [](#method-i-test_and) - -## test_anybits_p() [](#method-i-test_anybits_p) - -## test_aref() [](#method-i-test_aref) -VS.map! {|v| [0x4000000000000000.coerce(v)](0) } VS.concat VS.find_all {|v| -Fixnum === v }.map {|v| [0x4000000000000000.coerce(v)](0) } VS.sort! {|a, b| -a.abs <=> b.abs } - -## test_ceil() [](#method-i-test_ceil) - -## test_cmp() [](#method-i-test_cmp) - -## test_divmod() [](#method-i-test_divmod) - -## test_eq() [](#method-i-test_eq) - -## test_even_odd() [](#method-i-test_even_odd) - -## test_floor() [](#method-i-test_floor) - -## test_lshift() [](#method-i-test_lshift) - -## test_marshal() [](#method-i-test_marshal) - -## test_minus() [](#method-i-test_minus) - -## test_mult() [](#method-i-test_mult) - -## test_nobits_p() [](#method-i-test_nobits_p) - -## test_not() [](#method-i-test_not) - -## test_or() [](#method-i-test_or) - -## test_pack() [](#method-i-test_pack) - -## test_pack_ber() [](#method-i-test_pack_ber) - -## test_pack_utf8() [](#method-i-test_pack_utf8) - -## test_plus() [](#method-i-test_plus) - -## test_pow() [](#method-i-test_pow) - -## test_pred() [](#method-i-test_pred) - -## test_printf_b() [](#method-i-test_printf_b) - -## test_printf_b_sign() [](#method-i-test_printf_b_sign) - -## test_printf_diu() [](#method-i-test_printf_diu) - -## test_printf_o() [](#method-i-test_printf_o) - -## test_printf_o_sign() [](#method-i-test_printf_o_sign) - -## test_printf_x() [](#method-i-test_printf_x) - -## test_printf_x_sign() [](#method-i-test_printf_x_sign) - -## test_remainder() [](#method-i-test_remainder) - -## test_round() [](#method-i-test_round) - -## test_rshift() [](#method-i-test_rshift) - -## test_succ() [](#method-i-test_succ) - -## test_to_s() [](#method-i-test_to_s) - -## test_truncate() [](#method-i-test_truncate) - -## test_unary_minus() [](#method-i-test_unary_minus) - -## test_unary_plus() [](#method-i-test_unary_plus) - -## test_xor() [](#method-i-test_xor) - -## test_zero_nonzero() [](#method-i-test_zero_nonzero) - diff --git a/example/ruby/TestInvokeVerb.md b/example/ruby/TestInvokeVerb.md deleted file mode 100644 index 31a3ab9..0000000 --- a/example/ruby/TestInvokeVerb.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestInvokeVerb -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## find_link(path) [](#method-i-find_link) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_invokeverb() [](#method-i-test_invokeverb) - diff --git a/example/ruby/TestIseqLoad.md b/example/ruby/TestIseqLoad.md deleted file mode 100644 index 8b4d474..0000000 --- a/example/ruby/TestIseqLoad.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: TestIseqLoad -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_iseq_roundtrip(src, linecaller_locations(1,1)[0].lineno+1) [](#method-i-assert_iseq_roundtrip) - -## test_break_ensure() [](#method-i-test_break_ensure) - -## test_bug8543() [](#method-i-test_bug8543) - -## test_case_when() [](#method-i-test_case_when) - -## test_hidden() [](#method-i-test_hidden) - -## test_kwarg() [](#method-i-test_kwarg) - -## test_next_in_block_in_block() [](#method-i-test_next_in_block_in_block) - -## test_require_integration() [](#method-i-test_require_integration) -FIXME: still failing - -## test_splatsplat() [](#method-i-test_splatsplat) - -## test_stressful_roundtrip() [](#method-i-test_stressful_roundtrip) - diff --git a/example/ruby/TestIter.md b/example/ruby/TestIter.md deleted file mode 100644 index 35687ed..0000000 --- a/example/ruby/TestIter.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestIter - - - - - diff --git a/example/ruby/TestIter/IterBreak.md b/example/ruby/TestIter/IterBreak.md deleted file mode 100644 index 8dfa4f9..0000000 --- a/example/ruby/TestIter/IterBreak.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIter::IterBreak -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_iter_break() [](#method-i-test_iter_break) - diff --git a/example/ruby/TestIter/YieldBlock.md b/example/ruby/TestIter/YieldBlock.md deleted file mode 100644 index 3262179..0000000 --- a/example/ruby/TestIter/YieldBlock.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIter::YieldBlock -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_yield_block() [](#method-i-test_yield_block) - -## test_yield_lambda() [](#method-i-test_yield_lambda) - diff --git a/example/ruby/TestIter/YieldBlock/YieldTest.md b/example/ruby/TestIter/YieldBlock/YieldTest.md deleted file mode 100644 index 0928089..0000000 --- a/example/ruby/TestIter/YieldBlock/YieldTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestIter::YieldBlock::YieldTest -**Inherits:** Object - -**Includes:** Bug::Iter::Yield - - - - -# Attributes -## blockarg[RW] [](#attribute-i-blockarg) -Returns the value of attribute blockarg. - - -#Instance Methods -## call_lambda(&block) [](#method-i-call_lambda) - -## call_proc(&block) [](#method-i-call_proc) - -## test(arg, &block) [](#method-i-test) - diff --git a/example/ruby/TestIterator.md b/example/ruby/TestIterator.md deleted file mode 100644 index e4664f9..0000000 --- a/example/ruby/TestIterator.md +++ /dev/null @@ -1,127 +0,0 @@ -# Class: TestIterator -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## _test_break__nested_loop1() [](#method-i-_test_break__nested_loop1) - -## _test_break__nested_loop2() [](#method-i-_test_break__nested_loop2) - -## _test_break__nested_loop3() [](#method-i-_test_break__nested_loop3) - -## _test_return_trace_func(x) [](#method-i-_test_return_trace_func) - -## bar(&blk) [](#method-i-bar) - -## foo() [](#method-i-foo) - -**@yield** [:key, :value] - -## get_block(&block) [](#method-i-get_block) - -## m(var) [](#method-i-m) - -## m1() [](#method-i-m1) - -## m2() [](#method-i-m2) - -## m3(var, &block) [](#method-i-m3) - -## m4(&block) [](#method-i-m4) - -## marity_test(m) [](#method-i-marity_test) - -## proc_call(&b) [](#method-i-proc_call) - -## proc_call2(b) [](#method-i-proc_call2) - -## proc_return1() [](#method-i-proc_return1) - -## proc_return2() [](#method-i-proc_return2) - -## proc_yield() [](#method-i-proc_yield) - -## return1_test() [](#method-i-return1_test) - -## return2_test() [](#method-i-return2_test) - -## test_append_method_to_built_in_class() [](#method-i-test_append_method_to_built_in_class) - -## test_argument() [](#method-i-test_argument) - -## test_array() [](#method-i-test_array) - -## test_array_for_masgn() [](#method-i-test_array_for_masgn) - -## test_assoc_yield() [](#method-i-test_assoc_yield) - -## test_block() [](#method-i-test_block) - -## test_block_argument_without_paren() [](#method-i-test_block_argument_without_paren) - -## test_block_given() [](#method-i-test_block_given) - -## test_block_given_within_iterator() [](#method-i-test_block_given_within_iterator) -Check that the block passed to an iterator does not get propagated -inappropriately - -## test_block_passing() [](#method-i-test_block_passing) - -## test_break() [](#method-i-test_break) -iterator break/redo/next - -## test_break__nested_loop1() [](#method-i-test_break__nested_loop1) - -## test_break__nested_loop2() [](#method-i-test_break__nested_loop2) - -## test_break__nested_loop3() [](#method-i-test_break__nested_loop3) - -## test_break_from_enum() [](#method-i-test_break_from_enum) - -## test_collect() [](#method-i-test_collect) - -## test_enumerator() [](#method-i-test_enumerator) - -## test_get_block() [](#method-i-test_get_block) - -## test_iter4() [](#method-i-test_iter4) - -## test_iter_test2() [](#method-i-test_iter_test2) - -## test_itertest() [](#method-i-test_itertest) - -## test_ljump() [](#method-i-test_ljump) - -## test_marity() [](#method-i-test_marity) - -## test_nested_iterator() [](#method-i-test_nested_iterator) - -## test_proc() [](#method-i-test_proc) - -## test_proc_return1() [](#method-i-test_proc_return1) - -## test_proc_return2() [](#method-i-test_proc_return2) - -## test_return1() [](#method-i-test_return1) - -## test_return2() [](#method-i-test_return2) - -## test_return_trace_func() [](#method-i-test_return_trace_func) - -## test_yield_at_toplevel() [](#method-i-test_yield_at_toplevel) - -## test_yield_vs_call() [](#method-i-test_yield_vs_call) - -## tt() [](#method-i-tt) - -## tt2(dummy) [](#method-i-tt2) - -**@yield** [1] - -## tt3(&block) [](#method-i-tt3) - -## tt4(&block) [](#method-i-tt4) - diff --git a/example/ruby/TestIterator/C.md b/example/ruby/TestIterator/C.md deleted file mode 100644 index 2357729..0000000 --- a/example/ruby/TestIterator/C.md +++ /dev/null @@ -1,2074 +0,0 @@ -# Class: TestIterator::C -**Inherits:** Object - -**Includes:** Enumerable - - - - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(&block) [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize() [](#method-i-initialize) - -**@return** [C] a new instance of C - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/TestIterator/H.md b/example/ruby/TestIterator/H.md deleted file mode 100644 index 9b8b635..0000000 --- a/example/ruby/TestIterator/H.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestIterator::H -**Inherits:** Object - - - - - -#Instance Methods -## each() [](#method-i-each) - -**@yield** [[:key, :value]] - diff --git a/example/ruby/TestIterator/ITER_TEST1.md b/example/ruby/TestIterator/ITER_TEST1.md deleted file mode 100644 index 520668e..0000000 --- a/example/ruby/TestIterator/ITER_TEST1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIterator::ITER_TEST1 -**Inherits:** Object - - - - - -#Instance Methods -## a() [](#method-i-a) - diff --git a/example/ruby/TestIterator/ITER_TEST2.md b/example/ruby/TestIterator/ITER_TEST2.md deleted file mode 100644 index a1ddb94..0000000 --- a/example/ruby/TestIterator/ITER_TEST2.md +++ /dev/null @@ -1,326 +0,0 @@ -# Class: TestIterator::ITER_TEST2 -**Inherits:** TestIterator::ITER_TEST1 - -**Includes:** Test::Unit::Assertions - - - - - -#Instance Methods -## _assertions() [](#method-i-_assertions) -:nodoc: - -## _assertions=(n) [](#method-i-_assertions=) -:nodoc: - -## a() [](#method-i-a) - -## assert(test, msgnil) [](#method-i-assert) -Fails unless `test` is a true value. - -## assert_bignum(v, msgnil) [](#method-i-assert_bignum) - -## assert_block(*msgs) [](#method-i-assert_block) -:call-seq: - assert_block( failure_message = nil ) - -Tests the result of the given block. If the block does not return true, the -assertion will fail. The optional `failure_message` argument is the same as in -Assertions#assert. - - assert_block do - [1, 2, 3].any? { |num| num < 1 } - end - -## assert_cpu_usage_low(msgnil, pct:0.05, wait:1.0, stop:nil) [](#method-i-assert_cpu_usage_low) - -## assert_empty(obj, msgnil) [](#method-i-assert_empty) -Fails unless `obj` is empty. - -## assert_equal(exp, act, msgnil) [](#method-i-assert_equal) -:call-seq: - assert_equal( expected, actual, failure_message = nil ) - -Tests if `expected` is equal to `actual`. - -An optional failure message may be provided as the final argument. - -## assert_false(obj, msgnil) [](#method-i-assert_false) -Fails unless `obj` is false - -## assert_fixnum(v, msgnil) [](#method-i-assert_fixnum) - -## assert_in_delta(exp, act, delta0.001, msgnil) [](#method-i-assert_in_delta) -For comparing Floats. Fails unless `exp` and `act` are within `delta` of each -other. - - assert_in_delta Math::PI, (22.0 / 7.0), 0.01 - -## assert_in_epsilon(a, b, epsilon0.001, msgnil) [](#method-i-assert_in_epsilon) -For comparing Floats. Fails unless `exp` and `act` have a relative error less -than `epsilon`. - -## assert_includes(collection, obj, msgnil) [](#method-i-assert_includes) -Fails unless `collection` includes `obj`. - -## assert_instance_of(cls, obj, msgnil) [](#method-i-assert_instance_of) -Fails unless `obj` is an instance of `cls`. - -## assert_is_minus_zero(f) [](#method-i-assert_is_minus_zero) - -## assert_kind_of(cls, obj, msgnil) [](#method-i-assert_kind_of) -Fails unless `obj` is a kind of `cls`. - -## assert_match(matcher, obj, msgnil) [](#method-i-assert_match) -Fails unless `matcher` `=~` `obj`. - -## assert_nil(obj, msgnil) [](#method-i-assert_nil) -Fails unless `obj` is nil - -## assert_no_match(regexp, string, msgnil) [](#method-i-assert_no_match) -:call-seq: - assert_no_match( regexp, string, failure_message = nil ) - -Tests if the given Regexp does not match a given String. - -An optional failure message may be provided as the final argument. - -## assert_no_warning(pat, msgnil) [](#method-i-assert_no_warning) - -## assert_not_all?(obj, mnil, &blk) [](#method-i-assert_not_all?) - -**@return** [Boolean] - -## assert_not_equal(exp, act, msgnil) [](#method-i-assert_not_equal) -:call-seq: - assert_not_equal( expected, actual, failure_message = nil ) - -Tests if `expected` is not equal to `actual`. - -An optional failure message may be provided as the final argument. - -## assert_not_nil(exp, msgnil) [](#method-i-assert_not_nil) -:call-seq: - assert_not_nil( expression, failure_message = nil ) - -Tests if `expression` is not nil. - -An optional failure message may be provided as the final argument. - -## assert_not_same(expected, actual, message"") [](#method-i-assert_not_same) -:call-seq: - assert_not_same( expected, actual, failure_message = nil ) - -Tests if `expected` is not the same object as `actual`. This test uses -Object#equal? to test equality. - -An optional failure message may be provided as the final argument. - - assert_not_same("x", "x") #Succeeds - -## assert_not_send(send_ary, mnil) [](#method-i-assert_not_send) -:call-seq: - assert_not_send( +send_array+, failure_message = nil ) - -Passes if the method send doesn't return a true value. - -`send_array` is composed of: -* A receiver -* A method -* Arguments to the method - -Example: - assert_not_send([[1, 2], :member?, 1]) # -> fail - assert_not_send([[1, 2], :member?, 4]) # -> pass - -## assert_nothing_thrown(msgnil) [](#method-i-assert_nothing_thrown) -:call-seq: - assert_nothing_thrown( failure_message = nil, &block ) - -Fails if the given block uses a call to Kernel#throw, and returns the result -of the block otherwise. - -An optional failure message may be provided as the final argument. - - assert_nothing_thrown "Something was thrown!" do - throw :problem? - end - -## assert_operator(o1, op, o2(predicate = true; nil), msgnil) [](#method-i-assert_operator) -For testing with binary operators. - - assert_operator 5, :<=, 4 - -## assert_output(stdoutnil, stderrnil) [](#method-i-assert_output) -Fails if stdout or stderr do not output the expected results. Pass in nil if -you don't care about that streams output. Pass in "" if you require it to be -silent. Pass in a regexp if you want to pattern match. - -NOTE: this uses #capture_io, not #capture_subprocess_io. - -See also: #assert_silent - -## assert_path_exists(path, msgnil) [](#method-i-assert_path_exists) - -## assert_predicate(o1, op, msgnil) [](#method-i-assert_predicate) -For testing with predicates. - - assert_predicate str, :empty? - -This is really meant for specs and is front-ended by assert_operator: - - str.must_be :empty? - -## assert_raises(*exp, &b) [](#method-i-assert_raises) - -**@raise** [NoMethodError] - -## assert_respond_to(obj, meth, msgnil) [](#method-i-assert_respond_to) -Fails unless `obj` responds to `meth`. - -## assert_same(exp, act, msgnil) [](#method-i-assert_same) -Fails unless `exp` and `act` are #equal? - -## assert_send(send_ary, mnil) [](#method-i-assert_send) -:call-seq: - assert_send( +send_array+, failure_message = nil ) - -Passes if the method send returns a true value. - -`send_array` is composed of: -* A receiver -* A method -* Arguments to the method - -Example: - assert_send(["Hello world", :include?, "Hello"]) # -> pass - assert_send(["Hello world", :include?, "Goodbye"]) # -> fail - -## assert_silent() [](#method-i-assert_silent) -Fails if the block outputs anything to stderr or stdout. - -See also: #assert_output - -## assert_syntax_error(code, error, *args, **opt) [](#method-i-assert_syntax_error) - -## assert_throws(sym, msgnil) [](#method-i-assert_throws) -Fails unless the block throws `sym` - -## assert_true(obj, msgnil) [](#method-i-assert_true) -Fails unless `obj` is true - -## build_message(head, templatenil, *arguments) [](#method-i-build_message) -:nodoc: - -## capture_io() [](#method-i-capture_io) - -**@raise** [NoMethodError] - -## capture_output() [](#method-i-capture_output) -Captures $stdout and $stderr into strings: - - out, err = capture_output do - puts "Some info" - warn "You did a bad thing" - end - - assert_match %r%info%, out - assert_match %r%bad%, err - -## diff(exp, act) [](#method-i-diff) -Returns a diff between `exp` and `act`. If there is no known diff command or -if it doesn't make sense to diff the output (single line, short output), then -it simply returns a basic comparison between the two. - -## flunk(msgnil) [](#method-i-flunk) -Fails with `msg` - -## message(msgnil, endingnil, &default) [](#method-i-message) -Returns a proc that will output `msg` along with the default message. - -## mu_pp_for_diff(obj) [](#method-i-mu_pp_for_diff) -This returns a diff-able human-readable version of `obj`. This differs from -the regular mu_pp because it expands escaped newlines and makes hex-values -generic (like object_ids). This uses mu_pp to do the first pass and then -cleans it up. - -## pass(msgnil) [](#method-i-pass) -used for counting assertions - -## pend(msgnil, btcaller, &_) [](#method-i-pend) -Skips the current test. Gets listed at the end of the run but doesn't cause a -failure exit code. - -**@raise** [Test::Unit::PendedError] - -## refute(test, msgnil) [](#method-i-refute) -Fails if `test` is a true value - -## refute_empty(obj, msgnil) [](#method-i-refute_empty) -Fails if `obj` is empty. - -## refute_equal(exp, act, msgnil) [](#method-i-refute_equal) -Fails if `exp == act`. - -For floats use refute_in_delta. - -## refute_in_delta(exp, act, delta0.001, msgnil) [](#method-i-refute_in_delta) -For comparing Floats. Fails if `exp` is within `delta` of `act`. - - refute_in_delta Math::PI, (22.0 / 7.0) - -## refute_in_epsilon(a, b, epsilon0.001, msgnil) [](#method-i-refute_in_epsilon) -For comparing Floats. Fails if `exp` and `act` have a relative error less -than `epsilon`. - -## refute_includes(collection, obj, msgnil) [](#method-i-refute_includes) -Fails if `collection` includes `obj`. - -## refute_instance_of(cls, obj, msgnil) [](#method-i-refute_instance_of) -Fails if `obj` is an instance of `cls`. - -## refute_kind_of(cls, obj, msgnil) [](#method-i-refute_kind_of) -Fails if `obj` is a kind of `cls`. - -## refute_match(matcher, obj, msgnil) [](#method-i-refute_match) -Fails if `matcher` `=~` `obj`. - -## refute_nil(obj, msgnil) [](#method-i-refute_nil) -Fails if `obj` is nil. - -## refute_operator(o1, op, o2(predicate = true; nil), msgnil) [](#method-i-refute_operator) -Fails if `o1` is not `op` `o2`. Eg: - - refute_operator 1, :>, 2 #=> pass - refute_operator 1, :<, 2 #=> fail - -## refute_path_exists(path, msgnil) [](#method-i-refute_path_exists) - -## refute_predicate(o1, op, msgnil) [](#method-i-refute_predicate) -For testing with predicates. - - refute_predicate str, :empty? - -This is really meant for specs and is front-ended by refute_operator: - - str.wont_be :empty? - -## refute_respond_to(obj, meth, msgnil) [](#method-i-refute_respond_to) -Fails if `obj` responds to the message `meth`. - -## refute_same(exp, act, msgnil) [](#method-i-refute_same) -Fails if `exp` is the same (by object identity) as `act`. - -## skip(msgnil, btcaller) [](#method-i-skip) - -**@raise** [NoMethodError] - -## skipped?() [](#method-i-skipped?) -Was this testcase skipped? Meant for #teardown. - -**@return** [Boolean] - -## synchronize() [](#method-i-synchronize) -Takes a block and wraps it with the runner's shared mutex. - diff --git a/example/ruby/TestIterator/ITER_TEST3.md b/example/ruby/TestIterator/ITER_TEST3.md deleted file mode 100644 index 9a2b587..0000000 --- a/example/ruby/TestIterator/ITER_TEST3.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIterator::ITER_TEST3 -**Inherits:** Object - - - - - -#Instance Methods -## foo(x) [](#method-i-foo) - diff --git a/example/ruby/TestIterator/ITER_TEST4.md b/example/ruby/TestIterator/ITER_TEST4.md deleted file mode 100644 index 1f6eafc..0000000 --- a/example/ruby/TestIterator/ITER_TEST4.md +++ /dev/null @@ -1,326 +0,0 @@ -# Class: TestIterator::ITER_TEST4 -**Inherits:** TestIterator::ITER_TEST3 - -**Includes:** Test::Unit::Assertions - - - - - -#Instance Methods -## _assertions() [](#method-i-_assertions) -:nodoc: - -## _assertions=(n) [](#method-i-_assertions=) -:nodoc: - -## assert(test, msgnil) [](#method-i-assert) -Fails unless `test` is a true value. - -## assert_bignum(v, msgnil) [](#method-i-assert_bignum) - -## assert_block(*msgs) [](#method-i-assert_block) -:call-seq: - assert_block( failure_message = nil ) - -Tests the result of the given block. If the block does not return true, the -assertion will fail. The optional `failure_message` argument is the same as in -Assertions#assert. - - assert_block do - [1, 2, 3].any? { |num| num < 1 } - end - -## assert_cpu_usage_low(msgnil, pct:0.05, wait:1.0, stop:nil) [](#method-i-assert_cpu_usage_low) - -## assert_empty(obj, msgnil) [](#method-i-assert_empty) -Fails unless `obj` is empty. - -## assert_equal(exp, act, msgnil) [](#method-i-assert_equal) -:call-seq: - assert_equal( expected, actual, failure_message = nil ) - -Tests if `expected` is equal to `actual`. - -An optional failure message may be provided as the final argument. - -## assert_false(obj, msgnil) [](#method-i-assert_false) -Fails unless `obj` is false - -## assert_fixnum(v, msgnil) [](#method-i-assert_fixnum) - -## assert_in_delta(exp, act, delta0.001, msgnil) [](#method-i-assert_in_delta) -For comparing Floats. Fails unless `exp` and `act` are within `delta` of each -other. - - assert_in_delta Math::PI, (22.0 / 7.0), 0.01 - -## assert_in_epsilon(a, b, epsilon0.001, msgnil) [](#method-i-assert_in_epsilon) -For comparing Floats. Fails unless `exp` and `act` have a relative error less -than `epsilon`. - -## assert_includes(collection, obj, msgnil) [](#method-i-assert_includes) -Fails unless `collection` includes `obj`. - -## assert_instance_of(cls, obj, msgnil) [](#method-i-assert_instance_of) -Fails unless `obj` is an instance of `cls`. - -## assert_is_minus_zero(f) [](#method-i-assert_is_minus_zero) - -## assert_kind_of(cls, obj, msgnil) [](#method-i-assert_kind_of) -Fails unless `obj` is a kind of `cls`. - -## assert_match(matcher, obj, msgnil) [](#method-i-assert_match) -Fails unless `matcher` `=~` `obj`. - -## assert_nil(obj, msgnil) [](#method-i-assert_nil) -Fails unless `obj` is nil - -## assert_no_match(regexp, string, msgnil) [](#method-i-assert_no_match) -:call-seq: - assert_no_match( regexp, string, failure_message = nil ) - -Tests if the given Regexp does not match a given String. - -An optional failure message may be provided as the final argument. - -## assert_no_warning(pat, msgnil) [](#method-i-assert_no_warning) - -## assert_not_all?(obj, mnil, &blk) [](#method-i-assert_not_all?) - -**@return** [Boolean] - -## assert_not_equal(exp, act, msgnil) [](#method-i-assert_not_equal) -:call-seq: - assert_not_equal( expected, actual, failure_message = nil ) - -Tests if `expected` is not equal to `actual`. - -An optional failure message may be provided as the final argument. - -## assert_not_nil(exp, msgnil) [](#method-i-assert_not_nil) -:call-seq: - assert_not_nil( expression, failure_message = nil ) - -Tests if `expression` is not nil. - -An optional failure message may be provided as the final argument. - -## assert_not_same(expected, actual, message"") [](#method-i-assert_not_same) -:call-seq: - assert_not_same( expected, actual, failure_message = nil ) - -Tests if `expected` is not the same object as `actual`. This test uses -Object#equal? to test equality. - -An optional failure message may be provided as the final argument. - - assert_not_same("x", "x") #Succeeds - -## assert_not_send(send_ary, mnil) [](#method-i-assert_not_send) -:call-seq: - assert_not_send( +send_array+, failure_message = nil ) - -Passes if the method send doesn't return a true value. - -`send_array` is composed of: -* A receiver -* A method -* Arguments to the method - -Example: - assert_not_send([[1, 2], :member?, 1]) # -> fail - assert_not_send([[1, 2], :member?, 4]) # -> pass - -## assert_nothing_thrown(msgnil) [](#method-i-assert_nothing_thrown) -:call-seq: - assert_nothing_thrown( failure_message = nil, &block ) - -Fails if the given block uses a call to Kernel#throw, and returns the result -of the block otherwise. - -An optional failure message may be provided as the final argument. - - assert_nothing_thrown "Something was thrown!" do - throw :problem? - end - -## assert_operator(o1, op, o2(predicate = true; nil), msgnil) [](#method-i-assert_operator) -For testing with binary operators. - - assert_operator 5, :<=, 4 - -## assert_output(stdoutnil, stderrnil) [](#method-i-assert_output) -Fails if stdout or stderr do not output the expected results. Pass in nil if -you don't care about that streams output. Pass in "" if you require it to be -silent. Pass in a regexp if you want to pattern match. - -NOTE: this uses #capture_io, not #capture_subprocess_io. - -See also: #assert_silent - -## assert_path_exists(path, msgnil) [](#method-i-assert_path_exists) - -## assert_predicate(o1, op, msgnil) [](#method-i-assert_predicate) -For testing with predicates. - - assert_predicate str, :empty? - -This is really meant for specs and is front-ended by assert_operator: - - str.must_be :empty? - -## assert_raises(*exp, &b) [](#method-i-assert_raises) - -**@raise** [NoMethodError] - -## assert_respond_to(obj, meth, msgnil) [](#method-i-assert_respond_to) -Fails unless `obj` responds to `meth`. - -## assert_same(exp, act, msgnil) [](#method-i-assert_same) -Fails unless `exp` and `act` are #equal? - -## assert_send(send_ary, mnil) [](#method-i-assert_send) -:call-seq: - assert_send( +send_array+, failure_message = nil ) - -Passes if the method send returns a true value. - -`send_array` is composed of: -* A receiver -* A method -* Arguments to the method - -Example: - assert_send(["Hello world", :include?, "Hello"]) # -> pass - assert_send(["Hello world", :include?, "Goodbye"]) # -> fail - -## assert_silent() [](#method-i-assert_silent) -Fails if the block outputs anything to stderr or stdout. - -See also: #assert_output - -## assert_syntax_error(code, error, *args, **opt) [](#method-i-assert_syntax_error) - -## assert_throws(sym, msgnil) [](#method-i-assert_throws) -Fails unless the block throws `sym` - -## assert_true(obj, msgnil) [](#method-i-assert_true) -Fails unless `obj` is true - -## build_message(head, templatenil, *arguments) [](#method-i-build_message) -:nodoc: - -## capture_io() [](#method-i-capture_io) - -**@raise** [NoMethodError] - -## capture_output() [](#method-i-capture_output) -Captures $stdout and $stderr into strings: - - out, err = capture_output do - puts "Some info" - warn "You did a bad thing" - end - - assert_match %r%info%, out - assert_match %r%bad%, err - -## diff(exp, act) [](#method-i-diff) -Returns a diff between `exp` and `act`. If there is no known diff command or -if it doesn't make sense to diff the output (single line, short output), then -it simply returns a basic comparison between the two. - -## flunk(msgnil) [](#method-i-flunk) -Fails with `msg` - -## foo(x) [](#method-i-foo) - -## message(msgnil, endingnil, &default) [](#method-i-message) -Returns a proc that will output `msg` along with the default message. - -## mu_pp_for_diff(obj) [](#method-i-mu_pp_for_diff) -This returns a diff-able human-readable version of `obj`. This differs from -the regular mu_pp because it expands escaped newlines and makes hex-values -generic (like object_ids). This uses mu_pp to do the first pass and then -cleans it up. - -## pass(msgnil) [](#method-i-pass) -used for counting assertions - -## pend(msgnil, btcaller, &_) [](#method-i-pend) -Skips the current test. Gets listed at the end of the run but doesn't cause a -failure exit code. - -**@raise** [Test::Unit::PendedError] - -## refute(test, msgnil) [](#method-i-refute) -Fails if `test` is a true value - -## refute_empty(obj, msgnil) [](#method-i-refute_empty) -Fails if `obj` is empty. - -## refute_equal(exp, act, msgnil) [](#method-i-refute_equal) -Fails if `exp == act`. - -For floats use refute_in_delta. - -## refute_in_delta(exp, act, delta0.001, msgnil) [](#method-i-refute_in_delta) -For comparing Floats. Fails if `exp` is within `delta` of `act`. - - refute_in_delta Math::PI, (22.0 / 7.0) - -## refute_in_epsilon(a, b, epsilon0.001, msgnil) [](#method-i-refute_in_epsilon) -For comparing Floats. Fails if `exp` and `act` have a relative error less -than `epsilon`. - -## refute_includes(collection, obj, msgnil) [](#method-i-refute_includes) -Fails if `collection` includes `obj`. - -## refute_instance_of(cls, obj, msgnil) [](#method-i-refute_instance_of) -Fails if `obj` is an instance of `cls`. - -## refute_kind_of(cls, obj, msgnil) [](#method-i-refute_kind_of) -Fails if `obj` is a kind of `cls`. - -## refute_match(matcher, obj, msgnil) [](#method-i-refute_match) -Fails if `matcher` `=~` `obj`. - -## refute_nil(obj, msgnil) [](#method-i-refute_nil) -Fails if `obj` is nil. - -## refute_operator(o1, op, o2(predicate = true; nil), msgnil) [](#method-i-refute_operator) -Fails if `o1` is not `op` `o2`. Eg: - - refute_operator 1, :>, 2 #=> pass - refute_operator 1, :<, 2 #=> fail - -## refute_path_exists(path, msgnil) [](#method-i-refute_path_exists) - -## refute_predicate(o1, op, msgnil) [](#method-i-refute_predicate) -For testing with predicates. - - refute_predicate str, :empty? - -This is really meant for specs and is front-ended by refute_operator: - - str.wont_be :empty? - -## refute_respond_to(obj, meth, msgnil) [](#method-i-refute_respond_to) -Fails if `obj` responds to the message `meth`. - -## refute_same(exp, act, msgnil) [](#method-i-refute_same) -Fails if `exp` is the same (by object identity) as `act`. - -## skip(msgnil, btcaller) [](#method-i-skip) - -**@raise** [NoMethodError] - -## skipped?() [](#method-i-skipped?) -Was this testcase skipped? Meant for #teardown. - -**@return** [Boolean] - -## synchronize() [](#method-i-synchronize) -Takes a block and wraps it with the runner's shared mutex. - diff --git a/example/ruby/TestIterator/IterString.md b/example/ruby/TestIterator/IterString.md deleted file mode 100644 index 7ac4b7f..0000000 --- a/example/ruby/TestIterator/IterString.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestIterator::IterString -**Inherits:** String - - - - - -#Instance Methods -## ===(other) [](#method-i-===) - diff --git a/example/ruby/TestIterator/IterTest.md b/example/ruby/TestIterator/IterTest.md deleted file mode 100644 index 968351e..0000000 --- a/example/ruby/TestIterator/IterTest.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestIterator::IterTest -**Inherits:** Object - - - - - -#Instance Methods -## each0(&block) [](#method-i-each0) - -## each1(&block) [](#method-i-each1) - -## each2(&block) [](#method-i-each2) - -## each3(&block) [](#method-i-each3) - -## each4(&block) [](#method-i-each4) - -## each5() [](#method-i-each5) - -## each6() [](#method-i-each6) - -## each7() [](#method-i-each7) - -## each8() [](#method-i-each8) - -## f(a) [](#method-i-f) - -## initialize(e) [](#method-i-initialize) - -**@return** [IterTest] a new instance of IterTest - diff --git a/example/ruby/TestKOI8.md b/example/ruby/TestKOI8.md deleted file mode 100644 index 1266d09..0000000 --- a/example/ruby/TestKOI8.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestKOI8 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_koi8_r() [](#method-i-test_koi8_r) - -## test_koi8_u() [](#method-i-test_koi8_u) - diff --git a/example/ruby/TestKeyError.md b/example/ruby/TestKeyError.md deleted file mode 100644 index 41cd93e..0000000 --- a/example/ruby/TestKeyError.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestKeyError -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_all() [](#method-i-test_all) - -## test_default() [](#method-i-test_default) - -## test_key() [](#method-i-test_key) - -## test_message() [](#method-i-test_message) - -## test_receiver() [](#method-i-test_receiver) - -## test_receiver_and_key() [](#method-i-test_receiver_and_key) - diff --git a/example/ruby/TestKeywordArguments.md b/example/ruby/TestKeywordArguments.md deleted file mode 100644 index c0afff8..0000000 --- a/example/ruby/TestKeywordArguments.md +++ /dev/null @@ -1,278 +0,0 @@ -# Class: TestKeywordArguments -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## a(b: 1) [](#method-c-a) -## a0() [](#method-c-a0) -## kws(**a ) [](#method-c-kws) -## method_missing(_ , **kw ) [](#method-c-method_missing) -## o(x 1) [](#method-c-o) -## s(*a ) [](#method-c-s) -## skws(*a , **kw ) [](#method-c-skws) -## yo(kw ) [](#method-c-yo) -## yoa(*kw ) [](#method-c-yoa) - -#Instance Methods -## assert_equal_not_same(kw, res) [](#method-i-assert_equal_not_same) - -## f1(str:"foo", num:424242) [](#method-i-f1) - -## f10(a:1) [](#method-i-f10) - -## f11() [](#method-i-f11) - -## f13(a) [](#method-i-f13) - -## f2(x, str:"foo", num:424242) [](#method-i-f2) - -## f3(str:"foo", num:424242, **h) [](#method-i-f3) - -## f6(str:"foo", num:424242, **h, &blk) [](#method-i-f6) - -## f7(*r, str:"foo", num:424242, **h) [](#method-i-f7) - -## f9(r, o42, *args, p, k::key, **kw, &b) [](#method-i-f9) - -## m(a) [](#method-i-m) - -**@yield** [a] - -## m1(*args, **options) [](#method-i-m1) - -**@yield** [args, options] - -## many_kwargs(a0:'', a1:'', a2:'', a3:'', a4:'', a5:'', a6:'', a7:'', b0:'', b1:'', b2:'', b3:'', b4:'', b5:'', b6:'', b7:'', c0:'', c1:'', c2:'', c3:'', c4:'', c5:'', c6:'', c7:'', d0:'', d1:'', d2:'', d3:'', d4:'', d5:'', d6:'', d7:'', e0:'') [](#method-i-many_kwargs) - -## method_for_test_to_hash_call_during_setup_complex_parameters(k1:, k2:, **rest_kw) [](#method-i-method_for_test_to_hash_call_during_setup_complex_parameters) - -## opt_plus_keyword(x1, **h) [](#method-i-opt_plus_keyword) - -## p1() [](#method-i-p1) - -## p2() [](#method-i-p2) - -## p3() [](#method-i-p3) - -## p4() [](#method-i-p4) - -## p5() [](#method-i-p5) - -## p6() [](#method-i-p6) - -## req_plus_keyword(x, **h) [](#method-i-req_plus_keyword) - -## rest_keyrest(*args, **opt) [](#method-i-rest_keyrest) - -## splat_plus_keyword(*a, **h) [](#method-i-splat_plus_keyword) - -## test_Class_new_kwsplat_call() [](#method-i-test_Class_new_kwsplat_call) - -## test_Class_new_method_kwsplat_call() [](#method-i-test_Class_new_method_kwsplat_call) - -## test_Enumerator_Generator_each_kwsplat() [](#method-i-test_Enumerator_Generator_each_kwsplat) - -## test_Enumerator_Yielder_yield_kwsplat() [](#method-i-test_Enumerator_Yielder_yield_kwsplat) - -## test_Fiber_resume_kwsplat() [](#method-i-test_Fiber_resume_kwsplat) - -## test_Method_call_kwsplat_call() [](#method-i-test_Method_call_kwsplat_call) - -## test_Thread_new_kwsplat() [](#method-i-test_Thread_new_kwsplat) - -## test_UnboundMethod_bindcall_kwsplat_call() [](#method-i-test_UnboundMethod_bindcall_kwsplat_call) - -## test_anon_splat_ruby2_keywords() [](#method-i-test_anon_splat_ruby2_keywords) - -## test_anon_splat_ruby2_keywords_bug_20388() [](#method-i-test_anon_splat_ruby2_keywords_bug_20388) - -## test_arity_error_message() [](#method-i-test_arity_error_message) - -## test_attr_reader_kwsplat() [](#method-i-test_attr_reader_kwsplat) - -## test_attr_reader_method_kwsplat() [](#method-i-test_attr_reader_method_kwsplat) - -## test_attr_set_method_cache() [](#method-i-test_attr_set_method_cache) - -## test_attr_writer_kwsplat() [](#method-i-test_attr_writer_kwsplat) - -## test_attr_writer_method_kwsplat() [](#method-i-test_attr_writer_method_kwsplat) - -## test_bare_kwrest() [](#method-i-test_bare_kwrest) - -## test_block() [](#method-i-test_block) - -## test_block_required_keyword() [](#method-i-test_block_required_keyword) - -## test_define_method_kwsplat() [](#method-i-test_define_method_kwsplat) - -## test_define_method_method_kwsplat() [](#method-i-test_define_method_method_kwsplat) - -## test_dig_kwsplat() [](#method-i-test_dig_kwsplat) - -## test_dig_method_missing_kwsplat() [](#method-i-test_dig_method_missing_kwsplat) - -## test_do_not_use_newarraykwsplat() [](#method-i-test_do_not_use_newarraykwsplat) - -## test_dynamic_symbol_keyword() [](#method-i-test_dynamic_symbol_keyword) - -## test_enumerator_size_kwsplat() [](#method-i-test_enumerator_size_kwsplat) - -## test_explicit_super_kwsplat() [](#method-i-test_explicit_super_kwsplat) - -## test_f1() [](#method-i-test_f1) - -## test_f10() [](#method-i-test_f10) - -## test_f11() [](#method-i-test_f11) - -## test_f12() [](#method-i-test_f12) - -## test_f13() [](#method-i-test_f13) - -## test_f2() [](#method-i-test_f2) - -## test_f3() [](#method-i-test_f3) - -## test_f4() [](#method-i-test_f4) - -## test_f5() [](#method-i-test_f5) - -## test_f6() [](#method-i-test_f6) -ruby-core:40518 -: - -## test_f7() [](#method-i-test_f7) -ruby-core:41772 -: - -## test_f8() [](#method-i-test_f8) - -## test_f9() [](#method-i-test_f9) - -## test_gced_object_in_stack() [](#method-i-test_gced_object_in_stack) - -## test_implicit_super_kwsplat() [](#method-i-test_implicit_super_kwsplat) - -## test_instance_exec_define_method_kwsplat() [](#method-i-test_instance_exec_define_method_kwsplat) - -## test_instance_exec_kwsplat() [](#method-i-test_instance_exec_kwsplat) - -## test_instance_exec_method_kwsplat() [](#method-i-test_instance_exec_method_kwsplat) - -## test_instance_exec_sym_proc_kwsplat() [](#method-i-test_instance_exec_sym_proc_kwsplat) - -## test_keyword_no_split() [](#method-i-test_keyword_no_split) - -## test_keyword_splat_new() [](#method-i-test_keyword_splat_new) - -## test_keyword_splat_nil() [](#method-i-test_keyword_splat_nil) - -## test_keyword_splat_to_non_keyword_method() [](#method-i-test_keyword_splat_to_non_keyword_method) - -## test_keyword_with_anonymous_keyword_splat() [](#method-i-test_keyword_with_anonymous_keyword_splat) - -## test_kwrest_overwritten() [](#method-i-test_kwrest_overwritten) - -## test_lambda() [](#method-i-test_lambda) - -## test_lambda_kwsplat_call() [](#method-i-test_lambda_kwsplat_call) - -## test_lambda_method_kwsplat_call() [](#method-i-test_lambda_method_kwsplat_call) - -## test_large_kwsplat_to_method_taking_kw_and_kwsplat() [](#method-i-test_large_kwsplat_to_method_taking_kw_and_kwsplat) - -## test_many_kwargs() [](#method-i-test_many_kwargs) - -## test_method_missing_kwsplat() [](#method-i-test_method_missing_kwsplat) - -## test_method_parameters() [](#method-i-test_method_parameters) - -## test_no_implicit_hash_conversion() [](#method-i-test_no_implicit_hash_conversion) - -## test_non_keyword_hash_subclass() [](#method-i-test_non_keyword_hash_subclass) - -## test_nonsymbol_key() [](#method-i-test_nonsymbol_key) - -## test_p1() [](#method-i-test_p1) - -## test_p2() [](#method-i-test_p2) - -## test_p3() [](#method-i-test_p3) - -## test_p4() [](#method-i-test_p4) - -## test_p5() [](#method-i-test_p5) - -## test_p6() [](#method-i-test_p6) - -## test_precedence_of_keyword_arguments() [](#method-i-test_precedence_of_keyword_arguments) - -## test_precedence_of_keyword_arguments_with_post_argument() [](#method-i-test_precedence_of_keyword_arguments_with_post_argument) - -## test_proc_parameters() [](#method-i-test_proc_parameters) - -## test_proc_ruby2_keywords() [](#method-i-test_proc_ruby2_keywords) - -## test_public_send_kwsplat() [](#method-i-test_public_send_kwsplat) - -## test_rb_call_super_kw_method_missing_kwsplat() [](#method-i-test_rb_call_super_kw_method_missing_kwsplat) - -## test_rb_yield_block_kwsplat() [](#method-i-test_rb_yield_block_kwsplat) - -## test_regular_kwsplat() [](#method-i-test_regular_kwsplat) - -## test_required_keyword() [](#method-i-test_required_keyword) - -## test_required_keyword_with_newline() [](#method-i-test_required_keyword_with_newline) - -## test_required_keyword_with_reserved() [](#method-i-test_required_keyword_with_reserved) - -## test_rest_keyrest() [](#method-i-test_rest_keyrest) - -## test_ruby2_keywords() [](#method-i-test_ruby2_keywords) - -## test_ruby2_keywords_bug_20679() [](#method-i-test_ruby2_keywords_bug_20679) - -## test_send_kwsplat() [](#method-i-test_send_kwsplat) - -## test_send_method_kwsplat() [](#method-i-test_send_method_kwsplat) - -## test_splat_empty_hash_with_block_passing() [](#method-i-test_splat_empty_hash_with_block_passing) - -## test_splat_hash() [](#method-i-test_splat_hash) - -## test_splat_hash_conversion() [](#method-i-test_splat_hash_conversion) - -## test_splat_keyword_nondestructive() [](#method-i-test_splat_keyword_nondestructive) - -## test_super_method_missing_kwsplat() [](#method-i-test_super_method_missing_kwsplat) - -## test_super_with_anon_restkeywords() [](#method-i-test_super_with_anon_restkeywords) - -## test_super_with_keyword() [](#method-i-test_super_with_keyword) - -## test_super_with_keyword_kwrest() [](#method-i-test_super_with_keyword_kwrest) - -## test_sym_proc_kwsplat() [](#method-i-test_sym_proc_kwsplat) - -## test_sym_proc_method_kwsplat() [](#method-i-test_sym_proc_method_kwsplat) - -## test_to_hash_call_during_setup_complex_parameters() [](#method-i-test_to_hash_call_during_setup_complex_parameters) - -## test_top_ruby2_keywords() [](#method-i-test_top_ruby2_keywords) - -## test_unknown_keyword() [](#method-i-test_unknown_keyword) - -## test_unknown_keyword_with_block() [](#method-i-test_unknown_keyword_with_block) - -## test_unset_hash_flag() [](#method-i-test_unset_hash_flag) - -## test_without_paren() [](#method-i-test_without_paren) - -## test_zsuper_only_anonymous_kwrest() [](#method-i-test_zsuper_only_anonymous_kwrest) - -## test_zsuper_only_named_kwrest() [](#method-i-test_zsuper_only_named_kwrest) - diff --git a/example/ruby/TestKeywordArguments/AttrSetTest.md b/example/ruby/TestKeywordArguments/AttrSetTest.md deleted file mode 100644 index 7420345..0000000 --- a/example/ruby/TestKeywordArguments/AttrSetTest.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: TestKeywordArguments::AttrSetTest -**Inherits:** Object - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - diff --git a/example/ruby/TestKeywordArgumentsSymProcRefinements.md b/example/ruby/TestKeywordArgumentsSymProcRefinements.md deleted file mode 100644 index d9612b3..0000000 --- a/example/ruby/TestKeywordArgumentsSymProcRefinements.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestKeywordArgumentsSymProcRefinements -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## m_bug20570(*a) [](#method-i-m_bug20570) - -## test_protected_kwarg() [](#method-i-test_protected_kwarg) - -## test_splat_arg_with_prohibited_keyword() [](#method-i-test_splat_arg_with_prohibited_keyword) - -## test_splat_fixnum() [](#method-i-test_splat_fixnum) - -## test_sym_proc_refine_kwsplat() [](#method-i-test_sym_proc_refine_kwsplat) - -## test_sym_proc_refine_method_missing_kwsplat() [](#method-i-test_sym_proc_refine_method_missing_kwsplat) - -## test_sym_proc_refine_super_method_missing_kwsplat() [](#method-i-test_sym_proc_refine_super_method_missing_kwsplat) - -## test_value_omission() [](#method-i-test_value_omission) - diff --git a/example/ruby/TestKeywordArgumentsSymProcRefinements/C.md b/example/ruby/TestKeywordArgumentsSymProcRefinements/C.md deleted file mode 100644 index fa1e5ad..0000000 --- a/example/ruby/TestKeywordArgumentsSymProcRefinements/C.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestKeywordArgumentsSymProcRefinements::C -**Inherits:** Object - - - - - -#Instance Methods -## call(*args, **kw) [](#method-i-call) - -**@yield** [_self, args, kw] - -**@yieldparam** [TestKeywordArgumentsSymProcRefinements::C] the object that the method was called on - diff --git a/example/ruby/TestLLDBInit.md b/example/ruby/TestLLDBInit.md deleted file mode 100644 index 14d802f..0000000 --- a/example/ruby/TestLLDBInit.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestLLDBInit -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_rp(expr, pattern, messagenil) [](#method-i-assert_rp) - -## test_rp_object() [](#method-i-test_rp_object) - -## test_rp_regex() [](#method-i-test_rp_regex) - -## test_rp_string() [](#method-i-test_rp_string) - -## test_rp_symbol() [](#method-i-test_rp_symbol) - diff --git a/example/ruby/TestLambdaParameters.md b/example/ruby/TestLambdaParameters.md deleted file mode 100644 index 202ad2b..0000000 --- a/example/ruby/TestLambdaParameters.md +++ /dev/null @@ -1,77 +0,0 @@ -# Class: TestLambdaParameters -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## a() [](#method-c-a) -## b() [](#method-c-b) - -#Instance Methods -## break_in_callee(val) [](#method-i-break_in_callee) - -## break_in_current(val) [](#method-i-break_in_current) - -## foo() [](#method-i-foo) - -## return_in_callee(val) [](#method-i-return_in_callee) - -## return_in_current(val) [](#method-i-return_in_current) - -## test_arity_error() [](#method-i-test_arity_error) - -## test_brace_lambda_source_location() [](#method-i-test_brace_lambda_source_location) - -## test_break() [](#method-i-test_break) - -## test_call_block_from_lambda() [](#method-i-test_call_block_from_lambda) - -## test_call_opt_args() [](#method-i-test_call_opt_args) - -## test_call_rest_and_opt() [](#method-i-test_call_rest_and_opt) - -## test_call_rest_args() [](#method-i-test_call_rest_args) - -## test_call_simple() [](#method-i-test_call_simple) - -## test_call_with_block() [](#method-i-test_call_with_block) - -## test_do_lambda_source_location() [](#method-i-test_do_lambda_source_location) - -## test_exact_parameter() [](#method-i-test_exact_parameter) - -## test_in_basic_object() [](#method-i-test_in_basic_object) - -## test_instance_eval_return() [](#method-i-test_instance_eval_return) - -## test_instance_exec() [](#method-i-test_instance_exec) - -## test_instance_exec_return() [](#method-i-test_instance_exec_return) - -## test_lambda_as_iterator() [](#method-i-test_lambda_as_iterator) - -## test_location_on_error() [](#method-i-test_location_on_error) - -## test_not_orphan_break() [](#method-i-test_not_orphan_break) - -## test_not_orphan_next() [](#method-i-test_not_orphan_next) - -## test_not_orphan_return() [](#method-i-test_not_orphan_return) - -## test_proc_inside_lambda2_inside_method_return_outside_lambda1_inside_method() [](#method-i-test_proc_inside_lambda2_inside_method_return_outside_lambda1_inside_method) - -## test_proc_inside_lambda_inside_method_return_inside_lambda_inside_method() [](#method-i-test_proc_inside_lambda_inside_method_return_inside_lambda_inside_method) - -## test_proc_inside_lambda_inside_method_return_inside_lambda_outside_method() [](#method-i-test_proc_inside_lambda_inside_method_return_inside_lambda_outside_method) - -## test_proc_inside_lambda_inside_method_return_outside_lambda_inside_method() [](#method-i-test_proc_inside_lambda_inside_method_return_outside_lambda_inside_method) - -## test_proc_inside_lambda_inside_method_return_outside_lambda_outside_method() [](#method-i-test_proc_inside_lambda_inside_method_return_outside_lambda_outside_method) - -## test_proc_inside_lambda_toplevel() [](#method-i-test_proc_inside_lambda_toplevel) - -## test_return() [](#method-i-test_return) - -## yield_block() [](#method-i-yield_block) - diff --git a/example/ruby/TestLastThread.md b/example/ruby/TestLastThread.md deleted file mode 100644 index ed0c9c9..0000000 --- a/example/ruby/TestLastThread.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestLastThread -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_last_thread() [](#method-i-test_last_thread) -Bug #11237 -: - diff --git a/example/ruby/TestLaunchable.md b/example/ruby/TestLaunchable.md deleted file mode 100644 index 09fa288..0000000 --- a/example/ruby/TestLaunchable.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestLaunchable -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_json_stream_writer() [](#method-i-test_json_stream_writer) - diff --git a/example/ruby/TestLazyEnumerator.md b/example/ruby/TestLazyEnumerator.md deleted file mode 100644 index 799dc53..0000000 --- a/example/ruby/TestLazyEnumerator.md +++ /dev/null @@ -1,138 +0,0 @@ -# Class: TestLazyEnumerator -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## each() [](#method-c-each) - -#Instance Methods -## test_cycle() [](#method-i-test_cycle) - -## test_cycle_chain() [](#method-i-test_cycle_chain) - -## test_cycle_with_block() [](#method-i-test_cycle_with_block) - -## test_drop() [](#method-i-test_drop) - -## test_drop_and_take() [](#method-i-test_drop_and_take) - -## test_drop_nested() [](#method-i-test_drop_nested) - -## test_drop_while() [](#method-i-test_drop_while) - -## test_drop_while_nested() [](#method-i-test_drop_while_nested) - -## test_each_args() [](#method-i-test_each_args) - -## test_each_cons_limit() [](#method-i-test_each_cons_limit) - -## test_each_line() [](#method-i-test_each_line) - -## test_each_slice_limit() [](#method-i-test_each_slice_limit) - -## test_filter_map() [](#method-i-test_filter_map) - -## test_flat_map() [](#method-i-test_flat_map) - -## test_flat_map_hash() [](#method-i-test_flat_map_hash) - -## test_flat_map_nested() [](#method-i-test_flat_map_nested) - -## test_flat_map_non_array() [](#method-i-test_flat_map_non_array) - -## test_flat_map_take() [](#method-i-test_flat_map_take) - -## test_flat_map_to_ary() [](#method-i-test_flat_map_to_ary) - -## test_force() [](#method-i-test_force) - -## test_grep() [](#method-i-test_grep) - -## test_grep_multiple_values() [](#method-i-test_grep_multiple_values) - -## test_grep_v() [](#method-i-test_grep_v) - -## test_grep_v_multiple_values() [](#method-i-test_grep_v_multiple_values) - -## test_grep_v_with_block() [](#method-i-test_grep_v_with_block) - -## test_grep_with_block() [](#method-i-test_grep_with_block) - -## test_initialize() [](#method-i-test_initialize) - -## test_inspect() [](#method-i-test_inspect) - -## test_laziness_conservation() [](#method-i-test_laziness_conservation) - -## test_lazy_eager() [](#method-i-test_lazy_eager) - -## test_lazy_to_enum() [](#method-i-test_lazy_to_enum) - -## test_lazy_to_enum_lazy_methods() [](#method-i-test_lazy_to_enum_lazy_methods) - -## test_lazy_zip_map_yield_arity_bug_20623() [](#method-i-test_lazy_zip_map_yield_arity_bug_20623) - -## test_map() [](#method-i-test_map) - -## test_map_packed_nested() [](#method-i-test_map_packed_nested) - -## test_map_zip() [](#method-i-test_map_zip) - -## test_no_warnings() [](#method-i-test_no_warnings) - -## test_reject() [](#method-i-test_reject) - -## test_reject_multiple_values() [](#method-i-test_reject_multiple_values) - -## test_require_block() [](#method-i-test_require_block) - -## test_select() [](#method-i-test_select) - -## test_select_multiple_values() [](#method-i-test_select_multiple_values) - -## test_size() [](#method-i-test_size) - -## test_symbol_chain() [](#method-i-test_symbol_chain) - -## test_take() [](#method-i-test_take) - -## test_take_0_bug_18971() [](#method-i-test_take_0_bug_18971) - -## test_take_bad_arg() [](#method-i-test_take_bad_arg) - -## test_take_nested() [](#method-i-test_take_nested) - -## test_take_recycle() [](#method-i-test_take_recycle) - -## test_take_rewound() [](#method-i-test_take_rewound) - -## test_take_while() [](#method-i-test_take_while) - -## test_uniq() [](#method-i-test_uniq) - -## test_with_index() [](#method-i-test_with_index) - -## test_with_index_size() [](#method-i-test_with_index_size) - -## test_zip() [](#method-i-test_zip) - -## test_zip_bad_arg() [](#method-i-test_zip_bad_arg) - -## test_zip_efficient_on_array_args() [](#method-i-test_zip_efficient_on_array_args) - -## test_zip_lazy_on_args() [](#method-i-test_zip_lazy_on_args) - -## test_zip_map_lambda_bug_19569() [](#method-i-test_zip_map_lambda_bug_19569) - -## test_zip_nested() [](#method-i-test_zip_nested) - -## test_zip_nonsingle() [](#method-i-test_zip_nonsingle) - -## test_zip_short_arg() [](#method-i-test_zip_short_arg) - -## test_zip_with_block() [](#method-i-test_zip_with_block) - -## test_zip_without_arg() [](#method-i-test_zip_without_arg) - diff --git a/example/ruby/TestLazyEnumerator/Step.md b/example/ruby/TestLazyEnumerator/Step.md deleted file mode 100644 index 6b0cda4..0000000 --- a/example/ruby/TestLazyEnumerator/Step.md +++ /dev/null @@ -1,2081 +0,0 @@ -# Class: TestLazyEnumerator::Step -**Inherits:** Object - -**Includes:** Enumerable - - - - -# Attributes -## args[RW] [](#attribute-i-args) -Returns the value of attribute args. - -## current[RW] [](#attribute-i-current) -Returns the value of attribute current. - - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(*args) [](#method-i-each) - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(enum) [](#method-i-initialize) - -**@return** [Step] a new instance of Step - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/TestLoadFailure.md b/example/ruby/TestLoadFailure.md deleted file mode 100644 index 4209719..0000000 --- a/example/ruby/TestLoadFailure.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestLoadFailure -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_load_failure() [](#method-i-test_load_failure) - -## test_load_failure_parallel() [](#method-i-test_load_failure_parallel) - diff --git a/example/ruby/TestLogDevice.md b/example/ruby/TestLogDevice.md deleted file mode 100644 index 9fab01c..0000000 --- a/example/ruby/TestLogDevice.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: TestLogDevice -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## d(log, opt{}) [](#method-i-d) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_close() [](#method-i-test_close) - -## test_initialize() [](#method-i-test_initialize) - -## test_invalid_shifting_age() [](#method-i-test_invalid_shifting_age) - -## test_open_logfile_in_multiprocess() [](#method-i-test_open_logfile_in_multiprocess) - -## test_reopen_file() [](#method-i-test_reopen_file) - -## test_reopen_file_by_file() [](#method-i-test_reopen_file_by_file) - -## test_reopen_file_by_io() [](#method-i-test_reopen_file_by_io) - -## test_reopen_io() [](#method-i-test_reopen_io) - -## test_reopen_io_by_file() [](#method-i-test_reopen_io_by_file) - -## test_reopen_io_by_io() [](#method-i-test_reopen_io_by_io) - -## test_shifting_age() [](#method-i-test_shifting_age) - -## test_shifting_age_in_multiprocess() [](#method-i-test_shifting_age_in_multiprocess) - -## test_shifting_age_variants() [](#method-i-test_shifting_age_variants) - -## test_shifting_dst_change() [](#method-i-test_shifting_dst_change) - -## test_shifting_midnight() [](#method-i-test_shifting_midnight) - -## test_shifting_midnight_exist_file() [](#method-i-test_shifting_midnight_exist_file) - -## test_shifting_monthly() [](#method-i-test_shifting_monthly) - -## test_shifting_monthly_dst_change() [](#method-i-test_shifting_monthly_dst_change) - -## test_shifting_monthly_exist_file() [](#method-i-test_shifting_monthly_exist_file) - -## test_shifting_period_suffix() [](#method-i-test_shifting_period_suffix) - -## test_shifting_size() [](#method-i-test_shifting_size) - -## test_shifting_size_in_multiprocess() [](#method-i-test_shifting_size_in_multiprocess) - -## test_shifting_size_not_rotate_too_much() [](#method-i-test_shifting_size_not_rotate_too_much) - -## test_shifting_weekly() [](#method-i-test_shifting_weekly) - -## test_shifting_weekly_dst_change() [](#method-i-test_shifting_weekly_dst_change) - -## test_shifting_weekly_exist_file() [](#method-i-test_shifting_weekly_exist_file) - -## test_write() [](#method-i-test_write) - diff --git a/example/ruby/TestLogDevice/LogExcnRaiser.md b/example/ruby/TestLogDevice/LogExcnRaiser.md deleted file mode 100644 index e50bc8c..0000000 --- a/example/ruby/TestLogDevice/LogExcnRaiser.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestLogDevice::LogExcnRaiser -**Inherits:** Object - - - - - -#Instance Methods -## close() [](#method-i-close) - -## stat() [](#method-i-stat) - -## write(*arg) [](#method-i-write) - diff --git a/example/ruby/TestLogPeriod.md b/example/ruby/TestLogPeriod.md deleted file mode 100644 index e701b33..0000000 --- a/example/ruby/TestLogPeriod.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestLogPeriod -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_next_rotate_time() [](#method-i-test_next_rotate_time) - -## test_next_rotate_time_extreme_cases() [](#method-i-test_next_rotate_time_extreme_cases) - -## test_previous_period_end() [](#method-i-test_previous_period_end) - -## test_previous_period_end_extreme_cases() [](#method-i-test_previous_period_end_extreme_cases) - diff --git a/example/ruby/TestLogger.md b/example/ruby/TestLogger.md deleted file mode 100644 index 16e14e6..0000000 --- a/example/ruby/TestLogger.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: TestLogger -**Inherits:** Test::Unit::TestCase - -**Includes:** Logger::Severity - - - - - -#Instance Methods -## log(logger, msg_id, *arg, &block) [](#method-i-log) - -## log_add(logger, severity, msg, prognamenil, &block) [](#method-i-log_add) - -## log_raw(logger, msg_id, *arg, &block) [](#method-i-log_raw) - -## setup() [](#method-i-setup) - -## test_add() [](#method-i-test_add) - -## test_add_binary_data_with_binmode_logdev() [](#method-i-test_add_binary_data_with_binmode_logdev) - -## test_close() [](#method-i-test_close) - -## test_datetime_format() [](#method-i-test_datetime_format) - -## test_does_not_instantiate_log_device_for_File_NULL() [](#method-i-test_does_not_instantiate_log_device_for_File_NULL) - -## test_format() [](#method-i-test_format) - -## test_formatter() [](#method-i-test_formatter) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_with_datetime_format() [](#method-i-test_initialize_with_datetime_format) - -## test_initialize_with_formatter() [](#method-i-test_initialize_with_formatter) - -## test_initialize_with_level() [](#method-i-test_initialize_with_level) - -## test_initialize_with_progname() [](#method-i-test_initialize_with_progname) - -## test_level() [](#method-i-test_level) - -## test_level_log() [](#method-i-test_level_log) - -## test_lshift() [](#method-i-test_lshift) - -## test_overriding_level() [](#method-i-test_overriding_level) - -## test_progname() [](#method-i-test_progname) - -## test_reopen() [](#method-i-test_reopen) - -## test_reopen_nil_logdevice() [](#method-i-test_reopen_nil_logdevice) - -## test_reraise_write_errors() [](#method-i-test_reraise_write_errors) - -## test_string_level() [](#method-i-test_string_level) - -## test_symbol_level() [](#method-i-test_symbol_level) - diff --git a/example/ruby/TestLogger/CustomLogger.md b/example/ruby/TestLogger/CustomLogger.md deleted file mode 100644 index ea57adf..0000000 --- a/example/ruby/TestLogger/CustomLogger.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestLogger::CustomLogger -**Inherits:** Logger - - - - - -#Instance Methods -## level() [](#method-i-level) - diff --git a/example/ruby/TestLogger/Log.md b/example/ruby/TestLogger/Log.md deleted file mode 100644 index d117388..0000000 --- a/example/ruby/TestLogger/Log.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: TestLogger::Log -**Inherits:** Object - - - - -# Attributes -## datetime[RW] [](#attribute-i-datetime) -Returns the value of attribute datetime. - -## label[RW] [](#attribute-i-label) -Returns the value of attribute label. - -## msg[RW] [](#attribute-i-msg) -Returns the value of attribute msg. - -## pid[RW] [](#attribute-i-pid) -Returns the value of attribute pid. - -## progname[RW] [](#attribute-i-progname) -Returns the value of attribute progname. - -## severity[RW] [](#attribute-i-severity) -Returns the value of attribute severity. - - -#Instance Methods -## initialize(line) [](#method-i-initialize) - -**@return** [Log] a new instance of Log - diff --git a/example/ruby/TestLogger/MyError.md b/example/ruby/TestLogger/MyError.md deleted file mode 100644 index 767d7dd..0000000 --- a/example/ruby/TestLogger/MyError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestLogger::MyError -**Inherits:** StandardError - - - - - diff --git a/example/ruby/TestLogger/MyMsg.md b/example/ruby/TestLogger/MyMsg.md deleted file mode 100644 index 67a9ee9..0000000 --- a/example/ruby/TestLogger/MyMsg.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestLogger::MyMsg -**Inherits:** Object - - - - - -#Instance Methods -## inspect() [](#method-i-inspect) - diff --git a/example/ruby/TestLoggerSeverity.md b/example/ruby/TestLoggerSeverity.md deleted file mode 100644 index 02aa885..0000000 --- a/example/ruby/TestLoggerSeverity.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestLoggerSeverity -**Inherits:** Test::Unit::TestCase - -**Includes:** Logger::Severity - - - - - -#Instance Methods -## test_enum() [](#method-i-test_enum) - -## test_fiber_local_level() [](#method-i-test_fiber_local_level) - -## test_level_assignment() [](#method-i-test_level_assignment) - -## test_thread_local_level() [](#method-i-test_thread_local_level) - diff --git a/example/ruby/TestM17N.md b/example/ruby/TestM17N.md deleted file mode 100644 index 2c86492..0000000 --- a/example/ruby/TestM17N.md +++ /dev/null @@ -1,319 +0,0 @@ -# Class: TestM17N -**Inherits:** Test::Unit::TestCase - -**Extended by:** TestM17N::AESU - -**Includes:** TestM17N::AESU - - - - -# Class Methods -## a(str ) [](#method-c-a) -## e(str ) [](#method-c-e) -## s(str ) [](#method-c-s) -## u(str ) [](#method-c-u) -## ua(str ) [](#method-c-ua) - -#Instance Methods -## a(str) [](#method-i-a) - -## assert_encoding(encname, actual, messagenil) [](#method-i-assert_encoding) - -## assert_regexp_fixed_ascii8bit(r) [](#method-i-assert_regexp_fixed_ascii8bit) - -## assert_regexp_fixed_encoding(r) [](#method-i-assert_regexp_fixed_encoding) - -## assert_regexp_fixed_eucjp(r) [](#method-i-assert_regexp_fixed_eucjp) - -## assert_regexp_fixed_sjis(r) [](#method-i-assert_regexp_fixed_sjis) - -## assert_regexp_fixed_utf8(r) [](#method-i-assert_regexp_fixed_utf8) - -## assert_regexp_generic_ascii(r) [](#method-i-assert_regexp_generic_ascii) - -## assert_regexp_generic_encoding(r) [](#method-i-assert_regexp_generic_encoding) - -## assert_regexp_usascii_literal(r, enc, exnil) [](#method-i-assert_regexp_usascii_literal) - -## assert_same_result(expected_proc, actual_proc) [](#method-i-assert_same_result) - -## assert_str_enc_propagation(t, s1, s2) [](#method-i-assert_str_enc_propagation) - -## assert_strenc(bytes, enc, actual, messagenil) [](#method-i-assert_strenc) - -## e(str) [](#method-i-e) - -## each_encoding(*strings) [](#method-i-each_encoding) - -## encdump(str) [](#method-i-encdump) - -## encdumpargs(args) [](#method-i-encdumpargs) - -## s(str) [](#method-i-s) - -## str_enc_compatible?(*strs) [](#method-i-str_enc_compatible?) - -**@return** [Boolean] - -## test_array_to_s() [](#method-i-test_array_to_s) - -## test_aset() [](#method-i-test_aset) - -## test_begin_end_offset() [](#method-i-test_begin_end_offset) - -## test_begin_end_offset_sjis() [](#method-i-test_begin_end_offset_sjis) - -## test_bignum_to_s() [](#method-i-test_bignum_to_s) - -## test_casecmp() [](#method-i-test_casecmp) - -## test_chomp() [](#method-i-test_chomp) - -## test_chr() [](#method-i-test_chr) - -## test_combchar_codepoint() [](#method-i-test_combchar_codepoint) - -## test_compatible() [](#method-i-test_compatible) - -## test_count() [](#method-i-test_count) - -## test_count_sjis_trailing_byte() [](#method-i-test_count_sjis_trailing_byte) - -## test_delete() [](#method-i-test_delete) - -## test_dup_aref() [](#method-i-test_dup_aref) - -## test_dup_scan() [](#method-i-test_dup_scan) - -## test_dynamic_ascii_regexp() [](#method-i-test_dynamic_ascii_regexp) - -## test_dynamic_eucjp_regexp() [](#method-i-test_dynamic_eucjp_regexp) - -## test_dynamic_sjis_regexp() [](#method-i-test_dynamic_sjis_regexp) - -## test_dynamic_utf8_regexp() [](#method-i-test_dynamic_utf8_regexp) - -## test_each_char() [](#method-i-test_each_char) - -## test_each_line() [](#method-i-test_each_line) - -## test_empty_string() [](#method-i-test_empty_string) - -## test_encoding_find() [](#method-i-test_encoding_find) - -## test_encoding_names_of_default_internal() [](#method-i-test_encoding_names_of_default_internal) - -## test_encoding_to_s() [](#method-i-test_encoding_to_s) - -## test_end_with() [](#method-i-test_end_with) - -## test_env() [](#method-i-test_env) - -## test_escaped_metachar() [](#method-i-test_escaped_metachar) - -## test_euc_tw() [](#method-i-test_euc_tw) - -## test_false_to_s() [](#method-i-test_false_to_s) - -## test_fixnum_to_s() [](#method-i-test_fixnum_to_s) - -## test_float_to_s() [](#method-i-test_float_to_s) - -## test_force_encoding() [](#method-i-test_force_encoding) - -## test_gbk() [](#method-i-test_gbk) - -## test_getbyte() [](#method-i-test_getbyte) - -## test_greek_capital_gap() [](#method-i-test_greek_capital_gap) - -## test_gsub() [](#method-i-test_gsub) - -## test_hash_to_s() [](#method-i-test_hash_to_s) - -## test_include?() [](#method-i-test_include?) - -**@return** [Boolean] - -## test_index() [](#method-i-test_index) - -## test_insert() [](#method-i-test_insert) - -## test_inspect_with_default_internal() [](#method-i-test_inspect_with_default_internal) - -## test_magic_comment() [](#method-i-test_magic_comment) - -## test_magic_comment_at_various_positions() [](#method-i-test_magic_comment_at_various_positions) - -## test_magic_comment_vim() [](#method-i-test_magic_comment_vim) - -## test_marshal() [](#method-i-test_marshal) - -## test_next() [](#method-i-test_next) - -## test_nil_inspect() [](#method-i-test_nil_inspect) - -## test_nil_to_s() [](#method-i-test_nil_to_s) - -## test_nonascii_method_name() [](#method-i-test_nonascii_method_name) - -## test_object_inspect_external() [](#method-i-test_object_inspect_external) - -## test_object_utf16_32_inspect() [](#method-i-test_object_utf16_32_inspect) - -## test_plus() [](#method-i-test_plus) - -## test_quote() [](#method-i-test_quote) - -## test_regexp_ascii() [](#method-i-test_regexp_ascii) - -## test_regexp_ascii_none() [](#method-i-test_regexp_ascii_none) - -## test_regexp_embed() [](#method-i-test_regexp_embed) - -## test_regexp_embed_preprocess() [](#method-i-test_regexp_embed_preprocess) - -## test_regexp_euc() [](#method-i-test_regexp_euc) - -## test_regexp_generic() [](#method-i-test_regexp_generic) - -## test_regexp_match() [](#method-i-test_regexp_match) - -## test_regexp_mixed_unicode() [](#method-i-test_regexp_mixed_unicode) - -## test_regexp_named_class() [](#method-i-test_regexp_named_class) - -## test_regexp_property() [](#method-i-test_regexp_property) - -## test_regexp_sjis() [](#method-i-test_regexp_sjis) - -## test_regexp_source() [](#method-i-test_regexp_source) - -## test_regexp_too_short_multibyte_character() [](#method-i-test_regexp_too_short_multibyte_character) - -## test_regexp_unicode() [](#method-i-test_regexp_unicode) - -## test_regexp_usascii() [](#method-i-test_regexp_usascii) - -## test_regexp_windows_31j() [](#method-i-test_regexp_windows_31j) - -## test_reverse() [](#method-i-test_reverse) - -## test_reverse_bang() [](#method-i-test_reverse_bang) - -## test_scan() [](#method-i-test_scan) - -## test_scrub_bang() [](#method-i-test_scrub_bang) - -## test_scrub_dummy_encoding() [](#method-i-test_scrub_dummy_encoding) - -## test_scrub_modification_inside_block() [](#method-i-test_scrub_modification_inside_block) - -## test_scrub_replace_argument() [](#method-i-test_scrub_replace_argument) - -## test_scrub_replace_block() [](#method-i-test_scrub_replace_block) - -## test_scrub_replace_default() [](#method-i-test_scrub_replace_default) - -## test_scrub_valid_string() [](#method-i-test_scrub_valid_string) - -## test_scrub_widechar() [](#method-i-test_scrub_widechar) - -## test_setbyte() [](#method-i-test_setbyte) - -## test_setbyte_range() [](#method-i-test_setbyte_range) - -## test_split() [](#method-i-test_split) - -## test_sprintf_c() [](#method-i-test_sprintf_c) - -## test_sprintf_p() [](#method-i-test_sprintf_p) - -## test_sprintf_s() [](#method-i-test_sprintf_s) - -## test_squeeze() [](#method-i-test_squeeze) - -## test_str_String() [](#method-i-test_str_String) - -## test_str_allocate() [](#method-i-test_str_allocate) - -## test_str_aref() [](#method-i-test_str_aref) - -## test_str_aref_force_encoding() [](#method-i-test_str_aref_force_encoding) - -## test_str_aref_len() [](#method-i-test_str_aref_len) - -## test_str_aref_substr() [](#method-i-test_str_aref_substr) - -## test_str_b() [](#method-i-test_str_b) - -## test_str_center() [](#method-i-test_str_center) - -## test_str_concat() [](#method-i-test_str_concat) - -## test_str_dump() [](#method-i-test_str_dump) - -## test_str_lt() [](#method-i-test_str_lt) - -## test_str_multiply() [](#method-i-test_str_multiply) - -## test_string_ascii_literal() [](#method-i-test_string_ascii_literal) -tests start - -## test_string_eucjp_literal() [](#method-i-test_string_eucjp_literal) - -## test_string_inspect_encoding() [](#method-i-test_string_inspect_encoding) - -## test_string_inspect_invalid() [](#method-i-test_string_inspect_invalid) - -## test_string_mixed_unicode() [](#method-i-test_string_mixed_unicode) - -## test_sub() [](#method-i-test_sub) - -## test_sub2() [](#method-i-test_sub2) - -## test_sub3() [](#method-i-test_sub3) - -## test_symbol() [](#method-i-test_symbol) - -## test_symbol_op() [](#method-i-test_symbol_op) - -## test_tr() [](#method-i-test_tr) - -## test_tr_s() [](#method-i-test_tr_s) - -## test_true_to_s() [](#method-i-test_true_to_s) - -## test_union_0() [](#method-i-test_union_0) - -## test_union_1_asciionly_string() [](#method-i-test_union_1_asciionly_string) - -## test_union_1_nonascii_string() [](#method-i-test_union_1_nonascii_string) - -## test_union_1_regexp() [](#method-i-test_union_1_regexp) - -## test_union_2() [](#method-i-test_union_2) - -## test_upto() [](#method-i-test_upto) - -## test_utf8_literal() [](#method-i-test_utf8_literal) - -## test_utf8str_aref() [](#method-i-test_utf8str_aref) - -## test_utf_dummy_are_like_regular_dummy_encodings() [](#method-i-test_utf_dummy_are_like_regular_dummy_encodings) - -## test_utf_without_bom_asciionly() [](#method-i-test_utf_without_bom_asciionly) - -## test_utf_without_bom_valid() [](#method-i-test_utf_without_bom_valid) - -## test_valid_encoding() [](#method-i-test_valid_encoding) - -## test_validate_redundant_utf8() [](#method-i-test_validate_redundant_utf8) - -## test_validate_surrogate() [](#method-i-test_validate_surrogate) - -## u(str) [](#method-i-u) - -## ua(str) [](#method-i-ua) - diff --git a/example/ruby/TestM17N/AESU.md b/example/ruby/TestM17N/AESU.md deleted file mode 100644 index c3e57a7..0000000 --- a/example/ruby/TestM17N/AESU.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: TestM17N::AESU - - - - - -#Instance Methods -## a(str) [](#method-i-a) - -## e(str) [](#method-i-e) - -## s(str) [](#method-i-s) - -## u(str) [](#method-i-u) - -## ua(str) [](#method-i-ua) - diff --git a/example/ruby/TestM17NComb.md b/example/ruby/TestM17NComb.md deleted file mode 100644 index 82a3888..0000000 --- a/example/ruby/TestM17NComb.md +++ /dev/null @@ -1,231 +0,0 @@ -# Class: TestM17NComb -**Inherits:** Test::Unit::TestCase - -**Extended by:** TestM17NComb::AESU - -**Includes:** TestM17NComb::AESU - - - - -# Class Methods -## a(str ) [](#method-c-a) -## b(str ) [](#method-c-b) -## e(str ) [](#method-c-e) -## s(str ) [](#method-c-s) -## u(str ) [](#method-c-u) - -#Instance Methods -## a(str) [](#method-i-a) - -## assert_enccall(recv, meth, *args, &block) [](#method-i-assert_enccall) - -## assert_encoding(encname, actual, messagenil) [](#method-i-assert_encoding) - -## assert_same_result(expected_proc, actual_proc) [](#method-i-assert_same_result) - -## assert_str_enc_propagation(t, s1, s2) [](#method-i-assert_str_enc_propagation) - -## assert_strenc(bytes, enc, actual, messagenil) [](#method-i-assert_strenc) - -## b(str) [](#method-i-b) - -## combination(*args, &b) [](#method-i-combination) - -## crypt_supports_des_crypt?() [](#method-i-crypt_supports_des_crypt?) - -**@return** [Boolean] - -## e(str) [](#method-i-e) - -## each_slice_call() [](#method-i-each_slice_call) - -## encdump(str) [](#method-i-encdump) - -## encdumpargs(args) [](#method-i-encdumpargs) - -## encdumpcall(recv, meth, *args, &block) [](#method-i-encdumpcall) - -## s(str) [](#method-i-s) - -## str_enc_compatible?(*strs) [](#method-i-str_enc_compatible?) - -**@return** [Boolean] - -## test_bug11486() [](#method-i-test_bug11486) - -## test_marshal() [](#method-i-test_marshal) - -## test_sprintf_s() [](#method-i-test_sprintf_s) - -## test_str_aref() [](#method-i-test_str_aref) - -## test_str_aref_len() [](#method-i-test_str_aref_len) - -## test_str_aref_range2() [](#method-i-test_str_aref_range2) - -## test_str_aref_range3() [](#method-i-test_str_aref_range3) - -## test_str_aref_substr() [](#method-i-test_str_aref_substr) - -## test_str_assign() [](#method-i-test_str_assign) - -## test_str_assign_len() [](#method-i-test_str_assign_len) - -## test_str_assign_range2() [](#method-i-test_str_assign_range2) - -## test_str_assign_range3() [](#method-i-test_str_assign_range3) - -## test_str_assign_substr() [](#method-i-test_str_assign_substr) - -## test_str_bytes() [](#method-i-test_str_bytes) - -## test_str_bytesize() [](#method-i-test_str_bytesize) - -## test_str_capitalize() [](#method-i-test_str_capitalize) - -## test_str_casecmp() [](#method-i-test_str_casecmp) - -## test_str_casecmp?() [](#method-i-test_str_casecmp?) - -**@return** [Boolean] - -## test_str_center() [](#method-i-test_str_center) - -## test_str_chars() [](#method-i-test_str_chars) - -## test_str_chomp() [](#method-i-test_str_chomp) - -## test_str_chop() [](#method-i-test_str_chop) - -## test_str_chr() [](#method-i-test_str_chr) - -## test_str_clear() [](#method-i-test_str_clear) - -## test_str_clone() [](#method-i-test_str_clone) - -## test_str_cmp() [](#method-i-test_str_cmp) - -## test_str_concat() [](#method-i-test_str_concat) - -## test_str_count() [](#method-i-test_str_count) - -## test_str_crypt() [](#method-i-test_str_crypt) - -## test_str_crypt_nonstrict() [](#method-i-test_str_crypt_nonstrict) - -## test_str_delete() [](#method-i-test_str_delete) - -## test_str_downcase() [](#method-i-test_str_downcase) - -## test_str_dump() [](#method-i-test_str_dump) - -## test_str_dup() [](#method-i-test_str_dup) - -## test_str_each_byte() [](#method-i-test_str_each_byte) - -## test_str_each_line() [](#method-i-test_str_each_line) - -## test_str_empty?() [](#method-i-test_str_empty?) - -**@return** [Boolean] - -## test_str_end_with?() [](#method-i-test_str_end_with?) - -**@return** [Boolean] - -## test_str_eq() [](#method-i-test_str_eq) - -## test_str_eq_reflexive() [](#method-i-test_str_eq_reflexive) - -## test_str_eq_symmetric() [](#method-i-test_str_eq_symmetric) - -## test_str_eq_transitive() [](#method-i-test_str_eq_transitive) - -## test_str_hash() [](#method-i-test_str_hash) - -## test_str_hex() [](#method-i-test_str_hex) - -## test_str_include?() [](#method-i-test_str_include?) - -**@return** [Boolean] - -## test_str_index() [](#method-i-test_str_index) - -## test_str_insert() [](#method-i-test_str_insert) - -## test_str_intern() [](#method-i-test_str_intern) - -## test_str_length() [](#method-i-test_str_length) - -## test_str_ljust() [](#method-i-test_str_ljust) - -## test_str_new() [](#method-i-test_str_new) -tests start - -## test_str_oct() [](#method-i-test_str_oct) - -## test_str_ord() [](#method-i-test_str_ord) - -## test_str_partition() [](#method-i-test_str_partition) - -## test_str_plus() [](#method-i-test_str_plus) - -## test_str_replace() [](#method-i-test_str_replace) - -## test_str_reverse() [](#method-i-test_str_reverse) - -## test_str_rindex() [](#method-i-test_str_rindex) - -## test_str_rjust() [](#method-i-test_str_rjust) - -## test_str_rpartition() [](#method-i-test_str_rpartition) - -## test_str_scan() [](#method-i-test_str_scan) - -## test_str_slice() [](#method-i-test_str_slice) - -## test_str_slice!() [](#method-i-test_str_slice!) - -## test_str_smart_chomp() [](#method-i-test_str_smart_chomp) - -## test_str_split() [](#method-i-test_str_split) - -## test_str_squeeze() [](#method-i-test_str_squeeze) - -## test_str_start_with?() [](#method-i-test_str_start_with?) - -**@return** [Boolean] - -## test_str_strip() [](#method-i-test_str_strip) - -## test_str_sub() [](#method-i-test_str_sub) - -## test_str_sub!() [](#method-i-test_str_sub!) - -## test_str_succ() [](#method-i-test_str_succ) - -## test_str_succ2() [](#method-i-test_str_succ2) - -## test_str_sum() [](#method-i-test_str_sum) - -## test_str_swapcase() [](#method-i-test_str_swapcase) - -## test_str_times() [](#method-i-test_str_times) - -## test_str_to_f() [](#method-i-test_str_to_f) - -## test_str_to_i() [](#method-i-test_str_to_i) - -## test_str_to_s() [](#method-i-test_str_to_s) - -## test_str_upcase() [](#method-i-test_str_upcase) - -## test_tr() [](#method-i-test_tr) - -## test_tr_s() [](#method-i-test_tr_s) - -## test_tr_sjis() [](#method-i-test_tr_sjis) - -## u(str) [](#method-i-u) - diff --git a/example/ruby/TestM17NComb/AESU.md b/example/ruby/TestM17NComb/AESU.md deleted file mode 100644 index 5549e29..0000000 --- a/example/ruby/TestM17NComb/AESU.md +++ /dev/null @@ -1,17 +0,0 @@ -# Module: TestM17NComb::AESU - - - - - -#Instance Methods -## a(str) [](#method-i-a) - -## b(str) [](#method-i-b) - -## e(str) [](#method-i-e) - -## s(str) [](#method-i-s) - -## u(str) [](#method-i-u) - diff --git a/example/ruby/TestMarshal.md b/example/ruby/TestMarshal.md deleted file mode 100644 index ba2e147..0000000 --- a/example/ruby/TestMarshal.md +++ /dev/null @@ -1,268 +0,0 @@ -# Class: TestMarshal -**Inherits:** Test::Unit::TestCase - -**Includes:** MarshalTestLib - - - - - -#Instance Methods -## _test_hash_compared_by_identity(h) [](#method-i-_test_hash_compared_by_identity) - -## decode(s) [](#method-i-decode) - -## encode(o) [](#method-i-encode) - -## exception_test() [](#method-i-exception_test) - -## fact(n) [](#method-i-fact) - -## marshal_equal(o1, msgnil) [](#method-i-marshal_equal) - -## marshal_equal_with_ancestry(o1, msgnil) [](#method-i-marshal_equal_with_ancestry) - -## marshaltest(o1) [](#method-i-marshaltest) - -## nameerror_test() [](#method-i-nameerror_test) - -## ruby2_keywords_test(key:1) [](#method-i-ruby2_keywords_test) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_anonymous() [](#method-i-test_anonymous) - -## test_array() [](#method-i-test_array) - -## test_array_ivar() [](#method-i-test_array_ivar) - -## test_array_subclass() [](#method-i-test_array_subclass) - -## test_bignum() [](#method-i-test_bignum) - -## test_change_class_name() [](#method-i-test_change_class_name) - -## test_change_struct() [](#method-i-test_change_struct) - -## test_class() [](#method-i-test_class) - -## test_class_ivar() [](#method-i-test_class_ivar) - -## test_class_nonascii() [](#method-i-test_class_nonascii) - -## test_context_switch() [](#method-i-test_context_switch) - -## test_continuation() [](#method-i-test_continuation) - -## test_dump_buffer() [](#method-i-test_dump_buffer) - -## test_exception() [](#method-i-test_exception) - -## test_exception_subclass() [](#method-i-test_exception_subclass) - -## test_extend() [](#method-i-test_extend) - -## test_extend_string() [](#method-i-test_extend_string) - -## test_false() [](#method-i-test_false) - -## test_fixnum() [](#method-i-test_fixnum) - -## test_float() [](#method-i-test_float) - -## test_float_inf_nan() [](#method-i-test_float_inf_nan) - -## test_gc() [](#method-i-test_gc) - -## test_hash() [](#method-i-test_hash) - -## test_hash_compared_by_identity() [](#method-i-test_hash_compared_by_identity) - -## test_hash_default() [](#method-i-test_hash_default) - -## test_hash_default_compared_by_identity() [](#method-i-test_hash_default_compared_by_identity) - -## test_hash_default_proc() [](#method-i-test_hash_default_proc) - -## test_hash_extend() [](#method-i-test_hash_extend) - -## test_hash_ivar() [](#method-i-test_hash_ivar) - -## test_hash_subclass() [](#method-i-test_hash_subclass) - -## test_hash_subclass_extend() [](#method-i-test_hash_subclass_extend) - -## test_inconsistent_struct() [](#method-i-test_inconsistent_struct) - -## test_invalid_byte_sequence_symbol() [](#method-i-test_invalid_byte_sequence_symbol) - -## test_limit() [](#method-i-test_limit) - -## test_load_range_as_struct() [](#method-i-test_load_range_as_struct) - -## test_marshal() [](#method-i-test_marshal) - -## test_marshal_cloned_class() [](#method-i-test_marshal_cloned_class) - -## test_marshal_complex() [](#method-i-test_marshal_complex) - -## test_marshal_dump() [](#method-i-test_marshal_dump) - -## test_marshal_dump_adding_instance_variable() [](#method-i-test_marshal_dump_adding_instance_variable) - -## test_marshal_dump_excess_encoding() [](#method-i-test_marshal_dump_excess_encoding) - -## test_marshal_dump_extra_iv() [](#method-i-test_marshal_dump_extra_iv) - -## test_marshal_dump_ivar() [](#method-i-test_marshal_dump_ivar) - -## test_marshal_dump_recursion() [](#method-i-test_marshal_dump_recursion) - -## test_marshal_dump_removing_instance_variable() [](#method-i-test_marshal_dump_removing_instance_variable) - -## test_marshal_dump_struct_ivar() [](#method-i-test_marshal_dump_struct_ivar) - -## test_marshal_encoding_encoding() [](#method-i-test_marshal_encoding_encoding) - -## test_marshal_exception() [](#method-i-test_marshal_exception) - -## test_marshal_flonum_reference() [](#method-i-test_marshal_flonum_reference) - -## test_marshal_honor_post_proc_value_for_link() [](#method-i-test_marshal_honor_post_proc_value_for_link) - -## test_marshal_integers() [](#method-i-test_marshal_integers) - -## test_marshal_keyword_init_struct() [](#method-i-test_marshal_keyword_init_struct) - -## test_marshal_load_extended_class_crash() [](#method-i-test_marshal_load_extended_class_crash) - -## test_marshal_load_ivar() [](#method-i-test_marshal_load_ivar) - -## test_marshal_load_r_prepare_reference_crash() [](#method-i-test_marshal_load_r_prepare_reference_crash) - -## test_marshal_nameerror() [](#method-i-test_marshal_nameerror) - -## test_marshal_private_class() [](#method-i-test_marshal_private_class) - -## test_marshal_proc_freeze() [](#method-i-test_marshal_proc_freeze) - -## test_marshal_proc_string_encoding() [](#method-i-test_marshal_proc_string_encoding) - -## test_marshal_rational() [](#method-i-test_marshal_rational) - -## test_marshal_regexp_encoding() [](#method-i-test_marshal_regexp_encoding) - -## test_marshal_respond_to_arity() [](#method-i-test_marshal_respond_to_arity) - -## test_marshal_small_bignum_backref() [](#method-i-test_marshal_small_bignum_backref) - -## test_marshal_string_encoding() [](#method-i-test_marshal_string_encoding) - -## test_marshal_symbol_ascii8bit() [](#method-i-test_marshal_symbol_ascii8bit) - -## test_marshal_with_ruby2_keywords_hash() [](#method-i-test_marshal_with_ruby2_keywords_hash) - -## test_method_missing_without_respond_to() [](#method-i-test_method_missing_without_respond_to) - -## test_modify_array_during_dump() [](#method-i-test_modify_array_during_dump) - -## test_module_ivar() [](#method-i-test_module_ivar) - -## test_nil() [](#method-i-test_nil) - -## test_no_internal_ids() [](#method-i-test_no_internal_ids) - -## test_object() [](#method-i-test_object) - -## test_object_extend() [](#method-i-test_object_extend) - -## test_object_prepend() [](#method-i-test_object_prepend) - -## test_object_subclass() [](#method-i-test_object_subclass) - -## test_object_subclass_extend() [](#method-i-test_object_subclass_extend) - -## test_packed_string() [](#method-i-test_packed_string) - -## test_pipe() [](#method-i-test_pipe) - -## test_range() [](#method-i-test_range) - -## test_range_cyclic() [](#method-i-test_range_cyclic) - -## test_range_subclass() [](#method-i-test_range_subclass) - -## test_regexp() [](#method-i-test_regexp) - -## test_regexp2() [](#method-i-test_regexp2) - -## test_regexp_subclass() [](#method-i-test_regexp_subclass) - -## test_share() [](#method-i-test_share) - -## test_singleton() [](#method-i-test_singleton) - -## test_string() [](#method-i-test_string) - -## test_string_crlf() [](#method-i-test_string_crlf) - -## test_string_empty() [](#method-i-test_string_empty) - -## test_string_escape() [](#method-i-test_string_escape) - -## test_string_ivar() [](#method-i-test_string_ivar) - -## test_string_subclass() [](#method-i-test_string_subclass) - -## test_string_subclass_cycle() [](#method-i-test_string_subclass_cycle) - -## test_string_subclass_extend() [](#method-i-test_string_subclass_extend) - -## test_struct() [](#method-i-test_struct) - -## test_struct_invalid_members() [](#method-i-test_struct_invalid_members) - -## test_struct_ivar() [](#method-i-test_struct_ivar) - -## test_struct_subclass() [](#method-i-test_struct_subclass) - -## test_struct_subclass_extend() [](#method-i-test_struct_subclass_extend) - -## test_struct_toplevel() [](#method-i-test_struct_toplevel) - -## test_symbol() [](#method-i-test_symbol) - -## test_symbol2() [](#method-i-test_symbol2) - -## test_symlink() [](#method-i-test_symlink) - -## test_symlink_in_ivar() [](#method-i-test_symlink_in_ivar) - -## test_time() [](#method-i-test_time) - -## test_time_in_array() [](#method-i-test_time_in_array) - -## test_time_ivar() [](#method-i-test_time_ivar) - -## test_time_subclass() [](#method-i-test_time_subclass) - -## test_too_long_string() [](#method-i-test_too_long_string) - -## test_true() [](#method-i-test_true) - -## test_undumpable_data() [](#method-i-test_undumpable_data) - -## test_undumpable_message() [](#method-i-test_undumpable_message) - -## test_unloadable_data() [](#method-i-test_unloadable_data) - -## test_unloadable_userdef() [](#method-i-test_unloadable_userdef) - -## test_unloadable_usrmarshal() [](#method-i-test_unloadable_usrmarshal) - -## test_userdef_encoding() [](#method-i-test_userdef_encoding) - -## test_userdef_invalid() [](#method-i-test_userdef_invalid) - diff --git a/example/ruby/TestMarshal/Bug12974.md b/example/ruby/TestMarshal/Bug12974.md deleted file mode 100644 index 666d24c..0000000 --- a/example/ruby/TestMarshal/Bug12974.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestMarshal::Bug12974 -**Inherits:** Object - - - - - -#Instance Methods -## marshal_dump() [](#method-i-marshal_dump) - diff --git a/example/ruby/TestMarshal/Bug14314.md b/example/ruby/TestMarshal/Bug14314.md deleted file mode 100644 index 2540dfe..0000000 --- a/example/ruby/TestMarshal/Bug14314.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: TestMarshal::Bug14314 -**Inherits:** Struct - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo - -**@return** [Object] the current value of foo - - diff --git a/example/ruby/TestMarshal/Bug15968.md b/example/ruby/TestMarshal/Bug15968.md deleted file mode 100644 index 0ff1414..0000000 --- a/example/ruby/TestMarshal/Bug15968.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: TestMarshal::Bug15968 -**Inherits:** Object - - - - -# Attributes -## bar[RW] [](#attribute-i-bar) -Returns the value of attribute bar. - -## baz[RW] [](#attribute-i-baz) -Returns the value of attribute baz. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Bug15968] a new instance of Bug15968 - diff --git a/example/ruby/TestMarshal/Bug15968/Bar.md b/example/ruby/TestMarshal/Bug15968/Bar.md deleted file mode 100644 index 63ee1ba..0000000 --- a/example/ruby/TestMarshal/Bug15968/Bar.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestMarshal::Bug15968::Bar -**Inherits:** Object - - - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - -#Instance Methods -## initialize(foo) [](#method-i-initialize) - -**@return** [Bar] a new instance of Bar - -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(data) [](#method-i-marshal_load) - diff --git a/example/ruby/TestMarshal/Bug7627.md b/example/ruby/TestMarshal/Bug7627.md deleted file mode 100644 index 122af17..0000000 --- a/example/ruby/TestMarshal/Bug7627.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: TestMarshal::Bug7627 -**Inherits:** Struct - - - - -# Attributes -## bar[RW] [](#attribute-i-bar) -Returns the value of attribute bar - -**@return** [Object] the current value of bar - -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - -#Instance Methods -## marshal_dump() [](#method-i-marshal_dump) -fake dump data - -## marshal_load() [](#method-i-marshal_load) -do nothing - diff --git a/example/ruby/TestMarshal/Bug8276.md b/example/ruby/TestMarshal/Bug8276.md deleted file mode 100644 index c6fc553..0000000 --- a/example/ruby/TestMarshal/Bug8276.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMarshal::Bug8276 -**Inherits:** TestMarshal::LoadData - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Bug8276] a new instance of Bug8276 - diff --git a/example/ruby/TestMarshal/Bug9523.md b/example/ruby/TestMarshal/Bug9523.md deleted file mode 100644 index 464d75d..0000000 --- a/example/ruby/TestMarshal/Bug9523.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestMarshal::Bug9523 -**Inherits:** Object - - - - -# Attributes -## cc[RW] [](#attribute-i-cc) -Returns the value of attribute cc. - - -#Instance Methods -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(v) [](#method-i-marshal_load) - diff --git a/example/ruby/TestMarshal/C.md b/example/ruby/TestMarshal/C.md deleted file mode 100644 index a104f95..0000000 --- a/example/ruby/TestMarshal/C.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestMarshal::C -**Inherits:** Object - - - - -# Class Methods -## _load(s ) [](#method-c-_load) -# Attributes -## str[RW] [](#attribute-i-str) -Returns the value of attribute str. - - -#Instance Methods -## _dump(limit) [](#method-i-_dump) - -## initialize(str) [](#method-i-initialize) - -**@return** [C] a new instance of C - diff --git a/example/ruby/TestMarshal/C2.md b/example/ruby/TestMarshal/C2.md deleted file mode 100644 index f3d7a00..0000000 --- a/example/ruby/TestMarshal/C2.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestMarshal::C2 -**Inherits:** Object - - - - - -#Instance Methods -## _dump(s) [](#method-i-_dump) - -## initialize(ary) [](#method-i-initialize) - -**@return** [C2] a new instance of C2 - diff --git a/example/ruby/TestMarshal/C4.md b/example/ruby/TestMarshal/C4.md deleted file mode 100644 index dd45aa1..0000000 --- a/example/ruby/TestMarshal/C4.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestMarshal::C4 -**Inherits:** Object - - - - - -#Instance Methods -## _dump(s) [](#method-i-_dump) - -## initialize(gc) [](#method-i-initialize) - -**@return** [C4] a new instance of C4 - diff --git a/example/ruby/TestMarshal/C5.md b/example/ruby/TestMarshal/C5.md deleted file mode 100644 index b339b61..0000000 --- a/example/ruby/TestMarshal/C5.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestMarshal::C5 -**Inherits:** Object - - - - - -#Instance Methods -## initialize(x) [](#method-i-initialize) - -**@return** [C5] a new instance of C5 - -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(foo) [](#method-i-marshal_load) - diff --git a/example/ruby/TestMarshal/C6.md b/example/ruby/TestMarshal/C6.md deleted file mode 100644 index 8fcf098..0000000 --- a/example/ruby/TestMarshal/C6.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestMarshal::C6 -**Inherits:** Object - - - - -# Attributes -## stdin[RW] [](#attribute-i-stdin) -Returns the value of attribute stdin. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [C6] a new instance of C6 - -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(x) [](#method-i-marshal_load) - diff --git a/example/ruby/TestMarshal/DumpTest.md b/example/ruby/TestMarshal/DumpTest.md deleted file mode 100644 index 70cb2e2..0000000 --- a/example/ruby/TestMarshal/DumpTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMarshal::DumpTest -**Inherits:** Object - - - - - -#Instance Methods -## dump_each(&block) [](#method-i-dump_each) - -## marshal_dump() [](#method-i-marshal_dump) - diff --git a/example/ruby/TestMarshal/FrozenData.md b/example/ruby/TestMarshal/FrozenData.md deleted file mode 100644 index d4eac19..0000000 --- a/example/ruby/TestMarshal/FrozenData.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestMarshal::FrozenData -**Inherits:** TestMarshal::LoadData - - - - - -#Instance Methods -## marshal_load(data) [](#method-i-marshal_load) - diff --git a/example/ruby/TestMarshal/LoadData.md b/example/ruby/TestMarshal/LoadData.md deleted file mode 100644 index 7100c71..0000000 --- a/example/ruby/TestMarshal/LoadData.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestMarshal::LoadData -**Inherits:** Object - - - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## initialize(data) [](#method-i-initialize) - -**@return** [LoadData] a new instance of LoadData - diff --git a/example/ruby/TestMarshal/LoadTest.md b/example/ruby/TestMarshal/LoadTest.md deleted file mode 100644 index f3ab6d7..0000000 --- a/example/ruby/TestMarshal/LoadTest.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestMarshal::LoadTest -**Inherits:** Object - - - - -# Class Methods -## load_each(m , &block ) [](#method-c-load_each) - -#Instance Methods -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(obj) [](#method-i-marshal_load) - diff --git a/example/ruby/TestMarshal/MethodMissingWithoutRespondTo.md b/example/ruby/TestMarshal/MethodMissingWithoutRespondTo.md deleted file mode 100644 index 6ee673f..0000000 --- a/example/ruby/TestMarshal/MethodMissingWithoutRespondTo.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestMarshal::MethodMissingWithoutRespondTo -**Inherits:** Struct - - - - -# Attributes -## wrapped_object[RW] [](#attribute-i-wrapped_object) -Returns the value of attribute wrapped_object - -**@return** [Object] the current value of wrapped_object - - -#Instance Methods -## method_missing(*args, &block) [](#method-i-method_missing) - -## respond_to_missing?(name, privatefalse) [](#method-i-respond_to_missing?) - -**@return** [Boolean] - diff --git a/example/ruby/TestMarshal/TestClass.md b/example/ruby/TestMarshal/TestClass.md deleted file mode 100644 index d8f5ed0..0000000 --- a/example/ruby/TestMarshal/TestClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestMarshal::TestClass -**Inherits:** Object - - - - - diff --git a/example/ruby/TestMarshal/TestForRespondToFalse.md b/example/ruby/TestMarshal/TestForRespondToFalse.md deleted file mode 100644 index e8373fb..0000000 --- a/example/ruby/TestMarshal/TestForRespondToFalse.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMarshal::TestForRespondToFalse -**Inherits:** Object - - - - - -#Instance Methods -## respond_to?(a, privfalse) [](#method-i-respond_to?) - -**@return** [Boolean] - diff --git a/example/ruby/TestMarshal/TestMarshalFreeze.md b/example/ruby/TestMarshal/TestMarshalFreeze.md deleted file mode 100644 index 79c0776..0000000 --- a/example/ruby/TestMarshal/TestMarshalFreeze.md +++ /dev/null @@ -1,130 +0,0 @@ -# Class: TestMarshal::TestMarshalFreeze -**Inherits:** Test::Unit::TestCase - -**Includes:** MarshalTestLib - - - - - -#Instance Methods -## decode(s) [](#method-i-decode) - -## encode(o) [](#method-i-encode) - -## marshal_equal(o1, msgnil) [](#method-i-marshal_equal) - -## marshal_equal_with_ancestry(o1, msgnil) [](#method-i-marshal_equal_with_ancestry) - -## marshaltest(o1) [](#method-i-marshaltest) - -## test_anonymous() [](#method-i-test_anonymous) - -## test_array() [](#method-i-test_array) - -## test_array_ivar() [](#method-i-test_array_ivar) - -## test_array_subclass() [](#method-i-test_array_subclass) - -## test_bignum() [](#method-i-test_bignum) - -## test_exception() [](#method-i-test_exception) - -## test_exception_subclass() [](#method-i-test_exception_subclass) - -## test_extend() [](#method-i-test_extend) - -## test_extend_string() [](#method-i-test_extend_string) - -## test_false() [](#method-i-test_false) - -## test_fixnum() [](#method-i-test_fixnum) - -## test_float() [](#method-i-test_float) - -## test_float_inf_nan() [](#method-i-test_float_inf_nan) - -## test_hash() [](#method-i-test_hash) - -## test_hash_default() [](#method-i-test_hash_default) - -## test_hash_default_proc() [](#method-i-test_hash_default_proc) - -## test_hash_extend() [](#method-i-test_hash_extend) - -## test_hash_ivar() [](#method-i-test_hash_ivar) - -## test_hash_subclass() [](#method-i-test_hash_subclass) - -## test_hash_subclass_extend() [](#method-i-test_hash_subclass_extend) - -## test_modules_and_classes_are_not_frozen() [](#method-i-test_modules_and_classes_are_not_frozen) - -## test_nil() [](#method-i-test_nil) - -## test_object() [](#method-i-test_object) - -## test_object_extend() [](#method-i-test_object_extend) - -## test_object_prepend() [](#method-i-test_object_prepend) - -## test_object_subclass() [](#method-i-test_object_subclass) - -## test_object_subclass_extend() [](#method-i-test_object_subclass_extend) - -## test_proc_returned_object_are_not_frozen() [](#method-i-test_proc_returned_object_are_not_frozen) - -## test_range() [](#method-i-test_range) - -## test_range_cyclic() [](#method-i-test_range_cyclic) - -## test_range_subclass() [](#method-i-test_range_subclass) - -## test_regexp() [](#method-i-test_regexp) - -## test_regexp_subclass() [](#method-i-test_regexp_subclass) - -## test_return_objects_are_frozen() [](#method-i-test_return_objects_are_frozen) - -## test_share() [](#method-i-test_share) - -## test_singleton() [](#method-i-test_singleton) - -## test_string() [](#method-i-test_string) - -## test_string_crlf() [](#method-i-test_string_crlf) - -## test_string_empty() [](#method-i-test_string_empty) - -## test_string_escape() [](#method-i-test_string_escape) - -## test_string_ivar() [](#method-i-test_string_ivar) - -## test_string_subclass() [](#method-i-test_string_subclass) - -## test_string_subclass_cycle() [](#method-i-test_string_subclass_cycle) - -## test_string_subclass_extend() [](#method-i-test_string_subclass_extend) - -## test_struct() [](#method-i-test_struct) - -## test_struct_ivar() [](#method-i-test_struct_ivar) - -## test_struct_subclass() [](#method-i-test_struct_subclass) - -## test_struct_subclass_extend() [](#method-i-test_struct_subclass_extend) - -## test_struct_toplevel() [](#method-i-test_struct_toplevel) - -## test_symbol() [](#method-i-test_symbol) - -## test_time() [](#method-i-test_time) - -## test_time_in_array() [](#method-i-test_time_in_array) - -## test_time_ivar() [](#method-i-test_time_ivar) - -## test_time_subclass() [](#method-i-test_time_subclass) - -## test_true() [](#method-i-test_true) - diff --git a/example/ruby/TestMarshal/TestMarshalFreezeProc.md b/example/ruby/TestMarshal/TestMarshalFreezeProc.md deleted file mode 100644 index 3726a2d..0000000 --- a/example/ruby/TestMarshal/TestMarshalFreezeProc.md +++ /dev/null @@ -1,124 +0,0 @@ -# Class: TestMarshal::TestMarshalFreezeProc -**Inherits:** Test::Unit::TestCase - -**Includes:** MarshalTestLib - - - - - -#Instance Methods -## decode(s) [](#method-i-decode) - -## encode(o) [](#method-i-encode) - -## marshal_equal(o1, msgnil) [](#method-i-marshal_equal) - -## marshal_equal_with_ancestry(o1, msgnil) [](#method-i-marshal_equal_with_ancestry) - -## marshaltest(o1) [](#method-i-marshaltest) - -## test_anonymous() [](#method-i-test_anonymous) - -## test_array() [](#method-i-test_array) - -## test_array_ivar() [](#method-i-test_array_ivar) - -## test_array_subclass() [](#method-i-test_array_subclass) - -## test_bignum() [](#method-i-test_bignum) - -## test_exception() [](#method-i-test_exception) - -## test_exception_subclass() [](#method-i-test_exception_subclass) - -## test_extend() [](#method-i-test_extend) - -## test_extend_string() [](#method-i-test_extend_string) - -## test_false() [](#method-i-test_false) - -## test_fixnum() [](#method-i-test_fixnum) - -## test_float() [](#method-i-test_float) - -## test_float_inf_nan() [](#method-i-test_float_inf_nan) - -## test_hash() [](#method-i-test_hash) - -## test_hash_default() [](#method-i-test_hash_default) - -## test_hash_default_proc() [](#method-i-test_hash_default_proc) - -## test_hash_extend() [](#method-i-test_hash_extend) - -## test_hash_ivar() [](#method-i-test_hash_ivar) - -## test_hash_subclass() [](#method-i-test_hash_subclass) - -## test_hash_subclass_extend() [](#method-i-test_hash_subclass_extend) - -## test_nil() [](#method-i-test_nil) - -## test_object() [](#method-i-test_object) - -## test_object_extend() [](#method-i-test_object_extend) - -## test_object_prepend() [](#method-i-test_object_prepend) - -## test_object_subclass() [](#method-i-test_object_subclass) - -## test_object_subclass_extend() [](#method-i-test_object_subclass_extend) - -## test_range() [](#method-i-test_range) - -## test_range_cyclic() [](#method-i-test_range_cyclic) - -## test_range_subclass() [](#method-i-test_range_subclass) - -## test_regexp() [](#method-i-test_regexp) - -## test_regexp_subclass() [](#method-i-test_regexp_subclass) - -## test_share() [](#method-i-test_share) - -## test_singleton() [](#method-i-test_singleton) - -## test_string() [](#method-i-test_string) - -## test_string_crlf() [](#method-i-test_string_crlf) - -## test_string_empty() [](#method-i-test_string_empty) - -## test_string_escape() [](#method-i-test_string_escape) - -## test_string_ivar() [](#method-i-test_string_ivar) - -## test_string_subclass() [](#method-i-test_string_subclass) - -## test_string_subclass_cycle() [](#method-i-test_string_subclass_cycle) - -## test_string_subclass_extend() [](#method-i-test_string_subclass_extend) - -## test_struct() [](#method-i-test_struct) - -## test_struct_ivar() [](#method-i-test_struct_ivar) - -## test_struct_subclass() [](#method-i-test_struct_subclass) - -## test_struct_subclass_extend() [](#method-i-test_struct_subclass_extend) - -## test_struct_toplevel() [](#method-i-test_struct_toplevel) - -## test_symbol() [](#method-i-test_symbol) - -## test_time() [](#method-i-test_time) - -## test_time_in_array() [](#method-i-test_time_in_array) - -## test_time_ivar() [](#method-i-test_time_ivar) - -## test_time_subclass() [](#method-i-test_time_subclass) - -## test_true() [](#method-i-test_true) - diff --git a/example/ruby/TestMarshal/TestModule.md b/example/ruby/TestMarshal/TestModule.md deleted file mode 100644 index 48b3196..0000000 --- a/example/ruby/TestMarshal/TestModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestMarshal::TestModule - - - - - diff --git a/example/ruby/TestMath.md b/example/ruby/TestMath.md deleted file mode 100644 index 2d4d39d..0000000 --- a/example/ruby/TestMath.md +++ /dev/null @@ -1,80 +0,0 @@ -# Class: TestMath -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_float(a, b) [](#method-i-assert_float) - -## assert_float_and_int(exp_ary, act_ary) [](#method-i-assert_float_and_int) - -## assert_infinity(a, *rest) [](#method-i-assert_infinity) - -## assert_nan(a, *rest) [](#method-i-assert_nan) - -## test_acos() [](#method-i-test_acos) - -## test_acosh() [](#method-i-test_acosh) - -## test_asin() [](#method-i-test_asin) - -## test_asinh() [](#method-i-test_asinh) - -## test_atan() [](#method-i-test_atan) - -## test_atan2() [](#method-i-test_atan2) - -## test_atanh() [](#method-i-test_atanh) - -## test_bignum_to_f() [](#method-i-test_bignum_to_f) - -## test_cbrt() [](#method-i-test_cbrt) - -## test_cos() [](#method-i-test_cos) - -## test_cosh() [](#method-i-test_cosh) - -## test_erf() [](#method-i-test_erf) - -## test_erfc() [](#method-i-test_erfc) - -## test_exp() [](#method-i-test_exp) - -## test_fixnum_to_f() [](#method-i-test_fixnum_to_f) - -## test_frexp() [](#method-i-test_frexp) - -## test_gamma() [](#method-i-test_gamma) - -## test_hypot() [](#method-i-test_hypot) - -## test_ldexp() [](#method-i-test_ldexp) - -## test_lgamma() [](#method-i-test_lgamma) - -## test_log() [](#method-i-test_log) - -## test_log10() [](#method-i-test_log10) - -## test_log2() [](#method-i-test_log2) - -## test_override_bignum_to_f() [](#method-i-test_override_bignum_to_f) - -## test_override_integer_to_f() [](#method-i-test_override_integer_to_f) - -## test_override_rational_to_f() [](#method-i-test_override_rational_to_f) - -## test_rational_to_f() [](#method-i-test_rational_to_f) - -## test_sin() [](#method-i-test_sin) - -## test_sinh() [](#method-i-test_sinh) - -## test_sqrt() [](#method-i-test_sqrt) - -## test_tan() [](#method-i-test_tan) - -## test_tanh() [](#method-i-test_tanh) - diff --git a/example/ruby/TestMemoryView.md b/example/ruby/TestMemoryView.md deleted file mode 100644 index bc4ba3d..0000000 --- a/example/ruby/TestMemoryView.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: TestMemoryView -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## alignment_padding(total_size, alignment) [](#method-i-alignment_padding) - -## sizeof(type) [](#method-i-sizeof) - -## test_ractor() [](#method-i-test_ractor) - -## test_rb_memory_view_available_p() [](#method-i-test_rb_memory_view_available_p) - -## test_rb_memory_view_extract_item_members() [](#method-i-test_rb_memory_view_extract_item_members) - -## test_rb_memory_view_extract_item_members_doble() [](#method-i-test_rb_memory_view_extract_item_members_doble) - -## test_rb_memory_view_extract_item_members_doble_endianness() [](#method-i-test_rb_memory_view_extract_item_members_doble_endianness) - -## test_rb_memory_view_extract_item_members_endianness() [](#method-i-test_rb_memory_view_extract_item_members_endianness) - -## test_rb_memory_view_extract_item_members_float() [](#method-i-test_rb_memory_view_extract_item_members_float) - -## test_rb_memory_view_extract_item_members_float_endianness() [](#method-i-test_rb_memory_view_extract_item_members_float_endianness) - -## test_rb_memory_view_fill_contiguous_strides() [](#method-i-test_rb_memory_view_fill_contiguous_strides) - -## test_rb_memory_view_get_item_pointer_multiple_members() [](#method-i-test_rb_memory_view_get_item_pointer_multiple_members) - -## test_rb_memory_view_get_item_pointer_single_member() [](#method-i-test_rb_memory_view_get_item_pointer_single_member) - -## test_rb_memory_view_get_with_memory_view_unavailable_object() [](#method-i-test_rb_memory_view_get_with_memory_view_unavailable_object) - -## test_rb_memory_view_init_as_byte_array() [](#method-i-test_rb_memory_view_init_as_byte_array) - -## test_rb_memory_view_item_size_from_format() [](#method-i-test_rb_memory_view_item_size_from_format) - -## test_rb_memory_view_item_size_from_format_composed() [](#method-i-test_rb_memory_view_item_size_from_format_composed) - -## test_rb_memory_view_item_size_from_format_error() [](#method-i-test_rb_memory_view_item_size_from_format_error) - -## test_rb_memory_view_item_size_from_format_with_spaces() [](#method-i-test_rb_memory_view_item_size_from_format_with_spaces) - -## test_rb_memory_view_parse_item_format() [](#method-i-test_rb_memory_view_parse_item_format) - -## test_rb_memory_view_parse_item_format_with_alignment_compound() [](#method-i-test_rb_memory_view_parse_item_format_with_alignment_compound) - -## test_rb_memory_view_parse_item_format_with_alignment_signle() [](#method-i-test_rb_memory_view_parse_item_format_with_alignment_signle) - -## test_rb_memory_view_parse_item_format_with_alignment_total_size_with_tail_padding() [](#method-i-test_rb_memory_view_parse_item_format_with_alignment_total_size_with_tail_padding) - -## test_rb_memory_view_register_duplicated() [](#method-i-test_rb_memory_view_register_duplicated) - -## test_rb_memory_view_register_nonclass() [](#method-i-test_rb_memory_view_register_nonclass) - -## test_ref_count_with_exported_object() [](#method-i-test_ref_count_with_exported_object) - diff --git a/example/ruby/TestMetaclass.md b/example/ruby/TestMetaclass.md deleted file mode 100644 index 1320d75..0000000 --- a/example/ruby/TestMetaclass.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestMetaclass -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_metaclass() [](#method-i-test_metaclass) - diff --git a/example/ruby/TestMetaclass/Bar.md b/example/ruby/TestMetaclass/Bar.md deleted file mode 100644 index 6ec7cff..0000000 --- a/example/ruby/TestMetaclass/Bar.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestMetaclass::Bar -**Inherits:** TestMetaclass::Foo - - - - - diff --git a/example/ruby/TestMetaclass/Baz.md b/example/ruby/TestMetaclass/Baz.md deleted file mode 100644 index 021906a..0000000 --- a/example/ruby/TestMetaclass/Baz.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestMetaclass::Baz -**Inherits:** Object - - - - - diff --git a/example/ruby/TestMetaclass/Foo.md b/example/ruby/TestMetaclass/Foo.md deleted file mode 100644 index 1c600d9..0000000 --- a/example/ruby/TestMetaclass/Foo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestMetaclass::Foo -**Inherits:** Object - - - - - diff --git a/example/ruby/TestMethod.md b/example/ruby/TestMethod.md deleted file mode 100644 index 72dc653..0000000 --- a/example/ruby/TestMethod.md +++ /dev/null @@ -1,261 +0,0 @@ -# Class: TestMethod -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_curry_three_args(m) [](#method-i-assert_curry_three_args) - -## assert_curry_var_args(m) [](#method-i-assert_curry_var_args) - -## m0() [](#method-i-m0) - -## m1(a) [](#method-i-m1) - -## m2(a, b) [](#method-i-m2) - -## ma1(a, &b) [](#method-i-ma1) - -## method_equality_visbility_alias() [](#method-i-method_equality_visbility_alias) -Bug #18751 - -## mf() [](#method-i-mf) - -## mk1() [](#method-i-mk1) - -## mk2(**o) [](#method-i-mk2) - -## mk3(a, **o) [](#method-i-mk3) - -## mk4(anil, **o) [](#method-i-mk4) - -## mk5(a, bnil, **o) [](#method-i-mk5) - -## mk6(a, bnil, c, **o) [](#method-i-mk6) - -## mk7(a, bnil, *c, d, **o) [](#method-i-mk7) - -## mk8(a, bnil, *c, d, e:, f:nil, **o) [](#method-i-mk8) - -## mnk() [](#method-i-mnk) - -## mo1(anil, &b) [](#method-i-mo1) - -## mo2(a, bnil) [](#method-i-mo2) - -## mo3(*a) [](#method-i-mo3) - -## mo4(a, *b, &c) [](#method-i-mo4) - -## mo5(a, *b, c) [](#method-i-mo5) - -## mo6(a, *b, c, &d) [](#method-i-mo6) - -## mo7(a, bnil, *c, d, &e) [](#method-i-mo7) - -## mo8(a, bnil, d, &e) [](#method-i-mo8) - -## mv1() [](#method-i-mv1) - -## rest_parameter(*rest) [](#method-i-rest_parameter) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test___dir__() [](#method-i-test___dir__) - -## test_alias_owner() [](#method-i-test_alias_owner) - -## test_argument_error_location() [](#method-i-test_argument_error_location) - -## test_arity() [](#method-i-test_arity) - -## test_arity_special() [](#method-i-test_arity_special) - -## test_attrset_ivar() [](#method-i-test_attrset_ivar) - -## test_bind_module_instance_method() [](#method-i-test_bind_module_instance_method) - -## test_bmethod_bound_parameters() [](#method-i-test_bmethod_bound_parameters) - -## test_bmethod_unbound_parameters() [](#method-i-test_bmethod_unbound_parameters) - -## test_body() [](#method-i-test_body) - -## test_bound_method_entry() [](#method-i-test_bound_method_entry) - -## test_bound_parameters() [](#method-i-test_bound_parameters) - -## test_callee() [](#method-i-test_callee) - -## test_callee_top_level() [](#method-i-test_callee_top_level) - -## test_caller_negative_level() [](#method-i-test_caller_negative_level) - -## test_caller_top_level() [](#method-i-test_caller_top_level) - -## test_clone() [](#method-i-test_clone) - -## test_clone_under_gc_compact_stress() [](#method-i-test_clone_under_gc_compact_stress) - -## test_compose_with_callable() [](#method-i-test_compose_with_callable) - -## test_compose_with_method() [](#method-i-test_compose_with_method) - -## test_compose_with_noncallable() [](#method-i-test_compose_with_noncallable) - -## test_compose_with_proc() [](#method-i-test_compose_with_proc) - -## test_curry_from_proc() [](#method-i-test_curry_from_proc) - -## test_curry_from_proc_var_args() [](#method-i-test_curry_from_proc_var_args) - -## test_curry_method() [](#method-i-test_curry_method) - -## test_curry_var_args() [](#method-i-test_curry_var_args) - -## test_default_accessibility() [](#method-i-test_default_accessibility) - -## test_define_method() [](#method-i-test_define_method) - -## test_define_method_in_private_scope() [](#method-i-test_define_method_in_private_scope) - -## test_define_method_invalid_arg() [](#method-i-test_define_method_invalid_arg) - -## test_define_method_no_proc() [](#method-i-test_define_method_no_proc) - -## test_define_method_transplating() [](#method-i-test_define_method_transplating) - -## test_define_method_visibility() [](#method-i-test_define_method_visibility) - -## test_define_method_with_symbol() [](#method-i-test_define_method_with_symbol) - -## test_define_singleton_method() [](#method-i-test_define_singleton_method) - -## test_define_singleton_method_no_proc() [](#method-i-test_define_singleton_method_no_proc) - -## test_define_singleton_method_public() [](#method-i-test_define_singleton_method_public) - -## test_define_singleton_method_with_extended_method() [](#method-i-test_define_singleton_method_with_extended_method) - -## test_eq() [](#method-i-test_eq) - -## test_eqq() [](#method-i-test_eqq) - -## test_gced_bmethod() [](#method-i-test_gced_bmethod) - -## test_hash() [](#method-i-test_hash) - -## test_hash_does_not_change_after_compaction() [](#method-i-test_hash_does_not_change_after_compaction) - -## test_hidden_parameters() [](#method-i-test_hidden_parameters) - -## test_included() [](#method-i-test_included) - -## test_inspect() [](#method-i-test_inspect) - -## test_instance_method() [](#method-i-test_instance_method) - -## test_instance_methods_owner_consistency() [](#method-i-test_instance_methods_owner_consistency) -Bug 18435 - -## test_invalidating_CC_ASAN() [](#method-i-test_invalidating_CC_ASAN) - -## test_kwarg_eval_memory_leak() [](#method-i-test_kwarg_eval_memory_leak) - -## test_method_in_block_in_define_method_block() [](#method-i-test_method_in_block_in_define_method_block) - -## test_method_in_define_method_block() [](#method-i-test_method_in_define_method_block) - -## test_method_in_method_visibility_should_be_public() [](#method-i-test_method_in_method_visibility_should_be_public) - -## test_method_list() [](#method-i-test_method_list) - -## test_method_parameters_inspect() [](#method-i-test_method_parameters_inspect) - -## test_new() [](#method-i-test_new) - -## test_orphan_callee() [](#method-i-test_orphan_callee) - -## test_override_optimized_method_on_class_using_prepend() [](#method-i-test_override_optimized_method_on_class_using_prepend) - -## test_owner() [](#method-i-test_owner) - -## test_owner_missing() [](#method-i-test_owner_missing) - -## test_prepended() [](#method-i-test_prepended) - -## test_prepended_public_zsuper() [](#method-i-test_prepended_public_zsuper) - -## test_public_method_with_zsuper_method() [](#method-i-test_public_method_with_zsuper_method) - -## test_public_methods_with_extended() [](#method-i-test_public_methods_with_extended) - -## test_receiver_name_owner() [](#method-i-test_receiver_name_owner) - -## test_respond_to_missing_argument() [](#method-i-test_respond_to_missing_argument) - -## test_singleton_define_method_in_private_scope() [](#method-i-test_singleton_define_method_in_private_scope) - -## test_singleton_method() [](#method-i-test_singleton_method) - -## test_singleton_method_included_or_prepended_bug_20620() [](#method-i-test_singleton_method_included_or_prepended_bug_20620) - -## test_singleton_method_prepend() [](#method-i-test_singleton_method_prepend) - -## test_splat_long_array() [](#method-i-test_splat_long_array) - -## test_super_in_proc_from_define_method() [](#method-i-test_super_in_proc_from_define_method) - -## test_super_method() [](#method-i-test_super_method) - -## test_super_method_after_bind() [](#method-i-test_super_method_after_bind) - -## test_super_method_alias() [](#method-i-test_super_method_alias) - -## test_super_method_alias_to_prepended_module() [](#method-i-test_super_method_alias_to_prepended_module) - -## test_super_method_bind_unbind_clone() [](#method-i-test_super_method_bind_unbind_clone) - -## test_super_method_module() [](#method-i-test_super_method_module) - -## test_super_method_module_alias() [](#method-i-test_super_method_module_alias) -Bug 17780 - -## test_super_method_removed_public() [](#method-i-test_super_method_removed_public) - -## test_super_method_removed_regular() [](#method-i-test_super_method_removed_regular) - -## test_super_method_unbound() [](#method-i-test_super_method_unbound) - -## test_super_method_with_prepended_module() [](#method-i-test_super_method_with_prepended_module) - -## test_super_with_splat() [](#method-i-test_super_with_splat) - -## test_to_proc_binding() [](#method-i-test_to_proc_binding) - -## test_umethod_bind_call() [](#method-i-test_umethod_bind_call) - -## test_unbind() [](#method-i-test_unbind) - -## test_unbound_method_parameters_inspect() [](#method-i-test_unbound_method_parameters_inspect) - -## test_unbound_method_proc_coerce() [](#method-i-test_unbound_method_proc_coerce) - -## test_unbound_parameters() [](#method-i-test_unbound_parameters) - -## test_visibility() [](#method-i-test_visibility) - -## test_warn_unused_block() [](#method-i-test_warn_unused_block) - -## test_zsuper_method_redefined_bind_call() [](#method-i-test_zsuper_method_redefined_bind_call) - -## test_zsuper_method_removed() [](#method-i-test_zsuper_method_removed) - -## test_zsuper_method_removed_higher_method() [](#method-i-test_zsuper_method_removed_higher_method) - -## test_zsuper_private_override_instance_method() [](#method-i-test_zsuper_private_override_instance_method) - diff --git a/example/ruby/TestMethod/Base.md b/example/ruby/TestMethod/Base.md deleted file mode 100644 index 88588bc..0000000 --- a/example/ruby/TestMethod/Base.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestMethod::Base -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestMethod/C.md b/example/ruby/TestMethod/C.md deleted file mode 100644 index 0100b16..0000000 --- a/example/ruby/TestMethod/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestMethod::C -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestMethod/Derived.md b/example/ruby/TestMethod/Derived.md deleted file mode 100644 index 3a83a08..0000000 --- a/example/ruby/TestMethod/Derived.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestMethod::Derived -**Inherits:** TestMethod::Base - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestMethod/M.md b/example/ruby/TestMethod/M.md deleted file mode 100644 index 1ca1b29..0000000 --- a/example/ruby/TestMethod/M.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: TestMethod::M - - - - -# Class Methods -## func() [](#method-c-func) - -#Instance Methods -## meth() [](#method-i-meth) - diff --git a/example/ruby/TestMethod/T.md b/example/ruby/TestMethod/T.md deleted file mode 100644 index b4b6707..0000000 --- a/example/ruby/TestMethod/T.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestMethod::T -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [T] a new instance of T - -## initialize_clone() [](#method-i-initialize_clone) - -## initialize_copy() [](#method-i-initialize_copy) - -## initialize_dup() [](#method-i-initialize_dup) - -## normal_method() [](#method-i-normal_method) - -## respond_to_missing?() [](#method-i-respond_to_missing?) - -**@return** [Boolean] - diff --git a/example/ruby/TestMethod/Visibility.md b/example/ruby/TestMethod/Visibility.md deleted file mode 100644 index f7f92db..0000000 --- a/example/ruby/TestMethod/Visibility.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestMethod::Visibility -**Inherits:** Object - - - - - -#Instance Methods -## mv1() [](#method-i-mv1) - diff --git a/example/ruby/TestMethodCache.md b/example/ruby/TestMethodCache.md deleted file mode 100644 index 96f1837..0000000 --- a/example/ruby/TestMethodCache.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestMethodCache -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_negative_cache_with_and_without_subclasses() [](#method-i-test_negative_cache_with_and_without_subclasses) - -## test_undef() [](#method-i-test_undef) - -## test_undef_with_subclasses() [](#method-i-test_undef_with_subclasses) - -## test_undef_with_subclasses_complicated() [](#method-i-test_undef_with_subclasses_complicated) - diff --git a/example/ruby/TestMethodInlineCache.md b/example/ruby/TestMethodInlineCache.md deleted file mode 100644 index 1bf281e..0000000 --- a/example/ruby/TestMethodInlineCache.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestMethodInlineCache -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_alias() [](#method-i-test_alias) - -## test_module_methods_redefiniton() [](#method-i-test_module_methods_redefiniton) - -## test_zsuper() [](#method-i-test_zsuper) - diff --git a/example/ruby/TestMiniTestGuard.md b/example/ruby/TestMiniTestGuard.md deleted file mode 100644 index f16cff4..0000000 --- a/example/ruby/TestMiniTestGuard.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestMiniTestGuard -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_jruby_eh() [](#method-i-test_jruby_eh) - -## test_mri_eh() [](#method-i-test_mri_eh) - -## test_windows_eh() [](#method-i-test_windows_eh) - diff --git a/example/ruby/TestMiniTestRunner.md b/example/ruby/TestMiniTestRunner.md deleted file mode 100644 index 5adb543..0000000 --- a/example/ruby/TestMiniTestRunner.md +++ /dev/null @@ -1,15 +0,0 @@ -# Class: TestMiniTestRunner -**Inherits:** MetaMetaMetaTestCase - - - - - -#Instance Methods -## assert_filtering(name, expected, afalse) [](#method-i-assert_filtering) - -## test_class_test_suites() [](#method-i-test_class_test_suites) -do not parallelize this suite... it just can't handle it. - -## test_run_with_other_runner() [](#method-i-test_run_with_other_runner) - diff --git a/example/ruby/TestMiniTestRunner/Latch.md b/example/ruby/TestMiniTestRunner/Latch.md deleted file mode 100644 index 5132920..0000000 --- a/example/ruby/TestMiniTestRunner/Latch.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestMiniTestRunner::Latch -**Inherits:** Object - - - - - -#Instance Methods -## await() [](#method-i-await) - -## initialize(count1) [](#method-i-initialize) - -**@return** [Latch] a new instance of Latch - -## release() [](#method-i-release) - diff --git a/example/ruby/TestMiniTestUnit.md b/example/ruby/TestMiniTestUnit.md deleted file mode 100644 index 623951f..0000000 --- a/example/ruby/TestMiniTestUnit.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestMiniTestUnit -**Inherits:** MetaMetaMetaTestCase - - - - - -#Instance Methods -## test_class_puke_with_assertion_failed() [](#method-i-test_class_puke_with_assertion_failed) - -## test_class_puke_with_assertion_failed_and_long_backtrace() [](#method-i-test_class_puke_with_assertion_failed_and_long_backtrace) - -## test_class_puke_with_assertion_failed_and_user_defined_assertions() [](#method-i-test_class_puke_with_assertion_failed_and_user_defined_assertions) - -## test_class_puke_with_failure_and_flunk_in_backtrace() [](#method-i-test_class_puke_with_failure_and_flunk_in_backtrace) - -## test_class_puke_with_flunk_and_user_defined_assertions() [](#method-i-test_class_puke_with_flunk_and_user_defined_assertions) - -## test_class_puke_with_non_failure_exception() [](#method-i-test_class_puke_with_non_failure_exception) - -## test_default_runner_is_minitest_unit() [](#method-i-test_default_runner_is_minitest_unit) - -## test_filter_backtrace() [](#method-i-test_filter_backtrace) - -## test_filter_backtrace_all_unit() [](#method-i-test_filter_backtrace_all_unit) - -## test_filter_backtrace_unit_starts() [](#method-i-test_filter_backtrace_unit_starts) - -## test_passed_eh_teardown_flunked() [](#method-i-test_passed_eh_teardown_flunked) - -## test_passed_eh_teardown_good() [](#method-i-test_passed_eh_teardown_good) - -## test_passed_eh_teardown_skipped() [](#method-i-test_passed_eh_teardown_skipped) - -## util_expand_bt(bt) [](#method-i-util_expand_bt) - diff --git a/example/ruby/TestMiniTestUnitInherited.md b/example/ruby/TestMiniTestUnitInherited.md deleted file mode 100644 index 68a5523..0000000 --- a/example/ruby/TestMiniTestUnitInherited.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMiniTestUnitInherited -**Inherits:** MetaMetaMetaTestCase - - - - - -#Instance Methods -## test_inherited_hook_plays_nice_with_others() [](#method-i-test_inherited_hook_plays_nice_with_others) - -## with_overridden_include() [](#method-i-with_overridden_include) - diff --git a/example/ruby/TestMiniTestUnitOrder.md b/example/ruby/TestMiniTestUnitOrder.md deleted file mode 100644 index 3509c21..0000000 --- a/example/ruby/TestMiniTestUnitOrder.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: TestMiniTestUnitOrder -**Inherits:** MetaMetaMetaTestCase - - - - - -#Instance Methods -## test_after_teardown() [](#method-i-test_after_teardown) - -## test_all_teardowns_are_guaranteed_to_run() [](#method-i-test_all_teardowns_are_guaranteed_to_run) - -## test_before_setup() [](#method-i-test_before_setup) -do not parallelize this suite... it just can't handle it. - -## test_setup_and_teardown_survive_inheritance() [](#method-i-test_setup_and_teardown_survive_inheritance) - diff --git a/example/ruby/TestMiniTestUnitRecording.md b/example/ruby/TestMiniTestUnitRecording.md deleted file mode 100644 index ebb0c23..0000000 --- a/example/ruby/TestMiniTestUnitRecording.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestMiniTestUnitRecording -**Inherits:** MetaMetaMetaTestCase - - - - -# Class Methods -## record(suite , method , assertions , time , error ) [](#method-c-record) -## recording() [](#method-c-recording) - -#Instance Methods -## assert_run_record(*expected, &block) [](#method-i-assert_run_record) -do not parallelize this suite... it just can't handle it. - -## test_record_error() [](#method-i-test_record_error) - -## test_record_error_in_test_and_teardown() [](#method-i-test_record_error_in_test_and_teardown) - -## test_record_error_teardown() [](#method-i-test_record_error_teardown) - -## test_record_failing() [](#method-i-test_record_failing) - -## test_record_passing() [](#method-i-test_record_passing) - -## test_record_skip() [](#method-i-test_record_skip) - diff --git a/example/ruby/TestMiniTestUnitTestCase.md b/example/ruby/TestMiniTestUnitTestCase.md deleted file mode 100644 index 77238ef..0000000 --- a/example/ruby/TestMiniTestUnitTestCase.md +++ /dev/null @@ -1,253 +0,0 @@ -# Class: TestMiniTestUnitTestCase -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_triggered(expected, klassTest::Unit::AssertionFailedError) [](#method-i-assert_triggered) - -## non_verbose() [](#method-i-non_verbose) - -## setup() [](#method-i-setup) -do not call parallelize_me! - teardown accesses @tc._assertions which is not -threadsafe. Nearly every method in here is an assertion test so it isn't worth -splitting it out further. - -## teardown() [](#method-i-teardown) - -## test_assert() [](#method-i-test_assert) - -## test_assert__triggered() [](#method-i-test_assert__triggered) - -## test_assert__triggered_message() [](#method-i-test_assert__triggered_message) - -## test_assert_empty() [](#method-i-test_assert_empty) - -## test_assert_empty_triggered() [](#method-i-test_assert_empty_triggered) - -## test_assert_equal() [](#method-i-test_assert_equal) - -## test_assert_equal_different_collection_array_hex_invisible() [](#method-i-test_assert_equal_different_collection_array_hex_invisible) - -## test_assert_equal_different_collection_hash_hex_invisible() [](#method-i-test_assert_equal_different_collection_hash_hex_invisible) - -## test_assert_equal_different_diff_deactivated() [](#method-i-test_assert_equal_different_diff_deactivated) - -## test_assert_equal_different_escaped_newline() [](#method-i-test_assert_equal_different_escaped_newline) - -## test_assert_equal_different_hex() [](#method-i-test_assert_equal_different_hex) - -## test_assert_equal_different_hex_invisible() [](#method-i-test_assert_equal_different_hex_invisible) - -## test_assert_equal_different_long() [](#method-i-test_assert_equal_different_long) - -## test_assert_equal_different_long_invisible() [](#method-i-test_assert_equal_different_long_invisible) - -## test_assert_equal_different_long_msg() [](#method-i-test_assert_equal_different_long_msg) - -## test_assert_equal_different_short() [](#method-i-test_assert_equal_different_short) - -## test_assert_equal_different_short_msg() [](#method-i-test_assert_equal_different_short_msg) - -## test_assert_equal_different_short_multiline() [](#method-i-test_assert_equal_different_short_multiline) - -## test_assert_in_delta() [](#method-i-test_assert_in_delta) - -## test_assert_in_delta_triggered() [](#method-i-test_assert_in_delta_triggered) - -## test_assert_in_epsilon() [](#method-i-test_assert_in_epsilon) - -## test_assert_in_epsilon_triggered() [](#method-i-test_assert_in_epsilon_triggered) - -## test_assert_in_epsilon_triggered_negative_case() [](#method-i-test_assert_in_epsilon_triggered_negative_case) - -## test_assert_includes() [](#method-i-test_assert_includes) - -## test_assert_includes_triggered() [](#method-i-test_assert_includes_triggered) - -## test_assert_instance_of() [](#method-i-test_assert_instance_of) - -## test_assert_instance_of_triggered() [](#method-i-test_assert_instance_of_triggered) - -## test_assert_kind_of() [](#method-i-test_assert_kind_of) - -## test_assert_kind_of_triggered() [](#method-i-test_assert_kind_of_triggered) - -## test_assert_match() [](#method-i-test_assert_match) - -## test_assert_match_matchee_to_str() [](#method-i-test_assert_match_matchee_to_str) - -## test_assert_match_matcher_object() [](#method-i-test_assert_match_matcher_object) - -## test_assert_match_object_triggered() [](#method-i-test_assert_match_object_triggered) - -## test_assert_match_triggered() [](#method-i-test_assert_match_triggered) - -## test_assert_nil() [](#method-i-test_assert_nil) - -## test_assert_nil_triggered() [](#method-i-test_assert_nil_triggered) - -## test_assert_operator() [](#method-i-test_assert_operator) - -## test_assert_operator_bad_object() [](#method-i-test_assert_operator_bad_object) - -## test_assert_operator_triggered() [](#method-i-test_assert_operator_triggered) - -## test_assert_output_both() [](#method-i-test_assert_output_both) - -## test_assert_output_both_regexps() [](#method-i-test_assert_output_both_regexps) - -## test_assert_output_err() [](#method-i-test_assert_output_err) - -## test_assert_output_neither() [](#method-i-test_assert_output_neither) - -## test_assert_output_out() [](#method-i-test_assert_output_out) - -## test_assert_output_triggered_both() [](#method-i-test_assert_output_triggered_both) - -## test_assert_output_triggered_err() [](#method-i-test_assert_output_triggered_err) - -## test_assert_output_triggered_out() [](#method-i-test_assert_output_triggered_out) - -## test_assert_predicate() [](#method-i-test_assert_predicate) - -## test_assert_predicate_triggered() [](#method-i-test_assert_predicate_triggered) - -## test_assert_raise() [](#method-i-test_assert_raise) - -## test_assert_raise_module() [](#method-i-test_assert_raise_module) - -## test_assert_raise_skip() [](#method-i-test_assert_raise_skip) -**sigh** This is quite an odd scenario, but it is from real (albeit ugly) test -code in ruby-core: - -https://github.com/ruby/ruby/commit/6bab4ea9917dc05cd2c94aead2e96eb7df7d4be1 - -## test_assert_raise_triggered_different() [](#method-i-test_assert_raise_triggered_different) - -## test_assert_raise_triggered_different_msg() [](#method-i-test_assert_raise_triggered_different_msg) - -## test_assert_raise_triggered_none() [](#method-i-test_assert_raise_triggered_none) - -## test_assert_raise_triggered_none_msg() [](#method-i-test_assert_raise_triggered_none_msg) - -## test_assert_raise_triggered_subclass() [](#method-i-test_assert_raise_triggered_subclass) - -## test_assert_respond_to() [](#method-i-test_assert_respond_to) - -## test_assert_respond_to_triggered() [](#method-i-test_assert_respond_to_triggered) - -## test_assert_same() [](#method-i-test_assert_same) - -## test_assert_same_triggered() [](#method-i-test_assert_same_triggered) - -## test_assert_send() [](#method-i-test_assert_send) - -## test_assert_send_bad() [](#method-i-test_assert_send_bad) - -## test_assert_silent() [](#method-i-test_assert_silent) - -## test_assert_silent_triggered_err() [](#method-i-test_assert_silent_triggered_err) - -## test_assert_silent_triggered_out() [](#method-i-test_assert_silent_triggered_out) - -## test_assert_throws() [](#method-i-test_assert_throws) - -## test_assert_throws_different() [](#method-i-test_assert_throws_different) - -## test_assert_throws_unthrown() [](#method-i-test_assert_throws_unthrown) - -## test_capture_output() [](#method-i-test_capture_output) - -## test_delta_consistency() [](#method-i-test_delta_consistency) - -## test_epsilon_consistency() [](#method-i-test_epsilon_consistency) - -## test_flunk() [](#method-i-test_flunk) - -## test_flunk_message() [](#method-i-test_flunk_message) - -## test_message() [](#method-i-test_message) - -## test_message_deferred() [](#method-i-test_message_deferred) - -## test_message_lambda() [](#method-i-test_message_lambda) - -## test_message_message() [](#method-i-test_message_message) - -## test_omit() [](#method-i-test_omit) - -## test_pass() [](#method-i-test_pass) - -## test_pend() [](#method-i-test_pend) - -## test_prints() [](#method-i-test_prints) - -## test_refute() [](#method-i-test_refute) - -## test_refute_empty() [](#method-i-test_refute_empty) - -## test_refute_empty_triggered() [](#method-i-test_refute_empty_triggered) - -## test_refute_equal() [](#method-i-test_refute_equal) - -## test_refute_equal_triggered() [](#method-i-test_refute_equal_triggered) - -## test_refute_in_delta() [](#method-i-test_refute_in_delta) - -## test_refute_in_delta_triggered() [](#method-i-test_refute_in_delta_triggered) - -## test_refute_in_epsilon() [](#method-i-test_refute_in_epsilon) - -## test_refute_in_epsilon_triggered() [](#method-i-test_refute_in_epsilon_triggered) - -## test_refute_includes() [](#method-i-test_refute_includes) - -## test_refute_includes_triggered() [](#method-i-test_refute_includes_triggered) - -## test_refute_instance_of() [](#method-i-test_refute_instance_of) - -## test_refute_instance_of_triggered() [](#method-i-test_refute_instance_of_triggered) - -## test_refute_kind_of() [](#method-i-test_refute_kind_of) - -## test_refute_kind_of_triggered() [](#method-i-test_refute_kind_of_triggered) - -## test_refute_match() [](#method-i-test_refute_match) - -## test_refute_match_matcher_object() [](#method-i-test_refute_match_matcher_object) - -## test_refute_match_object_triggered() [](#method-i-test_refute_match_object_triggered) - -## test_refute_match_triggered() [](#method-i-test_refute_match_triggered) - -## test_refute_nil() [](#method-i-test_refute_nil) - -## test_refute_nil_triggered() [](#method-i-test_refute_nil_triggered) - -## test_refute_operator() [](#method-i-test_refute_operator) - -## test_refute_operator_bad_object() [](#method-i-test_refute_operator_bad_object) - -## test_refute_operator_triggered() [](#method-i-test_refute_operator_triggered) - -## test_refute_predicate() [](#method-i-test_refute_predicate) - -## test_refute_predicate_triggered() [](#method-i-test_refute_predicate_triggered) - -## test_refute_respond_to() [](#method-i-test_refute_respond_to) - -## test_refute_respond_to_triggered() [](#method-i-test_refute_respond_to_triggered) - -## test_refute_same() [](#method-i-test_refute_same) - -## test_refute_same_triggered() [](#method-i-test_refute_same_triggered) - -## test_test_methods() [](#method-i-test_test_methods) - -## util_msg(exp, act, msgnil) [](#method-i-util_msg) - -## without_diff() [](#method-i-without_diff) - diff --git a/example/ruby/TestMixedUnicodeEscape.md b/example/ruby/TestMixedUnicodeEscape.md deleted file mode 100644 index 491cbcc..0000000 --- a/example/ruby/TestMixedUnicodeEscape.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestMixedUnicodeEscape -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_basic() [](#method-i-test_basic) - diff --git a/example/ruby/TestMkmf.md b/example/ruby/TestMkmf.md deleted file mode 100644 index b1c32aa..0000000 --- a/example/ruby/TestMkmf.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestMkmf -**Inherits:** Test::Unit::TestCase - -**Includes:** TestMkmf::Base - - - - - -#Instance Methods -## assert_separately(args, extra_args, src, *rest, **options) [](#method-i-assert_separately) - -## config_value(name) [](#method-i-config_value) - -## mkmf(*args, &block) [](#method-i-mkmf) - -## mkmflog(msg) [](#method-i-mkmflog) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/TestMkmf/Base.md b/example/ruby/TestMkmf/Base.md deleted file mode 100644 index 147014a..0000000 --- a/example/ruby/TestMkmf/Base.md +++ /dev/null @@ -1,21 +0,0 @@ -# Module: TestMkmf::Base - - - - -# Attributes -## stdout[RW] [](#attribute-i-stdout) -Returns the value of attribute stdout. - - -#Instance Methods -## config_value(name) [](#method-i-config_value) - -## mkmf(*args, &block) [](#method-i-mkmf) - -## mkmflog(msg) [](#method-i-mkmflog) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/TestMkmf/Base/Capture.md b/example/ruby/TestMkmf/Base/Capture.md deleted file mode 100644 index 3140ffc..0000000 --- a/example/ruby/TestMkmf/Base/Capture.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestMkmf::Base::Capture -**Inherits:** Object - - - - -# Attributes -## origin[RW] [](#attribute-i-origin) -Returns the value of attribute origin. - - -#Instance Methods -## clear() [](#method-i-clear) - -## filter(&block) [](#method-i-filter) - -## flush() [](#method-i-flush) - -## initialize() [](#method-i-initialize) - -**@return** [Capture] a new instance of Capture - -## reopen(io) [](#method-i-reopen) - -## write(*s) [](#method-i-write) - diff --git a/example/ruby/TestMkmfConfig.md b/example/ruby/TestMkmfConfig.md deleted file mode 100644 index 8a512df..0000000 --- a/example/ruby/TestMkmfConfig.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestMkmfConfig -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_dir_config() [](#method-i-test_dir_config) - -## test_with_config_with_arg_and_no_value() [](#method-i-test_with_config_with_arg_and_no_value) - -## test_with_config_with_arg_and_value() [](#method-i-test_with_config_with_arg_and_value) - -## test_with_config_without_arg() [](#method-i-test_with_config_without_arg) - -## test_with_target_rbconfig() [](#method-i-test_with_target_rbconfig) - diff --git a/example/ruby/TestMkmfConfiguration.md b/example/ruby/TestMkmfConfiguration.md deleted file mode 100644 index ab47a7a..0000000 --- a/example/ruby/TestMkmfConfiguration.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestMkmfConfiguration -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_verbose_with_arg() [](#method-i-test_verbose_with_arg) - -## test_verbose_with_rbconfig_verbose_disabled() [](#method-i-test_verbose_with_rbconfig_verbose_disabled) - -## test_verbose_with_rbconfig_verbose_enabled() [](#method-i-test_verbose_with_rbconfig_verbose_enabled) - diff --git a/example/ruby/TestMkmfConvertible.md b/example/ruby/TestMkmfConvertible.md deleted file mode 100644 index 81af434..0000000 --- a/example/ruby/TestMkmfConvertible.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMkmfConvertible -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_typeof_builtin() [](#method-i-test_typeof_builtin) - -## test_typeof_typedef() [](#method-i-test_typeof_typedef) - diff --git a/example/ruby/TestMkmfEgrepCpp.md b/example/ruby/TestMkmfEgrepCpp.md deleted file mode 100644 index 4af122d..0000000 --- a/example/ruby/TestMkmfEgrepCpp.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMkmfEgrepCpp -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_egrep_cpp() [](#method-i-test_egrep_cpp) - -## test_not_have_func() [](#method-i-test_not_have_func) - diff --git a/example/ruby/TestMkmfFindExecutable.md b/example/ruby/TestMkmfFindExecutable.md deleted file mode 100644 index 9d136a6..0000000 --- a/example/ruby/TestMkmfFindExecutable.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestMkmfFindExecutable -**Inherits:** TestMkmf - - - - - -#Instance Methods -## each_exts(&block) [](#method-i-each_exts) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_find_executable() [](#method-i-test_find_executable) - -## test_find_executable_dir() [](#method-i-test_find_executable_dir) - -## test_quoted_path_on_windows() [](#method-i-test_quoted_path_on_windows) - diff --git a/example/ruby/TestMkmfFlags.md b/example/ruby/TestMkmfFlags.md deleted file mode 100644 index e27a397..0000000 --- a/example/ruby/TestMkmfFlags.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestMkmfFlags -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_try_cflag_invalid_opt() [](#method-i-test_try_cflag_invalid_opt) - -## test_try_cppflag_invalid_opt() [](#method-i-test_try_cppflag_invalid_opt) - -## test_try_ldflag_invalid_opt() [](#method-i-test_try_ldflag_invalid_opt) - -## test_valid_warnflags() [](#method-i-test_valid_warnflags) - diff --git a/example/ruby/TestMkmfGlobal.md b/example/ruby/TestMkmfGlobal.md deleted file mode 100644 index c7fb3ee..0000000 --- a/example/ruby/TestMkmfGlobal.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestMkmfGlobal -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/TestMkmfHaveFramework.md b/example/ruby/TestMkmfHaveFramework.md deleted file mode 100644 index 68d71d0..0000000 --- a/example/ruby/TestMkmfHaveFramework.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestMkmfHaveFramework -**Inherits:** TestMkmf - - - - - -#Instance Methods -## create_framework(fw, hdrname"#{fw}.h") [](#method-i-create_framework) - -## test_different_name_header() [](#method-i-test_different_name_header) - -## test_empty_framework() [](#method-i-test_empty_framework) - -## test_multi_frameworks() [](#method-i-test_multi_frameworks) - -## test_single_framework() [](#method-i-test_single_framework) - diff --git a/example/ruby/TestMkmfHaveFunc.md b/example/ruby/TestMkmfHaveFunc.md deleted file mode 100644 index 287c280..0000000 --- a/example/ruby/TestMkmfHaveFunc.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMkmfHaveFunc -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_have_func() [](#method-i-test_have_func) - -## test_not_have_func() [](#method-i-test_not_have_func) - diff --git a/example/ruby/TestMkmfHaveLibrary.md b/example/ruby/TestMkmfHaveLibrary.md deleted file mode 100644 index ee864a6..0000000 --- a/example/ruby/TestMkmfHaveLibrary.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestMkmfHaveLibrary -**Inherits:** TestMkmf - - - - - -#Instance Methods -## assert_have_library(*args) [](#method-i-assert_have_library) - -## assert_not_have_library(*args) [](#method-i-assert_not_have_library) - -## create_library(libnameLIBRARY_NAME) [](#method-i-create_library) - -## test_have_library() [](#method-i-test_have_library) - -## test_have_library_with_name() [](#method-i-test_have_library_with_name) - -## test_not_have_library() [](#method-i-test_not_have_library) - -## test_not_have_library_with_name() [](#method-i-test_not_have_library_with_name) - diff --git a/example/ruby/TestMkmfHaveMacro.md b/example/ruby/TestMkmfHaveMacro.md deleted file mode 100644 index 7f77da8..0000000 --- a/example/ruby/TestMkmfHaveMacro.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestMkmfHaveMacro -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_have_macro_header() [](#method-i-test_have_macro_header) - -## test_have_macro_opt() [](#method-i-test_have_macro_opt) - -## test_not_have_macro_header() [](#method-i-test_not_have_macro_header) - -## test_not_have_macro_opt() [](#method-i-test_not_have_macro_opt) - diff --git a/example/ruby/TestMkmfInstall.md b/example/ruby/TestMkmfInstall.md deleted file mode 100644 index 4ba2dcb..0000000 --- a/example/ruby/TestMkmfInstall.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestMkmfInstall -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_install_dirs() [](#method-i-test_install_dirs) - diff --git a/example/ruby/TestMkmfLibs.md b/example/ruby/TestMkmfLibs.md deleted file mode 100644 index a464eed..0000000 --- a/example/ruby/TestMkmfLibs.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestMkmfLibs -**Inherits:** TestMkmf - - - - - -#Instance Methods -## assert_in_order(array, x, y, mesgnil) [](#method-i-assert_in_order) - -## test_merge_cyclic() [](#method-i-test_merge_cyclic) - -## test_merge_cyclic_2() [](#method-i-test_merge_cyclic_2) - -## test_merge_reversal() [](#method-i-test_merge_reversal) - -## test_merge_reversal_followed() [](#method-i-test_merge_reversal_followed) - -## test_merge_seq() [](#method-i-test_merge_seq) - -## test_merge_seq_pre() [](#method-i-test_merge_seq_pre) - -## test_merge_simple() [](#method-i-test_merge_simple) - -## test_split_libs() [](#method-i-test_split_libs) - -## test_split_libs_macos() [](#method-i-test_split_libs_macos) - -## test_split_libs_windows() [](#method-i-test_split_libs_windows) - diff --git a/example/ruby/TestMkmfPkgConfig.md b/example/ruby/TestMkmfPkgConfig.md deleted file mode 100644 index 698299e..0000000 --- a/example/ruby/TestMkmfPkgConfig.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestMkmfPkgConfig -**Inherits:** TestMkmf - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_pkgconfig_with_cflags_option_returns_output() [](#method-i-test_pkgconfig_with_cflags_option_returns_output) - -## test_pkgconfig_with_libs_option_returns_output() [](#method-i-test_pkgconfig_with_libs_option_returns_output) - -## test_pkgconfig_with_multiple_options() [](#method-i-test_pkgconfig_with_multiple_options) - -## test_pkgconfig_with_option_returns_nil_on_error() [](#method-i-test_pkgconfig_with_option_returns_nil_on_error) - diff --git a/example/ruby/TestMkmfSignedness.md b/example/ruby/TestMkmfSignedness.md deleted file mode 100644 index ed17456..0000000 --- a/example/ruby/TestMkmfSignedness.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMkmfSignedness -**Inherits:** TestMkmf - - - - - -#Instance Methods -## test_typeof_builtin() [](#method-i-test_typeof_builtin) - -## test_typeof_typedef() [](#method-i-test_typeof_typedef) - diff --git a/example/ruby/TestMkmfSizeof.md b/example/ruby/TestMkmfSizeof.md deleted file mode 100644 index f738b44..0000000 --- a/example/ruby/TestMkmfSizeof.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestMkmfSizeof -**Inherits:** TestMkmf - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_sizeof_builtin() [](#method-i-test_sizeof_builtin) - -## test_sizeof_struct() [](#method-i-test_sizeof_struct) - diff --git a/example/ruby/TestMkmfTryConstant.md b/example/ruby/TestMkmfTryConstant.md deleted file mode 100644 index dd37864..0000000 --- a/example/ruby/TestMkmfTryConstant.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestMkmfTryConstant -**Inherits:** TestMkmf - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_large_unsigned() [](#method-i-test_large_unsigned) - -## test_long() [](#method-i-test_long) - -## test_simple() [](#method-i-test_simple) - -## test_sizeof() [](#method-i-test_sizeof) - diff --git a/example/ruby/TestModule.md b/example/ruby/TestModule.md deleted file mode 100644 index 987ec16..0000000 --- a/example/ruby/TestModule.md +++ /dev/null @@ -1,432 +0,0 @@ -# Class: TestModule -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## _wrap_assertion() [](#method-i-_wrap_assertion) - -## assert_method_defined?(klass, mid, message"") [](#method-i-assert_method_defined?) - -**@return** [Boolean] - -## assert_method_not_defined?(klass, mid, message"") [](#method-i-assert_method_not_defined?) - -**@return** [Boolean] - -## each_bad_constants(m, &b) [](#method-i-each_bad_constants) - -## labeled_class(name, superclassObject, &block) [](#method-i-labeled_class) - -## labeled_module(name, &block) [](#method-i-labeled_module) - -## module_exec_aux() [](#method-i-module_exec_aux) - -## module_exec_aux_2(&block) [](#method-i-module_exec_aux_2) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_CMP() [](#method-i-test_CMP) ---- - -## test_CMP_0() [](#method-i-test_CMP_0) - -## test_GE() [](#method-i-test_GE) -'>=' - -## test_GT() [](#method-i-test_GT) -'>' - -## test_GT_0() [](#method-i-test_GT_0) - -## test_LE() [](#method-i-test_LE) -'<=' - -## test_LT() [](#method-i-test_LT) -'<' - -## test_LT_0() [](#method-i-test_LT_0) - -## test_VERY_EQUAL() [](#method-i-test_VERY_EQUAL) -'===' - -## test_accidental_singleton_naming_with_class() [](#method-i-test_accidental_singleton_naming_with_class) - -## test_accidental_singleton_naming_with_module() [](#method-i-test_accidental_singleton_naming_with_module) - -## test_alias() [](#method-i-test_alias) - -## test_alias_method() [](#method-i-test_alias_method) - -## test_ancestors() [](#method-i-test_ancestors) - -## test_ancestry_of_duped_classes() [](#method-i-test_ancestry_of_duped_classes) - -## test_append_features() [](#method-i-test_append_features) - -## test_append_features_raise() [](#method-i-test_append_features_raise) - -## test_append_features_type_error() [](#method-i-test_append_features_type_error) - -## test_attr() [](#method-i-test_attr) - -## test_attr_inherited_visibility() [](#method-i-test_attr_inherited_visibility) - -## test_attr_obsoleted_flag() [](#method-i-test_attr_obsoleted_flag) - -## test_attr_public_at_toplevel() [](#method-i-test_attr_public_at_toplevel) - -## test_attr_writer_with_no_arguments() [](#method-i-test_attr_writer_with_no_arguments) - -## test_bad_constants_defined() [](#method-i-test_bad_constants_defined) - -## test_bad_constants_get() [](#method-i-test_bad_constants_get) - -## test_bug17590() [](#method-i-test_bug17590) - -## test_class_eval() [](#method-i-test_class_eval) - -## test_class_variable_defined() [](#method-i-test_class_variable_defined) - -## test_class_variable_get() [](#method-i-test_class_variable_get) - -## test_class_variable_in_dup_class() [](#method-i-test_class_variable_in_dup_class) - -## test_class_variable_set() [](#method-i-test_class_variable_set) - -## test_class_variables() [](#method-i-test_class_variables) - -## test_classpath() [](#method-i-test_classpath) - -## test_clone_freeze() [](#method-i-test_clone_freeze) - -## test_complemented_method_entry_memory_leak() [](#method-i-test_complemented_method_entry_memory_leak) - -## test_const_added() [](#method-i-test_const_added) - -## test_const_defined?() [](#method-i-test_const_defined?) - -**@return** [Boolean] - -## test_const_defined_invalid_name() [](#method-i-test_const_defined_invalid_name) - -## test_const_get() [](#method-i-test_const_get) - -## test_const_get_evaled() [](#method-i-test_const_get_evaled) - -## test_const_get_inherited() [](#method-i-test_const_get_inherited) - -## test_const_get_invalid_name() [](#method-i-test_const_get_invalid_name) - -## test_const_get_no_inherited() [](#method-i-test_const_get_no_inherited) - -## test_const_in_module() [](#method-i-test_const_in_module) - -## test_const_set() [](#method-i-test_const_set) - -## test_const_set_invalid_name() [](#method-i-test_const_set_invalid_name) - -## test_const_source_location() [](#method-i-test_const_source_location) - -## test_constant_access_from_method_in_cloned_module() [](#method-i-test_constant_access_from_method_in_cloned_module) - -## test_constant_lookup_in_method_defined_by_class_eval() [](#method-i-test_constant_lookup_in_method_defined_by_class_eval) - -## test_constant_lookup_in_module_in_class_eval() [](#method-i-test_constant_lookup_in_module_in_class_eval) - -## test_constant_lookup_in_toplevel_class_eval() [](#method-i-test_constant_lookup_in_toplevel_class_eval) - -## test_constants() [](#method-i-test_constants) - -## test_constants_with_private_constant() [](#method-i-test_constants_with_private_constant) - -## test_cyclic_include() [](#method-i-test_cyclic_include) - -## test_cyclic_prepend() [](#method-i-test_cyclic_prepend) - -## test_define_method_changes_visibility_with_existing_method_bug_19749() [](#method-i-test_define_method_changes_visibility_with_existing_method_bug_19749) - -## test_define_method_with_unbound_method() [](#method-i-test_define_method_with_unbound_method) - -## test_define_module_under_private_constant() [](#method-i-test_define_module_under_private_constant) - -## test_deprecate_constant() [](#method-i-test_deprecate_constant) - -## test_dup() [](#method-i-test_dup) - -## test_dup_anonymous() [](#method-i-test_dup_anonymous) - -## test_export_method() [](#method-i-test_export_method) - -## test_extend_module_with_no_args() [](#method-i-test_extend_module_with_no_args) - -## test_extend_module_with_protected_bmethod() [](#method-i-test_extend_module_with_protected_bmethod) - -## test_extend_module_with_protected_method() [](#method-i-test_extend_module_with_protected_method) - -## test_freeze() [](#method-i-test_freeze) - -## test_frozen_class() [](#method-i-test_frozen_class) - -## test_frozen_module() [](#method-i-test_frozen_module) - -## test_frozen_prepend_remove_method() [](#method-i-test_frozen_prepend_remove_method) - -## test_frozen_singleton_class() [](#method-i-test_frozen_singleton_class) - -## test_frozen_visibility() [](#method-i-test_frozen_visibility) - -## test_gc_prepend_chain() [](#method-i-test_gc_prepend_chain) - -## test_iclass_memory_leak() [](#method-i-test_iclass_memory_leak) - -## test_include_before_initialize() [](#method-i-test_include_before_initialize) - -## test_include_into_module_after_prepend_bug_20871() [](#method-i-test_include_into_module_after_prepend_bug_20871) - -## test_include_into_module_already_included() [](#method-i-test_include_into_module_already_included) - -## test_include_p() [](#method-i-test_include_p) - -## test_include_super_in_alias() [](#method-i-test_include_super_in_alias) - -## test_include_toplevel() [](#method-i-test_include_toplevel) - -## test_include_with_no_args() [](#method-i-test_include_with_no_args) - -## test_include_with_prepend() [](#method-i-test_include_with_prepend) - -## test_included() [](#method-i-test_included) - -## test_included_modules() [](#method-i-test_included_modules) - -## test_included_modules_with_prepend() [](#method-i-test_included_modules_with_prepend) - -## test_initialize_copy() [](#method-i-test_initialize_copy) - -## test_initialize_copy_empty() [](#method-i-test_initialize_copy_empty) - -## test_inspect_segfault() [](#method-i-test_inspect_segfault) - -## test_instance_methods() [](#method-i-test_instance_methods) - -## test_invalid_attr() [](#method-i-test_invalid_attr) - -## test_leading_colons() [](#method-i-test_leading_colons) - -## test_method_added() [](#method-i-test_method_added) - -## test_method_defined() [](#method-i-test_method_defined) - -## test_method_defined?() [](#method-i-test_method_defined?) - -**@return** [Boolean] - -## test_method_defined_without_include_super() [](#method-i-test_method_defined_without_include_super) - -## test_method_redefinition() [](#method-i-test_method_redefinition) - -## test_method_removed() [](#method-i-test_method_removed) - -## test_method_undefined() [](#method-i-test_method_undefined) - -## test_mod_constants() [](#method-i-test_mod_constants) - -## test_module_clone_memory_leak() [](#method-i-test_module_clone_memory_leak) - -## test_module_collected_extended_object() [](#method-i-test_module_collected_extended_object) - -## test_module_eval() [](#method-i-test_module_eval) - -## test_module_exec() [](#method-i-test_module_exec) - -## test_module_function_inside_method() [](#method-i-test_module_function_inside_method) - -## test_module_name_in_singleton_method() [](#method-i-test_module_name_in_singleton_method) - -## test_module_subclass_initialize() [](#method-i-test_module_subclass_initialize) - -## test_name() [](#method-i-test_name) - -## test_nested_defined() [](#method-i-test_nested_defined) - -## test_nested_defined_bad_class() [](#method-i-test_nested_defined_bad_class) - -## test_nested_defined_inheritance() [](#method-i-test_nested_defined_inheritance) - -## test_nested_defined_symbol() [](#method-i-test_nested_defined_symbol) - -## test_nested_get() [](#method-i-test_nested_get) - -## test_nested_get_bad_class() [](#method-i-test_nested_get_bad_class) - -## test_nested_get_const_missing() [](#method-i-test_nested_get_const_missing) - -## test_nested_get_symbol() [](#method-i-test_nested_get_symbol) - -## test_nonascii_name() [](#method-i-test_nonascii_name) - -## test_override_optmethod_after_prepend() [](#method-i-test_override_optmethod_after_prepend) - -## test_prepend() [](#method-i-test_prepend) - -## test_prepend_CMP() [](#method-i-test_prepend_CMP) - -## test_prepend_after_include() [](#method-i-test_prepend_after_include) - -## test_prepend_call_super() [](#method-i-test_prepend_call_super) - -## test_prepend_class_ancestors() [](#method-i-test_prepend_class_ancestors) - -## test_prepend_constant_lookup() [](#method-i-test_prepend_constant_lookup) - -## test_prepend_each_classes() [](#method-i-test_prepend_each_classes) - -## test_prepend_gc() [](#method-i-test_prepend_gc) - -## test_prepend_in_superclass() [](#method-i-test_prepend_in_superclass) - -## test_prepend_included_modules() [](#method-i-test_prepend_included_modules) - -## test_prepend_inheritance() [](#method-i-test_prepend_inheritance) - -## test_prepend_instance_methods() [](#method-i-test_prepend_instance_methods) - -## test_prepend_instance_methods_false() [](#method-i-test_prepend_instance_methods_false) - -## test_prepend_module_ancestors() [](#method-i-test_prepend_module_ancestors) - -## test_prepend_module_with_no_args() [](#method-i-test_prepend_module_with_no_args) - -## test_prepend_no_duplication() [](#method-i-test_prepend_no_duplication) - -## test_prepend_optmethod() [](#method-i-test_prepend_optmethod) - -## test_prepend_private_super() [](#method-i-test_prepend_private_super) - -## test_prepend_remove_method() [](#method-i-test_prepend_remove_method) - -## test_prepend_self() [](#method-i-test_prepend_self) - -## test_prepend_singleton_methods() [](#method-i-test_prepend_singleton_methods) - -## test_prepend_super_in_alias() [](#method-i-test_prepend_super_in_alias) - -## test_prepend_visibility() [](#method-i-test_prepend_visibility) - -## test_prepend_visibility_inherited() [](#method-i-test_prepend_visibility_inherited) - -## test_prepend_works_with_duped_classes() [](#method-i-test_prepend_works_with_duped_classes) - -## test_prepended_module_with_super_and_alias() [](#method-i-test_prepended_module_with_super_and_alias) - -## test_private_class_method() [](#method-i-test_private_class_method) - -## test_private_constant2() [](#method-i-test_private_constant2) - -## test_private_constant_const_missing() [](#method-i-test_private_constant_const_missing) - -## test_private_constant_in_class() [](#method-i-test_private_constant_in_class) - -## test_private_constant_in_module() [](#method-i-test_private_constant_in_module) - -## test_private_constant_reopen() [](#method-i-test_private_constant_reopen) - -## test_private_constant_with_no_args() [](#method-i-test_private_constant_with_no_args) - -## test_private_constants_clear_inlinecache() [](#method-i-test_private_constants_clear_inlinecache) - -## test_private_extended_module() [](#method-i-test_private_extended_module) - -## test_private_instance_methods() [](#method-i-test_private_instance_methods) - -## test_private_top_methods() [](#method-i-test_private_top_methods) - -## test_protected_include_into_included_module() [](#method-i-test_protected_include_into_included_module) - -## test_protected_instance_methods() [](#method-i-test_protected_instance_methods) - -## test_protected_singleton_method() [](#method-i-test_protected_singleton_method) - -## test_public_class_method() [](#method-i-test_public_class_method) - -## test_public_constant() [](#method-i-test_public_constant) - -## test_public_include() [](#method-i-test_public_include) - -## test_public_instance_methods() [](#method-i-test_public_instance_methods) - -## test_public_methods() [](#method-i-test_public_methods) - -## test_public_prepend() [](#method-i-test_public_prepend) - -## test_redefine_optmethod_after_prepend() [](#method-i-test_redefine_optmethod_after_prepend) - -## test_redefinition_mismatch() [](#method-i-test_redefinition_mismatch) - -## test_refine_module_then_include() [](#method-i-test_refine_module_then_include) - -## test_remove_class_variable() [](#method-i-test_remove_class_variable) - -## test_remove_const() [](#method-i-test_remove_const) - -## test_return_value_of_define_method() [](#method-i-test_return_value_of_define_method) - -## test_return_value_of_define_singleton_method() [](#method-i-test_return_value_of_define_singleton_method) - -## test_s_constants() [](#method-i-test_s_constants) - -## test_s_nesting() [](#method-i-test_s_nesting) - -## test_s_new() [](#method-i-test_s_new) - -## test_s_private() [](#method-i-test_s_private) - -## test_s_protected() [](#method-i-test_s_protected) - -## test_s_public() [](#method-i-test_s_public) - -## test_send() [](#method-i-test_send) - -## test_singleton_class_ancestors() [](#method-i-test_singleton_class_ancestors) - -## test_singleton_constants() [](#method-i-test_singleton_constants) - -## test_top_public_private() [](#method-i-test_top_public_private) - -## test_toplevel_private_constant() [](#method-i-test_toplevel_private_constant) - -## test_undef() [](#method-i-test_undef) - -## test_undefined_instance_methods() [](#method-i-test_undefined_instance_methods) - -## test_uninitialized_attr() [](#method-i-test_uninitialized_attr) - -## test_uninitialized_attr_class() [](#method-i-test_uninitialized_attr_class) - -## test_uninitialized_attr_non_object() [](#method-i-test_uninitialized_attr_non_object) - -## test_uninitialized_instance_variable() [](#method-i-test_uninitialized_instance_variable) - -## test_uninitialized_toplevel_constant() [](#method-i-test_uninitialized_toplevel_constant) - -## test_visibility_after_multiple_refine_and_visibility_change_with_origin_class() [](#method-i-test_visibility_after_multiple_refine_and_visibility_change_with_origin_class) - -## test_visibility_after_multiple_refine_and_visibility_change_with_superclass() [](#method-i-test_visibility_after_multiple_refine_and_visibility_change_with_superclass) - -## test_visibility_after_multiple_refine_and_visibility_change_without_origin_class() [](#method-i-test_visibility_after_multiple_refine_and_visibility_change_without_origin_class) - -## test_visibility_after_refine_and_visibility_change_with_origin_class() [](#method-i-test_visibility_after_refine_and_visibility_change_with_origin_class) - -## test_visibility_after_refine_and_visibility_change_with_superclass() [](#method-i-test_visibility_after_refine_and_visibility_change_with_superclass) - -## test_visibility_after_refine_and_visibility_change_without_origin_class() [](#method-i-test_visibility_after_refine_and_visibility_change_without_origin_class) - -## test_visibility_by_public_class_method() [](#method-i-test_visibility_by_public_class_method) - -## test_visibility_method_return_value() [](#method-i-test_visibility_method_return_value) - diff --git a/example/ruby/TestModule/AClass.md b/example/ruby/TestModule/AClass.md deleted file mode 100644 index fc348da..0000000 --- a/example/ruby/TestModule/AClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestModule::AClass -**Inherits:** Object - - - - -# Class Methods -## cm2() [](#method-c-cm2) - -#Instance Methods -## aClass() [](#method-i-aClass) - diff --git a/example/ruby/TestModule/AttrTest.md b/example/ruby/TestModule/AttrTest.md deleted file mode 100644 index 8857693..0000000 --- a/example/ruby/TestModule/AttrTest.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: TestModule::AttrTest -**Inherits:** Object - - - - -# Class Methods -## reset() [](#method-c-reset) -# Attributes -## cattr[RW] [](#attribute-c-cattr) -Returns the value of attribute cattr. - -## iattr[RW] [](#attribute-i-iattr) -Returns the value of attribute iattr. - - -#Instance Methods -## ivar() [](#method-i-ivar) - diff --git a/example/ruby/TestModule/BClass.md b/example/ruby/TestModule/BClass.md deleted file mode 100644 index 0429482..0000000 --- a/example/ruby/TestModule/BClass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestModule::BClass -**Inherits:** TestModule::AClass - - - - - -#Instance Methods -## bClass1() [](#method-i-bClass1) - diff --git a/example/ruby/TestModule/Bug18185.md b/example/ruby/TestModule/Bug18185.md deleted file mode 100644 index 808def9..0000000 --- a/example/ruby/TestModule/Bug18185.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestModule::Bug18185 -**Inherits:** Module - - - - -# Attributes -## ancestor_list[RW] [](#attribute-i-ancestor_list) -Returns the value of attribute ancestor_list. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Bug18185] a new instance of Bug18185 - diff --git a/example/ruby/TestModule/Bug18185/Foo.md b/example/ruby/TestModule/Bug18185/Foo.md deleted file mode 100644 index 319648a..0000000 --- a/example/ruby/TestModule/Bug18185/Foo.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestModule::Bug18185::Foo -**Inherits:** Object - - - - -# Attributes -## key[RW] [](#attribute-i-key) -Returns the value of attribute key. - - -#Instance Methods -## initialize(key:) [](#method-i-initialize) - -**@return** [Foo] a new instance of Foo - diff --git a/example/ruby/TestModule/Bug18185/InstanceMethods.md b/example/ruby/TestModule/Bug18185/InstanceMethods.md deleted file mode 100644 index 6e13c07..0000000 --- a/example/ruby/TestModule/Bug18185/InstanceMethods.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestModule::Bug18185::InstanceMethods - - - - - diff --git a/example/ruby/TestModule/Bug9413.md b/example/ruby/TestModule/Bug9413.md deleted file mode 100644 index 9f80a3d..0000000 --- a/example/ruby/TestModule/Bug9413.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestModule::Bug9413 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestModule/C.md b/example/ruby/TestModule/C.md deleted file mode 100644 index 9444779..0000000 --- a/example/ruby/TestModule/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestModule::C -**Inherits:** Object - - - - - -#Instance Methods -## m1() [](#method-i-m1) - diff --git a/example/ruby/TestModule/C0.md b/example/ruby/TestModule/C0.md deleted file mode 100644 index f04fa8a..0000000 --- a/example/ruby/TestModule/C0.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestModule::C0 -**Inherits:** TestModule::C - -**Includes:** TestModule::M0, TestModule::M1 - - - - - -#Instance Methods -## m1() [](#method-i-m1) - diff --git a/example/ruby/TestModule/C1.md b/example/ruby/TestModule/C1.md deleted file mode 100644 index 84b8454..0000000 --- a/example/ruby/TestModule/C1.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestModule::C1 -**Inherits:** TestModule::C0 - -**Includes:** Module.new do - def m1; [:M3, *super] end -end, TestModule::M2, TestModule::M4 - - - - - -#Instance Methods -## m1() [](#method-i-m1) - diff --git a/example/ruby/TestModule/CClass.md b/example/ruby/TestModule/CClass.md deleted file mode 100644 index e8bd2d4..0000000 --- a/example/ruby/TestModule/CClass.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestModule::CClass -**Inherits:** TestModule::BClass - - - - -# Class Methods -## cClass() [](#method-c-cClass) - diff --git a/example/ruby/TestModule/CloneTestC1.md b/example/ruby/TestModule/CloneTestC1.md deleted file mode 100644 index cef9513..0000000 --- a/example/ruby/TestModule/CloneTestC1.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestModule::CloneTestC1 -**Inherits:** Object - -**Includes:** TestModule::CloneTestM1 - - - - - diff --git a/example/ruby/TestModule/CloneTestC2.md b/example/ruby/TestModule/CloneTestC2.md deleted file mode 100644 index b84ea50..0000000 --- a/example/ruby/TestModule/CloneTestC2.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestModule::CloneTestC2 -**Inherits:** Object - -**Includes:** TestModule::CloneTestM2 - - - - - diff --git a/example/ruby/TestModule/CloneTestM0.md b/example/ruby/TestModule/CloneTestM0.md deleted file mode 100644 index 70bb94f..0000000 --- a/example/ruby/TestModule/CloneTestM0.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestModule::CloneTestM0 - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestModule/CloneTestM1.md b/example/ruby/TestModule/CloneTestM1.md deleted file mode 100644 index 7f220f7..0000000 --- a/example/ruby/TestModule/CloneTestM1.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestModule::CloneTestM1 - - - - - diff --git a/example/ruby/TestModule/CloneTestM2.md b/example/ruby/TestModule/CloneTestM2.md deleted file mode 100644 index a5e0aef..0000000 --- a/example/ruby/TestModule/CloneTestM2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestModule::CloneTestM2 - - - - - diff --git a/example/ruby/TestModule/CloneTestM_simple.md b/example/ruby/TestModule/CloneTestM_simple.md deleted file mode 100644 index 33e0d67..0000000 --- a/example/ruby/TestModule/CloneTestM_simple.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestModule::CloneTestM_simple - - - - -# Class Methods -## m() [](#method-c-m) - diff --git a/example/ruby/TestModule/M0.md b/example/ruby/TestModule/M0.md deleted file mode 100644 index 2ea8b3f..0000000 --- a/example/ruby/TestModule/M0.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestModule::M0 - - - - - -#Instance Methods -## m1() [](#method-i-m1) - diff --git a/example/ruby/TestModule/M1.md b/example/ruby/TestModule/M1.md deleted file mode 100644 index b80b84c..0000000 --- a/example/ruby/TestModule/M1.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestModule::M1 - - - - - -#Instance Methods -## m1() [](#method-i-m1) - diff --git a/example/ruby/TestModule/M1/M2.md b/example/ruby/TestModule/M1/M2.md deleted file mode 100644 index 395f7be..0000000 --- a/example/ruby/TestModule/M1/M2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestModule::M1::M2 - - - - - diff --git a/example/ruby/TestModule/M2.md b/example/ruby/TestModule/M2.md deleted file mode 100644 index a75d753..0000000 --- a/example/ruby/TestModule/M2.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestModule::M2 - - - - - -#Instance Methods -## m1() [](#method-i-m1) - diff --git a/example/ruby/TestModule/M4.md b/example/ruby/TestModule/M4.md deleted file mode 100644 index 5ddbd90..0000000 --- a/example/ruby/TestModule/M4.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestModule::M4 - - - - - -#Instance Methods -## m1() [](#method-i-m1) - diff --git a/example/ruby/TestModule/Mixin.md b/example/ruby/TestModule/Mixin.md deleted file mode 100644 index 82fa261..0000000 --- a/example/ruby/TestModule/Mixin.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: TestModule::Mixin - - -Support stuff - - - -#Instance Methods -## mixin() [](#method-i-mixin) - diff --git a/example/ruby/TestModule/MyClass.md b/example/ruby/TestModule/MyClass.md deleted file mode 100644 index 0007e26..0000000 --- a/example/ruby/TestModule/MyClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestModule::MyClass -**Inherits:** Object - - - - - diff --git a/example/ruby/TestModule/PrivateConstantReopen.md b/example/ruby/TestModule/PrivateConstantReopen.md deleted file mode 100644 index 0f3d851..0000000 --- a/example/ruby/TestModule/PrivateConstantReopen.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestModule::PrivateConstantReopen - - - - - diff --git a/example/ruby/TestModule/User.md b/example/ruby/TestModule/User.md deleted file mode 100644 index 0b41c11..0000000 --- a/example/ruby/TestModule/User.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: TestModule::User - -**Includes:** TestModule::Mixin - - - - - -#Instance Methods -## mixin() [](#method-i-mixin) - -## user() [](#method-i-user) - diff --git a/example/ruby/TestMonitor.md b/example/ruby/TestMonitor.md deleted file mode 100644 index f631f46..0000000 --- a/example/ruby/TestMonitor.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestMonitor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_cond() [](#method-i-test_cond) - -## test_enter() [](#method-i-test_enter) - -## test_enter_in_different_fibers() [](#method-i-test_enter_in_different_fibers) - -## test_enter_second_after_killed_thread() [](#method-i-test_enter_second_after_killed_thread) - -## test_exit() [](#method-i-test_exit) - -## test_initialize_with_keyword_arg() [](#method-i-test_initialize_with_keyword_arg) - -## test_killed_thread_in_synchronize() [](#method-i-test_killed_thread_in_synchronize) - -## test_mon_locked_and_owned() [](#method-i-test_mon_locked_and_owned) - -## test_new_cond_before_initialize() [](#method-i-test_new_cond_before_initialize) - -## test_synchronize() [](#method-i-test_synchronize) - -## test_timedwait() [](#method-i-test_timedwait) - -## test_try_enter() [](#method-i-test_try_enter) - -## test_try_enter_second_after_killed_thread() [](#method-i-test_try_enter_second_after_killed_thread) - -## test_wait_interruption() [](#method-i-test_wait_interruption) - diff --git a/example/ruby/TestMonitor/KeywordInitializeChild.md b/example/ruby/TestMonitor/KeywordInitializeChild.md deleted file mode 100644 index 85d4743..0000000 --- a/example/ruby/TestMonitor/KeywordInitializeChild.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: TestMonitor::KeywordInitializeChild -**Inherits:** TestMonitor::KeywordInitializeParent - -**Includes:** MonitorMixin - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [KeywordInitializeChild] a new instance of KeywordInitializeChild - -## mon_enter() [](#method-i-mon_enter) -Enters exclusive section. - -## mon_exit() [](#method-i-mon_exit) -Leaves exclusive section. - -## mon_locked?() [](#method-i-mon_locked?) -Returns true if this monitor is locked by any thread - -**@return** [Boolean] - -## mon_owned?() [](#method-i-mon_owned?) -Returns true if this monitor is locked by current thread. - -**@return** [Boolean] - -## mon_synchronize(&b) [](#method-i-mon_synchronize) -Enters exclusive section and executes the block. Leaves the exclusive section -automatically when the block exits. See example under `MonitorMixin`. - -## mon_try_enter() [](#method-i-mon_try_enter) -Attempts to enter exclusive section. Returns `false` if lock fails. - -## new_cond() [](#method-i-new_cond) -Creates a new MonitorMixin::ConditionVariable associated with the Monitor -object. - diff --git a/example/ruby/TestMonitor/KeywordInitializeParent.md b/example/ruby/TestMonitor/KeywordInitializeParent.md deleted file mode 100644 index 532d93a..0000000 --- a/example/ruby/TestMonitor/KeywordInitializeParent.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestMonitor::KeywordInitializeParent -**Inherits:** Object - - - - - -#Instance Methods -## initialize(x:) [](#method-i-initialize) - -**@return** [KeywordInitializeParent] a new instance of KeywordInitializeParent - diff --git a/example/ruby/TestMonitor/NewCondTest.md b/example/ruby/TestMonitor/NewCondTest.md deleted file mode 100644 index 7b8d0c6..0000000 --- a/example/ruby/TestMonitor/NewCondTest.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class: TestMonitor::NewCondTest -**Inherits:** Object - -**Includes:** MonitorMixin - - - - -# Attributes -## cond[RW] [](#attribute-i-cond) -Returns the value of attribute cond. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [NewCondTest] a new instance of NewCondTest - -## mon_enter() [](#method-i-mon_enter) -Enters exclusive section. - -## mon_exit() [](#method-i-mon_exit) -Leaves exclusive section. - -## mon_locked?() [](#method-i-mon_locked?) -Returns true if this monitor is locked by any thread - -**@return** [Boolean] - -## mon_owned?() [](#method-i-mon_owned?) -Returns true if this monitor is locked by current thread. - -**@return** [Boolean] - -## mon_synchronize(&b) [](#method-i-mon_synchronize) -Enters exclusive section and executes the block. Leaves the exclusive section -automatically when the block exits. See example under `MonitorMixin`. - -## mon_try_enter() [](#method-i-mon_try_enter) -Attempts to enter exclusive section. Returns `false` if lock fails. - -## new_cond() [](#method-i-new_cond) -Creates a new MonitorMixin::ConditionVariable associated with the Monitor -object. - diff --git a/example/ruby/TestMyDict.md b/example/ruby/TestMyDict.md deleted file mode 100644 index f3964e0..0000000 --- a/example/ruby/TestMyDict.md +++ /dev/null @@ -1,50 +0,0 @@ -# Class: TestMyDict -**Inherits:** Test::Unit::TestCase - -**Includes:** TestCaseForDict - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add() [](#method-i-test_add) - -## test_bracket() [](#method-i-test_bracket) - -## test_bracket_equal() [](#method-i-test_bracket_equal) - -## test_bracket_with_numkey() [](#method-i-test_bracket_with_numkey) - -## test_convert_bignum() [](#method-i-test_convert_bignum) - -## test_each() [](#method-i-test_each) - -## test_invoke_with_array() [](#method-i-test_invoke_with_array) - -## test_methods() [](#method-i-test_methods) - -## test_no_method_error() [](#method-i-test_no_method_error) - -## test_non_exist_property() [](#method-i-test_non_exist_property) - -## test_ole_func_methods() [](#method-i-test_ole_func_methods) - -## test_ole_get_methods() [](#method-i-test_ole_get_methods) - -## test_ole_method_help() [](#method-i-test_ole_method_help) - -## test_ole_methods() [](#method-i-test_ole_methods) - -## test_ole_put_methods() [](#method-i-test_ole_put_methods) - -## test_ole_typelib() [](#method-i-test_ole_typelib) - -## test_raise_message() [](#method-i-test_raise_message) - -## test_s_new() [](#method-i-test_s_new) - -## test_setproperty_equal_ended() [](#method-i-test_setproperty_equal_ended) - diff --git a/example/ruby/TestNIL2VT_EMPTY.md b/example/ruby/TestNIL2VT_EMPTY.md deleted file mode 100644 index 5354fc8..0000000 --- a/example/ruby/TestNIL2VT_EMPTY.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestNIL2VT_EMPTY -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_openSchema() [](#method-i-test_openSchema) - diff --git a/example/ruby/TestNameError.md b/example/ruby/TestNameError.md deleted file mode 100644 index b0cfd1f..0000000 --- a/example/ruby/TestNameError.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestNameError -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_info_const() [](#method-i-test_info_const) - -## test_info_const_name() [](#method-i-test_info_const_name) - -## test_info_local_variables() [](#method-i-test_info_local_variables) - -## test_info_method() [](#method-i-test_info_method) - -## test_info_method_missing() [](#method-i-test_info_method_missing) - -## test_info_parent_iseq_mark() [](#method-i-test_info_parent_iseq_mark) - -## test_large_receiver_inspect() [](#method-i-test_large_receiver_inspect) - -## test_new_default() [](#method-i-test_new_default) - -## test_new_message() [](#method-i-test_new_message) - -## test_new_name() [](#method-i-test_new_name) - -## test_new_receiver() [](#method-i-test_new_receiver) - diff --git a/example/ruby/TestNetHTTP.md b/example/ruby/TestNetHTTP.md deleted file mode 100644 index 6805cec..0000000 --- a/example/ruby/TestNetHTTP.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: TestNetHTTP -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_addr_port() [](#method-i-test_addr_port) - -## test_class_Proxy() [](#method-i-test_class_Proxy) - -## test_class_Proxy_from_ENV() [](#method-i-test_class_Proxy_from_ENV) - -## test_default_configuration() [](#method-i-test_default_configuration) - -## test_edit_path() [](#method-i-test_edit_path) - -## test_edit_path_proxy() [](#method-i-test_edit_path_proxy) - -## test_failure_message_includes_failed_domain_and_port() [](#method-i-test_failure_message_includes_failed_domain_and_port) - -## test_newobj() [](#method-i-test_newobj) - -## test_proxy_address() [](#method-i-test_proxy_address) - -## test_proxy_address_ENV() [](#method-i-test_proxy_address_ENV) - -## test_proxy_address_no_proxy() [](#method-i-test_proxy_address_no_proxy) - -## test_proxy_eh_ENV() [](#method-i-test_proxy_eh_ENV) - -## test_proxy_eh_ENV_no_proxy() [](#method-i-test_proxy_eh_ENV_no_proxy) - -## test_proxy_eh_ENV_none_set() [](#method-i-test_proxy_eh_ENV_none_set) - -## test_proxy_eh_ENV_with_urlencoded_user() [](#method-i-test_proxy_eh_ENV_with_urlencoded_user) - -## test_proxy_eh_ENV_with_user() [](#method-i-test_proxy_eh_ENV_with_user) - -## test_proxy_eh_no_proxy() [](#method-i-test_proxy_eh_no_proxy) - -## test_proxy_from_env_ENV() [](#method-i-test_proxy_from_env_ENV) - -## test_proxy_port() [](#method-i-test_proxy_port) - -## test_proxy_port_ENV() [](#method-i-test_proxy_port_ENV) - diff --git a/example/ruby/TestNetHTTPContinue.md b/example/ruby/TestNetHTTPContinue.md deleted file mode 100644 index 97031cf..0000000 --- a/example/ruby/TestNetHTTPContinue.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestNetHTTPContinue -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils - - - - - -#Instance Methods -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## mount_proc(&block) [](#method-i-mount_proc) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_expect_continue() [](#method-i-test_expect_continue) - -## test_expect_continue_error() [](#method-i-test_expect_continue_error) - -## test_expect_continue_error_before_body() [](#method-i-test_expect_continue_error_before_body) - -## test_expect_continue_error_while_waiting() [](#method-i-test_expect_continue_error_while_waiting) - -## test_expect_continue_timeout() [](#method-i-test_expect_continue_timeout) - diff --git a/example/ruby/TestNetHTTPForceEncoding.md b/example/ruby/TestNetHTTPForceEncoding.md deleted file mode 100644 index 851ca62..0000000 --- a/example/ruby/TestNetHTTPForceEncoding.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestNetHTTPForceEncoding -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils - - - - - -#Instance Methods -## config(key) [](#method-i-config) - -## fe_request(force_enc, content_typenil) [](#method-i-fe_request) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_response_body_encoding_encoding_without_content_type() [](#method-i-test_response_body_encoding_encoding_without_content_type) - -## test_response_body_encoding_false() [](#method-i-test_response_body_encoding_false) - -## test_response_body_encoding_string_without_content_type() [](#method-i-test_response_body_encoding_string_without_content_type) - -## test_response_body_encoding_true_with_content_type() [](#method-i-test_response_body_encoding_true_with_content_type) - -## test_response_body_encoding_true_without_content_type() [](#method-i-test_response_body_encoding_true_without_content_type) - diff --git a/example/ruby/TestNetHTTPKeepAlive.md b/example/ruby/TestNetHTTPKeepAlive.md deleted file mode 100644 index 96058ef..0000000 --- a/example/ruby/TestNetHTTPKeepAlive.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: TestNetHTTPKeepAlive -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils - - - - -# Class Methods -## run(sock ) [](#method-c-run) - -#Instance Methods -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_http_retry_failed() [](#method-i-test_http_retry_failed) - -## test_http_retry_failed_with_block() [](#method-i-test_http_retry_failed_with_block) - -## test_http_retry_success() [](#method-i-test_http_retry_success) - -## test_keep_alive_get_auto_reconnect() [](#method-i-test_keep_alive_get_auto_reconnect) - -## test_keep_alive_get_auto_retry() [](#method-i-test_keep_alive_get_auto_retry) - -## test_keep_alive_reset_on_new_connection() [](#method-i-test_keep_alive_reset_on_new_connection) - -## test_keep_alive_server_close() [](#method-i-test_keep_alive_server_close) - -## test_server_closed_connection_auto_reconnect() [](#method-i-test_server_closed_connection_auto_reconnect) - diff --git a/example/ruby/TestNetHTTPKeepAlive/MockSocket.md b/example/ruby/TestNetHTTPKeepAlive/MockSocket.md deleted file mode 100644 index 8a37e90..0000000 --- a/example/ruby/TestNetHTTPKeepAlive/MockSocket.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestNetHTTPKeepAlive::MockSocket -**Inherits:** Object - - - - -# Attributes -## count[RW] [](#attribute-i-count) -Returns the value of attribute count. - - -#Instance Methods -## close() [](#method-i-close) - -## closed?() [](#method-i-closed?) - -**@return** [Boolean] - -## initialize(success_after:nil) [](#method-i-initialize) - -**@return** [MockSocket] a new instance of MockSocket - -## read_all(_) [](#method-i-read_all) - -## readline() [](#method-i-readline) - -## readuntil(*_) [](#method-i-readuntil) - -## write(_) [](#method-i-write) - diff --git a/example/ruby/TestNetHTTPLocalBind.md b/example/ruby/TestNetHTTPLocalBind.md deleted file mode 100644 index 193d383..0000000 --- a/example/ruby/TestNetHTTPLocalBind.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestNetHTTPLocalBind -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils - - - - - -#Instance Methods -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_bind_to_local_host() [](#method-i-test_bind_to_local_host) - -## test_bind_to_local_port() [](#method-i-test_bind_to_local_port) - diff --git a/example/ruby/TestNetHTTPPartialResponse.md b/example/ruby/TestNetHTTPPartialResponse.md deleted file mode 100644 index 4cd133c..0000000 --- a/example/ruby/TestNetHTTPPartialResponse.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestNetHTTPPartialResponse -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils - - - - - -#Instance Methods -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_partial_response() [](#method-i-test_partial_response) - diff --git a/example/ruby/TestNetHTTPSIdentityVerifyFailure.md b/example/ruby/TestNetHTTPSIdentityVerifyFailure.md deleted file mode 100644 index 808ae9e..0000000 --- a/example/ruby/TestNetHTTPSIdentityVerifyFailure.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestNetHTTPSIdentityVerifyFailure -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils - - - - -# Class Methods -## read_fixture(key ) [](#method-c-read_fixture) - -#Instance Methods -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_identity_verify_failure() [](#method-i-test_identity_verify_failure) - diff --git a/example/ruby/TestNetHTTPSwitchingProtocols.md b/example/ruby/TestNetHTTPSwitchingProtocols.md deleted file mode 100644 index ae2f19d..0000000 --- a/example/ruby/TestNetHTTPSwitchingProtocols.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestNetHTTPSwitchingProtocols -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils - - - - - -#Instance Methods -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## mount_proc(&block) [](#method-i-mount_proc) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_info() [](#method-i-test_info) - diff --git a/example/ruby/TestNetHTTPUtils.md b/example/ruby/TestNetHTTPUtils.md deleted file mode 100644 index 46920aa..0000000 --- a/example/ruby/TestNetHTTPUtils.md +++ /dev/null @@ -1,33 +0,0 @@ -# Module: TestNetHTTPUtils - - - - -# Class Methods -## clean_http_proxy_env() [](#method-c-clean_http_proxy_env) - -#Instance Methods -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - diff --git a/example/ruby/TestNetHTTPUtils/Forbidden.md b/example/ruby/TestNetHTTPUtils/Forbidden.md deleted file mode 100644 index 46dd018..0000000 --- a/example/ruby/TestNetHTTPUtils/Forbidden.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestNetHTTPUtils::Forbidden -**Inherits:** StandardError - - - - - diff --git a/example/ruby/TestNetHTTPUtils/HTTPServer.md b/example/ruby/TestNetHTTPUtils/HTTPServer.md deleted file mode 100644 index 2930a87..0000000 --- a/example/ruby/TestNetHTTPUtils/HTTPServer.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestNetHTTPUtils::HTTPServer -**Inherits:** Object - - - - - -#Instance Methods -## handle_request(socket) [](#method-i-handle_request) - -## initialize(config, &block) [](#method-i-initialize) - -**@return** [HTTPServer] a new instance of HTTPServer - -## mount(path, proc) [](#method-i-mount) - -## mount_proc(path, &block) [](#method-i-mount_proc) - -## port() [](#method-i-port) - -## run(socket) [](#method-i-run) - -## shutdown() [](#method-i-shutdown) - -## start() [](#method-i-start) - diff --git a/example/ruby/TestNetHTTPUtils/HTTPServer/Request.md b/example/ruby/TestNetHTTPUtils/HTTPServer/Request.md deleted file mode 100644 index 43f3e82..0000000 --- a/example/ruby/TestNetHTTPUtils/HTTPServer/Request.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestNetHTTPUtils::HTTPServer::Request -**Inherits:** Object - - - - -# Attributes -## body[RW] [](#attribute-i-body) -Returns the value of attribute body. - -## headers[RW] [](#attribute-i-headers) -Returns the value of attribute headers. - -## method[RW] [](#attribute-i-method) -Returns the value of attribute method. - -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - -## query[RW] [](#attribute-i-query) -Returns the value of attribute query. - - -#Instance Methods -## [](key) [](#method-i-[]) - -## []=(key, value) [](#method-i-[]=) - -## continue() [](#method-i-continue) - -## initialize(method, path, headers, socket) [](#method-i-initialize) - -**@return** [Request] a new instance of Request - -## peeraddr() [](#method-i-peeraddr) - -## remote_ip() [](#method-i-remote_ip) - diff --git a/example/ruby/TestNetHTTPUtils/HTTPServer/Response.md b/example/ruby/TestNetHTTPUtils/HTTPServer/Response.md deleted file mode 100644 index cef95df..0000000 --- a/example/ruby/TestNetHTTPUtils/HTTPServer/Response.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestNetHTTPUtils::HTTPServer::Response -**Inherits:** Object - - - - -# Attributes -## body[RW] [](#attribute-i-body) -Returns the value of attribute body. - -## chunked[RW] [](#attribute-i-chunked) -Returns the value of attribute chunked. - -## cookies[RW] [](#attribute-i-cookies) -Returns the value of attribute cookies. - -## headers[RW] [](#attribute-i-headers) -Returns the value of attribute headers. - -## status[RW] [](#attribute-i-status) -Returns the value of attribute status. - - -#Instance Methods -## [](key) [](#method-i-[]) - -## []=(key, value) [](#method-i-[]=) - -## finish() [](#method-i-finish) - -## initialize(client) [](#method-i-initialize) - -**@return** [Response] a new instance of Response - -## write_chunk(chunk) [](#method-i-write_chunk) - diff --git a/example/ruby/TestNetHTTP_v1_2.md b/example/ruby/TestNetHTTP_v1_2.md deleted file mode 100644 index 179d661..0000000 --- a/example/ruby/TestNetHTTP_v1_2.md +++ /dev/null @@ -1,120 +0,0 @@ -# Class: TestNetHTTP_v1_2 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils, TestNetHTTP_version_1_1_methods, TestNetHTTP_version_1_2_methods - - - - - -#Instance Methods -## _test_get__chunked(http) [](#method-i-_test_get__chunked) - -## _test_get__get(http) [](#method-i-_test_get__get) - -## _test_get__iter(http) [](#method-i-_test_get__iter) - -## _test_patch__base(http) [](#method-i-_test_patch__base) - -## _test_post__base(http) [](#method-i-_test_post__base) - -## _test_post__file(http) [](#method-i-_test_post__file) - -## _test_post__no_data(http) [](#method-i-_test_post__no_data) - -## _test_request__GET(http) [](#method-i-_test_request__GET) - -## _test_request__HEAD(http) [](#method-i-_test_request__HEAD) - -## _test_request__POST(http) [](#method-i-_test_request__POST) - -## _test_request__accept_encoding(http) [](#method-i-_test_request__accept_encoding) - -## _test_request__file(http) [](#method-i-_test_request__file) - -## _test_request__path(http) [](#method-i-_test_request__path) - -## _test_request__range(http) [](#method-i-_test_request__range) - -## _test_request__stream_body(http) [](#method-i-_test_request__stream_body) - -## _test_request__uri(http) [](#method-i-_test_request__uri) - -## _test_request__uri_host(http) [](#method-i-_test_request__uri_host) - -## _test_send_request__GET(http) [](#method-i-_test_send_request__GET) - -## _test_send_request__HEAD(http) [](#method-i-_test_send_request__HEAD) - -## _test_send_request__POST(http) [](#method-i-_test_send_request__POST) - -## _test_set_form_multipart(http, chunked_p, data, expected) [](#method-i-_test_set_form_multipart) - -## _test_set_form_urlencoded(http, data) [](#method-i-_test_set_form_urlencoded) - -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_get() [](#method-i-test_get) - -## test_get2() [](#method-i-test_get2) - -## test_get__break() [](#method-i-test_get__break) - -## test_get__crlf() [](#method-i-test_get__crlf) - -## test_get__implicit_start() [](#method-i-test_get__implicit_start) - -## test_head() [](#method-i-test_head) - -## test_patch() [](#method-i-test_patch) - -## test_post() [](#method-i-test_post) - -## test_request() [](#method-i-test_request) - -## test_s_get() [](#method-i-test_s_get) - -## test_s_get_response() [](#method-i-test_s_get_response) - -## test_s_post() [](#method-i-test_s_post) - -## test_s_post_form() [](#method-i-test_s_post_form) - -## test_s_start() [](#method-i-test_s_start) - -## test_send_large_POST_request() [](#method-i-test_send_large_POST_request) - -## test_send_request() [](#method-i-test_send_request) - -## test_set_form() [](#method-i-test_set_form) - -## test_set_form_with_file() [](#method-i-test_set_form_with_file) - -## test_timeout_during_HTTP_session() [](#method-i-test_timeout_during_HTTP_session) - -## test_timeout_during_HTTP_session_write() [](#method-i-test_timeout_during_HTTP_session_write) - -## test_timeout_during_non_chunked_streamed_HTTP_session_write() [](#method-i-test_timeout_during_non_chunked_streamed_HTTP_session_write) - diff --git a/example/ruby/TestNetHTTP_v1_2_chunked.md b/example/ruby/TestNetHTTP_v1_2_chunked.md deleted file mode 100644 index 1a1d442..0000000 --- a/example/ruby/TestNetHTTP_v1_2_chunked.md +++ /dev/null @@ -1,120 +0,0 @@ -# Class: TestNetHTTP_v1_2_chunked -**Inherits:** Test::Unit::TestCase - -**Includes:** TestNetHTTPUtils, TestNetHTTP_version_1_1_methods, TestNetHTTP_version_1_2_methods - - - - - -#Instance Methods -## _test_get__chunked(http) [](#method-i-_test_get__chunked) - -## _test_get__get(http) [](#method-i-_test_get__get) - -## _test_get__iter(http) [](#method-i-_test_get__iter) - -## _test_patch__base(http) [](#method-i-_test_patch__base) - -## _test_post__base(http) [](#method-i-_test_post__base) - -## _test_post__file(http) [](#method-i-_test_post__file) - -## _test_post__no_data(http) [](#method-i-_test_post__no_data) - -## _test_request__GET(http) [](#method-i-_test_request__GET) - -## _test_request__HEAD(http) [](#method-i-_test_request__HEAD) - -## _test_request__POST(http) [](#method-i-_test_request__POST) - -## _test_request__accept_encoding(http) [](#method-i-_test_request__accept_encoding) - -## _test_request__file(http) [](#method-i-_test_request__file) - -## _test_request__path(http) [](#method-i-_test_request__path) - -## _test_request__range(http) [](#method-i-_test_request__range) - -## _test_request__stream_body(http) [](#method-i-_test_request__stream_body) - -## _test_request__uri(http) [](#method-i-_test_request__uri) - -## _test_request__uri_host(http) [](#method-i-_test_request__uri_host) - -## _test_send_request__GET(http) [](#method-i-_test_send_request__GET) - -## _test_send_request__HEAD(http) [](#method-i-_test_send_request__HEAD) - -## _test_send_request__POST(http) [](#method-i-_test_send_request__POST) - -## _test_set_form_multipart(http, chunked_p, data, expected) [](#method-i-_test_set_form_multipart) - -## _test_set_form_urlencoded(http, data) [](#method-i-_test_set_form_urlencoded) - -## config(key) [](#method-i-config) - -## handle_get(path, headers, socket) [](#method-i-handle_get) - -## handle_head(path, headers, socket) [](#method-i-handle_head) - -## handle_patch(path, headers, socket) [](#method-i-handle_patch) - -## handle_post(path, headers, socket) [](#method-i-handle_post) - -## logfile() [](#method-i-logfile) - -## new() [](#method-i-new) - -## parse_content_type(content_type) [](#method-i-parse_content_type) - -## setup() [](#method-i-setup) - -## spawn_server() [](#method-i-spawn_server) - -## start(&block) [](#method-i-start) - -## teardown() [](#method-i-teardown) - -## test_chunked_break() [](#method-i-test_chunked_break) - -## test_get() [](#method-i-test_get) - -## test_get2() [](#method-i-test_get2) - -## test_get__break() [](#method-i-test_get__break) - -## test_get__crlf() [](#method-i-test_get__crlf) - -## test_get__implicit_start() [](#method-i-test_get__implicit_start) - -## test_head() [](#method-i-test_head) - -## test_patch() [](#method-i-test_patch) - -## test_post() [](#method-i-test_post) - -## test_request() [](#method-i-test_request) - -## test_s_get() [](#method-i-test_s_get) - -## test_s_get_response() [](#method-i-test_s_get_response) - -## test_s_post() [](#method-i-test_s_post) - -## test_s_post_form() [](#method-i-test_s_post_form) - -## test_s_start() [](#method-i-test_s_start) - -## test_send_request() [](#method-i-test_send_request) - -## test_set_form() [](#method-i-test_set_form) - -## test_set_form_with_file() [](#method-i-test_set_form_with_file) - -## test_timeout_during_HTTP_session() [](#method-i-test_timeout_during_HTTP_session) - -## test_timeout_during_HTTP_session_write() [](#method-i-test_timeout_during_HTTP_session_write) - -## test_timeout_during_non_chunked_streamed_HTTP_session_write() [](#method-i-test_timeout_during_non_chunked_streamed_HTTP_session_write) - diff --git a/example/ruby/TestNetHTTP_version_1_1_methods.md b/example/ruby/TestNetHTTP_version_1_1_methods.md deleted file mode 100644 index 3ab2c27..0000000 --- a/example/ruby/TestNetHTTP_version_1_1_methods.md +++ /dev/null @@ -1,53 +0,0 @@ -# Module: TestNetHTTP_version_1_1_methods - - - - - -#Instance Methods -## _test_get__chunked(http) [](#method-i-_test_get__chunked) - -## _test_get__get(http) [](#method-i-_test_get__get) - -## _test_get__iter(http) [](#method-i-_test_get__iter) - -## _test_patch__base(http) [](#method-i-_test_patch__base) - -## _test_post__base(http) [](#method-i-_test_post__base) - -## _test_post__file(http) [](#method-i-_test_post__file) - -## _test_post__no_data(http) [](#method-i-_test_post__no_data) - -## test_get() [](#method-i-test_get) - -## test_get2() [](#method-i-test_get2) - -## test_get__break() [](#method-i-test_get__break) - -## test_get__crlf() [](#method-i-test_get__crlf) - -## test_get__implicit_start() [](#method-i-test_get__implicit_start) - -## test_head() [](#method-i-test_head) - -## test_patch() [](#method-i-test_patch) - -## test_post() [](#method-i-test_post) - -## test_s_get() [](#method-i-test_s_get) - -## test_s_get_response() [](#method-i-test_s_get_response) - -## test_s_post() [](#method-i-test_s_post) - -## test_s_post_form() [](#method-i-test_s_post_form) - -## test_s_start() [](#method-i-test_s_start) - -## test_timeout_during_HTTP_session() [](#method-i-test_timeout_during_HTTP_session) - -## test_timeout_during_HTTP_session_write() [](#method-i-test_timeout_during_HTTP_session_write) - -## test_timeout_during_non_chunked_streamed_HTTP_session_write() [](#method-i-test_timeout_during_non_chunked_streamed_HTTP_session_write) - diff --git a/example/ruby/TestNetHTTP_version_1_2_methods.md b/example/ruby/TestNetHTTP_version_1_2_methods.md deleted file mode 100644 index b49d7ad..0000000 --- a/example/ruby/TestNetHTTP_version_1_2_methods.md +++ /dev/null @@ -1,45 +0,0 @@ -# Module: TestNetHTTP_version_1_2_methods - - - - - -#Instance Methods -## _test_request__GET(http) [](#method-i-_test_request__GET) - -## _test_request__HEAD(http) [](#method-i-_test_request__HEAD) - -## _test_request__POST(http) [](#method-i-_test_request__POST) - -## _test_request__accept_encoding(http) [](#method-i-_test_request__accept_encoding) - -## _test_request__file(http) [](#method-i-_test_request__file) - -## _test_request__path(http) [](#method-i-_test_request__path) - -## _test_request__range(http) [](#method-i-_test_request__range) - -## _test_request__stream_body(http) [](#method-i-_test_request__stream_body) - -## _test_request__uri(http) [](#method-i-_test_request__uri) - -## _test_request__uri_host(http) [](#method-i-_test_request__uri_host) - -## _test_send_request__GET(http) [](#method-i-_test_send_request__GET) - -## _test_send_request__HEAD(http) [](#method-i-_test_send_request__HEAD) - -## _test_send_request__POST(http) [](#method-i-_test_send_request__POST) - -## _test_set_form_multipart(http, chunked_p, data, expected) [](#method-i-_test_set_form_multipart) - -## _test_set_form_urlencoded(http, data) [](#method-i-_test_set_form_urlencoded) - -## test_request() [](#method-i-test_request) - -## test_send_request() [](#method-i-test_send_request) - -## test_set_form() [](#method-i-test_set_form) - -## test_set_form_with_file() [](#method-i-test_set_form_with_file) - diff --git a/example/ruby/TestNoMethodError.md b/example/ruby/TestNoMethodError.md deleted file mode 100644 index 3621991..0000000 --- a/example/ruby/TestNoMethodError.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestNoMethodError -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_message_encoding() [](#method-i-test_message_encoding) - -## test_new_default() [](#method-i-test_new_default) - -## test_new_message() [](#method-i-test_new_message) - -## test_new_name() [](#method-i-test_new_name) - -## test_new_name_args() [](#method-i-test_new_name_args) - -## test_new_name_args_priv() [](#method-i-test_new_name_args_priv) - -## test_new_receiver() [](#method-i-test_new_receiver) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestNot.md b/example/ruby/TestNot.md deleted file mode 100644 index 59503dd..0000000 --- a/example/ruby/TestNot.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestNot -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_not_with_empty_grouped_expression() [](#method-i-test_not_with_empty_grouped_expression) - -## test_not_with_grouped_expression() [](#method-i-test_not_with_grouped_expression) - diff --git a/example/ruby/TestNum2int.md b/example/ruby/TestNum2int.md deleted file mode 100644 index db8d07f..0000000 --- a/example/ruby/TestNum2int.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: TestNum2int -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_fix2i_error(type, num) [](#method-i-assert_fix2i_error) - -## assert_fix2i_error_internal(func, arg) [](#method-i-assert_fix2i_error_internal) - -## assert_fix2i_success(type, num, resultnum) [](#method-i-assert_fix2i_success) - -## assert_fix2i_success_internal(exp, func, arg) [](#method-i-assert_fix2i_success_internal) - -## assert_num2i_error(type, num) [](#method-i-assert_num2i_error) - -## assert_num2i_error_internal(func, arg) [](#method-i-assert_num2i_error_internal) - -## assert_num2i_success(type, num, resultnum) [](#method-i-assert_num2i_success) - -## assert_num2i_success_internal(exp, func, arg) [](#method-i-assert_num2i_success_internal) - -## fix2big(n) [](#method-i-fix2big) - -## test_fix2int() [](#method-i-test_fix2int) - -## test_fix2long() [](#method-i-test_fix2long) - -## test_fix2short() [](#method-i-test_fix2short) - -## test_fix2uint() [](#method-i-test_fix2uint) - -## test_fix2ulong() [](#method-i-test_fix2ulong) - -## test_num2int() [](#method-i-test_num2int) - -## test_num2ll() [](#method-i-test_num2ll) - -## test_num2long() [](#method-i-test_num2long) - -## test_num2short() [](#method-i-test_num2short) - -## test_num2uint() [](#method-i-test_num2uint) - -## test_num2ull() [](#method-i-test_num2ull) - -## test_num2ulong() [](#method-i-test_num2ulong) - -## test_num2ushort() [](#method-i-test_num2ushort) - diff --git a/example/ruby/TestNumeric.md b/example/ruby/TestNumeric.md deleted file mode 100644 index db09cd0..0000000 --- a/example/ruby/TestNumeric.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: TestNumeric -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_step(expected, from, *args, inf:false) [](#method-i-assert_step) - -## test_abs() [](#method-i-test_abs) - -## test_clone() [](#method-i-test_clone) - -## test_cmp() [](#method-i-test_cmp) - -## test_coerce() [](#method-i-test_coerce) - -## test_coerced_remainder() [](#method-i-test_coerced_remainder) - -## test_comparison_comparable() [](#method-i-test_comparison_comparable) - -## test_divmod() [](#method-i-test_divmod) - -## test_dummynumeric() [](#method-i-test_dummynumeric) - -## test_dup() [](#method-i-test_dup) - -## test_eql() [](#method-i-test_eql) - -## test_float_round_ndigits() [](#method-i-test_float_round_ndigits) - -## test_floor_ceil_ndigits() [](#method-i-test_floor_ceil_ndigits) - -## test_floor_ceil_round_truncate() [](#method-i-test_floor_ceil_round_truncate) - -## test_integer_p() [](#method-i-test_integer_p) - -## test_negative_p() [](#method-i-test_negative_p) - -## test_nonzero_p() [](#method-i-test_nonzero_p) - -## test_num2long() [](#method-i-test_num2long) - -## test_positive_p() [](#method-i-test_positive_p) - -## test_pow() [](#method-i-test_pow) - -## test_quo() [](#method-i-test_quo) - -## test_quo_ruby_core_41575() [](#method-i-test_quo_ruby_core_41575) - -## test_real_p() [](#method-i-test_real_p) - -## test_remainder_infinity() [](#method-i-test_remainder_infinity) - -## test_singleton_method() [](#method-i-test_singleton_method) - -## test_step() [](#method-i-test_step) - -## test_step_bug15537() [](#method-i-test_step_bug15537) - -## test_to_int() [](#method-i-test_to_int) - -## test_zero_p() [](#method-i-test_zero_p) - diff --git a/example/ruby/TestObjSpace.md b/example/ruby/TestObjSpace.md deleted file mode 100644 index 25d8cbe..0000000 --- a/example/ruby/TestObjSpace.md +++ /dev/null @@ -1,138 +0,0 @@ -# Class: TestObjSpace -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## all_super_classes(klass) [](#method-i-all_super_classes) - -## assert_dump_object(info, line) [](#method-i-assert_dump_object) - -## assert_test_string_entry_correct_in_dump_all(output) [](#method-i-assert_test_string_entry_correct_in_dump_all) - -## load_allocation_path_helper(method, to_binary:false) [](#method-i-load_allocation_path_helper) - -## test_anonymous_class_name() [](#method-i-test_anonymous_class_name) - -## test_argf_memsize() [](#method-i-test_argf_memsize) - -## test_count_imemo_objects() [](#method-i-test_count_imemo_objects) - -## test_count_nodes() [](#method-i-test_count_nodes) - -## test_count_objects_size() [](#method-i-test_count_objects_size) - -## test_count_objects_size_with_hash() [](#method-i-test_count_objects_size_with_hash) - -## test_count_objects_size_with_wrong_type() [](#method-i-test_count_objects_size_with_wrong_type) - -## test_count_symbols() [](#method-i-test_count_symbols) - -## test_count_tdata_objects() [](#method-i-test_count_tdata_objects) - -## test_dump_addresses_match_dump_all_addresses() [](#method-i-test_dump_addresses_match_dump_all_addresses) - -## test_dump_all() [](#method-i-test_dump_all) - -## test_dump_all_full() [](#method-i-test_dump_all_full) - -## test_dump_all_single_generation() [](#method-i-test_dump_all_single_generation) - -## test_dump_array() [](#method-i-test_dump_array) - -## test_dump_callinfo_includes_mid() [](#method-i-test_dump_callinfo_includes_mid) - -## test_dump_class_addresses_match_dump_all_addresses() [](#method-i-test_dump_class_addresses_match_dump_all_addresses) - -## test_dump_control_char() [](#method-i-test_dump_control_char) - -## test_dump_dynamic_symbol() [](#method-i-test_dump_dynamic_symbol) - -## test_dump_escapes_method_name() [](#method-i-test_dump_escapes_method_name) - -## test_dump_flags() [](#method-i-test_dump_flags) - -## test_dump_includes_imemo_type() [](#method-i-test_dump_includes_imemo_type) - -## test_dump_includes_slot_size() [](#method-i-test_dump_includes_slot_size) - -## test_dump_not_too_complex_shape() [](#method-i-test_dump_not_too_complex_shape) - -## test_dump_object() [](#method-i-test_dump_object) - -## test_dump_objects_dumps_page_slot_sizes() [](#method-i-test_dump_objects_dumps_page_slot_sizes) - -## test_dump_reference_addresses_match_dump_all_addresses() [](#method-i-test_dump_reference_addresses_match_dump_all_addresses) - -## test_dump_shapes() [](#method-i-test_dump_shapes) - -## test_dump_singleton_class() [](#method-i-test_dump_singleton_class) - -## test_dump_special_consts() [](#method-i-test_dump_special_consts) - -## test_dump_special_floats() [](#method-i-test_dump_special_floats) - -## test_dump_string_coderange() [](#method-i-test_dump_string_coderange) - -## test_dump_to_default() [](#method-i-test_dump_to_default) - -## test_dump_to_io() [](#method-i-test_dump_to_io) - -## test_dump_too_complex_shape() [](#method-i-test_dump_too_complex_shape) - -## test_dump_uninitialized_file() [](#method-i-test_dump_uninitialized_file) - -## test_escape_class_name() [](#method-i-test_escape_class_name) - -## test_internal_class_of() [](#method-i-test_internal_class_of) - -## test_internal_class_of_on_ast() [](#method-i-test_internal_class_of_on_ast) - -## test_internal_super_of() [](#method-i-test_internal_super_of) - -## test_load_allocation_path_compile_file() [](#method-i-test_load_allocation_path_compile_file) - -## test_load_allocation_path_load() [](#method-i-test_load_allocation_path_load) - -## test_load_allocation_path_load_from_binary() [](#method-i-test_load_allocation_path_load_from_binary) - -## test_memsize_of() [](#method-i-test_memsize_of) - -## test_memsize_of_all() [](#method-i-test_memsize_of_all) - -## test_memsize_of_iseq() [](#method-i-test_memsize_of_iseq) - -## test_memsize_of_root_shared_string() [](#method-i-test_memsize_of_root_shared_string) - -## test_name_error_message() [](#method-i-test_name_error_message) - -## test_objspace_trace() [](#method-i-test_objspace_trace) - -## test_reachable_objects_during_iteration() [](#method-i-test_reachable_objects_during_iteration) - -## test_reachable_objects_from() [](#method-i-test_reachable_objects_from) - -## test_reachable_objects_from_root() [](#method-i-test_reachable_objects_from_root) - -## test_reachable_objects_size() [](#method-i-test_reachable_objects_size) - -## test_trace_object_allocations() [](#method-i-test_trace_object_allocations) - -## test_trace_object_allocations_compaction() [](#method-i-test_trace_object_allocations_compaction) - -## test_trace_object_allocations_compaction_freed_pages() [](#method-i-test_trace_object_allocations_compaction_freed_pages) - -## test_trace_object_allocations_gc_stress() [](#method-i-test_trace_object_allocations_gc_stress) - -## test_trace_object_allocations_start_stop_clear() [](#method-i-test_trace_object_allocations_start_stop_clear) - -## test_trace_object_allocations_stop_first() [](#method-i-test_trace_object_allocations_stop_first) - -## test_utf8_method_names() [](#method-i-test_utf8_method_names) - -## traverse_classes(klass) [](#method-i-traverse_classes) - -## traverse_super_classes(klass) [](#method-i-traverse_super_classes) - diff --git a/example/ruby/TestObjSpace/NotTooComplex.md b/example/ruby/TestObjSpace/NotTooComplex.md deleted file mode 100644 index 24bf85d..0000000 --- a/example/ruby/TestObjSpace/NotTooComplex.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestObjSpace::NotTooComplex -**Inherits:** Object - - - - - diff --git a/example/ruby/TestObjSpace/TooComplex.md b/example/ruby/TestObjSpace/TooComplex.md deleted file mode 100644 index 5759001..0000000 --- a/example/ruby/TestObjSpace/TooComplex.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestObjSpace::TooComplex -**Inherits:** Object - - - - - diff --git a/example/ruby/TestObjSpaceRactor.md b/example/ruby/TestObjSpaceRactor.md deleted file mode 100644 index fcc5287..0000000 --- a/example/ruby/TestObjSpaceRactor.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestObjSpaceRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_tracing_does_not_crash() [](#method-i-test_tracing_does_not_crash) - diff --git a/example/ruby/TestObject.md b/example/ruby/TestObject.md deleted file mode 100644 index fa2a59b..0000000 --- a/example/ruby/TestObject.md +++ /dev/null @@ -1,142 +0,0 @@ -# Class: TestObject -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_not_initialize_copy() [](#method-i-assert_not_initialize_copy) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_bad_initialize_copy() [](#method-i-test_bad_initialize_copy) - -## test_check_to_integer() [](#method-i-test_check_to_integer) - -## test_clone() [](#method-i-test_clone) - -## test_clone_object_should_not_be_old() [](#method-i-test_clone_object_should_not_be_old) - -## test_convert_array() [](#method-i-test_convert_array) - -## test_convert_hash() [](#method-i-test_convert_hash) - -## test_convert_string() [](#method-i-test_convert_string) - -## test_copied_ivar_memory_leak() [](#method-i-test_copied_ivar_memory_leak) - -## test_dup() [](#method-i-test_dup) - -## test_extend() [](#method-i-test_extend) - -## test_false_and() [](#method-i-test_false_and) - -## test_false_or() [](#method-i-test_false_or) - -## test_false_to_s() [](#method-i-test_false_to_s) - -## test_false_xor() [](#method-i-test_false_xor) - -## test_freeze_immediate() [](#method-i-test_freeze_immediate) - -## test_frozen_error_message() [](#method-i-test_frozen_error_message) - -## test_frozen_inspect() [](#method-i-test_frozen_inspect) - -## test_implicit_respond_to() [](#method-i-test_implicit_respond_to) - -## test_implicit_respond_to_arity_1() [](#method-i-test_implicit_respond_to_arity_1) - -## test_implicit_respond_to_arity_3() [](#method-i-test_implicit_respond_to_arity_3) - -## test_init_dupclone() [](#method-i-test_init_dupclone) - -## test_inspect() [](#method-i-test_inspect) - -## test_instance_exec() [](#method-i-test_instance_exec) - -## test_instance_of() [](#method-i-test_instance_of) - -## test_instance_variable_defined() [](#method-i-test_instance_variable_defined) - -## test_instance_variable_get() [](#method-i-test_instance_variable_get) - -## test_instance_variable_set() [](#method-i-test_instance_variable_set) - -## test_itself() [](#method-i-test_itself) - -## test_kind_of() [](#method-i-test_kind_of) - -## test_max_shape_variation_with_performance_warnings() [](#method-i-test_max_shape_variation_with_performance_warnings) - -## test_method_missing() [](#method-i-test_method_missing) - -## test_method_missing_passed_block() [](#method-i-test_method_missing_passed_block) - -## test_methods() [](#method-i-test_methods) - -## test_methods2() [](#method-i-test_methods2) - -## test_methods_prepend() [](#method-i-test_methods_prepend) - -## test_methods_prepend_singleton() [](#method-i-test_methods_prepend_singleton) - -## test_nil_to_f() [](#method-i-test_nil_to_f) - -## test_nil_to_s() [](#method-i-test_nil_to_s) - -## test_no_superclass_method() [](#method-i-test_no_superclass_method) - -## test_not() [](#method-i-test_not) - -## test_public_send() [](#method-i-test_public_send) - -## test_redef_method_missing() [](#method-i-test_redef_method_missing) - -## test_redefine_method_under_verbose() [](#method-i-test_redefine_method_under_verbose) - -## test_redefine_method_which_may_case_serious_problem() [](#method-i-test_redefine_method_which_may_case_serious_problem) - -## test_remove_instance_variable() [](#method-i-test_remove_instance_variable) - -## test_remove_instance_variable_re_embed() [](#method-i-test_remove_instance_variable_re_embed) - -## test_remove_method() [](#method-i-test_remove_method) - -## test_respond_to_missing() [](#method-i-test_respond_to_missing) - -## test_respond_to_missing_string() [](#method-i-test_respond_to_missing_string) - -## test_send_with_block() [](#method-i-test_send_with_block) - -## test_send_with_no_arguments() [](#method-i-test_send_with_no_arguments) - -## test_singleton_class() [](#method-i-test_singleton_class) - -## test_singleton_class_freeze() [](#method-i-test_singleton_class_freeze) - -## test_singleton_methods() [](#method-i-test_singleton_methods) - -## test_specific_eval_with_wrong_arguments() [](#method-i-test_specific_eval_with_wrong_arguments) - -## test_superclass_method() [](#method-i-test_superclass_method) - -## test_to_integer() [](#method-i-test_to_integer) - -## test_to_s() [](#method-i-test_to_s) - -## test_true_and() [](#method-i-test_true_and) - -## test_true_or() [](#method-i-test_true_or) - -## test_true_to_s() [](#method-i-test_true_to_s) - -## test_true_xor() [](#method-i-test_true_xor) - -## test_type_error_message() [](#method-i-test_type_error_message) - -## test_yield_self() [](#method-i-test_yield_self) - diff --git a/example/ruby/TestObject/InstanceExec.md b/example/ruby/TestObject/InstanceExec.md deleted file mode 100644 index 11e9181..0000000 --- a/example/ruby/TestObject/InstanceExec.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestObject::InstanceExec -**Inherits:** Object - - - - - diff --git a/example/ruby/TestObject/MyInteger.md b/example/ruby/TestObject/MyInteger.md deleted file mode 100644 index b12b880..0000000 --- a/example/ruby/TestObject/MyInteger.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestObject::MyInteger -**Inherits:** Object - - - - - -#Instance Methods -## +(n) [](#method-i-+) - -## <=(n) [](#method-i-<=) - -## <=>(n) [](#method-i-<=>) - -## initialize(n) [](#method-i-initialize) - -**@return** [MyInteger] a new instance of MyInteger - -## to_int() [](#method-i-to_int) - diff --git a/example/ruby/TestObjectSpace.md b/example/ruby/TestObjectSpace.md deleted file mode 100644 index d60bf25..0000000 --- a/example/ruby/TestObjectSpace.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestObjectSpace -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## deftest_id2ref(obj ) [](#method-c-deftest_id2ref) - -#Instance Methods -## test_count_objects() [](#method-i-test_count_objects) - -## test_each_object() [](#method-i-test_each_object) - -## test_each_object_enumerator() [](#method-i-test_each_object_enumerator) - -## test_each_object_no_garbage() [](#method-i-test_each_object_no_garbage) - -## test_each_object_recursive_key() [](#method-i-test_each_object_recursive_key) - -## test_each_object_singleton_class() [](#method-i-test_each_object_singleton_class) - -## test_each_object_with_allocation() [](#method-i-test_each_object_with_allocation) - -## test_exception_in_finalizer() [](#method-i-test_exception_in_finalizer) - -## test_finalizer() [](#method-i-test_finalizer) - -## test_finalizer_thread_raise() [](#method-i-test_finalizer_thread_raise) - -## test_finalizer_with_super() [](#method-i-test_finalizer_with_super) - -## test_id2ref_invalid_argument() [](#method-i-test_id2ref_invalid_argument) - -## test_id2ref_invalid_symbol_id() [](#method-i-test_id2ref_invalid_symbol_id) - -## test_id2ref_liveness() [](#method-i-test_id2ref_liveness) - diff --git a/example/ruby/TestOpen3.md b/example/ruby/TestOpen3.md deleted file mode 100644 index f888559..0000000 --- a/example/ruby/TestOpen3.md +++ /dev/null @@ -1,74 +0,0 @@ -# Class: TestOpen3 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_block() [](#method-i-test_block) - -## test_capture2() [](#method-i-test_capture2) - -## test_capture2_stdin_data() [](#method-i-test_capture2_stdin_data) - -## test_capture2_stdin_data_io() [](#method-i-test_capture2_stdin_data_io) - -## test_capture2e() [](#method-i-test_capture2e) - -## test_capture2e_stdin_data() [](#method-i-test_capture2e_stdin_data) - -## test_capture2e_stdin_data_io() [](#method-i-test_capture2e_stdin_data_io) - -## test_capture3() [](#method-i-test_capture3) - -## test_capture3_flip() [](#method-i-test_capture3_flip) - -## test_capture3_stdin_data() [](#method-i-test_capture3_stdin_data) - -## test_capture3_stdin_data_io() [](#method-i-test_capture3_stdin_data_io) - -## test_commandline() [](#method-i-test_commandline) - -## test_env() [](#method-i-test_env) - -## test_exit_status() [](#method-i-test_exit_status) - -## test_integer_and_symbol_key() [](#method-i-test_integer_and_symbol_key) - -## test_noblock() [](#method-i-test_noblock) - -## test_numeric_file_descriptor2() [](#method-i-test_numeric_file_descriptor2) - -## test_numeric_file_descriptor3() [](#method-i-test_numeric_file_descriptor3) - -## test_pid() [](#method-i-test_pid) - -## test_pipeline() [](#method-i-test_pipeline) - -## test_pipeline_r() [](#method-i-test_pipeline_r) - -## test_pipeline_rw() [](#method-i-test_pipeline_rw) - -## test_pipeline_start() [](#method-i-test_pipeline_start) - -## test_pipeline_start_noblock() [](#method-i-test_pipeline_start_noblock) - -## test_pipeline_w() [](#method-i-test_pipeline_w) - -## test_popen2() [](#method-i-test_popen2) - -## test_popen2e() [](#method-i-test_popen2e) - -## test_popen2e_noblock() [](#method-i-test_popen2e_noblock) - -## test_stderr() [](#method-i-test_stderr) - -## test_stdin() [](#method-i-test_stdin) - -## test_stdout() [](#method-i-test_stdout) - -## with_pipe() [](#method-i-with_pipe) - -## with_reopen(io, arg) [](#method-i-with_reopen) - diff --git a/example/ruby/TestOpenURI.md b/example/ruby/TestOpenURI.md deleted file mode 100644 index d258cf2..0000000 --- a/example/ruby/TestOpenURI.md +++ /dev/null @@ -1,99 +0,0 @@ -# Class: TestOpenURI -**Inherits:** Test::Unit::TestCase - -**Includes:** TestOpenURIUtils - - - - - -#Instance Methods -## setup_redirect_auth(srv, url) [](#method-i-setup_redirect_auth) - -## test_200() [](#method-i-test_200) - -## test_200_uri_open() [](#method-i-test_200_uri_open) - -## test_200big() [](#method-i-test_200big) - -## test_404() [](#method-i-test_404) - -## test_close_in_block_big() [](#method-i-test_close_in_block_big) - -## test_close_in_block_small() [](#method-i-test_close_in_block_small) - -## test_content_encoding() [](#method-i-test_content_encoding) - -## test_encoding() [](#method-i-test_encoding) - -## test_header() [](#method-i-test_header) - -## test_invalid_option() [](#method-i-test_invalid_option) - -## test_last_modified() [](#method-i-test_last_modified) - -## test_max_redirects_success() [](#method-i-test_max_redirects_success) - -## test_max_redirects_too_many() [](#method-i-test_max_redirects_too_many) - -## test_meta_init_doesnt_bump_global_constant_state() [](#method-i-test_meta_init_doesnt_bump_global_constant_state) -192.0.2.0/24 is TEST-NET. [RFC3330] - -## test_mode() [](#method-i-test_mode) - -## test_multi_proxy_opt() [](#method-i-test_multi_proxy_opt) - -## test_multiple_cookies() [](#method-i-test_multiple_cookies) - -## test_non_http_proxy() [](#method-i-test_non_http_proxy) - -## test_open_timeout() [](#method-i-test_open_timeout) - -## test_open_too_many_arg() [](#method-i-test_open_too_many_arg) - -## test_open_uri() [](#method-i-test_open_uri) - -## test_pass_keywords() [](#method-i-test_pass_keywords) - -## test_progress() [](#method-i-test_progress) - -## test_progress_chunked() [](#method-i-test_progress_chunked) - -## test_quoted_attvalue() [](#method-i-test_quoted_attvalue) - -## test_read_timeout() [](#method-i-test_read_timeout) - -## test_redirect() [](#method-i-test_redirect) - -## test_redirect_auth_failure_r1() [](#method-i-test_redirect_auth_failure_r1) - -## test_redirect_auth_failure_r2() [](#method-i-test_redirect_auth_failure_r2) - -## test_redirect_auth_success() [](#method-i-test_redirect_auth_success) - -## test_redirect_invalid() [](#method-i-test_redirect_invalid) - -## test_redirect_loop() [](#method-i-test_redirect_loop) - -## test_redirect_relative() [](#method-i-test_redirect_relative) - -## test_redirect_with_invalid_request_specific_fields_format() [](#method-i-test_redirect_with_invalid_request_specific_fields_format) - -## test_redirect_with_request_specific_fields_hash() [](#method-i-test_redirect_with_request_specific_fields_hash) - -## test_redirect_with_request_specific_fields_proc() [](#method-i-test_redirect_with_request_specific_fields_proc) - -## test_redirect_without_request_specific_fields_hash() [](#method-i-test_redirect_without_request_specific_fields_hash) - -## test_uri_read() [](#method-i-test_uri_read) - -## test_userinfo() [](#method-i-test_userinfo) - -## test_without_block() [](#method-i-test_without_block) - -## with_http(log_testerlambda {|log| assert_equal([], log) }) [](#method-i-with_http) - -## with_https(log_testerlambda {|log| assert_equal([], log) }) [](#method-i-with_https) - -## with_https_proxy(proxy_log_testerlambda {|proxy_log, proxy_access_log| assert_equal([], proxy_log) }) [](#method-i-with_https_proxy) - diff --git a/example/ruby/TestOpenURIFtp.md b/example/ruby/TestOpenURIFtp.md deleted file mode 100644 index d4167a8..0000000 --- a/example/ruby/TestOpenURIFtp.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestOpenURIFtp -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_ftp_over_http_proxy() [](#method-i-test_ftp_over_http_proxy) - -## test_ftp_over_http_proxy_auth() [](#method-i-test_ftp_over_http_proxy_auth) - -## with_env(h) [](#method-i-with_env) - diff --git a/example/ruby/TestOpenURIProxy.md b/example/ruby/TestOpenURIProxy.md deleted file mode 100644 index 4e69bea..0000000 --- a/example/ruby/TestOpenURIProxy.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestOpenURIProxy -**Inherits:** Test::Unit::TestCase - -**Includes:** TestOpenURIUtils - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_authenticated_proxy_http_basic_authentication_success() [](#method-i-test_authenticated_proxy_http_basic_authentication_success) - -## test_proxy() [](#method-i-test_proxy) - -## test_proxy_http_basic_authentication_failure() [](#method-i-test_proxy_http_basic_authentication_failure) - -## test_proxy_http_basic_authentication_success() [](#method-i-test_proxy_http_basic_authentication_success) - -## with_env(h) [](#method-i-with_env) - -## with_http(log_testerlambda {|log| assert_equal([], log) }) [](#method-i-with_http) - -## with_https(log_testerlambda {|log| assert_equal([], log) }) [](#method-i-with_https) - -## with_https_proxy(proxy_log_testerlambda {|proxy_log, proxy_access_log| assert_equal([], proxy_log) }) [](#method-i-with_https_proxy) - diff --git a/example/ruby/TestOpenURISSL.md b/example/ruby/TestOpenURISSL.md deleted file mode 100644 index ebb8434..0000000 --- a/example/ruby/TestOpenURISSL.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestOpenURISSL -**Inherits:** Test::Unit::TestCase - -**Includes:** TestOpenURIUtils - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## setup_validation(srv, dr) [](#method-i-setup_validation) - -## teardown() [](#method-i-teardown) - -## test_bad_ssl_version() [](#method-i-test_bad_ssl_version) - -## test_proxy_cacert_dir() [](#method-i-test_proxy_cacert_dir) - -## test_proxy_cacert_file() [](#method-i-test_proxy_cacert_file) - -## test_ssl_min_version() [](#method-i-test_ssl_min_version) - -## test_validation_failure() [](#method-i-test_validation_failure) - -## test_validation_noverify() [](#method-i-test_validation_noverify) - -## test_validation_success() [](#method-i-test_validation_success) - -## with_http(log_testerlambda {|log| assert_equal([], log) }) [](#method-i-with_http) - -## with_https(log_testerlambda {|log| assert_equal([], log) }) [](#method-i-with_https) - -## with_https_proxy(proxy_log_testerlambda {|proxy_log, proxy_access_log| assert_equal([], proxy_log) }) [](#method-i-with_https_proxy) - diff --git a/example/ruby/TestOpenURIUtils.md b/example/ruby/TestOpenURIUtils.md deleted file mode 100644 index 0e0ffd2..0000000 --- a/example/ruby/TestOpenURIUtils.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: TestOpenURIUtils - - - - - -#Instance Methods -## with_http(log_testerlambda {|log| assert_equal([], log) }) [](#method-i-with_http) - -## with_https(log_testerlambda {|log| assert_equal([], log) }) [](#method-i-with_https) - -## with_https_proxy(proxy_log_testerlambda {|proxy_log, proxy_access_log| assert_equal([], proxy_log) }) [](#method-i-with_https_proxy) - diff --git a/example/ruby/TestOpenURIUtils/ProxyAuthenticationRequired.md b/example/ruby/TestOpenURIUtils/ProxyAuthenticationRequired.md deleted file mode 100644 index 77510fe..0000000 --- a/example/ruby/TestOpenURIUtils/ProxyAuthenticationRequired.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestOpenURIUtils::ProxyAuthenticationRequired -**Inherits:** StandardError - - - - - diff --git a/example/ruby/TestOpenURIUtils/Unauthorized.md b/example/ruby/TestOpenURIUtils/Unauthorized.md deleted file mode 100644 index 7d86d04..0000000 --- a/example/ruby/TestOpenURIUtils/Unauthorized.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestOpenURIUtils::Unauthorized -**Inherits:** StandardError - - - - - diff --git a/example/ruby/TestOptionParser.md b/example/ruby/TestOptionParser.md deleted file mode 100644 index 0eb514a..0000000 --- a/example/ruby/TestOptionParser.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestOptionParser -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_no_error(*args) [](#method-i-assert_no_error) - -## setup() [](#method-i-setup) - -## test_exact_option() [](#method-i-test_exact_option) - -## test_help_pager() [](#method-i-test_help_pager) - -## test_into() [](#method-i-test_into) - -## test_nonopt_pattern() [](#method-i-test_nonopt_pattern) - -## test_order() [](#method-i-test_order) - -## test_permute() [](#method-i-test_permute) - -## test_raise_unknown() [](#method-i-test_raise_unknown) - -## test_regexp() [](#method-i-test_regexp) - -## test_require_exact() [](#method-i-test_require_exact) - diff --git a/example/ruby/TestOptionParser/DummyOutput.md b/example/ruby/TestOptionParser/DummyOutput.md deleted file mode 100644 index ef8a72f..0000000 --- a/example/ruby/TestOptionParser/DummyOutput.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestOptionParser::DummyOutput -**Inherits:** String - - - - - diff --git a/example/ruby/TestOptionParser/WithPattern.md b/example/ruby/TestOptionParser/WithPattern.md deleted file mode 100644 index 5c41667..0000000 --- a/example/ruby/TestOptionParser/WithPattern.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestOptionParser::WithPattern -**Inherits:** TestOptionParser - - - - - -#Instance Methods -## test_pattern() [](#method-i-test_pattern) - diff --git a/example/ruby/TestOptionParserAcceptable.md b/example/ruby/TestOptionParserAcceptable.md deleted file mode 100644 index eac6a8b..0000000 --- a/example/ruby/TestOptionParserAcceptable.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestOptionParserAcceptable -**Inherits:** TestOptionParser - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_array() [](#method-i-test_array) - -## test_decimal_integer() [](#method-i-test_decimal_integer) - -## test_decimal_numeric() [](#method-i-test_decimal_numeric) - -## test_float() [](#method-i-test_float) - -## test_integer() [](#method-i-test_integer) - -## test_numeric() [](#method-i-test_numeric) - -## test_octal_integer() [](#method-i-test_octal_integer) - diff --git a/example/ruby/TestOptionParserAutoConf.md b/example/ruby/TestOptionParserAutoConf.md deleted file mode 100644 index b563ca2..0000000 --- a/example/ruby/TestOptionParserAutoConf.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestOptionParserAutoConf -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## no_error(*args) [](#method-i-no_error) - -## setup() [](#method-i-setup) - -## test_disable() [](#method-i-test_disable) - -## test_enable() [](#method-i-test_enable) - -## test_enable_value() [](#method-i-test_enable_value) - -## test_help() [](#method-i-test_help) - -## test_with() [](#method-i-test_with) - -## test_without() [](#method-i-test_without) - diff --git a/example/ruby/TestOptionParserAutoConf/DummyOutput.md b/example/ruby/TestOptionParserAutoConf/DummyOutput.md deleted file mode 100644 index 54a8097..0000000 --- a/example/ruby/TestOptionParserAutoConf/DummyOutput.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestOptionParserAutoConf::DummyOutput -**Inherits:** String - - - - - diff --git a/example/ruby/TestOptionParserBashCompletion.md b/example/ruby/TestOptionParserBashCompletion.md deleted file mode 100644 index 0e8c952..0000000 --- a/example/ruby/TestOptionParserBashCompletion.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestOptionParserBashCompletion -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_case_sensitive() [](#method-i-test_case_sensitive) - -## test_empty() [](#method-i-test_empty) - -## test_long_f() [](#method-i-test_long_f) - -## test_long_for_option() [](#method-i-test_long_for_option) - -## test_long_for_option_args() [](#method-i-test_long_for_option_args) - -## test_long_for_option_complete() [](#method-i-test_long_for_option_complete) - -## test_one_hyphen() [](#method-i-test_one_hyphen) - -## test_two_hyphen() [](#method-i-test_two_hyphen) - diff --git a/example/ruby/TestOptionParserCClass.md b/example/ruby/TestOptionParserCClass.md deleted file mode 100644 index 2f16cbe..0000000 --- a/example/ruby/TestOptionParserCClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestOptionParserCClass -**Inherits:** TestOptionParser - - - - - -#Instance Methods -## test_no_argument() [](#method-i-test_no_argument) - -## test_required_argument() [](#method-i-test_required_argument) - diff --git a/example/ruby/TestOptionParserDidYouMean.md b/example/ruby/TestOptionParserDidYouMean.md deleted file mode 100644 index 5521f84..0000000 --- a/example/ruby/TestOptionParserDidYouMean.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestOptionParserDidYouMean -**Inherits:** TestOptionParser - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_ambiguous() [](#method-i-test_ambiguous) - -## test_no_suggestion() [](#method-i-test_no_suggestion) - -## test_plain() [](#method-i-test_plain) - diff --git a/example/ruby/TestOptionParserGetopts.md b/example/ruby/TestOptionParserGetopts.md deleted file mode 100644 index 93b5ec2..0000000 --- a/example/ruby/TestOptionParserGetopts.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestOptionParserGetopts -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_long_arg() [](#method-i-test_long_arg) - -## test_long_noarg() [](#method-i-test_long_noarg) - -## test_short_arg() [](#method-i-test_short_arg) - -## test_short_noarg() [](#method-i-test_short_noarg) - diff --git a/example/ruby/TestOptionParserKwArg.md b/example/ruby/TestOptionParserKwArg.md deleted file mode 100644 index 3c1148d..0000000 --- a/example/ruby/TestOptionParserKwArg.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestOptionParserKwArg -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_no_error(*args) [](#method-i-assert_no_error) - -## test_kwarg() [](#method-i-test_kwarg) - diff --git a/example/ruby/TestOptionParserKwArg/DummyOutput.md b/example/ruby/TestOptionParserKwArg/DummyOutput.md deleted file mode 100644 index 60596fb..0000000 --- a/example/ruby/TestOptionParserKwArg/DummyOutput.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestOptionParserKwArg::DummyOutput -**Inherits:** String - - - - - diff --git a/example/ruby/TestOptionParserKwArg/K.md b/example/ruby/TestOptionParserKwArg/K.md deleted file mode 100644 index 770789f..0000000 --- a/example/ruby/TestOptionParserKwArg/K.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestOptionParserKwArg::K -**Inherits:** Object - - - - - -#Instance Methods -## initialize(host:, port:8080) [](#method-i-initialize) - -**@return** [K] a new instance of K - diff --git a/example/ruby/TestOptionParserLoad.md b/example/ruby/TestOptionParserLoad.md deleted file mode 100644 index 403fdf7..0000000 --- a/example/ruby/TestOptionParserLoad.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestOptionParserLoad -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_load(result) [](#method-i-assert_load) - -## new_parser() [](#method-i-new_parser) - -## setup() [](#method-i-setup) - -## setup_options(env, dir, suffixnil) [](#method-i-setup_options) - -## setup_options_home(&block) [](#method-i-setup_options_home) - -## setup_options_home_config(&block) [](#method-i-setup_options_home_config) - -## setup_options_home_config_settings(&block) [](#method-i-setup_options_home_config_settings) - -## setup_options_xdg_config_dirs(&block) [](#method-i-setup_options_xdg_config_dirs) - -## setup_options_xdg_config_home(&block) [](#method-i-setup_options_xdg_config_home) - -## teardown() [](#method-i-teardown) - -## test_load_home_config() [](#method-i-test_load_home_config) - -## test_load_home_config_settings() [](#method-i-test_load_home_config_settings) - -## test_load_home_options() [](#method-i-test_load_home_options) - -## test_load_nothing() [](#method-i-test_load_nothing) - -## test_load_xdg_config_dirs() [](#method-i-test_load_xdg_config_dirs) - -## test_load_xdg_config_home() [](#method-i-test_load_xdg_config_home) - diff --git a/example/ruby/TestOptionParserNoArg.md b/example/ruby/TestOptionParserNoArg.md deleted file mode 100644 index c8a76c6..0000000 --- a/example/ruby/TestOptionParserNoArg.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: TestOptionParserNoArg - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_ambiguous() [](#method-i-test_ambiguous) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserNoArg/Def1.md b/example/ruby/TestOptionParserNoArg/Def1.md deleted file mode 100644 index 8d4b26d..0000000 --- a/example/ruby/TestOptionParserNoArg/Def1.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestOptionParserNoArg::Def1 -**Inherits:** TestOptionParser - -**Includes:** TestOptionParserNoArg - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_ambiguous() [](#method-i-test_ambiguous) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserNoArg/Def2.md b/example/ruby/TestOptionParserNoArg/Def2.md deleted file mode 100644 index f9f25aa..0000000 --- a/example/ruby/TestOptionParserNoArg/Def2.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestOptionParserNoArg::Def2 -**Inherits:** TestOptionParser - -**Includes:** TestOptionParserNoArg - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_ambiguous() [](#method-i-test_ambiguous) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserOptArg.md b/example/ruby/TestOptionParserOptArg.md deleted file mode 100644 index 231f8cc..0000000 --- a/example/ruby/TestOptionParserOptArg.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestOptionParserOptArg -**Inherits:** TestOptionParser - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_default_argument() [](#method-i-test_default_argument) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_lambda() [](#method-i-test_lambda) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserPlaceArg.md b/example/ruby/TestOptionParserPlaceArg.md deleted file mode 100644 index 87d4218..0000000 --- a/example/ruby/TestOptionParserPlaceArg.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestOptionParserPlaceArg -**Inherits:** TestOptionParser - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_conv() [](#method-i-test_conv) - -## test_default_argument() [](#method-i-test_default_argument) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_lambda() [](#method-i-test_lambda) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserReqArg.md b/example/ruby/TestOptionParserReqArg.md deleted file mode 100644 index 132027f..0000000 --- a/example/ruby/TestOptionParserReqArg.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: TestOptionParserReqArg - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_lambda() [](#method-i-test_lambda) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserReqArg/Def1.md b/example/ruby/TestOptionParserReqArg/Def1.md deleted file mode 100644 index b8f0cd7..0000000 --- a/example/ruby/TestOptionParserReqArg/Def1.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestOptionParserReqArg::Def1 -**Inherits:** TestOptionParser - -**Includes:** TestOptionParserReqArg - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_lambda() [](#method-i-test_lambda) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserReqArg/Def2.md b/example/ruby/TestOptionParserReqArg/Def2.md deleted file mode 100644 index b554471..0000000 --- a/example/ruby/TestOptionParserReqArg/Def2.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestOptionParserReqArg::Def2 -**Inherits:** TestOptionParser - -**Includes:** TestOptionParserReqArg - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_lambda() [](#method-i-test_lambda) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserReqArg/Def3.md b/example/ruby/TestOptionParserReqArg/Def3.md deleted file mode 100644 index b9815e4..0000000 --- a/example/ruby/TestOptionParserReqArg/Def3.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestOptionParserReqArg::Def3 -**Inherits:** TestOptionParser - -**Includes:** TestOptionParserReqArg - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_lambda() [](#method-i-test_lambda) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserReqArg/Def4.md b/example/ruby/TestOptionParserReqArg/Def4.md deleted file mode 100644 index cb0e125..0000000 --- a/example/ruby/TestOptionParserReqArg/Def4.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestOptionParserReqArg::Def4 -**Inherits:** TestOptionParser - -**Includes:** TestOptionParserReqArg - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_abbrev() [](#method-i-test_abbrev) - -## test_hyphenize() [](#method-i-test_hyphenize) - -## test_lambda() [](#method-i-test_lambda) - -## test_long() [](#method-i-test_long) - -## test_short() [](#method-i-test_short) - diff --git a/example/ruby/TestOptionParserSummaryTest.md b/example/ruby/TestOptionParserSummaryTest.md deleted file mode 100644 index 67ae8f8..0000000 --- a/example/ruby/TestOptionParserSummaryTest.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: TestOptionParserSummaryTest -**Inherits:** TestOptionParser - - - - - -#Instance Methods -## test_banner() [](#method-i-test_banner) - -## test_banner_from_progname() [](#method-i-test_banner_from_progname) - -## test_short_clash() [](#method-i-test_short_clash) - -## test_summary() [](#method-i-test_summary) - -## test_summary_containing_space() [](#method-i-test_summary_containing_space) - -## test_ver() [](#method-i-test_ver) - -## test_very_long_without_short() [](#method-i-test_very_long_without_short) -https://github.com/ruby/optparse/issues/37 - diff --git a/example/ruby/TestOptionParserZshCompletion.md b/example/ruby/TestOptionParserZshCompletion.md deleted file mode 100644 index 7428d66..0000000 --- a/example/ruby/TestOptionParserZshCompletion.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestOptionParserZshCompletion -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_compsys() [](#method-i-test_compsys) - diff --git a/example/ruby/TestPTY.md b/example/ruby/TestPTY.md deleted file mode 100644 index 6b1bb98..0000000 --- a/example/ruby/TestPTY.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestPTY -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_argv0() [](#method-i-test_argv0) - -## test_cloexec() [](#method-i-test_cloexec) - -## test_close_in_block() [](#method-i-test_close_in_block) - -## test_close_master() [](#method-i-test_close_master) - -## test_close_slave() [](#method-i-test_close_slave) - -## test_commandline() [](#method-i-test_commandline) - -## test_getpty_nonexistent() [](#method-i-test_getpty_nonexistent) - -## test_open() [](#method-i-test_open) - -## test_open_with_block() [](#method-i-test_open_with_block) - -## test_open_without_block() [](#method-i-test_open_without_block) - -## test_pty_check_default() [](#method-i-test_pty_check_default) - -## test_pty_check_raise() [](#method-i-test_pty_check_raise) - -## test_spawn_with_block() [](#method-i-test_spawn_with_block) - -## test_spawn_without_block() [](#method-i-test_spawn_without_block) - -## test_stat_slave() [](#method-i-test_stat_slave) - diff --git a/example/ruby/TestPack.md b/example/ruby/TestPack.md deleted file mode 100644 index d8bbd7c..0000000 --- a/example/ruby/TestPack.md +++ /dev/null @@ -1,120 +0,0 @@ -# Class: TestPack -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## _integer_big_endian(mod'') [](#method-i-_integer_big_endian) - -## _integer_little_endian(mod'') [](#method-i-_integer_little_endian) - -## test_ascii_incompatible() [](#method-i-test_ascii_incompatible) - -## test_bug_18343() [](#method-i-test_bug_18343) - -## test_comment() [](#method-i-test_comment) - -## test_format_string_modified() [](#method-i-test_format_string_modified) - -## test_illegal_bang() [](#method-i-test_illegal_bang) - -## test_integer_endian() [](#method-i-test_integer_endian) - -## test_integer_endian_explicit() [](#method-i-test_integer_endian_explicit) - -## test_invalid_warning() [](#method-i-test_invalid_warning) - -## test_length_too_big() [](#method-i-test_length_too_big) - -## test_monkey_pack() [](#method-i-test_monkey_pack) - -## test_monkey_pack_buffer() [](#method-i-test_monkey_pack_buffer) - -## test_pack() [](#method-i-test_pack) - -## test_pack_N() [](#method-i-test_pack_N) - -## test_pack_P() [](#method-i-test_pack_P) - -## test_pack_U() [](#method-i-test_pack_U) - -## test_pack_garbage() [](#method-i-test_pack_garbage) - -## test_pack_n() [](#method-i-test_pack_n) - -## test_pack_p() [](#method-i-test_pack_p) - -## test_pack_p2() [](#method-i-test_pack_p2) - -## test_pack_resize() [](#method-i-test_pack_resize) - -## test_pack_unpack_M() [](#method-i-test_pack_unpack_M) - -## test_pack_unpack_P2() [](#method-i-test_pack_unpack_P2) - -## test_pack_unpack_U() [](#method-i-test_pack_unpack_U) - -## test_pack_unpack_X() [](#method-i-test_pack_unpack_X) - -## test_pack_unpack_Z() [](#method-i-test_pack_unpack_Z) - -## test_pack_unpack_aA() [](#method-i-test_pack_unpack_aA) - -## test_pack_unpack_atmark() [](#method-i-test_pack_unpack_atmark) - -## test_pack_unpack_bB() [](#method-i-test_pack_unpack_bB) - -## test_pack_unpack_cC() [](#method-i-test_pack_unpack_cC) - -## test_pack_unpack_fdeEgG() [](#method-i-test_pack_unpack_fdeEgG) - -## test_pack_unpack_hH() [](#method-i-test_pack_unpack_hH) - -## test_pack_unpack_iI() [](#method-i-test_pack_unpack_iI) - -## test_pack_unpack_jJ() [](#method-i-test_pack_unpack_jJ) - -## test_pack_unpack_lL() [](#method-i-test_pack_unpack_lL) - -## test_pack_unpack_m() [](#method-i-test_pack_unpack_m) - -## test_pack_unpack_m0() [](#method-i-test_pack_unpack_m0) - -## test_pack_unpack_nN() [](#method-i-test_pack_unpack_nN) - -## test_pack_unpack_percent() [](#method-i-test_pack_unpack_percent) - -## test_pack_unpack_qQ() [](#method-i-test_pack_unpack_qQ) - -## test_pack_unpack_sS() [](#method-i-test_pack_unpack_sS) - -## test_pack_unpack_u() [](#method-i-test_pack_unpack_u) - -## test_pack_unpack_vV() [](#method-i-test_pack_unpack_vV) - -## test_pack_unpack_w() [](#method-i-test_pack_unpack_w) - -## test_pack_unpack_x() [](#method-i-test_pack_unpack_x) - -## test_pack_with_buffer() [](#method-i-test_pack_with_buffer) - -## test_short_string() [](#method-i-test_short_string) - -## test_short_with_block() [](#method-i-test_short_with_block) - -## test_unpack1() [](#method-i-test_unpack1) - -## test_unpack1_offset() [](#method-i-test_unpack1_offset) - -## test_unpack_N() [](#method-i-test_unpack_N) - -## test_unpack_garbage() [](#method-i-test_unpack_garbage) - -## test_unpack_n() [](#method-i-test_unpack_n) - -## test_unpack_offset() [](#method-i-test_unpack_offset) - -## test_unpack_with_block() [](#method-i-test_unpack_with_block) - diff --git a/example/ruby/TestParallel.md b/example/ruby/TestParallel.md deleted file mode 100644 index f41076b..0000000 --- a/example/ruby/TestParallel.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestParallel - - - - - diff --git a/example/ruby/TestParallel/TestParallel.md b/example/ruby/TestParallel/TestParallel.md deleted file mode 100644 index 1a18e95..0000000 --- a/example/ruby/TestParallel/TestParallel.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestParallel::TestParallel -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## spawn_runner(*opt_args, jobs:"t1") [](#method-i-spawn_runner) - -## teardown() [](#method-i-teardown) - -## test_hungup() [](#method-i-test_hungup) - -## test_ignore_jzero() [](#method-i-test_ignore_jzero) - -## test_jobs_status() [](#method-i-test_jobs_status) - -## test_no_retry_option() [](#method-i-test_no_retry_option) - -## test_retry_workers() [](#method-i-test_retry_workers) - -## test_separate() [](#method-i-test_separate) - -## test_should_retry_failed_on_workers() [](#method-i-test_should_retry_failed_on_workers) - -## test_should_run_all_without_any_leaks() [](#method-i-test_should_run_all_without_any_leaks) - diff --git a/example/ruby/TestParallel/TestParallelWorker.md b/example/ruby/TestParallel/TestParallelWorker.md deleted file mode 100644 index cd6f97e..0000000 --- a/example/ruby/TestParallel/TestParallelWorker.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestParallel::TestParallelWorker -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_accept_run_command_multiple_times() [](#method-i-test_accept_run_command_multiple_times) - -## test_done() [](#method-i-test_done) - -## test_p() [](#method-i-test_p) - -## test_quit() [](#method-i-test_quit) - -## test_run() [](#method-i-test_run) - -## test_run_multiple_testcase_in_one_file() [](#method-i-test_run_multiple_testcase_in_one_file) - diff --git a/example/ruby/TestParse.md b/example/ruby/TestParse.md deleted file mode 100644 index f8f445f..0000000 --- a/example/ruby/TestParse.md +++ /dev/null @@ -1,229 +0,0 @@ -# Class: TestParse -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_disallowed_variable(type, noname, invalid) [](#method-i-assert_disallowed_variable) - -## assert_nonascii_const() [](#method-i-assert_nonascii_const) - -## assert_not_ractor_shareable(obj) [](#method-i-assert_not_ractor_shareable) - -## assert_parse(code) [](#method-i-assert_parse) -def test_past_scope_variable - assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}} - end - -## assert_parse_error(code, message) [](#method-i-assert_parse_error) - -## assert_ractor_shareable(obj) [](#method-i-assert_ractor_shareable) - -## assert_raise_separately(error, message, code) [](#method-i-assert_raise_separately) - -## eval_separately(code) [](#method-i-eval_separately) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_alias_backref() [](#method-i-test_alias_backref) - -## test_arg() [](#method-i-test_arg) - -## test_arg2() [](#method-i-test_arg2) - -## test_assign_in_conditional() [](#method-i-test_assign_in_conditional) - -## test_backquote() [](#method-i-test_backquote) - -## test_bad_arg() [](#method-i-test_bad_arg) - -## test_block_call_colon2() [](#method-i-test_block_call_colon2) - -## test_block_dup() [](#method-i-test_block_dup) - -## test_block_variable() [](#method-i-test_block_variable) - -## test_call_method() [](#method-i-test_call_method) - -## test_carrige_return() [](#method-i-test_carrige_return) - -## test_cdmarg_after_command_args_and_tlbrace_arg() [](#method-i-test_cdmarg_after_command_args_and_tlbrace_arg) - -## test_class_module() [](#method-i-test_class_module) - -## test_command_call() [](#method-i-test_command_call) - -## test_command_def_cmdarg() [](#method-i-test_command_def_cmdarg) - -## test_define_singleton_error() [](#method-i-test_define_singleton_error) - -## test_disallowed_class_variable() [](#method-i-test_disallowed_class_variable) - -## test_disallowed_gloal_variable() [](#method-i-test_disallowed_gloal_variable) - -## test_disallowed_instance_variable() [](#method-i-test_disallowed_instance_variable) - -## test_do_lambda() [](#method-i-test_do_lambda) - -## test_dot_in_next_line() [](#method-i-test_dot_in_next_line) - -## test_dstr() [](#method-i-test_dstr) - -## test_dstr_disallowed_variable() [](#method-i-test_dstr_disallowed_variable) - -## test_dsym() [](#method-i-test_dsym) - -## test_duplicate_argument() [](#method-i-test_duplicate_argument) - -## test_dynamic_constant_assignment() [](#method-i-test_dynamic_constant_assignment) - -## test_else_without_rescue() [](#method-i-test_else_without_rescue) - -## test_embedded_rd() [](#method-i-test_embedded_rd) - -## test_embedded_rd_error() [](#method-i-test_embedded_rd_error) - -## test_eof() [](#method-i-test_eof) - -## test_eof_in_def() [](#method-i-test_eof_in_def) - -## test_error_def_in_argument() [](#method-i-test_error_def_in_argument) - -## test_error_line() [](#method-i-test_error_line) - -## test_escaped_space() [](#method-i-test_escaped_space) - -## test_file_in_indented_heredoc() [](#method-i-test_file_in_indented_heredoc) - -## test_flip_flop() [](#method-i-test_flip_flop) - -## test_float() [](#method-i-test_float) - -## test_global_variable() [](#method-i-test_global_variable) - -## test_here_document() [](#method-i-test_here_document) - -## test_heredoc_interpolation() [](#method-i-test_heredoc_interpolation) - -## test_heredoc_unterminated_interpolation() [](#method-i-test_heredoc_unterminated_interpolation) - -## test_if_after_class() [](#method-i-test_if_after_class) - -## test_invalid_char() [](#method-i-test_invalid_char) - -## test_invalid_class_variable() [](#method-i-test_invalid_class_variable) - -## test_invalid_instance_variable() [](#method-i-test_invalid_instance_variable) - -## test_label() [](#method-i-test_label) - -## test_literal_concat() [](#method-i-test_literal_concat) - -## test_literal_in_conditional() [](#method-i-test_literal_in_conditional) - -## test_location_of_invalid_token() [](#method-i-test_location_of_invalid_token) - -## test_lparenarg() [](#method-i-test_lparenarg) - -## test_magic_comment() [](#method-i-test_magic_comment) - -## test_method_block_location() [](#method-i-test_method_block_location) - -## test_method_location_in_rescue() [](#method-i-test_method_location_in_rescue) - -## test_mlhs_node() [](#method-i-test_mlhs_node) - -## test_named_capture_conflict() [](#method-i-test_named_capture_conflict) - -## test_named_capture_in_block() [](#method-i-test_named_capture_in_block) - -## test_negative_line_number() [](#method-i-test_negative_line_number) - -## test_no_blockarg() [](#method-i-test_no_blockarg) - -## test_no_shadowing_variable_warning() [](#method-i-test_no_shadowing_variable_warning) - -## test_nonascii_const_set() [](#method-i-test_nonascii_const_set) - -## test_nonascii_constant() [](#method-i-test_nonascii_constant) - -## test_op_asgn1_with_block() [](#method-i-test_op_asgn1_with_block) - -## test_op_name() [](#method-i-test_op_name) - -## test_parse_string() [](#method-i-test_parse_string) - -## test_parsing_begin_statement_inside_method_definition() [](#method-i-test_parsing_begin_statement_inside_method_definition) - -## test_percent() [](#method-i-test_percent) - -## test_pow_asgn() [](#method-i-test_pow_asgn) - -## test_question() [](#method-i-test_question) - -## test_rescue_in_command_assignment() [](#method-i-test_rescue_in_command_assignment) - -## test_serial_comparison() [](#method-i-test_serial_comparison) - -## test_set_backref() [](#method-i-test_set_backref) - -## test_shadowing_private_local_variable() [](#method-i-test_shadowing_private_local_variable) - -## test_shareable_constant_value_hash_with_keyword_splat() [](#method-i-test_shareable_constant_value_hash_with_keyword_splat) - -## test_shareable_constant_value_ignored() [](#method-i-test_shareable_constant_value_ignored) - -## test_shareable_constant_value_invalid() [](#method-i-test_shareable_constant_value_invalid) - -## test_shareable_constant_value_literal_const_refs() [](#method-i-test_shareable_constant_value_literal_const_refs) - -## test_shareable_constant_value_nested() [](#method-i-test_shareable_constant_value_nested) - -## test_shareable_constant_value_nonliteral() [](#method-i-test_shareable_constant_value_nonliteral) - -## test_shareable_constant_value_simple() [](#method-i-test_shareable_constant_value_simple) - -## test_shareable_constant_value_unfrozen() [](#method-i-test_shareable_constant_value_unfrozen) - -## test_shareable_constant_value_unshareable_literal() [](#method-i-test_shareable_constant_value_unshareable_literal) - -## test_string() [](#method-i-test_string) - -## test_symbol() [](#method-i-test_symbol) - -## test_truncated_source_line() [](#method-i-test_truncated_source_line) - -## test_unassignable() [](#method-i-test_unassignable) - -## test_unclosed_unicode_escape_at_eol_bug_19750() [](#method-i-test_unclosed_unicode_escape_at_eol_bug_19750) - -## test_unexpected_eof() [](#method-i-test_unexpected_eof) - -## test_unexpected_token_after_numeric() [](#method-i-test_unexpected_token_after_numeric) - -## test_unexpected_token_error() [](#method-i-test_unexpected_token_error) - -## test_ungettable_gvar() [](#method-i-test_ungettable_gvar) - -## test_unterminated_regexp_error() [](#method-i-test_unterminated_regexp_error) - -## test_unused_variable() [](#method-i-test_unused_variable) - -## test_utf8_bom() [](#method-i-test_utf8_bom) - -## test_void_expr_stmts_value() [](#method-i-test_void_expr_stmts_value) - -## test_void_value_in_rhs() [](#method-i-test_void_value_in_rhs) - -## test_whitespace_warning() [](#method-i-test_whitespace_warning) - -## test_words() [](#method-i-test_words) - -## test_xstring() [](#method-i-test_xstring) - -## test_yyerror_at_eol() [](#method-i-test_yyerror_at_eol) - diff --git a/example/ruby/TestPath.md b/example/ruby/TestPath.md deleted file mode 100644 index d97c967..0000000 --- a/example/ruby/TestPath.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestPath -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_ascii_incompatible_path() [](#method-i-test_ascii_incompatible_path) - -## test_basename() [](#method-i-test_basename) - -## test_dirname() [](#method-i-test_dirname) - -## test_extname() [](#method-i-test_extname) - -## test_join() [](#method-i-test_join) - -## test_path() [](#method-i-test_path) - diff --git a/example/ruby/TestPathname.md b/example/ruby/TestPathname.md deleted file mode 100644 index 5b60e65..0000000 --- a/example/ruby/TestPathname.md +++ /dev/null @@ -1,348 +0,0 @@ -# Class: TestPathname -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## defassert(name , result , *args ) [](#method-c-defassert) -## defassert_raise(name , exc , *args ) [](#method-c-defassert_raise) -## define_assertion(name , linenum , &block ) [](#method-c-define_assertion) -## get_linenum() [](#method-c-get_linenum) - -#Instance Methods -## add_trailing_separator(path) [](#method-i-add_trailing_separator) - -## ascend(path) [](#method-i-ascend) - -## assert_mode(val, mask, path, mesgnil) [](#method-i-assert_mode) - -## assert_pathname_cmp(e, s1, s2) [](#method-i-assert_pathname_cmp) - -## cleanpath_aggressive(path) [](#method-i-cleanpath_aggressive) - -## cleanpath_conservative(path) [](#method-i-cleanpath_conservative) - -## del_trailing_separator(path) [](#method-i-del_trailing_separator) - -## descend(path) [](#method-i-descend) - -## has_hardlink?() [](#method-i-has_hardlink?) - -**@return** [Boolean] - -## has_symlink?() [](#method-i-has_symlink?) - -**@return** [Boolean] - -## has_trailing_separator?(path) [](#method-i-has_trailing_separator?) -has_trailing_separator?(path) -> bool - -**@return** [Boolean] - -## parent(path) [](#method-i-parent) --> path - -## pathsub(path, pat, repl) [](#method-i-pathsub) - -## pathsubext(path, repl) [](#method-i-pathsubext) - -## plus(path1, path2) [](#method-i-plus) --> path - -## realdirpath(path) [](#method-i-realdirpath) - -## realpath(path, basedirnil) [](#method-i-realpath) - -## relative?(path) [](#method-i-relative?) - -**@return** [Boolean] - -## relative_path_from(dest_directory, base_directory) [](#method-i-relative_path_from) - -## root?(path) [](#method-i-root?) - -**@return** [Boolean] - -## test_absolute() [](#method-i-test_absolute) - -## test_atime() [](#method-i-test_atime) - -## test_basename() [](#method-i-test_basename) - -## test_binread() [](#method-i-test_binread) - -## test_binwrite() [](#method-i-test_binwrite) - -## test_binwrite_opts() [](#method-i-test_binwrite_opts) - -## test_birthtime() [](#method-i-test_birthtime) - -## test_blockdev?() [](#method-i-test_blockdev?) - -**@return** [Boolean] - -## test_blockless_ascend_is_enumerator() [](#method-i-test_blockless_ascend_is_enumerator) - -## test_blockless_descend_is_enumerator() [](#method-i-test_blockless_descend_is_enumerator) - -## test_chardev?() [](#method-i-test_chardev?) - -**@return** [Boolean] - -## test_children() [](#method-i-test_children) - -## test_chmod() [](#method-i-test_chmod) - -## test_chown() [](#method-i-test_chown) - -## test_comparison() [](#method-i-test_comparison) - -## test_comparison_string() [](#method-i-test_comparison_string) - -## test_ctime() [](#method-i-test_ctime) - -## test_destructive_update() [](#method-i-test_destructive_update) - -## test_directory?() [](#method-i-test_directory?) - -**@return** [Boolean] - -## test_dirname() [](#method-i-test_dirname) - -## test_each_child() [](#method-i-test_each_child) - -## test_each_entry() [](#method-i-test_each_entry) - -## test_each_entry_enumerator() [](#method-i-test_each_entry_enumerator) - -## test_each_filename() [](#method-i-test_each_filename) - -## test_each_line() [](#method-i-test_each_line) - -## test_each_line_opts() [](#method-i-test_each_line_opts) - -## test_empty?() [](#method-i-test_empty?) - -**@return** [Boolean] - -## test_entries() [](#method-i-test_entries) - -## test_equality() [](#method-i-test_equality) - -## test_executable?() [](#method-i-test_executable?) - -**@return** [Boolean] - -## test_executable_real?() [](#method-i-test_executable_real?) - -**@return** [Boolean] - -## test_exist?() [](#method-i-test_exist?) - -**@return** [Boolean] - -## test_expand_path() [](#method-i-test_expand_path) - -## test_extname() [](#method-i-test_extname) - -## test_file?() [](#method-i-test_file?) - -**@return** [Boolean] - -## test_file_basename() [](#method-i-test_file_basename) - -## test_file_dirname() [](#method-i-test_file_dirname) - -## test_file_extname() [](#method-i-test_file_extname) - -## test_file_fnmatch() [](#method-i-test_file_fnmatch) - -## test_file_split() [](#method-i-test_file_split) - -## test_find() [](#method-i-test_find) - -## test_fnmatch() [](#method-i-test_fnmatch) - -## test_fnmatch?() [](#method-i-test_fnmatch?) - -**@return** [Boolean] - -## test_freeze() [](#method-i-test_freeze) - -## test_ftype() [](#method-i-test_ftype) - -## test_glob() [](#method-i-test_glob) - -## test_global_constructor() [](#method-i-test_global_constructor) - -## test_grpowned?() [](#method-i-test_grpowned?) - -**@return** [Boolean] - -## test_hashkey() [](#method-i-test_hashkey) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_nul() [](#method-i-test_initialize_nul) - -## test_join() [](#method-i-test_join) - -## test_kernel_open() [](#method-i-test_kernel_open) - -## test_kernel_pathname() [](#method-i-test_kernel_pathname) - -## test_lchmod() [](#method-i-test_lchmod) - -## test_lchown() [](#method-i-test_lchown) - -## test_lstat() [](#method-i-test_lstat) - -## test_lutime() [](#method-i-test_lutime) - -## test_make_link() [](#method-i-test_make_link) - -## test_make_symlink() [](#method-i-test_make_symlink) - -## test_matchop() [](#method-i-test_matchop) - -## test_mkdir() [](#method-i-test_mkdir) - -## test_mkpath() [](#method-i-test_mkpath) - -## test_mktmpdir() [](#method-i-test_mktmpdir) - -## test_mountpoint?() [](#method-i-test_mountpoint?) - -**@return** [Boolean] - -## test_mountpoint_enoent() [](#method-i-test_mountpoint_enoent) - -## test_mtime() [](#method-i-test_mtime) - -## test_null_character() [](#method-i-test_null_character) - -## test_open() [](#method-i-test_open) - -## test_opendir() [](#method-i-test_opendir) - -## test_owned?() [](#method-i-test_owned?) - -**@return** [Boolean] - -## test_parent() [](#method-i-test_parent) - -## test_pipe?() [](#method-i-test_pipe?) - -**@return** [Boolean] - -## test_plus() [](#method-i-test_plus) - -## test_read() [](#method-i-test_read) - -## test_readable?() [](#method-i-test_readable?) - -**@return** [Boolean] - -## test_readable_real?() [](#method-i-test_readable_real?) - -**@return** [Boolean] - -## test_readlines() [](#method-i-test_readlines) - -## test_readlines_opts() [](#method-i-test_readlines_opts) - -## test_readlink() [](#method-i-test_readlink) - -## test_realdirpath() [](#method-i-test_realdirpath) - -## test_realpath() [](#method-i-test_realpath) - -## test_relative_path_from_casefold() [](#method-i-test_relative_path_from_casefold) - -## test_relative_path_from_mock() [](#method-i-test_relative_path_from_mock) - -## test_rename() [](#method-i-test_rename) - -## test_rmdir() [](#method-i-test_rmdir) - -## test_rmtree() [](#method-i-test_rmtree) - -## test_s_getwd() [](#method-i-test_s_getwd) - -## test_s_glob() [](#method-i-test_s_glob) - -## test_s_glob_3args() [](#method-i-test_s_glob_3args) - -## test_s_pwd() [](#method-i-test_s_pwd) - -## test_setgid?() [](#method-i-test_setgid?) - -**@return** [Boolean] - -## test_setuid?() [](#method-i-test_setuid?) - -**@return** [Boolean] - -## test_size() [](#method-i-test_size) - -## test_size?() [](#method-i-test_size?) - -**@return** [Boolean] - -## test_slash() [](#method-i-test_slash) - -## test_socket?() [](#method-i-test_socket?) - -**@return** [Boolean] - -## test_split() [](#method-i-test_split) - -## test_stat() [](#method-i-test_stat) - -## test_sticky?() [](#method-i-test_sticky?) - -**@return** [Boolean] - -## test_sub_matchdata() [](#method-i-test_sub_matchdata) - -## test_symlink?() [](#method-i-test_symlink?) - -**@return** [Boolean] - -## test_sysopen() [](#method-i-test_sysopen) - -## test_to_s() [](#method-i-test_to_s) - -## test_truncate() [](#method-i-test_truncate) - -## test_unlink() [](#method-i-test_unlink) - -## test_utime() [](#method-i-test_utime) - -## test_world_readable?() [](#method-i-test_world_readable?) - -**@return** [Boolean] - -## test_world_writable?() [](#method-i-test_world_writable?) - -**@return** [Boolean] - -## test_writable?() [](#method-i-test_writable?) - -**@return** [Boolean] - -## test_writable_real?() [](#method-i-test_writable_real?) - -**@return** [Boolean] - -## test_write() [](#method-i-test_write) - -## test_write_opts() [](#method-i-test_write_opts) - -## test_zero?() [](#method-i-test_zero?) - -**@return** [Boolean] - -## with_tmpchdir(basenil) [](#method-i-with_tmpchdir) - diff --git a/example/ruby/TestPathname/AnotherStringLike.md b/example/ruby/TestPathname/AnotherStringLike.md deleted file mode 100644 index ede99c5..0000000 --- a/example/ruby/TestPathname/AnotherStringLike.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: TestPathname::AnotherStringLike -**Inherits:** Object - - -:nodoc: - - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize(s) [](#method-i-initialize) - -**@return** [AnotherStringLike] a new instance of AnotherStringLike - -## to_str() [](#method-i-to_str) - diff --git a/example/ruby/TestPathnameRactor.md b/example/ruby/TestPathnameRactor.md deleted file mode 100644 index fc23292..0000000 --- a/example/ruby/TestPathnameRactor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestPathnameRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ractor_shareable() [](#method-i-test_ractor_shareable) - diff --git a/example/ruby/TestPipe.md b/example/ruby/TestPipe.md deleted file mode 100644 index 920115a..0000000 --- a/example/ruby/TestPipe.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestPipe -**Inherits:** Test::Unit::TestCase - -**Includes:** TestEOF - - - - - -#Instance Methods -## open_file(content) [](#method-i-open_file) - -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - -## test_stdout_epipe() [](#method-i-test_stdout_epipe) - diff --git a/example/ruby/TestPipe/WithConversion.md b/example/ruby/TestPipe/WithConversion.md deleted file mode 100644 index 7d6b0b8..0000000 --- a/example/ruby/TestPipe/WithConversion.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestPipe::WithConversion -**Inherits:** TestPipe - - - - - -#Instance Methods -## open_file(content) [](#method-i-open_file) - diff --git a/example/ruby/TestPopenDeadlock.md b/example/ruby/TestPopenDeadlock.md deleted file mode 100644 index 14bf254..0000000 --- a/example/ruby/TestPopenDeadlock.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestPopenDeadlock -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/TestPostponed_job.md b/example/ruby/TestPostponed_job.md deleted file mode 100644 index b2dc85b..0000000 --- a/example/ruby/TestPostponed_job.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestPostponed_job -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_legacy_register() [](#method-i-test_legacy_register) - -## test_legacy_register_in_c_thread() [](#method-i-test_legacy_register_in_c_thread) - -## test_legacy_register_one_same() [](#method-i-test_legacy_register_one_same) - -## test_multiple_preregistration() [](#method-i-test_multiple_preregistration) - -## test_multiple_preregistration_with_new_data() [](#method-i-test_multiple_preregistration_with_new_data) - -## test_preregister_and_trigger() [](#method-i-test_preregister_and_trigger) - diff --git a/example/ruby/TestProc.md b/example/ruby/TestProc.md deleted file mode 100644 index 7e0ec42..0000000 --- a/example/ruby/TestProc.md +++ /dev/null @@ -1,327 +0,0 @@ -# Class: TestProc -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## a() [](#method-c-a) -**@yield** [arg] - -## capture(&block ) [](#method-c-capture) -## respond_to?(m ) [](#method-c-respond_to?) -**@return** [Boolean] - -## yielder(splat ) [](#method-c-yielder) -**@yield** [splat] - -## yielder_ab(splat ) [](#method-c-yielder_ab) -**@yield** [[:a, :b], splat] - -# Attributes -## attr_accessor_source_location_test[RW] [](#attribute-i-attr_accessor_source_location_test) -Returns the value of attribute attr_accessor_source_location_test. - -## attr_reader_source_location_test[RW] [](#attribute-i-attr_reader_source_location_test) -Returns the value of attribute attr_reader_source_location_test. - -## attr_writer_source_location_test=[R] [](#attribute-i-attr_writer_source_location_test=) -Sets the attribute attr_writer_source_location_test - -**@param** [] the value to set the attribute attr_writer_source_location_test to. - - -#Instance Methods -## assert_arity(n, &block) [](#method-i-assert_arity) - -## block() [](#method-i-block) - -## block_source_location_test(*args, &block) [](#method-i-block_source_location_test) - -## foo() [](#method-i-foo) - -## get_binding(if:1, case:2, when:3, begin:4, end:5) [](#method-i-get_binding) - -## helper_test_warn_lambda_with_passed_block(&b) [](#method-i-helper_test_warn_lambda_with_passed_block) - -## local_variables_of(bind) [](#method-i-local_variables_of) - -## m(x) [](#method-i-m) - -## m1(var) [](#method-i-m1) - -## m2() [](#method-i-m2) - -## m_block_given?() [](#method-i-m_block_given?) - -**@return** [Boolean] - -## m_nest(&block) [](#method-i-m_nest) - -## m_nest0(&block) [](#method-i-m_nest0) - -## pm0() [](#method-i-pm0) - -## pm1(a) [](#method-i-pm1) - -## pm2(a, b) [](#method-i-pm2) - -## pma1(a, &b) [](#method-i-pma1) - -## pmk1() [](#method-i-pmk1) - -## pmk2(**o) [](#method-i-pmk2) - -## pmk3(a, **o) [](#method-i-pmk3) - -## pmk4(anil, **o) [](#method-i-pmk4) - -## pmk5(a, bnil, **o) [](#method-i-pmk5) - -## pmk6(a, bnil, c, **o) [](#method-i-pmk6) - -## pmk7(a, bnil, *c, d, **o) [](#method-i-pmk7) - -## pmo1(a:a, &b) [](#method-i-pmo1) - -## pmo2(a, b:b) [](#method-i-pmo2) - -## pmo3(*a) [](#method-i-pmo3) - -## pmo4(a, *b, &c) [](#method-i-pmo4) - -## pmo5(a, *b, c) [](#method-i-pmo5) - -## pmo6(a, *b, c, &d) [](#method-i-pmo6) - -## pmo7(a, b:b, *c, d, &e) [](#method-i-pmo7) - -## setup() [](#method-i-setup) - -## source_location_test(a1, b2) [](#method-i-source_location_test) - -## teardown() [](#method-i-teardown) - -## test_arity() [](#method-i-test_arity) - -## test_arity2() [](#method-i-test_arity2) - -## test_attr_source_location() [](#method-i-test_attr_source_location) - -## test_binding() [](#method-i-test_binding) - -## test_binding_error_unless_ruby_frame() [](#method-i-test_binding_error_unless_ruby_frame) - -## test_binding_receiver() [](#method-i-test_binding_receiver) - -## test_binding_source_location() [](#method-i-test_binding_source_location) - -## test_block_given_method() [](#method-i-test_block_given_method) - -## test_block_given_method_to_proc() [](#method-i-test_block_given_method_to_proc) - -## test_block_par() [](#method-i-test_block_par) - -## test_block_persist_between_calls() [](#method-i-test_block_persist_between_calls) - -## test_block_propagation() [](#method-i-test_block_propagation) - -## test_block_source_location() [](#method-i-test_block_source_location) - -## test_bound_parameters() [](#method-i-test_bound_parameters) - -## test_clone_subclass() [](#method-i-test_clone_subclass) - -## test_compose() [](#method-i-test_compose) - -## test_compose_with_block() [](#method-i-test_compose_with_block) - -## test_compose_with_callable() [](#method-i-test_compose_with_callable) - -## test_compose_with_lambda() [](#method-i-test_compose_with_lambda) - -## test_compose_with_method() [](#method-i-test_compose_with_method) - -## test_compose_with_multiple_args() [](#method-i-test_compose_with_multiple_args) - -## test_compose_with_noncallable() [](#method-i-test_compose_with_noncallable) - -## test_curry_binding() [](#method-i-test_curry_binding) - -## test_curry_given_blocks() [](#method-i-test_curry_given_blocks) - -## test_curry_instance_exec() [](#method-i-test_curry_instance_exec) - -## test_curry_lambda() [](#method-i-test_curry_lambda) - -## test_curry_lambda_splat() [](#method-i-test_curry_lambda_splat) - -## test_curry_no_arguments() [](#method-i-test_curry_no_arguments) - -## test_curry_optional_params() [](#method-i-test_curry_optional_params) - -## test_curry_passed_block() [](#method-i-test_curry_passed_block) - -## test_curry_proc() [](#method-i-test_curry_proc) - -## test_curry_proc_splat() [](#method-i-test_curry_proc_splat) - -## test_curry_ski_fib() [](#method-i-test_curry_ski_fib) - -## test_curry_with_trace() [](#method-i-test_curry_with_trace) - -## test_dup_clone() [](#method-i-test_dup_clone) - -## test_dup_ifunc_proc_bug_20950() [](#method-i-test_dup_ifunc_proc_bug_20950) - -## test_dup_subclass() [](#method-i-test_dup_subclass) - -## test_eq() [](#method-i-test_eq) - -## test_hash_does_not_change_after_compaction() [](#method-i-test_hash_does_not_change_after_compaction) - -## test_hash_equal() [](#method-i-test_hash_equal) - -## test_hash_uniqueness() [](#method-i-test_hash_uniqueness) - -## test_isolate() [](#method-i-test_isolate) - -## test_lambda?() [](#method-i-test_lambda?) - -**@return** [Boolean] - -## test_lambda_warning_pass_block() [](#method-i-test_lambda_warning_pass_block) - -## test_lambda_warning_pass_proc() [](#method-i-test_lambda_warning_pass_proc) - -## test_local_variable_defined?() [](#method-i-test_local_variable_defined?) - -**@return** [Boolean] - -## test_local_variable_get() [](#method-i-test_local_variable_get) - -## test_local_variable_set() [](#method-i-test_local_variable_set) - -## test_local_variable_set_wb() [](#method-i-test_local_variable_set_wb) - -## test_local_variables() [](#method-i-test_local_variables) - -## test_local_variables_in_other_context() [](#method-i-test_local_variables_in_other_context) - -## test_local_variables_nested() [](#method-i-test_local_variables_nested) - -## test_localjump_error() [](#method-i-test_localjump_error) - -## test_method_to_proc() [](#method-i-test_method_to_proc) -yarv-dev:777 -: block made by Method#to_proc - - -## test_not_orphan_next() [](#method-i-test_not_orphan_next) - -## test_orphan_break() [](#method-i-test_orphan_break) - -## test_orphan_return() [](#method-i-test_orphan_return) - -## test_overridden_lambda() [](#method-i-test_overridden_lambda) - -## test_overridden_proc() [](#method-i-test_overridden_proc) - -## test_parameters() [](#method-i-test_parameters) - -## test_parameters_lambda() [](#method-i-test_parameters_lambda) - -## test_prepended_call() [](#method-i-test_prepended_call) - -## test_proc() [](#method-i-test_proc) - -## test_proc_args_multiple_kw_autosplat() [](#method-i-test_proc_args_multiple_kw_autosplat) - -## test_proc_args_multiple_kwsplat_autosplat() [](#method-i-test_proc_args_multiple_kwsplat_autosplat) - -## test_proc_args_only_rest() [](#method-i-test_proc_args_only_rest) - -## test_proc_args_opt() [](#method-i-test_proc_args_opt) - -## test_proc_args_opt_block() [](#method-i-test_proc_args_opt_block) - -## test_proc_args_opt_post() [](#method-i-test_proc_args_opt_post) - -## test_proc_args_opt_post_block() [](#method-i-test_proc_args_opt_post_block) - -## test_proc_args_opt_rest() [](#method-i-test_proc_args_opt_rest) - -## test_proc_args_opt_rest_block() [](#method-i-test_proc_args_opt_rest_block) - -## test_proc_args_opt_rest_post() [](#method-i-test_proc_args_opt_rest_post) - -## test_proc_args_opt_rest_post_block() [](#method-i-test_proc_args_opt_rest_post_block) - -## test_proc_args_opt_single() [](#method-i-test_proc_args_opt_single) - -## test_proc_args_plain() [](#method-i-test_proc_args_plain) - -## test_proc_args_pos_block() [](#method-i-test_proc_args_pos_block) - -## test_proc_args_pos_opt() [](#method-i-test_proc_args_pos_opt) - -## test_proc_args_pos_opt_block() [](#method-i-test_proc_args_pos_opt_block) - -## test_proc_args_pos_opt_post() [](#method-i-test_proc_args_pos_opt_post) - -## test_proc_args_pos_opt_post_block() [](#method-i-test_proc_args_pos_opt_post_block) - -## test_proc_args_pos_opt_rest() [](#method-i-test_proc_args_pos_opt_rest) - -## test_proc_args_pos_opt_rest_block() [](#method-i-test_proc_args_pos_opt_rest_block) - -## test_proc_args_pos_opt_rest_post() [](#method-i-test_proc_args_pos_opt_rest_post) - -## test_proc_args_pos_opt_rest_post_block() [](#method-i-test_proc_args_pos_opt_rest_post_block) - -## test_proc_args_pos_rest_block() [](#method-i-test_proc_args_pos_rest_block) - -## test_proc_args_pos_rest_post() [](#method-i-test_proc_args_pos_rest_post) - -## test_proc_args_pos_rest_post_block() [](#method-i-test_proc_args_pos_rest_post_block) - -## test_proc_args_pos_unleashed() [](#method-i-test_proc_args_pos_unleashed) - -## test_proc_args_rest() [](#method-i-test_proc_args_rest) - -## test_proc_args_rest_block() [](#method-i-test_proc_args_rest_block) - -## test_proc_args_rest_kw() [](#method-i-test_proc_args_rest_kw) - -## test_proc_args_rest_kwsplat() [](#method-i-test_proc_args_rest_kwsplat) - -## test_proc_args_rest_post() [](#method-i-test_proc_args_rest_post) - -## test_proc_args_rest_post_block() [](#method-i-test_proc_args_rest_post_block) - -## test_proc_args_single_kw_no_autosplat() [](#method-i-test_proc_args_single_kw_no_autosplat) - -## test_proc_args_single_kwsplat_no_autosplat() [](#method-i-test_proc_args_single_kwsplat_no_autosplat) - -## test_proc_autosplat() [](#method-i-test_proc_autosplat) - -## test_proc_autosplat_with_multiple_args_with_ruby2_keywords_splat_bug_19759() [](#method-i-test_proc_autosplat_with_multiple_args_with_ruby2_keywords_splat_bug_19759) - -## test_proc_lambda() [](#method-i-test_proc_lambda) - -## test_proc_location() [](#method-i-test_proc_location) - -## test_proc_mark() [](#method-i-test_proc_mark) - -## test_proc_single_arg_with_keywords_accepted_and_yielded() [](#method-i-test_proc_single_arg_with_keywords_accepted_and_yielded) - -## test_refined_call() [](#method-i-test_refined_call) - -## test_source_location() [](#method-i-test_source_location) - -## test_splat_without_respond_to() [](#method-i-test_splat_without_respond_to) - -## test_to_proc() [](#method-i-test_to_proc) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestProcKeywords.md b/example/ruby/TestProcKeywords.md deleted file mode 100644 index 55b306f..0000000 --- a/example/ruby/TestProcKeywords.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestProcKeywords -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_compose_keywords() [](#method-i-test_compose_keywords) - -## test_compose_keywords_method() [](#method-i-test_compose_keywords_method) - -## test_compose_keywords_non_proc() [](#method-i-test_compose_keywords_non_proc) - diff --git a/example/ruby/TestProcess.md b/example/ruby/TestProcess.md deleted file mode 100644 index 24d0ddd..0000000 --- a/example/ruby/TestProcess.md +++ /dev/null @@ -1,371 +0,0 @@ -# Class: TestProcess -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## windows?() [](#method-c-windows?) -**@return** [Boolean] - - -#Instance Methods -## _test_execopts_env_popen(cmd) [](#method-i-_test_execopts_env_popen) - -## assert_fail_too_long_path(cmd, sep, mesg) [](#method-i-assert_fail_too_long_path) - -## rlimit_exist?() [](#method-i-rlimit_exist?) - -**@return** [Boolean] - -## run_in_child(str) [](#method-i-run_in_child) -should be called in a temporary directory - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test__fork() [](#method-i-test__fork) - -## test__fork_hook() [](#method-i-test__fork_hook) - -## test__fork_hook_popen() [](#method-i-test__fork_hook_popen) - -## test__fork_pid_cache() [](#method-i-test__fork_pid_cache) - -## test__fork_wrong_type_hook() [](#method-i-test__fork_wrong_type_hook) - -## test_abort() [](#method-i-test_abort) - -## test_argv0() [](#method-i-test_argv0) - -## test_argv0_frozen() [](#method-i-test_argv0_frozen) - -## test_argv0_keep_alive() [](#method-i-test_argv0_keep_alive) - -## test_argv0_noarg() [](#method-i-test_argv0_noarg) - -## test_aspawn_too_long_path() [](#method-i-test_aspawn_too_long_path) - -## test_clock_getres() [](#method-i-test_clock_getres) - -## test_clock_getres_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID() [](#method-i-test_clock_getres_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) - -## test_clock_getres_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID() [](#method-i-test_clock_getres_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) - -## test_clock_getres_GETTIMEOFDAY_BASED_CLOCK_REALTIME() [](#method-i-test_clock_getres_GETTIMEOFDAY_BASED_CLOCK_REALTIME) - -## test_clock_getres_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC() [](#method-i-test_clock_getres_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) - -## test_clock_getres_TIMES_BASED_CLOCK_MONOTONIC() [](#method-i-test_clock_getres_TIMES_BASED_CLOCK_MONOTONIC) - -## test_clock_getres_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID() [](#method-i-test_clock_getres_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID) - -## test_clock_getres_TIME_BASED_CLOCK_REALTIME() [](#method-i-test_clock_getres_TIME_BASED_CLOCK_REALTIME) - -## test_clock_getres_constants() [](#method-i-test_clock_getres_constants) - -## test_clock_gettime() [](#method-i-test_clock_gettime) - -## test_clock_gettime_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID() [](#method-i-test_clock_gettime_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) - -## test_clock_gettime_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID() [](#method-i-test_clock_gettime_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) - -## test_clock_gettime_GETTIMEOFDAY_BASED_CLOCK_REALTIME() [](#method-i-test_clock_gettime_GETTIMEOFDAY_BASED_CLOCK_REALTIME) - -## test_clock_gettime_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC() [](#method-i-test_clock_gettime_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) - -## test_clock_gettime_TIMES_BASED_CLOCK_MONOTONIC() [](#method-i-test_clock_gettime_TIMES_BASED_CLOCK_MONOTONIC) - -## test_clock_gettime_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID() [](#method-i-test_clock_gettime_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID) - -## test_clock_gettime_TIME_BASED_CLOCK_REALTIME() [](#method-i-test_clock_gettime_TIME_BASED_CLOCK_REALTIME) - -## test_clock_gettime_constants() [](#method-i-test_clock_gettime_constants) - -## test_clock_gettime_unit() [](#method-i-test_clock_gettime_unit) - -## test_close_others_default_false() [](#method-i-test_close_others_default_false) - -## test_concurrent_group_and_pid_wait() [](#method-i-test_concurrent_group_and_pid_wait) - -## test_daemon_default() [](#method-i-test_daemon_default) - -## test_daemon_detached() [](#method-i-test_daemon_detached) - -## test_daemon_no_threads() [](#method-i-test_daemon_no_threads) -darwin - -## test_daemon_nochdir_noclose() [](#method-i-test_daemon_nochdir_noclose) - -## test_daemon_noclose() [](#method-i-test_daemon_noclose) - -## test_daemon_pid() [](#method-i-test_daemon_pid) - -## test_daemon_readwrite() [](#method-i-test_daemon_readwrite) - -## test_deadlock_by_signal_at_forking() [](#method-i-test_deadlock_by_signal_at_forking) - -## test_exec_close_reserved_fd() [](#method-i-test_exec_close_reserved_fd) - -## test_exec_failure_leaves_no_child() [](#method-i-test_exec_failure_leaves_no_child) - -## test_exec_fd_3_redirect() [](#method-i-test_exec_fd_3_redirect) - -## test_exec_nonascii() [](#method-i-test_exec_nonascii) - -## test_exec_noshell() [](#method-i-test_exec_noshell) - -## test_exec_shell() [](#method-i-test_exec_shell) - -## test_exec_wordsplit() [](#method-i-test_exec_wordsplit) - -## test_execopt_env_path() [](#method-i-test_execopt_env_path) - -## test_execopts_chdir() [](#method-i-test_execopts_chdir) - -## test_execopts_close_others() [](#method-i-test_execopts_close_others) - -## test_execopts_duplex_io() [](#method-i-test_execopts_duplex_io) - -## test_execopts_env() [](#method-i-test_execopts_env) - -## test_execopts_env_popen_string() [](#method-i-test_execopts_env_popen_string) - -## test_execopts_env_popen_vector() [](#method-i-test_execopts_env_popen_vector) - -## test_execopts_env_single_word() [](#method-i-test_execopts_env_single_word) - -## test_execopts_exec() [](#method-i-test_execopts_exec) - -## test_execopts_gid() [](#method-i-test_execopts_gid) - -## test_execopts_modification() [](#method-i-test_execopts_modification) - -## test_execopts_new_pgroup() [](#method-i-test_execopts_new_pgroup) - -## test_execopts_open_chdir() [](#method-i-test_execopts_open_chdir) - -## test_execopts_open_chdir_m17n_path() [](#method-i-test_execopts_open_chdir_m17n_path) - -## test_execopts_open_failure() [](#method-i-test_execopts_open_failure) - -## test_execopts_opts() [](#method-i-test_execopts_opts) - -## test_execopts_pgroup() [](#method-i-test_execopts_pgroup) - -## test_execopts_popen() [](#method-i-test_execopts_popen) - -## test_execopts_popen_extra_fd() [](#method-i-test_execopts_popen_extra_fd) - -## test_execopts_popen_stdio() [](#method-i-test_execopts_popen_stdio) - -## test_execopts_preserve_env_on_exec_failure() [](#method-i-test_execopts_preserve_env_on_exec_failure) - -## test_execopts_redirect_dup2_child() [](#method-i-test_execopts_redirect_dup2_child) - -## test_execopts_redirect_fd() [](#method-i-test_execopts_redirect_fd) - -## test_execopts_redirect_nonascii_path() [](#method-i-test_execopts_redirect_nonascii_path) - -## test_execopts_redirect_open_fifo() [](#method-i-test_execopts_redirect_open_fifo) -passing non-stdio fds is not supported on Windows - -## test_execopts_redirect_open_fifo_interrupt_print() [](#method-i-test_execopts_redirect_open_fifo_interrupt_print) -does not support fifo - -## test_execopts_redirect_open_fifo_interrupt_raise() [](#method-i-test_execopts_redirect_open_fifo_interrupt_raise) -does not support fifo - -## test_execopts_redirect_open_order_normal() [](#method-i-test_execopts_redirect_open_order_normal) - -## test_execopts_redirect_open_order_reverse() [](#method-i-test_execopts_redirect_open_order_reverse) -passing non-stdio fds is not supported on Windows - -## test_execopts_redirect_pipe() [](#method-i-test_execopts_redirect_pipe) -does not support fifo - -## test_execopts_redirect_self() [](#method-i-test_execopts_redirect_self) -passing non-stdio fds is not supported on Windows - -## test_execopts_redirect_symbol() [](#method-i-test_execopts_redirect_symbol) - -## test_execopts_redirect_tempfile() [](#method-i-test_execopts_redirect_tempfile) -passing non-stdio fds is not supported on Windows - -## test_execopts_redirect_to_out_and_err() [](#method-i-test_execopts_redirect_to_out_and_err) - -## test_execopts_rlimit() [](#method-i-test_execopts_rlimit) - -## test_execopts_uid() [](#method-i-test_execopts_uid) - -## test_execopts_umask() [](#method-i-test_execopts_umask) - -## test_execopts_unsetenv_others() [](#method-i-test_execopts_unsetenv_others) - -## test_fallback_to_sh() [](#method-i-test_fallback_to_sh) - -## test_fd_inheritance() [](#method-i-test_fd_inheritance) - -## test_forked_child_handles_signal() [](#method-i-test_forked_child_handles_signal) - -## test_getegid() [](#method-i-test_getegid) - -## test_geteuid() [](#method-i-test_geteuid) - -## test_getpgid() [](#method-i-test_getpgid) - -## test_getpriority() [](#method-i-test_getpriority) - -## test_getuid() [](#method-i-test_getuid) - -## test_gid_from_name() [](#method-i-test_gid_from_name) - -## test_gid_re_exchangeable_p() [](#method-i-test_gid_re_exchangeable_p) - -## test_gid_sid_available?() [](#method-i-test_gid_sid_available?) - -**@return** [Boolean] - -## test_groups() [](#method-i-test_groups) - -## test_handle_interrupt_with_fork() [](#method-i-test_handle_interrupt_with_fork) - -## test_initgroups() [](#method-i-test_initgroups) - -## test_kill_at_spawn_failure() [](#method-i-test_kill_at_spawn_failure) - -## test_last_status() [](#method-i-test_last_status) - -## test_last_status_failure() [](#method-i-test_last_status_failure) - -## test_many_args() [](#method-i-test_many_args) - -## test_maxgroups() [](#method-i-test_maxgroups) - -## test_no_curdir() [](#method-i-test_no_curdir) - -## test_overwrite_ENV() [](#method-i-test_overwrite_ENV) - -## test_popen_cloexec() [](#method-i-test_popen_cloexec) - -## test_popen_exit() [](#method-i-test_popen_exit) - -## test_popen_fork() [](#method-i-test_popen_fork) - -## test_popen_noshell() [](#method-i-test_popen_noshell) - -## test_popen_reopen() [](#method-i-test_popen_reopen) - -## test_popen_shell() [](#method-i-test_popen_shell) - -## test_popen_wordsplit() [](#method-i-test_popen_wordsplit) - -## test_popen_wordsplit_beginning_and_trailing_spaces() [](#method-i-test_popen_wordsplit_beginning_and_trailing_spaces) - -## test_process_detach() [](#method-i-test_process_detach) - -## test_pst_inspect() [](#method-i-test_pst_inspect) - -## test_rescue_exec_fail() [](#method-i-test_rescue_exec_fail) - -## test_rlimit_availability() [](#method-i-test_rlimit_availability) - -## test_rlimit_name() [](#method-i-test_rlimit_name) - -## test_rlimit_nofile() [](#method-i-test_rlimit_nofile) - -## test_rlimit_value() [](#method-i-test_rlimit_value) - -## test_setegid() [](#method-i-test_setegid) - -## test_seteuid() [](#method-i-test_seteuid) - -## test_seteuid_name() [](#method-i-test_seteuid_name) - -## test_setpriority() [](#method-i-test_setpriority) - -## test_setsid() [](#method-i-test_setsid) - -## test_sh_comment() [](#method-i-test_sh_comment) - -## test_sh_env() [](#method-i-test_sh_env) - -## test_sh_exec() [](#method-i-test_sh_exec) - -## test_signals_work_after_exec_fail() [](#method-i-test_signals_work_after_exec_fail) - -## test_sigpipe() [](#method-i-test_sigpipe) - -## test_sleep() [](#method-i-test_sleep) - -## test_spawn_nonascii() [](#method-i-test_spawn_nonascii) - -## test_spawn_noshell() [](#method-i-test_spawn_noshell) - -## test_spawn_shell() [](#method-i-test_spawn_shell) - -## test_spawn_too_long_path() [](#method-i-test_spawn_too_long_path) - -## test_spawn_wordsplit() [](#method-i-test_spawn_wordsplit) - -## test_status() [](#method-i-test_status) - -## test_status_fail() [](#method-i-test_status_fail) - -## test_status_kill() [](#method-i-test_status_kill) - -## test_status_quit() [](#method-i-test_status_quit) - -## test_status_wait() [](#method-i-test_status_wait) - -## test_system_noshell() [](#method-i-test_system_noshell) - -## test_system_shell() [](#method-i-test_system_shell) - -## test_system_sigpipe() [](#method-i-test_system_sigpipe) - -## test_system_wordsplit() [](#method-i-test_system_wordsplit) - -## test_threading_works_after_exec_fail() [](#method-i-test_threading_works_after_exec_fail) - -## test_to_hash_on_arguments() [](#method-i-test_to_hash_on_arguments) - -## test_uid_from_name() [](#method-i-test_uid_from_name) - -## test_uid_re_exchangeable_p() [](#method-i-test_uid_re_exchangeable_p) - -## test_uid_sid_available?() [](#method-i-test_uid_sid_available?) - -**@return** [Boolean] - -## test_wait2() [](#method-i-test_wait2) - -## test_wait_and_sigchild() [](#method-i-test_wait_and_sigchild) - -## test_wait_exception() [](#method-i-test_wait_exception) - -## test_wait_without_arg() [](#method-i-test_wait_without_arg) - -## test_waitall() [](#method-i-test_waitall) - -## test_warmup_frees_pages() [](#method-i-test_warmup_frees_pages) - -## test_warmup_precompute_string_coderange() [](#method-i-test_warmup_precompute_string_coderange) - -## test_warmup_promote_all_objects_to_oldgen() [](#method-i-test_warmup_promote_all_objects_to_oldgen) - -## test_warmup_run_major_gc_and_compact() [](#method-i-test_warmup_run_major_gc_and_compact) - -## windows?() [](#method-i-windows?) - -**@return** [Boolean] - -## with_pipe() [](#method-i-with_pipe) - -## with_pipes(n) [](#method-i-with_pipes) - -## with_stdin(filename) [](#method-i-with_stdin) - -## with_tmpchdir() [](#method-i-with_tmpchdir) - diff --git a/example/ruby/TestProfileFrames.md b/example/ruby/TestProfileFrames.md deleted file mode 100644 index 53bf8b7..0000000 --- a/example/ruby/TestProfileFrames.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestProfileFrames -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_ifunc_frame() [](#method-i-test_ifunc_frame) - -## test_matches_backtrace_locations_main_thread() [](#method-i-test_matches_backtrace_locations_main_thread) - -## test_profile_frames() [](#method-i-test_profile_frames) - -## test_profile_thread_frames() [](#method-i-test_profile_thread_frames) - -## test_start() [](#method-i-test_start) - diff --git a/example/ruby/TestProtocol.md b/example/ruby/TestProtocol.md deleted file mode 100644 index 7903d80..0000000 --- a/example/ruby/TestProtocol.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: TestProtocol -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## create_mockio(capacity:100, max:nil) [](#method-i-create_mockio) - -## test_each_crlf_line() [](#method-i-test_each_crlf_line) - -## test_readuntil() [](#method-i-test_readuntil) - -## test_shareable_buffer_leak() [](#method-i-test_shareable_buffer_leak) -https://github.com/ruby/net-protocol/pull/19 - -## test_should_properly_dot_stuff_period_with_no_endline() [](#method-i-test_should_properly_dot_stuff_period_with_no_endline) - -## test_write0_multibyte() [](#method-i-test_write0_multibyte) - -## test_write0_success() [](#method-i-test_write0_success) - -## test_write0_success2() [](#method-i-test_write0_success2) - -## test_write0_success_multi1() [](#method-i-test_write0_success_multi1) - -## test_write0_success_multi2() [](#method-i-test_write0_success_multi2) - -## test_write0_timeout() [](#method-i-test_write0_timeout) - -## test_write0_timeout_multi1() [](#method-i-test_write0_timeout_multi1) - -## test_write0_timeout_multi2() [](#method-i-test_write0_timeout_multi2) - diff --git a/example/ruby/TestProtocol/FakeReadPartialIO.md b/example/ruby/TestProtocol/FakeReadPartialIO.md deleted file mode 100644 index 009ee6c..0000000 --- a/example/ruby/TestProtocol/FakeReadPartialIO.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestProtocol::FakeReadPartialIO -**Inherits:** Object - - - - - -#Instance Methods -## initialize(chunks) [](#method-i-initialize) - -**@return** [FakeReadPartialIO] a new instance of FakeReadPartialIO - -## read_nonblock(size, bufnil, exception:false) [](#method-i-read_nonblock) - diff --git a/example/ruby/TestPsych.md b/example/ruby/TestPsych.md deleted file mode 100644 index 3c15f09..0000000 --- a/example/ruby/TestPsych.md +++ /dev/null @@ -1,132 +0,0 @@ -# Class: TestPsych -**Inherits:** Psych::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_add_builtin_type() [](#method-i-test_add_builtin_type) - -## test_callbacks() [](#method-i-test_callbacks) - -## test_canonical() [](#method-i-test_canonical) - -## test_degenerate_strings() [](#method-i-test_degenerate_strings) - -## test_domain_types() [](#method-i-test_domain_types) - -## test_dump_file() [](#method-i-test_dump_file) - -## test_dump_io() [](#method-i-test_dump_io) - -## test_dump_stream() [](#method-i-test_dump_stream) - -## test_header() [](#method-i-test_header) - -## test_indent() [](#method-i-test_indent) - -## test_libyaml_version() [](#method-i-test_libyaml_version) - -## test_line_width_invalid() [](#method-i-test_line_width_invalid) - -## test_line_width_limit() [](#method-i-test_line_width_limit) - -## test_line_width_no_limit() [](#method-i-test_line_width_no_limit) - -## test_load_argument_error() [](#method-i-test_load_argument_error) - -## test_load_default_fallback() [](#method-i-test_load_default_fallback) - -## test_load_file() [](#method-i-test_load_file) - -## test_load_file_default_fallback() [](#method-i-test_load_file_default_fallback) - -## test_load_file_freeze() [](#method-i-test_load_file_freeze) - -## test_load_file_symbolize_names() [](#method-i-test_load_file_symbolize_names) - -## test_load_file_with_fallback() [](#method-i-test_load_file_with_fallback) - -## test_load_file_with_fallback_for_false() [](#method-i-test_load_file_with_fallback_for_false) - -## test_load_file_with_fallback_for_nil() [](#method-i-test_load_file_with_fallback_for_nil) - -## test_load_file_with_fallback_hash() [](#method-i-test_load_file_with_fallback_hash) - -## test_load_file_with_fallback_nil_or_false() [](#method-i-test_load_file_with_fallback_nil_or_false) - -## test_load_freeze() [](#method-i-test_load_freeze) - -## test_load_freeze_deduplication() [](#method-i-test_load_freeze_deduplication) - -## test_load_stream() [](#method-i-test_load_stream) - -## test_load_stream_default_fallback() [](#method-i-test_load_stream_default_fallback) - -## test_load_stream_freeze() [](#method-i-test_load_stream_freeze) - -## test_load_stream_raises_on_bad_input() [](#method-i-test_load_stream_raises_on_bad_input) - -## test_load_stream_symbolize_names() [](#method-i-test_load_stream_symbolize_names) - -## test_load_with_fallback() [](#method-i-test_load_with_fallback) - -## test_load_with_fallback_for_false() [](#method-i-test_load_with_fallback_for_false) - -## test_load_with_fallback_for_nil() [](#method-i-test_load_with_fallback_for_nil) - -## test_load_with_fallback_hash() [](#method-i-test_load_with_fallback_hash) - -## test_load_with_fallback_nil_or_false() [](#method-i-test_load_with_fallback_nil_or_false) - -## test_non_existing_class_on_deserialize() [](#method-i-test_non_existing_class_on_deserialize) - -## test_parse() [](#method-i-test_parse) - -## test_parse_default_fallback() [](#method-i-test_parse_default_fallback) - -## test_parse_file() [](#method-i-test_parse_file) - -## test_parse_file_default_fallback() [](#method-i-test_parse_file_default_fallback) - -## test_parse_raises_on_bad_input() [](#method-i-test_parse_raises_on_bad_input) - -## test_parse_stream() [](#method-i-test_parse_stream) - -## test_parse_stream_default_fallback() [](#method-i-test_parse_stream_default_fallback) - -## test_parse_stream_raises_on_bad_input() [](#method-i-test_parse_stream_raises_on_bad_input) - -## test_parse_stream_with_block() [](#method-i-test_parse_stream_with_block) - -## test_parse_stream_with_block_default_fallback() [](#method-i-test_parse_stream_with_block_default_fallback) - -## test_safe_dump_aliases() [](#method-i-test_safe_dump_aliases) - -## test_safe_dump_defaults() [](#method-i-test_safe_dump_defaults) - -## test_safe_dump_extra_permitted_classes() [](#method-i-test_safe_dump_extra_permitted_classes) - -## test_safe_dump_stringify_names() [](#method-i-test_safe_dump_stringify_names) - -## test_safe_dump_symbols() [](#method-i-test_safe_dump_symbols) - -## test_safe_dump_unpermitted_class() [](#method-i-test_safe_dump_unpermitted_class) - -## test_safe_load_file_with_permitted_classe() [](#method-i-test_safe_load_file_with_permitted_classe) - -## test_simple() [](#method-i-test_simple) - -## test_symbolize_names() [](#method-i-test_symbolize_names) - -## test_version_array() [](#method-i-test_version_array) - -## test_version_bool() [](#method-i-test_version_bool) - -## test_version_string() [](#method-i-test_version_string) - diff --git a/example/ruby/TestPsychRactor.md b/example/ruby/TestPsychRactor.md deleted file mode 100644 index 54137b4..0000000 --- a/example/ruby/TestPsychRactor.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestPsychRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_not_shareable() [](#method-i-test_not_shareable) - -## test_ractor_config() [](#method-i-test_ractor_config) - -## test_ractor_constants() [](#method-i-test_ractor_constants) - -## test_ractor_round_trip() [](#method-i-test_ractor_round_trip) - diff --git a/example/ruby/TestRDocAlias.md b/example/ruby/TestRDocAlias.md deleted file mode 100644 index 66a299a..0000000 --- a/example/ruby/TestRDocAlias.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRDocAlias -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestRDocAnyMethod.md b/example/ruby/TestRDocAnyMethod.md deleted file mode 100644 index 97ac82f..0000000 --- a/example/ruby/TestRDocAnyMethod.md +++ /dev/null @@ -1,90 +0,0 @@ -# Class: TestRDocAnyMethod -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## test_aref() [](#method-i-test_aref) - -## test_arglists() [](#method-i-test_arglists) - -## test_c_function() [](#method-i-test_c_function) - -## test_call_seq_alias_for() [](#method-i-test_call_seq_alias_for) - -## test_call_seq_equals() [](#method-i-test_call_seq_equals) - -## test_call_seq_handles_aliases() [](#method-i-test_call_seq_handles_aliases) - -## test_call_seq_returns_nil_if_alias_is_missing_from_call_seq() [](#method-i-test_call_seq_returns_nil_if_alias_is_missing_from_call_seq) - -## test_full_name() [](#method-i-test_full_name) - -## test_has_call_seq?() [](#method-i-test_has_call_seq?) - -**@return** [Boolean] - -## test_is_alias_for() [](#method-i-test_is_alias_for) - -## test_markup_code() [](#method-i-test_markup_code) - -## test_markup_code_empty() [](#method-i-test_markup_code_empty) - -## test_markup_code_with_line_numbers() [](#method-i-test_markup_code_with_line_numbers) - -## test_markup_code_with_variable_expansion() [](#method-i-test_markup_code_with_variable_expansion) - -## test_marshal_dump() [](#method-i-test_marshal_dump) - -## test_marshal_dump_version_2() [](#method-i-test_marshal_dump_version_2) - -## test_marshal_load_aliased_method() [](#method-i-test_marshal_load_aliased_method) - -## test_marshal_load_aliased_method_with_nil_singleton() [](#method-i-test_marshal_load_aliased_method_with_nil_singleton) - -## test_marshal_load_class_method() [](#method-i-test_marshal_load_class_method) - -## test_marshal_load_instance_method() [](#method-i-test_marshal_load_instance_method) - -## test_marshal_load_version_0() [](#method-i-test_marshal_load_version_0) - -## test_name() [](#method-i-test_name) - -## test_name_call_seq() [](#method-i-test_name_call_seq) - -## test_name_call_seq_dot() [](#method-i-test_name_call_seq_dot) - -## test_param_list_ampersand_param() [](#method-i-test_param_list_ampersand_param) - -## test_param_list_ampersand_param_block_params() [](#method-i-test_param_list_ampersand_param_block_params) - -## test_param_list_block_params() [](#method-i-test_param_list_block_params) - -## test_param_list_call_seq() [](#method-i-test_param_list_call_seq) - -## test_param_list_default() [](#method-i-test_param_list_default) - -## test_param_list_empty_params_with_block() [](#method-i-test_param_list_empty_params_with_block) - -## test_param_list_params() [](#method-i-test_param_list_params) - -## test_param_list_params_block_params() [](#method-i-test_param_list_params_block_params) - -## test_param_seq() [](#method-i-test_param_seq) - -## test_param_seq_call_seq() [](#method-i-test_param_seq_call_seq) - -## test_parent_name() [](#method-i-test_parent_name) - -## test_skip_description?() [](#method-i-test_skip_description?) - -**@return** [Boolean] - -## test_store_equals() [](#method-i-test_store_equals) - -## test_superclass_method() [](#method-i-test_superclass_method) - -## test_superclass_method_multilevel() [](#method-i-test_superclass_method_multilevel) - diff --git a/example/ruby/TestRDocAttr.md b/example/ruby/TestRDocAttr.md deleted file mode 100644 index 6ddd11b..0000000 --- a/example/ruby/TestRDocAttr.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestRDocAttr -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_aref() [](#method-i-test_aref) - -## test_arglists() [](#method-i-test_arglists) - -## test_block_params() [](#method-i-test_block_params) - -## test_call_seq() [](#method-i-test_call_seq) - -## test_definition() [](#method-i-test_definition) - -## test_full_name() [](#method-i-test_full_name) - -## test_marshal_dump() [](#method-i-test_marshal_dump) - -## test_marshal_dump_singleton() [](#method-i-test_marshal_dump_singleton) - -## test_marshal_load_version_1() [](#method-i-test_marshal_load_version_1) - -## test_marshal_load_version_2() [](#method-i-test_marshal_load_version_2) - -## test_params() [](#method-i-test_params) - -## test_singleton() [](#method-i-test_singleton) - -## test_type() [](#method-i-test_type) - diff --git a/example/ruby/TestRDocClassModule.md b/example/ruby/TestRDocClassModule.md deleted file mode 100644 index a8aa0b9..0000000 --- a/example/ruby/TestRDocClassModule.md +++ /dev/null @@ -1,119 +0,0 @@ -# Class: TestRDocClassModule -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## test_add_comment() [](#method-i-test_add_comment) - -## test_add_comment_comment() [](#method-i-test_add_comment_comment) - -## test_add_comment_duplicate() [](#method-i-test_add_comment_duplicate) - -## test_add_comment_stopdoc() [](#method-i-test_add_comment_stopdoc) - -## test_ancestors() [](#method-i-test_ancestors) - -## test_comment_equals() [](#method-i-test_comment_equals) - -## test_comment_equals_comment() [](#method-i-test_comment_equals_comment) - -## test_document_self_or_methods() [](#method-i-test_document_self_or_methods) - -## test_documented_eh() [](#method-i-test_documented_eh) - -## test_each_ancestor() [](#method-i-test_each_ancestor) - -## test_each_ancestor_cycle() [](#method-i-test_each_ancestor_cycle) - -## test_find_class_named() [](#method-i-test_find_class_named) -handle making a short module alias of yourself - -## test_from_module_comment() [](#method-i-test_from_module_comment) - -## test_marshal_dump() [](#method-i-test_marshal_dump) - -## test_marshal_dump_visibility() [](#method-i-test_marshal_dump_visibility) - -## test_marshal_load_version_0() [](#method-i-test_marshal_load_version_0) - -## test_marshal_load_version_1() [](#method-i-test_marshal_load_version_1) - -## test_marshal_load_version_2() [](#method-i-test_marshal_load_version_2) - -## test_marshal_load_version_3() [](#method-i-test_marshal_load_version_3) - -## test_merge() [](#method-i-test_merge) - -## test_merge_attributes() [](#method-i-test_merge_attributes) - -## test_merge_attributes_version_0() [](#method-i-test_merge_attributes_version_0) - -## test_merge_collections_drop() [](#method-i-test_merge_collections_drop) - -## test_merge_comment() [](#method-i-test_merge_comment) - -## test_merge_comment_version_0() [](#method-i-test_merge_comment_version_0) - -## test_merge_constants() [](#method-i-test_merge_constants) - -## test_merge_constants_version_0() [](#method-i-test_merge_constants_version_0) - -## test_merge_extends() [](#method-i-test_merge_extends) - -## test_merge_includes() [](#method-i-test_merge_includes) - -## test_merge_includes_version_0() [](#method-i-test_merge_includes_version_0) - -## test_merge_methods() [](#method-i-test_merge_methods) - -## test_merge_methods_version_0() [](#method-i-test_merge_methods_version_0) - -## test_merge_sections() [](#method-i-test_merge_sections) - -## test_merge_sections_overlap() [](#method-i-test_merge_sections_overlap) - -## test_parse() [](#method-i-test_parse) - -## test_parse_comment() [](#method-i-test_parse_comment) - -## test_parse_comment_format() [](#method-i-test_parse_comment_format) - -## test_parse_comment_location() [](#method-i-test_parse_comment_location) - -## test_remove_nodoc_children() [](#method-i-test_remove_nodoc_children) - -## test_search_record() [](#method-i-test_search_record) - -## test_search_record_merged() [](#method-i-test_search_record_merged) - -## test_setting_superclass() [](#method-i-test_setting_superclass) - -## test_store_equals() [](#method-i-test_store_equals) - -## test_super_classes() [](#method-i-test_super_classes) - -## test_superclass() [](#method-i-test_superclass) - -## test_update_aliases_class() [](#method-i-test_update_aliases_class) - -## test_update_aliases_module() [](#method-i-test_update_aliases_module) - -## test_update_aliases_reparent() [](#method-i-test_update_aliases_reparent) - -## test_update_aliases_reparent_root() [](#method-i-test_update_aliases_reparent_root) - -## test_update_extends() [](#method-i-test_update_extends) - -## test_update_extends_trim() [](#method-i-test_update_extends_trim) - -## test_update_extends_with_colons() [](#method-i-test_update_extends_with_colons) - -## test_update_includes() [](#method-i-test_update_includes) - -## test_update_includes_trim() [](#method-i-test_update_includes_trim) - -## test_update_includes_with_colons() [](#method-i-test_update_includes_with_colons) - diff --git a/example/ruby/TestRDocClassModule/TestRDocClassModuleMixins.md b/example/ruby/TestRDocClassModule/TestRDocClassModuleMixins.md deleted file mode 100644 index cadc4df..0000000 --- a/example/ruby/TestRDocClassModule/TestRDocClassModuleMixins.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocClassModule::TestRDocClassModuleMixins -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_embed_mixin_when_false_does_not_embed_anything() [](#method-i-test_embed_mixin_when_false_does_not_embed_anything) - -## test_embed_mixin_when_true_embeds_methods_and_constants() [](#method-i-test_embed_mixin_when_true_embeds_methods_and_constants) - diff --git a/example/ruby/TestRDocCodeObject.md b/example/ruby/TestRDocCodeObject.md deleted file mode 100644 index 9eef0e0..0000000 --- a/example/ruby/TestRDocCodeObject.md +++ /dev/null @@ -1,80 +0,0 @@ -# Class: TestRDocCodeObject -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_comment_equals() [](#method-i-test_comment_equals) - -## test_comment_equals_comment() [](#method-i-test_comment_equals_comment) - -## test_comment_equals_document() [](#method-i-test_comment_equals_document) - -## test_comment_equals_encoding() [](#method-i-test_comment_equals_encoding) - -## test_comment_equals_encoding_blank() [](#method-i-test_comment_equals_encoding_blank) - -## test_display_eh_document_self() [](#method-i-test_display_eh_document_self) - -## test_display_eh_ignore() [](#method-i-test_display_eh_ignore) - -## test_display_eh_suppress() [](#method-i-test_display_eh_suppress) - -## test_document_children_equals() [](#method-i-test_document_children_equals) - -## test_document_self_equals() [](#method-i-test_document_self_equals) - -## test_documented_eh() [](#method-i-test_documented_eh) - -## test_done_documenting() [](#method-i-test_done_documenting) - -## test_each_parent() [](#method-i-test_each_parent) - -## test_file_name() [](#method-i-test_file_name) - -## test_full_name_equals() [](#method-i-test_full_name_equals) - -## test_ignore() [](#method-i-test_ignore) - -## test_ignore_eh() [](#method-i-test_ignore_eh) - -## test_initialize() [](#method-i-test_initialize) - -## test_line() [](#method-i-test_line) - -## test_metadata() [](#method-i-test_metadata) - -## test_options() [](#method-i-test_options) - -## test_parent_file_name() [](#method-i-test_parent_file_name) - -## test_parent_name() [](#method-i-test_parent_name) - -## test_received_ndoc() [](#method-i-test_received_ndoc) - -## test_record_location() [](#method-i-test_record_location) - -## test_record_location_ignored() [](#method-i-test_record_location_ignored) - -## test_record_location_suppressed() [](#method-i-test_record_location_suppressed) - -## test_section() [](#method-i-test_section) - -## test_start_doc() [](#method-i-test_start_doc) - -## test_start_doc_ignored() [](#method-i-test_start_doc_ignored) - -## test_start_doc_suppressed() [](#method-i-test_start_doc_suppressed) - -## test_stop_doc() [](#method-i-test_stop_doc) - -## test_store_equals() [](#method-i-test_store_equals) - -## test_suppress() [](#method-i-test_suppress) - -## test_suppress_eh() [](#method-i-test_suppress_eh) - diff --git a/example/ruby/TestRDocComment.md b/example/ruby/TestRDocComment.md deleted file mode 100644 index 5af57d9..0000000 --- a/example/ruby/TestRDocComment.md +++ /dev/null @@ -1,86 +0,0 @@ -# Class: TestRDocComment -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_empty_eh() [](#method-i-test_empty_eh) - -## test_equals2() [](#method-i-test_equals2) - -## test_extract_call_linear_performance() [](#method-i-test_extract_call_linear_performance) - -## test_extract_call_seq() [](#method-i-test_extract_call_seq) - -## test_extract_call_seq_blank() [](#method-i-test_extract_call_seq_blank) - -## test_extract_call_seq_c() [](#method-i-test_extract_call_seq_c) - -## test_extract_call_seq_c_no_blank() [](#method-i-test_extract_call_seq_c_no_blank) - -## test_extract_call_seq_c_separator() [](#method-i-test_extract_call_seq_c_separator) - -## test_extract_call_seq_commented() [](#method-i-test_extract_call_seq_commented) - -## test_extract_call_seq_no_blank() [](#method-i-test_extract_call_seq_no_blank) - -## test_extract_call_seq_undent() [](#method-i-test_extract_call_seq_undent) - -## test_force_encoding() [](#method-i-test_force_encoding) - -## test_format() [](#method-i-test_format) - -## test_format_equals() [](#method-i-test_format_equals) - -## test_initialize_copy() [](#method-i-test_initialize_copy) - -## test_location() [](#method-i-test_location) - -## test_normalize() [](#method-i-test_normalize) - -## test_normalize_document() [](#method-i-test_normalize_document) - -## test_normalize_eh() [](#method-i-test_normalize_eh) - -## test_normalize_twice() [](#method-i-test_normalize_twice) - -## test_parse() [](#method-i-test_parse) - -## test_parse_rd() [](#method-i-test_parse_rd) - -## test_remove_private_encoding() [](#method-i-test_remove_private_encoding) - -## test_remove_private_hash() [](#method-i-test_remove_private_hash) - -## test_remove_private_hash_trail() [](#method-i-test_remove_private_hash_trail) - -## test_remove_private_long() [](#method-i-test_remove_private_long) - -## test_remove_private_rule() [](#method-i-test_remove_private_rule) - -## test_remove_private_star() [](#method-i-test_remove_private_star) - -## test_remove_private_star2() [](#method-i-test_remove_private_star2) - -## test_remove_private_toggle() [](#method-i-test_remove_private_toggle) - -## test_remove_private_toggle_encoding() [](#method-i-test_remove_private_toggle_encoding) - -## test_remove_private_toggle_encoding_ruby_bug?() [](#method-i-test_remove_private_toggle_encoding_ruby_bug?) - -**@return** [Boolean] - -## test_text() [](#method-i-test_text) - -## test_text_equals() [](#method-i-test_text_equals) - -## test_text_equals_no_text() [](#method-i-test_text_equals_no_text) - -## test_text_equals_parsed() [](#method-i-test_text_equals_parsed) - -## test_tomdoc_eh() [](#method-i-test_tomdoc_eh) - diff --git a/example/ruby/TestRDocConstant.md b/example/ruby/TestRDocConstant.md deleted file mode 100644 index b71f845..0000000 --- a/example/ruby/TestRDocConstant.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TestRDocConstant -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_documented_eh() [](#method-i-test_documented_eh) - -## test_documented_eh_alias() [](#method-i-test_documented_eh_alias) - -## test_full_name() [](#method-i-test_full_name) - -## test_is_alias_for() [](#method-i-test_is_alias_for) - -## test_marshal_dump() [](#method-i-test_marshal_dump) - -## test_marshal_load() [](#method-i-test_marshal_load) - -## test_marshal_load_version_0() [](#method-i-test_marshal_load_version_0) - -## test_marshal_round_trip() [](#method-i-test_marshal_round_trip) - -## test_path() [](#method-i-test_path) - diff --git a/example/ruby/TestRDocContext.md b/example/ruby/TestRDocContext.md deleted file mode 100644 index 054a7f0..0000000 --- a/example/ruby/TestRDocContext.md +++ /dev/null @@ -1,168 +0,0 @@ -# Class: TestRDocContext -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## bench_add_include() [](#method-i-bench_add_include) - -## setup() [](#method-i-setup) - -## test_add() [](#method-i-test_add) - -## test_add_alias() [](#method-i-test_add_alias) - -## test_add_alias_method() [](#method-i-test_add_alias_method) - -## test_add_alias_method_attr() [](#method-i-test_add_alias_method_attr) - -## test_add_alias_method_singleton() [](#method-i-test_add_alias_method_singleton) - -## test_add_class() [](#method-i-test_add_class) - -## test_add_class_basic_object() [](#method-i-test_add_class_basic_object) - -## test_add_class_object() [](#method-i-test_add_class_object) - -## test_add_class_singleton() [](#method-i-test_add_class_singleton) - -## test_add_class_superclass() [](#method-i-test_add_class_superclass) - -## test_add_class_upgrade() [](#method-i-test_add_class_upgrade) - -## test_add_constant() [](#method-i-test_add_constant) - -## test_add_extend() [](#method-i-test_add_extend) - -## test_add_include() [](#method-i-test_add_include) - -## test_add_method() [](#method-i-test_add_method) - -## test_add_method_alias() [](#method-i-test_add_method_alias) - -## test_add_method_duplicate() [](#method-i-test_add_method_duplicate) - -## test_add_method_duplicate_loading() [](#method-i-test_add_method_duplicate_loading) - -## test_add_module() [](#method-i-test_add_module) - -## test_add_module_alias() [](#method-i-test_add_module_alias) - -## test_add_module_alias_top_level() [](#method-i-test_add_module_alias_top_level) - -## test_add_module_class() [](#method-i-test_add_module_class) - -## test_add_require() [](#method-i-test_add_require) - -## test_add_section() [](#method-i-test_add_section) - -## test_add_section_no_comment() [](#method-i-test_add_section_no_comment) - -## test_add_to() [](#method-i-test_add_to) - -## test_add_to_done_documenting() [](#method-i-test_add_to_done_documenting) - -## test_add_to_no_document_self() [](#method-i-test_add_to_no_document_self) - -## test_add_to_temporary_section() [](#method-i-test_add_to_temporary_section) - -## test_child_name() [](#method-i-test_child_name) - -## test_classes() [](#method-i-test_classes) - -## test_current_section() [](#method-i-test_current_section) - -## test_defined_in_eh() [](#method-i-test_defined_in_eh) - -## test_each_method_enumerator() [](#method-i-test_each_method_enumerator) - -## test_each_section() [](#method-i-test_each_section) - -## test_each_section_enumerator() [](#method-i-test_each_section_enumerator) - -## test_each_section_only_display() [](#method-i-test_each_section_only_display) - -## test_equals2() [](#method-i-test_equals2) - -## test_find_attribute_named() [](#method-i-test_find_attribute_named) - -## test_find_class_method_named() [](#method-i-test_find_class_method_named) - -## test_find_constant_named() [](#method-i-test_find_constant_named) - -## test_find_enclosing_module_named() [](#method-i-test_find_enclosing_module_named) - -## test_find_file_named() [](#method-i-test_find_file_named) - -## test_find_instance_method_named() [](#method-i-test_find_instance_method_named) - -## test_find_local_symbol() [](#method-i-test_find_local_symbol) - -## test_find_method() [](#method-i-test_find_method) - -## test_find_method_named() [](#method-i-test_find_method_named) - -## test_find_module_named() [](#method-i-test_find_module_named) - -## test_find_symbol() [](#method-i-test_find_symbol) - -## test_find_symbol_method() [](#method-i-test_find_symbol_method) - -## test_find_symbol_module() [](#method-i-test_find_symbol_module) - -## test_fully_documented_eh() [](#method-i-test_fully_documented_eh) - -## test_initialize() [](#method-i-test_initialize) - -## test_methods_by_type() [](#method-i-test_methods_by_type) - -## test_methods_by_type_section() [](#method-i-test_methods_by_type_section) - -## test_methods_matching() [](#method-i-test_methods_matching) - -## test_methods_matching_inherit() [](#method-i-test_methods_matching_inherit) - -## test_methods_matching_singleton() [](#method-i-test_methods_matching_singleton) - -## test_remove_invisible_in_protected() [](#method-i-test_remove_invisible_in_protected) - -## test_remove_invisible_in_protected_force() [](#method-i-test_remove_invisible_in_protected_force) - -## test_remove_invisible_in_public() [](#method-i-test_remove_invisible_in_public) - -## test_remove_invisible_in_public_force() [](#method-i-test_remove_invisible_in_public_force) - -## test_remove_invisible_nodoc() [](#method-i-test_remove_invisible_nodoc) - -## test_remove_invisible_private() [](#method-i-test_remove_invisible_private) - -## test_remove_invisible_protected() [](#method-i-test_remove_invisible_protected) - -## test_remove_invisible_public() [](#method-i-test_remove_invisible_public) - -## test_remove_invisible_public_force() [](#method-i-test_remove_invisible_public_force) - -## test_section_contents() [](#method-i-test_section_contents) - -## test_section_contents_no_default() [](#method-i-test_section_contents_no_default) - -## test_section_contents_only_default() [](#method-i-test_section_contents_only_default) - -## test_section_contents_unused() [](#method-i-test_section_contents_unused) - -## test_set_current_section() [](#method-i-test_set_current_section) - -## test_sort_sections() [](#method-i-test_sort_sections) - -## test_sort_sections_tomdoc() [](#method-i-test_sort_sections_tomdoc) - -## test_sort_sections_tomdoc_missing() [](#method-i-test_sort_sections_tomdoc_missing) - -## test_spaceship() [](#method-i-test_spaceship) - -## test_visibility_def() [](#method-i-test_visibility_def) - -## util_visibilities() [](#method-i-util_visibilities) - diff --git a/example/ruby/TestRDocContextSection.md b/example/ruby/TestRDocContextSection.md deleted file mode 100644 index f0953ae..0000000 --- a/example/ruby/TestRDocContextSection.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestRDocContextSection -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_comment() [](#method-i-test_add_comment) - -## test_aref() [](#method-i-test_aref) - -## test_eql_eh() [](#method-i-test_eql_eh) - -## test_equals() [](#method-i-test_equals) - -## test_extract_comment() [](#method-i-test_extract_comment) - -## test_hash() [](#method-i-test_hash) - -## test_marshal_dump() [](#method-i-test_marshal_dump) - -## test_marshal_dump_no_comment() [](#method-i-test_marshal_dump_no_comment) - -## test_marshal_load_version_0() [](#method-i-test_marshal_load_version_0) - -## test_remove_comment_array() [](#method-i-test_remove_comment_array) - -## test_remove_comment_document() [](#method-i-test_remove_comment_document) - diff --git a/example/ruby/TestRDocCrossReference.md b/example/ruby/TestRDocCrossReference.md deleted file mode 100644 index 673f9f8..0000000 --- a/example/ruby/TestRDocCrossReference.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: TestRDocCrossReference -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## assert_ref(expected, name) [](#method-i-assert_ref) - -## assert_resolve_method(x) [](#method-i-assert_resolve_method) - -## refute_ref(name) [](#method-i-refute_ref) - -## setup() [](#method-i-setup) - -## test_METHOD_REGEXP_STR() [](#method-i-test_METHOD_REGEXP_STR) - -## test_resolve_C2() [](#method-i-test_resolve_C2) - -## test_resolve_C2_C3() [](#method-i-test_resolve_C2_C3) - -## test_resolve_C3() [](#method-i-test_resolve_C3) - -## test_resolve_C4() [](#method-i-test_resolve_C4) - -## test_resolve_C4_C4() [](#method-i-test_resolve_C4_C4) - -## test_resolve_class() [](#method-i-test_resolve_class) - -## test_resolve_class_and_method_of_the_same_name() [](#method-i-test_resolve_class_and_method_of_the_same_name) - -## test_resolve_file() [](#method-i-test_resolve_file) - -## test_resolve_method() [](#method-i-test_resolve_method) - -## test_resolve_no_ref() [](#method-i-test_resolve_no_ref) - -## test_resolve_page() [](#method-i-test_resolve_page) - -## test_resolve_the_same_name_in_instance_and_class_method() [](#method-i-test_resolve_the_same_name_in_instance_and_class_method) - diff --git a/example/ruby/TestRDocEncoding.md b/example/ruby/TestRDocEncoding.md deleted file mode 100644 index d5a71ed..0000000 --- a/example/ruby/TestRDocEncoding.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestRDocEncoding -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_class_detect_encoding() [](#method-i-test_class_detect_encoding) - -## test_class_read_file() [](#method-i-test_class_read_file) - -## test_class_read_file_encoding() [](#method-i-test_class_read_file_encoding) - -## test_class_read_file_encoding_convert() [](#method-i-test_class_read_file_encoding_convert) - -## test_class_read_file_encoding_fail() [](#method-i-test_class_read_file_encoding_fail) - -## test_class_read_file_encoding_fancy() [](#method-i-test_class_read_file_encoding_fancy) - -## test_class_read_file_encoding_force_transcode() [](#method-i-test_class_read_file_encoding_force_transcode) - -## test_class_read_file_encoding_guess() [](#method-i-test_class_read_file_encoding_guess) - -## test_class_read_file_encoding_invalid() [](#method-i-test_class_read_file_encoding_invalid) - -## test_class_read_file_encoding_iso_2022_jp() [](#method-i-test_class_read_file_encoding_iso_2022_jp) - -## test_class_read_file_encoding_with_signature() [](#method-i-test_class_read_file_encoding_with_signature) - -## test_class_set_encoding_bad() [](#method-i-test_class_set_encoding_bad) - -## test_sanity() [](#method-i-test_sanity) - diff --git a/example/ruby/TestRDocExtend.md b/example/ruby/TestRDocExtend.md deleted file mode 100644 index ee6a52c..0000000 --- a/example/ruby/TestRDocExtend.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocExtend -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_module() [](#method-i-test_module) - -## test_module_extended() [](#method-i-test_module_extended) - diff --git a/example/ruby/TestRDocGeneratorJsonIndex.md b/example/ruby/TestRDocGeneratorJsonIndex.md deleted file mode 100644 index 1f1822a..0000000 --- a/example/ruby/TestRDocGeneratorJsonIndex.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestRDocGeneratorJsonIndex -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_build_index() [](#method-i-test_build_index) - -## test_class_dir() [](#method-i-test_class_dir) - -## test_file_dir() [](#method-i-test_file_dir) - -## test_generate() [](#method-i-test_generate) - -## test_generate_gzipped() [](#method-i-test_generate_gzipped) - -## test_generate_search_index_with_reproducible_builds() [](#method-i-test_generate_search_index_with_reproducible_builds) - -## test_generate_utf_8() [](#method-i-test_generate_utf_8) - -## test_index_classes() [](#method-i-test_index_classes) - -## test_index_classes_nodoc() [](#method-i-test_index_classes_nodoc) - -## test_index_methods() [](#method-i-test_index_methods) - -## test_index_pages() [](#method-i-test_index_pages) - -## test_search_string() [](#method-i-test_search_string) - diff --git a/example/ruby/TestRDocGeneratorMarkup.md b/example/ruby/TestRDocGeneratorMarkup.md deleted file mode 100644 index 2086b40..0000000 --- a/example/ruby/TestRDocGeneratorMarkup.md +++ /dev/null @@ -1,84 +0,0 @@ -# Class: TestRDocGeneratorMarkup -**Inherits:** RDoc::TestCase - -**Includes:** RDoc::Generator::Markup, RDoc::Text - - - - -# Attributes -## path[RW] [](#attribute-i-path) -Returns the value of attribute path. - -## store[RW] [](#attribute-i-store) -Returns the value of attribute store. - - -#Instance Methods -## aref_to(target_path) [](#method-i-aref_to) -Generates a relative URL from this object's path to `target_path` - -## as_href(from_path) [](#method-i-as_href) -Generates a relative URL from `from_path` to this object's path - -## cvs_url(url, full_path) [](#method-i-cvs_url) -Build a webcvs URL starting for the given `url` with `full_path` appended as -the destination path. If `url` contains '%s' `full_path` will be will replace -the %s using sprintf on the `url`. - -## description() [](#method-i-description) -Handy wrapper for marking up this object's comment - -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## find_symbol(name) [](#method-i-find_symbol) - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## formatter() [](#method-i-formatter) -Creates an RDoc::Markup::ToHtmlCrossref formatter - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## parse(text, format'rdoc') [](#method-i-parse) -Normalizes `text` then builds a RDoc::Markup::Document from it - -## setup() [](#method-i-setup) - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## test_aref_to() [](#method-i-test_aref_to) - -## test_as_href() [](#method-i-test_as_href) - -## test_cvs_url() [](#method-i-test_cvs_url) - -## test_description() [](#method-i-test_description) - -## test_formatter() [](#method-i-test_formatter) - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/TestRDocGeneratorPOT.md b/example/ruby/TestRDocGeneratorPOT.md deleted file mode 100644 index 723727c..0000000 --- a/example/ruby/TestRDocGeneratorPOT.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocGeneratorPOT -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_generate() [](#method-i-test_generate) - diff --git a/example/ruby/TestRDocGeneratorPOTPO.md b/example/ruby/TestRDocGeneratorPOTPO.md deleted file mode 100644 index 9dd88ba..0000000 --- a/example/ruby/TestRDocGeneratorPOTPO.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocGeneratorPOTPO -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_empty() [](#method-i-test_empty) - -## test_have_entry() [](#method-i-test_have_entry) - diff --git a/example/ruby/TestRDocGeneratorPOTPOEntry.md b/example/ruby/TestRDocGeneratorPOTPOEntry.md deleted file mode 100644 index ff578ee..0000000 --- a/example/ruby/TestRDocGeneratorPOTPOEntry.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestRDocGeneratorPOTPOEntry -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## test_extracted_comment_multiple_lines() [](#method-i-test_extracted_comment_multiple_lines) - -## test_extracted_comment_normal() [](#method-i-test_extracted_comment_normal) - -## test_flags_multiple() [](#method-i-test_flags_multiple) - -## test_flags_normal() [](#method-i-test_flags_normal) - -## test_full() [](#method-i-test_full) - -## test_msgid_back_slash() [](#method-i-test_msgid_back_slash) - -## test_msgid_double_quote() [](#method-i-test_msgid_double_quote) - -## test_msgid_multiple_lines() [](#method-i-test_msgid_multiple_lines) - -## test_msgid_normal() [](#method-i-test_msgid_normal) - -## test_msgid_tab() [](#method-i-test_msgid_tab) - -## test_references_multiple() [](#method-i-test_references_multiple) - -## test_references_normal() [](#method-i-test_references_normal) - -## test_translator_comment_multiple_lines() [](#method-i-test_translator_comment_multiple_lines) - -## test_translator_comment_normal() [](#method-i-test_translator_comment_normal) - diff --git a/example/ruby/TestRDocGeneratorRI.md b/example/ruby/TestRDocGeneratorRI.md deleted file mode 100644 index c2c7e20..0000000 --- a/example/ruby/TestRDocGeneratorRI.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRDocGeneratorRI -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_generate() [](#method-i-test_generate) - -## test_generate_dry_run() [](#method-i-test_generate_dry_run) - diff --git a/example/ruby/TestRDocI18nLocale.md b/example/ruby/TestRDocI18nLocale.md deleted file mode 100644 index 700ad3e..0000000 --- a/example/ruby/TestRDocI18nLocale.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestRDocI18nLocale -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_load_existent_po() [](#method-i-test_load_existent_po) - -## test_load_nonexistent_po() [](#method-i-test_load_nonexistent_po) - -## test_name() [](#method-i-test_name) - -## test_translate_existent_message() [](#method-i-test_translate_existent_message) - -## test_translate_nonexistent_message() [](#method-i-test_translate_nonexistent_message) - diff --git a/example/ruby/TestRDocI18nText.md b/example/ruby/TestRDocI18nText.md deleted file mode 100644 index 5b46151..0000000 --- a/example/ruby/TestRDocI18nText.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRDocI18nText -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## test_multiple_paragraphs() [](#method-i-test_multiple_paragraphs) - -## test_translate_keep_empty_lines() [](#method-i-test_translate_keep_empty_lines) - -## test_translate_multiple_paragraphs() [](#method-i-test_translate_multiple_paragraphs) - -## test_translate_not_translated_message() [](#method-i-test_translate_not_translated_message) - diff --git a/example/ruby/TestRDocInclude.md b/example/ruby/TestRDocInclude.md deleted file mode 100644 index 5f01328..0000000 --- a/example/ruby/TestRDocInclude.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRDocInclude -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_module() [](#method-i-test_module) - -## test_module_extended() [](#method-i-test_module_extended) - -## test_store_equals() [](#method-i-test_store_equals) - diff --git a/example/ruby/TestRDocMarkdown.md b/example/ruby/TestRDocMarkdown.md deleted file mode 100644 index 815ba3b..0000000 --- a/example/ruby/TestRDocMarkdown.md +++ /dev/null @@ -1,184 +0,0 @@ -# Class: TestRDocMarkdown -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## parse(text) [](#method-i-parse) - -## setup() [](#method-i-setup) - -## test_class_parse() [](#method-i-test_class_parse) - -## test_code_fence_with_unintended_array() [](#method-i-test_code_fence_with_unintended_array) - -## test_emphasis() [](#method-i-test_emphasis) - -## test_gfm_table() [](#method-i-test_gfm_table) - -## test_gfm_table_2() [](#method-i-test_gfm_table_2) - -## test_parse_auto_link_email() [](#method-i-test_parse_auto_link_email) - -## test_parse_auto_link_url() [](#method-i-test_parse_auto_link_url) - -## test_parse_block_quote() [](#method-i-test_parse_block_quote) - -## test_parse_block_quote_continue() [](#method-i-test_parse_block_quote_continue) - -## test_parse_block_quote_list() [](#method-i-test_parse_block_quote_list) - -## test_parse_block_quote_newline() [](#method-i-test_parse_block_quote_newline) - -## test_parse_block_quote_separate() [](#method-i-test_parse_block_quote_separate) - -## test_parse_char_entity() [](#method-i-test_parse_char_entity) - -## test_parse_code() [](#method-i-test_parse_code) - -## test_parse_code_github() [](#method-i-test_parse_code_github) - -## test_parse_code_github_format() [](#method-i-test_parse_code_github_format) - -## test_parse_definition_list() [](#method-i-test_parse_definition_list) - -## test_parse_definition_list_indents() [](#method-i-test_parse_definition_list_indents) - -## test_parse_definition_list_multi_description() [](#method-i-test_parse_definition_list_multi_description) - -## test_parse_definition_list_multi_label() [](#method-i-test_parse_definition_list_multi_label) - -## test_parse_definition_list_multi_line() [](#method-i-test_parse_definition_list_multi_line) - -## test_parse_definition_list_no() [](#method-i-test_parse_definition_list_no) - -## test_parse_definition_list_rich_label() [](#method-i-test_parse_definition_list_rich_label) - -## test_parse_emphasis_star() [](#method-i-test_parse_emphasis_star) - -## test_parse_emphasis_underscore() [](#method-i-test_parse_emphasis_underscore) - -## test_parse_emphasis_underscore_embedded() [](#method-i-test_parse_emphasis_underscore_embedded) - -## test_parse_emphasis_underscore_in_word() [](#method-i-test_parse_emphasis_underscore_in_word) - -## test_parse_entity_dec() [](#method-i-test_parse_entity_dec) - -## test_parse_entity_hex() [](#method-i-test_parse_entity_hex) - -## test_parse_entity_named() [](#method-i-test_parse_entity_named) - -## test_parse_escape() [](#method-i-test_parse_escape) - -## test_parse_heading_atx() [](#method-i-test_parse_heading_atx) - -## test_parse_heading_setext_dash() [](#method-i-test_parse_heading_setext_dash) - -## test_parse_heading_setext_equals() [](#method-i-test_parse_heading_setext_equals) - -## test_parse_html() [](#method-i-test_parse_html) - -## test_parse_html_hr() [](#method-i-test_parse_html_hr) - -## test_parse_html_no_html() [](#method-i-test_parse_html_no_html) - -## test_parse_image() [](#method-i-test_parse_image) - -## test_parse_image_link() [](#method-i-test_parse_image_link) - -## test_parse_line_break() [](#method-i-test_parse_line_break) - -## test_parse_link_reference_id() [](#method-i-test_parse_link_reference_id) - -## test_parse_link_reference_id_adjacent() [](#method-i-test_parse_link_reference_id_adjacent) - -## test_parse_link_reference_id_eof() [](#method-i-test_parse_link_reference_id_eof) - -## test_parse_link_reference_id_many() [](#method-i-test_parse_link_reference_id_many) - -## test_parse_link_reference_implicit() [](#method-i-test_parse_link_reference_implicit) - -## test_parse_list_bullet() [](#method-i-test_parse_list_bullet) - -## test_parse_list_bullet_auto_link() [](#method-i-test_parse_list_bullet_auto_link) - -## test_parse_list_bullet_continue() [](#method-i-test_parse_list_bullet_continue) - -## test_parse_list_bullet_multiline() [](#method-i-test_parse_list_bullet_multiline) - -## test_parse_list_bullet_nest() [](#method-i-test_parse_list_bullet_nest) - -## test_parse_list_bullet_nest_continue() [](#method-i-test_parse_list_bullet_nest_continue) - -## test_parse_list_bullet_nest_loose() [](#method-i-test_parse_list_bullet_nest_loose) - -## test_parse_list_number() [](#method-i-test_parse_list_number) - -## test_parse_list_number_continue() [](#method-i-test_parse_list_number_continue) - -## test_parse_note() [](#method-i-test_parse_note) - -## test_parse_note_indent() [](#method-i-test_parse_note_indent) - -## test_parse_note_inline() [](#method-i-test_parse_note_inline) - -## test_parse_note_multiple() [](#method-i-test_parse_note_multiple) - -## test_parse_note_no_notes() [](#method-i-test_parse_note_no_notes) - -## test_parse_paragraph() [](#method-i-test_parse_paragraph) - -## test_parse_paragraph_break_on_newline() [](#method-i-test_parse_paragraph_break_on_newline) - -## test_parse_paragraph_html() [](#method-i-test_parse_paragraph_html) - -## test_parse_paragraph_html_no_html() [](#method-i-test_parse_paragraph_html_no_html) - -## test_parse_paragraph_indent_one() [](#method-i-test_parse_paragraph_indent_one) - -## test_parse_paragraph_indent_three() [](#method-i-test_parse_paragraph_indent_three) - -## test_parse_paragraph_indent_two() [](#method-i-test_parse_paragraph_indent_two) - -## test_parse_paragraph_multiline() [](#method-i-test_parse_paragraph_multiline) - -## test_parse_paragraph_stars() [](#method-i-test_parse_paragraph_stars) - -## test_parse_paragraph_two() [](#method-i-test_parse_paragraph_two) - -## test_parse_plain() [](#method-i-test_parse_plain) - -## test_parse_reference_link_embedded_bracket() [](#method-i-test_parse_reference_link_embedded_bracket) - -## test_parse_rule_dash() [](#method-i-test_parse_rule_dash) - -## test_parse_rule_star() [](#method-i-test_parse_rule_star) - -## test_parse_rule_underscore() [](#method-i-test_parse_rule_underscore) - -## test_parse_strike_tilde() [](#method-i-test_parse_strike_tilde) - -## test_parse_strike_tilde_no() [](#method-i-test_parse_strike_tilde_no) - -## test_parse_strike_words_tilde() [](#method-i-test_parse_strike_words_tilde) - -## test_parse_strong_emphasis_star() [](#method-i-test_parse_strong_emphasis_star) - -## test_parse_strong_emphasis_underscore() [](#method-i-test_parse_strong_emphasis_underscore) - -## test_parse_strong_star() [](#method-i-test_parse_strong_star) - -## test_parse_strong_underscore() [](#method-i-test_parse_strong_underscore) - -## test_parse_style() [](#method-i-test_parse_style) - -## test_parse_style_disabled() [](#method-i-test_parse_style_disabled) - -## test_parse_verbatim() [](#method-i-test_parse_verbatim) - -## test_parse_verbatim_eof() [](#method-i-test_parse_verbatim_eof) - -## test_strong() [](#method-i-test_strong) - diff --git a/example/ruby/TestRDocMarkdownTest.md b/example/ruby/TestRDocMarkdownTest.md deleted file mode 100644 index bacef44..0000000 --- a/example/ruby/TestRDocMarkdownTest.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: TestRDocMarkdownTest -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_amps_and_angle_encoding() [](#method-i-test_amps_and_angle_encoding) - -## test_auto_links() [](#method-i-test_auto_links) - -## test_backslash_escapes() [](#method-i-test_backslash_escapes) - -## test_blockquotes_with_code_blocks() [](#method-i-test_blockquotes_with_code_blocks) - -## test_code_blocks() [](#method-i-test_code_blocks) - -## test_code_spans() [](#method-i-test_code_spans) - -## test_hard_wrapped_paragraphs_with_list_like_lines() [](#method-i-test_hard_wrapped_paragraphs_with_list_like_lines) - -## test_horizontal_rules() [](#method-i-test_horizontal_rules) - -## test_inline_html_advanced() [](#method-i-test_inline_html_advanced) - -## test_inline_html_comments() [](#method-i-test_inline_html_comments) - -## test_inline_html_simple() [](#method-i-test_inline_html_simple) - -## test_links_inline_style() [](#method-i-test_links_inline_style) - -## test_links_reference_style() [](#method-i-test_links_reference_style) - -## test_links_shortcut_references() [](#method-i-test_links_shortcut_references) - -## test_literal_quotes_in_titles() [](#method-i-test_literal_quotes_in_titles) - -## test_markdown_documentation_basics() [](#method-i-test_markdown_documentation_basics) - -## test_markdown_documentation_syntax() [](#method-i-test_markdown_documentation_syntax) - -## test_nested_blockquotes() [](#method-i-test_nested_blockquotes) - -## test_ordered_and_unordered_lists() [](#method-i-test_ordered_and_unordered_lists) - -## test_strong_and_em_together() [](#method-i-test_strong_and_em_together) - -## test_tabs() [](#method-i-test_tabs) - -## test_tidiness() [](#method-i-test_tidiness) - diff --git a/example/ruby/TestRDocMarkup.md b/example/ruby/TestRDocMarkup.md deleted file mode 100644 index 0da89ca..0000000 --- a/example/ruby/TestRDocMarkup.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRDocMarkup -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## test_class_parse() [](#method-i-test_class_parse) - -## test_convert() [](#method-i-test_convert) - -## test_convert_custom_markup() [](#method-i-test_convert_custom_markup) - -## test_convert_document() [](#method-i-test_convert_document) - diff --git a/example/ruby/TestRDocMarkupAttributeManager.md b/example/ruby/TestRDocMarkupAttributeManager.md deleted file mode 100644 index d871f37..0000000 --- a/example/ruby/TestRDocMarkupAttributeManager.md +++ /dev/null @@ -1,87 +0,0 @@ -# Class: TestRDocMarkupAttributeManager -**Inherits:** RDoc::TestCase - - - - -# Class Methods -## str() [](#method-c-str) -## str=(str ) [](#method-c-str=) - -#Instance Methods -## crossref(text) [](#method-i-crossref) - -## output(str) [](#method-i-output) - -## setup() [](#method-i-setup) - -## test_add_html_tag() [](#method-i-test_add_html_tag) - -## test_add_regexp_handling() [](#method-i-test_add_regexp_handling) - -## test_add_word_pair() [](#method-i-test_add_word_pair) - -## test_add_word_pair_angle() [](#method-i-test_add_word_pair_angle) - -## test_add_word_pair_invalid() [](#method-i-test_add_word_pair_invalid) - -## test_add_word_pair_map() [](#method-i-test_add_word_pair_map) - -## test_add_word_pair_matching() [](#method-i-test_add_word_pair_matching) - -## test_adding() [](#method-i-test_adding) - -## test_basic() [](#method-i-test_basic) - -## test_bold() [](#method-i-test_bold) - -## test_bold_html_escaped() [](#method-i-test_bold_html_escaped) - -## test_combined() [](#method-i-test_combined) - -## test_convert_attrs() [](#method-i-test_convert_attrs) - -## test_convert_attrs_does_not_ignore_after_tt() [](#method-i-test_convert_attrs_does_not_ignore_after_tt) - -## test_convert_attrs_ignores_code() [](#method-i-test_convert_attrs_ignores_code) - -## test_convert_attrs_ignores_tt() [](#method-i-test_convert_attrs_ignores_tt) - -## test_convert_attrs_preserves_double() [](#method-i-test_convert_attrs_preserves_double) - -## test_escapes() [](#method-i-test_escapes) - -## test_exclude_tag() [](#method-i-test_exclude_tag) - -## test_exclude_tag_flow() [](#method-i-test_exclude_tag_flow) - -## test_html_like_em_bold() [](#method-i-test_html_like_em_bold) - -## test_html_like_em_bold_SGML() [](#method-i-test_html_like_em_bold_SGML) - -## test_html_like_em_bold_mixed_case() [](#method-i-test_html_like_em_bold_mixed_case) - -## test_html_like_em_bold_nested_1() [](#method-i-test_html_like_em_bold_nested_1) - -## test_html_like_em_bold_nested_2() [](#method-i-test_html_like_em_bold_nested_2) - -## test_html_like_em_bold_nested_mixed_case() [](#method-i-test_html_like_em_bold_nested_mixed_case) - -## test_html_like_teletype() [](#method-i-test_html_like_teletype) - -## test_html_like_teletype_em_bold_SGML() [](#method-i-test_html_like_teletype_em_bold_SGML) - -## test_initial_html() [](#method-i-test_initial_html) - -## test_initial_word_pairs() [](#method-i-test_initial_word_pairs) - -## test_lost_tag_for_the_second_time() [](#method-i-test_lost_tag_for_the_second_time) - -## test_mask_protected_sequence() [](#method-i-test_mask_protected_sequence) - -## test_protect() [](#method-i-test_protect) - -## test_regexp_handling() [](#method-i-test_regexp_handling) - -## test_tt_html() [](#method-i-test_tt_html) - diff --git a/example/ruby/TestRDocMarkupAttributes.md b/example/ruby/TestRDocMarkupAttributes.md deleted file mode 100644 index c595bbc..0000000 --- a/example/ruby/TestRDocMarkupAttributes.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRDocMarkupAttributes -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_as_string() [](#method-i-test_as_string) - -## test_bitmap_for() [](#method-i-test_bitmap_for) - -## test_each_name_of() [](#method-i-test_each_name_of) - diff --git a/example/ruby/TestRDocMarkupDocument.md b/example/ruby/TestRDocMarkupDocument.md deleted file mode 100644 index 4540890..0000000 --- a/example/ruby/TestRDocMarkupDocument.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestRDocMarkupDocument -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_append() [](#method-i-test_append) - -## test_append_document() [](#method-i-test_append_document) - -## test_append_string() [](#method-i-test_append_string) - -## test_concat() [](#method-i-test_concat) - -## test_each() [](#method-i-test_each) - -## test_empty_eh() [](#method-i-test_empty_eh) - -## test_empty_eh_document() [](#method-i-test_empty_eh_document) - -## test_equals2() [](#method-i-test_equals2) - -## test_equals2_file() [](#method-i-test_equals2_file) - -## test_file_equals() [](#method-i-test_file_equals) - -## test_file_equals_top_level() [](#method-i-test_file_equals_top_level) - -## test_lt2() [](#method-i-test_lt2) - -## test_merge() [](#method-i-test_merge) - -## test_merge_add() [](#method-i-test_merge_add) - -## test_merge_empty() [](#method-i-test_merge_empty) - -## test_push() [](#method-i-test_push) - -## test_table_of_contents() [](#method-i-test_table_of_contents) - -## test_table_of_contents_omit_headings_below() [](#method-i-test_table_of_contents_omit_headings_below) - diff --git a/example/ruby/TestRDocMarkupFormatter.md b/example/ruby/TestRDocMarkupFormatter.md deleted file mode 100644 index 2c0f24d..0000000 --- a/example/ruby/TestRDocMarkupFormatter.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: TestRDocMarkupFormatter -**Inherits:** RDoc::TestCase - - - - -# Class Methods -## handle_regexp_RDOCLINK(target ) [](#method-c-handle_regexp_RDOCLINK) -## handle_regexp_TIDYLINK(target ) [](#method-c-handle_regexp_TIDYLINK) - -#Instance Methods -## gen(from, to) [](#method-i-gen) - -## regexp_handling_names() [](#method-i-regexp_handling_names) - -## setup() [](#method-i-setup) - -## test_add_regexp_handling_RDOCLINK() [](#method-i-test_add_regexp_handling_RDOCLINK) - -## test_add_regexp_handling_TIDYLINK() [](#method-i-test_add_regexp_handling_TIDYLINK) - -## test_class_gen_relative_url() [](#method-i-test_class_gen_relative_url) - -## test_convert_tt_regexp_handling() [](#method-i-test_convert_tt_regexp_handling) - -## test_parse_url() [](#method-i-test_parse_url) - -## test_parse_url_anchor() [](#method-i-test_parse_url_anchor) - -## test_parse_url_link() [](#method-i-test_parse_url_link) - -## test_parse_url_link_id() [](#method-i-test_parse_url_link_id) - -## test_parse_url_rdoc_label() [](#method-i-test_parse_url_rdoc_label) - -## test_parse_url_scheme() [](#method-i-test_parse_url_scheme) - diff --git a/example/ruby/TestRDocMarkupFormatter/ToTest.md b/example/ruby/TestRDocMarkupFormatter/ToTest.md deleted file mode 100644 index 927e043..0000000 --- a/example/ruby/TestRDocMarkupFormatter/ToTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestRDocMarkupFormatter::ToTest -**Inherits:** RDoc::Markup::Formatter - - - - - -#Instance Methods -## accept_paragraph(paragraph) [](#method-i-accept_paragraph) - -## attributes(text) [](#method-i-attributes) - -## end_accepting() [](#method-i-end_accepting) - -## handle_regexp_CAPS(target) [](#method-i-handle_regexp_CAPS) - -## initialize(markup) [](#method-i-initialize) - -**@return** [ToTest] a new instance of ToTest - -## start_accepting() [](#method-i-start_accepting) - diff --git a/example/ruby/TestRDocMarkupHardBreak.md b/example/ruby/TestRDocMarkupHardBreak.md deleted file mode 100644 index 566535b..0000000 --- a/example/ruby/TestRDocMarkupHardBreak.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocMarkupHardBreak -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_accept() [](#method-i-test_accept) - -## test_equals2() [](#method-i-test_equals2) - diff --git a/example/ruby/TestRDocMarkupHeading.md b/example/ruby/TestRDocMarkupHeading.md deleted file mode 100644 index fe10756..0000000 --- a/example/ruby/TestRDocMarkupHeading.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRDocMarkupHeading -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_aref() [](#method-i-test_aref) - -## test_label() [](#method-i-test_label) - -## test_plain_html() [](#method-i-test_plain_html) - diff --git a/example/ruby/TestRDocMarkupInclude.md b/example/ruby/TestRDocMarkupInclude.md deleted file mode 100644 index 567c7c3..0000000 --- a/example/ruby/TestRDocMarkupInclude.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRDocMarkupInclude -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_equals2() [](#method-i-test_equals2) - diff --git a/example/ruby/TestRDocMarkupIndentedParagraph.md b/example/ruby/TestRDocMarkupIndentedParagraph.md deleted file mode 100644 index 22da194..0000000 --- a/example/ruby/TestRDocMarkupIndentedParagraph.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestRDocMarkupIndentedParagraph -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_accept() [](#method-i-test_accept) - -## test_equals2() [](#method-i-test_equals2) - -## test_initialize() [](#method-i-test_initialize) - -## test_text() [](#method-i-test_text) - -## test_text_break() [](#method-i-test_text_break) - diff --git a/example/ruby/TestRDocMarkupParagraph.md b/example/ruby/TestRDocMarkupParagraph.md deleted file mode 100644 index ac3658b..0000000 --- a/example/ruby/TestRDocMarkupParagraph.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocMarkupParagraph -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## test_accept() [](#method-i-test_accept) - -## test_text() [](#method-i-test_text) - -## test_text_break() [](#method-i-test_text_break) - diff --git a/example/ruby/TestRDocMarkupParser.md b/example/ruby/TestRDocMarkupParser.md deleted file mode 100644 index 35ca3b9..0000000 --- a/example/ruby/TestRDocMarkupParser.md +++ /dev/null @@ -1,213 +0,0 @@ -# Class: TestRDocMarkupParser -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_build_heading() [](#method-i-test_build_heading) - -## test_get() [](#method-i-test_get) - -## test_parse_block_quote() [](#method-i-test_parse_block_quote) - -## test_parse_bullet() [](#method-i-test_parse_bullet) - -## test_parse_bullet_heading() [](#method-i-test_parse_bullet_heading) - -## test_parse_bullet_indent() [](#method-i-test_parse_bullet_indent) - -## test_parse_bullet_indent_verbatim() [](#method-i-test_parse_bullet_indent_verbatim) - -## test_parse_bullet_multiline() [](#method-i-test_parse_bullet_multiline) - -## test_parse_bullet_multiparagraph() [](#method-i-test_parse_bullet_multiparagraph) - -## test_parse_bullet_paragraph() [](#method-i-test_parse_bullet_paragraph) - -## test_parse_bullet_utf_8() [](#method-i-test_parse_bullet_utf_8) - -## test_parse_bullet_verbatim_heading() [](#method-i-test_parse_bullet_verbatim_heading) - -## test_parse_dash() [](#method-i-test_parse_dash) - -## test_parse_heading() [](#method-i-test_parse_heading) - -## test_parse_heading_bullet() [](#method-i-test_parse_heading_bullet) - -## test_parse_heading_empty() [](#method-i-test_parse_heading_empty) - -## test_parse_heading_heading() [](#method-i-test_parse_heading_heading) - -## test_parse_heading_label() [](#method-i-test_parse_heading_label) - -## test_parse_heading_lalpha() [](#method-i-test_parse_heading_lalpha) - -## test_parse_heading_note() [](#method-i-test_parse_heading_note) - -## test_parse_heading_number() [](#method-i-test_parse_heading_number) - -## test_parse_heading_three() [](#method-i-test_parse_heading_three) - -## test_parse_heading_ualpha() [](#method-i-test_parse_heading_ualpha) - -## test_parse_label() [](#method-i-test_parse_label) - -## test_parse_label_bullet() [](#method-i-test_parse_label_bullet) - -## test_parse_label_multi_label() [](#method-i-test_parse_label_multi_label) - -## test_parse_label_multi_line() [](#method-i-test_parse_label_multi_line) - -## test_parse_label_newline() [](#method-i-test_parse_label_newline) - -## test_parse_lalpha() [](#method-i-test_parse_lalpha) - -## test_parse_lalpha_ualpha() [](#method-i-test_parse_lalpha_ualpha) - -## test_parse_lalpha_utf_8() [](#method-i-test_parse_lalpha_utf_8) - -## test_parse_line_break() [](#method-i-test_parse_line_break) - -## test_parse_list_list_1() [](#method-i-test_parse_list_list_1) - -## test_parse_list_list_2() [](#method-i-test_parse_list_list_2) - -## test_parse_list_verbatim() [](#method-i-test_parse_list_verbatim) - -## test_parse_lists() [](#method-i-test_parse_lists) - -## test_parse_note() [](#method-i-test_parse_note) - -## test_parse_note_empty() [](#method-i-test_parse_note_empty) - -## test_parse_note_note() [](#method-i-test_parse_note_note) - -## test_parse_number_bullet() [](#method-i-test_parse_number_bullet) - -## test_parse_paragraph() [](#method-i-test_parse_paragraph) - -## test_parse_paragraph_multiline() [](#method-i-test_parse_paragraph_multiline) - -## test_parse_paragraph_verbatim() [](#method-i-test_parse_paragraph_verbatim) - -## test_parse_rule() [](#method-i-test_parse_rule) - -## test_parse_trailing_cr() [](#method-i-test_parse_trailing_cr) - -## test_parse_ualpha() [](#method-i-test_parse_ualpha) - -## test_parse_verbatim() [](#method-i-test_parse_verbatim) - -## test_parse_verbatim_bullet() [](#method-i-test_parse_verbatim_bullet) - -## test_parse_verbatim_dash() [](#method-i-test_parse_verbatim_dash) - -## test_parse_verbatim_fold() [](#method-i-test_parse_verbatim_fold) - -## test_parse_verbatim_heading() [](#method-i-test_parse_verbatim_heading) - -## test_parse_verbatim_heading2() [](#method-i-test_parse_verbatim_heading2) - -## test_parse_verbatim_label() [](#method-i-test_parse_verbatim_label) - -## test_parse_verbatim_lalpha() [](#method-i-test_parse_verbatim_lalpha) - -## test_parse_verbatim_markup_example() [](#method-i-test_parse_verbatim_markup_example) - -## test_parse_verbatim_merge() [](#method-i-test_parse_verbatim_merge) - -## test_parse_verbatim_merge2() [](#method-i-test_parse_verbatim_merge2) - -## test_parse_verbatim_multilevel() [](#method-i-test_parse_verbatim_multilevel) - -## test_parse_verbatim_multiline() [](#method-i-test_parse_verbatim_multiline) - -## test_parse_verbatim_note() [](#method-i-test_parse_verbatim_note) - -## test_parse_verbatim_number() [](#method-i-test_parse_verbatim_number) - -## test_parse_verbatim_rule() [](#method-i-test_parse_verbatim_rule) - -## test_parse_verbatim_rule2() [](#method-i-test_parse_verbatim_rule2) - -## test_parse_verbatim_trim() [](#method-i-test_parse_verbatim_trim) - -## test_parse_verbatim_ualpha() [](#method-i-test_parse_verbatim_ualpha) - -## test_parse_whitespace() [](#method-i-test_parse_whitespace) - -## test_peek_token() [](#method-i-test_peek_token) - -## test_skip() [](#method-i-test_skip) - -## test_tokenize_bullet() [](#method-i-test_tokenize_bullet) - -## test_tokenize_bullet_indent() [](#method-i-test_tokenize_bullet_indent) - -## test_tokenize_heading() [](#method-i-test_tokenize_heading) - -## test_tokenize_heading_empty() [](#method-i-test_tokenize_heading_empty) - -## test_tokenize_heading_heading() [](#method-i-test_tokenize_heading_heading) - -## test_tokenize_heading_no_space() [](#method-i-test_tokenize_heading_no_space) - -## test_tokenize_label() [](#method-i-test_tokenize_label) - -## test_tokenize_label_newline() [](#method-i-test_tokenize_label_newline) - -## test_tokenize_label_newline_windows() [](#method-i-test_tokenize_label_newline_windows) - -## test_tokenize_label_note() [](#method-i-test_tokenize_label_note) - -## test_tokenize_lalpha() [](#method-i-test_tokenize_lalpha) - -## test_tokenize_line_break() [](#method-i-test_tokenize_line_break) - -## test_tokenize_line_break_long() [](#method-i-test_tokenize_line_break_long) - -## test_tokenize_line_break_no_short() [](#method-i-test_tokenize_line_break_no_short) - -## test_tokenize_note() [](#method-i-test_tokenize_note) - -## test_tokenize_note_empty() [](#method-i-test_tokenize_note_empty) - -## test_tokenize_note_newline() [](#method-i-test_tokenize_note_newline) - -## test_tokenize_note_newline_windows() [](#method-i-test_tokenize_note_newline_windows) - -## test_tokenize_note_not() [](#method-i-test_tokenize_note_not) - -## test_tokenize_note_utf_8() [](#method-i-test_tokenize_note_utf_8) - -## test_tokenize_number() [](#method-i-test_tokenize_number) - -## test_tokenize_number_period() [](#method-i-test_tokenize_number_period) - -## test_tokenize_number_period_continue() [](#method-i-test_tokenize_number_period_continue) - -## test_tokenize_paragraphs() [](#method-i-test_tokenize_paragraphs) - -## test_tokenize_rule() [](#method-i-test_tokenize_rule) - -## test_tokenize_rule_windows() [](#method-i-test_tokenize_rule_windows) - -## test_tokenize_ualpha() [](#method-i-test_tokenize_ualpha) - -## test_tokenize_verbatim_heading() [](#method-i-test_tokenize_verbatim_heading) - -## test_tokenize_verbatim_rule() [](#method-i-test_tokenize_verbatim_rule) - -## test_tokenize_verbatim_rule_fancy() [](#method-i-test_tokenize_verbatim_rule_fancy) - -## test_unget() [](#method-i-test_unget) - -## test_verbatim_normalize() [](#method-i-test_verbatim_normalize) -HACK move to Verbatim test case - -## util_parser() [](#method-i-util_parser) - diff --git a/example/ruby/TestRDocMarkupRaw.md b/example/ruby/TestRDocMarkupRaw.md deleted file mode 100644 index 182e173..0000000 --- a/example/ruby/TestRDocMarkupRaw.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocMarkupRaw -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_pretty_print() [](#method-i-test_pretty_print) - -## test_push() [](#method-i-test_push) - diff --git a/example/ruby/TestRDocMarkupToHtmlSnippet.md b/example/ruby/TestRDocMarkupToHtmlSnippet.md deleted file mode 100644 index a7c151a..0000000 --- a/example/ruby/TestRDocMarkupToHtmlSnippet.md +++ /dev/null @@ -1,166 +0,0 @@ -# Class: TestRDocMarkupToHtmlSnippet -**Inherits:** RDoc::Markup::FormatterTestCase - - - - - -#Instance Methods -## accept_blank_line() [](#method-i-accept_blank_line) - -## accept_block_quote() [](#method-i-accept_block_quote) - -## accept_document() [](#method-i-accept_document) - -## accept_heading() [](#method-i-accept_heading) - -## accept_heading_1() [](#method-i-accept_heading_1) - -## accept_heading_2() [](#method-i-accept_heading_2) - -## accept_heading_3() [](#method-i-accept_heading_3) - -## accept_heading_4() [](#method-i-accept_heading_4) - -## accept_heading_b() [](#method-i-accept_heading_b) - -## accept_heading_suppressed_crossref() [](#method-i-accept_heading_suppressed_crossref) - -## accept_list_end_bullet() [](#method-i-accept_list_end_bullet) - -## accept_list_end_label() [](#method-i-accept_list_end_label) - -## accept_list_end_lalpha() [](#method-i-accept_list_end_lalpha) - -## accept_list_end_note() [](#method-i-accept_list_end_note) - -## accept_list_end_number() [](#method-i-accept_list_end_number) - -## accept_list_end_ualpha() [](#method-i-accept_list_end_ualpha) - -## accept_list_item_end_bullet() [](#method-i-accept_list_item_end_bullet) - -## accept_list_item_end_label() [](#method-i-accept_list_item_end_label) - -## accept_list_item_end_lalpha() [](#method-i-accept_list_item_end_lalpha) - -## accept_list_item_end_note() [](#method-i-accept_list_item_end_note) - -## accept_list_item_end_number() [](#method-i-accept_list_item_end_number) - -## accept_list_item_end_ualpha() [](#method-i-accept_list_item_end_ualpha) - -## accept_list_item_start_bullet() [](#method-i-accept_list_item_start_bullet) - -## accept_list_item_start_label() [](#method-i-accept_list_item_start_label) - -## accept_list_item_start_lalpha() [](#method-i-accept_list_item_start_lalpha) - -## accept_list_item_start_note() [](#method-i-accept_list_item_start_note) - -## accept_list_item_start_note_2() [](#method-i-accept_list_item_start_note_2) - -## accept_list_item_start_note_multi_description() [](#method-i-accept_list_item_start_note_multi_description) - -## accept_list_item_start_note_multi_label() [](#method-i-accept_list_item_start_note_multi_label) - -## accept_list_item_start_number() [](#method-i-accept_list_item_start_number) - -## accept_list_item_start_ualpha() [](#method-i-accept_list_item_start_ualpha) - -## accept_list_start_bullet() [](#method-i-accept_list_start_bullet) - -## accept_list_start_label() [](#method-i-accept_list_start_label) - -## accept_list_start_lalpha() [](#method-i-accept_list_start_lalpha) - -## accept_list_start_note() [](#method-i-accept_list_start_note) - -## accept_list_start_number() [](#method-i-accept_list_start_number) - -## accept_list_start_ualpha() [](#method-i-accept_list_start_ualpha) - -## accept_paragraph() [](#method-i-accept_paragraph) - -## accept_paragraph_b() [](#method-i-accept_paragraph_b) - -## accept_paragraph_br() [](#method-i-accept_paragraph_br) - -## accept_paragraph_break() [](#method-i-accept_paragraph_break) - -## accept_paragraph_i() [](#method-i-accept_paragraph_i) - -## accept_paragraph_plus() [](#method-i-accept_paragraph_plus) - -## accept_paragraph_star() [](#method-i-accept_paragraph_star) - -## accept_paragraph_underscore() [](#method-i-accept_paragraph_underscore) - -## accept_raw() [](#method-i-accept_raw) - -## accept_rule() [](#method-i-accept_rule) - -## accept_verbatim() [](#method-i-accept_verbatim) - -## end_accepting() [](#method-i-end_accepting) - -## list_nested() [](#method-i-list_nested) - -## list_verbatim() [](#method-i-list_verbatim) - -## setup() [](#method-i-setup) - -## start_accepting() [](#method-i-start_accepting) - -## test_accept_heading_7() [](#method-i-test_accept_heading_7) - -## test_accept_heading_aref_class() [](#method-i-test_accept_heading_aref_class) - -## test_accept_heading_aref_method() [](#method-i-test_accept_heading_aref_method) - -## test_accept_verbatim_ruby() [](#method-i-test_accept_verbatim_ruby) - -## test_accept_verbatim_ruby_error() [](#method-i-test_accept_verbatim_ruby_error) - -## test_add_paragraph() [](#method-i-test_add_paragraph) - -## test_convert_RDOCLINK_label_footmark() [](#method-i-test_convert_RDOCLINK_label_footmark) - -## test_convert_RDOCLINK_label_foottext() [](#method-i-test_convert_RDOCLINK_label_foottext) - -## test_convert_RDOCLINK_label_label() [](#method-i-test_convert_RDOCLINK_label_label) - -## test_convert_RDOCLINK_ref() [](#method-i-test_convert_RDOCLINK_ref) - -## test_convert_TIDYLINK_rdoc_label() [](#method-i-test_convert_TIDYLINK_rdoc_label) - -## test_convert_limit() [](#method-i-test_convert_limit) - -## test_convert_limit_2() [](#method-i-test_convert_limit_2) - -## test_convert_limit_in_tag() [](#method-i-test_convert_limit_in_tag) - -## test_convert_limit_over() [](#method-i-test_convert_limit_over) - -## test_convert_limit_paragraphs() [](#method-i-test_convert_limit_paragraphs) - -## test_convert_limit_verbatim() [](#method-i-test_convert_limit_verbatim) - -## test_convert_limit_verbatim_2() [](#method-i-test_convert_limit_verbatim_2) - -## test_convert_limit_verbatim_multiline() [](#method-i-test_convert_limit_verbatim_multiline) - -## test_convert_string() [](#method-i-test_convert_string) - -## test_handle_regexp_HYPERLINK_link() [](#method-i-test_handle_regexp_HYPERLINK_link) - -## test_list_verbatim_2() [](#method-i-test_list_verbatim_2) - -## test_off_tags() [](#method-i-test_off_tags) - -## test_on_tags() [](#method-i-test_on_tags) - -## test_to_html() [](#method-i-test_to_html) - -## util_format(text) [](#method-i-util_format) - diff --git a/example/ruby/TestRDocMarkupToJoinedParagraph.md b/example/ruby/TestRDocMarkupToJoinedParagraph.md deleted file mode 100644 index ef7a479..0000000 --- a/example/ruby/TestRDocMarkupToJoinedParagraph.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocMarkupToJoinedParagraph -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_accept_paragraph() [](#method-i-test_accept_paragraph) - -## test_accept_paragraph_break() [](#method-i-test_accept_paragraph_break) - diff --git a/example/ruby/TestRDocMarkupToLabel.md b/example/ruby/TestRDocMarkupToLabel.md deleted file mode 100644 index 60152e6..0000000 --- a/example/ruby/TestRDocMarkupToLabel.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: TestRDocMarkupToLabel -**Inherits:** RDoc::Markup::FormatterTestCase - - - - - -#Instance Methods -## empty() [](#method-i-empty) - -## end_accepting() [](#method-i-end_accepting) - -## setup() [](#method-i-setup) - -## test_convert_bold() [](#method-i-test_convert_bold) - -## test_convert_crossref() [](#method-i-test_convert_crossref) - -## test_convert_em() [](#method-i-test_convert_em) - -## test_convert_em_dash() [](#method-i-test_convert_em_dash) -for HTML conversion - -## test_convert_escape() [](#method-i-test_convert_escape) - -## test_convert_tidylink() [](#method-i-test_convert_tidylink) - -## test_convert_tt() [](#method-i-test_convert_tt) - diff --git a/example/ruby/TestRDocMarkupToTableOfContents.md b/example/ruby/TestRDocMarkupToTableOfContents.md deleted file mode 100644 index 2788634..0000000 --- a/example/ruby/TestRDocMarkupToTableOfContents.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestRDocMarkupToTableOfContents -**Inherits:** RDoc::Markup::FormatterTestCase - - - - - -#Instance Methods -## accept_heading() [](#method-i-accept_heading) - -## accept_heading_1() [](#method-i-accept_heading_1) - -## accept_heading_2() [](#method-i-accept_heading_2) - -## accept_heading_3() [](#method-i-accept_heading_3) - -## accept_heading_4() [](#method-i-accept_heading_4) - -## accept_heading_b() [](#method-i-accept_heading_b) - -## accept_heading_suppressed_crossref() [](#method-i-accept_heading_suppressed_crossref) - -## empty() [](#method-i-empty) - -## end_accepting() [](#method-i-end_accepting) - -## setup() [](#method-i-setup) - -## test_accept_document_omit_headings_below() [](#method-i-test_accept_document_omit_headings_below) - -## test_accept_heading_suppressed() [](#method-i-test_accept_heading_suppressed) - -## test_suppressed_eh() [](#method-i-test_suppressed_eh) - diff --git a/example/ruby/TestRDocMarkupToTtOnly.md b/example/ruby/TestRDocMarkupToTtOnly.md deleted file mode 100644 index bc423d3..0000000 --- a/example/ruby/TestRDocMarkupToTtOnly.md +++ /dev/null @@ -1,126 +0,0 @@ -# Class: TestRDocMarkupToTtOnly -**Inherits:** RDoc::Markup::FormatterTestCase - - - - - -#Instance Methods -## accept_blank_line() [](#method-i-accept_blank_line) - -## accept_block_quote() [](#method-i-accept_block_quote) - -## accept_document() [](#method-i-accept_document) - -## accept_heading() [](#method-i-accept_heading) - -## accept_heading_1() [](#method-i-accept_heading_1) - -## accept_heading_2() [](#method-i-accept_heading_2) - -## accept_heading_3() [](#method-i-accept_heading_3) - -## accept_heading_4() [](#method-i-accept_heading_4) - -## accept_heading_b() [](#method-i-accept_heading_b) - -## accept_heading_indent() [](#method-i-accept_heading_indent) - -## accept_heading_suppressed_crossref() [](#method-i-accept_heading_suppressed_crossref) - -## accept_list_end_bullet() [](#method-i-accept_list_end_bullet) - -## accept_list_end_label() [](#method-i-accept_list_end_label) - -## accept_list_end_lalpha() [](#method-i-accept_list_end_lalpha) - -## accept_list_end_note() [](#method-i-accept_list_end_note) - -## accept_list_end_number() [](#method-i-accept_list_end_number) - -## accept_list_end_ualpha() [](#method-i-accept_list_end_ualpha) - -## accept_list_item_end_bullet() [](#method-i-accept_list_item_end_bullet) - -## accept_list_item_end_label() [](#method-i-accept_list_item_end_label) - -## accept_list_item_end_lalpha() [](#method-i-accept_list_item_end_lalpha) - -## accept_list_item_end_note() [](#method-i-accept_list_item_end_note) - -## accept_list_item_end_number() [](#method-i-accept_list_item_end_number) - -## accept_list_item_end_ualpha() [](#method-i-accept_list_item_end_ualpha) - -## accept_list_item_start_bullet() [](#method-i-accept_list_item_start_bullet) - -## accept_list_item_start_label() [](#method-i-accept_list_item_start_label) - -## accept_list_item_start_lalpha() [](#method-i-accept_list_item_start_lalpha) - -## accept_list_item_start_note() [](#method-i-accept_list_item_start_note) - -## accept_list_item_start_note_2() [](#method-i-accept_list_item_start_note_2) - -## accept_list_item_start_note_multi_description() [](#method-i-accept_list_item_start_note_multi_description) - -## accept_list_item_start_note_multi_label() [](#method-i-accept_list_item_start_note_multi_label) - -## accept_list_item_start_number() [](#method-i-accept_list_item_start_number) - -## accept_list_item_start_ualpha() [](#method-i-accept_list_item_start_ualpha) - -## accept_list_start_bullet() [](#method-i-accept_list_start_bullet) - -## accept_list_start_label() [](#method-i-accept_list_start_label) - -## accept_list_start_lalpha() [](#method-i-accept_list_start_lalpha) - -## accept_list_start_note() [](#method-i-accept_list_start_note) - -## accept_list_start_number() [](#method-i-accept_list_start_number) - -## accept_list_start_ualpha() [](#method-i-accept_list_start_ualpha) - -## accept_paragraph() [](#method-i-accept_paragraph) - -## accept_paragraph_b() [](#method-i-accept_paragraph_b) - -## accept_paragraph_br() [](#method-i-accept_paragraph_br) - -## accept_paragraph_break() [](#method-i-accept_paragraph_break) - -## accept_paragraph_i() [](#method-i-accept_paragraph_i) - -## accept_paragraph_indent() [](#method-i-accept_paragraph_indent) - -## accept_paragraph_plus() [](#method-i-accept_paragraph_plus) - -## accept_paragraph_star() [](#method-i-accept_paragraph_star) - -## accept_paragraph_underscore() [](#method-i-accept_paragraph_underscore) - -## accept_paragraph_wrap() [](#method-i-accept_paragraph_wrap) - -## accept_raw() [](#method-i-accept_raw) - -## accept_rule() [](#method-i-accept_rule) - -## accept_rule_indent() [](#method-i-accept_rule_indent) - -## accept_verbatim() [](#method-i-accept_verbatim) - -## accept_verbatim_big_indent() [](#method-i-accept_verbatim_big_indent) - -## accept_verbatim_indent() [](#method-i-accept_verbatim_indent) - -## end_accepting() [](#method-i-end_accepting) - -## list_nested() [](#method-i-list_nested) - -## list_verbatim() [](#method-i-list_verbatim) - -## setup() [](#method-i-setup) - -## start_accepting() [](#method-i-start_accepting) - diff --git a/example/ruby/TestRDocMarkupVerbatim.md b/example/ruby/TestRDocMarkupVerbatim.md deleted file mode 100644 index f8a4cd0..0000000 --- a/example/ruby/TestRDocMarkupVerbatim.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRDocMarkupVerbatim -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## test_equals2() [](#method-i-test_equals2) - -## test_ruby_eh() [](#method-i-test_ruby_eh) - diff --git a/example/ruby/TestRDocMethodAttr.md b/example/ruby/TestRDocMethodAttr.md deleted file mode 100644 index 9c75e07..0000000 --- a/example/ruby/TestRDocMethodAttr.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestRDocMethodAttr -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## test_block_params_equal() [](#method-i-test_block_params_equal) - -## test_equals2() [](#method-i-test_equals2) - -## test_find_method_or_attribute_recursive() [](#method-i-test_find_method_or_attribute_recursive) - -## test_full_name() [](#method-i-test_full_name) - -## test_initialize_copy() [](#method-i-test_initialize_copy) - -## test_is_alias_for() [](#method-i-test_is_alias_for) - -## test_output_name() [](#method-i-test_output_name) - -## test_pretty_print() [](#method-i-test_pretty_print) - -## test_search_record() [](#method-i-test_search_record) - -## test_spaceship_orders_symbols_first() [](#method-i-test_spaceship_orders_symbols_first) - -## test_spaceship_returns_nil_on_inappropriate_types() [](#method-i-test_spaceship_returns_nil_on_inappropriate_types) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestRDocNormalClass.md b/example/ruby/TestRDocNormalClass.md deleted file mode 100644 index 367ca2b..0000000 --- a/example/ruby/TestRDocNormalClass.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestRDocNormalClass -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## test_ancestors() [](#method-i-test_ancestors) - -## test_ancestors_multilevel() [](#method-i-test_ancestors_multilevel) - -## test_aref() [](#method-i-test_aref) - -## test_definition() [](#method-i-test_definition) - -## test_direct_ancestors() [](#method-i-test_direct_ancestors) - diff --git a/example/ruby/TestRDocNormalModule.md b/example/ruby/TestRDocNormalModule.md deleted file mode 100644 index 2a0feb9..0000000 --- a/example/ruby/TestRDocNormalModule.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestRDocNormalModule -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ancestors_module() [](#method-i-test_ancestors_module) - -## test_aref() [](#method-i-test_aref) - -## test_definition() [](#method-i-test_definition) - -## test_module_eh() [](#method-i-test_module_eh) - diff --git a/example/ruby/TestRDocOptions.md b/example/ruby/TestRDocOptions.md deleted file mode 100644 index 66056e5..0000000 --- a/example/ruby/TestRDocOptions.md +++ /dev/null @@ -1,160 +0,0 @@ -# Class: TestRDocOptions -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_apply_default_exclude_option() [](#method-i-test_apply_default_exclude_option) - -## test_check_files() [](#method-i-test_check_files) - -## test_check_files_warn() [](#method-i-test_check_files_warn) - -## test_dry_run_default() [](#method-i-test_dry_run_default) - -## test_encoding_default() [](#method-i-test_encoding_default) - -## test_exclude_option_without_default() [](#method-i-test_exclude_option_without_default) - -## test_generator_descriptions() [](#method-i-test_generator_descriptions) - -## test_ignore_missing_arg() [](#method-i-test_ignore_missing_arg) - -## test_ignore_needless_arg() [](#method-i-test_ignore_needless_arg) - -## test_init_with_encoding() [](#method-i-test_init_with_encoding) - -## test_init_with_trim_paths() [](#method-i-test_init_with_trim_paths) - -## test_load_options() [](#method-i-test_load_options) - -## test_load_options_empty_file() [](#method-i-test_load_options_empty_file) - -## test_load_options_invalid() [](#method-i-test_load_options_invalid) - -## test_load_options_no_file() [](#method-i-test_load_options_no_file) - -## test_load_options_partial_override() [](#method-i-test_load_options_partial_override) - -## test_no_apply_default_exclude_option() [](#method-i-test_no_apply_default_exclude_option) - -## test_no_skip_test_value() [](#method-i-test_no_skip_test_value) - -## test_parse_copy_files_directory_absolute() [](#method-i-test_parse_copy_files_directory_absolute) - -## test_parse_copy_files_directory_relative() [](#method-i-test_parse_copy_files_directory_relative) - -## test_parse_copy_files_file_absolute() [](#method-i-test_parse_copy_files_file_absolute) - -## test_parse_copy_files_file_relative() [](#method-i-test_parse_copy_files_file_relative) - -## test_parse_coverage() [](#method-i-test_parse_coverage) - -## test_parse_coverage_C() [](#method-i-test_parse_coverage_C) - -## test_parse_coverage_C_level_0() [](#method-i-test_parse_coverage_C_level_0) - -## test_parse_coverage_C_level_1() [](#method-i-test_parse_coverage_C_level_1) - -## test_parse_coverage_level_1() [](#method-i-test_parse_coverage_level_1) - -## test_parse_coverage_no() [](#method-i-test_parse_coverage_no) - -## test_parse_dash_p() [](#method-i-test_parse_dash_p) - -## test_parse_dash_p_files() [](#method-i-test_parse_dash_p_files) - -## test_parse_default() [](#method-i-test_parse_default) - -## test_parse_deprecated() [](#method-i-test_parse_deprecated) - -## test_parse_dry_run() [](#method-i-test_parse_dry_run) - -## test_parse_embed_mixins() [](#method-i-test_parse_embed_mixins) - -## test_parse_encoding() [](#method-i-test_parse_encoding) - -## test_parse_encoding_invalid() [](#method-i-test_parse_encoding_invalid) - -## test_parse_extension_alias() [](#method-i-test_parse_extension_alias) - -## test_parse_force_update() [](#method-i-test_parse_force_update) - -## test_parse_format_for_extra_generator() [](#method-i-test_parse_format_for_extra_generator) - -## test_parse_formatter() [](#method-i-test_parse_formatter) - -## test_parse_formatter_ri() [](#method-i-test_parse_formatter_ri) - -## test_parse_formatter_ri_site() [](#method-i-test_parse_formatter_ri_site) - -## test_parse_h() [](#method-i-test_parse_h) - -## test_parse_help() [](#method-i-test_parse_help) - -## test_parse_help_extra_generator() [](#method-i-test_parse_help_extra_generator) - -## test_parse_ignore_invalid() [](#method-i-test_parse_ignore_invalid) - -## test_parse_ignore_invalid_default() [](#method-i-test_parse_ignore_invalid_default) - -## test_parse_ignore_invalid_no() [](#method-i-test_parse_ignore_invalid_no) - -## test_parse_ignore_invalid_no_quiet() [](#method-i-test_parse_ignore_invalid_no_quiet) - -## test_parse_locale_name() [](#method-i-test_parse_locale_name) - -## test_parse_locale_name_default() [](#method-i-test_parse_locale_name_default) - -## test_parse_main() [](#method-i-test_parse_main) - -## test_parse_markup() [](#method-i-test_parse_markup) - -## test_parse_page_dir() [](#method-i-test_parse_page_dir) - -## test_parse_page_dir_root() [](#method-i-test_parse_page_dir_root) - -## test_parse_ri_site() [](#method-i-test_parse_ri_site) - -## test_parse_root() [](#method-i-test_parse_root) - -## test_parse_tab_width() [](#method-i-test_parse_tab_width) - -## test_parse_template() [](#method-i-test_parse_template) - -## test_parse_template_load_path() [](#method-i-test_parse_template_load_path) - -## test_parse_template_nonexistent() [](#method-i-test_parse_template_nonexistent) - -## test_parse_template_stylesheets() [](#method-i-test_parse_template_stylesheets) - -## test_parse_visibility() [](#method-i-test_parse_visibility) - -## test_parse_write_options() [](#method-i-test_parse_write_options) - -## test_setup_generator() [](#method-i-test_setup_generator) - -## test_setup_generator_no_option_parser() [](#method-i-test_setup_generator_no_option_parser) - -## test_skip_test_default_value() [](#method-i-test_skip_test_default_value) - -## test_to_yaml() [](#method-i-test_to_yaml) - -## test_to_yaml_trim_paths() [](#method-i-test_to_yaml_trim_paths) - -## test_update_output_dir() [](#method-i-test_update_output_dir) - -## test_version() [](#method-i-test_version) - -## test_visibility() [](#method-i-test_visibility) - -## test_warn() [](#method-i-test_warn) - -## test_write_options() [](#method-i-test_write_options) - diff --git a/example/ruby/TestRDocOptions/DummyCoder.md b/example/ruby/TestRDocOptions/DummyCoder.md deleted file mode 100644 index c9c0480..0000000 --- a/example/ruby/TestRDocOptions/DummyCoder.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRDocOptions::DummyCoder -**Inherits:** Hash - - - - - -#Instance Methods -## tag=(tag) [](#method-i-tag=) - diff --git a/example/ruby/TestRDocParserC.md b/example/ruby/TestRDocParserC.md deleted file mode 100644 index 76e6304..0000000 --- a/example/ruby/TestRDocParserC.md +++ /dev/null @@ -1,226 +0,0 @@ -# Class: TestRDocParserC -**Inherits:** RDoc::TestCase - - -TODO: test call-seq parsing - -/* - * call-seq: - * ARGF.readlines(sep=$/) -> array - * ARGF.readlines(limit) -> array - * ARGF.readlines(sep, limit) -> array - * - * ARGF.to_a(sep=$/) -> array - * ARGF.to_a(limit) -> array - * ARGF.to_a(sep, limit) -> array - * - * Reads +ARGF+'s current file in its entirety, returning an +Array+ of its - * lines, one line per element. Lines are assumed to be separated by _sep_. - * - * lines = ARGF.readlines - * lines[0] #=> "This is line one\n" - */ - -assert call-seq did not stop at first empty line - -/* - * call-seq: - * - * flt ** other -> float - * - * Raises float the other power. - * - * 2.0**3 #=> 8.0 - */ - -assert call-seq correct (bug: was empty) - -/* call-seq: flt ** other -> float */ - -assert call-seq correct - - - -#Instance Methods -## assert_do_attr(flags) [](#method-i-assert_do_attr) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_class_can_parse() [](#method-i-test_class_can_parse) - -## test_define_method() [](#method-i-test_define_method) - -## test_define_method_dynamically() [](#method-i-test_define_method_dynamically) - -## test_define_method_private() [](#method-i-test_define_method_private) - -## test_define_method_private_singleton() [](#method-i-test_define_method_private_singleton) - -## test_define_method_singleton() [](#method-i-test_define_method_singleton) - -## test_define_method_with_category() [](#method-i-test_define_method_with_category) - -## test_define_method_with_prototype() [](#method-i-test_define_method_with_prototype) - -## test_do_aliases() [](#method-i-test_do_aliases) - -## test_do_aliases_missing_class() [](#method-i-test_do_aliases_missing_class) - -## test_do_aliases_singleton() [](#method-i-test_do_aliases_singleton) - -## test_do_classes_class() [](#method-i-test_do_classes_class) - -## test_do_classes_class_under() [](#method-i-test_do_classes_class_under) - -## test_do_classes_class_under_rb_path2class() [](#method-i-test_do_classes_class_under_rb_path2class) - -## test_do_classes_duplicate_class() [](#method-i-test_do_classes_duplicate_class) - -## test_do_classes_module() [](#method-i-test_do_classes_module) - -## test_do_classes_module_under() [](#method-i-test_do_classes_module_under) - -## test_do_classes_singleton() [](#method-i-test_do_classes_singleton) - -## test_do_classes_struct() [](#method-i-test_do_classes_struct) - -## test_do_classes_struct_under() [](#method-i-test_do_classes_struct_under) - -## test_do_classes_struct_without_accessor() [](#method-i-test_do_classes_struct_without_accessor) - -## test_do_classes_struct_without_accessor_under() [](#method-i-test_do_classes_struct_without_accessor_under) - -## test_do_constants() [](#method-i-test_do_constants) - -## test_do_constants_curses() [](#method-i-test_do_constants_curses) - -## test_do_constants_file() [](#method-i-test_do_constants_file) - -## test_do_constants_global() [](#method-i-test_do_constants_global) - -## test_do_includes() [](#method-i-test_do_includes) - -## test_do_methods_in_c() [](#method-i-test_do_methods_in_c) -HACK parsing warning instead of setting up in file - -## test_do_methods_in_cpp() [](#method-i-test_do_methods_in_cpp) -HACK parsing warning instead of setting up in file - -## test_do_methods_in_y() [](#method-i-test_do_methods_in_y) -HACK parsing warning instead of setting up in file - -## test_do_methods_singleton_class() [](#method-i-test_do_methods_singleton_class) - -## test_do_missing() [](#method-i-test_do_missing) - -## test_do_missing_cycle() [](#method-i-test_do_missing_cycle) - -## test_find_alias_comment() [](#method-i-test_find_alias_comment) - -## test_find_attr_comment_document_attr() [](#method-i-test_find_attr_comment_document_attr) - -## test_find_attr_comment_document_attr_oneline() [](#method-i-test_find_attr_comment_document_attr_oneline) - -## test_find_attr_comment_document_attr_overlap() [](#method-i-test_find_attr_comment_document_attr_overlap) - -## test_find_body() [](#method-i-test_find_body) - -## test_find_body_2() [](#method-i-test_find_body_2) - -## test_find_body_cast() [](#method-i-test_find_body_cast) - -## test_find_body_define() [](#method-i-test_find_body_define) - -## test_find_body_define_comment() [](#method-i-test_find_body_define_comment) - -## test_find_body_document_method() [](#method-i-test_find_body_document_method) - -## test_find_body_document_method_equals() [](#method-i-test_find_body_document_method_equals) - -## test_find_body_document_method_same() [](#method-i-test_find_body_document_method_same) - -## test_find_body_macro() [](#method-i-test_find_body_macro) - -## test_find_body_static_inline() [](#method-i-test_find_body_static_inline) - -## test_find_class_comment() [](#method-i-test_find_class_comment) - -## test_find_class_comment_define_class() [](#method-i-test_find_class_comment_define_class) - -## test_find_class_comment_define_class_Init_Foo() [](#method-i-test_find_class_comment_define_class_Init_Foo) - -## test_find_class_comment_define_class_Init_Foo_no_void() [](#method-i-test_find_class_comment_define_class_Init_Foo_no_void) - -## test_find_class_comment_define_class_bogus_comment() [](#method-i-test_find_class_comment_define_class_bogus_comment) - -## test_find_class_comment_define_class_under() [](#method-i-test_find_class_comment_define_class_under) - -## test_find_class_comment_define_class_under_Init() [](#method-i-test_find_class_comment_define_class_under_Init) - -## test_find_class_comment_init() [](#method-i-test_find_class_comment_init) - -## test_find_class_comment_initvm() [](#method-i-test_find_class_comment_initvm) - -## test_find_const_comment_document_const() [](#method-i-test_find_const_comment_document_const) - -## test_find_const_comment_document_const_full_name() [](#method-i-test_find_const_comment_document_const_full_name) - -## test_find_const_comment_rb_define() [](#method-i-test_find_const_comment_rb_define) - -## test_find_const_comment_rb_define_global() [](#method-i-test_find_const_comment_rb_define_global) - -## test_find_modifiers_call_seq() [](#method-i-test_find_modifiers_call_seq) - -## test_find_modifiers_nodoc() [](#method-i-test_find_modifiers_nodoc) - -## test_find_modifiers_yields() [](#method-i-test_find_modifiers_yields) - -## test_handle_method_args_0() [](#method-i-test_handle_method_args_0) - -## test_handle_method_args_1() [](#method-i-test_handle_method_args_1) - -## test_handle_method_args_2() [](#method-i-test_handle_method_args_2) - -## test_handle_method_args_minus_1() [](#method-i-test_handle_method_args_minus_1) - -## test_handle_method_args_minus_2() [](#method-i-test_handle_method_args_minus_2) -test_handle_args_minus_1 handled by test_handle_method - -## test_handle_method_initialize() [](#method-i-test_handle_method_initialize) - -## test_handle_singleton() [](#method-i-test_handle_singleton) - -## test_initialize() [](#method-i-test_initialize) - -## test_known_classes() [](#method-i-test_known_classes) - -## test_load_variable_map() [](#method-i-test_load_variable_map) - -## test_load_variable_map_empty() [](#method-i-test_load_variable_map_empty) - -## test_load_variable_map_legacy() [](#method-i-test_load_variable_map_legacy) - -## test_load_variable_map_singleton() [](#method-i-test_load_variable_map_singleton) - -## test_load_variable_map_trim() [](#method-i-test_load_variable_map_trim) - -## test_look_for_directives_in() [](#method-i-test_look_for_directives_in) - -## test_markup_format_default() [](#method-i-test_markup_format_default) - -## test_markup_format_override() [](#method-i-test_markup_format_override) - -## test_rb_scan_args() [](#method-i-test_rb_scan_args) - -## test_scan() [](#method-i-test_scan) - -## test_scan_method_copy() [](#method-i-test_scan_method_copy) - -## test_scan_order_dependent() [](#method-i-test_scan_order_dependent) - -## util_get_class(content, namenil) [](#method-i-util_get_class) - -## util_parser(content'') [](#method-i-util_parser) - diff --git a/example/ruby/TestRDocParserChangeLog.md b/example/ruby/TestRDocParserChangeLog.md deleted file mode 100644 index 443b792..0000000 --- a/example/ruby/TestRDocParserChangeLog.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: TestRDocParserChangeLog -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## log_entry(*a) [](#method-i-log_entry) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_class_can_parse() [](#method-i-test_class_can_parse) - -## test_continue_entry_body() [](#method-i-test_continue_entry_body) - -## test_continue_entry_body_empty() [](#method-i-test_continue_entry_body_empty) - -## test_continue_entry_body_function() [](#method-i-test_continue_entry_body_function) - -## test_create_document() [](#method-i-test_create_document) - -## test_create_entries() [](#method-i-test_create_entries) - -## test_create_entries_colons() [](#method-i-test_create_entries_colons) - -## test_create_items() [](#method-i-test_create_items) - -## test_group_entries() [](#method-i-test_group_entries) - -## test_parse_entries() [](#method-i-test_parse_entries) - -## test_parse_entries_bad_time() [](#method-i-test_parse_entries_bad_time) - -## test_parse_entries_git() [](#method-i-test_parse_entries_git) - -## test_parse_entries_gnu() [](#method-i-test_parse_entries_gnu) - -## test_scan() [](#method-i-test_scan) - -## test_scan_git() [](#method-i-test_scan_git) - -## test_scan_git_commit_date() [](#method-i-test_scan_git_commit_date) - -## util_parser(content'') [](#method-i-util_parser) - diff --git a/example/ruby/TestRDocParserMarkdown.md b/example/ruby/TestRDocParserMarkdown.md deleted file mode 100644 index 0ee8ecc..0000000 --- a/example/ruby/TestRDocParserMarkdown.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestRDocParserMarkdown -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_class_can_parse() [](#method-i-test_class_can_parse) - -## test_file() [](#method-i-test_file) - -## test_scan() [](#method-i-test_scan) - -## util_parser(content) [](#method-i-util_parser) - diff --git a/example/ruby/TestRDocParserPrismRuby.md b/example/ruby/TestRDocParserPrismRuby.md deleted file mode 100644 index 7770ccb..0000000 --- a/example/ruby/TestRDocParserPrismRuby.md +++ /dev/null @@ -1,188 +0,0 @@ -# Class: TestRDocParserPrismRuby -**Inherits:** RDoc::TestCase - -**Includes:** RDocParserPrismTestCases - - - - - -#Instance Methods -## accept_legacy_bug?() [](#method-i-accept_legacy_bug?) - -**@return** [Boolean] - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_alias() [](#method-i-test_alias) - -## test_alias_method() [](#method-i-test_alias_method) - -## test_alias_method_stopdoc_nodoc() [](#method-i-test_alias_method_stopdoc_nodoc) - -## test_alias_singleton() [](#method-i-test_alias_singleton) - -## test_attributes() [](#method-i-test_attributes) - -## test_attributes_nodoc() [](#method-i-test_attributes_nodoc) - -## test_attributes_nodoc_track() [](#method-i-test_attributes_nodoc_track) - -## test_attributes_visibility() [](#method-i-test_attributes_visibility) - -## test_block_comment() [](#method-i-test_block_comment) - -## test_calls_super() [](#method-i-test_calls_super) - -## test_category() [](#method-i-test_category) - -## test_class() [](#method-i-test_class) - -## test_class_definition_encountered_after_class_reference() [](#method-i-test_class_definition_encountered_after_class_reference) - -## test_class_method_visibility() [](#method-i-test_class_method_visibility) - -## test_class_mistaken_for_module() [](#method-i-test_class_mistaken_for_module) - -## test_class_module_nodoc() [](#method-i-test_class_module_nodoc) - -## test_class_module_stopdoc() [](#method-i-test_class_module_stopdoc) - -## test_class_new_notnew() [](#method-i-test_class_new_notnew) - -## test_class_repeatedly() [](#method-i-test_class_repeatedly) - -## test_class_superclass() [](#method-i-test_class_superclass) - -## test_confusing_superclass() [](#method-i-test_confusing_superclass) - -## test_constant() [](#method-i-test_constant) - -## test_constant_alias() [](#method-i-test_constant_alias) - -## test_constant_assignment_to_undefined_module_path() [](#method-i-test_constant_assignment_to_undefined_module_path) - -## test_constant_method() [](#method-i-test_constant_method) - -## test_constant_visibility() [](#method-i-test_constant_visibility) - -## test_define_method_visibility() [](#method-i-test_define_method_visibility) - -## test_enddoc() [](#method-i-test_enddoc) - -## test_first_comment_is_not_a_meta_method() [](#method-i-test_first_comment_is_not_a_meta_method) - -## test_ghost_method() [](#method-i-test_ghost_method) - -## test_ignore_constant_assign_rhs() [](#method-i-test_ignore_constant_assign_rhs) - -## test_include_extend() [](#method-i-test_include_extend) - -## test_include_extend_to_singleton_class() [](#method-i-test_include_extend_to_singleton_class) - -## test_include_with_module_nesting() [](#method-i-test_include_with_module_nesting) - -## test_invalid_alias_method() [](#method-i-test_invalid_alias_method) - -## test_invalid_meta_method() [](#method-i-test_invalid_meta_method) - -## test_look_for_directives_in_commented() [](#method-i-test_look_for_directives_in_commented) - -## test_look_for_directives_in_section() [](#method-i-test_look_for_directives_in_section) - -## test_look_for_directives_in_unhandled() [](#method-i-test_look_for_directives_in_unhandled) - -## test_markup_first_comment() [](#method-i-test_markup_first_comment) - -## test_markup_override() [](#method-i-test_markup_override) - -## test_meta_attributes() [](#method-i-test_meta_attributes) - -## test_meta_attributes_named() [](#method-i-test_meta_attributes_named) - -## test_meta_define_method() [](#method-i-test_meta_define_method) - -## test_meta_method() [](#method-i-test_meta_method) - -## test_meta_method_unknown() [](#method-i-test_meta_method_unknown) - -## test_method() [](#method-i-test_method) - -## test_method_args_directive() [](#method-i-test_method_args_directive) - -## test_method_change_visibility() [](#method-i-test_method_change_visibility) - -## test_method_definition_nested_inside_block() [](#method-i-test_method_definition_nested_inside_block) - -## test_method_nested_visibility() [](#method-i-test_method_nested_visibility) - -## test_method_nodoc_stopdoc() [](#method-i-test_method_nodoc_stopdoc) - -## test_method_nodoc_track() [](#method-i-test_method_nodoc_track) - -## test_method_singleton_class_visibility() [](#method-i-test_method_singleton_class_visibility) - -## test_method_toplevel() [](#method-i-test_method_toplevel) - -## test_method_visibility_change_in_subclass() [](#method-i-test_method_visibility_change_in_subclass) - -## test_method_yields_directive() [](#method-i-test_method_yields_directive) - -## test_module() [](#method-i-test_module) - -## test_module_function() [](#method-i-test_module_function) - -## test_multibyte_method_name() [](#method-i-test_multibyte_method_name) - -## test_nested_class_with_colon() [](#method-i-test_nested_class_with_colon) - -## test_nested_module_with_colon() [](#method-i-test_nested_module_with_colon) - -## test_nodoc_constant_assigned_without_nodoc_comment() [](#method-i-test_nodoc_constant_assigned_without_nodoc_comment) - -## test_open_class_with_superclass() [](#method-i-test_open_class_with_superclass) - -## test_options_encoding() [](#method-i-test_options_encoding) - -## test_parenthesized_cdecl() [](#method-i-test_parenthesized_cdecl) - -## test_private_def_public_def() [](#method-i-test_private_def_public_def) - -## test_read_directive_linear_performance() [](#method-i-test_read_directive_linear_performance) - -## test_require() [](#method-i-test_require) - -## test_scan_duplicate_module() [](#method-i-test_scan_duplicate_module) - -## test_section() [](#method-i-test_section) - -## test_singleton_class() [](#method-i-test_singleton_class) - -## test_singleton_class_attributes() [](#method-i-test_singleton_class_attributes) - -## test_singleton_class_meta_method() [](#method-i-test_singleton_class_meta_method) - -## test_singleton_method_visibility_change_in_subclass() [](#method-i-test_singleton_method_visibility_change_in_subclass) - -## test_statements_identifier_alias_method_before_original_method() [](#method-i-test_statements_identifier_alias_method_before_original_method) - -## test_tomdoc_meta() [](#method-i-test_tomdoc_meta) - -## test_top_level_enddoc() [](#method-i-test_top_level_enddoc) - -## test_true_false_nil_method() [](#method-i-test_true_false_nil_method) - -## test_undefined_singleton_class_defines_module() [](#method-i-test_undefined_singleton_class_defines_module) - -## test_undocumentable_attributes() [](#method-i-test_undocumentable_attributes) - -## test_undocumentable_change_visibility() [](#method-i-test_undocumentable_change_visibility) - -## test_unknown_meta_method() [](#method-i-test_unknown_meta_method) - -## test_various_argument_include() [](#method-i-test_various_argument_include) - -## util_parser(content) [](#method-i-util_parser) - diff --git a/example/ruby/TestRDocParserRd.md b/example/ruby/TestRDocParserRd.md deleted file mode 100644 index 385bdea..0000000 --- a/example/ruby/TestRDocParserRd.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestRDocParserRd -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_class_can_parse() [](#method-i-test_class_can_parse) - -## test_file() [](#method-i-test_file) - -## test_scan() [](#method-i-test_scan) - -## util_parser(content) [](#method-i-util_parser) - diff --git a/example/ruby/TestRDocParserRuby.md b/example/ruby/TestRDocParserRuby.md deleted file mode 100644 index 65edb3d..0000000 --- a/example/ruby/TestRDocParserRuby.md +++ /dev/null @@ -1,466 +0,0 @@ -# Class: TestRDocParserRuby -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_collect_first_comment() [](#method-i-test_collect_first_comment) - -## test_collect_first_comment_encoding() [](#method-i-test_collect_first_comment_encoding) - -## test_collect_first_comment_rd_hash() [](#method-i-test_collect_first_comment_rd_hash) - -## test_document_after_rescue_inside_paren() [](#method-i-test_document_after_rescue_inside_paren) - -## test_end_that_doesnt_belong_to_class_doesnt_change_visibility() [](#method-i-test_end_that_doesnt_belong_to_class_doesnt_change_visibility) - -## test_get_class_or_module() [](#method-i-test_get_class_or_module) - -## test_get_class_or_module_document_children() [](#method-i-test_get_class_or_module_document_children) - -## test_get_class_or_module_ignore_constants() [](#method-i-test_get_class_or_module_ignore_constants) - -## test_get_class_specification() [](#method-i-test_get_class_specification) - -## test_get_symbol_or_name() [](#method-i-test_get_symbol_or_name) - -## test_look_for_directives_in_attr() [](#method-i-test_look_for_directives_in_attr) - -## test_look_for_directives_in_commented() [](#method-i-test_look_for_directives_in_commented) - -## test_look_for_directives_in_method() [](#method-i-test_look_for_directives_in_method) - -## test_look_for_directives_in_section() [](#method-i-test_look_for_directives_in_section) - -## test_look_for_directives_in_unhandled() [](#method-i-test_look_for_directives_in_unhandled) - -## test_parenthesized_cdecl() [](#method-i-test_parenthesized_cdecl) - -## test_parse_alias() [](#method-i-test_parse_alias) - -## test_parse_alias_meta() [](#method-i-test_parse_alias_meta) - -## test_parse_alias_singleton() [](#method-i-test_parse_alias_singleton) - -## test_parse_alias_stopdoc() [](#method-i-test_parse_alias_stopdoc) - -## test_parse_attr() [](#method-i-test_parse_attr) - -## test_parse_attr_accessor() [](#method-i-test_parse_attr_accessor) - -## test_parse_attr_accessor_nodoc() [](#method-i-test_parse_attr_accessor_nodoc) - -## test_parse_attr_accessor_nodoc_track() [](#method-i-test_parse_attr_accessor_nodoc_track) - -## test_parse_attr_accessor_stopdoc() [](#method-i-test_parse_attr_accessor_stopdoc) - -## test_parse_attr_accessor_with_newline() [](#method-i-test_parse_attr_accessor_with_newline) - -## test_parse_attr_accessor_writer() [](#method-i-test_parse_attr_accessor_writer) - -## test_parse_attr_stopdoc() [](#method-i-test_parse_attr_stopdoc) - -## test_parse_call_syntax_sugar_for_constant() [](#method-i-test_parse_call_syntax_sugar_for_constant) - -## test_parse_class() [](#method-i-test_parse_class) - -## test_parse_class_colon3() [](#method-i-test_parse_class_colon3) - -## test_parse_class_colon3_self_reference() [](#method-i-test_parse_class_colon3_self_reference) - -## test_parse_class_definition_encountered_after_class_reference() [](#method-i-test_parse_class_definition_encountered_after_class_reference) - -## test_parse_class_ghost_method() [](#method-i-test_parse_class_ghost_method) - -## test_parse_class_ghost_method_yields() [](#method-i-test_parse_class_ghost_method_yields) - -## test_parse_class_in_a_file_repeatedly() [](#method-i-test_parse_class_in_a_file_repeatedly) - -## test_parse_class_lower_name_warning() [](#method-i-test_parse_class_lower_name_warning) - -## test_parse_class_mistaken_for_module() [](#method-i-test_parse_class_mistaken_for_module) - -## test_parse_class_multi_ghost_methods() [](#method-i-test_parse_class_multi_ghost_methods) - -## test_parse_class_nested_superclass() [](#method-i-test_parse_class_nested_superclass) - -## test_parse_class_nodoc() [](#method-i-test_parse_class_nodoc) - -## test_parse_class_object() [](#method-i-test_parse_class_object) -TODO this is really a Context#add_class test - -## test_parse_class_single() [](#method-i-test_parse_class_single) - -## test_parse_class_single_gvar() [](#method-i-test_parse_class_single_gvar) - -## test_parse_class_single_root() [](#method-i-test_parse_class_single_root) - -## test_parse_class_singleton() [](#method-i-test_parse_class_singleton) - -## test_parse_class_stopdoc() [](#method-i-test_parse_class_stopdoc) - -## test_parse_class_the_same_of_outside() [](#method-i-test_parse_class_the_same_of_outside) - -## test_parse_comment_attr() [](#method-i-test_parse_comment_attr) - -## test_parse_comment_attr_attr_reader() [](#method-i-test_parse_comment_attr_attr_reader) - -## test_parse_comment_attr_stopdoc() [](#method-i-test_parse_comment_attr_stopdoc) - -## test_parse_comment_method() [](#method-i-test_parse_comment_method) - -## test_parse_comment_method_args() [](#method-i-test_parse_comment_method_args) - -## test_parse_comment_method_stopdoc() [](#method-i-test_parse_comment_method_stopdoc) - -## test_parse_comment_nested() [](#method-i-test_parse_comment_nested) - -## test_parse_const_alias_defined_elsewhere() [](#method-i-test_parse_const_alias_defined_elsewhere) - -## test_parse_const_alias_defined_far_away() [](#method-i-test_parse_const_alias_defined_far_away) - -## test_parse_const_fail_w_meta() [](#method-i-test_parse_const_fail_w_meta) - -## test_parse_const_third_party() [](#method-i-test_parse_const_third_party) - -## test_parse_constant() [](#method-i-test_parse_constant) - -## test_parse_constant_alias() [](#method-i-test_parse_constant_alias) - -## test_parse_constant_alias_same_name() [](#method-i-test_parse_constant_alias_same_name) - -## test_parse_constant_attrasgn() [](#method-i-test_parse_constant_attrasgn) - -## test_parse_constant_in_method() [](#method-i-test_parse_constant_in_method) - -## test_parse_constant_rescue() [](#method-i-test_parse_constant_rescue) - -## test_parse_constant_stopdoc() [](#method-i-test_parse_constant_stopdoc) - -## test_parse_constant_the_same_of_outside() [](#method-i-test_parse_constant_the_same_of_outside) - -## test_parse_constant_with_bracket() [](#method-i-test_parse_constant_with_bracket) - -## test_parse_extend_or_include_extend() [](#method-i-test_parse_extend_or_include_extend) - -## test_parse_extend_or_include_include() [](#method-i-test_parse_extend_or_include_include) - -## test_parse_for_in() [](#method-i-test_parse_for_in) - -## test_parse_heredoc_end() [](#method-i-test_parse_heredoc_end) - -## test_parse_include_by_dynamic_definition() [](#method-i-test_parse_include_by_dynamic_definition) - -## test_parse_include_by_dynamic_definition_directly() [](#method-i-test_parse_include_by_dynamic_definition_directly) - -## test_parse_include_by_dynamic_definition_via_variable() [](#method-i-test_parse_include_by_dynamic_definition_via_variable) - -## test_parse_include_by_dynamic_definition_with_brace() [](#method-i-test_parse_include_by_dynamic_definition_with_brace) - -## test_parse_include_by_dynamic_definition_without_paren() [](#method-i-test_parse_include_by_dynamic_definition_without_paren) - -## test_parse_included() [](#method-i-test_parse_included) - -## test_parse_instance_operation_method() [](#method-i-test_parse_instance_operation_method) - -## test_parse_meta_attr() [](#method-i-test_parse_meta_attr) - -## test_parse_meta_attr_accessor() [](#method-i-test_parse_meta_attr_accessor) - -## test_parse_meta_attr_named() [](#method-i-test_parse_meta_attr_named) - -## test_parse_meta_attr_reader() [](#method-i-test_parse_meta_attr_reader) - -## test_parse_meta_attr_stopdoc() [](#method-i-test_parse_meta_attr_stopdoc) - -## test_parse_meta_attr_writer() [](#method-i-test_parse_meta_attr_writer) - -## test_parse_meta_method() [](#method-i-test_parse_meta_method) - -## test_parse_meta_method_block() [](#method-i-test_parse_meta_method_block) - -## test_parse_meta_method_define_method() [](#method-i-test_parse_meta_method_define_method) - -## test_parse_meta_method_name() [](#method-i-test_parse_meta_method_name) - -## test_parse_meta_method_singleton() [](#method-i-test_parse_meta_method_singleton) - -## test_parse_meta_method_singleton_name() [](#method-i-test_parse_meta_method_singleton_name) - -## test_parse_meta_method_stopdoc() [](#method-i-test_parse_meta_method_stopdoc) - -## test_parse_meta_method_string_name() [](#method-i-test_parse_meta_method_string_name) - -## test_parse_meta_method_unknown() [](#method-i-test_parse_meta_method_unknown) - -## test_parse_method() [](#method-i-test_parse_method) - -## test_parse_method_alias() [](#method-i-test_parse_method_alias) - -## test_parse_method_ampersand() [](#method-i-test_parse_method_ampersand) - -## test_parse_method_bracket() [](#method-i-test_parse_method_bracket) - -## test_parse_method_constant() [](#method-i-test_parse_method_constant) - -## test_parse_method_dummy() [](#method-i-test_parse_method_dummy) - -## test_parse_method_false() [](#method-i-test_parse_method_false) - -## test_parse_method_funky() [](#method-i-test_parse_method_funky) - -## test_parse_method_gvar() [](#method-i-test_parse_method_gvar) - -## test_parse_method_gvar_insane() [](#method-i-test_parse_method_gvar_insane) - -## test_parse_method_internal_gvar() [](#method-i-test_parse_method_internal_gvar) - -## test_parse_method_internal_ivar() [](#method-i-test_parse_method_internal_ivar) - -## test_parse_method_internal_lvar() [](#method-i-test_parse_method_internal_lvar) - -## test_parse_method_nil() [](#method-i-test_parse_method_nil) - -## test_parse_method_no_parens() [](#method-i-test_parse_method_no_parens) - -## test_parse_method_nodoc() [](#method-i-test_parse_method_nodoc) - -## test_parse_method_nodoc_track() [](#method-i-test_parse_method_nodoc_track) - -## test_parse_method_or_yield_parameters_hash() [](#method-i-test_parse_method_or_yield_parameters_hash) - -## test_parse_method_parameters_comment() [](#method-i-test_parse_method_parameters_comment) - -## test_parse_method_parameters_comment_continue() [](#method-i-test_parse_method_parameters_comment_continue) - -## test_parse_method_parameters_with_paren_comment_continue() [](#method-i-test_parse_method_parameters_with_paren_comment_continue) - -## test_parse_method_star() [](#method-i-test_parse_method_star) - -## test_parse_method_stopdoc() [](#method-i-test_parse_method_stopdoc) - -## test_parse_method_toplevel() [](#method-i-test_parse_method_toplevel) - -## test_parse_method_toplevel_class() [](#method-i-test_parse_method_toplevel_class) - -## test_parse_method_true() [](#method-i-test_parse_method_true) - -## test_parse_method_utf8() [](#method-i-test_parse_method_utf8) - -## test_parse_method_with_args_directive() [](#method-i-test_parse_method_with_args_directive) - -## test_parse_module() [](#method-i-test_parse_module) - -## test_parse_module_nodoc() [](#method-i-test_parse_module_nodoc) - -## test_parse_module_relative_to_top_level_namespace() [](#method-i-test_parse_module_relative_to_top_level_namespace) - -## test_parse_module_stopdoc() [](#method-i-test_parse_module_stopdoc) - -## test_parse_multi_ghost_methods() [](#method-i-test_parse_multi_ghost_methods) - -## test_parse_mutable_heredocbeg() [](#method-i-test_parse_mutable_heredocbeg) - -## test_parse_on_ignored_nl_with_nil_text() [](#method-i-test_parse_on_ignored_nl_with_nil_text) - -## test_parse_percent_symbol() [](#method-i-test_parse_percent_symbol) - -## test_parse_postfix_nodoc() [](#method-i-test_parse_postfix_nodoc) - -## test_parse_redefinable_methods() [](#method-i-test_parse_redefinable_methods) - -## test_parse_redefined_op_with_constant() [](#method-i-test_parse_redefined_op_with_constant) - -## test_parse_require_dynamic_string() [](#method-i-test_parse_require_dynamic_string) - -## test_parse_statements_alias_method() [](#method-i-test_parse_statements_alias_method) - -## test_parse_statements_class_if() [](#method-i-test_parse_statements_class_if) - -## test_parse_statements_class_nested() [](#method-i-test_parse_statements_class_nested) - -## test_parse_statements_complex_condition_in_for() [](#method-i-test_parse_statements_complex_condition_in_for) - -## test_parse_statements_def_percent_string_pound() [](#method-i-test_parse_statements_def_percent_string_pound) - -## test_parse_statements_embdoc_in_document() [](#method-i-test_parse_statements_embdoc_in_document) - -## test_parse_statements_encoding() [](#method-i-test_parse_statements_encoding) - -## test_parse_statements_enddoc() [](#method-i-test_parse_statements_enddoc) - -## test_parse_statements_enddoc_top_level() [](#method-i-test_parse_statements_enddoc_top_level) - -## test_parse_statements_identifier_alias_method() [](#method-i-test_parse_statements_identifier_alias_method) - -## test_parse_statements_identifier_alias_method_before_original_method() [](#method-i-test_parse_statements_identifier_alias_method_before_original_method) - -## test_parse_statements_identifier_args() [](#method-i-test_parse_statements_identifier_args) - -## test_parse_statements_identifier_attr() [](#method-i-test_parse_statements_identifier_attr) - -## test_parse_statements_identifier_attr_accessor() [](#method-i-test_parse_statements_identifier_attr_accessor) - -## test_parse_statements_identifier_constant() [](#method-i-test_parse_statements_identifier_constant) - -## test_parse_statements_identifier_define_method() [](#method-i-test_parse_statements_identifier_define_method) - -## test_parse_statements_identifier_include() [](#method-i-test_parse_statements_identifier_include) - -## test_parse_statements_identifier_meta_method() [](#method-i-test_parse_statements_identifier_meta_method) - -## test_parse_statements_identifier_module_function() [](#method-i-test_parse_statements_identifier_module_function) - -## test_parse_statements_identifier_private() [](#method-i-test_parse_statements_identifier_private) - -## test_parse_statements_identifier_private_class_method() [](#method-i-test_parse_statements_identifier_private_class_method) - -## test_parse_statements_identifier_public_class_method() [](#method-i-test_parse_statements_identifier_public_class_method) - -## test_parse_statements_identifier_require() [](#method-i-test_parse_statements_identifier_require) - -## test_parse_statements_identifier_yields() [](#method-i-test_parse_statements_identifier_yields) - -## test_parse_statements_method_oneliner_with_regexp() [](#method-i-test_parse_statements_method_oneliner_with_regexp) - -## test_parse_statements_nodoc_identifier_alias() [](#method-i-test_parse_statements_nodoc_identifier_alias) - -## test_parse_statements_nodoc_identifier_alias_method() [](#method-i-test_parse_statements_nodoc_identifier_alias_method) - -## test_parse_statements_postfix_if_after_heredocbeg() [](#method-i-test_parse_statements_postfix_if_after_heredocbeg) - -## test_parse_statements_postfix_if_unless() [](#method-i-test_parse_statements_postfix_if_unless) - -## test_parse_statements_postfix_if_unless_with_expr_mid() [](#method-i-test_parse_statements_postfix_if_unless_with_expr_mid) - -## test_parse_statements_stopdoc_alias() [](#method-i-test_parse_statements_stopdoc_alias) - -## test_parse_statements_stopdoc_constant() [](#method-i-test_parse_statements_stopdoc_constant) - -## test_parse_statements_stopdoc_def() [](#method-i-test_parse_statements_stopdoc_def) - -## test_parse_statements_stopdoc_identifier_alias_method() [](#method-i-test_parse_statements_stopdoc_identifier_alias_method) - -## test_parse_statements_stopdoc_identifier_metaprogrammed() [](#method-i-test_parse_statements_stopdoc_identifier_metaprogrammed) - -## test_parse_statements_super() [](#method-i-test_parse_statements_super) - -## test_parse_statements_super_no_method() [](#method-i-test_parse_statements_super_no_method) - -## test_parse_statements_while_begin() [](#method-i-test_parse_statements_while_begin) - -## test_parse_symbol_in_arg() [](#method-i-test_parse_symbol_in_arg) - -## test_parse_symbol_in_paren_arg() [](#method-i-test_parse_symbol_in_paren_arg) - -## test_parse_syntax_error_code() [](#method-i-test_parse_syntax_error_code) - -## test_parse_top_level_statements_constant_nodoc_integration() [](#method-i-test_parse_top_level_statements_constant_nodoc_integration) -This tests parse_comment - -## test_parse_top_level_statements_enddoc() [](#method-i-test_parse_top_level_statements_enddoc) - -## test_parse_top_level_statements_stopdoc() [](#method-i-test_parse_top_level_statements_stopdoc) - -## test_parse_top_level_statements_stopdoc_integration() [](#method-i-test_parse_top_level_statements_stopdoc_integration) - -## test_parse_yield_in_braces_with_parens() [](#method-i-test_parse_yield_in_braces_with_parens) - -## test_read_directive() [](#method-i-test_read_directive) - -## test_read_directive_allow() [](#method-i-test_read_directive_allow) - -## test_read_directive_empty() [](#method-i-test_read_directive_empty) - -## test_read_directive_linear_performance() [](#method-i-test_read_directive_linear_performance) - -## test_read_directive_no_comment() [](#method-i-test_read_directive_no_comment) - -## test_read_directive_one_liner() [](#method-i-test_read_directive_one_liner) - -## test_read_documentation_modifiers() [](#method-i-test_read_documentation_modifiers) - -## test_read_documentation_modifiers_not_dash_new() [](#method-i-test_read_documentation_modifiers_not_dash_new) - -## test_read_documentation_modifiers_not_new() [](#method-i-test_read_documentation_modifiers_not_new) - -## test_read_documentation_modifiers_notnew() [](#method-i-test_read_documentation_modifiers_notnew) - -## test_sanity_integer() [](#method-i-test_sanity_integer) - -## test_sanity_interpolation() [](#method-i-test_sanity_interpolation) - -## test_sanity_interpolation_crazy() [](#method-i-test_sanity_interpolation_crazy) -If you're writing code like this you're doing it wrong - -## test_sanity_interpolation_curly() [](#method-i-test_sanity_interpolation_curly) - -## test_sanity_interpolation_format() [](#method-i-test_sanity_interpolation_format) - -## test_sanity_symbol_interpolation() [](#method-i-test_sanity_symbol_interpolation) - -## test_scan_block_comment() [](#method-i-test_scan_block_comment) - -## test_scan_block_comment_nested() [](#method-i-test_scan_block_comment_nested) -Issue #41 - -## test_scan_block_comment_notflush() [](#method-i-test_scan_block_comment_notflush) - -## test_scan_class_nested_nodoc() [](#method-i-test_scan_class_nested_nodoc) - -## test_scan_constant_in_method() [](#method-i-test_scan_constant_in_method) - -## test_scan_constant_in_rescue() [](#method-i-test_scan_constant_in_rescue) - -## test_scan_constant_nodoc() [](#method-i-test_scan_constant_nodoc) - -## test_scan_constant_nodoc_block() [](#method-i-test_scan_constant_nodoc_block) - -## test_scan_constant_visibility() [](#method-i-test_scan_constant_visibility) - -## test_scan_cr() [](#method-i-test_scan_cr) - -## test_scan_duplicate_module() [](#method-i-test_scan_duplicate_module) - -## test_scan_markup_first_comment() [](#method-i-test_scan_markup_first_comment) - -## test_scan_markup_override() [](#method-i-test_scan_markup_override) - -## test_scan_meta_method_block() [](#method-i-test_scan_meta_method_block) - -## test_scan_method_semi_method() [](#method-i-test_scan_method_semi_method) - -## test_scan_rails_routes() [](#method-i-test_scan_rails_routes) - -## test_scan_stopdoc() [](#method-i-test_scan_stopdoc) - -## test_scan_stopdoc_class_alias() [](#method-i-test_scan_stopdoc_class_alias) - -## test_scan_stopdoc_nested() [](#method-i-test_scan_stopdoc_nested) - -## test_scan_struct_self_brackets() [](#method-i-test_scan_struct_self_brackets) - -## test_scan_tomdoc_meta() [](#method-i-test_scan_tomdoc_meta) - -## test_scan_visibility() [](#method-i-test_scan_visibility) - -## test_scan_visibility_count() [](#method-i-test_scan_visibility_count) - -## test_singleton_method_via_eigenclass() [](#method-i-test_singleton_method_via_eigenclass) - -## test_stopdoc_after_comment() [](#method-i-test_stopdoc_after_comment) - -## test_suppress_parents() [](#method-i-test_suppress_parents) - -## test_suppress_parents_documented() [](#method-i-test_suppress_parents_documented) - -## util_parser(content) [](#method-i-util_parser) - -## util_two_parsers(first_file_content, second_file_content) [](#method-i-util_two_parsers) - diff --git a/example/ruby/TestRDocParserRubyWithPrismRubyTestCases.md b/example/ruby/TestRDocParserRubyWithPrismRubyTestCases.md deleted file mode 100644 index d303ed6..0000000 --- a/example/ruby/TestRDocParserRubyWithPrismRubyTestCases.md +++ /dev/null @@ -1,189 +0,0 @@ -# Class: TestRDocParserRubyWithPrismRubyTestCases -**Inherits:** RDoc::TestCase - -**Includes:** RDocParserPrismTestCases - - -Run the same test with the original RDoc::Parser::Ruby - - - -#Instance Methods -## accept_legacy_bug?() [](#method-i-accept_legacy_bug?) - -**@return** [Boolean] - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_alias() [](#method-i-test_alias) - -## test_alias_method() [](#method-i-test_alias_method) - -## test_alias_method_stopdoc_nodoc() [](#method-i-test_alias_method_stopdoc_nodoc) - -## test_alias_singleton() [](#method-i-test_alias_singleton) - -## test_attributes() [](#method-i-test_attributes) - -## test_attributes_nodoc() [](#method-i-test_attributes_nodoc) - -## test_attributes_nodoc_track() [](#method-i-test_attributes_nodoc_track) - -## test_attributes_visibility() [](#method-i-test_attributes_visibility) - -## test_block_comment() [](#method-i-test_block_comment) - -## test_calls_super() [](#method-i-test_calls_super) - -## test_category() [](#method-i-test_category) - -## test_class() [](#method-i-test_class) - -## test_class_definition_encountered_after_class_reference() [](#method-i-test_class_definition_encountered_after_class_reference) - -## test_class_method_visibility() [](#method-i-test_class_method_visibility) - -## test_class_mistaken_for_module() [](#method-i-test_class_mistaken_for_module) - -## test_class_module_nodoc() [](#method-i-test_class_module_nodoc) - -## test_class_module_stopdoc() [](#method-i-test_class_module_stopdoc) - -## test_class_new_notnew() [](#method-i-test_class_new_notnew) - -## test_class_repeatedly() [](#method-i-test_class_repeatedly) - -## test_class_superclass() [](#method-i-test_class_superclass) - -## test_confusing_superclass() [](#method-i-test_confusing_superclass) - -## test_constant() [](#method-i-test_constant) - -## test_constant_alias() [](#method-i-test_constant_alias) - -## test_constant_assignment_to_undefined_module_path() [](#method-i-test_constant_assignment_to_undefined_module_path) - -## test_constant_method() [](#method-i-test_constant_method) - -## test_constant_visibility() [](#method-i-test_constant_visibility) - -## test_define_method_visibility() [](#method-i-test_define_method_visibility) - -## test_enddoc() [](#method-i-test_enddoc) - -## test_first_comment_is_not_a_meta_method() [](#method-i-test_first_comment_is_not_a_meta_method) - -## test_ghost_method() [](#method-i-test_ghost_method) - -## test_ignore_constant_assign_rhs() [](#method-i-test_ignore_constant_assign_rhs) - -## test_include_extend() [](#method-i-test_include_extend) - -## test_include_extend_to_singleton_class() [](#method-i-test_include_extend_to_singleton_class) - -## test_include_with_module_nesting() [](#method-i-test_include_with_module_nesting) - -## test_invalid_alias_method() [](#method-i-test_invalid_alias_method) - -## test_invalid_meta_method() [](#method-i-test_invalid_meta_method) - -## test_look_for_directives_in_commented() [](#method-i-test_look_for_directives_in_commented) - -## test_look_for_directives_in_section() [](#method-i-test_look_for_directives_in_section) - -## test_look_for_directives_in_unhandled() [](#method-i-test_look_for_directives_in_unhandled) - -## test_markup_first_comment() [](#method-i-test_markup_first_comment) - -## test_markup_override() [](#method-i-test_markup_override) - -## test_meta_attributes() [](#method-i-test_meta_attributes) - -## test_meta_attributes_named() [](#method-i-test_meta_attributes_named) - -## test_meta_define_method() [](#method-i-test_meta_define_method) - -## test_meta_method() [](#method-i-test_meta_method) - -## test_meta_method_unknown() [](#method-i-test_meta_method_unknown) - -## test_method() [](#method-i-test_method) - -## test_method_args_directive() [](#method-i-test_method_args_directive) - -## test_method_change_visibility() [](#method-i-test_method_change_visibility) - -## test_method_definition_nested_inside_block() [](#method-i-test_method_definition_nested_inside_block) - -## test_method_nested_visibility() [](#method-i-test_method_nested_visibility) - -## test_method_nodoc_stopdoc() [](#method-i-test_method_nodoc_stopdoc) - -## test_method_nodoc_track() [](#method-i-test_method_nodoc_track) - -## test_method_singleton_class_visibility() [](#method-i-test_method_singleton_class_visibility) - -## test_method_toplevel() [](#method-i-test_method_toplevel) - -## test_method_visibility_change_in_subclass() [](#method-i-test_method_visibility_change_in_subclass) - -## test_method_yields_directive() [](#method-i-test_method_yields_directive) - -## test_module() [](#method-i-test_module) - -## test_module_function() [](#method-i-test_module_function) - -## test_multibyte_method_name() [](#method-i-test_multibyte_method_name) - -## test_nested_class_with_colon() [](#method-i-test_nested_class_with_colon) - -## test_nested_module_with_colon() [](#method-i-test_nested_module_with_colon) - -## test_nodoc_constant_assigned_without_nodoc_comment() [](#method-i-test_nodoc_constant_assigned_without_nodoc_comment) - -## test_open_class_with_superclass() [](#method-i-test_open_class_with_superclass) - -## test_options_encoding() [](#method-i-test_options_encoding) - -## test_parenthesized_cdecl() [](#method-i-test_parenthesized_cdecl) - -## test_private_def_public_def() [](#method-i-test_private_def_public_def) - -## test_read_directive_linear_performance() [](#method-i-test_read_directive_linear_performance) - -## test_require() [](#method-i-test_require) - -## test_scan_duplicate_module() [](#method-i-test_scan_duplicate_module) - -## test_section() [](#method-i-test_section) - -## test_singleton_class() [](#method-i-test_singleton_class) - -## test_singleton_class_attributes() [](#method-i-test_singleton_class_attributes) - -## test_singleton_class_meta_method() [](#method-i-test_singleton_class_meta_method) - -## test_singleton_method_visibility_change_in_subclass() [](#method-i-test_singleton_method_visibility_change_in_subclass) - -## test_statements_identifier_alias_method_before_original_method() [](#method-i-test_statements_identifier_alias_method_before_original_method) - -## test_tomdoc_meta() [](#method-i-test_tomdoc_meta) - -## test_top_level_enddoc() [](#method-i-test_top_level_enddoc) - -## test_true_false_nil_method() [](#method-i-test_true_false_nil_method) - -## test_undefined_singleton_class_defines_module() [](#method-i-test_undefined_singleton_class_defines_module) - -## test_undocumentable_attributes() [](#method-i-test_undocumentable_attributes) - -## test_undocumentable_change_visibility() [](#method-i-test_undocumentable_change_visibility) - -## test_unknown_meta_method() [](#method-i-test_unknown_meta_method) - -## test_various_argument_include() [](#method-i-test_various_argument_include) - -## util_parser(content) [](#method-i-util_parser) - diff --git a/example/ruby/TestRDocParserSimple.md b/example/ruby/TestRDocParserSimple.md deleted file mode 100644 index 80ab635..0000000 --- a/example/ruby/TestRDocParserSimple.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: TestRDocParserSimple -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_initialize_metadata() [](#method-i-test_initialize_metadata) - -## test_remove_coding_comment() [](#method-i-test_remove_coding_comment) - -## test_remove_private_comments() [](#method-i-test_remove_private_comments) -RDoc stops processing comments if it finds a comment line CONTAINING '`#--`'. -This can be used to separate external from internal comments, or to stop a -comment being associated with a method, class, or module. Commenting CAN be -turned back on with a line that STARTS '`#++`'. - -I've seen guys that comment their code like this: - # This method.... - #----------------- - def method - -# > either we do it only in ruby code, or we require the leading # - (to avoid conflict with rules). - - TODO: require the leading #, to provide the feature in simple text files. - Note: in ruby & C code, we require '#--' & '#++' or '*--' & '*++', - to allow rules: - - # this is a comment - #--- - # private text - #+++ - # this is a rule: - # --- - -## test_remove_private_comments_rule() [](#method-i-test_remove_private_comments_rule) - -## test_remove_private_comments_star() [](#method-i-test_remove_private_comments_star) - -## test_scan() [](#method-i-test_scan) - -## util_parser(content) [](#method-i-util_parser) - diff --git a/example/ruby/TestRDocRDoc.md b/example/ruby/TestRDocRDoc.md deleted file mode 100644 index 256ad7e..0000000 --- a/example/ruby/TestRDocRDoc.md +++ /dev/null @@ -1,80 +0,0 @@ -# Class: TestRDocRDoc -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_document() [](#method-i-test_document) -functional test - -## test_document_with_dry_run() [](#method-i-test_document_with_dry_run) -functional test - -## test_gather_files() [](#method-i-test_gather_files) - -## test_handle_pipe() [](#method-i-test_handle_pipe) - -## test_handle_pipe_rd() [](#method-i-test_handle_pipe_rd) - -## test_normalized_file_list() [](#method-i-test_normalized_file_list) - -## test_normalized_file_list_non_file_directory() [](#method-i-test_normalized_file_list_non_file_directory) - -## test_normalized_file_list_not_modified() [](#method-i-test_normalized_file_list_not_modified) - -## test_normalized_file_list_removes_created_rid_dir() [](#method-i-test_normalized_file_list_removes_created_rid_dir) - -## test_normalized_file_list_with_dot_doc() [](#method-i-test_normalized_file_list_with_dot_doc) - -## test_normalized_file_list_with_dot_doc_overridden_by_exclude_option() [](#method-i-test_normalized_file_list_with_dot_doc_overridden_by_exclude_option) - -## test_normalized_file_list_with_skipping_tests_disabled() [](#method-i-test_normalized_file_list_with_skipping_tests_disabled) - -## test_normalized_file_list_with_skipping_tests_enabled() [](#method-i-test_normalized_file_list_with_skipping_tests_enabled) - -## test_parse_file() [](#method-i-test_parse_file) - -## test_parse_file_binary() [](#method-i-test_parse_file_binary) - -## test_parse_file_encoding() [](#method-i-test_parse_file_encoding) - -## test_parse_file_forbidden() [](#method-i-test_parse_file_forbidden) - -## test_parse_file_include_root() [](#method-i-test_parse_file_include_root) - -## test_parse_file_page_dir() [](#method-i-test_parse_file_page_dir) - -## test_parse_file_relative() [](#method-i-test_parse_file_relative) - -## test_remove_unparseable() [](#method-i-test_remove_unparseable) - -## test_remove_unparseable_CVE_2021_31799() [](#method-i-test_remove_unparseable_CVE_2021_31799) - -## test_remove_unparseable_tags_emacs() [](#method-i-test_remove_unparseable_tags_emacs) - -## test_remove_unparseable_tags_vim() [](#method-i-test_remove_unparseable_tags_vim) - -## test_setup_output_dir() [](#method-i-test_setup_output_dir) - -## test_setup_output_dir_dry_run() [](#method-i-test_setup_output_dir_dry_run) - -## test_setup_output_dir_exists() [](#method-i-test_setup_output_dir_exists) - -## test_setup_output_dir_exists_empty_created_rid() [](#method-i-test_setup_output_dir_exists_empty_created_rid) - -## test_setup_output_dir_exists_file() [](#method-i-test_setup_output_dir_exists_file) - -## test_setup_output_dir_exists_not_rdoc() [](#method-i-test_setup_output_dir_exists_not_rdoc) - -## test_update_output_dir() [](#method-i-test_update_output_dir) - -## test_update_output_dir_dont() [](#method-i-test_update_output_dir_dont) - -## test_update_output_dir_dry_run() [](#method-i-test_update_output_dir_dry_run) - -## test_update_output_dir_with_reproducible_time() [](#method-i-test_update_output_dir_with_reproducible_time) - diff --git a/example/ruby/TestRDocRIPaths.md b/example/ruby/TestRDocRIPaths.md deleted file mode 100644 index 2d4e173..0000000 --- a/example/ruby/TestRDocRIPaths.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestRDocRIPaths -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_class_each() [](#method-i-test_class_each) - -## test_class_gem_dir() [](#method-i-test_class_gem_dir) - -## test_class_gemdirs_all() [](#method-i-test_class_gemdirs_all) - -## test_class_gemdirs_latest() [](#method-i-test_class_gemdirs_latest) - -## test_class_gemdirs_legacy() [](#method-i-test_class_gemdirs_legacy) - -## test_class_home_dir() [](#method-i-test_class_home_dir) - -## test_class_path_nonexistent() [](#method-i-test_class_path_nonexistent) - -## test_class_raw_path() [](#method-i-test_class_raw_path) - -## test_class_raw_path_extra_dirs() [](#method-i-test_class_raw_path_extra_dirs) - -## test_class_site_dir() [](#method-i-test_class_site_dir) - -## test_class_system_dir() [](#method-i-test_class_system_dir) - diff --git a/example/ruby/TestRDocRd.md b/example/ruby/TestRDocRd.md deleted file mode 100644 index 54db954..0000000 --- a/example/ruby/TestRDocRd.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocRd -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## test_class_parse() [](#method-i-test_class_parse) - -## test_class_parse_begin_end() [](#method-i-test_class_parse_begin_end) - -## test_class_parse_newline() [](#method-i-test_class_parse_newline) - diff --git a/example/ruby/TestRDocRdBlockParser.md b/example/ruby/TestRDocRdBlockParser.md deleted file mode 100644 index 8dcbf42..0000000 --- a/example/ruby/TestRDocRdBlockParser.md +++ /dev/null @@ -1,94 +0,0 @@ -# Class: TestRDocRdBlockParser -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## parse(text) [](#method-i-parse) - -## setup() [](#method-i-setup) - -## test_add_footnote() [](#method-i-test_add_footnote) - -## test_parse_desclist() [](#method-i-test_parse_desclist) - -## test_parse_enumlist() [](#method-i-test_parse_enumlist) - -## test_parse_enumlist_multiline() [](#method-i-test_parse_enumlist_multiline) - -## test_parse_enumlist_paragraphs() [](#method-i-test_parse_enumlist_paragraphs) - -## test_parse_enumlist_verbatim() [](#method-i-test_parse_enumlist_verbatim) - -## test_parse_enumlist_verbatim_continue() [](#method-i-test_parse_enumlist_verbatim_continue) - -## test_parse_footnote() [](#method-i-test_parse_footnote) - -## test_parse_heading() [](#method-i-test_parse_heading) -def test_parse_include_other_format - @block_parser.include_path = [Dir.tmpdir] - - expected = - doc( - blank_line, - para("include ((*worked*))"), - blank_line, - blank_line) - - str = <<~STR - =begin nonrd - <<< worked - =end - STR - - assert_equal(expected, @block_parser.parse str.lines.to_a) - end - -## test_parse_include() [](#method-i-test_parse_include) - -## test_parse_include_subtree() [](#method-i-test_parse_include_subtree) - -## test_parse_itemlist() [](#method-i-test_parse_itemlist) - -## test_parse_itemlist_multiline() [](#method-i-test_parse_itemlist_multiline) - -## test_parse_itemlist_nest() [](#method-i-test_parse_itemlist_nest) - -## test_parse_itemlist_paragraphs() [](#method-i-test_parse_itemlist_paragraphs) - -## test_parse_itemlist_verbatim() [](#method-i-test_parse_itemlist_verbatim) - -## test_parse_itemlist_verbatim_continue() [](#method-i-test_parse_itemlist_verbatim_continue) - -## test_parse_lists() [](#method-i-test_parse_lists) - -## test_parse_lists_nest() [](#method-i-test_parse_lists_nest) - -## test_parse_lists_nest_verbatim() [](#method-i-test_parse_lists_nest_verbatim) - -## test_parse_lists_nest_verbatim2() [](#method-i-test_parse_lists_nest_verbatim2) - -## test_parse_methodlist() [](#method-i-test_parse_methodlist) - -## test_parse_methodlist_empty() [](#method-i-test_parse_methodlist_empty) - -## test_parse_methodlist_paragraph() [](#method-i-test_parse_methodlist_paragraph) - -## test_parse_methodlist_paragraph2() [](#method-i-test_parse_methodlist_paragraph2) - -## test_parse_methodlist_paragraph_verbatim() [](#method-i-test_parse_methodlist_paragraph_verbatim) - -## test_parse_textblock() [](#method-i-test_parse_textblock) - -## test_parse_textblock_multi() [](#method-i-test_parse_textblock_multi) - -## test_parse_verbatim() [](#method-i-test_parse_verbatim) - -## test_parse_verbatim_blankline() [](#method-i-test_parse_verbatim_blankline) - -## test_parse_verbatim_indent() [](#method-i-test_parse_verbatim_indent) - -## test_parse_verbatim_multi() [](#method-i-test_parse_verbatim_multi) - diff --git a/example/ruby/TestRDocRdInline.md b/example/ruby/TestRDocRdInline.md deleted file mode 100644 index 7f6b1e9..0000000 --- a/example/ruby/TestRDocRdInline.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestRDocRdInline -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_append_inline() [](#method-i-test_append_inline) - -## test_append_string() [](#method-i-test_append_string) - -## test_class_new() [](#method-i-test_class_new) - -## test_equals2() [](#method-i-test_equals2) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_inline() [](#method-i-test_initialize_inline) - -## test_inspect() [](#method-i-test_inspect) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestRDocRdInlineParser.md b/example/ruby/TestRDocRdInlineParser.md deleted file mode 100644 index 99e68bd..0000000 --- a/example/ruby/TestRDocRdInlineParser.md +++ /dev/null @@ -1,82 +0,0 @@ -# Class: TestRDocRdInlineParser -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## parse(text) [](#method-i-parse) - -## setup() [](#method-i-setup) - -## test_parse() [](#method-i-test_parse) - -## test_parse_code() [](#method-i-test_parse_code) - -## test_parse_em() [](#method-i-test_parse_em) - -## test_parse_footnote() [](#method-i-test_parse_footnote) - -## test_parse_index() [](#method-i-test_parse_index) - -## test_parse_kbd() [](#method-i-test_parse_kbd) - -## test_parse_multiple() [](#method-i-test_parse_multiple) - -## test_parse_newline() [](#method-i-test_parse_newline) - -## test_parse_quote() [](#method-i-test_parse_quote) - -## test_parse_ref() [](#method-i-test_parse_ref) - -## test_parse_ref_em() [](#method-i-test_parse_ref_em) - -## test_parse_ref_filename() [](#method-i-test_parse_ref_filename) - -## test_parse_ref_filename_quote() [](#method-i-test_parse_ref_filename_quote) - -## test_parse_ref_quote() [](#method-i-test_parse_ref_quote) - -## test_parse_ref_quote_content() [](#method-i-test_parse_ref_quote_content) - -## test_parse_ref_quote_content_multi() [](#method-i-test_parse_ref_quote_content_multi) - -## test_parse_ref_substitute() [](#method-i-test_parse_ref_substitute) - -## test_parse_ref_substitute_element_quote() [](#method-i-test_parse_ref_substitute_element_quote) - -## test_parse_ref_substitute_filename() [](#method-i-test_parse_ref_substitute_filename) - -## test_parse_ref_substitute_filename_label() [](#method-i-test_parse_ref_substitute_filename_label) - -## test_parse_ref_substitute_filename_quote() [](#method-i-test_parse_ref_substitute_filename_quote) - -## test_parse_ref_substitute_multi_content() [](#method-i-test_parse_ref_substitute_multi_content) - -## test_parse_ref_substitute_multi_content2() [](#method-i-test_parse_ref_substitute_multi_content2) - -## test_parse_ref_substitute_multi_content3() [](#method-i-test_parse_ref_substitute_multi_content3) - -## test_parse_ref_substitute_quote() [](#method-i-test_parse_ref_substitute_quote) - -## test_parse_ref_substitute_quote_content() [](#method-i-test_parse_ref_substitute_quote_content) - -## test_parse_ref_substitute_url() [](#method-i-test_parse_ref_substitute_url) - -## test_parse_ref_url() [](#method-i-test_parse_ref_url) - -## test_parse_var() [](#method-i-test_parse_var) - -## test_parse_verb() [](#method-i-test_parse_verb) - -## test_parse_verb_backslash() [](#method-i-test_parse_verb_backslash) - -## test_parse_verb_backslash_backslash() [](#method-i-test_parse_verb_backslash_backslash) - -## test_parse_verb_backslash_quote() [](#method-i-test_parse_verb_backslash_quote) - -## test_parse_verb_emphasis() [](#method-i-test_parse_verb_emphasis) - -## test_parse_verb_multiple() [](#method-i-test_parse_verb_multiple) - diff --git a/example/ruby/TestRDocRequire.md b/example/ruby/TestRDocRequire.md deleted file mode 100644 index 71847ae..0000000 --- a/example/ruby/TestRDocRequire.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRDocRequire -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_initialize() [](#method-i-test_initialize) - diff --git a/example/ruby/TestRDocRubyGemsHook.md b/example/ruby/TestRDocRubyGemsHook.md deleted file mode 100644 index ac5a859..0000000 --- a/example/ruby/TestRDocRubyGemsHook.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: TestRDocRubyGemsHook -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_delete_legacy_args() [](#method-i-test_delete_legacy_args) - -## test_document() [](#method-i-test_document) - -## test_generate() [](#method-i-test_generate) - -## test_generate_all() [](#method-i-test_generate_all) - -## test_generate_configuration_rdoc_array() [](#method-i-test_generate_configuration_rdoc_array) - -## test_generate_configuration_rdoc_string() [](#method-i-test_generate_configuration_rdoc_string) - -## test_generate_default_gem() [](#method-i-test_generate_default_gem) - -## test_generate_disabled() [](#method-i-test_generate_disabled) - -## test_generate_force() [](#method-i-test_generate_force) - -## test_generate_no_overwrite() [](#method-i-test_generate_no_overwrite) - -## test_generate_rubygems_compatible() [](#method-i-test_generate_rubygems_compatible) - -## test_initialize() [](#method-i-test_initialize) - -## test_new_rdoc() [](#method-i-test_new_rdoc) - -## test_rdoc_installed?() [](#method-i-test_rdoc_installed?) - -**@return** [Boolean] - -## test_remove() [](#method-i-test_remove) - -## test_remove_unwritable() [](#method-i-test_remove_unwritable) - -## test_ri_installed?() [](#method-i-test_ri_installed?) - -**@return** [Boolean] - -## test_setup() [](#method-i-test_setup) - -## test_setup_unwritable() [](#method-i-test_setup_unwritable) - diff --git a/example/ruby/TestRDocServlet.md b/example/ruby/TestRDocServlet.md deleted file mode 100644 index 3436868..0000000 --- a/example/ruby/TestRDocServlet.md +++ /dev/null @@ -1,94 +0,0 @@ -# Class: TestRDocServlet -**Inherits:** RDoc::TestCase - - - - -# Class Methods -## mount() [](#method-c-mount) -## path() [](#method-c-path) -## path=(path ) [](#method-c-path=) - -#Instance Methods -## do_GET_not_found() [](#method-i-do_GET_not_found) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_asset() [](#method-i-test_asset) - -## test_do_GET() [](#method-i-test_do_GET) - -## test_do_GET_asset_darkfish() [](#method-i-test_do_GET_asset_darkfish) - -## test_do_GET_asset_json_index() [](#method-i-test_do_GET_asset_json_index) - -## test_do_GET_error() [](#method-i-test_do_GET_error) - -## test_do_GET_mount_path() [](#method-i-test_do_GET_mount_path) - -## test_do_GET_not_modified() [](#method-i-test_do_GET_not_modified) - -## test_do_GET_root() [](#method-i-test_do_GET_root) - -## test_do_GET_root_search() [](#method-i-test_do_GET_root_search) - -## test_documentation_page_class() [](#method-i-test_documentation_page_class) - -## test_documentation_page_not_found() [](#method-i-test_documentation_page_not_found) - -## test_documentation_page_page() [](#method-i-test_documentation_page_page) - -## test_documentation_page_page_with_nesting() [](#method-i-test_documentation_page_page_with_nesting) - -## test_documentation_source() [](#method-i-test_documentation_source) - -## test_documentation_source_cached() [](#method-i-test_documentation_source_cached) - -## test_error() [](#method-i-test_error) - -## test_generator_for() [](#method-i-test_generator_for) - -## test_if_modified_since() [](#method-i-test_if_modified_since) - -## test_if_modified_since_not_modified() [](#method-i-test_if_modified_since_not_modified) - -## test_installed_docs() [](#method-i-test_installed_docs) - -## test_not_found() [](#method-i-test_not_found) - -## test_not_found_message() [](#method-i-test_not_found_message) - -## test_ri_paths() [](#method-i-test_ri_paths) - -## test_root() [](#method-i-test_root) - -## test_root_search() [](#method-i-test_root_search) - -## test_show_documentation_index() [](#method-i-test_show_documentation_index) - -## test_show_documentation_page() [](#method-i-test_show_documentation_page) - -## test_show_documentation_search_index() [](#method-i-test_show_documentation_search_index) - -## test_show_documentation_table_of_contents() [](#method-i-test_show_documentation_table_of_contents) - -## test_store_for_extra() [](#method-i-test_store_for_extra) - -## test_store_for_gem() [](#method-i-test_store_for_gem) - -## test_store_for_home() [](#method-i-test_store_for_home) - -## test_store_for_missing_documentation() [](#method-i-test_store_for_missing_documentation) - -## test_store_for_missing_gem() [](#method-i-test_store_for_missing_gem) - -## test_store_for_ruby() [](#method-i-test_store_for_ruby) - -## test_store_for_site() [](#method-i-test_store_for_site) - -## touch_extra_cache_path() [](#method-i-touch_extra_cache_path) - -## touch_system_cache_path() [](#method-i-touch_system_cache_path) - diff --git a/example/ruby/TestRDocSingleClass.md b/example/ruby/TestRDocSingleClass.md deleted file mode 100644 index 5effbda..0000000 --- a/example/ruby/TestRDocSingleClass.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRDocSingleClass -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_aref_prefix() [](#method-i-test_aref_prefix) - -## test_definition() [](#method-i-test_definition) - diff --git a/example/ruby/TestRDocStats.md b/example/ruby/TestRDocStats.md deleted file mode 100644 index 91fb6c2..0000000 --- a/example/ruby/TestRDocStats.md +++ /dev/null @@ -1,80 +0,0 @@ -# Class: TestRDocStats -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_doc_stats() [](#method-i-test_doc_stats) - -## test_doc_stats_display_eh() [](#method-i-test_doc_stats_display_eh) - -## test_doc_stats_documented() [](#method-i-test_doc_stats_documented) - -## test_report_attr() [](#method-i-test_report_attr) - -## test_report_attr_documented() [](#method-i-test_report_attr_documented) - -## test_report_attr_line() [](#method-i-test_report_attr_line) - -## test_report_class() [](#method-i-test_report_class) - -## test_report_class_documented() [](#method-i-test_report_class_documented) - -## test_report_class_documented_level_1() [](#method-i-test_report_class_documented_level_1) - -## test_report_class_empty() [](#method-i-test_report_class_empty) - -## test_report_class_empty_2() [](#method-i-test_report_class_empty_2) - -## test_report_class_method_documented() [](#method-i-test_report_class_method_documented) - -## test_report_class_module_ignore() [](#method-i-test_report_class_module_ignore) - -## test_report_constant() [](#method-i-test_report_constant) - -## test_report_constant_alias() [](#method-i-test_report_constant_alias) - -## test_report_constant_documented() [](#method-i-test_report_constant_documented) - -## test_report_constant_line() [](#method-i-test_report_constant_line) - -## test_report_empty() [](#method-i-test_report_empty) - -## test_report_method() [](#method-i-test_report_method) - -## test_report_method_class() [](#method-i-test_report_method_class) - -## test_report_method_documented() [](#method-i-test_report_method_documented) - -## test_report_method_line() [](#method-i-test_report_method_line) - -## test_report_method_parameters() [](#method-i-test_report_method_parameters) - -## test_report_method_parameters_documented() [](#method-i-test_report_method_parameters_documented) - -## test_report_method_parameters_yield() [](#method-i-test_report_method_parameters_yield) - -## test_report_skip_object() [](#method-i-test_report_skip_object) - -## test_summary() [](#method-i-test_summary) - -## test_summary_level_1() [](#method-i-test_summary_level_1) - -## test_summary_level_false() [](#method-i-test_summary_level_false) - -## test_undoc_params() [](#method-i-test_undoc_params) - -## test_undoc_params_block() [](#method-i-test_undoc_params_block) - -## test_undoc_params_documented() [](#method-i-test_undoc_params_documented) - -## test_undoc_params_keywords() [](#method-i-test_undoc_params_keywords) - -## test_undoc_params_splat() [](#method-i-test_undoc_params_splat) - -## to_rdoc() [](#method-i-to_rdoc) - diff --git a/example/ruby/TestRDocStore.md b/example/ruby/TestRDocStore.md deleted file mode 100644 index 6692c99..0000000 --- a/example/ruby/TestRDocStore.md +++ /dev/null @@ -1,141 +0,0 @@ -# Class: TestRDocStore -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## assert_cache(imethods, cmethods, attrs, modules, ancestors{}, pages[], mainnil, titlenil) [](#method-i-assert_cache) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_add_c_enclosure() [](#method-i-test_add_c_enclosure) - -## test_add_c_variables() [](#method-i-test_add_c_variables) - -## test_add_file() [](#method-i-test_add_file) - -## test_add_file_relative() [](#method-i-test_add_file_relative) - -## test_all_classes_and_modules() [](#method-i-test_all_classes_and_modules) - -## test_all_files() [](#method-i-test_all_files) - -## test_all_modules() [](#method-i-test_all_modules) - -## test_attributes() [](#method-i-test_attributes) - -## test_class_file() [](#method-i-test_class_file) - -## test_class_methods() [](#method-i-test_class_methods) - -## test_class_path() [](#method-i-test_class_path) - -## test_classes() [](#method-i-test_classes) - -## test_complete() [](#method-i-test_complete) - -## test_complete_nodoc() [](#method-i-test_complete_nodoc) - -## test_dry_run() [](#method-i-test_dry_run) - -## test_find_c_enclosure() [](#method-i-test_find_c_enclosure) - -## test_find_c_enclosure_from_cache() [](#method-i-test_find_c_enclosure_from_cache) - -## test_find_c_enclosure_from_cache_legacy() [](#method-i-test_find_c_enclosure_from_cache_legacy) - -## test_find_class_named() [](#method-i-test_find_class_named) - -## test_find_class_named_from() [](#method-i-test_find_class_named_from) - -## test_find_class_or_module() [](#method-i-test_find_class_or_module) - -## test_find_file_named() [](#method-i-test_find_file_named) - -## test_find_module_named() [](#method-i-test_find_module_named) - -## test_find_text_page() [](#method-i-test_find_text_page) - -## test_friendly_path() [](#method-i-test_friendly_path) - -## test_instance_methods() [](#method-i-test_instance_methods) - -## test_load_all() [](#method-i-test_load_all) - -## test_load_cache() [](#method-i-test_load_cache) - -## test_load_cache_encoding_differs() [](#method-i-test_load_cache_encoding_differs) - -## test_load_cache_legacy() [](#method-i-test_load_cache_legacy) - -## test_load_cache_no_cache() [](#method-i-test_load_cache_no_cache) - -## test_load_class() [](#method-i-test_load_class) - -## test_load_method() [](#method-i-test_load_method) - -## test_load_method_legacy() [](#method-i-test_load_method_legacy) - -## test_load_page() [](#method-i-test_load_page) - -## test_load_single_class() [](#method-i-test_load_single_class) - -## test_main() [](#method-i-test_main) - -## test_method_file() [](#method-i-test_method_file) - -## test_module_names() [](#method-i-test_module_names) - -## test_page() [](#method-i-test_page) - -## test_page_with_extension() [](#method-i-test_page_with_extension) - -## test_resolve_c_superclasses() [](#method-i-test_resolve_c_superclasses) - -## test_save() [](#method-i-test_save) - -## test_save_cache() [](#method-i-test_save_cache) - -## test_save_cache_dry_run() [](#method-i-test_save_cache_dry_run) - -## test_save_cache_duplicate_methods() [](#method-i-test_save_cache_duplicate_methods) - -## test_save_cache_duplicate_pages() [](#method-i-test_save_cache_duplicate_pages) - -## test_save_class() [](#method-i-test_save_class) - -## test_save_class_basic_object() [](#method-i-test_save_class_basic_object) - -## test_save_class_delete() [](#method-i-test_save_class_delete) - -## test_save_class_dry_run() [](#method-i-test_save_class_dry_run) - -## test_save_class_loaded() [](#method-i-test_save_class_loaded) - -## test_save_class_merge() [](#method-i-test_save_class_merge) - -## test_save_class_merge_constant() [](#method-i-test_save_class_merge_constant) -This is a functional test - -## test_save_class_methods() [](#method-i-test_save_class_methods) - -## test_save_class_nested() [](#method-i-test_save_class_nested) - -## test_save_method() [](#method-i-test_save_method) - -## test_save_method_dry_run() [](#method-i-test_save_method_dry_run) - -## test_save_method_nested() [](#method-i-test_save_method_nested) - -## test_save_page() [](#method-i-test_save_page) - -## test_save_page_file() [](#method-i-test_save_page_file) - -## test_source() [](#method-i-test_source) - -## test_title() [](#method-i-test_title) - diff --git a/example/ruby/TestRDocTask.md b/example/ruby/TestRDocTask.md deleted file mode 100644 index 00ea0d6..0000000 --- a/example/ruby/TestRDocTask.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestRDocTask -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_clobber_task_description() [](#method-i-test_clobber_task_description) - -## test_coverage_task_description() [](#method-i-test_coverage_task_description) - -## test_generator_option() [](#method-i-test_generator_option) - -## test_inline_source() [](#method-i-test_inline_source) - -## test_main_option() [](#method-i-test_main_option) - -## test_markup_option() [](#method-i-test_markup_option) - -## test_output_dir_option() [](#method-i-test_output_dir_option) - -## test_rdoc_task_description() [](#method-i-test_rdoc_task_description) - -## test_rerdoc_task_description() [](#method-i-test_rerdoc_task_description) - -## test_tasks_creation() [](#method-i-test_tasks_creation) - -## test_tasks_creation_with_custom_name_hash() [](#method-i-test_tasks_creation_with_custom_name_hash) - -## test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given() [](#method-i-test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given) - -## test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given() [](#method-i-test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given) - -## test_tasks_creation_with_custom_name_string() [](#method-i-test_tasks_creation_with_custom_name_string) - -## test_tasks_creation_with_custom_name_symbol() [](#method-i-test_tasks_creation_with_custom_name_symbol) - -## test_tasks_option_parser() [](#method-i-test_tasks_option_parser) - -## test_template_option() [](#method-i-test_template_option) - -## test_title_option() [](#method-i-test_title_option) - diff --git a/example/ruby/TestRDocText.md b/example/ruby/TestRDocText.md deleted file mode 100644 index 6ec986a..0000000 --- a/example/ruby/TestRDocText.md +++ /dev/null @@ -1,148 +0,0 @@ -# Class: TestRDocText -**Inherits:** RDoc::TestCase - -**Includes:** RDoc::Text - - - - - -#Instance Methods -## expand_tabs(text) [](#method-i-expand_tabs) -Expands tab characters in `text` to eight spaces - -## flush_left(text) [](#method-i-flush_left) -Flush `text` left based on the shortest line - -## formatter() [](#method-i-formatter) - -## markup(text) [](#method-i-markup) -Convert a string in markup format into HTML. - -Requires the including class to implement #formatter - -## normalize_comment(text) [](#method-i-normalize_comment) -Strips hashes, expands tabs then flushes `text` to the left - -## options() [](#method-i-options) - -## parse(text, format'rdoc') [](#method-i-parse) -Normalizes `text` then builds a RDoc::Markup::Document from it - -## setup() [](#method-i-setup) - -## snippet(text, limit100) [](#method-i-snippet) -The first `limit` characters of `text` as HTML - -## strip_hashes(text) [](#method-i-strip_hashes) -Strips leading # characters from `text` - -## strip_newlines(text) [](#method-i-strip_newlines) -Strips leading and trailing n characters from `text` - -## strip_stars(text) [](#method-i-strip_stars) -Strips /* */ style comments - -## test_expand_tabs() [](#method-i-test_expand_tabs) - -## test_expand_tabs_encoding() [](#method-i-test_expand_tabs_encoding) - -## test_flush_left() [](#method-i-test_flush_left) - -## test_flush_left_encoding() [](#method-i-test_flush_left_encoding) - -## test_markup_comment() [](#method-i-test_markup_comment) - -## test_markup_string() [](#method-i-test_markup_string) - -## test_normalize_comment_hash() [](#method-i-test_normalize_comment_hash) - -## test_normalize_comment_stars_single_double_space() [](#method-i-test_normalize_comment_stars_single_double_space) - -## test_normalize_comment_stars_single_space() [](#method-i-test_normalize_comment_stars_single_space) - -## test_parse() [](#method-i-test_parse) - -## test_parse_comment() [](#method-i-test_parse_comment) - -## test_parse_document() [](#method-i-test_parse_document) - -## test_parse_empty() [](#method-i-test_parse_empty) - -## test_parse_empty_newline() [](#method-i-test_parse_empty_newline) - -## test_parse_format_markdown() [](#method-i-test_parse_format_markdown) - -## test_parse_format_rd() [](#method-i-test_parse_format_rd) - -## test_parse_format_tomdoc() [](#method-i-test_parse_format_tomdoc) - -## test_parse_newline() [](#method-i-test_parse_newline) - -## test_self_encode_fallback() [](#method-i-test_self_encode_fallback) - -## test_snippet() [](#method-i-test_snippet) - -## test_snippet_comment() [](#method-i-test_snippet_comment) - -## test_snippet_short() [](#method-i-test_snippet_short) - -## test_strip_hashes() [](#method-i-test_strip_hashes) - -## test_strip_hashes_encoding() [](#method-i-test_strip_hashes_encoding) - -## test_strip_newlines() [](#method-i-test_strip_newlines) - -## test_strip_newlines_encoding() [](#method-i-test_strip_newlines_encoding) - -## test_strip_stars() [](#method-i-test_strip_stars) - -## test_strip_stars_document_method() [](#method-i-test_strip_stars_document_method) - -## test_strip_stars_document_method_special() [](#method-i-test_strip_stars_document_method_special) - -## test_strip_stars_encoding() [](#method-i-test_strip_stars_encoding) - -## test_strip_stars_encoding2() [](#method-i-test_strip_stars_encoding2) - -## test_strip_stars_no_stars() [](#method-i-test_strip_stars_no_stars) - -## test_to_html_apostrophe() [](#method-i-test_to_html_apostrophe) - -## test_to_html_apostrophe_entity() [](#method-i-test_to_html_apostrophe_entity) - -## test_to_html_backslash() [](#method-i-test_to_html_backslash) - -## test_to_html_br() [](#method-i-test_to_html_br) - -## test_to_html_copyright() [](#method-i-test_to_html_copyright) - -## test_to_html_dash() [](#method-i-test_to_html_dash) - -## test_to_html_double_backtick() [](#method-i-test_to_html_double_backtick) - -## test_to_html_double_quote() [](#method-i-test_to_html_double_quote) - -## test_to_html_double_quote_quot() [](#method-i-test_to_html_double_quote_quot) - -## test_to_html_double_tick() [](#method-i-test_to_html_double_tick) - -## test_to_html_ellipsis() [](#method-i-test_to_html_ellipsis) - -## test_to_html_encoding() [](#method-i-test_to_html_encoding) - -## test_to_html_html_tag() [](#method-i-test_to_html_html_tag) - -## test_to_html_registered_trademark() [](#method-i-test_to_html_registered_trademark) - -## test_to_html_tt_tag() [](#method-i-test_to_html_tt_tag) - -## test_to_html_tt_tag_mismatch() [](#method-i-test_to_html_tt_tag_mismatch) - -## to_html(text) [](#method-i-to_html) -Converts ampersand, dashes, ellipsis, quotes, copyright and registered -trademark symbols in `text` to properly encoded characters. - -## wrap(txt, line_len76) [](#method-i-wrap) -Wraps `txt` to `line_len` - diff --git a/example/ruby/TestRDocTokenStream.md b/example/ruby/TestRDocTokenStream.md deleted file mode 100644 index ce4e1ff..0000000 --- a/example/ruby/TestRDocTokenStream.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestRDocTokenStream -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## test_add_token() [](#method-i-test_add_token) - -## test_add_tokens() [](#method-i-test_add_tokens) - -## test_class_to_html() [](#method-i-test_class_to_html) - -## test_class_to_html_empty() [](#method-i-test_class_to_html_empty) - -## test_collect_tokens() [](#method-i-test_collect_tokens) - -## test_pop_token() [](#method-i-test_pop_token) - -## test_token_stream() [](#method-i-test_token_stream) - -## test_tokens_to_s() [](#method-i-test_tokens_to_s) - diff --git a/example/ruby/TestRDocTomDoc.md b/example/ruby/TestRDocTomDoc.md deleted file mode 100644 index d1eb8e7..0000000 --- a/example/ruby/TestRDocTomDoc.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: TestRDocTomDoc -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_class_add_post_processor() [](#method-i-test_class_add_post_processor) - -## test_class_rdoc() [](#method-i-test_class_rdoc) - -## test_class_signature() [](#method-i-test_class_signature) - -## test_class_signature_no_space() [](#method-i-test_class_signature_no_space) - -## test_class_signature_none() [](#method-i-test_class_signature_none) - -## test_class_signature_two_space() [](#method-i-test_class_signature_two_space) - -## test_parse_arguments() [](#method-i-test_parse_arguments) - -## test_parse_arguments_array() [](#method-i-test_parse_arguments_array) - -## test_parse_arguments_multiline() [](#method-i-test_parse_arguments_multiline) - -## test_parse_arguments_nested() [](#method-i-test_parse_arguments_nested) - -## test_parse_examples() [](#method-i-test_parse_examples) - -## test_parse_examples_signature() [](#method-i-test_parse_examples_signature) - -## test_parse_multiline_paragraph() [](#method-i-test_parse_multiline_paragraph) - -## test_parse_paragraph() [](#method-i-test_parse_paragraph) - -## test_parse_raises_without_returns() [](#method-i-test_parse_raises_without_returns) - -## test_parse_returns() [](#method-i-test_parse_returns) - -## test_parse_returns_multiline() [](#method-i-test_parse_returns_multiline) - -## test_parse_returns_multiline_and_raises() [](#method-i-test_parse_returns_multiline_and_raises) - -## test_parse_returns_with_raises() [](#method-i-test_parse_returns_with_raises) - -## test_parse_signature() [](#method-i-test_parse_signature) - -## test_tokenize_arguments() [](#method-i-test_tokenize_arguments) - -## test_tokenize_arguments_array() [](#method-i-test_tokenize_arguments_array) - -## test_tokenize_arguments_multiline() [](#method-i-test_tokenize_arguments_multiline) - -## test_tokenize_arguments_nested() [](#method-i-test_tokenize_arguments_nested) - -## test_tokenize_examples() [](#method-i-test_tokenize_examples) - -## test_tokenize_multiline_paragraph() [](#method-i-test_tokenize_multiline_paragraph) - -## test_tokenize_paragraph() [](#method-i-test_tokenize_paragraph) - -## test_tokenize_returns() [](#method-i-test_tokenize_returns) - -## test_tokenize_returns_multiline() [](#method-i-test_tokenize_returns_multiline) - diff --git a/example/ruby/TestRDocTopLevel.md b/example/ruby/TestRDocTopLevel.md deleted file mode 100644 index c8af107..0000000 --- a/example/ruby/TestRDocTopLevel.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: TestRDocTopLevel -**Inherits:** XrefTestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_add_alias() [](#method-i-test_add_alias) - -## test_add_alias_nodoc() [](#method-i-test_add_alias_nodoc) - -## test_add_constant() [](#method-i-test_add_constant) - -## test_add_constant_nodoc() [](#method-i-test_add_constant_nodoc) - -## test_add_include() [](#method-i-test_add_include) - -## test_add_include_nodoc() [](#method-i-test_add_include_nodoc) - -## test_add_method() [](#method-i-test_add_method) - -## test_add_method_stopdoc() [](#method-i-test_add_method_stopdoc) - -## test_base_name() [](#method-i-test_base_name) - -## test_display_eh() [](#method-i-test_display_eh) - -## test_eql_eh() [](#method-i-test_eql_eh) - -## test_equals2() [](#method-i-test_equals2) - -## test_find_class_or_module() [](#method-i-test_find_class_or_module) - -## test_full_name() [](#method-i-test_full_name) - -## test_hash() [](#method-i-test_hash) - -## test_http_url() [](#method-i-test_http_url) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_relative() [](#method-i-test_initialize_relative) - -## test_last_modified() [](#method-i-test_last_modified) - -## test_marshal_dump() [](#method-i-test_marshal_dump) - -## test_marshal_load_version_0() [](#method-i-test_marshal_load_version_0) - -## test_name() [](#method-i-test_name) - -## test_page_name() [](#method-i-test_page_name) - -## test_page_name_trim_extension() [](#method-i-test_page_name_trim_extension) - -## test_search_record() [](#method-i-test_search_record) - -## test_search_record_page() [](#method-i-test_search_record_page) - -## test_text_eh() [](#method-i-test_text_eh) - -## test_text_eh_no_parser() [](#method-i-test_text_eh_no_parser) - diff --git a/example/ruby/TestRand.md b/example/ruby/TestRand.md deleted file mode 100644 index b37f288..0000000 --- a/example/ruby/TestRand.md +++ /dev/null @@ -1,98 +0,0 @@ -# Class: TestRand -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## rand() [](#method-c-rand) - -#Instance Methods -## assert_fork_status(n, mesg, &block) [](#method-i-assert_fork_status) - -## assert_random_int(m, init0, iterate:5) [](#method-i-assert_random_int) - -## assert_same_numbers(type, *nums) [](#method-i-assert_same_numbers) - -## test_0x10000() [](#method-i-test_0x10000) - -## test_0x100000000() [](#method-i-test_0x100000000) - -## test_0x10000000000() [](#method-i-test_0x10000000000) - -## test_0x1000000000000() [](#method-i-test_0x1000000000000) - -## test_0x1000000000001() [](#method-i-test_0x1000000000001) - -## test_0x100000001() [](#method-i-test_0x100000001) - -## test_0x3fffffff() [](#method-i-test_0x3fffffff) - -## test_0x3fffffffffffffff() [](#method-i-test_0x3fffffffffffffff) - -## test_0x40000000() [](#method-i-test_0x40000000) - -## test_0x4000000000000000() [](#method-i-test_0x4000000000000000) - -## test_0x4000000000000001() [](#method-i-test_0x4000000000000001) - -## test_0x40000001() [](#method-i-test_0x40000001) - -## test_0xffffffff() [](#method-i-test_0xffffffff) - -## test_big_seed() [](#method-i-test_big_seed) - -## test_broken_marshal() [](#method-i-test_broken_marshal) - -## test_default_seed() [](#method-i-test_default_seed) - -## test_fork_shuffle() [](#method-i-test_fork_shuffle) - -## test_initialize_frozen() [](#method-i-test_initialize_frozen) - -## test_marshal() [](#method-i-test_marshal) - -## test_marshal_load_frozen() [](#method-i-test_marshal_load_frozen) - -## test_mt() [](#method-i-test_mt) - -## test_new_seed() [](#method-i-test_new_seed) - -## test_rand_0x100000000() [](#method-i-test_rand_0x100000000) - -## test_rand_reseed_on_fork() [](#method-i-test_rand_reseed_on_fork) - -## test_random_argument_error() [](#method-i-test_random_argument_error) - -## test_random_bytes() [](#method-i-test_random_bytes) - -## test_random_dup() [](#method-i-test_random_dup) - -## test_random_equal() [](#method-i-test_random_equal) - -## test_random_float() [](#method-i-test_random_float) - -## test_random_gc() [](#method-i-test_random_gc) - -## test_random_range() [](#method-i-test_random_range) - -## test_random_seed() [](#method-i-test_random_seed) - -## test_random_type_error() [](#method-i-test_random_type_error) - -## test_random_ulong_limited() [](#method-i-test_random_ulong_limited) - -## test_random_ulong_limited_no_rand() [](#method-i-test_random_ulong_limited_no_rand) - -## test_seed() [](#method-i-test_seed) - -## test_seed_leading_zero_guard() [](#method-i-test_seed_leading_zero_guard) - -## test_shuffle() [](#method-i-test_shuffle) - -## test_srand() [](#method-i-test_srand) - -## test_types() [](#method-i-test_types) - -## test_urandom() [](#method-i-test_urandom) - diff --git a/example/ruby/TestRandomExt.md b/example/ruby/TestRandomExt.md deleted file mode 100644 index e23063e..0000000 --- a/example/ruby/TestRandomExt.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestRandomExt - - - - - -#Instance Methods -## setup() [](#method-i-setup) - diff --git a/example/ruby/TestRandomExt/TestLoop.md b/example/ruby/TestRandomExt/TestLoop.md deleted file mode 100644 index 41c8be9..0000000 --- a/example/ruby/TestRandomExt/TestLoop.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestRandomExt::TestLoop -**Inherits:** Test::Unit::TestCase - -**Includes:** TestRandomExt - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_bytes() [](#method-i-test_bytes) - -## test_rand() [](#method-i-test_rand) - -## test_real() [](#method-i-test_real) - diff --git a/example/ruby/TestRandomExt/TestVersionMax.md b/example/ruby/TestRandomExt/TestVersionMax.md deleted file mode 100644 index 521d5e0..0000000 --- a/example/ruby/TestRandomExt/TestVersionMax.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRandomExt::TestVersionMax -**Inherits:** Test::Unit::TestCase - -**Includes:** TestRandomExt - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_bad_version() [](#method-i-test_bad_version) - diff --git a/example/ruby/TestRandomExt/TestVersionZero.md b/example/ruby/TestRandomExt/TestVersionZero.md deleted file mode 100644 index 73e82a6..0000000 --- a/example/ruby/TestRandomExt/TestVersionZero.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRandomExt::TestVersionZero -**Inherits:** Test::Unit::TestCase - -**Includes:** TestRandomExt - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_bad_version() [](#method-i-test_bad_version) - diff --git a/example/ruby/TestRange.md b/example/ruby/TestRange.md deleted file mode 100644 index 0091d6c..0000000 --- a/example/ruby/TestRange.md +++ /dev/null @@ -1,142 +0,0 @@ -# Class: TestRange -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## check_bsearch_values(range, search, a) [](#method-i-check_bsearch_values) - -## test_bad_value() [](#method-i-test_bad_value) - -## test_beg_len() [](#method-i-test_beg_len) - -## test_begin_end() [](#method-i-test_begin_end) - -## test_beginless_range_iteration() [](#method-i-test_beginless_range_iteration) - -## test_bsearch_for_bignum() [](#method-i-test_bsearch_for_bignum) - -## test_bsearch_for_fixnum() [](#method-i-test_bsearch_for_fixnum) - -## test_bsearch_for_float() [](#method-i-test_bsearch_for_float) - -## test_bsearch_for_other_numerics() [](#method-i-test_bsearch_for_other_numerics) - -## test_bsearch_typechecks_return_values() [](#method-i-test_bsearch_typechecks_return_values) - -## test_bsearch_with_no_block() [](#method-i-test_bsearch_with_no_block) - -## test_comparison_when_recursive() [](#method-i-test_comparison_when_recursive) - -## test_count() [](#method-i-test_count) - -## test_cover() [](#method-i-test_cover) - -## test_cyclic_range_inspect() [](#method-i-test_cyclic_range_inspect) - -## test_duckrange() [](#method-i-test_duckrange) - -## test_each() [](#method-i-test_each) - -## test_each_no_blockarg() [](#method-i-test_each_no_blockarg) - -## test_each_with_succ() [](#method-i-test_each_with_succ) - -## test_eq() [](#method-i-test_eq) - -## test_eql() [](#method-i-test_eql) - -## test_eqq() [](#method-i-test_eqq) - -## test_eqq_non_iteratable() [](#method-i-test_eqq_non_iteratable) - -## test_eqq_non_linear() [](#method-i-test_eqq_non_linear) - -## test_eqq_string() [](#method-i-test_eqq_string) - -## test_eqq_time() [](#method-i-test_eqq_time) - -## test_eqq_unbounded_ruby_bug_19864() [](#method-i-test_eqq_unbounded_ruby_bug_19864) - -## test_evaluation_order() [](#method-i-test_evaluation_order) - -## test_exclude_end() [](#method-i-test_exclude_end) - -## test_first_last() [](#method-i-test_first_last) - -## test_frozen_initialize() [](#method-i-test_frozen_initialize) - -## test_hash() [](#method-i-test_hash) - -## test_include() [](#method-i-test_include) - -## test_initialize_twice() [](#method-i-test_initialize_twice) - -## test_inspect() [](#method-i-test_inspect) - -## test_last_with_redefine_each() [](#method-i-test_last_with_redefine_each) - -## test_marshal() [](#method-i-test_marshal) - -## test_max() [](#method-i-test_max) - -## test_min() [](#method-i-test_min) - -## test_minmax() [](#method-i-test_minmax) - -## test_new() [](#method-i-test_new) - -## test_overlap?() [](#method-i-test_overlap?) - -**@return** [Boolean] - -## test_percent_step() [](#method-i-test_percent_step) - -## test_range_bsearch_for_floats() [](#method-i-test_range_bsearch_for_floats) - -## test_range_numeric_string() [](#method-i-test_range_numeric_string) - -## test_range_string() [](#method-i-test_range_string) - -## test_range_symbol() [](#method-i-test_range_symbol) - -## test_reverse_each() [](#method-i-test_reverse_each) - -## test_reverse_each_for_beginless_range() [](#method-i-test_reverse_each_for_beginless_range) - -## test_reverse_each_for_empty_range() [](#method-i-test_reverse_each_for_empty_range) - -## test_reverse_each_for_endless_range() [](#method-i-test_reverse_each_for_endless_range) - -## test_reverse_each_for_single_point_range() [](#method-i-test_reverse_each_for_single_point_range) - -## test_reverse_each_size() [](#method-i-test_reverse_each_size) - -## test_reverse_each_with_no_block() [](#method-i-test_reverse_each_with_no_block) - -## test_size() [](#method-i-test_size) - -## test_step_big_float() [](#method-i-test_step_big_float) - -## test_step_bug15537() [](#method-i-test_step_bug15537) - -## test_step_non_numeric_range() [](#method-i-test_step_non_numeric_range) - -## test_step_numeric_fixnum_boundary() [](#method-i-test_step_numeric_fixnum_boundary) - -## test_step_numeric_range() [](#method-i-test_step_numeric_range) - -## test_step_ruby_core_35753() [](#method-i-test_step_ruby_core_35753) - -## test_step_string_legacy() [](#method-i-test_step_string_legacy) - -## test_step_symbol_legacy() [](#method-i-test_step_symbol_legacy) - -## test_to_a() [](#method-i-test_to_a) - -## test_to_s() [](#method-i-test_to_s) - -## test_uninitialized_range() [](#method-i-test_uninitialized_range) - diff --git a/example/ruby/TestRange/CyclicRange.md b/example/ruby/TestRange/CyclicRange.md deleted file mode 100644 index a96df03..0000000 --- a/example/ruby/TestRange/CyclicRange.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRange::CyclicRange -**Inherits:** Range - - - - - -#Instance Methods -## <=>(other) [](#method-i-<=>) - diff --git a/example/ruby/TestRange/DuckRange.md b/example/ruby/TestRange/DuckRange.md deleted file mode 100644 index 3de52fa..0000000 --- a/example/ruby/TestRange/DuckRange.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: TestRange::DuckRange -**Inherits:** Object - - - - -# Attributes -## begin[RW] [](#attribute-i-begin) -Returns the value of attribute begin. - -## end[RW] [](#attribute-i-end) -Returns the value of attribute end. - - -#Instance Methods -## exclude_end?() [](#method-i-exclude_end?) - -**@return** [Boolean] - -## initialize(b, e, exclfalse) [](#method-i-initialize) - -**@return** [DuckRange] a new instance of DuckRange - diff --git a/example/ruby/TestRational.md b/example/ruby/TestRational.md deleted file mode 100644 index f7a238d..0000000 --- a/example/ruby/TestRational.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRational -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_rb_rational_raw() [](#method-i-test_rb_rational_raw) - diff --git a/example/ruby/TestRational/TestGCD.md b/example/ruby/TestRational/TestGCD.md deleted file mode 100644 index 0971ef6..0000000 --- a/example/ruby/TestRational/TestGCD.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRational::TestGCD -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_gcd_gmp() [](#method-i-test_gcd_gmp) - -## test_gcd_gmp_brute_force() [](#method-i-test_gcd_gmp_brute_force) - -## test_gcd_normal() [](#method-i-test_gcd_normal) - diff --git a/example/ruby/TestRbConfig.md b/example/ruby/TestRbConfig.md deleted file mode 100644 index b92a89d..0000000 --- a/example/ruby/TestRbConfig.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestRbConfig -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_archdirs() [](#method-i-test_archdirs) - -## test_sitearchdirs() [](#method-i-test_sitearchdirs) - -## test_sitedirs() [](#method-i-test_sitedirs) - -## test_vendorarchdirs() [](#method-i-test_vendorarchdirs) - -## test_vendordirs() [](#method-i-test_vendordirs) - diff --git a/example/ruby/TestReadPartial.md b/example/ruby/TestReadPartial.md deleted file mode 100644 index 3ff2e3b..0000000 --- a/example/ruby/TestReadPartial.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestReadPartial -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## make_pipe() [](#method-i-make_pipe) - -## pipe() [](#method-i-pipe) - -## test_closed_pipe() [](#method-i-test_closed_pipe) - -## test_length_zero() [](#method-i-test_length_zero) - -## test_open_pipe() [](#method-i-test_open_pipe) - -## test_with_stdio() [](#method-i-test_with_stdio) - diff --git a/example/ruby/TestRecursion.md b/example/ruby/TestRecursion.md deleted file mode 100644 index b1976ba..0000000 --- a/example/ruby/TestRecursion.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRecursion -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## doit() [](#method-c-doit) - -#Instance Methods -## setup() [](#method-i-setup) - -## test_recursive() [](#method-i-test_recursive) - -## test_recursive_outer() [](#method-i-test_recursive_outer) - diff --git a/example/ruby/TestRedefinition.md b/example/ruby/TestRedefinition.md deleted file mode 100644 index 9938a78..0000000 --- a/example/ruby/TestRedefinition.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRedefinition -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_redefinition() [](#method-i-test_redefinition) - diff --git a/example/ruby/TestRefinement.md b/example/ruby/TestRefinement.md deleted file mode 100644 index 77135e8..0000000 --- a/example/ruby/TestRefinement.md +++ /dev/null @@ -1,260 +0,0 @@ -# Class: TestRefinement -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## suppress_verbose() [](#method-c-suppress_verbose) - -#Instance Methods -## test_adding_private_method() [](#method-i-test_adding_private_method) - -## test_alias_refined_method() [](#method-i-test_alias_refined_method) - -## test_alias_refined_method2() [](#method-i-test_alias_refined_method2) - -## test_ancestors() [](#method-i-test_ancestors) - -## test_builtin_method_no_local_rebinding() [](#method-i-test_builtin_method_no_local_rebinding) - -## test_call_method_in_unused_refinement() [](#method-i-test_call_method_in_unused_refinement) - -## test_call_refined_method_in_duplicate_module() [](#method-i-test_call_refined_method_in_duplicate_module) - -## test_case_dispatch_is_aware_of_refinements() [](#method-i-test_case_dispatch_is_aware_of_refinements) - -## test_change_refined_new_method_visibility() [](#method-i-test_change_refined_new_method_visibility) - -## test_check_funcall_undefined() [](#method-i-test_check_funcall_undefined) - -## test_defining_after_cached() [](#method-i-test_defining_after_cached) - -## test_dsym_literal() [](#method-i-test_dsym_literal) - -## test_eval_scoping() [](#method-i-test_eval_scoping) - -## test_eval_with_binding_scoping() [](#method-i-test_eval_with_binding_scoping) - -## test_funcall_inherited() [](#method-i-test_funcall_inherited) - -## test_import_methods() [](#method-i-test_import_methods) - -## test_include_into_refinement() [](#method-i-test_include_into_refinement) - -## test_include_refinement() [](#method-i-test_include_refinement) - -## test_inherit_singleton_methods_of_module() [](#method-i-test_inherit_singleton_methods_of_module) - -## test_inline_cache_invalidation() [](#method-i-test_inline_cache_invalidation) - -## test_inlinecache() [](#method-i-test_inlinecache) - -## test_inspect() [](#method-i-test_inspect) - -## test_instance_eval_without_refinement() [](#method-i-test_instance_eval_without_refinement) - -## test_instance_method_should_use_refinements() [](#method-i-test_instance_method_should_use_refinements) - -## test_instance_methods() [](#method-i-test_instance_methods) - -## test_instance_methods_not_include_superclass_method() [](#method-i-test_instance_methods_not_include_superclass_method) - -## test_main_using() [](#method-i-test_main_using) - -## test_main_using_is_private() [](#method-i-test_main_using_is_private) - -## test_making_private_method_public() [](#method-i-test_making_private_method_public) - -## test_method_defined() [](#method-i-test_method_defined) - -## test_method_missing() [](#method-i-test_method_missing) - -## test_method_should_use_refinements() [](#method-i-test_method_should_use_refinements) - -## test_mixed_using() [](#method-i-test_mixed_using) - -## test_module_eval() [](#method-i-test_module_eval) - -## test_module_inclusion() [](#method-i-test_module_inclusion) - -## test_module_inclusion2() [](#method-i-test_module_inclusion2) - -## test_module_using() [](#method-i-test_module_using) - -## test_module_using_class() [](#method-i-test_module_using_class) - -## test_module_using_in_method() [](#method-i-test_module_using_in_method) - -## test_module_using_invalid_self() [](#method-i-test_module_using_invalid_self) - -## test_multiple_refinements_for_same_module() [](#method-i-test_multiple_refinements_for_same_module) -Bug #20302 -: - -## test_new_method() [](#method-i-test_new_method) - -## test_new_method_on_subclass() [](#method-i-test_new_method_on_subclass) - -## test_no_kernel_using() [](#method-i-test_no_kernel_using) - -## test_no_local_rebinding() [](#method-i-test_no_local_rebinding) - -## test_override() [](#method-i-test_override) - -## test_override_builtin_method() [](#method-i-test_override_builtin_method) - -## test_override_builtin_method_with_method_added() [](#method-i-test_override_builtin_method_with_method_added) - -## test_prepend_after_refine() [](#method-i-test_prepend_after_refine) - -## test_prepend_after_refine_wb_miss() [](#method-i-test_prepend_after_refine_wb_miss) - -## test_prepend_into_refinement() [](#method-i-test_prepend_into_refinement) - -## test_prepend_refined_module() [](#method-i-test_prepend_refined_module) - -## test_prepended_with_method_cache() [](#method-i-test_prepended_with_method_cache) -Bug #17386 -: - -## test_prepended_with_method_cache_17417() [](#method-i-test_prepended_with_method_cache_17417) -Bug #17417 -: - -## test_privatizing_refined_method() [](#method-i-test_privatizing_refined_method) -Bug #17822 -: - -## test_public_in_refine() [](#method-i-test_public_in_refine) - -## test_public_send_should_use_refinements() [](#method-i-test_public_send_should_use_refinements) - -## test_redefine_refined_method() [](#method-i-test_redefine_refined_method) - -## test_redefining_refined_for_prepended_class() [](#method-i-test_redefining_refined_for_prepended_class) -Bug #17806 -: - -## test_refine_after_using() [](#method-i-test_refine_after_using) - -## test_refine_alias_in_subclass() [](#method-i-test_refine_alias_in_subclass) - -## test_refine_array_min_max() [](#method-i-test_refine_array_min_max) - -## test_refine_basic_object() [](#method-i-test_refine_basic_object) - -## test_refine_frozen_class() [](#method-i-test_refine_frozen_class) - -## test_refine_in_class() [](#method-i-test_refine_in_class) - -## test_refine_in_using() [](#method-i-test_refine_in_using) - -## test_refine_inherited_method_with_visibility_changes() [](#method-i-test_refine_inherited_method_with_visibility_changes) - -## test_refine_module() [](#method-i-test_refine_module) - -## test_refine_mutual_recursion() [](#method-i-test_refine_mutual_recursion) - -## test_refine_neither_class_nor_module() [](#method-i-test_refine_neither_class_nor_module) - -## test_refine_prepended_class() [](#method-i-test_refine_prepended_class) - -## test_refine_prepended_module() [](#method-i-test_refine_prepended_module) - -## test_refine_recursion() [](#method-i-test_refine_recursion) - -## test_refine_same_class_twice() [](#method-i-test_refine_same_class_twice) - -## test_refine_scoping() [](#method-i-test_refine_scoping) - -## test_refine_undefed_method_and_call() [](#method-i-test_refine_undefed_method_and_call) - -## test_refine_undefed_method_and_send() [](#method-i-test_refine_undefed_method_and_send) - -## test_refine_with_prepend() [](#method-i-test_refine_with_prepend) - -## test_refine_with_proc() [](#method-i-test_refine_with_proc) - -## test_refine_without_block() [](#method-i-test_refine_without_block) - -## test_refined_method_alias_warning() [](#method-i-test_refined_method_alias_warning) - -## test_refined_method_defined() [](#method-i-test_refined_method_defined) - -## test_refined_protected_methods() [](#method-i-test_refined_protected_methods) - -## test_refinements() [](#method-i-test_refinements) - -## test_refining_module_repeatedly() [](#method-i-test_refining_module_repeatedly) - -## test_remove_refined_method() [](#method-i-test_remove_refined_method) - -## test_remove_undefined_refined_method() [](#method-i-test_remove_undefined_refined_method) - -## test_reopen_refinement_module() [](#method-i-test_reopen_refinement_module) - -## test_respond_to_should_use_refinements() [](#method-i-test_respond_to_should_use_refinements) - -## test_return_value_of_refine() [](#method-i-test_return_value_of_refine) - -## test_send_should_use_refinements() [](#method-i-test_send_should_use_refinements) - -## test_singleton_method_should_not_use_refinements() [](#method-i-test_singleton_method_should_not_use_refinements) - -## test_subclass_is_prior() [](#method-i-test_subclass_is_prior) - -## test_super() [](#method-i-test_super) - -## test_super_from_refined_module() [](#method-i-test_super_from_refined_module) - -## test_super_in_block() [](#method-i-test_super_in_block) - -## test_super_in_subclass() [](#method-i-test_super_in_subclass) - -## test_super_not_chained() [](#method-i-test_super_not_chained) - -## test_super_to_module() [](#method-i-test_super_to_module) - -## test_symbol_proc() [](#method-i-test_symbol_proc) - -## test_symbol_proc_with_block() [](#method-i-test_symbol_proc_with_block) - -## test_target() [](#method-i-test_target) - -## test_to_proc() [](#method-i-test_to_proc) - -## test_tostring() [](#method-i-test_tostring) - -## test_two_refinements_for_prepended_class() [](#method-i-test_two_refinements_for_prepended_class) -Bug #17806 -: - -## test_unbound_refine_method() [](#method-i-test_unbound_refine_method) - -## test_undef_original_method() [](#method-i-test_undef_original_method) - -## test_undef_prepended_method() [](#method-i-test_undef_prepended_method) - -## test_undef_refined_method() [](#method-i-test_undef_refined_method) - -## test_undefined_refined_method_defined() [](#method-i-test_undefined_refined_method_defined) - -## test_unused_refinement_for_module() [](#method-i-test_unused_refinement_for_module) - -## test_used_modules() [](#method-i-test_used_modules) - -## test_used_refinements() [](#method-i-test_used_refinements) - -## test_using_in_method() [](#method-i-test_using_in_method) - -## test_using_in_module() [](#method-i-test_using_in_module) - -## test_using_method_cache() [](#method-i-test_using_method_cache) - -## test_using_same_class_refinements() [](#method-i-test_using_same_class_refinements) - -## test_using_wrong_argument() [](#method-i-test_using_wrong_argument) - -## test_warn_setconst_in_refinmenet() [](#method-i-test_warn_setconst_in_refinmenet) - diff --git a/example/ruby/TestRefinement/AliasInSubclass.md b/example/ruby/TestRefinement/AliasInSubclass.md deleted file mode 100644 index cb33336..0000000 --- a/example/ruby/TestRefinement/AliasInSubclass.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::AliasInSubclass - - - - - diff --git a/example/ruby/TestRefinement/AliasInSubclass/C.md b/example/ruby/TestRefinement/AliasInSubclass/C.md deleted file mode 100644 index 4860ab4..0000000 --- a/example/ruby/TestRefinement/AliasInSubclass/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::AliasInSubclass::C -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/AliasInSubclass/D.md b/example/ruby/TestRefinement/AliasInSubclass/D.md deleted file mode 100644 index c8c47f1..0000000 --- a/example/ruby/TestRefinement/AliasInSubclass/D.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::AliasInSubclass::D -**Inherits:** TestRefinement::AliasInSubclass::C - - - - - diff --git a/example/ruby/TestRefinement/AliasInSubclass/M.md b/example/ruby/TestRefinement/AliasInSubclass/M.md deleted file mode 100644 index b87067e..0000000 --- a/example/ruby/TestRefinement/AliasInSubclass/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::AliasInSubclass::M - - - - - diff --git a/example/ruby/TestRefinement/ArrayEachExt.md b/example/ruby/TestRefinement/ArrayEachExt.md deleted file mode 100644 index dfad93e..0000000 --- a/example/ruby/TestRefinement/ArrayEachExt.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::ArrayEachExt - - - - - diff --git a/example/ruby/TestRefinement/Bar.md b/example/ruby/TestRefinement/Bar.md deleted file mode 100644 index c659993..0000000 --- a/example/ruby/TestRefinement/Bar.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::Bar -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/BarExt.md b/example/ruby/TestRefinement/BarExt.md deleted file mode 100644 index 3c90ea6..0000000 --- a/example/ruby/TestRefinement/BarExt.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::BarExt - - - - - diff --git a/example/ruby/TestRefinement/Bug13446.md b/example/ruby/TestRefinement/Bug13446.md deleted file mode 100644 index c2623b3..0000000 --- a/example/ruby/TestRefinement/Bug13446.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::Bug13446 - - - - - diff --git a/example/ruby/TestRefinement/Bug13446/Enumerable.md b/example/ruby/TestRefinement/Bug13446/Enumerable.md deleted file mode 100644 index d6b84c5..0000000 --- a/example/ruby/TestRefinement/Bug13446/Enumerable.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestRefinement::Bug13446::Enumerable - - - - - -#Instance Methods -## sum(*args) [](#method-i-sum) - diff --git a/example/ruby/TestRefinement/Bug13446/GenericEnumerable.md b/example/ruby/TestRefinement/Bug13446/GenericEnumerable.md deleted file mode 100644 index 1215e14..0000000 --- a/example/ruby/TestRefinement/Bug13446/GenericEnumerable.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRefinement::Bug13446::GenericEnumerable -**Inherits:** Object - -**Includes:** TestRefinement::Bug13446::Enumerable - - - - - -#Instance Methods -## sum(*args) [](#method-i-sum) - diff --git a/example/ruby/TestRefinement/Bug16242.md b/example/ruby/TestRefinement/Bug16242.md deleted file mode 100644 index de060a8..0000000 --- a/example/ruby/TestRefinement/Bug16242.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::Bug16242 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/Bug16242/M.md b/example/ruby/TestRefinement/Bug16242/M.md deleted file mode 100644 index 0d6126e..0000000 --- a/example/ruby/TestRefinement/Bug16242/M.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: TestRefinement::Bug16242::M - -**Includes:** TestRefinement::Bug16242::OtherM - - - - - -#Instance Methods -## hoge() [](#method-i-hoge) - diff --git a/example/ruby/TestRefinement/Bug16242/OtherM.md b/example/ruby/TestRefinement/Bug16242/OtherM.md deleted file mode 100644 index 299bb21..0000000 --- a/example/ruby/TestRefinement/Bug16242/OtherM.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::Bug16242::OtherM - - - - - diff --git a/example/ruby/TestRefinement/Bug16242/X.md b/example/ruby/TestRefinement/Bug16242/X.md deleted file mode 100644 index f27b4d8..0000000 --- a/example/ruby/TestRefinement/Bug16242/X.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRefinement::Bug16242::X -**Inherits:** Object - -**Includes:** TestRefinement::Bug16242::M - - - - - -#Instance Methods -## hoge() [](#method-i-hoge) - diff --git a/example/ruby/TestRefinement/Bug17822.md b/example/ruby/TestRefinement/Bug17822.md deleted file mode 100644 index 3173637..0000000 --- a/example/ruby/TestRefinement/Bug17822.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::Bug17822 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/Bug17822/Client.md b/example/ruby/TestRefinement/Bug17822/Client.md deleted file mode 100644 index da62047..0000000 --- a/example/ruby/TestRefinement/Bug17822/Client.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestRefinement::Bug17822::Client - - - - -# Class Methods -## call_foo() [](#method-c-call_foo) - diff --git a/example/ruby/TestRefinement/Bug17822/Ext.md b/example/ruby/TestRefinement/Bug17822/Ext.md deleted file mode 100644 index 0867cdf..0000000 --- a/example/ruby/TestRefinement/Bug17822/Ext.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::Bug17822::Ext - - - - - diff --git a/example/ruby/TestRefinement/Bug18180.md b/example/ruby/TestRefinement/Bug18180.md deleted file mode 100644 index 3192eb3..0000000 --- a/example/ruby/TestRefinement/Bug18180.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::Bug18180 -**Inherits:** Object - - - - - -#Instance Methods -## t() [](#method-i-t) - diff --git a/example/ruby/TestRefinement/Bug18180/M.md b/example/ruby/TestRefinement/Bug18180/M.md deleted file mode 100644 index c490d33..0000000 --- a/example/ruby/TestRefinement/Bug18180/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::Bug18180::M - - - - - diff --git a/example/ruby/TestRefinement/Foo.md b/example/ruby/TestRefinement/Foo.md deleted file mode 100644 index 2ef2c2b..0000000 --- a/example/ruby/TestRefinement/Foo.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestRefinement::Foo -**Inherits:** Object - - - - - -#Instance Methods -## a() [](#method-i-a) - -## b() [](#method-i-b) - -## call_x() [](#method-i-call_x) - -## x() [](#method-i-x) - -## y() [](#method-i-y) - diff --git a/example/ruby/TestRefinement/FooBarExt.md b/example/ruby/TestRefinement/FooBarExt.md deleted file mode 100644 index ab76f0b..0000000 --- a/example/ruby/TestRefinement/FooBarExt.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestRefinement::FooBarExt - -**Includes:** TestRefinement::BarExt, TestRefinement::FooExt - - - - - diff --git a/example/ruby/TestRefinement/FooBarExtClient.md b/example/ruby/TestRefinement/FooBarExtClient.md deleted file mode 100644 index 067ce34..0000000 --- a/example/ruby/TestRefinement/FooBarExtClient.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestRefinement::FooBarExtClient - - - - -# Class Methods -## invoke_x_on(foo ) [](#method-c-invoke_x_on) - diff --git a/example/ruby/TestRefinement/FooExt.md b/example/ruby/TestRefinement/FooExt.md deleted file mode 100644 index a2a5502..0000000 --- a/example/ruby/TestRefinement/FooExt.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::FooExt - - - - - diff --git a/example/ruby/TestRefinement/FooExt2.md b/example/ruby/TestRefinement/FooExt2.md deleted file mode 100644 index 241def0..0000000 --- a/example/ruby/TestRefinement/FooExt2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::FooExt2 - - - - - diff --git a/example/ruby/TestRefinement/FooExtClient.md b/example/ruby/TestRefinement/FooExtClient.md deleted file mode 100644 index 2bca49e..0000000 --- a/example/ruby/TestRefinement/FooExtClient.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::FooExtClient -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/FooExtClient2.md b/example/ruby/TestRefinement/FooExtClient2.md deleted file mode 100644 index 8f11cc6..0000000 --- a/example/ruby/TestRefinement/FooExtClient2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::FooExtClient2 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/FooFoo2Ext.md b/example/ruby/TestRefinement/FooFoo2Ext.md deleted file mode 100644 index 1dd174c..0000000 --- a/example/ruby/TestRefinement/FooFoo2Ext.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestRefinement::FooFoo2Ext - -**Includes:** TestRefinement::FooExt, TestRefinement::FooExt2 - - - - - diff --git a/example/ruby/TestRefinement/FooFoo2ExtClient.md b/example/ruby/TestRefinement/FooFoo2ExtClient.md deleted file mode 100644 index afedd45..0000000 --- a/example/ruby/TestRefinement/FooFoo2ExtClient.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestRefinement::FooFoo2ExtClient - - - - -# Class Methods -## invoke_x_on(foo ) [](#method-c-invoke_x_on) -## invoke_y_on(foo ) [](#method-c-invoke_y_on) - diff --git a/example/ruby/TestRefinement/FooSub.md b/example/ruby/TestRefinement/FooSub.md deleted file mode 100644 index a6d64e1..0000000 --- a/example/ruby/TestRefinement/FooSub.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRefinement::FooSub -**Inherits:** TestRefinement::Foo - - - - - -#Instance Methods -## x() [](#method-i-x) - -## y() [](#method-i-y) - diff --git a/example/ruby/TestRefinement/Inspect.md b/example/ruby/TestRefinement/Inspect.md deleted file mode 100644 index 52e871b..0000000 --- a/example/ruby/TestRefinement/Inspect.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::Inspect - - - - - diff --git a/example/ruby/TestRefinement/Inspect/M.md b/example/ruby/TestRefinement/Inspect/M.md deleted file mode 100644 index 6674486..0000000 --- a/example/ruby/TestRefinement/Inspect/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::Inspect::M - - - - - diff --git a/example/ruby/TestRefinement/InstanceMethodIntegerPowEx.md b/example/ruby/TestRefinement/InstanceMethodIntegerPowEx.md deleted file mode 100644 index a7eff8e..0000000 --- a/example/ruby/TestRefinement/InstanceMethodIntegerPowEx.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::InstanceMethodIntegerPowEx - - - - - diff --git a/example/ruby/TestRefinement/IntegerFooExt.md b/example/ruby/TestRefinement/IntegerFooExt.md deleted file mode 100644 index 440dd66..0000000 --- a/example/ruby/TestRefinement/IntegerFooExt.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::IntegerFooExt - - - - - diff --git a/example/ruby/TestRefinement/IntegerPlusExt.md b/example/ruby/TestRefinement/IntegerPlusExt.md deleted file mode 100644 index ac7920f..0000000 --- a/example/ruby/TestRefinement/IntegerPlusExt.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::IntegerPlusExt - - - - - diff --git a/example/ruby/TestRefinement/IntegerSlashExt.md b/example/ruby/TestRefinement/IntegerSlashExt.md deleted file mode 100644 index cf97cf3..0000000 --- a/example/ruby/TestRefinement/IntegerSlashExt.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::IntegerSlashExt - - - - - diff --git a/example/ruby/TestRefinement/MethodIntegerPowEx.md b/example/ruby/TestRefinement/MethodIntegerPowEx.md deleted file mode 100644 index 6b1de3c..0000000 --- a/example/ruby/TestRefinement/MethodIntegerPowEx.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::MethodIntegerPowEx - - - - - diff --git a/example/ruby/TestRefinement/MethodMissing.md b/example/ruby/TestRefinement/MethodMissing.md deleted file mode 100644 index 9423116..0000000 --- a/example/ruby/TestRefinement/MethodMissing.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestRefinement::MethodMissing - - - - -# Class Methods -## call_undefined_method() [](#method-c-call_undefined_method) - diff --git a/example/ruby/TestRefinement/MethodMissing/Bar.md b/example/ruby/TestRefinement/MethodMissing/Bar.md deleted file mode 100644 index 3955d1c..0000000 --- a/example/ruby/TestRefinement/MethodMissing/Bar.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::MethodMissing::Bar - - - - - diff --git a/example/ruby/TestRefinement/MethodMissing/Foo.md b/example/ruby/TestRefinement/MethodMissing/Foo.md deleted file mode 100644 index 8070d6f..0000000 --- a/example/ruby/TestRefinement/MethodMissing/Foo.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::MethodMissing::Foo -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/MixedUsing1.md b/example/ruby/TestRefinement/MixedUsing1.md deleted file mode 100644 index d5492e1..0000000 --- a/example/ruby/TestRefinement/MixedUsing1.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestRefinement::MixedUsing1 - - - - -# Class Methods -## bar() [](#method-c-bar) -## foo() [](#method-c-foo) - diff --git a/example/ruby/TestRefinement/MixedUsing1/C.md b/example/ruby/TestRefinement/MixedUsing1/C.md deleted file mode 100644 index 92cfbed..0000000 --- a/example/ruby/TestRefinement/MixedUsing1/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::MixedUsing1::C -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/MixedUsing1/R1.md b/example/ruby/TestRefinement/MixedUsing1/R1.md deleted file mode 100644 index 06f76a5..0000000 --- a/example/ruby/TestRefinement/MixedUsing1/R1.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::MixedUsing1::R1 - - - - - diff --git a/example/ruby/TestRefinement/MixedUsing2.md b/example/ruby/TestRefinement/MixedUsing2.md deleted file mode 100644 index 8296d57..0000000 --- a/example/ruby/TestRefinement/MixedUsing2.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestRefinement::MixedUsing2 - - - - -# Class Methods -## f1() [](#method-c-f1) -## f2() [](#method-c-f2) - diff --git a/example/ruby/TestRefinement/MixedUsing2/C.md b/example/ruby/TestRefinement/MixedUsing2/C.md deleted file mode 100644 index fdac20f..0000000 --- a/example/ruby/TestRefinement/MixedUsing2/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::MixedUsing2::C -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/MixedUsing2/R1.md b/example/ruby/TestRefinement/MixedUsing2/R1.md deleted file mode 100644 index 1367290..0000000 --- a/example/ruby/TestRefinement/MixedUsing2/R1.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::MixedUsing2::R1 - - - - - diff --git a/example/ruby/TestRefinement/MixedUsing2/R2.md b/example/ruby/TestRefinement/MixedUsing2/R2.md deleted file mode 100644 index 6af9785..0000000 --- a/example/ruby/TestRefinement/MixedUsing2/R2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::MixedUsing2::R2 - - - - - diff --git a/example/ruby/TestRefinement/MixinDefiningPrivateMethod.md b/example/ruby/TestRefinement/MixinDefiningPrivateMethod.md deleted file mode 100644 index e7df940..0000000 --- a/example/ruby/TestRefinement/MixinDefiningPrivateMethod.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::MixinDefiningPrivateMethod - - - - - diff --git a/example/ruby/TestRefinement/ModuleUsing.md b/example/ruby/TestRefinement/ModuleUsing.md deleted file mode 100644 index 0e472fa..0000000 --- a/example/ruby/TestRefinement/ModuleUsing.md +++ /dev/null @@ -1,14 +0,0 @@ -# Module: TestRefinement::ModuleUsing - - - - -# Class Methods -## invoke_call_x_on(foo ) [](#method-c-invoke_call_x_on) -## invoke_x_on(foo ) [](#method-c-invoke_x_on) -## invoke_y_on(foo ) [](#method-c-invoke_y_on) -## invoke_z_on(foo ) [](#method-c-invoke_z_on) -## method_z(foo ) [](#method-c-method_z) -## public_send_z_on(foo ) [](#method-c-public_send_z_on) -## send_z_on(foo ) [](#method-c-send_z_on) - diff --git a/example/ruby/TestRefinement/NotIncludeSuperclassMethod.md b/example/ruby/TestRefinement/NotIncludeSuperclassMethod.md deleted file mode 100644 index c9231a0..0000000 --- a/example/ruby/TestRefinement/NotIncludeSuperclassMethod.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::NotIncludeSuperclassMethod - - - - - diff --git a/example/ruby/TestRefinement/NotIncludeSuperclassMethod/Bar.md b/example/ruby/TestRefinement/NotIncludeSuperclassMethod/Bar.md deleted file mode 100644 index 6fdeeef..0000000 --- a/example/ruby/TestRefinement/NotIncludeSuperclassMethod/Bar.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::NotIncludeSuperclassMethod::Bar - - - - - diff --git a/example/ruby/TestRefinement/NotIncludeSuperclassMethod/X.md b/example/ruby/TestRefinement/NotIncludeSuperclassMethod/X.md deleted file mode 100644 index 5092202..0000000 --- a/example/ruby/TestRefinement/NotIncludeSuperclassMethod/X.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::NotIncludeSuperclassMethod::X -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/NotIncludeSuperclassMethod/Y.md b/example/ruby/TestRefinement/NotIncludeSuperclassMethod/Y.md deleted file mode 100644 index 7256f54..0000000 --- a/example/ruby/TestRefinement/NotIncludeSuperclassMethod/Y.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::NotIncludeSuperclassMethod::Y -**Inherits:** TestRefinement::NotIncludeSuperclassMethod::X - - - - - diff --git a/example/ruby/TestRefinement/ParentDefiningPrivateMethod.md b/example/ruby/TestRefinement/ParentDefiningPrivateMethod.md deleted file mode 100644 index 8ab480e..0000000 --- a/example/ruby/TestRefinement/ParentDefiningPrivateMethod.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::ParentDefiningPrivateMethod -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/RedefineRefinedMethod.md b/example/ruby/TestRefinement/RedefineRefinedMethod.md deleted file mode 100644 index dd81a5e..0000000 --- a/example/ruby/TestRefinement/RedefineRefinedMethod.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RedefineRefinedMethod - - - - - diff --git a/example/ruby/TestRefinement/RedefineRefinedMethod/C.md b/example/ruby/TestRefinement/RedefineRefinedMethod/C.md deleted file mode 100644 index 3898466..0000000 --- a/example/ruby/TestRefinement/RedefineRefinedMethod/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::RedefineRefinedMethod::C -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/RedefineRefinedMethod/M.md b/example/ruby/TestRefinement/RedefineRefinedMethod/M.md deleted file mode 100644 index ca7c541..0000000 --- a/example/ruby/TestRefinement/RedefineRefinedMethod/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RedefineRefinedMethod::M - - - - - diff --git a/example/ruby/TestRefinement/RefineInUsing.md b/example/ruby/TestRefinement/RefineInUsing.md deleted file mode 100644 index a3f16b5..0000000 --- a/example/ruby/TestRefinement/RefineInUsing.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestRefinement::RefineInUsing -**Inherits:** Object - - - - -# Class Methods -## test() [](#method-c-test) - diff --git a/example/ruby/TestRefinement/RefineInUsing/M1.md b/example/ruby/TestRefinement/RefineInUsing/M1.md deleted file mode 100644 index ac5df3b..0000000 --- a/example/ruby/TestRefinement/RefineInUsing/M1.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RefineInUsing::M1 - - - - - diff --git a/example/ruby/TestRefinement/RefineInUsing/M2.md b/example/ruby/TestRefinement/RefineInUsing/M2.md deleted file mode 100644 index 665c1d1..0000000 --- a/example/ruby/TestRefinement/RefineInUsing/M2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RefineInUsing::M2 - - - - - diff --git a/example/ruby/TestRefinement/RefineModule.md b/example/ruby/TestRefinement/RefineModule.md deleted file mode 100644 index 44a4e47..0000000 --- a/example/ruby/TestRefinement/RefineModule.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: TestRefinement::RefineModule - - - - -# Class Methods -## call_bar() [](#method-c-call_bar) -## call_baz() [](#method-c-call_baz) -## call_foo() [](#method-c-call_foo) - diff --git a/example/ruby/TestRefinement/RefineModule/C.md b/example/ruby/TestRefinement/RefineModule/C.md deleted file mode 100644 index 90eed7e..0000000 --- a/example/ruby/TestRefinement/RefineModule/C.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRefinement::RefineModule::C -**Inherits:** Object - -**Includes:** TestRefinement::RefineModule::M - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## baz() [](#method-i-baz) - -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/RefineModule/M.md b/example/ruby/TestRefinement/RefineModule/M.md deleted file mode 100644 index f4f6e81..0000000 --- a/example/ruby/TestRefinement/RefineModule/M.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: TestRefinement::RefineModule::M - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## baz() [](#method-i-baz) - -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/RefineModule/M2.md b/example/ruby/TestRefinement/RefineModule/M2.md deleted file mode 100644 index 1030980..0000000 --- a/example/ruby/TestRefinement/RefineModule/M2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RefineModule::M2 - - - - - diff --git a/example/ruby/TestRefinement/RefinePrependedClass.md b/example/ruby/TestRefinement/RefinePrependedClass.md deleted file mode 100644 index 422866c..0000000 --- a/example/ruby/TestRefinement/RefinePrependedClass.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RefinePrependedClass - - - - - diff --git a/example/ruby/TestRefinement/RefinePrependedClass/C.md b/example/ruby/TestRefinement/RefinePrependedClass/C.md deleted file mode 100644 index c7ae883..0000000 --- a/example/ruby/TestRefinement/RefinePrependedClass/C.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRefinement::RefinePrependedClass::C -**Inherits:** Object - -**Includes:** TestRefinement::RefinePrependedClass::M1 - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/RefinePrependedClass/M1.md b/example/ruby/TestRefinement/RefinePrependedClass/M1.md deleted file mode 100644 index bc19625..0000000 --- a/example/ruby/TestRefinement/RefinePrependedClass/M1.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestRefinement::RefinePrependedClass::M1 - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/RefinePrependedClass/M2.md b/example/ruby/TestRefinement/RefinePrependedClass/M2.md deleted file mode 100644 index 327931f..0000000 --- a/example/ruby/TestRefinement/RefinePrependedClass/M2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RefinePrependedClass::M2 - - - - - diff --git a/example/ruby/TestRefinement/RefineSameClass.md b/example/ruby/TestRefinement/RefineSameClass.md deleted file mode 100644 index e2f1590..0000000 --- a/example/ruby/TestRefinement/RefineSameClass.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RefineSameClass - - - - - diff --git a/example/ruby/TestRefinement/RefineScoping.md b/example/ruby/TestRefinement/RefineScoping.md deleted file mode 100644 index 53e3d2d..0000000 --- a/example/ruby/TestRefinement/RefineScoping.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestRefinement::RefineScoping - - - - -# Class Methods -## call_outside_refine_block() [](#method-c-call_outside_refine_block) - diff --git a/example/ruby/TestRefinement/RespondTo.md b/example/ruby/TestRefinement/RespondTo.md deleted file mode 100644 index e9b57bd..0000000 --- a/example/ruby/TestRefinement/RespondTo.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RespondTo - - - - - diff --git a/example/ruby/TestRefinement/RespondTo/M.md b/example/ruby/TestRefinement/RespondTo/M.md deleted file mode 100644 index 0cde40e..0000000 --- a/example/ruby/TestRefinement/RespondTo/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::RespondTo::M - - - - - diff --git a/example/ruby/TestRefinement/RespondTo/Sub.md b/example/ruby/TestRefinement/RespondTo/Sub.md deleted file mode 100644 index 5157794..0000000 --- a/example/ruby/TestRefinement/RespondTo/Sub.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::RespondTo::Sub -**Inherits:** TestRefinement::RespondTo::Super - - - - - diff --git a/example/ruby/TestRefinement/RespondTo/Super.md b/example/ruby/TestRefinement/RespondTo/Super.md deleted file mode 100644 index b22eb51..0000000 --- a/example/ruby/TestRefinement/RespondTo/Super.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::RespondTo::Super -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/Sandbox.md b/example/ruby/TestRefinement/Sandbox.md deleted file mode 100644 index eef76e8..0000000 --- a/example/ruby/TestRefinement/Sandbox.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::Sandbox - - - - - diff --git a/example/ruby/TestRefinement/SomeChildClassToRefine.md b/example/ruby/TestRefinement/SomeChildClassToRefine.md deleted file mode 100644 index 45e3359..0000000 --- a/example/ruby/TestRefinement/SomeChildClassToRefine.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestRefinement::SomeChildClassToRefine -**Inherits:** TestRefinement::ParentDefiningPrivateMethod - -**Includes:** TestRefinement::MixinDefiningPrivateMethod - - - - - diff --git a/example/ruby/TestRefinement/StringCmpExt.md b/example/ruby/TestRefinement/StringCmpExt.md deleted file mode 100644 index 05b797e..0000000 --- a/example/ruby/TestRefinement/StringCmpExt.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::StringCmpExt - - - - - diff --git a/example/ruby/TestRefinement/StringExt.md b/example/ruby/TestRefinement/StringExt.md deleted file mode 100644 index 7e6bd5d..0000000 --- a/example/ruby/TestRefinement/StringExt.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::StringExt - - - - - diff --git a/example/ruby/TestRefinement/StringRecursiveLength.md b/example/ruby/TestRefinement/StringRecursiveLength.md deleted file mode 100644 index e5d4c52..0000000 --- a/example/ruby/TestRefinement/StringRecursiveLength.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::StringRecursiveLength - - - - - diff --git a/example/ruby/TestRefinement/SuperInBlock.md b/example/ruby/TestRefinement/SuperInBlock.md deleted file mode 100644 index f63a57a..0000000 --- a/example/ruby/TestRefinement/SuperInBlock.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::SuperInBlock - - - - - diff --git a/example/ruby/TestRefinement/SuperInBlock/C.md b/example/ruby/TestRefinement/SuperInBlock/C.md deleted file mode 100644 index eb90229..0000000 --- a/example/ruby/TestRefinement/SuperInBlock/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::SuperInBlock::C -**Inherits:** Object - - - - - -#Instance Methods -## foo(*args) [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/SuperInBlock/R.md b/example/ruby/TestRefinement/SuperInBlock/R.md deleted file mode 100644 index a6e10df..0000000 --- a/example/ruby/TestRefinement/SuperInBlock/R.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::SuperInBlock::R - - - - - diff --git a/example/ruby/TestRefinement/SuperToModule.md b/example/ruby/TestRefinement/SuperToModule.md deleted file mode 100644 index 35892a0..0000000 --- a/example/ruby/TestRefinement/SuperToModule.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::SuperToModule - - - - - diff --git a/example/ruby/TestRefinement/SuperToModule/Child.md b/example/ruby/TestRefinement/SuperToModule/Child.md deleted file mode 100644 index 3c4e4ea..0000000 --- a/example/ruby/TestRefinement/SuperToModule/Child.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestRefinement::SuperToModule::Child -**Inherits:** TestRefinement::SuperToModule::Parent - - - - -# Class Methods -## test() [](#method-c-test) - diff --git a/example/ruby/TestRefinement/SuperToModule/FooBar.md b/example/ruby/TestRefinement/SuperToModule/FooBar.md deleted file mode 100644 index 22c3bbf..0000000 --- a/example/ruby/TestRefinement/SuperToModule/FooBar.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::SuperToModule::FooBar - - - - - diff --git a/example/ruby/TestRefinement/SuperToModule/Parent.md b/example/ruby/TestRefinement/SuperToModule/Parent.md deleted file mode 100644 index 29ea4c2..0000000 --- a/example/ruby/TestRefinement/SuperToModule/Parent.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::SuperToModule::Parent -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/TestImport.md b/example/ruby/TestRefinement/TestImport.md deleted file mode 100644 index 86dd916..0000000 --- a/example/ruby/TestRefinement/TestImport.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::TestImport - - - - - diff --git a/example/ruby/TestRefinement/TestImport/A.md b/example/ruby/TestRefinement/TestImport/A.md deleted file mode 100644 index b3e59fb..0000000 --- a/example/ruby/TestRefinement/TestImport/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::TestImport::A -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestRefinement/TestImport/B.md b/example/ruby/TestRefinement/TestImport/B.md deleted file mode 100644 index 6519520..0000000 --- a/example/ruby/TestRefinement/TestImport/B.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestRefinement::TestImport::B - - - - - -#Instance Methods -## bar() [](#method-i-bar) - diff --git a/example/ruby/TestRefinement/TestImport/C.md b/example/ruby/TestRefinement/TestImport/C.md deleted file mode 100644 index 30f0f57..0000000 --- a/example/ruby/TestRefinement/TestImport/C.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::TestImport::C - - - - - diff --git a/example/ruby/TestRefinement/TestImport/UsingC.md b/example/ruby/TestRefinement/TestImport/UsingC.md deleted file mode 100644 index b5c1451..0000000 --- a/example/ruby/TestRefinement/TestImport/UsingC.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestRefinement::TestImport::UsingC - - - - -# Class Methods -## call_bar() [](#method-c-call_bar) - diff --git a/example/ruby/TestRefinement/ToJSON.md b/example/ruby/TestRefinement/ToJSON.md deleted file mode 100644 index db374d8..0000000 --- a/example/ruby/TestRefinement/ToJSON.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::ToJSON - - - - - diff --git a/example/ruby/TestRefinement/ToProc.md b/example/ruby/TestRefinement/ToProc.md deleted file mode 100644 index 3a2fd95..0000000 --- a/example/ruby/TestRefinement/ToProc.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: TestRefinement::ToProc - - - - -# Class Methods -## call(&block ) [](#method-c-call) - diff --git a/example/ruby/TestRefinement/ToProc/MethodMissing.md b/example/ruby/TestRefinement/ToProc/MethodMissing.md deleted file mode 100644 index 4ed3475..0000000 --- a/example/ruby/TestRefinement/ToProc/MethodMissing.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRefinement::ToProc::MethodMissing -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - -## method_missing(*args) [](#method-i-method_missing) - diff --git a/example/ruby/TestRefinement/ToProc/NonProc.md b/example/ruby/TestRefinement/ToProc/NonProc.md deleted file mode 100644 index d768305..0000000 --- a/example/ruby/TestRefinement/ToProc/NonProc.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::ToProc::NonProc -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - diff --git a/example/ruby/TestRefinement/ToProc/PrivateToProc.md b/example/ruby/TestRefinement/ToProc/PrivateToProc.md deleted file mode 100644 index 0061c30..0000000 --- a/example/ruby/TestRefinement/ToProc/PrivateToProc.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::ToProc::PrivateToProc -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - diff --git a/example/ruby/TestRefinement/ToProc/ReturnNoProc.md b/example/ruby/TestRefinement/ToProc/ReturnNoProc.md deleted file mode 100644 index 4f98c1c..0000000 --- a/example/ruby/TestRefinement/ToProc/ReturnNoProc.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::ToProc::ReturnNoProc -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - diff --git a/example/ruby/TestRefinement/ToProc/ReturnProc.md b/example/ruby/TestRefinement/ToProc/ReturnProc.md deleted file mode 100644 index 65a9934..0000000 --- a/example/ruby/TestRefinement/ToProc/ReturnProc.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::ToProc::ReturnProc -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - diff --git a/example/ruby/TestRefinement/ToProc/ToProcAndMethodMissing.md b/example/ruby/TestRefinement/ToProc/ToProcAndMethodMissing.md deleted file mode 100644 index fa9a42c..0000000 --- a/example/ruby/TestRefinement/ToProc/ToProcAndMethodMissing.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRefinement::ToProc::ToProcAndMethodMissing -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - -## method_missing(*args) [](#method-i-method_missing) - diff --git a/example/ruby/TestRefinement/ToProc/ToProcAndRefinements.md b/example/ruby/TestRefinement/ToProc/ToProcAndRefinements.md deleted file mode 100644 index b63e422..0000000 --- a/example/ruby/TestRefinement/ToProc/ToProcAndRefinements.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRefinement::ToProc::ToProcAndRefinements -**Inherits:** Object - - - - - -#Instance Methods -## call() [](#method-i-call) - -## to_proc() [](#method-i-to_proc) - diff --git a/example/ruby/TestRefinement/ToString.md b/example/ruby/TestRefinement/ToString.md deleted file mode 100644 index 0995be3..0000000 --- a/example/ruby/TestRefinement/ToString.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRefinement::ToString -**Inherits:** Object - - - - - -#Instance Methods -## string() [](#method-i-string) - diff --git a/example/ruby/TestRefinement/ToSymbol.md b/example/ruby/TestRefinement/ToSymbol.md deleted file mode 100644 index cbab410..0000000 --- a/example/ruby/TestRefinement/ToSymbol.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRefinement::ToSymbol -**Inherits:** Object - - - - - -#Instance Methods -## initialize(string) [](#method-i-initialize) - -**@return** [ToSymbol] a new instance of ToSymbol - -## symbol() [](#method-i-symbol) - diff --git a/example/ruby/TestRefinement/UsingClass.md b/example/ruby/TestRefinement/UsingClass.md deleted file mode 100644 index e97dc2d..0000000 --- a/example/ruby/TestRefinement/UsingClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRefinement::UsingClass -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRefinement/VisibleRefinements.md b/example/ruby/TestRefinement/VisibleRefinements.md deleted file mode 100644 index 6f642fb..0000000 --- a/example/ruby/TestRefinement/VisibleRefinements.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::VisibleRefinements - - - - - diff --git a/example/ruby/TestRefinement/VisibleRefinements/Bar.md b/example/ruby/TestRefinement/VisibleRefinements/Bar.md deleted file mode 100644 index 004bae3..0000000 --- a/example/ruby/TestRefinement/VisibleRefinements/Bar.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::VisibleRefinements::Bar - - - - - diff --git a/example/ruby/TestRefinement/VisibleRefinements/Combined.md b/example/ruby/TestRefinement/VisibleRefinements/Combined.md deleted file mode 100644 index 675f112..0000000 --- a/example/ruby/TestRefinement/VisibleRefinements/Combined.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::VisibleRefinements::Combined - - - - - diff --git a/example/ruby/TestRefinement/VisibleRefinements/Foo.md b/example/ruby/TestRefinement/VisibleRefinements/Foo.md deleted file mode 100644 index 5438232..0000000 --- a/example/ruby/TestRefinement/VisibleRefinements/Foo.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::VisibleRefinements::Foo - - - - - diff --git a/example/ruby/TestRefinement/VisibleRefinements/RefA.md b/example/ruby/TestRefinement/VisibleRefinements/RefA.md deleted file mode 100644 index cddce7e..0000000 --- a/example/ruby/TestRefinement/VisibleRefinements/RefA.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::VisibleRefinements::RefA - - - - - diff --git a/example/ruby/TestRefinement/VisibleRefinements/RefB.md b/example/ruby/TestRefinement/VisibleRefinements/RefB.md deleted file mode 100644 index 72188f1..0000000 --- a/example/ruby/TestRefinement/VisibleRefinements/RefB.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::VisibleRefinements::RefB - - - - - diff --git a/example/ruby/TestRefinement/VisibleRefinements/RefC.md b/example/ruby/TestRefinement/VisibleRefinements/RefC.md deleted file mode 100644 index db057c4..0000000 --- a/example/ruby/TestRefinement/VisibleRefinements/RefC.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRefinement::VisibleRefinements::RefC - - - - - diff --git a/example/ruby/TestRegexp.md b/example/ruby/TestRegexp.md deleted file mode 100644 index 1240477..0000000 --- a/example/ruby/TestRegexp.md +++ /dev/null @@ -1,344 +0,0 @@ -# Class: TestRegexp -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## test(s , nil: :ng) [](#method-c-test) -## threaded_test(worker ) [](#method-c-threaded_test) - -#Instance Methods -## assert_fail(re) [](#method-i-assert_fail) - -## assert_match_at(re, str, positions, msgnil) [](#method-i-assert_match_at) -This assertion is for porting x2() tests in testpy.py of Onigmo. - -## assert_match_each(re, conds, msgnil) [](#method-i-assert_match_each) - -## assert_regexp(re, ss, fs[], msgnil) [](#method-i-assert_regexp) - -## assert_unicode_age(char, mesgnil, matches:@matches, unmatches:@unmatches) [](#method-i-assert_unicode_age) - -## per_instance_redos_test(global_timeout, per_instance_timeout, expected_timeout) [](#method-i-per_instance_redos_test) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_absent() [](#method-i-test_absent) - -## test_assert_normal_exit() [](#method-i-test_assert_normal_exit) - -## test_assign_named_capture() [](#method-i-test_assign_named_capture) - -## test_assign_named_capture_to_const() [](#method-i-test_assign_named_capture_to_const) - -## test_assign_named_capture_to_reserved_word() [](#method-i-test_assign_named_capture_to_reserved_word) - -## test_assign_named_capture_trace() [](#method-i-test_assign_named_capture_trace) - -## test_backref_overrun() [](#method-i-test_backref_overrun) - -## test_backward() [](#method-i-test_backward) - -## test_bug18631() [](#method-i-test_bug18631) - -## test_bug_19273() [](#method-i-test_bug_19273) -Bug #19273 -: - -## test_bug_19467() [](#method-i-test_bug_19467) -Bug #19467 -: - -## test_bug_19476() [](#method-i-test_bug_19476) -Bug #19476 -: - -## test_bug_19537() [](#method-i-test_bug_19537) -Bug #19537 -: - -## test_bug_20083() [](#method-i-test_bug_20083) -Bug #20083 -: - -## test_bug_20098() [](#method-i-test_bug_20098) -Bug #20098 -: - -## test_bug_20207() [](#method-i-test_bug_20207) -Bug #20207 -: - -## test_bug_20212() [](#method-i-test_bug_20212) -Bug #20212 -: - -## test_bug_20246() [](#method-i-test_bug_20246) -Bug #20246 -: - -## test_bug_20453() [](#method-i-test_bug_20453) - -## test_bug_20886() [](#method-i-test_bug_20886) - -## test_cache_opcodes_initialize() [](#method-i-test_cache_opcodes_initialize) - -## test_casefold_p() [](#method-i-test_casefold_p) - -## test_cclass_R() [](#method-i-test_cclass_R) - -## test_cclass_X() [](#method-i-test_cclass_X) - -## test_char_class() [](#method-i-test_char_class) - -## test_char_to_option() [](#method-i-test_char_to_option) - -## test_char_to_option_kcode() [](#method-i-test_char_to_option_kcode) - -## test_char_type() [](#method-i-test_char_type) - -## test_conditional_expression() [](#method-i-test_conditional_expression) - -## test_dup() [](#method-i-test_dup) - -## test_dup_warn() [](#method-i-test_dup_warn) - -## test_encoding_flags_are_preserved_when_initialized_with_another_regexp() [](#method-i-test_encoding_flags_are_preserved_when_initialized_with_another_regexp) - -## test_eq_tilde_can_be_overridden() [](#method-i-test_eq_tilde_can_be_overridden) - -## test_eqq() [](#method-i-test_eqq) - -## test_equal() [](#method-i-test_equal) - -## test_error_message_on_failed_conversion() [](#method-i-test_error_message_on_failed_conversion) - -## test_exec() [](#method-i-test_exec) - -## test_extended_comment_invalid_escape_bug_18294() [](#method-i-test_extended_comment_invalid_escape_bug_18294) - -## test_getter() [](#method-i-test_getter) - -## test_has_NOENCODING() [](#method-i-test_has_NOENCODING) - -## test_ignorecase() [](#method-i-test_ignorecase) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_bool_warning() [](#method-i-test_initialize_bool_warning) - -## test_initialize_from_regex_memory_corruption() [](#method-i-test_initialize_from_regex_memory_corruption) - -## test_initialize_option() [](#method-i-test_initialize_option) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect_under_gc_compact_stress() [](#method-i-test_inspect_under_gc_compact_stress) - -## test_invalid_escape_error() [](#method-i-test_invalid_escape_error) - -## test_invalid_fragment() [](#method-i-test_invalid_fragment) - -## test_invalid_free_at_parse_depth_limit_over() [](#method-i-test_invalid_free_at_parse_depth_limit_over) - -## test_invalid_group() [](#method-i-test_invalid_group) - -## test_last_match() [](#method-i-test_last_match) - -## test_linear_performance() [](#method-i-test_linear_performance) - -## test_linear_time_p() [](#method-i-test_linear_time_p) - -## test_match() [](#method-i-test_match) - -## test_match_aref() [](#method-i-test_match_aref) - -## test_match_array() [](#method-i-test_match_array) - -## test_match_byteoffset_begin_end() [](#method-i-test_match_byteoffset_begin_end) - -## test_match_cache_atomic() [](#method-i-test_match_cache_atomic) - -## test_match_cache_atomic_complex() [](#method-i-test_match_cache_atomic_complex) - -## test_match_cache_exponential() [](#method-i-test_match_cache_exponential) - -## test_match_cache_negative_look_ahead() [](#method-i-test_match_cache_negative_look_ahead) - -## test_match_cache_negative_look_behind() [](#method-i-test_match_cache_negative_look_behind) - -## test_match_cache_positive_look_ahead() [](#method-i-test_match_cache_positive_look_ahead) - -## test_match_cache_positive_look_ahead_complex() [](#method-i-test_match_cache_positive_look_ahead_complex) - -## test_match_cache_positive_look_behind() [](#method-i-test_match_cache_positive_look_behind) - -## test_match_cache_square() [](#method-i-test_match_cache_square) - -## test_match_cache_with_peek_optimization() [](#method-i-test_match_cache_with_peek_optimization) - -## test_match_captures() [](#method-i-test_match_captures) - -## test_match_control_meta_escape() [](#method-i-test_match_control_meta_escape) - -## test_match_data_deconstruct() [](#method-i-test_match_data_deconstruct) - -## test_match_data_deconstruct_keys() [](#method-i-test_match_data_deconstruct_keys) - -## test_match_data_named_captures() [](#method-i-test_match_data_named_captures) - -## test_match_init_copy() [](#method-i-test_match_init_copy) - -## test_match_inspect() [](#method-i-test_match_inspect) - -## test_match_lambda_multithread() [](#method-i-test_match_lambda_multithread) - -## test_match_match_length() [](#method-i-test_match_match_length) - -## test_match_matchsubstring() [](#method-i-test_match_matchsubstring) - -## test_match_no_match_no_matchdata() [](#method-i-test_match_no_match_no_matchdata) - -## test_match_offset_begin_end() [](#method-i-test_match_offset_begin_end) - -## test_match_p() [](#method-i-test_match_p) - -## test_match_pre_post() [](#method-i-test_match_pre_post) - -## test_match_regexp() [](#method-i-test_match_regexp) - -## test_match_setter() [](#method-i-test_match_setter) - -## test_match_size() [](#method-i-test_match_size) - -## test_match_string() [](#method-i-test_match_string) - -## test_match_to_s() [](#method-i-test_match_to_s) - -## test_match_under_gc_compact_stress() [](#method-i-test_match_under_gc_compact_stress) - -## test_match_values_at() [](#method-i-test_match_values_at) - -## test_match_without_regexp() [](#method-i-test_match_without_regexp) - -## test_matchdata() [](#method-i-test_matchdata) - -## test_named_capture() [](#method-i-test_named_capture) - -## test_named_capture_nonascii() [](#method-i-test_named_capture_nonascii) - -## test_named_capture_with_nul() [](#method-i-test_named_capture_with_nul) - -## test_nonextended_section_of_extended_regexp_bug_19379() [](#method-i-test_nonextended_section_of_extended_regexp_bug_19379) - -## test_once() [](#method-i-test_once) - -## test_once_escape() [](#method-i-test_once_escape) - -## test_once_multithread() [](#method-i-test_once_multithread) - -## test_once_recursive() [](#method-i-test_once_recursive) - -## test_options() [](#method-i-test_options) - -## test_options_in_look_behind() [](#method-i-test_options_in_look_behind) - -## test_parse() [](#method-i-test_parse) - -## test_parse_comment() [](#method-i-test_parse_comment) - -## test_parse_curly_brace() [](#method-i-test_parse_curly_brace) - -## test_parse_kg() [](#method-i-test_parse_kg) - -## test_parse_look_behind() [](#method-i-test_parse_look_behind) - -## test_posix_bracket() [](#method-i-test_posix_bracket) - -## test_premature_end_char_property() [](#method-i-test_premature_end_char_property) - -## test_property_warn() [](#method-i-test_property_warn) - -## test_quantifier_reduction() [](#method-i-test_quantifier_reduction) - -## test_quote() [](#method-i-test_quote) - -## test_raw_hyphen_and_tk_char_type_after_range() [](#method-i-test_raw_hyphen_and_tk_char_type_after_range) - -## test_regexp_popped() [](#method-i-test_regexp_popped) - -## test_regsub() [](#method-i-test_regsub) - -## test_regsub_K() [](#method-i-test_regsub_K) - -## test_rindex_regexp() [](#method-i-test_rindex_regexp) - -## test_ruby_core_27247() [](#method-i-test_ruby_core_27247) - -## test_ruby_dev_24643() [](#method-i-test_ruby_dev_24643) - -## test_ruby_dev_24887() [](#method-i-test_ruby_dev_24887) - -## test_ruby_dev_31309() [](#method-i-test_ruby_dev_31309) - -## test_ruby_dev_999() [](#method-i-test_ruby_dev_999) - -## test_ruby_talk_116455() [](#method-i-test_ruby_talk_116455) - -## test_s_timeout() [](#method-i-test_s_timeout) - -## test_s_timeout_corner_cases() [](#method-i-test_s_timeout_corner_cases) - -## test_s_timeout_memory_leak() [](#method-i-test_s_timeout_memory_leak) - -## test_source() [](#method-i-test_source) - -## test_source_escaped() [](#method-i-test_source_escaped) - -## test_source_escaped_paren() [](#method-i-test_source_escaped_paren) - -## test_source_unescaped() [](#method-i-test_source_unescaped) - -## test_timeout_corner_cases() [](#method-i-test_timeout_corner_cases) - -## test_timeout_longer_than_global() [](#method-i-test_timeout_longer_than_global) - -## test_timeout_memory_leak() [](#method-i-test_timeout_memory_leak) - -## test_timeout_nil() [](#method-i-test_timeout_nil) - -## test_timeout_shorter_than_global() [](#method-i-test_timeout_shorter_than_global) - -## test_to_s() [](#method-i-test_to_s) - -## test_to_s2() [](#method-i-test_to_s2) - -## test_to_s_extended_subexp() [](#method-i-test_to_s_extended_subexp) - -## test_to_s_under_gc_compact_stress() [](#method-i-test_to_s_under_gc_compact_stress) - -## test_try_convert() [](#method-i-test_try_convert) - -## test_unescape() [](#method-i-test_unescape) - -## test_unicode() [](#method-i-test_unicode) - -## test_unicode_age() [](#method-i-test_unicode_age) - -## test_unicode_age_14_0() [](#method-i-test_unicode_age_14_0) - -## test_unicode_age_15_0() [](#method-i-test_unicode_age_15_0) - -## test_uninitialized() [](#method-i-test_uninitialized) - -## test_union() [](#method-i-test_union) - -## test_union2() [](#method-i-test_union2) - -## test_utf8_comment_in_usascii_extended_regexp_bug_19455() [](#method-i-test_utf8_comment_in_usascii_extended_regexp_bug_19455) - -## test_word_boundary() [](#method-i-test_word_boundary) - diff --git a/example/ruby/TestRequire.md b/example/ruby/TestRequire.md deleted file mode 100644 index 3dc53fc..0000000 --- a/example/ruby/TestRequire.md +++ /dev/null @@ -1,120 +0,0 @@ -# Class: TestRequire -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_require_nonascii_path(encoding, bug) [](#method-i-assert_require_nonascii_path) - -## assert_require_with_shared_array_modified(add, del) [](#method-i-assert_require_with_shared_array_modified) - -## assert_syntax_error_backtrace() [](#method-i-assert_syntax_error_backtrace) - -## prepare_require_path(dir, encoding) [](#method-i-prepare_require_path) - -## test_default_loaded_features_encoding() [](#method-i-test_default_loaded_features_encoding) - -## test_define_class() [](#method-i-test_define_class) - -## test_define_class_under() [](#method-i-test_define_class_under) - -## test_define_module() [](#method-i-test_define_module) - -## test_define_module_under() [](#method-i-test_define_module_under) - -## test_frozen_loaded_features() [](#method-i-test_frozen_loaded_features) - -## test_load() [](#method-i-test_load) - -## test_load_error_path() [](#method-i-test_load_error_path) - -## test_load_into_module() [](#method-i-test_load_into_module) - -## test_load_ospath() [](#method-i-test_load_ospath) - -## test_load_scope() [](#method-i-test_load_scope) - -## test_load_syntax_error() [](#method-i-test_load_syntax_error) - -## test_load_wrap_nil() [](#method-i-test_load_wrap_nil) - -## test_loaded_features_encoding() [](#method-i-test_loaded_features_encoding) - -## test_loading_fifo_fd_leak() [](#method-i-test_loading_fifo_fd_leak) - -## test_loading_fifo_threading_raise() [](#method-i-test_loading_fifo_threading_raise) - -## test_loading_fifo_threading_success() [](#method-i-test_loading_fifo_threading_success) - -## test_private_in_wrapped_load() [](#method-i-test_private_in_wrapped_load) - -## test_provide_in_required_file() [](#method-i-test_provide_in_required_file) - -## test_public_in_wrapped_load() [](#method-i-test_public_in_wrapped_load) - -## test_race_exception() [](#method-i-test_race_exception) - -## test_relative() [](#method-i-test_relative) - -## test_relative_symlink() [](#method-i-test_relative_symlink) - -## test_relative_symlink_realpath() [](#method-i-test_relative_symlink_realpath) - -## test_require_changed_current_dir() [](#method-i-test_require_changed_current_dir) - -## test_require_changed_home() [](#method-i-test_require_changed_home) - -## test_require_in_wrapped_load() [](#method-i-test_require_in_wrapped_load) - -## test_require_invalid_shared_object() [](#method-i-test_require_invalid_shared_object) - -## test_require_local_var_on_toplevel() [](#method-i-test_require_local_var_on_toplevel) - -## test_require_nonascii() [](#method-i-test_require_nonascii) - -## test_require_nonascii_path() [](#method-i-test_require_nonascii_path) - -## test_require_nonascii_path_shift_jis() [](#method-i-test_require_nonascii_path_shift_jis) - -## test_require_nonascii_path_utf8() [](#method-i-test_require_nonascii_path_utf8) - -## test_require_not_modified_load_path() [](#method-i-test_require_not_modified_load_path) - -## test_require_path_home_1() [](#method-i-test_require_path_home_1) - -## test_require_path_home_2() [](#method-i-test_require_path_home_2) - -## test_require_path_home_3() [](#method-i-test_require_path_home_3) - -## test_require_syntax_error() [](#method-i-test_require_syntax_error) - -## test_require_syntax_error_rescued() [](#method-i-test_require_syntax_error_rescued) - -## test_require_to_path_redefined_in_load_path() [](#method-i-test_require_to_path_redefined_in_load_path) - -## test_require_to_str_redefined_in_load_path() [](#method-i-test_require_to_str_redefined_in_load_path) - -## test_require_too_long_filename() [](#method-i-test_require_too_long_filename) - -## test_require_twice() [](#method-i-test_require_twice) - -## test_require_with_array_pop() [](#method-i-test_require_with_array_pop) - -## test_require_with_array_shift() [](#method-i-test_require_with_array_shift) - -## test_require_with_loaded_features_pop() [](#method-i-test_require_with_loaded_features_pop) - -## test_require_with_public_method_missing() [](#method-i-test_require_with_public_method_missing) - -## test_require_with_unc() [](#method-i-test_require_with_unc) - -## test_resolve_feature_path() [](#method-i-test_resolve_feature_path) - -## test_resolve_feature_path_with_missing_feature() [](#method-i-test_resolve_feature_path_with_missing_feature) - -## test_symlink_load_path() [](#method-i-test_symlink_load_path) - -## test_throw_while_loading() [](#method-i-test_throw_while_loading) - diff --git a/example/ruby/TestRequireLib.md b/example/ruby/TestRequireLib.md deleted file mode 100644 index 06abb93..0000000 --- a/example/ruby/TestRequireLib.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRequireLib -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/TestResolvAddr.md b/example/ruby/TestResolvAddr.md deleted file mode 100644 index 07180df..0000000 --- a/example/ruby/TestResolvAddr.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestResolvAddr -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_hosts_by_command() [](#method-i-test_hosts_by_command) - -## test_invalid_byte_comment() [](#method-i-test_invalid_byte_comment) - -## test_invalid_ipv4_address() [](#method-i-test_invalid_ipv4_address) - -## test_valid_ipv6_link_local_address() [](#method-i-test_valid_ipv6_link_local_address) - -## test_valid_socket_ip_address_list() [](#method-i-test_valid_socket_ip_address_list) - diff --git a/example/ruby/TestResolvDNS.md b/example/ruby/TestResolvDNS.md deleted file mode 100644 index 950c48e..0000000 --- a/example/ruby/TestResolvDNS.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: TestResolvDNS -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_no_fd_leak() [](#method-i-assert_no_fd_leak) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_case_insensitive_name() [](#method-i-test_case_insensitive_name) - -## test_dots_diffences() [](#method-i-test_dots_diffences) - -## test_each_name() [](#method-i-test_each_name) - -## test_invalid_byte_comment() [](#method-i-test_invalid_byte_comment) - -## test_ipv6_create() [](#method-i-test_ipv6_create) - -## test_ipv6_name() [](#method-i-test_ipv6_name) - -## test_ipv6_should_be_16() [](#method-i-test_ipv6_should_be_16) - -## test_ipv6_to_s() [](#method-i-test_ipv6_to_s) - -## test_multiple_servers_with_timeout_and_truncated_tcp_fallback() [](#method-i-test_multiple_servers_with_timeout_and_truncated_tcp_fallback) - -## test_no_fd_leak_connected() [](#method-i-test_no_fd_leak_connected) - -## test_no_fd_leak_unconnected() [](#method-i-test_no_fd_leak_unconnected) - -## test_no_server() [](#method-i-test_no_server) - -## test_query_ipv4_address() [](#method-i-test_query_ipv4_address) - -## test_query_ipv4_address_timeout() [](#method-i-test_query_ipv4_address_timeout) - -## test_query_ipv4_address_truncated_tcp_fallback() [](#method-i-test_query_ipv4_address_truncated_tcp_fallback) - -## test_query_ipv4_duplicate_responses() [](#method-i-test_query_ipv4_duplicate_responses) - -## test_resolv_conf_by_command() [](#method-i-test_resolv_conf_by_command) - -## test_resolve_with_2_ndots() [](#method-i-test_resolve_with_2_ndots) -ruby-core:65836 -: - -## test_too_big_label_address() [](#method-i-test_too_big_label_address) - -## test_unreachable_server() [](#method-i-test_unreachable_server) - -## with_tcp(host, port) [](#method-i-with_tcp) - -## with_udp(host, port) [](#method-i-with_udp) - -## with_udp_and_tcp(host, port) [](#method-i-with_udp_and_tcp) - diff --git a/example/ruby/TestResolvMDNS.md b/example/ruby/TestResolvMDNS.md deleted file mode 100644 index c6e8d60..0000000 --- a/example/ruby/TestResolvMDNS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestResolvMDNS -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_mdns_each_address() [](#method-i-test_mdns_each_address) - diff --git a/example/ruby/TestResolvResource.md b/example/ruby/TestResolvResource.md deleted file mode 100644 index 5b376ba..0000000 --- a/example/ruby/TestResolvResource.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestResolvResource -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_coord() [](#method-i-test_coord) - -## test_equality() [](#method-i-test_equality) - -## test_hash() [](#method-i-test_hash) - -## test_srv_no_compress() [](#method-i-test_srv_no_compress) - diff --git a/example/ruby/TestResolvResourceCAA.md b/example/ruby/TestResolvResourceCAA.md deleted file mode 100644 index 7f8c9b6..0000000 --- a/example/ruby/TestResolvResourceCAA.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestResolvResourceCAA -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_caa_flags() [](#method-i-test_caa_flags) - -## test_caa_roundtrip() [](#method-i-test_caa_roundtrip) - -## test_caa_stackoverflow() [](#method-i-test_caa_stackoverflow) - -## test_caa_tag() [](#method-i-test_caa_tag) - diff --git a/example/ruby/TestResolvSvcbHttps.md b/example/ruby/TestResolvSvcbHttps.md deleted file mode 100644 index a15c4af..0000000 --- a/example/ruby/TestResolvSvcbHttps.md +++ /dev/null @@ -1,37 +0,0 @@ -# Class: TestResolvSvcbHttps -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_alias_mode() [](#method-i-test_alias_mode) -Test vectors from [RFC9460] - -## test_alpn_comma_backslash() [](#method-i-test_alpn_comma_backslash) - -## test_dohpath() [](#method-i-test_dohpath) -For [RFC9461] - -## test_generic_key() [](#method-i-test_generic_key) - -## test_ipv6hint_embedded_ipv4() [](#method-i-test_ipv6hint_embedded_ipv4) - -## test_mandatory_alpn_ipv4hint() [](#method-i-test_mandatory_alpn_ipv4hint) - -## test_specifies_port() [](#method-i-test_specifies_port) - -## test_svcb() [](#method-i-test_svcb) - -## test_svcb_encode_order() [](#method-i-test_svcb_encode_order) - -## test_svcparams() [](#method-i-test_svcparams) - -## test_target_name_is_root() [](#method-i-test_target_name_is_root) - -## test_two_ipv6hints() [](#method-i-test_two_ipv6hints) - -## wrap_rdata(rrtype, rrclass, rdata) [](#method-i-wrap_rdata) -Wraps a RR in answer section - diff --git a/example/ruby/TestRipper.md b/example/ruby/TestRipper.md deleted file mode 100644 index 1df7d2a..0000000 --- a/example/ruby/TestRipper.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRipper - - - - - diff --git a/example/ruby/TestRipper/DummyParser.md b/example/ruby/TestRipper/DummyParser.md deleted file mode 100644 index 3e7610e..0000000 --- a/example/ruby/TestRipper/DummyParser.md +++ /dev/null @@ -1,96 +0,0 @@ -# Class: TestRipper::DummyParser -**Inherits:** Ripper - - - - - -#Instance Methods -## hook(*names) [](#method-i-hook) - -## on_alias_error(mesgnil, a) [](#method-i-on_alias_error) - -## on_arg_paren(args) [](#method-i-on_arg_paren) - -## on_args_add(list, arg) [](#method-i-on_args_add) - -## on_args_add_block(list, blk) [](#method-i-on_args_add_block) - -## on_args_add_star(list, arg) [](#method-i-on_args_add_star) - -## on_args_new() [](#method-i-on_args_new) - -## on_args_prepend(list, args) [](#method-i-on_args_prepend) - -## on_assign_error(mesgnil, a) [](#method-i-on_assign_error) - -## on_assoc_new(a, b) [](#method-i-on_assoc_new) - -## on_assoclist_from_args(a) [](#method-i-on_assoclist_from_args) - -## on_bare_assoc_hash(assoc_list) [](#method-i-on_bare_assoc_hash) - -## on_block_var(params, shadow) [](#method-i-on_block_var) - -## on_blockarg(var) [](#method-i-on_blockarg) - -## on_brace_block(params, code) [](#method-i-on_brace_block) - -## on_kwrest_param(var) [](#method-i-on_kwrest_param) - -## on_method_add_arg(m, arg) [](#method-i-on_method_add_arg) - -## on_method_add_block(m, b) [](#method-i-on_method_add_block) - -## on_mlhs_add(list, node) [](#method-i-on_mlhs_add) - -## on_mlhs_add_block(list, blk) [](#method-i-on_mlhs_add_block) - -## on_mlhs_add_post(list, post) [](#method-i-on_mlhs_add_post) - -## on_mlhs_add_star(list, arg) [](#method-i-on_mlhs_add_star) - -## on_mlhs_new() [](#method-i-on_mlhs_new) - -## on_mlhs_paren(list) [](#method-i-on_mlhs_paren) - -## on_params(required, optional, rest, more, keyword, keyword_rest, block) [](#method-i-on_params) - -## on_paren(params) [](#method-i-on_paren) - -## on_program(stmts) [](#method-i-on_program) - -## on_qsymbols_add(symbols, symbol) [](#method-i-on_qsymbols_add) - -## on_qsymbols_new() [](#method-i-on_qsymbols_new) - -## on_qwords_add(words, word) [](#method-i-on_qwords_add) - -## on_qwords_new() [](#method-i-on_qwords_new) - -## on_rescue(exc, *rest) [](#method-i-on_rescue) - -## on_rest_param(var) [](#method-i-on_rest_param) - -## on_stmts_add(stmts, st) [](#method-i-on_stmts_add) - -## on_stmts_new() [](#method-i-on_stmts_new) - -## on_symbols_add(symbols, symbol) [](#method-i-on_symbols_add) - -## on_symbols_new() [](#method-i-on_symbols_new) - -## on_var_alias(a, b) [](#method-i-on_var_alias) - -## on_var_ref(name) [](#method-i-on_var_ref) - -## on_void_stmt() [](#method-i-on_void_stmt) - -## on_word_add(word, w) [](#method-i-on_word_add) - -## on_word_new() [](#method-i-on_word_new) - -## on_words_add(words, word) [](#method-i-on_words_add) - -## on_words_new() [](#method-i-on_words_new) - diff --git a/example/ruby/TestRipper/Filter.md b/example/ruby/TestRipper/Filter.md deleted file mode 100644 index f86a358..0000000 --- a/example/ruby/TestRipper/Filter.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestRipper::Filter -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## filename() [](#method-i-filename) - -## test_filter_column() [](#method-i-test_filter_column) - -## test_filter_filename() [](#method-i-test_filter_filename) - -## test_filter_filename_unset() [](#method-i-test_filter_filename_unset) - -## test_filter_lineno() [](#method-i-test_filter_lineno) - -## test_filter_lineno_set() [](#method-i-test_filter_lineno_set) - -## test_filter_state() [](#method-i-test_filter_state) - -## test_filter_token() [](#method-i-test_filter_token) - diff --git a/example/ruby/TestRipper/Filter/Filter.md b/example/ruby/TestRipper/Filter/Filter.md deleted file mode 100644 index c5f292b..0000000 --- a/example/ruby/TestRipper/Filter/Filter.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRipper::Filter::Filter -**Inherits:** Ripper::Filter - - - - - -#Instance Methods -## on_default(event, token, data) [](#method-i-on_default) - diff --git a/example/ruby/TestRipper/Generic.md b/example/ruby/TestRipper/Generic.md deleted file mode 100644 index fd5e87a..0000000 --- a/example/ruby/TestRipper/Generic.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRipper::Generic -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_parse_files(dir, pattern"**/*.rb", exclude:nil, gc_stress:GC.stress, test_ratio:nil) [](#method-i-assert_parse_files) - diff --git a/example/ruby/TestRipper/Lexer.md b/example/ruby/TestRipper/Lexer.md deleted file mode 100644 index 70b64bb..0000000 --- a/example/ruby/TestRipper/Lexer.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: TestRipper::Lexer -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_lexer(expected, code) [](#method-i-assert_lexer) - -## state(name) [](#method-i-state) - -## test_embedded_expr_in_heredoc() [](#method-i-test_embedded_expr_in_heredoc) - -## test_end_of_script_char() [](#method-i-test_end_of_script_char) - -## test_expr_at_beginning_in_heredoc() [](#method-i-test_expr_at_beginning_in_heredoc) - -## test_heredoc_inside_block_param() [](#method-i-test_heredoc_inside_block_param) - -## test_heredoc_no_memory_leak() [](#method-i-test_heredoc_no_memory_leak) - -## test_heredoc_unterminated_interpolation() [](#method-i-test_heredoc_unterminated_interpolation) - -## test_invalid_escape_ctrl_mbchar() [](#method-i-test_invalid_escape_ctrl_mbchar) - -## test_invalid_escape_ctrl_meta_mbchar() [](#method-i-test_invalid_escape_ctrl_meta_mbchar) - -## test_invalid_escape_meta_ctrl_mbchar() [](#method-i-test_invalid_escape_meta_ctrl_mbchar) - -## test_invalid_escape_meta_mbchar() [](#method-i-test_invalid_escape_meta_mbchar) - -## test_invalid_escape_string() [](#method-i-test_invalid_escape_string) - -## test_lex_with_syntax_error() [](#method-i-test_lex_with_syntax_error) - -## test_lex_with_syntax_error_and_heredoc() [](#method-i-test_lex_with_syntax_error_and_heredoc) - -## test_lexer_scan_with_syntax_error() [](#method-i-test_lexer_scan_with_syntax_error) - -## test_nested_dedent_heredoc() [](#method-i-test_nested_dedent_heredoc) - -## test_nested_heredoc() [](#method-i-test_nested_heredoc) - -## test_raise_errors_keyword() [](#method-i-test_raise_errors_keyword) - -## test_slice() [](#method-i-test_slice) - -## test_space_after_expr_in_heredoc() [](#method-i-test_space_after_expr_in_heredoc) - -## test_spaces_at_eof() [](#method-i-test_spaces_at_eof) - -## test_stack_at_on_heredoc_beg() [](#method-i-test_stack_at_on_heredoc_beg) - -## test_state_after_cvar() [](#method-i-test_state_after_cvar) - -## test_state_after_ivar() [](#method-i-test_state_after_ivar) - -## test_token_aftr_error_heredoc() [](#method-i-test_token_aftr_error_heredoc) - -## test_tokenize_with_here_document() [](#method-i-test_tokenize_with_here_document) - -## test_tokenize_with_syntax_error() [](#method-i-test_tokenize_with_syntax_error) - -## test_trailing_on_embexpr_end() [](#method-i-test_trailing_on_embexpr_end) - diff --git a/example/ruby/TestRipper/Node.md b/example/ruby/TestRipper/Node.md deleted file mode 100644 index 264fe5e..0000000 --- a/example/ruby/TestRipper/Node.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: TestRipper::Node -**Inherits:** Object - - - - -# Class Methods -## trim_nil(list ) [](#method-c-trim_nil) -# Attributes -## children[RW] [](#attribute-i-children) -Returns the value of attribute children. - -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## initialize(name, *nodes) [](#method-i-initialize) - -**@return** [Node] a new instance of Node - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/TestRipper/Node/Sym.md b/example/ruby/TestRipper/Node/Sym.md deleted file mode 100644 index 77b64a6..0000000 --- a/example/ruby/TestRipper/Node/Sym.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestRipper::Node::Sym -**Inherits:** TestRipper::Node - - - - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [Sym] a new instance of Sym - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/TestRipper/NodeList.md b/example/ruby/TestRipper/NodeList.md deleted file mode 100644 index 05c3068..0000000 --- a/example/ruby/TestRipper/NodeList.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestRipper::NodeList -**Inherits:** Object - - - - -# Attributes -## list[RW] [](#attribute-i-list) -Returns the value of attribute list. - - -#Instance Methods -## concat(item) [](#method-i-concat) - -## initialize(list[]) [](#method-i-initialize) - -**@return** [NodeList] a new instance of NodeList - -## prepend(items) [](#method-i-prepend) - -## push(item) [](#method-i-push) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/TestRipper/ParserEvents.md b/example/ruby/TestRipper/ParserEvents.md deleted file mode 100644 index 4b25005..0000000 --- a/example/ruby/TestRipper/ParserEvents.md +++ /dev/null @@ -1,372 +0,0 @@ -# Class: TestRipper::ParserEvents -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## compile_error(str) [](#method-i-compile_error) - -## parse(str, nmnil, &bl) [](#method-i-parse) - -## test_BEGIN() [](#method-i-test_BEGIN) - -## test_END() [](#method-i-test_END) - -## test_alias() [](#method-i-test_alias) - -## test_alias_error() [](#method-i-test_alias_error) - -## test_anonymous_block_forwarding() [](#method-i-test_anonymous_block_forwarding) - -## test_anonymous_keyword_rest_forwarding() [](#method-i-test_anonymous_keyword_rest_forwarding) - -## test_anonymous_rest_forwarding() [](#method-i-test_anonymous_rest_forwarding) - -## test_aref() [](#method-i-test_aref) - -## test_aref_field() [](#method-i-test_aref_field) - -## test_arg_ambiguous() [](#method-i-test_arg_ambiguous) - -## test_arg_paren() [](#method-i-test_arg_paren) - -## test_arglist() [](#method-i-test_arglist) - -## test_args_add() [](#method-i-test_args_add) - -## test_args_add_block() [](#method-i-test_args_add_block) - -## test_args_add_star() [](#method-i-test_args_add_star) - -## test_args_forward() [](#method-i-test_args_forward) - -## test_args_new() [](#method-i-test_args_new) - -## test_array() [](#method-i-test_array) -array literal - -## test_aryptn() [](#method-i-test_aryptn) - -## test_assign() [](#method-i-test_assign) -generic assignment - -## test_assign_error() [](#method-i-test_assign_error) - -## test_assign_error_backref() [](#method-i-test_assign_error_backref) - -## test_assign_error_const() [](#method-i-test_assign_error_const) - -## test_assign_error_const_qualified() [](#method-i-test_assign_error_const_qualified) - -## test_assign_error_const_toplevel() [](#method-i-test_assign_error_const_toplevel) - -## test_assoc_new() [](#method-i-test_assoc_new) - -## test_assoc_splat() [](#method-i-test_assoc_splat) - -## test_assoclist_from_args() [](#method-i-test_assoclist_from_args) - -## test_assocs() [](#method-i-test_assocs) - -## test_bare_assoc_hash() [](#method-i-test_bare_assoc_hash) - -## test_begin() [](#method-i-test_begin) - -## test_block_var() [](#method-i-test_block_var) - -## test_block_var_add_block() [](#method-i-test_block_var_add_block) - -## test_block_var_add_star() [](#method-i-test_block_var_add_star) - -## test_block_variables() [](#method-i-test_block_variables) - -## test_blockarg() [](#method-i-test_blockarg) - -## test_bodystmt() [](#method-i-test_bodystmt) - -## test_brace_block() [](#method-i-test_brace_block) - -## test_break() [](#method-i-test_break) - -## test_call() [](#method-i-test_call) - -## test_call_colon2() [](#method-i-test_call_colon2) - -## test_case() [](#method-i-test_case) - -## test_class() [](#method-i-test_class) - -## test_class_name_error() [](#method-i-test_class_name_error) - -## test_command() [](#method-i-test_command) - -## test_command_call() [](#method-i-test_command_call) - -## test_const_path_field() [](#method-i-test_const_path_field) - -## test_const_path_ref() [](#method-i-test_const_path_ref) - -## test_const_ref() [](#method-i-test_const_ref) - -## test_def() [](#method-i-test_def) - -## test_defined() [](#method-i-test_defined) - -## test_defs() [](#method-i-test_defs) - -## test_do_block() [](#method-i-test_do_block) - -## test_dot2() [](#method-i-test_dot2) - -## test_dot3() [](#method-i-test_dot3) - -## test_dyna_symbol() [](#method-i-test_dyna_symbol) - -## test_else() [](#method-i-test_else) - -## test_elsif() [](#method-i-test_elsif) - -## test_endless_def() [](#method-i-test_endless_def) - -## test_endless_defs() [](#method-i-test_endless_defs) - -## test_ensure() [](#method-i-test_ensure) - -## test_event_coverage() [](#method-i-test_event_coverage) - -## test_excessed_comma() [](#method-i-test_excessed_comma) - -## test_fcall() [](#method-i-test_fcall) - -## test_field() [](#method-i-test_field) - -## test_fndptn() [](#method-i-test_fndptn) - -## test_for() [](#method-i-test_for) - -## test_hash() [](#method-i-test_hash) - -## test_heredoc() [](#method-i-test_heredoc) - -## test_heredoc_dedent() [](#method-i-test_heredoc_dedent) - -## test_hshptn() [](#method-i-test_hshptn) - -## test_if() [](#method-i-test_if) - -## test_if_mod() [](#method-i-test_if_mod) - -## test_ifop() [](#method-i-test_ifop) - -## test_ignored_nl() [](#method-i-test_ignored_nl) - -## test_in() [](#method-i-test_in) - -## test_invalid_class_variable_name() [](#method-i-test_invalid_class_variable_name) - -## test_invalid_global_variable_name() [](#method-i-test_invalid_global_variable_name) - -## test_invalid_instance_variable_name() [](#method-i-test_invalid_instance_variable_name) - -## test_kwrest_param() [](#method-i-test_kwrest_param) - -## test_lambda() [](#method-i-test_lambda) - -## test_local_variables() [](#method-i-test_local_variables) - -## test_magic_comment() [](#method-i-test_magic_comment) - -## test_massign() [](#method-i-test_massign) - -## test_method_add_arg() [](#method-i-test_method_add_arg) - -## test_method_add_block() [](#method-i-test_method_add_block) - -## test_mlhs_add() [](#method-i-test_mlhs_add) - -## test_mlhs_add_post() [](#method-i-test_mlhs_add_post) - -## test_mlhs_add_star() [](#method-i-test_mlhs_add_star) - -## test_mlhs_new() [](#method-i-test_mlhs_new) - -## test_mlhs_paren() [](#method-i-test_mlhs_paren) - -## test_module() [](#method-i-test_module) - -## test_mrhs_add() [](#method-i-test_mrhs_add) - -## test_mrhs_add_star() [](#method-i-test_mrhs_add_star) - -## test_mrhs_new() [](#method-i-test_mrhs_new) - -## test_mrhs_new_from_args() [](#method-i-test_mrhs_new_from_args) - -## test_next() [](#method-i-test_next) - -## test_nokw_param() [](#method-i-test_nokw_param) - -## test_opassign() [](#method-i-test_opassign) - -## test_opassign_error() [](#method-i-test_opassign_error) - -## test_operator_ambiguous() [](#method-i-test_operator_ambiguous) - -## test_param_error() [](#method-i-test_param_error) - -## test_params() [](#method-i-test_params) - -## test_params_mlhs() [](#method-i-test_params_mlhs) - -## test_params_mlhs_add() [](#method-i-test_params_mlhs_add) - -## test_params_mlhs_add_post() [](#method-i-test_params_mlhs_add_post) - -## test_params_mlhs_add_star() [](#method-i-test_params_mlhs_add_star) - -## test_params_mlhs_new() [](#method-i-test_params_mlhs_new) - -## test_params_mlhs_paren() [](#method-i-test_params_mlhs_paren) - -## test_paren() [](#method-i-test_paren) - -## test_parse_error() [](#method-i-test_parse_error) - -## test_program() [](#method-i-test_program) - -## test_qsymbols_add() [](#method-i-test_qsymbols_add) - -## test_qsymbols_new() [](#method-i-test_qsymbols_new) - -## test_qwords_add() [](#method-i-test_qwords_add) - -## test_qwords_new() [](#method-i-test_qwords_new) - -## test_redo() [](#method-i-test_redo) - -## test_regexp_add() [](#method-i-test_regexp_add) - -## test_regexp_literal() [](#method-i-test_regexp_literal) - -## test_regexp_new() [](#method-i-test_regexp_new) - -## test_rescue() [](#method-i-test_rescue) - -## test_rescue_class() [](#method-i-test_rescue_class) - -## test_rescue_mod() [](#method-i-test_rescue_mod) - -## test_rest_param() [](#method-i-test_rest_param) - -## test_retry() [](#method-i-test_retry) - -## test_return() [](#method-i-test_return) - -## test_return0() [](#method-i-test_return0) - -## test_return_out_of_compile_error_no_memory_leak() [](#method-i-test_return_out_of_compile_error_no_memory_leak) - -## test_return_out_of_warn_no_memory_leak() [](#method-i-test_return_out_of_warn_no_memory_leak) - -## test_sclass() [](#method-i-test_sclass) - -## test_stmts_add() [](#method-i-test_stmts_add) - -## test_stmts_new() [](#method-i-test_stmts_new) - -## test_string_add() [](#method-i-test_string_add) - -## test_string_concat() [](#method-i-test_string_concat) - -## test_string_content() [](#method-i-test_string_content) - -## test_string_dvar() [](#method-i-test_string_dvar) - -## test_string_embexpr() [](#method-i-test_string_embexpr) - -## test_string_literal() [](#method-i-test_string_literal) - -## test_super() [](#method-i-test_super) - -## test_symbol() [](#method-i-test_symbol) - -## test_symbol_literal() [](#method-i-test_symbol_literal) - -## test_symbols_add() [](#method-i-test_symbols_add) - -## test_symbols_new() [](#method-i-test_symbols_new) - -## test_top_const_field() [](#method-i-test_top_const_field) - -## test_top_const_ref() [](#method-i-test_top_const_ref) - -## test_unary() [](#method-i-test_unary) - -## test_undef() [](#method-i-test_undef) - -## test_unless() [](#method-i-test_unless) - -## test_unless_mod() [](#method-i-test_unless_mod) - -## test_unterminated_heredoc() [](#method-i-test_unterminated_heredoc) - -## test_unterminated_regexp() [](#method-i-test_unterminated_regexp) - -## test_until() [](#method-i-test_until) - -## test_until_mod() [](#method-i-test_until_mod) - -## test_var_alias() [](#method-i-test_var_alias) - -## test_var_field() [](#method-i-test_var_field) - -## test_var_ref() [](#method-i-test_var_ref) - -## test_vcall() [](#method-i-test_vcall) - -## test_void_stmt() [](#method-i-test_void_stmt) - -## test_warn_cr_in_middle() [](#method-i-test_warn_cr_in_middle) - -## test_warn_duplicated_hash_keys() [](#method-i-test_warn_duplicated_hash_keys) - -## test_warn_mismatched_indentations() [](#method-i-test_warn_mismatched_indentations) - -## test_warning_duplicated_when_clause() [](#method-i-test_warning_duplicated_when_clause) - -## test_warning_ignored_magic_comment() [](#method-i-test_warning_ignored_magic_comment) - -## test_warning_invalid_magic_comment() [](#method-i-test_warning_invalid_magic_comment) - -## test_when() [](#method-i-test_when) - -## test_while() [](#method-i-test_while) - -## test_while_mod() [](#method-i-test_while_mod) - -## test_word_add() [](#method-i-test_word_add) - -## test_word_new() [](#method-i-test_word_new) - -## test_words_add() [](#method-i-test_words_add) - -## test_words_new() [](#method-i-test_words_new) - -## test_xstring_add() [](#method-i-test_xstring_add) - -## test_xstring_literal() [](#method-i-test_xstring_literal) - -## test_xstring_new() [](#method-i-test_xstring_new) - -## test_yield() [](#method-i-test_yield) - -## test_yield0() [](#method-i-test_yield0) - -## test_zsuper() [](#method-i-test_zsuper) - -## warn(str) [](#method-i-warn) - -## warning(str) [](#method-i-warning) - diff --git a/example/ruby/TestRipper/Ripper.md b/example/ruby/TestRipper/Ripper.md deleted file mode 100644 index 5a1e957..0000000 --- a/example/ruby/TestRipper/Ripper.md +++ /dev/null @@ -1,47 +0,0 @@ -# Class: TestRipper::Ripper -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_assignable_in_regexp() [](#method-i-test_assignable_in_regexp) - -## test_column() [](#method-i-test_column) - -## test_dedent_string() [](#method-i-test_dedent_string) -https://bugs.jruby.org/4176 - -## test_encoding() [](#method-i-test_encoding) - -## test_end_seen_eh() [](#method-i-test_end_seen_eh) - -## test_filename() [](#method-i-test_filename) - -## test_lineno() [](#method-i-test_lineno) - -## test_new() [](#method-i-test_new) - -## test_no_memory_leak() [](#method-i-test_no_memory_leak) - -## test_parse() [](#method-i-test_parse) - -## test_regexp_enc_error() [](#method-i-test_regexp_enc_error) - -## test_regexp_with_option() [](#method-i-test_regexp_with_option) - -## test_sexp_no_memory_leak() [](#method-i-test_sexp_no_memory_leak) - -## test_state() [](#method-i-test_state) - -## test_yydebug() [](#method-i-test_yydebug) - -## test_yydebug_equals() [](#method-i-test_yydebug_equals) - -## test_yydebug_ident() [](#method-i-test_yydebug_ident) - -## test_yydebug_string() [](#method-i-test_yydebug_string) - diff --git a/example/ruby/TestRipper/Ripper/TestInput.md b/example/ruby/TestRipper/Ripper/TestInput.md deleted file mode 100644 index a8724df..0000000 --- a/example/ruby/TestRipper/Ripper/TestInput.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRipper::Ripper::TestInput -**Inherits:** TestRipper::Ripper - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_invalid_gets() [](#method-i-test_invalid_gets) - diff --git a/example/ruby/TestRipper/Ripper/TestInput/Input.md b/example/ruby/TestRipper/Ripper/TestInput/Input.md deleted file mode 100644 index 81af363..0000000 --- a/example/ruby/TestRipper/Ripper/TestInput/Input.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRipper::Ripper::TestInput::Input -**Inherits:** Struct - - - - -# Attributes -## lines[RW] [](#attribute-i-lines) -Returns the value of attribute lines - -**@return** [Object] the current value of lines - - -#Instance Methods -## gets() [](#method-i-gets) - diff --git a/example/ruby/TestRipper/ScannerEvents.md b/example/ruby/TestRipper/ScannerEvents.md deleted file mode 100644 index 9f3eaa9..0000000 --- a/example/ruby/TestRipper/ScannerEvents.md +++ /dev/null @@ -1,143 +0,0 @@ -# Class: TestRipper::ScannerEvents -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_lex(expected, *rest) [](#method-i-assert_lex) - -## assert_location(src) [](#method-i-assert_location) - -## scan(target, str, &error) [](#method-i-scan) - -## test_CHAR() [](#method-i-test_CHAR) - -## test___end__() [](#method-i-test___end__) - -## test_backref() [](#method-i-test_backref) - -## test_backtick() [](#method-i-test_backtick) - -## test_colon2_call() [](#method-i-test_colon2_call) - -## test_comma() [](#method-i-test_comma) - -## test_comment() [](#method-i-test_comment) - -## test_const() [](#method-i-test_const) - -## test_cvar() [](#method-i-test_cvar) - -## test_embdoc() [](#method-i-test_embdoc) - -## test_embdoc_beg() [](#method-i-test_embdoc_beg) - -## test_embdoc_end() [](#method-i-test_embdoc_end) - -## test_embexpr_beg() [](#method-i-test_embexpr_beg) - -## test_embexpr_end() [](#method-i-test_embexpr_end) - -## test_embvar() [](#method-i-test_embvar) - -## test_error_token() [](#method-i-test_error_token) - -## test_event_coverage() [](#method-i-test_event_coverage) - -## test_float() [](#method-i-test_float) - -## test_gvar() [](#method-i-test_gvar) - -## test_heredoc_beg() [](#method-i-test_heredoc_beg) - -## test_heredoc_end() [](#method-i-test_heredoc_end) - -## test_ident() [](#method-i-test_ident) - -## test_ignored_nl() [](#method-i-test_ignored_nl) - -## test_ignored_sp() [](#method-i-test_ignored_sp) - -## test_imaginary() [](#method-i-test_imaginary) - -## test_int() [](#method-i-test_int) - -## test_invalid_char() [](#method-i-test_invalid_char) - -## test_invalid_escape() [](#method-i-test_invalid_escape) - -## test_invalid_hex_escape_regexp() [](#method-i-test_invalid_hex_escape_regexp) - -## test_invalid_hex_escape_string() [](#method-i-test_invalid_hex_escape_string) - -## test_ivar() [](#method-i-test_ivar) - -## test_kw() [](#method-i-test_kw) - -## test_label() [](#method-i-test_label) - -## test_label_end() [](#method-i-test_label_end) - -## test_lbrace() [](#method-i-test_lbrace) - -## test_lbracket() [](#method-i-test_lbracket) - -## test_lex() [](#method-i-test_lex) - -## test_location() [](#method-i-test_location) - -## test_lparen() [](#method-i-test_lparen) - -## test_nl() [](#method-i-test_nl) -`nl' event always means End-Of-Statement. - -## test_op() [](#method-i-test_op) - -## test_period() [](#method-i-test_period) - -## test_qsymbols_beg() [](#method-i-test_qsymbols_beg) - -## test_qwords_beg() [](#method-i-test_qwords_beg) - -## test_rational() [](#method-i-test_rational) - -## test_rbrace() [](#method-i-test_rbrace) - -## test_rbracket() [](#method-i-test_rbracket) - -## test_regexp_beg() [](#method-i-test_regexp_beg) - -## test_regexp_end() [](#method-i-test_regexp_end) - -## test_rparen() [](#method-i-test_rparen) - -## test_semicolon() [](#method-i-test_semicolon) - -## test_sp() [](#method-i-test_sp) - -## test_symbeg() [](#method-i-test_symbeg) - -## test_symbols_beg() [](#method-i-test_symbols_beg) - -## test_tlambda() [](#method-i-test_tlambda) - -## test_tlambda_arg() [](#method-i-test_tlambda_arg) - -## test_tlambeg() [](#method-i-test_tlambeg) - -## test_tokenize() [](#method-i-test_tokenize) - -## test_tstring_beg() [](#method-i-test_tstring_beg) - -## test_tstring_content() [](#method-i-test_tstring_content) - -## test_tstring_content_HEREDOC() [](#method-i-test_tstring_content_HEREDOC) - -## test_tstring_end() [](#method-i-test_tstring_end) - -## test_words_beg() [](#method-i-test_words_beg) - -## test_words_sep() [](#method-i-test_words_sep) - diff --git a/example/ruby/TestRipper/Sexp.md b/example/ruby/TestRipper/Sexp.md deleted file mode 100644 index 7023cef..0000000 --- a/example/ruby/TestRipper/Sexp.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: TestRipper::Sexp -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## clear_pos(sexp) [](#method-i-clear_pos) - -## search_sexp(sym, sexp) [](#method-i-search_sexp) - -## test_command() [](#method-i-test_command) - -## test_compile_error() [](#method-i-test_compile_error) - -## test_def_fname() [](#method-i-test_def_fname) - -## test_defs_fname() [](#method-i-test_defs_fname) - -## test_dsym() [](#method-i-test_dsym) - -## test_hash_value_omission() [](#method-i-test_hash_value_omission) - -## test_heredoc_content() [](#method-i-test_heredoc_content) - -## test_hshptn() [](#method-i-test_hshptn) - -## test_named_with_default() [](#method-i-test_named_with_default) - -## test_params_mlhs() [](#method-i-test_params_mlhs) - -## test_raise_errors_keyword() [](#method-i-test_raise_errors_keyword) - -## test_regexp_content() [](#method-i-test_regexp_content) - -## test_regexp_named_capture() [](#method-i-test_regexp_named_capture) - -## test_squiggly_heredoc() [](#method-i-test_squiggly_heredoc) - -## test_squiggly_heredoc_with_interpolated_expression() [](#method-i-test_squiggly_heredoc_with_interpolated_expression) - diff --git a/example/ruby/TestRubyKaigi2023_F09FA5A2.md b/example/ruby/TestRubyKaigi2023_F09FA5A2.md deleted file mode 100644 index 8e6806d..0000000 --- a/example/ruby/TestRubyKaigi2023_F09FA5A2.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRubyKaigi2023🥢 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_chopsticks_0() [](#method-i-test_chopsticks_0) - -## test_chopsticks_0_1() [](#method-i-test_chopsticks_0_1) - -## test_chopsticks_1() [](#method-i-test_chopsticks_1) - -## test_chopsticks_1_0() [](#method-i-test_chopsticks_1_0) - diff --git a/example/ruby/TestRubyLiteral.md b/example/ruby/TestRubyLiteral.md deleted file mode 100644 index fae0a8c..0000000 --- a/example/ruby/TestRubyLiteral.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: TestRubyLiteral -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test__FILE__() [](#method-i-test__FILE__) - -## test__LINE__() [](#method-i-test__LINE__) - -## test_array() [](#method-i-test_array) - -## test_big_array_and_hash_literal() [](#method-i-test_big_array_and_hash_literal) - -## test_big_hash_literal() [](#method-i-test_big_hash_literal) - -## test_debug_frozen_string() [](#method-i-test_debug_frozen_string) - -## test_debug_frozen_string_in_array_literal() [](#method-i-test_debug_frozen_string_in_array_literal) - -## test_dregexp() [](#method-i-test_dregexp) - -## test_dstring() [](#method-i-test_dstring) - -## test_dstring_encoding() [](#method-i-test_dstring_encoding) - -## test_dsymbol() [](#method-i-test_dsymbol) - -## test_dsymbol_redefined_intern() [](#method-i-test_dsymbol_redefined_intern) - -## test_float() [](#method-i-test_float) - -## test_frozen_string() [](#method-i-test_frozen_string) - -## test_frozen_string_in_array_literal() [](#method-i-test_frozen_string_in_array_literal) - -## test_hash() [](#method-i-test_hash) - -## test_hash_duplicated_key() [](#method-i-test_hash_duplicated_key) - -## test_hash_frozen_key_id() [](#method-i-test_hash_frozen_key_id) - -## test_hash_key_tampering() [](#method-i-test_hash_key_tampering) - -## test_hash_literal_frozen() [](#method-i-test_hash_literal_frozen) - -## test_hash_value_omission() [](#method-i-test_hash_value_omission) - -## test_integer() [](#method-i-test_integer) - -## test_range() [](#method-i-test_range) - -## test_regexp() [](#method-i-test_regexp) - -## test_self() [](#method-i-test_self) - -## test_special_const() [](#method-i-test_special_const) - -## test_string() [](#method-i-test_string) - -## test_string_in_hash_literal() [](#method-i-test_string_in_hash_literal) - -## test_symbol_list() [](#method-i-test_symbol_list) - -## test_xstring() [](#method-i-test_xstring) - diff --git a/example/ruby/TestRubyOptimization.md b/example/ruby/TestRubyOptimization.md deleted file mode 100644 index b772afa..0000000 --- a/example/ruby/TestRubyOptimization.md +++ /dev/null @@ -1,214 +0,0 @@ -# Class: TestRubyOptimization -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## tailcall(klass , src , file nil, path nil, line nil, tailcall: true) [](#method-c-tailcall) - -#Instance Methods -## assert_performance_warning(klass, method) [](#method-i-assert_performance_warning) - -## assert_redefine_method(klass, method, code, msgnil) [](#method-i-assert_redefine_method) - -## bptest_binding(&b) [](#method-i-bptest_binding) - -## bptest_bp_pass_bp_value(&b) [](#method-i-bptest_bp_pass_bp_value) - -## bptest_bp_value(&b) [](#method-i-bptest_bp_value) - -## bptest_set(&b) [](#method-i-bptest_set) - -## bptest_yield(&b) [](#method-i-bptest_yield) - -## bptest_yield_pass(&b) [](#method-i-bptest_yield_pass) - -## disasm(name) [](#method-i-disasm) - -## do_raise() [](#method-i-do_raise) - -## errinfo() [](#method-i-errinfo) - -## just_yield() [](#method-i-just_yield) - -## tailcall(*args) [](#method-i-tailcall) - -## test_array_empty?() [](#method-i-test_array_empty?) - -**@return** [Boolean] - -## test_array_hash() [](#method-i-test_array_hash) - -## test_array_length() [](#method-i-test_array_length) - -## test_array_max() [](#method-i-test_array_max) - -## test_array_min() [](#method-i-test_array_min) - -## test_array_minus() [](#method-i-test_array_minus) - -## test_array_plus() [](#method-i-test_array_plus) - -## test_block_given_aset_aref() [](#method-i-test_block_given_aset_aref) - -## test_block_parameter() [](#method-i-test_block_parameter) - -## test_block_parameter_should_not_create_objects() [](#method-i-test_block_parameter_should_not_create_objects) - -## test_blockparam_in_rescue() [](#method-i-test_blockparam_in_rescue) - -## test_branch_condition_backquote() [](#method-i-test_branch_condition_backquote) - -## test_branch_condition_def() [](#method-i-test_branch_condition_def) - -## test_branch_condition_defs() [](#method-i-test_branch_condition_defs) - -## test_c_func_with_sp_offset_under_tailcall() [](#method-i-test_c_func_with_sp_offset_under_tailcall) - -## test_callinfo_unreachable_path() [](#method-i-test_callinfo_unreachable_path) - -## test_clear_unreachable_keyword_args() [](#method-i-test_clear_unreachable_keyword_args) - -## test_eq() [](#method-i-test_eq) - -## test_eqq() [](#method-i-test_eqq) - -## test_fixnum_and() [](#method-i-test_fixnum_and) - -## test_fixnum_div() [](#method-i-test_fixnum_div) - -## test_fixnum_ge() [](#method-i-test_fixnum_ge) - -## test_fixnum_gt() [](#method-i-test_fixnum_gt) - -## test_fixnum_le() [](#method-i-test_fixnum_le) - -## test_fixnum_lt() [](#method-i-test_fixnum_lt) - -## test_fixnum_minus() [](#method-i-test_fixnum_minus) - -## test_fixnum_mod() [](#method-i-test_fixnum_mod) - -## test_fixnum_mul() [](#method-i-test_fixnum_mul) - -## test_fixnum_or() [](#method-i-test_fixnum_or) - -## test_fixnum_plus() [](#method-i-test_fixnum_plus) - -## test_float_div() [](#method-i-test_float_div) - -## test_float_ge() [](#method-i-test_float_ge) - -## test_float_gt() [](#method-i-test_float_gt) - -## test_float_le() [](#method-i-test_float_le) - -## test_float_lt() [](#method-i-test_float_lt) - -## test_float_minus() [](#method-i-test_float_minus) - -## test_float_mul() [](#method-i-test_float_mul) - -## test_float_plus() [](#method-i-test_float_plus) - -## test_hash_aref_with() [](#method-i-test_hash_aref_with) - -## test_hash_aset_with() [](#method-i-test_hash_aset_with) - -## test_hash_empty?() [](#method-i-test_hash_empty?) - -**@return** [Boolean] - -## test_hash_length() [](#method-i-test_hash_length) - -## test_jump_elimination_with_optimized_out_block() [](#method-i-test_jump_elimination_with_optimized_out_block) - -## test_jump_elimination_with_optimized_out_block_2() [](#method-i-test_jump_elimination_with_optimized_out_block_2) - -## test_nil_safe_conditional_assign() [](#method-i-test_nil_safe_conditional_assign) - -## test_objtostring() [](#method-i-test_objtostring) - -## test_opt_case_dispatch() [](#method-i-test_opt_case_dispatch) - -## test_opt_case_dispatch_inf() [](#method-i-test_opt_case_dispatch_inf) - -## test_opt_duparray_send_include_p() [](#method-i-test_opt_duparray_send_include_p) - -## test_opt_newarray_send_include_p() [](#method-i-test_opt_newarray_send_include_p) - -## test_optimized_empty_ensure() [](#method-i-test_optimized_empty_ensure) - -## test_optimized_rescue() [](#method-i-test_optimized_rescue) - -## test_overwritten_blockparam() [](#method-i-test_overwritten_blockparam) - -## test_peephole_array_freeze() [](#method-i-test_peephole_array_freeze) - -## test_peephole_array_freeze_empty() [](#method-i-test_peephole_array_freeze_empty) - -## test_peephole_dstr() [](#method-i-test_peephole_dstr) - -## test_peephole_hash_freeze() [](#method-i-test_peephole_hash_freeze) - -## test_peephole_hash_freeze_empty() [](#method-i-test_peephole_hash_freeze_empty) - -## test_peephole_jump_after_newarray() [](#method-i-test_peephole_jump_after_newarray) - -## test_peephole_optimization_without_trace() [](#method-i-test_peephole_optimization_without_trace) - -## test_peephole_string_literal_range() [](#method-i-test_peephole_string_literal_range) - -## test_retry_label_in_unreachable_chunk() [](#method-i-test_retry_label_in_unreachable_chunk) - -## test_side_effect_in_popped_splat() [](#method-i-test_side_effect_in_popped_splat) - -## test_string_empty?() [](#method-i-test_string_empty?) - -**@return** [Boolean] - -## test_string_eq_neq() [](#method-i-test_string_eq_neq) - -## test_string_format() [](#method-i-test_string_format) - -## test_string_freeze() [](#method-i-test_string_freeze) - -## test_string_freeze_block() [](#method-i-test_string_freeze_block) - -## test_string_freeze_saves_memory() [](#method-i-test_string_freeze_saves_memory) - -## test_string_length() [](#method-i-test_string_length) - -## test_string_ltlt() [](#method-i-test_string_ltlt) - -## test_string_plus() [](#method-i-test_string_plus) - -## test_string_size() [](#method-i-test_string_size) - -## test_string_succ() [](#method-i-test_string_succ) - -## test_string_uminus() [](#method-i-test_string_uminus) - -## test_tailcall() [](#method-i-test_tailcall) - -## test_tailcall_and_post_arg() [](#method-i-test_tailcall_and_post_arg) - -## test_tailcall_condition_block() [](#method-i-test_tailcall_condition_block) - -## test_tailcall_inhibited_by_block() [](#method-i-test_tailcall_inhibited_by_block) - -## test_tailcall_inhibited_by_rescue() [](#method-i-test_tailcall_inhibited_by_rescue) - -## test_tailcall_interrupted_by_sigint() [](#method-i-test_tailcall_interrupted_by_sigint) - -## test_tailcall_not_to_grow_stack() [](#method-i-test_tailcall_not_to_grow_stack) - -## test_tailcall_symbol_block_arg() [](#method-i-test_tailcall_symbol_block_arg) - -## test_tailcall_with_block() [](#method-i-test_tailcall_with_block) - -## test_trace_optimized_methods() [](#method-i-test_trace_optimized_methods) - -## test_unconditional_branch_to_leave_block() [](#method-i-test_unconditional_branch_to_leave_block) - diff --git a/example/ruby/TestRubyOptimization/Bug10557.md b/example/ruby/TestRubyOptimization/Bug10557.md deleted file mode 100644 index 8fd83df..0000000 --- a/example/ruby/TestRubyOptimization/Bug10557.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRubyOptimization::Bug10557 -**Inherits:** Object - - - - - -#Instance Methods -## [](_) [](#method-i-[]) - -## []=(_, _) [](#method-i-[]=) - diff --git a/example/ruby/TestRubyOptimization/MyObj.md b/example/ruby/TestRubyOptimization/MyObj.md deleted file mode 100644 index ba45b7d..0000000 --- a/example/ruby/TestRubyOptimization/MyObj.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRubyOptimization::MyObj -**Inherits:** Object - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - diff --git a/example/ruby/TestRubyOptimization/Objtostring.md b/example/ruby/TestRubyOptimization/Objtostring.md deleted file mode 100644 index c44977e..0000000 --- a/example/ruby/TestRubyOptimization/Objtostring.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyOptimization::Objtostring -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRubyOptions.md b/example/ruby/TestRubyOptions.md deleted file mode 100644 index 373b375..0000000 --- a/example/ruby/TestRubyOptions.md +++ /dev/null @@ -1,161 +0,0 @@ -# Class: TestRubyOptions -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## rjit_enabled?() [](#method-c-rjit_enabled?) -**@return** [Boolean] - -## yjit_enabled?() [](#method-c-yjit_enabled?) -**@return** [Boolean] - - -#Instance Methods -## assert_crash_report(path, cmdnil, &block) [](#method-i-assert_crash_report) - -## assert_norun_with_rflag(*opt, test_stderr:[]) [](#method-i-assert_norun_with_rflag) - -## assert_segv(args, messagenil, list:SEGVTest::ExpectedStderrList, **opt, &block) [](#method-i-assert_segv) - -## test_DATA() [](#method-i-test_DATA) - -## test___dir__encoding() [](#method-i-test___dir__encoding) - -## test_assignment_in_conditional() [](#method-i-test_assignment_in_conditional) - -## test_autosplit() [](#method-i-test_autosplit) - -## test_backtrace_limit() [](#method-i-test_backtrace_limit) - -## test_chdir() [](#method-i-test_chdir) - -## test_copyright() [](#method-i-test_copyright) - -## test_crash_report() [](#method-i-test_crash_report) - -## test_crash_report_executable_path() [](#method-i-test_crash_report_executable_path) - -## test_crash_report_pipe() [](#method-i-test_crash_report_pipe) - -## test_crash_report_script() [](#method-i-test_crash_report_script) - -## test_crash_report_script_path() [](#method-i-test_crash_report_script_path) - -## test_cwd_encoding() [](#method-i-test_cwd_encoding) - -## test_debug() [](#method-i-test_debug) - -## test_disable() [](#method-i-test_disable) - -## test_dump_insns_with_rflag() [](#method-i-test_dump_insns_with_rflag) - -## test_dump_parsetree_error_tolerant() [](#method-i-test_dump_parsetree_error_tolerant) - -## test_dump_parsetree_with_rflag() [](#method-i-test_dump_parsetree_with_rflag) - -## test_dump_syntax_with_rflag() [](#method-i-test_dump_syntax_with_rflag) - -## test_dump_yydebug_with_rflag() [](#method-i-test_dump_yydebug_with_rflag) - -## test_enable() [](#method-i-test_enable) - -## test_enabled_gc() [](#method-i-test_enabled_gc) - -## test_encoding() [](#method-i-test_encoding) - -## test_eval() [](#method-i-test_eval) - -## test_flag_in_shebang() [](#method-i-test_flag_in_shebang) - -## test_free_at_exit_env_var() [](#method-i-test_free_at_exit_env_var) - -## test_frozen_string_literal() [](#method-i-test_frozen_string_literal) - -## test_frozen_string_literal_debug() [](#method-i-test_frozen_string_literal_debug) - -## test_frozen_string_literal_debug_chilled_strings() [](#method-i-test_frozen_string_literal_debug_chilled_strings) - -## test_include() [](#method-i-test_include) - -## test_indentation_check() [](#method-i-test_indentation_check) - -## test_invalid_option() [](#method-i-test_invalid_option) - -## test_kanji() [](#method-i-test_kanji) - -## test_notfound() [](#method-i-test_notfound) - -## test_null_script() [](#method-i-test_null_script) - -## test_option_missing_argument() [](#method-i-test_option_missing_argument) - -## test_option_variables() [](#method-i-test_option_variables) - -## test_parser_flag() [](#method-i-test_parser_flag) - -## test_pflag_gsub() [](#method-i-test_pflag_gsub) - -## test_pflag_sub() [](#method-i-test_pflag_sub) - -## test_program_name() [](#method-i-test_program_name) - -## test_require() [](#method-i-test_require) - -## test_rjit_disabled_version() [](#method-i-test_rjit_disabled_version) - -## test_rjit_version() [](#method-i-test_rjit_version) - -## test_rubylib_invalid_encoding() [](#method-i-test_rubylib_invalid_encoding) - -## test_rubyopt() [](#method-i-test_rubyopt) - -## test_script_from_stdin() [](#method-i-test_script_from_stdin) - -## test_script_is_directory() [](#method-i-test_script_is_directory) - -## test_search() [](#method-i-test_search) - -## test_segv_loaded_features() [](#method-i-test_segv_loaded_features) - -## test_segv_setproctitle() [](#method-i-test_segv_setproctitle) - -## test_segv_test() [](#method-i-test_segv_test) - -## test_separator() [](#method-i-test_separator) - -## test_set_program_name() [](#method-i-test_set_program_name) - -## test_setproctitle() [](#method-i-test_setproctitle) - -## test_sflag() [](#method-i-test_sflag) - -## test_shebang() [](#method-i-test_shebang) - -## test_source_file() [](#method-i-test_source_file) - -## test_syntax_check() [](#method-i-test_syntax_check) - -## test_toplevel_ruby() [](#method-i-test_toplevel_ruby) - -## test_unmatching_glob() [](#method-i-test_unmatching_glob) - -## test_unused_variable() [](#method-i-test_unused_variable) - -## test_usage() [](#method-i-test_usage) - -## test_usage_long() [](#method-i-test_usage_long) - -## test_verbose() [](#method-i-test_verbose) - -## test_version() [](#method-i-test_version) - -## test_warning() [](#method-i-test_warning) - -## test_yydebug() [](#method-i-test_yydebug) - -## with_tmpchdir() [](#method-i-with_tmpchdir) - -## write_file(filename, content) [](#method-i-write_file) - diff --git a/example/ruby/TestRubyOptions/SEGVTest.md b/example/ruby/TestRubyOptions/SEGVTest.md deleted file mode 100644 index 050f1c9..0000000 --- a/example/ruby/TestRubyOptions/SEGVTest.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestRubyOptions::SEGVTest - - - - - diff --git a/example/ruby/TestRubyPrimitive.md b/example/ruby/TestRubyPrimitive.md deleted file mode 100644 index 3c46453..0000000 --- a/example/ruby/TestRubyPrimitive.md +++ /dev/null @@ -1,60 +0,0 @@ -# Class: TestRubyPrimitive -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## fact(n) [](#method-i-fact) - -## test_aref() [](#method-i-test_aref) - -## test_aset() [](#method-i-test_aset) - -## test_attr_setter() [](#method-i-test_attr_setter) - -## test_backref() [](#method-i-test_backref) - -## test_concatarray_ruby_dev_41933() [](#method-i-test_concatarray_ruby_dev_41933) - -## test_constant() [](#method-i-test_constant) - -## test_constant_cache() [](#method-i-test_constant_cache) - -## test_constant_cache2() [](#method-i-test_constant_cache2) - -## test_constant_cache3() [](#method-i-test_constant_cache3) - -## test_constant_cache5() [](#method-i-test_constant_cache5) - -## test_constatant_cache4() [](#method-i-test_constatant_cache4) - -## test_cvar_from_instance_method() [](#method-i-test_cvar_from_instance_method) - -## test_cvar_from_singleton_method() [](#method-i-test_cvar_from_singleton_method) - -## test_cvar_from_singleton_method2() [](#method-i-test_cvar_from_singleton_method2) - -## test_div() [](#method-i-test_div) - -## test_fact() [](#method-i-test_fact) - -## test_gvar() [](#method-i-test_gvar) - -## test_length() [](#method-i-test_length) - -## test_list_expand() [](#method-i-test_list_expand) - -## test_lvar() [](#method-i-test_lvar) - -## test_mod() [](#method-i-test_mod) - -## test_mul() [](#method-i-test_mul) - -## test_not() [](#method-i-test_not) - -## test_opassign() [](#method-i-test_opassign) - -## test_opassign_and_or() [](#method-i-test_opassign_and_or) - diff --git a/example/ruby/TestRubyPrimitive/A10.md b/example/ruby/TestRubyPrimitive/A10.md deleted file mode 100644 index 9bd22fc..0000000 --- a/example/ruby/TestRubyPrimitive/A10.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: TestRubyPrimitive::A10 -**Inherits:** Object - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a. - - diff --git a/example/ruby/TestRubyPrimitive/A2.md b/example/ruby/TestRubyPrimitive/A2.md deleted file mode 100644 index 133cb77..0000000 --- a/example/ruby/TestRubyPrimitive/A2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::A2 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRubyPrimitive/A2/B2.md b/example/ruby/TestRubyPrimitive/A2/B2.md deleted file mode 100644 index def6e5c..0000000 --- a/example/ruby/TestRubyPrimitive/A2/B2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::A2::B2 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRubyPrimitive/A2/B2/C2.md b/example/ruby/TestRubyPrimitive/A2/B2/C2.md deleted file mode 100644 index 000f4bd..0000000 --- a/example/ruby/TestRubyPrimitive/A2/B2/C2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::A2::B2::C2 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRubyPrimitive/A3.md b/example/ruby/TestRubyPrimitive/A3.md deleted file mode 100644 index 37d6e3e..0000000 --- a/example/ruby/TestRubyPrimitive/A3.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::A3 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRubyPrimitive/A3/B3.md b/example/ruby/TestRubyPrimitive/A3/B3.md deleted file mode 100644 index a4be17c..0000000 --- a/example/ruby/TestRubyPrimitive/A3/B3.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::A3::B3 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRubyPrimitive/A4.md b/example/ruby/TestRubyPrimitive/A4.md deleted file mode 100644 index 01af19b..0000000 --- a/example/ruby/TestRubyPrimitive/A4.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::A4 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRubyPrimitive/A5.md b/example/ruby/TestRubyPrimitive/A5.md deleted file mode 100644 index b334c53..0000000 --- a/example/ruby/TestRubyPrimitive/A5.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::A5 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestRubyPrimitive/A6.md b/example/ruby/TestRubyPrimitive/A6.md deleted file mode 100644 index df61531..0000000 --- a/example/ruby/TestRubyPrimitive/A6.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestRubyPrimitive::A6 -**Inherits:** Object - - - - -# Class Methods -## foo() [](#method-c-foo) - diff --git a/example/ruby/TestRubyPrimitive/B6.md b/example/ruby/TestRubyPrimitive/B6.md deleted file mode 100644 index aa496bd..0000000 --- a/example/ruby/TestRubyPrimitive/B6.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::B6 -**Inherits:** TestRubyPrimitive::A6 - - - - - diff --git a/example/ruby/TestRubyPrimitive/C6.md b/example/ruby/TestRubyPrimitive/C6.md deleted file mode 100644 index ef0e431..0000000 --- a/example/ruby/TestRubyPrimitive/C6.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestRubyPrimitive::C6 -**Inherits:** TestRubyPrimitive::B6 - - - - - diff --git a/example/ruby/TestRubyPrimitive/MyArr.md b/example/ruby/TestRubyPrimitive/MyArr.md deleted file mode 100644 index 73c55fa..0000000 --- a/example/ruby/TestRubyPrimitive/MyArr.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRubyPrimitive::MyArr -**Inherits:** Object - - - - - -#Instance Methods -## length() [](#method-i-length) - diff --git a/example/ruby/TestRubyPrimitive/MyNum.md b/example/ruby/TestRubyPrimitive/MyNum.md deleted file mode 100644 index ff0ed77..0000000 --- a/example/ruby/TestRubyPrimitive/MyNum.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRubyPrimitive::MyNum -**Inherits:** Object - - - - - -#Instance Methods -## /(a) [](#method-i-/) - diff --git a/example/ruby/TestRubyPrimitive/MyNum2.md b/example/ruby/TestRubyPrimitive/MyNum2.md deleted file mode 100644 index ada70c1..0000000 --- a/example/ruby/TestRubyPrimitive/MyNum2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRubyPrimitive::MyNum2 -**Inherits:** Object - - - - - -#Instance Methods -## %(a) [](#method-i-%) - diff --git a/example/ruby/TestRubyPrimitive/MyObj.md b/example/ruby/TestRubyPrimitive/MyObj.md deleted file mode 100644 index c2bf40e..0000000 --- a/example/ruby/TestRubyPrimitive/MyObj.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestRubyPrimitive::MyObj -**Inherits:** Object - - - - - -#Instance Methods -## [](*args) [](#method-i-[]) - -## []=(*args) [](#method-i-[]=) - diff --git a/example/ruby/TestRubyPrimitive/MyObj2.md b/example/ruby/TestRubyPrimitive/MyObj2.md deleted file mode 100644 index e2caec8..0000000 --- a/example/ruby/TestRubyPrimitive/MyObj2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestRubyPrimitive::MyObj2 -**Inherits:** Object - - - - - -#Instance Methods -## attr=(*args) [](#method-i-attr=) - diff --git a/example/ruby/TestRubyVM.md b/example/ruby/TestRubyVM.md deleted file mode 100644 index 6891df2..0000000 --- a/example/ruby/TestRubyVM.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestRubyVM -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## parse_and_compile() [](#method-i-parse_and_compile) - -## test_keep_script_lines() [](#method-i-test_keep_script_lines) - -## test_stat() [](#method-i-test_stat) - -## test_stat_unknown() [](#method-i-test_stat_unknown) - diff --git a/example/ruby/TestRubyYield.md b/example/ruby/TestRubyYield.md deleted file mode 100644 index 0ce19df..0000000 --- a/example/ruby/TestRubyYield.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestRubyYield -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## block_args_unleashed() [](#method-i-block_args_unleashed) - -**@yield** [1, 2, 3, 4, 5] - -## iter0() [](#method-i-iter0) - -## iter1(args) [](#method-i-iter1) - -**@yield** [args] - -## iter2_1() [](#method-i-iter2_1) - -**@yield** [1, [2, 3]] - -## iter2_2() [](#method-i-iter2_2) - -**@yield** [1, []] - -## iter2_3() [](#method-i-iter2_3) - -**@yield** [1, [2]] - -## test_ary_each() [](#method-i-test_ary_each) - -## test_block_args_unleashed() [](#method-i-test_block_args_unleashed) - -## test_hash_each() [](#method-i-test_hash_each) - -## test_with_enum() [](#method-i-test_with_enum) - -## test_yield2() [](#method-i-test_yield2) - -## test_yield_0() [](#method-i-test_yield_0) - -## test_yield_1() [](#method-i-test_yield_1) - -## test_yield_nested() [](#method-i-test_yield_nested) - diff --git a/example/ruby/TestRubyYieldGen.md b/example/ruby/TestRubyYieldGen.md deleted file mode 100644 index 33601bb..0000000 --- a/example/ruby/TestRubyYieldGen.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestRubyYieldGen -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_all_sentences(syntax, *args) [](#method-i-assert_all_sentences) - -## check_nofork(t, islambdafalse) [](#method-i-check_nofork) - -## disable_stderr() [](#method-i-disable_stderr) - -## emu(t, vars, islambda) [](#method-i-emu) - -## emu_bind(t, islambda) [](#method-i-emu_bind) - -## emu_bind_params(args, params, islambda, result_binding{}) [](#method-i-emu_bind_params) - -## emu_bind_single(arg, param, result_binding) [](#method-i-emu_bind_single) - -## emu_eval_args(args) [](#method-i-emu_eval_args) - -## emu_return_args(*vs) [](#method-i-emu_return_args) - -## rename_var(obj) [](#method-i-rename_var) - -## split_by_comma(ary) [](#method-i-split_by_comma) - -## test_block_cached_argc() [](#method-i-test_block_cached_argc) - -## test_block_with_mock() [](#method-i-test_block_with_mock) - -## test_yield() [](#method-i-test_yield) - -## test_yield_enum() [](#method-i-test_yield_enum) - -## test_yield_lambda() [](#method-i-test_yield_lambda) - diff --git a/example/ruby/TestSH.md b/example/ruby/TestSH.md deleted file mode 100644 index 2d034e8..0000000 --- a/example/ruby/TestSH.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: TestSH -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## period2_iter(from, to) [](#method-i-period2_iter) - -## period2_iter2(from, to, sg) [](#method-i-period2_iter2) - -## test_base() [](#method-i-test_base) - -## test_canon24oc() [](#method-i-test_canon24oc) - -## test_cmp() [](#method-i-test_cmp) - -## test_commercial() [](#method-i-test_commercial) - -## test_different_alignments() [](#method-i-test_different_alignments) - -## test_dup() [](#method-i-test_dup) - -## test_enc() [](#method-i-test_enc) - -## test_eqeqeq() [](#method-i-test_eqeqeq) - -## test_fractional() [](#method-i-test_fractional) - -## test_inspect() [](#method-i-test_inspect) - -## test_jd() [](#method-i-test_jd) - -## test_marshal14() [](#method-i-test_marshal14) - -## test_marshal16() [](#method-i-test_marshal16) - -## test_marshal18() [](#method-i-test_marshal18) - -## test_marshal192() [](#method-i-test_marshal192) - -## test_new() [](#method-i-test_new) - -## test_ordinal() [](#method-i-test_ordinal) - -## test_period() [](#method-i-test_period) - -## test_period2() [](#method-i-test_period2) - -## test_strftime() [](#method-i-test_strftime) - -## test_to_s() [](#method-i-test_to_s) - -## test_zone() [](#method-i-test_zone) - diff --git a/example/ruby/TestScanArgs.md b/example/ruby/TestScanArgs.md deleted file mode 100644 index 2c61d13..0000000 --- a/example/ruby/TestScanArgs.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: TestScanArgs -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_hash() [](#method-i-test_hash) - -## test_k_lead_opt_hash() [](#method-i-test_k_lead_opt_hash) - -## test_lead() [](#method-i-test_lead) - -## test_lead_hash() [](#method-i-test_lead_hash) - -## test_lead_opt() [](#method-i-test_lead_opt) - -## test_lead_opt_hash() [](#method-i-test_lead_opt_hash) - -## test_lead_opt_trail() [](#method-i-test_lead_opt_trail) - -## test_lead_opt_trail_hash() [](#method-i-test_lead_opt_trail_hash) - -## test_lead_opt_var() [](#method-i-test_lead_opt_var) - -## test_lead_opt_var_hash() [](#method-i-test_lead_opt_var_hash) - -## test_lead_opt_var_trail() [](#method-i-test_lead_opt_var_trail) - -## test_lead_opt_var_trail_hash() [](#method-i-test_lead_opt_var_trail_hash) - -## test_lead_var() [](#method-i-test_lead_var) - -## test_lead_var_hash() [](#method-i-test_lead_var_hash) - -## test_lead_var_trail() [](#method-i-test_lead_var_trail) - -## test_lead_var_trail_hash() [](#method-i-test_lead_var_trail_hash) - -## test_n_lead_opt_hash() [](#method-i-test_n_lead_opt_hash) - -## test_opt() [](#method-i-test_opt) - -## test_opt_hash() [](#method-i-test_opt_hash) - -## test_opt_trail() [](#method-i-test_opt_trail) - -## test_opt_trail_hash() [](#method-i-test_opt_trail_hash) - -## test_opt_var() [](#method-i-test_opt_var) - -## test_opt_var_hash() [](#method-i-test_opt_var_hash) - -## test_opt_var_trail() [](#method-i-test_opt_var_trail) - -## test_opt_var_trail_hash() [](#method-i-test_opt_var_trail_hash) - -## test_var() [](#method-i-test_var) - -## test_var_hash() [](#method-i-test_var_hash) - -## test_var_trail() [](#method-i-test_var_trail) - -## test_var_trail_hash() [](#method-i-test_var_trail_hash) - diff --git a/example/ruby/TestSecureRandom.md b/example/ruby/TestSecureRandom.md deleted file mode 100644 index ef544fe..0000000 --- a/example/ruby/TestSecureRandom.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: TestSecureRandom -**Inherits:** Test::Unit::TestCase - - -This testcase does NOT aim to test cryptographically strongness and -randomness. - - - -#Instance Methods -## check_forking_random_bytes(target_pid, target) [](#method-i-check_forking_random_bytes) - -## forking_random_bytes() [](#method-i-forking_random_bytes) -[ENV]("CI") && RUBY_PLATFORM =~ /darwin/ && `sw_vers -productVersion`.to_i > -13 # for Apple Silicon - -## setup() [](#method-i-setup) - -## test_alphanumeric_with_chars() [](#method-i-test_alphanumeric_with_chars) - -## test_repeated_gen_random() [](#method-i-test_repeated_gen_random) - -## test_s_random_bytes_is_fork_safe() [](#method-i-test_s_random_bytes_is_fork_safe) -This test took 2 minutes on my machine. And 65536 times loop could not be -enough for forcing PID recycle. TODO: We should run this test only on GitHub -Actions. - -## test_with_openssl() [](#method-i-test_with_openssl) - diff --git a/example/ruby/TestServer.md b/example/ruby/TestServer.md deleted file mode 100644 index 98d3db7..0000000 --- a/example/ruby/TestServer.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestServer -**Inherits:** Object - - - - - -#Instance Methods -## add(*args) [](#method-i-add) - -## add_yield(x) [](#method-i-add_yield) - diff --git a/example/ruby/TestSetTraceFunc.md b/example/ruby/TestSetTraceFunc.md deleted file mode 100644 index 437fada..0000000 --- a/example/ruby/TestSetTraceFunc.md +++ /dev/null @@ -1,277 +0,0 @@ -# Class: TestSetTraceFunc -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_consistent_call_return(message'', check_events:nil) [](#method-i-assert_consistent_call_return) - -## check_with_events(trace_point_events, expected_eventstrace_point_events) [](#method-i-check_with_events) - -## f_break_in_iter() [](#method-i-f_break_in_iter) - -## f_break_in_rescue() [](#method-i-f_break_in_rescue) - -## f_iter() [](#method-i-f_iter) - -## f_iter1() [](#method-i-f_iter1) - -## f_iter2() [](#method-i-f_iter2) - -## f_raise() [](#method-i-f_raise) - -## f_return_in_iter() [](#method-i-f_return_in_iter) - -## foo() [](#method-i-foo) - -## helper_can_rescue() [](#method-i-helper_can_rescue) - -## helper_can_rescue_empty_body() [](#method-i-helper_can_rescue_empty_body) - -## helper_cant_rescue() [](#method-i-helper_cant_rescue) - -## m1_for_test_trace_point_binding_in_ifunc(arg) [](#method-i-m1_for_test_trace_point_binding_in_ifunc) - -## m1_test_trace_point_at_return_when_exception() [](#method-i-m1_test_trace_point_at_return_when_exception) - -## m2_for_test_trace_point_binding_in_ifunc(arg) [](#method-i-m2_for_test_trace_point_binding_in_ifunc) - -## m2_test_trace_point_at_return_when_exception() [](#method-i-m2_test_trace_point_at_return_when_exception) - -**@raise** [BAR_ERROR] - -## method_for_enable_target1() [](#method-i-method_for_enable_target1) - -## method_for_enable_target2() [](#method-i-method_for_enable_target2) - -## method_for_test_thread_add_trace_func() [](#method-i-method_for_test_thread_add_trace_func) - -## method_for_test_tracepoint_block() [](#method-i-method_for_test_tracepoint_block) - -## method_label(tp) [](#method-i-method_label) - -## method_prefix(event) [](#method-i-method_prefix) - -## method_test_ensure_should_not_cause_b_return() [](#method-i-method_test_ensure_should_not_cause_b_return) - -## method_test_rescue_should_not_cause_b_return() [](#method-i-method_test_rescue_should_not_cause_b_return) - -## method_test_tracepoint_raised_exception(err) [](#method-i-method_test_tracepoint_raised_exception) - -## method_test_tracepoint_return_value(obj) [](#method-i-method_test_tracepoint_return_value) - -## parameter_test(a, b, c) [](#method-i-parameter_test) - -## setup() [](#method-i-setup) - -## target_thread?() [](#method-i-target_thread?) - -**@return** [Boolean] - -## teardown() [](#method-i-teardown) - -## test_a_call() [](#method-i-test_a_call) - -## test_a_return() [](#method-i-test_a_return) - -## test_aliased_c_method() [](#method-i-test_aliased_c_method) - -## test_aliased_ruby_method() [](#method-i-test_aliased_ruby_method) - -## test_allow_reentry() [](#method-i-test_allow_reentry) - -## test_argument_error_on_bmethod() [](#method-i-test_argument_error_on_bmethod) - -## test_b_call_with_redo() [](#method-i-test_b_call_with_redo) - -## test_b_tracepoints_going_away() [](#method-i-test_b_tracepoints_going_away) - -## test_break() [](#method-i-test_break) - Bug #2610 -: - - -## test_break_with_rescue() [](#method-i-test_break_with_rescue) - -## test_c_call() [](#method-i-test_c_call) - -## test_c_call_aliased_method() [](#method-i-test_c_call_aliased_method) - -## test_c_call_no_binding() [](#method-i-test_c_call_no_binding) - -## test_c_call_removed_method() [](#method-i-test_c_call_removed_method) - -## test_c_return_no_binding() [](#method-i-test_c_return_no_binding) - -## test_call() [](#method-i-test_call) - -## test_class() [](#method-i-test_class) - -## test_const_missing() [](#method-i-test_const_missing) - -## test_define_method_on_exception() [](#method-i-test_define_method_on_exception) - -## test_define_method_on_return() [](#method-i-test_define_method_on_return) - -## test_disable_local_tracepoint_in_trace() [](#method-i-test_disable_local_tracepoint_in_trace) - -## test_elsif_line_event() [](#method-i-test_elsif_line_event) - -## test_enable_target_thread() [](#method-i-test_enable_target_thread) - -## test_fiber_switch() [](#method-i-test_fiber_switch) - -## test_invalid_proc() [](#method-i-test_invalid_proc) - -## test_isolated_raise_in_trace() [](#method-i-test_isolated_raise_in_trace) - -## test_lineno_in_optimized_insn() [](#method-i-test_lineno_in_optimized_insn) - -## test_method_missing() [](#method-i-test_method_missing) - -## test_multiple_enable() [](#method-i-test_multiple_enable) - -## test_multiple_tracepoints_same_bmethod() [](#method-i-test_multiple_tracepoints_same_bmethod) - -## test_no_duplicate_line_events() [](#method-i-test_no_duplicate_line_events) - -## test_non_local_return_across_multiple_define_methods() [](#method-i-test_non_local_return_across_multiple_define_methods) - -## test_raise() [](#method-i-test_raise) - -## test_raise_in_trace() [](#method-i-test_raise_in_trace) - -## test_raising_from_b_return_tp_tracing_bmethod() [](#method-i-test_raising_from_b_return_tp_tracing_bmethod) - -## test_rb_rescue() [](#method-i-test_rb_rescue) - -## test_recursive() [](#method-i-test_recursive) - -## test_remove_in_trace() [](#method-i-test_remove_in_trace) - -## test_rescue_and_ensure_should_not_cause_b_return() [](#method-i-test_rescue_and_ensure_should_not_cause_b_return) - -## test_return() [](#method-i-test_return) -ruby-dev:38701 -: - -## test_return2() [](#method-i-test_return2) -ruby-core:24463 -: - -## test_return_bmethod_location() [](#method-i-test_return_bmethod_location) - -## test_return_event_with_rescue() [](#method-i-test_return_event_with_rescue) - -## test_return_value_with_rescue() [](#method-i-test_return_value_with_rescue) - -## test_return_value_with_rescue_and_defined_methods() [](#method-i-test_return_value_with_rescue_and_defined_methods) - -## test_script_compiled() [](#method-i-test_script_compiled) - -## test_set_trace_func() [](#method-i-test_set_trace_func) - -## test_set_trace_func_curry_argument_error() [](#method-i-test_set_trace_func_curry_argument_error) - -## test_single_raise_inside_load() [](#method-i-test_single_raise_inside_load) - -## test_stat_exists() [](#method-i-test_stat_exists) - -## test_target_different_bmethod_same_iseq() [](#method-i-test_target_different_bmethod_same_iseq) - -## test_thread_add_trace_func() [](#method-i-test_thread_add_trace_func) - -## test_thread_trace() [](#method-i-test_thread_trace) - -## test_throwing_return_with_finish_frame() [](#method-i-test_throwing_return_with_finish_frame) - -## test_tp_rescue() [](#method-i-test_tp_rescue) - -## test_tp_rescue_event() [](#method-i-test_tp_rescue_event) - -## test_trace_defined_method() [](#method-i-test_trace_defined_method) - -## test_trace_point_at_return_when_exception() [](#method-i-test_trace_point_at_return_when_exception) - -## test_trace_point_binding_after_break() [](#method-i-test_trace_point_binding_after_break) - -## test_trace_point_binding_in_ifunc() [](#method-i-test_trace_point_binding_in_ifunc) - -## test_trace_point_raising_exception_in_bmethod_call() [](#method-i-test_trace_point_raising_exception_in_bmethod_call) - -## test_trace_point_require_block() [](#method-i-test_trace_point_require_block) - -## test_tracepoint() [](#method-i-test_tracepoint) - -## test_tracepoint_access_from_outside() [](#method-i-test_tracepoint_access_from_outside) - -## test_tracepoint_attr() [](#method-i-test_tracepoint_attr) - -## test_tracepoint_b_return_with_lambda() [](#method-i-test_tracepoint_b_return_with_lambda) - -## test_tracepoint_b_return_with_next() [](#method-i-test_tracepoint_b_return_with_next) - -## test_tracepoint_block() [](#method-i-test_tracepoint_block) - -## test_tracepoint_bmethod_memory_leak() [](#method-i-test_tracepoint_bmethod_memory_leak) - -## test_tracepoint_callee_id() [](#method-i-test_tracepoint_callee_id) - -## test_tracepoint_disable() [](#method-i-test_tracepoint_disable) - -## test_tracepoint_enable() [](#method-i-test_tracepoint_enable) - -## test_tracepoint_enable_target() [](#method-i-test_tracepoint_enable_target) - -## test_tracepoint_enable_with_target_line() [](#method-i-test_tracepoint_enable_with_target_line) - -## test_tracepoint_enable_with_target_line_two_times() [](#method-i-test_tracepoint_enable_with_target_line_two_times) - -## test_tracepoint_enabled() [](#method-i-test_tracepoint_enabled) - -## test_tracepoint_exception_at_c_return() [](#method-i-test_tracepoint_exception_at_c_return) - -## test_tracepoint_exception_at_line() [](#method-i-test_tracepoint_exception_at_line) - -## test_tracepoint_exception_at_return() [](#method-i-test_tracepoint_exception_at_return) - -## test_tracepoint_inspect() [](#method-i-test_tracepoint_inspect) - -## test_tracepoint_memory_leak() [](#method-i-test_tracepoint_memory_leak) -Bug #18264 - -## test_tracepoint_nested_enabled_with_target() [](#method-i-test_tracepoint_nested_enabled_with_target) - -## test_tracepoint_object_id() [](#method-i-test_tracepoint_object_id) - -## test_tracepoint_opt_invokebuiltin_delegate_leave() [](#method-i-test_tracepoint_opt_invokebuiltin_delegate_leave) - -## test_tracepoint_parameters() [](#method-i-test_tracepoint_parameters) - -## test_tracepoint_raised_exception() [](#method-i-test_tracepoint_raised_exception) - -## test_tracepoint_return_value() [](#method-i-test_tracepoint_return_value) - -## test_tracepoint_struct() [](#method-i-test_tracepoint_struct) - -## test_tracepoint_thread() [](#method-i-test_tracepoint_thread) - -## test_tracepoint_thread_begin() [](#method-i-test_tracepoint_thread_begin) - -## test_tracepoint_thread_end() [](#method-i-test_tracepoint_thread_end) - -## test_tracepoint_thread_end_with_exception() [](#method-i-test_tracepoint_thread_end_with_exception) - -## test_tracepoint_with_multithreads() [](#method-i-test_tracepoint_with_multithreads) - -## test_while_in_while() [](#method-i-test_while_in_while) - -## tp_return_value(mid) [](#method-i-tp_return_value) -tests for `return_value` with non-local exit [Bug #13369] - -## trace_by_set_trace_func() [](#method-i-trace_by_set_trace_func) - -## trace_by_tracepoint(*trace_events) [](#method-i-trace_by_tracepoint) - diff --git a/example/ruby/TestSetTraceFunc/AliasedCMethod.md b/example/ruby/TestSetTraceFunc/AliasedCMethod.md deleted file mode 100644 index 2104233..0000000 --- a/example/ruby/TestSetTraceFunc/AliasedCMethod.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestSetTraceFunc::AliasedCMethod -**Inherits:** Hash - - - - - -#Instance Methods -## original_size() [](#method-i-original_size) - -## size() [](#method-i-size) - diff --git a/example/ruby/TestSetTraceFunc/AliasedRubyMethod.md b/example/ruby/TestSetTraceFunc/AliasedRubyMethod.md deleted file mode 100644 index bbd8735..0000000 --- a/example/ruby/TestSetTraceFunc/AliasedRubyMethod.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSetTraceFunc::AliasedRubyMethod -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestSetTraceFunc/BAR_ERROR.md b/example/ruby/TestSetTraceFunc/BAR_ERROR.md deleted file mode 100644 index 1a74ac6..0000000 --- a/example/ruby/TestSetTraceFunc/BAR_ERROR.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestSetTraceFunc::BAR_ERROR -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/TestSetTraceFunc/Bug10724.md b/example/ruby/TestSetTraceFunc/Bug10724.md deleted file mode 100644 index 50814a9..0000000 --- a/example/ruby/TestSetTraceFunc/Bug10724.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestSetTraceFunc::Bug10724 -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Bug10724] a new instance of Bug10724 - diff --git a/example/ruby/TestSetTraceFunc/C11492.md b/example/ruby/TestSetTraceFunc/C11492.md deleted file mode 100644 index c39a6d6..0000000 --- a/example/ruby/TestSetTraceFunc/C11492.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestSetTraceFunc::C11492 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestSetTraceFunc/C9759.md b/example/ruby/TestSetTraceFunc/C9759.md deleted file mode 100644 index b95bda2..0000000 --- a/example/ruby/TestSetTraceFunc/C9759.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestSetTraceFunc::C9759 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestSetTraceFunc/FOO_ERROR.md b/example/ruby/TestSetTraceFunc/FOO_ERROR.md deleted file mode 100644 index f77873a..0000000 --- a/example/ruby/TestSetTraceFunc/FOO_ERROR.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestSetTraceFunc::FOO_ERROR -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/TestSetTraceFunc/XYZZYException.md b/example/ruby/TestSetTraceFunc/XYZZYException.md deleted file mode 100644 index 492622a..0000000 --- a/example/ruby/TestSetTraceFunc/XYZZYException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestSetTraceFunc::XYZZYException -**Inherits:** Exception - - - - - diff --git a/example/ruby/TestShapes.md b/example/ruby/TestShapes.md deleted file mode 100644 index b3a92a9..0000000 --- a/example/ruby/TestShapes.md +++ /dev/null @@ -1,147 +0,0 @@ -# Class: TestShapes -**Inherits:** Test::Unit::TestCase - - -These test the functionality of object shapes - - - -#Instance Methods -## assert_shape_equal(shape1, shape2) [](#method-i-assert_shape_equal) -RubyVM::Shape.of returns new instances of shape objects for each call. This -helper method allows us to define equality for shapes - -## ensure_complex() [](#method-i-ensure_complex) - -## refute_shape_equal(shape1, shape2) [](#method-i-refute_shape_equal) - -## test_array_has_root_shape() [](#method-i-test_array_has_root_shape) - -## test_basic_shape_transition() [](#method-i-test_basic_shape_transition) - -## test_cloning_with_freeze_option() [](#method-i-test_cloning_with_freeze_option) - -## test_complex_freeze_after_clone() [](#method-i-test_complex_freeze_after_clone) - -## test_delete_iv_after_complex() [](#method-i-test_delete_iv_after_complex) - -## test_delete_undefined_after_complex() [](#method-i-test_delete_undefined_after_complex) - -## test_different_objects_make_same_transition() [](#method-i-test_different_objects_make_same_transition) - -## test_duplicating_objects() [](#method-i-test_duplicating_objects) - -## test_duplicating_too_complex_objects_memory_leak() [](#method-i-test_duplicating_too_complex_objects_memory_leak) - -## test_evacuate_class_ivar_and_compaction() [](#method-i-test_evacuate_class_ivar_and_compaction) - -## test_evacuate_generic_ivar_and_compaction() [](#method-i-test_evacuate_generic_ivar_and_compaction) - -## test_evacuate_generic_ivar_memory_leak() [](#method-i-test_evacuate_generic_ivar_memory_leak) - -## test_evacuate_object_ivar_and_compaction() [](#method-i-test_evacuate_object_ivar_and_compaction) - -## test_freeze_after_complex() [](#method-i-test_freeze_after_complex) - -## test_freezing_and_cloning_object_with_ivars() [](#method-i-test_freezing_and_cloning_object_with_ivars) - -## test_freezing_and_cloning_objects() [](#method-i-test_freezing_and_cloning_objects) - -## test_freezing_and_cloning_string() [](#method-i-test_freezing_and_cloning_string) - -## test_freezing_and_cloning_string_with_ivars() [](#method-i-test_freezing_and_cloning_string_with_ivars) - -## test_freezing_and_duplicating_object() [](#method-i-test_freezing_and_duplicating_object) - -## test_freezing_and_duplicating_object_with_ivars() [](#method-i-test_freezing_and_duplicating_object_with_ivars) - -## test_freezing_and_duplicating_string_with_ivars() [](#method-i-test_freezing_and_duplicating_string_with_ivars) - -## test_gc_stress_during_evacuate_generic_ivar() [](#method-i-test_gc_stress_during_evacuate_generic_ivar) - -## test_iv_index() [](#method-i-test_iv_index) - -## test_iv_order_correct_on_complex_objects() [](#method-i-test_iv_order_correct_on_complex_objects) - -## test_iv_read_via_method_after_complex() [](#method-i-test_iv_read_via_method_after_complex) - -## test_new_obj_has_t_object_shape() [](#method-i-test_new_obj_has_t_object_shape) - -## test_nil_has_special_const_shape_id() [](#method-i-test_nil_has_special_const_shape_id) - -## test_ordered_alloc_is_not_complex() [](#method-i-test_ordered_alloc_is_not_complex) - -## test_out_of_bounds_shape() [](#method-i-test_out_of_bounds_shape) - -## test_read_iv_after_complex() [](#method-i-test_read_iv_after_complex) - -## test_read_method_after_complex() [](#method-i-test_read_method_after_complex) - -## test_read_undefined_iv_after_complex() [](#method-i-test_read_undefined_iv_after_complex) - -## test_remove_instance_variable() [](#method-i-test_remove_instance_variable) - -## test_remove_instance_variable_capacity_transition() [](#method-i-test_remove_instance_variable_capacity_transition) - -## test_remove_instance_variable_when_out_of_shapes() [](#method-i-test_remove_instance_variable_when_out_of_shapes) - -## test_remove_then_add_again() [](#method-i-test_remove_then_add_again) - -## test_removing_when_too_many_ivs_on_class() [](#method-i-test_removing_when_too_many_ivs_on_class) - -## test_removing_when_too_many_ivs_on_module() [](#method-i-test_removing_when_too_many_ivs_on_module) - -## test_root_shape_transition_to_special_const_on_frozen() [](#method-i-test_root_shape_transition_to_special_const_on_frozen) - -## test_run_out_of_shape_during_remove_instance_variable() [](#method-i-test_run_out_of_shape_during_remove_instance_variable) - -## test_run_out_of_shape_for_class_cvar() [](#method-i-test_run_out_of_shape_for_class_cvar) - -## test_run_out_of_shape_for_class_ivar() [](#method-i-test_run_out_of_shape_for_class_ivar) - -## test_run_out_of_shape_for_module_ivar() [](#method-i-test_run_out_of_shape_for_module_ivar) - -## test_run_out_of_shape_for_object() [](#method-i-test_run_out_of_shape_for_object) - -## test_run_out_of_shape_generic_instance_variable_set() [](#method-i-test_run_out_of_shape_generic_instance_variable_set) - -## test_run_out_of_shape_generic_ivar_set() [](#method-i-test_run_out_of_shape_generic_ivar_set) - -## test_run_out_of_shape_instance_variable_defined() [](#method-i-test_run_out_of_shape_instance_variable_defined) - -## test_run_out_of_shape_instance_variable_defined_on_module() [](#method-i-test_run_out_of_shape_instance_variable_defined_on_module) - -## test_run_out_of_shape_rb_obj_copy_ivar() [](#method-i-test_run_out_of_shape_rb_obj_copy_ivar) - -## test_run_out_of_shape_remove_instance_variable() [](#method-i-test_run_out_of_shape_remove_instance_variable) - -## test_shape_order() [](#method-i-test_shape_order) - -## test_str_has_root_shape() [](#method-i-test_str_has_root_shape) - -## test_too_complex() [](#method-i-test_too_complex) - -## test_too_complex_generic_ivar_ractor_share() [](#method-i-test_too_complex_generic_ivar_ractor_share) - -## test_too_complex_geniv() [](#method-i-test_too_complex_geniv) - -## test_too_complex_obj_ivar_ractor_share() [](#method-i-test_too_complex_obj_ivar_ractor_share) - -## test_too_complex_ractor() [](#method-i-test_too_complex_ractor) - -## test_too_complex_ractor_shareable() [](#method-i-test_too_complex_ractor_shareable) - -## test_too_many_ivs_on_class() [](#method-i-test_too_many_ivs_on_class) - -## test_too_many_ivs_on_obj() [](#method-i-test_too_many_ivs_on_obj) - -## test_true_has_special_const_shape_id() [](#method-i-test_true_has_special_const_shape_id) - -## test_use_all_shapes_module() [](#method-i-test_use_all_shapes_module) - -## test_use_all_shapes_then_freeze() [](#method-i-test_use_all_shapes_then_freeze) - -## test_write_iv_after_complex() [](#method-i-test_write_iv_after_complex) - -## test_write_method_after_complex() [](#method-i-test_write_method_after_complex) - diff --git a/example/ruby/TestShapes/Example.md b/example/ruby/TestShapes/Example.md deleted file mode 100644 index d73424a..0000000 --- a/example/ruby/TestShapes/Example.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestShapes::Example -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Example] a new instance of Example - diff --git a/example/ruby/TestShapes/IVOrder.md b/example/ruby/TestShapes/IVOrder.md deleted file mode 100644 index c0422bc..0000000 --- a/example/ruby/TestShapes/IVOrder.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestShapes::IVOrder -**Inherits:** Object - - - - - -#Instance Methods -## expected_ivs() [](#method-i-expected_ivs) - -## set_ivs() [](#method-i-set_ivs) - diff --git a/example/ruby/TestShapes/OrderedAlloc.md b/example/ruby/TestShapes/OrderedAlloc.md deleted file mode 100644 index e2e1546..0000000 --- a/example/ruby/TestShapes/OrderedAlloc.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestShapes::OrderedAlloc -**Inherits:** Object - - - - - -#Instance Methods -## add_ivars() [](#method-i-add_ivars) - diff --git a/example/ruby/TestShapes/RemoveAndAdd.md b/example/ruby/TestShapes/RemoveAndAdd.md deleted file mode 100644 index e0629e8..0000000 --- a/example/ruby/TestShapes/RemoveAndAdd.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestShapes::RemoveAndAdd -**Inherits:** Object - - - - - -#Instance Methods -## add_bar() [](#method-i-add_bar) - -## add_foo() [](#method-i-add_foo) - -## remove_foo() [](#method-i-remove_foo) - diff --git a/example/ruby/TestShapes/ShapeOrder.md b/example/ruby/TestShapes/ShapeOrder.md deleted file mode 100644 index c8e6bb8..0000000 --- a/example/ruby/TestShapes/ShapeOrder.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestShapes::ShapeOrder -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ShapeOrder] a new instance of ShapeOrder - -## set_b() [](#method-i-set_b) - -## set_c() [](#method-i-set_c) - diff --git a/example/ruby/TestShapes/TestObject.md b/example/ruby/TestShapes/TestObject.md deleted file mode 100644 index d974ea6..0000000 --- a/example/ruby/TestShapes/TestObject.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestShapes::TestObject -**Inherits:** Object - - - - - diff --git a/example/ruby/TestShapes/TooComplex.md b/example/ruby/TestShapes/TooComplex.md deleted file mode 100644 index 16fdcad..0000000 --- a/example/ruby/TestShapes/TooComplex.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TestShapes::TooComplex -**Inherits:** Object - - - - -# Attributes -## b[RW] [](#attribute-i-b) -Returns the value of attribute b. - -## hopefully_unique_name[RW] [](#attribute-i-hopefully_unique_name) -Returns the value of attribute hopefully_unique_name. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [TooComplex] a new instance of TooComplex - -## iv_not_defined() [](#method-i-iv_not_defined) - -## write_iv() [](#method-i-write_iv) - -## write_iv_method() [](#method-i-write_iv_method) - diff --git a/example/ruby/TestShellwords.md b/example/ruby/TestShellwords.md deleted file mode 100644 index 5b296b0..0000000 --- a/example/ruby/TestShellwords.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestShellwords -**Inherits:** Test::Unit::TestCase - -**Includes:** Shellwords - - - - - -#Instance Methods -## test_backslashes() [](#method-i-test_backslashes) - -## test_frozenness() [](#method-i-test_frozenness) - -## test_multibyte_characters() [](#method-i-test_multibyte_characters) - -## test_nul_char() [](#method-i-test_nul_char) - -## test_shellescape() [](#method-i-test_shellescape) - -## test_shellwords() [](#method-i-test_shellwords) - -## test_stringification() [](#method-i-test_stringification) - -## test_unmatched_double_quote() [](#method-i-test_unmatched_double_quote) - -## test_unmatched_quotes() [](#method-i-test_unmatched_quotes) - -## test_unmatched_single_quote() [](#method-i-test_unmatched_single_quote) - -## test_whitespace() [](#method-i-test_whitespace) - diff --git a/example/ruby/TestShiftJIS.md b/example/ruby/TestShiftJIS.md deleted file mode 100644 index 8b22b60..0000000 --- a/example/ruby/TestShiftJIS.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestShiftJIS -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_code_to_mbclen() [](#method-i-test_code_to_mbclen) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_property() [](#method-i-test_property) - diff --git a/example/ruby/TestSignal.md b/example/ruby/TestSignal.md deleted file mode 100644 index 0762d50..0000000 --- a/example/ruby/TestSignal.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: TestSignal -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_exit_action() [](#method-i-test_exit_action) - -## test_hup_me() [](#method-i-test_hup_me) - -## test_ignored_interrupt() [](#method-i-test_ignored_interrupt) - -## test_interrupt() [](#method-i-test_interrupt) - -## test_invalid_signal_name() [](#method-i-test_invalid_signal_name) - -## test_kill_immediately_before_termination() [](#method-i-test_kill_immediately_before_termination) - -## test_reserved_signal() [](#method-i-test_reserved_signal) - -## test_self_stop() [](#method-i-test_self_stop) - -## test_sigexit() [](#method-i-test_sigexit) - -## test_signal() [](#method-i-test_signal) - -## test_signal2() [](#method-i-test_signal2) - -## test_signal_exception() [](#method-i-test_signal_exception) - -## test_signal_list_dedupe_keys() [](#method-i-test_signal_list_dedupe_keys) - -## test_signal_process_group() [](#method-i-test_signal_process_group) - -## test_signame() [](#method-i-test_signame) - -## test_signame_delivered() [](#method-i-test_signame_delivered) - -## test_sigwait_fd_unused() [](#method-i-test_sigwait_fd_unused) - -## test_trap() [](#method-i-test_trap) - -## test_trap_puts() [](#method-i-test_trap_puts) - -## test_trap_system_default() [](#method-i-test_trap_system_default) - diff --git a/example/ruby/TestSingleton.md b/example/ruby/TestSingleton.md deleted file mode 100644 index dd03de4..0000000 --- a/example/ruby/TestSingleton.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestSingleton -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_allocate_raises_exception() [](#method-i-test_allocate_raises_exception) - -## test_class_level_cloning_creates_separate_singleton() [](#method-i-test_class_level_cloning_creates_separate_singleton) - -## test_class_level_cloning_preserves_singleton_behavior() [](#method-i-test_class_level_cloning_preserves_singleton_behavior) - -## test_clone_raises_exception() [](#method-i-test_clone_raises_exception) - -## test_dup_raises_exception() [](#method-i-test_dup_raises_exception) - -## test_extending_singleton_raises_exception() [](#method-i-test_extending_singleton_raises_exception) - -## test_include_in_module_raises_exception() [](#method-i-test_include_in_module_raises_exception) - -## test_inheritance_creates_separate_singleton() [](#method-i-test_inheritance_creates_separate_singleton) - -## test_inheritance_instantiation() [](#method-i-test_inheritance_instantiation) - -## test_inheritance_works_with_overridden_inherited_method() [](#method-i-test_inheritance_works_with_overridden_inherited_method) - -## test_initialize_raises_exception() [](#method-i-test_initialize_raises_exception) - -## test_instance_never_changes() [](#method-i-test_instance_never_changes) - -## test_marshal() [](#method-i-test_marshal) - diff --git a/example/ruby/TestSingleton/SingletonTest.md b/example/ruby/TestSingleton/SingletonTest.md deleted file mode 100644 index e4aafe9..0000000 --- a/example/ruby/TestSingleton/SingletonTest.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: TestSingleton::SingletonTest -**Inherits:** Object - -**Includes:** Singleton - - - - - -#Instance Methods -## _dump(depth-1)) [](#method-i-_dump) -By default, do not retain any state when marshalling. - -## clone() [](#method-i-clone) -Raises a TypeError to prevent cloning. - -**@raise** [TypeError] - -## dup() [](#method-i-dup) -Raises a TypeError to prevent duping. - -**@raise** [TypeError] - diff --git a/example/ruby/TestSleep.md b/example/ruby/TestSleep.md deleted file mode 100644 index 8f14116..0000000 --- a/example/ruby/TestSleep.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSleep -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_sleep_5sec() [](#method-i-test_sleep_5sec) - diff --git a/example/ruby/TestSlowTimeout.md b/example/ruby/TestSlowTimeout.md deleted file mode 100644 index 91b1762..0000000 --- a/example/ruby/TestSlowTimeout.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestSlowTimeout - - - - - -#Instance Methods -## test_slow() [](#method-i-test_slow) - diff --git a/example/ruby/TestSlowV0.md b/example/ruby/TestSlowV0.md deleted file mode 100644 index e6e9f69..0000000 --- a/example/ruby/TestSlowV0.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestSlowV0 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestSlowTimeout - - - - - -#Instance Methods -## test_slow() [](#method-i-test_slow) - diff --git a/example/ruby/TestSlowV1.md b/example/ruby/TestSlowV1.md deleted file mode 100644 index a7ded9a..0000000 --- a/example/ruby/TestSlowV1.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestSlowV1 -**Inherits:** Test::Unit::TestCase - -**Includes:** TestSlowTimeout - - - - - -#Instance Methods -## test_slow() [](#method-i-test_slow) - diff --git a/example/ruby/TestSocket.md b/example/ruby/TestSocket.md deleted file mode 100644 index a640c9f..0000000 --- a/example/ruby/TestSocket.md +++ /dev/null @@ -1,114 +0,0 @@ -# Class: TestSocket -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## errors_addrinuse() [](#method-i-errors_addrinuse) - -## random_port() [](#method-i-random_port) - -## test_accept_loop() [](#method-i-test_accept_loop) - -## test_accept_loop_multi_port() [](#method-i-test_accept_loop_multi_port) - -## test_accept_loop_with_unix() [](#method-i-test_accept_loop_with_unix) - -## test_bind() [](#method-i-test_bind) - -## test_bind_in_rescue() [](#method-i-test_bind_in_rescue) - -## test_bintime() [](#method-i-test_bintime) - -## test_closed_read() [](#method-i-test_closed_read) - -## test_connect_in_rescue() [](#method-i-test_connect_in_rescue) - -## test_connect_timeout() [](#method-i-test_connect_timeout) - -## test_getaddrinfo() [](#method-i-test_getaddrinfo) - -## test_getaddrinfo_raises_no_errors_on_port_argument_of_0() [](#method-i-test_getaddrinfo_raises_no_errors_on_port_argument_of_0) -ruby-core:29427 -: - -## test_getifaddrs() [](#method-i-test_getifaddrs) - -## test_getnameinfo() [](#method-i-test_getnameinfo) - -## test_initialize() [](#method-i-test_initialize) - -## test_ip_address_list() [](#method-i-test_ip_address_list) - -## test_ip_address_list_include_localhost() [](#method-i-test_ip_address_list_include_localhost) - -## test_linger() [](#method-i-test_linger) - -## test_listen_in_rescue() [](#method-i-test_listen_in_rescue) - -## test_recvmsg_udp_no_arg() [](#method-i-test_recvmsg_udp_no_arg) - -## test_resolurion_error_error_code() [](#method-i-test_resolurion_error_error_code) - -## test_socket_new() [](#method-i-test_socket_new) - -## test_socket_new_cloexec() [](#method-i-test_socket_new_cloexec) - -## test_sysaccept() [](#method-i-test_sysaccept) - -## test_tcp() [](#method-i-test_tcp) - -## test_tcp_cloexec() [](#method-i-test_tcp_cloexec) - -## test_tcp_fast_fallback() [](#method-i-test_tcp_fast_fallback) - -## test_tcp_server_sockets() [](#method-i-test_tcp_server_sockets) - -## test_tcp_server_sockets_in_rescue() [](#method-i-test_tcp_server_sockets_in_rescue) - -## test_tcp_server_sockets_port0() [](#method-i-test_tcp_server_sockets_port0) - -## test_tcp_socket_all_hostname_resolution_failed() [](#method-i-test_tcp_socket_all_hostname_resolution_failed) - -## test_tcp_socket_fast_fallback_is_false() [](#method-i-test_tcp_socket_fast_fallback_is_false) - -## test_tcp_socket_one_hostname_resolution_succeeded_at_least() [](#method-i-test_tcp_socket_one_hostname_resolution_succeeded_at_least) - -## test_tcp_socket_resolv_timeout() [](#method-i-test_tcp_socket_resolv_timeout) - -## test_tcp_socket_resolv_timeout_with_connection_failure() [](#method-i-test_tcp_socket_resolv_timeout_with_connection_failure) - -## test_tcp_socket_v4_hostname_resolved_earlier() [](#method-i-test_tcp_socket_v4_hostname_resolved_earlier) - -## test_tcp_socket_v6_address_passed() [](#method-i-test_tcp_socket_v6_address_passed) - -## test_tcp_socket_v6_hostname_resolved_earlier() [](#method-i-test_tcp_socket_v6_hostname_resolved_earlier) - -## test_tcp_socket_v6_hostname_resolved_earlier_and_v6_server_is_not_listening() [](#method-i-test_tcp_socket_v6_hostname_resolved_earlier_and_v6_server_is_not_listening) - -## test_tcp_socket_v6_hostname_resolved_in_resolution_delay() [](#method-i-test_tcp_socket_v6_hostname_resolved_in_resolution_delay) - -## test_timestamp() [](#method-i-test_timestamp) - -## test_timestampns() [](#method-i-test_timestampns) - -## test_udp_read_truncation() [](#method-i-test_udp_read_truncation) - -## test_udp_recv_truncation() [](#method-i-test_udp_recv_truncation) - -## test_udp_recvmsg_truncation() [](#method-i-test_udp_recvmsg_truncation) - -## test_udp_server() [](#method-i-test_udp_server) - -## test_udp_server_sockets_in_rescue() [](#method-i-test_udp_server_sockets_in_rescue) - -## test_unix() [](#method-i-test_unix) - -## test_unix_server_socket() [](#method-i-test_unix_server_socket) - -## test_unpack_sockaddr() [](#method-i-test_unpack_sockaddr) - -## timestamp_retry_rw(s1, s2, t1, type) [](#method-i-timestamp_retry_rw) - diff --git a/example/ruby/TestSocketAddrinfo.md b/example/ruby/TestSocketAddrinfo.md deleted file mode 100644 index 7acf1d3..0000000 --- a/example/ruby/TestSocketAddrinfo.md +++ /dev/null @@ -1,106 +0,0 @@ -# Class: TestSocketAddrinfo -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## errors_addrinuse() [](#method-i-errors_addrinuse) - -## ipv6(str) [](#method-i-ipv6) - -## random_port() [](#method-i-random_port) - -## tcp_unspecified_to_loopback(addrinfo) [](#method-i-tcp_unspecified_to_loopback) - -## test_addrinfo_inspect_sockaddr() [](#method-i-test_addrinfo_inspect_sockaddr) - -## test_addrinfo_inspect_sockaddr_inet6() [](#method-i-test_addrinfo_inspect_sockaddr_inet6) - -## test_addrinfo_inspect_sockaddr_unix() [](#method-i-test_addrinfo_inspect_sockaddr_unix) - -## test_addrinfo_ip() [](#method-i-test_addrinfo_ip) - -## test_addrinfo_ip_unpack() [](#method-i-test_addrinfo_ip_unpack) - -## test_addrinfo_ip_unpack_inet6() [](#method-i-test_addrinfo_ip_unpack_inet6) - -## test_addrinfo_new_inet() [](#method-i-test_addrinfo_new_inet) - -## test_addrinfo_new_inet6() [](#method-i-test_addrinfo_new_inet6) - -## test_addrinfo_new_unix() [](#method-i-test_addrinfo_new_unix) - -## test_addrinfo_predicates() [](#method-i-test_addrinfo_predicates) - -## test_addrinfo_predicates_unix() [](#method-i-test_addrinfo_predicates_unix) - -## test_addrinfo_tcp() [](#method-i-test_addrinfo_tcp) - -## test_addrinfo_timeout() [](#method-i-test_addrinfo_timeout) - -## test_addrinfo_udp() [](#method-i-test_addrinfo_udp) - -## test_addrinfo_unix() [](#method-i-test_addrinfo_unix) - -## test_addrinfo_unix_dgram() [](#method-i-test_addrinfo_unix_dgram) - -## test_addrinfo_unix_path() [](#method-i-test_addrinfo_unix_path) - -## test_basicsocket_local_address() [](#method-i-test_basicsocket_local_address) - -## test_basicsocket_remote_address() [](#method-i-test_basicsocket_remote_address) - -## test_basicsocket_send() [](#method-i-test_basicsocket_send) - -## test_bind() [](#method-i-test_bind) - -## test_connect() [](#method-i-test_connect) - -## test_connect_from() [](#method-i-test_connect_from) - -## test_connect_to() [](#method-i-test_connect_to) - -## test_error_message() [](#method-i-test_error_message) - -## test_family_addrinfo() [](#method-i-test_family_addrinfo) - -## test_ipv4_address_predicates() [](#method-i-test_ipv4_address_predicates) - -## test_ipv6_address_predicates() [](#method-i-test_ipv6_address_predicates) - -## test_ipv6_to_ipv4() [](#method-i-test_ipv6_to_ipv4) - -## test_listen() [](#method-i-test_listen) - -## test_marshal() [](#method-i-test_marshal) - -## test_marshal_inet6() [](#method-i-test_marshal_inet6) - -## test_marshal_memory_leak() [](#method-i-test_marshal_memory_leak) - -## test_marshal_unix() [](#method-i-test_marshal_unix) - -## test_s_foreach() [](#method-i-test_s_foreach) - -## test_socket_accept() [](#method-i-test_socket_accept) - -## test_socket_accept_nonblock() [](#method-i-test_socket_accept_nonblock) - -## test_socket_bind() [](#method-i-test_socket_bind) - -## test_socket_connect() [](#method-i-test_socket_connect) - -## test_socket_connect_nonblock() [](#method-i-test_socket_connect_nonblock) - -## test_socket_getnameinfo() [](#method-i-test_socket_getnameinfo) - -## test_socket_recvfrom() [](#method-i-test_socket_recvfrom) - -## test_socket_recvfrom_nonblock() [](#method-i-test_socket_recvfrom_nonblock) - -## test_socket_sysaccept() [](#method-i-test_socket_sysaccept) - -## test_udpsocket_send() [](#method-i-test_udpsocket_send) - diff --git a/example/ruby/TestSocketAncData.md b/example/ruby/TestSocketAncData.md deleted file mode 100644 index 4aee334..0000000 --- a/example/ruby/TestSocketAncData.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestSocketAncData -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_int() [](#method-i-test_int) - -## test_ip_pktinfo() [](#method-i-test_ip_pktinfo) - -## test_ipv6_pktinfo() [](#method-i-test_ipv6_pktinfo) - -## test_unix_rights() [](#method-i-test_unix_rights) - diff --git a/example/ruby/TestSocketNonblock.md b/example/ruby/TestSocketNonblock.md deleted file mode 100644 index 7ebc583..0000000 --- a/example/ruby/TestSocketNonblock.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: TestSocketNonblock -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## tcp_pair() [](#method-i-tcp_pair) - -## test_accept_nonblock() [](#method-i-test_accept_nonblock) - -## test_accept_nonblock_error() [](#method-i-test_accept_nonblock_error) - -## test_connect_nonblock() [](#method-i-test_connect_nonblock) - -## test_connect_nonblock_error() [](#method-i-test_connect_nonblock_error) - -## test_connect_nonblock_no_exception() [](#method-i-test_connect_nonblock_no_exception) - -## test_read_nonblock() [](#method-i-test_read_nonblock) - -## test_read_nonblock_no_exception() [](#method-i-test_read_nonblock_no_exception) - -## test_recv_nonblock_error() [](#method-i-test_recv_nonblock_error) - -## test_recv_nonblock_no_exception() [](#method-i-test_recv_nonblock_no_exception) - -## test_recvfrom_nonblock_no_exception() [](#method-i-test_recvfrom_nonblock_no_exception) - -## test_recvmsg_nonblock_error() [](#method-i-test_recvmsg_nonblock_error) - -## test_sendmsg_nonblock_error() [](#method-i-test_sendmsg_nonblock_error) -def test_write_nonblock - c, s = tcp_pair - str = "a" * 10000 - _, ws, _ = IO.select(nil, [c], nil) - assert_equal([c], ws) - ret = c.write_nonblock(str) - assert_operator(ret, :>, 0) - loop { - assert_raise(IO::WaitWritable) { - loop { - ret = c.write_nonblock(str) - assert_operator(ret, :>, 0) - } - } - _, ws, _ = IO.select(nil, [c], nil, 0) - break if !ws - } - ensure - c.close if c - s.close if s - end - -## test_sendmsg_nonblock_no_exception() [](#method-i-test_sendmsg_nonblock_no_exception) - -## test_sendmsg_nonblock_seqpacket() [](#method-i-test_sendmsg_nonblock_seqpacket) - -## test_socket_recvfrom_nonblock() [](#method-i-test_socket_recvfrom_nonblock) - -## test_tcp_recv_nonblock() [](#method-i-test_tcp_recv_nonblock) - -## test_udp_recv_nonblock() [](#method-i-test_udp_recv_nonblock) - -## test_udp_recvfrom_nonblock() [](#method-i-test_udp_recvfrom_nonblock) - -## udp_pair() [](#method-i-udp_pair) - diff --git a/example/ruby/TestSocketOption.md b/example/ruby/TestSocketOption.md deleted file mode 100644 index c819759..0000000 --- a/example/ruby/TestSocketOption.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestSocketOption -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_bool() [](#method-i-test_bool) - -## test_ipv4_multicast_loop() [](#method-i-test_ipv4_multicast_loop) - -## test_ipv4_multicast_loop_size() [](#method-i-test_ipv4_multicast_loop_size) - -## test_ipv4_multicast_ttl() [](#method-i-test_ipv4_multicast_ttl) - -## test_ipv4_multicast_ttl_size() [](#method-i-test_ipv4_multicast_ttl_size) - -## test_new() [](#method-i-test_new) - -## test_unpack() [](#method-i-test_unpack) - diff --git a/example/ruby/TestSocket_BasicSocket.md b/example/ruby/TestSocket_BasicSocket.md deleted file mode 100644 index e8b8a3d..0000000 --- a/example/ruby/TestSocket_BasicSocket.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestSocket_BasicSocket -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## inet_stream() [](#method-i-inet_stream) - -## socks() [](#method-i-socks) - -## test_close_read() [](#method-i-test_close_read) - -## test_close_write() [](#method-i-test_close_write) - -## test_for_fd() [](#method-i-test_for_fd) - -## test_getsockopt() [](#method-i-test_getsockopt) - -## test_listen() [](#method-i-test_listen) - -## test_read_nonblock_mix_buffered() [](#method-i-test_read_nonblock_mix_buffered) - -## test_read_write_nonblock() [](#method-i-test_read_write_nonblock) - -## test_setsockopt() [](#method-i-test_setsockopt) - -## test_write_nonblock_buffered() [](#method-i-test_write_nonblock_buffered) - diff --git a/example/ruby/TestSocket_TCPSocket.md b/example/ruby/TestSocket_TCPSocket.md deleted file mode 100644 index c8f9708..0000000 --- a/example/ruby/TestSocket_TCPSocket.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: TestSocket_TCPSocket -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_accept_multithread() [](#method-i-test_accept_multithread) - -## test_accept_nonblock() [](#method-i-test_accept_nonblock) - -## test_encoding() [](#method-i-test_encoding) - -## test_initialize_connect_timeout() [](#method-i-test_initialize_connect_timeout) - -## test_initialize_failure() [](#method-i-test_initialize_failure) - -## test_initialize_fast_fallback_is_false() [](#method-i-test_initialize_fast_fallback_is_false) - -## test_initialize_resolv_timeout() [](#method-i-test_initialize_resolv_timeout) - -## test_initialize_resolv_timeout_with_connection_failure() [](#method-i-test_initialize_resolv_timeout_with_connection_failure) - -## test_initialize_v4_connected_socket_with_v4_address() [](#method-i-test_initialize_v4_connected_socket_with_v4_address) - -## test_initialize_v4_hostname_resolved_earlier() [](#method-i-test_initialize_v4_hostname_resolved_earlier) - -## test_initialize_v6_connected_socket_with_v6_address() [](#method-i-test_initialize_v6_connected_socket_with_v6_address) - -## test_initialize_v6_hostname_resolution_failed_and_v4_hostname_resolution_is_success() [](#method-i-test_initialize_v6_hostname_resolution_failed_and_v4_hostname_resolution_is_success) - -## test_initialize_v6_hostname_resolved_earlier() [](#method-i-test_initialize_v6_hostname_resolved_earlier) - -## test_initialize_v6_hostname_resolved_earlier_and_v6_server_is_not_listening() [](#method-i-test_initialize_v6_hostname_resolved_earlier_and_v6_server_is_not_listening) - -## test_initialize_v6_hostname_resolved_in_resolution_delay() [](#method-i-test_initialize_v6_hostname_resolved_in_resolution_delay) - -## test_initialize_v6_hostname_resolved_later_and_v6_server_is_not_listening() [](#method-i-test_initialize_v6_hostname_resolved_later_and_v6_server_is_not_listening) - -## test_initialize_with_connection_failure_after_hostname_resolution_failure() [](#method-i-test_initialize_with_connection_failure_after_hostname_resolution_failure) - -## test_initialize_with_hostname_resolution_failure_after_connection_failure() [](#method-i-test_initialize_with_hostname_resolution_failure_after_connection_failure) - -## test_inspect() [](#method-i-test_inspect) - -## test_recvfrom() [](#method-i-test_recvfrom) - diff --git a/example/ruby/TestSocket_UDPSocket.md b/example/ruby/TestSocket_UDPSocket.md deleted file mode 100644 index e2a7981..0000000 --- a/example/ruby/TestSocket_UDPSocket.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestSocket_UDPSocket -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_bind() [](#method-i-test_bind) - -## test_bind_addrinuse() [](#method-i-test_bind_addrinuse) - -## test_bind_no_memory_leak() [](#method-i-test_bind_no_memory_leak) - -## test_connect() [](#method-i-test_connect) - -## test_connect_no_memory_leak() [](#method-i-test_connect_no_memory_leak) - -## test_inspect() [](#method-i-test_inspect) - -## test_open() [](#method-i-test_open) - -## test_send_no_memory_leak() [](#method-i-test_send_no_memory_leak) - -## test_send_too_long() [](#method-i-test_send_too_long) - diff --git a/example/ruby/TestSocket_UNIXSocket.md b/example/ruby/TestSocket_UNIXSocket.md deleted file mode 100644 index 4e80414..0000000 --- a/example/ruby/TestSocket_UNIXSocket.md +++ /dev/null @@ -1,98 +0,0 @@ -# Class: TestSocket_UNIXSocket -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## bound_unix_socket(klass) [](#method-i-bound_unix_socket) - -## test_abstract_namespace() [](#method-i-test_abstract_namespace) - -## test_abstract_unix_server() [](#method-i-test_abstract_unix_server) - -## test_abstract_unix_server_socket() [](#method-i-test_abstract_unix_server_socket) - -## test_abstract_unix_socket_econnrefused() [](#method-i-test_abstract_unix_socket_econnrefused) - -## test_accept_nonblock() [](#method-i-test_accept_nonblock) - -## test_addr() [](#method-i-test_addr) - -## test_autobind() [](#method-i-test_autobind) - -## test_cloexec() [](#method-i-test_cloexec) - -## test_dgram_pair() [](#method-i-test_dgram_pair) - -## test_dgram_pair_sendrecvmsg_errno_set() [](#method-i-test_dgram_pair_sendrecvmsg_errno_set) - -## test_epipe() [](#method-i-test_epipe) - -## test_fd_passing() [](#method-i-test_fd_passing) - -## test_fd_passing_class_mode() [](#method-i-test_fd_passing_class_mode) - -## test_fd_passing_n() [](#method-i-test_fd_passing_n) - -## test_fd_passing_n2() [](#method-i-test_fd_passing_n2) - -## test_fd_passing_race_condition() [](#method-i-test_fd_passing_race_condition) - -## test_getcred_ucred() [](#method-i-test_getcred_ucred) - -## test_getcred_xucred() [](#method-i-test_getcred_xucred) - -## test_getpeereid() [](#method-i-test_getpeereid) - -## test_initialize() [](#method-i-test_initialize) - -## test_noname_addr() [](#method-i-test_noname_addr) - -## test_noname_path() [](#method-i-test_noname_path) - -## test_noname_peeraddr() [](#method-i-test_noname_peeraddr) - -## test_noname_recv_nonblock() [](#method-i-test_noname_recv_nonblock) - -## test_noname_recvfrom() [](#method-i-test_noname_recvfrom) - -## test_noname_unpack_sockaddr_un() [](#method-i-test_noname_unpack_sockaddr_un) - -## test_open_nul_byte() [](#method-i-test_open_nul_byte) - -## test_recvmsg() [](#method-i-test_recvmsg) - -## test_sendcred_cmsgcred() [](#method-i-test_sendcred_cmsgcred) - -## test_sendcred_sockcred() [](#method-i-test_sendcred_sockcred) - -## test_sendcred_ucred() [](#method-i-test_sendcred_ucred) - -## test_sendmsg() [](#method-i-test_sendmsg) - -## test_sendmsg_ancillarydata_int() [](#method-i-test_sendmsg_ancillarydata_int) - -## test_sendmsg_ancillarydata_unix_rights() [](#method-i-test_sendmsg_ancillarydata_unix_rights) - -## test_seqpacket_pair() [](#method-i-test_seqpacket_pair) - -## test_socket_pair_with_block() [](#method-i-test_socket_pair_with_block) - -## test_stream_pair() [](#method-i-test_stream_pair) - -## test_too_long_path() [](#method-i-test_too_long_path) - -## test_unix_server_socket() [](#method-i-test_unix_server_socket) - -## test_unix_socket_pair_close_on_exec() [](#method-i-test_unix_socket_pair_close_on_exec) - -## test_unix_socket_pair_with_block() [](#method-i-test_unix_socket_pair_with_block) - -## test_unix_socket_with_encoding() [](#method-i-test_unix_socket_with_encoding) - -## test_windows_unix_socket_pair_paths() [](#method-i-test_windows_unix_socket_pair_paths) - -## test_windows_unix_socket_pair_with_umlaut() [](#method-i-test_windows_unix_socket_pair_with_umlaut) - diff --git a/example/ruby/TestSprintf.md b/example/ruby/TestSprintf.md deleted file mode 100644 index 76f93be..0000000 --- a/example/ruby/TestSprintf.md +++ /dev/null @@ -1,74 +0,0 @@ -# Class: TestSprintf -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_bignum() [](#method-i-test_bignum) - -## test_binary() [](#method-i-test_binary) - -## test_binary_format_coderange() [](#method-i-test_binary_format_coderange) - -## test_char() [](#method-i-test_char) - -## test_coderange() [](#method-i-test_coderange) - -## test_escape() [](#method-i-test_escape) - -## test_float() [](#method-i-test_float) - -## test_float2() [](#method-i-test_float2) - -## test_float_hex() [](#method-i-test_float_hex) - -## test_float_prec() [](#method-i-test_float_prec) - -## test_hash() [](#method-i-test_hash) - -## test_inf() [](#method-i-test_inf) - -## test_inspect() [](#method-i-test_inspect) - -## test_integer() [](#method-i-test_integer) - -## test_invalid() [](#method-i-test_invalid) - -## test_named_default() [](#method-i-test_named_default) - -## test_named_typed() [](#method-i-test_named_typed) - -## test_named_typed_enc() [](#method-i-test_named_typed_enc) - -## test_named_untyped() [](#method-i-test_named_untyped) - -## test_named_untyped_enc() [](#method-i-test_named_untyped_enc) - -## test_named_with_nil() [](#method-i-test_named_with_nil) - -## test_nan() [](#method-i-test_nan) - -## test_negative_hex() [](#method-i-test_negative_hex) - -## test_negative_width_overflow() [](#method-i-test_negative_width_overflow) - -## test_percent_sign_at_end() [](#method-i-test_percent_sign_at_end) - -## test_positional() [](#method-i-test_positional) - -## test_rational() [](#method-i-test_rational) - -## test_rational_precision() [](#method-i-test_rational_precision) - -## test_rb_sprintf() [](#method-i-test_rb_sprintf) - -## test_skip() [](#method-i-test_skip) - -## test_star() [](#method-i-test_star) - -## test_string() [](#method-i-test_string) - -## test_width_underflow() [](#method-i-test_width_underflow) - diff --git a/example/ruby/TestSprintf/T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.md b/example/ruby/TestSprintf/T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.md deleted file mode 100644 index 207f35f..0000000 --- a/example/ruby/TestSprintf/T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestSprintf::T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 -**Inherits:** Object - - - - - diff --git a/example/ruby/TestSprintfComb.md b/example/ruby/TestSprintfComb.md deleted file mode 100644 index fd3811d..0000000 --- a/example/ruby/TestSprintfComb.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestSprintfComb -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## assertions_format_float(format ) [](#method-c-assertions_format_float) -## assertions_format_integer(format ) [](#method-c-assertions_format_integer) -## combination(*args , &b ) [](#method-c-combination) - -#Instance Methods -## emu_e(sp, hs, pl, mi, zr, width, precision, type, v, sign, int, exp) [](#method-i-emu_e) - -## emu_f(sp, hs, pl, mi, zr, width, precision, type, sign, int, exp) [](#method-i-emu_f) - -## emu_float(format, v) [](#method-i-emu_float) - -## emu_int(format, v) [](#method-i-emu_int) - -## split_float10(v) [](#method-i-split_float10) - diff --git a/example/ruby/TestStack.md b/example/ruby/TestStack.md deleted file mode 100644 index a1cc55d..0000000 --- a/example/ruby/TestStack.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: TestStack -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## h_0() [](#method-i-h_0) - -## h_default() [](#method-i-h_default) - -## h_large() [](#method-i-h_large) - -## initialize() [](#method-i-initialize) - -**@return** [TestStack] a new instance of TestStack - -## invoke_ruby(script, vm_stack_size:nil, machine_stack_size:nil) [](#method-i-invoke_ruby) - -## test_machine_stack_size() [](#method-i-test_machine_stack_size) -Depending on OS, machine stack size may not change size. - -## test_relative_stack_sizes() [](#method-i-test_relative_stack_sizes) - -## test_vm_stack_size() [](#method-i-test_vm_stack_size) - diff --git a/example/ruby/TestString.md b/example/ruby/TestString.md deleted file mode 100644 index 1007b23..0000000 --- a/example/ruby/TestString.md +++ /dev/null @@ -1,478 +0,0 @@ -# Class: TestString -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## to_str() [](#method-c-to_str) - -#Instance Methods -## S(*args, **kw) [](#method-i-S) - -## casetest(a, b, revfalse) [](#method-i-casetest) - -## check_sum(str, bits16) [](#method-i-check_sum) - -## crypt_supports_des_crypt?() [](#method-i-crypt_supports_des_crypt?) - -**@return** [Boolean] - -## initialize(*args) [](#method-i-initialize) - -**@return** [TestString] a new instance of TestString - -## test_AREF() [](#method-i-test_AREF) -'[]' - -## test_AREF_invalid_encoding() [](#method-i-test_AREF_invalid_encoding) - -## test_AREF_underflow() [](#method-i-test_AREF_underflow) - -## test_ASET() [](#method-i-test_ASET) -'[]=' - -## test_CMP() [](#method-i-test_CMP) -'<=>' - -## test_EQUAL() [](#method-i-test_EQUAL) -'==' - -## test_LSHIFT() [](#method-i-test_LSHIFT) -'<<' - -## test_LSHIFT_neary_long_max() [](#method-i-test_LSHIFT_neary_long_max) - -## test_MATCH() [](#method-i-test_MATCH) -'=~' - -## test_MOD() [](#method-i-test_MOD) -'%' - -## test_MUL() [](#method-i-test_MUL) -'*' - -## test_PLUS() [](#method-i-test_PLUS) -'+' - -## test_VERY_EQUAL() [](#method-i-test_VERY_EQUAL) -'===' - -## test_append_bytes_into_binary() [](#method-i-test_append_bytes_into_binary) - -## test_append_bytes_into_utf32() [](#method-i-test_append_bytes_into_utf32) - -## test_append_bytes_into_utf8() [](#method-i-test_append_bytes_into_utf8) - -## test_ascii_incomat_inspect() [](#method-i-test_ascii_incomat_inspect) - -## test_byteindex() [](#method-i-test_byteindex) - -## test_byterindex() [](#method-i-test_byterindex) - -## test_bytes() [](#method-i-test_bytes) - -## test_byteslice() [](#method-i-test_byteslice) - -## test_byteslice_grapheme_clusters() [](#method-i-test_byteslice_grapheme_clusters) - -## test_bytesplice() [](#method-i-test_bytesplice) - -## test_capitalize() [](#method-i-test_capitalize) - -## test_capitalize!() [](#method-i-test_capitalize!) - -## test_casecmp() [](#method-i-test_casecmp) -def test_compare_different_encoding_string - s1 = S("\xff".force_encoding("UTF-8")) - s2 = S("\xff".force_encoding("ISO-2022-JP")) - assert_equal([-1, 1], [s1 <=> s2, s2 <=> s1].sort) - end - -## test_casecmp?() [](#method-i-test_casecmp?) - -**@return** [Boolean] - -## test_center() [](#method-i-test_center) - -## test_chars() [](#method-i-test_chars) - -## test_chilled_string() [](#method-i-test_chilled_string) - -## test_chilled_string_setivar() [](#method-i-test_chilled_string_setivar) - -## test_chilled_string_substring() [](#method-i-test_chilled_string_substring) - -## test_chomp() [](#method-i-test_chomp) - -## test_chomp!() [](#method-i-test_chomp!) - -## test_chop() [](#method-i-test_chop) - -## test_chop!() [](#method-i-test_chop!) - -## test_chr() [](#method-i-test_chr) - -## test_clear() [](#method-i-test_clear) - -## test_clear_nonasciicompat() [](#method-i-test_clear_nonasciicompat) - -## test_clone() [](#method-i-test_clone) - -## test_codepoints() [](#method-i-test_codepoints) - -## test_concat() [](#method-i-test_concat) - -## test_concat_literals() [](#method-i-test_concat_literals) - -## test_count() [](#method-i-test_count) - -## test_crypt() [](#method-i-test_crypt) - -## test_delete() [](#method-i-test_delete) - -## test_delete!() [](#method-i-test_delete!) - -## test_delete_prefix() [](#method-i-test_delete_prefix) - -## test_delete_prefix_argument_conversion() [](#method-i-test_delete_prefix_argument_conversion) - -## test_delete_prefix_bang() [](#method-i-test_delete_prefix_bang) - -## test_delete_prefix_bang_argument_conversion() [](#method-i-test_delete_prefix_bang_argument_conversion) - -## test_delete_prefix_bang_broken_encoding() [](#method-i-test_delete_prefix_bang_broken_encoding) - -## test_delete_prefix_bang_clear_coderange() [](#method-i-test_delete_prefix_bang_clear_coderange) - -## test_delete_prefix_bang_frozen_error() [](#method-i-test_delete_prefix_bang_frozen_error) - -## test_delete_prefix_bang_type_error() [](#method-i-test_delete_prefix_bang_type_error) - -## test_delete_prefix_broken_encoding() [](#method-i-test_delete_prefix_broken_encoding) - -## test_delete_prefix_clear_coderange() [](#method-i-test_delete_prefix_clear_coderange) - -## test_delete_prefix_type_error() [](#method-i-test_delete_prefix_type_error) - -## test_delete_suffix() [](#method-i-test_delete_suffix) - -## test_delete_suffix_argument_conversion() [](#method-i-test_delete_suffix_argument_conversion) - -## test_delete_suffix_bang() [](#method-i-test_delete_suffix_bang) - -## test_delete_suffix_bang_argument_conversion() [](#method-i-test_delete_suffix_bang_argument_conversion) - -## test_delete_suffix_bang_broken_encoding() [](#method-i-test_delete_suffix_bang_broken_encoding) - -## test_delete_suffix_bang_clear_coderange() [](#method-i-test_delete_suffix_bang_clear_coderange) - -## test_delete_suffix_bang_frozen_error() [](#method-i-test_delete_suffix_bang_frozen_error) - -## test_delete_suffix_bang_newline() [](#method-i-test_delete_suffix_bang_newline) - -## test_delete_suffix_bang_type_error() [](#method-i-test_delete_suffix_bang_type_error) - -## test_delete_suffix_broken_encoding() [](#method-i-test_delete_suffix_broken_encoding) - -## test_delete_suffix_clear_coderange() [](#method-i-test_delete_suffix_clear_coderange) - -## test_delete_suffix_newline() [](#method-i-test_delete_suffix_newline) - -## test_delete_suffix_type_error() [](#method-i-test_delete_suffix_type_error) - -## test_downcase() [](#method-i-test_downcase) - -## test_downcase!() [](#method-i-test_downcase!) - -## test_downcase2() [](#method-i-test_downcase2) - -## test_dummy_inspect() [](#method-i-test_dummy_inspect) - -## test_dump() [](#method-i-test_dump) - -## test_dup() [](#method-i-test_dup) - -## test_each() [](#method-i-test_each) - -## test_each_byte() [](#method-i-test_each_byte) - -## test_each_char() [](#method-i-test_each_char) - -## test_each_codepoint() [](#method-i-test_each_codepoint) - -## test_each_grapheme_cluster() [](#method-i-test_each_grapheme_cluster) - -## test_each_line() [](#method-i-test_each_line) - -## test_each_line_chomp() [](#method-i-test_each_line_chomp) - -## test_empty?() [](#method-i-test_empty?) - -**@return** [Boolean] - -## test_end_with?() [](#method-i-test_end_with?) - -**@return** [Boolean] - -## test_eq_tilde_can_be_overridden() [](#method-i-test_eq_tilde_can_be_overridden) - -## test_eql?() [](#method-i-test_eql?) - -**@return** [Boolean] - -## test_frozen_check() [](#method-i-test_frozen_check) - -## test_fs() [](#method-i-test_fs) - -## test_fs_setter() [](#method-i-test_fs_setter) - -## test_grapheme_clusters() [](#method-i-test_grapheme_clusters) - -## test_grapheme_clusters_memory_leak() [](#method-i-test_grapheme_clusters_memory_leak) - -## test_gsub() [](#method-i-test_gsub) - -## test_gsub!() [](#method-i-test_gsub!) - -## test_gsub_bang_gc_compact_stress() [](#method-i-test_gsub_bang_gc_compact_stress) - -## test_gsub_encoding() [](#method-i-test_gsub_encoding) - -## test_gsub_enumerator() [](#method-i-test_gsub_enumerator) - -## test_gsub_gc_compact_stress() [](#method-i-test_gsub_gc_compact_stress) - -## test_gsub_hash() [](#method-i-test_gsub_hash) - -## test_hash() [](#method-i-test_hash) - -## test_hex() [](#method-i-test_hex) - -## test_include?() [](#method-i-test_include?) - -**@return** [Boolean] - -## test_index() [](#method-i-test_index) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_memory_leak() [](#method-i-test_initialize_memory_leak) - -## test_initialize_nofree_memory_leak() [](#method-i-test_initialize_nofree_memory_leak) -Bug #18154 - -## test_initialize_nonstring() [](#method-i-test_initialize_nonstring) - -## test_initialize_shared() [](#method-i-test_initialize_shared) - -## test_insert() [](#method-i-test_insert) - -## test_inspect_next_line() [](#method-i-test_inspect_next_line) - -## test_inspect_nul() [](#method-i-test_inspect_nul) - -## test_intern() [](#method-i-test_intern) - -## test_ivar_set_after_frozen_dup() [](#method-i-test_ivar_set_after_frozen_dup) - -## test_length() [](#method-i-test_length) - -## test_lines() [](#method-i-test_lines) - -## test_ljust() [](#method-i-test_ljust) - -## test_lstrip() [](#method-i-test_lstrip) - -## test_lstrip_bang() [](#method-i-test_lstrip_bang) - -## test_match_method() [](#method-i-test_match_method) - -## test_match_p_regexp() [](#method-i-test_match_p_regexp) - -## test_match_p_string() [](#method-i-test_match_p_string) - -## test_mod_check() [](#method-i-test_mod_check) - -## test_nesting_shared() [](#method-i-test_nesting_shared) -def test_symbol_table_overflow - assert_in_out_err([], <<-INPUT, [], /symbol table overflow \(symbol [a-z]{8}\) \(RuntimeError\)/) - ("aaaaaaaa".."zzzzzzzz").each {|s| s.to_sym } - INPUT - end - -## test_nesting_shared_b() [](#method-i-test_nesting_shared_b) - -## test_next() [](#method-i-test_next) - -## test_next!() [](#method-i-test_next!) - -## test_oct() [](#method-i-test_oct) - -## test_ord() [](#method-i-test_ord) - -## test_partition() [](#method-i-test_partition) - -## test_prepend() [](#method-i-test_prepend) - -## test_rb_str_new4() [](#method-i-test_rb_str_new4) - -## test_rb_str_shared_replace() [](#method-i-test_rb_str_shared_replace) - -## test_rb_str_to_str() [](#method-i-test_rb_str_to_str) - -## test_regexp_match_subclass() [](#method-i-test_regexp_match_subclass) - -## test_replace() [](#method-i-test_replace) - -## test_respond_to() [](#method-i-test_respond_to) - -## test_reverse() [](#method-i-test_reverse) - -## test_reverse!() [](#method-i-test_reverse!) - -## test_rindex() [](#method-i-test_rindex) - -## test_rjust() [](#method-i-test_rjust) - -## test_rpartition() [](#method-i-test_rpartition) - -## test_rstrip() [](#method-i-test_rstrip) - -## test_rstrip_bang() [](#method-i-test_rstrip_bang) - -## test_s_new() [](#method-i-test_s_new) - -## test_scan() [](#method-i-test_scan) - -## test_scan_gc_compact_stress() [](#method-i-test_scan_gc_compact_stress) - -## test_scan_segv() [](#method-i-test_scan_segv) - -## test_shared_force_encoding() [](#method-i-test_shared_force_encoding) - -## test_size() [](#method-i-test_size) - -## test_slice() [](#method-i-test_slice) - -## test_slice!() [](#method-i-test_slice!) - -## test_splice!() [](#method-i-test_splice!) - -## test_split() [](#method-i-test_split) - -## test_split_dupped() [](#method-i-test_split_dupped) - -## test_split_encoding() [](#method-i-test_split_encoding) - -## test_split_invalid_argument() [](#method-i-test_split_invalid_argument) - -## test_split_invalid_sequence() [](#method-i-test_split_invalid_sequence) - -## test_split_lookbehind() [](#method-i-test_split_lookbehind) - -## test_split_wchar() [](#method-i-test_split_wchar) - -## test_split_with_block() [](#method-i-test_split_with_block) - -## test_squeeze() [](#method-i-test_squeeze) - -## test_squeeze!() [](#method-i-test_squeeze!) - -## test_start_with?() [](#method-i-test_start_with?) - -**@return** [Boolean] - -## test_start_with_regexp() [](#method-i-test_start_with_regexp) - -## test_start_with_timeout_memory_leak() [](#method-i-test_start_with_timeout_memory_leak) - -## test_str_new4() [](#method-i-test_str_new4) - -## test_string_interpolations_across_heaps_get_embedded() [](#method-i-test_string_interpolations_across_heaps_get_embedded) - -## test_strip() [](#method-i-test_strip) - -## test_strip!() [](#method-i-test_strip!) - -## test_sub() [](#method-i-test_sub) - -## test_sub!() [](#method-i-test_sub!) - -## test_sub_gc_compact_stress() [](#method-i-test_sub_gc_compact_stress) - -## test_sub_hash() [](#method-i-test_sub_hash) - -## test_substr_code_range() [](#method-i-test_substr_code_range) - -## test_substr_negative_begin() [](#method-i-test_substr_negative_begin) - -## test_succ() [](#method-i-test_succ) - -## test_succ!() [](#method-i-test_succ!) - -## test_sum() [](#method-i-test_sum) - -## test_sum_2() [](#method-i-test_sum_2) - -## test_sum_long() [](#method-i-test_sum_long) - -## test_swapcase() [](#method-i-test_swapcase) - -## test_swapcase!() [](#method-i-test_swapcase!) - -## test_times() [](#method-i-test_times) - -## test_times2() [](#method-i-test_times2) - -## test_to_f() [](#method-i-test_to_f) - -## test_to_i() [](#method-i-test_to_i) - -## test_to_id() [](#method-i-test_to_id) - -## test_to_s() [](#method-i-test_to_s) - -## test_to_s_2() [](#method-i-test_to_s_2) - -## test_to_str() [](#method-i-test_to_str) - -## test_tr() [](#method-i-test_tr) - -## test_tr!() [](#method-i-test_tr!) - -## test_tr_s() [](#method-i-test_tr_s) - -## test_tr_s!() [](#method-i-test_tr_s!) - -## test_try_convert() [](#method-i-test_try_convert) - -## test_uminus_frozen() [](#method-i-test_uminus_frozen) - -## test_uminus_no_freeze_not_bare() [](#method-i-test_uminus_no_freeze_not_bare) - -## test_undump() [](#method-i-test_undump) - -## test_undump_gc_compact_stress() [](#method-i-test_undump_gc_compact_stress) - -## test_unknown_string_option() [](#method-i-test_unknown_string_option) - -## test_unpack() [](#method-i-test_unpack) - -## test_upcase() [](#method-i-test_upcase) - -## test_upcase!() [](#method-i-test_upcase!) - -## test_upcase2() [](#method-i-test_upcase2) - -## test_uplus_minus() [](#method-i-test_uplus_minus) -enable only when string size range is smaller than memory space - -## test_upto() [](#method-i-test_upto) - -## test_upto_nonalnum() [](#method-i-test_upto_nonalnum) - -## test_upto_numeric() [](#method-i-test_upto_numeric) - -## u(str) [](#method-i-u) - diff --git a/example/ruby/TestString/Bug9581.md b/example/ruby/TestString/Bug9581.md deleted file mode 100644 index 90bcec0..0000000 --- a/example/ruby/TestString/Bug9581.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestString::Bug9581 -**Inherits:** String - - - - - -#Instance Methods -## =~(re) [](#method-i-=~) - diff --git a/example/ruby/TestString/S2.md b/example/ruby/TestString/S2.md deleted file mode 100644 index 56bb5b1..0000000 --- a/example/ruby/TestString/S2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestString::S2 -**Inherits:** String - - - - - diff --git a/example/ruby/TestString/StringLike.md b/example/ruby/TestString/StringLike.md deleted file mode 100644 index a1e9a30..0000000 --- a/example/ruby/TestString/StringLike.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestString::StringLike -**Inherits:** Object - - - - - -#Instance Methods -## initialize(str) [](#method-i-initialize) - -**@return** [StringLike] a new instance of StringLike - -## to_str() [](#method-i-to_str) - diff --git a/example/ruby/TestString/StringWithIVSet.md b/example/ruby/TestString/StringWithIVSet.md deleted file mode 100644 index 0a56921..0000000 --- a/example/ruby/TestString/StringWithIVSet.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestString::StringWithIVSet -**Inherits:** String - - - - - -#Instance Methods -## set_iv() [](#method-i-set_iv) - diff --git a/example/ruby/TestString2.md b/example/ruby/TestString2.md deleted file mode 100644 index 5523099..0000000 --- a/example/ruby/TestString2.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestString2 -**Inherits:** TestString - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [TestString2] a new instance of TestString2 - diff --git a/example/ruby/TestStringIO.md b/example/ruby/TestStringIO.md deleted file mode 100644 index 8e3faeb..0000000 --- a/example/ruby/TestStringIO.md +++ /dev/null @@ -1,194 +0,0 @@ -# Class: TestStringIO -**Inherits:** Test::Unit::TestCase - -**Includes:** TestEOF, TestEOF::Seek - - - - - -#Instance Methods -## open_file(content) [](#method-i-open_file) - -**@yield** [f] - -## open_file_seek(content, pos) [](#method-i-open_file_seek) - -## test_binary_encoding_read_and_default_internal() [](#method-i-test_binary_encoding_read_and_default_internal) - -## test_binmode() [](#method-i-test_binmode) - -## test_chilled_string() [](#method-i-test_chilled_string) - -## test_chilled_string_string_set() [](#method-i-test_chilled_string_string_set) - -## test_close() [](#method-i-test_close) - -## test_close_read() [](#method-i-test_close_read) - -## test_close_write() [](#method-i-test_close_write) - -## test_closed() [](#method-i-test_closed) - -## test_closed_read() [](#method-i-test_closed_read) - -## test_closed_write() [](#method-i-test_closed_write) - -## test_coderange_after_overwrite() [](#method-i-test_coderange_after_overwrite) - -## test_dup() [](#method-i-test_dup) - -## test_each() [](#method-i-test_each) - -## test_each_byte() [](#method-i-test_each_byte) - -## test_each_byte_closed() [](#method-i-test_each_byte_closed) - -## test_each_char() [](#method-i-test_each_char) - -## test_each_char_closed() [](#method-i-test_each_char_closed) - -## test_each_codepoint() [](#method-i-test_each_codepoint) - -## test_each_codepoint_closed() [](#method-i-test_each_codepoint_closed) - -## test_each_codepoint_enumerator() [](#method-i-test_each_codepoint_enumerator) - -## test_each_line_limit_0() [](#method-i-test_each_line_limit_0) - -## test_each_string_sep() [](#method-i-test_each_string_sep) - -## test_encoding_read() [](#method-i-test_encoding_read) - -## test_encoding_write() [](#method-i-test_encoding_write) - -## test_eof_0() [](#method-i-test_eof_0) - -## test_eof_0_rw() [](#method-i-test_eof_0_rw) - -## test_eof_0_seek() [](#method-i-test_eof_0_seek) - -## test_eof_1() [](#method-i-test_eof_1) - -## test_eof_1_seek() [](#method-i-test_eof_1_seek) - -## test_eof_2() [](#method-i-test_eof_2) - -## test_eof_3() [](#method-i-test_eof_3) - -## test_frozen() [](#method-i-test_frozen) - -## test_frozen_string() [](#method-i-test_frozen_string) - -## test_fsync() [](#method-i-test_fsync) - -## test_getbyte() [](#method-i-test_getbyte) - -## test_gets() [](#method-i-test_gets) - -## test_gets2() [](#method-i-test_gets2) - -## test_gets_chomp() [](#method-i-test_gets_chomp) - -## test_gets_chomp_eol() [](#method-i-test_gets_chomp_eol) - -## test_gets_utf_16() [](#method-i-test_gets_utf_16) - -## test_initialize() [](#method-i-test_initialize) - -## test_isatty() [](#method-i-test_isatty) - -## test_lineno() [](#method-i-test_lineno) - -## test_method() [](#method-i-test_method) - -## test_mode_error() [](#method-i-test_mode_error) - -## test_new_block_warning() [](#method-i-test_new_block_warning) - -## test_null() [](#method-i-test_null) - -## test_open() [](#method-i-test_open) - -## test_overflow() [](#method-i-test_overflow) - -## test_overwrite() [](#method-i-test_overwrite) - -## test_pos() [](#method-i-test_pos) - -## test_pread() [](#method-i-test_pread) - -## test_putc() [](#method-i-test_putc) - -## test_putc_nonascii() [](#method-i-test_putc_nonascii) - -## test_read() [](#method-i-test_read) - -## test_read_nonblock() [](#method-i-test_read_nonblock) - -## test_read_nonblock_no_exceptions() [](#method-i-test_read_nonblock_no_exceptions) - -## test_readbyte() [](#method-i-test_readbyte) - -## test_readchar() [](#method-i-test_readchar) - -## test_readlines() [](#method-i-test_readlines) - -## test_readlines_limit_0() [](#method-i-test_readlines_limit_0) - -## test_readpartial() [](#method-i-test_readpartial) - -## test_reopen() [](#method-i-test_reopen) - -## test_seek() [](#method-i-test_seek) - -## test_seek_beyond_eof() [](#method-i-test_seek_beyond_eof) - -## test_set_encoding() [](#method-i-test_set_encoding) - -## test_set_fcntl() [](#method-i-test_set_fcntl) - -## test_size() [](#method-i-test_size) - -## test_sync() [](#method-i-test_sync) - -## test_sysread() [](#method-i-test_sysread) - -## test_truncate() [](#method-i-test_truncate) - -## test_ungetbyte() [](#method-i-test_ungetbyte) - -## test_ungetbyte_fill() [](#method-i-test_ungetbyte_fill) - -## test_ungetbyte_padding() [](#method-i-test_ungetbyte_padding) - -## test_ungetbyte_pos() [](#method-i-test_ungetbyte_pos) - -## test_ungetbyte_same_string() [](#method-i-test_ungetbyte_same_string) - -## test_ungetc() [](#method-i-test_ungetc) - -## test_ungetc_fill() [](#method-i-test_ungetc_fill) - -## test_ungetc_padding() [](#method-i-test_ungetc_padding) - -## test_ungetc_pos() [](#method-i-test_ungetc_pos) - -## test_ungetc_same_string() [](#method-i-test_ungetc_same_string) - -## test_version() [](#method-i-test_version) - -## test_write() [](#method-i-test_write) - -## test_write_encoding() [](#method-i-test_write_encoding) - -## test_write_encoding_conversion() [](#method-i-test_write_encoding_conversion) - -## test_write_integer_overflow() [](#method-i-test_write_integer_overflow) - -## test_write_nonblock() [](#method-i-test_write_nonblock) - -## test_write_nonblock_no_exceptions() [](#method-i-test_write_nonblock_no_exceptions) - -## test_write_with_multiple_arguments() [](#method-i-test_write_with_multiple_arguments) - diff --git a/example/ruby/TestStringIO/C.md b/example/ruby/TestStringIO/C.md deleted file mode 100644 index 5b3b9e7..0000000 --- a/example/ruby/TestStringIO/C.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestStringIO::C -**Inherits:** StringIO - - -This test is should in ruby/test_method.rb However this test depends on -stringio library, we write it here. - - -# Attributes -## foo[RW] [](#attribute-i-foo) -Returns the value of attribute foo. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [C] a new instance of C - -## old_init() [](#method-i-old_init) - diff --git a/example/ruby/TestStringIOInRactor.md b/example/ruby/TestStringIOInRactor.md deleted file mode 100644 index 50e217c..0000000 --- a/example/ruby/TestStringIOInRactor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestStringIOInRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ractor() [](#method-i-test_ractor) - diff --git a/example/ruby/TestStringMemory.md b/example/ruby/TestStringMemory.md deleted file mode 100644 index 85ee481..0000000 --- a/example/ruby/TestStringMemory.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestStringMemory -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## capture_allocations(klass) [](#method-i-capture_allocations) - -## test_byteslice_postfix() [](#method-i-test_byteslice_postfix) - -## test_byteslice_postfix_twice() [](#method-i-test_byteslice_postfix_twice) - -## test_byteslice_prefix() [](#method-i-test_byteslice_prefix) - diff --git a/example/ruby/TestStringScanner.md b/example/ruby/TestStringScanner.md deleted file mode 100644 index c81f9a2..0000000 --- a/example/ruby/TestStringScanner.md +++ /dev/null @@ -1,156 +0,0 @@ -# Class: TestStringScanner -**Inherits:** Test::Unit::TestCase - -**Includes:** StringScannerTests - - - - - -#Instance Methods -## create_string_scanner(string, *args) [](#method-i-create_string_scanner) - -## test_AREF() [](#method-i-test_AREF) - -## test_aref_without_regex() [](#method-i-test_aref_without_regex) - -## test_bol?() [](#method-i-test_bol?) - -**@return** [Boolean] - -## test_captures() [](#method-i-test_captures) - -## test_charpos_not_use_string_methods() [](#method-i-test_charpos_not_use_string_methods) - -## test_check() [](#method-i-test_check) - -## test_check_until() [](#method-i-test_check_until) - -## test_check_until_string() [](#method-i-test_check_until_string) - -## test_concat() [](#method-i-test_concat) - -## test_const_Id() [](#method-i-test_const_Id) - -## test_const_Version() [](#method-i-test_const_Version) - -## test_dup() [](#method-i-test_dup) - -## test_empty_encoding_ascii_8bit() [](#method-i-test_empty_encoding_ascii_8bit) - -## test_empty_encoding_utf8() [](#method-i-test_empty_encoding_utf8) - -## test_encoding() [](#method-i-test_encoding) - -## test_encoding_string() [](#method-i-test_encoding_string) - -## test_eos?() [](#method-i-test_eos?) - -**@return** [Boolean] - -## test_exist_p() [](#method-i-test_exist_p) - -## test_exist_p_invalid_argument() [](#method-i-test_exist_p_invalid_argument) - -## test_exist_p_string() [](#method-i-test_exist_p_string) - -## test_fixed_anchor_false() [](#method-i-test_fixed_anchor_false) - -## test_fixed_anchor_true() [](#method-i-test_fixed_anchor_true) - -## test_generic_regexp() [](#method-i-test_generic_regexp) - -## test_get_byte() [](#method-i-test_get_byte) - -## test_getch() [](#method-i-test_getch) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect2() [](#method-i-test_inspect2) - -## test_invalid_encoding_string() [](#method-i-test_invalid_encoding_string) - -## test_match_p() [](#method-i-test_match_p) - -## test_matched() [](#method-i-test_matched) - -## test_matched_size() [](#method-i-test_matched_size) - -## test_named_captures() [](#method-i-test_named_captures) - -## test_peek() [](#method-i-test_peek) - -## test_peek_byte() [](#method-i-test_peek_byte) - -## test_pos() [](#method-i-test_pos) - -## test_pos_unicode() [](#method-i-test_pos_unicode) - -## test_post_match() [](#method-i-test_post_match) - -## test_pre_match() [](#method-i-test_pre_match) - -## test_reset() [](#method-i-test_reset) - -## test_rest() [](#method-i-test_rest) - -## test_rest_size() [](#method-i-test_rest_size) - -## test_s_allocate() [](#method-i-test_s_allocate) - -## test_s_mustc() [](#method-i-test_s_mustc) - -## test_s_new() [](#method-i-test_s_new) - -## test_scan() [](#method-i-test_scan) - -## test_scan_aref_repeatedly() [](#method-i-test_scan_aref_repeatedly) - -## test_scan_byte() [](#method-i-test_scan_byte) - -## test_scan_full() [](#method-i-test_scan_full) - -## test_scan_integer() [](#method-i-test_scan_integer) - -## test_scan_integer_base_16() [](#method-i-test_scan_integer_base_16) - -## test_scan_integer_encoding() [](#method-i-test_scan_integer_encoding) - -## test_scan_integer_unmatch() [](#method-i-test_scan_integer_unmatch) - -## test_scan_string() [](#method-i-test_scan_string) - -## test_scan_until() [](#method-i-test_scan_until) - -## test_scan_until_string() [](#method-i-test_scan_until_string) - -## test_search_full() [](#method-i-test_search_full) - -## test_search_full_string() [](#method-i-test_search_full_string) - -## test_set_pos() [](#method-i-test_set_pos) - -## test_size() [](#method-i-test_size) - -## test_skip() [](#method-i-test_skip) - -## test_skip_until() [](#method-i-test_skip_until) - -## test_skip_until_string() [](#method-i-test_skip_until_string) - -## test_skip_with_begenning_of_line_anchor_match() [](#method-i-test_skip_with_begenning_of_line_anchor_match) - -## test_skip_with_begenning_of_string_anchor_match() [](#method-i-test_skip_with_begenning_of_string_anchor_match) - -## test_string() [](#method-i-test_string) - -## test_string_append() [](#method-i-test_string_append) - -## test_string_set_is_equal() [](#method-i-test_string_set_is_equal) - -## test_terminate() [](#method-i-test_terminate) - -## test_unscan() [](#method-i-test_unscan) - -## test_values_at() [](#method-i-test_values_at) - diff --git a/example/ruby/TestStringScannerFixedAnchor.md b/example/ruby/TestStringScannerFixedAnchor.md deleted file mode 100644 index 55f70b0..0000000 --- a/example/ruby/TestStringScannerFixedAnchor.md +++ /dev/null @@ -1,159 +0,0 @@ -# Class: TestStringScannerFixedAnchor -**Inherits:** Test::Unit::TestCase - -**Includes:** StringScannerTests - - - - - -#Instance Methods -## create_string_scanner(string, *args) [](#method-i-create_string_scanner) - -## test_AREF() [](#method-i-test_AREF) - -## test_aref_without_regex() [](#method-i-test_aref_without_regex) - -## test_bol?() [](#method-i-test_bol?) - -**@return** [Boolean] - -## test_captures() [](#method-i-test_captures) - -## test_charpos_not_use_string_methods() [](#method-i-test_charpos_not_use_string_methods) - -## test_check() [](#method-i-test_check) - -## test_check_until() [](#method-i-test_check_until) - -## test_check_until_string() [](#method-i-test_check_until_string) - -## test_concat() [](#method-i-test_concat) - -## test_const_Id() [](#method-i-test_const_Id) - -## test_const_Version() [](#method-i-test_const_Version) - -## test_dup() [](#method-i-test_dup) - -## test_empty_encoding_ascii_8bit() [](#method-i-test_empty_encoding_ascii_8bit) - -## test_empty_encoding_utf8() [](#method-i-test_empty_encoding_utf8) - -## test_encoding() [](#method-i-test_encoding) - -## test_encoding_string() [](#method-i-test_encoding_string) - -## test_eos?() [](#method-i-test_eos?) - -**@return** [Boolean] - -## test_exist_p() [](#method-i-test_exist_p) - -## test_exist_p_invalid_argument() [](#method-i-test_exist_p_invalid_argument) - -## test_exist_p_string() [](#method-i-test_exist_p_string) - -## test_generic_regexp() [](#method-i-test_generic_regexp) - -## test_get_byte() [](#method-i-test_get_byte) - -## test_getch() [](#method-i-test_getch) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect2() [](#method-i-test_inspect2) - -## test_invalid_encoding_string() [](#method-i-test_invalid_encoding_string) - -## test_match_p() [](#method-i-test_match_p) - -## test_matched() [](#method-i-test_matched) - -## test_matched_size() [](#method-i-test_matched_size) - -## test_named_captures() [](#method-i-test_named_captures) - -## test_peek() [](#method-i-test_peek) - -## test_peek_byte() [](#method-i-test_peek_byte) - -## test_pos() [](#method-i-test_pos) - -## test_pos_unicode() [](#method-i-test_pos_unicode) - -## test_post_match() [](#method-i-test_post_match) - -## test_pre_match() [](#method-i-test_pre_match) - -## test_reset() [](#method-i-test_reset) - -## test_rest() [](#method-i-test_rest) - -## test_rest_size() [](#method-i-test_rest_size) - -## test_s_allocate() [](#method-i-test_s_allocate) - -## test_s_mustc() [](#method-i-test_s_mustc) - -## test_s_new() [](#method-i-test_s_new) - -## test_scan() [](#method-i-test_scan) - -## test_scan_aref_repeatedly() [](#method-i-test_scan_aref_repeatedly) - -## test_scan_byte() [](#method-i-test_scan_byte) - -## test_scan_full() [](#method-i-test_scan_full) - -## test_scan_integer() [](#method-i-test_scan_integer) - -## test_scan_integer_base_16() [](#method-i-test_scan_integer_base_16) - -## test_scan_integer_encoding() [](#method-i-test_scan_integer_encoding) - -## test_scan_integer_unmatch() [](#method-i-test_scan_integer_unmatch) - -## test_scan_shared_string() [](#method-i-test_scan_shared_string) -ruby/strscan#86 - -## test_scan_string() [](#method-i-test_scan_string) - -## test_scan_until() [](#method-i-test_scan_until) - -## test_scan_until_string() [](#method-i-test_scan_until_string) - -## test_search_full() [](#method-i-test_search_full) - -## test_search_full_string() [](#method-i-test_search_full_string) - -## test_set_pos() [](#method-i-test_set_pos) - -## test_size() [](#method-i-test_size) - -## test_skip() [](#method-i-test_skip) - -## test_skip_until() [](#method-i-test_skip_until) - -## test_skip_until_string() [](#method-i-test_skip_until_string) - -## test_skip_with_begenning_of_line_anchor_match() [](#method-i-test_skip_with_begenning_of_line_anchor_match) - -## test_skip_with_begenning_of_line_anchor_not_match() [](#method-i-test_skip_with_begenning_of_line_anchor_not_match) - -## test_skip_with_begenning_of_string_anchor_match() [](#method-i-test_skip_with_begenning_of_string_anchor_match) - -## test_skip_with_begenning_of_string_anchor_not_match() [](#method-i-test_skip_with_begenning_of_string_anchor_not_match) - -## test_string() [](#method-i-test_string) - -## test_string_append() [](#method-i-test_string_append) - -## test_string_set_is_equal() [](#method-i-test_string_set_is_equal) - -## test_terminate() [](#method-i-test_terminate) - -## test_unscan() [](#method-i-test_unscan) - -## test_values_at() [](#method-i-test_values_at) - diff --git a/example/ruby/TestStringScannerRactor.md b/example/ruby/TestStringScannerRactor.md deleted file mode 100644 index e8c5cd8..0000000 --- a/example/ruby/TestStringScannerRactor.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestStringScannerRactor -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ractor() [](#method-i-test_ractor) - diff --git a/example/ruby/TestStringchar.md b/example/ruby/TestStringchar.md deleted file mode 100644 index d57e390..0000000 --- a/example/ruby/TestStringchar.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestStringchar -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_bang() [](#method-i-test_bang) - -## test_char() [](#method-i-test_char) - -## test_dump() [](#method-i-test_dump) - -## test_string() [](#method-i-test_string) - diff --git a/example/ruby/TestStruct.md b/example/ruby/TestStruct.md deleted file mode 100644 index b88b0f6..0000000 --- a/example/ruby/TestStruct.md +++ /dev/null @@ -1,110 +0,0 @@ -# Module: TestStruct - - - - - -#Instance Methods -## test_aref() [](#method-i-test_aref) - -## test_arity() [](#method-i-test_arity) - -## test_aset() [](#method-i-test_aset) - -## test_attrset_id() [](#method-i-test_attrset_id) - -## test_bang_mark_in_member() [](#method-i-test_bang_mark_in_member) - -## test_big_struct() [](#method-i-test_big_struct) - -## test_comparison_when_recursive() [](#method-i-test_comparison_when_recursive) - -## test_deconstruct_keys() [](#method-i-test_deconstruct_keys) - -## test_dig() [](#method-i-test_dig) - -## test_each() [](#method-i-test_each) - -## test_each_pair() [](#method-i-test_each_pair) - -## test_eql() [](#method-i-test_eql) - -## test_equal() [](#method-i-test_equal) - -## test_error() [](#method-i-test_error) - -## test_filter() [](#method-i-test_filter) - -## test_hash() [](#method-i-test_hash) - -## test_inherit() [](#method-i-test_inherit) - -## test_init_copy() [](#method-i-test_init_copy) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_with_kw() [](#method-i-test_initialize_with_kw) - -## test_inspect() [](#method-i-test_inspect) - -## test_junk() [](#method-i-test_junk) - -## test_keyword_args_warning() [](#method-i-test_keyword_args_warning) - -## test_larger_than_largest_pool() [](#method-i-test_larger_than_largest_pool) - -## test_members() [](#method-i-test_members) - -## test_morethan10members() [](#method-i-test_morethan10members) -ruby-dev:26247 -: more than 10 struct members causes segmentation fault - - -## test_named_structs_are_not_rooted() [](#method-i-test_named_structs_are_not_rooted) - -## test_new_duplicate() [](#method-i-test_new_duplicate) - -## test_nonascii() [](#method-i-test_nonascii) - -## test_overridden_aref() [](#method-i-test_overridden_aref) - -## test_overridden_aset() [](#method-i-test_overridden_aset) - -## test_parameters() [](#method-i-test_parameters) - -## test_public_send() [](#method-i-test_public_send) - -## test_question_mark_in_member() [](#method-i-test_question_mark_in_member) - -## test_redefinition_warning() [](#method-i-test_redefinition_warning) - -## test_ref() [](#method-i-test_ref) - -## test_select() [](#method-i-test_select) - -## test_set() [](#method-i-test_set) - -## test_setter_method_returns_value() [](#method-i-test_setter_method_returns_value) - -## test_size() [](#method-i-test_size) - -## test_small_structs() [](#method-i-test_small_structs) - -## test_struct() [](#method-i-test_struct) - -## test_struct_keyword_init_p() [](#method-i-test_struct_keyword_init_p) - -## test_struct_new() [](#method-i-test_struct_new) - -## test_struct_new_with_hash() [](#method-i-test_struct_new_with_hash) - -## test_struct_new_with_keyword_init() [](#method-i-test_struct_new_with_keyword_init) - -## test_struct_new_with_keyword_init_and_block() [](#method-i-test_struct_new_with_keyword_init_and_block) - -## test_to_h() [](#method-i-test_to_h) - -## test_to_h_block() [](#method-i-test_to_h_block) - -## test_values_at() [](#method-i-test_values_at) - diff --git a/example/ruby/TestStruct/SubStruct.md b/example/ruby/TestStruct/SubStruct.md deleted file mode 100644 index 801e410..0000000 --- a/example/ruby/TestStruct/SubStruct.md +++ /dev/null @@ -1,117 +0,0 @@ -# Class: TestStruct::SubStruct -**Inherits:** Test::Unit::TestCase - -**Includes:** TestStruct - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [SubStruct] a new instance of SubStruct - -## test_aref() [](#method-i-test_aref) - -## test_arity() [](#method-i-test_arity) - -## test_aset() [](#method-i-test_aset) - -## test_attrset_id() [](#method-i-test_attrset_id) - -## test_bang_mark_in_member() [](#method-i-test_bang_mark_in_member) - -## test_big_struct() [](#method-i-test_big_struct) - -## test_comparison_when_recursive() [](#method-i-test_comparison_when_recursive) - -## test_deconstruct_keys() [](#method-i-test_deconstruct_keys) - -## test_dig() [](#method-i-test_dig) - -## test_each() [](#method-i-test_each) - -## test_each_pair() [](#method-i-test_each_pair) - -## test_eql() [](#method-i-test_eql) - -## test_equal() [](#method-i-test_equal) - -## test_error() [](#method-i-test_error) - -## test_filter() [](#method-i-test_filter) - -## test_hash() [](#method-i-test_hash) - -## test_inherit() [](#method-i-test_inherit) - -## test_init_copy() [](#method-i-test_init_copy) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_with_kw() [](#method-i-test_initialize_with_kw) - -## test_inspect() [](#method-i-test_inspect) - -## test_junk() [](#method-i-test_junk) - -## test_keyword_args_warning() [](#method-i-test_keyword_args_warning) - -## test_larger_than_largest_pool() [](#method-i-test_larger_than_largest_pool) - -## test_members() [](#method-i-test_members) - -## test_morethan10members() [](#method-i-test_morethan10members) -ruby-dev:26247 -: more than 10 struct members causes segmentation fault - - -## test_named_structs_are_not_rooted() [](#method-i-test_named_structs_are_not_rooted) - -## test_new_duplicate() [](#method-i-test_new_duplicate) - -## test_nonascii() [](#method-i-test_nonascii) - -## test_overridden_aref() [](#method-i-test_overridden_aref) - -## test_overridden_aset() [](#method-i-test_overridden_aset) - -## test_parameters() [](#method-i-test_parameters) - -## test_public_send() [](#method-i-test_public_send) - -## test_question_mark_in_member() [](#method-i-test_question_mark_in_member) - -## test_redefinition_warning() [](#method-i-test_redefinition_warning) - -## test_ref() [](#method-i-test_ref) - -## test_select() [](#method-i-test_select) - -## test_set() [](#method-i-test_set) - -## test_setter_method_returns_value() [](#method-i-test_setter_method_returns_value) - -## test_size() [](#method-i-test_size) - -## test_small_structs() [](#method-i-test_small_structs) - -## test_struct() [](#method-i-test_struct) - -## test_struct_keyword_init_p() [](#method-i-test_struct_keyword_init_p) - -## test_struct_new() [](#method-i-test_struct_new) - -## test_struct_new_with_hash() [](#method-i-test_struct_new_with_hash) - -## test_struct_new_with_keyword_init() [](#method-i-test_struct_new_with_keyword_init) - -## test_struct_new_with_keyword_init_and_block() [](#method-i-test_struct_new_with_keyword_init_and_block) - -## test_to_h() [](#method-i-test_to_h) - -## test_to_h_block() [](#method-i-test_to_h_block) - -## test_values_at() [](#method-i-test_values_at) - diff --git a/example/ruby/TestStruct/TopStruct.md b/example/ruby/TestStruct/TopStruct.md deleted file mode 100644 index 33ccd18..0000000 --- a/example/ruby/TestStruct/TopStruct.md +++ /dev/null @@ -1,117 +0,0 @@ -# Class: TestStruct::TopStruct -**Inherits:** Test::Unit::TestCase - -**Includes:** TestStruct - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [TopStruct] a new instance of TopStruct - -## test_aref() [](#method-i-test_aref) - -## test_arity() [](#method-i-test_arity) - -## test_aset() [](#method-i-test_aset) - -## test_attrset_id() [](#method-i-test_attrset_id) - -## test_bang_mark_in_member() [](#method-i-test_bang_mark_in_member) - -## test_big_struct() [](#method-i-test_big_struct) - -## test_comparison_when_recursive() [](#method-i-test_comparison_when_recursive) - -## test_deconstruct_keys() [](#method-i-test_deconstruct_keys) - -## test_dig() [](#method-i-test_dig) - -## test_each() [](#method-i-test_each) - -## test_each_pair() [](#method-i-test_each_pair) - -## test_eql() [](#method-i-test_eql) - -## test_equal() [](#method-i-test_equal) - -## test_error() [](#method-i-test_error) - -## test_filter() [](#method-i-test_filter) - -## test_hash() [](#method-i-test_hash) - -## test_inherit() [](#method-i-test_inherit) - -## test_init_copy() [](#method-i-test_init_copy) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_with_kw() [](#method-i-test_initialize_with_kw) - -## test_inspect() [](#method-i-test_inspect) - -## test_junk() [](#method-i-test_junk) - -## test_keyword_args_warning() [](#method-i-test_keyword_args_warning) - -## test_larger_than_largest_pool() [](#method-i-test_larger_than_largest_pool) - -## test_members() [](#method-i-test_members) - -## test_morethan10members() [](#method-i-test_morethan10members) -ruby-dev:26247 -: more than 10 struct members causes segmentation fault - - -## test_named_structs_are_not_rooted() [](#method-i-test_named_structs_are_not_rooted) - -## test_new_duplicate() [](#method-i-test_new_duplicate) - -## test_nonascii() [](#method-i-test_nonascii) - -## test_overridden_aref() [](#method-i-test_overridden_aref) - -## test_overridden_aset() [](#method-i-test_overridden_aset) - -## test_parameters() [](#method-i-test_parameters) - -## test_public_send() [](#method-i-test_public_send) - -## test_question_mark_in_member() [](#method-i-test_question_mark_in_member) - -## test_redefinition_warning() [](#method-i-test_redefinition_warning) - -## test_ref() [](#method-i-test_ref) - -## test_select() [](#method-i-test_select) - -## test_set() [](#method-i-test_set) - -## test_setter_method_returns_value() [](#method-i-test_setter_method_returns_value) - -## test_size() [](#method-i-test_size) - -## test_small_structs() [](#method-i-test_small_structs) - -## test_struct() [](#method-i-test_struct) - -## test_struct_keyword_init_p() [](#method-i-test_struct_keyword_init_p) - -## test_struct_new() [](#method-i-test_struct_new) - -## test_struct_new_with_hash() [](#method-i-test_struct_new_with_hash) - -## test_struct_new_with_keyword_init() [](#method-i-test_struct_new_with_keyword_init) - -## test_struct_new_with_keyword_init_and_block() [](#method-i-test_struct_new_with_keyword_init_and_block) - -## test_to_h() [](#method-i-test_to_h) - -## test_to_h_block() [](#method-i-test_to_h_block) - -## test_values_at() [](#method-i-test_values_at) - diff --git a/example/ruby/TestStubSpecification.md b/example/ruby/TestStubSpecification.md deleted file mode 100644 index 259db74..0000000 --- a/example/ruby/TestStubSpecification.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: TestStubSpecification -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## stub_with_extension() [](#method-i-stub_with_extension) - -## stub_with_version() [](#method-i-stub_with_version) - -## stub_without_extension() [](#method-i-stub_without_extension) - -## stub_without_version() [](#method-i-stub_without_version) - -## test_contains_requirable_file_eh() [](#method-i-test_contains_requirable_file_eh) - -## test_contains_requirable_file_eh_extension() [](#method-i-test_contains_requirable_file_eh_extension) - -## test_full_require_paths() [](#method-i-test_full_require_paths) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_extension() [](#method-i-test_initialize_extension) - -## test_initialize_missing_stubline() [](#method-i-test_initialize_missing_stubline) - -## test_initialize_version() [](#method-i-test_initialize_version) - -## test_initialize_with_empty_version() [](#method-i-test_initialize_with_empty_version) - -## test_lib_dirs_glob() [](#method-i-test_lib_dirs_glob) - -## test_lib_dirs_glob_with_extension() [](#method-i-test_lib_dirs_glob_with_extension) - -## test_matches_for_glob() [](#method-i-test_matches_for_glob) - -## test_matches_for_glob_with_bundler_inline() [](#method-i-test_matches_for_glob_with_bundler_inline) - -## test_missing_extensions_eh() [](#method-i-test_missing_extensions_eh) - -## test_missing_extensions_eh_default_gem() [](#method-i-test_missing_extensions_eh_default_gem) - -## test_missing_extensions_eh_none() [](#method-i-test_missing_extensions_eh_none) - -## test_to_spec() [](#method-i-test_to_spec) - -## test_to_spec_default() [](#method-i-test_to_spec_default) - -## test_to_spec_with_other_specs_loaded_does_not_warn() [](#method-i-test_to_spec_with_other_specs_loaded_does_not_warn) - diff --git a/example/ruby/TestSuper.md b/example/ruby/TestSuper.md deleted file mode 100644 index 58889cc..0000000 --- a/example/ruby/TestSuper.md +++ /dev/null @@ -1,108 +0,0 @@ -# Class: TestSuper -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_super_in_block(type) [](#method-i-assert_super_in_block) - -## test_array1() [](#method-i-test_array1) - -## test_array2() [](#method-i-test_array2) - -## test_array3() [](#method-i-test_array3) - -## test_array4() [](#method-i-test_array4) - -## test_define_method() [](#method-i-test_define_method) - -## test_double1() [](#method-i-test_double1) - -## test_double2() [](#method-i-test_double2) - -## test_double3() [](#method-i-test_double3) - -## test_double_include() [](#method-i-test_double_include) - -## test_double_include2() [](#method-i-test_double_include2) - -## test_forwardable() [](#method-i-test_forwardable) - -## test_from_eval() [](#method-i-test_from_eval) - -## test_keyword1() [](#method-i-test_keyword1) - -## test_keyword2() [](#method-i-test_keyword2) - -## test_missing_super() [](#method-i-test_missing_super) - -## test_missing_super_in_method_module() [](#method-i-test_missing_super_in_method_module) - -## test_missing_super_in_module_unbound_method() [](#method-i-test_missing_super_in_module_unbound_method) - -## test_module_super_in_method_module() [](#method-i-test_module_super_in_method_module) - -## test_optional1() [](#method-i-test_optional1) - -## test_optional2() [](#method-i-test_optional2) - -## test_optional3() [](#method-i-test_optional3) - -## test_optional4() [](#method-i-test_optional4) - -## test_optional5() [](#method-i-test_optional5) - -## test_overlaid() [](#method-i-test_overlaid) - -## test_public_zsuper_with_prepend() [](#method-i-test_public_zsuper_with_prepend) - -## test_single1() [](#method-i-test_single1) - -## test_single2() [](#method-i-test_single2) - -## test_super_attr_reader() [](#method-i-test_super_attr_reader) - -## test_super_attr_writer() [](#method-i-test_super_attr_writer) -Bug #16785 -: - -## test_super_in_BEGIN() [](#method-i-test_super_in_BEGIN) - -## test_super_in_END() [](#method-i-test_super_in_END) - -## test_super_in_at_exit() [](#method-i-test_super_in_at_exit) - -## test_super_in_instance_eval() [](#method-i-test_super_in_instance_eval) - -## test_super_in_instance_eval_in_module() [](#method-i-test_super_in_instance_eval_in_module) - -## test_super_in_instance_eval_with_define_method() [](#method-i-test_super_in_instance_eval_with_define_method) - -## test_super_in_module_unbound_method() [](#method-i-test_super_in_module_unbound_method) - -## test_super_in_orphan_block() [](#method-i-test_super_in_orphan_block) - -## test_super_in_orphan_block_with_instance_eval() [](#method-i-test_super_in_orphan_block_with_instance_eval) - -## test_super_in_thread() [](#method-i-test_super_in_thread) - -## test_super_missing_prepended_module() [](#method-i-test_super_missing_prepended_module) -Bug #18329 -: - -## test_super_splat() [](#method-i-test_super_splat) - -## test_super_with_block() [](#method-i-test_super_with_block) - -## test_super_with_define_method() [](#method-i-test_super_with_define_method) - -## test_super_with_included_prepended_module_method_caching_bug_20716() [](#method-i-test_super_with_included_prepended_module_method_caching_bug_20716) - -## test_super_with_modified_rest_parameter() [](#method-i-test_super_with_modified_rest_parameter) - -## test_yielding_super() [](#method-i-test_yielding_super) - -## test_zsuper_kw_splat_not_mutable() [](#method-i-test_zsuper_kw_splat_not_mutable) - diff --git a/example/ruby/TestSuper/A.md b/example/ruby/TestSuper/A.md deleted file mode 100644 index 5d07e04..0000000 --- a/example/ruby/TestSuper/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestSuper::A -**Inherits:** Object - - - - - -#Instance Methods -## tt(aa) [](#method-i-tt) - -## uu(a) [](#method-i-uu) - diff --git a/example/ruby/TestSuper/Array1.md b/example/ruby/TestSuper/Array1.md deleted file mode 100644 index 7c93240..0000000 --- a/example/ruby/TestSuper/Array1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Array1 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## array() [](#method-i-array) - diff --git a/example/ruby/TestSuper/Array2.md b/example/ruby/TestSuper/Array2.md deleted file mode 100644 index c2103e8..0000000 --- a/example/ruby/TestSuper/Array2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Array2 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## array(a) [](#method-i-array) - diff --git a/example/ruby/TestSuper/Array3.md b/example/ruby/TestSuper/Array3.md deleted file mode 100644 index 8d41cfa..0000000 --- a/example/ruby/TestSuper/Array3.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Array3 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## array(a, b) [](#method-i-array) - diff --git a/example/ruby/TestSuper/Array4.md b/example/ruby/TestSuper/Array4.md deleted file mode 100644 index b86cad1..0000000 --- a/example/ruby/TestSuper/Array4.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Array4 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## array(a, b, c) [](#method-i-array) - diff --git a/example/ruby/TestSuper/Base.md b/example/ruby/TestSuper/Base.md deleted file mode 100644 index c016ca4..0000000 --- a/example/ruby/TestSuper/Base.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestSuper::Base -**Inherits:** Object - - - - - -#Instance Methods -## array(*a) [](#method-i-array) - -## double(a, b) [](#method-i-double) - -## forward(*a) [](#method-i-forward) - -## keyword(**a) [](#method-i-keyword) - -## optional(a0) [](#method-i-optional) - -## single(a) [](#method-i-single) - diff --git a/example/ruby/TestSuper/Double1.md b/example/ruby/TestSuper/Double1.md deleted file mode 100644 index c4e4358..0000000 --- a/example/ruby/TestSuper/Double1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Double1 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## double() [](#method-i-double) - diff --git a/example/ruby/TestSuper/Double2.md b/example/ruby/TestSuper/Double2.md deleted file mode 100644 index 6c40c79..0000000 --- a/example/ruby/TestSuper/Double2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Double2 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## double(a) [](#method-i-double) - diff --git a/example/ruby/TestSuper/Double3.md b/example/ruby/TestSuper/Double3.md deleted file mode 100644 index 1e2012a..0000000 --- a/example/ruby/TestSuper/Double3.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Double3 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## double(a, b) [](#method-i-double) - diff --git a/example/ruby/TestSuper/DoubleInclude.md b/example/ruby/TestSuper/DoubleInclude.md deleted file mode 100644 index 32bbb77..0000000 --- a/example/ruby/TestSuper/DoubleInclude.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestSuper::DoubleInclude - - - - - diff --git a/example/ruby/TestSuper/DoubleInclude/A.md b/example/ruby/TestSuper/DoubleInclude/A.md deleted file mode 100644 index b10aa49..0000000 --- a/example/ruby/TestSuper/DoubleInclude/A.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestSuper::DoubleInclude::A -**Inherits:** TestSuper::DoubleInclude::Base - - - - - diff --git a/example/ruby/TestSuper/DoubleInclude/B.md b/example/ruby/TestSuper/DoubleInclude/B.md deleted file mode 100644 index 92aa298..0000000 --- a/example/ruby/TestSuper/DoubleInclude/B.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestSuper::DoubleInclude::B -**Inherits:** TestSuper::DoubleInclude::A - - - - - diff --git a/example/ruby/TestSuper/DoubleInclude/Base.md b/example/ruby/TestSuper/DoubleInclude/Base.md deleted file mode 100644 index 48688aa..0000000 --- a/example/ruby/TestSuper/DoubleInclude/Base.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::DoubleInclude::Base -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestSuper/DoubleInclude/Override.md b/example/ruby/TestSuper/DoubleInclude/Override.md deleted file mode 100644 index 320a626..0000000 --- a/example/ruby/TestSuper/DoubleInclude/Override.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestSuper::DoubleInclude::Override - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestSuper/DoubleInclude2.md b/example/ruby/TestSuper/DoubleInclude2.md deleted file mode 100644 index f5ff454..0000000 --- a/example/ruby/TestSuper/DoubleInclude2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestSuper::DoubleInclude2 - - - - - diff --git a/example/ruby/TestSuper/DoubleInclude2/A.md b/example/ruby/TestSuper/DoubleInclude2/A.md deleted file mode 100644 index 4854693..0000000 --- a/example/ruby/TestSuper/DoubleInclude2/A.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::DoubleInclude2::A -**Inherits:** TestSuper::DoubleInclude2::Base - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestSuper/DoubleInclude2/B.md b/example/ruby/TestSuper/DoubleInclude2/B.md deleted file mode 100644 index 22d33e2..0000000 --- a/example/ruby/TestSuper/DoubleInclude2/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::DoubleInclude2::B -**Inherits:** TestSuper::DoubleInclude2::A - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestSuper/DoubleInclude2/Base.md b/example/ruby/TestSuper/DoubleInclude2/Base.md deleted file mode 100644 index 291b02d..0000000 --- a/example/ruby/TestSuper/DoubleInclude2/Base.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::DoubleInclude2::Base -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestSuper/DoubleInclude2/Override.md b/example/ruby/TestSuper/DoubleInclude2/Override.md deleted file mode 100644 index ca2a683..0000000 --- a/example/ruby/TestSuper/DoubleInclude2/Override.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestSuper::DoubleInclude2::Override - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestSuper/Forward.md b/example/ruby/TestSuper/Forward.md deleted file mode 100644 index 9a48a10..0000000 --- a/example/ruby/TestSuper/Forward.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Forward -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## forward() [](#method-i-forward) - diff --git a/example/ruby/TestSuper/Indexed.md b/example/ruby/TestSuper/Indexed.md deleted file mode 100644 index e052c06..0000000 --- a/example/ruby/TestSuper/Indexed.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Indexed -**Inherits:** Object - - - - - -#Instance Methods -## subseq() [](#method-i-subseq) - diff --git a/example/ruby/TestSuper/Keyword1.md b/example/ruby/TestSuper/Keyword1.md deleted file mode 100644 index 9cfd4ac..0000000 --- a/example/ruby/TestSuper/Keyword1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Keyword1 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## keyword(foo:"keyword1") [](#method-i-keyword) - diff --git a/example/ruby/TestSuper/Keyword2.md b/example/ruby/TestSuper/Keyword2.md deleted file mode 100644 index 8b5d196..0000000 --- a/example/ruby/TestSuper/Keyword2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Keyword2 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## keyword(foo:"keyword2") [](#method-i-keyword) - diff --git a/example/ruby/TestSuper/Optional1.md b/example/ruby/TestSuper/Optional1.md deleted file mode 100644 index 38e82b7..0000000 --- a/example/ruby/TestSuper/Optional1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Optional1 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## optional(a1) [](#method-i-optional) - diff --git a/example/ruby/TestSuper/Optional2.md b/example/ruby/TestSuper/Optional2.md deleted file mode 100644 index f53108e..0000000 --- a/example/ruby/TestSuper/Optional2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Optional2 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## optional(a, b1) [](#method-i-optional) - diff --git a/example/ruby/TestSuper/Optional3.md b/example/ruby/TestSuper/Optional3.md deleted file mode 100644 index 2667949..0000000 --- a/example/ruby/TestSuper/Optional3.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Optional3 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## single(a1) [](#method-i-single) - diff --git a/example/ruby/TestSuper/Optional4.md b/example/ruby/TestSuper/Optional4.md deleted file mode 100644 index ec5e597..0000000 --- a/example/ruby/TestSuper/Optional4.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Optional4 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## array(a1) [](#method-i-array) - diff --git a/example/ruby/TestSuper/Optional5.md b/example/ruby/TestSuper/Optional5.md deleted file mode 100644 index 5a3fb58..0000000 --- a/example/ruby/TestSuper/Optional5.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Optional5 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## array(a1, b2) [](#method-i-array) - diff --git a/example/ruby/TestSuper/Single1.md b/example/ruby/TestSuper/Single1.md deleted file mode 100644 index 72d69b7..0000000 --- a/example/ruby/TestSuper/Single1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Single1 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## single() [](#method-i-single) - diff --git a/example/ruby/TestSuper/Single2.md b/example/ruby/TestSuper/Single2.md deleted file mode 100644 index 3d4d86c..0000000 --- a/example/ruby/TestSuper/Single2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::Single2 -**Inherits:** TestSuper::Base - - - - - -#Instance Methods -## single(a) [](#method-i-single) - diff --git a/example/ruby/TestSuper/SubSeq.md b/example/ruby/TestSuper/SubSeq.md deleted file mode 100644 index cd38342..0000000 --- a/example/ruby/TestSuper/SubSeq.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestSuper::SubSeq -**Inherits:** Object - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [SubSeq] a new instance of SubSeq - -## subseq() [](#method-i-subseq) - diff --git a/example/ruby/TestSuper/TestFor_super_with_modified_rest_parameter.md b/example/ruby/TestSuper/TestFor_super_with_modified_rest_parameter.md deleted file mode 100644 index 2802bfb..0000000 --- a/example/ruby/TestSuper/TestFor_super_with_modified_rest_parameter.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::TestFor_super_with_modified_rest_parameter -**Inherits:** TestSuper::TestFor_super_with_modified_rest_parameter_base - - - - - -#Instance Methods -## foo(*args) [](#method-i-foo) - diff --git a/example/ruby/TestSuper/TestFor_super_with_modified_rest_parameter_base.md b/example/ruby/TestSuper/TestFor_super_with_modified_rest_parameter_base.md deleted file mode 100644 index 9905d91..0000000 --- a/example/ruby/TestSuper/TestFor_super_with_modified_rest_parameter_base.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::TestFor_super_with_modified_rest_parameter_base -**Inherits:** Object - - - - - -#Instance Methods -## foo(*args) [](#method-i-foo) - diff --git a/example/ruby/TestSuper/X.md b/example/ruby/TestSuper/X.md deleted file mode 100644 index b073fa5..0000000 --- a/example/ruby/TestSuper/X.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSuper::X -**Inherits:** Object - - - - - -#Instance Methods -## foo(*args) [](#method-i-foo) - diff --git a/example/ruby/TestSuper/Y.md b/example/ruby/TestSuper/Y.md deleted file mode 100644 index 978fc20..0000000 --- a/example/ruby/TestSuper/Y.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestSuper::Y -**Inherits:** TestSuper::X - - - - - diff --git a/example/ruby/TestSymbol.md b/example/ruby/TestSymbol.md deleted file mode 100644 index cfb2fbf..0000000 --- a/example/ruby/TestSymbol.md +++ /dev/null @@ -1,155 +0,0 @@ -# Class: TestSymbol -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## _test_to_proc_arg_with_refinements_call(&block ) [](#method-c-_test_to_proc_arg_with_refinements_call) - -#Instance Methods -## _test_to_proc_arg_with_refinements_call(&block) [](#method-i-_test_to_proc_arg_with_refinements_call) - -## _test_to_proc_with_refinements_call(&block) [](#method-i-_test_to_proc_with_refinements_call) - -## assert_eval_inspected(sym, validtrue) [](#method-i-assert_eval_inspected) -ruby-core:3573 -: - -## assert_inspect_evaled(n) [](#method-i-assert_inspect_evaled) - -## m2_block_given?(mnil) [](#method-i-m2_block_given?) - -**@return** [Boolean] - -## m_block_given?() [](#method-i-m_block_given?) - -**@return** [Boolean] - -## test_MATCH() [](#method-i-test_MATCH) -'=~' - -## test_all_symbols() [](#method-i-test_all_symbols) - -## test_ascii_incomat_inspect() [](#method-i-test_ascii_incomat_inspect) - -## test_block_curry_lambda() [](#method-i-test_block_curry_lambda) - -## test_block_curry_proc() [](#method-i-test_block_curry_proc) - -## test_block_given_to_proc() [](#method-i-test_block_given_to_proc) - -## test_block_method_to_proc() [](#method-i-test_block_method_to_proc) - -## test_block_persist_between_calls() [](#method-i-test_block_persist_between_calls) - -## test_call() [](#method-i-test_call) - -## test_case() [](#method-i-test_case) - -## test_casecmp() [](#method-i-test_casecmp) - -## test_casecmp?() [](#method-i-test_casecmp?) - -**@return** [Boolean] - -## test_cmp() [](#method-i-test_cmp) - -## test_dynamic_attrset_id() [](#method-i-test_dynamic_attrset_id) - -## test_empty() [](#method-i-test_empty) - -## test_end_with?() [](#method-i-test_end_with?) - -**@return** [Boolean] - -## test_eq_can_be_redefined() [](#method-i-test_eq_can_be_redefined) - -## test_frozen_symbol() [](#method-i-test_frozen_symbol) - -## test_hash_nondeterministic() [](#method-i-test_hash_nondeterministic) - -## test_hash_redefinition() [](#method-i-test_hash_redefinition) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect_dollar() [](#method-i-test_inspect_dollar) - -## test_inspect_invalid() [](#method-i-test_inspect_invalid) - -## test_inspect_number() [](#method-i-test_inspect_number) - -## test_inspect_suboptimal() [](#method-i-test_inspect_suboptimal) - -## test_inspect_under_gc_compact_stress() [](#method-i-test_inspect_under_gc_compact_stress) - -## test_instance_eval() [](#method-i-test_instance_eval) - -## test_instance_exec() [](#method-i-test_instance_exec) - -## test_intern() [](#method-i-test_intern) - -## test_length() [](#method-i-test_length) - -## test_match_method() [](#method-i-test_match_method) - -## test_match_p_regexp() [](#method-i-test_match_p_regexp) - -## test_match_p_string() [](#method-i-test_match_p_string) - -## test_name() [](#method-i-test_name) - -## test_return_from_symbol_proc() [](#method-i-test_return_from_symbol_proc) - -## test_singleton_method() [](#method-i-test_singleton_method) - -## test_start_with?() [](#method-i-test_start_with?) - -**@return** [Boolean] - -## test_succ() [](#method-i-test_succ) - -## test_symbol_encoding() [](#method-i-test_symbol_encoding) - -## test_symbol_fstr_memory_leak() [](#method-i-test_symbol_fstr_memory_leak) - -## test_symbol_gc_1() [](#method-i-test_symbol_gc_1) - -## test_symbol_popped() [](#method-i-test_symbol_popped) - -## test_to_proc() [](#method-i-test_to_proc) - -## test_to_proc_arg() [](#method-i-test_to_proc_arg) - -## test_to_proc_arg_with_refinements() [](#method-i-test_to_proc_arg_with_refinements) - -## test_to_proc_arg_with_refinements_override() [](#method-i-test_to_proc_arg_with_refinements_override) - -## test_to_proc_arg_with_refinements_undefined() [](#method-i-test_to_proc_arg_with_refinements_undefined) - -## test_to_proc_arity() [](#method-i-test_to_proc_arity) - -## test_to_proc_arity_with_refinements() [](#method-i-test_to_proc_arity_with_refinements) - -## test_to_proc_binding() [](#method-i-test_to_proc_binding) - -## test_to_proc_call_with_symbol_proc() [](#method-i-test_to_proc_call_with_symbol_proc) - -## test_to_proc_for_hash_each() [](#method-i-test_to_proc_for_hash_each) - -## test_to_proc_instance_exec() [](#method-i-test_to_proc_instance_exec) - -## test_to_proc_iseq() [](#method-i-test_to_proc_iseq) - -## test_to_proc_lambda?() [](#method-i-test_to_proc_lambda?) - -**@return** [Boolean] - -## test_to_proc_lambda_with_refinements() [](#method-i-test_to_proc_lambda_with_refinements) - -## test_to_proc_new_proc() [](#method-i-test_to_proc_new_proc) - -## test_to_proc_no_method() [](#method-i-test_to_proc_no_method) - -## test_to_proc_yield() [](#method-i-test_to_proc_yield) - diff --git a/example/ruby/TestSymbol/TestToPRocArgWithRefinements.md b/example/ruby/TestSymbol/TestToPRocArgWithRefinements.md deleted file mode 100644 index 1209183..0000000 --- a/example/ruby/TestSymbol/TestToPRocArgWithRefinements.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestSymbol::TestToPRocArgWithRefinements -**Inherits:** Object - - - - - diff --git a/example/ruby/TestSyntax.md b/example/ruby/TestSyntax.md deleted file mode 100644 index f0e1331..0000000 --- a/example/ruby/TestSyntax.md +++ /dev/null @@ -1,332 +0,0 @@ -# Class: TestSyntax -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_constant_reassignment_nested(preset, op, expected, err[], bug'[Bug #5449]') [](#method-i-assert_constant_reassignment_nested) - -## assert_constant_reassignment_toplevel(preset, op, expected, err[], bug'[Bug #5449]') [](#method-i-assert_constant_reassignment_toplevel) - -## assert_dedented_heredoc(expect, result, mesg"") [](#method-i-assert_dedented_heredoc) - -## assert_syntax_files(test) [](#method-i-assert_syntax_files) - -## test__END___cr() [](#method-i-test__END___cr) - -## test_alias_symbol() [](#method-i-test_alias_symbol) - -## test_anonymous_block_forwarding() [](#method-i-test_anonymous_block_forwarding) - -## test_anonymous_keyword_rest_forwarding() [](#method-i-test_anonymous_keyword_rest_forwarding) - -## test_anonymous_rest_forwarding() [](#method-i-test_anonymous_rest_forwarding) - -## test_argument_forwarding() [](#method-i-test_argument_forwarding) - -## test_argument_forwarding_with_anon_rest_kwrest_and_block() [](#method-i-test_argument_forwarding_with_anon_rest_kwrest_and_block) - -## test_argument_forwarding_with_leading_arguments() [](#method-i-test_argument_forwarding_with_leading_arguments) - -## test_argument_forwarding_with_super() [](#method-i-test_argument_forwarding_with_super) - -## test_argument_forwarding_with_super_memory_leak() [](#method-i-test_argument_forwarding_with_super_memory_leak) - -## test_array_kwsplat_hash() [](#method-i-test_array_kwsplat_hash) - -## test_assignment_return_in_loop() [](#method-i-test_assignment_return_in_loop) - -## test_block_after_cmdarg_in_paren() [](#method-i-test_block_after_cmdarg_in_paren) - -## test_block_after_cond() [](#method-i-test_block_after_cond) - -## test_brace_after_literal_argument() [](#method-i-test_brace_after_literal_argument) - -## test_brace_after_local_variable() [](#method-i-test_brace_after_local_variable) - -## test_cdhash() [](#method-i-test_cdhash) - -## test_class_module_Object_ancestors() [](#method-i-test_class_module_Object_ancestors) - -## test_classdef_in_cond() [](#method-i-test_classdef_in_cond) - -## test_cmd_symbol_after_keyword() [](#method-i-test_cmd_symbol_after_keyword) - -## test_cmd_symbol_in_string() [](#method-i-test_cmd_symbol_in_string) - -## test_cmd_symbol_singleton_class() [](#method-i-test_cmd_symbol_singleton_class) - -## test_cmd_symbol_superclass() [](#method-i-test_cmd_symbol_superclass) - -## test_cmdarg_in_paren() [](#method-i-test_cmdarg_in_paren) - -## test_cmdarg_kwarg_lvar_clashing_method() [](#method-i-test_cmdarg_kwarg_lvar_clashing_method) - -## test_command_do_block_call_with_empty_args_brace_block() [](#method-i-test_command_do_block_call_with_empty_args_brace_block) - -## test_command_newline_in_tlparen_args() [](#method-i-test_command_newline_in_tlparen_args) - -## test_command_semicolon_in_tlparen_at_the_first_arg() [](#method-i-test_command_semicolon_in_tlparen_at_the_first_arg) - -## test_command_with_cmd_brace_block() [](#method-i-test_command_with_cmd_brace_block) - -## test_constant_reassignment_nested() [](#method-i-test_constant_reassignment_nested) - -## test_constant_reassignment_toplevel() [](#method-i-test_constant_reassignment_toplevel) - -## test_dedented_heredoc_concatenation() [](#method-i-test_dedented_heredoc_concatenation) - -## test_dedented_heredoc_continued_line() [](#method-i-test_dedented_heredoc_continued_line) - -## test_dedented_heredoc_expr_at_beginning() [](#method-i-test_dedented_heredoc_expr_at_beginning) - -## test_dedented_heredoc_expr_string() [](#method-i-test_dedented_heredoc_expr_string) - -## test_dedented_heredoc_invalid_identifer() [](#method-i-test_dedented_heredoc_invalid_identifer) - -## test_dedented_heredoc_with_blank_less_indented_line() [](#method-i-test_dedented_heredoc_with_blank_less_indented_line) - -## test_dedented_heredoc_with_blank_less_indented_line_escaped() [](#method-i-test_dedented_heredoc_with_blank_less_indented_line_escaped) - -## test_dedented_heredoc_with_blank_more_indented_line() [](#method-i-test_dedented_heredoc_with_blank_more_indented_line) - -## test_dedented_heredoc_with_blank_more_indented_line_escaped() [](#method-i-test_dedented_heredoc_with_blank_more_indented_line_escaped) - -## test_dedented_heredoc_with_concatenation() [](#method-i-test_dedented_heredoc_with_concatenation) - -## test_dedented_heredoc_with_empty_line() [](#method-i-test_dedented_heredoc_with_empty_line) - -## test_dedented_heredoc_with_indentation() [](#method-i-test_dedented_heredoc_with_indentation) - -## test_dedented_heredoc_with_interpolated_expression() [](#method-i-test_dedented_heredoc_with_interpolated_expression) - -## test_dedented_heredoc_with_interpolated_string() [](#method-i-test_dedented_heredoc_with_interpolated_string) - -## test_dedented_heredoc_with_leading_blank_line() [](#method-i-test_dedented_heredoc_with_leading_blank_line) - -## test_dedented_heredoc_with_newline() [](#method-i-test_dedented_heredoc_with_newline) - -## test_dedented_heredoc_without_indentation() [](#method-i-test_dedented_heredoc_without_indentation) - -## test_defined_empty_argument() [](#method-i-test_defined_empty_argument) - -## test_defined_in_short_circuit_if_condition() [](#method-i-test_defined_in_short_circuit_if_condition) - -## test_do_after_local_variable() [](#method-i-test_do_after_local_variable) - -## test_do_block_after_lambda() [](#method-i-test_do_block_after_lambda) - -## test_do_block_in_call_args() [](#method-i-test_do_block_in_call_args) - -## test_do_block_in_cmdarg() [](#method-i-test_do_block_in_cmdarg) - -## test_do_block_in_cmdarg_begin() [](#method-i-test_do_block_in_cmdarg_begin) - -## test_do_block_in_hash_brace() [](#method-i-test_do_block_in_hash_brace) - -## test_do_block_in_lambda() [](#method-i-test_do_block_in_lambda) - -## test_duplicated_arg() [](#method-i-test_duplicated_arg) - -## test_duplicated_kw() [](#method-i-test_duplicated_kw) - -## test_duplicated_kw_kwrest() [](#method-i-test_duplicated_kw_kwrest) - -## test_duplicated_opt() [](#method-i-test_duplicated_opt) - -## test_duplicated_opt_kw() [](#method-i-test_duplicated_opt_kw) - -## test_duplicated_opt_kwrest() [](#method-i-test_duplicated_opt_kwrest) - -## test_duplicated_opt_post() [](#method-i-test_duplicated_opt_post) - -## test_duplicated_opt_rest() [](#method-i-test_duplicated_opt_rest) - -## test_duplicated_rest() [](#method-i-test_duplicated_rest) - -## test_duplicated_rest_kw() [](#method-i-test_duplicated_rest_kw) - -## test_duplicated_rest_kwrest() [](#method-i-test_duplicated_rest_kwrest) - -## test_duplicated_rest_opt() [](#method-i-test_duplicated_rest_opt) - -## test_duplicated_rest_post() [](#method-i-test_duplicated_rest_post) - -## test_duplicated_when() [](#method-i-test_duplicated_when) - -## test_duplicated_when_check_option() [](#method-i-test_duplicated_when_check_option) - -## test_error_message_encoding() [](#method-i-test_error_message_encoding) - -## test_eval_return_toplevel() [](#method-i-test_eval_return_toplevel) - -## test_fluent_dot() [](#method-i-test_fluent_dot) - -## test_hash_kwsplat_hash() [](#method-i-test_hash_kwsplat_hash) - -## test_heredoc_after_label() [](#method-i-test_heredoc_after_label) - -## test_heredoc_cr() [](#method-i-test_heredoc_cr) - -## test_heredoc_mixed_encoding() [](#method-i-test_heredoc_mixed_encoding) - -## test_heredoc_no_terminator() [](#method-i-test_heredoc_no_terminator) - -## test_integer_suffix() [](#method-i-test_integer_suffix) - -## test_invalid_break() [](#method-i-test_invalid_break) - -## test_invalid_encoding_symbol() [](#method-i-test_invalid_encoding_symbol) - -## test_invalid_jump() [](#method-i-test_invalid_jump) - -## test_invalid_literal_message() [](#method-i-test_invalid_literal_message) - -## test_invalid_next() [](#method-i-test_invalid_next) - -## test_invalid_regexp() [](#method-i-test_invalid_regexp) - -## test_invalid_symbol_in_hash_memory_leak() [](#method-i-test_invalid_symbol_in_hash_memory_leak) - -## test_invalid_symbol_space() [](#method-i-test_invalid_symbol_space) - -## test_it() [](#method-i-test_it) - -## test_keyword_duplicated() [](#method-i-test_keyword_duplicated) - -## test_keyword_duplicated_splat() [](#method-i-test_keyword_duplicated_splat) - -## test_keyword_empty_splat() [](#method-i-test_keyword_empty_splat) - -## test_keyword_invalid_name() [](#method-i-test_keyword_invalid_name) - -## test_keyword_not_parens() [](#method-i-test_keyword_not_parens) - -## test_keyword_rest() [](#method-i-test_keyword_rest) - -## test_keyword_self_reference() [](#method-i-test_keyword_self_reference) - -## test_keyword_splat() [](#method-i-test_keyword_splat) - -## test_keywords_specified_and_not_accepted() [](#method-i-test_keywords_specified_and_not_accepted) - -## test_lambda_with_space() [](#method-i-test_lambda_with_space) - -## test_lineno_after_heredoc() [](#method-i-test_lineno_after_heredoc) - -## test_lineno_command_call_quote() [](#method-i-test_lineno_command_call_quote) - -## test_lineno_operation_brace_block() [](#method-i-test_lineno_operation_brace_block) - -## test_method_call_location() [](#method-i-test_method_call_location) - -## test_methoddef_endless() [](#method-i-test_methoddef_endless) - -## test_methoddef_endless_command() [](#method-i-test_methoddef_endless_command) - -## test_methoddef_in_cond() [](#method-i-test_methoddef_in_cond) - -## test_must_ascii_compatible() [](#method-i-test_must_ascii_compatible) - -## test_newline_in_block_parameters() [](#method-i-test_newline_in_block_parameters) - -## test_no_label_with_percent() [](#method-i-test_no_label_with_percent) - -## test_no_warning_logop_literal() [](#method-i-test_no_warning_logop_literal) - -## test_normal_argument() [](#method-i-test_normal_argument) - -## test_null_range_cmdarg() [](#method-i-test_null_range_cmdarg) - -## test_numbered_parameter() [](#method-i-test_numbered_parameter) - -## test_optional_argument() [](#method-i-test_optional_argument) - -## test_optional_self_reference() [](#method-i-test_optional_self_reference) - -## test_paren_after_label() [](#method-i-test_paren_after_label) - -## test_parenthesised_statement_argument() [](#method-i-test_parenthesised_statement_argument) - -## test_percent_string_after_label() [](#method-i-test_percent_string_after_label) - -## test_range_at_eol() [](#method-i-test_range_at_eol) - -## test_rescue_do_end_ensure_in_lambda() [](#method-i-test_rescue_do_end_ensure_in_lambda) - -## test_rescue_do_end_ensure_result() [](#method-i-test_rescue_do_end_ensure_result) - -## test_rescue_do_end_no_raise() [](#method-i-test_rescue_do_end_no_raise) - -## test_rescue_do_end_raised() [](#method-i-test_rescue_do_end_raised) - -## test_rescue_do_end_rescued() [](#method-i-test_rescue_do_end_rescued) - -## test_reserved_method_no_args() [](#method-i-test_reserved_method_no_args) - -## test_return_in_BEGIN_in_eval() [](#method-i-test_return_in_BEGIN_in_eval) - -## test_return_in_END() [](#method-i-test_return_in_END) - -## test_return_in_loop() [](#method-i-test_return_in_loop) - -## test_return_in_proc_in_class() [](#method-i-test_return_in_proc_in_class) - -## test_return_toplevel() [](#method-i-test_return_toplevel) - -## test_return_toplevel_with_argument() [](#method-i-test_return_toplevel_with_argument) - -## test_safe_call_in_for_variable() [](#method-i-test_safe_call_in_for_variable) - -## test_safe_call_in_massign_lhs() [](#method-i-test_safe_call_in_massign_lhs) - -## test_script_lines() [](#method-i-test_script_lines) - -## test_script_lines_encoding() [](#method-i-test_script_lines_encoding) - -## test_syntax_error_at_newline() [](#method-i-test_syntax_error_at_newline) - -## test_syntax_error_in_rescue() [](#method-i-test_syntax_error_in_rescue) - -## test_syntax_ext() [](#method-i-test_syntax_ext) - -## test_syntax_lib() [](#method-i-test_syntax_lib) - -## test_syntax_sample() [](#method-i-test_syntax_sample) - -## test_syntax_test() [](#method-i-test_syntax_test) - -## test_tautological_condition() [](#method-i-test_tautological_condition) - -## test_too_big_nth_ref() [](#method-i-test_too_big_nth_ref) - -## test_unassignable() [](#method-i-test_unassignable) - -## test_undef_symbol() [](#method-i-test_undef_symbol) - -## test_unexpected_fraction() [](#method-i-test_unexpected_fraction) - -## test_unterminated_heredoc() [](#method-i-test_unterminated_heredoc) - -## test_unterminated_heredoc_cr() [](#method-i-test_unterminated_heredoc_cr) - -## test_value_expr_in_condition() [](#method-i-test_value_expr_in_condition) - -## test_value_expr_in_singleton() [](#method-i-test_value_expr_in_singleton) - -## test_value_of_def() [](#method-i-test_value_of_def) - -## test_warn_balanced() [](#method-i-test_warn_balanced) - -## test_warn_grouped_expression() [](#method-i-test_warn_grouped_expression) - -## test_warn_unreachable() [](#method-i-test_warn_unreachable) - -## test_warning_for_cr() [](#method-i-test_warning_for_cr) - -## test_warning_literal_in_condition() [](#method-i-test_warning_literal_in_condition) - -## test_warning_literal_in_flip_flop() [](#method-i-test_warning_literal_in_flip_flop) - diff --git a/example/ruby/TestSyntax/KW2.md b/example/ruby/TestSyntax/KW2.md deleted file mode 100644 index d6d3f1c..0000000 --- a/example/ruby/TestSyntax/KW2.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestSyntax::KW2 -**Inherits:** Object - - - - - -#Instance Methods -## kw(k1:1, k2:2) [](#method-i-kw) - diff --git a/example/ruby/TestSystem.md b/example/ruby/TestSystem.md deleted file mode 100644 index ecd59db..0000000 --- a/example/ruby/TestSystem.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestSystem -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_empty_evstr() [](#method-i-test_empty_evstr) - -## test_fallback_to_sh() [](#method-i-test_fallback_to_sh) - -## test_system() [](#method-i-test_system) - -## test_system_at() [](#method-i-test_system_at) - -## test_system_closed() [](#method-i-test_system_closed) - -## test_system_exception() [](#method-i-test_system_exception) - -## test_system_exception_nonascii() [](#method-i-test_system_exception_nonascii) - -## test_system_redirect_win() [](#method-i-test_system_redirect_win) - diff --git a/example/ruby/TestTRICK2013.md b/example/ruby/TestTRICK2013.md deleted file mode 100644 index def8cd1..0000000 --- a/example/ruby/TestTRICK2013.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestTRICK2013 -**Inherits:** Test::Unit::TestCase - - -This is a test suite for TRICK entries, joke Ruby program contest. The -programs are very unusual, and not practical. Feel free to comment them out if -they bother you. I'll appreciate it if you could notify mame - - - - -#Instance Methods -## test_kinaba() [](#method-i-test_kinaba) - -## test_mame() [](#method-i-test_mame) - -## test_shinh() [](#method-i-test_shinh) - -## test_yhara() [](#method-i-test_yhara) - diff --git a/example/ruby/TestTRICK2015.md b/example/ruby/TestTRICK2015.md deleted file mode 100644 index 254ece8..0000000 --- a/example/ruby/TestTRICK2015.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestTRICK2015 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_eregon() [](#method-i-test_eregon) - -## test_kinaba() [](#method-i-test_kinaba) - -## test_ksk_1() [](#method-i-test_ksk_1) - -## test_ksk_2() [](#method-i-test_ksk_2) - -## test_monae() [](#method-i-test_monae) - diff --git a/example/ruby/TestTRICK2018.md b/example/ruby/TestTRICK2018.md deleted file mode 100644 index 9610dd1..0000000 --- a/example/ruby/TestTRICK2018.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestTRICK2018 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_01_kinaba() [](#method-i-test_01_kinaba) - -## test_02_mame() [](#method-i-test_02_mame) - -## test_03_tompng() [](#method-i-test_03_tompng) - -## test_04_colin() [](#method-i-test_04_colin) - -## test_05_tompng() [](#method-i-test_05_tompng) - diff --git a/example/ruby/TestTRICK2022.md b/example/ruby/TestTRICK2022.md deleted file mode 100644 index 4f5ddc4..0000000 --- a/example/ruby/TestTRICK2022.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestTRICK2022 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_01_tompng() [](#method-i-test_01_tompng) - -## test_02_tompng() [](#method-i-test_02_tompng) - -## test_03_mame() [](#method-i-test_03_mame) - diff --git a/example/ruby/TestTempfile.md b/example/ruby/TestTempfile.md deleted file mode 100644 index a4cdd87..0000000 --- a/example/ruby/TestTempfile.md +++ /dev/null @@ -1,108 +0,0 @@ -# Class: TestTempfile -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_mktmpdir_traversal() [](#method-i-assert_mktmpdir_traversal) - -## initialize() [](#method-i-initialize) - -**@return** [TestTempfile] a new instance of TestTempfile - -## teardown() [](#method-i-teardown) - -## tempfile(*args, **kw, &block) [](#method-i-tempfile) - -## test_basename() [](#method-i-test_basename) - -## test_basename_with_suffix() [](#method-i-test_basename_with_suffix) - -## test_basic() [](#method-i-test_basic) - -## test_binmode() [](#method-i-test_binmode) - -## test_clone() [](#method-i-test_clone) - -## test_close_and_close_p() [](#method-i-test_close_and_close_p) - -## test_close_bang_does_not_unlink_if_already_unlinked() [](#method-i-test_close_bang_does_not_unlink_if_already_unlinked) - -## test_close_bang_works() [](#method-i-test_close_bang_works) - -## test_close_does_not_make_path_nil() [](#method-i-test_close_does_not_make_path_nil) - -## test_close_flushes_buffer() [](#method-i-test_close_flushes_buffer) - -## test_close_with_unlink_now_true_does_not_unlink_if_already_unlinked() [](#method-i-test_close_with_unlink_now_true_does_not_unlink_if_already_unlinked) - -## test_close_with_unlink_now_true_works() [](#method-i-test_close_with_unlink_now_true_works) - -## test_concurrency() [](#method-i-test_concurrency) - -## test_create_anonymous_autoclose() [](#method-i-test_create_anonymous_autoclose) - -## test_create_anonymous_path() [](#method-i-test_create_anonymous_path) - -## test_create_anonymous_removes_file() [](#method-i-test_create_anonymous_removes_file) - -## test_create_anonymous_with_block() [](#method-i-test_create_anonymous_with_block) - -## test_create_anonymous_without_block() [](#method-i-test_create_anonymous_without_block) - -## test_create_default_basename() [](#method-i-test_create_default_basename) - -## test_create_traversal_dir() [](#method-i-test_create_traversal_dir) - -## test_create_with_block() [](#method-i-test_create_with_block) - -## test_create_without_block() [](#method-i-test_create_without_block) - -## test_default_basename() [](#method-i-test_default_basename) - -## test_dup() [](#method-i-test_dup) - -## test_extend() [](#method-i-test_extend) - -## test_finalizer_does_not_unlink_if_already_unlinked() [](#method-i-test_finalizer_does_not_unlink_if_already_unlinked) - -## test_finalizer_removes_file() [](#method-i-test_finalizer_removes_file) - -## test_finalizer_removes_file_when_clone() [](#method-i-test_finalizer_removes_file_when_clone) - -## test_finalizer_removes_file_when_dup() [](#method-i-test_finalizer_removes_file_when_dup) - -## test_leakchecker() [](#method-i-test_leakchecker) - -## test_new_traversal_dir() [](#method-i-test_new_traversal_dir) - -## test_open() [](#method-i-test_open) - -## test_open_traversal_dir() [](#method-i-test_open_traversal_dir) - -## test_saves_in_given_directory() [](#method-i-test_saves_in_given_directory) - -## test_size_flushes_buffer_before_determining_file_size() [](#method-i-test_size_flushes_buffer_before_determining_file_size) - -## test_size_on_empty_file() [](#method-i-test_size_on_empty_file) - -## test_size_works_if_file_is_closed() [](#method-i-test_size_works_if_file_is_closed) - -## test_tempfile_encoding_ascii8bit() [](#method-i-test_tempfile_encoding_ascii8bit) - -## test_tempfile_encoding_ascii8bit2() [](#method-i-test_tempfile_encoding_ascii8bit2) - -## test_tempfile_encoding_nooption() [](#method-i-test_tempfile_encoding_nooption) - -## test_tempfile_finalizer_does_not_run_if_unlinked() [](#method-i-test_tempfile_finalizer_does_not_run_if_unlinked) - -## test_tempfile_is_unlinked_when_ruby_exits() [](#method-i-test_tempfile_is_unlinked_when_ruby_exits) - -## test_unlink() [](#method-i-test_unlink) - -## test_unlink_before_close_works_on_posix_systems() [](#method-i-test_unlink_before_close_works_on_posix_systems) - -## test_unlink_silently_fails_on_windows() [](#method-i-test_unlink_silently_fails_on_windows) - diff --git a/example/ruby/TestTempfile/M.md b/example/ruby/TestTempfile/M.md deleted file mode 100644 index c0d8d87..0000000 --- a/example/ruby/TestTempfile/M.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestTempfile::M - - - - - diff --git a/example/ruby/TestTestUnitSorting.md b/example/ruby/TestTestUnitSorting.md deleted file mode 100644 index 7000ecc..0000000 --- a/example/ruby/TestTestUnitSorting.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestTestUnitSorting -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## make_test_list() [](#method-i-make_test_list) - -## sorting(*args) [](#method-i-sorting) - -## test_sort_alpha() [](#method-i-test_sort_alpha) - -## test_sort_nosort() [](#method-i-test_sort_nosort) - -## test_sort_random() [](#method-i-test_sort_random) - -## test_sorting() [](#method-i-test_sorting) - diff --git a/example/ruby/TestTestUnitSorting/Item.md b/example/ruby/TestTestUnitSorting/Item.md deleted file mode 100644 index ac63eb6..0000000 --- a/example/ruby/TestTestUnitSorting/Item.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: TestTestUnitSorting::Item -**Inherits:** Struct - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name - -**@return** [Object] the current value of name - - diff --git a/example/ruby/TestThread.md b/example/ruby/TestThread.md deleted file mode 100644 index 77e4a38..0000000 --- a/example/ruby/TestThread.md +++ /dev/null @@ -1,200 +0,0 @@ -# Class: TestThread -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## execute(task ) [](#method-c-execute) -## foo() [](#method-c-foo) -## p(arg ) [](#method-c-p) -## synchronize() [](#method-c-synchronize) - -#Instance Methods -## for_test_handle_interrupt_with_return() [](#method-i-for_test_handle_interrupt_with_return) - -## invoke_rec(script, vm_stack_size, machine_stack_size, use_lengthtrue) [](#method-i-invoke_rec) - -## make_handle_interrupt_test_thread1(flag) [](#method-i-make_handle_interrupt_test_thread1) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_abort_on_exception() [](#method-i-test_abort_on_exception) - -## test_backtrace() [](#method-i-test_backtrace) - -## test_blocking_mutex_unlocked_on_fork() [](#method-i-test_blocking_mutex_unlocked_on_fork) - -## test_exit() [](#method-i-test_exit) - -## test_fork_in_thread() [](#method-i-test_fork_in_thread) - -## test_fork_value() [](#method-i-test_fork_value) - -## test_fork_while_locked() [](#method-i-test_fork_while_locked) - -## test_fork_while_mutex_locked_by_forker() [](#method-i-test_fork_while_mutex_locked_by_forker) - -## test_fork_while_parent_locked() [](#method-i-test_fork_while_parent_locked) - -## test_handle_interrupt() [](#method-i-test_handle_interrupt) - -## test_handle_interrupt_and_io() [](#method-i-test_handle_interrupt_and_io) - -## test_handle_interrupt_and_p() [](#method-i-test_handle_interrupt_and_p) - -## test_handle_interrupt_blocking() [](#method-i-test_handle_interrupt_blocking) - -## test_handle_interrupt_invalid_argument() [](#method-i-test_handle_interrupt_invalid_argument) - -## test_handle_interrupt_with_break() [](#method-i-test_handle_interrupt_with_break) - -## test_handle_interrupt_with_return() [](#method-i-test_handle_interrupt_with_return) - -## test_handle_interrupted?() [](#method-i-test_handle_interrupted?) - -**@return** [Boolean] - -## test_ignore_deadlock() [](#method-i-test_ignore_deadlock) - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect_with_fiber() [](#method-i-test_inspect_with_fiber) - -## test_join() [](#method-i-test_join) - -## test_join2() [](#method-i-test_join2) - -## test_join_argument_conversion() [](#method-i-test_join_argument_conversion) - -## test_kill_main_thread() [](#method-i-test_kill_main_thread) - -## test_kill_thread_subclass() [](#method-i-test_kill_thread_subclass) - -## test_kill_wrong_argument() [](#method-i-test_kill_wrong_argument) - -## test_list() [](#method-i-test_list) - -## test_local_barrier() [](#method-i-test_local_barrier) - -## test_machine_stack_size() [](#method-i-test_machine_stack_size) - -## test_main() [](#method-i-test_main) - -## test_main_thread_status_at_exit() [](#method-i-test_main_thread_status_at_exit) - -## test_main_thread_variable_in_enumerator() [](#method-i-test_main_thread_variable_in_enumerator) - -## test_mutex_deadlock() [](#method-i-test_mutex_deadlock) - -## test_mutex_fifo_like_lock() [](#method-i-test_mutex_fifo_like_lock) - -## test_mutex_illegal_unlock() [](#method-i-test_mutex_illegal_unlock) - -## test_mutex_interrupt() [](#method-i-test_mutex_interrupt) - -## test_mutex_owned() [](#method-i-test_mutex_owned) - -## test_mutex_owned2() [](#method-i-test_mutex_owned2) - -## test_mutex_synchronize() [](#method-i-test_mutex_synchronize) - -## test_mutex_synchronize_yields_no_block_params() [](#method-i-test_mutex_synchronize_yields_no_block_params) - -## test_mutex_trylock() [](#method-i-test_mutex_trylock) - -## test_mutex_unlock_on_trap() [](#method-i-test_mutex_unlock_on_trap) - -## test_new() [](#method-i-test_new) - -## test_new_symbol_proc() [](#method-i-test_new_symbol_proc) - -## test_no_valid_cfp() [](#method-i-test_no_valid_cfp) - -## test_pending_interrupt?() [](#method-i-test_pending_interrupt?) - -**@return** [Boolean] - -## test_priority() [](#method-i-test_priority) - -## test_recursive_outer() [](#method-i-test_recursive_outer) - -## test_report_on_exception() [](#method-i-test_report_on_exception) - -## test_select_wait() [](#method-i-test_select_wait) - -## test_signal_at_join() [](#method-i-test_signal_at_join) - -## test_stack_size() [](#method-i-test_stack_size) - -## test_status_and_stop_p() [](#method-i-test_status_and_stop_p) - -## test_stop() [](#method-i-test_stop) - -## test_subclass_no_initialize() [](#method-i-test_subclass_no_initialize) - -## test_switch_while_busy_loop() [](#method-i-test_switch_while_busy_loop) - -## test_thread_instance_variable() [](#method-i-test_thread_instance_variable) - -## test_thread_interrupt_for_killed_thread() [](#method-i-test_thread_interrupt_for_killed_thread) - -## test_thread_invalid_name() [](#method-i-test_thread_invalid_name) - -## test_thread_invalid_object() [](#method-i-test_thread_invalid_object) - -## test_thread_join_current() [](#method-i-test_thread_join_current) - -## test_thread_join_in_trap() [](#method-i-test_thread_join_in_trap) - -## test_thread_join_main_thread() [](#method-i-test_thread_join_main_thread) - -## test_thread_local() [](#method-i-test_thread_local) - -## test_thread_local_dynamic_symbol() [](#method-i-test_thread_local_dynamic_symbol) - -## test_thread_local_fetch() [](#method-i-test_thread_local_fetch) - -## test_thread_local_security() [](#method-i-test_thread_local_security) - -## test_thread_name() [](#method-i-test_thread_name) - -## test_thread_native_thread_id() [](#method-i-test_thread_native_thread_id) - -## test_thread_native_thread_id_across_fork_on_linux() [](#method-i-test_thread_native_thread_id_across_fork_on_linux) - -## test_thread_setname_in_initialize() [](#method-i-test_thread_setname_in_initialize) - -## test_thread_status_in_trap() [](#method-i-test_thread_status_in_trap) - -## test_thread_status_raise_after_kill() [](#method-i-test_thread_status_raise_after_kill) -Bug #7450 - -## test_thread_timer_and_ensure() [](#method-i-test_thread_timer_and_ensure) - -## test_thread_timer_and_interrupt() [](#method-i-test_thread_timer_and_interrupt) - -## test_thread_value_in_trap() [](#method-i-test_thread_value_in_trap) - -## test_thread_variable?() [](#method-i-test_thread_variable?) - -**@return** [Boolean] - -## test_thread_variable_frozen() [](#method-i-test_thread_variable_frozen) - -## test_thread_variable_in_enumerator() [](#method-i-test_thread_variable_in_enumerator) - -## test_thread_variable_strings_and_symbols_are_the_same_key() [](#method-i-test_thread_variable_strings_and_symbols_are_the_same_key) - -## test_thread_variables() [](#method-i-test_thread_variables) - -## test_uninitialized() [](#method-i-test_uninitialized) - -## test_vm_machine_stack_size() [](#method-i-test_vm_machine_stack_size) - -## test_wakeup() [](#method-i-test_wakeup) - -## test_yield_across_thread_through_enum() [](#method-i-test_yield_across_thread_through_enum) - diff --git a/example/ruby/TestThread/Thread.md b/example/ruby/TestThread/Thread.md deleted file mode 100644 index 45f751b..0000000 --- a/example/ruby/TestThread/Thread.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestThread::Thread -**Inherits:** Thread - - - - -# Class Methods -## new() [](#method-c-new) - diff --git a/example/ruby/TestThreadConditionVariable.md b/example/ruby/TestThreadConditionVariable.md deleted file mode 100644 index d3ace81..0000000 --- a/example/ruby/TestThreadConditionVariable.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestThreadConditionVariable -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_condvar_empty_broadcast() [](#method-i-test_condvar_empty_broadcast) - -## test_condvar_empty_signal() [](#method-i-test_condvar_empty_signal) - -## test_condvar_fork() [](#method-i-test_condvar_fork) - -## test_condvar_nolock() [](#method-i-test_condvar_nolock) - -## test_condvar_nolock_2() [](#method-i-test_condvar_nolock_2) - -## test_condvar_nolock_3() [](#method-i-test_condvar_nolock_3) - -## test_condvar_signal_and_wait() [](#method-i-test_condvar_signal_and_wait) - -## test_condvar_timed_wait() [](#method-i-test_condvar_timed_wait) - -## test_condvar_wait_and_broadcast() [](#method-i-test_condvar_wait_and_broadcast) - -## test_condvar_wait_deadlock() [](#method-i-test_condvar_wait_deadlock) - -## test_condvar_wait_deadlock_2() [](#method-i-test_condvar_wait_deadlock_2) - -## test_condvar_wait_exception_handling() [](#method-i-test_condvar_wait_exception_handling) - -## test_dump() [](#method-i-test_dump) - -## test_dup() [](#method-i-test_dup) - diff --git a/example/ruby/TestThreadFdClose.md b/example/ruby/TestThreadFdClose.md deleted file mode 100644 index fdee3c8..0000000 --- a/example/ruby/TestThreadFdClose.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestThreadFdClose -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_thread_fd_close() [](#method-i-test_thread_fd_close) - diff --git a/example/ruby/TestThreadGroup.md b/example/ruby/TestThreadGroup.md deleted file mode 100644 index 6ca1cf7..0000000 --- a/example/ruby/TestThreadGroup.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestThreadGroup -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_enclosed_thgroup() [](#method-i-test_enclosed_thgroup) - -## test_frozen_thgroup() [](#method-i-test_frozen_thgroup) - -## test_thread_init() [](#method-i-test_thread_init) - diff --git a/example/ruby/TestThreadInstrumentation.md b/example/ruby/TestThreadInstrumentation.md deleted file mode 100644 index 69f5245..0000000 --- a/example/ruby/TestThreadInstrumentation.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: TestThreadInstrumentation -**Inherits:** Test::Unit::TestCase - -**Includes:** ThreadInstrumentation::TestHelper - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_blocking_on_ractor() [](#method-i-test_blocking_on_ractor) - -## test_io_release_gvl() [](#method-i-test_io_release_gvl) - -## test_join_suspends() [](#method-i-test_join_suspends) -Bug #18900 - -## test_multi_thread_timeline() [](#method-i-test_multi_thread_timeline) - -## test_queue_releases_gvl() [](#method-i-test_queue_releases_gvl) - -## test_single_thread_timeline() [](#method-i-test_single_thread_timeline) - -## test_sleeping_inside_ractor() [](#method-i-test_sleeping_inside_ractor) - -## test_thread_blocked_forever_on_mutex() [](#method-i-test_thread_blocked_forever_on_mutex) - -## test_thread_blocked_temporarily_on_mutex() [](#method-i-test_thread_blocked_temporarily_on_mutex) - -## test_thread_instrumentation_fork_safe() [](#method-i-test_thread_instrumentation_fork_safe) - -## test_thread_instrumentation_unregister() [](#method-i-test_thread_instrumentation_unregister) - -## test_thread_pass_multi_thread() [](#method-i-test_thread_pass_multi_thread) - -## test_thread_pass_single_thread() [](#method-i-test_thread_pass_single_thread) - diff --git a/example/ruby/TestThreadLockNativeThread.md b/example/ruby/TestThreadLockNativeThread.md deleted file mode 100644 index e7fbba5..0000000 --- a/example/ruby/TestThreadLockNativeThread.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestThreadLockNativeThread -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_lock_native_thread() [](#method-i-test_lock_native_thread) - -## test_lock_native_thread_tls() [](#method-i-test_lock_native_thread_tls) - diff --git a/example/ruby/TestThreadQueue.md b/example/ruby/TestThreadQueue.md deleted file mode 100644 index c6fdac1..0000000 --- a/example/ruby/TestThreadQueue.md +++ /dev/null @@ -1,101 +0,0 @@ -# Class: TestThreadQueue -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## close_wakeup(num_items, num_threads, &qcreate) [](#method-i-close_wakeup) -test that waiting producers are woken up on close - -## grind(num_threads, num_objects, num_iterations, klass, *args) [](#method-i-grind) - -## sized_queue_size_close() [](#method-i-sized_queue_size_close) -size should account for waiting pushers during shutdown - -## test_blocked_pushers() [](#method-i-test_blocked_pushers) - -## test_blocked_pushers_empty() [](#method-i-test_blocked_pushers_empty) - -## test_close() [](#method-i-test_close) - -## test_close_twice() [](#method-i-test_close_twice) - -## test_deny_pushers() [](#method-i-test_deny_pushers) - -## test_dump() [](#method-i-test_dump) - -## test_dup() [](#method-i-test_dup) - -## test_empty_non_blocking() [](#method-i-test_empty_non_blocking) -make sure that shutdown state is handled properly by empty? for the -non-blocking case - -## test_fork_while_queue_waiting() [](#method-i-test_fork_while_queue_waiting) - -## test_freeze() [](#method-i-test_freeze) - -## test_one_element_sized_queue() [](#method-i-test_one_element_sized_queue) -test thread wakeup on one-element SizedQueue with close - -## test_queue() [](#method-i-test_queue) - -## test_queue_clear_return_value() [](#method-i-test_queue_clear_return_value) - -## test_queue_close_multi_multi() [](#method-i-test_queue_close_multi_multi) - -## test_queue_close_wakeup() [](#method-i-test_queue_close_wakeup) - -## test_queue_initialize() [](#method-i-test_queue_initialize) - -## test_queue_initialized() [](#method-i-test_queue_initialized) - -## test_queue_pop_interrupt() [](#method-i-test_queue_pop_interrupt) - -## test_queue_pop_non_block() [](#method-i-test_queue_pop_non_block) - -## test_queue_pop_timeout() [](#method-i-test_queue_pop_timeout) - -## test_queue_push_return_value() [](#method-i-test_queue_push_return_value) - -## test_queue_thread_raise() [](#method-i-test_queue_thread_raise) - -## test_queue_with_trap() [](#method-i-test_queue_with_trap) - -## test_size_queue_close_wakeup() [](#method-i-test_size_queue_close_wakeup) - -## test_sized_queue() [](#method-i-test_sized_queue) - -## test_sized_queue_assign_max() [](#method-i-test_sized_queue_assign_max) - -## test_sized_queue_clear() [](#method-i-test_sized_queue_clear) - -## test_sized_queue_clear_return_value() [](#method-i-test_sized_queue_clear_return_value) - -## test_sized_queue_closed_push_non_blocking() [](#method-i-test_sized_queue_closed_push_non_blocking) - -## test_sized_queue_initialize() [](#method-i-test_sized_queue_initialize) - -## test_sized_queue_initialized() [](#method-i-test_sized_queue_initialized) - -## test_sized_queue_one_closed_interrupt() [](#method-i-test_sized_queue_one_closed_interrupt) - -## test_sized_queue_pop_interrupt() [](#method-i-test_sized_queue_pop_interrupt) - -## test_sized_queue_pop_non_block() [](#method-i-test_sized_queue_pop_non_block) - -## test_sized_queue_pop_timeout() [](#method-i-test_sized_queue_pop_timeout) - -## test_sized_queue_push_interrupt() [](#method-i-test_sized_queue_push_interrupt) - -## test_sized_queue_push_non_block() [](#method-i-test_sized_queue_push_non_block) - -## test_sized_queue_push_return_value() [](#method-i-test_sized_queue_push_return_value) - -## test_sized_queue_push_timeout() [](#method-i-test_sized_queue_push_timeout) - -## test_sized_queue_throttle() [](#method-i-test_sized_queue_throttle) - -## test_thr_kill() [](#method-i-test_thr_kill) - diff --git a/example/ruby/TestTiemout.md b/example/ruby/TestTiemout.md deleted file mode 100644 index 082fc9f..0000000 --- a/example/ruby/TestTiemout.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestTiemout -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_timeout() [](#method-i-test_timeout) - diff --git a/example/ruby/TestTime.md b/example/ruby/TestTime.md deleted file mode 100644 index 8220fdf..0000000 --- a/example/ruby/TestTime.md +++ /dev/null @@ -1,204 +0,0 @@ -# Class: TestTime -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_marshal_roundtrip(t) [](#method-i-assert_marshal_roundtrip) - -## assert_zone_encoding(time) [](#method-i-assert_zone_encoding) - -## get_t2000() [](#method-i-get_t2000) - -## in_timezone(zone) [](#method-i-in_timezone) - -## negative_time_t?() [](#method-i-negative_time_t?) - -**@return** [Boolean] - -## no_leap_seconds?() [](#method-i-no_leap_seconds?) - -**@return** [Boolean] - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_1901() [](#method-i-test_1901) - -## test_1970() [](#method-i-test_1970) - -## test_2038() [](#method-i-test_2038) - -## test_asctime() [](#method-i-test_asctime) - -## test_at() [](#method-i-test_at) - -## test_at2() [](#method-i-test_at2) - -## test_at3() [](#method-i-test_at3) - -## test_at_rational() [](#method-i-test_at_rational) - -## test_at_splat() [](#method-i-test_at_splat) - -## test_at_with_unit() [](#method-i-test_at_with_unit) - -## test_big_minus() [](#method-i-test_big_minus) - -## test_ceil() [](#method-i-test_ceil) - -## test_cmp() [](#method-i-test_cmp) - -## test_deconstruct_keys() [](#method-i-test_deconstruct_keys) - -## test_delegate() [](#method-i-test_delegate) - -## test_eq_nsec() [](#method-i-test_eq_nsec) - -## test_eql() [](#method-i-test_eql) - -## test_floor() [](#method-i-test_floor) - -## test_future() [](#method-i-test_future) - -## test_getlocal_dont_share_eigenclass() [](#method-i-test_getlocal_dont_share_eigenclass) - -## test_getlocal_nil() [](#method-i-test_getlocal_nil) - -## test_getlocal_utc() [](#method-i-test_getlocal_utc) - -## test_getlocal_utc_offset() [](#method-i-test_getlocal_utc_offset) - -## test_hash() [](#method-i-test_hash) - -## test_huge_difference() [](#method-i-test_huge_difference) - -## test_init_copy() [](#method-i-test_init_copy) - -## test_inspect() [](#method-i-test_inspect) - -## test_localtime_gmtime() [](#method-i-test_localtime_gmtime) - -## test_marshal_broken_month() [](#method-i-test_marshal_broken_month) - -## test_marshal_broken_offset() [](#method-i-test_marshal_broken_offset) - -## test_marshal_broken_zone() [](#method-i-test_marshal_broken_zone) - -## test_marshal_distant_future() [](#method-i-test_marshal_distant_future) - -## test_marshal_distant_past() [](#method-i-test_marshal_distant_past) - -## test_marshal_ivar() [](#method-i-test_marshal_ivar) - -## test_marshal_nsec() [](#method-i-test_marshal_nsec) - -## test_marshal_nsec_191() [](#method-i-test_marshal_nsec_191) - -## test_marshal_rational() [](#method-i-test_marshal_rational) - -## test_marshal_timezone() [](#method-i-test_marshal_timezone) - -## test_marshal_to_s() [](#method-i-test_marshal_to_s) - -## test_marshal_zone() [](#method-i-test_marshal_zone) - -## test_marshal_zone_gc() [](#method-i-test_marshal_zone_gc) - -## test_memsize() [](#method-i-test_memsize) - -## test_minus() [](#method-i-test_minus) - -## test_new() [](#method-i-test_new) - -## test_new_from_string() [](#method-i-test_new_from_string) - -## test_num_exact_error() [](#method-i-test_num_exact_error) - -## test_parse_zero_bigint() [](#method-i-test_parse_zero_bigint) - -## test_past() [](#method-i-test_past) - -## test_plus_minus() [](#method-i-test_plus_minus) - -## test_plus_type() [](#method-i-test_plus_type) - -## test_readers() [](#method-i-test_readers) - -## test_reinitialize() [](#method-i-test_reinitialize) - -## test_round() [](#method-i-test_round) - -## test_sec_str() [](#method-i-test_sec_str) - -## test_strfimte_zoneoffset() [](#method-i-test_strfimte_zoneoffset) - -## test_strftime() [](#method-i-test_strftime) - -## test_strftime_ctrlchar() [](#method-i-test_strftime_ctrlchar) - -## test_strftime_far_future() [](#method-i-test_strftime_far_future) - -## test_strftime_flags() [](#method-i-test_strftime_flags) - -## test_strftime_invalid_flags() [](#method-i-test_strftime_invalid_flags) - -## test_strftime_invalid_modifier() [](#method-i-test_strftime_invalid_modifier) - -## test_strftime_padding() [](#method-i-test_strftime_padding) - -## test_strftime_rational() [](#method-i-test_strftime_rational) - -## test_strftime_sec() [](#method-i-test_strftime_sec) - -## test_strftime_seconds_from_epoch() [](#method-i-test_strftime_seconds_from_epoch) - -## test_strftime_subsec() [](#method-i-test_strftime_subsec) - -## test_strftime_too_wide() [](#method-i-test_strftime_too_wide) - -## test_strftime_weekflags() [](#method-i-test_strftime_weekflags) - -## test_strftime_weeknum() [](#method-i-test_strftime_weeknum) - -## test_strftime_wide_precision() [](#method-i-test_strftime_wide_precision) - -## test_strftime_year() [](#method-i-test_strftime_year) - -## test_strftime_yearday_on_last_day_of_year() [](#method-i-test_strftime_yearday_on_last_day_of_year) - -## test_strftime_zone() [](#method-i-test_strftime_zone) - -## test_strtime() [](#method-i-test_strtime) - -## test_time_add() [](#method-i-test_time_add) - -## test_time_interval() [](#method-i-test_time_interval) - -## test_time_subt() [](#method-i-test_time_subt) - -## test_time_time() [](#method-i-test_time_time) - -## test_timegm() [](#method-i-test_timegm) - -## test_to_f() [](#method-i-test_to_f) - -## test_to_f_accuracy() [](#method-i-test_to_f_accuracy) - -## test_to_r() [](#method-i-test_to_r) - -## test_to_s() [](#method-i-test_to_s) - -## test_utc_or_local() [](#method-i-test_utc_or_local) - -## test_utc_p() [](#method-i-test_utc_p) - -## test_utc_subsecond() [](#method-i-test_utc_subsecond) - -## test_xmlschema_encode() [](#method-i-test_xmlschema_encode) - -## test_zone() [](#method-i-test_zone) - diff --git a/example/ruby/TestTimeExtension.md b/example/ruby/TestTimeExtension.md deleted file mode 100644 index 8f98fa7..0000000 --- a/example/ruby/TestTimeExtension.md +++ /dev/null @@ -1,82 +0,0 @@ -# Class: TestTimeExtension -**Inherits:** Test::Unit::TestCase - - -:nodoc: - - - -#Instance Methods -## subtest_xmlschema(method) [](#method-i-subtest_xmlschema) -http://www.w3.org/TR/xmlschema-2/ - -## subtest_xmlschema_alias(method) [](#method-i-subtest_xmlschema_alias) - -## subtest_xmlschema_encode(method) [](#method-i-subtest_xmlschema_encode) - -## subtest_xmlschema_fraction(method) [](#method-i-subtest_xmlschema_fraction) - -## subtest_xmlschema_leap_second(method) [](#method-i-subtest_xmlschema_leap_second) - -## subtest_xmlschema_nsec(method) [](#method-i-subtest_xmlschema_nsec) - -## test_completion() [](#method-i-test_completion) - -## test_completion_with_different_timezone() [](#method-i-test_completion_with_different_timezone) - -## test_encode_httpdate() [](#method-i-test_encode_httpdate) - -## test_encode_rfc2822() [](#method-i-test_encode_rfc2822) - -## test_huge_precision() [](#method-i-test_huge_precision) - -## test_invalid() [](#method-i-test_invalid) - -## test_nsec() [](#method-i-test_nsec) - -## test_parse_fraction() [](#method-i-test_parse_fraction) - -## test_parse_leap_second() [](#method-i-test_parse_leap_second) - -## test_parse_now_nil() [](#method-i-test_parse_now_nil) - -## test_parse_offset_hour_minute_second() [](#method-i-test_parse_offset_hour_minute_second) - -## test_parse_with_various_object() [](#method-i-test_parse_with_various_object) - -## test_rfc2616() [](#method-i-test_rfc2616) - -## test_rfc2822() [](#method-i-test_rfc2822) - -## test_rfc2822_leap_second() [](#method-i-test_rfc2822_leap_second) - -## test_rfc2822_nonlinear() [](#method-i-test_rfc2822_nonlinear) - -## test_rfc2822_ractor() [](#method-i-test_rfc2822_ractor) - -## test_rfc2822_utc_roundtrip_summer() [](#method-i-test_rfc2822_utc_roundtrip_summer) - -## test_rfc2822_utc_roundtrip_winter() [](#method-i-test_rfc2822_utc_roundtrip_winter) - -## test_rfc822() [](#method-i-test_rfc822) - -## test_ruby_talk_152866() [](#method-i-test_ruby_talk_152866) - -## test_strptime() [](#method-i-test_strptime) - -## test_strptime_Ymd_z() [](#method-i-test_strptime_Ymd_z) - -## test_strptime_empty() [](#method-i-test_strptime_empty) - -## test_strptime_j() [](#method-i-test_strptime_j) - -## test_strptime_p() [](#method-i-test_strptime_p) - -## test_strptime_s_N() [](#method-i-test_strptime_s_N) - -## test_strptime_s_z() [](#method-i-test_strptime_s_z) - -## test_strptime_wuvg() [](#method-i-test_strptime_wuvg) - -## test_zone_0000() [](#method-i-test_zone_0000) - diff --git a/example/ruby/TestTimeExtension/MyDate.md b/example/ruby/TestTimeExtension/MyDate.md deleted file mode 100644 index 6857142..0000000 --- a/example/ruby/TestTimeExtension/MyDate.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestTimeExtension::MyDate -**Inherits:** Object - - - - -# Attributes -## day[RW] [](#attribute-i-day) -Returns the value of attribute day. - -## mon[RW] [](#attribute-i-mon) -Returns the value of attribute mon. - -## year[RW] [](#attribute-i-year) -Returns the value of attribute year. - - -#Instance Methods -## initialize(mon, day, year) [](#method-i-initialize) - -**@return** [MyDate] a new instance of MyDate - diff --git a/example/ruby/TestTimeTZ.md b/example/ruby/TestTimeTZ.md deleted file mode 100644 index cf2cfd1..0000000 --- a/example/ruby/TestTimeTZ.md +++ /dev/null @@ -1,72 +0,0 @@ -# Class: TestTimeTZ -**Inherits:** Test::Unit::TestCase - -**Extended by:** TestTimeTZ::Util - -**Includes:** TestTimeTZ::Util - - - - -# Class Methods -## format_gmtoff(gmtoff , colon false) [](#method-c-format_gmtoff) -## format_gmtoff2(gmtoff ) [](#method-c-format_gmtoff2) -## gen_test_name(hint ) [](#method-c-gen_test_name) -## gen_variational_zdump_test(hint , data ) [](#method-c-gen_variational_zdump_test) -## gen_zdump_test(data ) [](#method-c-gen_zdump_test) -## group_by(e , &block ) [](#method-c-group_by) -## have_tz_offset?(tz ) [](#method-c-have_tz_offset?) -**@return** [Boolean] - -## parse_zdump_line(line ) [](#method-c-parse_zdump_line) -## with_tz(tz ) [](#method-c-with_tz) - -#Instance Methods -## assert_time_constructor(tz, expected, method, args, messagenil) [](#method-i-assert_time_constructor) - -## format_gmtoff(gmtoff, colonfalse) [](#method-i-format_gmtoff) - -## format_gmtoff2(gmtoff) [](#method-i-format_gmtoff2) - -## group_by(e, &block) [](#method-i-group_by) - -## have_tz_offset?(tz) [](#method-i-have_tz_offset?) - -**@return** [Boolean] - -## test_america_los_angeles() [](#method-i-test_america_los_angeles) - -## test_america_managua() [](#method-i-test_america_managua) - -## test_asia_kuala_lumpur() [](#method-i-test_asia_kuala_lumpur) - -## test_asia_singapore() [](#method-i-test_asia_singapore) - -## test_asia_tokyo() [](#method-i-test_asia_tokyo) - -## test_canada_newfoundland() [](#method-i-test_canada_newfoundland) - -## test_europe_berlin() [](#method-i-test_europe_berlin) - -## test_europe_brussels() [](#method-i-test_europe_brussels) - -## test_europe_lisbon() [](#method-i-test_europe_lisbon) - -## test_localtime_zone() [](#method-i-test_localtime_zone) - -## test_military_names() [](#method-i-test_military_names) - -## test_pacific_kiritimati() [](#method-i-test_pacific_kiritimati) - -## test_right_america_los_angeles() [](#method-i-test_right_america_los_angeles) - -## test_right_utc() [](#method-i-test_right_utc) - -## test_right_utc_switching() [](#method-i-test_right_utc_switching) - -## test_utc_names() [](#method-i-test_utc_names) - -## time_to_s(t) [](#method-i-time_to_s) - -## with_tz(tz) [](#method-i-with_tz) - diff --git a/example/ruby/TestTimeTZ/DummyTZ.md b/example/ruby/TestTimeTZ/DummyTZ.md deleted file mode 100644 index c0d7c86..0000000 --- a/example/ruby/TestTimeTZ/DummyTZ.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: TestTimeTZ::DummyTZ -**Inherits:** Test::Unit::TestCase - -**Includes:** TestTimeTZ::WithTZ - - - - -# Class Methods -## make_timezone(tzname , abbr , utc_offset , abbr2 nil, utc_offset2 nil) [](#method-c-make_timezone) - -#Instance Methods -## make_timezone(tzname, abbr, utc_offset, abbr2nil, utc_offset2nil) [](#method-i-make_timezone) - -## nametest_marshal_compatibility(time_class, tzname, abbr, utc_offset) [](#method-i-nametest_marshal_compatibility) - -## subtest_at(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_at) - -## subtest_dst?(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_dst?) - -**@return** [Boolean] - -## subtest_fractional_second(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_fractional_second) - -## subtest_getlocal(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_getlocal) - -## subtest_hour24(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_hour24) - -## subtest_marshal(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_marshal) - -## subtest_new(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_new) - -## subtest_now(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_now) - -## subtest_plus(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_plus) - -## subtest_strftime(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_strftime) - -## subtest_to_a(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_to_a) - -## test_fractional_second() [](#method-i-test_fractional_second) - -## test_invalid_zone() [](#method-i-test_invalid_zone) - diff --git a/example/ruby/TestTimeTZ/DummyTZ/TIME_CLASS.md b/example/ruby/TestTimeTZ/DummyTZ/TIME_CLASS.md deleted file mode 100644 index 87f3c5f..0000000 --- a/example/ruby/TestTimeTZ/DummyTZ/TIME_CLASS.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TestTimeTZ::DummyTZ::TIME_CLASS -**Inherits:** Time - - - - -# Class Methods -## find_timezone(tzname ) [](#method-c-find_timezone) - diff --git a/example/ruby/TestTimeTZ/TZ.md b/example/ruby/TestTimeTZ/TZ.md deleted file mode 100644 index a51838a..0000000 --- a/example/ruby/TestTimeTZ/TZ.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestTimeTZ::TZ -**Inherits:** Object - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## abbr(t) [](#method-i-abbr) - -## dst?(t) [](#method-i-dst?) - -**@return** [Boolean] - -## initialize(name, abbr, offset, abbr2nil, offset2nil) [](#method-i-initialize) - -**@return** [TZ] a new instance of TZ - -## inspect() [](#method-i-inspect) - -## local_to_utc(t) [](#method-i-local_to_utc) - -## offset(t) [](#method-i-offset) - -## utc_to_local(t) [](#method-i-utc_to_local) - diff --git a/example/ruby/TestTimeTZ/Util.md b/example/ruby/TestTimeTZ/Util.md deleted file mode 100644 index 747c87c..0000000 --- a/example/ruby/TestTimeTZ/Util.md +++ /dev/null @@ -1,19 +0,0 @@ -# Module: TestTimeTZ::Util - - - - - -#Instance Methods -## format_gmtoff(gmtoff, colonfalse) [](#method-i-format_gmtoff) - -## format_gmtoff2(gmtoff) [](#method-i-format_gmtoff2) - -## group_by(e, &block) [](#method-i-group_by) - -## have_tz_offset?(tz) [](#method-i-have_tz_offset?) - -**@return** [Boolean] - -## with_tz(tz) [](#method-i-with_tz) - diff --git a/example/ruby/TestTimeTZ/WithTZ.md b/example/ruby/TestTimeTZ/WithTZ.md deleted file mode 100644 index 9145e39..0000000 --- a/example/ruby/TestTimeTZ/WithTZ.md +++ /dev/null @@ -1,37 +0,0 @@ -# Module: TestTimeTZ::WithTZ - - - - - -#Instance Methods -## make_timezone(tzname, abbr, utc_offset, abbr2nil, utc_offset2nil) [](#method-i-make_timezone) - -## nametest_marshal_compatibility(time_class, tzname, abbr, utc_offset) [](#method-i-nametest_marshal_compatibility) - -## subtest_at(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_at) - -## subtest_dst?(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_dst?) - -**@return** [Boolean] - -## subtest_fractional_second(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_fractional_second) - -## subtest_getlocal(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_getlocal) - -## subtest_hour24(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_hour24) - -## subtest_marshal(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_marshal) - -## subtest_new(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_new) - -## subtest_now(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_now) - -## subtest_plus(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_plus) - -## subtest_strftime(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_strftime) - -## subtest_to_a(time_class, tz, tzarg, tzname, abbr, utc_offset) [](#method-i-subtest_to_a) - -## test_invalid_zone() [](#method-i-test_invalid_zone) - diff --git a/example/ruby/TestTimeout.md b/example/ruby/TestTimeout.md deleted file mode 100644 index f174e30..0000000 --- a/example/ruby/TestTimeout.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: TestTimeout -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## zero?() [](#method-c-zero?) -**@return** [Boolean] - - -#Instance Methods -## test_allows_nil_seconds() [](#method-i-test_allows_nil_seconds) - -## test_allows_zero_seconds() [](#method-i-test_allows_zero_seconds) - -## test_cannot_convert_into_time_interval() [](#method-i-test_cannot_convert_into_time_interval) - -## test_custom_exception() [](#method-i-test_custom_exception) - -## test_enumerator_next() [](#method-i-test_enumerator_next) - -## test_exit_exception() [](#method-i-test_exit_exception) - -## test_fork() [](#method-i-test_fork) - -## test_handle_interrupt() [](#method-i-test_handle_interrupt) - -## test_handling_enclosed_threadgroup() [](#method-i-test_handling_enclosed_threadgroup) -https://github.com/ruby/timeout/issues/24 - -## test_included() [](#method-i-test_included) - -## test_nested_timeout() [](#method-i-test_nested_timeout) - -## test_nested_timeout_error_identity() [](#method-i-test_nested_timeout_error_identity) -DOES NOT fail with -* raise new(message) if exc.equal?(e) -+ raise new(message) if exc.class == e.class - -## test_nested_timeout_which_error_bubbles_up() [](#method-i-test_nested_timeout_which_error_bubbles_up) -DOES fail with -* raise new(message) if exc.equal?(e) -+ raise new(message) if exc.class == e.class - -## test_non_timing_out_code_is_successful() [](#method-i-test_non_timing_out_code_is_successful) - -## test_queue() [](#method-i-test_queue) - -## test_raise_for_neg_second() [](#method-i-test_raise_for_neg_second) - -## test_raise_with_message() [](#method-i-test_raise_with_message) - -## test_raises_exception_internally() [](#method-i-test_raises_exception_internally) - -## test_rescue_exit() [](#method-i-test_rescue_exit) - -## test_skip_rescue_standarderror() [](#method-i-test_skip_rescue_standarderror) - -## test_threadgroup() [](#method-i-test_threadgroup) - -## test_timeout() [](#method-i-test_timeout) - -## test_work_is_done_in_same_fiber_as_caller() [](#method-i-test_work_is_done_in_same_fiber_as_caller) - -## test_work_is_done_in_same_thread_as_caller() [](#method-i-test_work_is_done_in_same_thread_as_caller) - -## test_yield_param() [](#method-i-test_yield_param) - diff --git a/example/ruby/TestTimeout/MyNewErrorInner.md b/example/ruby/TestTimeout/MyNewErrorInner.md deleted file mode 100644 index edc1147..0000000 --- a/example/ruby/TestTimeout/MyNewErrorInner.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestTimeout::MyNewErrorInner -**Inherits:** StandardError - - - - - diff --git a/example/ruby/TestTimeout/MyNewErrorOuter.md b/example/ruby/TestTimeout/MyNewErrorOuter.md deleted file mode 100644 index 712e563..0000000 --- a/example/ruby/TestTimeout/MyNewErrorOuter.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: TestTimeout::MyNewErrorOuter -**Inherits:** StandardError - - - - - diff --git a/example/ruby/TestTmpdir.md b/example/ruby/TestTmpdir.md deleted file mode 100644 index cf08a3c..0000000 --- a/example/ruby/TestTmpdir.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TestTmpdir -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_mktmpdir_traversal() [](#method-i-assert_mktmpdir_traversal) - -## test_mktmpdir_mutate() [](#method-i-test_mktmpdir_mutate) - -## test_mktmpdir_nil() [](#method-i-test_mktmpdir_nil) - -## test_mktmpdir_not_empty_parent() [](#method-i-test_mktmpdir_not_empty_parent) - -## test_mktmpdir_traversal() [](#method-i-test_mktmpdir_traversal) - -## test_mktmpdir_traversal_array() [](#method-i-test_mktmpdir_traversal_array) - -## test_no_homedir() [](#method-i-test_no_homedir) - -## test_ractor() [](#method-i-test_ractor) - -## test_tmpdir_modifiable() [](#method-i-test_tmpdir_modifiable) - -## test_tmpdir_not_empty_parent() [](#method-i-test_tmpdir_not_empty_parent) - -## test_world_writable() [](#method-i-test_world_writable) - diff --git a/example/ruby/TestTrace.md b/example/ruby/TestTrace.md deleted file mode 100644 index 0227f44..0000000 --- a/example/ruby/TestTrace.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestTrace -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_trace() [](#method-i-test_trace) - -## test_trace_break() [](#method-i-test_trace_break) - -## test_trace_proc_that_raises_exception() [](#method-i-test_trace_proc_that_raises_exception) - -## test_trace_string() [](#method-i-test_trace_string) - diff --git a/example/ruby/TestTracepointObj.md b/example/ruby/TestTracepointObj.md deleted file mode 100644 index 0851ea2..0000000 --- a/example/ruby/TestTracepointObj.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestTracepointObj -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_after_gc_start_hook_with_GC_stress() [](#method-i-test_after_gc_start_hook_with_GC_stress) - -## test_not_available_from_ruby() [](#method-i-test_not_available_from_ruby) - -## test_teardown_with_active_GC_end_hook() [](#method-i-test_teardown_with_active_GC_end_hook) - -## test_tracepoint_specify_normal_and_internal_events() [](#method-i-test_tracepoint_specify_normal_and_internal_events) - -## test_tracks_objspace_count() [](#method-i-test_tracks_objspace_count) - -## test_tracks_objspace_events() [](#method-i-test_tracks_objspace_events) - diff --git a/example/ruby/TestTranscode.md b/example/ruby/TestTranscode.md deleted file mode 100644 index 19bd5ea..0000000 --- a/example/ruby/TestTranscode.md +++ /dev/null @@ -1,201 +0,0 @@ -# Class: TestTranscode -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## escape(x ) [](#method-c-escape) - -#Instance Methods -## check_utf_16_both_ways(utf8, raw) [](#method-i-check_utf_16_both_ways) - -## check_utf_32_both_ways(utf8, raw) [](#method-i-check_utf_32_both_ways) - -## test_Big5() [](#method-i-test_Big5) - -## test_Big5_Hkscs() [](#method-i-test_Big5_Hkscs) - -## test_Big5_UAO() [](#method-i-test_Big5_UAO) - -## test_CESU_8() [](#method-i-test_CESU_8) - -## test_CP850() [](#method-i-test_CP850) - -## test_CP852() [](#method-i-test_CP852) - -## test_CP855() [](#method-i-test_CP855) - -## test_EBCDIC() [](#method-i-test_EBCDIC) - -## test_IBM437() [](#method-i-test_IBM437) - -## test_IBM720() [](#method-i-test_IBM720) - -## test_IBM775() [](#method-i-test_IBM775) - -## test_IBM852() [](#method-i-test_IBM852) - -## test_IBM855() [](#method-i-test_IBM855) - -## test_IBM857() [](#method-i-test_IBM857) - -## test_IBM860() [](#method-i-test_IBM860) - -## test_IBM861() [](#method-i-test_IBM861) - -## test_IBM862() [](#method-i-test_IBM862) - -## test_IBM863() [](#method-i-test_IBM863) - -## test_IBM864() [](#method-i-test_IBM864) - -## test_IBM865() [](#method-i-test_IBM865) - -## test_IBM866() [](#method-i-test_IBM866) - -## test_IBM869() [](#method-i-test_IBM869) - -## test_TIS_620() [](#method-i-test_TIS_620) - -## test_all_bytes() [](#method-i-test_all_bytes) - -## test_arguments() [](#method-i-test_arguments) - -## test_ascii_range() [](#method-i-test_ascii_range) - -## test_encode_with_invalid_chars() [](#method-i-test_encode_with_invalid_chars) - -## test_encode_xml_multibyte() [](#method-i-test_encode_xml_multibyte) - -## test_encoding_of_ascii_originating_from_binary() [](#method-i-test_encoding_of_ascii_originating_from_binary) - -## test_encodings() [](#method-i-test_encodings) - -## test_errors() [](#method-i-test_errors) - -## test_euc_jis_2004() [](#method-i-test_euc_jis_2004) - -## test_euc_jp() [](#method-i-test_euc_jp) - -## test_eucjp_ms() [](#method-i-test_eucjp_ms) - -## test_eucjp_sjis() [](#method-i-test_eucjp_sjis) - -## test_eucjp_sjis_unassigned() [](#method-i-test_eucjp_sjis_unassigned) - -## test_eucjp_sjis_undef() [](#method-i-test_eucjp_sjis_undef) - -## test_fallback() [](#method-i-test_fallback) - -## test_fallback_aref() [](#method-i-test_fallback_aref) - -## test_fallback_hash_default() [](#method-i-test_fallback_hash_default) - -## test_fallback_method() [](#method-i-test_fallback_method) - -## test_fallback_proc() [](#method-i-test_fallback_proc) - -## test_from_cp50221() [](#method-i-test_from_cp50221) - -## test_gb18030() [](#method-i-test_gb18030) - -## test_gb2312() [](#method-i-test_gb2312) - -## test_gbk() [](#method-i-test_gbk) - -## test_ill_formed_utf_8_replace() [](#method-i-test_ill_formed_utf_8_replace) - -## test_invalid_ignore() [](#method-i-test_invalid_ignore) - -## test_invalid_replace() [](#method-i-test_invalid_replace) - -## test_invalid_replace_string() [](#method-i-test_invalid_replace_string) - -## test_iso_2022_jp() [](#method-i-test_iso_2022_jp) - -## test_iso_2022_jp_1() [](#method-i-test_iso_2022_jp_1) - -## test_koi8_r() [](#method-i-test_koi8_r) - -## test_koi8_u() [](#method-i-test_koi8_u) - -## test_length() [](#method-i-test_length) - -## test_loading_race() [](#method-i-test_loading_race) - -## test_macCroatian() [](#method-i-test_macCroatian) - -## test_macCyrillic() [](#method-i-test_macCyrillic) - -## test_macGreek() [](#method-i-test_macGreek) - -## test_macIceland() [](#method-i-test_macIceland) - -## test_macRoman() [](#method-i-test_macRoman) - -## test_macRomania() [](#method-i-test_macRomania) - -## test_macTurkish() [](#method-i-test_macTurkish) - -## test_macUkraine() [](#method-i-test_macUkraine) - -## test_newline_options() [](#method-i-test_newline_options) - -## test_noargument() [](#method-i-test_noargument) - -## test_nothing_changed() [](#method-i-test_nothing_changed) - -## test_pseudo_encoding_inspect() [](#method-i-test_pseudo_encoding_inspect) - -## test_scrub_encode_with_coderange() [](#method-i-test_scrub_encode_with_coderange) - -## test_shift_jis() [](#method-i-test_shift_jis) - -## test_tilde_overline() [](#method-i-test_tilde_overline) - -## test_to_cp50221() [](#method-i-test_to_cp50221) - -## test_twostep() [](#method-i-test_twostep) - -## test_undef_replace() [](#method-i-test_undef_replace) - -## test_undef_replace_string() [](#method-i-test_undef_replace_string) - -## test_unicode_public_review_issue_121() [](#method-i-test_unicode_public_review_issue_121) -see http://www.unicode.org/review/pr-121.html - -## test_utf8_mac() [](#method-i-test_utf8_mac) - -## test_utf_16() [](#method-i-test_utf_16) - -## test_utf_16_bom() [](#method-i-test_utf_16_bom) - -## test_utf_32() [](#method-i-test_utf_32) - -## test_utf_32_bom() [](#method-i-test_utf_32_bom) - -## test_valid_dummy_encoding() [](#method-i-test_valid_dummy_encoding) - -## test_windows_1250() [](#method-i-test_windows_1250) - -## test_windows_1251() [](#method-i-test_windows_1251) - -## test_windows_1252() [](#method-i-test_windows_1252) - -## test_windows_1253() [](#method-i-test_windows_1253) - -## test_windows_1254() [](#method-i-test_windows_1254) - -## test_windows_1255() [](#method-i-test_windows_1255) - -## test_windows_1256() [](#method-i-test_windows_1256) - -## test_windows_1257() [](#method-i-test_windows_1257) - -## test_windows_31j() [](#method-i-test_windows_31j) - -## test_windows_874() [](#method-i-test_windows_874) - -## test_yen_sign() [](#method-i-test_yen_sign) - diff --git a/example/ruby/TestUTF16.md b/example/ruby/TestUTF16.md deleted file mode 100644 index 5cb1d70..0000000 --- a/example/ruby/TestUTF16.md +++ /dev/null @@ -1,89 +0,0 @@ -# Class: TestUTF16 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_str_equal(expected, actual, messagenil) [](#method-i-assert_str_equal) - -## enccall(recv, meth, *args) [](#method-i-enccall) - -## encdump(obj) [](#method-i-encdump) - -## test_casecmp() [](#method-i-test_casecmp) - -## test_casecmp2() [](#method-i-test_casecmp2) - -## test_chomp() [](#method-i-test_chomp) - -## test_code_to_mbc() [](#method-i-test_code_to_mbc) - -## test_compatible() [](#method-i-test_compatible) - -## test_concat_empty1() [](#method-i-test_concat_empty1) - -## test_concat_empty2() [](#method-i-test_concat_empty2) - -## test_concat_nonempty() [](#method-i-test_concat_nonempty) - -## test_count() [](#method-i-test_count) - -## test_count2() [](#method-i-test_count2) - -## test_empty_regexp() [](#method-i-test_empty_regexp) - -## test_encoding_find() [](#method-i-test_encoding_find) - -## test_end_with() [](#method-i-test_end_with) - -## test_gsub() [](#method-i-test_gsub) - -## test_header() [](#method-i-test_header) - -## test_hex() [](#method-i-test_hex) - -## test_intern() [](#method-i-test_intern) - -## test_interpolation() [](#method-i-test_interpolation) - -## test_is_mbc_newline() [](#method-i-test_is_mbc_newline) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_oct() [](#method-i-test_oct) - -## test_plus() [](#method-i-test_plus) - -## test_plus_empty1() [](#method-i-test_plus_empty1) - -## test_plus_empty2() [](#method-i-test_plus_empty2) - -## test_plus_nonempty() [](#method-i-test_plus_nonempty) - -## test_regexp_escape() [](#method-i-test_regexp_escape) - -## test_regexp_match() [](#method-i-test_regexp_match) - -## test_regexp_union() [](#method-i-test_regexp_union) - -## test_slice!() [](#method-i-test_slice!) - -## test_split_awk() [](#method-i-test_split_awk) - -## test_strftime() [](#method-i-test_strftime) - -## test_succ() [](#method-i-test_succ) - -## test_surrogate_pair() [](#method-i-test_surrogate_pair) - -## test_sym_eq() [](#method-i-test_sym_eq) - -## test_utf16be_valid_encoding() [](#method-i-test_utf16be_valid_encoding) -tests start - -## test_utf16le_valid_encoding() [](#method-i-test_utf16le_valid_encoding) - -## utf8_to_utf16(s, e) [](#method-i-utf8_to_utf16) - diff --git a/example/ruby/TestUTF32.md b/example/ruby/TestUTF32.md deleted file mode 100644 index 17ef4b2..0000000 --- a/example/ruby/TestUTF32.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: TestUTF32 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## ascii_to_utf16be(s) [](#method-i-ascii_to_utf16be) - -## ascii_to_utf16le(s) [](#method-i-ascii_to_utf16le) - -## assert_str_equal(expected, actual, messagenil) [](#method-i-assert_str_equal) - -## encdump(str) [](#method-i-encdump) - -## test_code_to_mbc() [](#method-i-test_code_to_mbc) - -## test_mbc_case_fold() [](#method-i-test_mbc_case_fold) - -## test_mbc_len() [](#method-i-test_mbc_len) - -## test_mbc_newline() [](#method-i-test_mbc_newline) - -## test_mbc_to_code() [](#method-i-test_mbc_to_code) - -## test_substr() [](#method-i-test_substr) - -## test_utf32be_valid_encoding() [](#method-i-test_utf32be_valid_encoding) - -## test_utf32le_valid_encoding() [](#method-i-test_utf32le_valid_encoding) - -## utf8_to_utf32(s, e) [](#method-i-utf8_to_utf32) - diff --git a/example/ruby/TestUbfAsyncSafe.md b/example/ruby/TestUbfAsyncSafe.md deleted file mode 100644 index 2f25220..0000000 --- a/example/ruby/TestUbfAsyncSafe.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestUbfAsyncSafe -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_ubf_async_safe() [](#method-i-test_ubf_async_safe) - diff --git a/example/ruby/TestUndef.md b/example/ruby/TestUndef.md deleted file mode 100644 index 8ea5ae9..0000000 --- a/example/ruby/TestUndef.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestUndef -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_singleton_undef() [](#method-i-test_singleton_undef) - -## test_special_const_undef() [](#method-i-test_special_const_undef) - -## test_undef() [](#method-i-test_undef) - diff --git a/example/ruby/TestUndef/Undef0.md b/example/ruby/TestUndef/Undef0.md deleted file mode 100644 index 3c15628..0000000 --- a/example/ruby/TestUndef/Undef0.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestUndef::Undef0 -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/TestUndef/Undef1.md b/example/ruby/TestUndef/Undef1.md deleted file mode 100644 index 405ebdd..0000000 --- a/example/ruby/TestUndef/Undef1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestUndef::Undef1 -**Inherits:** Object - - - - - -#Instance Methods -## bar() [](#method-i-bar) - diff --git a/example/ruby/TestUndef/Undef2.md b/example/ruby/TestUndef/Undef2.md deleted file mode 100644 index 80f366a..0000000 --- a/example/ruby/TestUndef/Undef2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestUndef::Undef2 -**Inherits:** TestUndef::Undef1 - - - - - diff --git a/example/ruby/TestUnicodeEscape.md b/example/ruby/TestUnicodeEscape.md deleted file mode 100644 index cacdbef..0000000 --- a/example/ruby/TestUnicodeEscape.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TestUnicodeEscape -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_basic() [](#method-i-test_basic) - -## test_chars() [](#method-i-test_chars) - -## test_dynamic_regexp() [](#method-i-test_dynamic_regexp) - -## test_edge_cases() [](#method-i-test_edge_cases) - -## test_fail() [](#method-i-test_fail) -Tests to make sure that disallowed cases fail - -## test_fulton() [](#method-i-test_fulton) - -## test_regexp() [](#method-i-test_regexp) - -## test_syntax_variants() [](#method-i-test_syntax_variants) - diff --git a/example/ruby/TestUnicodeNormalize.md b/example/ruby/TestUnicodeNormalize.md deleted file mode 100644 index 262100d..0000000 --- a/example/ruby/TestUnicodeNormalize.md +++ /dev/null @@ -1,29 +0,0 @@ -# Class: TestUnicodeNormalize -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## expand_filename(basename ) [](#method-c-expand_filename) - -#Instance Methods -## test_hangul_plus_accents() [](#method-i-test_hangul_plus_accents) - -## test_no_trailing_jamo() [](#method-i-test_no_trailing_jamo) -preventive tests for (non-)bug #14934 - -## test_non_UTF_8() [](#method-i-test_non_UTF_8) - -## test_partial_jamo_compose() [](#method-i-test_partial_jamo_compose) - -## test_partial_jamo_decompose() [](#method-i-test_partial_jamo_decompose) - -## test_raise_exception_for_non_unicode_encoding() [](#method-i-test_raise_exception_for_non_unicode_encoding) - -## test_reiwa() [](#method-i-test_reiwa) - -## test_singleton_with_accents() [](#method-i-test_singleton_with_accents) - -## test_us_ascii() [](#method-i-test_us_ascii) - diff --git a/example/ruby/TestUpdateSuggestion.md b/example/ruby/TestUpdateSuggestion.md deleted file mode 100644 index 2ab5f0a..0000000 --- a/example/ruby/TestUpdateSuggestion.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestUpdateSuggestion -**Inherits:** Gem::TestCase - - - - -# Class Methods -## with_eligible_environment(tty: true, rubygems_version: Gem::Version.new("1.2.3"), latest_rubygems_version: Gem::Version.new("2.0.0"), ci: false, reset_last_update_check: true, cmd: ) [](#method-c-with_eligible_environment) - -#Instance Methods -## setup() [](#method-i-setup) - -## test_eligible_for_update() [](#method-i-test_eligible_for_update) - -## test_eligible_for_update_disabled_update() [](#method-i-test_eligible_for_update_disabled_update) - -## test_eligible_for_update_for_prerelease() [](#method-i-test_eligible_for_update_for_prerelease) - -## test_eligible_for_update_is_not_annoying_when_new_version_is_released() [](#method-i-test_eligible_for_update_is_not_annoying_when_new_version_is_released) - -## test_eligible_for_update_is_not_annoying_when_not_upgraded() [](#method-i-test_eligible_for_update_is_not_annoying_when_not_upgraded) - -## test_eligible_for_update_non_tty() [](#method-i-test_eligible_for_update_non_tty) - -## test_eligible_for_update_notification_delay() [](#method-i-test_eligible_for_update_notification_delay) - -## test_eligible_for_update_on_ci() [](#method-i-test_eligible_for_update_on_ci) - -## test_eligible_for_update_prevent_config() [](#method-i-test_eligible_for_update_prevent_config) - -## test_eligible_for_update_prevent_env() [](#method-i-test_eligible_for_update_prevent_env) - -## test_eligible_for_update_unwrittable_config() [](#method-i-test_eligible_for_update_unwrittable_config) - -## test_update_suggestion() [](#method-i-test_update_suggestion) - -## with_eligible_environment(**params) [](#method-i-with_eligible_environment) - diff --git a/example/ruby/TestUri.md b/example/ruby/TestUri.md deleted file mode 100644 index 637a323..0000000 --- a/example/ruby/TestUri.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestUri -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## test_redacted_does_not_modify_uri() [](#method-i-test_redacted_does_not_modify_uri) - -## test_redacted_with_invalid_uri() [](#method-i-test_redacted_with_invalid_uri) - -## test_redacted_with_token() [](#method-i-test_redacted_with_token) - -## test_redacted_with_user_pass() [](#method-i-test_redacted_with_user_pass) - -## test_redacted_with_user_x_oauth_basic() [](#method-i-test_redacted_with_user_x_oauth_basic) - -## test_redacted_without_credential() [](#method-i-test_redacted_without_credential) - -## test_to_s_invalid_uri() [](#method-i-test_to_s_invalid_uri) - -## test_to_s_not_string() [](#method-i-test_to_s_not_string) - diff --git a/example/ruby/TestVM.md b/example/ruby/TestVM.md deleted file mode 100644 index c531399..0000000 --- a/example/ruby/TestVM.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestVM -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_at_exit() [](#method-i-test_at_exit) -Bug #12095 -: - diff --git a/example/ruby/TestVMDump.md b/example/ruby/TestVMDump.md deleted file mode 100644 index a6e679a..0000000 --- a/example/ruby/TestVMDump.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TestVMDump -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_darwin_vm_dump_works(args, timeoutnil) [](#method-i-assert_darwin_vm_dump_works) - -## test_darwin_invalid_access() [](#method-i-test_darwin_invalid_access) - -## test_darwin_invalid_call() [](#method-i-test_darwin_invalid_call) - -## test_darwin_segv_in_syscall() [](#method-i-test_darwin_segv_in_syscall) - diff --git a/example/ruby/TestVariable.md b/example/ruby/TestVariable.md deleted file mode 100644 index c37e100..0000000 --- a/example/ruby/TestVariable.md +++ /dev/null @@ -1,56 +0,0 @@ -# Class: TestVariable -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## prepare_klass_for_test_svar_with_ifunc() [](#method-i-prepare_klass_for_test_svar_with_ifunc) - -## test_cloned_allows_setting_cvar() [](#method-i-test_cloned_allows_setting_cvar) - -## test_cloned_classes_copy_cvar_cache() [](#method-i-test_cloned_classes_copy_cvar_cache) - -## test_constant_popped() [](#method-i-test_constant_popped) - -## test_cvar_overtaken_by_module() [](#method-i-test_cvar_overtaken_by_module) - -## test_cvar_overtaken_by_parent_class() [](#method-i-test_cvar_overtaken_by_parent_class) - -## test_external_ivars() [](#method-i-test_external_ivars) - -## test_global_variable_0() [](#method-i-test_global_variable_0) - -## test_global_variable_popped() [](#method-i-test_global_variable_popped) - -## test_global_variables() [](#method-i-test_global_variables) - -## test_include_refined_module_class_variable() [](#method-i-test_include_refined_module_class_variable) - -## test_local_variables() [](#method-i-test_local_variables) - -## test_local_variables2() [](#method-i-test_local_variables2) - -## test_local_variables3() [](#method-i-test_local_variables3) - -## test_local_variables_with_kwarg() [](#method-i-test_local_variables_with_kwarg) - -## test_many_instance_variables() [](#method-i-test_many_instance_variables) - -## test_set_class_variable_on_frozen_object() [](#method-i-test_set_class_variable_on_frozen_object) - -## test_setting_class_variable_on_module_through_inheritance() [](#method-i-test_setting_class_variable_on_module_through_inheritance) - -## test_shadowing_block_local_variables() [](#method-i-test_shadowing_block_local_variables) - -## test_shadowing_local_variables() [](#method-i-test_shadowing_local_variables) - -## test_singleton_class_included_class_variable() [](#method-i-test_singleton_class_included_class_variable) - -## test_special_constant_ivars() [](#method-i-test_special_constant_ivars) - -## test_svar_with_ifunc() [](#method-i-test_svar_with_ifunc) - -## test_variable() [](#method-i-test_variable) - diff --git a/example/ruby/TestVariable/ExIvar.md b/example/ruby/TestVariable/ExIvar.md deleted file mode 100644 index 5cdd1d3..0000000 --- a/example/ruby/TestVariable/ExIvar.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestVariable::ExIvar -**Inherits:** Hash - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [ExIvar] a new instance of ExIvar - -## ivars() [](#method-i-ivars) - diff --git a/example/ruby/TestVariable/Gods.md b/example/ruby/TestVariable/Gods.md deleted file mode 100644 index ffc2763..0000000 --- a/example/ruby/TestVariable/Gods.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestVariable::Gods -**Inherits:** Object - - - - -# Class Methods -## ruler1() [](#method-c-ruler1) -<= per method definition style -## ruler2() [](#method-c-ruler2) - -#Instance Methods -## ruler0() [](#method-i-ruler0) - diff --git a/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning.md b/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning.md deleted file mode 100644 index 7b3de10..0000000 --- a/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestVariable::IncludeRefinedModuleClassVariableNoWarning -**Inherits:** Object - -**Includes:** TestVariable::IncludeRefinedModuleClassVariableNoWarning::Mod - - - - - -#Instance Methods -## t() [](#method-i-t) - diff --git a/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning/Mod.md b/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning/Mod.md deleted file mode 100644 index 1b4e62e..0000000 --- a/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning/Mod.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestVariable::IncludeRefinedModuleClassVariableNoWarning::Mod - - - - - diff --git a/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning/Mod2.md b/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning/Mod2.md deleted file mode 100644 index 0250546..0000000 --- a/example/ruby/TestVariable/IncludeRefinedModuleClassVariableNoWarning/Mod2.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestVariable::IncludeRefinedModuleClassVariableNoWarning::Mod2 - - - - - diff --git a/example/ruby/TestVariable/Olympians.md b/example/ruby/TestVariable/Olympians.md deleted file mode 100644 index f0460e5..0000000 --- a/example/ruby/TestVariable/Olympians.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TestVariable::Olympians - - - - - -#Instance Methods -## ruler3() [](#method-i-ruler3) - diff --git a/example/ruby/TestVariable/Titans.md b/example/ruby/TestVariable/Titans.md deleted file mode 100644 index cdb2722..0000000 --- a/example/ruby/TestVariable/Titans.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestVariable::Titans -**Inherits:** TestVariable::Gods - -**Includes:** TestVariable::Olympians - - - - - -#Instance Methods -## ruler3() [](#method-i-ruler3) - -## ruler4() [](#method-i-ruler4) - diff --git a/example/ruby/TestWIN32OLE_EVENT.md b/example/ruby/TestWIN32OLE_EVENT.md deleted file mode 100644 index 31da09f..0000000 --- a/example/ruby/TestWIN32OLE_EVENT.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestWIN32OLE_EVENT -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_s_new_exception() [](#method-i-test_s_new_exception) - -## test_s_new_non_exist_event() [](#method-i-test_s_new_non_exist_event) - diff --git a/example/ruby/TestWIN32OLE_EVENT_ADO.md b/example/ruby/TestWIN32OLE_EVENT_ADO.md deleted file mode 100644 index bc0ce70..0000000 --- a/example/ruby/TestWIN32OLE_EVENT_ADO.md +++ /dev/null @@ -1,54 +0,0 @@ -# Class: TestWIN32OLE_EVENT_ADO -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## default_handler(event, *args) [](#method-i-default_handler) - -## handler1() [](#method-i-handler1) - -## handler2() [](#method-i-handler2) - -## handler3(*arg) [](#method-i-handler3) - -## message_loop() [](#method-i-message_loop) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_handler1() [](#method-i-test_handler1) - -## test_handler2() [](#method-i-test_handler2) - -## test_off_event() [](#method-i-test_off_event) - -## test_off_event_arg() [](#method-i-test_off_event_arg) - -## test_off_event_arg2() [](#method-i-test_off_event_arg2) - -## test_off_event_sym_arg() [](#method-i-test_off_event_sym_arg) - -## test_on_event2() [](#method-i-test_on_event2) - -## test_on_event4() [](#method-i-test_on_event4) - -## test_on_event5() [](#method-i-test_on_event5) - -## test_on_event_hash_return() [](#method-i-test_on_event_hash_return) - -## test_on_event_hash_return2() [](#method-i-test_on_event_hash_return2) - -## test_on_event_hash_return3() [](#method-i-test_on_event_hash_return3) - -## test_on_event_hash_return4() [](#method-i-test_on_event_hash_return4) - -## test_on_event_hash_return5() [](#method-i-test_on_event_hash_return5) - -## test_on_event_with_outargs() [](#method-i-test_on_event_with_outargs) - -## test_unadvise() [](#method-i-test_unadvise) - diff --git a/example/ruby/TestWIN32OLE_EVENT_ADO/ADO.md b/example/ruby/TestWIN32OLE_EVENT_ADO/ADO.md deleted file mode 100644 index 7239b0b..0000000 --- a/example/ruby/TestWIN32OLE_EVENT_ADO/ADO.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestWIN32OLE_EVENT_ADO::ADO - - - - - diff --git a/example/ruby/TestWIN32OLE_EVENT_ADO/Handler1.md b/example/ruby/TestWIN32OLE_EVENT_ADO/Handler1.md deleted file mode 100644 index 95de70e..0000000 --- a/example/ruby/TestWIN32OLE_EVENT_ADO/Handler1.md +++ /dev/null @@ -1,31 +0,0 @@ -# Class: TestWIN32OLE_EVENT_ADO::Handler1 -**Inherits:** Object - - - - -# Attributes -## val1[RW] [](#attribute-i-val1) -Returns the value of attribute val1. - -## val2[RW] [](#attribute-i-val2) -Returns the value of attribute val2. - -## val3[RW] [](#attribute-i-val3) -Returns the value of attribute val3. - -## val4[RW] [](#attribute-i-val4) -Returns the value of attribute val4. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Handler1] a new instance of Handler1 - -## onConnectComplete(err, stat, pconn) [](#method-i-onConnectComplete) - -## onInfoMessage(err, stat, pconn) [](#method-i-onInfoMessage) - -## onWillConnect(conn, uid, pwd, opts, stat, pconn) [](#method-i-onWillConnect) - diff --git a/example/ruby/TestWIN32OLE_EVENT_ADO/Handler2.md b/example/ruby/TestWIN32OLE_EVENT_ADO/Handler2.md deleted file mode 100644 index beb9a81..0000000 --- a/example/ruby/TestWIN32OLE_EVENT_ADO/Handler2.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestWIN32OLE_EVENT_ADO::Handler2 -**Inherits:** Object - - - - -# Attributes -## ev[RW] [](#attribute-i-ev) -Returns the value of attribute ev. - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Handler2] a new instance of Handler2 - -## method_missing(ev, *arg) [](#method-i-method_missing) - diff --git a/example/ruby/TestWIN32OLE_EVENT_SWbemSink.md b/example/ruby/TestWIN32OLE_EVENT_SWbemSink.md deleted file mode 100644 index b1f8d16..0000000 --- a/example/ruby/TestWIN32OLE_EVENT_SWbemSink.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: TestWIN32OLE_EVENT_SWbemSink -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## default_handler(event, *args) [](#method-i-default_handler) - -## handler1() [](#method-i-handler1) - -## message_loop(watch_ivarnil) [](#method-i-message_loop) - -## setup() [](#method-i-setup) - -## test_on_event() [](#method-i-test_on_event) - -## test_on_event_symbol() [](#method-i-test_on_event_symbol) - -## test_s_new() [](#method-i-test_s_new) - -## test_s_new_loop() [](#method-i-test_s_new_loop) - -## test_s_new_non_exist_event() [](#method-i-test_s_new_non_exist_event) - diff --git a/example/ruby/TestWIN32OLE_FOR_PROPERTYPUTREF.md b/example/ruby/TestWIN32OLE_FOR_PROPERTYPUTREF.md deleted file mode 100644 index db69779..0000000 --- a/example/ruby/TestWIN32OLE_FOR_PROPERTYPUTREF.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestWIN32OLE_FOR_PROPERTYPUTREF -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ole_methods() [](#method-i-test_ole_methods) - -## test_ole_put_methods() [](#method-i-test_ole_put_methods) - diff --git a/example/ruby/TestWIN32OLE_METHOD.md b/example/ruby/TestWIN32OLE_METHOD.md deleted file mode 100644 index 57b6c47..0000000 --- a/example/ruby/TestWIN32OLE_METHOD.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class: TestWIN32OLE_METHOD -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## is_ruby64?() [](#method-i-is_ruby64?) - -**@return** [Boolean] - -## setup() [](#method-i-setup) - -## test_dispid() [](#method-i-test_dispid) - -## test_helpcontext() [](#method-i-test_helpcontext) - -## test_helpfile() [](#method-i-test_helpfile) - -## test_helpstring() [](#method-i-test_helpstring) - -## test_initialize() [](#method-i-test_initialize) - -## test_inspect() [](#method-i-test_inspect) - -## test_invkind() [](#method-i-test_invkind) - -## test_invoke_kind() [](#method-i-test_invoke_kind) - -## test_name() [](#method-i-test_name) - -## test_offset_vtbl() [](#method-i-test_offset_vtbl) - -## test_params() [](#method-i-test_params) - -## test_return_type() [](#method-i-test_return_type) - -## test_return_type_detail() [](#method-i-test_return_type_detail) - -## test_return_vtype() [](#method-i-test_return_vtype) - -## test_size_opt_params() [](#method-i-test_size_opt_params) - -## test_size_params() [](#method-i-test_size_params) - -## test_to_s() [](#method-i-test_to_s) - -## test_visible?() [](#method-i-test_visible?) - -**@return** [Boolean] - diff --git a/example/ruby/TestWIN32OLE_METHOD_EVENT.md b/example/ruby/TestWIN32OLE_METHOD_EVENT.md deleted file mode 100644 index 8245424..0000000 --- a/example/ruby/TestWIN32OLE_METHOD_EVENT.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestWIN32OLE_METHOD_EVENT -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_dummy_for_skip_message() [](#method-i-test_dummy_for_skip_message) - -## test_event?() [](#method-i-test_event?) - -**@return** [Boolean] - -## test_event_interface() [](#method-i-test_event_interface) - -## test_event_interface_is_nil() [](#method-i-test_event_interface_is_nil) - diff --git a/example/ruby/TestWIN32OLE_PARAM.md b/example/ruby/TestWIN32OLE_PARAM.md deleted file mode 100644 index 4494d79..0000000 --- a/example/ruby/TestWIN32OLE_PARAM.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TestWIN32OLE_PARAM -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_default() [](#method-i-test_default) - -## test_input?() [](#method-i-test_input?) - -**@return** [Boolean] - -## test_inspect() [](#method-i-test_inspect) - -## test_name() [](#method-i-test_name) - -## test_ole_type() [](#method-i-test_ole_type) - -## test_ole_type_detail() [](#method-i-test_ole_type_detail) - -## test_optional?() [](#method-i-test_optional?) - -**@return** [Boolean] - -## test_output?() [](#method-i-test_output?) - -**@return** [Boolean] - -## test_retval?() [](#method-i-test_retval?) - -**@return** [Boolean] - -## test_s_new() [](#method-i-test_s_new) - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestWIN32OLE_PARAM_EVENT.md b/example/ruby/TestWIN32OLE_PARAM_EVENT.md deleted file mode 100644 index 92721eb..0000000 --- a/example/ruby/TestWIN32OLE_PARAM_EVENT.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestWIN32OLE_PARAM_EVENT -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_dummy_for_skip_message() [](#method-i-test_dummy_for_skip_message) - -## test_input?() [](#method-i-test_input?) - -**@return** [Boolean] - -## test_output?() [](#method-i-test_output?) - -**@return** [Boolean] - diff --git a/example/ruby/TestWIN32OLE_PROPERTYPUTREF.md b/example/ruby/TestWIN32OLE_PROPERTYPUTREF.md deleted file mode 100644 index 5f338e5..0000000 --- a/example/ruby/TestWIN32OLE_PROPERTYPUTREF.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestWIN32OLE_PROPERTYPUTREF -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_sapi() [](#method-i-test_sapi) - diff --git a/example/ruby/TestWIN32OLE_RECORD.md b/example/ruby/TestWIN32OLE_RECORD.md deleted file mode 100644 index 6ac4f68..0000000 --- a/example/ruby/TestWIN32OLE_RECORD.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TestWIN32OLE_RECORD -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/TestWIN32OLE_RECORD_BY_RBCOMTEST.md b/example/ruby/TestWIN32OLE_RECORD_BY_RBCOMTEST.md deleted file mode 100644 index 0b08503..0000000 --- a/example/ruby/TestWIN32OLE_RECORD_BY_RBCOMTEST.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: TestWIN32OLE_RECORD_BY_RBCOMTEST -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_dummy_for_skip_message() [](#method-i-test_dummy_for_skip_message) - -## test_get_record_array_from_comserver() [](#method-i-test_get_record_array_from_comserver) - -## test_get_record_from_comserver() [](#method-i-test_get_record_from_comserver) - -## test_inspect() [](#method-i-test_inspect) - -## test_method_missing_getter() [](#method-i-test_method_missing_getter) - -## test_method_missing_setter() [](#method-i-test_method_missing_setter) - -## test_ole_instance_variable_get() [](#method-i-test_ole_instance_variable_get) - -## test_ole_instance_variable_set() [](#method-i-test_ole_instance_variable_set) - -## test_pass_and_get_record_parameter_byref() [](#method-i-test_pass_and_get_record_parameter_byref) - -## test_pass_record_parameter() [](#method-i-test_pass_record_parameter) - -## test_pass_record_parameter_byref() [](#method-i-test_pass_record_parameter_byref) - -## test_pass_variant_parameter_byref() [](#method-i-test_pass_variant_parameter_byref) - -## test_s_new_from_win32ole() [](#method-i-test_s_new_from_win32ole) - -## test_s_new_from_win32ole_typelib() [](#method-i-test_s_new_from_win32ole_typelib) - -## test_s_new_raise() [](#method-i-test_s_new_raise) - -## test_to_h() [](#method-i-test_to_h) - -## test_typename() [](#method-i-test_typename) - diff --git a/example/ruby/TestWIN32OLE_THREAD.md b/example/ruby/TestWIN32OLE_THREAD.md deleted file mode 100644 index 9bd8d57..0000000 --- a/example/ruby/TestWIN32OLE_THREAD.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: TestWIN32OLE_THREAD -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_creating_win32ole_object_in_thread(meth) [](#method-i-assert_creating_win32ole_object_in_thread) -test for Bug #2618(ruby-core:27634) - -## test_creating_win32ole_object_in_thread_fork() [](#method-i-test_creating_win32ole_object_in_thread_fork) - -## test_creating_win32ole_object_in_thread_new() [](#method-i-test_creating_win32ole_object_in_thread_new) - -## test_creating_win32ole_object_in_thread_start() [](#method-i-test_creating_win32ole_object_in_thread_start) - diff --git a/example/ruby/TestWIN32OLE_TYPE.md b/example/ruby/TestWIN32OLE_TYPE.md deleted file mode 100644 index a33863d..0000000 --- a/example/ruby/TestWIN32OLE_TYPE.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: TestWIN32OLE_TYPE -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_guid() [](#method-i-test_guid) - -## test_helpcontext() [](#method-i-test_helpcontext) - -## test_helpfile() [](#method-i-test_helpfile) - -## test_helpstring() [](#method-i-test_helpstring) - -## test_implemented_ole_types() [](#method-i-test_implemented_ole_types) - -## test_initialize() [](#method-i-test_initialize) - -## test_inspect() [](#method-i-test_inspect) - -## test_major_version() [](#method-i-test_major_version) - -## test_minor_version() [](#method-i-test_minor_version) - -## test_name() [](#method-i-test_name) - -## test_ole_methods() [](#method-i-test_ole_methods) - -## test_ole_type() [](#method-i-test_ole_type) - -## test_ole_typelib() [](#method-i-test_ole_typelib) - -## test_progid() [](#method-i-test_progid) - -## test_s_ole_classes() [](#method-i-test_s_ole_classes) -WIN32OLE::Type.ole_classes will be obsoleted. - -## test_s_progids() [](#method-i-test_s_progids) - -## test_s_typelibs() [](#method-i-test_s_typelibs) -WIN32OLE::Type.typelibs will be obsoleted. - -## test_src_type() [](#method-i-test_src_type) - -## test_to_s() [](#method-i-test_to_s) - -## test_typekind() [](#method-i-test_typekind) - -## test_variables() [](#method-i-test_variables) - -## test_visible?() [](#method-i-test_visible?) - -**@return** [Boolean] - diff --git a/example/ruby/TestWIN32OLE_TYPELIB.md b/example/ruby/TestWIN32OLE_TYPELIB.md deleted file mode 100644 index 60d71ed..0000000 --- a/example/ruby/TestWIN32OLE_TYPELIB.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: TestWIN32OLE_TYPELIB -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_guid() [](#method-i-test_guid) - -## test_initialize() [](#method-i-test_initialize) - -## test_initialize_with_REG_EXPAND_SZ() [](#method-i-test_initialize_with_REG_EXPAND_SZ) -#Bug:3907 [ruby-dev:42338] - -## test_inspect() [](#method-i-test_inspect) - -## test_library_name() [](#method-i-test_library_name) - -## test_major_version() [](#method-i-test_major_version) - -## test_minor_version() [](#method-i-test_minor_version) - -## test_name() [](#method-i-test_name) - -## test_ole_types() [](#method-i-test_ole_types) - -## test_path() [](#method-i-test_path) - -## test_s_typelibs() [](#method-i-test_s_typelibs) - -## test_to_s() [](#method-i-test_to_s) - -## test_version() [](#method-i-test_version) - -## test_visible?() [](#method-i-test_visible?) - -**@return** [Boolean] - diff --git a/example/ruby/TestWIN32OLE_TYPE_EVENT.md b/example/ruby/TestWIN32OLE_TYPE_EVENT.md deleted file mode 100644 index 24c096f..0000000 --- a/example/ruby/TestWIN32OLE_TYPE_EVENT.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestWIN32OLE_TYPE_EVENT -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_default_event_sources() [](#method-i-test_default_event_sources) - -## test_default_ole_types() [](#method-i-test_default_ole_types) - -## test_dummy_for_skip_message() [](#method-i-test_dummy_for_skip_message) - -## test_implemented_ole_types() [](#method-i-test_implemented_ole_types) - -## test_source_ole_types() [](#method-i-test_source_ole_types) - diff --git a/example/ruby/TestWIN32OLE_VARIABLE.md b/example/ruby/TestWIN32OLE_VARIABLE.md deleted file mode 100644 index 2792ed4..0000000 --- a/example/ruby/TestWIN32OLE_VARIABLE.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: TestWIN32OLE_VARIABLE -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_initialize() [](#method-i-test_initialize) - -## test_inspect() [](#method-i-test_inspect) - -## test_name() [](#method-i-test_name) - -## test_ole_type() [](#method-i-test_ole_type) - -## test_ole_type_detail() [](#method-i-test_ole_type_detail) - -## test_ole_type_value() [](#method-i-test_ole_type_value) - -## test_ole_type_variable_kind() [](#method-i-test_ole_type_variable_kind) - -## test_ole_type_varkind() [](#method-i-test_ole_type_varkind) - -## test_ole_type_visible?() [](#method-i-test_ole_type_visible?) - -**@return** [Boolean] - -## test_to_s() [](#method-i-test_to_s) - diff --git a/example/ruby/TestWIN32OLE_VARIANT.md b/example/ruby/TestWIN32OLE_VARIANT.md deleted file mode 100644 index 0ae4dd5..0000000 --- a/example/ruby/TestWIN32OLE_VARIANT.md +++ /dev/null @@ -1,117 +0,0 @@ -# Class: TestWIN32OLE_VARIANT -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_c_empty() [](#method-i-test_c_empty) - -## test_c_noparam() [](#method-i-test_c_noparam) - -## test_c_nothing() [](#method-i-test_c_nothing) - -## test_c_null() [](#method-i-test_c_null) - -## test_conversion_dbl2date_with_msec() [](#method-i-test_conversion_dbl2date_with_msec) - -## test_conversion_float2int() [](#method-i-test_conversion_float2int) - -## test_conversion_num2str() [](#method-i-test_conversion_num2str) - -## test_conversion_ole_variant2ole_variant() [](#method-i-test_conversion_ole_variant2ole_variant) - -## test_conversion_str2cy() [](#method-i-test_conversion_str2cy) -this test failed because of VariantTimeToSystemTime and -SystemTimeToVariantTime API ignores wMilliseconds member of SYSTEMTIME -struct. - -def test_conversion_time_nsec2date - dt = Time.new(2004, 12,24, 12, 24, 45) - dt += 0.1 - obj = WIN32OLE::Variant.new(dt, WIN32OLE::VARIANT::VT_DATE) - assert_equal(dt, obj.value) - -end - -## test_conversion_str2date() [](#method-i-test_conversion_str2date) - -## test_conversion_str2num() [](#method-i-test_conversion_str2num) - -## test_conversion_time2date() [](#method-i-test_conversion_time2date) - -## test_conversion_time2date_with_msec() [](#method-i-test_conversion_time2date_with_msec) - -## test_conversion_vt_date() [](#method-i-test_conversion_vt_date) - -## test_create_nil_dispatch() [](#method-i-test_create_nil_dispatch) - -## test_create_variant_byref() [](#method-i-test_create_variant_byref) - -## test_create_vt_array() [](#method-i-test_create_vt_array) - -## test_create_vt_array2() [](#method-i-test_create_vt_array2) - -## test_create_vt_array3() [](#method-i-test_create_vt_array3) - -## test_create_vt_array_exc() [](#method-i-test_create_vt_array_exc) - -## test_create_vt_array_int() [](#method-i-test_create_vt_array_int) - -## test_create_vt_array_nil() [](#method-i-test_create_vt_array_nil) - -## test_create_vt_array_str() [](#method-i-test_create_vt_array_str) - -## test_create_vt_array_str2ui1array() [](#method-i-test_create_vt_array_str2ui1array) - -## test_create_vt_nested_array() [](#method-i-test_create_vt_nested_array) - -## test_s_array() [](#method-i-test_s_array) - -## test_s_array_exc() [](#method-i-test_s_array_exc) - -## test_s_new() [](#method-i-test_s_new) - -## test_s_new_2_argument() [](#method-i-test_s_new_2_argument) - -## test_s_new_2_argument2() [](#method-i-test_s_new_2_argument2) - -## test_s_new_array() [](#method-i-test_s_new_array) - -## test_s_new_ary() [](#method-i-test_s_new_ary) - -## test_s_new_dispatch_array() [](#method-i-test_s_new_dispatch_array) - -## test_s_new_exc() [](#method-i-test_s_new_exc) - -## test_s_new_no_argument() [](#method-i-test_s_new_no_argument) - -## test_s_new_one_argument() [](#method-i-test_s_new_one_argument) - -## test_s_new_vt_record_exc() [](#method-i-test_s_new_vt_record_exc) - -## test_s_new_with_i8_byref() [](#method-i-test_s_new_with_i8_byref) - -## test_s_new_with_nil() [](#method-i-test_s_new_with_nil) - -## test_s_new_with_non_nil() [](#method-i-test_s_new_with_non_nil) - -## test_s_new_with_non_nil_byref() [](#method-i-test_s_new_with_non_nil_byref) - -## test_s_new_with_ui8_byref() [](#method-i-test_s_new_with_ui8_byref) - -## test_set_value() [](#method-i-test_set_value) - -## test_value() [](#method-i-test_value) - -## test_vartype() [](#method-i-test_vartype) - -## test_vt_array_bracket() [](#method-i-test_vt_array_bracket) - -## test_vt_error_noparam() [](#method-i-test_vt_error_noparam) - diff --git a/example/ruby/TestWIN32OLE_VARIANT_OUTARG.md b/example/ruby/TestWIN32OLE_VARIANT_OUTARG.md deleted file mode 100644 index dfdbffd..0000000 --- a/example/ruby/TestWIN32OLE_VARIANT_OUTARG.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestWIN32OLE_VARIANT_OUTARG -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_variant_ref_and_argv() [](#method-i-test_variant_ref_and_argv) - diff --git a/example/ruby/TestWIN32OLE_VARIANT_OUTARG/ADO.md b/example/ruby/TestWIN32OLE_VARIANT_OUTARG/ADO.md deleted file mode 100644 index d83e06d..0000000 --- a/example/ruby/TestWIN32OLE_VARIANT_OUTARG/ADO.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TestWIN32OLE_VARIANT_OUTARG::ADO - - - - - diff --git a/example/ruby/TestWIN32OLE_WITH_WORD.md b/example/ruby/TestWIN32OLE_WITH_WORD.md deleted file mode 100644 index 75d57e4..0000000 --- a/example/ruby/TestWIN32OLE_WITH_WORD.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TestWIN32OLE_WITH_WORD -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_dummy_for_skip_message() [](#method-i-test_dummy_for_skip_message) - -## test_ole_methods() [](#method-i-test_ole_methods) - -## test_s_connect() [](#method-i-test_s_connect) - diff --git a/example/ruby/TestWait.md b/example/ruby/TestWait.md deleted file mode 100644 index 79b20f1..0000000 --- a/example/ruby/TestWait.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestWait -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_wait_for_closed_pipe() [](#method-i-test_wait_for_closed_pipe) - -## test_wait_for_invalid_fd() [](#method-i-test_wait_for_invalid_fd) - -## test_wait_for_valid_fd() [](#method-i-test_wait_for_valid_fd) - diff --git a/example/ruby/TestWarning.md b/example/ruby/TestWarning.md deleted file mode 100644 index e50a78a..0000000 --- a/example/ruby/TestWarning.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestWarning -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_warn_called_only_when_category_enabled() [](#method-i-test_warn_called_only_when_category_enabled) - diff --git a/example/ruby/TestWeakKeyMap.md b/example/ruby/TestWeakKeyMap.md deleted file mode 100644 index 216ecb9..0000000 --- a/example/ruby/TestWeakKeyMap.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestWeakKeyMap -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_aset_const() [](#method-i-test_aset_const) - -## test_clear() [](#method-i-test_clear) - -## test_clear_bug_20691() [](#method-i-test_clear_bug_20691) - -## test_compaction() [](#method-i-test_compaction) - -## test_delete() [](#method-i-test_delete) - -## test_frozen_object() [](#method-i-test_frozen_object) - -## test_gc_compact_stress() [](#method-i-test_gc_compact_stress) - -## test_getkey() [](#method-i-test_getkey) - -## test_inconsistent_hash_key_memory_leak() [](#method-i-test_inconsistent_hash_key_memory_leak) - -## test_inspect() [](#method-i-test_inspect) - -## test_key?() [](#method-i-test_key?) - -**@return** [Boolean] - -## test_map() [](#method-i-test_map) - -## test_no_hash_method() [](#method-i-test_no_hash_method) - diff --git a/example/ruby/TestWeakMap.md b/example/ruby/TestWeakMap.md deleted file mode 100644 index cc09435..0000000 --- a/example/ruby/TestWeakMap.md +++ /dev/null @@ -1,46 +0,0 @@ -# Class: TestWeakMap -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_weak_include(m, k, n100) [](#method-i-assert_weak_include) - -## setup() [](#method-i-setup) - -## test_aset_const() [](#method-i-test_aset_const) - -## test_compaction() [](#method-i-test_compaction) - -## test_delete() [](#method-i-test_delete) - -## test_each() [](#method-i-test_each) - -## test_each_key() [](#method-i-test_each_key) - -## test_each_value() [](#method-i-test_each_value) - -## test_frozen_object() [](#method-i-test_frozen_object) - -## test_gc_compact_stress() [](#method-i-test_gc_compact_stress) - -## test_include?() [](#method-i-test_include?) - -**@return** [Boolean] - -## test_inspect() [](#method-i-test_inspect) - -## test_inspect_garbage() [](#method-i-test_inspect_garbage) - -## test_map() [](#method-i-test_map) - -## test_no_memory_leak() [](#method-i-test_no_memory_leak) - -## test_replaced_values_bug_19531() [](#method-i-test_replaced_values_bug_19531) - -## test_size() [](#method-i-test_size) - -## test_use_after_free_bug_20688() [](#method-i-test_use_after_free_bug_20688) - diff --git a/example/ruby/TestWeakRef.md b/example/ruby/TestWeakRef.md deleted file mode 100644 index b288091..0000000 --- a/example/ruby/TestWeakRef.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: TestWeakRef -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## make_weakref(level10) [](#method-i-make_weakref) - -## test_not_reference_different_object() [](#method-i-test_not_reference_different_object) - -## test_recycled() [](#method-i-test_recycled) - -## test_ref() [](#method-i-test_ref) - -## test_repeated_object_memory_leak() [](#method-i-test_repeated_object_memory_leak) - -## test_weakref_finalize() [](#method-i-test_weakref_finalize) - diff --git a/example/ruby/TestWhileuntil.md b/example/ruby/TestWhileuntil.md deleted file mode 100644 index ec59a01..0000000 --- a/example/ruby/TestWhileuntil.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestWhileuntil -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_begin_while() [](#method-i-test_begin_while) - -## test_until() [](#method-i-test_until) - -## test_while() [](#method-i-test_while) - diff --git a/example/ruby/TestWin32OLE.md b/example/ruby/TestWin32OLE.md deleted file mode 100644 index 3c2be36..0000000 --- a/example/ruby/TestWin32OLE.md +++ /dev/null @@ -1,126 +0,0 @@ -# Class: TestWin32OLE -**Inherits:** Test::Unit::TestCase - -**Includes:** TestCaseForDict - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test__invoke() [](#method-i-test__invoke) - -## test_add() [](#method-i-test_add) - -## test_bracket() [](#method-i-test_bracket) - -## test_bracket_equal() [](#method-i-test_bracket_equal) - -## test_bracket_with_numkey() [](#method-i-test_bracket_with_numkey) - -## test_const_CP_ACP() [](#method-i-test_const_CP_ACP) - -## test_const_CP_MACCP() [](#method-i-test_const_CP_MACCP) - -## test_const_CP_OEMCP() [](#method-i-test_const_CP_OEMCP) - -## test_const_CP_SYMBOL() [](#method-i-test_const_CP_SYMBOL) - -## test_const_CP_THREAD_ACP() [](#method-i-test_const_CP_THREAD_ACP) - -## test_const_CP_UTF7() [](#method-i-test_const_CP_UTF7) - -## test_const_CP_UTF8() [](#method-i-test_const_CP_UTF8) - -## test_const_LOCALE_SYSTEM_DEFAULT() [](#method-i-test_const_LOCALE_SYSTEM_DEFAULT) - -## test_const_LOCALE_USER_DEFAULT() [](#method-i-test_const_LOCALE_USER_DEFAULT) - -## test_convert_bignum() [](#method-i-test_convert_bignum) - -## test_cp51932() [](#method-i-test_cp51932) - -## test_each() [](#method-i-test_each) - -## test_get_win32ole_object() [](#method-i-test_get_win32ole_object) - -## test_invoke() [](#method-i-test_invoke) - -## test_invoke_accept_multi_hash_key() [](#method-i-test_invoke_accept_multi_hash_key) - -## test_invoke_accept_symbol_hash_key() [](#method-i-test_invoke_accept_symbol_hash_key) - -## test_invoke_hash_key_non_str_sym() [](#method-i-test_invoke_hash_key_non_str_sym) - -## test_invoke_with_array() [](#method-i-test_invoke_with_array) - -## test_method_missing() [](#method-i-test_method_missing) - -## test_methods() [](#method-i-test_methods) - -## test_no_method_error() [](#method-i-test_no_method_error) - -## test_non_exist_property() [](#method-i-test_non_exist_property) - -## test_ole_func_methods() [](#method-i-test_ole_func_methods) - -## test_ole_get_methods() [](#method-i-test_ole_get_methods) - -## test_ole_invoke_with_named_arg_last() [](#method-i-test_ole_invoke_with_named_arg_last) - -## test_ole_method_help() [](#method-i-test_ole_method_help) - -## test_ole_methods() [](#method-i-test_ole_methods) - -## test_ole_obj_help() [](#method-i-test_ole_obj_help) - -## test_ole_put_methods() [](#method-i-test_ole_put_methods) - -## test_ole_query_interface() [](#method-i-test_ole_query_interface) - -## test_ole_respond_to() [](#method-i-test_ole_respond_to) - -## test_ole_type() [](#method-i-test_ole_type) - -## test_ole_typelib() [](#method-i-test_ole_typelib) - -## test_raise_message() [](#method-i-test_raise_message) - -## test_s_codepage_changed() [](#method-i-test_s_codepage_changed) - -## test_s_codepage_set() [](#method-i-test_s_codepage_set) -WIN32OLE.codepage is initialized according to Encoding.default_external. - -def test_s_codepage - assert_equal(WIN32OLE::CP_ACP, WIN32OLE.codepage) - -end - -## test_s_connect() [](#method-i-test_s_connect) - -## test_s_connect_exc() [](#method-i-test_s_connect_exc) - -## test_s_const_load() [](#method-i-test_s_const_load) - -## test_s_create_guid() [](#method-i-test_s_create_guid) - -## test_s_locale() [](#method-i-test_s_locale) - -## test_s_locale_change() [](#method-i-test_s_locale_change) - -## test_s_locale_set() [](#method-i-test_s_locale_set) - -## test_s_new() [](#method-i-test_s_new) - -## test_s_new_DCOM() [](#method-i-test_s_new_DCOM) - -## test_s_new_exc() [](#method-i-test_s_new_exc) - -## test_s_new_from_clsid() [](#method-i-test_s_new_from_clsid) - -## test_setproperty() [](#method-i-test_setproperty) - -## test_setproperty_equal_ended() [](#method-i-test_setproperty_equal_ended) - diff --git a/example/ruby/TestWin32OLE_VARIANT_MODULE.md b/example/ruby/TestWin32OLE_VARIANT_MODULE.md deleted file mode 100644 index a3fb1e2..0000000 --- a/example/ruby/TestWin32OLE_VARIANT_MODULE.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestWin32OLE_VARIANT_MODULE -**Inherits:** Test::Unit::TestCase - -**Includes:** Alias of WIN32OLE - - - - - -#Instance Methods -## test_variant() [](#method-i-test_variant) - diff --git a/example/ruby/TestWin32Registry.md b/example/ruby/TestWin32Registry.md deleted file mode 100644 index c1b3749..0000000 --- a/example/ruby/TestWin32Registry.md +++ /dev/null @@ -1,57 +0,0 @@ -# Class: TestWin32Registry -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) -Create a new registry key per test in an atomic way, which is deleted on -teardown. - -Fills the following instance variables: - - @test_registry_key - A registry path which is not yet created, - but can be created without collisions even when running - multiple test processes. - @test_registry_rnd - The part of the registry path with a random number. - @createopts - Required parameters (desired, opt) for create method in - the volatile environment of the registry. - -## teardown() [](#method-i-teardown) - -## test_accessors() [](#method-i-test_accessors) - -## test_class_open() [](#method-i-test_class_open) - -## test_create_no_block() [](#method-i-test_create_no_block) - -## test_create_with_block() [](#method-i-test_create_with_block) - -## test_each_key() [](#method-i-test_each_key) - -## test_each_key_enum() [](#method-i-test_each_key_enum) - -## test_each_value() [](#method-i-test_each_value) - -## test_each_value_enum() [](#method-i-test_each_value_enum) - -## test_keys() [](#method-i-test_keys) - -## test_name() [](#method-i-test_name) - -## test_open_no_block() [](#method-i-test_open_no_block) - -## test_open_with_block() [](#method-i-test_open_with_block) - -## test_predefined() [](#method-i-test_predefined) - -## test_read() [](#method-i-test_read) - -## test_utf8_encoding() [](#method-i-test_utf8_encoding) - -## test_values() [](#method-i-test_values) - -## test_write() [](#method-i-test_write) - diff --git a/example/ruby/TestWindows1251.md b/example/ruby/TestWindows1251.md deleted file mode 100644 index c93bb81..0000000 --- a/example/ruby/TestWindows1251.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TestWindows1251 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_windows_1251() [](#method-i-test_windows_1251) - diff --git a/example/ruby/TestWindows1252.md b/example/ruby/TestWindows1252.md deleted file mode 100644 index 0660f84..0000000 --- a/example/ruby/TestWindows1252.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: TestWindows1252 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_stset() [](#method-i-test_stset) - -## test_windows_1252() [](#method-i-test_windows_1252) - diff --git a/example/ruby/TestYAMLDBM.md b/example/ruby/TestYAMLDBM.md deleted file mode 100644 index 5daad83..0000000 --- a/example/ruby/TestYAMLDBM.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TestYAMLDBM -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_delete() [](#method-i-test_delete) - -## test_each_value() [](#method-i-test_each_value) - -## test_fetch() [](#method-i-test_fetch) - -## test_shift() [](#method-i-test_shift) - -## test_values() [](#method-i-test_values) - diff --git a/example/ruby/TestYJIT.md b/example/ruby/TestYJIT.md deleted file mode 100644 index 8e754a9..0000000 --- a/example/ruby/TestYJIT.md +++ /dev/null @@ -1,279 +0,0 @@ -# Class: TestYJIT -**Inherits:** Test::Unit::TestCase - - -Tests for YJIT with assertions on compilation and side exits insipired by the -RJIT tests in test/ruby/test_rjit.rb - - - -#Instance Methods -## test_bug_19316() [](#method-i-test_bug_19316) - -## test_build_large_struct() [](#method-i-test_build_large_struct) -Tests calling a variadic cfunc with many args - -## test_byteslice_sp_invalidation() [](#method-i-test_byteslice_sp_invalidation) - -## test_cfunc_kwarg() [](#method-i-test_cfunc_kwarg) - -## test_checkkeyword() [](#method-i-test_checkkeyword) - -## test_code_gc() [](#method-i-test_code_gc) - -## test_code_gc_partial_last_page() [](#method-i-test_code_gc_partial_last_page) - -## test_code_gc_with_auto_compact() [](#method-i-test_code_gc_with_auto_compact) - -## test_code_gc_with_many_iseqs() [](#method-i-test_code_gc_with_many_iseqs) - -## test_command_line_switches() [](#method-i-test_command_line_switches) - -## test_compile_attr_set() [](#method-i-test_compile_attr_set) - -## test_compile_duphash() [](#method-i-test_compile_duphash) - -## test_compile_dynamic_symbol() [](#method-i-test_compile_dynamic_symbol) - -## test_compile_eq_arbitrary_class() [](#method-i-test_compile_eq_arbitrary_class) - -## test_compile_eq_fixnum() [](#method-i-test_compile_eq_fixnum) - -## test_compile_eq_object() [](#method-i-test_compile_eq_object) - -## test_compile_eq_string() [](#method-i-test_compile_eq_string) - -## test_compile_eq_symbol() [](#method-i-test_compile_eq_symbol) - -## test_compile_getclassvariable() [](#method-i-test_compile_getclassvariable) - -## test_compile_getconstant() [](#method-i-test_compile_getconstant) - -## test_compile_getconstant_with_sp_offset() [](#method-i-test_compile_getconstant_with_sp_offset) - -## test_compile_newhash() [](#method-i-test_compile_newhash) - -## test_compile_newrange() [](#method-i-test_compile_newrange) - -## test_compile_opt_and() [](#method-i-test_compile_opt_and) - -## test_compile_opt_aset() [](#method-i-test_compile_opt_aset) - -## test_compile_opt_duparray() [](#method-i-test_compile_opt_duparray) - -## test_compile_opt_ge() [](#method-i-test_compile_opt_ge) - -## test_compile_opt_getconstant_path() [](#method-i-test_compile_opt_getconstant_path) - -## test_compile_opt_gt() [](#method-i-test_compile_opt_gt) - -## test_compile_opt_le() [](#method-i-test_compile_opt_le) - -## test_compile_opt_lt() [](#method-i-test_compile_opt_lt) - -## test_compile_opt_minus() [](#method-i-test_compile_opt_minus) - -## test_compile_opt_newarray() [](#method-i-test_compile_opt_newarray) - -## test_compile_opt_nil_p() [](#method-i-test_compile_opt_nil_p) - -## test_compile_opt_not() [](#method-i-test_compile_opt_not) - -## test_compile_opt_or() [](#method-i-test_compile_opt_or) - -## test_compile_opt_plus() [](#method-i-test_compile_opt_plus) - -## test_compile_opt_succ() [](#method-i-test_compile_opt_succ) - -## test_compile_putnil() [](#method-i-test_compile_putnil) - -## test_compile_putobject() [](#method-i-test_compile_putobject) - -## test_compile_putspecialobject() [](#method-i-test_compile_putspecialobject) - -## test_compile_regexp() [](#method-i-test_compile_regexp) - -## test_compile_set_and_get_global() [](#method-i-test_compile_set_and_get_global) - -## test_compile_setclassvariable() [](#method-i-test_compile_setclassvariable) - -## test_compile_tostring() [](#method-i-test_compile_tostring) - -## test_ctx_different_mappings() [](#method-i-test_ctx_different_mappings) -regression test simplified from URI::Generic#hostname= - -## test_disable_code_gc_with_many_iseqs() [](#method-i-test_disable_code_gc_with_many_iseqs) - -## test_disable_stats() [](#method-i-test_disable_stats) - -## test_empty_splat() [](#method-i-test_empty_splat) - -## test_enable_from_env_var() [](#method-i-test_enable_from_env_var) - -## test_expandarray() [](#method-i-test_expandarray) - -## test_expandarray_nil() [](#method-i-test_expandarray_nil) - -## test_fib_recursion() [](#method-i-test_fib_recursion) - -## test_gc_compact_cyclic_branch() [](#method-i-test_gc_compact_cyclic_branch) - -## test_getblockparam() [](#method-i-test_getblockparam) - -## test_getblockparamproxy() [](#method-i-test_getblockparamproxy) - -## test_getivar_opt_plus() [](#method-i-test_getivar_opt_plus) - -## test_getlocal_with_level() [](#method-i-test_getlocal_with_level) - -## test_getspecial_backref() [](#method-i-test_getspecial_backref) - -## test_ifunc_getblockparamproxy() [](#method-i-test_ifunc_getblockparamproxy) - -## test_int_equal() [](#method-i-test_int_equal) - -## test_invalidate_cyclic_branch() [](#method-i-test_invalidate_cyclic_branch) - -## test_invokeblock_many_locals() [](#method-i-test_invokeblock_many_locals) - -## test_io_reopen_clobbering_singleton_class() [](#method-i-test_io_reopen_clobbering_singleton_class) - -## test_kw_splat_nil() [](#method-i-test_kw_splat_nil) - -## test_kwrest() [](#method-i-test_kwrest) - -## test_leaf_builtin() [](#method-i-test_leaf_builtin) - -## test_multisend() [](#method-i-test_multisend) - -## test_nested_send() [](#method-i-test_nested_send) - -## test_nil_then_string() [](#method-i-test_nil_then_string) - -## test_no_excessive_opt_getinlinecache_invalidation() [](#method-i-test_no_excessive_opt_getinlinecache_invalidation) - -## test_odd_calls_to_attr_reader() [](#method-i-test_odd_calls_to_attr_reader) - -## test_on_stack_code_gc_call() [](#method-i-test_on_stack_code_gc_call) - -## test_on_stack_code_gc_twice() [](#method-i-test_on_stack_code_gc_twice) - -## test_opt_aref_with() [](#method-i-test_opt_aref_with) - -## test_opt_case_dispatch() [](#method-i-test_opt_case_dispatch) - -## test_opt_getconstant_path_general() [](#method-i-test_opt_getconstant_path_general) - -## test_opt_getconstant_path_slowpath() [](#method-i-test_opt_getconstant_path_slowpath) - -## test_opt_length_in_method() [](#method-i-test_opt_length_in_method) - -## test_opt_mult_overflow() [](#method-i-test_opt_mult_overflow) - -## test_opt_regexpmatch2() [](#method-i-test_opt_regexpmatch2) - -## test_optarg_and_kwarg() [](#method-i-test_optarg_and_kwarg) - -## test_proc_block_arg() [](#method-i-test_proc_block_arg) - -## test_return_to_invalidated_block() [](#method-i-test_return_to_invalidated_block) - -## test_return_to_invalidated_frame() [](#method-i-test_return_to_invalidated_frame) - -## test_runtime_stats_arg_error() [](#method-i-test_runtime_stats_arg_error) - -## test_runtime_stats_key_arg() [](#method-i-test_runtime_stats_key_arg) - -## test_runtime_stats_types() [](#method-i-test_runtime_stats_types) - -## test_runtime_stats_unknown_key() [](#method-i-test_runtime_stats_unknown_key) - -## test_send_block() [](#method-i-test_send_block) - -## test_send_block_calling() [](#method-i-test_send_block_calling) - -## test_send_block_only_receiver() [](#method-i-test_send_block_only_receiver) - -## test_send_block_only_sender() [](#method-i-test_send_block_only_sender) - -## test_send_blockarg() [](#method-i-test_send_blockarg) - -## test_send_kwargs() [](#method-i-test_send_kwargs) - -## test_send_kwargs_in_receiver_only() [](#method-i-test_send_kwargs_in_receiver_only) - -## test_send_kwargs_splat() [](#method-i-test_send_kwargs_splat) - -## test_send_multiarg() [](#method-i-test_send_multiarg) - -## test_send_polymorphic_method_name() [](#method-i-test_send_polymorphic_method_name) - -## test_send_splat() [](#method-i-test_send_splat) - -## test_send_to_call() [](#method-i-test_send_to_call) - -## test_send_with_underscores() [](#method-i-test_send_with_underscores) - -## test_setivar_on_class() [](#method-i-test_setivar_on_class) - -## test_setlocal_with_level() [](#method-i-test_setlocal_with_level) - -## test_str_concat_encoding_mismatch() [](#method-i-test_str_concat_encoding_mismatch) - -## test_str_uplus_subclass() [](#method-i-test_str_uplus_subclass) - -## test_string_concat_ascii() [](#method-i-test_string_concat_ascii) - -## test_string_concat_utf8() [](#method-i-test_string_concat_utf8) - -## test_string_interpolation() [](#method-i-test_string_interpolation) - -## test_string_interpolation_cast() [](#method-i-test_string_interpolation_cast) - -## test_string_then_nil() [](#method-i-test_string_then_nil) - -## test_struct_aref() [](#method-i-test_struct_aref) - -## test_struct_aset() [](#method-i-test_struct_aset) - -## test_super_cfunc() [](#method-i-test_super_cfunc) - -## test_super_iseq() [](#method-i-test_super_iseq) - -## test_super_with_alias() [](#method-i-test_super_with_alias) - -## test_trace_b_call() [](#method-i-test_trace_b_call) -ISEQ_TRACE_EVENTS - -## test_trace_script_compiled() [](#method-i-test_trace_script_compiled) -not ISEQ_TRACE_EVENTS - -## test_tracing_str_uplus() [](#method-i-test_tracing_str_uplus) - -## test_yjit_disable() [](#method-i-test_yjit_disable) - -## test_yjit_enable() [](#method-i-test_yjit_enable) - -## test_yjit_enable_preserves_array_each_monkey_patch() [](#method-i-test_yjit_enable_preserves_array_each_monkey_patch) - -## test_yjit_enable_replaces_array_each() [](#method-i-test_yjit_enable_replaces_array_each) - -## test_yjit_enable_stats_false() [](#method-i-test_yjit_enable_stats_false) - -## test_yjit_enable_stats_quiet() [](#method-i-test_yjit_enable_stats_quiet) - -## test_yjit_enable_stats_true() [](#method-i-test_yjit_enable_stats_true) - -## test_yjit_enable_with_call_threshold() [](#method-i-test_yjit_enable_with_call_threshold) - -## test_yjit_enable_with_monkey_patch() [](#method-i-test_yjit_enable_with_monkey_patch) - -## test_yjit_in_ruby_description() [](#method-i-test_yjit_in_ruby_description) - -## test_yjit_in_version() [](#method-i-test_yjit_in_version) -Check that YJIT is in the version string - -## test_yjit_option_uses_array_each_in_ruby() [](#method-i-test_yjit_option_uses_array_each_in_ruby) - -## test_yjit_stats_and_v_no_error() [](#method-i-test_yjit_stats_and_v_no_error) - diff --git a/example/ruby/TestYJITExitLocations.md b/example/ruby/TestYJITExitLocations.md deleted file mode 100644 index 249d8fc..0000000 --- a/example/ruby/TestYJITExitLocations.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TestYJITExitLocations -**Inherits:** Test::Unit::TestCase - - -Tests for YJIT with assertions on tracing exits insipired by the RJIT tests in -test/ruby/test_yjit.rb - - - -#Instance Methods -## test_trace_exits_expandarray_splat() [](#method-i-test_trace_exits_expandarray_splat) - -## test_yjit_trace_exits_and_v_no_error() [](#method-i-test_yjit_trace_exits_and_v_no_error) - diff --git a/example/ruby/TestZlib.md b/example/ruby/TestZlib.md deleted file mode 100644 index fc4750c..0000000 --- a/example/ruby/TestZlib.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: TestZlib -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_adler32() [](#method-i-test_adler32) - -## test_adler32_combine() [](#method-i-test_adler32_combine) - -## test_crc32() [](#method-i-test_crc32) - -## test_crc32_combine() [](#method-i-test_crc32_combine) - -## test_crc_table() [](#method-i-test_crc_table) - -## test_deflate() [](#method-i-test_deflate) - -## test_deflate_stream() [](#method-i-test_deflate_stream) - -## test_gunzip() [](#method-i-test_gunzip) - -## test_gunzip_encoding() [](#method-i-test_gunzip_encoding) -Zlib.gunzip input is always considered a binary string, regardless of its -String#encoding. - -## test_gunzip_no_memory_leak() [](#method-i-test_gunzip_no_memory_leak) - -## test_gzip() [](#method-i-test_gzip) - -## test_inflate() [](#method-i-test_inflate) - -## test_version() [](#method-i-test_version) - diff --git a/example/ruby/TestZlibDeflate.md b/example/ruby/TestZlibDeflate.md deleted file mode 100644 index cdc583b..0000000 --- a/example/ruby/TestZlibDeflate.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: TestZlibDeflate -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_addstr() [](#method-i-test_addstr) - -## test_adler() [](#method-i-test_adler) - -## test_avail() [](#method-i-test_avail) - -## test_close() [](#method-i-test_close) - -## test_closed_p() [](#method-i-test_closed_p) - -## test_data_type() [](#method-i-test_data_type) - -## test_deflate() [](#method-i-test_deflate) - -## test_deflate_chunked() [](#method-i-test_deflate_chunked) - -## test_deflate_chunked_break() [](#method-i-test_deflate_chunked_break) - -## test_dup() [](#method-i-test_dup) - -## test_expand_buffer() [](#method-i-test_expand_buffer) - -## test_finished_p() [](#method-i-test_finished_p) - -## test_flush() [](#method-i-test_flush) - -## test_initialize() [](#method-i-test_initialize) - -## test_params() [](#method-i-test_params) - -## test_reset() [](#method-i-test_reset) - -## test_set_dictionary() [](#method-i-test_set_dictionary) - -## test_total() [](#method-i-test_total) - diff --git a/example/ruby/TestZlibGzipFile.md b/example/ruby/TestZlibGzipFile.md deleted file mode 100644 index ce09bda..0000000 --- a/example/ruby/TestZlibGzipFile.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: TestZlibGzipFile -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_closed_p() [](#method-i-test_closed_p) - -## test_comment() [](#method-i-test_comment) - -## test_crc() [](#method-i-test_crc) - -## test_gzip_reader_zcat() [](#method-i-test_gzip_reader_zcat) - -## test_level() [](#method-i-test_level) - -## test_lineno() [](#method-i-test_lineno) - -## test_mtime() [](#method-i-test_mtime) - -## test_orig_name() [](#method-i-test_orig_name) - -## test_os_code() [](#method-i-test_os_code) - -## test_path() [](#method-i-test_path) - -## test_path_tmpfile() [](#method-i-test_path_tmpfile) - -## test_pos() [](#method-i-test_pos) - -## test_sync() [](#method-i-test_sync) - -## test_to_io() [](#method-i-test_to_io) - -## test_zero_mtime() [](#method-i-test_zero_mtime) - diff --git a/example/ruby/TestZlibGzipReader.md b/example/ruby/TestZlibGzipReader.md deleted file mode 100644 index e80282e..0000000 --- a/example/ruby/TestZlibGzipReader.md +++ /dev/null @@ -1,58 +0,0 @@ -# Class: TestZlibGzipReader -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_corrupted_header() [](#method-i-test_corrupted_header) - -## test_double_close() [](#method-i-test_double_close) - -## test_each() [](#method-i-test_each) - -## test_each_byte() [](#method-i-test_each_byte) - -## test_encoding() [](#method-i-test_encoding) - -## test_getbyte() [](#method-i-test_getbyte) - -## test_getc() [](#method-i-test_getc) - -## test_gets() [](#method-i-test_gets) - -## test_gets2() [](#method-i-test_gets2) - -## test_gzfile_read_size_boundary() [](#method-i-test_gzfile_read_size_boundary) -Various methods of Zlib::GzipReader failed when to reading files just a few -bytes larger than GZFILE_READ_SIZE. - -## test_open() [](#method-i-test_open) - -## test_read() [](#method-i-test_read) - -## test_read0() [](#method-i-test_read0) - -## test_readchar() [](#method-i-test_readchar) - -## test_reader_wrap() [](#method-i-test_reader_wrap) - -## test_readline() [](#method-i-test_readline) - -## test_readlines() [](#method-i-test_readlines) - -## test_readpartial() [](#method-i-test_readpartial) - -## test_rewind() [](#method-i-test_rewind) - -## test_ungetc() [](#method-i-test_ungetc) - -## test_ungetc_at_start_of_file() [](#method-i-test_ungetc_at_start_of_file) - -## test_ungetc_paragraph() [](#method-i-test_ungetc_paragraph) - -## test_unused() [](#method-i-test_unused) - -## test_unused2() [](#method-i-test_unused2) - diff --git a/example/ruby/TestZlibGzipWriter.md b/example/ruby/TestZlibGzipWriter.md deleted file mode 100644 index 5533d6a..0000000 --- a/example/ruby/TestZlibGzipWriter.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: TestZlibGzipWriter -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_double_close() [](#method-i-test_double_close) - -## test_invalid_new() [](#method-i-test_invalid_new) - -## test_open() [](#method-i-test_open) - -## test_putc() [](#method-i-test_putc) - -## test_puts() [](#method-i-test_puts) - -## test_write() [](#method-i-test_write) - -## test_writer_wrap() [](#method-i-test_writer_wrap) - -## test_zlib_writer_buffered_write() [](#method-i-test_zlib_writer_buffered_write) - diff --git a/example/ruby/TestZlibInflate.md b/example/ruby/TestZlibInflate.md deleted file mode 100644 index 2184a00..0000000 --- a/example/ruby/TestZlibInflate.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: TestZlibInflate -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_add_dictionary() [](#method-i-test_add_dictionary) - -## test_class_inflate_dictionary() [](#method-i-test_class_inflate_dictionary) - -## test_finish_chunked() [](#method-i-test_finish_chunked) - -## test_inflate() [](#method-i-test_inflate) - -## test_inflate_buffer() [](#method-i-test_inflate_buffer) - -## test_inflate_buffer_chunked() [](#method-i-test_inflate_buffer_chunked) - -## test_inflate_buffer_partial_input() [](#method-i-test_inflate_buffer_partial_input) - -## test_inflate_chunked() [](#method-i-test_inflate_chunked) - -## test_inflate_chunked_break() [](#method-i-test_inflate_chunked_break) - -## test_inflate_dictionary() [](#method-i-test_inflate_dictionary) - -## test_inflate_partial_input() [](#method-i-test_inflate_partial_input) - -## test_initialize() [](#method-i-test_initialize) - -## test_multithread_deflate() [](#method-i-test_multithread_deflate) - -## test_multithread_inflate() [](#method-i-test_multithread_inflate) - -## test_recursive_deflate() [](#method-i-test_recursive_deflate) - -## test_recursive_inflate() [](#method-i-test_recursive_inflate) - -## test_set_dictionary() [](#method-i-test_set_dictionary) - -## test_sync() [](#method-i-test_sync) - diff --git a/example/ruby/Test_ArithSeq.md b/example/ruby/Test_ArithSeq.md deleted file mode 100644 index 738597c..0000000 --- a/example/ruby/Test_ArithSeq.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Test_ArithSeq -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_beg_len_step() [](#method-i-test_beg_len_step) - -## test_extract_with_arith_seq() [](#method-i-test_extract_with_arith_seq) - -## test_extract_with_others() [](#method-i-test_extract_with_others) - -## test_extract_with_range() [](#method-i-test_extract_with_range) - diff --git a/example/ruby/Test_Array.md b/example/ruby/Test_Array.md deleted file mode 100644 index ee2ee60..0000000 --- a/example/ruby/Test_Array.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test_Array -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/Test_Array/TestResize.md b/example/ruby/Test_Array/TestResize.md deleted file mode 100644 index 975b1db..0000000 --- a/example/ruby/Test_Array/TestResize.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_Array::TestResize -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_expand() [](#method-i-test_expand) - diff --git a/example/ruby/Test_BUG_14834.md b/example/ruby/Test_BUG_14834.md deleted file mode 100644 index da1d956..0000000 --- a/example/ruby/Test_BUG_14834.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_BUG_14834 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test() [](#method-i-test) - diff --git a/example/ruby/Test_BUG_3571.md b/example/ruby/Test_BUG_3571.md deleted file mode 100644 index 2053f3e..0000000 --- a/example/ruby/Test_BUG_3571.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_BUG_3571 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_block_call_id() [](#method-i-test_block_call_id) - diff --git a/example/ruby/Test_BUG_5832.md b/example/ruby/Test_BUG_5832.md deleted file mode 100644 index adc30e3..0000000 --- a/example/ruby/Test_BUG_5832.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_BUG_5832 -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_block_passing() [](#method-i-test_block_passing) - diff --git a/example/ruby/Test_Class.md b/example/ruby/Test_Class.md deleted file mode 100644 index 44af3b2..0000000 --- a/example/ruby/Test_Class.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test_Class -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/Test_Class/Test_Class2Name.md b/example/ruby/Test_Class/Test_Class2Name.md deleted file mode 100644 index 0311e30..0000000 --- a/example/ruby/Test_Class/Test_Class2Name.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Test_Class::Test_Class2Name -**Inherits:** Object - - - - - -#Instance Methods -## test_singleton_class() [](#method-i-test_singleton_class) - -## test_toplevel_class() [](#method-i-test_toplevel_class) - -## test_toplevel_module() [](#method-i-test_toplevel_module) - diff --git a/example/ruby/Test_DotDot.md b/example/ruby/Test_DotDot.md deleted file mode 100644 index bdde528..0000000 --- a/example/ruby/Test_DotDot.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_DotDot -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_load_dot_dot() [](#method-i-test_load_dot_dot) - diff --git a/example/ruby/Test_EConvAppend.md b/example/ruby/Test_EConvAppend.md deleted file mode 100644 index 7cfd7c3..0000000 --- a/example/ruby/Test_EConvAppend.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_EConvAppend -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_econv_str_append_broken() [](#method-i-test_econv_str_append_broken) - -## test_econv_str_append_valid() [](#method-i-test_econv_str_append_valid) - diff --git a/example/ruby/Test_FileStat.md b/example/ruby/Test_FileStat.md deleted file mode 100644 index f678f90..0000000 --- a/example/ruby/Test_FileStat.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_FileStat -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_stat_for_fd() [](#method-i-test_stat_for_fd) - -## test_stat_for_path() [](#method-i-test_stat_for_path) - diff --git a/example/ruby/Test_Hash.md b/example/ruby/Test_Hash.md deleted file mode 100644 index dcfe69d..0000000 --- a/example/ruby/Test_Hash.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test_Hash -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/Test_Hash/TestDelete.md b/example/ruby/Test_Hash/TestDelete.md deleted file mode 100644 index bc89d0d..0000000 --- a/example/ruby/Test_Hash/TestDelete.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_Hash::TestDelete -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_delete() [](#method-i-test_delete) - diff --git a/example/ruby/Test_Integer.md b/example/ruby/Test_Integer.md deleted file mode 100644 index 8c4bdc8..0000000 --- a/example/ruby/Test_Integer.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_Integer -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_fixnum_range() [](#method-i-test_fixnum_range) - -## test_positive_pow() [](#method-i-test_positive_pow) - diff --git a/example/ruby/Test_JISX0208_Char.md b/example/ruby/Test_JISX0208_Char.md deleted file mode 100644 index aabe9c0..0000000 --- a/example/ruby/Test_JISX0208_Char.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Test_JISX0208_Char -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_cell() [](#method-i-test_cell) - -## test_create_with_row_cell() [](#method-i-test_create_with_row_cell) - -## test_from_sjis() [](#method-i-test_from_sjis) - -## test_row() [](#method-i-test_row) - -## test_succ() [](#method-i-test_succ) - -## test_to_shift_jis() [](#method-i-test_to_shift_jis) - diff --git a/example/ruby/Test_Load_Protect.md b/example/ruby/Test_Load_Protect.md deleted file mode 100644 index fd19537..0000000 --- a/example/ruby/Test_Load_Protect.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_Load_Protect -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_load_protect() [](#method-i-test_load_protect) - diff --git a/example/ruby/Test_Load_ResolveSymbol.md b/example/ruby/Test_Load_ResolveSymbol.md deleted file mode 100644 index 25001f2..0000000 --- a/example/ruby/Test_Load_ResolveSymbol.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_Load_ResolveSymbol -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_load_resolve_symbol_resolver() [](#method-i-test_load_resolve_symbol_resolver) - diff --git a/example/ruby/Test_Load_stringify_symbols.md b/example/ruby/Test_Load_stringify_symbols.md deleted file mode 100644 index ad0aaad..0000000 --- a/example/ruby/Test_Load_stringify_symbols.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Test_Load_stringify_symbols -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_load_stringify_symbol_missing_target() [](#method-i-test_load_stringify_symbol_missing_target) - -## test_load_stringify_symbol_required_extensions() [](#method-i-test_load_stringify_symbol_required_extensions) - -## test_load_stringify_symbol_statically_linked() [](#method-i-test_load_stringify_symbol_statically_linked) - diff --git a/example/ruby/Test_Method.md b/example/ruby/Test_Method.md deleted file mode 100644 index 225def3..0000000 --- a/example/ruby/Test_Method.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test_Method -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/Test_Method/TestArity.md b/example/ruby/Test_Method/TestArity.md deleted file mode 100644 index b332957..0000000 --- a/example/ruby/Test_Method/TestArity.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_Method::TestArity -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_base() [](#method-i-test_base) - -## test_zsuper() [](#method-i-test_zsuper) - diff --git a/example/ruby/Test_Method/TestArity/A.md b/example/ruby/Test_Method/TestArity/A.md deleted file mode 100644 index fc3be91..0000000 --- a/example/ruby/Test_Method/TestArity/A.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Test_Method::TestArity::A -**Inherits:** Object - - - - - -#Instance Methods -## foo0() [](#method-i-foo0) - -## foo1(a) [](#method-i-foo1) - -## foo2(a, b) [](#method-i-foo2) - -## foom1(*a) [](#method-i-foom1) - -## foom2(a, *b) [](#method-i-foom2) - diff --git a/example/ruby/Test_Method/TestArity/B.md b/example/ruby/Test_Method/TestArity/B.md deleted file mode 100644 index ff06bef..0000000 --- a/example/ruby/Test_Method/TestArity/B.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test_Method::TestArity::B -**Inherits:** Test_Method::TestArity::A - - - - - diff --git a/example/ruby/Test_MyInteger.md b/example/ruby/Test_MyInteger.md deleted file mode 100644 index ebd62ab..0000000 --- a/example/ruby/Test_MyInteger.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_MyInteger -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_my_integer_cmp() [](#method-i-test_my_integer_cmp) - -## test_my_integer_to_f() [](#method-i-test_my_integer_to_f) - diff --git a/example/ruby/Test_NotImplement.md b/example/ruby/Test_NotImplement.md deleted file mode 100644 index 08eaf5c..0000000 --- a/example/ruby/Test_NotImplement.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Test_NotImplement -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_funcall_notimplement() [](#method-i-test_funcall_notimplement) - -## test_method_inspect_notimplement() [](#method-i-test_method_inspect_notimplement) - -## test_not_method_defined() [](#method-i-test_not_method_defined) - -## test_not_private_method_defined() [](#method-i-test_not_private_method_defined) - -## test_not_protected_method_defined() [](#method-i-test_not_protected_method_defined) - -## test_respond_to() [](#method-i-test_respond_to) - diff --git a/example/ruby/Test_PathToClass.md b/example/ruby/Test_PathToClass.md deleted file mode 100644 index 65e72f8..0000000 --- a/example/ruby/Test_PathToClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_PathToClass -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## path_to_class(path ) [](#method-c-path_to_class) - -#Instance Methods -## test_path_to_class() [](#method-i-test_path_to_class) - diff --git a/example/ruby/Test_Proc.md b/example/ruby/Test_Proc.md deleted file mode 100644 index d55f8ab..0000000 --- a/example/ruby/Test_Proc.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test_Proc -**Inherits:** Test::Unit::TestCase - - - - - diff --git a/example/ruby/Test_Proc/TestBMethod.md b/example/ruby/Test_Proc/TestBMethod.md deleted file mode 100644 index ba8863b..0000000 --- a/example/ruby/Test_Proc/TestBMethod.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Test_Proc::TestBMethod -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_block_super() [](#method-i-test_block_super) - -## test_receiver_in_bmethod() [](#method-i-test_receiver_in_bmethod) - -## test_super_in_bmethod() [](#method-i-test_super_in_bmethod) - diff --git a/example/ruby/Test_Proc/TestBMethod/Base.md b/example/ruby/Test_Proc/TestBMethod/Base.md deleted file mode 100644 index d8fa9cc..0000000 --- a/example/ruby/Test_Proc/TestBMethod/Base.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_Proc::TestBMethod::Base -**Inherits:** Object - - - - - -#Instance Methods -## foo(*a) [](#method-i-foo) - diff --git a/example/ruby/Test_Proc/TestBMethod/Bound.md b/example/ruby/Test_Proc/TestBMethod/Bound.md deleted file mode 100644 index a5d38cc..0000000 --- a/example/ruby/Test_Proc/TestBMethod/Bound.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test_Proc::TestBMethod::Bound -**Inherits:** Test_Proc::TestBMethod::Base - - - - - diff --git a/example/ruby/Test_RbInternedStr.md b/example/ruby/Test_RbInternedStr.md deleted file mode 100644 index 6ab159d..0000000 --- a/example/ruby/Test_RbInternedStr.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_RbInternedStr -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_interned_str() [](#method-i-test_interned_str) - diff --git a/example/ruby/Test_RbStrDup.md b/example/ruby/Test_RbStrDup.md deleted file mode 100644 index 5e0df31..0000000 --- a/example/ruby/Test_RbStrDup.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_RbStrDup -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_nested_shared_frozen() [](#method-i-test_nested_shared_frozen) - -## test_nested_shared_non_frozen() [](#method-i-test_nested_shared_non_frozen) - diff --git a/example/ruby/Test_SPrintf.md b/example/ruby/Test_SPrintf.md deleted file mode 100644 index eea8f39..0000000 --- a/example/ruby/Test_SPrintf.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: Test_SPrintf -**Inherits:** Test::Unit::TestCase - - - - -# Class Methods -## assertions_format_integer(format , type , **opts ) [](#method-c-assertions_format_integer) -## to_s() [](#method-c-to_s) - -#Instance Methods -## inspect() [](#method-i-inspect) - -## test_encoding() [](#method-i-test_encoding) - -## test_inspect() [](#method-i-test_inspect) - -## test_quote() [](#method-i-test_quote) - -## test_snprintf_count() [](#method-i-test_snprintf_count) - -## test_string_prec() [](#method-i-test_string_prec) - -## test_to_str() [](#method-i-test_to_str) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/Test_StForeachUnpack.md b/example/ruby/Test_StForeachUnpack.md deleted file mode 100644 index a611c10..0000000 --- a/example/ruby/Test_StForeachUnpack.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_StForeachUnpack -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_st_foreach_check_unpack() [](#method-i-test_st_foreach_check_unpack) - -## test_st_foreach_unpack() [](#method-i-test_st_foreach_unpack) - diff --git a/example/ruby/Test_StrEncAssociate.md b/example/ruby/Test_StrEncAssociate.md deleted file mode 100644 index b286249..0000000 --- a/example/ruby/Test_StrEncAssociate.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_StrEncAssociate -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_frozen() [](#method-i-test_frozen) - diff --git a/example/ruby/Test_StrSetLen.md b/example/ruby/Test_StrSetLen.md deleted file mode 100644 index 373d62d..0000000 --- a/example/ruby/Test_StrSetLen.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Test_StrSetLen -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_capacity_equals_to_new_size() [](#method-i-test_capacity_equals_to_new_size) - -## test_coderange_after_append() [](#method-i-test_coderange_after_append) - -## test_coderange_after_trunc() [](#method-i-test_coderange_after_trunc) - -## test_non_shared() [](#method-i-test_non_shared) - -## test_shared() [](#method-i-test_shared) - -## test_valid_encoding_after_resized() [](#method-i-test_valid_encoding_after_resized) - diff --git a/example/ruby/Test_StringCStr.md b/example/ruby/Test_StringCStr.md deleted file mode 100644 index 7cb5494..0000000 --- a/example/ruby/Test_StringCStr.md +++ /dev/null @@ -1,48 +0,0 @@ -# Class: Test_StringCStr -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_wchars_term_char(str) [](#method-i-assert_wchars_term_char) - -## test_embed() [](#method-i-test_embed) - -## test_embedded_from_heap() [](#method-i-test_embedded_from_heap) - -## test_frozen() [](#method-i-test_frozen) - -## test_long() [](#method-i-test_long) - -## test_rb_str_new_frozen_embed() [](#method-i-test_rb_str_new_frozen_embed) - -## test_shared() [](#method-i-test_shared) - -## test_wchar_aset() [](#method-i-test_wchar_aset) - -## test_wchar_chomp!() [](#method-i-test_wchar_chomp!) - -## test_wchar_chop!() [](#method-i-test_wchar_chop!) - -## test_wchar_delete!() [](#method-i-test_wchar_delete!) - -## test_wchar_embed() [](#method-i-test_wchar_embed) - -## test_wchar_long() [](#method-i-test_wchar_long) - -## test_wchar_lstrip!() [](#method-i-test_wchar_lstrip!) - -## test_wchar_replace() [](#method-i-test_wchar_replace) - -## test_wchar_rstrip!() [](#method-i-test_wchar_rstrip!) - -## test_wchar_squeeze!() [](#method-i-test_wchar_squeeze!) - -## test_wchar_sub!() [](#method-i-test_wchar_sub!) - -## test_wchar_tr!() [](#method-i-test_wchar_tr!) - -## test_wchar_tr_s!() [](#method-i-test_wchar_tr_s!) - diff --git a/example/ruby/Test_StringCapacity.md b/example/ruby/Test_StringCapacity.md deleted file mode 100644 index 25f4c7f..0000000 --- a/example/ruby/Test_StringCapacity.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: Test_StringCapacity -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_capacity_embedded() [](#method-i-test_capacity_embedded) - -## test_capacity_frozen() [](#method-i-test_capacity_frozen) - -## test_capacity_fstring() [](#method-i-test_capacity_fstring) - -## test_capacity_normal() [](#method-i-test_capacity_normal) - -## test_capacity_shared() [](#method-i-test_capacity_shared) - -## test_io_read() [](#method-i-test_io_read) - -## test_literal_capacity() [](#method-i-test_literal_capacity) - -## test_s_new_capacity() [](#method-i-test_s_new_capacity) - diff --git a/example/ruby/Test_StringCoderange.md b/example/ruby/Test_StringCoderange.md deleted file mode 100644 index 73e6200..0000000 --- a/example/ruby/Test_StringCoderange.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Test_StringCoderange -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_ascii8bit() [](#method-i-test_ascii8bit) - -## test_usascii() [](#method-i-test_usascii) - -## test_utf8() [](#method-i-test_utf8) - diff --git a/example/ruby/Test_StringEllipsize.md b/example/ruby/Test_StringEllipsize.md deleted file mode 100644 index 103ce36..0000000 --- a/example/ruby/Test_StringEllipsize.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: Test_StringEllipsize -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_equal_with_class(expected, result, *rest) [](#method-i-assert_equal_with_class) - -## setup() [](#method-i-setup) - -## test_longer() [](#method-i-test_longer) - -## test_negative_length() [](#method-i-test_negative_length) - -## test_nonascii() [](#method-i-test_nonascii) - -## test_shorter() [](#method-i-test_shorter) - diff --git a/example/ruby/Test_StringEncStrBufCat.md b/example/ruby/Test_StringEncStrBufCat.md deleted file mode 100644 index dedd461..0000000 --- a/example/ruby/Test_StringEncStrBufCat.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_StringEncStrBufCat -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_str_conv_enc() [](#method-i-test_str_conv_enc) - -## test_unknown() [](#method-i-test_unknown) - diff --git a/example/ruby/Test_StringExternalNew.md b/example/ruby/Test_StringExternalNew.md deleted file mode 100644 index 0a6b909..0000000 --- a/example/ruby/Test_StringExternalNew.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_StringExternalNew -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_buf_new() [](#method-i-test_buf_new) - -## test_external_new_with_enc() [](#method-i-test_external_new_with_enc) - diff --git a/example/ruby/Test_StringModifyExpand.md b/example/ruby/Test_StringModifyExpand.md deleted file mode 100644 index 1d76075..0000000 --- a/example/ruby/Test_StringModifyExpand.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_StringModifyExpand -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_integer_overflow() [](#method-i-test_integer_overflow) - -## test_modify_expand_memory_leak() [](#method-i-test_modify_expand_memory_leak) - diff --git a/example/ruby/Test_StringNoFree.md b/example/ruby/Test_StringNoFree.md deleted file mode 100644 index 662a2eb..0000000 --- a/example/ruby/Test_StringNoFree.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_StringNoFree -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_no_memory_leak() [](#method-i-test_no_memory_leak) - diff --git a/example/ruby/Test_StringNormalize.md b/example/ruby/Test_StringNormalize.md deleted file mode 100644 index 5504f99..0000000 --- a/example/ruby/Test_StringNormalize.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: Test_StringNormalize -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_dont_normalize_hfsplus() [](#method-i-test_dont_normalize_hfsplus) - -## test_invalid_sequence() [](#method-i-test_invalid_sequence) - -## test_normalize() [](#method-i-test_normalize) - -## test_not_normalize_kc() [](#method-i-test_not_normalize_kc) - diff --git a/example/ruby/Test_StringQSort.md b/example/ruby/Test_StringQSort.md deleted file mode 100644 index 41c9f89..0000000 --- a/example/ruby/Test_StringQSort.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_StringQSort -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_qsort() [](#method-i-test_qsort) - -## test_qsort_slice() [](#method-i-test_qsort_slice) - diff --git a/example/ruby/Test_String_Fstring.md b/example/ruby/Test_String_Fstring.md deleted file mode 100644 index 5760a26..0000000 --- a/example/ruby/Test_String_Fstring.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Test_String_Fstring -**Inherits:** Test::Unit::TestCase - -**Includes:** Test_Symbol::NonInterned - - - - - -#Instance Methods -## assert_fstring(str) [](#method-i-assert_fstring) - -**@yield** [str] - -## test_fake_str() [](#method-i-test_fake_str) - -## test_instance_variable() [](#method-i-test_instance_variable) - -## test_rb_enc_interned_str_autoloaded_encoding() [](#method-i-test_rb_enc_interned_str_autoloaded_encoding) - -## test_rb_enc_interned_str_null_encoding() [](#method-i-test_rb_enc_interned_str_null_encoding) - -## test_rb_enc_str_new_autoloaded_encoding() [](#method-i-test_rb_enc_str_new_autoloaded_encoding) - -## test_rb_enc_str_new_null_encoding() [](#method-i-test_rb_enc_str_new_null_encoding) - -## test_singleton_class() [](#method-i-test_singleton_class) - -## test_singleton_method() [](#method-i-test_singleton_method) - -## test_subclass() [](#method-i-test_subclass) - diff --git a/example/ruby/Test_String_Fstring/S.md b/example/ruby/Test_String_Fstring/S.md deleted file mode 100644 index a244a9b..0000000 --- a/example/ruby/Test_String_Fstring/S.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Test_String_Fstring::S -**Inherits:** String - - - - - diff --git a/example/ruby/Test_Symbol.md b/example/ruby/Test_Symbol.md deleted file mode 100644 index 98128cb..0000000 --- a/example/ruby/Test_Symbol.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Test_Symbol - - - - - diff --git a/example/ruby/Test_Symbol/NonInterned.md b/example/ruby/Test_Symbol/NonInterned.md deleted file mode 100644 index 75674d6..0000000 --- a/example/ruby/Test_Symbol/NonInterned.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: Test_Symbol::NonInterned - - - - -# Class Methods -## noninterned_name(prefix "") [](#method-c-noninterned_name) - diff --git a/example/ruby/Test_Symbol/TestInadvertent.md b/example/ruby/Test_Symbol/TestInadvertent.md deleted file mode 100644 index 26b2b37..0000000 --- a/example/ruby/Test_Symbol/TestInadvertent.md +++ /dev/null @@ -1,130 +0,0 @@ -# Class: Test_Symbol::TestInadvertent -**Inherits:** Test::Unit::TestCase - -**Includes:** Test_Symbol::NonInterned - - - - - -#Instance Methods -## assert_no_immortal_symbol_created(name) [](#method-i-assert_no_immortal_symbol_created) - -**@yield** [name] - -## assert_no_immortal_symbol_in_method_missing(name) [](#method-i-assert_no_immortal_symbol_in_method_missing) - -## assert_not_interned(name, msgnil) [](#method-i-assert_not_interned) - -## assert_not_interned_error(obj, meth, name, msgnil, &block) [](#method-i-assert_not_interned_error) - -## assert_not_interned_false(obj, meth, name, msgnil) [](#method-i-assert_not_interned_false) - -## assert_not_pinneddown(name, msgnil) [](#method-i-assert_not_pinneddown) - -## setup() [](#method-i-setup) - -## test___send__() [](#method-i-test___send__) - -## test_aliased_method() [](#method-i-test_aliased_method) - -## test_const_missing() [](#method-i-test_const_missing) - -## test_enumerable_inject_op() [](#method-i-test_enumerable_inject_op) - -## test_execopt_key() [](#method-i-test_execopt_key) - -## test_execopt_redirect_path() [](#method-i-test_execopt_redirect_path) - -## test_execopt_redirect_symbol() [](#method-i-test_execopt_redirect_symbol) - -## test_execopt_redirect_value() [](#method-i-test_execopt_redirect_value) - -## test_gc_attrset() [](#method-i-test_gc_attrset) - -## test_invalid_attr() [](#method-i-test_invalid_attr) - -## test_invalid_attr_accessor() [](#method-i-test_invalid_attr_accessor) - -## test_invalid_attr_reader() [](#method-i-test_invalid_attr_reader) - -## test_invalid_attr_writer() [](#method-i-test_invalid_attr_writer) - -## test_iv_get() [](#method-i-test_iv_get) - -## test_kwarg_symbol_leak_just_rest() [](#method-i-test_kwarg_symbol_leak_just_rest) - -## test_kwarg_symbol_leak_no_rest() [](#method-i-test_kwarg_symbol_leak_no_rest) - -## test_kwarg_symbol_leak_with_rest() [](#method-i-test_kwarg_symbol_leak_with_rest) - -## test_missing_method() [](#method-i-test_missing_method) - -## test_module_const_defined?() [](#method-i-test_module_const_defined?) - -**@return** [Boolean] - -## test_module_const_get() [](#method-i-test_module_const_get) - -## test_module_const_get_toplevel() [](#method-i-test_module_const_get_toplevel) - -## test_module_const_set() [](#method-i-test_module_const_set) - -## test_module_cvar_set() [](#method-i-test_module_cvar_set) - -## test_module_define_method_argument_error() [](#method-i-test_module_define_method_argument_error) - -## test_module_define_method_type_error() [](#method-i-test_module_define_method_type_error) - -## test_object_ivar_set() [](#method-i-test_object_ivar_set) - -## test_public_send() [](#method-i-test_public_send) - -## test_respond_to_missing() [](#method-i-test_respond_to_missing) - -## test_send() [](#method-i-test_send) - -## test_send_leak_string() [](#method-i-test_send_leak_string) - -## test_send_leak_string_custom_method_missing() [](#method-i-test_send_leak_string_custom_method_missing) - -## test_send_leak_string_custom_method_missing_no_optimization() [](#method-i-test_send_leak_string_custom_method_missing_no_optimization) - -## test_send_leak_string_no_optimization() [](#method-i-test_send_leak_string_no_optimization) - -## test_send_leak_symbol() [](#method-i-test_send_leak_symbol) - -## test_send_leak_symbol_custom_method_missing() [](#method-i-test_send_leak_symbol_custom_method_missing) - -## test_send_leak_symbol_custom_method_missing_no_optimization() [](#method-i-test_send_leak_symbol_custom_method_missing_no_optimization) - -## test_send_leak_symbol_no_optimization() [](#method-i-test_send_leak_symbol_no_optimization) - -## test_struct_aref() [](#method-i-test_struct_aref) - -## test_struct_aset() [](#method-i-test_struct_aset) - -## test_struct_new() [](#method-i-test_struct_new) - -## test_thread_aref() [](#method-i-test_thread_aref) - -## test_thread_key?() [](#method-i-test_thread_key?) - -**@return** [Boolean] - -## test_thread_variable?() [](#method-i-test_thread_variable?) - -**@return** [Boolean] - -## test_thread_variable_get() [](#method-i-test_thread_variable_get) - -## test_thread_variable_set() [](#method-i-test_thread_variable_set) - -## test_undefined_class_variable() [](#method-i-test_undefined_class_variable) - -## test_undefined_const() [](#method-i-test_undefined_const) - -## test_undefined_instance_variable() [](#method-i-test_undefined_instance_variable) - -## test_undefined_method() [](#method-i-test_undefined_method) - diff --git a/example/ruby/Test_Symbol/TestType.md b/example/ruby/Test_Symbol/TestType.md deleted file mode 100644 index 300a8f3..0000000 --- a/example/ruby/Test_Symbol/TestType.md +++ /dev/null @@ -1,32 +0,0 @@ -# Class: Test_Symbol::TestType -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_not_symtype(sym, pred, msgnil) [](#method-i-assert_not_symtype) - -## assert_symtype(sym, pred, msgnil) [](#method-i-assert_symtype) - -## test_attrset() [](#method-i-test_attrset) - -## test_check_id_invalid_type() [](#method-i-test_check_id_invalid_type) - -## test_check_symbol_invalid_type() [](#method-i-test_check_symbol_invalid_type) - -## test_class() [](#method-i-test_class) - -## test_const() [](#method-i-test_const) - -## test_const_name_type() [](#method-i-test_const_name_type) - -## test_global() [](#method-i-test_global) - -## test_id2str_fstring_bug9171() [](#method-i-test_id2str_fstring_bug9171) - -## test_instance() [](#method-i-test_instance) - -## test_local() [](#method-i-test_local) - diff --git a/example/ruby/Test_SyncDefaultGems.md b/example/ruby/Test_SyncDefaultGems.md deleted file mode 100644 index 32ba6c1..0000000 --- a/example/ruby/Test_SyncDefaultGems.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Test_SyncDefaultGems - - - - - diff --git a/example/ruby/Test_SyncDefaultGems/TestMessageFilter.md b/example/ruby/Test_SyncDefaultGems/TestMessageFilter.md deleted file mode 100644 index ca8f25f..0000000 --- a/example/ruby/Test_SyncDefaultGems/TestMessageFilter.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Test_SyncDefaultGems::TestMessageFilter -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_message_filter(expected, trailers, input, repo"ruby/test", sha"0123456789") [](#method-i-assert_message_filter) - -## test_co_authored_by() [](#method-i-test_co_authored_by) - -## test_co_authored_by_no_newline() [](#method-i-test_co_authored_by_no_newline) - -## test_dot_ending_subject() [](#method-i-test_dot_ending_subject) - -## test_link_in_parenthesis() [](#method-i-test_link_in_parenthesis) - -## test_multiple_co_authored_by() [](#method-i-test_multiple_co_authored_by) - -## test_subject_only() [](#method-i-test_subject_only) - diff --git a/example/ruby/Test_SyncDefaultGems/TestSyncWithCommits.md b/example/ruby/Test_SyncDefaultGems/TestSyncWithCommits.md deleted file mode 100644 index f651530..0000000 --- a/example/ruby/Test_SyncDefaultGems/TestSyncWithCommits.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: Test_SyncDefaultGems::TestSyncWithCommits -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## assert_sync(commitstrue, success:true, editor:nil) [](#method-i-assert_sync) - -## capture_process_output_to(outputs) [](#method-i-capture_process_output_to) - -## capture_process_outputs() [](#method-i-capture_process_outputs) - -## git(*commands, **opts) [](#method-i-git) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_adding_toplevel() [](#method-i-test_adding_toplevel) - -## test_delete_after_conflict() [](#method-i-test_delete_after_conflict) - -## test_gitignore() [](#method-i-test_gitignore) - -## test_gitignore_after_conflict() [](#method-i-test_gitignore_after_conflict) - -## test_skip_test_fixtures() [](#method-i-test_skip_test_fixtures) - -## test_skip_tool() [](#method-i-test_skip_tool) - -## test_skip_toplevel() [](#method-i-test_skip_toplevel) - -## test_sync() [](#method-i-test_sync) - -## top_commit(dir, format:"%H") [](#method-i-top_commit) - diff --git a/example/ruby/Test_TooManyDummyEncodings.md b/example/ruby/Test_TooManyDummyEncodings.md deleted file mode 100644 index 2bea55a..0000000 --- a/example/ruby/Test_TooManyDummyEncodings.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: Test_TooManyDummyEncodings -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_exceed_encoding_table_size() [](#method-i-test_exceed_encoding_table_size) - diff --git a/example/ruby/Test_TypedData.md b/example/ruby/Test_TypedData.md deleted file mode 100644 index 005bdfe..0000000 --- a/example/ruby/Test_TypedData.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: Test_TypedData -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_deferred_free() [](#method-i-test_deferred_free) - -## test_wrong_argtype() [](#method-i-test_wrong_argtype) - diff --git a/example/ruby/Test_Win32Console.md b/example/ruby/Test_Win32Console.md deleted file mode 100644 index 0e47a21..0000000 --- a/example/ruby/Test_Win32Console.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: Test_Win32Console -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## reset() [](#method-i-reset) - -## reverse_video(fore, back0x0) [](#method-i-reverse_video) - -## test_bold() [](#method-i-test_bold) - -## test_bold_reverse() [](#method-i-test_bold_reverse) - -## test_default() [](#method-i-test_default) - -## test_reverse() [](#method-i-test_reverse) - -## test_reverse_bold() [](#method-i-test_reverse_bold) - diff --git a/example/ruby/Thread.md b/example/ruby/Thread.md deleted file mode 100644 index 7c36722..0000000 --- a/example/ruby/Thread.md +++ /dev/null @@ -1,1078 +0,0 @@ -# Class: Thread -**Inherits:** Object - - -Threads are the Ruby implementation for a concurrent programming model. - -Programs that require multiple threads of execution are a perfect candidate -for Ruby's Thread class. - -For example, we can create a new thread separate from the main thread's -execution using ::new. - - thr = Thread.new { puts "What's the big deal" } - -Then we are able to pause the execution of the main thread and allow our new -thread to finish, using #join: - - thr.join #=> "What's the big deal" - -If we don't call `thr.join` before the main thread terminates, then all other -threads including `thr` will be killed. - -Alternatively, you can use an array for handling multiple threads at once, -like in the following example: - - threads = [] - threads << Thread.new { puts "What's the big deal" } - threads << Thread.new { 3.times { puts "Threads are fun!" } } - -After creating a few threads we wait for them all to finish consecutively. - - threads.each { |thr| thr.join } - - To retrieve the last value of a thread, use #value - - thr = Thread.new { sleep 1; "Useful value" } - thr.value #=> "Useful value" - -### Thread initialization - -In order to create new threads, Ruby provides ::new, ::start, and ::fork. A -block must be provided with each of these methods, otherwise a ThreadError -will be raised. - -When subclassing the Thread class, the `initialize` method of your subclass -will be ignored by ::start and ::fork. Otherwise, be sure to call super in -your `initialize` method. - - === Thread termination - - For terminating threads, Ruby provides a variety of ways to do this. - -The class method ::kill, is meant to exit a given thread: - - thr = Thread.new { sleep } - Thread.kill(thr) # sends exit() to thr - -Alternatively, you can use the instance method #exit, or any of its aliases -#kill or #terminate. - - thr.exit - - === Thread status - - Ruby provides a few instance methods for querying the state of a given - thread. To get a string with the current thread's state use #status - - thr = Thread.new { sleep } - thr.status # => "sleep" - thr.exit - thr.status # => false - -You can also use #alive? to tell if the thread is running or sleeping, and -#stop? if the thread is dead or sleeping. - - === Thread variables and scope - - Since threads are created with blocks, the same rules apply to other Ruby -blocks for variable scope. Any local variables created within this block are -accessible to only this thread. - - ==== Fiber-local vs. Thread-local - -Each fiber has its own bucket for Thread#[] storage. When you set a new -fiber-local it is only accessible within this Fiber. To illustrate: - - Thread.new { - Thread.current[:foo] = "bar" - Fiber.new { - p Thread.current[:foo] # => nil - }.resume - }.join - - This example uses #[] for getting and #[]= for setting fiber-locals, you can -also use #keys to list the fiber-locals for a given thread and #key? to check -if a fiber-local exists. - -When it comes to thread-locals, they are accessible within the entire scope of -the thread. Given the following example: - - Thread.new{ - Thread.current.thread_variable_set(:foo, 1) - p Thread.current.thread_variable_get(:foo) # => 1 - Fiber.new{ - - Thread.current.thread_variable_set(:foo, 2) p -Thread.current.thread_variable_get(:foo) # => 2 - }.resume - p Thread.current.thread_variable_get(:foo) # => 2 - }.join - - You can see that the thread-local +:foo+ carried over into the fiber - and was changed to +2+ by the end of the thread. - - This example makes use of #thread_variable_set to create new - thread-locals, and #thread_variable_get to reference them. - - There is also #thread_variables to list all thread-locals, and - #thread_variable? to check if a given thread-local exists. - - === Exception handling - - When an unhandled exception is raised inside a thread, it will - terminate. By default, this exception will not propagate to other - threads. The exception is stored and when another thread calls #value - or #join, the exception will be re-raised in that thread. - - t = Thread.new{ raise 'something went wrong' } - t.value #=> RuntimeError: something went wrong - - An exception can be raised from outside the thread using the - Thread#raise instance method, which takes the same parameters as - Kernel#raise. - - Setting Thread.abort_on_exception = true, Thread#abort_on_exception = - true, or $DEBUG = true will cause a subsequent unhandled exception - raised in a thread to be automatically re-raised in the main thread. - -With the addition of the class method ::handle_interrupt, you can now handle -exceptions asynchronously with threads. - - === Scheduling - - Ruby provides a few ways to support scheduling threads in your program. - - The first way is by using the class method ::stop, to put the current - running thread to sleep and schedule the execution of another thread. - - Once a thread is asleep, you can use the instance method #wakeup to mark -your thread as eligible for scheduling. - - You can also try ::pass, which attempts to pass execution to another thread -but is dependent on the OS whether a running thread will switch or not. The -same goes for #priority, which lets you hint to the thread scheduler which -threads you want to take precedence when passing execution. This method is -also dependent on the OS and may be ignored on some platforms. - - -# Class Methods -## abort_on_exception() [](#method-c-abort_on_exception) -Returns the status of the global ``abort on exception'' condition. - -The default is `false`. - -When set to `true`, if any thread is aborted by an exception, the raised -exception will be re-raised in the main thread. - -Can also be specified by the global $DEBUG flag or command line option `-d`. - -See also ::abort_on_exception=. - -There is also an instance level method to set this for a specific thread, see -#abort_on_exception. -**@overload** [] - -## abort_on_exception=(val ) [](#method-c-abort_on_exception=) -When set to `true`, if any thread is aborted by an exception, the raised -exception will be re-raised in the main thread. Returns the new state. - - Thread.abort_on_exception = true - t1 = Thread.new do - puts "In new thread" - raise "Exception from thread" - end - sleep(1) - puts "not reached" - -This will produce: - - In new thread - prog.rb:4: Exception from thread (RuntimeError) - from prog.rb:2:in `initialize' - from prog.rb:2:in `new' - from prog.rb:2 - -See also ::abort_on_exception. - -There is also an instance level method to set this for a specific thread, see -#abort_on_exception=. -**@overload** [] - -## capi_thread_specs=(t ) [](#method-c-capi_thread_specs=) -## current() [](#method-c-current) -Returns the currently executing thread. - - Thread.current #=> # -**@overload** [] - -## each_caller_location(*args ) [](#method-c-each_caller_location) -Yields each frame of the current execution stack as a backtrace location -object. -**@overload** [] - -## exit() [](#method-c-exit) -Terminates the currently running thread and schedules another thread to be -run. - -If this thread is already marked to be killed, ::exit returns the Thread. - -If this is the main thread, or the last thread, exit the process. -**@overload** [] - -## fork(args ) [](#method-c-fork) -Basically the same as ::new. However, if class Thread is subclassed, then -calling `start` in that subclass will not invoke the subclass's `initialize` -method. -**@overload** [] - -**@overload** [] - -## handle_interrupt(mask_arg ) [](#method-c-handle_interrupt) -Changes asynchronous interrupt timing. - -*interrupt* means asynchronous event and corresponding procedure by -Thread#raise, Thread#kill, signal trap (not supported yet) and main thread -termination (if main thread terminates, then all other thread will be killed). - -The given `hash` has pairs like `ExceptionClass => :TimingSymbol`. Where the -ExceptionClass is the interrupt handled by the given block. The TimingSymbol -can be one of the following symbols: - -`:immediate` -: Invoke interrupts immediately. - -`:on_blocking` -: Invoke interrupts while *BlockingOperation*. - -`:never` -: Never invoke all interrupts. - - -*BlockingOperation* means that the operation will block the calling thread, -such as read and write. On CRuby implementation, *BlockingOperation* is any -operation executed without GVL. - -Masked asynchronous interrupts are delayed until they are enabled. This method -is similar to sigprocmask(3). - -### NOTE - -Asynchronous interrupts are difficult to use. - -If you need to communicate between threads, please consider to use another way -such as Queue. - -Or use them with deep understanding about this method. - -### Usage - -In this example, we can guard from Thread#raise exceptions. - -Using the `:never` TimingSymbol the RuntimeError exception will always be -ignored in the first block of the main thread. In the second -::handle_interrupt block we can purposefully handle RuntimeError exceptions. - - th = Thread.new do - Thread.handle_interrupt(RuntimeError => :never) { - begin - # You can write resource allocation code safely. - Thread.handle_interrupt(RuntimeError => :immediate) { - # ... - } - ensure - # You can write resource deallocation code safely. - end - } - end - Thread.pass - # ... - th.raise "stop" - -While we are ignoring the RuntimeError exception, it's safe to write our -resource allocation code. Then, the ensure block is where we can safely -deallocate your resources. - -#### Stack control settings - -It's possible to stack multiple levels of ::handle_interrupt blocks in order -to control more than one ExceptionClass and TimingSymbol at a time. - - Thread.handle_interrupt(FooError => :never) { - Thread.handle_interrupt(BarError => :never) { - # FooError and BarError are prohibited. - } - } - -#### Inheritance with ExceptionClass - -All exceptions inherited from the ExceptionClass parameter will be considered. - - Thread.handle_interrupt(Exception => :never) { - # all exceptions inherited from Exception are prohibited. - } - -For handling all interrupts, use `Object` and not `Exception` as the -ExceptionClass, as kill/terminate interrupts are not handled by `Exception`. -**@overload** [] - -## ignore_deadlock() [](#method-c-ignore_deadlock) -Returns the status of the global ``ignore deadlock'' condition. The default is -`false`, so that deadlock conditions are not ignored. - -See also ::ignore_deadlock=. -**@overload** [] - -## ignore_deadlock=(val ) [](#method-c-ignore_deadlock=) -Returns the new state. When set to `true`, the VM will not check for deadlock -conditions. It is only useful to set this if your application can break a -deadlock condition via some other means, such as a signal. - - Thread.ignore_deadlock = true - queue = Thread::Queue.new - - trap(:SIGUSR1){queue.push "Received signal"} - - # raises fatal error unless ignoring deadlock - puts queue.pop - -See also ::ignore_deadlock. -**@overload** [] - -## kill(th ) [](#method-c-kill) -Causes the given `thread` to exit, see also Thread::exit. - - count = 0 - a = Thread.new { loop { count += 1 } } - sleep(0.1) #=> 0 - Thread.kill(a) #=> # - count #=> 93947 - a.alive? #=> false -**@overload** [] - -## list() [](#method-c-list) -Returns an array of Thread objects for all threads that are either runnable or -stopped. - - Thread.new { sleep(200) } - Thread.new { 1000000.times {|i| i*i } } - Thread.new { Thread.stop } - Thread.list.each {|t| p t} - -This will produce: - - # - # - # - # -**@overload** [] - -## main() [](#method-c-main) -Returns the main thread. -**@overload** [] - -## new(*args ) [](#method-c-new) -Thread.new(*args, &proc) -> thread - Thread.new(*args) { |args| ... } -> thread - - Creates a new thread executing the given block. - - Any +args+ given to ::new will be passed to the block: - -arr = [] a, b, c = 1, 2, 3 Thread.new(a,b,c) { |d,e,f| arr << d << e << f -}.join arr #=> [1, 2, 3] - - A ThreadError exception is raised if ::new is called without a block. - - If you're going to subclass Thread, be sure to call super in your - +initialize+ method, otherwise a ThreadError will be raised. -## pass() [](#method-c-pass) -Give the thread scheduler a hint to pass execution to another thread. A -running thread may or may not switch, it depends on OS and processor. -**@overload** [] - -## pending_interrupt?(*args ) [](#method-c-pending_interrupt?) -Returns whether or not the asynchronous queue is empty. - -Since Thread::handle_interrupt can be used to defer asynchronous events, this -method can be used to determine if there are any deferred events. - -If you find this method returns true, then you may finish `:never` blocks. - -For example, the following method processes deferred asynchronous events -immediately. - - def Thread.kick_interrupt_immediately - Thread.handle_interrupt(Object => :immediate) { - Thread.pass - } - end - -If `error` is given, then check only for `error` type deferred events. - -### Usage - - th = Thread.new{ - Thread.handle_interrupt(RuntimeError => :on_blocking){ - while true - ... - # reach safe point to invoke interrupt - if Thread.pending_interrupt? - Thread.handle_interrupt(Object => :immediate){} - end - ... - end - } - } - ... - th.raise # stop thread - -This example can also be written as the following, which you should use to -avoid asynchronous interrupts. - - flag = true - th = Thread.new{ - Thread.handle_interrupt(RuntimeError => :on_blocking){ - while true - ... - # reach safe point to invoke interrupt - break if flag == false - ... - end - } - } - ... - flag = false # stop thread -**@overload** [] - -**@return** [Boolean] - -## report_on_exception() [](#method-c-report_on_exception) -Returns the status of the global ``report on exception'' condition. - -The default is `true` since Ruby 2.5. - -All threads created when this flag is true will report a message on $stderr if -an exception kills the thread. - - Thread.new { 1.times { raise } } - -will produce this output on $stderr: - - # terminated with exception (report_on_exception is true): - Traceback (most recent call last): - 2: from -e:1:in `block in
' - 1: from -e:1:in `times' - -This is done to catch errors in threads early. In some cases, you might not -want this output. There are multiple ways to avoid the extra output: - -* If the exception is not intended, the best is to fix the cause of the - exception so it does not happen anymore. -* If the exception is intended, it might be better to rescue it closer to - where it is raised rather then let it kill the Thread. -* If it is guaranteed the Thread will be joined with Thread#join or - Thread#value, then it is safe to disable this report with - `Thread.current.report_on_exception = false` when starting the Thread. - However, this might handle the exception much later, or not at all if the - Thread is never joined due to the parent thread being blocked, etc. - -See also ::report_on_exception=. - -There is also an instance level method to set this for a specific thread, see -#report_on_exception=. -**@overload** [] - -## report_on_exception=(val ) [](#method-c-report_on_exception=) -Returns the new state. When set to `true`, all threads created afterwards will -inherit the condition and report a message on $stderr if an exception kills a -thread: - - Thread.report_on_exception = true - t1 = Thread.new do - puts "In new thread" - raise "Exception from thread" - end - sleep(1) - puts "In the main thread" - -This will produce: - - In new thread - # terminated with exception (report_on_exception is true): - Traceback (most recent call last): - prog.rb:4:in `block in
': Exception from thread (RuntimeError) - In the main thread - -See also ::report_on_exception. - -There is also an instance level method to set this for a specific thread, see -#report_on_exception=. -**@overload** [] - -## start(args ) [](#method-c-start) -Basically the same as ::new. However, if class Thread is subclassed, then -calling `start` in that subclass will not invoke the subclass's `initialize` -method. -**@overload** [] - -**@overload** [] - -## stop() [](#method-c-stop) -Stops execution of the current thread, putting it into a ``sleep'' state, and -schedules execution of another thread. - - a = Thread.new { print "a"; Thread.stop; print "c" } - sleep 0.1 while a.status!='sleep' - print "b" - a.run - a.join - #=> "abc" -**@overload** [] - - -#Instance Methods -## [](key) [](#method-i-[]) -Attribute Reference---Returns the value of a fiber-local variable (current -thread's root fiber if not explicitly inside a Fiber), using either a symbol -or a string name. If the specified variable does not exist, returns `nil`. - - [ - Thread.new { Thread.current["name"] = "A" }, - Thread.new { Thread.current[:name] = "B" }, - Thread.new { Thread.current["name"] = "C" } - ].each do |th| - th.join - puts "#{th.inspect}: #{th[:name]}" - end - -This will produce: - - #: A - #: B - #: C - -Thread#[] and Thread#[]= are not thread-local but fiber-local. This confusion -did not exist in Ruby 1.8 because fibers are only available since Ruby 1.9. -Ruby 1.9 chooses that the methods behaves fiber-local to save following idiom -for dynamic scope. - - def meth(newvalue) - begin - oldvalue = Thread.current[:name] - Thread.current[:name] = newvalue - yield - ensure - Thread.current[:name] = oldvalue - end - end - -The idiom may not work as dynamic scope if the methods are thread-local and a -given block switches fiber. - - f = Fiber.new { - meth(1) { - Fiber.yield - } - } - meth(2) { - f.resume - } - f.resume - p Thread.current[:name] - #=> nil if fiber-local - #=> 2 if thread-local (The value 2 is leaked to outside of meth method.) - -For thread-local variables, please see #thread_variable_get and -#thread_variable_set. - -**@overload** [] - -## []=(id, val) [](#method-i-[]=) -Attribute Assignment---Sets or creates the value of a fiber-local variable, -using either a symbol or a string. - -See also Thread#[]. - -For thread-local variables, please see #thread_variable_set and -#thread_variable_get. - -**@overload** [] - -## __infinite_loop_dlsym__(name) [](#method-i-__infinite_loop_dlsym__) - -## abort_on_exception() [](#method-i-abort_on_exception) -Returns the status of the thread-local ``abort on exception'' condition for -this `thr`. - -The default is `false`. - -See also #abort_on_exception=. - -There is also a class level method to set this for all threads, see -::abort_on_exception. - -**@overload** [] - -## abort_on_exception=(val) [](#method-i-abort_on_exception=) -When set to `true`, if this `thr` is aborted by an exception, the raised -exception will be re-raised in the main thread. - -See also #abort_on_exception. - -There is also a class level method to set this for all threads, see -::abort_on_exception=. - -**@overload** [] - -## add_trace_func(trace) [](#method-i-add_trace_func) -Adds *proc* as a handler for tracing. - -See Thread#set_trace_func and Kernel#set_trace_func. - -**@overload** [] - -## alive?() [](#method-i-alive?) -Returns `true` if `thr` is running or sleeping. - - thr = Thread.new { } - thr.join #=> # - Thread.current.alive? #=> true - thr.alive? #=> false - -See also #stop? and #status. - -**@overload** [] - -## backtrace(*args) [](#method-i-backtrace) -Returns the current backtrace of the target thread. - -**@overload** [] - -## backtrace_locations(*args) [](#method-i-backtrace_locations) -Returns the execution stack for the target thread---an array containing -backtrace location objects. - -See Thread::Backtrace::Location for more information. - -This method behaves similarly to Kernel#caller_locations except it applies to -a specific thread. - -**@overload** [] - -## call_capi_rb_thread_wakeup() [](#method-i-call_capi_rb_thread_wakeup) - -## exit() [](#method-i-exit) -Terminates `thr` and schedules another thread to be run, returning the -terminated Thread. If this is the main thread, or the last thread, exits the -process. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## fetch(*args) [](#method-i-fetch) -Returns a fiber-local for the given key. If the key can't be found, there are -several options: With no other arguments, it will raise a KeyError exception; -if *default* is given, then that will be returned; if the optional code block -is specified, then that will be run and its result returned. See Thread#[] -and Hash#fetch. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## get_tls() [](#method-i-get_tls) - -## group() [](#method-i-group) -Returns the ThreadGroup which contains the given thread. - - Thread.main.group #=> # - -**@overload** [] - -## initialize(args) [](#method-i-initialize) -:nodoc: - -## join(*args) [](#method-i-join) -The calling thread will suspend execution and run this `thr`. - -Does not return until `thr` exits or until the given `limit` seconds have -passed. - -If the time limit expires, `nil` will be returned, otherwise `thr` is -returned. - -Any threads not joined will be killed when the main program exits. - -If `thr` had previously raised an exception and the ::abort_on_exception or -$DEBUG flags are not set, (so the exception has not yet been processed), it -will be processed at this time. - - a = Thread.new { print "a"; sleep(10); print "b"; print "c" } - x = Thread.new { print "x"; Thread.pass; print "y"; print "z" } - x.join # Let thread x finish, thread a will be killed on exit. - #=> "axyz" - -The following example illustrates the `limit` parameter. - - y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }} - puts "Waiting" until y.join(0.15) - -This will produce: - - tick... - Waiting - tick... - Waiting - tick... - tick... - -**@overload** [] - -**@overload** [] - -## key?(key) [](#method-i-key?) -Returns `true` if the given string (or symbol) exists as a fiber-local -variable. - - me = Thread.current - me[:oliver] = "a" - me.key?(:oliver) #=> true - me.key?(:stanley) #=> false - -**@overload** [] - -## keys() [](#method-i-keys) -Returns an array of the names of the fiber-local variables (as Symbols). - - thr = Thread.new do - Thread.current[:cat] = 'meow' - Thread.current["dog"] = 'woof' - end - thr.join #=> # - thr.keys #=> [:dog, :cat] - -**@overload** [] - -## kill() [](#method-i-kill) -Terminates `thr` and schedules another thread to be run, returning the -terminated Thread. If this is the main thread, or the last thread, exits the -process. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lock_native_thread() [](#method-i-lock_native_thread) - -## name() [](#method-i-name) -show the name of the thread. - -**@overload** [] - -## name=(name) [](#method-i-name=) -set given name to the ruby thread. On some platform, it may set the name to -pthread and/or kernel. - -**@overload** [] - -## native_thread_id() [](#method-i-native_thread_id) -Return the native thread ID which is used by the Ruby thread. - -The ID depends on the OS. (not POSIX thread ID returned by pthread_self(3)) -* On Linux it is TID returned by gettid(2). -* On macOS it is the system-wide unique integral ID of thread returned by - pthread_threadid_np(3). -* On FreeBSD it is the unique integral ID of the thread returned by - pthread_getthreadid_np(3). -* On Windows it is the thread identifier returned by GetThreadId(). -* On other platforms, it raises NotImplementedError. - -NOTE: If the thread is not associated yet or already deassociated with a -native thread, it returns *nil*. If the Ruby implementation uses M:N thread -model, the ID may change depending on the timing. - -**@overload** [] - -## pending_interrupt?(*args) [](#method-i-pending_interrupt?) -Returns whether or not the asynchronous queue is empty for the target thread. - -If `error` is given, then check only for `error` type deferred events. - -See ::pending_interrupt? for more information. - -**@overload** [] - -**@return** [Boolean] - -## priority() [](#method-i-priority) -Returns the priority of *thr*. Default is inherited from the current thread -which creating the new thread, or zero for the initial main thread; -higher-priority thread will run more frequently than lower-priority threads -(but lower-priority threads can also run). - -This is just hint for Ruby thread scheduler. It may be ignored on some -platform. - - Thread.current.priority #=> 0 - -**@overload** [] - -## priority=(prio) [](#method-i-priority=) -Sets the priority of *thr* to *integer*. Higher-priority threads will run more -frequently than lower-priority threads (but lower-priority threads can also -run). - -This is just hint for Ruby thread scheduler. It may be ignored on some -platform. - - count1 = count2 = 0 - a = Thread.new do - loop { count1 += 1 } - end - a.priority = -1 - - b = Thread.new do - loop { count2 += 1 } - end - b.priority = -2 - sleep 1 #=> 1 - count1 #=> 622504 - count2 #=> 5832 - -**@overload** [] - -## raise(*args) [](#method-i-raise) -Raises an exception from the given thread. The caller does not have to be -`thr`. See Kernel#raise for more information. - - Thread.abort_on_exception = true - a = Thread.new { sleep(200) } - a.raise("Gotcha") - -This will produce: - - prog.rb:3: Gotcha (RuntimeError) - from prog.rb:2:in `initialize' - from prog.rb:2:in `new' - from prog.rb:2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## report_on_exception() [](#method-i-report_on_exception) -Returns the status of the thread-local ``report on exception'' condition for -this `thr`. - -The default value when creating a Thread is the value of the global flag -Thread.report_on_exception. - -See also #report_on_exception=. - -There is also a class level method to set this for all new threads, see -::report_on_exception=. - -**@overload** [] - -## report_on_exception=(value) [](#method-i-report_on_exception=) -When set to `true`, a message is printed on $stderr if an exception kills this -`thr`. See ::report_on_exception for details. - -See also #report_on_exception. - -There is also a class level method to set this for all new threads, see -::report_on_exception=. - -**@overload** [] - -## run() [](#method-i-run) -Wakes up `thr`, making it eligible for scheduling. - - a = Thread.new { puts "a"; Thread.stop; puts "c" } - sleep 0.1 while a.status!='sleep' - puts "Got here" - a.run - a.join - -This will produce: - - a - Got here - c - -See also the instance method #wakeup. - -**@overload** [] - -## set_tls(vn) [](#method-i-set_tls) - -## set_trace_func(trace) [](#method-i-set_trace_func) -Establishes *proc* on *thr* as the handler for tracing, or disables tracing if -the parameter is `nil`. - -See Kernel#set_trace_func. - -**@overload** [] - -**@overload** [] - -## status() [](#method-i-status) -Returns the status of `thr`. - -`"sleep"` -: Returned if this thread is sleeping or waiting on I/O - `"run"` -: When this thread is executing - `"aborting"` -: If this thread is aborting - `false` -: When this thread is terminated normally - `nil` -: If terminated with an exception. - - a = Thread.new { raise("die now") } - b = Thread.new { Thread.stop } - c = Thread.new { Thread.exit } - d = Thread.new { sleep } - d.kill #=> # - a.status #=> nil - b.status #=> "sleep" - c.status #=> false - d.status #=> "aborting" - Thread.current.status #=> "run" - - See also the instance methods #alive? and #stop? - - - - - - -**@overload** [] - -## stop?() [](#method-i-stop?) -Returns `true` if `thr` is dead or sleeping. - - a = Thread.new { Thread.stop } - b = Thread.current - a.stop? #=> true - b.stop? #=> false - -See also #alive? and #status. - -**@overload** [] - -## terminate() [](#method-i-terminate) -Terminates `thr` and schedules another thread to be run, returning the -terminated Thread. If this is the main thread, or the last thread, exits the -process. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## thread_variable?(key) [](#method-i-thread_variable?) -Returns `true` if the given string (or symbol) exists as a thread-local -variable. - - me = Thread.current - me.thread_variable_set(:oliver, "a") - me.thread_variable?(:oliver) #=> true - me.thread_variable?(:stanley) #=> false - -Note that these are not fiber local variables. Please see Thread#[] and -Thread#thread_variable_get for more details. - -**@overload** [] - -## thread_variable_get(key) [](#method-i-thread_variable_get) -Returns the value of a thread local variable that has been set. Note that -these are different than fiber local values. For fiber local values, please -see Thread#[] and Thread#[]=. - -Thread local values are carried along with threads, and do not respect fibers. - For example: - - Thread.new { - Thread.current.thread_variable_set("foo", "bar") # set a thread local - Thread.current["foo"] = "bar" # set a fiber local - - Fiber.new { - Fiber.yield [ - Thread.current.thread_variable_get("foo"), # get the thread local - Thread.current["foo"], # get the fiber local - ] - }.resume - }.join.value # => ['bar', nil] - -The value "bar" is returned for the thread local, where nil is returned for -the fiber local. The fiber is executed in the same thread, so the thread -local values are available. - -**@overload** [] - -## thread_variable_set(key, val) [](#method-i-thread_variable_set) -Sets a thread local with `key` to `value`. Note that these are local to -threads, and not to fibers. Please see Thread#thread_variable_get and -Thread#[] for more information. - -**@overload** [] - -## thread_variables() [](#method-i-thread_variables) -Returns an array of the names of the thread-local variables (as Symbols). - - thr = Thread.new do - Thread.current.thread_variable_set(:cat, 'meow') - Thread.current.thread_variable_set("dog", 'woof') - end - thr.join #=> # - thr.thread_variables #=> [:dog, :cat] - -Note that these are not fiber local variables. Please see Thread#[] and -Thread#thread_variable_get for more details. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Dump the name, id, and status of *thr* to a string. - -**@overload** [] - -## value() [](#method-i-value) -Waits for `thr` to complete, using #join, and returns its value or raises the -exception which terminated the thread. - - a = Thread.new { 2 + 2 } - a.value #=> 4 - - b = Thread.new { raise 'something went wrong' } - b.value #=> RuntimeError: something went wrong - -**@overload** [] - -## wakeup() [](#method-i-wakeup) -Marks a given thread as eligible for scheduling, however it may still remain -blocked on I/O. - -**Note:** This does not invoke the scheduler, see #run for more information. - - c = Thread.new { Thread.stop; puts "hey!" } - sleep 0.1 while c.status!='sleep' - c.wakeup - c.join - #=> "hey!" - -**@overload** [] - diff --git a/example/ruby/Thread/Backtrace.md b/example/ruby/Thread/Backtrace.md deleted file mode 100644 index 403d030..0000000 --- a/example/ruby/Thread/Backtrace.md +++ /dev/null @@ -1,55 +0,0 @@ -# Class: Thread::Backtrace -**Inherits:** Object - - - - -# Class Methods -## limit() [](#method-c-limit) -Returns maximum backtrace length set by `--backtrace-limit` command-line -option. The default is `-1` which means unlimited backtraces. If the value is -zero or positive, the error backtraces, produced by Exception#full_message, -are abbreviated and the extra lines are replaced by `... 3 levels... ` - - $ ruby -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" - - 1 - .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) - from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' - from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' - from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' - from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' - from .../lib/ruby/3.1.0/net/http.rb:965:in `start' - from .../lib/ruby/3.1.0/net/http.rb:627:in `start' - from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' - from .../lib/ruby/3.1.0/net/http.rb:474:in `get' - .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) - from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' - from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' - from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' - from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' - from .../lib/ruby/3.1.0/net/http.rb:965:in `start' - from .../lib/ruby/3.1.0/net/http.rb:627:in `start' - from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' - from .../lib/ruby/3.1.0/net/http.rb:474:in `get' - from -e:1:in `
' - - $ ruby --backtrace-limit 2 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" - 2 - .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) - from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' - from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' - ... 7 levels... - .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) - from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' - from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' - ... 7 levels... - - $ ruby --backtrace-limit 0 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" - 0 - .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) - ... 9 levels... - .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) - ... 9 levels... -**@overload** [] - - diff --git a/example/ruby/Thread/Backtrace/Location.md b/example/ruby/Thread/Backtrace/Location.md deleted file mode 100644 index 98cf65a..0000000 --- a/example/ruby/Thread/Backtrace/Location.md +++ /dev/null @@ -1,83 +0,0 @@ -# Class: Thread::Backtrace::Location -**Inherits:** Object - - - - - -#Instance Methods -## absolute_path() [](#method-i-absolute_path) -Returns the full file path of this frame. - -Same as #path, except that it will return absolute path even if the frame is -in the main script. - -## base_label() [](#method-i-base_label) -Returns the base label of this frame, which is usually equal to the label, -without decoration. - -Consider the following example: - -def foo - puts caller_locations(0).first.base_label - - 1.times do - puts caller_locations(0).first.base_label - - 1.times do - puts caller_locations(0).first.base_label - end - end - -end - -The result of calling `foo` is this: - -foo foo foo - -## inspect() [](#method-i-inspect) -Returns the same as calling `inspect` on the string representation of #to_str - -## label() [](#method-i-label) -Returns the label of this frame. - -Usually consists of method, class, module, etc names with decoration. - -Consider the following example: - -def foo - puts caller_locations(0).first.label - - 1.times do - puts caller_locations(0).first.label - - 1.times do - puts caller_locations(0).first.label - end - end - -end - -The result of calling `foo` is this: - -foo block in foo block (2 levels) in foo - -## lineno() [](#method-i-lineno) -Returns the line number of this frame. - -For example, using `caller_locations.rb` from Thread::Backtrace::Location - -loc = c(0..1).first loc.lineno #=> 2 - -## path() [](#method-i-path) -Returns the file name of this frame. This will generally be an absolute path, -unless the frame is in the main script, in which case it will be the script -location passed on the command line. - -For example, using `caller_locations.rb` from Thread::Backtrace::Location - -loc = c(0..1).first loc.path #=> caller_locations.rb - -## to_s() [](#method-i-to_s) -Returns a Kernel#caller style string representing this frame. - diff --git a/example/ruby/Thread/ConditionVariable.md b/example/ruby/Thread/ConditionVariable.md deleted file mode 100644 index 7a3786f..0000000 --- a/example/ruby/Thread/ConditionVariable.md +++ /dev/null @@ -1,57 +0,0 @@ -# Class: Thread::ConditionVariable -**Inherits:** Object - - -ConditionVariable objects augment class Mutex. Using condition variables, it -is possible to suspend while in the middle of a critical section until a -resource becomes available. - -Example: - - mutex = Thread::Mutex.new - resource = Thread::ConditionVariable.new - - a = Thread.new { - -mutex.synchronize { - # Thread 'a' now needs the resource - resource.wait(mutex) - # 'a' can now have the resource - -} - } - - b = Thread.new { - -mutex.synchronize { - # Thread 'b' has finished using the resource - resource.signal - -} - } - - - -#Instance Methods -## broadcast() [](#method-i-broadcast) -Wakes up all threads waiting for this lock. - -## initialize() [](#method-i-initialize) -Creates a new condition variable instance. - -## marshal_dump() [](#method-i-marshal_dump) -:nodoc: - -## signal() [](#method-i-signal) -Wakes up the first thread in line waiting for this lock. - -## wait(*args) [](#method-i-wait) -Releases the lock held in `mutex` and waits; reacquires the lock on wakeup. - -If `timeout` is given, this method returns after `timeout` seconds passed, -even if no other thread doesn't signal. - -Returns the slept result on `mutex`. - -**@overload** [] - diff --git a/example/ruby/Thread/Mutex.md b/example/ruby/Thread/Mutex.md deleted file mode 100644 index 0712b66..0000000 --- a/example/ruby/Thread/Mutex.md +++ /dev/null @@ -1,78 +0,0 @@ -# Class: Thread::Mutex -**Inherits:** Object - - -Thread::Mutex implements a simple semaphore that can be used to coordinate -access to shared data from multiple concurrent threads. - -Example: - - semaphore = Thread::Mutex.new - - a = Thread.new { - semaphore.synchronize { - # access shared resource - } - } - - b = Thread.new { - semaphore.synchronize { - # access shared resource - } - } - - - -#Instance Methods -## initialize() [](#method-i-initialize) -Creates a new Mutex - -**@overload** [] - -## lock() [](#method-i-lock) -Attempts to grab the lock and waits if it isn't available. Raises -`ThreadError` if `mutex` was locked by the current thread. - -**@overload** [] - -## locked?() [](#method-i-locked?) -Returns `true` if this lock is currently held by some thread. - -**@overload** [] - -## owned?() [](#method-i-owned?) -Returns `true` if this lock is currently held by current thread. - -**@overload** [] - -## sleep(*args) [](#method-i-sleep) -Releases the lock and sleeps `timeout` seconds if it is given and non-nil or -forever. Raises `ThreadError` if `mutex` wasn't locked by the current thread. - -When the thread is next woken up, it will attempt to reacquire the lock. - -Note that this method can wakeup without explicit Thread#wakeup call. For -example, receiving signal and so on. - -Returns the slept time in seconds if woken up, or `nil` if timed out. - -**@overload** [] - -## synchronize() [](#method-i-synchronize) -Obtains a lock, runs the block, and releases the lock when the block -completes. See the example under Thread::Mutex. - -**@overload** [] - -## try_lock() [](#method-i-try_lock) -Attempts to obtain the lock and returns immediately. Returns `true` if the -lock was granted. - -**@overload** [] - -## unlock() [](#method-i-unlock) -Releases the lock. Raises `ThreadError` if `mutex` wasn't locked by the -current thread. - -**@overload** [] - diff --git a/example/ruby/Thread/Queue.md b/example/ruby/Thread/Queue.md deleted file mode 100644 index 748099a..0000000 --- a/example/ruby/Thread/Queue.md +++ /dev/null @@ -1,150 +0,0 @@ -# Class: Thread::Queue -**Inherits:** Object - - -The Thread::Queue class implements multi-producer, multi-consumer queues. It -is especially useful in threaded programming when information must be -exchanged safely between multiple threads. The Thread::Queue class implements -all the required locking semantics. - -The class implements FIFO (first in, first out) type of queue. In a FIFO -queue, the first tasks added are the first retrieved. - -Example: - -queue = Thread::Queue.new - -producer = Thread.new do - 5.times do |i| - sleep rand(i) # simulate expense - queue << i - puts "#{i} produced" - end - -end - -consumer = Thread.new do - 5.times do |i| - value = queue.pop - sleep rand(i/2) # simulate expense - puts "consumed #{value}" - end - -end - -consumer.join - - - -#Instance Methods -## clear() [](#method-i-clear) -Removes all objects from the queue. - -## close() [](#method-i-close) -Closes the queue. A closed queue cannot be re-opened. - -After the call to close completes, the following are true: - -* `closed?` will return true - -* `close` will be ignored. - -* calling enq/push/<< will raise a `ClosedQueueError`. - -* when `empty?` is false, calling deq/pop/shift will return an object from - the queue as usual. -* when `empty?` is true, deq(false) will not suspend the thread and will - return nil. deq(true) will raise a `ThreadError`. - -ClosedQueueError is inherited from StopIteration, so that you can break loop -block. - -Example: - - q = Thread::Queue.new - Thread.new{ - while e = q.deq # wait for nil to break loop - # ... - end - } - q.close - -**@overload** [] - -## closed?() [](#method-i-closed?) -Returns `true` if the queue is closed. - -**@overload** [] - -**@return** [Boolean] - -## empty?() [](#method-i-empty?) -Returns `true` if the queue is empty. - -**@overload** [] - -**@return** [Boolean] - -## freeze() [](#method-i-freeze) -The queue can't be frozen, so this method raises an exception: - Thread::Queue.new.freeze # Raises TypeError (cannot freeze #) - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -call-seq: - Thread::Queue.new -> empty_queue - Thread::Queue.new(enumerable) -> queue - -Creates a new queue instance, optionally using the contents of an `enumerable` -for its initial state. - -Example: - - q = Thread::Queue.new - #=> # - q.empty? - #=> true - - q = Thread::Queue.new([1, 2, 3]) - #=> # - q.empty? - #=> false - q.pop - #=> 1 - -## length() [](#method-i-length) -Returns the length of the queue. - -**@overload** [] - -**@overload** [] - -## marshal_dump() [](#method-i-marshal_dump) -:nodoc: - -## num_waiting() [](#method-i-num_waiting) -Returns the number of threads waiting on the queue. - -## pop(non_blockfalse, timeout:nil) [](#method-i-pop) -call-seq: - pop(non_block=false, timeout: nil) - -Retrieves data from the queue. - -If the queue is empty, the calling thread is suspended until data is pushed -onto the queue. If `non_block` is true, the thread isn't suspended, and -`ThreadError` is raised. - -If `timeout` seconds have passed and no data is available `nil` is returned. -If `timeout` is `0` it returns immediately. - -## push(obj) [](#method-i-push) -Pushes the given `object` to the queue. - -**@overload** [] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Thread/SizedQueue.md b/example/ruby/Thread/SizedQueue.md deleted file mode 100644 index 8659b8b..0000000 --- a/example/ruby/Thread/SizedQueue.md +++ /dev/null @@ -1,83 +0,0 @@ -# Class: Thread::SizedQueue -**Inherits:** Object - - -This class represents queues of specified size capacity. The push operation -may be blocked if the capacity is full. - -See Thread::Queue for an example of how a Thread::SizedQueue works. - - - -#Instance Methods -## clear() [](#method-i-clear) -Removes all objects from the queue. - -## close() [](#method-i-close) -Similar to Thread::Queue#close. - -The difference is behavior with waiting enqueuing threads. - -If there are waiting enqueuing threads, they are interrupted by raising -ClosedQueueError('queue closed'). - -**@overload** [] - -## empty?() [](#method-i-empty?) -Returns `true` if the queue is empty. - -**@overload** [] - -**@return** [Boolean] - -## initialize(vmax) [](#method-i-initialize) -Creates a fixed-length queue with a maximum size of `max`. - -**@overload** [] - -## length() [](#method-i-length) -Returns the length of the queue. - -**@overload** [] - -**@overload** [] - -## max() [](#method-i-max) -Returns the maximum size of the queue. - -## max=(vmax) [](#method-i-max=) -Sets the maximum size of the queue to the given `number`. - -**@overload** [] - -## num_waiting() [](#method-i-num_waiting) -Returns the number of threads waiting on the queue. - -## pop(non_blockfalse, timeout:nil) [](#method-i-pop) -call-seq: - pop(non_block=false, timeout: nil) - -Retrieves data from the queue. - -If the queue is empty, the calling thread is suspended until data is pushed -onto the queue. If `non_block` is true, the thread isn't suspended, and -`ThreadError` is raised. - -If `timeout` seconds have passed and no data is available `nil` is returned. -If `timeout` is `0` it returns immediately. - -## push(object, non_blockfalse, timeout:nil) [](#method-i-push) -call-seq: - push(object, non_block=false, timeout: nil) - enq(object, non_block=false, timeout: nil) - <<(object) - -Pushes `object` to the queue. - -If there is no space left in the queue, waits until space becomes available, -unless `non_block` is true. If `non_block` is true, the thread isn't -suspended, and `ThreadError` is raised. - -If `timeout` seconds have passed and no space is available `nil` is returned. -If `timeout` is `0` it returns immediately. Otherwise it returns `self`. - diff --git a/example/ruby/ThreadBacktraceLocationSpecs.md b/example/ruby/ThreadBacktraceLocationSpecs.md deleted file mode 100644 index 1b603ad..0000000 --- a/example/ruby/ThreadBacktraceLocationSpecs.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: ThreadBacktraceLocationSpecs - - - - -# Class Methods -## block_location() [](#method-c-block_location) -## locations() [](#method-c-locations) -## locations_inside_nested_blocks() [](#method-c-locations_inside_nested_blocks) -## method_location() [](#method-c-method_location) - diff --git a/example/ruby/ThreadBacktraceLocationSpecs/MethodAddedAbsolutePath.md b/example/ruby/ThreadBacktraceLocationSpecs/MethodAddedAbsolutePath.md deleted file mode 100644 index 210c99f..0000000 --- a/example/ruby/ThreadBacktraceLocationSpecs/MethodAddedAbsolutePath.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: ThreadBacktraceLocationSpecs::MethodAddedAbsolutePath -**Inherits:** Object - - - - -# Class Methods -## method_added(name ) [](#method-c-method_added) -**@private** [] - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/ThreadError.md b/example/ruby/ThreadError.md deleted file mode 100644 index 13cad4f..0000000 --- a/example/ruby/ThreadError.md +++ /dev/null @@ -1,17 +0,0 @@ -# Exception: ThreadError -**Inherits:** StandardError - - -Raised when an invalid operation is attempted on a thread. - -For example, when no other thread has been started: - - Thread.stop - -This will raises the following exception: - - ThreadError: stopping only thread - note: use sleep to stop forever - - - diff --git a/example/ruby/ThreadGroup.md b/example/ruby/ThreadGroup.md deleted file mode 100644 index 170c6d7..0000000 --- a/example/ruby/ThreadGroup.md +++ /dev/null @@ -1,66 +0,0 @@ -# Class: ThreadGroup -**Inherits:** Object - - -ThreadGroup provides a means of keeping track of a number of threads as a - group. - - A given Thread object can only belong to one ThreadGroup at a time; adding - a thread to a new group will remove it from any previous group. - - Newly created threads belong to the same group as the thread from which they - were created. - - - -#Instance Methods -## add(thread) [](#method-i-add) -Adds the given `thread` to this group, removing it from any other group to -which it may have previously been a member. - - puts "Initial group is #{ThreadGroup::Default.list}" - tg = ThreadGroup.new - t1 = Thread.new { sleep } - t2 = Thread.new { sleep } - puts "t1 is #{t1}" - puts "t2 is #{t2}" - tg.add(t1) - puts "Initial group now #{ThreadGroup::Default.list}" - puts "tg group now #{tg.list}" - -This will produce: - - Initial group is # - t1 is # - t2 is # - Initial group now ## - tg group now # - -**@overload** [] - -## enclose() [](#method-i-enclose) -Prevents threads from being added to or removed from the receiving -ThreadGroup. - -New threads can still be started in an enclosed ThreadGroup. - - ThreadGroup::Default.enclose #=> # - thr = Thread.new { Thread.stop } #=> # - tg = ThreadGroup.new #=> # - tg.add thr - #=> ThreadError: can't move from the enclosed thread group - -**@overload** [] - -## enclosed?() [](#method-i-enclosed?) -Returns `true` if the `thgrp` is enclosed. See also ThreadGroup#enclose. - -**@overload** [] - -## list() [](#method-i-list) -Returns an array of all existing Thread objects that belong to this group. - - ThreadGroup::Default.list #=> [#] - -**@overload** [] - diff --git a/example/ruby/ThreadInstrumentation.md b/example/ruby/ThreadInstrumentation.md deleted file mode 100644 index 352b3b0..0000000 --- a/example/ruby/ThreadInstrumentation.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ThreadInstrumentation - - - - - diff --git a/example/ruby/ThreadInstrumentation/TestHelper.md b/example/ruby/ThreadInstrumentation/TestHelper.md deleted file mode 100644 index 77f7af6..0000000 --- a/example/ruby/ThreadInstrumentation/TestHelper.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: ThreadInstrumentation::TestHelper - - - - - diff --git a/example/ruby/ThreadSpecs.md b/example/ruby/ThreadSpecs.md deleted file mode 100644 index 8a98bee..0000000 --- a/example/ruby/ThreadSpecs.md +++ /dev/null @@ -1,41 +0,0 @@ -# Module: ThreadSpecs - - - - -# Class Methods -## clear_state() [](#method-c-clear_state) -## completed_thread() [](#method-c-completed_thread) -## counter() [](#method-c-counter) -## counter=(c ) [](#method-c-counter=) -## create_and_kill_critical_thread(pass_after_kill false) [](#method-c-create_and_kill_critical_thread) -## create_critical_thread() [](#method-c-create_critical_thread) -## critical_is_reset() [](#method-c-critical_is_reset) -## critical_thread1() [](#method-c-critical_thread1) -## critical_thread2(is_thread_stop ) [](#method-c-critical_thread2) -## critical_thread_yields_to_main_thread(is_thread_sleep false, is_thread_stop false) [](#method-c-critical_thread_yields_to_main_thread) -## dying_thread_ensures(kill_method_name :kill) [](#method-c-dying_thread_ensures) -## dying_thread_with_outer_ensure(kill_method_name :kill) [](#method-c-dying_thread_with_outer_ensure) -## increment_counter(incr ) [](#method-c-increment_counter) -## join_dying_thread_with_outer_ensure(kill_method_name :kill) [](#method-c-join_dying_thread_with_outer_ensure) -## main_thread1(critical_thread , is_thread_sleep , is_thread_stop ) [](#method-c-main_thread1) -## main_thread2(critical_thread ) [](#method-c-main_thread2) -## running_thread() [](#method-c-running_thread) -## sleeping_thread() [](#method-c-sleeping_thread) -## spin_until_sleeping(t ) [](#method-c-spin_until_sleeping) -## status_of_blocked_thread() [](#method-c-status_of_blocked_thread) -## status_of_completed_thread() [](#method-c-status_of_completed_thread) -## status_of_current_thread() [](#method-c-status_of_current_thread) -## status_of_dying_running_thread() [](#method-c-status_of_dying_running_thread) -## status_of_dying_sleeping_thread() [](#method-c-status_of_dying_sleeping_thread) -## status_of_dying_thread_after_sleep() [](#method-c-status_of_dying_thread_after_sleep) -## status_of_killed_thread() [](#method-c-status_of_killed_thread) -## status_of_running_thread() [](#method-c-status_of_running_thread) -## status_of_sleeping_thread() [](#method-c-status_of_sleeping_thread) -## status_of_thread_with_uncaught_exception() [](#method-c-status_of_thread_with_uncaught_exception) -## wakeup_dying_sleeping_thread(kill_method_name :kill) [](#method-c-wakeup_dying_sleeping_thread) -# Attributes -## state[RW] [](#attribute-c-state) -Returns the value of attribute state. - - diff --git a/example/ruby/ThreadSpecs/Status.md b/example/ruby/ThreadSpecs/Status.md deleted file mode 100644 index a41792f..0000000 --- a/example/ruby/ThreadSpecs/Status.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: ThreadSpecs::Status -**Inherits:** Object - - - - -# Attributes -## inspect[RW] [](#attribute-i-inspect) -Returns the value of attribute inspect. - -## status[RW] [](#attribute-i-status) -Returns the value of attribute status. - -## thread[RW] [](#attribute-i-thread) -Returns the value of attribute thread. - -## to_s[RW] [](#attribute-i-to_s) -Returns the value of attribute to_s. - - -#Instance Methods -## alive?() [](#method-i-alive?) - -**@return** [Boolean] - -## initialize(thread) [](#method-i-initialize) - -**@return** [Status] a new instance of Status - -## stop?() [](#method-i-stop?) - -**@return** [Boolean] - diff --git a/example/ruby/ThreadSpecs/SubThread.md b/example/ruby/ThreadSpecs/SubThread.md deleted file mode 100644 index c552cca..0000000 --- a/example/ruby/ThreadSpecs/SubThread.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: ThreadSpecs::SubThread -**Inherits:** Thread - - - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) - -**@return** [SubThread] a new instance of SubThread - diff --git a/example/ruby/Tick.md b/example/ruby/Tick.md deleted file mode 100644 index 7088878..0000000 --- a/example/ruby/Tick.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Tick -**Inherits:** Object - -**Includes:** Observable - - - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Tick] a new instance of Tick - diff --git a/example/ruby/Time.md b/example/ruby/Time.md deleted file mode 100644 index a59bab0..0000000 --- a/example/ruby/Time.md +++ /dev/null @@ -1,1545 +0,0 @@ -# Class: Time -**Inherits:** Object - -**Includes:** Comparable - - -# - - -# Class Methods -## apply_offset(year , mon , day , hour , min , sec , off ) [](#method-c-apply_offset) -## at(time , subsec false, unit :microsecond, in: nil) [](#method-c-at) -Returns a new `Time` object based on the given arguments. - -Required argument `time` may be either of: - -* A `Time` object, whose value is the basis for the returned time; also - influenced by optional keyword argument `in:` (see below). -* A numeric number of [Epoch seconds](rdoc-ref:Time@Epoch+Seconds) for the - returned time. - -Examples: - - t = Time.new(2000, 12, 31, 23, 59, 59) # => 2000-12-31 23:59:59 -0600 - secs = t.to_i # => 978328799 - Time.at(secs) # => 2000-12-31 23:59:59 -0600 - Time.at(secs + 0.5) # => 2000-12-31 23:59:59.5 -0600 - Time.at(1000000000) # => 2001-09-08 20:46:40 -0500 - Time.at(0) # => 1969-12-31 18:00:00 -0600 - Time.at(-1000000000) # => 1938-04-24 17:13:20 -0500 - -Optional numeric argument `subsec` and optional symbol argument `units` work -together to specify subseconds for the returned time; argument `units` -specifies the units for `subsec`: - -* `:millisecond`: `subsec` in milliseconds: - - Time.at(secs, 0, :millisecond) # => 2000-12-31 23:59:59 -0600 - Time.at(secs, 500, :millisecond) # => 2000-12-31 23:59:59.5 -0600 - Time.at(secs, 1000, :millisecond) # => 2001-01-01 00:00:00 -0600 - Time.at(secs, -1000, :millisecond) # => 2000-12-31 23:59:58 -0600 - -* `:microsecond` or `:usec`: `subsec` in microseconds: - - Time.at(secs, 0, :microsecond) # => 2000-12-31 23:59:59 -0600 - Time.at(secs, 500000, :microsecond) # => 2000-12-31 23:59:59.5 -0600 - Time.at(secs, 1000000, :microsecond) # => 2001-01-01 00:00:00 -0600 - Time.at(secs, -1000000, :microsecond) # => 2000-12-31 23:59:58 -0600 - -* `:nanosecond` or `:nsec`: `subsec` in nanoseconds: - - Time.at(secs, 0, :nanosecond) # => 2000-12-31 23:59:59 -0600 - Time.at(secs, 500000000, :nanosecond) # => 2000-12-31 23:59:59.5 -0600 - Time.at(secs, 1000000000, :nanosecond) # => 2001-01-01 00:00:00 -0600 - Time.at(secs, -1000000000, :nanosecond) # => 2000-12-31 23:59:58 -0600 - -Optional keyword argument `in: zone` specifies the timezone for the returned -time: - - Time.at(secs, in: '+12:00') # => 2001-01-01 17:59:59 +1200 - Time.at(secs, in: '-12:00') # => 2000-12-31 17:59:59 -1200 - -For the forms of argument `zone`, see [Timezone -Specifiers](rdoc-ref:Time@Timezone+Specifiers). -## force_zone!(t , zone , offset nil) [](#method-c-force_zone!) -## httpdate(date ) [](#method-c-httpdate) -Parses `date` as an HTTP-date defined by RFC 2616 and converts it to a Time -object. - -ArgumentError is raised if `date` is not compliant with RFC 2616 or if the -Time class cannot represent specified date. - -See #httpdate for more information on this format. - - require 'time' - - Time.httpdate("Thu, 06 Oct 2011 02:26:12 GMT") - #=> 2011-10-06 02:26:12 UTC - -You must require 'time' to use this method. -## iso8601() [](#method-c-iso8601) -Parses `time` as a dateTime defined by the XML Schema and converts it to a -Time object. The format is a restricted version of the format defined by ISO -8601. - -ArgumentError is raised if `time` is not compliant with the format or if the -Time class cannot represent the specified time. - -See #xmlschema for more information on this format. - - require 'time' - - Time.xmlschema("2011-10-05T22:26:12-04:00") - #=> 2011-10-05 22:26:12-04:00 - -You must require 'time' to use this method. -## json_create(object ) [](#method-c-json_create) -See #as_json. -## local(*args ) [](#method-c-local) -Like Time.utc, except that the returned `Time` object has the local timezone, -not the UTC timezone: - - # With seven arguments. - Time.local(0, 1, 2, 3, 4, 5, 6) - # => 0000-01-02 03:04:05.000006 -0600 - # With exactly ten arguments. - Time.local(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) - # => 0005-04-03 02:01:00 -0600 -**@overload** [] - -**@overload** [] - -## make_time(date , year , yday , mon , day , hour , min , sec , sec_fraction , zone , now ) [](#method-c-make_time) -## month_days(y , m ) [](#method-c-month_days) -## now(in: nil) [](#method-c-now) -Creates a new `Time` object from the current system time. This is the same as -Time.new without arguments. - - Time.now # => 2009-06-24 12:39:54 +0900 - Time.now(in: '+04:00') # => 2009-06-24 07:39:54 +0400 - -For forms of argument `zone`, see [Timezone -Specifiers](rdoc-ref:Time@Timezone+Specifiers). -## parse(date , now self.now) [](#method-c-parse) -Takes a string representation of a Time and attempts to parse it using a -heuristic. - -This method **does not** function as a validator. If the input string does -not match valid formats strictly, you may get a cryptic result. Should -consider to use Time.strptime instead of this method as possible. - - require 'time' - - Time.parse("2010-10-31") #=> 2010-10-31 00:00:00 -0500 - -Any missing pieces of the date are inferred based on the current date. - - require 'time' - - # assuming the current date is "2011-10-31" - Time.parse("12:00") #=> 2011-10-31 12:00:00 -0500 - -We can change the date used to infer our missing elements by passing a second -object that responds to #mon, #day and #year, such as Date, Time or DateTime. -We can also use our own object. - - require 'time' - - class MyDate - attr_reader :mon, :day, :year - - def initialize(mon, day, year) - @mon, @day, @year = mon, day, year - end - end - - d = Date.parse("2010-10-28") - t = Time.parse("2010-10-29") - dt = DateTime.parse("2010-10-30") - md = MyDate.new(10,31,2010) - - Time.parse("12:00", d) #=> 2010-10-28 12:00:00 -0500 - Time.parse("12:00", t) #=> 2010-10-29 12:00:00 -0500 - Time.parse("12:00", dt) #=> 2010-10-30 12:00:00 -0500 - Time.parse("12:00", md) #=> 2010-10-31 12:00:00 -0500 - -If a block is given, the year described in `date` is converted by the block. -This is specifically designed for handling two digit years. For example, if -you wanted to treat all two digit years prior to 70 as the year 2000+ you -could write this: - - require 'time' - - Time.parse("01-10-31") {|year| year + (year < 70 ? 2000 : 1900)} - #=> 2001-10-31 00:00:00 -0500 - Time.parse("70-10-31") {|year| year + (year < 70 ? 2000 : 1900)} - #=> 1970-10-31 00:00:00 -0500 - -If the upper components of the given time are broken or missing, they are -supplied with those of `now`. For the lower components, the minimum values (1 -or 0) are assumed if broken or missing. For example: - - require 'time' - - # Suppose it is "Thu Nov 29 14:33:20 2001" now and - # your time zone is EST which is GMT-5. - now = Time.parse("Thu Nov 29 14:33:20 2001") - Time.parse("16:30", now) #=> 2001-11-29 16:30:00 -0500 - Time.parse("7/23", now) #=> 2001-07-23 00:00:00 -0500 - Time.parse("Aug 31", now) #=> 2001-08-31 00:00:00 -0500 - Time.parse("Aug 2000", now) #=> 2000-08-01 00:00:00 -0500 - -Since there are numerous conflicts among locally defined time zone -abbreviations all over the world, this method is not intended to understand -all of them. For example, the abbreviation "CST" is used variously as: - - -06:00 in America/Chicago, - -05:00 in America/Havana, - +08:00 in Asia/Harbin, - +09:30 in Australia/Darwin, - +10:30 in Australia/Adelaide, - etc. - -Based on this fact, this method only understands the time zone abbreviations -described in RFC 822 and the system time zone, in the order named. (i.e. a -definition in RFC 822 overrides the system time zone definition.) The system -time zone is taken from `Time.local(year, 1, 1).zone` and `Time.local(year, 7, -1).zone`. If the extracted time zone abbreviation does not match any of them, -it is ignored and the given time is regarded as a local time. - -ArgumentError is raised if Date._parse cannot extract information from `date` -or if the Time class cannot represent specified date. - -This method can be used as a fail-safe for other parsing methods as: - - Time.rfc2822(date) rescue Time.parse(date) - Time.httpdate(date) rescue Time.parse(date) - Time.xmlschema(date) rescue Time.parse(date) - -A failure of Time.parse should be checked, though. - -You must require 'time' to use this method. -## rfc2822(date ) [](#method-c-rfc2822) -Parses `date` as date-time defined by RFC 2822 and converts it to a Time -object. The format is identical to the date format defined by RFC 822 and -updated by RFC 1123. - -ArgumentError is raised if `date` is not compliant with RFC 2822 or if the -Time class cannot represent specified date. - -See #rfc2822 for more information on this format. - - require 'time' - - Time.rfc2822("Wed, 05 Oct 2011 22:26:12 -0400") - #=> 2010-10-05 22:26:12 -0400 - -You must require 'time' to use this method. -## rfc822() [](#method-c-rfc822) -Parses `date` as date-time defined by RFC 2822 and converts it to a Time -object. The format is identical to the date format defined by RFC 822 and -updated by RFC 1123. - -ArgumentError is raised if `date` is not compliant with RFC 2822 or if the -Time class cannot represent specified date. - -See #rfc2822 for more information on this format. - - require 'time' - - Time.rfc2822("Wed, 05 Oct 2011 22:26:12 -0400") - #=> 2010-10-05 22:26:12 -0400 - -You must require 'time' to use this method. -## strptime(date , format , now self.now) [](#method-c-strptime) -Works similar to `parse` except that instead of using a heuristic to detect -the format of the input string, you provide a second argument that describes -the format of the string. - -Raises ArgumentError if the date or format is invalid. - -If a block is given, the year described in `date` is converted by the block. -For example: - - Time.strptime(...) {|y| y < 100 ? (y >= 69 ? y + 1900 : y + 2000) : y} - -Below is a list of the formatting options: - -%a -: The abbreviated weekday name ("Sun") - -%A -: The full weekday name ("Sunday") - -%b -: The abbreviated month name ("Jan") - -%B -: The full month name ("January") - -%c -: The preferred local date and time representation - -%C -: Century (20 in 2009) - -%d -: Day of the month (01..31) - -%D -: Date (%m/%d/%y) - -%e -: Day of the month, blank-padded ( 1..31) - -%F -: Equivalent to %Y-%m-%d (the ISO 8601 date format) - -%g -: The last two digits of the commercial year - -%G -: The week-based year according to ISO-8601 (week 1 starts on Monday and - includes January 4) - -%h -: Equivalent to %b - -%H -: Hour of the day, 24-hour clock (00..23) - -%I -: Hour of the day, 12-hour clock (01..12) - -%j -: Day of the year (001..366) - -%k -: hour, 24-hour clock, blank-padded ( 0..23) - -%l -: hour, 12-hour clock, blank-padded ( 0..12) - -%L -: Millisecond of the second (000..999) - -%m -: Month of the year (01..12) - -%M -: Minute of the hour (00..59) - -%n -: Newline (n) - -%N -: Fractional seconds digits - -%p -: Meridian indicator ("AM" or "PM") - -%P -: Meridian indicator ("am" or "pm") - -%r -: time, 12-hour (same as %I:%M:%S %p) - -%R -: time, 24-hour (%H:%M) - -%s -: Number of seconds since 1970-01-01 00:00:00 UTC. - -%S -: Second of the minute (00..60) - -%t -: Tab character (t) - -%T -: time, 24-hour (%H:%M:%S) - -%u -: Day of the week as a decimal, Monday being 1. (1..7) - -%U -: Week number of the current year, starting with the first Sunday as the - first day of the first week (00..53) - -%v -: VMS date (%e-%b-%Y) - -%V -: Week number of year according to ISO 8601 (01..53) - -%W -: Week number of the current year, starting with the first Monday as the - first day of the first week (00..53) - -%w -: Day of the week (Sunday is 0, 0..6) - -%x -: Preferred representation for the date alone, no time - -%X -: Preferred representation for the time alone, no date - -%y -: Year without a century (00..99) - -%Y -: Year which may include century, if provided - -%z -: Time zone as hour offset from UTC (e.g. +0900) - -%Z -: Time zone name - -%% -: Literal "%" character - -%+ -: date(1) (%a %b %e %H:%M:%S %Z %Y) - - - require 'time' - - Time.strptime("2000-10-31", "%Y-%m-%d") #=> 2000-10-31 00:00:00 -0500 - -You must require 'time' to use this method. -**@raise** [ArgumentError] - -## utc(*args ) [](#method-c-utc) -Returns a new `Time` object based the on given arguments, in the UTC timezone. - -With one to seven arguments given, the arguments are interpreted as in the -first calling sequence above: - - Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0) - -Examples: - - Time.utc(2000) # => 2000-01-01 00:00:00 UTC - Time.utc(-2000) # => -2000-01-01 00:00:00 UTC - -There are no minimum and maximum values for the required argument `year`. - -For the optional arguments: - -* `month`: Month in range (1..12), or case-insensitive 3-letter month name: - - Time.utc(2000, 1) # => 2000-01-01 00:00:00 UTC - Time.utc(2000, 12) # => 2000-12-01 00:00:00 UTC - Time.utc(2000, 'jan') # => 2000-01-01 00:00:00 UTC - Time.utc(2000, 'JAN') # => 2000-01-01 00:00:00 UTC - -* `mday`: Month day in range(1..31): - - Time.utc(2000, 1, 1) # => 2000-01-01 00:00:00 UTC - Time.utc(2000, 1, 31) # => 2000-01-31 00:00:00 UTC - -* `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero: - - Time.utc(2000, 1, 1, 0) # => 2000-01-01 00:00:00 UTC - Time.utc(2000, 1, 1, 23) # => 2000-01-01 23:00:00 UTC - Time.utc(2000, 1, 1, 24) # => 2000-01-02 00:00:00 UTC - -* `min`: Minute in range (0..59): - - Time.utc(2000, 1, 1, 0, 0) # => 2000-01-01 00:00:00 UTC - Time.utc(2000, 1, 1, 0, 59) # => 2000-01-01 00:59:00 UTC - -* `sec`: Second in range (0..59), or 60 if `usec` is zero: - - Time.utc(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 UTC - Time.utc(2000, 1, 1, 0, 0, 59) # => 2000-01-01 00:00:59 UTC - Time.utc(2000, 1, 1, 0, 0, 60) # => 2000-01-01 00:01:00 UTC - -* `usec`: Microsecond in range (0..999999): - - Time.utc(2000, 1, 1, 0, 0, 0, 0) # => 2000-01-01 00:00:00 UTC - Time.utc(2000, 1, 1, 0, 0, 0, 999999) # => 2000-01-01 00:00:00.999999 UTC - -The values may be: - -* Integers, as above. -* Numerics convertible to integers: - - Time.utc(Float(0.0), Rational(1, 1), 1.0, 0.0, 0.0, 0.0, 0.0) - # => 0000-01-01 00:00:00 UTC - -* String integers: - - a = %w[0 1 1 0 0 0 0 0] - # => ["0", "1", "1", "0", "0", "0", "0", "0"] - Time.utc(*a) # => 0000-01-01 00:00:00 UTC - -When exactly ten arguments are given, the arguments are interpreted as in the -second calling sequence above: - - Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy) - -where the `dummy` arguments are ignored: - - a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - Time.utc(*a) # => 0005-04-03 02:01:00 UTC - -This form is useful for creating a `Time` object from a 10-element array -returned by Time.to_a: - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006 - a = t.to_a # => [5, 4, 3, 2, 1, 2000, 0, 2, false, nil] - Time.utc(*a) # => 2000-01-02 03:04:05 UTC - -The two forms have their first six arguments in common, though in different -orders; the ranges of these common arguments are the same for both forms; see -above. - -Raises an exception if the number of arguments is eight, nine, or greater than -ten. - -Related: Time.local. -**@overload** [] - -**@overload** [] - -## xmlschema(time ) [](#method-c-xmlschema) -Parses `time` as a dateTime defined by the XML Schema and converts it to a -Time object. The format is a restricted version of the format defined by ISO -8601. - -ArgumentError is raised if `time` is not compliant with the format or if the -Time class cannot represent the specified time. - -See #xmlschema for more information on this format. - - require 'time' - - Time.xmlschema("2011-10-05T22:26:12-04:00") - #=> 2011-10-05 22:26:12-04:00 - -You must require 'time' to use this method. -## zone_offset(zone , year self.now.year) [](#method-c-zone_offset) -Return the number of seconds the specified time zone differs from UTC. - -Numeric time zones that include minutes, such as `-10:00` or `+1330` will -work, as will simpler hour-only time zones like `-10` or `+13`. - -Textual time zones listed in ZoneOffset are also supported. - -If the time zone does not match any of the above, `zone_offset` will check if -the local time zone (both with and without potential Daylight Saving Time -changes being in effect) matches `zone`. Specifying a value for `year` will -change the year used to find the local time zone. - -If `zone_offset` is unable to determine the offset, nil will be returned. - - require 'time' - - Time.zone_offset("EST") #=> -18000 - -You must require 'time' to use this method. -## zone_utc?(zone ) [](#method-c-zone_utc?) -:stopdoc: -**@return** [Boolean] - - -#Instance Methods -## +(time2) [](#method-i-+) -Returns a new `Time` object whose value is the sum of the numeric value of -`self` and the given `numeric`: - - t = Time.new(2000) # => 2000-01-01 00:00:00 -0600 - t + (60 * 60 * 24) # => 2000-01-02 00:00:00 -0600 - t + 0.5 # => 2000-01-01 00:00:00.5 -0600 - -Related: Time#-. - -**@overload** [] - -## -(time2) [](#method-i--) -When `numeric` is given, returns a new `Time` object whose value is the -difference of the numeric value of `self` and `numeric`: - - t = Time.new(2000) # => 2000-01-01 00:00:00 -0600 - t - (60 * 60 * 24) # => 1999-12-31 00:00:00 -0600 - t - 0.5 # => 1999-12-31 23:59:59.5 -0600 - -When `other_time` is given, returns a Float whose value is the difference of -the numeric values of `self` and `other_time` in seconds: - - t - t # => 0.0 - -Related: Time#+. - -**@overload** [] - -**@overload** [] - -## <(y) [](#method-i-<) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than 0. - -**@overload** [] - -## <=(y) [](#method-i-<=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value less than or equal to 0. - -**@overload** [] - -## <=>(time2) [](#method-i-<=>) -Compares `self` with `other_time`; returns: - -* `-1`, if `self` is less than `other_time`. -* `0`, if `self` is equal to `other_time`. -* `1`, if `self` is greater then `other_time`. -* `nil`, if `self` and `other_time` are incomparable. - -Examples: - - t = Time.now # => 2007-11-19 08:12:12 -0600 - t2 = t + 2592000 # => 2007-12-19 08:12:12 -0600 - t <=> t2 # => -1 - t2 <=> t # => 1 - - t = Time.now # => 2007-11-19 08:13:38 -0600 - t2 = t + 0.1 # => 2007-11-19 08:13:38 -0600 - t.nsec # => 98222999 - t2.nsec # => 198222999 - t <=> t2 # => -1 - t2 <=> t # => 1 - t <=> t # => 0 - -**@overload** [] - -## ==(y) [](#method-i-==) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns 0. Also returns true if *obj* and *other* are the same object. - -**@overload** [] - -## >(y) [](#method-i->) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than 0. - -**@overload** [] - -## >=(y) [](#method-i->=) -Compares two objects based on the receiver's `<=>` method, returning true if -it returns a value greater than or equal to 0. - -**@overload** [] - -## as_json() [](#method-i-as_json) -Methods `Time#as_json` and `Time.json_create` may be used to serialize and -deserialize a Time object; see [Marshal](rdoc-ref:Marshal). - -Method `Time#as_json` serializes `self`, returning a 2-element hash -representing `self`: - - require 'json/add/time' - x = Time.now.as_json - # => {"json_class"=>"Time", "s"=>1700931656, "n"=>472846644} - -Method `JSON.create` deserializes such a hash, returning a Time object: - - Time.json_create(x) - # => 2023-11-25 11:00:56.472846644 -0600 - -## asctime() [](#method-i-asctime) -Returns a string representation of `self`, formatted by `strftime('%a %b %e %T -%Y')` or its shorthand version `strftime('%c')`; see [Formats for Dates and -Times](rdoc-ref:strftime_formatting.rdoc): - - t = Time.new(2000, 12, 31, 23, 59, 59, 0.5) - t.ctime # => "Sun Dec 31 23:59:59 2000" - t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000" - t.strftime('%c') # => "Sun Dec 31 23:59:59 2000" - -Related: Time#to_s, Time#inspect: - - t.inspect # => "2000-12-31 23:59:59.5 +000001" - t.to_s # => "2000-12-31 23:59:59 +0000" - -**@overload** [] - -## between?(min, max) [](#method-i-between?) -Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max* -is greater than zero, `true` otherwise. - - 3.between?(1, 5) #=> true - 6.between?(1, 5) #=> false - 'cat'.between?('ant', 'dog') #=> true - 'gnu'.between?('ant', 'dog') #=> false - -**@overload** [] - -## ceil(*args) [](#method-i-ceil) -Returns a new `Time` object whose numerical value is greater than or equal to -`self` with its seconds truncated to precision `ndigits`: - - t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r) - t # => 2010-03-30 05:43:25.123456789 UTC - t.ceil # => 2010-03-30 05:43:26 UTC - t.ceil(2) # => 2010-03-30 05:43:25.13 UTC - t.ceil(4) # => 2010-03-30 05:43:25.1235 UTC - t.ceil(6) # => 2010-03-30 05:43:25.123457 UTC - t.ceil(8) # => 2010-03-30 05:43:25.12345679 UTC - t.ceil(10) # => 2010-03-30 05:43:25.123456789 UTC - - t = Time.utc(1999, 12, 31, 23, 59, 59) - t # => 1999-12-31 23:59:59 UTC - (t + 0.4).ceil # => 2000-01-01 00:00:00 UTC - (t + 0.9).ceil # => 2000-01-01 00:00:00 UTC - (t + 1.4).ceil # => 2000-01-01 00:00:01 UTC - (t + 1.9).ceil # => 2000-01-01 00:00:01 UTC - -Related: Time#floor, Time#round. - -**@overload** [] - -## clamp(*args) [](#method-i-clamp) -In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero, -*max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise. - - 12.clamp(0, 100) #=> 12 - 523.clamp(0, 100) #=> 100 - -3.123.clamp(0, 100) #=> 0 - - 'd'.clamp('a', 'f') #=> 'd' - 'z'.clamp('a', 'f') #=> 'f' - -If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`, -it is considered greater than *obj*. - - -20.clamp(0, nil) #=> 0 - 523.clamp(nil, 100) #=> 100 - -In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less -than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and -*obj* otherwise. - - 12.clamp(0..100) #=> 12 - 523.clamp(0..100) #=> 100 - -3.123.clamp(0..100) #=> 0 - - 'd'.clamp('a'..'f') #=> 'd' - 'z'.clamp('a'..'f') #=> 'f' - -If *range.begin* is `nil`, it is considered smaller than *obj*, and if -*range.end* is `nil`, it is considered greater than *obj*. - - -20.clamp(0..) #=> 0 - 523.clamp(..100) #=> 100 - -When *range.end* is excluded and not `nil`, an exception is raised. - - 100.clamp(0...100) # ArgumentError - -**@overload** [] - -**@overload** [] - -## ctime() [](#method-i-ctime) -Returns a string representation of `self`, formatted by `strftime('%a %b %e %T -%Y')` or its shorthand version `strftime('%c')`; see [Formats for Dates and -Times](rdoc-ref:strftime_formatting.rdoc): - - t = Time.new(2000, 12, 31, 23, 59, 59, 0.5) - t.ctime # => "Sun Dec 31 23:59:59 2000" - t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000" - t.strftime('%c') # => "Sun Dec 31 23:59:59 2000" - -Related: Time#to_s, Time#inspect: - - t.inspect # => "2000-12-31 23:59:59.5 +000001" - t.to_s # => "2000-12-31 23:59:59 +0000" - -**@overload** [] - -## day() [](#method-i-day) -Returns the integer day of the month for `self`, in range (1..31): - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.mday # => 2 - -Related: Time#year, Time#hour, Time#min. - -**@overload** [] - -## deconstruct_keys(keys) [](#method-i-deconstruct_keys) -Returns a hash of the name/value pairs, to use in pattern matching. Possible -keys are: `:year`, `:month`, `:day`, `:yday`, `:wday`, `:hour`, `:min`, -`:sec`, `:subsec`, `:dst`, `:zone`. - -Possible usages: - - t = Time.utc(2022, 10, 5, 21, 25, 30) - - if t in wday: 3, day: ..7 # uses deconstruct_keys underneath - puts "first Wednesday of the month" - end - #=> prints "first Wednesday of the month" - - case t - in year: ...2022 - puts "too old" - in month: ..9 - puts "quarter 1-3" - in wday: 1..5, month: - puts "working day in month #{month}" - end - #=> prints "working day in month 10" - -Note that deconstruction by pattern can also be combined with class check: - - if t in Time(wday: 3, day: ..7) - puts "first Wednesday of the month" - end - -**@overload** [] - -## dst?() [](#method-i-dst?) -Returns `true` if `self` is in daylight saving time, `false` otherwise: - - t = Time.local(2000, 1, 1) # => 2000-01-01 00:00:00 -0600 - t.zone # => "Central Standard Time" - t.dst? # => false - t = Time.local(2000, 7, 1) # => 2000-07-01 00:00:00 -0500 - t.zone # => "Central Daylight Time" - t.dst? # => true - -**@overload** [] - -## eql?(time2) [](#method-i-eql?) -Returns `true` if `self` and `other_time` are both `Time` objects with the -exact same time value. - -**@overload** [] - -**@return** [Boolean] - -## floor(*args) [](#method-i-floor) -Returns a new `Time` object whose numerical value is less than or equal to -`self` with its seconds truncated to precision `ndigits`: - - t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r) - t # => 2010-03-30 05:43:25.123456789 UTC - t.floor # => 2010-03-30 05:43:25 UTC - t.floor(2) # => 2010-03-30 05:43:25.12 UTC - t.floor(4) # => 2010-03-30 05:43:25.1234 UTC - t.floor(6) # => 2010-03-30 05:43:25.123456 UTC - t.floor(8) # => 2010-03-30 05:43:25.12345678 UTC - t.floor(10) # => 2010-03-30 05:43:25.123456789 UTC - - t = Time.utc(1999, 12, 31, 23, 59, 59) - t # => 1999-12-31 23:59:59 UTC - (t + 0.4).floor # => 1999-12-31 23:59:59 UTC - (t + 0.9).floor # => 1999-12-31 23:59:59 UTC - (t + 1.4).floor # => 2000-01-01 00:00:00 UTC - (t + 1.9).floor # => 2000-01-01 00:00:00 UTC - -Related: Time#ceil, Time#round. - -**@overload** [] - -## friday?() [](#method-i-friday?) -Returns `true` if `self` represents a Friday, `false` otherwise: - - t = Time.utc(2000, 1, 7) # => 2000-01-07 00:00:00 UTC - t.friday? # => true - -Related: Time#saturday?, Time#sunday?, Time#monday?. - -**@overload** [] - -## getgm() [](#method-i-getgm) -Returns a new `Time` object representing the value of `self` converted to the -UTC timezone: - - local = Time.local(2000) # => 2000-01-01 00:00:00 -0600 - local.utc? # => false - utc = local.getutc # => 2000-01-01 06:00:00 UTC - utc.utc? # => true - utc == local # => true - -**@overload** [] - -## getlocal(*args) [](#method-i-getlocal) -Returns a new `Time` object representing the value of `self` converted to a -given timezone; if `zone` is `nil`, the local timezone is used: - - t = Time.utc(2000) # => 2000-01-01 00:00:00 UTC - t.getlocal # => 1999-12-31 18:00:00 -0600 - t.getlocal('+12:00') # => 2000-01-01 12:00:00 +1200 - -For forms of argument `zone`, see [Timezone -Specifiers](rdoc-ref:Time@Timezone+Specifiers). - -**@overload** [] - -## getutc() [](#method-i-getutc) -Returns a new `Time` object representing the value of `self` converted to the -UTC timezone: - - local = Time.local(2000) # => 2000-01-01 00:00:00 -0600 - local.utc? # => false - utc = local.getutc # => 2000-01-01 06:00:00 UTC - utc.utc? # => true - utc == local # => true - -**@overload** [] - -## gmt?() [](#method-i-gmt?) -Returns `true` if `self` represents a time in UTC (GMT): - - now = Time.now - # => 2022-08-18 10:24:13.5398485 -0500 - now.utc? # => false - utc = Time.utc(2000, 1, 1, 20, 15, 1) - # => 2000-01-01 20:15:01 UTC - utc.utc? # => true - -Related: Time.utc. - -**@overload** [] - -## gmt_offset() [](#method-i-gmt_offset) -Returns the offset in seconds between the timezones of UTC and `self`: - - Time.utc(2000, 1, 1).utc_offset # => 0 - Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours. - -**@overload** [] - -## gmtime() [](#method-i-gmtime) -Returns `self`, converted to the UTC timezone: - - t = Time.new(2000) # => 2000-01-01 00:00:00 -0600 - t.utc? # => false - t.utc # => 2000-01-01 06:00:00 UTC - t.utc? # => true - -Related: Time#getutc (returns a new converted `Time` object). - -**@overload** [] - -## gmtoff() [](#method-i-gmtoff) -Returns the offset in seconds between the timezones of UTC and `self`: - - Time.utc(2000, 1, 1).utc_offset # => 0 - Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours. - -**@overload** [] - -## hash() [](#method-i-hash) -Returns the integer hash code for `self`. - -Related: Object#hash. - -**@overload** [] - -## hour() [](#method-i-hour) -Returns the integer hour of the day for `self`, in range (0..23): - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.hour # => 3 - -Related: Time#year, Time#mon, Time#min. - -**@overload** [] - -## httpdate() [](#method-i-httpdate) -Returns a string which represents the time as RFC 1123 date of HTTP-date -defined by RFC 2616: - - day-of-week, DD month-name CCYY hh:mm:ss GMT - -Note that the result is always UTC (GMT). - - require 'time' - - t = Time.now - t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT" - -You must require 'time' to use this method. - -## initialize(year(now = true), mon(str = year; nil), mdaynil, hournil, minnil, secnil, zonenil, in:nil, precision:9) [](#method-i-initialize) -call-seq: - Time.new(year = nil, mon = nil, mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil, precision: 9) - -Returns a new `Time` object based on the given arguments, by default in the -local timezone. - -With no positional arguments, returns the value of Time.now: - - Time.new # => 2021-04-24 17:27:46.0512465 -0500 - -With one string argument that represents a time, returns a new `Time` object -based on the given argument, in the local timezone. - - Time.new('2000-12-31 23:59:59.5') # => 2000-12-31 23:59:59.5 -0600 - Time.new('2000-12-31 23:59:59.5 +0900') # => 2000-12-31 23:59:59.5 +0900 - Time.new('2000-12-31 23:59:59.5', in: '+0900') # => 2000-12-31 23:59:59.5 +0900 - Time.new('2000-12-31 23:59:59.5') # => 2000-12-31 23:59:59.5 -0600 - Time.new('2000-12-31 23:59:59.56789', precision: 3) # => 2000-12-31 23:59:59.567 -0600 - -With one to six arguments, returns a new `Time` object based on the given -arguments, in the local timezone. - - Time.new(2000, 1, 2, 3, 4, 5) # => 2000-01-02 03:04:05 -0600 - -For the positional arguments (other than `zone`): - -* `year`: Year, with no range limits: - - Time.new(999999999) # => 999999999-01-01 00:00:00 -0600 - Time.new(-999999999) # => -999999999-01-01 00:00:00 -0600 - -* `month`: Month in range (1..12), or case-insensitive 3-letter month name: - - Time.new(2000, 1) # => 2000-01-01 00:00:00 -0600 - Time.new(2000, 12) # => 2000-12-01 00:00:00 -0600 - Time.new(2000, 'jan') # => 2000-01-01 00:00:00 -0600 - Time.new(2000, 'JAN') # => 2000-01-01 00:00:00 -0600 - -* `mday`: Month day in range(1..31): - - Time.new(2000, 1, 1) # => 2000-01-01 00:00:00 -0600 - Time.new(2000, 1, 31) # => 2000-01-31 00:00:00 -0600 - -* `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero: - - Time.new(2000, 1, 1, 0) # => 2000-01-01 00:00:00 -0600 - Time.new(2000, 1, 1, 23) # => 2000-01-01 23:00:00 -0600 - Time.new(2000, 1, 1, 24) # => 2000-01-02 00:00:00 -0600 - -* `min`: Minute in range (0..59): - - Time.new(2000, 1, 1, 0, 0) # => 2000-01-01 00:00:00 -0600 - Time.new(2000, 1, 1, 0, 59) # => 2000-01-01 00:59:00 -0600 - -* `sec`: Second in range (0...61): - - Time.new(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 -0600 - Time.new(2000, 1, 1, 0, 0, 59) # => 2000-01-01 00:00:59 -0600 - Time.new(2000, 1, 1, 0, 0, 60) # => 2000-01-01 00:01:00 -0600 - - `sec` may be Float or Rational. - - Time.new(2000, 1, 1, 0, 0, 59.5) # => 2000-12-31 23:59:59.5 +0900 - Time.new(2000, 1, 1, 0, 0, 59.7r) # => 2000-12-31 23:59:59.7 +0900 - -These values may be: - -* Integers, as above. -* Numerics convertible to integers: - - Time.new(Float(0.0), Rational(1, 1), 1.0, 0.0, 0.0, 0.0) - # => 0000-01-01 00:00:00 -0600 - -* String integers: - - a = %w[0 1 1 0 0 0] - # => ["0", "1", "1", "0", "0", "0"] - Time.new(*a) # => 0000-01-01 00:00:00 -0600 - -When positional argument `zone` or keyword argument `in:` is given, the new -`Time` object is in the specified timezone. For the forms of argument `zone`, -see [Timezone Specifiers](rdoc-ref:Time@Timezone+Specifiers): - - Time.new(2000, 1, 1, 0, 0, 0, '+12:00') - # => 2000-01-01 00:00:00 +1200 - Time.new(2000, 1, 1, 0, 0, 0, in: '-12:00') - # => 2000-01-01 00:00:00 -1200 - Time.new(in: '-12:00') - # => 2022-08-23 08:49:26.1941467 -1200 - -Since `in:` keyword argument just provides the default, so if the first -argument in single string form contains time zone information, this keyword -argument will be silently ignored. - - Time.new('2000-01-01 00:00:00 +0100', in: '-0500').utc_offset # => 3600 - -* `precision`: maximum effective digits in sub-second part, default is 9. - More digits will be truncated, as other operations of `Time`. Ignored - unless the first argument is a string. - -**@return** [Time] a new instance of Time - -## initialize_copy(time) [](#method-i-initialize_copy) -:nodoc: - -## inspect() [](#method-i-inspect) -Returns a string representation of `self` with subseconds: - - t = Time.new(2000, 12, 31, 23, 59, 59, 0.5) - t.inspect # => "2000-12-31 23:59:59.5 +000001" - -Related: Time#ctime, Time#to_s: - - t.ctime # => "Sun Dec 31 23:59:59 2000" - t.to_s # => "2000-12-31 23:59:59 +0000" - -**@overload** [] - -## isdst() [](#method-i-isdst) -Returns `true` if `self` is in daylight saving time, `false` otherwise: - - t = Time.local(2000, 1, 1) # => 2000-01-01 00:00:00 -0600 - t.zone # => "Central Standard Time" - t.dst? # => false - t = Time.local(2000, 7, 1) # => 2000-07-01 00:00:00 -0500 - t.zone # => "Central Daylight Time" - t.dst? # => true - -**@overload** [] - -## localtime(*args) [](#method-i-localtime) -With no argument given: - -* Returns `self` if `self` is a local time. -* Otherwise returns a new `Time` in the user's local timezone: - - t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC - t.localtime # => 2000-01-01 14:15:01 -0600 - -With argument `zone` given, returns the new `Time` object created by -converting `self` to the given time zone: - - t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC - t.localtime("-09:00") # => 2000-01-01 11:15:01 -0900 - -For forms of argument `zone`, see [Timezone -Specifiers](rdoc-ref:Time@Timezone+Specifiers). - -**@overload** [] - -**@overload** [] - -## mday() [](#method-i-mday) -Returns the integer day of the month for `self`, in range (1..31): - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.mday # => 2 - -Related: Time#year, Time#hour, Time#min. - -**@overload** [] - -## min() [](#method-i-min) -Returns the integer minute of the hour for `self`, in range (0..59): - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.min # => 4 - -Related: Time#year, Time#mon, Time#sec. - -**@overload** [] - -## mon() [](#method-i-mon) -Returns the integer month of the year for `self`, in range (1..12): - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.mon # => 1 - -Related: Time#year, Time#hour, Time#min. - -**@overload** [] - -## monday?() [](#method-i-monday?) -Returns `true` if `self` represents a Monday, `false` otherwise: - - t = Time.utc(2000, 1, 3) # => 2000-01-03 00:00:00 UTC - t.monday? # => true - -Related: Time#tuesday?, Time#wednesday?, Time#thursday?. - -**@overload** [] - -## month() [](#method-i-month) -Returns the integer month of the year for `self`, in range (1..12): - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.mon # => 1 - -Related: Time#year, Time#hour, Time#min. - -**@overload** [] - -## nsec() [](#method-i-nsec) -Returns the number of nanoseconds in the subseconds part of `self` in the -range (0..999_999_999); lower-order digits are truncated, not rounded: - - t = Time.now # => 2022-07-11 15:04:53.3219637 -0500 - t.nsec # => 321963700 - -Related: Time#subsec (returns exact subseconds). - -**@overload** [] - -## rfc2822() [](#method-i-rfc2822) -Returns a string which represents the time as date-time defined by RFC 2822: - - day-of-week, DD month-name CCYY hh:mm:ss zone - -where zone is [+-]hhmm. - -If `self` is a UTC time, -0000 is used as zone. - - require 'time' - - t = Time.now - t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 -0400" - -You must require 'time' to use this method. - -## round(*args) [](#method-i-round) -Returns a new `Time` object whose numeric value is that of `self`, with its -seconds value rounded to precision `ndigits`: - - t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r) - t # => 2010-03-30 05:43:25.123456789 UTC - t.round # => 2010-03-30 05:43:25 UTC - t.round(0) # => 2010-03-30 05:43:25 UTC - t.round(1) # => 2010-03-30 05:43:25.1 UTC - t.round(2) # => 2010-03-30 05:43:25.12 UTC - t.round(3) # => 2010-03-30 05:43:25.123 UTC - t.round(4) # => 2010-03-30 05:43:25.1235 UTC - - t = Time.utc(1999, 12,31, 23, 59, 59) - t # => 1999-12-31 23:59:59 UTC - (t + 0.4).round # => 1999-12-31 23:59:59 UTC - (t + 0.49).round # => 1999-12-31 23:59:59 UTC - (t + 0.5).round # => 2000-01-01 00:00:00 UTC - (t + 1.4).round # => 2000-01-01 00:00:00 UTC - (t + 1.49).round # => 2000-01-01 00:00:00 UTC - (t + 1.5).round # => 2000-01-01 00:00:01 UTC - -Related: Time#ceil, Time#floor. - -**@overload** [] - -## saturday?() [](#method-i-saturday?) -Returns `true` if `self` represents a Saturday, `false` otherwise: - - t = Time.utc(2000, 1, 1) # => 2000-01-01 00:00:00 UTC - t.saturday? # => true - -Related: Time#sunday?, Time#monday?, Time#tuesday?. - -**@overload** [] - -## sec() [](#method-i-sec) -Returns the integer second of the minute for `self`, in range (0..60): - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.sec # => 5 - -Note: the second value may be 60 when there is a [leap -second](https://en.wikipedia.org/wiki/Leap_second). - -Related: Time#year, Time#mon, Time#min. - -**@overload** [] - -## strftime(format) [](#method-i-strftime) -Returns a string representation of `self`, formatted according to the given -string `format`. See [Formats for Dates and -Times](rdoc-ref:strftime_formatting.rdoc). - -**@overload** [] - -## subsec() [](#method-i-subsec) -Returns the exact subseconds for `self` as a Numeric (Integer or Rational): - - t = Time.now # => 2022-07-11 15:11:36.8490302 -0500 - t.subsec # => (4245151/5000000) - -If the subseconds is zero, returns integer zero: - - t = Time.new(2000, 1, 1, 2, 3, 4) # => 2000-01-01 02:03:04 -0600 - t.subsec # => 0 - -**@overload** [] - -## sunday?() [](#method-i-sunday?) -Returns `true` if `self` represents a Sunday, `false` otherwise: - - t = Time.utc(2000, 1, 2) # => 2000-01-02 00:00:00 UTC - t.sunday? # => true - -Related: Time#monday?, Time#tuesday?, Time#wednesday?. - -**@overload** [] - -## thursday?() [](#method-i-thursday?) -Returns `true` if `self` represents a Thursday, `false` otherwise: - - t = Time.utc(2000, 1, 6) # => 2000-01-06 00:00:00 UTC - t.thursday? # => true - -Related: Time#friday?, Time#saturday?, Time#sunday?. - -**@overload** [] - -## to_a() [](#method-i-to_a) -Returns a 10-element array of values representing `self`: - - Time.utc(2000, 1, 1).to_a - # => [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"] - # [sec, min, hour, day, mon, year, wday, yday, dst?, zone] - -The returned array is suitable for use as an argument to Time.utc or -Time.local to create a new `Time` object. - -**@overload** [] - -## to_date() [](#method-i-to_date) -Returns a Date object which denotes self. - -**@overload** [] - -## to_datetime() [](#method-i-to_datetime) -Returns a DateTime object which denotes self. - -**@overload** [] - -## to_f() [](#method-i-to_f) -Returns the value of `self` as a Float number [Epoch -seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are included. - -The stored value of `self` is a [Rational](rdoc-ref:Rational@#method-i-to_f), -which means that the returned value may be approximate: - - Time.utc(1970, 1, 1, 0, 0, 0).to_f # => 0.0 - Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_f # => 0.999999 - Time.utc(1950, 1, 1, 0, 0, 0).to_f # => -631152000.0 - Time.utc(1990, 1, 1, 0, 0, 0).to_f # => 631152000.0 - -Related: Time#to_i, Time#to_r. - -**@overload** [] - -## to_i() [](#method-i-to_i) -Returns the value of `self` as integer [Epoch -seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded): - - Time.utc(1970, 1, 1, 0, 0, 0).to_i # => 0 - Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_i # => 0 - Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000 - Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000 - -Related: Time#to_f Time#to_r. - -**@overload** [] - -## to_json(*args) [](#method-i-to_json) -Returns a JSON string representing `self`: - - require 'json/add/time' - puts Time.now.to_json - -Output: - - {"json_class":"Time","s":1700931678,"n":980650786} - -## to_r() [](#method-i-to_r) -Returns the value of `self` as a Rational exact number of [Epoch -seconds](rdoc-ref:Time@Epoch+Seconds); - - Time.now.to_r # => (16571402750320203/10000000) - -Related: Time#to_f, Time#to_i. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns a string representation of `self`, without subseconds: - - t = Time.new(2000, 12, 31, 23, 59, 59, 0.5) - t.to_s # => "2000-12-31 23:59:59 +0000" - -Related: Time#ctime, Time#inspect: - - t.ctime # => "Sun Dec 31 23:59:59 2000" - t.inspect # => "2000-12-31 23:59:59.5 +000001" - -**@overload** [] - -## to_time() [](#method-i-to_time) -Returns self. - -**@overload** [] - -## tuesday?() [](#method-i-tuesday?) -Returns `true` if `self` represents a Tuesday, `false` otherwise: - - t = Time.utc(2000, 1, 4) # => 2000-01-04 00:00:00 UTC - t.tuesday? # => true - -Related: Time#wednesday?, Time#thursday?, Time#friday?. - -**@overload** [] - -## tv_nsec() [](#method-i-tv_nsec) -Returns the number of nanoseconds in the subseconds part of `self` in the -range (0..999_999_999); lower-order digits are truncated, not rounded: - - t = Time.now # => 2022-07-11 15:04:53.3219637 -0500 - t.nsec # => 321963700 - -Related: Time#subsec (returns exact subseconds). - -**@overload** [] - -## tv_sec() [](#method-i-tv_sec) -Returns the value of `self` as integer [Epoch -seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded): - - Time.utc(1970, 1, 1, 0, 0, 0).to_i # => 0 - Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_i # => 0 - Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000 - Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000 - -Related: Time#to_f Time#to_r. - -**@overload** [] - -## tv_usec() [](#method-i-tv_usec) -Returns the number of microseconds in the subseconds part of `self` in the -range (0..999_999); lower-order digits are truncated, not rounded: - - t = Time.now # => 2022-07-11 14:59:47.5484697 -0500 - t.usec # => 548469 - -Related: Time#subsec (returns exact subseconds). - -**@overload** [] - -## usec() [](#method-i-usec) -Returns the number of microseconds in the subseconds part of `self` in the -range (0..999_999); lower-order digits are truncated, not rounded: - - t = Time.now # => 2022-07-11 14:59:47.5484697 -0500 - t.usec # => 548469 - -Related: Time#subsec (returns exact subseconds). - -**@overload** [] - -## utc() [](#method-i-utc) -Returns `self`, converted to the UTC timezone: - - t = Time.new(2000) # => 2000-01-01 00:00:00 -0600 - t.utc? # => false - t.utc # => 2000-01-01 06:00:00 UTC - t.utc? # => true - -Related: Time#getutc (returns a new converted `Time` object). - -**@overload** [] - -## utc?() [](#method-i-utc?) -Returns `true` if `self` represents a time in UTC (GMT): - - now = Time.now - # => 2022-08-18 10:24:13.5398485 -0500 - now.utc? # => false - utc = Time.utc(2000, 1, 1, 20, 15, 1) - # => 2000-01-01 20:15:01 UTC - utc.utc? # => true - -Related: Time.utc. - -**@overload** [] - -## utc_offset() [](#method-i-utc_offset) -Returns the offset in seconds between the timezones of UTC and `self`: - - Time.utc(2000, 1, 1).utc_offset # => 0 - Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours. - -**@overload** [] - -## wday() [](#method-i-wday) -Returns the integer day of the week for `self`, in range (0..6), with Sunday -as zero. - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.wday # => 0 - t.sunday? # => true - -Related: Time#year, Time#hour, Time#min. - -**@overload** [] - -## wednesday?() [](#method-i-wednesday?) -Returns `true` if `self` represents a Wednesday, `false` otherwise: - - t = Time.utc(2000, 1, 5) # => 2000-01-05 00:00:00 UTC - t.wednesday? # => true - -Related: Time#thursday?, Time#friday?, Time#saturday?. - -**@overload** [] - -## xmlschema(*args) [](#method-i-xmlschema) -Returns a string which represents the time as a dateTime defined by XML -Schema: - - CCYY-MM-DDThh:mm:ssTZD - CCYY-MM-DDThh:mm:ss.sssTZD - -where TZD is Z or [+-]hh:mm. - -If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise. - -`fraction_digits` specifies a number of digits to use for fractional seconds. -Its default value is 0. - - t = Time.now - t.xmlschema # => "2011-10-05T22:26:12-04:00" - -**@overload** [] - -## yday() [](#method-i-yday) -Returns the integer day of the year of `self`, in range (1..366). - - Time.new(2000, 1, 1).yday # => 1 - Time.new(2000, 12, 31).yday # => 366 - -**@overload** [] - -## year() [](#method-i-year) -Returns the integer year for `self`: - - t = Time.new(2000, 1, 2, 3, 4, 5, 6) - # => 2000-01-02 03:04:05 +000006 - t.year # => 2000 - -Related: Time#mon, Time#hour, Time#min. - -**@overload** [] - -## zone() [](#method-i-zone) -Returns the string name of the time zone for `self`: - - Time.utc(2000, 1, 1).zone # => "UTC" - Time.new(2000, 1, 1).zone # => "Central Standard Time" - -**@overload** [] - diff --git a/example/ruby/Time/tm.md b/example/ruby/Time/tm.md deleted file mode 100644 index a861ae9..0000000 --- a/example/ruby/Time/tm.md +++ /dev/null @@ -1,8 +0,0 @@ -# Class: Time::tm -**Inherits:** Object - - -A container class for timezone conversion. - - - diff --git a/example/ruby/TimeSpecs.md b/example/ruby/TimeSpecs.md deleted file mode 100644 index 85e8ddf..0000000 --- a/example/ruby/TimeSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TimeSpecs - - - - - diff --git a/example/ruby/TimeSpecs/MethodHolder.md b/example/ruby/TimeSpecs/MethodHolder.md deleted file mode 100644 index e3add3a..0000000 --- a/example/ruby/TimeSpecs/MethodHolder.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TimeSpecs::MethodHolder -**Inherits:** Object - - - - - diff --git a/example/ruby/TimeSpecs/SubTime.md b/example/ruby/TimeSpecs/SubTime.md deleted file mode 100644 index 37fdddd..0000000 --- a/example/ruby/TimeSpecs/SubTime.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: TimeSpecs::SubTime -**Inherits:** Time - - - - - diff --git a/example/ruby/TimeSpecs/TimeLikeArgumentRecorder.md b/example/ruby/TimeSpecs/TimeLikeArgumentRecorder.md deleted file mode 100644 index efe22d3..0000000 --- a/example/ruby/TimeSpecs/TimeLikeArgumentRecorder.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TimeSpecs::TimeLikeArgumentRecorder -**Inherits:** Object - - - - -# Class Methods -## result() [](#method-c-result) - diff --git a/example/ruby/TimeSpecs/TimeWithFindTimezone.md b/example/ruby/TimeSpecs/TimeWithFindTimezone.md deleted file mode 100644 index c78d392..0000000 --- a/example/ruby/TimeSpecs/TimeWithFindTimezone.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: TimeSpecs::TimeWithFindTimezone -**Inherits:** Time - - - - -# Class Methods -## find_timezone(name ) [](#method-c-find_timezone) - diff --git a/example/ruby/TimeSpecs/Timezone.md b/example/ruby/TimeSpecs/Timezone.md deleted file mode 100644 index dfa79a5..0000000 --- a/example/ruby/TimeSpecs/Timezone.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TimeSpecs::Timezone -**Inherits:** Object - - - - - -#Instance Methods -## initialize(options) [](#method-i-initialize) - -**@return** [Timezone] a new instance of Timezone - -## local_to_utc(t) [](#method-i-local_to_utc) - -## utc_to_local(t) [](#method-i-utc_to_local) - diff --git a/example/ruby/TimeSpecs/TimezoneMethodCallRecorder.md b/example/ruby/TimeSpecs/TimezoneMethodCallRecorder.md deleted file mode 100644 index 9c201ef..0000000 --- a/example/ruby/TimeSpecs/TimezoneMethodCallRecorder.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TimeSpecs::TimezoneMethodCallRecorder -**Inherits:** TimeSpecs::Timezone - - - - - -#Instance Methods -## initialize(options, &blk) [](#method-i-initialize) - -**@return** [TimezoneMethodCallRecorder] a new instance of TimezoneMethodCallRecorder - -## local_to_utc(t) [](#method-i-local_to_utc) - -## utc_to_local(t) [](#method-i-utc_to_local) - diff --git a/example/ruby/TimeSpecs/TimezoneWithName.md b/example/ruby/TimeSpecs/TimezoneWithName.md deleted file mode 100644 index a4ebdcb..0000000 --- a/example/ruby/TimeSpecs/TimezoneWithName.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: TimeSpecs::TimezoneWithName -**Inherits:** TimeSpecs::Timezone - - - - -# Attributes -## name[RW] [](#attribute-i-name) -Returns the value of attribute name. - - -#Instance Methods -## abbr(t) [](#method-i-abbr) - -## dst?(t) [](#method-i-dst?) - -**@return** [Boolean] - -## initialize(options) [](#method-i-initialize) - -**@return** [TimezoneWithName] a new instance of TimezoneWithName - -## local_to_utc(t) [](#method-i-local_to_utc) - -## utc_offset(t) [](#method-i-utc_offset) - -## utc_to_local(t) [](#method-i-utc_to_local) - -## zone(t) [](#method-i-zone) - diff --git a/example/ruby/TimeSpecs/Z.md b/example/ruby/TimeSpecs/Z.md deleted file mode 100644 index 6443bca..0000000 --- a/example/ruby/TimeSpecs/Z.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TimeSpecs::Z -**Inherits:** Struct - - - - -# Attributes -## abbr[RW] [](#attribute-i-abbr) -Returns the value of attribute abbr - -**@return** [Object] the current value of abbr - -## offset[RW] [](#attribute-i-offset) -Returns the value of attribute offset - -**@return** [Object] the current value of offset - - diff --git a/example/ruby/TimeSpecs/Zone.md b/example/ruby/TimeSpecs/Zone.md deleted file mode 100644 index 837d961..0000000 --- a/example/ruby/TimeSpecs/Zone.md +++ /dev/null @@ -1,23 +0,0 @@ -# Class: TimeSpecs::Zone -**Inherits:** Struct - - - - -# Attributes -## dst[RW] [](#attribute-i-dst) -Returns the value of attribute dst - -**@return** [Object] the current value of dst - -## dst_range[RW] [](#attribute-i-dst_range) -Returns the value of attribute dst_range - -**@return** [Object] the current value of dst_range - -## std[RW] [](#attribute-i-std) -Returns the value of attribute std - -**@return** [Object] the current value of std - - diff --git a/example/ruby/Timeout.md b/example/ruby/Timeout.md deleted file mode 100644 index 42d29e7..0000000 --- a/example/ruby/Timeout.md +++ /dev/null @@ -1,65 +0,0 @@ -# Module: Timeout - - -Timeout long-running blocks - -## Synopsis - - require 'timeout' - status = Timeout.timeout(5) { - # Something that should be interrupted if it takes more than 5 seconds... - } - -## Description - -Timeout provides a way to auto-terminate a potentially long-running operation -if it hasn't finished in a fixed amount of time. - -## Copyright - -Copyright -: (C) 2000 Network Applied Communication Laboratory, Inc. - -Copyright -: (C) 2000 Information-technology Promotion Agency, Japan - - - -# Class Methods -## ensure_timeout_thread_created() [](#method-c-ensure_timeout_thread_created) -## timeout(sec , klass nil, message nil, &block ) [](#method-c-timeout) -Perform an operation in a block, raising an error if it takes longer than -`sec` seconds to complete. - -`sec` -: Number of seconds to wait for the block to terminate. Any non-negative - number or nil may be used, including Floats to specify fractional seconds. - A value of 0 or `nil` will execute the block without any timeout. Any - negative number will raise an ArgumentError. - -`klass` -: Exception Class to raise if the block fails to terminate in `sec` seconds. - Omitting will use the default, Timeout::Error - -`message` -: Error message to raise with Exception Class. Omitting will use the - default, "execution expired" - - -Returns the result of the block **if** the block completed before `sec` -seconds, otherwise throws an exception, based on the value of `klass`. - -The exception thrown to terminate the given block cannot be rescued inside the -block unless `klass` is given explicitly. However, the block can use ensure to -prevent the handling of the exception. For that reason, this method cannot be -relied on to enforce timeouts for untrusted blocks. - -If a scheduler is defined, it will be used to handle the timeout by invoking -Scheduler#timeout_after. - -Note that this is both a method of module Timeout, so you can `include -Timeout` into your classes so they have a #timeout method, as well as a module -method, so you can call it directly as Timeout.timeout(). -**@raise** [ArgumentError] - - diff --git a/example/ruby/Timeout/Error.md b/example/ruby/Timeout/Error.md deleted file mode 100644 index dfedec8..0000000 --- a/example/ruby/Timeout/Error.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: Timeout::Error -**Inherits:** RuntimeError - - -Raised by Timeout.timeout when the block times out. - - -# Class Methods -## handle_timeout(message ) [](#method-c-handle_timeout) -:nodoc: - diff --git a/example/ruby/Timeout/ExitException.md b/example/ruby/Timeout/ExitException.md deleted file mode 100644 index be47a34..0000000 --- a/example/ruby/Timeout/ExitException.md +++ /dev/null @@ -1,12 +0,0 @@ -# Exception: Timeout::ExitException -**Inherits:** Exception - - -Internal error raised to when a timeout is triggered. - - - -#Instance Methods -## exception() [](#method-i-exception) -:nodoc: - diff --git a/example/ruby/TimeoutAction.md b/example/ruby/TimeoutAction.md deleted file mode 100644 index da894fc..0000000 --- a/example/ruby/TimeoutAction.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TimeoutAction -**Inherits:** Object - - - - - -#Instance Methods -## after(statenil) [](#method-i-after) - -## before(statenil) [](#method-i-before) - -## finish() [](#method-i-finish) - -## initialize(timeout) [](#method-i-initialize) - -**@return** [TimeoutAction] a new instance of TimeoutAction - -## register() [](#method-i-register) - -## start() [](#method-i-start) - diff --git a/example/ruby/TimerAction.md b/example/ruby/TimerAction.md deleted file mode 100644 index 10da27d..0000000 --- a/example/ruby/TimerAction.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TimerAction -**Inherits:** Object - - - - - -#Instance Methods -## elapsed() [](#method-i-elapsed) - -## finish() [](#method-i-finish) - -## format() [](#method-i-format) - -## register() [](#method-i-register) - -## start() [](#method-i-start) - diff --git a/example/ruby/Titans.md b/example/ruby/Titans.md deleted file mode 100644 index c257816..0000000 --- a/example/ruby/Titans.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: Titans -**Inherits:** Gods - -**Includes:** Olympians - - - - - -#Instance Methods -## ruler3() [](#method-i-ruler3) - -## ruler4() [](#method-i-ruler4) - diff --git a/example/ruby/Toggle.md b/example/ruby/Toggle.md deleted file mode 100644 index f3e99df..0000000 --- a/example/ruby/Toggle.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: Toggle -**Inherits:** Object - - --*- Ruby -*- $Id: objinst-ruby.code,v 1.4 2004/11/13 07:42:25 bfulgham Exp $ -http://www.bagley.org/~doug/shootout/ with help from Aristarkh Zagorodnikov - - - -#Instance Methods -## activate() [](#method-i-activate) - -## initialize(start_state) [](#method-i-initialize) - -**@return** [Toggle] a new instance of Toggle - -## value() [](#method-i-value) - diff --git a/example/ruby/TracePoint.md b/example/ruby/TracePoint.md deleted file mode 100644 index bf88b5a..0000000 --- a/example/ruby/TracePoint.md +++ /dev/null @@ -1,399 +0,0 @@ -# Class: TracePoint -**Inherits:** Object - - -A class that provides the functionality of Kernel#set_trace_func in a -well-structured Object-Oriented API. - -## Example - -Use TracePoint to gather information specifically for exceptions: - - trace = TracePoint.new(:raise) do |tp| - p [tp.lineno, tp.event, tp.raised_exception] - end - #=> # - - trace.enable #=> false - - 0 / 0 - #=> [5, :raise, #] - -## Events - -If you don't specify the types of events you want to listen for, TracePoint -will include all available events. - -**Note:** Do not depend on the current event set, as this list is subject to -change. Instead, it is recommended to specify the types of events you want to -use. - -To filter what is traced, you can pass any of the following as `events`: - -`:line` -: Execute an expression or statement on a new line. - -`:class` -: Start a class or module definition. - -`:end` -: Finish a class or module definition. - -`:call` -: Call a Ruby method. - -`:return` -: Return from a Ruby method. - -`:c_call` -: Call a C-language routine. - -`:c_return` -: Return from a C-language routine. - -`:raise` -: Raise an exception. - -`:rescue` -: Rescue an exception. - -`:b_call` -: Event hook at block entry. - -`:b_return` -: Event hook at block ending. - -`:a_call` -: Event hook at all calls (`call`, `b_call`, and `c_call`). - -`:a_return` -: Event hook at all returns (`return`, `b_return`, and `c_return`). - -`:thread_begin` -: Event hook at thread beginning. - -`:thread_end` -: Event hook at thread ending. - -`:fiber_switch` -: Event hook at fiber switch. - -`:script_compiled` -: New Ruby code compiled (with `eval`, `load`, or `require`). - - - -# Class Methods -## allow_reentry() [](#method-c-allow_reentry) -call-seq: - TracePoint.allow_reentry { block } - -Generally, while a TracePoint callback is running, other registered callbacks -are not called to avoid confusion from reentrance. This method allows -reentrance within a given block. Use this method carefully to avoid infinite -callback invocation. - -If called when reentrance is already allowed, it raises a RuntimeError. - -**Example:** - - # Without reentry - # --------------- - - line_handler = TracePoint.new(:line) do |tp| - next if tp.path != __FILE__ # Only works in this file - puts "Line handler" - binding.eval("class C; end") - end.enable - - class_handler = TracePoint.new(:class) do |tp| - puts "Class handler" - end.enable - - class B - end - - # This script will print "Class handler" only once: when inside the :line - # handler, all other handlers are ignored. - - # With reentry - # ------------ - - line_handler = TracePoint.new(:line) do |tp| - next if tp.path != __FILE__ # Only works in this file - next if (__LINE__..__LINE__+3).cover?(tp.lineno) # Prevent infinite calls - puts "Line handler" - TracePoint.allow_reentry { binding.eval("class C; end") } - end.enable - - class_handler = TracePoint.new(:class) do |tp| - puts "Class handler" - end.enable - - class B - end - - # This will print "Class handler" twice: inside the allow_reentry block in the :line - # handler, other handlers are enabled. - -Note that the example shows the principal effect of the method, but its -practical usage is for debugging libraries that sometimes require other -libraries' hooks to not be affected by the debugger being inside trace point -handling. Precautions should be taken against infinite recursion in this case -(note that we needed to filter out calls by itself from the :line handler, -otherwise it would call itself infinitely). -## new(*events ) [](#method-c-new) -call-seq: - TracePoint.new(*events) { |tp| block } -> tp - -Returns a new TracePoint object, not enabled by default. - -To activate the TracePoint object, use TracePoint#enable: - - trace = TracePoint.new(:call) do |tp| - p [tp.lineno, tp.defined_class, tp.method_id, tp.event] - end - #=> # - - trace.enable #=> false - - puts "Hello, TracePoint!" - # ... - # [48, IRB::Notifier::AbstractNotifier, :printf, :call] - # ... - -To deactivate the trace, use TracePoint#disable. - - trace.disable - -See TracePoint@Events for possible events and more information. - -A block must be given; otherwise, an ArgumentError is raised. - -If the trace method isn't included in the given events filter, a RuntimeError -is raised. - - TracePoint.trace(:line) do |tp| - p tp.raised_exception - end - #=> RuntimeError: 'raised_exception' not supported by this event - -If the trace method is called outside a block, a RuntimeError is raised. - - TracePoint.trace(:line) do |tp| - $tp = tp - end - $tp.lineno #=> access from outside (RuntimeError) - -Access from other threads is also forbidden. -## stat() [](#method-c-stat) -call-seq: - TracePoint.stat -> obj - -Returns internal information of TracePoint. - -The contents of the returned value are implementation-specific and may change -in the future. - -This method is only for debugging TracePoint itself. -## trace(*events ) [](#method-c-trace) -call-seq: - TracePoint.trace(*events) { |tp| block } -> obj - -A convenience method for TracePoint.new that activates the trace -automatically. - - trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] } - #=> # - - trace.enabled? #=> true - -#Instance Methods -## binding() [](#method-i-binding) -Returns the generated binding object from the event. - -Note that for `:c_call` and `:c_return` events, the method returns `nil`, -since C methods themselves do not have bindings. - -## callee_id() [](#method-i-callee_id) -Returns the called name of the method being called. - -## defined_class() [](#method-i-defined_class) -Returns the class or module of the method being called. - - class C; def foo; end; end - trace = TracePoint.new(:call) do |tp| - p tp.defined_class #=> C - end.enable do - C.new.foo - end - -If the method is defined by a module, then that module is returned. - - module M; def foo; end; end - class C; include M; end - trace = TracePoint.new(:call) do |tp| - p tp.defined_class #=> M - end.enable do - C.new.foo - end - -**Note:** #defined_class returns the singleton class. - -The 6th block parameter of Kernel#set_trace_func passes the original class -attached by the singleton class. - -**This is a difference between Kernel#set_trace_func and TracePoint.** - - class C; def self.foo; end; end - trace = TracePoint.new(:call) do |tp| - p tp.defined_class #=> # - end.enable do - C.foo - end - -## disable() [](#method-i-disable) -call-seq: - trace.disable -> true or false - trace.disable { block } -> obj - -Deactivates the trace. - -Returns `true` if the trace was enabled. Returns `false` if the trace was -disabled. - - trace.enabled? #=> true - trace.disable #=> true (previous status) - trace.enabled? #=> false - trace.disable #=> false - -If a block is given, the trace will only be disabled within the scope of the -block. - - trace.enabled? #=> true - - trace.disable do - trace.enabled? - # Only disabled for this block - end - - trace.enabled? #=> true - -Note: You cannot access event hooks within the block. - - trace.disable { p tp.lineno } - #=> RuntimeError: access from outside - -## enable(target:nil, target_line:nil, target_thread::default) [](#method-i-enable) -call-seq: - trace.enable(target: nil, target_line: nil, target_thread: nil) -> true or false - trace.enable(target: nil, target_line: nil, target_thread: :default) { block } -> obj - -Activates the trace. - -Returns `true` if the trace was enabled. Returns `false` if the trace was -disabled. - - trace.enabled? #=> false - trace.enable #=> false (previous state) - # trace is enabled - trace.enabled? #=> true - trace.enable #=> true (previous state) - # trace is still enabled - -If a block is given, the trace will only be enabled during the block -execution. If target and target_line are both nil, then target_thread will -default to the current thread if a block is given. - - trace.enabled? #=> false - - trace.enable do - trace.enabled? - # Only enabled for this block and thread - end - - trace.enabled? #=> false - -The `target`, `target_line`, and `target_thread` parameters are used to limit -tracing to specified code objects. `target` should be a code object for which -RubyVM::InstructionSequence.of will return an instruction sequence. - - t = TracePoint.new(:line) { |tp| p tp } - - def m1 - p 1 - end - - def m2 - p 2 - end - - t.enable(target: method(:m1)) - - m1 - # Prints # - m2 - # Prints nothing - -Note: You cannot access event hooks within the `enable` block. - - trace.enable { p tp.lineno } - #=> RuntimeError: access from outside - -## enabled?() [](#method-i-enabled?) -call-seq: - trace.enabled? -> true or false - -Returns the current status of the trace. - -**@return** [Boolean] - -## eval_script() [](#method-i-eval_script) -Returns the compiled source code (String) from eval methods on the -`:script_compiled` event. If loaded from a file, it returns `nil`. - -## event() [](#method-i-event) -Returns the type of event. - -See TracePoint@Events for more information. - -## inspect() [](#method-i-inspect) -call-seq: - trace.inspect -> string - -Returns a string containing a human-readable TracePoint status. - -## instruction_sequence() [](#method-i-instruction_sequence) -Returns the compiled instruction sequence represented by a -RubyVM::InstructionSequence instance on the `:script_compiled` event. - -Note that this method is CRuby-specific. - -## lineno() [](#method-i-lineno) -Returns the line number of the event. - -## method_id() [](#method-i-method_id) -Returns the name at the definition of the method being called. - -## parameters() [](#method-i-parameters) -Returns the parameter definitions of the method or block that the current hook -belongs to. The format is the same as for Method#parameters. - -## path() [](#method-i-path) -Returns the path of the file being executed. - -## raised_exception() [](#method-i-raised_exception) -Returns the exception raised on the `:raise` event or rescued on the `:rescue` -event. - -## return_value() [](#method-i-return_value) -Returns the return value from `:return`, `:c_return`, and `:b_return` events. - -## self() [](#method-i-self) -Returns the trace object during the event. - -Similar to the following, but it returns the correct object (the method -receiver) for `:c_call` and `:c_return` events: - - trace.binding.eval('self') - diff --git a/example/ruby/TracePointChecker.md b/example/ruby/TracePointChecker.md deleted file mode 100644 index 0ea562a..0000000 --- a/example/ruby/TracePointChecker.md +++ /dev/null @@ -1,15 +0,0 @@ -# Module: TracePointChecker - - - - -# Class Methods -## call_stack() [](#method-c-call_stack) -## check() [](#method-c-check) -## clear_call_stack() [](#method-c-clear_call_stack) -## method_label(tp ) [](#method-c-method_label) -## prefix(event ) [](#method-c-prefix) -## start(verbose: false, stop_at_failure: false) [](#method-c-start) -## stop() [](#method-c-stop) -## verbose_out(label , method ) [](#method-c-verbose_out) - diff --git a/example/ruby/TracePointChecker/ZombieTraceHunter.md b/example/ruby/TracePointChecker/ZombieTraceHunter.md deleted file mode 100644 index be3b33f..0000000 --- a/example/ruby/TracePointChecker/ZombieTraceHunter.md +++ /dev/null @@ -1,13 +0,0 @@ -# Module: TracePointChecker::ZombieTraceHunter - - - - - -#Instance Methods -## after_teardown() [](#method-i-after_teardown) - -## before_setup() [](#method-i-before_setup) - -## tracepoint_capture_stat_get() [](#method-i-tracepoint_capture_stat_get) - diff --git a/example/ruby/TracePointSpec.md b/example/ruby/TracePointSpec.md deleted file mode 100644 index 8bb1bf7..0000000 --- a/example/ruby/TracePointSpec.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: TracePointSpec - - - - -# Class Methods -## target_thread?() [](#method-c-target_thread?) -**@return** [Boolean] - -## test() [](#method-c-test) - diff --git a/example/ruby/TracePointSpec/A.md b/example/ruby/TracePointSpec/A.md deleted file mode 100644 index c934e80..0000000 --- a/example/ruby/TracePointSpec/A.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: TracePointSpec::A - - - - - -#Instance Methods -## bar() [](#method-i-bar) - diff --git a/example/ruby/TracePointSpec/B.md b/example/ruby/TracePointSpec/B.md deleted file mode 100644 index 11333e4..0000000 --- a/example/ruby/TracePointSpec/B.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TracePointSpec::B -**Inherits:** Object - -**Includes:** TracePointSpec::A - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## foo() [](#method-i-foo) - diff --git a/example/ruby/TracePointSpec/C.md b/example/ruby/TracePointSpec/C.md deleted file mode 100644 index 4ad0372..0000000 --- a/example/ruby/TracePointSpec/C.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TracePointSpec::C -**Inherits:** TracePointSpec::B - - - - - -#Instance Methods -## bar() [](#method-i-bar) - -## foo() [](#method-i-foo) - -## initialize() [](#method-i-initialize) - -**@return** [C] a new instance of C - diff --git a/example/ruby/TracePointSpec/ClassWithMethodAlias.md b/example/ruby/TracePointSpec/ClassWithMethodAlias.md deleted file mode 100644 index a1d2bf3..0000000 --- a/example/ruby/TracePointSpec/ClassWithMethodAlias.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: TracePointSpec::ClassWithMethodAlias -**Inherits:** Object - - - - - -#Instance Methods -## m() [](#method-i-m) - diff --git a/example/ruby/Transformation.md b/example/ruby/Transformation.md deleted file mode 100644 index 8e3a6f3..0000000 --- a/example/ruby/Transformation.md +++ /dev/null @@ -1,33 +0,0 @@ -# Class: Transformation -**Inherits:** Object - - - - -# Attributes -## q[RW] [](#attribute-i-q) -Returns the value of attribute q. - -## r[RW] [](#attribute-i-r) -Returns the value of attribute r. - -## s[RW] [](#attribute-i-s) -Returns the value of attribute s. - -## t[RW] [](#attribute-i-t) -Returns the value of attribute t. - - -#Instance Methods -## compose(a) [](#method-i-compose) - -## extract(j) [](#method-i-extract) - -## initialize(q, r, s, t) [](#method-i-initialize) - -**@return** [Transformation] a new instance of Transformation - -## next!() [](#method-i-next!) - -## qrst(*args) [](#method-i-qrst) - diff --git a/example/ruby/TreeSpell.md b/example/ruby/TreeSpell.md deleted file mode 100644 index 6a002ba..0000000 --- a/example/ruby/TreeSpell.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: TreeSpell - - -module for classes needed to test TreeSpellChecker - - - diff --git a/example/ruby/TreeSpell/ChangeWord.md b/example/ruby/TreeSpell/ChangeWord.md deleted file mode 100644 index 4440e74..0000000 --- a/example/ruby/TreeSpell/ChangeWord.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: TreeSpell::ChangeWord -**Inherits:** Object - - -Changes a word with one of four actions: insertion, substitution, deletion and -transposition. - - - -#Instance Methods -## deletion(i_place) [](#method-i-deletion) -delete character at index of i_place - -## initialize(input) [](#method-i-initialize) -initialize with input string - -**@return** [ChangeWord] a new instance of ChangeWord - -## insertion(i_place, char) [](#method-i-insertion) -insert char after index of i_place - -## substitution(i_place, char) [](#method-i-substitution) -substitute char at index of i_place - -## transposition(i_place, direction) [](#method-i-transposition) -transpose char at i_place with char at i_place + direction if i_place + -direction is out of bounds just swap in other direction - diff --git a/example/ruby/TreeSpell/HumanTypo.md b/example/ruby/TreeSpell/HumanTypo.md deleted file mode 100644 index 7dc11ae..0000000 --- a/example/ruby/TreeSpell/HumanTypo.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TreeSpell::HumanTypo -**Inherits:** Object - - -Simulate an error prone human typist see doc/human_typo_api.md for the api -description - - - -#Instance Methods -## call() [](#method-i-call) - -## initialize(input, lambda:0.05) [](#method-i-initialize) - -**@return** [HumanTypo] a new instance of HumanTypo - diff --git a/example/ruby/TreeSpellCheckerTest.md b/example/ruby/TreeSpellCheckerTest.md deleted file mode 100644 index 1b13a9a..0000000 --- a/example/ruby/TreeSpellCheckerTest.md +++ /dev/null @@ -1,42 +0,0 @@ -# Class: TreeSpellCheckerTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_corrupt_root() [](#method-i-test_corrupt_root) - -## test_file_in_root() [](#method-i-test_file_in_root) - -## test_find_out_leaves_in_a_path() [](#method-i-test_find_out_leaves_in_a_path) - -## test_leafless_state() [](#method-i-test_leafless_state) - -## test_no_idea_with_augmentation() [](#method-i-test_no_idea_with_augmentation) - -## test_no_plausible_states() [](#method-i-test_no_plausible_states) - -## test_no_plausible_states_with_augmentation() [](#method-i-test_no_plausible_states_with_augmentation) - -## test_parses_dictionary() [](#method-i-test_parses_dictionary) - -## test_parses_elementary_dictionary() [](#method-i-test_parses_elementary_dictionary) - -## test_rake_dictionary() [](#method-i-test_rake_dictionary) - -## test_special_words_mini() [](#method-i-test_special_words_mini) - -## test_special_words_rspec() [](#method-i-test_special_words_rspec) - -## test_works_out_nodes() [](#method-i-test_works_out_nodes) - -## test_works_out_state_space() [](#method-i-test_works_out_state_space) - -## test_works_out_suggestions() [](#method-i-test_works_out_suggestions) - -## test_works_when_input_is_correct() [](#method-i-test_works_when_input_is_correct) - diff --git a/example/ruby/TrueClass.md b/example/ruby/TrueClass.md deleted file mode 100644 index 7e88415..0000000 --- a/example/ruby/TrueClass.md +++ /dev/null @@ -1,65 +0,0 @@ -# Class: TrueClass -**Inherits:** Object - - -The class of the singleton object `true`. - -Several of its methods act as operators: - -* #& -* #| -* #=== -* #^ - -One other method: - -* #to_s and its alias #inspect. - - - -#Instance Methods -## &(obj2) [](#method-i-&) -Returns `false` if `object` is `false` or `nil`, `true` otherwise: - -true & Object.new # => true true & false # => false true & nil # -=> false - -**@overload** [] - -## ===() [](#method-i-===) - -## ^(obj2) [](#method-i-^) -Returns `true` if `object` is `false` or `nil`, `false` otherwise: - - true ^ Object.new # => false - true ^ false # => true - true ^ nil # => true - -**@overload** [] - -## hash() [](#method-i-hash) - -## to_s() [](#method-i-to_s) -Returns string `'true'`: - - true.to_s # => "true" - -TrueClass#inspect is an alias for TrueClass#to_s. - -**@overload** [] - -## |(obj2) [](#method-i-|) -Returns `true`: - - true | Object.new # => true - true | false # => true - true | nil # => true - -Argument `object` is evaluated. This is different from `true` with the -short-circuit operator, whose operand is evaluated only if necessary: - - true | raise # => Raises RuntimeError. - true || raise # => true - -**@overload** [] - diff --git a/example/ruby/TupleSpace.md b/example/ruby/TupleSpace.md deleted file mode 100644 index 7ccc5e5..0000000 --- a/example/ruby/TupleSpace.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: TupleSpace -**Inherits:** Object - - -TupleSpace Copyright (c) 1999-2000 Masatoshi SEKI You can redistribute it -and/or modify it under the same terms as Ruby. - - - -#Instance Methods -## in(template, non_blockfalse) [](#method-i-in) - -## initialize() [](#method-i-initialize) - -**@return** [TupleSpace] a new instance of TupleSpace - -## mv(dest, template, non_blockfalse) [](#method-i-mv) - -## out(*tuples) [](#method-i-out) - -## rd(template, non_blockfalse) [](#method-i-rd) - diff --git a/example/ruby/TupleSpace/Template.md b/example/ruby/TupleSpace/Template.md deleted file mode 100644 index 68bf250..0000000 --- a/example/ruby/TupleSpace/Template.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: TupleSpace::Template -**Inherits:** Object - - - - -# Attributes -## size[RW] [](#attribute-i-size) -Returns the value of attribute size. - - -#Instance Methods -## initialize(list) [](#method-i-initialize) - -**@return** [Template] a new instance of Template - -## match(tuple) [](#method-i-match) - diff --git a/example/ruby/TurboTests.md b/example/ruby/TurboTests.md deleted file mode 100644 index c204ba7..0000000 --- a/example/ruby/TurboTests.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: TurboTests - - - - - diff --git a/example/ruby/TurboTests/CLI.md b/example/ruby/TurboTests/CLI.md deleted file mode 100644 index 1a36021..0000000 --- a/example/ruby/TurboTests/CLI.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: TurboTests::CLI -**Inherits:** Object - - - - - -#Instance Methods -## initialize(argv) [](#method-i-initialize) - -**@return** [CLI] a new instance of CLI - -## run() [](#method-i-run) - diff --git a/example/ruby/TurboTests/FakeExample.md b/example/ruby/TurboTests/FakeExample.md deleted file mode 100644 index dbc6944..0000000 --- a/example/ruby/TurboTests/FakeExample.md +++ /dev/null @@ -1,43 +0,0 @@ -# Class: TurboTests::FakeExample -**Inherits:** Struct - - - - -# Class Methods -## from_obj(obj ) [](#method-c-from_obj) -# Attributes -## description[RW] [](#attribute-i-description) -Returns the value of attribute description - -**@return** [Object] the current value of description - -## execution_result[RW] [](#attribute-i-execution_result) -Returns the value of attribute execution_result - -**@return** [Object] the current value of execution_result - -## full_description[RW] [](#attribute-i-full_description) -Returns the value of attribute full_description - -**@return** [Object] the current value of full_description - -## location[RW] [](#attribute-i-location) -Returns the value of attribute location - -**@return** [Object] the current value of location - -## location_rerun_argument[RW] [](#attribute-i-location_rerun_argument) -Returns the value of attribute location_rerun_argument - -**@return** [Object] the current value of location_rerun_argument - -## metadata[RW] [](#attribute-i-metadata) -Returns the value of attribute metadata - -**@return** [Object] the current value of metadata - - -#Instance Methods -## notification() [](#method-i-notification) - diff --git a/example/ruby/TurboTests/FakeException.md b/example/ruby/TurboTests/FakeException.md deleted file mode 100644 index 5cd835e..0000000 --- a/example/ruby/TurboTests/FakeException.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: TurboTests::FakeException -**Inherits:** Struct - - - - -# Class Methods -## from_obj(obj ) [](#method-c-from_obj) -# Attributes -## backtrace[RW] [](#attribute-i-backtrace) -Returns the value of attribute backtrace - -**@return** [Object] the current value of backtrace - -## cause[RW] [](#attribute-i-cause) -Returns the value of attribute cause - -**@return** [Object] the current value of cause - -## message[RW] [](#attribute-i-message) -Returns the value of attribute message - -**@return** [Object] the current value of message - - diff --git a/example/ruby/TurboTests/FakeExecutionResult.md b/example/ruby/TurboTests/FakeExecutionResult.md deleted file mode 100644 index a09e38d..0000000 --- a/example/ruby/TurboTests/FakeExecutionResult.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: TurboTests::FakeExecutionResult -**Inherits:** Struct - - - - -# Class Methods -## from_obj(obj ) [](#method-c-from_obj) -# Attributes -## example_skipped?[RW] [](#attribute-i-example_skipped?) -Returns the value of attribute example_skipped? - -**@return** [Object] the current value of example_skipped? - -## exception[RW] [](#attribute-i-exception) -Returns the value of attribute exception - -**@return** [Object] the current value of exception - -## pending_exception[RW] [](#attribute-i-pending_exception) -Returns the value of attribute pending_exception - -**@return** [Object] the current value of pending_exception - -## pending_fixed?[RW] [](#attribute-i-pending_fixed?) -Returns the value of attribute pending_fixed? - -**@return** [Object] the current value of pending_fixed? - -## pending_message[RW] [](#attribute-i-pending_message) -Returns the value of attribute pending_message - -**@return** [Object] the current value of pending_message - -## status[RW] [](#attribute-i-status) -Returns the value of attribute status - -**@return** [Object] the current value of status - - diff --git a/example/ruby/TurboTests/JsonRowsFormatter.md b/example/ruby/TurboTests/JsonRowsFormatter.md deleted file mode 100644 index 9e6c3a1..0000000 --- a/example/ruby/TurboTests/JsonRowsFormatter.md +++ /dev/null @@ -1,35 +0,0 @@ -# Class: TurboTests::JsonRowsFormatter -**Inherits:** Object - - -An RSpec formatter used for each subprocess during parallel test execution - - -# Attributes -## output[RW] [](#attribute-i-output) -Returns the value of attribute output. - - -#Instance Methods -## close(notification) [](#method-i-close) - -## example_failed(notification) [](#method-i-example_failed) - -## example_group_finished(notification) [](#method-i-example_group_finished) - -## example_group_started(notification) [](#method-i-example_group_started) - -## example_passed(notification) [](#method-i-example_passed) - -## example_pending(notification) [](#method-i-example_pending) - -## initialize(output) [](#method-i-initialize) - -**@return** [JsonRowsFormatter] a new instance of JsonRowsFormatter - -## message(notification) [](#method-i-message) - -## seed(notification) [](#method-i-seed) - -## start(notification) [](#method-i-start) - diff --git a/example/ruby/TurboTests/Reporter.md b/example/ruby/TurboTests/Reporter.md deleted file mode 100644 index cbc8aea..0000000 --- a/example/ruby/TurboTests/Reporter.md +++ /dev/null @@ -1,53 +0,0 @@ -# Class: TurboTests::Reporter -**Inherits:** Object - - - - -# Class Methods -## from_config(formatter_config , start_time , seed , seed_used ) [](#method-c-from_config) -# Attributes -## failed_examples[RW] [](#attribute-i-failed_examples) -Returns the value of attribute failed_examples. - -## load_time=[R] [](#attribute-i-load_time=) -Sets the attribute load_time - -**@param** [] the value to set the attribute load_time to. - -## pending_examples[RW] [](#attribute-i-pending_examples) -Returns the value of attribute pending_examples. - - -#Instance Methods -## add(name, outputs) [](#method-i-add) - -## error_outside_of_examples(error_message) [](#method-i-error_outside_of_examples) - -## example_failed(example) [](#method-i-example_failed) - -## example_passed(example) [](#method-i-example_passed) - -## example_pending(example) [](#method-i-example_pending) - -## finish() [](#method-i-finish) - -## group_finished() [](#method-i-group_finished) - -## group_started(notification) [](#method-i-group_started) - -## initialize(start_time, seed, seed_used) [](#method-i-initialize) - -**@return** [Reporter] a new instance of Reporter - -## message(message) [](#method-i-message) - -## report(example_groups) [](#method-i-report) -Borrowed from RSpec::Core::Reporter -https://github.com/rspec/rspec-core/blob/5699fcdc4723087ff6139af55bd155ad9ad61 -a7b/lib/rspec/core/reporter.rb#L71 - -## report_number_of_tests(groups) [](#method-i-report_number_of_tests) - -## start(example_groups, timeRSpec::Core::Time.now) [](#method-i-start) - diff --git a/example/ruby/TurboTests/Runner.md b/example/ruby/TurboTests/Runner.md deleted file mode 100644 index 379034a..0000000 --- a/example/ruby/TurboTests/Runner.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: TurboTests::Runner -**Inherits:** Object - - - - -# Class Methods -## run(opts {}) [](#method-c-run) - -#Instance Methods -## initialize(opts) [](#method-i-initialize) - -**@return** [Runner] a new instance of Runner - -## run() [](#method-i-run) - diff --git a/example/ruby/TypeError.md b/example/ruby/TypeError.md deleted file mode 100644 index ba6fd73..0000000 --- a/example/ruby/TypeError.md +++ /dev/null @@ -1,21 +0,0 @@ -# Exception: TypeError -**Inherits:** StandardError - -**Includes:** ErrorHighlight::CoreExt - - -Raised when encountering an object that is not of the expected type. - - [1, 2, 3].first("two") - -*raises the exception:* - - TypeError: no implicit conversion of String into Integer - - - -#Instance Methods -## detailed_message(highlight:false, error_highlight:true) [](#method-i-detailed_message) - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/UDPSocket.md b/example/ruby/UDPSocket.md deleted file mode 100644 index df74ed8..0000000 --- a/example/ruby/UDPSocket.md +++ /dev/null @@ -1,114 +0,0 @@ -# Class: UDPSocket -**Inherits:** IPSocket - - -UDPSocket represents a UDP/IP socket. - - - -#Instance Methods -## bind(host, port) [](#method-i-bind) -Binds *udpsocket* to *host*:*port*. - - u1 = UDPSocket.new - u1.bind("127.0.0.1", 4913) - u1.send "message-to-self", 0, "127.0.0.1", 4913 - p u1.recvfrom(10) #=> ["message-to", ["AF_INET", 4913, "localhost", "127.0.0.1"]] - -**@overload** [] - -## connect(host, port) [](#method-i-connect) -Connects *udpsocket* to *host*:*port*. - -This makes possible to send without destination address. - - u1 = UDPSocket.new - u1.bind("127.0.0.1", 4913) - u2 = UDPSocket.new - u2.connect("127.0.0.1", 4913) - u2.send "uuuu", 0 - p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]] - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a new UDPSocket object. - -*address_family* should be an integer, a string or a symbol: Socket::AF_INET, -"AF_INET", :INET, etc. - - require 'socket' - - UDPSocket.new #=> # - UDPSocket.new(Socket::AF_INET6) #=> # - -**@overload** [] - -## recvfrom_nonblock(len, flag0, outbufnil, exception:true) [](#method-i-recvfrom_nonblock) -call-seq: - udpsocket.recvfrom_nonblock(maxlen [, flags[, outbuf [, options]]]) => [mesg, sender_inet_addr] - -Receives up to *maxlen* bytes from `udpsocket` using recvfrom(2) after -O_NONBLOCK is set for the underlying file descriptor. *flags* is zero or more -of the `MSG_` options. The first element of the results, *mesg*, is the data -received. The second element, *sender_inet_addr*, is an array to represent the -sender address. - -When recvfrom(2) returns 0, Socket#recv_nonblock returns nil. In most cases it -means the connection was closed, but it may also mean an empty packet was -received, as the underlying API makes it impossible to distinguish these two -cases. - -### Parameters -* `maxlen` - the number of bytes to receive from the socket -* `flags` - zero or more of the `MSG_` options -* `outbuf` - destination String buffer -* `options` - keyword hash, supporting `exception: false` - -### Example - require 'socket' s1 = UDPSocket.new s1.bind("127.0.0.1", 0) s2 = -UDPSocket.new s2.bind("127.0.0.1", 0) s2.connect(*s1.addr.values_at(3,1)) - s1.connect(*s2.addr.values_at(3,1)) s1.send "aaa", 0 begin # emulate -blocking recvfrom p s2.recvfrom_nonblock(10) #=> ["aaa", ["AF_INET", -33302, "localhost.localdomain", "127.0.0.1"]] rescue IO::WaitReadable -[IO.select(](s2)) retry end - -Refer to Socket#recvfrom for the exceptions that may be thrown if the call to -*recvfrom_nonblock* fails. - -UDPSocket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) -failure, including Errno::EWOULDBLOCK. - -If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, it is extended by -IO::WaitReadable. So IO::WaitReadable can be used to rescue the exceptions for -retrying recvfrom_nonblock. - -By specifying a keyword argument *exception* to `false`, you can indicate that -recvfrom_nonblock should not raise an IO::WaitReadable exception, but return -the symbol `:wait_readable` instead. - -### See -* Socket#recvfrom - -## send(*args) [](#method-i-send) -Sends *mesg* via *udpsocket*. - -*flags* should be a bitwise OR of Socket::MSG_* constants. - - u1 = UDPSocket.new - u1.bind("127.0.0.1", 4913) - - u2 = UDPSocket.new - u2.send "hi", 0, "127.0.0.1", 4913 - - mesg, addr = u1.recvfrom(10) - u1.send mesg, 0, addr[3], addr[1] - - p u2.recv(100) #=> "hi" - -**@overload** [] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/UN.md b/example/ruby/UN.md deleted file mode 100644 index 78c0976..0000000 --- a/example/ruby/UN.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: UN - - -:nodoc: - - -# Class Methods -## help(argv , output: $stdout) [](#method-c-help) - diff --git a/example/ruby/UNIXServer.md b/example/ruby/UNIXServer.md deleted file mode 100644 index 2950a7b..0000000 --- a/example/ruby/UNIXServer.md +++ /dev/null @@ -1,151 +0,0 @@ -# Class: UNIXServer -**Inherits:** UNIXSocket - - -UNIXServer represents a UNIX domain stream server socket. - - - -#Instance Methods -## accept() [](#method-i-accept) -Accepts an incoming connection. It returns a new UNIXSocket object. - - UNIXServer.open("/tmp/sock") {|serv| - UNIXSocket.open("/tmp/sock") {|c| - s = serv.accept - s.puts "hi" - s.close - p c.read #=> "hi\n" - } - } - -**@overload** [] - -## accept_nonblock(exception:true) [](#method-i-accept_nonblock) -call-seq: - unixserver.accept_nonblock([options]) => unixsocket - -Accepts an incoming connection using accept(2) after O_NONBLOCK is set for the -underlying file descriptor. It returns an accepted UNIXSocket for the incoming -connection. - -### Example - require 'socket' serv = UNIXServer.new("/tmp/sock") begin # emulate -blocking accept sock = serv.accept_nonblock rescue IO::WaitReadable, -Errno::EINTR [IO.select(](serv)) retry end # sock is an accepted -socket. - -Refer to Socket#accept for the exceptions that may be thrown if the call to -UNIXServer#accept_nonblock fails. - -UNIXServer#accept_nonblock may raise any error corresponding to accept(2) -failure, including Errno::EWOULDBLOCK. - -If the exception is Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::ECONNABORTED or -Errno::EPROTO, it is extended by IO::WaitReadable. So IO::WaitReadable can be -used to rescue the exceptions for retrying accept_nonblock. - -By specifying a keyword argument *exception* to `false`, you can indicate that -accept_nonblock should not raise an IO::WaitReadable exception, but return the -symbol `:wait_readable` instead. - -### See -* UNIXServer#accept -* Socket#accept - -## initialize(path) [](#method-i-initialize) -Creates a new UNIX server socket bound to *path*. - - require 'socket' - - serv = UNIXServer.new("/tmp/sock") - s = serv.accept - p s.read - -**@overload** [] - -## listen(log) [](#method-i-listen) -Listens for connections, using the specified `int` as the backlog. A call to -*listen* only applies if the `socket` is of type SOCK_STREAM or -SOCK_SEQPACKET. - -### Parameter -* `backlog` - the maximum length of the queue for pending connections. - -### Example 1 - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) - socket.bind( sockaddr ) - socket.listen( 5 ) - -### Example 2 (listening on an arbitrary port, unix-based systems only): - require 'socket' - include Socket::Constants - socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) - socket.listen( 1 ) - -### Unix-based Exceptions -On unix based systems the above will work because a new `sockaddr` struct is -created on the address ADDR_ANY, for an arbitrary port number as handed off by -the kernel. It will not work on Windows, because Windows requires that the -`socket` is bound by calling *bind* before it can *listen*. - -If the *backlog* amount exceeds the implementation-dependent maximum queue -length, the implementation's maximum queue length will be used. - -On unix-based based systems the following system exceptions may be raised if -the call to *listen* fails: -* Errno::EBADF - the *socket* argument is not a valid file descriptor -* Errno::EDESTADDRREQ - the *socket* is not bound to a local address, and - the protocol does not support listening on an unbound socket -* Errno::EINVAL - the *socket* is already connected -* Errno::ENOTSOCK - the *socket* argument does not refer to a socket -* Errno::EOPNOTSUPP - the *socket* protocol does not support listen -* Errno::EACCES - the calling process does not have appropriate privileges -* Errno::EINVAL - the *socket* has been shut down -* Errno::ENOBUFS - insufficient resources are available in the system to - complete the call - -### Windows Exceptions -On Windows systems the following system exceptions may be raised if the call -to *listen* fails: -* Errno::ENETDOWN - the network is down -* Errno::EADDRINUSE - the socket's local address is already in use. This - usually occurs during the execution of *bind* but could be delayed if the - call to *bind* was to a partially wildcard address (involving ADDR_ANY) - and if a specific address needs to be committed at the time of the call to - *listen* -* Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the - service provider is still processing a callback function -* Errno::EINVAL - the `socket` has not been bound with a call to *bind*. -* Errno::EISCONN - the `socket` is already connected -* Errno::EMFILE - no more socket descriptors are available -* Errno::ENOBUFS - no buffer space is available -* Errno::ENOTSOC - `socket` is not a socket -* Errno::EOPNOTSUPP - the referenced `socket` is not a type that supports - the *listen* method - -### See -* listen manual pages on unix-based systems -* listen function in Microsoft's Winsock functions reference - -**@overload** [] - -## sysaccept() [](#method-i-sysaccept) -Accepts a new connection. It returns the new file descriptor which is an -integer. - - UNIXServer.open("/tmp/sock") {|serv| - UNIXSocket.open("/tmp/sock") {|c| - fd = serv.sysaccept - s = IO.new(fd) - s.puts "hi" - s.close - p c.read #=> "hi\n" - } - } - -**@overload** [] - diff --git a/example/ruby/UNIXSocket.md b/example/ruby/UNIXSocket.md deleted file mode 100644 index 7d69a79..0000000 --- a/example/ruby/UNIXSocket.md +++ /dev/null @@ -1,147 +0,0 @@ -# Class: UNIXSocket -**Inherits:** BasicSocket - - -UNIXSocket represents a UNIX domain stream client socket. - - -# Class Methods -## pair(*args ) [](#method-c-pair) -Creates a pair of sockets connected to each other. - -*type* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. - -*protocol* should be a protocol defined in the domain. 0 is default protocol -for the domain. - - s1, s2 = UNIXSocket.pair - s1.send "a", 0 - s1.send "b", 0 - p s2.recv(10) #=> "ab" -**@overload** [] - -**@overload** [] - -## socketpair(*args ) [](#method-c-socketpair) -Creates a pair of sockets connected to each other. - -*type* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. - -*protocol* should be a protocol defined in the domain. 0 is default protocol -for the domain. - - s1, s2 = UNIXSocket.pair - s1.send "a", 0 - s1.send "b", 0 - p s2.recv(10) #=> "ab" -**@overload** [] - -**@overload** [] - - -#Instance Methods -## addr() [](#method-i-addr) -Returns the local address as an array which contains address_family and -unix_path. - -Example - serv = UNIXServer.new("/tmp/sock") - p serv.addr #=> ["AF_UNIX", "/tmp/sock"] - -**@overload** [] - -## initialize(path) [](#method-i-initialize) -Creates a new UNIX client socket connected to *path*. - - require 'socket' - - s = UNIXSocket.new("/tmp/sock") - s.send "hello", 0 - -**@overload** [] - -## path() [](#method-i-path) -Returns the path of the local address of unixsocket. - - s = UNIXServer.new("/tmp/sock") - p s.path #=> "/tmp/sock" - -**@overload** [] - -## peeraddr() [](#method-i-peeraddr) -Returns the remote address as an array which contains address_family and -unix_path. - -Example - serv = UNIXServer.new("/tmp/sock") - c = UNIXSocket.new("/tmp/sock") - p c.peeraddr #=> ["AF_UNIX", "/tmp/sock"] - -**@overload** [] - -## recv_io(*args) [](#method-i-recv_io) -Example - - UNIXServer.open("/tmp/sock") {|serv| - UNIXSocket.open("/tmp/sock") {|c| - s = serv.accept - - c.send_io STDOUT - stdout = s.recv_io - - p STDOUT.fileno #=> 1 - p stdout.fileno #=> 7 - - stdout.puts "hello" # outputs "hello\n" to standard output. - } - } - -*klass* will determine the class of *io* returned (using the IO.for_fd -singleton method or similar). If *klass* is `nil`, an integer file descriptor -is returned. - -*mode* is the same as the argument passed to IO.for_fd - -**@overload** [] - -## recvfrom(*args) [](#method-i-recvfrom) -Receives a message via *unixsocket*. - -*maxlen* is the maximum number of bytes to receive. - -*flags* should be a bitwise OR of Socket::MSG_* constants. - -*outbuf* will contain only the received data after the method call even if it -is not empty at the beginning. - - s1 = Socket.new(:UNIX, :DGRAM, 0) - s1_ai = Addrinfo.unix("/tmp/sock1") - s1.bind(s1_ai) - - s2 = Socket.new(:UNIX, :DGRAM, 0) - s2_ai = Addrinfo.unix("/tmp/sock2") - s2.bind(s2_ai) - s3 = UNIXSocket.for_fd(s2.fileno) - - s1.send "a", 0, s2_ai - p s3.recvfrom(10) #=> ["a", ["AF_UNIX", "/tmp/sock1"]] - -**@overload** [] - -## send_io(val) [](#method-i-send_io) -Sends *io* as file descriptor passing. - - s1, s2 = UNIXSocket.pair - - s1.send_io STDOUT - stdout = s2.recv_io - - p STDOUT.fileno #=> 1 - p stdout.fileno #=> 6 - - stdout.puts "hello" # outputs "hello\n" to standard output. - -*io* may be any kind of IO object or integer file descriptor. - -**@overload** [] - diff --git a/example/ruby/URI.md b/example/ruby/URI.md deleted file mode 100644 index 115deaf..0000000 --- a/example/ruby/URI.md +++ /dev/null @@ -1,381 +0,0 @@ -# Module: URI - - --- -# uri/common.rb - -Author -: Akira Yamada - -License -: You can redistribute it and/or modify it under the same term as Ruby. - - -See URI for general documentation - - -# Class Methods -## const_missing(const ) [](#method-c-const_missing) -## decode_uri_component(str , enc Encoding::UTF_8) [](#method-c-decode_uri_component) -Like URI.decode_www_form_component, except that `'+'` is preserved. -## decode_www_form(str , enc Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false) [](#method-c-decode_www_form) -Returns name/value pairs derived from the given string `str`, which must be an -ASCII string. - -The method may be used to decode the body of Net::HTTPResponse object `res` -for which `res['Content-Type']` is `'application/x-www-form-urlencoded'`. - -The returned data is an array of 2-element subarrays; each subarray is a -name/value pair (both are strings). Each returned string has encoding `enc`, -and has had invalid characters removed via -[String#scrub](rdoc-ref:String#scrub). - -A simple example: - - URI.decode_www_form('foo=0&bar=1&baz') - # => [["foo", "0"], ["bar", "1"], ["baz", ""]] - -The returned strings have certain conversions, similar to those performed in -URI.decode_www_form_component: - - URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40') - # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]] - -The given string may contain consecutive separators: - - URI.decode_www_form('foo=0&&bar=1&&baz=2') - # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]] - -A different separator may be specified: - - URI.decode_www_form('foo=0--bar=1--baz', separator: '--') - # => [["foo", "0"], ["bar", "1"], ["baz", ""]] -**@raise** [ArgumentError] - -## decode_www_form_component(str , enc Encoding::UTF_8) [](#method-c-decode_www_form_component) -Returns a string decoded from the given URL-encoded string `str`. - -The given string is first encoded as Encoding::ASCII-8BIT (using String#b), -then decoded (as below), and finally force-encoded to the given encoding -`enc`. - -The returned string: - -* Preserves: - - * Characters `'*'`, `'.'`, `'-'`, and `'_'`. - * Character in ranges `'a'..'z'`, `'A'..'Z'`, and `'0'..'9'`. - - Example: - - URI.decode_www_form_component('*.-_azAZ09') - # => "*.-_azAZ09" - -* Converts: - - * Character `'+'` to character `' '`. - * Each "percent notation" to an ASCII character. - - Example: - - URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A') - # => "Here are some punctuation characters: ,;?:" - -Related: URI.decode_uri_component (preserves `'+'`). -## encode_uri_component(str , enc nil) [](#method-c-encode_uri_component) -Like URI.encode_www_form_component, except that `' '` (space) is encoded as -`'%20'` (instead of `'+'`). -## encode_www_form(enum , enc nil) [](#method-c-encode_www_form) -Returns a URL-encoded string derived from the given -[Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) `enum`. - -The result is suitable for use as form data for an HTTP request whose -`Content-Type` is `'application/x-www-form-urlencoded'`. - -The returned string consists of the elements of `enum`, each converted to one -or more URL-encoded strings, and all joined with character `'&'`. - -Simple examples: - - URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]]) - # => "foo=0&bar=1&baz=2" - URI.encode_www_form({foo: 0, bar: 1, baz: 2}) - # => "foo=0&bar=1&baz=2" - -The returned string is formed using method URI.encode_www_form_component, -which converts certain characters: - - URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@') - # => "f%23o=%2F&b-r=%24&b+z=%40" - -When `enum` is Array-like, each element `ele` is converted to a field: - -* If `ele` is an array of two or more elements, the field is formed from its - first two elements (and any additional elements are ignored): - - name = URI.encode_www_form_component(ele[0], enc) - value = URI.encode_www_form_component(ele[1], enc) - "#{name}=#{value}" - - Examples: - - URI.encode_www_form([%w[foo bar], %w[baz bat bah]]) - # => "foo=bar&baz=bat" - URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']]) - # => "foo=0&bar=baz" - -* If `ele` is an array of one element, the field is formed from `ele[0]`: - - URI.encode_www_form_component(ele[0]) - - Example: - - URI.encode_www_form([['foo'], [:bar], [0]]) - # => "foo&bar&0" - -* Otherwise the field is formed from `ele`: - - URI.encode_www_form_component(ele) - - Example: - - URI.encode_www_form(['foo', :bar, 0]) - # => "foo&bar&0" - -The elements of an Array-like `enum` may be mixture: - - URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat]) - # => "foo=0&bar=1&baz&bat" - -When `enum` is Hash-like, each `key`/`value` pair is converted to one or more -fields: - -* If `value` is - [Array-convertible](rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Ob - jects), each element `ele` in `value` is paired with `key` to form a - field: - - name = URI.encode_www_form_component(key, enc) - value = URI.encode_www_form_component(ele, enc) - "#{name}=#{value}" - - Example: - - URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]}) - # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2" - -* Otherwise, `key` and `value` are paired to form a field: - - name = URI.encode_www_form_component(key, enc) - value = URI.encode_www_form_component(value, enc) - "#{name}=#{value}" - - Example: - - URI.encode_www_form({foo: 0, bar: 1, baz: 2}) - # => "foo=0&bar=1&baz=2" - -The elements of a Hash-like `enum` may be mixture: - - URI.encode_www_form({foo: [0, 1], bar: 2}) - # => "foo=0&foo=1&bar=2" -## encode_www_form_component(str , enc nil) [](#method-c-encode_www_form_component) -Returns a URL-encoded string derived from the given string `str`. - -The returned string: - -* Preserves: - - * Characters `'*'`, `'.'`, `'-'`, and `'_'`. - * Character in ranges `'a'..'z'`, `'A'..'Z'`, and `'0'..'9'`. - - Example: - - URI.encode_www_form_component('*.-_azAZ09') - # => "*.-_azAZ09" - -* Converts: - - * Character `' '` to character `'+'`. - * Any other character to "percent notation"; the percent notation for - character *c* is `'%%%X' % c.ord`. - - Example: - - URI.encode_www_form_component('Here are some punctuation characters: ,;?:') - # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A" - -Encoding: - -* If `str` has encoding Encoding::ASCII_8BIT, argument `enc` is ignored. -* Otherwise `str` is converted first to Encoding::UTF_8 (with suitable - character replacements), and then to encoding `enc`. - -In either case, the returned string has forced encoding Encoding::US_ASCII. - -Related: URI.encode_uri_component (encodes `' '` as `'%20'`). -## extract(str , schemes nil, &block ) [](#method-c-extract) -## Synopsis - - URI::extract(str[, schemes][,&blk]) - -## Args - -`str` -: String to extract URIs from. - -`schemes` -: Limit URI matching to specific schemes. - - -## Description - -Extracts URIs from a string. If block given, iterates through all matched -URIs. Returns nil if block given or array with matches. - -## Usage - - require "uri" - - URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") - # => ["http://foo.example.com/bla", "mailto:test@example.com"] -## for(scheme , *arguments , default: Generic) [](#method-c-for) -Returns a new object constructed from the given `scheme`, `arguments`, and -`default`: - -* The new object is an instance of `URI.scheme_list[scheme.upcase]`. -* The object is initialized by calling the class initializer using `scheme` - and `arguments`. See URI::Generic.new. - -Examples: - - values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top'] - URI.for('https', *values) - # => # - URI.for('foo', *values, default: URI::HTTP) - # => # -## join(*str ) [](#method-c-join) -Merges the given URI strings `str` per [RFC -2396](https://www.rfc-editor.org/rfc/rfc2396.html). - -Each string in `str` is converted to an [RFC3986 -URI](https://www.rfc-editor.org/rfc/rfc3986.html) before being merged. - -Examples: - - URI.join("http://example.com/","main.rbx") - # => # - - URI.join('http://example.com', 'foo') - # => # - - URI.join('http://example.com', '/foo', '/bar') - # => # - - URI.join('http://example.com', '/foo', 'bar') - # => # - - URI.join('http://example.com', '/foo/', 'bar') - # => # -## open(name , *rest , &block ) [](#method-c-open) -Allows the opening of various resources including URIs. - -If the first argument responds to the 'open' method, 'open' is called on it -with the rest of the arguments. - -If the first argument is a string that begins with `(protocol)://`, it is -parsed by URI.parse. If the parsed object responds to the 'open' method, -'open' is called on it with the rest of the arguments. - -Otherwise, Kernel#open is called. - -OpenURI::OpenRead#open provides URI::HTTP#open, URI::HTTPS#open and -URI::FTP#open, Kernel#open. - -We can accept URIs and strings that begin with http://, https:// and ftp://. -In these cases, the opened file object is extended by OpenURI::Meta. -## parse(uri ) [](#method-c-parse) -Returns a new URI object constructed from the given string `uri`: - - URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - # => # - URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - # => # - -It's recommended to first ::escape string `uri` if it may contain invalid URI -characters. -## parser=(parser RFC3986_PARSER) [](#method-c-parser=) -## regexp(schemes nil) [](#method-c-regexp) -## Synopsis - - URI::regexp([match_schemes]) - -## Args - -`match_schemes` -: Array of schemes. If given, resulting regexp matches to URIs whose scheme - is one of the match_schemes. - - -## Description - -Returns a Regexp object which matches to URI-like strings. The Regexp object -returned by this method includes arbitrary number of capture group -(parentheses). Never rely on its number. - -## Usage - - require 'uri' - - # extract first URI from html_string - html_string.slice(URI.regexp) - - # remove ftp URIs - html_string.sub(URI.regexp(['ftp']), '') - - # You should not rely on the number of parentheses - html_string.scan(URI.regexp) do |*matches| - p $& - end -## register_scheme(scheme , klass ) [](#method-c-register_scheme) -Registers the given `klass` as the class to be instantiated when parsing a URI -with the given `scheme`: - - URI.register_scheme('MS_SEARCH', URI::Generic) # => URI::Generic - URI.scheme_list['MS_SEARCH'] # => URI::Generic - -Note that after calling String#upcase on `scheme`, it must be a valid constant -name. -## scheme_list() [](#method-c-scheme_list) -Returns a hash of the defined schemes: - - URI.scheme_list - # => - {"MAILTO"=>URI::MailTo, - "LDAPS"=>URI::LDAPS, - "WS"=>URI::WS, - "HTTP"=>URI::HTTP, - "HTTPS"=>URI::HTTPS, - "LDAP"=>URI::LDAP, - "FILE"=>URI::File, - "FTP"=>URI::FTP} - -Related: URI.register_scheme. -## split(uri ) [](#method-c-split) -Returns a 9-element array representing the parts of the URI formed from the -string `uri`; each array element is a string or `nil`: - - names = %w[scheme userinfo host port registry path opaque query fragment] - values = URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') - names.zip(values) - # => - [["scheme", "https"], - ["userinfo", "john.doe"], - ["host", "www.example.com"], - ["port", "123"], - ["registry", nil], - ["path", "/forum/questions/"], - ["opaque", nil], - ["query", "tag=networking&order=newest"], - ["fragment", "top"]] - diff --git a/example/ruby/URI/BadURIError.md b/example/ruby/URI/BadURIError.md deleted file mode 100644 index 4a43423..0000000 --- a/example/ruby/URI/BadURIError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: URI::BadURIError -**Inherits:** URI::Error - - -URI is valid, bad usage is not. - - - diff --git a/example/ruby/URI/Error.md b/example/ruby/URI/Error.md deleted file mode 100644 index 1b34adb..0000000 --- a/example/ruby/URI/Error.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: URI::Error -**Inherits:** StandardError - - -Base class for all URI exceptions. - - - diff --git a/example/ruby/URI/FTP.md b/example/ruby/URI/FTP.md deleted file mode 100644 index 100448e..0000000 --- a/example/ruby/URI/FTP.md +++ /dev/null @@ -1,323 +0,0 @@ -# Class: URI::FTP -**Inherits:** URI::Generic - -**Includes:** OpenURI::OpenRead - - -FTP URI syntax is defined by RFC1738 section 3.2. - -This class will be redesigned because of difference of implementations; the -structure of its path. draft-hoffman-ftp-uri-04 is a draft but it is a good -summary about the de facto spec. -https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04 - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new URI::FTP object from components, with syntax checking. - -The components accepted are `userinfo`, `host`, `port`, `path`, and -`typecode`. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, typecode]`. - -If the path supplied is absolute, it will be escaped in order to make it -absolute in the URI. - -Examples: - - require 'uri' - - uri1 = URI::FTP.build(['user:password', 'ftp.example.com', nil, - '/path/file.zip', 'i']) - uri1.to_s # => "ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i" - - uri2 = URI::FTP.build({:host => 'ftp.example.com', - :path => 'ruby/src'}) - uri2.to_s # => "ftp://ftp.example.com/ruby/src" -## new2(user , password , host , port , path , typecode nil, arg_check true) [](#method-c-new2) -# Attributes -## typecode[RW] [](#attribute-i-typecode) -typecode accessor. - -See URI::FTP::COMPONENT. - - -#Instance Methods -## buffer_open(buf, proxy, options) [](#method-i-buffer_open) -:nodoc: - -## initialize(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parsernil, arg_checkfalse) [](#method-i-initialize) -## Description - -Creates a new URI::FTP object from generic URL components with no syntax -checking. - -Unlike build(), this method does not escape the path component as required by -RFC1738; instead it is treated as per RFC2396. - -Arguments are `scheme`, `userinfo`, `host`, `port`, `registry`, `path`, -`opaque`, `query`, and `fragment`, in that order. - -**@raise** [InvalidURIError] - -**@return** [FTP] a new instance of FTP - -## merge(oth) [](#method-i-merge) -:nodoc: - -## open(*rest, &block) [](#method-i-open) -OpenURI::OpenRead#open provides `open' for URI::HTTP and URI::FTP. - -OpenURI::OpenRead#open takes optional 3 arguments as: - - OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }] - -OpenURI::OpenRead#open returns an IO-like object if block is not given. -Otherwise it yields the IO object and return the value of the block. The IO -object is extended with OpenURI::Meta. - -`mode` and `perm` are the same as Kernel#open. - -However, `mode` must be read mode because OpenURI::OpenRead#open doesn't -support write mode (yet). Also `perm` is ignored because it is meaningful only -for file creation. - -`options` must be a hash. - -Each option with a string key specifies an extra header field for HTTP. I.e., -it is ignored for FTP without HTTP proxy. - -The hash may include other options, where keys are symbols: - -:proxy -: Synopsis: - :proxy => "http://proxy.foo.com:8000/" - :proxy => URI.parse("http://proxy.foo.com:8000/") - :proxy => true - :proxy => false - :proxy => nil - - If :proxy option is specified, the value should be String, URI, boolean or - nil. - - When String or URI is given, it is treated as proxy URI. - - When true is given or the option itself is not specified, environment - variable `scheme_proxy' is examined. `scheme' is replaced by `http', - `https' or `ftp'. - - When false or nil is given, the environment variables are ignored and - connection will be made to a server directly. - - -:proxy_http_basic_authentication -: Synopsis: - :proxy_http_basic_authentication => - ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"] - :proxy_http_basic_authentication => - [URI.parse("http://proxy.foo.com:8000/"), - "proxy-user", "proxy-password"] - - If :proxy option is specified, the value should be an Array with 3 - elements. It should contain a proxy URI, a proxy user name and a proxy - password. The proxy URI should be a String, an URI or nil. The proxy - user name and password should be a String. - - If nil is given for the proxy URI, this option is just ignored. - - If :proxy and :proxy_http_basic_authentication is specified, ArgumentError - is raised. - - -:http_basic_authentication -: Synopsis: - :http_basic_authentication=>[user, password] - - If :http_basic_authentication is specified, the value should be an array - which contains 2 strings: username and password. It is used for HTTP Basic - authentication defined by RFC 2617. - - -:content_length_proc -: Synopsis: - :content_length_proc => lambda {|content_length| ... } - - If :content_length_proc option is specified, the option value procedure is - called before actual transfer is started. It takes one argument, which is - expected content length in bytes. - - If two or more transfers are performed by HTTP redirection, the procedure - is called only once for the last transfer. - - When expected content length is unknown, the procedure is called with nil. - This happens when the HTTP response has no Content-Length header. - - -:progress_proc -: Synopsis: - :progress_proc => lambda {|size| ...} - - If :progress_proc option is specified, the proc is called with one - argument each time when `open' gets content fragment from network. The - argument `size` is the accumulated transferred size in bytes. - - If two or more transfer is done by HTTP redirection, the procedure is - called only one for a last transfer. - - :progress_proc and :content_length_proc are intended to be used for - progress bar. For example, it can be implemented as follows using - Ruby/ProgressBar. - - pbar = nil - open("http://...", - :content_length_proc => lambda {|t| - if t && 0 < t - pbar = ProgressBar.new("...", t) - pbar.file_transfer_mode - end - }, - :progress_proc => lambda {|s| - pbar.set s if pbar - }) {|f| ... } - - -:read_timeout -: Synopsis: - :read_timeout=>nil (no timeout) - :read_timeout=>10 (10 second) - - :read_timeout option specifies a timeout of read for http connections. - - -:open_timeout -: Synopsis: - :open_timeout=>nil (no timeout) - :open_timeout=>10 (10 second) - - :open_timeout option specifies a timeout of open for http connections. - - -:ssl_ca_cert -: Synopsis: - :ssl_ca_cert=>filename or an Array of filenames - - :ssl_ca_cert is used to specify CA certificate for SSL. If it is given, - default certificates are not used. - - -:ssl_verify_mode -: Synopsis: - :ssl_verify_mode=>mode - - :ssl_verify_mode is used to specify openssl verify mode. - - -:ssl_min_version -: Synopsis: - :ssl_min_version=>:TLS1_2 - - :ssl_min_version option specifies the minimum allowed SSL/TLS protocol - version. See also OpenSSL::SSL::SSLContext#min_version=. - - -:ssl_max_version -: Synopsis: - :ssl_max_version=>:TLS1_2 - - :ssl_max_version option specifies the maximum allowed SSL/TLS protocol - version. See also OpenSSL::SSL::SSLContext#max_version=. - - -:ftp_active_mode -: Synopsis: - :ftp_active_mode=>bool - - `:ftp_active_mode => true` is used to make ftp active mode. Ruby 1.9 uses - passive mode by default. Note that the active mode is default in Ruby 1.8 - or prior. - - -:redirect -: Synopsis: - :redirect=>bool - - `:redirect` is true by default. `:redirect => false` is used to disable - all HTTP redirects. - - OpenURI::HTTPRedirect exception raised on redirection. Using `true` also - means that redirections between http and ftp are permitted. - - -:max_redirects -: Synopsis: - :max_redirects=>int - - Number of HTTP redirects allowed before OpenURI::TooManyRedirects is - raised. The default is 64. - - -:request_specific_fields -: Synopsis: - :request_specific_fields => {} - :request_specific_fields => lambda {|url| ...} - - :request_specific_fields option allows specifying custom header fields - that are sent with the HTTP request. It can be passed as a Hash or a Proc - that gets evaluated on each request and returns a Hash of header fields. - - If a Hash is provided, it specifies the headers only for the initial - request and these headers will not be sent on redirects. - - If a Proc is provided, it will be executed for each request including - redirects, allowing dynamic header customization based on the request URL. - It is important that the Proc returns a Hash. And this Hash specifies the - headers to be sent with the request. - - For Example with Hash - URI.open("http://...", - request_specific_fields: {"Authorization" => "token dummy"}) {|f| ... } - - For Example with Proc: - URI.open("http://...", - request_specific_fields: lambda { |uri| - if uri.host == "example.com" - {"Authorization" => "token dummy"} - else - {} - end - }) {|f| ... } - - -## path() [](#method-i-path) -Returns the path from an FTP URI. - -RFC 1738 specifically states that the path for an FTP URI does not include the -/ which separates the URI path from the URI host. Example: - -`ftp://ftp.example.com/pub/ruby` - -The above URI indicates that the client should connect to ftp.example.com then -cd to pub/ruby from the initial login directory. - -If you want to cd to an absolute directory, you must include an escaped / -(%2F) in the path. Example: - -`ftp://ftp.example.com/%2Fpub/ruby` - -This method will then return "/pub/ruby". - -## read(options{}) [](#method-i-read) -OpenURI::OpenRead#read([ options ]) reads a content referenced by self and -returns the content as string. The string is extended with OpenURI::Meta. The -argument `options` is same as OpenURI::OpenRead#open. - -## to_s() [](#method-i-to_s) -Returns a String representation of the URI::FTP. - diff --git a/example/ruby/URI/File.md b/example/ruby/URI/File.md deleted file mode 100644 index 2de18e4..0000000 --- a/example/ruby/URI/File.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: URI::File -**Inherits:** URI::Generic - - -The "file" URI is defined by RFC8089. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new URI::File object from components, with syntax checking. - -The components accepted are `host` and `path`. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[host, -path]`. - -A path from e.g. the File class should be escaped before being passed. - -Examples: - - require 'uri' - - uri1 = URI::File.build(['host.example.com', '/path/file.zip']) - uri1.to_s # => "file://host.example.com/path/file.zip" - - uri2 = URI::File.build({:host => 'host.example.com', - :path => '/ruby/src'}) - uri2.to_s # => "file://host.example.com/ruby/src" - - uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')}) - uri3.to_s # => "file:///path/my%20file.txt" - -#Instance Methods -## check_password(user) [](#method-i-check_password) -raise InvalidURIError - -**@raise** [URI::InvalidURIError] - -## check_user(user) [](#method-i-check_user) -raise InvalidURIError - -**@raise** [URI::InvalidURIError] - -## check_userinfo(user) [](#method-i-check_userinfo) -raise InvalidURIError - -**@raise** [URI::InvalidURIError] - -## set_host(v) [](#method-i-set_host) -Protected setter for the host component `v`. - -See also URI::Generic.host=. - -## set_password(v) [](#method-i-set_password) -do nothing - -## set_port(v) [](#method-i-set_port) -do nothing - -## set_user(v) [](#method-i-set_user) -do nothing - -## set_userinfo(v) [](#method-i-set_userinfo) -do nothing - diff --git a/example/ruby/URI/Generic.md b/example/ruby/URI/Generic.md deleted file mode 100644 index 8a9b386..0000000 --- a/example/ruby/URI/Generic.md +++ /dev/null @@ -1,438 +0,0 @@ -# Class: URI::Generic -**Inherits:** Object - -**Includes:** URI - - -Base class for all URI classes. Implements generic URI syntax as per RFC 2396. - - -# Class Methods -## build(args ) [](#method-c-build) -## Synopsis - -See ::new. - -## Description - -Creates a new URI::Generic instance from components of URI::Generic with -check. Components are: scheme, userinfo, host, port, registry, path, opaque, -query, and fragment. You can provide arguments either by an Array or a Hash. -See ::new for hash keys to use or for order of array items. -## build2(args ) [](#method-c-build2) -## Synopsis - -See ::new. - -## Description - -At first, tries to create a new URI::Generic instance using -URI::Generic::build. But, if exception URI::InvalidComponentError is raised, -then it does URI::Escape.escape all URI components and tries again. -## component() [](#method-c-component) -Components of the URI in the order. -## default_port() [](#method-c-default_port) -Returns default port. -## use_proxy?(hostname , addr , port , no_proxy ) [](#method-c-use_proxy?) -:nodoc: -**@return** [Boolean] - -## use_registry() [](#method-c-use_registry) -:nodoc: -# Attributes -## fragment[RW] [](#attribute-i-fragment) -Returns the fragment component of the URI. - - URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies" - -## host[RW] [](#attribute-i-host) -Returns the host component of the URI. - - URI("http://foo/bar/baz").host #=> "foo" - -It returns nil if no host component exists. - - URI("mailto:foo@example.org").host #=> nil - -The component does not contain the port number. - - URI("http://foo:8080/bar/baz").host #=> "foo" - -Since IPv6 addresses are wrapped with brackets in URIs, this method returns -IPv6 addresses wrapped with brackets. This form is not appropriate to pass to -socket methods such as TCPSocket.open. If unwrapped host names are required, -use the #hostname method. - - URI("http://[::1]/bar/baz").host #=> "[::1]" - URI("http://[::1]/bar/baz").hostname #=> "::1" - -## opaque[RW] [](#attribute-i-opaque) -Returns the opaque part of the URI. - - URI("mailto:foo@example.org").opaque #=> "foo@example.org" - URI("http://foo/bar/baz").opaque #=> nil - -The portion of the path that does not make use of the slash '/'. The path -typically refers to an absolute path or an opaque part. (See RFC2396 Section 3 -and 5.2.) - -## path[RW] [](#attribute-i-path) -Returns the path component of the URI. - - URI("http://foo/bar/baz").path #=> "/bar/baz" - -## port[RW] [](#attribute-i-port) -Returns the port component of the URI. - - URI("http://foo/bar/baz").port #=> 80 - URI("http://foo:8080/bar/baz").port #=> 8080 - -## query[RW] [](#attribute-i-query) -Returns the query component of the URI. - - URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar" - -## scheme[RW] [](#attribute-i-scheme) -Returns the scheme component of the URI. - - URI("http://foo/bar/baz").scheme #=> "http" - - -#Instance Methods -## ==(oth) [](#method-i-==) -Compares two URIs. - -## absolute?() [](#method-i-absolute?) -Returns true if URI has a scheme (e.g. http:// or https://) specified. - -**@return** [Boolean] - -## coerce(oth) [](#method-i-coerce) -## Args - -`v` -: URI or String - - -## Description - -Attempts to parse other URI `oth`, returns [parsed_oth, self]. - -## Usage - - require 'uri' - - uri = URI.parse("http://my.example.com") - uri.coerce("http://foo.com") - #=> [#, #] - -## component() [](#method-i-component) -Components of the URI in the order. - -## decoded_password() [](#method-i-decoded_password) -Returns the password component after URI decoding. - -## decoded_user() [](#method-i-decoded_user) -Returns the user component after URI decoding. - -## default_port() [](#method-i-default_port) -Returns default port. - -## eql?(oth) [](#method-i-eql?) - -**@return** [Boolean] - -## find_proxy(envENV) [](#method-i-find_proxy) -Returns a proxy URI. The proxy URI is obtained from environment variables such -as http_proxy, ftp_proxy, no_proxy, etc. If there is no proper proxy, nil is -returned. - -If the optional parameter `env` is specified, it is used instead of ENV. - -Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are -examined, too. - -But http_proxy and HTTP_PROXY is treated specially under CGI environment. It's -because HTTP_PROXY may be set by Proxy: header. So HTTP_PROXY is not used. -http_proxy is not used too if the variable is case insensitive. CGI_HTTP_PROXY -can be used instead. - -**@raise** [BadURIError] - -## hash() [](#method-i-hash) - -## hierarchical?() [](#method-i-hierarchical?) -Returns true if URI is hierarchical. - -## Description - -URI has components listed in order of decreasing significance from left to -right, see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3. - -## Usage - - require 'uri' - - uri = URI.parse("http://my.example.com/") - uri.hierarchical? - #=> true - uri = URI.parse("mailto:joe@example.com") - uri.hierarchical? - #=> false - -**@return** [Boolean] - -## hostname() [](#method-i-hostname) -Extract the host part of the URI and unwrap brackets for IPv6 addresses. - -This method is the same as URI::Generic#host except brackets for IPv6 (and -future IP) addresses are removed. - - uri = URI("http://[::1]/bar") - uri.hostname #=> "::1" - uri.host #=> "[::1]" - -## hostname=(v) [](#method-i-hostname=) -Sets the host part of the URI as the argument with brackets for IPv6 -addresses. - -This method is the same as URI::Generic#host= except the argument can be a -bare IPv6 address. - - uri = URI("http://foo/bar") - uri.hostname = "::1" - uri.to_s #=> "http://[::1]/bar" - -If the argument seems to be an IPv6 address, it is wrapped with brackets. - -## initialize(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parserDEFAULT_PARSER, arg_checkfalse) [](#method-i-initialize) -## Args - -`scheme` -: Protocol scheme, i.e. 'http','ftp','mailto' and so on. - -`userinfo` -: User name and password, i.e. 'sdmitry:bla'. - -`host` -: Server host name. - -`port` -: Server port. - -`registry` -: Registry of naming authorities. - -`path` -: Path on server. - -`opaque` -: Opaque part. - -`query` -: Query data. - -`fragment` -: Part of the URI after '#' character. - -`parser` -: Parser for internal use [URI::DEFAULT_PARSER by default]. - -`arg_check` -: Check arguments [false by default]. - - -## Description - -Creates a new URI::Generic instance from ``generic'' components without check. - -**@return** [Generic] a new instance of Generic - -## inspect() [](#method-i-inspect) - -## merge(oth) [](#method-i-merge) -## Args - -`oth` -: URI or String - - -## Description - -Merges two URIs. - -## Usage - - require 'uri' - - uri = URI.parse("http://my.example.com") - uri.merge("/main.rbx?page=1") - # => "http://my.example.com/main.rbx?page=1" - -## merge!(oth) [](#method-i-merge!) -## Args - -`oth` -: URI or String - - -## Description - -Destructive form of #merge. - -## Usage - - require 'uri' - - uri = URI.parse("http://my.example.com") - uri.merge!("/main.rbx?page=1") - uri.to_s # => "http://my.example.com/main.rbx?page=1" - -## normalize() [](#method-i-normalize) -Returns normalized URI. - - require 'uri' - - URI("HTTP://my.EXAMPLE.com").normalize - #=> # - -Normalization here means: - -* scheme and host are converted to lowercase, -* an empty path component is set to "/". - -## normalize!() [](#method-i-normalize!) -Destructive version of #normalize. - -## parser() [](#method-i-parser) -Returns the parser to be used. - -Unless a URI::Parser is defined, DEFAULT_PARSER is used. - -## password() [](#method-i-password) -Returns the password component (without URI decoding). - -## password=(password) [](#method-i-password=) -## Args - -`v` -: String - - -## Description - -Public setter for the `password` component (with validation). - -See also URI::Generic.check_password. - -## Usage - - require 'uri' - - uri = URI.parse("http://john:S3nsit1ve@my.example.com") - uri.password = "V3ry_S3nsit1ve" - uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com" - -## registry() [](#method-i-registry) -:nodoc: - -## registry=(v) [](#method-i-registry=) - -**@raise** [InvalidURIError] - -## relative?() [](#method-i-relative?) -Returns true if URI does not have a scheme (e.g. http:// or https://) -specified. - -**@return** [Boolean] - -## route_from(oth) [](#method-i-route_from) -## Args - -`oth` -: URI or String - - -## Description - -Calculates relative path from oth to self. - -## Usage - - require 'uri' - - uri = URI.parse('http://my.example.com/main.rbx?page=1') - uri.route_from('http://my.example.com') - #=> # - -## route_to(oth) [](#method-i-route_to) -## Args - -`oth` -: URI or String - - -## Description - -Calculates relative path to oth from self. - -## Usage - - require 'uri' - - uri = URI.parse('http://my.example.com') - uri.route_to('http://my.example.com/main.rbx?page=1') - #=> # - -## select(*components) [](#method-i-select) -## Args - -`components` -: Multiple Symbol arguments defined in URI::HTTP. - - -## Description - -Selects specified components from URI. - -## Usage - - require 'uri' - - uri = URI.parse('http://myuser:mypass@my.example.com/test.rbx') - uri.select(:userinfo, :host, :path) - # => ["myuser:mypass", "my.example.com", "/test.rbx"] - -## to_s() [](#method-i-to_s) -Constructs String from URI. - -## user() [](#method-i-user) -Returns the user component (without URI decoding). - -## user=(user) [](#method-i-user=) -## Args - -`v` -: String - - -## Description - -Public setter for the `user` component (with validation). - -See also URI::Generic.check_user. - -## Usage - - require 'uri' - - uri = URI.parse("http://john:S3nsit1ve@my.example.com") - uri.user = "sam" - uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com" - -## userinfo() [](#method-i-userinfo) -Returns the userinfo, either as 'user' or 'user:password'. - -## userinfo=(userinfo) [](#method-i-userinfo=) -Sets userinfo, argument is string like 'name:pass'. - diff --git a/example/ruby/URI/HTTP.md b/example/ruby/URI/HTTP.md deleted file mode 100644 index 4ec5fbc..0000000 --- a/example/ruby/URI/HTTP.md +++ /dev/null @@ -1,308 +0,0 @@ -# Class: URI::HTTP -**Inherits:** URI::Generic - -**Includes:** OpenURI::OpenRead - - -The syntax of HTTP URIs is defined in RFC1738 section 3.3. - -Note that the Ruby URI library allows HTTP URLs containing usernames and -passwords. This is not legal as per the RFC, but used to be supported in -Internet Explorer 5 and 6, before the MS04-004 security update. See -. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new URI::HTTP object from components, with syntax checking. - -The components accepted are userinfo, host, port, path, query, and fragment. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, query, fragment]`. - -Example: - - uri = URI::HTTP.build(host: 'www.example.com', path: '/foo/bar') - - uri = URI::HTTP.build([nil, "www.example.com", nil, "/path", - "query", 'fragment']) - -Currently, if passed userinfo components this method generates invalid HTTP -URIs as per RFC 1738. - -#Instance Methods -## authority() [](#method-i-authority) -## Description - -Returns the authority for an HTTP uri, as defined in -https://www.rfc-editor.org/rfc/rfc3986#section-3.2. - -Example: - - URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com" - URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000" - URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com" - -## buffer_open(buf, proxy, options) [](#method-i-buffer_open) -:nodoc: - -## open(*rest, &block) [](#method-i-open) -OpenURI::OpenRead#open provides `open' for URI::HTTP and URI::FTP. - -OpenURI::OpenRead#open takes optional 3 arguments as: - - OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }] - -OpenURI::OpenRead#open returns an IO-like object if block is not given. -Otherwise it yields the IO object and return the value of the block. The IO -object is extended with OpenURI::Meta. - -`mode` and `perm` are the same as Kernel#open. - -However, `mode` must be read mode because OpenURI::OpenRead#open doesn't -support write mode (yet). Also `perm` is ignored because it is meaningful only -for file creation. - -`options` must be a hash. - -Each option with a string key specifies an extra header field for HTTP. I.e., -it is ignored for FTP without HTTP proxy. - -The hash may include other options, where keys are symbols: - -:proxy -: Synopsis: - :proxy => "http://proxy.foo.com:8000/" - :proxy => URI.parse("http://proxy.foo.com:8000/") - :proxy => true - :proxy => false - :proxy => nil - - If :proxy option is specified, the value should be String, URI, boolean or - nil. - - When String or URI is given, it is treated as proxy URI. - - When true is given or the option itself is not specified, environment - variable `scheme_proxy' is examined. `scheme' is replaced by `http', - `https' or `ftp'. - - When false or nil is given, the environment variables are ignored and - connection will be made to a server directly. - - -:proxy_http_basic_authentication -: Synopsis: - :proxy_http_basic_authentication => - ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"] - :proxy_http_basic_authentication => - [URI.parse("http://proxy.foo.com:8000/"), - "proxy-user", "proxy-password"] - - If :proxy option is specified, the value should be an Array with 3 - elements. It should contain a proxy URI, a proxy user name and a proxy - password. The proxy URI should be a String, an URI or nil. The proxy - user name and password should be a String. - - If nil is given for the proxy URI, this option is just ignored. - - If :proxy and :proxy_http_basic_authentication is specified, ArgumentError - is raised. - - -:http_basic_authentication -: Synopsis: - :http_basic_authentication=>[user, password] - - If :http_basic_authentication is specified, the value should be an array - which contains 2 strings: username and password. It is used for HTTP Basic - authentication defined by RFC 2617. - - -:content_length_proc -: Synopsis: - :content_length_proc => lambda {|content_length| ... } - - If :content_length_proc option is specified, the option value procedure is - called before actual transfer is started. It takes one argument, which is - expected content length in bytes. - - If two or more transfers are performed by HTTP redirection, the procedure - is called only once for the last transfer. - - When expected content length is unknown, the procedure is called with nil. - This happens when the HTTP response has no Content-Length header. - - -:progress_proc -: Synopsis: - :progress_proc => lambda {|size| ...} - - If :progress_proc option is specified, the proc is called with one - argument each time when `open' gets content fragment from network. The - argument `size` is the accumulated transferred size in bytes. - - If two or more transfer is done by HTTP redirection, the procedure is - called only one for a last transfer. - - :progress_proc and :content_length_proc are intended to be used for - progress bar. For example, it can be implemented as follows using - Ruby/ProgressBar. - - pbar = nil - open("http://...", - :content_length_proc => lambda {|t| - if t && 0 < t - pbar = ProgressBar.new("...", t) - pbar.file_transfer_mode - end - }, - :progress_proc => lambda {|s| - pbar.set s if pbar - }) {|f| ... } - - -:read_timeout -: Synopsis: - :read_timeout=>nil (no timeout) - :read_timeout=>10 (10 second) - - :read_timeout option specifies a timeout of read for http connections. - - -:open_timeout -: Synopsis: - :open_timeout=>nil (no timeout) - :open_timeout=>10 (10 second) - - :open_timeout option specifies a timeout of open for http connections. - - -:ssl_ca_cert -: Synopsis: - :ssl_ca_cert=>filename or an Array of filenames - - :ssl_ca_cert is used to specify CA certificate for SSL. If it is given, - default certificates are not used. - - -:ssl_verify_mode -: Synopsis: - :ssl_verify_mode=>mode - - :ssl_verify_mode is used to specify openssl verify mode. - - -:ssl_min_version -: Synopsis: - :ssl_min_version=>:TLS1_2 - - :ssl_min_version option specifies the minimum allowed SSL/TLS protocol - version. See also OpenSSL::SSL::SSLContext#min_version=. - - -:ssl_max_version -: Synopsis: - :ssl_max_version=>:TLS1_2 - - :ssl_max_version option specifies the maximum allowed SSL/TLS protocol - version. See also OpenSSL::SSL::SSLContext#max_version=. - - -:ftp_active_mode -: Synopsis: - :ftp_active_mode=>bool - - `:ftp_active_mode => true` is used to make ftp active mode. Ruby 1.9 uses - passive mode by default. Note that the active mode is default in Ruby 1.8 - or prior. - - -:redirect -: Synopsis: - :redirect=>bool - - `:redirect` is true by default. `:redirect => false` is used to disable - all HTTP redirects. - - OpenURI::HTTPRedirect exception raised on redirection. Using `true` also - means that redirections between http and ftp are permitted. - - -:max_redirects -: Synopsis: - :max_redirects=>int - - Number of HTTP redirects allowed before OpenURI::TooManyRedirects is - raised. The default is 64. - - -:request_specific_fields -: Synopsis: - :request_specific_fields => {} - :request_specific_fields => lambda {|url| ...} - - :request_specific_fields option allows specifying custom header fields - that are sent with the HTTP request. It can be passed as a Hash or a Proc - that gets evaluated on each request and returns a Hash of header fields. - - If a Hash is provided, it specifies the headers only for the initial - request and these headers will not be sent on redirects. - - If a Proc is provided, it will be executed for each request including - redirects, allowing dynamic header customization based on the request URL. - It is important that the Proc returns a Hash. And this Hash specifies the - headers to be sent with the request. - - For Example with Hash - URI.open("http://...", - request_specific_fields: {"Authorization" => "token dummy"}) {|f| ... } - - For Example with Proc: - URI.open("http://...", - request_specific_fields: lambda { |uri| - if uri.host == "example.com" - {"Authorization" => "token dummy"} - else - {} - end - }) {|f| ... } - - -## origin() [](#method-i-origin) -## Description - -Returns the origin for an HTTP uri, as defined in -https://www.rfc-editor.org/rfc/rfc6454. - -Example: - - URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com" - URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000" - URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com" - URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com" - -## read(options{}) [](#method-i-read) -OpenURI::OpenRead#read([ options ]) reads a content referenced by self and -returns the content as string. The string is extended with OpenURI::Meta. The -argument `options` is same as OpenURI::OpenRead#open. - -## request_uri() [](#method-i-request_uri) -## Description - -Returns the full path for an HTTP request, as required by Net::HTTP::Get. - -If the URI contains a query, the full path is URI#path + '?' + URI#query. -Otherwise, the path is simply URI#path. - -Example: - - uri = URI::HTTP.build(path: '/foo/bar', query: 'test=true') - uri.request_uri # => "/foo/bar?test=true" - diff --git a/example/ruby/URI/HTTPS.md b/example/ruby/URI/HTTPS.md deleted file mode 100644 index 1f8d7fa..0000000 --- a/example/ruby/URI/HTTPS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: URI::HTTPS -**Inherits:** URI::HTTP - - -The default port for HTTPS URIs is 443, and the scheme is 'https:' rather than -'http:'. Other than that, HTTPS URIs are identical to HTTP URIs; see -URI::HTTP. - - - diff --git a/example/ruby/URI/InvalidComponentError.md b/example/ruby/URI/InvalidComponentError.md deleted file mode 100644 index e4de9d6..0000000 --- a/example/ruby/URI/InvalidComponentError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: URI::InvalidComponentError -**Inherits:** URI::Error - - -Not a URI component. - - - diff --git a/example/ruby/URI/InvalidURIError.md b/example/ruby/URI/InvalidURIError.md deleted file mode 100644 index 6aecb9e..0000000 --- a/example/ruby/URI/InvalidURIError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: URI::InvalidURIError -**Inherits:** URI::Error - - -Not a URI. - - - diff --git a/example/ruby/URI/LDAP.md b/example/ruby/URI/LDAP.md deleted file mode 100644 index 533c9b5..0000000 --- a/example/ruby/URI/LDAP.md +++ /dev/null @@ -1,85 +0,0 @@ -# Class: URI::LDAP -**Inherits:** URI::Generic - - -LDAP URI SCHEMA (described in RFC2255). -- -[ldap:///[?[?[?](?)]]] ++ - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new URI::LDAP object from components, with syntax checking. - -The components accepted are host, port, dn, attributes, scope, filter, and -extensions. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[host, port, -dn, attributes, scope, filter, extensions]`. - -Example: - - uri = URI::LDAP.build({:host => 'ldap.example.com', - :dn => '/dc=example'}) - - uri = URI::LDAP.build(["ldap.example.com", nil, - "/dc=example;dc=com", "query", nil, nil, nil]) - -#Instance Methods -## attributes() [](#method-i-attributes) -Returns attributes. - -## attributes=(val) [](#method-i-attributes=) -Setter for attributes `val`. - -## dn() [](#method-i-dn) -Returns dn. - -## dn=(val) [](#method-i-dn=) -Setter for dn `val`. - -## extensions() [](#method-i-extensions) -Returns extensions. - -## extensions=(val) [](#method-i-extensions=) -Setter for extensions `val`. - -## filter() [](#method-i-filter) -Returns filter. - -## filter=(val) [](#method-i-filter=) -Setter for filter `val`. - -## hierarchical?() [](#method-i-hierarchical?) -Checks if URI has a path. For URI::LDAP this will return `false`. - -**@return** [Boolean] - -## initialize(*arg) [](#method-i-initialize) -## Description - -Creates a new URI::LDAP object from generic URI components as per RFC 2396. No -LDAP-specific syntax checking is performed. - -Arguments are `scheme`, `userinfo`, `host`, `port`, `registry`, `path`, -`opaque`, `query`, and `fragment`, in that order. - -Example: - - uri = URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil, - "/dc=example;dc=com", nil, "query", nil) - -See also URI::Generic.new. - -**@return** [LDAP] a new instance of LDAP - -## scope() [](#method-i-scope) -Returns scope. - -## scope=(val) [](#method-i-scope=) -Setter for scope `val`. - diff --git a/example/ruby/URI/LDAPS.md b/example/ruby/URI/LDAPS.md deleted file mode 100644 index b1f908a..0000000 --- a/example/ruby/URI/LDAPS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: URI::LDAPS -**Inherits:** URI::LDAP - - -The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather than -'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs; see -URI::LDAP. - - - diff --git a/example/ruby/URI/MailTo.md b/example/ruby/URI/MailTo.md deleted file mode 100644 index 7ca1154..0000000 --- a/example/ruby/URI/MailTo.md +++ /dev/null @@ -1,70 +0,0 @@ -# Class: URI::MailTo -**Inherits:** URI::Generic - -**Includes:** URI::RFC2396_REGEXP - - -RFC6068, the mailto URL scheme. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new URI::MailTo object from components, with syntax checking. - -Components can be provided as an Array or Hash. If an Array is used, the -components must be supplied as `[to, headers]`. - -If a Hash is used, the keys are the component names preceded by colons. - -The headers can be supplied as a pre-encoded string, such as -`"subject=subscribe&cc=address"`, or as an Array of Arrays like `[['subject', -'subscribe'], ['cc', 'address']]`. - -Examples: - - require 'uri' - - m1 = URI::MailTo.build(['joe@example.com', 'subject=Ruby']) - m1.to_s # => "mailto:joe@example.com?subject=Ruby" - - m2 = URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]]) - m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com" - - m3 = URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]}) - m3.to_s # => "mailto:listman@example.com?subject=subscribe" -# Attributes -## headers[RW] [](#attribute-i-headers) -E-mail headers set by the URL, as an Array of Arrays. - -## to[RW] [](#attribute-i-to) -The primary e-mail address of the URL, as a String. - - -#Instance Methods -## initialize(*arg) [](#method-i-initialize) -## Description - -Creates a new URI::MailTo object from generic URL components with no syntax -checking. - -This method is usually called from URI::parse, which checks the validity of -each component. - -**@return** [MailTo] a new instance of MailTo - -## to_mailtext() [](#method-i-to_mailtext) -Returns the RFC822 e-mail text equivalent of the URL, as a String. - -Example: - - require 'uri' - - uri = URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr") - uri.to_mailtext - # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n" - -## to_s() [](#method-i-to_s) -Constructs String from URI. - diff --git a/example/ruby/URI/RFC2396_Parser.md b/example/ruby/URI/RFC2396_Parser.md deleted file mode 100644 index 1c9cf95..0000000 --- a/example/ruby/URI/RFC2396_Parser.md +++ /dev/null @@ -1,154 +0,0 @@ -# Class: URI::RFC2396_Parser -**Inherits:** Object - -**Includes:** URI::RFC2396_REGEXP - - -Class that parses String's into URI's. - -It contains a Hash set of patterns and Regexp's that match and validate. - - -# Attributes -## pattern[RW] [](#attribute-i-pattern) -The Hash of patterns. - -See also URI::Parser.initialize_pattern. - -## regexp[RW] [](#attribute-i-regexp) -The Hash of Regexp. - -See also URI::Parser.initialize_regexp. - - -#Instance Methods -## escape(str, unsafe) [](#method-i-escape) -:call-seq: - escape( str ) - escape( str, unsafe ) - -## Args - -`str` -: String to make safe - -`unsafe` -: Regexp to apply. Defaults to `self.regexp[:UNSAFE]` - - -## Description - -Constructs a safe String from `str`, removing unsafe characters, replacing -them with codes. - -## extract(str, schemesnil) [](#method-i-extract) -:call-seq: - extract( str ) - extract( str, schemes ) - extract( str, schemes ) {|item| block } - -## Args - -`str` -: String to search - -`schemes` -: Patterns to apply to `str` - - -## Description - -Attempts to parse and merge a set of URIs. If no `block` given, then returns -the result, else it calls `block` for each element in result. - -See also URI::Parser.make_regexp. - -## initialize(opts{}) [](#method-i-initialize) -## Synopsis - - URI::Parser.new([opts]) - -## Args - -The constructor accepts a hash as options for parser. Keys of options are -pattern names of URI components and values of options are pattern strings. The -constructor generates set of regexps for parsing URIs. - -You can use the following keys: - - * :ESCAPED (URI::PATTERN::ESCAPED in default) - * :UNRESERVED (URI::PATTERN::UNRESERVED in default) - * :DOMLABEL (URI::PATTERN::DOMLABEL in default) - * :TOPLABEL (URI::PATTERN::TOPLABEL in default) - * :HOSTNAME (URI::PATTERN::HOSTNAME in default) - -## Examples - - p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})") - u = p.parse("http://example.jp/%uABCD") #=> # - URI.parse(u.to_s) #=> raises URI::InvalidURIError - - s = "http://example.com/ABCD" - u1 = p.parse(s) #=> # - u2 = URI.parse(s) #=> # - u1 == u2 #=> true - u1.eql?(u2) #=> false - -**@return** [RFC2396_Parser] a new instance of RFC2396_Parser - -## inspect() [](#method-i-inspect) - -## join(*uris) [](#method-i-join) -## Args - -`uris` -: an Array of Strings - - -## Description - -Attempts to parse and merge a set of URIs. - -## make_regexp(schemesnil) [](#method-i-make_regexp) -Returns Regexp that is default `self.regexp[:ABS_URI_REF]`, unless `schemes` -is provided. Then it is a Regexp.union with `self.pattern[:X_ABS_URI]`. - -## parse(uri) [](#method-i-parse) -## Args - -`uri` -: String - - -## Description - -Parses `uri` and constructs either matching URI scheme object (File, FTP, -HTTP, HTTPS, LDAP, LDAPS, or MailTo) or URI::Generic. - -## Usage - - p = URI::Parser.new - p.parse("ldap://ldap.example.com/dc=example?user=john") - #=> # - -## split(uri) [](#method-i-split) -Returns a split URI against `regexp[:ABS_URI]`. - -## unescape(str, escaped) [](#method-i-unescape) -:call-seq: - unescape( str ) - unescape( str, escaped ) - -## Args - -`str` -: String to remove escapes from - -`escaped` -: Regexp to apply. Defaults to `self.regexp[:ESCAPED]` - - -## Description - -Removes escapes from `str`. - diff --git a/example/ruby/URI/RFC2396_REGEXP.md b/example/ruby/URI/RFC2396_REGEXP.md deleted file mode 100644 index 775137b..0000000 --- a/example/ruby/URI/RFC2396_REGEXP.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: URI::RFC2396_REGEXP - - -Includes URI::REGEXP::PATTERN - - - diff --git a/example/ruby/URI/RFC2396_REGEXP/PATTERN.md b/example/ruby/URI/RFC2396_REGEXP/PATTERN.md deleted file mode 100644 index b5f125e..0000000 --- a/example/ruby/URI/RFC2396_REGEXP/PATTERN.md +++ /dev/null @@ -1,7 +0,0 @@ -# Module: URI::RFC2396_REGEXP::PATTERN - - -Patterns used to parse URI's - - - diff --git a/example/ruby/URI/RFC3986_Parser.md b/example/ruby/URI/RFC3986_Parser.md deleted file mode 100644 index fab4c30..0000000 --- a/example/ruby/URI/RFC3986_Parser.md +++ /dev/null @@ -1,40 +0,0 @@ -# Class: URI::RFC3986_Parser -**Inherits:** Object - - -:nodoc: - - -# Attributes -## regexp[RW] [](#attribute-i-regexp) -Returns the value of attribute regexp. - - -#Instance Methods -## escape(str, unsafenil) [](#method-i-escape) -Compatibility for RFC2396 parser - -## extract(str, schemesnil, &block) [](#method-i-extract) -Compatibility for RFC2396 parser - -## initialize() [](#method-i-initialize) - -**@return** [RFC3986_Parser] a new instance of RFC3986_Parser - -## inspect() [](#method-i-inspect) - -## join(*uris) [](#method-i-join) -:nodoc: - -## make_regexp(schemesnil) [](#method-i-make_regexp) -Compatibility for RFC2396 parser - -## parse(uri) [](#method-i-parse) -:nodoc: - -## split(uri) [](#method-i-split) -:nodoc: - -## unescape(str, escapednil) [](#method-i-unescape) -Compatibility for RFC2396 parser - diff --git a/example/ruby/URI/TestCommon.md b/example/ruby/URI/TestCommon.md deleted file mode 100644 index a5824bb..0000000 --- a/example/ruby/URI/TestCommon.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: URI::TestCommon -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_decode_uri_component() [](#method-i-test_decode_uri_component) - -## test_decode_www_form() [](#method-i-test_decode_www_form) - -## test_decode_www_form_component() [](#method-i-test_decode_www_form_component) - -## test_encode_uri_component() [](#method-i-test_encode_uri_component) - -## test_encode_www_form() [](#method-i-test_encode_www_form) - -## test_encode_www_form_component() [](#method-i-test_encode_www_form_component) - -## test_extract() [](#method-i-test_extract) - -## test_fallback_constants() [](#method-i-test_fallback_constants) - -## test_kernel_uri() [](#method-i-test_kernel_uri) - -## test_parse_timeout() [](#method-i-test_parse_timeout) - -## test_parser_switch() [](#method-i-test_parser_switch) - -## test_ractor() [](#method-i-test_ractor) - -## test_regexp() [](#method-i-test_regexp) - -## test_register_scheme() [](#method-i-test_register_scheme) - -## test_register_scheme_lowercase() [](#method-i-test_register_scheme_lowercase) - -## test_register_scheme_with_symbols() [](#method-i-test_register_scheme_with_symbols) - diff --git a/example/ruby/URI/TestFTP.md b/example/ruby/URI/TestFTP.md deleted file mode 100644 index 4255b7b..0000000 --- a/example/ruby/URI/TestFTP.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: URI::TestFTP -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_assemble() [](#method-i-test_assemble) - -## test_parse() [](#method-i-test_parse) - -## test_parse_invalid() [](#method-i-test_parse_invalid) - -## test_paths() [](#method-i-test_paths) - -## test_select() [](#method-i-test_select) - diff --git a/example/ruby/URI/TestFile.md b/example/ruby/URI/TestFile.md deleted file mode 100644 index 50191de..0000000 --- a/example/ruby/URI/TestFile.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: URI::TestFile -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_build() [](#method-i-test_build) - -## test_parse() [](#method-i-test_parse) - diff --git a/example/ruby/URI/TestGeneric.md b/example/ruby/URI/TestGeneric.md deleted file mode 100644 index 73591c5..0000000 --- a/example/ruby/URI/TestGeneric.md +++ /dev/null @@ -1,76 +0,0 @@ -# Class: URI::TestGeneric -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_absolute() [](#method-i-test_absolute) - -## test_bad_password_component() [](#method-i-test_bad_password_component) - -## test_build() [](#method-i-test_build) - -## test_build2() [](#method-i-test_build2) - -## test_find_proxy() [](#method-i-test_find_proxy) - -## test_find_proxy_bad_uri() [](#method-i-test_find_proxy_bad_uri) -192.0.2.0/24 is TEST-NET. [RFC3330] - -## test_find_proxy_bad_value() [](#method-i-test_find_proxy_bad_value) - -## test_find_proxy_case_sensitive_env() [](#method-i-test_find_proxy_case_sensitive_env) - -## test_find_proxy_get() [](#method-i-test_find_proxy_get) - -## test_find_proxy_no_env() [](#method-i-test_find_proxy_no_env) - -## test_find_proxy_no_proxy() [](#method-i-test_find_proxy_no_proxy) - -## test_find_proxy_no_proxy_cidr() [](#method-i-test_find_proxy_no_proxy_cidr) - -## test_hierarchical() [](#method-i-test_hierarchical) - -## test_ipv6() [](#method-i-test_ipv6) - -## test_join() [](#method-i-test_join) - -## test_merge() [](#method-i-test_merge) - -## test_parse() [](#method-i-test_parse) - -## test_parse_scheme_with_symbols() [](#method-i-test_parse_scheme_with_symbols) - -## test_rfc3986_examples() [](#method-i-test_rfc3986_examples) - -## test_route() [](#method-i-test_route) - -## test_set_component() [](#method-i-test_set_component) -ruby-dev:16728 - -## test_set_scheme() [](#method-i-test_set_scheme) - -## test_split() [](#method-i-test_split) - -## test_to_s() [](#method-i-test_to_s) - -## test_use_proxy_p() [](#method-i-test_use_proxy_p) - -## uri_to_ary(uri) [](#method-i-uri_to_ary) - -## with_proxy_env(h, &b) [](#method-i-with_proxy_env) - -**@yield** [h] - -## with_proxy_env_case_sensitive(h, &b) [](#method-i-with_proxy_env_case_sensitive) - -**@yield** [h] - -## with_proxy_real_env(h) [](#method-i-with_proxy_real_env) - diff --git a/example/ruby/URI/TestGeneric/CaseInsensitiveEnv.md b/example/ruby/URI/TestGeneric/CaseInsensitiveEnv.md deleted file mode 100644 index b9fed53..0000000 --- a/example/ruby/URI/TestGeneric/CaseInsensitiveEnv.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: URI::TestGeneric::CaseInsensitiveEnv -**Inherits:** Object - - - - - -#Instance Methods -## [](k) [](#method-i-[]) - -## []=(k, v) [](#method-i-[]=) - -## each() [](#method-i-each) - -## include?(k) [](#method-i-include?) - -**@return** [Boolean] - -## initialize(h{}) [](#method-i-initialize) - -**@return** [CaseInsensitiveEnv] a new instance of CaseInsensitiveEnv - -## length() [](#method-i-length) - -## reject() [](#method-i-reject) - -## shift() [](#method-i-shift) - -## to_hash() [](#method-i-to_hash) - diff --git a/example/ruby/URI/TestHTTP.md b/example/ruby/URI/TestHTTP.md deleted file mode 100644 index e3c29d1..0000000 --- a/example/ruby/URI/TestHTTP.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: URI::TestHTTP -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_authority() [](#method-i-test_authority) - -## test_build() [](#method-i-test_build) - -## test_equal() [](#method-i-test_equal) - -## test_normalize() [](#method-i-test_normalize) - -## test_origin() [](#method-i-test_origin) - -## test_parse() [](#method-i-test_parse) - -## test_request_uri() [](#method-i-test_request_uri) - -## test_select() [](#method-i-test_select) - -## uri_to_ary(uri) [](#method-i-uri_to_ary) - diff --git a/example/ruby/URI/TestLDAP.md b/example/ruby/URI/TestLDAP.md deleted file mode 100644 index ab5ef33..0000000 --- a/example/ruby/URI/TestLDAP.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: URI::TestLDAP -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_parse() [](#method-i-test_parse) - -## test_parse_invalid_uri() [](#method-i-test_parse_invalid_uri) - -## test_select() [](#method-i-test_select) - -## uri_to_ary(uri) [](#method-i-uri_to_ary) - diff --git a/example/ruby/URI/TestMailTo.md b/example/ruby/URI/TestMailTo.md deleted file mode 100644 index 92c4f7d..0000000 --- a/example/ruby/URI/TestMailTo.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: URI::TestMailTo -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_build() [](#method-i-test_build) - -## test_check_to() [](#method-i-test_check_to) - -## test_initializer() [](#method-i-test_initializer) - -## test_select() [](#method-i-test_select) - -## test_to_mailtext() [](#method-i-test_to_mailtext) - -## test_to_s() [](#method-i-test_to_s) - -## uri_to_ary(uri) [](#method-i-uri_to_ary) - diff --git a/example/ruby/URI/TestParser.md b/example/ruby/URI/TestParser.md deleted file mode 100644 index ddac375..0000000 --- a/example/ruby/URI/TestParser.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: URI::TestParser -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## test_compare() [](#method-i-test_compare) - -## test_inspect() [](#method-i-test_inspect) - -## test_parse_auth() [](#method-i-test_parse_auth) - -## test_parse_query_pct_encoded() [](#method-i-test_parse_query_pct_encoded) - -## test_parse_rfc2396_parser() [](#method-i-test_parse_rfc2396_parser) - -## test_raise_bad_uri_for_integer() [](#method-i-test_raise_bad_uri_for_integer) - -## test_rfc2822_parse_relative_uri() [](#method-i-test_rfc2822_parse_relative_uri) - -## test_rfc2822_unescape() [](#method-i-test_rfc2822_unescape) - -## test_rfc3986_port_check() [](#method-i-test_rfc3986_port_check) - -## test_split() [](#method-i-test_split) - -## uri_to_ary(uri) [](#method-i-uri_to_ary) - diff --git a/example/ruby/URI/TestWS.md b/example/ruby/URI/TestWS.md deleted file mode 100644 index 5ebc67d..0000000 --- a/example/ruby/URI/TestWS.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: URI::TestWS -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_build() [](#method-i-test_build) - -## test_equal() [](#method-i-test_equal) - -## test_normalize() [](#method-i-test_normalize) - -## test_parse() [](#method-i-test_parse) - -## test_request_uri() [](#method-i-test_request_uri) - -## test_select() [](#method-i-test_select) - -## uri_to_ary(uri) [](#method-i-uri_to_ary) - diff --git a/example/ruby/URI/TestWSS.md b/example/ruby/URI/TestWSS.md deleted file mode 100644 index 7290c23..0000000 --- a/example/ruby/URI/TestWSS.md +++ /dev/null @@ -1,26 +0,0 @@ -# Class: URI::TestWSS -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_build() [](#method-i-test_build) - -## test_equal() [](#method-i-test_equal) - -## test_normalize() [](#method-i-test_normalize) - -## test_parse() [](#method-i-test_parse) - -## test_request_uri() [](#method-i-test_request_uri) - -## test_select() [](#method-i-test_select) - -## uri_to_ary(uri) [](#method-i-uri_to_ary) - diff --git a/example/ruby/URI/Util.md b/example/ruby/URI/Util.md deleted file mode 100644 index efc8b2f..0000000 --- a/example/ruby/URI/Util.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: URI::Util - - -:nodoc: - - -# Class Methods -## make_components_hash(klass , array_hash ) [](#method-c-make_components_hash) - diff --git a/example/ruby/URI/WS.md b/example/ruby/URI/WS.md deleted file mode 100644 index 38f0b57..0000000 --- a/example/ruby/URI/WS.md +++ /dev/null @@ -1,49 +0,0 @@ -# Class: URI::WS -**Inherits:** URI::Generic - - -The syntax of WS URIs is defined in RFC6455 section 3. - -Note that the Ruby URI library allows WS URLs containing usernames and -passwords. This is not legal as per the RFC, but used to be supported in -Internet Explorer 5 and 6, before the MS04-004 security update. See -. - - -# Class Methods -## build(args ) [](#method-c-build) -## Description - -Creates a new URI::WS object from components, with syntax checking. - -The components accepted are userinfo, host, port, path, and query. - -The components should be provided either as an Array, or as a Hash with keys -formed by preceding the component names with a colon. - -If an Array is used, the components must be passed in the order `[userinfo, -host, port, path, query]`. - -Example: - - uri = URI::WS.build(host: 'www.example.com', path: '/foo/bar') - - uri = URI::WS.build([nil, "www.example.com", nil, "/path", "query"]) - -Currently, if passed userinfo components this method generates invalid WS URIs -as per RFC 1738. - -#Instance Methods -## request_uri() [](#method-i-request_uri) -## Description - -Returns the full path for a WS URI, as required by Net::HTTP::Get. - -If the URI contains a query, the full path is URI#path + '?' + URI#query. -Otherwise, the path is simply URI#path. - -Example: - - uri = URI::WS.build(path: '/foo/bar', query: 'test=true') - uri.request_uri # => "/foo/bar?test=true" - diff --git a/example/ruby/URI/WSS.md b/example/ruby/URI/WSS.md deleted file mode 100644 index fb98e27..0000000 --- a/example/ruby/URI/WSS.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: URI::WSS -**Inherits:** URI::WS - - -The default port for WSS URIs is 443, and the scheme is 'wss:' rather than -'ws:'. Other than that, WSS URIs are identical to WS URIs; see URI::WS. - - - diff --git a/example/ruby/URISpec.md b/example/ruby/URISpec.md deleted file mode 100644 index 250c956..0000000 --- a/example/ruby/URISpec.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: URISpec - - - - -# Class Methods -## components(uri ) [](#method-c-components) - diff --git a/example/ruby/UnboundMethod.md b/example/ruby/UnboundMethod.md deleted file mode 100644 index 846eaf2..0000000 --- a/example/ruby/UnboundMethod.md +++ /dev/null @@ -1,287 +0,0 @@ -# Class: UnboundMethod -**Inherits:** Object - - -******************************************************************** - - Ruby supports two forms of objectified methods. Class Method is - used to represent methods that are associated with a particular - object: these method objects are bound to that object. Bound - method objects for an object can be created using Object#method. - - Ruby also supports unbound methods; methods objects that are not - associated with a particular object. These can be created either - by calling Module#instance_method or by calling #unbind on a bound - method object. The result of both of these is an UnboundMethod - object. - - Unbound methods can only be called after they are bound to an - object. That object must be a kind_of? the method's original - class. - - class Square - def area - @side * @side - end - def initialize(side) - @side = side - end - end - - area_un = Square.instance_method(:area) - - s = Square.new(12) - area = area_un.bind(s) - area.call #=> 144 - - Unbound methods are a reference to the method at the time it was - objectified: subsequent changes to the underlying class will not - affect the unbound method. - - class Test - def test - :original - end - end - um = Test.instance_method(:test) - class Test - def test - :modified - end - end - t = Test.new - t.test #=> :modified - um.bind(t).call #=> :original - - - -#Instance Methods -## ==() [](#method-i-==) - -## arity() [](#method-i-arity) -Returns an indication of the number of arguments accepted by a method. Returns -a nonnegative integer for methods that take a fixed number of arguments. For -Ruby methods that take a variable number of arguments, returns -n-1, where n -is the number of required arguments. Keyword arguments will be considered as a -single additional argument, that argument being mandatory if any keyword -argument is mandatory. For methods written in C, returns -1 if the call takes -a variable number of arguments. - - class C - def one; end - def two(a); end - def three(*a); end - def four(a, b); end - def five(a, b, *c); end - def six(a, b, *c, &d); end - def seven(a, b, x:0); end - def eight(x:, y:); end - def nine(x:, y:, **z); end - def ten(*a, x:, y:); end - end - c = C.new - c.method(:one).arity #=> 0 - c.method(:two).arity #=> 1 - c.method(:three).arity #=> -1 - c.method(:four).arity #=> 2 - c.method(:five).arity #=> -3 - c.method(:six).arity #=> -3 - c.method(:seven).arity #=> -3 - c.method(:eight).arity #=> 1 - c.method(:nine).arity #=> 1 - c.method(:ten).arity #=> -2 - - "cat".method(:size).arity #=> 0 - "cat".method(:replace).arity #=> 1 - "cat".method(:squeeze).arity #=> -1 - "cat".method(:count).arity #=> -1 - -**@overload** [] - -## bind(recv) [](#method-i-bind) -Bind *umeth* to *obj*. If Klass was the class from which *umeth* was obtained, -`obj.kind_of?(Klass)` must be true. - - class A - def test - puts "In test, class = #{self.class}" - end - end - class B < A - end - class C < B - end - - um = B.instance_method(:test) - bm = um.bind(C.new) - bm.call - bm = um.bind(B.new) - bm.call - bm = um.bind(A.new) - bm.call - -*produces:* - - In test, class = C - In test, class = B - prog.rb:16:in `bind': bind argument must be an instance of B (TypeError) - from prog.rb:16 - -**@overload** [] - -## bind_call(*args) [](#method-i-bind_call) -Bind *umeth* to *recv* and then invokes the method with the specified -arguments. This is semantically equivalent to `umeth.bind(recv).call(args, -...)`. - -**@overload** [] - -## clone() [](#method-i-clone) -Returns a clone of this method. - - class A - def foo - return "bar" - end - end - - m = A.new.method(:foo) - m.call # => "bar" - n = m.clone.call # => "bar" - -**@overload** [] - -## dup() [](#method-i-dup) -:nodoc: - -## eql?() [](#method-i-eql?) - -**@return** [Boolean] - -## hash() [](#method-i-hash) -Returns a hash value corresponding to the method object. - -See also Object#hash. - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns a human-readable description of the underlying method. - - "cat".method(:count).inspect #=> "#" - (1..3).method(:map).inspect #=> "#" - -In the latter case, the method description includes the "owner" of the -original method (`Enumerable` module, which is included into `Range`). - -`inspect` also provides, when possible, method argument names (call sequence) -and source location. - - require 'net/http' - Net::HTTP.method(:get).inspect - #=> "#/lib/ruby/2.7.0/net/http.rb:457>" - -`...` in argument definition means argument is optional (has some default -value). - -For methods defined in C (language core and extensions), location and argument -names can't be extracted, and only generic information is provided in form of -`*` (any number of arguments) or `_` (some positional argument). - - "cat".method(:count).inspect #=> "#" - "cat".method(:+).inspect #=> "#"" - -**@overload** [] - -**@overload** [] - -## name() [](#method-i-name) -Returns the name of the method. - -**@overload** [] - -## original_name() [](#method-i-original_name) -Returns the original name of the method. - - class C - def foo; end - alias bar foo - end - C.instance_method(:bar).original_name # => :foo - -**@overload** [] - -## owner() [](#method-i-owner) -Returns the class or module on which this method is defined. In other words, - - meth.owner.instance_methods(false).include?(meth.name) # => true - -holds as long as the method is not removed/undefined/replaced, (with -private_instance_methods instead of instance_methods if the method is -private). - -See also Method#receiver. - - (1..3).method(:map).owner #=> Enumerable - -**@overload** [] - -## parameters() [](#method-i-parameters) -Returns the parameter information of this method. - - def foo(bar); end - method(:foo).parameters #=> [[:req, :bar]] - - def foo(bar, baz, bat, &blk); end - method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:req, :bat], [:block, :blk]] - - def foo(bar, *args); end - method(:foo).parameters #=> [[:req, :bar], [:rest, :args]] - - def foo(bar, baz, *args, &blk); end - method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:rest, :args], [:block, :blk]] - -**@overload** [] - -## source_location() [](#method-i-source_location) -Returns the Ruby source filename and line number containing this method or nil -if this method was not defined in Ruby (i.e. native). - -**@overload** [] - -## super_method() [](#method-i-super_method) -Returns a Method of superclass which would be called when super is used or nil -if there is no method on superclass. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns a human-readable description of the underlying method. - - "cat".method(:count).inspect #=> "#" - (1..3).method(:map).inspect #=> "#" - -In the latter case, the method description includes the "owner" of the -original method (`Enumerable` module, which is included into `Range`). - -`inspect` also provides, when possible, method argument names (call sequence) -and source location. - - require 'net/http' - Net::HTTP.method(:get).inspect - #=> "#/lib/ruby/2.7.0/net/http.rb:457>" - -`...` in argument definition means argument is optional (has some default -value). - -For methods defined in C (language core and extensions), location and argument -names can't be extracted, and only generic information is provided in form of -`*` (any number of arguments) or `_` (some positional argument). - - "cat".method(:count).inspect #=> "#" - "cat".method(:+).inspect #=> "#"" - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/UnboundMethodSpecs.md b/example/ruby/UnboundMethodSpecs.md deleted file mode 100644 index df2456c..0000000 --- a/example/ruby/UnboundMethodSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: UnboundMethodSpecs - - - - - diff --git a/example/ruby/UnboundMethodSpecs/A.md b/example/ruby/UnboundMethodSpecs/A.md deleted file mode 100644 index 3eb63f2..0000000 --- a/example/ruby/UnboundMethodSpecs/A.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: UnboundMethodSpecs::A -**Inherits:** Object - - - - - -#Instance Methods -## baz(a, b) [](#method-i-baz) - -## overridden() [](#method-i-overridden) - diff --git a/example/ruby/UnboundMethodSpecs/B.md b/example/ruby/UnboundMethodSpecs/B.md deleted file mode 100644 index 7079871..0000000 --- a/example/ruby/UnboundMethodSpecs/B.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: UnboundMethodSpecs::B -**Inherits:** UnboundMethodSpecs::A - - - - - -#Instance Methods -## overridden() [](#method-i-overridden) - diff --git a/example/ruby/UnboundMethodSpecs/C.md b/example/ruby/UnboundMethodSpecs/C.md deleted file mode 100644 index 6e7a577..0000000 --- a/example/ruby/UnboundMethodSpecs/C.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: UnboundMethodSpecs::C -**Inherits:** UnboundMethodSpecs::B - - - - - -#Instance Methods -## overridden() [](#method-i-overridden) - diff --git a/example/ruby/UnboundMethodSpecs/Child1.md b/example/ruby/UnboundMethodSpecs/Child1.md deleted file mode 100644 index a18f912..0000000 --- a/example/ruby/UnboundMethodSpecs/Child1.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UnboundMethodSpecs::Child1 -**Inherits:** UnboundMethodSpecs::Parent - - - - - diff --git a/example/ruby/UnboundMethodSpecs/Child2.md b/example/ruby/UnboundMethodSpecs/Child2.md deleted file mode 100644 index 63bdcb8..0000000 --- a/example/ruby/UnboundMethodSpecs/Child2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UnboundMethodSpecs::Child2 -**Inherits:** UnboundMethodSpecs::Parent - - - - - diff --git a/example/ruby/UnboundMethodSpecs/Child3.md b/example/ruby/UnboundMethodSpecs/Child3.md deleted file mode 100644 index c549669..0000000 --- a/example/ruby/UnboundMethodSpecs/Child3.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UnboundMethodSpecs::Child3 -**Inherits:** UnboundMethodSpecs::Parent - - - - - diff --git a/example/ruby/UnboundMethodSpecs/HashSpecs.md b/example/ruby/UnboundMethodSpecs/HashSpecs.md deleted file mode 100644 index e28fe4d..0000000 --- a/example/ruby/UnboundMethodSpecs/HashSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: UnboundMethodSpecs::HashSpecs - - - - - diff --git a/example/ruby/UnboundMethodSpecs/HashSpecs/SubClass.md b/example/ruby/UnboundMethodSpecs/HashSpecs/SubClass.md deleted file mode 100644 index bd8ab07..0000000 --- a/example/ruby/UnboundMethodSpecs/HashSpecs/SubClass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UnboundMethodSpecs::HashSpecs::SubClass -**Inherits:** UnboundMethodSpecs::HashSpecs::SuperClass - - - - - diff --git a/example/ruby/UnboundMethodSpecs/HashSpecs/SuperClass.md b/example/ruby/UnboundMethodSpecs/HashSpecs/SuperClass.md deleted file mode 100644 index b76e881..0000000 --- a/example/ruby/UnboundMethodSpecs/HashSpecs/SuperClass.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: UnboundMethodSpecs::HashSpecs::SuperClass -**Inherits:** Object - - - - - -#Instance Methods -## foo() [](#method-i-foo) - diff --git a/example/ruby/UnboundMethodSpecs/Methods.md b/example/ruby/UnboundMethodSpecs/Methods.md deleted file mode 100644 index 601723a..0000000 --- a/example/ruby/UnboundMethodSpecs/Methods.md +++ /dev/null @@ -1,44 +0,0 @@ -# Class: UnboundMethodSpecs::Methods -**Inherits:** Object - -**Includes:** UnboundMethodSpecs::Mod - - - - - -#Instance Methods -## discard_1() [](#method-i-discard_1) - -## discard_2() [](#method-i-discard_2) - -## foo() [](#method-i-foo) - -## foo_super() [](#method-i-foo_super) - -## four(a, b, &c) [](#method-i-four) - -## from_mod() [](#method-i-from_mod) - -## identical_body() [](#method-i-identical_body) - -## my_public_method() [](#method-i-my_public_method) - -## neg_four(a, b, *c, &d) [](#method-i-neg_four) - -## neg_one(*a) [](#method-i-neg_one) - -## neg_three(a, b, *c) [](#method-i-neg_three) - -## neg_two(a, *b) [](#method-i-neg_two) - -## one() [](#method-i-one) - -## original_body() [](#method-i-original_body) - -## three(a, b) [](#method-i-three) - -## two(a) [](#method-i-two) - -## with_block(&block) [](#method-i-with_block) - diff --git a/example/ruby/UnboundMethodSpecs/Mod.md b/example/ruby/UnboundMethodSpecs/Mod.md deleted file mode 100644 index f421a79..0000000 --- a/example/ruby/UnboundMethodSpecs/Mod.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: UnboundMethodSpecs::Mod - - - - - -#Instance Methods -## foo_super() [](#method-i-foo_super) - -## from_mod() [](#method-i-from_mod) - diff --git a/example/ruby/UnboundMethodSpecs/Parent.md b/example/ruby/UnboundMethodSpecs/Parent.md deleted file mode 100644 index a074fbc..0000000 --- a/example/ruby/UnboundMethodSpecs/Parent.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: UnboundMethodSpecs::Parent -**Inherits:** Object - - - - -# Class Methods -## class_method() [](#method-c-class_method) - -#Instance Methods -## foo() [](#method-i-foo) - -## foo_super() [](#method-i-foo_super) - diff --git a/example/ruby/UnboundMethodSpecs/SourceLocation.md b/example/ruby/UnboundMethodSpecs/SourceLocation.md deleted file mode 100644 index d832fa1..0000000 --- a/example/ruby/UnboundMethodSpecs/SourceLocation.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: UnboundMethodSpecs::SourceLocation -**Inherits:** Object - - - - -# Class Methods -## location() [](#method-c-location) -This needs to be on this line -## redefined() [](#method-c-redefined) - -#Instance Methods -## original() [](#method-i-original) - diff --git a/example/ruby/UncaughtThrowError.md b/example/ruby/UncaughtThrowError.md deleted file mode 100644 index ef551d5..0000000 --- a/example/ruby/UncaughtThrowError.md +++ /dev/null @@ -1,41 +0,0 @@ -# Exception: UncaughtThrowError -**Inherits:** ArgumentError - - -Raised when `throw` is called with a *tag* which does not have corresponding -`catch` block. - - throw "foo", "bar" - -*raises the exception:* - - UncaughtThrowError: uncaught throw "foo" - - - -#Instance Methods -## initialize(*args) [](#method-i-initialize) -Raised when `throw` is called with a *tag* which does not have corresponding -`catch` block. - - throw "foo", "bar" - -*raises the exception:* - - UncaughtThrowError: uncaught throw "foo" - -## tag() [](#method-i-tag) -Return the tag object which was called for. - -**@overload** [] - -## to_s() [](#method-i-to_s) -Returns formatted message with the inspected tag. - -**@overload** [] - -## value() [](#method-i-value) -Return the return value which was called for. - -**@overload** [] - diff --git a/example/ruby/UncorrectableNameCheckTest.md b/example/ruby/UncorrectableNameCheckTest.md deleted file mode 100644 index 693279d..0000000 --- a/example/ruby/UncorrectableNameCheckTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: UncorrectableNameCheckTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_message() [](#method-i-test_message) - diff --git a/example/ruby/UncorrectableNameCheckTest/FirstNameError.md b/example/ruby/UncorrectableNameCheckTest/FirstNameError.md deleted file mode 100644 index 7519842..0000000 --- a/example/ruby/UncorrectableNameCheckTest/FirstNameError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: UncorrectableNameCheckTest::FirstNameError -**Inherits:** NameError - - - - - diff --git a/example/ruby/UnexpectedException.md b/example/ruby/UnexpectedException.md deleted file mode 100644 index 3e895ba..0000000 --- a/example/ruby/UnexpectedException.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: UnexpectedException -**Inherits:** Exception - - - - - diff --git a/example/ruby/UnicodeNormalize.md b/example/ruby/UnicodeNormalize.md deleted file mode 100644 index c4d8a3d..0000000 --- a/example/ruby/UnicodeNormalize.md +++ /dev/null @@ -1,20 +0,0 @@ -# Module: UnicodeNormalize - - -:stopdoc: - - -# Class Methods -## canonical_ordering_one(string ) [](#method-c-canonical_ordering_one) -Canonical Ordering -## hangul_comp_one(string ) [](#method-c-hangul_comp_one) -## hangul_decomp_one(target ) [](#method-c-hangul_decomp_one) -Hangul Algorithm -## nfc_one(string ) [](#method-c-nfc_one) -## nfd_one(string ) [](#method-c-nfd_one) -Normalization Forms for Patterns (not whole Strings) -## normalize(string , form :nfc) [](#method-c-normalize) -## normalized?(string , form :nfc) [](#method-c-normalized?) -**@return** [Boolean] - - diff --git a/example/ruby/Unifdef.md b/example/ruby/Unifdef.md deleted file mode 100644 index 9e02f10..0000000 --- a/example/ruby/Unifdef.md +++ /dev/null @@ -1,41 +0,0 @@ -# Class: Unifdef -**Inherits:** Object - - -Write Data - - -# Attributes -## kwdonly[RW] [](#attribute-i-kwdonly) -Returns the value of attribute kwdonly. - -## output[RW] [](#attribute-i-output) -Returns the value of attribute output. - -## stack[RW] [](#attribute-i-stack) -Returns the value of attribute stack. - -## stdout[RW] [](#attribute-i-stdout) -Returns the value of attribute stdout. - -## top[RW] [](#attribute-i-top) -Returns the value of attribute top. - - -#Instance Methods -## _show(dest, ary, syms) [](#method-i-_show) - -## endif(sym) [](#method-i-endif) - -## ifdef(sym) [](#method-i-ifdef) - -## initialize(out) [](#method-i-initialize) - -**@return** [Unifdef] a new instance of Unifdef - -## restore() [](#method-i-restore) - -## show(dest, *syms) [](#method-i-show) - -## write(str) [](#method-i-write) - diff --git a/example/ruby/UnitdiffFormatter.md b/example/ruby/UnitdiffFormatter.md deleted file mode 100644 index e09cd02..0000000 --- a/example/ruby/UnitdiffFormatter.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: UnitdiffFormatter -**Inherits:** DottedFormatter - - - - - -#Instance Methods -## finish() [](#method-i-finish) - diff --git a/example/ruby/UpdateEnv.md b/example/ruby/UpdateEnv.md deleted file mode 100644 index 87f559b..0000000 --- a/example/ruby/UpdateEnv.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: UpdateEnv - - - - - -#Instance Methods -## update_env(environ) [](#method-i-update_env) - diff --git a/example/ruby/UserArray.md b/example/ruby/UserArray.md deleted file mode 100644 index c26300a..0000000 --- a/example/ruby/UserArray.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UserArray -**Inherits:** Array - - - - - diff --git a/example/ruby/UserCustomConstructorString.md b/example/ruby/UserCustomConstructorString.md deleted file mode 100644 index 4061133..0000000 --- a/example/ruby/UserCustomConstructorString.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: UserCustomConstructorString -**Inherits:** String - - - - - -#Instance Methods -## initialize(arg1, arg2) [](#method-i-initialize) - -**@return** [UserCustomConstructorString] a new instance of UserCustomConstructorString - diff --git a/example/ruby/UserDefined.md b/example/ruby/UserDefined.md deleted file mode 100644 index a3bf8db..0000000 --- a/example/ruby/UserDefined.md +++ /dev/null @@ -1,25 +0,0 @@ -# Class: UserDefined -**Inherits:** Object - - - - -# Class Methods -## _load(data ) [](#method-c-_load) -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a. - -## b[RW] [](#attribute-i-b) -Returns the value of attribute b. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## _dump(depth) [](#method-i-_dump) - -## initialize() [](#method-i-initialize) - -**@return** [UserDefined] a new instance of UserDefined - diff --git a/example/ruby/UserDefined/Nested.md b/example/ruby/UserDefined/Nested.md deleted file mode 100644 index 218f485..0000000 --- a/example/ruby/UserDefined/Nested.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: UserDefined::Nested -**Inherits:** Object - - - - - -#Instance Methods -## ==(other) [](#method-i-==) - diff --git a/example/ruby/UserDefinedImmediate.md b/example/ruby/UserDefinedImmediate.md deleted file mode 100644 index 11dca34..0000000 --- a/example/ruby/UserDefinedImmediate.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: UserDefinedImmediate -**Inherits:** Object - - - - -# Class Methods -## _load(data ) [](#method-c-_load) - -#Instance Methods -## _dump(depth) [](#method-i-_dump) - diff --git a/example/ruby/UserDefinedString.md b/example/ruby/UserDefinedString.md deleted file mode 100644 index 92188b7..0000000 --- a/example/ruby/UserDefinedString.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: UserDefinedString -**Inherits:** Object - - - - -# Class Methods -## _load(data ) [](#method-c-_load) -# Attributes -## string[RW] [](#attribute-i-string) -Returns the value of attribute string. - - -#Instance Methods -## _dump(depth) [](#method-i-_dump) - -## initialize(string) [](#method-i-initialize) - -**@return** [UserDefinedString] a new instance of UserDefinedString - diff --git a/example/ruby/UserDefinedWithIvar.md b/example/ruby/UserDefinedWithIvar.md deleted file mode 100644 index 2a88970..0000000 --- a/example/ruby/UserDefinedWithIvar.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: UserDefinedWithIvar -**Inherits:** Object - - - - -# Class Methods -## _load(data ) [](#method-c-_load) -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a. - -## b[RW] [](#attribute-i-b) -Returns the value of attribute b. - -## c[RW] [](#attribute-i-c) -Returns the value of attribute c. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## _dump(depth) [](#method-i-_dump) - -## initialize() [](#method-i-initialize) - -**@return** [UserDefinedWithIvar] a new instance of UserDefinedWithIvar - diff --git a/example/ruby/UserHash.md b/example/ruby/UserHash.md deleted file mode 100644 index faf5795..0000000 --- a/example/ruby/UserHash.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UserHash -**Inherits:** Hash - - - - - diff --git a/example/ruby/UserHashInitParams.md b/example/ruby/UserHashInitParams.md deleted file mode 100644 index 858c762..0000000 --- a/example/ruby/UserHashInitParams.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: UserHashInitParams -**Inherits:** Hash - - - - - -#Instance Methods -## initialize(a) [](#method-i-initialize) - -**@return** [UserHashInitParams] a new instance of UserHashInitParams - diff --git a/example/ruby/UserMarshal.md b/example/ruby/UserMarshal.md deleted file mode 100644 index b57d2bb..0000000 --- a/example/ruby/UserMarshal.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: UserMarshal -**Inherits:** Object - - - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize() [](#method-i-initialize) - -**@return** [UserMarshal] a new instance of UserMarshal - -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(data) [](#method-i-marshal_load) - diff --git a/example/ruby/UserMarshalWithClassName.md b/example/ruby/UserMarshalWithClassName.md deleted file mode 100644 index f8b608e..0000000 --- a/example/ruby/UserMarshalWithClassName.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: UserMarshalWithClassName -**Inherits:** UserMarshal - - - - -# Class Methods -## name() [](#method-c-name) - diff --git a/example/ruby/UserMarshalWithIvar.md b/example/ruby/UserMarshalWithIvar.md deleted file mode 100644 index 2d7e2f7..0000000 --- a/example/ruby/UserMarshalWithIvar.md +++ /dev/null @@ -1,22 +0,0 @@ -# Class: UserMarshalWithIvar -**Inherits:** Object - - - - -# Attributes -## data[RW] [](#attribute-i-data) -Returns the value of attribute data. - - -#Instance Methods -## ==(other) [](#method-i-==) - -## initialize() [](#method-i-initialize) - -**@return** [UserMarshalWithIvar] a new instance of UserMarshalWithIvar - -## marshal_dump() [](#method-i-marshal_dump) - -## marshal_load(o) [](#method-i-marshal_load) - diff --git a/example/ruby/UserObject.md b/example/ruby/UserObject.md deleted file mode 100644 index 2e925ee..0000000 --- a/example/ruby/UserObject.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UserObject -**Inherits:** Object - - - - - diff --git a/example/ruby/UserPreviouslyDefinedWithInitializedIvar.md b/example/ruby/UserPreviouslyDefinedWithInitializedIvar.md deleted file mode 100644 index 8d7ba3c..0000000 --- a/example/ruby/UserPreviouslyDefinedWithInitializedIvar.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: UserPreviouslyDefinedWithInitializedIvar -**Inherits:** Object - - - - -# Attributes -## field1[RW] [](#attribute-i-field1) -Returns the value of attribute field1. - -## field2[RW] [](#attribute-i-field2) -Returns the value of attribute field2. - - diff --git a/example/ruby/UserRegexp.md b/example/ruby/UserRegexp.md deleted file mode 100644 index 7a39a0c..0000000 --- a/example/ruby/UserRegexp.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UserRegexp -**Inherits:** Regexp - - - - - diff --git a/example/ruby/UserString.md b/example/ruby/UserString.md deleted file mode 100644 index d69f493..0000000 --- a/example/ruby/UserString.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: UserString -**Inherits:** String - - - - - diff --git a/example/ruby/VCS.md b/example/ruby/VCS.md deleted file mode 100644 index 4ddc254..0000000 --- a/example/ruby/VCS.md +++ /dev/null @@ -1,68 +0,0 @@ -# Class: VCS -**Inherits:** Object - -**Includes:** DebugSystem - - - - -# Class Methods -## define_options(parser , opts {}) [](#method-c-define_options) -## detect(path '.', options {}, parser nil, **opts ) [](#method-c-detect) -**@raise** [VCS::NotFoundError] - -## dump(obj , pre nil) [](#method-c-dump) -## local_path?(path ) [](#method-c-local_path?) -**@return** [Boolean] - -## register(dir , &pred ) [](#method-c-register) -## short_revision(rev ) [](#method-c-short_revision) -# Attributes -## debug[RW] [](#attribute-i-debug) -Returns the value of attribute debug. - -## dryrun[RW] [](#attribute-i-dryrun) -Returns the value of attribute dryrun. - -## srcdir[RW] [](#attribute-i-srcdir) -Returns the value of attribute srcdir. - - -#Instance Methods -## after_export(dir) [](#method-i-after_export) - -## chdir(path) [](#method-i-chdir) - -## define_options(parser) [](#method-i-define_options) - -## get_revisions(path) [](#method-i-get_revisions) -returns -* the last revision of the current branch -* the last revision in which `path` was modified -* the last modified time of `path` -* the last commit title since the latest upstream - -## initialize(path) [](#method-i-initialize) - -**@return** [VCS] a new instance of VCS - -## modified(path) [](#method-i-modified) - -## relative_to(path) [](#method-i-relative_to) - -## release_date(time) [](#method-i-release_date) - -## revision_handler(rev) [](#method-i-revision_handler) - -## revision_header(last, release_date, release_datetimenil, branchnil, titlenil, limit:20) [](#method-i-revision_header) -make-snapshot generates only release_date whereas file2lastrev generates both -release_date and release_datetime - -## revision_name(rev) [](#method-i-revision_name) - -## set_options(opts) [](#method-i-set_options) - -## short_revision(rev) [](#method-i-short_revision) - -## system(*args) [](#method-i-system) - diff --git a/example/ruby/VCS/GIT.md b/example/ruby/VCS/GIT.md deleted file mode 100644 index ddd903f..0000000 --- a/example/ruby/VCS/GIT.md +++ /dev/null @@ -1,59 +0,0 @@ -# Class: VCS::GIT -**Inherits:** VCS - - - - -# Class Methods -## revision_name(rev ) [](#method-c-revision_name) -## short_revision(rev ) [](#method-c-short_revision) - -#Instance Methods -## _get_revisions(path, srcdirnil) [](#method-i-_get_revisions) - -## branch(name) [](#method-i-branch) - -## branch_beginning(url) [](#method-i-branch_beginning) - -## branch_list(pat) [](#method-i-branch_list) - -## cmd_args(cmds, srcdirnil) [](#method-i-cmd_args) - -## cmd_pipe(*cmds, &block) [](#method-i-cmd_pipe) - -## cmd_pipe_at(srcdir, cmds, &block) [](#method-i-cmd_pipe_at) - -## cmd_read(*cmds) [](#method-i-cmd_read) - -## cmd_read_at(srcdir, cmds) [](#method-i-cmd_read_at) - -## commit(opts{}) [](#method-i-commit) - -## export(revision, url, dir, keep_tempfalse) [](#method-i-export) - -## export_changelog(url'@', fromnil, tonil, _pathnil, path:_path, base_url:nil) [](#method-i-export_changelog) - -## format_changelog(path, arg, base_urlnil) [](#method-i-format_changelog) - -## format_changelog_as_svn(path, arg) [](#method-i-format_changelog_as_svn) - -## global_config() [](#method-i-global_config) - -## grep(pat, tag, *files, &block) [](#method-i-grep) - -## initialize() [](#method-i-initialize) - -**@return** [GIT] a new instance of GIT - -## master() [](#method-i-master) - -## revision_handler(rev) [](#method-i-revision_handler) - -## stable() [](#method-i-stable) - -## svn_revision(log) [](#method-i-svn_revision) - -## upstream() [](#method-i-upstream) - -## without_gitconfig() [](#method-i-without_gitconfig) - diff --git a/example/ruby/VCS/GIT/Branch.md b/example/ruby/VCS/GIT/Branch.md deleted file mode 100644 index 436ae7c..0000000 --- a/example/ruby/VCS/GIT/Branch.md +++ /dev/null @@ -1,13 +0,0 @@ -# Class: VCS::GIT::Branch -**Inherits:** Struct - - - - -# Attributes -## to_str[RW] [](#attribute-i-to_str) -Returns the value of attribute to_str - -**@return** [Object] the current value of to_str - - diff --git a/example/ruby/VCS/GITSVN.md b/example/ruby/VCS/GITSVN.md deleted file mode 100644 index 7c3c176..0000000 --- a/example/ruby/VCS/GITSVN.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: VCS::GITSVN -**Inherits:** VCS::GIT - - - - -# Class Methods -## revision_name(rev ) [](#method-c-revision_name) - -#Instance Methods -## commit(opts{}) [](#method-i-commit) - -## last_changed_revision() [](#method-i-last_changed_revision) - diff --git a/example/ruby/VCS/NotFoundError.md b/example/ruby/VCS/NotFoundError.md deleted file mode 100644 index 5280d8c..0000000 --- a/example/ruby/VCS/NotFoundError.md +++ /dev/null @@ -1,7 +0,0 @@ -# Exception: VCS::NotFoundError -**Inherits:** RuntimeError - - - - - diff --git a/example/ruby/VCS/Null.md b/example/ruby/VCS/Null.md deleted file mode 100644 index a7be90d..0000000 --- a/example/ruby/VCS/Null.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: VCS::Null -**Inherits:** VCS - - - - - -#Instance Methods -## get_revisions(path, srcdirnil) [](#method-i-get_revisions) - -## revision_header(last, release_date, release_datetimenil, branchnil, titlenil, limit:20) [](#method-i-revision_header) - diff --git a/example/ruby/VCS/SVN.md b/example/ruby/VCS/SVN.md deleted file mode 100644 index aae1a62..0000000 --- a/example/ruby/VCS/SVN.md +++ /dev/null @@ -1,39 +0,0 @@ -# Class: VCS::SVN -**Inherits:** VCS - - - - -# Class Methods -## revision_name(rev ) [](#method-c-revision_name) -## search_root(path ) [](#method-c-search_root) - -#Instance Methods -## _get_revisions(path, srcdirnil) [](#method-i-_get_revisions) - -## after_export(dir) [](#method-i-after_export) - -## branch(name) [](#method-i-branch) - -## branch_beginning(url) [](#method-i-branch_beginning) - -## branch_list(pat) [](#method-i-branch_list) - -## commit() [](#method-i-commit) - -## export(revision, url, dir, keep_tempfalse) [](#method-i-export) - -## export_changelog(url'.', fromnil, tonil, _pathnil, path:_path) [](#method-i-export_changelog) - -## get_info() [](#method-i-get_info) - -## grep(pat, tag, *files, &block) [](#method-i-grep) - -## tag(name) [](#method-i-tag) - -## trunk() [](#method-i-trunk) - -## url() [](#method-i-url) - -## wcroot() [](#method-i-wcroot) - diff --git a/example/ruby/VPath.md b/example/ruby/VPath.md deleted file mode 100644 index 743f86e..0000000 --- a/example/ruby/VPath.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: VPath -**Inherits:** Object - - - - -# Attributes -## separator[RW] [](#attribute-i-separator) -Returns the value of attribute separator. - - -#Instance Methods -## add(path) [](#method-i-add) - -## def_options(opt) [](#method-i-def_options) - -## foreach(file, *args, &block) [](#method-i-foreach) - -## initialize(*list) [](#method-i-initialize) - -**@return** [VPath] a new instance of VPath - -## inspect() [](#method-i-inspect) - -## list() [](#method-i-list) - -## open(*args) [](#method-i-open) - -## process(*args, &block) [](#method-i-process) - -## read(*args) [](#method-i-read) - -## search(meth, base, *rest) [](#method-i-search) - -## strip(path) [](#method-i-strip) - diff --git a/example/ruby/VariableMatcher.md b/example/ruby/VariableMatcher.md deleted file mode 100644 index 5334307..0000000 --- a/example/ruby/VariableMatcher.md +++ /dev/null @@ -1,27 +0,0 @@ -# Class: VariableMatcher -**Inherits:** Object - - - - -# Attributes -## description[RW] [](#attribute-c-description) -Returns the value of attribute description. - -## variables_method[RW] [](#attribute-c-variables_method) -Returns the value of attribute variables_method. - - -#Instance Methods -## failure_message() [](#method-i-failure_message) - -## initialize(variable) [](#method-i-initialize) - -**@return** [VariableMatcher] a new instance of VariableMatcher - -## matches?(object) [](#method-i-matches?) - -**@return** [Boolean] - -## negative_failure_message() [](#method-i-negative_failure_message) - diff --git a/example/ruby/VariableNameCheckTest.md b/example/ruby/VariableNameCheckTest.md deleted file mode 100644 index cb47004..0000000 --- a/example/ruby/VariableNameCheckTest.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: VariableNameCheckTest -**Inherits:** Test::Unit::TestCase - -**Includes:** DidYouMean::TestHelper - - - - - -#Instance Methods -## assert_correction(expected, array) [](#method-i-assert_correction) - -## setup() [](#method-i-setup) - -## test_corrections_include_class_variable_name() [](#method-i-test_corrections_include_class_variable_name) - -## test_corrections_include_instance_method() [](#method-i-test_corrections_include_instance_method) - -## test_corrections_include_instance_variable_name() [](#method-i-test_corrections_include_instance_variable_name) - -## test_corrections_include_local_variable_name() [](#method-i-test_corrections_include_local_variable_name) - -## test_corrections_include_method_from_module() [](#method-i-test_corrections_include_method_from_module) - -## test_corrections_include_private_method() [](#method-i-test_corrections_include_private_method) - -## test_corrections_include_ruby_predefined_objects() [](#method-i-test_corrections_include_ruby_predefined_objects) - -## test_exclude_duplicates_with_same_name() [](#method-i-test_exclude_duplicates_with_same_name) - -## test_exclude_typical_incorrect_suggestions() [](#method-i-test_exclude_typical_incorrect_suggestions) - -## test_struct_name_error() [](#method-i-test_struct_name_error) - -## test_suggests_yield() [](#method-i-test_suggests_yield) - diff --git a/example/ruby/VariableNameCheckTest/User.md b/example/ruby/VariableNameCheckTest/User.md deleted file mode 100644 index 03806c0..0000000 --- a/example/ruby/VariableNameCheckTest/User.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: VariableNameCheckTest::User -**Inherits:** Object - - - - - -#Instance Methods -## first_name() [](#method-i-first_name) - -## initialize() [](#method-i-initialize) - -**@return** [User] a new instance of User - -## to_s() [](#method-i-to_s) - diff --git a/example/ruby/VariableNameCheckTest/UserModule.md b/example/ruby/VariableNameCheckTest/UserModule.md deleted file mode 100644 index 7f4f2e9..0000000 --- a/example/ruby/VariableNameCheckTest/UserModule.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: VariableNameCheckTest::UserModule - - - - - -#Instance Methods -## from_module() [](#method-i-from_module) - diff --git a/example/ruby/VariablesSpecs.md b/example/ruby/VariablesSpecs.md deleted file mode 100644 index e45c5c2..0000000 --- a/example/ruby/VariablesSpecs.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: VariablesSpecs - - - - -# Class Methods -## false() [](#method-c-false) -## reverse_foo(a , b ) [](#method-c-reverse_foo) - diff --git a/example/ruby/VariablesSpecs/ArrayLike.md b/example/ruby/VariablesSpecs/ArrayLike.md deleted file mode 100644 index eac8dc2..0000000 --- a/example/ruby/VariablesSpecs/ArrayLike.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: VariablesSpecs::ArrayLike -**Inherits:** Object - - - - - -#Instance Methods -## initialize(array) [](#method-i-initialize) - -**@return** [ArrayLike] a new instance of ArrayLike - -## to_a() [](#method-i-to_a) - diff --git a/example/ruby/VariablesSpecs/ArraySubclass.md b/example/ruby/VariablesSpecs/ArraySubclass.md deleted file mode 100644 index cb39882..0000000 --- a/example/ruby/VariablesSpecs/ArraySubclass.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: VariablesSpecs::ArraySubclass -**Inherits:** Array - - - - - diff --git a/example/ruby/VariablesSpecs/Chain.md b/example/ruby/VariablesSpecs/Chain.md deleted file mode 100644 index b223540..0000000 --- a/example/ruby/VariablesSpecs/Chain.md +++ /dev/null @@ -1,9 +0,0 @@ -# Class: VariablesSpecs::Chain -**Inherits:** Object - - - - -# Class Methods -## without_parenthesis(a ) [](#method-c-without_parenthesis) - diff --git a/example/ruby/VariablesSpecs/EvalOrder.md b/example/ruby/VariablesSpecs/EvalOrder.md deleted file mode 100644 index 7c6029a..0000000 --- a/example/ruby/VariablesSpecs/EvalOrder.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: VariablesSpecs::EvalOrder -**Inherits:** Object - - - - -# Attributes -## order[RW] [](#attribute-i-order) -Returns the value of attribute order. - - -#Instance Methods -## <<(value) [](#method-i-<<) - -## a() [](#method-i-a) - -## b() [](#method-i-b) - -## bar() [](#method-i-bar) - -## foo() [](#method-i-foo) - -## initialize() [](#method-i-initialize) - -**@return** [EvalOrder] a new instance of EvalOrder - -## node() [](#method-i-node) - -## reset() [](#method-i-reset) - diff --git a/example/ruby/VariablesSpecs/EvalOrder/BarClass.md b/example/ruby/VariablesSpecs/EvalOrder/BarClass.md deleted file mode 100644 index d1c5d93..0000000 --- a/example/ruby/VariablesSpecs/EvalOrder/BarClass.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: VariablesSpecs::EvalOrder::BarClass -**Inherits:** Object - - - - -# Attributes -## evaluator[RW] [](#attribute-i-evaluator) -Returns the value of attribute evaluator. - - -#Instance Methods -## baz=(_value) [](#method-i-baz=) - -## initialize(evaluator) [](#method-i-initialize) - -**@return** [BarClass] a new instance of BarClass - diff --git a/example/ruby/VariablesSpecs/EvalOrder/FooClass.md b/example/ruby/VariablesSpecs/EvalOrder/FooClass.md deleted file mode 100644 index 13bff90..0000000 --- a/example/ruby/VariablesSpecs/EvalOrder/FooClass.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: VariablesSpecs::EvalOrder::FooClass -**Inherits:** Object - - - - -# Attributes -## evaluator[RW] [](#attribute-i-evaluator) -Returns the value of attribute evaluator. - - -#Instance Methods -## []=(_index, _value) [](#method-i-[]=) - -## initialize(evaluator) [](#method-i-initialize) - -**@return** [FooClass] a new instance of FooClass - diff --git a/example/ruby/VariablesSpecs/EvalOrder/Node.md b/example/ruby/VariablesSpecs/EvalOrder/Node.md deleted file mode 100644 index d85a91d..0000000 --- a/example/ruby/VariablesSpecs/EvalOrder/Node.md +++ /dev/null @@ -1,14 +0,0 @@ -# Class: VariablesSpecs::EvalOrder::Node -**Inherits:** Object - - - - -# Attributes -## left[RW] [](#attribute-i-left) -Returns the value of attribute left. - -## right[RW] [](#attribute-i-right) -Returns the value of attribute right. - - diff --git a/example/ruby/VariablesSpecs/Hashalike.md b/example/ruby/VariablesSpecs/Hashalike.md deleted file mode 100644 index 0b64448..0000000 --- a/example/ruby/VariablesSpecs/Hashalike.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: VariablesSpecs::Hashalike -**Inherits:** Object - - - - - -#Instance Methods -## [](k) [](#method-i-[]) - -## []=(k, v) [](#method-i-[]=) - diff --git a/example/ruby/VariablesSpecs/OpAsgn.md b/example/ruby/VariablesSpecs/OpAsgn.md deleted file mode 100644 index 9e29fcd..0000000 --- a/example/ruby/VariablesSpecs/OpAsgn.md +++ /dev/null @@ -1,24 +0,0 @@ -# Class: VariablesSpecs::OpAsgn -**Inherits:** Object - - - - -# Attributes -## a[RW] [](#attribute-i-a) -Returns the value of attribute a. - -## b[RW] [](#attribute-i-b) -Returns the value of attribute b. - -## side_effect[RW] [](#attribute-i-side_effect) -Returns the value of attribute side_effect. - - -#Instance Methods -## do_bool_side_effects() [](#method-i-do_bool_side_effects) - -## do_more_side_effects() [](#method-i-do_more_side_effects) - -## do_side_effect() [](#method-i-do_side_effect) - diff --git a/example/ruby/VariablesSpecs/ParAsgn.md b/example/ruby/VariablesSpecs/ParAsgn.md deleted file mode 100644 index 150d7a1..0000000 --- a/example/ruby/VariablesSpecs/ParAsgn.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: VariablesSpecs::ParAsgn -**Inherits:** Object - - - - -# Attributes -## x[RW] [](#attribute-i-x) -Returns the value of attribute x. - - -#Instance Methods -## inc() [](#method-i-inc) - -## initialize() [](#method-i-initialize) - -**@return** [ParAsgn] a new instance of ParAsgn - -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/VariablesSpecs/PrivateMethods.md b/example/ruby/VariablesSpecs/PrivateMethods.md deleted file mode 100644 index f37ddbe..0000000 --- a/example/ruby/VariablesSpecs/PrivateMethods.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: VariablesSpecs::PrivateMethods -**Inherits:** Object - - - - - diff --git a/example/ruby/VariablesSpecs/ToAryNil.md b/example/ruby/VariablesSpecs/ToAryNil.md deleted file mode 100644 index dfdeba6..0000000 --- a/example/ruby/VariablesSpecs/ToAryNil.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: VariablesSpecs::ToAryNil -**Inherits:** Object - - - - - -#Instance Methods -## to_ary() [](#method-i-to_ary) - diff --git a/example/ruby/Vec.md b/example/ruby/Vec.md deleted file mode 100644 index e79a217..0000000 --- a/example/ruby/Vec.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: Vec -**Inherits:** Object - - - - -# Attributes -## x[RW] [](#attribute-i-x) -Returns the value of attribute x. - -## y[RW] [](#attribute-i-y) -Returns the value of attribute y. - -## z[RW] [](#attribute-i-z) -Returns the value of attribute z. - - -#Instance Methods -## initialize(x, y, z) [](#method-i-initialize) - -**@return** [Vec] a new instance of Vec - -## vadd(b) [](#method-i-vadd) - -## vcross(b) [](#method-i-vcross) - -## vdot(b) [](#method-i-vdot) - -## vlength() [](#method-i-vlength) - -## vnormalize() [](#method-i-vnormalize) - -## vsub(b) [](#method-i-vsub) - diff --git a/example/ruby/VersionGuard.md b/example/ruby/VersionGuard.md deleted file mode 100644 index 7b522ca..0000000 --- a/example/ruby/VersionGuard.md +++ /dev/null @@ -1,18 +0,0 @@ -# Class: VersionGuard -**Inherits:** SpecGuard - - - - -# Class Methods -## kernel_version() [](#method-c-kernel_version) - -#Instance Methods -## initialize(version, requirement) [](#method-i-initialize) - -**@return** [VersionGuard] a new instance of VersionGuard - -## match?() [](#method-i-match?) - -**@return** [Boolean] - diff --git a/example/ruby/WIN32COMGen.md b/example/ruby/WIN32COMGen.md deleted file mode 100644 index 68713ba..0000000 --- a/example/ruby/WIN32COMGen.md +++ /dev/null @@ -1,64 +0,0 @@ -# Class: WIN32COMGen -**Inherits:** Object - - - - -# Attributes -## typelib[RW] [](#attribute-i-typelib) -Returns the value of attribute typelib. - - -#Instance Methods -## class_name(klass) [](#method-i-class_name) - -## define_class(klass, ioSTDOUT) [](#method-i-define_class) - -## define_include() [](#method-i-define_include) - -## define_initialize(klass) [](#method-i-define_initialize) - -## define_instance_variables() [](#method-i-define_instance_variables) - -## define_method_missing() [](#method-i-define_method_missing) - -## define_module(klass, ioSTDOUT) [](#method-i-define_module) - -## generate(ioSTDOUT) [](#method-i-generate) - -## generate_args(method) [](#method-i-generate_args) - -## generate_argtype(typedetails) [](#method-i-generate_argtype) - -## generate_argtypes(method, proptypes) [](#method-i-generate_argtypes) - -## generate_class(klass, ioSTDOUT) [](#method-i-generate_class) - -## generate_constants(klass, ioSTDOUT) [](#method-i-generate_constants) - -## generate_func_methods(klass, ioSTDOUT) [](#method-i-generate_func_methods) - -## generate_method(method, disptype, ioSTDOUT, typesnil) [](#method-i-generate_method) - -## generate_method_args_help(method) [](#method-i-generate_method_args_help) - -## generate_method_body(method, disptype, typesnil) [](#method-i-generate_method_body) - -## generate_method_help(method, typenil) [](#method-i-generate_method_help) - -## generate_methods(klass, ioSTDOUT) [](#method-i-generate_methods) - -## generate_properties_with_args(klass, ioSTDOUT) [](#method-i-generate_properties_with_args) - -## generate_propget_methods(klass, ioSTDOUT) [](#method-i-generate_propget_methods) - -## generate_propput_methods(klass, ioSTDOUT) [](#method-i-generate_propput_methods) - -## generate_propputref_methods(klass, ioSTDOUT) [](#method-i-generate_propputref_methods) - -## initialize(typelib) [](#method-i-initialize) - -**@return** [WIN32COMGen] a new instance of WIN32COMGen - -## ole_classes(typelib) [](#method-i-ole_classes) - diff --git a/example/ruby/WIN32OLE.md b/example/ruby/WIN32OLE.md deleted file mode 100644 index f2f6951..0000000 --- a/example/ruby/WIN32OLE.md +++ /dev/null @@ -1,366 +0,0 @@ -# Class: WIN32OLE -**Inherits:** Object - - -`WIN32OLE` objects represent OLE Automation object in Ruby. - - By using +WIN32OLE+, you can access OLE server like VBScript. - - Here is sample script. - - require 'win32ole' - - excel = WIN32OLE.new('Excel.Application') - excel.visible = true - workbook = excel.Workbooks.Add(); - worksheet = workbook.Worksheets(1); - worksheet.Range("A1:D1").value = ["North","South","East","West"]; - worksheet.Range("A2:B2").value = [5.2, 10]; - worksheet.Range("C2").value = 8; - worksheet.Range("D2").value = 20; - - range = worksheet.Range("A1:D2"); - range.select - chart = workbook.Charts.Add; - - workbook.saved = true; - - excel.ActiveWorkbook.Close(0); - excel.Quit(); - - Unfortunately, +WIN32OLE+ doesn't support the argument passed by - reference directly. - Instead, +WIN32OLE+ provides WIN32OLE::ARGV or WIN32OLE::Variant object. - If you want to get the result value of argument passed by reference, - you can use WIN32OLE::ARGV or WIN32OLE::Variant. - - oleobj.method(arg1, arg2, refargv3) - puts WIN32OLE::ARGV[2] # the value of refargv3 after called oleobj.method - - or - - refargv3 = WIN32OLE::Variant.new(XXX, - WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_XXX) - oleobj.method(arg1, arg2, refargv3) - p refargv3.value # the value of refargv3 after called oleobj.method. - - -# Class Methods -## codepage() [](#method-c-codepage) -Returns current codepage. - WIN32OLE.codepage # => WIN32OLE::CP_ACP -**@overload** [] - -## codepage=(vcp ) [](#method-c-codepage=) -Sets current codepage. The WIN32OLE.codepage is initialized according to -Encoding.default_internal. If Encoding.default_internal is nil then -WIN32OLE.codepage is initialized according to Encoding.default_external. - - WIN32OLE.codepage = WIN32OLE::CP_UTF8 - WIN32OLE.codepage = 65001 -**@overload** [] - -## connect(*args ) [](#method-c-connect) -Returns running OLE Automation object or WIN32OLE object from moniker. 1st -argument should be OLE program id or class id or moniker. - - WIN32OLE.connect('Excel.Application') # => WIN32OLE object which represents running Excel. -**@overload** [] - -## const_load(*args ) [](#method-c-const_load) -Defines the constants of OLE Automation server as mod's constants. The first -argument is WIN32OLE object or type library name. If 2nd argument is omitted, -the default is WIN32OLE. The first letter of Ruby's constant variable name is -upper case, so constant variable name of WIN32OLE object is capitalized. For -example, the 'xlTop' constant of Excel is changed to 'XlTop' in WIN32OLE. If -the first letter of constant variable is not [A-Z], then the constant is -defined as CONSTANTS hash element. - - module EXCEL_CONST - end - excel = WIN32OLE.new('Excel.Application') - WIN32OLE.const_load(excel, EXCEL_CONST) - puts EXCEL_CONST::XlTop # => -4160 - puts EXCEL_CONST::CONSTANTS['_xlDialogChartSourceData'] # => 541 - - WIN32OLE.const_load(excel) - puts WIN32OLE::XlTop # => -4160 - - module MSO - end - WIN32OLE.const_load('Microsoft Office 9.0 Object Library', MSO) - puts MSO::MsoLineSingle # => 1 -**@overload** [] - -## create_guid() [](#method-c-create_guid) -Creates GUID. - WIN32OLE.create_guid # => {1CB530F1-F6B1-404D-BCE6-1959BF91F4A8} -**@overload** [] - -## locale() [](#method-c-locale) -Returns current locale id (lcid). The default locale is -WIN32OLE::LOCALE_SYSTEM_DEFAULT. - - lcid = WIN32OLE.locale -**@overload** [] - -## locale=(vlcid ) [](#method-c-locale=) -Sets current locale id (lcid). - - WIN32OLE.locale = 1033 # set locale English(U.S) - obj = WIN32OLE::Variant.new("$100,000", WIN32OLE::VARIANT::VT_CY) -**@overload** [] - -## ole_free(obj ) [](#method-c-ole_free) -Invokes Release method of Dispatch interface of WIN32OLE object. You should -not use this method because this method exists only for debugging WIN32OLE. -The return value is reference counter of OLE object. -**@overload** [] - -## ole_initialize() [](#method-c-ole_initialize) -:nodoc: -## ole_reference_count(obj ) [](#method-c-ole_reference_count) -Returns reference counter of Dispatch interface of WIN32OLE object. You should -not use this method because this method exists only for debugging WIN32OLE. -**@overload** [] - -## ole_show_help(*args ) [](#method-c-ole_show_help) -Displays helpfile. The 1st argument specifies WIN32OLE::Type object or -WIN32OLE::Method object or helpfile. - - excel = WIN32OLE.new('Excel.Application') - typeobj = excel.ole_type - WIN32OLE.ole_show_help(typeobj) -**@overload** [] - -## ole_uninitialize() [](#method-c-ole_uninitialize) -:nodoc: - -#Instance Methods -## [](*args) [](#method-i-[]) -Returns the value of Collection specified by a1, a2,.... - - dict = WIN32OLE.new('Scripting.Dictionary') - dict.add('ruby', 'Ruby') - puts dict['ruby'] # => 'Ruby' (same as `puts dict.item('ruby')') - -Remark: You can not use this method to get the property. - excel = WIN32OLE.new('Excel.Application') - # puts excel['Visible'] This is error !!! - puts excel.Visible # You should to use this style to get the property. - -**@overload** [] - -## []=(*args) [](#method-i-[]=) -Sets the value to WIN32OLE object specified by a1, a2, ... - - dict = WIN32OLE.new('Scripting.Dictionary') - dict.add('ruby', 'RUBY') - dict['ruby'] = 'Ruby' - puts dict['ruby'] # => 'Ruby' - -Remark: You can not use this method to set the property value. - - excel = WIN32OLE.new('Excel.Application') - # excel['Visible'] = true # This is error !!! - excel.Visible = true # You should to use this style to set the property. - -**@overload** [] - -## _getproperty(dispid, args, types) [](#method-i-_getproperty) -Runs the early binding method to get property. The 1st argument specifies -dispatch ID, the 2nd argument specifies the array of arguments, the 3rd -argument specifies the array of the type of arguments. - - excel = WIN32OLE.new('Excel.Application') - puts excel._getproperty(558, [], []) # same effect as puts excel.visible - -**@overload** [] - -## _invoke(dispid, args, types) [](#method-i-_invoke) -Runs the early binding method. The 1st argument specifies dispatch ID, the 2nd -argument specifies the array of arguments, the 3rd argument specifies the -array of the type of arguments. - - excel = WIN32OLE.new('Excel.Application') - excel._invoke(302, [], []) # same effect as excel.Quit - -**@overload** [] - -## _setproperty(dispid, args, types) [](#method-i-_setproperty) -Runs the early binding method to set property. The 1st argument specifies -dispatch ID, the 2nd argument specifies the array of arguments, the 3rd -argument specifies the array of the type of arguments. - - excel = WIN32OLE.new('Excel.Application') - excel._setproperty(558, [true], [WIN32OLE::VARIANT::VT_BOOL]) # same effect as excel.visible = true - -**@overload** [] - -## each() [](#method-i-each) -Iterates over each item of OLE collection which has IEnumVARIANT interface. - - excel = WIN32OLE.new('Excel.Application') - book = excel.workbooks.add - sheets = book.worksheets(1) - cells = sheets.cells("A1:A5") - cells.each do |cell| - cell.value = 10 - end - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Returns a new WIN32OLE object(OLE Automation object). The first argument -server specifies OLE Automation server. The first argument should be CLSID or -PROGID. If second argument host specified, then returns OLE Automation object -on host. If :license keyword argument is provided, -IClassFactory2::CreateInstanceLic is used to create instance of licensed -server. - - WIN32OLE.new('Excel.Application') # => Excel OLE Automation WIN32OLE object. - WIN32OLE.new('{00024500-0000-0000-C000-000000000046}') # => Excel OLE Automation WIN32OLE object. - -**@overload** [] - -**@overload** [] - -## invoke(*args) [](#method-i-invoke) -Runs OLE method. The first argument specifies the method name of OLE -Automation object. The others specify argument of the *method*. If you can not -execute *method* directly, then use this method instead. - - excel = WIN32OLE.new('Excel.Application') - excel.invoke('Quit') # => same as excel.Quit - -**@overload** [] - -## method_missing(*args) [](#method-i-method_missing) -Calls WIN32OLE#invoke method. - -**@overload** [] - -## methods(*args) [](#method-i-methods) -By overriding Object#methods, WIN32OLE might work well with did_you_mean gem. -This is experimental. - - require 'win32ole' - dict = WIN32OLE.new('Scripting.Dictionary') - dict.Ade('a', 1) - #=> Did you mean? Add - -## ole_activex_initialize() [](#method-i-ole_activex_initialize) -Initialize WIN32OLE object(ActiveX Control) by calling -IPersistMemory::InitNew. - -Before calling OLE method, some kind of the ActiveX controls created with MFC -should be initialized by calling IPersistXXX::InitNew. - -If and only if you received the exception "HRESULT error code: 0x8000ffff -catastrophic failure", try this method before invoking any ole_method. - - obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control") - obj.ole_activex_initialize - obj.method(...) - -**@overload** [] - -## ole_free() [](#method-i-ole_free) -invokes Release method of Dispatch interface of WIN32OLE object. Usually, you -do not need to call this method because Release method called automatically -when WIN32OLE object garbaged. - -**@overload** [] - -## ole_func_methods() [](#method-i-ole_func_methods) -Returns the array of WIN32OLE::Method object . The element of the array is -property (settable) of WIN32OLE object. - - excel = WIN32OLE.new('Excel.Application') - properties = excel.ole_func_methods - -**@overload** [] - -## ole_get_methods() [](#method-i-ole_get_methods) -Returns the array of WIN32OLE::Method object . The element of the array is -property (gettable) of WIN32OLE object. - - excel = WIN32OLE.new('Excel.Application') - properties = excel.ole_get_methods - -**@overload** [] - -## ole_method(cmdname) [](#method-i-ole_method) -Returns WIN32OLE::Method object corresponding with method specified by 1st -argument. - - excel = WIN32OLE.new('Excel.Application') - method = excel.ole_method_help('Quit') - -**@overload** [] - -## ole_methods() [](#method-i-ole_methods) -Returns the array of WIN32OLE::Method object. The element is OLE method of -WIN32OLE object. - - excel = WIN32OLE.new('Excel.Application') - methods = excel.ole_methods - -**@overload** [] - -## ole_put_methods() [](#method-i-ole_put_methods) -Returns the array of WIN32OLE::Method object . The element of the array is -property (settable) of WIN32OLE object. - - excel = WIN32OLE.new('Excel.Application') - properties = excel.ole_put_methods - -**@overload** [] - -## ole_query_interface(str_iid) [](#method-i-ole_query_interface) -Returns WIN32OLE object for a specific dispatch or dual interface specified by -iid. - - ie = WIN32OLE.new('InternetExplorer.Application') - ie_web_app = ie.ole_query_interface('{0002DF05-0000-0000-C000-000000000046}') # => WIN32OLE object for dispinterface IWebBrowserApp - -**@overload** [] - -## ole_respond_to?(method) [](#method-i-ole_respond_to?) -Returns true when OLE object has OLE method, otherwise returns false. - - ie = WIN32OLE.new('InternetExplorer.Application') - ie.ole_respond_to?("gohome") => true - -**@overload** [] - -## ole_type() [](#method-i-ole_type) -Returns WIN32OLE::Type object. - - excel = WIN32OLE.new('Excel.Application') - tobj = excel.ole_type - -**@overload** [] - -## ole_typelib() [](#method-i-ole_typelib) -Returns the WIN32OLE::TypeLib object. The object represents the type library -which contains the WIN32OLE object. - - excel = WIN32OLE.new('Excel.Application') - tlib = excel.ole_typelib - puts tlib.name # -> 'Microsoft Excel 9.0 Object Library' - -**@overload** [] - -## setproperty(*args) [](#method-i-setproperty) -Sets property of OLE object. When you want to set property with argument, you -can use this method. - - excel = WIN32OLE.new('Excel.Application') - excel.Visible = true - book = excel.workbooks.add - sheet = book.worksheets(1) - sheet.setproperty('Cells', 1, 2, 10) # => The B1 cell value is 10. - -**@overload** [] - diff --git a/example/ruby/WIN32OLE/Event.md b/example/ruby/WIN32OLE/Event.md deleted file mode 100644 index ce88e6b..0000000 --- a/example/ruby/WIN32OLE/Event.md +++ /dev/null @@ -1,127 +0,0 @@ -# Class: WIN32OLE::Event -**Inherits:** Object - - -`WIN32OLE::Event` objects controls OLE event. - - -# Class Methods -## message_loop() [](#method-c-message_loop) -Translates and dispatches Windows message. -**@overload** [] - - -#Instance Methods -## handler() [](#method-i-handler) -returns handler object. - -**@overload** [] - -## handler=(val) [](#method-i-handler=) -sets event handler object. If handler object has onXXX method according to XXX -event, then onXXX method is called when XXX event occurs. - -If handler object has method_missing and there is no method according to the -event, then method_missing called and 1-st argument is event name. - -If handler object has onXXX method and there is block defined by -`on_event('XXX'){}`, then block is executed but handler object method is not -called when XXX event occurs. - - class Handler - def onStatusTextChange(text) - puts "StatusTextChanged" - end - def onPropertyChange(prop) - puts "PropertyChanged" - end - def method_missing(ev, *arg) - puts "other event #{ev}" - end - end - - handler = Handler.new - ie = WIN32OLE.new('InternetExplorer.Application') - ev = WIN32OLE::Event.new(ie) - ev.on_event("StatusTextChange") {|*args| - puts "this block executed." - puts "handler.onStatusTextChange method is not called." - } - ev.handler = handler - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Returns OLE event object. The first argument specifies WIN32OLE object. The -second argument specifies OLE event name. - ie = WIN32OLE.new('InternetExplorer.Application') - ev = WIN32OLE::Event.new(ie, 'DWebBrowserEvents') - -**@overload** [] - -## off_event(*args) [](#method-i-off_event) -removes the callback of event. - - ie = WIN32OLE.new('InternetExplorer.Application') - ev = WIN32OLE::Event.new(ie) - ev.on_event('BeforeNavigate2') {|*args| - args.last[6] = true - } - # ... - ev.off_event('BeforeNavigate2') - # ... - -**@overload** [] - -## on_event(*args) [](#method-i-on_event) -Defines the callback event. If argument is omitted, this method defines the -callback of all events. If you want to modify reference argument in callback, -return hash in callback. If you want to return value to OLE server as result -of callback use `return' or :return. - - ie = WIN32OLE.new('InternetExplorer.Application') - ev = WIN32OLE::Event.new(ie) - ev.on_event("NavigateComplete") {|url| puts url} - ev.on_event() {|ev, *args| puts "#{ev} fired"} - - ev.on_event("BeforeNavigate2") {|*args| - # ... - # set true to BeforeNavigate reference argument `Cancel'. - # Cancel is 7-th argument of BeforeNavigate, - # so you can use 6 as key of hash instead of 'Cancel'. - # The argument is counted from 0. - # The hash key of 0 means first argument.) - {:Cancel => true} # or {'Cancel' => true} or {6 => true} - } - - ev.on_event(event_name) {|*args| - {:return => 1, :xxx => yyy} - } - -**@overload** [] - -## on_event_with_outargs(*args) [](#method-i-on_event_with_outargs) -Defines the callback of event. If you want modify argument in callback, you -could use this method instead of WIN32OLE::Event#on_event. - - ie = WIN32OLE.new('InternetExplorer.Application') - ev = WIN32OLE::Event.new(ie) - ev.on_event_with_outargs('BeforeNavigate2') {|*args| - args.last[6] = true - } - -**@overload** [] - -## unadvise() [](#method-i-unadvise) -disconnects OLE server. If this method called, then the WIN32OLE::Event object -does not receive the OLE server event any more. This method is trial -implementation. - - ie = WIN32OLE.new('InternetExplorer.Application') - ev = WIN32OLE::Event.new(ie) - ev.on_event() { something } - # ... - ev.unadvise - -**@overload** [] - diff --git a/example/ruby/WIN32OLE/Method.md b/example/ruby/WIN32OLE/Method.md deleted file mode 100644 index 55abd69..0000000 --- a/example/ruby/WIN32OLE/Method.md +++ /dev/null @@ -1,172 +0,0 @@ -# Class: WIN32OLE::Method -**Inherits:** Object - - -`WIN32OLE::Method` objects represent OLE method information. - - - -#Instance Methods -## dispid() [](#method-i-dispid) -Returns dispatch ID. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.dispid # => 181 - -**@overload** [] - -## event?() [](#method-i-event?) -Returns true if the method is event. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SheetActivate') - puts method.event? # => true - -**@overload** [] - -**@return** [Boolean] - -## event_interface() [](#method-i-event_interface) -Returns event interface name if the method is event. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SheetActivate') - puts method.event_interface # => WorkbookEvents - -**@overload** [] - -## helpcontext() [](#method-i-helpcontext) -Returns help context. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.helpcontext # => 65717 - -**@overload** [] - -## helpfile() [](#method-i-helpfile) -Returns help file. If help file is not found, then the method returns nil. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.helpfile # => C:\...\VBAXL9.CHM - -**@overload** [] - -## helpstring() [](#method-i-helpstring) -Returns help string of OLE method. If the help string is not found, then the -method returns nil. - tobj = WIN32OLE::Type.new('Microsoft Internet Controls', 'IWebBrowser') - method = WIN32OLE::Method.new(tobj, 'Navigate') - puts method.helpstring # => Navigates to a URL or file. - -**@overload** [] - -## initialize(oletype, method) [](#method-i-initialize) -Returns a new WIN32OLE::Method object which represents the information about -OLE method. The first argument *ole_type* specifies WIN32OLE::Type object. The -second argument *method* specifies OLE method name defined OLE class which -represents WIN32OLE::Type object. - - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns the method name with class name. - -**@overload** [] - -## invkind() [](#method-i-invkind) -Returns the method invoke kind. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.invkind # => 1 - -**@overload** [] - -## invoke_kind() [](#method-i-invoke_kind) -Returns the method kind string. The string is "UNKNOWN" or "PROPERTY" or -"PROPERTY" or "PROPERTYGET" or "PROPERTYPUT" or "PROPERTYPPUTREF" or "FUNC". - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.invoke_kind # => "FUNC" - -**@overload** [] - -## name() [](#method-i-name) -Returns the name of the method. - - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - puts method.name # => SaveAs - -**@overload** [] - -## offset_vtbl() [](#method-i-offset_vtbl) -Returns the offset ov VTBL. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.offset_vtbl # => 40 - -**@overload** [] - -## params() [](#method-i-params) -returns array of WIN32OLE::Param object corresponding with method parameters. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - p method.params # => [Filename, FileFormat, Password, WriteResPassword, - ReadOnlyRecommended, CreateBackup, AccessMode, - ConflictResolution, AddToMru, TextCodepage, - TextVisualLayout] - -**@overload** [] - -## return_type() [](#method-i-return_type) -Returns string of return value type of method. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.return_type # => Workbook - -**@overload** [] - -## return_type_detail() [](#method-i-return_type_detail) -Returns detail information of return value type of method. The information is -array. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"] - -**@overload** [] - -## return_vtype() [](#method-i-return_vtype) -Returns number of return value type of method. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.return_vtype # => 26 - -**@overload** [] - -## size_opt_params() [](#method-i-size_opt_params) -Returns the size of optional parameters. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - puts method.size_opt_params # => 4 - -**@overload** [] - -## size_params() [](#method-i-size_params) -Returns the size of arguments of the method. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - puts method.size_params # => 11 - -**@overload** [] - -## visible?() [](#method-i-visible?) -Returns true if the method is public. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbooks') - method = WIN32OLE::Method.new(tobj, 'Add') - puts method.visible? # => true - -**@overload** [] - -**@return** [Boolean] - diff --git a/example/ruby/WIN32OLE/Param.md b/example/ruby/WIN32OLE/Param.md deleted file mode 100644 index 8ef8409..0000000 --- a/example/ruby/WIN32OLE/Param.md +++ /dev/null @@ -1,136 +0,0 @@ -# Class: WIN32OLE::Param -**Inherits:** Object - - -`WIN32OLE::Param` objects represent param information of - the OLE method. - - - -#Instance Methods -## default() [](#method-i-default) -Returns default value. If the default value does not exist, this method -returns nil. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - method.params.each do |param| - if param.default - puts "#{param.name} (= #{param.default})" - else - puts "#{param}" - end - end - -The above script result is following: - Filename - FileFormat - Password - WriteResPassword - ReadOnlyRecommended - CreateBackup - AccessMode (= 1) - ConflictResolution - AddToMru - TextCodepage - TextVisualLayout - -**@overload** [] - -## initialize(olemethod, n) [](#method-i-initialize) -Returns WIN32OLE::Param object which represents OLE parameter information. 1st -argument should be WIN32OLE::Method object. 2nd argument `n' is n-th parameter -of the method specified by 1st argument. - - tobj = WIN32OLE::Type.new('Microsoft Scripting Runtime', 'IFileSystem') - method = WIN32OLE::Method.new(tobj, 'CreateTextFile') - param = WIN32OLE::Param.new(method, 2) # => # - -**@overload** [] - -## input?() [](#method-i-input?) -Returns true if the parameter is input. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - param1 = method.params[0] - puts param1.input? # => true - -**@overload** [] - -**@return** [Boolean] - -## inspect() [](#method-i-inspect) -Returns the parameter name with class name. If the parameter has default -value, then returns name=value string with class name. - -**@overload** [] - -## name() [](#method-i-name) -Returns name. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - param1 = method.params[0] - puts param1.name # => Filename - -**@overload** [] - -## ole_type() [](#method-i-ole_type) -Returns OLE type of WIN32OLE::Param object(parameter of OLE method). - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - param1 = method.params[0] - puts param1.ole_type # => VARIANT - -**@overload** [] - -## ole_type_detail() [](#method-i-ole_type_detail) -Returns detail information of type of argument. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'IWorksheetFunction') - method = WIN32OLE::Method.new(tobj, 'SumIf') - param1 = method.params[0] - p param1.ole_type_detail # => ["PTR", "USERDEFINED", "Range"] - -**@overload** [] - -## optional?() [](#method-i-optional?) -Returns true if argument is optional. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') - method = WIN32OLE::Method.new(tobj, 'SaveAs') - param1 = method.params[0] - puts "#{param1.name} #{param1.optional?}" # => Filename true - -**@overload** [] - -**@return** [Boolean] - -## output?() [](#method-i-output?) -Returns true if argument is output. - tobj = WIN32OLE::Type.new('Microsoft Internet Controls', 'DWebBrowserEvents') - method = WIN32OLE::Method.new(tobj, 'NewWindow') - method.params.each do |param| - puts "#{param.name} #{param.output?}" - end - -The result of above script is following: - URL false - Flags false - TargetFrameName false - PostData false - Headers false - Processed true - -**@overload** [] - -**@return** [Boolean] - -## retval?() [](#method-i-retval?) -Returns true if argument is return value. - tobj = WIN32OLE::Type.new('DirectX 7 for Visual Basic Type Library', - 'DirectPlayLobbyConnection') - method = WIN32OLE::Method.new(tobj, 'GetPlayerShortName') - param = method.params[0] - puts "#{param.name} #{param.retval?}" # => name true - -**@overload** [] - -**@return** [Boolean] - diff --git a/example/ruby/WIN32OLE/Property.md b/example/ruby/WIN32OLE/Property.md deleted file mode 100644 index 5aa6956..0000000 --- a/example/ruby/WIN32OLE/Property.md +++ /dev/null @@ -1,19 +0,0 @@ -# Class: WIN32OLE::Property -**Inherits:** Object - - -OLEProperty is a helper class of Property with arguments, used by -`olegen.rb`-generated files. - - - -#Instance Methods -## [](*args) [](#method-i-[]) - -## []=(*args) [](#method-i-[]=) - -## initialize(obj, dispid, gettypes, settypes) [](#method-i-initialize) -:stopdoc: - -**@return** [Property] a new instance of Property - diff --git a/example/ruby/WIN32OLE/QueryInterfaceError.md b/example/ruby/WIN32OLE/QueryInterfaceError.md deleted file mode 100644 index 90c455e..0000000 --- a/example/ruby/WIN32OLE/QueryInterfaceError.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: WIN32OLE::QueryInterfaceError -**Inherits:** WIN32OLE::RuntimeError - - -Raised when OLE query failed. - - - diff --git a/example/ruby/WIN32OLE/Record.md b/example/ruby/WIN32OLE/Record.md deleted file mode 100644 index c1e345d..0000000 --- a/example/ruby/WIN32OLE/Record.md +++ /dev/null @@ -1,213 +0,0 @@ -# Class: WIN32OLE::Record -**Inherits:** Object - - -`WIN32OLE::Record` objects represents VT_RECORD OLE variant. - Win32OLE returns WIN32OLE::Record object if the result value of invoking - OLE methods. - - If COM server in VB.NET ComServer project is the following: - - Imports System.Runtime.InteropServices - Public Class ComClass - Public Structure Book - _ - Public title As String - Public cost As Integer - End Structure - Public Function getBook() As Book - Dim book As New Book - book.title = "The Ruby Book" - book.cost = 20 - Return book - End Function - End Class - - then, you can retrieve getBook return value from the following - Ruby script: - - require 'win32ole' - obj = WIN32OLE.new('ComServer.ComClass') - book = obj.getBook - book.class # => WIN32OLE::Record - book.title # => "The Ruby Book" - book.cost # => 20 - - - -#Instance Methods -## initialize(typename, oleobj) [](#method-i-initialize) -Returns WIN32OLE::Record object. The first argument is struct name (String or -Symbol). The second parameter obj should be WIN32OLE object or -WIN32OLE::TypeLib object. If COM server in VB.NET ComServer project is the -following: - - Imports System.Runtime.InteropServices - Public Class ComClass - Public Structure Book - _ - Public title As String - Public cost As Integer - End Structure - End Class - -then, you can create WIN32OLE::Record object is as following: - - require 'win32ole' - obj = WIN32OLE.new('ComServer.ComClass') - book1 = WIN32OLE::Record.new('Book', obj) # => WIN32OLE::Record object - tlib = obj.ole_typelib - book2 = WIN32OLE::Record.new('Book', tlib) # => WIN32OLE::Record object - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns the OLE struct name and member name and the value of member - -If COM server in VB.NET ComServer project is the following: - - Imports System.Runtime.InteropServices - Public Class ComClass - _ - Public title As String - Public cost As Integer - End Class - -then - - srver = WIN32OLE.new('ComServer.ComClass') - obj = WIN32OLE::Record.new('Book', server) - obj.inspect # => nil, "cost" => nil}> - -**@overload** [] - -## method_missing(*args) [](#method-i-method_missing) -Returns value specified by the member name of VT_RECORD OLE variable. Or sets -value specified by the member name of VT_RECORD OLE variable. If the member -name is not correct, KeyError exception is raised. - -If COM server in VB.NET ComServer project is the following: - - Imports System.Runtime.InteropServices - Public Class ComClass - Public Structure Book - _ - Public title As String - Public cost As Integer - End Structure - End Class - -Then getting/setting value from Ruby is as the following: - - obj = WIN32OLE.new('ComServer.ComClass') - book = WIN32OLE::Record.new('Book', obj) - book.title # => nil ( book.method_missing(:title) is invoked. ) - book.title = "Ruby" # ( book.method_missing(:title=, "Ruby") is invoked. ) - -**@overload** [] - -## ole_instance_variable_get(name) [](#method-i-ole_instance_variable_get) -Returns value specified by the member name of VT_RECORD OLE object. If the -member name is not correct, KeyError exception is raised. If you can't access -member variable of VT_RECORD OLE object directly, use this method. - -If COM server in VB.NET ComServer project is the following: - - Imports System.Runtime.InteropServices - Public Class ComClass - Public Structure ComObject - Public object_id As Ineger - End Structure - End Class - -and Ruby Object class has title attribute: - -then accessing object_id of ComObject from Ruby is as the following: - - srver = WIN32OLE.new('ComServer.ComClass') - obj = WIN32OLE::Record.new('ComObject', server) - # obj.object_id returns Ruby Object#object_id - obj.ole_instance_variable_get(:object_id) # => nil - -**@overload** [] - -## ole_instance_variable_set(name, val) [](#method-i-ole_instance_variable_set) -Sets value specified by the member name of VT_RECORD OLE object. If the member -name is not correct, KeyError exception is raised. If you can't set value of -member of VT_RECORD OLE object directly, use this method. - -If COM server in VB.NET ComServer project is the following: - - Imports System.Runtime.InteropServices - Public Class ComClass - _ - Public title As String - Public cost As Integer - End Class - -then setting value of the `title' member is as following: - - srver = WIN32OLE.new('ComServer.ComClass') - obj = WIN32OLE::Record.new('Book', server) - obj.ole_instance_variable_set(:title, "The Ruby Book") - -**@overload** [] - -## to_h() [](#method-i-to_h) -Returns Ruby Hash object which represents VT_RECORD variable. The keys of Hash -object are member names of VT_RECORD OLE variable and the values of Hash -object are values of VT_RECORD OLE variable. - -If COM server in VB.NET ComServer project is the following: - - Imports System.Runtime.InteropServices - Public Class ComClass - Public Structure Book - _ - Public title As String - Public cost As Integer - End Structure - Public Function getBook() As Book - Dim book As New Book - book.title = "The Ruby Book" - book.cost = 20 - Return book - End Function - End Class - -then, the result of WIN32OLE::Record#to_h is the following: - - require 'win32ole' - obj = WIN32OLE.new('ComServer.ComClass') - book = obj.getBook - book.to_h # => {"title"=>"The Ruby Book", "cost"=>20} - -**@overload** [] - -## typename() [](#method-i-typename) -Returns the type name of VT_RECORD OLE variable. - -If COM server in VB.NET ComServer project is the following: - - Imports System.Runtime.InteropServices - Public Class ComClass - Public Structure Book - _ - Public title As String - Public cost As Integer - End Structure - Public Function getBook() As Book - Dim book As New Book - book.title = "The Ruby Book" - book.cost = 20 - Return book - End Function - End Class - -then, the result of WIN32OLE::Record#typename is the following: - - require 'win32ole' - obj = WIN32OLE.new('ComServer.ComClass') - book = obj.getBook - book.typename # => "Book" - diff --git a/example/ruby/WIN32OLE/RuntimeError.md b/example/ruby/WIN32OLE/RuntimeError.md deleted file mode 100644 index fef48f1..0000000 --- a/example/ruby/WIN32OLE/RuntimeError.md +++ /dev/null @@ -1,18 +0,0 @@ -# Exception: WIN32OLE::RuntimeError -**Inherits:** RuntimeError - - -Raised when OLE processing failed. - -EX: - - obj = WIN32OLE.new("NonExistProgID") - -raises the exception: - - WIN32OLE::RuntimeError: unknown OLE server: `NonExistProgID' - HRESULT error code:0x800401f3 - Invalid class string - - - diff --git a/example/ruby/WIN32OLE/Type.md b/example/ruby/WIN32OLE/Type.md deleted file mode 100644 index 93c0703..0000000 --- a/example/ruby/WIN32OLE/Type.md +++ /dev/null @@ -1,185 +0,0 @@ -# Class: WIN32OLE::Type -**Inherits:** Object - - -`WIN32OLE::Type` objects represent OLE type library information. - - -# Class Methods -## ole_classes(typelib ) [](#method-c-ole_classes) -Returns array of WIN32OLE::Type objects defined by the *typelib* type library. - -This method will be OBSOLETE. Use `WIN32OLE::TypeLib.new(typelib).ole_classes` -instead. -**@overload** [] - -## progids() [](#method-c-progids) -Returns array of ProgID. -**@overload** [] - -## typelibs() [](#method-c-typelibs) -Returns array of type libraries. - -This method will be OBSOLETE. Use `WIN32OLE::TypeLib.typelibs.collect{|t| -t.name}` instead. -**@overload** [] - - -#Instance Methods -## default_event_sources() [](#method-i-default_event_sources) -Returns the array of WIN32OLE::Type object which is implemented by the -WIN32OLE::Type object and having IMPLTYPEFLAG_FSOURCE and -IMPLTYPEFLAG_FDEFAULT. - tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer") - p tobj.default_event_sources # => [#] - -**@overload** [] - -## default_ole_types() [](#method-i-default_ole_types) -Returns the array of WIN32OLE::Type object which is implemented by the -WIN32OLE::Type object and having IMPLTYPEFLAG_FDEFAULT. - tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer") - p tobj.default_ole_types - # => [#, #] - -**@overload** [] - -## guid() [](#method-i-guid) -Returns GUID. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Application') - puts tobj.guid # => {00024500-0000-0000-C000-000000000046} - -## helpcontext() [](#method-i-helpcontext) -Returns helpcontext. If helpcontext is not found, then returns nil. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Worksheet') - puts tobj.helpfile # => 131185 - -**@overload** [] - -## helpfile() [](#method-i-helpfile) -Returns helpfile path. If helpfile is not found, then returns nil. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Worksheet') - puts tobj.helpfile # => C:\...\VBAXL9.CHM - -**@overload** [] - -## helpstring() [](#method-i-helpstring) -Returns help string. - tobj = WIN32OLE::Type.new('Microsoft Internet Controls', 'IWebBrowser') - puts tobj.helpstring # => Web Browser interface - -## implemented_ole_types() [](#method-i-implemented_ole_types) -Returns the array of WIN32OLE::Type object which is implemented by the -WIN32OLE::Type object. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Worksheet') - p tobj.implemented_ole_types # => [_Worksheet, DocEvents] - -**@overload** [] - -## initialize(typelib, oleclass) [](#method-i-initialize) -Returns a new WIN32OLE::Type object. The first argument *typelib* specifies -OLE type library name. The second argument specifies OLE class name. - - WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Application') - # => WIN32OLE::Type object of Application class of Excel. - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns the type name with class name. - - ie = WIN32OLE.new('InternetExplorer.Application') - ie.ole_type.inspect => # - -**@overload** [] - -## major_version() [](#method-i-major_version) -Returns major version. - tobj = WIN32OLE::Type.new('Microsoft Word 10.0 Object Library', 'Documents') - puts tobj.major_version # => 8 - -**@overload** [] - -## minor_version() [](#method-i-minor_version) -Returns minor version. - tobj = WIN32OLE::Type.new('Microsoft Word 10.0 Object Library', 'Documents') - puts tobj.minor_version # => 2 - -## name() [](#method-i-name) -Returns OLE type name. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Application') - puts tobj.name # => Application - -## ole_methods() [](#method-i-ole_methods) -Returns array of WIN32OLE::Method objects which represent OLE method defined -in OLE type library. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Worksheet') - methods = tobj.ole_methods.collect{|m| - m.name - } - # => ['Activate', 'Copy', 'Delete',....] - -## ole_type() [](#method-i-ole_type) -returns type of OLE class. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Application') - puts tobj.ole_type # => Class - -## ole_typelib() [](#method-i-ole_typelib) -Returns the WIN32OLE::TypeLib object which is including the WIN32OLE::Type -object. If it is not found, then returns nil. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Worksheet') - puts tobj.ole_typelib # => 'Microsoft Excel 9.0 Object Library' - -**@overload** [] - -## progid() [](#method-i-progid) -Returns ProgID if it exists. If not found, then returns nil. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Application') - puts tobj.progid # => Excel.Application.9 - -## source_ole_types() [](#method-i-source_ole_types) -Returns the array of WIN32OLE::Type object which is implemented by the -WIN32OLE::Type object and having IMPLTYPEFLAG_FSOURCE. - tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer") - p tobj.source_ole_types - # => [#, #] - -**@overload** [] - -## src_type() [](#method-i-src_type) -Returns source class when the OLE class is 'Alias'. - tobj = WIN32OLE::Type.new('Microsoft Office 9.0 Object Library', 'MsoRGBType') - puts tobj.src_type # => I4 - -## typekind() [](#method-i-typekind) -Returns number which represents type. - tobj = WIN32OLE::Type.new('Microsoft Word 10.0 Object Library', 'Documents') - puts tobj.typekind # => 4 - -## variables() [](#method-i-variables) -Returns array of WIN32OLE::Variable objects which represent variables defined -in OLE class. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') - vars = tobj.variables - vars.each do |v| - puts "#{v.name} = #{v.value}" - end - - The result of above sample script is follows: - xlChart = -4109 - xlDialogSheet = -4116 - xlExcel4IntlMacroSheet = 4 - xlExcel4MacroSheet = 3 - xlWorksheet = -4167 - -**@overload** [] - -## visible?() [](#method-i-visible?) -Returns true if the OLE class is public. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Application') - puts tobj.visible # => true - -**@overload** [] - -**@return** [Boolean] - diff --git a/example/ruby/WIN32OLE/TypeLib.md b/example/ruby/WIN32OLE/TypeLib.md deleted file mode 100644 index 0302211..0000000 --- a/example/ruby/WIN32OLE/TypeLib.md +++ /dev/null @@ -1,124 +0,0 @@ -# Class: WIN32OLE::TypeLib -**Inherits:** Object - - -`WIN32OLE::TypeLib` objects represent OLE tyblib information. - - -# Class Methods -## typelibs() [](#method-c-typelibs) -Returns the array of WIN32OLE::TypeLib object. - - tlibs = WIN32OLE::TypeLib.typelibs -**@overload** [] - - -#Instance Methods -## guid() [](#method-i-guid) -Returns guid string which specifies type library. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - guid = tlib.guid # -> '{00020813-0000-0000-C000-000000000046}' - -**@overload** [] - -## initialize(args) [](#method-i-initialize) -Returns a new WIN32OLE::TypeLib object. - -The first argument *typelib* specifies OLE type library name or GUID or OLE -library file. The second argument is major version or version of the type -library. The third argument is minor version. The second argument and third -argument are optional. If the first argument is type library name, then the -second and third argument are ignored. - - tlib1 = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - tlib2 = WIN32OLE::TypeLib.new('{00020813-0000-0000-C000-000000000046}') - tlib3 = WIN32OLE::TypeLib.new('{00020813-0000-0000-C000-000000000046}', 1.3) - tlib4 = WIN32OLE::TypeLib.new('{00020813-0000-0000-C000-000000000046}', 1, 3) - tlib5 = WIN32OLE::TypeLib.new("C:\\WINNT\\SYSTEM32\\SHELL32.DLL") - puts tlib1.name # -> 'Microsoft Excel 9.0 Object Library' - puts tlib2.name # -> 'Microsoft Excel 9.0 Object Library' - puts tlib3.name # -> 'Microsoft Excel 9.0 Object Library' - puts tlib4.name # -> 'Microsoft Excel 9.0 Object Library' - puts tlib5.name # -> 'Microsoft Shell Controls And Automation' - -**@overload** [] - -## inspect() [](#method-i-inspect) -Returns the type library name with class name. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - tlib.inspect # => "<#WIN32OLE::TypeLib:Microsoft Excel 9.0 Object Library>" - -**@overload** [] - -## library_name() [](#method-i-library_name) -Returns library name. If the method fails to access library name, -WIN32OLE::RuntimeError is raised. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - tlib.library_name # => Excel - -**@overload** [] - -## major_version() [](#method-i-major_version) -Returns the type library major version. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - puts tlib.major_version # -> 1 - -**@overload** [] - -## minor_version() [](#method-i-minor_version) -Returns the type library minor version. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - puts tlib.minor_version # -> 3 - -**@overload** [] - -## name() [](#method-i-name) -Returns the type library name. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - name = tlib.name # -> 'Microsoft Excel 9.0 Object Library' - -**@overload** [] - -## ole_types() [](#method-i-ole_types) -Returns the type library file path. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - classes = tlib.ole_types.collect{|k| k.name} # -> ['AddIn', 'AddIns' ...] - -**@overload** [] - -## path() [](#method-i-path) -Returns the type library file path. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - puts tlib.path #-> 'C:\...\EXCEL9.OLB' - -**@overload** [] - -## version() [](#method-i-version) -Returns the type library version. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - puts tlib.version #-> "1.3" - -**@overload** [] - -## visible?() [](#method-i-visible?) -Returns true if the type library information is not hidden. If wLibFlags of -TLIBATTR is 0 or LIBFLAG_FRESTRICTED or LIBFLAG_FHIDDEN, the method returns -false, otherwise, returns true. If the method fails to access the TLIBATTR -information, then WIN32OLE::RuntimeError is raised. - - tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') - tlib.visible? # => true - -**@overload** [] - -**@return** [Boolean] - diff --git a/example/ruby/WIN32OLE/Variable.md b/example/ruby/WIN32OLE/Variable.md deleted file mode 100644 index 4650fca..0000000 --- a/example/ruby/WIN32OLE/Variable.md +++ /dev/null @@ -1,134 +0,0 @@ -# Class: WIN32OLE::Variable -**Inherits:** Object - - -`WIN32OLE::Variable` objects represent OLE variable information. - - - -#Instance Methods -## inspect() [](#method-i-inspect) -Returns the OLE variable name and the value with class name. - -**@overload** [] - -## name() [](#method-i-name) -Returns the name of variable. - - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') - variables = tobj.variables - variables.each do |variable| - puts "#{variable.name}" - end - - The result of above script is following: - xlChart - xlDialogSheet - xlExcel4IntlMacroSheet - xlExcel4MacroSheet - xlWorksheet - -**@overload** [] - -## ole_type() [](#method-i-ole_type) -Returns OLE type string. - - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') - variables = tobj.variables - variables.each do |variable| - puts "#{variable.ole_type} #{variable.name}" - end - - The result of above script is following: - INT xlChart - INT xlDialogSheet - INT xlExcel4IntlMacroSheet - INT xlExcel4MacroSheet - INT xlWorksheet - -**@overload** [] - -## ole_type_detail() [](#method-i-ole_type_detail) -Returns detail information of type. The information is array of type. - - tobj = WIN32OLE::Type.new('DirectX 7 for Visual Basic Type Library', 'D3DCLIPSTATUS') - variable = tobj.variables.find {|variable| variable.name == 'lFlags'} - tdetail = variable.ole_type_detail - p tdetail # => ["USERDEFINED", "CONST_D3DCLIPSTATUSFLAGS"] - -**@overload** [] - -## value() [](#method-i-value) -Returns value if value is exists. If the value does not exist, this method -returns nil. - - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') - variables = tobj.variables - variables.each do |variable| - puts "#{variable.name} #{variable.value}" - end - - The result of above script is following: - xlChart = -4109 - xlDialogSheet = -4116 - xlExcel4IntlMacroSheet = 4 - xlExcel4MacroSheet = 3 - xlWorksheet = -4167 - -**@overload** [] - -## variable_kind() [](#method-i-variable_kind) -Returns variable kind string. - - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') - variables = tobj.variables - variables.each do |variable| - puts "#{variable.name} #{variable.variable_kind}" - end - - The result of above script is following: - xlChart CONSTANT - xlDialogSheet CONSTANT - xlExcel4IntlMacroSheet CONSTANT - xlExcel4MacroSheet CONSTANT - xlWorksheet CONSTANT - -**@overload** [] - -## varkind() [](#method-i-varkind) -Returns the number which represents variable kind. - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') - variables = tobj.variables - variables.each do |variable| - puts "#{variable.name} #{variable.varkind}" - end - - The result of above script is following: - xlChart 2 - xlDialogSheet 2 - xlExcel4IntlMacroSheet 2 - xlExcel4MacroSheet 2 - xlWorksheet 2 - -**@overload** [] - -## visible?() [](#method-i-visible?) -Returns true if the variable is public. - - tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') - variables = tobj.variables - variables.each do |variable| - puts "#{variable.name} #{variable.visible?}" - end - - The result of above script is following: - xlChart true - xlDialogSheet true - xlExcel4IntlMacroSheet true - xlExcel4MacroSheet true - xlWorksheet true - -**@overload** [] - -**@return** [Boolean] - diff --git a/example/ruby/WIN32OLE/Variant.md b/example/ruby/WIN32OLE/Variant.md deleted file mode 100644 index 8c08c03..0000000 --- a/example/ruby/WIN32OLE/Variant.md +++ /dev/null @@ -1,108 +0,0 @@ -# Class: WIN32OLE::Variant -**Inherits:** Object - - -`WIN32OLE::Variant` objects represents OLE variant. - - Win32OLE converts Ruby object into OLE variant automatically when - invoking OLE methods. If OLE method requires the argument which is - different from the variant by automatic conversion of Win32OLE, you - can convert the specified variant type by using WIN32OLE::Variant class. - - param = WIN32OLE::Variant.new(10, WIN32OLE::VARIANT::VT_R4) - oleobj.method(param) - - WIN32OLE::Variant does not support VT_RECORD variant. Use WIN32OLE::Record - class instead of WIN32OLE::Variant if the VT_RECORD variant is needed. - - -# Class Methods -## array(elems , vvt ) [](#method-c-array) -Returns Ruby object wrapping OLE variant whose variant type is VT_ARRAY. The -first argument should be Array object which specifies dimensions and each size -of dimensions of OLE array. The second argument specifies variant type of the -element of OLE array. - -The following create 2 dimensions OLE array. The first dimensions size is 3, -and the second is 4. - - ole_ary = WIN32OLE::Variant.array([3,4], VT_I4) - ruby_ary = ole_ary.value # => [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] -**@overload** [] - - -#Instance Methods -## [](*args) [](#method-i-[]) -Returns the element of WIN32OLE::Variant object(OLE array). This method is -available only when the variant type of WIN32OLE::Variant object is VT_ARRAY. - -REMARK: - The all indices should be 0 or natural number and - lower than or equal to max indices. - (This point is different with Ruby Array indices.) - - obj = WIN32OLE::Variant.new([[1,2,3],[4,5,6]]) - p obj[0,0] # => 1 - p obj[1,0] # => 4 - p obj[2,0] # => WIN32OLE::RuntimeError - p obj[0, -1] # => WIN32OLE::RuntimeError - -**@overload** [] - -## []=(*args) [](#method-i-[]=) -Set the element of WIN32OLE::Variant object(OLE array) to val. This method is -available only when the variant type of WIN32OLE::Variant object is VT_ARRAY. - -REMARK: - The all indices should be 0 or natural number and - lower than or equal to max indices. - (This point is different with Ruby Array indices.) - - obj = WIN32OLE::Variant.new([[1,2,3],[4,5,6]]) - obj[0,0] = 7 - obj[1,0] = 8 - p obj.value # => [[7,2,3], [8,5,6]] - obj[2,0] = 9 # => WIN32OLE::RuntimeError - obj[0, -1] = 9 # => WIN32OLE::RuntimeError - -**@overload** [] - -## initialize(args) [](#method-i-initialize) -Returns Ruby object wrapping OLE variant. The first argument specifies Ruby -object to convert OLE variant variable. The second argument specifies VARIANT -type. In some situation, you need the WIN32OLE::Variant object to pass OLE -method - - shell = WIN32OLE.new("Shell.Application") - folder = shell.NameSpace("C:\\Windows") - item = folder.ParseName("tmp.txt") - # You can't use Ruby String object to call FolderItem.InvokeVerb. - # Instead, you have to use WIN32OLE::Variant object to call the method. - shortcut = WIN32OLE::Variant.new("Create Shortcut(\&S)") - item.invokeVerb(shortcut) - -**@overload** [] - -## value() [](#method-i-value) -Returns Ruby object value from OLE variant. - obj = WIN32OLE::Variant.new(1, WIN32OLE::VARIANT::VT_BSTR) - obj.value # => "1" (not Integer object, but String object "1") - -## value=(val) [](#method-i-value=) -Sets variant value to val. If the val type does not match variant value -type(vartype), then val is changed to match variant value type(vartype) before -setting val. This method is not available when vartype is VT_ARRAY(except -VT_UI1|VT_ARRAY). If the vartype is VT_UI1|VT_ARRAY, the val should be String -object. - - obj = WIN32OLE::Variant.new(1) # obj.vartype is WIN32OLE::VARIANT::VT_I4 - obj.value = 3.2 # 3.2 is changed to 3 when setting value. - p obj.value # => 3 - -**@overload** [] - -## vartype() [](#method-i-vartype) -Returns OLE variant type. - obj = WIN32OLE::Variant.new("string") - obj.vartype # => WIN32OLE::VARIANT::VT_BSTR - diff --git a/example/ruby/WIN32OLE/VariantType.md b/example/ruby/WIN32OLE/VariantType.md deleted file mode 100644 index 84c5947..0000000 --- a/example/ruby/WIN32OLE/VariantType.md +++ /dev/null @@ -1,11 +0,0 @@ -# Module: WIN32OLE::VariantType - - -The `WIN32OLE::VariantType` module includes constants of VARIANT type -constants. The constants is used when creating WIN32OLE::Variant object. - - obj = WIN32OLE::Variant.new("2e3", WIN32OLE::VARIANT::VT_R4) - obj.value # => 2000.0 - - - diff --git a/example/ruby/WIN32OLESpecs.md b/example/ruby/WIN32OLESpecs.md deleted file mode 100644 index 0ab5eeb..0000000 --- a/example/ruby/WIN32OLESpecs.md +++ /dev/null @@ -1,8 +0,0 @@ -# Module: WIN32OLESpecs - - - - -# Class Methods -## new_ole(name ) [](#method-c-new_ole) - diff --git a/example/ruby/Warning.md b/example/ruby/Warning.md deleted file mode 100644 index 5435d3e..0000000 --- a/example/ruby/Warning.md +++ /dev/null @@ -1,77 +0,0 @@ -# Module: Warning - -**Extended by:** CompileWarning - - -The Warning module contains a single method named #warn, and the module -extends itself, making Warning.warn available. Warning.warn is called for all -warnings issued by Ruby. By default, warnings are printed to $stderr. - -Changing the behavior of Warning.warn is useful to customize how warnings are -handled by Ruby, for instance by filtering some warnings, and/or outputting -warnings somewhere other than `$stderr`. - -If you want to change the behavior of Warning.warn you should use -`Warning.extend(MyNewModuleWithWarnMethod)` and you can use `super` to get the -default behavior of printing the warning to `$stderr`. - -Example: - module MyWarningFilter - def warn(message, category: nil, **kwargs) - if /some warning I want to ignore/.match?(message) - # ignore - else - super - end - end - end - Warning.extend MyWarningFilter - -You should never redefine Warning#warn (the instance method), as that will -then no longer provide a way to use the default behavior. - -The [warning](https://rubygems.org/gems/warning) gem provides convenient ways -to customize Warning.warn. - - -# Class Methods -## [](category ) [](#method-c-[]) -Returns the flag to show the warning messages for `category`. Supported -categories are: - -`:deprecated` -: deprecation warnings - * assignment of non-nil value to `$,` and `$;` - * keyword arguments - etc. - - -`:experimental` -: experimental features - - -`:performance` -: performance hints - * Shape variation limit - -**@overload** [] - -## []=(category , flag ) [](#method-c-[]=) -Sets the warning flags for `category`. See Warning.[] for the categories. -**@overload** [] - -## categories() [](#method-c-categories) -Returns a list of the supported category symbols. -**@overload** [] - -## warn(message ) [](#method-c-warn) - -#Instance Methods -## warn(*args) [](#method-i-warn) -Writes warning message `msg` to $stderr. This method is called by Ruby for all -emitted warnings. A `category` may be included with the warning. - -See the documentation of the Warning module for how to customize this. - -**@overload** [] - diff --git a/example/ruby/Warning/buffer.md b/example/ruby/Warning/buffer.md deleted file mode 100644 index d9a28eb..0000000 --- a/example/ruby/Warning/buffer.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: Warning::buffer -**Inherits:** String - - - - - -#Instance Methods -## write(*args) [](#method-i-write) -:nodoc: - diff --git a/example/ruby/WeakRef.md b/example/ruby/WeakRef.md deleted file mode 100644 index 73a55de..0000000 --- a/example/ruby/WeakRef.md +++ /dev/null @@ -1,36 +0,0 @@ -# Class: WeakRef -**Inherits:** Delegator - - -Weak Reference class that allows a referenced object to be garbage-collected. - -A WeakRef may be used exactly like the object it references. - -Usage: - - foo = Object.new # create a new object instance - p foo.to_s # original's class - foo = WeakRef.new(foo) # reassign foo with WeakRef instance - p foo.to_s # should be same class - GC.start # start the garbage collector - p foo.to_s # should raise exception (recycled) - - - -#Instance Methods -## __getobj__() [](#method-i-__getobj__) -:nodoc: - -## __setobj__(obj) [](#method-i-__setobj__) -:nodoc: - -## initialize(orig) [](#method-i-initialize) -Creates a weak reference to `orig` - -**@return** [WeakRef] a new instance of WeakRef - -## weakref_alive?() [](#method-i-weakref_alive?) -Returns true if the referenced object is still alive. - -**@return** [Boolean] - diff --git a/example/ruby/WeakRef/RefError.md b/example/ruby/WeakRef/RefError.md deleted file mode 100644 index 22a50cc..0000000 --- a/example/ruby/WeakRef/RefError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: WeakRef::RefError -**Inherits:** StandardError - - -RefError is raised when a referenced object has been recycled by the garbage -collector - - - diff --git a/example/ruby/WeakRefSpec.md b/example/ruby/WeakRefSpec.md deleted file mode 100644 index 34c5a33..0000000 --- a/example/ruby/WeakRefSpec.md +++ /dev/null @@ -1,11 +0,0 @@ -# Class: WeakRefSpec -**Inherits:** Object - - -From MRI test_weakref.rb - - -# Class Methods -## make_dead_weakref() [](#method-c-make_dead_weakref) -## make_weakref(level 10) [](#method-c-make_weakref) - diff --git a/example/ruby/WebauthnListenerResponseTest.md b/example/ruby/WebauthnListenerResponseTest.md deleted file mode 100644 index da9fecf..0000000 --- a/example/ruby/WebauthnListenerResponseTest.md +++ /dev/null @@ -1,20 +0,0 @@ -# Class: WebauthnListenerResponseTest -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_bad_request_response_to_s() [](#method-i-test_bad_request_response_to_s) - -## test_method_not_allowed_response_to_s() [](#method-i-test_method_not_allowed_response_to_s) - -## test_method_not_found_response_to_s() [](#method-i-test_method_not_found_response_to_s) - -## test_no_to_s_response_to_s() [](#method-i-test_no_to_s_response_to_s) - -## test_ok_response_to_s() [](#method-i-test_ok_response_to_s) - diff --git a/example/ruby/WebauthnListenerTest.md b/example/ruby/WebauthnListenerTest.md deleted file mode 100644 index b24ba6f..0000000 --- a/example/ruby/WebauthnListenerTest.md +++ /dev/null @@ -1,30 +0,0 @@ -# Class: WebauthnListenerTest -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_listener_thread_retreives_otp_code() [](#method-i-test_listener_thread_retreives_otp_code) - -## test_listener_thread_sets_error() [](#method-i-test_listener_thread_sets_error) - -## test_wait_for_otp_code_get_follows_options() [](#method-i-test_wait_for_otp_code_get_follows_options) - -## test_wait_for_otp_code_get_request() [](#method-i-test_wait_for_otp_code_get_request) - -## test_wait_for_otp_code_incorrect_params() [](#method-i-test_wait_for_otp_code_incorrect_params) - -## test_wait_for_otp_code_incorrect_path() [](#method-i-test_wait_for_otp_code_incorrect_path) - -## test_wait_for_otp_code_invalid_post_req_method() [](#method-i-test_wait_for_otp_code_invalid_post_req_method) - -## test_wait_for_otp_code_no_params_response() [](#method-i-test_wait_for_otp_code_no_params_response) - -## test_wait_for_otp_code_options_request() [](#method-i-test_wait_for_otp_code_options_request) - diff --git a/example/ruby/WebauthnPollerTest.md b/example/ruby/WebauthnPollerTest.md deleted file mode 100644 index fa77e32..0000000 --- a/example/ruby/WebauthnPollerTest.md +++ /dev/null @@ -1,28 +0,0 @@ -# Class: WebauthnPollerTest -**Inherits:** Gem::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - -## test_poll_for_otp_invalid_format() [](#method-i-test_poll_for_otp_invalid_format) - -## test_poll_for_otp_invalid_status() [](#method-i-test_poll_for_otp_invalid_status) - -## test_poll_for_otp_missing_credentials() [](#method-i-test_poll_for_otp_missing_credentials) - -## test_poll_for_otp_not_http_success() [](#method-i-test_poll_for_otp_not_http_success) - -## test_poll_for_otp_pending_sleeps() [](#method-i-test_poll_for_otp_pending_sleeps) - -## test_poll_for_otp_success() [](#method-i-test_poll_for_otp_success) - -## test_poll_thread_success() [](#method-i-test_poll_thread_success) - -## test_poll_thread_timeout_error() [](#method-i-test_poll_thread_timeout_error) - -## test_poll_thread_webauthn_verification_error() [](#method-i-test_poll_thread_webauthn_verification_error) - diff --git a/example/ruby/Win32.md b/example/ruby/Win32.md deleted file mode 100644 index 24cefc1..0000000 --- a/example/ruby/Win32.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Win32 - - - - - diff --git a/example/ruby/Win32/Registry.md b/example/ruby/Win32/Registry.md deleted file mode 100644 index ac8eb4f..0000000 --- a/example/ruby/Win32/Registry.md +++ /dev/null @@ -1,2309 +0,0 @@ -# Class: Win32::Registry -**Inherits:** Object - -**Includes:** Enumerable, Win32::Registry::Constants - - - - -# Class Methods -## create(hkey , subkey , desired KEY_ALL_ACCESS, opt REG_OPTION_RESERVED) [](#method-c-create) ---- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = -REG_OPTION_RESERVED) - ---- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = -REG_OPTION_RESERVED) { |reg| ... } - -Create or open the registry key subkey under key. You can use predefined key -HKEY_* (see Constants) - -If subkey is already exists, key is opened and Registry#created? method will -return false. - -If block is given, the key is closed automatically. -## expand_environ(str ) [](#method-c-expand_environ) -Replace %w+% into the environment value of what is contained between the %'s -This method is used for REG_EXPAND_SZ. - -For detail, see -[expandEnvironmentStrings](http://msdn.microsoft.com/library/en-us/sysinfo/bas -e/expandenvironmentstrings.asp) Win32 API. -## open(hkey , subkey , desired KEY_READ, opt REG_OPTION_RESERVED) [](#method-c-open) ---- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) - ---- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) -{ |reg| ... } - -Open the registry key subkey under key. key is Win32::Registry object of -parent key. You can use predefined key HKEY_* (see Constants) desired and opt -is access mask and key option. For detail, see the -[MSDN](http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp). -If block is given, the key is closed automatically. -## time2wtime(time ) [](#method-c-time2wtime) -Convert Time object or Integer object into 64-bit FILETIME. -## type2name(type ) [](#method-c-type2name) -Convert registry type value to readable string. -## wtime2time(wtime ) [](#method-c-wtime2time) -Convert 64-bit FILETIME integer into Time object. -# Attributes -## disposition[RW] [](#attribute-i-disposition) -Disposition value (REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY). - -## keyname[RW] [](#attribute-i-keyname) -Same as subkey value of Registry.open or Registry.create method. - -## parent[RW] [](#attribute-i-parent) -Win32::Registry object of parent key, or nil if predefeined key. - - -#Instance Methods -## [](name, *rtype) [](#method-i-[]) -Read a registry value named name and return its value data. The class of the -value is the same as the #read method returns. - -If the value type is REG_EXPAND_SZ, returns value data whose environment -variables are replaced. If the value type is neither REG_SZ, REG_MULTI_SZ, -REG_DWORD, REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised. - -The meaning of rtype is the same as for the #read method. - -## []=(name, rtype, valuenil) [](#method-i-[]=) -Write value to a registry value named name. - -If wtype is specified, the value type is it. Otherwise, the value type is -depend on class of value: :Integer - REG_DWORD - -:String - REG_SZ - -:Array - REG_MULTI_SZ - -## _dump(depth) [](#method-i-_dump) -marshalling is not allowed - -**@raise** [TypeError] - -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## close() [](#method-i-close) -Close key. - -After close, most method raise an error. - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## create(subkey, desiredKEY_ALL_ACCESS, optREG_OPTION_RESERVED, &blk) [](#method-i-create) -Same as Win32::Registry.create (self, subkey, desired, opt) - -## created?() [](#method-i-created?) -Returns if key is created ((**newly**)). (see Registry.create) -- basically -you call create then when you call created? on the instance returned it will -tell if it was successful or not - -**@return** [Boolean] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## delete_key(name, recursivefalse) [](#method-i-delete_key) -Delete a subkey named name and all its values. - -If recursive is false, the subkey must not have subkeys. Otherwise, this -method deletes all subkeys and values recursively. - -## delete_value(name) [](#method-i-delete_value) -Delete a registry value named name. We can not delete the `default' value. - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_key() [](#method-i-each_key) -Enumerate all subkeys. - -For each subkey it yields subkey and wtime. - -subkey is String which contains name of subkey. wtime is last write time as -FILETIME (64-bit integer). (see Registry.wtime2time) - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_value() [](#method-i-each_value) -Enumerate all values in this registry path. - -For each value it yields key, type and data. - -key is a String which contains name of key. type is a type contant kind of -Win32::Registry::REG_* data is the value of this key. - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## flush() [](#method-i-flush) -Write all the attributes into the registry file. - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## hkey() [](#method-i-hkey) -Returns key handle value. - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## info() [](#method-i-info) -Returns key information as Array of: :num_keys - The number of subkeys. - -:max_key_length - Maximum length of name of subkeys. - -:num_values - The number of values. - -:max_value_name_length - Maximum length of name of values. - -:max_value_length - Maximum length of value of values. - -:descriptor_length - Length of security descriptor. - -:wtime - Last write time as FILETIME(64-bit integer) - -For detail, see -[RegQueryInfoKey](http://msdn.microsoft.com/library/en-us/sysinfo/base/regquer -yinfokey.asp) Win32 API. - -## initialize(hkey, parent, keyname, disposition) [](#method-i-initialize) -initialize - -**@return** [Registry] a new instance of Registry - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## inspect() [](#method-i-inspect) - -## keys() [](#method-i-keys) -return keys as an array - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## name() [](#method-i-name) -Full path of key such as 'HKEY_CURRENT_USERSOFTWAREfoobar'. - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## open(subkey, desiredKEY_READ, optREG_OPTION_RESERVED, &blk) [](#method-i-open) -Same as Win32::Registry.open (self, subkey, desired, opt) - -## open?() [](#method-i-open?) -Returns if key is not closed. - -**@return** [Boolean] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## read(name, *rtype) [](#method-i-read) -Read a registry value named name and return array of [ type, data ]. When name -is nil, the `default' value is read. type is value type. (see -Win32::Registry::Constants module) data is value data, its class is: :REG_SZ, -REG_EXPAND_SZ - String - -:REG_MULTI_SZ - Array of String - -:REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD - Integer - -:REG_BINARY, REG_NONE - String (contains binary data) - -When rtype is specified, the value type must be included by rtype array, or -TypeError is raised. - -## read_bin(name) [](#method-i-read_bin) -Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin) registry -value named name. - -If the values type does not match, TypeError is raised. - -## read_i(name) [](#method-i-read_i) -Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin) registry -value named name. - -If the values type does not match, TypeError is raised. - -## read_s(name) [](#method-i-read_s) -Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin) registry -value named name. - -If the values type does not match, TypeError is raised. - -## read_s_expand(name) [](#method-i-read_s_expand) -Read a REG_SZ or REG_EXPAND_SZ registry value named name. - -If the value type is REG_EXPAND_SZ, environment variables are replaced. Unless -the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised. - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## values() [](#method-i-values) -return values as an array - -## write(name, type, data) [](#method-i-write) -Write data to a registry value named name. When name is nil, write to the -`default' value. - -type is type value. (see Registry::Constants module) Class of data must be -same as which #read method returns. - -## write_bin(name, value) [](#method-i-write_bin) -Write value to a registry value named name. - -The value type is REG_SZ(write_s), REG_DWORD(write_i), or -REG_BINARY(write_bin). - -## write_i(name, value) [](#method-i-write_i) -Write value to a registry value named name. - -The value type is REG_SZ(write_s), REG_DWORD(write_i), or -REG_BINARY(write_bin). - -## write_s(name, value) [](#method-i-write_s) -Write value to a registry value named name. - -The value type is REG_SZ(write_s), REG_DWORD(write_i), or -REG_BINARY(write_bin). - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Win32/Registry/API.md b/example/ruby/Win32/Registry/API.md deleted file mode 100644 index b1056cc..0000000 --- a/example/ruby/Win32/Registry/API.md +++ /dev/null @@ -1,166 +0,0 @@ -# Module: Win32::Registry::API - -**Extended by:** Fiddle::Importer - -**Includes:** Win32::Registry::Constants - - -Win32 APIs - - -# Class Methods -## CloseKey(hkey ) [](#method-c-CloseKey) -## CreateKey(hkey , name , opt , desired ) [](#method-c-CreateKey) -## DeleteKey(hkey , name ) [](#method-c-DeleteKey) -## DeleteValue(hkey , name ) [](#method-c-DeleteValue) -## EnumKey(hkey , index ) [](#method-c-EnumKey) -## EnumValue(hkey , index ) [](#method-c-EnumValue) -## FlushKey(hkey ) [](#method-c-FlushKey) -## OpenKey(hkey , name , opt , desired ) [](#method-c-OpenKey) -## QueryInfoKey(hkey ) [](#method-c-QueryInfoKey) -## QueryValue(hkey , name ) [](#method-c-QueryValue) -## SetValue(hkey , name , type , data , size ) [](#method-c-SetValue) -## [](name ) [](#method-c-[]) -Returns the function mapped to `name`, that was created by either -Fiddle::Importer.extern or Fiddle::Importer.bind -## bind(signature , *opts , &blk ) [](#method-c-bind) -Creates a global method from the given C `signature` using the given `opts` as -bind parameters with the given block. -## bind_function(name , ctype , argtype , call_type nil, &block ) [](#method-c-bind_function) -Returns a new closure wrapper for the `name` function. - -* `ctype` is the return type of the function -* `argtype` is an Array of arguments, passed to the callback function -* `call_type` is the abi of the closure -* `block` is passed to the callback - -See Fiddle::Closure -## check(result ) [](#method-c-check) -**@raise** [Error] - -## create_value(ty , val nil) [](#method-c-create_value) -Creates a class to wrap the C struct with the value `ty` - -See also Fiddle::Importer.struct -## dlload(*libs ) [](#method-c-dlload) -Creates an array of handlers for the given `libs`, can be an instance of -Fiddle::Handle, Fiddle::Importer, or will create a new instance of -Fiddle::Handle using Fiddle.dlopen - -Raises a DLError if the library cannot be loaded. - -See Fiddle.dlopen -## extern(signature , *opts ) [](#method-c-extern) -Creates a global method from the given C `signature`. -## handler() [](#method-c-handler) -The Fiddle::CompositeHandler instance - -Will raise an error if no handlers are open. -## import_function(name , ctype , argtype , call_type nil) [](#method-c-import_function) -Returns a new Fiddle::Function instance at the memory address of the given -`name` function. - -Raises a DLError if the `name` doesn't exist. - -* `argtype` is an Array of arguments, passed to the `name` function. -* `ctype` is the return type of the function -* `call_type` is the ABI of the function - -See also Fiddle:Function.new - -See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym -## import_symbol(name ) [](#method-c-import_symbol) -Returns a new Fiddle::Pointer instance at the memory address of the given -`name` symbol. - -Raises a DLError if the `name` doesn't exist. - -See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym -## import_value(ty , addr ) [](#method-c-import_value) -Returns a new instance of the C struct with the value `ty` at the `addr` -address. -## make_wstr(str ) [](#method-c-make_wstr) -## packdw(dw ) [](#method-c-packdw) -## packhandle(h ) [](#method-c-packhandle) -## packqw(qw ) [](#method-c-packqw) -## parse_ctype(ty , tymap nil) [](#method-c-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP -## parse_signature(signature , tymap nil) [](#method-c-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] -## parse_struct_signature(signature , tymap nil) [](#method-c-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] -## sizeof(ty ) [](#method-c-sizeof) -Returns the sizeof `ty`, using Fiddle::Importer.parse_ctype to determine the C -type and the appropriate Fiddle constant. -## struct(signature ) [](#method-c-struct) -Creates a class to wrap the C struct described by `signature`. - - MyStruct = struct ['int i', 'char c'] -## typealias(alias_type , orig_type ) [](#method-c-typealias) -Sets the type alias for `alias_type` as `orig_type` -## union(signature ) [](#method-c-union) -Creates a class to wrap the C union described by `signature`. - - MyUnion = union ['int i', 'char c'] -## unpackdw(dw ) [](#method-c-unpackdw) -## unpackhandle(h ) [](#method-c-unpackhandle) -## unpackqw(qw ) [](#method-c-unpackqw) -## win64?() [](#method-c-win64?) -**@return** [Boolean] - - diff --git a/example/ruby/Win32/Registry/Constants.md b/example/ruby/Win32/Registry/Constants.md deleted file mode 100644 index 687e7a8..0000000 --- a/example/ruby/Win32/Registry/Constants.md +++ /dev/null @@ -1,32 +0,0 @@ -# Module: Win32::Registry::Constants - - -For detail, see the -[MSDN](http://msdn.microsoft.com/library/en-us/sysinfo/base/registry.asp). - ---- HKEY_* - - Predefined key ((*handle*)). - These are Integer, not Win32::Registry. - ---- REG_* - - Registry value type. - ---- KEY_* - - Security access mask. - ---- KEY_OPTIONS_* - - Key options. - ---- REG_CREATED_NEW_KEY - ---- REG_OPENED_EXISTING_KEY - - If the key is created newly or opened existing key. - See also Registry#disposition method. - - - diff --git a/example/ruby/Win32/Registry/Error.md b/example/ruby/Win32/Registry/Error.md deleted file mode 100644 index 36e435d..0000000 --- a/example/ruby/Win32/Registry/Error.md +++ /dev/null @@ -1,17 +0,0 @@ -# Exception: Win32::Registry::Error -**Inherits:** StandardError - - -Error - - -# Attributes -## code[RW] [](#attribute-i-code) -Returns the value of attribute code. - - -#Instance Methods -## initialize(code) [](#method-i-initialize) - -**@return** [Error] a new instance of Error - diff --git a/example/ruby/Win32/Registry/Error/Kernel32.md b/example/ruby/Win32/Registry/Error/Kernel32.md deleted file mode 100644 index 93d84b7..0000000 --- a/example/ruby/Win32/Registry/Error/Kernel32.md +++ /dev/null @@ -1,139 +0,0 @@ -# Module: Win32::Registry::Error::Kernel32 - -**Extended by:** Fiddle::Importer - - - - -# Class Methods -## [](name ) [](#method-c-[]) -Returns the function mapped to `name`, that was created by either -Fiddle::Importer.extern or Fiddle::Importer.bind -## bind(signature , *opts , &blk ) [](#method-c-bind) -Creates a global method from the given C `signature` using the given `opts` as -bind parameters with the given block. -## bind_function(name , ctype , argtype , call_type nil, &block ) [](#method-c-bind_function) -Returns a new closure wrapper for the `name` function. - -* `ctype` is the return type of the function -* `argtype` is an Array of arguments, passed to the callback function -* `call_type` is the abi of the closure -* `block` is passed to the callback - -See Fiddle::Closure -## create_value(ty , val nil) [](#method-c-create_value) -Creates a class to wrap the C struct with the value `ty` - -See also Fiddle::Importer.struct -## dlload(*libs ) [](#method-c-dlload) -Creates an array of handlers for the given `libs`, can be an instance of -Fiddle::Handle, Fiddle::Importer, or will create a new instance of -Fiddle::Handle using Fiddle.dlopen - -Raises a DLError if the library cannot be loaded. - -See Fiddle.dlopen -## extern(signature , *opts ) [](#method-c-extern) -Creates a global method from the given C `signature`. -## handler() [](#method-c-handler) -The Fiddle::CompositeHandler instance - -Will raise an error if no handlers are open. -## import_function(name , ctype , argtype , call_type nil) [](#method-c-import_function) -Returns a new Fiddle::Function instance at the memory address of the given -`name` function. - -Raises a DLError if the `name` doesn't exist. - -* `argtype` is an Array of arguments, passed to the `name` function. -* `ctype` is the return type of the function -* `call_type` is the ABI of the function - -See also Fiddle:Function.new - -See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym -## import_symbol(name ) [](#method-c-import_symbol) -Returns a new Fiddle::Pointer instance at the memory address of the given -`name` symbol. - -Raises a DLError if the `name` doesn't exist. - -See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym -## import_value(ty , addr ) [](#method-c-import_value) -Returns a new instance of the C struct with the value `ty` at the `addr` -address. -## parse_ctype(ty , tymap nil) [](#method-c-parse_ctype) -Given a String of C type `ty`, returns the corresponding Fiddle constant. - -`ty` can also accept an Array of C type Strings, and will be returned in a -corresponding Array. - -If Hash `tymap` is provided, `ty` is expected to be the key, and the value -will be the C type to be looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_ctype('int') - #=> Fiddle::TYPE_INT - - parse_ctype('double diff') - #=> Fiddle::TYPE_DOUBLE - - parse_ctype('unsigned char byte') - #=> -Fiddle::TYPE_CHAR - - parse_ctype('const char* const argv[]') - #=> -Fiddle::TYPE_VOIDP -## parse_signature(signature , tymap nil) [](#method-c-parse_signature) -Parses a C prototype signature - -If Hash `tymap` is provided, the return value and the arguments from the -`signature` are expected to be keys, and the value will be the C type to be -looked up. - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_signature('double sum(double, double)') - #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] - - parse_signature('void update(void (*cb)(int code))') - #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] - - parse_signature('char (*getbuffer(void))[80]') - #=> ["getbuffer", Fiddle::TYPE_VOIDP, []] -## parse_struct_signature(signature , tymap nil) [](#method-c-parse_struct_signature) -Parses a C struct's members - -Example: - require 'fiddle/import' - - include Fiddle::CParser - #=> Object - - parse_struct_signature(['int i', 'char c']) - #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]] - - parse_struct_signature(['char buffer[80]']) - #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]] -## sizeof(ty ) [](#method-c-sizeof) -Returns the sizeof `ty`, using Fiddle::Importer.parse_ctype to determine the C -type and the appropriate Fiddle constant. -## struct(signature ) [](#method-c-struct) -Creates a class to wrap the C struct described by `signature`. - - MyStruct = struct ['int i', 'char c'] -## typealias(alias_type , orig_type ) [](#method-c-typealias) -Sets the type alias for `alias_type` as `orig_type` -## union(signature ) [](#method-c-union) -Creates a class to wrap the C union described by `signature`. - - MyUnion = union ['int i', 'char c'] - diff --git a/example/ruby/Win32/Registry/PredefinedKey.md b/example/ruby/Win32/Registry/PredefinedKey.md deleted file mode 100644 index 8098594..0000000 --- a/example/ruby/Win32/Registry/PredefinedKey.md +++ /dev/null @@ -1,21 +0,0 @@ -# Class: Win32::Registry::PredefinedKey -**Inherits:** Win32::Registry - - -Predefined Keys - - - -#Instance Methods -## class() [](#method-i-class) -Fake #class method for Registry#open, Registry#create - -## close() [](#method-i-close) -Predefined keys cannot be closed - -**@raise** [Error] - -## initialize(hkey, keyname) [](#method-i-initialize) - -**@return** [PredefinedKey] a new instance of PredefinedKey - diff --git a/example/ruby/Win32/Resolv.md b/example/ruby/Win32/Resolv.md deleted file mode 100644 index c658b05..0000000 --- a/example/ruby/Win32/Resolv.md +++ /dev/null @@ -1,10 +0,0 @@ -# Module: Win32::Resolv - - - - - -# Class Methods -## get_hosts_path() [](#method-c-get_hosts_path) -## get_resolv_info() [](#method-c-get_resolv_info) - diff --git a/example/ruby/Win32/Resolv/SZ.md b/example/ruby/Win32/Resolv/SZ.md deleted file mode 100644 index fe09716..0000000 --- a/example/ruby/Win32/Resolv/SZ.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Win32::Resolv::SZ - - - - - diff --git a/example/ruby/Windows.md b/example/ruby/Windows.md deleted file mode 100644 index d5ae8e6..0000000 --- a/example/ruby/Windows.md +++ /dev/null @@ -1,7 +0,0 @@ -# Class: Windows -**Inherits:** Sinatra::Base - - - - - diff --git a/example/ruby/Word.md b/example/ruby/Word.md deleted file mode 100644 index 107092b..0000000 --- a/example/ruby/Word.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: Word - - - - - diff --git a/example/ruby/X.md b/example/ruby/X.md deleted file mode 100644 index 88c1165..0000000 --- a/example/ruby/X.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: X - - - - - diff --git a/example/ruby/XMP.md b/example/ruby/XMP.md deleted file mode 100644 index 0c070d4..0000000 --- a/example/ruby/XMP.md +++ /dev/null @@ -1,62 +0,0 @@ -# Class: XMP -**Inherits:** Object - - -An example printer for irb. - -It's much like the standard library PrettyPrint, that shows the value of each -expression as it runs. - -In order to use this library, you must first require it: - - require 'irb/xmp' - -Now, you can take advantage of the Object#xmp convenience method. - - xmp < foo = "bar" - #==>"bar" - #=> baz = 42 - #==>42 - -You can also create an XMP object, with an optional binding to print -expressions in the given binding: - - ctx = binding - x = XMP.new ctx - x.puts - #=> today = "a good day" - #==>"a good day" - ctx.eval 'today # is what?' - #=> "a good day" - - - -#Instance Methods -## initialize(bindnil) [](#method-i-initialize) -Creates a new XMP object. - -The top-level binding or, optional `bind` parameter will be used when creating -the workspace. See WorkSpace.new for more information. - -This uses the `:XMP` prompt mode. See [Custom -Prompts](rdoc-ref:IRB@Custom+Prompts) for more information. - -**@return** [XMP] a new instance of XMP - -## puts(exps) [](#method-i-puts) -Evaluates the given `exps`, for example: - - require 'irb/xmp' - x = XMP.new - - x.puts '{:a => 1, :b => 2, :c => 3}' - #=> {:a => 1, :b => 2, :c => 3} - # ==>{:a=>1, :b=>2, :c=>3} - x.puts 'foo = "bar"' - # => foo = "bar" - # ==>"bar" - diff --git a/example/ruby/XMP/StringInputMethod.md b/example/ruby/XMP/StringInputMethod.md deleted file mode 100644 index b9713b9..0000000 --- a/example/ruby/XMP/StringInputMethod.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: XMP::StringInputMethod -**Inherits:** IRB::InputMethod - - -A custom InputMethod class used by XMP for evaluating string io. - - -# Attributes -## encoding[RW] [](#attribute-i-encoding) -Returns the encoding of last expression printed by #puts. - - -#Instance Methods -## eof?() [](#method-i-eof?) -Whether there are any expressions left in this printer. - -**@return** [Boolean] - -## gets() [](#method-i-gets) -Reads the next expression from this printer. - -See IO#gets for more information. - -## initialize() [](#method-i-initialize) -Creates a new StringInputMethod object - -**@return** [StringInputMethod] a new instance of StringInputMethod - -## puts(exps) [](#method-i-puts) -Concatenates all expressions in this printer, separated by newlines. - -An Encoding::CompatibilityError is raised of the given `exps`'s encoding -doesn't match the previous expression evaluated. - diff --git a/example/ruby/XrefTestCase.md b/example/ruby/XrefTestCase.md deleted file mode 100644 index c6454f9..0000000 --- a/example/ruby/XrefTestCase.md +++ /dev/null @@ -1,10 +0,0 @@ -# Class: XrefTestCase -**Inherits:** RDoc::TestCase - - - - - -#Instance Methods -## setup() [](#method-i-setup) - diff --git a/example/ruby/YAML.md b/example/ruby/YAML.md deleted file mode 100644 index 2a21030..0000000 --- a/example/ruby/YAML.md +++ /dev/null @@ -1,53 +0,0 @@ -# Module: YAML - - -YAML Ain't Markup Language - -This module provides a Ruby interface for data serialization in YAML format. - -The YAML module is an alias of Psych, the YAML engine for Ruby. - -## Usage - -Working with YAML can be very simple, for example: - - require 'yaml' - # Parse a YAML string - YAML.load("--- foo") #=> "foo" - - # Emit some YAML - YAML.dump("foo") # => "--- foo\n...\n" - { :a => 'b'}.to_yaml # => "---\n:a: b\n" - -As the implementation is provided by the Psych library, detailed documentation -can be found in that library's docs (also part of standard library). - -## Security - -Do not use YAML to load untrusted data. Doing so is unsafe and could allow -malicious input to execute arbitrary code inside your application. Please see -doc/security.rdoc for more information. - -## History - -Syck was the original YAML implementation in Ruby's standard library developed -by why the lucky stiff. - -You can still use Syck, if you prefer, for parsing and emitting YAML, but you -must install the 'syck' gem now in order to use it. - -In older Ruby versions, ie. <= 1.9, Syck is still provided, however it was -completely removed with the release of Ruby 2.0.0. - -## More info - -For more advanced details on the implementation see Psych, and also check out -http://yaml.org for spec details and other helpful information. - -Psych is maintained by Aaron Patterson on github: -https://github.com/ruby/psych - -Syck can also be found on github: https://github.com/ruby/syck - - - diff --git a/example/ruby/YAML/DBM.md b/example/ruby/YAML/DBM.md deleted file mode 100644 index 72ac207..0000000 --- a/example/ruby/YAML/DBM.md +++ /dev/null @@ -1,194 +0,0 @@ -# Class: YAML::DBM -**Inherits:** DBM - - -YAML + DBM = YDBM - -YAML::DBM provides the same interface as ::DBM. - -However, while DBM only allows strings for both keys and values, this library -allows one to use most Ruby objects for values by first converting them to -YAML. Keys must be strings. - -Conversion to and from YAML is performed automatically. - -See the documentation for ::DBM and ::YAML for more information. - - - -#Instance Methods -## [](key) [](#method-i-[]) -:call-seq: - ydbm[key] -> value - -Return value associated with `key` from database. - -Returns `nil` if there is no such `key`. - -See #fetch for more information. - -## []=(key, val) [](#method-i-[]=) -:call-seq: - ydbm[key] = value - -Set `key` to `value` in database. - -`value` will be converted to YAML before storage. - -See #store for more information. - -## delete(key) [](#method-i-delete) -:call-seq: - ydbm.delete(key) - -Deletes value from database associated with `key`. - -Returns value or `nil`. - -## delete_if() [](#method-i-delete_if) -:call-seq: - ydbm.delete_if { |key, value| ... } - -Calls the given block once for each `key`, `value` pair in the database. -Deletes all entries for which the block returns true. - -Returns `self`. - -## each_pair() [](#method-i-each_pair) -:call-seq: - ydbm.each_pair { |key, value| ... } - -Calls the given block once for each `key`, `value` pair in the database. - -Returns `self`. - -## each_value() [](#method-i-each_value) -:call-seq: - ydbm.each_value { |value| ... } - -Calls the given block for each value in database. - -Returns `self`. - -## fetch(keystr, ifnonenil) [](#method-i-fetch) -:call-seq: - ydbm.fetch( key, ifnone = nil ) - ydbm.fetch( key ) { |key| ... } - -Return value associated with `key`. - -If there is no value for `key` and no block is given, returns `ifnone`. - -Otherwise, calls block passing in the given `key`. - -See ::DBM#fetch for more information. - -## has_value?(val) [](#method-i-has_value?) -:call-seq: - ydbm.has_value?(value) - -Returns true if specified `value` is found in the database. - -**@return** [Boolean] - -## index(keystr) [](#method-i-index) -Deprecated, used YAML::DBM#key instead. ---- -Note: YAML::DBM#index makes warning from internal of ::DBM#index. It says -'DBM#index is deprecated; use DBM#key', but DBM#key behaves not same as -DBM#index. - -## invert() [](#method-i-invert) -:call-seq: - ydbm.invert -> hash - -Returns a Hash (not a DBM database) created by using each value in the -database as a key, with the corresponding key as its value. - -Note that all values in the hash will be Strings, but the keys will be actual -objects. - -## key(keystr) [](#method-i-key) -:call-seq: - ydbm.key(value) -> string - -Returns the key for the specified value. - -## reject() [](#method-i-reject) -:call-seq: - ydbm.reject { |key, value| ... } - -Converts the contents of the database to an in-memory Hash, then calls -Hash#reject with the specified code block, returning a new Hash. - -## replace(hsh) [](#method-i-replace) -:call-seq: - ydbm.replace(hash) -> ydbm - -Replaces the contents of the database with the contents of the specified -object. Takes any object which implements the each_pair method, including Hash -and DBM objects. - -## select(*keys) [](#method-i-select) -:call-seq: - ydbm.select { |key, value| ... } - ydbm.select(*keys) - -If a block is provided, returns a new array containing [key, value] pairs for -which the block returns true. - -Otherwise, same as #values_at - -## shift() [](#method-i-shift) -:call-seq: - ydbm.shift -> [key, value] - -Removes a [key, value] pair from the database, and returns it. If the database -is empty, returns `nil`. - -The order in which values are removed/returned is not guaranteed. - -## store(key, val) [](#method-i-store) -:call-seq: - ydbm.store(key, value) -> value - -Stores `value` in database with `key` as the index. `value` is converted to -YAML before being stored. - -Returns `value` - -## to_a() [](#method-i-to_a) -:call-seq: - ydbm.to_a -> array - -Converts the contents of the database to an array of [key, value] arrays, and -returns it. - -## to_hash() [](#method-i-to_hash) -:call-seq: - ydbm.to_hash -> hash - -Converts the contents of the database to an in-memory Hash object, and returns -it. - -## update(hsh) [](#method-i-update) -:call-seq: - ydbm.update(hash) -> ydbm - -Updates the database with multiple values from the specified object. Takes any -object which implements the each_pair method, including Hash and DBM objects. - -Returns `self`. - -## values() [](#method-i-values) -:call-seq: - ydbm.values - -Returns an array of values from the database. - -## values_at(*keys) [](#method-i-values_at) -:call-seq: - ydbm.values_at(*keys) - -Returns an array containing the values associated with the given keys. - diff --git a/example/ruby/YAML/Store.md b/example/ruby/YAML/Store.md deleted file mode 100644 index ffae07c..0000000 --- a/example/ruby/YAML/Store.md +++ /dev/null @@ -1,69 +0,0 @@ -# Class: YAML::Store -**Inherits:** PStore - - -YAML::Store provides the same functionality as PStore, except it uses YAML to -dump objects instead of Marshal. - -## Example - - require 'yaml/store' - - Person = Struct.new :first_name, :last_name - - people = [Person.new("Bob", "Smith"), Person.new("Mary", "Johnson")] - - store = YAML::Store.new "test.store" - - store.transaction do - store["people"] = people - store["greeting"] = { "hello" => "world" } - end - -After running the above code, the contents of "test.store" will be: - - --- - people: - - !ruby/struct:Person - first_name: Bob - last_name: Smith - - !ruby/struct:Person - first_name: Mary - last_name: Johnson - greeting: - hello: world - - - -#Instance Methods -## dump(table) [](#method-i-dump) -:stopdoc: - -## empty_marshal_checksum() [](#method-i-empty_marshal_checksum) - -## empty_marshal_data() [](#method-i-empty_marshal_data) - -## initialize(*o) [](#method-i-initialize) -:call-seq: - initialize( file_name, yaml_opts = {} ) - initialize( file_name, thread_safe = false, yaml_opts = {} ) - -Creates a new YAML::Store object, which will store data in `file_name`. If the -file does not already exist, it will be created. - -YAML::Store objects are always reentrant. But if *thread_safe* is set to true, -then it will become thread-safe at the cost of a minor performance hit. - -Options passed in through `yaml_opts` will be used when converting the store -to YAML via Hash#to_yaml(). - -**@return** [Store] a new instance of Store - -## load(content) [](#method-i-load) - -## marshal_dump_supports_canonical_option?() [](#method-i-marshal_dump_supports_canonical_option?) - -**@return** [Boolean] - -## old_load() [](#method-i-old_load) - diff --git a/example/ruby/YAMLSpecs.md b/example/ruby/YAMLSpecs.md deleted file mode 100644 index 4ceeefe..0000000 --- a/example/ruby/YAMLSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: YAMLSpecs - - - - - diff --git a/example/ruby/YAMLSpecs/Example.md b/example/ruby/YAMLSpecs/Example.md deleted file mode 100644 index 2915dfa..0000000 --- a/example/ruby/YAMLSpecs/Example.md +++ /dev/null @@ -1,12 +0,0 @@ -# Class: YAMLSpecs::Example -**Inherits:** Object - - - - - -#Instance Methods -## initialize(name) [](#method-i-initialize) - -**@return** [Example] a new instance of Example - diff --git a/example/ruby/YAMLStoreTest.md b/example/ruby/YAMLStoreTest.md deleted file mode 100644 index 07c5087..0000000 --- a/example/ruby/YAMLStoreTest.md +++ /dev/null @@ -1,38 +0,0 @@ -# Class: YAMLStoreTest -**Inherits:** Test::Unit::TestCase - - - - - -#Instance Methods -## second_file() [](#method-i-second_file) - -## setup() [](#method-i-setup) - -## teardown() [](#method-i-teardown) - -## test_changes_after_commit_are_discarded() [](#method-i-test_changes_after_commit_are_discarded) - -## test_changes_are_not_written_on_abort() [](#method-i-test_changes_are_not_written_on_abort) - -## test_data_should_be_loaded_correctly_when_in_readonly_mode() [](#method-i-test_data_should_be_loaded_correctly_when_in_readonly_mode) - -## test_data_should_be_loaded_correctly_when_in_readwrite_mode() [](#method-i-test_data_should_be_loaded_correctly_when_in_readwrite_mode) - -## test_nested_transaction_raises_error() [](#method-i-test_nested_transaction_raises_error) - -## test_opening_new_file_in_readonly_mode_should_result_in_empty_values() [](#method-i-test_opening_new_file_in_readonly_mode_should_result_in_empty_values) - -## test_opening_new_file_in_readwrite_mode_should_result_in_empty_values() [](#method-i-test_opening_new_file_in_readwrite_mode_should_result_in_empty_values) - -## test_thread_safe() [](#method-i-test_thread_safe) - -## test_with_options() [](#method-i-test_with_options) - -## test_writing_inside_readonly_transaction_raises_error() [](#method-i-test_writing_inside_readonly_transaction_raises_error) - -## test_yaml_store_files_are_accessed_as_binary_files() [](#method-i-test_yaml_store_files_are_accessed_as_binary_files) -Test that PStore's file operations do not blow up when default encodings are -set - diff --git a/example/ruby/YamlFormatter.md b/example/ruby/YamlFormatter.md deleted file mode 100644 index 7c9accf..0000000 --- a/example/ruby/YamlFormatter.md +++ /dev/null @@ -1,16 +0,0 @@ -# Class: YamlFormatter -**Inherits:** BaseFormatter - - - - - -#Instance Methods -## finish() [](#method-i-finish) - -## initialize(outnil) [](#method-i-initialize) - -**@return** [YamlFormatter] a new instance of YamlFormatter - -## switch() [](#method-i-switch) - diff --git a/example/ruby/YieldSpecs.md b/example/ruby/YieldSpecs.md deleted file mode 100644 index b91410e..0000000 --- a/example/ruby/YieldSpecs.md +++ /dev/null @@ -1,6 +0,0 @@ -# Module: YieldSpecs - - - - - diff --git a/example/ruby/YieldSpecs/Yielder.md b/example/ruby/YieldSpecs/Yielder.md deleted file mode 100644 index 5156f14..0000000 --- a/example/ruby/YieldSpecs/Yielder.md +++ /dev/null @@ -1,34 +0,0 @@ -# Class: YieldSpecs::Yielder -**Inherits:** Object - - - - -# Class Methods -## define_deep(&inned_block ) [](#method-c-define_deep) - -#Instance Methods -## k(a) [](#method-i-k) - -**@yield** [a, b: true] - -## m(a, b, c) [](#method-i-m) - -**@yield** [a, b, c] - -## r(a) [](#method-i-r) - -**@yield** [a] - -## rs(a, b, c) [](#method-i-rs) - -**@yield** [a, b, c] - -## s(a) [](#method-i-s) - -**@yield** [a] - -## z() [](#method-i-z) - -## ze(&block) [](#method-i-ze) - diff --git a/example/ruby/Zero.md b/example/ruby/Zero.md deleted file mode 100644 index 0f95fc3..0000000 --- a/example/ruby/Zero.md +++ /dev/null @@ -1,17 +0,0 @@ -# Class: Zero -**Inherits:** Object - - -The goal of this is to use a synthetic (non-IO) reader to trigger the -read/write loop of IO.copy_stream, bypassing in-kernel mechanisms like -sendfile for zero copy, so we wrap the /dev/zero IO object: - - - -#Instance Methods -## initialize() [](#method-i-initialize) - -**@return** [Zero] a new instance of Zero - -## read(len, buf) [](#method-i-read) - diff --git a/example/ruby/ZeroDivisionError.md b/example/ruby/ZeroDivisionError.md deleted file mode 100644 index bdd1c09..0000000 --- a/example/ruby/ZeroDivisionError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: ZeroDivisionError -**Inherits:** StandardError - - -Raised when attempting to divide an integer by 0. - - 42 / 0 #=> ZeroDivisionError: divided by 0 - -Note that only division by an exact 0 will raise the exception: - - 42 / 0.0 #=> Float::INFINITY - 42 / -0.0 #=> -Float::INFINITY - 0 / 0.0 #=> NaN - - - diff --git a/example/ruby/Zlib.md b/example/ruby/Zlib.md deleted file mode 100644 index 64da2f3..0000000 --- a/example/ruby/Zlib.md +++ /dev/null @@ -1,188 +0,0 @@ -# Module: Zlib - - -This module provides access to the [zlib library](http://zlib.net). Zlib is -designed to be a portable, free, general-purpose, legally unencumbered -- that -is, not covered by any patents -- lossless data-compression library for use on -virtually any computer hardware and operating system. - -The zlib compression library provides in-memory compression and decompression -functions, including integrity checks of the uncompressed data. - -The zlib compressed data format is described in RFC 1950, which is a wrapper -around a deflate stream which is described in RFC 1951. - -The library also supports reading and writing files in gzip (.gz) format with -an interface similar to that of IO. The gzip format is described in RFC 1952 -which is also a wrapper around a deflate stream. - -The zlib format was designed to be compact and fast for use in memory and on -communications channels. The gzip format was designed for single-file -compression on file systems, has a larger header than zlib to maintain -directory information, and uses a different, slower check method than zlib. - -See your system's zlib.h for further information about zlib - -## Sample usage - -Using the wrapper to compress strings with default parameters is quite simple: - - require "zlib" - - data_to_compress = File.read("don_quixote.txt") - - puts "Input size: #{data_to_compress.size}" - #=> Input size: 2347740 - - data_compressed = Zlib::Deflate.deflate(data_to_compress) - - puts "Compressed size: #{data_compressed.size}" - #=> Compressed size: 887238 - - uncompressed_data = Zlib::Inflate.inflate(data_compressed) - - puts "Uncompressed data is: #{uncompressed_data}" - #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote... - -## Class tree - -* Zlib::Deflate -* Zlib::Inflate -* Zlib::ZStream -* Zlib::Error - * Zlib::StreamEnd - * Zlib::NeedDict - * Zlib::DataError - * Zlib::StreamError - * Zlib::MemError - * Zlib::BufError - * Zlib::VersionError - * Zlib::InProgressError - -(if you have GZIP_SUPPORT) -* Zlib::GzipReader -* Zlib::GzipWriter -* Zlib::GzipFile -* Zlib::GzipFile::Error - * Zlib::GzipFile::LengthError - * Zlib::GzipFile::CRCError - * Zlib::GzipFile::NoFooter - - -# Class Methods -## adler32(*args ) [](#method-c-adler32) -call-seq: Zlib.adler32(string, adler) - -Calculates Adler-32 checksum for `string`, and returns updated value of -`adler`. If `string` is omitted, it returns the Adler-32 initial value. If -`adler` is omitted, it assumes that the initial value is given to `adler`. If -`string` is an IO instance, reads from the IO until the IO returns nil and -returns Adler-32 of all read data. - -Example usage: - - require "zlib" - - data = "foo" - puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" - #=> Adler32 checksum: 2820145 -## adler32_combine(adler1 , adler2 , len2 ) [](#method-c-adler32_combine) -call-seq: Zlib.adler32_combine(adler1, adler2, len2) - -Combine two Adler-32 check values in to one. `adler1` is the first Adler-32 -value, `adler2` is the second Adler-32 value. `len2` is the length of the -string used to generate `adler2`. -## crc32(*args ) [](#method-c-crc32) -call-seq: Zlib.crc32(string, crc) - -Calculates CRC checksum for `string`, and returns updated value of `crc`. If -`string` is omitted, it returns the CRC initial value. If `crc` is omitted, it -assumes that the initial value is given to `crc`. If `string` is an IO -instance, reads from the IO until the IO returns nil and returns CRC checksum -of all read data. - -FIXME: expression. -## crc32_combine(crc1 , crc2 , len2 ) [](#method-c-crc32_combine) -call-seq: Zlib.crc32_combine(crc1, crc2, len2) - -Combine two CRC-32 check values in to one. `crc1` is the first CRC-32 value, -`crc2` is the second CRC-32 value. `len2` is the length of the string used to -generate `crc2`. -## crc_table() [](#method-c-crc_table) -Returns the table for calculating CRC checksum as an array. -## deflate(*args ) [](#method-c-deflate) -call-seq: - Zlib.deflate(string[, level]) - Zlib::Deflate.deflate(string[, level]) - -Compresses the given `string`. Valid values of level are Zlib::NO_COMPRESSION, -Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, or an -integer from 0 to 9. - -This method is almost equivalent to the following code: - - def deflate(string, level) - z = Zlib::Deflate.new(level) - dst = z.deflate(string, Zlib::FINISH) - z.close - dst - end - -See also Zlib.inflate -## gunzip(src ) [](#method-c-gunzip) -Decode the given gzipped `string`. - -This method is almost equivalent to the following code: - - def gunzip(string) - sio = StringIO.new(string) - gz = Zlib::GzipReader.new(sio, encoding: Encoding::ASCII_8BIT) - gz.read - ensure - gz&.close - end - -See also Zlib.gzip -**@overload** [] - -## gzip(*args ) [](#method-c-gzip) -Gzip the given `string`. Valid values of level are Zlib::NO_COMPRESSION, -Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION (default), -or an integer from 0 to 9. - -This method is almost equivalent to the following code: - - def gzip(string, level: nil, strategy: nil) - sio = StringIO.new - sio.binmode - gz = Zlib::GzipWriter.new(sio, level, strategy) - gz.write(string) - gz.close - sio.string - end - -See also Zlib.gunzip -**@overload** [] - -## inflate(src ) [](#method-c-inflate) -call-seq: - Zlib.inflate(string) - Zlib::Inflate.inflate(string) - -Decompresses `string`. Raises a Zlib::NeedDict exception if a preset -dictionary is needed for decompression. - -This method is almost equivalent to the following code: - - def inflate(string) - zstream = Zlib::Inflate.new - buf = zstream.inflate(string) - zstream.finish - zstream.close - buf - end - -See also Zlib.deflate -## zlib_version() [](#method-c-zlib_version) -Returns the string which represents the version of zlib library. - diff --git a/example/ruby/Zlib/BufError.md b/example/ruby/Zlib/BufError.md deleted file mode 100644 index e3bdfc2..0000000 --- a/example/ruby/Zlib/BufError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Zlib::BufError -**Inherits:** Zlib::Error - - -Subclass of Zlib::Error when zlib returns a Z_BUF_ERROR. - -Usually if no progress is possible. - - - diff --git a/example/ruby/Zlib/DataError.md b/example/ruby/Zlib/DataError.md deleted file mode 100644 index 3c04052..0000000 --- a/example/ruby/Zlib/DataError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Zlib::DataError -**Inherits:** Zlib::Error - - -Subclass of Zlib::Error when zlib returns a Z_DATA_ERROR. - -Usually if a stream was prematurely freed. - - - diff --git a/example/ruby/Zlib/Deflate.md b/example/ruby/Zlib/Deflate.md deleted file mode 100644 index 7573951..0000000 --- a/example/ruby/Zlib/Deflate.md +++ /dev/null @@ -1,184 +0,0 @@ -# Class: Zlib::Deflate -**Inherits:** Zlib::ZStream - - -Zlib::Deflate is the class for compressing data. See Zlib::ZStream for more -information. - - -# Class Methods -## deflate(*args ) [](#method-c-deflate) -call-seq: - Zlib.deflate(string[, level]) - Zlib::Deflate.deflate(string[, level]) - -Compresses the given `string`. Valid values of level are Zlib::NO_COMPRESSION, -Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, or an -integer from 0 to 9. - -This method is almost equivalent to the following code: - - def deflate(string, level) - z = Zlib::Deflate.new(level) - dst = z.deflate(string, Zlib::FINISH) - z.close - dst - end - -See also Zlib.inflate - -#Instance Methods -## <<(src) [](#method-i-<<) -call-seq: << string - -Inputs `string` into the deflate stream just like Zlib::Deflate#deflate, but -returns the Zlib::Deflate object itself. The output from the stream is -preserved in output buffer. - -## deflate(*args) [](#method-i-deflate) -call-seq: - z.deflate(string, flush = Zlib::NO_FLUSH) -> String - z.deflate(string, flush = Zlib::NO_FLUSH) { |chunk| ... } -> nil - -Inputs `string` into the deflate stream and returns the output from the -stream. On calling this method, both the input and the output buffers of the -stream are flushed. If `string` is nil, this method finishes the stream, just -like Zlib::ZStream#finish. - -If a block is given consecutive deflated chunks from the `string` are yielded -to the block and `nil` is returned. - -The `flush` parameter specifies the flush mode. The following constants may -be used: - -Zlib::NO_FLUSH -: The default - -Zlib::SYNC_FLUSH -: Flushes the output to a byte boundary - -Zlib::FULL_FLUSH -: SYNC_FLUSH + resets the compression state - -Zlib::FINISH -: Pending input is processed, pending output is flushed. - - -See the constants for further description. - -## flush(*args) [](#method-i-flush) -call-seq: - flush(flush = Zlib::SYNC_FLUSH) -> String - flush(flush = Zlib::SYNC_FLUSH) { |chunk| ... } -> nil - -This method is equivalent to `deflate('', flush)`. This method is just -provided to improve the readability of your Ruby program. If a block is given -chunks of deflate output are yielded to the block until the buffer is flushed. - -See Zlib::Deflate#deflate for detail on the `flush` constants NO_FLUSH, -SYNC_FLUSH, FULL_FLUSH and FINISH. - -## initialize(*args) [](#method-i-initialize) -call-seq: - Zlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY) - -Creates a new deflate stream for compression. If a given argument is nil, the -default value of that argument is used. - -The `level` sets the compression level for the deflate stream between 0 (no -compression) and 9 (best compression). The following constants have been -defined to make code more readable: - -* Zlib::DEFAULT_COMPRESSION -* Zlib::NO_COMPRESSION -* Zlib::BEST_SPEED -* Zlib::BEST_COMPRESSION - -See http://www.zlib.net/manual.html#Constants for further information. - -The `window_bits` sets the size of the history buffer and should be between 8 -and 15. Larger values of this parameter result in better compression at the -expense of memory usage. - -The `mem_level` specifies how much memory should be allocated for the internal -compression state. 1 uses minimum memory but is slow and reduces compression -ratio while 9 uses maximum memory for optimal speed. The default value is 8. -Two constants are defined: - -* Zlib::DEF_MEM_LEVEL -* Zlib::MAX_MEM_LEVEL - -The `strategy` sets the deflate compression strategy. The following -strategies are available: - -Zlib::DEFAULT_STRATEGY -: For normal data - -Zlib::FILTERED -: For data produced by a filter or predictor - -Zlib::FIXED -: Prevents dynamic Huffman codes - -Zlib::HUFFMAN_ONLY -: Prevents string matching - -Zlib::RLE -: Designed for better compression of PNG image data - - -See the constants for further description. - -## Examples - -### Basic - - open "compressed.file", "w+" do |io| - io << Zlib::Deflate.new.deflate(File.read("big.file")) - end - -### Custom compression - - open "compressed.file", "w+" do |compressed_io| - deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION, - Zlib::MAX_WBITS, - Zlib::MAX_MEM_LEVEL, - Zlib::HUFFMAN_ONLY) - - begin - open "big.file" do |big_io| - until big_io.eof? do - compressed_io << zd.deflate(big_io.read(16384)) - end - end - ensure - deflate.close - end - end - -While this example will work, for best optimization review the flags for your -specific time, memory usage and output space requirements. - -## initialize_copy(orig) [](#method-i-initialize_copy) -Duplicates the deflate stream. - -## params(v_level, v_strategy) [](#method-i-params) -call-seq: params(level, strategy) - -Changes the parameters of the deflate stream to allow changes between -different types of data that require different types of compression. Any -unprocessed data is flushed before changing the params. - -See Zlib::Deflate.new for a description of `level` and `strategy`. - -## set_dictionary(dic) [](#method-i-set_dictionary) -call-seq: set_dictionary(string) - -Sets the preset dictionary and returns `string`. This method is available just -only after Zlib::Deflate.new or Zlib::ZStream#reset method was called. See -zlib.h for details. - -Can raise errors of Z_STREAM_ERROR if a parameter is invalid (such as NULL -dictionary) or the stream state is inconsistent, Z_DATA_ERROR if the given -dictionary doesn't match the expected one (incorrect adler32 value) - diff --git a/example/ruby/Zlib/Error.md b/example/ruby/Zlib/Error.md deleted file mode 100644 index c19c312..0000000 --- a/example/ruby/Zlib/Error.md +++ /dev/null @@ -1,20 +0,0 @@ -# Exception: Zlib::Error -**Inherits:** StandardError - - -The superclass for all exceptions raised by Ruby/zlib. - -The following exceptions are defined as subclasses of Zlib::Error. These -exceptions are raised when zlib library functions return with an error status. - -* Zlib::StreamEnd -* Zlib::NeedDict -* Zlib::DataError -* Zlib::StreamError -* Zlib::MemError -* Zlib::BufError -* Zlib::VersionError -* Zlib::InProgressError - - - diff --git a/example/ruby/Zlib/GzipFile.md b/example/ruby/Zlib/GzipFile.md deleted file mode 100644 index e760248..0000000 --- a/example/ruby/Zlib/GzipFile.md +++ /dev/null @@ -1,100 +0,0 @@ -# Class: Zlib::GzipFile -**Inherits:** Object - - -Zlib::GzipFile is an abstract class for handling a gzip formatted compressed -file. The operations are defined in the subclasses, Zlib::GzipReader for -reading, and Zlib::GzipWriter for writing. - -GzipReader should be used by associating an IO, or IO-like, object. - -## Method Catalogue - -* ::wrap -* ::open (Zlib::GzipReader::open and Zlib::GzipWriter::open) -* #close -* #closed? -* #comment -* comment= (Zlib::GzipWriter#comment=) -* #crc -* eof? (Zlib::GzipReader#eof?) -* #finish -* #level -* lineno (Zlib::GzipReader#lineno) -* lineno= (Zlib::GzipReader#lineno=) -* #mtime -* mtime= (Zlib::GzipWriter#mtime=) -* #orig_name -* orig_name (Zlib::GzipWriter#orig_name=) -* #os_code -* path (when the underlying IO supports #path) -* #sync -* #sync= -* #to_io - -(due to internal structure, documentation may appear under Zlib::GzipReader or -Zlib::GzipWriter) - - -# Class Methods -## wrap(*args ) [](#method-c-wrap) -call-seq: - Zlib::GzipReader.wrap(io, ...) { |gz| ... } - Zlib::GzipWriter.wrap(io, ...) { |gz| ... } - -Creates a GzipReader or GzipWriter associated with `io`, passing in any -necessary extra options, and executes the block with the newly created object -just like File.open. - -The GzipFile object will be closed automatically after executing the block. If -you want to keep the associated IO object open, you may call -Zlib::GzipFile#finish method in the block. - -#Instance Methods -## close() [](#method-i-close) -Closes the GzipFile object. This method calls close method of the associated -IO object. Returns the associated IO object. - -## closed?() [](#method-i-closed?) -Same as IO#closed? - -**@return** [Boolean] - -## comment() [](#method-i-comment) -Returns comments recorded in the gzip file header, or nil if the comments is -not present. - -## crc() [](#method-i-crc) -Returns CRC value of the uncompressed data. - -## finish() [](#method-i-finish) -Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method never -calls the close method of the associated IO object. Returns the associated IO -object. - -## level() [](#method-i-level) -Returns compression level. - -## mtime() [](#method-i-mtime) -Returns last modification time recorded in the gzip file header. - -## orig_name() [](#method-i-orig_name) -Returns original filename recorded in the gzip file header, or `nil` if -original filename is not present. - -## os_code() [](#method-i-os_code) -Returns OS code number recorded in the gzip file header. - -## sync() [](#method-i-sync) -Same as IO#sync - -## sync=(mode) [](#method-i-sync=) -call-seq: sync = flag - -Same as IO. If flag is `true`, the associated IO object must respond to the -`flush` method. While `sync` mode is `true`, the compression ratio decreases -sharply. - -## to_io() [](#method-i-to_io) -Same as IO. - diff --git a/example/ruby/Zlib/GzipFile/CRCError.md b/example/ruby/Zlib/GzipFile/CRCError.md deleted file mode 100644 index ef67b72..0000000 --- a/example/ruby/Zlib/GzipFile/CRCError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Zlib::GzipFile::CRCError -**Inherits:** Zlib::GzipFile::Error - - -Raised when the CRC checksum recorded in gzip file footer is not equivalent to -the CRC checksum of the actual uncompressed data. - - - diff --git a/example/ruby/Zlib/GzipFile/Error.md b/example/ruby/Zlib/GzipFile/Error.md deleted file mode 100644 index 1e56963..0000000 --- a/example/ruby/Zlib/GzipFile/Error.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Zlib::GzipFile::Error -**Inherits:** Zlib::Error - - -Base class of errors that occur when processing GZIP files. - - -# Attributes -## input[RW] [](#attribute-i-input) -input gzipped string - - -#Instance Methods -## inspect() [](#method-i-inspect) -Constructs a String of the GzipFile Error - diff --git a/example/ruby/Zlib/GzipFile/LengthError.md b/example/ruby/Zlib/GzipFile/LengthError.md deleted file mode 100644 index 9da6de9..0000000 --- a/example/ruby/Zlib/GzipFile/LengthError.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: Zlib::GzipFile::LengthError -**Inherits:** Zlib::GzipFile::Error - - -Raised when the data length recorded in the gzip file footer is not equivalent -to the length of the actual uncompressed data. - - - diff --git a/example/ruby/Zlib/GzipFile/NoFooter.md b/example/ruby/Zlib/GzipFile/NoFooter.md deleted file mode 100644 index d6882a6..0000000 --- a/example/ruby/Zlib/GzipFile/NoFooter.md +++ /dev/null @@ -1,8 +0,0 @@ -# Exception: Zlib::GzipFile::NoFooter -**Inherits:** Zlib::GzipFile::Error - - -Raised when gzip file footer is not found. - - - diff --git a/example/ruby/Zlib/GzipReader.md b/example/ruby/Zlib/GzipReader.md deleted file mode 100644 index 61f8a74..0000000 --- a/example/ruby/Zlib/GzipReader.md +++ /dev/null @@ -1,2233 +0,0 @@ -# Class: Zlib::GzipReader -**Inherits:** Zlib::GzipFile - -**Includes:** Enumerable - - -Zlib::GzipReader is the class for reading a gzipped file. GzipReader should -be used as an IO, or -IO-like, object. - - Zlib::GzipReader.open('hoge.gz') {|gz| - print gz.read - } - - File.open('hoge.gz') do |f| - gz = Zlib::GzipReader.new(f) - print gz.read - gz.close - end - -## Method Catalogue - -The following methods in Zlib::GzipReader are just like their counterparts in -IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an error -was found in the gzip file. -* #each -* #each_line -* #each_byte -* #gets -* #getc -* #lineno -* #lineno= -* #read -* #readchar -* #readline -* #readlines -* #ungetc - -Be careful of the footer of the gzip file. A gzip file has the checksum of -pre-compressed data in its footer. GzipReader checks all uncompressed data -against that checksum at the following cases, and if it fails, raises -`Zlib::GzipFile::NoFooter`, `Zlib::GzipFile::CRCError`, or -`Zlib::GzipFile::LengthError` exception. - -* When an reading request is received beyond the end of file (the end of - compressed data). That is, when Zlib::GzipReader#read, - Zlib::GzipReader#gets, or some other methods for reading returns nil. -* When Zlib::GzipFile#close method is called after the object reaches the - end of file. -* When Zlib::GzipReader#unused method is called after the object reaches the - end of file. - -The rest of the methods are adequately described in their own documentation. - - -# Class Methods -## open(*args ) [](#method-c-open) -call-seq: Zlib::GzipReader.open(filename) {|gz| ... } - -Opens a file specified by `filename` as a gzipped file, and returns a -GzipReader object associated with that file. Further details of this method -are in Zlib::GzipReader.new and ZLib::GzipFile.wrap. -## zcat(*args ) [](#method-c-zcat) -call-seq: - Zlib::GzipReader.zcat(io, options = {}, &block) => nil - Zlib::GzipReader.zcat(io, options = {}) => string - -Decompresses all gzip data in the `io`, handling multiple gzip streams until -the end of the `io`. There should not be any non-gzip data after the gzip -streams. - -If a block is given, it is yielded strings of uncompressed data, and the -method returns `nil`. If a block is not given, the method returns the -concatenation of all uncompressed data in all gzip streams. - -#Instance Methods -## all?(*args) [](#method-i-all?) -Returns whether every element meets a given criterion. - -If `self` has no element, returns `true` and argument or block are not used. - -With no argument and no block, returns whether every element is truthy: - - (1..4).all? # => true - %w[a b c d].all? # => true - [1, 2, nil].all? # => false - ['a','b', false].all? # => false - [].all? # => true - -With argument `pattern` and no block, returns whether for each element -`element`, `pattern === element`: - - (1..4).all?(Integer) # => true - (1..4).all?(Numeric) # => true - (1..4).all?(Float) # => false - %w[bar baz bat bam].all?(/ba/) # => true - %w[bar baz bat bam].all?(/bar/) # => false - %w[bar baz bat bam].all?('ba') # => false - {foo: 0, bar: 1, baz: 2}.all?(Array) # => true - {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false - [].all?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for every -element: - - (1..4).all? {|element| element < 5 } # => true - (1..4).all? {|element| element < 4 } # => false - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true - {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false - -Related: #any?, #none? #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## any?(*args) [](#method-i-any?) -Returns whether any element meets a given criterion. - -If `self` has no element, returns `false` and argument or block are not used. - -With no argument and no block, returns whether any element is truthy: - - (1..4).any? # => true - %w[a b c d].any? # => true - [1, false, nil].any? # => true - [].any? # => false - -With argument `pattern` and no block, returns whether for any element -`element`, `pattern === element`: - - [nil, false, 0].any?(Integer) # => true - [nil, false, 0].any?(Numeric) # => true - [nil, false, 0].any?(Float) # => false - %w[bar baz bat bam].any?(/m/) # => true - %w[bar baz bat bam].any?(/foo/) # => false - %w[bar baz bat bam].any?('ba') # => false - {foo: 0, bar: 1, baz: 2}.any?(Array) # => true - {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false - [].any?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for any -element: - - (1..4).any? {|element| element < 2 } # => true - (1..4).any? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false - -Related: #all?, #none?, #one?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## chain(*args) [](#method-i-chain) -Returns an enumerator object generated from this enumerator and given -enumerables. - - e = (1..3).chain([4, 5]) - e.to_a #=> [1, 2, 3, 4, 5] - -**@overload** [] - -## chunk() [](#method-i-chunk) -Each element in the returned enumerator is a 2-element array consisting of: - -* A value returned by the block. -* An array ("chunk") containing the element for which that value was - returned, and all following elements for which the block returned the same - value: - -So that: - -* Each block return value that is different from its predecessor begins a - new chunk. -* Each block return value that is the same as its predecessor continues the - same chunk. - -Example: - - e = (0..10).chunk {|i| (i / 3).floor } # => # - # The enumerator elements. - e.next # => [0, [0, 1, 2]] - e.next # => [1, [3, 4, 5]] - e.next # => [2, [6, 7, 8]] - e.next # => [3, [9, 10]] - -Method `chunk` is especially useful for an enumerable that is already sorted. -This example counts words for each initial letter in a large array of words: - - # Get sorted words from a web page. - url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' - words = URI::open(url).readlines - # Make chunks, one for each letter. - e = words.chunk {|word| word.upcase[0] } # => # - # Display 'A' through 'F'. - e.each {|c, words| p [c, words.length]; break if c == 'F' } - -Output: - - ["A", 17096] - ["B", 11070] - ["C", 19901] - ["D", 10896] - ["E", 8736] - ["F", 6860] - -You can use the special symbol `:_alone` to force an element into its own -separate chuck: - - a = [0, 0, 1, 1] - e = a.chunk{|i| i.even? ? :_alone : true } - e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] - -For example, you can put each line that contains a URL into its own chunk: - - pattern = /http/ - open(filename) { |f| - f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| - pp lines - } - } - -You can use the special symbol `:_separator` or `nil` to force an element to -be ignored (not included in any chunk): - - a = [0, 0, -1, 1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1, 1]]] - -Note that the separator does end the chunk: - - a = [0, 0, -1, 1, -1, 1] - e = a.chunk{|i| i < 0 ? :_separator : true } - e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] - -For example, the sequence of hyphens in svn log can be eliminated as follows: - - sep = "-"*72 + "\n" - IO.popen("svn log README") { |f| - f.chunk { |line| - line != sep || nil - }.each { |_, lines| - pp lines - } - } - #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Update the portability section.\n", - # "\n"] - # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", - # "\n", - # "* README, README.ja: Add a note about default C flags.\n", - # "\n"] - # ... - -Paragraphs separated by empty lines can be parsed as follows: - - File.foreach("README").chunk { |line| - /\A\s*\z/ !~ line || nil - }.each { |_, lines| - pp lines - } - -**@overload** [] - -## chunk_while() [](#method-i-chunk_while) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `false`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.chunk_while {|i, j| i+1 == j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.chunk_while {|i, j| i <= j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.chunk_while {|i, j| i.even? == j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Enumerable#slice_when does the same, except splitting when the block returns -`true` instead of `false`. - -**@overload** [] - -## collect() [](#method-i-collect) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## collect_concat() [](#method-i-collect_concat) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## compact() [](#method-i-compact) -Returns an array of all non-`nil` elements: - - a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] - a.compact # => [0, "a", false, false, "a", 0] - -**@overload** [] - -## count(*args) [](#method-i-count) -Returns the count of elements, based on an argument or block criterion, if -given. - -With no argument and no block given, returns the number of elements: - - [0, 1, 2].count # => 3 - {foo: 0, bar: 1, baz: 2}.count # => 3 - -With argument `object` given, returns the number of elements that are `==` to -`object`: - - [0, 1, 2, 1].count(1) # => 2 - -With a block given, calls the block with each element and returns the number -of elements for which the block returns a truthy value: - - [0, 1, 2, 3].count {|element| element < 2} # => 2 - {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## cycle(*args) [](#method-i-cycle) -When called with positive integer argument `n` and a block, calls the block -with each element, then does so again, until it has done so `n` times; returns -`nil`: - - a = [] - (1..4).cycle(3) {|element| a.push(element) } # => nil - a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] - a = [] - ('a'..'d').cycle(2) {|element| a.push(element) } - a # => ["a", "b", "c", "d", "a", "b", "c", "d"] - a = [] - {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } - a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] - -If count is zero or negative, does not call the block. - -When called with a block and `n` is `nil`, cycles forever. - -When no block is given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## detect(*args) [](#method-i-detect) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## drop(n) [](#method-i-drop) -For positive integer `n`, returns an array containing all but the first `n` -elements: - - r = (1..4) - r.drop(3) # => [4] - r.drop(2) # => [3, 4] - r.drop(1) # => [2, 3, 4] - r.drop(0) # => [1, 2, 3, 4] - r.drop(50) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.drop(2) # => [[:baz, 2], [:bat, 3]] - -**@overload** [] - -## drop_while() [](#method-i-drop_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements after that point: - - (1..4).drop_while{|i| i < 3 } # => [3, 4] - h = {foo: 0, bar: 1, baz: 2} - a = h.drop_while{|element| key, value = *element; value < 2 } - a # => [[:baz, 2]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each(*args) [](#method-i-each) -See Zlib::GzipReader documentation for a description. - -## each_byte() [](#method-i-each_byte) -See Zlib::GzipReader documentation for a description. - -## each_char() [](#method-i-each_char) -See Zlib::GzipReader documentation for a description. - -## each_cons(n) [](#method-i-each_cons) -Calls the block with each successive overlapped `n`-tuple of elements; returns -`self`: - - a = [] - (1..5).each_cons(3) {|element| a.push(element) } - a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bam: 3} - h.each_cons(2) {|element| a.push(element) } - a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_entry(*args) [](#method-i-each_entry) -Calls the given block with each element, converting multiple values from yield -to an array; returns `self`: - - a = [] - (1..4).each_entry {|element| a.push(element) } # => 1..4 - a # => [1, 2, 3, 4] - - a = [] - h = {foo: 0, bar: 1, baz:2} - h.each_entry {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:foo, 0], [:bar, 1], [:baz, 2]] - - class Foo - include Enumerable - def each - yield 1 - yield 1, 2 - yield - end - end - Foo.new.each_entry {|yielded| p yielded } - -Output: - - 1 - [1, 2] - nil - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_line(*args) [](#method-i-each_line) -See Zlib::GzipReader documentation for a description. - -## each_slice(n) [](#method-i-each_slice) -Calls the block with each successive disjoint `n`-tuple of elements; returns -`self`: - - a = [] - (1..10).each_slice(3) {|tuple| a.push(tuple) } - a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] - - a = [] - h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} - h.each_slice(2) {|tuple| a.push(tuple) } - a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_index(*args) [](#method-i-each_with_index) -Invoke `self.each` with `*args`. With a block given, the block receives each -element and its index; returns `self`: - - h = {} - (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 - h # => {1=>0, 2=>1, 3=>2, 4=>3} - - h = {} - %w[a b c d].each_with_index {|element, i| h[element] = i } - # => ["a", "b", "c", "d"] - h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} - - a = [] - h = {foo: 0, bar: 1, baz: 2} - h.each_with_index {|element, i| a.push([i, element]) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## each_with_object(memo) [](#method-i-each_with_object) -Calls the block once for each element, passing both the element and the given -object: - - (1..4).each_with_object([]) {|i, a| a.push(i**2) } - # => [1, 4, 9, 16] - - {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k } - # => {0=>:foo, 1=>:bar, 2=>:baz} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## entries(*args) [](#method-i-entries) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## eof() [](#method-i-eof) -Returns `true` or `false` whether the stream has reached the end. - -## eof?() [](#method-i-eof?) -Returns `true` or `false` whether the stream has reached the end. - -**@return** [Boolean] - -## external_encoding() [](#method-i-external_encoding) -See Zlib::GzipReader documentation for a description. - -## filter() [](#method-i-filter) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## filter_map() [](#method-i-filter_map) -Returns an array containing truthy elements returned by the block. - -With a block given, calls the block with successive elements; returns an array -containing each truthy value returned by the block: - - (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] - {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] - -When no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find(*args) [](#method-i-find) -Returns the first element for which the block returns a truthy value. - -With a block given, calls the block with successive elements of the -collection; returns the first element for which the block returns a truthy -value: - - (0..9).find {|element| element > 2} # => 3 - -If no such element is found, calls `if_none_proc` and returns its return -value. - - (0..9).find(proc {false}) {|element| element > 12} # => false - {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] - {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## find_all() [](#method-i-find_all) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## find_index(*args) [](#method-i-find_index) -Returns the index of the first element that meets a specified criterion, or -`nil` if no such element is found. - -With argument `object` given, returns the index of the first element that is -`==` `object`: - - ['a', 'b', 'c', 'b'].find_index('b') # => 1 - -With a block given, calls the block with successive elements; returns the -first element for which the block returns a truthy value: - - ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 - {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 - -With no argument and no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## first(*args) [](#method-i-first) -Returns the first element or elements. - -With no argument, returns the first element, or `nil` if there is none: - - (1..4).first # => 1 - %w[a b c].first # => "a" - {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] - [].first # => nil - -With integer argument `n`, returns an array containing the first `n` elements -that exist: - - (1..4).first(2) # => [1, 2] - %w[a b c d].first(3) # => ["a", "b", "c"] - %w[a b c d].first(50) # => ["a", "b", "c", "d"] - {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] - [].first(2) # => [] - -**@overload** [] - -**@overload** [] - -## flat_map() [](#method-i-flat_map) -Returns an array of flattened objects returned by the block. - -With a block given, calls the block with successive elements; returns a -flattened array of objects returned by the block: - - [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] - [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] - [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] - {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] - -With no block given, returns an Enumerator. - -Alias: #collect_concat. - -**@overload** [] - -**@overload** [] - -## getbyte() [](#method-i-getbyte) -See Zlib::GzipReader documentation for a description. - -## getc() [](#method-i-getc) -See Zlib::GzipReader documentation for a description. - -## gets(*args) [](#method-i-gets) -See Zlib::GzipReader documentation for a description. However, note that this -method can return `nil` even if #eof? returns false, unlike the behavior of -File#gets. - -## grep(pat) [](#method-i-grep) -Returns an array of objects based elements of `self` that match the given -pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `true`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) # => ["bar", "car"] - (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] - ['a', 'b', 0, 1].grep(Integer) # => [0, 1] - -With a block given, calls the block with each matching element and returns an -array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] - -Related: #grep_v. - -**@overload** [] - -**@overload** [] - -## grep_v(pat) [](#method-i-grep_v) -Returns an array of objects based on elements of `self` that *don't* match the -given pattern. - -With no block given, returns an array containing each element for which -`pattern === element` is `false`: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) # => ["foo", "moo"] - (1..10).grep_v(3..8) # => [1, 2, 9, 10] - ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] - -With a block given, calls the block with each non-matching element and returns -an array containing each object returned by the block: - - a = ['foo', 'bar', 'car', 'moo'] - a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] - -Related: #grep. - -**@overload** [] - -**@overload** [] - -## group_by() [](#method-i-group_by) -With a block given returns a hash: - -* Each key is a return value from the block. -* Each value is an array of those elements for which the block returned that - key. - -Examples: - - g = (1..6).group_by {|i| i%3 } - g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} - h = {foo: 0, bar: 1, baz: 0, bat: 1} - g = h.group_by {|key, value| value } - g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## include?(val) [](#method-i-include?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -call-seq: - Zlib::GzipReader.new(io, options = {}) - -Creates a GzipReader object associated with `io`. The GzipReader object reads -gzipped data from `io`, and parses/decompresses it. The `io` must have a -`read` method that behaves same as the IO#read. - -The `options` hash may be used to set the encoding of the data. -`:external_encoding`, `:internal_encoding` and `:encoding` may be set as in -IO::new. - -If the gzip file header is incorrect, raises an Zlib::GzipFile::Error -exception. - -## inject(*args) [](#method-i-inject) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## lazy() [](#method-i-lazy) -Returns an Enumerator::Lazy, which redefines most Enumerable methods to -postpone enumeration and enumerate values only on an as-needed basis. - -### Example - -The following program finds pythagorean triples: - - def pythagorean_triples - (1..Float::INFINITY).lazy.flat_map {|z| - (1..z).flat_map {|x| - (x..z).select {|y| - x**2 + y**2 == z**2 - }.map {|y| - [x, y, z] - } - } - } - end - # show first ten pythagorean triples - p pythagorean_triples.take(10).force # take is lazy, so force is needed - p pythagorean_triples.first(10) # first is eager - # show pythagorean triples less than 100 - p pythagorean_triples.take_while { |*, z| z < 100 }.force - -**@overload** [] - -## lineno() [](#method-i-lineno) -The line number of the last row read from this file. - -## lineno=(lineno) [](#method-i-lineno=) -Specify line number of the last row read from this file. - -## map() [](#method-i-map) -Returns an array of objects returned by the block. - -With a block given, calls the block with successive elements; returns an array -of the objects returned by the block: - - (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] - {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## max(*args) [](#method-i-max) -Returns the element with the maximum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the maximum element, using the -elements' own method `#<=>` for comparison: - - (1..4).max # => 4 - (-4..-1).max # => -1 - %w[d c b a].max # => "d" - {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] - [].max # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` maximum elements that exist: - - (1..4).max(2) # => [4, 3] - (-4..-1).max(2) # => [-1, -2] - %w[d c b a].max(2) # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] - [].max(2) # => [] - -With a block given, the block determines the maximum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the maximum element as determined -by the block: - - %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" - h = {foo: 0, bar: 1, baz: 2} - h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] - [].max {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` maximum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] - h = {foo: 0, bar: 1, baz: 2} - h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:baz, 2], [:bar, 1]] - [].max(2) {|a, b| a <=> b } # => [] - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## max_by(*args) [](#method-i-max_by) -Returns the elements for which the block returns the maximum values. - -With a block given and no argument, returns the element for which the block -returns the maximum value: - - (1..4).max_by {|element| -element } # => 1 - %w[a b c d].max_by {|element| -element.ord } # => "a" - {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] - [].max_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns maximum values: - - (1..4).max_by(2) {|element| -element } - # => [1, 2] - %w[a b c d].max_by(2) {|element| -element.ord } - # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } - # => [[:foo, 0], [:bar, 1]] - [].max_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #max, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## member?(val) [](#method-i-member?) -Returns whether for any element `object == element`: - - (1..4).include?(2) # => true - (1..4).include?(5) # => false - (1..4).include?('2') # => false - %w[a b c d].include?('b') # => true - %w[a b c d].include?('2') # => false - {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true - {foo: 0, bar: 1, baz: 2}.include?('foo') # => false - {foo: 0, bar: 1, baz: 2}.include?(0) # => false - -**@overload** [] - -## min(*args) [](#method-i-min) -Returns the element with the minimum element according to a given criterion. -The ordering of equal elements is indeterminate and may be unstable. - -With no argument and no block, returns the minimum element, using the -elements' own method `#<=>` for comparison: - - (1..4).min # => 1 - (-4..-1).min # => -4 - %w[d c b a].min # => "a" - {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] - [].min # => nil - -With positive integer argument `n` given, and no block, returns an array -containing the first `n` minimum elements that exist: - - (1..4).min(2) # => [1, 2] - (-4..-1).min(2) # => [-4, -3] - %w[d c b a].min(2) # => ["a", "b"] - {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] - [].min(2) # => [] - -With a block given, the block determines the minimum elements. The block is -called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -With a block given and no argument, returns the minimum element as determined -by the block: - - %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" - h = {foo: 0, bar: 1, baz: 2} - h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] - [].min {|a, b| a <=> b } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the first `n` minimum elements that exist, as determined by the -block. - - %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] - h = {foo: 0, bar: 1, baz: 2} - h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:bar, 1]] - [].min(2) {|a, b| a <=> b } # => [] - -Related: #min_by, #minmax, #max. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## min_by(*args) [](#method-i-min_by) -Returns the elements for which the block returns the minimum values. - -With a block given and no argument, returns the element for which the block -returns the minimum value: - - (1..4).min_by {|element| -element } # => 4 - %w[a b c d].min_by {|element| -element.ord } # => "d" - {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] - [].min_by {|element| -element } # => nil - -With a block given and positive integer argument `n` given, returns an array -containing the `n` elements for which the block returns minimum values: - - (1..4).min_by(2) {|element| -element } - # => [4, 3] - %w[a b c d].min_by(2) {|element| -element.ord } - # => ["d", "c"] - {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } - # => [[:baz, 2], [:bar, 1]] - [].min_by(2) {|element| -element } - # => [] - -Returns an Enumerator if no block is given. - -Related: #min, #minmax, #max_by. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## minmax() [](#method-i-minmax) -Returns a 2-element array containing the minimum and maximum elements -according to a given criterion. The ordering of equal elements is -indeterminate and may be unstable. - -With no argument and no block, returns the minimum and maximum elements, using -the elements' own method `#<=>` for comparison: - - (1..4).minmax # => [1, 4] - (-4..-1).minmax # => [-4, -1] - %w[d c b a].minmax # => ["a", "d"] - {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] - [].minmax # => [nil, nil] - -With a block given, returns the minimum and maximum elements as determined by -the block: - - %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] - h = {foo: 0, bar: 1, baz: 2} - h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } - # => [[:foo, 0], [:baz, 2]] - [].minmax {|a, b| a <=> b } # => [nil, nil] - -Related: #min, #max, #minmax_by. - -**@overload** [] - -**@overload** [] - -## minmax_by() [](#method-i-minmax_by) -Returns a 2-element array containing the elements for which the block returns -minimum and maximum values: - - (1..4).minmax_by {|element| -element } - # => [4, 1] - %w[a b c d].minmax_by {|element| -element.ord } - # => ["d", "a"] - {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } - # => [[:baz, 2], [:foo, 0]] - [].minmax_by {|element| -element } - # => [nil, nil] - -Returns an Enumerator if no block is given. - -Related: #max_by, #minmax, #min_by. - -**@overload** [] - -**@overload** [] - -## none?(*args) [](#method-i-none?) -Returns whether no element meets a given criterion. - -With no argument and no block, returns whether no element is truthy: - - (1..4).none? # => false - [nil, false].none? # => true - {foo: 0}.none? # => false - {foo: 0, bar: 1}.none? # => false - [].none? # => true - -With argument `pattern` and no block, returns whether for no element -`element`, `pattern === element`: - - [nil, false, 1.1].none?(Integer) # => true - %w[bar baz bat bam].none?(/m/) # => false - %w[bar baz bat bam].none?(/foo/) # => true - %w[bar baz bat bam].none?('ba') # => true - {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true - {foo: 0}.none?(Array) # => false - [].none?(Integer) # => true - -With a block given, returns whether the block returns a truthy value for no -element: - - (1..4).none? {|element| element < 1 } # => true - (1..4).none? {|element| element < 2 } # => false - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true - {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false - -Related: #one?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## one?(*args) [](#method-i-one?) -Returns whether exactly one element meets a given criterion. - -With no argument and no block, returns whether exactly one element is truthy: - - (1..1).one? # => true - [1, nil, false].one? # => true - (1..4).one? # => false - {foo: 0}.one? # => true - {foo: 0, bar: 1}.one? # => false - [].one? # => false - -With argument `pattern` and no block, returns whether for exactly one element -`element`, `pattern === element`: - - [nil, false, 0].one?(Integer) # => true - [nil, false, 0].one?(Numeric) # => true - [nil, false, 0].one?(Float) # => false - %w[bar baz bat bam].one?(/m/) # => true - %w[bar baz bat bam].one?(/foo/) # => false - %w[bar baz bat bam].one?('ba') # => false - {foo: 0, bar: 1, baz: 2}.one?(Array) # => false - {foo: 0}.one?(Array) # => true - [].one?(Integer) # => false - -With a block given, returns whether the block returns a truthy value for -exactly one element: - - (1..4).one? {|element| element < 2 } # => true - (1..4).one? {|element| element < 1 } # => false - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true - {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false - -Related: #none?, #all?, #any?. - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## partition() [](#method-i-partition) -With a block given, returns an array of two arrays: - -* The first having those elements for which the block returns a truthy - value. -* The other having all other elements. - -Examples: - - p = (1..4).partition {|i| i.even? } - p # => [[2, 4], [1, 3]] - p = ('a'..'d').partition {|c| c < 'c' } - p # => [["a", "b"], ["c", "d"]] - h = {foo: 0, bar: 1, baz: 2, bat: 3} - p = h.partition {|key, value| key.start_with?('b') } - p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] - p = h.partition {|key, value| value < 2 } - p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] - -With no block given, returns an Enumerator. - -Related: Enumerable#group_by. - -**@overload** [] - -**@overload** [] - -## pos() [](#method-i-pos) -Total number of output bytes output so far. - -## read(*args) [](#method-i-read) -See Zlib::GzipReader documentation for a description. - -## readbyte() [](#method-i-readbyte) -See Zlib::GzipReader documentation for a description. - -## readchar() [](#method-i-readchar) -See Zlib::GzipReader documentation for a description. - -## readline(*args) [](#method-i-readline) -See Zlib::GzipReader documentation for a description. - -## readlines(*args) [](#method-i-readlines) -See Zlib::GzipReader documentation for a description. - -## readpartial(*args) [](#method-i-readpartial) -call-seq: - gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf - - Reads at most maxlen bytes from the gzipped stream but - it blocks only if gzipreader has no data immediately available. - If the optional outbuf argument is present, - it must reference a String, which will receive the data. - It raises EOFError on end of file. - -## reduce(*args) [](#method-i-reduce) -Returns the result of applying a reducer to an initial value and the first -element of the Enumerable. It then takes the result and applies the function -to it and the second element of the collection, and so on. The return value is -the result returned by the final call to the function. - -You can think of - - [ a, b, c, d ].inject(i) { |r, v| fn(r, v) } - -as being - - fn(fn(fn(fn(i, a), b), c), d) - -In a way the `inject` function *injects* the function between the elements of -the enumerable. - -`inject` is aliased as `reduce`. You use it when you want to *reduce* a -collection to a single value. - -**The Calling Sequences** - -Let's start with the most verbose: - - enum.inject(initial_value) do |result, next_value| - # do something with +result+ and +next_value+ - # the value returned by the block becomes the - # value passed in to the next iteration - # as +result+ - end - -For example: - - product = [ 2, 3, 4 ].inject(1) do |result, next_value| - result * next_value - end - product #=> 24 - -When this runs, the block is first called with `1` (the initial value) and `2` -(the first element of the array). The block returns `1*2`, so on the next -iteration the block is called with `2` (the previous result) and `3`. The -block returns `6`, and is called one last time with `6` and `4`. The result of -the block, `24` becomes the value returned by `inject`. This code returns the -product of the elements in the enumerable. - -**First Shortcut: Default Initial value** - -In the case of the previous example, the initial value, `1`, wasn't really -necessary: the calculation of the product of a list of numbers is -self-contained. - -In these circumstances, you can omit the `initial_value` parameter. `inject` -will then initially call the block with the first element of the collection as -the `result` parameter and the second element as the `next_value`. - - [ 2, 3, 4 ].inject do |result, next_value| - result * next_value - end - -This shortcut is convenient, but can only be used when the block produces a -result which can be passed back to it as a first parameter. - -Here's an example where that's not the case: it returns a hash where the keys -are words and the values are the number of occurrences of that word in the -enumerable. - - freqs = File.read("README.md") - .scan(/\w{2,}/) - .reduce(Hash.new(0)) do |counts, word| - counts[word] += 1 - counts - end - freqs #=> {"Actions"=>4, - "Status"=>5, - "MinGW"=>3, - "https"=>27, - "github"=>10, - "com"=>15, ... - -Note that the last line of the block is just the word `counts`. This ensures -the return value of the block is the result that's being calculated. - -**Second Shortcut: a Reducer function** - -A *reducer function* is a function that takes a partial result and the next -value, returning the next partial result. The block that is given to `inject` -is a reducer. - -You can also write a reducer as a function and pass the name of that function -(as a symbol) to `inject`. However, for this to work, the function - -1. Must be defined on the type of the result value -2. Must accept a single parameter, the next value in the collection, and -3. Must return an updated result which will also implement the function. - -Here's an example that adds elements to a string. The two calls invoke the -functions String#concat and String#+ on the result so far, passing it the next -value. - - s = [ "cat", " ", "dog" ].inject("", :concat) - s #=> "cat dog" - s = [ "cat", " ", "dog" ].inject("The result is:", :+) - s #=> "The result is: cat dog" - -Here's a more complex example when the result object maintains state of a -different type to the enumerable elements. - - class Turtle - - def initialize - @x = @y = 0 - end - - def move(dir) - case dir - when "n" then @y += 1 - when "s" then @y -= 1 - when "e" then @x += 1 - when "w" then @x -= 1 - end - self - end - end - - position = "nnneesw".chars.reduce(Turtle.new, :move) - position #=>> # - -**Third Shortcut: Reducer With no Initial Value** - -If your reducer returns a value that it can accept as a parameter, then you -don't have to pass in an initial value. Here `:*` is the name of the *times* -function: - - product = [ 2, 3, 4 ].inject(:*) - product # => 24 - -String concatenation again: - - s = [ "cat", " ", "dog" ].inject(:+) - s #=> "cat dog" - -And an example that converts a hash to an array of two-element subarrays. - - nested = {foo: 0, bar: 1}.inject([], :push) - nested # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -**@overload** [] - -## reject() [](#method-i-reject) -Returns an array of objects rejected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns `nil` or `false`: - - (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] - {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} - -When no block given, returns an Enumerator. - -Related: #select. - -**@overload** [] - -**@overload** [] - -## reverse_each(*args) [](#method-i-reverse_each) -With a block given, calls the block with each element, but in reverse order; -returns `self`: - - a = [] - (1..4).reverse_each {|element| a.push(-element) } # => 1..4 - a # => [-4, -3, -2, -1] - - a = [] - %w[a b c d].reverse_each {|element| a.push(element) } - # => ["a", "b", "c", "d"] - a # => ["d", "c", "b", "a"] - - a = [] - h.reverse_each {|element| a.push(element) } - # => {:foo=>0, :bar=>1, :baz=>2} - a # => [[:baz, 2], [:bar, 1], [:foo, 0]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## rewind() [](#method-i-rewind) -Resets the position of the file pointer to the point created the GzipReader -object. The associated IO object needs to respond to the `seek` method. - -## select() [](#method-i-select) -Returns an array containing elements selected by the block. - -With a block given, calls the block with successive elements; returns an array -of those elements for which the block returns a truthy value: - - (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] - a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } - a # => {:bar=>1, :baz=>2} - -With no block given, returns an Enumerator. - -Related: #reject. - -**@overload** [] - -**@overload** [] - -## slice_after(*args) [](#method-i-slice_after) -Creates an enumerator for each chunked elements. The ends of chunks are -defined by *pattern* and the block. - -If *`pattern* === *elt`* returns `true` or the block returns `true` for the -element, the element is end of a chunk. - -The `===` and *block* is called from the first element to the last element of -*enum*. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_after(pattern).each { |ary| ... } - enum.slice_after { |elt| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `map`, -etc., are also usable. - -For example, continuation lines (lines end with backslash) can be concatenated -as follows: - - lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] - e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] - p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } - #=>["foo\n", "barbaz\n", "\n", "qux\n"] - -**@overload** [] - -**@overload** [] - -## slice_before(*args) [](#method-i-slice_before) -With argument `pattern`, returns an enumerator that uses the pattern to -partition elements into arrays ("slices"). An element begins a new slice if -`element === pattern` (or if it is the first element). - - a = %w[foo bar fop for baz fob fog bam foy] - e = a.slice_before(/ba/) # => # - e.each {|array| p array } - -Output: - - ["foo"] - ["bar", "fop", "for"] - ["baz", "fob", "fog"] - ["bam", "foy"] - -With a block, returns an enumerator that uses the block to partition elements -into arrays. An element begins a new slice if its block return is a truthy -value (or if it is the first element): - - e = (1..20).slice_before {|i| i % 4 == 2 } # => # - e.each {|array| p array } - -Output: - - [1] - [2, 3, 4, 5] - [6, 7, 8, 9] - [10, 11, 12, 13] - [14, 15, 16, 17] - [18, 19, 20] - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, iteration over ChangeLog entries can be implemented as follows: - - # iterate over ChangeLog entries. - open("ChangeLog") { |f| - f.slice_before(/\A\S/).each { |e| pp e } - } - - # same as above. block is used instead of pattern argument. - open("ChangeLog") { |f| - f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } - } - -"svn proplist -R" produces multiline output for each file. They can be chunked -as follows: - - IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| - f.lines.slice_before(/\AProp/).each { |lines| p lines } - } - #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] - # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] - # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] - # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] - # ... - -If the block needs to maintain state over multiple elements, local variables -can be used. For example, three or more consecutive increasing numbers can be -squashed as follows (see `chunk_while` for a better way): - - a = [0, 2, 3, 4, 6, 7, 9] - prev = a[0] - p a.slice_before { |e| - prev, prev2 = e, prev - prev2 + 1 != e - }.map { |es| - es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" - }.join(",") - #=> "0,2-4,6,7,9" - -However local variables should be used carefully if the result enumerator is -enumerated twice or more. The local variables should be initialized for each -enumeration. Enumerator.new can be used to do it. - - # Word wrapping. This assumes all characters have same width. - def wordwrap(words, maxwidth) - Enumerator.new {|y| - # cols is initialized in Enumerator.new. - cols = 0 - words.slice_before { |w| - cols += 1 if cols != 0 - cols += w.length - if maxwidth < cols - cols = w.length - true - else - false - end - }.each {|ws| y.yield ws } - } - end - text = (1..20).to_a.join(" ") - enum = wordwrap(text.split(/\s+/), 10) - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # first enumeration. - puts "-"*10 - enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. - puts "-"*10 - #=> ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - # 1 2 3 4 5 - # 6 7 8 9 10 - # 11 12 13 - # 14 15 16 - # 17 18 19 - # 20 - # ---------- - -mbox contains series of mails which start with Unix From line. So each mail -can be extracted by slice before Unix From line. - - # parse mbox - open("mbox") { |f| - f.slice_before { |line| - line.start_with? "From " - }.each { |mail| - unix_from = mail.shift - i = mail.index("\n") - header = mail[0...i] - body = mail[(i+1)..-1] - body.pop if body.last == "\n" - fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a - p unix_from - pp fields - pp body - } - } - - # split mails in mbox (slice before Unix From line after an empty line) - open("mbox") { |f| - emp = true - f.slice_before { |line| - prevemp = emp - emp = line == "\n" - prevemp && line.start_with?("From ") - }.each { |mail| - mail.pop if mail.last == "\n" - pp mail - } - } - -**@overload** [] - -**@overload** [] - -## slice_when() [](#method-i-slice_when) -Creates an enumerator for each chunked elements. The beginnings of chunks are -defined by the block. - -This method splits each chunk using adjacent elements, *elt_before* and -*elt_after*, in the receiver enumerator. This method split chunks between -*elt_before* and *elt_after* where the block returns `true`. - -The block is called the length of the receiver enumerator minus one. - -The result enumerator yields the chunked elements as an array. So `each` -method can be called as follows: - - enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } - -Other methods of the Enumerator class and Enumerable module, such as `to_a`, -`map`, etc., are also usable. - -For example, one-by-one increasing subsequence can be chunked as follows: - - a = [1,2,4,9,10,11,12,15,16,19,20,21] - b = a.slice_when {|i, j| i+1 != j } - p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] - c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } - p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] - d = c.join(",") - p d #=> "1,2,4,9-12,15,16,19-21" - -Near elements (threshold: 6) in sorted array can be chunked as follows: - - a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] - p a.slice_when {|i, j| 6 < j - i }.to_a - #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] - -Increasing (non-decreasing) subsequence can be chunked as follows: - - a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] - p a.slice_when {|i, j| i > j }.to_a - #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] - -Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is -another way to do it.) - - a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] - p a.slice_when {|i, j| i.even? != j.even? }.to_a - #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] - -Paragraphs (non-empty lines with trailing empty lines) can be chunked as -follows: (See Enumerable#chunk to ignore empty lines.) - - lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] - p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a - #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] - -Enumerable#chunk_while does the same, except splitting when the block returns -`false` instead of `true`. - -**@overload** [] - -## sort() [](#method-i-sort) -Returns an array containing the sorted elements of `self`. The ordering of -equal elements is indeterminate and may be unstable. - -With no block given, the sort compares using the elements' own method `#<=>`: - - %w[b c a d].sort # => ["a", "b", "c", "d"] - {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] - -With a block given, comparisons in the block determine the ordering. The block -is called with two elements `a` and `b`, and must return: - -* A negative integer if `a < b`. -* Zero if `a == b`. -* A positive integer if `a > b`. - -Examples: - - a = %w[b c a d] - a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] - h = {foo: 0, bar: 1, baz: 2} - h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] - -See also #sort_by. It implements a Schwartzian transform which is useful when -key computation or comparison is expensive. - -**@overload** [] - -**@overload** [] - -## sort_by() [](#method-i-sort_by) -With a block given, returns an array of elements of `self`, sorted according -to the value returned by the block for each element. The ordering of equal -elements is indeterminate and may be unstable. - -Examples: - - a = %w[xx xxx x xxxx] - a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] - a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] - h = {foo: 2, bar: 1, baz: 0} - h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] - h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] - -With no block given, returns an Enumerator. - -The current implementation of #sort_by generates an array of tuples containing -the original collection element and the mapped value. This makes #sort_by -fairly expensive when the keysets are simple. - - require 'benchmark' - - a = (1..100000).map { rand(100000) } - - Benchmark.bm(10) do |b| - b.report("Sort") { a.sort } - b.report("Sort by") { a.sort_by { |a| a } } - end - -*produces:* - - user system total real - Sort 0.180000 0.000000 0.180000 ( 0.175469) - Sort by 1.980000 0.040000 2.020000 ( 2.013586) - -However, consider the case where comparing the keys is a non-trivial -operation. The following code sorts some files on modification time using the -basic #sort method. - - files = Dir["*"] - sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This sort is inefficient: it generates two new File objects during every -comparison. A slightly better technique is to use the Kernel#test method to -generate the modification times directly. - - files = Dir["*"] - sorted = files.sort { |a, b| - test(?M, a) <=> test(?M, b) - } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This still generates many unnecessary Time objects. A more efficient technique -is to cache the sort keys (modification times in this case) before the sort. -Perl users often call this approach a Schwartzian transform, after Randal -Schwartz. We construct a temporary array, where each element is an array -containing our sort key along with the filename. We sort this array, and then -extract the filename from the result. - - sorted = Dir["*"].collect { |f| - [test(?M, f), f] - }.sort.collect { |f| f[1] } - sorted #=> ["mon", "tues", "wed", "thurs"] - -This is exactly what #sort_by does internally. - - sorted = Dir["*"].sort_by { |f| test(?M, f) } - sorted #=> ["mon", "tues", "wed", "thurs"] - -To produce the reverse of a specific order, the following can be used: - - ary.sort_by { ... }.reverse! - -**@overload** [] - -**@overload** [] - -## sum(*args) [](#method-i-sum) -With no block given, returns the sum of `initial_value` and the elements: - - (1..100).sum # => 5050 - (1..100).sum(1) # => 5051 - ('a'..'d').sum('foo') # => "fooabcd" - -Generally, the sum is computed using methods `+` and `each`; for performance -optimizations, those methods may not be used, and so any redefinition of those -methods may not have effect here. - -One such optimization: When possible, computes using Gauss's summation formula -*n(n+1)/2*: - - 100 * (100 + 1) / 2 # => 5050 - -With a block given, calls the block with each element; returns the sum of -`initial_value` and the block return values: - - (1..4).sum {|i| i*i } # => 30 - (1..4).sum(100) {|i| i*i } # => 130 - h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} - h.sum {|key, value| value.odd? ? value : 0 } # => 9 - ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" - -**@overload** [] - -**@overload** [] - -## take(n) [](#method-i-take) -For non-negative integer `n`, returns the first `n` elements: - - r = (1..4) - r.take(2) # => [1, 2] - r.take(0) # => [] - - h = {foo: 0, bar: 1, baz: 2, bat: 3} - h.take(2) # => [[:foo, 0], [:bar, 1]] - -**@overload** [] - -## take_while() [](#method-i-take_while) -Calls the block with successive elements as long as the block returns a truthy -value; returns an array of all elements up to that point: - - (1..4).take_while{|i| i < 3 } # => [1, 2] - h = {foo: 0, bar: 1, baz: 2} - h.take_while{|element| key, value = *element; value < 2 } - # => [[:foo, 0], [:bar, 1]] - -With no block given, returns an Enumerator. - -**@overload** [] - -**@overload** [] - -## tally(*args) [](#method-i-tally) -When argument `hash` is not given, returns a new hash whose keys are the -distinct elements in `self`; each integer value is the count of occurrences of -each element: - - %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} - -When argument `hash` is given, returns `hash`, possibly augmented; for each -element `ele` in `self`: - -* Adds it as a key with a zero value if that key does not already exist: - - hash[ele] = 0 unless hash.include?(ele) - -* Increments the value of key `ele`: - - hash[ele] += 1 - -This is useful for accumulating tallies across multiple enumerables: - - h = {} # => {} - %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} - %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} - %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1} - -The key to be added or found for an element depends on the class of `self`; -see [Enumerable in Ruby -Classes](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes). - -Examples: - -* Array (and certain array-like classes): the key is the element (as above). -* Hash (and certain hash-like classes): the key is the 2-element array - formed from the key-value pair: - - h = {} # => {} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1} - {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2} - -**@overload** [] - -## tell() [](#method-i-tell) -Total number of output bytes output so far. - -## to_a(*args) [](#method-i-to_a) -Returns an array containing the items in `self`: - - (0..4).to_a # => [0, 1, 2, 3, 4] - -**@overload** [] - -## to_h(*args) [](#method-i-to_h) -When `self` consists of 2-element arrays, returns a hash each of whose entries -is the key-value pair formed from one of those arrays: - - [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} - -When a block is given, the block is called with each element of `self`; the -block should return a 2-element array which becomes a key-value pair in the -returned hash: - - (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} - -Raises an exception if an element of `self` is not a 2-element array, and a -block is not passed. - -**@overload** [] - -**@overload** [] - -## to_set(klassSet, *args, &block) [](#method-i-to_set) -Makes a set from the enumerable object with given arguments. - -## ungetbyte(ch) [](#method-i-ungetbyte) -See Zlib::GzipReader documentation for a description. - -## ungetc(s) [](#method-i-ungetc) -See Zlib::GzipReader documentation for a description. - -## uniq() [](#method-i-uniq) -With no block, returns a new array containing only unique elements; the array -has no two elements `e0` and `e1` such that `e0.eql?(e1)`: - - %w[a b c c b a a b c].uniq # => ["a", "b", "c"] - [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] - -With a block, returns a new array containing elements only for which the block -returns a unique value: - - a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] - a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] - a = %w[a b c d e e d c b a a b c d e] - a.uniq {|c| c < 'c' } # => ["a", "c"] - -**@overload** [] - -**@overload** [] - -## unused() [](#method-i-unused) -Returns the rest of the data which had read for parsing gzip format, or `nil` -if the whole gzip file is not parsed yet. - -## zip(*args) [](#method-i-zip) -With no block given, returns a new array `new_array` of size self.size whose -elements are arrays. Each nested array `new_array[n]` is of size -`other_enums.size+1`, and contains: - -* The `n`-th element of self. -* The `n`-th element of each of the `other_enums`. - -If all `other_enums` and self are the same size, all elements are included in -the result, and there is no `nil`-filling: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - - f = {foo: 0, bar: 1, baz: 2} - g = {goo: 3, gar: 4, gaz: 5} - h = {hoo: 6, har: 7, haz: 8} - d = f.zip(g, h) - d # => [ - # [[:foo, 0], [:goo, 3], [:hoo, 6]], - # [[:bar, 1], [:gar, 4], [:har, 7]], - # [[:baz, 2], [:gaz, 5], [:haz, 8]] - # ] - -If any enumerable in other_enums is smaller than self, fills to `self.size` -with `nil`: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2] - c = [:c0, :c1] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] - -If any enumerable in other_enums is larger than self, its trailing elements -are ignored: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3, :b4] - c = [:c0, :c1, :c2, :c3, :c4, :c5] - d = a.zip(b, c) - d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] - -When a block is given, calls the block with each of the sub-arrays (formed as -above); returns nil: - - a = [:a0, :a1, :a2, :a3] - b = [:b0, :b1, :b2, :b3] - c = [:c0, :c1, :c2, :c3] - a.zip(b, c) {|sub_array| p sub_array} # => nil - -Output: - - [:a0, :b0, :c0] - [:a1, :b1, :c1] - [:a2, :b2, :c2] - [:a3, :b3, :c3] - -**@overload** [] - -**@overload** [] - diff --git a/example/ruby/Zlib/GzipWriter.md b/example/ruby/Zlib/GzipWriter.md deleted file mode 100644 index 5a2cd88..0000000 --- a/example/ruby/Zlib/GzipWriter.md +++ /dev/null @@ -1,105 +0,0 @@ -# Class: Zlib::GzipWriter -**Inherits:** Zlib::GzipFile - - -Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should be -used with an instance of IO, or IO-like, object. - -Following two example generate the same result. - - Zlib::GzipWriter.open('hoge.gz') do |gz| - gz.write 'jugemu jugemu gokou no surikire...' - end - - File.open('hoge.gz', 'w') do |f| - gz = Zlib::GzipWriter.new(f) - gz.write 'jugemu jugemu gokou no surikire...' - gz.close - end - -To make like gzip(1) does, run following: - - orig = 'hoge.txt' - Zlib::GzipWriter.open('hoge.gz') do |gz| - gz.mtime = File.mtime(orig) - gz.orig_name = orig - gz.write IO.binread(orig) - end - -NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close -GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter will -be not able to write the gzip footer and will generate a broken gzip file. - - -# Class Methods -## open(*args ) [](#method-c-open) -Opens a file specified by `filename` for writing gzip compressed data, and -returns a GzipWriter object associated with that file. Further details of -this method are found in Zlib::GzipWriter.new and Zlib::GzipFile.wrap. -**@overload** [] - - -#Instance Methods -## <<() [](#method-i-<<) -Same as IO. - -## comment=(str) [](#method-i-comment=) -Specify the comment (`str`) in the gzip header. - -## flush(*args) [](#method-i-flush) -Flushes all the internal buffers of the GzipWriter object. The meaning of -`flush` is same as in Zlib::Deflate#deflate. `Zlib::SYNC_FLUSH` is used if -`flush` is omitted. It is no use giving flush `Zlib::NO_FLUSH`. - -**@overload** [] - -## initialize(*args) [](#method-i-initialize) -Creates a GzipWriter object associated with `io`. `level` and `strategy` -should be the same as the arguments of Zlib::Deflate.new. The GzipWriter -object writes gzipped data to `io`. `io` must respond to the `write` method -that behaves the same as IO#write. - -The `options` hash may be used to set the encoding of the data. -`:external_encoding`, `:internal_encoding` and `:encoding` may be set as in -IO::new. - -**@overload** [] - -## mtime=(mtime) [](#method-i-mtime=) -Specify the modification time (`mtime`) in the gzip header. Using an Integer. - -Setting the mtime in the gzip header does not effect the mtime of the file -generated. Different utilities that expand the gzipped files may use the mtime -header. For example the gunzip utility can use the `-N` flag which will set -the resultant file's mtime to the value in the header. By default many tools -will set the mtime of the expanded file to the mtime of the gzipped file, not -the mtime in the header. - -If you do not set an mtime, the default value will be the time when -compression started. Setting a value of 0 indicates no time stamp is -available. - -## orig_name=(str) [](#method-i-orig_name=) -Specify the original name (`str`) in the gzip header. - -## pos() [](#method-i-pos) -Total number of input bytes read so far. - -## print() [](#method-i-print) -Same as IO. - -## printf() [](#method-i-printf) -Same as IO. - -## putc(ch) [](#method-i-putc) -Same as IO. - -## puts() [](#method-i-puts) -Same as IO. - -## tell() [](#method-i-tell) -Total number of input bytes read so far. - -## write(*args) [](#method-i-write) -Same as IO. - diff --git a/example/ruby/Zlib/InProgressError.md b/example/ruby/Zlib/InProgressError.md deleted file mode 100644 index 72b6eb8..0000000 --- a/example/ruby/Zlib/InProgressError.md +++ /dev/null @@ -1,16 +0,0 @@ -# Exception: Zlib::InProgressError -**Inherits:** Zlib::Error - - -Subclass of Zlib::Error. This error is raised when the zlib stream is -currently in progress. - -For example: - - inflater = Zlib::Inflate.new - inflater.inflate(compressed) do - inflater.inflate(compressed) # Raises Zlib::InProgressError - end - - - diff --git a/example/ruby/Zlib/Inflate.md b/example/ruby/Zlib/Inflate.md deleted file mode 100644 index 08fe5ed..0000000 --- a/example/ruby/Zlib/Inflate.md +++ /dev/null @@ -1,158 +0,0 @@ -# Class: Zlib::Inflate -**Inherits:** Zlib::ZStream - - -Zlib:Inflate is the class for decompressing compressed data. Unlike -Zlib::Deflate, an instance of this class is not able to duplicate (clone, dup) -itself. - - -# Class Methods -## inflate(src ) [](#method-c-inflate) -call-seq: - Zlib.inflate(string) - Zlib::Inflate.inflate(string) - -Decompresses `string`. Raises a Zlib::NeedDict exception if a preset -dictionary is needed for decompression. - -This method is almost equivalent to the following code: - - def inflate(string) - zstream = Zlib::Inflate.new - buf = zstream.inflate(string) - zstream.finish - zstream.close - buf - end - -See also Zlib.deflate - -#Instance Methods -## <<(src) [](#method-i-<<) -Inputs `string` into the inflate stream just like Zlib::Inflate#inflate, but -returns the Zlib::Inflate object itself. The output from the stream is -preserved in output buffer. - -**@overload** [] - -## add_dictionary(dictionary) [](#method-i-add_dictionary) -call-seq: add_dictionary(string) - -Provide the inflate stream with a dictionary that may be required in the -future. Multiple dictionaries may be provided. The inflate stream will -automatically choose the correct user-provided dictionary based on the -stream's required dictionary. - -## inflate(*args) [](#method-i-inflate) -call-seq: - inflate(deflate_string, buffer: nil) -> String - inflate(deflate_string, buffer: nil) { |chunk| ... } -> nil - -Inputs `deflate_string` into the inflate stream and returns the output from -the stream. Calling this method, both the input and the output buffer of the -stream are flushed. If string is `nil`, this method finishes the stream, just -like Zlib::ZStream#finish. - -If a block is given consecutive inflated chunks from the `deflate_string` are -yielded to the block and `nil` is returned. - -If a :buffer keyword argument is given and not nil: - -* The :buffer keyword should be a String, and will used as the output - buffer. Using this option can reuse the memory required during inflation. -* When not passing a block, the return value will be the same object as the - :buffer keyword argument. -* When passing a block, the yielded chunks will be the same value as the - :buffer keyword argument. - -Raises a Zlib::NeedDict exception if a preset dictionary is needed to -decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then call -this method again with an empty string to flush the stream: - - inflater = Zlib::Inflate.new - - begin - out = inflater.inflate compressed - rescue Zlib::NeedDict - # ensure the dictionary matches the stream's required dictionary - raise unless inflater.adler == Zlib.adler32(dictionary) - - inflater.set_dictionary dictionary - inflater.inflate '' - end - - # ... - - inflater.close - -See also Zlib::Inflate.new - -## initialize(*args) [](#method-i-initialize) -call-seq: - Zlib::Inflate.new(window_bits = Zlib::MAX_WBITS) - -Creates a new inflate stream for decompression. `window_bits` sets the size -of the history buffer and can have the following values: - -0 -: Have inflate use the window size from the zlib header of the compressed - stream. - - -(8..15) -: Overrides the window size of the inflate header in the compressed stream. - The window size must be greater than or equal to the window size of the - compressed stream. - - -Greater than 15 -: Add 32 to window_bits to enable zlib and gzip decoding with automatic - header detection, or add 16 to decode only the gzip format (a - Zlib::DataError will be raised for a non-gzip stream). - - -(-8..-15) -: Enables raw deflate mode which will not generate a check value, and will - not look for any check values for comparison at the end of the stream. - - This is for use with other formats that use the deflate compressed data - format such as zip which provide their own check values. - - -## Example - - open "compressed.file" do |compressed_io| - zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32) - - begin - open "uncompressed.file", "w+" do |uncompressed_io| - uncompressed_io << zi.inflate(compressed_io.read) - end - ensure - zi.close - end - end - -## set_dictionary(dic) [](#method-i-set_dictionary) -Sets the preset dictionary and returns `string`. This method is available -just only after a Zlib::NeedDict exception was raised. See zlib.h for -details. - -## sync(src) [](#method-i-sync) -Inputs `string` into the end of input buffer and skips data until a full flush -point can be found. If the point is found in the buffer, this method flushes -the buffer and returns false. Otherwise it returns `true` and the following -data of full flush point is preserved in the buffer. - -**@overload** [] - -## sync_point?() [](#method-i-sync_point?) -Quoted verbatim from original documentation: - - What is this? - -`:)` - -**@return** [Boolean] - diff --git a/example/ruby/Zlib/MemError.md b/example/ruby/Zlib/MemError.md deleted file mode 100644 index c0244df..0000000 --- a/example/ruby/Zlib/MemError.md +++ /dev/null @@ -1,10 +0,0 @@ -# Exception: Zlib::MemError -**Inherits:** Zlib::Error - - -Subclass of Zlib::Error - -When zlib returns a Z_MEM_ERROR, usually if there was not enough memory. - - - diff --git a/example/ruby/Zlib/NeedDict.md b/example/ruby/Zlib/NeedDict.md deleted file mode 100644 index 21186ae..0000000 --- a/example/ruby/Zlib/NeedDict.md +++ /dev/null @@ -1,13 +0,0 @@ -# Exception: Zlib::NeedDict -**Inherits:** Zlib::Error - - -Subclass of Zlib::Error - -When zlib returns a Z_NEED_DICT if a preset dictionary is needed at this -point. - -Used by Zlib::Inflate.inflate and `Zlib.inflate` - - - diff --git a/example/ruby/Zlib/StreamEnd.md b/example/ruby/Zlib/StreamEnd.md deleted file mode 100644 index 5b0361f..0000000 --- a/example/ruby/Zlib/StreamEnd.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: Zlib::StreamEnd -**Inherits:** Zlib::Error - - -Subclass of Zlib::Error - -When zlib returns a Z_STREAM_END is return if the end of the compressed data -has been reached and all uncompressed out put has been produced. - - - diff --git a/example/ruby/Zlib/StreamError.md b/example/ruby/Zlib/StreamError.md deleted file mode 100644 index b9426d5..0000000 --- a/example/ruby/Zlib/StreamError.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: Zlib::StreamError -**Inherits:** Zlib::Error - - -Subclass of Zlib::Error - -When zlib returns a Z_STREAM_ERROR, usually if the stream state was -inconsistent. - - - diff --git a/example/ruby/Zlib/VersionError.md b/example/ruby/Zlib/VersionError.md deleted file mode 100644 index 402256d..0000000 --- a/example/ruby/Zlib/VersionError.md +++ /dev/null @@ -1,11 +0,0 @@ -# Exception: Zlib::VersionError -**Inherits:** Zlib::Error - - -Subclass of Zlib::Error - -When zlib returns a Z_VERSION_ERROR, usually if the zlib library version is -incompatible with the version assumed by the caller. - - - diff --git a/example/ruby/Zlib/ZStream.md b/example/ruby/Zlib/ZStream.md deleted file mode 100644 index 7017236..0000000 --- a/example/ruby/Zlib/ZStream.md +++ /dev/null @@ -1,141 +0,0 @@ -# Class: Zlib::ZStream -**Inherits:** Object - - -Zlib::ZStream is the abstract class for the stream which handles the -compressed data. The operations are defined in the subclasses: Zlib::Deflate -for compression, and Zlib::Inflate for decompression. - -An instance of Zlib::ZStream has one stream (struct zstream in the source) and -two variable-length buffers which associated to the input (next_in) of the -stream and the output (next_out) of the stream. In this document, "input -buffer" means the buffer for input, and "output buffer" means the buffer for -output. - -Data input into an instance of Zlib::ZStream are temporally stored into the -end of input buffer, and then data in input buffer are processed from the -beginning of the buffer until no more output from the stream is produced (i.e. -until avail_out > 0 after processing). During processing, output buffer is -allocated and expanded automatically to hold all output data. - -Some particular instance methods consume the data in output buffer and return -them as a String. - -Here is an ascii art for describing above: - - +================ an instance of Zlib::ZStream ================+ - || || - || +--------+ +-------+ +--------+ || - || +--| output |<---------|zstream|<---------| input |<--+ || - || | | buffer | next_out+-------+next_in | buffer | | || - || | +--------+ +--------+ | || - || | | || - +===|======================================================|===+ - | | - v | - "output data" "input data" - -If an error occurs during processing input buffer, an exception which is a -subclass of Zlib::Error is raised. At that time, both input and output buffer -keep their conditions at the time when the error occurs. - -## Method Catalogue - -Many of the methods in this class are fairly low-level and unlikely to be of -interest to users. In fact, users are unlikely to use this class directly; -rather they will be interested in Zlib::Inflate and Zlib::Deflate. - -The higher level methods are listed below. - -* #total_in -* #total_out -* #data_type -* #adler -* #reset -* #finish -* #finished? -* #close -* #closed? - - - -#Instance Methods -## adler() [](#method-i-adler) -Returns the adler-32 checksum. - -## avail_in() [](#method-i-avail_in) -Returns bytes of data in the input buffer. Normally, returns 0. - -## avail_out() [](#method-i-avail_out) -Returns number of bytes of free spaces in output buffer. Because the free -space is allocated automatically, this method returns 0 normally. - -## avail_out=(size) [](#method-i-avail_out=) -Allocates `size` bytes of free space in the output buffer. If there are more -than `size` bytes already in the buffer, the buffer is truncated. Because free -space is allocated automatically, you usually don't need to use this method. - -## close() [](#method-i-close) -Closes the stream. All operations on the closed stream will raise an -exception. - -## closed?() [](#method-i-closed?) -Returns true if the stream is closed. - -**@return** [Boolean] - -## data_type() [](#method-i-data_type) -Guesses the type of the data which have been inputted into the stream. The -returned value is either `BINARY`, `ASCII`, or `UNKNOWN`. - -## end() [](#method-i-end) -Closes the stream. All operations on the closed stream will raise an -exception. - -## ended?() [](#method-i-ended?) -Returns true if the stream is closed. - -**@return** [Boolean] - -## finish() [](#method-i-finish) -Finishes the stream and flushes output buffer. If a block is given each chunk -is yielded to the block until the input buffer has been flushed to the output -buffer. - -**@overload** [] - -**@overload** [] - -## finished?() [](#method-i-finished?) -Returns true if the stream is finished. - -**@return** [Boolean] - -## flush_next_in() [](#method-i-flush_next_in) - -**@overload** [] - -## flush_next_out() [](#method-i-flush_next_out) -Flushes output buffer and returns all data in that buffer. If a block is -given each chunk is yielded to the block until the current output buffer has -been flushed. - -**@overload** [] - -**@overload** [] - -## reset() [](#method-i-reset) -Resets and initializes the stream. All data in both input and output buffer -are discarded. - -## stream_end?() [](#method-i-stream_end?) -Returns true if the stream is finished. - -**@return** [Boolean] - -## total_in() [](#method-i-total_in) -Returns the total bytes of the input data to the stream. FIXME - -## total_out() [](#method-i-total_out) -Returns the total bytes of the output data from the stream. FIXME - diff --git a/example/ruby/ZombieHunter.md b/example/ruby/ZombieHunter.md deleted file mode 100644 index 70dc74a..0000000 --- a/example/ruby/ZombieHunter.md +++ /dev/null @@ -1,9 +0,0 @@ -# Module: ZombieHunter - - - - - -#Instance Methods -## after_teardown() [](#method-i-after_teardown) - diff --git a/example/ruby/fatal.md b/example/ruby/fatal.md deleted file mode 100644 index d96a5c6..0000000 --- a/example/ruby/fatal.md +++ /dev/null @@ -1,9 +0,0 @@ -# Exception: fatal -**Inherits:** Exception - - -`fatal` is an Exception that is raised when Ruby has encountered a fatal error -and must exit. - - -